[FFmpeg-cvslog] avcodec/wavpack: remove hard limitation on number of supported channels

Paul B Mahol git at videolan.org
Tue Aug 15 01:33:41 EEST 2023


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Tue Aug 15 00:12:52 2023 +0200| [46412a8935e4632b2460988bfce4152c7dccce22] | committer: Paul B Mahol

avcodec/wavpack: remove hard limitation on number of supported channels

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=46412a8935e4632b2460988bfce4152c7dccce22
---

 libavcodec/wavpack.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c
index 4346304f54..71e7d40c81 100644
--- a/libavcodec/wavpack.c
+++ b/libavcodec/wavpack.c
@@ -96,12 +96,10 @@ typedef struct WavpackFrameContext {
     uint8_t *value_lookup[MAX_HISTORY_BINS];
 } WavpackFrameContext;
 
-#define WV_MAX_FRAME_DECODERS 14
-
 typedef struct WavpackContext {
     AVCodecContext *avctx;
 
-    WavpackFrameContext *fdec[WV_MAX_FRAME_DECODERS];
+    WavpackFrameContext **fdec;
     int fdec_num;
 
     int block;
@@ -971,7 +969,8 @@ static inline int wv_unpack_mono(WavpackFrameContext *s, GetBitContext *gb,
 
 static av_cold int wv_alloc_frame_context(WavpackContext *c)
 {
-    if (c->fdec_num == WV_MAX_FRAME_DECODERS)
+    c->fdec = av_realloc_f(c->fdec, c->fdec_num + 1, sizeof(*c->fdec));
+    if (!c->fdec)
         return -1;
 
     c->fdec[c->fdec_num] = av_mallocz(sizeof(**c->fdec));
@@ -1064,6 +1063,7 @@ static av_cold int wavpack_decode_end(AVCodecContext *avctx)
 
     for (int i = 0; i < s->fdec_num; i++)
         av_freep(&s->fdec[i]);
+    av_freep(&s->fdec);
     s->fdec_num = 0;
 
     ff_thread_release_ext_buffer(avctx, &s->curr_frame);
@@ -1415,18 +1415,12 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no,
                 size = bytestream2_get_byte(&gb);
                 chan  |= (bytestream2_get_byte(&gb) & 0xF) << 8;
                 chan  += 1;
-                if (avctx->ch_layout.nb_channels != chan)
-                    av_log(avctx, AV_LOG_WARNING, "%i channels signalled"
-                           " instead of %i.\n", chan, avctx->ch_layout.nb_channels);
                 chmask = bytestream2_get_le24(&gb);
                 break;
             case 5:
                 size = bytestream2_get_byte(&gb);
                 chan  |= (bytestream2_get_byte(&gb) & 0xF) << 8;
                 chan  += 1;
-                if (avctx->ch_layout.nb_channels != chan)
-                    av_log(avctx, AV_LOG_WARNING, "%i channels signalled"
-                           " instead of %i.\n", chan, avctx->ch_layout.nb_channels);
                 chmask = bytestream2_get_le32(&gb);
                 break;
             default:
@@ -1519,11 +1513,7 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no,
                     return AVERROR_INVALIDDATA;
                 }
             } else {
-                ret = av_channel_layout_copy(&new_ch_layout, &avctx->ch_layout);
-                if (ret < 0) {
-                    av_log(avctx, AV_LOG_ERROR, "Error copying channel layout\n");
-                    return ret;
-                }
+                av_channel_layout_default(&new_ch_layout, chan);
             }
         } else {
             av_channel_layout_default(&new_ch_layout, s->stereo + 1);



More information about the ffmpeg-cvslog mailing list