diff options
author | Michael Niedermayer | 2015-01-15 04:56:32 +0100 |
---|---|---|
committer | Michael Niedermayer | 2015-01-15 05:07:25 +0100 |
commit | 55dc253c24f2160ede1db4f04cfe0692b0b80d05 (patch) | |
tree | 8efda157c2be25699896113158afe0dfbdb5ff50 | |
parent | cc18ea8de05820a6c96f4d8afb8f3ce0e38c7793 (diff) | |
parent | e2ad0b66fa273c5c823978e8f601f2c0d9ee42f8 (diff) |
Merge commit 'e2ad0b66fa273c5c823978e8f601f2c0d9ee42f8'
* commit 'e2ad0b66fa273c5c823978e8f601f2c0d9ee42f8':
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: e6674e46ecdd7aaa93d7f7d818eb1c8224b35eae
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavutil/imgutils.c | 41 | ||||
-rw-r--r-- | libavutil/imgutils.h | 2 | ||||
-rw-r--r-- | libavutil/version.h | 2 |
3 files changed, 28 insertions, 17 deletions
diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c index 7f3032bdf3..07b494c38a 100644 --- a/libavutil/imgutils.c +++ b/libavutil/imgutils.c @@ -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); diff --git a/libavutil/imgutils.h b/libavutil/imgutils.h index 2ec246aa48..23282a38fa 100644 --- a/libavutil/imgutils.h +++ b/libavutil/imgutils.h @@ -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 diff --git a/libavutil/version.h b/libavutil/version.h index a1ed502016..5fd331c489 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -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, \ |