[Ffmpeg-devel] [PATCH/RFC] 1-7 and 9-15 bits per pixel PGM files
Ivo
ivop
Mon Apr 9 11:27:33 CEST 2007
Hi,
On Monday 09 April 2007 11:08, Reimar D?ffinger wrote:
> On Mon, Apr 09, 2007 at 10:30:16AM +0200, Ivo wrote:
> > Fixed. I suppose it is always better to use the bytestream stuff like
> > Reimar suggested earlier?
>
> No, bytestream use the AV_RL etc. macros, it just also increments the
> pointer for you, hopefully simplifying the code (also since indexing
> into an array with an int needs quite a lot of code on 64 bit systems -
> might be also due to gcc stupidity though).
> (uint16_t *) is always faster, but assumes things to be aligned
> properly.
> Which reminds me that it actually will break if linesize is odd - does
> that matter?
I don't think linesize can be odd with 2 bytes per pixel grayscale, can it?
> > + if(s->maxval >= 256 && avctx->pix_fmt == PIX_FMT_GRAY8)
> > avctx->pix_fmt = PIX_FMT_GRAY16BE;
> > }
> > /* more check if YUV420 */
> > @@ -259,6 +261,21 @@
> > }
> > break;
> > }
> > + /* upgrade values to full range of PIX_FMT */
> > + if (avctx->pix_fmt == PIX_FMT_GRAY8 && s->maxval < 255) {
> > + unsigned int j, f = (255*128 + s->maxval/2) / s->maxval;
> > + for(ptr = p->data[0], i = 0; i < avctx->height; i++, ptr +=
> > linesize) + for(j = 0; j < avctx->width; j++)
> > + ptr[j] = (ptr[j] * f + 64)>>7;
> > + } else if (avctx->pix_fmt == PIX_FMT_GRAY16BE && s->maxval <
> > 65535) { + unsigned int j, val, f = (65535*32768 + s->maxval/2)
> > / s->maxval; + for(ptr = p->data[0], i = 0; i < avctx->height;
> > i++, ptr += linesize) + for(j = 0; j < avctx->width; j++) {
> > + val = be2me_16(((uint16_t *)ptr)[j]);
> > + ((uint16_t *)ptr)[j] = (val * f + 16384)>>15;
> > + }
> > + avctx->pix_fmt = PIX_FMT_GRAY16;
>
> Hmm... does that work for more than one frame? I think the if above must
> then check for
> avctx->pix_fmt == PIX_FMT_GRAY16BE || avctx->pix_fmt == PIX_FMT_GRAY16
> Or maybe avctx->pix_fmt != PIX_FMT_GRAY8
I see. pix_fmt will stay changed after the first run. Fixed.
--Ivo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: maxval.patch
Type: text/x-diff
Size: 1709 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070409/6d81d0b0/attachment.patch>
More information about the ffmpeg-devel
mailing list