# HG changeset patch # User michaelni # Date 1050669934 0 # Node ID 2e06398e464769eb598d5e2d24c5a6986663edf4 # Parent f7522f310c7ead6b9aab2fc468f89746554bd133 mpeg2 qscale flag a few bugfixes for the C pp code minor optimization diff -r f7522f310c7e -r 2e06398e4647 avcodec.h --- a/avcodec.h Thu Apr 17 19:53:36 2003 +0000 +++ b/avcodec.h Fri Apr 18 12:45:34 2003 +0000 @@ -15,8 +15,8 @@ #define LIBAVCODEC_VERSION_INT 0x000406 #define LIBAVCODEC_VERSION "0.4.6" -#define LIBAVCODEC_BUILD 4663 -#define LIBAVCODEC_BUILD_STR "4663" +#define LIBAVCODEC_BUILD 4664 +#define LIBAVCODEC_BUILD_STR "4664" #define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" LIBAVCODEC_BUILD_STR @@ -314,8 +314,15 @@ * - encoding: unused\ * - decoding: set by lavc\ */\ - int repeat_pict; + int repeat_pict;\ + \ + /**\ + * \ + */\ + int qscale_type;\ +#define FF_QSCALE_TYPE_MPEG1 0 +#define FF_QSCALE_TYPE_MPEG2 1 #define FF_BUFFER_TYPE_INTERNAL 1 #define FF_BUFFER_TYPE_USER 2 ///< Direct rendering buffers diff -r f7522f310c7e -r 2e06398e4647 libpostproc/postprocess.c --- a/libpostproc/postprocess.c Thu Apr 17 19:53:36 2003 +0000 +++ b/libpostproc/postprocess.c Fri Apr 18 12:45:34 2003 +0000 @@ -199,8 +199,9 @@ { 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 @@ } 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 @@ 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 @@ c->vChromaSubSample= 1; } - reallocBuffers(c, width, height, stride); + reallocBuffers(c, width, height, stride, qpStride); c->frameNum=-1; @@ -804,6 +809,7 @@ free(c->tempDst); free(c->tempSrc); free(c->deintTemp); + free(c->stdQPTable); free(c->nonBQPTable); free(c->forcedQPTable); @@ -823,9 +829,11 @@ 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 @@ 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 -r f7522f310c7e -r 2e06398e4647 libpostproc/postprocess.h --- a/libpostproc/postprocess.h Thu Apr 17 19:53:36 2003 +0000 +++ b/libpostproc/postprocess.h Fri Apr 18 12:45:34 2003 +0000 @@ -66,6 +66,8 @@ #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 -r f7522f310c7e -r 2e06398e4647 libpostproc/postprocess_internal.h --- a/libpostproc/postprocess_internal.h Thu Apr 17 19:53:36 2003 +0000 +++ b/libpostproc/postprocess_internal.h Fri Apr 18 12:45:34 2003 +0000 @@ -137,6 +137,7 @@ 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 @@ 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 */ diff -r f7522f310c7e -r 2e06398e4647 mpeg12.c --- a/mpeg12.c Thu Apr 17 19:53:36 2003 +0000 +++ b/mpeg12.c Fri Apr 18 12:45:34 2003 +0000 @@ -2001,8 +2001,11 @@ if (s->mb_y<mb_height && !s->first_field) { /* end of image */ - if(s->mpeg2) - s->qscale >>=1; + if(s->mpeg2){ + s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_MPEG2; + }else + s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_MPEG1; + ff_er_frame_end(s); MPV_frame_end(s);