diff options
author | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2009-03-11 19:34:12 +0100 |
---|---|---|
committer | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2009-03-21 10:19:47 +0100 |
commit | 654f0627e4874ec9f010ab7e2d523bd2a3f3fba0 (patch) | |
tree | 6f485075d4e42cec3849e032c3d677250d04e507 /gst/mxf/mxfjpeg2000.c | |
parent | 244c0a4707aa4ffcac9f93d5c8077fd3588feec7 (diff) | |
download | gst-plugins-bad-654f0627e4874ec9f010ab7e2d523bd2a3f3fba0.tar.gz gst-plugins-bad-654f0627e4874ec9f010ab7e2d523bd2a3f3fba0.tar.bz2 gst-plugins-bad-654f0627e4874ec9f010ab7e2d523bd2a3f3fba0.zip |
mxfmux: Add support for muxing JPEG2000 code streams
Diffstat (limited to 'gst/mxf/mxfjpeg2000.c')
-rw-r--r-- | gst/mxf/mxfjpeg2000.c | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/gst/mxf/mxfjpeg2000.c b/gst/mxf/mxfjpeg2000.c index c9d7b2aa..9ff13f70 100644 --- a/gst/mxf/mxfjpeg2000.c +++ b/gst/mxf/mxfjpeg2000.c @@ -31,9 +31,11 @@ #endif #include <gst/gst.h> +#include <gst/video/video.h> #include <string.h> #include "mxfjpeg2000.h" +#include "mxfwrite.h" GST_DEBUG_CATEGORY_EXTERN (mxf_debug); #define GST_CAT_DEFAULT mxf_debug @@ -202,8 +204,123 @@ static const MXFEssenceElementHandler mxf_jpeg2000_essence_element_handler = { mxf_jpeg2000_create_caps }; +static GstFlowReturn +mxf_jpeg2000_write_func (GstBuffer * buffer, GstCaps * caps, + gpointer mapping_data, GstAdapter * adapter, GstBuffer ** outbuf, + gboolean flush) +{ + *outbuf = buffer; + return GST_FLOW_OK; +} + +static const guint8 jpeg2000_essence_container_ul[] = { + 0x06, 0x0e, 0x2b, 0x34, 0x04, 0x01, 0x01, 0x07, + 0x0d, 0x01, 0x03, 0x01, 0x02, 0x0c, 0x01, 0x00 +}; + +static const guint jpeg2000_picture_essence_coding[] = { + 0x06, 0x0E, 0x2B, 0x34, 0x04, 0x01, 0x01, 0x07, + 0x04, 0x01, 0x02, 0x02, 0x03, 0x01, 0x01, 0x00 +}; + +static MXFMetadataFileDescriptor * +mxf_jpeg2000_get_descriptor (GstPadTemplate * tmpl, GstCaps * caps, + MXFEssenceElementWriteFunc * handler, gpointer * mapping_data) +{ + MXFMetadataRGBAPictureEssenceDescriptor *ret; + GstStructure *s; + guint32 fourcc; + + s = gst_caps_get_structure (caps, 0); + if (strcmp (gst_structure_get_name (s), "image/x-jpc") != 0) + return NULL; + + if (!gst_structure_get_fourcc (s, "fourcc", &fourcc)) + return NULL; + + ret = (MXFMetadataRGBAPictureEssenceDescriptor *) + gst_mini_object_new (MXF_TYPE_METADATA_RGBA_PICTURE_ESSENCE_DESCRIPTOR); + + memcpy (&ret->parent.parent.essence_container, &jpeg2000_essence_container_ul, + 16); + memcpy (&ret->parent.picture_essence_coding, &jpeg2000_picture_essence_coding, + 16); + + if (fourcc == GST_MAKE_FOURCC ('s', 'R', 'G', 'B')) { + ret->n_pixel_layout = 3; + ret->pixel_layout = g_new0 (guint8, 6); + ret->pixel_layout[0] = 'R'; + ret->pixel_layout[1] = 8; + ret->pixel_layout[2] = 'G'; + ret->pixel_layout[3] = 8; + ret->pixel_layout[4] = 'B'; + ret->pixel_layout[5] = 8; + } else if (fourcc == GST_MAKE_FOURCC ('s', 'Y', 'U', 'V')) { + ret->n_pixel_layout = 3; + ret->pixel_layout = g_new0 (guint8, 6); + ret->pixel_layout[0] = 'Y'; + ret->pixel_layout[1] = 8; + ret->pixel_layout[2] = 'U'; + ret->pixel_layout[3] = 8; + ret->pixel_layout[4] = 'V'; + ret->pixel_layout[5] = 8; + } else { + g_assert_not_reached (); + } + + mxf_metadata_generic_picture_essence_descriptor_from_caps (&ret->parent, + caps); + *handler = mxf_jpeg2000_write_func; + + return (MXFMetadataFileDescriptor *) ret; +} + +static void +mxf_jpeg2000_update_descriptor (MXFMetadataFileDescriptor * d, GstCaps * caps, + gpointer mapping_data, GstBuffer * buf) +{ + return; +} + +static void +mxf_jpeg2000_get_edit_rate (MXFMetadataFileDescriptor * a, GstCaps * caps, + gpointer mapping_data, GstBuffer * buf, MXFMetadataSourcePackage * package, + MXFMetadataTimelineTrack * track, MXFFraction * edit_rate) +{ + (*edit_rate).n = a->sample_rate.n; + (*edit_rate).d = a->sample_rate.d; +} + +static guint32 +mxf_jpeg2000_get_track_number_template (MXFMetadataFileDescriptor * a, + GstCaps * caps, gpointer mapping_data) +{ + return (0x15 << 24) | (0x08 << 8); +} + +static MXFEssenceElementWriter mxf_jpeg2000_essence_element_writer = { + mxf_jpeg2000_get_descriptor, + mxf_jpeg2000_update_descriptor, + mxf_jpeg2000_get_edit_rate, + mxf_jpeg2000_get_track_number_template, + NULL, + {{0,}} +}; + void mxf_jpeg2000_init (void) { mxf_essence_element_handler_register (&mxf_jpeg2000_essence_element_handler); + + mxf_jpeg2000_essence_element_writer.pad_template = + gst_pad_template_new ("jpeg2000_video_sink_%u", GST_PAD_SINK, + GST_PAD_REQUEST, + gst_caps_from_string ("image/x-jpc, fields = 1, width = " + GST_VIDEO_SIZE_RANGE ", height = " GST_VIDEO_SIZE_RANGE + ", framerate = " GST_VIDEO_FPS_RANGE + ", fourcc = (GstFourcc) { sRGB, sYUV }")); + memcpy (&mxf_jpeg2000_essence_element_writer.data_definition, + mxf_metadata_track_identifier_get (MXF_METADATA_TRACK_PICTURE_ESSENCE), + 16); + mxf_essence_element_writer_register (&mxf_jpeg2000_essence_element_writer); } |