h264decoder: use last_output_poc from DPB

It seems that `last_output_poc` in `h264decoder` class is a left over of commit
5527cc4a2e.

This patch removes it but keeps the log message by fetching the `h264picture`'s
`last_output_pic`.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4288>
This commit is contained in:
Víctor Manuel Jáquez Leal 2023-03-27 13:53:34 +02:00
parent a31cd75c73
commit 57e0bdb356
3 changed files with 55 additions and 12 deletions

View file

@ -60,6 +60,7 @@
#include <gst/base/base.h>
#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;
}

View file

@ -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

View file

@ -21,7 +21,8 @@
#include <config.h>
#endif
#include "gsth264picture.h"
#include "gsth264picture-private.h"
#include <stdlib.h>
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