decoder: h264: properly support grayscale formats.
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Sat, 10 May 2014 04:23:29 +0000 (06:23 +0200)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Sat, 10 May 2014 04:29:25 +0000 (06:29 +0200)
Request the correct chroma format for decoding grayscale streams.
i.e. make lookups of the VA chroma format more generic, thus possibly
supporting more formats in the future.

This means that, if a VA driver doesn't support grayscale formats,
it is now going to fail. We cannot safely assume that maybe grayscale
was implemented on top of some YUV 4:2:0 with the chroma components
all set to 0x80.

gst-libs/gst/vaapi/gstvaapicontext.c
gst-libs/gst/vaapi/gstvaapidecoder_h264.c
gst-libs/gst/vaapi/gstvaapiutils.c
gst-libs/gst/vaapi/gstvaapiutils.h

index 45ecf9c..e79c30f 100644 (file)
@@ -195,8 +195,11 @@ context_create (GstVaapiContext * context)
   attrib->type = VAConfigAttribRTFormat;
   if (!context_get_attribute (context, attrib->type, &value))
     goto cleanup;
-  if (!(value & va_chroma_format))
+  if (!(value & va_chroma_format)) {
+    GST_ERROR ("unsupported chroma format (%s)",
+        string_of_va_chroma_format (va_chroma_format));
     goto cleanup;
+  }
   attrib->value = va_chroma_format;
   attrib++;
 
index b870c92..d12cbca 100644 (file)
@@ -957,7 +957,7 @@ ensure_context(GstVaapiDecoderH264 *decoder, GstH264SPS *sps)
     /* XXX: fix surface size when cropping is implemented */
     info.profile    = priv->profile;
     info.entrypoint = priv->entrypoint;
-    info.chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420;
+    info.chroma_type = priv->chroma_type;
     info.width      = sps->width;
     info.height     = sps->height;
     info.ref_frames = get_max_dec_frame_buffering(sps);
index 87923cc..63e4691 100644 (file)
@@ -208,6 +208,29 @@ string_of_VADisplayAttributeType (VADisplayAttribType attribute_type)
   return "<unknown>";
 }
 
+/* Return a string representation of a VA chroma format */
+const gchar *
+string_of_va_chroma_format (guint chroma_format)
+{
+  switch (chroma_format) {
+#define MAP(value) \
+        STRCASEP(VA_RT_FORMAT_, value)
+      MAP (YUV420);
+      MAP (YUV422);
+      MAP (YUV444);
+#if VA_CHECK_VERSION(0,34,0)
+      MAP (YUV400);
+      MAP (RGB16);
+      MAP (RGB32);
+      MAP (RGBP);
+#endif
+#undef MAP
+    default:
+      break;
+  }
+  return "<unknown>";
+}
+
 const gchar *
 string_of_VARateControl (guint rate_control)
 {
index fb5b1e4..e5f8503 100644 (file)
@@ -71,6 +71,11 @@ G_GNUC_INTERNAL
 const gchar *
 string_of_VADisplayAttributeType (VADisplayAttribType attribute_type);
 
+/* Return a string representation of a VA chroma format */
+G_GNUC_INTERNAL
+const gchar *
+string_of_va_chroma_format (guint chroma_format);
+
 G_GNUC_INTERNAL
 const gchar *
 string_of_VARateControl (guint rate_control);