45 #define AT1_MAX_BFU 52
46 #define AT1_SU_SIZE 212
47 #define AT1_SU_SAMPLES 512
48 #define AT1_FRAME_SIZE AT1_SU_SIZE * 2
49 #define AT1_SU_MAX_BITS AT1_SU_SIZE * 8
50 #define AT1_MAX_CHANNELS 2
52 #define AT1_QMF_BANDS 3
53 #define IDX_LOW_BAND 0
54 #define IDX_MID_BAND 1
55 #define IDX_HIGH_BAND 2
96 int transf_size = 1 << nbits;
100 for (i = 0; i < transf_size / 2; i++)
101 FFSWAP(
float, spec[i], spec[transf_size - 1 - i]);
103 mdct_context->
imdct_half(mdct_context, out, spec);
109 int band_num, band_samples, log2_block_count, nbits, num_blocks, block_size;
110 unsigned int start_pos, ref_pos = 0, pos = 0;
121 num_blocks = 1 << log2_block_count;
123 if (num_blocks == 1) {
126 block_size = band_samples >> log2_block_count;
131 if (nbits != 5 && nbits != 7 && nbits != 8)
139 prev_buf = &su->
spectrum[1][ref_pos + band_samples - 16];
140 for (j=0; j < num_blocks; j++) {
145 &su->
spectrum[0][ref_pos + start_pos], ff_sine_32, 16);
147 prev_buf = &su->
spectrum[0][ref_pos+start_pos + 16];
148 start_pos += block_size;
153 memcpy(q->
bands[band_num] + 32, &su->
spectrum[0][ref_pos + 16], 240 *
sizeof(
float));
155 ref_pos += band_samples;
170 int log2_block_count_tmp, i;
172 for (i = 0; i < 2; i++) {
174 log2_block_count_tmp =
get_bits(gb, 2);
175 if (log2_block_count_tmp & 1)
177 log2_block_cnt[i] = 2 - log2_block_count_tmp;
181 log2_block_count_tmp =
get_bits(gb, 2);
182 if (log2_block_count_tmp != 0 && log2_block_count_tmp != 3)
194 int bits_used, band_num, bfu_num, i;
204 bits_used = su->
num_bfus * 10 + 32 +
218 idwls[i] = idsfs[i] = 0;
226 int word_len = !!idwls[bfu_num] + idwls[bfu_num];
228 bits_used += word_len * num_specs;
238 float max_quant = 1.0 / (float)((1 << (word_len - 1)) - 1);
240 for (i = 0; i < num_specs; i++) {
244 spec[pos+i] =
get_sbits(gb, word_len) * scale_factor * max_quant;
247 memset(&spec[pos], 0, num_specs *
sizeof(
float));
259 float iqmf_temp[512 + 46];
274 int *got_frame_ptr,
AVPacket *avpkt)
277 int buf_size = avpkt->
size;
283 if (buf_size < 212 * avctx->channels) {
295 for (ch = 0; ch < avctx->
channels; ch++) {
383 .priv_data_size =
sizeof(
AT1Ctx),
void(* vector_fmul_window)(float *dst, const float *src0, const float *src1, const float *win, int len)
av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx)
float snd_qmf_delay[46]
delay line for the 2nd stacked QMF filter
This structure describes decoded (raw) audio or video data.
AVCodec ff_atrac1_decoder
Sound unit struct, one unit is used per channel.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static int at1_unpack_dequant(GetBitContext *gb, AT1SUCtx *su, float spec[AT1_SU_SAMPLES])
AT1SUCtx SUs[AT1_MAX_CHANNELS]
channel sound unit
AVFrame * coded_frame
the picture in the bitstream
static av_cold int atrac1_decode_init(AVCodecContext *avctx)
static av_cold int atrac1_decode_end(AVCodecContext *avctx)
static const uint8_t bfu_amount_tab2[4]
void ff_atrac_iqmf(float *inlo, float *inhi, unsigned int nIn, float *pOut, float *delayBuf, float *temp)
Quadrature mirror synthesis filter.
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
static int get_sbits(GetBitContext *s, int n)
static void at1_subband_synthesis(AT1Ctx *q, AT1SUCtx *su, float *pOut)
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...
float ff_atrac_sf_table[64]
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
#define FFSWAP(type, a, b)
enum AVSampleFormat sample_fmt
audio sample format
static const uint16_t samples_per_band[3]
size of the transform in samples in the long mode for each QMF band
The atrac1 context, holds all needed parameters for decoding.
void ff_atrac_generate_tables(void)
Generate common tables.
float spec2[AT1_SU_SAMPLES]
mdct buffer
#define AT1_SU_SAMPLES
number of samples in a sound unit
bitstream reader API header.
static int at1_parse_bsm(GetBitContext *gb, int log2_block_cnt[AT1_QMF_BANDS])
Parse the block size mode byte.
static int init(AVCodecParserContext *s)
static void at1_imdct(AT1Ctx *q, float *spec, float *out, int nbits, int rev_spec)
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_tab1[8]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
float spec1[AT1_SU_SAMPLES]
mdct buffer
int log2_block_count[AT1_QMF_BANDS]
log2 number of blocks in a band
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame)
Get a buffer for a frame.
float fst_qmf_delay[46]
delay line for the 1st stacked QMF filter
main external API structure.
static void close(AVCodecParserContext *s)
void(* imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input)
static int atrac1_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
void avcodec_get_frame_defaults(AVFrame *frame)
Set the fields of the given AVFrame to default values.
static void skip_bits(GetBitContext *s, int n)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static const uint8_t mdct_long_nbits[3]
#define AT1_MAX_BFU
max number of block floating units in a sound unit
#define DECLARE_ALIGNED(n, t, v)
static const uint8_t bfu_bands_t[4]
number of BFUs in each QMF band
float last_qmf_delay[256+23]
delay line for the last stacked QMF filter
float spec[AT1_SU_SAMPLES]
the mdct spectrum buffer
common internal api header.
#define AVERROR_INVALIDDATA
AVSampleFormat
Audio Sample Formats.
Atrac 1 compatible decoder data.
int channels
number of audio channels
uint8_t ** extended_data
pointers to the data planes/channels.
This structure stores compressed data.
static const uint8_t bfu_amount_tab3[8]
int nb_samples
number of audio samples (per channel) described by this frame
int num_bfus
number of Block Floating Units
void ff_init_ff_sine_windows(int index)
initialize the specified entry of ff_sine_windows
static int at1_imdct_block(AT1SUCtx *su, AT1Ctx *q)
static const uint16_t bfu_start_long[52]
start position of each BFU in the MDCT spectrum for the long mode