51#define DEFINE_SMEAR(depth, type, div) \
52static int smear_slice ## depth(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) \
54 ChromaShiftContext *s = ctx->priv; \
55 AVFrame *in = s->in; \
57 const int sulinesize = in->linesize[1] / div; \
58 const int svlinesize = in->linesize[2] / div; \
59 const int ulinesize = out->linesize[1] / div; \
60 const int vlinesize = out->linesize[2] / div; \
61 const int cbh = s->cbh; \
62 const int cbv = s->cbv; \
63 const int crh = s->crh; \
64 const int crv = s->crv; \
65 const int h = s->height[1]; \
66 const int w = s->width[1]; \
67 const int slice_start = ff_slice_pos(h, jobnr, nb_jobs); \
68 const int slice_end = ff_slice_pos(h, jobnr + 1, nb_jobs); \
69 const type *su = (const type *)in->data[1]; \
70 const type *sv = (const type *)in->data[2]; \
71 type *du = (type *)out->data[1] + slice_start * ulinesize; \
72 type *dv = (type *)out->data[2] + slice_start * vlinesize; \
74 for (int y = slice_start; y < slice_end; y++) { \
75 const int duy = av_clip(y - cbv, 0, h-1) * sulinesize; \
76 const int dvy = av_clip(y - crv, 0, h-1) * svlinesize; \
78 for (int x = 0; x < w; x++) { \
79 du[x] = su[av_clip(x - cbh, 0, w - 1) + duy]; \
80 dv[x] = sv[av_clip(x - crh, 0, w - 1) + dvy]; \
93#define DEFINE_WRAP(depth, type, div) \
94static int wrap_slice ## depth(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) \
96 ChromaShiftContext *s = ctx->priv; \
97 AVFrame *in = s->in; \
99 const int sulinesize = in->linesize[1] / div; \
100 const int svlinesize = in->linesize[2] / div; \
101 const int ulinesize = out->linesize[1] / div; \
102 const int vlinesize = out->linesize[2] / div; \
103 const int cbh = s->cbh; \
104 const int cbv = s->cbv; \
105 const int crh = s->crh; \
106 const int crv = s->crv; \
107 const int h = s->height[1]; \
108 const int w = s->width[1]; \
109 const int slice_start = ff_slice_pos(h, jobnr, nb_jobs); \
110 const int slice_end = ff_slice_pos(h, jobnr + 1, nb_jobs); \
111 const type *su = (const type *)in->data[1]; \
112 const type *sv = (const type *)in->data[2]; \
113 type *du = (type *)out->data[1] + slice_start * ulinesize; \
114 type *dv = (type *)out->data[2] + slice_start * vlinesize; \
116 for (int y = slice_start; y < slice_end; y++) { \
117 int uy = (y - cbv) % h; \
118 int vy = (y - crv) % h; \
125 for (int x = 0; x < w; x++) { \
126 int ux = (x - cbh) % w; \
127 int vx = (x - crh) % w; \
134 du[x] = su[ux + uy * sulinesize]; \
135 dv[x] = sv[vx + vy * svlinesize]; \
148#define DEFINE_RGBASMEAR(depth, type, div) \
149static int rgbasmear_slice ## depth(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) \
151 ChromaShiftContext *s = ctx->priv; \
152 AVFrame *in = s->in; \
153 AVFrame *out = arg; \
154 const int srlinesize = in->linesize[2] / div; \
155 const int sglinesize = in->linesize[0] / div; \
156 const int sblinesize = in->linesize[1] / div; \
157 const int salinesize = in->linesize[3] / div; \
158 const int rlinesize = out->linesize[2] / div; \
159 const int glinesize = out->linesize[0] / div; \
160 const int blinesize = out->linesize[1] / div; \
161 const int alinesize = out->linesize[3] / div; \
162 const int rh = s->rh; \
163 const int rv = s->rv; \
164 const int gh = s->gh; \
165 const int gv = s->gv; \
166 const int bh = s->bh; \
167 const int bv = s->bv; \
168 const int ah = s->ah; \
169 const int av = s->av; \
170 const int h = s->height[1]; \
171 const int w = s->width[1]; \
172 const int slice_start = ff_slice_pos(h, jobnr, nb_jobs); \
173 const int slice_end = ff_slice_pos(h, jobnr + 1, nb_jobs); \
174 const type *sr = (const type *)in->data[2]; \
175 const type *sg = (const type *)in->data[0]; \
176 const type *sb = (const type *)in->data[1]; \
177 const type *sa = (const type *)in->data[3]; \
178 type *dr = (type *)out->data[2] + slice_start * rlinesize; \
179 type *dg = (type *)out->data[0] + slice_start * glinesize; \
180 type *db = (type *)out->data[1] + slice_start * blinesize; \
181 type *da = (type *)out->data[3] + slice_start * alinesize; \
183 for (int y = slice_start; y < slice_end; y++) { \
184 const int ry = av_clip(y - rv, 0, h-1) * srlinesize; \
185 const int gy = av_clip(y - gv, 0, h-1) * sglinesize; \
186 const int by = av_clip(y - bv, 0, h-1) * sblinesize; \
189 for (int x = 0; x < w; x++) { \
190 dr[x] = sr[av_clip(x - rh, 0, w - 1) + ry]; \
191 dg[x] = sg[av_clip(x - gh, 0, w - 1) + gy]; \
192 db[x] = sb[av_clip(x - bh, 0, w - 1) + by]; \
199 if (s->nb_planes < 4) \
201 ay = av_clip(y - av, 0, h-1) * salinesize; \
202 for (int x = 0; x < w; x++) { \
203 da[x] = sa[av_clip(x - ah, 0, w - 1) + ay]; \
215#define DEFINE_RGBAWRAP(depth, type, div) \
216static int rgbawrap_slice ## depth(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) \
218 ChromaShiftContext *s = ctx->priv; \
219 AVFrame *in = s->in; \
220 AVFrame *out = arg; \
221 const int srlinesize = in->linesize[2] / div; \
222 const int sglinesize = in->linesize[0] / div; \
223 const int sblinesize = in->linesize[1] / div; \
224 const int salinesize = in->linesize[3] / div; \
225 const int rlinesize = out->linesize[2] / div; \
226 const int glinesize = out->linesize[0] / div; \
227 const int blinesize = out->linesize[1] / div; \
228 const int alinesize = out->linesize[3] / div; \
229 const int rh = s->rh; \
230 const int rv = s->rv; \
231 const int gh = s->gh; \
232 const int gv = s->gv; \
233 const int bh = s->bh; \
234 const int bv = s->bv; \
235 const int ah = s->ah; \
236 const int av = s->av; \
237 const int h = s->height[1]; \
238 const int w = s->width[1]; \
239 const int slice_start = ff_slice_pos(h, jobnr, nb_jobs); \
240 const int slice_end = ff_slice_pos(h, jobnr + 1, nb_jobs); \
241 const type *sr = (const type *)in->data[2]; \
242 const type *sg = (const type *)in->data[0]; \
243 const type *sb = (const type *)in->data[1]; \
244 const type *sa = (const type *)in->data[3]; \
245 type *dr = (type *)out->data[2] + slice_start * rlinesize; \
246 type *dg = (type *)out->data[0] + slice_start * glinesize; \
247 type *db = (type *)out->data[1] + slice_start * blinesize; \
248 type *da = (type *)out->data[3] + slice_start * alinesize; \
250 for (int y = slice_start; y < slice_end; y++) { \
251 int ry = (y - rv) % h; \
252 int gy = (y - gv) % h; \
253 int by = (y - bv) % h; \
262 for (int x = 0; x < w; x++) { \
263 int rx = (x - rh) % w; \
264 int gx = (x - gh) % w; \
265 int bx = (x - bh) % w; \
273 dr[x] = sr[rx + ry * srlinesize]; \
274 dg[x] = sg[gx + gy * sglinesize]; \
275 db[x] = sb[bx + by * sblinesize]; \
282 if (s->nb_planes < 4) \
284 for (int x = 0; x < w; x++) { \
285 int ax = (x - ah) % w; \
286 int ay = (x - av) % h; \
292 da[x] = sa[ax + ay * salinesize]; \
319 if (!
s->is_rgbashift) {
322 in->data[0], in->linesize[0],
323 s->linesize[0],
s->height[0]);
340 s->is_rgbashift = !strcmp(
ctx->filter->name,
"rgbashift");
341 s->depth =
desc->comp[0].depth;
342 s->nb_planes =
desc->nb_components;
343 if (
s->is_rgbashift) {
344 s->filter_slice[1] =
s->depth > 8 ? rgbawrap_slice16 : rgbawrap_slice8;
345 s->filter_slice[0] =
s->depth > 8 ? rgbasmear_slice16 : rgbasmear_slice8;
347 s->filter_slice[1] =
s->depth > 8 ? wrap_slice16 : wrap_slice8;
348 s->filter_slice[0] =
s->depth > 8 ? smear_slice16 : smear_slice8;
351 s->height[0] =
s->height[3] = inlink->
h;
353 s->width[0] =
s->width[3] = inlink->
w;
358#define OFFSET(x) offsetof(ChromaShiftContext, x)
359#define VFR AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_RUNTIME_PARAM
399 .p.name =
"chromashift",
401 .p.priv_class = &chromashift_class,
436 .p.name =
"rgbashift",
438 .p.priv_class = &rgbashift_class,
static const AVFilterPad inputs[]
static int config_input(AVFilterLink *inlink)
const FFFilter ff_vf_chromashift
const FFFilter ff_vf_rgbashift
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Main libavfilter public API header.
#define AV_CEIL_RSHIFT(a, b)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
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.
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_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.
static enum AVPixelFormat rgb_pix_fmts[]
static enum AVPixelFormat yuv_pix_fmts[]
#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.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUV420P14
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_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
@ 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_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
@ 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 AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV440P10
#define AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P10
Describe the class of an AVClass context structure.
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.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
int(* filter_slice[2])(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static AVFormatContext * ctx
#define DEFINE_RGBASMEAR(depth, type, div)
static const AVOption rgbashift_options[]
#define DEFINE_RGBAWRAP(depth, type, div)
static int config_input(AVFilterLink *inlink)
#define DEFINE_WRAP(depth, type, div)
static const AVOption chromashift_options[]
#define DEFINE_SMEAR(depth, type, div)
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.