Updated the FATE test files for the latest checkout.

The stride will be calculated incorrectly for the attached 3 x 3 pixel pal8 nut file, since there is some padding in the packet after the video data and before the palette. It will be properly rounded down to the real width of the video data for larger sizes, but this one will be 4 instead of 3. I've tried a 1x1 file, but that one wouldn't play at all. Anyway, run ffplay with "-v debug" to output the packet size and the stride.

If you have a better solution, feel free to change the stride calculation code. I suppose it's not that bad after all, since there aren't too many users who use 3 x 3 pixel videos out there. But it's a bit irritating nevertheless. Life would be easier if there were no padding between the video data and the palette, but I guess it's done for memory alignment purposes.

Just remember this: When using "-vcodec copy" with nut as the output, FFmpeg will happily copy the video to the file without ever considering the stride of it. Therefore, it's not possible to base the stride on avctx->width for nut. It would of course be much easier. One will have to divide the packet size (minus the palette size, 1024 bytes, in the case of pal8 nut) with the height, in the same way as the stride is calculated for AVI and QuickTime. They don't contain any palette in the packets, of course.

Description follows:

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.

For black & white AVI or QuickTime files, in order to produce a monochrome nut file, force the pixel format with "-pix_fmt monow" or "-pix_fmt monob".

Another way is to use "ffmpeg -i 1bpp.avi -vcodec copy -vtag B1W0 1bpp.nut". The "-vtag" option is currently needed, otherwise FFmpeg will use a RGB[15] codec tag for some reason.

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

Mats
>From 999aa8311b0b018accf35b5825af2c027efeb474 Mon Sep 17 00:00:00 2001
From: Mats Peterson <matsp...@yahoo.com>
Date: Thu, 11 Feb 2016 03:16:00 +0100
Subject: [PATCH v8] lavc/rawdec: Remove monowhite switching code for 1 bpp AVI without a palette

---
 libavcodec/rawdec.c               |   62 ++++++++++-----------------
 tests/ref/fate/sub2video          |   85 ++++++++++++++++++++++++++++++++++++-
 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 +-
 6 files changed, 115 insertions(+), 48 deletions(-)

diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
index b7ce2b6..83ca576 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);
         }
     }
@@ -121,17 +121,13 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx)
     if (avctx->codec_tag == MKTAG('B','1','W','0') ||
         avctx->codec_tag == MKTAG('B','0','W','1'))
         context->is_nut_mono = 1;
-    else if (avctx->codec_tag == MKTAG('P','A','L','8'))
+    else if (avctx->codec_tag == MKTAG('P','A','L',8))
         context->is_nut_pal8 = 1;
 
     if (avctx->codec_tag == AV_RL32("yuv2") &&
         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;
 }
 
@@ -192,33 +188,16 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
         return AVERROR_INVALIDDATA;
     }
 
-    if (context->is_nut_mono)
-        stride = avctx->width / 8 + (avctx->width & 7 ? 1 : 0);
-    else if (context->is_nut_pal8)
-        stride = avctx->width;
-    else
-        stride = avpkt->size / avctx->height;
+    stride = (avpkt->size - (context->is_nut_pal8 ? AVPALETTE_SIZE : 0)) / avctx->height;
+
+    av_log(avctx, AV_LOG_DEBUG, "PACKET SIZE: %d\n", avpkt->size);
+    av_log(avctx, AV_LOG_DEBUG, "STRIDE: %d\n", stride);
 
-    if (stride == 0 || avpkt->size < stride * avctx->height) {
+    if (stride <= 0 || avpkt->size < stride * avctx->height) {
         av_log(avctx, AV_LOG_ERROR, "Packet too small (%d)\n", avpkt->size);
         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
@@ -380,18 +359,23 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
     }
 
     if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
-        const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE,
-                                                     NULL);
-
-        if (pal) {
-            av_buffer_unref(&context->palette);
-            context->palette = av_buffer_alloc(AVPALETTE_SIZE);
-            if (!context->palette) {
-                av_buffer_unref(&frame->buf[0]);
-                return AVERROR(ENOMEM);
-            }
-            memcpy(context->palette->data, pal, AVPALETTE_SIZE);
+        if (context->is_nut_pal8) {
+            memcpy(context->palette->data,
+                   avpkt->data + avpkt->size - AVPALETTE_SIZE, AVPALETTE_SIZE);
             frame->palette_has_changed = 1;
+        } else {
+            const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE,
+                                                         NULL);
+            if (pal) {
+                av_buffer_unref(&context->palette);
+                context->palette = av_buffer_alloc(AVPALETTE_SIZE);
+                if (!context->palette) {
+                    av_buffer_unref(&frame->buf[0]);
+                    return AVERROR(ENOMEM);
+                }
+                memcpy(context->palette->data, pal, AVPALETTE_SIZE);
+                frame->palette_has_changed = 1;
+            }
         }
     }
 
