Commit b4027d97 authored by Ronald S. Bultje's avatar Ronald S. Bultje

wmapro: change max. block size to 13 bits.

WMApro actually support 13-bits block sizes (potentially even up to 14),
and thus we should support that also. If we get block sizes beyond what
the decoder can handle (14 is possible depending on s->decode_flags),
error out instead of crashing.
parent 204cb29b
...@@ -53,7 +53,8 @@ extern SINETABLE( 512); ...@@ -53,7 +53,8 @@ extern SINETABLE( 512);
extern SINETABLE(1024); extern SINETABLE(1024);
extern SINETABLE(2048); extern SINETABLE(2048);
extern SINETABLE(4096); extern SINETABLE(4096);
extern SINETABLE(8192);
extern SINETABLE_CONST float * const ff_sine_windows[13]; extern SINETABLE_CONST float * const ff_sine_windows[14];
#endif /* AVCODEC_SINEWIN_H */ #endif /* AVCODEC_SINEWIN_H */
...@@ -38,7 +38,7 @@ int main(void) ...@@ -38,7 +38,7 @@ int main(void)
write_fileheader(); write_fileheader();
for (i = 5; i <= 12; i++) { for (i = 5; i <= 13; i++) {
ff_init_ff_sine_windows(i); ff_init_ff_sine_windows(i);
printf("SINETABLE(%4i) = {\n", 1 << i); printf("SINETABLE(%4i) = {\n", 1 << i);
write_float_array(ff_sine_windows[i], 1 << i); write_float_array(ff_sine_windows[i], 1 << i);
......
...@@ -38,6 +38,7 @@ SINETABLE( 512); ...@@ -38,6 +38,7 @@ SINETABLE( 512);
SINETABLE(1024); SINETABLE(1024);
SINETABLE(2048); SINETABLE(2048);
SINETABLE(4096); SINETABLE(4096);
SINETABLE(8192);
#else #else
#include "libavcodec/sinewin_tables.h" #include "libavcodec/sinewin_tables.h"
#endif #endif
...@@ -45,7 +46,7 @@ SINETABLE(4096); ...@@ -45,7 +46,7 @@ SINETABLE(4096);
SINETABLE_CONST float * const ff_sine_windows[] = { SINETABLE_CONST float * const ff_sine_windows[] = {
NULL, NULL, NULL, NULL, NULL, // unused NULL, NULL, NULL, NULL, NULL, // unused
ff_sine_32 , ff_sine_64 , ff_sine_32 , ff_sine_64 ,
ff_sine_128, ff_sine_256, ff_sine_512, ff_sine_1024, ff_sine_2048, ff_sine_4096 ff_sine_128, ff_sine_256, ff_sine_512, ff_sine_1024, ff_sine_2048, ff_sine_4096, ff_sine_8192
}; };
// Generate a sine window. // Generate a sine window.
......
...@@ -105,7 +105,7 @@ ...@@ -105,7 +105,7 @@
#define MAX_FRAMESIZE 32768 ///< maximum compressed frame size #define MAX_FRAMESIZE 32768 ///< maximum compressed frame size
#define WMAPRO_BLOCK_MIN_BITS 6 ///< log2 of min block 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_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 #define WMAPRO_BLOCK_SIZES (WMAPRO_BLOCK_MAX_BITS - WMAPRO_BLOCK_MIN_BITS + 1) ///< possible block sizes
...@@ -276,7 +276,7 @@ static av_cold int decode_init(AVCodecContext *avctx) ...@@ -276,7 +276,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
WMAProDecodeCtx *s = avctx->priv_data; WMAProDecodeCtx *s = avctx->priv_data;
uint8_t *edata_ptr = avctx->extradata; uint8_t *edata_ptr = avctx->extradata;
unsigned int channel_mask; unsigned int channel_mask;
int i; int i, bits;
int log2_max_num_subframes; int log2_max_num_subframes;
int num_possible_block_sizes; int num_possible_block_sizes;
...@@ -310,8 +310,12 @@ static av_cold int decode_init(AVCodecContext *avctx) ...@@ -310,8 +310,12 @@ static av_cold int decode_init(AVCodecContext *avctx)
s->len_prefix = (s->decode_flags & 0x40); s->len_prefix = (s->decode_flags & 0x40);
/** get frame len */ /** get frame len */
s->samples_per_frame = 1 << ff_wma_get_frame_len_bits(avctx->sample_rate, bits = ff_wma_get_frame_len_bits(avctx->sample_rate, 3, s->decode_flags);
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 */ /** subframe info */
log2_max_num_subframes = ((s->decode_flags & 0x38) >> 3); log2_max_num_subframes = ((s->decode_flags & 0x38) >> 3);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment