[FFmpeg-devel] [patch] support decoding png 1,2,4 bits

Reimar Döffinger Reimar.Doeffinger
Thu Feb 14 11:20:46 CET 2008


Hello,
On Thu, Feb 14, 2008 at 10:41:50AM +0100, Julien Reichel wrote:
> +    if (src_bits==1){
> +        for(j = 0;j < width; j+=8) {

This will probably break badly if width is not divisible by 8?

> +            v = src[0];
> +            dst[0] = (v&0x80)>>7;
> +            dst[1] = (v&0x40)>>6;
> +            dst[2] = (v&0x20)>>5;
> +            dst[3] = (v&0x10)>>4;
> +            dst[4] = (v&0x08)>>3;
> +            dst[5] = (v&0x04)>>2;
> +            dst[6] = (v&0x02)>>1;
> +            dst[7] = (v&0x01);

(v >> 7) & 1;
(v >> 6) & 1;
(v >> 5) & 1;
...

IMO would be much more readable.
In addition if speed does not matter (much), just using the bitstream
reader would be much simpler as well (maybe 4 lines of code to handle
_all_ cases), though it would require src to be padded, not idea if that
is the case currently.

Greetings,
Reimar D?ffinger




More information about the ffmpeg-devel mailing list