Commit f580719b authored by Michael Niedermayer's avatar Michael Niedermayer

swscale/swscale: Factor bottom to top handling

Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 5dcd913a
......@@ -761,6 +761,12 @@ int attribute_align_arg sws_scale(struct SwsContext *c,
uint8_t *dst2[4];
uint8_t *rgb0_tmp = NULL;
int macro_height = isBayer(c->srcFormat) ? 2 : (1 << c->chrSrcVSubSample);
// copy strides, so they can safely be modified
int srcStride2[4] = { srcStride[0], srcStride[1], srcStride[2],
srcStride[3] };
int dstStride2[4] = { dstStride[0], dstStride[1], dstStride[2],
dstStride[3] };
int srcSliceY_internal = srcSliceY;
if (!srcStride || !dstStride || !dst || !srcSlice) {
av_log(c, AV_LOG_ERROR, "One of the input parameters to sws_scale() is NULL, please check the calling code\n");
......@@ -943,30 +949,12 @@ int attribute_align_arg sws_scale(struct SwsContext *c,
for (i = 0; i < 4; i++)
memset(c->dither_error[i], 0, sizeof(c->dither_error[0][0]) * (c->dstW+2));
// copy strides, so they can safely be modified
if (c->sliceDir == 1) {
// slices go from top to bottom
int srcStride2[4] = { srcStride[0], srcStride[1], srcStride[2],
srcStride[3] };
int dstStride2[4] = { dstStride[0], dstStride[1], dstStride[2],
dstStride[3] };
reset_ptr(src2, c->srcFormat);
reset_ptr((void*)dst2, c->dstFormat);
/* reset slice direction at end of frame */
if (srcSliceY + srcSliceH == c->srcH)
c->sliceDir = 0;
ret = c->swscale(c, src2, srcStride2, srcSliceY, srcSliceH, dst2,
dstStride2);
} else {
if (c->sliceDir != 1) {
// slices go from bottom to top => we flip the image internally
int srcStride2[4] = { -srcStride[0], -srcStride[1], -srcStride[2],
-srcStride[3] };
int dstStride2[4] = { -dstStride[0], -dstStride[1], -dstStride[2],
-dstStride[3] };
for (i=0; i<4; i++) {
srcStride2[i] *= -1;
dstStride2[i] *= -1;
}
src2[0] += (srcSliceH - 1) * srcStride[0];
if (!usePal(c->srcFormat))
......@@ -978,16 +966,15 @@ int attribute_align_arg sws_scale(struct SwsContext *c,
dst2[2] += ((c->dstH >> c->chrDstVSubSample) - 1) * dstStride[2];
dst2[3] += ( c->dstH - 1) * dstStride[3];
reset_ptr(src2, c->srcFormat);
reset_ptr((void*)dst2, c->dstFormat);
/* reset slice direction at end of frame */
if (!srcSliceY)
c->sliceDir = 0;
ret = c->swscale(c, src2, srcStride2, c->srcH-srcSliceY-srcSliceH,
srcSliceH, dst2, dstStride2);
srcSliceY_internal = c->srcH-srcSliceY-srcSliceH;
}
reset_ptr(src2, c->srcFormat);
reset_ptr((void*)dst2, c->dstFormat);
/* reset slice direction at end of frame */
if (srcSliceY_internal + srcSliceH == c->srcH)
c->sliceDir = 0;
ret = c->swscale(c, src2, srcStride2, srcSliceY_internal, srcSliceH, dst2, dstStride2);
if (c->dstXYZ && !(c->srcXYZ && c->srcW==c->dstW && c->srcH==c->dstH)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment