changeset 9499:bc5b87370cd1

cleanup
author michael
date Mon, 24 Feb 2003 00:12:30 +0000
parents 7e282f362dbe
children 4930b82dbf02
files postproc/swscale.c postproc/swscale_internal.h postproc/swscale_template.c postproc/yuv2rgb.c postproc/yuv2rgb_mlib.c postproc/yuv2rgb_template.c
diffstat 6 files changed, 31 insertions(+), 63 deletions(-) [+]
line wrap: on
line diff
--- a/postproc/swscale.c	Sun Feb 23 23:48:03 2003 +0000
+++ b/postproc/swscale.c	Mon Feb 24 00:12:30 2003 +0000
@@ -1764,7 +1764,7 @@
 /**
  * bring pointers in YUV order instead of YVU
  */
-inline void sws_orderYUV(int format, uint8_t * sortedP[], int sortedStride[], uint8_t * p[], int stride[]){
+inline static void sws_orderYUV(int format, uint8_t * sortedP[], int sortedStride[], uint8_t * p[], int stride[]){
 	if(format == IMGFMT_YV12 || format == IMGFMT_YVU9 
            || format == IMGFMT_444P || format == IMGFMT_422P || format == IMGFMT_411P){
 		sortedP[0]= p[0];
@@ -1797,16 +1797,8 @@
 }
 
 /* unscaled copy like stuff (assumes nearly identical formats) */
-static int simpleCopy(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY,
-             int srcSliceH, uint8_t* dstParam[], int dstStrideParam[]){
-
-	int srcStride[3];
-	int dstStride[3];
-	uint8_t *src[3];
-	uint8_t *dst[3];
-
-	sws_orderYUV(c->srcFormat, src, srcStride, srcParam, srcStrideParam);
-	sws_orderYUV(c->dstFormat, dst, dstStride, dstParam, dstStrideParam);
+static int simpleCopy(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
+             int srcSliceH, uint8_t* dst[], int dstStride[]){
 
 	if(isPacked(c->srcFormat))
 	{
@@ -2382,11 +2374,18 @@
 /**
  * swscale warper, so we dont need to export the SwsContext
  */
-int sws_scale(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
-                           int srcSliceH, uint8_t* dst[], int dstStride[]){
+int sws_scale(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY,
+                           int srcSliceH, uint8_t* dstParam[], int dstStrideParam[]){
+	int srcStride[3];
+	int dstStride[3];
+	uint8_t *src[3];
+	uint8_t *dst[3];
+
+	sws_orderYUV(c->srcFormat, src, srcStride, srcParam, srcStrideParam);
+	sws_orderYUV(c->dstFormat, dst, dstStride, dstParam, dstStrideParam);
+//printf("sws: slice %d %d\n", srcSliceY, srcSliceH);
 	return c->swScale(c, src, srcStride, srcSliceY, srcSliceH, dst, dstStride);
 }
-//FIXME order YV12/I420 here
 
 /**
  * returns a normalized gaussian curve used to filter stuff
--- a/postproc/swscale_internal.h	Sun Feb 23 23:48:03 2003 +0000
+++ b/postproc/swscale_internal.h	Mon Feb 24 00:12:30 2003 +0000
@@ -26,6 +26,10 @@
 
 /* this struct should be aligned on at least 32-byte boundary */
 typedef struct SwsContext{
+	/**
+	 *
+	 * Note the src,dst,srcStride,dstStride will be copied, in the sws_scale() warper so they can freely be modified here
+	 */
 	SwsFunc swScale;
 	int srcW, srcH, dstH;
 	int chrSrcW, chrSrcH, chrDstW, chrDstH;
@@ -119,7 +123,6 @@
 } SwsContext;
 //FIXME check init (where 0)
 
-inline void sws_orderYUV(int format, uint8_t * sortedP[], int sortedStride[], uint8_t * p[], int stride[]);
 SwsFunc yuv2rgb_get_func_ptr (SwsContext *c);
 int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation);
 
--- a/postproc/swscale_template.c	Sun Feb 23 23:48:03 2003 +0000
+++ b/postproc/swscale_template.c	Mon Feb 24 00:12:30 2003 +0000
@@ -1585,7 +1585,7 @@
 	{
 		int b=  ((uint32_t*)src)[i]&0xFF;
 		int g= (((uint32_t*)src)[i]>>8)&0xFF;
-		int r=  ((uint32_t*)src)[i]>>16;
+		int r= (((uint32_t*)src)[i]>>16)&0xFF;
 
 		dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT);
 	}
@@ -1946,7 +1946,7 @@
 	{
 		int r=  ((uint32_t*)src)[i]&0xFF;
 		int g= (((uint32_t*)src)[i]>>8)&0xFF;
-		int b=  ((uint32_t*)src)[i]>>16;
+		int b= (((uint32_t*)src)[i]>>16)&0xFF;
 
 		dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT);
 	}
@@ -2502,8 +2502,8 @@
    }
 }
 
-static int RENAME(swScale)(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY,
-             int srcSliceH, uint8_t* dstParam[], int dstStrideParam[]){
+static int RENAME(swScale)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
+             int srcSliceH, uint8_t* dst[], int dstStride[]){
 
 	/* load a few things into local vars to make the code more readable? and faster */
 	const int srcW= c->srcW;
@@ -2548,21 +2548,14 @@
 	int chrBufIndex= c->chrBufIndex;
 	int lastInLumBuf= c->lastInLumBuf;
 	int lastInChrBuf= c->lastInChrBuf;
-	int srcStride[3];
-	int dstStride[3];
-	uint8_t *src[3];
-	uint8_t *dst[3];
 	
-	sws_orderYUV(c->srcFormat, src, srcStride, srcParam, srcStrideParam);
-	sws_orderYUV(c->dstFormat, dst, dstStride, dstParam, dstStrideParam);
-
 	if(isPacked(c->srcFormat)){
 		src[0]=
 		src[1]=
-		src[2]= srcParam[0];
+		src[2]= src[0];
 		srcStride[0]=
 		srcStride[1]=
-		srcStride[2]= srcStrideParam[0];
+		srcStride[2]= srcStride[0];
 	}
 	srcStride[1]<<= c->vChrDrop;
 	srcStride[2]<<= c->vChrDrop;
--- a/postproc/yuv2rgb.c	Sun Feb 23 23:48:03 2003 +0000
+++ b/postproc/yuv2rgb.c	Mon Feb 24 00:12:30 2003 +0000
@@ -262,13 +262,10 @@
 	dst_2[6*i+3] = b[Y]; dst_2[6*i+4] = g[Y]; dst_2[6*i+5] = r[Y];
 
 #define PROLOG(func_name, dst_type) \
-static int func_name(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, \
+static int func_name(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, \
              int srcSliceH, uint8_t* dst[], int dstStride[]){\
-    uint8_t *src[3];\
-    int srcStride[3];\
     int y;\
 \
-    sws_orderYUV(c->srcFormat, src, srcStride, srcParam, srcStrideParam);\
     if(c->srcFormat == IMGFMT_422P){\
 	srcStride[1] *= 2;\
 	srcStride[2] *= 2;\
--- a/postproc/yuv2rgb_mlib.c	Sun Feb 23 23:48:03 2003 +0000
+++ b/postproc/yuv2rgb_mlib.c	Mon Feb 24 00:12:30 2003 +0000
@@ -33,12 +33,8 @@
 #include "../libvo/img_format.h" //FIXME try to reduce dependency of such stuff
 #include "swscale.h"
 
-static int mlib_YUV2ARGB420_32(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, 
+static int mlib_YUV2ARGB420_32(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, 
              int srcSliceH, uint8_t* dst[], int dstStride[]){
-    uint8_t *src[3];
-    int srcStride[3];
-
-    sws_orderYUV(c->srcFormat, src, srcStride, srcParam, srcStrideParam);
     if(c->srcFormat == IMGFMT_422P){
 	srcStride[1] *= 2;
 	srcStride[2] *= 2;
@@ -51,12 +47,8 @@
     return srcSliceH;
 }
 
-static int mlib_YUV2ABGR420_32(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, 
+static int mlib_YUV2ABGR420_32(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, 
              int srcSliceH, uint8_t* dst[], int dstStride[]){
-    uint8_t *src[3];
-    int srcStride[3];
-
-    sws_orderYUV(c->srcFormat, src, srcStride, srcParam, srcStrideParam);
     if(c->srcFormat == IMGFMT_422P){
 	srcStride[1] *= 2;
 	srcStride[2] *= 2;
@@ -69,12 +61,8 @@
     return srcSliceH;
 }
 
-static int mlib_YUV2RGB420_24(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, 
+static int mlib_YUV2RGB420_24(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, 
              int srcSliceH, uint8_t* dst[], int dstStride[]){
-    uint8_t *src[3];
-    int srcStride[3];
-
-    sws_orderYUV(c->srcFormat, src, srcStride, srcParam, srcStrideParam);
     if(c->srcFormat == IMGFMT_422P){
 	srcStride[1] *= 2;
 	srcStride[2] *= 2;
--- a/postproc/yuv2rgb_template.c	Sun Feb 23 23:48:03 2003 +0000
+++ b/postproc/yuv2rgb_template.c	Mon Feb 24 00:12:30 2003 +0000
@@ -123,13 +123,10 @@
 		     "punpcklbw %%mm5, %%mm2;" /* G7 G6 G5 G4 G3 G2 G1 G0 */\
 
 
-static inline int RENAME(yuv420_rgb16)(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY,
+static inline int RENAME(yuv420_rgb16)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
              int srcSliceH, uint8_t* dst[], int dstStride[]){
-    int srcStride[3];
-    uint8_t *src[3];
     int y, h_size;
 
-    sws_orderYUV(c->srcFormat, src, srcStride, srcParam, srcStrideParam);
     if(c->srcFormat == IMGFMT_422P){
 	srcStride[1] *= 2;
 	srcStride[2] *= 2;
@@ -221,13 +218,10 @@
     return srcSliceH;
 }
 
-static inline int RENAME(yuv420_rgb15)(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY,
+static inline int RENAME(yuv420_rgb15)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
              int srcSliceH, uint8_t* dst[], int dstStride[]){
-    int srcStride[3];
-    uint8_t *src[3];
     int y, h_size;
 
-    sws_orderYUV(c->srcFormat, src, srcStride, srcParam, srcStrideParam);
     if(c->srcFormat == IMGFMT_422P){
 	srcStride[1] *= 2;
 	srcStride[2] *= 2;
@@ -313,13 +307,10 @@
     return srcSliceH;
 }
 
-static inline int RENAME(yuv420_rgb24)(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY,
+static inline int RENAME(yuv420_rgb24)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
              int srcSliceH, uint8_t* dst[], int dstStride[]){
-    int srcStride[3];
-    uint8_t *src[3];
     int y, h_size;
 
-    sws_orderYUV(c->srcFormat, src, srcStride, srcParam, srcStrideParam);
     if(c->srcFormat == IMGFMT_422P){
 	srcStride[1] *= 2;
 	srcStride[2] *= 2;
@@ -462,13 +453,10 @@
     return srcSliceH;
 }
 
-static inline int RENAME(yuv420_rgb32)(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY,
+static inline int RENAME(yuv420_rgb32)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
              int srcSliceH, uint8_t* dst[], int dstStride[]){
-    int srcStride[3];
-    uint8_t *src[3];
     int y, h_size;
 
-    sws_orderYUV(c->srcFormat, src, srcStride, srcParam, srcStrideParam);
     if(c->srcFormat == IMGFMT_422P){
 	srcStride[1] *= 2;
 	srcStride[2] *= 2;