FFmpeg
Data Structures | Macros | Functions | Variables
atrac1.c File Reference
#include <math.h>
#include "libavutil/float_dsp.h"
#include "libavutil/mem_internal.h"
#include "libavutil/tx.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "decode.h"
#include "get_bits.h"
#include "sinewin.h"
#include "atrac.h"
#include "atrac1data.h"

Go to the source code of this file.

Data Structures

struct  AT1SUCtx
 Sound unit struct, one unit is used per channel. More...
 
struct  AT1Ctx
 The atrac1 context, holds all needed parameters for decoding. More...
 

Macros

#define AT1_MAX_BFU   52
 max number of block floating units in a sound unit More...
 
#define AT1_SU_SIZE   212
 number of bytes in a sound unit More...
 
#define AT1_SU_SAMPLES   512
 number of samples in a sound unit More...
 
#define AT1_FRAME_SIZE   AT1_SU_SIZE * 2
 
#define AT1_SU_MAX_BITS   AT1_SU_SIZE * 8
 
#define AT1_MAX_CHANNELS   2
 
#define AT1_QMF_BANDS   3
 
#define IDX_LOW_BAND   0
 
#define IDX_MID_BAND   1
 
#define IDX_HIGH_BAND   2
 

Functions

static void at1_imdct (AT1Ctx *q, float *spec, float *out, int nbits, int rev_spec)
 
static int at1_imdct_block (AT1SUCtx *su, AT1Ctx *q)
 
static int at1_parse_bsm (GetBitContext *gb, int log2_block_cnt[AT1_QMF_BANDS])
 Parse the block size mode byte. More...
 
static int at1_unpack_dequant (GetBitContext *gb, AT1SUCtx *su, float spec[AT1_SU_SAMPLES])
 
static void at1_subband_synthesis (AT1Ctx *q, AT1SUCtx *su, float *pOut)
 
static int atrac1_decode_frame (AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
 
static av_cold int atrac1_decode_end (AVCodecContext *avctx)
 
static av_cold int atrac1_decode_init (AVCodecContext *avctx)
 

Variables

static const uint16_t samples_per_band [3] = {128, 128, 256}
 size of the transform in samples in the long mode for each QMF band More...
 
static const uint8_t mdct_long_nbits [3] = {7, 7, 8}
 
const FFCodec ff_atrac1_decoder
 

Detailed Description

ATRAC1 compatible decoder. This decoder handles raw ATRAC1 data and probably SDDS data.

Definition in file atrac1.c.

Macro Definition Documentation

◆ AT1_MAX_BFU

#define AT1_MAX_BFU   52

max number of block floating units in a sound unit

Definition at line 46 of file atrac1.c.

◆ AT1_SU_SIZE

#define AT1_SU_SIZE   212

number of bytes in a sound unit

Definition at line 47 of file atrac1.c.

◆ AT1_SU_SAMPLES

#define AT1_SU_SAMPLES   512

number of samples in a sound unit

Definition at line 48 of file atrac1.c.

◆ AT1_FRAME_SIZE

#define AT1_FRAME_SIZE   AT1_SU_SIZE * 2

Definition at line 49 of file atrac1.c.

◆ AT1_SU_MAX_BITS

#define AT1_SU_MAX_BITS   AT1_SU_SIZE * 8

Definition at line 50 of file atrac1.c.

◆ AT1_MAX_CHANNELS

#define AT1_MAX_CHANNELS   2

Definition at line 51 of file atrac1.c.

◆ AT1_QMF_BANDS

#define AT1_QMF_BANDS   3

Definition at line 53 of file atrac1.c.

◆ IDX_LOW_BAND

#define IDX_LOW_BAND   0

Definition at line 54 of file atrac1.c.

◆ IDX_MID_BAND

#define IDX_MID_BAND   1

Definition at line 55 of file atrac1.c.

◆ IDX_HIGH_BAND

#define IDX_HIGH_BAND   2

Definition at line 56 of file atrac1.c.

Function Documentation

◆ at1_imdct()

static void at1_imdct ( AT1Ctx q,
float spec,
float out,
int  nbits,
int  rev_spec 
)
static

Definition at line 94 of file atrac1.c.

Referenced by at1_imdct_block().

◆ at1_imdct_block()

static int at1_imdct_block ( AT1SUCtx su,
AT1Ctx q 
)
static

Definition at line 110 of file atrac1.c.

Referenced by atrac1_decode_frame().

◆ at1_parse_bsm()

static int at1_parse_bsm ( GetBitContext gb,
int  log2_block_cnt[AT1_QMF_BANDS] 
)
static

Parse the block size mode byte.

Definition at line 171 of file atrac1.c.

Referenced by atrac1_decode_frame().

◆ at1_unpack_dequant()

static int at1_unpack_dequant ( GetBitContext gb,
AT1SUCtx su,
float  spec[AT1_SU_SAMPLES] 
)
static

< the word length indexes for each BFU

< the scalefactor indexes for each BFU

Definition at line 194 of file atrac1.c.

Referenced by atrac1_decode_frame().

◆ at1_subband_synthesis()

static void at1_subband_synthesis ( AT1Ctx q,
AT1SUCtx su,
float pOut 
)
static

Definition at line 259 of file atrac1.c.

Referenced by atrac1_decode_frame().

◆ atrac1_decode_frame()

static int atrac1_decode_frame ( AVCodecContext avctx,
AVFrame frame,
int got_frame_ptr,
AVPacket avpkt 
)
static

Definition at line 276 of file atrac1.c.

◆ atrac1_decode_end()

static av_cold int atrac1_decode_end ( AVCodecContext avctx)
static

Definition at line 323 of file atrac1.c.

◆ atrac1_decode_init()

static av_cold int atrac1_decode_init ( AVCodecContext avctx)
static

Definition at line 335 of file atrac1.c.

Variable Documentation

◆ samples_per_band

const uint16_t samples_per_band[3] = {128, 128, 256}
static

size of the transform in samples in the long mode for each QMF band

Definition at line 90 of file atrac1.c.

Referenced by at1_imdct_block().

◆ mdct_long_nbits

const uint8_t mdct_long_nbits[3] = {7, 7, 8}
static

Definition at line 91 of file atrac1.c.

Referenced by at1_imdct_block().

◆ ff_atrac1_decoder

const FFCodec ff_atrac1_decoder
Initial value:
= {
.p.name = "atrac1",
CODEC_LONG_NAME("ATRAC1 (Adaptive TRansform Acoustic Coding)"),
.p.type = AVMEDIA_TYPE_AUDIO,
.priv_data_size = sizeof(AT1Ctx),
.p.capabilities = AV_CODEC_CAP_DR1,
.p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
}

Definition at line 391 of file atrac1.c.

AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:66
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:42
AT1Ctx
The atrac1 context, holds all needed parameters for decoding.
Definition: atrac1.c:75
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:287
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:365
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:56
AV_CODEC_ID_ATRAC1
@ AV_CODEC_ID_ATRAC1
Definition: codec_id.h:486
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
atrac1_decode_init
static av_cold int atrac1_decode_init(AVCodecContext *avctx)
Definition: atrac1.c:335
atrac1_decode_end
static av_cold int atrac1_decode_end(AVCodecContext *avctx)
Definition: atrac1.c:323
atrac1_decode_frame
static int atrac1_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
Definition: atrac1.c:276