]> git.sesse.net Git - ffmpeg/commitdiff
mov: Write the display matrix in order
authorVittorio Giovara <vittorio.giovara@gmail.com>
Tue, 17 Mar 2015 17:38:48 +0000 (17:38 +0000)
committerVittorio Giovara <vittorio.giovara@gmail.com>
Mon, 23 Mar 2015 20:53:28 +0000 (20:53 +0000)
This will allow to copy the matrix as is and it is just cleaner to keep
the matrix in the same order specified by the mov standard (which is
also explicitly described in the documentation).

In order to preserve compatibility, flip the angle sign in the display API
av_display_rotation_set() and av_display_rotation_get(), and improve the
documentation mentioning the rotation direction.

libavformat/mov.c
libavutil/display.c
libavutil/display.h
libavutil/version.h

index 76ce9ee21759450d26c89358d7276106073fa62e..ef58492217400a84a78b5c54c535e3741307ac08 100644 (file)
@@ -2606,7 +2606,7 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 
         for (i = 0; i < 3; i++)
             for (j = 0; j < 3; j++)
-                sc->display_matrix[i * 3 + j] = display_matrix[j][i];
+                sc->display_matrix[i * 3 + j] = display_matrix[i][j];
     }
 
     // transform the display width/height according to the matrix
index 74aceb28472b3bddd6cfaccc613a73fa2a90454a..f7500948ff1ba8324f38482fc448b1bd91249b0d 100644 (file)
@@ -46,12 +46,12 @@ double av_display_rotation_get(const int32_t matrix[9])
     rotation = atan2(CONV_FP(matrix[1]) / scale[1],
                      CONV_FP(matrix[0]) / scale[0]) * 180 / M_PI;
 
-    return rotation;
+    return -rotation;
 }
 
 void av_display_rotation_set(int32_t matrix[9], double angle)
 {
-    double radians = angle * M_PI / 180.0f;
+    double radians = -angle * M_PI / 180.0f;
     double c = cos(radians);
     double s = sin(radians);
 
index 7e376276375e1efb9f9b3b4b6a6de8e72514b0fb..dba3b1e60d1f51f7079575189c60f5ce39df3e5e 100644 (file)
@@ -55,9 +55,9 @@
  * Extract the rotation component of the transformation matrix.
  *
  * @param matrix the transformation matrix
- * @return the angle (in degrees) by which the transformation rotates the frame.
- *         The angle will be in range [-180.0, 180.0], or NaN if the matrix is
- *         singular.
+ * @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.
@@ -65,8 +65,8 @@
 double av_display_rotation_get(const int32_t matrix[9]);
 
 /**
- * Initialize a transformation matrix describing a pure rotation by the
- * specified angle (in degrees).
+ * Initialize a transformation matrix describing a pure counterclockwise
+ * rotation by the specified angle (in degrees).
  *
  * @param matrix an allocated transformation matrix (will be fully overwritten
  *               by this function)
index 77595a8e54daa0ac9fe9e5f8149267f51ea0fd5c..c1a302966e994ef622f7e15091600697571fd5b9 100644 (file)
@@ -55,7 +55,7 @@
 
 #define LIBAVUTIL_VERSION_MAJOR 54
 #define LIBAVUTIL_VERSION_MINOR  9
-#define LIBAVUTIL_VERSION_MICRO  0
+#define LIBAVUTIL_VERSION_MICRO  1
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
                                                LIBAVUTIL_VERSION_MINOR, \