• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18 #include "vou_coef_org.h"
19 
20 #ifdef __cplusplus
21 #if __cplusplus
22 extern "C" {
23 #endif
24 #endif /* end of #ifdef __cplusplus */
25 
26 /* RGB->YUV601 coefficient matrix */
27 const csc_coef g_csc_rgb2yuv601_tv = {
28     /* csc multiplier coefficient */
29     258, 504, 98, -148, -291, 439, 439, -368, -71,
30     /* csc input DC component (IDC) */
31     0, 0, 0,
32     /* csc output DC component (ODC) */
33     16, 128, 128,
34     0, 0, 0
35 };
36 
37 /* RGB->YUV601 coefficient matrix */
38 const csc_coef g_csc_rgb2yuv601_pc = {
39     /* csc multiplier coefficient */
40     299, 587, 114, -172, -339, 511, 511, -428, -83,
41     /* csc input DC component (IDC) */
42     0, 0, 0,
43     /* csc output DC component (ODC) */
44     0, 128, 128,
45     0, 0, 0
46 };
47 
48 /* RGB->YUV709 coefficient matrix */
49 const csc_coef g_csc_rgb2yuv709_tv = {
50     /* csc multiplier coefficient */
51     184, 614, 62, -101, -338, 439, 439, -399, -40,
52     /* csc input DC component (IDC) */
53     0, 0, 0,
54     /* csc output DC component (ODC) */
55     16, 128, 128,
56     0, 0, 0
57 };
58 
59 /* RGB->YUV709 coefficient matrix ,output full[0,255] */
60 const csc_coef g_csc_rgb2yuv709_pc = {
61     /* csc multiplier coefficient */
62     213, 715, 72, -117, -394, 511, 511, -464, -47,
63     /* csc input DC component (IDC) */
64     0, 0, 0,
65     /* csc output DC component (ODC) */
66     0, 128, 128,
67     0, 0, 0
68 };
69 
70 /* RGB -> YUV BT.2020 coefficient matrix */
71 const csc_coef g_csc_rgb2yuv2020_pc = {
72     /* csc multiplier coefficient */
73     263, 678, 59, -143, -368, 511, 511, -470, -41,
74     /* csc input DC component (IDC) */
75     0, 0, 0,
76     /* csc output DC component (ODC) */
77     0, 128, 128,
78     0, 0, 0
79 };
80 
81 /* YUV601->RGB coefficient matrix */
82 const csc_coef g_csc_yuv601_to_rgb_pc = {
83     /* csc multiplier coefficient */
84     1164, 0, 1596, 1164, -391, -813, 1164, 2018, 0,
85     /* csc input DC component (IDC) */
86     -16, -128, -128,
87     /* csc output DC component (ODC) */
88     0, 0, 0,
89     0, 0, 0
90 };
91 
92 /* YUV709->RGB coefficient matrix */
93 const csc_coef g_csc_yuv709_to_rgb_pc = {
94     /* csc multiplier coefficient */
95     1164, 0, 1793, 1164, -213, -534, 1164, 2115, 0,
96     /* csc input DC component (IDC) */
97     -16, -128, -128,
98     /* csc output DC component (ODC) */
99     0, 0, 0,
100     0, 0, 0
101 };
102 
103 /* BT.2020 YUV -> RGB coefficient matrix */
104 const csc_coef g_csc_yuv2020_to_rgb_pc = {
105     /* csc multiplier coefficient */
106     1000, 0, 1442, 1000, -160, -560, 1000, 1841, 0,
107     /* csc input DC component (IDC) */
108     0, -128, -128,
109     /* csc output DC component (ODC) */
110     0, 0, 0,
111     0, 0, 0
112 };
113 
114 /* YUV601->YUV709 coefficient matrix,output full[0,255] */
115 const csc_coef g_csc_yuv2yuv_601_709 = {
116     /* csc multiplier coefficient */
117     1000, -116, 208, 0, 1017, 114, 0, 75, 1025,
118     /* csc input DC component (IDC) */
119     -16, -128, -128,
120     /* csc output DC component (ODC) */
121     16, 128, 128,
122     0, 0, 0
123 };
124 
125 /* YUV709->YUV601 coefficient matrix,output full[0,255] */
126 const csc_coef g_csc_yuv2yuv_709_601 = {
127     /* csc multiplier coefficient */
128     1000, 99, 192, 0, 990, -111, 0, -72, 983,
129     /* csc input DC component (IDC) */
130     -16, -128, -128,
131     /* csc output DC component (ODC) */
132     16, 128, 128,
133     0, 0, 0
134 };
135 
136 /* YUV601->YUV709 coefficient matrix */
137 const csc_coef g_csc_init = {
138     /* csc multiplier coefficient */
139     1000, 0, 0, 0, 1000, 0, 0, 0, 1000,
140     /* csc input DC component (IDC) */
141     -16, -128, -128,
142     /* csc output DC component (ODC) */
143     16, 128, 128,
144     0, 0, 0
145 };
146 
147 const int g_sin_table[61] = {
148     -500, -485, -469, -454, -438, -422, -407, -391, -374, -358,
149     -342, -325, -309, -292, -276, -259, -242, -225, -208, -191,
150     -174, -156, -139, -122, -104, -87, -70, -52, -35, -17,
151     0, 17, 35, 52, 70, 87, 104, 122, 139, 156,
152     174, 191, 208, 225, 242, 259, 276, 292, 309, 325,
153     342, 358, 374, 391, 407, 422, 438, 454, 469, 485,
154     500
155 };
156 
157 const int g_cos_table[61] = {
158     866, 875, 883, 891, 899, 906, 914, 921, 927, 934,
159     940, 946, 951, 956, 961, 966, 970, 974, 978, 982,
160     985, 988, 990, 993, 995, 996, 998, 999, 999, 1000,
161     1000, 1000, 999, 999, 998, 996, 995, 993, 990, 988,
162     985, 982, 978, 974, 970, 966, 961, 956, 951, 946,
163     940, 934, 927, 921, 914, 906, 899, 891, 883, 875,
164     866
165 };
166 
vo_get_csc_coef(hal_csc_mode csc_mode)167 const csc_coef *vo_get_csc_coef(hal_csc_mode csc_mode)
168 {
169     switch (csc_mode) {
170         case HAL_CSC_MODE_BT601_TO_BT601:
171         case HAL_CSC_MODE_BT709_TO_BT709:
172         case HAL_CSC_MODE_RGB_TO_RGB:
173             return &g_csc_init;
174         case HAL_CSC_MODE_BT709_TO_BT601:
175             return &g_csc_yuv2yuv_709_601;
176         case HAL_CSC_MODE_BT601_TO_BT709:
177             return &g_csc_yuv2yuv_601_709;
178         case HAL_CSC_MODE_BT601_TO_RGB_PC:
179             return &g_csc_yuv601_to_rgb_pc;
180         case HAL_CSC_MODE_BT709_TO_RGB_PC:
181             return &g_csc_yuv709_to_rgb_pc;
182         case HAL_CSC_MODE_RGB_TO_BT601_PC:
183             return &g_csc_rgb2yuv601_pc;
184         case HAL_CSC_MODE_RGB_TO_BT709_PC:
185             return &g_csc_rgb2yuv709_pc;
186         case HAL_CSC_MODE_RGB_TO_BT601_TV:
187             return &g_csc_rgb2yuv601_tv;
188         case HAL_CSC_MODE_RGB_TO_BT709_TV:
189             return &g_csc_rgb2yuv709_tv;
190         default:
191             return HI_NULL;
192     }
193 }
194 
vo_get_sin_table(hi_void)195 const int *vo_get_sin_table(hi_void)
196 {
197     return g_sin_table;
198 }
199 
vo_get_cos_table(hi_void)200 const int *vo_get_cos_table(hi_void)
201 {
202     return g_cos_table;
203 }
204 
205 #ifdef __cplusplus
206 #if __cplusplus
207 }
208 #endif
209 #endif /* end of #ifdef __cplusplus */
210 
211