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>
This commit is contained in:
commit
b4fca397dd
@ -21,7 +21,7 @@
|
|||||||
#include "libavutil/avassert.h"
|
#include "libavutil/avassert.h"
|
||||||
#include "libavutil/pixdesc.h"
|
#include "libavutil/pixdesc.h"
|
||||||
#include "formats.h"
|
#include "formats.h"
|
||||||
|
#include "internal.h"
|
||||||
#include "vaapi_vpp.h"
|
#include "vaapi_vpp.h"
|
||||||
|
|
||||||
int ff_vaapi_vpp_query_formats(AVFilterContext *avctx)
|
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;
|
ctx->va_config = VA_INVALID_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
av_buffer_unref(&ctx->output_frames_ref);
|
|
||||||
av_buffer_unref(&ctx->device_ref);
|
av_buffer_unref(&ctx->device_ref);
|
||||||
ctx->hwctx = NULL;
|
ctx->hwctx = NULL;
|
||||||
}
|
}
|
||||||
@ -99,6 +98,7 @@ int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
|
|||||||
VAAPIVPPContext *ctx = avctx->priv;
|
VAAPIVPPContext *ctx = avctx->priv;
|
||||||
AVVAAPIHWConfig *hwconfig = NULL;
|
AVVAAPIHWConfig *hwconfig = NULL;
|
||||||
AVHWFramesConstraints *constraints = NULL;
|
AVHWFramesConstraints *constraints = NULL;
|
||||||
|
AVHWFramesContext *output_frames;
|
||||||
AVVAAPIFramesContext *va_frames;
|
AVVAAPIFramesContext *va_frames;
|
||||||
VAStatus vas;
|
VAStatus vas;
|
||||||
int err, i;
|
int err, i;
|
||||||
@ -172,34 +172,35 @@ int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->output_frames_ref = av_hwframe_ctx_alloc(ctx->device_ref);
|
outlink->hw_frames_ctx = av_hwframe_ctx_alloc(ctx->device_ref);
|
||||||
if (!ctx->output_frames_ref) {
|
if (!outlink->hw_frames_ctx) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Failed to create HW frame context "
|
av_log(avctx, AV_LOG_ERROR, "Failed to create HW frame context "
|
||||||
"for output.\n");
|
"for output.\n");
|
||||||
err = AVERROR(ENOMEM);
|
err = AVERROR(ENOMEM);
|
||||||
goto fail;
|
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;
|
output_frames->format = AV_PIX_FMT_VAAPI;
|
||||||
ctx->output_frames->sw_format = ctx->output_format;
|
output_frames->sw_format = ctx->output_format;
|
||||||
ctx->output_frames->width = ctx->output_width;
|
output_frames->width = ctx->output_width;
|
||||||
ctx->output_frames->height = ctx->output_height;
|
output_frames->height = ctx->output_height;
|
||||||
|
|
||||||
// The number of output frames we need is determined by what follows
|
output_frames->initial_pool_size = 4;
|
||||||
// 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;
|
|
||||||
|
|
||||||
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) {
|
if (err < 0) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Failed to initialise VAAPI frame "
|
av_log(avctx, AV_LOG_ERROR, "Failed to initialise VAAPI frame "
|
||||||
"context for output: %d\n", err);
|
"context for output: %d\n", err);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
va_frames = ctx->output_frames->hwctx;
|
va_frames = output_frames->hwctx;
|
||||||
|
|
||||||
av_assert0(ctx->va_context == VA_INVALID_ID);
|
av_assert0(ctx->va_context == VA_INVALID_ID);
|
||||||
vas = vaCreateContext(ctx->hwctx->display, ctx->va_config,
|
vas = vaCreateContext(ctx->hwctx->display, ctx->va_config,
|
||||||
@ -222,18 +223,12 @@ int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
|
|||||||
goto fail;
|
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_freep(&hwconfig);
|
||||||
av_hwframe_constraints_free(&constraints);
|
av_hwframe_constraints_free(&constraints);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
av_buffer_unref(&ctx->output_frames_ref);
|
av_buffer_unref(&outlink->hw_frames_ctx);
|
||||||
av_freep(&hwconfig);
|
av_freep(&hwconfig);
|
||||||
av_hwframe_constraints_free(&constraints);
|
av_hwframe_constraints_free(&constraints);
|
||||||
return err;
|
return err;
|
||||||
@ -374,6 +369,5 @@ void ff_vaapi_vpp_ctx_uninit(AVFilterContext *avctx)
|
|||||||
ctx->pipeline_uninit(avctx);
|
ctx->pipeline_uninit(avctx);
|
||||||
|
|
||||||
av_buffer_unref(&ctx->input_frames_ref);
|
av_buffer_unref(&ctx->input_frames_ref);
|
||||||
av_buffer_unref(&ctx->output_frames_ref);
|
|
||||||
av_buffer_unref(&ctx->device_ref);
|
av_buffer_unref(&ctx->device_ref);
|
||||||
}
|
}
|
||||||
|
@ -40,9 +40,6 @@ typedef struct VAAPIVPPContext {
|
|||||||
AVBufferRef *input_frames_ref;
|
AVBufferRef *input_frames_ref;
|
||||||
AVHWFramesContext *input_frames;
|
AVHWFramesContext *input_frames;
|
||||||
|
|
||||||
AVBufferRef *output_frames_ref;
|
|
||||||
AVHWFramesContext *output_frames;
|
|
||||||
|
|
||||||
enum AVPixelFormat output_format;
|
enum AVPixelFormat output_format;
|
||||||
int output_width; // computed width
|
int output_width; // computed width
|
||||||
int output_height; // computed height
|
int output_height; // computed height
|
||||||
|
Loading…
x
Reference in New Issue
Block a user