summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorRoman Artiukhin <bahusdrive@gmail.com>2024-10-14 21:33:40 +0300
committerChristian Soffke <christian.soffke@gmail.com>2024-10-28 12:46:51 -0400
commit55a5bfe7409677a26437651798abbc6d87b56089 (patch)
tree7ab7d96f52ee15257b174e75f15abae1f09b74cf /apps
parentc1bcebd9986b1e2120fd05ead67754d444dae7d3 (diff)
downloadrockbox-55a5bfe7409677a26437651798abbc6d87b56089.tar.gz
rockbox-55a5bfe7409677a26437651798abbc6d87b56089.zip
View Album Art from WPS context menu
Add ability to imageviewer to view current track embedded/folder album art Add "View Album Art" WPS context menu item Change-Id: I49caebd38e5e3e2910d418bbeaa5e51da0e6bd93
Diffstat (limited to 'apps')
-rw-r--r--apps/lang/english.lang14
-rw-r--r--apps/onplay.c14
-rw-r--r--apps/plugins/imageviewer/bmp/bmp.c9
-rw-r--r--apps/plugins/imageviewer/gif/gif.c5
-rw-r--r--apps/plugins/imageviewer/imageviewer.c98
-rw-r--r--apps/plugins/imageviewer/imageviewer.h2
-rw-r--r--apps/plugins/imageviewer/jpeg/jpeg.c14
-rw-r--r--apps/plugins/imageviewer/jpegp/jpegp.c8
-rw-r--r--apps/plugins/imageviewer/png/png.c17
-rw-r--r--apps/plugins/imageviewer/ppm/ppm.c16
10 files changed, 166 insertions, 31 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 1beb730411..f88864efcc 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -16567,3 +16567,17 @@
16567 *: "Remaining" 16567 *: "Remaining"
16568 </voice> 16568 </voice>
16569</phrase> 16569</phrase>
16570<phrase>
16571 id: LANG_VIEW_ALBUMART
16572 desc: WPS context menu
16573 user: core
16574 <source>
16575 *: "View Album Art"
16576 </source>
16577 <dest>
16578 *: "View Album Art"
16579 </dest>
16580 <voice>
16581 *: "View Album Art"
16582 </voice>
16583</phrase>
diff --git a/apps/onplay.c b/apps/onplay.c
index ab507f08ac..a259e88c58 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -211,6 +211,13 @@ static void playing_time(void)
211 plugin_load(PLUGIN_APPS_DIR"/playing_time.rock", NULL); 211 plugin_load(PLUGIN_APPS_DIR"/playing_time.rock", NULL);
212} 212}
213 213
214#ifdef HAVE_ALBUMART
215static void view_album_art(void)
216{
217 plugin_load(VIEWERS_DIR"/imageviewer.rock", NULL);
218}
219#endif
220
214MENUITEM_FUNCTION(wps_view_cur_playlist_item, 0, ID2P(LANG_VIEW_DYNAMIC_PLAYLIST), 221MENUITEM_FUNCTION(wps_view_cur_playlist_item, 0, ID2P(LANG_VIEW_DYNAMIC_PLAYLIST),
215 wps_view_cur_playlist, NULL, Icon_NOICON); 222 wps_view_cur_playlist, NULL, Icon_NOICON);
216MENUITEM_FUNCTION(search_playlist_item, 0, ID2P(LANG_SEARCH_IN_PLAYLIST), 223MENUITEM_FUNCTION(search_playlist_item, 0, ID2P(LANG_SEARCH_IN_PLAYLIST),
@@ -705,6 +712,10 @@ MENUITEM_FUNCTION(browse_id3_item, MENU_FUNC_CHECK_RETVAL, ID2P(LANG_MENU_SHOW_I
705MENUITEM_FUNCTION(pitch_screen_item, 0, ID2P(LANG_PITCH), 712MENUITEM_FUNCTION(pitch_screen_item, 0, ID2P(LANG_PITCH),
706 gui_syncpitchscreen_run, NULL, Icon_Audio); 713 gui_syncpitchscreen_run, NULL, Icon_Audio);
707#endif 714#endif
715#ifdef HAVE_ALBUMART
716MENUITEM_FUNCTION(view_album_art_item, 0, ID2P(LANG_VIEW_ALBUMART),
717 view_album_art, NULL, Icon_NOICON);
718#endif
708 719
709static int clipboard_delete_selected_fileobject(void) 720static int clipboard_delete_selected_fileobject(void)
710{ 721{
@@ -1028,6 +1039,9 @@ MAKE_ONPLAYMENU( wps_onplay_menu, ID2P(LANG_ONPLAY_MENU_TITLE),
1028#ifdef HAVE_PITCHCONTROL 1039#ifdef HAVE_PITCHCONTROL
1029 &pitch_screen_item, 1040 &pitch_screen_item,
1030#endif 1041#endif
1042#ifdef HAVE_ALBUMART
1043 &view_album_art_item,
1044#endif
1031 ); 1045 );
1032 1046
1033MENUITEM_FUNCTION(view_playlist_item, 0, ID2P(LANG_VIEW), 1047MENUITEM_FUNCTION(view_playlist_item, 0, ID2P(LANG_VIEW),
diff --git a/apps/plugins/imageviewer/bmp/bmp.c b/apps/plugins/imageviewer/bmp/bmp.c
index f7e55dbe62..019c4982d3 100644
--- a/apps/plugins/imageviewer/bmp/bmp.c
+++ b/apps/plugins/imageviewer/bmp/bmp.c
@@ -100,8 +100,10 @@ static int img_mem(int ds)
100} 100}
101 101
102static int load_image(char *filename, struct image_info *info, 102static int load_image(char *filename, struct image_info *info,
103 unsigned char *buf, ssize_t *buf_size) 103 unsigned char *buf, ssize_t *buf_size,
104 int offset, int filesize)
104{ 105{
106 (void)filesize;
105 int w, h; /* used to center output */ 107 int w, h; /* used to center output */
106 long time; /* measured ticks */ 108 long time; /* measured ticks */
107 int fd; 109 int fd;
@@ -127,6 +129,11 @@ static int load_image(char *filename, struct image_info *info,
127 rb->splashf(HZ, "err opening %s: %d", filename, fd); 129 rb->splashf(HZ, "err opening %s: %d", filename, fd);
128 return PLUGIN_ERROR; 130 return PLUGIN_ERROR;
129 } 131 }
132 if (offset)
133 {
134 rb->lseek(fd, offset, SEEK_SET);
135 }
136
130 int ds = 1; 137 int ds = 1;
131 /* check size of image needed to load image. */ 138 /* check size of image needed to load image. */
132 size = scaled_read_bmp_fd(fd, &bmp, 0, format | FORMAT_RETURN_SIZE, cformat); 139 size = scaled_read_bmp_fd(fd, &bmp, 0, format | FORMAT_RETURN_SIZE, cformat);
diff --git a/apps/plugins/imageviewer/gif/gif.c b/apps/plugins/imageviewer/gif/gif.c
index 0521c29e3a..61ff1a6146 100644
--- a/apps/plugins/imageviewer/gif/gif.c
+++ b/apps/plugins/imageviewer/gif/gif.c
@@ -76,8 +76,11 @@ static int img_mem(int ds)
76} 76}
77 77
78static int load_image(char *filename, struct image_info *info, 78static int load_image(char *filename, struct image_info *info,
79 unsigned char *buf, ssize_t *buf_size) 79 unsigned char *buf, ssize_t *buf_size,
80 int offset, int filesize)
80{ 81{
82 (void)offset;(void)filesize;
83
81 int w, h; 84 int w, h;
82 long time = 0; /* measured ticks */ 85 long time = 0; /* measured ticks */
83 struct gif_decoder *p_decoder = &decoder; 86 struct gif_decoder *p_decoder = &decoder;
diff --git a/apps/plugins/imageviewer/imageviewer.c b/apps/plugins/imageviewer/imageviewer.c
index ba5f8fec16..77286bd37d 100644
--- a/apps/plugins/imageviewer/imageviewer.c
+++ b/apps/plugins/imageviewer/imageviewer.c
@@ -838,16 +838,12 @@ static void get_view(struct image_info *info, int *p_cx, int *p_cy)
838} 838}
839 839
840/* load, decode, display the image */ 840/* load, decode, display the image */
841static int load_and_show(char* filename, struct image_info *info) 841static int load_and_show(char *filename, struct image_info *info,
842 int offset, int filesize, int status)
842{ 843{
843 int status;
844 int cx, cy; 844 int cx, cy;
845 ssize_t remaining; 845 ssize_t remaining;
846 846
847 rb->lcd_clear_display();
848
849 /* suppress warning while running slideshow */
850 status = get_image_type(filename, iv_api.running_slideshow);
851 if (status == IMAGE_UNKNOWN) { 847 if (status == IMAGE_UNKNOWN) {
852 /* file isn't supported image file, skip this. */ 848 /* file isn't supported image file, skip this. */
853 file_pt[curfile] = NULL; 849 file_pt[curfile] = NULL;
@@ -855,6 +851,8 @@ static int load_and_show(char* filename, struct image_info *info)
855 } 851 }
856 852
857reload_decoder: 853reload_decoder:
854 rb->lcd_clear_display();
855
858 if (image_type != status) /* type of image is changed, load decoder. */ 856 if (image_type != status) /* type of image is changed, load decoder. */
859 { 857 {
860 struct loader_info loader_info = { 858 struct loader_info loader_info = {
@@ -881,11 +879,10 @@ reload_decoder:
881 if (rb->button_get(false) == IMGVIEW_MENU) 879 if (rb->button_get(false) == IMGVIEW_MENU)
882 status = PLUGIN_ABORT; 880 status = PLUGIN_ABORT;
883 else 881 else
884 status = imgdec->load_image(filename, info, buf, &remaining); 882 status = imgdec->load_image(filename, info, buf, &remaining, offset, filesize);
885 883
886 if (status == PLUGIN_JPEG_PROGRESSIVE) 884 if (status == PLUGIN_JPEG_PROGRESSIVE)
887 { 885 {
888 rb->lcd_clear_display();
889 status = IMAGE_JPEG_PROGRESSIVE; 886 status = IMAGE_JPEG_PROGRESSIVE;
890 goto reload_decoder; 887 goto reload_decoder;
891 } 888 }
@@ -1035,6 +1032,47 @@ reload_decoder:
1035 return status; 1032 return status;
1036} 1033}
1037 1034
1035static bool find_album_art(int *offset, int *filesize, int *status)
1036{
1037#ifndef HAVE_ALBUMART
1038 (void)offset;(void)filesize;(void)status;
1039 return false;
1040#else
1041 struct mp3entry *current_track = rb->audio_current_track();
1042
1043 if (current_track == NULL)
1044 {
1045 return false;
1046 }
1047
1048 switch (current_track->albumart.type)
1049 {
1050 case AA_TYPE_BMP:
1051 (*status) = IMAGE_BMP;
1052 break;
1053 case AA_TYPE_PNG:
1054 (*status) = IMAGE_PNG;
1055 break;
1056 case AA_TYPE_JPG:
1057 (*status) = IMAGE_JPEG;
1058 break;
1059 default:
1060 if (rb->search_albumart_files(current_track, "", np_file, MAX_PATH))
1061 {
1062 (*status) = get_image_type(np_file, false);
1063 return true;
1064 } else
1065 {
1066 return false;
1067 }
1068 }
1069 rb->strcpy(np_file, current_track->path);
1070 (*offset) = current_track->albumart.pos;
1071 (*filesize) = current_track->albumart.size;
1072 return true;
1073#endif
1074}
1075
1038/******************** Plugin entry point *********************/ 1076/******************** Plugin entry point *********************/
1039 1077
1040enum plugin_status plugin_start(const void* parameter) 1078enum plugin_status plugin_start(const void* parameter)
@@ -1044,13 +1082,28 @@ enum plugin_status plugin_start(const void* parameter)
1044 long greysize; /* helper */ 1082 long greysize; /* helper */
1045#endif 1083#endif
1046 1084
1047 if(!parameter) {rb->splash(HZ*2, "No file"); return PLUGIN_ERROR; } 1085 int offset = 0, filesize = 0, status;
1048 1086
1049 rb->strcpy(np_file, parameter); 1087 bool is_album_art = false;
1050 if (get_image_type(np_file, false) == IMAGE_UNKNOWN) 1088 if (!parameter)
1051 { 1089 {
1052 rb->splash(HZ*2, "Unsupported file"); 1090 if (!find_album_art(&offset, &filesize, &status))
1053 return PLUGIN_ERROR; 1091 {
1092 rb->splash(HZ * 2, "No file");
1093 return PLUGIN_ERROR;
1094 }
1095
1096 entries = 1;
1097 is_album_art = true;
1098 }
1099 else
1100 {
1101 rb->strcpy(np_file, parameter);
1102 if ((status = get_image_type(np_file, false)) == IMAGE_UNKNOWN)
1103 {
1104 rb->splash(HZ * 2, "Unsupported file");
1105 return PLUGIN_ERROR;
1106 }
1054 } 1107 }
1055 1108
1056#ifdef USE_PLUG_BUF 1109#ifdef USE_PLUG_BUF
@@ -1060,7 +1113,10 @@ enum plugin_status plugin_start(const void* parameter)
1060 buf = rb->plugin_get_audio_buffer(&buf_size); 1113 buf = rb->plugin_get_audio_buffer(&buf_size);
1061#endif 1114#endif
1062 1115
1063 get_pic_list(); 1116 if(!is_album_art)
1117 {
1118 get_pic_list();
1119 }
1064 1120
1065#ifdef USEGSLIB 1121#ifdef USEGSLIB
1066 if (!grey_init(buf, buf_size, GREY_ON_COP, 1122 if (!grey_init(buf, buf_size, GREY_ON_COP,
@@ -1100,8 +1156,18 @@ enum plugin_status plugin_start(const void* parameter)
1100 1156
1101 do 1157 do
1102 { 1158 {
1103 condition = load_and_show(np_file, &image_info); 1159 condition = load_and_show(np_file, &image_info, offset, filesize, status);
1104 } while (condition >= PLUGIN_OTHER); 1160 if (condition >= PLUGIN_OTHER)
1161 {
1162 if(!is_album_art)
1163 {
1164 /* suppress warning while running slideshow */
1165 status = get_image_type(np_file, iv_api.running_slideshow);
1166 }
1167 continue;
1168 }
1169 break;
1170 } while (true);
1105 release_decoder(); 1171 release_decoder();
1106 1172
1107 if (rb->memcmp(&settings, &old_settings, sizeof (settings))) 1173 if (rb->memcmp(&settings, &old_settings, sizeof (settings)))
diff --git a/apps/plugins/imageviewer/imageviewer.h b/apps/plugins/imageviewer/imageviewer.h
index 44e56c0696..79691f747e 100644
--- a/apps/plugins/imageviewer/imageviewer.h
+++ b/apps/plugins/imageviewer/imageviewer.h
@@ -126,7 +126,7 @@ struct image_decoder {
126 * size of buf after load image. it is used to calculate min downscale. 126 * size of buf after load image. it is used to calculate min downscale.
127 * return PLUGIN_ERROR for error. ui will skip to next image. */ 127 * return PLUGIN_ERROR for error. ui will skip to next image. */
128 int (*load_image)(char *filename, struct image_info *info, 128 int (*load_image)(char *filename, struct image_info *info,
129 unsigned char *buf, ssize_t *buf_size); 129 unsigned char *buf, ssize_t *buf_size, int offset, int filesize);
130 /* downscale loaded image by ds. use the buffer passed to load_image to 130 /* downscale loaded image by ds. use the buffer passed to load_image to
131 * reszie image and/or store resized image. 131 * reszie image and/or store resized image.
132 * return PLUGIN_ERROR for error. ui will skip to next image. */ 132 * return PLUGIN_ERROR for error. ui will skip to next image. */
diff --git a/apps/plugins/imageviewer/jpeg/jpeg.c b/apps/plugins/imageviewer/jpeg/jpeg.c
index c231209beb..c7969c10c9 100644
--- a/apps/plugins/imageviewer/jpeg/jpeg.c
+++ b/apps/plugins/imageviewer/jpeg/jpeg.c
@@ -110,10 +110,10 @@ static int img_mem(int ds)
110} 110}
111 111
112static int load_image(char *filename, struct image_info *info, 112static int load_image(char *filename, struct image_info *info,
113 unsigned char *buf, ssize_t *buf_size) 113 unsigned char *buf, ssize_t *buf_size,
114 int offset, int filesize)
114{ 115{
115 int fd; 116 int fd;
116 int filesize;
117 unsigned char* buf_jpeg; /* compressed JPEG image */ 117 unsigned char* buf_jpeg; /* compressed JPEG image */
118 int status; 118 int status;
119 struct jpeg *p_jpg = &jpg; 119 struct jpeg *p_jpg = &jpg;
@@ -127,7 +127,15 @@ static int load_image(char *filename, struct image_info *info,
127 rb->splashf(HZ, "err opening %s: %d", filename, fd); 127 rb->splashf(HZ, "err opening %s: %d", filename, fd);
128 return PLUGIN_ERROR; 128 return PLUGIN_ERROR;
129 } 129 }
130 filesize = rb->filesize(fd); 130
131 if (offset)
132 {
133 rb->lseek(fd, offset, SEEK_SET);
134 }
135 else
136 {
137 filesize = rb->filesize(fd);
138 }
131 139
132 /* allocate JPEG buffer */ 140 /* allocate JPEG buffer */
133 buf_jpeg = buf; 141 buf_jpeg = buf;
diff --git a/apps/plugins/imageviewer/jpegp/jpegp.c b/apps/plugins/imageviewer/jpegp/jpegp.c
index bb7be314f1..88edc7e8f3 100644
--- a/apps/plugins/imageviewer/jpegp/jpegp.c
+++ b/apps/plugins/imageviewer/jpegp/jpegp.c
@@ -96,8 +96,10 @@ static void scaled_dequantization_and_idct(void)
96} 96}
97 97
98static int load_image(char *filename, struct image_info *info, 98static int load_image(char *filename, struct image_info *info,
99 unsigned char *buf, ssize_t *buf_size) 99 unsigned char *buf, ssize_t *buf_size,
100 int offset, int filesize)
100{ 101{
102 (void)filesize;
101 int status; 103 int status;
102 struct JPEGD *p_jpg = &jpg; 104 struct JPEGD *p_jpg = &jpg;
103 105
@@ -110,6 +112,10 @@ static int load_image(char *filename, struct image_info *info,
110 { 112 {
111 return PLUGIN_ERROR; 113 return PLUGIN_ERROR;
112 } 114 }
115 if (offset)
116 {
117 POS(offset);
118 }
113 119
114 if (!iv->running_slideshow) 120 if (!iv->running_slideshow)
115 { 121 {
diff --git a/apps/plugins/imageviewer/png/png.c b/apps/plugins/imageviewer/png/png.c
index 29b6713585..34a8a1fd34 100644
--- a/apps/plugins/imageviewer/png/png.c
+++ b/apps/plugins/imageviewer/png/png.c
@@ -89,7 +89,8 @@ static int img_mem(int ds)
89} 89}
90 90
91static int load_image(char *filename, struct image_info *info, 91static int load_image(char *filename, struct image_info *info,
92 unsigned char *buf, ssize_t *buf_size) 92 unsigned char *buf, ssize_t *buf_size,
93 int offset, int file_size)
93{ 94{
94 int fd; 95 int fd;
95 long time = 0; /* measured ticks */ 96 long time = 0; /* measured ticks */
@@ -97,7 +98,7 @@ static int load_image(char *filename, struct image_info *info,
97 LodePNG_Decoder *p_decoder = &decoder; 98 LodePNG_Decoder *p_decoder = &decoder;
98 99
99 unsigned char *memory, *memory_max, *image; 100 unsigned char *memory, *memory_max, *image;
100 size_t memory_size, file_size; 101 size_t memory_size;
101 102
102 /* cleanup */ 103 /* cleanup */
103 memset(&disp, 0, sizeof(disp)); 104 memset(&disp, 0, sizeof(disp));
@@ -113,7 +114,15 @@ static int load_image(char *filename, struct image_info *info,
113 rb->splashf(HZ, "err opening %s: %d", filename, fd); 114 rb->splashf(HZ, "err opening %s: %d", filename, fd);
114 return PLUGIN_ERROR; 115 return PLUGIN_ERROR;
115 } 116 }
116 file_size = rb->filesize(fd); 117
118 if (offset)
119 {
120 rb->lseek(fd, offset, SEEK_SET);
121 }
122 else
123 {
124 file_size = rb->filesize(fd);
125 }
117 126
118 DEBUGF("reading file '%s'\n", filename); 127 DEBUGF("reading file '%s'\n", filename);
119 128
@@ -122,7 +131,7 @@ static int load_image(char *filename, struct image_info *info,
122 rb->lcd_update(); 131 rb->lcd_update();
123 } 132 }
124 133
125 if (file_size > memory_size) { 134 if ((size_t)file_size > memory_size) {
126 p_decoder->error = FILE_TOO_LARGE; 135 p_decoder->error = FILE_TOO_LARGE;
127 rb->close(fd); 136 rb->close(fd);
128 137
diff --git a/apps/plugins/imageviewer/ppm/ppm.c b/apps/plugins/imageviewer/ppm/ppm.c
index 5e03f8c335..6f59b1f6b0 100644
--- a/apps/plugins/imageviewer/ppm/ppm.c
+++ b/apps/plugins/imageviewer/ppm/ppm.c
@@ -75,7 +75,8 @@ static int img_mem(int ds)
75} 75}
76 76
77static int load_image(char *filename, struct image_info *info, 77static int load_image(char *filename, struct image_info *info,
78 unsigned char *buf, ssize_t *buf_size) 78 unsigned char *buf, ssize_t *buf_size,
79 int offset, int filesize)
79{ 80{
80 int fd; 81 int fd;
81 int rc = PLUGIN_OK; 82 int rc = PLUGIN_OK;
@@ -83,7 +84,7 @@ static int load_image(char *filename, struct image_info *info,
83 int w, h; /* used to center output */ 84 int w, h; /* used to center output */
84 85
85 unsigned char *memory, *memory_max; 86 unsigned char *memory, *memory_max;
86 size_t memory_size, file_size; 87 size_t memory_size;
87 88
88 /* cleanup */ 89 /* cleanup */
89 memset(&disp, 0, sizeof(disp)); 90 memset(&disp, 0, sizeof(disp));
@@ -100,13 +101,20 @@ static int load_image(char *filename, struct image_info *info,
100 return PLUGIN_ERROR; 101 return PLUGIN_ERROR;
101 } 102 }
102 103
103 file_size = rb->filesize(fd); 104 if (offset)
105 {
106 rb->lseek(fd, offset, SEEK_SET);
107 }
108 else
109 {
110 filesize = rb->filesize(fd);
111 }
104 DEBUGF("reading file '%s'\n", filename); 112 DEBUGF("reading file '%s'\n", filename);
105 113
106 if (!iv->running_slideshow) 114 if (!iv->running_slideshow)
107 { 115 {
108 rb->lcd_puts(0, 0, rb->strrchr(filename,'/')+1); 116 rb->lcd_puts(0, 0, rb->strrchr(filename,'/')+1);
109 rb->lcd_putsf(0, 1, "loading %zu bytes", file_size); 117 rb->lcd_putsf(0, 1, "loading %zu bytes", filesize);
110 rb->lcd_update(); 118 rb->lcd_update();
111 } 119 }
112 120