Go to the documentation of this file.
50 #define OFFSET(x) offsetof(KerndeintContext, x)
51 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
87 kerndeint->
vsub =
desc->log2_chroma_h;
107 const uint8_t *prvpp;
108 const uint8_t *prvpn;
109 const uint8_t *prvppp;
110 const uint8_t *prvpnn;
111 const uint8_t *prvp4p;
112 const uint8_t *prvp4n;
115 const uint8_t *srcpp;
116 const uint8_t *srcpn;
117 const uint8_t *srcppp;
118 const uint8_t *srcpnn;
119 const uint8_t *srcp3p;
120 const uint8_t *srcp3n;
121 const uint8_t *srcp4p;
122 const uint8_t *srcp4n;
124 uint8_t *dstp, *dstp_saved;
125 const uint8_t *srcp_saved;
127 int src_linesize, psrc_linesize, dst_linesize, bwidth;
128 int x, y, plane,
val, hi, lo,
g,
h, n = kerndeint->
frame++;
131 const int thresh = kerndeint->
thresh;
132 const int order = kerndeint->
order;
133 const int map = kerndeint->
map;
134 const int sharp = kerndeint->
sharp;
135 const int twoway = kerndeint->
twoway;
145 #if FF_API_INTERLACED_FRAME
152 for (plane = 0; plane < 4 &&
inpic->data[plane] &&
inpic->linesize[plane]; plane++) {
156 srcp_saved =
inpic->data[plane];
157 src_linesize =
inpic->linesize[plane];
159 dstp_saved = outpic->
data[plane];
160 dst_linesize = outpic->
linesize[plane];
161 srcp = srcp_saved + (1 - order) * src_linesize;
162 dstp = dstp_saved + (1 - order) * dst_linesize;
164 for (y = 0; y <
h; y += 2) {
165 memcpy(dstp, srcp, bwidth);
166 srcp += 2 * src_linesize;
167 dstp += 2 * dst_linesize;
171 memcpy(dstp_saved + order * dst_linesize, srcp_saved + (1 - order) * src_linesize, bwidth);
172 memcpy(dstp_saved + (2 + order ) * dst_linesize, srcp_saved + (3 - order) * src_linesize, bwidth);
173 memcpy(dstp_saved + (
h - 2 + order) * dst_linesize, srcp_saved + (
h - 1 - order) * src_linesize, bwidth);
174 memcpy(dstp_saved + (
h - 4 + order) * dst_linesize, srcp_saved + (
h - 3 - order) * src_linesize, bwidth);
178 prvp = kerndeint->
tmp_data[plane] + 5 * psrc_linesize - (1 - order) * psrc_linesize;
179 prvpp = prvp - psrc_linesize;
180 prvppp = prvp - 2 * psrc_linesize;
181 prvp4p = prvp - 4 * psrc_linesize;
182 prvpn = prvp + psrc_linesize;
183 prvpnn = prvp + 2 * psrc_linesize;
184 prvp4n = prvp + 4 * psrc_linesize;
186 srcp = srcp_saved + 5 * src_linesize - (1 - order) * src_linesize;
187 srcpp = srcp - src_linesize;
188 srcppp = srcp - 2 * src_linesize;
189 srcp3p = srcp - 3 * src_linesize;
190 srcp4p = srcp - 4 * src_linesize;
192 srcpn = srcp + src_linesize;
193 srcpnn = srcp + 2 * src_linesize;
194 srcp3n = srcp + 3 * src_linesize;
195 srcp4n = srcp + 4 * src_linesize;
197 dstp = dstp_saved + 5 * dst_linesize - (1 - order) * dst_linesize;
199 for (y = 5 - (1 - order); y <=
h - 5 - (1 - order); y += 2) {
200 for (x = 0; x < bwidth; x++) {
201 if (thresh == 0 || n == 0 ||
202 (
abs((
int)prvp[x] - (int)srcp[x]) > thresh) ||
203 (
abs((
int)prvpp[x] - (int)srcpp[x]) > thresh) ||
204 (
abs((
int)prvpn[x] - (int)srcpn[x]) > thresh)) {
216 dstp[x] = plane == 0 ? 235 : 128;
223 hi = x & 1 ? 240 : 235;
226 hi = plane == 0 ? 235 : 240;
232 valf = + 0.526 * ((int)srcpp[x] + (
int)srcpn[x])
233 + 0.170 * ((
int)srcp[x] + (int)prvp[x])
234 - 0.116 * ((int)srcppp[x] + (
int)srcpnn[x] + (int)prvppp[x] + (
int)prvpnn[x])
235 - 0.026 * ((
int)srcp3p[x] + (int)srcp3n[x])
236 + 0.031 * ((int)srcp4p[x] + (
int)srcp4n[x] + (int)prvp4p[x] + (
int)prvp4n[x]);
238 valf = + 0.526 * ((int)srcpp[x] + (
int)srcpn[x])
239 + 0.170 * ((
int)prvp[x])
240 - 0.116 * ((
int)prvppp[x] + (int)prvpnn[x])
241 - 0.026 * ((int)srcp3p[x] + (
int)srcp3n[x])
242 + 0.031 * ((
int)prvp4p[x] + (int)prvp4p[x]);
244 dstp[x] =
av_clip(valf, lo, hi);
247 val = (8 * ((int)srcpp[x] + (
int)srcpn[x]) + 2 * ((
int)srcp[x] + (int)prvp[x])
248 - (int)(srcppp[x]) - (int)(srcpnn[x])
249 - (int)(prvppp[x]) - (int)(prvpnn[x])) >> 4;
251 val = (8 * ((int)srcpp[x] + (
int)srcpn[x]) + 2 * ((
int)prvp[x])
252 - (
int)(prvppp[x]) - (
int)(prvpnn[x])) >> 4;
261 prvp += 2 * psrc_linesize;
262 prvpp += 2 * psrc_linesize;
263 prvppp += 2 * psrc_linesize;
264 prvpn += 2 * psrc_linesize;
265 prvpnn += 2 * psrc_linesize;
266 prvp4p += 2 * psrc_linesize;
267 prvp4n += 2 * psrc_linesize;
268 srcp += 2 * src_linesize;
269 srcpp += 2 * src_linesize;
270 srcppp += 2 * src_linesize;
271 srcp3p += 2 * src_linesize;
272 srcp4p += 2 * src_linesize;
273 srcpn += 2 * src_linesize;
274 srcpnn += 2 * src_linesize;
275 srcp3n += 2 * src_linesize;
276 srcp4n += 2 * src_linesize;
277 dstp += 2 * dst_linesize;
280 srcp =
inpic->data[plane];
303 .priv_class = &kerndeint_class,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
#define FF_ENABLE_DEPRECATION_WARNINGS
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
#define FILTER_PIXFMTS_ARRAY(array)
static av_cold void uninit(AVFilterContext *ctx)
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)
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 FILTER_INPUTS(array)
This structure describes decoded (raw) audio or video data.
uint8_t * tmp_data[4]
temporary plane data buffer
static const AVFilterPad kerndeint_inputs[]
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
const char * name
Filter name.
A link between two filters.
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.
static double val(void *priv, double ch)
A filter pad used for either input or output.
attribute_deprecated int interlaced_frame
The content of the picture is interlaced.
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
AVFILTER_DEFINE_CLASS(kerndeint)
static int config_props(AVFilterLink *inlink)
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
Fill plane linesizes for an image with pixel format pix_fmt and width width.
#define AV_CEIL_RSHIFT(a, b)
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FILTER_OUTPUTS(array)
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
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.
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
const AVFilter ff_vf_kerndeint
static enum AVPixelFormat pix_fmts[]
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
int tmp_linesize[4]
temporary plane byte linesize
int av_image_alloc(uint8_t *pointers[4], int linesizes[4], int w, int h, enum AVPixelFormat pix_fmt, int align)
Allocate an image with size w and h and pixel format pix_fmt, and fill pointers and linesizes accordi...
#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).
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
int w
agreed upon image width
const char * name
Pad name.
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
int frame
frame count, starting from 0
int tmp_bwidth[4]
temporary plane byte width
int h
agreed upon image height
@ AV_OPT_TYPE_INT
Underlying C type is int.
#define FF_DISABLE_DEPRECATION_WARNINGS
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
const VDPAUPixFmtMap * map
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
static const AVOption kerndeint_options[]
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_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined