]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/nvenc_hevc.c
nvenc: factor out the pixel format list
[ffmpeg] / libavcodec / nvenc_hevc.c
index a862428905c38d28e0eb292bfe6b85922890a568..f0c6d41b8323b827a3608c53fc3803d6cb728028 100644 (file)
@@ -89,7 +89,7 @@ static const AVCodecDefault defaults[] = {
 };
 
 AVCodec ff_hevc_nvenc_encoder = {
-    .name           = "nvenc_hevc",
+    .name           = "hevc_nvenc",
     .long_name      = NULL_IF_CONFIG_SMALL("NVIDIA NVENC HEVC encoder"),
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = AV_CODEC_ID_HEVC,
@@ -99,10 +99,39 @@ AVCodec ff_hevc_nvenc_encoder = {
     .priv_data_size = sizeof(NVENCContext),
     .priv_class     = &nvenc_hevc_class,
     .defaults       = defaults,
-    .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
-                                                    AV_PIX_FMT_YUV420P,
-                                                    AV_PIX_FMT_YUV444P,
-                                                    AV_PIX_FMT_NONE },
-    .capabilities   = CODEC_CAP_DELAY,
+    .pix_fmts       = ff_nvenc_pix_fmts,
+    .capabilities   = AV_CODEC_CAP_DELAY,
+    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+};
+
+#if FF_API_NVENC_OLD_NAME
+
+static int nvenc_old_init(AVCodecContext *avctx)
+{
+    av_log(avctx, AV_LOG_WARNING, "This encoder is deprecated, use 'hevc_nvenc' instead\n");
+    return ff_nvenc_encode_init(avctx);
+}
+
+static const AVClass nvenc_hevc_old_class = {
+    .class_name = "nvenc_hevc",
+    .item_name = av_default_item_name,
+    .option = options,
+    .version = LIBAVUTIL_VERSION_INT,
+};
+
+AVCodec ff_nvenc_hevc_encoder = {
+    .name           = "nvenc_hevc",
+    .long_name      = NULL_IF_CONFIG_SMALL("NVIDIA NVENC HEVC encoder"),
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = AV_CODEC_ID_HEVC,
+    .init           = nvenc_old_init,
+    .encode2        = ff_nvenc_encode_frame,
+    .close          = ff_nvenc_encode_close,
+    .priv_data_size = sizeof(NVENCContext),
+    .priv_class     = &nvenc_hevc_old_class,
+    .defaults       = defaults,
+    .pix_fmts       = ff_nvenc_pix_fmts,
+    .capabilities   = AV_CODEC_CAP_DELAY,
     .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
+#endif