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

uberblit_swizzle.cpp « source « Kasumi « VirtualDub « thirdparty « src - github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d65c317a242ee15a0c79cc1dab09c90786a6ae55 (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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//	VirtualDub - Video processing and capture application
//	Graphics support library
//	Copyright (C) 1998-2009 Avery Lee
//
//	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., 675 Mass Ave, Cambridge, MA 02139, USA.

#include <stdafx.h>
#include "uberblit_swizzle.h"

void VDPixmapGen_Swap8In16::Init(IVDPixmapGen *gen, int srcIndex, uint32 w, uint32 h, uint32 bpr) {
	InitSource(gen, srcIndex);
	mRowLength = bpr;
	SetOutputSize(w, h);
	gen->AddWindowRequest(0, 0);
}

void VDPixmapGen_Swap8In16::Start() {
	StartWindow(mRowLength);
}

uint32 VDPixmapGen_Swap8In16::GetType(uint32 index) const {
	return mpSrc->GetType(mSrcIndex);
}

void VDPixmapGen_Swap8In16::Compute(void *dst0, sint32 y) {
	const uint8 *src = (const uint8 *)mpSrc->GetRow(y, mSrcIndex);
	uint8 *dst = (uint8 *)dst0;
	sint32 w = mRowLength;

	uint32 n4 = w >> 2;

	for(uint32 i=0; i<n4; ++i) {
		uint32 p = *(uint32 *)src;
		src += 4;

		uint32 r = ((p & 0xff00ff00) >> 8) + ((p & 0x00ff00ff) << 8);

		*(uint32 *)dst = r;
		dst += 4;
	}

	if (w & 2) {
		dst[0] = src[1];
		dst[1] = src[0];
		dst += 2;
		src += 2;
	}

	if (w & 1) {
		*dst = *src;
	}
}

/////////////////////////////////////////////////////////////////////////////

void VDPixmapGen_B8x2_To_B8R8::Init(IVDPixmapGen *srcCb, uint32 srcindexCb, IVDPixmapGen *srcCr, uint32 srcindexCr) {
	mpSrcCb = srcCb;
	mSrcIndexCb = srcindexCb;
	mpSrcCr = srcCr;
	mSrcIndexCr = srcindexCr;
	mWidth = srcCb->GetWidth(srcindexCb);
	mHeight = srcCb->GetHeight(srcindexCb);

	srcCb->AddWindowRequest(0, 0);
	srcCr->AddWindowRequest(0, 0);
}

void VDPixmapGen_B8x2_To_B8R8::Start() {
	mpSrcCb->Start();
	mpSrcCr->Start();

	StartWindow(mWidth * 2);
}

uint32 VDPixmapGen_B8x2_To_B8R8::GetType(uint32 output) const {
	return (mpSrcCb->GetType(mSrcIndexCb) & ~kVDPixType_Mask) | kVDPixType_B8R8;
}

void VDPixmapGen_B8x2_To_B8R8::Compute(void *dst0, sint32 y) {
	uint8 *VDRESTRICT dst = (uint8 *)dst0;
	const uint8 *VDRESTRICT srcCb = (const uint8 *)mpSrcCb->GetRow(y, mSrcIndexCb);
	const uint8 *VDRESTRICT srcCr = (const uint8 *)mpSrcCr->GetRow(y, mSrcIndexCr);

	sint32 w = mWidth;
	for(sint32 x=0; x<w; ++x) {
		uint8 cb = srcCb[0];
		uint8 cr = srcCr[0];

		dst[0] = cb;
		dst[1] = cr;

		++srcCb;
		++srcCr;
		dst += 2;
	}
}