48#define AT1_SU_SIZE 212
49#define AT1_SU_SAMPLES 512
50#define AT1_FRAME_SIZE AT1_SU_SIZE * 2
51#define AT1_SU_MAX_BITS AT1_SU_SIZE * 8
52#define AT1_MAX_CHANNELS 8
54#define AT1_QMF_BANDS 3
57#define IDX_HIGH_BAND 2
100 int transf_size = 1 << nbits;
104 for (
i = 0;
i < transf_size / 2;
i++)
105 FFSWAP(
float, spec[
i], spec[transf_size - 1 -
i]);
107 mdct_fn(mdct_context,
out, spec,
sizeof(
float));
113 int band_num, band_samples, log2_block_count, nbits, num_blocks, block_size;
114 unsigned int start_pos, ref_pos = 0,
pos = 0;
125 num_blocks = 1 << log2_block_count;
127 if (num_blocks == 1) {
130 block_size = band_samples >> log2_block_count;
135 if (nbits != 5 && nbits != 7 && nbits != 8)
143 prev_buf = &su->
spectrum[1][ref_pos + band_samples - 16];
144 for (j=0; j < num_blocks; j++) {
149 &su->
spectrum[0][ref_pos + start_pos], ff_sine_32, 16);
151 prev_buf = &su->
spectrum[0][ref_pos+start_pos + 16];
152 start_pos += block_size;
157 memcpy(q->
bands[band_num] + 32, &su->
spectrum[0][ref_pos + 16], 240 *
sizeof(
float));
159 ref_pos += band_samples;
174 int log2_block_count_tmp,
i;
176 for (
i = 0;
i < 2;
i++) {
178 log2_block_count_tmp =
get_bits(gb, 2);
179 if (log2_block_count_tmp & 1)
181 log2_block_cnt[
i] = 2 - log2_block_count_tmp;
185 log2_block_count_tmp =
get_bits(gb, 2);
186 if (log2_block_count_tmp != 0 && log2_block_count_tmp != 3)
198 int bits_used, band_num, bfu_num,
i;
208 bits_used = su->
num_bfus * 10 + 32 +
222 idwls[
i] = idsfs[
i] = 0;
230 int word_len = !!idwls[bfu_num] + idwls[bfu_num];
232 bits_used += word_len * num_specs;
242 float max_quant = 1.0 / (
float)((1 << (word_len - 1)) - 1);
244 for (
i = 0;
i < num_specs;
i++) {
248 spec[
pos+
i] =
get_sbits(gb, word_len) * scale_factor * max_quant;
251 memset(&spec[
pos], 0, num_specs *
sizeof(
float));
263 float iqmf_temp[512 + 46];
278 int *got_frame_ptr,
AVPacket *avpkt)
280 const uint8_t *buf = avpkt->
data;
281 int buf_size = avpkt->
size;
341 float scale = -1.0 / (1 << 15);
359 1, 32, &
scale, 0) < 0))
362 1, 128, &
scale, 0) < 0))
365 1, 256, &
scale, 0) < 0))
397 .priv_data_size =
sizeof(
AT1Ctx),
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static float win(SuperEqualizerContext *s, float n, int N)
const FFCodec ff_atrac1_decoder
static av_cold void close(AVCodecParserContext *s)
static av_cold int atrac1_decode_end(AVCodecContext *avctx)
static void at1_imdct(AT1Ctx *q, float *spec, float *out, int nbits, int rev_spec)
static const uint16_t samples_per_band[3]
size of the transform in samples in the long mode for each QMF band
static void at1_subband_synthesis(AT1Ctx *q, AT1SUCtx *su, float *pOut)
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.
static int at1_unpack_dequant(GetBitContext *gb, AT1SUCtx *su, float spec[AT1_SU_SAMPLES])
static const uint8_t mdct_long_nbits[3]
static int atrac1_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
#define AT1_MAX_BFU
max number of block floating units in a sound unit
static av_cold int atrac1_decode_init(AVCodecContext *avctx)
#define AT1_SU_SAMPLES
number of samples in a sound unit
ATRAC1 compatible decoder data.
static const uint16_t bfu_start_short[52]
start position of each BFU in the MDCT spectrum for the short mode
static const uint8_t bfu_amount_tab2[4]
static const uint8_t bfu_amount_tab1[8]
static const uint16_t bfu_start_long[52]
start position of each BFU in the MDCT spectrum for the long mode
static const uint8_t specs_per_bfu[52]
number of spectral lines in each BFU block floating unit = group of spectral frequencies having the s...
static const uint8_t bfu_amount_tab3[8]
static const uint8_t bfu_bands_t[4]
number of BFUs in each QMF band
float ff_atrac_sf_table[64]
av_cold void ff_atrac_generate_tables(void)
Generate common tables.
void ff_atrac_iqmf(float *inlo, float *inhi, unsigned int nIn, float *pOut, float *delayBuf, float *temp)
Quadrature mirror synthesis filter.
Libavcodec external API header.
#define i(width, name, range_min, range_max)
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int(* init)(AVBSFContext *ctx)
bitstream reader API header.
static int get_sbits(GetBitContext *s, int n)
static void skip_bits(GetBitContext *s, int n)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_SAMPLE_FMT_FLTP
float, planar
static void scale(int *out, const int *in, const int w, const int h, const int shift)
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
#define FFSWAP(type, a, b)
Memory handling functions.
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
void ff_init_ff_sine_windows(int index)
initialize the specified entry of ff_sine_windows
The atrac1 context, holds all needed parameters for decoding.
AT1SUCtx SUs[AT1_MAX_CHANNELS]
channel sound unit
void(* vector_fmul_window)(float *dst, const float *src0, const float *src1, const float *win, int len)
float spec[AT1_SU_SAMPLES]
the mdct spectrum buffer
AVTXContext * mdct_ctx[3]
Sound unit struct, one unit is used per channel.
float fst_qmf_delay[46]
delay line for the 1st stacked QMF filter
float spec1[AT1_SU_SAMPLES]
mdct buffer
int num_bfus
number of Block Floating Units
float snd_qmf_delay[46]
delay line for the 2nd stacked QMF filter
float spec2[AT1_SU_SAMPLES]
mdct buffer
int log2_block_count[AT1_QMF_BANDS]
log2 number of blocks in a band
float last_qmf_delay[256+39]
delay line for the last stacked QMF filter
int nb_channels
Number of channels in this layout.
main external API structure.
AVChannelLayout ch_layout
Audio channel layout.
enum AVSampleFormat sample_fmt
audio sample format
int flags
AV_CODEC_FLAG_*.
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs.
void(* vector_fmul_window)(float *dst, const float *src0, const float *src1, const float *win, int len)
Overlap/add with window function.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
av_cold void av_tx_uninit(AVTXContext **ctx)
Frees a context and sets *ctx to NULL, does nothing when *ctx == NULL.
av_cold int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum AVTXType type, int inv, int len, const void *scale, uint64_t flags)
Initialize a transform context with the given configuration (i)MDCTs with an odd length are currently...
@ AV_TX_FLOAT_MDCT
Standard MDCT with a sample data type of float, double or int32_t, respectively.
void(* av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
Function pointer to a function to perform the transform.