From patchwork Mon Dec 7 12:55:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linjie Fu X-Patchwork-Id: 24408 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:c00a:0:0:0:0:0 with SMTP id c10csp2575556ybf; Mon, 7 Dec 2020 04:57:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJyTR9RR0BSOg6oCeqXLlWOCgCoojxBf/GP98YM6GFKsI4TY1JidJH1fDXC+k9d2OhLpFWzU X-Received: by 2002:adf:f9c5:: with SMTP id w5mr19109615wrr.69.1607345827919; Mon, 07 Dec 2020 04:57:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607345827; cv=none; d=google.com; s=arc-20160816; b=nZ693f1iNmsDTs05oEufs0QpU/9Nu+HU7k78t4jflGwyJcKc4TAfL8/Et9XShySdxH eu+OuDVLmJeAI5RJQ9yqweVTJcPA8tm6nLlgLqwdk9MFR3fURSnxNGGOZkyAsBXozt2H de4YlpNG01GzGCtLqMWB9IhLqo6mfJjXzarnmHM72841523rhRralNrNi8rOukYEUDed rrb4UPzpT1Tqhf2kn0QM0S4n5jQ4uEX0sE2bRhXoIPAz5fYFCCSrSZe+ccB0q2JjU8w5 L8O+HpBOvsB6dm7dSKrMlU/v5Yz7rx9NB+ZrmyJX6siBq0iNus4s6eo+QFh048tSw4x8 bR1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=jc47XIiDxJK3P+y6TqrX0wX7XVleAkBv0Eo4TFAWk90=; b=toZvArE4zLAhc/1g9u5JLVz8joHNpAC2Icf/7/1vxgCtgjPeXIJB1j1Ujz3Px6o4oC XtpKciWQkZjX3mM0w/AY5Kf0sHokrkPaM3hDV3XCau5pjOkn2i3HL5eYr+XEuFk6vB+r kIgHO9ildkDpgMdhtmbJT+Dt9s6BLACDTxCOXKYTboB5CTOOAEG2wjWkcwL5Iul/Zjv0 9gIYnRT2/2wxRLNWWWLrzPMAHRey7TYkG0+PweyG5Bmt6MQ1MwLt6AxfE6fBMHdzMPGs PWpGgI/le8orXvfyCnPt/vNzhnlQBsLZNpHCQ19ERkWIqUxs0ZtJlxzYtPnv9mhm8Ig7 hNmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=p9BP2owo; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id f10si10958550wre.89.2020.12.07.04.57.06; Mon, 07 Dec 2020 04:57:07 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=p9BP2owo; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 17C1D68A1CC; Mon, 7 Dec 2020 14:56:39 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 22D9A68A1C5 for ; Mon, 7 Dec 2020 14:56:33 +0200 (EET) Received: by mail-qk1-f179.google.com with SMTP id q5so12292700qkc.12 for ; Mon, 07 Dec 2020 04:56:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GQMDpvX3ABI+GyrNRQUYzo7++SRroAMcDVshxbHTuKQ=; b=p9BP2owoxuZA/kle7FAlEw4zzFI7R35ypKubW+TK5/7AAhV0WLGUJxYPr0f6dG7Vbx /iae3E2owVcaS08cIxwxeYCciW7Gi2rd39L5Dmt7MKQ1dsqryZf0rmJ27qs/L6/B0tlV 7/gF+Tef7xxHVkWG3mZypbSYHlUHwzIEN3oLINsfXoVJxm0Jjxa5Dfn7hZKf0RgnTqKJ KsFwGc/kswPmu+ESYintgS+ylBJ1JT+0plFg8FfJZNrgrasx6nqkGfItjh2+dB8mJK+n EzajqFDrZzu6we/ibEqobXv9W4Kk3QmI2ug1RjExremTzUjW4f+4oDGR89rUmBJs6ERu jtQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GQMDpvX3ABI+GyrNRQUYzo7++SRroAMcDVshxbHTuKQ=; b=pmM6V9DPQlC0lgQ3u6vBhslGySHOiGimes4oUWGWCZApSqUjk+fHdlYFFjpBNIOv5t L7FIUWQZYlbGA3ss5pheQSbF/Fn4u7sUsl4fGbNN8NQdm5VS65e/AHMpgsesqf0Ki9P+ zcUEpDMMxJLS/3JviJCvE+oVjSad4OPDcBW35CibhiNKa2t2YZ2mVuLprLwWa1R3apeL okfgUYZj5/TxrtcZOeDGGUqp8296CuwZ8jZu9GASrXppKf+7RiBQD4oerfLgAAFki9/u 3bo0m4m2RsO/FZwey2AOJcrTPTkVbzLyT6baEwfVJ+7Fu0aujMh8kvLM7AeG25xLvNHn NqJQ== X-Gm-Message-State: AOAM53368ahI4sFeQqE6GfiwJ3dCcroVTSCrPkZ+CLDRfCdDajmoKHuS cq8HpXK45tuTYNdR39+eYnI0U0t0iDZgwQ== X-Received: by 2002:a05:620a:16a5:: with SMTP id s5mr505516qkj.368.1607345791484; Mon, 07 Dec 2020 04:56:31 -0800 (PST) Received: from ip-172-31-39-116.us-east-2.compute.internal (ec2-52-14-134-25.us-east-2.compute.amazonaws.com. [52.14.134.25]) by smtp.gmail.com with ESMTPSA id w15sm1638489qta.95.2020.12.07.04.56.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 04:56:30 -0800 (PST) From: Linjie Fu To: ffmpeg-devel@ffmpeg.org Date: Mon, 7 Dec 2020 12:55:44 +0000 Message-Id: <20201207125545.621159-8-linjie.justin.fu@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201207125545.621159-1-linjie.justin.fu@gmail.com> References: <20201207125545.621159-1-linjie.justin.fu@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 7/8] lavc/hevc: Update reference list for SCC X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Linjie Fu Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: /Y9Kz+As7yEd Content-Length: 6347 Screen Content Coding allows non-intra slice in an IDR frame, and would mark the current decoded picture as "used for long-term reference", no matter TwoVersionsOfCurrDecPicFlag(8.1.3), hence some previous restricts are not suitable any more. Constructe RefPicListTemp and RefPicList according to 8-8/9/10. Add a check for native decoder to quit while self-referencing is detected, since it's not supported yet. Signed-off-by: Linjie Fu --- libavcodec/hevc_refs.c | 27 +++++++++++++++++++++++++-- libavcodec/hevcdec.c | 6 +++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c index 4f6d985ae6..ba32e232bb 100644 --- a/libavcodec/hevc_refs.c +++ b/libavcodec/hevc_refs.c @@ -301,7 +301,7 @@ int ff_hevc_slice_rpl(HEVCContext *s) return ret; if (!(s->rps[ST_CURR_BEF].nb_refs + s->rps[ST_CURR_AFT].nb_refs + - s->rps[LT_CURR].nb_refs)) { + s->rps[LT_CURR].nb_refs) && !s->ps.pps->pps_curr_pic_ref_enabled_flag) { av_log(s->avctx, AV_LOG_ERROR, "Zero refs in the frame RPS.\n"); return AVERROR_INVALIDDATA; } @@ -328,6 +328,12 @@ int ff_hevc_slice_rpl(HEVCContext *s) rpl_tmp.nb_refs++; } } + // Construct RefPicList0, RefPicList1 (8-8, 8-10) + if (s->ps.pps->pps_curr_pic_ref_enabled_flag) { + rpl_tmp.ref[rpl_tmp.nb_refs] = s->ref; + rpl_tmp.isLongTerm[rpl_tmp.nb_refs] = 1; + rpl_tmp.nb_refs++; + } } /* reorder the references if necessary */ @@ -350,6 +356,12 @@ int ff_hevc_slice_rpl(HEVCContext *s) rpl->nb_refs = FFMIN(rpl->nb_refs, sh->nb_refs[list_idx]); } + // 8-9 + if (s->ps.pps->pps_curr_pic_ref_enabled_flag && sh->slice_type == HEVC_SLICE_P && + !sh->rpl_modification_flag[list_idx] && rpl_tmp.nb_refs > sh->nb_refs[L0]) { + rpl->ref[sh->nb_refs[L0]] = s->ref; + } + if (sh->collocated_list == list_idx && sh->collocated_ref_idx < rpl->nb_refs) s->ref->collocated_ref = rpl->ref[sh->collocated_ref_idx]; @@ -423,7 +435,8 @@ static int add_candidate_ref(HEVCContext *s, RefPicList *list, { HEVCFrame *ref = find_ref_idx(s, poc, use_msb); - if (ref == s->ref || list->nb_refs >= HEVC_MAX_REFS) + if ((ref == s->ref && !s->ps.pps->pps_curr_pic_ref_enabled_flag) || + list->nb_refs >= HEVC_MAX_REFS) return AVERROR_INVALIDDATA; if (!ref) { @@ -492,6 +505,12 @@ int ff_hevc_frame_rps(HEVCContext *s) goto fail; } + if (s->ps.pps->pps_curr_pic_ref_enabled_flag) { + ret = add_candidate_ref(s, &rps[LT_FOLL], s->poc, HEVC_FRAME_FLAG_LONG_REF, 1); + if (ret < 0) + goto fail; + } + fail: /* release any frames that are now unused */ for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) @@ -518,5 +537,9 @@ int ff_hevc_frame_nb_refs(const HEVCContext *s) for (i = 0; i < long_rps->nb_refs; i++) ret += !!long_rps->used[i]; } + + if (s->ps.pps->pps_curr_pic_ref_enabled_flag) + ret++; + return ret; } diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 6a029b270e..e1d469658c 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -637,7 +637,8 @@ static int hls_slice_header(HEVCContext *s) sh->slice_type); return AVERROR_INVALIDDATA; } - if (IS_IRAP(s) && sh->slice_type != HEVC_SLICE_I) { + if (IS_IRAP(s) && sh->slice_type != HEVC_SLICE_I && + s->ps.sps->ptl.general_ptl.profile_idc != FF_PROFILE_HEVC_SCC) { av_log(s->avctx, AV_LOG_ERROR, "Inter slices in an IRAP frame.\n"); return AVERROR_INVALIDDATA; } @@ -752,6 +753,9 @@ static int hls_slice_header(HEVCContext *s) if (!nb_refs) { av_log(s->avctx, AV_LOG_ERROR, "Zero refs for a frame with P or B slices.\n"); return AVERROR_INVALIDDATA; + } else if (s->ps.pps->pps_curr_pic_ref_enabled_flag) { + av_log(s->avctx, AV_LOG_ERROR, "Self refs for a frame is not supprted yet.\n"); + return AVERROR_INVALIDDATA; } if (s->ps.pps->lists_modification_present_flag && nb_refs > 1) {