[FFmpeg-devel] [PATCH]Assume GRAY8 if 1 < maxval < 255 in pnm

Carl Eugen Hoyos cehoyos at ag.or.at
Sun Jul 28 17:48:02 CEST 2013


HI!

Attached patch is untested (I don't know how to produce a sample) but 
I think pnm with maxval < 256 should never be interpreted as gray16.

Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c
index 308457b..6e2e96c 100644
--- a/libavcodec/pnm.c
+++ b/libavcodec/pnm.c
@@ -116,7 +116,7 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
         if (depth == 1) {
             if (maxval == 1) {
                 avctx->pix_fmt = AV_PIX_FMT_MONOBLACK;
-            } else if (maxval == 255) {
+            } else if (maxval < 256) {
                 avctx->pix_fmt = AV_PIX_FMT_GRAY8;
             } else {
                 avctx->pix_fmt = AV_PIX_FMT_GRAY16BE;


More information about the ffmpeg-devel mailing list