[FFmpeg-soc] [soc]: r4902 - wmapro/wmaprodec.c
faust3
subversion at mplayerhq.hu
Sun Aug 2 12:21:08 CEST 2009
Author: faust3
Date: Sun Aug 2 12:21:08 2009
New Revision: 4902
Log:
simplify handling of resampled scale factors
Modified:
wmapro/wmaprodec.c
Modified: wmapro/wmaprodec.c
==============================================================================
--- wmapro/wmaprodec.c Sun Aug 2 11:43:13 2009 (r4901)
+++ wmapro/wmaprodec.c Sun Aug 2 12:21:08 2009 (r4902)
@@ -139,7 +139,7 @@ typedef struct {
int8_t scale_factor_step; ///< scaling step for the current subframe
int max_scale_factor; ///< maximum scale factor for the current subframe
int scale_factors[MAX_BANDS]; ///< scale factor values for the current subframe
- int resampled_scale_factors[MAX_BANDS]; ///< scale factors from a previous subframe
+ int saved_scale_factors[MAX_BANDS]; ///< scale factors from a previous subframe
int16_t scale_factor_block_len; ///< scale factor reference block length
float* coeffs; ///< pointer to the subframe decode buffer
DECLARE_ALIGNED_16(float, out[2*WMAPRO_BLOCK_MAX_SIZE]); ///< output buffer
@@ -924,17 +924,8 @@ static int decode_scale_factors(WMA3Deco
MAX_BANDS * idx0 + MAX_BANDS * idx1];
int b;
for (b=0;b<s->num_bands;b++)
- s->channel[c].resampled_scale_factors[b] =
- s->channel[c].scale_factors[*sf_offsets++];
-
- s->channel[c].max_scale_factor =
- s->channel[c].resampled_scale_factors[0];
- sf = s->channel[c].resampled_scale_factors + 1;
- while (sf < s->channel[c].resampled_scale_factors + s->num_bands) {
- if (*sf > s->channel[c].max_scale_factor)
- s->channel[c].max_scale_factor = *sf;
- ++sf;
- }
+ s->channel[c].scale_factors[b] =
+ s->channel[c].saved_scale_factors[*sf_offsets++];
}
if (s->channel[c].cur_subframe > 0) {
@@ -956,11 +947,6 @@ static int decode_scale_factors(WMA3Deco
} else {
int i;
/** run level decode differences to the resampled factors */
-
- memcpy(s->channel[c].scale_factors,
- s->channel[c].resampled_scale_factors,
- sizeof(int) * s->num_bands);
-
for (i=0;i<s->num_bands;i++) {
int idx;
int skip;
@@ -992,14 +978,22 @@ static int decode_scale_factors(WMA3Deco
}
}
- s->channel[c].reuse_sf = 1;
- s->channel[c].max_scale_factor = s->channel[c].scale_factors[0];
- for (sf=s->channel[c].scale_factors + 1; sf < sf_end; sf++) {
- if (s->channel[c].max_scale_factor < *sf)
- s->channel[c].max_scale_factor = *sf;
- }
+ /** save transmitted scale factors so that they can be reused for
+ the next subframe */
+ memcpy(s->channel[c].saved_scale_factors,
+ s->channel[c].scale_factors,
+ sizeof(int) * s->num_bands);
s->channel[c].scale_factor_block_len = s->subframe_len;
+ s->channel[c].reuse_sf = 1;
+ }
+
+ /** calculate new scale factor maximum */
+ s->channel[c].max_scale_factor = s->channel[c].scale_factors[0];
+ for (sf=s->channel[c].scale_factors + 1; sf < sf_end; sf++) {
+ if (s->channel[c].max_scale_factor < *sf)
+ s->channel[c].max_scale_factor = *sf;
}
+
}
return 0;
}
@@ -1286,14 +1280,9 @@ static int decode_subframe(WMA3DecodeCon
inverse_channel_transform(s);
for (i=0;i<s->channels_for_cur_subframe;i++) {
int c = s->channel_indexes_for_cur_subframe[i];
- int* sf;
+ const int* sf = s->channel[c].scale_factors;
int b;
- if (s->channel[c].transmit_sf) {
- sf = s->channel[c].scale_factors;
- } else
- sf = s->channel[c].resampled_scale_factors;
-
if (c == s->lfe_channel)
memset(&s->tmp[s->cur_subwoofer_cutoff],0,
sizeof(float) * (subframe_len - s->cur_subwoofer_cutoff));
@@ -1411,8 +1400,6 @@ static int decode_frame(WMA3DecodeContex
s->channel[i].max_scale_factor = 0;
memset(s->channel[i].scale_factors, 0,
sizeof(s->channel[i].scale_factors));
- memset(s->channel[i].resampled_scale_factors, 0,
- sizeof(s->channel[i].resampled_scale_factors));
}
/** decode all subframes */
More information about the FFmpeg-soc
mailing list