Revision: 1746
          http://gtkpod.svn.sourceforge.net/gtkpod/?rev=1746&view=rev
Author:   teuf
Date:     2007-10-29 14:52:44 -0700 (Mon, 29 Oct 2007)

Log Message:
-----------
Patch from Filippo Giunchedi <[EMAIL PROTECTED]>
* src/itdb_artwork.c: add I420 unpacker
* src/itdb_device.c: iPod classic full screen photo format is I420
* src/itdb_device.h: add I420 format
* src/ithumb-writer.c: add stub for an I420 packer

Modified Paths:
--------------
    libgpod/trunk/ChangeLog
    libgpod/trunk/src/itdb_artwork.c
    libgpod/trunk/src/itdb_device.c
    libgpod/trunk/src/itdb_device.h
    libgpod/trunk/src/ithumb-writer.c

Modified: libgpod/trunk/ChangeLog
===================================================================
--- libgpod/trunk/ChangeLog     2007-10-29 21:34:18 UTC (rev 1745)
+++ libgpod/trunk/ChangeLog     2007-10-29 21:52:44 UTC (rev 1746)
@@ -1,5 +1,14 @@
 2007-10-29  Christophe Fergeau <[EMAIL PROTECTED]>
 
+       Patch from Filippo Giunchedi <[EMAIL PROTECTED]>
+
+       * src/itdb_artwork.c: add I420 unpacker
+       * src/itdb_device.c: iPod classic full screen photo format is I420
+       * src/itdb_device.h: add I420 format
+       * src/ithumb-writer.c: add stub for an I420 packer
+
+2007-10-29  Christophe Fergeau <[EMAIL PROTECTED]>
+
        * src/itdb_device.c: the iPod Touch probably uses the same image format
        as the iPhone
 

Modified: libgpod/trunk/src/itdb_artwork.c
===================================================================
--- libgpod/trunk/src/itdb_artwork.c    2007-10-29 21:34:18 UTC (rev 1745)
+++ libgpod/trunk/src/itdb_artwork.c    2007-10-29 21:52:44 UTC (rev 1746)
@@ -664,7 +664,48 @@
     }
     return x;
 }
+
+// swapping U and V planes this unpacks YV12
 static guchar *
+unpack_I420 (guchar *yuvdata, gint bytes_len, guint byte_order,
+               gint width, gint height)
+{
+       gint imgsize = width*3*height;
+       gint yuvdim = width*height;
+       guchar* rgbdata;
+       gint row, col;
+       gint z = 0;
+       gint h = 0;
+       gint y, u, v;
+       gint ustart = yuvdim;
+       gint vstart = yuvdim + yuvdim / 4;
+
+       g_return_val_if_fail (bytes_len < 2*(G_MAXUINT/3), NULL);
+       g_return_val_if_fail (width * height * 2 == bytes_len, NULL);
+
+       rgbdata = g_malloc(imgsize);
+
+       // FIXME could be faster
+       while(h < yuvdim){
+               y = yuvdata[h];
+
+               row = h / width;
+               col = h % width;
+
+               u = yuvdata[ustart + (row/2)*(width/2) + col/2];
+               v = yuvdata[vstart + (row/2)*(width/2) + col/2];
+
+               rgbdata[z] = limit8bit((y-16)*1.164 + (v-128)*1.596); 
+               rgbdata[z+1] = limit8bit((y-16)*1.164 - (v-128)*0.813 - 
(u-128)*0.391); 
+               rgbdata[z+2] = limit8bit((y-16)*1.164 + (u-128)*2.018); 
+
+               z+=3;
+               h++;
+       }
+       return rgbdata;
+}
+
+static guchar *
 unpack_UYVY (guchar *yuvdata, gint bytes_len, guint byte_order,
             gint width, gint height)
 {
@@ -879,6 +920,12 @@
                                  itdb_thumb_get_byteorder (img_info->format),
                                  img_info->width, img_info->height);
            break;
+       case THUMB_FORMAT_I420_LE:
+       case THUMB_FORMAT_I420_BE:
+           pixels = unpack_I420 (pixels_raw, thumb->size,
+                                 itdb_thumb_get_byteorder (img_info->format),
+                                 img_info->width, img_info->height);
+           break;
        }
        g_free (pixels_raw);
 
