From 0426af31117b1bc50b3abb2b4265c38b8c02e7a5 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 18 Apr 2003 12:45:34 +0000 Subject: mpeg2 qscale flag a few bugfixes for the C pp code minor optimization Originally committed as revision 1786 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/libpostproc/postprocess.c | 56 ++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 18 deletions(-) (limited to 'libavcodec/libpostproc/postprocess.c') diff --git a/libavcodec/libpostproc/postprocess.c b/libavcodec/libpostproc/postprocess.c index e922965cc4..f91bed6d05 100644 --- a/libavcodec/libpostproc/postprocess.c +++ b/libavcodec/libpostproc/postprocess.c @@ -199,8 +199,9 @@ static inline int isHorizDC(uint8_t src[], int stride, PPContext *c) { int numEq= 0; int y; - const int dcOffset= ((c->QP*c->ppMode.baseDcDiff)>>8) + 1; + const int dcOffset= ((c->nonBQP*c->ppMode.baseDcDiff)>>8) + 1; const int dcThreshold= dcOffset*2 + 1; + for(y=0; yQP*c->ppMode.baseDcDiff)>>8) + 1; + const int dcOffset= ((c->nonBQP*c->ppMode.baseDcDiff)>>8) + 1; const int dcThreshold= dcOffset*2 + 1; + src+= stride*4; // src points to begin of the 8x8 Block for(y=0; y>4; int mbHeight= (height+15)>>4; int i; c->stride= stride; + c->qpStride= qpStride; reallocAlign((void **)&c->tempDst, 8, stride*24); reallocAlign((void **)&c->tempSrc, 8, stride*24); @@ -757,7 +760,8 @@ static void reallocBuffers(PPContext *c, int width, int height, int stride){ } reallocAlign((void **)&c->deintTemp, 8, 2*width+32); - reallocAlign((void **)&c->nonBQPTable, 8, mbWidth*mbHeight*sizeof(QP_STORE_T)); + reallocAlign((void **)&c->nonBQPTable, 8, qpStride*mbHeight*sizeof(QP_STORE_T)); + reallocAlign((void **)&c->stdQPTable, 8, qpStride*mbHeight*sizeof(QP_STORE_T)); reallocAlign((void **)&c->forcedQPTable, 8, mbWidth*sizeof(QP_STORE_T)); } @@ -772,6 +776,7 @@ static void global_init(){ pp_context_t *pp_get_context(int width, int height, int cpuCaps){ PPContext *c= memalign(32, sizeof(PPContext)); int stride= (width+15)&(~15); //assumed / will realloc if needed + int qpStride= (width+15)/16 + 2; //assumed / will realloc if needed global_init(); @@ -785,7 +790,7 @@ pp_context_t *pp_get_context(int width, int height, int cpuCaps){ c->vChromaSubSample= 1; } - reallocBuffers(c, width, height, stride); + reallocBuffers(c, width, height, stride, qpStride); c->frameNum=-1; @@ -804,6 +809,7 @@ void pp_free_context(void *vc){ free(c->tempDst); free(c->tempSrc); free(c->deintTemp); + free(c->stdQPTable); free(c->nonBQPTable); free(c->forcedQPTable); @@ -823,9 +829,11 @@ void pp_postprocess(uint8_t * src[3], int srcStride[3], PPMode *mode = (PPMode*)vm; PPContext *c = (PPContext*)vc; int minStride= MAX(srcStride[0], dstStride[0]); - - if(c->stride < minStride) - reallocBuffers(c, width, height, minStride); + + if(c->stride < minStride || c->qpStride < QPStride) + reallocBuffers(c, width, height, + MAX(minStride, c->stride), + MAX(c->qpStride, QPStride)); if(QP_store==NULL || (mode->lumMode & FORCE_QUANT)) { @@ -837,6 +845,20 @@ void pp_postprocess(uint8_t * src[3], int srcStride[3], else for(i=0; i>2); i++){ + ((uint32_t*)c->stdQPTable)[i] = (((uint32_t*)QP_store)[i]>>1) & 0x7F7F7F7F; + } + for(i<<=2; istdQPTable[i] = QP_store[i]>>1; + } + QP_store= c->stdQPTable; + } + if(0){ int x,y; for(y=0; ynonBQPTable[y*mbWidth + x]= qscale; - } + int i; + const int count= mbHeight * QPStride; + for(i=0; i<(count>>2); i++){ + ((uint32_t*)c->nonBQPTable)[i] = ((uint32_t*)QP_store)[i] & 0x1F1F1F1F; + } + for(i<<=2; inonBQPTable[i] = QP_store[i] & 0x1F; } } -- cgit v1.2.3