From 14e9d383e3ccfede18084da96243e769f3ec381d Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Fri, 25 Apr 2014 13:47:53 +0200 Subject: [PATCH] encoder: derive chroma type from video format. Cope with previous VA context change to derive the correct surface chroma type from the input video format. --- gst-libs/gst/vaapi/gstvaapiencoder.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapiencoder.c b/gst-libs/gst/vaapi/gstvaapiencoder.c index b055ef5ae0..520bea4e36 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder.c @@ -543,22 +543,37 @@ get_packed_headers (GstVaapiEncoder * encoder) } /* Updates video context */ -static void +static gboolean set_context_info (GstVaapiEncoder * encoder) { GstVaapiContextInfo *const cip = &encoder->context_info; GstVaapiConfigInfoEncoder *const config = &cip->config.encoder; + const GstVideoFormat format = + GST_VIDEO_INFO_FORMAT (GST_VAAPI_ENCODER_VIDEO_INFO (encoder)); cip->usage = GST_VAAPI_CONTEXT_USAGE_ENCODE; cip->profile = encoder->profile; cip->entrypoint = GST_VAAPI_ENTRYPOINT_SLICE_ENCODE; + 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 (!cip->chroma_type) + goto error_unsupported_format; + memset (config, 0, sizeof (*config)); config->rc_mode = GST_VAAPI_ENCODER_RATE_CONTROL (encoder); config->packed_headers = get_packed_headers (encoder); + return TRUE; + + /* ERRORS */ +error_unsupported_format: + { + GST_ERROR ("failed to determine chroma type for format %s", + gst_vaapi_video_format_to_string (format)); + return FALSE; + } } /* Ensures the underlying VA context for encoding is created */ @@ -567,7 +582,8 @@ gst_vaapi_encoder_ensure_context (GstVaapiEncoder * encoder) { GstVaapiContextInfo *const cip = &encoder->context_info; - set_context_info (encoder); + if (!set_context_info (encoder)) + return FALSE; if (encoder->context) { if (!gst_vaapi_context_reset (encoder->context, cip))