summaryrefslogtreecommitdiff
path: root/dxr3colormanager.h
blob: 4f95c0250ad64910441c11b513b7b523db058e5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/***************************************************************************
                          dxr3colormanager.h  -  description
                             -------------------
    begin                : Tue Oct 22 2002
    copyright            : (C) 2002 by Stefan Schluenss
    email                : vdr@schluenss.de
 ***************************************************************************/

/*
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */

#ifndef _DXR3COLORMANAGER_H_
#define _DXR3COLORMANAGER_H_
/*
// ==================================
struct rectangular_area
{
    rectangular_area() :
	m_startrow(0), m_endrow(0), m_startcol(0), m_endcol(0)	{}

private:
    size_t m_startrow;
    size_t m_endrow;
    size_t m_startcol;
    size_t m_endcol;

    unsigned int Colors[4];
    unsigned int Opac[4];
}
*/

/**SPU-ColorManager
 *@author Stefan Schluenss
 */

#define OSD_SPU_CM_DUMP 0

#define MAX_NO_OF_SECTIONS 15
#define MAX_NO_OF_REGIONS 100


// ==================================
class xSection
{
public:
    xSection(int x);
    bool HasColor(unsigned int color, unsigned char &ColorIndex);
    unsigned char AddColor(unsigned int color);
    bool AllColorsUsed(bool FirstLine) {
	//DIAG("AllColorsUsed: %d\n",NrOfColors);
	return(NrOfColors >= (FirstLine ? 3 : 4));
    };
    int X1;
    int X2;
    int NrOfColors;
    unsigned int Colors[4];
    unsigned int Opac[4];
};

// ==================================
class yRegion
{
public:
    yRegion() : Y1(0), Y2(0), N(0) {}

    /** No descriptions */
    void AddSection(int first, int last, unsigned int color,
		    unsigned int opac);
    int Y1;
    int Y2;
    int N;

    xSection* Section[MAX_NO_OF_SECTIONS];
};

// ==================================
class cColorManager
{
public:
    cColorManager();
    ~cColorManager();

    void EncodeColors(int width, int height, unsigned char* smap,
		      unsigned char* dmap);

    /** Sets a new color on the OSD */
    unsigned char AddColor(int x, int y, unsigned char color,
			   unsigned char &ColorIndex);

    /** Encodes the color information as highlight spu data */
    unsigned char* GetSpuData(int &len);

private:
    yRegion *hlr[MAX_NO_OF_REGIONS];
    yRegion *curRegion;
    int NrOfRegions;
    unsigned char spudata[(4+6*MAX_NO_OF_SECTIONS)*MAX_NO_OF_REGIONS+7];
    xSection *curSection;
    int curSectionIndex;

    /** Opens a new highlight region */
    void OpenRegion(int y);
    /** Closes the spu-highlight region */
    void CloseRegion(int y);

    void NewSection(int x);
    void FirstSection(void);
    void NextSection(void);
};

#endif /*_DXR3COLORMANAGER_H_*/

// Local variables:
// mode: c++
// c-file-style: "stroustrup"
// c-file-offsets: ((inline-open . 0))
// tab-width: 4;
// indent-tabs-mode: nil
// End: