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 794537 - h264parse: Internal 'state' not cleared properly on state change
h264parse: Internal 'state' not cleared properly on state change
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
1.12.2
Other Linux
: Normal normal
: 1.12.5
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2018-03-20 18:48 UTC by Brendan Shanks
Modified: 2018-03-21 20:52 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
annotated log showing h264parse bug (155.69 KB, text/x-log)
2018-03-20 18:48 UTC, Brendan Shanks
  Details
patch against master (942 bytes, patch)
2018-03-20 18:55 UTC, Brendan Shanks
committed Details | Review

Description Brendan Shanks 2018-03-20 18:48:26 UTC
Created attachment 369922 [details]
annotated log showing h264parse bug

I'm using an h264parse to convert H264 from byte-stream to avc for feeding into a qtmux/filesink for movie recording. When recording for the first time after creating the parser, it works normally. The parser has to drop frames (with a message like 'broken/invalid nal Type: 1 Slice, Size: 4725 will be dropped') until an SPS/PPS is received, but once that happens it creates a proper caps event with codec_data and everything works.

But after stopping recording (blocking data, sending EOS through the pipeline, setting h264parse to NULL state) and then starting recording again, the h264parse doesn't work right. Rather than dropping frames until SPS/PPS comes in, it attempts to parse the frames but fails:

gsth264parser.c:962:gst_h264_parser_parse_pic_timing: didn't get the associated sequence paramater set for the current access unit
gsth264parser.c:1007:gst_h264_parser_parse_pic_timing: error parsing "Picture timing"
gsth264parse.c:530:gst_h264_parse_process_sei:<vparser> failed to parse one or more SEI message

The parser then sends a caps event without codec_data since no SPS/PPS has been received, I don't believe this is even legal for stream-format=au. qtmux rejects the caps, and video doesn't flow.

The problem appears to be that h264parse->state is not reset when the nalparser is recreated, i.e. in gst_h264_parse_start(). From 'h264parse->state' in the previous run, h264parse thinks that the nalparser has already parsed an SPS, when it actually hasn't (it was just free'd and recreated). The nalparser then fails to parse any non-SPS/PPS messages, and bad caps are sent out.

Patch against master is attached. I've tested the same patch against 1.12.2 with success. Also attached an annotated/condensed log.
Comment 1 Brendan Shanks 2018-03-20 18:55:55 UTC
Created attachment 369923 [details] [review]
patch against master
Comment 2 Sebastian Dröge (slomo) 2018-03-21 07:15:11 UTC
commit 8e3827b7beab78b54552a3f042acb28d8b355627 (HEAD -> master, origin/master, origin/HEAD)
Author: Brendan Shanks <brendan.shanks@teradek.com>
Date:   Tue Mar 20 11:49:19 2018 -0700

    h264parse: reset internal 'state' variable properly
    
    Reset the internal 'state' variable when the parser is started, fixes
    errors when parser is being re-used.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=794537
Comment 3 Nicolas Dufresne (ndufresne) 2018-03-21 20:52:21 UTC
commit 13e6c9b6186305b80e9eb19b3193930133069e72 (HEAD -> 1.12)
Author: Brendan Shanks <brendan.shanks@teradek.com>
Date:   Tue Mar 20 11:49:19 2018 -0700

    h264parse: reset internal 'state' variable properly
    
    Reset the internal 'state' variable when the parser is started, fixes
    errors when parser is being re-used.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=794537

commit 5d65cb21e79aac69fa8756a23093984155ba91fd (HEAD -> 1.14)
Author: Brendan Shanks <brendan.shanks@teradek.com>
Date:   Tue Mar 20 11:49:19 2018 -0700

    h264parse: reset internal 'state' variable properly
    
    Reset the internal 'state' variable when the parser is started, fixes
    errors when parser is being re-used.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=794537