diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-02-24 17:14:28 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-02-24 17:14:28 +0400 |
commit | 198ea7a96f64b60d26068ac30605d5b50245abeb (patch) | |
tree | f3733ea0f10027eebe49df94826e46e52e907b3d /libavcodec/pnmenc.c | |
parent | a77a27a24b27fc29d119b00866740e4d0b69ba28 (diff) | |
parent | b5f536d24b5ae360503935c34d5d59fa5181b94d (diff) |
Merge commit 'b5f536d24b5ae360503935c34d5d59fa5181b94d'
* commit 'b5f536d24b5ae360503935c34d5d59fa5181b94d':
pnm: add high-bitdepth PGMYUV support for both encoder and decoder
Conflicts:
libavcodec/pnm.c
libavcodec/pnmdec.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/pnmenc.c')
-rw-r--r-- | libavcodec/pnmenc.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/libavcodec/pnmenc.c b/libavcodec/pnmenc.c index ab20cf558f..47e91f4efd 100644 --- a/libavcodec/pnmenc.c +++ b/libavcodec/pnmenc.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/pixdesc.h" #include "avcodec.h" #include "internal.h" #include "pnm.h" @@ -77,6 +78,11 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt, n = avctx->width; h1 = (h * 3) / 2; break; + case AV_PIX_FMT_YUV420P16BE: + c = '5'; + n = avctx->width * 2; + h1 = (h * 3) / 2; + break; default: return -1; } @@ -84,8 +90,9 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt, "P%c\n%d %d\n", c, avctx->width, h1); s->bytestream += strlen(s->bytestream); if (avctx->pix_fmt != AV_PIX_FMT_MONOWHITE) { + int maxdepth = (1 << (av_pix_fmt_descriptors[avctx->pix_fmt].comp[0].depth_minus1 + 1)) - 1; snprintf(s->bytestream, s->bytestream_end - s->bytestream, - "%d\n", (avctx->pix_fmt != AV_PIX_FMT_GRAY16BE && avctx->pix_fmt != AV_PIX_FMT_RGB48BE) ? 255 : 65535); + "%d\n", maxdepth); s->bytestream += strlen(s->bytestream); } @@ -97,7 +104,7 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt, ptr += linesize; } - if (avctx->pix_fmt == AV_PIX_FMT_YUV420P) { + if (avctx->pix_fmt == AV_PIX_FMT_YUV420P || avctx->pix_fmt == AV_PIX_FMT_YUV420P16BE) { h >>= 1; n >>= 1; ptr1 = p->data[1]; @@ -142,7 +149,9 @@ AVCodec ff_pgmyuv_encoder = { .priv_data_size = sizeof(PNMContext), .init = ff_pnm_init, .encode2 = pnm_encode_frame, - .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, + .pix_fmts = (const enum AVPixelFormat[]){ + AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV420P16BE, AV_PIX_FMT_NONE + }, .long_name = NULL_IF_CONFIG_SMALL("PGMYUV (Portable GrayMap YUV) image"), }; #endif |