Unified · Split
| @@ -192,3 +192,13 @@ uint64_t av_get_default_channel_layout(int nb_channels) · 191 unmodified lines | ||
| 192 | 192 | default: return 0; |
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | + | |
| 196 | +int av_get_channel_layout_channel_index(uint64_t channel_layout, | |
| 197 | + uint64_t channel) | |
| 198 | +{ | |
| 199 | + if (!(channel_layout & channel) || | |
| 200 | + av_get_channel_layout_nb_channels(channel) != 1) | |
| 201 | + return AVERROR(EINVAL); | |
| 202 | + channel_layout &= channel - 1; | |
| 203 | + return av_get_channel_layout_nb_channels(channel_layout); | |
| 204 | +} | |
| @@ -143,6 +143,18 @@ int av_get_channel_layout_nb_channels(uint64_t channel_layout); · 142 unmodified lines | ||
| 143 | 143 | */ |
| 144 | 144 | uint64_t av_get_default_channel_layout(int nb_channels); |
| 145 | 145 | |
| 146 | +/** | |
| 147 | + * Get the index of a channel in channel_layout. | |
| 148 | + * | |
| 149 | + * @param channel a channel layout describing exactly one channel which must be | |
| 150 | + * present in channel_layout. | |
| 151 | + * | |
| 152 | + * @return index of channel in channel_layout on success, a negative AVERROR | |
| 153 | + * on error. | |
| 154 | + */ | |
| 155 | +int av_get_channel_layout_channel_index(uint64_t channel_layout, | |
| 156 | + uint64_t channel); | |
| 157 | + | |
| 146 | 158 | /** |
| 147 | 159 | * @} |
| 148 | 160 | */ |