summaryrefslogtreecommitdiff
path: root/libavcodec/pnm.c
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2013-02-22 11:57:59 +0100
committerKostya Shishkov <kostya.shishkov@gmail.com>2013-02-23 16:49:22 +0100
commitb5f536d24b5ae360503935c34d5d59fa5181b94d (patch)
tree3f4700246c9c1194ffff6cd779c7aa57d7fc06ef /libavcodec/pnm.c
parent2f325a6fd4421c4dd4e26d7065e5d4bf26ed52f2 (diff)
pnm: add high-bitdepth PGMYUV support for both encoder and decoder
Diffstat (limited to 'libavcodec/pnm.c')
-rw-r--r--libavcodec/pnm.c9
1 files changed, 8 insertions, 1 deletions
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);