Index: src/apps/plugins/pictureflow/pictureflow.c =================================================================== --- src/apps/plugins/pictureflow/pictureflow.c (old version) +++ src/apps/plugins/pictureflow/pictureflow.c (new version) @@ -1051,6 +1051,24 @@ rb->yield(); } +/* Calculate modified FNV hash of string + * has good avalanche behaviour and uniform distribution + * see http://home.comcast.net/~bretm/hash/ */ +unsigned int mfnv(char *str) +{ + const unsigned int p = 16777619; + unsigned int hash = 0x811C9DC5; // 2166136261; + + while(*str) + hash = (hash ^ *str++) * p; + hash += hash << 13; + hash ^= hash >> 7; + hash += hash << 3; + hash ^= hash >> 17; + hash += hash << 5; + return hash; +} + /** Precomupte the album art images and store them in CACHE_PREFIX. */ @@ -1064,29 +1082,35 @@ char pfraw_file[MAX_PATH]; char albumart_file[MAX_PATH]; unsigned int format = FORMAT_NATIVE; + bool forced = cache_version == 0; cache_version = 0; configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION); if (resize) format |= FORMAT_RESIZE|FORMAT_KEEP_ASPECT; for (i=0; i < album_count; i++) { - rb->snprintf(pfraw_file, sizeof(pfraw_file), CACHE_PREFIX "/%d.pfraw", - i); + rb->snprintf(pfraw_file, sizeof(pfraw_file), CACHE_PREFIX "/%x.pfraw", + mfnv(get_album_name(i))); /* delete existing cache, so it's a true rebuild */ - if(rb->file_exists(pfraw_file)) + if(rb->file_exists(pfraw_file)) { + if(!forced) + continue; rb->remove(pfraw_file); + } draw_progressbar(i); if (!get_albumart_for_index_from_db(i, albumart_file, MAX_PATH)) - continue; + rb->strcpy(albumart_file, EMPTY_SLIDE_BMP); input_bmp.data = buf; input_bmp.width = DISPLAY_WIDTH; input_bmp.height = DISPLAY_HEIGHT; - ret = read_image_file(albumart_file, &input_bmp, - buf_size, format, &format_transposed); + ret = read_image_file(albumart_file, &input_bmp, buf_size, format, &format_transposed); if (ret <= 0) { - rb->splash(HZ, "Could not read bmp"); - continue; /* skip missing/broken files */ + rb->splashf(HZ, "Album art is bad: %s", get_album_name(i)); + rb->strcpy(albumart_file, EMPTY_SLIDE_BMP); + ret = read_image_file(albumart_file, &input_bmp, buf_size, format, &format_transposed); + if(ret <= 0) + continue; } if (!save_pfraw(pfraw_file, &input_bmp)) { @@ -1361,8 +1385,10 @@ { struct pfraw_header bmph; int fh = rb->open(filename, O_RDONLY); - if( fh < 0 ) + if( fh < 0 ) { + cache_version = 1; return empty_slide_hid; + } else rb->read(fh, &bmph, sizeof(struct pfraw_header)); @@ -1402,8 +1428,8 @@ const int prio) { char tmp_path_name[MAX_PATH+1]; - rb->snprintf(tmp_path_name, sizeof(tmp_path_name), CACHE_PREFIX "/%d.pfraw", - slide_index); + rb->snprintf(tmp_path_name, sizeof(tmp_path_name), CACHE_PREFIX "/%x.pfraw", + mfnv(get_album_name(slide_index))); int hid = read_pfraw(tmp_path_name, prio); if (!hid)