aboutsummaryrefslogtreecommitdiffstats
path: root/postproc/swscale.c
diff options
context:
space:
mode:
authorJindřich Makovička <makovick@gmail.com>2005-04-24 07:47:41 +0000
committerJindřich Makovička <makovick@gmail.com>2005-04-24 07:47:41 +0000
commite63ac25d05587df64f615e548543fc5f0e8c33b9 (patch)
tree01e68e6c1631e77953f1311f4ccaad8a23d99be1 /postproc/swscale.c
parent4719d1f3811c3e7e9caaa35aff0ffcf91cd22718 (diff)
downloadffmpeg-e63ac25d05587df64f615e548543fc5f0e8c33b9.tar.gz
support for both orderings of the slices (top->down / bottom->up)
Originally committed as revision 15249 to svn://svn.mplayerhq.hu/mplayer/trunk/postproc
Diffstat (limited to 'postproc/swscale.c')
-rw-r--r--postproc/swscale.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/postproc/swscale.c b/postproc/swscale.c
index 71e6ff515f..a94de52af6 100644
--- a/postproc/swscale.c
+++ b/postproc/swscale.c
@@ -2275,10 +2275,34 @@ SwsContext *sws_getContext(int srcW, int srcH, int origSrcFormat, int dstW, int
*/
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);
+ }
}
/**