History

aacdec: initialize float/fixed SBR tables only when either is needed

Lynne committed 2 years ago

Commit e3650881 parent 176c9223 files · +21 −14Browse files

Showing the changes to libavcodec (3 of 3 files). Show all

Unified · Split

3 files
  1. libavcodec/aac/aacdec.c +15 −14
  2. libavcodec/aac/aacdec_fixed.c +3 −0
  3. libavcodec/aac/aacdec_float.c +3 −0
libavcodec/aac/aacdec.c+15−14
@@ -29,6 +29,10 @@ · 28 unmodified lines
2929 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3030 */
3131
32+/* We use several quantization functions here (Q31, Q30),
33+ * for which we need this to be defined for them to work as expected. */
34+#define USE_FIXED 1
35+
3236 #include <limits.h>
3337 #include <stddef.h>
3438
@@ -184,8 +188,8 @@ static int frame_configure_elements(AVCodecContext *avctx) · 149 unmodified lines
184188 for (id = 0; id < MAX_ELEM_ID; id++) {
185189 ChannelElement *che = ac->che[type][id];
186190 if (che) {
187− che->ch[0].AAC_RENAME(output) = che->ch[0].AAC_RENAME(ret_buf);
188− che->ch[1].AAC_RENAME(output) = che->ch[1].AAC_RENAME(ret_buf);
191+ che->ch[0].output = che->ch[0].ret_buf;
192+ che->ch[1].output = che->ch[1].ret_buf;
189193 }
190194 }
191195 }
@@ -202,7 +206,7 @@ static int frame_configure_elements(AVCodecContext *avctx) · 10 unmodified lines
202206 /* map output channel pointers to AVFrame data */
203207 for (ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
204208 if (ac->output_element[ch])
205− ac->output_element[ch]->AAC_RENAME(output) = (INTFLOAT *)ac->frame->extended_data[ch];
209+ ac->output_element[ch]->output = (void *)ac->frame->extended_data[ch];
206210 }
207211
208212 return 0;
@@ -1107,9 +1111,6 @@ static int sample_rate_idx (int rate) · 898 unmodified lines
11071111
11081112 static av_cold void aac_static_table_init(void)
11091113 {
1110− ff_aac_sbr_init();
1111− ff_aac_sbr_init_fixed();
1112−
11131114 ff_aacdec_common_init_once();
11141115 }
11151116 static AVOnce aac_table_init = AV_ONCE_INIT;
@@ -1118,8 +1119,8 @@ static av_cold int decode_close(AVCodecContext *avctx) · 2 unmodified lines
11181119 {
11191120 AACDecContext *ac = avctx->priv_data;
11201121 int is_fixed = ac->is_fixed;
1121− void (*sbr_close)(ChannelElement *che) = is_fixed ? RENAME_FIXED(ff_aac_sbr_ctx_close)
1122− : ff_aac_sbr_ctx_close;
1122+ void (*sbr_close)(ChannelElement *che) = is_fixed ? ff_aac_sbr_ctx_close_fixed :
1123+ ff_aac_sbr_ctx_close;
11231124
11241125 for (int type = 0; type < FF_ARRAY_ELEMS(ac->che); type++) {
11251126 for (int i = 0; i < MAX_ELEM_ID; i++) {
@@ -2069,10 +2070,10 @@ static void spectral_to_sample(AACDecContext *ac, int samples) · 943 unmodified lines
20692070 }
20702071 }
20712072 if (che->ch[0].tns.present)
2072− ac->dsp.apply_tns(che->ch[0].AAC_RENAME(coeffs),
2073+ ac->dsp.apply_tns(che->ch[0].coeffs,
20732074 &che->ch[0].tns, &che->ch[0].ics, 1);
20742075 if (che->ch[1].tns.present)
2075− ac->dsp.apply_tns(che->ch[1].AAC_RENAME(coeffs),
2076+ ac->dsp.apply_tns(che->ch[1].coeffs,
20762077 &che->ch[1].tns, &che->ch[1].ics, 1);
20772078 if (type <= TYPE_CPE)
20782079 apply_channel_coupling(ac, che, type, i, BETWEEN_TNS_AND_IMDCT, ac->dsp.apply_dependent_coupling);
@@ -2088,12 +2089,12 @@ static void spectral_to_sample(AACDecContext *ac, int samples) · 9 unmodified lines
20882089 if (ac->oc[1].m4ac.sbr > 0) {
20892090 if (ac->is_fixed)
20902091 ff_aac_sbr_apply_fixed(ac, che, type,
2091− che->ch[0].AAC_RENAME(output),
2092− che->ch[1].AAC_RENAME(output));
2092+ (void *)che->ch[0].output,
2093+ (void *)che->ch[1].output);
20932094 else
20942095 ff_aac_sbr_apply(ac, che, type,
2095− che->ch[0].AAC_RENAME(output),
2096− che->ch[1].AAC_RENAME(output));
2096+ (void *)che->ch[0].output,
2097+ (void *)che->ch[1].output);
20972098 }
20982099 }
20992100 if (type <= TYPE_CCE)
libavcodec/aac/aacdec_fixed.c+3−0
@@ -41,6 +41,7 @@ · 40 unmodified lines
4141 #include "libavcodec/sinewin_fixed_tablegen.h"
4242 #include "libavcodec/kbdwin.h"
4343 #include "libavcodec/cbrt_data.h"
44+#include "libavcodec/aacsbr.h"
4445
4546 DECLARE_ALIGNED(32, static INTFLOAT, AAC_RENAME2(aac_kbd_long_1024))[1024];
4647 DECLARE_ALIGNED(32, static INTFLOAT, AAC_RENAME2(aac_kbd_short_128))[128];
@@ -57,6 +58,8 @@ static void init_tables_fixed_fn(void) · 10 unmodified lines
5758 AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(aac_kbd_long_960), 4.0, 960);
5859 AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(aac_kbd_short_120), 6.0, 120);
5960
61+ AAC_RENAME(ff_aac_sbr_init)();
62+
6063 init_sine_windows_fixed();
6164 }
6265
libavcodec/aac/aacdec_float.c+3−0
@@ -42,6 +42,7 @@ · 41 unmodified lines
4242 #include "libavcodec/kbdwin.h"
4343 #include "libavcodec/cbrt_data.h"
4444 #include "libavutil/mathematics.h"
45+#include "libavcodec/aacsbr.h"
4546
4647 DECLARE_ALIGNED(32, static float, sine_120)[120];
4748 DECLARE_ALIGNED(32, static float, sine_960)[960];
@@ -61,6 +62,8 @@ static void init_tables_float_fn(void) · 13 unmodified lines
6162 AAC_RENAME(ff_sine_window_init)(AAC_RENAME(sine_960), 960);
6263 AAC_RENAME(ff_sine_window_init)(AAC_RENAME(sine_120), 120);
6364 AAC_RENAME(ff_init_ff_sine_windows)(9);
65+
66+ AAC_RENAME(ff_aac_sbr_init)();
6467 }
6568
6669 static int init(AACDecContext *ac)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t