diff options
author | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2012-12-15 11:25:36 +0100 |
---|---|---|
committer | Sebastian Dröge <slomo@circular-chaos.org> | 2013-07-29 12:30:22 +0200 |
commit | 844f7528b5774a5455f59f9be2a5d0a539bfddfe (patch) | |
tree | 78c4b58caf0491aa3aee7c8906a699c740b1a8b2 | |
parent | c7a34979f7d39a7d7a52edc1aa948575ec2eb5df (diff) | |
download | gstreamer-plugins-bad-844f7528b5774a5455f59f9be2a5d0a539bfddfe.tar.gz |
openjpeg: Add support for the colorspace field in the caps
-rw-r--r-- | ext/openjpeg/gstopenjpegdec.c | 14 | ||||
-rw-r--r-- | ext/openjpeg/gstopenjpegdec.h | 1 | ||||
-rw-r--r-- | ext/openjpeg/gstopenjpegenc.c | 13 |
3 files changed, 27 insertions, 1 deletions
diff --git a/ext/openjpeg/gstopenjpegdec.c b/ext/openjpeg/gstopenjpegdec.c index 49c469f2b..ea929b950 100644 --- a/ext/openjpeg/gstopenjpegdec.c +++ b/ext/openjpeg/gstopenjpegdec.c @@ -187,11 +187,14 @@ gst_openjpeg_dec_set_format (GstVideoDecoder * decoder, { GstOpenJPEGDec *self = GST_OPENJPEG_DEC (decoder); GstStructure *s; + const gchar *color_space; GST_DEBUG_OBJECT (self, "Setting format: %" GST_PTR_FORMAT, state->caps); s = gst_caps_get_structure (state->caps, 0); + self->color_space = CLRSPC_UNKNOWN; + if (gst_structure_has_name (s, "image/jp2")) { self->codec_format = CODEC_JP2; self->is_jp2c = FALSE; @@ -205,6 +208,14 @@ gst_openjpeg_dec_set_format (GstVideoDecoder * decoder, g_return_val_if_reached (FALSE); } + color_space = gst_structure_get_string (s, "colorspace"); + if (g_str_equal (color_space, "sRGB")) + self->color_space = CLRSPC_SRGB; + else if (g_str_equal (color_space, "GRAY")) + self->color_space = CLRSPC_GRAY; + else if (g_str_equal (color_space, "sYUV")) + self->color_space = CLRSPC_SYCC; + if (self->input_state) gst_video_codec_state_unref (self->input_state); self->input_state = gst_video_codec_state_ref (state); @@ -541,6 +552,9 @@ gst_openjpeg_dec_negotiate (GstOpenJPEGDec * self, opj_image_t * image) GstVideoFormat format; gint width, height; + if (image->color_space == CLRSPC_UNKNOWN) + image->color_space = self->color_space; + switch (image->color_space) { case CLRSPC_SRGB: if (image->numcomps == 4) { diff --git a/ext/openjpeg/gstopenjpegdec.h b/ext/openjpeg/gstopenjpegdec.h index 1dab83f39..a1f0612c4 100644 --- a/ext/openjpeg/gstopenjpegdec.h +++ b/ext/openjpeg/gstopenjpegdec.h @@ -53,6 +53,7 @@ struct _GstOpenJPEGDec OPJ_CODEC_FORMAT codec_format; gboolean is_jp2c; + OPJ_COLOR_SPACE color_space; void (*fill_frame) (GstVideoFrame *frame, opj_image_t * image); diff --git a/ext/openjpeg/gstopenjpegenc.c b/ext/openjpeg/gstopenjpegenc.c index b17cfbf92..7dfe04ce1 100644 --- a/ext/openjpeg/gstopenjpegenc.c +++ b/ext/openjpeg/gstopenjpegenc.c @@ -354,6 +354,7 @@ gst_openjpeg_enc_set_format (GstVideoEncoder * encoder, GstOpenJPEGEnc *self = GST_OPENJPEG_ENC (encoder); GstCaps *allowed_caps, *caps; GstStructure *s; + const gchar *colorspace; GST_DEBUG_OBJECT (self, "Setting format: %" GST_PTR_FORMAT, state->caps); @@ -419,7 +420,17 @@ gst_openjpeg_enc_set_format (GstVideoEncoder * encoder, g_assert_not_reached (); } - caps = gst_caps_new_empty_simple (gst_structure_get_name (s)); + if ((state->info.finfo->flags & GST_VIDEO_FORMAT_FLAG_YUV)) + colorspace = "sYUV"; + else if ((state->info.finfo->flags & GST_VIDEO_FORMAT_FLAG_RGB)) + colorspace = "sRGB"; + else if ((state->info.finfo->flags & GST_VIDEO_FORMAT_FLAG_GRAY)) + colorspace = "GRAY"; + else + g_return_val_if_reached (FALSE); + + caps = gst_caps_new_simple (gst_structure_get_name (s), + "colorspace", G_TYPE_STRING, colorspace, NULL); gst_caps_unref (allowed_caps); if (self->output_state) |