aboutsummaryrefslogtreecommitdiffstats
path: root/libswscale/slice.c
diff options
context:
space:
mode:
authorPedro Arthur <bygrandao@gmail.com>2015-10-13 13:32:07 -0300
committerPedro Arthur <bygrandao@gmail.com>2015-10-13 13:43:39 -0300
commit5bd62a1b3c3356b84818efca3fcaf52da27a32af (patch)
tree315f041e83eb44beeead3d743a5f2b4d79a5fca3 /libswscale/slice.c
parentde262d018d7d7d9c967af1dfd1b861c4b9eb2a60 (diff)
downloadffmpeg-5bd62a1b3c3356b84818efca3fcaf52da27a32af.tar.gz
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.
Diffstat (limited to 'libswscale/slice.c')
-rw-r--r--libswscale/slice.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/libswscale/slice.c b/libswscale/slice.c
index 94841e5776..38e12e33ec 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;