mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 01:30:38 +00:00
jpeg2000parse: support frame and stripe alignment in caps
forward alignment and num-stripes caps properties Use caps height when setting caps for subframe We want downstream to use full frame height, not subframe height Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1653>
This commit is contained in:
parent
8a923af42f
commit
db13dc9d02
2 changed files with 55 additions and 2 deletions
|
@ -221756,7 +221756,7 @@
|
||||||
"long-name": "JPEG 2000 parser",
|
"long-name": "JPEG 2000 parser",
|
||||||
"pad-templates": {
|
"pad-templates": {
|
||||||
"sink": {
|
"sink": {
|
||||||
"caps": "image/jp2:\nimage/x-jpc:\nimage/x-j2c:\n",
|
"caps": "image/jp2:\nimage/x-jpc:\n alignment: { (string)frame, (string)stripe }\nimage/x-j2c:\n alignment: { (string)frame, (string)stripe }\n",
|
||||||
"direction": "sink",
|
"direction": "sink",
|
||||||
"presence": "always"
|
"presence": "always"
|
||||||
},
|
},
|
||||||
|
|
|
@ -109,7 +109,9 @@ static GstStaticPadTemplate srctemplate =
|
||||||
static GstStaticPadTemplate sinktemplate =
|
static GstStaticPadTemplate sinktemplate =
|
||||||
GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK,
|
GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("image/jp2;image/x-jpc;image/x-j2c"));
|
GST_STATIC_CAPS ("image/jp2;"
|
||||||
|
"image/x-jpc, alignment = (string){frame, stripe};"
|
||||||
|
"image/x-j2c, alignment = (string){frame, stripe}"));
|
||||||
|
|
||||||
#define parent_class gst_jpeg2000_parse_parent_class
|
#define parent_class gst_jpeg2000_parse_parent_class
|
||||||
G_DEFINE_TYPE (GstJPEG2000Parse, gst_jpeg2000_parse, GST_TYPE_BASE_PARSE);
|
G_DEFINE_TYPE (GstJPEG2000Parse, gst_jpeg2000_parse, GST_TYPE_BASE_PARSE);
|
||||||
|
@ -665,6 +667,20 @@ gst_jpeg2000_parse_handle_frame (GstBaseParse * parse,
|
||||||
colorspace = GST_JPEG2000_COLORSPACE_YUV;
|
colorspace = GST_JPEG2000_COLORSPACE_YUV;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 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;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* now we can set the source caps, if something has changed */
|
/* now we can set the source caps, if something has changed */
|
||||||
source_sampling =
|
source_sampling =
|
||||||
sink_sampling !=
|
sink_sampling !=
|
||||||
|
@ -695,6 +711,8 @@ gst_jpeg2000_parse_handle_frame (GstBaseParse * parse,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_caps_struct) {
|
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 = gst_structure_get_string
|
||||||
(current_caps_struct, "colorimetry");
|
(current_caps_struct, "colorimetry");
|
||||||
if (caps_string) {
|
if (caps_string) {
|
||||||
|
@ -725,6 +743,41 @@ gst_jpeg2000_parse_handle_frame (GstBaseParse * parse,
|
||||||
gst_caps_set_simple (src_caps, "chroma-site", G_TYPE_STRING,
|
gst_caps_set_simple (src_caps, "chroma-site", G_TYPE_STRING,
|
||||||
caps_string, NULL);
|
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);
|
||||||
|
/* 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,
|
if (gst_structure_get_fraction (current_caps_struct, "framerate", &fr_num,
|
||||||
&fr_denom)) {
|
&fr_denom)) {
|
||||||
gst_caps_set_simple (src_caps, "framerate", GST_TYPE_FRACTION, fr_num,
|
gst_caps_set_simple (src_caps, "framerate", GST_TYPE_FRACTION, fr_num,
|
||||||
|
|
Loading…
Reference in a new issue