From 1f481fe1d5bcb782c46f4d3d192c29ac4e858dbe Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Mon, 20 Jan 2025 04:52:00 +0900 Subject: [PATCH] nvcodec: Specify documentation caps ... since produced caps will be different depending on OS and GPU model. Also adding Y444_16LE format to decoder's GL template caps Part-of: --- .../sys/nvcodec/gstnvav1dec.cpp | 39 ++++++++++++--- .../sys/nvcodec/gstnvav1encoder.cpp | 46 +++++++++++++++--- .../sys/nvcodec/gstnvdecoder.cpp | 1 + .../sys/nvcodec/gstnvh264dec.cpp | 43 +++++++++++++---- .../sys/nvcodec/gstnvh264encoder.cpp | 48 ++++++++++++++++--- .../sys/nvcodec/gstnvh265dec.cpp | 44 ++++++++++++++--- .../sys/nvcodec/gstnvh265encoder.cpp | 48 ++++++++++++++++--- .../sys/nvcodec/gstnvvp8dec.cpp | 37 +++++++++++--- .../sys/nvcodec/gstnvvp9dec.cpp | 39 ++++++++++++--- 9 files changed, 295 insertions(+), 50 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvav1dec.cpp b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvav1dec.cpp index b9a8cffda6..b36aaee327 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvav1dec.cpp +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvav1dec.cpp @@ -44,6 +44,26 @@ GST_DEBUG_CATEGORY_STATIC (gst_nv_av1_dec_debug); #define GST_CAT_DEFAULT gst_nv_av1_dec_debug +#define DOC_SINK_CAPS \ + "video/x-av1, width = (int) [ 128, 8192 ], height = (int) [ 128, 8192 ], " \ + "alignment= (string) frame, " \ + "profile = (string) main" + +#define DOC_SRC_CAPS_COMM \ + "format = (string) { NV12, P010_10LE }, " \ + "width = (int) [ 128, 8192 ], height = (int) [ 128, 8192 ]" + +#define DOC_SRC_CAPS_D3D11 \ + "format = (string) { I420, I420_10LE }, " \ + "width = (int) [ 128, 8192 ], height = (int) [ 128, 8192 ]" + +#define DOC_SRC_CAPS \ + "video/x-raw(memory:CUDAMemory), " DOC_SRC_CAPS_COMM "; " \ + "video/x-raw(memory:D3D12Memory), " DOC_SRC_CAPS_COMM "; " \ + "video/x-raw(memory:D3D11Memory), " DOC_SRC_CAPS_D3D11 "; " \ + "video/x-raw(memory:GLMemory), " DOC_SRC_CAPS_COMM "; " \ + "video/x-raw, " DOC_SRC_CAPS_COMM + typedef struct _GstNvAV1Dec { GstAV1Decoder parent; @@ -229,12 +249,19 @@ gst_nv_av1_dec_class_init (GstNvAV1DecClass * klass, "Codec/Decoder/Video/Hardware", "NVIDIA AV1 video decoder", "Seungha Yang "); - gst_element_class_add_pad_template (element_class, - gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - cdata->sink_caps)); - gst_element_class_add_pad_template (element_class, - gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - cdata->src_caps)); + auto pad_templ = gst_pad_template_new ("sink", + GST_PAD_SINK, GST_PAD_ALWAYS, cdata->sink_caps); + auto doc_caps = gst_caps_from_string (DOC_SINK_CAPS); + gst_pad_template_set_documentation_caps (pad_templ, doc_caps); + gst_caps_unref (doc_caps); + gst_element_class_add_pad_template (element_class, pad_templ); + + pad_templ = gst_pad_template_new ("src", + GST_PAD_SRC, GST_PAD_ALWAYS, cdata->src_caps); + doc_caps = gst_caps_from_string (DOC_SRC_CAPS); + gst_pad_template_set_documentation_caps (pad_templ, doc_caps); + gst_caps_unref (doc_caps); + gst_element_class_add_pad_template (element_class, pad_templ); decoder_class->open = GST_DEBUG_FUNCPTR (gst_nv_av1_dec_open); decoder_class->close = GST_DEBUG_FUNCPTR (gst_nv_av1_dec_close); diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvav1encoder.cpp b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvav1encoder.cpp index 9418c20243..a8cad8315f 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvav1encoder.cpp +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvav1encoder.cpp @@ -30,6 +30,30 @@ GST_DEBUG_CATEGORY_STATIC (gst_nv_av1_encoder_debug); #define GST_CAT_DEFAULT gst_nv_av1_encoder_debug +#define DOC_SINK_CAPS_COMM \ + "format = (string) { NV12, P010_10LE, VUYA, RGBA, RGBx, BGRA, BGRx, RGB10A2_LE }, " \ + "width = (int) [ 192, 8192 ], height = (int) [ 128, 8192 ]" + +#define DOC_SINK_CAPS \ + "video/x-raw(memory:CUDAMemory), " DOC_SINK_CAPS_COMM "; " \ + "video/x-raw(memory:D3D12Memory), " DOC_SINK_CAPS_COMM "; " \ + "video/x-raw(memory:GLMemory), " DOC_SINK_CAPS_COMM "; " \ + "video/x-raw, " DOC_SINK_CAPS_COMM + +#define DOC_SINK_CAPS_D3D11 \ + "video/x-raw(memory:D3D11Memory), " DOC_SINK_CAPS_COMM "; " \ + "video/x-raw, " DOC_SINK_CAPS_COMM + +#define DOC_SINK_CAPS_AUTOGPU \ + "video/x-raw(memory:CUDAMemory), " DOC_SINK_CAPS_COMM "; " \ + "video/x-raw(memory:D3D11Memory), " DOC_SINK_CAPS_COMM "; " \ + "video/x-raw(memory:GLMemory), " DOC_SINK_CAPS_COMM "; " \ + "video/x-raw, " DOC_SINK_CAPS_COMM + +#define DOC_SRC_CAPS \ + "video/x-av1, width = (int) [ 192, 8192 ], height = (int) [ 128, 8192 ], " \ + "profile = (string) main, alignment = (string) tu, stream-format = (string) obu-stream" + static GTypeClass *parent_class = nullptr; enum @@ -383,6 +407,9 @@ gst_nv_av1_encoder_class_init (GstNvAv1EncoderClass * klass, gpointer data) "Target Constant Quality level for VBR mode (0 = automatic)", 0, 51, DEFAULT_CONST_QUALITY, param_flags)); + GstPadTemplate *pad_templ = gst_pad_template_new ("sink", + GST_PAD_SINK, GST_PAD_ALWAYS, cdata->sink_caps); + GstCaps *doc_caps = nullptr; switch (cdata->device_mode) { case GST_NV_ENCODER_DEVICE_CUDA: gst_element_class_set_static_metadata (element_class, @@ -390,6 +417,7 @@ gst_nv_av1_encoder_class_init (GstNvAv1EncoderClass * klass, gpointer data) "Codec/Encoder/Video/Hardware", "Encode AV1 video streams using NVCODEC API CUDA Mode", "Seungha Yang "); + doc_caps = gst_caps_from_string (DOC_SINK_CAPS); break; case GST_NV_ENCODER_DEVICE_D3D11: gst_element_class_set_static_metadata (element_class, @@ -397,6 +425,7 @@ gst_nv_av1_encoder_class_init (GstNvAv1EncoderClass * klass, gpointer data) "Codec/Encoder/Video/Hardware", "Encode AV1 video streams using NVCODEC API Direct3D11 Mode", "Seungha Yang "); + doc_caps = gst_caps_from_string (DOC_SINK_CAPS_D3D11); break; case GST_NV_ENCODER_DEVICE_AUTO_SELECT: gst_element_class_set_static_metadata (element_class, @@ -404,18 +433,23 @@ gst_nv_av1_encoder_class_init (GstNvAv1EncoderClass * klass, gpointer data) "Codec/Encoder/Video/Hardware", "Encode AV1 video streams using NVCODEC API auto GPU select Mode", "Seungha Yang "); + doc_caps = gst_caps_from_string (DOC_SINK_CAPS_AUTOGPU); break; default: g_assert_not_reached (); break; } - gst_element_class_add_pad_template (element_class, - gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - cdata->sink_caps)); - gst_element_class_add_pad_template (element_class, - gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - cdata->src_caps)); + gst_pad_template_set_documentation_caps (pad_templ, doc_caps); + gst_caps_unref (doc_caps); + gst_element_class_add_pad_template (element_class, pad_templ); + + pad_templ = gst_pad_template_new ("src", + GST_PAD_SRC, GST_PAD_ALWAYS, cdata->src_caps); + doc_caps = gst_caps_from_string (DOC_SRC_CAPS); + gst_pad_template_set_documentation_caps (pad_templ, doc_caps); + gst_caps_unref (doc_caps); + gst_element_class_add_pad_template (element_class, pad_templ); nvenc_class->set_format = GST_DEBUG_FUNCPTR (gst_nv_av1_encoder_set_format); nvenc_class->set_output_state = diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.cpp b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.cpp index 8bf4deaad5..222c08f4ae 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.cpp +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvdecoder.cpp @@ -1547,6 +1547,7 @@ gst_nv_decoder_check_device_caps (GstCudaContext * context, APPEND_STRING (format_str, formats, "P010_10LE"); APPEND_STRING (format_str, formats, "P012_LE"); APPEND_STRING (format_str, formats, "Y444"); + APPEND_STRING (format_str, formats, "Y444_16LE"); APPEND_STRING (format_str, formats, "GBR"); format_str += " }"; } diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264dec.cpp b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264dec.cpp index cc62faa226..7cecf4d03d 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264dec.cpp +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264dec.cpp @@ -97,6 +97,27 @@ GST_DEBUG_CATEGORY_STATIC (gst_nv_h264_dec_debug); #define GST_CAT_DEFAULT gst_nv_h264_dec_debug +#define DOC_SINK_CAPS \ + "video/x-h264, width = (int) [ 48, 4096 ], height = (int) [ 16, 4096 ], " \ + "stream-format= (string) { avc, avc3, byte-stream }, " \ + "alignment= (string) au, " \ + "profile = (string) { high, main, constrained-high, constrained-baseline, baseline, progressive-high }" + +#define DOC_SRC_CAPS_COMM \ + "format = (string) NV12, " \ + "width = (int) [ 48, 4096 ], height = (int) [ 16, 4096 ]" + +#define DOC_SRC_CAPS_D3D11 \ + "format = (string) NV12, " \ + "width = (int) [ 48, 4096 ], height = (int) [ 16, 4096 ]" + +#define DOC_SRC_CAPS \ + "video/x-raw(memory:CUDAMemory), " DOC_SRC_CAPS_COMM "; " \ + "video/x-raw(memory:D3D12Memory), " DOC_SRC_CAPS_COMM "; " \ + "video/x-raw(memory:D3D11Memory), " DOC_SRC_CAPS_D3D11 "; " \ + "video/x-raw(memory:GLMemory), " DOC_SRC_CAPS_COMM "; " \ + "video/x-raw, " DOC_SRC_CAPS_COMM + typedef struct _GstNvH264Dec { GstH264Decoder parent; @@ -297,12 +318,19 @@ gst_nv_h264_dec_class_init (GstNvH264DecClass * klass, "Codec/Decoder/Video/Hardware", "NVIDIA H.264 video decoder", "Seungha Yang "); - gst_element_class_add_pad_template (element_class, - gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - cdata->sink_caps)); - gst_element_class_add_pad_template (element_class, - gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - cdata->src_caps)); + auto pad_templ = gst_pad_template_new ("sink", + GST_PAD_SINK, GST_PAD_ALWAYS, cdata->sink_caps); + auto doc_caps = gst_caps_from_string (DOC_SINK_CAPS); + gst_pad_template_set_documentation_caps (pad_templ, doc_caps); + gst_caps_unref (doc_caps); + gst_element_class_add_pad_template (element_class, pad_templ); + + pad_templ = gst_pad_template_new ("src", + GST_PAD_SRC, GST_PAD_ALWAYS, cdata->src_caps); + doc_caps = gst_caps_from_string (DOC_SRC_CAPS); + gst_pad_template_set_documentation_caps (pad_templ, doc_caps); + gst_caps_unref (doc_caps); + gst_element_class_add_pad_template (element_class, pad_templ); decoder_class->open = GST_DEBUG_FUNCPTR (gst_nv_h264_dec_open); decoder_class->close = GST_DEBUG_FUNCPTR (gst_nv_h264_dec_close); @@ -1075,8 +1103,7 @@ gst_nv_h264_dec_register (GstPlugin * plugin, guint device_id, cdata->sink_caps = gst_caps_from_string ("video/x-h264, " "stream-format= (string) { avc, avc3, byte-stream }, " "alignment= (string) au, " - "profile = (string) { high, main, constrained-high, constrained-baseline, baseline, progressive-high }, " - "framerate = " GST_VIDEO_FPS_RANGE); + "profile = (string) { high, main, constrained-high, constrained-baseline, baseline, progressive-high }"); s = gst_caps_get_structure (sink_caps, 0); value = gst_structure_get_value (s, "width"); diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264encoder.cpp b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264encoder.cpp index b0aac116fc..ab1d06287d 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264encoder.cpp +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh264encoder.cpp @@ -48,6 +48,32 @@ GST_DEBUG_CATEGORY_STATIC (gst_nv_h264_encoder_debug); #define GST_CAT_DEFAULT gst_nv_h264_encoder_debug +#define DOC_SINK_CAPS_COMM \ + "format = (string) { NV12, Y444, VUYA, RGBA, RGBx, BGRA, BGRx }, " \ + "width = (int) [ 160, 4096 ], height = (int) [ 64, 4096 ], " \ + "interlace-mode = (string) progressive" + +#define DOC_SINK_CAPS \ + "video/x-raw(memory:CUDAMemory), " DOC_SINK_CAPS_COMM "; " \ + "video/x-raw(memory:D3D12Memory), " DOC_SINK_CAPS_COMM "; " \ + "video/x-raw(memory:GLMemory), " DOC_SINK_CAPS_COMM "; " \ + "video/x-raw, " DOC_SINK_CAPS_COMM + +#define DOC_SINK_CAPS_D3D11 \ + "video/x-raw(memory:D3D11Memory), " DOC_SINK_CAPS_COMM "; " \ + "video/x-raw, " DOC_SINK_CAPS_COMM + +#define DOC_SINK_CAPS_AUTOGPU \ + "video/x-raw(memory:CUDAMemory), " DOC_SINK_CAPS_COMM "; " \ + "video/x-raw(memory:D3D11Memory), " DOC_SINK_CAPS_COMM "; " \ + "video/x-raw(memory:GLMemory), " DOC_SINK_CAPS_COMM "; " \ + "video/x-raw, " DOC_SINK_CAPS_COMM + +#define DOC_SRC_CAPS \ + "video/x-h264, width = (int) [ 160, 4096 ], height = (int) [ 64, 4096 ], " \ + "profile = (string) { main, high, constrained-baseline, baseline, high-4:4:4 }, " \ + "stream-format = (string) { byte-stream, avc }, alignment = (string) au" + static GTypeClass *parent_class = nullptr; enum @@ -487,6 +513,9 @@ gst_nv_h264_encoder_class_init (GstNvH264EncoderClass * klass, gpointer data) "Insert sequence headers (SPS/PPS) per IDR", DEFAULT_REPEAT_SEQUENCE_HEADER, param_flags)); + GstPadTemplate *pad_templ = gst_pad_template_new ("sink", + GST_PAD_SINK, GST_PAD_ALWAYS, cdata->sink_caps); + GstCaps *doc_caps = nullptr; switch (cdata->device_mode) { case GST_NV_ENCODER_DEVICE_CUDA: gst_element_class_set_static_metadata (element_class, @@ -494,6 +523,7 @@ gst_nv_h264_encoder_class_init (GstNvH264EncoderClass * klass, gpointer data) "Codec/Encoder/Video/Hardware", "Encode H.264 video streams using NVCODEC API CUDA Mode", "Seungha Yang "); + doc_caps = gst_caps_from_string (DOC_SINK_CAPS); break; case GST_NV_ENCODER_DEVICE_D3D11: gst_element_class_set_static_metadata (element_class, @@ -501,6 +531,7 @@ gst_nv_h264_encoder_class_init (GstNvH264EncoderClass * klass, gpointer data) "Codec/Encoder/Video/Hardware", "Encode H.264 video streams using NVCODEC API Direct3D11 Mode", "Seungha Yang "); + doc_caps = gst_caps_from_string (DOC_SINK_CAPS_D3D11); break; case GST_NV_ENCODER_DEVICE_AUTO_SELECT: gst_element_class_set_static_metadata (element_class, @@ -508,18 +539,23 @@ gst_nv_h264_encoder_class_init (GstNvH264EncoderClass * klass, gpointer data) "Codec/Encoder/Video/Hardware", "Encode H.264 video streams using NVCODEC API auto GPU select Mode", "Seungha Yang "); + doc_caps = gst_caps_from_string (DOC_SINK_CAPS_AUTOGPU); break; default: g_assert_not_reached (); break; } - gst_element_class_add_pad_template (element_class, - gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - cdata->sink_caps)); - gst_element_class_add_pad_template (element_class, - gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - cdata->src_caps)); + gst_pad_template_set_documentation_caps (pad_templ, doc_caps); + gst_caps_unref (doc_caps); + gst_element_class_add_pad_template (element_class, pad_templ); + + pad_templ = gst_pad_template_new ("src", + GST_PAD_SRC, GST_PAD_ALWAYS, cdata->src_caps); + doc_caps = gst_caps_from_string (DOC_SRC_CAPS); + gst_pad_template_set_documentation_caps (pad_templ, doc_caps); + gst_caps_unref (doc_caps); + gst_element_class_add_pad_template (element_class, pad_templ); videoenc_class->getcaps = GST_DEBUG_FUNCPTR (gst_nv_h264_encoder_getcaps); videoenc_class->stop = GST_DEBUG_FUNCPTR (gst_nv_h264_encoder_stop); diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265dec.cpp b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265dec.cpp index 5d8e46404d..989c6fa0d4 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265dec.cpp +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265dec.cpp @@ -98,6 +98,31 @@ GST_DEBUG_CATEGORY_STATIC (gst_nv_h265_dec_debug); #define GST_CAT_DEFAULT gst_nv_h265_dec_debug +#define DOC_SINK_CAPS \ + "video/x-h265, width = (int) [ 144, 8192 ], height = (int) [ 144, 8192 ], " \ + "stream-format= (string) { hev1, hvc1, byte-stream }, " \ + "alignment= (string) au, " \ + "profile = (string) { main, main-10, main-12, main-444, main-444-10, main-444-12 }" + +#define DOC_SRC_CAPS_COMM \ + "format = (string) { NV12, P010_10LE, P012_LE, Y444, Y444_16LE, GBR, GBR_16LE }, " \ + "width = (int) [ 144, 8192 ], height = (int) [ 144, 8192 ]" + +#define DOC_SRC_CAPS_D3D11 \ + "format = (string) { I420, I420_10LE, I420_12LE, Y444, Y444_16LE, GBR, GBR_16LE }, " \ + "width = (int) [ 144, 8192 ], height = (int) [ 144, 8192 ]" + +#define DOC_SRC_CAPS_GL \ + "format = (string) { I420, I420_10LE, I420_12LE, Y444, Y444_16LE, GBR }, " \ + "width = (int) [ 144, 8192 ], height = (int) [ 144, 8192 ]" + +#define DOC_SRC_CAPS \ + "video/x-raw(memory:CUDAMemory), " DOC_SRC_CAPS_COMM "; " \ + "video/x-raw(memory:D3D12Memory), " DOC_SRC_CAPS_COMM "; " \ + "video/x-raw(memory:D3D11Memory), " DOC_SRC_CAPS_D3D11 "; " \ + "video/x-raw(memory:GLMemory), " DOC_SRC_CAPS_GL "; " \ + "video/x-raw, " DOC_SRC_CAPS_COMM + typedef struct _GstNvH265Dec { GstH265Decoder parent; @@ -293,12 +318,19 @@ gst_nv_h265_dec_class_init (GstNvH265DecClass * klass, "Codec/Decoder/Video/Hardware", "NVIDIA H.265 video decoder", "Seungha Yang "); - gst_element_class_add_pad_template (element_class, - gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - cdata->sink_caps)); - gst_element_class_add_pad_template (element_class, - gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - cdata->src_caps)); + auto pad_templ = gst_pad_template_new ("sink", + GST_PAD_SINK, GST_PAD_ALWAYS, cdata->sink_caps); + auto doc_caps = gst_caps_from_string (DOC_SINK_CAPS); + gst_pad_template_set_documentation_caps (pad_templ, doc_caps); + gst_caps_unref (doc_caps); + gst_element_class_add_pad_template (element_class, pad_templ); + + pad_templ = gst_pad_template_new ("src", + GST_PAD_SRC, GST_PAD_ALWAYS, cdata->src_caps); + doc_caps = gst_caps_from_string (DOC_SRC_CAPS); + gst_pad_template_set_documentation_caps (pad_templ, doc_caps); + gst_caps_unref (doc_caps); + gst_element_class_add_pad_template (element_class, pad_templ); decoder_class->open = GST_DEBUG_FUNCPTR (gst_nv_h265_dec_open); decoder_class->close = GST_DEBUG_FUNCPTR (gst_nv_h265_dec_close); diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265encoder.cpp b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265encoder.cpp index ababef0942..e736d2f347 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265encoder.cpp +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvh265encoder.cpp @@ -48,6 +48,32 @@ GST_DEBUG_CATEGORY_STATIC (gst_nv_h265_encoder_debug); #define GST_CAT_DEFAULT gst_nv_h265_encoder_debug +#define DOC_SINK_CAPS_COMM \ + "format = (string) { NV12, P010_10LE, Y444, Y444_16LE, GBR, GBR_16LE, VUYA, RGBA, RGBx, BGRA, BGRx, RGB10A2_LE }, " \ + "width = (int) [ 144, 8192 ], height = (int) [ 48, 8192 ], " \ + "interlace-mode = (string) progressive" + +#define DOC_SINK_CAPS \ + "video/x-raw(memory:CUDAMemory), " DOC_SINK_CAPS_COMM "; " \ + "video/x-raw(memory:D3D12Memory), " DOC_SINK_CAPS_COMM "; " \ + "video/x-raw(memory:GLMemory), " DOC_SINK_CAPS_COMM "; " \ + "video/x-raw, " DOC_SINK_CAPS_COMM + +#define DOC_SINK_CAPS_D3D11 \ + "video/x-raw(memory:D3D11Memory), " DOC_SINK_CAPS_COMM "; " \ + "video/x-raw, " DOC_SINK_CAPS_COMM + +#define DOC_SINK_CAPS_AUTOGPU \ + "video/x-raw(memory:CUDAMemory), " DOC_SINK_CAPS_COMM "; " \ + "video/x-raw(memory:D3D11Memory), " DOC_SINK_CAPS_COMM "; " \ + "video/x-raw(memory:GLMemory), " DOC_SINK_CAPS_COMM "; " \ + "video/x-raw, " DOC_SINK_CAPS_COMM + +#define DOC_SRC_CAPS \ + "video/x-h265, width = (int) [ 144, 8192 ], height = (int) [ 48, 8192 ], " \ + "profile = (string) { main, main-10, main-444, main-444-10 }, " \ + "stream-format = (string) { byte-stream, hvc1, hev1 }, alignment = (string) au" + static GTypeClass *parent_class = NULL; enum @@ -488,6 +514,9 @@ gst_nv_h265_encoder_class_init (GstNvH265EncoderClass * klass, gpointer data) "ignored if negotiated stream-format is \"hvc1\"", DEFAULT_REPEAT_SEQUENCE_HEADER, param_flags)); + GstPadTemplate *pad_templ = gst_pad_template_new ("sink", + GST_PAD_SINK, GST_PAD_ALWAYS, cdata->sink_caps); + GstCaps *doc_caps = nullptr; switch (cdata->device_mode) { case GST_NV_ENCODER_DEVICE_CUDA: gst_element_class_set_static_metadata (element_class, @@ -495,6 +524,7 @@ gst_nv_h265_encoder_class_init (GstNvH265EncoderClass * klass, gpointer data) "Codec/Encoder/Video/Hardware", "Encode H.265 video streams using NVCODEC API CUDA Mode", "Seungha Yang "); + doc_caps = gst_caps_from_string (DOC_SINK_CAPS); break; case GST_NV_ENCODER_DEVICE_D3D11: gst_element_class_set_static_metadata (element_class, @@ -502,6 +532,7 @@ gst_nv_h265_encoder_class_init (GstNvH265EncoderClass * klass, gpointer data) "Codec/Encoder/Video/Hardware", "Encode H.265 video streams using NVCODEC API Direct3D11 Mode", "Seungha Yang "); + doc_caps = gst_caps_from_string (DOC_SINK_CAPS_D3D11); break; case GST_NV_ENCODER_DEVICE_AUTO_SELECT: gst_element_class_set_static_metadata (element_class, @@ -509,18 +540,23 @@ gst_nv_h265_encoder_class_init (GstNvH265EncoderClass * klass, gpointer data) "Codec/Encoder/Video/Hardware", "Encode H.265 video streams using NVCODEC API auto GPU select Mode", "Seungha Yang "); + doc_caps = gst_caps_from_string (DOC_SINK_CAPS_AUTOGPU); break; default: g_assert_not_reached (); break; } - gst_element_class_add_pad_template (element_class, - gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - cdata->sink_caps)); - gst_element_class_add_pad_template (element_class, - gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - cdata->src_caps)); + gst_pad_template_set_documentation_caps (pad_templ, doc_caps); + gst_caps_unref (doc_caps); + gst_element_class_add_pad_template (element_class, pad_templ); + + pad_templ = gst_pad_template_new ("src", + GST_PAD_SRC, GST_PAD_ALWAYS, cdata->src_caps); + doc_caps = gst_caps_from_string (DOC_SRC_CAPS); + gst_pad_template_set_documentation_caps (pad_templ, doc_caps); + gst_caps_unref (doc_caps); + gst_element_class_add_pad_template (element_class, pad_templ); videoenc_class->getcaps = GST_DEBUG_FUNCPTR (gst_nv_h265_encoder_getcaps); videoenc_class->stop = GST_DEBUG_FUNCPTR (gst_nv_h265_encoder_stop); diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp8dec.cpp b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp8dec.cpp index 0273590ee1..059c7197e9 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp8dec.cpp +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp8dec.cpp @@ -44,6 +44,24 @@ GST_DEBUG_CATEGORY_STATIC (gst_nv_vp8_dec_debug); #define GST_CAT_DEFAULT gst_nv_vp8_dec_debug +#define DOC_SINK_CAPS \ + "video/x-vp8, width = (int) [ 48, 4096 ], height = (int) [ 16, 4096 ]" \ + +#define DOC_SRC_CAPS_COMM \ + "format = (string) NV12, " \ + "width = (int) [ 48, 4096 ], height = (int) [ 16, 4096 ]" + +#define DOC_SRC_CAPS_D3D11 \ + "format = (string) NV12, " \ + "width = (int) [ 48, 4096 ], height = (int) [ 16, 4096 ]" + +#define DOC_SRC_CAPS \ + "video/x-raw(memory:CUDAMemory), " DOC_SRC_CAPS_COMM "; " \ + "video/x-raw(memory:D3D12Memory), " DOC_SRC_CAPS_COMM "; " \ + "video/x-raw(memory:D3D11Memory), " DOC_SRC_CAPS_D3D11 "; " \ + "video/x-raw(memory:GLMemory), " DOC_SRC_CAPS_COMM "; " \ + "video/x-raw, " DOC_SRC_CAPS_COMM + typedef struct _GstNvVp8Dec { GstVp8Decoder parent; @@ -216,12 +234,19 @@ gst_nv_vp8_dec_class_init (GstNvVp8DecClass * klass, "Codec/Decoder/Video/Hardware", "NVIDIA VP8 video decoder", "Seungha Yang "); - gst_element_class_add_pad_template (element_class, - gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - cdata->sink_caps)); - gst_element_class_add_pad_template (element_class, - gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - cdata->src_caps)); + auto pad_templ = gst_pad_template_new ("sink", + GST_PAD_SINK, GST_PAD_ALWAYS, cdata->sink_caps); + auto doc_caps = gst_caps_from_string (DOC_SINK_CAPS); + gst_pad_template_set_documentation_caps (pad_templ, doc_caps); + gst_caps_unref (doc_caps); + gst_element_class_add_pad_template (element_class, pad_templ); + + pad_templ = gst_pad_template_new ("src", + GST_PAD_SRC, GST_PAD_ALWAYS, cdata->src_caps); + doc_caps = gst_caps_from_string (DOC_SRC_CAPS); + gst_pad_template_set_documentation_caps (pad_templ, doc_caps); + gst_caps_unref (doc_caps); + gst_element_class_add_pad_template (element_class, pad_templ); decoder_class->open = GST_DEBUG_FUNCPTR (gst_nv_vp8_dec_open); decoder_class->close = GST_DEBUG_FUNCPTR (gst_nv_vp8_dec_close); diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp9dec.cpp b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp9dec.cpp index 04ca0a7045..0f733e9d81 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp9dec.cpp +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp9dec.cpp @@ -44,6 +44,26 @@ GST_DEBUG_CATEGORY_STATIC (gst_nv_vp9_dec_debug); #define GST_CAT_DEFAULT gst_nv_vp9_dec_debug +#define DOC_SINK_CAPS \ + "video/x-vp9, width = (int) [ 128, 8192 ], height = (int) [ 128, 8192 ], " \ + "alignment= (string) frame, " \ + "profile = (string) { 0, 2 }" + +#define DOC_SRC_CAPS_COMM \ + "format = (string) { NV12, P010_10LE, P012_LE }, " \ + "width = (int) [ 128, 8192 ], height = (int) [ 128, 8192 ]" + +#define DOC_SRC_CAPS_D3D11 \ + "format = (string) { I420, I420_10LE, I420_12LE }, " \ + "width = (int) [ 128, 8192 ], height = (int) [ 128, 8192 ]" + +#define DOC_SRC_CAPS \ + "video/x-raw(memory:CUDAMemory), " DOC_SRC_CAPS_COMM "; " \ + "video/x-raw(memory:D3D12Memory), " DOC_SRC_CAPS_COMM "; " \ + "video/x-raw(memory:D3D11Memory), " DOC_SRC_CAPS_D3D11 "; " \ + "video/x-raw(memory:GLMemory), " DOC_SRC_CAPS_COMM "; " \ + "video/x-raw, " DOC_SRC_CAPS_COMM + typedef struct _GstNvVp9Dec { GstVp9Decoder parent; @@ -219,12 +239,19 @@ gst_nv_vp9_dec_class_init (GstNvVp9DecClass * klass, "Codec/Decoder/Video/Hardware", "NVIDIA VP9 video decoder", "Seungha Yang "); - gst_element_class_add_pad_template (element_class, - gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - cdata->sink_caps)); - gst_element_class_add_pad_template (element_class, - gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - cdata->src_caps)); + auto pad_templ = gst_pad_template_new ("sink", + GST_PAD_SINK, GST_PAD_ALWAYS, cdata->sink_caps); + auto doc_caps = gst_caps_from_string (DOC_SINK_CAPS); + gst_pad_template_set_documentation_caps (pad_templ, doc_caps); + gst_caps_unref (doc_caps); + gst_element_class_add_pad_template (element_class, pad_templ); + + pad_templ = gst_pad_template_new ("src", + GST_PAD_SRC, GST_PAD_ALWAYS, cdata->src_caps); + doc_caps = gst_caps_from_string (DOC_SRC_CAPS); + gst_pad_template_set_documentation_caps (pad_templ, doc_caps); + gst_caps_unref (doc_caps); + gst_element_class_add_pad_template (element_class, pad_templ); decoder_class->open = GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_open); decoder_class->close = GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_close);