From patchwork Thu Aug 18 18:35:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 37353 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp478204pzh; Thu, 18 Aug 2022 11:36:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR56/bn2HsRBJPB4J+/VK2D5HWvv/n9Y3GqlSBVnkIcQshikS9YFLLpTKs3StXDxm/jxjQ3S X-Received: by 2002:a05:6402:5388:b0:435:71b:5d44 with SMTP id ew8-20020a056402538800b00435071b5d44mr3160295edb.364.1660847771992; Thu, 18 Aug 2022 11:36:11 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id b16-20020a056402351000b0043d19ac7ff2si1990254edd.87.2022.08.18.11.36.11; Thu, 18 Aug 2022 11:36:11 -0700 (PDT) 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=VwAOD7A1; 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 9871E68B968; Thu, 18 Aug 2022 21:36:07 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03olkn2027.outbound.protection.outlook.com [40.92.59.27]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5CA5868B75A for ; Thu, 18 Aug 2022 21:36:01 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AMrxb6tI4ge1wsOiX89TbvuUWwfGcxLZ9fmtbsZPSryXgvYB5gVsFCupJ1nfLLaTbwwGYT5YcMwFZKDpvAlYTGL23MPFj5Zw6RCMmei0lFdX/AqS4gZpNjXo7wFNcrLJfn33cO4yy2zxHq1MTibjB3weiNQZqK9crEN4IOa9kcKDg1wa/moVoTusM0qFQPBFlzzjiaxzkQA2h5D/+Cg3S7f0t8XM+ZjQBTjirpBHvbeYM8Icep/ELKNqqq2GlEuNTtaodp+5jmqgp+gHq1nBHO1DN1rw571yKQpPNN4BdA0dYVaNRj76nB7G8rSCQW3OKYcgZtGyyVcKcYFJGCyDZw== 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=E9MYe1qgDYTQyBDZxmmHpcc1tszp6wjCcNCG+gVyw0E=; b=dpq1hRmKq3LCmaIoJwc+by3U/+Yb4PqmMpxwviKCBnDgItlrYd4Pf0x/QVliHop99UHLlyeuM+1V3GnfqjuS+7ZrRM52XpgEs09Z2aEsEOXfHRXUWi5vGaeuh2pz8yajH7CFmHY43+i548GD7M2nhHAl6ZfcNUHgXLGTo2oebDXkk8Xswktfo6r2td15XKEkKspY8VcWQTeAsoqJl0mYNUY0h1r4xuWl3AFJ3Dqsqj06+xGAtvUJKnOM5cKBsVGVabJOgxCp35rBtmmRq9z+9u6IP8eUFeXVr0qgOhMrBQCb9yicNxiqsvTd8KzQrNNEFxjsLup8b5lFifHe/g4u2A== 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=E9MYe1qgDYTQyBDZxmmHpcc1tszp6wjCcNCG+gVyw0E=; b=VwAOD7A15ewJhCyQ01Zw9/PWy51P6TcGDr4Fxq2EEqhbbqiOTr6cNjLCvzm5jxPH9ftSP3BiAKJDsGzzpY64zHLKuc87jNxqPB2/35VtGygBcVE/gDHb5pHxCON9Ac0RSneSnJCRGJms5yMPydD0bTCnJk6u02ezV6ZvXZrQs1od3eG2r1/KkqxByXaWKMUqvDW9fUDaMkMNHvBWh03Rch8ZM/XOGP5rhyZ13BT5OkrVfrA+uCcHM+x/ip+78h5DOMgTKu0qPt65WJieMbpsvkAqkAgkVqsWXQxk8h7LbqFrYSHS2+/9j/qdcVBfGWbf1K5Bs3U2K913pm6yX8IXTw== Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) by PAXPR01MB10262.eurprd01.prod.exchangelabs.com (2603:10a6:102:24f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Thu, 18 Aug 2022 18:35:59 +0000 Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::210e:b627:bcc9:8c46]) by DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::210e:b627:bcc9:8c46%11]) with mapi id 15.20.5504.028; Thu, 18 Aug 2022 18:35:58 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 18 Aug 2022 20:35:52 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 X-TMN: [O4ZMT5Mj5QIWr7c53oLbIOG0NaMt49HR] X-ClientProxiedBy: ZR0P278CA0122.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:20::19) To DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) X-Microsoft-Original-Message-ID: <20220818183552.742576-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eac1ec0b-1c23-4f01-081b-08da81487e52 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNWqLpJmXNddFg/tAMG69OavoqHLRDfbCuT6RU4P+jCoaWrNl6XMz8aISUjIkoti9EqNVqUyDYbOhL0PZi7Tmsc7ATClhI7mbchrsUSTt7xaaYRPzFX5iY7HL5EsjtitFxROUGDYyaTZtSRyfeWYZulXra9B07J++69iaJ0r8wbzXGkA1tiAIF/VZijoB7hDyXz17VOZK0pwjBQ1g4wOAZDRWHh/FhTlG5CH6K8hA7w0S1NC3bplmhTDrDZqyUSTGgqaBHjqGnSibdMGONGM2fM+VlN5ndpFtygsxhRlpH+dDXl6DtWHor2aB95mEBYyjP2jKXcro5WgQByAIW2GJmn+BdJrQAVmRHSjgJOp+F49xKOsQKlHtQ1u3LjewSwkgpx0kABd7DoK6tbsrOI29q2MEHyDTCJC0FjHR+WOstPNe7iVPkER1D+F0vfmskmdmiDAEzjMqcZJJwqDO/PssL7qfO/zCC/+OfesQu5PVsQXwhnq2hLnw0iry7X48WsoyHg3pUvznlIslnUyFBuGr+8XpddhthKIFHap051tSI50c4ozZj7eVyHDatNqInFBwabAsoiCEJBDkmlRciTFJQwPAJxKH1/3Zl+idZs00162AJu1f9yrs03dwjrtdWxXsR49eTgKEQpMtg9wqYk8/ae5saROxJMJ96BV9maXD9u4ELfgid5w8t0f/08SiTPehhOjmh1y4AK4Sxq5E62+64OBpHB/j7QJo2U= X-MS-TrafficTypeDiagnostic: PAXPR01MB10262:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IPUjCS3/DlzkLe8JyWgmCOKHQXyl5FcEgVm8xuCfg5TWF41jRak0Tnd84805EMNIE9MfGu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2nUjhnP296XLeFOrxlkdY+GQ0EoU9uRVyp/VYgOPw4j/YzX5RwkmQnP2VK2BWBcQXC/+HBxHO3IGR7NJlPy6/nzefARUwyERtXUar3SDJA9+jckQTV6VbSLw/RJqcZBsJZ56KS9DlKIw5UA7k2jazcZ/qW7kWbCZbaIBtb6uY8zipE79SRIpvEPYFOZQN2j0cfaZBrnUcKlbV1MweItBQJeUaE3TE9wy1XOlwhDjuNKpbYZKjBcjlTfTnzh6pvGmPT05jIow4nPHwVo84oOetWeQgAMv/EslSLpU4xqyIyB4wmMg3ciS2LU0cMJgf8yx9swMQZ0iQGXSrvVGuYklF5civz1g4awM4NOhhCcSjAmRRf+2dodbhg3DHgXwyOD87oraYJa7hjIGhvFAS4An6wUy1cvbs+LKcwuhWKHVVy1vLI7dJ0lBdXTfbxvU6qzY/qIBCyzEqRh5/Dejea0tK4zXF9MVI5k3OYH2prhfrtESDl2w+0OqlM1eEIoUrBYp2k0atG4/VTBvIRn0ZpGm7A+EjAHzmJwyHON8c/uvblM6ZxCs2cCLjjafNmAWZG+p3DjFrGUrLJTtD4zcCKNc+4Tpmd8BIZCKgd2X0CjeT/bpTw8YN3+f0ua8HzELc1af5v9NTIespGzTpBPZt96GCmOAgqPDZInJCCKwJbbutUNW1vUWA0Fj4IphLoK9Kme7X1vRSEZMBfzeMwhJrEpzgFimJncef9N26kBjcQ1cPgBw/LDbpXXHk6nNwFeK4HDg+71ik0hmIVH3OgUQKvSRXmNbmvOHXhtZ2E7BIIY/1GsD1KnchpHlt5K70DtJMLbJIWXi3XvRI/0CyLbKzPdqUYab02wNLVHU8EmK6EPiHMEMprGO+0= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: eac1ec0b-1c23-4f01-081b-08da81487e52 X-MS-Exchange-CrossTenant-AuthSource: DB6PR0101MB2214.eurprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2022 18:35:58.8904 (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: PAXPR01MB10262 Subject: [FFmpeg-devel] [PATCH] avcodec/mpegvideo_dec: Combine two loops 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: kc6OskW/DKLZ (I think the check for !reference is unnecessary.) Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo_dec.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c index 406c3feacf..5b37e79e36 100644 --- a/libavcodec/mpegvideo_dec.c +++ b/libavcodec/mpegvideo_dec.c @@ -279,12 +279,12 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx) ff_mpeg_unref_picture(s->avctx, s->last_picture_ptr); } - /* release forgotten pictures */ - /* if (MPEG-124 / H.263) */ + /* release non reference/forgotten frames */ for (int i = 0; i < MAX_PICTURE_COUNT; i++) { - if (&s->picture[i] != s->last_picture_ptr && - &s->picture[i] != s->next_picture_ptr && - s->picture[i].reference && !s->picture[i].needs_realloc) { + if (!s->picture[i].reference || + (&s->picture[i] != s->last_picture_ptr && + &s->picture[i] != s->next_picture_ptr && + !s->picture[i].needs_realloc)) { ff_mpeg_unref_picture(s->avctx, &s->picture[i]); } } @@ -293,12 +293,6 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx) ff_mpeg_unref_picture(s->avctx, &s->last_picture); ff_mpeg_unref_picture(s->avctx, &s->next_picture); - /* release non reference frames */ - for (int i = 0; i < MAX_PICTURE_COUNT; i++) { - if (!s->picture[i].reference) - ff_mpeg_unref_picture(s->avctx, &s->picture[i]); - } - if (s->current_picture_ptr && !s->current_picture_ptr->f->buf[0]) { // we already have an unused image // (maybe it was set before reading the header)