From patchwork Thu Oct 27 17:50:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 39018 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:85a8:b0:a2:d5a7:ad9d with SMTP id s40csp324187pzd; Thu, 27 Oct 2022 10:50:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5z/tYcGW2AfYw4Ti2PH6v9Tg1EAhmrWSRTHh20j13EdaKgdhCGk55uv0IiY0pYPpfZ3Isk X-Received: by 2002:a05:6402:1d86:b0:457:e84:f0e with SMTP id dk6-20020a0564021d8600b004570e840f0emr46494483edb.241.1666893044147; Thu, 27 Oct 2022 10:50:44 -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 y10-20020a056402358a00b00461cb980126si2320426edc.309.2022.10.27.10.50.43; Thu, 27 Oct 2022 10:50:44 -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=oQIV8Moy; 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 44FB368BC30; Thu, 27 Oct 2022 20:50:39 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2048.outbound.protection.outlook.com [40.92.89.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 78C4368B940 for ; Thu, 27 Oct 2022 20:50:32 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CvpMRD/B1u+132E0PPMe4QqreSflVkTZ/c2miWIjeLAH6gpS4RCBAO1feP7zm/gqZzXYASafFtQiBtxK7acD+KalLDmynd09onTONA1P/5cMJyv0/nPka28/jgxpDjkZUHc471Nb7CdM68ER40he/BMRZf10eUv58xWg7DMR8XvELRLH0jWWU+aHEcVyyzLiWbnM48V4vz2Lc/irEmKlub+Zm4u91oGaO0Ay2L8TuCTUfXNJj13PhHBK7/aJ7eT1K0AMCGstbmBZvTvE0Kbi75EbL1SLvfXtlbNWikdBVxW9TRqZcyvn68Ne/IjHHz/fQWX0zRCQHuVjAjcI6a/l0A== 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=lckf1OHN8tigeGtZIovCI1az/YdxhRdwAVppRFPBgSc=; b=HVzKM1qI5tEHA6CwCviMbVYIru85tYeCSXDM/3gCJABgm4bmZByBQEoTAC9q6lBOSWlaMPuuNNgxFBRW66HpitXWmjS64b+17/hXQXNMbrh2pzRHdTxGhHEAoDimITntBqC++bHFP0G2QltuskPrM+dqTg3pJBn54UJQlJdY+mkvTbYMXd9w4Qk9TK+Jzh9Br9CEQ8SCr7fZRVd2u9wwPHKErykxQR0VJOav3BrM4ms98eTHtz9JNRLgwYai2roLcOnL8nQe1uVS0/+ToT++B9PlKF2baykyRlr4zrgOxJgcX+2e+JYVTbwSsNhOxv/zKdxFXp4X1wUNrKZ/f5TdwQ== 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=lckf1OHN8tigeGtZIovCI1az/YdxhRdwAVppRFPBgSc=; b=oQIV8MoygnxJOkp+MjlfC0sjbn/XMbSehVrmZjfO/J3FBrrUmCPwszdMBpno8dxOGsd9pw728bmrShO7VD/mW3dIUn/ZT89NKwsEyiL8BZmCGsKIzL7BdW+TxwDrtu9wvPLXqcKpbey26HrJCy71lADBMIDUN480ZCAdmFMTFdco9loOVh6OSn3DLmqDX9zCm3QdJOmxZxnXIa7BEzw/LduRen32FSMXF9NLwNfVovO0pqqxWfp2vgMAS93gG4p8TJYt+7kysCGaQz9c/RzJxeYwloXDWcwVVU6aHbWbjoDOfISMBtnRIW3iuq1HQIz+/KN/0z/T5yjqAwHIiKV6Bg== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by PR3P250MB0258.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:17d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.21; Thu, 27 Oct 2022 17:50:29 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::f9d7:680f:70c4:44fe]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::f9d7:680f:70c4:44fe%9]) with mapi id 15.20.5709.015; Thu, 27 Oct 2022 17:50:29 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 27 Oct 2022 19:50:35 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 X-TMN: [DseW8C6ACezsoSE/XNBWhUq/F0Pzbv0+HS3nOQ64F2I=] X-ClientProxiedBy: AS9PR06CA0568.eurprd06.prod.outlook.com (2603:10a6:20b:485::30) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20221027175035.610931-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|PR3P250MB0258:EE_ X-MS-Office365-Filtering-Correlation-Id: 2a5f16c6-1326-4a22-bb6f-08dab843bcc9 X-MS-Exchange-SLBlob-MailProps: AZnQBsB9Xmpo6vGbDxRaQp9dxtE8jPdb46+ro30eCz4QYOJnc7ZjE4WXka+D6u32t0/OH0GtmHPpgKeLcPrpRc1zWVT5l+tdQ4f7Ggwcvs7OL9jn/OoqsN22dMrKEhVUnMUPi4eeei5hUQVCVdUG1eisZz9sMTwMycCI61NGohTdPbaTSTOrJK3WPt39B+LrQNU6Hs6Ki30FgHA3U4W/SrVbFajj9luw/t1jMPpDrY3+aC9sWYelGcTg+er5UqkomBB/wqkiJSIrH5XPrLA0mzlZFv+hjuulTyXbF9IhfVI2W2h+H3UuMj/+whiLlWhdI7qryw/Fm6SZlnfXrBaU5rsKJwR29PjQaVW7b7EJjbGTrWtaEqH/zjbnP4K1Pg2Cj10FqHIHpLI+1jVho5ac31aI/RdAZYa5ZF6S4cMzSPEQU+IBJnpOpem2rSMLPluW8yZGzy43+wXGjPKVnL9TIgpo9QlDcQ9he/gpbUgIT5N9WI9BE5ITGlEYIW27tSDAD53HRWdorUaohmd5hFdWqIi6lWcck7Ft9jOM0Ft+Z8fUVTuEIiFzgBxadhFwTQNFH/M+iFB4WJXVx1ANILXWV7GSnBAcYx6C7xsWI6VVtFsplYfrw/Gaf3jKAnhBACM8EEgG4KqGd9BBxAhJJiuT9UORHPvuvnmQjtd8joRe83q+LUBINTzZiB5oEuV3ygaVnn680LZMuQynpPHQULHZKlKAstRx9Q89vHivp7iLAeRK05FRWfMPyzOyizJFmD3S8SxAdxHyUjc= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Bi+ni0IbtHRvlJ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MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Oct 2022 17:50:29.8346 (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: PR3P250MB0258 Subject: [FFmpeg-devel] [PATCH] avcodec/mpegvideo_enc: Initialize dct_unquantize_int(ra|er) only once 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: aKLw5K1tagd1 For encoders, mpeg_quant is an option of the MPEG-4 encoder and therefore constant. This implies that one can set the dct_unquantize_(intra|inter) function pointers during init. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo_enc.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index ce363a585d..0b709974a1 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -880,6 +880,17 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) ff_dct_encode_init(s); + if (s->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG2VIDEO) { + s->dct_unquantize_intra = s->dct_unquantize_mpeg2_intra; + s->dct_unquantize_inter = s->dct_unquantize_mpeg2_inter; + } else if (s->out_format == FMT_H263 || s->out_format == FMT_H261) { + s->dct_unquantize_intra = s->dct_unquantize_h263_intra; + s->dct_unquantize_inter = s->dct_unquantize_h263_inter; + } else { + s->dct_unquantize_intra = s->dct_unquantize_mpeg1_intra; + s->dct_unquantize_inter = s->dct_unquantize_mpeg1_inter; + } + if ((CONFIG_H263P_ENCODER || CONFIG_RV20_ENCODER) && s->modified_quant) s->chroma_qscale_table = ff_h263_chroma_qscale_table; @@ -1723,17 +1734,6 @@ static int frame_start(MpegEncContext *s) } } - if (s->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG2VIDEO) { - s->dct_unquantize_intra = s->dct_unquantize_mpeg2_intra; - s->dct_unquantize_inter = s->dct_unquantize_mpeg2_inter; - } else if (s->out_format == FMT_H263 || s->out_format == FMT_H261) { - s->dct_unquantize_intra = s->dct_unquantize_h263_intra; - s->dct_unquantize_inter = s->dct_unquantize_h263_inter; - } else { - s->dct_unquantize_intra = s->dct_unquantize_mpeg1_intra; - s->dct_unquantize_inter = s->dct_unquantize_mpeg1_inter; - } - if (s->dct_error_sum) { av_assert2(s->noise_reduction && s->encoding); update_noise_reduction(s);