From be1771126d4a0a30ca678ef48282564ffc731417 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Tue, 1 Nov 2022 22:19:18 +0900 Subject: [PATCH] qsv: Check 16K resolution support ... and remove duplicated code Part-of: --- .../docs/plugins/gst_plugins_cache.json | 12 ++--- .../gst-plugins-bad/sys/qsv/gstqsvav1enc.cpp | 28 ++++------- .../gst-plugins-bad/sys/qsv/gstqsvh264dec.cpp | 40 ++++++---------- .../gst-plugins-bad/sys/qsv/gstqsvh264enc.cpp | 28 ++++------- .../gst-plugins-bad/sys/qsv/gstqsvh265dec.cpp | 48 ++++++++----------- .../gst-plugins-bad/sys/qsv/gstqsvh265enc.cpp | 28 ++++------- .../gst-plugins-bad/sys/qsv/gstqsvjpegenc.cpp | 28 ++++------- .../gst-plugins-bad/sys/qsv/gstqsvutils.h | 11 +++++ .../gst-plugins-bad/sys/qsv/gstqsvvp9dec.cpp | 28 ++++------- .../gst-plugins-bad/sys/qsv/gstqsvvp9enc.cpp | 28 ++++------- 10 files changed, 105 insertions(+), 174 deletions(-) diff --git a/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json b/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json index 2c57a42818..ab1bdc5bcc 100644 --- a/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json +++ b/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json @@ -225343,12 +225343,12 @@ "klass": "Codec/Decoder/Video/Hardware", "pad-templates": { "sink": { - "caps": "video/x-h264:\n width: [ 16, 4096 ]\n height: [ 16, 4096 ]\n stream-format: { (string)byte-stream, (string)avc, (string)avc3 }\n alignment: au\n profile: { (string)high, (string)progressive-high, (string)constrained-high, (string)main, (string)constrained-baseline, (string)baseline }\n", + "caps": "video/x-h264:\n width: [ 1, 4096 ]\n height: [ 1, 4096 ]\n stream-format: { (string)byte-stream, (string)avc, (string)avc3 }\n alignment: au\n profile: { (string)high, (string)progressive-high, (string)constrained-high, (string)main, (string)constrained-baseline, (string)baseline }\n", "direction": "sink", "presence": "always" }, "src": { - "caps": "video/x-raw(memory:D3D11Memory):\n format: NV12\n width: [ 16, 4096 ]\n height: [ 16, 4096 ]\nvideo/x-raw:\n format: NV12\n width: [ 16, 4096 ]\n height: [ 16, 4096 ]\n", + "caps": "video/x-raw(memory:D3D11Memory):\n format: NV12\n width: [ 1, 4096 ]\n height: [ 1, 4096 ]\nvideo/x-raw:\n format: NV12\n width: [ 1, 4096 ]\n height: [ 1, 4096 ]\n", "direction": "src", "presence": "always" } @@ -225742,12 +225742,12 @@ "klass": "Codec/Decoder/Video/Hardware", "pad-templates": { "sink": { - "caps": "video/x-h265:\n width: [ 16, 8192 ]\n height: [ 16, 8192 ]\n stream-format: { (string)byte-stream, (string)hev1, (string)hvc1 }\n alignment: au\n profile: { (string)main, (string)main-10 }\n", + "caps": "video/x-h265:\n width: [ 1, 16384 ]\n height: [ 1, 16384 ]\n stream-format: { (string)byte-stream, (string)hev1, (string)hvc1 }\n alignment: au\n profile: { (string)main, (string)main-10 }\n", "direction": "sink", "presence": "always" }, "src": { - "caps": "video/x-raw(memory:D3D11Memory):\n format: NV12\n width: [ 16, 8192 ]\n height: [ 16, 8192 ]\nvideo/x-raw:\n format: NV12\n width: [ 16, 8192 ]\n height: [ 16, 8192 ]\n", + "caps": "video/x-raw(memory:D3D11Memory):\n format: NV12\n width: [ 1, 16384 ]\n height: [ 1, 16384 ]\nvideo/x-raw:\n format: NV12\n width: [ 1, 16384 ]\n height: [ 1, 16384 ]\n", "direction": "src", "presence": "always" } @@ -226078,12 +226078,12 @@ "klass": "Codec/Encoder/Video/Hardware", "pad-templates": { "sink": { - "caps": "video/x-raw(memory:D3D11Memory):\n format: { NV12, BGRA }\n width: [ 16, 8192 ]\n height: [ 16, 8192 ]\n\nvideo/x-raw(memory:VAMemory):\n format: { NV12, BGRA }\n width: [ 16, 8192 ]\n height: [ 16, 8192 ]\nvideo/x-raw:\n format: { NV12, BGRA }\n width: [ 16, 8192 ]\n height: [ 16, 8192 ]\n", + "caps": "video/x-raw(memory:D3D11Memory):\n format: { NV12, BGRA }\n width: [ 16, 16384 ]\n height: [ 16, 16384 ]\n\nvideo/x-raw(memory:VAMemory):\n format: { NV12, BGRA }\n width: [ 16, 16384 ]\n height: [ 16, 16384 ]\nvideo/x-raw:\n format: { NV12, BGRA }\n width: [ 16, 16384 ]\n height: [ 16, 16384 ]\n", "direction": "sink", "presence": "always" }, "src": { - "caps": "image/jpeg:\n width: [ 16, 8192 ]\n height: [ 16, 8192 ]\n", + "caps": "image/jpeg:\n width: [ 16, 16384 ]\n height: [ 16, 16384 ]\n", "direction": "src", "presence": "always" } diff --git a/subprojects/gst-plugins-bad/sys/qsv/gstqsvav1enc.cpp b/subprojects/gst-plugins-bad/sys/qsv/gstqsvav1enc.cpp index 9e44c1a7c5..c35ff76a8a 100644 --- a/subprojects/gst-plugins-bad/sys/qsv/gstqsvav1enc.cpp +++ b/subprojects/gst-plugins-bad/sys/qsv/gstqsvav1enc.cpp @@ -626,24 +626,14 @@ done: return ret; } -typedef struct -{ - guint width; - guint height; -} Resolution; - void gst_qsv_av1_enc_register (GstPlugin * plugin, guint rank, guint impl_index, GstObject * device, mfxSession session) { mfxVideoParam param; mfxInfoMFX *mfx; - static const Resolution resolutions_to_check[] = { - {1280, 720}, {1920, 1088}, {2560, 1440}, {3840, 2160}, {4096, 2160}, - {7680, 4320}, {8192, 4320} - }; std::vector < std::string > supported_formats; - Resolution max_resolution; + GstQsvResolution max_resolution; mfxExtAV1ResolutionParam resolution_param; mfxExtAV1BitstreamParam bitstream_param; mfxExtBuffer *ext_bufs[2]; @@ -651,7 +641,7 @@ gst_qsv_av1_enc_register (GstPlugin * plugin, guint rank, guint impl_index, GST_DEBUG_CATEGORY_INIT (gst_qsv_av1_enc_debug, "qsvav1enc", 0, "qsvav1enc"); memset (¶m, 0, sizeof (mfxVideoParam)); - memset (&max_resolution, 0, sizeof (Resolution)); + memset (&max_resolution, 0, sizeof (GstQsvResolution)); memset (&resolution_param, 0, sizeof (mfxExtAV1ResolutionParam)); memset (&bitstream_param, 0, sizeof (mfxExtAV1BitstreamParam)); @@ -718,22 +708,22 @@ gst_qsv_av1_enc_register (GstPlugin * plugin, guint rank, guint impl_index, mfx->FrameInfo.Shift = 0; /* Check max-resolution */ - for (guint i = 0; i < G_N_ELEMENTS (resolutions_to_check); i++) { + for (guint i = 0; i < G_N_ELEMENTS (gst_qsv_resolutions); i++) { mfx->FrameInfo.Width = mfx->FrameInfo.CropW = - GST_ROUND_UP_16 (resolutions_to_check[i].width); + GST_ROUND_UP_16 (gst_qsv_resolutions[i].width); mfx->FrameInfo.Height = mfx->FrameInfo.CropH = - GST_ROUND_UP_16 (resolutions_to_check[i].height); + GST_ROUND_UP_16 (gst_qsv_resolutions[i].height); - resolution_param.FrameWidth = resolutions_to_check[i].width; - resolution_param.FrameHeight = resolutions_to_check[i].height; + resolution_param.FrameWidth = gst_qsv_resolutions[i].width; + resolution_param.FrameHeight = gst_qsv_resolutions[i].height; bitstream_param.WriteIVFHeaders = MFX_CODINGOPTION_OFF; if (MFXVideoENCODE_Query (session, ¶m, ¶m) != MFX_ERR_NONE) break; - max_resolution.width = resolutions_to_check[i].width; - max_resolution.height = resolutions_to_check[i].height; + max_resolution.width = gst_qsv_resolutions[i].width; + max_resolution.height = gst_qsv_resolutions[i].height; } GST_INFO ("Maximum supported resolution: %dx%d", diff --git a/subprojects/gst-plugins-bad/sys/qsv/gstqsvh264dec.cpp b/subprojects/gst-plugins-bad/sys/qsv/gstqsvh264dec.cpp index a00300fad8..e86e6c1a7c 100644 --- a/subprojects/gst-plugins-bad/sys/qsv/gstqsvh264dec.cpp +++ b/subprojects/gst-plugins-bad/sys/qsv/gstqsvh264dec.cpp @@ -50,7 +50,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_qsv_h264_dec_debug); #define GST_CAT_DEFAULT gst_qsv_h264_dec_debug #define DOC_SINK_CAPS \ - "video/x-h264, width = (int) [ 16, 4096 ], height = (int) [ 16, 4096 ], " \ + "video/x-h264, width = (int) [ 1, 4096 ], height = (int) [ 1, 4096 ], " \ "stream-format = (string) { byte-stream, avc, avc3 }, " \ "alignment = (string) au, " \ "profile = (string) { high, progressive-high, constrained-high, main, " \ @@ -58,7 +58,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_qsv_h264_dec_debug); #define DOC_SRC_CAPS_COMM \ "format = (string) NV12, " \ - "width = (int) [ 16, 4096 ], height = (int) [ 16, 4096 ]" + "width = (int) [ 1, 4096 ], height = (int) [ 1, 4096 ]" #define DOC_SRC_CAPS \ "video/x-raw(memory:D3D11Memory), " DOC_SRC_CAPS_COMM "; " \ @@ -436,29 +436,19 @@ gst_qsv_h264_dec_process_input (GstQsvDecoder * decoder, return new_buf; } -typedef struct -{ - guint width; - guint height; -} Resolution; - void gst_qsv_h264_dec_register (GstPlugin * plugin, guint rank, guint impl_index, GstObject * device, mfxSession session) { mfxVideoParam param; mfxInfoMFX *mfx; - static const Resolution resolutions_to_check[] = { - {1280, 720}, {1920, 1088}, {2560, 1440}, {3840, 2160}, {4096, 2160}, - {7680, 4320}, {8192, 4320} - }; - Resolution max_resolution; + GstQsvResolution max_resolution; GST_DEBUG_CATEGORY_INIT (gst_qsv_h264_dec_debug, "qsvh264dec", 0, "qsvh264dec"); memset (¶m, 0, sizeof (mfxVideoParam)); - memset (&max_resolution, 0, sizeof (Resolution)); + memset (&max_resolution, 0, sizeof (GstQsvResolution)); param.AsyncDepth = 4; param.IOPattern = MFX_IOPATTERN_OUT_VIDEO_MEMORY; @@ -478,17 +468,17 @@ gst_qsv_h264_dec_register (GstPlugin * plugin, guint rank, guint impl_index, mfx->CodecProfile = MFX_PROFILE_AVC_MAIN; /* Check max-resolution */ - for (guint i = 0; i < G_N_ELEMENTS (resolutions_to_check); i++) { - mfx->FrameInfo.Width = GST_ROUND_UP_16 (resolutions_to_check[i].width); - mfx->FrameInfo.Height = GST_ROUND_UP_16 (resolutions_to_check[i].height); - mfx->FrameInfo.CropW = resolutions_to_check[i].width; - mfx->FrameInfo.CropH = resolutions_to_check[i].height; + for (guint i = 0; i < G_N_ELEMENTS (gst_qsv_resolutions); i++) { + mfx->FrameInfo.Width = GST_ROUND_UP_16 (gst_qsv_resolutions[i].width); + mfx->FrameInfo.Height = GST_ROUND_UP_16 (gst_qsv_resolutions[i].height); + mfx->FrameInfo.CropW = gst_qsv_resolutions[i].width; + mfx->FrameInfo.CropH = gst_qsv_resolutions[i].height; if (MFXVideoDECODE_Query (session, ¶m, ¶m) != MFX_ERR_NONE) break; - max_resolution.width = resolutions_to_check[i].width; - max_resolution.height = resolutions_to_check[i].height; + max_resolution.width = gst_qsv_resolutions[i].width; + max_resolution.height = gst_qsv_resolutions[i].height; } if (max_resolution.width == 0 || max_resolution.height == 0) @@ -502,8 +492,8 @@ gst_qsv_h264_dec_register (GstPlugin * plugin, guint rank, guint impl_index, guint resolution = MAX (max_resolution.width, max_resolution.height); std::string src_caps_str = "video/x-raw, format=(string) NV12"; - src_caps_str += ", width=(int) [ 16, " + std::to_string (resolution) + " ]"; - src_caps_str += ", height=(int) [ 16, " + std::to_string (resolution) + " ]"; + src_caps_str += ", width=(int) [ 1, " + std::to_string (resolution) + " ]"; + src_caps_str += ", height=(int) [ 1, " + std::to_string (resolution) + " ]"; GstCaps *src_caps = gst_caps_from_string (src_caps_str.c_str ()); @@ -518,8 +508,8 @@ gst_qsv_h264_dec_register (GstPlugin * plugin, guint rank, guint impl_index, #endif std::string sink_caps_str = "video/x-h264"; - sink_caps_str += ", width=(int) [ 16, " + std::to_string (resolution) + " ]"; - sink_caps_str += ", height=(int) [ 16, " + std::to_string (resolution) + " ]"; + sink_caps_str += ", width=(int) [ 1, " + std::to_string (resolution) + " ]"; + sink_caps_str += ", height=(int) [ 1, " + std::to_string (resolution) + " ]"; sink_caps_str += ", stream-format=(string) { byte-stream, avc, avc3 }"; sink_caps_str += ", alignment=(string) au"; diff --git a/subprojects/gst-plugins-bad/sys/qsv/gstqsvh264enc.cpp b/subprojects/gst-plugins-bad/sys/qsv/gstqsvh264enc.cpp index ece9024d54..32aa9500e0 100644 --- a/subprojects/gst-plugins-bad/sys/qsv/gstqsvh264enc.cpp +++ b/subprojects/gst-plugins-bad/sys/qsv/gstqsvh264enc.cpp @@ -1842,12 +1842,6 @@ done: return ret; } -typedef struct -{ - guint width; - guint height; -} Resolution; - void gst_qsv_h264_enc_register (GstPlugin * plugin, guint rank, guint impl_index, GstObject * device, mfxSession session) @@ -1855,19 +1849,15 @@ gst_qsv_h264_enc_register (GstPlugin * plugin, guint rank, guint impl_index, mfxStatus status; mfxVideoParam param; mfxInfoMFX *mfx; - static const Resolution resolutions_to_check[] = { - {1280, 720}, {1920, 1088}, {2560, 1440}, {3840, 2160}, {4096, 2160}, - {7680, 4320}, {8192, 4320} - }; std::vector < mfxU16 > supported_profiles; - Resolution max_resolution; + GstQsvResolution max_resolution; bool supports_interlaced = false; GST_DEBUG_CATEGORY_INIT (gst_qsv_h264_enc_debug, "qsvh264enc", 0, "qsvh264enc"); memset (¶m, 0, sizeof (mfxVideoParam)); - memset (&max_resolution, 0, sizeof (Resolution)); + memset (&max_resolution, 0, sizeof (GstQsvResolution)); param.AsyncDepth = 4; param.IOPattern = MFX_IOPATTERN_IN_VIDEO_MEMORY; @@ -1907,17 +1897,17 @@ gst_qsv_h264_enc_register (GstPlugin * plugin, guint rank, guint impl_index, mfx->CodecProfile = supported_profiles[0]; /* Check max-resolution */ - for (guint i = 0; i < G_N_ELEMENTS (resolutions_to_check); i++) { - mfx->FrameInfo.Width = GST_ROUND_UP_16 (resolutions_to_check[i].width); - mfx->FrameInfo.Height = GST_ROUND_UP_16 (resolutions_to_check[i].height); - mfx->FrameInfo.CropW = resolutions_to_check[i].width; - mfx->FrameInfo.CropH = resolutions_to_check[i].height; + for (guint i = 0; i < G_N_ELEMENTS (gst_qsv_resolutions); i++) { + mfx->FrameInfo.Width = GST_ROUND_UP_16 (gst_qsv_resolutions[i].width); + mfx->FrameInfo.Height = GST_ROUND_UP_16 (gst_qsv_resolutions[i].height); + mfx->FrameInfo.CropW = gst_qsv_resolutions[i].width; + mfx->FrameInfo.CropH = gst_qsv_resolutions[i].height; if (MFXVideoENCODE_Query (session, ¶m, ¶m) != MFX_ERR_NONE) break; - max_resolution.width = resolutions_to_check[i].width; - max_resolution.height = resolutions_to_check[i].height; + max_resolution.width = gst_qsv_resolutions[i].width; + max_resolution.height = gst_qsv_resolutions[i].height; } GST_INFO ("Maximum supported resolution: %dx%d", diff --git a/subprojects/gst-plugins-bad/sys/qsv/gstqsvh265dec.cpp b/subprojects/gst-plugins-bad/sys/qsv/gstqsvh265dec.cpp index 15c10f25d3..4650dc399b 100644 --- a/subprojects/gst-plugins-bad/sys/qsv/gstqsvh265dec.cpp +++ b/subprojects/gst-plugins-bad/sys/qsv/gstqsvh265dec.cpp @@ -51,13 +51,13 @@ GST_DEBUG_CATEGORY_STATIC (gst_qsv_h265_dec_debug); #define GST_CAT_DEFAULT gst_qsv_h265_dec_debug #define DOC_SINK_CAPS \ - "video/x-h265, width = (int) [ 16, 8192 ], height = (int) [ 16, 8192 ], " \ + "video/x-h265, width = (int) [ 1, 16384 ], height = (int) [ 1, 16384 ], " \ "stream-format = (string) { byte-stream, hev1, hvc1 }, " \ "alignment = (string) au, profile = (string) { main, main-10 }" #define DOC_SRC_CAPS_COMM \ "format = (string) NV12, " \ - "width = (int) [ 16, 8192 ], height = (int) [ 16, 8192 ]" + "width = (int) [ 1, 16384 ], height = (int) [ 1, 16384 ]" #define DOC_SRC_CAPS \ "video/x-raw(memory:D3D11Memory), " DOC_SRC_CAPS_COMM "; " \ @@ -477,23 +477,13 @@ gst_qsv_h265_dec_process_input (GstQsvDecoder * decoder, return new_buf; } -typedef struct -{ - guint width; - guint height; -} Resolution; - void gst_qsv_h265_dec_register (GstPlugin * plugin, guint rank, guint impl_index, GstObject * device, mfxSession session) { mfxVideoParam param; mfxInfoMFX *mfx; - static const Resolution resolutions_to_check[] = { - {1280, 720}, {1920, 1088}, {2560, 1440}, {3840, 2160}, {4096, 2160}, - {7680, 4320}, {8192, 4320} - }; - Resolution max_resolution; + GstQsvResolution max_resolution; std::vector < std::string > supported_profiles; std::vector < std::string > supported_formats; @@ -501,7 +491,7 @@ gst_qsv_h265_dec_register (GstPlugin * plugin, guint rank, guint impl_index, "qsvh265dec", 0, "qsvh265dec"); memset (¶m, 0, sizeof (mfxVideoParam)); - memset (&max_resolution, 0, sizeof (Resolution)); + memset (&max_resolution, 0, sizeof (GstQsvResolution)); param.AsyncDepth = 4; param.IOPattern = MFX_IOPATTERN_OUT_VIDEO_MEMORY; @@ -521,17 +511,17 @@ gst_qsv_h265_dec_register (GstPlugin * plugin, guint rank, guint impl_index, mfx->CodecProfile = MFX_PROFILE_HEVC_MAIN; /* Check max-resolution */ - for (guint i = 0; i < G_N_ELEMENTS (resolutions_to_check); i++) { - mfx->FrameInfo.Width = GST_ROUND_UP_16 (resolutions_to_check[i].width); - mfx->FrameInfo.Height = GST_ROUND_UP_16 (resolutions_to_check[i].height); - mfx->FrameInfo.CropW = resolutions_to_check[i].width; - mfx->FrameInfo.CropH = resolutions_to_check[i].height; + for (guint i = 0; i < G_N_ELEMENTS (gst_qsv_resolutions); i++) { + mfx->FrameInfo.Width = GST_ROUND_UP_16 (gst_qsv_resolutions[i].width); + mfx->FrameInfo.Height = GST_ROUND_UP_16 (gst_qsv_resolutions[i].height); + mfx->FrameInfo.CropW = gst_qsv_resolutions[i].width; + mfx->FrameInfo.CropH = gst_qsv_resolutions[i].height; if (MFXVideoDECODE_Query (session, ¶m, ¶m) != MFX_ERR_NONE) break; - max_resolution.width = resolutions_to_check[i].width; - max_resolution.height = resolutions_to_check[i].height; + max_resolution.width = gst_qsv_resolutions[i].width; + max_resolution.height = gst_qsv_resolutions[i].height; } if (max_resolution.width == 0 || max_resolution.height == 0) @@ -552,10 +542,10 @@ gst_qsv_h265_dec_register (GstPlugin * plugin, guint rank, guint impl_index, mfx->FrameInfo.Shift = 1; mfx->FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE; mfx->CodecProfile = MFX_PROFILE_HEVC_MAIN10; - mfx->FrameInfo.Width = GST_ROUND_UP_16 (resolutions_to_check[0].width); - mfx->FrameInfo.Height = GST_ROUND_UP_16 (resolutions_to_check[0].height); - mfx->FrameInfo.CropW = resolutions_to_check[0].width; - mfx->FrameInfo.CropH = resolutions_to_check[0].height; + mfx->FrameInfo.Width = GST_ROUND_UP_16 (gst_qsv_resolutions[0].width); + mfx->FrameInfo.Height = GST_ROUND_UP_16 (gst_qsv_resolutions[0].height); + mfx->FrameInfo.CropW = gst_qsv_resolutions[0].width; + mfx->FrameInfo.CropH = gst_qsv_resolutions[0].height; if (MFXVideoDECODE_Query (session, ¶m, ¶m) == MFX_ERR_NONE) { supported_profiles.push_back ("main-10"); supported_formats.push_back ("P010_10LE"); @@ -566,8 +556,8 @@ gst_qsv_h265_dec_register (GstPlugin * plugin, guint rank, guint impl_index, guint resolution = MAX (max_resolution.width, max_resolution.height); std::string src_caps_str = "video/x-raw"; - src_caps_str += ", width=(int) [ 16, " + std::to_string (resolution) + " ]"; - src_caps_str += ", height=(int) [ 16, " + std::to_string (resolution) + " ]"; + src_caps_str += ", width=(int) [ 1, " + std::to_string (resolution) + " ]"; + src_caps_str += ", height=(int) [ 1, " + std::to_string (resolution) + " ]"; /* *INDENT-OFF* */ if (supported_formats.size () > 1) { @@ -600,8 +590,8 @@ gst_qsv_h265_dec_register (GstPlugin * plugin, guint rank, guint impl_index, #endif std::string sink_caps_str = "video/x-h265"; - sink_caps_str += ", width=(int) [ 16, " + std::to_string (resolution) + " ]"; - sink_caps_str += ", height=(int) [ 16, " + std::to_string (resolution) + " ]"; + sink_caps_str += ", width=(int) [ 1, " + std::to_string (resolution) + " ]"; + sink_caps_str += ", height=(int) [ 1, " + std::to_string (resolution) + " ]"; sink_caps_str += ", stream-format=(string) { byte-stream, hev1, hvc1 }"; sink_caps_str += ", alignment=(string) au"; diff --git a/subprojects/gst-plugins-bad/sys/qsv/gstqsvh265enc.cpp b/subprojects/gst-plugins-bad/sys/qsv/gstqsvh265enc.cpp index 64f7daaa95..18ce15c4aa 100644 --- a/subprojects/gst-plugins-bad/sys/qsv/gstqsvh265enc.cpp +++ b/subprojects/gst-plugins-bad/sys/qsv/gstqsvh265enc.cpp @@ -1424,25 +1424,15 @@ done: return ret; } -typedef struct -{ - guint width; - guint height; -} Resolution; - void gst_qsv_h265_enc_register (GstPlugin * plugin, guint rank, guint impl_index, GstObject * device, mfxSession session) { mfxVideoParam param; mfxInfoMFX *mfx; - static const Resolution resolutions_to_check[] = { - {1280, 720}, {1920, 1088}, {2560, 1440}, {3840, 2160}, {4096, 2160}, - {7680, 4320}, {8192, 4320} - }; std::vector < mfxU16 > supported_profiles; std::vector < std::string > supported_formats; - Resolution max_resolution; + GstQsvResolution max_resolution; mfxExtContentLightLevelInfo cll; mfxExtMasteringDisplayColourVolume mdcv; mfxExtBuffer *ext_buffers[2]; @@ -1452,7 +1442,7 @@ gst_qsv_h265_enc_register (GstPlugin * plugin, guint rank, guint impl_index, "qsvh265enc", 0, "qsvh265enc"); memset (¶m, 0, sizeof (mfxVideoParam)); - memset (&max_resolution, 0, sizeof (Resolution)); + memset (&max_resolution, 0, sizeof (GstQsvResolution)); memset (&cll, 0, sizeof (mfxExtContentLightLevelInfo)); memset (&mdcv, 0, sizeof (mfxExtMasteringDisplayColourVolume)); @@ -1543,17 +1533,17 @@ gst_qsv_h265_enc_register (GstPlugin * plugin, guint rank, guint impl_index, param.ExtParam = nullptr; /* Check max-resolution */ - for (guint i = 0; i < G_N_ELEMENTS (resolutions_to_check); i++) { - mfx->FrameInfo.Width = GST_ROUND_UP_16 (resolutions_to_check[i].width); - mfx->FrameInfo.Height = GST_ROUND_UP_16 (resolutions_to_check[i].height); - mfx->FrameInfo.CropW = resolutions_to_check[i].width; - mfx->FrameInfo.CropH = resolutions_to_check[i].height; + for (guint i = 0; i < G_N_ELEMENTS (gst_qsv_resolutions); i++) { + mfx->FrameInfo.Width = GST_ROUND_UP_16 (gst_qsv_resolutions[i].width); + mfx->FrameInfo.Height = GST_ROUND_UP_16 (gst_qsv_resolutions[i].height); + mfx->FrameInfo.CropW = gst_qsv_resolutions[i].width; + mfx->FrameInfo.CropH = gst_qsv_resolutions[i].height; if (MFXVideoENCODE_Query (session, ¶m, ¶m) != MFX_ERR_NONE) break; - max_resolution.width = resolutions_to_check[i].width; - max_resolution.height = resolutions_to_check[i].height; + max_resolution.width = gst_qsv_resolutions[i].width; + max_resolution.height = gst_qsv_resolutions[i].height; } GST_INFO ("Maximum supported resolution: %dx%d", diff --git a/subprojects/gst-plugins-bad/sys/qsv/gstqsvjpegenc.cpp b/subprojects/gst-plugins-bad/sys/qsv/gstqsvjpegenc.cpp index 60be81d66b..2e273596b4 100644 --- a/subprojects/gst-plugins-bad/sys/qsv/gstqsvjpegenc.cpp +++ b/subprojects/gst-plugins-bad/sys/qsv/gstqsvjpegenc.cpp @@ -60,7 +60,7 @@ enum #define DOC_SINK_CAPS_COMM \ "format = (string) { NV12, BGRA }, " \ - "width = (int) [ 16, 8192 ], height = (int) [ 16, 8192 ]" + "width = (int) [ 16, 16384 ], height = (int) [ 16, 16384 ]" #define DOC_SINK_CAPS \ "video/x-raw(memory:D3D11Memory), " DOC_SINK_CAPS_COMM "; " \ @@ -68,7 +68,7 @@ enum "video/x-raw, " DOC_SINK_CAPS_COMM #define DOC_SRC_CAPS \ - "image/jpeg, width = (int) [ 16, 8192 ], height = (int) [ 16, 8192 ]" + "image/jpeg, width = (int) [ 16, 16384 ], height = (int) [ 16, 16384 ]" typedef struct _GstQsvJpegEncClassData { @@ -359,24 +359,14 @@ gst_qsv_jpeg_enc_check_reconfigure (GstQsvEncoder * encoder, mfxSession session, return ret; } -typedef struct -{ - guint width; - guint height; -} Resolution; - void gst_qsv_jpeg_enc_register (GstPlugin * plugin, guint rank, guint impl_index, GstObject * device, mfxSession session) { mfxVideoParam param; mfxInfoMFX *mfx; - static const Resolution resolutions_to_check[] = { - {1280, 720}, {1920, 1088}, {2560, 1440}, {3840, 2160}, {4096, 2160}, - {7680, 4320}, {8192, 4320} - }; std::vector < std::string > supported_formats; - Resolution max_resolution; + GstQsvResolution max_resolution; mfxStatus status; gboolean interlaved = TRUE; @@ -384,7 +374,7 @@ gst_qsv_jpeg_enc_register (GstPlugin * plugin, guint rank, guint impl_index, "qsvjpegenc", 0, "qsvjpegenc"); memset (¶m, 0, sizeof (mfxVideoParam)); - memset (&max_resolution, 0, sizeof (Resolution)); + memset (&max_resolution, 0, sizeof (GstQsvResolution)); param.AsyncDepth = 4; param.IOPattern = MFX_IOPATTERN_IN_VIDEO_MEMORY; @@ -433,16 +423,16 @@ gst_qsv_jpeg_enc_register (GstPlugin * plugin, guint rank, guint impl_index, mfx->FrameInfo.FourCC = MFX_FOURCC_NV12; /* Check max-resolution */ - for (guint i = 0; i < G_N_ELEMENTS (resolutions_to_check); i++) { - mfx->FrameInfo.Width = mfx->FrameInfo.CropW = resolutions_to_check[i].width; + for (guint i = 0; i < G_N_ELEMENTS (gst_qsv_resolutions); i++) { + mfx->FrameInfo.Width = mfx->FrameInfo.CropW = gst_qsv_resolutions[i].width; mfx->FrameInfo.Height = mfx->FrameInfo.CropH = - resolutions_to_check[i].height; + gst_qsv_resolutions[i].height; if (MFXVideoENCODE_Query (session, ¶m, ¶m) != MFX_ERR_NONE) break; - max_resolution.width = resolutions_to_check[i].width; - max_resolution.height = resolutions_to_check[i].height; + max_resolution.width = gst_qsv_resolutions[i].width; + max_resolution.height = gst_qsv_resolutions[i].height; } GST_INFO ("Maximum supported resolution: %dx%d", diff --git a/subprojects/gst-plugins-bad/sys/qsv/gstqsvutils.h b/subprojects/gst-plugins-bad/sys/qsv/gstqsvutils.h index 84c5ce6fba..d57dd3eca5 100644 --- a/subprojects/gst-plugins-bad/sys/qsv/gstqsvutils.h +++ b/subprojects/gst-plugins-bad/sys/qsv/gstqsvutils.h @@ -64,4 +64,15 @@ gst_qsv_timestamp_from_gst (GstClockTime timestamp) return gst_util_uint64_scale (timestamp, 90000, GST_SECOND); } +typedef struct _GstQsvResolution +{ + guint width; + guint height; +} GstQsvResolution; + +static const GstQsvResolution gst_qsv_resolutions[] = { + {1920, 1088}, {2560, 1440}, {3840, 2160}, {4096, 2160}, + {7680, 4320}, {8192, 4320}, {15360, 8640}, {16384, 8640} +}; + G_END_DECLS diff --git a/subprojects/gst-plugins-bad/sys/qsv/gstqsvvp9dec.cpp b/subprojects/gst-plugins-bad/sys/qsv/gstqsvvp9dec.cpp index f2789a2e2b..eb010ef84a 100644 --- a/subprojects/gst-plugins-bad/sys/qsv/gstqsvvp9dec.cpp +++ b/subprojects/gst-plugins-bad/sys/qsv/gstqsvvp9dec.cpp @@ -133,23 +133,13 @@ gst_qsv_vp9_dec_init (GstQsvVP9Dec * self) { } -typedef struct -{ - guint width; - guint height; -} Resolution; - void gst_qsv_vp9_dec_register (GstPlugin * plugin, guint rank, guint impl_index, GstObject * device, mfxSession session) { mfxVideoParam param; mfxInfoMFX *mfx; - static const Resolution resolutions_to_check[] = { - {1280, 720}, {1920, 1088}, {2560, 1440}, {3840, 2160}, {4096, 2160}, - {7680, 4320}, {8192, 4320}, {15360, 8640}, {16384, 8640} - }; - Resolution max_resolution; + GstQsvResolution max_resolution; std::vector < std::string > supported_formats; gboolean have_profile_2 = FALSE; gboolean have_profile_2_12bits = FALSE; @@ -157,7 +147,7 @@ gst_qsv_vp9_dec_register (GstPlugin * plugin, guint rank, guint impl_index, GST_DEBUG_CATEGORY_INIT (gst_qsv_vp9_dec_debug, "qsvvp9dec", 0, "qsvvp9dec"); memset (¶m, 0, sizeof (mfxVideoParam)); - memset (&max_resolution, 0, sizeof (Resolution)); + memset (&max_resolution, 0, sizeof (GstQsvResolution)); param.AsyncDepth = 4; param.IOPattern = MFX_IOPATTERN_OUT_VIDEO_MEMORY; @@ -177,17 +167,17 @@ gst_qsv_vp9_dec_register (GstPlugin * plugin, guint rank, guint impl_index, mfx->CodecProfile = MFX_PROFILE_VP9_0; /* Check max-resolution */ - for (guint i = 0; i < G_N_ELEMENTS (resolutions_to_check); i++) { - mfx->FrameInfo.Width = GST_ROUND_UP_16 (resolutions_to_check[i].width); - mfx->FrameInfo.Height = GST_ROUND_UP_16 (resolutions_to_check[i].height); - mfx->FrameInfo.CropW = resolutions_to_check[i].width; - mfx->FrameInfo.CropH = resolutions_to_check[i].height; + for (guint i = 0; i < G_N_ELEMENTS (gst_qsv_resolutions); i++) { + mfx->FrameInfo.Width = GST_ROUND_UP_16 (gst_qsv_resolutions[i].width); + mfx->FrameInfo.Height = GST_ROUND_UP_16 (gst_qsv_resolutions[i].height); + mfx->FrameInfo.CropW = gst_qsv_resolutions[i].width; + mfx->FrameInfo.CropH = gst_qsv_resolutions[i].height; if (MFXVideoDECODE_Query (session, ¶m, ¶m) != MFX_ERR_NONE) break; - max_resolution.width = resolutions_to_check[i].width; - max_resolution.height = resolutions_to_check[i].height; + max_resolution.width = gst_qsv_resolutions[i].width; + max_resolution.height = gst_qsv_resolutions[i].height; } if (max_resolution.width == 0 || max_resolution.height == 0) diff --git a/subprojects/gst-plugins-bad/sys/qsv/gstqsvvp9enc.cpp b/subprojects/gst-plugins-bad/sys/qsv/gstqsvvp9enc.cpp index c7d9f62025..17ca1647f5 100644 --- a/subprojects/gst-plugins-bad/sys/qsv/gstqsvvp9enc.cpp +++ b/subprojects/gst-plugins-bad/sys/qsv/gstqsvvp9enc.cpp @@ -835,32 +835,22 @@ done: return ret; } -typedef struct -{ - guint width; - guint height; -} Resolution; - void gst_qsv_vp9_enc_register (GstPlugin * plugin, guint rank, guint impl_index, GstObject * device, mfxSession session) { mfxVideoParam param; mfxInfoMFX *mfx; - static const Resolution resolutions_to_check[] = { - {1280, 720}, {1920, 1088}, {2560, 1440}, {3840, 2160}, {4096, 2160}, - {7680, 4320}, {8192, 4320} - }; std::vector < mfxU16 > supported_profiles; std::vector < std::string > supported_formats; - Resolution max_resolution; + GstQsvResolution max_resolution; mfxExtVP9Param vp9_param; mfxExtBuffer *ext_bufs[1]; GST_DEBUG_CATEGORY_INIT (gst_qsv_vp9_enc_debug, "qsvvp9enc", 0, "qsvvp9enc"); memset (¶m, 0, sizeof (mfxVideoParam)); - memset (&max_resolution, 0, sizeof (Resolution)); + memset (&max_resolution, 0, sizeof (GstQsvResolution)); ext_bufs[0] = (mfxExtBuffer *) & vp9_param; @@ -945,24 +935,24 @@ gst_qsv_vp9_enc_register (GstPlugin * plugin, guint rank, guint impl_index, mfx->FrameInfo.Shift = 0; /* Check max-resolution */ - for (guint i = 0; i < G_N_ELEMENTS (resolutions_to_check); i++) { + for (guint i = 0; i < G_N_ELEMENTS (gst_qsv_resolutions); i++) { mfx->FrameInfo.Width = mfx->FrameInfo.CropW = - GST_ROUND_UP_16 (resolutions_to_check[i].width); + GST_ROUND_UP_16 (gst_qsv_resolutions[i].width); mfx->FrameInfo.Height = mfx->FrameInfo.CropH = - GST_ROUND_UP_16 (resolutions_to_check[i].height); + GST_ROUND_UP_16 (gst_qsv_resolutions[i].height); gst_qsv_vp9_enc_init_vp9_param (&vp9_param); - vp9_param.FrameWidth = resolutions_to_check[i].width; - vp9_param.FrameHeight = resolutions_to_check[i].height; + vp9_param.FrameWidth = gst_qsv_resolutions[i].width; + vp9_param.FrameHeight = gst_qsv_resolutions[i].height; vp9_param.WriteIVFHeaders = MFX_CODINGOPTION_OFF; if (MFXVideoENCODE_Query (session, ¶m, ¶m) != MFX_ERR_NONE) break; - max_resolution.width = resolutions_to_check[i].width; - max_resolution.height = resolutions_to_check[i].height; + max_resolution.width = gst_qsv_resolutions[i].width; + max_resolution.height = gst_qsv_resolutions[i].height; } GST_INFO ("Maximum supported resolution: %dx%d",