[vlc-devel] [PATCH] h264_nal: fix parsing of the end of SPS and PPS NAL units
Rémi Denis-Courmont
remi at remlab.net
Tue Jul 14 13:14:12 CEST 2015
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.
--
Rémi Denis-Courmont
http://www.remlab.net/
More information about the vlc-devel
mailing list