Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMats Peterson <matsp888@yahoo.com>2015-12-30 00:50:56 +0300
committerMichael Niedermayer <michael@niedermayer.cc>2016-01-04 05:31:35 +0300
commitbf42a7ef6d073221915dcc042c080374045ab245 (patch)
treed4c279e1d61dc576e1ffb1d7be5a222c7834f5f1 /libavcodec/qtrle.c
parent4da2ac5c7a491b20be62ad19d77526e62aa57c69 (diff)
lavc/qtrle: Use AV_PIX_FMT_PAL8 for 1-bit video
This commit fixes the lack of palettized display of 1-bit video in the qtrle decoder. It is related to my commit of lavf/qtpalette, which added 1-bit video to the "palettized video" category. As far as I can see, everything works fine, but comments are of course welcome. Below are links to sample files, which should now be displayed properly with bluish colors, but which were previously displayed in black & white. Matroska: https://drive.google.com/open?id=0B3_pEBoLs0faNjI0cHBMWDhYY2c Earth Spin 1-bit qtrle.mkv QuickTime (mov): https://drive.google.com/open?id=0B3_pEBoLs0faUlItWm9KaGJSTEE Earth Spin 1-bit qtrle.mov Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/qtrle.c')
-rw-r--r--libavcodec/qtrle.c45
1 files changed, 33 insertions, 12 deletions
diff --git a/libavcodec/qtrle.c b/libavcodec/qtrle.c
index 1fcf5b3c79..3f482f4453 100644
--- a/libavcodec/qtrle.c
+++ b/libavcodec/qtrle.c
@@ -83,9 +83,9 @@ static void qtrle_decode_1bpp(QtrleContext *s, int row_ptr, int lines_to_change)
if(skip & 0x80) {
lines_to_change--;
row_ptr += row_inc;
- pixel_ptr = row_ptr + 2 * (skip & 0x7f);
+ pixel_ptr = row_ptr + 2 * 8 * (skip & 0x7f);
} else
- pixel_ptr += 2 * skip;
+ pixel_ptr += 2 * 8 * skip;
CHECK_PIXEL_PTR(0); /* make sure pixel_ptr is positive */
if(rle_code == -1)
@@ -99,19 +99,42 @@ static void qtrle_decode_1bpp(QtrleContext *s, int row_ptr, int lines_to_change)
pi0 = bytestream2_get_byte(&s->g);
pi1 = bytestream2_get_byte(&s->g);
- CHECK_PIXEL_PTR(rle_code * 2);
+ CHECK_PIXEL_PTR(rle_code * 2 * 8);
while (rle_code--) {
- rgb[pixel_ptr++] = pi0;
- rgb[pixel_ptr++] = pi1;
+ rgb[pixel_ptr++] = (pi0 >> 7) & 0x01;
+ rgb[pixel_ptr++] = (pi0 >> 6) & 0x01;
+ rgb[pixel_ptr++] = (pi0 >> 5) & 0x01;
+ rgb[pixel_ptr++] = (pi0 >> 4) & 0x01;
+ rgb[pixel_ptr++] = (pi0 >> 3) & 0x01;
+ rgb[pixel_ptr++] = (pi0 >> 2) & 0x01;
+ rgb[pixel_ptr++] = (pi0 >> 1) & 0x01;
+ rgb[pixel_ptr++] = pi0 & 0x01;
+ rgb[pixel_ptr++] = (pi1 >> 7) & 0x01;
+ rgb[pixel_ptr++] = (pi1 >> 6) & 0x01;
+ rgb[pixel_ptr++] = (pi1 >> 5) & 0x01;
+ rgb[pixel_ptr++] = (pi1 >> 4) & 0x01;
+ rgb[pixel_ptr++] = (pi1 >> 3) & 0x01;
+ rgb[pixel_ptr++] = (pi1 >> 2) & 0x01;
+ rgb[pixel_ptr++] = (pi1 >> 1) & 0x01;
+ rgb[pixel_ptr++] = pi1 & 0x01;
}
} else {
/* copy the same pixel directly to output 2 times */
rle_code *= 2;
- CHECK_PIXEL_PTR(rle_code);
+ CHECK_PIXEL_PTR(rle_code * 8);
- bytestream2_get_buffer(&s->g, &rgb[pixel_ptr], rle_code);
- pixel_ptr += rle_code;
+ while (rle_code--) {
+ int x = bytestream2_get_byte(&s->g);
+ rgb[pixel_ptr++] = (x >> 7) & 0x01;
+ rgb[pixel_ptr++] = (x >> 6) & 0x01;
+ rgb[pixel_ptr++] = (x >> 5) & 0x01;
+ rgb[pixel_ptr++] = (x >> 4) & 0x01;
+ rgb[pixel_ptr++] = (x >> 3) & 0x01;
+ rgb[pixel_ptr++] = (x >> 2) & 0x01;
+ rgb[pixel_ptr++] = (x >> 1) & 0x01;
+ rgb[pixel_ptr++] = x & 0x01;
+ }
}
}
}
@@ -364,13 +387,10 @@ static av_cold int qtrle_decode_init(AVCodecContext *avctx)
s->avctx = avctx;
switch (avctx->bits_per_coded_sample) {
case 1:
- case 33:
- avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
- break;
-
case 2:
case 4:
case 8:
+ case 33:
case 34:
case 36:
case 40:
@@ -446,6 +466,7 @@ static int qtrle_decode_frame(AVCodecContext *avctx,
case 1:
case 33:
qtrle_decode_1bpp(s, row_ptr, height);
+ has_palette = 1;
break;
case 2: