summaryrefslogtreecommitdiff
path: root/apps/plugins/video.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/video.c')
-rw-r--r--apps/plugins/video.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/apps/plugins/video.c b/apps/plugins/video.c
index 5a2c28ca2b..0800745b3c 100644
--- a/apps/plugins/video.c
+++ b/apps/plugins/video.c
@@ -7,10 +7,10 @@
7* \/ \/ \/ \/ \/ 7* \/ \/ \/ \/ \/
8* $Id$ 8* $Id$
9* 9*
10* Experimental plugin for halftoning 10* Plugin for video playback
11* Reads raw image data from a file 11* Reads raw image data + audio data from a file
12* 12*
13* Copyright (C) 2003 Jörg Hohensohn [IDC]Dragon 13* Copyright (C) 2003-2004 Jörg Hohensohn aka [IDC]Dragon
14* 14*
15* All files in this archive are subject to the GNU General Public License. 15* All files in this archive are subject to the GNU General Public License.
16* See the file COPYING in the source tree root for full license agreement. 16* See the file COPYING in the source tree root for full license agreement.
@@ -20,6 +20,8 @@
20* 20*
21****************************************************************************/ 21****************************************************************************/
22#include "plugin.h" 22#include "plugin.h"
23#include "sh7034.h"
24#include "system.h"
23#include "../apps/recorder/widgets.h" /* not in search path, booh */ 25#include "../apps/recorder/widgets.h" /* not in search path, booh */
24 26
25#ifndef SIMULATOR /* not for simulator by now */ 27#ifndef SIMULATOR /* not for simulator by now */
@@ -27,9 +29,10 @@
27 29
28#define SCREENSIZE (LCD_WIDTH*LCD_HEIGHT/8) /* in bytes */ 30#define SCREENSIZE (LCD_WIDTH*LCD_HEIGHT/8) /* in bytes */
29#define FILEBUFSIZE (SCREENSIZE*4) /* must result in a multiple of 512 */ 31#define FILEBUFSIZE (SCREENSIZE*4) /* must result in a multiple of 512 */
32#define FPS 71 /* desired framerate */
33#define WIND_MAX 9 /* max FF/FR speed */
30 34
31#define WIND_MAX 9 35#define FRAMETIME (FREQ/8/FPS) /* internal timer4 value */
32
33 36
34/* globals */ 37/* globals */
35static struct plugin_api* rb; /* here is a global api struct pointer */ 38static struct plugin_api* rb; /* here is a global api struct pointer */
@@ -168,9 +171,13 @@ int show_buffer(unsigned char* p_start, int frames)
168 171
169 do 172 do
170 { 173 {
174 /* wait for frame to be due */
175 while (TCNT4 < FRAMETIME) /* use our timer 4 */
176 rb->yield(); /* yield to the other treads */
177 TCNT4 -= FRAMETIME;
178
171 rb->lcd_blit(p_current, 0, 0, LCD_WIDTH, LCD_HEIGHT/8, LCD_WIDTH); 179 rb->lcd_blit(p_current, 0, 0, LCD_WIDTH, LCD_HEIGHT/8, LCD_WIDTH);
172 180
173 rb->yield(); /* yield to the other treads */
174 shown++; 181 shown++;
175 182
176 delta = check_button(); 183 delta = check_button();
@@ -241,8 +248,10 @@ int show_file(unsigned char* p_buffer, int fd)
241 else 248 else
242 read = 0; 249 read = 0;
243 250
244 if (read < SCREENSIZE) /* below average? */ 251 /* wait for frame to be due */
245 rb->yield(); /* time to do something else */ 252 while (TCNT4 < FRAMETIME) /* use our timer 4 */
253 rb->yield(); /* yield to the other treads */
254 TCNT4 -= FRAMETIME;
246 255
247 /* display OSD if FF/FR */ 256 /* display OSD if FF/FR */
248 if (playstep != 1 && playstep != -1) 257 if (playstep != 1 && playstep != -1)
@@ -322,18 +331,28 @@ int main(char* filename)
322 if (fd < 0) 331 if (fd < 0)
323 return PLUGIN_ERROR; 332 return PLUGIN_ERROR;
324 333
334 /* init timer 4, crude code */
335 IPRD = (IPRD & 0xFF0F); // disable interrupt
336 and_b(~0x10, &TSTR); // Stop the timer 4
337 and_b(~0x10, &TSNC); // No synchronization
338 and_b(~0x10, &TMDR); // Operate normally
339 TCR4 = 0x03; // no clear at GRA match, sysclock/8
340 TCNT4 = 0; // start counting at 0
341
325 file_size = rb->filesize(fd); 342 file_size = rb->filesize(fd);
326 if (file_size <= buffer_size) 343 if (file_size <= buffer_size)
327 { /* we can read the whole file in advance */ 344 { /* we can read the whole file in advance */
328 got_now = rb->read(fd, p_buffer, file_size); 345 got_now = rb->read(fd, p_buffer, file_size);
329 rb->close(fd); 346 rb->close(fd);
330 frames = got_now / (LCD_WIDTH*LCD_HEIGHT/8); 347 frames = got_now / (LCD_WIDTH*LCD_HEIGHT/8);
348 or_b(0x10, &TSTR); // start timer 4
331 time = *rb->current_tick; 349 time = *rb->current_tick;
332 shown = show_buffer(p_buffer, frames); 350 shown = show_buffer(p_buffer, frames);
333 time = *rb->current_tick - time; 351 time = *rb->current_tick - time;
334 } 352 }
335 else 353 else
336 { /* we need to stream */ 354 { /* we need to stream */
355 or_b(0x10, &TSTR); // start timer 4
337 time = *rb->current_tick; 356 time = *rb->current_tick;
338 shown = show_file(p_buffer, fd); 357 shown = show_file(p_buffer, fd);
339 time = *rb->current_tick - time; 358 time = *rb->current_tick - time;