[FFmpeg-devel] [PATCH] avutil/imgutils: av_image_get_buffer_size(): do not insert padding between stride*height and palette

Michael Niedermayer michael at niedermayer.cc
Sat Feb 13 19:38:01 CET 2016


This fixes the layout that is stored in pal8 nut with odd width*height

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavcodec/avpicture.c |    2 ++
 libavutil/imgutils.c   |    4 ++++
 2 files changed, 6 insertions(+)

diff --git a/libavcodec/avpicture.c b/libavcodec/avpicture.c
index 56435f4..cac9287 100644
--- a/libavcodec/avpicture.c
+++ b/libavcodec/avpicture.c
@@ -51,6 +51,8 @@ int avpicture_layout(const AVPicture* src, enum AVPixelFormat pix_fmt, int width
 
 int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height)
 {
+    if (pix_fmt == AV_PIX_FMT_PAL8)
+        return FFALIGN(width*height, 4) + 1024;
     return av_image_get_buffer_size(pix_fmt, width, height, 1);
 }
 
diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
index adf6fdd..976bd23 100644
--- a/libavutil/imgutils.c
+++ b/libavutil/imgutils.c
@@ -372,6 +372,10 @@ int av_image_get_buffer_size(enum AVPixelFormat pix_fmt,
     if (desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)
         return FFALIGN(width, align) * height;
 
+    // For paletted images we do not align the palette as in AVFrames
+    if (desc->flags & AV_PIX_FMT_FLAG_PAL)
+        return FFALIGN(width, align) * height + 1024;
+
     return av_image_fill_arrays(data, linesize, NULL, pix_fmt,
                                 width, height, align);
 }
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list