summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Pixel.h9
-rw-r--r--ambiservice.c9
-rw-r--r--ambiservice.h6
-rw-r--r--ambithread.c71
-rw-r--r--ambithread.h8
-rw-r--r--main_menu.c1
-rw-r--r--setup_menu.c3
-rw-r--r--vdrboblight.c3
8 files changed, 67 insertions, 43 deletions
diff --git a/Pixel.h b/Pixel.h
index 55a684f..2acb9db 100644
--- a/Pixel.h
+++ b/Pixel.h
@@ -31,14 +31,9 @@ struct Pixel
unsigned char r;
unsigned char a;
- int isBlack(int threshold = 3) {
-
- if (r > threshold || g > threshold || b > threshold) {
- return false;
- }
- return true;
+ inline int isBlack(int threshold) {
+ return (r < threshold || g < threshold || b < threshold);
}
-
};
#endif \ No newline at end of file
diff --git a/ambiservice.c b/ambiservice.c
index 544095c..95b40fe 100644
--- a/ambiservice.c
+++ b/ambiservice.c
@@ -31,7 +31,10 @@ const char* cAmbiService::viewModes[] =
"detached"
};
-const char* cAmbiService::toName(ViewMode vm)
+const char* cAmbiService::cineBars[] =
{
- return viewModes[vm];
-}
+ "None",
+ "Horizontal",
+ "Vertical",
+ "Both"
+};
diff --git a/ambiservice.h b/ambiservice.h
index 3e08c2a..793b782 100644
--- a/ambiservice.h
+++ b/ambiservice.h
@@ -25,7 +25,8 @@ class cAmbiService
public:
enum Cinebars
- {
+ {
+ cbNone,
cbHorizontal,
cbVertical,
cbBoth,
@@ -42,9 +43,8 @@ class cAmbiService
};
// static
-
- static const char* toName(ViewMode vm);
static const char* viewModes[];
+ static const char* cineBars[];
};
#endif // __AMBI_SERVICE_H
diff --git a/ambithread.c b/ambithread.c
index 1f71968..1738ee3 100644
--- a/ambithread.c
+++ b/ambithread.c
@@ -39,6 +39,15 @@ cAmbiThread::cAmbiThread()
imageHeight = 0;
xBarHeight = 0;
yBarWidth = 0;
+ lastxBarHeight = 0;
+ lastyBarWidth = 0;
+ barsChanged = true;
+
+ softHdPlugin = cPluginManager::GetPlugin("softhddevice");
+ int softHdGrabService = (softHdPlugin && softHdPlugin->Service(ATMO1_GRAB_SERVICE, 0));
+
+ if (!softHdGrabService)
+ error("Can't find softhddevice %s!", softHdPlugin ? "service" : "plugin");
}
cAmbiThread::~cAmbiThread()
@@ -163,12 +172,6 @@ void cAmbiThread::Action()
int cAmbiThread::softhddeviceNotDetached()
{
- cPlugin* softHdPlugin = cPluginManager::GetPlugin("softhddevice");
- if(!softHdPlugin)
- {
- error("Can't find softhddevice");
- return fail;
- }
int reply_code = 0;
cString reply_msg;
reply_msg = softHdPlugin->SVDRPCommand("STAT", "", reply_code);
@@ -196,13 +199,6 @@ int cAmbiThread::grabImage()
free(image);
image = 0;
- cPlugin* softHdPlugin = cPluginManager::GetPlugin("softhddevice");
- int softHdGrabService = (softHdPlugin && softHdPlugin->Service(ATMO1_GRAB_SERVICE, 0));
-
- if (!softHdGrabService)
- return error("Can't find softhddevice %s, aborting grab, retrying in 10 seconds!",
- softHdPlugin ? "service" : "plugin");
-
// grab image at sofhddevice
req.width = 64;
req.height = 64;
@@ -237,29 +233,32 @@ int cAmbiThread::detectCineBars()
|0|x x|0|
*/
- Pixel* p;
+ if (cfg.detectCineBars == cbNone) {
+ return done;
+ }
+ Pixel* p;
const int xOffset = imageWidth / 4;
const int yOffset = imageHeight / 4;
- xBarHeight = 0;
- yBarWidth = 0;
+ int tempxBarHeight = 0;
+ int tempyBarWidth = 0;
if (cfg.detectCineBars == cbHorizontal || cfg.detectCineBars == cbBoth) {
// check for xBar
- for (int y = 0; y < yOffset; y++) {
+ for (int y = 0; y < yOffset; ++y) {
int row = imageWidth * y;
int xBarCount = 0;
- for (int x = xOffset; x < imageWidth - xOffset; x++) {
+ for (int x = xOffset; x < imageWidth - xOffset; ++x) {
p = &image[row + x];
if(p->isBlack(cfg.cineBarsThreshold)) {
- xBarCount++;
+ ++xBarCount;
}
}
if(xBarCount == imageWidth - (2*xOffset)){
- xBarHeight++;
+ ++tempxBarHeight;
}
else {
break;
@@ -269,17 +268,18 @@ int cAmbiThread::detectCineBars()
if (cfg.detectCineBars == cbVertical || cfg.detectCineBars == cbBoth) {
// check for yBar
- for (int x = 0; x < xOffset; x++) {
+ for (int x = 0; x < xOffset; ++x) {
int yBarCount = 0;
- for (int y = yOffset; y < imageHeight - yOffset; y++) {
+ for (int y = yOffset; y < imageHeight - yOffset; ++y) {
+
int row = imageWidth * y;
p = &image[row + x];
if(p->isBlack(cfg.cineBarsThreshold)) {
- yBarCount++;
+ ++yBarCount;
}
}
if(yBarCount == imageHeight - (2*yOffset) ){
- yBarWidth++;
+ ++tempyBarWidth;
}
else {
break;
@@ -287,10 +287,23 @@ int cAmbiThread::detectCineBars()
}
}
- tell(1, "Black border detection horBar: %d verBar: %d", xBarHeight, yBarWidth);
+ if (tempxBarHeight != lastxBarHeight || tempyBarWidth != lastyBarWidth) {
+ barsChanged = true;
+ xBarHeight = tempxBarHeight;
+ yBarWidth = tempyBarWidth;
+ }
+ else {
+ barsChanged = false;
+ }
+
+ lastxBarHeight = tempxBarHeight;
+ lastyBarWidth = tempyBarWidth;
+
+ if(barsChanged) tell(1, "V2 Black border detection horBar: %d verBar: %d", xBarHeight, yBarWidth);
return done;
}
+
//***************************************************************************
// Put Data
//***************************************************************************
@@ -310,8 +323,7 @@ int cAmbiThread::putData()
else if(cfg.viewMode == vmAtmo) {
int row = 0;
- Pixel pixel = {0,0,0,0};
- Pixel* p = &pixel;
+ Pixel* p;
for (int y = 0; y < imageHeight; y++) {
// skip horizontal cinebars
@@ -330,7 +342,10 @@ int cAmbiThread::putData()
bob.writeColor(rgb, x - yBarWidth, y - xBarHeight);
}
}
- bob.setScanRange(imageWidth - (2*yBarWidth), imageHeight - (2*xBarHeight));
+ if (barsChanged) {
+ bob.setScanRange(imageWidth - (2*yBarWidth), imageHeight - (2*xBarHeight));
+ barsChanged = false;
+ }
}
bob.send();
diff --git a/ambithread.h b/ambithread.h
index 2bf739d..9c3ed4c 100644
--- a/ambithread.h
+++ b/ambithread.h
@@ -56,6 +56,8 @@ class cAmbiThread : public cThread, public cAmbiService
// data
cBoblight bob;
+ cPlugin* softHdPlugin;
+
cMutex mutex;
cCondVar waitCondition;
int loopActive;
@@ -63,6 +65,12 @@ class cAmbiThread : public cThread, public cAmbiService
Pixel* image;
int xBarHeight;
int yBarWidth;
+
+ int lastxBarHeight;
+ int lastyBarWidth;
+
+ bool barsChanged;
+
int imageSize;
int imageWidth;
int imageHeight;
diff --git a/main_menu.c b/main_menu.c
index 04c58ef..97b8cb3 100644
--- a/main_menu.c
+++ b/main_menu.c
@@ -14,6 +14,7 @@ cBoblightPluginMenu::cBoblightPluginMenu(const char* title, cPluginBoblight* aPl
}
void cBoblightPluginMenu::Create(void) {
+ SetMenuCategory(mcPluginSetup);
Clear();
Add(new cMenuEditStraItem(tr("View Mode"), &cfg.viewMode, cAmbiService::vmCount, cAmbiService::viewModes));
diff --git a/setup_menu.c b/setup_menu.c
index 7c8cf5a..868eef8 100644
--- a/setup_menu.c
+++ b/setup_menu.c
@@ -30,7 +30,8 @@ void cAmbiSetup::Setup()
Add(new cMenuEditIntItem(tr("Updaterate [Hz]"), &cfg.frequence, 1, 100));
- Add(new cMenuEditStraItem(tr("Detect black borders"), &cfg.detectCineBars, 3, cineBars));
+ Add(new cMenuEditStraItem(tr("Detect black borders"), &cfg.detectCineBars, cAmbiService::cbCount, cAmbiService::cineBars));
+
Add(new cMenuEditIntItem(tr("Black border detection Threshold (0-255)"), &cfg.cineBarsThreshold, 0, 255));
Add(new cMenuEditIntItem(tr("Threshold (0-255)"), &cfg.threshold, 0, 255));
diff --git a/vdrboblight.c b/vdrboblight.c
index 5a90b77..4e47dbf 100644
--- a/vdrboblight.c
+++ b/vdrboblight.c
@@ -138,7 +138,7 @@ bool cPluginBoblight::SetupParse(const char* Name, const char* Value)
else if (!strcasecmp(Name, "DetectCineBars")) cfg.detectCineBars = (cAmbiService::Cinebars)atoi(Value);
else if (!strcasecmp(Name, "CineBarsThreshold")) cfg.cineBarsThreshold = atoi(Value);
- else if (!strcasecmp(Name, "Frequence")) cfg.frequence = atoi(Value);
+ else if (!strcasecmp(Name, "Updaterate")) cfg.frequence = atoi(Value);
else if (!strcasecmp(Name, "Threshold")) cfg.threshold = atoi(Value);
else if (!strcasecmp(Name, "Value")) cfg.value = atoi(Value);
else if (!strcasecmp(Name, "Saturation")) cfg.saturation = atoi(Value);
@@ -146,6 +146,7 @@ bool cPluginBoblight::SetupParse(const char* Name, const char* Value)
else if (!strcasecmp(Name, "Autospeed")) cfg.autospeed = atoi(Value);
else if (!strcasecmp(Name, "Interpolation")) cfg.interpolation = atoi(Value);
else if (!strcasecmp(Name, "Priority")) cfg.priority = atoi(Value);
+ else if (!strcasecmp(Name, "Gamma")) cfg.gamma = atoi(Value);
else if (!strcasecmp(Name, "FixedColorRed")) cfg.fixedR = atoi(Value);