After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 793836 - gstvaapidecode: Playback of succession of I-frames fails with AMD card
gstvaapidecode: Playback of succession of I-frames fails with AMD card
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer-vaapi
git master
Other Linux
: Normal normal
: 1.12.5
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2018-02-26 10:08 UTC by Alicia Boya García
Modified: 2018-03-21 12:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
dmsg|grep drm (9.19 KB, text/x-log)
2018-02-27 08:55 UTC, Philippe Normand
  Details
Test vector (1.92 KB, video/mp4)
2018-02-27 12:11 UTC, Alicia Boya García
  Details
GST_DEBUG=error,vaapi*:5 gst-play-1.0 i-frames-non-frag.mp4 (169 bytes, text/plain)
2018-02-27 12:29 UTC, Alicia Boya García
  Details
GST_DEBUG=*vaapi*:6,2 gst-play-1.0 i-frames-non-frag.mp4 (68.62 KB, text/plain)
2018-02-27 13:01 UTC, Alicia Boya García
  Details
dmesg | grep drm (4.15 KB, text/plain)
2018-02-27 13:02 UTC, Alicia Boya García
  Details
libs: decoder: h264: ensure num_ref_frames is greater than 0 (1.27 KB, patch)
2018-03-12 17:14 UTC, Julien Isorce
committed Details | Review

Description Alicia Boya García 2018-02-26 10:08:48 UTC
This simple file fails to play on master when using vaapi with amdgpu drivers in GStreamer master:

$ gst-launch-1.0 videotestsrc pattern=blink num-buffers=3 \
  ! video/x-raw, framerate=3/1 \
  ! x264enc key-int-max=1 \
  ! mp4mux faststart=true movie-timescale=30 trak-timescale=3 \
  ! filesink location=i-frames-non-frag.mp4
$ gst-play-1.0 i-frames-non-frag.mp4 
Press 'k' to see a list of keyboard shortcuts.
Now playing /home/ntrrgc/Dropbox/igalia/mp4-edts-testcases/i-frames-non-frag.mp4
0:00:00.163746350 53076 0x7fabbc007000 ERROR            vaapidecode gstvaapidecode.c:755:gst_vaapidecode_handle_frame: decode error -1
0:00:00.164154644 53076 0x7fabbc007000 ERROR            vaapidecode gstvaapidecode.c:755:gst_vaapidecode_handle_frame: decode error -1
0:00:00.164425618 53076 0x7fabbc007000 ERROR            vaapidecode gstvaapidecode.c:755:gst_vaapidecode_handle_frame: decode error -1
ERROR No valid frames decoded before end of stream for file:///home/ntrrgc/Dropbox/igalia/mp4-edts-testcases/i-frames-non-frag.mp4
ERROR debug information: ../subprojects/gst-plugins-base/gst-libs/gst/video/gstvideodecoder.c(1160): gst_video_decoder_sink_event_default (): /GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0/GstDecodeBin:decodebin0/GstVaapiDecodeBin:vaapidecodebin0/GstVaapiDecode:vaapidecode0:
no valid frames found
Reached end of play list.

