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
This commit is contained in:
Jan Schmidt 2017-11-24 16:53:40 +11:00
parent c8ff205089
commit e82c24e893
2 changed files with 5 additions and 1 deletions

View File

@ -254,7 +254,7 @@ gst_jpegenc_term_destination (j_compress_ptr cinfo)
jpegenc->output_map.data = NULL; jpegenc->output_map.data = NULL;
jpegenc->output_map.size = 0; jpegenc->output_map.size = 0;
if (jpegenc->sof_marker != sof_marker) { if (jpegenc->sof_marker != sof_marker || jpegenc->input_caps_changed) {
GstVideoCodecState *output; GstVideoCodecState *output;
output = output =
gst_video_encoder_set_output_state (GST_VIDEO_ENCODER (jpegenc), 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); NULL), jpegenc->input_state);
gst_video_codec_state_unref (output); gst_video_codec_state_unref (output);
jpegenc->sof_marker = sof_marker; jpegenc->sof_marker = sof_marker;
jpegenc->input_caps_changed = FALSE;
} }
outbuf = gst_buffer_new (); 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->planar = (enc->inc[0] == 1 && enc->inc[1] == 1 && enc->inc[2] == 1);
enc->input_caps_changed = TRUE;
gst_jpegenc_resync (enc); gst_jpegenc_resync (enc);
return TRUE; return TRUE;

View File

@ -58,6 +58,8 @@ struct _GstJpegEnc
GstVideoCodecFrame *current_frame; GstVideoCodecFrame *current_frame;
GstFlowReturn res; GstFlowReturn res;
gboolean input_caps_changed;
guint channels; guint channels;
gint inc[GST_VIDEO_MAX_COMPONENTS]; gint inc[GST_VIDEO_MAX_COMPONENTS];