[FFmpeg-devel] [PATCH]Fix 32bit pam decoding
Carl Eugen Hoyos
cehoyos at ag.or.at
Mon Jan 16 15:22:13 CET 2012
Hi!
Attached patch fixes decoding of 32bit pam images.
Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c
index fa43c8d..2446e41 100644
--- a/libavcodec/pnm.c
+++ b/libavcodec/pnm.c
@@ -126,7 +126,7 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
}
} else if (depth == 4) {
if (maxval < 256) {
- avctx->pix_fmt = PIX_FMT_RGB32;
+ avctx->pix_fmt = PIX_FMT_RGBA;
} else {
av_log(avctx, AV_LOG_ERROR, "Unsupported bit depth\n");
return -1;
diff --git a/libavcodec/pnmdec.c b/libavcodec/pnmdec.c
index dc64f9b..0de9ce6 100644
--- a/libavcodec/pnmdec.c
+++ b/libavcodec/pnmdec.c
@@ -63,6 +63,11 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data,
components=3;
sample_len=16;
goto do_read;
+ case PIX_FMT_RGBA:
+ n = avctx->width * 4;
+ components=4;
+ sample_len=8;
+ goto do_read;
case PIX_FMT_RGB24:
n = avctx->width * 3;
components=3;
@@ -168,24 +173,6 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data,
}
}
break;
- case PIX_FMT_RGB32:
- ptr = p->data[0];
- linesize = p->linesize[0];
- if (s->bytestream + avctx->width * avctx->height * 4 > s->bytestream_end)
- return -1;
- for (i = 0; i < avctx->height; i++) {
- int j, r, g, b, a;
-
- for (j = 0; j < avctx->width; j++) {
- r = *s->bytestream++;
- g = *s->bytestream++;
- b = *s->bytestream++;
- a = *s->bytestream++;
- ((uint32_t *)ptr)[j] = (a << 24) | (r << 16) | (g << 8) | b;
- }
- ptr += linesize;
- }
- break;
}
*picture = *(AVFrame*)&s->picture;
*data_size = sizeof(AVPicture);
More information about the ffmpeg-devel
mailing list