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