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 705452 - h264parse: Does not extract width/height/etc from h264-in-mpeg-ps
h264parse: Does not extract width/height/etc from h264-in-mpeg-ps
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal blocker
: 1.1.4
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 708240 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-08-04 15:46 UTC by Tim-Philipp Müller
Modified: 2014-11-12 16:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
h264parse: do not set CAPS before SPS/PPS nals parsing (885 bytes, patch)
2013-08-20 11:07 UTC, Matthieu Bouron
needs-work Details | Review
h264parse: do not set CAPS before SPS/PPS nals parsing (885 bytes, patch)
2013-08-20 11:12 UTC, Matthieu Bouron
none Details | Review
h264parse: do not set passthrough mode before SPS/PPS nals parsing (1.06 KB, patch)
2013-08-20 15:01 UTC, Matthieu Bouron
needs-work Details | Review
h264parse: do not set CAPS and passthrough mode if SPS/PPS have not been parsed (1.43 KB, patch)
2013-08-27 10:49 UTC, Matthieu Bouron
committed Details | Review
h264parse: only update src CAPS when it's necessary (1.42 KB, patch)
2013-08-27 10:50 UTC, Matthieu Bouron
committed Details | Review

Description Tim-Philipp Müller 2013-08-04 15:46:36 UTC
$ gst-launch-1.0 videotestsrc num-buffers=200 ! x264enc ! mpegpsmux ! filesink location=/tmp/h264.mpg

$ G_DEBUG=fatal_warnings gst-launch-1.0 playbin uri=file:///tmp/h264.mpg  
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...

