diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gsth264decoder.c b/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gsth264decoder.c index 4e815e0127..2c1c0f2344 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gsth264decoder.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gsth264decoder.c @@ -60,6 +60,7 @@ #include #include "gsth264decoder.h" +#include "gsth264picture-private.h" GST_DEBUG_CATEGORY (gst_h264_decoder_debug); #define GST_CAT_DEFAULT gst_h264_decoder_debug @@ -126,9 +127,6 @@ struct _GstH264DecoderPrivate GstH264PictureField prev_ref_field; - /* PicOrderCount of the previously outputted frame */ - gint last_output_poc; - gboolean process_ref_pic_lists; guint preferred_output_delay; @@ -344,8 +342,6 @@ gst_h264_decoder_init (GstH264Decoder * self) self->priv = priv = gst_h264_decoder_get_instance_private (self); - priv->last_output_poc = G_MININT32; - priv->ref_pic_list_p0 = g_array_sized_new (FALSE, TRUE, sizeof (GstH264Picture *), 32); g_array_set_clear_func (priv->ref_pic_list_p0, @@ -485,7 +481,6 @@ gst_h264_decoder_clear_dpb (GstH264Decoder * self, gboolean flush) gst_h264_decoder_clear_ref_pic_lists (self); gst_clear_h264_picture (&priv->last_field); gst_h264_dpb_clear (priv->dpb); - priv->last_output_poc = G_MININT32; } static gboolean @@ -1774,19 +1769,23 @@ gst_h264_decoder_do_output_picture (GstH264Decoder * self, GstVideoCodecFrame *frame = NULL; GstH264DecoderOutputFrame output_frame; GstFlowReturn flow_ret = GST_FLOW_OK; +#ifndef GST_DISABLE_GST_DEBUG + guint32 last_output_poc; +#endif g_assert (ret != NULL); GST_LOG_OBJECT (self, "Outputting picture %p (frame_num %d, poc %d)", picture, picture->frame_num, picture->pic_order_cnt); - if (picture->pic_order_cnt < priv->last_output_poc) { +#ifndef GST_DISABLE_GST_DEBUG + last_output_poc = gst_h264_dpb_get_last_output_poc (priv->dpb); + if (picture->pic_order_cnt < last_output_poc) { GST_WARNING_OBJECT (self, "Outputting out of order %d -> %d, likely a broken stream", - priv->last_output_poc, picture->pic_order_cnt); + last_output_poc, picture->pic_order_cnt); } - - priv->last_output_poc = picture->pic_order_cnt; +#endif frame = gst_video_decoder_get_frame (GST_VIDEO_DECODER (self), picture->system_frame_number); @@ -1878,7 +1877,6 @@ gst_h264_decoder_drain_internal (GstH264Decoder * self) gst_clear_h264_picture (&priv->last_field); gst_h264_dpb_clear (priv->dpb); - priv->last_output_poc = G_MININT32; return ret; } diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gsth264picture-private.h b/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gsth264picture-private.h new file mode 100644 index 0000000000..f71741d659 --- /dev/null +++ b/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gsth264picture-private.h @@ -0,0 +1,28 @@ +/* GStreamer + * Copyright (C) <2023> The GStreamer Contributors. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#pragma once + +#include "gsth264picture.h" + +G_BEGIN_DECLS + +gint32 gst_h264_dpb_get_last_output_poc (GstH264Dpb * dpb); + +G_END_DECLS diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gsth264picture.c b/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gsth264picture.c index 7b100a779c..0962d4cdf1 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gsth264picture.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gsth264picture.c @@ -21,7 +21,8 @@ #include #endif -#include "gsth264picture.h" +#include "gsth264picture-private.h" + #include GST_DEBUG_CATEGORY_EXTERN (gst_h264_decoder_debug); @@ -214,6 +215,22 @@ gst_h264_dpb_get_interlaced (GstH264Dpb * dpb) return dpb->interlaced; } +/** + * gst_h264_dpb_get_last_output_poc: + * @dpb: a #GstH264Dpb + * + * Returns: the last outputted picture order count + * + * Since: 1.24 + */ +gint32 +gst_h264_dpb_get_last_output_poc (GstH264Dpb * dpb) +{ + g_return_val_if_fail (dpb != NULL, G_MININT32); + + return dpb->last_output_poc; +} + /** * gst_h264_dpb_free: * @dpb: a #GstH264Dpb to free