Mercurial > libavcodec.hg
comparison motion_est_template.c @ 4298:bba6e75e026b libavcodec
mv overflow in map fix (untested except regression tests)
author | michael |
---|---|
date | Tue, 12 Dec 2006 13:31:12 +0000 |
parents | d6f83e2f8804 |
children | eb0ae1ce40a5 |
comparison
equal
deleted
inserted
replaced
4297:c5f74ebdba34 | 4298:bba6e75e026b |
---|---|
821 int map_generation= c->map_generation; | 821 int map_generation= c->map_generation; |
822 | 822 |
823 cmpf= s->dsp.me_cmp[size]; | 823 cmpf= s->dsp.me_cmp[size]; |
824 chroma_cmpf= s->dsp.me_cmp[size+1]; | 824 chroma_cmpf= s->dsp.me_cmp[size+1]; |
825 | 825 |
826 for(j=i=0; i<ME_MAP_SIZE; i++){ | 826 /*Note j<MAX_SAB_SIZE is needed if MAX_SAB_SIZE < ME_MAP_SIZE as j can |
827 become larger due to MVs overflowing their ME_MAP_MV_BITS bits space in map | |
828 */ | |
829 for(j=i=0; i<ME_MAP_SIZE && j<MAX_SAB_SIZE; i++){ | |
827 uint32_t key= map[i]; | 830 uint32_t key= map[i]; |
828 | 831 |
829 key += (1<<(ME_MAP_MV_BITS-1)) + (1<<(2*ME_MAP_MV_BITS-1)); | 832 key += (1<<(ME_MAP_MV_BITS-1)) + (1<<(2*ME_MAP_MV_BITS-1)); |
830 | 833 |
831 if((key&((-1)<<(2*ME_MAP_MV_BITS))) != map_generation) continue; | 834 if((key&((-1)<<(2*ME_MAP_MV_BITS))) != map_generation) continue; |
832 | |
833 assert(j<MAX_SAB_SIZE); //max j = number of predictors | |
834 | 835 |
835 minima[j].height= score_map[i]; | 836 minima[j].height= score_map[i]; |
836 minima[j].x= key & ((1<<ME_MAP_MV_BITS)-1); key>>=ME_MAP_MV_BITS; | 837 minima[j].x= key & ((1<<ME_MAP_MV_BITS)-1); key>>=ME_MAP_MV_BITS; |
837 minima[j].y= key & ((1<<ME_MAP_MV_BITS)-1); | 838 minima[j].y= key & ((1<<ME_MAP_MV_BITS)-1); |
838 minima[j].x-= (1<<(ME_MAP_MV_BITS-1)); | 839 minima[j].x-= (1<<(ME_MAP_MV_BITS-1)); |
839 minima[j].y-= (1<<(ME_MAP_MV_BITS-1)); | 840 minima[j].y-= (1<<(ME_MAP_MV_BITS-1)); |
841 | |
842 // all entries in map should be in range except if the mv overflows their ME_MAP_MV_BITS bits space | |
843 if( minima[j].x > xmax || minima[j].x < xmin | |
844 || minima[j].y > ymax || minima[j].y < ymin) | |
845 continue; | |
846 | |
840 minima[j].checked=0; | 847 minima[j].checked=0; |
841 if(minima[j].x || minima[j].y) | 848 if(minima[j].x || minima[j].y) |
842 minima[j].height+= (mv_penalty[((minima[j].x)<<shift)-pred_x] + mv_penalty[((minima[j].y)<<shift)-pred_y])*penalty_factor; | 849 minima[j].height+= (mv_penalty[((minima[j].x)<<shift)-pred_x] + mv_penalty[((minima[j].y)<<shift)-pred_y])*penalty_factor; |
843 | 850 |
844 j++; | 851 j++; |