Unified · Split
| @@ -96,12 +96,10 @@ typedef struct WavpackFrameContext { · 95 unmodified lines | |||
| 96 | uint8_t *value_lookup[MAX_HISTORY_BINS]; | 96 | uint8_t *value_lookup[MAX_HISTORY_BINS]; |
| 97 | } WavpackFrameContext; | 97 | } WavpackFrameContext; |
| 98 | 98 | ||
| 99 | #define WV_MAX_FRAME_DECODERS 14 | ||
| 100 | |||
| 101 | typedef struct WavpackContext { | 99 | typedef struct WavpackContext { |
| 102 | AVCodecContext *avctx; | 100 | AVCodecContext *avctx; |
| 103 | 101 | ||
| 104 | WavpackFrameContext *fdec[WV_MAX_FRAME_DECODERS]; | 102 | WavpackFrameContext **fdec; |
| 105 | int fdec_num; | 103 | int fdec_num; |
| 106 | 104 | ||
| 107 | int block; | 105 | int block; |
| @@ -971,7 +969,8 @@ static inline int wv_unpack_mono(WavpackFrameContext *s, GetBitContext *gb, · 863 unmodified lines | |||
| 971 | 969 | ||
| 972 | static av_cold int wv_alloc_frame_context(WavpackContext *c) | 970 | static av_cold int wv_alloc_frame_context(WavpackContext *c) |
| 973 | { | 971 | { |
| 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) | ||
| 975 | return -1; | 974 | return -1; |
| 976 | 975 | ||
| 977 | c->fdec[c->fdec_num] = av_mallocz(sizeof(**c->fdec)); | 976 | 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 | |||
| 1064 | 1063 | ||
| 1065 | for (int i = 0; i < s->fdec_num; i++) | 1064 | for (int i = 0; i < s->fdec_num; i++) |
| 1066 | av_freep(&s->fdec[i]); | 1065 | av_freep(&s->fdec[i]); |
| 1066 | av_freep(&s->fdec); | ||
| 1067 | s->fdec_num = 0; | 1067 | s->fdec_num = 0; |
| 1068 | 1068 | ||
| 1069 | ff_thread_release_ext_buffer(avctx, &s->curr_frame); | 1069 | 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 | |||
| 1415 | size = bytestream2_get_byte(&gb); | 1415 | size = bytestream2_get_byte(&gb); |
| 1416 | chan |= (bytestream2_get_byte(&gb) & 0xF) << 8; | 1416 | chan |= (bytestream2_get_byte(&gb) & 0xF) << 8; |
| 1417 | chan += 1; | 1417 | 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); | ||
| 1421 | chmask = bytestream2_get_le24(&gb); | 1418 | chmask = bytestream2_get_le24(&gb); |
| 1422 | break; | 1419 | break; |
| 1423 | case 5: | 1420 | case 5: |
| 1424 | size = bytestream2_get_byte(&gb); | 1421 | size = bytestream2_get_byte(&gb); |
| 1425 | chan |= (bytestream2_get_byte(&gb) & 0xF) << 8; | 1422 | chan |= (bytestream2_get_byte(&gb) & 0xF) << 8; |
| 1426 | chan += 1; | 1423 | 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); | ||
| 1430 | chmask = bytestream2_get_le32(&gb); | 1424 | chmask = bytestream2_get_le32(&gb); |
| 1431 | break; | 1425 | break; |
| 1432 | default: | 1426 | default: |
| @@ -1519,11 +1513,7 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, · 86 unmodified lines | |||
| 1519 | return AVERROR_INVALIDDATA; | 1513 | return AVERROR_INVALIDDATA; |
| 1520 | } | 1514 | } |
| 1521 | } else { | 1515 | } else { |
| 1522 | ret = av_channel_layout_copy(&new_ch_layout, &avctx->ch_layout); | 1516 | av_channel_layout_default(&new_ch_layout, chan); |
| 1523 | if (ret < 0) { | ||
| 1524 | av_log(avctx, AV_LOG_ERROR, "Error copying channel layout\n"); | ||
| 1525 | return ret; | ||
| 1526 | } | ||
| 1527 | } | 1517 | } |
| 1528 | } else { | 1518 | } else { |
| 1529 | av_channel_layout_default(&new_ch_layout, s->stereo + 1); | 1519 | av_channel_layout_default(&new_ch_layout, s->stereo + 1); |