libavcodec/atrac3.c File Reference

Atrac 3 compatible decoder. More...

#include <math.h>
#include <stddef.h>
#include <stdio.h>
#include "avcodec.h"
#include "bitstream.h"
#include "dsputil.h"
#include "bytestream.h"
#include "atrac3data.h"

Go to the source code of this file.

Data Structures

struct  gain_info
struct  gain_block
struct  tonal_component
struct  channel_unit
struct  ATRAC3Context

Defines

#define JOINT_STEREO   0x12
#define STEREO   0x2
#define INTERPOLATE(old, new, nsample)   ((old) + (nsample)*0.125*((new)-(old)))

Functions

static DECLARE_ALIGNED_16 (float, mdct_window[512])
static void iqmf (float *inlo, float *inhi, unsigned int nIn, float *pOut, float *delayBuf, float *temp)
 Quadrature mirror synthesis filter.
static void IMLT (float *pInput, float *pOutput, int odd_band)
 Regular 512 points IMDCT without overlapping, with the exception of the swapping of odd bands caused by the reverse spectra of the QMF.
static int decode_bytes (const uint8_t *inbuffer, uint8_t *out, int bytes)
 Atrac 3 indata descrambling, only used for data coming from the rm container.
static av_cold void init_atrac3_transforms (ATRAC3Context *q)
static av_cold int atrac3_decode_close (AVCodecContext *avctx)
 Atrac3 uninit, free all allocated memory.
static void readQuantSpectralCoeffs (GetBitContext *gb, int selector, int codingFlag, int *mantissas, int numCodes)
 / * Mantissa decoding
static int decodeSpectrum (GetBitContext *gb, float *pOut)
 Restore the quantized band spectrum coefficients.
static int decodeTonalComponents (GetBitContext *gb, tonal_component *pComponent, int numBands)
 Restore the quantized tonal components.
static int decodeGainControl (GetBitContext *gb, gain_block *pGb, int numBands)
 Decode gain parameters for the coded bands.
static void gainCompensateAndOverlap (float *pIn, float *pPrev, float *pOut, gain_info *pGain1, gain_info *pGain2)
 Apply gain parameters and perform the MDCT overlapping part.
static int addTonalComponents (float *pSpectrum, int numComponents, tonal_component *pComponent)
 Combine the tonal band spectrum and regular band spectrum Return position of the last tonal coefficient.
static void reverseMatrixing (float *su1, float *su2, int *pPrevCode, int *pCurrCode)
static void getChannelWeights (int indx, int flag, float ch[2])
static void channelWeighting (float *su1, float *su2, int *p3)
static int decodeChannelSoundUnit (ATRAC3Context *q, GetBitContext *gb, channel_unit *pSnd, float *pOut, int channelNum, int codingMode)
 Decode a Sound Unit.
static int decodeFrame (ATRAC3Context *q, const uint8_t *databuf)
 Frame handling.
static int atrac3_decode_frame (AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size)
 Atrac frame decoding.
static av_cold int atrac3_decode_init (AVCodecContext *avctx)
 Atrac3 initialization.

Variables

static float qmf_window [48]
static VLC spectral_coeff_tab [7]
static float SFTable [64]
static float gain_tab1 [16]
static float gain_tab2 [31]
static MDCTContext mdct_ctx
static DSPContext dsp
AVCodec atrac3_decoder


Detailed Description

Atrac 3 compatible decoder.

This decoder handles Sony's ATRAC3 data.

Container formats used to store atrac 3 data: RealMedia (.rm), RIFF WAV (.wav, .at3), Sony OpenMG (.oma, .aa3).

To use this decoder, a calling application must supply the extradata bytes provided in the containers above.

Definition in file atrac3.c.


Define Documentation

#define INTERPOLATE ( old,
new,
nsample   )     ((old) + (nsample)*0.125*((new)-(old)))

Definition at line 605 of file atrac3.c.

Referenced by channelWeighting(), and reverseMatrixing().

