From 288a44fb7a4fb21f9c1e92fc009ad06797ef78d3 Mon Sep 17 00:00:00 2001 From: Aurelien Jacobs Date: Tue, 4 Mar 2008 23:10:47 +0000 Subject: move ff_emulated_edge_mc() to dsputil Originally committed as revision 12318 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/dsputil.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++ libavcodec/dsputil.h | 4 +++ libavcodec/mpegvideo.c | 71 -------------------------------------------------- libavcodec/mpegvideo.h | 2 -- 4 files changed, 75 insertions(+), 73 deletions(-) (limited to 'libavcodec') diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index 9e69bf7ae3..cfe3666b5c 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -457,6 +457,77 @@ static void draw_edges_c(uint8_t *buf, int wrap, int width, int height, int w) } } +/** + * Copies a rectangular area of samples to a temporary buffer and replicates the boarder samples. + * @param buf destination buffer + * @param src source buffer + * @param linesize number of bytes between 2 vertically adjacent samples in both the source and destination buffers + * @param block_w width of block + * @param block_h height of block + * @param src_x x coordinate of the top left sample of the block in the source buffer + * @param src_y y coordinate of the top left sample of the block in the source buffer + * @param w width of the source buffer + * @param h height of the source buffer + */ +void ff_emulated_edge_mc(uint8_t *buf, uint8_t *src, int linesize, int block_w, int block_h, + int src_x, int src_y, int w, int h){ + int x, y; + int start_y, start_x, end_y, end_x; + + if(src_y>= h){ + src+= (h-1-src_y)*linesize; + src_y=h-1; + }else if(src_y<=-block_h){ + src+= (1-block_h-src_y)*linesize; + src_y=1-block_h; + } + if(src_x>= w){ + src+= (w-1-src_x); + src_x=w-1; + }else if(src_x<=-block_w){ + src+= (1-block_w-src_x); + src_x=1-block_w; + } + + start_y= FFMAX(0, -src_y); + start_x= FFMAX(0, -src_x); + end_y= FFMIN(block_h, h-src_y); + end_x= FFMIN(block_w, w-src_x); + + // copy existing part + for(y=start_y; y= h){ - src+= (h-1-src_y)*linesize; - src_y=h-1; - }else if(src_y<=-block_h){ - src+= (1-block_h-src_y)*linesize; - src_y=1-block_h; - } - if(src_x>= w){ - src+= (w-1-src_x); - src_x=w-1; - }else if(src_x<=-block_w){ - src+= (1-block_w-src_x); - src_x=1-block_w; - } - - start_y= FFMAX(0, -src_y); - start_x= FFMAX(0, -src_x); - end_y= FFMIN(block_h, h-src_y); - end_x= FFMIN(block_w, w-src_x); - - // copy existing part - for(y=start_y; y