@@ -15,6 +15,9 @@ libavutil: 2017-10-21
API changes, most recent first:
+2019-05-16 - XXXXXXXXXX - lavu 56.29.100 - display.h
+ Add av_display_rotation_get2
+
2019-05-15 - b79b29ddb1 - lavu 56.28.100 - tx.h
Add av_tx_init(), av_tx_uninit() and related definitions.
@@ -71,3 +71,16 @@ void av_display_matrix_flip(int32_t matrix[9], int hflip, int vflip)
for (i = 0; i < 9; i++)
matrix[i] *= flip[i % 3];
}
+
+double av_display_rotation_get2(const int32_t matrix[9], int *hflip)
+{
+ int32_t m[9];
+ *hflip = 0;
+ memcpy(m, matrix, sizeof(m));
+
+ if ((int64_t)m[0] * m[4] < (int64_t)m[1] * m[3]) {
+ *hflip = 1;
+ av_display_matrix_flip(m, 1, 0);
+ }
+ return av_display_rotation_get(m);
+}
@@ -106,6 +106,20 @@ void av_display_rotation_set(int32_t matrix[9], double angle);
*/
void av_display_matrix_flip(int32_t matrix[9], int hflip, int vflip);
+/**
+ * Extract the rotation component and hflip status of the transformation matrix.
+ *
+ * @param matrix the transformation matrix
+ * @param hflip will be set to 1 if the matrix indicates horizontal flip
+ * @return the angle (in degrees) by which the transformation rotates the frame
+ * counterclockwise. The angle will be in range [-180.0, 180.0],
+ * or NaN if the matrix is singular.
+ *
+ * @note floating point numbers are inherently inexact, so callers are
+ * recommended to round the return value to nearest integer before use.
+ */
+double av_display_rotation_get2(const int32_t matrix[9], int* hflip);
+
/**
* @}
* @}
@@ -35,6 +35,8 @@ static void print_matrix(int32_t matrix[9])
int main(void)
{
int32_t matrix[9];
+ int hflip = 0;
+ double degree;
// Set the matrix to 90 degrees
av_display_rotation_set(matrix, 90);
@@ -56,6 +58,30 @@ int main(void)
print_matrix(matrix);
printf("degrees: %f\n", av_display_rotation_get(matrix));
+ // Set the matrix to 90 degrees
+ av_display_rotation_set(matrix, 90);
+ print_matrix(matrix);
+ degree = av_display_rotation_get2(matrix, &hflip);
+ printf("degrees: %f, hflip: %i\n", degree, hflip);
+
+ // Set the matrix to -45 degrees
+ av_display_rotation_set(matrix, -45);
+ print_matrix(matrix);
+ degree = av_display_rotation_get2(matrix, &hflip);
+ printf("degrees: %f, hflip: %i\n", degree, hflip);
+
+ // flip horizontal
+ av_display_matrix_flip(matrix, 1, 0);
+ print_matrix(matrix);
+ degree = av_display_rotation_get2(matrix, &hflip);
+ printf("degrees: %f, hflip: %i\n", degree, hflip);
+
+ // flip vertical
+ av_display_matrix_flip(matrix, 0, 1);
+ print_matrix(matrix);
+ degree = av_display_rotation_get2(matrix, &hflip);
+ printf("degrees: %f, hflip: %i\n", degree, hflip);
+
return 0;
}
@@ -79,7 +79,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 56
-#define LIBAVUTIL_VERSION_MINOR 28
+#define LIBAVUTIL_VERSION_MINOR 29
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
@@ -14,3 +14,19 @@ degrees: 135.000000
-46340 -46340 0
0 0 1073741824
degrees: -135.000000
+0 65536 0
+-65536 0 0
+0 0 1073741824
+degrees: -90.000000, hflip: 0
+46340 -46340 0
+46340 46340 0
+0 0 1073741824
+degrees: 45.000000, hflip: 0
+-46340 -46340 0
+-46340 46340 0
+0 0 1073741824
+degrees: 45.000000, hflip: 1
+-46340 46340 0
+-46340 -46340 0
+0 0 1073741824
+degrees: -135.000000, hflip: 0