libs: encoder: Consider vp9 profiles based on input format.
authorHe Junyan <junyan.he@hotmail.com>
Thu, 18 Jul 2019 14:01:01 +0000 (22:01 +0800)
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Thu, 15 Aug 2019 14:54:29 +0000 (14:54 +0000)
Only support GST_VAAPI_PROFILE_VP9_0 and GST_VAAPI_PROFILE_VP9_2 now.

Fix: #184

gst-libs/gst/vaapi/gstvaapiencoder_vp9.c

index 085a184..14a1616 100644 (file)
@@ -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);