Home

Dokumentation

Impressum

Dokumentation VDR
 

Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

dvbspu.h

Go to the documentation of this file.
00001 
00014 #ifndef __DVBSPU_H
00015 #define __DVBSPU_H
00016 
00017 #include <inttypes.h>
00018 
00019 #include "osdbase.h"
00020 #include "spu.h"
00021 
00022 typedef struct sDvbSpuPalDescr {
00023     uint8_t index;
00024     uint8_t trans;
00025 
00026     bool operator != (const sDvbSpuPalDescr pd) const {
00027         return index != pd.index && trans != pd.trans;
00028     };
00029 } aDvbSpuPalDescr[4];
00030 
00031 typedef struct sDvbSpuRect {
00032     int x1, y1;
00033     int x2, y2;
00034 
00035     int width() {
00036         return x2 - x1 + 1;
00037     };
00038     int height() {
00039         return y2 - y1 + 1;
00040     };
00041 
00042     bool operator != (const sDvbSpuRect r) const {
00043         return r.x1 != x1 || r.y1 != y1 || r.x2 != x2 || r.y2 != y2;
00044     };
00045 }
00046 
00047 sDvbSpuRect;
00048 
00050 class cDvbSpuPalette {
00051   private:
00052     uint32_t palette[16];
00053 
00054   private:
00055     uint32_t yuv2rgb(uint32_t yuv_color);
00056 
00057   public:
00058     void setPalette(const uint32_t * pal);
00059     uint32_t getColor(uint8_t idx, uint8_t trans) const;
00060 };
00061 
00062 
00064 class cDvbSpuBitmap {
00065 
00066   public:
00067   private:
00068     sDvbSpuRect bmpsize;
00069     sDvbSpuRect minsize[4];
00070     uint8_t *bmp;
00071 
00072   private:
00073     void putPixel(int xp, int yp, int len, uint8_t colorid);
00074     void putFieldData(int field, uint8_t * data, uint8_t * endp);
00075 
00076   public:
00077      cDvbSpuBitmap(sDvbSpuRect size,
00078                    uint8_t * fodd, uint8_t * eodd,
00079                    uint8_t * feven, uint8_t * eeven);
00080     ~cDvbSpuBitmap();
00081 
00082     bool getMinSize(const aDvbSpuPalDescr paldescr,
00083                     sDvbSpuRect & size) const;
00084     cBitmap *getBitmap(const aDvbSpuPalDescr paldescr,
00085                        const cDvbSpuPalette & pal,
00086                        sDvbSpuRect & size) const;
00087 };
00088 
00089 
00091 class cDvbSpuDecoder:public cSpuDecoder {
00092   private:
00093     cOsdBase * osd;
00094 
00098     uint8_t *spu;
00099     uint32_t spupts;
00100     bool clean;
00101     bool ready;
00102 
00103     enum spFlag { spNONE, spHIDE, spSHOW, spMENU };
00104     spFlag state;
00105 
00106      cSpuDecoder::eScaleMode scaleMode;
00107 
00111     bool highlight;
00112     sDvbSpuRect hlpsize;
00113     aDvbSpuPalDescr hlpDescr;
00114 
00118     cDvbSpuPalette palette;
00119 
00123     sDvbSpuRect size;
00124     aDvbSpuPalDescr palDescr;
00125 
00126     uint16_t DCSQ_offset;
00127     uint16_t prev_DCSQ_offset;
00128 
00129     cDvbSpuBitmap *spubmp;
00130   private:
00131     int cmdOffs(void) {
00132         return ((spu[2] << 8) | spu[3]);
00133     };
00134     int spuSize(void) {
00135         return ((spu[0] << 8) | spu[1]);
00136     };
00137 
00138     int ScaleYcoord(int value);
00139     int ScaleYres(int value);
00140     void DrawBmp(sDvbSpuRect & size, cBitmap * bmp);
00141 
00142     void Draw();
00143     void Hide();
00144 
00145   public:
00146     cDvbSpuDecoder();
00147     ~cDvbSpuDecoder();
00148 
00149     int setTime(uint32_t pts);
00150 
00151     void setScaleMode(cSpuDecoder::eScaleMode ScaleMode);
00152     void setPalette(uint32_t * pal);
00153     void setHighlight(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey,
00154                       uint32_t palette);
00155     void clearHighlight(void);
00156     void Empty(void);
00157     void processSPU(uint32_t pts, uint8_t * buf);
00158 };
00159 
00160 inline uint32_t cDvbSpuPalette::yuv2rgb(uint32_t yuv_color)
00161 {
00162     int Y, Cb, Cr;
00163     int Ey, Epb, Epr;
00164     int Eg, Eb, Er;
00165     uint32_t result;
00166 
00167     Y = (yuv_color >> 16) & 0xff;
00168     Cb = (yuv_color) & 0xff;
00169     Cr = (yuv_color >> 8) & 0xff;
00170 
00171     Ey = (Y - 16);
00172     Epb = (Cb - 128);
00173     Epr = (Cr - 128);
00174     /* ITU-R 709
00175        Eg = (298*Ey - 55*Epb - 137*Epr)/256;
00176        Eb = (298*Ey + 543*Epb)/256;
00177        Er = (298*Ey + 460*Epr)/256;
00178      */
00179     /* FCC ~= mediaLib */
00180     Eg = (298 * Ey - 100 * Epb - 208 * Epr) / 256;
00181     Eb = (298 * Ey + 516 * Epb) / 256;
00182     Er = (298 * Ey + 408 * Epr) / 256;
00183 
00184     if (Eg > 255)
00185         Eg = 255;
00186     if (Eg < 0)
00187         Eg = 0;
00188 
00189     if (Eb > 255)
00190         Eb = 255;
00191     if (Eb < 0)
00192         Eb = 0;
00193 
00194     if (Er > 255)
00195         Er = 255;
00196     if (Er < 0)
00197         Er = 0;
00198 
00199     result = (Eb << 16) | (Eg << 8) | Er;
00200 
00201     return result;
00202 }
00203 
00204 inline uint32_t cDvbSpuPalette::getColor(uint8_t idx, uint8_t trans) const
00205 {
00206     uint8_t t = trans == 0x0f ? 0xff : trans << 4;
00207     return palette[idx] | (t << 24);
00208 }
00209 
00210 #endif                          // __DVBSPU_H
00211 

Generated on Wed Feb 5 23:30:08 2003 for VDR by doxygen1.3-rc2