summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarek Samic <cldfire3@gmail.com>2019-08-08 09:24:31 -0400
committerMark Thompson <sw@jkqxz.net>2019-08-22 23:11:27 +0100
commit5b5746b1e0d2cfef307e3f7c8edec5876eca53dc (patch)
tree4ff56171e4ca91eb5feda34dc4619d9f0247ab8d
parentd3cd33ab1b23fb459e25ae92a0cd7fbfe7c1c169 (diff)
lavfi: modify avfilter_get_matrix to support separate scale factors
-rw-r--r--libavfilter/transform.c13
-rw-r--r--libavfilter/transform.h30
-rw-r--r--libavfilter/vf_deshake.c7
3 files changed, 34 insertions, 16 deletions
diff --git a/libavfilter/transform.c b/libavfilter/transform.c
index f92fc4d42f..f4f9e0a47d 100644
--- a/libavfilter/transform.c
+++ b/libavfilter/transform.c
@@ -103,12 +103,19 @@ INTERPOLATE_METHOD(interpolate_biquadratic)
}
}
-void avfilter_get_matrix(float x_shift, float y_shift, float angle, float zoom, float *matrix) {
- matrix[0] = zoom * cos(angle);
+void ff_get_matrix(
+ float x_shift,
+ float y_shift,
+ float angle,
+ float scale_x,
+ float scale_y,
+ float *matrix
+) {
+ matrix[0] = scale_x * cos(angle);
matrix[1] = -sin(angle);
matrix[2] = x_shift;
matrix[3] = -matrix[1];
- matrix[4] = matrix[0];
+ matrix[4] = scale_y * cos(angle);
matrix[5] = y_shift;
matrix[6] = 0;
matrix[7] = 0;
diff --git a/libavfilter/transform.h b/libavfilter/transform.h
index 07436bfccb..9b0c19ceca 100644
--- a/libavfilter/transform.h
+++ b/libavfilter/transform.h
@@ -60,20 +60,28 @@ enum FillMethod {
#define FILL_DEFAULT FILL_ORIGINAL
/**
- * Get an affine transformation matrix from a given translation, rotation, and
- * zoom factor. The matrix will look like:
+ * Get an affine transformation matrix from given translation, rotation, and
+ * zoom factors. The matrix will look like:
*
- * [ zoom * cos(angle), -sin(angle), x_shift,
- * sin(angle), zoom * cos(angle), y_shift,
- * 0, 0, 1 ]
+ * [ scale_x * cos(angle), -sin(angle), x_shift,
+ * sin(angle), scale_y * cos(angle), y_shift,
+ * 0, 0, 1 ]
*
- * @param x_shift horizontal translation
- * @param y_shift vertical translation
- * @param angle rotation in radians
- * @param zoom scale percent (1.0 = 100%)
- * @param matrix 9-item affine transformation matrix
+ * @param x_shift horizontal translation
+ * @param y_shift vertical translation
+ * @param angle rotation in radians
+ * @param scale_x x scale percent (1.0 = 100%)
+ * @param scale_y y scale percent (1.0 = 100%)
+ * @param matrix 9-item affine transformation matrix
*/
-void avfilter_get_matrix(float x_shift, float y_shift, float angle, float zoom, float *matrix);
+void ff_get_matrix(
+ float x_shift,
+ float y_shift,
+ float angle,
+ float scale_x,
+ float scale_y,
+ float *matrix
+);
/**
* Add two matrices together. result = m1 + m2.
diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c
index c8480e74dd..b516ea2d59 100644
--- a/libavfilter/vf_deshake.c
+++ b/libavfilter/vf_deshake.c
@@ -421,6 +421,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
const int chroma_width = AV_CEIL_RSHIFT(link->w, desc->log2_chroma_w);
const int chroma_height = AV_CEIL_RSHIFT(link->h, desc->log2_chroma_h);
int aligned;
+ float transform_zoom;
out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!out) {
@@ -505,10 +506,12 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
deshake->last.angle = t.angle;
deshake->last.zoom = t.zoom;
+ transform_zoom = 1.0 + t.zoom / 100.0;
+
// Generate a luma transformation matrix
- avfilter_get_matrix(t.vec.x, t.vec.y, t.angle, 1.0 + t.zoom / 100.0, matrix_y);
+ ff_get_matrix(t.vec.x, t.vec.y, t.angle, transform_zoom, transform_zoom, matrix_y);
// Generate a chroma transformation matrix
- 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);
+ 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);
// Transform the luma and chroma planes
ret = deshake->transform(link->dst, link->w, link->h, chroma_width, chroma_height,
matrix_y, matrix_uv, INTERPOLATE_BILINEAR, deshake->edge, in, out);