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

Michael Niedermayer michaelni at gmx.at
Tue Jan 29 15:23:12 CET 2013


On Tue, Jan 29, 2013 at 09:34:59AM +0100, Carl Eugen Hoyos wrote:
> On Monday 28 January 2013 02:57:56 pm Michael Niedermayer wrote:
> > On Mon, Jan 28, 2013 at 09:46:56AM +0100, Carl Eugen Hoyos wrote:
> 
> > > +            if ((s->width&1) >= 1) pd[8*i + 0] =  pd[i]>>7;
> >
> > the &X values look strange
> 
> New patch attached.
> 
> Thank you, Carl Eugen

>  pngdec.c |   10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> ae7ad0a6d5328ee18035b49f2d7e3cb9d3a2acf0  patchpngpal1bpp.diff
> diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
> index 593df60..fb1e6b3 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&7) >= 6) pd[8*i + 5] = (pd[i]>>2) & 1;
> +            if ((s->width&7) >= 5) pd[8*i + 4] = (pd[i]>>3) & 1;
> +            if ((s->width&7) >= 4) pd[8*i + 3] = (pd[i]>>4) & 1;
> +            if ((s->width&7) >= 3) pd[8*i + 2] = (pd[i]>>5) & 1;
> +            if ((s->width&7) >= 2) pd[8*i + 1] = (pd[i]>>6) & 1;
> +            if ((s->width&7) >= 1) pd[8*i + 0] =  pd[i]>>7;

should be ok if it works
alternatively this maybe could be simplified with a loop

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many things microsoft did are stupid, but not doing something just because
microsoft did it is even more stupid. If everything ms did were stupid they
would be bankrupt already.
-------------- 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/20130129/1bdf9a64/attachment.asc>


More information about the ffmpeg-devel mailing list