FFmpeg
libavutil
display.h
Go to the documentation of this file.
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
26
#ifndef AVUTIL_DISPLAY_H
27
#define AVUTIL_DISPLAY_H
28
29
#include <stdint.h>
30
#include "
common.h
"
31
32
/**
33
* @addtogroup lavu_video
34
* @{
35
*
36
* @defgroup lavu_video_display Display transformation matrix functions
37
* @{
38
*/
39
40
/**
41
* @addtogroup lavu_video_display
42
* The display transformation matrix specifies an affine transformation that
43
* should be applied to video frames for correct presentation. It is compatible
44
* with the matrices stored in the ISO/IEC 14496-12 container format.
45
*
46
* The data is a 3x3 matrix represented as a 9-element array:
47
*
48
* @code{.unparsed}
49
* | a b u |
50
* (a, b, u, c, d, v, x, y, w) -> | c d v |
51
* | x y w |
52
* @endcode
53
*
54
* All numbers are stored in native endianness, as 16.16 fixed-point values,
55
* except for u, v and w, which are stored as 2.30 fixed-point values.
56
*
57
* The transformation maps a point (p, q) in the source (pre-transformation)
58
* frame to the point (p', q') in the destination (post-transformation) frame as
59
* follows:
60
*
61
* @code{.unparsed}
62
* | a b u |
63
* (p, q, 1) . | c d v | = z * (p', q', 1)
64
* | x y w |
65
* @endcode
66
*
67
* The transformation can also be more explicitly written in components as
68
* follows:
69
*
70
* @code{.unparsed}
71
* p' = (a * p + c * q + x) / z;
72
* q' = (b * p + d * q + y) / z;
73
* z = u * p + v * q + w
74
* @endcode
75
*/
76
77
/**
78
* Extract the rotation component of the transformation matrix.
79
*
80
* @param matrix the transformation matrix
81
* @return the angle (in degrees) by which the transformation rotates the frame
82
* counterclockwise. The angle will be in range [-180.0, 180.0],
83
* or NaN if the matrix is singular.
84
*
85
* @note floating point numbers are inherently inexact, so callers are
86
* recommended to round the return value to nearest integer before use.
87
*/
88
double
av_display_rotation_get
(
const
int32_t
matrix[9]);
89
90
/**
91
* Initialize a transformation matrix describing a pure clockwise
92
* rotation by the specified angle (in degrees).
93
*
94
* @param matrix an allocated transformation matrix (will be fully overwritten
95
* by this function)
96
* @param angle rotation angle in degrees.
97
*/
98
void
av_display_rotation_set
(
int32_t
matrix[9],
double
angle);
99
100
/**
101
* Flip the input matrix horizontally and/or vertically.
102
*
103
* @param matrix an allocated transformation matrix
104
* @param hflip whether the matrix should be flipped horizontally
105
* @param vflip whether the matrix should be flipped vertically
106
*/
107
void
av_display_matrix_flip
(
int32_t
matrix[9],
int
hflip,
int
vflip);
108
109
/**
110
* @}
111
* @}
112
*/
113
114
#endif
/* AVUTIL_DISPLAY_H */
av_display_matrix_flip
void av_display_matrix_flip(int32_t matrix[9], int hflip, int vflip)
Flip the input matrix horizontally and/or vertically.
Definition:
display.c:65
av_display_rotation_set
void av_display_rotation_set(int32_t matrix[9], double angle)
Initialize a transformation matrix describing a pure clockwise rotation by the specified angle (in de...
Definition:
display.c:50
common.h
int32_t
int32_t
Definition:
audioconvert.c:56
av_display_rotation_get
double av_display_rotation_get(const int32_t matrix[9])
Extract the rotation component of the transformation matrix.
Definition:
display.c:34
Generated on Wed Aug 24 2022 21:38:29 for FFmpeg by
1.8.17