80 #define OFFSET(x) offsetof(RotContext, x)
81 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
121 static enum PixelFormat pix_fmts[] = {
145 float sinx = sin(angle);
146 float cosx = cos(angle);
148 return FFMAX(0, inh * sinx) +
FFMAX(0, -inw * cosx) +
157 float sinx = sin(angle);
158 float cosx = cos(angle);
160 return FFMAX(0, -inh * cosx) +
FFMAX(0, -inw * sinx) +
164 static double (*
const func1[])(
void *, double) = {
206 "Error occurred parsing angle expression '%s'\n", rot->
angle_expr_str);
210 #define SET_SIZE_EXPR(name, opt_name) do { \
211 ret = av_expr_parse_and_eval(&res, expr = rot->name##_expr_str, \
212 var_names, rot->var_values, \
213 func1_names, func1, NULL, NULL, rot, 0, ctx); \
214 if (ret < 0 || isnan(res) || isinf(res) || res <= 0) { \
215 av_log(ctx, AV_LOG_ERROR, \
216 "Error parsing or evaluating expression for option %s: " \
217 "invalid expression '%s' or non-positive or indefinite value %f\n", \
218 opt_name, expr, res); \
227 rot->
outw = res + 0.5;
230 rot->
outh = res + 0.5;
235 rot->
outw = res + 0.5;
239 outlink->
w = rot->
outw;
240 outlink->
h = rot->
outh;
245 #define INT_PI 205887 //(M_PI * FIXP)
263 for (i = 2; i < 7; i += 2) {
265 a = -a*a2 / (
FIXP*i*(i+1));
275 const uint8_t *
src,
int src_linesize,
int src_linestep,
276 int x,
int y,
int max_x,
int max_y)
278 int int_x = av_clip(x>>16, 0, max_x);
279 int int_y = av_clip(y>>16, 0, max_y);
280 int frac_x = x&0xFFFF;
281 int frac_y = y&0xFFFF;
283 int int_x1 =
FFMIN(int_x+1, max_x);
284 int int_y1 =
FFMIN(int_y+1, max_y);
286 for (i = 0; i < src_linestep; i++) {
287 int s00 = src[src_linestep * int_x + i + src_linesize * int_y ];
288 int s01 = src[src_linestep * int_x1 + i + src_linesize * int_y ];
289 int s10 = src[src_linestep * int_x + i + src_linesize * int_y1];
290 int s11 = src[src_linestep * int_x1 + i + src_linesize * int_y1];
291 int s0 = (((1<<16) - frac_x)*s00 + frac_x*s01);
292 int s1 = (((1<<16) - frac_x)*s10 + frac_x*s11);
294 dst_color[i] = ((int64_t)((1<<16) - frac_y)*s0 + (int64_t)frac_y*
s1) >> 32;
300 #define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)*av_q2d(tb))
308 int angle_int,
s,
c, plane;
325 angle_int = res *
FIXP;
332 0, 0, outlink->
w, outlink->
h);
334 for (plane = 0; plane < rot->
nb_planes; plane++) {
335 int hsub = plane == 1 || plane == 2 ? rot->
hsub : 0;
336 int vsub = plane == 1 || plane == 2 ? rot->
vsub : 0;
342 const int xi = -outw/2 *
c;
343 const int yi = outw/2 *
s;
344 int xprime = -outh/2 *
s;
345 int yprime = -outh/2 *
c;
348 for (j = 0; j < outh; j++) {
349 x = xprime + xi + FIXP*inw/2;
350 y = yprime + yi + FIXP*inh/2;
352 for (i = 0; i < outw; i++) {
362 if (x1 >= -1 && x1 <= inw && y1 >= -1 && y1 <= inh) {
370 int x2 = av_clip(x1, 0, inw-1);
371 int y2 = av_clip(y1, 0, inh-1);
379 *((uint16_t *)pout) = *((uint16_t *)pin);
386 *((uint32_t *)pout) = *((uint32_t *)pin);
409 if (!strcmp(cmd,
"angle") || !strcmp(cmd,
"a")) {
412 NULL, NULL, NULL, NULL, 0, ctx);
415 "Error when parsing the expression '%s' for angle command\n", args);
454 .priv_class = &rotate_class,