msdkh265enc: add b-pyramid property

Like as msdkh264enc, b-pyramid is added to enable B-Pyramid reference
structure for H265 encoding

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1908>
This commit is contained in:
Haihao Xiang 2020-12-22 16:17:18 +08:00
parent ff206f6525
commit af988e282a
2 changed files with 24 additions and 0 deletions

View file

@ -52,6 +52,7 @@ enum
PROP_MAX_SLICE_SIZE,
PROP_TUNE_MODE,
PROP_TRANSFORM_SKIP,
PROP_B_PYRAMID,
};
enum
@ -66,6 +67,7 @@ enum
#define PROP_MAX_SLICE_SIZE_DEFAULT 0
#define PROP_TUNE_MODE_DEFAULT MFX_CODINGOPTION_UNKNOWN
#define PROP_TRANSFORM_SKIP_DEFAULT MFX_CODINGOPTION_UNKNOWN
#define PROP_B_PYRAMID_DEFAULT FALSE
#define RAW_FORMATS "NV12, I420, YV12, YUY2, UYVY, BGRA, P010_10LE, VUYA"
#define PROFILES "main, main-10, main-444"
@ -347,6 +349,13 @@ gst_msdkh265enc_configure (GstMsdkEnc * encoder)
}
#endif
if (h265enc->b_pyramid) {
encoder->option2.BRefType = MFX_B_REF_PYRAMID;
/* Don't define Gop structure for B-pyramid, otherwise EncodeInit
* will throw Invalid param error */
encoder->param.mfx.GopRefDist = 0;
}
gst_msdkenc_ensure_extended_coding_options (encoder);
if (h265enc->num_tile_rows > 1 || h265enc->num_tile_cols > 1) {
@ -530,6 +539,10 @@ gst_msdkh265enc_set_property (GObject * object, guint prop_id,
thiz->transform_skip = g_value_get_enum (value);
break;
case PROP_B_PYRAMID:
thiz->b_pyramid = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -574,6 +587,10 @@ gst_msdkh265enc_get_property (GObject * object, guint prop_id, GValue * value,
g_value_set_enum (value, thiz->transform_skip);
break;
case PROP_B_PYRAMID:
g_value_set_boolean (value, thiz->b_pyramid);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -699,6 +716,11 @@ gst_msdkh265enc_class_init (GstMsdkH265EncClass * klass)
gst_msdkenc_transform_skip_get_type (), PROP_TRANSFORM_SKIP_DEFAULT,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_B_PYRAMID,
g_param_spec_boolean ("b-pyramid", "B-pyramid",
"Enable B-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",
@ -719,5 +741,6 @@ gst_msdkh265enc_init (GstMsdkH265Enc * thiz)
thiz->max_slice_size = PROP_MAX_SLICE_SIZE_DEFAULT;
thiz->tune_mode = PROP_TUNE_MODE_DEFAULT;
thiz->transform_skip = PROP_TRANSFORM_SKIP_DEFAULT;
thiz->b_pyramid = PROP_B_PYRAMID_DEFAULT;
msdk_enc->num_extra_frames = 1;
}

View file

@ -63,6 +63,7 @@ struct _GstMsdkH265Enc
gint tune_mode;
guint prop_flag;
gushort transform_skip;
guint b_pyramid;
mfxExtHEVCTiles ext_tiles;
/* roi[0] for current ROI and roi[1] for previous ROI */