From patchwork Mon Jan 24 17:00:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 33800 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:e71a:0:0:0:0:0 with SMTP id b26csp495101ioh; Mon, 24 Jan 2022 09:01:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+rJQlYHG6hirFAJ0B7p470EQYDGbihVN3SKkuRa46laejQQ7t4FWJDzXaSBPDeaTnP0s5 X-Received: by 2002:a17:907:1b11:: with SMTP id mp17mr13233206ejc.374.1643043665867; Mon, 24 Jan 2022 09:01:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643043665; cv=none; d=google.com; s=arc-20160816; b=S3fSR//Q8XmoyjB91x7cGbXTTj3ZCYO886UChTt24dkvaGKnZlfusizw/10vy4NDr3 LBCyHfUD2HCBcJo07xPg+9ZzytmbjwnSwWZ1sA+GNwLGdtjRPNeGucmL3sNMNITiHYRL IKcNlaHcuu0sD1NLNkcqSgiQCnNkAkIaKT8nasfovB3clBHkNH0sr1v+L9Clw5bxrEJP +HDsnsZulFLzyabI6eg/43PimT72lPZtWtG6ftFoAH1XRyemO1cHjbcEx1E6+ypid25v y1U65XWhpS1G+/XRLFifROAL0A+tZRXtlN2dDUm0kOcN0YwaM0PI3sQPrg9LwnLE0CXk SMyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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:delivered-to; bh=+x43pTBD2l2ZPL/eZKqh3iD/Oc2wUjPRcsANJUAUhfw=; b=dQIYz1NDkTGhmS848d/5ppSEeWneqk1tjwtJYhPGSJRVv8zhqzfj/HWZYpkbbdGspL UKnbXpUz/Oz+sK6ZY6WxnbpACP1bWS2hUgKfggaRgk9s5in3usCgs+EHcUlqZBQS3sds xqiDsws7dHCdtJuZzhmh1hRNS+pJFzVQx3YeuKT0rvTH31F7rYJbGeQrgJYc9KEqVOA/ 2rccWdNCcbdlZJLbnT5grMunsmdbu4Lt/p7lx4KAFg5m5Bst06/RtvIA60aP2O0b2lER 85oHd3RJ683DdmmEKe/AhhHt5V29LChD+FF7kvfnooW+lCH5Okjarl1rCd+aruIXzRgx W5FQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 4si7758090ejl.790.2022.01.24.09.01.03; Mon, 24 Jan 2022 09:01: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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9600468B10D; Mon, 24 Jan 2022 19:00:39 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1A61868B0DE for ; Mon, 24 Jan 2022 19:00:32 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 7F2AF24017C for ; Mon, 24 Jan 2022 18:00:31 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id LhpJrXpdd91w for ; Mon, 24 Jan 2022 18:00:30 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id CE0C2240506 for ; Mon, 24 Jan 2022 18:00:29 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id A01D63A0663; Mon, 24 Jan 2022 18:00:26 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 24 Jan 2022 18:00:06 +0100 Message-Id: <20220124170014.17189-5-anton@khirnov.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124170014.17189-1-anton@khirnov.net> References: <20220124170014.17189-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/13] 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: YzHOkO5K/4U9 --- 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 1e1f84ef33..4a56463340 100644 --- a/libavcodec/h264dec.h +++ b/libavcodec/h264dec.h @@ -53,8 +53,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 @@ -466,8 +464,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