| 157 | #define HB_AV_CH_BOTH_MASK (HB_AV_CH_SIDE_MASK|HB_AV_CH_BACK_MASK) |
| 158 | |
| 159 | static int downmix_required(const AVChannelLayout *target_layout_mask, const AVChannelLayout *input_layout_mask) |
| 160 | { |
| 161 | /* |
| 162 | * Side channels can easily be remapped to back channels and vice-versa. |
| 163 | * Provided the other channels are the same, downmixing is not required. |
| 164 | */ |
| 165 | if (av_channel_layout_subset(input_layout_mask, HB_AV_CH_SIDE_MASK) == 0 && |
| 166 | av_channel_layout_subset(input_layout_mask, HB_AV_CH_BACK_MASK) == HB_AV_CH_BACK_MASK) |
| 167 | { |
| 168 | if (av_channel_layout_subset(target_layout_mask, HB_AV_CH_BACK_MASK) == 0 && |
| 169 | av_channel_layout_subset(target_layout_mask, HB_AV_CH_SIDE_MASK) == HB_AV_CH_SIDE_MASK) |
| 170 | { |
| 171 | // input has back channels but not side channels |
| 172 | // target has the opposite (sides but not backs) |
| 173 | return (av_channel_layout_subset(input_layout_mask, ~HB_AV_CH_BOTH_MASK) != |
| 174 | av_channel_layout_subset(target_layout_mask, ~HB_AV_CH_BOTH_MASK)); |
| 175 | } |
| 176 | } |
| 177 | if (av_channel_layout_subset(input_layout_mask, HB_AV_CH_BACK_MASK) == 0 && |
| 178 | av_channel_layout_subset(input_layout_mask, HB_AV_CH_SIDE_MASK) == HB_AV_CH_SIDE_MASK) |
| 179 | { |
| 180 | if (av_channel_layout_subset(target_layout_mask, HB_AV_CH_SIDE_MASK) == 0 && |
| 181 | av_channel_layout_subset(target_layout_mask, HB_AV_CH_BACK_MASK) == HB_AV_CH_BACK_MASK) |
| 182 | { |
| 183 | // input has side channels but not back channels |
| 184 | // target has the opposite (backs but not sides) |
| 185 | return (av_channel_layout_subset(input_layout_mask, ~HB_AV_CH_BOTH_MASK) != |
| 186 | av_channel_layout_subset(target_layout_mask, ~HB_AV_CH_BOTH_MASK)); |
| 187 | } |
| 188 | } |
| 189 | return av_channel_layout_compare(input_layout_mask, target_layout_mask); |
| 190 | } |
| 191 | |
| 192 | static uint64_t ac3_downmix_mask(int hb_mixdown, int normalized, const AVChannelLayout *input_layout, const char **dmix_mode) |
| 193 | { |
no outgoing calls
no test coverage detected