changeset 8805:e547ce712577

YUV 411/422/444 support for pp
author michael
date Sun, 05 Jan 2003 19:10:42 +0000
parents b233200c3fca
children 1a308d921475
files libmpcodecs/vf_pp.c postproc/postprocess.c postproc/postprocess.h postproc/postprocess_internal.h postproc/postprocess_template.c
diffstat 5 files changed, 45 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vf_pp.c	Sun Jan 05 16:44:44 2003 +0000
+++ b/libmpcodecs/vf_pp.c	Sun Jan 05 19:10:42 2003 +0000
@@ -37,12 +37,20 @@
 static int config(struct vf_instance_s* vf,
         int width, int height, int d_width, int d_height,
 	unsigned int voflags, unsigned int outfmt){
-    if(vf->priv->context) pp_free_context(vf->priv->context);
-    vf->priv->context= pp_get_context(width, height,
+    int flags=
           (gCpuCaps.hasMMX   ? PP_CPU_CAPS_MMX   : 0)
 	| (gCpuCaps.hasMMX2  ? PP_CPU_CAPS_MMX2  : 0)
-	| (gCpuCaps.has3DNow ? PP_CPU_CAPS_3DNOW : 0)
-    );
+	| (gCpuCaps.has3DNow ? PP_CPU_CAPS_3DNOW : 0);
+
+    switch(outfmt){
+    case IMGFMT_444P: flags|= PP_FORMAT_444; break;
+    case IMGFMT_422P: flags|= PP_FORMAT_422; break;
+    case IMGFMT_411P: flags|= PP_FORMAT_411; break;
+    default:          flags|= PP_FORMAT_420; break;
+    }
+        
+    if(vf->priv->context) pp_free_context(vf->priv->context);
+    vf->priv->context= pp_get_context(width, height, flags);
 
     return vf_next_config(vf,width,height,d_width,d_height,voflags,vf->priv->outfmt);
 }
@@ -61,7 +69,10 @@
     case IMGFMT_YV12:
     case IMGFMT_I420:
     case IMGFMT_IYUV:
-	return vf_next_query_format(vf,vf->priv->outfmt);
+    case IMGFMT_444P:
+    case IMGFMT_422P:
+    case IMGFMT_411P:
+	return vf_next_query_format(vf,fmt);
     }
     return 0;
 }
@@ -129,6 +140,9 @@
     IMGFMT_YV12,
     IMGFMT_I420,
     IMGFMT_IYUV,
+    IMGFMT_444P,
+    IMGFMT_422P,
+    IMGFMT_411P,
     0
 };
 
--- a/postproc/postprocess.c	Sun Jan 05 16:44:44 2003 +0000
+++ b/postproc/postprocess.c	Sun Jan 05 19:10:42 2003 +0000
@@ -753,6 +753,13 @@
         
 	memset(c, 0, sizeof(PPContext));
 	c->cpuCaps= cpuCaps;
+	if(cpuCaps&PP_FORMAT){
+		c->hChromaSubSample= cpuCaps&0x3;
+		c->vChromaSubSample= (cpuCaps>>4)&0x3;
+	}else{
+		c->hChromaSubSample= 1;
+		c->vChromaSubSample= 1;
+	}
 
 	reallocBuffers(c, width, height, stride);
         
@@ -795,7 +802,6 @@
 	
 	if(c->stride < minStride)
 		reallocBuffers(c, width, height, minStride);
-        
 
 	if(QP_store==NULL || (mode->lumMode & FORCE_QUANT)) 
 	{
@@ -840,8 +846,8 @@
 	postProcess(src[0], srcStride[0], dst[0], dstStride[0],
 		width, height, QP_store, QPStride, 0, mode, c);
 
-	width  = (width +1)>>1;
-	height = (height+1)>>1;
+	width  = (width )>>c->hChromaSubSample;
+	height = (height)>>c->vChromaSubSample;
 
 	if(mode->chromMode)
 	{
--- a/postproc/postprocess.h	Sun Jan 05 16:44:44 2003 +0000
+++ b/postproc/postprocess.h	Sun Jan 05 19:10:42 2003 +0000
@@ -43,11 +43,17 @@
 pp_mode_t *pp_get_mode_by_name_and_quality(char *name, int quality);
 void pp_free_mode(pp_mode_t *mode);
 
-pp_context_t *pp_get_context(int width, int height, int cpuCaps);
+pp_context_t *pp_get_context(int width, int height, int flags);
 void pp_free_context(pp_context_t *ppContext);
 
 #define PP_CPU_CAPS_MMX   0x80000000
 #define PP_CPU_CAPS_MMX2  0x20000000
 #define PP_CPU_CAPS_3DNOW 0x40000000
 
+#define PP_FORMAT         0x00000008
+#define PP_FORMAT_420    (0x00000011|PP_FORMAT)
+#define PP_FORMAT_422    (0x00000001|PP_FORMAT)
+#define PP_FORMAT_411    (0x00000002|PP_FORMAT)
+#define PP_FORMAT_444    (0x00000000|PP_FORMAT)
+
 #endif
--- a/postproc/postprocess_internal.h	Sun Jan 05 16:44:44 2003 +0000
+++ b/postproc/postprocess_internal.h	Sun Jan 05 19:10:42 2003 +0000
@@ -119,6 +119,9 @@
 	int cpuCaps;
         
 	int stride; //size of some buffers (needed to realloc them if needed)
+        
+	int hChromaSubSample;
+	int vChromaSubSample;
 
 	PPMode ppMode;
 } PPContext;
--- a/postproc/postprocess_template.c	Sun Jan 05 16:44:44 2003 +0000
+++ b/postproc/postprocess_template.c	Sun Jan 05 19:10:42 2003 +0000
@@ -2663,6 +2663,9 @@
 	int i;
 #endif
 
+	const int qpHShift= isColor ? 4-c.hChromaSubSample : 4;
+	const int qpVShift= isColor ? 4-c.vChromaSubSample : 4;
+
 	//FIXME remove
 	uint64_t * const yHistogram= c.yHistogram;
 	uint8_t * const tempSrc= c.tempSrc;
@@ -2846,8 +2849,8 @@
 		uint8_t *tempBlock1= c.tempBlocks;
 		uint8_t *tempBlock2= c.tempBlocks + 8;
 #endif
-		int8_t *QPptr= isColor ? &QPs[(y>>3)*QPStride] :&QPs[(y>>4)*QPStride];
-		int8_t *nonBQPptr= isColor ? &c.nonBQPTable[(y>>3)*mbWidth] :&c.nonBQPTable[(y>>4)*mbWidth];
+		int8_t *QPptr= &QPs[(y>>qpVShift)*QPStride];
+		int8_t *nonBQPptr= &c.nonBQPTable[(y>>qpVShift)*mbWidth];
 		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 */
@@ -2886,8 +2889,8 @@
 #endif
 			if(isColor)
 			{
-				QP= QPptr[x>>3];
-				c.nonBQP= nonBQPptr[x>>3];
+				QP= QPptr[x>>qpHShift];
+				c.nonBQP= nonBQPptr[x>>qpHShift];
 			}
 			else
 			{