changeset 30412:41fb4acf3df6

Support more qscale types in most post-processing filters.
author reimar
date Fri, 29 Jan 2010 19:13:07 +0000
parents bf19c3502f1b
children e75026202313
files libmpcodecs/vf.h libmpcodecs/vf_fspp.c libmpcodecs/vf_pp7.c libmpcodecs/vf_spp.c libmpcodecs/vf_uspp.c
diffstat 5 files changed, 19 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vf.h	Fri Jan 29 13:54:20 2010 +0000
+++ b/libmpcodecs/vf.h	Fri Jan 29 19:13:07 2010 +0000
@@ -129,4 +129,19 @@
 		      int width, int height, int d_width, int d_height,
 		      unsigned int flags, unsigned int outfmt);
 
+static inline int norm_qscale(int qscale, int type)
+{
+    switch (type) {
+    case 0: // MPEG-1
+        return qscale;
+    case 1: // MPEG-2
+        return qscale >> 1;
+    case 2: // H264
+        return qscale >> 2;
+    case 3: // VP56
+        return (63 - qscale + 2) >> 2;
+    }
+    return qscale;
+}
+
 #endif /* MPLAYER_VF_H */
--- a/libmpcodecs/vf_fspp.c	Fri Jan 29 13:54:20 2010 +0000
+++ b/libmpcodecs/vf_fspp.c	Fri Jan 29 19:13:07 2010 +0000
@@ -454,7 +454,7 @@
 		    t=x+x0-2; //correct t=x+x0-2-(y&1), but its the same
 		    if (t<0) t=0;//t always < width-2
 		    t=qp_store[qy+(t>>qps)];
-		    if(p->mpeg2) t>>=1; //copy p->mpeg2,prev_q to locals?
+		    t=norm_qscale(t, p->mpeg2);
 		    if (t!=p->prev_q) p->prev_q=t, mul_thrmat_s(p, t);
 		    column_fidct_s((int16_t*)(&p->threshold_mtx[0]), block+x*8, block3+x*8, 8); //yes, this is a HOTSPOT
 		}
--- a/libmpcodecs/vf_pp7.c	Fri Jan 29 13:54:20 2010 +0000
+++ b/libmpcodecs/vf_pp7.c	Fri Jan 29 19:13:07 2010 +0000
@@ -321,7 +321,7 @@
                 qp= p->qp;
             else{
                 qp= qp_store[ (XMIN(x, width-1)>>qps) + (XMIN(y, height-1)>>qps) * qp_stride];
-                if(p->mpeg2) qp>>=1;
+                qp=norm_qscale(qp, p->mpeg2);
             }
             for(; x<end; x++){
                 const int index= x + y*stride + (8-3)*(1+stride) + 8; //FIXME silly offset
--- a/libmpcodecs/vf_spp.c	Fri Jan 29 13:54:20 2010 +0000
+++ b/libmpcodecs/vf_spp.c	Fri Jan 29 19:13:07 2010 +0000
@@ -406,7 +406,7 @@
 				qp= p->qp;
 			else{
 				qp= qp_store[ (XMIN(x, width-1)>>qps) + (XMIN(y, height-1)>>qps) * qp_stride];
-				if(p->mpeg2) qp = FFMAX(1, qp>>1);
+				qp = FFMAX(1, norm_qscale(qp, p->mpeg2));
 			}
 			for(i=0; i<count; i++){
 				const int x1= x + offset[i+count-1][0];
--- a/libmpcodecs/vf_uspp.c	Fri Jan 29 13:54:20 2010 +0000
+++ b/libmpcodecs/vf_uspp.c	Fri Jan 29 19:13:07 2010 +0000
@@ -168,7 +168,7 @@
     if(p->qp)
         p->frame->quality= p->qp * FF_QP2LAMBDA;
     else
-        p->frame->quality= (qp_store[0] * FF_QP2LAMBDA)>>p->mpeg2;
+        p->frame->quality= norm_qscale(qp_store[0], p->mpeg2) * FF_QP2LAMBDA;
 //    init per MB qscale stuff FIXME
 
     for(i=0; i<count; i++){