You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
avfilter/overlay_vaapi: handle secondary null input
Currently segfaults in this case. Signed-off-by: softworkz <softworkz@hotmail.com>
This commit is contained in:
@@ -106,6 +106,16 @@ static int overlay_vaapi_render_picture(AVFilterContext *avctx,
|
|||||||
params_id);
|
params_id);
|
||||||
|
|
||||||
|
|
||||||
|
vas = vaRenderPicture(ctx->hwctx->display, ctx->va_context,
|
||||||
|
¶ms_id, 1);
|
||||||
|
if (vas != VA_STATUS_SUCCESS) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "Failed to render parameter buffer: "
|
||||||
|
"%d (%s).\n", vas, vaErrorStr(vas));
|
||||||
|
err = AVERROR(EIO);
|
||||||
|
goto fail_after_begin;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (subpic_params) {
|
||||||
vas = vaCreateBuffer(ctx->hwctx->display, ctx->va_context,
|
vas = vaCreateBuffer(ctx->hwctx->display, ctx->va_context,
|
||||||
VAProcPipelineParameterBufferType,
|
VAProcPipelineParameterBufferType,
|
||||||
sizeof(*subpic_params), 1, subpic_params, &subpic_params_id);
|
sizeof(*subpic_params), 1, subpic_params, &subpic_params_id);
|
||||||
@@ -118,15 +128,6 @@ static int overlay_vaapi_render_picture(AVFilterContext *avctx,
|
|||||||
av_log(avctx, AV_LOG_DEBUG, "Pipeline subpic parameter buffer is %#x.\n",
|
av_log(avctx, AV_LOG_DEBUG, "Pipeline subpic parameter buffer is %#x.\n",
|
||||||
subpic_params_id);
|
subpic_params_id);
|
||||||
|
|
||||||
vas = vaRenderPicture(ctx->hwctx->display, ctx->va_context,
|
|
||||||
¶ms_id, 1);
|
|
||||||
if (vas != VA_STATUS_SUCCESS) {
|
|
||||||
av_log(avctx, AV_LOG_ERROR, "Failed to render parameter buffer: "
|
|
||||||
"%d (%s).\n", vas, vaErrorStr(vas));
|
|
||||||
err = AVERROR(EIO);
|
|
||||||
goto fail_after_begin;
|
|
||||||
}
|
|
||||||
|
|
||||||
vas = vaRenderPicture(ctx->hwctx->display, ctx->va_context,
|
vas = vaRenderPicture(ctx->hwctx->display, ctx->va_context,
|
||||||
&subpic_params_id, 1);
|
&subpic_params_id, 1);
|
||||||
if (vas != VA_STATUS_SUCCESS) {
|
if (vas != VA_STATUS_SUCCESS) {
|
||||||
@@ -135,6 +136,7 @@ static int overlay_vaapi_render_picture(AVFilterContext *avctx,
|
|||||||
err = AVERROR(EIO);
|
err = AVERROR(EIO);
|
||||||
goto fail_after_begin;
|
goto fail_after_begin;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
vas = vaEndPicture(ctx->hwctx->display, ctx->va_context);
|
vas = vaEndPicture(ctx->hwctx->display, ctx->va_context);
|
||||||
if (vas != VA_STATUS_SUCCESS) {
|
if (vas != VA_STATUS_SUCCESS) {
|
||||||
@@ -177,7 +179,7 @@ static int overlay_vaapi_blend(FFFrameSync *fs)
|
|||||||
AVFrame *input_main, *input_overlay;
|
AVFrame *input_main, *input_overlay;
|
||||||
AVFrame *output;
|
AVFrame *output;
|
||||||
VAProcPipelineParameterBuffer params, subpic_params;
|
VAProcPipelineParameterBuffer params, subpic_params;
|
||||||
VABlendState blend_state; /**< Blend State */
|
VABlendState blend_state = { 0 }; /**< Blend State */
|
||||||
VARectangle overlay_region, output_region;
|
VARectangle overlay_region, output_region;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
@@ -192,10 +194,6 @@ static int overlay_vaapi_blend(FFFrameSync *fs)
|
|||||||
av_get_pix_fmt_name(input_main->format),
|
av_get_pix_fmt_name(input_main->format),
|
||||||
input_main->width, input_main->height, input_main->pts);
|
input_main->width, input_main->height, input_main->pts);
|
||||||
|
|
||||||
av_log(avctx, AV_LOG_DEBUG, "Filter overlay: %s, %ux%u (%"PRId64").\n",
|
|
||||||
av_get_pix_fmt_name(input_overlay->format),
|
|
||||||
input_overlay->width, input_overlay->height, input_overlay->pts);
|
|
||||||
|
|
||||||
if (vpp_ctx->va_context == VA_INVALID_ID)
|
if (vpp_ctx->va_context == VA_INVALID_ID)
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
|
|
||||||
@@ -214,13 +212,6 @@ static int overlay_vaapi_blend(FFFrameSync *fs)
|
|||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
overlay_region = (VARectangle) {
|
|
||||||
.x = ctx->overlay_ox,
|
|
||||||
.y = ctx->overlay_oy,
|
|
||||||
.width = ctx->overlay_ow ? ctx->overlay_ow : input_overlay->width,
|
|
||||||
.height = ctx->overlay_oh ? ctx->overlay_oh : input_overlay->height,
|
|
||||||
};
|
|
||||||
|
|
||||||
output_region = (VARectangle) {
|
output_region = (VARectangle) {
|
||||||
.x = 0,
|
.x = 0,
|
||||||
.y = 0,
|
.y = 0,
|
||||||
@@ -228,6 +219,24 @@ static int overlay_vaapi_blend(FFFrameSync *fs)
|
|||||||
.height = output->height,
|
.height = output->height,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
params.filters = &vpp_ctx->filter_buffers[0];
|
||||||
|
params.num_filters = vpp_ctx->nb_filter_buffers;
|
||||||
|
|
||||||
|
params.output_region = &output_region;
|
||||||
|
params.output_background_color = VAAPI_VPP_BACKGROUND_BLACK;
|
||||||
|
|
||||||
|
if (input_overlay) {
|
||||||
|
av_log(avctx, AV_LOG_DEBUG, "Filter overlay: %s, %ux%u (%"PRId64").\n",
|
||||||
|
av_get_pix_fmt_name(input_overlay->format),
|
||||||
|
input_overlay->width, input_overlay->height, input_overlay->pts);
|
||||||
|
|
||||||
|
overlay_region = (VARectangle) {
|
||||||
|
.x = ctx->overlay_ox,
|
||||||
|
.y = ctx->overlay_oy,
|
||||||
|
.width = ctx->overlay_ow ? ctx->overlay_ow : input_overlay->width,
|
||||||
|
.height = ctx->overlay_oh ? ctx->overlay_oh : input_overlay->height,
|
||||||
|
};
|
||||||
|
|
||||||
if (overlay_region.x + overlay_region.width > input_main->width ||
|
if (overlay_region.x + overlay_region.width > input_main->width ||
|
||||||
overlay_region.y + overlay_region.height > input_main->height) {
|
overlay_region.y + overlay_region.height > input_main->height) {
|
||||||
av_log(ctx, AV_LOG_WARNING,
|
av_log(ctx, AV_LOG_WARNING,
|
||||||
@@ -235,12 +244,6 @@ static int overlay_vaapi_blend(FFFrameSync *fs)
|
|||||||
"will crop the overlay image according based on the main image.\n");
|
"will crop the overlay image according based on the main image.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
params.filters = &vpp_ctx->filter_buffers[0];
|
|
||||||
params.num_filters = vpp_ctx->nb_filter_buffers;
|
|
||||||
|
|
||||||
params.output_region = &output_region;
|
|
||||||
params.output_background_color = VAAPI_VPP_BACKGROUND_BLACK;
|
|
||||||
|
|
||||||
memcpy(&subpic_params, ¶ms, sizeof(subpic_params));
|
memcpy(&subpic_params, ¶ms, sizeof(subpic_params));
|
||||||
|
|
||||||
blend_state.flags = VA_BLEND_GLOBAL_ALPHA;
|
blend_state.flags = VA_BLEND_GLOBAL_ALPHA;
|
||||||
@@ -249,8 +252,9 @@ static int overlay_vaapi_blend(FFFrameSync *fs)
|
|||||||
|
|
||||||
subpic_params.surface = (VASurfaceID)(uintptr_t)input_overlay->data[3];
|
subpic_params.surface = (VASurfaceID)(uintptr_t)input_overlay->data[3];
|
||||||
subpic_params.output_region = &overlay_region;
|
subpic_params.output_region = &overlay_region;
|
||||||
|
}
|
||||||
|
|
||||||
err = overlay_vaapi_render_picture(avctx, ¶ms, &subpic_params, output);
|
err = overlay_vaapi_render_picture(avctx, ¶ms, input_overlay ? &subpic_params : NULL, output);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user