Go to the documentation of this file.
28 #ifndef AVCODEC_ATRAC3PLUS_H
29 #define AVCODEC_ATRAC3PLUS_H
40 #define ATRAC3P_SUBBANDS 16
41 #define ATRAC3P_SUBBAND_SAMPLES 128
42 #define ATRAC3P_FRAME_SAMPLES (ATRAC3P_SUBBAND_SAMPLES * ATRAC3P_SUBBANDS)
44 #define ATRAC3P_PQF_FIR_LEN 12
47 #define ATRAC3P_POWER_COMP_OFF 15
196 int ch_num,
int sb,
float *
out);
209 int ch_index,
float *
sp,
int rng_index,
int sb_num);
223 float *pOut,
int wind_id,
int sb);
235 const float *
in,
float *
out);
Atrac3pWaveSynthParams * waves_info
uint8_t tone_master[ATRAC3P_SUBBANDS]
1 - subband-wise tone channel swapping
Atrac3pWavesData * tones_info_prev
int has_stop_point
indicates stop point within the GHA window
int qu_tab_idx[32]
array of code table indexes for each quant unit
int num_wavs
number of sine waves in the group
Atrac3pIPQFChannelCtx ipqf_ctx[2]
void ff_atrac3p_generate_tones(Atrac3pChanUnitCtx *ch_unit, AVFloatDSPContext *fdsp, int ch_num, int sb, float *out)
Synthesize sine waves for a particular subband.
void ff_atrac3p_power_compensation(Atrac3pChanUnitCtx *ctx, AVFloatDSPContext *fdsp, int ch_index, float *sp, int rng_index, int sb_num)
Perform power compensation aka noise dithering.
void ff_atrac3p_ipqf(FFTContext *dct_ctx, Atrac3pIPQFChannelCtx *hist, const float *in, float *out)
Subband synthesis filter based on the polyphase quadrature (pseudo-QMF) filter bank.
uint8_t negate_coeffs[ATRAC3P_SUBBANDS]
1 - subband-wise IMDCT coefficients negation
Atrac3pWaveParam waves[48]
int use_full_table
1 - full table list, 0 - restricted one
#define ATRAC3P_FRAME_SAMPLES
@ CH_UNIT_EXTENSION
unit containing extension information
int noise_level_index
global noise level index
uint8_t * wnd_shape
IMDCT window shape for current frame.
int amp_index
quantized amplitude index
const float ff_atrac3p_sf_tab[64]
int used_quant_units
number of quant units with coded spectrum
@ CH_UNIT_MONO
unit containing one coded channel
int num_coded_subbands
number of subbands with coded spectrum
int tones_index
total sum of tones in this unit
int noise_present
1 - global noise info present
const uint16_t ff_atrac3p_qu_to_spec_pos[33]
Map quant unit number to its position in the spectrum.
Atrac3pWaveSynthParams * waves_info_prev
const float ff_atrac3p_mant_tab[8]
#define ATRAC3P_PQF_FIR_LEN
length of the prototype FIR of the PQF
@ CH_UNIT_TERMINATOR
unit sequence terminator
int noise_table_index
global noise RNG table index
Atrac3pWaveEnvelope pend_env
pending envelope from the previous frame
AtracGainInfo * gain_data_prev
gain control data for previous frame
int16_t spectrum[2048]
decoded IMDCT spectrum
float buf1[ATRAC3P_PQF_FIR_LEN *2][8]
int num_coded_vals
number of transmitted quant unit values
uint8_t invert_phase[ATRAC3P_SUBBANDS]
1 - subband-wise phase inversion
uint8_t wnd_shape_hist[2][ATRAC3P_SUBBANDS]
IMDCT window shape, 0=sine/1=steep.
Gain control parameters for one subband.
Atrac3pWavesData * tones_info
uint8_t tone_sharing[ATRAC3P_SUBBANDS]
1 - subband-wise tone sharing flags
int has_start_point
indicates start point within the GHA window
int start_index
start index into global tones table for that subband
AtracGainInfo gain_data_hist[2][ATRAC3P_SUBBANDS]
gain control data for all subbands
int qu_sf_idx[32]
array of scale factor indexes for each quant unit
@ CH_UNIT_STEREO
unit containing two jointly-coded channels
int ff_atrac3p_decode_channel_unit(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int num_channels, AVCodecContext *avctx)
Decode bitstream data of a channel unit.
int amp_sf
quantized amplitude scale factor
Per-channel IPQF history.
Amplitude envelope of a group of sine waves.
Atrac3pWaveSynthParams wave_synth_hist[2]
waves synth history for two frames
Sound channel parameters.
int amplitude_mode
1 - low range, 0 - high range
#define DECLARE_ALIGNED(n, t, v)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
void ff_atrac3p_imdct(AVFloatDSPContext *fdsp, FFTContext *mdct_ctx, float *pIn, float *pOut, int wind_id, int sb)
Regular IMDCT and windowing without overlapping, with spectrum reversal in the odd subbands.
int unit_type
unit type (mono/stereo)
Parameters of a single sine wave.
void ff_atrac3p_init_imdct(AVCodecContext *avctx, FFTContext *mdct_ctx)
Initialize IMDCT transform.
int stop_pos
stop position expressed in n*4 samples
void ff_atrac3p_init_vlcs(void)
Initialize VLC tables for bitstream parsing.
Atrac3pWavesData tones_info_hist[2][ATRAC3P_SUBBANDS]
void ff_atrac3p_init_wave_synth(void)
Initialize sine waves synthesizer.
int phase_index
quantized phase index
float prev_buf[2][ATRAC3P_FRAME_SAMPLES]
overlapping buffer
uint8_t power_levs[5]
power compensation levels
int tones_present
1 - tones info present
uint8_t swap_channels[ATRAC3P_SUBBANDS]
1 - perform subband-wise channel swapping
int freq_index
wave frequency index
main external API structure.
Parameters of a group of sine waves.
uint8_t * wnd_shape_prev
IMDCT window shape for previous frame.
int table_type
table type: 0 - tone?, 1- noise?
Atrac3pWaveEnvelope curr_env
group envelope from the current frame
#define ATRAC3P_SUBBANDS
Global unit sizes.
int num_gain_subbands
number of subbands with gain control data
int qu_wordlen[32]
array of word lengths for each quant unit
AtracGainInfo * gain_data
gain control data for next frame
float buf2[ATRAC3P_PQF_FIR_LEN *2][8]
Atrac3pChannelUnitTypes
ATRAC3+ channel unit types.
int num_tone_bands
number of PQF bands with tones
int start_pos
start position expressed in n*4 samples