From d89ada9aad29870ad08b503aac3e85d8bc36c2ff Mon Sep 17 00:00:00 2001 From: Johns Date: Fri, 4 Jan 2013 21:50:55 +0100 Subject: [PATCH] Makes PIP+Video position configurable. --- softhddev.c | 32 ++++++++-- softhddev.h | 2 + softhddevice.cpp | 152 +++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 172 insertions(+), 14 deletions(-) diff --git a/softhddev.c b/softhddev.c index 558fed7..ad8c609 100644 --- a/softhddev.c +++ b/softhddev.c @@ -2916,6 +2916,33 @@ void ScaleVideo(int x, int y, int width, int height) #ifdef USE_PIP +/** +** Set PIP position. +** +** @param x video window x coordinate OSD relative +** @param y video window y coordinate OSD relative +** @param width video window width OSD relative +** @param height video window height OSD relative +** @param pip_x pip window x coordinate OSD relative +** @param pip_y pip window y coordinate OSD relative +** @param pip_width pip window width OSD relative +** @param pip_height pip window height OSD relative +*/ +void PipSetPosition(int x, int y, int width, int height, int pip_x, int pip_y, + int pip_width, int pip_height) +{ + if (!MyVideoStream->HwDecoder) { // video not running + return; + } + ScaleVideo(x, y, width, height); + + if (!PipVideoStream->HwDecoder) { // pip not running + return; + } + VideoSetOutputPosition(PipVideoStream->HwDecoder, pip_x, pip_y, + pip_width, pip_height); +} + /** ** Start PIP stream. ** @@ -2935,8 +2962,6 @@ void PipStart(int x, int y, int width, int height, int pip_x, int pip_y, return; } - ScaleVideo(x, y, width, height); - if (!PipVideoStream->Decoder) { PipVideoStream->SkipStream = 1; if ((PipVideoStream->HwDecoder = VideoNewHwDecoder(PipVideoStream))) { @@ -2948,10 +2973,9 @@ void PipStart(int x, int y, int width, int height, int pip_x, int pip_y, PipVideoStream->LastCodecID = CODEC_ID_NONE; VideoPacketInit(PipVideoStream); - VideoSetOutputPosition(PipVideoStream->HwDecoder, pip_x, pip_y, - pip_width, pip_height); } } + PipSetPosition(x, y, width, height, pip_x, pip_y, pip_width, pip_height); } /** diff --git a/softhddev.h b/softhddev.h index 4075fbd..69fa32e 100644 --- a/softhddev.h +++ b/softhddev.h @@ -98,6 +98,8 @@ extern "C" /// C plugin scale video extern void ScaleVideo(int, int, int, int); + /// Set Pip position + extern void PipSetPosition(int, int, int, int, int, int, int, int); /// Pip start extern void PipStart(int, int, int, int, int, int, int, int); /// Pip stop diff --git a/softhddevice.cpp b/softhddevice.cpp index f931f76..06fe3aa 100644 --- a/softhddevice.cpp +++ b/softhddevice.cpp @@ -141,22 +141,22 @@ static char *ConfigAudioDevice; ///< config audio stereo device static char *ConfigAC3Device; ///< config audio passthrough device #ifdef USE_PIP -static int ConfigPipX; ///< config pip pip x in % -static int ConfigPipY; ///< config pip pip y in % -static int ConfigPipWidth; ///< config pip pip width in % -static int ConfigPipHeight; ///< config pip pip height in % +static int ConfigPipX = 100 - 3 - 18; ///< config pip pip x in % +static int ConfigPipY = 100 - 4 - 18; ///< config pip pip y in % +static int ConfigPipWidth = 18; ///< config pip pip width in % +static int ConfigPipHeight = 18; ///< config pip pip height in % static int ConfigPipVideoX; ///< config pip video x in % static int ConfigPipVideoY; ///< config pip video y in % static int ConfigPipVideoWidth; ///< config pip video width in % static int ConfigPipVideoHeight; ///< config pip video height in % static int ConfigPipAltX; ///< config pip alt. pip x in % -static int ConfigPipAltY; ///< config pip alt. pip y in % +static int ConfigPipAltY = 50; ///< config pip alt. pip y in % static int ConfigPipAltWidth; ///< config pip alt. pip width in % -static int ConfigPipAltHeight; ///< config pip alt. pip height in % +static int ConfigPipAltHeight = 50; ///< config pip alt. pip height in % static int ConfigPipAltVideoX; ///< config pip alt. video x in % static int ConfigPipAltVideoY; ///< config pip alt. video y in % static int ConfigPipAltVideoWidth; ///< config pip alt. video width in % -static int ConfigPipAltVideoHeight; ///< config pip alt. video height in % +static int ConfigPipAltVideoHeight = 50; ///< config pip alt. video height in % #endif static volatile int DoMakePrimary; ///< switch primary device to this @@ -1309,6 +1309,8 @@ cSoftHdControl::~cSoftHdControl() #ifdef USE_PIP +static int PipAltPosition; ///< flag alternative position + ////////////////////////////////////////////////////////////////////////////// // cReceiver ////////////////////////////////////////////////////////////////////////////// @@ -1359,7 +1361,33 @@ void cSoftReceiver::Activate(bool on) fprintf(stderr, "pip: activate %d\n", on); if (on) { - PipStart(0, 0, 0, 0, 50, 50, 355, 200); + int width; + int height; + double video_aspect; + + GetOsdSize(&width, &height, &video_aspect); + if (PipAltPosition) { + PipStart((ConfigPipAltVideoX * width) / 100, + (ConfigPipAltVideoY * height) / 100, + ConfigPipAltVideoWidth ? (ConfigPipAltVideoWidth * width) / + 100 : width, + ConfigPipAltVideoHeight ? (ConfigPipAltVideoHeight * height) / + 100 : height, (ConfigPipAltX * width) / 100, + (ConfigPipAltY * height) / 100, + ConfigPipAltWidth ? (ConfigPipAltWidth * width) / 100 : width, + ConfigPipAltHeight ? (ConfigPipAltHeight * height) / + 100 : height); + } else { + PipStart((ConfigPipVideoX * width) / 100, + (ConfigPipVideoY * height) / 100, + ConfigPipVideoWidth ? (ConfigPipVideoWidth * width) / + 100 : width, + ConfigPipVideoHeight ? (ConfigPipVideoHeight * height) / + 100 : height, (ConfigPipX * width) / 100, + (ConfigPipY * height) / 100, + ConfigPipWidth ? (ConfigPipWidth * width) / 100 : width, + ConfigPipHeight ? (ConfigPipHeight * height) / 100 : height); + } } else { PipStop(); } @@ -1476,7 +1504,7 @@ void cSoftReceiver::Receive(uchar * data, int size) ////////////////////////////////////////////////////////////////////////////// -static cSoftReceiver * PipReceiver; ///< PIP receiver +static cSoftReceiver *PipReceiver; ///< PIP receiver /** ** Prepare new PIP. @@ -1494,6 +1522,7 @@ static void NewPip(void) fprintf(stderr, "pip: %d %p %p\n", channel_nr, channel, device); delete PipReceiver; + PipReceiver = NULL; device->SwitchChannel(channel, false); @@ -1511,9 +1540,44 @@ static void DelPip(void) { fprintf(stderr, "pip: stopped\n"); delete PipReceiver; + PipReceiver = NULL; } +/** +** Swap PIP position. +*/ +static void SwapPipPosition(void) +{ + int width; + int height; + double video_aspect; + + GetOsdSize(&width, &height, &video_aspect); + + PipAltPosition ^= 1; + if (PipAltPosition) { + PipSetPosition((ConfigPipAltVideoX * width) / 100, + (ConfigPipAltVideoY * height) / 100, + ConfigPipAltVideoWidth ? (ConfigPipAltVideoWidth * width) / + 100 : width, + ConfigPipAltVideoHeight ? (ConfigPipAltVideoHeight * height) / + 100 : height, (ConfigPipAltX * width) / 100, + (ConfigPipAltY * height) / 100, + ConfigPipAltWidth ? (ConfigPipAltWidth * width) / 100 : width, + ConfigPipAltHeight ? (ConfigPipAltHeight * height) / 100 : height); + } else { + PipSetPosition((ConfigPipVideoX * width) / 100, + (ConfigPipVideoY * height) / 100, + ConfigPipVideoWidth ? (ConfigPipVideoWidth * width) / 100 : width, + ConfigPipVideoHeight ? (ConfigPipVideoHeight * height) / + 100 : height, (ConfigPipX * width) / 100, + (ConfigPipY * height) / 100, + ConfigPipWidth ? (ConfigPipWidth * width) / 100 : width, + ConfigPipHeight ? (ConfigPipHeight * height) / 100 : height); + } +} + #endif ////////////////////////////////////////////////////////////////////////////// @@ -1760,6 +1824,9 @@ eOSState cSoftHdMenu::ProcessKey(eKeys key) case osUser2: NewPip(); return osEnd; + case osUser7: + SwapPipPosition(); + return osEnd; case osUser8: DelPip(); return osEnd; @@ -2709,7 +2776,72 @@ bool cPluginSoftHdDevice::SetupParse(const char *name, const char *value) ConfigAudioBufferTime = atoi(value); return true; } - +#ifdef USE_PIP + if (!strcasecmp(name, "pip.X")) { + ConfigPipX = atoi(value); + return true; + } + if (!strcasecmp(name, "pip.Y")) { + ConfigPipY = atoi(value); + return true; + } + if (!strcasecmp(name, "pip.Width")) { + ConfigPipWidth = atoi(value); + return true; + } + if (!strcasecmp(name, "pip.Height")) { + ConfigPipHeight = atoi(value); + return true; + } + if (!strcasecmp(name, "pip.VideoX")) { + ConfigPipVideoX = atoi(value); + return true; + } + if (!strcasecmp(name, "pip.VideoY")) { + ConfigPipVideoY = atoi(value); + return true; + } + if (!strcasecmp(name, "pip.VideoWidth")) { + ConfigPipVideoWidth = atoi(value); + return true; + } + if (!strcasecmp(name, "pip.VideoHeight")) { + ConfigPipVideoHeight = atoi(value); + return true; + } + if (!strcasecmp(name, "pip.Alt.X")) { + ConfigPipAltX = atoi(value); + return true; + } + if (!strcasecmp(name, "pip.Alt.Y")) { + ConfigPipAltY = atoi(value); + return true; + } + if (!strcasecmp(name, "pip.Alt.Width")) { + ConfigPipAltWidth = atoi(value); + return true; + } + if (!strcasecmp(name, "pip.Alt.Height")) { + ConfigPipAltHeight = atoi(value); + return true; + } + if (!strcasecmp(name, "pip.Alt.VideoX")) { + ConfigPipAltVideoX = atoi(value); + return true; + } + if (!strcasecmp(name, "pip.Alt.VideoY")) { + ConfigPipAltVideoY = atoi(value); + return true; + } + if (!strcasecmp(name, "pip.Alt.VideoWidth")) { + ConfigPipAltVideoWidth = atoi(value); + return true; + } + if (!strcasecmp(name, "pip.Alt.VideoHeight")) { + ConfigPipAltVideoHeight = atoi(value); + return true; + } +#endif return false; }