History

avcodec/aacsbr: Make ff_aac_sbr_* funcs accept ChannelElement*

Each ChannelElement contains exactly one SpectralBandReplication structure; the latter structure contains lots of buffers whose size depend upon USE_FIXED (i.e. AAC_FLOAT arrays). This complicates deduplicating the parts of the AAC decoder that are duplicated between the fixed-point and the floating point decoder. In order to fix this, the SpectralBandReplication structure will be moved from the part of ChannelElement visible to the common code. Therefore the ff_aac_sbr_* functions are ported to accept a ChannelElement*; they will then have to translate that to the corresponding SpectralBandReplication* themselves (which is possible, because there are floating-point and fixed-point versions of these functions). While just at it, also ensure that these functions are properly namespaced.

Andreas Rheinhardt committed 2 years ago

Commit 6975d961 parent 3600f757 files · +26 −24Browse files

Unified · Split

7 files
  1. libavcodec/aacdec.c +0 −1
  2. libavcodec/aacdec_fixed.c +0 −1
  3. libavcodec/aacdec_template.c +5 −5
  4. libavcodec/aacsbr.h +7 −11
  5. libavcodec/aacsbr_template.c +11 −6
  6. libavcodec/mips/aacsbr_mips.c +1 −0
  7. libavcodec/sbr.h +2 −0
