From 19591033f7145115790338bfd038b7ecb6ff39ee Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 24 Oct 2010 12:35:42 +0000 Subject: Fix the case with swaping states 127 and 129 in ffv1 Originally committed as revision 25562 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/ffv1.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'libavcodec/ffv1.c') diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index eddac74cb6..2ac13a39f1 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -896,19 +896,23 @@ static av_cold int encode_init(AVCodecContext *avctx) double size0= COST2(i, i ) + COST2(i2, i2); double sizeX= COST2(i, i2) + COST2(i2, i ); - if(sizeX < size0 && i!=128 && i2!=128){ //128 is special we cant swap it around FIXME 127<->129 swap + if(sizeX < size0 && i!=128 && i2!=128){ int j; FFSWAP(int, s->state_transition[ i], s->state_transition[ i2]); - FFSWAP(int, s->state_transition[256-i], s->state_transition[256-i2]); FFSWAP(int, s->rc_stat[i ][0],s->rc_stat[ i2][0]); FFSWAP(int, s->rc_stat[i ][1],s->rc_stat[ i2][1]); + if(i != 256-i2){ + FFSWAP(int, s->state_transition[256-i], s->state_transition[256-i2]); FFSWAP(int, s->rc_stat[256-i][0],s->rc_stat[256-i2][0]); FFSWAP(int, s->rc_stat[256-i][1],s->rc_stat[256-i2][1]); + } for(j=1; j<256; j++){ if (s->state_transition[j] == i ) s->state_transition[j] = i2; else if(s->state_transition[j] == i2) s->state_transition[j] = i ; + if(i != 256-i2){ if (s->state_transition[256-j] == 256-i ) s->state_transition[256-j] = 256-i2; else if(s->state_transition[256-j] == 256-i2) s->state_transition[256-j] = 256-i ; + } } changed=1; } -- cgit v1.2.3