summaryrefslogtreecommitdiff
path: root/apps/plugins/mpegplayer/mpegplayer.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-01-03 16:41:19 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-01-03 16:41:19 +0000
commitb664f62e36b5f0ac296567e423816dab3811075d (patch)
tree7ca49c59d7332d7c1e51139efa12466b6730e511 /apps/plugins/mpegplayer/mpegplayer.c
parentf8fde296a63dd06efef5cf71c9fdb2c26c5a3fd6 (diff)
downloadrockbox-b664f62e36b5f0ac296567e423816dab3811075d.tar.gz
rockbox-b664f62e36b5f0ac296567e423816dab3811075d.zip
MPEGPlayer graphics mutation: Implement a more visible FPS display and remove the debugging info from it. Tweak thumbnailing and printing of unavailable frames.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28960 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/mpegplayer/mpegplayer.c')
-rw-r--r--apps/plugins/mpegplayer/mpegplayer.c130
1 files changed, 125 insertions, 5 deletions
diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c
index d21907f607..5ea17f9a3e 100644
--- a/apps/plugins/mpegplayer/mpegplayer.c
+++ b/apps/plugins/mpegplayer/mpegplayer.c
@@ -380,6 +380,7 @@ CONFIG_KEYPAD == SANSA_M200_PAD
380 /* 3% of 30min file == 54s step size */ 380 /* 3% of 30min file == 54s step size */
381#define MIN_FF_REWIND_STEP (TS_SECOND/2) 381#define MIN_FF_REWIND_STEP (TS_SECOND/2)
382#define OSD_MIN_UPDATE_INTERVAL (HZ/2) 382#define OSD_MIN_UPDATE_INTERVAL (HZ/2)
383#define FPS_UPDATE_INTERVAL (HZ) /* Get new FPS reading each second */
383 384
384enum video_action 385enum video_action
385{ 386{
@@ -457,9 +458,25 @@ struct osd
457 uint32_t curr_time; 458 uint32_t curr_time;
458 unsigned auto_refresh; 459 unsigned auto_refresh;
459 unsigned flags; 460 unsigned flags;
461 int font;
462};
463
464struct fps
465{
466 /* FPS Display */
467 struct vo_rect rect; /* OSD coordinates */
468 int pf_x; /* Screen coordinates */
469 int pf_y;
470 int pf_width;
471 int pf_height;
472 long update_tick; /* When to next update FPS reading */
473 #define FPS_FORMAT "%d.%02d"
474 #define FPS_DIMSTR "999.99" /* For establishing rect size */
475 #define FPS_BUFSIZE sizeof("999.99")
460}; 476};
461 477
462static struct osd osd; 478static struct osd osd;
479static struct fps fps NOCACHEBSS_ATTR; /* Accessed on other processor */
463 480
464static void osd_show(unsigned show); 481static void osd_show(unsigned show);
465 482
@@ -573,6 +590,12 @@ static void draw_scrollbar_draw_rect(const struct vo_rect *rc, int min,
573 min, max, val); 590 min, max, val);
574} 591}
575 592
593static void draw_setfont(int font)
594{
595 osd.font = font;
596 mylcd_setfont(font);
597}
598
576#ifdef LCD_PORTRAIT 599#ifdef LCD_PORTRAIT
577/* Portrait displays need rotated text rendering */ 600/* Portrait displays need rotated text rendering */
578 601
@@ -646,7 +669,7 @@ static void draw_putsxy_oriented(int x, int y, const char *str)
646 unsigned short ch; 669 unsigned short ch;
647 unsigned short *ucs; 670 unsigned short *ucs;
648 int ofs = MIN(x, 0); 671 int ofs = MIN(x, 0);
649 struct font* pf = rb->font_get(FONT_UI); 672 struct font* pf = rb->font_get(osd.font);
650 673
651 ucs = rb->bidi_l2v(str, 1); 674 ucs = rb->bidi_l2v(str, 1);
652 675
@@ -696,6 +719,96 @@ static void draw_putsxy_oriented(int x, int y, const char *str)
696} 719}
697#endif /* LCD_PORTRAIT */ 720#endif /* LCD_PORTRAIT */
698 721
722/** FPS Display **/
723
724/* Post-frame callback (on video thread) - update the FPS rectangle from the
725 * framebuffer */
726static void fps_post_frame_callback(void)
727{
728 vo_lock();
729 mylcd_update_rect(fps.pf_x, fps.pf_y,
730 fps.pf_width, fps.pf_height);
731 vo_unlock();
732}
733
734/* Set up to have the callback only update the intersection of the video
735 * rectangle and the FPS text rectangle - if they don't intersect, then
736 * the callback is set to NULL */
737static void fps_update_post_frame_callback(void)
738{
739 void (*cb)(void) = NULL;
740
741 if (settings.showfps) {
742 struct vo_rect cliprect;
743
744 if (stream_vo_get_clip(&cliprect)) {
745 /* Oriented screen coordinates -> OSD coordinates */
746 vo_rect_offset(&cliprect, -osd.x, -osd.y);
747
748 if (vo_rect_intersect(&cliprect, &cliprect, &fps.rect)) {
749 int x = cliprect.l;
750 int y = cliprect.t;
751 int width = cliprect.r - cliprect.l;
752 int height = cliprect.b - cliprect.t;
753
754 /* OSD coordinates -> framebuffer coordinates */
755 fps.pf_x = _X;
756 fps.pf_y = _Y;
757 fps.pf_width = _W;
758 fps.pf_height = _H;
759
760 cb = fps_post_frame_callback;
761 }
762 }
763 }
764
765 stream_set_callback(VIDEO_SET_POST_FRAME_CALLBACK, cb);
766}
767
768/* Refresh the FPS display */
769static void fps_refresh(void)
770{
771 char str[FPS_BUFSIZE];
772 struct video_output_stats stats;
773 int w, h, sw;
774 long tick;
775
776 tick = *rb->current_tick;
777
778 if (TIME_BEFORE(tick, fps.update_tick))
779 return;
780
781 fps.update_tick = tick + FPS_UPDATE_INTERVAL;
782
783 stream_video_stats(&stats);
784
785 rb->snprintf(str, FPS_BUFSIZE, FPS_FORMAT,
786 stats.fps / 100, stats.fps % 100);
787
788 w = fps.rect.r - fps.rect.l;
789 h = fps.rect.b - fps.rect.t;
790
791 draw_clear_area(fps.rect.l, fps.rect.t, w, h);
792 mylcd_getstringsize(str, &sw, NULL);
793 draw_putsxy_oriented(fps.rect.r - sw, fps.rect.t, str);
794
795 vo_lock();
796 draw_update_rect(fps.rect.l, fps.rect.t, w, h);
797 vo_unlock();
798}
799
800/* Initialize the FPS display */
801static void fps_init(void)
802{
803 fps.update_tick = *rb->current_tick;
804 fps.rect.l = fps.rect.t = 0;
805 mylcd_getstringsize(FPS_DIMSTR, &fps.rect.r, &fps.rect.b);
806 vo_rect_offset(&fps.rect, -osd.x, -osd.y);
807 fps_update_post_frame_callback();
808}
809
810/** OSD **/
811
699#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) 812#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
700/* So we can refresh the overlay */ 813/* So we can refresh the overlay */
701static void osd_lcd_enable_hook(void* param) 814static void osd_lcd_enable_hook(void* param)
@@ -743,7 +856,7 @@ static void osd_text_init(void)
743 int phys; 856 int phys;
744 int spc_width; 857 int spc_width;
745 858
746 mylcd_setfont(FONT_UI); 859 draw_setfont(FONT_UI);
747 860
748 osd.x = 0; 861 osd.x = 0;
749 osd.width = SCREEN_WIDTH; 862 osd.width = SCREEN_WIDTH;
@@ -812,7 +925,7 @@ static void osd_text_init(void)
812#endif 925#endif
813 osd.y = SCREEN_HEIGHT - osd.height; 926 osd.y = SCREEN_HEIGHT - osd.height;
814 927
815 mylcd_setfont(FONT_SYSFIXED); 928 draw_setfont(FONT_SYSFIXED);
816} 929}
817 930
818static void osd_init(void) 931static void osd_init(void)
@@ -835,6 +948,7 @@ static void osd_init(void)
835 osd.auto_refresh = OSD_REFRESH_TIME; 948 osd.auto_refresh = OSD_REFRESH_TIME;
836 osd.next_auto_refresh = *rb->current_tick; 949 osd.next_auto_refresh = *rb->current_tick;
837 osd_text_init(); 950 osd_text_init();
951 fps_init();
838} 952}
839 953
840#ifdef HAVE_HEADPHONE_DETECTION 954#ifdef HAVE_HEADPHONE_DETECTION
@@ -1047,6 +1161,9 @@ static void osd_refresh(int hint)
1047 1161
1048 tick = *rb->current_tick; 1162 tick = *rb->current_tick;
1049 1163
1164 if (settings.showfps)
1165 fps_refresh();
1166
1050 if (hint == OSD_REFRESH_DEFAULT) { 1167 if (hint == OSD_REFRESH_DEFAULT) {
1051 /* The default which forces no updates */ 1168 /* The default which forces no updates */
1052 1169
@@ -1116,7 +1233,7 @@ static void osd_refresh(int hint)
1116 oldfg = mylcd_get_foreground(); 1233 oldfg = mylcd_get_foreground();
1117 oldbg = mylcd_get_background(); 1234 oldbg = mylcd_get_background();
1118 1235
1119 mylcd_setfont(FONT_UI); 1236 draw_setfont(FONT_UI);
1120 mylcd_set_foreground(osd.fgcolor); 1237 mylcd_set_foreground(osd.fgcolor);
1121 mylcd_set_background(osd.bgcolor); 1238 mylcd_set_background(osd.bgcolor);
1122 1239
@@ -1140,7 +1257,7 @@ static void osd_refresh(int hint)
1140 } 1257 }
1141 1258
1142 /* Go back to defaults */ 1259 /* Go back to defaults */
1143 mylcd_setfont(FONT_SYSFIXED); 1260 draw_setfont(FONT_SYSFIXED);
1144 mylcd_set_foreground(oldfg); 1261 mylcd_set_foreground(oldfg);
1145 mylcd_set_background(oldbg); 1262 mylcd_set_background(oldbg);
1146 1263
@@ -1391,6 +1508,7 @@ static int osd_play(uint32_t time)
1391 osd_backlight_on_video_mode(true); 1508 osd_backlight_on_video_mode(true);
1392 osd_backlight_brightness_video_mode(true); 1509 osd_backlight_brightness_video_mode(true);
1393 stream_show_vo(true); 1510 stream_show_vo(true);
1511
1394 retval = stream_play(); 1512 retval = stream_play();
1395 1513
1396 if (retval >= STREAM_OK) 1514 if (retval >= STREAM_OK)
@@ -1747,6 +1865,8 @@ static int button_loop(void)
1747 1865
1748 next_action = (settings.play_mode == 0) ? VIDEO_STOP : VIDEO_NEXT; 1866 next_action = (settings.play_mode == 0) ? VIDEO_STOP : VIDEO_NEXT;
1749 1867
1868 fps_update_post_frame_callback();
1869
1750 /* The menu can change the font, so restore */ 1870 /* The menu can change the font, so restore */
1751 rb->lcd_setfont(FONT_SYSFIXED); 1871 rb->lcd_setfont(FONT_SYSFIXED);
1752#ifdef HAVE_LCD_COLOR 1872#ifdef HAVE_LCD_COLOR