45#define OFFSET(x) offsetof(SwapRectContext, x)
46#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
71static const char *
const var_names[] = {
"w",
"h",
"a",
"n",
"t",
"sar",
"dar",
NULL };
91 var_values[
VAR_W] = inlink->
w;
92 var_values[
VAR_H] = inlink->
h;
141 w = dw;
h = dh; x1[0] = dx1; y1[0] = dy1; x2[0] = dx2; y2[0] = dy2;
143 x1[0] =
av_clip(x1[0], 0, inlink->
w - 1);
144 y1[0] =
av_clip(y1[0], 0, inlink->
h - 1);
146 x2[0] =
av_clip(x2[0], 0, inlink->
w - 1);
147 y2[0] =
av_clip(y2[0], 0, inlink->
h - 1);
154 w =
FFMIN3(
w, inlink->
w - x1[0], inlink->
w - x2[0]);
155 h =
FFMIN3(
h, inlink->
h - y1[0], inlink->
h - y2[0]);
163 lh[0] = lh[3] = inlink->
h;
165 lw[0] = lw[3] = inlink->
w;
167 x1[1] = x1[2] = (x1[0] >>
s->desc->log2_chroma_w);
168 x1[0] = x1[3] = x1[0];
169 y1[1] = y1[2] = (y1[0] >>
s->desc->log2_chroma_h);
170 y1[0] = y1[3] = y1[0];
172 x2[1] = x2[2] = (x2[0] >>
s->desc->log2_chroma_w);
173 x2[0] = x2[3] = x2[0];
174 y2[1] = y2[2] = (y2[0] >>
s->desc->log2_chroma_h);
175 y2[0] = y2[3] = y2[0];
181 for (p = 0; p <
s->nb_planes; p++) {
182 if (
ph[p] == ah[p] && pw[p] == aw[p]) {
183 uint8_t *
src = in->
data[p] + y1[p] * in->
linesize[p] + x1[p] *
s->pixsteps[p];
184 uint8_t *
dst = in->
data[p] + y2[p] * in->
linesize[p] + x2[p] *
s->pixsteps[p];
186 for (y = 0; y <
ph[p]; y++) {
187 memcpy(
s->temp,
src, pw[p] *
s->pixsteps[p]);
188 memmove(
src,
dst, pw[p] *
s->pixsteps[p]);
189 memcpy(
dst,
s->temp, pw[p] *
s->pixsteps[p]);
205 if (!
s->w || !
s->h ||
214 for (
int p = 0; p <
s->nb_planes; p++) {
215 int shift = p == 1 || p == 2 ?
s->desc->log2_chroma_w : 0;
218 if (
width > INT_MAX /
s->pixsteps[p])
247 .p.name =
"swaprect",
249 .p.priv_class = &swaprect_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static const AVFilterPad inputs[]
static int config_input(AVFilterLink *inlink)
const FFFilter ff_vf_swaprect
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
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.
Main libavfilter public API header.
static int FUNC ph(CodedBitstreamContext *ctx, RWContext *rw, H266RawPH *current)
#define AV_CEIL_RSHIFT(a, b)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
int av_expr_parse_and_eval(double *d, const char *s, const char *const *const_names, const double *const_values, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), void *opaque, int log_offset, void *log_ctx)
Parse and evaluate an expression.
simple arithmetic expression evaluator
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
static double av_q2d(AVRational a)
Convert an AVRational to a double.
void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], const AVPixFmtDescriptor *pixdesc)
Compute the max pixel step for each plane of an image with a format described by pixdesc.
#define AV_NOPTS_VALUE
Undefined timestamp value.
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int shift(int a, int b)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define AVFILTERPAD_FLAG_NEEDS_WRITABLE
The filter expects writable frames from its input link, duplicating data buffers if needed.
static FilterLink * ff_filter_link(AVFilterLink *link)
#define AVFILTER_DEFINE_CLASS(fname)
#define FILTER_QUERY_FUNC2(func)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Memory handling functions.
static const char *const var_names[]
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
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
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.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
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...
Link properties exposed to filter code, but not external callers.
const AVPixFmtDescriptor * desc
static AVFormatContext * ctx
static int config_input(AVFilterLink *inlink)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static const AVOption swaprect_options[]
static av_cold void uninit(AVFilterContext *ctx)
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.