vdr/dvbspu.h
Klaus Schmidinger 8b9350c091 Version 1.7.18
- Changed -O2 to -O3 in Make.config.template (reported by Matti Lehtimäki).
- Added a missing 'default' case in cPixmapMemory::DrawEllipse().
- Fixed some direct comparisons of double values.
- Fixed detecting frames on channels that broadcast with separate "fields" instead
  of complete frames.
- Made updating the editing marks during replay react faster in case the marks
  file has just been written (with a patch from Udo Richter).
- Fixed horizontal scaling of subtitles (reported by Reinhard Nissl).
- Stripped the note "The data returned by this function is only used for informational
  purposes (if any)" from the description of cDevice::GetVideoSize(). The VideoAspect
  is now used to properly scale subtitles.
- Fixed cUnbufferedFile::Seek() in case it is compiled without USE_FADVISE (thanks
  to Juergen Lock).
- Fixed the Language header of the Serbian translation file (thanks to Ville Skyttä).
- Added anti-aliasing when upscaling bitmaps, which improves the display of SD subtitles
  when replayed on an HD OSD (thanks to Reinhard Nissl for his help in debugging).
- Renamed cBitmap::Scale() to Scaled(), because it doesn't modify the bitmap itself,
  but rather returns a scaled copy.
- Fixed the description of cReceiver in PLUGINS.html, regarding detaching a receiver
  from its device before deleting it (reported by Winfried Köhler). This change in
  behavior was introduced in version 1.5.7.
- Fixed scaling subtitles in case the OSD size is exactly the same as the display
  size of the subtitles.
- Added a missing initialization to sDvbSpuRect (reported by Sergiu Dotenco).
- Replaced "%lld" and "%llX" print format specifiers with "PRId64" and "PRIX64" to
  avoid compiler warnings with gcc 4.5.2 (thanks to Sergiu Dotenco).
  On a personal note: I find it a step in the totally wrong direction that there
  have been macros introduced to work around this problem in the first place. There
  should have been "real" format specifiers defined that address this. These macros
  are nothing but an ugly workaround.
- Added Cancel(3) to ~cTrueColorDemo() in the "osddemo" plugin (thanks to Reinhard Nissl).
- Added a missing font deletion in cTrueColorDemo::Action() in the "osddemo" plugin
  (thanks to Reinhard Nissl).
- Fixed a buffer overflow in cFont::Bidi() (thanks to Reinhard Nissl).
- Added HD stream content identifiers to vdr.5 (thanks to Christoph Haubrich).
- Made cRecordingInfo::Read(FILE *f) private to avoid calls to it from outside
  cRecordingInfo or cRecording (reported by Mika Laitio).
- The dvbhddevice plugin is now part of the VDR distribution archive (thanks to
  Andreas Regel).
- Removed an obsolete local variable in dvbsdffosd.c (thanks to Paul Menzel).
- Fixed a possible NULL pointer dereference in osddemo.c (reported by Paul Menzel).
- Now using pkg-config to get fribidi, freetype and fontconfig cflags and libs (thanks
  to Ville Skyttä).
- The Makefile now also installs the include files (thanks to Ville Skyttä).
- Added handling of "ANSI/SCTE 57" descriptors (thanks too Rolf Ahrenberg).
- Avoiding an unecessary call to Recordings.ResetResume() (thanks to Reinhard
  Nissl).
2011-04-17 17:09:00 +02:00

207 lines
4.8 KiB
C++

