From f6e81c84e91d9019bf08dfc37c07c988cd976693 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 7 Dec 2008 18:39:41 +0000 Subject: [PATCH] gst/mxf/mxfup.c: Handle the image start and end offsets, otherwise we output too large image buffers. Original commit message from CVS: * gst/mxf/mxfup.c: (mxf_up_handle_essence_element), (mxf_up_rgba_create_caps): Handle the image start and end offsets, otherwise we output too large image buffers. --- ChangeLog | 7 +++++++ gst/mxf/mxfup.c | 41 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b0b20a8..b719d20 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2008-12-07 Sebastian Dröge + * gst/mxf/mxfup.c: (mxf_up_handle_essence_element), + (mxf_up_rgba_create_caps): + Handle the image start and end offsets, otherwise we output + too large image buffers. + +2008-12-07 Sebastian Dröge + * gst/mxf/mxfmpeg.c: (mxf_mpeg_es_create_caps): Set codec name tags for the MPEG audio essence. diff --git a/gst/mxf/mxfup.c b/gst/mxf/mxfup.c index 2d40175..77adcc0 100644 --- a/gst/mxf/mxfup.c +++ b/gst/mxf/mxfup.c @@ -24,6 +24,8 @@ /* TODO: * - Handle CDCI essence * - Correctly transform for the GStreamer strides + * - Handle all the dimensions and other properties in the picture + * essence descriptors correctly according to S377M Annex E */ #ifdef HAVE_CONFIG_H @@ -40,6 +42,12 @@ GST_DEBUG_CATEGORY_EXTERN (mxf_debug); #define GST_CAT_DEFAULT mxf_debug +typedef struct +{ + guint32 image_start_offset; + guint32 image_end_offset; +} MXFUPMappingData; + gboolean mxf_is_up_essence_track (const MXFMetadataTrack * track) { @@ -68,7 +76,7 @@ mxf_up_handle_essence_element (const MXFUL * key, GstBuffer * buffer, MXFMetadataTrack * track, MXFMetadataStructuralComponent * component, gpointer mapping_data, GstBuffer ** outbuf) { - *outbuf = buffer; + MXFUPMappingData *data = mapping_data; /* SMPTE 384M 7.1 */ if (key->u[12] != 0x15 || (key->u[14] != 0x01 && key->u[14] != 0x02 @@ -77,6 +85,26 @@ mxf_up_handle_essence_element (const MXFUL * key, GstBuffer * buffer, return GST_FLOW_ERROR; } + if (!data || (data->image_start_offset == 0 && data->image_end_offset == 0)) { + *outbuf = buffer; + } else { + if (data->image_start_offset + data->image_end_offset + > GST_BUFFER_SIZE (buffer)) { + gst_buffer_unref (buffer); + GST_ERROR ("Invalid buffer size"); + return GST_FLOW_ERROR; + } else { + *outbuf = + gst_buffer_create_sub (buffer, data->image_start_offset, + GST_BUFFER_SIZE (buffer) - data->image_end_offset - + data->image_start_offset); + gst_buffer_copy_metadata (*outbuf, buffer, + GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS | + GST_BUFFER_COPY_CAPS); + gst_buffer_unref (buffer); + } + } + return GST_FLOW_OK; } @@ -157,6 +185,17 @@ mxf_up_rgba_create_caps (MXFMetadataGenericPackage * package, return NULL; } + if (caps) { + MXFUPMappingData *data = g_new0 (MXFUPMappingData, 1); + + data->image_start_offset = + ((MXFMetadataGenericPictureEssenceDescriptor *) d)->image_start_offset; + data->image_end_offset = + ((MXFMetadataGenericPictureEssenceDescriptor *) d)->image_end_offset; + + *mapping_data = data; + } + return caps; } -- 2.7.4