From 696bb8e934bc8bd9c73df4f954d74e926dbeeadb Mon Sep 17 00:00:00 2001 From: Johns Date: Mon, 2 Jul 2012 17:05:36 +0200 Subject: [PATCH] Display frame statistics in plugin menu. --- ChangeLog | 1 + softhddev.c | 19 +++++++++++++++++++ softhddev.h | 3 +++ softhddevice.cpp | 45 +++++++++++++++++++++++++++++++++++++-------- video.c | 31 +++++++++++++++++++++++++++++++ video.h | 3 +++ 6 files changed, 94 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index e093beb..1948e42 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ User johns Date: Release Version 0.5.1 + Display frame statistics in plugin menu. Fix bug: 100% CPU use during playback. Fix bug: audio use 100% CPU during pause. Guard audio skip against old PTS values. diff --git a/softhddev.c b/softhddev.c index 57858ed..849835e 100644 --- a/softhddev.c +++ b/softhddev.c @@ -2689,3 +2689,22 @@ void Resume(void) pthread_mutex_unlock(&SuspendLockMutex); } + +/* +** Get decoder statistics. +** +** @param[out] missed missed frames +** @param[out] duped duped frames +** @param[out] dropped dropped frames +** @param[out] count number of decoded frames +*/ +void GetStats(int *missed, int *duped, int *dropped, int *counter) +{ + *missed = 0; + *duped = 0; + *dropped = 0; + *counter = 0; + if (MyHwDecoder) { + VideoGetStats(MyHwDecoder, missed, duped, dropped, counter); + } +} diff --git a/softhddev.h b/softhddev.h index 77181c7..66b0b5a 100644 --- a/softhddev.h +++ b/softhddev.h @@ -90,6 +90,9 @@ extern "C" extern void Suspend(int, int, int); /// Resume plugin extern void Resume(void); + + /// Get decoder statistics + extern void GetStats(int *, int *, int *, int *); #ifdef __cplusplus } #endif diff --git a/softhddevice.cpp b/softhddevice.cpp index a11e989..023d036 100644 --- a/softhddevice.cpp +++ b/softhddevice.cpp @@ -648,7 +648,7 @@ void cMenuSetupSoft::Create(void) // Add(CollapsedItem(tr("Video"), Video)); if (Video) { -#if 0 // disabled, not working as expected +#if 0 // disabled, not working as expected Add(new cMenuEditBoolItem(trVDR("Setup.DVB$Video format"), &VideoFormat, "4:3", "16:9")); if (VideoFormat) { @@ -921,9 +921,9 @@ void cMenuSetupSoft::Store(void) //SetupStore("VideoFormat", Setup.VideoFormat); if (Setup.VideoDisplayFormat != VideoDisplayFormat) { Setup.VideoDisplayFormat = VideoDisplayFormat; - cDevice:: - PrimaryDevice()->SetVideoDisplayFormat(eVideoDisplayFormat - (Setup.VideoDisplayFormat)); + cDevice::PrimaryDevice()-> + SetVideoDisplayFormat(eVideoDisplayFormat(Setup. + VideoDisplayFormat)); } //SetupStore("VideoDisplayFormat", Setup.VideoDisplayFormat); @@ -1102,14 +1102,43 @@ cSoftHdControl::~cSoftHdControl() */ class cSoftHdMenu:public cOsdMenu { + private: int HotkeyState; ///< current hot-key state int HotkeyCode; ///< current hot-key code + void Create(void); ///< create plugin main menu public: cSoftHdMenu(const char *, int = 0, int = 0, int = 0, int = 0, int = 0); virtual ~ cSoftHdMenu(); virtual eOSState ProcessKey(eKeys); }; +/** +** Create main menu. +*/ +void cSoftHdMenu::Create(void) +{ + int current; + int missed; + int duped; + int dropped; + int counter; + + current = Current(); // get current menu item index + Clear(); // clear the menu + + SetHasHotkeys(); + Add(new cOsdItem(hk(tr("Suspend SoftHdDevice")), osUser1)); + Add(new cOsdItem(NULL, osUnknown, false)); + Add(new cOsdItem(NULL, osUnknown, false)); + GetStats(&missed, &duped, &dropped, &counter); + Add(new cOsdItem(cString:: + sprintf(tr(" Frames missed(%d) duped(%d) dropped(%d) total(%d)"), + missed, duped, dropped, counter), osUnknown, false)); + + SetCurrent(Get(current)); // restore selected menu entry + Display(); // display build menu +} + /** ** Soft device menu constructor. */ @@ -1119,8 +1148,7 @@ cSoftHdMenu::cSoftHdMenu(const char *title, int c0, int c1, int c2, int c3, { HotkeyState = 0; - SetHasHotkeys(); - Add(new cOsdItem(hk(tr("Suspend SoftHdDevice")), osUser1)); + Create(); } /** @@ -1288,6 +1316,7 @@ eOSState cSoftHdMenu::ProcessKey(eKeys key) } return osEnd; default: + Create(); break; } return state; @@ -1581,8 +1610,8 @@ bool cSoftHdDevice::Flush(int timeout_ms) ** Sets the video display format to the given one (only useful if this ** device has an MPEG decoder). */ -void cSoftHdDevice:: SetVideoDisplayFormat(eVideoDisplayFormat - video_display_format) +void cSoftHdDevice:: +SetVideoDisplayFormat(eVideoDisplayFormat video_display_format) { static int last = -1; diff --git a/video.c b/video.c index 4ae0f07..48543de 100644 --- a/video.c +++ b/video.c @@ -9642,6 +9642,37 @@ uint8_t *VideoGrabService(int *size, int *width, int *height) return NULL; } +/// +/// Get decoder statistics. +/// +/// @param hw_decoder video hardware decoder +/// @param[out] missed missed frames +/// @param[out] duped duped frames +/// @param[out] dropped dropped frames +/// @param[out] count number of decoded frames +/// +void VideoGetStats(VideoHwDecoder * hw_decoder, int *missed, int *duped, + int *dropped, int *counter) +{ + // FIXME: test to check if working, than make module function +#ifdef USE_VDPAU + if (VideoUsedModule == &VdpauModule) { + *missed = hw_decoder->Vdpau.FramesMissed; + *duped = hw_decoder->Vdpau.FramesDuped; + *dropped = hw_decoder->Vdpau.FramesDropped; + *counter = hw_decoder->Vdpau.FrameCounter; + } +#endif +#ifdef USE_VAPI + if (VideoUsedModule == &VaapiModule) { + *missed = hw_decoder->Vaapi.FramesMissed; + *duped = hw_decoder->Vaapi.FramesDuped; + *dropped = hw_decoder->Vaapi.FramesDropped; + *counter = hw_decoder->Vaapi.FrameCounter; + } +#endif +} + #ifdef USE_SCREENSAVER //---------------------------------------------------------------------------- diff --git a/video.h b/video.h index 3b5bbaa..9624e2d 100644 --- a/video.h +++ b/video.h @@ -174,6 +174,9 @@ extern uint8_t *VideoGrab(int *, int *, int *, int); /// Grab screen raw. extern uint8_t *VideoGrabService(int *, int *, int *); + /// Get decoder statistics. +extern void VideoGetStats(VideoHwDecoder *, int *, int *, int *, int *); + extern void VideoOsdInit(void); ///< Setup osd. extern void VideoOsdExit(void); ///< Cleanup osd.