summaryrefslogtreecommitdiffstats
path: root/drivers/theoraplayer/src/YUV/C/yuv420_grey_c.c
blob: 8af5dd1f5851185abf826e58bb47dca3205c3644 (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
/************************************************************************************
This source file is part of the Theora Video Playback Library
For latest info, see http://libtheoraplayer.googlecode.com
*************************************************************************************
Copyright (c) 2008-2014 Kresimir Spes (kspes@cateia.com)
This program is free software; you can redistribute it and/or modify it under
the terms of the BSD license: http://opensource.org/licenses/BSD-3-Clause
*************************************************************************************/
#include "yuv_util.h"

static void _decodeGrey3(struct TheoraPixelTransform* t, int stride, int nBytes)
{
	unsigned char *ySrc = t->y, *yLineEnd, *out = t->out;
	unsigned int y;
	for (y = 0; y < t->h; ++y, ySrc += t->yStride - t->w, out += stride-t->w * nBytes)
		for (yLineEnd = ySrc + t->w; ySrc != yLineEnd; ++ySrc, out += nBytes)
			out[0] = out[1] = out[2] = *ySrc;
}

void decodeGrey(struct TheoraPixelTransform* t)
{
	unsigned char *ySrc = t->y, *yLineEnd, *out = t->out;
	unsigned int y;
	for (y = 0; y < t->h; ++y, ySrc += t->yStride - t->w)
		for (yLineEnd = ySrc + t->w; ySrc != yLineEnd; ++ySrc, ++out)
			*out = *ySrc;

}

void decodeGrey3(struct TheoraPixelTransform* t)
{
	_decodeGrey3(t, t->w * 3, 3);
}

void decodeGreyA(struct TheoraPixelTransform* t)
{
	_decodeGrey3(t, t->w * 4, 4);
	_decodeAlpha(incOut(t, 3), t->w * 4);
}

void decodeGreyX(struct TheoraPixelTransform* t)
{
	_decodeGrey3(t, t->w * 4, 4);
}

void decodeAGrey(struct TheoraPixelTransform* t)
{
	_decodeGrey3(incOut(t, 1), t->w * 4, 4);
	_decodeAlpha(t, t->w * 4);
}

void decodeXGrey(struct TheoraPixelTransform* t)
{
	_decodeGrey3(incOut(t, 1), t->w * 4, 4);
}