[Pkg-cups-devel] Bug#533468: Patch, always output little-endian QPDL

Ulrich Eckhardt doomster at knuut.de
Sat Jun 20 14:05:49 UTC 2009


reassign 533468 splix

The following patch makes the output of the filter always use the little-
endian variant of the language. I'm not actually sure where the problem lies, 
whether it is the printer that doesn't the big-endian variant or whether it is 
not implemented correctly.

BTW: As far as the correctness of the implementation is concerned, there is 
one place in the code that doesn't look good to me:

    out[w] = COMPRESSION_FLAG | (bestCompCounter & 0x7F);
    out[w+1] = ((bestCompCounter >> 1) & 0xC0) | (bestPtr & 0x3F);

This writes a 16-bit value but always uses little-endian format. I'm not sure 
that is correct, but I tried changing this to also use big-endian format but 
it didn't help.

Cheers!

Uli


diff -u -r ../splix-2.0.0/src/algo0x11.cpp ./src/algo0x11.cpp
--- ../splix-2.0.0/src/algo0x11.cpp	2009-06-20 15:26:10.000000000 +0200
+++ ./src/algo0x11.cpp	2009-06-20 15:40:37.000000000 +0200
@@ -32,9 +32,20 @@
  */
 int Algo0x11::__compare(const void *n1, const void *n2)
 {
+    // extract little-endian values
+    unsigned char const* p1 = static_cast<unsigned char const*>(n1);
+    unsigned char const* p2 = static_cast<unsigned char const*>(n2);
+    uint32_t v1 = p1[0]
+               + (p1[1]<<8)
+               + (p1[2]<<16)
+               + (p1[3]<<24);
+    uint32_t v2 = p2[0]
+               + (p2[1]<<8)
+               + (p2[2]<<16)
+               + (p2[3]<<24);
     // n2 and n1 has been exchanged since the first
     // element of the array MUST be the biggest
-    return *(uint32_t *)n2 - *(uint32_t *)n1;
+    return v2-v1;
 }
 
 bool Algo0x11::_lookupBestOccurs(const unsigned char* data, unsigned long 
size)
@@ -87,7 +98,8 @@
 
     // Print the table
     for (unsigned long i=0; i < TABLE_PTR_SIZE; i++, w += 2) {
-        *(uint16_t *)(out + w) = (uint16_t)_ptrArray[i];
+        out[w] = _ptrArray[i];
+        out[w+1] = _ptrArray[i] >> 8;
         if (_ptrArray[i] > uncompSize)
             uncompSize = _ptrArray[i];
     }
@@ -95,7 +107,10 @@
     // Print the first uncompressed bytes
     if (uncompSize > MAX_UNCOMPRESSED_BYTES)
         uncompSize = MAX_UNCOMPRESSED_BYTES;
-    *(uint32_t *)out = (uint32_t)uncompSize;
+    out[0] = uncompSize;
+    out[1] = uncompSize>>8;
+    out[2] = uncompSize>>16;
+    out[3] = uncompSize>>24;
     for (r=0; r < uncompSize; r++, w++)
         out[w] = data[r];
 
@@ -232,7 +247,7 @@
     // Register the result into a band plane
     plane = new BandPlane();
     plane->setData(output, outputSize);
-    plane->setEndian(BandPlane::Dependant);
+    plane->setEndian(BandPlane::LittleEndian);
     plane->setCompression(0x11);
 
     return plane;






More information about the Pkg-cups-devel mailing list