Fix compile errors
[geeqie.git] / src / image_load_cr3.c
index fefeae5..d40a75c 100644 (file)
@@ -18,7 +18,7 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-/* FIXME: This is just a copy of image_load_jpeg.c, with an adjusted
+/** @FIXME This is just a copy of image_load_jpeg.c, with an adjusted
  * start address for a .cr3 file
  */
 #include "main.h"
@@ -93,7 +93,8 @@ static void
 convert_cmyk_to_rgb (struct jpeg_decompress_struct *cinfo,
                     guchar **lines)
 {
-       gint i, j;
+       gint i;
+       guint j;
 
        g_return_if_fail (cinfo != NULL);
        g_return_if_fail (cinfo->output_components == 4);
@@ -217,7 +218,7 @@ static void skip_input_data (j_decompress_ptr cinfo, long num_bytes)
 {
        struct jpeg_source_mgr* src = (struct jpeg_source_mgr*) cinfo->src;
 
-       if (num_bytes > src->bytes_in_buffer)
+       if ((gulong)num_bytes > src->bytes_in_buffer)
                {
                ERREXIT(cinfo, JERR_INPUT_EOF);
                }
@@ -262,34 +263,48 @@ static gboolean image_loader_cr3_load (gpointer loader, const guchar *buf, gsize
 
        struct error_handler_data jerr;
 
-/* FIXME: Just start search at where full size jpeg should be,
+/** @FIXME Just start search at where full size jpeg should be,
  * / then search through the file looking for a jpeg end-marker
  */
-       guint64 align_buf;
        gboolean found = FALSE;
        gint i;
+       guint n;
 
-       memcpy(&align_buf, &buf[0xf2], sizeof(guint64));
-       buf = buf + GUINT64_FROM_BE(align_buf) + 0x10;
-
-       if (memcmp(&buf[0], "\xFF\xD8", 2) == 0)
+       n = 0;
+       while (n < count - 4 && !found)
                {
-               i = 0;
-               while (!found )
+               if (memcmp(&buf[n], "mdat", 4) == 0)
                        {
-                       if (memcmp(&buf[ i], "\xFF\xD9", 2) == 0)
+                       if (memcmp(&buf[n + 12], "\xFF\xD8", 2) == 0)
+                               {
+                               i = 0;
+                               while (!found )
+                                       {
+                                       if (memcmp(&buf[n + 12 + i], "\xFF\xD9", 2) == 0)
+                                               {
+                                               found = TRUE;
+                                               }
+                                       i++;
+                                       }
+                               }
+                       else
                                {
-                               found = TRUE;
+                               break;
                                }
-                       i = i + 1;
+                       }
+               else
+                       {
+                       n++;
                        }
                }
-       else
+
+       if (!found)
                {
                return FALSE;
                }
 
        count = i;
+       buf = (unsigned char *)buf + n + 12;
 
        lj->stereo = FALSE;