X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fdsputil.c;h=80efd07825bf026558abc0f16052592002ddde17;hb=bbdfa06d437a1cb8dd18169bc0c3db129aaa25d2;hp=9e69bf7ae3c983ca229fe5370e8bf70ae0a688f7;hpb=4c79b95c32ec9d44af48a5a52c7390b84c52928c;p=ffmpeg diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index 9e69bf7ae3c..80efd07825b 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -29,7 +29,6 @@ #include "avcodec.h" #include "dsputil.h" -#include "mpegvideo.h" #include "simple_idct.h" #include "faandct.h" #include "faanidct.h" @@ -152,6 +151,8 @@ static const uint8_t simple_mmx_permutation[64]={ 0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F, }; +static const uint8_t idct_sse2_row_perm[8] = {0, 4, 1, 5, 2, 6, 3, 7}; + void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable){ int i; int end; @@ -457,6 +458,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; yac_esc_length; uint8_t * length; uint8_t * last_length; @@ -3693,9 +3765,9 @@ static int rd8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int s->dsp.idct_add(bak, stride, temp); - distoration= s->dsp.sse[1](NULL, bak, src1, stride, 8); + distortion= s->dsp.sse[1](NULL, bak, src1, stride, 8); - return distoration + ((bits*s->qscale*s->qscale*109 + 64)>>7); + return distortion + ((bits*s->qscale*s->qscale*109 + 64)>>7); } static int bit8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){ @@ -4406,6 +4478,10 @@ void dsputil_init(DSPContext* c, AVCodecContext *avctx) for(i=0; i<64; i++) c->idct_permutation[i]= (i&0x24) | ((i&3)<<3) | ((i>>3)&3); break; + case FF_SSE2_IDCT_PERM: + for(i=0; i<64; i++) + c->idct_permutation[i]= (i&0x38) | idct_sse2_row_perm[i&7]; + break; default: av_log(avctx, AV_LOG_ERROR, "Internal error, IDCT permutation not set\n"); }