Go to the documentation of this file.
55 #define DEFINE_SMEAR(depth, type, div) \
56 static int smear_slice ## depth(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) \
58 ChromaShiftContext *s = ctx->priv; \
59 AVFrame *in = s->in; \
61 const int sulinesize = in->linesize[1] / div; \
62 const int svlinesize = in->linesize[2] / div; \
63 const int ulinesize = out->linesize[1] / div; \
64 const int vlinesize = out->linesize[2] / div; \
65 const int cbh = s->cbh; \
66 const int cbv = s->cbv; \
67 const int crh = s->crh; \
68 const int crv = s->crv; \
69 const int h = s->height[1]; \
70 const int w = s->width[1]; \
71 const int slice_start = (h * jobnr) / nb_jobs; \
72 const int slice_end = (h * (jobnr+1)) / nb_jobs; \
73 const type *su = (const type *)in->data[1]; \
74 const type *sv = (const type *)in->data[2]; \
75 type *du = (type *)out->data[1] + slice_start * ulinesize; \
76 type *dv = (type *)out->data[2] + slice_start * vlinesize; \
78 for (int y = slice_start; y < slice_end; y++) { \
79 const int duy = av_clip(y - cbv, 0, h-1) * sulinesize; \
80 const int dvy = av_clip(y - crv, 0, h-1) * svlinesize; \
82 for (int x = 0; x < w; x++) { \
83 du[x] = su[av_clip(x - cbh, 0, w - 1) + duy]; \
84 dv[x] = sv[av_clip(x - crh, 0, w - 1) + dvy]; \
97 #define DEFINE_WRAP(depth, type, div) \
98 static int wrap_slice ## depth(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) \
100 ChromaShiftContext *s = ctx->priv; \
101 AVFrame *in = s->in; \
102 AVFrame *out = arg; \
103 const int sulinesize = in->linesize[1] / div; \
104 const int svlinesize = in->linesize[2] / div; \
105 const int ulinesize = out->linesize[1] / div; \
106 const int vlinesize = out->linesize[2] / div; \
107 const int cbh = s->cbh; \
108 const int cbv = s->cbv; \
109 const int crh = s->crh; \
110 const int crv = s->crv; \
111 const int h = s->height[1]; \
112 const int w = s->width[1]; \
113 const int slice_start = (h * jobnr) / nb_jobs; \
114 const int slice_end = (h * (jobnr+1)) / nb_jobs; \
115 const type *su = (const type *)in->data[1]; \
116 const type *sv = (const type *)in->data[2]; \
117 type *du = (type *)out->data[1] + slice_start * ulinesize; \
118 type *dv = (type *)out->data[2] + slice_start * vlinesize; \
120 for (int y = slice_start; y < slice_end; y++) { \
121 int uy = (y - cbv) % h; \
122 int vy = (y - crv) % h; \
129 for (int x = 0; x < w; x++) { \
130 int ux = (x - cbh) % w; \
131 int vx = (x - crh) % w; \
138 du[x] = su[ux + uy * sulinesize]; \
139 dv[x] = sv[vx + vy * svlinesize]; \
152 #define DEFINE_RGBASMEAR(depth, type, div) \
153 static int rgbasmear_slice ## depth(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) \
155 ChromaShiftContext *s = ctx->priv; \
156 AVFrame *in = s->in; \
157 AVFrame *out = arg; \
158 const int srlinesize = in->linesize[2] / div; \
159 const int sglinesize = in->linesize[0] / div; \
160 const int sblinesize = in->linesize[1] / div; \
161 const int salinesize = in->linesize[3] / div; \
162 const int rlinesize = out->linesize[2] / div; \
163 const int glinesize = out->linesize[0] / div; \
164 const int blinesize = out->linesize[1] / div; \
165 const int alinesize = out->linesize[3] / div; \
166 const int rh = s->rh; \
167 const int rv = s->rv; \
168 const int gh = s->gh; \
169 const int gv = s->gv; \
170 const int bh = s->bh; \
171 const int bv = s->bv; \
172 const int ah = s->ah; \
173 const int av = s->av; \
174 const int h = s->height[1]; \
175 const int w = s->width[1]; \
176 const int slice_start = (h * jobnr) / nb_jobs; \
177 const int slice_end = (h * (jobnr+1)) / nb_jobs; \
178 const type *sr = (const type *)in->data[2]; \
179 const type *sg = (const type *)in->data[0]; \
180 const type *sb = (const type *)in->data[1]; \
181 const type *sa = (const type *)in->data[3]; \
182 type *dr = (type *)out->data[2] + slice_start * rlinesize; \
183 type *dg = (type *)out->data[0] + slice_start * glinesize; \
184 type *db = (type *)out->data[1] + slice_start * blinesize; \
185 type *da = (type *)out->data[3] + slice_start * alinesize; \
187 for (int y = slice_start; y < slice_end; y++) { \
188 const int ry = av_clip(y - rv, 0, h-1) * srlinesize; \
189 const int gy = av_clip(y - gv, 0, h-1) * sglinesize; \
190 const int by = av_clip(y - bv, 0, h-1) * sblinesize; \
193 for (int x = 0; x < w; x++) { \
194 dr[x] = sr[av_clip(x - rh, 0, w - 1) + ry]; \
195 dg[x] = sg[av_clip(x - gh, 0, w - 1) + gy]; \
196 db[x] = sb[av_clip(x - bh, 0, w - 1) + by]; \
203 if (s->nb_planes < 4) \
205 ay = av_clip(y - av, 0, h-1) * salinesize; \
206 for (int x = 0; x < w; x++) { \
207 da[x] = sa[av_clip(x - ah, 0, w - 1) + ay]; \
219 #define DEFINE_RGBAWRAP(depth, type, div) \
220 static int rgbawrap_slice ## depth(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) \
222 ChromaShiftContext *s = ctx->priv; \
223 AVFrame *in = s->in; \
224 AVFrame *out = arg; \
225 const int srlinesize = in->linesize[2] / div; \
226 const int sglinesize = in->linesize[0] / div; \
227 const int sblinesize = in->linesize[1] / div; \
228 const int salinesize = in->linesize[3] / div; \
229 const int rlinesize = out->linesize[2] / div; \
230 const int glinesize = out->linesize[0] / div; \
231 const int blinesize = out->linesize[1] / div; \
232 const int alinesize = out->linesize[3] / div; \
233 const int rh = s->rh; \
234 const int rv = s->rv; \
235 const int gh = s->gh; \
236 const int gv = s->gv; \
237 const int bh = s->bh; \
238 const int bv = s->bv; \
239 const int ah = s->ah; \
240 const int av = s->av; \
241 const int h = s->height[1]; \
242 const int w = s->width[1]; \
243 const int slice_start = (h * jobnr) / nb_jobs; \
244 const int slice_end = (h * (jobnr+1)) / nb_jobs; \
245 const type *sr = (const type *)in->data[2]; \
246 const type *sg = (const type *)in->data[0]; \
247 const type *sb = (const type *)in->data[1]; \
248 const type *sa = (const type *)in->data[3]; \
249 type *dr = (type *)out->data[2] + slice_start * rlinesize; \
250 type *dg = (type *)out->data[0] + slice_start * glinesize; \
251 type *db = (type *)out->data[1] + slice_start * blinesize; \
252 type *da = (type *)out->data[3] + slice_start * alinesize; \
254 for (int y = slice_start; y < slice_end; y++) { \
255 int ry = (y - rv) % h; \
256 int gy = (y - gv) % h; \
257 int by = (y - bv) % h; \
266 for (int x = 0; x < w; x++) { \
267 int rx = (x - rh) % w; \
268 int gx = (x - gh) % w; \
269 int bx = (x - bh) % w; \
277 dr[x] = sr[rx + ry * srlinesize]; \
278 dg[x] = sg[gx + gy * sglinesize]; \
279 db[x] = sb[bx + by * sblinesize]; \
286 if (s->nb_planes < 4) \
288 for (int x = 0; x < w; x++) { \
289 int ax = (x - ah) % w; \
290 int ay = (x - av) % h; \
296 da[x] = sa[ax + ay * salinesize]; \
323 if (!
s->is_rgbashift) {
326 in->data[0], in->linesize[0],
327 s->linesize[0],
s->height[0]);
344 s->is_rgbashift = !strcmp(
ctx->filter->name,
"rgbashift");
345 s->depth =
desc->comp[0].depth;
346 s->nb_planes =
desc->nb_components;
347 if (
s->is_rgbashift) {
349 s->filter_slice =
s->depth > 8 ? rgbawrap_slice16 : rgbawrap_slice8;
351 s->filter_slice =
s->depth > 8 ? rgbasmear_slice16 : rgbasmear_slice8;
354 s->filter_slice =
s->depth > 8 ? wrap_slice16 : wrap_slice8;
356 s->filter_slice =
s->depth > 8 ? smear_slice16 : smear_slice8;
359 s->height[0] =
s->height[3] =
inlink->h;
361 s->width[0] =
s->width[3] =
inlink->w;
367 char *res,
int res_len,
int flags)
378 #define OFFSET(x) offsetof(ChromaShiftContext, x)
379 #define VFR AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_RUNTIME_PARAM
426 .
name =
"chromashift",
429 .priv_class = &chromashift_class,
466 .priv_class = &rgbashift_class,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
#define AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_GBRAP16
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
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
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)
#define FILTER_PIXFMTS_ARRAY(array)
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
static enum AVPixelFormat yuv_pix_fmts[]
#define DEFINE_SMEAR(depth, type, div)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
#define AV_PIX_FMT_YUVA420P16
static int config_input(AVFilterLink *inlink)
#define AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUV420P10
const AVFilter ff_vf_chromashift
const AVFilter ff_vf_rgbashift
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
const char * name
Filter name.
A link between two filters.
#define AV_PIX_FMT_YUVA422P10
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.
#define AV_PIX_FMT_GBRP14
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
#define AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUV422P9
A filter pad used for either input or output.
#define AV_PIX_FMT_YUV444P10
#define DEFINE_WRAP(depth, type, div)
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
AVFILTER_DEFINE_CLASS(chromashift)
#define AV_PIX_FMT_YUV422P16
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
#define AV_PIX_FMT_GBRAP10
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_PIX_FMT_GBRAP12
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
#define AV_PIX_FMT_YUV444P16
#define AV_CEIL_RSHIFT(a, b)
#define AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P16
#define DEFINE_RGBAWRAP(depth, type, div)
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FILTER_INPUTS(array)
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
#define AV_PIX_FMT_GBRP16
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.
static const AVOption rgbashift_options[]
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
int(* filter_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
#define AV_PIX_FMT_YUV440P10
#define AV_PIX_FMT_YUV422P10
#define DEFINE_RGBASMEAR(depth, type, div)
static enum AVPixelFormat rgb_pix_fmts[]
static const AVFilterPad inputs[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV444P12
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.
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
#define AV_PIX_FMT_YUVA444P10
#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 w
agreed upon image width
#define AV_PIX_FMT_GBRP12
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
const char * name
Pad name.
#define AV_PIX_FMT_YUV444P9
static const AVOption chromashift_options[]
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV422P14
int h
agreed upon image height
#define AV_PIX_FMT_YUVA422P12
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
@ 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
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
#define FILTER_OUTPUTS(array)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
#define flags(name, subs,...)
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
#define AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV444P14
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
#define AV_PIX_FMT_YUV420P14
static const AVFilterPad outputs[]