From patchwork Mon Jan 24 20:09:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33822 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp15600iov; Mon, 24 Jan 2022 12:11:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJyZ0HFoaiM+EBBLvgySGAneJHwvp7+lN5oYuvbdGHCGB5HPg+fPW9xoQ5tUrvKTQEzcUZv/ X-Received: by 2002:a17:907:7247:: with SMTP id ds7mr14529769ejc.401.1643055065673; Mon, 24 Jan 2022 12:11:05 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ne27si6635629ejc.592.2022.01.24.12.11.05; Mon, 24 Jan 2022 12:11:05 -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=@outlook.com header.s=selector1 header.b=DBedkpqk; arc=fail (body hash mismatch); 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=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 09D9B68B1C6; Mon, 24 Jan 2022 22:10:09 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-oln040092065018.outbound.protection.outlook.com [40.92.65.18]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5D9BB68B192 for ; Mon, 24 Jan 2022 22:09:59 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kng0+VCGlTP0pOjcBrFWIDGJkL3bluvsa0OvR50FZ/Ins3Ldbqb/ZphpiuhLVETa2kdHzYR8D1zI4+I6nEKL+HIKA3a5ePiSMPNZdDUXB8kdoH7HpztEG02IeGTLQqbVsHKcTBQCLDi1GlVCSGHehGWAaNSHgGq1NqZMMR82uCC6qoABVYSIkFPJ493ocfpOQJWk4zApxj6bOKl0g4VY60MHgWg9ke/2LEjCW7Bo0XWbSAdxlf2zIaGMmRu63wxKeTPEWBLL6m2LLNPMRmjdCcq4NItFMBT+k36xttamSUbv1Fbwb0DivZ06gxXA2nDVMne5OthhqZobW9wbDCqe3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Xl7SjLhRW3xVy+WwB7cMChvNm0Bt4cmMZwFrWIfeZg8=; b=bZ3PioYwVTBlYPnfCS4LqWpbsIIe6U5nq7jQEY+AAdnRfRIsS+jeFYw2IjRlhCfPS7pgCHsrJT8DTAwXK0PFoq9x4HMhMHu1ZIkztaVDhrzq5ZblU8kyUJqYX7L1xXEvsCbtMZcKrQ91MLFrtxFPvJod1UWbHz4Sbj3qHWFdKlcLV7Y3zXNemCyQTFr5Fzgt9h4bMrdWQv1y1HEyigARc9J+HT31HcMEKp5xJ3SGrDIJCC2ahNNEUVaFu4vPn/zLtxd+piTyM4Ndyyd7tkNezTYgMoa35HTLyn5kveQ3OVdAV3JQuQ8PeyJTE+gZ5lCzbh/XcVM3+0rt9AekgVXNig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Xl7SjLhRW3xVy+WwB7cMChvNm0Bt4cmMZwFrWIfeZg8=; b=DBedkpqkHhaa9ahvj7uNrVg4l//ydTUQjWBhKQ8CPRtXPmLGU+dIdUJxG+Dy1BqMXL/hTJmb5tWNCOlTWSu3V9d7AAVtHbHuZ59NiwmCWi9Zl63rg8ey+2CVYbXyjtAVvPlfETBPPirhUXwHyKxuuhXsV5+jF/mRP0+YRjZm/2HpNRh4Gp8Jnf4jFO7jv778xxd2FW2s4VHSNULzZZwmZnPf3F5G10/pdjDru+MoT9MpcE+TTPlQ3n+yePehnZTf/DVCgeS5thVk51oJtSuTWV2fb7dZFWHdwq1xp0TMCoa9/MGJBNIGIRSfSFJaSoQTwGJtO489J7yojgEt3m95bw== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by VI1PR0301MB2557.eurprd03.prod.outlook.com (2603:10a6:800:64::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.17; Mon, 24 Jan 2022 20:09:46 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::ac56:2ff4:d304:ab22]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::ac56:2ff4:d304:ab22%4]) with mapi id 15.20.4909.017; Mon, 24 Jan 2022 20:09:46 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 24 Jan 2022 21:09:19 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220124200931.593079-1-andreas.rheinhardt@outlook.com> References: <20220124200931.593079-1-andreas.rheinhardt@outlook.com> X-TMN: [czNLCoNmkWiqwnduNtgWUArsv4G+uMp2] X-ClientProxiedBy: AS8PR04CA0012.eurprd04.prod.outlook.com (2603:10a6:20b:310::17) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220124200931.593079-5-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 30664d72-f778-418e-fdc4-08d9df7577f8 X-MS-TrafficTypeDiagnostic: VI1PR0301MB2557:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qVJ4Fxp/fyKbJU3//KEGIcDThTyChvPk2X1NqXR8pFMnW+OOngojBsQjN+ucrkWBAGw9LPvVzkal9ucJ2oaN/rqsi/qsRooBUuKtbQypSM7nfi8c7su3H3pf8ysEMx/c+mBFdty021q+Kh9PLJLzP5vsaAkzOnj73vB8S9perf4nWYM/QnmA7ltLDBOdEpIKA1AATAEN8cusaDY2gjrEU2SLbO1pJtmget037MfiM/huzSDVEJWe1qXBmpPHbu3HUeMUVJp6lkcWNvKrjtZeeyEsw+ZfKxBDohW8Bo8K29nzt/MOvAGhdDQey4kjBZj72ZEad88lfopRuAKjri3nQdnTFiTdmuuYPsRHgmqBYYDz5QVYvWGKwBYzJkvWNN0xp5ZpEZ6osDWH3stVFBw82UxOXQswj9vT9Hz8wUsQbjV2JC9VK2tAPD/8CZzyAYHQOAq8Qv6hYpr2ylTyD5+qSBtCxt7uxrSFQkto0uUtBAzgKbEtYPQ7VrXLamZWnHj80XVDz88+4APWfwFBzS9fP3z+QADympSE0X/tu2EbImJmcVfl4m0AnTL0JP2UzmwBtHk1JrP8kAnxSCqzFhezHg== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: j8gmmq0mYyDL7zAMcB35epUkxPKCSKGQsmfOPvJOAKT8x/hAckp3G0XeJ2Pgijyk/wchSICtti2wGeic8wUNkgFuqvHdkmBO4Q+UpO9X+dfBRolB1u1Ki/kx0CYdpIUgzg8uhjZMB/EbJskZAHTHlyYxaqKZ1i+CkB6e7F7y64NgSMiIx1hz++QmjaoX2fr4m6W5AnHv6qf9hSfgiuBfvvq3RWQYWM50cVV2YN0A0h6vlNHfqhLOvg/55Gx2PfVomYmqeyIvbviCBozvIK/WlnyzKQgI6U2OY+oND7fDE7hrXHQqpvWXVJmudmd65tQdpuAoJbJAFMGHdSO9GSeyZue88deGKpRpI37CuTIzYqmH4D6QSSFi0PsZXFCfKaO9eEGtYXjXWiCTawKDEKbkFpuAVEOzs3SQ6+tN36DMSQjdBCECJVXD9cCasDPWr/wkUTgSdOMCQdZgas7+ZRRrZzE2w6mR6UwRdKorvDFlUqDGZa83/TD1EfekyfO81w1fs1UbPth4H56fHx4PmisGo6MrQF0oIB6o65N8H85xCd1mLmlDMr2PCZjjVkgd93+bTRyIb+I6e/Gi0JVB1NFK4rnIwT2FWQklkCS8yrCPDiOu6Q01Py9GaZHpaZl2yrBS8eK+lAF2mmUWnXqGRRFf3xz4nrsy3c4tXwZsJzMkWH99skj/yngSHwM5VH7B0aFhpAtUMAkqdfZ5EMVjMeRzeFt1G6r0DnpfDosIrGsPvRfoRFI0V7afMJiKE6ClONLLZ02qW8XjhNuBqo9QSgx1/QMPsEjgJQ+CMErCs5sZso7a0W99u5i75WDTuNyZo+czsMVrwAyNhIfafmfI776VwcKd2lm/Y8ydS/f8hW4ZdVeHg9BCCNLUp19nVL4P2KX76W3TYdlrMoUAa4YL56eF+Thrtg0BPZdy2LqJTGlIfPq6NYq1emgq58MtVt+MrEvwbEQtNmycx8RGpohb7WvjKQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 30664d72-f778-418e-fdc4-08d9df7577f8 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2022 20:09:46.8328 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0301MB2557 Subject: [FFmpeg-devel] [PATCH v2 06/18] lavc/h264: replace MAX_DELAYED_PIC_COUNT by H264_MAX_DPB_FRAMES 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: Anton Khirnov Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: qHZrzcY/xUif From: Anton Khirnov --- libavcodec/h264_ps.c | 4 ++-- libavcodec/h264_slice.c | 12 ++++++------ libavcodec/h264dec.h | 6 ++---- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c index e21c2b56ac..f68d5bf81c 100644 --- a/libavcodec/h264_ps.c +++ b/libavcodec/h264_ps.c @@ -485,7 +485,7 @@ int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx, sps->ref_frame_count = get_ue_golomb_31(gb); if (avctx->codec_tag == MKTAG('S', 'M', 'V', '2')) sps->ref_frame_count = FFMAX(2, sps->ref_frame_count); - if (sps->ref_frame_count > MAX_DELAYED_PIC_COUNT) { + if (sps->ref_frame_count > H264_MAX_DPB_FRAMES) { av_log(avctx, AV_LOG_ERROR, "too many reference frames %d\n", sps->ref_frame_count); goto fail; @@ -590,7 +590,7 @@ int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx, * level */ if (!sps->bitstream_restriction_flag && (sps->ref_frame_count || avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT)) { - sps->num_reorder_frames = MAX_DELAYED_PIC_COUNT - 1; + sps->num_reorder_frames = H264_MAX_DPB_FRAMES - 1; for (i = 0; i < FF_ARRAY_ELEMS(level_max_dpb_mbs); i++) { if (level_max_dpb_mbs[i][0] == sps->level_idc) { sps->num_reorder_frames = FFMIN(level_max_dpb_mbs[i][1] / (sps->mb_width * sps->mb_height), diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index d6d4497fc9..32df9fd3ae 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1456,7 +1456,7 @@ static int h264_select_output_frame(H264Context *h) } for (i = 0; 1; i++) { - if(i == MAX_DELAYED_PIC_COUNT || cur->poc < h->last_pocs[i]){ + if(i == H264_MAX_DPB_FRAMES || cur->poc < h->last_pocs[i]){ if(i) h->last_pocs[i-1] = cur->poc; break; @@ -1464,13 +1464,13 @@ static int h264_select_output_frame(H264Context *h) h->last_pocs[i-1]= h->last_pocs[i]; } } - out_of_order = MAX_DELAYED_PIC_COUNT - i; + out_of_order = H264_MAX_DPB_FRAMES - i; if( cur->f->pict_type == AV_PICTURE_TYPE_B - || (h->last_pocs[MAX_DELAYED_PIC_COUNT-2] > INT_MIN && h->last_pocs[MAX_DELAYED_PIC_COUNT-1] - (int64_t)h->last_pocs[MAX_DELAYED_PIC_COUNT-2] > 2)) + || (h->last_pocs[H264_MAX_DPB_FRAMES-2] > INT_MIN && h->last_pocs[H264_MAX_DPB_FRAMES-1] - (int64_t)h->last_pocs[H264_MAX_DPB_FRAMES-2] > 2)) out_of_order = FFMAX(out_of_order, 1); - if (out_of_order == MAX_DELAYED_PIC_COUNT) { + if (out_of_order == H264_MAX_DPB_FRAMES) { av_log(h->avctx, AV_LOG_VERBOSE, "Invalid POC %d<%d\n", cur->poc, h->last_pocs[0]); - for (i = 1; i < MAX_DELAYED_PIC_COUNT; i++) + for (i = 1; i < H264_MAX_DPB_FRAMES; i++) h->last_pocs[i] = INT_MIN; h->last_pocs[0] = cur->poc; cur->mmco_reset = 1; @@ -1484,7 +1484,7 @@ static int h264_select_output_frame(H264Context *h) while (h->delayed_pic[pics]) pics++; - av_assert0(pics <= MAX_DELAYED_PIC_COUNT); + av_assert0(pics <= H264_MAX_DPB_FRAMES); h->delayed_pic[pics++] = cur; if (cur->reference == 0) diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h index c7662f930e..7553dd808c 100644 --- a/libavcodec/h264dec.h +++ b/libavcodec/h264dec.h @@ -52,8 +52,6 @@ #define H264_MAX_PICTURE_COUNT 36 -#define MAX_DELAYED_PIC_COUNT 16 - /* Compiling in interlaced support reduces the speed * of progressive decoding by about 2%. */ #define ALLOW_INTERLACE @@ -465,8 +463,8 @@ typedef struct H264Context { H264Ref default_ref[2]; H264Picture *short_ref[32]; H264Picture *long_ref[32]; - H264Picture *delayed_pic[MAX_DELAYED_PIC_COUNT + 2]; // FIXME size? - int last_pocs[MAX_DELAYED_PIC_COUNT]; + H264Picture *delayed_pic[H264_MAX_DPB_FRAMES + 2]; // FIXME size? + int last_pocs[H264_MAX_DPB_FRAMES]; H264Picture *next_output_pic; int next_outputed_poc; int poc_offset; ///< PicOrderCnt_offset from SMPTE RDD-2006