sizeof(PredictorState) is different for the floating-point and the fixed-point AAC decoders; this is an obstacle for deduplicating code between these decoders. So don't include this array in SingleChannelElement, instead add a union of pointers to the fixed-point PredictorState and the floating-point PredictorState. The actual arrays are part of the extended ChannelElement to be allocated by ff_aac_sbr_ctx_alloc_init(); it also sets the pointers.
Unified · Split
| @@ -30,9 +30,6 @@ · 29 unmodified lines | ||
| 30 | 30 | #ifndef AVCODEC_AAC_H |
| 31 | 31 | #define AVCODEC_AAC_H |
| 32 | 32 | |
| 33 | − | |
| 34 | −#include "aac_defines.h" | |
| 35 | − | |
| 36 | 33 | #define MAX_CHANNELS 64 |
| 37 | 34 | #define MAX_ELEM_ID 16 |
| 38 | 35 | |
| @@ -85,20 +82,6 @@ enum ChannelPosition { · 46 unmodified lines | ||
| 85 | 82 | AAC_CHANNEL_CC = 5, |
| 86 | 83 | }; |
| 87 | 84 | |
| 88 | −/** | |
| 89 | − * Predictor State | |
| 90 | − */ | |
| 91 | −typedef struct PredictorState { | |
| 92 | − AAC_FLOAT cor0; | |
| 93 | − AAC_FLOAT cor1; | |
| 94 | − AAC_FLOAT var0; | |
| 95 | − AAC_FLOAT var1; | |
| 96 | − AAC_FLOAT r0; | |
| 97 | − AAC_FLOAT r1; | |
| 98 | − AAC_FLOAT k1; | |
| 99 | − AAC_FLOAT x_est; | |
| 100 | −} PredictorState; | |
| 101 | − | |
| 102 | 85 | #define MAX_PREDICTORS 672 |
| 103 | 86 | |
| 104 | 87 | #define SCALE_DIV_512 36 ///< scalefactor difference that corresponds to scale difference in 512 times |
| @@ -72,6 +72,20 @@ typedef int AAC_SIGNE; · 71 unmodified lines | ||
| 72 | 72 | 0x40000000) >> 31) |
| 73 | 73 | #define AAC_HALF_SUM(x, y) (((x) >> 1) + ((y) >> 1)) |
| 74 | 74 | |
| 75 | +/** | |
| 76 | + * Predictor State | |
| 77 | + */ | |
| 78 | +typedef struct PredictorStateFixed { | |
| 79 | + SoftFloat cor0; | |
| 80 | + SoftFloat cor1; | |
| 81 | + SoftFloat var0; | |
| 82 | + SoftFloat var1; | |
| 83 | + SoftFloat r0; | |
| 84 | + SoftFloat r1; | |
| 85 | + SoftFloat k1; | |
| 86 | + SoftFloat x_est; | |
| 87 | +} PredictorState; | |
| 88 | + | |
| 75 | 89 | #ifdef LPC_USE_FIXED |
| 76 | 90 | #error aac_defines.h must be included before lpc_functions.h for fixed point decoder |
| 77 | 91 | #endif |
| @@ -112,6 +126,20 @@ typedef unsigned AAC_SIGNE; · 34 unmodified lines | ||
| 112 | 126 | #define AAC_MSUB31_V3(x, y, z) ((x) - (y)) * (z) |
| 113 | 127 | #define AAC_HALF_SUM(x, y) ((x) + (y)) * 0.5f |
| 114 | 128 | |
| 129 | +/** | |
| 130 | + * Predictor State | |
| 131 | + */ | |
| 132 | +typedef struct PredictorState { | |
| 133 | + float cor0; | |
| 134 | + float cor1; | |
| 135 | + float var0; | |
| 136 | + float var1; | |
| 137 | + float r0; | |
| 138 | + float r1; | |
| 139 | + float k1; | |
| 140 | + float x_est; | |
| 141 | +} PredictorState; | |
| 142 | + | |
| 115 | 143 | #endif /* USE_FIXED */ |
| 116 | 144 | |
| 117 | 145 | #endif /* AVCODEC_AAC_DEFINES_H */ |
| @@ -140,7 +140,10 @@ typedef struct SingleChannelElement { · 139 unmodified lines | ||
| 140 | 140 | DECLARE_ALIGNED(32, INTFLOAT, saved)[1536]; ///< overlap |
| 141 | 141 | DECLARE_ALIGNED(32, INTFLOAT, ret_buf)[2048]; ///< PCM output buffer |
| 142 | 142 | DECLARE_ALIGNED(16, INTFLOAT, ltp_state)[3072]; ///< time signal for LTP |
| 143 | − PredictorState predictor_state[MAX_PREDICTORS]; | |
| 143 | + union { | |
| 144 | + struct PredictorStateFixed *RENAME_FIXED(predictor_state); | |
| 145 | + struct PredictorState *predictor_state; | |
| 146 | + }; | |
| 144 | 147 | INTFLOAT *ret; ///< PCM output |
| 145 | 148 | } SingleChannelElement; |
| 146 | 149 | |
| @@ -1942,7 +1942,7 @@ static void apply_prediction(AACDecContext *ac, SingleChannelElement *sce) · 1941 unmodified lines | ||
| 1942 | 1942 | int sfb, k; |
| 1943 | 1943 | |
| 1944 | 1944 | if (!sce->ics.predictor_initialized) { |
| 1945 | − reset_all_predictors(sce->predictor_state); | |
| 1945 | + reset_all_predictors(sce->AAC_RENAME(predictor_state)); | |
| 1946 | 1946 | sce->ics.predictor_initialized = 1; |
| 1947 | 1947 | } |
| 1948 | 1948 | |
| @@ -1953,16 +1953,16 @@ static void apply_prediction(AACDecContext *ac, SingleChannelElement *sce) · 4 unmodified lines | ||
| 1953 | 1953 | for (k = sce->ics.swb_offset[sfb]; |
| 1954 | 1954 | k < sce->ics.swb_offset[sfb + 1]; |
| 1955 | 1955 | k++) { |
| 1956 | − predict(&sce->predictor_state[k], &sce->coeffs[k], | |
| 1956 | + predict(&sce->AAC_RENAME(predictor_state)[k], &sce->coeffs[k], | |
| 1957 | 1957 | sce->ics.predictor_present && |
| 1958 | 1958 | sce->ics.prediction_used[sfb]); |
| 1959 | 1959 | } |
| 1960 | 1960 | } |
| 1961 | 1961 | if (sce->ics.predictor_reset_group) |
| 1962 | − reset_predictor_group(sce->predictor_state, | |
| 1962 | + reset_predictor_group(sce->AAC_RENAME(predictor_state), | |
| 1963 | 1963 | sce->ics.predictor_reset_group); |
| 1964 | 1964 | } else |
| 1965 | − reset_all_predictors(sce->predictor_state); | |
| 1965 | + reset_all_predictors(sce->AAC_RENAME(predictor_state)); | |
| 1966 | 1966 | } |
| 1967 | 1967 | |
| 1968 | 1968 | static void decode_gain_control(SingleChannelElement * sce, GetBitContext * gb) |
| @@ -49,6 +49,20 @@ typedef enum AACCoder { · 48 unmodified lines | ||
| 49 | 49 | AAC_CODER_NB, |
| 50 | 50 | }AACCoder; |
| 51 | 51 | |
| 52 | +/** | |
| 53 | + * Predictor State | |
| 54 | + */ | |
| 55 | +typedef struct PredictorState { | |
| 56 | + float cor0; | |
| 57 | + float cor1; | |
| 58 | + float var0; | |
| 59 | + float var1; | |
| 60 | + float r0; | |
| 61 | + float r1; | |
| 62 | + float k1; | |
| 63 | + float x_est; | |
| 64 | +} PredictorState; | |
| 65 | + | |
| 52 | 66 | typedef struct AACEncOptions { |
| 53 | 67 | int coder; |
| 54 | 68 | int pns; |
| @@ -40,6 +40,7 @@ · 39 unmodified lines | ||
| 40 | 40 | |
| 41 | 41 | typedef struct ExtChannelElement { |
| 42 | 42 | ChannelElement ch; |
| 43 | + PredictorState predictor_state[2][MAX_PREDICTORS]; | |
| 43 | 44 | SpectralBandReplication sbr; |
| 44 | 45 | } ExtChannelElement; |
| 45 | 46 | |
| @@ -87,6 +88,8 @@ av_cold int AAC_RENAME(ff_aac_sbr_ctx_alloc_init)(AACDecContext *ac, · 41 unmodified lines | ||
| 87 | 88 | return AVERROR(ENOMEM); |
| 88 | 89 | *che = &ext->ch; |
| 89 | 90 | sbr = &ext->sbr; |
| 91 | + ext->ch.ch[0].AAC_RENAME(predictor_state) = ext->predictor_state[0]; | |
| 92 | + ext->ch.ch[1].AAC_RENAME(predictor_state) = ext->predictor_state[1]; | |
| 90 | 93 | |
| 91 | 94 | sbr->kx[0] = sbr->kx[1]; |
| 92 | 95 | sbr->id_aac = id_aac; |