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
This commit is contained in:
Guillaume Desmottes 2017-11-07 15:09:35 +01:00 committed by Nicolas Dufresne
parent 1990580d79
commit 6c57d06ee1

View file

@ -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;
}