author | unc0rr |
Fri, 30 Mar 2018 20:42:24 +0200 | |
changeset 13311 | 806347b3c978 |
parent 7813 | 7ac83d79b897 |
permissions | -rw-r--r-- |
7813
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
1 |
/* |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
2 |
* This file is part of Libav. |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
3 |
* |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
4 |
* Libav is free software; you can redistribute it and/or |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
5 |
* modify it under the terms of the GNU Lesser General Public |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
6 |
* License as published by the Free Software Foundation; either |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
7 |
* version 2.1 of the License, or (at your option) any later version. |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
8 |
* |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
9 |
* Libav is distributed in the hope that it will be useful, |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
12 |
* Lesser General Public License for more details. |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
13 |
* |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU Lesser General Public |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
15 |
* License along with Libav; if not, write to the Free Software |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
17 |
*/ |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
18 |
|
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
19 |
#ifndef AVUTIL_IMGUTILS_H |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
20 |
#define AVUTIL_IMGUTILS_H |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
21 |
|
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
22 |
/** |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
23 |
* @file |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
24 |
* misc image utilities |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
25 |
* |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
26 |
* @addtogroup lavu_picture |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
27 |
* @{ |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
28 |
*/ |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
29 |
|
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
30 |
#include "avutil.h" |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
31 |
#include "pixdesc.h" |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
32 |
|
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
33 |
/** |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
34 |
* Compute the max pixel step for each plane of an image with a |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
35 |
* format described by pixdesc. |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
36 |
* |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
37 |
* The pixel step is the distance in bytes between the first byte of |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
38 |
* the group of bytes which describe a pixel component and the first |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
39 |
* byte of the successive group in the same plane for the same |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
40 |
* component. |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
41 |
* |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
42 |
* @param max_pixsteps an array which is filled with the max pixel step |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
43 |
* for each plane. Since a plane may contain different pixel |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
44 |
* components, the computed max_pixsteps[plane] is relative to the |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
45 |
* component in the plane with the max pixel step. |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
46 |
* @param max_pixstep_comps an array which is filled with the component |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
47 |
* for each plane which has the max pixel step. May be NULL. |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
48 |
*/ |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
49 |
void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
50 |
const AVPixFmtDescriptor *pixdesc); |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
51 |
|
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
52 |
/** |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
53 |
* Compute the size of an image line with format pix_fmt and width |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
54 |
* width for the plane plane. |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
55 |
* |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
56 |
* @return the computed size in bytes |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
57 |
*/ |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
58 |
int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane); |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
59 |
|
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
60 |
/** |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
61 |
* Fill plane linesizes for an image with pixel format pix_fmt and |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
62 |
* width width. |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
63 |
* |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
64 |
* @param linesizes array to be filled with the linesize for each plane |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
65 |
* @return >= 0 in case of success, a negative error code otherwise |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
66 |
*/ |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
67 |
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width); |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
68 |
|
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
69 |
/** |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
70 |
* Fill plane data pointers for an image with pixel format pix_fmt and |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
71 |
* height height. |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
72 |
* |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
73 |
* @param data pointers array to be filled with the pointer for each image plane |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
74 |
* @param ptr the pointer to a buffer which will contain the image |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
75 |
* @param linesizes the array containing the linesize for each |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
76 |
* plane, should be filled by av_image_fill_linesizes() |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
77 |
* @return the size in bytes required for the image buffer, a negative |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
78 |
* error code in case of failure |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
79 |
*/ |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
80 |
int av_image_fill_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt, int height, |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
81 |
uint8_t *ptr, const int linesizes[4]); |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
82 |
|
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
83 |
/** |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
84 |
* Allocate an image with size w and h and pixel format pix_fmt, and |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
85 |
* fill pointers and linesizes accordingly. |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
86 |
* The allocated image buffer has to be freed by using |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
87 |
* av_freep(&pointers[0]). |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
88 |
* |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
89 |
* @param align the value to use for buffer size alignment |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
90 |
* @return the size in bytes required for the image buffer, a negative |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
91 |
* error code in case of failure |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
92 |
*/ |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
93 |
int av_image_alloc(uint8_t *pointers[4], int linesizes[4], |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
94 |
int w, int h, enum AVPixelFormat pix_fmt, int align); |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
95 |
|
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
96 |
/** |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
97 |
* Copy image plane from src to dst. |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
98 |
* That is, copy "height" number of lines of "bytewidth" bytes each. |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
99 |
* The first byte of each successive line is separated by *_linesize |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
100 |
* bytes. |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
101 |
* |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
102 |
* @param dst_linesize linesize for the image plane in dst |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
103 |
* @param src_linesize linesize for the image plane in src |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
104 |
*/ |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
105 |
void av_image_copy_plane(uint8_t *dst, int dst_linesize, |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
106 |
const uint8_t *src, int src_linesize, |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
107 |
int bytewidth, int height); |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
108 |
|
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
109 |
/** |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
110 |
* Copy image in src_data to dst_data. |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
111 |
* |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
112 |
* @param dst_linesizes linesizes for the image in dst_data |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
113 |
* @param src_linesizes linesizes for the image in src_data |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
114 |
*/ |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
115 |
void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
116 |
const uint8_t *src_data[4], const int src_linesizes[4], |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
117 |
enum AVPixelFormat pix_fmt, int width, int height); |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
118 |
|
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
119 |
/** |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
120 |
* Check if the given dimension of an image is valid, meaning that all |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
121 |
* bytes of the image can be addressed with a signed int. |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
122 |
* |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
123 |
* @param w the width of the picture |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
124 |
* @param h the height of the picture |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
125 |
* @param log_offset the offset to sum to the log level for logging with log_ctx |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
126 |
* @param log_ctx the parent logging context, it may be NULL |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
127 |
* @return >= 0 if valid, a negative error code otherwise |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
128 |
*/ |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
129 |
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx); |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
130 |
|
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
131 |
int avpriv_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt); |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
132 |
|
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
133 |
/** |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
134 |
* @} |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
135 |
*/ |
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
136 |
|
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
137 |
|
7ac83d79b897
support video recording on windows with automation and headers
koda
parents:
diff
changeset
|
138 |
#endif /* AVUTIL_IMGUTILS_H */ |