summaryrefslogtreecommitdiff
path: root/libavcodec/qtrle.c
diff options
context:
space:
mode:
authorAlexis Ballier <aballier@gentoo.org>2011-12-07 09:27:20 -0300
committerMichael Niedermayer <michaelni@gmx.at>2011-12-07 21:11:51 +0100
commit1af91978dbab35ba9fdede187577c00d643ae33b (patch)
tree7dca1a1bed6af7863e881087ded37790d96a2309 /libavcodec/qtrle.c
parent0be95fe1836a1ecad980240de793b72e7421a84f (diff)
qtrle.c: Fix for ticket #226.
In 1bpp mode, interpret skip&0x80 as "start a new line" instead of "go to next line", this is almost the same except for the first line which was always skipped before and caused to try to write an extra line at the end of the frame (ticket #226). Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/qtrle.c')
-rw-r--r--libavcodec/qtrle.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/libavcodec/qtrle.c b/libavcodec/qtrle.c
index c7a04c0520..e84a63bc30 100644
--- a/libavcodec/qtrle.c
+++ b/libavcodec/qtrle.c
@@ -72,6 +72,15 @@ static void qtrle_decode_1bpp(QtrleContext *s, int stream_ptr, int row_ptr, int
unsigned char *rgb = s->frame.data[0];
int pixel_limit = s->frame.linesize[0] * s->avctx->height;
int skip;
+ /* skip & 0x80 appears to mean 'start a new line', which can be interpreted
+ * as 'go to next line' during the decoding of a frame but is 'go to first
+ * line' at the beginning. Since we always interpret it as 'go to next line'
+ * in the decoding loop (which makes code simpler/faster), the first line
+ * would not be counted, so we count one more.
+ * See: https://ffmpeg.org/trac/ffmpeg/ticket/226
+ * In the following decoding loop, row_ptr will be the position of the
+ * _next_ row. */
+ lines_to_change++;
while (lines_to_change) {
CHECK_STREAM_PTR(2);
@@ -81,8 +90,8 @@ static void qtrle_decode_1bpp(QtrleContext *s, int stream_ptr, int row_ptr, int
break;
if(skip & 0x80) {
lines_to_change--;
- row_ptr += row_inc;
pixel_ptr = row_ptr + 2 * (skip & 0x7f);
+ row_ptr += row_inc;
} else
pixel_ptr += 2 * skip;
CHECK_PIXEL_PTR(0); /* make sure pixel_ptr is positive */