/*
* Copyright (C) 2007 Haakon Sporsheim <hakon.sporsheim@tandberg.com>
- * 2008 Ole André Vadla Ravnås <ole.andre.ravnas@tandberg.com>
+ * 2008 Ole André Vadla Ravnås <ole.andre.ravnas@tandberg.com>
* 2009 Knut Inge Hvidsten <knut.inge.hvidsten@tandberg.com>
*
* This library is free software; you can redistribute it and/or
}
static GstStructure *
-ks_video_format_to_structure (GUID subtype_guid, GUID format_guid)
+ks_video_format_to_structure (GUID subtype_guid, GUID format_guid,
+ gboolean * p_is_rgb)
{
GstStructure *structure = NULL;
const gchar *media_type = NULL, *format = NULL;
+ /* RGB formats can be bottom-up (upside down) DIB */
+ gboolean is_rgb = FALSE;
if (IsEqualGUID (&subtype_guid, &MEDIASUBTYPE_MJPG) || IsEqualGUID (&subtype_guid, &MEDIASUBTYPE_TVMJ) || /* FIXME: NOT tested */
IsEqualGUID (&subtype_guid, &MEDIASUBTYPE_WAKE) || /* FIXME: NOT tested */
} else if (IsEqualGUID (&subtype_guid, &MEDIASUBTYPE_RGB555)) {
media_type = "video/x-raw";
format = "RGB15";
+ is_rgb = TRUE;
} else if (IsEqualGUID (&subtype_guid, &MEDIASUBTYPE_RGB565)) {
media_type = "video/x-raw";
format = "RGB16";
+ is_rgb = TRUE;
} else if (IsEqualGUID (&subtype_guid, &MEDIASUBTYPE_RGB24)) {
media_type = "video/x-raw";
- format = "RGBx";
+ format = "BGR";
+ is_rgb = TRUE;
} else if (IsEqualGUID (&subtype_guid, &MEDIASUBTYPE_RGB32)) {
media_type = "video/x-raw";
- format = "RGB";
+ format = "BGRx";
+ is_rgb = TRUE;
} else if (IsEqualGUID (&subtype_guid, &MEDIASUBTYPE_ARGB32)) {
media_type = "video/x-raw";
- format = "ARGB";
+ format = "BGRA";
+ is_rgb = TRUE;
} else if (IsEqualGUID (&subtype_guid, &MEDIASUBTYPE_ARGB1555)) {
GST_WARNING ("Unsupported video format ARGB15555");
} else if (IsEqualGUID (&subtype_guid, &MEDIASUBTYPE_ARGB4444)) {
GST_WARNING ("Unsupported video format ARGB4444");
} else if (memcmp (&subtype_guid.Data2, &MEDIASUBTYPE_FOURCC.Data2,
sizeof (subtype_guid) - sizeof (subtype_guid.Data1)) == 0) {
- guint8 *p = (guint8 *) & subtype_guid.Data1;
- gchar *format = g_strdup_printf ("%c%c%c%c", p[0], p[1], p[2], p[3]);
- structure = gst_structure_new ("video/x-raw", "format",
- G_TYPE_STRING, format, NULL);
+ guint32 fourcc = subtype_guid.Data1;
+ gchar *format =
+ g_strdup_printf ("%" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (fourcc));
+ if (GST_STR_FOURCC (format) == GST_MAKE_FOURCC ('Y', '1', '6', ' ')) {
+ structure = gst_structure_new ("video/x-raw", "format",
+ G_TYPE_STRING, "GRAY16_LE", NULL);
+ } else {
+ structure = gst_structure_new ("video/x-raw", "format",
+ G_TYPE_STRING, format, NULL);
+ }
g_free (format);
} else if (IsEqualGUID (&subtype_guid, &MEDIASUBTYPE_dvsd)) {
if (IsEqualGUID (&format_guid, &FORMAT_DvInfo)) {
if (format) {
gst_structure_set (structure, "format", G_TYPE_STRING, format, NULL);
}
+ if (p_is_rgb) {
+ *p_is_rgb = is_rgb;
+ }
}
if (!structure) {
- GST_DEBUG ("Unknown DirectShow Video GUID %08x-%04x-%04x-%04x-%08x%04x",
- (guint) subtype_guid.Data1, (guint) subtype_guid.Data2,
- (guint) subtype_guid.Data3,
- (guint) subtype_guid.Data4, (guint) & subtype_guid.Data4[2],
- (guint) & subtype_guid.Data4[6]);
+ GST_DEBUG ("Unknown DirectShow Video GUID "
+ "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ (guint) subtype_guid.Data1, subtype_guid.Data2, subtype_guid.Data3,
+ subtype_guid.Data4[0], subtype_guid.Data4[1], subtype_guid.Data4[2],
+ subtype_guid.Data4[3], subtype_guid.Data4[4], subtype_guid.Data4[5],
+ subtype_guid.Data4[6], subtype_guid.Data4[7]);
}
return structure;
guess_aspect (gint width, gint height, gint * par_width, gint * par_height)
{
/*
- * As we dont have access to the actual pixel aspect, we will try to do a
+ * As we don't have access to the actual pixel aspect, we will try to do a
* best-effort guess. The guess is based on most sensors being either 4/3
* or 16/9, and most pixel aspects being close to 1/1.
*/
guint i;
for (i = 0; i < items->Count; i++) {
- if (IsEqualGUID (&range->MajorFormat, &KSDATAFORMAT_TYPE_VIDEO)) {
+ if (IsEqualGUID (&range->MajorFormat, &MEDIATYPE_Video)
+ || IsEqualGUID (&range->MajorFormat, &MEDIATYPE_Interleaved)) {
KsVideoMediaType *entry;
- gpointer src_vscc, src_format;
+ gpointer src_vscc = NULL, src_format = NULL;
GstStructure *media_structure;
entry = g_new0 (KsVideoMediaType, 1);
entry->sample_size =
vr->VideoInfoHeader.hdr.bmiHeader.biSizeImage;
} else if (IsEqualGUID (&range->Specifier, &FORMAT_MPEG2Video)) {
- /* Untested and probably wrong... */
KS_DATARANGE_MPEG2_VIDEO *vr =
(KS_DATARANGE_MPEG2_VIDEO *) entry->range;
-
src_vscc = &vr->ConfigCaps;
src_format = &vr->VideoInfoHeader;
entry->format_size = sizeof (vr->VideoInfoHeader);
entry->sample_size =
vr->VideoInfoHeader.hdr.bmiHeader.biSizeImage;
+ } else if (IsEqualGUID (&range->Specifier, &FORMAT_DvInfo)) {
+ KS_DATARANGE_DVVIDEO *vr = (KS_DATARANGE_DVVIDEO *) entry->range;
+
+ src_vscc = NULL;
+ src_format = &vr->DVVideoInfo;
+
+ entry->format_size = sizeof (vr->DVVideoInfo);
+ entry->sample_size = vr->DataRange.SampleSize;
} else {
gchar *guid_str;
if (entry != NULL) {
g_assert (entry->sample_size != 0);
- memcpy ((gpointer) & entry->vscc, src_vscc, sizeof (entry->vscc));
+ if (src_vscc != NULL) {
+ memcpy ((gpointer) & entry->vscc, src_vscc,
+ sizeof (entry->vscc));
+ }
entry->format = g_malloc (entry->format_size);
memcpy (entry->format, src_format, entry->format_size);
media_structure =
ks_video_format_to_structure (range->SubFormat,
- range->MajorFormat);
+ range->Specifier, &entry->is_rgb);
if (media_structure == NULL) {
g_warning ("ks_video_format_to_structure returned NULL");
ks_video_media_type_free (entry);
entry = NULL;
+ } else if (src_vscc == NULL) {
+ entry->translated_caps = gst_caps_new_empty ();
+ gst_caps_append_structure (entry->translated_caps,
+ media_structure);
} else if (ks_video_append_video_stream_cfg_fields
(media_structure, &entry->vscc)) {
entry->translated_caps = gst_caps_new_empty ();
/* RGB formats */
structure =
ks_video_append_var_video_fields (ks_video_format_to_structure
- (MEDIASUBTYPE_RGB555, FORMAT_VideoInfo));
+ (MEDIASUBTYPE_RGB555, FORMAT_VideoInfo, NULL));
gst_caps_append_structure (caps, structure);
structure =
ks_video_append_var_video_fields (ks_video_format_to_structure
- (MEDIASUBTYPE_RGB565, FORMAT_VideoInfo));
+ (MEDIASUBTYPE_RGB565, FORMAT_VideoInfo, NULL));
gst_caps_append_structure (caps, structure);
structure =
ks_video_append_var_video_fields (ks_video_format_to_structure
- (MEDIASUBTYPE_RGB24, FORMAT_VideoInfo));
+ (MEDIASUBTYPE_RGB24, FORMAT_VideoInfo, NULL));
gst_caps_append_structure (caps, structure);
structure =
ks_video_append_var_video_fields (ks_video_format_to_structure
- (MEDIASUBTYPE_RGB32, FORMAT_VideoInfo));
+ (MEDIASUBTYPE_RGB32, FORMAT_VideoInfo, NULL));
gst_caps_append_structure (caps, structure);
/* YUV formats */
/* Other formats */
structure =
ks_video_append_var_video_fields (ks_video_format_to_structure
- (MEDIASUBTYPE_MJPG, FORMAT_VideoInfo));
+ (MEDIASUBTYPE_MJPG, FORMAT_VideoInfo, NULL));
gst_caps_append_structure (caps, structure);
structure =
ks_video_append_var_video_fields (ks_video_format_to_structure
- (MEDIASUBTYPE_dvsd, FORMAT_VideoInfo));
+ (MEDIASUBTYPE_dvsd, FORMAT_VideoInfo, NULL));
gst_caps_append_structure (caps, structure);
structure = /* no variable video fields (width, height, framerate) */
- ks_video_format_to_structure (MEDIASUBTYPE_dvsd, FORMAT_DvInfo);
+ ks_video_format_to_structure (MEDIASUBTYPE_dvsd, FORMAT_DvInfo, NULL);
gst_caps_append_structure (caps, structure);
}