From patchwork Tue Feb 1 13:06:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34004 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp606242iov; Tue, 1 Feb 2022 05:14:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJyIldltLMrEFIQ9wCFTpQKs0ezV7hmVfw50X3J2nCm+eQFV9gU3Z9Z+cA5DmSa7e0+Gef+V X-Received: by 2002:a17:907:1c0f:: with SMTP id nc15mr20755447ejc.673.1643721259404; Tue, 01 Feb 2022 05:14:19 -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 dn2si7239593ejc.146.2022.02.01.05.14.19; Tue, 01 Feb 2022 05:14:19 -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=YFAwwSxU; 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 81BFC68B37F; Tue, 1 Feb 2022 15:08:08 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-oln040092073057.outbound.protection.outlook.com [40.92.73.57]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 384E068B37E for ; Tue, 1 Feb 2022 15:08:01 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jDut0G1bhM3ZiSYkao6Ds41h+o754raoNAtbtg8iRrpmeg7e95fdh7RmF5jiuJdq9NUJ0/e1Tpk88dGIjg7T+UimkRsKIFediAN7Yqq4i4+r8yIXjQ/pQ6aLQmiOMVZQbfHO0fL84WNHVTP5MGk0IuGR1MEMzWJ7HbEyojeDzLcBbXTtXGzAo5tB8xRuk+GXxgYZ4sIvvGdcFwHYf2VvUXW63LYRshyqsj5hX+/rfo+fBDxpFGxu4+is7bTW8gCC0Ex2qHkFc7XJFCeM7EexA6lSoAvE5eORfKW5vaRcpWs0f8p3UMwitpSAc8yc1YAVjO6JTmdSlXdA0HQBtW++Iw== 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=/nt9bL+771HzE/i77VcI+d2ObuF639mbr9NYHFPPTmk=; b=c4q1EvABp2YdiefCySgLAB8J/7agKmiDLO1LPo9wPZjj5BlzjOjtXw3MvaBPC2N9UQdtfv06//WPNC7WUTAnD+M5D73qYCLIwhy3FID7AyQO4SA2/Hcvauf6CxlF2KOGXotsEpnBSuYJLsSVo7jUAXZsZCi02+j1t+IE0judTpW35k97NyoF1fOO+klkVAheYl9pvDuZaY6QEJuF8OhvDJ0lxs4QEPaPi+/Bu//+2x2nUroj4HFY4N9505mSu8SZ9xSI7r1bEihoq4fPgNhMpS+XQ9CMLUZK1JCO1tV9pO4BViHJ82Yn0FsZ/5l8ojcEywx9m1kLxuq8N8nTQGs5lA== 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=/nt9bL+771HzE/i77VcI+d2ObuF639mbr9NYHFPPTmk=; b=YFAwwSxUAI6k43biRIYtTKjgUzeT+wv1zYsX0TF8h3qLPd+tIS+JnSZsLIZCGyWtOOjA5Go+NBkQjGNIAdhU6YZZ8oKZu0esG4LOFzNVylCLdOBJ6u7PjhGg81G2I/JCEEU7flwsZH+kD1f03c2QopVGCAq8hV+beVgwp+ULCuv1IqNSMCGPbn0R+7fOiLbt9remelcn//gG/q1+Qh9IBXG4mI9qTu8CtImhiZNsVtaT1S2OVx7jVbZhssiFG5NzbPmJYV2BUG9JQ0xq+OOviz1dOOnawsVgJxEzxKedodKrNDFutKpNhtCGgGJigNvo1+um/B5eW8Pci9J4qHFDJw== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM9PR03MB6948.eurprd03.prod.outlook.com (2603:10a6:20b:2d9::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.22; Tue, 1 Feb 2022 13:07:59 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::ac56:2ff4:d304:ab22]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::ac56:2ff4:d304:ab22%6]) with mapi id 15.20.4951.011; Tue, 1 Feb 2022 13:07:59 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:28 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [2pxDP7V49AGFmxqyISAYo4DOSbFSvWkU] X-ClientProxiedBy: AM6P195CA0092.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:86::33) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220201130706.1420875-30-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 483656fe-6516-4edb-c424-08d9e583def9 X-MS-TrafficTypeDiagnostic: AM9PR03MB6948:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8oU9gJmqzlds5BYVnK8gixKuQnynV8piyttd53D4ABg1hghQPjolxGkp9mG8jF75nD9zQqzRcbMR5X/A/LnuyktoMwc+/f9VejYJBW0yT+6zabvnUx/zg5ryjq50JubwiXggeMjID2BneMP6N/GdpBuz4TZ1ryKJJuWbwblZ28qHcTGiwUYT/inpBLNG45zsHDRZm94JKvuBNXeH3qslB9MDuK4UA5WTKh3iWooSYD4O8lrjYKuS8Lffvd1WSJymxmaCtUlTwoPYfSIjZGdcoOkNfeeHKK/lYj0k4M7mbgkeIgUdccPvYECTLmCsAnurbKqlpA7ZG1iX6xsmANS1jbLbwCQa0VERBFZkz/54oV62d6UoeAC019KykKVSWW9JA2rn0669MrLKYanGE+HBEoYDK7sB45lI0HC0zAOgfbCX4dBIyrUfsybHk9BB8up6Ud9sj1biiytx4XJuxKTBBnKzgvU6yT6E1mPedXHZ1ZDnseINDz6rh43l7GIvAyQDmHp9E573LYubmz4qudXjm5kKJ+R3PtyDzfgUClGOfbRoPqTVVveuj6t9ogR9XAi3 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ycrbg5TBAvEfMuEhVNBLzZMv2TJ3ArZevCy0gHYO8rYoV0cNTI3RZHlazg1U4pPv1HRb6fp2SKANzOw2FHYKQRgOClw22QDSlxZGj+D+M1AcndcC6dvqnQ/AU0Bcw4MYVD1i5av8FJAwaS3Txo7WyTrrQoFH9pMRGUU+Obrvrw3cA/FB3IKgK1OWrYsyTIB2s3oXa+gKc8x/L87p92g3hnnh7dwGVkt4ldE+pqeIjvbubxfKRqUPY++oRSyiHN5J6KFFECXN97Q1ty090zLK8jtgCkzLx2tkCma2MA9s2nSwlXenT/Hz36FhjWjiMYjMB+JvWjx46zfArAKINuH85zbYrj9nA90xOb8ki6zt88g7lxg5q5lR344Eik7x2n4ctCdP6WzYqfAuSNGWf3bT5eiOalA/P2SRy3a99lOrwixtHp9BgD/8X2C2tPXLLllGxl+5iRTPM7IYqXT55oq8lCOO8uduNBsMcCXD/xp+vbzCX17uPiK4jyMJWUY7y6lw7z6skHBwpwXo1XNb18KEVgaPtpJgmpEUkllcezuCUoumSW4/pAHAWGEGxBwUroAwyY3r8iPjVUp+8engQYOrGb8TjFT0/IQkWzTw/XESLZYPOMtNl8AbbwwQJFebUlvxUOnrrH/NyT+j3onnMQXSMx47JeV9nVKcDI8FEQpZSetJOujzpLLfejFu0GxZp6GPrFvwZQ/1fTEiJUVqwckCe94XcSNor2F36s6l1SP40T7segTtmQsL9wkCdrwLaKW9UqIQMFqDFeAZ6y3eEQhlBd8+AdrqmW2UwAT+qeWm3Rk5a577r/roeWto+SatQ/yI5Iliu5xo2Q/HsQJ+8kSTFvp1SloXFCBLwyW907UI2YmTjFVco/W+zQEki80BsxAL3TAicHYtcmMSZZW/Z1LazUymCAYDraHiLz+4iZmkSXQ6sqZ2djYZzM2pY+4IemLThsxcv0J15K+IfSL/p9VM8Q== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 483656fe-6516-4edb-c424-08d9e583def9 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2022 13:07:59.6053 (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: AM9PR03MB6948 Subject: [FFmpeg-devel] [PATCH v2 31/69] avcodec/mpegvideo: Move me_pre and me_penalty_compensation to enc-ctx 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: mjGLsaQGWMI8 Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo.h | 2 -- libavcodec/mpegvideo_enc.c | 8 ++++---- libavcodec/mpegvideoenc.h | 7 +++++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 4811fc0ad6..c59d4848a8 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -236,8 +236,6 @@ typedef struct MPVContext { uint8_t (*p_field_select_table[2]); ///< Only the first element is allocated uint8_t (*b_field_select_table[2][2]); ///< Only the first element is allocated int motion_est; ///< ME algorithm - int me_penalty_compensation; - int me_pre; ///< prepass for motion estimation int mv_dir; #define MV_DIR_FORWARD 1 #define MV_DIR_BACKWARD 2 diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 37eeb68f15..b67f706504 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -3563,11 +3563,11 @@ static int encode_picture(MPVMainEncContext *m, int picture_number) /* Estimate motion for every MB */ if(s->pict_type != AV_PICTURE_TYPE_I){ - s->lambda = (s->lambda * s->me_penalty_compensation + 128) >> 8; - s->lambda2 = (s->lambda2 * (int64_t) s->me_penalty_compensation + 128) >> 8; + s->lambda = (s->lambda * m->me_penalty_compensation + 128) >> 8; + s->lambda2 = (s->lambda2 * (int64_t) m->me_penalty_compensation + 128) >> 8; if (s->pict_type != AV_PICTURE_TYPE_B) { - if ((s->me_pre && s->last_non_b_pict_type == AV_PICTURE_TYPE_I) || - s->me_pre == 2) { + if ((m->me_pre && s->last_non_b_pict_type == AV_PICTURE_TYPE_I) || + m->me_pre == 2) { s->avctx->execute(s->avctx, pre_estimate_motion_thread, &s->thread_context[0], NULL, context_count, sizeof(void*)); } } diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index b03b785769..06e14ad11f 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -39,6 +39,9 @@ typedef MPVContext MPVEncContext; typedef struct MPVMainEncContext { MPVMainContext common; + int me_penalty_compensation; + int me_pre; ///< prepass for motion estimation + /* bit rate control */ int64_t total_bits; int frame_bits; ///< bits used for the current frame @@ -125,8 +128,8 @@ FF_MPV_OPT_CMP_FUNC, \ {"sc_threshold", "Scene change threshold", FF_MPV_OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ {"noise_reduction", "Noise reduction", FF_MPV_OFFSET(noise_reduction), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ {"ps", "RTP payload size in bytes", FF_MPV_OFFSET(rtp_payload_size), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"mepc", "Motion estimation bitrate penalty compensation (1.0 = 256)", FF_MPV_OFFSET(me_penalty_compensation), AV_OPT_TYPE_INT, {.i64 = 256 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"mepre", "pre motion estimation", FF_MPV_OFFSET(me_pre), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ +{"mepc", "Motion estimation bitrate penalty compensation (1.0 = 256)", FF_MPV_MAIN_OFFSET(me_penalty_compensation), AV_OPT_TYPE_INT, {.i64 = 256 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ +{"mepre", "pre motion estimation", FF_MPV_MAIN_OFFSET(me_pre), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ {"intra_penalty", "Penalty for intra blocks in block decision", FF_MPV_OFFSET(intra_penalty), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX/2, FF_MPV_OPT_FLAGS }, \ #define FF_MPV_COMMON_BFRAME_OPTS \