@ -295,7 +295,6 @@ typedef struct {
int bit_rate ; ///< transmission bit rate
int bit_rate ; ///< transmission bit rate
int bit_rate_index ; ///< transmission bit rate index
int bit_rate_index ; ///< transmission bit rate index
int downmix ; ///< embedded downmix enabled
int dynrange ; ///< embedded dynamic range flag
int dynrange ; ///< embedded dynamic range flag
int timestamp ; ///< embedded time stamp flag
int timestamp ; ///< embedded time stamp flag
int aux_data ; ///< auxiliary data flag
int aux_data ; ///< auxiliary data flag
@ -569,7 +568,7 @@ static int dca_parse_frame_header(DCAContext *s)
if ( ! s - > bit_rate )
if ( ! s - > bit_rate )
return AVERROR_INVALIDDATA ;
return AVERROR_INVALIDDATA ;
s - > downmix = get_bits ( & s - > gb , 1 ) ;
skip_bits1 ( & s - > gb ) ; // always 0 (reserved, cf. ETSI TS 102 114 V1.4.1)
s - > dynrange = get_bits ( & s - > gb , 1 ) ;
s - > dynrange = get_bits ( & s - > gb , 1 ) ;
s - > timestamp = get_bits ( & s - > gb , 1 ) ;
s - > timestamp = get_bits ( & s - > gb , 1 ) ;
s - > aux_data = get_bits ( & s - > gb , 1 ) ;
s - > aux_data = get_bits ( & s - > gb , 1 ) ;
@ -615,7 +614,6 @@ static int dca_parse_frame_header(DCAContext *s)
s - > sample_rate ) ;
s - > sample_rate ) ;
av_log ( s - > avctx , AV_LOG_DEBUG , " bit rate: %i bits/s \n " ,
av_log ( s - > avctx , AV_LOG_DEBUG , " bit rate: %i bits/s \n " ,
s - > bit_rate ) ;
s - > bit_rate ) ;
av_log ( s - > avctx , AV_LOG_DEBUG , " downmix: %i \n " , s - > downmix ) ;
av_log ( s - > avctx , AV_LOG_DEBUG , " dynrange: %i \n " , s - > dynrange ) ;
av_log ( s - > avctx , AV_LOG_DEBUG , " dynrange: %i \n " , s - > dynrange ) ;
av_log ( s - > avctx , AV_LOG_DEBUG , " timestamp: %i \n " , s - > timestamp ) ;
av_log ( s - > avctx , AV_LOG_DEBUG , " timestamp: %i \n " , s - > timestamp ) ;
av_log ( s - > avctx , AV_LOG_DEBUG , " aux_data: %i \n " , s - > aux_data ) ;
av_log ( s - > avctx , AV_LOG_DEBUG , " aux_data: %i \n " , s - > aux_data ) ;
@ -800,28 +798,20 @@ static int dca_subframe_header(DCAContext *s, int base_channel, int block_index)
/* Stereo downmix coefficients */
/* Stereo downmix coefficients */
if ( ! base_channel & & s - > prim_channels > 2 ) {
if ( ! base_channel & & s - > prim_channels > 2 ) {
if ( s - > downmix ) {
int am = s - > amode & DCA_CHANNEL_MASK ;
for ( j = base_channel ; j < s - > prim_channels ; j + + ) {
if ( am > = FF_ARRAY_ELEMS ( dca_default_coeffs ) ) {
s - > downmix_coef [ j ] [ 0 ] = dca_downmix_coeffs [ get_bits ( & s - > gb , 7 ) ] ;
av_log ( s - > avctx , AV_LOG_ERROR ,
s - > downmix_coef [ j ] [ 1 ] = dca_downmix_coeffs [ get_bits ( & s - > gb , 7 ) ] ;
" Invalid channel mode %d \n " , am ) ;
}
return AVERROR_INVALIDDATA ;
} else {
}
int am = s - > amode & DCA_CHANNEL_MASK ;
if ( s - > prim_channels > FF_ARRAY_ELEMS ( dca_default_coeffs [ 0 ] ) ) {
if ( am > = FF_ARRAY_ELEMS ( dca_default_coeffs ) ) {
avpriv_request_sample ( s - > avctx , " Downmixing %d channels " ,
av_log ( s - > avctx , AV_LOG_ERROR ,
s - > prim_channels ) ;
" Invalid channel mode %d \n " , am ) ;
return AVERROR_PATCHWELCOME ;
return AVERROR_INVALIDDATA ;
}
}
for ( j = base_channel ; j < s - > prim_channels ; j + + ) {
if ( s - > prim_channels > FF_ARRAY_ELEMS ( dca_default_coeffs [ 0 ] ) ) {
s - > downmix_coef [ j ] [ 0 ] = dca_default_coeffs [ am ] [ j ] [ 0 ] ;
avpriv_request_sample ( s - > avctx , " Downmixing %d channels " ,
s - > downmix_coef [ j ] [ 1 ] = dca_default_coeffs [ am ] [ j ] [ 1 ] ;
s - > prim_channels ) ;
return AVERROR_PATCHWELCOME ;
}
for ( j = base_channel ; j < s - > prim_channels ; j + + ) {
s - > downmix_coef [ j ] [ 0 ] = dca_default_coeffs [ am ] [ j ] [ 0 ] ;
s - > downmix_coef [ j ] [ 1 ] = dca_default_coeffs [ am ] [ j ] [ 1 ] ;
}
}
}
}
}
@ -919,7 +909,7 @@ static int dca_subframe_header(DCAContext *s, int base_channel, int block_index)
av_log ( s - > avctx , AV_LOG_DEBUG , " \n " ) ;
av_log ( s - > avctx , AV_LOG_DEBUG , " \n " ) ;
}
}
}
}
if ( ! base_channel & & s - > prim_channels > 2 & & s - > downmix ) {
if ( ! base_channel & & s - > prim_channels > 2 ) {
av_log ( s - > avctx , AV_LOG_DEBUG , " Downmix coeffs: \n " ) ;
av_log ( s - > avctx , AV_LOG_DEBUG , " Downmix coeffs: \n " ) ;
for ( j = 0 ; j < s - > prim_channels ; j + + ) {
for ( j = 0 ; j < s - > prim_channels ; j + + ) {
av_log ( s - > avctx , AV_LOG_DEBUG , " Channel 0, %d = %f \n " , j ,
av_log ( s - > avctx , AV_LOG_DEBUG , " Channel 0, %d = %f \n " , j ,
@ -1319,7 +1309,7 @@ static int dca_subframe_footer(DCAContext *s, int base_channel)
for ( i = 0 ; i < aux_data_count ; i + + )
for ( i = 0 ; i < aux_data_count ; i + + )
get_bits ( & s - > gb , 8 ) ;
get_bits ( & s - > gb , 8 ) ;
if ( s - > crc_present & & ( s - > downmix | | s - > dynrange ) )
if ( s - > crc_present & & s - > dynrange )
get_bits ( & s - > gb , 16 ) ;
get_bits ( & s - > gb , 16 ) ;
}
}