From d3ac6ed667872332efcb8c953bb45cbd125dbaab Mon Sep 17 00:00:00 2001 From: Loren Merritt Date: Thu, 19 Jan 2006 09:21:39 +0000 Subject: [PATCH] detect when iterative_me fails to converge, and stop searching Originally committed as revision 4868 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/snow.c | 16 ++++++++++++++++ tests/ffmpeg.regression.ref | 8 ++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 4a96f3e0d2..88fb49a10e 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -25,6 +25,8 @@ #include "mpegvideo.h" +#include + #undef NDEBUG #include @@ -3301,6 +3303,8 @@ static void iterative_me(SnowContext *s){ const int b_height= s->b_height << s->block_max_depth; const int b_stride= b_width; int color[3]; + const int first_crc_pass= 12; + uint32_t crcs[50]; for(pass=0; pass<50; pass++){ int change= 0; @@ -3435,6 +3439,18 @@ static void iterative_me(SnowContext *s){ } } av_log(NULL, AV_LOG_ERROR, "pass:%d changed:%d\n", pass, change); + + if(pass >= first_crc_pass){ + int i; + //FIXME can we hash just the blocks that were analysed? + crcs[pass]= crc32(crc32(0,NULL,0), (void*)s->block, b_stride*b_height*sizeof(BlockNode)); + for(i=pass-1; i>=first_crc_pass; i--){ + if(crcs[i] == crcs[pass]){ + change= 0; + break; + } + } + } if(!change) break; } diff --git a/tests/ffmpeg.regression.ref b/tests/ffmpeg.regression.ref index 7f0cb2f7a4..cd4f631d1e 100644 --- a/tests/ffmpeg.regression.ref +++ b/tests/ffmpeg.regression.ref @@ -119,10 +119,10 @@ a7ef4746f27be309138c188e327d3ebe *./data/a-ffv1.avi 2653642 ./data/a-ffv1.avi 799d3db687f6cdd7a837ec156efc171f *./data/out.yuv stddev: 0.00 PSNR:99.99 bytes:7602176 -97c7066617d9e6c86a43a2736b3e9f16 *./data/a-snow.avi -1190760 ./data/a-snow.avi -7e4d9c61252ff22b1a0d4e892cc1d957 *./data/out.yuv -stddev: 2.89 PSNR:38.87 bytes:7602176 +b7e88c743458e60d59d83554d1e1ace5 *./data/a-snow.avi +1191118 ./data/a-snow.avi +2e0cda9acd71d339d72372a22591500a *./data/out.yuv +stddev: 2.90 PSNR:38.87 bytes:7602176 11fd61ee7e67ef7a7b2a3df973691305 *./data/a-snow53.avi 3533710 ./data/a-snow53.avi 799d3db687f6cdd7a837ec156efc171f *./data/out.yuv