mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-13 10:44:59 +00:00
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
This commit is contained in:
parent
804d489c4a
commit
75ef689884
@ -185,6 +185,7 @@ static FFPsyWindowInfo psy_3gpp_window(FFPsyContext *ctx,
|
|||||||
Psy3gppContext *pctx = (Psy3gppContext*) ctx->model_priv_data;
|
Psy3gppContext *pctx = (Psy3gppContext*) ctx->model_priv_data;
|
||||||
Psy3gppChannel *pch = &pctx->ch[channel];
|
Psy3gppChannel *pch = &pctx->ch[channel];
|
||||||
uint8_t grouping = 0;
|
uint8_t grouping = 0;
|
||||||
|
int next_type = pch->next_window_seq;
|
||||||
FFPsyWindowInfo wi;
|
FFPsyWindowInfo wi;
|
||||||
|
|
||||||
memset(&wi, 0, sizeof(wi));
|
memset(&wi, 0, sizeof(wi));
|
||||||
@ -193,6 +194,7 @@ static FFPsyWindowInfo psy_3gpp_window(FFPsyContext *ctx,
|
|||||||
int switch_to_eight = 0;
|
int switch_to_eight = 0;
|
||||||
float sum = 0.0, sum2 = 0.0;
|
float sum = 0.0, sum2 = 0.0;
|
||||||
int attack_n = 0;
|
int attack_n = 0;
|
||||||
|
int stay_short = 0;
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
for (j = 0; j < 128; j++) {
|
for (j = 0; j < 128; j++) {
|
||||||
v = iir_filter(la[(i*128+j)*ctx->avctx->channels], pch->iir_state);
|
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) {
|
switch (prev_type) {
|
||||||
case ONLY_LONG_SEQUENCE:
|
case ONLY_LONG_SEQUENCE:
|
||||||
wi.window_type[0] = switch_to_eight ? LONG_START_SEQUENCE : 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;
|
break;
|
||||||
case LONG_START_SEQUENCE:
|
case LONG_START_SEQUENCE:
|
||||||
wi.window_type[0] = EIGHT_SHORT_SEQUENCE;
|
wi.window_type[0] = EIGHT_SHORT_SEQUENCE;
|
||||||
grouping = pch->next_grouping;
|
grouping = pch->next_grouping;
|
||||||
|
next_type = switch_to_eight ? EIGHT_SHORT_SEQUENCE : LONG_STOP_SEQUENCE;
|
||||||
break;
|
break;
|
||||||
case LONG_STOP_SEQUENCE:
|
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;
|
break;
|
||||||
case EIGHT_SHORT_SEQUENCE:
|
case EIGHT_SHORT_SEQUENCE:
|
||||||
wi.window_type[0] = switch_to_eight ? EIGHT_SHORT_SEQUENCE : LONG_STOP_SEQUENCE;
|
stay_short = next_type == EIGHT_SHORT_SEQUENCE || switch_to_eight;
|
||||||
grouping = switch_to_eight ? pch->next_grouping : 0;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
pch->next_grouping = window_grouping[attack_n];
|
pch->next_grouping = window_grouping[attack_n];
|
||||||
|
pch->next_window_seq = next_type;
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
wi.window_type[i] = prev_type;
|
wi.window_type[i] = prev_type;
|
||||||
|
Loading…
Reference in New Issue
Block a user