[Ffmpeg-devel] [PATCH/RFC] 1-7 and 9-15 bits per pixel PGM files
Reimar Döffinger
Reimar.Doeffinger
Mon Apr 9 11:08:03 CEST 2007
Hello,
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?
[...]
> + 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
Greetings,
Reimar D?ffinger
More information about the ffmpeg-devel
mailing list