mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 01:45:33 +00:00
msdkenc{h264,h265}: add p-pyramid property
The SDK can support P-Pyramid reference structure [1], so add a new property to enable this feature in msdkenc{h264,h265}. [1] https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#preftype Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1908>
This commit is contained in:
parent
af988e282a
commit
7bc3d51b42
4 changed files with 50 additions and 0 deletions
|
@ -54,6 +54,7 @@ enum
|
|||
PROP_MAX_SLICE_SIZE,
|
||||
PROP_B_PYRAMID,
|
||||
PROP_TUNE_MODE,
|
||||
PROP_P_PYRAMID,
|
||||
};
|
||||
|
||||
enum
|
||||
|
@ -70,6 +71,7 @@ enum
|
|||
#define PROP_MAX_SLICE_SIZE_DEFAULT 0
|
||||
#define PROP_B_PYRAMID_DEFAULT FALSE
|
||||
#define PROP_TUNE_MODE_DEFAULT MFX_CODINGOPTION_UNKNOWN
|
||||
#define PROP_P_PYRAMID_DEFAULT FALSE
|
||||
|
||||
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
|
@ -388,6 +390,15 @@ gst_msdkh264enc_configure (GstMsdkEnc * encoder)
|
|||
encoder->param.mfx.GopRefDist = 0;
|
||||
}
|
||||
|
||||
if (thiz->p_pyramid) {
|
||||
encoder->option3.PRefType = MFX_P_REF_PYRAMID;
|
||||
/* MFX_P_REF_PYRAMID is available for GopRefDist = 1 */
|
||||
encoder->param.mfx.GopRefDist = 1;
|
||||
/* SDK decides the DPB size for P pyramid */
|
||||
encoder->param.mfx.NumRefFrame = 0;
|
||||
encoder->enable_extopt3 = TRUE;
|
||||
}
|
||||
|
||||
/* Enable Extended coding options */
|
||||
gst_msdkenc_ensure_extended_coding_options (encoder);
|
||||
|
||||
|
@ -557,6 +568,9 @@ gst_msdkh264enc_set_property (GObject * object, guint prop_id,
|
|||
thiz->tune_mode = g_value_get_enum (value);
|
||||
thiz->prop_flag |= GST_MSDK_FLAG_TUNE_MODE;
|
||||
break;
|
||||
case PROP_P_PYRAMID:
|
||||
thiz->p_pyramid = g_value_get_boolean (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -602,6 +616,9 @@ gst_msdkh264enc_get_property (GObject * object, guint prop_id, GValue * value,
|
|||
case PROP_TUNE_MODE:
|
||||
g_value_set_enum (value, thiz->tune_mode);
|
||||
break;
|
||||
case PROP_P_PYRAMID:
|
||||
g_value_set_boolean (value, thiz->p_pyramid);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -703,6 +720,11 @@ gst_msdkh264enc_class_init (GstMsdkH264EncClass * klass)
|
|||
gst_msdkenc_tune_mode_get_type (), PROP_TUNE_MODE_DEFAULT,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_P_PYRAMID,
|
||||
g_param_spec_boolean ("p-pyramid", "P-pyramid",
|
||||
"Enable P-Pyramid Reference structure", FALSE,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
gst_element_class_set_static_metadata (element_class,
|
||||
"Intel MSDK H264 encoder", "Codec/Encoder/Video/Hardware",
|
||||
"H264 video encoder based on Intel Media SDK",
|
||||
|
@ -721,4 +743,5 @@ gst_msdkh264enc_init (GstMsdkH264Enc * thiz)
|
|||
thiz->max_slice_size = PROP_MAX_SLICE_SIZE_DEFAULT;
|
||||
thiz->b_pyramid = PROP_B_PYRAMID_DEFAULT;
|
||||
thiz->tune_mode = PROP_TUNE_MODE_DEFAULT;
|
||||
thiz->p_pyramid = PROP_P_PYRAMID_DEFAULT;
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ struct _GstMsdkH264Enc
|
|||
guint b_pyramid;
|
||||
gint tune_mode;
|
||||
guint prop_flag;
|
||||
guint p_pyramid;
|
||||
|
||||
GstH264NalParser *parser;
|
||||
GArray *cc_sei_array;
|
||||
|
|
|
@ -53,6 +53,7 @@ enum
|
|||
PROP_TUNE_MODE,
|
||||
PROP_TRANSFORM_SKIP,
|
||||
PROP_B_PYRAMID,
|
||||
PROP_P_PYRAMID,
|
||||
};
|
||||
|
||||
enum
|
||||
|
@ -68,6 +69,7 @@ enum
|
|||
#define PROP_TUNE_MODE_DEFAULT MFX_CODINGOPTION_UNKNOWN
|
||||
#define PROP_TRANSFORM_SKIP_DEFAULT MFX_CODINGOPTION_UNKNOWN
|
||||
#define PROP_B_PYRAMID_DEFAULT FALSE
|
||||
#define PROP_P_PYRAMID_DEFAULT FALSE
|
||||
|
||||
#define RAW_FORMATS "NV12, I420, YV12, YUY2, UYVY, BGRA, P010_10LE, VUYA"
|
||||
#define PROFILES "main, main-10, main-444"
|
||||
|
@ -356,6 +358,15 @@ gst_msdkh265enc_configure (GstMsdkEnc * encoder)
|
|||
encoder->param.mfx.GopRefDist = 0;
|
||||
}
|
||||
|
||||
if (h265enc->p_pyramid) {
|
||||
encoder->option3.PRefType = MFX_P_REF_PYRAMID;
|
||||
/* MFX_P_REF_PYRAMID is available for GopRefDist = 1 */
|
||||
encoder->param.mfx.GopRefDist = 1;
|
||||
/* SDK decides the DPB size for P pyramid */
|
||||
encoder->param.mfx.NumRefFrame = 0;
|
||||
encoder->enable_extopt3 = TRUE;
|
||||
}
|
||||
|
||||
gst_msdkenc_ensure_extended_coding_options (encoder);
|
||||
|
||||
if (h265enc->num_tile_rows > 1 || h265enc->num_tile_cols > 1) {
|
||||
|
@ -543,6 +554,10 @@ gst_msdkh265enc_set_property (GObject * object, guint prop_id,
|
|||
thiz->b_pyramid = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
case PROP_P_PYRAMID:
|
||||
thiz->p_pyramid = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -591,6 +606,10 @@ gst_msdkh265enc_get_property (GObject * object, guint prop_id, GValue * value,
|
|||
g_value_set_boolean (value, thiz->b_pyramid);
|
||||
break;
|
||||
|
||||
case PROP_P_PYRAMID:
|
||||
g_value_set_boolean (value, thiz->p_pyramid);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -721,6 +740,11 @@ gst_msdkh265enc_class_init (GstMsdkH265EncClass * klass)
|
|||
"Enable B-Pyramid Reference structure", FALSE,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_P_PYRAMID,
|
||||
g_param_spec_boolean ("p-pyramid", "P-pyramid",
|
||||
"Enable P-Pyramid Reference structure", FALSE,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
gst_element_class_set_static_metadata (element_class,
|
||||
"Intel MSDK H265 encoder",
|
||||
"Codec/Encoder/Video/Hardware",
|
||||
|
@ -742,5 +766,6 @@ gst_msdkh265enc_init (GstMsdkH265Enc * thiz)
|
|||
thiz->tune_mode = PROP_TUNE_MODE_DEFAULT;
|
||||
thiz->transform_skip = PROP_TRANSFORM_SKIP_DEFAULT;
|
||||
thiz->b_pyramid = PROP_B_PYRAMID_DEFAULT;
|
||||
thiz->p_pyramid = PROP_P_PYRAMID_DEFAULT;
|
||||
msdk_enc->num_extra_frames = 1;
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ struct _GstMsdkH265Enc
|
|||
guint prop_flag;
|
||||
gushort transform_skip;
|
||||
guint b_pyramid;
|
||||
guint p_pyramid;
|
||||
|
||||
mfxExtHEVCTiles ext_tiles;
|
||||
/* roi[0] for current ROI and roi[1] for previous ROI */
|
||||
|
|
Loading…
Reference in a new issue