From 72e26ed30b475553019e0b2952057cfd4b56e27a Mon Sep 17 00:00:00 2001 From: Hyunjun Ko Date: Wed, 7 Dec 2016 11:10:42 +0100 Subject: [PATCH] libs: encoder: split set_context_info() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Split set_context_info() adding init_context_info() which only initialises the GstVaapiContextInfo structure inside GstVaapiEncoder required for VAConfig. https://bugzilla.gnome.org/show_bug.cgi?id=769266 Signed-off-by: Víctor Manuel Jáquez Leal --- gst-libs/gst/vaapi/gstvaapiencoder.c | 32 +++++++++++++++++++--------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapiencoder.c b/gst-libs/gst/vaapi/gstvaapiencoder.c index b8cd4f1341..eac90a81bf 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder.c @@ -588,6 +588,26 @@ unsupported: } } +static void +init_context_info (GstVaapiEncoder * encoder) +{ + GstVaapiContextInfo *const cip = &encoder->context_info; + const GstVaapiEncoderClassData *const cdata = + GST_VAAPI_ENCODER_GET_CLASS (encoder)->class_data; + + cip->usage = GST_VAAPI_CONTEXT_USAGE_ENCODE; + cip->profile = encoder->profile; + if (cdata->codec == GST_VAAPI_CODEC_JPEG) { + cip->entrypoint = GST_VAAPI_ENTRYPOINT_PICTURE_ENCODE; + } else { + if (cip->entrypoint != GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_LP) + cip->entrypoint = GST_VAAPI_ENTRYPOINT_SLICE_ENCODE; + } + cip->width = 0; + cip->height = 0; + cip->ref_frames = encoder->num_ref_frames; +} + /* Updates video context */ static gboolean set_context_info (GstVaapiEncoder * encoder) @@ -596,20 +616,12 @@ set_context_info (GstVaapiEncoder * encoder) GstVaapiConfigInfoEncoder *const config = &cip->config.encoder; const GstVideoFormat format = GST_VIDEO_INFO_FORMAT (GST_VAAPI_ENCODER_VIDEO_INFO (encoder)); - const GstVaapiEncoderClassData *const cdata = - GST_VAAPI_ENCODER_GET_CLASS (encoder)->class_data; - cip->usage = GST_VAAPI_CONTEXT_USAGE_ENCODE; - cip->profile = encoder->profile; - if (cdata->codec != GST_VAAPI_CODEC_JPEG) { - if (cip->entrypoint != GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_LP) - cip->entrypoint = GST_VAAPI_ENTRYPOINT_SLICE_ENCODE; - } else - cip->entrypoint = GST_VAAPI_ENTRYPOINT_PICTURE_ENCODE; + init_context_info (encoder); + cip->chroma_type = gst_vaapi_video_format_get_chroma_type (format); cip->width = GST_VAAPI_ENCODER_WIDTH (encoder); cip->height = GST_VAAPI_ENCODER_HEIGHT (encoder); - cip->ref_frames = encoder->num_ref_frames; if (!is_chroma_type_supported (encoder)) goto error_unsupported_format;