Go to the documentation of this file.
77 #define DEFINE_DEDOTCRAWL(name, type, div) \
78 static int dedotcrawl##name(AVFilterContext *ctx, void *arg, \
79 int jobnr, int nb_jobs) \
81 DedotContext *s = ctx->priv; \
83 int src_linesize = s->frames[2]->linesize[0] / div; \
84 int dst_linesize = out->linesize[0] / div; \
85 int p0_linesize = s->frames[0]->linesize[0] / div; \
86 int p1_linesize = s->frames[1]->linesize[0] / div; \
87 int p3_linesize = s->frames[3]->linesize[0] / div; \
88 int p4_linesize = s->frames[4]->linesize[0] / div; \
89 const int h = s->planeheight[0]; \
90 int slice_start = (h * jobnr) / nb_jobs; \
91 int slice_end = (h * (jobnr+1)) / nb_jobs; \
92 type *p0 = (type *)s->frames[0]->data[0]; \
93 type *p1 = (type *)s->frames[1]->data[0]; \
94 type *p3 = (type *)s->frames[3]->data[0]; \
95 type *p4 = (type *)s->frames[4]->data[0]; \
96 type *src = (type *)s->frames[2]->data[0]; \
97 type *dst = (type *)out->data[0]; \
98 const int luma2d = s->luma2d; \
99 const int lumaT = s->lumaT; \
101 if (!slice_start) { \
104 p0 += p0_linesize * slice_start; \
105 p1 += p1_linesize * slice_start; \
106 p3 += p3_linesize * slice_start; \
107 p4 += p4_linesize * slice_start; \
108 src += src_linesize * slice_start; \
109 dst += dst_linesize * slice_start; \
110 if (slice_end == h) { \
113 for (int y = slice_start; y < slice_end; y++) { \
114 for (int x = 1; x < s->planewidth[0] - 1; x++) { \
115 int above = src[x - src_linesize]; \
116 int bellow = src[x + src_linesize]; \
118 int left = src[x - 1]; \
119 int right = src[x + 1]; \
121 if (FFABS(above + bellow - 2 * cur) <= luma2d && \
122 FFABS(left + right - 2 * cur) <= luma2d) \
125 if (FFABS(cur - p0[x]) <= lumaT && \
126 FFABS(cur - p4[x]) <= lumaT && \
127 FFABS(p1[x] - p3[x]) <= lumaT) { \
128 int diff1 = FFABS(cur - p1[x]); \
129 int diff2 = FFABS(cur - p3[x]); \
132 dst[x] = (src[x] + p1[x] + 1) >> 1; \
134 dst[x] = (src[x] + p3[x] + 1) >> 1; \
138 dst += dst_linesize; \
139 src += src_linesize; \
156 #define DEFINE_DERAINBOW(name, type, div) \
157 static int derainbow##name(AVFilterContext *ctx, void *arg, \
158 int jobnr, int nb_jobs) \
160 DedotContext *s = ctx->priv; \
161 ThreadData *td = arg; \
162 AVFrame *out = td->out; \
163 const int plane = td->plane; \
164 const int h = s->planeheight[plane]; \
165 int slice_start = (h * jobnr) / nb_jobs; \
166 int slice_end = (h * (jobnr+1)) / nb_jobs; \
167 int src_linesize = s->frames[2]->linesize[plane] / div; \
168 int dst_linesize = out->linesize[plane] / div; \
169 int p0_linesize = s->frames[0]->linesize[plane] / div; \
170 int p1_linesize = s->frames[1]->linesize[plane] / div; \
171 int p3_linesize = s->frames[3]->linesize[plane] / div; \
172 int p4_linesize = s->frames[4]->linesize[plane] / div; \
173 type *p0 = (type *)s->frames[0]->data[plane]; \
174 type *p1 = (type *)s->frames[1]->data[plane]; \
175 type *p3 = (type *)s->frames[3]->data[plane]; \
176 type *p4 = (type *)s->frames[4]->data[plane]; \
177 type *src = (type *)s->frames[2]->data[plane]; \
178 type *dst = (type *)out->data[plane]; \
179 const int chromaT1 = s->chromaT1; \
180 const int chromaT2 = s->chromaT2; \
182 p0 += slice_start * p0_linesize; \
183 p1 += slice_start * p1_linesize; \
184 p3 += slice_start * p3_linesize; \
185 p4 += slice_start * p4_linesize; \
186 src += slice_start * src_linesize; \
187 dst += slice_start * dst_linesize; \
188 for (int y = slice_start; y < slice_end; y++) { \
189 for (int x = 0; x < s->planewidth[plane]; x++) { \
192 if (FFABS(cur - p0[x]) <= chromaT1 && \
193 FFABS(cur - p4[x]) <= chromaT1 && \
194 FFABS(p1[x] - p3[x]) <= chromaT1 && \
195 FFABS(cur - p1[x]) > chromaT2 && \
196 FFABS(cur - p3[x]) > chromaT2) { \
197 int diff1 = FFABS(cur - p1[x]); \
198 int diff2 = FFABS(cur - p3[x]); \
201 dst[x] = (src[x] + p1[x] + 1) >> 1; \
203 dst[x] = (src[x] + p3[x] + 1) >> 1; \
207 dst += dst_linesize; \
208 src += src_linesize; \
230 s->depth =
s->desc->comp[0].depth;
231 s->max = (1 <<
s->depth) - 1;
232 s->luma2d =
s->lt *
s->max;
233 s->lumaT =
s->tl *
s->max;
234 s->chromaT1 =
s->tc *
s->max;
235 s->chromaT2 =
s->ct *
s->max;
238 s->planewidth[0] =
s->planewidth[3] =
inlink->w;
241 s->planeheight[0] =
s->planeheight[3] =
inlink->h;
244 s->dedotcrawl = dedotcrawl8;
245 s->derainbow = derainbow8;
247 s->dedotcrawl = dedotcrawl16;
248 s->derainbow = derainbow16;
271 if (
frame ||
s->eof_frames > 0) {
275 for (
int i = 2;
i < 5;
i++) {
280 }
else if (
s->frames[3]) {
291 if (
out && !
ctx->is_disabled) {
317 s->frames[0] =
s->frames[1];
318 s->frames[1] =
s->frames[2];
319 s->frames[2] =
s->frames[3];
320 s->frames[3] =
s->frames[4];
330 if (
s->eof_frames <= 0) {
341 s->eof_frames = !!
s->frames[0] + !!
s->frames[1];
342 if (
s->eof_frames <= 0) {
360 for (
int i = 0;
i < 5;
i++)
364 #define OFFSET(x) offsetof(DedotContext, x)
365 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
399 .priv_class = &dedot_class,
#define AV_PIX_FMT_YUVA422P16
AVPixelFormat
Pixel format.
they must not be accessed directly The fifo field contains the frames that are queued in the input for processing by the filter The status_in and status_out fields contains the queued status(EOF or error) of the link
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
const AVFilter ff_vf_dedot
static const AVFilterPad outputs[]
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)
#define AVERROR_EOF
End of file.
#define FILTER_PIXFMTS_ARRAY(array)
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
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.
int av_frame_make_writable(AVFrame *frame)
Ensure that the frame data is writable, avoiding data copy if possible.
#define AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P10
static int config_output(AVFilterLink *outlink)
#define AV_PIX_FMT_YUV420P10
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
const char * name
Filter name.
A link between two filters.
#define AV_PIX_FMT_YUVA422P10
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_YUVA420P9
AVFILTER_DEFINE_CLASS(dedot)
#define AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUV422P9
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...
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
@ 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)
const AVPixFmtDescriptor * desc
#define AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P16
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FILTER_INPUTS(array)
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Describe the class of an AVClass context structure.
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
#define DEFINE_DEDOTCRAWL(name, type, div)
#define AV_PIX_FMT_YUV422P10
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
int(* derainbow)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int(* dedotcrawl)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static av_cold void uninit(AVFilterContext *ctx)
#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
FF_FILTER_FORWARD_WANTED(outlink, inlink)
static enum AVPixelFormat pixel_fmts[]
#define i(width, name, range_min, range_max)
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
#define DEFINE_DERAINBOW(name, type, div)
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
#define AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUVA422P12
static const AVOption dedot_options[]
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
@ 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...
#define FILTER_OUTPUTS(array)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
static int activate(AVFilterContext *ctx)
@ 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
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
static const AVFilterPad inputs[]
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
#define AV_PIX_FMT_YUV420P14
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.