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 }
90 "strength:%0.3f intensity:%0.3f antibanding:%d\n",
98 static const enum PixelFormat pix_fmts[] = {
125 #define GET_RGB_VALUES(r, g, b, src, map) do { \
126 r = src[x + map[R]]; \
127 g = src[x + map[G]]; \
128 b = src[x + map[B]]; \
136 int strength = histeq->
strength * 1000;
137 int intensity = histeq->
intensity * 1000;
138 int x,
y, i, luthi, lutlo, lut, luma, oluma,
m;
140 unsigned int r,
g,
b, jran;
156 src = inpic->
data[0];
157 dst = outpic->
data[0];
158 for (y = 0; y < inlink->
h; y++) {
159 for (x = 0; x < inlink->
w * histeq->
bpp; x += histeq->
bpp) {
161 luma = (55 * r + 182 * g + 19 *
b) >> 8;
170 for (x = 0; x < 256; x++)
177 for (x = 1; x < 256; x++)
181 for (x = 0; x < 256; x++)
182 histeq->
LUT[x] = (histeq->
LUT[x] * intensity) / (inlink->
h * inlink->
w);
186 for (x = 0; x < 256; x++)
187 histeq->
LUT[x] = (strength * histeq->
LUT[x]) / 255 +
188 ((255 - strength) * x) / 255;
193 src = inpic->
data[0];
194 dst = outpic->
data[0];
195 for (y = 0; y < inlink->
h; y++) {
196 for (x = 0; x < inlink->
w * histeq->
bpp; x += histeq->
bpp) {
199 for (i = 0; i < histeq->
bpp; ++i)
203 lut = histeq->
LUT[luma];
207 (histeq->
LUT[luma] + histeq->
LUT[luma - 1]) / 2 :
208 histeq->
LUT[luma - 1];
214 (histeq->
LUT[luma] + histeq->
LUT[luma + 1]) / 2 :
215 histeq->
LUT[luma + 1];
219 if (lutlo != luthi) {
221 lut = lutlo + ((luthi - lutlo + 1) * jran) /
LCG_M;
226 if (((m =
FFMAX3(r, g, b)) * lut) / luma > 255) {
231 r = (r * lut) / luma;
232 g = (g * lut) / luma;
233 b = (b * lut) / luma;
238 oluma = av_clip_uint8((55 * r + 182 * g + 19 * b) >> 8);
246 for (x = 0; x < 256; x++)
281 .priv_class = &histeq_class,