diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-01-15 04:56:32 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-01-15 05:07:25 +0100 |
commit | 55dc253c24f2160ede1db4f04cfe0692b0b80d05 (patch) | |
tree | 8efda157c2be25699896113158afe0dfbdb5ff50 /libavutil/imgutils.c | |
parent | cc18ea8de05820a6c96f4d8afb8f3ce0e38c7793 (diff) | |
parent | e2ad0b66fa273c5c823978e8f601f2c0d9ee42f8 (diff) | |
download | ffmpeg-55dc253c24f2160ede1db4f04cfe0692b0b80d05.tar.gz |
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>
Diffstat (limited to 'libavutil/imgutils.c')
-rw-r--r-- | libavutil/imgutils.c | 41 |
1 files changed, 26 insertions, 15 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); |