47 #define LCG(x) (((x) * LCG_A + LCG_C) % LCG_M)
48 #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",
126 #define GET_RGB_VALUES(r, g, b, src, map) do { \
127 r = src[x + map[R]]; \
128 g = src[x + map[G]]; \
129 b = src[x + map[B]]; \
137 int strength = histeq->
strength * 1000;
138 int intensity = histeq->
intensity * 1000;
139 int x, y, i, luthi, lutlo, lut, luma, oluma, m;
141 unsigned int r,
g,
b, jran;
157 src = inpic->
data[0];
158 dst = outpic->
data[0];
159 for (y = 0; y < inlink->
h; y++) {
160 for (x = 0; x < inlink->
w * histeq->
bpp; x += histeq->
bpp) {
162 luma = (55 * r + 182 * g + 19 *
b) >> 8;
171 for (x = 0; x < 256; x++)
178 for (x = 1; x < 256; x++)
182 for (x = 0; x < 256; x++)
183 histeq->
LUT[x] = (histeq->
LUT[x] * intensity) / (inlink->
h * inlink->
w);
187 for (x = 0; x < 256; x++)
188 histeq->
LUT[x] = (strength * histeq->
LUT[x]) / 255 +
189 ((255 - strength) * x) / 255;
194 src = inpic->
data[0];
195 dst = outpic->
data[0];
196 for (y = 0; y < inlink->
h; y++) {
197 for (x = 0; x < inlink->
w * histeq->
bpp; x += histeq->
bpp) {
200 for (i = 0; i < histeq->
bpp; ++i)
204 lut = histeq->
LUT[luma];
208 (histeq->
LUT[luma] + histeq->
LUT[luma - 1]) / 2 :
209 histeq->
LUT[luma - 1];
215 (histeq->
LUT[luma] + histeq->
LUT[luma + 1]) / 2 :
216 histeq->
LUT[luma + 1];
220 if (lutlo != luthi) {
222 lut = lutlo + ((luthi - lutlo + 1) * jran) /
LCG_M;
227 if (((m =
FFMAX3(r, g, b)) * lut) / luma > 255) {
232 r = (r * lut) / luma;
233 g = (g * lut) / luma;
234 b = (b * lut) / luma;
239 oluma = av_clip_uint8((55 * r + 182 * g + 19 * b) >> 8);
247 for (x = 0; x < 256; x++)
281 .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.
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)
common internal API header
static const AVFilterPad histeq_outputs[]
packed RGB 8:8:8, 24bpp, BGRBGR...
static const AVFilterPad outputs[]
int format
agreed upon media format
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
static const AVFilterPad inputs[]
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.
const char * name
Filter name.
static int query_formats(AVFilterContext *ctx)
AVFilterLink ** outputs
array of pointers to output links
static enum AVPixelFormat pix_fmts[]
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.