summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/mpegplayer/SOURCES3
-rw-r--r--apps/plugins/mpegplayer/mpeg_settings.c106
-rw-r--r--apps/plugins/mpegplayer/mpeg_settings.h3
-rw-r--r--apps/plugins/mpegplayer/video_out_rockbox.c204
4 files changed, 87 insertions, 229 deletions
diff --git a/apps/plugins/mpegplayer/SOURCES b/apps/plugins/mpegplayer/SOURCES
index e9a01b73d0..6629cf7a4c 100644
--- a/apps/plugins/mpegplayer/SOURCES
+++ b/apps/plugins/mpegplayer/SOURCES
@@ -1,14 +1,15 @@
1alloc.c 1alloc.c
2decode.c 2decode.c
3header.c 3header.c
4idct.c
5 4
6motion_comp.c 5motion_comp.c
7 6
8#ifdef CPU_ARM 7#ifdef CPU_ARM
8idct_arm_c.c
9motion_comp_arm_c.c 9motion_comp_arm_c.c
10motion_comp_arm_s.S 10motion_comp_arm_s.S
11#else /* other CPU or SIM */ 11#else /* other CPU or SIM */
12idct.c
12motion_comp_c.c 13motion_comp_c.c
13#endif /* CPU_* */ 14#endif /* CPU_* */
14 15
diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c
index 964bad08bd..28062f4567 100644
--- a/apps/plugins/mpegplayer/mpeg_settings.c
+++ b/apps/plugins/mpegplayer/mpeg_settings.c
@@ -9,41 +9,87 @@ extern struct plugin_api* rb;
9struct mpeg_settings settings; 9struct mpeg_settings settings;
10static struct mpeg_settings old_settings; 10static struct mpeg_settings old_settings;
11 11
12#define SETTINGS_VERSION 1 12#define SETTINGS_VERSION 2
13#define SETTINGS_MIN_VERSION 1 13#define SETTINGS_MIN_VERSION 1
14#define SETTINGS_FILENAME "mpegplayer.cfg" 14#define SETTINGS_FILENAME "mpegplayer.cfg"
15 15
16static char* showfps_options[] = {"No", "Yes"};
17static char* limitfps_options[] = {"No", "Yes"};
18static char* skipframes_options[] = {"No", "Yes"};
19
20static struct configdata config[] = 16static struct configdata config[] =
21{ 17{
22 {TYPE_ENUM, 0, 2, &settings.showfps, "Show FPS", showfps_options, NULL}, 18 {TYPE_ENUM, 0, 2, &settings.showfps, "Show FPS",
23 {TYPE_ENUM, 0, 2, &settings.limitfps, "Limit FPS", limitfps_options, NULL}, 19 (char *[]){ "No", "Yes" }, NULL},
24 {TYPE_ENUM, 0, 2, &settings.skipframes, "Skip frames", skipframes_options, NULL}, 20 {TYPE_ENUM, 0, 2, &settings.limitfps, "Limit FPS",
21 (char *[]){ "No", "Yes" }, NULL},
22 {TYPE_ENUM, 0, 2, &settings.skipframes, "Skip frames",
23 (char *[]){ "No", "Yes" }, NULL},
24#if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200)
25 {TYPE_INT, 0, INT_MAX, &settings.displayoptions, "Display options",
26 NULL, NULL},
27#endif
28};
29
30enum mpeg_menu_ids
31{
32 __MPEG_OPTION_START = -1,
33#if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200)
34 MPEG_OPTION_DISPLAY_SETTINGS,
35#endif
36 MPEG_OPTION_DISPLAY_FPS,
37 MPEG_OPTION_LIMIT_FPS,
38 MPEG_OPTION_SKIP_FRAMES,
39 MPEG_OPTION_QUIT,
40};
41
42static const struct opt_items noyes[2] = {
43 { "No", -1 },
44 { "Yes", -1 },
25}; 45};
26 46
47#if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200)
48static bool set_option_dithering(void)
49{
50 int val = (settings.displayoptions & LCD_YUV_DITHER) ? 1 : 0;
51 rb->set_option("Dithering", &val, INT, noyes, 2, NULL);
52 settings.displayoptions = (settings.displayoptions & ~LCD_YUV_DITHER)
53 | ((val != 0) ? LCD_YUV_DITHER : 0);
54 rb->lcd_yuv_set_options(settings.displayoptions);
55 return false;
56}
57
58static void display_options(void)
59{
60 static const struct menu_item items[] = {
61 { "Dithering", set_option_dithering },
62 };
63
64 int m = menu_init(rb, items, ARRAYLEN(items),
65 NULL, NULL, NULL, NULL);
66 menu_run(m);
67 menu_exit(m);
68}
69#endif /* #ifdef TOSHIBA_GIGABEAT_F */
70
27bool mpeg_menu(void) 71bool mpeg_menu(void)
28{ 72{
29 int m; 73 int m;
30 int result; 74 int result;
31 int menu_quit=0; 75 int menu_quit=0;
32 76
33 static const struct opt_items noyes[2] = {
34 { "No", -1 },
35 { "Yes", -1 },
36 };
37
38 static const struct menu_item items[] = { 77 static const struct menu_item items[] = {
39 { "Display FPS", NULL }, 78#if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200)
40 { "Limit FPS", NULL }, 79 [MPEG_OPTION_DISPLAY_SETTINGS] =
41 { "Skip frames", NULL }, 80 { "Display Options", NULL },
42 { "Quit mpegplayer", NULL }, 81#endif
82 [MPEG_OPTION_DISPLAY_FPS] =
83 { "Display FPS", NULL },
84 [MPEG_OPTION_LIMIT_FPS] =
85 { "Limit FPS", NULL },
86 [MPEG_OPTION_SKIP_FRAMES] =
87 { "Skip frames", NULL },
88 [MPEG_OPTION_QUIT] =
89 { "Quit mpegplayer", NULL },
43 }; 90 };
44 91
45 m = menu_init(rb, items, sizeof(items) / sizeof(*items), 92 m = menu_init(rb, items, ARRAYLEN(items), NULL, NULL, NULL, NULL);
46 NULL, NULL, NULL, NULL);
47 93
48 rb->button_clear_queue(); 94 rb->button_clear_queue();
49 95
@@ -52,22 +98,28 @@ bool mpeg_menu(void)
52 98
53 switch(result) 99 switch(result)
54 { 100 {
55 case 0: /* Show FPS */ 101#if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200)
102 case MPEG_OPTION_DISPLAY_SETTINGS:
103 display_options();
104 break;
105#endif
106 case MPEG_OPTION_DISPLAY_FPS:
56 rb->set_option("Display FPS",&settings.showfps,INT, 107 rb->set_option("Display FPS",&settings.showfps,INT,
57 noyes, 2, NULL); 108 noyes, 2, NULL);
58 break; 109 break;
59 case 1: /* Limit FPS */ 110 case MPEG_OPTION_LIMIT_FPS:
60 rb->set_option("Limit FPS",&settings.limitfps,INT, 111 rb->set_option("Limit FPS",&settings.limitfps,INT,
61 noyes, 2, NULL); 112 noyes, 2, NULL);
62 break; 113 break;
63 case 2: /* Skip frames */ 114 case MPEG_OPTION_SKIP_FRAMES:
64 rb->set_option("Skip frames",&settings.skipframes,INT, 115 rb->set_option("Skip frames",&settings.skipframes,INT,
65 noyes, 2, NULL); 116 noyes, 2, NULL);
66 break; 117 break;
118 case MPEG_OPTION_QUIT:
67 default: 119 default:
68 menu_quit=1; 120 menu_quit=1;
69 if (result == MENU_ATTACHED_USB) 121 if (result == MENU_ATTACHED_USB)
70 result = 3; 122 result = MPEG_OPTION_QUIT;
71 break; 123 break;
72 } 124 }
73 } 125 }
@@ -77,7 +129,7 @@ bool mpeg_menu(void)
77 rb->lcd_clear_display(); 129 rb->lcd_clear_display();
78 rb->lcd_update(); 130 rb->lcd_update();
79 131
80 return (result==3); 132 return (result==MPEG_OPTION_QUIT);
81} 133}
82 134
83 135
@@ -87,6 +139,9 @@ void init_settings(void)
87 settings.showfps = 0; /* Do not show FPS */ 139 settings.showfps = 0; /* Do not show FPS */
88 settings.limitfps = 1; /* Limit FPS */ 140 settings.limitfps = 1; /* Limit FPS */
89 settings.skipframes = 1; /* Skip frames */ 141 settings.skipframes = 1; /* Skip frames */
142#if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200)
143 settings.displayoptions = 0; /* No visual effects */
144#endif
90 145
91 configfile_init(rb); 146 configfile_init(rb);
92 147
@@ -105,6 +160,9 @@ void init_settings(void)
105 /* Keep a copy of the saved version of the settings - so we can check if 160 /* Keep a copy of the saved version of the settings - so we can check if
106 the settings have changed when we quit */ 161 the settings have changed when we quit */
107 old_settings = settings; 162 old_settings = settings;
163#if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200)
164 rb->lcd_yuv_set_options(settings.displayoptions);
165#endif
108} 166}
109 167
110void save_settings(void) 168void save_settings(void)
diff --git a/apps/plugins/mpegplayer/mpeg_settings.h b/apps/plugins/mpegplayer/mpeg_settings.h
index cd2dcd2343..7721c46f64 100644
--- a/apps/plugins/mpegplayer/mpeg_settings.h
+++ b/apps/plugins/mpegplayer/mpeg_settings.h
@@ -5,6 +5,9 @@ struct mpeg_settings {
5 int showfps; 5 int showfps;
6 int limitfps; 6 int limitfps;
7 int skipframes; 7 int skipframes;
8#if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200)
9 unsigned displayoptions;
10#endif
8}; 11};
9 12
10extern struct mpeg_settings settings; 13extern struct mpeg_settings settings;
diff --git a/apps/plugins/mpegplayer/video_out_rockbox.c b/apps/plugins/mpegplayer/video_out_rockbox.c
index b57f77bc0a..2aac0b8039 100644
--- a/apps/plugins/mpegplayer/video_out_rockbox.c
+++ b/apps/plugins/mpegplayer/video_out_rockbox.c
@@ -40,216 +40,12 @@ static int output_y;
40static int output_width; 40static int output_width;
41static int output_height; 41static int output_height;
42 42
43#if defined(SIMULATOR) && defined(HAVE_LCD_COLOR)
44
45/**
46 * |R| |1.000000 -0.000001 1.402000| |Y'|
47 * |G| = |1.000000 -0.334136 -0.714136| |Pb|
48 * |B| |1.000000 1.772000 0.000000| |Pr|
49 * Scaled, normalized, rounded and tweaked to yield RGB 565:
50 * |R| |74 0 101| |Y' - 16| >> 9
51 * |G| = |74 -24 -51| |Cb - 128| >> 8
52 * |B| |74 128 0| |Cr - 128| >> 9
53 */
54#define YFAC (74)
55#define RVFAC (101)
56#define GUFAC (-24)
57#define GVFAC (-51)
58#define BUFAC (128)
59
60static inline int clamp(int val, int min, int max)
61{
62 if (val < min)
63 val = min;
64 else if (val > max)
65 val = max;
66 return val;
67}
68
69/* Draw a partial YUV colour bitmap - similiar behavior to lcd_yuv_blit
70 in the core */
71static void yuv_bitmap_part(unsigned char * const src[3],
72 int src_x, int src_y, int stride,
73 int x, int y, int width, int height)
74{
75 const unsigned char *ysrc, *usrc, *vsrc;
76 fb_data *dst, *row_end;
77 off_t z;
78
79 /* width and height must be >= 2 and an even number */
80 width &= ~1;
81 height >>= 1;
82
83#if LCD_WIDTH >= LCD_HEIGHT
84 dst = rb->lcd_framebuffer + LCD_WIDTH * y + x;
85 row_end = dst + width;
86#else
87 dst = rb->lcd_framebuffer + x * LCD_WIDTH + (LCD_WIDTH - y) - 1;
88 row_end = dst + LCD_WIDTH * width;
89#endif
90
91 z = stride * src_y;
92 ysrc = src[0] + z + src_x;
93 usrc = src[1] + (z >> 2) + (src_x >> 1);
94 vsrc = src[2] + (usrc - src[1]);
95
96 /* stride => amount to jump from end of last row to start of next */
97 stride -= width;
98
99 /* upsampling, YUV->RGB conversion and reduction to RGB565 in one go */
100
101 do
102 {
103 do
104 {
105 int y, cb, cr, rv, guv, bu, r, g, b;
106
107 y = YFAC*(*ysrc++ - 16);
108 cb = *usrc++ - 128;
109 cr = *vsrc++ - 128;
110
111 rv = RVFAC*cr;
112 guv = GUFAC*cb + GVFAC*cr;
113 bu = BUFAC*cb;
114
115 r = y + rv;
116 g = y + guv;
117 b = y + bu;
118
119 if ((unsigned)(r | g | b) > 64*256-1)
120 {
121 r = clamp(r, 0, 64*256-1);
122 g = clamp(g, 0, 64*256-1);
123 b = clamp(b, 0, 64*256-1);
124 }
125
126 *dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9);
127
128#if LCD_WIDTH >= LCD_HEIGHT
129 dst++;
130#else
131 dst += LCD_WIDTH;
132#endif
133
134 y = YFAC*(*ysrc++ - 16);
135 r = y + rv;
136 g = y + guv;
137 b = y + bu;
138
139 if ((unsigned)(r | g | b) > 64*256-1)
140 {
141 r = clamp(r, 0, 64*256-1);
142 g = clamp(g, 0, 64*256-1);
143 b = clamp(b, 0, 64*256-1);
144 }
145
146 *dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9);
147
148#if LCD_WIDTH >= LCD_HEIGHT
149 dst++;
150#else
151 dst += LCD_WIDTH;
152#endif
153 }
154 while (dst < row_end);
155
156 ysrc += stride;
157 usrc -= width >> 1;
158 vsrc -= width >> 1;
159
160#if LCD_WIDTH >= LCD_HEIGHT
161 row_end += LCD_WIDTH;
162 dst += LCD_WIDTH - width;
163#else
164 row_end -= 1;
165 dst -= LCD_WIDTH*width + 1;
166#endif
167
168 do
169 {
170 int y, cb, cr, rv, guv, bu, r, g, b;
171
172 y = YFAC*(*ysrc++ - 16);
173 cb = *usrc++ - 128;
174 cr = *vsrc++ - 128;
175
176 rv = RVFAC*cr;
177 guv = GUFAC*cb + GVFAC*cr;
178 bu = BUFAC*cb;
179
180 r = y + rv;
181 g = y + guv;
182 b = y + bu;
183
184 if ((unsigned)(r | g | b) > 64*256-1)
185 {
186 r = clamp(r, 0, 64*256-1);
187 g = clamp(g, 0, 64*256-1);
188 b = clamp(b, 0, 64*256-1);
189 }
190
191 *dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9);
192
193#if LCD_WIDTH >= LCD_HEIGHT
194 dst++;
195#else
196 dst += LCD_WIDTH;
197#endif
198
199 y = YFAC*(*ysrc++ - 16);
200 r = y + rv;
201 g = y + guv;
202 b = y + bu;
203
204 if ((unsigned)(r | g | b) > 64*256-1)
205 {
206 r = clamp(r, 0, 64*256-1);
207 g = clamp(g, 0, 64*256-1);
208 b = clamp(b, 0, 64*256-1);
209 }
210
211 *dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9);
212
213#if LCD_WIDTH >= LCD_HEIGHT
214 dst++;
215#else
216 dst += LCD_WIDTH;
217#endif
218 }
219 while (dst < row_end);
220
221 ysrc += stride;
222 usrc += stride >> 1;
223 vsrc += stride >> 1;
224
225#if LCD_WIDTH >= LCD_HEIGHT
226 row_end += LCD_WIDTH;
227 dst += LCD_WIDTH - width;
228#else
229 row_end -= 1;
230 dst -= LCD_WIDTH*width + 1;
231#endif
232 }
233 while (--height > 0);
234}
235#endif /* defined(SIMULATOR) && defined(HAVE_LCD_COLOR) */
236
237void vo_draw_frame (uint8_t * const * buf) 43void vo_draw_frame (uint8_t * const * buf)
238{ 44{
239#ifdef HAVE_LCD_COLOR 45#ifdef HAVE_LCD_COLOR
240#ifdef SIMULATOR
241 yuv_bitmap_part(buf,0,0,image_width,
242 output_x,output_y,output_width,output_height);
243#if LCD_WIDTH >= LCD_HEIGHT
244 rb->lcd_update_rect(output_x,output_y,output_width,output_height);
245#else
246 rb->lcd_update_rect(output_y,output_x,output_height,output_width);
247#endif
248#else
249 rb->lcd_yuv_blit(buf, 46 rb->lcd_yuv_blit(buf,
250 0,0,image_width, 47 0,0,image_width,
251 output_x,output_y,output_width,output_height); 48 output_x,output_y,output_width,output_height);
252#endif
253#else 49#else
254 gray_ub_gray_bitmap_part(buf[0],0,0,image_width, 50 gray_ub_gray_bitmap_part(buf[0],0,0,image_width,
255 output_x,output_y,output_width,output_height); 51 output_x,output_y,output_width,output_height);