[FFmpeg-cvslog] avutil/imgutils: remove special case for aligning the palette
Michael Niedermayer
git at videolan.org
Sun Feb 14 21:33:41 CET 2016
ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Sun Feb 14 15:22:47 2016 +0100| [0eb4092c1bf4d74c3b9a65fb0dbe4f90d3a316d0] | committer: Michael Niedermayer
avutil/imgutils: remove special case for aligning the palette
This was suggested by wm4 and stefano.
After this patch using align=1 the size used by various functions would not
contain padding, while the palette would be aligned at align>1
This patch makes it required to use align>=4 if the palette is to be accessed
as uint32
As a side-effect It fixes storing pal8 in nut with odd with&height
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0eb4092c1bf4d74c3b9a65fb0dbe4f90d3a316d0
---
libavutil/imgutils.c | 14 +++++++-------
libavutil/version.h | 2 +-
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
index adf6fdd..1474482 100644
--- a/libavutil/imgutils.c
+++ b/libavutil/imgutils.c
@@ -125,7 +125,6 @@ int av_image_fill_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt, int hei
if (desc->flags & AV_PIX_FMT_FLAG_PAL ||
desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) {
- size[0] = (size[0] + 3) & ~3;
data[1] = ptr + size[0]; /* palette is stored here as 256 32 bits words */
return size[0] + 256 * 4;
}
@@ -216,8 +215,13 @@ int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
av_free(buf);
return ret;
}
- if (desc->flags & AV_PIX_FMT_FLAG_PAL || desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)
+ if (desc->flags & AV_PIX_FMT_FLAG_PAL || desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) {
avpriv_set_systematic_pal2((uint32_t*)pointers[1], pix_fmt);
+ if (align < 4) {
+ av_log(NULL, AV_LOG_ERROR, "Formats with a palette require a minimum alignment of 4\n");
+ return AVERROR(EINVAL);
+ }
+ }
if ((desc->flags & AV_PIX_FMT_FLAG_PAL ||
desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) &&
@@ -385,7 +389,6 @@ 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,10 +412,7 @@ 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;
+ uint32_t *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 aa7d913..0ea8c79 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 102
+#define LIBAVUTIL_VERSION_MICRO 103
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \
More information about the ffmpeg-cvslog
mailing list