History

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

Paul B Mahol committed 3 years ago

Commit 46412a81 parent ddc1cd51 file · +5 −15Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/wavpack.c+5−15
@@ -96,12 +96,10 @@ typedef struct WavpackFrameContext { · 95 unmodified lines
9696 uint8_t *value_lookup[MAX_HISTORY_BINS];
9797 } WavpackFrameContext;
9898
99−#define WV_MAX_FRAME_DECODERS 14
100−
10199 typedef struct WavpackContext {
102100 AVCodecContext *avctx;
103101
104− WavpackFrameContext *fdec[WV_MAX_FRAME_DECODERS];
102+ WavpackFrameContext **fdec;
105103 int fdec_num;
106104
107105 int block;
@@ -971,7 +969,8 @@ static inline int wv_unpack_mono(WavpackFrameContext *s, GetBitContext *gb, · 863 unmodified lines
971969
972970 static av_cold int wv_alloc_frame_context(WavpackContext *c)
973971 {
974− if (c->fdec_num == WV_MAX_FRAME_DECODERS)
972+ c->fdec = av_realloc_f(c->fdec, c->fdec_num + 1, sizeof(*c->fdec));
973+ if (!c->fdec)
975974 return -1;
976975
977976 c->fdec[c->fdec_num] = av_mallocz(sizeof(**c->fdec));
@@ -1064,6 +1063,7 @@ static av_cold int wavpack_decode_end(AVCodecContext *avctx) · 86 unmodified lines
10641063
10651064 for (int i = 0; i < s->fdec_num; i++)
10661065 av_freep(&s->fdec[i]);
1066+ av_freep(&s->fdec);
10671067 s->fdec_num = 0;
10681068
10691069 ff_thread_release_ext_buffer(avctx, &s->curr_frame);
@@ -1415,18 +1415,12 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, · 345 unmodified lines
14151415 size = bytestream2_get_byte(&gb);
14161416 chan |= (bytestream2_get_byte(&gb) & 0xF) << 8;
14171417 chan += 1;
1418− if (avctx->ch_layout.nb_channels != chan)
1419− av_log(avctx, AV_LOG_WARNING, "%i channels signalled"
1420− " instead of %i.\n", chan, avctx->ch_layout.nb_channels);
14211418 chmask = bytestream2_get_le24(&gb);
14221419 break;
14231420 case 5:
14241421 size = bytestream2_get_byte(&gb);
14251422 chan |= (bytestream2_get_byte(&gb) & 0xF) << 8;
14261423 chan += 1;
1427− if (avctx->ch_layout.nb_channels != chan)
1428− av_log(avctx, AV_LOG_WARNING, "%i channels signalled"
1429− " instead of %i.\n", chan, avctx->ch_layout.nb_channels);
14301424 chmask = bytestream2_get_le32(&gb);
14311425 break;
14321426 default:
@@ -1519,11 +1513,7 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, · 86 unmodified lines
15191513 return AVERROR_INVALIDDATA;
15201514 }
15211515 } else {
1522− ret = av_channel_layout_copy(&new_ch_layout, &avctx->ch_layout);
1523− if (ret < 0) {
1524− av_log(avctx, AV_LOG_ERROR, "Error copying channel layout\n");
1525− return ret;
1526− }
1516+ av_channel_layout_default(&new_ch_layout, chan);
15271517 }
15281518 } else {
15291519 av_channel_layout_default(&new_ch_layout, s->stereo + 1);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t