Libav
avpicture.c
Go to the documentation of this file.
1 /*
2  * AVPicture management routines
3  * Copyright (c) 2001, 2002, 2003 Fabrice Bellard
4  *
5  * This file is part of Libav.
6  *
7  * Libav is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * Libav is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with Libav; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
27 #include "avcodec.h"
28 #include "internal.h"
29 #include "libavutil/common.h"
30 #include "libavutil/pixdesc.h"
31 #include "libavutil/imgutils.h"
32 #include "libavutil/internal.h"
33 #include "libavutil/colorspace.h"
34 
35 #if FF_API_AVPICTURE
37 int avpicture_fill(AVPicture *picture, uint8_t *ptr,
38  enum AVPixelFormat pix_fmt, int width, int height)
39 {
40  return av_image_fill_arrays(picture->data, picture->linesize,
41  ptr, pix_fmt, width, height, 1);
42 }
43 
45  int width, int height,
46  unsigned char *dest, int dest_size)
47 {
48  return av_image_copy_to_buffer(dest, dest_size,
49  src->data, src->linesize,
50  pix_fmt, width, height, 1);
51 }
52 
54 {
55  return av_image_get_buffer_size(pix_fmt, width, height, 1);
56 }
57 
59  enum AVPixelFormat pix_fmt, int width, int height)
60 {
61  int ret = av_image_alloc(picture->data, picture->linesize,
62  width, height, pix_fmt, 1);
63  if (ret < 0) {
64  memset(picture, 0, sizeof(AVPicture));
65  return ret;
66  }
67 
68  return 0;
69 }
70 
71 void avpicture_free(AVPicture *picture)
72 {
73  av_free(picture->data[0]);
74 }
75 
77  enum AVPixelFormat pix_fmt, int width, int height)
78 {
79  av_image_copy(dst->data, dst->linesize, src->data,
80  src->linesize, pix_fmt, width, height);
81 }
83 #endif /* FF_API_AVPICTURE */
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:345
misc image utilities
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:182
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:303
Various defines for YUV<->RGB conversion.
four components are given, that&#39;s all.
Definition: avcodec.h:3390
int avpicture_alloc(AVPicture *picture, enum AVPixelFormat pix_fmt, int width, int height)
Definition: avpicture.c:58
uint8_t
attribute_deprecated int linesize[AV_NUM_DATA_POINTERS]
number of bytes per line
Definition: avcodec.h:3394
#define src
Definition: vp8dsp.c:254
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:323
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
Definition: mem.c:190
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:268
common internal API header
int avpicture_layout(const AVPicture *src, enum AVPixelFormat pix_fmt, int width, int height, unsigned char *dest, int dest_size)
Definition: avpicture.c:44
int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height)
Definition: avpicture.c:53
attribute_deprecated uint8_t * data[AV_NUM_DATA_POINTERS]
Definition: avcodec.h:3392
enum AVPixelFormat pix_fmt
Definition: movenc.c:853
static int width
Definition: utils.c:156
Libavcodec external API header.
int height
Definition: gxfenc.c:72
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:77
common internal api header.
common internal and external API header
void avpicture_free(AVPicture *picture)
Definition: avpicture.c:71
void av_picture_copy(AVPicture *dst, const AVPicture *src, enum AVPixelFormat pix_fmt, int width, int height)
Definition: avpicture.c:76
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:78
AVPixelFormat
Pixel format.
Definition: pixfmt.h:57
FF_DISABLE_DEPRECATION_WARNINGS int avpicture_fill(AVPicture *picture, uint8_t *ptr, enum AVPixelFormat pix_fmt, int width, int height)
Definition: avpicture.c:37