[Ffmpeg-devel] [PATCH/RFC] 1-7 and 9-15 bits per pixel PGM files

Michael Niedermayer michaelni
Sat Apr 7 23:45:00 CEST 2007


Hi

On Sat, Apr 07, 2007 at 11:17:43PM +0200, Ivo wrote:
> On Saturday 07 April 2007 16:27, Michael Niedermayer wrote:
> > On Sat, Apr 07, 2007 at 03:43:40PM +0200, Ivo wrote:
> > > I see. I have thought about it and I think the shift/or "upgrading" to
> > > 8/16-bits per component is better than multiply/division, even in this
> >
> > division is too slow, always mupltply by the reciprocal and shift
> >
> > > case, because it won't introduce rounding errors and can be downgraded
> > > losslessly (simple shift).
> >
> > hmm
> 
> Do you disagree here and should I support all non-power-of-two maxvals 
> exactly, despite the rounding errors they will introduce, or are you ok 
> with treating non-power-of-two maxvals like they had a maxval of the 
> nearest power of two above that? (which is what the current patch does)

i dunno :)


> 
> > > +        ptr[j] = ptr[j]<<(8-s->bpp) | ptr[j]>>(s->bpp-(8-s->bpp));
> >
> > will fail if bpp<4 (negative shift)
> 
> Ah, yes, I overlooked that as I copied over the 16-bit variant, not thinking 
> about the fact that in that case it will never happen (bpp always >8 in 
> that case).
> Fixed it.
> 
> > 16bit formats should be in native endian internally (for obvious reasons)
> 
> Fixed :)
[...]
> +    /* upgrade values to full range of PIX_FMT */
> +    if (avctx->pix_fmt == PIX_FMT_GRAY8 && s->bpp < 8) {
> +        unsigned int j;
> +        for(ptr = p->data[0], i = 0; i < avctx->height; i++, ptr += linesize) {
> +            for(j = 0; j < avctx->width; j++)
> +                ptr[j] = ptr[j]<<(8-s->bpp) | ptr[j]>>s->bpp;

ptr[j]>>s->bpp == 0


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070407/8e130c02/attachment.pgp>



More information about the ffmpeg-devel mailing list