aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorghost <andreas.monzner@multimedia-labs.de>2008-11-17 21:17:34 +0100
committerghost <andreas.monzner@multimedia-labs.de>2008-11-17 21:17:34 +0100
commit9ccb92fb3eaca35ec60c1a596db9620f9f302044 (patch)
treef4a248e012ab24ab869e862212eb0643ed4a77d6
parent5eb41508927a7f48d09d52e158e136fa07252dac (diff)
downloadenigma2-9ccb92fb3eaca35ec60c1a596db9620f9f302044.tar.gz
enigma2-9ccb92fb3eaca35ec60c1a596db9620f9f302044.zip
more changes for async picture decode support
-rw-r--r--lib/gdi/picload.cpp109
-rw-r--r--lib/gdi/picload.h5
-rw-r--r--lib/python/Components/AVSwitch.py16
-rw-r--r--lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py29
4 files changed, 125 insertions, 34 deletions
diff --git a/lib/gdi/picload.cpp b/lib/gdi/picload.cpp
index 2ef901f5..b1dfd1a1 100644
--- a/lib/gdi/picload.cpp
+++ b/lib/gdi/picload.cpp
@@ -569,19 +569,29 @@ ePicLoad::ePicLoad()
m_conf.thumbnailsize = 180;
}
-ePicLoad::~ePicLoad()
+void ePicLoad::waitFinished()
{
msg_thread.send(Message(Message::quit));
kill();
+}
+ePicLoad::~ePicLoad()
+{
+ if (threadrunning)
+ waitFinished();
if(m_filepara != NULL)
delete m_filepara;
}
+void ePicLoad::thread_finished()
+{
+ threadrunning=false;
+}
void ePicLoad::thread()
{
hasStarted();
+ threadrunning=true;
nice(4);
runLoop();
}
@@ -759,7 +769,6 @@ void ePicLoad::gotMessage(const Message &msg)
break;
case Message::decode_finished: // called from main thread
//eDebug("[Picload] decode finished... %s", m_filepara->file);
- threadrunning=false;
if(m_filepara->callback)
{
PictureData(m_filepara->picinfo.c_str());
@@ -824,7 +833,6 @@ int ePicLoad::startThread(int what, const char *file, int x, int y)
return 1;
}
- threadrunning=true;
if(what==1)
msg_thread.send(Message(Message::decode_Pic));
else
@@ -843,33 +851,6 @@ RESULT ePicLoad::getThumbnail(const char *file, int x, int y)
return startThread(0, file, x, y);
}
-RESULT ePicLoad::setPara(PyObject *val)
-{
- if (!PyList_Check(val))
- return 0;
- if (PyList_Size(val) < 6)
- return 0;
-
- m_conf.max_x = PyInt_AsLong( PyList_GET_ITEM(val, 0));
- m_conf.max_y = PyInt_AsLong( PyList_GET_ITEM(val, 1));
- m_conf.aspect_ratio = PyFloat_AsDouble( PyList_GET_ITEM(val, 2));
- m_conf.usecache = PyInt_AsLong( PyList_GET_ITEM(val, 3));
- m_conf.resizetype = PyInt_AsLong( PyList_GET_ITEM(val, 4));
- const char *bg_str = PyString_AsString( PyList_GET_ITEM(val, 5));
-
- if(bg_str[0] == '#' && strlen(bg_str)==9)
- {
- int bg = strtoul(bg_str+1, NULL, 16);
- m_conf.background[0] = bg&0xFF; //BB
- m_conf.background[1] = (bg>>8)&0xFF; //GG
- m_conf.background[2] = (bg>>16)&0xFF; //RR
- m_conf.background[3] = bg>>24; //AA
- }
-
- eDebug("[Picload] setPara max-X=%d max-Y=%d aspect_ratio=%lf cache=%d resize=%d bg=#%02X%02X%02X%02X", m_conf.max_x, m_conf.max_y, m_conf.aspect_ratio, (int)m_conf.usecache, (int)m_conf.resizetype, m_conf.background[3], m_conf.background[2], m_conf.background[1], m_conf.background[0]);
- return 1;
-}
-
PyObject *ePicLoad::getInfo(const char *filename)
{
ePyObject list;
@@ -935,6 +916,7 @@ PyObject *ePicLoad::getInfo(const char *filename)
int ePicLoad::getData(ePtr<gPixmap> &result)
{
+ result = 0;
if(m_filepara->pic_buffer == NULL) return 0;
m_filepara->pic_buffer = conv24to32(m_filepara->pic_buffer, m_filepara->ox * m_filepara->oy);
@@ -1015,3 +997,70 @@ int ePicLoad::getData(ePtr<gPixmap> &result)
return 0;
}
+
+RESULT ePicLoad::setPara(PyObject *val)
+{
+ if (!PyList_Check(val))
+ return 0;
+ if (PyList_Size(val) < 6)
+ return 0;
+
+ m_conf.max_x = PyInt_AsLong( PyList_GET_ITEM(val, 0));
+ m_conf.max_y = PyInt_AsLong( PyList_GET_ITEM(val, 1));
+ m_conf.aspect_ratio = PyFloat_AsDouble( PyList_GET_ITEM(val, 2));
+ m_conf.usecache = PyInt_AsLong( PyList_GET_ITEM(val, 3));
+ m_conf.resizetype = PyInt_AsLong( PyList_GET_ITEM(val, 4));
+ const char *bg_str = PyString_AsString( PyList_GET_ITEM(val, 5));
+
+ if(bg_str[0] == '#' && strlen(bg_str)==9)
+ {
+ int bg = strtoul(bg_str+1, NULL, 16);
+ m_conf.background[0] = bg&0xFF; //BB
+ m_conf.background[1] = (bg>>8)&0xFF; //GG
+ m_conf.background[2] = (bg>>16)&0xFF; //RR
+ m_conf.background[3] = bg>>24; //AA
+ }
+
+ eDebug("[Picload] setPara max-X=%d max-Y=%d aspect_ratio=%lf cache=%d resize=%d bg=#%02X%02X%02X%02X", m_conf.max_x, m_conf.max_y, m_conf.aspect_ratio, (int)m_conf.usecache, (int)m_conf.resizetype, m_conf.background[3], m_conf.background[2], m_conf.background[1], m_conf.background[0]);
+ return 1;
+}
+
+//------------------------------------------------------------------------------------
+
+//for old plugins
+SWIG_VOID(int) loadPic(ePtr<gPixmap> &result, std::string filename, int x, int y, int aspect, int resize_mode, int rotate, int background, std::string cachefile)
+{
+ result = 0;
+ eDebug("deprecated loadPic function used!!! please use the non blocking version! you can see demo code in Pictureplayer plugin... this function is removed in the near future!");
+ ePicLoad mPL;
+
+ double aspect_ratio;
+ switch(aspect)
+ {
+ case 1: aspect_ratio = 1.778 / ((double)720/576); break; //16:9
+ case 2: aspect_ratio = 1.600 / ((double)720/576); break; //16:10
+ case 3: aspect_ratio = 1.250 / ((double)720/576); break; //5:4
+ default: aspect_ratio = 1.333 / ((double)720/576); //4:3
+ }
+
+ ePyObject list = PyList_New(6);
+ PyList_SET_ITEM(list, 0, PyLong_FromLong(x));
+ PyList_SET_ITEM(list, 1, PyLong_FromLong(y));
+ PyList_SET_ITEM(list, 2, PyFloat_FromDouble(aspect_ratio));
+ PyList_SET_ITEM(list, 3, PyLong_FromLong(0));
+ PyList_SET_ITEM(list, 4, PyLong_FromLong(resize_mode));
+ if(background)
+ PyList_SET_ITEM(list, 5, PyString_FromString("#ff000000"));
+ else
+ PyList_SET_ITEM(list, 5, PyString_FromString("#00000000"));
+
+ mPL.setPara(list);
+
+ if(!mPL.startDecode(filename.c_str()))
+ {
+ mPL.waitFinished(); // this blocks until the thread is finished
+ mPL.getData(result);
+ }
+
+ return 0;
+}
diff --git a/lib/gdi/picload.h b/lib/gdi/picload.h
index a85567c0..6a0f70b9 100644
--- a/lib/gdi/picload.h
+++ b/lib/gdi/picload.h
@@ -86,7 +86,9 @@ class ePicLoad: public eMainloop, public eThread, public Object, public iObject
void gotMessage(const Message &message);
void thread();
int startThread(int what, const char *file, int x, int y);
+ void thread_finished();
public:
+ void waitFinished();
PSignal1<void, const char*> PictureData;
ePicLoad();
@@ -99,4 +101,7 @@ public:
SWIG_VOID(int) getData(ePtr<gPixmap> &SWIG_OUTPUT);
};
+//for old plugins
+SWIG_VOID(int) loadPic(ePtr<gPixmap> &SWIG_OUTPUT, std::string filename, int x, int y, int aspect, int resize_mode=0, int rotate=0, int background=0, std::string cachefile="");
+
#endif // __picload_h__
diff --git a/lib/python/Components/AVSwitch.py b/lib/python/Components/AVSwitch.py
index 7ac2bb98..19aca24d 100644
--- a/lib/python/Components/AVSwitch.py
+++ b/lib/python/Components/AVSwitch.py
@@ -1,5 +1,5 @@
from config import config, ConfigSlider, ConfigSelection, ConfigYesNo, ConfigEnableDisable, ConfigSubsection, ConfigBoolean
-from enigma import eAVSwitch
+from enigma import eAVSwitch, getDesktop
from SystemInfo import SystemInfo
class AVSwitch:
@@ -32,9 +32,12 @@ class AVSwitch:
if valstr in ("4_3_letterbox", "4_3_panscan"): # 4:3
return 1.333333333
elif valstr == "16_9": # auto ... 4:3 or 16:9
- # TODO: here we must retrieve the current video aspect ratio...
- # because the TV can run in 4:3 or in 16:9 mode.. (switched by wss or scart pin8)
- # until we have done this we always return the scale value for 16:9!!
+ try:
+ aspect_str = open("/proc/stb/vmpeg/0/aspect", "r").read()
+ if aspect_str == "1": # 4:3
+ return 1.333333333
+ except IOError:
+ pass
return 1.777777778
elif valstr in ("16_9_always", "16_9_letterbox"): # 16:9
return 1.777777778
@@ -43,6 +46,11 @@ class AVSwitch:
print "unknown output aspect!"
return 1.0000
+ def getFramebufferScale(self):
+ aspect = self.getOutputAspect()
+ fb_size = getDesktop(0).size()
+ return aspect / ((1.0 * fb_size.width()) / fb_size.height())
+
def getAspectRatioSetting(self):
valstr = config.av.aspectratio.value
if valstr == "4_3_letterbox":
diff --git a/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py b/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py
index 2422475e..5e38f3e6 100644
--- a/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py
+++ b/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py
@@ -59,6 +59,34 @@ class VideoHardware:
widescreen_modes = set(["720p", "1080i"])
+ def getOutputAspect(self):
+ ret = 1.777777778 # 16:9
+ port = config.av.videoport.value
+ if port not in config.av.videomode:
+ print "current port not available in getOutputAspect!!! force 16:9"
+ else:
+ mode = config.av.videomode[port].value
+ force_widescreen = self.isWidescreenMode(port, mode)
+ is_widescreen = force_widescreen or config.av.aspect.value in ["16_9", "16_10"]
+ is_auto = config.av.aspect.value == "auto"
+ if is_widescreen:
+ if force_widescreen:
+ pass
+ else:
+ aspect = {"16_9": "16:9", "16_10": "16:10"}[config.av.aspect.value]
+ if aspect == "16:10":
+ ret = 1.6
+ elif is_auto:
+ try:
+ aspect_str = open("/proc/stb/vmpeg/0/aspect", "r").read()
+ if aspect_str == "1": # 4:3
+ ret = 1.333333333
+ except IOError:
+ pass
+ else: # 4:3
+ ret = 1.333333333
+ return ret
+
def __init__(self):
self.last_modes_preferred = [ ]
self.on_hotplug = CList()
@@ -80,6 +108,7 @@ class VideoHardware:
config.av.tvsystem.notifiers = [ ]
config.av.wss.notifiers = [ ]
AVSwitch.setInput = self.AVSwitchSetInput
+ AVSwitch.getOutputAspect = self.getOutputAspect
config.av.aspect.addNotifier(self.updateAspect)
config.av.wss.addNotifier(self.updateAspect)