-
Notifications
You must be signed in to change notification settings - Fork 15
/
yuv2rgb.h
120 lines (116 loc) · 4.13 KB
/
yuv2rgb.h
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
109
110
111
112
113
114
115
116
117
118
119
120
//==============================================================================
// xxYUV : yuv2rgb Header
//
// Copyright (c) 2020-2021 TAiGA
// https://github.com/metarutaiga/xxYUV
//==============================================================================
#pragma once
#ifndef xxYUV_EXPORT
#define xxYUV_EXPORT
#endif
//------------------------------------------------------------------------------
typedef struct _yuv2rgb_parameter
{
int width;
int height;
const void* y;
const void* u;
const void* v;
int alignWidth;
int alignHeight;
int alignSize;
int strideY;
int strideU;
int strideV;
bool videoRange;
void* rgb;
int componentRGB;
int strideRGB;
bool swizzleRGB;
} yuv2rgb_parameter;
//------------------------------------------------------------------------------
xxYUV_EXPORT void yuv2rgb_yu12(const yuv2rgb_parameter* parameter);
xxYUV_EXPORT void yuv2rgb_yv12(const yuv2rgb_parameter* parameter);
xxYUV_EXPORT void yuv2rgb_nv12(const yuv2rgb_parameter* parameter);
xxYUV_EXPORT void yuv2rgb_nv21(const yuv2rgb_parameter* parameter);
//------------------------------------------------------------------------------
#ifndef xxYUV_DEPRECATED
//------------------------------------------------------------------------------
inline void yuv2rgb_yu12(int width, int height, const void* yuv, void* rgb, bool fullRange = true, int rgbWidth = 3, bool rgbSwizzle = false, int strideRGB = 0, int alignWidth = 16, int alignHeight = 1, int alignSize = 1)
{
yuv2rgb_parameter parameter =
{
.width = width,
.height = height,
.y = yuv,
.alignWidth = alignWidth,
.alignHeight = alignHeight,
.alignSize = alignSize,
.videoRange = !fullRange,
.rgb = rgb,
.componentRGB = rgbWidth,
.strideRGB = strideRGB,
.swizzleRGB = rgbSwizzle,
};
yuv2rgb_yu12(¶meter);
}
//------------------------------------------------------------------------------
inline void yuv2rgb_yv12(int width, int height, const void* yuv, void* rgb, bool fullRange = true, int rgbWidth = 3, bool rgbSwizzle = false, int strideRGB = 0, int alignWidth = 16, int alignHeight = 1, int alignSize = 1)
{
yuv2rgb_parameter parameter =
{
.width = width,
.height = height,
.y = yuv,
.alignWidth = alignWidth,
.alignHeight = alignHeight,
.alignSize = alignSize,
.videoRange = !fullRange,
.rgb = rgb,
.componentRGB = rgbWidth,
.strideRGB = strideRGB,
.swizzleRGB = rgbSwizzle,
};
yuv2rgb_yv12(¶meter);
}
//------------------------------------------------------------------------------
inline void yuv2rgb_nv12(int width, int height, const void* yuv, void* rgb, bool fullRange = true, int rgbWidth = 3, bool rgbSwizzle = false, int strideRGB = 0, int alignWidth = 16, int alignHeight = 1, int alignSize = 1)
{
yuv2rgb_parameter parameter =
{
.width = width,
.height = height,
.y = yuv,
.alignWidth = alignWidth,
.alignHeight = alignHeight,
.alignSize = alignSize,
.videoRange = !fullRange,
.rgb = rgb,
.componentRGB = rgbWidth,
.strideRGB = strideRGB,
.swizzleRGB = rgbSwizzle,
};
yuv2rgb_nv12(¶meter);
}
//------------------------------------------------------------------------------
inline void yuv2rgb_nv21(int width, int height, const void* yuv, void* rgb, bool fullRange = true, int rgbWidth = 3, bool rgbSwizzle = false, int strideRGB = 0, int alignWidth = 16, int alignHeight = 1, int alignSize = 1)
{
yuv2rgb_parameter parameter =
{
.width = width,
.height = height,
.y = yuv,
.alignWidth = alignWidth,
.alignHeight = alignHeight,
.alignSize = alignSize,
.videoRange = !fullRange,
.rgb = rgb,
.componentRGB = rgbWidth,
.strideRGB = strideRGB,
.swizzleRGB = rgbSwizzle,
};
yuv2rgb_nv21(¶meter);
}
//------------------------------------------------------------------------------
#endif
//------------------------------------------------------------------------------