From 35f87a4ba017f2174f8d21281fddcf8999491d9e Mon Sep 17 00:00:00 2001 From: agalin89 Date: Sat, 28 Nov 2020 15:59:44 +0000 Subject: qsv: fixed corrupted images in scale_qsv filter --- .../ffmpeg/A22-qsv-scale-fix-green-stripes.patch | 35 ++++++++++++++++++++++ libhb/qsv_common.c | 4 +++ 2 files changed, 39 insertions(+) create mode 100644 contrib/ffmpeg/A22-qsv-scale-fix-green-stripes.patch diff --git a/contrib/ffmpeg/A22-qsv-scale-fix-green-stripes.patch b/contrib/ffmpeg/A22-qsv-scale-fix-green-stripes.patch new file mode 100644 index 000000000..15170fa50 --- /dev/null +++ b/contrib/ffmpeg/A22-qsv-scale-fix-green-stripes.patch @@ -0,0 +1,35 @@ +diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c +index 82bb64eb42..2691d1a1fa 100644 +--- a/libavfilter/vf_scale_qsv.c ++++ b/libavfilter/vf_scale_qsv.c +@@ -280,7 +280,7 @@ static mfxStatus frame_get_hdl(mfxHDL pthis, mfxMemId mid, mfxHDL *hdl) + return MFX_ERR_NONE; + } + +-static int init_out_session(AVFilterContext *ctx) ++static int init_out_session(AVFilterContext *ctx, int in_width, int in_height) + { + + QSVScaleContext *s = ctx->priv; +@@ -395,8 +395,11 @@ static int init_out_session(AVFilterContext *ctx) + sizeof(*s->mem_ids_in)); + if (!s->mem_ids_in) + return AVERROR(ENOMEM); +- for (i = 0; i < in_frames_hwctx->nb_surfaces; i++) ++ for (i = 0; i < in_frames_hwctx->nb_surfaces; i++) { ++ in_frames_hwctx->surfaces[i].Info.CropW = in_width; ++ in_frames_hwctx->surfaces[i].Info.CropH = in_height; + s->mem_ids_in[i] = in_frames_hwctx->surfaces[i].Data.MemId; ++ } + s->nb_mem_ids_in = in_frames_hwctx->nb_surfaces; + + s->mem_ids_out = av_mallocz_array(out_frames_hwctx->nb_surfaces, +@@ -460,7 +463,7 @@ static int init_scale_session(AVFilterContext *ctx, int in_width, int in_height, + if (ret < 0) + return ret; + +- ret = init_out_session(ctx); ++ ret = init_out_session(ctx, in_width, in_height); + if (ret < 0) + return ret; + diff --git a/libhb/qsv_common.c b/libhb/qsv_common.c index 7997f9746..a07fe459c 100644 --- a/libhb/qsv_common.c +++ b/libhb/qsv_common.c @@ -3036,6 +3036,8 @@ hb_buffer_t* hb_qsv_copy_frame(hb_job_t *job, AVFrame *frame, int is_vpp) mfxHDLPair* input_pair = (mfxHDLPair*)input_surface->Data.MemId; // copy all surface fields *output_surface = *input_surface; + output_surface->Info.CropW = frame->width; + output_surface->Info.CropH = frame->height; if (hb_qsv_hw_filters_are_enabled(job)) { output_surface->Data.MemId = mid->handle_pair; @@ -3077,6 +3079,8 @@ hb_buffer_t* hb_qsv_copy_frame(hb_job_t *job, AVFrame *frame, int is_vpp) int output_index = (int)(intptr_t)mid->handle_pair->second == MFX_INFINITE ? 0 : (int)(intptr_t)mid->handle_pair->second; // copy all surface fields *output_surface = *input_surface; + output_surface->Info.CropW = frame->width; + output_surface->Info.CropH = frame->height; if (hb_qsv_hw_filters_are_enabled(job)) { // Make sure that we pass handle_pair to scale_qsv -- cgit v1.2.3