Backed out changeset 40784ea31188 (bug 651482) for Reftest failures in bmp-corrupted/wrapper.html?invalid-compression-BITFIELDS.bmp. CLOSED TREE
authorDorel Luca <dluca@mozilla.com>
Fri, 22 May 2020 12:21:32 +0300
changeset 531614 b08a7f6f47bc51ad21324702aa9e9ffdb2020794
parent 531613 7d23598568559e99f12428cd39dfa64fa8ddb52c
child 531615 0224aa78cb39c30c8e1778fa8f175061fbe46159
push id116762
push userdluca@mozilla.com
push dateFri, 22 May 2020 09:22:30 +0000
treeherderautoland@b08a7f6f47bc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs651482
milestone78.0a1
backs out40784ea31188fe5d253e017ab6d8b8b1f58e7696
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 40784ea31188 (bug 651482) for Reftest failures in bmp-corrupted/wrapper.html?invalid-compression-BITFIELDS.bmp. CLOSED TREE
image/BMPHeaders.h
image/decoders/nsBMPDecoder.cpp
image/test/reftest/bmp/bmp-24bpp/24bpp-rgb-ref.png
image/test/reftest/bmp/bmp-24bpp/24bpp-rgb.bmp
image/test/reftest/bmp/bmp-24bpp/reftest.list
image/test/reftest/bmp/bmp-32bpp/32bpp-rgb-ref.png
image/test/reftest/bmp/bmp-32bpp/32bpp-rgb.bmp
image/test/reftest/bmp/bmp-32bpp/reftest.list
image/test/reftest/bmp/bmpsuite/q/reftest.list
image/test/reftest/bmp/bmpsuite/q/rgb32h52.png
image/test/reftest/bmp/bmpsuite/q/rgba32h56.png
image/test/reftest/bmp/reftest.list
--- a/image/BMPHeaders.h
+++ b/image/BMPHeaders.h
@@ -15,18 +15,16 @@ namespace bmp {
 // The length of the file header as defined in the BMP spec.
 static const size_t FILE_HEADER_LENGTH = 14;
 
 // This lengths of the info header for the different BMP versions.
 struct InfoHeaderLength {
   enum {
     WIN_V2 = 12,
     WIN_V3 = 40,
-    WIN_V3_NT = 52,
-    WIN_V3_NT_ALPHA = 56,
     WIN_V4 = 108,
     WIN_V5 = 124,
 
     // OS2_V1 is omitted; it's the same as WIN_V2.
     OS2_V2_MIN = 16,  // Minimum allowed value for OS2v2.
     OS2_V2_MAX = 64,  // Maximum allowed value for OS2v2.
 
     WIN_ICO = WIN_V3,
--- a/image/decoders/nsBMPDecoder.cpp
+++ b/image/decoders/nsBMPDecoder.cpp
@@ -31,33 +31,29 @@
 //   (|mBpp|) which must be 1, 4, 8 or 24.
 // - Next is the semi-optional color table, which has length 2^|mBpp| and has 3
 //   bytes per value (BGR). The color table is required if |mBpp| is 1, 4, or 8.
 // - Next is an optional gap.
 // - Next is the pixel data, which is pointed to by |mDataOffset|.
 //
 // WinBMPv3. This is the most widely used version.
 // - It changed the info header to 40 bytes by taking the WinBMPv2 info
-//   header, enlarging its width and height fields, and adding more fields
+//   header, enlargening its width and height fields, and adding more fields
 //   including: a compression type (|mCompression|) and number of colors
 //   (|mNumColors|).
 // - The semi-optional color table is now 4 bytes per value (BGR0), and its
 //   length is |mNumColors|, or 2^|mBpp| if |mNumColors| is zero.
 // - |mCompression| can be RGB (i.e. no compression), RLE4 (if |mBpp|==4) or
 //   RLE8 (if |mBpp|==8) values.
 //
 // WinBMPv3-NT. A variant of WinBMPv3.
 // - It did not change the info header layout from WinBMPv3.
 // - |mBpp| can now be 16 or 32, in which case |mCompression| can be RGB or the
 //   new BITFIELDS value; in the latter case an additional 12 bytes of color
-//   bitfields follow the info header (52 bytes total).
-//
-// WinBMPv3-NT-Alpha. A variant of WinBMPv3-NT with support for alpha channels.
-//   Adds an additional 4 bytes in in the info header (now 56 bytes total), and
-//   supports an alpha channel in the BITFIELDS sections.
+//   bitfields follow the info header.
 //
 // WinBMPv4.
 // - It extended the info header to 108 bytes, including the 12 bytes of color
 //   mask data from WinBMPv3-NT, plus alpha mask data, and also color-space and
 //   gamma correction fields.
 //
 // WinBMPv5.
 // - It extended the info header to 124 bytes, adding color profile data.
@@ -493,18 +489,16 @@ LexerTransition<nsBMPDecoder::State> nsB
 LexerTransition<nsBMPDecoder::State> nsBMPDecoder::ReadInfoHeaderSize(
     const char* aData, size_t aLength) {
   mPreGapLength += aLength;
 
   mH.mBIHSize = LittleEndian::readUint32(aData);
 
   bool bihSizeOk = mH.mBIHSize == InfoHeaderLength::WIN_V2 ||
                    mH.mBIHSize == InfoHeaderLength::WIN_V3 ||
-                   mH.mBIHSize == InfoHeaderLength::WIN_V3_NT ||
-                   mH.mBIHSize == InfoHeaderLength::WIN_V3_NT_ALPHA ||
                    mH.mBIHSize == InfoHeaderLength::WIN_V4 ||
                    mH.mBIHSize == InfoHeaderLength::WIN_V5 ||
                    (mH.mBIHSize >= InfoHeaderLength::OS2_V2_MIN &&
                     mH.mBIHSize <= InfoHeaderLength::OS2_V2_MAX);
   if (!bihSizeOk) {
     return Transition::TerminateFailure();
   }
   // ICO BMPs must have a WinBMPv3 header. nsICODecoder should have already
@@ -612,18 +606,16 @@ LexerTransition<nsBMPDecoder::State> nsB
        (mH.mBpp == 1 || mH.mBpp == 4 || mH.mBpp == 8 || mH.mBpp == 16 ||
         mH.mBpp == 24 || mH.mBpp == 32)) ||
       (mH.mCompression == Compression::RLE8 && mH.mBpp == 8) ||
       (mH.mCompression == Compression::RLE4 && mH.mBpp == 4) ||
       (mH.mCompression == Compression::BITFIELDS &&
        // For BITFIELDS compression we require an exact match for one of the
        // WinBMP BIH sizes; this clearly isn't an OS2 BMP.
        (mH.mBIHSize == InfoHeaderLength::WIN_V3 ||
-        mH.mBIHSize == InfoHeaderLength::WIN_V3_NT ||
-        mH.mBIHSize == InfoHeaderLength::WIN_V3_NT_ALPHA ||
         mH.mBIHSize == InfoHeaderLength::WIN_V4 ||
         mH.mBIHSize == InfoHeaderLength::WIN_V5) &&
        (mH.mBpp == 16 || mH.mBpp == 32));
   if (!bppCompressionOk) {
     return Transition::TerminateFailure();
   }
 
   // Initialize our current row to the top of the image.
@@ -636,17 +628,17 @@ LexerTransition<nsBMPDecoder::State> nsB
   uint32_t surplus = mPixelRowSize % 4;
   if (surplus != 0) {
     mPixelRowSize += 4 - surplus;
   }
 
   size_t bitFieldsLengthStillToRead = 0;
   if (mH.mCompression == Compression::BITFIELDS) {
     // Need to read bitfields.
-    if (mH.mBIHSize >= InfoHeaderLength::WIN_V3_NT) {
+    if (mH.mBIHSize >= InfoHeaderLength::WIN_V4) {
       // Bitfields are present in the info header, so we can read them
       // immediately.
       mBitFields.ReadFromHeader(aData + 36, /* aReadAlpha = */ true);
 
       // If this came from the clipboard, then we know that even if the header
       // explicitly includes the bitfield masks, we need to add an additional
       // offset for the start of the RGB data.
       if (mIsForClipboard) {
@@ -1042,17 +1034,18 @@ LexerTransition<nsBMPDecoder::State> nsB
       while (lpos > 0) {
         SetPixel(dst, src[2], src[1], src[0]);
         --lpos;
         src += 3;
       }
       break;
 
     case 32:
-      if (mH.mCompression == Compression::RGB && mIsWithinICO) {
+      if (mH.mCompression == Compression::RGB && mIsWithinICO &&
+          mH.mBpp == 32) {
         // This is a special case only used for 32bpp WinBMPv3-ICO files, which
         // could be in either 0RGB or ARGB format. We start by assuming it's
         // an 0RGB image. If we hit a non-zero alpha value, then we know it's
         // actually an ARGB image, and change tack accordingly.
         // (Note: a fully-transparent ARGB image is indistinguishable from a
         // 0RGB image, and we will render such an image as a 0RGB image, i.e.
         // opaquely. This is unlikely to be a problem in practice.)
         while (lpos > 0) {
deleted file mode 100644
index 9de5fc22a23a0574caa860abe9748e7cb733d1a5..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 65e2cf418ce5bd279c1bc817225ff07038240847..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
--- a/image/test/reftest/bmp/bmp-24bpp/reftest.list
+++ b/image/test/reftest/bmp/bmp-24bpp/reftest.list
@@ -14,9 +14,8 @@
 == bmp-size-16x16-24bpp.bmp bmp-size-16x16-24bpp.png
 == bmp-size-17x17-24bpp.bmp bmp-size-17x17-24bpp.png
 == bmp-size-31x31-24bpp.bmp bmp-size-31x31-24bpp.png
 == bmp-size-32x32-24bpp.bmp bmp-size-32x32-24bpp.png
 == bmp-size-33x33-24bpp.bmp bmp-size-33x33-24bpp.png
 == bmp-not-square-24bpp.bmp bmp-not-square-24bpp.png
 == os2bmp-size-32x32-24bpp.bmp bmp-size-32x32-24bpp.png
 == top-to-bottom-16x16-24bpp.bmp bmp-size-16x16-24bpp.png
-== 24bpp-rgb.bmp 24bpp-rgb-ref.png
deleted file mode 100644
index 9de5fc22a23a0574caa860abe9748e7cb733d1a5..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 9dd5c28f5117ef279bad56a46e720e4c138d4975..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/image/test/reftest/bmp/bmp-32bpp/reftest.list
+++ /dev/null
@@ -1,4 +0,0 @@
-# BMP 32BPP tests
-
-# Images of various odd size info header sizes
-== 32bpp-rgb.bmp 32bpp-rgb-ref.png
--- a/image/test/reftest/bmp/bmpsuite/q/reftest.list
+++ b/image/test/reftest/bmp/bmpsuite/q/reftest.list
@@ -178,18 +178,19 @@ fuzzy(10-10,6590-6597) == rgb24prof2.bmp
 # BMP: bihsize=64, 127 x 64, bpp=24, compression=4, colors=0
 # "An OS/2v2 bitmap with RLE24 compression. This image uses a limited number
 # of colors, just to make it more compressible."
 # [We reject it. Chromium accepts it.]
 == wrapper.html?rgb24rle24.bmp about:blank
 
 # BMP: bihsize=52, 127 x 64, bpp=32, compression=3, colors=0
 # "Similar to g/rgb32bf.bmp, but with a 52-byte “BITMAPV2INFOHEADER”. This is
-# an uncommon version of BMP."
-== rgb32h52.bmp rgb32h52.png 
+# an uncommon version of BMP, and I can’t confirm that this file is correct."
+# [We reject it. Chromium accepts it.]
+== wrapper.html?rgb32h52.bmp about:blank
 
 # BMP: bihsize=124, 127 x 64, bpp=32, compression=3, colors=0
 # "Color channels are the same size and order as rgb32bfdef.bmp, but they use
 # the highest available bits, instead of the lowest (or vice versa, depending
 # on your byte-order perspective)."
 == rgb32-xbgr.bmp rgb24.png
 
 # BMP: bihsize=40, 127 x 64, bpp=32, compression=0, colors=0
@@ -240,10 +241,11 @@ fuzzy(0-1,0-1554) == rgba32-61754.bmp rg
 # "An image of type BI_ALPHABITFIELDS. Supposedly, this was used on Windows CE.
 # I don’t know whether it is constructed correctly."
 # [We reject it. Chromium accepts it.]
 == wrapper.html?rgba32abf.bmp about:blank
 
 # BMP: bihsize=56, 127 x 64, bpp=32, compression=3, colors=0
 # "Similar to q/rgba32.bmp, but with a 56-byte “BITMAPV3INFOHEADER”. This is an
 # uncommon version of BMP, and I can’t confirm that this file is correct."
-== rgba32h56.bmp rgba32h56.png
+# [We reject it. Chromium accepts it.]
+== wrapper.html?rgba32h56.bmp about:blank
 
deleted file mode 100644
index 86a9c945b0bfe98d71fb50f86f11434bea521882..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 25e542a6551acf16d58489d2d7fde3a5d423b477..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
--- a/image/test/reftest/bmp/reftest.list
+++ b/image/test/reftest/bmp/reftest.list
@@ -1,15 +1,14 @@
 # BMP tests
 
 include bmp-1bpp/reftest.list
 include bmp-4bpp/reftest.list
 include bmp-8bpp/reftest.list
 include bmp-24bpp/reftest.list
-include bmp-32bpp/reftest.list
 include bmp-corrupted/reftest.list
 include bmpsuite/reftest.list
 
 # Two bmp files where the offset to the start of the image data in the file
 # is past the end of the file. In 1240629-1.bmp the offset us uint32_max,
 # so we are testing that we don't try to allocate a buffer that size (and
 # fail on 32 bit platforms) and declare the image in error state. If in the
 # future we decide that such bmps (offset past the end of the file) are