aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2016-02-13 15:32:58 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2016-02-13 19:49:34 +0100
commit4c920ce777a1904202952ea3010fdfb99e002ad3 (patch)
tree065fba108b82ac14a4a1347ee875b6177112a6e2
parent5307adadeb220db14418bf4af1e45c4b83a53542 (diff)
downloadffmpeg-4c920ce777a1904202952ea3010fdfb99e002ad3.tar.gz
avutil/imgutils: only align the palette in av_image_copy_to_buffer() if there is enough space
This allows disabling the alignment by using a compact buffer Reviewed-by: Stefano Sabatini <stefasab@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavutil/imgutils.c5
-rw-r--r--libavutil/version.h2
2 files changed, 6 insertions, 1 deletions
diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
index 5c2870323c..adf6fdd206 100644
--- a/libavutil/imgutils.c
+++ b/libavutil/imgutils.c
@@ -385,6 +385,7 @@ int av_image_copy_to_buffer(uint8_t *dst, int dst_size,
int i, j, nb_planes = 0, linesize[4];
int size = av_image_get_buffer_size(pix_fmt, width, height, align);
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
+ uint8_t *orig_dst = dst;
if (size > dst_size || size < 0 || !desc)
return AVERROR(EINVAL);
@@ -409,6 +410,10 @@ int av_image_copy_to_buffer(uint8_t *dst, int dst_size,
if (desc->flags & AV_PIX_FMT_FLAG_PAL) {
uint32_t *d32 = (uint32_t *)(((size_t)dst + 3) & ~3);
+
+ if (dst_size - 1024 < (uint8_t*)d32 - orig_dst)
+ d32 = (uint32_t *)dst;
+
for (i = 0; i<256; i++)
AV_WL32(d32 + i, AV_RN32(src_data[1] + 4*i));
}
diff --git a/libavutil/version.h b/libavutil/version.h
index f99624c94b..aa7d9137a7 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -65,7 +65,7 @@
#define LIBAVUTIL_VERSION_MAJOR 55
#define LIBAVUTIL_VERSION_MINOR 17
-#define LIBAVUTIL_VERSION_MICRO 101
+#define LIBAVUTIL_VERSION_MICRO 102
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \