diff options
author | Casimir666 <casimir666@users.sourceforge.net> | 2009-11-11 22:16:30 +0300 |
---|---|---|
committer | Casimir666 <casimir666@users.sourceforge.net> | 2009-11-11 22:16:30 +0300 |
commit | ac39f6c9f79c7e4e2d0112cb0a53409c9c5087ea (patch) | |
tree | 49e793a53d910b555be7556d1c50e886a498efea /src/subtitles/DVBSub.h | |
parent | 24db6e20e4de08e7b0b2890423b6dca53a7670b6 (diff) |
Added : support for DVB subtitles
Fixed : several issues for HDMV subtitle display (better support for transparent subtitles, memory leak)
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@1335 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/subtitles/DVBSub.h')
-rw-r--r-- | src/subtitles/DVBSub.h | 223 |
1 files changed, 223 insertions, 0 deletions
diff --git a/src/subtitles/DVBSub.h b/src/subtitles/DVBSub.h new file mode 100644 index 000000000..6588673b6 --- /dev/null +++ b/src/subtitles/DVBSub.h @@ -0,0 +1,223 @@ +/*
+ * $Id$
+ *
+ * (C) 2006-2007 see AUTHORS
+ *
+ * This file is part of mplayerc.
+ *
+ * Mplayerc is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Mplayerc is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+#pragma once
+
+#include "BaseSub.h"
+
+#define MAX_REGIONS 10
+#define MAX_OBJECTS 10 // Max number of objects per region
+
+class CGolombBuffer;
+
+class CDVBSub : public CBaseSub
+{
+public:
+ CDVBSub(void);
+ ~CDVBSub(void);
+
+ virtual HRESULT ParseSample (IMediaSample* pSample);
+ virtual void Render(SubPicDesc& spd, REFERENCE_TIME rt, RECT& bbox);
+ virtual HRESULT GetTextureSize (POSITION pos, SIZE& MaxTextureSize, SIZE& VideoSize, POINT& VideoTopLeft);
+ virtual POSITION GetStartPosition(REFERENCE_TIME rt, double fps);
+ virtual POSITION GetNext(POSITION pos);
+ virtual REFERENCE_TIME GetStart(POSITION nPos);
+ virtual REFERENCE_TIME GetStop(POSITION nPos);
+ virtual void Reset();
+
+ // EN 300-743, table 2
+ enum DVB_SEGMENT_TYPE
+ {
+ NO_SEGMENT = 0xFFFF,
+ PAGE = 0x10,
+ REGION = 0x11,
+ CLUT = 0x12,
+ OBJECT = 0x13,
+ DISPLAY = 0x14,
+ END_OF_DISPLAY = 0x80
+ };
+
+ // EN 300-743, table 6
+ enum DVB_OBJECT_TYPE
+ {
+ OT_BASIC_BITMAP = 0x00,
+ OT_BASIC_CHAR = 0x01,
+ OT_COMPOSITE_STRING = 0x02
+ };
+
+ enum DVB_PAGE_STATE
+ {
+ DPS_NORMAL = 0x00,
+ DPS_ACQUISITION = 0x01,
+ DPS_MODE = 0x02,
+ DPS_RESERVED = 0x03
+ };
+
+ struct DVB_CLUT
+ {
+ BYTE id;
+ BYTE version_number;
+ BYTE Size;
+
+ HDMV_PALETTE Palette[256];
+
+ DVB_CLUT()
+ {
+ memset (Palette, 0, sizeof(Palette));
+ }
+ };
+
+ struct DVB_DISPLAY
+ {
+ BYTE version_number;
+ BYTE display_window_flag;
+ SHORT width;
+ SHORT height;
+ SHORT horizontal_position_minimun;
+ SHORT horizontal_position_maximum;
+ SHORT vertical_position_minimun;
+ SHORT vertical_position_maximum;
+
+ DVB_DISPLAY()
+ {
+ // Default value (§5.1.3)
+ version_number = 0;
+ width = 720;
+ height = 576;
+ }
+ };
+
+ struct DVB_OBJECT
+ {
+ SHORT object_id;
+ BYTE object_type;
+ BYTE object_provider_flag;
+ SHORT object_horizontal_position;
+ SHORT object_vertical_position;
+ BYTE foreground_pixel_code;
+ BYTE background_pixel_code;
+
+ DVB_OBJECT()
+ {
+ object_id = 0xFF;
+ object_type = 0;
+ object_provider_flag = 0;
+ object_horizontal_position = 0;
+ object_vertical_position = 0;
+ foreground_pixel_code = 0;
+ background_pixel_code = 0;
+ }
+ };
+
+ struct DVB_REGION
+ {
+ BYTE Id;
+ WORD HorizAddr;
+ WORD VertAddr;
+ BYTE version_number;
+ BYTE fill_flag;
+ WORD width;
+ WORD height;
+ BYTE level_of_compatibility;
+ BYTE depth;
+ BYTE CLUT_id;
+ BYTE _8_bit_pixel_code;
+ BYTE _4_bit_pixel_code;
+ BYTE _2_bit_pixel_code;
+ int ObjectCount;
+ DVB_OBJECT Objects[MAX_OBJECTS];
+
+ DVB_CLUT Clut;
+
+ DVB_REGION()
+ {
+ Id = 0;
+ HorizAddr = 0;
+ VertAddr = 0;
+ version_number = 0;
+ fill_flag = 0;
+ width = 0;
+ height = 0;
+ level_of_compatibility = 0;
+ depth = 0;
+ CLUT_id = 0;
+ _8_bit_pixel_code = 0;
+ _4_bit_pixel_code = 0;
+ _2_bit_pixel_code = 0;
+ }
+ };
+
+ class DVB_PAGE
+ {
+ public :
+ REFERENCE_TIME rtStart;
+ REFERENCE_TIME rtStop;
+ BYTE PageTimeOut;
+ BYTE PageVersionNumber;
+ BYTE PageState;
+ int RegionCount;
+ DVB_REGION Regions[MAX_REGIONS];
+ CAtlList<CompositionObject*> Objects;
+
+ DVB_PAGE()
+ {
+ PageTimeOut = 0;
+ PageVersionNumber = 0;
+ PageState = 0;
+ RegionCount = 0;
+ }
+
+ ~DVB_PAGE()
+ {
+ CompositionObject* pPage;
+ while (Objects.GetCount() > 0)
+ {
+ pPage = Objects.RemoveHead();
+ delete pPage;
+ }
+ }
+ };
+
+private:
+ static const REFERENCE_TIME INVALID_TIME = _I64_MIN;
+
+ DVB_SEGMENT_TYPE m_nCurSegment;
+ CAtlArray<BYTE> m_SegBuffer;
+ CAtlList<DVB_PAGE*> m_Pages;
+ CAutoPtr<DVB_PAGE> m_pCurrentPage;
+ DVB_DISPLAY m_Display;
+
+ void AppendBuffer(BYTE* pData, int nSize);
+ void ShrinkBuffer();
+ DVB_PAGE* FindPage(REFERENCE_TIME rt);
+ DVB_REGION* FindRegion(DVB_PAGE* pPage, BYTE bRegionId);
+ DVB_CLUT* FindClut(DVB_PAGE* pPage, BYTE bClutId);
+ CompositionObject* FindObject(DVB_PAGE* pPage, SHORT sObjectId);
+
+ HRESULT ParsePage(CGolombBuffer& gb, WORD wSegLength, CAutoPtr<DVB_PAGE>& pPage);
+ HRESULT ParseDisplay(CGolombBuffer& gb, WORD wSegLength);
+ HRESULT ParseRegion(CGolombBuffer& gb, WORD wSegLength);
+ HRESULT ParseClut(CGolombBuffer& gb, WORD wSegLength);
+ HRESULT ParseObject(CGolombBuffer& gb, WORD wSegLength);
+
+};
|