2 * Copyright (C) 2003-2006 Gabest
3 * http://www.gabest.org
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GNU Make; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
24 #include "SubPicImpl.h"
28 typedef const UINT8 CUINT8
, *PCUINT8
;
30 class CMemSubPic
: public CSubPicExImpl
33 static void AlphaBltYv12Luma(byte
* dst
, int dst_pitch
, int w
, int h
, const byte
* sub
, const byte
* alpha
, int sub_pitch
);
34 static void AlphaBltYv12LumaC(byte
* dst
, int dst_pitch
, int w
, int h
, const byte
* sub
, const byte
* alpha
, int sub_pitch
);
36 static void AlphaBltYv12Chroma(byte
* dst
, int dst_pitch
, int w
, int chroma_h
, const byte
* sub_chroma
,
37 const byte
* alpha
, int sub_pitch
);
38 static void AlphaBltYv12ChromaC(byte
* dst
, int dst_pitch
, int w
, int chroma_h
, const byte
* sub_chroma
,
39 const byte
* alpha
, int sub_pitch
);
41 static HRESULT
AlphaBltAnv12_P010(const BYTE
* src_a
, const BYTE
* src_y
, const BYTE
* src_uv
, int src_pitch
,
42 BYTE
* dst_y
, BYTE
* dst_uv
, int dst_pitch
,
44 static HRESULT
AlphaBltAnv12_P010_C(const BYTE
* src_a
, const BYTE
* src_y
, const BYTE
* src_uv
, int src_pitch
,
45 BYTE
* dst_y
, BYTE
* dst_uv
, int dst_pitch
,
47 static HRESULT
AlphaBltAnv12_Nv12(const BYTE
* src_a
, const BYTE
* src_y
, const BYTE
* src_uv
, int src_pitch
,
48 BYTE
* dst_y
, BYTE
* dst_uv
, int dst_pitch
,
50 static HRESULT
AlphaBltAnv12_Nv12_C(const BYTE
* src_a
, const BYTE
* src_y
, const BYTE
* src_uv
, int src_pitch
,
51 BYTE
* dst_y
, BYTE
* dst_uv
, int dst_pitch
,
54 static void AlphaBlt_YUY2(int w
, int h
, BYTE
* d
, int dstpitch
, PCUINT8 s
, int srcpitch
);
56 static void SubsampleAndInterlace(BYTE
* dst
, const BYTE
* u
, const BYTE
* v
, int h
, int w
, int pitch
);
57 static void SubsampleAndInterlaceC(BYTE
* dst
, const BYTE
* u
, const BYTE
* v
, int h
, int w
, int pitch
);
59 CMemSubPic(SubPicDesc
& spd
, int alpha_blt_dst_type
);
60 virtual ~CMemSubPic();
63 STDMETHODIMP
GetDesc(SubPicDesc
& spd
) const;
64 STDMETHODIMP
ClearDirtyRect(DWORD color
);
65 STDMETHODIMP
Lock(SubPicDesc
& spd
);
66 STDMETHODIMP
AlphaBlt(const RECT
* pSrc
, const RECT
* pDst
, SubPicDesc
* pTarget
);
69 STDMETHODIMP
CopyTo(ISubPicEx
* pSubPic
);
70 STDMETHODIMP
Unlock(CAtlList
<CRect
>* dirtyRectList
);
71 STDMETHODIMP
SetDirtyRectEx(CAtlList
<CRect
>* dirtyRectList
);
77 int m_alpha_blt_dst_type
;
82 STDMETHODIMP_(void*) GetObject() const; // returns SubPicDesc*
84 HRESULT
AlphaBltAxyuAxyv_P010(const RECT
* pSrc
, const RECT
* pDst
, SubPicDesc
* pTarget
);
85 HRESULT
AlphaBltAxyuAxyv_Yv12(const RECT
* pSrc
, const RECT
* pDst
, SubPicDesc
* pTarget
);
86 HRESULT
AlphaBltAxyuAxyv_Nv12(const RECT
* pSrc
, const RECT
* pDst
, SubPicDesc
* pTarget
);
87 HRESULT
AlphaBltAnv12_P010(const RECT
* pSrc
, const RECT
* pDst
, SubPicDesc
* pTarget
);
88 HRESULT
AlphaBltAnv12_Nv12(const RECT
* pSrc
, const RECT
* pDst
, SubPicDesc
* pTarget
);
89 HRESULT
AlphaBltOther(const RECT
* pSrc
, const RECT
* pDst
, SubPicDesc
* pTarget
);
91 HRESULT
UnlockRGBA_YUV(CAtlList
<CRect
>* dirtyRectList
);
92 HRESULT
UnlockOther(CAtlList
<CRect
>* dirtyRectList
);
94 void SubsampleAndInterlace( const CRect
& cRect
, bool u_first
);
97 // CMemSubPicAllocator
99 class CMemSubPicAllocator
: public CSubPicExAllocatorImpl
102 int m_alpha_blt_dst_type
;
105 bool AllocEx(bool fStatic
, ISubPicEx
** ppSubPic
);
108 CMemSubPicAllocator(int alpha_blt_dst_type
, SIZE maxsize
, int type
=-1);