annotate libmpcodecs/vf_eq2.c @ 8573:b2e4f9dab7ad

codec-cfg cannot be built when the gui is enabled - it fails to link with a couple of undefined external references. Problem is that mp_msg.c is included in the codec-cfg binary, but for codec-cfg the gui code in mp_msg.c shouldn't be compiled in.
author jkeil
date Fri, 27 Dec 2002 16:17:57 +0000
parents 916d5392dcc9
children 601ed700e1cc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7517
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
1 /*
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
2 * vf_eq2.c
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
3 *
7595
b667328dc62e renamed to LUT-based sw. eq.
alex
parents: 7517
diff changeset
4 * LUT-based software equalizer (brightness, contrast, gamma)
7517
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
5 *
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
6 * Hampa Hug <hhug@student.ethz.ch>
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
7 *
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
8 */
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
9
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
10 #include <stdio.h>
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
11 #include <stdlib.h>
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
12 #include <string.h>
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
13 #include <math.h>
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
14
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
15 #include "../config.h"
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
16 #include "../mp_msg.h"
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
17
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
18 #include "img_format.h"
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
19 #include "mp_image.h"
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
20 #include "vf.h"
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
21
8087
610976c39408 locale fix
nexus
parents: 7595
diff changeset
22 #ifdef USE_SETLOCALE
610976c39408 locale fix
nexus
parents: 7595
diff changeset
23 #include <locale.h>
610976c39408 locale fix
nexus
parents: 7595
diff changeset
24 #endif
610976c39408 locale fix
nexus
parents: 7595
diff changeset
25
7517
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
26
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
27 typedef struct vf_priv_s {
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
28 unsigned char *buf;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
29 int buf_w;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
30 int buf_h;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
31
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
32 double contrast;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
33 double bright;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
34 double gamma;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
35
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
36 unsigned char lut[256];
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
37 } vf_eq2_t;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
38
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
39
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
40 static
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
41 void create_lut (vf_eq2_t *eq2)
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
42 {
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
43 unsigned i;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
44 double c, b, g;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
45 double v;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
46
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
47 c = eq2->contrast;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
48 b = eq2->bright;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
49 g = eq2->gamma;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
50
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
51 if ((g < 0.001) || (g > 1000.0)) {
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
52 g = 1.0;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
53 }
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
54
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
55 fprintf (stderr, "vf_eq2: c=%.2f b=%.2f g=%.4f\n", c, b, g);
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
56
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
57 g = 1.0 / g;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
58
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
59 for (i = 0; i < 256; i++) {
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
60 v = (double) i / 255.0;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
61 v = c * (v - 0.5) + 0.5 + b;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
62
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
63 if (v <= 0.0) {
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
64 eq2->lut[i] = 0;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
65 }
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
66 else {
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
67 v = pow (v, g);
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
68
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
69 if (v >= 1.0) {
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
70 eq2->lut[i] = 255;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
71 }
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
72 else {
8349
916d5392dcc9 - It fixes a small bug where a byte value is divided by 255.0 to convert
arpi
parents: 8087
diff changeset
73 /* we divided by 255.0 so now we also multiply by 255.0, not
916d5392dcc9 - It fixes a small bug where a byte value is divided by 255.0 to convert
arpi
parents: 8087
diff changeset
74 by 256.0. "+ 0.5" ensures proper rounding */
916d5392dcc9 - It fixes a small bug where a byte value is divided by 255.0 to convert
arpi
parents: 8087
diff changeset
75 eq2->lut[i] = (unsigned char) (255.0 * v + 0.5);
7517
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
76 }
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
77 }
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
78 }
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
79 }
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
80
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
81 /* could inline this */
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
82 static
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
83 void process (unsigned char *dst, int dstride, unsigned char *src, int sstride,
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
84 int w, int h, unsigned char lut[256])
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
85 {
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
86 int i, j;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
87
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
88 for (j = 0; j < h; j++) {
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
89 for (i = 0; i < w; i++) {
8349
916d5392dcc9 - It fixes a small bug where a byte value is divided by 255.0 to convert
arpi
parents: 8087
diff changeset
90 dst[i] = lut[src[i]];
7517
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
91 }
8349
916d5392dcc9 - It fixes a small bug where a byte value is divided by 255.0 to convert
arpi
parents: 8087
diff changeset
92 src += sstride;
916d5392dcc9 - It fixes a small bug where a byte value is divided by 255.0 to convert
arpi
parents: 8087
diff changeset
93 dst += dstride;
7517
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
94 }
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
95 }
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
96
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
97 static
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
98 int put_image (vf_instance_t *vf, mp_image_t *src)
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
99 {
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
100 mp_image_t *dst;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
101 vf_eq2_t *eq2;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
102
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
103 eq2 = vf->priv;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
104
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
105 if ((eq2->buf == NULL) || (eq2->buf_w != src->stride[0]) || (eq2->buf_h != src->h)) {
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
106 eq2->buf = (unsigned char *) realloc (eq2->buf, src->stride[0] * src->h);
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
107 eq2->buf_w = src->stride[0];
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
108 eq2->buf_h = src->h;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
109 }
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
110
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
111 dst = vf_get_image (vf->next, src->imgfmt, MP_IMGTYPE_EXPORT, 0, src->w, src->h);
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
112
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
113 dst->stride[0] = src->stride[0];
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
114 dst->stride[1] = src->stride[1];
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
115 dst->stride[2] = src->stride[2];
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
116 dst->planes[0] = vf->priv->buf;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
117 dst->planes[1] = src->planes[1];
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
118 dst->planes[2] = src->planes[2];
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
119
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
120 process (
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
121 dst->planes[0], dst->stride[0], src->planes[0], src->stride[0],
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
122 src->w, src->h, eq2->lut
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
123 );
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
124
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
125 return vf_next_put_image (vf, dst);
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
126 }
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
127
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
128 static
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
129 int control (vf_instance_t *vf, int request, void *data)
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
130 {
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
131 vf_equalizer_t *eq;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
132
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
133 switch (request) {
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
134 case VFCTRL_SET_EQUALIZER:
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
135 eq = (vf_equalizer_t *) data;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
136
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
137 if (strcmp (eq->item, "gamma") == 0) {
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
138 vf->priv->gamma = exp (log (8.0) * eq->value / 100.0);
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
139 create_lut (vf->priv);
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
140 return CONTROL_TRUE;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
141 }
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
142 else if (strcmp (eq->item, "contrast") == 0) {
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
143 vf->priv->contrast = (1.0 / 100.0) * (eq->value + 100);
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
144 create_lut (vf->priv);
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
145 return CONTROL_TRUE;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
146 }
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
147 else if (strcmp (eq->item, "brightness") == 0) {
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
148 vf->priv->bright = (1.0 / 100.0) * eq->value;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
149 create_lut (vf->priv);
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
150 return CONTROL_TRUE;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
151 }
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
152 break;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
153
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
154 case VFCTRL_GET_EQUALIZER:
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
155 eq = (vf_equalizer_t *) data;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
156 if (strcmp (eq->item, "gamma") == 0) {
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
157 eq->value = (int) (100.0 * log (vf->priv->gamma) / log (8.0));
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
158 return CONTROL_TRUE;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
159 }
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
160 else if (strcmp (eq->item, "contrast") == 0) {
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
161 eq->value = (int) (100.0 * vf->priv->contrast) - 100;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
162 return CONTROL_TRUE;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
163 }
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
164 else if (strcmp (eq->item, "brightness") == 0) {
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
165 eq->value = (int) (100.0 * vf->priv->bright);
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
166 return CONTROL_TRUE;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
167 }
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
168 break;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
169 }
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
170
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
171 return vf_next_control (vf, request, data);
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
172 }
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
173
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
174 static
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
175 int query_format (vf_instance_t *vf, unsigned fmt)
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
176 {
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
177 switch (fmt) {
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
178 case IMGFMT_YVU9:
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
179 case IMGFMT_IF09:
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
180 case IMGFMT_YV12:
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
181 case IMGFMT_I420:
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
182 case IMGFMT_IYUV:
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
183 case IMGFMT_CLPL:
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
184 case IMGFMT_Y800:
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
185 case IMGFMT_Y8:
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
186 case IMGFMT_NV12:
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
187 case IMGFMT_444P:
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
188 case IMGFMT_422P:
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
189 case IMGFMT_411P:
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
190 return vf_next_query_format (vf, fmt);
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
191 }
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
192
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
193 return 0;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
194 }
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
195
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
196 static
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
197 void uninit (vf_instance_t *vf)
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
198 {
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
199 if (vf->priv != NULL) {
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
200 free (vf->priv->buf);
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
201 free (vf->priv);
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
202 }
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
203 }
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
204
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
205 static
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
206 int open (vf_instance_t *vf, char *args)
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
207 {
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
208 vf_eq2_t *eq2;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
209
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
210 vf->control = control;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
211 vf->query_format = query_format;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
212 vf->put_image = put_image;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
213 vf->uninit = uninit;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
214
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
215 vf->priv = (vf_eq2_t *) malloc (sizeof (vf_eq2_t));
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
216 eq2 = vf->priv;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
217
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
218 eq2->buf = NULL;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
219 eq2->buf_w = 0;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
220 eq2->buf_h = 0;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
221
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
222 eq2->gamma = 1.0;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
223 eq2->contrast = 1.0;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
224 eq2->bright = 0.0;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
225
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
226 if (args != NULL) {
8087
610976c39408 locale fix
nexus
parents: 7595
diff changeset
227 #ifdef USE_SETLOCALE
610976c39408 locale fix
nexus
parents: 7595
diff changeset
228 setlocale( LC_NUMERIC, "C" );
610976c39408 locale fix
nexus
parents: 7595
diff changeset
229 #endif
7517
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
230 sscanf (args, "%lf:%lf:%lf", &eq2->gamma, &eq2->contrast, &eq2->bright);
8087
610976c39408 locale fix
nexus
parents: 7595
diff changeset
231 #ifdef USE_SETLOCALE
610976c39408 locale fix
nexus
parents: 7595
diff changeset
232 setlocale( LC_NUMERIC, "" );
610976c39408 locale fix
nexus
parents: 7595
diff changeset
233 #endif
7517
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
234 }
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
235
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
236 create_lut (eq2);
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
237
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
238 return 1;
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
239 }
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
240
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
241 vf_info_t vf_info_eq2 = {
7595
b667328dc62e renamed to LUT-based sw. eq.
alex
parents: 7517
diff changeset
242 "LUT-based software equalizer",
7517
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
243 "eq2",
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
244 "Hampa Hug",
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
245 "",
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
246 &open
9d433771b6d0 -vf eq2, LUT-based brightness/contrast/gamma correction (Y-only)
arpi
parents:
diff changeset
247 };