** (gst-launch-1.0:2029): CRITICAL **: gst_video_decoder_negotiate_default: assertion `GST_VIDEO_INFO_WIDTH (&state->info) != 0' failed
Trace/breakpoint trap


Program received signal SIGTRAP, Trace/breakpoint trap.

Thread 140737199171328 (LWP 2058)

  • #0 g_logv
    at gmessages.c line 981
  • #1 g_log
    at gmessages.c line 1010
  • #2 g_return_if_fail_warning
  • #3 gst_video_decoder_negotiate_default
    at gstvideodecoder.c line 3012
  • #4 gst_video_decoder_negotiate
    at gstvideodecoder.c line 3142
  • #5 gst_ffmpegviddec_negotiate
    at gstavviddec.c line 895
  • #6 gst_ffmpegviddec_get_buffer
    at gstavviddec.c line 629
  • #7 submit_packet
    at libavcodec/pthread.c line 573
  • #8 ff_thread_decode_frame
    at libavcodec/pthread.c line 603
  • #9 avcodec_decode_video2
    at libavcodec/utils.c line 1283
  • #10 gst_ffmpegviddec_video_frame
    at gstavviddec.c line 1114
  • #11 gst_ffmpegviddec_frame
    at gstavviddec.c line 1241
  • #12 gst_ffmpegviddec_handle_frame
    at gstavviddec.c line 1357
  • #13 gst_video_decoder_decode_frame
    at gstvideodecoder.c line 2755
  • #14 gst_video_decoder_chain_forward
    at gstvideodecoder.c line 1755
  • #15 gst_video_decoder_chain
    at gstvideodecoder.c line 2002

Comment 1 Sebastian Dröge (slomo) 2013-08-08 10:58:03 UTC
The problem here seems to be that h264parse does not extract width/height or anything from the h264 stream.
Comment 2 Matthieu Bouron 2013-08-20 11:07:32 UTC
Created attachment 252371 [details] [review]
h264parse: do not set CAPS before SPS/PPS nals parsing
Comment 3 Matthieu Bouron 2013-08-20 11:12:56 UTC
Created attachment 252373 [details] [review]
h264parse: do not set CAPS before SPS/PPS nals parsing
Comment 4 Sebastian Dröge (slomo) 2013-08-20 11:51:42 UTC
Review of attachment 252371 [details] [review]:

::: gst/videoparsers/gsth264parse.c
@@ +1888,3 @@
+    /* do not set CAPS before SPS/PPS nals parsing */
+    if (!h264parse->have_sps || !h264parse->have_pps)
+      return TRUE;

I'm not sure if that is enough, also it would seem cleaner to just put the negotiate block below in an if (have_sps && have_pps) block.

The problem I see here is that handle_frame() will immediately call negotiate() again, which might be before the SPS/PPS are parsed.
Comment 5 Matthieu Bouron 2013-08-20 13:06:19 UTC
(In reply to comment #4)
> Review of attachment 252371 [details] [review]:
> 
> ::: gst/videoparsers/gsth264parse.c
> @@ +1888,3 @@
> +    /* do not set CAPS before SPS/PPS nals parsing */
> +    if (!h264parse->have_sps || !h264parse->have_pps)
> +      return TRUE;
> 
> I'm not sure if that is enough, also it would seem cleaner to just put the
> negotiate block below in an if (have_sps && have_pps) block.

Fixed locally.

> 
> The problem I see here is that handle_frame() will immediately call negotiate()
> again, which might be before the SPS/PPS are parsed.

As far i understand calling _negociate without SPS/PPS is not a problem since it does not directly set the caps but rather update it + format/align. Only _update_src_caps should not be called before any SPS/PPS parsing.

Calls to _update_src_caps are automatically triggered when SPS/PPS are parsed (h264parse->update_caps = TRUE).

Should a check be added before calling _negociate in _handle_frame() ?
Comment 6 Sebastian Dröge (slomo) 2013-08-20 13:26:28 UTC
Ah good point. No that should be fine then :)
Comment 7 Matthieu Bouron 2013-08-20 15:01:37 UTC
Created attachment 252438 [details] [review]
h264parse: do not set passthrough mode before SPS/PPS nals parsing
Comment 8 Matthieu Bouron 2013-08-20 15:04:35 UTC
(In reply to comment #6)
> Ah good point. No that should be fine then :)

The check could even be placed to not enable passtrough mode if SPS/PSS has not been parsed yet. This won't hijack the code path below if input != output and input is avc.

The question now is, should the passtrough mode enabled later ?
Comment 9 Sebastian Dröge (slomo) 2013-08-21 06:37:05 UTC
Comment on attachment 252438 [details] [review]
h264parse: do not set passthrough mode before SPS/PPS nals parsing

I don't know why but this patch alone causes new caps to be set for every single buffer it seems, and also the initial caps don't have width/height set.

Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
/GstPipeline:pipeline0/GstH264Parse:h264parse0.GstPad:src: caps = video/x-h264, parsed=(boolean)true, stream-format=(string)byte-stream, alignment=(string)au
/GstPipeline:pipeline0/GstFakeSink:fakesink0.GstPad:sink: caps = video/x-h264, parsed=(boolean)true, stream-format=(string)byte-stream, alignment=(string)au
/GstPipeline:pipeline0/GstH264Parse:h264parse0.GstPad:sink: caps = video/x-h264
/GstPipeline:pipeline0/GstH264Parse:h264parse0.GstPad:src: caps = video/x-h264, width=(int)320, height=(int)240, parsed=(boolean)true, stream-format=(string)byte-stream, alignment=(string)au, pixel-aspect-ratio=(fraction)1/1
/GstPipeline:pipeline0/GstFakeSink:fakesink0.GstPad:sink: caps = video/x-h264, width=(int)320, height=(int)240, parsed=(boolean)true, stream-format=(string)byte-stream, alignment=(string)au, pixel-aspect-ratio=(fraction)1/1
[...]
Comment 10 Sebastian Dröge (slomo) 2013-08-21 06:38:07 UTC
Your first patch was setting the width/height on the initial caps, but there was also new caps (the same) for every single buffer
Comment 11 Matthieu Bouron 2013-08-22 10:27:54 UTC
(In reply to comment #10)
> Your first patch was setting the width/height on the initial caps, but there
> was also new caps (the same) for every single buffer

This has something to do with enabling the passthrough mode at some point. I should be able to send patch by the end of the week.
Comment 12 Matthieu Bouron 2013-08-27 10:49:48 UTC
Created attachment 253232 [details] [review]
h264parse: do not set CAPS and passthrough mode if SPS/PPS have not been parsed
Comment 13 Matthieu Bouron 2013-08-27 10:50:19 UTC
Created attachment 253233 [details] [review]
h264parse: only update src CAPS when it's necessary
Comment 14 Sebastian Dröge (slomo) 2013-08-27 13:01:41 UTC
commit 4b10f278b6268b01d16052257d5da7c9ba985f03
Author: Matthieu Bouron <matthieu.bouron@collabora.com>
Date:   Tue Aug 27 11:27:04 2013 +0100

    h264parse: only update src CAPS when it's necessary
    
    https://bugzilla.gnome.org/show_bug.cgi?id=705452

commit 43dcebe2a024547d04cd4d7fac41cc88c6d13dd6
Author: Matthieu Bouron <matthieu.bouron@collabora.com>
Date:   Tue Aug 20 11:59:34 2013 +0100

    h264parse: do not set CAPS and passthrough mode if SPS/PPS have not been parsed
    
    https://bugzilla.gnome.org/show_bug.cgi?id=705452
Comment 15 Sebastian Dröge (slomo) 2013-10-04 10:39:54 UTC
*** Bug 708240 has been marked as a duplicate of this bug. ***