39#define DEBUG(format, args...) printf (format, ## args)
41#define DEBUG(format, args...) void()
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);
165static 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])
259 DEBUG(
"dvbspu SetSpuScaling OsdSize %d x %d\n", OsdWidth, OsdHeight);
273 xscaling = (double)OsdWidth / Width;
274 yscaling = (double)OsdHeight / Height;
283 DEBUG(
"SPU pushData: pts: %d\n", pts);
317 uint16_t ex, uint16_t ey,
321 for (
int i = 0; i < 4; i++) {
322 pld[i].index = 0xf & (
palette >> (16 + 4 * i));
323 pld[i].trans = 0xf & (
palette >> (4 * i));
332 DEBUG(
"setHighlight: %d,%d x %d,%d\n", sx, sy, ex, ey);
357 if (fgbmp && bgbmp) {
387 for (
int i = 0; i < 4; i++) {
388 if (paldescr[i].trans != 0) {
392 return col > 2 ? 2 : 1;
442 bgdrawsize.
x2 = bgdrawsize.
x1 + bg->
Width();
454 tArea Area = { areaSize.
x1, areaSize.
y1, areaSize.
x2, areaSize.
y2, 4 };
456 DEBUG(
"dvbspu CanHandleAreas (%d,%d)x(%d,%d), 4 failed\n", areaSize.
x1, areaSize.
y1, areaSize.
x2, areaSize.
y2);
464 bool setarea =
false;
473 if (hlsize.
x1 > hlsize.
x2 || hlsize.
y1 > hlsize.
y2)
474 hlsize.
x1 = hlsize.
x2 = hlsize.
y1 = hlsize.
y2 = 0;
483#define DIV(a, b) (a/b)?:1
484 for (
int d = 1; !setarea && d <= 2; d++) {
489 if ((Area.
Width() & 7) != 0)
490 Area.
x2 += 8 - (Area.
Width() & 7);
497 if (!setarea && fg && bg) {
498 tArea Area_Both [2] = {
502 if (!Area_Both[0].Intersects(Area_Both[1])) {
504 if ((Area_Both[0].Width() & 7) != 0)
505 Area_Both[0].
x2 += 8 - (Area_Both[0].
Width() & 7);
506 if ((Area_Both[1].Width() & 7) != 0)
507 Area_Both[1].
x2 += 8 - (Area_Both[1].
Width() & 7);
515 DEBUG(
"dvbspu: reduced AreaSize (%d, %d) (%d, %d) Bpp %d\n", areaSize.
x1, areaSize.
y1, areaSize.
x2, areaSize.
y2, (fg && bg) ? 4 : 2);
517 dsyslog(
"dvbspu: reduced AreaSize (%d, %d) (%d, %d) Bpp %d failed", areaSize.
x1, areaSize.
y1, areaSize.
x2, areaSize.
y2, (fg && bg) ? 4 : 2);
570 if ((pts != 0) && (exec_time > pts))
572 DEBUG(
"offs = %d, rel = %d, time = %d, pts = %d, diff = %d\n",
573 i,
spuU32(i) * 1024, exec_time, pts, exec_time - pts);
583 DEBUG(
"offs = %d, DCSQ = %d, prev_DCSQ = %d\n",
590 DEBUG(
"\tshow subpicture\n");
596 DEBUG(
"\thide subpicture\n");
624 DEBUG(
"\t(%d, %d) x (%d, %d)\n",
632 DEBUG(
"\todd = %d even = %d\n", fodd, feven);
643 DEBUG(
"\tspu menu\n");
650 esyslog(
"invalid sequence in control header (%.2x)",
656 if (fodd != 0 && feven != 0) {
cBitmap * Scaled(double FactorX, double FactorY, bool AntiAlias=false) const
Creates a copy of this bitmap, scaled by the given factors.
void SetIndex(int x, int y, tIndex Index)
Sets the index at the given coordinates to Index.
cBitmap(int Width, int Height, int Bpp, int X0=0, int Y0=0)
Creates a bitmap with the given Width, Height and color depth (Bpp).
static cDevice * PrimaryDevice(void)
Returns the primary device.
virtual void GetOsdSize(int &Width, int &Height, double &PixelAspect)
Returns the Width, Height and PixelAspect ratio the OSD should use to best fit the resolution of the ...
int getMinBpp(const aDvbSpuPalDescr paldescr)
void putFieldData(int field, uint8_t *data, uint8_t *endp)
void putPixel(int xp, int yp, int len, uint8_t colorid)
bool getMinSize(const aDvbSpuPalDescr paldescr, sDvbSpuRect &size) const
cBitmap * getBitmap(const aDvbSpuPalDescr paldescr, const cDvbSpuPalette &pal, sDvbSpuRect &size) const
cDvbSpuBitmap(sDvbSpuRect size, uint8_t *fodd, uint8_t *eodd, uint8_t *feven, uint8_t *eeven)
uint16_t prev_DCSQ_offset
void processSPU(uint32_t pts, uint8_t *buf, bool AllowedShow)
void setHighlight(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint32_t palette)
void setPalette(uint32_t *pal)
void clearHighlight(void)
int setTime(uint32_t pts)
void setScaleMode(cSpuDecoder::eScaleMode ScaleMode)
int CalcAreaBpp(cBitmap *fgbmp, cBitmap *bgbmp)
sDvbSpuRect CalcAreaSize(sDvbSpuRect fgsize, cBitmap *fgbmp, sDvbSpuRect bgsize, cBitmap *bgbmp)
void setResolution(int Xres, int Yres)
cSpuDecoder::eScaleMode scaleMode
void setPalette(const uint32_t *pal)
uint32_t yuv2rgb(uint32_t yuv_color)
uint32_t getColor(uint8_t idx, uint8_t trans) const
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.
virtual eOsdError SetAreas(const tArea *Areas, int NumAreas)
Sets the sub-areas to the given areas.
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 ...
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 SetColor(int Index, tColor Color)
Sets the palette entry at Index to Color.
#define CMD_SPU_SET_PXD_OFFSET
static uint8_t getBits(uint8_t *&data, uint8_t &bitf)
#define DEBUG(format, args...)
#define CMD_SPU_SET_PALETTE
#define CMD_SPU_CHG_COLCON
#define CMD_SPU_SET_ALPHA
struct sDvbSpuPalDescr aDvbSpuPalDescr[4]