components/openexr/patches/013-DwaCompressor-endian.patch
changeset 7697 8a41b565423d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/openexr/patches/013-DwaCompressor-endian.patch	Tue Feb 14 16:51:42 2017 -0800
@@ -0,0 +1,87 @@
+Addresses DwaCompressor endianess issue, which caused a sparc-only test failure.
+Posted upstream here https://github.com/openexr/openexr/issues/222. No response yet.
+
+--- IlmImf/ImfDwaCompressor.cpp	2016-12-22 15:20:40.220763763 +0000
++++ IlmImf/ImfDwaCompressor.cpp	2017-01-10 09:47:16.415207575 +0000
+@@ -824,15 +824,15 @@
+ 
+                 if (!_isNativeXdr)
+                 {
+-                    for (int i = 0; i < 64; ++i)
+-                    {
+-                        tmpShortXdr      = halfZigBlock[comp]._buffer[i];
++                    //for (int i = 0; i < 64; ++i)
++                    //{
++                        tmpShortXdr      = halfZigBlock[comp]._buffer[0];
+                         tmpConstCharPtr  = (const char *)&tmpShortXdr;
+ 
+                         Xdr::read<CharPtrIO> (tmpConstCharPtr, tmpShortNative);
+ 
+-                        halfZigBlock[comp]._buffer[i] = tmpShortNative;
+-                    }
++                        halfZigBlock[comp]._buffer[0] = tmpShortNative;
++                    //}
+                 }
+ 
+                 if (lastNonZero == 0)
+@@ -1131,6 +1131,20 @@
+         } // comp
+     } // blocky
+ 
++    if (!_isNativeXdr) {
++        for (unsigned int chan = 0; chan < numComp; ++chan)
++        {
++            for (int y=0; y<_height; ++y)
++            {
++                for (int x=0; x<_width; ++x)
++                {
++                    char c = _rowPtrs[chan][y][2*x];
++                    _rowPtrs[chan][y][2*x] =_rowPtrs[chan][y][2*x+1];
++                    _rowPtrs[chan][y][2*x+1] = c;
++                }
++            }
++        }
++    }
+     //
+     // Walk over all the channels that are of type FLOAT.
+     // Convert from HALF XDR back to FLOAT XDR.
+@@ -1470,9 +1484,12 @@
+                             vy = _height - (vy - (_height - 1));
+ 
+                         if (vy < 0) vy = _height-1;
+-                    
++                        
+                         tmpShortXdr =
+                             ((const unsigned short *)(_rowPtrs[chan])[vy])[vx];
++			if (!GLOBAL_SYSTEM_LITTLE_ENDIAN) {
++			    tmpShortXdr = ((tmpShortXdr << 8) & 0xff00) | ((tmpShortXdr >> 8) & 0xff);
++			}
+ 
+                         if (_toNonlinear)
+                         {
+@@ -1546,6 +1563,9 @@
+                 {
+                     tmpCharPtr = (char *)&tmpShortXdr;
+                     Xdr::write<CharPtrIO>(tmpCharPtr, halfZigCoef[i].bits());
++		    if (!GLOBAL_SYSTEM_LITTLE_ENDIAN) {
++                        tmpShortXdr = ((tmpShortXdr << 8) & 0xff00) | ((tmpShortXdr >> 8) & 0xff);
++                    }
+                     halfZigCoef[i].setBits(tmpShortXdr);
+                 }
+ 
+@@ -1553,9 +1573,12 @@
+                 // Save the DC component separately, to be compressed on
+                 // its own.
+                 //
+-
+-                *currDcComp[chan]++ = halfZigCoef[0].bits();
+-                _numDcComp++;
++		if (!GLOBAL_SYSTEM_LITTLE_ENDIAN) {
++                    *currDcComp[chan]++ = (halfZigCoef[0].bits() << 8 & 0xff00) | (halfZigCoef[0].bits() >> 8 & 0xff);
++                } else {
++		    *currDcComp[chan]++ = halfZigCoef[0].bits();
++		}
++		_numDcComp++;
+                 
+                 //
+                 // Then RLE the AC components (which will record the count