OK, I've merged all my comments into one place. And here it is.

This patch removes the monowhite switching code for 1 bpp raw AVI without a palette. I don't see any reason to keep it, since it's semantically incorrect to use monowhite for palettized data in my book, it adds unnecessary noise to the code, and it's inconsistent with the rest of the code in FFmpeg.

Regarding not being able to produce a working nut file with "ffmpeg -i in.avi -vcodec rawvideo out.nut", it's no more of a regression than not being able to produce a working nut file with the same command line from a 2, 4 or 8 bpp file, since nut currently doesn't have a pal8 mode.

In order to produce a working nut file from a 1, 2, 4 or 8 bpp AVI or QuickTime file, force the pixel format with "-pix_fmt rgb24" or similar. For black & white files in order to save space, use "-pix_fmt monow" or "-pix_fmt monob" (give or take the slightly erratic conversion from pal8 to monow/monob in FFmpeg).

I have also updated the 1 bpp FATE test files (once again).

I deliberately kept the pal8 placeholders for the future in case you wonder, Michael.

AVI (and BMP indirectly) doesn't have a dedicated grayscale mode like PNG, or explicit black & white mode like TIFF's bilevel mode or nut's B1W0 or B0W1 mode. Hence it should not use monowhite under any circumstances in my book. The BMP code in FFmpeg handles this correctly by using pal8 exclusively for 1 bpp.

Speaking of BMP, "ffmpeg -i 1bpp.bmp -vcodec rawvideo out.nut" will fail as well (since BMP correctly uses pal8). The same goes for any input file that is stored as pal8 internally. Since nut doesn't have a pal8 mode, it will incorrectly use the RGB[15] codec tag for some reason, but the data in the file will still be 8 bpp. So, if there ever was a "regression", it was there before this patch.

Mats

--
Mats Peterson
http://matsp888.no-ip.org/~mats/
>From 6c1c2223fefb946d128ab71ed38abbfa72af0c28 Mon Sep 17 00:00:00 2001
From: Mats Peterson <matsp...@yahoo.com>
Date: Sat, 6 Feb 2016 05:02:16 +0100
Subject: [PATCH] lavc/rawdec: Remove monowhite switching code for 1 bpp AVI without a palette

---
 libavcodec/rawdec.c               |   21 +--------------------
 tests/ref/vsynth/vsynth1-bpp1     |    4 ++--
 tests/ref/vsynth/vsynth2-bpp1     |    4 ++--
 tests/ref/vsynth/vsynth3-bpp1     |    4 ++--
 tests/ref/vsynth/vsynth_lena-bpp1 |    4 ++--
 5 files changed, 9 insertions(+), 28 deletions(-)

diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
index b7ce2b6..268e1b4 100644
--- a/libavcodec/rawdec.c
+++ b/libavcodec/rawdec.c
@@ -100,7 +100,7 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx)
             avpriv_set_systematic_pal2((uint32_t*)context->palette->data, avctx->pix_fmt);
         else {
             memset(context->palette->data, 0, AVPALETTE_SIZE);
-            if (avctx->bits_per_coded_sample <= 1)
+            if (avctx->bits_per_coded_sample == 1)
                 memset(context->palette->data, 0xff, 4);
         }
     }
@@ -128,10 +128,6 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx)
         avctx->pix_fmt   == AV_PIX_FMT_YUYV422)
         context->is_yuv2 = 1;
 
-    /* Temporary solution until PAL8 is implemented in nut */
-    if (context->is_pal8 && avctx->bits_per_coded_sample == 1)
-        avctx->pix_fmt = AV_PIX_FMT_NONE;
-
     return 0;
 }
 
@@ -204,21 +200,6 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
         return AVERROR_INVALIDDATA;
     }
 
