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;
90 "Input height %d is too small; minimum chroma plane height is 4\n",
96 inlink->
w, inlink->
h, inlink->
format, 16);
99 memset(kerndeint->
tmp_data[0], 0, ret);
113 const uint8_t *prvpp;
114 const uint8_t *prvpn;
115 const uint8_t *prvppp;
116 const uint8_t *prvpnn;
117 const uint8_t *prvp4p;
118 const uint8_t *prvp4n;
121 const uint8_t *srcpp;
122 const uint8_t *srcpn;
123 const uint8_t *srcppp;
124 const uint8_t *srcpnn;
125 const uint8_t *srcp3p;
126 const uint8_t *srcp3n;
127 const uint8_t *srcp4p;
128 const uint8_t *srcp4n;
130 uint8_t *dstp, *dstp_saved;
131 const uint8_t *srcp_saved;
133 int src_linesize, psrc_linesize, dst_linesize, bwidth;
134 int x, y, plane,
val, hi, lo,
g,
h, n = kerndeint->
frame++;
137 const int thresh = kerndeint->
thresh;
138 const int order = kerndeint->
order;
139 const int map = kerndeint->
map;
140 const int sharp = kerndeint->
sharp;
141 const int twoway = kerndeint->
twoway;
153 for (plane = 0; plane < 4 &&
inpic->data[plane] &&
inpic->linesize[plane]; plane++) {
157 srcp_saved =
inpic->data[plane];
158 src_linesize =
inpic->linesize[plane];
160 dstp_saved = outpic->
data[plane];
161 dst_linesize = outpic->
linesize[plane];
162 srcp = srcp_saved + (1 - order) * src_linesize;
163 dstp = dstp_saved + (1 - order) * dst_linesize;
165 for (y = 0; y <
h; y += 2) {
166 memcpy(dstp, srcp, bwidth);
167 srcp += 2 * src_linesize;
168 dstp += 2 * dst_linesize;
172 memcpy(dstp_saved + order * dst_linesize, srcp_saved + (1 - order) * src_linesize, bwidth);
173 memcpy(dstp_saved + (2 + order ) * dst_linesize, srcp_saved + (3 - order) * src_linesize, bwidth);
174 memcpy(dstp_saved + (
h - 2 + order) * dst_linesize, srcp_saved + (
h - 1 - order) * src_linesize, bwidth);
175 memcpy(dstp_saved + (
h - 4 + order) * dst_linesize, srcp_saved + (
h - 3 - order) * src_linesize, bwidth);
179 prvp = kerndeint->
tmp_data[plane] + 5 * psrc_linesize - (1 - order) * psrc_linesize;
180 prvpp = prvp - psrc_linesize;
181 prvppp = prvp - 2 * psrc_linesize;
182 prvp4p = prvp - 4 * psrc_linesize;
183 prvpn = prvp + psrc_linesize;
184 prvpnn = prvp + 2 * psrc_linesize;
185 prvp4n = prvp + 4 * psrc_linesize;
187 srcp = srcp_saved + 5 * src_linesize - (1 - order) * src_linesize;
188 srcpp = srcp - src_linesize;
189 srcppp = srcp - 2 * src_linesize;
190 srcp3p = srcp - 3 * src_linesize;
191 srcp4p = srcp - 4 * src_linesize;
193 srcpn = srcp + src_linesize;
194 srcpnn = srcp + 2 * src_linesize;
195 srcp3n = srcp + 3 * src_linesize;
196 srcp4n = srcp + 4 * src_linesize;
198 dstp = dstp_saved + 5 * dst_linesize - (1 - order) * dst_linesize;
200 for (y = 5 - (1 - order); y <=
h - 5 - (1 - order); y += 2) {
201 for (x = 0; x < bwidth; x++) {
202 if (thresh == 0 || n == 0 ||
203 (
abs((
int)prvp[x] - (
int)srcp[x]) > thresh) ||
204 (
abs((
int)prvpp[x] - (
int)srcpp[x]) > thresh) ||
205 (
abs((
int)prvpn[x] - (
int)srcpn[x]) > thresh)) {
217 dstp[x] = plane == 0 ? 235 : 128;
224 hi = x & 1 ? 240 : 235;
227 hi = plane == 0 ? 235 : 240;
233 valf = + 0.526 * ((int)srcpp[x] + (int)srcpn[x])
234 + 0.170 * ((
int)srcp[x] + (
int)prvp[x])
235 - 0.116 * ((int)srcppp[x] + (int)srcpnn[x] + (int)prvppp[x] + (int)prvpnn[x])
236 - 0.026 * ((
int)srcp3p[x] + (
int)srcp3n[x])
237 + 0.031 * ((int)srcp4p[x] + (int)srcp4n[x] + (int)prvp4p[x] + (int)prvp4n[x]);
239 valf = + 0.526 * ((int)srcpp[x] + (int)srcpn[x])
240 + 0.170 * ((
int)prvp[x])
241 - 0.116 * ((int)prvppp[x] + (int)prvpnn[x])
242 - 0.026 * ((
int)srcp3p[x] + (
int)srcp3n[x])
243 + 0.031 * ((int)prvp4p[x] + (int)prvp4p[x]);
245 dstp[x] =
av_clip(valf, lo, hi);
248 val = (8 * ((int)srcpp[x] + (int)srcpn[x]) + 2 * ((int)srcp[x] + (int)prvp[x])
249 - (int)(srcppp[x]) - (int)(srcpnn[x])
250 - (int)(prvppp[x]) - (int)(prvpnn[x])) >> 4;
252 val = (8 * ((int)srcpp[x] + (int)srcpn[x]) + 2 * ((int)prvp[x])
253 - (int)(prvppp[x]) - (int)(prvpnn[x])) >> 4;
262 prvp += 2 * psrc_linesize;
263 prvpp += 2 * psrc_linesize;
264 prvppp += 2 * psrc_linesize;
265 prvpn += 2 * psrc_linesize;
266 prvpnn += 2 * psrc_linesize;
267 prvp4p += 2 * psrc_linesize;
268 prvp4n += 2 * psrc_linesize;
269 srcp += 2 * src_linesize;
270 srcpp += 2 * src_linesize;
271 srcppp += 2 * src_linesize;
272 srcp3p += 2 * src_linesize;
273 srcp4p += 2 * src_linesize;
274 srcpn += 2 * src_linesize;
275 srcpnn += 2 * src_linesize;
276 srcp3n += 2 * src_linesize;
277 srcp4n += 2 * src_linesize;
278 dstp += 2 * dst_linesize;
281 srcp =
inpic->data[plane];
301 .p.name =
"kerndeint",
303 .p.priv_class = &kerndeint_class,
static double val(void *priv, double ch)
const FFFilter ff_vf_kerndeint
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Main libavfilter public API header.
#define AV_CEIL_RSHIFT(a, b)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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_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...
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.
const VDPAUPixFmtMap * map
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FILTER_PIXFMTS_ARRAY(array)
#define AVFILTER_DEFINE_CLASS(fname)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static enum AVPixelFormat pix_fmts[]
Memory handling functions.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
static int config_props(AVBitStreamFilterLink *link)
Describe the class of an AVClass context structure.
void * priv
private data for use by the filter
AVFilterLink ** outputs
array of pointers to output links
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
uint64_t flags
Combination of AV_PIX_FMT_FLAG_... flags.
int frame
frame count, starting from 0
int tmp_bwidth[4]
temporary plane byte width
int tmp_linesize[4]
temporary plane byte linesize
uint8_t * tmp_data[4]
temporary plane data buffer
static AVFormatContext * ctx
static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
static int config_props(AVFilterLink *inlink)
static av_cold void uninit(AVFilterContext *ctx)
static const AVOption kerndeint_options[]
static const AVFilterPad kerndeint_inputs[]
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.