h264parse: correct NAL mode backlog processing

- Only process what is left in backlog when AU was completed, draining or next
  nal is AUD.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6093>
This commit is contained in:
Daniel Morin 2024-02-11 22:08:12 -05:00 committed by GStreamer Marge Bot
parent cfa8386dd0
commit b2098849dc

View file

@ -1699,11 +1699,11 @@ gst_h264_parse_process_backlog_loop (GstH264Parse * h264parse,
static gboolean
gst_h264_parse_process_backlog_nal (GstH264Parse * h264parse, gint * proc_size,
gboolean * aud_insert, guint8 * data, gboolean clear_bl,
gboolean au_completed)
gboolean * aud_insert, guint8 * data, gboolean drain, gboolean au_completed)
{
GstH264NalUnit *bnalu;
gint framesize = 0;
gboolean next_is_aud = FALSE;
g_assert (h264parse->nal_backlog != NULL);
g_assert (h264parse->nal_backlog->len > 0);
@ -1733,14 +1733,19 @@ gst_h264_parse_process_backlog_nal (GstH264Parse * h264parse, gint * proc_size,
gst_h264_parse_trim_backlog (h264parse);
}
/* Process all backlog. Used when draining or output in NAL mode. */
if (!gst_h264_parse_process_backlog_loop (h264parse,
h264parse->nal_backlog->len, TRUE, aud_insert, data, &framesize)) {
goto fail;
if (h264parse->bl_next_nal < h264parse->nal_backlog->len) {
bnalu = &g_array_index (h264parse->nal_backlog, GstH264NalUnit,
h264parse->bl_next_nal);
next_is_aud = bnalu->type == GST_H264_NAL_AU_DELIMITER;
}
if (clear_bl) {
gst_h264_parse_clear_backlog (h264parse);
/* Process all backlog. Used when draining or in NAL mode and nals still
* in backlog after completing or next is AUD. */
if ((au_completed || drain || next_is_aud)) {
if (!gst_h264_parse_process_backlog_loop (h264parse,
h264parse->nal_backlog->len, TRUE, aud_insert, data, &framesize)) {
goto fail;
}
}
/* Backlog content doesn't need to parsed again, adjust offset accordingly. */
@ -2027,7 +2032,7 @@ gst_h264_parse_handle_frame (GstBaseParse * parse,
if (h264parse->align == GST_H264_PARSE_ALIGN_NAL) {
if (!gst_h264_parse_process_backlog_nal (h264parse, &framesize,
&h264parse->aud_insert, data, FALSE,
&h264parse->aud_insert, data, drain,
blstatus == GST_H264_PARSE_BACKLOG_STATUS_AU_COMPLETE)) {
*skipsize = current_off;
}