[FFmpeg-devel] [PATCH]Fix LZW/ZLIB compressed 4bit tiff
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Sun Sep 25 15:07:52 CEST 2011
On Sun, Sep 25, 2011 at 02:21:10PM +0200, Carl Eugen Hoyos wrote:
> + int i;
> + for(i = width - 1; i >= 0; i--){
That looks the same as
while (--width >= 0)
However for cache reasons going through it backwards is questionable.
You can get the advantage of both by incrementing src/dts by width
and indexing with -width .. -1 for example, but that is obfuscation.
> + dst[i * 2 + 1] = src[i] & 0x0F;
> + dst[i * 2 + 0] = (src[i] & 0xF0) >> 4;
The second & is unnecessary.
I'd probably go with
while (--width >= 0) {
*dst++ = *src >> 4;
*dst++ = *src++ & 0xF;
}
> @@ -148,7 +158,11 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uin
> }
> src = zbuf;
> for(line = 0; line < lines; line++){
> - memcpy(dst, src, width);
> + if(s->bpp == 4){
> + split_nibbles(src, dst, width);
> + }else{
> + memcpy(dst, src, width);
> + }
> dst += stride;
> src += width;
> }
> @@ -238,6 +252,8 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uin
> av_log(s->avctx, AV_LOG_ERROR, "Decoded only %i bytes of %i\n", pixels, width);
> return -1;
> }
> + if(s->bpp == 4)
> + split_nibbles(dst, dst, width);
That doubles the amount of data, are the buffer size/size checks still
correct after that change?
More information about the ffmpeg-devel
mailing list