46 #define LCG(x) (((x) * LCG_A + LCG_C) % LCG_M)
47 #define LCG_SEED 739187
62 int in_histogram [256];
63 int out_histogram[256];
69 #define OFFSET(x) offsetof(HisteqContext, x)
70 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
71 #define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, INT_MIN, INT_MAX, FLAGS, unit }
88 const char *shorthand[] = {
"strength",
"intensity",
"antibanding",
NULL };
91 histeq->
class = &histeq_class;
98 "strength:%0.3f intensity:%0.3f antibanding:%d\n",
112 static const enum PixelFormat pix_fmts[] = {
139 #define GET_RGB_VALUES(r, g, b, src, map) do { \
140 r = src[x + map[R]]; \
141 g = src[x + map[G]]; \
142 b = src[x + map[B]]; \
150 int strength = histeq->
strength * 1000;
151 int intensity = histeq->
intensity * 1000;
152 int x, y, i, luthi, lutlo, lut, luma, oluma,
m;
154 unsigned int r,
g,
b, jran;
170 src = inpic->
data[0];
171 dst = outpic->
data[0];
172 for (y = 0; y < inlink->
h; y++) {
173 for (x = 0; x < inlink->
w * histeq->
bpp; x += histeq->
bpp) {
175 luma = (55 * r + 182 * g + 19 *
b) >> 8;
184 for (x = 0; x < 256; x++)
191 for (x = 1; x < 256; x++)
195 for (x = 0; x < 256; x++)
196 histeq->
LUT[x] = (histeq->
LUT[x] * intensity) / (inlink->
h * inlink->
w);
200 for (x = 0; x < 256; x++)
201 histeq->
LUT[x] = (strength * histeq->
LUT[x]) / 255 +
202 ((255 - strength) * x) / 255;
207 src = inpic->
data[0];
208 dst = outpic->
data[0];
209 for (y = 0; y < inlink->
h; y++) {
210 for (x = 0; x < inlink->
w * histeq->
bpp; x += histeq->
bpp) {
213 for (i = 0; i < histeq->
bpp; ++i)
217 lut = histeq->
LUT[luma];
221 (histeq->
LUT[luma] + histeq->
LUT[luma - 1]) / 2 :
222 histeq->
LUT[luma - 1];
228 (histeq->
LUT[luma] + histeq->
LUT[luma + 1]) / 2 :
229 histeq->
LUT[luma + 1];
233 if (lutlo != luthi) {
235 lut = lutlo + ((luthi - lutlo + 1) * jran) /
LCG_M;
240 if (((m =
FFMAX3(r, g, b)) * lut) / luma > 255) {
245 r = (r * lut) / luma;
246 g = (g * lut) / luma;
247 b = (b * lut) / luma;
252 oluma = (55 * r + 182 * g + 19 *
b) >> 8;
260 for (x = 0; x < 256; x++)
297 .priv_class = &histeq_class,