[FFmpeg-devel] [PATCH 2/2] avutil/imgutils: only align the palette in av_image_copy_to_buffer() if there is enough space
Michael Niedermayer
michael at niedermayer.cc
Sat Feb 13 18:11:28 CET 2016
On Sat, Feb 13, 2016 at 05:53:17PM +0100, Stefano Sabatini wrote:
> On date Saturday 2016-02-13 15:32:58 +0100, Michael Niedermayer encoded:
> > This allows disabling the alignment by using a compact buffer
> >
> > Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> > ---
> > libavutil/imgutils.c | 5 +++++
> > libavutil/version.h | 2 +-
> > 2 files changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
> > index 5c28703..adf6fdd 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;
> > +
>
> Do you have a specific use case for this?
the nut spec currently says that for pal8 theres
width*height + palette
if both width and height are odd the padding results in a mismatch
to that
This commit alone doesnt fix it but it allows to use
av_image_copy_to_buffer() to create that layout
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User
questions about the command line tools should be sent to the ffmpeg-user ML.
And questions about how to use libav* should be sent to the libav-user ML.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160213/20f54971/attachment.sig>
More information about the ffmpeg-devel
mailing list