Go to the documentation of this file.
75 int threshold,
const uint8_t *coordinates[],
int coord,
80 for (x = 0; x <
width; x++) {
84 for (
i = 0;
i < 8;
i++) {
85 if (coord & (1 <<
i)) {
96 int threshold,
const uint8_t *coordinates[],
int coord,
99 uint16_t *dst = (uint16_t *)dstp;
102 for (x = 0; x <
width; x++) {
106 for (
i = 0;
i < 8;
i++) {
107 if (coord & (1 <<
i)) {
118 int threshold,
const uint8_t *coordinates[],
int coord,
123 for (x = 0; x <
width; x++) {
127 for (
i = 0;
i < 8;
i++) {
128 if (coord & (1 <<
i)) {
139 int threshold,
const uint8_t *coordinates[],
int coord,
142 uint16_t *dst = (uint16_t *)dstp;
145 for (x = 0; x <
width; x++) {
149 for (
i = 0;
i < 8;
i++) {
150 if (coord & (1 <<
i)) {
161 int threshold,
const uint8_t *coordinates[],
int coord,
166 for (x = 0; x <
width; x++) {
170 for (
i = 0;
i < 8; sum += *(coordinates[
i++] + x));
177 int threshold,
const uint8_t *coordinates[],
int coord,
180 uint16_t *dst = (uint16_t *)dstp;
183 for (x = 0; x <
width; x++) {
187 for (
i = 0;
i < 8; sum +=
AV_RN16A(coordinates[
i++] + x * 2));
194 int threshold,
const uint8_t *coordinates[],
int coord,
199 for (x = 0; x <
width; x++) {
203 for (
i = 0;
i < 8; sum += *(coordinates[
i++] + x));
210 int threshold,
const uint8_t *coordinates[],
int coord,
213 uint16_t *dst = (uint16_t *)dstp;
216 for (x = 0; x <
width; x++) {
220 for (
i = 0;
i < 8; sum +=
AV_RN16A(coordinates[
i++] + x * 2));
232 s->depth =
desc->comp[0].depth;
233 s->max = (1 <<
s->depth) - 1;
234 s->bpc = (
s->depth + 7) / 8;
237 s->planewidth[0] =
s->planewidth[3] =
inlink->w;
239 s->planeheight[0] =
s->planeheight[3] =
inlink->h;
243 if (!strcmp(
ctx->filter->name,
"erosion"))
245 else if (!strcmp(
ctx->filter->name,
"dilation"))
247 else if (!strcmp(
ctx->filter->name,
"deflate"))
249 else if (!strcmp(
ctx->filter->name,
"inflate"))
263 for (plane = 0; plane <
s->nb_planes; plane++) {
264 const int bpc =
s->bpc;
265 const int threshold =
s->threshold[plane];
267 const int dstride =
out->linesize[plane];
268 const int height =
s->planeheight[plane];
269 const int width =
s->planewidth[plane];
270 const int slice_start = (
height * jobnr) / nb_jobs;
272 const uint8_t *
src = (
const uint8_t *)in->
data[plane] + slice_start *
stride;
273 uint8_t *dst =
out->data[plane] + slice_start * dstride;
280 for (y = slice_start; y <
slice_end; y++) {
281 const int nh = y > 0;
282 const int ph = y <
height - 1;
288 src + 1 * bpc,
src + 1 * bpc,
295 s->filter(dst,
src, 1, threshold, coordinateslb,
s->coordinates,
s->max);
297 s->filter(dst + 1 * bpc,
src + 1 * bpc,
width - 2, threshold, coordinates,
s->coordinates,
s->max);
298 s->filter(dst + (
width - 1) * bpc,
src + (
width - 1) * bpc, 1, threshold, coordinatesrb,
s->coordinates,
s->max);
349 #define OFFSET(x) offsetof(NContext, x)
350 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
352 #define DEFINE_NEIGHBOR_FILTER(name_, description_, priv_class_) \
353 const AVFilter ff_vf_##name_ = { \
355 .description = NULL_IF_CONFIG_SMALL(description_), \
356 .priv_class = &priv_class_##_class, \
357 .priv_size = sizeof(NContext), \
358 FILTER_INPUTS(neighbor_inputs), \
359 FILTER_OUTPUTS(neighbor_outputs), \
360 FILTER_PIXFMTS_ARRAY(pix_fmts), \
361 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC| \
362 AVFILTER_FLAG_SLICE_THREADS, \
363 .process_command = ff_filter_process_command, \
368 #define DEINFLATE_OPTIONS_OFFSET (CONFIG_EROSION_FILTER || CONFIG_DILATION_FILTER)
370 #if CONFIG_EROSION_FILTER || CONFIG_DILATION_FILTER
382 #if CONFIG_EROSION_FILTER
388 #if CONFIG_DILATION_FILTER
397 #if CONFIG_DEFLATE_FILTER
403 #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