50#define OFFSET(x) offsetof(DisplaceContext, x)
51#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
90 for (
int plane = 0; plane <
s->nb_planes; plane++) {
91 const int h =
s->height[plane];
92 const int w =
s->width[plane];
95 const int dlinesize =
out->linesize[plane];
96 const int slinesize = in->
linesize[plane];
97 const int xlinesize = xin->
linesize[plane];
98 const int ylinesize = yin->
linesize[plane];
99 const uint8_t *
src = in->
data[plane];
103 const uint8_t blank =
s->blank[plane];
108 for (
int x = 0; x <
w; x++) {
109 int Y = y + ysrc[x] - 128;
110 int X = x + xsrc[x] - 128;
119 for (
int x = 0; x <
w; x++) {
120 int Y =
av_clip(y + ysrc[x] - 128, 0,
h - 1);
121 int X =
av_clip(x + xsrc[x] - 128, 0,
w - 1);
126 for (
int x = 0; x <
w; x++) {
127 int Y = (y + ysrc[x] - 128) %
h;
128 int X = (x + xsrc[x] - 128) %
w;
138 for (
int x = 0; x <
w; x++) {
139 int Y = y + ysrc[x] - 128;
140 int X = x + xsrc[x] - 128;
171 const int step =
s->step;
172 const int h =
s->height[0];
173 const int w =
s->width[0];
176 const int dlinesize =
out->linesize[0];
177 const int slinesize = in->
linesize[0];
178 const int xlinesize = xin->
linesize[0];
179 const int ylinesize = yin->
linesize[0];
180 const uint8_t *
src = in->
data[0];
184 const uint8_t *blank =
s->blank;
189 for (
int x = 0; x <
w; x++) {
190 for (
int c = 0;
c <
s->nb_components;
c++) {
191 int Y = y + (ysrc[x * step +
c] - 128);
192 int X = x + (xsrc[x * step +
c] - 128);
195 dst[x * step +
c] = blank[
c];
197 dst[x * step +
c] =
src[
Y * slinesize +
X * step +
c];
202 for (
int x = 0; x <
w; x++) {
203 for (
int c = 0;
c <
s->nb_components;
c++) {
204 int Y =
av_clip(y + (ysrc[x * step +
c] - 128), 0,
h - 1);
205 int X =
av_clip(x + (xsrc[x * step +
c] - 128), 0,
w - 1);
207 dst[x * step +
c] =
src[
Y * slinesize +
X * step +
c];
212 for (
int x = 0; x <
w; x++) {
213 for (
int c = 0;
c <
s->nb_components;
c++) {
214 int Y = (y + (ysrc[x * step +
c] - 128)) %
h;
215 int X = (x + (xsrc[x * step +
c] - 128)) %
w;
221 dst[x * step +
c] =
src[
Y * slinesize +
X * step +
c];
226 for (
int x = 0; x <
w; x++) {
227 for (
int c = 0;
c <
s->nb_components;
c++) {
228 int Y = y + ysrc[x * step +
c] - 128;
229 int X = x + xsrc[x * step +
c] - 128;
239 dst[x * step +
c] =
src[
Y * slinesize +
X * step +
c];
265 if (
ctx->is_disabled) {
297 s->nb_components =
desc->nb_components;
299 if (
s->nb_planes > 1 ||
s->nb_components == 1)
305 s->blank[1] =
s->blank[2] = 128;
311 vsub =
desc->log2_chroma_h;
313 s->height[0] =
s->height[3] = inlink->
h;
315 s->width[0] =
s->width[3] = inlink->
w;
332 if (srclink->
w != xlink->
w ||
333 srclink->
h != xlink->
h ||
334 srclink->
w != ylink->
w ||
335 srclink->
h != ylink->
h) {
337 "(size %dx%d) do not match the corresponding "
338 "second input link %s parameters (%dx%d) "
339 "and/or third input link %s parameters (%dx%d)\n",
340 ctx->input_pads[0].name, srclink->
w, srclink->
h,
341 ctx->input_pads[1].name, xlink->
w, xlink->
h,
342 ctx->input_pads[2].name, ylink->
w, ylink->
h);
346 outlink->
w = srclink->
w;
347 outlink->
h = srclink->
h;
415 .p.name =
"displace",
417 .p.priv_class = &displace_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_displace
static AVFormatContext * ctx
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 fs(width, name, subs,...)
#define AV_CEIL_RSHIFT(a, b)
static av_always_inline int process_frame(AVTextFormatContext *tfc, InputFile *ifile, AVFrame *frame, const AVPacket *pkt, int *packet_new)
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, unsigned get)
Get the current frame in an input.
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
int ff_framesync_init(FFFrameSync *fs, AVFilterContext *parent, unsigned nb_in)
Initialize a frame sync structure.
@ EXT_INFINITY
Extend the frame to infinity.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
static int config_output(AVBitStreamFilterLink *outlink)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
static int ff_slice_pos(int total, int jobnr, int nb_jobs)
Compute the boundary index for a slice when work of size total is split into nb_jobs slices.
#define FILTER_PIXFMTS_ARRAY(array)
static FilterLink * ff_filter_link(AVFilterLink *link)
#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[]
static int slice_end(AVCodecContext *avctx, AVFrame *pict, int *got_output)
Handle slice ends.
@ EXT_STOP
Completely stop all streams with this one.
@ EXT_NULL
Ignore this stream and continue processing the other ones.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel for the pixel format described by pixdesc, including any padding ...
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_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
@ 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_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ 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_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
@ 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_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
@ 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_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
@ 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...
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 * src
source filter
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
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...
int(* displace_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
enum FFFrameSyncExtMode after
Extrapolation mode for timestamps after the last frame.
enum FFFrameSyncExtMode before
Extrapolation mode for timestamps before the first frame.
AVRational time_base
Time base for the incoming frames.
unsigned sync
Synchronization level: frames on input at the highest sync level will generate output frame events.
Link properties exposed to filter code, but not external callers.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable.
Used for passing data between threads.
static const AVFilterPad displace_inputs[]
static int config_input(AVFilterLink *inlink)
static const AVFilterPad displace_outputs[]
static int displace_planar(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int activate(AVFilterContext *ctx)
static av_cold void uninit(AVFilterContext *ctx)
static int config_output(AVFilterLink *outlink)
static const AVOption displace_options[]
static int process_frame(FFFrameSync *fs)
static int displace_packed(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
static int slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)