From 6f3b07176ae833429586bf9d27c8477db9efa7a7 Mon Sep 17 00:00:00 2001 From: Mike Melanson Date: Thu, 19 Jun 2003 00:47:19 +0000 Subject: maintenance ffmpeg sync: import and activate decoders for 4X and RealAudio codecs; import VP3 decoder but leave de-activated; fixes for SVQ3 bugs; more conditional compilation for encoders CVS patchset: 5067 CVS date: 2003/06/19 00:47:19 --- src/libffmpeg/libavcodec/libpostproc/postprocess.c | 66 ++++++++++++++-------- src/libffmpeg/libavcodec/libpostproc/postprocess.h | 2 + .../libavcodec/libpostproc/postprocess_internal.h | 5 +- .../libavcodec/libpostproc/postprocess_template.c | 2 +- 4 files changed, 50 insertions(+), 25 deletions(-) (limited to 'src/libffmpeg/libavcodec/libpostproc') diff --git a/src/libffmpeg/libavcodec/libpostproc/postprocess.c b/src/libffmpeg/libavcodec/libpostproc/postprocess.c index ce61ffd39..8473882bb 100644 --- a/src/libffmpeg/libavcodec/libpostproc/postprocess.c +++ b/src/libffmpeg/libavcodec/libpostproc/postprocess.c @@ -169,8 +169,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 more deblocking\n" -" 2. flatness threshold: default=40, lower -> more deblocking\n" +" 1. difference factor: default=32, higher -> more deblocking\n" +" 2. flatness threshold: default=39, lower -> more deblocking\n" " the h & v deblocking filters share these\n" " so u cant set different thresholds for h / v\n" "vb vdeblock (2 Threshold) vertical deblocking filter\n" @@ -523,8 +525,8 @@ pp_mode_t *pp_get_mode_by_name_and_quality(char *name, int quality) ppMode->maxTmpNoise[2]= 3000; ppMode->maxAllowedY= 234; ppMode->minAllowedY= 16; - ppMode->baseDcDiff= 256/4; - ppMode->flatnessThreshold= 56-16; + ppMode->baseDcDiff= 256/8; + ppMode->flatnessThreshold= 56-16-1; ppMode->maxClippedThreshold= 0.01; ppMode->error=0; @@ -705,12 +707,13 @@ static void reallocAlign(void **p, int alignment, int size){ memset(*p, 0, size); } -static void reallocBuffers(PPContext *c, int width, int height, int stride){ +static void reallocBuffers(PPContext *c, int width, int height, int stride, int qpStride){ int mbWidth = (width+15)>>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); @@ -727,11 +730,12 @@ 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)); } -static void global_init(){ +static void global_init(void){ int i; memset(clip_table, 0, 256); for(i=256; i<512; i++) @@ -742,6 +746,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(); @@ -755,7 +760,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; @@ -774,6 +779,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); @@ -793,9 +799,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)) { @@ -807,6 +815,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; } } diff --git a/src/libffmpeg/libavcodec/libpostproc/postprocess.h b/src/libffmpeg/libavcodec/libpostproc/postprocess.h index fd8a42c13..dae863044 100644 --- a/src/libffmpeg/libavcodec/libpostproc/postprocess.h +++ b/src/libffmpeg/libavcodec/libpostproc/postprocess.h @@ -66,6 +66,8 @@ void pp_free_context(pp_context_t *ppContext); #define PP_FORMAT_411 (0x00000002|PP_FORMAT) #define PP_FORMAT_444 (0x00000000|PP_FORMAT) +#define PP_PICT_TYPE_QP2 0x00000010 ///< MPEG2 style QScale + #ifdef __cplusplus } #endif diff --git a/src/libffmpeg/libavcodec/libpostproc/postprocess_internal.h b/src/libffmpeg/libavcodec/libpostproc/postprocess_internal.h index febea1818..13b3e3831 100644 --- a/src/libffmpeg/libavcodec/libpostproc/postprocess_internal.h +++ b/src/libffmpeg/libavcodec/libpostproc/postprocess_internal.h @@ -137,6 +137,7 @@ typedef struct PPContext{ uint64_t __attribute__((aligned(8))) mmxDcOffset[32]; uint64_t __attribute__((aligned(8))) mmxDcThreshold[32]; + QP_STORE_T *stdQPTable; ///< used to fix MPEG2 style qscale QP_STORE_T *nonBQPTable; QP_STORE_T *forcedQPTable; @@ -147,7 +148,8 @@ typedef struct PPContext{ int cpuCaps; - int stride; ///>qpVShift)*QPStride]; - int8_t *nonBQPptr= &c.nonBQPTable[(y>>qpVShift)*mbWidth]; + int8_t *nonBQPptr= &c.nonBQPTable[(y>>qpVShift)*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 */ -- cgit v1.2.3