h264parse: don't rewind to the NAL length size in bytewriter if the format is bytestream
authorThibault Saunier <thibault.saunier@collabora.com>
Tue, 6 Nov 2012 15:40:05 +0000 (12:40 -0300)
committerThibault Saunier <thibault.saunier@collabora.com>
Tue, 6 Nov 2012 15:44:29 +0000 (12:44 -0300)
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=687548

Signed-off-by: Kevin Thornberry
gst/videoparsers/gsth264parse.c

index 68a13f9ac74308d48e48156f225e7bcc57591ffb..6fa77dd720fce35fcc644e8ab53a57c8fe00742f 100644 (file)
@@ -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;
             }