Go to the documentation of this file.
37 #define SFB_PER_PRED_BAND 2
42 if (
val < ((1 << nb1) - 1))
46 if (nb3 && (val2 == ((1 << nb2) - 1)))
114 for (
int i = 0;
i <
info->nb_measurements;
i++) {
116 info->measurements[
i].method_val =
134 if (
info->downmix_id != 0 ||
info->drc_set_id != 0)
136 for (
int j = 0; j <
info->nb_measurements; j++) {
137 int method =
info->measurements[j].method_def;
138 if (method == 1 || method == 2)
139 return info->measurements[j].method_val;
168 uint8_t size_bits =
get_bits(gb, 4) + 4;
187 uint8_t header_extra1;
188 uint8_t header_extra2;
216 e->
sbr.
dflt.smoothing_mode = 1;
252 int numBands = ((
int[]){0,28,20,14,10,7,5,4})[e->
mps.
freq_res];
261 int otts_bands_phase = ((
int[]){0,10,10,7,5,3,2,2})[e->
mps.
freq_res];
264 if (otts_bands_phase > numBands)
271 int residual_bands =
get_bits(gb, 5);
272 if (residual_bands > numBands)
290 int base_channel_count =
get_bits(gb, 7);
293 for (
int i = 0;
i < base_channel_count;
i++)
296 return base_channel_count;
302 int target_channel_count;
304 target_channel_count =
get_bits(gb, 7);
307 skip_bits_long(gb, 4 * target_channel_count * base_channel_count);
320 int add_downmix_cnt =
get_bits(gb, 3);
321 for (
int j = 0; j < add_downmix_cnt; j++)
326 if ((set_effects & (3 << 10)) == 0) {
342 int nb_downmix_instr, nb_coeff_basic = 0, nb_instr_basic = 0;
343 int nb_coeff_uni, nb_instr_uni;
344 int base_channel_count;
362 if (nb_coeff_uni || nb_instr_uni) {
364 "AAC USAC uniDrc DRC processing");
370 for (
int i = 0;
i < nb_downmix_instr;
i++)
373 for (
int i = 0;
i < nb_coeff_basic;
i++)
376 for (
int i = 0;
i < nb_instr_basic;
i++)
382 uint8_t size_bits =
get_bits(gb, 4) + 4;
398 int len = 0, ext_config_len;
453 int elem_id[3 ] = { 0, 0, 0 };
486 memset(
us, 0,
sizeof(*
us));
491 for (
int j = 0; j < ch; j++) {
495 memset(
ue, 0,
sizeof(*
ue));
498 ue->noise.seed = 0x3039;
515 uint8_t channel_config_idx;
517 int ratio_mult, ratio_dec;
530 memset(usac, 0,
sizeof(*usac));
534 if (freq_idx == 0x1f) {
556 if (sbr_ratio == 2) {
559 }
else if (sbr_ratio == 3) {
562 }
else if (sbr_ratio == 4) {
572 m4ac->
sample_rate = (samplerate * ratio_dec) / ratio_mult;
575 m4ac->
sbr = sbr_ratio > 0;
577 channel_config_idx =
get_bits(gb, 5);
578 if (!channel_config_idx) {
581 if (nb_channels > 64)
590 for (
int i = 0;
i < nb_channels;
i++) {
607 &nb_elements, channel_config_idx)))
611 for (
int i = 0;
i < nb_elements;
i++)
612 nb_channels += layout_map[
i][0] ==
TYPE_CPE ? 2 : 1;
618 elem_id[0] = elem_id[1] = elem_id[2] = 0;
628 int map_count = elem_id[0] + elem_id[1] + elem_id[2];
630 memset(e, 0,
sizeof(*e));
652 layout_map[map_count][0] =
TYPE_SCE;
653 layout_map[map_count][1] = elem_id[0]++;
664 layout_map[map_count][0] =
TYPE_CPE;
665 layout_map[map_count][1] = elem_id[1]++;
674 layout_map[map_count][0] =
TYPE_LFE;
675 layout_map[map_count][1] = elem_id[2]++;
699 for (
int i = 0;
i < nb_extensions;
i++) {
734 "USAC input loudness: %.2f LKFS (bsMethodValue=%d)\n",
752 int offset_sf = global_gain;
754 for (
int sfb = 0; sfb < ics->
max_sfb; sfb++) {
757 if (offset_sf > 255
U) {
759 "Scalefactor (%d) out of range.\n", offset_sf);
780 int reset, uint16_t
len, uint16_t
N)
802 for (
i = 0;
i <
len/2;
i++) {
806 for (lvl=esc_nb=0;;) {
818 if ((esc_nb = lvl) > 7)
833 for (
int l = lvl; l > 0; l--) {
834 int lsbidx = !
a ? 1 : (!
b ? 0 : 2);
837 a = (
a << 1) | (
r & 1);
838 b = (
b << 1) | ((
r >> 1) & 1);
850 skip_bits(gb, gb_count2 - gb_count - 14);
857 for (;
i <
N/2;
i++) {
863 for (
i = 0;
i <
len;
i++) {
875 int num_window_groups,
876 int prev_num_window_groups,
883 for (
int g = 0;
g < num_window_groups;
g++) {
892 for (
int g = 0;
g < num_window_groups;
g++)
900 us->use_prev_frame = 0;
901 if (
us->complex_coef && !indep_flag)
909 for (
int g = 0;
g < num_window_groups;
g++) {
911 float last_alpha_q_re = 0;
912 float last_alpha_q_im = 0;
913 if (delta_code_time) {
924 const int wg = prev_num_window_groups - 1;
925 last_alpha_q_re =
us->prev_alpha_q_re[wg*cpe->
max_sfb_ste + sfb];
926 last_alpha_q_im =
us->prev_alpha_q_im[wg*cpe->
max_sfb_ste + sfb];
940 last_alpha_q_re +=
val * 0.1f;
941 if (
us->complex_coef) {
943 last_alpha_q_im +=
val * 0.1f;
985 for (
int j = 0; j < 7; j++) {
987 if (
ue->scale_factor_grouping & (1 << (6 - j)))
1013 "Number of scalefactor bands in group (%d) "
1014 "exceeds limit (%d).\n",
1031 int ret, tns_active;
1041 us->common_window = 0;
1046 memset(
us->alpha_q_re, 0,
sizeof(
us->alpha_q_re));
1047 memset(
us->alpha_q_im, 0,
sizeof(
us->alpha_q_im));
1055 if (!
us->common_window || indep_flag) {
1056 memset(
us->prev_alpha_q_re, 0,
sizeof(
us->prev_alpha_q_re));
1057 memset(
us->prev_alpha_q_im, 0,
sizeof(
us->prev_alpha_q_im));
1060 if (
us->common_window) {
1080 memset(
us->prev_alpha_q_re, 0,
sizeof(
us->prev_alpha_q_re));
1081 memset(
us->prev_alpha_q_im, 0,
sizeof(
us->prev_alpha_q_im));
1112 if (
us->ms_mask_mode == 1) {
1116 }
else if (
us->ms_mask_mode == 2) {
1131 "AAC USAC timewarping");
1139 if (
us->common_window)
1147 memcpy(&sce2->
tns, &sce1->
tns,
sizeof(sce1->
tns));
1171 unsigned int new_seed = *
seed = ((*seed) * 69069) + 5;
1172 if (((new_seed) & 0x10000) > 0)
1183 float noise_val =
powf(2, ((
float)
ue->noise.level - 14.0f)/3.0f);
1184 int noise_offset =
ue->noise.offset - 16;
1194 for (
int sfb = 0; sfb < ics->
max_sfb; sfb++) {
1197 int band_quantized_to_zero = 1;
1202 for (
int group = 0; group < (unsigned)g_len; group++,
cb += 128) {
1203 for (
int z = 0; z < cb_len; z++) {
1207 band_quantized_to_zero = 0;
1211 if (band_quantized_to_zero) {
1226 if (
ue->noise.level)
1237 for (
int sfb = 0; sfb < ics->
max_sfb; sfb++) {
1240 float sf = sce->sf[
g*ics->
max_sfb + sfb];
1242 for (
int group = 0; group < (unsigned)g_len; group++,
cb += 128)
1259 for (
int sfb = 0; sfb < cpe->
max_sfb_ste; sfb++) {
1263 float *
c1 = coef1 + off;
1264 float *
c2 = coef2 + off;
1265 float *dm = dmix_re + off;
1267 for (
int group = 0; group < (unsigned)g_len;
1268 group++,
c1 += 128,
c2 += 128, dm += 128) {
1269 for (
int z = 0; z < cb_len; z++)
1270 dm[z] = 0.5*(
c1[z] + sign*
c2[z]);
1274 coef1 += g_len << 7;
1275 coef2 += g_len << 7;
1276 dmix_re += g_len << 7;
1291 for (
int sfb = 0; sfb < cpe->
max_sfb_ste; sfb++) {
1295 float *
c1 = coef1 + off;
1296 float *
c2 = coef2 + off;
1297 float *dm = dmix_re + off;
1300 for (
int group = 0; group < (unsigned)g_len;
1301 group++,
c1 += 128,
c2 += 128, dm += 128) {
1302 for (
int z = 0; z < cb_len; z++)
1303 dm[z] = 0.5*(
c1[z] + sign*
c2[z]);
1306 for (
int group = 0; group < (unsigned)g_len;
1307 group++,
c1 += 128,
c2 += 128, dm += 128) {
1308 for (
int z = 0; z < cb_len; z++)
1314 coef1 += g_len << 7;
1315 coef2 += g_len << 7;
1316 dmix_re += g_len << 7;
1321 int len,
int factor_even,
int factor_odd)
1326 s =
f[6]*re[2] +
f[5]*re[1] +
f[4]*re[0] +
1328 f[2]*re[1] +
f[1]*re[2] +
f[0]*re[3];
1329 im[
i] +=
s*factor_even;
1332 s =
f[6]*re[1] +
f[5]*re[0] +
f[4]*re[0] +
1334 f[2]*re[2] +
f[1]*re[3] +
f[0]*re[4];
1335 im[
i] +=
s*factor_odd;
1338 s =
f[6]*re[0] +
f[5]*re[0] +
f[4]*re[1] +
1340 f[2]*re[3] +
f[1]*re[4] +
f[0]*re[5];
1342 im[
i] +=
s*factor_even;
1343 for (
i = 3;
i <
len - 4;
i += 2) {
1344 s =
f[6]*re[
i-3] +
f[5]*re[
i-2] +
f[4]*re[
i-1] +
1346 f[2]*re[
i+1] +
f[1]*re[
i+2] +
f[0]*re[
i+3];
1347 im[
i+0] +=
s*factor_odd;
1349 s =
f[6]*re[
i-2] +
f[5]*re[
i-1] +
f[4]*re[
i] +
1351 f[2]*re[
i+2] +
f[1]*re[
i+3] +
f[0]*re[
i+4];
1352 im[
i+1] +=
s*factor_even;
1356 s =
f[6]*re[
i-3] +
f[5]*re[
i-2] +
f[4]*re[
i-1] +
1358 f[2]*re[
i+1] +
f[1]*re[
i+2] +
f[0]*re[
i+2];
1359 im[
i] +=
s*factor_odd;
1362 s =
f[6]*re[
i-3] +
f[5]*re[
i-2] +
f[4]*re[
i-1] +
1364 f[2]*re[
i+1] +
f[1]*re[
i+1] +
f[0]*re[
i];
1365 im[
i] +=
s*factor_even;
1368 s =
f[6]*re[
i-3] +
f[5]*re[
i-2] +
f[4]*re[
i-1] +
1370 f[2]*re[
i] +
f[1]*re[
i-1] +
f[0]*re[
i-2];
1371 im[
i] +=
s*factor_odd;
1380 float *dmix_im =
us->dmix_im;
1384 for (
int sfb = 0; sfb < cpe->
max_sfb_ste; sfb++) {
1388 float *
c1 = coef1 + off;
1389 float *
c2 = coef2 + off;
1390 float *dm_im = dmix_im + off;
1398 for (
int group = 0; group < (unsigned)g_len;
1399 group++,
c1 += 128,
c2 += 128, dm_im += 128) {
1400 for (
int z = 0; z < cb_len; z++) {
1402 side =
c2[z] - alpha_re*
c1[z] - alpha_im*dm_im[z];
1403 c2[z] =
c1[z] - side;
1404 c1[z] =
c1[z] + side;
1408 for (
int group = 0; group < (unsigned)g_len;
1409 group++,
c1 += 128,
c2 += 128, dm_im += 128) {
1410 for (
int z = 0; z < cb_len; z++) {
1412 mid =
c2[z] - alpha_re*
c1[z] - alpha_im*dm_im[z];
1413 c2[z] = mid -
c1[z];
1414 c1[z] = mid +
c1[z];
1420 coef1 += g_len << 7;
1421 coef2 += g_len << 7;
1422 dmix_im += g_len << 7;
1471 for (
int ch = 0; ch < nb_channels; ch++) {
1479 if (nb_channels > 1 &&
us->common_window) {
1480 for (
int ch = 0; ch < nb_channels; ch++) {
1488 if (
us->ms_mask_mode == 3) {
1496 if (
us->use_prev_frame) {
1503 }
else if (
us->ms_mask_mode > 0) {
1509 if (nb_channels > 1) {
1511 for (
int ch = 0; ch < nb_channels; ch++) {
1513 memcpy(sce->prev_coeffs, sce->
coeffs,
sizeof(sce->
coeffs));
1515 memcpy(us2->prev_alpha_q_re, us2->alpha_q_re,
sizeof(us2->alpha_q_re));
1516 memcpy(us2->prev_alpha_q_im, us2->alpha_q_im,
sizeof(us2->alpha_q_im));
1519 for (
int ch = 0; ch < nb_channels; ch++) {
1523 if (sce->
tns.
present && ((nb_channels == 1) || (
us->tns_on_lr)))
1533 255 , 28, 20, 14, 10, 7, 5, 4,
1541 int nb_tr_slots,
int nb_slots)
1543 int nb_bits =
av_log2(nb_slots / (nb_tr_slots + 1));
1545 for (
int k = 0; k < nb_slots; k++)
1548 int p = nb_tr_slots + 1;
1549 for (
int k = nb_slots - 1; k >= 0; k--) {
1556 for (
int h = 2;
h <=
p &&
c <=
s;
h++) {
1590 int indep = frame_indep_flag;
1591 if (!frame_indep_flag)
1595 (nb_time_slots - 1);
1646 int nb_data_bands = (nb_bands - 1);
1648 for (
int j = 0; j < nb_data_bands; j++)
1661 for (
int i = 0;
i < 2;
i++)
1667 "Error parsing TSD reshape data!\n");
1679 for (
int i = 0;
i < nb_time_slots;
i++) {
1694 int arith_reset_flag;
1696 int core_nb_channels = nb_channels;
1699 uint8_t global_gain;
1701 us->common_window = 0;
1703 for (
int ch = 0; ch < core_nb_channels; ch++) {
1708 ue->tns_data_present = 0;
1714 core_nb_channels = 1;
1716 if (core_nb_channels == 2) {
1722 for (
int ch = 0; ch < core_nb_channels; ch++) {
1727 if (
ue->core_mode) {
1734 if ((core_nb_channels == 1) ||
1741 ue->noise.level = 0;
1747 if (!
us->common_window) {
1770 "AAC USAC timewarping");
1779 if (
ue->tns_data_present) {
1787 arith_reset_flag = indep_flag;
1788 if (!arith_reset_flag)
1792 memset(&sce->
coeffs[0], 0, 1024*
sizeof(
float));
1802 arith_reset_flag && (
win == 0), lg,
N);
1819 int sbr_ch = nb_channels;
1820 if (nb_channels == 2 &&
1853 uint8_t temp_data[512];
1854 uint8_t *tmp_buf = temp_data;
1855 size_t tmp_buf_size =
sizeof(temp_data);
1858 int num_preroll_frames;
1876 if (!memcmp(m4ac, &m4ac_bak,
sizeof(m4ac_bak)))
1885 for (
int i = 0;
i < num_preroll_frames;
i++) {
1886 int got_frame_ptr = 0;
1889 if (au_len*8 > tmp_buf_size) {
1891 tmp_buf = tmp_buf == temp_data ?
NULL : tmp_buf;
1894 if (tmp_buf != temp_data)
1902 for (
int j = 0; j < au_len; j++)
1914 if (tmp_buf != temp_data)
1923 uint8_t pl_frag_start = 1;
1924 uint8_t pl_frag_end = 1;
1951 if (!(pl_frag_start && pl_frag_end)) {
1967 for (
int i = 0;
i <
len;
i++)
1979 if (!(pl_frag_start && pl_frag_end)) {
2015 int ret, is_dmono = 0;
2017 int audio_found = 0;
2018 int elem_id[3 ] = { 0, 0, 0 };
2021 int ratio_mult, ratio_dec;
2028 if (sbr_ratio == 2) {
2031 }
else if (sbr_ratio == 3) {
2034 }
else if (sbr_ratio == 4) {
2056 layout_id = elem_id[0]++;
2060 layout_id = elem_id[1]++;
2064 layout_id = elem_id[2]++;
2071 "channel element %d.%d is not allocated\n",
2072 layout_type, layout_id);
2110 if (ac->
oc[1].
status && audio_found) {
2134 if (method_val < 0) {
2137 "target_level set but no program/anchor loudness "
2138 "measurement available; normalization skipped\n");
2143 float input_loudness = -57.75f + 0.25f * method_val;
2145 float gain =
powf(10.0
f, gain_dB / 20.0
f);
2147 for (
int ch = 0; ch <
frame->ch_layout.nb_channels; ch++)
2149 (
float *)
frame->extended_data[ch],
2150 gain,
frame->nb_samples);
2155 is_dmono = ac->
dmono_mode && elem_id[0] == 2 &&
uint8_t stereo_config_index
int frame_size
Number of samples per channel in an audio frame.
const uint8_t ff_usac_noise_fill_start_offset[2][2]
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
int input_method_val
Raw bsMethodValue (μ) of the program/anchor-loudness measurement selected for normalization at config...
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
static int decode_usac_stereo_info(AACDecContext *ac, AACUSACConfig *usac, AACUsacElemConfig *ec, ChannelElement *cpe, GetBitContext *gb, int indep_flag)
#define AV_CHANNEL_LAYOUT_STEREO
int sample_rate
samples per second
uint16_t stream_identifier
static double cb(void *priv, double x, double y)
static void spectrum_decode(AACDecContext *ac, AACUSACConfig *usac, ChannelElement *cpe, int nb_channels)
int16_t temp_shape_data[MPS_MAX_TIME_SLOTS]
int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx, GetBitContext *gb, OutputConfiguration *oc, int channel_config)
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
const uint16_t ff_aac_ac_lsb_cdfs[3][4]
static int get_bits_count(const GetBitContext *s)
AVChannelCustom * map
This member must be used when the channel order is AV_CHANNEL_ORDER_CUSTOM.
This structure describes decoded (raw) audio or video data.
@ AV_CHAN_TOP_SURROUND_LEFT
+110 degrees, Lvs, TpLS
static const uint8_t mps_fr_stride_smg[4]
static void complex_stereo_downmix_cur(AACDecContext *ac, ChannelElement *cpe, float *dmix_re)
#define ue(name, range_min, range_max)
#define AV_LOG_VERBOSE
Detailed information.
uint8_t scale_factor_grouping
void(* apply_tns)(void *_coef_param, TemporalNoiseShaping *tns, IndividualChannelStream *ics, int decode)
SingleChannelElement ch[2]
static int ff_aac_sample_rate_idx(int rate)
struct AACUsacElemConfig::@29::@33 dflt
const uint16_t *const ff_swb_offset_128[]
@ ID_CONFIG_EXT_STREAM_ID
static float win(SuperEqualizerContext *s, float n, int N)
int dmono_mode
0->not dmono, 1->use first channel, 2->use second channel
static void skip_bits(GetBitContext *s, int n)
int num_swb
number of scalefactor window bands
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
@ AV_CHAN_SURROUND_DIRECT_LEFT
float coeffs[1024]
coefficients for IMDCT, maybe processed
struct AACUsacElemConfig::@31 ext
AVChannelLayout ch_layout
Audio channel layout.
static int parse_ext_ele(AACDecContext *ac, AACUsacElemConfig *e, GetBitContext *gb)
@ ID_EXT_ELE_AUDIOPREROLL
struct AACUSACConfig::@35 loudness
#define SFB_PER_PRED_BAND
static int decode_spectrum_ac(AACDecContext *s, float coef[1024], GetBitContext *gb, AACArithState *state, int reset, uint16_t len, uint16_t N)
Decode and dequantize arithmetically coded, uniformly quantized value.
static double val(void *priv, double ch)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
IndividualChannelStream ics
int smooth_time[MPS_MAX_PARAM_SETS]
int ff_aac_ec_data_dec(GetBitContext *gb, AACMPSLosslessData *ld, enum AACMPSDataType data_type, int default_val, int start_band, int end_band, int frame_indep_flag, int indep_flag, int nb_param_sets)
union AVChannelLayout::@518 u
Details about which channels are present in this layout.
int param_sets[MPS_MAX_PARAM_SETS]
static void complex_stereo_interpolate_imag(float *im, float *re, const float f[7], int len, int factor_even, int factor_odd)
@ AV_CHAN_BOTTOM_FRONT_LEFT
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
void(* dequant_scalefactors)(SingleChannelElement *sce)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
@ OC_GLOBAL_HDR
Output configuration set in a global header but not yet locked.
static int parse_mps212(AACDecContext *ac, AACUSACConfig *usac, AACUsacMPSData *mps, AACUsacElemConfig *ec, GetBitContext *gb, int frame_indep_flag)
void(* apply_mid_side_stereo)(AACDecContext *ac, ChannelElement *cpe)
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
An AVChannelCustom defines a single channel within a custom order layout.
void ff_aac_ac_finish(AACArithState *state, int offset, int N)
struct AACUsacElemConfig::@30 mps
static int decode_usac_scale_factors(AACDecContext *ac, SingleChannelElement *sce, GetBitContext *gb, uint8_t global_gain)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static void decode_tsd(GetBitContext *gb, int *data, int nb_tr_slots, int nb_slots)
static void * av_refstruct_alloc_ext(size_t size, unsigned flags, void *opaque, void(*free_cb)(AVRefStructOpaque opaque, void *obj))
A wrapper around av_refstruct_alloc_ext_c() for the common case of a non-const qualified opaque.
ChannelElement * ff_aac_get_che(AACDecContext *ac, int type, int elem_id)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static void decode_drc_instructions_basic(AACUsacElemConfig *e, GetBitContext *gb)
uint8_t core_sbr_frame_len_idx
Individual Channel Stream.
#define SCALE_DIFF_ZERO
codebook index corresponding to zero scalefactor indices difference
const uint8_t ff_tns_max_bands_usac_1024[]
int ff_aac_usac_decode_frame(AVCodecContext *avctx, AACDecContext *ac, GetBitContext *gb, int *got_frame_ptr)
void ff_aac_ac_init(AACArith *ac, GetBitContext *gb)
static int decode_loudness_info(AACDecContext *ac, AACUSACLoudnessInfo *info, GetBitContext *gb)
@ AV_CHAN_SIDE_SURROUND_LEFT
+90 degrees, Lss, SiL
void(* sbr_apply)(AACDecContext *ac, ChannelElement *che, int id_aac, int fl960, void *L, void *R)
static int decode_drc_channel_layout(GetBitContext *gb)
int ff_aac_ldp_parse_channel_stream(AACDecContext *ac, AACUSACConfig *usac, AACUsacElemData *ce, GetBitContext *gb)
int target_level
Target output loudness in dBFS, used for xHE-AAC loudness normalization based on the parsed loudnessI...
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
AACMPSLosslessData ott[MPS_ELE_NB]
void(* vector_fmul_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float.
uint8_t use_kb_window[2]
If set, use Kaiser-Bessel window, otherwise use a sine window.
const uint8_t ff_aac_num_swb_128[]
const uint8_t ff_tns_max_bands_usac_128[]
#define AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL
The specified retype target order is ignored and the simplest possible (canonical) order is used for ...
@ AV_CHAN_TOP_BACK_CENTER
#define AV_REFSTRUCT_FLAG_NO_ZEROING
If this flag is set in av_refstruct_alloc_ext_c(), the object will not be initially zeroed.
static unsigned int get_bits1(GetBitContext *s)
uint8_t ms_mask[128]
Set if mid/side stereo is used for each scalefactor window band.
static const uint8_t mps_fr_nb_bands[8]
static int parse_audio_preroll(AACDecContext *ac, GetBitContext *gb)
static uint32_t get_escaped_value(GetBitContext *gb, int nb1, int nb2, int nb3)
@ AV_CHAN_BOTTOM_FRONT_RIGHT
uint8_t temp_shape_config
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
static int decode_usac_stereo_cplx(AACDecContext *ac, AACUsacStereo *us, ChannelElement *cpe, GetBitContext *gb, int num_window_groups, int prev_num_window_groups, int indep_flag)
uint16_t ff_aac_ac_decode(AACArith *ac, GetBitContext *gb, const uint16_t *cdf, uint16_t cdf_len)
static void spectrum_scale(AACDecContext *ac, SingleChannelElement *sce, AACUsacElemData *ue)
@ OC_LOCKED
Output configuration locked in place.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
@ AV_CHAN_FRONT_RIGHT_OF_CENTER
int prev_num_window_groups
Previous frame's number of window groups.
AACUsacElemData ue
USAC element data.
uint8_t layout_map[MAX_ELEM_ID *4][3]
bool smg_data[MPS_MAX_PARAM_SETS][MPS_MAX_PARAM_BANDS]
struct AACUsacElemConfig::@29 sbr
enum WindowSequence window_sequence[2]
int ott_idx[MPS_ELE_NB][MPS_MAX_PARAM_SETS][MPS_MAX_PARAM_BANDS]
const uint16_t *const ff_swb_offset_1024[]
uint8_t otts_bands_phase_present
An AVChannelLayout holds information about the channel layout of audio data.
#define i(width, name, range_min, range_max)
void(* imdct_and_windowing)(AACDecContext *ac, SingleChannelElement *sce)
uint8_t max_sfb_ste
(USAC) Maximum of both max_sfb values
@ ESC_BT
Spectral data are coded with an escape sequence.
int sfo[128]
scalefactor offsets
int warned_loudness_missing
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
const float ff_aac_usac_mdst_filt_cur[4][4][7]
int freq_res_stride_smg[MPS_MAX_PARAM_SETS]
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
int av_channel_layout_retype(AVChannelLayout *channel_layout, enum AVChannelOrder order, int flags)
Change the AVChannelOrder of a channel layout.
@ AV_CHAN_TOP_FRONT_RIGHT
@ AV_CHANNEL_ORDER_NATIVE
The native channel order, i.e.
static void skip_bits1(GetBitContext *s)
uint32_t ff_aac_ac_get_context(AACArithState *state, uint32_t c, int i, int N)
@ AV_CHAN_FRONT_LEFT_OF_CENTER
struct AACUsacElemData::@20 noise
enum BandType band_type[128]
band types
@ ID_CONFIG_EXT_LOUDNESS_INFO
float * output
PCM output.
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
uint32_t ff_aac_ac_get_pk(uint32_t c)
int av_channel_layout_custom_init(AVChannelLayout *channel_layout, int nb_channels)
Initialize a custom channel layout with the specified number of channels.
void av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
static void apply_noise_fill(AACDecContext *ac, SingleChannelElement *sce, AACUsacElemData *ue)
@ AV_CHAN_TOP_SURROUND_RIGHT
-110 degrees, Rvs, TpRS
@ AV_CHAN_SURROUND_DIRECT_RIGHT
Single Channel Element - used for both SCE and LFE elements.
const uint16_t *const ff_swb_offset_768[]
static int decode_usac_element_pair(AACDecContext *ac, AACUsacElemConfig *e, GetBitContext *gb)
struct AACUsacElemConfig::@32 drc
static enum AVChannel usac_ch_pos_to_av[64]
channel element - generic struct for SCE/CPE/CCE/LFE
const uint16_t * swb_offset
table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular wind...
static int decode_drc_config(AACDecContext *ac, AACUsacElemConfig *e, GetBitContext *gb)
int ff_aac_parse_fac_data(AACUsacElemData *ce, GetBitContext *gb, int use_gain, int len)
const int ff_aac_usac_samplerate[32]
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
static const float * complex_stereo_get_filter(ChannelElement *cpe, int is_prev)
void ff_aac_ac_update_context(AACArithState *state, int idx, uint16_t a, uint16_t b)
static const int8_t filt[NUMTAPS *2]
static void complex_stereo_downmix_prev(AACDecContext *ac, ChannelElement *cpe, float *dmix_re)
OutputConfiguration oc[2]
const uint8_t ff_aac_num_swb_96[]
uint32_t ff_aac_ac_map_process(AACArithState *state, int reset, int N)
static int decode_usac_sbr_data(AACDecContext *ac, AACUsacElemConfig *e, GetBitContext *gb)
const uint8_t ff_aac_num_swb_1024[]
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
static void decode_usac_element_core(AACUsacElemConfig *e, GetBitContext *gb, int sbr_ratio)
int smooth_mode[MPS_MAX_PARAM_SETS]
main AAC decoding context
AACUSACLoudnessInfo info[64]
main external API structure.
bool temp_shape_enable_ch[2]
struct AACUsacElemConfig::@32::@34 loudness
@ AV_CHAN_LOW_FREQUENCY_2
struct AVCodecContext * avctx
static float noise_random_sign(unsigned int *seed)
static void apply_complex_stereo(AACDecContext *ac, ChannelElement *cpe)
static int setup_sce(AACDecContext *ac, SingleChannelElement *sce, AACUSACConfig *usac)
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
int sbr
-1 implicit, 1 presence
Filter the word “frame” indicates either a video frame or a group of audio samples
int ff_aac_decode_tns(AACDecContext *ac, TemporalNoiseShaping *tns, GetBitContext *gb, const IndividualChannelStream *ics)
Decode Temporal Noise Shaping data; reference: table 4.48.
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
int ff_aac_usac_reset_state(AACDecContext *ac, OutputConfiguration *oc)
@ AV_CHAN_BOTTOM_FRONT_CENTER
static int decode_loudness_set(AACDecContext *ac, AACUSACConfig *usac, GetBitContext *gb)
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
int ff_aac_map_index_data(AACMPSLosslessData *ld, enum AACMPSDataType data_type, int dst_idx[MPS_MAX_PARAM_SETS][MPS_MAX_PARAM_BANDS], int default_value, int start_band, int stop_band, int nb_param_sets, const int *param_set_idx, int extend_frame)
@ AV_CHAN_TOP_FRONT_CENTER
AACUsacElemConfig elems[MAX_ELEM_ID]
#define us(width, name, range_min, range_max, subs,...)
static void skip_drc_downmix_instructions(GetBitContext *gb, int base_channel_count)
@ AV_CHAN_SIDE_SURROUND_RIGHT
-90 degrees, Rss, SiR
AVChannelLayout ch_layout
int ff_aac_sbr_decode_usac_data(AACDecContext *ac, ChannelElement *che, AACUsacElemConfig *ue, GetBitContext *gb, int sbr_ch, int indep_flag)
Decode frame SBR data, USAC.
static int decode_usac_core_coder(AACDecContext *ac, AACUSACConfig *usac, AACUsacElemConfig *ec, ChannelElement *che, GetBitContext *gb, int indep_flag, int nb_channels)
void(* imdct_and_windowing_768)(AACDecContext *ac, SingleChannelElement *sce)
const uint16_t ff_aac_ac_msb_cdfs[64][17]
VLCElem ff_vlc_scalefactors[352]
uint8_t max_sfb
number of scalefactor bands per group
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int ff_aac_set_default_channel_config(AACDecContext *ac, AVCodecContext *avctx, uint8_t(*layout_map)[3], int *tags, int channel_config)
Set up channel positions based on a default channel configuration as specified in table 1....
int ff_aac_huff_dec_reshape(GetBitContext *gb, int16_t *out_data, int nb_val)
int ff_aac_sbr_config_usac(AACDecContext *ac, ChannelElement *che, AACUsacElemConfig *ue)
Due to channel allocation not being known upon SBR parameter transmission, supply the parameters sepa...
const uint8_t ff_aac_num_swb_768[]
#define AV_PROFILE_AAC_USAC
static int select_loudness_measurement(const AACUSACConfig *usac)
static void BS_FUNC() skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
static int methodvalue_width(int method_def)
int ff_aac_output_configure(AACDecContext *ac, uint8_t layout_map[MAX_ELEM_ID *4][3], int tags, enum OCStatus oc_type, int get_new_frame)
Configure output channel order based on the current program configuration element.
AACUSACLoudnessInfo album_info[64]
const uint16_t *const ff_swb_offset_96[]
static int decode_usac_extension(AACDecContext *ac, AACUsacElemConfig *e, GetBitContext *gb)