libavcodec/aacdec.c+0−1
@@ -50,7 +50,6 @@ · 49 unmodified lines
5050 #include "aac/aacdec_tab.h"
5151 #include "adts_header.h"
5252 #include "cbrt_data.h"
53−#include "sbr.h"
5453 #include "aacsbr.h"
5554 #include "mpeg4audio.h"
5655 #include "profiles.h"
libavcodec/aacdec_fixed.c+0−1
@@ -75,7 +75,6 @@ · 74 unmodified lines
7575 #include "aac/aacdec_tab.h"
7676 #include "adts_header.h"
7777 #include "cbrt_data.h"
78−#include "sbr.h"
7978 #include "aacsbr.h"
8079 #include "mpeg4audio.h"
8180 #include "profiles.h"
libavcodec/aacdec_template.c+5−5
@@ -137,7 +137,7 @@ static av_cold int che_configure(AACDecContext *ac, · 136 unmodified lines
137137 int ret;
138138 if (!(ac->che[type][id] = av_mallocz(sizeof(ChannelElement))))
139139 return AVERROR(ENOMEM);
140− ret = AAC_RENAME(ff_aac_sbr_ctx_init)(ac, &ac->che[type][id]->sbr, type);
140+ ret = AAC_RENAME(ff_aac_sbr_ctx_init)(ac, ac->che[type][id], type);
141141 if (ret < 0)
142142 return ret;
143143 }
@@ -154,7 +154,7 @@ static av_cold int che_configure(AACDecContext *ac, · 10 unmodified lines
154154 }
155155 } else {
156156 if (ac->che[type][id])
157− AAC_RENAME(ff_aac_sbr_ctx_close)(&ac->che[type][id]->sbr);
157+ AAC_RENAME(ff_aac_sbr_ctx_close)(ac->che[type][id]);
158158 av_freep(&ac->che[type][id]);
159159 }
160160 return 0;
@@ -2461,7 +2461,7 @@ static int decode_extension_payload(AACDecContext *ac, GetBitContext *gb, int cn · 2300 unmodified lines
24612461 ac->oc[1].m4ac.sbr = 1;
24622462 ac->avctx->profile = AV_PROFILE_AAC_HE;
24632463 }
2464− res = AAC_RENAME(ff_decode_sbr_extension)(ac, &che->sbr, gb, crc_flag, cnt, elem_type);
2464+ res = AAC_RENAME(ff_aac_sbr_decode_extension)(ac, che, gb, crc_flag, cnt, elem_type);
24652465 if (ac->oc[1].m4ac.ps == 1 && !ac->warned_he_aac_mono) {
24662466 av_log(ac->avctx, AV_LOG_VERBOSE, "Treating HE-AAC mono as stereo.\n");
24672467 ac->warned_he_aac_mono = 1;
@@ -2942,7 +2942,7 @@ static void spectral_to_sample(AACDecContext *ac, int samples) · 474 unmodified lines
29422942 ac->update_ltp(ac, &che->ch[1]);
29432943 }
29442944 if (ac->oc[1].m4ac.sbr > 0) {
2945− AAC_RENAME(ff_sbr_apply)(ac, &che->sbr, type, che->ch[0].ret, che->ch[1].ret);
2945+ AAC_RENAME(ff_aac_sbr_apply)(ac, che, type, che->ch[0].ret, che->ch[1].ret);
29462946 }
29472947 }
29482948 if (type <= TYPE_CCE)
@@ -3382,7 +3382,7 @@ static av_cold int aac_decode_close(AVCodecContext *avctx) · 433 unmodified lines
33823382 for (i = 0; i < MAX_ELEM_ID; i++) {
33833383 for (type = 0; type < 4; type++) {
33843384 if (ac->che[type][i])
3385− AAC_RENAME(ff_aac_sbr_ctx_close)(&ac->che[type][i]->sbr);
3385+ AAC_RENAME(ff_aac_sbr_ctx_close)(ac->che[type][i]);
33863386 av_freep(&ac->che[type][i]);
33873387 }
33883388 }
libavcodec/aacsbr.h+7−11
@@ -30,14 +30,12 @@ · 29 unmodified lines
3030 #define AVCODEC_AACSBR_H
3131
3232 #include "get_bits.h"
33+#include "aacdec.h"
3334 #include "aac_defines.h"
34−#include "sbr.h"
3535
3636 #define ENVELOPE_ADJUSTMENT_OFFSET 2
3737 #define NOISE_FLOOR_OFFSET 6
3838
39−struct AACDecContext;
40−
4139 /**
4240 * SBR VLC tables
4341 */
@@ -71,16 +69,14 @@ enum { · 27 unmodified lines
7169 /** Initialize SBR. */
7270 void AAC_RENAME(ff_aac_sbr_init)(void);
7371 /** Initialize one SBR context. */
74−int AAC_RENAME(ff_aac_sbr_ctx_init)(struct AACDecContext *ac, SpectralBandReplication *sbr, int id_aac);
72+int AAC_RENAME(ff_aac_sbr_ctx_init)(AACDecContext *ac, ChannelElement *che, int id_aac);
7573 /** Close one SBR context. */
76−void AAC_RENAME(ff_aac_sbr_ctx_close)(SpectralBandReplication *sbr);
74+void AAC_RENAME(ff_aac_sbr_ctx_close)(ChannelElement *che);
7775 /** Decode one SBR element. */
78−int AAC_RENAME(ff_decode_sbr_extension)(struct AACDecContext *ac, SpectralBandReplication *sbr,
79− GetBitContext *gb, int crc, int cnt, int id_aac);
76+int AAC_RENAME(ff_aac_sbr_decode_extension)(AACDecContext *ac, ChannelElement *che,
77+ GetBitContext *gb, int crc, int cnt, int id_aac);
8078 /** Apply one SBR element to one AAC element. */
81−void AAC_RENAME(ff_sbr_apply)(struct AACDecContext *ac, SpectralBandReplication *sbr, int id_aac,
82− INTFLOAT* L, INTFLOAT *R);
83−
84−void ff_aacsbr_func_ptr_init_mips(AACSBRContext *c);
79+void AAC_RENAME(ff_aac_sbr_apply)(AACDecContext *ac, ChannelElement *che,
80+ int id_aac, INTFLOAT* L, INTFLOAT* R);
8581
8682 #endif /* AVCODEC_AACSBR_H */
libavcodec/aacsbr_template.c+11−6
@@ -65,8 +65,9 @@ static void sbr_turnoff(SpectralBandReplication *sbr) { · 64 unmodified lines
6565 memset(&sbr->spectrum_params, -1, sizeof(SpectrumParameters));
6666 }
6767
68−av_cold int AAC_RENAME(ff_aac_sbr_ctx_init)(AACDecContext *ac, SpectralBandReplication *sbr, int id_aac)
68+av_cold int AAC_RENAME(ff_aac_sbr_ctx_init)(AACDecContext *ac, ChannelElement *che, int id_aac)
6969 {
70+ SpectralBandReplication *sbr = &che->sbr;
7071 int ret;
7172 float scale;
7273
@@ -103,8 +104,9 @@ av_cold int AAC_RENAME(ff_aac_sbr_ctx_init)(AACDecContext *ac, SpectralBandRepli · 30 unmodified lines
103104 return 0;
104105 }
105106
106−av_cold void AAC_RENAME(ff_aac_sbr_ctx_close)(SpectralBandReplication *sbr)
107+av_cold void AAC_RENAME(ff_aac_sbr_ctx_close)(ChannelElement *che)
107108 {
109+ SpectralBandReplication *sbr = &che->sbr;
108110 av_tx_uninit(&sbr->mdct);
109111 av_tx_uninit(&sbr->mdct_ana);
110112 }
@@ -1091,9 +1093,11 @@ static void sbr_reset(AACDecContext *ac, SpectralBandReplication *sbr) · 980 unmodified lines
10911093 *
10921094 * @return Returns number of bytes consumed from the TYPE_FIL element.
10931095 */
1094−int AAC_RENAME(ff_decode_sbr_extension)(AACDecContext *ac, SpectralBandReplication *sbr,
1095− GetBitContext *gb_host, int crc, int cnt, int id_aac)
1096+int AAC_RENAME(ff_aac_sbr_decode_extension)(AACDecContext *ac, ChannelElement *che,
1097+ GetBitContext *gb_host, int crc,
1098+ int cnt, int id_aac)
10961099 {
1100+ SpectralBandReplication *sbr = &che->sbr;
10971101 unsigned int num_sbr_bits = 0, num_align_bits;
10981102 unsigned bytes_read;
10991103 GetBitContext gbc = *gb_host, *gb = &gbc;
@@ -1457,9 +1461,10 @@ static void sbr_env_estimate(AAC_FLOAT (*e_curr)[48], INTFLOAT X_high[64][40][2] · 357 unmodified lines
14571461 }
14581462 }
14591463
1460−void AAC_RENAME(ff_sbr_apply)(AACDecContext *ac, SpectralBandReplication *sbr, int id_aac,
1461− INTFLOAT* L, INTFLOAT* R)
1464+void AAC_RENAME(ff_aac_sbr_apply)(AACDecContext *ac, ChannelElement *che,
1465+ int id_aac, INTFLOAT* L, INTFLOAT* R)
14621466 {
1467+ SpectralBandReplication *sbr = &che->sbr;
14631468 int downsampled = ac->oc[1].m4ac.ext_sample_rate < sbr->sample_rate;
14641469 int ch;
14651470 int nch = (id_aac == TYPE_CPE) ? 2 : 1;
libavcodec/mips/aacsbr_mips.c+1−0
@@ -53,6 +53,7 @@ · 52 unmodified lines
5353
5454 #include "libavcodec/aacdec.h"
5555 #include "libavcodec/aacsbr.h"
56+#include "libavcodec/sbr.h"
5657 #include "libavutil/mem_internal.h"
5758 #include "libavutil/mips/asmdefs.h"
5859
libavcodec/sbr.h+2−0
@@ -217,4 +217,6 @@ struct SpectralBandReplication { · 216 unmodified lines
217217 AACSBRContext c;
218218 };
219219
220+void ff_aacsbr_func_ptr_init_mips(AACSBRContext *c);
221+
220222 #endif /* AVCODEC_SBR_H */

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