[FFmpeg-soc] [soc]: r2435 - in aacenc: aacenc.c aacpsy.c aacpsy.h
kostya
subversion at mplayerhq.hu
Sat Jun 14 18:01:40 CEST 2008
Author: kostya
Date: Sat Jun 14 18:01:40 2008
New Revision: 2435
Log:
Another advancement in '8 short windows' mode support
Modified:
aacenc/aacenc.c
aacenc/aacpsy.c
aacenc/aacpsy.h
Modified: aacenc/aacenc.c
==============================================================================
--- aacenc/aacenc.c (original)
+++ aacenc/aacenc.c Sat Jun 14 18:01:40 2008
@@ -98,6 +98,36 @@ static const uint8_t *swb_size_1024[] =
swb_size_1024_16, swb_size_1024_16, swb_size_1024_8
};
+static const uint8_t swb_size_128_96[] = {
+ 4, 4, 4, 4, 4, 4, 8, 8, 8, 16, 28, 36
+};
+
+static const uint8_t swb_size_128_48[] = {
+ 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 12, 16, 16, 16
+};
+
+static const uint8_t swb_size_128_24[] = {
+ 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 16, 16, 20
+};
+
+static const uint8_t swb_size_128_16[] = {
+ 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 12, 12, 16, 20, 20
+};
+
+static const uint8_t swb_size_128_8[] = {
+ 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 12, 16, 20, 20
+};
+
+static const uint8_t *swb_size_128[] = {
+ /* the last entry on the following row is swb_size_128_64 but is a
+ duplicate of swb_size_128_96 */
+ swb_size_128_96, swb_size_128_96, swb_size_128_96,
+ swb_size_128_48, swb_size_128_48, swb_size_128_48,
+ swb_size_128_24, swb_size_128_24, swb_size_128_16,
+ swb_size_128_16, swb_size_128_16, swb_size_128_8
+};
+
+
#define MAX_SWB_SIZE 51
//borrowed data ends here
@@ -141,8 +171,10 @@ typedef struct {
DECLARE_ALIGNED_16(FFTSample, tmp[1024]);
int samplerate_index;
- uint8_t *swb_sizes;
- int swb_num;
+ uint8_t *swb_sizes1024;
+ int swb_num1024;
+ uint8_t *swb_sizes128;
+ int swb_num128;
cpe_struct cpe;
AACPsyContext psy;
} AACEncContext;
@@ -187,14 +219,16 @@ static int aac_encode_init(AVCodecContex
return -1;
}
s->samplerate_index = i;
- s->swb_sizes = swb_size_1024[i];
- s->swb_num = num_swb_1024[i];
+ s->swb_sizes1024 = swb_size_1024[i];
+ s->swb_num1024 = num_swb_1024[i];
+ s->swb_sizes128 = swb_size_128[i];
+ s->swb_num128 = num_swb_128[i];
ff_mdct_init(&s->mdct, 11, 0);
// window init
ff_kbd_window_init(s->kbd_long_1024, 4.0, 1024);
- ff_aac_psy_init(&s->psy, avctx, AAC_PSY_NULL, 0, s->swb_sizes, s->swb_num);
+ ff_aac_psy_init(&s->psy, avctx, AAC_PSY_NULL, 0, s->swb_sizes1024, s->swb_num1024, s->swb_sizes128, s->swb_num128);
avctx->extradata = av_malloc(2);
avctx->extradata_size = 2;
put_audio_specific_config(avctx);
@@ -402,8 +436,8 @@ static void encode_spectral_data(AVCodec
for(i = 0; i < cpe->ch[channel].ics.max_sfb; i++){
if(!cpe->ch[channel].zeroes[0][i])
- encode_codebook(s, cpe, channel, start, s->swb_sizes[i], cpe->ch[channel].cb[0][i]);
- start += s->swb_sizes[i];
+ encode_codebook(s, cpe, channel, start, cpe->ch[channel].ics.swb_sizes[i], cpe->ch[channel].cb[0][i]);
+ start += cpe->ch[channel].ics.swb_sizes[i];
}
}
@@ -418,11 +452,11 @@ static int encode_individual_channel(AVC
i = 0;
while(i < 1024){
if(!cpe->ch[channel].zeroes[0][g]){
- cpe->ch[channel].cb[0][g] = determine_section_info(s, cpe, channel, g, i, s->swb_sizes[g]);
+ cpe->ch[channel].cb[0][g] = determine_section_info(s, cpe, channel, g, i, cpe->ch[channel].ics.swb_sizes[g]);
cpe->ch[channel].zeroes[0][g] = !cpe->ch[channel].cb[0][g];
}else
cpe->ch[channel].cb[0][g] = 0;
- i += s->swb_sizes[g];
+ i += cpe->ch[channel].ics.swb_sizes[g];
g++;
}
Modified: aacenc/aacpsy.c
==============================================================================
--- aacenc/aacpsy.c (original)
+++ aacenc/aacpsy.c Sat Jun 14 18:01:40 2008
@@ -43,6 +43,8 @@ static void psy_null_window(AACPsyContex
for(ch = 0; ch < apc->avctx->channels; ch++){
cpe->ch[ch].ics.window_sequence = 0;
cpe->ch[ch].ics.window_shape = 1;
+ cpe->ch[ch].ics.swb_sizes = apc->bands1024;
+ cpe->ch[ch].ics.num_swb = apc->num_bands1024;
}
cpe->common_window = cpe->ch[0].ics.window_shape == cpe->ch[1].ics.window_shape;
}
@@ -55,10 +57,10 @@ static void psy_null_process(AACPsyConte
//detect M/S
if(apc->avctx->channels > 1 && cpe->common_window){
start = 0;
- for(g = 0; g < apc->num_bands; g++){
+ for(g = 0; g < apc->num_bands1024; g++){
float diff = 0.0f;
- for(i = 0; i < apc->bands[g]; i++)
+ for(i = 0; i < apc->bands1024[g]; i++)
diff += fabs(cpe->ch[0].coeffs[start+i] - cpe->ch[1].coeffs[start+i]);
cpe->ms.mask[0][g] = diff == 0.0;
}
@@ -66,24 +68,24 @@ static void psy_null_process(AACPsyConte
for(ch = 0; ch < apc->avctx->channels; ch++){
start = 0;
cpe->ch[ch].gain = SCALE_ONE_POS;
- for(g = 0; g < apc->num_bands; g++){
+ for(g = 0; g < apc->num_bands1024; g++){
sum = 0;
cpe->ch[ch].sf_idx[0][g] = SCALE_ONE_POS;
//apply M/S
if(!ch && cpe->ms.mask[0][g]){
- for(i = 0; i < apc->bands[g]; i++){
+ for(i = 0; i < apc->bands1024[g]; i++){
cpe->ch[0].coeffs[start+i] = (cpe->ch[0].coeffs[start+i] + cpe->ch[1].coeffs[start+i]) / 2.0;
cpe->ch[1].coeffs[start+i] = cpe->ch[0].coeffs[start+i] - cpe->ch[1].coeffs[start+i];
}
}
- for(i = 0; i < apc->bands[g]; i++){
+ for(i = 0; i < apc->bands1024[g]; i++){
cpe->ch[ch].icoefs[start+i] = av_clip((int)(roundf(cpe->ch[ch].coeffs[start+i] / pow2sf_tab[cpe->ch[ch].sf_idx[0][g]+60])), -8191, 8191);
sum += !!cpe->ch[ch].icoefs[start+i];
}
cpe->ch[ch].zeroes[0][g] = !sum;
- start += apc->bands[g];
+ start += apc->bands1024[g];
}
- for(maxsfb = apc->num_bands; maxsfb > 0 && cpe->ch[ch].zeroes[0][maxsfb-1]; maxsfb--);
+ for(maxsfb = apc->num_bands1024; maxsfb > 0 && cpe->ch[ch].zeroes[0][maxsfb-1]; maxsfb--);
cpe->ch[ch].ics.max_sfb = maxsfb;
}
if(apc->avctx->channels > 1 && cpe->common_window){
@@ -109,7 +111,8 @@ static const AACPsyModel psy_models[AAC_
};
int ff_aac_psy_init(AACPsyContext *ctx, AVCodecContext *avctx, int model, int flags,
- const uint8_t *bands, int num_bands)
+ const uint8_t *bands1024, int num_bands1024,
+ const uint8_t *bands128, int num_bands128)
{
int i;
@@ -122,8 +125,10 @@ int ff_aac_psy_init(AACPsyContext *ctx,
pow2sf_tab[i] = pow(2, (i - 200)/4.);
ctx->avctx = avctx;
- ctx->bands = bands;
- ctx->num_bands = num_bands;
+ ctx->bands1024 = bands1024;
+ ctx->num_bands1024 = num_bands1024;
+ ctx->bands128 = bands128;
+ ctx->num_bands128 = num_bands128;
dsputil_init(&ctx->dsp, avctx);
ctx->model = &psy_models[model];
Modified: aacenc/aacpsy.h
==============================================================================
--- aacenc/aacpsy.h (original)
+++ aacenc/aacpsy.h Sat Jun 14 18:01:40 2008
@@ -99,8 +99,10 @@ typedef struct AACPsyContext {
int window_type[2];
int window_shape[2];
- const uint8_t *bands;
- int num_bands;
+ const uint8_t *bands1024;
+ int num_bands1024;
+ const uint8_t *bands128;
+ int num_bands128;
const struct AACPsyModel *model;
void* model_priv_data;
@@ -115,7 +117,8 @@ typedef struct AACPsyModel {
}AACPsyModel;
int ff_aac_psy_init(AACPsyContext *ctx, AVCodecContext *avctx, int model, int flags,
- const uint8_t *bands, int num_bands);
+ const uint8_t *bands1024, int num_bands1024,
+ const uint8_t *bands128, int num_bands128);
void ff_aac_psy_suggest_window(AACPsyContext *ctx, int16_t *audio, int channel, cpe_struct *cpe);
void ff_aac_psy_analyze(AACPsyContext *ctx, int16_t *audio, int channel, cpe_struct *cpe);
void ff_aac_psy_end(AACPsyContext *ctx);
More information about the FFmpeg-soc
mailing list