Skip to content
Snippets Groups Projects
Commit 6e050e00 authored by Mark Thompson's avatar Mark Thompson
Browse files

Merge commit 'e4cdef00'


* commit 'e4cdef00':
  vf_scale_qsv: Support increasing hardware frame pool size

Merged-by: default avatarMark Thompson <sw@jkqxz.net>
parents a5ed0794 e4cdef00
No related branches found
No related tags found
No related merge requests found
...@@ -71,7 +71,6 @@ enum var_name { ...@@ -71,7 +71,6 @@ enum var_name {
typedef struct QSVScaleContext { typedef struct QSVScaleContext {
const AVClass *class; const AVClass *class;
AVBufferRef *out_frames_ref;
/* a clone of the main session, used internally for scaling */ /* a clone of the main session, used internally for scaling */
mfxSession session; mfxSession session;
...@@ -134,7 +133,6 @@ static void qsvscale_uninit(AVFilterContext *ctx) ...@@ -134,7 +133,6 @@ static void qsvscale_uninit(AVFilterContext *ctx)
MFXClose(s->session); MFXClose(s->session);
s->session = NULL; s->session = NULL;
} }
av_buffer_unref(&s->out_frames_ref);
av_freep(&s->mem_ids_in); av_freep(&s->mem_ids_in);
av_freep(&s->mem_ids_out); av_freep(&s->mem_ids_out);
...@@ -165,6 +163,7 @@ static int init_out_pool(AVFilterContext *ctx, ...@@ -165,6 +163,7 @@ static int init_out_pool(AVFilterContext *ctx,
int out_width, int out_height) int out_width, int out_height)
{ {
QSVScaleContext *s = ctx->priv; QSVScaleContext *s = ctx->priv;
AVFilterLink *outlink = ctx->outputs[0];
AVHWFramesContext *in_frames_ctx; AVHWFramesContext *in_frames_ctx;
AVHWFramesContext *out_frames_ctx; AVHWFramesContext *out_frames_ctx;
...@@ -185,21 +184,25 @@ static int init_out_pool(AVFilterContext *ctx, ...@@ -185,21 +184,25 @@ static int init_out_pool(AVFilterContext *ctx,
in_format = in_frames_ctx->sw_format; in_format = in_frames_ctx->sw_format;
out_format = (s->format == AV_PIX_FMT_NONE) ? in_format : s->format; out_format = (s->format == AV_PIX_FMT_NONE) ? in_format : s->format;
s->out_frames_ref = av_hwframe_ctx_alloc(in_frames_ctx->device_ref); outlink->hw_frames_ctx = av_hwframe_ctx_alloc(in_frames_ctx->device_ref);
if (!s->out_frames_ref) if (!outlink->hw_frames_ctx)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
out_frames_ctx = (AVHWFramesContext*)s->out_frames_ref->data; out_frames_ctx = (AVHWFramesContext*)outlink->hw_frames_ctx->data;
out_frames_hwctx = out_frames_ctx->hwctx; out_frames_hwctx = out_frames_ctx->hwctx;
out_frames_ctx->format = AV_PIX_FMT_QSV; out_frames_ctx->format = AV_PIX_FMT_QSV;
out_frames_ctx->width = FFALIGN(out_width, 32); out_frames_ctx->width = FFALIGN(out_width, 32);
out_frames_ctx->height = FFALIGN(out_height, 32); out_frames_ctx->height = FFALIGN(out_height, 32);
out_frames_ctx->sw_format = out_format; out_frames_ctx->sw_format = out_format;
out_frames_ctx->initial_pool_size = 32; out_frames_ctx->initial_pool_size = 4;
out_frames_hwctx->frame_type = in_frames_hwctx->frame_type; out_frames_hwctx->frame_type = in_frames_hwctx->frame_type;
ret = av_hwframe_ctx_init(s->out_frames_ref); ret = ff_filter_init_hw_frames(ctx, outlink, 32);
if (ret < 0)
return ret;
ret = av_hwframe_ctx_init(outlink->hw_frames_ctx);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -266,7 +269,7 @@ static int init_out_session(AVFilterContext *ctx) ...@@ -266,7 +269,7 @@ static int init_out_session(AVFilterContext *ctx)
QSVScaleContext *s = ctx->priv; QSVScaleContext *s = ctx->priv;
AVHWFramesContext *in_frames_ctx = (AVHWFramesContext*)ctx->inputs[0]->hw_frames_ctx->data; AVHWFramesContext *in_frames_ctx = (AVHWFramesContext*)ctx->inputs[0]->hw_frames_ctx->data;
AVHWFramesContext *out_frames_ctx = (AVHWFramesContext*)s->out_frames_ref->data; AVHWFramesContext *out_frames_ctx = (AVHWFramesContext*)ctx->outputs[0]->hw_frames_ctx->data;
AVQSVFramesContext *in_frames_hwctx = in_frames_ctx->hwctx; AVQSVFramesContext *in_frames_hwctx = in_frames_ctx->hwctx;
AVQSVFramesContext *out_frames_hwctx = out_frames_ctx->hwctx; AVQSVFramesContext *out_frames_hwctx = out_frames_ctx->hwctx;
AVQSVDeviceContext *device_hwctx = in_frames_ctx->device_ctx->hwctx; AVQSVDeviceContext *device_hwctx = in_frames_ctx->device_ctx->hwctx;
...@@ -407,8 +410,6 @@ static int init_out_session(AVFilterContext *ctx) ...@@ -407,8 +410,6 @@ static int init_out_session(AVFilterContext *ctx)
static int init_scale_session(AVFilterContext *ctx, int in_width, int in_height, static int init_scale_session(AVFilterContext *ctx, int in_width, int in_height,
int out_width, int out_height) int out_width, int out_height)
{ {
QSVScaleContext *s = ctx->priv;
int ret; int ret;
qsvscale_uninit(ctx); qsvscale_uninit(ctx);
...@@ -421,11 +422,6 @@ static int init_scale_session(AVFilterContext *ctx, int in_width, int in_height, ...@@ -421,11 +422,6 @@ static int init_scale_session(AVFilterContext *ctx, int in_width, int in_height,
if (ret < 0) if (ret < 0)
return ret; return ret;
av_buffer_unref(&ctx->outputs[0]->hw_frames_ctx);
ctx->outputs[0]->hw_frames_ctx = av_buffer_ref(s->out_frames_ref);
if (!ctx->outputs[0]->hw_frames_ctx)
return AVERROR(ENOMEM);
return 0; return 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment