[FFmpeg-cvslog] swscale: fix ticket #4881
Pedro Arthur
git at videolan.org
Tue Oct 13 20:12:44 CEST 2015
ffmpeg | branch: release/2.8 | Pedro Arthur <bygrandao at gmail.com> | Tue Oct 13 13:32:07 2015 -0300| [bb3b4ad46030939fbf44fb83c004ab851c55c3d3] | committer: Carl Eugen Hoyos
swscale: fix ticket #4881
When scaling only a slice of a frame the output was written always
in the first lines leaving the rest of the frame black.
(cherry picked from commit 5bd62a1b3c3356b84818efca3fcaf52da27a32af)
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bb3b4ad46030939fbf44fb83c004ab851c55c3d3
---
libswscale/slice.c | 34 ++++++++++++++++++----------------
libswscale/swscale.c | 4 ++--
libswscale/swscale_internal.h | 3 ++-
3 files changed, 22 insertions(+), 19 deletions(-)
diff --git a/libswscale/slice.c b/libswscale/slice.c
index 94841e5..38e12e3 100644
--- a/libswscale/slice.c
+++ b/libswscale/slice.c
@@ -144,7 +144,7 @@ int ff_rotate_slice(SwsSlice *s, int lum, int chr)
return 0;
}
-int ff_init_slice_from_src(SwsSlice * s, uint8_t *src[4], int stride[4], int srcW, int lumY, int lumH, int chrY, int chrH)
+int ff_init_slice_from_src(SwsSlice * s, uint8_t *src[4], int stride[4], int srcW, int lumY, int lumH, int chrY, int chrH, int relative)
{
int i = 0;
@@ -158,30 +158,32 @@ int ff_init_slice_from_src(SwsSlice * s, uint8_t *src[4], int stride[4], int src
chrY + chrH,
lumY + lumH};
+ const uint8_t *src_[4] = {src[0] + (relative ? 0 : start[0]) * stride[0],
+ src[1] + (relative ? 0 : start[1]) * stride[0],
+ src[2] + (relative ? 0 : start[2]) * stride[0],
+ src[3] + (relative ? 0 : start[3]) * stride[0]};
+
s->width = srcW;
for (i = 0; i < 4; ++i) {
int j;
- int lines = end[i];
- lines = s->plane[i].available_lines < lines ? s->plane[i].available_lines : lines;
+ int first = s->plane[i].sliceY;
+ int n = s->plane[i].available_lines;
+ int lines = end[i] - start[i];
+ int tot_lines = end[i] - first;
- if (end[i] > s->plane[i].sliceY+s->plane[i].sliceH) {
- if (start[i] <= s->plane[i].sliceY+1)
- s->plane[i].sliceY = FFMIN(start[i], s->plane[i].sliceY);
- else
- s->plane[i].sliceY = start[i];
- s->plane[i].sliceH = end[i] - s->plane[i].sliceY;
+ if (start[i] >= first && n >= tot_lines) {
+ s->plane[i].sliceH = FFMAX(tot_lines, s->plane[i].sliceH);
+ for (j = 0; j < lines; j+= 1)
+ s->plane[i].line[start[i] - first + j] = src_[i] + j * stride[i];
} else {
- if (end[i] >= s->plane[i].sliceY)
- s->plane[i].sliceH = s->plane[i].sliceY + s->plane[i].sliceH - start[i];
- else
- s->plane[i].sliceH = end[i] - start[i];
s->plane[i].sliceY = start[i];
+ lines = lines > n ? n : lines;
+ s->plane[i].sliceH = lines;
+ for (j = 0; j < lines; j+= 1)
+ s->plane[i].line[j] = src_[i] + j * stride[i];
}
- for (j = start[i]; j < lines; j+= 1)
- s->plane[i].line[j] = src[i] + (start[i] + j) * stride[i];
-
}
return 0;
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index ac224a8..722909a 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -471,11 +471,11 @@ static int swscale(SwsContext *c, const uint8_t *src[],
yuv2packed1, yuv2packed2, yuv2packedX, yuv2anyX, c->use_mmx_vfilter);
ff_init_slice_from_src(src_slice, (uint8_t**)src, srcStride, c->srcW,
- srcSliceY, srcSliceH, chrSrcSliceY, chrSrcSliceH);
+ srcSliceY, srcSliceH, chrSrcSliceY, chrSrcSliceH, 1);
ff_init_slice_from_src(vout_slice, (uint8_t**)dst, dstStride, c->dstW,
dstY, dstH, dstY >> c->chrDstVSubSample,
- FF_CEIL_RSHIFT(dstH, c->chrDstVSubSample));
+ FF_CEIL_RSHIFT(dstH, c->chrDstVSubSample), 0);
if (srcSliceY == 0) {
hout_slice->plane[0].sliceY = lastInLumBuf + 1;
hout_slice->plane[1].sliceY = lastInChrBuf + 1;
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 608cc3e..5dd23ef 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -1012,7 +1012,8 @@ typedef struct VScalerContext
} VScalerContext;
// warp input lines in the form (src + width*i + j) to slice format (line[i][j])
-int ff_init_slice_from_src(SwsSlice * s, uint8_t *src[4], int stride[4], int srcW, int lumY, int lumH, int chrY, int chrH);
+// relative=true means first line src[x][0] otherwise first line is src[x][lum/crh Y]
+int ff_init_slice_from_src(SwsSlice * s, uint8_t *src[4], int stride[4], int srcW, int lumY, int lumH, int chrY, int chrH, int relative);
// Initialize scaler filter descriptor chain
int ff_init_filters(SwsContext *c);
More information about the ffmpeg-cvslog
mailing list