46 #define LCG(x) (((x) * LCG_A + LCG_C) % LCG_M)
47 #define LCG_SEED 739187
61 int in_histogram [256];
62 int out_histogram[256];
68 #define OFFSET(x) offsetof(HisteqContext, x)
69 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
70 #define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, INT_MIN, INT_MAX, FLAGS, unit }
89 "strength:%0.3f intensity:%0.3f antibanding:%d\n",
124 #define GET_RGB_VALUES(r, g, b, src, map) do { \
125 r = src[x + map[R]]; \
126 g = src[x + map[G]]; \
127 b = src[x + map[B]]; \
135 int strength = histeq->
strength * 1000;
136 int intensity = histeq->
intensity * 1000;
137 int x,
y, i, luthi, lutlo, lut, luma, oluma,
m;
139 unsigned int r,
g,
b, jran;
155 src = inpic->
data[0];
156 dst = outpic->
data[0];
157 for (y = 0; y < inlink->
h; y++) {
158 for (x = 0; x < inlink->
w * histeq->
bpp; x += histeq->
bpp) {
160 luma = (55 * r + 182 * g + 19 *
b) >> 8;
169 for (x = 0; x < 256; x++)
176 for (x = 1; x < 256; x++)
180 for (x = 0; x < 256; x++)
181 histeq->
LUT[x] = (histeq->
LUT[x] * intensity) / (inlink->
h * inlink->
w);
185 for (x = 0; x < 256; x++)
186 histeq->
LUT[x] = (strength * histeq->
LUT[x]) / 255 +
187 ((255 - strength) * x) / 255;
192 src = inpic->
data[0];
193 dst = outpic->
data[0];
194 for (y = 0; y < inlink->
h; y++) {
195 for (x = 0; x < inlink->
w * histeq->
bpp; x += histeq->
bpp) {
198 for (i = 0; i < histeq->
bpp; ++i)
202 lut = histeq->
LUT[luma];
206 (histeq->
LUT[luma] + histeq->
LUT[luma - 1]) / 2 :
207 histeq->
LUT[luma - 1];
213 (histeq->
LUT[luma] + histeq->
LUT[luma + 1]) / 2 :
214 histeq->
LUT[luma + 1];
218 if (lutlo != luthi) {
220 lut = lutlo + ((luthi - lutlo + 1) * jran) /
LCG_M;
225 if (((m =
FFMAX3(r, g, b)) * lut) / luma > 255) {
230 r = (r * lut) / luma;
231 g = (g * lut) / luma;
232 b = (b * lut) / luma;
237 oluma = av_clip_uint8((55 * r + 182 * g + 19 * b) >> 8);
245 for (x = 0; x < 256; x++)
279 .priv_class = &histeq_class,