changeset 15248:43e55b3d1af0

support for both orderings of the slices (top->down / bottom->up)
author henry
date Sun, 24 Apr 2005 07:47:41 +0000
parents adaba898053d
children 0deaa53ed5ad
files postproc/swscale.c postproc/swscale_internal.h
diffstat 2 files changed, 29 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/postproc/swscale.c	Sun Apr 24 07:43:41 2005 +0000
+++ b/postproc/swscale.c	Sun Apr 24 07:47:41 2005 +0000
@@ -2275,10 +2275,34 @@
  */
 int sws_scale_ordered(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
                            int srcSliceH, uint8_t* dst[], int dstStride[]){
-	//copy strides, so they can safely be modified
-	int srcStride2[3]= {srcStride[0], srcStride[1], srcStride[2]};
-	int dstStride2[3]= {dstStride[0], dstStride[1], dstStride[2]};
-	return c->swScale(c, src, srcStride2, srcSliceY, srcSliceH, dst, dstStride2);
+	if (c->sliceDir == 0 && srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) {
+	    MSG_ERR("swScaler: slices start in the middle!\n");
+	    return 0;
+	}
+	if (c->sliceDir == 0) {
+	    if (srcSliceY == 0) c->sliceDir = 1; else c->sliceDir = -1;
+	}
+
+	// copy strides, so they can safely be modified
+	if (c->sliceDir == 1) {
+	    // slices go from top to bottom
+	    int srcStride2[3]= {srcStride[0], srcStride[1], srcStride[2]};
+	    int dstStride2[3]= {dstStride[0], dstStride[1], dstStride[2]};
+	    return c->swScale(c, src, srcStride2, srcSliceY, srcSliceH, dst, dstStride2);
+	} else {
+	    // slices go from bottom to top => we flip the image internally
+	    uint8_t* src2[3]= {src[0] + (srcSliceH-1)*srcStride[0],
+			       src[1] + ((srcSliceH>>c->chrSrcVSubSample)-1)*srcStride[1],
+			       src[2] + ((srcSliceH>>c->chrSrcVSubSample)-1)*srcStride[2]
+	    };
+	    uint8_t* dst2[3]= {dst[0] + (c->dstH-1)*dstStride[0],
+			       dst[1] + ((c->dstH>>c->chrDstVSubSample)-1)*dstStride[1],
+			       dst[2] + ((c->dstH>>c->chrDstVSubSample)-1)*dstStride[2]};
+	    int srcStride2[3]= {-srcStride[0], -srcStride[1], -srcStride[2]};
+	    int dstStride2[3]= {-dstStride[0], -dstStride[1], -dstStride[2]};
+	    
+	    return c->swScale(c, src2, srcStride2, c->srcH-srcSliceY-srcSliceH, srcSliceH, dst2, dstStride2);
+	}
 }
 
 /**
--- a/postproc/swscale_internal.h	Sun Apr 24 07:43:41 2005 +0000
+++ b/postproc/swscale_internal.h	Sun Apr 24 07:47:41 2005 +0000
@@ -60,6 +60,7 @@
 	int chrIntHSubSample, chrIntVSubSample;
 	int chrDstHSubSample, chrDstVSubSample;
 	int vChrDrop;
+        int sliceDir;
 	double param[2];
 
 	int16_t **lumPixBuf;