FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 FFmpeg.
6  *
7  * FFmpeg 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  * FFmpeg 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 FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /**
23  * @file
24  * AVPicture management routines
25  */
26 
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, const 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  unsigned char *dest, int dest_size)
46 {
47  return av_image_copy_to_buffer(dest, dest_size,
48  (const uint8_t * const*)src->data, src->linesize,
49  pix_fmt, width, height, 1);
50 }
51 
53 {
54  return av_image_get_buffer_size(pix_fmt, width, height, 1);
55 }
56 
58  enum AVPixelFormat pix_fmt, int width, int height)
59 {
60  int ret = av_image_alloc(picture->data, picture->linesize,
61  width, height, pix_fmt, 1);
62  if (ret < 0) {
63  memset(picture, 0, sizeof(AVPicture));
64  return ret;
65  }
66 
67  return 0;
68 }
69 
70 void avpicture_free(AVPicture *picture)
71 {
72  av_freep(&picture->data[0]);
73 }
74 
76  enum AVPixelFormat pix_fmt, int width, int height)
77 {
78  av_image_copy(dst->data, dst->linesize, (const uint8_t **)src->data,
79  src->linesize, pix_fmt, width, height);
80 }
82 #endif /* FF_API_AVPICTURE */
static enum AVPixelFormat pix_fmt
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:452
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:192
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:410
Various defines for YUV<->RGB conversion.
Picture data structure.
Definition: avcodec.h:3721
#define src
Definition: vp8dsp.c:254
int avpicture_alloc(AVPicture *picture, enum AVPixelFormat pix_fmt, int width, int height)
Definition: avpicture.c:57
uint8_t
attribute_deprecated int linesize[AV_NUM_DATA_POINTERS]
number of bytes per line
Definition: avcodec.h:3725
#define height
FF_DISABLE_DEPRECATION_WARNINGS int avpicture_fill(AVPicture *picture, const uint8_t *ptr, enum AVPixelFormat pix_fmt, int width, int height)
Definition: avpicture.c: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:430
uint16_t width
Definition: gdv.c:47
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:386
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:52
attribute_deprecated uint8_t * data[AV_NUM_DATA_POINTERS]
pointers to the image data planes
Definition: avcodec.h:3723
Libavcodec external API header.
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:84
common internal api header.
common internal and external API header
void avpicture_free(AVPicture *picture)
Definition: avpicture.c:70
void av_picture_copy(AVPicture *dst, const AVPicture *src, enum AVPixelFormat pix_fmt, int width, int height)
Definition: avpicture.c:75
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:85
#define av_freep(p)
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60