From b3abd51656dd5883066fada3d29953111437c1bf Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Tue, 6 Nov 2012 12:40:05 -0300 Subject: [PATCH] h264parse: don't rewind to the NAL length size in bytewriter if the format is bytestream Fixes https://bugzilla.gnome.org/show_bug.cgi?id=687548 Signed-off-by: Kevin Thornberry --- gst/videoparsers/gsth264parse.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c index 68a13f9ac7..6fa77dd720 100644 --- a/gst/videoparsers/gsth264parse.c +++ b/gst/videoparsers/gsth264parse.c @@ -1617,10 +1617,15 @@ gst_h264_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame) if ((codec_nal = h264parse->sps_nals[i])) { gsize nal_size = gst_buffer_get_size (codec_nal); GST_DEBUG_OBJECT (h264parse, "inserting SPS nal"); - ok &= gst_byte_writer_put_uint32_be (&bw, - bs ? 1 : (nal_size << (nls * 8))); - ok &= gst_byte_writer_set_pos (&bw, - gst_byte_writer_get_pos (&bw) - nls); + if (bs) { + ok &= gst_byte_writer_put_uint32_be (&bw, 1); + } else { + ok &= gst_byte_writer_put_uint32_be (&bw, + (nal_size << (nls * 8))); + ok &= gst_byte_writer_set_pos (&bw, + gst_byte_writer_get_pos (&bw) - nls); + } + ok &= gst_byte_writer_put_buffer (&bw, codec_nal, 0, nal_size); h264parse->last_report = new_ts; } @@ -1629,10 +1634,14 @@ gst_h264_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame) if ((codec_nal = h264parse->pps_nals[i])) { gsize nal_size = gst_buffer_get_size (codec_nal); GST_DEBUG_OBJECT (h264parse, "inserting PPS nal"); - ok &= gst_byte_writer_put_uint32_be (&bw, - bs ? 1 : (nal_size << (nls * 8))); - ok &= gst_byte_writer_set_pos (&bw, - gst_byte_writer_get_pos (&bw) - nls); + if (bs) { + ok &= gst_byte_writer_put_uint32_be (&bw, 1); + } else { + ok &= gst_byte_writer_put_uint32_be (&bw, + (nal_size << (nls * 8))); + ok &= gst_byte_writer_set_pos (&bw, + gst_byte_writer_get_pos (&bw) - nls); + } ok &= gst_byte_writer_put_buffer (&bw, codec_nal, 0, nal_size); h264parse->last_report = new_ts; } -- 2.34.1