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

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
29 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA29 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
30 */30 */
31 31
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
32#include <limits.h>36#include <limits.h>
33#include <stddef.h>37#include <stddef.h>
34 38
@@ -184,8 +188,8 @@ static int frame_configure_elements(AVCodecContext *avctx) · 149 unmodified lines
184 for (id = 0; id < MAX_ELEM_ID; id++) {188 for (id = 0; id < MAX_ELEM_ID; id++) {
185 ChannelElement *che = ac->che[type][id];189 ChannelElement *che = ac->che[type][id];
186 if (che) {190 if (che) {
187 che->ch[0].AAC_RENAME(output) = che->ch[0].AAC_RENAME(ret_buf);191 che->ch[0].output = che->ch[0].ret_buf;
188 che->ch[1].AAC_RENAME(output) = che->ch[1].AAC_RENAME(ret_buf);192 che->ch[1].output = che->ch[1].ret_buf;
189 }193 }
190 }194 }
191 }195 }
@@ -202,7 +206,7 @@ static int frame_configure_elements(AVCodecContext *avctx) · 10 unmodified lines
202 /* map output channel pointers to AVFrame data */206 /* map output channel pointers to AVFrame data */
203 for (ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {207 for (ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
204 if (ac->output_element[ch])208 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];
206 }210 }
207 211
208 return 0;212 return 0;
@@ -1107,9 +1111,6 @@ static int sample_rate_idx (int rate) · 898 unmodified lines
1107 1111
1108static av_cold void aac_static_table_init(void)1112static av_cold void aac_static_table_init(void)
1109{1113{
1110 ff_aac_sbr_init();
1111 ff_aac_sbr_init_fixed();
1112
1113 ff_aacdec_common_init_once();1114 ff_aacdec_common_init_once();
1114}1115}
1115static AVOnce aac_table_init = AV_ONCE_INIT;1116static AVOnce aac_table_init = AV_ONCE_INIT;
@@ -1118,8 +1119,8 @@ static av_cold int decode_close(AVCodecContext *avctx) · 2 unmodified lines
1118{1119{
1119 AACDecContext *ac = avctx->priv_data;1120 AACDecContext *ac = avctx->priv_data;
1120 int is_fixed = ac->is_fixed;1121 int is_fixed = ac->is_fixed;
1121 void (*sbr_close)(ChannelElement *che) = is_fixed ? RENAME_FIXED(ff_aac_sbr_ctx_close)1122 void (*sbr_close)(ChannelElement *che) = is_fixed ? ff_aac_sbr_ctx_close_fixed :
1122 : ff_aac_sbr_ctx_close;1123 ff_aac_sbr_ctx_close;
1123 1124
1124 for (int type = 0; type < FF_ARRAY_ELEMS(ac->che); type++) {1125 for (int type = 0; type < FF_ARRAY_ELEMS(ac->che); type++) {
1125 for (int i = 0; i < MAX_ELEM_ID; i++) {1126 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
2069 }2070 }
2070 }2071 }
2071 if (che->ch[0].tns.present)2072 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,
2073 &che->ch[0].tns, &che->ch[0].ics, 1);2074 &che->ch[0].tns, &che->ch[0].ics, 1);
2074 if (che->ch[1].tns.present)2075 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,
2076 &che->ch[1].tns, &che->ch[1].ics, 1);2077 &che->ch[1].tns, &che->ch[1].ics, 1);
2077 if (type <= TYPE_CPE)2078 if (type <= TYPE_CPE)
2078 apply_channel_coupling(ac, che, type, i, BETWEEN_TNS_AND_IMDCT, ac->dsp.apply_dependent_coupling);2079 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
2088 if (ac->oc[1].m4ac.sbr > 0) {2089 if (ac->oc[1].m4ac.sbr > 0) {
2089 if (ac->is_fixed)2090 if (ac->is_fixed)
2090 ff_aac_sbr_apply_fixed(ac, che, type,2091 ff_aac_sbr_apply_fixed(ac, che, type,
2091 che->ch[0].AAC_RENAME(output),2092 (void *)che->ch[0].output,
2092 che->ch[1].AAC_RENAME(output));2093 (void *)che->ch[1].output);
2093 else2094 else
2094 ff_aac_sbr_apply(ac, che, type,2095 ff_aac_sbr_apply(ac, che, type,
2095 che->ch[0].AAC_RENAME(output),2096 (void *)che->ch[0].output,
2096 che->ch[1].AAC_RENAME(output));2097 (void *)che->ch[1].output);
2097 }2098 }
2098 }2099 }
2099 if (type <= TYPE_CCE)2100 if (type <= TYPE_CCE)
libavcodec/aac/aacdec_fixed.c+3−0
@@ -41,6 +41,7 @@ · 40 unmodified lines
41#include "libavcodec/sinewin_fixed_tablegen.h"41#include "libavcodec/sinewin_fixed_tablegen.h"
42#include "libavcodec/kbdwin.h"42#include "libavcodec/kbdwin.h"
43#include "libavcodec/cbrt_data.h"43#include "libavcodec/cbrt_data.h"
44#include "libavcodec/aacsbr.h"
44 45
45DECLARE_ALIGNED(32, static INTFLOAT, AAC_RENAME2(aac_kbd_long_1024))[1024];46DECLARE_ALIGNED(32, static INTFLOAT, AAC_RENAME2(aac_kbd_long_1024))[1024];
46DECLARE_ALIGNED(32, static INTFLOAT, AAC_RENAME2(aac_kbd_short_128))[128];47DECLARE_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
57 AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(aac_kbd_long_960), 4.0, 960);58 AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(aac_kbd_long_960), 4.0, 960);
58 AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(aac_kbd_short_120), 6.0, 120);59 AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(aac_kbd_short_120), 6.0, 120);
59 60
61 AAC_RENAME(ff_aac_sbr_init)();
62
60 init_sine_windows_fixed();63 init_sine_windows_fixed();
61}64}
62 65
libavcodec/aac/aacdec_float.c+3−0
@@ -42,6 +42,7 @@ · 41 unmodified lines
42#include "libavcodec/kbdwin.h"42#include "libavcodec/kbdwin.h"
43#include "libavcodec/cbrt_data.h"43#include "libavcodec/cbrt_data.h"
44#include "libavutil/mathematics.h"44#include "libavutil/mathematics.h"
45#include "libavcodec/aacsbr.h"
45 46
46DECLARE_ALIGNED(32, static float, sine_120)[120];47DECLARE_ALIGNED(32, static float, sine_120)[120];
47DECLARE_ALIGNED(32, static float, sine_960)[960];48DECLARE_ALIGNED(32, static float, sine_960)[960];
@@ -61,6 +62,8 @@ static void init_tables_float_fn(void) · 13 unmodified lines
61 AAC_RENAME(ff_sine_window_init)(AAC_RENAME(sine_960), 960);62 AAC_RENAME(ff_sine_window_init)(AAC_RENAME(sine_960), 960);
62 AAC_RENAME(ff_sine_window_init)(AAC_RENAME(sine_120), 120);63 AAC_RENAME(ff_sine_window_init)(AAC_RENAME(sine_120), 120);
63 AAC_RENAME(ff_init_ff_sine_windows)(9);64 AAC_RENAME(ff_init_ff_sine_windows)(9);
65
66 AAC_RENAME(ff_aac_sbr_init)();
64}67}
65 68
66static int init(AACDecContext *ac)69static 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