From 7f72b99426e8615cc16bff1c8157cd7d6efdba54 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Thu, 17 May 2012 11:47:19 +0200 Subject: [PATCH] h264parse: also consider nal_length_size when inserting codec data See #676174. --- gst/videoparsers/gsth264parse.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c index b1f19f9..38086a5 100644 --- a/gst/videoparsers/gsth264parse.c +++ b/gst/videoparsers/gsth264parse.c @@ -1577,6 +1577,7 @@ gst_h264_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame) GstByteWriter bw; GstBuffer *new_buf; const gboolean bs = h264parse->format == GST_H264_PARSE_FORMAT_BYTE; + const gint nls = 4 - h264parse->nal_length_size; gboolean ok; gst_byte_writer_init_with_size (&bw, gst_buffer_get_size (buffer), @@ -1587,7 +1588,10 @@ 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); + 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); ok &= gst_byte_writer_put_buffer (&bw, codec_nal, 0, nal_size); h264parse->last_report = new_ts; } @@ -1596,8 +1600,10 @@ 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); - ok &= gst_byte_writer_put_buffer (&bw, codec_nal, 0, nal_size); + 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); h264parse->last_report = new_ts; } } -- 2.7.4