diff --git a/tests/ref/fate/sub2video b/tests/ref/fate/sub2video
index 5c2c46a..3a03cbf 100644
--- a/tests/ref/fate/sub2video
+++ b/tests/ref/fate/sub2video
@@ -52,46 +52,129 @@
 0,         47,         47,        1,   518400, 0xde69683f
 0,         48,         48,        1,   518400, 0x7df08fba
 0,         49,         49,        1,   518400, 0xbab197ea
-0,         50,         50,        1,   518400, 0x902285d9
 1,      15355,      15355,     4733,     2094, 0x3c171425, F=0x0
+0,         77,         77,        1,   518400, 0x902285d9
+0,        100,        100,        1,   518400, 0xbab197ea
 1,      48797,      48797,     2560,     2480, 0x7c0edf21, F=0x0
+0,        244,        244,        1,   518400, 0x7a11c812
+0,        257,        257,        1,   518400, 0xbab197ea
 1,      51433,      51433,     2366,     3059, 0xc95b8a05, F=0x0
+0,        258,        258,        1,   518400, 0x34cdddee
+0,        269,        269,        1,   518400, 0xbab197ea
 1,      53910,      53910,     2696,     2095, 0x61bb15ed, F=0x0
+0,        270,        270,        1,   518400, 0x4db4ce51
+0,        283,        283,        1,   518400, 0xbab197ea
 1,      56663,      56663,     1262,     1013, 0xc9ae89b7, F=0x0
+0,        284,        284,        1,   518400, 0xe6bc0ea9
+0,        290,        290,        1,   518400, 0xbab197ea
 1,      58014,      58014,     1661,      969, 0xe01878f0, F=0x0
+0,        291,        291,        1,   518400, 0xa8643af7
+0,        298,        298,        1,   518400, 0xbab197ea
 1,      67724,      67724,     1365,      844, 0xe7db4fc1, F=0x0
+0,        339,        339,        1,   518400, 0xb1885c67
+0,        345,        345,        1,   518400, 0xbab197ea
 1,      69175,      69175,     1558,      802, 0xf48531ba, F=0x0
+0,        346,        346,        1,   518400, 0x378e3fd0
+0,        354,        354,        1,   518400, 0xbab197ea
 1,      70819,      70819,     1865,     1709, 0xb4d5a1bd, F=0x0
+0,        355,        355,        1,   518400, 0xa3782469
+0,        363,        363,        1,   518400, 0xbab197ea
 1,      72762,      72762,     1968,     2438, 0x99d7bc82, F=0x0
+0,        364,        364,        1,   518400, 0xba23a0d5
+0,        374,        374,        1,   518400, 0xbab197ea
 1,      74806,      74806,     1831,     2116, 0x96514097, F=0x0
+0,        375,        375,        1,   518400, 0x129de2f8
+0,        383,        383,        1,   518400, 0xbab197ea
 1,      76716,      76716,     1262,     1822, 0xefccc72e, F=0x0
+0,        384,        384,        1,   518400, 0x19772f0f
+0,        390,        390,        1,   518400, 0xbab197ea
 1,      78051,      78051,     1524,      987, 0x7b927a27, F=0x0
+0,        391,        391,        1,   518400, 0x56f54e73
+0,        398,        398,        1,   518400, 0xbab197ea
 1,      79644,      79644,     2662,     2956, 0x190778f7, F=0x0
+0,        399,        399,        1,   518400, 0x300b5247
 1,      82380,      82380,     2764,     3094, 0xc021b7d3, F=0x0
+0,        412,        412,        1,   518400, 0xbab197ea
+0,        413,        413,        1,   518400, 0x6fd028fa
+0,        426,        426,        1,   518400, 0xbab197ea
 1,      85225,      85225,     2366,     2585, 0x74d0048f, F=0x0
+0,        427,        427,        1,   518400, 0x01f80e9d
+0,        438,        438,        1,   518400, 0xbab197ea
 1,      87652,      87652,     1831,      634, 0x8832fda1, F=0x0
+0,        439,        439,        1,   518400, 0xb48d90c0
+0,        447,        447,        1,   518400, 0xbab197ea
 1,      91531,      91531,     2332,     2080, 0x97a1146f, F=0x0
