static void set_downmix_coeffs ( AC3DecodeContext * s ) {
 int i ;
 float cmix = gain_levels [ s -> center_mix_level ] ;
 float smix = gain_levels [ s -> surround_mix_level ] ;
 float norm0 , norm1 ;
 for ( i = 0 ;
 i < s -> fbw_channels ;
 i ++ ) {
 s -> downmix_coeffs [ i ] [ 0 ] = gain_levels [ ac3_default_coeffs [ s -> channel_mode ] [ i ] [ 0 ] ] ;
 s -> downmix_coeffs [ i ] [ 1 ] = gain_levels [ ac3_default_coeffs [ s -> channel_mode ] [ i ] [ 1 ] ] ;
 }
 if ( s -> channel_mode > 1 && s -> channel_mode & 1 ) {
 s -> downmix_coeffs [ 1 ] [ 0 ] = s -> downmix_coeffs [ 1 ] [ 1 ] = cmix ;
 }
 if ( s -> channel_mode == AC3_CHMODE_2F1R || s -> channel_mode == AC3_CHMODE_3F1R ) {
 int nf = s -> channel_mode - 2 ;
 s -> downmix_coeffs [ nf ] [ 0 ] = s -> downmix_coeffs [ nf ] [ 1 ] = smix * LEVEL_MINUS_3DB ;
 }
 if ( s -> channel_mode == AC3_CHMODE_2F2R || s -> channel_mode == AC3_CHMODE_3F2R ) {
 int nf = s -> channel_mode - 4 ;
 s -> downmix_coeffs [ nf ] [ 0 ] = s -> downmix_coeffs [ nf + 1 ] [ 1 ] = smix ;
 }
 norm0 = norm1 = 0.0 ;
 for ( i = 0 ;
 i < s -> fbw_channels ;
 i ++ ) {
 norm0 += s -> downmix_coeffs [ i ] [ 0 ] ;
 norm1 += s -> downmix_coeffs [ i ] [ 1 ] ;
 }
 norm0 = 1.0f / norm0 ;
 norm1 = 1.0f / norm1 ;
 for ( i = 0 ;
 i < s -> fbw_channels ;
 i ++ ) {
 s -> downmix_coeffs [ i ] [ 0 ] *= norm0 ;
 s -> downmix_coeffs [ i ] [ 1 ] *= norm1 ;
 }
 if ( s -> output_mode == AC3_CHMODE_MONO ) {
 for ( i = 0 ;
 i < s -> fbw_channels ;
 i ++ ) s -> downmix_coeffs [ i ] [ 0 ] = ( s -> downmix_coeffs [ i ] [ 0 ] + s -> downmix_coeffs [ i ] [ 1 ] ) * LEVEL_MINUS_3DB ;
 }
 }
static void set_downmix_coeffs ( AC3DecodeContext * s ) {
 int i ;
 float cmix = gain_levels [ s -> center_mix_level ] ;
 float smix = gain_levels [ s -> surround_mix_level ] ;
 float norm0 , norm1 ;
 for ( i = 0 ;
 i < s -> fbw_channels ;
 i ++ ) {
 s -> downmix_coeffs [ i ] [ 0 ] = gain_levels [ ac3_default_coeffs [ s -> channel_mode ] [ i ] [ 0 ] ] ;
 s -> downmix_coeffs [ i ] [ 1 ] = gain_levels [ ac3_default_coeffs [ s -> channel_mode ] [ i ] [ 1 ] ] ;
 }
 if ( s -> channel_mode > 1 && s -> channel_mode & 1 ) {
 s -> downmix_coeffs [ 1 ] [ 0 ] = s -> downmix_coeffs [ 1 ] [ 1 ] = cmix ;
 }
 if ( s -> channel_mode == AC3_CHMODE_2F1R || s -> channel_mode == AC3_CHMODE_3F1R ) {
 int nf = s -> channel_mode - 2 ;
 s -> downmix_coeffs [ nf ] [ 0 ] = s -> downmix_coeffs [ nf ] [ 1 ] = smix * LEVEL_MINUS_3DB ;
 }
 if ( s -> channel_mode == AC3_CHMODE_2F2R || s -> channel_mode == AC3_CHMODE_3F2R ) {
 int nf = s -> channel_mode - 4 ;
 s -> downmix_coeffs [ nf ] [ 0 ] = s -> downmix_coeffs [ nf + 1 ] [ 1 ] = smix ;
 }
 norm0 = norm1 = 0.0 ;
 for ( i = 0 ;
 i < s -> fbw_channels ;
 i ++ ) {
 norm0 += s -> downmix_coeffs [ i ] [ 0 ] ;
 norm1 += s -> downmix_coeffs [ i ] [ 1 ] ;
 }
 norm0 = 1.0f / norm0 ;
 norm1 = 1.0f / norm1 ;
 for ( i = 0 ;
 i < s -> fbw_channels ;
 i ++ ) {
 s -> downmix_coeffs [ i ] [ 0 ] *= norm0 ;
 s -> downmix_coeffs [ i ] [ 1 ] *= norm1 ;
 }
 if ( s -> output_mode == AC3_CHMODE_MONO ) {
 for ( i = 0 ;
 i < s -> fbw_channels ;
 i ++ ) s -> downmix_coeffs [ i ] [ 0 ] = ( s -> downmix_coeffs [ i ] [ 0 ] + s -> downmix_coeffs [ i ] [ 1 ] ) * LEVEL_MINUS_3DB ;
 }
 }