FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
imgutils.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 /**
20  * @file
21  * misc image utilities
22  */
23 
24 #include "avassert.h"
25 #include "common.h"
26 #include "imgutils.h"
27 #include "imgutils_internal.h"
28 #include "internal.h"
29 #include "intreadwrite.h"
30 #include "log.h"
31 #include "mathematics.h"
32 #include "pixdesc.h"
33 #include "rational.h"
34 
35 void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
36  const AVPixFmtDescriptor *pixdesc)
37 {
38  int i;
39  memset(max_pixsteps, 0, 4*sizeof(max_pixsteps[0]));
40  if (max_pixstep_comps)
41  memset(max_pixstep_comps, 0, 4*sizeof(max_pixstep_comps[0]));
42 
43  for (i = 0; i < 4; i++) {
44  const AVComponentDescriptor *comp = &(pixdesc->comp[i]);
45  if (comp->step > max_pixsteps[comp->plane]) {
46  max_pixsteps[comp->plane] = comp->step;
47  if (max_pixstep_comps)
48  max_pixstep_comps[comp->plane] = i;
49  }
50  }
51 }
52 
53 static inline
55  int max_step, int max_step_comp,
56  const AVPixFmtDescriptor *desc)
57 {
58  int s, shifted_w, linesize;
59 
60  if (!desc)
61  return AVERROR(EINVAL);
62 
63  if (width < 0)
64  return AVERROR(EINVAL);
65  s = (max_step_comp == 1 || max_step_comp == 2) ? desc->log2_chroma_w : 0;
66  shifted_w = ((width + (1 << s) - 1)) >> s;
67  if (shifted_w && max_step > INT_MAX / shifted_w)
68  return AVERROR(EINVAL);
69  linesize = max_step * shifted_w;
70 
71  if (desc->flags & AV_PIX_FMT_FLAG_BITSTREAM)
72  linesize = (linesize + 7) >> 3;
73  return linesize;
74 }
75 
77 {
79  int max_step [4]; /* max pixel step for each plane */
80  int max_step_comp[4]; /* the component for each plane which has the max pixel step */
81 
82  if (!desc || desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
83  return AVERROR(EINVAL);
84 
85  av_image_fill_max_pixsteps(max_step, max_step_comp, desc);
86  return image_get_linesize(width, plane, max_step[plane], max_step_comp[plane], desc);
87 }
88 
89 int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
90 {
91  int i, ret;
93  int max_step [4]; /* max pixel step for each plane */
94  int max_step_comp[4]; /* the component for each plane which has the max pixel step */
95 
96  memset(linesizes, 0, 4*sizeof(linesizes[0]));
97 
98  if (!desc || desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
99  return AVERROR(EINVAL);
100 
101  av_image_fill_max_pixsteps(max_step, max_step_comp, desc);
102  for (i = 0; i < 4; i++) {
103  if ((ret = image_get_linesize(width, i, max_step[i], max_step_comp[i], desc)) < 0)
104  return ret;
105  linesizes[i] = ret;
106  }
107 
108  return 0;
109 }
110 
112  uint8_t *ptr, const int linesizes[4])
113 {
114  int i, total_size, size[4] = { 0 }, has_plane[4] = { 0 };
115 
116  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
117  memset(data , 0, sizeof(data[0])*4);
118 
119  if (!desc || desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
120  return AVERROR(EINVAL);
121 
122  data[0] = ptr;
123  if (linesizes[0] > (INT_MAX - 1024) / height)
124  return AVERROR(EINVAL);
125  size[0] = linesizes[0] * height;
126 
127  if (desc->flags & AV_PIX_FMT_FLAG_PAL ||
129  data[1] = ptr + size[0]; /* palette is stored here as 256 32 bits words */
130  return size[0] + 256 * 4;
131  }
132 
133  for (i = 0; i < 4; i++)
134  has_plane[desc->comp[i].plane] = 1;
135 
136  total_size = size[0];
137  for (i = 1; i < 4 && has_plane[i]; i++) {
138  int h, s = (i == 1 || i == 2) ? desc->log2_chroma_h : 0;
139  data[i] = data[i-1] + size[i-1];
140  h = (height + (1 << s) - 1) >> s;
141  if (linesizes[i] > INT_MAX / h)
142  return AVERROR(EINVAL);
143  size[i] = h * linesizes[i];
144  if (total_size > INT_MAX - size[i])
145  return AVERROR(EINVAL);
146  total_size += size[i];
147  }
148 
149  return total_size;
150 }
151 
153 {
154  int i;
155 
156  for (i = 0; i < 256; i++) {
157  int r, g, b;
158 
159  switch (pix_fmt) {
160  case AV_PIX_FMT_RGB8:
161  r = (i>>5 )*36;
162  g = ((i>>2)&7)*36;
163  b = (i&3 )*85;
164  break;
165  case AV_PIX_FMT_BGR8:
166  b = (i>>6 )*85;
167  g = ((i>>3)&7)*36;
168  r = (i&7 )*36;
169  break;
171  r = (i>>3 )*255;
172  g = ((i>>1)&3)*85;
173  b = (i&1 )*255;
174  break;
176  b = (i>>3 )*255;
177  g = ((i>>1)&3)*85;
178  r = (i&1 )*255;
179  break;
180  case AV_PIX_FMT_GRAY8:
181  r = b = g = i;
182  break;
183  default:
184  return AVERROR(EINVAL);
185  }
186  pal[i] = b + (g << 8) + (r << 16) + (0xFFU << 24);
187  }
188 
189  return 0;
190 }
191 
192 int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
193  int w, int h, enum AVPixelFormat pix_fmt, int align)
194 {
195  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
196  int i, ret;
197  uint8_t *buf;
198 
199  if (!desc)
200  return AVERROR(EINVAL);
201 
202  if ((ret = av_image_check_size(w, h, 0, NULL)) < 0)
203  return ret;
204  if ((ret = av_image_fill_linesizes(linesizes, pix_fmt, align>7 ? FFALIGN(w, 8) : w)) < 0)
205  return ret;
206 
207  for (i = 0; i < 4; i++)
208  linesizes[i] = FFALIGN(linesizes[i], align);
209 
210  if ((ret = av_image_fill_pointers(pointers, pix_fmt, h, NULL, linesizes)) < 0)
211  return ret;
212  buf = av_malloc(ret + align);
213  if (!buf)
214  return AVERROR(ENOMEM);
215  if ((ret = av_image_fill_pointers(pointers, pix_fmt, h, buf, linesizes)) < 0) {
216  av_free(buf);
217  return ret;
218  }
219  if (desc->flags & AV_PIX_FMT_FLAG_PAL || desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) {
220  avpriv_set_systematic_pal2((uint32_t*)pointers[1], pix_fmt);
221  if (align < 4) {
222  av_log(NULL, AV_LOG_ERROR, "Formats with a palette require a minimum alignment of 4\n");
223  return AVERROR(EINVAL);
224  }
225  }
226 
227  if ((desc->flags & AV_PIX_FMT_FLAG_PAL ||
228  desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) &&
229  pointers[1] - pointers[0] > linesizes[0] * h) {
230  /* zero-initialize the padding before the palette */
231  memset(pointers[0] + linesizes[0] * h, 0,
232  pointers[1] - pointers[0] - linesizes[0] * h);
233  }
234 
235  return ret;
236 }
237 
238 typedef struct ImgUtils {
239  const AVClass *class;
241  void *log_ctx;
242 } ImgUtils;
243 
244 static const AVClass imgutils_class = {
245  .class_name = "IMGUTILS",
246  .item_name = av_default_item_name,
247  .version = LIBAVUTIL_VERSION_INT,
248  .log_level_offset_offset = offsetof(ImgUtils, log_offset),
249  .parent_log_context_offset = offsetof(ImgUtils, log_ctx),
250 };
251 
252 int av_image_check_size2(unsigned int w, unsigned int h, int64_t max_pixels, enum AVPixelFormat pix_fmt, int log_offset, void *log_ctx)
253 {
254  ImgUtils imgutils = {
255  .class = &imgutils_class,
256  .log_offset = log_offset,
257  .log_ctx = log_ctx,
258  };
259  int64_t stride = av_image_get_linesize(pix_fmt, w, 0);
260  if (stride <= 0)
261  stride = 8LL*w;
262  stride += 128*8;
263 
264  if ((int)w<=0 || (int)h<=0 || stride >= INT_MAX || stride*(uint64_t)(h+128) >= INT_MAX) {
265  av_log(&imgutils, AV_LOG_ERROR, "Picture size %ux%u is invalid\n", w, h);
266  return AVERROR(EINVAL);
267  }
268 
269  if (max_pixels < INT64_MAX) {
270  if (w*(int64_t)h > max_pixels) {
271  av_log(&imgutils, AV_LOG_ERROR,
272  "Picture size %ux%u exceeds specified max pixel count %"PRId64", see the documentation if you wish to increase it\n",
273  w, h, max_pixels);
274  return AVERROR(EINVAL);
275  }
276  }
277 
278  return 0;
279 }
280 
281 int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
282 {
283  return av_image_check_size2(w, h, INT64_MAX, AV_PIX_FMT_NONE, log_offset, log_ctx);
284 }
285 
286 int av_image_check_sar(unsigned int w, unsigned int h, AVRational sar)
287 {
288  int64_t scaled_dim;
289 
290  if (sar.den <= 0 || sar.num < 0)
291  return AVERROR(EINVAL);
292 
293  if (!sar.num || sar.num == sar.den)
294  return 0;
295 
296  if (sar.num < sar.den)
297  scaled_dim = av_rescale_rnd(w, sar.num, sar.den, AV_ROUND_ZERO);
298  else
299  scaled_dim = av_rescale_rnd(h, sar.den, sar.num, AV_ROUND_ZERO);
300 
301  if (scaled_dim > 0)
302  return 0;
303 
304  return AVERROR(EINVAL);
305 }
306 
307 static void image_copy_plane(uint8_t *dst, ptrdiff_t dst_linesize,
308  const uint8_t *src, ptrdiff_t src_linesize,
309  ptrdiff_t bytewidth, int height)
310 {
311  if (!dst || !src)
312  return;
313  av_assert0(abs(src_linesize) >= bytewidth);
314  av_assert0(abs(dst_linesize) >= bytewidth);
315  for (;height > 0; height--) {
316  memcpy(dst, src, bytewidth);
317  dst += dst_linesize;
318  src += src_linesize;
319  }
320 }
321 
322 static void image_copy_plane_uc_from(uint8_t *dst, ptrdiff_t dst_linesize,
323  const uint8_t *src, ptrdiff_t src_linesize,
324  ptrdiff_t bytewidth, int height)
325 {
326  int ret = -1;
327 
328 #if ARCH_X86
329  ret = ff_image_copy_plane_uc_from_x86(dst, dst_linesize, src, src_linesize,
330  bytewidth, height);
331 #endif
332 
333  if (ret < 0)
334  image_copy_plane(dst, dst_linesize, src, src_linesize, bytewidth, height);
335 }
336 
337 void av_image_copy_plane(uint8_t *dst, int dst_linesize,
338  const uint8_t *src, int src_linesize,
339  int bytewidth, int height)
340 {
341  image_copy_plane(dst, dst_linesize, src, src_linesize, bytewidth, height);
342 }
343 
344 static void image_copy(uint8_t *dst_data[4], const ptrdiff_t dst_linesizes[4],
345  const uint8_t *src_data[4], const ptrdiff_t src_linesizes[4],
346  enum AVPixelFormat pix_fmt, int width, int height,
347  void (*copy_plane)(uint8_t *, ptrdiff_t, const uint8_t *,
348  ptrdiff_t, ptrdiff_t, int))
349 {
350  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
351 
352  if (!desc || desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
353  return;
354 
355  if (desc->flags & AV_PIX_FMT_FLAG_PAL ||
357  copy_plane(dst_data[0], dst_linesizes[0],
358  src_data[0], src_linesizes[0],
359  width, height);
360  /* copy the palette */
361  memcpy(dst_data[1], src_data[1], 4*256);
362  } else {
363  int i, planes_nb = 0;
364 
365  for (i = 0; i < desc->nb_components; i++)
366  planes_nb = FFMAX(planes_nb, desc->comp[i].plane + 1);
367 
368  for (i = 0; i < planes_nb; i++) {
369  int h = height;
370  ptrdiff_t bwidth = av_image_get_linesize(pix_fmt, width, i);
371  if (bwidth < 0) {
372  av_log(NULL, AV_LOG_ERROR, "av_image_get_linesize failed\n");
373  return;
374  }
375  if (i == 1 || i == 2) {
376  h = AV_CEIL_RSHIFT(height, desc->log2_chroma_h);
377  }
378  copy_plane(dst_data[i], dst_linesizes[i],
379  src_data[i], src_linesizes[i],
380  bwidth, h);
381  }
382  }
383 }
384 
385 void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
386  const uint8_t *src_data[4], const int src_linesizes[4],
387  enum AVPixelFormat pix_fmt, int width, int height)
388 {
389  ptrdiff_t dst_linesizes1[4], src_linesizes1[4];
390  int i;
391 
392  for (i = 0; i < 4; i++) {
393  dst_linesizes1[i] = dst_linesizes[i];
394  src_linesizes1[i] = src_linesizes[i];
395  }
396 
397  image_copy(dst_data, dst_linesizes1, src_data, src_linesizes1, pix_fmt,
398  width, height, image_copy_plane);
399 }
400 
401 void av_image_copy_uc_from(uint8_t *dst_data[4], const ptrdiff_t dst_linesizes[4],
402  const uint8_t *src_data[4], const ptrdiff_t src_linesizes[4],
403  enum AVPixelFormat pix_fmt, int width, int height)
404 {
405  image_copy(dst_data, dst_linesizes, src_data, src_linesizes, pix_fmt,
406  width, height, image_copy_plane_uc_from);
407 }
408 
409 int av_image_fill_arrays(uint8_t *dst_data[4], int dst_linesize[4],
410  const uint8_t *src, enum AVPixelFormat pix_fmt,
411  int width, int height, int align)
412 {
413  int ret, i;
414 
415  ret = av_image_check_size(width, height, 0, NULL);
416  if (ret < 0)
417  return ret;
418 
419  ret = av_image_fill_linesizes(dst_linesize, pix_fmt, width);
420  if (ret < 0)
421  return ret;
422 
423  for (i = 0; i < 4; i++)
424  dst_linesize[i] = FFALIGN(dst_linesize[i], align);
425 
426  return av_image_fill_pointers(dst_data, pix_fmt, height, (uint8_t *)src, dst_linesize);
427 }
428 
430  int width, int height, int align)
431 {
432  uint8_t *data[4];
433  int linesize[4];
434  int ret;
435  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
436  if (!desc)
437  return AVERROR(EINVAL);
438 
439  ret = av_image_check_size(width, height, 0, NULL);
440  if (ret < 0)
441  return ret;
442 
443  // do not include palette for these pseudo-paletted formats
444  if (desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)
445  return FFALIGN(width, align) * height;
446 
447  return av_image_fill_arrays(data, linesize, NULL, pix_fmt,
448  width, height, align);
449 }
450 
451 int av_image_copy_to_buffer(uint8_t *dst, int dst_size,
452  const uint8_t * const src_data[4],
453  const int src_linesize[4],
454  enum AVPixelFormat pix_fmt,
455  int width, int height, int align)
456 {
457  int i, j, nb_planes = 0, linesize[4];
458  int size = av_image_get_buffer_size(pix_fmt, width, height, align);
459  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
460  int ret;
461 
462  if (size > dst_size || size < 0 || !desc)
463  return AVERROR(EINVAL);
464 
465  for (i = 0; i < desc->nb_components; i++)
466  nb_planes = FFMAX(desc->comp[i].plane, nb_planes);
467 
468  nb_planes++;
469 
470  ret = av_image_fill_linesizes(linesize, pix_fmt, width);
471  av_assert0(ret >= 0); // was checked previously
472 
473  for (i = 0; i < nb_planes; i++) {
474  int h, shift = (i == 1 || i == 2) ? desc->log2_chroma_h : 0;
475  const uint8_t *src = src_data[i];
476  h = (height + (1 << shift) - 1) >> shift;
477 
478  for (j = 0; j < h; j++) {
479  memcpy(dst, src, linesize[i]);
480  dst += FFALIGN(linesize[i], align);
481  src += src_linesize[i];
482  }
483  }
484 
485  if (desc->flags & AV_PIX_FMT_FLAG_PAL) {
486  uint32_t *d32 = (uint32_t *)dst;
487 
488  for (i = 0; i<256; i++)
489  AV_WL32(d32 + i, AV_RN32(src_data[1] + 4*i));
490  }
491 
492  return size;
493 }
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
Definition: pixdesc.h:132
int plane
Definition: avisynth_c.h:422
int plane
Which of the 4 planes contains the component.
Definition: pixdesc.h:35
#define NULL
Definition: coverity.c:32
int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane)
Compute the size of an image line with format pix_fmt and width width for the plane plane...
Definition: imgutils.c:76
const char * s
Definition: avisynth_c.h:768
static enum AVPixelFormat pix_fmt
static int shift(int a, int b)
Definition: sonic.c:82
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2333
ptrdiff_t const GLvoid * data
Definition: opengl_enc.c:101
int av_image_copy_to_buffer(uint8_t *dst, int dst_size, const uint8_t *const src_data[4], const int src_linesize[4], enum AVPixelFormat pix_fmt, int width, int height, int align)
Copy image data from an image into a buffer.
Definition: imgutils.c:451
misc image utilities
#define LIBAVUTIL_VERSION_INT
Definition: version.h:86
const char * g
Definition: vf_curves.c:112
const char * desc
Definition: nvenc.c:60
int av_image_alloc(uint8_t *pointers[4], int linesizes[4], int w, int h, enum AVPixelFormat pix_fmt, int align)
Allocate an image with size w and h and pixel format pix_fmt, and fill pointers and linesizes accordi...
Definition: imgutils.c:192
int num
Numerator.
Definition: rational.h:59
static const AVClass imgutils_class
Definition: imgutils.c:244
const char * b
Definition: vf_curves.c:113
int av_image_fill_arrays(uint8_t *dst_data[4], int dst_linesize[4], const uint8_t *src, enum AVPixelFormat pix_fmt, int width, int height, int align)
Setup the data pointers and linesizes based on the specified image parameters and the provided array...
Definition: imgutils.c:409
#define src
Definition: vp8dsp.c:254
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:92
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
Definition: pixfmt.h:86
void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], const AVPixFmtDescriptor *pixdesc)
Compute the max pixel step for each plane of an image with a format described by pixdesc.
Definition: imgutils.c:35
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:72
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:117
uint8_t
#define av_malloc(s)
int avpriv_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt)
Definition: imgutils.c:152
void * log_ctx
Definition: imgutils.c:241
int av_image_check_sar(unsigned int w, unsigned int h, AVRational sar)
Check if the given sample aspect ratio of an image is valid.
Definition: imgutils.c:286
#define height
ptrdiff_t size
Definition: opengl_enc.c:101
#define FFALIGN(x, a)
Definition: macros.h:48
#define av_log(a,...)
#define U(x)
Definition: vp56_arith.h:37
int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, int width, int height, int align)
Return the size in bytes of the amount of data required to store an image with the given parameters...
Definition: imgutils.c:429
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:101
av_default_item_name
#define AVERROR(e)
Definition: error.h:43
static void image_copy_plane_uc_from(uint8_t *dst, ptrdiff_t dst_linesize, const uint8_t *src, ptrdiff_t src_linesize, ptrdiff_t bytewidth, int height)
Definition: imgutils.c:322
const char * r
Definition: vf_curves.c:111
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
Definition: pixdesc.h:140
simple assert() macros that are a bit more flexible than ISO C assert().
#define FFMAX(a, b)
Definition: common.h:94
void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], const uint8_t *src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Copy image in src_data to dst_data.
Definition: imgutils.c:385
common internal API header
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:106
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
Definition: imgutils.c:281
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition: pixdesc.h:83
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
Definition: pixfmt.h:89
Round toward zero.
Definition: mathematics.h:80
#define width
#define AV_PIX_FMT_FLAG_PSEUDOPAL
The pixel format is "pseudo-paletted".
Definition: pixdesc.h:158
static int image_get_linesize(int width, int plane, int max_step, int max_step_comp, const AVPixFmtDescriptor *desc)
Definition: imgutils.c:54
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
Rescale a 64-bit integer with specified rounding.
Definition: mathematics.c:58
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
Definition: eamad.c:83
const AVClass * class
Definition: imgutils.c:239
const AVS_VideoInfo int align
Definition: avisynth_c.h:795
int log_offset
Definition: imgutils.c:240
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
Definition: pixfmt.h:84
int av_image_fill_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt, int height, uint8_t *ptr, const int linesizes[4])
Fill plane data pointers for an image with pixel format pix_fmt and height height.
Definition: imgutils.c:111
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
void * buf
Definition: avisynth_c.h:690
Describe the class of an AVClass context structure.
Definition: log.h:67
static void image_copy(uint8_t *dst_data[4], const ptrdiff_t dst_linesizes[4], const uint8_t *src_data[4], const ptrdiff_t src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height, void(*copy_plane)(uint8_t *, ptrdiff_t, const uint8_t *, ptrdiff_t, ptrdiff_t, int))
Definition: imgutils.c:344
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
Fill plane linesizes for an image with pixel format pix_fmt and width width.
Definition: imgutils.c:89
Rational number (pair of numerator and denominator).
Definition: rational.h:58
const uint8_t * d32
Definition: yuv2rgb.c:493
#define AV_RN32(p)
Definition: intreadwrite.h:369
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
Definition: pixdesc.h:136
GLint GLenum GLboolean GLsizei stride
Definition: opengl_enc.c:105
Y , 8bpp.
Definition: pixfmt.h:70
common internal and external API header
Utilties for rational number calculation.
void av_image_copy_uc_from(uint8_t *dst_data[4], const ptrdiff_t dst_linesizes[4], const uint8_t *src_data[4], const ptrdiff_t src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Copy image data located in uncacheable (e.g.
Definition: imgutils.c:401
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
Definition: pixfmt.h:87
int den
Denominator.
Definition: rational.h:60
int av_image_check_size2(unsigned int w, unsigned int h, int64_t max_pixels, enum AVPixelFormat pix_fmt, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of a plane of an image with...
Definition: imgutils.c:252
#define av_free(p)
static void image_copy_plane(uint8_t *dst, ptrdiff_t dst_linesize, const uint8_t *src, ptrdiff_t src_linesize, ptrdiff_t bytewidth, int height)
Definition: imgutils.c:307
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
Definition: imgutils.c:337
int ff_image_copy_plane_uc_from_x86(uint8_t *dst, ptrdiff_t dst_linesize, const uint8_t *src, ptrdiff_t src_linesize, ptrdiff_t bytewidth, int height)
Definition: imgutils_init.c:34
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
for(j=16;j >0;--j)
int step
Number of elements between 2 horizontally consecutive pixels.
Definition: pixdesc.h:41
#define AV_WL32(p, v)
Definition: intreadwrite.h:431
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58