Merge with MPC-HC 6d1472b2f18266d92e5bc068667de348c0cd3b3b.
[xy_vsfilter.git] / src / subtitles / CompositionObject.h
blobb7549c7f1df39e0f937bc1a8f77afaf3f1713337
1 /*
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/>.
21 #pragma once
23 #include "Rasterizer.h"
26 struct HDMV_PALETTE {
27 BYTE entry_id;
28 BYTE Y;
29 BYTE Cr;
30 BYTE Cb;
31 BYTE T; // HDMV rule : 0 transparent, 255 opaque (compatible DirectX)
34 class CGolombBuffer;
36 class CompositionObject : Rasterizer
38 public:
39 short m_object_id_ref;
40 BYTE m_window_id_ref;
41 bool m_object_cropped_flag;
42 bool m_forced_on_flag;
43 BYTE m_version_number;
45 short m_horizontal_position;
46 short m_vertical_position;
47 short m_width;
48 short m_height;
50 short m_cropping_horizontal_position;
51 short m_cropping_vertical_position;
52 short m_cropping_width;
53 short m_cropping_height;
55 CompositionObject();
56 ~CompositionObject();
58 void SetRLEData(const BYTE* pBuffer, int nSize, int nTotalSize);
59 void AppendRLEData(const BYTE* pBuffer, int nSize);
60 const BYTE* GetRLEData() { return m_pRLEData; };
61 int GetRLEDataSize() { return m_nRLEDataSize; };
62 bool IsRLEComplete() { return m_nRLEPos >= m_nRLEDataSize; };
63 void RenderHdmv(SubPicDesc& spd);
64 void RenderDvb(SubPicDesc& spd, short nX, short nY);
65 void WriteSeg(SubPicDesc& spd, short nX, short nY, short nCount, short nPaletteIndex);
66 void InitColor(const SubPicDesc& spd);
67 void SetPalette(int nNbEntry, HDMV_PALETTE* pPalette, bool bIsHD);
68 void SetPalette(int nNbEntry, DWORD* dwColors);
69 bool HavePalette() {
70 return !m_Palette.IsEmpty();
73 private:
74 BYTE* m_pRLEData;
75 int m_nRLEDataSize;
76 int m_nRLEPos;
78 CAtlArray<HDMV_PALETTE> m_Palette;
79 enum ColorType
81 NONE,
82 YUV_Rec601,
83 YUV_Rec709,
84 RGB
86 ColorType m_OriginalColorType;
88 DWORD m_Colors[256];
89 int m_colorType;
91 void DvbRenderField(SubPicDesc& spd, CGolombBuffer& gb, short nXStart, short nYStart, short nLength);
92 void Dvb2PixelsCodeString(SubPicDesc& spd, CGolombBuffer& gb, short& nX, short& nY);
93 void Dvb4PixelsCodeString(SubPicDesc& spd, CGolombBuffer& gb, short& nX, short& nY);
94 void Dvb8PixelsCodeString(SubPicDesc& spd, CGolombBuffer& gb, short& nX, short& nY);