Also, use the new function in the AC-3 encoder.
| ... | ... |
@@ -2074,7 +2074,7 @@ static av_cold int set_channel_info(AC3EncodeContext *s, int channels, |
| 2074 | 2074 |
return AVERROR(EINVAL); |
| 2075 | 2075 |
ch_layout = *channel_layout; |
| 2076 | 2076 |
if (!ch_layout) |
| 2077 |
- ch_layout = avcodec_guess_channel_layout(channels, CODEC_ID_AC3, NULL); |
|
| 2077 |
+ ch_layout = av_get_default_channel_layout(channels); |
|
| 2078 | 2078 |
|
| 2079 | 2079 |
s->lfe_on = !!(ch_layout & AV_CH_LOW_FREQUENCY); |
| 2080 | 2080 |
s->channels = channels; |
| ... | ... |
@@ -153,3 +153,18 @@ int av_get_channel_layout_nb_channels(uint64_t channel_layout) |
| 153 | 153 |
x &= x-1; // unset lowest set bit |
| 154 | 154 |
return count; |
| 155 | 155 |
} |
| 156 |
+ |
|
| 157 |
+uint64_t av_get_default_channel_layout(int nb_channels) |
|
| 158 |
+{
|
|
| 159 |
+ switch(nb_channels) {
|
|
| 160 |
+ case 1: return AV_CH_LAYOUT_MONO; |
|
| 161 |
+ case 2: return AV_CH_LAYOUT_STEREO; |
|
| 162 |
+ case 3: return AV_CH_LAYOUT_SURROUND; |
|
| 163 |
+ case 4: return AV_CH_LAYOUT_QUAD; |
|
| 164 |
+ case 5: return AV_CH_LAYOUT_5POINT0; |
|
| 165 |
+ case 6: return AV_CH_LAYOUT_5POINT1; |
|
| 166 |
+ case 7: return AV_CH_LAYOUT_6POINT1; |
|
| 167 |
+ case 8: return AV_CH_LAYOUT_7POINT1; |
|
| 168 |
+ default: return 0; |
|
| 169 |
+ } |
|
| 170 |
+} |
| ... | ... |
@@ -125,6 +125,11 @@ void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint |
| 125 | 125 |
int av_get_channel_layout_nb_channels(uint64_t channel_layout); |
| 126 | 126 |
|
| 127 | 127 |
/** |
| 128 |
+ * Return default channel layout for a given number of channels. |
|
| 129 |
+ */ |
|
| 130 |
+uint64_t av_get_default_channel_layout(int nb_channels); |
|
| 131 |
+ |
|
| 132 |
+/** |
|
| 128 | 133 |
* @} |
| 129 | 134 |
*/ |
| 130 | 135 |
|