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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
/*
* dxr3spuencoder.h - encodes an OSD bitmap as subpicture
*
* Assimilated and adapted by
* Stefan Schluenss <dxr3_osd@schluenss.de>
* Nov. 2002
*
* Based on the subpicture encoding routines from MPlayer and
* the information given by
* Samuel Hocevar
* Michel Lespinasse
* and http://members.aol.com/mpucoder/DVD/spu.html
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _DXR3_INTERFACE_SPU_ENCODER_
#define _DXR3_INTERFACE_SPU_ENCODER_
#include <stdlib.h>
#include <linux/dvb/osd.h>
#include "dxr3vdrincludes.h"
#include "dxr3palettemanager.h"
#include "dxr3colormanager.h"
#include "dxr3interface.h"
#include "dxr3singleton.h"
// ==================================
#define MAXWINDOWS 8
#define DATASIZE 53220
#define OSDWIDTH 720
#define OSDWIDTH2 480
#define OSDHEIGHT 576
// ==================================
// basic infos about one osd "window"
struct sOSD_Window
{
size_t x0;
size_t y0;
size_t x1;
size_t y1;
unsigned char colors[16];
unsigned char opacity[16];
size_t NumColors;
};
// ==================================
// used to get active osd area
struct sRectal
{
sRectal() { Reset(); }
void Reset()
{
x0 = x1 = y0 = y1 = 0;
}
size_t x0;
size_t x1;
size_t y0;
size_t y1;
};
// ==================================
// our spu(data) with all needed routines
class cSpuData
{
public:
cSpuData(): count(0), malloc_size(0) {}
~cSpuData();
void Clear();
u_char* GetData() const { return data; }
// write operations
void WriteByte(uint8_t byte);
void WriteNibble(int *higher_nibble, uint8_t nibble);
void WriteRle(int *higher_nibble, int length, int color);
private:
u_char *data;
size_t count; // the count of bytes written
size_t malloc_size; // size of data
};
// ==================================
class cSPUEncoder : public Singleton<cSPUEncoder>
{
public:
cSPUEncoder();
~cSPUEncoder() {}
int Cmd(OSD_Command cmd, int color = 0, int x0 = 0, int y0 = 0, int x1 = 0, int y1 = 0, const void *data = 0);
private:
void CopyBlockIntoOSD(int linewidth, int x0,int y0, int x1, int y1, u_char *data);
void CalculateActiveOsdArea();
sOSD_Window m_windows[8];
size_t m_lastwindow;
// 'active' osd area
sRectal m_active_osd;
// our osd :)
u_char m_OSD[OSDWIDTH * OSDHEIGHT];
};
/*
// ==================================
struct pixbuf
{
int x, y;
u_int rgb[4];
u_char* pixels;
};
*/
// ==================================
/*
dxr3interface.c: In member function `void cDxr3Interface::ClearOsd()':
dxr3interface.c:984: error: `encodedata' undeclared (first use this function)
dxr3interface.c:984: error: (Each undeclared identifier is reported only once
for each function it appears in.)
dxr3interface.c:984: error: parse error before `;' token
dxr3interface.c:987: error: `ed' undeclared (first use this function)
make: *** [dxr3interface.o] Error 1
!!Fix this!!
*/
struct encodedata
{
u_char data[DATASIZE];
int count; // the count of bytes written
int oddstart;
int nibblewaiting;
};
/*
// ==================================
class cSPUEncoder : public Singleton<cSPUEncoder>
{
public:
cSPUEncoder();
~cSPUEncoder() {}
int Cmd(OSD_Command cmd, int color = 0, int x0 = 0, int y0 = 0, int x1 = 0, int y1 = 0, const void *data = 0);
private:
cSPUEncoder(cSPUEncoder&); // no copy constructor
// helper functions
void CopyBlockIntoOSD(int linewidth, int x0,int y0, int x1, int y1, u_char *data);
void EncodePixelbufRle(int x, int y, int w, int h, u_char *inbuf, int stride, encodedata *ed);
void ScaleOSD(double fac, unsigned char* buf, unsigned char NumColors=4);
void encode_put_nibble(encodedata* ed, u_char nibble);
void encode_pixels(encodedata* ed, int color, int number);
void encode_eol(encodedata* ed);
void encode_do_row(encodedata* ed, pixbuf* pb, int row);
void encode_do_control(int x,int y, encodedata* ed, pixbuf* pb);
void CalculateActiveOsdArea();
sOSD_Window m_windows[8];
cDxr3PaletteManager m_palManager;
cColorManager* m_ColorManager;
encodedata m_encodeddata;
int m_lastwindow;
// our osd :)
u_char OSD_Screen[OSDWIDTH * OSDHEIGHT];
u_char OSD_Screen2[OSDWIDTH * OSDHEIGHT];
u_char OSD_Screen3[OSDWIDTH * OSDHEIGHT];
// 'active' osd sizes
sRectal m_active_osd;
};
*/
#endif /*_DXR3_INTERFACE_SPU_ENCODER_*/
// Local variables:
// mode: c++
// c-file-style: "stroustrup"
// c-file-offsets: ((inline-open . 0))
// indent-tabs-mode: t
// End:
|