atrac3.c File Reference

Atrac 3 compatible decoder. More...

#include <math.h>
#include <stddef.h>
#include <stdio.h>
#include "libavutil/float_dsp.h"
#include "avcodec.h"
#include "bytestream.h"
#include "fft.h"
#include "fmtconvert.h"
#include "get_bits.h"
#include "internal.h"
#include "atrac.h"
#include "atrac3data.h"

Go to the source code of this file.

Data Structures

struct  GainInfo
 
struct  GainBlock
 
struct  TonalComponent
 
struct  ChannelUnit
 
struct  ATRAC3Context
 

Macros

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

Typedefs

typedef struct GainInfo GainInfo
 
typedef struct GainBlock GainBlock
 
typedef struct TonalComponent TonalComponent
 
typedef struct ChannelUnit ChannelUnit
 
typedef struct ATRAC3Context ATRAC3Context
 

Functions

static void imlt (ATRAC3Context *q, float *input, float *output, int odd_band)
 
static int decode_bytes (const uint8_t *input, uint8_t *out, int bytes)
 
static av_cold void init_atrac3_window (void)
 
static av_cold int atrac3_decode_close (AVCodecContext *avctx)
 
static void read_quant_spectral_coeffs (GetBitContext *gb, int selector, int coding_flag, int *mantissas, int num_codes)
 
static int decode_spectrum (GetBitContext *gb, float *output)
 
static int decode_tonal_components (GetBitContext *gb, TonalComponent *components, int num_bands)
 
static int decode_gain_control (GetBitContext *gb, GainBlock *block, int num_bands)
 
static void gain_compensate_and_overlap (float *input, float *prev, float *output, GainInfo *gain1, GainInfo *gain2)
 
static int add_tonal_components (float *spectrum, int num_components, TonalComponent *components)
 
static void reverse_matrixing (float *su1, float *su2, int *prev_code, int *curr_code)
 
static void get_channel_weights (int index, int flag, float ch[2])
 
static void channel_weighting (float *su1, float *su2, int *p3)
 
static int decode_channel_sound_unit (ATRAC3Context *q, GetBitContext *gb, ChannelUnit *snd, float *output, int channel_num, int coding_mode)
 
static int decode_frame (AVCodecContext *avctx, const uint8_t *databuf, float **out_samples)
 
static int atrac3_decode_frame (AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
 
static void atrac3_init_static_data (AVCodec *codec)
 
static av_cold int atrac3_decode_init (AVCodecContext *avctx)
 

Variables

static float mdct_window [MDCT_SIZE]
 
static VLC_TYPE atrac3_vlc_table [4096][2]
 
static VLC spectral_coeff_tab [7]
 
static float gain_tab1 [16]
 
static float gain_tab2 [31]
 
AVCodec ff_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.

Macro Definition Documentation

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

Definition at line 529 of file atrac3.c.

Referenced by channel_weighting(), and reverse_matrixing().

#define JOINT_STEREO   0x12
#define MDCT_SIZE   512

Definition at line 54 of file atrac3.c.

Referenced by imlt().

#define SAMPLES_PER_FRAME   1024
#define STEREO   0x2

Definition at line 51 of file atrac3.c.

Referenced by atrac3_decode_init().

Typedef Documentation

typedef struct ATRAC3Context ATRAC3Context
typedef struct ChannelUnit ChannelUnit
typedef struct GainBlock GainBlock
typedef struct GainInfo GainInfo

Function Documentation

static int add_tonal_components ( float *  spectrum,
int  num_components,
TonalComponent components 
)
static

Definition at line 511 of file atrac3.c.

Referenced by decode_channel_sound_unit().

static av_cold int atrac3_decode_close ( AVCodecContext avctx)
static

Definition at line 196 of file atrac3.c.

Referenced by atrac3_decode_init().

static int atrac3_decode_frame ( AVCodecContext avctx,
void data,
int *  got_frame_ptr,
AVPacket avpkt 
)
static

Definition at line 801 of file atrac3.c.

static av_cold int atrac3_decode_init ( AVCodecContext avctx)
static

Definition at line 868 of file atrac3.c.

static void atrac3_init_static_data ( AVCodec codec)
static

Definition at line 843 of file atrac3.c.

static void channel_weighting ( float *  su1,
float *  su2,
int *  p3 
)
static

Definition at line 607 of file atrac3.c.

Referenced by decode_frame().

static int decode_bytes ( const uint8_t input,
uint8_t out,
int  bytes 
)
static

Definition at line 158 of file atrac3.c.

Referenced by atrac3_decode_frame().

static int decode_channel_sound_unit ( ATRAC3Context q,
GetBitContext gb,
ChannelUnit snd,
float *  output,
int  channel_num,
int  coding_mode 
)
static

Definition at line 638 of file atrac3.c.

Referenced by decode_frame().

static int decode_frame ( AVCodecContext avctx,
const uint8_t databuf,
float **  out_samples 
)
static

Definition at line 706 of file atrac3.c.

Referenced by atrac3_decode_frame().

static int decode_gain_control ( GetBitContext gb,
GainBlock block,
int  num_bands 
)
static

Definition at line 417 of file atrac3.c.

Referenced by decode_channel_sound_unit().

static int decode_spectrum ( GetBitContext gb,
float *  output 
)
static

Definition at line 275 of file atrac3.c.

Referenced by decode_channel_sound_unit().

static int decode_tonal_components ( GetBitContext gb,
TonalComponent components,
int  num_bands 
)
static

Definition at line 333 of file atrac3.c.

Referenced by decode_channel_sound_unit().

static void gain_compensate_and_overlap ( float *  input,
float *  prev,
float *  output,
GainInfo gain1,
GainInfo gain2 
)
static

Definition at line 455 of file atrac3.c.

Referenced by decode_channel_sound_unit().

static void get_channel_weights ( int  index,
int  flag,
float  ch[2] 
)
static

Definition at line 594 of file atrac3.c.

Referenced by channel_weighting().

static void imlt ( ATRAC3Context q,
float *  input,
float *  output,
int  odd_band 
)
static

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 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 132 of file atrac3.c.

Referenced by decode_channel_sound_unit().

static av_cold void init_atrac3_window ( void  )
static

Definition at line 181 of file atrac3.c.

Referenced by atrac3_init_static_data().

static void read_quant_spectral_coeffs ( GetBitContext gb,
int  selector,
int  coding_flag,
int *  mantissas,
int  num_codes 
)
static

Definition at line 216 of file atrac3.c.

Referenced by decode_spectrum(), and decode_tonal_components().

static void reverse_matrixing ( float *  su1,
float *  su2,
int *  prev_code,
int *  curr_code 
)
static

Definition at line 532 of file atrac3.c.

Referenced by decode_frame().

Variable Documentation

VLC_TYPE atrac3_vlc_table[4096][2]
static

Definition at line 120 of file atrac3.c.

Referenced by atrac3_init_static_data().

AVCodec ff_atrac3_decoder
Initial value:
= {
.name = "atrac3",
.priv_data_size = sizeof(ATRAC3Context),
.init_static_data = atrac3_init_static_data,
.long_name = NULL_IF_CONFIG_SMALL("Atrac 3 (Adaptive TRansform Acoustic Coding 3)"),
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
}
struct ATRAC3Context ATRAC3Context
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
Definition: mimic.c:228
static int atrac3_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
Definition: atrac3.c:801
static int init(AVCodecParserContext *s)
Definition: h264_parser.c:335
float, planar
Definition: samplefmt.h:60
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:88
AV_SAMPLE_FMT_NONE
Definition: avconv_filter.c:63
static void close(AVCodecParserContext *s)
Definition: h264_parser.c:326
static av_cold int atrac3_decode_close(AVCodecContext *avctx)
Definition: atrac3.c:196
static av_cold int atrac3_decode_init(AVCodecContext *avctx)
Definition: atrac3.c:868
AVSampleFormat
Audio Sample Formats.
Definition: samplefmt.h:49
static void atrac3_init_static_data(AVCodec *codec)
Definition: atrac3.c:843

Definition at line 1000 of file atrac3.c.

float gain_tab1[16]
static

Definition at line 122 of file atrac3.c.

Referenced by atrac3_init_static_data(), and gain_compensate_and_overlap().

float gain_tab2[31]
static

Definition at line 123 of file atrac3.c.

Referenced by atrac3_init_static_data(), and gain_compensate_and_overlap().

float mdct_window[MDCT_SIZE]
static

Definition at line 119 of file atrac3.c.

Referenced by imlt(), and init_atrac3_window().

VLC spectral_coeff_tab[7]
static

Definition at line 121 of file atrac3.c.