diff options
-rw-r--r-- | ext/openjpeg/gstopenjpegdec.c | 12 | ||||
-rw-r--r-- | ext/openjpeg/gstopenjpegdec.h | 1 | ||||
-rw-r--r-- | ext/openjpeg/gstopenjpegenc.c | 13 |
3 files changed, 23 insertions, 3 deletions
diff --git a/ext/openjpeg/gstopenjpegdec.c b/ext/openjpeg/gstopenjpegdec.c index ea929b950..e379b8f62 100644 --- a/ext/openjpeg/gstopenjpegdec.c +++ b/ext/openjpeg/gstopenjpegdec.c @@ -121,6 +121,7 @@ gst_openjpeg_dec_init (GstOpenJPEGDec * self) gst_video_decoder_set_packetized (decoder, TRUE); opj_set_default_decoder_parameters (&self->params); + self->params.cp_limit_decoding = NO_LIMITATION; } static void @@ -216,6 +217,9 @@ gst_openjpeg_dec_set_format (GstVideoDecoder * decoder, else if (g_str_equal (color_space, "sYUV")) self->color_space = CLRSPC_SYCC; + self->ncomps = 0; + gst_structure_get_int (s, "num-components", &self->ncomps); + if (self->input_state) gst_video_codec_state_unref (self->input_state); self->input_state = gst_video_codec_state_ref (state); @@ -552,7 +556,7 @@ gst_openjpeg_dec_negotiate (GstOpenJPEGDec * self, opj_image_t * image) GstVideoFormat format; gint width, height; - if (image->color_space == CLRSPC_UNKNOWN) + if (image->color_space == CLRSPC_UNKNOWN || image->color_space == 0) image->color_space = self->color_space; switch (image->color_space) { @@ -740,6 +744,7 @@ gst_openjpeg_dec_handle_frame (GstVideoDecoder * decoder, opj_cio_t *io; opj_image_t *image; GstVideoFrame vframe; + opj_dparameters_t params; GST_DEBUG_OBJECT (self, "Handling frame"); @@ -757,7 +762,10 @@ gst_openjpeg_dec_handle_frame (GstVideoDecoder * decoder, opj_set_event_mgr ((opj_common_ptr) dec, NULL, NULL); - opj_setup_decoder (dec, &self->params); + params = self->params; + if (self->ncomps) + params.jpwl_exp_comps = self->ncomps; + opj_setup_decoder (dec, ¶ms); if (!gst_buffer_map (frame->input_buffer, &map, GST_MAP_READ)) goto map_read_error; diff --git a/ext/openjpeg/gstopenjpegdec.h b/ext/openjpeg/gstopenjpegdec.h index a1f0612c4..c4a7cd942 100644 --- a/ext/openjpeg/gstopenjpegdec.h +++ b/ext/openjpeg/gstopenjpegdec.h @@ -54,6 +54,7 @@ struct _GstOpenJPEGDec OPJ_CODEC_FORMAT codec_format; gboolean is_jp2c; OPJ_COLOR_SPACE color_space; + gint ncomps; void (*fill_frame) (GstVideoFrame *frame, opj_image_t * image); diff --git a/ext/openjpeg/gstopenjpegenc.c b/ext/openjpeg/gstopenjpegenc.c index 7dfe04ce1..05d8c92f0 100644 --- a/ext/openjpeg/gstopenjpegenc.c +++ b/ext/openjpeg/gstopenjpegenc.c @@ -355,6 +355,7 @@ gst_openjpeg_enc_set_format (GstVideoEncoder * encoder, GstCaps *allowed_caps, *caps; GstStructure *s; const gchar *colorspace; + gint ncomps; GST_DEBUG_OBJECT (self, "Setting format: %" GST_PTR_FORMAT, state->caps); @@ -381,15 +382,19 @@ gst_openjpeg_enc_set_format (GstVideoEncoder * encoder, switch (state->info.finfo->format) { case GST_VIDEO_FORMAT_ARGB64: self->fill_image = fill_image_packed16_4; + ncomps = 4; break; case GST_VIDEO_FORMAT_ARGB: self->fill_image = fill_image_packed8_4; + ncomps = 4; break; case GST_VIDEO_FORMAT_xRGB: self->fill_image = fill_image_packed8_3; + ncomps = 3; break; case GST_VIDEO_FORMAT_AYUV64: self->fill_image = fill_image_packed16_4; + ncomps = 4; break; case GST_VIDEO_FORMAT_Y444_10LE: case GST_VIDEO_FORMAT_Y444_10BE: @@ -398,9 +403,11 @@ gst_openjpeg_enc_set_format (GstVideoEncoder * encoder, case GST_VIDEO_FORMAT_I420_10LE: case GST_VIDEO_FORMAT_I420_10BE: self->fill_image = fill_image_planar16_3; + ncomps = 3; break; case GST_VIDEO_FORMAT_AYUV: self->fill_image = fill_image_packed8_3; + ncomps = 3; break; case GST_VIDEO_FORMAT_Y444: case GST_VIDEO_FORMAT_Y42B: @@ -408,13 +415,16 @@ gst_openjpeg_enc_set_format (GstVideoEncoder * encoder, case GST_VIDEO_FORMAT_Y41B: case GST_VIDEO_FORMAT_YUV9: self->fill_image = fill_image_planar8_3; + ncomps = 3; break; case GST_VIDEO_FORMAT_GRAY8: self->fill_image = fill_image_planar8_1; + ncomps = 1; break; case GST_VIDEO_FORMAT_GRAY16_LE: case GST_VIDEO_FORMAT_GRAY16_BE: self->fill_image = fill_image_planar16_1; + ncomps = 1; break; default: g_assert_not_reached (); @@ -430,7 +440,8 @@ gst_openjpeg_enc_set_format (GstVideoEncoder * encoder, g_return_val_if_reached (FALSE); caps = gst_caps_new_simple (gst_structure_get_name (s), - "colorspace", G_TYPE_STRING, colorspace, NULL); + "colorspace", G_TYPE_STRING, colorspace, + "num-components", G_TYPE_INT, ncomps, NULL); gst_caps_unref (allowed_caps); if (self->output_state) |