/*
* SPU decoder for DVB devices
*
* Copyright (C) 2001.2002 Andreas Schultz <aschultz@warp10.net>
*
* This code is distributed under the terms and conditions of the
* GNU GENERAL PUBLIC LICENSE. See the file COPYING for details.
*
* parts of this file are derived from the OMS program.
*
* $Id: dvbspu.h 2.5 2011/03/27 14:50:48 kls Exp $
*/
#ifndef __DVBSPU_H
#define __DVBSPU_H
#include <inttypes.h>
#include "osd.h"
#include "spu.h"
#include "thread.h"
typedef struct sDvbSpuPalDescr {
uint8_t index;
uint8_t trans;
bool operator != (const sDvbSpuPalDescr pd) const {
return index != pd.index && trans != pd.trans;
};
} aDvbSpuPalDescr[4];
typedef struct sDvbSpuRect {
int x1, y1;
int x2, y2;
sDvbSpuRect(void) {
x1 = y1 = x2 = y2 = 0;
};
int width() const {
return x2 - x1 + 1;
};
int height() const {
return y2 - y1 + 1;
};
bool operator != (const sDvbSpuRect r) const {
return r.x1 != x1 || r.y1 != y1 || r.x2 != x2 || r.y2 != y2;
};
}
sDvbSpuRect;
// --- cDvbSpuPalette---------------------------------------------------------
class cDvbSpuPalette {
private:
uint32_t palette[16];
private:
uint32_t yuv2rgb(uint32_t yuv_color);
public:
void setPalette(const uint32_t * pal);
uint32_t getColor(uint8_t idx, uint8_t trans) const;
};
// --- cDvbSpuBitmap----------------------------------------------------------
class cDvbSpuBitmap {
private:
sDvbSpuRect bmpsize;
sDvbSpuRect minsize[4];
uint8_t *bmp;
private:
void putPixel(int xp, int yp, int len, uint8_t colorid);
void putFieldData(int field, uint8_t * data, uint8_t * endp);
public:
cDvbSpuBitmap(sDvbSpuRect size,
uint8_t * fodd, uint8_t * eodd,
uint8_t * feven, uint8_t * eeven);
~cDvbSpuBitmap();
bool getMinSize(const aDvbSpuPalDescr paldescr,
sDvbSpuRect & size) const;
int getMinBpp(const aDvbSpuPalDescr paldescr);
cBitmap *getBitmap(const aDvbSpuPalDescr paldescr,
const cDvbSpuPalette & pal,
sDvbSpuRect & size) const;
};
// --- cDvbSpuDecoder---------------------------------------------------------
class cDvbSpuDecoder:public cSpuDecoder {
private:
cOsd *osd;
cMutex mutex;
// processing state
uint8_t *spu;
uint32_t spupts;
bool clean;
bool ready;
bool restricted_osd;
enum spFlag { spNONE, spHIDE, spSHOW, spMENU };
spFlag state;
cSpuDecoder::eScaleMode scaleMode;
//highligh area
bool highlight;
sDvbSpuRect hlpsize;
aDvbSpuPalDescr hlpDescr;
//palette
cDvbSpuPalette palette;
// spu info's
sDvbSpuRect size;
aDvbSpuPalDescr palDescr;
uint16_t DCSQ_offset;
uint16_t prev_DCSQ_offset;
cDvbSpuBitmap *spubmp;
bool allowedShow;
private:
int cmdOffs(void) {
return ((spu[2] << 8) | spu[3]);
};
int spuSize(void) {
return ((spu[0] << 8) | spu[1]);
};
sDvbSpuRect CalcAreaSize(sDvbSpuRect fgsize, cBitmap *fgbmp, sDvbSpuRect bgsize, cBitmap *bgbmp);
int CalcAreaBpp(cBitmap *fgbmp, cBitmap *bgbmp);
public:
cDvbSpuDecoder();
~cDvbSpuDecoder();
int setTime(uint32_t pts);
cSpuDecoder::eScaleMode getScaleMode(void) { return scaleMode; }
void setScaleMode(cSpuDecoder::eScaleMode ScaleMode);
void setPalette(uint32_t * pal);
void setHighlight(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey,
uint32_t palette);
void clearHighlight(void);
void Empty(void);
void Hide(void);
void Draw(void);
bool IsVisible(void) { return osd != NULL; }
void processSPU(uint32_t pts, uint8_t * buf, bool AllowedShow);
};
// --- cDvbSpuPalette --------------------------------------------------------
inline uint32_t cDvbSpuPalette::yuv2rgb(uint32_t yuv_color)
{
int Y, Cb, Cr;
int Ey, Epb, Epr;
int Eg, Eb, Er;
Y = (yuv_color >> 16) & 0xff;
Cb = (yuv_color) & 0xff;
Cr = (yuv_color >> 8) & 0xff;
Ey = (Y - 16);
Epb = (Cb - 128);
Epr = (Cr - 128);
/* ITU-R 709
Eg = (298*Ey - 55*Epb - 137*Epr)/256;
Eb = (298*Ey + 543*Epb)/256;
Er = (298*Ey + 460*Epr)/256;
*/
/* FCC ~= mediaLib */
Eg = (298 * Ey - 100 * Epb - 208 * Epr) / 256;
Eb = (298 * Ey + 516 * Epb) / 256;
Er = (298 * Ey + 408 * Epr) / 256;
if (Eg > 255)
Eg = 255;
if (Eg < 0)
Eg = 0;
if (Eb > 255)
Eb = 255;
if (Eb < 0)
Eb = 0;
if (Er > 255)
Er = 255;
if (Er < 0)
Er = 0;
return Eb | (Eg << 8) | (Er << 16);
}
inline uint32_t cDvbSpuPalette::getColor(uint8_t idx, uint8_t trans) const
{
return palette[idx] | ((trans == 0x0f) ? 0xff000000 : (trans << 28));
}
#endif // __DVBSPU_H