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
|
#include "transcoder.h"
#define RED(y, u, v) (y + 1.4075 * (v - 128))
#define GREEN(y, u, v) (y - (0.3455 * (u - 128)) - (0.7169 * (v - 128)))
#define BLUE(y, u, v) (y + 1.7790 * (u - 128))
static Frame *transcode_yuv2brg0(Frame *input, char* rgb, int bufsz)
{
if(!rgb) {
rgb = new char[720 * 576 * 4];
bufsz = 720 * 576 * 4;
}
if(bufsz < 720 * 576 * 4) return NULL;
unsigned char Y0, Y1, U, V;
unsigned int byte = 0;
unsigned int pos = 0;
char *pframe = input->vframe;
while(pos < 720*576*4) {
Y0 = pframe[byte]; byte++;
U = pframe[byte]; byte++;
Y1 = pframe[byte]; byte++;
V = pframe[byte]; byte++;
rgb[pos+3] = 0;
rgb[pos+2] = (unsigned char)RED(Y0, U, V);
rgb[pos+1] = (unsigned char)GREEN(Y0, U, V);
rgb[pos+0] = (unsigned char)BLUE(Y0, U, V);
pos+=4;
rgb[pos+3] = 0;
rgb[pos+2] = (unsigned char)RED(Y1, U, V);
rgb[pos+1] = (unsigned char)GREEN(Y1, U, V);
rgb[pos+0] = (unsigned char)BLUE(Y1, U, V);
pos+=4;
}
return new Frame(rgb, bufsz, VF_BRG0, NULL, 0, AF_NONE);
}
Frame *transcode(Frame *input,
video_format_t vformat, char *vbuffer, int vbuffer_size,
audio_format_t aformat, char *abuffer, int abuffer_size)
{
if(vformat == VF_BRG0 && input->vformat == VF_YUV422 &&
aformat == AF_NONE && abuffer == NULL)
return transcode_yuv2brg0(input, vbuffer, vbuffer_size);
return NULL;
}
|