Go to the documentation of this file.
27 #include <stdatomic.h>
63 #define OFFSET(x) offsetof(ColorDetectContext, x)
64 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
70 {
"all",
"Detect all supported properties", 0,
AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0,
FLAGS, .unit =
"mode" },
100 const int depth =
desc->comp[0].depth;
101 const int mpeg_min = 16 << (depth - 8);
102 const int mpeg_max = 235 << (depth - 8);
108 s->mpeg_min = mpeg_min;
109 s->mpeg_max = mpeg_max;
119 s->idx_a =
desc->comp[
desc->nb_components - 1].plane;
130 int jobnr,
int nb_jobs)
135 const int y_start = (in->
height * jobnr) / nb_jobs;
136 const int y_end = (in->
height * (jobnr + 1)) / nb_jobs;
137 const int h_slice = y_end - y_start;
140 in->
width, h_slice,
s->mpeg_min,
s->mpeg_max))
142 memory_order_relaxed);
148 int jobnr,
int nb_jobs)
154 const int y_start = (
h * jobnr) / nb_jobs;
155 const int y_end = (
h * (jobnr + 1)) / nb_jobs;
156 const int h_slice = y_end - y_start;
159 const ptrdiff_t alpha_stride = in->
linesize[
s->idx_a];
160 const uint8_t *
alpha = in->
data[
s->idx_a] + y_start * alpha_stride;
174 const int alpha_max = (1 <<
s->depth) - 1;
175 const int mpeg_range =
s->mpeg_max -
s->mpeg_min;
176 const int offset = alpha_max *
s->mpeg_min + (1 << (
s->depth - 1));
179 for (
int i = 0;
i < nb_planes;
i++) {
182 alpha, alpha_stride,
w, h_slice, alpha_max,
219 memory_order_relaxed);
227 memory_order_relaxed);
277 .
p.
name =
"colordetect",
279 .p.priv_class = &colordetect_class,
const AVPixFmtDescriptor * desc
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
#define AV_PIX_FMT_FLAG_FLOAT
The pixel format contains IEEE-754 floating point values.
static int detect_range(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
#define FILTER_INPUTS(array)
This structure describes decoded (raw) audio or video data.
@ AVCOL_RANGE_JPEG
Full range content.
const char * name
Filter name.
A link between two filters.
const FFFilter ff_vf_colordetect
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int config_input(AVFilterLink *inlink)
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
AVFILTER_DEFINE_CLASS(colordetect)
A filter pad used for either input or output.
static const AVFilterPad colordetect_inputs[]
static av_cold void report_detected_props(AVFilterContext *ctx)
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
@ COLOR_DETECT_COLOR_RANGE
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
#define FILTER_OUTPUTS(array)
Describe the class of an AVClass context structure.
atomic_int detected_alpha
@ FF_ALPHA_TRANSPARENT
alpha < alpha_max
static int detect_alpha(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
@ AVCOL_RANGE_UNSPECIFIED
#define atomic_load_explicit(object, order)
void ff_inlink_set_status(AVFilterLink *link, int status)
Set the status on an input link.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
static int query_format(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
FF_FILTER_FORWARD_WANTED(outlink, inlink)
#define AV_LOG_INFO
Standard information.
#define AV_PIX_FMT_FLAG_BAYER
The pixel format is following a Bayer pattern.
#define i(width, name, range_min, range_max)
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
#define atomic_store_explicit(object, desired, order)
#define FILTER_QUERY_FUNC2(func)
static const AVOption colordetect_options[]
#define AV_PIX_FMT_FLAG_BE
Pixel format is big-endian.
const char * name
Pad name.
FFColorDetectDSPContext dsp
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
#define AV_PIX_FMT_FLAG_XYZ
The pixel format contains XYZ-like data (as opposed to YUV/RGB/grayscale).
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
#define atomic_fetch_or_explicit(object, operand, order)
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
static av_cold void ff_color_detect_dsp_init(FFColorDetectDSPContext *dsp, int depth, enum AVColorRange color_range)
int ff_outlink_get_status(AVFilterLink *link)
Get the status on an output link.
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
AVFilter p
The public AVFilter.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
@ COLOR_DETECT_ALPHA_MODE
atomic_int detected_range
static const int16_t alpha[]
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
static int activate(AVFilterContext *ctx)
#define atomic_init(obj, value)
AVColorRange
Visual content value range.
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ FF_ALPHA_STRAIGHT
alpha < pixel