-    /* Temporary solution until PAL8 is implemented in nut */
-    if (avctx->pix_fmt == AV_PIX_FMT_NONE &&
-        avctx->bits_per_coded_sample == 1 &&
-        avctx->frame_number == 0 &&
-        context->palette &&
-        AV_RB64(context->palette->data) == 0xFFFFFFFF00000000
-    ) {
-        const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
-        if (!pal) {
-            avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
-            context->is_pal8 = 0;
-            context->is_mono = 1;
-        } else
-            avctx->pix_fmt = AV_PIX_FMT_PAL8;
-    }
     desc = av_pix_fmt_desc_get(avctx->pix_fmt);
 
     if ((avctx->bits_per_coded_sample == 8 || avctx->bits_per_coded_sample == 4
diff --git a/tests/ref/vsynth/vsynth1-bpp1 b/tests/ref/vsynth/vsynth1-bpp1
index 32dab11..378f990 100644
--- a/tests/ref/vsynth/vsynth1-bpp1
+++ b/tests/ref/vsynth/vsynth1-bpp1
@@ -1,4 +1,4 @@
 3e5e0f4afb3a0350440e86b1ea56cec9 *tests/data/fate/vsynth1-bpp1.avi
 640452 tests/data/fate/vsynth1-bpp1.avi
-ccef5f5d5b0392f1d01c200499dac657 *tests/data/fate/vsynth1-bpp1.out.rawvideo
-stddev:   97.30 PSNR:  8.37 MAXDIFF:  237 bytes:  7603200/  7603200
+853694f3c1aa3ef3807ab1fccbeefe7b *tests/data/fate/vsynth1-bpp1.out.rawvideo
+stddev:   84.44 PSNR:  9.60 MAXDIFF:  221 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth2-bpp1 b/tests/ref/vsynth/vsynth2-bpp1
index d010bbd..ae8fd27 100644
--- a/tests/ref/vsynth/vsynth2-bpp1
+++ b/tests/ref/vsynth/vsynth2-bpp1
@@ -1,4 +1,4 @@
 771437c9038b44f4e2d4ff764c1c3821 *tests/data/fate/vsynth2-bpp1.avi
 640452 tests/data/fate/vsynth2-bpp1.avi
-ba70b5aebc786e625af6bd7f7ec82717 *tests/data/fate/vsynth2-bpp1.out.rawvideo
-stddev:   81.63 PSNR:  9.89 MAXDIFF:  237 bytes:  7603200/  7603200
+94261fc8aa20130cbd4361e15b742ef7 *tests/data/fate/vsynth2-bpp1.out.rawvideo
+stddev:   70.29 PSNR: 11.19 MAXDIFF:  221 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth3-bpp1 b/tests/ref/vsynth/vsynth3-bpp1
index f84808a..6f71248 100644
--- a/tests/ref/vsynth/vsynth3-bpp1
+++ b/tests/ref/vsynth/vsynth3-bpp1
@@ -1,4 +1,4 @@
 a5e6d1eff2f6fc3bba31e3bb8753b905 *tests/data/fate/vsynth3-bpp1.avi
 15352 tests/data/fate/vsynth3-bpp1.avi
-75e8ee0c0b0ada4515455d9f29377a16 *tests/data/fate/vsynth3-bpp1.out.rawvideo
-stddev:   97.70 PSNR:  8.33 MAXDIFF:  248 bytes:    86700/    86700
+79076b5fc43ee2a2284c0cde991d21f3 *tests/data/fate/vsynth3-bpp1.out.rawvideo
+stddev:   84.88 PSNR:  9.55 MAXDIFF:  232 bytes:    86700/    86700
diff --git a/tests/ref/vsynth/vsynth_lena-bpp1 b/tests/ref/vsynth/vsynth_lena-bpp1
index d4570c7..3e250a8 100644
--- a/tests/ref/vsynth/vsynth_lena-bpp1
+++ b/tests/ref/vsynth/vsynth_lena-bpp1
@@ -1,4 +1,4 @@
 d53d08c755ffde5fca744f0f941bfcb1 *tests/data/fate/vsynth_lena-bpp1.avi
 640452 tests/data/fate/vsynth_lena-bpp1.avi
-9a66df9009670b0a593d889975246c00 *tests/data/fate/vsynth_lena-bpp1.out.rawvideo
-stddev:   96.36 PSNR:  8.45 MAXDIFF:  233 bytes:  7603200/  7603200
+dce624117fcd2b16f38e0a0a62b13fa7 *tests/data/fate/vsynth_lena-bpp1.out.rawvideo
+stddev:   83.18 PSNR:  9.73 MAXDIFF:  217 bytes:  7603200/  7603200
-- 
1.7.10.4

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to