intel/vpl-gpu-rt

GOP Size Not Being Passed from FFmpeg to Libvpl

Deathproof76 opened this issue · 4 comments

Copied from intel/media-driver#1576

System information

11th Gen Intel(R) Core(TM) i5-11400 @ 2.60GHz
00:02.0 VGA compatible controller [0300]: Intel Corporation RocketLake-S GT1 [UHD Graphics 730] [8086:4c8b] (rev 04)
03:00.0 VGA compatible controller [0300]: Intel Corporation DG2 [Arc A380] [8086:56a5] (rev 05)

Which component impacted?

Decode probably

Is it regression? Good in old configuration?

None

What happened?

Wenn trying to transcode a h264 or hevc file via FFmpeg the following error can be seen in the output:

[h264_qsv @ 0x5633a4634580] A decode call did not consume any data: expect more data at input (-10)

I'm using FFmpeg with Onevpl/Onevpl-Gpu and cartwheel patches applied with the following configuration:

configuration: --prefix=/home/max/.local/ --extra-cflags=-I/opt/intel/mediasdk/include --extra-ldflags=-L/opt/intel/mediasdk/lib --extra-ldflags=-L/opt/intel/mediasdk/plugins --enable-vaapi --enable-opencl --disable-debug --enable-libvpl --enable-libvorbis --enable-libvpx --enable-libdrm --enable-gpl --cpu=native --enable-libfdk-aac --enable-libx264 --enable-libx265 --extra-libs=-lpthread --enable-nonfree
  libavutil      57. 42.100 / 57. 42.100
  libavcodec     59. 52.102 / 59. 52.102
  libavformat    59. 34.101 / 59. 34.101
  libavdevice    59.  8.101 / 59.  8.101
  libavfilter     8. 50.100 /  8. 50.100
  libswscale      6.  8.112 /  6.  8.112
  libswresample   4.  9.100 /  4.  9.100
  libpostproc    56.  7.100 / 56.  7.100

The resulting file works quality/filesize are as expected but has only a single I-Frame of the beginning of the file which leads to problems when seeking during playback. See here for further info. Also here an affected sample file (simpsons movie trailer).

Most likely: If using the intel onevpl libvpl and the latest ffmpeg from git, the GOP size isn't being passed from ffmpeg to the libvpl, so it defaults to 65535.

Command used for the related file:

ffmpeg -hwaccel_output_format qsv -qsv_device /dev/dri/renderD129 -c:v h264_qsv -i simpsons_trailer.mkv -map 0 -b:v 2500k -minrate 500k -maxrate 5000k -c:v hevc_qsv -c:a copy simpson_trailer_defect.mkv

Output of ffprobe -show_frames input.mkv -hide_banner | grep pict_type=I
Input #0, matroska,webm, from 'problem.mkv':
  Metadata:
    title           : The Simpsons Movie
    ARTIST          : Fox
    DATE_RELEASED   : 2007
    GENRE           : Trailer
    ENCODER         : Lavf59.34.101
  Duration: 00:02:17.28, start: 0.000000, bitrate: 2562 kb/s
  Stream #0:0: Video: hevc (Main), yuv420p(tv, bt709, progressive), 1920x800 [SAR 1:1 DAR 12:5], 23.98 fps, 23.98 tbr, 1k tbn (default)
    Metadata:
      ENCODER         : Lavc59.52.102 hevc_qsv
      DURATION        : 00:02:17.262000000
  Stream #0:1: Audio: aac (LC), 44100 Hz, stereo, fltp (default)
    Metadata:
      title           : Stereo
      DURATION        : 00:02:17.276000000
pict_type=I

Vaapi transcode seems to be working

What's the usage scenario when you are seeing the problem?

Transcode for media delivery

Debug Information

Env: Ubuntu 22.04 with 5.17.0-1019-oem, Arc A380 using the gpu-backport.
also current and built from source media-driver with -DENABLE_PRODUCTION_KMD=ON, gmmlib, libva, Libva utils

