[FFmpeg-devel] [PATCH 3/4] avcodec/nvdec: add support for 12 bit formats

Timo Rothenpieler timo at rothenpieler.org
Sat Nov 11 17:21:38 EET 2017


---
 libavcodec/nvdec.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c
index 780c2e67cf..d3620f0d1f 100644
--- a/libavcodec/nvdec.c
+++ b/libavcodec/nvdec.c
@@ -234,9 +234,21 @@ int ff_nvdec_decode_init(AVCodecContext *avctx, unsigned int dpb_size)
         frames_ctx->format            = AV_PIX_FMT_CUDA;
         frames_ctx->width             = (avctx->width + 1) & ~1;
         frames_ctx->height            = (avctx->height + 1) & ~1;
-        frames_ctx->sw_format         = AV_PIX_FMT_NV12;
-        frames_ctx->sw_format         = sw_desc->comp[0].depth > 8 ?
-                                        AV_PIX_FMT_P010 : AV_PIX_FMT_NV12;
+
+        switch (sw_desc->comp[0].depth) {
+        case 8:
+            frames_ctx->sw_format = AV_PIX_FMT_NV12;
+            break;
+        case 10:
+            frames_ctx->sw_format = AV_PIX_FMT_P010;
+            break;
+        case 12:
+            frames_ctx->sw_format = AV_PIX_FMT_P016;
+            break;
+        default:
+            return AVERROR(EINVAL);
+        }
+
         frames_ctx->initial_pool_size = dpb_size;
 
         ret = av_hwframe_ctx_init(avctx->hw_frames_ctx);
-- 
2.14.2



More information about the ffmpeg-devel mailing list