summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStéphane Cerveau <scerveau@collabora.com>2021-01-22 10:39:56 +0100
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>2021-09-20 15:11:03 +0000
commit0d0e89108bf72800c22962a6e996b3c1a9cd20bb (patch)
tree8b2652429715bbe8bbc59023e2b1d4d57f1a0bfd
parent619cbca642f8bd4e3a1d6a5267f6afd6d8a28707 (diff)
downloadgstreamer-plugins-bad-0d0e89108bf72800c22962a6e996b3c1a9cd20bb.tar.gz
jpeg2000parse + openjpeg: Switch striped mode to its own caps
It's not compatible with any other element that use the non-striped mode. In addition, in this mode, we require that every frame have the same number of stripes or that the MARKER bit be present, which is different from the other formats too. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/979>
-rw-r--r--docs/plugins/gst_plugins_cache.json28
-rw-r--r--ext/openjpeg/gstopenjpegdec.c25
-rw-r--r--ext/openjpeg/gstopenjpegenc.c100
-rw-r--r--gst/videoparsers/gstjpeg2000parse.c96
4 files changed, 131 insertions, 118 deletions
diff --git a/docs/plugins/gst_plugins_cache.json b/docs/plugins/gst_plugins_cache.json
index 37925b325..c7776a2d9 100644
--- a/docs/plugins/gst_plugins_cache.json
+++ b/docs/plugins/gst_plugins_cache.json
@@ -1,4 +1,4 @@
- {
+{
"accurip": {
"description": "Computes an AccurateRip CRC",
"elements": {
@@ -217932,7 +217932,7 @@
"long-name": "OpenJPEG JPEG2000 decoder",
"pad-templates": {
"sink": {
- "caps": "image/x-j2c:\n sampling: { (string)RGB, (string)BGR, (string)RGBA, (string)BGRA, (string)YCbCr-4:4:4, (string)YCbCr-4:2:2, (string)YCbCr-4:2:0, (string)YCbCr-4:1:1, (string)GRAYSCALE, (string)YCbCrA-4:4:4:4 }\nimage/x-jpc:\n alignment: frame\n sampling: { (string)RGB, (string)BGR, (string)RGBA, (string)BGRA, (string)YCbCr-4:4:4, (string)YCbCr-4:2:2, (string)YCbCr-4:2:0, (string)YCbCr-4:1:1, (string)YCbCr-4:1:0, (string)GRAYSCALE, (string)YCbCrA-4:4:4:4 }\nimage/jp2:\n",
+ "caps": "image/x-j2c:\n sampling: { (string)RGB, (string)BGR, (string)RGBA, (string)BGRA, (string)YCbCr-4:4:4, (string)YCbCr-4:2:2, (string)YCbCr-4:2:0, (string)YCbCr-4:1:1, (string)YCbCr-4:1:0, (string)GRAYSCALE, (string)YCbCrA-4:4:4:4 }\nimage/x-jpc:\n sampling: { (string)RGB, (string)BGR, (string)RGBA, (string)BGRA, (string)YCbCr-4:4:4, (string)YCbCr-4:2:2, (string)YCbCr-4:2:0, (string)YCbCr-4:1:1, (string)YCbCr-4:1:0, (string)GRAYSCALE, (string)YCbCrA-4:4:4:4 }\nimage/jp2:\nimage/x-jpc-striped:\n num-stripes: [ 2, 2147483647 ]\n sampling: { (string)RGB, (string)BGR, (string)RGBA, (string)BGRA, (string)YCbCr-4:4:4, (string)YCbCr-4:2:2, (string)YCbCr-4:2:0, (string)YCbCr-4:1:1, (string)YCbCr-4:1:0, (string)GRAYSCALE, (string)YCbCrA-4:4:4:4 }\n",
"direction": "sink",
"presence": "always"
},
@@ -217943,8 +217943,22 @@
}
},
"properties": {
+ "max-slice-threads": {
+ "blurb": "Maximum number of worker threads to spawn according to the frame boundary. (0 = no thread)",
+ "conditionally-available": false,
+ "construct": false,
+ "construct-only": false,
+ "controllable": false,
+ "default": "0",
+ "max": "2147483647",
+ "min": "0",
+ "mutable": "null",
+ "readable": true,
+ "type": "gint",
+ "writable": true
+ },
"max-threads": {
- "blurb": "Maximum number of worker threads to spawn. (0 = auto)",
+ "blurb": "Maximum number of worker threads to spawn used by openjpeg internally. (0 = no thread)",
"conditionally-available": false,
"construct": false,
"construct-only": false,
@@ -217983,7 +217997,7 @@
"presence": "always"
},
"src": {
- "caps": "image/x-j2c:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\n num-components: [ 1, 4 ]\n sampling: { (string)RGB, (string)BGR, (string)RGBA, (string)BGRA, (string)YCbCr-4:4:4, (string)YCbCr-4:2:2, (string)YCbCr-4:2:0, (string)YCbCr-4:1:1, (string)YCbCr-4:1:0, (string)GRAYSCALE, (string)YCbCrA-4:4:4:4 }\n colorspace: { (string)sRGB, (string)sYUV, (string)GRAY }\nimage/x-jpc:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\n num-components: [ 1, 4 ]\n num-stripes: [ 1, 2147483647 ]\n alignment: { (string)frame, (string)stripe }\n sampling: { (string)RGB, (string)BGR, (string)RGBA, (string)BGRA, (string)YCbCr-4:4:4, (string)YCbCr-4:2:2, (string)YCbCr-4:2:0, (string)YCbCr-4:1:1, (string)GRAYSCALE, (string)YCbCrA-4:4:4:4 }\n colorspace: { (string)sRGB, (string)sYUV, (string)GRAY }\nimage/jp2:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\n",
+ "caps": "image/x-j2c:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\n num-components: [ 1, 4 ]\n sampling: { (string)RGB, (string)BGR, (string)RGBA, (string)BGRA, (string)YCbCr-4:4:4, (string)YCbCr-4:2:2, (string)YCbCr-4:2:0, (string)YCbCr-4:1:1, (string)YCbCr-4:1:0, (string)GRAYSCALE, (string)YCbCrA-4:4:4:4 }\n colorspace: { (string)sRGB, (string)sYUV, (string)GRAY }\nimage/x-jpc:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\n num-components: [ 1, 4 ]\n num-stripes: [ 1, 2147483647 ]\n alignment: { (string)frame, (string)stripe }\n sampling: { (string)RGB, (string)BGR, (string)RGBA, (string)BGRA, (string)YCbCr-4:4:4, (string)YCbCr-4:2:2, (string)YCbCr-4:2:0, (string)YCbCr-4:1:1, (string)YCbCr-4:1:0, (string)GRAYSCALE, (string)YCbCrA-4:4:4:4 }\n colorspace: { (string)sRGB, (string)sYUV, (string)GRAY }\nimage/jp2:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nimage/x-jpc-striped:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\n num-components: [ 1, 4 ]\n sampling: { (string)RGB, (string)BGR, (string)RGBA, (string)BGRA, (string)YCbCr-4:4:4, (string)YCbCr-4:2:2, (string)YCbCr-4:2:0, (string)YCbCr-4:1:1, (string)YCbCr-4:1:0, (string)GRAYSCALE, (string)YCbCrA-4:4:4:4 }\n colorspace: { (string)sRGB, (string)sYUV, (string)GRAY }\n num-stripes: [ 2, 2147483647 ]\n stripe-height: [ 1, 2147483647 ]\n",
"direction": "src",
"presence": "always"
}
@@ -226301,12 +226315,12 @@
"long-name": "JPEG 2000 parser",
"pad-templates": {
"sink": {
- "caps": "image/jp2:\nimage/x-jpc:\n alignment: { (string)frame, (string)stripe }\nimage/x-j2c:\n alignment: { (string)frame, (string)stripe }\n",
+ "caps": "image/jp2:\nimage/x-jpc:\nimage/x-j2c:\nimage/x-jpc-striped:\n",
"direction": "sink",
"presence": "always"
},
"src": {
- "caps": "image/x-jpc:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\n sampling: { (string)RGB, (string)BGR, (string)RGBA, (string)BGRA, (string)YCbCr-4:4:4, (string)YCbCr-4:2:2, (string)YCbCr-4:2:0, (string)YCbCr-4:1:1, (string)YCbCr-4:1:0, (string)GRAYSCALE, (string)YCbCrA-4:4:4:4 }\n colorspace: { (string)sRGB, (string)sYUV, (string)GRAY }\n profile: [ 0, 49151 ]\n parsed: true\nimage/x-j2c:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\n sampling: { (string)RGB, (string)BGR, (string)RGBA, (string)BGRA, (string)YCbCr-4:4:4, (string)YCbCr-4:2:2, (string)YCbCr-4:2:0, (string)YCbCr-4:1:1, (string)YCbCr-4:1:0, (string)GRAYSCALE, (string)YCbCrA-4:4:4:4 }\n colorspace: { (string)sRGB, (string)sYUV, (string)GRAY }\n profile: [ 0, 49151 ]\n parsed: true\n",
+ "caps": "image/x-jpc:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\n sampling: { (string)RGB, (string)BGR, (string)RGBA, (string)BGRA, (string)YCbCr-4:4:4, (string)YCbCr-4:2:2, (string)YCbCr-4:2:0, (string)YCbCr-4:1:1, (string)YCbCr-4:1:0, (string)GRAYSCALE, (string)YCbCrA-4:4:4:4 }\n colorspace: { (string)sRGB, (string)sYUV, (string)GRAY }\n profile: [ 0, 49151 ]\n parsed: true\nimage/x-j2c:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\n sampling: { (string)RGB, (string)BGR, (string)RGBA, (string)BGRA, (string)YCbCr-4:4:4, (string)YCbCr-4:2:2, (string)YCbCr-4:2:0, (string)YCbCr-4:1:1, (string)YCbCr-4:1:0, (string)GRAYSCALE, (string)YCbCrA-4:4:4:4 }\n colorspace: { (string)sRGB, (string)sYUV, (string)GRAY }\n profile: [ 0, 49151 ]\n parsed: true\nimage/x-jpc-striped:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\n sampling: { (string)RGB, (string)BGR, (string)RGBA, (string)BGRA, (string)YCbCr-4:4:4, (string)YCbCr-4:2:2, (string)YCbCr-4:2:0, (string)YCbCr-4:1:1, (string)YCbCr-4:1:0, (string)GRAYSCALE, (string)YCbCrA-4:4:4:4 }\n colorspace: { (string)sRGB, (string)sYUV, (string)GRAY }\n profile: [ 0, 49151 ]\n num-stripes: [ 2, 2147483647 ]\n parsed: true\n",
"direction": "src",
"presence": "always"
}
@@ -230150,4 +230164,4 @@
"tracers": {},
"url": "Unknown package origin"
}
-}
+} \ No newline at end of file
diff --git a/ext/openjpeg/gstopenjpegdec.c b/ext/openjpeg/gstopenjpegdec.c
index ef67b21e6..4909d9a34 100644
--- a/ext/openjpeg/gstopenjpegdec.c
+++ b/ext/openjpeg/gstopenjpegdec.c
@@ -101,11 +101,11 @@ static GstStaticPadTemplate gst_openjpeg_dec_sink_template =
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("image/x-j2c, "
- "alignment= (string){frame,stripe}, "
GST_JPEG2000_SAMPLING_LIST "; "
"image/x-jpc,"
- "alignment= (string){frame,stripe}, "
- GST_JPEG2000_SAMPLING_LIST "; " "image/jp2")
+ GST_JPEG2000_SAMPLING_LIST "; image/jp2 ; "
+ "image/x-jpc-striped, "
+ "num-stripes = (int) [2, MAX], " GST_JPEG2000_SAMPLING_LIST)
);
static GstStaticPadTemplate gst_openjpeg_dec_src_template =
@@ -359,8 +359,6 @@ gst_openjpeg_dec_set_format (GstVideoDecoder * decoder,
{
GstOpenJPEGDec *self = GST_OPENJPEG_DEC (decoder);
GstStructure *s;
- gint caps_int = 0;
- const gchar *caps_string = NULL;
GST_DEBUG_OBJECT (self, "Setting format: %" GST_PTR_FORMAT, state->caps);
@@ -374,27 +372,22 @@ gst_openjpeg_dec_set_format (GstVideoDecoder * decoder,
} else if (gst_structure_has_name (s, "image/x-j2c")) {
self->codec_format = OPJ_CODEC_J2K;
self->is_jp2c = TRUE;
- } else if (gst_structure_has_name (s, "image/x-jpc")) {
+ } else if (gst_structure_has_name (s, "image/x-jpc") ||
+ gst_structure_has_name (s, "image/x-jpc-striped")) {
self->codec_format = OPJ_CODEC_J2K;
self->is_jp2c = FALSE;
} else {
g_return_val_if_reached (FALSE);
}
- self->num_stripes = 1;
- caps_string = gst_structure_get_string (s, "alignment");
- gst_structure_get_int (s, "num-stripes", &caps_int);
- if (caps_int > 1) {
- self->num_stripes = caps_int;
+ if (gst_structure_has_name (s, "image/x-jpc-striped")) {
+ gst_structure_get_int (s, "num-stripes", &self->num_stripes);
gst_video_decoder_set_subframe_mode (decoder, TRUE);
} else {
+ self->num_stripes = 1;
gst_video_decoder_set_subframe_mode (decoder, FALSE);
- if (g_strcmp0 (caps_string, "stripe") == 0) {
- GST_ERROR_OBJECT (self,
- "Alignment is set to stripe but num-stripes is missing");
- return FALSE;
- }
}
+
self->sampling =
gst_jpeg2000_sampling_from_string (gst_structure_get_string (s,
"sampling"));
diff --git a/ext/openjpeg/gstopenjpegenc.c b/ext/openjpeg/gstopenjpegenc.c
index 4d70e3089..f6d8e203b 100644
--- a/ext/openjpeg/gstopenjpegenc.c
+++ b/ext/openjpeg/gstopenjpegenc.c
@@ -162,7 +162,15 @@ static GstStaticPadTemplate gst_openjpeg_enc_src_template =
"alignment = (string) { frame, stripe }, "
GST_JPEG2000_SAMPLING_LIST ","
GST_JPEG2000_COLORSPACE_LIST "; "
- "image/jp2, " "width = (int) [1, MAX], " "height = (int) [1, MAX]")
+ "image/jp2, " "width = (int) [1, MAX], "
+ "height = (int) [1, MAX] ;"
+ "image/x-jpc-striped, "
+ "width = (int) [1, MAX], "
+ "height = (int) [1, MAX], "
+ "num-components = (int) [1, 4], "
+ GST_JPEG2000_SAMPLING_LIST ", "
+ GST_JPEG2000_COLORSPACE_LIST ", "
+ "num-stripes = (int) [2, MAX], stripe-height = (int) [1 , MAX]")
);
#define parent_class gst_openjpeg_enc_parent_class
@@ -742,20 +750,46 @@ gst_openjpeg_enc_set_format (GstVideoEncoder * encoder,
gst_video_codec_state_unref (self->input_state);
self->input_state = gst_video_codec_state_ref (state);
- allowed_caps = gst_pad_get_allowed_caps (GST_VIDEO_ENCODER_SRC_PAD (encoder));
- allowed_caps = gst_caps_truncate (allowed_caps);
- s = gst_caps_get_structure (allowed_caps, 0);
- if (gst_structure_has_name (s, "image/jp2")) {
- self->codec_format = OPJ_CODEC_JP2;
- self->is_jp2c = FALSE;
- } else if (gst_structure_has_name (s, "image/x-j2c")) {
- self->codec_format = OPJ_CODEC_J2K;
- self->is_jp2c = TRUE;
- } else if (gst_structure_has_name (s, "image/x-jpc")) {
+ if (stripe_mode) {
+ GstCaps *template_caps = gst_caps_new_empty_simple ("image/x-jpc-striped");
+ GstCaps *my_caps;
+
+ my_caps = gst_pad_query_caps (GST_VIDEO_ENCODER_SRC_PAD (encoder),
+ template_caps);
+ gst_caps_unref (template_caps);
+
+ allowed_caps = gst_pad_peer_query_caps (GST_VIDEO_ENCODER_SRC_PAD (encoder),
+ my_caps);
+ gst_caps_unref (my_caps);
+
+ if (gst_caps_is_empty (allowed_caps)) {
+ gst_caps_unref (allowed_caps);
+ GST_WARNING_OBJECT (self, "Striped JPEG 2000 not accepted downstream");
+ return FALSE;
+ }
+
self->codec_format = OPJ_CODEC_J2K;
self->is_jp2c = FALSE;
+ allowed_caps = gst_caps_truncate (allowed_caps);
+ s = gst_caps_get_structure (allowed_caps, 0);
} else {
- g_return_val_if_reached (FALSE);
+ allowed_caps =
+ gst_pad_get_allowed_caps (GST_VIDEO_ENCODER_SRC_PAD (encoder));
+ allowed_caps = gst_caps_truncate (allowed_caps);
+
+ s = gst_caps_get_structure (allowed_caps, 0);
+ if (gst_structure_has_name (s, "image/jp2")) {
+ self->codec_format = OPJ_CODEC_JP2;
+ self->is_jp2c = FALSE;
+ } else if (gst_structure_has_name (s, "image/x-j2c")) {
+ self->codec_format = OPJ_CODEC_J2K;
+ self->is_jp2c = TRUE;
+ } else if (gst_structure_has_name (s, "image/x-jpc")) {
+ self->codec_format = OPJ_CODEC_J2K;
+ self->is_jp2c = FALSE;
+ } else {
+ g_return_val_if_reached (FALSE);
+ }
}
switch (state->info.finfo->format) {
@@ -806,7 +840,6 @@ gst_openjpeg_enc_set_format (GstVideoEncoder * encoder,
g_assert_not_reached ();
}
-
/* sampling */
/* note: encoder re-orders channels so that alpha channel is encoded as the last channel */
switch (state->info.finfo->format) {
@@ -861,21 +894,24 @@ gst_openjpeg_enc_set_format (GstVideoEncoder * encoder,
} else
g_return_val_if_reached (FALSE);
- if (sampling != GST_JPEG2000_SAMPLING_NONE) {
- caps = gst_caps_new_simple (gst_structure_get_name (s),
+ if (stripe_mode) {
+ caps = gst_caps_new_simple ("image/x-jpc-striped",
"colorspace", G_TYPE_STRING, colorspace,
"sampling", G_TYPE_STRING, gst_jpeg2000_sampling_to_string (sampling),
"num-components", G_TYPE_INT, ncomps,
- "alignment", G_TYPE_STRING,
- stripe_mode ? "stripe" : "frame",
- "num-stripes", G_TYPE_INT, self->num_stripes, NULL);
+ "num-stripes", G_TYPE_INT, self->num_stripes,
+ "stripe-height", G_TYPE_INT,
+ get_stripe_height (self, 0,
+ GST_VIDEO_INFO_COMP_HEIGHT (&state->info, 0)), NULL);
+ } else if (sampling != GST_JPEG2000_SAMPLING_NONE) {
+ caps = gst_caps_new_simple (gst_structure_get_name (s),
+ "colorspace", G_TYPE_STRING, colorspace,
+ "sampling", G_TYPE_STRING, gst_jpeg2000_sampling_to_string (sampling),
+ "num-components", G_TYPE_INT, ncomps, NULL);
} else {
caps = gst_caps_new_simple (gst_structure_get_name (s),
"colorspace", G_TYPE_STRING, colorspace,
- "num-components", G_TYPE_INT, ncomps,
- "alignment", G_TYPE_STRING,
- stripe_mode ? "stripe" : "frame",
- "num-stripes", G_TYPE_INT, self->num_stripes, NULL);
+ "num-components", G_TYPE_INT, ncomps, NULL);
}
gst_caps_unref (allowed_caps);
@@ -1342,30 +1378,14 @@ gst_openjpeg_enc_handle_frame (GstVideoEncoder * encoder,
GstOpenJPEGEnc *self = GST_OPENJPEG_ENC (encoder);
GstFlowReturn ret = GST_FLOW_OK;
GstVideoFrame vframe;
-
- GstCaps *current_caps;
- GstStructure *s;
gboolean subframe_mode =
self->num_stripes != GST_OPENJPEG_ENC_DEFAULT_NUM_STRIPES;
GST_DEBUG_OBJECT (self, "Handling frame");
- current_caps = gst_pad_get_current_caps (GST_VIDEO_ENCODER_SRC_PAD (encoder));
- s = gst_caps_get_structure (current_caps, 0);
-
if (subframe_mode) {
- const gchar *str = gst_structure_get_string (s, "alignment");
gint min_res;
- if (g_strcmp0 (str, "stripe") != 0) {
- GST_ERROR_OBJECT (self,
- "Number of stripes set to %d, but alignment=stripe not supported downstream",
- self->num_stripes);
- gst_video_codec_frame_unref (frame);
- ret = GST_FLOW_NOT_NEGOTIATED;
- goto done;
- }
-
/* due to limitations in openjpeg library,
* number of wavelet resolutions must not exceed floor(log(stripe height)) + 1 */
if (!gst_video_frame_map (&vframe, &self->input_state->info,
@@ -1387,9 +1407,7 @@ gst_openjpeg_enc_handle_frame (GstVideoEncoder * encoder,
}
if (self->encode_frame (encoder, frame) != GST_FLOW_OK)
goto error;
-done:
- if (current_caps)
- gst_caps_unref (current_caps);
+
return ret;
error:
diff --git a/gst/videoparsers/gstjpeg2000parse.c b/gst/videoparsers/gstjpeg2000parse.c
index bf3f3810a..4ac5ccfe8 100644
--- a/gst/videoparsers/gstjpeg2000parse.c
+++ b/gst/videoparsers/gstjpeg2000parse.c
@@ -109,15 +109,21 @@ static GstStaticPadTemplate srctemplate =
" width = (int)[1, MAX], height = (int)[1, MAX],"
GST_JPEG2000_SAMPLING_LIST ","
GST_JPEG2000_COLORSPACE_LIST ","
- " profile = (int)[0, 49151]," " parsed = (boolean) true")
+ " profile = (int)[0, 49151],"
+ " parsed = (boolean) true ; "
+ "image/x-jpc-striped,"
+ " width = (int)[1, MAX], height = (int)[1, MAX],"
+ GST_JPEG2000_SAMPLING_LIST ","
+ GST_JPEG2000_COLORSPACE_LIST ","
+ " profile = (int)[0, 49151],"
+ " num-stripes = [ 2, MAX ], parsed = (boolean) true;")
);
static GstStaticPadTemplate sinktemplate =
GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("image/jp2;"
- "image/x-jpc, alignment = (string){frame, stripe};"
- "image/x-j2c, alignment = (string){frame, stripe}"));
+ GST_STATIC_CAPS ("image/jp2; image/x-jpc; image/x-j2c; "
+ "image/x-jpc-striped"));
#define parent_class gst_jpeg2000_parse_parent_class
G_DEFINE_TYPE (GstJPEG2000Parse, gst_jpeg2000_parse, GST_TYPE_BASE_PARSE);
@@ -334,6 +340,8 @@ gst_jpeg2000_parse_handle_frame (GstBaseParse * parse,
guint num_prefix_bytes = 0; /* number of bytes to skip before actual code stream */
GstCaps *src_caps = NULL;
guint eoc_frame_size = 0;
+ gint num_stripes = 1;
+ gint stripe_height = 0;
for (i = 0; i < GST_JPEG2000_PARSE_MAX_SUPPORTED_COMPONENTS; ++i) {
dx[i] = 1;
@@ -684,15 +692,30 @@ gst_jpeg2000_parse_handle_frame (GstBaseParse * parse,
/* use caps height if in sub-frame mode, as encoded frame height will be
* strictly less than full frame height */
- if (current_caps_struct) {
- gint num_stripes = 1;
+ if (current_caps_struct &&
+ gst_structure_has_name (current_caps_struct, "image/x-jpc-striped")) {
gint h;
- if (gst_structure_get_int (current_caps_struct, "num-stripes", &num_stripes)
- && num_stripes > 1) {
- gst_structure_get_int (current_caps_struct, "height", &h);
- height = h;
+ if (!gst_structure_get_int (current_caps_struct, "num-stripes",
+ &num_stripes) || num_stripes < 2) {
+ GST_ELEMENT_ERROR (parse, STREAM, FORMAT, (NULL),
+ ("Striped JPEG 2000 is missing the stripe count"));
+ ret = GST_FLOW_ERROR;
+ goto beach;
+ }
+
+ if (!gst_structure_get_int (current_caps_struct, "stripe-height",
+ &stripe_height)) {
+ stripe_height = height;
+ } else if (stripe_height != height &&
+ !GST_BUFFER_FLAG_IS_SET (frame->buffer, GST_BUFFER_FLAG_MARKER)) {
+ GST_WARNING_OBJECT (parse,
+ "Only the last stripe is expected to be different"
+ " from the stripe height (%d != %u)", height, stripe_height);
}
+
+ gst_structure_get_int (current_caps_struct, "height", &h);
+ height = h;
}
/* now we can set the source caps, if something has changed */
@@ -705,8 +728,8 @@ gst_jpeg2000_parse_handle_frame (GstBaseParse * parse,
gint fr_num = 0, fr_denom = 0;
src_caps =
- gst_caps_new_simple (media_type_from_codec_format
- (jpeg2000parse->src_codec_format),
+ gst_caps_new_simple (num_stripes > 1 ? "image/x-jpc-striped" :
+ media_type_from_codec_format (jpeg2000parse->src_codec_format),
"width", G_TYPE_INT, width,
"height", G_TYPE_INT, height,
"colorspace", G_TYPE_STRING,
@@ -714,6 +737,10 @@ gst_jpeg2000_parse_handle_frame (GstBaseParse * parse,
G_TYPE_STRING, gst_jpeg2000_sampling_to_string (source_sampling),
"profile", G_TYPE_INT, profile, "parsed", G_TYPE_BOOLEAN, TRUE, NULL);
+ if (num_stripes > 1)
+ gst_caps_set_simple (src_caps, "num-stripes", G_TYPE_INT, num_stripes,
+ "stripe_height", G_TYPE_INT, stripe_height, NULL);
+
if (gst_jpeg2000_parse_is_broadcast (capabilities)
|| gst_jpeg2000_parse_is_imf (capabilities)) {
gst_caps_set_simple (src_caps, "main-level", G_TYPE_INT, main_level,
@@ -725,9 +752,9 @@ gst_jpeg2000_parse_handle_frame (GstBaseParse * parse,
}
if (current_caps_struct) {
- gint caps_int = 0;
- gboolean has_num_stripes = FALSE;
- const gchar *caps_string = gst_structure_get_string
+ const gchar *caps_string;
+
+ caps_string = gst_structure_get_string
(current_caps_struct, "colorimetry");
if (caps_string) {
gst_caps_set_simple (src_caps, "colorimetry", G_TYPE_STRING,
@@ -757,45 +784,6 @@ gst_jpeg2000_parse_handle_frame (GstBaseParse * parse,
gst_caps_set_simple (src_caps, "chroma-site", G_TYPE_STRING,
caps_string, NULL);
}
- caps_string = gst_structure_get_string (current_caps_struct, "alignment");
- has_num_stripes =
- gst_structure_get_int (current_caps_struct, "num-stripes", &caps_int);
- if ((g_strcmp0 (caps_string, "stripe") == 0)
- && !has_num_stripes) {
- GST_ERROR_OBJECT (jpeg2000parse,
- "Alignment is set to stripe but num-stripes is missing");
- ret = GST_FLOW_NOT_NEGOTIATED;
- gst_caps_unref (src_caps);
- goto beach;
- }
-
- /* if there is no alignment or number of strips in caps,
- * we set alignment to default value : "frame"
- */
- if (!caps_string && !has_num_stripes) {
- gst_caps_set_simple (src_caps, "alignment", G_TYPE_STRING,
- "frame", NULL);
- } else {
- if (caps_string) {
- gst_caps_set_simple (src_caps, "alignment", G_TYPE_STRING,
- caps_string, NULL);
- }
- if (has_num_stripes) {
- gst_caps_set_simple (src_caps, "num-stripes", G_TYPE_INT,
- caps_int, NULL);
- /* remove PTS interpolation in the case of stripes having same PTS */
- if (caps_int > 1)
- gst_base_parse_set_pts_interpolation (GST_BASE_PARSE
- (jpeg2000parse), FALSE);
- /* lets deduce the alignment property */
- if (!caps_string) {
- GST_WARNING_OBJECT (jpeg2000parse,
- "num-stripes is set but alignment is missing. We will deduce the correct value for \"alignment\"");
- gst_caps_set_simple (src_caps, "alignment", G_TYPE_STRING,
- caps_int > 1 ? "stripe" : "frame", NULL);
- }
- }
- }
if (gst_structure_get_fraction (current_caps_struct, "framerate", &fr_num,
&fr_denom)) {
gst_caps_set_simple (src_caps, "framerate", GST_TYPE_FRACTION, fr_num,