diff options
-rw-r--r-- | apps/plugins/mpegplayer/mpegplayer.c | 84 | ||||
-rw-r--r-- | apps/plugins/mpegplayer/video_out.h | 38 | ||||
-rw-r--r-- | apps/plugins/mpegplayer/video_out_rockbox.c | 69 |
3 files changed, 23 insertions, 168 deletions
diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c index 577d9c6512..be028c01f8 100644 --- a/apps/plugins/mpegplayer/mpegplayer.c +++ b/apps/plugins/mpegplayer/mpegplayer.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * mpegplayer.c - based on mpeg2dec.c | 2 | * mpegplayer.c - based on mpeg2dec.c |
3 | * | 3 | * |
4 | * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org> | 4 | * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org> |
@@ -45,11 +45,8 @@ struct plugin_api* rb; | |||
45 | #define BUFFER_SIZE (MEM-6)*1024*1024 | 45 | #define BUFFER_SIZE (MEM-6)*1024*1024 |
46 | 46 | ||
47 | static mpeg2dec_t * mpeg2dec; | 47 | static mpeg2dec_t * mpeg2dec; |
48 | static vo_open_t * output_open = NULL; | ||
49 | static vo_instance_t * output; | ||
50 | static int total_offset = 0; | 48 | static int total_offset = 0; |
51 | 49 | ||
52 | extern vo_open_t vo_rockbox_open; | ||
53 | /* button definitions */ | 50 | /* button definitions */ |
54 | #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) | 51 | #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) |
55 | #define MPEG_STOP BUTTON_OFF | 52 | #define MPEG_STOP BUTTON_OFF |
@@ -106,7 +103,6 @@ static bool decode_mpeg2 (uint8_t * current, uint8_t * end) | |||
106 | { | 103 | { |
107 | const mpeg2_info_t * info; | 104 | const mpeg2_info_t * info; |
108 | mpeg2_state_t state; | 105 | mpeg2_state_t state; |
109 | vo_setup_result_t setup_result; | ||
110 | 106 | ||
111 | mpeg2_buffer (mpeg2dec, current, end); | 107 | mpeg2_buffer (mpeg2dec, current, end); |
112 | total_offset += end - current; | 108 | total_offset += end - current; |
@@ -121,70 +117,20 @@ static bool decode_mpeg2 (uint8_t * current, uint8_t * end) | |||
121 | case STATE_BUFFER: | 117 | case STATE_BUFFER: |
122 | return false; | 118 | return false; |
123 | case STATE_SEQUENCE: | 119 | case STATE_SEQUENCE: |
124 | /* might set nb fbuf, convert format, stride */ | 120 | vo_setup(info->sequence->width, |
125 | /* might set fbufs */ | 121 | info->sequence->height, |
126 | if (output->setup (output, info->sequence->width, | 122 | info->sequence->chroma_width, |
127 | info->sequence->height, | 123 | info->sequence->chroma_height); |
128 | info->sequence->chroma_width, | 124 | mpeg2_skip (mpeg2dec, false); |
129 | info->sequence->chroma_height, &setup_result)) { | ||
130 | //fprintf (stderr, "display setup failed\n"); | ||
131 | return false; | ||
132 | } | ||
133 | if (setup_result.convert && | ||
134 | mpeg2_convert (mpeg2dec, setup_result.convert, NULL)) { | ||
135 | //fprintf (stderr, "color conversion setup failed\n"); | ||
136 | return false; | ||
137 | } | ||
138 | if (output->set_fbuf) { | ||
139 | uint8_t * buf[3]; | ||
140 | void * id; | ||
141 | |||
142 | mpeg2_custom_fbuf (mpeg2dec, 1); | ||
143 | output->set_fbuf (output, buf, &id); | ||
144 | mpeg2_set_buf (mpeg2dec, buf, id); | ||
145 | output->set_fbuf (output, buf, &id); | ||
146 | mpeg2_set_buf (mpeg2dec, buf, id); | ||
147 | } else if (output->setup_fbuf) { | ||
148 | uint8_t * buf[3]; | ||
149 | void * id; | ||
150 | |||
151 | output->setup_fbuf (output, buf, &id); | ||
152 | mpeg2_set_buf (mpeg2dec, buf, id); | ||
153 | output->setup_fbuf (output, buf, &id); | ||
154 | mpeg2_set_buf (mpeg2dec, buf, id); | ||
155 | output->setup_fbuf (output, buf, &id); | ||
156 | mpeg2_set_buf (mpeg2dec, buf, id); | ||
157 | } | ||
158 | mpeg2_skip (mpeg2dec, (output->draw == NULL)); | ||
159 | break; | 125 | break; |
160 | case STATE_PICTURE: | 126 | case STATE_PICTURE: |
161 | /* might skip */ | ||
162 | /* might set fbuf */ | ||
163 | if (output->set_fbuf) { | ||
164 | uint8_t * buf[3]; | ||
165 | void * id; | ||
166 | |||
167 | output->set_fbuf (output, buf, &id); | ||
168 | mpeg2_set_buf (mpeg2dec, buf, id); | ||
169 | } | ||
170 | if (output->start_fbuf) | ||
171 | output->start_fbuf (output, info->current_fbuf->buf, | ||
172 | info->current_fbuf->id); | ||
173 | break; | 127 | break; |
174 | case STATE_SLICE: | 128 | case STATE_SLICE: |
175 | case STATE_END: | 129 | case STATE_END: |
176 | case STATE_INVALID_END: | 130 | case STATE_INVALID_END: |
177 | /* draw current picture */ | 131 | /* draw current picture */ |
178 | /* might free frame buffer */ | 132 | if (info->display_fbuf) |
179 | if (info->display_fbuf) { | 133 | vo_draw_frame(info->display_fbuf->buf); |
180 | if (output->draw) | ||
181 | output->draw (output, info->display_fbuf->buf, | ||
182 | info->display_fbuf->id); | ||
183 | //print_fps (0); | ||
184 | } | ||
185 | if (output->discard && info->discard_fbuf) | ||
186 | output->discard (output, info->discard_fbuf->buf, | ||
187 | info->discard_fbuf->id); | ||
188 | break; | 134 | break; |
189 | default: | 135 | default: |
190 | break; | 136 | break; |
@@ -256,20 +202,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
256 | return PLUGIN_ERROR; | 202 | return PLUGIN_ERROR; |
257 | } | 203 | } |
258 | 204 | ||
259 | output_open = vo_rockbox_open; | ||
260 | |||
261 | if (output_open == NULL) { | ||
262 | //fprintf (stderr, "output_open is NULL\n"); | ||
263 | return PLUGIN_ERROR; | ||
264 | } | ||
265 | |||
266 | output = output_open (); | ||
267 | |||
268 | if (output == NULL) { | ||
269 | //fprintf (stderr, "Can not open output\n"); | ||
270 | return PLUGIN_ERROR; | ||
271 | } | ||
272 | |||
273 | mpeg2dec = mpeg2_init (); | 205 | mpeg2dec = mpeg2_init (); |
274 | 206 | ||
275 | if (mpeg2dec == NULL) | 207 | if (mpeg2dec == NULL) |
diff --git a/apps/plugins/mpegplayer/video_out.h b/apps/plugins/mpegplayer/video_out.h index 342c551972..e29d0d775d 100644 --- a/apps/plugins/mpegplayer/video_out.h +++ b/apps/plugins/mpegplayer/video_out.h | |||
@@ -21,38 +21,6 @@ | |||
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 | */ | 22 | */ |
23 | 23 | ||
24 | struct mpeg2_sequence_s; | 24 | void vo_draw_frame (uint8_t * const * buf); |
25 | struct mpeg2_convert_init_s; | 25 | void vo_setup (unsigned int width, unsigned int height, |
26 | typedef struct { | 26 | unsigned int chroma_width, unsigned int chroma_height); |
27 | int (* convert) (int stage, void * id, | ||
28 | const struct mpeg2_sequence_s * sequence, | ||
29 | int stride, uint32_t accel, void * arg, | ||
30 | struct mpeg2_convert_init_s * result); | ||
31 | } vo_setup_result_t; | ||
32 | |||
33 | typedef struct vo_instance_s vo_instance_t; | ||
34 | struct vo_instance_s { | ||
35 | int (* setup) (vo_instance_t * instance, unsigned int width, | ||
36 | unsigned int height, unsigned int chroma_width, | ||
37 | unsigned int chroma_height, vo_setup_result_t * result); | ||
38 | void (* setup_fbuf) (vo_instance_t * instance, uint8_t ** buf, void ** id); | ||
39 | void (* set_fbuf) (vo_instance_t * instance, uint8_t ** buf, void ** id); | ||
40 | void (* start_fbuf) (vo_instance_t * instance, | ||
41 | uint8_t * const * buf, void * id); | ||
42 | void (* draw) (vo_instance_t * instance, uint8_t * const * buf, void * id); | ||
43 | void (* discard) (vo_instance_t * instance, | ||
44 | uint8_t * const * buf, void * id); | ||
45 | void (* close) (vo_instance_t * instance); | ||
46 | }; | ||
47 | |||
48 | typedef vo_instance_t * vo_open_t (void); | ||
49 | |||
50 | typedef struct { | ||
51 | char * name; | ||
52 | vo_open_t * open; | ||
53 | } vo_driver_t; | ||
54 | |||
55 | void vo_accel (uint32_t accel); | ||
56 | |||
57 | /* return NULL terminated array of all drivers */ | ||
58 | vo_driver_t const * vo_drivers (void); | ||
diff --git a/apps/plugins/mpegplayer/video_out_rockbox.c b/apps/plugins/mpegplayer/video_out_rockbox.c index 7bce6aadaa..258416fcdd 100644 --- a/apps/plugins/mpegplayer/video_out_rockbox.c +++ b/apps/plugins/mpegplayer/video_out_rockbox.c | |||
@@ -45,8 +45,7 @@ static int output_y; | |||
45 | static int output_width; | 45 | static int output_width; |
46 | static int output_height; | 46 | static int output_height; |
47 | 47 | ||
48 | #if (LCD_DEPTH == 16) && \ | 48 | #ifdef SIMULATOR |
49 | ((LCD_PIXELFORMAT == RGB565) || (LCD_PIXELFORMAT == RGB565SWAPPED)) | ||
50 | 49 | ||
51 | #define RYFAC (31*257) | 50 | #define RYFAC (31*257) |
52 | #define GYFAC (63*257) | 51 | #define GYFAC (63*257) |
@@ -59,9 +58,9 @@ static int output_height; | |||
59 | #define ROUNDOFFS (127*257) | 58 | #define ROUNDOFFS (127*257) |
60 | 59 | ||
61 | /* Draw a partial YUV colour bitmap - taken from the Rockbox JPEG viewer */ | 60 | /* Draw a partial YUV colour bitmap - taken from the Rockbox JPEG viewer */ |
62 | void yuv_bitmap_part(unsigned char * const src[3], | 61 | static void yuv_bitmap_part(unsigned char * const src[3], |
63 | int src_x, int src_y, int stride, | 62 | int src_x, int src_y, int stride, |
64 | int x, int y, int width, int height) | 63 | int x, int y, int width, int height) |
65 | { | 64 | { |
66 | fb_data *dst, *dst_end; | 65 | fb_data *dst, *dst_end; |
67 | 66 | ||
@@ -190,25 +189,20 @@ void yuv_bitmap_part(unsigned char * const src[3], | |||
190 | } | 189 | } |
191 | #endif | 190 | #endif |
192 | 191 | ||
193 | static void rockbox_draw_frame (vo_instance_t * instance, | 192 | void vo_draw_frame (uint8_t * const * buf) |
194 | uint8_t * const * buf, void * id) | ||
195 | { | 193 | { |
196 | char str[80]; | 194 | char str[80]; |
197 | static int frame=0; | 195 | static int frame=0; |
198 | int ticks,fps; | 196 | int ticks,fps; |
199 | 197 | ||
200 | (void)id; | 198 | #ifdef SIMULATOR |
201 | (void)instance; | ||
202 | |||
203 | #if defined(HAVE_LCD_COLOR) && !defined(SIMULATOR) | ||
204 | rb->lcd_yuv_blit(buf, | ||
205 | 0,0,image_width, | ||
206 | output_x,output_y,output_width,output_height); | ||
207 | #elif (LCD_DEPTH == 16) && \ | ||
208 | ((LCD_PIXELFORMAT == RGB565) || (LCD_PIXELFORMAT == RGB565SWAPPED)) | ||
209 | yuv_bitmap_part(buf,0,0,image_width, | 199 | yuv_bitmap_part(buf,0,0,image_width, |
210 | output_x,output_y,output_width,output_height); | 200 | output_x,output_y,output_width,output_height); |
211 | rb->lcd_update_rect(output_x,output_y,output_width,output_height); | 201 | rb->lcd_update_rect(output_x,output_y,output_width,output_height); |
202 | #else | ||
203 | rb->lcd_yuv_blit(buf, | ||
204 | 0,0,image_width, | ||
205 | output_x,output_y,output_width,output_height); | ||
212 | #endif | 206 | #endif |
213 | 207 | ||
214 | if (starttick==0) { | 208 | if (starttick==0) { |
@@ -230,41 +224,9 @@ static void rockbox_draw_frame (vo_instance_t * instance, | |||
230 | frame++; | 224 | frame++; |
231 | } | 225 | } |
232 | 226 | ||
233 | vo_instance_t static_instance; | 227 | void vo_setup(unsigned int width, unsigned int height, |
234 | 228 | unsigned int chroma_width, unsigned int chroma_height) | |
235 | static vo_instance_t * internal_open (int setup (vo_instance_t *, unsigned int, | ||
236 | unsigned int, unsigned int, | ||
237 | unsigned int, | ||
238 | vo_setup_result_t *), | ||
239 | void draw (vo_instance_t *, | ||
240 | uint8_t * const *, void *)) | ||
241 | { | ||
242 | vo_instance_t * instance; | ||
243 | |||
244 | instance = (vo_instance_t *) &static_instance; | ||
245 | if (instance == NULL) | ||
246 | return NULL; | ||
247 | |||
248 | instance->setup = setup; | ||
249 | instance->setup_fbuf = NULL; | ||
250 | instance->set_fbuf = NULL; | ||
251 | instance->start_fbuf = NULL; | ||
252 | instance->draw = draw; | ||
253 | instance->discard = NULL; | ||
254 | //instance->close = (void (*) (vo_instance_t *)) free; | ||
255 | |||
256 | return instance; | ||
257 | } | ||
258 | |||
259 | static int rockbox_setup (vo_instance_t * instance, unsigned int width, | ||
260 | unsigned int height, unsigned int chroma_width, | ||
261 | unsigned int chroma_height, | ||
262 | vo_setup_result_t * result) | ||
263 | { | 229 | { |
264 | (void)instance; | ||
265 | |||
266 | result->convert = NULL; | ||
267 | |||
268 | image_width=width; | 230 | image_width=width; |
269 | image_height=height; | 231 | image_height=height; |
270 | image_chroma_x=image_width/chroma_width; | 232 | image_chroma_x=image_width/chroma_width; |
@@ -285,11 +247,4 @@ static int rockbox_setup (vo_instance_t * instance, unsigned int width, | |||
285 | output_height = image_height; | 247 | output_height = image_height; |
286 | output_y = (LCD_HEIGHT-image_height)/2; | 248 | output_y = (LCD_HEIGHT-image_height)/2; |
287 | } | 249 | } |
288 | |||
289 | return 0; | ||
290 | } | ||
291 | |||
292 | vo_instance_t * vo_rockbox_open (void) | ||
293 | { | ||
294 | return internal_open (rockbox_setup, rockbox_draw_frame); | ||
295 | } | 250 | } |