From b5f536d24b5ae360503935c34d5d59fa5181b94d Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Fri, 22 Feb 2013 11:57:59 +0100 Subject: pnm: add high-bitdepth PGMYUV support for both encoder and decoder --- libavcodec/pnm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'libavcodec/pnm.c') diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c index 5d1365090e..094e03d8fa 100644 --- a/libavcodec/pnm.c +++ b/libavcodec/pnm.c @@ -157,6 +157,13 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s) } else if (avctx->pix_fmt == AV_PIX_FMT_RGB24) { if (s->maxval > 255) avctx->pix_fmt = AV_PIX_FMT_RGB48BE; + } else if (avctx->pix_fmt == AV_PIX_FMT_YUV420P && s->maxval < 65536) { + if (s->maxval < 512) + avctx->pix_fmt = AV_PIX_FMT_YUV420P9BE; + else if (s->maxval < 1024) + avctx->pix_fmt = AV_PIX_FMT_YUV420P10BE; + else + avctx->pix_fmt = AV_PIX_FMT_YUV420P16; } else { av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format\n"); avctx->pix_fmt = AV_PIX_FMT_NONE; @@ -166,7 +173,7 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s) }else s->maxval=1; /* more check if YUV420 */ - if (avctx->pix_fmt == AV_PIX_FMT_YUV420P) { + if (av_pix_fmt_descriptors[avctx->pix_fmt].flags & PIX_FMT_PLANAR) { if ((avctx->width & 1) != 0) return AVERROR_INVALIDDATA; h = (avctx->height * 2); -- cgit v1.2.3