+0,        458,        458,        1,   518400, 0xcb5a0173
+0,        469,        469,        1,   518400, 0xbab197ea
 1,      95510,      95510,     3299,     2964, 0x8b8f6684, F=0x0
+0,        478,        478,        1,   518400, 0xb8a323e4
+0,        494,        494,        1,   518400, 0xbab197ea
 1,      98872,      98872,     2161,     1875, 0x9002ef71, F=0x0
+0,        495,        495,        1,   518400, 0xc43518ba
+0,        505,        505,        1,   518400, 0xbab197ea
 1,     101124,     101124,     4096,     3872, 0x20c6ed9c, F=0x0
+0,        506,        506,        1,   518400, 0x04e38692
+0,        526,        526,        1,   518400, 0xbab197ea
 1,     105303,     105303,     2730,     3094, 0xf203a663, F=0x0
+0,        527,        527,        1,   518400, 0x856b0ee5
+0,        540,        540,        1,   518400, 0xbab197ea
 1,     108106,     108106,     2059,     2404, 0x41a7b429, F=0x0
+0,        541,        541,        1,   518400, 0x3e5beee2
+0,        551,        551,        1,   518400, 0xbab197ea
 1,     141556,     141556,     1661,     1088, 0xde20aa20, F=0x0
+0,        708,        708,        1,   518400, 0xb8bc1365
+0,        716,        716,        1,   518400, 0xbab197ea
+0,        817,        817,        1,   518400, 0x83efa32d
 1,     163445,     163445,     1331,      339, 0x8bd186ef, F=0x0
+0,        824,        824,        1,   518400, 0xbab197ea
+0,        840,        840,        1,   518400, 0x03ea0e90
 1,     168049,     168049,     1900,     1312, 0x0bf20e8d, F=0x0
+0,        850,        850,        1,   518400, 0xbab197ea
 1,     170035,     170035,     1524,     1279, 0xb6c2dafe, F=0x0
+0,        851,        851,        1,   518400, 0x8780239e
+0,        858,        858,        1,   518400, 0xbab197ea
+0,        861,        861,        1,   518400, 0x6eb72347
 1,     172203,     172203,     1695,     1826, 0x9a1ac769, F=0x0
+0,        869,        869,        1,   518400, 0xbab197ea
 1,     173947,     173947,     1934,     1474, 0xa9b03cdc, F=0x0
+0,        870,        870,        1,   518400, 0x9c4a3a3d
+0,        879,        879,        1,   518400, 0xbab197ea
 1,     175957,     175957,     1763,     1019, 0x20409355, F=0x0
+0,        880,        880,        1,   518400, 0xc9ebfa89
+0,        889,        889,        1,   518400, 0xbab197ea
+0,        946,        946,        1,   518400, 0xbaf801ef
 1,     189295,     189295,     1968,     1596, 0x408c726e, F=0x0
+0,        956,        956,        1,   518400, 0xbab197ea
 1,     191356,     191356,     1228,     1517, 0xae8c5c2b, F=0x0
+0,        957,        957,        1,   518400, 0x59f4e72f
+0,        963,        963,        1,   518400, 0xbab197ea
 1,     192640,     192640,     1763,     2506, 0xa458d6d4, F=0x0
+0,        964,        964,        1,   518400, 0x9d5b9d69
+0,        972,        972,        1,   518400, 0xbab197ea
 1,     195193,     195193,     1092,     1074, 0x397ba9a8, F=0x0
+0,        976,        976,        1,   518400, 0x923d1ce7
+0,        981,        981,        1,   518400, 0xbab197ea
 1,     196361,     196361,     1524,     1715, 0x695ca41e, F=0x0
+0,        982,        982,        1,   518400, 0x6e652cd2
+0,        989,        989,        1,   518400, 0xbab197ea
 1,     197946,     197946,     1160,      789, 0xc63a189e, F=0x0
+0,        990,        990,        1,   518400, 0x25113966
+0,        996,        996,        1,   518400, 0xbab197ea
 1,     199230,     199230,     1627,     1846, 0xeea8c599, F=0x0
+0,        997,        997,        1,   518400, 0x2dc83609
+0,       1004,       1004,        1,   518400, 0xbab197ea
 1,     200924,     200924,     1763,      922, 0xd4a87222, F=0x0
+0,       1005,       1005,        1,   518400, 0x90483bc6
+0,       1013,       1013,        1,   518400, 0xbab197ea
+0,       1053,       1053,        1,   518400, 0x3de86ab7
 1,     210600,     210600,     1831,      665, 0x55580135, F=0x0
