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

FGFilterLAV.h « mpc-hc « src - github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: dd5a708de68ebb5ee21b79621d395a9fd931de83 (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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
/*
 * (C) 2013-2014 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 <string>

DEFINE_GUID(GUID_LAVSplitter, 0x171252A0, 0x8820, 0x4AFE, 0x9D, 0xF8, 0x5C, 0x92, 0xB2, 0xD6, 0x6B, 0x04);
DEFINE_GUID(GUID_LAVSplitterSource, 0xB98D13E7, 0x55DB, 0x4385, 0xA3, 0x3D, 0x09, 0xFD, 0x1B, 0xA2, 0x63, 0x38);
DEFINE_GUID(GUID_LAVVideo, 0xEE30215D, 0x164F, 0x4A92, 0xA4, 0xEB, 0x9D, 0x4C, 0x13, 0x39, 0x0F, 0x9F);
DEFINE_GUID(GUID_LAVAudio, 0xE8E73B6B, 0x4CB3, 0x44A4, 0xBE, 0x99, 0x4F, 0x7B, 0xCB, 0x96, 0xE4, 0x91);

#include "FGFilter.h"
#include "ComPropertySheet.h"

#include "LAVFilters/src/common/includes/LAVSplitterSettings.h"
#include "LAVFilters/src/decoder/LAVVideo/LAVVideoSettings.h"
#include "LAVFilters/src/decoder/LAVAudio/LAVAudioSettings.h"

class CFGFilterLAV : public CFGFilterFile
{
protected:
    static CList<const IBaseFilter*> s_instances;

    CFGFilterLAV(const CLSID& clsid, CString path, CStringW name, bool bAddLowMeritSuffix, UINT64 merit);

public:
    enum LAVFILTER_TYPE {
        INVALID = -1,
        SPLITTER,
        SPLITTER_SOURCE,
        VIDEO_DECODER,
        AUDIO_DECODER
    };

    static CString GetFilterPath(LAVFILTER_TYPE filterType);
    static bool CheckVersion(CString filtersPath);
    static CString GetVersion(LAVFILTER_TYPE filterType = INVALID);

    static CFGFilterLAV* CreateFilter(LAVFILTER_TYPE filterType, UINT64 merit = MERIT64_DO_USE, bool bAddLowMeritSuffix = false);

    static bool IsInternalInstance(IBaseFilter* pBF, LAVFILTER_TYPE* pLAVFilterType = nullptr);
    static void ResetInternalInstances() {
        s_instances.RemoveAll();
    }

    template<LAVFILTER_TYPE filterType, typename filterClass, typename filterInterface, int iIgnoredPage>
    static void ShowPropertyPages(CWnd* pParendWnd) {
        CAutoPtr<CFGFilterLAV> pLAVFilter(CFGFilterLAV::CreateFilter(filterType));

        if (pLAVFilter) {
            CComPtr<IBaseFilter> pBF;
            CInterfaceList<IUnknown, &IID_IUnknown> pUnks;

            if (SUCCEEDED(pLAVFilter->Create(&pBF, pUnks))) {
                if (CComQIPtr<ISpecifyPropertyPages> pSPP = pBF) {
                    CComPropertySheet ps(ResStr(IDS_PROPSHEET_PROPERTIES), pParendWnd);
                    ps.AddPages(pSPP, iIgnoredPage);
                    ps.DoModal();

                    if (CComQIPtr<filterInterface> pLAVFSettings = pBF) {
                        filterClass::Settings settings;
                        if (settings.GetSettings(pLAVFSettings)) { // Get current settings
                            settings.SaveSettings(); // Save them to the registry/ini
                        }
                    }
                }
            }
        }
    }

    static HRESULT PropertyPageCallback(IBaseFilter* pFilter);
};

class CFGFilterLAVSplitterBase : public CFGFilterLAV
{
protected:
    CAtlList<CStringA> m_enabledFormats, m_disabledFormats;

    CFGFilterLAVSplitterBase(CString path, const CLSID& clsid, CStringW name, bool bAddLowMeritSuffix, UINT64 merit);

    void SetEnabledDisabledFormats(CComQIPtr<ILAVFSettings> pLAVFSettings);

public:
    struct Settings {
        BOOL bTrayIcon;
        std::wstring prefAudioLangs;
        std::wstring prefSubLangs;
        std::wstring subtitleAdvanced;
        LAVSubtitleMode subtitleMode;
        BOOL bPGSForcedStream;
        BOOL bPGSOnlyForced;
        int iVC1Mode;
        BOOL bSubstreams;

        BOOL bMatroskaExternalSegments;

        BOOL bStreamSwitchRemoveAudio;
        BOOL bImpairedAudio;
        BOOL bPreferHighQualityAudio;
        DWORD dwQueueMaxSize;
        DWORD dwNetworkAnalysisDuration;

        void LoadSettings();
        void SaveSettings();

        bool GetSettings(CComQIPtr<ILAVFSettings> pLAVFSettings);
        bool SetSettings(CComQIPtr<ILAVFSettings> pLAVFSettings);
    };

    static const CString filename;

    virtual HRESULT Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);

    static void ShowPropertyPages(CWnd* pParendWnd);

    void AddEnabledFormat(CStringA format) {
        m_enabledFormats.AddTail(format);
    }

    void AddDisabledFormat(CStringA format) {
        m_disabledFormats.AddTail(format);
    }
};

class CFGFilterLAVSplitter : public CFGFilterLAVSplitterBase
{
public:
    CFGFilterLAVSplitter(CString path, UINT64 merit = MERIT64_DO_USE, bool bAddLowMeritSuffix = false);
};

class CFGFilterLAVSplitterSource : public CFGFilterLAVSplitterBase
{
public:
    CFGFilterLAVSplitterSource(CString path, UINT64 merit = MERIT64_DO_USE, bool bAddLowMeritSuffix = false);
};

class CFGFilterLAVVideo : public CFGFilterLAV
{
public:
    struct Settings {
        BOOL bTrayIcon;
        DWORD dwStreamAR;
        DWORD dwNumThreads;
        BOOL bPixFmts[LAVOutPixFmt_NB];
        DWORD dwRGBRange;
        DWORD dwHWAccel;
        BOOL bHWFormats[HWCodec_NB];
        DWORD dwHWAccelResFlags;
        DWORD dwHWDeintMode;
        DWORD dwHWDeintOutput;
        BOOL bHWDeintHQ;
        DWORD dwDeintFieldOrder;
        LAVDeintMode deintMode;
        DWORD dwSWDeintMode;
        DWORD dwSWDeintOutput;
        DWORD dwDitherMode;

        void LoadSettings();
        void SaveSettings();

        bool GetSettings(CComQIPtr<ILAVVideoSettings> pLAVFSettings);
        bool SetSettings(CComQIPtr<ILAVVideoSettings> pLAVFSettings);
    };

    static const CString filename;

    CFGFilterLAVVideo(CString path, UINT64 merit = MERIT64_DO_USE, bool bAddLowMeritSuffix = false);

    virtual HRESULT Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);

    static void ShowPropertyPages(CWnd* pParendWnd);

    static LPCTSTR GetUserFriendlyDecoderName(const CString& decoderName);
};

class CFGFilterLAVAudio : public CFGFilterLAV
{
public:
    struct Settings {
        BOOL bTrayIcon;
        BOOL bDRCEnabled;
        int iDRCLevel;
        BOOL bBitstream[Bitstream_NB];
        BOOL bDTSHDFraming;
        BOOL bAutoAVSync;
        BOOL bExpandMono;
        BOOL bExpand61;
        BOOL bOutputStandardLayout;
        BOOL bAllowRawSPDIF;
        BOOL bSampleFormats[SampleFormat_NB];
        BOOL bSampleConvertDither;
        BOOL bAudioDelayEnabled;
        int  iAudioDelay;

        BOOL bMixingEnabled;
        DWORD dwMixingLayout;
        DWORD dwMixingFlags;
        DWORD dwMixingMode;
        DWORD dwMixingCenterLevel;
        DWORD dwMixingSurroundLevel;
        DWORD dwMixingLFELevel;

        void LoadSettings();
        void SaveSettings();

        bool GetSettings(CComQIPtr<ILAVAudioSettings> pLAVFSettings);
        bool SetSettings(CComQIPtr<ILAVAudioSettings> pLAVFSettings);
    };

    static const CString filename;

    CFGFilterLAVAudio(CString path, UINT64 merit = MERIT64_DO_USE, bool bAddLowMeritSuffix = false);

    virtual HRESULT Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);

    static void ShowPropertyPages(CWnd* pParendWnd);
};