Welcome to mirror list, hosted at ThFree Co, Russian Federation.

HdmvClipInfo.h « DSUtil « src - github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 261c7c4b7d5dcb31c1393ae747c5bdafa2c78a12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*
 * (C) 2008-2013 see Authors.txt
 *
 * This file is part of MPC-HC.
 *
 * MPC-HC 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.
 *
 * MPC-HC 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 "Mpeg2Def.h"

enum BDVM_VideoFormat {
    BDVM_VideoFormat_Unknown = 0,
    BDVM_VideoFormat_480i    = 1,
    BDVM_VideoFormat_576i    = 2,
    BDVM_VideoFormat_480p    = 3,
    BDVM_VideoFormat_1080i   = 4,
    BDVM_VideoFormat_720p    = 5,
    BDVM_VideoFormat_1080p   = 6,
    BDVM_VideoFormat_576p    = 7
};

enum BDVM_FrameRate {
    BDVM_FrameRate_Unknown = 0,
    BDVM_FrameRate_23_976  = 1,
    BDVM_FrameRate_24      = 2,
    BDVM_FrameRate_25      = 3,
    BDVM_FrameRate_29_97   = 4,
    BDVM_FrameRate_50      = 6,
    BDVM_FrameRate_59_94   = 7
};

enum BDVM_AspectRatio {
    BDVM_AspectRatio_Unknown = 0,
    BDVM_AspectRatio_4_3     = 2,
    BDVM_AspectRatio_16_9    = 3,
    BDVM_AspectRatio_2_21    = 4
};

enum BDVM_ChannelLayout {
    BDVM_ChannelLayout_Unknown = 0,
    BDVM_ChannelLayout_MONO    = 1,
    BDVM_ChannelLayout_STEREO  = 3,
    BDVM_ChannelLayout_MULTI   = 6,
    BDVM_ChannelLayout_COMBO   = 12
};

enum BDVM_SampleRate {
    BDVM_SampleRate_Unknown = 0,
    BDVM_SampleRate_48      = 1,
    BDVM_SampleRate_96      = 4,
    BDVM_SampleRate_192     = 5,
    BDVM_SampleRate_48_192  = 12,
    BDVM_SampleRate_48_96   = 14
};

class CHdmvClipInfo
{
public:

    struct Stream {
        Stream() {
            ZeroMemory(this, sizeof(*this));
        }
        short m_PID;
        PES_STREAM_TYPE m_Type;
        char m_LanguageCode[4];
        LCID m_LCID;

        // Valid for video types
        BDVM_VideoFormat m_VideoFormat;
        BDVM_FrameRate m_FrameRate;
        BDVM_AspectRatio m_AspectRatio;
        // Valid for audio types
        BDVM_ChannelLayout m_ChannelLayout;
        BDVM_SampleRate m_SampleRate;

        LPCTSTR Format();
    };

    struct PlaylistItem {
        CString m_strFileName;
        REFERENCE_TIME m_rtIn;
        REFERENCE_TIME m_rtOut;

        REFERENCE_TIME Duration() const { return m_rtOut - m_rtIn; }

        bool operator == (const PlaylistItem& pi) const {
            return pi.m_strFileName == m_strFileName;
        }
    };

    enum PlaylistMarkType {
        Reserved  = 0x00,
        EntryMark = 0x01,
        LinkPoint = 0x02
    };

    struct PlaylistChapter {
        short            m_nPlayItemId;
        PlaylistMarkType m_nMarkType;
        REFERENCE_TIME   m_rtTimestamp;
        short            m_nEntryPID;
        REFERENCE_TIME   m_rtDuration;
    };

    CHdmvClipInfo();
    ~CHdmvClipInfo();

    HRESULT ReadInfo(LPCTSTR strFile);
    Stream* FindStream(short wPID);
    bool IsHdmv() const { return m_bIsHdmv; };
    size_t GetStreamNumber() { return m_Streams.GetCount(); };
    Stream* GetStreamByIndex(size_t nIndex) { return (nIndex < m_Streams.GetCount()) ? &m_Streams[nIndex] : nullptr; };

    HRESULT FindMainMovie(LPCTSTR strFolder, CString& strPlaylistFile, CAtlList<PlaylistItem>& MainPlaylist, CAtlList<PlaylistItem>& MPLSPlaylists);
    HRESULT ReadPlaylist(CString strPlaylistFile, REFERENCE_TIME& rtDuration, CAtlList<PlaylistItem>& Playlist);
    HRESULT ReadChapters(CString strPlaylistFile, CAtlList<CHdmvClipInfo::PlaylistItem>& PlaylistItems, CAtlList<PlaylistChapter>& Chapters);

private:
    DWORD SequenceInfo_start_address;
    DWORD ProgramInfo_start_address;

    HANDLE m_hFile;

    CAtlArray<Stream> m_Streams;
    bool m_bIsHdmv;

    DWORD ReadDword();
    short ReadShort();
    BYTE ReadByte();
    void ReadBuffer(BYTE* pBuff, DWORD nLen);

    HRESULT ReadProgramInfo();
    HRESULT CloseFile(HRESULT hr);
};