Mercurial > libavcodec.hg
comparison zmbvenc.c @ 4647:255affa5bae7 libavcodec
Correctly ME border blocks
author | kostya |
---|---|
date | Sun, 11 Mar 2007 09:51:01 +0000 |
parents | 6f34a614f5d9 |
children | b3ee9a1526b0 |
comparison
equal
deleted
inserted
replaced
4646:cd5964d440e8 | 4647:255affa5bae7 |
---|---|
78 * TODO make better ME decisions | 78 * TODO make better ME decisions |
79 */ | 79 */ |
80 static int zmbv_me(ZmbvEncContext *c, uint8_t *src, int sstride, uint8_t *prev, int pstride, | 80 static int zmbv_me(ZmbvEncContext *c, uint8_t *src, int sstride, uint8_t *prev, int pstride, |
81 int x, int y, int *mx, int *my) | 81 int x, int y, int *mx, int *my) |
82 { | 82 { |
83 int dx, dy, tx, ty, tv, bv; | 83 int dx, dy, tx, ty, tv, bv, bw, bh; |
84 | 84 |
85 *mx = *my = 0; | 85 *mx = *my = 0; |
86 bv = block_cmp(src, sstride, prev, pstride, ZMBV_BLOCK, ZMBV_BLOCK); | 86 bw = FFMIN(ZMBV_BLOCK, c->avctx->width - x); |
87 bh = FFMIN(ZMBV_BLOCK, c->avctx->height - y); | |
88 bv = block_cmp(src, sstride, prev, pstride, bw, bh); | |
87 if(!bv) return 0; | 89 if(!bv) return 0; |
88 for(ty = FFMAX(y - c->range, 0); ty < FFMIN(y + c->range, c->avctx->height - ZMBV_BLOCK); ty++){ | 90 for(ty = FFMAX(y - c->range, 0); ty < FFMIN(y + c->range, c->avctx->height - bh); ty++){ |
89 for(tx = FFMAX(x - c->range, 0); tx < FFMIN(x + c->range, c->avctx->width - ZMBV_BLOCK); tx++){ | 91 for(tx = FFMAX(x - c->range, 0); tx < FFMIN(x + c->range, c->avctx->width - bw); tx++){ |
90 if(tx == x && ty == y) continue; // we already tested this block | 92 if(tx == x && ty == y) continue; // we already tested this block |
91 dx = tx - x; | 93 dx = tx - x; |
92 dy = ty - y; | 94 dy = ty - y; |
93 tv = block_cmp(src, sstride, prev + dx + dy*pstride, pstride, ZMBV_BLOCK, ZMBV_BLOCK); | 95 tv = block_cmp(src, sstride, prev + dx + dy*pstride, pstride, bw, bh); |
94 if(tv < bv){ | 96 if(tv < bv){ |
95 bv = tv; | 97 bv = tv; |
96 *mx = dx; | 98 *mx = dx; |
97 *my = dy; | 99 *my = dy; |
98 if(!bv) return 0; | 100 if(!bv) return 0; |