80 uint8_t *(*interpolate_bilinear)(uint8_t *dst_color,
81 const uint8_t *
src,
int src_linesize,
int src_linestep,
82 int x,
int y,
int max_x,
int max_y);
95#define OFFSET(x) offsetof(RotContext, x)
96#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
97#define TFLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
163 float sinx = sin(angle);
164 float cosx = cos(angle);
166 return FFMAX(0, inh * sinx) +
FFMAX(0, -inw * cosx) +
175 float sinx = sin(angle);
176 float cosx = cos(angle);
178 return FFMAX(0, -inh * cosx) +
FFMAX(0, -inw * sinx) +
196#define INT_PI 3294199
214 for (
i = 2;
i < 11;
i += 2) {
226 const uint8_t *
src,
int src_linesize,
int src_linestep,
227 int x,
int y,
int max_x,
int max_y)
229 int int_x =
av_clip(x>>16, 0, max_x);
230 int int_y =
av_clip(y>>16, 0, max_y);
231 int frac_x = x&0xFFFF;
232 int frac_y = y&0xFFFF;
234 int int_x1 =
FFMIN(int_x+1, max_x);
235 int int_y1 =
FFMIN(int_y+1, max_y);
237 for (
i = 0;
i < src_linestep;
i++) {
238 int s00 =
src[src_linestep * int_x +
i + src_linesize * int_y ];
239 int s01 =
src[src_linestep * int_x1 +
i + src_linesize * int_y ];
240 int s10 =
src[src_linestep * int_x +
i + src_linesize * int_y1];
241 int s11 =
src[src_linestep * int_x1 +
i + src_linesize * int_y1];
242 int s0 = (((1<<16) - frac_x)*s00 + frac_x*s01);
243 int s1 = (((1<<16) - frac_x)*s10 + frac_x*s11);
245 dst_color[
i] = ((
int64_t)((1<<16) - frac_y)*s0 + (
int64_t)frac_y*s1) >> 32;
256 const uint8_t *
src,
int src_linesize,
int src_linestep,
257 int x,
int y,
int max_x,
int max_y)
259 int int_x =
av_clip(x>>16, 0, max_x);
260 int int_y =
av_clip(y>>16, 0, max_y);
264 int int_x1 =
FFMIN(int_x+1, max_x);
265 int int_y1 =
FFMIN(int_y+1, max_y);
267 for (
i = 0;
i < src_linestep;
i+=2) {
268 int s00 =
AV_RL16(&
src[src_linestep * int_x +
i + src_linesize * int_y ]);
269 int s01 =
AV_RL16(&
src[src_linestep * int_x1 +
i + src_linesize * int_y ]);
270 int s10 =
AV_RL16(&
src[src_linestep * int_x +
i + src_linesize * int_y1]);
271 int s11 =
AV_RL16(&
src[src_linestep * int_x1 +
i + src_linesize * int_y1]);
272 int64_t s0 = (((1<<16) - frac_x)*s00 + frac_x*s01);
273 int64_t s1 = (((1<<16) - frac_x)*s10 + frac_x*s11);
275 AV_WL16(&dst_color[
i], (((1<<16) - frac_y)*s0 + frac_y*s1) >> 32);
318 "Error occurred parsing angle expression '%s'\n", rot->
angle_expr_str);
322#define SET_SIZE_EXPR(name, opt_name) do { \
323 ret = av_expr_parse_and_eval(&res, expr = rot->name##_expr_str, \
324 var_names, rot->var_values, \
325 func1_names, func1, NULL, NULL, rot, 0, ctx); \
326 if (ret < 0 || isnan(res) || isinf(res) || res <= 0) { \
327 av_log(ctx, AV_LOG_ERROR, \
328 "Error parsing or evaluating expression for option %s: " \
329 "invalid expression '%s' or non-positive or indefinite value %f\n", \
330 opt_name, expr, res); \
339 rot->
outw = res + 0.5;
342 rot->
outh = res + 0.5;
347 rot->
outw = res + 0.5;
351 outlink->
w = rot->
outw;
352 outlink->
h = rot->
outh;
364 *((uint16_t *)pout) = *((uint16_t *)pin);
371 *((uint32_t *)pout) = *((uint32_t *)pin);
374 memcpy(pout, pin, elem_size);
418 const int outw = td->
outw, outh = td->
outh;
419 const int inw = td->
inw, inh = td->
inh;
420 const int plane = td->
plane;
421 const int xi = td->
xi, yi = td->
yi;
422 const int c = td->
c,
s = td->
s;
423 const int start = (outh * job ) / nb_jobs;
424 const int end = (outh * (job+1)) / nb_jobs;
425 int xprime = td->
xprime + start *
s;
426 int yprime = td->
yprime + start *
c;
429 for (j = start; j < end; j++) {
430 x = xprime +
xi +
FIXP*(inw-1)/2;
431 y = yprime + yi +
FIXP*(inh-1)/2;
433 if (
fabs(rot->
angle - 0) < FLT_EPSILON && outw == inw && outh == inh) {
437 }
else if (
fabs(rot->
angle -
M_PI/2) < FLT_EPSILON && outw == inh && outh == inw) {
441 }
else if (
fabs(rot->
angle -
M_PI) < FLT_EPSILON && outw == inw && outh == inh) {
445 }
else if (
fabs(rot->
angle - 3*
M_PI/2) < FLT_EPSILON && outw == inh && outh == inw) {
451 for (
i = 0;
i < outw;
i++) {
459 if (x1 >= -1 && x1 <= inw && y1 >= -1 && y1 <= inh) {
467 int x2 =
av_clip(x1, 0, inw-1);
468 int y2 =
av_clip(y1, 0, inh-1);
484 *((uint32_t *)pout) = *((uint32_t *)pin);
509 int angle_int,
s,
c, plane;
526 angle_int = res *
FIXP * 16;
533 0, 0, outlink->
w, outlink->
h);
535 for (plane = 0; plane < rot->
nb_planes; plane++) {
536 int hsub = plane == 1 || plane == 2 ? rot->
hsub : 0;
537 int vsub = plane == 1 || plane == 2 ? rot->
vsub : 0;
543 .outh = outh, .outw = outw,
544 .xi = -(outw-1) *
c / 2, .yi = (outw-1) *
s / 2,
545 .xprime = -(outh-1) *
s / 2,
546 .yprime = -(outh-1) *
c / 2,
547 .plane = plane, .c =
c, .s =
s };
558 char *res,
int res_len,
int flags)
563 if (!strcmp(cmd,
"angle") || !strcmp(cmd,
"a")) {
569 "Error when parsing the expression '%s' for angle command\n", args);
599 .p.priv_class = &rotate_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
const FFFilter ff_vf_rotate
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
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 flags(name, subs,...)
#define i(width, name, range_min, range_max)
#define xi(width, name, var, range_min, range_max, subs,...)
#define AV_CEIL_RSHIFT(a, b)
static __device__ float fabs(float a)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4])
Prepare a color.
void ff_fill_rectangle(FFDrawContext *draw, FFDrawColor *color, uint8_t *dst[], int dst_linesize[], int dst_x, int dst_y, int w, int h)
Fill a rectangle with an uniform color.
int ff_draw_init_from_link(FFDrawContext *draw, const AVFilterLink *link, unsigned flags)
Init a draw context, taking the format, colorspace and range from the given filter link.
int(* init)(AVBSFContext *ctx)
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
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.
int av_expr_parse(AVExpr **expr, const char *s, const char *const *const_names, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), int log_offset, void *log_ctx)
Parse an expression.
simple arithmetic expression evaluator
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
@ 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...
#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.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#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 const char *const var_names[]
int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen, void *log_ctx)
Put the RGBA values that correspond to color_string in rgba_color.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
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_YUVA444P9LE
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), little-endian
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
@ AV_PIX_FMT_YUVA444P10LE
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
@ AV_PIX_FMT_YUV420P9LE
planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_YUVA420P10LE
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
@ 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_YUV420P10LE
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
@ 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_YUVA420P9LE
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), little-endian
@ 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_YUV444P9LE
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
@ AV_PIX_FMT_YUVA444P16LE
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
@ AV_PIX_FMT_YUVA420P16LE
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
@ AV_PIX_FMT_YUV420P12LE
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
@ AV_PIX_FMT_YUV444P16LE
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
@ 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_YUV444P10LE
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
@ AV_PIX_FMT_YUV420P16LE
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
@ AV_PIX_FMT_YUV444P12LE
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
static int config_props(AVBitStreamFilterLink *link)
Describe the class of an AVClass context structure.
int depth
Number of bits in the component.
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.
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...
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
int pixelstep[MAX_PLANES]
Link properties exposed to filter code, but not external callers.
double var_values[VAR_VARS_NB]
char * angle_expr_str
expression for the angle
uint8_t *(* interpolate_bilinear)(uint8_t *dst_color, const uint8_t *src, int src_linesize, int src_linestep, int x, int y, int max_x, int max_y)
uint8_t fillcolor[4]
color expressed either in YUVA or RGBA colorspace for the padding area
AVExpr * angle_expr
parsed expression for the angle
Used for passing data between threads.
static AVFormatContext * ctx
static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
#define SET_SIZE_EXPR(name, opt_name)
static int config_props(AVFilterLink *outlink)
static const AVFilterPad rotate_inputs[]
static double(*const func1[])(void *, double)
static uint8_t * interpolate_bilinear16(uint8_t *dst_color, const uint8_t *src, int src_linesize, int src_linestep, int x, int y, int max_x, int max_y)
Interpolate the color in src at position x and y using bilinear interpolation.
static double get_rotated_w(void *opaque, double angle)
static double get_rotated_h(void *opaque, double angle)
static uint8_t * interpolate_bilinear8(uint8_t *dst_color, const uint8_t *src, int src_linesize, int src_linestep, int x, int y, int max_x, int max_y)
Interpolate the color in src at position x and y using bilinear interpolation.
static int64_t int_sin(int64_t a)
Compute the sin of a using integer values.
static const AVFilterPad rotate_outputs[]
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static av_always_inline void simple_rotate(uint8_t *dst, const uint8_t *src, int src_linesize, int angle, int elem_size, int len)
static av_always_inline void simple_rotate_internal(uint8_t *dst, const uint8_t *src, int src_linesize, int angle, int elem_size, int len)
static av_always_inline void copy_elem(uint8_t *pout, const uint8_t *pin, int elem_size)
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
static const AVOption rotate_options[]
static av_cold void uninit(AVFilterContext *ctx)
static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
static const char *const func1_names[]
static void rotate(const float rot_quaternion[2][4], float *vec)
Rotate vector with given rotation quaternion.
static double a2(void *priv, double x, double y)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.