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

LAVSubtitleProvider.h « subtitles « LAVVideo « decoder - github.com/mpc-hc/LAVFilters.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cf8b044af8b5a5220957c364423d05b5f8320f44 (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
/*
 *      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 "SubRenderOptionsImpl.h"
#include "LAVSubtitleFrame.h"

class CLAVVideo;

typedef struct LAVSubtitleProviderContext {
  LPWSTR name;                    ///< name of the Provider
  LPWSTR version;                 ///< Version of the Provider

  bool combineBitmaps;            ///< Control if the provider combines all bitmaps into one
} LAVSubtitleProviderContext;

struct _AM_PROPERTY_SPPAL;
struct _AM_PROPERTY_SPHLI;

class CLAVSubtitleProvider : public ISubRenderProvider, public CSubRenderOptionsImpl, public CUnknown, private CCritSec
{
public:
  CLAVSubtitleProvider(CLAVVideo *pLAVVideo, ISubRenderConsumer *pConsumer);
  ~CLAVSubtitleProvider(void);
  DECLARE_IUNKNOWN;
  DECLARE_ISUBRENDEROPTIONS;

  // ISubRenderProvider
  STDMETHODIMP RequestFrame(REFERENCE_TIME start, REFERENCE_TIME stop);
  STDMETHODIMP Disconnect(void);

  // CLAVSubtitleProvider public
  STDMETHODIMP DisconnectConsumer(void);

  STDMETHODIMP InitDecoder(const CMediaType *pmt, AVCodecID codecId);
  STDMETHODIMP Decode(BYTE *buf, int buflen, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);

  STDMETHODIMP Flush();

  STDMETHODIMP SetDVDPalette(struct _AM_PROPERTY_SPPAL *pPal);
  STDMETHODIMP SetDVDHLI(struct _AM_PROPERTY_SPHLI *pHLI);
  STDMETHODIMP SetDVDComposit(BOOL bComposit);

private:
  void CloseDecoder();

  void ProcessSubtitleFrame(AVSubtitle *sub, REFERENCE_TIME rtStart);
  void ProcessSubtitleRect(AVSubtitleRect *rect, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
  void AddSubtitleRect(CLAVSubRect *rect);
  CLAVSubRect* ProcessDVDHLI(CLAVSubRect *rect);
  void ClearSubtitleRects();
  void TimeoutSubtitleRects(REFERENCE_TIME rtStop);

private:
  LAVSubtitleProviderContext context;
  CLAVVideo *m_pLAVVideo            = nullptr;

  ISubRenderConsumer *m_pConsumer   = nullptr;

  const AVCodec        *m_pAVCodec  = nullptr;
  AVCodecContext       *m_pAVCtx    = nullptr;
  AVCodecParserContext *m_pParser   = nullptr;

  REFERENCE_TIME        m_rtLastFrame  = 0;
  REFERENCE_TIME        m_rtStartCache = AV_NOPTS_VALUE;
  ULONGLONG             m_SubPicId     = 0;
  BOOL                  m_bComposit    = TRUE;

  std::list<CLAVSubRect *> m_SubFrames;

  struct _AM_PROPERTY_SPHLI *m_pHLI = nullptr;
};