Commit 75ef6898 authored by Alex Converse's avatar Alex Converse

aacenc: Fix window decision logic.

This keeps the encoder from switching away from an wight short sequence
prematurely when attacks are detected two frames in a row. It also allows for
the legal and useful LONG_STOP_SEQUENCE to LONG_START_SEQUENCE transition.

Originally committed as revision 23870 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 804d489c
......@@ -185,6 +185,7 @@ static FFPsyWindowInfo psy_3gpp_window(FFPsyContext *ctx,
Psy3gppContext *pctx = (Psy3gppContext*) ctx->model_priv_data;
Psy3gppChannel *pch = &pctx->ch[channel];
uint8_t grouping = 0;
int next_type = pch->next_window_seq;
FFPsyWindowInfo wi;
memset(&wi, 0, sizeof(wi));
......@@ -193,6 +194,7 @@ static FFPsyWindowInfo psy_3gpp_window(FFPsyContext *ctx,
int switch_to_eight = 0;
float sum = 0.0, sum2 = 0.0;
int attack_n = 0;
int stay_short = 0;
for (i = 0; i < 8; i++) {
for (j = 0; j < 128; j++) {
v = iir_filter(la[(i*128+j)*ctx->avctx->channels], pch->iir_state);
......@@ -214,20 +216,27 @@ static FFPsyWindowInfo psy_3gpp_window(FFPsyContext *ctx,
switch (prev_type) {
case ONLY_LONG_SEQUENCE:
wi.window_type[0] = switch_to_eight ? LONG_START_SEQUENCE : ONLY_LONG_SEQUENCE;
next_type = switch_to_eight ? EIGHT_SHORT_SEQUENCE : ONLY_LONG_SEQUENCE;
break;
case LONG_START_SEQUENCE:
wi.window_type[0] = EIGHT_SHORT_SEQUENCE;
grouping = pch->next_grouping;
next_type = switch_to_eight ? EIGHT_SHORT_SEQUENCE : LONG_STOP_SEQUENCE;
break;
case LONG_STOP_SEQUENCE:
wi.window_type[0] = ONLY_LONG_SEQUENCE;
wi.window_type[0] = switch_to_eight ? LONG_START_SEQUENCE : ONLY_LONG_SEQUENCE;
next_type = switch_to_eight ? EIGHT_SHORT_SEQUENCE : ONLY_LONG_SEQUENCE;
break;
case EIGHT_SHORT_SEQUENCE:
wi.window_type[0] = switch_to_eight ? EIGHT_SHORT_SEQUENCE : LONG_STOP_SEQUENCE;
grouping = switch_to_eight ? pch->next_grouping : 0;
stay_short = next_type == EIGHT_SHORT_SEQUENCE || switch_to_eight;
wi.window_type[0] = stay_short ? EIGHT_SHORT_SEQUENCE : LONG_STOP_SEQUENCE;
grouping = next_type == EIGHT_SHORT_SEQUENCE ? pch->next_grouping : 0;
next_type = switch_to_eight ? EIGHT_SHORT_SEQUENCE : LONG_STOP_SEQUENCE;
break;
}
pch->next_grouping = window_grouping[attack_n];
pch->next_window_seq = next_type;
} else {
for (i = 0; i < 3; i++)
wi.window_type[i] = prev_type;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment