[FFmpeg-devel] [PATCH] PC Paintbrush PCX decoder
Michael Niedermayer
michaelni
Wed Dec 26 21:00:46 CET 2007
On Wed, Dec 26, 2007 at 07:56:52PM +0100, Ivo wrote:
> On Wednesday 26 December 2007 18:47, Michael Niedermayer wrote:
> > On Wed, Dec 26, 2007 at 04:54:31PM +0100, Ivo wrote:
> > > +static char *pcx_rle_decode(uint8_t *src, uint8_t *dst,
> > > + unsigned int bytes_per_scanline,
> > > + unsigned int dst_size) {
> > > + unsigned int i = 0;
> > > + unsigned char c, d;
> > > +
> > > + if (!dst_size) dst_size = bytes_per_scanline;
> > > +
> > > + while (i<bytes_per_scanline) {
> > > + c = 1;
> > > + d = *src++;
> > > + if (d >= 0xc0) {
> > > + c = d & 0x3f;
> > > + d = *src++;
> > > + }
> > > + while (i<bytes_per_scanline && c--) {
> > > + if (i < dst_size) dst[i] = d;
> > > + i++;
> > > + }
> > > + }
> >
> > why are there 2 sizes? dst_size and bytes_per_scanline serve the same
> > purpose, remove one and pass the proper (smaller) size ... but isnt
> > it an error anyway if bytes_per_scanline > dst_size ?
>
> 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;
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
I am the wisest man alive, for I know one thing, and that is that I know
nothing. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20071226/526b7672/attachment.pgp>
More information about the ffmpeg-devel
mailing list