diff options
author | Christophe Fergeau <teuf@gnome.org> | 2007-10-29 21:52:44 +0000 |
---|---|---|
committer | Christophe Fergeau <teuf@gnome.org> | 2007-10-29 21:52:44 +0000 |
commit | 60a9f4bad17d86056f7282c633a1e6efa52fe7f1 (patch) | |
tree | 2b882a8a9383a5ab0b372bb797ca50133813242d | |
parent | 0c365c1e713578373dac48e00c7c208f8cf5418a (diff) | |
download | libgpod-60a9f4bad17d86056f7282c633a1e6efa52fe7f1.tar.gz libgpod-60a9f4bad17d86056f7282c633a1e6efa52fe7f1.tar.xz libgpod-60a9f4bad17d86056f7282c633a1e6efa52fe7f1.zip |
Patch from Filippo Giunchedi <filippo@esaurito.net>
* 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
git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@1746 f01d2545-417e-4e96-918e-98f8d0dbbcb6
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | src/itdb_artwork.c | 49 | ||||
-rw-r--r-- | src/itdb_device.c | 6 | ||||
-rw-r--r-- | src/itdb_device.h | 2 | ||||
-rw-r--r-- | src/ithumb-writer.c | 16 |
5 files changed, 77 insertions, 5 deletions
@@ -1,5 +1,14 @@ 2007-10-29 Christophe Fergeau <teuf@gnome.org> + Patch from Filippo Giunchedi <filippo@esaurito.net> + + * 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 <teuf@gnome.org> + * src/itdb_device.c: the iPod Touch probably uses the same image format as the iPhone diff --git a/src/itdb_artwork.c b/src/itdb_artwork.c index d2cd5f6..c3ec898 100644 --- a/src/itdb_artwork.c +++ b/src/itdb_artwork.c @@ -664,6 +664,47 @@ static gint limit8bit (float x) } 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_rgb_data (Itdb_Device *device, Itdb_Thumb *thumb) 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 @@ itdb_thumb_get_byteorder (const ItdbThumbFormat format) 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 @@ itdb_thumb_get_byteorder (const ItdbThumbFormat format) 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); diff --git a/src/itdb_device.c b/src/itdb_device.c index ca64aaf..caaea58 100644 --- a/src/itdb_device.c +++ b/src/itdb_device.c @@ -312,11 +312,7 @@ static const Itdb_ArtworkFormat ipod_classic_1_artwork_info[] = { {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 diff --git a/src/itdb_device.h b/src/itdb_device.h index 0c45009..e62a9b3 100644 --- a/src/itdb_device.h +++ b/src/itdb_device.h @@ -52,6 +52,8 @@ enum _ItdbThumbFormat { 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, diff --git a/src/ithumb-writer.c b/src/ithumb-writer.c index 2c925a8..5763634 100644 --- a/src/ithumb-writer.c +++ b/src/ithumb-writer.c @@ -297,6 +297,15 @@ pack_rec_RGB_555 (GdkPixbuf *pixbuf, const Itdb_ArtworkFormat *img_info, 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 @@ ithumb_writer_write_thumbnail (iThumbWriter *writer, 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; } |