From 2692ceab8bcc0e7787ce707e9040b4d3ca79723e Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 7 Jan 2006 18:34:19 +0000 Subject: [PATCH] use h264 MC functions for rectangular blocks too Originally committed as revision 4821 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/snow.c | 42 ++++++++++++++++++++++++++++++----- tests/ffmpeg.regression.ref | 12 +++++----- tests/rotozoom.regression.ref | 12 +++++----- 3 files changed, 48 insertions(+), 18 deletions(-) diff --git a/libavcodec/snow.c b/libavcodec/snow.c index aa569c28ce..0aa56dba61 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -2469,10 +2469,29 @@ mca( 8, 8,8) static void pred_block(SnowContext *s, uint8_t *dst, uint8_t *src, uint8_t *tmp, int stride, int sx, int sy, int b_w, int b_h, BlockNode *block, int plane_index, int w, int h){ if(block->type & BLOCK_INTRA){ int x, y; - const int color= block->color[plane_index]; - for(y=0; y < b_h; y++){ - for(x=0; x < b_w; x++){ - dst[x + y*stride]= color; + const int color = block->color[plane_index]; + const int color4= color*0x01010101; + if(b_w==16){ + for(y=0; y < b_h; y++){ + *(uint32_t*)&dst[0 + y*stride]= color4; + *(uint32_t*)&dst[4 + y*stride]= color4; + *(uint32_t*)&dst[8 + y*stride]= color4; + *(uint32_t*)&dst[12+ y*stride]= color4; + } + }else if(b_w==8){ + for(y=0; y < b_h; y++){ + *(uint32_t*)&dst[0 + y*stride]= color4; + *(uint32_t*)&dst[4 + y*stride]= color4; + } + }else if(b_w==4){ + for(y=0; y < b_h; y++){ + *(uint32_t*)&dst[0 + y*stride]= color4; + } + }else{ + for(y=0; y < b_h; y++){ + for(x=0; x < b_w; x++){ + dst[x + y*stride]= color; + } } } }else{ @@ -2489,10 +2508,21 @@ static void pred_block(SnowContext *s, uint8_t *dst, uint8_t *src, uint8_t *tmp, ff_emulated_edge_mc(tmp + MB_SIZE, src, stride, b_w+5, b_h+5, sx, sy, w, h); src= tmp + MB_SIZE; } - if((dx&3) || (dy&3) || b_w!=b_h || (b_w!=4 && b_w!=8 && b_w!=16)) + assert(b_w == b_h || 2*b_w == b_h || b_w == 2*b_h); + assert(!(b_w&(b_w-1))); + assert(b_w>1 && b_h>1); + if((dx&3) || (dy&3) || b_w==2 || b_h==2) mc_block(dst, src, tmp, stride, b_w, b_h, dx, dy); - else + else if(b_w==b_h) s->dsp.put_h264_qpel_pixels_tab[2-(b_w>>3)][dy+(dx>>2)](dst,src + 2 + 2*stride,stride); + else if(b_w==2*b_h){ + s->dsp.put_h264_qpel_pixels_tab[2-(b_h>>3)][dy+(dx>>2)](dst ,src + 2 + 2*stride,stride); + s->dsp.put_h264_qpel_pixels_tab[2-(b_h>>3)][dy+(dx>>2)](dst+b_h,src + 2 + b_h + 2*stride,stride); + }else{ + assert(2*b_w==b_h); + s->dsp.put_h264_qpel_pixels_tab[2-(b_w>>3)][dy+(dx>>2)](dst ,src + 2 + 2*stride ,stride); + s->dsp.put_h264_qpel_pixels_tab[2-(b_w>>3)][dy+(dx>>2)](dst+b_w*stride,src + 2 + 2*stride+b_w*stride,stride); + } } } diff --git a/tests/ffmpeg.regression.ref b/tests/ffmpeg.regression.ref index db8b1f37dd..c56846fa65 100644 --- a/tests/ffmpeg.regression.ref +++ b/tests/ffmpeg.regression.ref @@ -119,12 +119,12 @@ a7ef4746f27be309138c188e327d3ebe *./data/a-ffv1.avi 2653642 ./data/a-ffv1.avi 799d3db687f6cdd7a837ec156efc171f *./data/out.yuv stddev: 0.00 PSNR:99.99 bytes:7602176 -1b5f58ef86909635fa4a582eeb275118 *./data/a-snow.avi -1198432 ./data/a-snow.avi -0b96ab5415cf2d1f486a75810d033e2b *./data/out.yuv -stddev: 2.90 PSNR:38.87 bytes:7602176 -de8eac1454746a37eae0b1ff88c0f849 *./data/a-snow53.avi -3535414 ./data/a-snow53.avi +14fa515bf25a47fc2ad3d18b726e8e31 *./data/a-snow.avi +1197138 ./data/a-snow.avi +e7c746171b092266b0cf55bb5de2a40a *./data/out.yuv +stddev: 2.89 PSNR:38.87 bytes:7602176 +94bedf8929178a8202ae3b5dbcdb84dd *./data/a-snow53.avi +3533696 ./data/a-snow53.avi 799d3db687f6cdd7a837ec156efc171f *./data/out.yuv stddev: 0.00 PSNR:99.99 bytes:7602176 e1da20e3f52f4d2aa18e9486986161fc *./data/a-dv.dv diff --git a/tests/rotozoom.regression.ref b/tests/rotozoom.regression.ref index 7f168f1516..4eda12d065 100644 --- a/tests/rotozoom.regression.ref +++ b/tests/rotozoom.regression.ref @@ -119,12 +119,12 @@ d0831a8339491fd680b650f05262e5d9 *./data/a-ffv1.avi 3524768 ./data/a-ffv1.avi dde5895817ad9d219f79a52d0bdfb001 *./data/out.yuv stddev: 0.00 PSNR:99.99 bytes:7602176 -f5dd9e5779f7fdc0fd9f67f44fd3979b *./data/a-snow.avi -286706 ./data/a-snow.avi -1b59f5ede351d67fc61c75a34b13ccb5 *./data/out.yuv -stddev: 2.32 PSNR:40.79 bytes:7602176 -d0a8bdb25d7ed641eab0debcac396eb7 *./data/a-snow53.avi -2725842 ./data/a-snow53.avi +b926518ac399c7af0f218a7115315b4f *./data/a-snow.avi +286800 ./data/a-snow.avi +6c59db71d950610f854d05e2cef18609 *./data/out.yuv +stddev: 2.32 PSNR:40.80 bytes:7602176 +4d2bcc832e318fad3c25614e31daa6fe *./data/a-snow53.avi +2725630 ./data/a-snow53.avi dde5895817ad9d219f79a52d0bdfb001 *./data/out.yuv stddev: 0.00 PSNR:99.99 bytes:7602176 a553532dcd54c1c421b52c3b6fece6ef *./data/a-dv.dv