[vlc-commits] h264_nal: fix confusion between NAL size and NAL length size.

Thomas Guillem git at videolan.org
Thu Jul 30 13:40:46 CEST 2015


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Jul 30 13:22:39 2015 +0200| [4a8dc0f0085585c5f979fac7aadfc86ad8164640] | committer: Thomas Guillem

h264_nal: fix confusion between NAL size and NAL length size.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4a8dc0f0085585c5f979fac7aadfc86ad8164640
---

 modules/codec/mft.c              |    6 +++---
 modules/codec/omxil/mediacodec.c |   14 +++++++-------
 modules/packetizer/h264_nal.c    |   20 ++++++++++----------
 modules/packetizer/h264_nal.h    |    6 +++---
 4 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/modules/codec/mft.c b/modules/codec/mft.c
index e41762c..a61fa00 100644
--- a/modules/codec/mft.c
+++ b/modules/codec/mft.c
@@ -100,7 +100,7 @@ struct decoder_sys_t
     IMFMediaType *output_type;
 
     /* H264 only. */
-    uint32_t nal_size;
+    uint32_t nal_length_size;
 };
 
 static const int pi_channels_maps[9] =
@@ -575,7 +575,7 @@ static int ProcessInputStream(decoder_t *p_dec, DWORD stream_id, block_t *p_bloc
     if (p_dec->fmt_in.i_codec == VLC_CODEC_H264)
     {
         /* in-place NAL to annex B conversion. */
-        convert_h264_to_annexb(buffer_start, p_block->i_buffer, p_sys->nal_size);
+        convert_h264_to_annexb(buffer_start, p_block->i_buffer, p_sys->nal_length_size);
     }
 
     hr = IMFMediaBuffer_Unlock(input_media_buffer);
@@ -993,7 +993,7 @@ static int InitializeMFT(decoder_t *p_dec)
             {
                 convert_sps_pps(p_dec, p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra,
                                 buf, buf_size,
-                                &size, &p_sys->nal_size);
+                                &size, &p_sys->nal_length_size);
             }
             free(buf);
         }
