diff options
author | scop <scop> | 2005-04-05 18:54:01 +0000 |
---|---|---|
committer | scop <scop> | 2005-04-05 18:54:01 +0000 |
commit | 410566af59dd7b658e45a303d6eec2c0f25a0016 (patch) | |
tree | 51143267d821f24e4dc7c1e4602aba8b3244cba9 /dxr3palettemanager.c | |
parent | e879e3f9315a471f7a4b15dcb28ed6e6f7b60604 (diff) | |
download | vdr-plugin-dxr3-410566af59dd7b658e45a303d6eec2c0f25a0016.tar.gz vdr-plugin-dxr3-410566af59dd7b658e45a303d6eec2c0f25a0016.tar.bz2 |
More palette stuff fixing/cleanups from Martin Cap and Luca Olivetti.
Diffstat (limited to 'dxr3palettemanager.c')
-rw-r--r-- | dxr3palettemanager.c | 121 |
1 files changed, 0 insertions, 121 deletions
diff --git a/dxr3palettemanager.c b/dxr3palettemanager.c deleted file mode 100644 index 058186b..0000000 --- a/dxr3palettemanager.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * dxr3palettemanager.c: - * - * See the main source file 'dxr3.c' for copyright information and - * how to reach the author. - * - */ - -/* - ToDo: - - cDxr3PaletteManager: Should we use here std::vector? -*/ - -#include <string.h> -#include "dxr3palettemanager.h" -#include "dxr3tools.h" - -// ================================== -//! constructor -cDxr3PaletteManager::cDxr3PaletteManager() -{ - memset(m_colors, 0, sizeof(int) * MAX_COLORS); - memset(m_users, 0, sizeof(int) * MAX_COLORS); - memset(m_pal, 0, sizeof(uint32_t) * MAX_COLORS); - m_changed = false; -}; - -// ================================== -void cDxr3PaletteManager::AddColor(int color) -{ - int freeIndex = MAX_COLORS; - bool found = false; - - for (int i = 0; i < MAX_COLORS && !found; ++i) - { - if (color == m_colors[i]) - { - if (m_users[i] == 0) m_changed = true; - ++m_users[i]; - found = true; - } - if (m_users[i] == 0 && freeIndex >= MAX_COLORS) - { - freeIndex = i; - } - } - if (!found && freeIndex < MAX_COLORS) - { - m_colors[freeIndex] = color; - m_users[freeIndex] = 1; - m_changed = true; - } -} - -// ================================== -void cDxr3PaletteManager::RemoveColor(int color) -{ - bool found = 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; - } - } -} - -// ================================== -int cDxr3PaletteManager::GetIndex(int color) -{ - bool found = false; - int index = 0; - for (int i = 0; i < MAX_COLORS && !found; ++i) - { - if (color == m_colors[i]) - { - index = i; - found = true; - } - } - return index; -} - -// ================================== -int cDxr3PaletteManager::GetCount() -{ - return MAX_COLORS; -} - -// ================================== -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; -} - -// ================================== -uint32_t* cDxr3PaletteManager::GetPalette() -{ - for (int i = 0; i < MAX_COLORS; ++i) - { - m_pal[i] = Tools::Rgb2YCrCb(m_colors[i]); - } - - return m_pal; -} - -// ================================== -void cDxr3PaletteManager::Clear() -{ - memset(m_users, 0, sizeof(int) * MAX_COLORS); -} |