diff options
author | Sascha Sommer <saschasommer@freenet.de> | 2009-06-12 15:21:43 +0000 |
---|---|---|
committer | Sascha Sommer <saschasommer@freenet.de> | 2009-06-12 15:21:43 +0000 |
commit | cee4bb894d0e9e4a8f9fca1ebdc5aa8330eaa366 (patch) | |
tree | 8f6a5fff4d82542334c020c0b2df58e40f4ef0b0 | |
parent | 8e6e9bacc4fd983741e4589bf5dd366c01ac4e15 (diff) | |
download | ffmpeg-cee4bb894d0e9e4a8f9fca1ebdc5aa8330eaa366.tar.gz |
Move frame len bits calculation to ff_wma_get_frame_len_bits
so that it can be reused for wmapro
Originally committed as revision 19167 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/wma.c | 34 | ||||
-rw-r--r-- | libavcodec/wma.h | 2 |
2 files changed, 28 insertions, 8 deletions
diff --git a/libavcodec/wma.c b/libavcodec/wma.c index 053be0a3ff..00893ab8ee 100644 --- a/libavcodec/wma.c +++ b/libavcodec/wma.c @@ -62,6 +62,30 @@ static void init_coef_vlc(VLC *vlc, uint16_t **prun_table, *pint_table = int_table; } +/** + *@brief Get the samples per frame for this stream. + *@param sample_rate output sample_rate + *@param version wma version + *@param decode_flags codec compression features + *@return log2 of the number of output samples per frame + */ +int av_cold ff_wma_get_frame_len_bits(int sample_rate, int version, + unsigned int decode_flags) +{ + + int frame_len_bits; + + if (sample_rate <= 16000) + frame_len_bits = 9; + else if (sample_rate <= 22050 || + (sample_rate <= 32000 && version == 1)) + frame_len_bits = 10; + else + frame_len_bits = 11; + + return frame_len_bits; +} + int ff_wma_init(AVCodecContext *avctx, int flags2) { WMACodecContext *s = avctx->priv_data; @@ -90,14 +114,8 @@ int ff_wma_init(AVCodecContext *avctx, int flags2) } /* compute MDCT block size */ - if (s->sample_rate <= 16000) { - s->frame_len_bits = 9; - } else if ( s->sample_rate <= 22050 || - (s->sample_rate <= 32000 && s->version == 1)) { - s->frame_len_bits = 10; - } else { - s->frame_len_bits = 11; - } + s->frame_len_bits = ff_wma_get_frame_len_bits(s->sample_rate, s->version, 0); + s->frame_len = 1 << s->frame_len_bits; if (s->use_variable_block_len) { int nb_max, nb; diff --git a/libavcodec/wma.h b/libavcodec/wma.h index 213eff6db4..50dcdf0a41 100644 --- a/libavcodec/wma.h +++ b/libavcodec/wma.h @@ -143,6 +143,8 @@ extern const float ff_wma_lsp_codebook[NB_LSP_COEFS][16]; extern const uint32_t ff_wma_scale_huffcodes[121]; extern const uint8_t ff_wma_scale_huffbits[121]; +int av_cold ff_wma_get_frame_len_bits(int sample_rate, int version, + unsigned int decode_flags); int ff_wma_init(AVCodecContext * avctx, int flags2); int ff_wma_total_gain_to_bits(int total_gain); int ff_wma_end(AVCodecContext *avctx); |