-
Notifications
You must be signed in to change notification settings - Fork 1
/
CorePNG.h
128 lines (106 loc) · 4.24 KB
/
CorePNG.h
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
// ----------------------------------------------------------------------------
// CorePNG
// http://corecodec.org/projects/corepng
//
// Copyright (C) 2003 Jory Stone
//
// This file may be distributed under the terms of the Q Public License
// as defined by Trolltech AS of Norway and appearing in the file
// copying.txt included in the packaging of this file.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
//-----------------------------------------------------------------------------
#ifndef _COREPNG_H_
#define _COREPNG_H_
//Memory Leak Debuging define
#ifdef _DEBUG
//#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#endif
#include <windows.h>
#include <streams.h>
#include <malloc.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <queue>
#include "ximage.h"
#define ODS(x) OutputDebugString(x)
HRESULT DShowIMediaSampleCopy(IMediaSample *pSource, IMediaSample *pDest, bool bCopyData);
class CCorePNGEncoderFilter : public CTransformFilter {
public:
CCorePNGEncoderFilter(LPUNKNOWN pUnk, HRESULT *pHr);
~CCorePNGEncoderFilter();
virtual HRESULT CheckInputType(const CMediaType *mtIn);
virtual HRESULT CheckTransform(const CMediaType *mtIn, const CMediaType *mtOut);
virtual HRESULT DecideBufferSize(IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest);
virtual HRESULT GetMediaType(int iPosition, CMediaType *pMediaType);
virtual HRESULT SetMediaType(PIN_DIRECTION direction, const CMediaType *pmt);
virtual HRESULT Transform(IMediaSample *pIn, IMediaSample *pOut);
static CUnknown * WINAPI CreateInstance(LPUNKNOWN pUnk, HRESULT *pHr);
protected:
CxImage m_Image;
CxMemFile memfile;
VIDEOINFOHEADER m_VideoHeader;
long m_BufferSize;
};
class CCorePNGDecoderFilter : public CTransformFilter {
public:
CCorePNGDecoderFilter(LPUNKNOWN pUnk, HRESULT *pHr);
~CCorePNGDecoderFilter();
virtual HRESULT CheckInputType(const CMediaType *mtIn);
virtual HRESULT CheckTransform(const CMediaType *mtIn, const CMediaType *mtOut);
virtual HRESULT DecideBufferSize(IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest);
virtual HRESULT GetMediaType(int iPosition, CMediaType *pMediaType);
virtual HRESULT SetMediaType(PIN_DIRECTION direction, const CMediaType *pmt);
virtual HRESULT Transform(IMediaSample *pIn, IMediaSample *pOut);
static CUnknown * WINAPI CreateInstance(LPUNKNOWN pUnk, HRESULT *pHr);
protected:
CxImage m_Image;
VIDEOINFOHEADER m_VideoHeader;
long m_BufferSize;
GUID m_OutputSubType;
};
class CCorePNGSubtitlerFilterPNGInputPin : public CTransformInputPin {
public:
CCorePNGSubtitlerFilterPNGInputPin(TCHAR *pObjectName, CTransformFilter *pTransformFilter, HRESULT * phr, LPCWSTR pName);
virtual HRESULT CheckMediaType(const CMediaType* pmt);
virtual STDMETHODIMP Receive(IMediaSample *pSample);
protected:
};
class CCorePNGSubtitlerFilterOutputPin : public CTransformOutputPin {
public:
HRESULT Receive(IMediaSample *pSampleToPass) {
return this->m_pInputPin->Receive(pSampleToPass);
};
};
class CCorePNGSubtitlerFilter : public CTransformFilter {
public:
CCorePNGSubtitlerFilter(LPUNKNOWN pUnk, HRESULT *pHr);
~CCorePNGSubtitlerFilter();
virtual int GetPinCount() { return 3; };
virtual CBasePin *GetPin(int n);
virtual HRESULT CheckInputType(const CMediaType *mtIn);
virtual HRESULT CheckTransform(const CMediaType *mtIn, const CMediaType *mtOut);
virtual HRESULT DecideBufferSize(IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest);
virtual HRESULT GetMediaType(int iPosition, CMediaType *pMediaType);
virtual HRESULT SetMediaType(PIN_DIRECTION direction, const CMediaType *pmt);
virtual HRESULT Transform(IMediaSample *pIn, IMediaSample *pOut);
HRESULT GetPNGSample(IMediaSample *pSample);
HRESULT SetPNGHeader(VIDEOINFOHEADER *pVideoHeader);
static CUnknown * WINAPI CreateInstance(LPUNKNOWN pUnk, HRESULT *pHr);
protected:
HRESULT AlphaBlend(RGBTRIPLE *targetBits);
inline BOOL BlendImages(RGBTRIPLE *lprgbSrc2, RGBTRIPLE *lprgbDst);
CCorePNGSubtitlerFilterPNGInputPin *m_pInputPNGPin;
bool m_HaveSubtitle;
CxImage m_Image;
VIDEOINFOHEADER m_VideoHeader;
VIDEOINFOHEADER m_PNGVideoHeader;
long m_BufferSize;
};
#endif //_COREPNG_H_