[FFmpeg-cvslog] swscale/swscale: Factor bottom to top handling
Michael Niedermayer
git at videolan.org
Fri Sep 2 22:58:49 EEST 2016
ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Fri Sep 2 16:35:36 2016 +0200| [f580719b1a24a311ef9e38efce214fd77373dbc2] | committer: Michael Niedermayer
swscale/swscale: Factor bottom to top handling
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f580719b1a24a311ef9e38efce214fd77373dbc2
---
libswscale/swscale.c | 51 +++++++++++++++++++--------------------------------
1 file changed, 19 insertions(+), 32 deletions(-)
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index bbea0fe..63d16bd 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -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)) {
More information about the ffmpeg-cvslog
mailing list