From 0afc81312359cd2f1756bd713efa48a161d6d8c2 Mon Sep 17 00:00:00 2001 From: He Junyan Date: Thu, 18 Jul 2019 22:01:01 +0800 Subject: [PATCH] libs: encoder: Consider vp9 profiles based on input format. Only support GST_VAAPI_PROFILE_VP9_0 and GST_VAAPI_PROFILE_VP9_2 now. Fix: #184 --- gst-libs/gst/vaapi/gstvaapiencoder_vp9.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_vp9.c b/gst-libs/gst/vaapi/gstvaapiencoder_vp9.c index 085a184718..14a161664f 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_vp9.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder_vp9.c @@ -149,8 +149,20 @@ ensure_bitrate (GstVaapiEncoderVP9 * encoder) static GstVaapiEncoderStatus ensure_profile (GstVaapiEncoderVP9 * encoder) { - /* Always start from "simple" profile for maximum compatibility */ - encoder->profile = GST_VAAPI_PROFILE_VP9_0; + /* + Profile Color | Depth Chroma | Subsampling + 0 | 8 bit/sample | 4:2:0 + 1 | 8 bit | 4:2:2, 4:4:4 + 2 | 10 or 12 bit | 4:2:0 + 3 | 10 or 12 bit | 4:2:2, 4:4:4 */ + const GstVideoFormat format = + GST_VIDEO_INFO_FORMAT (GST_VAAPI_ENCODER_VIDEO_INFO (encoder)); + if (format == GST_VIDEO_FORMAT_P010_10LE) + encoder->profile = GST_VAAPI_PROFILE_VP9_2; + else if (format == GST_VIDEO_FORMAT_NV12) + encoder->profile = GST_VAAPI_PROFILE_VP9_0; + else + return GST_VAAPI_ENCODER_STATUS_ERROR_UNSUPPORTED_PROFILE; /* Ensure bitrate if not set already */ ensure_bitrate (encoder);