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
|
/*
* Copyright (C) 2010-2014 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"
#include "../decoders/ILAVDecoder.h"
#define BLEND_FUNC_PARAMS (BYTE* video[4], ptrdiff_t videoStride[4], RECT vidRect, BYTE* subData[4], ptrdiff_t subStride[4], POINT position, SIZE size, LAVPixelFormat pixFmt, int bpp)
#define DECLARE_BLEND_FUNC(name) \
HRESULT name BLEND_FUNC_PARAMS
#define DECLARE_BLEND_FUNC_IMPL(name) \
DECLARE_BLEND_FUNC(CLAVSubtitleConsumer::name)
typedef struct LAVSubtitleConsumerContext {
LPWSTR name; ///< name of the Consumer
LPWSTR version; ///< Version of the Consumer
SIZE originalVideoSize; ///< Size of the video
bool redraw;
bool menu;
} LAVSubtitleConsumerContext;
class CLAVVideo;
class CLAVSubtitleConsumer : public ISubRenderConsumer, public CSubRenderOptionsImpl, public CUnknown
{
public:
CLAVSubtitleConsumer(CLAVVideo *pLAVVideo);
virtual ~CLAVSubtitleConsumer(void);
DECLARE_IUNKNOWN;
DECLARE_ISUBRENDEROPTIONS;
// ISubRenderConsumer
STDMETHODIMP GetMerit(ULONG *merit) { CheckPointer(merit, E_POINTER); *merit = 0x00010000; return S_OK; }
STDMETHODIMP Connect(ISubRenderProvider *subtitleRenderer);
STDMETHODIMP Disconnect(void);
STDMETHODIMP DeliverFrame(REFERENCE_TIME start, REFERENCE_TIME stop, ISubRenderFrame *subtitleFrame);
// LAV Internal methods
STDMETHODIMP RequestFrame(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
STDMETHODIMP ProcessFrame(LAVFrame *pFrame);
STDMETHODIMP DisconnectProvider() { if (m_pProvider) return m_pProvider->Disconnect(); SafeRelease(&m_pProvider); return S_OK; }
BOOL HasProvider() const { return m_pProvider != nullptr; }
void SetVideoSize(LONG w, LONG h) { context.originalVideoSize.cx = w; context.originalVideoSize.cy = h; }
private:
STDMETHODIMP ProcessSubtitleBitmap(LAVPixelFormat pixFmt, int bpp, RECT videoRect, BYTE *videoData[4], ptrdiff_t videoStride[4], RECT subRect, POINT subPosition, SIZE subSize, const uint8_t *rgbData, ptrdiff_t pitch);
STDMETHODIMP SelectBlendFunction();
typedef HRESULT (CLAVSubtitleConsumer::*BlendFn) BLEND_FUNC_PARAMS;
BlendFn blend = nullptr;
DECLARE_BLEND_FUNC(blend_rgb_c);
template <class pixT, int nv12> DECLARE_BLEND_FUNC(blend_yuv_c);
private:
ISubRenderProvider *m_pProvider = nullptr;
ISubRenderFrame *m_SubtitleFrame = nullptr;
CAMEvent m_evFrame{FALSE};
SwsContext *m_pSwsContext = nullptr;
LAVPixelFormat m_PixFmt = LAVPixFmt_None;
LAVSubtitleConsumerContext context;
CLAVVideo *m_pLAVVideo = nullptr;
};
|