[FFmpeg-devel] [PATCH 2/2] avcodec/nvenc: Accept P016 content

Philip Langdale philipl at overt.org
Mon Nov 21 17:28:04 EET 2016


nvenc doesn't officially support P016 input, but at the same time,
cuvid only outputs P016, technically (it uses the same format for
both 10 and 12 bit output). As it's safe to pass P016 when P010 is
expected, let's just allow it; it's wasteful to force content through
swscale.

After this change, both cuvid and nvenc support P016, but the
ffmpeg_cuvid transcoding logic will need more work to connect the
two together. Similarly, the scale_npp filter still only works with
8bit surfaces.

Signed-off-by: Philip Langdale <philipl at overt.org>
---
 libavcodec/nvenc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index d71a445..ba8fdfd 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -39,6 +39,7 @@ const enum AVPixelFormat ff_nvenc_pix_fmts[] = {
     AV_PIX_FMT_YUV420P,
     AV_PIX_FMT_NV12,
     AV_PIX_FMT_P010,
+    AV_PIX_FMT_P016,
     AV_PIX_FMT_YUV444P,
     AV_PIX_FMT_YUV444P16,
     AV_PIX_FMT_0RGB32,
@@ -48,6 +49,7 @@ const enum AVPixelFormat ff_nvenc_pix_fmts[] = {
 };
 
 #define IS_10BIT(pix_fmt) (pix_fmt == AV_PIX_FMT_P010 ||    \
+                           pix_fmt == AV_PIX_FMT_P016 ||    \
                            pix_fmt == AV_PIX_FMT_YUV444P16)
 
 #define IS_YUV444(pix_fmt) (pix_fmt == AV_PIX_FMT_YUV444P || \
@@ -1018,6 +1020,7 @@ static av_cold int nvenc_alloc_surface(AVCodecContext *avctx, int idx)
         break;
 
     case AV_PIX_FMT_P010:
+    case AV_PIX_FMT_P016:
         ctx->surfaces[idx].format = NV_ENC_BUFFER_FORMAT_YUV420_10BIT;
         break;
 
-- 
2.9.3


More information about the ffmpeg-devel mailing list