summaryrefslogtreecommitdiffstats
path: root/libavfilter/vaapi_vpp.c
diff options
context:
space:
mode:
authorMark Thompson <sw@jkqxz.net>2018-02-12 22:44:28 +0000
committerMark Thompson <sw@jkqxz.net>2018-02-12 22:44:28 +0000
commitb4fca397dd40e8c073c839716bcf5e240a348d73 (patch)
tree26006702a5f4c367d908ef3dd94f638a51c193e2 /libavfilter/vaapi_vpp.c
parentbcab11a1a23d8b156198db352bbdb932740a966c (diff)
parentb128be1748f3920a14a98307265df5f2d3433e1d (diff)
downloadffmpeg-streaming-b4fca397dd40e8c073c839716bcf5e240a348d73.zip
ffmpeg-streaming-b4fca397dd40e8c073c839716bcf5e240a348d73.tar.gz
Merge commit 'b128be1748f3920a14a98307265df5f2d3433e1d'
* commit 'b128be1748f3920a14a98307265df5f2d3433e1d': vf_*_vaapi: Support increasing hardware frame pool size Rewritten to apply to common VAAPI code rather than specific filters. Merged-by: Mark Thompson <sw@jkqxz.net>
Diffstat (limited to 'libavfilter/vaapi_vpp.c')
-rw-r--r--libavfilter/vaapi_vpp.c40
1 files changed, 17 insertions, 23 deletions
diff --git a/libavfilter/vaapi_vpp.c b/libavfilter/vaapi_vpp.c
index 9d91772..c5bbc3b 100644
--- a/libavfilter/vaapi_vpp.c
+++ b/libavfilter/vaapi_vpp.c
@@ -21,7 +21,7 @@
#include "libavutil/avassert.h"
#include "libavutil/pixdesc.h"
#include "formats.h"
-
+#include "internal.h"
#include "vaapi_vpp.h"
int ff_vaapi_vpp_query_formats(AVFilterContext *avctx)
@@ -63,7 +63,6 @@ void ff_vaapi_vpp_pipeline_uninit(AVFilterContext *avctx)
ctx->va_config = VA_INVALID_ID;
}
- av_buffer_unref(&ctx->output_frames_ref);
av_buffer_unref(&ctx->device_ref);
ctx->hwctx = NULL;
}
@@ -99,6 +98,7 @@ int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
VAAPIVPPContext *ctx = avctx->priv;
AVVAAPIHWConfig *hwconfig = NULL;
AVHWFramesConstraints *constraints = NULL;
+ AVHWFramesContext *output_frames;
AVVAAPIFramesContext *va_frames;
VAStatus vas;
int err, i;
@@ -172,34 +172,35 @@ int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
goto fail;
}
- ctx->output_frames_ref = av_hwframe_ctx_alloc(ctx->device_ref);
- if (!ctx->output_frames_ref) {
+ outlink->hw_frames_ctx = av_hwframe_ctx_alloc(ctx->device_ref);
+ if (!outlink->hw_frames_ctx) {
av_log(avctx, AV_LOG_ERROR, "Failed to create HW frame context "
"for output.\n");
err = AVERROR(ENOMEM);
goto fail;
}
- ctx->output_frames = (AVHWFramesContext*)ctx->output_frames_ref->data;
+ output_frames = (AVHWFramesContext*)outlink->hw_frames_ctx->data;
- ctx->output_frames->format = AV_PIX_FMT_VAAPI;
- ctx->output_frames->sw_format = ctx->output_format;
- ctx->output_frames->width = ctx->output_width;
- ctx->output_frames->height = ctx->output_height;
+ output_frames->format = AV_PIX_FMT_VAAPI;
+ output_frames->sw_format = ctx->output_format;
+ output_frames->width = ctx->output_width;
+ output_frames->height = ctx->output_height;
- // The number of output frames we need is determined by what follows
- // the filter. If it's an encoder with complex frame reference
- // structures then this could be very high.
- ctx->output_frames->initial_pool_size = 10;
+ output_frames->initial_pool_size = 4;
- err = av_hwframe_ctx_init(ctx->output_frames_ref);
+ err = ff_filter_init_hw_frames(avctx, outlink, 10);
+ if (err < 0)
+ goto fail;
+
+ err = av_hwframe_ctx_init(outlink->hw_frames_ctx);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to initialise VAAPI frame "
"context for output: %d\n", err);
goto fail;
}
- va_frames = ctx->output_frames->hwctx;
+ va_frames = output_frames->hwctx;
av_assert0(ctx->va_context == VA_INVALID_ID);
vas = vaCreateContext(ctx->hwctx->display, ctx->va_config,
@@ -222,18 +223,12 @@ int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
goto fail;
}
- outlink->hw_frames_ctx = av_buffer_ref(ctx->output_frames_ref);
- if (!outlink->hw_frames_ctx) {
- err = AVERROR(ENOMEM);
- goto fail;
- }
-
av_freep(&hwconfig);
av_hwframe_constraints_free(&constraints);
return 0;
fail:
- av_buffer_unref(&ctx->output_frames_ref);
+ av_buffer_unref(&outlink->hw_frames_ctx);
av_freep(&hwconfig);
av_hwframe_constraints_free(&constraints);
return err;
@@ -374,6 +369,5 @@ void ff_vaapi_vpp_ctx_uninit(AVFilterContext *avctx)
ctx->pipeline_uninit(avctx);
av_buffer_unref(&ctx->input_frames_ref);
- av_buffer_unref(&ctx->output_frames_ref);
av_buffer_unref(&ctx->device_ref);
}
OpenPOWER on IntegriCloud