From e82c24e893ccf3c2a30850eb777ca7d94baf392b Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Fri, 24 Nov 2017 16:53:40 +1100 Subject: [PATCH] jpegenc: Update output caps on input caps change If the input changes width/height that should be reflected in the output caps, so make sure they get updated --- ext/jpeg/gstjpegenc.c | 4 +++- ext/jpeg/gstjpegenc.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ext/jpeg/gstjpegenc.c b/ext/jpeg/gstjpegenc.c index 9d8a598120..7913a97647 100644 --- a/ext/jpeg/gstjpegenc.c +++ b/ext/jpeg/gstjpegenc.c @@ -254,7 +254,7 @@ gst_jpegenc_term_destination (j_compress_ptr cinfo) jpegenc->output_map.data = NULL; jpegenc->output_map.size = 0; - if (jpegenc->sof_marker != sof_marker) { + if (jpegenc->sof_marker != sof_marker || jpegenc->input_caps_changed) { GstVideoCodecState *output; output = gst_video_encoder_set_output_state (GST_VIDEO_ENCODER (jpegenc), @@ -262,6 +262,7 @@ gst_jpegenc_term_destination (j_compress_ptr cinfo) NULL), jpegenc->input_state); gst_video_codec_state_unref (output); jpegenc->sof_marker = sof_marker; + jpegenc->input_caps_changed = FALSE; } outbuf = gst_buffer_new (); @@ -361,6 +362,7 @@ gst_jpegenc_set_format (GstVideoEncoder * encoder, GstVideoCodecState * state) } enc->planar = (enc->inc[0] == 1 && enc->inc[1] == 1 && enc->inc[2] == 1); + enc->input_caps_changed = TRUE; gst_jpegenc_resync (enc); return TRUE; diff --git a/ext/jpeg/gstjpegenc.h b/ext/jpeg/gstjpegenc.h index 7c636d358d..82b6868109 100644 --- a/ext/jpeg/gstjpegenc.h +++ b/ext/jpeg/gstjpegenc.h @@ -58,6 +58,8 @@ struct _GstJpegEnc GstVideoCodecFrame *current_frame; GstFlowReturn res; + gboolean input_caps_changed; + guint channels; gint inc[GST_VIDEO_MAX_COMPONENTS];