Commit bee38da8 authored by Francois Cartegnie's avatar Francois Cartegnie

packetizer: add isavcC helper

parent d76bc0b9
...@@ -992,7 +992,7 @@ static int InitializeMFT(decoder_t *p_dec) ...@@ -992,7 +992,7 @@ static int InitializeMFT(decoder_t *p_dec)
int buf_size = p_dec->fmt_in.i_extra + 20; int buf_size = p_dec->fmt_in.i_extra + 20;
uint32_t size = p_dec->fmt_in.i_extra; uint32_t size = p_dec->fmt_in.i_extra;
uint8_t *buf = malloc(buf_size); uint8_t *buf = malloc(buf_size);
if (((uint8_t*)p_dec->fmt_in.p_extra)[0] == 1) if (h264_isavcC((uint8_t*)p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra))
{ {
h264_avcC_to_AnnexB_NAL(p_dec, p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra, h264_avcC_to_AnnexB_NAL(p_dec, p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra,
buf, buf_size, buf, buf_size,
......
...@@ -313,7 +313,7 @@ static int ParseVideoExtra(decoder_t *p_dec, uint8_t *p_extra, int i_extra) ...@@ -313,7 +313,7 @@ static int ParseVideoExtra(decoder_t *p_dec, uint8_t *p_extra, int i_extra)
if (p_dec->fmt_in.i_codec == VLC_CODEC_H264) if (p_dec->fmt_in.i_codec == VLC_CODEC_H264)
{ {
if (p_extra[0] == 1 if ( h264_isavcC(p_extra, i_extra)
&& h264_avcC_to_AnnexB_NAL(p_dec, p_extra, i_extra, && h264_avcC_to_AnnexB_NAL(p_dec, p_extra, i_extra,
p_buf, buf_size, &size, p_buf, buf_size, &size,
&p_sys->u.video.i_nal_length_size) == VLC_SUCCESS) &p_sys->u.video.i_nal_length_size) == VLC_SUCCESS)
......
...@@ -31,6 +31,15 @@ ...@@ -31,6 +31,15 @@
static const uint8_t annexb_startcode[] = { 0x00, 0x00, 0x01 }; static const uint8_t annexb_startcode[] = { 0x00, 0x00, 0x01 };
bool h264_isavcC( const uint8_t *p_buf, size_t i_buf )
{
return ( i_buf > H264_MIN_AVCC_SIZE &&
p_buf[0] == 0x01 &&
(p_buf[4] & 0xFC) == 0xFC &&
(p_buf[4] & 0x03) != 0x02 &&
(p_buf[5] & 0xE0) == 0xE0 );
}
static inline bool strip_AnnexB_startcode( const uint8_t **pp_data, size_t *pi_data ) static inline bool strip_AnnexB_startcode( const uint8_t **pp_data, size_t *pi_data )
{ {
const uint8_t *p_data = *pp_data; const uint8_t *p_data = *pp_data;
......
...@@ -113,6 +113,10 @@ struct h264_nal_pps ...@@ -113,6 +113,10 @@ struct h264_nal_pps
avcC: AVCDecoderConfigurationRecord combining SPS & PPS in AVC Sample Format avcC: AVCDecoderConfigurationRecord combining SPS & PPS in AVC Sample Format
*/ */
#define H264_MIN_AVCC_SIZE 7
bool h264_isavcC( const uint8_t *, size_t );
/* Convert AVC Sample format to Annex B in-place */ /* Convert AVC Sample format to Annex B in-place */
void h264_AVC_to_AnnexB( uint8_t *p_buf, uint32_t i_len, void h264_AVC_to_AnnexB( uint8_t *p_buf, uint32_t i_len,
uint8_t i_nal_length_size ); uint8_t i_nal_length_size );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment