Merge some MPC-HC Rev.3895 code to get HdmvSub and DVBSub support.
[xy_vsfilter.git] / src / dsutil / HdmvClipInfo.h
blob0f619f54a63aae48070b4e665348e74db5a2df02
1 /*
2 * $Id: HdmvClipInfo.h 3888 2011-12-10 02:00:30Z Aleksoid $
4 * (C) 2006-2011 see AUTHORS
6 * This file is part of mplayerc.
8 * Mplayerc is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * Mplayerc is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #pragma once
25 #include "Mpeg2Def.h"
27 enum BDVM_VideoFormat {
28 BDVM_VideoFormat_Unknown = 0,
29 BDVM_VideoFormat_480i = 1,
30 BDVM_VideoFormat_576i = 2,
31 BDVM_VideoFormat_480p = 3,
32 BDVM_VideoFormat_1080i = 4,
33 BDVM_VideoFormat_720p = 5,
34 BDVM_VideoFormat_1080p = 6,
35 BDVM_VideoFormat_576p = 7,
38 enum BDVM_FrameRate {
39 BDVM_FrameRate_Unknown = 0,
40 BDVM_FrameRate_23_976 = 1,
41 BDVM_FrameRate_24 = 2,
42 BDVM_FrameRate_25 = 3,
43 BDVM_FrameRate_29_97 = 4,
44 BDVM_FrameRate_50 = 6,
45 BDVM_FrameRate_59_94 = 7
48 enum BDVM_AspectRatio {
49 BDVM_AspectRatio_Unknown = 0,
50 BDVM_AspectRatio_4_3 = 2,
51 BDVM_AspectRatio_16_9 = 3,
52 BDVM_AspectRatio_2_21 = 4
55 enum BDVM_ChannelLayout {
56 BDVM_ChannelLayout_Unknown = 0,
57 BDVM_ChannelLayout_MONO = 1,
58 BDVM_ChannelLayout_STEREO = 3,
59 BDVM_ChannelLayout_MULTI = 6,
60 BDVM_ChannelLayout_COMBO = 12
63 enum BDVM_SampleRate {
64 BDVM_SampleRate_Unknown = 0,
65 BDVM_SampleRate_48 = 1,
66 BDVM_SampleRate_96 = 4,
67 BDVM_SampleRate_192 = 5,
68 BDVM_SampleRate_48_192 = 12,
69 BDVM_SampleRate_48_96 = 14
72 typedef unsigned char uint8;
73 typedef signed char int8;
75 typedef unsigned short uint16;
76 typedef short int16;
78 typedef unsigned long uint32;
79 typedef long int32;
82 class CHdmvClipInfo
84 public:
86 struct Stream {
87 Stream() {
88 memset(this, 0, sizeof(*this));
90 SHORT m_PID;
91 PES_STREAM_TYPE m_Type;
92 char m_LanguageCode[4];
93 LCID m_LCID;
95 // Valid for video types
96 BDVM_VideoFormat m_VideoFormat;
97 BDVM_FrameRate m_FrameRate;
98 BDVM_AspectRatio m_AspectRatio;
99 // Valid for audio types
100 BDVM_ChannelLayout m_ChannelLayout;
101 BDVM_SampleRate m_SampleRate;
103 LPCTSTR Format();
106 struct PlaylistItem {
107 CString m_strFileName;
108 REFERENCE_TIME m_rtIn;
109 REFERENCE_TIME m_rtOut;
111 REFERENCE_TIME Duration() const {
112 return m_rtOut - m_rtIn;
115 bool operator == (const PlaylistItem& pi) const {
116 return pi.m_strFileName == m_strFileName;
120 enum PlaylistMarkType
122 Reserved = 0x00,
123 EntryMark = 0x01,
124 LinkPoint = 0x02
127 struct PlaylistChapter
129 SHORT m_nPlayItemId;
130 PlaylistMarkType m_nMarkType;
131 REFERENCE_TIME m_rtTimestamp;
132 SHORT m_nEntryPID;
133 REFERENCE_TIME m_rtDuration;
136 CHdmvClipInfo(void);
137 ~CHdmvClipInfo();
139 HRESULT ReadInfo(LPCTSTR strFile);
140 Stream* FindStream(SHORT wPID);
141 bool IsHdmv() const {
142 return m_bIsHdmv;
144 size_t GetStreamNumber() {
145 return m_Streams.GetCount();
147 Stream* GetStreamByIndex(size_t nIndex) {
148 return (nIndex < m_Streams.GetCount()) ? &m_Streams[nIndex] : NULL;
151 HRESULT FindMainMovie(LPCTSTR strFolder, CString& strPlaylistFile, CAtlList<PlaylistItem>& MainPlaylist, CAtlList<PlaylistItem>& MPLSPlaylists);
152 HRESULT ReadPlaylist(CString strPlaylistFile, REFERENCE_TIME& rtDuration, CAtlList<PlaylistItem>& Playlist);
153 HRESULT ReadChapters(CString strPlaylistFile, CAtlList<CHdmvClipInfo::PlaylistItem>& PlaylistItems, CAtlList<PlaylistChapter>& Chapters);
155 private :
156 DWORD SequenceInfo_start_address;
157 DWORD ProgramInfo_start_address;
159 HANDLE m_hFile;
162 CAtlArray<Stream> m_Streams;
163 bool m_bIsHdmv;
165 DWORD ReadDword();
166 SHORT ReadShort();
167 BYTE ReadByte();
168 void ReadBuffer(BYTE* pBuff, DWORD nLen);
170 HRESULT ReadProgramInfo();
171 HRESULT CloseFile(HRESULT hr);