Go to the documentation of this file.
47 #define AT1_MAX_BFU 52
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 2
54 #define AT1_QMF_BANDS 3
55 #define IDX_LOW_BAND 0
56 #define IDX_MID_BAND 1
57 #define IDX_HIGH_BAND 2
98 int transf_size = 1 << nbits;
102 for (
i = 0;
i < transf_size / 2;
i++)
103 FFSWAP(
float, spec[
i], spec[transf_size - 1 -
i]);
111 int band_num, band_samples, log2_block_count, nbits, num_blocks, block_size;
112 unsigned int start_pos, ref_pos = 0,
pos = 0;
119 log2_block_count =
su->log2_block_count[band_num];
123 num_blocks = 1 << log2_block_count;
125 if (num_blocks == 1) {
128 block_size = band_samples >> log2_block_count;
133 if (nbits != 5 && nbits != 7 && nbits != 8)
141 prev_buf = &
su->spectrum[1][ref_pos + band_samples - 16];
142 for (j=0; j < num_blocks; j++) {
147 &
su->spectrum[0][ref_pos + start_pos], ff_sine_32, 16);
149 prev_buf = &
su->spectrum[0][ref_pos+start_pos + 16];
150 start_pos += block_size;
155 memcpy(q->
bands[band_num] + 32, &
su->spectrum[0][ref_pos + 16], 240 *
sizeof(
float));
157 ref_pos += band_samples;
161 FFSWAP(
float*,
su->spectrum[0],
su->spectrum[1]);
172 int log2_block_count_tmp,
i;
174 for (
i = 0;
i < 2;
i++) {
176 log2_block_count_tmp =
get_bits(gb, 2);
177 if (log2_block_count_tmp & 1)
179 log2_block_cnt[
i] = 2 - log2_block_count_tmp;
183 log2_block_count_tmp =
get_bits(gb, 2);
184 if (log2_block_count_tmp != 0 && log2_block_count_tmp != 3)
196 int bits_used, band_num, bfu_num,
i;
206 bits_used =
su->num_bfus * 10 + 32 +
211 for (
i = 0;
i <
su->num_bfus;
i++)
215 for (
i = 0;
i <
su->num_bfus;
i++)
220 idwls[
i] = idsfs[
i] = 0;
228 int word_len = !!idwls[bfu_num] + idwls[bfu_num];
230 bits_used += word_len * num_specs;
240 float max_quant = 1.0 / (float)((1 << (word_len - 1)) - 1);
242 for (
i = 0;
i < num_specs;
i++) {
246 spec[
pos+
i] =
get_sbits(gb, word_len) * scale_factor * max_quant;
249 memset(&spec[
pos], 0, num_specs *
sizeof(
float));
261 float iqmf_temp[512 + 46];
267 memcpy(
su->last_qmf_delay, &
su->last_qmf_delay[256],
sizeof(
float) * 39);
268 memcpy(&
su->last_qmf_delay[39], q->
bands[2],
sizeof(
float) * 256);
276 int *got_frame_ptr,
AVPacket *avpkt)
279 const uint8_t *buf = avpkt->
data;
280 int buf_size = avpkt->
size;
286 if (buf_size < 212 * avctx->
channels) {
296 for (ch = 0; ch < avctx->
channels; ch++) {
390 .priv_data_size =
sizeof(
AT1Ctx),
@ AV_SAMPLE_FMT_FLTP
float, planar
static const uint8_t mdct_long_nbits[3]
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
#define AT1_MAX_BFU
max number of block floating units in a sound unit
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
#define AT1_SU_SAMPLES
number of samples in a sound unit
static const uint8_t bfu_bands_t[4]
number of BFUs in each QMF band
static enum AVSampleFormat sample_fmts[]
This structure describes decoded (raw) audio or video data.
float spec[AT1_SU_SAMPLES]
the mdct spectrum buffer
int num_bfus
number of Block Floating Units
static void at1_imdct(AT1Ctx *q, float *spec, float *out, int nbits, int rev_spec)
The atrac1 context, holds all needed parameters for decoding.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static float win(SuperEqualizerContext *s, float n, int N)
static void skip_bits(GetBitContext *s, int n)
float spec2[AT1_SU_SAMPLES]
mdct buffer
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Sound unit struct, one unit is used per channel.
static int at1_imdct_block(AT1SUCtx *su, AT1Ctx *q)
int flags
AV_CODEC_FLAG_*.
void(* vector_fmul_window)(float *dst, const float *src0, const float *src1, const float *win, int len)
float fst_qmf_delay[46]
delay line for the 1st stacked QMF filter
static const uint16_t bfu_start_long[52]
start position of each BFU in the MDCT spectrum for the long mode
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int atrac1_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
static const uint16_t bfu_start_short[52]
start position of each BFU in the MDCT spectrum for the short mode
static int get_sbits(GetBitContext *s, int n)
static int at1_unpack_dequant(GetBitContext *gb, AT1SUCtx *su, float spec[AT1_SU_SAMPLES])
static const uint8_t bfu_amount_tab1[8]
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
AT1SUCtx SUs[AT1_MAX_CHANNELS]
channel sound unit
float ff_atrac_sf_table[64]
void(* imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static int at1_parse_bsm(GetBitContext *gb, int log2_block_cnt[AT1_QMF_BANDS])
Parse the block size mode byte.
enum AVSampleFormat sample_fmt
audio sample format
float spec1[AT1_SU_SAMPLES]
mdct buffer
static const uint8_t bfu_amount_tab2[4]
int log2_block_count[AT1_QMF_BANDS]
log2 number of blocks in a band
av_cold void ff_atrac_generate_tables(void)
Generate common tables.
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]
int channels
number of audio channels
#define DECLARE_ALIGNED(n, t, v)
#define i(width, name, range_min, range_max)
float snd_qmf_delay[46]
delay line for the 2nd stacked QMF filter
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
AVSampleFormat
Audio sample formats.
const char * name
Name of the codec implementation.
static av_cold int atrac1_decode_init(AVCodecContext *avctx)
static av_cold int atrac1_decode_end(AVCodecContext *avctx)
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs.
#define FFSWAP(type, a, b)
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
float last_qmf_delay[256+39]
delay line for the last stacked QMF filter
main external API structure.
void ff_init_ff_sine_windows(int index)
initialize the specified entry of ff_sine_windows
const AVCodec ff_atrac1_decoder
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
void(* vector_fmul_window)(float *dst, const float *src0, const float *src1, const float *win, int len)
Overlap/add with window function.
This structure stores compressed data.
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static void at1_subband_synthesis(AT1Ctx *q, AT1SUCtx *su, float *pOut)
void ff_atrac_iqmf(float *inlo, float *inhi, unsigned int nIn, float *pOut, float *delayBuf, float *temp)
Quadrature mirror synthesis filter.
static const uint16_t samples_per_band[3]
size of the transform in samples in the long mode for each QMF band