X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fwmaprodec.c;h=30a43c85859b3b8432f4604f9c40ccfafe8bae0e;hb=40f81769aec24a93563cd547e02ba8478aa95849;hp=2f2cbd6de5108d112cb504b4bcbc40b15b233e57;hpb=9cf0841ef35239660fc313314778414e2828f025;p=ffmpeg diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c index 2f2cbd6de51..30a43c85859 100644 --- a/libavcodec/wmaprodec.c +++ b/libavcodec/wmaprodec.c @@ -97,6 +97,7 @@ #include "fmtconvert.h" #include "sinewin.h" #include "wma.h" +#include "wma_common.h" /** current decoder limitations */ #define WMAPRO_MAX_CHANNELS 8 ///< max number of handled channels @@ -105,7 +106,7 @@ #define MAX_FRAMESIZE 32768 ///< maximum compressed frame size #define WMAPRO_BLOCK_MIN_BITS 6 ///< log2 of min block size -#define WMAPRO_BLOCK_MAX_BITS 12 ///< log2 of max block size +#define WMAPRO_BLOCK_MAX_BITS 13 ///< log2 of max block size #define WMAPRO_BLOCK_MAX_SIZE (1 << WMAPRO_BLOCK_MAX_BITS) ///< maximum block size #define WMAPRO_BLOCK_SIZES (WMAPRO_BLOCK_MAX_BITS - WMAPRO_BLOCK_MIN_BITS + 1) ///< possible block sizes @@ -236,7 +237,7 @@ typedef struct WMAProDecodeCtx { *@brief helper function to print the most important members of the context *@param s context */ -static void av_cold dump_context(WMAProDecodeCtx *s) +static av_cold void dump_context(WMAProDecodeCtx *s) { #define PRINT(a, b) av_log(s->avctx, AV_LOG_DEBUG, " %s = %d\n", a, b); #define PRINT_HEX(a, b) av_log(s->avctx, AV_LOG_DEBUG, " %s = %x\n", a, b); @@ -276,7 +277,7 @@ static av_cold int decode_init(AVCodecContext *avctx) WMAProDecodeCtx *s = avctx->priv_data; uint8_t *edata_ptr = avctx->extradata; unsigned int channel_mask; - int i; + int i, bits; int log2_max_num_subframes; int num_possible_block_sizes; @@ -310,8 +311,12 @@ static av_cold int decode_init(AVCodecContext *avctx) s->len_prefix = (s->decode_flags & 0x40); /** get frame len */ - s->samples_per_frame = 1 << ff_wma_get_frame_len_bits(avctx->sample_rate, - 3, s->decode_flags); + bits = ff_wma_get_frame_len_bits(avctx->sample_rate, 3, s->decode_flags); + if (bits > WMAPRO_BLOCK_MAX_BITS) { + av_log_missing_feature(avctx, "14-bits block sizes", 1); + return AVERROR_INVALIDDATA; + } + s->samples_per_frame = 1 << bits; /** subframe info */ log2_max_num_subframes = ((s->decode_flags & 0x38) >> 3); @@ -516,7 +521,7 @@ static int decode_subframe_length(WMAProDecodeCtx *s, int offset) */ static int decode_tilehdr(WMAProDecodeCtx *s) { - uint16_t num_samples[WMAPRO_MAX_CHANNELS]; /**< sum of samples for all currently known subframes of a channel */ + uint16_t num_samples[WMAPRO_MAX_CHANNELS] = { 0 };/**< sum of samples for all currently known subframes of a channel */ uint8_t contains_subframe[WMAPRO_MAX_CHANNELS]; /**< flag indicating if a channel contains the current subframe */ int channels_for_cur_subframe = s->num_channels; /**< number of channels that contain the current subframe */ int fixed_channel_layout = 0; /**< flag indicating that all channels use the same subframe offsets and sizes */ @@ -533,8 +538,6 @@ static int decode_tilehdr(WMAProDecodeCtx *s) for (c = 0; c < s->num_channels; c++) s->channel[c].num_subframes = 0; - memset(num_samples, 0, sizeof(num_samples)); - if (s->max_num_subframes == 1 || get_bits1(&s->gb)) fixed_channel_layout = 1; @@ -1477,7 +1480,6 @@ static void save_bits(WMAProDecodeCtx *s, GetBitContext* gb, int len, *@brief Decode a single WMA packet. *@param avctx codec context *@param data the output buffer - *@param data_size number of bytes that were written to the output buffer *@param avpkt input packet *@return number of bytes that were read from the input buffer */ @@ -1622,6 +1624,6 @@ AVCodec ff_wmapro_decoder = { .close = decode_end, .decode = decode_packet, .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1, - .flush= flush, - .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 9 Professional"), + .flush = flush, + .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 9 Professional"), };