[FFmpeg-devel] [PATCH]Fix 1bpp palettized png with width not a multiple of 8

Michael Niedermayer michaelni at gmx.at
Mon Jan 28 14:57:56 CET 2013


On Mon, Jan 28, 2013 at 09:46:56AM +0100, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch based on 9e36d9e fixes ticket #2204 for me.
> 
> Please comment, Carl Eugen

>  pngdec.c |   10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> ccf2fcfbd0561f8987af8511ba38afff98cea879  patchpngpal1bpp.diff
> diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
> index 593df60..b34dd63 100644
> --- a/libavcodec/pngdec.c
> +++ b/libavcodec/pngdec.c
> @@ -768,7 +768,15 @@ static int decode_frame(AVCodecContext *avctx,
>          int i, j;
>          uint8_t *pd = s->current_picture->data[0];
>          for (j = 0; j < s->height; j++) {
> +            i = s->width / 8;
> +            if ((s->width&7) >= 7) pd[8*i + 6] = (pd[i]>>1) & 1;
> +            if ((s->width&6) >= 6) pd[8*i + 5] = (pd[i]>>2) & 1;
> +            if ((s->width&5) >= 5) pd[8*i + 4] = (pd[i]>>3) & 1;
> +            if ((s->width&4) >= 4) pd[8*i + 3] = (pd[i]>>4) & 1;
> +            if ((s->width&3) >= 3) pd[8*i + 2] = (pd[i]>>5) & 1;
> +            if ((s->width&2) >= 2) pd[8*i + 1] = (pd[i]>>6) & 1;
> +            if ((s->width&1) >= 1) pd[8*i + 0] =  pd[i]>>7;

the &X values look strange

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No great genius has ever existed without some touch of madness. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130128/1938a96e/attachment.asc>


More information about the ffmpeg-devel mailing list