diff options
author | Alex Converse <alex.converse@gmail.com> | 2010-06-28 21:49:26 +0000 |
---|---|---|
committer | Alex Converse <alex.converse@gmail.com> | 2010-06-28 21:49:26 +0000 |
commit | 75ef6898846fb14dd47691cad6ce8850c9106723 (patch) | |
tree | aa9858104fe20a5118805590fee88dd7e636dfce /libavcodec/aacpsy.c | |
parent | 804d489c4a97b8a97f1da216678b1ea0c03974e3 (diff) | |
download | ffmpeg-75ef6898846fb14dd47691cad6ce8850c9106723.tar.gz |
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
Diffstat (limited to 'libavcodec/aacpsy.c')
-rw-r--r-- | libavcodec/aacpsy.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c index 4d0c738765..466b0e9a1a 100644 --- a/libavcodec/aacpsy.c +++ b/libavcodec/aacpsy.c @@ -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; |