| 190 | } |
| 191 | |
| 192 | static uint64_t ac3_downmix_mask(int hb_mixdown, int normalized, const AVChannelLayout *input_layout, const char **dmix_mode) |
| 193 | { |
| 194 | /* |
| 195 | * ac3/eac3 bitstreams contain mix levels for center, surround and LFE channels. |
| 196 | * |
| 197 | * libavcodec's decoder can use them to build a normalized downmix matrix: |
| 198 | * libavcodec/ac3dec.c static int set_downmix_coeffs() |
| 199 | * |
| 200 | * and downmix to either mono or stereo specifically: |
| 201 | * libavcodec/ac3dsp.c static void ac3_downmix_c() |
| 202 | * |
| 203 | * We only do a decoder downmix here for a minor speed boost, as the mix levels |
| 204 | * are otherwise available to us via AV_FRAME_DATA_DOWNMIX_INFO, which we use |
| 205 | * in decodeAudio() to build the "regular" (non-normalized) downmix matrix. |
| 206 | * |
| 207 | * Note: the decoder ignores Lt/Rt-specific mix levels and is otherwise incapable of |
| 208 | * producing a Dolby Surround/PLII-compatible downmix: only use it for normal Stereo. |
| 209 | */ |
| 210 | if (normalized == 1) |
| 211 | { |
| 212 | uint64_t mask = 0; |
| 213 | switch (hb_mixdown) |
| 214 | { |
| 215 | case HB_AMIXDOWN_MONO: |
| 216 | case HB_AMIXDOWN_STEREO: |
| 217 | mask = hb_ff_mixdown_xlat(hb_mixdown, NULL); |
| 218 | break; |
| 219 | |
| 220 | default: |
| 221 | return 0; |
| 222 | } |
| 223 | if (mask) |
| 224 | { |
| 225 | AVChannelLayout mask_layout = {0}; |
| 226 | av_channel_layout_from_mask(&mask_layout, mask); |
| 227 | |
| 228 | if (downmix_required(&mask_layout, input_layout)) |
| 229 | { |
| 230 | /* |
| 231 | * We also set the existing decoder option "dmix_mode" to 2 (AC3_DMIXMOD_LORO) |
| 232 | * which is currently ignored by the decoder but should (theoretically) ensure |
| 233 | * we always get a regular Lo/Ro downmix, if the decoder were to ever gain the |
| 234 | * ability to do a Dolby/PLII downmix in the future. |
| 235 | */ |
| 236 | *dmix_mode = "2"; |
| 237 | av_channel_layout_uninit(&mask_layout); |
| 238 | return mask; |
| 239 | } |
| 240 | av_channel_layout_uninit(&mask_layout); |
| 241 | } |
| 242 | } |
| 243 | return 0; |
| 244 | } |
| 245 | |
| 246 | static uint64_t dca_downmix_mask(int hb_mixdown, int normalized, const AVChannelLayout *input_layout) |
| 247 | { |
no test coverage detected