46#define LCG(x) (((x) * LCG_A + LCG_C) % LCG_M)
47#define LCG_SEED 739187
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, u) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, INT_MIN, INT_MAX, FLAGS, .unit = u }
89 "strength:%0.3f intensity:%0.3f antibanding:%d\n",
118#define GET_RGB_VALUES(r, g, b, src, map) do { \
119 r = src[x + map[R]]; \
120 g = src[x + map[G]]; \
121 b = src[x + map[B]]; \
129 int strength = histeq->
strength * 1000;
130 int intensity = histeq->
intensity * 1000;
131 int x, y,
i, luthi, lutlo, lut, luma, oluma, m;
133 unsigned int r,
g,
b, jran;
151 for (y = 0; y < inlink->
h; y++) {
152 for (x = 0; x < inlink->
w * histeq->
bpp; x += histeq->
bpp) {
154 luma = (55 *
r + 182 *
g + 19 *
b) >> 8;
163 for (x = 0; x < 256; x++)
170 for (x = 1; x < 256; x++)
174 for (x = 0; x < 256; x++)
175 histeq->
LUT[x] = (histeq->
LUT[x] * intensity) / (inlink->
h * inlink->
w);
179 for (x = 0; x < 256; x++)
180 histeq->
LUT[x] = (strength * histeq->
LUT[x]) / 255 +
181 ((255 - strength) * x) / 255;
188 for (y = 0; y < inlink->
h; y++) {
189 for (x = 0; x < inlink->
w * histeq->
bpp; x += histeq->
bpp) {
192 for (
i = 0;
i < histeq->
bpp; ++
i)
196 lut = histeq->
LUT[luma];
200 (histeq->
LUT[luma] + histeq->
LUT[luma - 1]) / 2 :
201 histeq->
LUT[luma - 1];
207 (histeq->
LUT[luma] + histeq->
LUT[luma + 1]) / 2 :
208 histeq->
LUT[luma + 1];
212 if (lutlo != luthi) {
214 lut = lutlo + ((luthi - lutlo + 1) * jran) /
LCG_M;
219 if (((m =
FFMAX3(
r,
g,
b)) * lut) / luma > 255) {
224 r = (
r * lut) / luma;
225 g = (
g * lut) / luma;
226 b = (
b * lut) / luma;
239 for (x = 0; x < 256; x++)
259 .p.priv_class = &histeq_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static int config_input(AVFilterLink *inlink)
const FFFilter ff_vf_histeq
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
common internal and external API header
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
int(* init)(AVBSFContext *ctx)
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_LOG_VERBOSE
Detailed information.
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FILTER_PIXFMTS_ARRAY(array)
#define AVFILTER_DEFINE_CLASS(fname)
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static enum AVPixelFormat pix_fmts[]
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel used by the pixel format described by pixdesc.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Describe the class of an AVClass context structure.
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
uint8_t rgba_map[4]
components position
int LUT[256]
lookup table derived from histogram[]
int out_histogram[256]
output histogram
int antibanding
HisteqAntibanding.
int in_histogram[256]
input histogram
static AVFormatContext * ctx
static const AVOption histeq_options[]
static const AVFilterPad histeq_inputs[]
static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
@ HISTEQ_ANTIBANDING_NONE
@ HISTEQ_ANTIBANDING_STRONG
@ HISTEQ_ANTIBANDING_WEAK
static int config_input(AVFilterLink *inlink)
#define CONST(name, help, val, u)
#define GET_RGB_VALUES(r, g, b, src, map)
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.