Go to the documentation of this file.
27 #include <stdatomic.h>
70 #define OFFSET(x) offsetof(ColorDetectContext, x)
71 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
77 {
"all",
"Detect all supported properties", 0,
AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0,
FLAGS, .unit =
"mode" },
107 const int depth =
desc->comp[0].depth;
108 const int mpeg_min = 16 << (depth - 8);
109 const int mpeg_max = 235 << (depth - 8);
115 s->mpeg_min = mpeg_min;
116 s->mpeg_max = mpeg_max;
126 s->idx_a =
desc->comp[
desc->nb_components - 1].plane;
137 int jobnr,
int nb_jobs)
142 const int y_start = (in->
height * jobnr) / nb_jobs;
143 const int y_end = (in->
height * (jobnr + 1)) / nb_jobs;
144 const int h_slice = y_end - y_start;
147 in->
width, h_slice,
s->mpeg_min,
s->mpeg_max))
154 int jobnr,
int nb_jobs)
160 const int y_start = (
h * jobnr) / nb_jobs;
161 const int y_end = (
h * (jobnr + 1)) / nb_jobs;
162 const int h_slice = y_end - y_start;
165 const ptrdiff_t alpha_stride = in->
linesize[
s->idx_a];
166 const uint8_t *
alpha = in->
data[
s->idx_a] + y_start * alpha_stride;
181 const int p = (1 <<
s->depth) - 1;
182 const int q =
s->mpeg_max -
s->mpeg_min;
183 const int k = p *
s->mpeg_min + q + (1 << (
s->depth - 1));
185 for (
int i = 0;
i < nb_planes;
i++) {
188 alpha, alpha_stride,
w, h_slice, p, q, k)) {
260 .
p.
name =
"colordetect",
262 .p.priv_class = &colordetect_class,
#define atomic_store(object, desired)
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.
static av_cold void uninit(AVFilterContext *ctx)
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)
#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[]
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
@ COLOR_DETECT_COLOR_RANGE
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
av_cold void ff_color_detect_dsp_init(FFColorDetectDSPContext *dsp, int depth, enum AVColorRange color_range)
#define FILTER_OUTPUTS(array)
Describe the class of an AVClass context structure.
atomic_int detected_alpha
static int detect_alpha(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
void ff_color_detect_dsp_init_x86(FFColorDetectDSPContext *dsp, int depth, enum AVColorRange color_range)
@ AVCOL_RANGE_UNSPECIFIED
static int ff_detect_range16_c(const uint8_t *data, ptrdiff_t stride, ptrdiff_t width, ptrdiff_t height, int mpeg_min, int mpeg_max)
static int ff_detect_alpha_limited_c(const uint8_t *color, ptrdiff_t color_stride, const uint8_t *alpha, ptrdiff_t alpha_stride, ptrdiff_t width, ptrdiff_t height, int p, int q, int k)
static int ff_detect_alpha_full_c(const uint8_t *color, ptrdiff_t color_stride, const uint8_t *alpha, ptrdiff_t alpha_stride, ptrdiff_t width, ptrdiff_t height, int p, int q, int k)
#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 ff_detect_alpha16_full_c(const uint8_t *color, ptrdiff_t color_stride, const uint8_t *alpha, ptrdiff_t alpha_stride, ptrdiff_t width, ptrdiff_t height, int p, int q, int k)
static int query_format(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
#define AV_LOG_INFO
Standard information.
#define AV_PIX_FMT_FLAG_BAYER
The pixel format is following a Bayer pattern.
int(* detect_range)(const uint8_t *data, ptrdiff_t stride, ptrdiff_t width, ptrdiff_t height, int mpeg_min, int mpeg_max)
static int ff_detect_alpha16_limited_c(const uint8_t *color, ptrdiff_t color_stride, const uint8_t *alpha, ptrdiff_t alpha_stride, ptrdiff_t width, ptrdiff_t height, int p, int q, int k)
#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 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
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 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.
#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...
int(* detect_alpha)(const uint8_t *color, ptrdiff_t color_stride, const uint8_t *alpha, ptrdiff_t alpha_stride, ptrdiff_t width, ptrdiff_t height, int p, int q, int k)
#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.
static int ff_detect_range_c(const uint8_t *data, ptrdiff_t stride, ptrdiff_t width, ptrdiff_t height, int mpeg_min, int mpeg_max)