Mercurial > libavcodec.hg
changeset 10073:57d76996ccb8 libavcodec
Add some more wmapro decoder hunks
author | faust3 |
---|---|
date | Fri, 21 Aug 2009 16:54:42 +0000 |
parents | 0a3bf7990e39 |
children | c4a83f3a5c9f |
files | wmaprodec.c |
diffstat | 1 files changed, 88 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/wmaprodec.c Fri Aug 21 10:10:42 2009 +0000 +++ b/wmaprodec.c Fri Aug 21 16:54:42 2009 +0000 @@ -1,3 +1,91 @@ +/* + * Wmapro compatible decoder + * Copyright (c) 2007 Baptiste Coudurier, Benjamin Larsson, Ulion + * Copyright (c) 2008 - 2009 Sascha Sommer, Benjamin Larsson + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file libavcodec/wmaprodec.c + * @brief wmapro decoder implementation + * Wmapro is an MDCT based codec comparable to wma standard or AAC. + * The decoding therefore consists of the following steps: + * - bitstream decoding + * - reconstruction of per-channel data + * - rescaling and inverse quantization + * - IMDCT + * - windowing and overlapp-add + * + * The compressed wmapro bitstream is split into individual packets. + * Every such packet contains one or more wma frames. + * The compressed frames may have a variable length and frames may + * cross packet boundaries. + * Common to all wmapro frames is the number of samples that are stored in + * a frame. + * The number of samples and a few other decode flags are stored + * as extradata that has to be passed to the decoder. + * + * The wmapro frames themselves are again split into a variable number of + * subframes. Every subframe contains the data for 2^N time domain samples + * where N varies between 7 and 12. + * + * Example wmapro bitstream (in samples): + * + * || packet 0 || packet 1 || packet 2 packets + * --------------------------------------------------- + * || frame 0 || frame 1 || frame 2 || frames + * --------------------------------------------------- + * || | | || | | | || || subframes of channel 0 + * --------------------------------------------------- + * || | | || | | | || || subframes of channel 1 + * --------------------------------------------------- + * + * The frame layouts for the individual channels of a wma frame does not need + * to be the same. + * + * However, if the offsets and lengths of several subframes of a frame are the + * same, the subframes of the channels can be grouped. + * Every group may then use special coding techniques like M/S stereo coding + * to improve the compression ratio. These channel transformations do not + * need to be applied to a whole subframe. Instead, they can also work on + * individual scale factor bands (see below). + * The coefficients that carry the audio signal in the frequency domain + * are transmitted as huffman-coded vectors with 4, 2 and 1 elements. + * In addition to that, the encoder can switch to a runlevel coding scheme + * by transmitting subframe_length / 128 zero coefficients. + * + * Before the audio signal can be converted to the time domain, the + * coefficients have to be rescaled and inverse quantized. + * A subframe is therefore split into several scale factor bands that get + * scaled individually. + * Scale factors are submitted for every frame but they might be shared + * between the subframes of a channel. Scale factors are initially DPCM-coded. + * Once scale factors are shared, the differences are transmitted as runlevel + * codes. + * Every subframe length and offset combination in the frame layout shares a + * common quantization factor that can be adjusted for every channel by a + * modifier. + * After the inverse quantization, the coefficients get processed by an IMDCT. + * The resulting values are then windowed with a sine window and the first half + * of the values are added to the second half of the output from the previous + * subframe in order to reconstruct the output samples. + */ + /** *@brief Uninitialize the decoder and free all resources. *@param avctx codec context @@ -8,11 +96,6 @@ WMA3DecodeContext *s = avctx->priv_data; int i; - av_freep(&s->num_sfb); - av_freep(&s->sfb_offsets); - av_freep(&s->subwoofer_cutoffs); - av_freep(&s->sf_offsets); - for (i = 0 ; i < WMAPRO_BLOCK_SIZES ; i++) ff_mdct_end(&s->mdct_ctx[i]);