[vlc-commits] packetizer: add isavcC helper
Francois Cartegnie
git at videolan.org
Wed Dec 9 12:40:01 CET 2015
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Dec 9 10:56:48 2015 +0100| [bee38da89a496024e77900979c19a85717896bfa] | committer: Francois Cartegnie
packetizer: add isavcC helper
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bee38da89a496024e77900979c19a85717896bfa
---
modules/codec/mft.c | 2 +-
modules/codec/omxil/mediacodec.c | 2 +-
modules/packetizer/h264_nal.c | 9 +++++++++
modules/packetizer/h264_nal.h | 4 ++++
4 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/modules/codec/mft.c b/modules/codec/mft.c
index 931ffbe..2d638cd 100644
--- a/modules/codec/mft.c
+++ b/modules/codec/mft.c
@@ -992,7 +992,7 @@ static int InitializeMFT(decoder_t *p_dec)
int buf_size = p_dec->fmt_in.i_extra + 20;
uint32_t size = p_dec->fmt_in.i_extra;
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,
buf, buf_size,
diff --git a/modules/codec/omxil/mediacodec.c b/modules/codec/omxil/mediacodec.c
index bfeb9b8..7df856e 100644
--- a/modules/codec/omxil/mediacodec.c
+++ b/modules/codec/omxil/mediacodec.c
@@ -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_extra[0] == 1
+ if ( h264_isavcC(p_extra, i_extra)
&& h264_avcC_to_AnnexB_NAL(p_dec, p_extra, i_extra,
p_buf, buf_size, &size,
&p_sys->u.video.i_nal_length_size) == VLC_SUCCESS)
diff --git a/modules/packetizer/h264_nal.c b/modules/packetizer/h264_nal.c
index 70e8761..601f3f4 100644
--- a/modules/packetizer/h264_nal.c
+++ b/modules/packetizer/h264_nal.c
@@ -31,6 +31,15 @@
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 )
{
const uint8_t *p_data = *pp_data;
diff --git a/modules/packetizer/h264_nal.h b/modules/packetizer/h264_nal.h
index 98d41cf..e3fca90 100644
--- a/modules/packetizer/h264_nal.h
+++ b/modules/packetizer/h264_nal.h
@@ -113,6 +113,10 @@ struct h264_nal_pps
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 */
void h264_AVC_to_AnnexB( uint8_t *p_buf, uint32_t i_len,
uint8_t i_nal_length_size );
More information about the vlc-commits
mailing list