Since the request_channel_layout is used only by a handful of codecs,
move the option to codec private contexts.
---
libavcodec/avcodec.h | 31 +
libavcodec/decode.c| 49 +-
libavcodec/encode.c| 9 ++-
libavcodec/internal.h | 2 +
libavcodec/options_table.h | 5 ++
libavcodec/utils.c | 162 +
libavformat/utils.c| 26 +++-
7 files changed, 220 insertions(+), 64 deletions(-)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index bc7097c7bd..b0eac85f72 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1834,7 +1834,13 @@ typedef struct AVCodecContext {
/* audio only */
int sample_rate; ///< samples per second
+#if FF_API_OLD_CHANNEL_LAYOUT
+/**
+ * @deprecated use ch_layout.nb_channels
+ */
+attribute_deprecated
int channels;///< number of audio channels
+#endif
/**
* audio sample format
@@ -1879,19 +1885,25 @@ typedef struct AVCodecContext {
*/
int cutoff;
+#if FF_API_OLD_CHANNEL_LAYOUT
/**
* Audio channel layout.
* - encoding: set by user.
* - decoding: set by libavcodec.
+ * @deprecated use ch_layout
*/
+attribute_deprecated
uint64_t channel_layout;
/**
* Request decoder to use this channel layout if it can (0 for default)
* - encoding: unused
* - decoding: Set by user.
+ * @deprecated use "downmix" codec private option
*/
+attribute_deprecated
uint64_t request_channel_layout;
+#endif
/**
* Type of service that the audio stream conveys.
@@ -2730,6 +2742,14 @@ typedef struct AVCodecContext {
* AVCodecContext.get_format callback)
*/
int hwaccel_flags;
+
+/**
+ * Audio channel layout.
+ * - encoding: must be set by the caller, to one of AVCodec.ch_layouts.
+ * - decoding: may be set by the caller if known e.g. from the container.
+ * The decoder can then override during decoding as needed.
+ */
+AVChannelLayout ch_layout;
} AVCodecContext;
/**
@@ -2771,10 +2791,21 @@ typedef struct AVCodec {
const enum AVPixelFormat *pix_fmts; ///< array of supported pixel
formats, or NULL if unknown, array is terminated by -1
const int *supported_samplerates; ///< array of supported audio
samplerates, or NULL if unknown, array is terminated by 0
const enum AVSampleFormat *sample_fmts; ///< array of supported sample
formats, or NULL if unknown, array is terminated by -1
+#if FF_API_OLD_CHANNEL_LAYOUT
+/**
+ * @deprecated use ch_layouts instead
+ */
+attribute_deprecated
const uint64_t *channel_layouts; ///< array of support channel
layouts, or NULL if unknown. array is terminated by 0
+#endif
const AVClass *priv_class; ///< AVClass for the private
context
const AVProfile *profiles; ///< array of recognized profiles,
or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
+/**
+ * Array of supported channel layouts, terminated with a zeroed layout.
+ */
+const AVChannelLayout *ch_layouts;
+
/*
* No fields below this line are part of the public API. They
* may not be used outside of libavcodec and can be changed and
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index b0d6b9fb33..c4bcfb95df 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1131,27 +1131,42 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame
*frame, int flags)
frame->sample_rate= avctx->sample_rate;
if (frame->format < 0)
frame->format = avctx->sample_fmt;
+#if FF_API_OLD_CHANNEL_LAYOUT
+FF_DISABLE_DEPRECATION_WARNINGS
+if (avctx->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ||
+avctx->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) {
+if (!frame->ch_layout.nb_channels && (avctx->channel_layout ||
avctx->channels)) {
+if (avctx->channel_layout)
+av_channel_layout_from_mask(&frame->ch_layout,
avctx->channel_layout);
+else
+av_channel_layout_default(&frame->ch_layout,
avctx->channels);
+}
+}
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (!frame->ch_layout.nb_channels) {
-if (avctx->channel_layout)
-av_channel_layout_from_mask(&frame->ch_layout,
avctx->channel_layout);
-else
-av_channel_layout_default(&frame->ch_layout, avctx->channels);
+ret = av_channel_layout_copy(&frame->ch_layout, &avctx->ch_layout);
+if (ret < 0)
+return ret;
}
#if FF_API_OLD_CHANNEL_LAYOUT
FF_DISABLE_DEPRECATION_WARNINGS
-/* set the deprecated channel_layout field for callers
- * that didn't update to t