[vlc-devel] [PATCH] h264_nal: fix parsing of the end of SPS and PPS NAL units

Thomas Guillem thomas at gllm.fr
Thu Jul 23 19:14:29 CEST 2015



On Tue, Jul 14, 2015, at 13:14, Rémi Denis-Courmont wrote:
> Le 2015-07-13 17:01, Thomas Guillem a écrit :
> > SPS and PPS NAL units always start with "00 00 00 01" but others NAL
> > units may
> > starts with "00 00 01".
> > ---
> >  modules/packetizer/h264_nal.c | 91
> > +++++++++++++++++++++++++++----------------
> >  1 file changed, 57 insertions(+), 34 deletions(-)
> >
> > diff --git a/modules/packetizer/h264_nal.c 
> > b/modules/packetizer/h264_nal.c
> > index a35f861..a867dc9 100644
> > --- a/modules/packetizer/h264_nal.c
> > +++ b/modules/packetizer/h264_nal.c
> > @@ -20,9 +20,10 @@
> >
> >  #include "h264_nal.h"
> >
> > +#include <assert.h>
> >  #include <limits.h>
> >
> > -static const uint8_t annexb_startcode[] = { 0x00, 0x00, 0x00, 0x01 
> > };
> > +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,
> > @@ -140,6 +141,15 @@ void convert_h264_to_annexb( uint8_t *p_buf,
> > uint32_t i_len,
> >      }
> >  }
> >
> > +static size_t get_spspps_size( uint8_t *p_start, uint8_t *p_end )
> > +{
> > +    /* cf B.1.1: don't count trailing_zero_8bits */
> > +
> > +    while( *p_end == 0 && p_end > p_start )
> > +        p_end--;
> > +    return p_end - p_start + 1;
> > +}
> > +
> 
> Is there a warranty that SPS and PPS end with a non-zero byte?

> 
> As for the rest of the code, it does not match my understanding of the 
> spec before the patch nor after the patch. Maybe I don't understand.

Indeed, I didn't understand it. A new patch that respect the spec is
coming.

> 
> -- 
> Rémi Denis-Courmont
> http://www.remlab.net/
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel



More information about the vlc-devel mailing list