+0,       1062,       1062,        1,   518400, 0xbab197ea
 1,     214771,     214771,     1558,     1216, 0x50d1f6c5, F=0x0
+0,       1074,       1074,        1,   518400, 0x8c320e68
+0,       1082,       1082,        1,   518400, 0xbab197ea
+0,       1128,       1128,        1,   518400, 0x81e977b2
 1,     225640,     225640,     2127,     2133, 0x670c11a5, F=0x0
+0,       1139,       1139,        1,   518400, 0xbab197ea
 1,     227834,     227834,     1262,     1264, 0xc1d9fc57, F=0x0
+0,       1140,       1140,        1,   518400, 0xb046dd30
+0,       1145,       1145,        1,   518400, 0xbab197ea
diff --git a/tests/ref/vsynth/vsynth1-bpp1 b/tests/ref/vsynth/vsynth1-bpp1
index 0bd1a77..0abadd6 100644
--- a/tests/ref/vsynth/vsynth1-bpp1
+++ b/tests/ref/vsynth/vsynth1-bpp1
@@ -1,4 +1,4 @@
 611de0803ff6bd0ef385dde59964a105 *tests/data/fate/vsynth1-bpp1.avi
 640452 tests/data/fate/vsynth1-bpp1.avi
-576b690e8a8921c54d777463b63a8307 *tests/data/fate/vsynth1-bpp1.out.rawvideo
-stddev:   97.41 PSNR:  8.36 MAXDIFF:  238 bytes:  7603200/  7603200
+cd1e1448d9895561347ceb66d0add34d *tests/data/fate/vsynth1-bpp1.out.rawvideo
+stddev:   84.48 PSNR:  9.60 MAXDIFF:  218 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth2-bpp1 b/tests/ref/vsynth/vsynth2-bpp1
index d283d6c..38e745f 100644
--- a/tests/ref/vsynth/vsynth2-bpp1
+++ b/tests/ref/vsynth/vsynth2-bpp1
@@ -1,4 +1,4 @@
 b51ad49892eb8f8912c5a983718a17bb *tests/data/fate/vsynth2-bpp1.avi
 640452 tests/data/fate/vsynth2-bpp1.avi
-338fb9039a4564e471bf8179f0c48a95 *tests/data/fate/vsynth2-bpp1.out.rawvideo
-stddev:   80.40 PSNR: 10.02 MAXDIFF:  238 bytes:  7603200/  7603200
+f0dfc0e87e5d96bce29a5944b1bd7471 *tests/data/fate/vsynth2-bpp1.out.rawvideo
+stddev:   68.98 PSNR: 11.36 MAXDIFF:  218 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth3-bpp1 b/tests/ref/vsynth/vsynth3-bpp1
index 5a65728..b4267cf 100644
--- a/tests/ref/vsynth/vsynth3-bpp1
+++ b/tests/ref/vsynth/vsynth3-bpp1
@@ -1,4 +1,4 @@
 98852649c5201df7d85d0e9b5a5b9f15 *tests/data/fate/vsynth3-bpp1.avi
 15352 tests/data/fate/vsynth3-bpp1.avi
-0b1ea21b69d384564dd3a978065443b2 *tests/data/fate/vsynth3-bpp1.out.rawvideo
-stddev:   97.64 PSNR:  8.34 MAXDIFF:  248 bytes:    86700/    86700
+52ae74ef7910e5b603c12288d425b9ae *tests/data/fate/vsynth3-bpp1.out.rawvideo
+stddev:   84.76 PSNR:  9.57 MAXDIFF:  232 bytes:    86700/    86700
diff --git a/tests/ref/vsynth/vsynth_lena-bpp1 b/tests/ref/vsynth/vsynth_lena-bpp1
index 63ab9e1..2577733 100644
--- a/tests/ref/vsynth/vsynth_lena-bpp1
+++ b/tests/ref/vsynth/vsynth_lena-bpp1
@@ -1,4 +1,4 @@
 2859022fac452b59e49a1189c4fbb3ec *tests/data/fate/vsynth_lena-bpp1.avi
 640452 tests/data/fate/vsynth_lena-bpp1.avi
-3be3497f8ca548c9196dcecc5bc7cb2b *tests/data/fate/vsynth_lena-bpp1.out.rawvideo
-stddev:   96.52 PSNR:  8.44 MAXDIFF:  231 bytes:  7603200/  7603200
+6183ba861d4e48d4aaefc514fde270e5 *tests/data/fate/vsynth_lena-bpp1.out.rawvideo
+stddev:   83.28 PSNR:  9.72 MAXDIFF:  215 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