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

quicksync.h « decoders « LAVVideo « decoder - github.com/mpc-hc/LAVFilters.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3639604a31c3dc07148ab41dd056bb12de725632 (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
/*
 *      Copyright (C) 2010-2015 Hendrik Leppkes
 *      http://www.1f0.de
 *
 *  This program 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 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program 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, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#pragma once
#include "DecBase.h"

#include "IQuickSyncDecoder.h"

typedef IQuickSyncDecoder* __stdcall pcreateQuickSync();
typedef void               __stdcall pdestroyQuickSync(IQuickSyncDecoder*);
typedef DWORD              __stdcall pcheck();

#include <queue>

class CDecQuickSync : public CDecBase
{
public:
  CDecQuickSync(void);
  virtual ~CDecQuickSync(void);

  // ILAVDecoder
  STDMETHODIMP Check();
  STDMETHODIMP InitDecoder(AVCodecID codec, const CMediaType *pmt);
  STDMETHODIMP Decode(const BYTE *buffer, int buflen, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, BOOL bSyncPoint, BOOL bDiscontinuity);
  STDMETHODIMP Flush();
  STDMETHODIMP EndOfStream();
  STDMETHODIMP GetPixelFormat(LAVPixelFormat *pPix, int *pBpp);
  STDMETHODIMP_(REFERENCE_TIME) GetFrameDuration();
  STDMETHODIMP_(BOOL) IsInterlaced();
  STDMETHODIMP_(const WCHAR*) GetDecoderName() { return L"quicksync"; }

  STDMETHODIMP PostConnect(IPin *pPin);

  // CDecBase
  STDMETHODIMP Init();

private:
  STDMETHODIMP DestroyDecoder(bool bFull);

  static HRESULT QS_DeliverSurfaceCallback(void* obj, QsFrameData* data);
  STDMETHODIMP HandleFrame(QsFrameData *data);

  STDMETHODIMP CheckH264Sequence(const BYTE *buffer, size_t buflen, int nal_size, int *pRefFrames = nullptr, int *pProfile = nullptr, int *pLevel = nullptr);

private:
  struct {
    HMODULE quickSyncLib;

    pcreateQuickSync *create;
    pdestroyQuickSync *destroy;
    pcheck *check;
  } qs;

  IQuickSyncDecoder *m_pDecoder = nullptr;

  BOOL m_bNeedSequenceCheck = FALSE;
  BOOL m_bInterlaced        = TRUE;
  BOOL m_bDI                = FALSE;
  BOOL m_bAVC1              = FALSE;
  int  m_nAVCNalSize        = 0;
  BOOL m_bEndOfSequence     = FALSE;

  BOOL                   m_bUseTimestampQueue;
  std::queue<REFERENCE_TIME> m_timestampQueue;

  DXVA2_ExtendedFormat m_DXVAExtendedFormat;

  FOURCC m_Codec = 0;

  IDirect3DDeviceManager9 *m_pD3DDevMngr = nullptr;
};