71#define OFFSET(x) offsetof(ColorDetectContext, x)
72#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
78 {
"all",
"Detect all supported properties", 0,
AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0,
FLAGS, .unit =
"mode" },
81 {
"threshold",
"Detection threshold, as a fraction of the full range",
OFFSET(threshold),
AV_OPT_TYPE_FLOAT, {.dbl = 0.001}, 0.0, 0.05,
FLAGS },
111 const int depth =
desc->comp[0].depth;
112 const int range = (1 << depth) - 1;
114 const int mpeg_min = 16 << (depth - 8);
115 const int mpeg_max = 235 << (depth - 8);
147 s->offset = threshold;
149 s->mpeg_range = mpeg_max - mpeg_min;
150 s->offset =
range * (mpeg_min + threshold) + (1 << (depth - 1));
160 s->idx_a =
desc->comp[
desc->nb_components - 1].plane;
171 int jobnr,
int nb_jobs)
178 const int h_slice = y_end - y_start;
181 in->
width, h_slice,
s->mpeg_min,
s->mpeg_max))
189 int jobnr,
int nb_jobs)
197 const int h_slice = y_end - y_start;
200 const ptrdiff_t alpha_stride = in->
linesize[
s->idx_a];
201 const uint8_t *
alpha = in->
data[
s->idx_a] + y_start * alpha_stride;
204 for (
int i = 0;
i < nb_planes;
i++) {
207 alpha, alpha_stride,
w, h_slice,
s->range,
208 s->mpeg_range,
s->offset);
221 const int nb_threads =
FFMIN(inlink->
h,
s->nb_threads);
302 .p.name =
"colordetect",
304 .p.priv_class = &colordetect_class,
static int config_input(AVFilterLink *inlink)
const FFFilter ff_vf_colordetect
static AVFormatContext * ctx
void ff_inlink_set_status(AVFilterLink *link, int status)
Set the status on an input link.
int ff_outlink_get_status(AVFilterLink *link)
Get the status on an output link.
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
#define AV_LOG_INFO
Standard information.
static const int16_t alpha[]
static int activate(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
static int ff_slice_pos(int total, int jobnr, int nb_jobs)
Compute the boundary index for a slice when work of size total is split into nb_jobs slices.
#define FF_FILTER_FORWARD_WANTED(outlink, inlink)
Forward the frame_wanted_out flag from an output link to an input link.
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
#define FFERROR_NOT_READY
Filters implementation helper functions and internal structures.
#define AVFILTER_DEFINE_CLASS(fname)
#define FILTER_QUERY_FUNC2(func)
static int query_format(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static const AVFilterPad colordetect_inputs[]
static av_cold void report_detected_props(AVFilterContext *ctx)
static int detect_range(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int detect_alpha(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int config_input(AVFilterLink *inlink)
static const AVOption colordetect_options[]
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
@ COLOR_DETECT_COLOR_RANGE
@ COLOR_DETECT_ALPHA_MODE
static int activate(AVFilterContext *ctx)
static int query_format(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Memory handling functions.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
#define AV_PIX_FMT_FLAG_FLOAT
The pixel format contains IEEE-754 floating point values.
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
#define AV_PIX_FMT_FLAG_BE
Pixel format is big-endian.
#define AV_PIX_FMT_FLAG_XYZ
The pixel format contains XYZ-like data (as opposed to YUV/RGB/grayscale).
#define AV_PIX_FMT_FLAG_BAYER
The pixel format is following a Bayer pattern.
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
AVColorRange
Visual content value range.
@ AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_JPEG
Full range content.
#define atomic_load_explicit(object, order)
#define atomic_fetch_or_explicit(object, operand, order)
#define atomic_store_explicit(object, desired, order)
#define atomic_init(obj, value)
Describe the class of an AVClass context structure.
AVFilterLink ** outputs
array of pointers to output links
A link between two filters.
int h
agreed upon image height
AVFilterContext * dst
dest filter
int format
agreed upon media format
enum AVColorRange color_range
agreed upon YUV color range
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...
FFColorDetectDSPContext dsp
atomic_int detected_alpha
atomic_int detected_range
const AVPixFmtDescriptor * desc
@ FF_ALPHA_TRANSPARENT
alpha < alpha_max
@ FF_ALPHA_STRAIGHT
alpha < pixel
static av_cold void ff_color_detect_dsp_init(FFColorDetectDSPContext *dsp, int depth, int offset, enum AVColorRange color_range)
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.