[003/200] lavc: deprecate channel count/layout changing side data

Message ID 20170517174712.8625-4-vittorio.giovara@gmail.com
State New
Headers show

Commit Message

Vittorio Giovara May 17, 2017, 5:46 p.m.
From: Anton Khirnov <anton@khirnov.net>

They are incompatible with the new channel layout scheme and no decoder
uses them.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
---
 libavcodec/avcodec.h | 5 +++++
 libavcodec/decode.c  | 4 ++++
 libavformat/dump.c   | 9 ++++++++-
 libavformat/utils.c  | 9 +++++++++
 4 files changed, 26 insertions(+), 1 deletion(-)

Comments

Luca Barbato May 23, 2017, 8:09 p.m. | #1
On 5/17/17 7:46 PM, Vittorio Giovara wrote:
> From: Anton Khirnov <anton@khirnov.net>
> 
> They are incompatible with the new channel layout scheme and no decoder
> uses them.
> 

Ok.

Patch

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 162f1abe4b..4089c08a24 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1165,8 +1165,13 @@  typedef struct AVPacket {
 #define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted
 
 enum AVSideDataParamChangeFlags {
+#if FF_API_OLD_CHANNEL_LAYOUT
+    /**
+     * @deprecated those are not used by any decoder
+     */
     AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT  = 0x0001,
     AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002,
+#endif
     AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE    = 0x0004,
     AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS     = 0x0008,
 };
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 8aa27095b6..8ad5104d6b 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -60,6 +60,8 @@  static int apply_param_change(AVCodecContext *avctx, AVPacket *avpkt)
     flags = bytestream_get_le32(&data);
     size -= 4;
 
+#if FF_API_OLD_CHANNEL_LAYOUT
+FF_DISABLE_DEPRECATION_WARNINGS
     if (flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT) {
         if (size < 4)
             goto fail;
@@ -72,6 +74,8 @@  static int apply_param_change(AVCodecContext *avctx, AVPacket *avpkt)
         avctx->channel_layout = bytestream_get_le64(&data);
         size -= 8;
     }
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     if (flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE) {
         if (size < 4)
             goto fail;
diff --git a/libavformat/dump.c b/libavformat/dump.c
index 261e21efd3..e1f6848547 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -142,8 +142,11 @@  static void dump_paramchange(void *ctx, AVPacketSideData *sd)
 {
     int size = sd->size;
     const uint8_t *data = sd->data;
-    uint32_t flags, channels, sample_rate, width, height;
+    uint32_t flags, sample_rate, width, height;
+#if FF_API_OLD_CHANNEL_LAYOUT
+    uint32_t channels;
     uint64_t layout;
+#endif
 
     if (!data || sd->size < 4)
         goto fail;
@@ -152,6 +155,8 @@  static void dump_paramchange(void *ctx, AVPacketSideData *sd)
     data += 4;
     size -= 4;
 
+#if FF_API_OLD_CHANNEL_LAYOUT
+FF_DISABLE_DEPRECATION_WARNINGS
     if (flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT) {
         if (size < 4)
             goto fail;
@@ -169,6 +174,8 @@  static void dump_paramchange(void *ctx, AVPacketSideData *sd)
         av_log(ctx, AV_LOG_INFO,
                "channel layout: %s, ", av_get_channel_name(layout));
     }
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif /* FF_API_OLD_CHANNEL_LAYOUT */
     if (flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE) {
         if (size < 4)
             goto fail;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index eaba473914..c8bb04aa70 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3234,6 +3234,9 @@  int ff_add_param_change(AVPacket *pkt, int32_t channels,
     uint8_t *data;
     if (!pkt)
         return AVERROR(EINVAL);
+
+#if FF_API_OLD_CHANNEL_LAYOUT
+FF_DISABLE_DEPRECATION_WARNINGS
     if (channels) {
         size  += 4;
         flags |= AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT;
@@ -3242,6 +3245,8 @@  int ff_add_param_change(AVPacket *pkt, int32_t channels,
         size  += 8;
         flags |= AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT;
     }
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     if (sample_rate) {
         size  += 4;
         flags |= AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE;
@@ -3254,10 +3259,14 @@  int ff_add_param_change(AVPacket *pkt, int32_t channels,
     if (!data)
         return AVERROR(ENOMEM);
     bytestream_put_le32(&data, flags);
+#if FF_API_OLD_CHANNEL_LAYOUT
+FF_DISABLE_DEPRECATION_WARNINGS
     if (channels)
         bytestream_put_le32(&data, channels);
     if (channel_layout)
         bytestream_put_le64(&data, channel_layout);
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     if (sample_rate)
         bytestream_put_le32(&data, sample_rate);
     if (width || height) {