gst/matroska/matroska-demux.c: Handle codec_data for VfW compatibility codec IDs (#339451)

Original commit message from CVS:
Patch by: Mark Nauwelaerts  <manauw at skynet dot be>
* gst/matroska/matroska-demux.c: (gst_matroska_demux_video_caps):
Handle codec_data for VfW compatibility codec IDs (#339451)
* gst/matroska/matroska-mux.c:
(gst_matroska_mux_video_pad_setcaps):
Same here, handle codec_data and add additional caps we can handle
now to the pad template (huffyuv, dv and h263 video) (#339451)
This commit is contained in:
Mark Nauwelaerts 2006-04-25 11:45:00 +00:00 committed by Tim-Philipp Müller
parent 2e1a9a0472
commit a0b8e8176a
3 changed files with 77 additions and 35 deletions

View file

@ -1,3 +1,15 @@
2006-04-25 Tim-Philipp Müller <tim at centricular dot net>
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* gst/matroska/matroska-demux.c: (gst_matroska_demux_video_caps):
Handle codec_data for VfW compatibility codec IDs (#339451)
* gst/matroska/matroska-mux.c:
(gst_matroska_mux_video_pad_setcaps):
Same here, handle codec_data and add additional caps we can handle
now to the pad template (huffyuv, dv and h263 video) (#339451)
2006-04-25 Tim-Philipp Müller <tim at centricular dot net> 2006-04-25 Tim-Philipp Müller <tim at centricular dot net>
Patch by: Josef Zlomek <josef dot zlomek at itonis dot tv> Patch by: Josef Zlomek <josef dot zlomek at itonis dot tv>

View file

@ -2976,6 +2976,8 @@ gst_matroska_demux_video_caps (GstMatroskaTrackVideoContext *
gst_riff_strf_vids *vids = NULL; gst_riff_strf_vids *vids = NULL;
if (data) { if (data) {
GstBuffer *buf = NULL;
vids = (gst_riff_strf_vids *) data; vids = (gst_riff_strf_vids *) data;
/* assure size is big enough */ /* assure size is big enough */
@ -3002,8 +3004,18 @@ gst_matroska_demux_video_caps (GstMatroskaTrackVideoContext *
vids->num_colors = GUINT32_FROM_LE (vids->num_colors); vids->num_colors = GUINT32_FROM_LE (vids->num_colors);
vids->imp_colors = GUINT32_FROM_LE (vids->imp_colors); vids->imp_colors = GUINT32_FROM_LE (vids->imp_colors);
if (size > sizeof (gst_riff_strf_vids)) { /* some extra_data */
buf = gst_buffer_new_and_alloc (size - sizeof (gst_riff_strf_vids));
memcpy (GST_BUFFER_DATA (buf),
(guint8 *) vids + sizeof (gst_riff_strf_vids),
GST_BUFFER_SIZE (buf));
}
caps = gst_riff_create_video_caps (vids->compression, NULL, vids, caps = gst_riff_create_video_caps (vids->compression, NULL, vids,
NULL, NULL, codec_name); buf, NULL, codec_name);
if (buf)
gst_buffer_unref (buf);
} }
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_VIDEO_UNCOMPRESSED)) { } else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_VIDEO_UNCOMPRESSED)) {
guint32 fourcc = 0; guint32 fourcc = 0;

View file

@ -72,6 +72,12 @@ static GstStaticPadTemplate videosink_templ =
COMMON_VIDEO_CAPS "; " COMMON_VIDEO_CAPS "; "
"video/x-xvid, " "video/x-xvid, "
COMMON_VIDEO_CAPS "; " COMMON_VIDEO_CAPS "; "
"video/x-huffyuv, "
COMMON_VIDEO_CAPS "; "
"video/x-dv, "
COMMON_VIDEO_CAPS "; "
"video/x-h263, "
COMMON_VIDEO_CAPS "; "
"video/x-msmpeg, " "video/x-msmpeg, "
COMMON_VIDEO_CAPS "; " COMMON_VIDEO_CAPS "; "
"image/jpeg, " "image/jpeg, "
@ -484,12 +490,17 @@ gst_matroska_mux_video_pad_setcaps (GstPad * pad, GstCaps * caps)
context->codec_id = g_strdup (GST_MATROSKA_CODEC_ID_VIDEO_MJPEG); context->codec_id = g_strdup (GST_MATROSKA_CODEC_ID_VIDEO_MJPEG);
return TRUE; return TRUE;
} else if (!strcmp (mimetype, "video/x-divx")) { } else if (!strcmp (mimetype, "video/x-xvid") /* MS/VfW compatibility cases */
gint divxversion; ||!strcmp (mimetype, "video/x-huffyuv")
|| !strcmp (mimetype, "video/x-divx")
|| !strcmp (mimetype, "video/x-dv")
|| !strcmp (mimetype, "video/x-h263")) {
BITMAPINFOHEADER *bih; BITMAPINFOHEADER *bih;
const GValue *codec_data;
gint size = sizeof (BITMAPINFOHEADER);
bih = (BITMAPINFOHEADER *) g_malloc0 (sizeof (BITMAPINFOHEADER)); bih = g_new0 (BITMAPINFOHEADER, 1);
GST_WRITE_UINT32_LE (&bih->bi_size, sizeof (BITMAPINFOHEADER)); GST_WRITE_UINT32_LE (&bih->bi_size, size);
GST_WRITE_UINT32_LE (&bih->bi_width, videocontext->pixel_width); GST_WRITE_UINT32_LE (&bih->bi_width, videocontext->pixel_width);
GST_WRITE_UINT32_LE (&bih->bi_height, videocontext->pixel_height); GST_WRITE_UINT32_LE (&bih->bi_height, videocontext->pixel_height);
GST_WRITE_UINT16_LE (&bih->bi_planes, (guint16) 1); GST_WRITE_UINT16_LE (&bih->bi_planes, (guint16) 1);
@ -497,40 +508,47 @@ gst_matroska_mux_video_pad_setcaps (GstPad * pad, GstCaps * caps)
GST_WRITE_UINT32_LE (&bih->bi_size_image, videocontext->pixel_width * GST_WRITE_UINT32_LE (&bih->bi_size_image, videocontext->pixel_width *
videocontext->pixel_height * 3); videocontext->pixel_height * 3);
gst_structure_get_int (structure, "divxversion", &divxversion); if (!strcmp (mimetype, "video/x-xvid"))
switch (divxversion) { GST_WRITE_UINT32_LE (&bih->bi_compression, GST_STR_FOURCC ("XVID"));
case 3: else if (!strcmp (mimetype, "video/x-huffyuv"))
GST_WRITE_UINT32_LE (&bih->bi_compression, GST_STR_FOURCC ("DIV3")); GST_WRITE_UINT32_LE (&bih->bi_compression, GST_STR_FOURCC ("HFYU"));
break; else if (!strcmp (mimetype, "video/x-dv"))
case 4: GST_WRITE_UINT32_LE (&bih->bi_compression, GST_STR_FOURCC ("DVSD"));
GST_WRITE_UINT32_LE (&bih->bi_compression, GST_STR_FOURCC ("DIVX")); else if (!strcmp (mimetype, "video/x-h263"))
break; GST_WRITE_UINT32_LE (&bih->bi_compression, GST_STR_FOURCC ("H263"));
case 5: else if (!strcmp (mimetype, "video/x-divx")) {
GST_WRITE_UINT32_LE (&bih->bi_compression, GST_STR_FOURCC ("DX50")); gint divxversion;
break;
gst_structure_get_int (structure, "divxversion", &divxversion);
switch (divxversion) {
case 3:
GST_WRITE_UINT32_LE (&bih->bi_compression, GST_STR_FOURCC ("DIV3"));
break;
case 4:
GST_WRITE_UINT32_LE (&bih->bi_compression, GST_STR_FOURCC ("DIVX"));
break;
case 5:
GST_WRITE_UINT32_LE (&bih->bi_compression, GST_STR_FOURCC ("DX50"));
break;
}
}
/* process codec private/initialization data, if any */
codec_data = gst_structure_get_value (structure, "codec_data");
if (codec_data) {
GstBuffer *codec_data_buf;
codec_data_buf = g_value_peek_pointer (codec_data);
size += GST_BUFFER_SIZE (codec_data_buf);
bih = g_realloc (bih, size);
GST_WRITE_UINT32_LE (&bih->bi_size, size);
memcpy ((guint8 *) bih + sizeof (BITMAPINFOHEADER),
GST_BUFFER_DATA (codec_data_buf), GST_BUFFER_SIZE (codec_data_buf));
} }
context->codec_id = g_strdup (GST_MATROSKA_CODEC_ID_VIDEO_VFW_FOURCC); context->codec_id = g_strdup (GST_MATROSKA_CODEC_ID_VIDEO_VFW_FOURCC);
context->codec_priv = (gpointer) bih; context->codec_priv = (gpointer) bih;
context->codec_priv_size = sizeof (BITMAPINFOHEADER); context->codec_priv_size = size;
return TRUE;
} else if (!strcmp (mimetype, "video/x-xvid")) {
BITMAPINFOHEADER *bih;
bih = (BITMAPINFOHEADER *) g_malloc0 (sizeof (BITMAPINFOHEADER));
GST_WRITE_UINT32_LE (&bih->bi_size, sizeof (BITMAPINFOHEADER));
GST_WRITE_UINT32_LE (&bih->bi_width, videocontext->pixel_width);
GST_WRITE_UINT32_LE (&bih->bi_height, videocontext->pixel_height);
GST_WRITE_UINT16_LE (&bih->bi_planes, (guint16) 1);
GST_WRITE_UINT16_LE (&bih->bi_bit_count, (guint16) 24);
GST_WRITE_UINT32_LE (&bih->bi_compression, GST_STR_FOURCC ("XVID"));
GST_WRITE_UINT32_LE (&bih->bi_size_image, videocontext->pixel_width *
videocontext->pixel_height * 3);
context->codec_id = g_strdup (GST_MATROSKA_CODEC_ID_VIDEO_VFW_FOURCC);
context->codec_priv = (gpointer) bih;
context->codec_priv_size = sizeof (BITMAPINFOHEADER);
return TRUE; return TRUE;
} else if (!strcmp (mimetype, "video/x-h264")) { } else if (!strcmp (mimetype, "video/x-h264")) {