47 {0x00,0x60,0x18,0x78,0x06,0x66,0x1E,0x7E},
48 {0x40,0x20,0x58,0x38,0x46,0x26,0x5E,0x3E},
49 {0x10,0x70,0x08,0x68,0x16,0x76,0x0E,0x6E},
50 {0x50,0x30,0x48,0x28,0x56,0x36,0x4E,0x2E},
51 {0x04,0x64,0x1C,0x7C,0x02,0x62,0x1A,0x7A},
52 {0x44,0x24,0x5C,0x3C,0x42,0x22,0x5A,0x3A},
53 {0x14,0x74,0x0C,0x6C,0x12,0x72,0x0A,0x6A},
54 {0x54,0x34,0x4C,0x2C,0x52,0x32,0x4A,0x2A},
60 for (x = 0; x <
width; dc += x & 1, x++) {
64 m =
FFMAX(0, 127 - m);
65 m = m * m *
delta >> 14;
74 for (x = 0; x <
width; x++) {
75 v = buf1[x] +
src[2 * x] +
src[2 * x + 1] +
src[2 * x + src_linesize] +
src[2 * x + 1 + src_linesize];
86 uint32_t dc_factor = (1 << 21) / (
r *
r);
87 uint16_t *dc =
ctx->buf + 16;
88 uint16_t *buf =
ctx->buf + bstride + 32;
89 int thresh =
ctx->thresh;
91 memset(dc, 0, (bstride + 16) *
sizeof(*buf));
92 for (y = 0; y <
r; y++)
93 ctx->blur_line(dc, buf + y * bstride, buf + (y - 1) * bstride,
src + 2 * y * src_linesize, src_linesize,
width / 2);
96 int mod = ((y +
r) / 2) %
r;
97 uint16_t *buf0 = buf +
mod * bstride;
98 uint16_t *buf1 = buf + (
mod ?
mod - 1 :
r - 1) * bstride;
100 ctx->blur_line(dc, buf0, buf1,
src + (y +
r) * src_linesize, src_linesize,
width / 2);
101 for (x = v = 0; x <
r; x++)
103 for (; x <
width / 2; x++) {
104 v += dc[x] - dc[x-
r];
105 dc[x-
r] = v * dc_factor >> 16;
107 for (; x < (
width +
r + 1) / 2; x++)
108 dc[x-
r] = v * dc_factor >> 16;
109 for (x = -
r / 2; x < 0; x++)
113 for (y = 0; y <
r; y++)
114 ctx->filter_line(
dst + y * dst_linesize,
src + y * src_linesize, dc -
r / 2,
width, thresh,
dither[y & 7]);
116 ctx->filter_line(
dst + y * dst_linesize,
src + y * src_linesize, dc -
r / 2,
width, thresh,
dither[y & 7]);
118 ctx->filter_line(
dst + y * dst_linesize,
src + y * src_linesize, dc -
r / 2,
width, thresh,
dither[y & 7]);
127 s->thresh = (1 << 15) /
s->strength;
128 s->radius =
av_clip((
s->radius + 1) & ~1, 4, 32);
133#if ARCH_X86 && HAVE_X86ASM
162 int vsub =
desc->log2_chroma_h;
171 s->chroma_r =
av_clip(((((
s->radius >>
hsub) + (
s->radius >> vsub)) / 2 ) + 1) & ~1, 4, 32);
196 for (p = 0; p < 4 && in->
data[p] && in->
linesize[p]; p++) {
208 else if (
out->data[p] != in->
data[p])
218#define OFFSET(x) offsetof(GradFunContext, x)
219#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
222 {
"strength",
"The maximum amount by which the filter will change any one pixel.",
OFFSET(strength),
AV_OPT_TYPE_FLOAT, { .dbl = 1.2 }, 0.51, 64,
FLAGS },
241 .p.priv_class = &gradfun_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static int config_input(AVFilterLink *inlink)
const FFFilter ff_vf_gradfun
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Main libavfilter public API header.
common internal and external API header
#define AV_CEIL_RSHIFT(a, b)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
int(* init)(AVBSFContext *ctx)
void ff_gradfun_blur_line_c(uint16_t *dc, uint16_t *buf, const uint16_t *buf1, const uint8_t *src, int src_linesize, int width)
void ff_gradfun_filter_line_c(uint8_t *dst, const uint8_t *src, const uint16_t *dc, int width, int thresh, const uint16_t *dithers)
void ff_gradfun_init_x86(GradFunContext *gf)
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
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_VERBOSE
Detailed information.
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 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[]
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
@ 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
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 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...
Holds instance-specific information for gradfun.
static const uint8_t dithers[8][8][8]
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)
static AVFormatContext * ctx
void ff_gradfun_blur_line_c(uint16_t *dc, uint16_t *buf, const uint16_t *buf1, const uint8_t *src, int src_linesize, int width)
static int config_input(AVFilterLink *inlink)
static const AVOption gradfun_options[]
static const AVFilterPad avfilter_vf_gradfun_inputs[]
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
void ff_gradfun_filter_line_c(uint8_t *dst, const uint8_t *src, const uint16_t *dc, int width, int thresh, const uint16_t *dithers)
static av_cold void uninit(AVFilterContext *ctx)
static const uint16_t dither[8][8]
static int mod(int a, int b)
Modulo operation with only positive remainders.
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.