#include "libavutil/common.h"
#include "libavutil/eval.h"
#include "libavutil/hwcontext.h"
-#include "libavutil/hwcontext_cuda.h"
+#include "libavutil/hwcontext_cuda_internal.h"
#include "libavutil/internal.h"
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
static const enum AVPixelFormat pixel_formats[] = {
AV_PIX_FMT_CUDA, AV_PIX_FMT_NONE,
};
- AVFilterFormats *pix_fmts = ff_make_format_list(pixel_formats);
+ AVFilterFormats *pix_fmts = ff_make_format_list(pixel_formats);
- ff_set_common_formats(ctx, pix_fmts);
-
- return 0;
+ return ff_set_common_formats(ctx, pix_fmts);
}
static int init_stage(NPPScaleStageContext *stage, AVBufferRef *device_ctx)
/* figure out which stages need to be done */
if (in_width != out_width || in_height != out_height ||
- in_deinterleaved_format != out_deinterleaved_format)
+ in_deinterleaved_format != out_deinterleaved_format) {
s->stages[STAGE_RESIZE].stage_needed = 1;
+ if (s->interp_algo == NPPI_INTER_SUPER &&
+ (out_width > in_width && out_height > in_height)) {
+ s->interp_algo = NPPI_INTER_LANCZOS;
+ av_log(ctx, AV_LOG_WARNING, "super-sampling not supported for output dimensions, using lanczos instead.\n");
+ }
+ if (s->interp_algo == NPPI_INTER_SUPER &&
+ !(out_width < in_width && out_height < in_height)) {
+ s->interp_algo = NPPI_INTER_CUBIC;
+ av_log(ctx, AV_LOG_WARNING, "super-sampling not supported for output dimensions, using cubic instead.\n");
+ }
+ }
+
if (!s->stages[STAGE_RESIZE].stage_needed && in_format == out_format)
s->passthrough = 1;
}
if (last_stage < 0)
- return AVERROR_BUG;
+ return 0;
ctx->outputs[0]->hw_frames_ctx = av_buffer_ref(s->stages[last_stage].frames_ctx);
if (!ctx->outputs[0]->hw_frames_ctx)
return AVERROR(ENOMEM);
goto fail;
}
- av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den,
- (int64_t)in->sample_aspect_ratio.num * outlink->h * link->w,
- (int64_t)in->sample_aspect_ratio.den * outlink->w * link->h,
- INT_MAX);
-
- err = cuCtxPushCurrent(device_hwctx->cuda_ctx);
+ err = device_hwctx->internal->cuda_dl->cuCtxPushCurrent(device_hwctx->cuda_ctx);
if (err != CUDA_SUCCESS) {
ret = AVERROR_UNKNOWN;
goto fail;
ret = nppscale_scale(ctx, out, in);
- cuCtxPopCurrent(&dummy);
+ device_hwctx->internal->cuda_dl->cuCtxPopCurrent(&dummy);
if (ret < 0)
goto fail;
+ av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den,
+ (int64_t)in->sample_aspect_ratio.num * outlink->h * link->w,
+ (int64_t)in->sample_aspect_ratio.den * outlink->w * link->h,
+ INT_MAX);
+
av_frame_free(&in);
return ff_filter_frame(outlink, out);
fail: