[FFmpeg-devel] [PATCH 6/8] avcodec/aacsbr_template: Avoid using AACDecContext; pass logctx directly
Andreas Rheinhardt
andreas.rheinhardt at outlook.com
Mon Feb 26 03:26:54 EET 2024
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
libavcodec/aacsbr_template.c | 131 ++++++++++++++++++-----------------
1 file changed, 66 insertions(+), 65 deletions(-)
diff --git a/libavcodec/aacsbr_template.c b/libavcodec/aacsbr_template.c
index ce3834e2dc..72bec96d2c 100644
--- a/libavcodec/aacsbr_template.c
+++ b/libavcodec/aacsbr_template.c
@@ -237,15 +237,15 @@ static int array_min_int16(const int16_t *array, int nel)
return min;
}
-static int check_n_master(AVCodecContext *avctx, int n_master, int bs_xover_band)
+static int check_n_master(void *logctx, int n_master, int bs_xover_band)
{
// Requirements (14496-3 sp04 p205)
if (n_master <= 0) {
- av_log(avctx, AV_LOG_ERROR, "Invalid n_master: %d\n", n_master);
+ av_log(logctx, AV_LOG_ERROR, "Invalid n_master: %d\n", n_master);
return -1;
}
if (bs_xover_band >= n_master) {
- av_log(avctx, AV_LOG_ERROR,
+ av_log(logctx, AV_LOG_ERROR,
"Invalid bitstream, crossover band index beyond array bounds: %d\n",
bs_xover_band);
return -1;
@@ -254,7 +254,7 @@ static int check_n_master(AVCodecContext *avctx, int n_master, int bs_xover_band
}
/// Master Frequency Band Table (14496-3 sp04 p194)
-static int sbr_make_f_master(AACDecContext *ac, SpectralBandReplication *sbr,
+static int sbr_make_f_master(void *logctx, SpectralBandReplication *sbr,
SpectrumParameters *spectrum)
{
unsigned int temp, max_qmf_subbands = 0;
@@ -283,7 +283,7 @@ static int sbr_make_f_master(AACDecContext *ac, SpectralBandReplication *sbr,
sbr_offset_ptr = sbr_offset[5];
break;
default:
- av_log(ac->avctx, AV_LOG_ERROR,
+ av_log(logctx, AV_LOG_ERROR,
"Unsupported sample rate for SBR: %d\n", sbr->sample_rate);
return -1;
}
@@ -311,7 +311,7 @@ static int sbr_make_f_master(AACDecContext *ac, SpectralBandReplication *sbr,
} else if (spectrum->bs_stop_freq == 15) {
sbr->k[2] = 3*sbr->k[0];
} else {
- av_log(ac->avctx, AV_LOG_ERROR,
+ av_log(logctx, AV_LOG_ERROR,
"Invalid bs_stop_freq: %d\n", spectrum->bs_stop_freq);
return -1;
}
@@ -328,7 +328,7 @@ static int sbr_make_f_master(AACDecContext *ac, SpectralBandReplication *sbr,
av_assert0(0);
if (sbr->k[2] - sbr->k[0] > max_qmf_subbands) {
- av_log(ac->avctx, AV_LOG_ERROR,
+ av_log(logctx, AV_LOG_ERROR,
"Invalid bitstream, too many QMF subbands: %d\n", sbr->k[2] - sbr->k[0]);
return -1;
}
@@ -338,7 +338,7 @@ static int sbr_make_f_master(AACDecContext *ac, SpectralBandReplication *sbr,
dk = spectrum->bs_alter_scale + 1;
sbr->n_master = ((sbr->k[2] - sbr->k[0] + (dk&2)) >> dk) << 1;
- if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band))
+ if (check_n_master(logctx, sbr->n_master, sbr->spectrum_params.bs_xover_band))
return -1;
for (k = 1; k <= sbr->n_master; k++)
@@ -388,7 +388,7 @@ static int sbr_make_f_master(AACDecContext *ac, SpectralBandReplication *sbr,
#endif /* USE_FIXED */
if (num_bands_0 <= 0) { // Requirements (14496-3 sp04 p205)
- av_log(ac->avctx, AV_LOG_ERROR, "Invalid num_bands_0: %d\n", num_bands_0);
+ av_log(logctx, AV_LOG_ERROR, "Invalid num_bands_0: %d\n", num_bands_0);
return -1;
}
@@ -402,7 +402,7 @@ static int sbr_make_f_master(AACDecContext *ac, SpectralBandReplication *sbr,
vk0[0] = sbr->k[0];
for (k = 1; k <= num_bands_0; k++) {
if (vk0[k] <= 0) { // Requirements (14496-3 sp04 p205)
- av_log(ac->avctx, AV_LOG_ERROR, "Invalid vDk0[%d]: %d\n", k, vk0[k]);
+ av_log(logctx, AV_LOG_ERROR, "Invalid vDk0[%d]: %d\n", k, vk0[k]);
return -1;
}
vk0[k] += vk0[k-1];
@@ -448,14 +448,14 @@ static int sbr_make_f_master(AACDecContext *ac, SpectralBandReplication *sbr,
vk1[0] = sbr->k[1];
for (k = 1; k <= num_bands_1; k++) {
if (vk1[k] <= 0) { // Requirements (14496-3 sp04 p205)
- av_log(ac->avctx, AV_LOG_ERROR, "Invalid vDk1[%d]: %d\n", k, vk1[k]);
+ av_log(logctx, AV_LOG_ERROR, "Invalid vDk1[%d]: %d\n", k, vk1[k]);
return -1;
}
vk1[k] += vk1[k-1];
}
sbr->n_master = num_bands_0 + num_bands_1;
- if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band))
+ if (check_n_master(logctx, sbr->n_master, sbr->spectrum_params.bs_xover_band))
return -1;
memcpy(&sbr->f_master[0], vk0,
(num_bands_0 + 1) * sizeof(sbr->f_master[0]));
@@ -464,7 +464,7 @@ static int sbr_make_f_master(AACDecContext *ac, SpectralBandReplication *sbr,
} else {
sbr->n_master = num_bands_0;
- if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band))
+ if (check_n_master(logctx, sbr->n_master, sbr->spectrum_params.bs_xover_band))
return -1;
memcpy(sbr->f_master, vk0, (num_bands_0 + 1) * sizeof(sbr->f_master[0]));
}
@@ -474,7 +474,7 @@ static int sbr_make_f_master(AACDecContext *ac, SpectralBandReplication *sbr,
}
/// High Frequency Generation - Patch Construction (14496-3 sp04 p216 fig. 4.46)
-static int sbr_hf_calc_npatches(AACDecContext *ac, SpectralBandReplication *sbr)
+static int sbr_hf_calc_npatches(void *logctx, SpectralBandReplication *sbr)
{
int i, k, last_k = -1, last_msb = -1, sb = 0;
int msb = sbr->k[0];
@@ -491,7 +491,7 @@ static int sbr_hf_calc_npatches(AACDecContext *ac, SpectralBandReplication *sbr)
do {
int odd = 0;
if (k == last_k && msb == last_msb) {
- av_log(ac->avctx, AV_LOG_ERROR, "patch construction failed\n");
+ av_log(logctx, AV_LOG_ERROR, "patch construction failed\n");
return AVERROR_INVALIDDATA;
}
last_k = k;
@@ -506,7 +506,7 @@ static int sbr_hf_calc_npatches(AACDecContext *ac, SpectralBandReplication *sbr)
// illegal however the Coding Technologies decoder check stream has a final
// count of 6 patches
if (sbr->num_patches > 5) {
- av_log(ac->avctx, AV_LOG_ERROR, "Too many patches: %d\n", sbr->num_patches);
+ av_log(logctx, AV_LOG_ERROR, "Too many patches: %d\n", sbr->num_patches);
return -1;
}
@@ -532,7 +532,7 @@ static int sbr_hf_calc_npatches(AACDecContext *ac, SpectralBandReplication *sbr)
}
/// Derived Frequency Band Tables (14496-3 sp04 p197)
-static int sbr_make_f_derived(AACDecContext *ac, SpectralBandReplication *sbr)
+static int sbr_make_f_derived(void *logctx, SpectralBandReplication *sbr)
{
int k, temp;
#if USE_FIXED
@@ -549,12 +549,12 @@ static int sbr_make_f_derived(AACDecContext *ac, SpectralBandReplication *sbr)
// Requirements (14496-3 sp04 p205)
if (sbr->kx[1] + sbr->m[1] > 64) {
- av_log(ac->avctx, AV_LOG_ERROR,
+ av_log(logctx, AV_LOG_ERROR,
"Stop frequency border too high: %d\n", sbr->kx[1] + sbr->m[1]);
return -1;
}
if (sbr->kx[1] > 32) {
- av_log(ac->avctx, AV_LOG_ERROR, "Start frequency border too high: %d\n", sbr->kx[1]);
+ av_log(logctx, AV_LOG_ERROR, "Start frequency border too high: %d\n", sbr->kx[1]);
return -1;
}
@@ -581,7 +581,7 @@ static int sbr_make_f_derived(AACDecContext *ac, SpectralBandReplication *sbr)
#endif /* USE_FIXED */
if (sbr->n_q > 5) {
- av_log(ac->avctx, AV_LOG_ERROR, "Too many noise floor scale factors: %d\n", sbr->n_q);
+ av_log(logctx, AV_LOG_ERROR, "Too many noise floor scale factors: %d\n", sbr->n_q);
return -1;
}
@@ -592,7 +592,7 @@ static int sbr_make_f_derived(AACDecContext *ac, SpectralBandReplication *sbr)
sbr->f_tablenoise[k] = sbr->f_tablelow[temp];
}
- if (sbr_hf_calc_npatches(ac, sbr) < 0)
+ if (sbr_hf_calc_npatches(logctx, sbr) < 0)
return -1;
sbr_make_f_tablelim(sbr);
@@ -617,7 +617,7 @@ static const int8_t ceil_log2[] = {
0, 1, 2, 2, 3, 3,
};
-static int read_sbr_grid(AACDecContext *ac, SpectralBandReplication *sbr,
+static int read_sbr_grid(void *logctx, SpectralBandReplication *sbr,
GetBitContext *gb, SBRData *ch_data)
{
int i;
@@ -636,7 +636,7 @@ static int read_sbr_grid(AACDecContext *ac, SpectralBandReplication *sbr,
case FIXFIX:
bs_num_env = 1 << get_bits(gb, 2);
if (bs_num_env > 4) {
- av_log(ac->avctx, AV_LOG_ERROR,
+ av_log(logctx, AV_LOG_ERROR,
"Invalid bitstream, too many SBR envelopes in FIXFIX type SBR frame: %d\n",
bs_num_env);
return -1;
@@ -696,7 +696,7 @@ static int read_sbr_grid(AACDecContext *ac, SpectralBandReplication *sbr,
bs_num_env = num_rel_lead + num_rel_trail + 1;
if (bs_num_env > 5) {
- av_log(ac->avctx, AV_LOG_ERROR,
+ av_log(logctx, AV_LOG_ERROR,
"Invalid bitstream, too many SBR envelopes in VARVAR type SBR frame: %d\n",
bs_num_env);
return -1;
@@ -720,7 +720,7 @@ static int read_sbr_grid(AACDecContext *ac, SpectralBandReplication *sbr,
av_assert0(bs_pointer >= 0);
if (bs_pointer > ch_data->bs_num_env + 1) {
- av_log(ac->avctx, AV_LOG_ERROR,
+ av_log(logctx, AV_LOG_ERROR,
"Invalid bitstream, bs_pointer points to a middle noise border outside the time borders table: %d\n",
bs_pointer);
return -1;
@@ -728,7 +728,7 @@ static int read_sbr_grid(AACDecContext *ac, SpectralBandReplication *sbr,
for (i = 1; i <= ch_data->bs_num_env; i++) {
if (ch_data->t_env[i-1] >= ch_data->t_env[i]) {
- av_log(ac->avctx, AV_LOG_ERROR, "Not strictly monotone time borders\n");
+ av_log(logctx, AV_LOG_ERROR, "Not strictly monotone time borders\n");
return -1;
}
}
@@ -800,7 +800,7 @@ static void read_sbr_invf(SpectralBandReplication *sbr, GetBitContext *gb,
ch_data->bs_invf_mode[0][i] = get_bits(gb, 2);
}
-static int read_sbr_envelope(AACDecContext *ac, SpectralBandReplication *sbr, GetBitContext *gb,
+static int read_sbr_envelope(void *logctx, SpectralBandReplication *sbr, GetBitContext *gb,
SBRData *ch_data, int ch)
{
int bits;
@@ -838,7 +838,7 @@ static int read_sbr_envelope(AACDecContext *ac, SpectralBandReplication *sbr, Ge
for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) {
ch_data->env_facs_q[i + 1][j] = ch_data->env_facs_q[i][j] + delta * get_vlc2(gb, t_huff, 9, 3);
if (ch_data->env_facs_q[i + 1][j] > 127U) {
- av_log(ac->avctx, AV_LOG_ERROR, "env_facs_q %d is invalid\n", ch_data->env_facs_q[i + 1][j]);
+ av_log(logctx, AV_LOG_ERROR, "env_facs_q %d is invalid\n", ch_data->env_facs_q[i + 1][j]);
return AVERROR_INVALIDDATA;
}
}
@@ -847,7 +847,7 @@ static int read_sbr_envelope(AACDecContext *ac, SpectralBandReplication *sbr, Ge
k = (j + odd) >> 1; // find k such that f_tablelow[k] <= f_tablehigh[j] < f_tablelow[k + 1]
ch_data->env_facs_q[i + 1][j] = ch_data->env_facs_q[i][k] + delta * get_vlc2(gb, t_huff, 9, 3);
if (ch_data->env_facs_q[i + 1][j] > 127U) {
- av_log(ac->avctx, AV_LOG_ERROR, "env_facs_q %d is invalid\n", ch_data->env_facs_q[i + 1][j]);
+ av_log(logctx, AV_LOG_ERROR, "env_facs_q %d is invalid\n", ch_data->env_facs_q[i + 1][j]);
return AVERROR_INVALIDDATA;
}
}
@@ -856,7 +856,7 @@ static int read_sbr_envelope(AACDecContext *ac, SpectralBandReplication *sbr, Ge
k = j ? 2*j - odd : 0; // find k such that f_tablehigh[k] == f_tablelow[j]
ch_data->env_facs_q[i + 1][j] = ch_data->env_facs_q[i][k] + delta * get_vlc2(gb, t_huff, 9, 3);
if (ch_data->env_facs_q[i + 1][j] > 127U) {
- av_log(ac->avctx, AV_LOG_ERROR, "env_facs_q %d is invalid\n", ch_data->env_facs_q[i + 1][j]);
+ av_log(logctx, AV_LOG_ERROR, "env_facs_q %d is invalid\n", ch_data->env_facs_q[i + 1][j]);
return AVERROR_INVALIDDATA;
}
}
@@ -866,7 +866,7 @@ static int read_sbr_envelope(AACDecContext *ac, SpectralBandReplication *sbr, Ge
for (j = 1; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) {
ch_data->env_facs_q[i + 1][j] = ch_data->env_facs_q[i + 1][j - 1] + delta * get_vlc2(gb, f_huff, 9, 3);
if (ch_data->env_facs_q[i + 1][j] > 127U) {
- av_log(ac->avctx, AV_LOG_ERROR, "env_facs_q %d is invalid\n", ch_data->env_facs_q[i + 1][j]);
+ av_log(logctx, AV_LOG_ERROR, "env_facs_q %d is invalid\n", ch_data->env_facs_q[i + 1][j]);
return AVERROR_INVALIDDATA;
}
}
@@ -880,7 +880,7 @@ static int read_sbr_envelope(AACDecContext *ac, SpectralBandReplication *sbr, Ge
return 0;
}
-static int read_sbr_noise(AACDecContext *ac, SpectralBandReplication *sbr, GetBitContext *gb,
+static int read_sbr_noise(void *logctx, SpectralBandReplication *sbr, GetBitContext *gb,
SBRData *ch_data, int ch)
{
int i, j;
@@ -900,7 +900,7 @@ static int read_sbr_noise(AACDecContext *ac, SpectralBandReplication *sbr, GetBi
for (j = 0; j < sbr->n_q; j++) {
ch_data->noise_facs_q[i + 1][j] = ch_data->noise_facs_q[i][j] + delta * get_vlc2(gb, t_huff, 9, 2);
if (ch_data->noise_facs_q[i + 1][j] > 30U) {
- av_log(ac->avctx, AV_LOG_ERROR, "noise_facs_q %d is invalid\n", ch_data->noise_facs_q[i + 1][j]);
+ av_log(logctx, AV_LOG_ERROR, "noise_facs_q %d is invalid\n", ch_data->noise_facs_q[i + 1][j]);
return AVERROR_INVALIDDATA;
}
}
@@ -909,7 +909,7 @@ static int read_sbr_noise(AACDecContext *ac, SpectralBandReplication *sbr, GetBi
for (j = 1; j < sbr->n_q; j++) {
ch_data->noise_facs_q[i + 1][j] = ch_data->noise_facs_q[i + 1][j - 1] + delta * get_vlc2(gb, f_huff, 9, 3);
if (ch_data->noise_facs_q[i + 1][j] > 30U) {
- av_log(ac->avctx, AV_LOG_ERROR, "noise_facs_q %d is invalid\n", ch_data->noise_facs_q[i + 1][j]);
+ av_log(logctx, AV_LOG_ERROR, "noise_facs_q %d is invalid\n", ch_data->noise_facs_q[i + 1][j]);
return AVERROR_INVALIDDATA;
}
}
@@ -949,7 +949,7 @@ static void read_sbr_extension(AACDecContext *ac, SpectralBandReplication *sbr,
}
}
-static int read_sbr_single_channel_element(AACDecContext *ac,
+static int read_sbr_single_channel_element(void *logctx,
SpectralBandReplication *sbr,
GetBitContext *gb)
{
@@ -958,13 +958,13 @@ static int read_sbr_single_channel_element(AACDecContext *ac,
if (get_bits1(gb)) // bs_data_extra
skip_bits(gb, 4); // bs_reserved
- if (read_sbr_grid(ac, sbr, gb, &sbr->data[0]))
+ if (read_sbr_grid(logctx, sbr, gb, &sbr->data[0]))
return -1;
read_sbr_dtdf(sbr, gb, &sbr->data[0]);
read_sbr_invf(sbr, gb, &sbr->data[0]);
- if((ret = read_sbr_envelope(ac, sbr, gb, &sbr->data[0], 0)) < 0)
+ if((ret = read_sbr_envelope(logctx, sbr, gb, &sbr->data[0], 0)) < 0)
return ret;
- if((ret = read_sbr_noise(ac, sbr, gb, &sbr->data[0], 0)) < 0)
+ if((ret = read_sbr_noise(logctx, sbr, gb, &sbr->data[0], 0)) < 0)
return ret;
if ((sbr->data[0].bs_add_harmonic_flag = get_bits1(gb)))
@@ -973,7 +973,7 @@ static int read_sbr_single_channel_element(AACDecContext *ac,
return 0;
}
-static int read_sbr_channel_pair_element(AACDecContext *ac,
+static int read_sbr_channel_pair_element(void *logctx,
SpectralBandReplication *sbr,
GetBitContext *gb)
{
@@ -983,7 +983,7 @@ static int read_sbr_channel_pair_element(AACDecContext *ac,
skip_bits(gb, 8); // bs_reserved
if ((sbr->bs_coupling = get_bits1(gb))) {
- if (read_sbr_grid(ac, sbr, gb, &sbr->data[0]))
+ if (read_sbr_grid(logctx, sbr, gb, &sbr->data[0]))
return -1;
copy_sbr_grid(&sbr->data[1], &sbr->data[0]);
read_sbr_dtdf(sbr, gb, &sbr->data[0]);
@@ -991,29 +991,29 @@ static int read_sbr_channel_pair_element(AACDecContext *ac,
read_sbr_invf(sbr, gb, &sbr->data[0]);
memcpy(sbr->data[1].bs_invf_mode[1], sbr->data[1].bs_invf_mode[0], sizeof(sbr->data[1].bs_invf_mode[0]));
memcpy(sbr->data[1].bs_invf_mode[0], sbr->data[0].bs_invf_mode[0], sizeof(sbr->data[1].bs_invf_mode[0]));
- if((ret = read_sbr_envelope(ac, sbr, gb, &sbr->data[0], 0)) < 0)
+ if((ret = read_sbr_envelope(logctx, sbr, gb, &sbr->data[0], 0)) < 0)
return ret;
- if((ret = read_sbr_noise(ac, sbr, gb, &sbr->data[0], 0)) < 0)
+ if((ret = read_sbr_noise(logctx, sbr, gb, &sbr->data[0], 0)) < 0)
return ret;
- if((ret = read_sbr_envelope(ac, sbr, gb, &sbr->data[1], 1)) < 0)
+ if((ret = read_sbr_envelope(logctx, sbr, gb, &sbr->data[1], 1)) < 0)
return ret;
- if((ret = read_sbr_noise(ac, sbr, gb, &sbr->data[1], 1)) < 0)
+ if((ret = read_sbr_noise(logctx, sbr, gb, &sbr->data[1], 1)) < 0)
return ret;
} else {
- if (read_sbr_grid(ac, sbr, gb, &sbr->data[0]) ||
- read_sbr_grid(ac, sbr, gb, &sbr->data[1]))
+ if (read_sbr_grid(logctx, sbr, gb, &sbr->data[0]) ||
+ read_sbr_grid(logctx, sbr, gb, &sbr->data[1]))
return -1;
read_sbr_dtdf(sbr, gb, &sbr->data[0]);
read_sbr_dtdf(sbr, gb, &sbr->data[1]);
read_sbr_invf(sbr, gb, &sbr->data[0]);
read_sbr_invf(sbr, gb, &sbr->data[1]);
- if((ret = read_sbr_envelope(ac, sbr, gb, &sbr->data[0], 0)) < 0)
+ if((ret = read_sbr_envelope(logctx, sbr, gb, &sbr->data[0], 0)) < 0)
return ret;
- if((ret = read_sbr_envelope(ac, sbr, gb, &sbr->data[1], 1)) < 0)
+ if((ret = read_sbr_envelope(logctx, sbr, gb, &sbr->data[1], 1)) < 0)
return ret;
- if((ret = read_sbr_noise(ac, sbr, gb, &sbr->data[0], 0)) < 0)
+ if((ret = read_sbr_noise(logctx, sbr, gb, &sbr->data[0], 0)) < 0)
return ret;
- if((ret = read_sbr_noise(ac, sbr, gb, &sbr->data[1], 1)) < 0)
+ if((ret = read_sbr_noise(logctx, sbr, gb, &sbr->data[1], 1)) < 0)
return ret;
}
@@ -1029,22 +1029,23 @@ static unsigned int read_sbr_data(AACDecContext *ac, SpectralBandReplication *sb
GetBitContext *gb, int id_aac)
{
unsigned int cnt = get_bits_count(gb);
+ void *logctx = ac->avctx;
sbr->id_aac = id_aac;
sbr->ready_for_dequant = 1;
if (id_aac == TYPE_SCE || id_aac == TYPE_CCE) {
- if (read_sbr_single_channel_element(ac, sbr, gb)) {
+ if (read_sbr_single_channel_element(logctx, sbr, gb)) {
sbr_turnoff(sbr);
return get_bits_count(gb) - cnt;
}
} else if (id_aac == TYPE_CPE) {
- if (read_sbr_channel_pair_element(ac, sbr, gb)) {
+ if (read_sbr_channel_pair_element(logctx, sbr, gb)) {
sbr_turnoff(sbr);
return get_bits_count(gb) - cnt;
}
} else {
- av_log(ac->avctx, AV_LOG_ERROR,
+ av_log(logctx, AV_LOG_ERROR,
"Invalid bitstream - cannot apply SBR to element type %d\n", id_aac);
sbr_turnoff(sbr);
return get_bits_count(gb) - cnt;
@@ -1060,7 +1061,7 @@ static unsigned int read_sbr_data(AACDecContext *ac, SpectralBandReplication *sb
read_sbr_extension(ac, sbr, gb, get_bits(gb, 2), &num_bits_left); // bs_extension_id
}
if (num_bits_left < 0) {
- av_log(ac->avctx, AV_LOG_ERROR, "SBR Extension over read.\n");
+ av_log(logctx, AV_LOG_ERROR, "SBR Extension over read.\n");
}
if (num_bits_left > 0)
skip_bits(gb, num_bits_left);
@@ -1069,14 +1070,14 @@ static unsigned int read_sbr_data(AACDecContext *ac, SpectralBandReplication *sb
return get_bits_count(gb) - cnt;
}
-static void sbr_reset(AACDecContext *ac, SpectralBandReplication *sbr)
+static void sbr_reset(void *logctx, SpectralBandReplication *sbr)
{
int err;
- err = sbr_make_f_master(ac, sbr, &sbr->spectrum_params);
+ err = sbr_make_f_master(logctx, sbr, &sbr->spectrum_params);
if (err >= 0)
- err = sbr_make_f_derived(ac, sbr);
+ err = sbr_make_f_derived(logctx, sbr);
if (err < 0) {
- av_log(ac->avctx, AV_LOG_ERROR,
+ av_log(logctx, AV_LOG_ERROR,
"SBR reset failed. Switching SBR to pure upsampling mode.\n");
sbr_turnoff(sbr);
}
@@ -1120,7 +1121,7 @@ int AAC_RENAME(ff_decode_sbr_extension)(AACDecContext *ac, SpectralBandReplicati
num_sbr_bits += read_sbr_header(sbr, gb);
if (sbr->reset)
- sbr_reset(ac, sbr);
+ sbr_reset(ac->avctx, sbr);
if (sbr->start)
num_sbr_bits += read_sbr_data(ac, sbr, gb, id_aac);
@@ -1268,7 +1269,7 @@ static int sbr_lf_gen(AACDecContext *ac, SpectralBandReplication *sbr,
}
/// High Frequency Generator (14496-3 sp04 p215)
-static int sbr_hf_gen(AACDecContext *ac, SpectralBandReplication *sbr,
+static int sbr_hf_gen(void *logctx, 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,
@@ -1285,7 +1286,7 @@ static int sbr_hf_gen(AACDecContext *ac, SpectralBandReplication *sbr,
g--;
if (g < 0) {
- av_log(ac->avctx, AV_LOG_ERROR,
+ av_log(logctx, AV_LOG_ERROR,
"ERROR : no subband found for frequency %d\n", k);
return -1;
}
@@ -1342,7 +1343,7 @@ static int sbr_x_gen(SpectralBandReplication *sbr, INTFLOAT X[2][38][64],
/** High Frequency Adjustment (14496-3 sp04 p217) and Mapping
* (14496-3 sp04 p217)
*/
-static int sbr_mapping(AACDecContext *ac, SpectralBandReplication *sbr,
+static int sbr_mapping(void *logctx, SpectralBandReplication *sbr,
SBRData *ch_data, int e_a[2])
{
int e, i, m;
@@ -1354,7 +1355,7 @@ static int sbr_mapping(AACDecContext *ac, SpectralBandReplication *sbr,
int k;
if (sbr->kx[1] != table[0]) {
- av_log(ac->avctx, AV_LOG_ERROR, "kx != f_table{high,low}[0]. "
+ av_log(logctx, AV_LOG_ERROR, "kx != f_table{high,low}[0]. "
"Derived frequency tables were not regenerated.\n");
sbr_turnoff(sbr);
return AVERROR_BUG;
@@ -1502,7 +1503,7 @@ void AAC_RENAME(ff_sbr_apply)(AACDecContext *ac, SpectralBandReplication *sbr, i
(const INTFLOAT (*)[40][2]) sbr->X_low, sbr->k[0]);
sbr_chirp(sbr, &sbr->data[ch]);
av_assert0(sbr->data[ch].bs_num_env > 0);
- sbr_hf_gen(ac, sbr, sbr->X_high,
+ sbr_hf_gen(ac->avctx, sbr, sbr->X_high,
(const INTFLOAT (*)[40][2]) sbr->X_low,
(const INTFLOAT (*)[2]) sbr->alpha0,
(const INTFLOAT (*)[2]) sbr->alpha1,
@@ -1510,7 +1511,7 @@ void AAC_RENAME(ff_sbr_apply)(AACDecContext *ac, SpectralBandReplication *sbr, i
sbr->data[ch].bs_num_env);
// hf_adj
- err = sbr_mapping(ac, sbr, &sbr->data[ch], sbr->data[ch].e_a);
+ err = sbr_mapping(ac->avctx, sbr, &sbr->data[ch], sbr->data[ch].e_a);
if (!err) {
sbr_env_estimate(sbr->e_curr, sbr->X_high, sbr, &sbr->data[ch]);
sbr_gain_calc(sbr, &sbr->data[ch], sbr->data[ch].e_a);
--
2.40.1
More information about the ffmpeg-devel
mailing list