49 #define OFFSET(x) offsetof(KerndeintContext, x) 50 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM 97 inlink->
w, inlink->
h, inlink->
format, 16);
100 memset(kerndeint->
tmp_data[0], 0, ret);
134 int src_linesize, psrc_linesize, dst_linesize, bwidth;
140 const int map = kerndeint->
map;
163 srcp = srcp_saved + (1 -
order) * src_linesize;
164 dstp = dstp_saved + (1 -
order) * dst_linesize;
166 for (y = 0; y <
h; y += 2) {
167 memcpy(dstp, srcp, bwidth);
168 srcp += 2 * src_linesize;
169 dstp += 2 * dst_linesize;
173 memcpy(dstp_saved + order * dst_linesize, srcp_saved + (1 - order) * src_linesize, bwidth);
174 memcpy(dstp_saved + (2 + order ) * dst_linesize, srcp_saved + (3 - order) * src_linesize, bwidth);
175 memcpy(dstp_saved + (h - 2 + order) * dst_linesize, srcp_saved + (h - 1 - order) * src_linesize, bwidth);
176 memcpy(dstp_saved + (h - 4 + order) * dst_linesize, srcp_saved + (h - 3 - order) * src_linesize, bwidth);
181 prvpp = prvp - psrc_linesize;
182 prvppp = prvp - 2 * psrc_linesize;
183 prvp4p = prvp - 4 * psrc_linesize;
184 prvpn = prvp + psrc_linesize;
185 prvpnn = prvp + 2 * psrc_linesize;
186 prvp4n = prvp + 4 * psrc_linesize;
188 srcp = srcp_saved + 5 * src_linesize - (1 -
order) * src_linesize;
189 srcpp = srcp - src_linesize;
190 srcppp = srcp - 2 * src_linesize;
191 srcp3p = srcp - 3 * src_linesize;
192 srcp4p = srcp - 4 * src_linesize;
194 srcpn = srcp + src_linesize;
195 srcpnn = srcp + 2 * src_linesize;
196 srcp3n = srcp + 3 * src_linesize;
197 srcp4n = srcp + 4 * src_linesize;
199 dstp = dstp_saved + 5 * dst_linesize - (1 -
order) * dst_linesize;
201 for (y = 5 - (1 - order); y <= h - 5 - (1 -
order); y += 2) {
202 for (x = 0; x < bwidth; x++) {
203 if (thresh == 0 || n == 0 ||
204 (abs((
int)prvp[x] - (
int)srcp[x]) >
thresh) ||
205 (abs((
int)prvpp[x] - (
int)srcpp[x]) >
thresh) ||
206 (abs((
int)prvpn[x] - (
int)srcpn[x]) >
thresh)) {
218 dstp[x] = plane == 0 ? 235 : 128;
225 hi = x & 1 ? 240 : 235;
228 hi = plane == 0 ? 235 : 240;
234 valf = + 0.526 * ((
int)srcpp[x] + (
int)srcpn[x])
235 + 0.170 * ((
int)srcp[x] + (
int)prvp[x])
236 - 0.116 * ((
int)srcppp[x] + (
int)srcpnn[x] + (
int)prvppp[x] + (
int)prvpnn[x])
237 - 0.026 * ((
int)srcp3p[x] + (
int)srcp3n[x])
238 + 0.031 * ((
int)srcp4p[x] + (
int)srcp4n[x] + (
int)prvp4p[x] + (
int)prvp4n[x]);
240 valf = + 0.526 * ((
int)srcpp[x] + (
int)srcpn[x])
241 + 0.170 * ((
int)prvp[x])
242 - 0.116 * ((
int)prvppp[x] + (
int)prvpnn[x])
243 - 0.026 * ((
int)srcp3p[x] + (
int)srcp3n[x])
244 + 0.031 * ((
int)prvp4p[x] + (
int)prvp4p[x]);
246 dstp[x] = av_clip(valf, lo, hi);
249 val = (8 * ((
int)srcpp[x] + (
int)srcpn[x]) + 2 * ((
int)srcp[x] + (
int)prvp[x])
250 - (
int)(srcppp[x]) - (
int)(srcpnn[x])
251 - (
int)(prvppp[x]) - (
int)(prvpnn[x])) >> 4;
253 val = (8 * ((
int)srcpp[x] + (
int)srcpn[x]) + 2 * ((
int)prvp[x])
254 - (
int)(prvppp[x]) - (
int)(prvpnn[x])) >> 4;
256 dstp[x] = av_clip(val, lo, hi);
263 prvp += 2 * psrc_linesize;
264 prvpp += 2 * psrc_linesize;
265 prvppp += 2 * psrc_linesize;
266 prvpn += 2 * psrc_linesize;
267 prvpnn += 2 * psrc_linesize;
268 prvp4p += 2 * psrc_linesize;
269 prvp4n += 2 * psrc_linesize;
270 srcp += 2 * src_linesize;
271 srcpp += 2 * src_linesize;
272 srcppp += 2 * src_linesize;
273 srcp3p += 2 * src_linesize;
274 srcp4p += 2 * src_linesize;
275 srcpn += 2 * src_linesize;
276 srcpnn += 2 * src_linesize;
277 srcp3n += 2 * src_linesize;
278 srcp4n += 2 * src_linesize;
279 dstp += 2 * dst_linesize;
314 .priv_class = &kerndeint_class,
317 .
inputs = kerndeint_inputs,
const char const char void * val
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
Main libavfilter public API header.
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...
static av_cold void uninit(AVFilterContext *ctx)
int h
agreed upon image height
static const AVFilterPad kerndeint_inputs[]
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
uint8_t * tmp_data[4]
temporary plane data buffer
BYTE int const BYTE * srcp
const char * name
Pad name.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static const AVFilterPad kerndeint_outputs[]
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
AVFILTER_DEFINE_CLASS(kerndeint)
int interlaced_frame
The content of the picture is interlaced.
A filter pad used for either input or output.
A link between two filters.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
static int config_props(AVFilterLink *inlink)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
void * priv
private data for use by the filter
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
int w
agreed upon image width
static int query_formats(AVFilterContext *ctx)
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
int tmp_linesize[4]
temporary plane byte linesize
static const AVFilterPad inputs[]
static const AVFilterPad outputs[]
int format
agreed upon media format
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Describe the class of an AVClass context structure.
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.
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
const char * name
Filter name.
static const AVOption kerndeint_options[]
AVFilterLink ** outputs
array of pointers to output links
static enum AVPixelFormat pix_fmts[]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
int frame
frame count, starting from 0
int tmp_bwidth[4]
temporary plane byte width
AVFilterContext * dst
dest filter
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.
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
AVPixelFormat
Pixel format.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_CEIL_RSHIFT(a, b)