22 #ifndef AVCODEC_AACENC_H
23 #define AVCODEC_AACENC_H
62 int win,
int group_len,
const float lambda);
64 int scale_idx,
int cb,
const float lambda,
int rtz);
142 .num_ele = { 1, 0, 0, 0 },
143 .pairing = { { 0 }, },
146 .reorder_map = { 0 },
150 .num_ele = { 1, 0, 0, 0 },
151 .pairing = { { 1 }, },
154 .reorder_map = { 0, 1 },
158 .num_ele = { 1, 0, 0, 1 },
159 .pairing = { { 1 }, },
160 .index = { { 0 },{ 0 },{ 0 },{ 0 } },
162 .reorder_map = { 0, 1, 2 },
166 .num_ele = { 1, 0, 1, 0 },
167 .pairing = { { 1 },{ 0 },{ 0 } },
168 .index = { { 0 },{ 0 },{ 0 }, },
170 .reorder_map = { 0, 1, 2 },
174 .num_ele = { 2, 0, 0, 0 },
175 .pairing = { { 1, 0 }, },
176 .index = { { 0, 0 }, },
178 .reorder_map = { 0, 1, 2 },
182 .num_ele = { 2, 0, 0, 1 },
183 .pairing = { { 1, 0 }, },
184 .index = { { 0, 0 }, { 0 }, { 0 }, { 0 }, },
186 .reorder_map = { 0, 1, 2, 3 },
190 .num_ele = { 2, 0, 1, 0 },
191 .pairing = { { 1, 0 }, { 0 }, { 0 }, },
192 .index = { { 0, 0 }, { 0 }, { 1 } },
194 .reorder_map = { 0, 1, 2, 3 },
198 .num_ele = { 2, 1, 1, 0 },
199 .pairing = { { 1, 0 }, { 0 }, { 0 }, },
200 .index = { { 0, 0 }, { 1 }, { 2 }, { 0 } },
202 .reorder_map = { 0, 1, 2, 3, 4 },
206 .num_ele = { 1, 1, 0, 0 },
207 .pairing = { { 1 }, { 1 }, },
208 .index = { { 0 }, { 1 }, },
210 .reorder_map = { 0, 1, 2, 3 },
214 .num_ele = { 1, 0, 1, 0 },
215 .pairing = { { 1 }, { 0 }, { 1 }, },
216 .index = { { 0 }, { 0 }, { 1 } },
218 .reorder_map = { 0, 1, 2, 3 },
222 .num_ele = { 2, 1, 0, 0 },
223 .pairing = { { 1, 0 }, { 1 }, },
224 .index = { { 0, 0 }, { 1 } },
226 .reorder_map = { 0, 1, 2, 3, 4 },
230 .num_ele = { 2, 1, 1, 0 },
231 .pairing = { { 1, 0 }, { 0 }, { 1 }, },
232 .index = { { 0, 0 }, { 1 }, { 1 } },
234 .reorder_map = { 0, 1, 2, 3, 4, 5 },
238 .num_ele = { 2, 0, 1, 0 },
239 .pairing = { { 1, 0 }, { 0 }, { 1 } },
240 .index = { { 0, 0 }, { 0 }, { 1 } },
242 .reorder_map = { 0, 1, 2, 3, 4 },
246 .num_ele = { 2, 1, 1, 0 },
247 .pairing = { { 1, 0 }, { 0 }, { 1 }, },
248 .index = { { 0, 0 }, { 1 }, { 1 } },
250 .reorder_map = { 0, 1, 2, 3, 4, 5 },
254 .num_ele = { 2, 1, 1, 0 },
255 .pairing = { { 1, 0 }, { 1 }, { 0 }, },
256 .index = { { 0, 0 }, { 1 }, { 1 } },
258 .reorder_map = { 0, 1, 2, 3, 4, 5 },
262 .num_ele = { 2, 1, 0, 0 },
263 .pairing = { { 1, 1 }, { 1 } },
264 .index = { { 1, 0 }, { 2 }, },
266 .reorder_map = { 0, 1, 2, 3, 4, 5 },
270 .num_ele = { 2, 0, 2, 0 },
271 .pairing = { { 1, 0 },{ 0 },{ 1, 0 }, },
272 .index = { { 0, 0 },{ 0 },{ 1, 1 } },
274 .reorder_map = { 0, 1, 2, 3, 4, 5 },
278 .num_ele = { 2, 1, 2, 0 },
279 .pairing = { { 1, 0 },{ 0 },{ 1, 0 }, },
280 .index = { { 0, 0 },{ 1 },{ 1, 2 } },
282 .reorder_map = { 0, 1, 2, 3, 4, 5, 6 },
286 .num_ele = { 2, 1, 2, 0 },
287 .pairing = { { 1, 0 }, { 0 }, { 1, 0 }, },
288 .index = { { 0, 0 }, { 1 }, { 1, 2 } },
290 .reorder_map = { 0, 1, 2, 3, 4, 5, 6 },
294 .num_ele = { 2, 1, 2, 0 },
295 .pairing = { { 1, 0 }, { 0 }, { 1, 0 }, },
296 .index = { { 0, 0 }, { 1 }, { 1, 2 } },
298 .reorder_map = { 0, 1, 2, 3, 4, 5, 6 },
302 .num_ele = { 2, 1, 1, 0 },
303 .pairing = { { 1, 0 }, { 1 }, { 1 }, },
304 .index = { { 0, 0 }, { 1 }, { 2 }, },
306 .reorder_map = { 0, 1, 2, 3, 4, 5, 6 },
310 .num_ele = { 2, 1, 1, 0 },
311 .pairing = { { 1, 0 }, { 1 }, { 1 }, },
312 .index = { { 0, 0 }, { 1 }, { 2 }, },
314 .reorder_map = { 0, 1, 2, 3, 4, 5, 6 },
318 .num_ele = { 2, 1, 2, 0 },
319 .pairing = { { 1, 0 }, { 0 }, { 1, 1 }, },
320 .index = { { 0, 0 }, { 1 }, { 1, 2 }, { 0 } },
322 .reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7 },
326 .num_ele = { 2, 1, 2, 0 },
327 .pairing = { { 1, 0 }, { 0 },{ 1, 1 }, },
328 .index = { { 0, 0 }, { 1 }, { 1, 2 }, { 0 } },
330 .reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7 },
334 .num_ele = { 2, 1, 2, 0 },
335 .pairing = { { 1, 0 }, { 0 }, { 1, 1 }, },
336 .index = { { 0, 0 }, { 1 }, { 1, 2 }, { 0 } },
338 .reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7 },
342 .num_ele = { 2, 1, 2, 0 },
343 .pairing = { { 1, 0 }, { 1 }, { 1, 0 }, },
344 .index = { { 0, 0 }, { 1 }, { 2, 1 } },
346 .reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7 },
350 .num_ele = { 2, 2, 2, 0 },
351 .pairing = { { 1, 0 }, { 1, 0 }, { 1, 0 }, },
352 .index = { { 0, 0 }, { 1, 1 }, { 2, 2 } },
354 .reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7, 8 },
359 .num_ele = { 2, 2, 2, 0 },
360 .pairing = { { 1, 1 }, { 1, 0 }, { 1, 0 }, },
361 .index = { { 0, 1 }, { 2, 0 }, { 3, 1 } },
363 .reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
367 .num_ele = { 4, 2, 4, 0 },
368 .pairing = { { 1, 0, 1, 0 }, { 1, 1 }, { 1, 0, 1, 0 }, },
369 .index = { { 0, 0, 1, 1 }, { 2, 3 }, { 4, 2, 5, 3 } },
370 .config_map = { 10,
TYPE_CPE,
TYPE_SCE,
TYPE_CPE,
TYPE_SCE,
TYPE_CPE,
TYPE_CPE,
TYPE_CPE,
TYPE_SCE,
TYPE_CPE,
TYPE_SCE },
371 .reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
417 int size,
int is_signed,
int maxval,
const float Q34,
418 const float rounding);
void ff_aac_coder_init_mips(AACEncContext *c)
static const AACPCEInfo aac_pce_configs[]
List of PCE (Program Configuration Element) for the channel layouts listed in channel_layout....
const AACCoefficientsEncoder ff_aac_coders[]
void ff_aac_dsp_init_x86(AACEncContext *s)
void ff_quantize_band_cost_cache_init(struct AACEncContext *s)
static float win(SuperEqualizerContext *s, float n, int N)
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
Libavcodec external API header.
#define AV_CH_LAYOUT_2POINT1
#define AV_CH_LAYOUT_QUAD
#define AV_CH_LAYOUT_6POINT1
#define AV_CH_LAYOUT_4POINT0
#define AV_CH_LAYOUT_6POINT0
#define AV_CH_LAYOUT_5POINT0
#define AV_CH_LAYOUT_7POINT1
#define AV_CH_LAYOUT_HEXAGONAL
#define AV_CH_LAYOUT_MONO
#define AV_CH_LAYOUT_SURROUND
#define AV_CH_LAYOUT_6POINT0_FRONT
#define AV_CH_LAYOUT_7POINT1_WIDE
#define AV_CH_LAYOUT_6POINT1_FRONT
#define AV_CH_LAYOUT_7POINT1_WIDE_BACK
#define AV_CH_LAYOUT_7POINT0_FRONT
#define AV_CH_LAYOUT_OCTAGONAL
#define AV_CH_LAYOUT_6POINT1_BACK
#define AV_CH_LAYOUT_5POINT0_BACK
#define AV_CH_LAYOUT_7POINT0
#define AV_CH_LAYOUT_STEREO
#define AV_CH_LAYOUT_5POINT1
#define AV_CH_LAYOUT_4POINT1
#define AV_CH_LAYOUT_3POINT1
#define AV_CH_LAYOUT_5POINT1_BACK
#define AV_CH_LAYOUT_HEXADECAGONAL
#define AV_CH_BACK_CENTER
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
typedef void(RENAME(mix_any_func_type))
void(* encode_tns_info)(struct AACEncContext *s, SingleChannelElement *sce)
void(* search_for_ms)(struct AACEncContext *s, ChannelElement *cpe)
void(* adjust_common_ltp)(struct AACEncContext *s, ChannelElement *cpe)
void(* search_for_quantizers)(AVCodecContext *avctx, struct AACEncContext *s, SingleChannelElement *sce, const float lambda)
void(* update_ltp)(struct AACEncContext *s, SingleChannelElement *sce)
void(* apply_main_pred)(struct AACEncContext *s, SingleChannelElement *sce)
void(* search_for_ltp)(struct AACEncContext *s, SingleChannelElement *sce, int common_window)
void(* ltp_insert_new_frame)(struct AACEncContext *s)
void(* mark_pns)(struct AACEncContext *s, AVCodecContext *avctx, SingleChannelElement *sce)
void(* search_for_pns)(struct AACEncContext *s, AVCodecContext *avctx, SingleChannelElement *sce)
void(* encode_window_bands_info)(struct AACEncContext *s, SingleChannelElement *sce, int win, int group_len, const float lambda)
void(* apply_tns_filt)(struct AACEncContext *s, SingleChannelElement *sce)
void(* quantize_and_encode_band)(struct AACEncContext *s, PutBitContext *pb, const float *in, float *out, int size, int scale_idx, int cb, const float lambda, int rtz)
void(* search_for_pred)(struct AACEncContext *s, SingleChannelElement *sce)
void(* encode_main_pred)(struct AACEncContext *s, SingleChannelElement *sce)
void(* set_special_band_scalefactors)(struct AACEncContext *s, SingleChannelElement *sce)
void(* search_for_tns)(struct AACEncContext *s, SingleChannelElement *sce)
void(* encode_ltp_info)(struct AACEncContext *s, SingleChannelElement *sce, int common_window)
void(* search_for_is)(struct AACEncContext *s, AVCodecContext *avctx, ChannelElement *cpe)
void(* adjust_common_pred)(struct AACEncContext *s, ChannelElement *cpe)
int profile
copied from avctx
FFTContext mdct128
short (128 samples) frame transform context
AACPCEInfo pce
PCE data, if needed.
float * planar_samples[16]
saved preprocessed input
int last_frame_pb_count
number of bits for the previous frame
LPCContext lpc
used by TNS
const uint8_t * chan_map
channel configuration map
void(* abs_pow34)(float *out, const float *in, const int size)
uint16_t quantize_band_cost_cache_generation
int qcoefs[96]
quantized coefficients
AACQuantizeBandCostCacheEntry quantize_band_cost_cache[256][128]
memoization area for quantize_band_cost
float lambda_sum
sum(lambda), for Qvg reporting
FFTContext mdct1024
long (1024 samples) frame transform context
int channels
channel count
ChannelElement * cpe
channel elements
int needs_pce
flag for non-standard layout
struct AACEncContext::@6 buffer
int lambda_count
count(lambda), for Qvg reporting
struct FFPsyPreprocessContext * psypp
int cur_channel
current channel for coder context
void(* quant_bands)(int *out, const float *in, const float *scaled, int size, int is_signed, int maxval, const float Q34, const float rounding)
float scoefs[1024]
scaled coefficients
const AACCoefficientsEncoder * coder
AACEncOptions options
encoding options
const uint8_t * reorder_map
lavc to aac reorder map
enum RawDataBlockType cur_type
channel group type cur_channel belongs to
int samplerate_index
MPEG-4 samplerate index.
int num_ele[4]
front, side, back, lfe
int index[4][8]
front, side, back, lfe
int pairing[3][8]
front, side, back
uint8_t config_map[16]
configs the encoder's channel specific settings
uint8_t reorder_map[16]
maps channels from lavc to aac order
Describe the class of an AVClass context structure.
main external API structure.
channel element - generic struct for SCE/CPE/CCE/LFE
context used by psychoacoustic model
Single Channel Element - used for both SCE and LFE elements.
static double cb(void *priv, double x, double y)