Blob Blame History Raw
diff -Naur dvdisaster-0.70/CHANGELOG dvdisaster-0.70.2/CHANGELOG
--- dvdisaster-0.70/CHANGELOG	2006-09-09 14:22:34.590160232 +0200
+++ dvdisaster-0.70.2/CHANGELOG	2006-09-09 13:21:25.000000000 +0200
@@ -2,6 +2,8 @@
 0.70 (pl2)
 	- fixed crash by inappropriate g_free() on Pango layout (thanks to Dmitry
 	  for pointing this out)
+	- fixed pngpack decoding failure on big endian machines (thanks again to
+	  Dmitry)
 
 0.70 (pl-1) 30-07-2006
 	- fixed a bug in read-adaptive for RS02 which would sometimes prevent it 
diff -Naur dvdisaster-0.70/tools/configure dvdisaster-0.70.2/tools/configure
--- dvdisaster-0.70/tools/configure	2006-04-18 22:50:00.000000000 +0200
+++ dvdisaster-0.70.2/tools/configure	2006-09-09 13:17:50.000000000 +0200
@@ -19,7 +19,7 @@
 
 # Set the package name and version
 
-PACKAGE pngpack 0.10
+PACKAGE pngpack 0.11
 
 # Check for some essential tools.
 
@@ -43,6 +43,11 @@
 REQUIRE_INCLUDE png.h png
 REQUIRE_LIBRARY png png_sig_cmp png
 
+# Byte order
+
+echo
+CHECK_ENDIAN
+
 # Do not proceed further if in --help mode
 
 if test -n "$cfg_help_mode"; then
diff -Naur dvdisaster-0.70/tools/pngpack.c dvdisaster-0.70.2/tools/pngpack.c
--- dvdisaster-0.70/tools/pngpack.c	2006-05-21 18:58:45.000000000 +0200
+++ dvdisaster-0.70.2/tools/pngpack.c	2006-09-09 14:15:28.131991728 +0200
@@ -55,6 +55,14 @@
   #include "exdll.h"
 #endif
 
+guint32 SwapBytes32(guint32 in)
+{
+  return
+        ((in & 0xff000000) >> 24) 
+      | ((in & 0x00ff0000) >>  8) 
+      | ((in & 0x0000ff00) <<  8) 
+      | ((in & 0x000000ff) << 24);
+}
 
 /*
  * Tell user that current action was aborted due to a serious error.
@@ -65,12 +73,12 @@
 
    /*** Show message depending on commandline / GUI mode  */ 
 
-   fprintf(stderr, "*\n* pngpack - can not continue:\n*\n");
+   fprintf(stdout, "*\n* pngpack - can not continue:\n*\n");
    va_start(argp, format);
-   vfprintf(stderr, format, argp);
+   vfprintf(stdout, format, argp);
    va_end(argp);
-   fprintf(stderr, "\n\n");
-   fflush(stderr);
+   fprintf(stdout, "\n\n");
+   fflush(stdout);
 
    exit(EXIT_FAILURE);
 }
@@ -125,8 +133,8 @@
    /* stat ppm file */
 
    if(stat(name, &mystat) == -1)
-   {  fprintf(stderr, "COULD NOT STAT %s!\n", name);
-      fflush(stderr);
+   {  fprintf(stdout, "COULD NOT STAT %s!\n", name);
+      fflush(stdout);
       return NULL;
    }
 
@@ -139,8 +147,8 @@
 
    pi->file = fopen(name, "rb");
    if(!pi->file)
-   {  fprintf(stderr, "COULD NOT OPEN %s!\n", name);
-      fflush(stderr);
+   {  fprintf(stdout, "COULD NOT OPEN %s!\n", name);
+      fflush(stdout);
       return NULL;
    }
 
@@ -149,8 +157,8 @@
    fread(buf, 1, 8, pi->file);
    if(png_sig_cmp(buf, 0, 8))
    {  fclose(pi->file);
-      fprintf(stderr, "%s is not a .png file!\n", name);
-      fflush(stderr);
+      fprintf(stdout, "%s is not a .png file!\n", name);
+      fflush(stdout);
       return NULL;
    }
 
@@ -164,8 +172,8 @@
 
    if(setjmp(png_jmpbuf(pi->png_read)))
    {  free_image(pi);
-      fprintf(stderr, "error decoding .png file!\n");
-      fflush(stderr);
+      fprintf(stdout, "error decoding .png file!\n");
+      fflush(stdout);
       return NULL;
    }
 
@@ -185,8 +193,8 @@
 
    if(depth != 8)
    {  free_image(pi);
-      fprintf(stderr, ", ILLEGAL DEPTH: %d\n",depth);
-      fflush(stderr);
+      fprintf(stdout, ", ILLEGAL DEPTH: %d\n",depth);
+      fflush(stdout);
       return NULL;
    }
 
@@ -256,8 +264,8 @@
    if(setjmp(png_jmpbuf(pi->png_write)))
    {  png_destroy_write_struct(&pi->png_write, &pi->png_info);
       fclose(pi->file);
-      fprintf(stderr, "error creating .png file!\n");
-      fflush(stderr);
+      fprintf(stdout, "error creating .png file!\n");
+      fflush(stdout);
       return;
    }
 
@@ -317,21 +325,11 @@
    if(!file)
      Stop("Could not open %s: %s\n",name,strerror(errno));
 
-#if 0
    fprintf(file, "P6\n"
 	         "# CREATOR: pngpack-%s\n"
 	         "%d %d\n"
 	         "255\n",
 	         VERSION, pi->width, pi->height);
-#endif
-
-#if 1
-   fprintf(file, "P6\n"
-                 "# CREATOR: XV Version 3.10a  Rev: 12/29/94 (PNG patch 1.2)\n"
-	         "%d %d\n"
-	         "255\n",
-	         pi->width, pi->height);
-#endif
 	   
    while(size--)
    {  putc((*pixel>>16)&0xff, file);
@@ -932,6 +930,7 @@
 {  struct MD5Context md5ctxt;
    unsigned char checksum[16]; 
    unsigned int oidx,i,*p;
+   unsigned int background;
    int x=0, y=0;
 
    /* Clear the image */ 
@@ -939,8 +938,15 @@
    i = pi->width * pi->height; 
    p = pi->image;
 
+#ifdef HAVE_LITTLE_ENDIAN
+   background = pi->tile_background;
+   while(i--)
+     *p++ = background;
+#else
+   background = SwapBytes32(pi->tile_background);
    while(i--)
-     *p++ = pi->tile_background;
+     *p++ = background;
+#endif
 
    /* Render it */
 
@@ -958,7 +964,11 @@
       for(i=0; i<t->width; i++) 
 	for(j=0; j<t->height; j++)
 	  if(t->image[i][j] != t->background)
+#ifdef HAVE_LITTLE_ENDIAN
 	    PIXEL(pi, i+x, j+y) = t->image[i][j]; 
+#else
+            PIXEL(pi, i+x, j+y) = SwapBytes32(t->image[i][j]); 
+#endif
    }  
 
    /* verify md5sum */
@@ -969,7 +979,7 @@
 
    if(!memcmp(pi->checksum, checksum, 16))
          fprintf(stdout, "\n");
-   else  fprintf(stderr, " - DECODING FAILURE (checksum error).\n");
+   else  fprintf(stdout, " - DECODING FAILURE (checksum error).\n");
 }
 
 /***