#define JOINT_STEREO   0x12

#define STEREO   0x2

Definition at line 47 of file atrac3.c.

Referenced by atrac3_decode_init(), and cook_decode_init().


Function Documentation

static int addTonalComponents ( float *  pSpectrum,
int  numComponents,
tonal_component pComponent 
) [static]

Combine the tonal band spectrum and regular band spectrum Return position of the last tonal coefficient.

Parameters:
pSpectrum output spectrum buffer
numComponents amount of tonal components
pComponent tonal components for this band

Definition at line 587 of file atrac3.c.

Referenced by decodeChannelSoundUnit().

static av_cold int atrac3_decode_close ( AVCodecContext avctx  )  [static]

Atrac3 uninit, free all allocated memory.

Definition at line 278 of file atrac3.c.

static int atrac3_decode_frame ( AVCodecContext avctx,
void *  data,
int *  data_size,
const uint8_t *  buf,
int  buf_size 
) [static]

Atrac frame decoding.

Parameters:
avctx pointer to the AVCodecContext

Definition at line 881 of file atrac3.c.

static av_cold int atrac3_decode_init ( AVCodecContext avctx  )  [static]

Atrac3 initialization.

Parameters:
avctx pointer to the AVCodecContext

Definition at line 931 of file atrac3.c.

static void channelWeighting ( float *  su1,
float *  su2,
int *  p3 
) [static]

Definition at line 682 of file atrac3.c.

Referenced by decodeFrame().

static DECLARE_ALIGNED_16 ( float  ,
mdct_window  [512] 
) [static]

static int decode_bytes ( const uint8_t *  inbuffer,
uint8_t *  out,
int  bytes 
) [static]

Atrac 3 indata descrambling, only used for data coming from the rm container.

Parameters:
in pointer to 8 bit array of indata
bits amount of bits
out pointer to 8 bit array of outdata

Definition at line 227 of file atrac3.c.

Referenced by atrac3_decode_frame(), and decode_bytes_and_gain().

static int decodeChannelSoundUnit ( ATRAC3Context q,
GetBitContext gb,
channel_unit pSnd,
float *  pOut,
int  channelNum,
int  codingMode 
) [static]

Decode a Sound Unit.

Parameters:
gb the GetBit context
pSnd the channel unit to be used
pOut the decoded samples before IQMF in float representation
channelNum channel number
codingMode the coding mode (JOINT_STEREO or regular stereo/mono)

Definition at line 719 of file atrac3.c.

Referenced by decodeFrame().

static int decodeFrame ( ATRAC3Context q,
const uint8_t *  databuf 
) [static]

Frame handling.

Parameters:
q Atrac3 private context
databuf the input data

Definition at line 783 of file atrac3.c.

Referenced by atrac3_decode_frame().

static int decodeGainControl ( GetBitContext gb,
gain_block pGb,
int  numBands 
) [static]

Decode gain parameters for the coded bands.

Parameters:
gb the GetBit context
pGb the gainblock for the current band
numBands amount of coded bands

Definition at line 491 of file atrac3.c.

Referenced by decodeChannelSoundUnit().

static int decodeSpectrum ( GetBitContext gb,
float *  pOut 
) [static]

Restore the quantized band spectrum coefficients.

Parameters:
gb the GetBit context
pOut decoded band spectrum
Returns:
outSubbands subband counter, fix for broken specification/files

Definition at line 356 of file atrac3.c.

Referenced by decodeChannelSoundUnit().

static int decodeTonalComponents ( GetBitContext gb,
tonal_component pComponent,
int  numBands 
) [static]

Restore the quantized tonal components.

Parameters:
gb the GetBit context
pComponent tone component
numBands amount of coded bands

Definition at line 414 of file atrac3.c.

Referenced by decodeChannelSoundUnit().

static void gainCompensateAndOverlap ( float *  pIn,
float *  pPrev,
float *  pOut,
gain_info pGain1,
gain_info pGain2 
) [static]

