diff options
author | Marton Balint <cus@passwd.hu> | 2016-12-26 01:19:34 +0100 |
---|---|---|
committer | Marton Balint <cus@passwd.hu> | 2017-01-24 23:51:36 +0100 |
commit | c4618f842a2de85097627763f02931afc3fde6d9 (patch) | |
tree | 3ce0700ff1dfa7f52726aa984558c04cc3e5209f /libavutil/channel_layout.c | |
parent | 5049f05f27c20f0606209bf3508e1157e0eabc9e (diff) | |
download | ffmpeg-c4618f842a2de85097627763f02931afc3fde6d9.tar.gz |
avutil/channel_layout: add av_get_extended_channel_layout
Return a channel layout and the number of channels based on the specified name.
This function is similar to av_get_channel_layout(), but can also parse unknown
channel layout specifications.
Unknown channel layout specifications are a decimal number and a capital 'C'
suffix, in order to not break compatibility with the lowercase 'c' suffix,
which is used for a guessed channel layout with the specified number of
channels.
Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavutil/channel_layout.c')
-rw-r--r-- | libavutil/channel_layout.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c index 26c87c96a8..3bd5ee29b7 100644 --- a/libavutil/channel_layout.c +++ b/libavutil/channel_layout.c @@ -152,6 +152,28 @@ uint64_t av_get_channel_layout(const char *name) return layout; } +int av_get_extended_channel_layout(const char *name, uint64_t* channel_layout, int* nb_channels) +{ + int nb = 0; + char *end; + uint64_t layout = av_get_channel_layout(name); + + if (layout) { + *channel_layout = layout; + *nb_channels = av_get_channel_layout_nb_channels(layout); + return 0; + } + + nb = strtol(name, &end, 10); + if (!errno && *end == 'C' && *(end + 1) == '\0' && nb > 0 && nb < 64) { + *channel_layout = 0; + *nb_channels = nb; + return 0; + } + + return AVERROR(EINVAL); +} + void av_bprint_channel_layout(struct AVBPrint *bp, int nb_channels, uint64_t channel_layout) { |