From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 080E5434C0 for ; Tue, 14 Jun 2022 01:30:15 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0FADE68B634; Tue, 14 Jun 2022 04:30:09 +0300 (EEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A08CB68B333 for ; Tue, 14 Jun 2022 04:30:02 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655170207; x=1686706207; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kp0kfqAH36tcbraDoEOtpSPO3NAypSToQVgeQc0VzjY=; b=DPAMexyF2qxeNAg5IpI9oW1ERdBPciAmQDSThGW/lexkvwuqeaaRX6eS tRmSJjPVpdhd51/zr9ayCb5tWAhAbaRdjQ55qE7c+6/lHCgD/yr9HH640 mqOBENPivTvqMreKxW8L+YH1AiG1BYRmli3OpgsfCcP6oRqjrGlNh6uyo prd4j4sRGCOjfTQQOP5QJrGlIoatq/p97Hlmov3mnXAY1ZVckrOd+S+ko sVvWa5nwBjpRJ/+lHivJa9j5yixkuGU42LOKEBceKZwbFz8UBmRGzOcVC ClbYUR7nXWNG0C5VzCQKOdXWNJSqgML0VXtyqJSEge6SThTFBbt+EoWWt g==; X-IronPort-AV: E=McAfee;i="6400,9594,10377"; a="342432964" X-IronPort-AV: E=Sophos;i="5.91,298,1647327600"; d="scan'208";a="342432964" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2022 18:29:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,298,1647327600"; d="scan'208";a="686378070" Received: from t.sh.intel.com ([10.239.159.147]) by fmsmga002.fm.intel.com with ESMTP; 13 Jun 2022 18:29:51 -0700 From: Fei Wang To: ffmpeg-devel@ffmpeg.org Date: Tue, 14 Jun 2022 09:23:00 +0800 Message-Id: <20220614012302.2808428-2-fei.w.wang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220614012302.2808428-1-fei.w.wang@intel.com> References: <20220614012302.2808428-1-fei.w.wang@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 2/4] lavc/hevcdec: do not let missing ref frames invovled in dpb process X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Xu Guangxin , Fei Wang Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Xu Guangxin We will generate a new frame for a missed reference. The frame can only be used for reference. We assign an invalid decode sequence to it, so it will not be involved in any dpb process. Tested-by: Fei Wang Signed-off-by: Xu Guangxin --- libavcodec/hevc_refs.c | 14 +++++++++++++- libavcodec/hevcdec.c | 4 ++-- libavcodec/hevcdec.h | 3 +++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c index 3f8fe1ef18..89053fd1a2 100644 --- a/libavcodec/hevc_refs.c +++ b/libavcodec/hevc_refs.c @@ -172,6 +172,16 @@ int ff_hevc_set_new_ref(HEVCContext *s, AVFrame **frame, int poc) return 0; } +static void unref_missing_refs(HEVCContext *s) +{ + for (int i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) { + HEVCFrame *frame = &s->DPB[i]; + if (frame->sequence == HEVC_DECODE_SEQUENCE_INVALID) { + ff_hevc_unref_frame(s, frame, ~0); + } + } +} + int ff_hevc_output_frame(HEVCContext *s, AVFrame *out, int flush) { if (IS_IRAP(s) && s->no_rasl_output_flag == 1) { @@ -418,7 +428,7 @@ static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc) } frame->poc = poc; - frame->sequence = s->seq_decode; + frame->sequence = HEVC_DECODE_SEQUENCE_INVALID; frame->flags = 0; if (s->threads_type == FF_THREAD_FRAME) @@ -462,6 +472,8 @@ int ff_hevc_frame_rps(HEVCContext *s) return 0; } + unref_missing_refs(s); + /* clear the reference flags on all frames except the current one */ for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) { HEVCFrame *frame = &s->DPB[i]; diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index f782ea6394..99785aa5d1 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -569,7 +569,7 @@ static int hls_slice_header(HEVCContext *s) } if ((IS_IDR(s) || IS_BLA(s)) && sh->first_slice_in_pic_flag) { - s->seq_decode = (s->seq_decode + 1) & 0xff; + s->seq_decode = (s->seq_decode + 1) & HEVC_DECODE_SEQUENCE_MASK; s->max_ra = INT_MAX; if (IS_IDR(s)) ff_hevc_clear_refs(s); @@ -614,7 +614,7 @@ static int hls_slice_header(HEVCContext *s) return pix_fmt; s->avctx->pix_fmt = pix_fmt; - s->seq_decode = (s->seq_decode + 1) & 0xff; + s->seq_decode = (s->seq_decode + 1) & HEVC_DECODE_SEQUENCE_MASK; s->max_ra = INT_MAX; } diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h index de861b88b3..9c8bcefb48 100644 --- a/libavcodec/hevcdec.h +++ b/libavcodec/hevcdec.h @@ -390,6 +390,9 @@ typedef struct DBParams { #define HEVC_FRAME_FLAG_LONG_REF (1 << 2) #define HEVC_FRAME_FLAG_BUMPING (1 << 3) +#define HEVC_DECODE_SEQUENCE_MASK 0xff +#define HEVC_DECODE_SEQUENCE_INVALID (HEVC_DECODE_SEQUENCE_MASK + 1) + typedef struct HEVCFrame { AVFrame *frame; AVFrame *frame_grain; -- 2.25.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".