diff options
author | teuf <teuf@f01d2545-417e-4e96-918e-98f8d0dbbcb6> | 2008-06-09 19:57:02 +0000 |
---|---|---|
committer | teuf <teuf@f01d2545-417e-4e96-918e-98f8d0dbbcb6> | 2008-06-09 19:57:02 +0000 |
commit | 69a7740761b910d3d1286e017b164979a8977884 (patch) | |
tree | b8d6b518333dcceee4f2a7010dae3df74047661c | |
parent | 1d8f0569e5d779a14a590d33cc4aa45db5d8049b (diff) | |
download | libgpod-tmz-69a7740761b910d3d1286e017b164979a8977884.tar.gz libgpod-tmz-69a7740761b910d3d1286e017b164979a8977884.tar.xz libgpod-tmz-69a7740761b910d3d1286e017b164979a8977884.zip |
* src/db-artwork-writer.c:
* src/db-image-parser.h:
* src/itdb.h:
* src/itdb_device.c:
* src/itdb_device.h:
* src/ithumb-writer.c: get rid of ItdbThumbType, it's replaced by
pointers to the appropriate Itdb_ArtworkFormat for the thumbnail
type when it's needed
git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@2010 f01d2545-417e-4e96-918e-98f8d0dbbcb6
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | src/db-artwork-writer.c | 25 | ||||
-rw-r--r-- | src/db-image-parser.h | 4 | ||||
-rw-r--r-- | src/itdb.h | 15 | ||||
-rw-r--r-- | src/itdb_device.c | 109 | ||||
-rw-r--r-- | src/itdb_device.h | 6 | ||||
-rw-r--r-- | src/ithumb-writer.c | 51 |
7 files changed, 79 insertions, 142 deletions
@@ -1,5 +1,16 @@ 2008-06-09 Christophe Fergeau <christophe@anevia.com> + * src/db-artwork-writer.c: + * src/db-image-parser.h: + * src/itdb.h: + * src/itdb_device.c: + * src/itdb_device.h: + * src/ithumb-writer.c: get rid of ItdbThumbType, it's replaced by + pointers to the appropriate Itdb_ArtworkFormat for the thumbnail + type when it's needed + +2008-06-09 Christophe Fergeau <christophe@anevia.com> + * src/db-artwork-parser.c: remove duplicated artwork/photo support testing functions * src/db-artwork-parser.h: ditto diff --git a/src/db-artwork-writer.c b/src/db-artwork-writer.c index 24e1bbb..1d868fa 100644 --- a/src/db-artwork-writer.c +++ b/src/db-artwork-writer.c @@ -749,31 +749,6 @@ write_mhif (Itdb_DB *db, iPodBuffer *buffer, return get_gint32 (mhif->header_len, buffer->byte_order); } -G_GNUC_INTERNAL gboolean -itdb_thumb_type_is_valid_for_db (const Itdb_ArtworkFormat *format, - DbType db_type) -{ - switch (format->type) { - case ITDB_THUMB_COVER_SMALL: - case ITDB_THUMB_COVER_LARGE: - case ITDB_THUMB_COVER_XLARGE: - case ITDB_THUMB_COVER_MEDIUM: - case ITDB_THUMB_COVER_SMEDIUM: - case ITDB_THUMB_COVER_XSMALL: - return (db_type == DB_TYPE_ITUNES); - case ITDB_THUMB_CHAPTER_SMALL: - case ITDB_THUMB_CHAPTER_LARGE: - return FALSE; /* not supported yet */ - case ITDB_THUMB_PHOTO_SMALL: - case ITDB_THUMB_PHOTO_LARGE: - case ITDB_THUMB_PHOTO_FULL_SCREEN: - case ITDB_THUMB_PHOTO_TV_SCREEN: - return (db_type == DB_TYPE_PHOTO); - } - - g_return_val_if_reached (FALSE); -} - static int write_mhlf (Itdb_DB *db, iPodBuffer *buffer) { diff --git a/src/db-image-parser.h b/src/db-image-parser.h index c8fbbe4..606bb4f 100644 --- a/src/db-image-parser.h +++ b/src/db-image-parser.h @@ -82,8 +82,4 @@ G_GNUC_INTERNAL Itdb_Thumb_Ipod_Item *ipod_image_new_from_mhni (MhniHeader *mhni Itdb_DB *db); G_GNUC_INTERNAL int itdb_write_ithumb_files (Itdb_DB *db); - -G_GNUC_INTERNAL gboolean -itdb_thumb_type_is_valid_for_db (const Itdb_ArtworkFormat *format, DbType db_type); - #endif @@ -478,21 +478,6 @@ struct _Itdb_Chapterdata #define ITDB_RATING_STEP 20 /* Types of thumbnails in Itdb_Image */ -typedef enum { - ITDB_THUMB_COVER_SMALL = 0, - ITDB_THUMB_COVER_LARGE, - ITDB_THUMB_PHOTO_SMALL, - ITDB_THUMB_PHOTO_LARGE, - ITDB_THUMB_PHOTO_FULL_SCREEN, - ITDB_THUMB_PHOTO_TV_SCREEN, - ITDB_THUMB_COVER_XLARGE, /* iPhone: cover flow */ - ITDB_THUMB_COVER_MEDIUM, /* iPhone: cover view */ - ITDB_THUMB_COVER_SMEDIUM, /* iPhone: ?? */ - ITDB_THUMB_COVER_XSMALL, /* iPhone: ?? */ - ITDB_THUMB_CHAPTER_SMALL, /* classic -- not supported yet */ - ITDB_THUMB_CHAPTER_LARGE, /* classic -- not supported yet */ -} ItdbThumbType; - enum _ItdbThumbDataType { ITDB_THUMB_TYPE_INVALID, ITDB_THUMB_TYPE_FILE, diff --git a/src/itdb_device.c b/src/itdb_device.c index 5b7b2aa..28ae5ef 100644 --- a/src/itdb_device.c +++ b/src/itdb_device.c @@ -268,100 +268,100 @@ static const gchar *ipod_generation_name_table [] = { static const Itdb_ArtworkFormat ipod_photo_cover_art_info[] = { - {ITDB_THUMB_COVER_SMALL, 56, 56, 1017, THUMB_FORMAT_RGB565_LE}, - {ITDB_THUMB_COVER_LARGE, 140, 140, 1016, THUMB_FORMAT_RGB565_LE}, - {-1, -1, -1, -1, -1} + { 56, 56, 1017, THUMB_FORMAT_RGB565_LE}, + {140, 140, 1016, THUMB_FORMAT_RGB565_LE}, + { -1, -1, -1, -1} }; static const Itdb_ArtworkFormat ipod_photo_photo_info[] = { - {ITDB_THUMB_PHOTO_SMALL, 42, 30, 1009, THUMB_FORMAT_RGB565_LE}, - {ITDB_THUMB_PHOTO_LARGE, 130, 88, 1015, THUMB_FORMAT_RGB565_LE}, - {ITDB_THUMB_PHOTO_FULL_SCREEN,220, 176, 1013, THUMB_FORMAT_RGB565_BE_90}, - {ITDB_THUMB_PHOTO_TV_SCREEN, 720, 480, 1019, THUMB_FORMAT_UYVY_BE}, - {-1, -1, -1, -1, -1} + { 42, 30, 1009, THUMB_FORMAT_RGB565_LE}, + {130, 88, 1015, THUMB_FORMAT_RGB565_LE}, + {220, 176, 1013, THUMB_FORMAT_RGB565_BE_90}, + {720, 480, 1019, THUMB_FORMAT_UYVY_BE}, + { -1, -1, -1, -1} }; static const Itdb_ArtworkFormat ipod_nano_cover_art_info[] = { - {ITDB_THUMB_COVER_SMALL, 42, 42, 1031, THUMB_FORMAT_RGB565_LE}, - {ITDB_THUMB_COVER_LARGE, 100, 100, 1027, THUMB_FORMAT_RGB565_LE}, - {-1, -1, -1, -1, -1} + { 42, 42, 1031, THUMB_FORMAT_RGB565_LE}, + {100, 100, 1027, THUMB_FORMAT_RGB565_LE}, + { -1, -1, -1, -1} }; static const Itdb_ArtworkFormat ipod_nano_photo_info[] = { - {ITDB_THUMB_PHOTO_LARGE, 42, 37, 1032, THUMB_FORMAT_RGB565_LE}, - {ITDB_THUMB_PHOTO_FULL_SCREEN,176, 132, 1023, THUMB_FORMAT_RGB565_BE}, - {-1, -1, -1, -1, -1} + { 42, 37, 1032, THUMB_FORMAT_RGB565_LE}, + {176, 132, 1023, THUMB_FORMAT_RGB565_BE}, + { -1, -1, -1, -1} }; static const Itdb_ArtworkFormat ipod_video_cover_art_info[] = { - {ITDB_THUMB_COVER_SMALL, 100, 100, 1028, THUMB_FORMAT_RGB565_LE}, - {ITDB_THUMB_COVER_LARGE, 200, 200, 1029, THUMB_FORMAT_RGB565_LE}, - {-1, -1, -1, -1, -1} + {100, 100, 1028, THUMB_FORMAT_RGB565_LE}, + {200, 200, 1029, THUMB_FORMAT_RGB565_LE}, + { -1, -1, -1, -1} }; static const Itdb_ArtworkFormat ipod_video_photo_info[] = { - {ITDB_THUMB_PHOTO_SMALL, 50, 41, 1036, THUMB_FORMAT_RGB565_LE}, - {ITDB_THUMB_PHOTO_LARGE, 130, 88, 1015, THUMB_FORMAT_RGB565_LE}, - {ITDB_THUMB_PHOTO_FULL_SCREEN,320, 240, 1024, THUMB_FORMAT_RGB565_LE}, - {ITDB_THUMB_PHOTO_TV_SCREEN, 720, 480, 1019, THUMB_FORMAT_UYVY_BE}, - {-1, -1, -1, -1, -1} + { 50, 41, 1036, THUMB_FORMAT_RGB565_LE}, + {130, 88, 1015, THUMB_FORMAT_RGB565_LE}, + {320, 240, 1024, THUMB_FORMAT_RGB565_LE}, + {720, 480, 1019, THUMB_FORMAT_UYVY_BE}, + { -1, -1, -1, -1} }; static const Itdb_ArtworkFormat ipod_mobile_1_cover_art_info[] = { - {ITDB_THUMB_COVER_SMALL, 50, 50, 2002, THUMB_FORMAT_RGB565_BE}, - {ITDB_THUMB_COVER_LARGE, 150, 150, 2003, THUMB_FORMAT_RGB565_BE}, - {-1, -1, -1, -1, -1} + { 50, 50, 2002, THUMB_FORMAT_RGB565_BE}, + {150, 150, 2003, THUMB_FORMAT_RGB565_BE}, + { -1, -1, -1, -1} }; static const Itdb_ArtworkFormat ipod_touch_1_cover_art_info[] = { - {ITDB_THUMB_COVER_LARGE, 256, 256, 3001, THUMB_FORMAT_REC_RGB555_LE}, - {ITDB_THUMB_COVER_MEDIUM, 128, 128, 3002, THUMB_FORMAT_REC_RGB555_LE}, - {ITDB_THUMB_COVER_SMALL, 64, 64, 3003, THUMB_FORMAT_REC_RGB555_LE}, - {ITDB_THUMB_COVER_XLARGE, 320, 320, 3005, THUMB_FORMAT_RGB555_LE}, - {ITDB_THUMB_COVER_XSMALL, 56, 56, 3006, THUMB_FORMAT_RGB555_LE, 8192}, /*pad data to 8192 bytes */ - {ITDB_THUMB_COVER_SMEDIUM, 88, 88, 3007, THUMB_FORMAT_RGB555_LE, 16364}, /*pad data to 16384 bytes */ - {-1, -1, -1, -1, -1} + {256, 256, 3001, THUMB_FORMAT_REC_RGB555_LE}, + {128, 128, 3002, THUMB_FORMAT_REC_RGB555_LE}, + { 64, 64, 3003, THUMB_FORMAT_REC_RGB555_LE}, + {320, 320, 3005, THUMB_FORMAT_RGB555_LE}, + { 56, 56, 3006, THUMB_FORMAT_RGB555_LE, 8192}, /*pad data to 8192 bytes */ + { 88, 88, 3007, THUMB_FORMAT_RGB555_LE, 16364}, /*pad data to 16384 bytes */ + { -1, -1, -1, -1} }; static const Itdb_ArtworkFormat ipod_touch_1_photo_info[] = { /* In the album list, if a photo is being used to represent a whole album, PHOTO_SMALL is used. We specify TRUE for the crop option so we fill the square completely. */ - {ITDB_THUMB_PHOTO_SMALL, 56, 55, 3004, THUMB_FORMAT_RGB555_LE, 8192, TRUE}, + { 56, 55, 3004, THUMB_FORMAT_RGB555_LE, 8192, TRUE}, /* In thumbnail view, PHOTO_LARGE is used. It's actually 79x79, with a 4px white border on the right and bottom. We specify TRUE for the crop option so we fill the square completely. */ - {ITDB_THUMB_PHOTO_LARGE, 80, 79, 3011, THUMB_FORMAT_RGB555_LE, 0, TRUE}, - {ITDB_THUMB_PHOTO_FULL_SCREEN,160, 120, 3009, THUMB_FORMAT_RGB555_LE}, + { 80, 79, 3011, THUMB_FORMAT_RGB555_LE, 0, TRUE}, + {160, 120, 3009, THUMB_FORMAT_RGB555_LE}, /* When viewing an individual photo, PHOTO_TV_SCREEN is used. Note that it is acceptable to write a thumbnail less than the specified width or height, the iPhone / iTouch will scale it to fit the screen. This is important for images that are taller than they wide. */ - {ITDB_THUMB_PHOTO_TV_SCREEN, 640, 480, 3008, THUMB_FORMAT_RGB555_LE}, - {-1, -1, -1, -1, -1} + {640, 480, 3008, THUMB_FORMAT_RGB555_LE}, + { -1, -1, -1, -1} }; static const Itdb_ArtworkFormat ipod_classic_1_cover_art_info[] = { /* officially 55x55 -- verify! */ - {ITDB_THUMB_COVER_SMALL, 56, 56, 1061, THUMB_FORMAT_RGB565_LE}, - {ITDB_THUMB_COVER_MEDIUM, 128, 128, 1055, THUMB_FORMAT_RGB565_LE}, - {ITDB_THUMB_COVER_LARGE, 320, 320, 1060, THUMB_FORMAT_RGB565_LE}, - {-1, -1, -1, -1, -1} + { 56, 56, 1061, THUMB_FORMAT_RGB565_LE}, + {128, 128, 1055, THUMB_FORMAT_RGB565_LE}, + {320, 320, 1060, THUMB_FORMAT_RGB565_LE}, + { -1, -1, -1, -1} }; static const Itdb_ArtworkFormat ipod_classic_1_photo_info[] = { - {ITDB_THUMB_PHOTO_TV_SCREEN, 720, 480, 1067, THUMB_FORMAT_I420_LE}, - {ITDB_THUMB_PHOTO_FULL_SCREEN,320, 240, 1024, THUMB_FORMAT_RGB565_LE}, - {ITDB_THUMB_PHOTO_SMALL, 64, 64, 1066, THUMB_FORMAT_RGB565_LE}, - {-1, -1, -1, -1, -1} + {720, 480, 1067, THUMB_FORMAT_I420_LE}, + {320, 240, 1024, THUMB_FORMAT_RGB565_LE}, + { 64, 64, 1066, THUMB_FORMAT_RGB565_LE}, + { -1, -1, -1, -1} }; static const Itdb_ArtworkFormat ipod_classic_1_chapter_image_info[] = { /* These are the same as for the iPod video... -- labeled by the iPod as "chapter images" */ - {ITDB_THUMB_CHAPTER_SMALL, 100, 100, 1028, THUMB_FORMAT_RGB565_LE}, - {ITDB_THUMB_CHAPTER_LARGE, 200, 200, 1029, THUMB_FORMAT_RGB565_LE}, - {-1, -1, -1, -1, -1} + {100, 100, 1028, THUMB_FORMAT_RGB565_LE}, + {200, 200, 1029, THUMB_FORMAT_RGB565_LE}, + { -1, -1, -1, -1} }; enum ArtworkType { @@ -772,7 +772,7 @@ GList *itdb_device_get_photo_formats (const Itdb_Device *device) return NULL; } - for (it = formats; it->type != -1; it++) { + for (it = formats; it->format_id != -1; it++) { photo_formats = g_list_prepend (photo_formats, (gpointer)it); } @@ -790,7 +790,7 @@ GList *itdb_device_get_cover_art_formats (const Itdb_Device *device) return NULL; } - for (it = formats; it->type != -1; it++) { + for (it = formats; it->format_id != -1; it++) { cover_art_formats = g_list_prepend (cover_art_formats, (gpointer)it); } @@ -1097,18 +1097,11 @@ gboolean itdb_device_supports_video (const Itdb_Device *device) gboolean itdb_device_supports_photo (const Itdb_Device *device) { - const Itdb_ArtworkFormat *formats; - if (device == NULL) { return FALSE; } - formats = itdb_device_get_artwork_formats (device, ARTWORK_TYPE_PHOTO); - if (formats == NULL) { - return FALSE; - } - - return (formats->type != -1); + return (itdb_device_get_artwork_formats (device, ARTWORK_TYPE_PHOTO) != NULL); } diff --git a/src/itdb_device.h b/src/itdb_device.h index 85956af..2d733a4 100644 --- a/src/itdb_device.h +++ b/src/itdb_device.h @@ -52,8 +52,8 @@ enum _ItdbThumbFormat { THUMB_FORMAT_UYVY_LE, THUMB_FORMAT_UYVY_BE, - THUMB_FORMAT_I420_LE, - THUMB_FORMAT_I420_BE, + THUMB_FORMAT_I420_LE, + THUMB_FORMAT_I420_BE, THUMB_FORMAT_RGB565_LE, THUMB_FORMAT_RGB565_LE_90, THUMB_FORMAT_RGB565_BE, @@ -74,7 +74,6 @@ enum _ItdbThumbFormat THUMB_FORMAT_EXPERIMENTAL_BE, }; - struct _Itdb_Device { gchar *mountpoint; /* mountpoint of the iPod */ @@ -97,7 +96,6 @@ struct _Itdb_Device struct _Itdb_ArtworkFormat { - ItdbThumbType type; gint16 width; gint16 height; gint16 format_id; diff --git a/src/ithumb-writer.c b/src/ithumb-writer.c index 83c9bff..aff2852 100644 --- a/src/ithumb-writer.c +++ b/src/ithumb-writer.c @@ -482,7 +482,20 @@ pack_UYVY (GdkPixbuf *orig_pixbuf, const Itdb_ArtworkFormat *img_info, return yuvdata; } - +static char *get_ithmb_filename (iThumbWriter *writer) +{ + switch (writer->db_type) { + case DB_TYPE_ITUNES: + return g_strdup_printf (":F%d_%d.ithmb", + writer->img_info->format_id, + writer->current_file_index); + case DB_TYPE_PHOTO: + return g_strdup_printf (":Thumbs:F%d_%d.ithmb", + writer->img_info->format_id, + writer->current_file_index); + } + g_return_val_if_reached (NULL); +} static char * ipod_image_get_ithmb_filename (const char *mount_point, gint format_id, gint index, DbType db_type ) @@ -781,35 +794,6 @@ static gboolean write_pixels (iThumbWriter *writer, Itdb_Thumb_Ipod_Item *thumb, return TRUE; } -static char *get_ithmb_filename (iThumbWriter *writer, - const Itdb_ArtworkFormat *format) -{ - switch (format->type) - { - case ITDB_THUMB_PHOTO_LARGE: - case ITDB_THUMB_PHOTO_SMALL: - case ITDB_THUMB_PHOTO_FULL_SCREEN: - case ITDB_THUMB_PHOTO_TV_SCREEN: - return g_strdup_printf (":Thumbs:F%d_%d.ithmb", - writer->img_info->format_id, - writer->current_file_index); - break; - case ITDB_THUMB_COVER_LARGE: - case ITDB_THUMB_COVER_SMALL: - case ITDB_THUMB_COVER_XLARGE: - case ITDB_THUMB_COVER_MEDIUM: - case ITDB_THUMB_COVER_SMEDIUM: - case ITDB_THUMB_COVER_XSMALL: - case ITDB_THUMB_CHAPTER_LARGE: - case ITDB_THUMB_CHAPTER_SMALL: - return g_strdup_printf (":F%d_%d.ithmb", - writer->img_info->format_id, - writer->current_file_index); - break; - } - g_return_val_if_reached (NULL); -} - static void set_thumb_padding (iThumbWriter *writer, Itdb_Thumb_Ipod_Item *thumb, gint width, gint height) @@ -821,11 +805,6 @@ static void set_thumb_padding (iThumbWriter *writer, thumb->vertical_padding = (writer->img_info->height - height)/2; break; case DB_TYPE_ITUNES: - /* IPOD_COVER_LARGE will be centered automatically using - the info in mhni->width/height. Free space around - IPOD_COVER_SMALL will be used to display track - information -> no padding (tested on iPod - Nano). mhni->hor_/ver_padding is working */ thumb->horizontal_padding = 0; thumb->vertical_padding = 0; break; @@ -933,7 +912,7 @@ ithumb_writer_write_thumbnail (iThumbWriter *writer, pixels = pack_thumbnail (writer, thumb_ipod, scaled_pixbuf); g_object_unref (G_OBJECT (scaled_pixbuf)); - thumb_ipod->filename = get_ithmb_filename (writer, writer->img_info); + thumb_ipod->filename = get_ithmb_filename (writer); result = write_pixels (writer, thumb_ipod, pixels); g_free (pixels); |