92 #define OFFSET(x) offsetof(RotContext, x)
93 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
157 float sinx = sin(angle);
158 float cosx = cos(angle);
160 return FFMAX(0, inh * sinx) +
FFMAX(0, -inw * cosx) +
169 float sinx = sin(angle);
170 float cosx = cos(angle);
172 return FFMAX(0, -inh * cosx) +
FFMAX(0, -inw * sinx) +
176 static double (*
const func1[])(
void *, double) = {
218 "Error occurred parsing angle expression '%s'\n", rot->
angle_expr_str);
222 #define SET_SIZE_EXPR(name, opt_name) do { \
223 ret = av_expr_parse_and_eval(&res, expr = rot->name##_expr_str, \
224 var_names, rot->var_values, \
225 func1_names, func1, NULL, NULL, rot, 0, ctx); \
226 if (ret < 0 || isnan(res) || isinf(res) || res <= 0) { \
227 av_log(ctx, AV_LOG_ERROR, \
228 "Error parsing or evaluating expression for option %s: " \
229 "invalid expression '%s' or non-positive or indefinite value %f\n", \
230 opt_name, expr, res); \
239 rot->
outw = res + 0.5;
242 rot->
outh = res + 0.5;
247 rot->
outw = res + 0.5;
251 outlink->
w = rot->
outw;
252 outlink->
h = rot->
outh;
257 #define FIXP2 (1<<20)
258 #define INT_PI 3294199 //(M_PI * FIXP2)
276 for (i = 2; i < 11; i += 2) {
278 a = -a*a2 / (
FIXP2*i*(i+1));
288 const uint8_t *
src,
int src_linesize,
int src_linestep,
289 int x,
int y,
int max_x,
int max_y)
291 int int_x = av_clip(x>>16, 0, max_x);
292 int int_y = av_clip(y>>16, 0, max_y);
293 int frac_x = x&0xFFFF;
294 int frac_y = y&0xFFFF;
296 int int_x1 =
FFMIN(int_x+1, max_x);
297 int int_y1 =
FFMIN(int_y+1, max_y);
299 for (i = 0; i < src_linestep; i++) {
300 int s00 = src[src_linestep * int_x + i + src_linesize * int_y ];
301 int s01 = src[src_linestep * int_x1 + i + src_linesize * int_y ];
302 int s10 = src[src_linestep * int_x + i + src_linesize * int_y1];
303 int s11 = src[src_linestep * int_x1 + i + src_linesize * int_y1];
304 int s0 = (((1<<16) - frac_x)*s00 + frac_x*s01);
305 int s1 = (((1<<16) - frac_x)*s10 + frac_x*s11);
307 dst_color[i] = ((int64_t)((1<<16) - frac_y)*s0 + (int64_t)frac_y*
s1) >> 32;
321 *((uint16_t *)pout) = *((uint16_t *)pin);
328 *((uint32_t *)pout) = *((uint32_t *)pin);
331 memcpy(pout, pin, elem_size);
341 memcpy(dst, src, elem_size * len);
344 for (i = 0; i<
len; i++)
345 copy_elem(dst + i*elem_size, src + (len-i-1)*src_linesize, elem_size);
348 for (i = 0; i<
len; i++)
349 copy_elem(dst + i*elem_size, src + (len-i-1)*elem_size, elem_size);
352 for (i = 0; i<
len; i++)
353 copy_elem(dst + i*elem_size, src + i*src_linesize, elem_size);
369 #define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)*av_q2d(tb))
377 const int outw = td->
outw, outh = td->
outh;
378 const int inw = td->
inw, inh = td->
inh;
379 const int plane = td->
plane;
380 const int xi = td->
xi, yi = td->
yi;
381 const int c = td->
c,
s = td->
s;
382 const int start = (outh * job ) / nb_jobs;
383 const int end = (outh * (job+1)) / nb_jobs;
384 int xprime = td->
xprime + start *
s;
385 int yprime = td->
yprime + start *
c;
388 for (j = start; j <
end; j++) {
389 x = xprime + xi +
FIXP*(inw-1)/2;
390 y = yprime + yi +
FIXP*(inh-1)/2;
392 if (fabs(rot->
angle - 0) < FLT_EPSILON && outw == inw && outh == inh) {
396 }
else if (fabs(rot->
angle -
M_PI/2) < FLT_EPSILON && outw == inh && outh == inw) {
400 }
else if (fabs(rot->
angle -
M_PI) < FLT_EPSILON && outw == inw && outh == inh) {
404 }
else if (fabs(rot->
angle - 3*
M_PI/2) < FLT_EPSILON && outw == inh && outh == inw) {
410 for (i = 0; i < outw; i++) {
418 if (x1 >= -1 && x1 <= inw && y1 >= -1 && y1 <= inh) {
426 int x2 = av_clip(x1, 0, inw-1);
427 int y2 = av_clip(y1, 0, inh-1);
435 *((uint16_t *)pout) = *((uint16_t *)pin);
442 *((uint32_t *)pout) = *((uint32_t *)pin);
466 int angle_int,
s,
c, plane;
483 angle_int = res *
FIXP * 16;
490 0, 0, outlink->
w, outlink->
h);
492 for (plane = 0; plane < rot->
nb_planes; plane++) {
493 int hsub = plane == 1 || plane == 2 ? rot->
hsub : 0;
494 int vsub = plane == 1 || plane == 2 ? rot->
vsub : 0;
500 .outh = outh, .outw = outw,
501 .xi = -(outw-1) * c / 2, .yi = (outw-1) * s / 2,
502 .xprime = -(outh-1) * s / 2,
503 .yprime = -(outh-1) * c / 2,
504 .plane = plane, .c =
c, .s = s };
515 char *res,
int res_len,
int flags)
520 if (!strcmp(cmd,
"angle") || !strcmp(cmd,
"a")) {
523 NULL, NULL, NULL, NULL, 0, ctx);
526 "Error when parsing the expression '%s' for angle command\n", args);
565 .priv_class = &rotate_class,