From patchwork Wed Mar 30 11:49:11 2005 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Cap X-Patchwork-Id: 11836 Received: from smtp.compuserve.de ([62.52.27.101] helo=lnxc-641.srv.mediaways.net) by www.linuxtv.org with smtp (Exim 4.34) id 1DGbgz-000112-QY for vdr@linuxtv.org; Wed, 30 Mar 2005 13:49:02 +0200 Received: (qmail 19769 invoked by uid 501); 30 Mar 2005 11:49:15 -0000 X-Authenticated-Sender: macap20001 Received: from dsl-084-058-017-094.arcor-ip.net (dsl-084-058-017-094.arcor-ip.net [84.58.17.94]) by compuserve.de ([10.228.3.105]) with ESMTP via TCP; 30 Mar 2005 11:49:15 -0000 Message-ID: <424A9237.5030506@compuserve.de> Date: Wed, 30 Mar 2005 13:49:11 +0200 From: Martin Cap User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040616 Thunderbird/0.7 Mnenhy/0.6.0.101 X-Accept-Language: de-de, en-us, en MIME-Version: 1.0 To: vdr@linuxtv.org Subject: [vdr] Patch: dxr3plugin OSD don't turn pink X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Klaus Schmidinger's VDR List-Id: Klaus Schmidinger's VDR List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2005 11:49:08 -0000 Status: O X-Status: X-Keywords: X-UID: 1243 Hi ML, Hi Dxr3plugin lovers, Attached to this posting is a patch which fixes the odd osd-problem turning pink after returning from mplayer or after hardware-reset of the dxr3-card. I posted this fix in the german-vdr-forum a couple of months ago and it works for other users there, too. I haven't found the time to post it here (other users hadn't either:) )... so, here it is. Now what this patch does it change the behavior in cDxr3PaletteManager. It seems, that after returning from pmExtern_THIS_SHOULD_BE_AVOIDED, palette-data in cDxr3PaletteManager is somehow broken after resuscitation (whatever happens there, the code is a total mess). I avoid this by not copying & converting the whole data again in cDxr3PaletteManager::GetPalette through Tools::Rgb2YCrCb() (only when it has changed, indicated by member m_changed). Additionally, this should speed up GetPalette(). This patch may be applied to current CVS (HEAD or MAIN, also vdr-dxr3-0-2). diff -Nur dxr3_orig/dxr3palettemanager.c dxr3/dxr3palettemanager.c --- dxr3_orig/dxr3palettemanager.c 2005-03-30 12:59:51.935560952 +0200 +++ dxr3/dxr3palettemanager.c 2005-03-30 13:02:48.096780376 +0200 @@ -17,12 +17,12 @@ // ================================== //! constructor -cDxr3PaletteManager::cDxr3PaletteManager() +cDxr3PaletteManager::cDxr3PaletteManager() : + m_changed(false) { memset(m_colors, 0, sizeof(int) * MAX_COLORS); memset(m_users, 0, sizeof(int) * MAX_COLORS); - memset(m_pal, 0, sizeof(int) * MAX_COLORS); - m_changed = false; + memset(m_pal, 0, sizeof(uint32_t) * MAX_COLORS); }; // ================================== @@ -31,6 +31,8 @@ int freeIndex = MAX_COLORS; bool found = false; + m_changed = false; + for (int i = 0; i < MAX_COLORS && !found; ++i) { if (color == m_colors[i]) @@ -56,12 +58,17 @@ void cDxr3PaletteManager::RemoveColor(int color) { bool found = false; + + m_changed = false; + for (int i = 0; i < MAX_COLORS && !found; ++i) { if (color == m_colors[i]) { if (m_users[i] > 0) --m_users[i]; - found = true; + m_changed = found = true; + + } } } @@ -71,12 +78,15 @@ { bool found = false; int index = 0; + + m_changed = false; + for (int i = 0; i < MAX_COLORS && !found; ++i) { if (color == m_colors[i]) { index = i; - found = true; + m_changed = found = true; } } return index; @@ -92,24 +102,29 @@ int cDxr3PaletteManager::operator[](int index) { assert(index < MAX_COLORS && index > 0); + return m_colors[index]; } // ================================== bool cDxr3PaletteManager::HasChanged() { - bool retval = m_changed; - m_changed = false; - return retval; +// bool retval = m_changed; +// m_changed = false; + return m_changed; } // ================================== uint32_t* cDxr3PaletteManager::GetPalette() { - for (int i = 0; i < MAX_COLORS; ++i) - { - m_pal[i] = Tools::Rgb2YCrCb(m_colors[i]); - } - + if(m_changed) + { + for (int i = 0; i < MAX_COLORS; ++i) + { + m_pal[i] = Tools::Rgb2YCrCb(m_colors[i]); + } + } + return m_pal; } + diff -Nur dxr3_orig/dxr3palettemanager.h dxr3/dxr3palettemanager.h --- dxr3_orig/dxr3palettemanager.h 2005-03-30 12:59:51.937560648 +0200 +++ dxr3/dxr3palettemanager.h 2005-03-30 13:03:38.515115624 +0200 @@ -13,10 +13,12 @@ #include #include + // ================================== class cDxr3PaletteManager { public: + cDxr3PaletteManager(); ~cDxr3PaletteManager() {}; @@ -27,12 +29,13 @@ int GetIndex(int color); bool HasChanged(); uint32_t* GetPalette(); - private: static const int MAX_COLORS = 16; + int m_colors[MAX_COLORS]; uint32_t m_pal[MAX_COLORS]; int m_users[MAX_COLORS]; + bool m_changed; };