[FFmpeg-cvslog] avutil/channel_layout: add av_get_extended_channel_layout
Marton Balint
git at videolan.org
Wed Jan 25 00:55:56 EET 2017
ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Mon Dec 26 01:19:34 2016 +0100| [c4618f842a2de85097627763f02931afc3fde6d9] | committer: Marton Balint
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 at passwd.hu>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c4618f842a2de85097627763f02931afc3fde6d9
---
doc/APIchanges | 3 +++
doc/utils.texi | 7 ++++++-
libavutil/channel_layout.c | 22 ++++++++++++++++++++++
libavutil/channel_layout.h | 14 ++++++++++++++
libavutil/version.h | 2 +-
5 files changed, 46 insertions(+), 2 deletions(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index f5f7e0c..109d550 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2015-08-28
API changes, most recent first:
+2017-01-24 - xxxxxxx - lavu 55.45.100 - channel_layout.h
+ Add av_get_extended_channel_layout()
+
2017-01-22 - xxxxxxx - lavu 55.44.100 - lfg.h
Add av_lfg_init_from_data().
diff --git a/doc/utils.texi b/doc/utils.texi
index df887c7..30a962a 100644
--- a/doc/utils.texi
+++ b/doc/utils.texi
@@ -725,13 +725,18 @@ layout for that number of channels (see the function
default layout.
@item
+a number of channels, in decimal, followed by 'C', yielding an unknown channel
+layout with the specified number of channels. Note that not all channel layout
+specification strings support unknown channel layouts.
+
+ at item
a channel layout mask, in hexadecimal starting with "0x" (see the
@code{AV_CH_*} macros in @file{libavutil/channel_layout.h}.
@end itemize
Before libavutil version 53 the trailing character "c" to specify a number of
channels was optional, but now it is required, while a channel layout mask can
-also be specified as a decimal number (if and only if not followed by "c").
+also be specified as a decimal number (if and only if not followed by "c" or "C").
See also the function @code{av_get_channel_layout} defined in
@file{libavutil/channel_layout.h}.
diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c
index 26c87c9..3bd5ee2 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)
{
diff --git a/libavutil/channel_layout.h b/libavutil/channel_layout.h
index 38c3337..50bb8f03 100644
--- a/libavutil/channel_layout.h
+++ b/libavutil/channel_layout.h
@@ -142,6 +142,20 @@ enum AVMatrixEncoding {
uint64_t av_get_channel_layout(const char *name);
/**
+ * Return a channel layout and the number of channels based on the specified name.
+ *
+ * This function is similar to (@see av_get_channel_layout), but can also parse
+ * unknown channel layout specifications.
+ *
+ * @param[in] name channel layout specification string
+ * @param[out] channel_layout parsed channel layout (0 if unknown)
+ * @param[out] nb_channels number of channels
+ *
+ * @return 0 on success, AVERROR(EINVAL) if the parsing fails.
+ */
+int av_get_extended_channel_layout(const char *name, uint64_t* channel_layout, int* nb_channels);
+
+/**
* Return a description of a channel layout.
* If nb_channels is <= 0, it is guessed from the channel_layout.
*
diff --git a/libavutil/version.h b/libavutil/version.h
index 2e83ef2..9d95086 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 55
-#define LIBAVUTIL_VERSION_MINOR 44
+#define LIBAVUTIL_VERSION_MINOR 45
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
More information about the ffmpeg-cvslog
mailing list