2 * Copyright (c) 2014 Vittorio Giovara <vittorio.giovara@gmail.com>
4 * This file is part of Libav.
6 * Libav is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * Libav is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with Libav; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 #ifndef AVUTIL_DISPLAY_H
27 #define AVUTIL_DISPLAY_H
32 * @addtogroup lavu_video
35 * @defgroup lavu_video_display Display transformation matrix functions
40 * @addtogroup lavu_video_display
41 * The display transformation matrix specifies an affine transformation that
42 * should be applied to video frames for correct presentation. It is compatible
43 * with the matrices stored in the ISO/IEC 14496-12 container format.
45 * The data is a 3x3 matrix represented as a 9-element array:
49 * (a, b, u, c, d, v, x, y, w) -> | c d v |
53 * All numbers are stored in native endianness, as 16.16 fixed-point values,
54 * except for u, v and w, which are stored as 2.30 fixed-point values.
56 * The transformation maps a point (p, q) in the source (pre-transformation)
57 * frame to the point (p', q') in the destination (post-transformation) frame as
62 * (p, q, 1) . | c d v | = z * (p', q', 1)
66 * The transformation can also be more explicitly written in components as
70 * p' = (a * p + c * q + x) / z;
71 * q' = (b * p + d * q + y) / z;
72 * z = u * p + v * q + w
77 * Extract the rotation component of the transformation matrix.
79 * @param matrix the transformation matrix
80 * @return the angle (in degrees) by which the transformation rotates the frame
81 * counterclockwise. The angle will be in range [-180.0, 180.0],
82 * or NaN if the matrix is singular.
84 * @note floating point numbers are inherently inexact, so callers are
85 * recommended to round the return value to nearest integer before use.
87 double av_display_rotation_get(const int32_t matrix[9]);
90 * Initialize a transformation matrix describing a pure counterclockwise
91 * rotation by the specified angle (in degrees).
93 * @param matrix an allocated transformation matrix (will be fully overwritten
95 * @param angle rotation angle in degrees.
97 void av_display_rotation_set(int32_t matrix[9], double angle);
100 * Flip the input matrix horizontally and/or vertically.
102 * @param matrix an allocated transformation matrix
103 * @param hflip whether the matrix should be flipped horizontally
104 * @param vflip whether the matrix should be flipped vertically
106 void av_display_matrix_flip(int32_t matrix[9], int hflip, int vflip);
113 #endif /* AVUTIL_DISPLAY_H */