Works fine in GStreamer 1.12.4 from Fedora.
Comment 1 Alicia Boya García 2018-02-26 10:16:27 UTC
(In reply to Alicia Boya García from comment #0)
> 
> Works fine in GStreamer 1.12.4 from Fedora.

Sorry, gstreamer1-vaapi was not installed. Actually it does not work in 1.12.4 either. It fails to play too, just showing fewer errors:

$ gst-play-1.0 i-frames-non-frag.mp4 
Press 'k' to see a list of keyboard shortcuts.
Now playing /home/ntrrgc/Dropbox/igalia/mp4-edts-testcases/i-frames-non-frag.mp4
ERROR No valid frames decoded before end of stream for file:///home/ntrrgc/Dropbox/igalia/mp4-edts-testcases/i-frames-non-frag.mp4
ERROR debug information: gstvideodecoder.c(1156): gst_video_decoder_sink_event_default (): /GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0/GstDecodeBin:decodebin0/GstVaapiDecodeBin:vaapidecodebin0/GstVaapiDecode:vaapidecode0:
no valid frames found
Reached end of play list.
Comment 2 Víctor Manuel Jáquez Leal 2018-02-26 11:18:02 UTC
Thanks @Alicia,

Can you upload the debug output with GST_DEBUG=vaapi*:5?
Comment 3 Víctor Manuel Jáquez Leal 2018-02-26 11:28:50 UTC
also,

1. can you upload the test sample?
2. which version of mesa libraries are you using?

As I cannot replicate this issue with the intel driver, there's a chance this will boil down to Gallium driver.
Comment 4 Julien Isorce 2018-02-27 06:01:41 UTC
Hi Alicia, is it Fedora 27 ? and what is the exact version of Mesa ? (The package that contains the va driver is mesa-dri-drivers and the lib is /usr/lib64/dri/radeonsi_drv_video.so)
Can you compare result with Fedora 26 to spot any regression ?
Can you also attach output of "dmesg | grep drm" ?
Comment 5 Philippe Normand 2018-02-27 08:54:55 UTC
I can confirm this issue here on Debian testing with Mesa 17.3.3-1.
Comment 6 Philippe Normand 2018-02-27 08:55:20 UTC
Created attachment 368993 [details]
dmsg|grep drm
Comment 7 Julien Isorce 2018-02-27 09:18:32 UTC
(In reply to Philippe Normand from comment #6)
> Created attachment 368993 [details]
> dmsg|grep drm

Thx Philippe, I was about to suggest to compare with the radeon driver by setting 
amdgpu.cik_support=0 amdgpu.si_support=0 radeon.cik_support=1 radeon.si_support=1 (in /etc/default/grub::GRUB_CMDLINE_LINUX_DEFAULT) but your POLARIS card is too recent so only supported by the amdgpu driver.
Comment 8 Alicia Boya García 2018-02-27 12:11:29 UTC
Created attachment 369012 [details]
Test vector
Comment 9 Alicia Boya García 2018-02-27 12:29:30 UTC
Created attachment 369013 [details]
GST_DEBUG=error,vaapi*:5 gst-play-1.0 i-frames-non-frag.mp4
Comment 10 Alicia Boya García 2018-02-27 12:35:25 UTC
(In reply to Julien Isorce from comment #4)
> Hi Alicia, is it Fedora 27 ? and what is the exact version of Mesa ? (The
> package that contains the va driver is mesa-dri-drivers and the lib is
> /usr/lib64/dri/radeonsi_drv_video.so)

This is Fedora 27.

Name         : mesa-dri-drivers
Version      : 17.2.4
Release      : 3.fc27
Arch         : x86_64

> Can you also attach output of "dmesg | grep drm" ?

Nothing is written there while playing.

Note other videos (with more complex GOPs) seem to play fine in practice.
Comment 11 Julien Isorce 2018-02-27 12:56:57 UTC
(In reply to Alicia Boya García from comment #9)
> Created attachment 369013 [details]
> GST_DEBUG=error,vaapi*:5 gst-play-1.0 i-frames-non-frag.mp4

GST_DEBUG=*vaapi*:6,2 ?
Comment 12 Julien Isorce 2018-02-27 12:58:22 UTC
(In reply to Alicia Boya García from comment #10)
> (In reply to Julien Isorce from comment #4)
> > Hi Alicia, is it Fedora 27 ? and what is the exact version of Mesa ? (The
> > package that contains the va driver is mesa-dri-drivers and the lib is
> > /usr/lib64/dri/radeonsi_drv_video.so)
> 
> This is Fedora 27.
> 
> Name         : mesa-dri-drivers
> Version      : 17.2.4
> Release      : 3.fc27
> Arch         : x86_64
> 
> > Can you also attach output of "dmesg | grep drm" ?
> 
> Nothing is written there while playing.

Thx for the infos, can you attach "dmesg | grep drm" just after a fresh boot ? (not when playing a video)
Comment 13 Alicia Boya García 2018-02-27 13:01:24 UTC
Created attachment 369018 [details]
GST_DEBUG=*vaapi*:6,2 gst-play-1.0 i-frames-non-frag.mp4
Comment 14 Alicia Boya García 2018-02-27 13:02:26 UTC
Created attachment 369019 [details]
dmesg | grep drm
Comment 15 Julien Isorce 2018-02-27 22:22:12 UTC
Just to confirm, does it happen only on the attached i-frames-non-frag.mp4 or there are mp4/h264 that succeed ?

It could fail here https://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/state_trackers/va/picture.c#n149
max_references is set here https://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/state_trackers/va/picture_h264.c#n114 so is gstreamer-vaapi setting libva::va.h::VAPictureParameterBufferH264::num_ref_frames correctly ?
Comment 16 Alicia Boya García 2018-02-28 10:06:49 UTC
(In reply to Julien Isorce from comment #15)
> Just to confirm, does it happen only on the attached i-frames-non-frag.mp4
> or there are mp4/h264 that succeed ?

There are mp4/h264 files that play correctly, there are files that don't (like i-frames-non-frag.mp4) and there are files that crash (https://bugzilla.gnome.org/show_bug.cgi?id=793890). At least so far the results have been consistent when playing the same file.
Comment 17 Julien Isorce 2018-03-12 17:14:36 UTC
Created attachment 369583 [details] [review]
libs: decoder: h264: ensure num_ref_frames is greater than 0

Hi Alicia, could you try the attached patch ? Thx!
Comment 18 Alicia Boya García 2018-03-13 10:54:34 UTC
It works, thank you very much! :)
Comment 19 Julien Isorce 2018-03-16 09:07:04 UTC
Hi Victor, Hi Sreerenj, what do you think of the fix ?
Comment 20 Víctor Manuel Jáquez Leal 2018-03-16 14:15:20 UTC
Comment on attachment 369583 [details] [review]
libs: decoder: h264: ensure num_ref_frames is greater than 0

I haven't tested it, but it looks correct. Please push it, Julien.
Comment 21 Víctor Manuel Jáquez Leal 2018-03-16 18:49:09 UTC
Attachment 369583 [details] pushed as bfa2fbd - libs: decoder: h264: ensure num_ref_frames is greater than 0
Comment 22 Víctor Manuel Jáquez Leal 2018-03-16 18:50:28 UTC
reminder: this patch needs to be merged into branch 1.12 too (but right now I'm in a hurry)
Comment 23 Víctor Manuel Jáquez Leal 2018-03-21 12:13:50 UTC
Pushed in branch 1.12

* 9a130035 libs: decoder: h264: ensure num_ref_frames is greater than 0