|
1 Addresses DwaCompressor endianess issue, which caused a sparc-only test failure. |
|
2 Posted upstream here https://github.com/openexr/openexr/issues/222. No response yet. |
|
3 |
|
4 --- IlmImf/ImfDwaCompressor.cpp 2016-12-22 15:20:40.220763763 +0000 |
|
5 +++ IlmImf/ImfDwaCompressor.cpp 2017-01-10 09:47:16.415207575 +0000 |
|
6 @@ -824,15 +824,15 @@ |
|
7 |
|
8 if (!_isNativeXdr) |
|
9 { |
|
10 - for (int i = 0; i < 64; ++i) |
|
11 - { |
|
12 - tmpShortXdr = halfZigBlock[comp]._buffer[i]; |
|
13 + //for (int i = 0; i < 64; ++i) |
|
14 + //{ |
|
15 + tmpShortXdr = halfZigBlock[comp]._buffer[0]; |
|
16 tmpConstCharPtr = (const char *)&tmpShortXdr; |
|
17 |
|
18 Xdr::read<CharPtrIO> (tmpConstCharPtr, tmpShortNative); |
|
19 |
|
20 - halfZigBlock[comp]._buffer[i] = tmpShortNative; |
|
21 - } |
|
22 + halfZigBlock[comp]._buffer[0] = tmpShortNative; |
|
23 + //} |
|
24 } |
|
25 |
|
26 if (lastNonZero == 0) |
|
27 @@ -1131,6 +1131,20 @@ |
|
28 } // comp |
|
29 } // blocky |
|
30 |
|
31 + if (!_isNativeXdr) { |
|
32 + for (unsigned int chan = 0; chan < numComp; ++chan) |
|
33 + { |
|
34 + for (int y=0; y<_height; ++y) |
|
35 + { |
|
36 + for (int x=0; x<_width; ++x) |
|
37 + { |
|
38 + char c = _rowPtrs[chan][y][2*x]; |
|
39 + _rowPtrs[chan][y][2*x] =_rowPtrs[chan][y][2*x+1]; |
|
40 + _rowPtrs[chan][y][2*x+1] = c; |
|
41 + } |
|
42 + } |
|
43 + } |
|
44 + } |
|
45 // |
|
46 // Walk over all the channels that are of type FLOAT. |
|
47 // Convert from HALF XDR back to FLOAT XDR. |
|
48 @@ -1470,9 +1484,12 @@ |
|
49 vy = _height - (vy - (_height - 1)); |
|
50 |
|
51 if (vy < 0) vy = _height-1; |
|
52 - |
|
53 + |
|
54 tmpShortXdr = |
|
55 ((const unsigned short *)(_rowPtrs[chan])[vy])[vx]; |
|
56 + if (!GLOBAL_SYSTEM_LITTLE_ENDIAN) { |
|
57 + tmpShortXdr = ((tmpShortXdr << 8) & 0xff00) | ((tmpShortXdr >> 8) & 0xff); |
|
58 + } |
|
59 |
|
60 if (_toNonlinear) |
|
61 { |
|
62 @@ -1546,6 +1563,9 @@ |
|
63 { |
|
64 tmpCharPtr = (char *)&tmpShortXdr; |
|
65 Xdr::write<CharPtrIO>(tmpCharPtr, halfZigCoef[i].bits()); |
|
66 + if (!GLOBAL_SYSTEM_LITTLE_ENDIAN) { |
|
67 + tmpShortXdr = ((tmpShortXdr << 8) & 0xff00) | ((tmpShortXdr >> 8) & 0xff); |
|
68 + } |
|
69 halfZigCoef[i].setBits(tmpShortXdr); |
|
70 } |
|
71 |
|
72 @@ -1553,9 +1573,12 @@ |
|
73 // Save the DC component separately, to be compressed on |
|
74 // its own. |
|
75 // |
|
76 - |
|
77 - *currDcComp[chan]++ = halfZigCoef[0].bits(); |
|
78 - _numDcComp++; |
|
79 + if (!GLOBAL_SYSTEM_LITTLE_ENDIAN) { |
|
80 + *currDcComp[chan]++ = (halfZigCoef[0].bits() << 8 & 0xff00) | (halfZigCoef[0].bits() >> 8 & 0xff); |
|
81 + } else { |
|
82 + *currDcComp[chan]++ = halfZigCoef[0].bits(); |
|
83 + } |
|
84 + _numDcComp++; |
|
85 |
|
86 // |
|
87 // Then RLE the AC components (which will record the count |