40 for (n = 1; n < 320; n++)
45 for (n = 0; n < 320; n++)
52 const void *sbr_codes, *sbr_bits;
53 const unsigned int table_size, elem_size;
98 if(sbr->mdct.mdct_bits)
100 sbr->kx[0] = sbr->kx[1];
101 sbr->id_aac = id_aac;
123 return *(
const int16_t *)a - *(
const int16_t *)
b;
129 for (i = 0; i <= last_el; i++)
130 if (table[i] == needle)
140 static const INTFLOAT bands_warped[3] = {
Q23(1.32715174233856803909
f),
141 Q23(1.18509277094158210129
f),
142 Q23(1.11987160404675912501
f) };
144 int16_t patch_borders[7];
147 patch_borders[0] = sbr->
kx[1];
154 memcpy(sbr->
f_tablelim + sbr->
n[0] + 1, patch_borders + 1,
155 (sbr->
num_patches - 1) *
sizeof(patch_borders[0]));
162 while (out < sbr->f_tablelim + sbr->
n_lim) {
164 if ((*in << 23) >= *
out * lim_bands_per_octave_warped) {
166 if (*in >= *
out * lim_bands_per_octave_warped) {
169 }
else if (*in == *
out ||
210 if (bs_header_extra_1) {
224 if (bs_header_extra_2) {
244 int i,
min = array[0];
245 for (i = 1; i < nel; i++)
246 min =
FFMIN(array[i], min);
257 if (bs_xover_band >= n_master) {
259 "Invalid bitstream, crossover band index beyond array bounds: %d\n",
270 unsigned int temp, max_qmf_subbands = 0;
271 unsigned int start_min, stop_min;
273 const int8_t *sbr_offset_ptr;
289 case 44100:
case 48000:
case 64000:
292 case 88200:
case 96000:
case 128000:
case 176400:
case 192000:
297 "Unsupported sample rate for SBR: %d\n", sbr->
sample_rate);
314 sbr->
k[2] = stop_min;
318 sbr->
k[2] += stop_dk[k];
320 sbr->
k[2] = 2*sbr->
k[0];
322 sbr->
k[2] = 3*sbr->
k[0];
328 sbr->
k[2] =
FFMIN(64, sbr->
k[2]);
332 max_qmf_subbands = 48;
334 max_qmf_subbands = 35;
336 max_qmf_subbands = 32;
340 if (sbr->
k[2] - sbr->
k[0] > max_qmf_subbands) {
342 "Invalid bitstream, too many QMF subbands: %d\n", sbr->
k[2] - sbr->
k[0]);
350 sbr->
n_master = ((sbr->
k[2] - sbr->
k[0] + (dk&2)) >> dk) << 1;
354 for (k = 1; k <= sbr->
n_master; k++)
357 k2diff = sbr->
k[2] - sbr->
k[0] - sbr->
n_master * dk;
366 for (k = 1; k <= sbr->
n_master; k++)
371 int two_regions, num_bands_0;
372 int vdk0_max, vdk1_min;
378 if (49 * sbr->
k[2] > 110 * sbr->
k[0]) {
380 sbr->
k[1] = 2 * sbr->
k[0];
383 sbr->
k[1] = sbr->
k[2];
387 tmp = (sbr->
k[1] << 23) / sbr->
k[0];
388 while (tmp < 0x40000000) {
394 tmp = (((tmp + 0x80) >> 8) + ((8 - nz) << 23)) * half_bands;
395 num_bands_0 = ((tmp + 0x400000) >> 23) * 2;
397 num_bands_0 =
lrintf(half_bands *
log2f(sbr->
k[1] / (
float)sbr->
k[0])) * 2;
400 if (num_bands_0 <= 0) {
410 vdk0_max = vk0[num_bands_0];
413 for (k = 1; k <= num_bands_0; k++) {
426 tmp = (sbr->
k[2] << 23) / sbr->
k[1];
428 while (tmp < 0x40000000) {
434 tmp = (((tmp + 0x80) >> 8) + ((8 - nz) << 23)) * half_bands;
437 num_bands_1 = ((tmp + 0x400000) >> 23) * 2;
439 float invwarp = spectrum->
bs_alter_scale ? 0.76923076923076923077f
441 int num_bands_1 =
lrintf(half_bands * invwarp *
442 log2f(sbr->
k[2] / (
float)sbr->
k[1])) * 2;
448 if (vdk1_min < vdk0_max) {
451 change =
FFMIN(vdk0_max - vk1[1], (vk1[num_bands_1] - vk1[1]) >> 1);
453 vk1[num_bands_1] -= change;
459 for (k = 1; k <= num_bands_1; k++) {
467 sbr->
n_master = num_bands_0 + num_bands_1;
471 (num_bands_0 + 1) *
sizeof(sbr->
f_master[0]));
472 memcpy(&sbr->
f_master[num_bands_0 + 1], vk1 + 1,
473 num_bands_1 *
sizeof(sbr->
f_master[0]));
489 int i, k, last_k = -1, last_msb = -1, sb = 0;
491 int usb = sbr->
kx[1];
496 if (goal_sb < sbr->kx[1] + sbr->
m[1]) {
497 for (k = 0; sbr->
f_master[k] < goal_sb; k++) ;
503 if (k == last_k && msb == last_msb) {
509 for (i = k; i == k || sb > (sbr->
k[0] - 1 + msb - odd); i--) {
511 odd = (sb + sbr->
k[0]) & 1;
535 }
while (sb != sbr->
kx[1] + sbr->
m[1]);
553 sbr->
n[0] = (sbr->
n[1] + 1) >> 1;
556 (sbr->
n[1] + 1) *
sizeof(sbr->
f_master[0]));
561 if (sbr->
kx[1] + sbr->
m[1] > 64) {
563 "Stop frequency border too high: %d\n", sbr->
kx[1] + sbr->
m[1]);
566 if (sbr->
kx[1] > 32) {
572 temp = sbr->
n[1] & 1;
573 for (k = 1; k <= sbr->
n[0]; k++)
576 temp = (sbr->
k[2] << 23) / sbr->
kx[1];
577 while (temp < 0x40000000) {
585 sbr->
n_q = (temp + 0x400000) >> 23;
590 log2f(sbr->
k[2] / (
float)sbr->
kx[1])));
600 for (k = 1; k <= sbr->
n_q; k++) {
601 temp += (sbr->
n[0] -
temp) / (sbr->
n_q + 1 - k);
636 int abs_bord_trail = 16;
637 int num_rel_lead, num_rel_trail;
638 unsigned bs_num_env_old = ch_data->
bs_num_env;
639 int bs_frame_class, bs_num_env;
645 switch (bs_frame_class =
get_bits(gb, 2)) {
648 if (bs_num_env > 4) {
650 "Invalid bitstream, too many SBR envelopes in FIXFIX type SBR frame: %d\n",
660 ch_data->
t_env[0] = 0;
663 abs_bord_trail = (abs_bord_trail + (ch_data->
bs_num_env >> 1)) /
665 for (i = 0; i < num_rel_lead; i++)
666 ch_data->
t_env[i + 1] = ch_data->
t_env[i] + abs_bord_trail;
676 ch_data->
t_env[0] = 0;
679 for (i = 0; i < num_rel_trail; i++)
694 for (i = 0; i < num_rel_lead; i++)
706 bs_num_env = num_rel_lead + num_rel_trail + 1;
708 if (bs_num_env > 5) {
710 "Invalid bitstream, too many SBR envelopes in VARVAR type SBR frame: %d\n",
718 for (i = 0; i < num_rel_lead; i++)
720 for (i = 0; i < num_rel_trail; i++)
734 "Invalid bitstream, bs_pointer points to a middle noise border outside the time borders table: %d\n",
740 if (ch_data->
t_env[i-1] >= ch_data->
t_env[i]) {
748 ch_data->
t_q[0] = ch_data->
t_env[0];
759 else if (bs_pointer == 1)
762 idx = bs_pointer - 1;
764 ch_data->
t_q[1] = ch_data->
t_env[idx];
767 ch_data->
e_a[0] = -(ch_data->
e_a[1] != bs_num_env_old);
768 ch_data->
e_a[1] = -1;
772 ch_data->
e_a[1] = bs_pointer - 1;
786 memcpy(dst->
t_q, src->
t_q,
sizeof(dst->
t_q));
791 dst->
e_a[1] = src->
e_a[1];
809 for (i = 0; i < sbr->
n_q; i++)
818 VLC_TYPE (*t_huff)[2], (*f_huff)[2];
821 const int odd = sbr->
n[1] & 1;
857 for (j = 0; j < sbr->
n[ch_data->
bs_freq_res[i + 1]]; j++) {
865 for (j = 0; j < sbr->
n[ch_data->
bs_freq_res[i + 1]]; j++) {
874 for (j = 0; j < sbr->
n[ch_data->
bs_freq_res[i + 1]]; j++) {
875 k = j ? 2*j - odd : 0;
885 for (j = 1; j < sbr->
n[ch_data->
bs_freq_res[i + 1]]; j++) {
906 VLC_TYPE (*t_huff)[2], (*f_huff)[2];
924 for (j = 0; j < sbr->
n_q; j++) {
933 for (j = 1; j < sbr->
n_q; j++) {
951 int bs_extension_id,
int *num_bits_left)
953 switch (bs_extension_id) {
956 av_log(ac->
avctx,
AV_LOG_ERROR,
"Parametric Stereo signaled to be not-present but was found in the bitstream.\n");
966 if (bs_extension_id || *num_bits_left > 16 ||
show_bits(gb, *num_bits_left))
1070 "Invalid bitstream - cannot apply SBR to element type %d\n", id_aac);
1075 int num_bits_left =
get_bits(gb, 4);
1076 if (num_bits_left == 15)
1079 num_bits_left <<= 3;
1080 while (num_bits_left > 7) {
1084 if (num_bits_left < 0) {
1087 if (num_bits_left > 0)
1102 "SBR reset failed. Switching SBR to pure upsampling mode.\n");
1118 unsigned int num_sbr_bits = 0, num_align_bits;
1119 unsigned bytes_read;
1125 if (!sbr->sample_rate)
1126 sbr->sample_rate = 2 * ac->oc[1].m4ac.sample_rate;
1127 if (!ac->oc[1].m4ac.ext_sample_rate)
1128 ac->oc[1].m4ac.ext_sample_rate = 2 * ac->oc[1].m4ac.sample_rate;
1136 sbr->kx[0] = sbr->kx[1];
1137 sbr->m[0] = sbr->m[1];
1138 sbr->kx_and_m_pushed = 1;
1150 num_align_bits = ((cnt << 3) - 4 - num_sbr_bits) & 7;
1151 bytes_read = ((num_sbr_bits + num_align_bits + 4) >> 3);
1153 if (bytes_read > cnt) {
1155 "Expected to read %d SBR bytes actually read %d.\n", cnt, bytes_read);
1167 #ifndef sbr_qmf_analysis
1180 memcpy(x , x+1024, (320-32)*
sizeof(x[0]));
1181 memcpy(x+288, in, 1024*
sizeof(x[0]));
1182 for (i = 0; i < 32; i++) {
1186 sbrdsp->qmf_pre_shuffle(z);
1188 for (j = 64; j < 128; j++) {
1191 "sbr_qmf_analysis: value %09d too large, setting to %09d\n",
1194 }
else if (z[j] < -(1<<24)) {
1196 "sbr_qmf_analysis: value %09d too small, setting to %09d\n",
1203 sbrdsp->qmf_post_shuffle(W[buf_idx][i], z);
1213 #ifndef sbr_qmf_synthesis
1222 INTFLOAT *
v0,
int *v_off,
const unsigned int div)
1226 const int step = 128 >> div;
1228 for (i = 0; i < 32; i++) {
1229 if (*v_off < step) {
1230 int saved_samples = (1280 - 128) >> div;
1238 for (n = 0; n < 32; n++) {
1239 X[0][i][
n] = -X[0][i][
n];
1240 X[0][i][32+
n] = X[1][i][31-
n];
1242 mdct->
imdct_half(mdct, mdct_buf[0], X[0][i]);
1243 sbrdsp->qmf_deint_neg(v, mdct_buf[0]);
1245 sbrdsp->neg_odd_64(X[1][i]);
1246 mdct->
imdct_half(mdct, mdct_buf[0], X[0][i]);
1247 mdct->
imdct_half(mdct, mdct_buf[1], X[1][i]);
1248 sbrdsp->qmf_deint_bfly(v, mdct_buf[1], mdct_buf[0]);
1250 dsp->
vector_fmul (out, v , sbr_qmf_window , 64 >> div);
1251 dsp->
vector_fmul_add(out, v + ( 192 >> div), sbr_qmf_window + ( 64 >> div), out , 64 >> div);
1252 dsp->
vector_fmul_add(out, v + ( 256 >> div), sbr_qmf_window + (128 >> div), out , 64 >> div);
1253 dsp->
vector_fmul_add(out, v + ( 448 >> div), sbr_qmf_window + (192 >> div), out , 64 >> div);
1254 dsp->
vector_fmul_add(out, v + ( 512 >> div), sbr_qmf_window + (256 >> div), out , 64 >> div);
1255 dsp->
vector_fmul_add(out, v + ( 704 >> div), sbr_qmf_window + (320 >> div), out , 64 >> div);
1256 dsp->
vector_fmul_add(out, v + ( 768 >> div), sbr_qmf_window + (384 >> div), out , 64 >> div);
1257 dsp->
vector_fmul_add(out, v + ( 960 >> div), sbr_qmf_window + (448 >> div), out , 64 >> div);
1258 dsp->
vector_fmul_add(out, v + (1024 >> div), sbr_qmf_window + (512 >> div), out , 64 >> div);
1259 dsp->
vector_fmul_add(out, v + (1216 >> div), sbr_qmf_window + (576 >> div), out , 64 >> div);
1271 const int t_HFGen = 8;
1273 memset(X_low, 0, 32*
sizeof(*X_low));
1274 for (k = 0; k < sbr->
kx[1]; k++) {
1275 for (i = t_HFGen; i < i_f + t_HFGen; i++) {
1276 X_low[k][i][0] = W[buf_idx][i - t_HFGen][k][0];
1277 X_low[k][i][1] = W[buf_idx][i - t_HFGen][k][1];
1280 buf_idx = 1-buf_idx;
1281 for (k = 0; k < sbr->
kx[0]; k++) {
1282 for (i = 0; i < t_HFGen; i++) {
1283 X_low[k][i][0] = W[buf_idx][i + i_f - t_HFGen][k][0];
1284 X_low[k][i][1] = W[buf_idx][i + i_f - t_HFGen][k][1];
1309 "ERROR : no subband found for frequency %d\n", k);
1315 alpha0[p], alpha1[p], bw_array[g],
1316 2 * t_env[0], 2 * t_env[bs_num_env]);
1319 if (k < sbr->m[1] + sbr->
kx[1])
1320 memset(X_high + k, 0, (sbr->
m[1] + sbr->
kx[1] - k) *
sizeof(*X_high));
1333 memset(X, 0, 2*
sizeof(*X));
1334 for (k = 0; k < sbr->
kx[0]; k++) {
1335 for (i = 0; i < i_Temp; i++) {
1340 for (; k < sbr->
kx[0] + sbr->
m[0]; k++) {
1341 for (i = 0; i < i_Temp; i++) {
1342 X[0][i][k] = Y0[i + i_f][k][0];
1343 X[1][i][k] = Y0[i + i_f][k][1];
1347 for (k = 0; k < sbr->
kx[1]; k++) {
1348 for (i = i_Temp; i < 38; i++) {
1353 for (; k < sbr->
kx[1] + sbr->
m[1]; k++) {
1354 for (i = i_Temp; i < i_f; i++) {
1355 X[0][i][k] = Y1[i][k][0];
1356 X[1][i][k] = Y1[i][k][1];
1372 const unsigned int ilim = sbr->
n[ch_data->
bs_freq_res[e + 1]];
1376 if (sbr->
kx[1] != table[0]) {
1378 "Derived frequency tables were not regenerated.\n");
1382 for (i = 0; i < ilim; i++)
1383 for (m = table[i]; m < table[i + 1]; m++)
1388 for (i = 0; i < sbr->
n_q; i++)
1389 for (m = sbr->
f_tablenoise[i]; m < sbr->f_tablenoise[i + 1]; m++)
1392 for (i = 0; i < sbr->
n[1]; i++) {
1394 const unsigned int m_midpoint =
1398 (e >= e_a[1] || (ch_data->
s_indexmapped[0][m_midpoint - sbr->
kx[1]] == 1));
1402 for (i = 0; i < ilim; i++) {
1403 int additional_sinusoid_present = 0;
1404 for (m = table[i]; m < table[i + 1]; m++) {
1406 additional_sinusoid_present = 1;
1410 memset(&sbr->
s_mapped[e][table[i] - sbr->
kx[1]], additional_sinusoid_present,
1411 (table[i + 1] - table[i]) *
sizeof(sbr->
s_mapped[e][0]));
1424 int kx1 = sbr->
kx[1];
1431 const float recip_env_size = 0.5f / (ch_data->
t_env[e + 1] - ch_data->
t_env[e]);
1436 for (m = 0; m < sbr->
m[1]; m++) {
1439 e_curr[e][m] =
av_mul_sf(sum, recip_env_size);
1441 e_curr[e][m] = sum * recip_env_size;
1449 const int env_size = 2 * (ch_data->
t_env[e + 1] - ch_data->
t_env[e]);
1454 for (p = 0; p < sbr->
n[ch_data->
bs_freq_res[e + 1]]; p++) {
1457 const SoftFloat den =
av_int2sf(0x20000000 / (env_size * (table[p + 1] - table[p])), 29);
1458 for (k = table[p]; k < table[p + 1]; k++) {
1464 const int den = env_size * (table[p + 1] - table[p]);
1466 for (k = table[p]; k < table[p + 1]; k++) {
1471 for (k = table[p]; k < table[p + 1]; k++) {
1472 e_curr[e][k - kx1] = sum;
1482 int downsampled = ac->oc[1].m4ac.ext_sample_rate < sbr->sample_rate;
1484 int nch = (id_aac ==
TYPE_CPE) ? 2 : 1;
1487 if (id_aac != sbr->id_aac) {
1489 "element type mismatch %d != %d\n", id_aac, sbr->id_aac);
1493 if (sbr->start && !sbr->ready_for_dequant) {
1495 "No quantized data read for sbr_dequant.\n");
1499 if (!sbr->kx_and_m_pushed) {
1500 sbr->kx[0] = sbr->kx[1];
1501 sbr->m[0] = sbr->m[1];
1503 sbr->kx_and_m_pushed = 0;
1508 sbr->ready_for_dequant = 0;
1510 for (ch = 0; ch < nch; ch++) {
1512 sbr_qmf_analysis(ac->fdsp, &sbr->mdct_ana, &sbr->dsp, ch ?
R : L, sbr->data[ch].analysis_filterbank_samples,
1513 (
INTFLOAT*)sbr->qmf_filter_scratch,
1514 sbr->data[ch].W, sbr->data[ch].Ypos);
1515 sbr->c.sbr_lf_gen(ac, sbr, sbr->X_low,
1516 (
const INTFLOAT (*)[32][32][2]) sbr->data[ch].W,
1517 sbr->data[ch].Ypos);
1518 sbr->data[
ch].Ypos ^= 1;
1520 sbr->c.sbr_hf_inverse_filter(&sbr->dsp, sbr->alpha0, sbr->alpha1,
1521 (
const INTFLOAT (*)[40][2]) sbr->X_low, sbr->k[0]);
1525 (
const INTFLOAT (*)[40][2]) sbr->X_low,
1526 (
const INTFLOAT (*)[2]) sbr->alpha0,
1527 (
const INTFLOAT (*)[2]) sbr->alpha1,
1528 sbr->data[ch].bw_array, sbr->data[ch].t_env,
1529 sbr->data[ch].bs_num_env);
1532 err =
sbr_mapping(ac, sbr, &sbr->data[ch], sbr->data[ch].e_a);
1536 sbr->c.sbr_hf_assemble(sbr->data[ch].Y[sbr->data[ch].Ypos],
1537 (
const INTFLOAT (*)[40][2]) sbr->X_high,
1538 sbr, &sbr->data[ch],
1544 sbr->c.sbr_x_gen(sbr, sbr->X[ch],
1545 (
const INTFLOAT (*)[64][2]) sbr->data[ch].Y[1-sbr->data[ch].Ypos],
1546 (
const INTFLOAT (*)[64][2]) sbr->data[ch].Y[ sbr->data[ch].Ypos],
1547 (
const INTFLOAT (*)[40][2]) sbr->X_low, ch);
1550 if (ac->oc[1].m4ac.ps == 1) {
1551 if (sbr->ps.start) {
1554 memcpy(sbr->X[1], sbr->X[0],
sizeof(sbr->X[0]));
1560 L, sbr->X[0], sbr->qmf_filter_scratch,
1561 sbr->data[0].synthesis_filterbank_samples,
1562 &sbr->data[0].synthesis_filterbank_samples_offset,
1566 R, sbr->X[1], sbr->qmf_filter_scratch,
1567 sbr->data[1].synthesis_filterbank_samples,
1568 &sbr->data[1].synthesis_filterbank_samples_offset,
uint8_t s_indexmapped[8][48]
unsigned bs_add_harmonic_flag
void AAC_RENAME() ff_sbrdsp_init(SBRDSPContext *s)
static int qsort_comparison_function_int16(const void *a, const void *b)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static unsigned int read_sbr_data(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, int id_aac)
static int array_min_int16(const int16_t *array, int nel)
static void sbr_hf_assemble(float Y1[38][64][2], const float X_high[64][40][2], SpectralBandReplication *sbr, SBRData *ch_data, const int e_a[2])
Assembling HF Signals (14496-3 sp04 p220)
static const int8_t vlc_sbr_lav[10]
unsigned bs_smoothing_mode
static void sbr_reset(AACContext *ac, SpectralBandReplication *sbr)
AAC_FLOAT(* sum_square)(INTFLOAT(*x)[2], int n)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
static void sbr_qmf_synthesis(FFTContext *mdct, SBRDSPContext *sbrdsp, AVFloatDSPContext *dsp, INTFLOAT *out, INTFLOAT X[2][38][64], INTFLOAT mdct_buf[2][64], INTFLOAT *v0, int *v_off, const unsigned int div)
Synthesis QMF Bank (14496-3 sp04 p206) and Downsampled Synthesis QMF Bank (14496-3 sp04 p206) ...
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
static int sbr_hf_gen(AACContext *ac, SpectralBandReplication *sbr, INTFLOAT X_high[64][40][2], const INTFLOAT X_low[32][40][2], const INTFLOAT(*alpha0)[2], const INTFLOAT(*alpha1)[2], const INTFLOAT bw_array[5], const uint8_t *t_env, int bs_num_env)
High Frequency Generator (14496-3 sp04 p215)
int e_a[2]
l_APrev and l_A
int AAC_RENAME() ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps, int bits_left)
static void read_sbr_invf(SpectralBandReplication *sbr, GetBitContext *gb, SBRData *ch_data)
Read inverse filtering data.
AAC_SIGNE kx[2]
kx', and kx respectively, kx is the first QMF subband where SBR is used.
uint8_t noise_facs_q[3][5]
Noise scalefactors.
void(* vector_fmul_reverse)(float *dst, const float *src0, const float *src1, int len)
Calculate the entry wise product of two vectors of floats, and store the result in a vector of floats...
void(* sbr_hf_assemble)(INTFLOAT Y1[38][64][2], const INTFLOAT X_high[64][40][2], SpectralBandReplication *sbr, SBRData *ch_data, const int e_a[2])
int(* sbr_x_gen)(SpectralBandReplication *sbr, INTFLOAT X[2][38][64], const INTFLOAT Y0[38][64][2], const INTFLOAT Y1[38][64][2], const INTFLOAT X_low[32][40][2], int ch)
#define FF_PROFILE_AAC_HE_V2
SpectrumParameters spectrum_params
int AAC_RENAME() ff_ps_apply(AVCodecContext *avctx, PSContext *ps, INTFLOAT L[2][38][64], INTFLOAT R[2][38][64], int top)
static const SoftFloat FLOAT_0
0.0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static const int8_t sbr_offset[6][16]
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
AAC_FLOAT noise_facs[3][5]
AAC_SIGNE n_lim
Number of limiter bands.
#define ENVELOPE_ADJUSTMENT_OFFSET
static unsigned int read_sbr_header(SpectralBandReplication *sbr, GetBitContext *gb)
uint16_t f_tablehigh[49]
Frequency borders for high resolution SBR.
void ff_aacsbr_func_ptr_init_mips(AACSBRContext *c)
static int get_bits_count(const GetBitContext *s)
static INTFLOAT sbr_qmf_window_us[640]
#define AV_LOG_VERBOSE
Detailed information.
av_cold void AAC_RENAME() ff_aac_sbr_ctx_close(SpectralBandReplication *sbr)
Close one SBR context.
static int sbr_make_f_derived(AACContext *ac, SpectralBandReplication *sbr)
Derived Frequency Band Tables (14496-3 sp04 p197)
void(* sbr_hf_inverse_filter)(SBRDSPContext *dsp, INTFLOAT(*alpha0)[2], INTFLOAT(*alpha1)[2], const INTFLOAT X_low[32][40][2], int k0)
static int fixed_log(int x)
static int read_sbr_envelope(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, SBRData *ch_data, int ch)
uint8_t patch_num_subbands[6]
static const uint16_t table[]
uint16_t f_tablenoise[6]
Frequency borders for noise floors.
#define SBR_INIT_VLC_STATIC(num, size)
static void copy_sbr_grid(SBRData *dst, const SBRData *src)
uint8_t t_q[3]
Noise time borders.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
uint16_t f_tablelow[25]
Frequency borders for low resolution SBR.
static void sbr_hf_inverse_filter(SBRDSPContext *dsp, float(*alpha0)[2], float(*alpha1)[2], const float X_low[32][40][2], int k0)
High Frequency Generation (14496-3 sp04 p214+) and Inverse Filtering (14496-3 sp04 p214) Warning: Thi...
Spectral Band Replication header - spectrum parameters that invoke a reset if they differ from the pr...
AAC_SIGNE m[2]
M' and M respectively, M is the number of QMF subbands that use SBR.
void(* vector_fmul)(float *dst, const float *src0, const float *src1, int len)
Calculate the entry wise product of two vectors of floats and store the result in a vector of floats...
static void sbr_dequant(SpectralBandReplication *sbr, int id_aac)
Dequantization and stereo decoding (14496-3 sp04 p203)
static int sbr_mapping(AACContext *ac, SpectralBandReplication *sbr, SBRData *ch_data, int e_a[2])
High Frequency Adjustment (14496-3 sp04 p217) and Mapping (14496-3 sp04 p217)
av_cold void AAC_RENAME() ff_aac_sbr_ctx_init(AACContext *ac, SpectralBandReplication *sbr, int id_aac)
Initialize one SBR context.
unsigned bs_interpol_freq
uint8_t env_facs_q[6][48]
Envelope scalefactors.
uint8_t t_env_num_env_old
Envelope time border of the last envelope of the previous frame.
static int read_sbr_channel_pair_element(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb)
static int check_n_master(AVCodecContext *avctx, int n_master, int bs_xover_band)
static const ElemCat * elements[ELEMENT_COUNT]
unsigned bs_limiter_gains
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
static const int CONST_RECIP_LN2
static void sbr_qmf_analysis(AVFloatDSPContext *dsp, FFTContext *mdct, SBRDSPContext *sbrdsp, const INTFLOAT *in, INTFLOAT *x, INTFLOAT z[320], INTFLOAT W[2][32][32][2], int buf_idx)
Analysis QMF Bank (14496-3 sp04 p206)
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
AAC_FLOAT e_origmapped[7][48]
Dequantized envelope scalefactors, remapped.
uint8_t s_mapped[7][48]
Sinusoidal presence, remapped.
static void aacsbr_func_ptr_init(AACSBRContext *c)
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
static int in_table_int16(const int16_t *table, int last_el, int16_t needle)
static void sbr_env_estimate(AAC_FLOAT(*e_curr)[48], INTFLOAT X_high[64][40][2], SpectralBandReplication *sbr, SBRData *ch_data)
Estimation of current envelope (14496-3 sp04 p218)
av_cold void AAC_RENAME() ff_ps_init(void)
static int sbr_lf_gen(AACContext *ac, SpectralBandReplication *sbr, INTFLOAT X_low[32][40][2], const INTFLOAT W[2][32][32][2], int buf_idx)
Generate the subband filtered lowband.
static void sbr_gain_calc(AACContext *ac, SpectralBandReplication *sbr, SBRData *ch_data, const int e_a[2])
Calculation of levels of additional HF signal components (14496-3 sp04 p219) and Calculation of gain ...
static void sbr_turnoff(SpectralBandReplication *sbr)
Places SBR in pure upsampling mode.
#define SBR_SYNTHESIS_BUF_SIZE
AAC_FLOAT q_mapped[7][48]
Dequantized noise scalefactors, remapped.
static const int8_t ceil_log2[]
ceil(log2(index+1))
void(* hf_gen)(INTFLOAT(*X_high)[2], const INTFLOAT(*X_low)[2], const INTFLOAT alpha0[2], const INTFLOAT alpha1[2], INTFLOAT bw, int start, int end)
void AAC_RENAME() ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac, INTFLOAT *L, INTFLOAT *R)
Apply one SBR element to one AAC element.
int AAC_RENAME() ff_decode_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb_host, int crc, int cnt, int id_aac)
Decode Spectral Band Replication extension data; reference: table 4.55.
main external API structure.
static void read_sbr_dtdf(SpectralBandReplication *sbr, GetBitContext *gb, SBRData *ch_data)
Read how the envelope and noise floor data is delta coded.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}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;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->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);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
void(* imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input)
void(* vector_fmul_add)(float *dst, const float *src0, const float *src1, const float *src2, int len)
Calculate the entry wise product of two vectors of floats, add a third vector of floats and store the...
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
static unsigned int get_bits1(GetBitContext *s)
static const int CONST_076923
static void skip_bits(GetBitContext *s, int n)
static av_always_inline void get_bits1_vector(GetBitContext *gb, uint8_t *vec, int elements)
static void read_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, int bs_extension_id, int *num_bits_left)
static int read_sbr_single_channel_element(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb)
static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, SpectrumParameters *spectrum)
Master Frequency Band Table (14496-3 sp04 p194)
static void sbr_chirp(SpectralBandReplication *sbr, SBRData *ch_data)
Chirp Factors (14496-3 sp04 p214)
av_cold void AAC_RENAME() ff_ps_ctx_init(PSContext *ps)
AAC_FLOAT env_facs[6][48]
AAC_SIGNE n_master
The number of frequency bands in f_master.
static void sbr_make_f_tablelim(SpectralBandReplication *sbr)
Limiter Frequency Band Table (14496-3 sp04 p198)
uint16_t f_master[49]
The master QMF frequency grouping.
uint8_t bs_invf_mode[2][5]
static av_const SoftFloat av_add_sf(SoftFloat a, SoftFloat b)
static int sbr_x_gen(SpectralBandReplication *sbr, INTFLOAT X[2][38][64], const INTFLOAT Y0[38][64][2], const INTFLOAT Y1[38][64][2], const INTFLOAT X_low[32][40][2], int ch)
Generate the subband filtered lowband.
OutputConfiguration oc[2]
int(* sbr_lf_gen)(AACContext *ac, SpectralBandReplication *sbr, INTFLOAT X_low[32][40][2], const INTFLOAT W[2][32][32][2], int buf_idx)
static av_cold void aacsbr_tableinit(void)
static av_const SoftFloat av_mul_sf(SoftFloat a, SoftFloat b)
uint8_t patch_start_subband[6]
uint8_t t_env[8]
Envelope time borders.
aacsbr functions pointers
static INTFLOAT sbr_qmf_window_ds[320]
< window coefficients for analysis/synthesis QMF banks
uint16_t f_tablelim[30]
Frequency borders for the limiter.
Spectral Band Replication per channel data.
static void make_bands(int16_t *bands, int start, int stop, int num_bands)
#define SBR_VLC_ROW(name)
unsigned bs_limiter_bands
static int sbr_hf_calc_npatches(AACContext *ac, SpectralBandReplication *sbr)
High Frequency Generation - Patch Construction (14496-3 sp04 p216 fig. 4.46)
VLC_TYPE(* table)[2]
code, bits
static av_const SoftFloat av_int2sf(int v, int frac_bits)
Converts a mantisse and exponent to a SoftFloat.
static int array[MAX_W *MAX_W]
int ps
-1 implicit, 1 presence
AAC_SIGNE n_q
Number of noise floor bands.
Spectral Band Replication.
static int read_sbr_noise(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, SBRData *ch_data, int ch)
av_cold void AAC_RENAME() ff_aac_sbr_init(void)
Initialize SBR.
uint8_t bs_add_harmonic[48]
#define AV_QSORT(p, num, type, cmp)
Quicksort This sort is fast, and fully inplace but not stable and it is possible to construct input t...
AAC_SIGNE n[2]
N_Low and N_High respectively, the number of frequency bands for low and high resolution.
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(constuint8_t *) pi-0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(constint16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(constint32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(constint64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(constfloat *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(constdouble *) pi *(INT64_C(1)<< 63)))#defineFMT_PAIR_FUNC(out, in) staticconv_func_type *constfmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64),};staticvoidcpy1(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, len);}staticvoidcpy2(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 2 *len);}staticvoidcpy4(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 4 *len);}staticvoidcpy8(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 8 *len);}AudioConvert *swri_audio_convert_alloc(enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, constint *ch_map, intflags){AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) returnNULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) returnNULL;if(channels==1){in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);}ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map){switch(av_get_bytes_per_sample(in_fmt)){case1:ctx->simd_f=cpy1;break;case2:ctx->simd_f=cpy2;break;case4:ctx->simd_f=cpy4;break;case8:ctx->simd_f=cpy8;break;}}if(HAVE_X86ASM &&1) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);returnctx;}voidswri_audio_convert_free(AudioConvert **ctx){av_freep(ctx);}intswri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, intlen){intch;intoff=0;constintos=(out->planar?1:out->ch_count)*out->bps;unsignedmisaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask){intplanes=in->planar?in->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;}if(ctx->out_simd_align_mask){intplanes=out->planar?out->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;}if(ctx->simd_f &&!ctx->ch_map &&!misaligned){off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){if(out->planar==in->planar){intplanes=out->planar?out->ch_count:1;for(ch=0;ch< planes;ch++){ctx->simd_f(out-> ch ch
static int read_sbr_grid(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, SBRData *ch_data)