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).
--
---
Martin Cap
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 <stdlib.h>
#include <stdint.h>
+
// ==================================
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;
};