ls /dev/dri
by-path  card0  card1  renderD128  renderD129

First GPU is a RKL from a 11400K.

vainfo --device /dev/dri/renderD129 --display drm
Trying display: drm
libva info: VA-API version 1.17.0
libva info: Trying to open /usr/local/lib/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_17
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.17 (libva 2.17.0.1)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 22.6.4 (7cef45fcc)
vainfo: Supported profile and entrypoints
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileNone                   : VAEntrypointStats
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointFEI
      VAProfileH264Main               : VAEntrypointEncSliceLP
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointFEI
      VAProfileH264High               : VAEntrypointEncSliceLP
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointFEI
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointFEI
      VAProfileHEVCMain               : VAEntrypointEncSliceLP
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointEncSlice
      VAProfileHEVCMain10             : VAEntrypointEncSliceLP
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile1            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD
      VAProfileVP9Profile3            : VAEntrypointVLD
      VAProfileHEVCMain12             : VAEntrypointVLD
      VAProfileHEVCMain12             : VAEntrypointEncSlice
      VAProfileHEVCMain422_10         : VAEntrypointVLD
      VAProfileHEVCMain422_10         : VAEntrypointEncSlice
      VAProfileHEVCMain422_12         : VAEntrypointVLD
      VAProfileHEVCMain422_12         : VAEntrypointEncSlice
      VAProfileHEVCMain444            : VAEntrypointVLD
      VAProfileHEVCMain444            : VAEntrypointEncSliceLP
      VAProfileHEVCMain444_10         : VAEntrypointVLD
      VAProfileHEVCMain444_10         : VAEntrypointEncSliceLP
      VAProfileHEVCMain444_12         : VAEntrypointVLD
      VAProfileHEVCSccMain            : VAEntrypointVLD
      VAProfileHEVCSccMain            : VAEntrypointEncSliceLP
      VAProfileHEVCSccMain10          : VAEntrypointVLD
      VAProfileHEVCSccMain10          : VAEntrypointEncSliceLP
      VAProfileHEVCSccMain444         : VAEntrypointVLD
      VAProfileHEVCSccMain444         : VAEntrypointEncSliceLP
      VAProfileAV1Profile0            : VAEntrypointVLD
      VAProfileHEVCSccMain444_10      : VAEntrypointVLD
      VAProfileHEVCSccMain444_10      : VAEntrypointEncSliceLP

Do you want to contribute a patch to fix the issue?

None

Jexu commented

As what mentioned in bellow comment. Vpl is better to add strict check for GOP size of all other codecs as what avc and mpeg2 do.

_I can only find the mfx.GopPicSize == 0 handling in H264 and MPEG2 in VPL codes.
So the issue cannot be reproduced in these codecs.
Maybe you guys should check out mfx.GopPicSize for the rest of the codecs such as HEVC and AV1.

H264 encode_hw

if (par.mfx.GopPicSize == 0)
{
    mfxU32 maxScale = (par.calcParam.numTemporalLayer) > 0
        ? par.calcParam.scale[par.calcParam.numTemporalLayer - 1]
        : 1;
    par.mfx.GopPicSize = mfxU16((256 + maxScale - 1) / maxScale * maxScale);
}

MPEG2 encode_hw

if (par->mfxVideoParams.mfx.GopPicSize == 0)
{
    par->mfxVideoParams.mfx.GopPicSize = 24;
}_

libavcodec/qsvenc: Let runtime to set default parameter.

Unset qsv_h264 and qsv_hevc's default settings. Let runtime to decide
these parameters, so that it can choose the best parameter and ffmpeg-qsv
can keep up with runtime's update.

FFmpeg/FFmpeg@a3c0a3e

Auto Created VSMGWL-66143 for further analysis.

FFmpeg/FFmpeg@a7f24d7
This FFmpeg commit should have fixed this issue.