summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2017-11-07 15:09:35 +0100
committerNicolas Dufresne <nicolas.dufresne@collabora.com>2018-01-30 09:23:59 +0000
commit6c57d06ee1905cae936eabbfa0b32faf104f0c39 (patch)
tree13333ee2a6bd98d8415360c1c3d144944f75f4f6
parent1990580d798ad7c8d0ad1605b04d5f7d6c41fb55 (diff)
downloadgst-omx-6c57d06ee1905cae936eabbfa0b32faf104f0c39.tar.gz
omxvideoenc: expose chroma format and bit depth in output caps
As we added in the parser (bgo#792039) expose the chroma and bit depth information in output caps. https://bugzilla.gnome.org/show_bug.cgi?id=792040
-rw-r--r--omx/gstomxvideoenc.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c
index 80f9562..035eb89 100644
--- a/omx/gstomxvideoenc.c
+++ b/omx/gstomxvideoenc.c
@@ -549,14 +549,70 @@ gst_omx_video_enc_change_state (GstElement * element, GstStateChange transition)
return ret;
}
+static gboolean
+get_chroma_info_from_input (GstOMXVideoEnc * self, const gchar ** chroma_format,
+ guint * bit_depth_luma, guint * bit_depth_chroma)
+{
+ switch (self->input_state->info.finfo->format) {
+ case GST_VIDEO_FORMAT_GRAY8:
+ *chroma_format = "4:0:0";
+ *bit_depth_luma = 8;
+ *bit_depth_chroma = 0;
+ break;
+ case GST_VIDEO_FORMAT_I420:
+ case GST_VIDEO_FORMAT_NV12:
+ *chroma_format = "4:2:0";
+ *bit_depth_luma = *bit_depth_chroma = 8;
+ break;
+ case GST_VIDEO_FORMAT_NV16:
+ case GST_VIDEO_FORMAT_YUY2:
+ case GST_VIDEO_FORMAT_YVYU:
+ case GST_VIDEO_FORMAT_UYVY:
+ *chroma_format = "4:2:2";
+ *bit_depth_luma = *bit_depth_chroma = 8;
+ break;
+ case GST_VIDEO_FORMAT_GRAY10_LE32:
+ *chroma_format = "4:0:0";
+ *bit_depth_luma = 10;
+ *bit_depth_chroma = 0;
+ break;
+ case GST_VIDEO_FORMAT_NV12_10LE32:
+ *chroma_format = "4:2:0";
+ *bit_depth_luma = *bit_depth_chroma = 10;
+ break;
+ case GST_VIDEO_FORMAT_NV16_10LE32:
+ *chroma_format = "4:2:2";
+ *bit_depth_luma = *bit_depth_chroma = 10;
+ break;
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
static GstCaps *
get_output_caps (GstOMXVideoEnc * self)
{
GstOMXVideoEncClass *klass = GST_OMX_VIDEO_ENC_GET_CLASS (self);
GstCaps *caps;
+ const gchar *chroma_format;
+ guint bit_depth_luma, bit_depth_chroma;
caps = klass->get_caps (self, self->enc_out_port, self->input_state);
+ /* Add chroma info about the encoded stream inferred from the format of the input */
+ if (get_chroma_info_from_input (self, &chroma_format, &bit_depth_luma,
+ &bit_depth_chroma)) {
+ GST_DEBUG_OBJECT (self,
+ "adding chroma info to output caps: %s (luma %d bits) (chroma %d bits)",
+ chroma_format, bit_depth_luma, bit_depth_chroma);
+
+ gst_caps_set_simple (caps, "chroma-format", G_TYPE_STRING, chroma_format,
+ "bit-depth-luma", G_TYPE_UINT, bit_depth_luma,
+ "bit-depth-chroma", G_TYPE_UINT, bit_depth_chroma, NULL);
+ }
+
return caps;
}