Showing the changes to libavcodec/alsdec.c (1 of 1 file). Show all
Unified · Split
| @@ -319,7 +319,13 @@ static av_cold int read_specific_config(ALSDecContext *ctx) · 318 unmodified lines | |||
| 319 | avctx->sample_rate = m4ac.sample_rate; | 319 | avctx->sample_rate = m4ac.sample_rate; |
| 320 | skip_bits_long(&gb, 32); // sample rate already known | 320 | skip_bits_long(&gb, 32); // sample rate already known |
| 321 | sconf->samples = get_bits_long(&gb, 32); | 321 | sconf->samples = get_bits_long(&gb, 32); |
| 322 | avctx->channels = m4ac.channels; | 322 | |
| 323 | if (avctx->ch_layout.nb_channels != m4ac.channels) { | ||
| 324 | av_channel_layout_uninit(&avctx->ch_layout); | ||
| 325 | avctx->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; | ||
| 326 | avctx->ch_layout.nb_channels = m4ac.channels; | ||
| 327 | } | ||
| 328 | |||
| 323 | skip_bits(&gb, 16); // number of channels already known | 329 | skip_bits(&gb, 16); // number of channels already known |
| 324 | skip_bits(&gb, 3); // skip file_type | 330 | skip_bits(&gb, 3); // skip file_type |
| 325 | sconf->resolution = get_bits(&gb, 3); | 331 | sconf->resolution = get_bits(&gb, 3); |
| @@ -349,7 +355,7 @@ static av_cold int read_specific_config(ALSDecContext *ctx) · 23 unmodified lines | |||
| 349 | if (als_id != MKBETAG('A','L','S','\0')) | 355 | if (als_id != MKBETAG('A','L','S','\0')) |
| 350 | return AVERROR_INVALIDDATA; | 356 | return AVERROR_INVALIDDATA; |
| 351 | 357 | ||
| 352 | if (avctx->channels > FF_SANE_NB_CHANNELS) { | 358 | if (avctx->ch_layout.nb_channels > FF_SANE_NB_CHANNELS) { |
| 353 | avpriv_request_sample(avctx, "Huge number of channels"); | 359 | avpriv_request_sample(avctx, "Huge number of channels"); |
| 354 | return AVERROR_PATCHWELCOME; | 360 | return AVERROR_PATCHWELCOME; |
| 355 | } | 361 | } |
| @@ -363,26 +369,26 @@ static av_cold int read_specific_config(ALSDecContext *ctx) · 7 unmodified lines | |||
| 363 | 369 | ||
| 364 | 370 | ||
| 365 | // read channel sorting | 371 | // read channel sorting |
| 366 | if (sconf->chan_sort && avctx->channels > 1) { | 372 | if (sconf->chan_sort && avctx->ch_layout.nb_channels > 1) { |
| 367 | int chan_pos_bits = av_ceil_log2(avctx->channels); | 373 | int chan_pos_bits = av_ceil_log2(avctx->ch_layout.nb_channels); |
| 368 | int bits_needed = avctx->channels * chan_pos_bits + 7; | 374 | int bits_needed = avctx->ch_layout.nb_channels * chan_pos_bits + 7; |
| 369 | if (get_bits_left(&gb) < bits_needed) | 375 | if (get_bits_left(&gb) < bits_needed) |
| 370 | return AVERROR_INVALIDDATA; | 376 | return AVERROR_INVALIDDATA; |
| 371 | 377 | ||
| 372 | if (!(sconf->chan_pos = av_malloc_array(avctx->channels, sizeof(*sconf->chan_pos)))) | 378 | if (!(sconf->chan_pos = av_malloc_array(avctx->ch_layout.nb_channels, sizeof(*sconf->chan_pos)))) |
| 373 | return AVERROR(ENOMEM); | 379 | return AVERROR(ENOMEM); |
| 374 | 380 | ||
| 375 | ctx->cs_switch = 1; | 381 | ctx->cs_switch = 1; |
| 376 | 382 | ||
| 377 | for (i = 0; i < avctx->channels; i++) { | 383 | for (i = 0; i < avctx->ch_layout.nb_channels; i++) { |
| 378 | sconf->chan_pos[i] = -1; | 384 | sconf->chan_pos[i] = -1; |
| 379 | } | 385 | } |
| 380 | 386 | ||
| 381 | for (i = 0; i < avctx->channels; i++) { | 387 | for (i = 0; i < avctx->ch_layout.nb_channels; i++) { |
| 382 | int idx; | 388 | int idx; |
| 383 | 389 | ||
| 384 | idx = get_bits(&gb, chan_pos_bits); | 390 | idx = get_bits(&gb, chan_pos_bits); |
| 385 | if (idx >= avctx->channels || sconf->chan_pos[idx] != -1) { | 391 | if (idx >= avctx->ch_layout.nb_channels || sconf->chan_pos[idx] != -1) { |
| 386 | av_log(avctx, AV_LOG_WARNING, "Invalid channel reordering.\n"); | 392 | av_log(avctx, AV_LOG_WARNING, "Invalid channel reordering.\n"); |
| 387 | ctx->cs_switch = 0; | 393 | ctx->cs_switch = 0; |
| 388 | break; | 394 | break; |
| @@ -1228,7 +1234,7 @@ static int read_channel_data(ALSDecContext *ctx, ALSChannelData *cd, int c) · 839 unmodified lines | |||
| 1228 | { | 1234 | { |
| 1229 | GetBitContext *gb = &ctx->gb; | 1235 | GetBitContext *gb = &ctx->gb; |
| 1230 | ALSChannelData *current = cd; | 1236 | ALSChannelData *current = cd; |
| 1231 | unsigned int channels = ctx->avctx->channels; | 1237 | unsigned int channels = ctx->avctx->ch_layout.nb_channels; |
| 1232 | int entries = 0; | 1238 | int entries = 0; |
| 1233 | 1239 | ||
| 1234 | while (entries < channels && !(current->stop_flag = get_bits1(gb))) { | 1240 | while (entries < channels && !(current->stop_flag = get_bits1(gb))) { |
| @@ -1277,7 +1283,7 @@ static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd, · 42 unmodified lines | |||
| 1277 | { | 1283 | { |
| 1278 | ALSChannelData *ch = cd[c]; | 1284 | ALSChannelData *ch = cd[c]; |
| 1279 | unsigned int dep = 0; | 1285 | unsigned int dep = 0; |
| 1280 | unsigned int channels = ctx->avctx->channels; | 1286 | unsigned int channels = ctx->avctx->ch_layout.nb_channels; |
| 1281 | unsigned int channel_size = ctx->sconf.frame_length + ctx->sconf.max_order; | 1287 | unsigned int channel_size = ctx->sconf.frame_length + ctx->sconf.max_order; |
| 1282 | 1288 | ||
| 1283 | if (reverted[c]) | 1289 | if (reverted[c]) |
| @@ -1475,15 +1481,15 @@ static int read_diff_float_data(ALSDecContext *ctx, unsigned int ra_frame) { · 191 unmodified lines | |||
| 1475 | use_acf = get_bits1(gb); | 1481 | use_acf = get_bits1(gb); |
| 1476 | 1482 | ||
| 1477 | if (ra_frame) { | 1483 | if (ra_frame) { |
| 1478 | memset(last_acf_mantissa, 0, avctx->channels * sizeof(*last_acf_mantissa)); | 1484 | memset(last_acf_mantissa, 0, avctx->ch_layout.nb_channels * sizeof(*last_acf_mantissa)); |
| 1479 | memset(last_shift_value, 0, avctx->channels * sizeof(*last_shift_value) ); | 1485 | memset(last_shift_value, 0, avctx->ch_layout.nb_channels * sizeof(*last_shift_value) ); |
| 1480 | ff_mlz_flush_dict(ctx->mlz); | 1486 | ff_mlz_flush_dict(ctx->mlz); |
| 1481 | } | 1487 | } |
| 1482 | 1488 | ||
| 1483 | if (avctx->channels * 8 > get_bits_left(gb)) | 1489 | if (avctx->ch_layout.nb_channels * 8 > get_bits_left(gb)) |
| 1484 | return AVERROR_INVALIDDATA; | 1490 | return AVERROR_INVALIDDATA; |
| 1485 | 1491 | ||
| 1486 | for (c = 0; c < avctx->channels; ++c) { | 1492 | for (c = 0; c < avctx->ch_layout.nb_channels; ++c) { |
| 1487 | if (use_acf) { | 1493 | if (use_acf) { |
| 1488 | //acf_flag | 1494 | //acf_flag |
| 1489 | if (get_bits1(gb)) { | 1495 | if (get_bits1(gb)) { |
| @@ -1634,6 +1640,7 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame) · 144 unmodified lines | |||
| 1634 | unsigned int div_blocks[32]; ///< block sizes. | 1640 | unsigned int div_blocks[32]; ///< block sizes. |
| 1635 | int c; | 1641 | int c; |
| 1636 | unsigned int js_blocks[2]; | 1642 | unsigned int js_blocks[2]; |
| 1643 | int channels = avctx->ch_layout.nb_channels; | ||
| 1637 | uint32_t bs_info = 0; | 1644 | uint32_t bs_info = 0; |
| 1638 | int ret; | 1645 | int ret; |
| 1639 | 1646 | ||
| @@ -1649,7 +1656,7 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame) · 9 unmodified lines | |||
| 1649 | if (!sconf->mc_coding || ctx->js_switch) { | 1656 | if (!sconf->mc_coding || ctx->js_switch) { |
| 1650 | int independent_bs = !sconf->joint_stereo; | 1657 | int independent_bs = !sconf->joint_stereo; |
| 1651 | 1658 | ||
| 1652 | for (c = 0; c < avctx->channels; c++) { | 1659 | for (c = 0; c < channels; c++) { |
| 1653 | js_blocks[0] = 0; | 1660 | js_blocks[0] = 0; |
| 1654 | js_blocks[1] = 0; | 1661 | js_blocks[1] = 0; |
| 1655 | 1662 | ||
| @@ -1662,7 +1669,7 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame) · 6 unmodified lines | |||
| 1662 | independent_bs = 2; | 1669 | independent_bs = 2; |
| 1663 | 1670 | ||
| 1664 | // if this is the last channel, it has to be decoded independently | 1671 | // if this is the last channel, it has to be decoded independently |
| 1665 | if (c == avctx->channels - 1 || (c & 1)) | 1672 | if (c == channels - 1 || (c & 1)) |
| 1666 | independent_bs = 1; | 1673 | independent_bs = 1; |
| 1667 | 1674 | ||
| 1668 | if (independent_bs) { | 1675 | if (independent_bs) { |
| @@ -1691,13 +1698,13 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame) · 22 unmodified lines | |||
| 1691 | int *reverted_channels = ctx->reverted_channels; | 1698 | int *reverted_channels = ctx->reverted_channels; |
| 1692 | unsigned int offset = 0; | 1699 | unsigned int offset = 0; |
| 1693 | 1700 | ||
| 1694 | for (c = 0; c < avctx->channels; c++) | 1701 | for (c = 0; c < channels; c++) |
| 1695 | if (ctx->chan_data[c] < ctx->chan_data_buffer) { | 1702 | if (ctx->chan_data[c] < ctx->chan_data_buffer) { |
| 1696 | av_log(ctx->avctx, AV_LOG_ERROR, "Invalid channel data.\n"); | 1703 | av_log(ctx->avctx, AV_LOG_ERROR, "Invalid channel data.\n"); |
| 1697 | return AVERROR_INVALIDDATA; | 1704 | return AVERROR_INVALIDDATA; |
| 1698 | } | 1705 | } |
| 1699 | 1706 | ||
| 1700 | memset(reverted_channels, 0, sizeof(*reverted_channels) * avctx->channels); | 1707 | memset(reverted_channels, 0, sizeof(*reverted_channels) * channels); |
| 1701 | 1708 | ||
| 1702 | bd.ra_block = ra_frame; | 1709 | bd.ra_block = ra_frame; |
| 1703 | bd.prev_raw_samples = ctx->prev_raw_samples; | 1710 | bd.prev_raw_samples = ctx->prev_raw_samples; |
| @@ -1713,7 +1720,7 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame) · 9 unmodified lines | |||
| 1713 | continue; | 1720 | continue; |
| 1714 | } | 1721 | } |
| 1715 | 1722 | ||
| 1716 | for (c = 0; c < avctx->channels; c++) { | 1723 | for (c = 0; c < channels; c++) { |
| 1717 | bd.const_block = ctx->const_block + c; | 1724 | bd.const_block = ctx->const_block + c; |
| 1718 | bd.shift_lsbs = ctx->shift_lsbs + c; | 1725 | bd.shift_lsbs = ctx->shift_lsbs + c; |
| 1719 | bd.opt_order = ctx->opt_order + c; | 1726 | bd.opt_order = ctx->opt_order + c; |
| @@ -1732,13 +1739,13 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame) · 12 unmodified lines | |||
| 1732 | return ret; | 1739 | return ret; |
| 1733 | } | 1740 | } |
| 1734 | 1741 | ||
| 1735 | for (c = 0; c < avctx->channels; c++) { | 1742 | for (c = 0; c < channels; c++) { |
| 1736 | ret = revert_channel_correlation(ctx, &bd, ctx->chan_data, | 1743 | ret = revert_channel_correlation(ctx, &bd, ctx->chan_data, |
| 1737 | reverted_channels, offset, c); | 1744 | reverted_channels, offset, c); |
| 1738 | if (ret < 0) | 1745 | if (ret < 0) |
| 1739 | return ret; | 1746 | return ret; |
| 1740 | } | 1747 | } |
| 1741 | for (c = 0; c < avctx->channels; c++) { | 1748 | for (c = 0; c < channels; c++) { |
| 1742 | bd.const_block = ctx->const_block + c; | 1749 | bd.const_block = ctx->const_block + c; |
| 1743 | bd.shift_lsbs = ctx->shift_lsbs + c; | 1750 | bd.shift_lsbs = ctx->shift_lsbs + c; |
| 1744 | bd.opt_order = ctx->opt_order + c; | 1751 | bd.opt_order = ctx->opt_order + c; |
| @@ -1756,13 +1763,13 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame) · 11 unmodified lines | |||
| 1756 | ctx->highest_decoded_channel = FFMAX(ctx->highest_decoded_channel, c); | 1763 | ctx->highest_decoded_channel = FFMAX(ctx->highest_decoded_channel, c); |
| 1757 | } | 1764 | } |
| 1758 | 1765 | ||
| 1759 | memset(reverted_channels, 0, avctx->channels * sizeof(*reverted_channels)); | 1766 | memset(reverted_channels, 0, channels * sizeof(*reverted_channels)); |
| 1760 | offset += div_blocks[b]; | 1767 | offset += div_blocks[b]; |
| 1761 | bd.ra_block = 0; | 1768 | bd.ra_block = 0; |
| 1762 | } | 1769 | } |
| 1763 | 1770 | ||
| 1764 | // store carryover raw samples | 1771 | // store carryover raw samples |
| 1765 | for (c = 0; c < avctx->channels; c++) | 1772 | for (c = 0; c < channels; c++) |
| 1766 | memmove(ctx->raw_samples[c] - sconf->max_order, | 1773 | memmove(ctx->raw_samples[c] - sconf->max_order, |
| 1767 | ctx->raw_samples[c] - sconf->max_order + sconf->frame_length, | 1774 | ctx->raw_samples[c] - sconf->max_order + sconf->frame_length, |
| 1768 | sizeof(*ctx->raw_samples[c]) * sconf->max_order); | 1775 | sizeof(*ctx->raw_samples[c]) * sconf->max_order); |
| @@ -1792,6 +1799,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, · 23 unmodified lines | |||
| 1792 | const uint8_t *buffer = avpkt->data; | 1799 | const uint8_t *buffer = avpkt->data; |
| 1793 | int buffer_size = avpkt->size; | 1800 | int buffer_size = avpkt->size; |
| 1794 | int invalid_frame, ret; | 1801 | int invalid_frame, ret; |
| 1802 | int channels = avctx->ch_layout.nb_channels; | ||
| 1795 | unsigned int c, sample, ra_frame, bytes_read, shift; | 1803 | unsigned int c, sample, ra_frame, bytes_read, shift; |
| 1796 | 1804 | ||
| 1797 | if ((ret = init_get_bits8(&ctx->gb, buffer, buffer_size)) < 0) | 1805 | if ((ret = init_get_bits8(&ctx->gb, buffer, buffer_size)) < 0) |
| @@ -1833,7 +1841,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, · 35 unmodified lines | |||
| 1833 | #define INTERLEAVE_OUTPUT(bps) \ | 1841 | #define INTERLEAVE_OUTPUT(bps) \ |
| 1834 | { \ | 1842 | { \ |
| 1835 | int##bps##_t *dest = (int##bps##_t*)frame->data[0]; \ | 1843 | int##bps##_t *dest = (int##bps##_t*)frame->data[0]; \ |
| 1836 | int channels = avctx->channels; \ | ||
| 1837 | int32_t *raw_samples = ctx->raw_samples[0]; \ | 1844 | int32_t *raw_samples = ctx->raw_samples[0]; \ |
| 1838 | int raw_step = channels > 1 ? ctx->raw_samples[1] - raw_samples : 1; \ | 1845 | int raw_step = channels > 1 ? ctx->raw_samples[1] - raw_samples : 1; \ |
| 1839 | shift = bps - ctx->avctx->bits_per_raw_sample; \ | 1846 | shift = bps - ctx->avctx->bits_per_raw_sample; \ |
| @@ -1862,7 +1869,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, · 22 unmodified lines | |||
| 1862 | int32_t *src = (int32_t *)frame->data[0]; | 1869 | int32_t *src = (int32_t *)frame->data[0]; |
| 1863 | 1870 | ||
| 1864 | for (sample = 0; | 1871 | for (sample = 0; |
| 1865 | sample < ctx->cur_frame_length * avctx->channels; | 1872 | sample < ctx->cur_frame_length * channels; |
| 1866 | sample++) { | 1873 | sample++) { |
| 1867 | int32_t v; | 1874 | int32_t v; |
| 1868 | 1875 | ||
| @@ -1883,13 +1890,13 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, · 14 unmodified lines | |||
| 1883 | int16_t *src = (int16_t*) frame->data[0]; | 1890 | int16_t *src = (int16_t*) frame->data[0]; |
| 1884 | int16_t *dest = (int16_t*) ctx->crc_buffer; | 1891 | int16_t *dest = (int16_t*) ctx->crc_buffer; |
| 1885 | for (sample = 0; | 1892 | for (sample = 0; |
| 1886 | sample < ctx->cur_frame_length * avctx->channels; | 1893 | sample < ctx->cur_frame_length * channels; |
| 1887 | sample++) | 1894 | sample++) |
| 1888 | *dest++ = av_bswap16(src[sample]); | 1895 | *dest++ = av_bswap16(src[sample]); |
| 1889 | } else { | 1896 | } else { |
| 1890 | ctx->bdsp.bswap_buf((uint32_t *) ctx->crc_buffer, | 1897 | ctx->bdsp.bswap_buf((uint32_t *) ctx->crc_buffer, |
| 1891 | (uint32_t *) frame->data[0], | 1898 | (uint32_t *) frame->data[0], |
| 1892 | ctx->cur_frame_length * avctx->channels); | 1899 | ctx->cur_frame_length * channels); |
| 1893 | } | 1900 | } |
| 1894 | crc_source = ctx->crc_buffer; | 1901 | crc_source = ctx->crc_buffer; |
| 1895 | } else { | 1902 | } else { |
| @@ -1897,7 +1904,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, · 1 unmodified line | |||
| 1897 | } | 1904 | } |
| 1898 | 1905 | ||
| 1899 | ctx->crc = av_crc(ctx->crc_table, ctx->crc, crc_source, | 1906 | ctx->crc = av_crc(ctx->crc_table, ctx->crc, crc_source, |
| 1900 | ctx->cur_frame_length * avctx->channels * | 1907 | ctx->cur_frame_length * channels * |
| 1901 | av_get_bytes_per_sample(avctx->sample_fmt)); | 1908 | av_get_bytes_per_sample(avctx->sample_fmt)); |
| 1902 | } | 1909 | } |
| 1903 | 1910 | ||
| @@ -1960,7 +1967,7 @@ static av_cold int decode_end(AVCodecContext *avctx) · 56 unmodified lines | |||
| 1960 | av_freep(&ctx->shift_value); | 1967 | av_freep(&ctx->shift_value); |
| 1961 | av_freep(&ctx->last_shift_value); | 1968 | av_freep(&ctx->last_shift_value); |
| 1962 | if (ctx->raw_mantissa) { | 1969 | if (ctx->raw_mantissa) { |
| 1963 | for (i = 0; i < avctx->channels; i++) { | 1970 | for (i = 0; i < avctx->ch_layout.nb_channels; i++) { |
| 1964 | av_freep(&ctx->raw_mantissa[i]); | 1971 | av_freep(&ctx->raw_mantissa[i]); |
| 1965 | } | 1972 | } |
| 1966 | av_freep(&ctx->raw_mantissa); | 1973 | av_freep(&ctx->raw_mantissa); |
| @@ -1979,6 +1986,7 @@ static av_cold int decode_init(AVCodecContext *avctx) · 12 unmodified lines | |||
| 1979 | unsigned int c; | 1986 | unsigned int c; |
| 1980 | unsigned int channel_size; | 1987 | unsigned int channel_size; |
| 1981 | int num_buffers, ret; | 1988 | int num_buffers, ret; |
| 1989 | int channels = avctx->ch_layout.nb_channels; | ||
| 1982 | ALSDecContext *ctx = avctx->priv_data; | 1990 | ALSDecContext *ctx = avctx->priv_data; |
| 1983 | ALSSpecificConfig *sconf = &ctx->sconf; | 1991 | ALSSpecificConfig *sconf = &ctx->sconf; |
| 1984 | ctx->avctx = avctx; | 1992 | ctx->avctx = avctx; |
| @@ -2026,7 +2034,7 @@ static av_cold int decode_init(AVCodecContext *avctx) · 41 unmodified lines | |||
| 2026 | (avctx->sample_rate >= 192000); | 2034 | (avctx->sample_rate >= 192000); |
| 2027 | 2035 | ||
| 2028 | // allocate quantized parcor coefficient buffer | 2036 | // allocate quantized parcor coefficient buffer |
| 2029 | num_buffers = sconf->mc_coding ? avctx->channels : 1; | 2037 | num_buffers = sconf->mc_coding ? channels : 1; |
| 2030 | if (num_buffers * (uint64_t)num_buffers > INT_MAX) // protect chan_data_buffer allocation | 2038 | if (num_buffers * (uint64_t)num_buffers > INT_MAX) // protect chan_data_buffer allocation |
| 2031 | return AVERROR_INVALIDDATA; | 2039 | return AVERROR_INVALIDDATA; |
| 2032 | 2040 | ||
| @@ -2095,11 +2103,11 @@ static av_cold int decode_init(AVCodecContext *avctx) · 62 unmodified lines | |||
| 2095 | } | 2103 | } |
| 2096 | 2104 | ||
| 2097 | if (sconf->floating) { | 2105 | if (sconf->floating) { |
| 2098 | ctx->acf = av_malloc_array(avctx->channels, sizeof(*ctx->acf)); | 2106 | ctx->acf = av_malloc_array(channels, sizeof(*ctx->acf)); |
| 2099 | ctx->shift_value = av_malloc_array(avctx->channels, sizeof(*ctx->shift_value)); | 2107 | ctx->shift_value = av_malloc_array(channels, sizeof(*ctx->shift_value)); |
| 2100 | ctx->last_shift_value = av_malloc_array(avctx->channels, sizeof(*ctx->last_shift_value)); | 2108 | ctx->last_shift_value = av_malloc_array(channels, sizeof(*ctx->last_shift_value)); |
| 2101 | ctx->last_acf_mantissa = av_malloc_array(avctx->channels, sizeof(*ctx->last_acf_mantissa)); | 2109 | ctx->last_acf_mantissa = av_malloc_array(channels, sizeof(*ctx->last_acf_mantissa)); |
| 2102 | ctx->raw_mantissa = av_calloc(avctx->channels, sizeof(*ctx->raw_mantissa)); | 2110 | ctx->raw_mantissa = av_calloc(channels, sizeof(*ctx->raw_mantissa)); |
| 2103 | 2111 | ||
| 2104 | ctx->larray = av_malloc_array(ctx->cur_frame_length * 4, sizeof(*ctx->larray)); | 2112 | ctx->larray = av_malloc_array(ctx->cur_frame_length * 4, sizeof(*ctx->larray)); |
| 2105 | ctx->nbits = av_malloc_array(ctx->cur_frame_length, sizeof(*ctx->nbits)); | 2113 | ctx->nbits = av_malloc_array(ctx->cur_frame_length, sizeof(*ctx->nbits)); |
| @@ -2116,7 +2124,7 @@ static av_cold int decode_init(AVCodecContext *avctx) · 10 unmodified lines | |||
| 2116 | return ret; | 2124 | return ret; |
| 2117 | ff_mlz_flush_dict(ctx->mlz); | 2125 | ff_mlz_flush_dict(ctx->mlz); |
| 2118 | 2126 | ||
| 2119 | for (c = 0; c < avctx->channels; ++c) { | 2127 | for (c = 0; c < channels; ++c) { |
| 2120 | ctx->raw_mantissa[c] = av_calloc(ctx->cur_frame_length, sizeof(**ctx->raw_mantissa)); | 2128 | ctx->raw_mantissa[c] = av_calloc(ctx->cur_frame_length, sizeof(**ctx->raw_mantissa)); |
| 2121 | } | 2129 | } |
| 2122 | } | 2130 | } |
| @@ -2125,8 +2133,8 @@ static av_cold int decode_init(AVCodecContext *avctx) · 2 unmodified lines | |||
| 2125 | 2133 | ||
| 2126 | // allocate previous raw sample buffer | 2134 | // allocate previous raw sample buffer |
| 2127 | ctx->prev_raw_samples = av_malloc_array(sconf->max_order, sizeof(*ctx->prev_raw_samples)); | 2135 | ctx->prev_raw_samples = av_malloc_array(sconf->max_order, sizeof(*ctx->prev_raw_samples)); |
| 2128 | ctx->raw_buffer = av_calloc(avctx->channels * channel_size, sizeof(*ctx->raw_buffer)); | 2136 | ctx->raw_buffer = av_calloc(channels * channel_size, sizeof(*ctx->raw_buffer)); |
| 2129 | ctx->raw_samples = av_malloc_array(avctx->channels, sizeof(*ctx->raw_samples)); | 2137 | ctx->raw_samples = av_malloc_array(channels, sizeof(*ctx->raw_samples)); |
| 2130 | if (!ctx->prev_raw_samples || !ctx->raw_buffer|| !ctx->raw_samples) { | 2138 | if (!ctx->prev_raw_samples || !ctx->raw_buffer|| !ctx->raw_samples) { |
| 2131 | av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n"); | 2139 | av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n"); |
| 2132 | return AVERROR(ENOMEM); | 2140 | return AVERROR(ENOMEM); |
| @@ -2134,14 +2142,14 @@ static av_cold int decode_init(AVCodecContext *avctx) · 1 unmodified line | |||
| 2134 | 2142 | ||
| 2135 | // assign raw samples buffers | 2143 | // assign raw samples buffers |
| 2136 | ctx->raw_samples[0] = ctx->raw_buffer + sconf->max_order; | 2144 | ctx->raw_samples[0] = ctx->raw_buffer + sconf->max_order; |
| 2137 | for (c = 1; c < avctx->channels; c++) | 2145 | for (c = 1; c < channels; c++) |
| 2138 | ctx->raw_samples[c] = ctx->raw_samples[c - 1] + channel_size; | 2146 | ctx->raw_samples[c] = ctx->raw_samples[c - 1] + channel_size; |
| 2139 | 2147 | ||
| 2140 | // allocate crc buffer | 2148 | // allocate crc buffer |
| 2141 | if (HAVE_BIGENDIAN != sconf->msb_first && sconf->crc_enabled && | 2149 | if (HAVE_BIGENDIAN != sconf->msb_first && sconf->crc_enabled && |
| 2142 | (avctx->err_recognition & (AV_EF_CRCCHECK|AV_EF_CAREFUL))) { | 2150 | (avctx->err_recognition & (AV_EF_CRCCHECK|AV_EF_CAREFUL))) { |
| 2143 | ctx->crc_buffer = av_malloc_array(ctx->cur_frame_length * | 2151 | ctx->crc_buffer = av_malloc_array(ctx->cur_frame_length * |
| 2144 | avctx->channels * | 2152 | channels * |
| 2145 | av_get_bytes_per_sample(avctx->sample_fmt), | 2153 | av_get_bytes_per_sample(avctx->sample_fmt), |
| 2146 | sizeof(*ctx->crc_buffer)); | 2154 | sizeof(*ctx->crc_buffer)); |
| 2147 | if (!ctx->crc_buffer) { | 2155 | if (!ctx->crc_buffer) { |