Go to the documentation of this file.
39 #define DEBUG(format, args...) printf (format, ## args)
41 #define DEBUG(format, args...)
48 for (
int i = 0; i < 16; i++)
54 #define setMin(a, b) if (a > b) a = b
55 #define setMax(a, b) if (a < b) a = b
61 #define revRect(r1, r2) { r1.x1 = r2.x2; r1.y1 = r2.y2; r1.x2 = r2.x1; r1.y2 = r2.y1; }
64 uint8_t * fodd, uint8_t * eodd,
65 uint8_t * feven, uint8_t * eeven)
79 bmp =
new uint8_t[MemSize];
82 memset(
bmp, 0, MemSize);
110 for (
int i = 0; i < 4; i++) {
112 pal.
getColor(paldescr[i].index, paldescr[i].trans);
118 for (
int yp = 0; yp < h; yp++) {
119 for (
int xp = 0; xp < w; xp++) {
133 for (
int i = 0; i < 4; i++) {
134 if (paldescr[i].trans != 0) {
147 DEBUG(
"MinSize: (%d, %d) x (%d, %d)\n",
148 size.
x1, size.
y1, size.
x2, size.
y2);
149 if (size.
x1 > size.
x2 || size.
y1 > size.
y2)
158 memset(
bmp +
spuXres * yp + xp, colorid, len);
165 static uint8_t
getBits(uint8_t * &data, uint8_t & bitf)
183 while (data < endp) {
184 uint16_t vlc =
getBits(data, bitf);
186 vlc = (vlc << 4) |
getBits(data, bitf);
188 vlc = (vlc << 4) |
getBits(data, bitf);
190 vlc = (vlc << 4) |
getBits(data, bitf);
195 uint8_t color = vlc & 0x03;
218 #define CMD_SPU_MENU 0x00
219 #define CMD_SPU_SHOW 0x01
220 #define CMD_SPU_HIDE 0x02
221 #define CMD_SPU_SET_PALETTE 0x03
222 #define CMD_SPU_SET_ALPHA 0x04
223 #define CMD_SPU_SET_SIZE 0x05
224 #define CMD_SPU_SET_PXD_OFFSET 0x06
225 #define CMD_SPU_CHG_COLCON 0x07
226 #define CMD_SPU_EOF 0xff
228 #define spuU32(i) ((spu[i] << 8) + spu[i+1])
256 cDevice::PrimaryDevice()->GetOsdSize(OsdWidth, OsdHeight, VideoAspect);
257 DEBUG(
"dvbspu SetSpuScaling OsdSize %d x %d\n", OsdWidth, OsdHeight);
271 xscaling = (double)OsdWidth / Width;
272 yscaling = (double)OsdHeight / Height;
281 DEBUG(
"SPU pushData: pts: %d\n", pts);
307 uint16_t ex, uint16_t ey,
311 for (
int i = 0; i < 4; i++) {
313 pld[i].trans = 0xf & (
palette >> (4 * i));
322 DEBUG(
"setHighlight: %d,%d x %d,%d\n", sx, sy, ex, ey);
347 if (fgbmp && bgbmp) {
377 for (
int i = 0; i < 4; i++) {
378 if (paldescr[i].trans != 0) {
382 return col > 2 ? 2 : 1;
432 bgdrawsize.
x2 = bgdrawsize.
x1 + bg->
Width();
444 tArea Area = { areaSize.
x1, areaSize.
y1, areaSize.
x2, areaSize.
y2, 4 };
446 DEBUG(
"dvbspu CanHandleAreas (%d,%d)x(%d,%d), 4 failed\n", areaSize.
x1, areaSize.
y1, areaSize.
x2, areaSize.
y2);
454 bool setarea =
false;
463 if (hlsize.
x1 > hlsize.
x2 || hlsize.
y1 > hlsize.
y2)
464 hlsize.
x1 = hlsize.
x2 = hlsize.
y1 = hlsize.
y2 = 0;
473 #define DIV(a, b) (a/b)?:1
474 for (
int d = 1; !setarea && d <= 2; d++) {
479 if ((Area.
Width() & 7) != 0)
480 Area.
x2 += 8 - (Area.
Width() & 7);
487 if (!setarea && fg && bg) {
488 tArea Area_Both [2] = {
492 if (!Area_Both[0].Intersects(Area_Both[1])) {
494 if ((Area_Both[0].Width() & 7) != 0)
495 Area_Both[0].
x2 += 8 - (Area_Both[0].
Width() & 7);
496 if ((Area_Both[1].Width() & 7) != 0)
497 Area_Both[1].x2 += 8 - (Area_Both[1].Width() & 7);
505 DEBUG(
"dvbspu: reduced AreaSize (%d, %d) (%d, %d) Bpp %d\n", areaSize.
x1, areaSize.
y1, areaSize.
x2, areaSize.
y2, (fg && bg) ? 4 : 2);
507 dsyslog(
"dvbspu: reduced AreaSize (%d, %d) (%d, %d) Bpp %d failed", areaSize.
x1, areaSize.
y1, areaSize.
x2, areaSize.
y2, (fg && bg) ? 4 : 2);
560 if ((pts != 0) && (exec_time > pts))
562 DEBUG(
"offs = %d, rel = %d, time = %d, pts = %d, diff = %d\n",
563 i,
spuU32(i) * 1024, exec_time, pts, exec_time - pts);
573 DEBUG(
"offs = %d, DCSQ = %d, prev_DCSQ = %d\n",
580 DEBUG(
"\tshow subpicture\n");
586 DEBUG(
"\thide subpicture\n");
614 DEBUG(
"\t(%d, %d) x (%d, %d)\n",
622 DEBUG(
"\todd = %d even = %d\n", fodd, feven);
633 DEBUG(
"\tspu menu\n");
640 esyslog(
"invalid sequence in control header (%.2x)",
646 if (fodd != 0 && feven != 0) {
static cOsd * NewOsd(int Left, int Top, uint Level=OSD_LEVEL_DEFAULT)
Returns a pointer to a newly created cOsd object, which will be located at the given coordinates.
void SetIndex(int x, int y, tIndex Index)
Sets the index at the given coordinates to Index.
cBitmap * getBitmap(const aDvbSpuPalDescr paldescr, const cDvbSpuPalette &pal, sDvbSpuRect &size) const
#define CMD_SPU_CHG_COLCON
void setHighlight(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint32_t palette)
void clearHighlight(void)
cBitmap * Scaled(double FactorX, double FactorY, bool AntiAlias=false) const
Creates a copy of this bitmap, scaled by the given factors.
struct sDvbSpuPalDescr aDvbSpuPalDescr[4]
#define DEBUG(format, args...)
void setPalette(const uint32_t *pal)
uint32_t yuv2rgb(uint32_t yuv_color)
#define CMD_SPU_SET_ALPHA
void putFieldData(int field, uint8_t *data, uint8_t *endp)
#define CMD_SPU_SET_PXD_OFFSET
int setTime(uint32_t pts)
uint16_t prev_DCSQ_offset
bool getMinSize(const aDvbSpuPalDescr paldescr, sDvbSpuRect &size) const
void SetColor(int Index, tColor Color)
Sets the palette entry at Index to Color.
sDvbSpuRect CalcAreaSize(sDvbSpuRect fgsize, cBitmap *fgbmp, sDvbSpuRect bgsize, cBitmap *bgbmp)
cDvbSpuBitmap(sDvbSpuRect size, uint8_t *fodd, uint8_t *eodd, uint8_t *feven, uint8_t *eeven)
#define CMD_SPU_SET_PALETTE
void putPixel(int xp, int yp, int len, uint8_t colorid)
virtual eOsdError SetAreas(const tArea *Areas, int NumAreas)
Sets the sub-areas to the given areas.
void setScaleMode(cSpuDecoder::eScaleMode ScaleMode)
uint32_t getColor(uint8_t idx, uint8_t trans) const
cSpuDecoder::eScaleMode scaleMode
virtual void DrawBitmap(int x, int y, const cBitmap &Bitmap, tColor ColorFg=0, tColor ColorBg=0, bool ReplacePalette=false, bool Overlay=false)
Sets the pixels in the OSD with the data from the given Bitmap, putting the upper left corner of the ...
int getMinBpp(const aDvbSpuPalDescr paldescr)
static uint8_t getBits(uint8_t *&data, uint8_t &bitf)
virtual eOsdError CanHandleAreas(const tArea *Areas, int NumAreas)
Checks whether the OSD can display the given set of sub-areas.
virtual void Flush(void)
Actually commits all data to the OSD hardware.
void processSPU(uint32_t pts, uint8_t *buf, bool AllowedShow)
int CalcAreaBpp(cBitmap *fgbmp, cBitmap *bgbmp)
void setPalette(uint32_t *pal)