@@ -1175,6 +1222,7 @@
     case THUMB_FORMAT_REC_RGB555_LE:
     case THUMB_FORMAT_REC_RGB555_LE_90:
     case THUMB_FORMAT_EXPERIMENTAL_LE:
+       case THUMB_FORMAT_I420_LE:
        return G_LITTLE_ENDIAN;
     case THUMB_FORMAT_UYVY_BE:
     case THUMB_FORMAT_RGB565_BE:
@@ -1186,6 +1234,7 @@
     case THUMB_FORMAT_REC_RGB555_BE:
     case THUMB_FORMAT_REC_RGB555_BE_90:
     case THUMB_FORMAT_EXPERIMENTAL_BE:
+       case THUMB_FORMAT_I420_BE:
        return G_BIG_ENDIAN;
     }
     g_return_val_if_reached (-1);

Modified: libgpod/trunk/src/itdb_device.c
===================================================================
--- libgpod/trunk/src/itdb_device.c     2007-10-29 21:34:18 UTC (rev 1745)
+++ libgpod/trunk/src/itdb_device.c     2007-10-29 21:52:44 UTC (rev 1746)
@@ -312,11 +312,7 @@
     {ITDB_THUMB_COVER_XSMALL,      56,  56, 1061, THUMB_FORMAT_RGB565_LE},
     {ITDB_THUMB_COVER_MEDIUM,     128, 128, 1055, THUMB_FORMAT_RGB565_LE},
     {ITDB_THUMB_COVER_XLARGE,     320, 320, 1060, THUMB_FORMAT_RGB565_LE},
-
-    /* not sure if the THUMB_FORMAT is correct */
-/*    {ITDB_THUMB_PHOTO_TV_SCREEN,  720, 480, 1067, THUMB_FORMAT_UYVY_BE},*/
-    {ITDB_THUMB_PHOTO_TV_SCREEN,  720, 480, 1067, THUMB_FORMAT_RGB565_BE},
-    /* not sure if the THUMB_FORMAT is correct */
+    {ITDB_THUMB_PHOTO_TV_SCREEN,  720, 480, 1067, THUMB_FORMAT_I420_LE},
     {ITDB_THUMB_PHOTO_FULL_SCREEN,320, 240, 1064, THUMB_FORMAT_RGB888_LE},
     {ITDB_THUMB_PHOTO_SMALL,       64,  64, 1066, THUMB_FORMAT_RGB565_LE},
 /*  These are the same as for the iPod video... -- labeled by the iPod as

Modified: libgpod/trunk/src/itdb_device.h
===================================================================
--- libgpod/trunk/src/itdb_device.h     2007-10-29 21:34:18 UTC (rev 1745)
+++ libgpod/trunk/src/itdb_device.h     2007-10-29 21:52:44 UTC (rev 1746)
@@ -52,6 +52,8 @@
 {
     THUMB_FORMAT_UYVY_LE,
     THUMB_FORMAT_UYVY_BE,
+       THUMB_FORMAT_I420_LE,
+       THUMB_FORMAT_I420_BE,
     THUMB_FORMAT_RGB565_LE,
     THUMB_FORMAT_RGB565_LE_90,
     THUMB_FORMAT_RGB565_BE,

Modified: libgpod/trunk/src/ithumb-writer.c
===================================================================
--- libgpod/trunk/src/ithumb-writer.c   2007-10-29 21:34:18 UTC (rev 1745)
+++ libgpod/trunk/src/ithumb-writer.c   2007-10-29 21:52:44 UTC (rev 1746)
@@ -297,6 +297,15 @@
     return deranged_pixels;
 }
 
+static guchar *
+pack_I420 (GdkPixbuf *orig_pixbuf, const Itdb_ArtworkFormat *img_info,
+          gint horizontal_padding, gint vertical_padding,
+          guint32 *thumb_size)
+{
+       // FIXME do something
+    g_return_val_if_fail (img_info, NULL);
+    return NULL;
+}
 
 /* pack_UYVY() is adapted from imgconvert.c from the GPixPod project
  * (www.gpixpod.org) */
@@ -702,6 +711,13 @@
                            thumb->vertical_padding,
                            &thumb->size);
        break;
+    case THUMB_FORMAT_I420_BE:
+    case THUMB_FORMAT_I420_LE:
+       pixels = pack_I420 (pixbuf, writer->img_info,
+                           thumb->horizontal_padding,
+                           thumb->vertical_padding,
+                           &thumb->size);
+       break;
     }
 
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to