Apply gain parameters and perform the MDCT overlapping part.

Parameters:
pIn input float buffer
pPrev previous float buffer to perform overlap against
pOut output float buffer
pGain1 current band gain info
pGain2 next band gain info

Definition at line 530 of file atrac3.c.

Referenced by decodeChannelSoundUnit().

static void getChannelWeights ( int  indx,
int  flag,
float  ch[2] 
) [static]

Definition at line 669 of file atrac3.c.

Referenced by channelWeighting().

static void IMLT ( float *  pInput,
float *  pOutput,
int  odd_band 
) [static]

Regular 512 points IMDCT without overlapping, with the exception of the swapping of odd bands caused by the reverse spectra of the QMF.

Parameters:
pInput float input
pOutput float output
odd_band 1 if the band is an odd band

Reverse the odd bands before IMDCT, this is an effect of the QMF transform or it gives better compression to do it this way. FIXME: It should be possible to handle this in ff_imdct_calc for that to happen a modification of the prerotation step of all SIMD code and C code is needed. Or fix the functions before so they generate a pre reversed spectrum.

Definition at line 193 of file atrac3.c.

Referenced by decodeChannelSoundUnit().

static av_cold void init_atrac3_transforms ( ATRAC3Context q  )  [static]

Definition at line 247 of file atrac3.c.

Referenced by atrac3_decode_init().

static void iqmf ( float *  inlo,
float *  inhi,
unsigned int  nIn,
float *  pOut,
float *  delayBuf,
float *  temp 
) [static]

Quadrature mirror synthesis filter.

Parameters:
inlo lower part of spectrum
inhi higher part of spectrum
nIn size of spectrum buffer
pOut out buffer
delayBuf delayBuf buffer
temp temp buffer

Definition at line 145 of file atrac3.c.

Referenced by decodeFrame().

static void readQuantSpectralCoeffs ( GetBitContext gb,
int  selector,
int  codingFlag,
int *  mantissas,
int  numCodes 
) [static]

/ * Mantissa decoding

Parameters:
gb the GetBit context
selector what table is the output values coded with
codingFlag constant length coding or variable length coding
mantissas mantissa output table
numCodes amount of values to get

Definition at line 298 of file atrac3.c.

Referenced by decodeSpectrum(), and decodeTonalComponents().

static void reverseMatrixing ( float *  su1,
float *  su2,
int *  pPrevCode,
int *  pCurrCode 
) [static]

Definition at line 607 of file atrac3.c.

Referenced by decodeFrame().


Variable Documentation

Initial value:

{
    .name = "atrac3",
    .type = CODEC_TYPE_AUDIO,
    .id = CODEC_ID_ATRAC3,
    .priv_data_size = sizeof(ATRAC3Context),
    .init = atrac3_decode_init,
    .close = atrac3_decode_close,
    .decode = atrac3_decode_frame,
    .long_name = NULL_IF_CONFIG_SMALL("Atrac 3 (Adaptive TRansform Acoustic Coding 3)"),
}

Definition at line 1072 of file atrac3.c.

DSPContext dsp [static]

float gain_tab1[16] [static]

Definition at line 125 of file atrac3.c.

Referenced by atrac3_decode_init(), and gainCompensateAndOverlap().

float gain_tab2[31] [static]

Definition at line 126 of file atrac3.c.

Referenced by atrac3_decode_init(), and gainCompensateAndOverlap().

Definition at line 127 of file atrac3.c.

float qmf_window[48] [static]

Definition at line 122 of file atrac3.c.

Referenced by init_atrac3_transforms(), and iqmf().

float SFTable[64] [static]

Definition at line 124 of file atrac3.c.

Referenced by atrac3_decode_init(), decodeSpectrum(), and decodeTonalComponents().

VLC spectral_coeff_tab[7] [static]

Definition at line 123 of file atrac3.c.


Generated on Fri Oct 26 02:35:42 2012 for FFmpeg by  doxygen 1.5.8