Unified · Split
| @@ -103,12 +103,19 @@ INTERPOLATE_METHOD(interpolate_biquadratic) · 102 unmodified lines | ||
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | −void avfilter_get_matrix(float x_shift, float y_shift, float angle, float zoom, float *matrix) { | |
| 107 | − matrix[0] = zoom * cos(angle); | |
| 106 | +void ff_get_matrix( | |
| 107 | + float x_shift, | |
| 108 | + float y_shift, | |
| 109 | + float angle, | |
| 110 | + float scale_x, | |
| 111 | + float scale_y, | |
| 112 | + float *matrix | |
| 113 | +) { | |
| 114 | + matrix[0] = scale_x * cos(angle); | |
| 108 | 115 | matrix[1] = -sin(angle); |
| 109 | 116 | matrix[2] = x_shift; |
| 110 | 117 | matrix[3] = -matrix[1]; |
| 111 | − matrix[4] = matrix[0]; | |
| 118 | + matrix[4] = scale_y * cos(angle); | |
| 112 | 119 | matrix[5] = y_shift; |
| 113 | 120 | matrix[6] = 0; |
| 114 | 121 | matrix[7] = 0; |
| @@ -60,20 +60,28 @@ enum FillMethod { · 59 unmodified lines | ||
| 60 | 60 | #define FILL_DEFAULT FILL_ORIGINAL |
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | − * Get an affine transformation matrix from a given translation, rotation, and | |
| 64 | − * zoom factor. The matrix will look like: | |
| 63 | + * Get an affine transformation matrix from given translation, rotation, and | |
| 64 | + * zoom factors. The matrix will look like: | |
| 65 | 65 | * |
| 66 | − * [ zoom * cos(angle), -sin(angle), x_shift, | |
| 67 | − * sin(angle), zoom * cos(angle), y_shift, | |
| 68 | − * 0, 0, 1 ] | |
| 66 | + * [ scale_x * cos(angle), -sin(angle), x_shift, | |
| 67 | + * sin(angle), scale_y * cos(angle), y_shift, | |
| 68 | + * 0, 0, 1 ] | |
| 69 | 69 | * |
| 70 | − * @param x_shift horizontal translation | |
| 71 | − * @param y_shift vertical translation | |
| 72 | − * @param angle rotation in radians | |
| 73 | − * @param zoom scale percent (1.0 = 100%) | |
| 74 | − * @param matrix 9-item affine transformation matrix | |
| 70 | + * @param x_shift horizontal translation | |
| 71 | + * @param y_shift vertical translation | |
| 72 | + * @param angle rotation in radians | |
| 73 | + * @param scale_x x scale percent (1.0 = 100%) | |
| 74 | + * @param scale_y y scale percent (1.0 = 100%) | |
| 75 | + * @param matrix 9-item affine transformation matrix | |
| 75 | 76 | */ |
| 76 | −void avfilter_get_matrix(float x_shift, float y_shift, float angle, float zoom, float *matrix); | |
| 77 | +void ff_get_matrix( | |
| 78 | + float x_shift, | |
| 79 | + float y_shift, | |
| 80 | + float angle, | |
| 81 | + float scale_x, | |
| 82 | + float scale_y, | |
| 83 | + float *matrix | |
| 84 | +); | |
| 77 | 85 | |
| 78 | 86 | /** |
| 79 | 87 | * Add two matrices together. result = m1 + m2. |
| @@ -421,6 +421,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) · 420 unmodified lines | ||
| 421 | 421 | const int chroma_width = AV_CEIL_RSHIFT(link->w, desc->log2_chroma_w); |
| 422 | 422 | const int chroma_height = AV_CEIL_RSHIFT(link->h, desc->log2_chroma_h); |
| 423 | 423 | int aligned; |
| 424 | + float transform_zoom; | |
| 424 | 425 | |
| 425 | 426 | out = ff_get_video_buffer(outlink, outlink->w, outlink->h); |
| 426 | 427 | if (!out) { |
| @@ -505,10 +506,12 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) · 78 unmodified lines | ||
| 505 | 506 | deshake->last.angle = t.angle; |
| 506 | 507 | deshake->last.zoom = t.zoom; |
| 507 | 508 | |
| 509 | + transform_zoom = 1.0 + t.zoom / 100.0; | |
| 510 | + | |
| 508 | 511 | // Generate a luma transformation matrix |
| 509 | − avfilter_get_matrix(t.vec.x, t.vec.y, t.angle, 1.0 + t.zoom / 100.0, matrix_y); | |
| 512 | + ff_get_matrix(t.vec.x, t.vec.y, t.angle, transform_zoom, transform_zoom, matrix_y); | |
| 510 | 513 | // Generate a chroma transformation matrix |
| 511 | − avfilter_get_matrix(t.vec.x / (link->w / chroma_width), t.vec.y / (link->h / chroma_height), t.angle, 1.0 + t.zoom / 100.0, matrix_uv); | |
| 514 | + ff_get_matrix(t.vec.x / (link->w / chroma_width), t.vec.y / (link->h / chroma_height), t.angle, transform_zoom, transform_zoom, matrix_uv); | |
| 512 | 515 | // Transform the luma and chroma planes |
| 513 | 516 | ret = deshake->transform(link->dst, link->w, link->h, chroma_width, chroma_height, |
| 514 | 517 | matrix_y, matrix_uv, INTERPOLATE_BILINEAR, deshake->edge, in, out); |