rendered paste bodyIndex: apps/plugins/mpegplayer/mpegplayer.c
===================================================================
--- apps/plugins/mpegplayer/mpegplayer.c (revision 12911)
+++ apps/plugins/mpegplayer/mpegplayer.c (working copy)
@@ -103,6 +103,7 @@
#include "mpeg2dec_config.h"
#include "plugin.h"
+#include "gray.h"
#include "mpeg2.h"
#include "mpeg_settings.h"
@@ -270,8 +271,16 @@
/* Wait for video thread to stop */
while (videostatus == PLEASE_PAUSE) { rb->sleep(HZ/25); }
}
+
+#ifndef HAVE_LCD_COLOR
+ gray_show(false);
+#endif
result = mpeg_menu();
+#ifndef HAVE_LCD_COLOR
+ gray_show(true);
+#endif
+
/* The menu can change the font, so restore */
rb->lcd_setfont(FONT_SYSFIXED);
@@ -911,6 +920,10 @@
size_t file_remaining;
size_t n;
size_t disk_buf_len;
+#ifndef HAVE_LCD_COLOR
+ long graysize;
+ int grayscales;
+#endif
/* We define this here so it is on the main stack (in IRAM) */
mad_fixed_t mad_frame_overlap[2][32][18]; /* 4608 bytes */
@@ -940,13 +953,27 @@
buffer_size = audiosize - (PCMBUFFER_SIZE+AUDIOBUFFER_SIZE+LIBMPEG2BUFFER_SIZE);
DEBUGF("audiosize=%d, buffer_size=%ld\n",audiosize,buffer_size);
- buffer_size &= ~(0x7ff); /* Round buffer down to nearest 2KB */
- DEBUGF("audiosize=%d, buffer_size=%ld\n",audiosize,buffer_size);
buffer = mpeg2_malloc(buffer_size,-1);
if (buffer == NULL)
return PLUGIN_ERROR;
+#ifndef HAVE_LCD_COLOR
+ /* initialize the grayscale buffer: 32 bitplanes for 33 shades of gray. */
+ grayscales = gray_init(rb, buffer, buffer_size, false, LCD_WIDTH, LCD_HEIGHT,
+ 32, 2<<8, &graysize) + 1;
+ buffer += graysize;
+ buffer_size -= graysize;
+ if (grayscales < 33 || buffer_size <= 0)
+ {
+ rb->splash(HZ, "gray buf error");
+ return PLUGIN_ERROR;
+ }
+#endif
+
+ buffer_size &= ~(0x7ff); /* Round buffer down to nearest 2KB */
+ DEBUGF("audiosize=%d, buffer_size=%ld\n",audiosize,buffer_size);
+
mpa_buffer_size = AUDIOBUFFER_SIZE;
mpa_buffer = mpeg2_malloc(mpa_buffer_size,-2);
@@ -1026,6 +1053,10 @@
audiostatus = STREAM_BUFFERING;
videostatus = STREAM_PLAYING;
+#ifndef HAVE_LCD_COLOR
+ gray_show(true);
+#endif
+
/* We put the video thread on the second processor for multi-core targets. */
if ((videothread_id = rb->create_thread(video_thread,
(uint8_t*)video_stack,VIDEO_STACKSIZE,"mpgvideo" IF_PRIO(,PRIORITY_PLAYBACK)
@@ -1074,6 +1105,10 @@
rb->sleep(HZ/10);
}
+#ifndef HAVE_LCD_COLOR
+ gray_release();
+#endif
+
rb->remove_thread(audiothread_id);
rb->yield(); /* Is this needed? */
Index: apps/plugins/mpegplayer/video_out_rockbox.c
===================================================================
--- apps/plugins/mpegplayer/video_out_rockbox.c (revision 12900)
+++ apps/plugins/mpegplayer/video_out_rockbox.c (working copy)
@@ -24,6 +24,7 @@
#include "mpeg2dec_config.h"
#include "plugin.h"
+#include "gray.h"
extern struct plugin_api* rb;
@@ -188,6 +189,7 @@
void vo_draw_frame (uint8_t * const * buf)
{
+#ifdef HAVE_LCD_COLOR
#ifdef SIMULATOR
yuv_bitmap_part(buf,0,0,image_width,
output_x,output_y,output_width,output_height);
@@ -197,6 +199,10 @@
0,0,image_width,
output_x,output_y,output_width,output_height);
#endif
+#else
+ gray_ub_gray_bitmap_part(buf[0],0,0,image_width,
+ output_x,output_y,output_width,output_height);
+#endif
}
#if LCD_WIDTH >= LCD_HEIGHT
Index: apps/plugins/mpegplayer/Makefile
===================================================================
--- apps/plugins/mpegplayer/Makefile (revision 12900)
+++ apps/plugins/mpegplayer/Makefile (working copy)
@@ -8,7 +8,7 @@
#
INCLUDES = -I$(APPSDIR) -I.. -I. $(TARGET_INC) -I$(FIRMDIR)/include -I$(FIRMDIR)/export \
- -I$(FIRMDIR)/common -I$(FIRMDIR)/drivers -I$(OUTDIR) -I$(BUILDDIR)
+ -I$(FIRMDIR)/common -I$(FIRMDIR)/drivers -I$(APPSDIR)/plugins/lib -I$(OUTDIR) -I$(BUILDDIR)
CFLAGS = $(INCLUDES) $(GCCOPTS) -O2 $(TARGET) $(EXTRA_DEFINES) \
-DTARGET_ID=$(TARGET_ID) -DMEM=${MEMORYSIZE} -DPLUGIN
Index: apps/plugins/SUBDIRS
===================================================================
--- apps/plugins/SUBDIRS (revision 12900)
+++ apps/plugins/SUBDIRS (working copy)
@@ -32,9 +32,7 @@
#endif
/* For all the colour targets */
-#if defined(HAVE_LCD_COLOR)
mpegplayer
-#endif
#endif /* IRIVER_IFP7XX_SERIES */