From 655f688d54ab2a4160eafb26522c0d5f2791ca70 Mon Sep 17 00:00:00 2001 From: Jindřich Makovička Date: Sun, 27 Feb 2005 08:56:26 +0000 Subject: support for negative strides Originally committed as revision 3989 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/libpostproc/postprocess.c | 40 +++++++++++++++++---------- libavcodec/libpostproc/postprocess_internal.h | 8 ++++++ libavcodec/libpostproc/postprocess_template.c | 24 ++++++++-------- 3 files changed, 46 insertions(+), 26 deletions(-) (limited to 'libavcodec') diff --git a/libavcodec/libpostproc/postprocess.c b/libavcodec/libpostproc/postprocess.c index bc14ef3828..ba4dd83a14 100644 --- a/libavcodec/libpostproc/postprocess.c +++ b/libavcodec/libpostproc/postprocess.c @@ -1051,18 +1051,20 @@ void pp_postprocess(uint8_t * src[3], int srcStride[3], int mbHeight= (height+15)>>4; PPMode *mode = (PPMode*)vm; PPContext *c = (PPContext*)vc; - int minStride= MAX(srcStride[0], dstStride[0]); + int minStride= MAX(ABS(srcStride[0]), ABS(dstStride[0])); + int absQPStride = ABS(QPStride); - if(c->stride < minStride || c->qpStride < QPStride) + // c->stride and c->QPStride are always positive + if(c->stride < minStride || c->qpStride < absQPStride) reallocBuffers(c, width, height, MAX(minStride, c->stride), - MAX(c->qpStride, QPStride)); + MAX(c->qpStride, absQPStride)); if(QP_store==NULL || (mode->lumMode & FORCE_QUANT)) { int i; QP_store= c->forcedQPTable; - QPStride= 0; + absQPStride = QPStride = 0; if(mode->lumMode & FORCE_QUANT) for(i=0; iforcedQuant; else @@ -1072,7 +1074,7 @@ void pp_postprocess(uint8_t * src[3], int srcStride[3], if(pict_type & PP_PICT_TYPE_QP2){ int i; - const int count= mbHeight * QPStride; + const int count= mbHeight * absQPStride; for(i=0; i<(count>>2); i++){ ((uint32_t*)c->stdQPTable)[i] = (((uint32_t*)QP_store)[i]>>1) & 0x7F7F7F7F; } @@ -1080,6 +1082,7 @@ void pp_postprocess(uint8_t * src[3], int srcStride[3], c->stdQPTable[i] = QP_store[i]>>1; } QP_store= c->stdQPTable; + QPStride= absQPStride; } if(0){ @@ -1095,13 +1098,22 @@ for(y=0; y>2); i++){ - ((uint32_t*)c->nonBQPTable)[i] = ((uint32_t*)QP_store)[i] & 0x3F3F3F3F; - } - for(i<<=2; inonBQPTable[i] = QP_store[i] & 0x3F; + if (QPStride >= 0) { + int i; + const int count= mbHeight * QPStride; + for(i=0; i<(count>>2); i++){ + ((uint32_t*)c->nonBQPTable)[i] = ((uint32_t*)QP_store)[i] & 0x3F3F3F3F; + } + for(i<<=2; inonBQPTable[i] = QP_store[i] & 0x3F; + } + } else { + int i,j; + for(i=0; inonBQPTable[i*absQPStride+j] = QP_store[i*QPStride+j] & 0x3F; + } + } } } @@ -1125,8 +1137,8 @@ for(y=0; y 0) { + memcpy(dest, src, lines*stride); + } else { + memcpy(dest+(lines-1)*stride, src+(lines-1)*stride, -lines*stride); + } +} diff --git a/libavcodec/libpostproc/postprocess_template.c b/libavcodec/libpostproc/postprocess_template.c index 5e056aa04c..d1307cacab 100644 --- a/libavcodec/libpostproc/postprocess_template.c +++ b/libavcodec/libpostproc/postprocess_template.c @@ -3366,8 +3366,8 @@ static void RENAME(postProcess)(uint8_t src[], int srcStride, uint8_t dst[], int //FIXME remove uint64_t * const yHistogram= c.yHistogram; - uint8_t * const tempSrc= c.tempSrc; - uint8_t * const tempDst= c.tempDst; + uint8_t * const tempSrc= srcStride > 0 ? c.tempSrc : c.tempSrc - 23*srcStride; + uint8_t * const tempDst= dstStride > 0 ? c.tempDst : c.tempDst - 23*dstStride; //const int mbWidth= isColor ? (width+7)>>3 : (width+15)>>4; #ifdef HAVE_MMX @@ -3529,8 +3529,8 @@ static void RENAME(postProcess)(uint8_t src[], int srcStride, uint8_t dst[], int dstBlock+=8; srcBlock+=8; } - if(width==dstStride) - memcpy(dst, tempDst + 9*dstStride, copyAhead*dstStride); + if(width==ABS(dstStride)) + linecpy(dst, tempDst + 9*dstStride, copyAhead, dstStride); else { int i; @@ -3552,7 +3552,7 @@ static void RENAME(postProcess)(uint8_t src[], int srcStride, uint8_t dst[], int uint8_t *tempBlock2= c.tempBlocks + 8; #endif int8_t *QPptr= &QPs[(y>>qpVShift)*QPStride]; - int8_t *nonBQPptr= &c.nonBQPTable[(y>>qpVShift)*QPStride]; + int8_t *nonBQPptr= &c.nonBQPTable[(y>>qpVShift)*ABS(QPStride)]; int QP=0; /* can we mess with a 8x16 block from srcBlock/dstBlock downwards and 1 line upwards if not than use a temporary buffer */ @@ -3561,19 +3561,19 @@ static void RENAME(postProcess)(uint8_t src[], int srcStride, uint8_t dst[], int int i; /* copy from line (copyAhead) to (copyAhead+7) of src, these will be copied with blockcopy to dst later */ - memcpy(tempSrc + srcStride*copyAhead, srcBlock + srcStride*copyAhead, - srcStride*MAX(height-y-copyAhead, 0) ); + linecpy(tempSrc + srcStride*copyAhead, srcBlock + srcStride*copyAhead, + MAX(height-y-copyAhead, 0), srcStride); /* duplicate last line of src to fill the void upto line (copyAhead+7) */ for(i=MAX(height-y, 8); i= height) { uint8_t *dstBlock= &(dst[y*dstStride]); - if(width==dstStride) - memcpy(dstBlock, tempDst + dstStride, dstStride*(height-y)); + if(width==ABS(dstStride)) + linecpy(dstBlock, tempDst + dstStride, height-y, dstStride); else { int i; -- cgit v1.2.3