Commit 55dc253c authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'e2ad0b66'

* commit 'e2ad0b66':
  imgutils: create misc functions for dealing with buffers

Conflicts:
	doc/APIchanges
	libavcodec/avcodec.h
	libavcodec/avpicture.c
	libavutil/imgutils.c
	libavutil/imgutils.h
	libavutil/version.h

See: e6674e46Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents cc18ea8d e2ad0b66
......@@ -317,15 +317,17 @@ void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
}
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)
const uint8_t *src, enum AVPixelFormat pix_fmt,
int width, int height, int align)
{
int ret, i;
if ((ret = av_image_check_size(width, height, 0, NULL)) < 0)
ret = av_image_check_size(width, height, 0, NULL);
if (ret < 0)
return ret;
if ((ret = av_image_fill_linesizes(dst_linesize, pix_fmt, width)) < 0)
ret = av_image_fill_linesizes(dst_linesize, pix_fmt, width);
if (ret < 0)
return ret;
for (i = 0; i < 4; i++)
......@@ -334,35 +336,44 @@ int av_image_fill_arrays(uint8_t *dst_data[4], int dst_linesize[4],
return av_image_fill_pointers(dst_data, pix_fmt, height, (uint8_t *)src, dst_linesize);
}
int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, int width, int height, int align)
int av_image_get_buffer_size(enum AVPixelFormat pix_fmt,
int width, int height, int align)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
uint8_t *data[4];
int linesize[4];
int ret;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
if (!desc)
return AVERROR(EINVAL);
if (av_image_check_size(width, height, 0, NULL) < 0)
return AVERROR(EINVAL);
ret = av_image_check_size(width, height, 0, NULL);
if (ret < 0)
return ret;
// do not include palette for these pseudo-paletted formats
if (desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)
// do not include palette for these pseudo-paletted formats
return width * height;
return av_image_fill_arrays(data, linesize, NULL, pix_fmt, width, height, align);
return av_image_fill_arrays(data, linesize, NULL, pix_fmt,
width, height, align);
}
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)
const uint8_t * const src_data[4],
const int src_linesize[4],
enum AVPixelFormat pix_fmt,
int width, int height, int align)
{
int i, j, nb_planes = 0, linesize[4];
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
int size = av_image_get_buffer_size(pix_fmt, width, height, align);
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
if (size > dst_size || size < 0)
if (size > dst_size || size < 0 || !desc)
return AVERROR(EINVAL);
for (i = 0; i < desc->nb_components; i++)
nb_planes = FFMAX(desc->comp[i].plane, nb_planes);
nb_planes++;
av_image_fill_linesizes(linesize, pix_fmt, width);
......
......@@ -130,7 +130,7 @@ void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
* line sizes will be set. If a planar format is specified, several
* pointers will be set pointing to the different picture planes and
* the line sizes of the different planes will be stored in the
* lines_sizes array. Call with !src to get the required
* lines_sizes array. Call with src == NULL to get the required
* size for the src buffer.
*
* To allocate the buffer and fill in the dst_data and dst_linesize in
......
......@@ -57,7 +57,7 @@
#define LIBAVUTIL_VERSION_MAJOR 54
#define LIBAVUTIL_VERSION_MINOR 16
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_MICRO 101
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment