static gboolean gst_h265_decoder_finish_current_picture (GstH265Decoder * self);
static void gst_h265_decoder_clear_ref_pic_sets (GstH265Decoder * self);
-static void gst_h265_decoder_clear_dpb (GstH265Decoder * self);
+static void gst_h265_decoder_clear_dpb (GstH265Decoder * self, gboolean flush);
static gboolean gst_h265_decoder_drain_internal (GstH265Decoder * self);
static gboolean gst_h265_decoder_start_current_picture (GstH265Decoder * self);
{
GstH265Decoder *self = GST_H265_DECODER (decoder);
- gst_h265_decoder_clear_dpb (self);
+ gst_h265_decoder_clear_dpb (self, TRUE);
return TRUE;
}
}
static void
-gst_h265_decoder_clear_dpb (GstH265Decoder * self)
+gst_h265_decoder_clear_dpb (GstH265Decoder * self, gboolean flush)
{
+ GstVideoDecoder *decoder = GST_VIDEO_DECODER (self);
GstH265DecoderPrivate *priv = self->priv;
+ GstH265Picture *picture;
+
+ /* If we are not flushing now, videodecoder baseclass will hold
+ * GstVideoCodecFrame. Release frames manually */
+ if (!flush) {
+ while ((picture = gst_h265_dpb_bump (priv->dpb)) != NULL) {
+ GstVideoCodecFrame *frame = gst_video_decoder_get_frame (decoder,
+ picture->system_frame_number);
+
+ if (frame)
+ gst_video_decoder_release_frame (decoder, frame);
+ gst_h265_picture_unref (picture);
+ }
+ }
gst_h265_dpb_clear (priv->dpb);
priv->last_output_poc = 0;
if (picture->NoOutputOfPriorPicsFlag) {
GST_DEBUG_OBJECT (self, "Clear dpb");
- gst_h265_decoder_clear_dpb (self);
+ gst_h265_decoder_clear_dpb (self, FALSE);
} else {
gst_h265_dpb_delete_unused (priv->dpb);
while ((to_output = gst_h265_dpb_bump (priv->dpb)) != NULL)