1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg 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 GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 #include <string.h>
19
22
27
28 // ProcAmp Min/Max/Default Values
29 #define BRIGHTNESS_MIN -100.0F
30 #define BRIGHTNESS_MAX 100.0F
31 #define BRIGHTNESS_DEFAULT 0.0F
32
33 #define CONTRAST_MIN 0.0F
34 #define CONTRAST_MAX 10.0F
35 #define CONTRAST_DEFAULT 1.0F
36
37 #define HUE_MIN -180.0F
38 #define HUE_MAX 180.0F
39 #define HUE_DEFAULT 0.0F
40
41 #define SATURATION_MIN 0.0F
42 #define SATURATION_MAX 10.0F
43 #define SATURATION_DEFAULT 1.0F
44
47
53
54 static float map(
float x,
float in_min,
float in_max,
float out_min,
float out_max)
55 {
57
58 slope = 1.0 * (out_max - out_min) / (in_max - in_min);
59 output = out_min + slope * (x - in_min);
60
62 }
63
65 {
68 VAStatus vas;
69 VAProcFilterParameterBufferColorBalance procamp_params[4];
70 VAProcFilterCapColorBalance procamp_caps[VAProcColorBalanceCount];
71 int num_caps;
73
74 memset(&procamp_params, 0, sizeof(procamp_params));
75 memset(&procamp_caps, 0, sizeof(procamp_caps));
76
77 num_caps = VAProcColorBalanceCount;
79 VAProcFilterColorBalance, &procamp_caps, &num_caps);
80
81 if (vas != VA_STATUS_SUCCESS) {
83 "filter caps: %d (%s).\n", vas, vaErrorStr(vas));
85 }
86
87 /* brightness */
88 procamp_params[
i].type = VAProcFilterColorBalance;
89 procamp_params[
i].attrib = VAProcColorBalanceBrightness;
91 procamp_caps[VAProcColorBalanceBrightness-1].range.min_value,
92 procamp_caps[VAProcColorBalanceBrightness-1].range.max_value);
94
95 /* contrast */
96 procamp_params[
i].type = VAProcFilterColorBalance;
97 procamp_params[
i].attrib = VAProcColorBalanceContrast;
99 procamp_caps[VAProcColorBalanceContrast-1].range.min_value,
100 procamp_caps[VAProcColorBalanceContrast-1].range.max_value);
102
103 /* hue */
104 procamp_params[
i].type = VAProcFilterColorBalance;
105 procamp_params[
i].attrib = VAProcColorBalanceHue;
107 procamp_caps[VAProcColorBalanceHue-1].range.min_value,
108 procamp_caps[VAProcColorBalanceHue-1].range.max_value);
110
111 /* saturation */
112 procamp_params[
i].type = VAProcFilterColorBalance;
113 procamp_params[
i].attrib = VAProcColorBalanceSaturation;
115 procamp_caps[VAProcColorBalanceSaturation-1].range.min_value,
116 procamp_caps[VAProcColorBalanceSaturation-1].range.max_value);
118
120 VAProcFilterParameterBufferType,
121 &procamp_params,
122 sizeof(procamp_params[0]),
124 }
125
127 {
132 VAProcPipelineParameterBuffer params;
133 int err;
134
138
141
147 }
148
150 if (err < 0)
152
155 if (err < 0)
157
159 params.num_filters = 1;
160
162 if (err < 0)
164
166
170
172
176 return err;
177 }
178
180 {
182
187
188 return 0;
189 }
190
191 #define OFFSET(x) offsetof(ProcampVAAPIContext, x)
192 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM)
194 { "b", "Output video brightness",
196 { "brightness", "Output video brightness",
198 { "s", "Output video saturation",
200 { "saturatio", "Output video saturation",
202 { "c", "Output video contrast",
204 { "contrast", "Output video contrast",
206 { "h", "Output video hue",
208 { "hue", "Output video hue",
211 };
212
214
216 {
221 },
222 };
223
225 {
229 },
230 };
231
233 .
name =
"procamp_vaapi",
234 .description =
NULL_IF_CONFIG_SMALL(
"ProcAmp (color balance) adjustments for hue, saturation, brightness, contrast"),
241 .priv_class = &procamp_vaapi_class,
243 };