comparison snow.c @ 3053:2991dc513726 libavcodec

detect when iterative_me fails to converge, and stop searching
author lorenm
date Thu, 19 Jan 2006 09:21:39 +0000
parents c0fde3eb7784
children 17494903551b
comparison
equal deleted inserted replaced
3052:6c3f87300378 3053:2991dc513726
22 22
23 #include "rangecoder.h" 23 #include "rangecoder.h"
24 #define MID_STATE 128 24 #define MID_STATE 128
25 25
26 #include "mpegvideo.h" 26 #include "mpegvideo.h"
27
28 #include <zlib.h>
27 29
28 #undef NDEBUG 30 #undef NDEBUG
29 #include <assert.h> 31 #include <assert.h>
30 32
31 #define MAX_DECOMPOSITIONS 8 33 #define MAX_DECOMPOSITIONS 8
3299 int pass, mb_x, mb_y; 3301 int pass, mb_x, mb_y;
3300 const int b_width = s->b_width << s->block_max_depth; 3302 const int b_width = s->b_width << s->block_max_depth;
3301 const int b_height= s->b_height << s->block_max_depth; 3303 const int b_height= s->b_height << s->block_max_depth;
3302 const int b_stride= b_width; 3304 const int b_stride= b_width;
3303 int color[3]; 3305 int color[3];
3306 const int first_crc_pass= 12;
3307 uint32_t crcs[50];
3304 3308
3305 for(pass=0; pass<50; pass++){ 3309 for(pass=0; pass<50; pass++){
3306 int change= 0; 3310 int change= 0;
3307 3311
3308 for(mb_y= 0; mb_y<b_height; mb_y++){ 3312 for(mb_y= 0; mb_y<b_height; mb_y++){
3433 change ++; 3437 change ++;
3434 } 3438 }
3435 } 3439 }
3436 } 3440 }
3437 av_log(NULL, AV_LOG_ERROR, "pass:%d changed:%d\n", pass, change); 3441 av_log(NULL, AV_LOG_ERROR, "pass:%d changed:%d\n", pass, change);
3442
3443 if(pass >= first_crc_pass){
3444 int i;
3445 //FIXME can we hash just the blocks that were analysed?
3446 crcs[pass]= crc32(crc32(0,NULL,0), (void*)s->block, b_stride*b_height*sizeof(BlockNode));
3447 for(i=pass-1; i>=first_crc_pass; i--){
3448 if(crcs[i] == crcs[pass]){
3449 change= 0;
3450 break;
3451 }
3452 }
3453 }
3438 if(!change) 3454 if(!change)
3439 break; 3455 break;
3440 } 3456 }
3441 3457
3442 if(s->block_max_depth == 1){ 3458 if(s->block_max_depth == 1){