[FFmpeg-devel] [PATCH] PC Paintbrush PCX decoder

Ivo ivop
Wed Dec 26 23:21:05 CET 2007

On Wednesday 26 December 2007 21:00, Michael Niedermayer wrote:
> On Wed, Dec 26, 2007 at 07:56:52PM +0100, Ivo wrote:
> > Scanlines in PCX files are padded at the right side, so it's possible
> > decoded bytes will be written outside of the dst buffer while decoding
> > the last scanline (only the PAL8 case which decodes directly to
> > s->picture->data[0], others decode to an intermediate scanline buffer
> > that is always large enough).
> >
> > Is there a way to force s->picture->linesize[0] to bytes_per_scanline
> > during allocation? In that case I could simplify the code and get rid
> > of dst_size.
> it can be forced but it has other disadvantages, that is you loose direct
> rendering support ...
> anyway, i do not think the check per sample is faster than a buffer and
> memcpy
> you could also try:
> if(i<dst_size)
>     memset(dst+i, d, FFMIN(c, dst_size-i));
> i+=c;

Ok. I chose the buffer/memcpy way as that simplifies rle_decode and speeds 
up all non-pal8 cases. The code is also ~50 bytes smaller (and the memset 
code was 150+ bytes larger). Also, most runs for a typical file will be 
relatively small or no run at all, so memset might actually hurt.



More information about the ffmpeg-devel mailing list