74 for (
i = 0;
i < 4;
i++) {
75 for (j = 0; j < pce->
num_ele[
i]; j++) {
95 int channels = (!
s->needs_pce)*(
s->channels - (
s->channels == 8 ? 1 : 0));
96 const int max_size = 32;
125 ++
s->quantize_band_cost_cache_generation;
126 if (
s->quantize_band_cost_cache_generation == 0) {
127 memset(
s->quantize_band_cost_cache, 0,
sizeof(
s->quantize_band_cost_cache));
128 s->quantize_band_cost_cache_generation = 1;
132 #define WINDOW_FUNC(type) \
133 static void apply_ ##type ##_window(AVFloatDSPContext *fdsp, \
134 SingleChannelElement *sce, \
141 float *
out = sce->ret_buf;
143 fdsp->vector_fmul (
out, audio, lwindow, 1024);
144 fdsp->vector_fmul_reverse(
out + 1024, audio + 1024, pwindow, 1024);
151 float *
out = sce->ret_buf;
153 fdsp->vector_fmul(
out, audio, lwindow, 1024);
154 memcpy(
out + 1024, audio + 1024,
sizeof(
out[0]) * 448);
155 fdsp->vector_fmul_reverse(
out + 1024 + 448, audio + 1024 + 448, swindow, 128);
156 memset(
out + 1024 + 576, 0,
sizeof(
out[0]) * 448);
163 float *
out = sce->ret_buf;
165 memset(
out, 0,
sizeof(
out[0]) * 448);
166 fdsp->vector_fmul(
out + 448, audio + 448, swindow, 128);
167 memcpy(
out + 576, audio + 576,
sizeof(
out[0]) * 448);
168 fdsp->vector_fmul_reverse(
out + 1024, audio + 1024, lwindow, 1024);
175 const float *
in = audio + 448;
176 float *
out = sce->ret_buf;
179 for (
w = 0;
w < 8;
w++) {
180 fdsp->vector_fmul (
out,
in,
w ? pwindow : swindow, 128);
183 fdsp->vector_fmul_reverse(
out,
in, swindow, 128);
190 const float *audio) = {
201 const float *output = sce->
ret_buf;
206 s->mdct1024.mdct_calc(&
s->mdct1024, sce->
coeffs, output);
208 for (
i = 0;
i < 1024;
i += 128)
209 s->mdct128.mdct_calc(&
s->mdct128, &sce->
coeffs[
i], output +
i*2);
210 memcpy(audio, audio + 1024,
sizeof(audio[0]) * 1024);
230 for (
w = 1;
w < 8;
w++)
258 for (ch = 0; ch < chans; ch++) {
264 for (cmaxsfb = ics->
num_swb; cmaxsfb > 0 && cpe->
ch[ch].
zeroes[
w*16+cmaxsfb-1]; cmaxsfb--)
266 maxsfb =
FFMAX(maxsfb, cmaxsfb);
296 if (msc == 0 || ics0->
max_sfb == 0)
311 int start = (
w+w2) * 128;
340 int start = (
w+w2) * 128;
371 if (
s->coder->set_special_band_scalefactors)
372 s->coder->set_special_band_scalefactors(
s, sce);
385 int off_is = 0, noise_flag = 1;
394 if (noise_flag-- > 0) {
448 s->coder->quantize_and_encode_band(
s, &
s->pb,
449 &sce->
coeffs[start + w2*128],
472 float *swb_coeffs = &sce->
coeffs[start +
w*128];
489 if (!common_window) {
491 if (
s->coder->encode_main_pred)
492 s->coder->encode_main_pred(
s, sce);
493 if (
s->coder->encode_ltp_info)
494 s->coder->encode_ltp_info(
s, sce, 0);
500 if (
s->coder->encode_tns_info)
501 s->coder->encode_tns_info(
s, sce);
512 int i, namelen, padbits;
514 namelen = strlen(
name) + 2;
522 for (
i = 0;
i < namelen - 2;
i++)
535 const uint8_t *channel_map =
s->reorder_map;
538 for (ch = 0; ch <
s->channels; ch++) {
540 memcpy(&
s->planar_samples[ch][1024], &
s->planar_samples[ch][2048], 1024 *
sizeof(
s->planar_samples[0][0]));
544 memcpy(&
s->planar_samples[ch][2048],
548 memset(&
s->planar_samples[ch][end], 0,
549 (3072 - end) *
sizeof(
s->planar_samples[0][0]));
557 float **samples =
s->planar_samples, *samples2, *la, *overlap;
561 int i, its, ch,
w, chans,
tag, start_ch, ret, frame_bits;
562 int target_bits, rate_bits, too_many_bits, too_few_bits;
563 int ms_mode = 0, is_mode = 0, tns_mode = 0, pred_mode = 0;
564 int chan_el_counter[4];
572 if (!
s->afq.remaining_samples || (!
s->afq.frame_alloc && !
s->afq.frame_count))
584 for (
i = 0;
i <
s->chan_map[0];
i++) {
586 tag =
s->chan_map[
i+1];
589 for (ch = 0; ch < chans; ch++) {
591 float clip_avoidance_factor;
594 s->cur_channel = start_ch + ch;
595 overlap = &samples[
s->cur_channel][0];
596 samples2 = overlap + 1024;
597 la = samples2 + (448+64);
611 ics->
num_swb =
s->samplerate_index >= 8 ? 1 : 3;
613 wi[ch] =
s->psy.model->window(&
s->psy, samples2, la,
s->cur_channel,
635 clip_avoidance_factor = 0.0f;
637 const float *wbuf = overlap +
w * 128;
642 for (j = 0; j < wlen; j++)
649 clip_avoidance_factor =
FFMAX(clip_avoidance_factor, wi[ch].clipping[
w]);
662 if (
s->options.ltp &&
s->coder->update_ltp) {
663 s->coder->update_ltp(
s, sce);
668 for (k = 0; k < 1024; k++) {
680 frame_bits = its = 0;
688 memset(chan_el_counter, 0,
sizeof(chan_el_counter));
689 for (
i = 0;
i <
s->chan_map[0];
i++) {
691 const float *coeffs[2];
692 tag =
s->chan_map[
i+1];
700 for (ch = 0; ch < chans; ch++) {
708 for (
w = 0;
w < 128;
w++)
712 s->psy.bitres.alloc = -1;
713 s->psy.bitres.bits =
s->last_frame_pb_count /
s->channels;
714 s->psy.model->analyze(&
s->psy, start_ch, coeffs, wi);
715 if (
s->psy.bitres.alloc > 0) {
717 target_bits +=
s->psy.bitres.alloc
719 s->psy.bitres.alloc /= chans;
722 for (ch = 0; ch < chans; ch++) {
723 s->cur_channel = start_ch + ch;
724 if (
s->options.pns &&
s->coder->mark_pns)
725 s->coder->mark_pns(
s, avctx, &cpe->
ch[ch]);
726 s->coder->search_for_quantizers(avctx,
s, &cpe->
ch[ch],
s->lambda);
729 && wi[0].window_type[0] == wi[1].window_type[0]
730 && wi[0].window_shape == wi[1].window_shape) {
734 if (wi[0].grouping[
w] != wi[1].grouping[
w]) {
740 for (ch = 0; ch < chans; ch++) {
742 s->cur_channel = start_ch + ch;
743 if (
s->options.tns &&
s->coder->search_for_tns)
744 s->coder->search_for_tns(
s, sce);
745 if (
s->options.tns &&
s->coder->apply_tns_filt)
746 s->coder->apply_tns_filt(
s, sce);
749 if (
s->options.pns &&
s->coder->search_for_pns)
750 s->coder->search_for_pns(
s, avctx, sce);
752 s->cur_channel = start_ch;
753 if (
s->options.intensity_stereo) {
754 if (
s->coder->search_for_is)
755 s->coder->search_for_is(
s, avctx, cpe);
759 if (
s->options.pred) {
760 for (ch = 0; ch < chans; ch++) {
762 s->cur_channel = start_ch + ch;
763 if (
s->options.pred &&
s->coder->search_for_pred)
764 s->coder->search_for_pred(
s, sce);
767 if (
s->coder->adjust_common_pred)
768 s->coder->adjust_common_pred(
s, cpe);
769 for (ch = 0; ch < chans; ch++) {
771 s->cur_channel = start_ch + ch;
772 if (
s->options.pred &&
s->coder->apply_main_pred)
773 s->coder->apply_main_pred(
s, sce);
775 s->cur_channel = start_ch;
777 if (
s->options.mid_side) {
778 if (
s->options.mid_side == -1 &&
s->coder->search_for_ms)
779 s->coder->search_for_ms(
s, cpe);
785 if (
s->options.ltp) {
786 for (ch = 0; ch < chans; ch++) {
788 s->cur_channel = start_ch + ch;
789 if (
s->coder->search_for_ltp)
793 s->cur_channel = start_ch;
794 if (
s->coder->adjust_common_ltp)
795 s->coder->adjust_common_ltp(
s, cpe);
801 if (
s->coder->encode_main_pred)
802 s->coder->encode_main_pred(
s, &cpe->
ch[0]);
803 if (
s->coder->encode_ltp_info)
804 s->coder->encode_ltp_info(
s, &cpe->
ch[0], 1);
809 for (ch = 0; ch < chans; ch++) {
810 s->cur_channel = start_ch + ch;
827 rate_bits =
FFMIN(rate_bits, 6144 *
s->channels - 3);
828 too_many_bits =
FFMAX(target_bits, rate_bits);
829 too_many_bits =
FFMIN(too_many_bits, 6144 *
s->channels - 3);
830 too_few_bits =
FFMIN(
FFMAX(rate_bits - rate_bits/4, target_bits), too_many_bits);
833 too_few_bits = too_few_bits - too_few_bits/8;
834 too_many_bits = too_many_bits + too_many_bits/2;
837 || (its < 5 && (frame_bits < too_few_bits || frame_bits > too_many_bits))
838 || frame_bits >= 6144 *
s->channels - 3 )
840 float ratio = ((float)rate_bits) / frame_bits;
842 if (frame_bits >= too_few_bits && frame_bits <= too_many_bits) {
849 ratio = sqrtf(sqrtf(ratio));
850 ratio =
av_clipf(ratio, 0.9f, 1.1f);
853 ratio = sqrtf(ratio);
855 s->lambda =
FFMIN(
s->lambda * ratio, 65536.f);
858 if (ratio > 0.9f && ratio < 1.1f) {
861 if (is_mode || ms_mode || tns_mode || pred_mode) {
862 for (
i = 0;
i <
s->chan_map[0];
i++) {
866 for (ch = 0; ch < chans; ch++)
877 if (
s->options.ltp &&
s->coder->ltp_insert_new_frame)
878 s->coder->ltp_insert_new_frame(
s);
885 s->lambda_sum +=
s->lambda;
941 for(ch = 0; ch <
s->channels; ch++)
942 s->planar_samples[ch] =
s->buffer.samples + 3 * 1024 * ch;
956 s->last_frame_pb_count = 0;
967 s->needs_pce =
s->options.pce;
979 av_log(avctx,
AV_LOG_INFO,
"Using a PCE to encode channel layout \"%s\"\n", buf);
981 s->reorder_map =
s->pce.reorder_map;
982 s->chan_map =
s->pce.config_map;
989 for (
i = 1;
i <=
s->chan_map[0];
i++) {
997 for (
i = 0;
i < 16;
i++)
1000 s->samplerate_index =
i;
1004 "Unsupported sample rate %d\n", avctx->
sample_rate);
1008 "Too many bits %f > %d per frame requested, clamping to max\n",
1010 6144 *
s->channels);
1023 "Main prediction unavailable in the \"mpeg2_aac_low\" profile\n");
1025 "LTP prediction unavailable in the \"mpeg2_aac_low\" profile\n");
1027 "PNS unavailable in the \"mpeg2_aac_low\" profile, turning off\n");
1032 "Main prediction unavailable in the \"aac_ltp\" profile\n");
1034 s->options.pred = 1;
1036 "LTP prediction unavailable in the \"aac_main\" profile\n");
1037 }
else if (
s->options.ltp) {
1040 "Chainging profile to \"aac_ltp\"\n");
1042 "Main prediction unavailable in the \"aac_ltp\" profile\n");
1043 }
else if (
s->options.pred) {
1046 "Chainging profile to \"aac_main\"\n");
1048 "LTP prediction unavailable in the \"aac_main\" profile\n");
1056 "The ANMR coder is considered experimental, add -strict -2 to enable!\n");
1057 s->options.intensity_stereo = 0;
1061 "The LPT profile requires experimental compliance, add -strict -2 to enable!\n");
1064 if (
s->channels > 3)
1065 s->options.mid_side = 0;
1080 for (
i = 0;
i <
s->chan_map[0];
i++)
1083 s->chan_map[0], grouping)) < 0)
1087 s->random_state = 0x1f2e3d4c;
1104 #define AACENC_FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
1106 {
"aac_coder",
"Coding algorithm", offsetof(
AACEncContext,
options.coder),
AV_OPT_TYPE_INT, {.i64 =
AAC_CODER_FAST}, 0,
AAC_CODER_NB-1,
AACENC_FLAGS,
"coder"},
#define NOISE_PRE
preamble for NOISE_BT, put in bitstream with the first noise band
@ INTENSITY_BT
Scalefactor data are intensity stereo positions (in phase).
@ INTENSITY_BT2
Scalefactor data are intensity stereo positions (out of phase).
@ RESERVED_BT
Band types following are encoded differently from others.
@ NOISE_BT
Spectral data are scaled white noise not coded in the bitstream.
#define CLIP_AVOIDANCE_FACTOR
#define NOISE_PRE_BITS
length of preamble
#define SCALE_DIFF_ZERO
codebook index corresponding to zero scalefactor indices difference
#define NOISE_OFFSET
subtracted from global gain, used as offset for the preamble
const AACCoefficientsEncoder ff_aac_coders[AAC_CODER_NB]
static void put_bitstream_info(AACEncContext *s, const char *name)
Write some auxiliary information about the created AAC file.
static const AVCodecDefault aac_encode_defaults[]
static void avoid_clipping(AACEncContext *s, SingleChannelElement *sce)
Downscale spectral coefficients for near-clipping windows to avoid artifacts.
static void apply_mid_side_stereo(ChannelElement *cpe)
static void adjust_frame_information(ChannelElement *cpe, int chans)
Produce integer coefficients from scalefactors provided by the model.
static int encode_individual_channel(AVCodecContext *avctx, AACEncContext *s, SingleChannelElement *sce, int common_window)
Encode one channel of audio data.
static av_cold int dsp_init(AVCodecContext *avctx, AACEncContext *s)
static const AVOption aacenc_options[]
static int put_audio_specific_config(AVCodecContext *avctx)
Make AAC audio config object.
static void(*const apply_window[4])(AVFloatDSPContext *fdsp, SingleChannelElement *sce, const float *audio)
static void encode_pulses(AACEncContext *s, Pulse *pulse)
Encode pulse data.
#define WINDOW_FUNC(type)
static const AVClass aacenc_class
static av_cold int aac_encode_end(AVCodecContext *avctx)
static void encode_band_info(AACEncContext *s, SingleChannelElement *sce)
Encode scalefactor band coding type.
static void apply_window_and_mdct(AACEncContext *s, SingleChannelElement *sce, float *audio)
static av_cold int aac_encode_init(AVCodecContext *avctx)
static void apply_intensity_stereo(ChannelElement *cpe)
static void put_pce(PutBitContext *pb, AVCodecContext *avctx)
static void encode_ms_info(PutBitContext *pb, ChannelElement *cpe)
Encode MS data.
static void put_ics_info(AACEncContext *s, IndividualChannelStream *info)
Encode ics_info element.
static void encode_spectral_coeffs(AACEncContext *s, SingleChannelElement *sce)
Encode spectral coefficients processed by psychoacoustic model.
static av_cold int alloc_buffers(AVCodecContext *avctx, AACEncContext *s)
static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
static void copy_input_samples(AACEncContext *s, const AVFrame *frame)
static void encode_scale_factors(AVCodecContext *avctx, AACEncContext *s, SingleChannelElement *sce)
Encode scalefactors.
void ff_quantize_band_cost_cache_init(struct AACEncContext *s)
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....
void ff_aac_dsp_init_x86(AACEncContext *s)
#define WARN_IF(cond,...)
static void quantize_bands(int *out, const float *in, const float *scaled, int size, int is_signed, int maxval, const float Q34, const float rounding)
#define ERROR_IF(cond,...)
static void abs_pow34_v(float *out, const float *in, const int size)
const uint8_t *const ff_aac_swb_size_1024[]
const int ff_aac_swb_size_128_len
const uint8_t *const ff_aac_swb_size_128[]
const int ff_aac_swb_size_1024_len
static const uint8_t aac_chan_maps[AAC_MAX_CHANNELS][AAC_MAX_CHANNELS]
Table to remap channels from libavcodec's default order to AAC order.
static const int64_t aac_normal_chan_layouts[7]
static const uint8_t aac_chan_configs[AAC_MAX_CHANNELS][6]
default channel configurations
static const int aacenc_profiles[]
static const int mpeg4audio_sample_rates[16]
const uint32_t ff_aac_scalefactor_code[121]
const uint8_t ff_tns_max_bands_1024[]
const uint16_t *const ff_swb_offset_128[]
const uint16_t *const ff_swb_offset_1024[]
const uint8_t ff_aac_scalefactor_bits[121]
void ff_aac_tableinit(void)
const uint8_t ff_aac_num_swb_1024[]
const uint8_t ff_aac_num_swb_128[]
const uint8_t ff_tns_max_bands_128[]
float ff_aac_kbd_long_1024[1024]
void ff_aac_float_common_init(void)
float ff_aac_kbd_short_128[128]
static enum AVSampleFormat sample_fmts[]
static const AVCodecDefault defaults[]
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
av_cold void ff_af_queue_init(AVCodecContext *avctx, AudioFrameQueue *afq)
Initialize AudioFrameQueue.
void ff_af_queue_close(AudioFrameQueue *afq)
Close AudioFrameQueue.
void ff_af_queue_remove(AudioFrameQueue *afq, int nb_samples, int64_t *pts, int64_t *duration)
Remove frame(s) from the queue.
int ff_af_queue_add(AudioFrameQueue *afq, const AVFrame *f)
Add a frame to the queue.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
#define FF_PROFILE_UNKNOWN
#define FF_PROFILE_MPEG2_AAC_LOW
#define FF_PROFILE_AAC_MAIN
#define FF_PROFILE_AAC_LOW
#define FF_PROFILE_AAC_LTP
static av_cold int init(AVCodecContext *avctx)
void ff_put_string(PutBitContext *pb, const char *string, int terminate_string)
Put the string string in the bitstream.
static __device__ float fabsf(float a)
static __device__ float fabs(float a)
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
const OptionDef options[]
void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout)
Return a description of a channel layout.
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define AV_CODEC_FLAG_QSCALE
Use fixed qscale.
#define AV_CODEC_CAP_SMALL_LAST_FRAME
Codec can be fed a final frame with a smaller size.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_FLTP
float, planar
#define LIBAVUTIL_VERSION_INT
static const int sizes[][2]
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
#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 FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define FF_ALLOCZ_TYPED_ARRAY(p, nelem)
Replacements for frequently missing libm functions.
av_cold void ff_lpc_end(LPCContext *s)
Uninitialize LPCContext.
av_cold int ff_lpc_init(LPCContext *s, int blocksize, int max_order, enum FFLPCType lpc_type)
Initialize LPCContext.
@ FF_LPC_TYPE_LEVINSON
Levinson-Durbin recursion.
const int avpriv_mpeg4audio_sample_rates[16]
@ AOT_SBR
Y Spectral Band Replication.
#define FF_AAC_PROFILE_OPTS
av_cold struct FFPsyPreprocessContext * ff_psy_preprocess_init(AVCodecContext *avctx)
psychoacoustic model audio preprocessing initialization
av_cold void ff_psy_preprocess_end(struct FFPsyPreprocessContext *ctx)
Cleanup audio preprocessing module.
av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, int num_lens, const uint8_t **bands, const int *num_bands, int num_groups, const uint8_t *group_map)
Initialize psychoacoustic model.
av_cold void ff_psy_end(FFPsyContext *ctx)
Cleanup model context at the end.
void ff_psy_preprocess(struct FFPsyPreprocessContext *ctx, float **audio, int channels)
Preprocess several channel in audio frame in order to compress it better.
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
static int put_bits_count(PutBitContext *s)
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
static void align_put_bits(PutBitContext *s)
Pad the bitstream with zeros up to the next byte boundary.
typedef void(RENAME(mix_any_func_type))
#define FF_ARRAY_ELEMS(a)
int num_ele[4]
front, side, back, lfe
int index[4][8]
front, side, back, lfe
int pairing[3][8]
front, side, back
Describe the class of an AVClass context structure.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
main external API structure.
int global_quality
Global quality for codecs which cannot change it per frame.
int strict_std_compliance
strictly follow the standard (MPEG-4, ...).
int64_t bit_rate
the average bitrate
int initial_padding
Audio only.
int sample_rate
samples per second
int frame_number
Frame counter, set by libavcodec.
int flags
AV_CODEC_FLAG_*.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
int channels
number of audio channels
uint64_t channel_layout
Audio channel layout.
int frame_size
Number of samples per channel in an audio frame.
const char * name
Name of the codec implementation.
This structure describes decoded (raw) audio or video data.
int nb_samples
number of audio samples (per channel) described by this frame
uint8_t ** extended_data
pointers to the data planes/channels.
This structure stores compressed data.
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
channel element - generic struct for SCE/CPE/CCE/LFE
uint8_t is_mask[128]
Set if intensity stereo is used (used by encoder)
int ms_mode
Signals mid/side stereo flags coding mode (used by encoder)
int common_window
Set if channels share a common 'IndividualChannelStream' in bitstream.
uint8_t is_mode
Set if any bands have been encoded using intensity stereo (used by encoder)
uint8_t ms_mask[128]
Set if mid/side stereo is used for each scalefactor window band.
SingleChannelElement ch[2]
windowing related information
int num_windows
number of windows in a frame
int grouping[8]
window grouping (for e.g. AAC)
float clipping[8]
maximum absolute normalized intensity in the given window for clip avoidance
int window_shape
window shape (sine/KBD/whatever)
int window_type[3]
window type (short/long/transitional, etc.) - current, previous and next
Individual Channel Stream.
uint8_t max_sfb
number of scalefactor bands per group
int num_swb
number of scalefactor window bands
uint8_t use_kb_window[2]
If set, use Kaiser-Bessel window, otherwise use a sine window.
uint8_t prediction_used[41]
float clip_avoidance_factor
set if any window is near clipping to the necessary atennuation factor to avoid it
const uint8_t * swb_sizes
table of scalefactor band sizes for a particular window
enum WindowSequence window_sequence[2]
uint8_t window_clipping[8]
set if a certain window is near clipping
const uint16_t * swb_offset
table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular wind...
int8_t used[MAX_LTP_LONG_SFB]
Single Channel Element - used for both SCE and LFE elements.
uint8_t zeroes[128]
band is not coded (used by encoder)
enum BandType band_type[128]
band types
float is_ener[128]
Intensity stereo pos (used by encoder)
INTFLOAT pcoeffs[1024]
coefficients for IMDCT, pristine
INTFLOAT ret_buf[2048]
PCM output buffer.
INTFLOAT coeffs[1024]
coefficients for IMDCT, maybe processed
INTFLOAT ltp_state[3072]
time signal for LTP
AAC_FLOAT lcoeffs[1024]
MDCT of LTP coefficients (used by encoder)
IndividualChannelStream ics
int sf_idx[128]
scalefactor indices (used by encoder)
static av_always_inline int diff(const uint32_t a, const uint32_t b)