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
50#include "aac/aacdec_tab.h"50#include "aac/aacdec_tab.h"
51#include "adts_header.h"51#include "adts_header.h"
52#include "cbrt_data.h"52#include "cbrt_data.h"
53#include "sbr.h"
54#include "aacsbr.h"53#include "aacsbr.h"
55#include "mpeg4audio.h"54#include "mpeg4audio.h"
56#include "profiles.h"55#include "profiles.h"
libavcodec/aacdec_fixed.c+0−1
@@ -75,7 +75,6 @@ · 74 unmodified lines
75#include "aac/aacdec_tab.h"75#include "aac/aacdec_tab.h"
76#include "adts_header.h"76#include "adts_header.h"
77#include "cbrt_data.h"77#include "cbrt_data.h"
78#include "sbr.h"
79#include "aacsbr.h"78#include "aacsbr.h"
80#include "mpeg4audio.h"79#include "mpeg4audio.h"
81#include "profiles.h"80#include "profiles.h"
libavcodec/aacdec_template.c+5−5
@@ -137,7 +137,7 @@ static av_cold int che_configure(AACDecContext *ac, · 136 unmodified lines
137 int ret;137 int ret;
138 if (!(ac->che[type][id] = av_mallocz(sizeof(ChannelElement))))138 if (!(ac->che[type][id] = av_mallocz(sizeof(ChannelElement))))
139 return AVERROR(ENOMEM);139 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);
141 if (ret < 0)141 if (ret < 0)
142 return ret;142 return ret;
143 }143 }
@@ -154,7 +154,7 @@ static av_cold int che_configure(AACDecContext *ac, · 10 unmodified lines
154 }154 }
155 } else {155 } else {
156 if (ac->che[type][id])156 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]);
158 av_freep(&ac->che[type][id]);158 av_freep(&ac->che[type][id]);
159 }159 }
160 return 0;160 return 0;
@@ -2461,7 +2461,7 @@ static int decode_extension_payload(AACDecContext *ac, GetBitContext *gb, int cn · 2300 unmodified lines
2461 ac->oc[1].m4ac.sbr = 1;2461 ac->oc[1].m4ac.sbr = 1;
2462 ac->avctx->profile = AV_PROFILE_AAC_HE;2462 ac->avctx->profile = AV_PROFILE_AAC_HE;
2463 }2463 }
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);
2465 if (ac->oc[1].m4ac.ps == 1 && !ac->warned_he_aac_mono) {2465 if (ac->oc[1].m4ac.ps == 1 && !ac->warned_he_aac_mono) {
2466 av_log(ac->avctx, AV_LOG_VERBOSE, "Treating HE-AAC mono as stereo.\n");2466 av_log(ac->avctx, AV_LOG_VERBOSE, "Treating HE-AAC mono as stereo.\n");
2467 ac->warned_he_aac_mono = 1;2467 ac->warned_he_aac_mono = 1;
@@ -2942,7 +2942,7 @@ static void spectral_to_sample(AACDecContext *ac, int samples) · 474 unmodified lines
2942 ac->update_ltp(ac, &che->ch[1]);2942 ac->update_ltp(ac, &che->ch[1]);
2943 }2943 }
2944 if (ac->oc[1].m4ac.sbr > 0) {2944 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);
2946 }2946 }
2947 }2947 }
2948 if (type <= TYPE_CCE)2948 if (type <= TYPE_CCE)
@@ -3382,7 +3382,7 @@ static av_cold int aac_decode_close(AVCodecContext *avctx) · 433 unmodified lines
3382 for (i = 0; i < MAX_ELEM_ID; i++) {3382 for (i = 0; i < MAX_ELEM_ID; i++) {
3383 for (type = 0; type < 4; type++) {3383 for (type = 0; type < 4; type++) {
3384 if (ac->che[type][i])3384 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]);
3386 av_freep(&ac->che[type][i]);3386 av_freep(&ac->che[type][i]);
3387 }3387 }
3388 }3388 }
libavcodec/aacsbr.h+7−11
@@ -30,14 +30,12 @@ · 29 unmodified lines
30#define AVCODEC_AACSBR_H30#define AVCODEC_AACSBR_H
31 31
32#include "get_bits.h"32#include "get_bits.h"
33#include "aacdec.h"
33#include "aac_defines.h"34#include "aac_defines.h"
34#include "sbr.h"
35 35
36#define ENVELOPE_ADJUSTMENT_OFFSET 236#define ENVELOPE_ADJUSTMENT_OFFSET 2
37#define NOISE_FLOOR_OFFSET 637#define NOISE_FLOOR_OFFSET 6
38 38
39struct AACDecContext;
40
41/**39/**
42 * SBR VLC tables40 * SBR VLC tables
43 */41 */
@@ -71,16 +69,14 @@ enum { · 27 unmodified lines
71/** Initialize SBR. */69/** Initialize SBR. */
72void AAC_RENAME(ff_aac_sbr_init)(void);70void AAC_RENAME(ff_aac_sbr_init)(void);
73/** Initialize one SBR context. */71/** Initialize one SBR context. */
74int AAC_RENAME(ff_aac_sbr_ctx_init)(struct AACDecContext *ac, SpectralBandReplication *sbr, int id_aac);72int AAC_RENAME(ff_aac_sbr_ctx_init)(AACDecContext *ac, ChannelElement *che, int id_aac);
75/** Close one SBR context. */73/** Close one SBR context. */
76void AAC_RENAME(ff_aac_sbr_ctx_close)(SpectralBandReplication *sbr);74void AAC_RENAME(ff_aac_sbr_ctx_close)(ChannelElement *che);
77/** Decode one SBR element. */75/** Decode one SBR element. */
78int AAC_RENAME(ff_decode_sbr_extension)(struct AACDecContext *ac, SpectralBandReplication *sbr,76int AAC_RENAME(ff_aac_sbr_decode_extension)(AACDecContext *ac, ChannelElement *che,
79 GetBitContext *gb, int crc, int cnt, int id_aac);77 GetBitContext *gb, int crc, int cnt, int id_aac);
80/** Apply one SBR element to one AAC element. */78/** Apply one SBR element to one AAC element. */
81void AAC_RENAME(ff_sbr_apply)(struct AACDecContext *ac, SpectralBandReplication *sbr, int id_aac,79void AAC_RENAME(ff_aac_sbr_apply)(AACDecContext *ac, ChannelElement *che,
82 INTFLOAT* L, INTFLOAT *R);80 int id_aac, INTFLOAT* L, INTFLOAT* R);
83
84void ff_aacsbr_func_ptr_init_mips(AACSBRContext *c);
85 81
86#endif /* AVCODEC_AACSBR_H */82#endif /* AVCODEC_AACSBR_H */
libavcodec/aacsbr_template.c+11−6
@@ -65,8 +65,9 @@ static void sbr_turnoff(SpectralBandReplication *sbr) { · 64 unmodified lines
65 memset(&sbr->spectrum_params, -1, sizeof(SpectrumParameters));65 memset(&sbr->spectrum_params, -1, sizeof(SpectrumParameters));
66}66}
67 67
68av_cold int AAC_RENAME(ff_aac_sbr_ctx_init)(AACDecContext *ac, SpectralBandReplication *sbr, int id_aac)68av_cold int AAC_RENAME(ff_aac_sbr_ctx_init)(AACDecContext *ac, ChannelElement *che, int id_aac)
69{69{
70 SpectralBandReplication *sbr = &che->sbr;
70 int ret;71 int ret;
71 float scale;72 float scale;
72 73
@@ -103,8 +104,9 @@ av_cold int AAC_RENAME(ff_aac_sbr_ctx_init)(AACDecContext *ac, SpectralBandRepli · 30 unmodified lines
103 return 0;104 return 0;
104}105}
105 106
106av_cold void AAC_RENAME(ff_aac_sbr_ctx_close)(SpectralBandReplication *sbr)107av_cold void AAC_RENAME(ff_aac_sbr_ctx_close)(ChannelElement *che)
107{108{
109 SpectralBandReplication *sbr = &che->sbr;
108 av_tx_uninit(&sbr->mdct);110 av_tx_uninit(&sbr->mdct);
109 av_tx_uninit(&sbr->mdct_ana);111 av_tx_uninit(&sbr->mdct_ana);
110}112}
@@ -1091,9 +1093,11 @@ static void sbr_reset(AACDecContext *ac, SpectralBandReplication *sbr) · 980 unmodified lines
1091 *1093 *
1092 * @return Returns number of bytes consumed from the TYPE_FIL element.1094 * @return Returns number of bytes consumed from the TYPE_FIL element.
1093 */1095 */
1094int AAC_RENAME(ff_decode_sbr_extension)(AACDecContext *ac, SpectralBandReplication *sbr,1096int AAC_RENAME(ff_aac_sbr_decode_extension)(AACDecContext *ac, ChannelElement *che,
1095 GetBitContext *gb_host, int crc, int cnt, int id_aac)1097 GetBitContext *gb_host, int crc,
1098 int cnt, int id_aac)
1096{1099{
1100 SpectralBandReplication *sbr = &che->sbr;
1097 unsigned int num_sbr_bits = 0, num_align_bits;1101 unsigned int num_sbr_bits = 0, num_align_bits;
1098 unsigned bytes_read;1102 unsigned bytes_read;
1099 GetBitContext gbc = *gb_host, *gb = &gbc;1103 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
1457 }1461 }
1458}1462}
1459 1463
1460void AAC_RENAME(ff_sbr_apply)(AACDecContext *ac, SpectralBandReplication *sbr, int id_aac,1464void AAC_RENAME(ff_aac_sbr_apply)(AACDecContext *ac, ChannelElement *che,
1461 INTFLOAT* L, INTFLOAT* R)1465 int id_aac, INTFLOAT* L, INTFLOAT* R)
1462{1466{
1467 SpectralBandReplication *sbr = &che->sbr;
1463 int downsampled = ac->oc[1].m4ac.ext_sample_rate < sbr->sample_rate;1468 int downsampled = ac->oc[1].m4ac.ext_sample_rate < sbr->sample_rate;
1464 int ch;1469 int ch;
1465 int nch = (id_aac == TYPE_CPE) ? 2 : 1;1470 int nch = (id_aac == TYPE_CPE) ? 2 : 1;
libavcodec/mips/aacsbr_mips.c+1−0
@@ -53,6 +53,7 @@ · 52 unmodified lines
53 53
54#include "libavcodec/aacdec.h"54#include "libavcodec/aacdec.h"
55#include "libavcodec/aacsbr.h"55#include "libavcodec/aacsbr.h"
56#include "libavcodec/sbr.h"
56#include "libavutil/mem_internal.h"57#include "libavutil/mem_internal.h"
57#include "libavutil/mips/asmdefs.h"58#include "libavutil/mips/asmdefs.h"
58 59
libavcodec/sbr.h+2−0
@@ -217,4 +217,6 @@ struct SpectralBandReplication { · 216 unmodified lines
217 AACSBRContext c;217 AACSBRContext c;
218};218};
219 219
220void ff_aacsbr_func_ptr_init_mips(AACSBRContext *c);
221
220#endif /* AVCODEC_SBR_H */222#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