mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-03 05:59:10 +00:00
openjpeg: Handle the num-components field in the caps
This commit is contained in:
parent
8547618f96
commit
cb5dcaba76
3 changed files with 23 additions and 3 deletions
|
@ -121,6 +121,7 @@ gst_openjpeg_dec_init (GstOpenJPEGDec * self)
|
||||||
|
|
||||||
gst_video_decoder_set_packetized (decoder, TRUE);
|
gst_video_decoder_set_packetized (decoder, TRUE);
|
||||||
opj_set_default_decoder_parameters (&self->params);
|
opj_set_default_decoder_parameters (&self->params);
|
||||||
|
self->params.cp_limit_decoding = NO_LIMITATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -216,6 +217,9 @@ gst_openjpeg_dec_set_format (GstVideoDecoder * decoder,
|
||||||
else if (g_str_equal (color_space, "sYUV"))
|
else if (g_str_equal (color_space, "sYUV"))
|
||||||
self->color_space = CLRSPC_SYCC;
|
self->color_space = CLRSPC_SYCC;
|
||||||
|
|
||||||
|
self->ncomps = 0;
|
||||||
|
gst_structure_get_int (s, "num-components", &self->ncomps);
|
||||||
|
|
||||||
if (self->input_state)
|
if (self->input_state)
|
||||||
gst_video_codec_state_unref (self->input_state);
|
gst_video_codec_state_unref (self->input_state);
|
||||||
self->input_state = gst_video_codec_state_ref (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;
|
GstVideoFormat format;
|
||||||
gint width, height;
|
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;
|
image->color_space = self->color_space;
|
||||||
|
|
||||||
switch (image->color_space) {
|
switch (image->color_space) {
|
||||||
|
@ -740,6 +744,7 @@ gst_openjpeg_dec_handle_frame (GstVideoDecoder * decoder,
|
||||||
opj_cio_t *io;
|
opj_cio_t *io;
|
||||||
opj_image_t *image;
|
opj_image_t *image;
|
||||||
GstVideoFrame vframe;
|
GstVideoFrame vframe;
|
||||||
|
opj_dparameters_t params;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (self, "Handling frame");
|
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_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))
|
if (!gst_buffer_map (frame->input_buffer, &map, GST_MAP_READ))
|
||||||
goto map_read_error;
|
goto map_read_error;
|
||||||
|
|
|
@ -54,6 +54,7 @@ struct _GstOpenJPEGDec
|
||||||
OPJ_CODEC_FORMAT codec_format;
|
OPJ_CODEC_FORMAT codec_format;
|
||||||
gboolean is_jp2c;
|
gboolean is_jp2c;
|
||||||
OPJ_COLOR_SPACE color_space;
|
OPJ_COLOR_SPACE color_space;
|
||||||
|
gint ncomps;
|
||||||
|
|
||||||
void (*fill_frame) (GstVideoFrame *frame, opj_image_t * image);
|
void (*fill_frame) (GstVideoFrame *frame, opj_image_t * image);
|
||||||
|
|
||||||
|
|
|
@ -355,6 +355,7 @@ gst_openjpeg_enc_set_format (GstVideoEncoder * encoder,
|
||||||
GstCaps *allowed_caps, *caps;
|
GstCaps *allowed_caps, *caps;
|
||||||
GstStructure *s;
|
GstStructure *s;
|
||||||
const gchar *colorspace;
|
const gchar *colorspace;
|
||||||
|
gint ncomps;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (self, "Setting format: %" GST_PTR_FORMAT, state->caps);
|
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) {
|
switch (state->info.finfo->format) {
|
||||||
case GST_VIDEO_FORMAT_ARGB64:
|
case GST_VIDEO_FORMAT_ARGB64:
|
||||||
self->fill_image = fill_image_packed16_4;
|
self->fill_image = fill_image_packed16_4;
|
||||||
|
ncomps = 4;
|
||||||
break;
|
break;
|
||||||
case GST_VIDEO_FORMAT_ARGB:
|
case GST_VIDEO_FORMAT_ARGB:
|
||||||
self->fill_image = fill_image_packed8_4;
|
self->fill_image = fill_image_packed8_4;
|
||||||
|
ncomps = 4;
|
||||||
break;
|
break;
|
||||||
case GST_VIDEO_FORMAT_xRGB:
|
case GST_VIDEO_FORMAT_xRGB:
|
||||||
self->fill_image = fill_image_packed8_3;
|
self->fill_image = fill_image_packed8_3;
|
||||||
|
ncomps = 3;
|
||||||
break;
|
break;
|
||||||
case GST_VIDEO_FORMAT_AYUV64:
|
case GST_VIDEO_FORMAT_AYUV64:
|
||||||
self->fill_image = fill_image_packed16_4;
|
self->fill_image = fill_image_packed16_4;
|
||||||
|
ncomps = 4;
|
||||||
break;
|
break;
|
||||||
case GST_VIDEO_FORMAT_Y444_10LE:
|
case GST_VIDEO_FORMAT_Y444_10LE:
|
||||||
case GST_VIDEO_FORMAT_Y444_10BE:
|
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_10LE:
|
||||||
case GST_VIDEO_FORMAT_I420_10BE:
|
case GST_VIDEO_FORMAT_I420_10BE:
|
||||||
self->fill_image = fill_image_planar16_3;
|
self->fill_image = fill_image_planar16_3;
|
||||||
|
ncomps = 3;
|
||||||
break;
|
break;
|
||||||
case GST_VIDEO_FORMAT_AYUV:
|
case GST_VIDEO_FORMAT_AYUV:
|
||||||
self->fill_image = fill_image_packed8_3;
|
self->fill_image = fill_image_packed8_3;
|
||||||
|
ncomps = 3;
|
||||||
break;
|
break;
|
||||||
case GST_VIDEO_FORMAT_Y444:
|
case GST_VIDEO_FORMAT_Y444:
|
||||||
case GST_VIDEO_FORMAT_Y42B:
|
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_Y41B:
|
||||||
case GST_VIDEO_FORMAT_YUV9:
|
case GST_VIDEO_FORMAT_YUV9:
|
||||||
self->fill_image = fill_image_planar8_3;
|
self->fill_image = fill_image_planar8_3;
|
||||||
|
ncomps = 3;
|
||||||
break;
|
break;
|
||||||
case GST_VIDEO_FORMAT_GRAY8:
|
case GST_VIDEO_FORMAT_GRAY8:
|
||||||
self->fill_image = fill_image_planar8_1;
|
self->fill_image = fill_image_planar8_1;
|
||||||
|
ncomps = 1;
|
||||||
break;
|
break;
|
||||||
case GST_VIDEO_FORMAT_GRAY16_LE:
|
case GST_VIDEO_FORMAT_GRAY16_LE:
|
||||||
case GST_VIDEO_FORMAT_GRAY16_BE:
|
case GST_VIDEO_FORMAT_GRAY16_BE:
|
||||||
self->fill_image = fill_image_planar16_1;
|
self->fill_image = fill_image_planar16_1;
|
||||||
|
ncomps = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
|
@ -430,7 +440,8 @@ gst_openjpeg_enc_set_format (GstVideoEncoder * encoder,
|
||||||
g_return_val_if_reached (FALSE);
|
g_return_val_if_reached (FALSE);
|
||||||
|
|
||||||
caps = gst_caps_new_simple (gst_structure_get_name (s),
|
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);
|
gst_caps_unref (allowed_caps);
|
||||||
|
|
||||||
if (self->output_state)
|
if (self->output_state)
|
||||||
|
|
Loading…
Reference in a new issue