diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-06-10 21:34:15 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-06-10 21:34:15 +0200 |
commit | 3630a075132a8d059b16f92a291e523c1bc7ebc9 (patch) | |
tree | 37e9a6cbb8fced1a6e3f34dd348985ff8c081663 /libavutil | |
parent | 9e724d7216e693ba7af76caee5ccfb98c73d7a4b (diff) | |
parent | bcbb30e2a0f3be3e6b158694687d0fde2f6db625 (diff) | |
download | ffmpeg-3630a075132a8d059b16f92a291e523c1bc7ebc9.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
libmp3lame: add missing layout terminator
avconv: multithreaded demuxing.
Bump lavu minor and add an APIChanges entry for audioconvert functions.
audioconvert: add a function for extracting the channel with the given index
audioconvert: add a function for getting the name of a single channel.
audioconvert: add a function for getting channel's index in layout
audioconvert: use av_popcount64 in av_get_channel_layout_nb_channels
vf_libopencv: add missing headers.
iac: add missing dependency
Conflicts:
configure
doc/APIchanges
ffmpeg.c
libavcodec/libmp3lame.c
libavutil/avutil.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/audioconvert.c | 41 | ||||
-rw-r--r-- | libavutil/audioconvert.h | 24 | ||||
-rw-r--r-- | libavutil/avutil.h | 2 |
3 files changed, 61 insertions, 6 deletions
diff --git a/libavutil/audioconvert.c b/libavutil/audioconvert.c index 7dc7e9f1a7..e17f52ee59 100644 --- a/libavutil/audioconvert.c +++ b/libavutil/audioconvert.c @@ -182,11 +182,7 @@ void av_get_channel_layout_string(char *buf, int buf_size, int av_get_channel_layout_nb_channels(uint64_t channel_layout) { - int count; - uint64_t x = channel_layout; - for (count = 0; x; count++) - x &= x-1; // unset lowest set bit - return count; + return av_popcount64(channel_layout); } int64_t av_get_default_channel_layout(int nb_channels) { @@ -196,3 +192,38 @@ int64_t av_get_default_channel_layout(int nb_channels) { return channel_layout_map[i].layout; return 0; } + +int av_get_channel_layout_channel_index(uint64_t channel_layout, + uint64_t channel) +{ + if (!(channel_layout & channel) || + av_get_channel_layout_nb_channels(channel) != 1) + return AVERROR(EINVAL); + channel_layout &= channel - 1; + return av_get_channel_layout_nb_channels(channel_layout); +} + +const char *av_get_channel_name(uint64_t channel) +{ + int i; + if (av_get_channel_layout_nb_channels(channel) != 1) + return NULL; + for (i = 0; i < 64; i++) + if ((1ULL<<i) & channel) + return get_channel_name(i); + return NULL; +} + +uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index) +{ + int i; + + if (av_get_channel_layout_nb_channels(channel_layout) <= index) + return 0; + + for (i = 0; i < 64; i++) { + if ((1ULL << i) & channel_layout && !index--) + return 1ULL << i; + } + return 0; +} diff --git a/libavutil/audioconvert.h b/libavutil/audioconvert.h index 319cc8ab71..03e080cb26 100644 --- a/libavutil/audioconvert.h +++ b/libavutil/audioconvert.h @@ -150,6 +150,30 @@ int av_get_channel_layout_nb_channels(uint64_t channel_layout); int64_t av_get_default_channel_layout(int nb_channels); /** + * Get the index of a channel in channel_layout. + * + * @param channel a channel layout describing exactly one channel which must be + * present in channel_layout. + * + * @return index of channel in channel_layout on success, a negative AVERROR + * on error. + */ +int av_get_channel_layout_channel_index(uint64_t channel_layout, + uint64_t channel); + +/** + * Get the channel with the given index in channel_layout. + */ +uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index); + +/** + * Get the name of a given channel. + * + * @return channel name on success, NULL on error. + */ +const char *av_get_channel_name(uint64_t channel); + +/** * @} */ diff --git a/libavutil/avutil.h b/libavutil/avutil.h index 2e83d1fd11..02b9c7b2ed 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -153,7 +153,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 51 -#define LIBAVUTIL_VERSION_MINOR 56 +#define LIBAVUTIL_VERSION_MINOR 57 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ |