@ -47,9 +47,16 @@ static const uint8_t center_levels[4] = { 4, 5, 6, 5 };
static const uint8_t surround_levels [ 4 ] = { 4 , 6 , 7 , 6 } ;
int avpriv_ac3_parse_header ( GetBitContext * gbc , AC3HeaderInfo * hdr )
int avpriv_ac3_parse_header2 ( GetBitContext * gbc , AC3HeaderInfo * * p hdr)
{
int frame_size_code ;
AC3HeaderInfo * hdr ;
if ( ! * phdr )
* phdr = av_mallocz ( sizeof ( AC3HeaderInfo ) ) ;
if ( ! * phdr )
return AVERROR ( ENOMEM ) ;
hdr = * phdr ;
memset ( hdr , 0 , sizeof ( * hdr ) ) ;
@ -144,6 +151,15 @@ int avpriv_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
return 0 ;
}
int avpriv_ac3_parse_header ( GetBitContext * gbc , AC3HeaderInfo * hdr )
{
AC3HeaderInfo tmp , * ptmp = & tmp ;
int ret = avpriv_ac3_parse_header2 ( gbc , & ptmp ) ;
memcpy ( hdr , ptmp , ( ( intptr_t ) & tmp . channel_layout ) - ( ( intptr_t ) & tmp ) + sizeof ( uint64_t ) ) ;
return ret ;
}
static int ac3_sync ( uint64_t state , AACAC3ParseContext * hdr_info ,
int * need_next_header , int * new_frame_start )
{
@ -152,11 +168,11 @@ static int ac3_sync(uint64_t state, AACAC3ParseContext *hdr_info,
uint64_t u64 ;
uint8_t u8 [ 8 ] ;
} tmp = { av_be2ne64 ( state ) } ;
AC3HeaderInfo hdr ;
AC3HeaderInfo hdr , * phdr = & hdr ;
GetBitContext gbc ;
init_get_bits ( & gbc , tmp . u8 + 8 - AC3_HEADER_SIZE , 54 ) ;
err = avpriv_ac3_parse_header ( & gbc , & hdr ) ;
err = avpriv_ac3_parse_header2 ( & gbc , & p hdr) ;
if ( err < 0 )
return 0 ;