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",
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++)
280 .priv_class = &histeq_class,
static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
int out_histogram[256]
output histogram
This structure describes decoded (raw) audio or video data.
static const AVFilterPad outputs[]
Main libavfilter public API header.
packed RGB 8:8:8, 24bpp, RGBRGB...
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel used by the pixel format described by pixdesc.
int h
agreed upon image height
uint8_t rgba_map[4]
components position
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
static const AVOption histeq_options[]
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
const char * name
Pad name.
int in_histogram[256]
input histogram
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
#define AV_LOG_VERBOSE
Detailed information.
A filter pad used for either input or output.
A link between two filters.
#define CONST(name, help, val, unit)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
void * priv
private data for use by the filter
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
static int config_input(AVFilterLink *inlink)
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
int w
agreed upon image width
#define GET_RGB_VALUES(r, g, b, src, map)
static const AVFilterPad histeq_outputs[]
packed RGB 8:8:8, 24bpp, BGRBGR...
int format
agreed upon media format
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
#define av_dlog(pctx,...)
av_dlog macros
static av_cold int init(AVFilterContext *ctx)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
AVFILTER_DEFINE_CLASS(histeq)
Describe the class of an AVClass context structure.
static const AVFilterPad inputs[]
const char * name
Filter name.
static int query_formats(AVFilterContext *ctx)
AVFilterLink ** outputs
array of pointers to output links
int antibanding
HisteqAntibanding.
static const AVFilterPad histeq_inputs[]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
common internal and external API header
AVFilterContext * dst
dest filter
int LUT[256]
lookup table derived from histogram[]
AVPixelFormat
Pixel format.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.