diff --git a/modules/codec/omxil/mediacodec.c b/modules/codec/omxil/mediacodec.c
index f9c7d1d..c305084 100644
--- a/modules/codec/omxil/mediacodec.c
+++ b/modules/codec/omxil/mediacodec.c
@@ -86,7 +86,7 @@ struct decoder_sys_t
         {
             AWindowHandler *p_awh;
             int i_pixel_format, i_stride, i_slice_height, i_width, i_height;
-            uint32_t i_nal_size;
+            uint32_t i_nal_length_size;
             size_t i_h264_profile;
             ArchitectureSpecificCopyData ascd;
             /* stores the inflight picture for each output buffer or NULL */
@@ -295,13 +295,13 @@ static int ParseVideoExtra(decoder_t *p_dec, uint8_t *p_extra, int i_extra)
             if (p_extra[0] == 1
              && convert_sps_pps(p_dec, p_extra, i_extra,
                                 p_buf, buf_size, &size,
-                                &p_sys->u.video.i_nal_size) == VLC_SUCCESS)
+                                &p_sys->u.video.i_nal_length_size) == VLC_SUCCESS)
                 H264SetCSD(p_dec, p_buf, size, NULL);
         } else
         {
             if (convert_hevc_nal_units(p_dec, p_extra, i_extra,
                                        p_buf, buf_size, &size,
-                                       &p_sys->u.video.i_nal_size) == VLC_SUCCESS)
+                                       &p_sys->u.video.i_nal_length_size) == VLC_SUCCESS)
             {
                 struct csd csd;
 
@@ -1056,10 +1056,10 @@ static void H264ProcessBlock(decoder_t *p_dec, block_t *p_block,
 
     assert(p_dec->fmt_in.i_codec == VLC_CODEC_H264 && p_block);
 
-    if (p_sys->u.video.i_nal_size)
+    if (p_sys->u.video.i_nal_length_size)
     {
         convert_h264_to_annexb(p_block->p_buffer, p_block->i_buffer,
-                               p_sys->u.video.i_nal_size);
+                               p_sys->u.video.i_nal_length_size);
     } else if (H264SetCSD(p_dec, p_block->p_buffer, p_block->i_buffer,
                           p_size_changed) == VLC_SUCCESS)
     {
@@ -1074,10 +1074,10 @@ static void HEVCProcessBlock(decoder_t *p_dec, block_t *p_block,
 
     assert(p_dec->fmt_in.i_codec == VLC_CODEC_HEVC && p_block);
 
-    if (p_sys->u.video.i_nal_size)
+    if (p_sys->u.video.i_nal_length_size)
     {
         convert_h264_to_annexb(p_block->p_buffer, p_block->i_buffer,
-                               p_sys->u.video.i_nal_size);
+                               p_sys->u.video.i_nal_length_size);
     }
 
     /* TODO */
diff --git a/modules/packetizer/h264_nal.c b/modules/packetizer/h264_nal.c
index b5cd3d2..9ccc794 100644
--- a/modules/packetizer/h264_nal.c
+++ b/modules/packetizer/h264_nal.c
@@ -32,7 +32,7 @@ static const uint8_t annexb_startcode[] = { 0x00, 0x00, 0x01 };
 int convert_sps_pps( decoder_t *p_dec, const uint8_t *p_buf,
                      uint32_t i_buf_size, uint8_t *p_out_buf,
                      uint32_t i_out_buf_size, uint32_t *p_sps_pps_size,
-                     uint32_t *p_nal_size)
+                     uint32_t *p_nal_length_size)
 {
     int i_profile;
     uint32_t i_data_size = i_buf_size, i_nal_size, i_sps_pps_size = 0;
@@ -47,8 +47,8 @@ int convert_sps_pps( decoder_t *p_dec, const uint8_t *p_buf,
 
     /* Read infos in first 6 bytes */
     i_profile = (p_buf[1] << 16) | (p_buf[2] << 8) | p_buf[3];
-    if (p_nal_size)
-        *p_nal_size  = (p_buf[4] & 0x03) + 1;
+    if (p_nal_length_size)
+        *p_nal_length_size  = (p_buf[4] & 0x03) + 1;
     p_buf       += 5;
     i_data_size -= 5;
 
@@ -107,23 +107,23 @@ int convert_sps_pps( decoder_t *p_dec, const uint8_t *p_buf,
 }
 
 void convert_h264_to_annexb( uint8_t *p_buf, uint32_t i_len,
-                             size_t i_nal_size )
+                             size_t i_nal_length_size )
 {
     uint32_t nal_len = 0, nal_pos = 0;
 
-    if( i_nal_size < 3 || i_nal_size > 4 )
+    if( i_nal_length_size < 3 || i_nal_length_size > 4 )
         return;
 
     /* This only works for NAL sizes 3-4 */
     while( i_len > 0 )
     {
-        if( nal_pos < i_nal_size ) {
+        if( nal_pos < i_nal_length_size ) {
             unsigned int i;
-            for( i = 0; nal_pos < i_nal_size && i < i_len; i++, nal_pos++ ) {
+            for( i = 0; nal_pos < i_nal_length_size && i < i_len; i++, nal_pos++ ) {
                 nal_len = (nal_len << 8) | p_buf[i];
                 p_buf[i] = 0;
             }
-            if( nal_pos < i_nal_size )
+            if( nal_pos < i_nal_length_size )
                 return;
             p_buf[i - 1] = 1;
             p_buf += i;
@@ -518,7 +518,7 @@ int h264_parse_pps( const uint8_t *p_pps_buf, int i_pps_size,
 }
 
 bool h264_get_profile_level(const es_format_t *p_fmt, size_t *p_profile,
-                            size_t *p_level, size_t *p_nal_size)
+                            size_t *p_level, size_t *p_nal_length_size)
 {
     uint8_t *p = (uint8_t*)p_fmt->p_extra;
     if(!p || !p_fmt->p_extra) return false;
@@ -527,7 +527,7 @@ bool h264_get_profile_level(const es_format_t *p_fmt, size_t *p_profile,
     if (p_fmt->i_original_fourcc == VLC_FOURCC('a','v','c','1') && p[0] == 1)
     {
         if (p_fmt->i_extra < 12) return false;
-        if (p_nal_size) *p_nal_size = 1 + (p[4]&0x03);
+        if (p_nal_length_size) *p_nal_length_size = 1 + (p[4]&0x03);
         if (!(p[5]&0x1f)) return false;
         p += 8;
     }
diff --git a/modules/packetizer/h264_nal.h b/modules/packetizer/h264_nal.h
index a178138..a67e607 100644
--- a/modules/packetizer/h264_nal.h
+++ b/modules/packetizer/h264_nal.h
@@ -118,10 +118,10 @@ static inline void CreateDecodedNAL( uint8_t **pp_ret, int *pi_ret,
 int convert_sps_pps( decoder_t *p_dec, const uint8_t *p_buf,
                      uint32_t i_buf_size, uint8_t *p_out_buf,
                      uint32_t i_out_buf_size, uint32_t *p_sps_pps_size,
-                     uint32_t *p_nal_size);
+                     uint32_t *p_nal_length_size);
 
 void convert_h264_to_annexb( uint8_t *p_buf, uint32_t i_len,
-                             size_t i_nal_size );
+                             size_t i_nal_length_size );
 
 /* Get the SPS/PPS pointers from an Annex B buffer
  * Returns 0 if a SPS and/or a PPS is found */
@@ -141,6 +141,6 @@ int h264_parse_pps( const uint8_t *p_pps_buf, int i_pps_size,
 
 /* Get level and Profile */
 bool h264_get_profile_level(const es_format_t *p_fmt, size_t *p_profile,
-                            size_t *p_level, size_t *p_nal_size);
+                            size_t *p_level, size_t *p_nal_length_size);
 
 #endif /* H264_NAL_H */



More information about the vlc-commits mailing list