summaryrefslogtreecommitdiff
path: root/gst/videoparsers/gstjpeg2000parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'gst/videoparsers/gstjpeg2000parse.c')
-rw-r--r--gst/videoparsers/gstjpeg2000parse.c96
1 files changed, 42 insertions, 54 deletions
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,