Go to the documentation of this file.
22 #include "config_components.h"
77 int threshold,
const uint8_t *coordinates[],
int coord,
82 for (x = 0; x <
width; x++) {
86 for (
i = 0;
i < 8;
i++) {
87 if (coord & (1 <<
i)) {
98 int threshold,
const uint8_t *coordinates[],
int coord,
101 uint16_t *dst = (uint16_t *)dstp;
104 for (x = 0; x <
width; x++) {
108 for (
i = 0;
i < 8;
i++) {
109 if (coord & (1 <<
i)) {
120 int threshold,
const uint8_t *coordinates[],
int coord,
125 for (x = 0; x <
width; x++) {
129 for (
i = 0;
i < 8;
i++) {
130 if (coord & (1 <<
i)) {
141 int threshold,
const uint8_t *coordinates[],
int coord,
144 uint16_t *dst = (uint16_t *)dstp;
147 for (x = 0; x <
width; x++) {
151 for (
i = 0;
i < 8;
i++) {
152 if (coord & (1 <<
i)) {
163 int threshold,
const uint8_t *coordinates[],
int coord,
168 for (x = 0; x <
width; x++) {
172 for (
i = 0;
i < 8; sum += *(coordinates[
i++] + x));
179 int threshold,
const uint8_t *coordinates[],
int coord,
182 uint16_t *dst = (uint16_t *)dstp;
185 for (x = 0; x <
width; x++) {
189 for (
i = 0;
i < 8; sum +=
AV_RN16A(coordinates[
i++] + x * 2));
196 int threshold,
const uint8_t *coordinates[],
int coord,
201 for (x = 0; x <
width; x++) {
205 for (
i = 0;
i < 8; sum += *(coordinates[
i++] + x));
212 int threshold,
const uint8_t *coordinates[],
int coord,
215 uint16_t *dst = (uint16_t *)dstp;
218 for (x = 0; x <
width; x++) {
222 for (
i = 0;
i < 8; sum +=
AV_RN16A(coordinates[
i++] + x * 2));
234 s->depth =
desc->comp[0].depth;
235 s->max = (1 <<
s->depth) - 1;
236 s->bpc = (
s->depth + 7) / 8;
239 s->planewidth[0] =
s->planewidth[3] =
inlink->w;
241 s->planeheight[0] =
s->planeheight[3] =
inlink->h;
245 if (!strcmp(
ctx->filter->name,
"erosion"))
247 else if (!strcmp(
ctx->filter->name,
"dilation"))
249 else if (!strcmp(
ctx->filter->name,
"deflate"))
251 else if (!strcmp(
ctx->filter->name,
"inflate"))
265 for (plane = 0; plane <
s->nb_planes; plane++) {
266 const int bpc =
s->bpc;
267 const int threshold =
s->threshold[plane];
269 const int dstride =
out->linesize[plane];
270 const int height =
s->planeheight[plane];
271 const int width =
s->planewidth[plane];
272 const int slice_start = (
height * jobnr) / nb_jobs;
274 const uint8_t *
src = (
const uint8_t *)in->
data[plane] + slice_start *
stride;
275 uint8_t *dst =
out->data[plane] + slice_start * dstride;
282 for (y = slice_start; y <
slice_end; y++) {
283 const int nh = y > 0;
284 const int ph = y <
height - 1;
290 src + 1 * bpc,
src + 1 * bpc,
297 s->filter(dst,
src, 1, threshold, coordinateslb,
s->coordinates,
s->max);
299 s->filter(dst + 1 * bpc,
src + 1 * bpc,
width - 2, threshold, coordinates,
s->coordinates,
s->max);
300 s->filter(dst + (
width - 1) * bpc,
src + (
width - 1) * bpc, 1, threshold, coordinatesrb,
s->coordinates,
s->max);
351 #define OFFSET(x) offsetof(NContext, x)
352 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
354 #define DEFINE_NEIGHBOR_FILTER(name_, description_, priv_class_) \
355 const AVFilter ff_vf_##name_ = { \
357 .description = NULL_IF_CONFIG_SMALL(description_), \
358 .priv_class = &priv_class_##_class, \
359 .priv_size = sizeof(NContext), \
360 FILTER_INPUTS(neighbor_inputs), \
361 FILTER_OUTPUTS(neighbor_outputs), \
362 FILTER_PIXFMTS_ARRAY(pix_fmts), \
363 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC| \
364 AVFILTER_FLAG_SLICE_THREADS, \
365 .process_command = ff_filter_process_command, \
370 #define DEINFLATE_OPTIONS_OFFSET (CONFIG_EROSION_FILTER || CONFIG_DILATION_FILTER)
372 #if CONFIG_EROSION_FILTER || CONFIG_DILATION_FILTER
384 #if CONFIG_EROSION_FILTER
390 #if CONFIG_DILATION_FILTER
399 #if CONFIG_DEFLATE_FILTER
405 #if CONFIG_INFLATE_FILTER
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
#define AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_GBRAP16
static void deflate16(uint8_t *dstp, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord, int maxc)
AVPixelFormat
Pixel format.
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)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
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
static void erosion(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord, int maxc)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define AV_PIX_FMT_YUVA422P9
This structure describes decoded (raw) audio or video data.
#define AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUV420P10
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
A link between two filters.
#define AV_PIX_FMT_YUVA422P10
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_YUVA420P9
static int config_input(AVFilterLink *inlink)
static void dilation(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord, int maxc)
#define AV_PIX_FMT_GBRP14
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
#define AV_PIX_FMT_GBRP10
static void inflate(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord, int maxc)
#define AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_GRAY16
A filter pad used for either input or output.
#define AV_PIX_FMT_YUV444P10
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
#define AV_PIX_FMT_YUV422P16
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
#define AV_PIX_FMT_GBRAP10
#define DEINFLATE_OPTIONS_OFFSET
#define AV_PIX_FMT_GBRAP12
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
#define AV_PIX_FMT_YUV444P16
#define AV_CEIL_RSHIFT(a, b)
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
#define AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_GRAY14
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
#define AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GBRP16
Describe the class of an AVClass context structure.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
static const AVFilterPad neighbor_inputs[]
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
static void deflate(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord, int maxc)
#define AV_PIX_FMT_YUV422P10
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
static void inflate16(uint8_t *dstp, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord, int maxc)
#define AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV444P12
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
#define AV_PIX_FMT_YUVA444P10
#define DEFINE_NEIGHBOR_FILTER(name_, description_, priv_class_)
#define i(width, name, range_min, range_max)
AVFILTER_DEFINE_CLASS_EXT(erosion_dilation, "erosion/dilation", options)
int w
agreed upon image width
void(* filter)(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord, int maxc)
#define AV_PIX_FMT_GBRP12
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Used for passing data between threads.
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
const char * name
Pad name.
#define AV_PIX_FMT_YUV444P9
static double limit(double x)
static enum AVPixelFormat pix_fmts[]
static const AVFilterPad neighbor_outputs[]
#define AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV422P14
int h
agreed upon image height
#define AV_PIX_FMT_YUVA422P12
static void dilation16(uint8_t *dstp, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord, int maxc)
static const AVOption options[]
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
#define AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_GRAY12
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
static void erosion16(uint8_t *dstp, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord, int maxc)
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
#define AV_PIX_FMT_YUV420P14