- break;
- case AC3_INPUT_2F_1R:
- switch (to) {
- case AC3_OUTPUT_MONO:
- nf = 2.0 * LEVEL_MINUS_3DB / (2.0 + slev);
- ctx->chcoeffs[0] *= (nf * LEVEL_MINUS_3DB);
- ctx->chcoeffs[1] *= (nf * LEVEL_MINUS_3DB);
- ctx->chcoeffs[2] *= (nf * slev * LEVEL_MINUS_3DB);
- break;
- case AC3_OUTPUT_STEREO:
- nf = 1.0 / (1.0 + (slev * LEVEL_MINUS_3DB));
- ctx->chcoeffs[0] *= nf;
- ctx->chcoeffs[1] *= nf;
- ctx->chcoeffs[2] *= (nf * slev * LEVEL_MINUS_3DB);
- break;
- case AC3_OUTPUT_DOLBY:
- nf = 1.0 / (1.0 + LEVEL_MINUS_3DB);
- ctx->chcoeffs[0] *= nf;
- ctx->chcoeffs[1] *= nf;
- ctx->chcoeffs[2] *= (nf * LEVEL_MINUS_3DB);
- break;
- }
- break;
- case AC3_INPUT_3F_1R:
- switch (to) {
- case AC3_OUTPUT_MONO:
- nf = LEVEL_MINUS_3DB / (1.0 + clev + (slev / 2.0));
- ctx->chcoeffs[0] *= (nf * LEVEL_MINUS_3DB);
- ctx->chcoeffs[2] *= (nf * LEVEL_MINUS_3DB);
- ctx->chcoeffs[1] *= (nf * clev * LEVEL_PLUS_3DB);
- ctx->chcoeffs[3] *= (nf * slev * LEVEL_MINUS_3DB);
- break;
- case AC3_OUTPUT_STEREO:
- nf = 1.0 / (1.0 + clev + (slev * LEVEL_MINUS_3DB));
- ctx->chcoeffs[0] *= nf;
- ctx->chcoeffs[2] *= nf;
- ctx->chcoeffs[1] *= (nf * clev);
- ctx->chcoeffs[3] *= (nf * slev * LEVEL_MINUS_3DB);
- break;
- case AC3_OUTPUT_DOLBY:
- nf = 1.0 / (1.0 + (2.0 * LEVEL_MINUS_3DB));
- ctx->chcoeffs[0] *= nf;
- ctx->chcoeffs[1] *= nf;
- ctx->chcoeffs[1] *= (nf * LEVEL_MINUS_3DB);
- ctx->chcoeffs[3] *= (nf * LEVEL_MINUS_3DB);
- break;
- }
- break;
- case AC3_INPUT_2F_2R:
- switch (to) {
- case AC3_OUTPUT_MONO:
- nf = LEVEL_MINUS_3DB / (1.0 + slev);
- ctx->chcoeffs[0] *= (nf * LEVEL_MINUS_3DB);
- ctx->chcoeffs[1] *= (nf * LEVEL_MINUS_3DB);
- ctx->chcoeffs[2] *= (nf * slev * LEVEL_MINUS_3DB);
- ctx->chcoeffs[3] *= (nf * slev * LEVEL_MINUS_3DB);
- break;
- case AC3_OUTPUT_STEREO:
- nf = 1.0 / (1.0 + slev);
- ctx->chcoeffs[0] *= nf;
- ctx->chcoeffs[1] *= nf;
- ctx->chcoeffs[2] *= (nf * slev);
- ctx->chcoeffs[3] *= (nf * slev);
- break;
- case AC3_OUTPUT_DOLBY:
- nf = 1.0 / (1.0 + (2.0 * LEVEL_MINUS_3DB));
- ctx->chcoeffs[0] *= nf;
- ctx->chcoeffs[1] *= nf;
- ctx->chcoeffs[2] *= (nf * LEVEL_MINUS_3DB);
- ctx->chcoeffs[3] *= (nf * LEVEL_MINUS_3DB);
- break;
- }
- break;
- case AC3_INPUT_3F_2R:
- switch (to) {
- case AC3_OUTPUT_MONO:
- nf = LEVEL_MINUS_3DB / (1.0 + clev + slev);
- ctx->chcoeffs[0] *= (nf * LEVEL_MINUS_3DB);
- ctx->chcoeffs[2] *= (nf * LEVEL_MINUS_3DB);
- ctx->chcoeffs[1] *= (nf * clev * LEVEL_PLUS_3DB);
- ctx->chcoeffs[3] *= (nf * slev * LEVEL_MINUS_3DB);
- ctx->chcoeffs[4] *= (nf * slev * LEVEL_MINUS_3DB);
- break;
- case AC3_OUTPUT_STEREO:
- nf = 1.0 / (1.0 + clev + slev);
- ctx->chcoeffs[0] *= nf;
- ctx->chcoeffs[2] *= nf;
- ctx->chcoeffs[1] *= (nf * clev);
- ctx->chcoeffs[3] *= (nf * slev);
- ctx->chcoeffs[4] *= (nf * slev);
- break;
- case AC3_OUTPUT_DOLBY:
- nf = 1.0 / (1.0 + (3.0 * LEVEL_MINUS_3DB));
- ctx->chcoeffs[0] *= nf;
- ctx->chcoeffs[1] *= nf;
- ctx->chcoeffs[1] *= (nf * LEVEL_MINUS_3DB);
- ctx->chcoeffs[3] *= (nf * LEVEL_MINUS_3DB);
- ctx->chcoeffs[4] *= (nf * LEVEL_MINUS_3DB);
- break;
- }
- break;
- }
-}
-
-/*********** BEGIN DOWNMIX FUNCTIONS ***********/
-static inline void mix_dualmono_to_mono(AC3DecodeContext *ctx)
-{
- int i;
- float (*output)[BLOCK_SIZE] = ctx->output;
-
- for (i = 0; i < 256; i++)
- output[1][i] += output[2][i];
- memset(output[2], 0, sizeof(output[2]));
-}
-
-static inline void mix_dualmono_to_stereo(AC3DecodeContext *ctx)
-{
- int i;
- float tmp;
- float (*output)[BLOCK_SIZE] = ctx->output;
-
- for (i = 0; i < 256; i++) {
- tmp = output[1][i] + output[2][i];
- output[1][i] = output[2][i] = tmp;
- }
-}
-
-static inline void upmix_mono_to_stereo(AC3DecodeContext *ctx)
-{
- int i;
- float (*output)[BLOCK_SIZE] = ctx->output;
-
- for (i = 0; i < 256; i++)
- output[2][i] = output[1][i];
-}
-
-static inline void mix_stereo_to_mono(AC3DecodeContext *ctx)
-{
- int i;
- float (*output)[BLOCK_SIZE] = ctx->output;
-
- for (i = 0; i < 256; i++)
- output[1][i] += output[2][i];
- memset(output[2], 0, sizeof(output[2]));
-}
-
-static inline void mix_3f_to_mono(AC3DecodeContext *ctx)
-{
- int i;
- float (*output)[BLOCK_SIZE] = ctx->output;
-
- for (i = 0; i < 256; i++)
- output[1][i] += (output[2][i] + output[3][i]);
- memset(output[2], 0, sizeof(output[2]));
- memset(output[3], 0, sizeof(output[3]));
-}
-
-static inline void mix_3f_to_stereo(AC3DecodeContext *ctx)
-{
- int i;
- float (*output)[BLOCK_SIZE] = ctx->output;
-
- for (i = 0; i < 256; i++) {
- output[1][i] += output[2][i];
- output[2][i] += output[3][i];
- }
- memset(output[3], 0, sizeof(output[3]));
-}
-
-static inline void mix_2f_1r_to_mono(AC3DecodeContext *ctx)
-{
- int i;
- float (*output)[BLOCK_SIZE] = ctx->output;
-
- for (i = 0; i < 256; i++)
- output[1][i] += (output[2][i] + output[3][i]);
- memset(output[2], 0, sizeof(output[2]));
- memset(output[3], 0, sizeof(output[3]));
-
-}
-
-static inline void mix_2f_1r_to_stereo(AC3DecodeContext *ctx)
-{
- int i;
- float (*output)[BLOCK_SIZE] = ctx->output;
-
- for (i = 0; i < 256; i++) {
- output[1][i] += output[2][i];
- output[2][i] += output[3][i];
- }
- memset(output[3], 0, sizeof(output[3]));
-}
-
-static inline void mix_2f_1r_to_dolby(AC3DecodeContext *ctx)
-{
- int i;
- float (*output)[BLOCK_SIZE] = ctx->output;
-
- for (i = 0; i < 256; i++) {
- output[1][i] -= output[3][i];
- output[2][i] += output[3][i];
- }
- memset(output[3], 0, sizeof(output[3]));
-}
-
-static inline void mix_3f_1r_to_mono(AC3DecodeContext *ctx)
-{
- int i;
- float (*output)[BLOCK_SIZE] = ctx->output;
-
- for (i = 0; i < 256; i++)
- output[1][i] = (output[2][i] + output[3][i] + output[4][i]);
- memset(output[2], 0, sizeof(output[2]));
- memset(output[3], 0, sizeof(output[3]));
- memset(output[4], 0, sizeof(output[4]));
-}
-
-static inline void mix_3f_1r_to_stereo(AC3DecodeContext *ctx)
-{
- int i;
- float (*output)[BLOCK_SIZE] = ctx->output;
-
- for (i = 0; i < 256; i++) {
- output[1][i] += (output[2][i] + output[4][i]);
- output[2][i] += (output[3][i] + output[4][i]);
- }
- memset(output[3], 0, sizeof(output[3]));
- memset(output[4], 0, sizeof(output[4]));
-}
-
-static inline void mix_3f_1r_to_dolby(AC3DecodeContext *ctx)
-{
- int i;
- float (*output)[BLOCK_SIZE] = ctx->output;
-
- for (i = 0; i < 256; i++) {
- output[1][i] += (output[2][i] - output[4][i]);
- output[2][i] += (output[3][i] + output[4][i]);
- }
- memset(output[3], 0, sizeof(output[3]));
- memset(output[4], 0, sizeof(output[4]));
-}
-
-static inline void mix_2f_2r_to_mono(AC3DecodeContext *ctx)
-{
- int i;
- float (*output)[BLOCK_SIZE] = ctx->output;
-
- for (i = 0; i < 256; i++)
- output[1][i] = (output[2][i] + output[3][i] + output[4][i]);
- memset(output[2], 0, sizeof(output[2]));
- memset(output[3], 0, sizeof(output[3]));
- memset(output[4], 0, sizeof(output[4]));
-}
-
-static inline void mix_2f_2r_to_stereo(AC3DecodeContext *ctx)
-{
- int i;
- float (*output)[BLOCK_SIZE] = ctx->output;
-
- for (i = 0; i < 256; i++) {
- output[1][i] += output[3][i];
- output[2][i] += output[4][i];
- }
- memset(output[3], 0, sizeof(output[3]));
- memset(output[4], 0, sizeof(output[4]));
-}
-
-static inline void mix_2f_2r_to_dolby(AC3DecodeContext *ctx)
-{
- int i;
- float (*output)[BLOCK_SIZE] = ctx->output;
-
- for (i = 0; i < 256; i++) {
- output[1][i] -= output[3][i];
- output[2][i] += output[4][i];