diff options
author | Sebastian Dröge <slomo@circular-chaos.org> | 2008-11-25 14:49:34 +0000 |
---|---|---|
committer | Sebastian Dröge <slomo@circular-chaos.org> | 2008-11-25 14:49:34 +0000 |
commit | 15afef86524b53f2c2d5f8f5966418e4ef8368d0 (patch) | |
tree | 69679c5d865cd8f759bda17a27d8cb34e5f380fc /gst | |
parent | 4f365b391e9ab1582c2374889f4255da61f8d330 (diff) | |
download | gst-plugins-bad-15afef86524b53f2c2d5f8f5966418e4ef8368d0.tar.gz gst-plugins-bad-15afef86524b53f2c2d5f8f5966418e4ef8368d0.tar.bz2 gst-plugins-bad-15afef86524b53f2c2d5f8f5966418e4ef8368d0.zip |
gst/mxf/: Set video dimensions and pixel aspect ratio on the caps.
Original commit message from CVS:
* gst/mxf/mxfmpeg.c: (mxf_mpeg_video_create_caps):
* gst/mxf/mxfparse.c:
(mxf_metadata_generic_picture_essence_descriptor_set_caps):
* gst/mxf/mxfparse.h:
Set video dimensions and pixel aspect ratio on the caps.
Diffstat (limited to 'gst')
-rw-r--r-- | gst/mxf/mxfmpeg.c | 28 | ||||
-rw-r--r-- | gst/mxf/mxfparse.c | 31 | ||||
-rw-r--r-- | gst/mxf/mxfparse.h | 1 |
3 files changed, 50 insertions, 10 deletions
diff --git a/gst/mxf/mxfmpeg.c b/gst/mxf/mxfmpeg.c index ab70780b..18f652ff 100644 --- a/gst/mxf/mxfmpeg.c +++ b/gst/mxf/mxfmpeg.c @@ -23,6 +23,7 @@ /* TODO: * - Handle PES streams + * - Fix TS/PS demuxers to forward timestamps */ #ifdef HAVE_CONFIG_H @@ -242,7 +243,9 @@ mxf_mpeg_video_create_caps (MXFMetadataGenericPackage * package, { MXFMetadataMPEGVideoDescriptor *d = NULL; MXFMetadataFileDescriptor *f = NULL; + MXFMetadataGenericPictureEssenceDescriptor *p = NULL; guint i; + GstCaps *caps = NULL; g_return_val_if_fail (package != NULL, NULL); g_return_val_if_fail (track != NULL, NULL); @@ -257,12 +260,16 @@ mxf_mpeg_video_create_caps (MXFMetadataGenericPackage * package, MXF_METADATA_MPEG_VIDEO_DESCRIPTOR) { d = (MXFMetadataMPEGVideoDescriptor *) track->descriptor[i]; f = track->descriptor[i]; + p = (MXFMetadataGenericPictureEssenceDescriptor *) track->descriptor[i]; + break; + } else if (((MXFMetadataGenericDescriptor *) track->descriptor[i])->type == + MXF_METADATA_CDCI_PICTURE_ESSENCE_DESCRIPTOR || + ((MXFMetadataGenericDescriptor *) track->descriptor[i])->type == + MXF_METADATA_GENERIC_PICTURE_ESSENCE_DESCRIPTOR) { + f = track->descriptor[i]; + p = (MXFMetadataGenericPictureEssenceDescriptor *) track->descriptor[i]; break; } else if (((MXFMetadataGenericDescriptor *) track->descriptor[i])->type == - MXF_METADATA_CDCI_PICTURE_ESSENCE_DESCRIPTOR - || ((MXFMetadataGenericDescriptor *) track->descriptor[i])->type == - MXF_METADATA_GENERIC_PICTURE_ESSENCE_DESCRIPTOR - || ((MXFMetadataGenericDescriptor *) track->descriptor[i])->type == MXF_METADATA_FILE_DESCRIPTOR) { f = track->descriptor[i]; } @@ -278,7 +285,7 @@ mxf_mpeg_video_create_caps (MXFMetadataGenericPackage * package, if (f->essence_container.u[13] == 0x04) { /* FIXME: get mpeg version somehow */ GST_DEBUG ("Found MPEG ES stream"); - return gst_caps_new_simple ("video/mpeg", "mpegversion", G_TYPE_INT, 1, + caps = gst_caps_new_simple ("video/mpeg", "mpegversion", G_TYPE_INT, 1, "systemstream", G_TYPE_BOOLEAN, FALSE, NULL); } else if (f->essence_container.u[13] == 0x07) { GST_ERROR ("MPEG PES streams not supported yet"); @@ -286,11 +293,16 @@ mxf_mpeg_video_create_caps (MXFMetadataGenericPackage * package, } else if (f->essence_container.u[13] == 0x08) { /* FIXME: get mpeg version somehow */ GST_DEBUG ("Found MPEG PS stream"); - return gst_caps_new_simple ("video/mpeg", "mpegversion", G_TYPE_INT, 1, + caps = gst_caps_new_simple ("video/mpeg", "mpegversion", G_TYPE_INT, 1, "systemstream", G_TYPE_BOOLEAN, TRUE, NULL); } else if (f->essence_container.u[13] == 0x09) { GST_DEBUG ("Found MPEG TS stream"); - return gst_caps_new_simple ("video/mpegts", NULL); + caps = gst_caps_new_simple ("video/mpegts", NULL); + } - return NULL; + + if (p) + mxf_metadata_generic_picture_essence_descriptor_set_caps (p, caps); + + return caps; } diff --git a/gst/mxf/mxfparse.c b/gst/mxf/mxfparse.c index 0f5323e7..efe102b5 100644 --- a/gst/mxf/mxfparse.c +++ b/gst/mxf/mxfparse.c @@ -2278,11 +2278,38 @@ void mxf_metadata_generic_picture_essence_descriptor_reset memset (descriptor, 0, sizeof (MXFMetadataGenericPictureEssenceDescriptor)); } +void mxf_metadata_generic_picture_essence_descriptor_set_caps + (MXFMetadataGenericPictureEssenceDescriptor * descriptor, GstCaps * caps) +{ + guint par_n, par_d; + guint width, height; + + g_return_if_fail (descriptor != NULL); + g_return_if_fail (GST_IS_CAPS (caps)); + + width = descriptor->stored_width; + height = descriptor->stored_height; + + if (width == 0 || height == 0) + return; + + gst_caps_set_simple (caps, "width", G_TYPE_INT, width, "height", G_TYPE_INT, + height, NULL); + + if (descriptor->aspect_ratio.n == 0 || descriptor->aspect_ratio.d == 0) + return; + + par_n = height * descriptor->aspect_ratio.n; + par_d = width * descriptor->aspect_ratio.d; + + gst_caps_set_simple (caps, "pixel-aspect-ratio", GST_TYPE_FRACTION, + par_n, par_d, NULL); +} + gboolean mxf_metadata_cdci_picture_essence_descriptor_handle_tag (MXFMetadataGenericDescriptor * d, const MXFPrimerPack * primer, - guint16 tag, const guint8 * tag_data, guint16 tag_size) -{ + guint16 tag, const guint8 * tag_data, guint16 tag_size) { MXFMetadataCDCIPictureEssenceDescriptor *descriptor = (MXFMetadataCDCIPictureEssenceDescriptor *) d; gboolean ret = FALSE; diff --git a/gst/mxf/mxfparse.h b/gst/mxf/mxfparse.h index 8a6b3437..94a5d766 100644 --- a/gst/mxf/mxfparse.h +++ b/gst/mxf/mxfparse.h @@ -126,6 +126,7 @@ void mxf_metadata_generic_sound_essence_descriptor_reset (MXFMetadataGenericSoun gboolean mxf_metadata_generic_picture_essence_descriptor_handle_tag (MXFMetadataGenericDescriptor *descriptor, const MXFPrimerPack *primer, guint16 tag, const guint8 *tag_data, guint16 tag_size); void mxf_metadata_generic_picture_essence_descriptor_reset (MXFMetadataGenericPictureEssenceDescriptor *descriptor); +void mxf_metadata_generic_picture_essence_descriptor_set_caps (MXFMetadataGenericPictureEssenceDescriptor *descriptor, GstCaps *caps); gboolean mxf_metadata_cdci_picture_essence_descriptor_handle_tag (MXFMetadataGenericDescriptor *descriptor, const MXFPrimerPack *primer, guint16 tag, const guint8 *tag_data, guint16 tag_size); |