diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gsth265decoder.c b/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gsth265decoder.c
index d6034fbd7b..468eae0159 100644
--- a/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gsth265decoder.c
+++ b/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gsth265decoder.c
@@ -1842,14 +1842,6 @@ gst_h265_decoder_start_current_picture (GstH265Decoder * self)
     return GST_FLOW_OK;
   }
 
-  /* If subclass didn't update output state at this point,
-   * marking this picture as a discont and stores current input state */
-  if (priv->input_state_changed) {
-    gst_h265_picture_set_discont_state (priv->current_picture,
-        self->input_state);
-    priv->input_state_changed = FALSE;
-  }
-
   if (!gst_h265_decoder_prepare_rps (self, &priv->current_slice,
           priv->current_picture)) {
     GST_WARNING_OBJECT (self, "Failed to prepare ref pic set");
@@ -1887,6 +1879,14 @@ gst_h265_decoder_start_current_picture (GstH265Decoder * self)
     }
   }
 
+  /* If subclass didn't update output state at this point,
+   * marking this picture as a discont and stores current input state */
+  if (priv->input_state_changed) {
+    gst_h265_picture_set_discont_state (priv->current_picture,
+        self->input_state);
+    priv->input_state_changed = FALSE;
+  }
+
   return GST_FLOW_OK;
 }