• Wenbin Chen's avatar
    libavutil/hwcontext_qsv: clean padding when upload qsv frames · ed6c5c13
    Wenbin Chen authored
    Fix #7830
    When we upload a frame that is not padded as MSDK requires, we create a
    new AVFrame to copy data. The frame's padding data is uninitialized so
    it brings run to run problem. For example, If we run the following
    command serveral times we will get different outputs.
    
    ffmpeg -init_hw_device qsv=qsv:hw -qsv_device /dev/dri/renderD128 \
    -filter_hw_device qsv -f rawvideo -s 192x200 -pix_fmt p010 \
    -i 192x200_P010.yuv -vf "format=nv12,hwupload=extra_hw_frames=16" \
    -c:v hevc_qsv output.265
    
    According to https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#encoding-procedures
    "Note: It is the application's responsibility to fill pixels outside
    of crop window when it is smaller than frame to be encoded. Especially
    in cases when crops are not aligned to minimum coding block size (16
    for AVC, 8 for HEVC and VP9)"
    
    I add a function to fill padding area with border pixel to fix this
    run2run problem, and also move the new AVFrame to global structure
    to reduce redundant allocation operation to increase preformance.
    Signed-off-by: 's avatarWenbin Chen <wenbin.chen@intel.com>
    Signed-off-by: 's avatarHaihao Xiang <haihao.xiang@intel.com>
    ed6c5c13
hwcontext_qsv.c 52.9 KB