00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00027 #include "avcodec.h"
00028 #include "internal.h"
00029 #include "libavutil/common.h"
00030 #include "libavutil/pixdesc.h"
00031 #include "libavutil/imgutils.h"
00032 #include "libavutil/colorspace.h"
00033
00034 int avpicture_fill(AVPicture *picture, const uint8_t *ptr,
00035 enum AVPixelFormat pix_fmt, int width, int height)
00036 {
00037 return av_image_fill_arrays(picture->data, picture->linesize,
00038 ptr, pix_fmt, width, height, 1);
00039 }
00040
00041 int avpicture_layout(const AVPicture* src, enum AVPixelFormat pix_fmt, int width, int height,
00042 unsigned char *dest, int dest_size)
00043 {
00044 return av_image_copy_to_buffer(dest, dest_size,
00045 (const uint8_t * const*)src->data, src->linesize,
00046 pix_fmt, width, height, 1);
00047 }
00048
00049 int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height)
00050 {
00051 return av_image_get_buffer_size(pix_fmt, width, height, 1);
00052 }
00053
00054 int avpicture_alloc(AVPicture *picture,
00055 enum AVPixelFormat pix_fmt, int width, int height)
00056 {
00057 int ret = av_image_alloc(picture->data, picture->linesize,
00058 width, height, pix_fmt, 1);
00059 if (ret < 0) {
00060 memset(picture, 0, sizeof(AVPicture));
00061 return ret;
00062 }
00063
00064 return 0;
00065 }
00066
00067 void avpicture_free(AVPicture *picture)
00068 {
00069 av_free(picture->data[0]);
00070 }
00071
00072 void av_picture_copy(AVPicture *dst, const AVPicture *src,
00073 enum AVPixelFormat pix_fmt, int width, int height)
00074 {
00075 av_image_copy(dst->data, dst->linesize, (const uint8_t **)src->data,
00076 src->linesize, pix_fmt, width, height);
00077 }
00078