diff options
author | Aaron Boxer <aaron.boxer@collabora.com> | 2020-01-13 14:00:38 -0500 |
---|---|---|
committer | GStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2020-11-12 13:53:47 +0000 |
commit | 7463e1090c2d4feac5e852a631caf5a31de2d49f (patch) | |
tree | f3a32c3a79b692b4e01f67090da0642124448b18 /ext | |
parent | 977c3276d4a6cf80e79a1587466b38fb895eb587 (diff) | |
download | gstreamer-plugins-bad-7463e1090c2d4feac5e852a631caf5a31de2d49f.tar.gz |
openjpegenc: fail negotation in handle_frame if alignment mismatch
If encoder is in stripe mode, then downstream must also support stripe
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1800>
Diffstat (limited to 'ext')
-rw-r--r-- | ext/openjpeg/gstopenjpegenc.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/ext/openjpeg/gstopenjpegenc.c b/ext/openjpeg/gstopenjpegenc.c index 307d753d0..6186222a8 100644 --- a/ext/openjpeg/gstopenjpegenc.c +++ b/ext/openjpeg/gstopenjpegenc.c @@ -618,7 +618,6 @@ gst_openjpeg_enc_set_format (GstVideoEncoder * encoder, GstOpenJPEGEnc *self = GST_OPENJPEG_ENC (encoder); GstCaps *allowed_caps, *caps; GstStructure *s; - const gchar *str = NULL; const gchar *colorspace = NULL; GstJPEG2000Sampling sampling = GST_JPEG2000_SAMPLING_NONE; gint ncomps; @@ -747,16 +746,6 @@ gst_openjpeg_enc_set_format (GstVideoEncoder * encoder, } else g_return_val_if_reached (FALSE); - if (stripe_mode) { - str = gst_structure_get_string (s, "alignment"); - if (!str || strcmp (str, "stripe") != 0) { - GST_ERROR_OBJECT (self, - "Number of stripes set to %d, but alignment=stripe not supported downstream", - self->num_stripes); - return FALSE; - } - } - if (sampling != GST_JPEG2000_SAMPLING_NONE) { caps = gst_caps_new_simple (gst_structure_get_name (s), "colorspace", G_TYPE_STRING, colorspace, @@ -941,9 +930,29 @@ gst_openjpeg_enc_handle_frame (GstVideoEncoder * encoder, opj_image_t *image; GstVideoFrame vframe; guint i; + GstCaps *current_caps; + GstStructure *s; + gboolean stripe_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 (stripe_mode) { + const gchar *str = gst_structure_get_string (s, "alignment"); + 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; + } + } + + for (i = 0; i < self->num_stripes; ++i) { enc = opj_create_compress (self->codec_format); if (!enc) @@ -1029,6 +1038,9 @@ gst_openjpeg_enc_handle_frame (GstVideoEncoder * encoder, } +done: + if (current_caps) + gst_caps_unref (current_caps); return ret; initialization_error: |