rendered paste bodycommit dc25ea762a2ae44ba965e4b54c24c8326ccf23abAuthor: Christophe Fergeau <cfergeau@mandriva.com>Date: Tue Aug 24 19:40:52 2010 +0200 alignment hackdiff --git a/src/itdb_artwork.c b/src/itdb_artwork.cindex dd6c4ca..d7211e2 100644--- a/src/itdb_artwork.c+++ b/src/itdb_artwork.c@@ -330,6 +330,49 @@ unpack_RGB_565 (guint16 *pixels, guint bytes_len, guint byte_order) } static guchar *+unpack_RGB_555_aligned_hack (guint16 *pixels, guint bytes_len, guint byte_order)+{+ guchar *result;+ guint x;+ guint y;+ guint rowstride;+ guint alignment = 16;+ guint height = 110;+ guint width = 110;++ g_return_val_if_fail (bytes_len < 2*(G_MAXUINT/3), NULL);++ result = g_malloc ((bytes_len/2) * 3);++ rowstride = width*2;+ if (alignment) {+ rowstride = (rowstride + alignment - 1)/alignment * alignment;+ }+ rowstride /= 2; /* FIXME: rowstride in pixel size unit, not bytes */++ for (y = 0; y < height; y++) {+ for (x = 0; x < width; x++) {+ guint16 cur_pixel;+ guint i;+ /* FIXME: endianness */+ cur_pixel = get_gint16 (pixels[y*rowstride + x], byte_order);+ i = y * width + x;+ /* Unpack pixels */+ result[3*i] = (cur_pixel & RED_MASK_555) >> RED_SHIFT_555;+ result[3*i+1] = (cur_pixel & GREEN_MASK_555) >> GREEN_SHIFT_555;+ result[3*i+2] = (cur_pixel & BLUE_MASK_555) >> BLUE_SHIFT_555;++ /* Normalize color values so that they use a [0..255] range */+ result[3*i] <<= (8 - RED_BITS_555);+ result[3*i+1] <<= (8 - GREEN_BITS_555);+ result[3*i+2] <<= (8 - BLUE_BITS_555);+ }+ }++ return result;+}++static guchar * unpack_RGB_555 (guint16 *pixels, guint bytes_len, guint byte_order) { guchar *result;@@ -758,8 +801,13 @@ itdb_thumb_get_rgb_data (Itdb_Device *device, Itdb_Thumb_Ipod_Item *item) screen photo thumbnail) */ case THUMB_FORMAT_RGB555_LE: case THUMB_FORMAT_RGB555_BE:- pixels = unpack_RGB_555 (pixels_raw, item->size,- itdb_thumb_get_byteorder (item->format->format));+ if (item->format->format_id == 3106) {+ pixels = unpack_RGB_555_aligned_hack (pixels_raw, item->size,+ itdb_thumb_get_byteorder (item->format->format));+ } else {+ pixels = unpack_RGB_555 (pixels_raw, item->size,+ itdb_thumb_get_byteorder (item->format->format));+ } break; case THUMB_FORMAT_RGB888_LE_90: case THUMB_FORMAT_RGB888_BE_90: