1 /* 2 * Copyright (c) 2014 Vittorio Giovara <vittorio.giovara@gmail.com> 3 * 4 * This file is part of FFmpeg. 5 * 6 * FFmpeg 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. 10 * 11 * FFmpeg 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. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with FFmpeg; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 21 /** 22 * @file 23 * Display matrix 24 */ 25 module ffmpeg.libavutil.display; 26 extern (C) @nogc nothrow: 27 28 /** 29 * @addtogroup lavu_video 30 * @{ 31 * 32 * @defgroup lavu_video_display Display transformation matrix functions 33 * @{ 34 */ 35 36 /** 37 * @addtogroup lavu_video_display 38 * The display transformation matrix specifies an affine transformation that 39 * should be applied to video frames for correct presentation. It is compatible 40 * with the matrices stored in the ISO/IEC 14496-12 container format. 41 * 42 * The data is a 3x3 matrix represented as a 9-element array: 43 * 44 * @code{.unparsed} 45 * | a b u | 46 * (a, b, u, c, d, v, x, y, w) -> | c d v | 47 * | x y w | 48 * @endcode 49 * 50 * All numbers are stored in native endianness, as 16.16 fixed-point values, 51 * except for u, v and w, which are stored as 2.30 fixed-point values. 52 * 53 * The transformation maps a point (p, q) in the source (pre-transformation) 54 * frame to the point (p', q') in the destination (post-transformation) frame as 55 * follows: 56 * 57 * @code{.unparsed} 58 * | a b u | 59 * (p, q, 1) . | c d v | = z * (p', q', 1) 60 * | x y w | 61 * @endcode 62 * 63 * The transformation can also be more explicitly written in components as 64 * follows: 65 * 66 * @code{.unparsed} 67 * p' = (a * p + c * q + x) / z; 68 * q' = (b * p + d * q + y) / z; 69 * z = u * p + v * q + w 70 * @endcode 71 */ 72 73 /** 74 * Extract the rotation component of the transformation matrix. 75 * 76 * @param matrix the transformation matrix 77 * @return the angle (in degrees) by which the transformation rotates the frame 78 * counterclockwise. The angle will be in range [-180.0, 180.0], 79 * or NaN if the matrix is singular. 80 * 81 * @note floating point numbers are inherently inexact, so callers are 82 * recommended to round the return value to nearest integer before use. 83 */ 84 double av_display_rotation_get (ref const(int)[9] matrix); 85 86 /** 87 * Initialize a transformation matrix describing a pure counterclockwise 88 * rotation by the specified angle (in degrees). 89 * 90 * @param matrix an allocated transformation matrix (will be fully overwritten 91 * by this function) 92 * @param angle rotation angle in degrees. 93 */ 94 void av_display_rotation_set (ref int[9] matrix, double angle); 95 96 /** 97 * Flip the input matrix horizontally and/or vertically. 98 * 99 * @param matrix an allocated transformation matrix 100 * @param hflip whether the matrix should be flipped horizontally 101 * @param vflip whether the matrix should be flipped vertically 102 */ 103 void av_display_matrix_flip (ref int[9] matrix, int hflip, int vflip); 104 105 /** 106 * @} 107 * @} 108 */ 109 110 /* AVUTIL_DISPLAY_H */