Go to the documentation of this file.
22 #include "config_components.h"
76 int threshold,
const uint8_t *coordinates[],
int coord,
81 for (x = 0; x <
width; x++) {
85 for (
i = 0;
i < 8;
i++) {
86 if (coord & (1 <<
i)) {
97 int threshold,
const uint8_t *coordinates[],
int coord,
100 uint16_t *dst = (uint16_t *)dstp;
103 for (x = 0; x <
width; x++) {
107 for (
i = 0;
i < 8;
i++) {
108 if (coord & (1 <<
i)) {
119 int threshold,
const uint8_t *coordinates[],
int coord,
124 for (x = 0; x <
width; x++) {
128 for (
i = 0;
i < 8;
i++) {
129 if (coord & (1 <<
i)) {
140 int threshold,
const uint8_t *coordinates[],
int coord,
143 uint16_t *dst = (uint16_t *)dstp;
146 for (x = 0; x <
width; x++) {
150 for (
i = 0;
i < 8;
i++) {
151 if (coord & (1 <<
i)) {
162 int threshold,
const uint8_t *coordinates[],
int coord,
167 for (x = 0; x <
width; x++) {
171 for (
i = 0;
i < 8; sum += *(coordinates[
i++] + x));
178 int threshold,
const uint8_t *coordinates[],
int coord,
181 uint16_t *dst = (uint16_t *)dstp;
184 for (x = 0; x <
width; x++) {
188 for (
i = 0;
i < 8; sum +=
AV_RN16A(coordinates[
i++] + x * 2));
195 int threshold,
const uint8_t *coordinates[],
int coord,
200 for (x = 0; x <
width; x++) {
204 for (
i = 0;
i < 8; sum += *(coordinates[
i++] + x));
211 int threshold,
const uint8_t *coordinates[],
int coord,
214 uint16_t *dst = (uint16_t *)dstp;
217 for (x = 0; x <
width; x++) {
221 for (
i = 0;
i < 8; sum +=
AV_RN16A(coordinates[
i++] + x * 2));
233 s->depth =
desc->comp[0].depth;
234 s->max = (1 <<
s->depth) - 1;
235 s->bpc = (
s->depth + 7) / 8;
238 s->planewidth[0] =
s->planewidth[3] =
inlink->w;
240 s->planeheight[0] =
s->planeheight[3] =
inlink->h;
244 if (!strcmp(
ctx->filter->name,
"erosion"))
246 else if (!strcmp(
ctx->filter->name,
"dilation"))
248 else if (!strcmp(
ctx->filter->name,
"deflate"))
250 else if (!strcmp(
ctx->filter->name,
"inflate"))
264 for (plane = 0; plane <
s->nb_planes; plane++) {
265 const int bpc =
s->bpc;
266 const int threshold =
s->threshold[plane];
268 const int dstride =
out->linesize[plane];
269 const int height =
s->planeheight[plane];
270 const int width =
s->planewidth[plane];
282 const int nh = y > 0;
289 src + 1 * bpc,
src + 1 * bpc,
296 s->filter(dst,
src, 1, threshold, coordinateslb,
s->coordinates,
s->max);
298 s->filter(dst + 1 * bpc,
src + 1 * bpc,
width - 2, threshold, coordinates,
s->coordinates,
s->max);
299 s->filter(dst + (
width - 1) * bpc,
src + (
width - 1) * bpc, 1, threshold, coordinatesrb,
s->coordinates,
s->max);
343 #define OFFSET(x) offsetof(NContext, x)
344 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
346 #define DEFINE_NEIGHBOR_FILTER(name_, description_, priv_class_) \
347 const AVFilter ff_vf_##name_ = { \
349 .description = NULL_IF_CONFIG_SMALL(description_), \
350 .priv_class = &priv_class_##_class, \
351 .priv_size = sizeof(NContext), \
352 FILTER_INPUTS(neighbor_inputs), \
353 FILTER_OUTPUTS(ff_video_default_filterpad), \
354 FILTER_PIXFMTS_ARRAY(pix_fmts), \
355 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC| \
356 AVFILTER_FLAG_SLICE_THREADS, \
357 .process_command = ff_filter_process_command, \
362 #define DEINFLATE_OPTIONS_OFFSET (CONFIG_EROSION_FILTER || CONFIG_DILATION_FILTER)
364 #if CONFIG_EROSION_FILTER || CONFIG_DILATION_FILTER
376 #if CONFIG_EROSION_FILTER
382 #if CONFIG_DILATION_FILTER
391 #if CONFIG_DEFLATE_FILTER
397 #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
static int FUNC() ph(CodedBitstreamContext *ctx, RWContext *rw, H266RawPH *current)
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 ...
static int slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)
#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[]
#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