vlc | branch: master | Francois Cartegnie <[email protected]> | Fri Dec 21 15:16:44 2018 +0100| [50209309f66f55d568c01a975e05914b8250ff5e] | committer: Francois Cartegnie
packetizer: a52: add EAC3 header defines > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=50209309f66f55d568c01a975e05914b8250ff5e --- modules/demux/mpeg/es.c | 16 ++++++++-------- modules/packetizer/a52.c | 10 +++++----- modules/packetizer/a52.h | 10 ++++++---- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/modules/demux/mpeg/es.c b/modules/demux/mpeg/es.c index 3f81712969..731049bf14 100644 --- a/modules/demux/mpeg/es.c +++ b/modules/demux/mpeg/es.c @@ -1127,16 +1127,16 @@ static int AacInit( demux_t *p_demux ) static int A52CheckSync( const uint8_t *p_peek, bool *p_big_endian, unsigned *pi_samples, bool b_eac3 ) { vlc_a52_header_t header; - uint8_t p_tmp[VLC_A52_HEADER_SIZE]; + uint8_t p_tmp[VLC_A52_MIN_HEADER_SIZE]; *p_big_endian = p_peek[0] == 0x0b && p_peek[1] == 0x77; if( !*p_big_endian ) { - swab( p_peek, p_tmp, VLC_A52_HEADER_SIZE ); + swab( p_peek, p_tmp, VLC_A52_MIN_HEADER_SIZE ); p_peek = p_tmp; } - if( vlc_a52_header_Parse( &header, p_peek, VLC_A52_HEADER_SIZE ) ) + if( vlc_a52_header_Parse( &header, p_peek, VLC_A52_MIN_HEADER_SIZE ) ) return VLC_EGENERIC; if( !header.b_eac3 != !b_eac3 ) @@ -1157,8 +1157,8 @@ static int EA52Probe( demux_t *p_demux, uint64_t *pi_offset ) const uint16_t rgi_twocc[] = { WAVE_FORMAT_PCM, WAVE_FORMAT_A52, WAVE_FORMAT_UNKNOWN }; return GenericProbe( p_demux, pi_offset, ppsz_name, EA52CheckSyncProbe, - VLC_A52_HEADER_SIZE, - 1920 + VLC_A52_HEADER_SIZE + 1, + VLC_A52_MIN_HEADER_SIZE, + 1920 + VLC_A52_MIN_HEADER_SIZE + 1, WAV_EXTRA_PROBE_SIZE, true, rgi_twocc, GenericFormatCheck ); } @@ -1175,8 +1175,8 @@ static int A52Probe( demux_t *p_demux, uint64_t *pi_offset ) const uint16_t rgi_twocc[] = { WAVE_FORMAT_PCM, WAVE_FORMAT_A52, WAVE_FORMAT_UNKNOWN }; return GenericProbe( p_demux, pi_offset, ppsz_name, A52CheckSyncProbe, - VLC_A52_HEADER_SIZE, - 1920 + VLC_A52_HEADER_SIZE + 1, + VLC_A52_MIN_HEADER_SIZE, + 1920 + VLC_A52_MIN_HEADER_SIZE + 1, WAV_EXTRA_PROBE_SIZE, true, rgi_twocc, GenericFormatCheck ); } @@ -1191,7 +1191,7 @@ static int A52Init( demux_t *p_demux ) const uint8_t *p_peek; /* peek the begining */ - if( vlc_stream_Peek( p_demux->s, &p_peek, VLC_A52_HEADER_SIZE ) >= VLC_A52_HEADER_SIZE ) + if( vlc_stream_Peek( p_demux->s, &p_peek, VLC_A52_MIN_HEADER_SIZE ) >= VLC_A52_MIN_HEADER_SIZE ) { A52CheckSync( p_peek, &p_sys->b_big_endian, NULL, true ); } diff --git a/modules/packetizer/a52.c b/modules/packetizer/a52.c index c8209f3966..fb8ab6a7f5 100644 --- a/modules/packetizer/a52.c +++ b/modules/packetizer/a52.c @@ -138,7 +138,7 @@ static block_t *GetOutBuffer( decoder_t *p_dec ) static block_t *PacketizeBlock( decoder_t *p_dec, block_t **pp_block ) { decoder_sys_t *p_sys = p_dec->p_sys; - uint8_t p_header[VLC_A52_HEADER_SIZE]; + uint8_t p_header[VLC_A52_MIN_HEADER_SIZE]; block_t *p_out_buffer; block_t *p_block = pp_block ? *pp_block : NULL; @@ -195,7 +195,7 @@ static block_t *PacketizeBlock( decoder_t *p_dec, block_t **pp_block ) case STATE_HEADER: /* Get A/52 frame header (VLC_A52_HEADER_SIZE bytes) */ if( block_PeekBytes( &p_sys->bytestream, p_header, - VLC_A52_HEADER_SIZE ) != VLC_SUCCESS ) + VLC_A52_MIN_HEADER_SIZE ) != VLC_SUCCESS ) { /* Need more data */ return NULL; @@ -203,7 +203,7 @@ static block_t *PacketizeBlock( decoder_t *p_dec, block_t **pp_block ) /* Check if frame is valid and get frame info */ if( vlc_a52_header_Parse( &p_sys->frame, p_header, - VLC_A52_HEADER_SIZE ) != VLC_SUCCESS ) + VLC_A52_MIN_HEADER_SIZE ) != VLC_SUCCESS ) { msg_Dbg( p_dec, "emulated sync word" ); block_SkipByte( &p_sys->bytestream ); @@ -228,7 +228,7 @@ static block_t *PacketizeBlock( decoder_t *p_dec, block_t **pp_block ) case STATE_NEXT_SYNC: /* Check if next expected frame contains the sync word */ if( block_PeekOffsetBytes( &p_sys->bytestream, p_sys->i_input_size, - p_header, VLC_A52_HEADER_SIZE ) + p_header, VLC_A52_MIN_HEADER_SIZE ) != VLC_SUCCESS ) { if( p_block == NULL ) /* drain */ @@ -257,7 +257,7 @@ static block_t *PacketizeBlock( decoder_t *p_dec, block_t **pp_block ) } vlc_a52_header_t a52; - if( !vlc_a52_header_Parse( &a52, p_header, VLC_A52_HEADER_SIZE ) + if( !vlc_a52_header_Parse( &a52, p_header, VLC_A52_MIN_HEADER_SIZE ) && a52.b_eac3 && a52.bs.eac3.strmtyp == EAC3_STRMTYP_DEPENDENT ) p_sys->i_input_size += a52.i_size; diff --git a/modules/packetizer/a52.h b/modules/packetizer/a52.h index d9d6911225..e29b56b1e2 100644 --- a/modules/packetizer/a52.h +++ b/modules/packetizer/a52.h @@ -33,7 +33,9 @@ /** * Minimum AC3 header size that vlc_a52_header_Parse needs. */ -#define VLC_A52_HEADER_SIZE (8) +#define VLC_A52_MIN_HEADER_SIZE (8) +#define VLC_A52_EAC3_BSI_SIZE ((532 + 7)/8) +#define VLC_A52_EAC3_HEADER_SIZE (VLC_A52_EAC3_BSI_SIZE + 2) /** * AC3 header information. @@ -130,7 +132,7 @@ static inline int vlc_a52_header_ParseAc3( vlc_a52_header_t *p_header, { if( vlc_a52_ParseAc3BitstreamInfo( &p_header->bs, &p_buf[4], /* start code + CRC */ - VLC_A52_HEADER_SIZE - 4 ) != VLC_SUCCESS ) + VLC_A52_MIN_HEADER_SIZE - 4 ) != VLC_SUCCESS ) return VLC_EGENERIC; /* cf. Table 5.18 Frame Size Code Table */ @@ -249,7 +251,7 @@ static inline int vlc_a52_header_ParseEac3( vlc_a52_header_t *p_header, { if( vlc_a52_ParseEac3BitstreamInfo( &p_header->bs, &p_buf[2], /* start code */ - VLC_A52_HEADER_SIZE - 2 ) != VLC_SUCCESS ) + VLC_A52_MIN_HEADER_SIZE - 2 ) != VLC_SUCCESS ) return VLC_EGENERIC; const struct vlc_a52_bitstream_info *bs = &p_header->bs; @@ -306,7 +308,7 @@ static inline int vlc_a52_header_Parse( vlc_a52_header_t *p_header, 48000, 44100, 32000 }; - if( i_buffer < VLC_A52_HEADER_SIZE ) + if( i_buffer < VLC_A52_MIN_HEADER_SIZE ) return VLC_EGENERIC; /* Check synword */ _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
