diff -ur vdr-1.3.13_orig/dvbspu.c vdr-1.3.13/dvbspu.c --- vdr-1.3.13_orig/dvbspu.c Sun Oct 17 18:39:51 2004 +++ vdr-1.3.13/dvbspu.c Thu Oct 21 22:06:05 2004 @@ -227,6 +227,7 @@ spu = NULL; osd = NULL; spubmp = NULL; + allowedShow = false; } cDvbSpuDecoder::~cDvbSpuDecoder() @@ -236,7 +237,7 @@ delete osd; } -void cDvbSpuDecoder::processSPU(uint32_t pts, uint8_t * buf) +void cDvbSpuDecoder::processSPU(uint32_t pts, uint8_t * buf, bool AllowedShow) { setTime(pts); @@ -252,6 +253,7 @@ prev_DCSQ_offset = 0; clean = true; + allowedShow = AllowedShow; } void cDvbSpuDecoder::setScaleMode(cSpuDecoder::eScaleMode ScaleMode) @@ -319,25 +321,43 @@ return value; } -void cDvbSpuDecoder::DrawBmp(sDvbSpuRect & size, cBitmap * bmp) -{ - int x2 = size.x2; - while ((x2 - size.x1 + 1) & 0x03) - x2++; - tArea Area = { size.x1, size.y1, x2, size.y2, 2 }; - osd->SetAreas(&Area, 1); - if (x2 > size.x2) - osd->DrawRectangle(size.x2 + 1, size.y1, x2, size.y2, clrTransparent); - osd->DrawBitmap(size.x1, size.y1, *bmp); - delete bmp; +sDvbSpuRect cDvbSpuDecoder::CalcAreaSize(sDvbSpuRect fgsize, cBitmap *fgbmp, sDvbSpuRect bgsize, cBitmap *bgbmp) { + sDvbSpuRect size; + if (fgbmp && bgbmp) { + size.x1 = min(fgsize.x1, bgsize.x1); + size.y1 = min(fgsize.y1, bgsize.y1); + size.x2 = max(fgsize.x2, bgsize.x2); + size.y2 = max(fgsize.y2, bgsize.y2); + } + else if (fgbmp) { + size.x1 = fgsize.x1; + size.y1 = fgsize.y1; + size.x2 = fgsize.x2; + size.y2 = fgsize.y2; + } + else if (bgbmp) { + size.x1 = bgsize.x1; + size.y1 = bgsize.y1; + size.x2 = bgsize.x2; + size.y2 = bgsize.y2; + } + else { + size.x1 = 0; + size.y1 = 0; + size.x2 = 0; + size.y2 = 0; + } + return size; } void cDvbSpuDecoder::Draw(void) { - Hide(); +// Hide(); - if (!spubmp) + if (!spubmp) { + Hide(); return; + } cBitmap *fg = NULL; cBitmap *bg = NULL; @@ -362,22 +382,33 @@ } } + sDvbSpuRect areaSize = CalcAreaSize(hlsize, fg, bgsize, bg); + + if(!fg || !bg || !osd) { + Hide(); + } + if (bg || fg) { - if (osd == NULL) + if (osd == NULL) { if ((osd = cOsdProvider::NewOsd(0, 0)) == NULL) { + delete fg; + delete bg; dsyslog("NewOsd failed\n"); return; } + int x2 = areaSize.x2; + while ((x2 - areaSize.x1 + 1) & 0x03) + x2++; + tArea Area = { areaSize.x1, areaSize.y1, x2, areaSize.y2, (fg && bg) ? 4 : 2 }; + osd->SetAreas(&Area, 1); + } - if (fg) - DrawBmp(hlsize, fg); - - if (bg) - DrawBmp(bgsize, bg); - + if (bg) osd->DrawBitmap(bgsize.x1, bgsize.y1, *bg); + if (fg) osd->DrawBitmap(hlsize.x1, hlsize.y1, *fg); + delete fg; + delete bg; osd->Flush(); } - clean = true; } @@ -503,7 +534,7 @@ } else if (!clean) state = spSHOW; - if (state == spSHOW || state == spMENU) + if ((state == spSHOW && allowedShow) || state == spMENU) Draw(); if (state == spHIDE) diff -ur vdr-1.3.13_orig/dvbspu.h vdr-1.3.13/dvbspu.h --- vdr-1.3.13_orig/dvbspu.h Sun Oct 17 18:39:51 2004 +++ vdr-1.3.13/dvbspu.h Thu Oct 21 22:06:17 2004 @@ -120,6 +120,7 @@ uint16_t prev_DCSQ_offset; cDvbSpuBitmap *spubmp; + bool allowedShow; private: int cmdOffs(void) { return ((spu[2] << 8) | spu[3]); @@ -130,8 +131,7 @@ int ScaleYcoord(int value); int ScaleYres(int value); - void DrawBmp(sDvbSpuRect & size, cBitmap * bmp); - + sDvbSpuRect CalcAreaSize(sDvbSpuRect fgsize, cBitmap *fgbmp, sDvbSpuRect bgsize, cBitmap *bgbmp); public: cDvbSpuDecoder(); ~cDvbSpuDecoder(); @@ -147,7 +147,7 @@ void Hide(void); void Draw(void); bool IsVisible(void) { return osd != NULL; } - void processSPU(uint32_t pts, uint8_t * buf); + void processSPU(uint32_t pts, uint8_t * buf, bool AllowedShow); }; // --- cDvbSpuPalette ------------------------------------------- diff -ur vdr-1.3.13_orig/spu.h vdr-1.3.13/spu.h --- vdr-1.3.13_orig/spu.h Sun Oct 17 18:39:51 2004 +++ vdr-1.3.13/spu.h Thu Oct 21 22:06:27 2004 @@ -35,7 +35,7 @@ virtual void Hide(void) = 0; virtual void Draw(void) = 0; virtual bool IsVisible(void) = 0; - virtual void processSPU(uint32_t pts, uint8_t * buf) = 0; + virtual void processSPU(uint32_t pts, uint8_t * buf, bool AllowedShow) = 0; }; #endif // __SPU_VDR_H