Add CPU capability check. [PART 1]
[xy_vsfilter.git] / src / subpic / MemSubPic.h
blob6e71233e089e3aa5633878766fb9d79b3ba8e08d
1 /*
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)
8 * any later version.
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
22 #pragma once
24 #include "SubPicImpl.h"
26 // CMemSubPic
28 class CMemSubPic : public CSubPicExImpl
30 public:
31 static void AlphaBltYv12Luma(byte* dst, int dst_pitch, int w, int h, const byte* sub, const byte* alpha, int sub_pitch);
32 static void AlphaBltYv12LumaC(byte* dst, int dst_pitch, int w, int h, const byte* sub, const byte* alpha, int sub_pitch);
34 static void AlphaBltYv12Chroma(byte* dst, int dst_pitch, int w, int chroma_h, const byte* sub_chroma,
35 const byte* alpha, int sub_pitch);
36 static void AlphaBltYv12ChromaC(byte* dst, int dst_pitch, int w, int chroma_h, const byte* sub_chroma,
37 const byte* alpha, int sub_pitch);
39 static HRESULT AlphaBltAnv12_P010(const BYTE* src_a, const BYTE* src_y, const BYTE* src_uv, int src_pitch,
40 BYTE* dst_y, BYTE* dst_uv, int dst_pitch,
41 int w, int h);
42 static HRESULT AlphaBltAnv12_P010_C(const BYTE* src_a, const BYTE* src_y, const BYTE* src_uv, int src_pitch,
43 BYTE* dst_y, BYTE* dst_uv, int dst_pitch,
44 int w, int h);
45 static HRESULT AlphaBltAnv12_Nv12(const BYTE* src_a, const BYTE* src_y, const BYTE* src_uv, int src_pitch,
46 BYTE* dst_y, BYTE* dst_uv, int dst_pitch,
47 int w, int h);
48 static HRESULT AlphaBltAnv12_Nv12_C(const BYTE* src_a, const BYTE* src_y, const BYTE* src_uv, int src_pitch,
49 BYTE* dst_y, BYTE* dst_uv, int dst_pitch,
50 int w, int h);
52 static void SubsampleAndInterlace(BYTE* dst, const BYTE* u, const BYTE* v, int h, int w, int pitch);
53 static void SubsampleAndInterlaceC(BYTE* dst, const BYTE* u, const BYTE* v, int h, int w, int pitch);
54 public:
55 CMemSubPic(SubPicDesc& spd, int alpha_blt_dst_type);
56 virtual ~CMemSubPic();
58 // ISubPic
59 STDMETHODIMP GetDesc(SubPicDesc& spd) const;
60 STDMETHODIMP ClearDirtyRect(DWORD color);
61 STDMETHODIMP Lock(SubPicDesc& spd);
62 STDMETHODIMP AlphaBlt(const RECT* pSrc, const RECT* pDst, SubPicDesc* pTarget);
64 // ISubPicEx
65 STDMETHODIMP CopyTo(ISubPicEx* pSubPic);
66 STDMETHODIMP Unlock(CAtlList<CRect>* dirtyRectList);
67 STDMETHODIMP SetDirtyRectEx(CAtlList<CRect>* dirtyRectList);
69 protected:
70 int m_type;
71 bool converted;
73 int m_alpha_blt_dst_type;
75 SubPicDesc m_spd;
77 protected:
78 STDMETHODIMP_(void*) GetObject() const; // returns SubPicDesc*
80 HRESULT AlphaBltAxyuAxyv_P010(const RECT* pSrc, const RECT* pDst, SubPicDesc* pTarget);
81 HRESULT AlphaBltAxyuAxyv_Yv12(const RECT* pSrc, const RECT* pDst, SubPicDesc* pTarget);
82 HRESULT AlphaBltAxyuAxyv_Nv12(const RECT* pSrc, const RECT* pDst, SubPicDesc* pTarget);
83 HRESULT AlphaBltAnv12_P010(const RECT* pSrc, const RECT* pDst, SubPicDesc* pTarget);
84 HRESULT AlphaBltAnv12_Nv12(const RECT* pSrc, const RECT* pDst, SubPicDesc* pTarget);
85 HRESULT AlphaBltOther(const RECT* pSrc, const RECT* pDst, SubPicDesc* pTarget);
87 HRESULT UnlockRGBA_YUV(CAtlList<CRect>* dirtyRectList);
88 HRESULT UnlockOther(CAtlList<CRect>* dirtyRectList);
90 void SubsampleAndInterlace( const CRect& cRect, bool u_first );
93 // CMemSubPicAllocator
95 class CMemSubPicAllocator : public CSubPicExAllocatorImpl
97 int m_type;
98 int m_alpha_blt_dst_type;
99 CSize m_maxsize;
101 bool AllocEx(bool fStatic, ISubPicEx** ppSubPic);
103 public:
104 CMemSubPicAllocator(int alpha_blt_dst_type, SIZE maxsize, int type=-1);