2 * (C) 2006-2012 see Authors.txt
4 * This file is part of MPC-HC.
6 * MPC-HC is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * MPC-HC is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
27 class CHdmvSub
: public CBaseSub
31 static const REFERENCE_TIME INVALID_TIME
= _I64_MIN
;
33 enum HDMV_SEGMENT_TYPE
{
37 PRESENTATION_SEG
= 0x16,
39 INTERACTIVE_SEG
= 0x18,
40 END_OF_DISPLAY
= 0x80,
46 struct VIDEO_DESCRIPTOR
{
49 BYTE bFrameRate
; // <= Frame rate here!
52 struct COMPOSITION_DESCRIPTOR
{
57 struct SEQUENCE_DESCRIPTOR
{
68 HDMV_PALETTE palette
[256];
70 HDMV_CLUT():id(0),version_number(0),size(0) { memset(palette
, 0, sizeof(palette
)); }
73 struct HDMV_PRESENTATION_SEGMENT
{
74 REFERENCE_TIME rtStart
;
75 REFERENCE_TIME rtStop
;
77 VIDEO_DESCRIPTOR video_descriptor
;
78 COMPOSITION_DESCRIPTOR composition_descriptor
;
80 byte palette_update_flag
;
85 CAtlList
<CompositionObject
*> objects
;
87 ~HDMV_PRESENTATION_SEGMENT() {
88 CompositionObject
* pObject
;
89 while (objects
.GetCount() > 0) {
90 pObject
= objects
.RemoveHead();
99 HRESULT
ParseSample(IMediaSample
* pSample
);
102 POSITION
GetStartPosition(REFERENCE_TIME rt
, double fps
);
103 POSITION
GetNext(POSITION pos
) {
104 m_pPresentationSegments
.GetNext(pos
);
109 virtual REFERENCE_TIME
GetStart(POSITION nPos
) {
110 HDMV_PRESENTATION_SEGMENT
* pPresentationSegment
= m_pPresentationSegments
.GetAt(nPos
);
111 return pPresentationSegment
!= NULL
? pPresentationSegment
->rtStart
: INVALID_TIME
;
113 virtual REFERENCE_TIME
GetStop(POSITION nPos
) {
114 HDMV_PRESENTATION_SEGMENT
* pPresentationSegment
= m_pPresentationSegments
.GetAt(nPos
);
115 return pPresentationSegment
!= NULL
? pPresentationSegment
->rtStop
: INVALID_TIME
;
118 void Render(SubPicDesc
& spd
, REFERENCE_TIME rt
, RECT
& bbox
);
119 HRESULT
GetTextureSize(POSITION pos
, SIZE
& MaxTextureSize
, SIZE
& VideoSize
, POINT
& VideoTopLeft
);
121 virtual HRESULT
SetYuvType(ColorType colorType
, YuvRangeType yuvRangeType
);
124 HDMV_SEGMENT_TYPE m_nCurSegment
;
126 int m_nTotalSegBuffer
;
130 HDMV_PRESENTATION_SEGMENT
* m_pCurrentPresentationSegment
;
131 CAtlList
<HDMV_PRESENTATION_SEGMENT
*> m_pPresentationSegments
;
133 HDMV_CLUT m_CLUTs
[256];
134 CompositionObject m_compositionObjects
[64];
137 int ParsePresentationSegment(REFERENCE_TIME rt
, CGolombBuffer
* pGBuffer
);
138 void EnqueuePresentationSegment(REFERENCE_TIME rt
);
140 void ParsePalette(CGolombBuffer
* pGBuffer
, unsigned short nSize
);
141 void ParseObject(CGolombBuffer
* pGBuffer
, unsigned short nUnitSize
);
143 void ParseVideoDescriptor(CGolombBuffer
* pGBuffer
, VIDEO_DESCRIPTOR
* pVideoDescriptor
);
144 void ParseCompositionDescriptor(CGolombBuffer
* pGBuffer
, COMPOSITION_DESCRIPTOR
* pCompositionDescriptor
);
145 void ParseCompositionObject(CGolombBuffer
* pGBuffer
, CompositionObject
* pCompositionObject
);
147 void AllocSegment(int nSize
);
149 HDMV_PRESENTATION_SEGMENT
* FindPresentationSegment(REFERENCE_TIME rt
);
150 CompositionObject
* FindObject(HDMV_PRESENTATION_SEGMENT
* pPresentationSegment
, short sObjectId
);