[FFmpeg-devel] [PATCH] lavu/hwcontext_qsv: update crop width/height when mapping frames

Rodger Combs rodger.combs at gmail.com
Fri Sep 13 09:27:36 EEST 2019


This happens with any use of the hwmap filter in the derive_device configuration with input being HEVC decoded via dxva2 with dimensions that aren't 128-pixel-aligned and output being QSV; eg:
ffmpeg.exe -codec:0 hevc -hwaccel:0 dxva2 -hwaccel_output_format:0 dxva2_vld test.mkv -filter_complex '[0:0]hwmap=derive_device=qsv[0];[0]scale_qsv=format=nv12[1]' -map[1] -codec:0 h264_qsv output.mkv

> On Sep 12, 2019, at 07:59, Li, Zhong <zhong.li at intel.com> wrote:
> 
>> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of Rodger
>> Combs
>> Sent: Thursday, September 12, 2019 11:59 AM
>> To: ffmpeg-devel at ffmpeg.org
>> Subject: [FFmpeg-devel] [PATCH] lavu/hwcontext_qsv: update crop width/height
>> when mapping frames
>> 
>> This fixes an issue where the context could be configured with one resolution, but
>> incoming frames could have another, and our output AVFrames wouldn't match
>> the underlying surfaces' resolution, which is usually the value that MFX code uses.
>> 
>> In particular, this would happen when mapping from DXVA2 decoders, since
>> DXVA2 aligns the width/height fields in its context to the required alignment for
>> the particular codec being used, and those values are then propagated into the
>> QSV context, rather than the crop dimensions.
>> ---
>> libavutil/hwcontext_qsv.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>> 
>> diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index
>> 8f9838d7d8..fe5a705c19 100644
>> --- a/libavutil/hwcontext_qsv.c
>> +++ b/libavutil/hwcontext_qsv.c
>> @@ -1031,8 +1031,8 @@ static int qsv_map_to(AVHWFramesContext *dst_ctx,
>>     if (err)
>>         return err;
>> 
>> -    dst->width   = src->width;
>> -    dst->height  = src->height;
>> +    hwctx->surfaces[i].Info.CropW = dst->width  = src->width;
>> +    hwctx->surfaces[i].Info.CropH = dst->height = src->height;
>>     dst->data[3] = (uint8_t*)&hwctx->surfaces[i];
>> 
>>     return 0;
>> --
>> 2.21.0
> 
> Patch looks good. 
> Could you please share detailed command line and clip to reproduce the issue?
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".



More information about the ffmpeg-devel mailing list