get rid of some floating point values
authorghost <andreas.monzner@multimedia-labs.de>
Mon, 17 Nov 2008 22:34:41 +0000 (23:34 +0100)
committerghost <andreas.monzner@multimedia-labs.de>
Mon, 17 Nov 2008 22:34:41 +0000 (23:34 +0100)
lib/gdi/picload.cpp
lib/python/Components/AVSwitch.py
lib/python/Plugins/Extensions/PicturePlayer/plugin.py
lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py

index f67507ca3da91a03958d48abdcc1e713b68ad3b2..375f33fbed30195f2b474bd9820f004d848be1e5 100644 (file)
@@ -1011,16 +1011,16 @@ RESULT ePicLoad::setPara(PyObject *val)
 {
        if (!PySequence_Check(val))
                return 0;
-       if (PySequence_Size(val) < 6)
+       if (PySequence_Size(val) < 7)
                return 0;
        else {
                ePyObject fast = PySequence_Fast(val, "");
                m_conf.max_x            = PyInt_AsLong( PySequence_Fast_GET_ITEM(val, 0));
                m_conf.max_y            = PyInt_AsLong( PySequence_Fast_GET_ITEM(val, 1));
-               m_conf.aspect_ratio     = PyFloat_AsDouble( PySequence_Fast_GET_ITEM(val, 2));
-               m_conf.usecache         = PyInt_AsLong( PySequence_Fast_GET_ITEM(val, 3));
-               m_conf.resizetype       = PyInt_AsLong( PySequence_Fast_GET_ITEM(val, 4));
-               const char *bg_str      = PyString_AsString( PySequence_Fast_GET_ITEM(val, 5));
+               m_conf.aspect_ratio     = (double)PyInt_AsLong( PySequence_Fast_GET_ITEM(val, 2)) / PyInt_AsLong(PySequence_Fast_GET_ITEM(val, 3));
+               m_conf.usecache         = PyInt_AsLong( PySequence_Fast_GET_ITEM(val, 4));
+               m_conf.resizetype       = PyInt_AsLong( PySequence_Fast_GET_ITEM(val, 5));
+               const char *bg_str      = PyString_AsString( PySequence_Fast_GET_ITEM(val, 6));
        
                if(bg_str[0] == '#' && strlen(bg_str)==9)
                {
@@ -1040,29 +1040,30 @@ RESULT ePicLoad::setPara(PyObject *val)
 //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)
 {
+       long asp1, asp2;
        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
+               case 1:         asp1 = 16*576, asp2 = 9*720; break; //16:9
+               case 2:         asp1 = 16*576, asp2 = 10*720; break; //16:10
+               case 3:         asp1 = 5*576, asp2 = 4*720; break; //5:4
+               default:        asp1 = 4*576, asp2 = 3*720; break; //4:3
        }
-       
-       ePyObject tuple = PyTuple_New(6);
+
+       ePyObject tuple = PyTuple_New(7);
        PyTuple_SET_ITEM(tuple, 0,  PyLong_FromLong(x));
        PyTuple_SET_ITEM(tuple, 1,  PyLong_FromLong(y));
-       PyTuple_SET_ITEM(tuple, 2,  PyFloat_FromDouble(aspect_ratio));
-       PyTuple_SET_ITEM(tuple, 3,  PyLong_FromLong(0));
-       PyTuple_SET_ITEM(tuple, 4,  PyLong_FromLong(resize_mode));
+       PyTuple_SET_ITEM(tuple, 2,  PyLong_FromLong(asp1));
+       PyTuple_SET_ITEM(tuple, 3,  PyLong_FromLong(asp2));
+       PyTuple_SET_ITEM(tuple, 4,  PyLong_FromLong(0));
+       PyTuple_SET_ITEM(tuple, 5,  PyLong_FromLong(resize_mode));
        if(background)
-               PyTuple_SET_ITEM(tuple, 5,  PyString_FromString("#ff000000"));
+               PyTuple_SET_ITEM(tuple, 6,  PyString_FromString("#ff000000"));
        else
-               PyTuple_SET_ITEM(tuple, 5,  PyString_FromString("#00000000"));
+               PyTuple_SET_ITEM(tuple, 6,  PyString_FromString("#00000000"));
 
        mPL.setPara(tuple);
 
index 19aca24d885a33ac75bd92c60abcd4b95138da05..00350cbb464fc88a978866d648b08db0f0c34fd3 100644 (file)
@@ -30,26 +30,24 @@ class AVSwitch:
 
        def getOutputAspect(self):
                if valstr in ("4_3_letterbox", "4_3_panscan"): # 4:3
-                       return 1.333333333
+                       return (4,3)
                elif valstr == "16_9": # auto ... 4:3 or 16:9
                        try:
                                aspect_str = open("/proc/stb/vmpeg/0/aspect", "r").read()
                                if aspect_str == "1": # 4:3
-                                       return 1.333333333
+                                       return (4,3)
                        except IOError:
                                pass
-                       return 1.777777778
                elif valstr in ("16_9_always", "16_9_letterbox"): # 16:9
-                       return 1.777777778
+                       pass
                elif valstr in ("16_10_letterbox", "16_10_panscan"): # 16:10
-                       return 1.6
-               print "unknown output aspect!"
-               return 1.0000
+                       return (16,10)
+               return (16,9)
 
        def getFramebufferScale(self):
                aspect = self.getOutputAspect()
                fb_size = getDesktop(0).size()
-               return aspect / ((1.0 * fb_size.width()) / fb_size.height())
+               return (aspect[0] * fb_size.height(), aspect[1] * fb_size.width())
 
        def getAspectRatioSetting(self):
                valstr = config.av.aspectratio.value
index 7d62d2beabce17b69734f6f5f2f823c78a84bbe9..0cdab56374b1521ab7f92e218eaf4b34b6d463f1 100644 (file)
@@ -15,7 +15,7 @@ from Components.ConfigList import ConfigList
 
 from Components.config import config, ConfigSubsection, ConfigInteger, ConfigSelection, ConfigText, ConfigEnableDisable, KEY_LEFT, KEY_RIGHT, KEY_0, getConfigListEntry
 
-def getAspectforPic():
+def getScale():
        return AVSwitch().getFramebufferScale()
 
 config.pic = ConfigSubsection()
@@ -119,8 +119,9 @@ class picshow(Screen):
                        self.session.openWithCallback(self.callbackView, Pic_Full_View, self.filelist.getFileList(), self.filelist.getSelectionIndex(), self.filelist.getCurrentDirectory())
 
        def setConf(self):
+               sc = getScale()
                #0=Width 1=Height 2=Aspect 3=use_cache 4=resize_type 5=Background(#AARRGGBB)
-               self.picload.setPara([self["thn"].instance.size().width(), self["thn"].instance.size().height(), getAspectforPic(), config.pic.cache.value, int(config.pic.resize.value), "#00000000"])
+               self.picload.setPara((self["thn"].instance.size().width(), self["thn"].instance.size().height(), sc[0], sc[1], config.pic.cache.value, int(config.pic.resize.value), "#00000000"))
                
        def callbackView(self, val=0):
                if val > 0:
@@ -311,10 +312,10 @@ class Pic_Thumb(Screen):
                self.ThumbTimer.callback.append(self.showPic)
 
        def setPicloadConf(self):
-               self.picload.setPara([self["thumb0"].instance.size().width(), self["thumb0"].instance.size().height(), getAspectforPic(), config.pic.cache.value, int(config.pic.resize.value), self.color])
+               sc = getScale()
+               self.picload.setPara([self["thumb0"].instance.size().width(), self["thumb0"].instance.size().height(), sc[0], sc[1], config.pic.cache.value, int(config.pic.resize.value), self.color])
                self.paintFrame()
-               
-               
+
        def paintFrame(self):
                #print "index=" + str(self.index)
                if self.maxentry < self.index or self.index < 0:
@@ -468,7 +469,8 @@ class Pic_Full_View(Screen):
                        self.onLayoutFinish.append(self.setPicloadConf)
 
        def setPicloadConf(self):
-               self.picload.setPara([self["pic"].instance.size().width(), self["pic"].instance.size().height(), getAspectforPic(), 0, int(config.pic.resize.value), self.bgcolor])
+               sc = getScale()
+               self.picload.setPara([self["pic"].instance.size().width(), self["pic"].instance.size().height(), sc[0], sc[1], 0, int(config.pic.resize.value), self.bgcolor])
                
                self["play_icon"].hide()
                if config.pic.infoline.value == False:
index 5e38f3e647878506db8f7436291dc1aa03cc6356..02fdf9a5252454a7e6181f3685c01f9e87309381 100644 (file)
@@ -60,7 +60,7 @@ class VideoHardware:
        widescreen_modes = set(["720p", "1080i"])
 
        def getOutputAspect(self):
-               ret = 1.777777778 # 16:9
+               ret = (16,9)
                port = config.av.videoport.value
                if port not in config.av.videomode:
                        print "current port not available in getOutputAspect!!! force 16:9"
@@ -75,16 +75,16 @@ class VideoHardware:
                                else:
                                        aspect = {"16_9": "16:9", "16_10": "16:10"}[config.av.aspect.value]
                                        if aspect == "16:10":
-                                               ret = 1.6
+                                               ret = (16,10)
                        elif is_auto:
                                try:
                                        aspect_str = open("/proc/stb/vmpeg/0/aspect", "r").read()
                                        if aspect_str == "1": # 4:3
-                                               ret = 1.333333333
+                                               ret = (4,3)
                                except IOError:
                                        pass
                        else:  # 4:3
-                               ret = 1.333333333
+                               ret = (4,3)
                return ret
 
        def __init__(self):