FFmpeg
Classes | Macros | Typedefs | Variables
wmaprodec.c File Reference

wmapro decoder implementation Wmapro is an MDCT based codec comparable to wma standard or AAC. More...

#include <inttypes.h>
#include "libavutil/ffmath.h"
#include "libavutil/float_dsp.h"
#include "libavutil/intfloat.h"
#include "libavutil/intreadwrite.h"
#include "avcodec.h"
#include "internal.h"
#include "get_bits.h"
#include "put_bits.h"
#include "wmaprodata.h"
#include "sinewin.h"
#include "wma.h"
#include "wma_common.h"

Classes

struct  WMAProChannelCtx
 frame specific decoder context for a single channel More...
 
struct  WMAProChannelGrp
 channel group for channel transformations More...
 
struct  WMAProDecodeCtx
 main decoder context More...
 
struct  XMADecodeCtx
 

Macros

#define WMAPRO_MAX_CHANNELS   8
 current decoder limitations More...
 
#define MAX_SUBFRAMES   32
 max number of subframes per channel
 
#define MAX_BANDS   29
 max number of scale factor bands
 
#define MAX_FRAMESIZE   32768
 maximum compressed frame size
 
#define XMA_MAX_STREAMS   8
 
#define XMA_MAX_CHANNELS_STREAM   2
 
#define XMA_MAX_CHANNELS   (XMA_MAX_STREAMS * XMA_MAX_CHANNELS_STREAM)
 
#define WMAPRO_BLOCK_MIN_BITS   6
 log2 of min block size
 
#define WMAPRO_BLOCK_MAX_BITS   13
 log2 of max block size
 
#define WMAPRO_BLOCK_MIN_SIZE   (1 << WMAPRO_BLOCK_MIN_BITS)
 minimum 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 VLCBITS   9
 
#define SCALEVLCBITS   8
 
#define VEC4MAXDEPTH   ((HUFF_VEC4_MAXBITS+VLCBITS-1)/VLCBITS)
 
#define VEC2MAXDEPTH   ((HUFF_VEC2_MAXBITS+VLCBITS-1)/VLCBITS)
 
#define VEC1MAXDEPTH   ((HUFF_VEC1_MAXBITS+VLCBITS-1)/VLCBITS)
 
#define SCALEMAXDEPTH   ((HUFF_SCALE_MAXBITS+SCALEVLCBITS-1)/SCALEVLCBITS)
 
#define SCALERLMAXDEPTH   ((HUFF_SCALE_RL_MAXBITS+VLCBITS-1)/VLCBITS)
 
#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 = %"PRIx32"\n", a, b);
 

Typedefs

typedef struct WMAProChannelCtx WMAProChannelCtx
 frame specific decoder context for a single channel
 
typedef struct WMAProChannelGrp WMAProChannelGrp
 channel group for channel transformations
 
typedef struct WMAProDecodeCtx WMAProDecodeCtx
 main decoder context
 
typedef struct XMADecodeCtx XMADecodeCtx
 

Variables

AVCodec ff_wmapro_decoder
 wmapro decoder More...
 
AVCodec ff_xma1_decoder
 
AVCodec ff_xma2_decoder
 

Detailed Description

wmapro decoder implementation Wmapro is an MDCT based codec comparable to wma standard or AAC.

The decoding therefore consists of the following steps:

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.

Macro Definition Documentation

§ WMAPRO_MAX_CHANNELS

#define WMAPRO_MAX_CHANNELS   8

current decoder limitations

max number of handled channels

Variable Documentation

§ ff_wmapro_decoder

AVCodec ff_wmapro_decoder
Initial value:
= {
.name = "wmapro",
.long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 9 Professional"),
.type = AVMEDIA_TYPE_AUDIO,
.id = AV_CODEC_ID_WMAPRO,
.priv_data_size = sizeof(WMAProDecodeCtx),
.init = wmapro_decode_init,
.close = wmapro_decode_end,
.decode = wmapro_decode_packet,
.flush = wmapro_flush,
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
AV_SAMPLE_FMT_NONE },
}
float, planar
Definition: samplefmt.h:69
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
struct WMAProDecodeCtx WMAProDecodeCtx
main decoder context
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
#define AV_CODEC_CAP_SUBFRAMES
Codec can output multiple frames per AVPacket Normally demuxers return one frame at a time...
Definition: avcodec.h:1002
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:959

wmapro decoder

§ ff_xma1_decoder

AVCodec ff_xma1_decoder
Initial value:
= {
.name = "xma1",
.long_name = NULL_IF_CONFIG_SMALL("Xbox Media Audio 1"),
.type = AVMEDIA_TYPE_AUDIO,
.id = AV_CODEC_ID_XMA1,
.priv_data_size = sizeof(XMADecodeCtx),
.init = xma_decode_init,
.close = xma_decode_end,
.decode = xma_decode_packet,
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
AV_SAMPLE_FMT_NONE },
}
float, planar
Definition: samplefmt.h:69
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
Definition: wmaprodec.c:240
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
#define AV_CODEC_CAP_SUBFRAMES
Codec can output multiple frames per AVPacket Normally demuxers return one frame at a time...
Definition: avcodec.h:1002
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:959

§ ff_xma2_decoder

AVCodec ff_xma2_decoder
Initial value:
= {
.name = "xma2",
.long_name = NULL_IF_CONFIG_SMALL("Xbox Media Audio 2"),
.type = AVMEDIA_TYPE_AUDIO,
.id = AV_CODEC_ID_XMA2,
.priv_data_size = sizeof(XMADecodeCtx),
.init = xma_decode_init,
.close = xma_decode_end,
.decode = xma_decode_packet,
.flush = xma_flush,
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
AV_SAMPLE_FMT_NONE },
}
float, planar
Definition: samplefmt.h:69
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
Definition: wmaprodec.c:240
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
#define AV_CODEC_CAP_SUBFRAMES
Codec can output multiple frames per AVPacket Normally demuxers return one frame at a time...
Definition: avcodec.h:1002
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:959