From patchwork Tue Feb 1 12:47:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33974 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp586457iov; Tue, 1 Feb 2022 04:49:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJzF1tb1vm17oJgeuoFf92vQHjcRbr9Rtp3Ze+SrlLuzIKKLwQs+jGsmOJwGo2lyfq3qBy7t X-Received: by 2002:a05:6402:254a:: with SMTP id l10mr24927382edb.230.1643719745232; Tue, 01 Feb 2022 04:49: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 30si8315249ejq.841.2022.02.01.04.49.03; Tue, 01 Feb 2022 04:49: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="TDh/qNcf"; 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 3A91F68B275; Tue, 1 Feb 2022 14:49:00 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-oln040092067066.outbound.protection.outlook.com [40.92.67.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F3E2368B0A4 for ; Tue, 1 Feb 2022 14:48:52 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RHZzCz0zf9o60eNHmPx3zgqcJi7p5s1coBrlgiZfD9TxEiv9Cg7SYzBN3kTdUog99/nuBu8Mm8LAzQuGtCbrx/idqKmcPKIzbyISO0e4am7fmwmlSExKA8JX76ivCdUZxz7ygMdaN/kblLjdD96CVGfV8LwLJLywGb7Kb2+LCDCENODr+2W3O/aOppMDorcMX/oDVVwHuxF1om147sQicoljxMveZ7cZwjBG154C7BBeTGYpuCvSCWSjpAw5OWxWdk8R0dJuqCmgpHg57p9fSWDhgPWlzXvR0st7lTZjdGg/E4SGzfwraVBsnbL9mF7y/MLuobOaj/VH1GI2aHXTcA== 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=6KPC/r1Ul6GViifhG5bKe7ZiHwxAeCn9i54QmoAtOZg=; b=aAJgVLIhitxrY94ck0KlPMOv7fEsgFnnuEePf/dZnu1RRfaq0IO2ChdNY3r1nseIYphlYjx198cDxoGjWT5pasSTedM27qnfUMA+niKXgAkWN50QEpNv7CBV9czX7ntuiiDblNi3HLDY+ggHak8+lFy1TzLh9uqf7mjbS4vWQIvpS2mV1erFsBbREEUVoTS+qywPDaLGuW/wVM3puuALohxsdJeEwsyOe4yxxIHvtg4r5S1ckr5FzCZMt7go4JdDRhBrX5R6NozLu+SWU31PgqEpp18RZGFTTnx+yIcKkMaY4HVGYin/UzvD7h/mwJzfcm+jUiG8wKU2x9+ON5Zxow== 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=6KPC/r1Ul6GViifhG5bKe7ZiHwxAeCn9i54QmoAtOZg=; b=TDh/qNcf3Qn1rWgZnZbAZrJWwhKe/ai+D+PIIdLt2Z2Kaal9ak8vjfroIrwWK14o2XAa+cy8pAEKvqQp4PT4+E7Gv04diW7Zn+zfmkEwuZR8kdwHqcJeDoT9x1QgHs7y5UGs0dnZfuh/NGsZo4PmLoiUmKx0aeUiBrfJH8mQXjE3OepVYAMt6CtGMmESMTybjE7gRYBu2CT4bstzDJc44VsSIcbmGxnkIm3RPFfwWR0H3D8inUB1jIY6kCvIpMM7qs1WN1moeVt38XsOMu1buWOhfb7bx20MWaZatuy70dmCmTO6XWB1bx77mdnlh0SKTaSKpLLnGi5jFEnn9uKBmg== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by HE1PR0301MB2252.eurprd03.prod.outlook.com (2603:10a6:3:22::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.21; Tue, 1 Feb 2022 12:48:51 +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 12:48:51 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 13:47:33 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 X-TMN: [ZubWA0B1lYLBXTnDYnNGFpOsuiZBamV/] X-ClientProxiedBy: AS9PR06CA0210.eurprd06.prod.outlook.com (2603:10a6:20b:45d::28) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220201124841.1418979-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4f39e474-f35f-43ae-d893-08d9e581326d X-MS-TrafficTypeDiagnostic: HE1PR0301MB2252:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gkxhAHf9p5IKMAlRFoyeY8gp1a8W6SNW//xaaRXkeUYDQe3gTudI8aZ6g9Xmj6DVM6YdEtZnc1/OG9RsDj2fBNgqTLdMKmSjZcwP/B66t1uDn06x001FVZBcnqcsgVbHfFV6IGABPMcqe0aziKneBLX0hWg0Xx8hvSWzCzLx4iZRvioSMFTz/LD2WH/j6+bnPLUR6l+bg/QoyEASzbmt0munBLlwhq6Ghi+g7es3PRuqBDzK4+8erMLqW73HIZoznUc/2LEc6HFAxnhkTlSyABtGuzsYTyFXeR/IsVJ7EoTup7ACx4gZlCWbIUEw6uK4yGks7k3gLMb3l58B/vCnTU73j0WdJwSIYFxAXVMqftdiFdWLxaiN1yMSZOLocpaYkHw1gXONIfab9fszEdPC9YyzIYlImyM4SRzw+sUcNncQ8vYtwiKy8oFrqxw6/PRm5MW3bqQ+MdICygHzDh34hZ4XkmSr9/juioRf+eKJquDQous580x3OiCpXvJjUvAdgIN+EKA+lPwQcyW13KuucjcPKRqsop9JkFNQPGmfJU2RwxenBiKgDhw8DfpXQkpb X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: P+z5WQlNrOzqdcrV0BTr/YTs4z1TJfc5NfEfHtwtKM+wGYirMx6NWHRItcN/9w3qlp1Onnabsewpr/EhvyzHEjyJifsgq62T+09+EXMzw/Td+0WPB/cAWRdhNnPnk1S5OCV0gXv1Lg2a1tPjWhjTORVveB6LTBOmtWo1tRkHKqWNXti7fdZtZy/NH+Zhd7MUKxugF8XqXJW5ER+Xg9LsuUq3w+z+M92s4aCsXXe6bA3osQNdP9Odu76zd8k5LH4kXY9UY6bgub4oz4kzzunFXUQ0txWIG00anXpIdUPCsEl2TrwtCuWvvUi1nP4N0BXRKQHQ8BjvwrgjDGwV86oXEXyMmvgCp/lIwIAx6SFtvDsbbQDQoeLJoCBOFTEq4TzcaBJDAbnituzZeGHcnMvNLmLGycv/fVjoC29QrJ/2goKRX0z510pCaKYgm/7T7lsHIbP7ICIvwGQF15+7lc7ozPMr0WzIuGbbTFynoSLkFHPQL1RKbCsqSkOI5uDoVz1VLOtwRZH/ve3irrnp4AQhrCOvchKO9bQ6+MwBC2Rp9yIKOvfyUgRXSgXSUucQE98Hzwksy2ykradjXS/gwtJ+NJsBb9FBfrS7f/rHSMejnz6F97CUcCsEiZAUM0AtYlqmAmTTBJZnVYpiJKoGgP8LJEDkws2nBiPT9XLPt+/triI7jsGDNhzEXUN53fCRjLubdl1g5Jw/ebAk0/IP28NU7d7NAL5/8pLkSpLyGFJSSqdtXwn3DpkCiZjlH9W/bCYhOX4HaxyArHf7a2Akd6BH8+U2xn4t5Xiuq7CEz86qfRkwoW03xr5C3OOsbnydkcQdmbPALp6leS+6iASGVD/6JbJ2lH9iLCz5+2xCQ5eiAhMY0uAsWXm6fIRLWWQaGBOj4ZicIDGPD8/G5gwSh22FX7899d5X4Er/Qvvre4ig6HASmmrSUJrDpFjRBHibNQ2kfV/xtMYIY3msSY3go059MA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4f39e474-f35f-43ae-d893-08d9e581326d X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2022 12:48:51.0955 (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: HE1PR0301MB2252 Subject: [FFmpeg-devel] [PATCH v2 01/69] avcodec/avcodec: Avoid MpegEncContext in AVHWAccel.decode_mb 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: abCB28iK+2vY Use an opaque pointer to void instead. Signed-off-by: Andreas Rheinhardt --- libavcodec/avcodec.h | 6 +----- libavcodec/mpegvideo_xvmc.c | 3 ++- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index ec1a0566a4..918753fd0e 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2026,8 +2026,6 @@ typedef struct AVCodecContext { int (*get_encode_buffer)(struct AVCodecContext *s, AVPacket *pkt, int flags); } AVCodecContext; -struct MpegEncContext; - /** * @defgroup lavc_hwaccel AVHWAccel * @@ -2154,10 +2152,8 @@ typedef struct AVHWAccel { * XvMC uses it to replace the ff_mpv_reconstruct_mb(). * Instead of decoding to raw picture, MB parameters are * stored in an array provided by the video driver. - * - * @param s the mpeg context */ - void (*decode_mb)(struct MpegEncContext *s); + void (*decode_mb)(void *opaque); /** * Initialize the hwaccel private data. diff --git a/libavcodec/mpegvideo_xvmc.c b/libavcodec/mpegvideo_xvmc.c index f06583768c..bfeb453834 100644 --- a/libavcodec/mpegvideo_xvmc.c +++ b/libavcodec/mpegvideo_xvmc.c @@ -168,8 +168,9 @@ static int ff_xvmc_field_end(AVCodecContext *avctx) * Synthesize the data needed by XvMC to render one macroblock of data. * Fill all relevant fields, if necessary do IDCT. */ -static void ff_xvmc_decode_mb(struct MpegEncContext *s) +static void ff_xvmc_decode_mb(void *opaque) { + MpegEncContext *const s = opaque; XvMCMacroBlock *mv_block; struct xvmc_pix_fmt *render; int i, cbp, blocks_per_mb; From patchwork Tue Feb 1 13:05:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33976 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp600153iov; Tue, 1 Feb 2022 05:07:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUW8eRJaASyPYdcPrBY17kOATDVg7Lavrm4ZA5LiibjgNXhHUGEhP7Z3kbtwdBU12sOXgl X-Received: by 2002:a50:bf4f:: with SMTP id g15mr25532450edk.362.1643720845619; Tue, 01 Feb 2022 05:07:25 -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 k27si9459581edk.389.2022.02.01.05.07.25; Tue, 01 Feb 2022 05:07:25 -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="Yy05nlI/"; 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 A8A4768B297; Tue, 1 Feb 2022 15:07:21 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2062.outbound.protection.outlook.com [40.92.89.62]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9925168B06E for ; Tue, 1 Feb 2022 15:07:15 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xlf2103FbRqwiHiGGvDSI1fT7tCBSUmNSrXmx9lS8ycz8mFbIKK86/pFhF1dw+QW3JCDk063RioCrby26yNO9jAOBIos9yp7gEeQKfBauVgIKpztpBYoXYjT/IOs+MTyEFZic+BTZxMesqO8bJDTOSv1PZVHKMqF+XsHAQ6HuvX37/cppRdbJBSzii8ZZwdIZ9VjwGgM39e+Mk4qo9t7uyBZziP0tyYrfX3if2Bx2UVFS5Bi3CtoA9IBZt7E67nLjNKWvads2yEvlQb0ISd1/vtHzQ9fhFx6B6IwCQvReSyt98IW183IVipgR3avGHwWVDlioFIqAhbh9JP8+0SAPw== 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=oiHuhLnojEMWE8uij5W/D+xipkCqbNbr8/gjls1O1js=; b=aaWiGPxTAEWBrp7AXeUJM5/kKPHFRbW5m95gDiJuBBiGBd1NGfVymehceDJo5DMwSQ5HTcUDjv8TcyeTvFIBcmlJ/s58bzR0qqmenpsTPNo7swVrAWy98inYvg7uw9wDmcory7pcU0rnxooVLcIpzn0nBTZEMFPUHF0NdWRfhrENLltbvG6DNwxZkl4a/AXFVvt8lUt2YfH6ysOiqIPtIW+zbsoFy/7VBu9dho/AB136aHAt9IDr1WyCfWPkyR+HuF3hqbzK2KTXdZH++MYCUzQPn9X4N6j5brVRpNljjQHgxhDG/+lT7WDSf28YOdScArSyWU5I4Gne0wU0HsG3VQ== 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=oiHuhLnojEMWE8uij5W/D+xipkCqbNbr8/gjls1O1js=; b=Yy05nlI/lt5itAFiBvQp1ZehKqUc3VkioHARlLa/Wx9aU2vqkMulsLfpQpAepQOaBd1hr9BG4+nMtEsky6jT3NdEmwrL4i8isvzFh7y5h80bNSs7zoW2QS6dmDI9bRB/2KbGxyhDTaDsOUBWc87/+5xl5rKZWec03+ZXqz/xtJOteUOqDZlk5mrYXQBLDAWidIjTT01KGasklCL8qK96wDZc1pDs8qyR0+WL4ERkt0r9BPksKE20Q2Gwzl8n3oLcr7JrDlak43GXSiRi12SE54iIew87qeRbVEjaQGLfeSQ+lF93tDUh7ND+xszsOLMEcvckJRBLc6ClkRlus3f5lw== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by DB6PR03MB3046.eurprd03.prod.outlook.com (2603:10a6:6:34::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.21; Tue, 1 Feb 2022 13:07:13 +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:13 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:05:59 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [w1DyglD7AsIEQaMv9UBe9I0w6InkBVD0] 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-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 62ba908a-52cb-49cc-6863-08d9e583c395 X-MS-TrafficTypeDiagnostic: DB6PR03MB3046:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BcPCLZnXKmBxvTtIHAhs1HP6L26ygWuMYqzMKzZmc/Nm9oNQR4fS/ZMNY2oqKfnhwysZMoT1IHiq5tJ7l1nUe0xb+id9LbiltsuyxWBTSd9a4WB5HTaea2HjleJZzqyR0NWdf2Ahi1Matjdq2SvfLjZbj9otfeyhuvyCTr0+tN/2MYmJ3I3Rq7YpwtFzSLI7QdC17DBTxz7zyNrfTjRWhD8os43CvrrwvFfUrJzQfLLywVb2WK6/tII5UeZt5c19yQICBQg4hXgjCuhHJcXvLD5A2gc6ael0s6H5vesrJtyJ76ZQwROVVziHoOR0LTVUPzL4WnRZPjgux97n/UlZ23IjDF8iOy0/fIhrnks3LTAs9PKGxkNa4H3l2s+aVTh9N7i886WuDUGWUyjXUupuqlv2E6vI46TWh1M7WAHOtRUwDVkM8jorrUx0kztkT8FLVO3sZOB6KdDQt5H5W1nr5VvPPwRRJ/g844IqL6kGBz7mZUuyGnNWrqp5xUWe9+0spqhh4OiJM7sP84zKaXCF0VVuHnuu2JnsGNvq+/rcGf8XChp0Qo++hixBqOWvB8Zf X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FqRTG4w5GVNbsYCVVeDsyBWki1/q1TVwj5GZKg765p6e/bwBXPz6cjOpVThPTNeb41a2Bqkqo+B0Spe2ruxBAfrJ60+dhS+mAAeyzzTjGphl+T53RbvmPoW2XVZoxMxdbwzy23uGE2eBK9M5EMLykf2crGLqvpOFrdbZnT//EgWbEdrE/2uzP4zyIya9Qsc0imImLqPXok/A2hp11syyQRb1IzFKmeCJqyRFMvqApwDQYe5nqb0GG27TKVvNHvgJ+F85VllIX5stS32EOJfOJcSN9RJNBmA8mRIFMspgRZHlrXnlAljDLaLZikRiA1bUlmRxwCX33wyBmnpvfLRqX+dJdthrK8oxdwxzWBl1EVAqH0zqLE7JHI350un13r2G3kiXDP7hUPKs8DDzxEOxyBhlUS32SDPgND504Vwhr3Csj1m2wYVtsz8olc09cSCkzlo8cpAp8cPcVYaLztKMKfBYGnjJ03IvPDk8TUSmzbOiQAfzEZeO0rugBx6wEJw6bb6lzr17EP1Vwrkl35d80GU7UAy/SUujrumpjo1CHJgRZJ7yWEnvvwTnHEQgC9uMv6tt+4gvGkEpKtaYAgoWdgB27CCWjU7tmq8wsgR2p18pwvu9ArgZPyNICIQ0Ba53WmNSeTzkOCQfD2/0rd2rqKXQnUCqiqFqhpKRnuqSFjruFU+DEZhqhgT1JtOAEeMEcLkP7i1TiFByZn9nmUARK8FQofnIYjiShpETC8l94YKYXO60g8OJCEIDNsQLTcrLsI3EetYD4fMrmNnhNukK1hc8r+9EENhWSGcj9IELBeGxcLZ3Ypw7vavrQx+rhQR5l6c/OYlKaiFAP6689CAf9YjptnG7ZKELjD0ogduV5gspVmr+3iok1v7KifWeFlqqR6ziYAIQmGnQXN/VWnrLk+aYTwQvsqN3M491o+fR5Hwqwiy1VuTI0Lnk3INe2QdYorSenMitGJNxvSNGRu7vuw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 62ba908a-52cb-49cc-6863-08d9e583c395 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:13.5879 (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: DB6PR03MB3046 Subject: [FFmpeg-devel] [PATCH v2 02/69] avcodec/mpegvideo_enc: Allow slices only for slice-thread-able codecs 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: bMRgllUvqASy One can use slices without slice-threading. The results for mpegvideo-encoders are abysmal: AMV, SpeedHQ, H.263, RV10, RV20, MSMPEG4v2, MSMPEG4v3 and WMV1 produce broken files. WMV2 meanwhile expects the MpegEncContext given to ff_wmv2_encode_mb() to be at the beginning of a Wmv2Context (a structure that this encoder shares with the WMV2 decoder), yet this is only true for the main context and not for the slice contexts, leading to segfaults. SpeedHQ additionally triggers an av_assert2, because it is not byte-aligned at a position where it ought to be byte-aligned. Given that no codec not supporting slice threading works this commit disallows using slices unless the encoder supports slice threading. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo_enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 33f2937217..6df2a46eaa 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -599,7 +599,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) } if (avctx->slices > 1 && - (avctx->codec_id == AV_CODEC_ID_FLV1 || avctx->codec_id == AV_CODEC_ID_H261)) { + !(avctx->codec->capabilities & AV_CODEC_CAP_SLICE_THREADS)) { av_log(avctx, AV_LOG_ERROR, "Multiple slices are not supported by this codec\n"); return AVERROR(EINVAL); } From patchwork Tue Feb 1 13:06:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33977 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp600329iov; Tue, 1 Feb 2022 05:07:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJyIHy9VzvO73ACJmS0UFiQZzmnaUOSa67p+oAHjy0GwljS8uBObUlI3dbgXguKpiZccH3Jd X-Received: by 2002:a17:906:d551:: with SMTP id cr17mr20198622ejc.27.1643720856137; Tue, 01 Feb 2022 05:07:36 -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 z10si7947796edc.165.2022.02.01.05.07.35; Tue, 01 Feb 2022 05:07:36 -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=JwYDrhTi; 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 C22A168B2AA; Tue, 1 Feb 2022 15:07:27 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2063.outbound.protection.outlook.com [40.92.89.63]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7170568B275 for ; Tue, 1 Feb 2022 15:07:21 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N1amdK67W0GQGzJ9T8bUOrsAICAAPz+K+UqPZPZ/wpCP35cv+qQYpocTlE6GXcmOKMH37z6ImxN5mpYHWzs6AJAlSDykcQE4SvsAF3qp07bC49IHs7jN/+vtGn7BvlBBx6EgVkQDVr4bFaQUYev3WN2OGc9zchBKxvGwoUZOyZxFK5rz9GU+U0BKmHf2YRE8glpYVkVw4BKXeHBJZ5uxU4PeXz963AC73XF0/UgAybIcs5TmQjmv/ehFtaN8M9gcvyvbB/OiZvH8CYKHjxUzE8u7kw3eCoYeF0rdMfNCEAsZYq5C9gxtmUg4IwkFeaCa2lEf2XdQOkA109qnQVtZ/w== 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=0kx2hBfKC4Q0c0Te6zy2LeREuXtmgPHdd3HCNzjxdyg=; b=I+pn1ZmVNIoAxKhVItIAEWzNWwiy5MSNt7GcHrFUECkMHeEd2gt6toEpa70k4HN97gDA2LBm/dDbi6QBmtgqkkX2DuhkoTHnuVipL5eyglej6nSI28hLpry0Wraq+nivDku70LFIsxYQapVWqTG43GUhX97GkB9UljBkzJ/fqvRKgLwH6uEl6fBUd7h/+03OFM9sIu+WcB2N8wfdM4W091VDc+gtsTN8GTyu7gQIotD1cPNCG1VOAhxCvJIGBWRULGREaAQwlgiJl3r+WyKO40r4W24o6WzGSTU0DsLXaSzkTvhWf/s6t3/Sv1wdrH+qizGUilcgCmUCe7+WPvpWbg== 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=0kx2hBfKC4Q0c0Te6zy2LeREuXtmgPHdd3HCNzjxdyg=; b=JwYDrhTif0aRXi7n/daJvgrigIZguqJSQo3bMIKd5oFBy/S7Kf38f7logj37vZdsWClhZ+lSr1rmNP9TMSMnnliLeSM2atYvzll/gK7IMtmPy3WMP5kmhZsI5JTQrXerLGXbFPUdL7I407QSMJ4YyP7NB+72yxrWaN2pEEOKIcRRIQDbV/ytOLa4J77cl+VTgt3m09E6s700AkXM5Z1MVZbkvjvQjNqADYbMTpTwm6V+ULcnwflYiZLoSWPMd3QdnYDkiW/gWZ2ICOK/hGWwUgm5sZymZJXUclPLyAFQfcrkbmEhXQJ1U+/ZpNVHAbRJ+WLGWubTzCvLzjb90VbH+A== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by DB6PR03MB3046.eurprd03.prod.outlook.com (2603:10a6:6:34::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.21; Tue, 1 Feb 2022 13:07:20 +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:20 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:00 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [hk25B0IigmALHx8CFO2gnF1sqRe2l3LB] 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-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1dbe1bf2-b6a3-4d44-0a10-08d9e583c77d X-MS-TrafficTypeDiagnostic: DB6PR03MB3046:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: X2IBXab1PVkwNyD9khAA1FgFIvYgFuroT6fuDT6Q5U/QKYxj1Z7MwcIbMIACtOAibogTMppJ5herivwzEl+2btudpLGLkVQ6vH+E4qkgrIEMtrm3Vsn2lP6uBG4aZ+9rnesuVqNoDarniikPHV/D9twzw0Ll1g1MR93ITkOFvzuZp6N7Pb9ObG1MWprXFDcMFWBXYp17ypyvPWS7T51UBDojvOOSuPeefe6a/8d222pn29RZdmYPjRWCKvMsox6IeTR2uehFwgc0NTkfmtwxmiMHlg8tNnZkDoCthYABB8PYdh0xMrIk6sesLnHybObuODA97EZc8ZyWqmBtGXIvKREaMmGDys4e4RWGUbSOZIQwqM+/DJ4xTwkGhc+jPsh/PHRABupzR5woGwz2Ewx+J9WodsmzU+fm0uUfu4HLn8hNr4PrFbtbJDFoZ9YYfJ0eKEyvMpzoD0AAYCTzbk5IEJ8IE8AP5qb9VfSlFBxhuoHdhBV+WjKs+LsZz5R1j6x9U5H7VteBwdvoLBIlT99f1ygdEkuvvN9zX5w+Zj1YogJ5Iu9fCUD5YqxmhXgtWCzL X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Vt7pFmFE4i3umIbl/EbABO32u6O7BC65bL4bnScnieqdpi488/02yKbR7j03xEva9zNmUk5E/kQV4EQ0gaprnf/gdTFGGCaRiv7owbDW39NwUL10N37/KYFVUVPIFn68o9sqFmh8+HA4NcevjforuOepVY1x23uaqKhyq24Vc8cQ7T3Ik1bD0Q/FzJXcZ1EfbAK6q/yU7S4ZbuzGk0AOJ68Pqhy8Sws4lst5f1KY/JiDydPnOXgwxIwtvbW+q9HrhaMq2NjKzjYwLwu3ZoVVEqIG4brDlf+IEWK8syb62Ke849RKtcCOYKMqTCjasXWwE2CQMYknkzXiqbONOSW7w8gCv1sv+VJ1vEutN68USaYg9hjviWZxc2sUMxDC6FSEZVwk5AZFDc7flRVnAiKKAGBNVT+DCmY9sVYSDbtR5ZdnaDZ7WPsfcVHFmXaxIwr7gTZEFx+y68PjlNdW3T+z5MEWcxTmPw2ec7ZxRsQuatKmWN6TMNx4/RKGZKYmJpseuRXGmcB3oF/uC9DHqtRifbKU4ZqphvqmlH/Da38zod35jprDv28QUb8YnRfq3qQ1V0IZc2grPvkVtBErP/mJK3UoZGlWnE5mrM64w2rZ+rio21Q+q+wqZMi8VCG7m0BDOTPZhDx8/0srl2PjUeNusrWvrQE4pd5R0BrmFSnpirFftMDaeLWdcWAYOi4soShTHiy5Rrqz+wTT02LBv1YXbx7FifcLrbXierWJu9Uey4av8MbhCTNPGDJ4Xpupp+01csYFaM5PVQxF9wofRrHAUGvi154reSCB+vmm2dUOF+3XvbXoz3TtrJ7JrRh5tn8iErmMkwEzt8lX7Miyi5ibQnmpw+zZ9DI+/oC2FLS95GLVPXv7PDoLfMm9Sb9GzixOvV9s6GDZ+ugCs32+cL8jQ/yFRF5sz/m/yP4i8aThrrLgpvGC0Bl/VZiTQGGcLf2Z3bCpYt1tPWZpEaCJhRTrUw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1dbe1bf2-b6a3-4d44-0a10-08d9e583c77d 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:20.1836 (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: DB6PR03MB3046 Subject: [FFmpeg-devel] [PATCH v2 03/69] avcodec/mjpegenc, speedhqenc: Remove nonsense assert 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: z0LYAofPbmzO Our code for writing optimal huffman tables is incompatible with using multiple slices and hence commit 884506dfe2e29a5b2bd2905ca4f17e277e32acb1 that implemented this also added an assert that slice_context_count is always 1. Yet this was always wrong: a) The MJPEG-encoder has (and had) the AV_CODEC_CAP_SLICE_THREADS capability, so asserting that it always uses one slice context is incorrect. b) This commit did not add any proper checks that ensured that optimal huffman tables are never used together with multiple slices. This only happened with 03eb0515c12637dbd20c2e3ca8503d7b47cf583a. c) This assert is at the wrong place: ff_mjpeg_encode_init() is called before the actual slice_context_count is set. This is the reason why this assert was never triggered. Therefore this commit removes this assert. Also remove an assert from the SpeedHQ encoder sharing b) and c). Signed-off-by: Andreas Rheinhardt --- libavcodec/mjpegenc.c | 2 -- libavcodec/speedhqenc.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index d15b9ece50..022f171c9e 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -293,8 +293,6 @@ av_cold int ff_mjpeg_encode_init(MpegEncContext *s) s->mjpeg_ctx = m; - av_assert0(s->slice_context_count == 1); - if (s->codec_id == AV_CODEC_ID_AMV || (s->avctx->active_thread_type & FF_THREAD_SLICE)) m->huffman = HUFFMAN_TABLE_DEFAULT; diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c index 967774931c..6df0316611 100644 --- a/libavcodec/speedhqenc.c +++ b/libavcodec/speedhqenc.c @@ -87,8 +87,6 @@ av_cold int ff_speedhq_encode_init(MpegEncContext *s) { static AVOnce init_static_once = AV_ONCE_INIT; - av_assert0(s->slice_context_count == 1); - if (s->width > 65500 || s->height > 65500) { av_log(s, AV_LOG_ERROR, "SpeedHQ does not support resolutions above 65500x65500\n"); return AVERROR(EINVAL); From patchwork Tue Feb 1 13:06:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33978 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp600516iov; Tue, 1 Feb 2022 05:07:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQmnr0wNjLMNdR4HfFG2+VfnaAyxwwnBYPHMT4ZbZXcXp810PUreYytn4TPoLDjQy/lJRJ X-Received: by 2002:a17:907:3e8a:: with SMTP id hs10mr21113437ejc.767.1643720868432; Tue, 01 Feb 2022 05:07:48 -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 e14si8436405ejl.52.2022.02.01.05.07.47; Tue, 01 Feb 2022 05:07:48 -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="jyHkUh/e"; 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 D455E68B2B4; Tue, 1 Feb 2022 15:07:32 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2063.outbound.protection.outlook.com [40.92.89.63]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8B74768B2A0 for ; Tue, 1 Feb 2022 15:07:26 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kOLJzuUEPsp2bCbBVw5TkF4GN0HYWREOtpKF0UmvKLvjvz7PW86t2aMq2VYiX1sCtiFhK88umPmTgDeCTOXb4z8DHt/CrCjQxVCb96chKIa72gGJbVYnqJIKK2vvkbydO+I3CB7aaWuUoivwp5bPXUZZUOZWYf6M+IkWUj42Dwceuyxv3T1oO/aHf/CcxOF3PWaTCBopLRF2r14qWSynA7nZh52x5FMdKldZknVqS9zqiPQXjmxsmm2hpUN8MWC5xtVvsgKOGTGTMG/ooPTvewTiuJLxcb64mfypO7t55ayICF6gmAEzwBr/bsY/ph+RqMHnfnwn91Ss+nvVKazuoA== 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=AcNBbug0fMoALEg3Hu1S56ahHm3gqkJ2iyuuwT/YgUY=; b=oDpAW++vn/DgD4WaT766XM1A7m8S3qY0LlK/r1u/LBImoBbrm4aKjZFDncSSuWIxpo0cYtH6XIRydO6TCc/1Zuv0BXgLpwFTSCsn27BnbtQfZ6FQzOK2pjpxGfjRNV/NSuHLTxTtpP/Or8vyKb3OEkuRtMNXfUy902v6mhq63wS/4h9HPl0LY67VPpvGwWBi5HEDrbp5LQeIr6Xi5C90utsTHJ4afgVAUvcaKYoS3J9i9k7KNCnqBZVL12x2irNhcjx3eFTNQhfgvS9uuBBez9NPToaya+7QHo2BfIe0xfGrUvPaNvUX0w1xrOn0C/yIEIE1rnFaj7G3puL4OIAEnA== 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=AcNBbug0fMoALEg3Hu1S56ahHm3gqkJ2iyuuwT/YgUY=; b=jyHkUh/eaRP2jzqXPMFmvrpvbDjkF9nOtqbl/wVpAoJjFyOlMVpFI3Ty3bhd9c2A5CDJ4FhPejFF62Ggu+XkubusrHTYIHNA+f4ez841OryvYJNgehj2vi9wXYKlP4jicG24+pvnbu9/9v5HMtk+LwVjSxUcJs9inAcD2KZgeKSrp2tXvK/ujotJ5rYjpLtMyE2yGZij9QZmeXUfLWVNE1TQM7Um1+raVuZEBQuiqpfG/dOfgzCpJWd0AwSavCHsdSHFbuMGzlmivPN/4Li6Fhic+KenIFbsd93vDGNzs6BB66iTGrJT76C4A1WsZQtS3IhWreWDEsLPlW+UVr0unw== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by DB6PR03MB3046.eurprd03.prod.outlook.com (2603:10a6:6:34::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.21; Tue, 1 Feb 2022 13:07:21 +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:21 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:01 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [qORlHzFLYTWNZwuFcK0dZnpuZIwWT7/Y] 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-3-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c471242d-a683-4ac1-b7b5-08d9e583c861 X-MS-TrafficTypeDiagnostic: DB6PR03MB3046:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: p3nGduP1AxrQIJC4prnetZnHEKQ7lKwYaVcmIqLGqaovZbbhwmpNo2ZHqRbzM74bfbRsEDAPN02HVpOt83yxri740cIE1cv7yyXZbXZYZ/brxNlPuF5HpfE9VpJJsSrAjBDCP/tpk8Ps/HRJV5rw95YhSMZU0jErKdg8nBn3RGg4hx3LrKoM971B/m4q6fLm7w0U+JyH9/jaIhHoRRU6DRK11Z+JCqV63SnVMTOqf814wyC3f9SxqUzPEaOaLp1ugvgLEe/gtfffGrdcrfzSoK2m6OV7NdYuCPidjNgYYRYGbGl/Xcljdh/k9UXoRWtSMdY1gWFmE/beNavvRhzQVkftD44M696BTW9TmXblDbLCbxfX1mcz6SnoswCna4FLsWk/1G80pTTZoMbsFfElkuPWocmZdkw8LsIclcuGpc03Yitt4H3Wo2DNQqXlKLQ8t3sWxKgOp36HUD32qPF3JocbfO0tiivXsAE+jFtzACYEC5dhwI1qfLUtR+SV0VNDZ6CIm1uf0XlhT4WrDETMaUzoPkAveEnpeZIjRJ5QY+qNn9ipewxN0n9mJsbwNixP X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2ZWpb+w/CBJYz1Njzz6Yri/z6HHRGJ3FEY35Vl860Pyok4x1ELgZiM8AaAC/d9bNdMKat6iaNmnbo6spIGkF0WbW55kwTT/qYPCd67+6LEeBfxkImEXz6rAGwx3NLzPV0oIHE00i0aRWHHgjC+jQfrAw0m7RzPlSX3tBVZx3oiLg3ka46WFGZRVwnfr8krTgMxpHCiXA7WXMPUwPb7wFFO7Rh5QTpHwh35fsJe7WKCruopHLZMISrvTG3jTlAqL47ycROnAln1LnHnx9TYvadNh1Clyu/2udbq4SKhXNJ8HQsYHrXH0ig1nD5fCmaNE+JhxEV17dQ+F2+87B8eSxf3bEdpEjwhIhPypf93+5iGj2ZpgYVlYfgy9pqz8zMI7TejdPGLK3A2Nb9Ab047/Sp6mhjKQl/V6P8tw3a7XljwcOqS1QKZZ2mEW39Cd9QSRvKzbLelbTrgqVXIJK8tOw3XaNjVMK4TJVtaJmzfp7U157MWQIfkg9T+z/D2gmZ5JOzvo0ctBerLLd0mM27dAZpgC0WZC9Rj/+ng5ljML/8vPUWiuvDOWrC2Rm1LgKMuMmnJKTzWGzNyWJvE+qtZ0w+GgATtGjIyihS/Ng2SWdjergmkwxasDus7Ej9i5VG09THiP1A8GZzvcArK1SfLE76QQpTzy9+jxMytz/vN4Qv5zOyqq57kLMV7uwBssyHKvWPGuEDKxL3nHuppBAm6w8rOG87cImmWBNDOz6kN5Bd3ytLhMshUo86xbi0IXsDsJNWIREtHqXTkGfMqBVpubJ36afn0Ci3778U1pGosnBho0SDrXB4R4DrXVve86wIPY1AeDrAlX6uZD9vxrnIFuHHIVsFmgppyKkf/Uhgind+AjhFcyRqOIMGqA7GLuBvwDRL9owzMFkVX2JLbLqRieVQ5tl+cCgkjycUB8lIY0u7CAKmDg+TkGgldXrwLnmzoipSoSlOFU6D08S3WtqtigwEw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c471242d-a683-4ac1-b7b5-08d9e583c861 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:21.6378 (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: DB6PR03MB3046 Subject: [FFmpeg-devel] [PATCH v2 04/69] avcodec/mjpegenc: Fix files with slices > 1, but threads == 1 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: wT88k2w+cQsA In the aforementioned case mpegvideo_enc.c calls ff_mjpeg_encode_stuffing() at the end of every line which pads the output to byte-alignment and escapes it; yet it does not write the restart-markers (and also not the DRI marker when writing the header) and so the output files are broken. Fix this by writing these markers depending upon the number of slices and not the number of threads in use; this also makes the output of the encoder reproducible given a slice count and is therefore important if encoder tests that actually use -threads auto are added in the future. Signed-off-by: Andreas Rheinhardt --- libavcodec/ljpegenc.c | 2 +- libavcodec/mjpegenc.c | 12 ++++++++---- libavcodec/mjpegenc_common.c | 10 ++++++---- libavcodec/mjpegenc_common.h | 3 ++- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c index e15f448f90..7c53da7bc3 100644 --- a/libavcodec/ljpegenc.c +++ b/libavcodec/ljpegenc.c @@ -239,7 +239,7 @@ static int ljpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt, init_put_bits(&pb, pkt->data, pkt->size); ff_mjpeg_encode_picture_header(avctx, &pb, NULL, &s->scantable, - s->pred, s->matrix, s->matrix); + s->pred, s->matrix, s->matrix, 0); header_bits = put_bits_count(&pb); diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index 022f171c9e..6a47503ab4 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -78,7 +78,8 @@ static void mjpeg_encode_picture_header(MpegEncContext *s) { ff_mjpeg_encode_picture_header(s->avctx, &s->pb, s->mjpeg_ctx, &s->intra_scantable, 0, - s->intra_matrix, s->chroma_intra_matrix); + s->intra_matrix, s->chroma_intra_matrix, + s->slice_context_count > 1); s->esc_pos = put_bytes_count(&s->pb, 0); for (int i = 1; i < s->slice_context_count; i++) @@ -247,7 +248,7 @@ int ff_mjpeg_encode_stuffing(MpegEncContext *s) ff_mjpeg_escape_FF(pbc, s->esc_pos); - if ((s->avctx->active_thread_type & FF_THREAD_SLICE) && mb_y < s->mb_height - 1) + if (s->slice_context_count > 1 && mb_y < s->mb_height - 1) put_marker(pbc, RST0 + (mb_y&7)); s->esc_pos = put_bytes_count(pbc, 0); @@ -289,11 +290,14 @@ static int alloc_huffman(MpegEncContext *s) av_cold int ff_mjpeg_encode_init(MpegEncContext *s) { MJpegContext *const m = &((MJPEGEncContext*)s)->mjpeg; - int ret; + int ret, use_slices; s->mjpeg_ctx = m; + use_slices = s->avctx->slices > 0 ? s->avctx->slices > 1 : + (s->avctx->active_thread_type & FF_THREAD_SLICE) && + s->avctx->thread_count > 1; - if (s->codec_id == AV_CODEC_ID_AMV || (s->avctx->active_thread_type & FF_THREAD_SLICE)) + if (s->codec_id == AV_CODEC_ID_AMV || use_slices) m->huffman = HUFFMAN_TABLE_DEFAULT; if (s->mpv_flags & FF_MPV_FLAG_QP_RD) { diff --git a/libavcodec/mjpegenc_common.c b/libavcodec/mjpegenc_common.c index 995e2b7670..86b6568902 100644 --- a/libavcodec/mjpegenc_common.c +++ b/libavcodec/mjpegenc_common.c @@ -60,7 +60,7 @@ static void jpeg_table_header(AVCodecContext *avctx, PutBitContext *p, ScanTable *intra_scantable, uint16_t luma_intra_matrix[64], uint16_t chroma_intra_matrix[64], - int hsample[3]) + int hsample[3], int use_slices) { int i, j, size; uint8_t *ptr; @@ -91,7 +91,7 @@ static void jpeg_table_header(AVCodecContext *avctx, PutBitContext *p, } } - if(avctx->active_thread_type & FF_THREAD_SLICE){ + if (use_slices) { put_marker(p, DRI); put_bits(p, 16, 4); put_bits(p, 16, (avctx->width-1)/(8*hsample[0]) + 1); @@ -216,7 +216,8 @@ void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb, MJpegContext *m, ScanTable *intra_scantable, int pred, uint16_t luma_intra_matrix[64], - uint16_t chroma_intra_matrix[64]) + uint16_t chroma_intra_matrix[64], + int use_slices) { const int lossless = !m; int hsample[4], vsample[4]; @@ -236,7 +237,8 @@ void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb, jpeg_put_comments(avctx, pb); jpeg_table_header(avctx, pb, m, intra_scantable, - luma_intra_matrix, chroma_intra_matrix, hsample); + luma_intra_matrix, chroma_intra_matrix, hsample, + use_slices); switch (avctx->codec_id) { case AV_CODEC_ID_MJPEG: put_marker(pb, SOF0 ); break; diff --git a/libavcodec/mjpegenc_common.h b/libavcodec/mjpegenc_common.h index ac753bf153..ba7c4f93fa 100644 --- a/libavcodec/mjpegenc_common.h +++ b/libavcodec/mjpegenc_common.h @@ -33,7 +33,8 @@ void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb, struct MJpegContext *m, ScanTable *intra_scantable, int pred, uint16_t luma_intra_matrix[64], - uint16_t chroma_intra_matrix[64]); + uint16_t chroma_intra_matrix[64], + int use_slices); void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits); void ff_mjpeg_escape_FF(PutBitContext *pb, int start); void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code, From patchwork Tue Feb 1 13:06:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33980 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp600956iov; Tue, 1 Feb 2022 05:08:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJxmuyf9RevlIMyfFhviRxJ+4mO5lsOpPAaTZeKs9e6fkwLM0zDJXOT961yW/OC1PVNvRxBY X-Received: by 2002:a17:906:bcd2:: with SMTP id lw18mr17200911ejb.647.1643720896269; Tue, 01 Feb 2022 05:08:16 -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 b10si10867349edz.437.2022.02.01.05.08.15; Tue, 01 Feb 2022 05:08:16 -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=sA0LHXYd; 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 E064B68B2B9; Tue, 1 Feb 2022 15:07:38 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2063.outbound.protection.outlook.com [40.92.89.63]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A56BA68B2A8 for ; Tue, 1 Feb 2022 15:07:31 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FuqSZtcLW6m+GGKblptrN732ny4x75bliDxQq4qPYPujQLHp4U950uFI0MsRFTT33fLkexbfYvG6ICNAyowaIbOGNYKDkn9FxEmAsT3/VBtlqKwrr4XlsfbnJ99C+aG3fKh+0SGUzqtXd8UAkK036e9FLRwHaJ/zpzUskebeqTTTA//xs+1FMLiR004weRYZT0VZ2IjGo3CZ6dCVjWB2t5gxmIB+z6u4mNdJcW2Z9UrpBaPz+3wGfGr92xZQqi4oOaRU7LIJ+u3GlcQa11Zy8FFiUe8tK7LP8rviSfwfGQpVJuEoCebBsUeV13db4B1DIZ38KA0WyvEtNtYUnACGig== 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=tEoQhMsnfZm05PvmHwfwjTaIg9cpp/FywxhM7zdz2SU=; b=G7+/03KnMuft/v3dSxqQk82A9DF/vp2FG9t4oBWpeHS9kpHBHElfBzAPMZJfCT0MAIIznxW2XDJlOHnD7lHB6povTGeBKbcJPTCnH9XRkDC3EQz54ylBpMybK/jI/SXq4+6BpOkJrJQ+8OHZzOY8yJ4o6E82aRN0UPCX+yFCFRnc6QL6Bg6thRkJPnDSpxsyUkvUAZnn+7jgXi5Bqu3b/hsrsoS08WXXXVGaVtDi7UAsh/jLv/DmiQKscHV9wPYhfaPwKNaNNA/lyM48Cq0XqxLQnTBkuvUSLXsfF5h5tIl3Ps4Mn1jXFK5oJ4yVxfc/BaX9GMt6HmlRtEctU/e5Ag== 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=tEoQhMsnfZm05PvmHwfwjTaIg9cpp/FywxhM7zdz2SU=; b=sA0LHXYdYNDFEbGlelvE3bxUCEhjsU3FRsovegD0FIfmRTpf1grydEVjDzBx4Ch7FVTZtnIhhp2LZyx43iweJhVby5mn3pV+8iyOLwmGZM3hdXX8HQUYD7f7Xh6bm5kcnamA8RZcdaikt0a5JTpLZHq3yR1DMez5CSxZOMwsdLDCRyk5ddzeQK1TloodhGdCnc8gGKbDj2hUJu9uvEerIGGfMTADqPHunJwgOxEym3HZ7YppoQTjbDt8GHmXyR/Rq2pp/cNp5CQRgnVvs2coV4oDM+R8A9JI6IVcNdBMW1lRjdC2RyVJxNCJyAkIUfIFRDrjqNUpkqakhwY30TvYMQ== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by DB6PR03MB3046.eurprd03.prod.outlook.com (2603:10a6:6:34::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.21; Tue, 1 Feb 2022 13:07:24 +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:24 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:02 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [SOhSENleGAG1Y7v2LBG62xyjwZEgMM/H] 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-4-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1c1531bc-6c36-4cf4-9850-08d9e583c9f2 X-MS-TrafficTypeDiagnostic: DB6PR03MB3046:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NdxMhCPo/eaqHzPMMlYTWH9eMoEqkjuTYd/4sYnwBDT4HdXW4s+Yc2dvi4PpF5wGkQAVV5N/75LLkKwCYBG4zWVzU6c+hXho63bUWGJhC0veB2pY8g8bW2zXmv5b2O3OtwBrrA3w7KLrTCM8rbGWYTr79zVm9m9ieCniseo0FPk+516+8dmf48EeuwMrpovaGTiifxLNQyWpsi98GC5TWTsWpXC78cQEgItwm8YhY+Lj8K9igvz2TRMoh/jssiq6yHK8syYc//TKipxYmeOuSEjVZzcFRZ0SeyD9Pw/xcaGlr61WKq4XKnulvGKobb3MFgDHZCzNXB54tNMgEecGGF6KZT/xOTGuGJeqScsC7oTIPtOs5AyQ+btYLK9bziNqOp3QYvhfC47EYw8nVpMr8NsEVjevBgn550T7yqt9st//NUQnFOrcetwRy9NhJOpocMs+LjZh+Mk0dBmm4E5X57+nif91PtKh+WfHf24Q28GouBLRZlf3ioCPhVMg8nGYEIzSBKfwDYGq8mo1Cs8D1cZBp/Xyvu1qmJXZBWG33dUIf03AlXANfLubQcdMVxd9 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bD98T6bqUw5nwq999m1okwqi+PRxwfDgZZVHy53JnTF45JIrOFLH5aZd5WgHOdtd/YhK7ypq/6VhKPX8wpIqifsWGUZHFAvkow3xWnd/p14An35f2gXc/2vVQnrG17N1x3OcP7ojBQbLehVKfPkknrUS64JzRkv5rtDExdCZrglZQKPDwzPZzcjXPp+HPLoHzfApLPcJKbAh2C2maIH8wx5zXvGRnTzWwfv+vFV9W4aofi1f/b5QGSNei3/qO/Z+G3oNWdsEsSo5OgqLiRSVsUXCNuBshdzVkVHuREPyxyuRL37dlW4TnTZ7aTMmGmQ+OPQ/s4OOVfOneQJT1ZfdG7uOYzzuuecBgRmeZA/Hko/KI2wwTMHrGdrVp6tWfT0QWReARSFE27GxPT0aQaZjkBSECK4erGyEKqlc+qPj6+rxpHf+2fmA4wYEWNO644SzTcy4TxuhOVWJHfj5tlVesYOzQHsaXmFfXV6wG+kPEcB2+0pJuMTvPdQkyVdjaUu2z5cdMFNwEGQFZ8j71aoYoSKr3v5OAMcELASzqQfb2tkARNMuIvMtOauyqRoRvxgsVF8zHDp8jaaJlNAzCS78JzxtOtFZc8sr9yo77/A6qioL5HUkp039En+/1mTllCvAbv3CNx9pzzU0P4v7zSRm1XbBzwurbQLgo0pt2cW2huIKE8tQhlfoazCvmjgUVQIT9IxsN5YfeBP+sVmqj56a9GAiXpH5gFuRKFMOtVcIoOWUGnG9GCGh0e1Y/pXp1hPW9/ptyeZzijcwB4B9VZdCz8z4bN0f7mYKRpgVCTy6C2sdCOLvdynezUeGzopwxuyjKoZad4OKknAHuUd1bGaPeyVxAd/Ed7kzfUxk2HRoJwsMmlr+JtJSvfy/QQ7N66ezKVPFCAJDsnQEC17YEQVeuKjZhVcM/SMEqQnV3dwL0GgLYAxTnxdFQKNVSOXJGtp1Jf3G9VM3kBZKSk7q9YvMmg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1c1531bc-6c36-4cf4-9850-08d9e583c9f2 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:24.2481 (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: DB6PR03MB3046 Subject: [FFmpeg-devel] [PATCH v2 05/69] avcodec/mpegvideo: Enable private contexts 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: dokmOE2ygYs+ MpegEncContext is used by many different codecs and every one of these uses just a subset of its fields. If one tries to separate this and e.g. add a real MpegContext and extension structures (say MpegDecContext and MpegEncContext), one runs into two difficulties: a) Some code is shared between decoder and encoder of the same format and they therefore use the same contexts, either MpegEncContext itself or identical extensions thereof. The latter is the case for H.261 as well as WMV2. b) In case of slice threading, the generic code can only allocate and initialize the structure it knows about; right now this is an MpegEncContext. If the codec has an even more extensive structure, it is only available for the main thread's MpegEncContext. Fixing this would involve making ff_mpv_common_init() aware of the size the size of slice context to allocate and would be part of separating the main thread's context from the slice contexts in general. This commit only intends to tackle the first issue by adding a pointer to MpegEncContext that codecs can set to a common context so that the aforementioned codecs can use this context (together with the MpegEncContext) in their common code. This will allow to move fields only used by the main thread to more specialized contexts. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo.h | 3 +++ libavcodec/mpegvideo_dec.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 84d79d2e59..5e406b9a9c 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -84,6 +84,9 @@ typedef struct MpegEncContext { * offsets used in ASM. */ struct AVCodecContext *avctx; + /* The following pointer is intended for codecs sharing code + * between decoder and encoder and in need of a common context to do so. */ + void *private_ctx; /* the following parameters must be initialized before encoding */ int width, height;///< picture size. must be a multiple of 16 int gop_size; diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c index 1e238bd1e1..cc23e070ea 100644 --- a/libavcodec/mpegvideo_dec.c +++ b/libavcodec/mpegvideo_dec.c @@ -62,10 +62,12 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst, // FIXME can parameters change on I-frames? // in that case dst may need a reinit if (!s->context_initialized) { + void *private_ctx = s->private_ctx; int err; memcpy(s, s1, sizeof(*s)); s->avctx = dst; + s->private_ctx = private_ctx; s->bitstream_buffer = NULL; s->bitstream_buffer_size = s->allocated_bitstream_buffer_size = 0; @@ -76,6 +78,7 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst, if ((err = ff_mpv_common_init(s)) < 0) { memset(s, 0, sizeof(*s)); s->avctx = dst; + s->private_ctx = private_ctx; return err; } } From patchwork Tue Feb 1 13:06:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33981 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp601167iov; Tue, 1 Feb 2022 05:08:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJz/eyeadj4ijAUSyiI3Bsv1ExJ757mf1WRb9cF3me4k0TqXEudKcexVLWvjGNObP5/rdAf1 X-Received: by 2002:aa7:da44:: with SMTP id w4mr24949353eds.146.1643720909932; Tue, 01 Feb 2022 05:08:29 -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 dn8si9108402ejc.1000.2022.02.01.05.08.29; Tue, 01 Feb 2022 05:08:29 -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=dHrhQoWu; 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 BFFC068B2D1; Tue, 1 Feb 2022 15:07:39 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2063.outbound.protection.outlook.com [40.92.89.63]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D308068B2A8 for ; Tue, 1 Feb 2022 15:07:36 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iJPScLGoKzovGBRnYTTS3pckQwl59/rg/dNRLqB+gd8X1d8mClwPOI0FVpsX0WvwsFwxNcNxSMnWnwTzV0Ez7FKEn27feBcPP5IJ+8LVeeENe+ly8Ps5tATiAESNemM0Gp/T9gr1s8vmlcd8NCZNnaD1vQusyFrv3zR6n5fwgRqXrZoXD7c+JrOHMs8k+IEm6x/tDbQgqq4Y+PWnVy4DOfZ3cag8B75mNK474IJ1tMPBLKB4tzuC5/P/kkREgF8K4L/JHDV0ke7D7K+3UYpjQ2jZzVozhV2zq3q+dJHrzZWkiSqDRrunycjq+pFxns/KC7VLF9T5+hvXbBOOpC5w/w== 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=e5RcdzWXrLSzX913ql4rGxTnzdBVcWgeF8FZ5CLLymw=; b=S5t/LNUO4VY4lGpq0nqadClSrE+FVrHgESfjZubdaedFWlOW7xlVwidU/FiRALVunuPcChwup3r/Z1cxqT3ySULuBGR0AkGy7PQAPSH7oKJAcO7ec4csV2KJYOqsb/J7/yPf29crg5nc2PrUCkAs8cU6Tv0uXxc6gc6rwP7gIgRA9xKlEYQwuiKRB+n9a3YercAW4tLFVohVgldxxfaf56+wB+pQu4TKSzDib/yIR5kBRnuZSWwuKh7z2WHYV0ZppYDmVAGasojbp1J9x8Qg9bb5EIhEj4KiwNJFI9EbAOWe1iJ5FV10EUrh4AP6/5tnQAOyq3O8xAsdN7Y3CCU5sQ== 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=e5RcdzWXrLSzX913ql4rGxTnzdBVcWgeF8FZ5CLLymw=; b=dHrhQoWunLaKQDdGiaPWyYMD1FuMXcB0yH/J9I0CsksgTIwpzEw12K8e4EXgfW8uYhDLSZxWB1uq3nFhIdY1pNvyd/sFpUXC1VjnQtbEBZgoe4RR5OdVHUbkSBhWha4rmjphs8U/Y2lc82Siid0CryivYRUl2t2cByvpEuHQtosWO5d3z8tB6szKoj+w8rVCCLyyqa9i1rpZwYawGU0T6NaIq9q9fIhDcgxkfU1MkDvuGuZjTP7DC8heOXIN8A2eFhEUsBRL12GdbTeYBS7wn39A1smOMlLX1p9u5QjqUW5uE/VYyOJO2S/8h8nxeYs+bJgX7tTcaTE1VEPnoeypng== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by DB6PR03MB3046.eurprd03.prod.outlook.com (2603:10a6:6:34::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.21; Tue, 1 Feb 2022 13:07:26 +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:26 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:03 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [kPAXmCKsPxWt7ETUM+uPkE5sTJ4xiF0i] 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-5-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fcd1ca3e-a1ed-4714-975d-08d9e583cb1c X-MS-TrafficTypeDiagnostic: DB6PR03MB3046:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uVOtdER3uoGIs4a0SaBUBaJfoE3ZpogkZ4n8y430uVAaXuR1hlMagOWNIbou2TzN1quqFJQk76gPRX6jOXRFYnVhA0pCeSGkwbW4gEOb0a6QHrGmHB8SPZOTrx+i9QQYFWAGAedzXUcfJUgws6ghkoeoGHqep0HWeYnQr3aBf135LMl/rB+mAMjxEl9eL3EChSXgplpsWrtHWgtK4X7WLv8brRyzli1ai5Pw3bnwP1/YRa2Tcile8TeM2eRfUgiu1ZLUYIESeaNZwP18/+FTJKFGuClVt7ljTh3/TqC5YsDs22vuxP/notGMyI3gWpTT+ZanhEC2q5sN7N1cbPOHFfWdA09KdWgzttAzE2TKu1LgdPQIMdW7pOW5JJ0lQI2yRgwdUAUYWkfcQiD9QBcfSi09dHSvX7uaulCo2aGD4RUqkOoH09fc14jYJ7J2YaBik3ZeSB6a3c0Oi7x8FGxzxyNNKD9V+KQ/NTuO4LEWsKmZ+F+WdIG9cN7dwYMmWodw9i6xnw/CzXvfLjbQK3lbRThc7HjbaB0o6BqfdjHcYMusHsfNr6qOvrzjJ+U7qE8j X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vM9J6aHCulQ45/HT3QVDQiEXDL15QJaHrYS6iq5MThAm5nldhHv7yGhKr7rMZ9TgBOAX/LUXckm7VgJ1rftW2iDy/KaUBrmWC0QBejMd7r2GqaMhhMEprZNFkmF+f4iez2GW1gPwV+7iQ5O+apS4QGs8H9yCzBVCpEbm5K7KAMHycYANEGa6YgIW/UaHGEAIyMUVrWF6VaXeIbM9TQjvbOhq1Il/H34ZwnaXR6IBFrLy67Lj0wQ0jJ1A8DWtHzhRjj5BwX0O/ni5UFbGxTlC6CT7TkvtIDcP43vfrwklIN6c42RCRCp/p+8gPFWNL5DICZbmTWIIdAoYTFGBOK4WrO1lfX+kK3ZnJhwPXTB6ZvIRWgWgxCns3lk6DlHadpsDXR7Zw2xmCHXeSks8D34upv46oO7qU+oKKNfh+xd4ltVQtZWY6LLF61A+Vj7wLfMLQVI+lZUpt93E1bTidDfVbZ0xu+4YCwJaZ3M86rhWbVb9qbGUWPer807ZTaa3hQCJysEZJN8P1vH8uBENBHgDdkTz1xEvJPReOArtPH/MhHaqtzW5JyUZM01Fs8WMUuVCjB9Zueqs5aL/corthsZY3GkWOkP+FnIjnMpG9mqy0zPHtbuANvzM0SYtRLcnbb9mX3YEQkzlNS9d7K7PI7U01XcrlbcDe8GD27/I5cJgmBmnkq3a+k9FLl7wvpYT6qtkQF8BhY6KjtVw+R2qfv/JCyOYaRt7xbxM0i/5ivYlIyfpfyVTm9XXqAaprTEG0vUpRDQTgbmYih5VM42uGoV4j4vKU/KrS2RFjYS/DzsU6N9kMBLqT9QZaMF56kY2JWGFxFulCCT4BPCGvotk1+igyVWy61G7dTEOFmE/MD7vCnukipkqrmadCuceWtcbXXfGBV+8Gt7NX9NcGYw+3sO3eGkZdKm7X1GLn0Ieyiay3amDQZ5Dd0KcvEVWvk1G5AJHeUUXGL/eQcBT359OmRy4rA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: fcd1ca3e-a1ed-4714-975d-08d9e583cb1c 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:26.1854 (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: DB6PR03MB3046 Subject: [FFmpeg-devel] [PATCH v2 06/69] avcodec/h261: Separate decode and encode contexts 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: R5Yz1oc228Eu Signed-off-by: Andreas Rheinhardt --- libavcodec/h261.c | 2 +- libavcodec/h261.h | 8 ------ libavcodec/h261dec.c | 59 +++++++++++++++++++++++++++----------------- libavcodec/h261enc.c | 54 +++++++++++++++++++++++++--------------- 4 files changed, 72 insertions(+), 51 deletions(-) diff --git a/libavcodec/h261.c b/libavcodec/h261.c index 1290c040cd..7dfaee7dc4 100644 --- a/libavcodec/h261.c +++ b/libavcodec/h261.c @@ -60,7 +60,7 @@ static void h261_loop_filter(uint8_t *src, int stride) void ff_h261_loop_filter(MpegEncContext *s) { - H261Context *h = (H261Context *)s; + H261Context *const h = s->private_ctx; const int linesize = s->linesize; const int uvlinesize = s->uvlinesize; uint8_t *dest_y = s->dest[0]; diff --git a/libavcodec/h261.h b/libavcodec/h261.h index 25728a295d..ff1903e508 100644 --- a/libavcodec/h261.h +++ b/libavcodec/h261.h @@ -35,15 +35,7 @@ * H261Context */ typedef struct H261Context { - MpegEncContext s; - - int current_mba; - int mba_diff; int mtype; - int current_mv_x; - int current_mv_y; - int gob_number; - int gob_start_code_skipped; // 1 if gob start code is already read before gob header is read } H261Context; #define MB_TYPE_H261_FIL 0x800000 diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c index 2fd8d94df1..17f1067b15 100644 --- a/libavcodec/h261dec.c +++ b/libavcodec/h261dec.c @@ -47,6 +47,19 @@ static VLC h261_mtype_vlc; static VLC h261_mv_vlc; static VLC h261_cbp_vlc; +typedef struct H261DecContext { + MpegEncContext s; + + H261Context common; + + int current_mba; + int mba_diff; + int current_mv_x; + int current_mv_y; + int gob_number; + int gob_start_code_skipped; // 1 if gob start code is already read before gob header is read +} H261DecContext; + static av_cold void h261_decode_init_static(void) { INIT_VLC_STATIC(&h261_mba_vlc, H261_MBA_VLC_BITS, 35, @@ -67,9 +80,10 @@ static av_cold void h261_decode_init_static(void) static av_cold int h261_decode_init(AVCodecContext *avctx) { static AVOnce init_static_once = AV_ONCE_INIT; - H261Context *h = avctx->priv_data; + H261DecContext *const h = avctx->priv_data; MpegEncContext *const s = &h->s; + s->private_ctx = &h->common; // set defaults ff_mpv_decode_init(s, avctx); @@ -89,7 +103,7 @@ static av_cold int h261_decode_init(AVCodecContext *avctx) * Decode the group of blocks header or slice header. * @return <0 if an error occurred */ -static int h261_decode_gob_header(H261Context *h) +static int h261_decode_gob_header(H261DecContext *h) { unsigned int val; MpegEncContext *const s = &h->s; @@ -143,7 +157,7 @@ static int h261_decode_gob_header(H261Context *h) * Decode the group of blocks / video packet header. * @return <0 if no resync found */ -static int h261_resync(H261Context *h) +static int h261_resync(H261DecContext *h) { MpegEncContext *const s = &h->s; int left, ret; @@ -184,7 +198,7 @@ static int h261_resync(H261Context *h) * Decode skipped macroblocks. * @return 0 */ -static int h261_decode_mb_skipped(H261Context *h, int mba1, int mba2) +static int h261_decode_mb_skipped(H261DecContext *h, int mba1, int mba2) { MpegEncContext *const s = &h->s; int i; @@ -209,7 +223,7 @@ static int h261_decode_mb_skipped(H261Context *h, int mba1, int mba2) s->mv[0][0][0] = 0; s->mv[0][0][1] = 0; s->mb_skipped = 1; - h->mtype &= ~MB_TYPE_H261_FIL; + h->common.mtype &= ~MB_TYPE_H261_FIL; if (s->current_picture.motion_val[0]) { int b_stride = 2*s->mb_width + 1; @@ -254,7 +268,7 @@ static int decode_mv_component(GetBitContext *gb, int v) * Decode a macroblock. * @return <0 if an error occurred */ -static int h261_decode_block(H261Context *h, int16_t *block, int n, int coded) +static int h261_decode_block(H261DecContext *h, int16_t *block, int n, int coded) { MpegEncContext *const s = &h->s; int level, i, j, run; @@ -346,9 +360,10 @@ static int h261_decode_block(H261Context *h, int16_t *block, int n, int coded) return 0; } -static int h261_decode_mb(H261Context *h) +static int h261_decode_mb(H261DecContext *h) { MpegEncContext *const s = &h->s; + H261Context *const com = &h->common; int i, cbp, xy; cbp = 63; @@ -386,23 +401,23 @@ static int h261_decode_mb(H261Context *h) ff_update_block_index(s); // Read mtype - h->mtype = get_vlc2(&s->gb, h261_mtype_vlc.table, H261_MTYPE_VLC_BITS, 2); - if (h->mtype < 0) { + com->mtype = get_vlc2(&s->gb, h261_mtype_vlc.table, H261_MTYPE_VLC_BITS, 2); + if (com->mtype < 0) { av_log(s->avctx, AV_LOG_ERROR, "Invalid mtype index %d\n", - h->mtype); + com->mtype); return SLICE_ERROR; } - av_assert0(h->mtype < FF_ARRAY_ELEMS(ff_h261_mtype_map)); - h->mtype = ff_h261_mtype_map[h->mtype]; + av_assert0(com->mtype < FF_ARRAY_ELEMS(ff_h261_mtype_map)); + com->mtype = ff_h261_mtype_map[com->mtype]; // Read mquant - if (IS_QUANT(h->mtype)) + if (IS_QUANT(com->mtype)) ff_set_qscale(s, get_bits(&s->gb, 5)); - s->mb_intra = IS_INTRA4x4(h->mtype); + s->mb_intra = IS_INTRA4x4(com->mtype); // Read mv - if (IS_16X16(h->mtype)) { + if (IS_16X16(com->mtype)) { /* Motion vector data is included for all MC macroblocks. MVD is * obtained from the macroblock vector by subtracting the vector * of the preceding macroblock. For this calculation the vector @@ -425,7 +440,7 @@ static int h261_decode_mb(H261Context *h) } // Read cbp - if (HAS_CBP(h->mtype)) + if (HAS_CBP(com->mtype)) cbp = get_vlc2(&s->gb, h261_cbp_vlc.table, H261_CBP_VLC_BITS, 1) + 1; if (s->mb_intra) { @@ -449,7 +464,7 @@ static int h261_decode_mb(H261Context *h) intra: /* decode each block */ - if (s->mb_intra || HAS_CBP(h->mtype)) { + if (s->mb_intra || HAS_CBP(com->mtype)) { s->bdsp.clear_blocks(s->block[0]); for (i = 0; i < 6; i++) { if (h261_decode_block(h, s->block[i], i, cbp & 32) < 0) @@ -470,7 +485,7 @@ intra: * Decode the H.261 picture header. * @return <0 if no startcode found */ -static int h261_decode_picture_header(H261Context *h) +static int h261_decode_picture_header(H261DecContext *h) { MpegEncContext *const s = &h->s; int format, i; @@ -534,7 +549,7 @@ static int h261_decode_picture_header(H261Context *h) return 0; } -static int h261_decode_gob(H261Context *h) +static int h261_decode_gob(H261DecContext *h) { MpegEncContext *const s = &h->s; @@ -580,9 +595,9 @@ static int get_consumed_bytes(MpegEncContext *s, int buf_size) static int h261_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { + H261DecContext *const h = avctx->priv_data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; - H261Context *h = avctx->priv_data; MpegEncContext *s = &h->s; int ret; AVFrame *pict = data; @@ -657,7 +672,7 @@ retry: static av_cold int h261_decode_end(AVCodecContext *avctx) { - H261Context *h = avctx->priv_data; + H261DecContext *const h = avctx->priv_data; MpegEncContext *s = &h->s; ff_mpv_common_end(s); @@ -669,7 +684,7 @@ const AVCodec ff_h261_decoder = { .long_name = NULL_IF_CONFIG_SMALL("H.261"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_H261, - .priv_data_size = sizeof(H261Context), + .priv_data_size = sizeof(H261DecContext), .init = h261_decode_init, .close = h261_decode_end, .decode = h261_decode_frame, diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c index af65c1f3b1..13fe5bbfb2 100644 --- a/libavcodec/h261enc.c +++ b/libavcodec/h261enc.c @@ -37,6 +37,14 @@ static uint8_t uni_h261_rl_len [64*64*2*2]; #define UNI_ENC_INDEX(last,run,level) ((last)*128*64 + (run)*128 + (level)) +typedef struct H261EncContext { + MpegEncContext s; + + H261Context common; + + int gob_number; +} H261EncContext; + int ff_h261_get_picture_format(int width, int height) { // QCIF @@ -52,7 +60,7 @@ int ff_h261_get_picture_format(int width, int height) void ff_h261_encode_picture_header(MpegEncContext *s, int picture_number) { - H261Context *h = (H261Context *)s; + H261EncContext *const h = (H261EncContext *)s; int format, temp_ref; align_put_bits(&s->pb); @@ -90,7 +98,7 @@ void ff_h261_encode_picture_header(MpegEncContext *s, int picture_number) */ static void h261_encode_gob_header(MpegEncContext *s, int mb_line) { - H261Context *h = (H261Context *)s; + H261EncContext *const h = (H261EncContext *)s; if (ff_h261_get_picture_format(s->width, s->height) == 0) { h->gob_number += 2; // QCIF } else { @@ -132,7 +140,7 @@ void ff_h261_reorder_mb_index(MpegEncContext *s) } } -static void h261_encode_motion(H261Context *h, int val) +static void h261_encode_motion(H261EncContext *h, int val) { MpegEncContext *const s = &h->s; int sign, code; @@ -166,7 +174,7 @@ static inline int get_cbp(MpegEncContext *s, int16_t block[6][64]) * @param block the 8x8 block * @param n block index (0-3 are luma, 4-5 are chroma) */ -static void h261_encode_block(H261Context *h, int16_t *block, int n) +static void h261_encode_block(H261EncContext *h, int16_t *block, int n) { MpegEncContext *const s = &h->s; int level, run, i, j, last_index, last_non_zero, sign, slevel, code; @@ -237,12 +245,15 @@ static void h261_encode_block(H261Context *h, int16_t *block, int n) void ff_h261_encode_mb(MpegEncContext *s, int16_t block[6][64], int motion_x, int motion_y) { - H261Context *h = (H261Context *)s; + /* The following is only allowed because this encoder + * does not use slice threading. */ + H261EncContext *const h = (H261EncContext *)s; + H261Context *const com = &h->common; int mvd, mv_diff_x, mv_diff_y, i, cbp; cbp = 63; // avoid warning mvd = 0; - h->mtype = 0; + com->mtype = 0; if (!s->mb_intra) { /* compute cbp */ @@ -270,34 +281,34 @@ void ff_h261_encode_mb(MpegEncContext *s, int16_t block[6][64], /* calculate MTYPE */ if (!s->mb_intra) { - h->mtype++; + com->mtype++; if (mvd || s->loop_filter) - h->mtype += 3; + com->mtype += 3; if (s->loop_filter) - h->mtype += 3; + com->mtype += 3; if (cbp) - h->mtype++; - av_assert1(h->mtype > 1); + com->mtype++; + av_assert1(com->mtype > 1); } if (s->dquant && cbp) { - h->mtype++; + com->mtype++; } else s->qscale -= s->dquant; put_bits(&s->pb, - ff_h261_mtype_bits[h->mtype], - ff_h261_mtype_code[h->mtype]); + ff_h261_mtype_bits[com->mtype], + ff_h261_mtype_code[com->mtype]); - h->mtype = ff_h261_mtype_map[h->mtype]; + com->mtype = ff_h261_mtype_map[com->mtype]; - if (IS_QUANT(h->mtype)) { + if (IS_QUANT(com->mtype)) { ff_set_qscale(s, s->qscale + s->dquant); put_bits(&s->pb, 5, s->qscale); } - if (IS_16X16(h->mtype)) { + if (IS_16X16(com->mtype)) { mv_diff_x = (motion_x >> 1) - s->last_mv[0][0][0]; mv_diff_y = (motion_y >> 1) - s->last_mv[0][0][1]; s->last_mv[0][0][0] = (motion_x >> 1); @@ -306,7 +317,7 @@ void ff_h261_encode_mb(MpegEncContext *s, int16_t block[6][64], h261_encode_motion(h, mv_diff_y); } - if (HAS_CBP(h->mtype)) { + if (HAS_CBP(com->mtype)) { av_assert1(cbp > 0); put_bits(&s->pb, ff_h261_cbp_tab[cbp - 1][1], @@ -316,7 +327,7 @@ void ff_h261_encode_mb(MpegEncContext *s, int16_t block[6][64], /* encode each block */ h261_encode_block(h, block[i], i); - if (!IS_16X16(h->mtype)) { + if (!IS_16X16(com->mtype)) { s->last_mv[0][0][0] = 0; s->last_mv[0][0][1] = 0; } @@ -371,8 +382,11 @@ static av_cold void h261_encode_init_static(void) av_cold void ff_h261_encode_init(MpegEncContext *s) { + H261EncContext *const h = (H261EncContext*)s; static AVOnce init_static_once = AV_ONCE_INIT; + s->private_ctx = &h->common; + s->min_qcoeff = -127; s->max_qcoeff = 127; s->y_dc_scale_table = @@ -390,7 +404,7 @@ const AVCodec ff_h261_encoder = { .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_H261, .priv_class = &ff_mpv_enc_class, - .priv_data_size = sizeof(H261Context), + .priv_data_size = sizeof(H261EncContext), .init = ff_mpv_encode_init, .encode2 = ff_mpv_encode_picture, .close = ff_mpv_encode_end, From patchwork Tue Feb 1 13:06:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33982 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp601401iov; Tue, 1 Feb 2022 05:08:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJzpxsswNfD7W07aPx3SYUx0UML4fxJeSGcWQ3O7xHEBKyk1+n+0Xu8xGcEGsM+b5VIyMEEN X-Received: by 2002:a05:6402:520b:: with SMTP id s11mr25308757edd.365.1643720923635; Tue, 01 Feb 2022 05:08:43 -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 v2si1101047edc.280.2022.02.01.05.08.42; Tue, 01 Feb 2022 05:08:43 -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=JRG7w2e+; 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 8D87168B2DA; Tue, 1 Feb 2022 15:07:40 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2063.outbound.protection.outlook.com [40.92.89.63]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ED64068B2BB for ; Tue, 1 Feb 2022 15:07:36 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gbz6IzaOb+X4Yd9UwAmDZqRHAyvHyOAeFDacouHIKPH7vX6+kqBSz+3RBvxlPo35RRpcTTho7KXSo8EwY+sv2fgEeq40XWszunts7OkVrGLxNGgqEzpqAfsdW86IoKSfQiBJl+rz2VEam46QpQ7f5Tjc8WOjHTQNsPG4WGQeGFSVO1/GExI2M9e55mOlv+dttSHfQOyqEpMA9CNdze/uZL3EmQ6wpn61ReAwkOGNTDuiImxWuWDsiZI+IAVa467lTV42f6NhbyrNyolitdHRXY66/7waVjTK0laRef+teXwhMfWnZtylY6VQ18+7egJufY12jnbsfZslUZWG7ItiOw== 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=ef6sq/kMFI0NY+lRVqTS9aSe3yZPbeRYp3YLKw+LLvI=; b=YdTEIEzL8hH1NiGKLtg2ay+m35WMFrhwOsYpLeCjsEvmYMIa5IGG6/lnCNvbt7z12nC3ClieBhPYsvzugMjr8R4OeIlONxg4zsStotLbfewwIA9ylaMrTySdb30K+m2OHcUxCkaSwKH32Bc0WewKK0vkA5mL+enKhNqJ2r4lI3A35ARPrS+GiFvfyao7fzhBQ2e2M57+fzx9bBCWtDfkuLsG9I8JdvcPf9bpNePa9bxW6fMPnROhsju9X7TbAQzd2NzP9X/cEdgyyaCigcnfd6YrC3j24P3ARu4Yb7kE5QRZyrZAa5bms3x1Fe2UH+AP+CciOxtK0ajKEwJ0OA3r6Q== 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=ef6sq/kMFI0NY+lRVqTS9aSe3yZPbeRYp3YLKw+LLvI=; b=JRG7w2e+JaBEJ3pVaspxjxGV+MXkv7HBj8Zu+TY9QzR6xapDholcvfbZ0sOQ/OrHtNBsLRdzpFyRCyz0tckDPo8DJEycBt0VmSShvCQjEoMu3zSx/tj0mj2wh+yNJWd9CUv+ZWGCyVW89PCa15A7k0y3wDWpnUjqwea4E2iWN52OvNcTnA7mFOuR/HfHoeZ6RdK5/ipms9chSDV6MvUwHW9+rBZg61IX8/88q2A7S7sgxHFSiKZTVPu44ZBLuC9QZbJ9WO3ubbAvS8VYpTReGhL51rW0rMlknB7auu0R7Qfd+z1WqbYCYb75oyMSrUq0N8j56YsnIy7lZRFDib9/pQ== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by DB6PR03MB3046.eurprd03.prod.outlook.com (2603:10a6:6:34::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.21; Tue, 1 Feb 2022 13:07:27 +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:27 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:04 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [MecIm1QsBpRtFLM9HxcW30he4ng541wG] 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-6-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cebdbdd6-c411-4822-522c-08d9e583cc12 X-MS-TrafficTypeDiagnostic: DB6PR03MB3046:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: n5aK0I+aJ1J6qV/LhD465IEzAW9jLN7lda7/a9xgkTfHnbAgnrclssh9Fq0wATSuMQ2f+Y1KtfIWqFXexmmvxmmtvelUeE+S5b4gA/5aoBOd3Dj3XLw/68R9xbGHf3CaK3Y3OV1RCLXWichS4M8ko3vIgcRFz+onPEhW1yY1OwpYojuZmtScg3vqwofkDnQVwIT0uJz5CdpoNFSxWFTAxyEKUZBTsUWAygPNeL946+gYmcoxSIEps/jgcaZQ2Rwo6k+7Bs5aqQW8h2W8sgP2ibmb9P5J25Nz0ACmJnYRJznKI7y1bw5GqVplUdJkapS2tn2LtzlxhuQuAPmIOsyIpl0aVNdVx4Yex+jkOyg5pqIZ77KvkCkdJQSDnrVX5fU/Lw/p0loBF6LZ+I+MBEfcSJdVFU+HG6k6mWt1KLakxxfLNmguhDTN70vk3vCor8OvPszwUkzbmbHVxWws5zhWbbEaLZi76RDqQ72HYpk8zjf2efgogxTXR/UhTJn6QPUxFO074hlpngEnPnouNE7BDVhpHFbHEGakdgy49BbvcB1DMT3RxHY767mFqwKoAnBu X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cyFb1zqkTrVHbra3KXAN4mNG2UzYnOh1vq3ozBR7w4BSqvs408ZLmG/dR/ic/TogxqYAs34SGE/CVLbUMO9G17ZROIyblwSeqr0gLU4wbykfQoZe0KWSjexnDBN4RS1XBQBFXpdvK4XLZwAuoOHprJIvKhMqHimY7v6pPNuu66znHoV4Z+TkqPZUECrjChvhnFgTrozufUlvKy3KPBIo/s28jDIzM0NBwSDlfgQcjET/N3K5At7Z9C4HnwoFY7VlIV+o9De2TU80mPcPZIj4oGlaAoZFqqLF5P/Egk8JPo5INnGTDHYYA3dzIsOHnOlaRFZidqeYEaFjH5BZKdQSxC/peEJWjOj3k6a/v8p/AV4YnX2Hr532KKTUMbrUygm/C1Eo6wZryS77PuEITUsanalQ4YZE0iL6mNxGoWl+XtwL3t6Xl4skEPp2YSXvImct3WQ0rXpBmn5TiFbQrXS17YIhHtWMTeoYqMWmh5zzWWDufANmHRa+aZ9pjPGiCGfX9NoNF43F0sykSDbnivyQddCEFVCu1dN35/7jqamJQUZQ1CATj3ozDRXnKq/1iX2Ub1F50JrNvijU/PswGcB1PlHzz+d2tq91+LZsycxM8GNOSZTspzR3elWH+lBttMrHUjVh1wei9wPIMRlnwB1XzHl20Kd1LgI2/q95lxHvTVlB6WU+lW+k1tdHnQlvUOs6yj02ruhZ4mRKl3cH4ty6mUKzUd0tc1FMIbUCGRjmzRZFYeOsZMLsSdIDi9Y6U8pfjZM1yqvWf00SEXf7Th+YeeUOqrrRyCZmkoTpTEOMcdVITq5ZxBQ02OzQtm7JtTsEpEV6ieaUdFhM0pZgR8L3uakcFdKgpV9+n2mPZi8tl+s4HhZfpGJ+45Xrtz+9CwsHDbkvAA3Cl4P/LhAZMUaa/kGILQ6Bo1cRO9WVEAdVvEV03JMdfrVC+M6ryedqeoAWGUGzW5ZF/th7kDMRatQ82Q== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: cebdbdd6-c411-4822-522c-08d9e583cc12 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:27.7802 (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: DB6PR03MB3046 Subject: [FFmpeg-devel] [PATCH v2 07/69] avcodec/h261: Move encoder-only stuff to a new header 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: axgcrP8iS/mN Signed-off-by: Andreas Rheinhardt --- libavcodec/h261.h | 7 ------- libavcodec/h261enc.c | 1 + libavcodec/h261enc.h | 40 ++++++++++++++++++++++++++++++++++++++ libavcodec/mpegvideo_enc.c | 2 +- 4 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 libavcodec/h261enc.h diff --git a/libavcodec/h261.h b/libavcodec/h261.h index ff1903e508..67c362be93 100644 --- a/libavcodec/h261.h +++ b/libavcodec/h261.h @@ -51,11 +51,4 @@ extern RLTable ff_h261_rl_tcoeff; void ff_h261_loop_filter(MpegEncContext *s); -int ff_h261_get_picture_format(int width, int height); -void ff_h261_reorder_mb_index(MpegEncContext *s); -void ff_h261_encode_mb(MpegEncContext *s, int16_t block[6][64], - int motion_x, int motion_y); -void ff_h261_encode_picture_header(MpegEncContext *s, int picture_number); -void ff_h261_encode_init(MpegEncContext *s); - #endif /* AVCODEC_H261_H */ diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c index 13fe5bbfb2..f1cd51ec2f 100644 --- a/libavcodec/h261enc.c +++ b/libavcodec/h261enc.c @@ -32,6 +32,7 @@ #include "mpegutils.h" #include "mpegvideo.h" #include "h261.h" +#include "h261enc.h" #include "mpegvideodata.h" static uint8_t uni_h261_rl_len [64*64*2*2]; diff --git a/libavcodec/h261enc.h b/libavcodec/h261enc.h new file mode 100644 index 0000000000..0a01858be5 --- /dev/null +++ b/libavcodec/h261enc.h @@ -0,0 +1,40 @@ +/* + * H.261 encoder + * Copyright (c) 2002-2004 Michael Niedermayer + * Copyright (c) 2004 Maarten Daniels + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * H.261 encoder header. + */ + +#ifndef AVCODEC_H261ENC_H +#define AVCODEC_H261ENC_H + +#include "mpegvideo.h" + +int ff_h261_get_picture_format(int width, int height); +void ff_h261_reorder_mb_index(MpegEncContext *s); +void ff_h261_encode_mb(MpegEncContext *s, int16_t block[6][64], + int motion_x, int motion_y); +void ff_h261_encode_picture_header(MpegEncContext *s, int picture_number); +void ff_h261_encode_init(MpegEncContext *s); + +#endif diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 6df2a46eaa..bb8d3bc908 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -48,7 +48,7 @@ #include "mpeg12data.h" #include "mpegvideo.h" #include "mpegvideodata.h" -#include "h261.h" +#include "h261enc.h" #include "h263.h" #include "h263data.h" #include "mjpegenc_common.h" From patchwork Tue Feb 1 13:06:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33983 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp601777iov; Tue, 1 Feb 2022 05:09:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJxocInJjBw9vtuYJj1T7ase8omHrOPwr418SgYt687WWfh8E5/YnxFOL4hDXPc5mC1Xe7e9 X-Received: by 2002:a17:907:1b15:: with SMTP id mp21mr20527007ejc.533.1643720942027; Tue, 01 Feb 2022 05:09:02 -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 y11si9309944edv.47.2022.02.01.05.08.55; Tue, 01 Feb 2022 05:09:02 -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=IInMN13f; 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 59C8568B28B; Tue, 1 Feb 2022 15:07:41 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2063.outbound.protection.outlook.com [40.92.89.63]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2674368B2BB for ; Tue, 1 Feb 2022 15:07:37 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fUgDDlOQ5HTm8ufzsJIrYNyBLYboZ14r89WEh8sWVaiz4pbb2ln9tNrjzQz6h2jId4rKwEq+3ONcuTeFuu4Vpms+OSdh0ctvdxLNIleyaSTpv/VzXJNxG3oMFoq6ktJRsPDJ92+uBY6MTx4e6SDZBst8i5RoKCYdkquNSvzF/iQyOoTGSCC9+SqpyMoy+fi8VCcsRqp2ptHlu9A89vbacFXzRKWuZxLnYWq7w8efbBuebZNC1jgBR1T6SIzIJ1iF5xLK3Hv6G7/iQMlpPZWigKWjKMHoEyp6aoD+ULotAadoN8XEGGyPSfOuYIj/upw57jK6tL4DnKKrYDOcvdR1tA== 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=M8oDHh6fGenfMRomU2811OFzSJT8e0150Ox1Z+djTeU=; b=AGWl7aDp5i2z4lEDGu+CjFqoln/Z8iRKIIkeLrLLj8ZrXEXyyR345+naRYYpqJxi0YnlIV1WE5pcHIEF+miHTSVYEW25lpn8TXq9h7m1pvXzaScvT4WZAhhIdYrAUAxYOa75n2Ff6+ebZ1s+u2nCSu6IUrC6p0fsSIg5Y+DQV8twPt6ADlO0GxQofR/vv+QbZZob/5OrHQ7ghbl6kS2/FCLVjWHO1GBqvoJgeNWVO/pUYK96Fzbv+F1xJK4tHHpycxM9YFtPezDV918UT4R247Lyug/jXKhixssBgA32byGJL8yjmGdp5MKxIZLmAuSbAF6PbMFZgm+wpDEDTZpbWg== 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=M8oDHh6fGenfMRomU2811OFzSJT8e0150Ox1Z+djTeU=; b=IInMN13f835eHKW+ovtgT7fPE/iA3wH44fz9LLwYLDDA+MdOoHSBrmOkRfJ87FzplZXOBXLPidHpwysJgiITVfyTP/M/oL+Paww8szR1lPxI7L+Ddi3F3XK8NPXTjmY1UrnylGsjKMr+TGdyoSR+nSeQbqZj8Z5G7IxGGOAvV6fD41KJ0z4PTsgRUKw7Of2MugmjOODVyKo9V7QWPQqXSYpyrPyLln/63OUwBXL+2iY7K9kz9Q2+yx1KvO4qMcaRFinvWX4SmJ4qEKlFyM02Vhexfl5XoIEK7XZRsdI4x1q80esg5NEKC97LJr/jDDoyQA3dveNTn7cCMcS2xEwVGA== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by DB6PR03MB3046.eurprd03.prod.outlook.com (2603:10a6:6:34::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.21; Tue, 1 Feb 2022 13:07:28 +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:28 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:05 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [/WmhsMhwaqzFr39QeeX2/Z4jD1t9Ohex] 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-7-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2d593c6c-419f-466e-0bad-08d9e583cc93 X-MS-TrafficTypeDiagnostic: DB6PR03MB3046:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: El0sbEz8OlM6qAbcLMN+nzBRJ1ydQqV7POPl2su90RdMD/Jrz0m1d69Sw0NwYJ7Rk1KxQIBTVSP1oPvt16qvsa3zHZajh0CfQW09YUoi9VcIiPQP5hdGFs7Dv39jjPZEsr7Z4mH4gezL/nrnXE9BGiJRW7RGuHNkQ3XM88GZMpmp4zQ5fO7wDrLGaD6auCbLafbUpWTFnlIb1AMA4oW1iIdPm7XZnfNwgPtRYn5WOf+r8GVwlyTVEfTYTMJFfs7Cd/JDwdKG8ywKSYPgn7j6Ag4vOxMzlb74xSOZIiulLt48dnkAOoW9mTa1hbYGpRYbX8MRf1tRbo9NQqMVtGRB977ezvU+6LBcfLkgjN3hdYKE1eL0ESA7FKGf5Rqhx8YFi+DSpHmoWVRYcR53NDP0wNY1vwvP5JNHM791vEJaTI1V5oxF7bFkzjNjC05Sb9Sr8GhSSQdSq57hS+RMkCjC93h6rqaF32SOlUsmNFQWOfAcuMoKr1N6QEHCKTcKe4v1oYk/ir4T2euGb6vKKRPZHNe7N0KxtQBbx3L7SzEhERY1OzL6D1kDyB5GoCodxAqF X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SIoO2lFyf99knaAruOv9DzQGeSbUj//bOyWs2Izurzb3klEG9OpNPOTJlTMdrujDW0YV5L39glOLe7CQPRvEwjFvR5+e2/iJY11ekYv9Oq/4XmBihhNidNNuDI020vDO/9wP36hc50GDN3SPkZu2X0omaMFmp3eStR0cPBj65W3eJRGX2mH1GUKHmlBh2RQLh2tNuqP2TYIAt2LFiw5o25LF8Za4MGHcVd0iKxeJmIS7GbX6rP1KY0tpru3YaOZrZ4ikm41C4s50oabwaIhLLL2t1mikrDWxM97HaJZ74AkuHcrNKytnMUBWwSlb38lxNsPjVk3frwoNBecF8pRdCuu74opu7KBVH640W57jgm9Uzz1Ubs+kNDgFw9DGLVcxzWdYfSphfCb6D0gA8jlahRJWApRTZ4cf7FnF3v/E9YILPbtzlOhgCvI7OxC1ZT5NpSm92h4JCSfsETd2+HcrFRNstfHmR2sDTgVW8CqhLZmspiRej2PIL2FUoCa8BTjXyq6PsRD23B5pvWwC6ppkPzCpZuEJEUYhKl4CKu5vAjN6jsVEjYxzz3tQj5+/IadVQD911GZG6s7eZr6/SFqM31uMhB/apK+vNnHAkL6Yk/CToqCY9BB8ILSHVFejOnU4WqQMsRxdeTvy+W7j1sywFQ3OKALhxkcWz2lPX3X8geAiLxlOSW0fLGGJxctO0G6A3xhU1AvOKnE6OFoDeAM+gqtcVQFFJStocZKX4rxG8pMnpWvcs9DkSOq9R+UB3BdCvpyu04q/7DVgApxh3DHgyFkqywvewOU6Ga2rrrCFYpVe3T4ukMZHVpSerTwuhxbjSOzcrN4gD8dz8Zaw/gWvGG1HaxO6DAp8z07CvHvRYhhJzb6l03oGlphl/pw+gCGGi/pCNHgDGzenWeJnonChqvI6WSD7RJSXvCxVhywdCAcc7lsL8UMCwzcEJfKueNkT/1khNBtBxsw8QonU7Qdt0A== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2d593c6c-419f-466e-0bad-08d9e583cc93 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:28.6394 (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: DB6PR03MB3046 Subject: [FFmpeg-devel] [PATCH v2 08/69] avcodec/h261enc: Pass PutBitContext directly in h261_encode_motion() 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: Tl8QqFMKKZLV Signed-off-by: Andreas Rheinhardt --- libavcodec/h261enc.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c index f1cd51ec2f..66b7cc18fd 100644 --- a/libavcodec/h261enc.c +++ b/libavcodec/h261enc.c @@ -141,13 +141,12 @@ void ff_h261_reorder_mb_index(MpegEncContext *s) } } -static void h261_encode_motion(H261EncContext *h, int val) +static void h261_encode_motion(PutBitContext *pb, int val) { - MpegEncContext *const s = &h->s; int sign, code; if (val == 0) { code = 0; - put_bits(&s->pb, ff_h261_mv_tab[code][1], ff_h261_mv_tab[code][0]); + put_bits(pb, ff_h261_mv_tab[code][1], ff_h261_mv_tab[code][0]); } else { if (val > 15) val -= 32; @@ -155,8 +154,8 @@ static void h261_encode_motion(H261EncContext *h, int val) val += 32; sign = val < 0; code = sign ? -val : val; - put_bits(&s->pb, ff_h261_mv_tab[code][1], ff_h261_mv_tab[code][0]); - put_bits(&s->pb, 1, sign); + put_bits(pb, ff_h261_mv_tab[code][1], ff_h261_mv_tab[code][0]); + put_bits(pb, 1, sign); } } @@ -314,8 +313,8 @@ void ff_h261_encode_mb(MpegEncContext *s, int16_t block[6][64], mv_diff_y = (motion_y >> 1) - s->last_mv[0][0][1]; s->last_mv[0][0][0] = (motion_x >> 1); s->last_mv[0][0][1] = (motion_y >> 1); - h261_encode_motion(h, mv_diff_x); - h261_encode_motion(h, mv_diff_y); + h261_encode_motion(&s->pb, mv_diff_x); + h261_encode_motion(&s->pb, mv_diff_y); } if (HAS_CBP(com->mtype)) { From patchwork Tue Feb 1 13:06:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33979 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp600704iov; Tue, 1 Feb 2022 05:08:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJwIu0e27OEDDzv9adX6XP6DioD444p5uTEgCCTXqvf1kjB6bx/158wpksmmNKQHPrbvBMZi X-Received: by 2002:a17:907:62a9:: with SMTP id nd41mr21028880ejc.50.1643720881632; Tue, 01 Feb 2022 05:08:01 -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 u5si1369408edx.350.2022.02.01.05.08.01; Tue, 01 Feb 2022 05:08:01 -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=g6hxNrax; 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 D0C5E68B2C7; Tue, 1 Feb 2022 15:07:37 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-oln040092071051.outbound.protection.outlook.com [40.92.71.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 45FE268B2A8 for ; Tue, 1 Feb 2022 15:07:31 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LDx/9fD9D7qgty2q63rFQnENe5yO5g4PjhDKKPtOI1ZmEsyq18DbLGxWLrOGeotHgm0iOEN6Z5Yy9qEurYth+X0tffrB7UGd02zms0l7DiY7a7W8Xug+hmUKXl8QCpVnfFpQkVtLigkF1jUfXkeRBKtMHv7BkowwrqQ1gQLQtePsxZqF5xlGVfFA0SAmxLe/1oROF7HBmlRZNQ6e3+31+v+LCWaMupxyReVkI0JTDq5sDtFKNYuDUmX2rBI3f9oHBt1/qUtnM2ss5sJd8H00I4M2fLzVizbvESt6SqQpvtpHMslcFabkPucbMdqx1KJKts06xG/k8M2/bvRofhDULw== 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=QDzJ2CAjddPdFf4qSKiPRWOuO3lgPg11FCh82Wxghfs=; b=T28YSKKnMGq3Y+WSqiTdmIQJ6h0Ybj5+rYQYxRvjPNVZ6CjnUptS7C84E+qPlfgNb7mm2h+m+joP5UPSCLQndRoeCufnqCtgf7QGf/eZDHBVH4+7TOcqxofnZBwnJe21CAdbw1RqvuTIUh5JU+/aDfQGcDjmnbAlo8vLCM6+r6D1z68qsHGbmauhCFSnz5cqYXByjWd2+MwS9UCGSPfiiZnBW8YwZ/cdEMAbYyplasauost0aN1UknovXaYid3+tCipNh5F2F9JJYkjy3jRqiwgJIjrB2VwB06va/AvPoqIHx26+AnKKcL/nB2L4PAtv7xQkA/Z+uWAJMO/W710j2g== 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=QDzJ2CAjddPdFf4qSKiPRWOuO3lgPg11FCh82Wxghfs=; b=g6hxNrax43rBaIzhXxrjhDH6gvGnZ24Hzd0+RCF+gIqlkFjLraux+2sKcUFfM9mJ7Z1Sbcur4LdtRf8ftE5HckxGpkBbxfJ7Y8yiUfPzFQV2e47fvGMdpkxkpGjrU3mp/NBE0sJgiZyf0o4VybQrifQPwCqDJ7W/xrLs5xbwYrhOTRjxrsHKAYV+jYYhYwwTYVV+Kxoadr1WgFt0dREE405H9vlx9Z/CAmkEuwmHMt8tiWvkFN6S7N0wC3YCGumvIgxrua0v8DToN6DyH50FErZcwfNRed+4RyUXeXuOpMHuO1J2TpJKMwhEtqw3VYb8XKO8mjJwlh7Syf3FcYAYjg== 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:30 +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:30 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:06 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [at47e9Cmc2hvbjn+fUPLbe1Uo6mLPhn+] 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-8-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 99a728c9-cd32-4cd5-c9e8-08d9e583cd6e X-MS-TrafficTypeDiagnostic: AM9PR03MB6948:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ulmYSeGOBQxAK4QNpoO1h5n37vQ8M7WgZfSdkUWcXE6UuAab+X2NqKMkWSCHQXjWlTJ0FH2n97HG912sB9ihfYEIQkv35xq/zsI639UqP27YajeIcP4OinaHiV7eKFiZEvnEbuvyviHNqjxbUFyxgReOr+KwRacE87f3l8RhxIoU/Rg5vvUo6mrGZY9m+B6WbbULZhBYPYpCHJ29IhxM3AsHTcA3fDp6jp29eMIQSyA7wtCWN5VMIIPoIu7X2zbIDyqlRBfg29AJdHukbul+M6obslbwqCaqTkLi0P79nx7S9PTg0sKJmJ9o/Eq9iI/DLMYZk0gCJb5eAa55cZzMrRoZkiAOu/USIDZzZfIR7m9sIR0LATmP3D5hLsSaFrRfY9IsMgiCx6/azRjDf7DKM420WL8gX4Up2IKOM2N08yrhPSc8fHZMUZ+09ukwxpfU9P+7GqlIygXe+HGlknjECWMenNl/kBimiEmw4Pxd+8Tu+4bnU8ExwW+iIZspcleSVT9tBfbWs7/QLw5Ml3hz6pny+WPYFQCBwnYoqJRfbrmSxy6A6KPIQSdYCyiK1sky X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XMpVbPx7YEMt0AtSDD8J7F+V+E2/Lx6H6hxluKeRjqcyj7lJZg8mcllCnjOiLTBGmXcn8CZn7Uzi6X+uhz7c2/GkAJO4RWVTQVhlaO0HO3CKzJC/4QHq61mdfXv93h+hJ4o8L+x3ishBJTk0pFRHecoAXOJQqY9hhoNa6zjGv1KDrwp+lWhz2cZnuTAkPsoXb8eqbDDBEc2XegFTvvNeMf2cMtyqq8i0l2eoJQBPivFZCKVpOOPBmzaJHah1NCbHzrcm09DqanjbzBMc4AeGBhlYLOAUBhXfexOIhCAdgSOH9Sa64QCUYBr3bwrdZHnTogTvUq9ttHmnvBZpLrBOU3yObJ6CgsHojEHwGK3K9Uxh7nECM8qOshyXe0k7TYlezuwoNj16vFlT1nVZWstA9IOLvnaagoUgLpiIqNHz/NHqaJQs33n8/qYrUl63RZQ9dAc2lTmKlMHqhJEqrZT/TTtp65fOVAO+1qv9XlXlHtV17zXS6McQTTfgRbDIKTT6XHB7z1gQpQExwddn1NLrlVrYhQLtjWNd72Vzz/9eKDx68rFoXfSuwkbe+iAwVuYKRI1DyaBYCs2gNypNrv1B/6RIpsExHjCpemtRwcvmMGUiIO+2KZ/xqiH94ZMaMGzzGTl8dImisc/HOftKgTa1nGLVKkYngNqdOHSI5oj4WRzHuVCBLNelOgszfO+ATLAxf6dtgFoNv4JrZswmYOudTdfG7pQQNiT9++hvtT1YUg2z1b86NwZO/KrLby+0GkI0oGhYJxxyh3O1rOtWwny8T2DpqYgDy+oyU9TR/YKgMupviPHTbPk44JAA9JcdUs4meUeGc3uzZpAY+IIVqAYgzVrwKrD3xsXEvUBLAR4RbEhB4HM4rUm3r3ZkKkzII0D1O1UI4QzQRG8Uh9G/pxHJK68J2Xg7LJ1Y4+Tk7+MLk35Fhs1/t4CgZa2/prnb3kIst8EWJ11SbMRBgf5MzJOTZw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 99a728c9-cd32-4cd5-c9e8-08d9e583cd6e 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:30.0639 (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 09/69] avcodec/idctdsp: Constify the permutation parameter of ff_init_scantable 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: +F64j65FOo+V Signed-off-by: Andreas Rheinhardt --- libavcodec/idctdsp.c | 2 +- libavcodec/idctdsp.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/idctdsp.c b/libavcodec/idctdsp.c index 71bd03c606..d07dc29207 100644 --- a/libavcodec/idctdsp.c +++ b/libavcodec/idctdsp.c @@ -26,7 +26,7 @@ #include "simple_idct.h" #include "xvididct.h" -av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st, +av_cold void ff_init_scantable(const uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable) { int i, end; diff --git a/libavcodec/idctdsp.h b/libavcodec/idctdsp.h index 014488aec3..e8f20acaf2 100644 --- a/libavcodec/idctdsp.h +++ b/libavcodec/idctdsp.h @@ -43,7 +43,7 @@ enum idct_permutation_type { FF_IDCT_PERM_SSE2, }; -void ff_init_scantable(uint8_t *permutation, ScanTable *st, +void ff_init_scantable(const uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable); void ff_init_scantable_permutation(uint8_t *idct_permutation, enum idct_permutation_type perm_type); From patchwork Tue Feb 1 13:06:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33984 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp601909iov; Tue, 1 Feb 2022 05:09:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwcSxWI9WWc+8hWzYpk/a2wpQeSC9dGBpIELnRM0BQuwZQEVvbkaWdxSIhcDx1jetw5pTGo X-Received: by 2002:a17:907:6d99:: with SMTP id sb25mr21555688ejc.15.1643720949205; Tue, 01 Feb 2022 05:09:09 -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 v27si10291257edx.440.2022.02.01.05.09.08; Tue, 01 Feb 2022 05:09:09 -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=Zqetf05p; 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 54CC368B2E7; Tue, 1 Feb 2022 15:07:42 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-oln040092071051.outbound.protection.outlook.com [40.92.71.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6803D68B2DE for ; Tue, 1 Feb 2022 15:07:36 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cRuSncrKaFYwB7yUy0j8Y4N3GKC6VVXIVtVWqNdmGdk5ChPxa89vBUTqkSQyIReabQuNZTsSlgEITV+KmpFFi8AdIjplDFp0TIMOdej2a6ci9uMXjgzcwsC9aZnZojfkdMh262IaC+JR1Q/hlS43VE9jnq7SkQzzbdRkpumuKxi7BrGgEZx9v+VsJGHLAg2eoNyAvKO2aqoAURq2VBIg3FBCTD7SOQinuMF6XAumzBTfEf6vvvcUgFzU/4PLAik+dcASS6e7Xo9pm2v9oAKRx+BGqD4jg1XjhHvhz5xqmM64S3UG5NNZtRcSDIE2O7Dd7yZ1QXTQV+TCoFzNxOaJng== 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=HABDUQ8uO4qiV3YQ+txT2vA8zW66V3hs226HYDQ0puE=; b=MDhJER2IVeHQ1ySDqp9lnzdUQIVnTZ0w/Gz8x2gevEnjR/YaQWhKotoKY+Gq+jy5qldNP3WgKqBzcuCqyxj2ITYHTF8fIGFXPVD/hPYeUEah6iis85TmwmPWtbmezoTorbhm9xLnQ/IZM/aMpQHyJTP68HXCtWcHfRMjGKiMLaKa/bPuRGMPf6/CVSRlbTovD+ktBB8rieRYBIUTVcQc7zDHlYmBqAJvh1Ns7zXXHKtigqxbNucZU6Jp8w+YS9YYMmLW5rBQvrXbaOtewhTJ6HDpPqE+1WjnZbxXXnIzBlO0y3Vm6GP1nHAtukBMI2JEYO/Z3FZMoeRdEEaH2ecdAw== 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=HABDUQ8uO4qiV3YQ+txT2vA8zW66V3hs226HYDQ0puE=; b=Zqetf05pnbIK1cT5ye10gh53bs5RoFaix0g2rRcHT4etpCLRsFq8YKz0DP/iNfooFT3gfH8Se1GleEI3zewwG9bxDYlSduxeN93p0j7EBSIo//ltE+NAZx/hOmmRmh4WkbeG0bpstV/wKwmu+O0CRiO9Q6/zJhwzPW3PaETIBs9sRx5z9/sskzquYJfeL57vhJJ20Nm1HQ+9xsHtnHBJ5d/WYYQTb3S9rO5IKMuAXtihDdNb9mZ4UW29ZXr0c0Or7eQrWYC3Uzehn/MjhFFv1L6WCaPoD/Pq/YT6QMvZOEMWvsR2rDv47zQH8Oi6Tazc4aN0zPik8a8P6YNDHVKBHQ== 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:31 +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:31 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:07 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [Crk2n7YHwAFsetbE7mQWFFLVKqbWsZTd] 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-9-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 18417162-daaf-4e33-b037-08d9e583ce2f X-MS-TrafficTypeDiagnostic: AM9PR03MB6948:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ABkZdan+AliLUp1nxBU2o1NS0WFtiVkGI/ZBl2q6E89ip6TZbxMQHbQLurhSADzikCIVHnIwJCjI5TYZsnXt8cAqG5DFNK0wNOC9LcB5sBfh+rveEXwTwSnOO67KpXfoYnbE1FgqMiRmfD+hd/Xsg/jKj3vhTnKzFhQUXwIqq1MW6DHukoK5AXVUjxppfiyybooyvRQff9sKpu9D0ok/Rn/3QHYTPFK7lE6Hjq6TeKjmVVkY0po98ljoaILOaPCPrf0Rlcf/QH+pyuoGBVix7eV5jLn2CegFGK33w56DX5mB4sEkq/sdyNgJEsUM3G2rvQIHpm4Yc5zrUS5U0h1M9FezKgBWeG6pvIHjkaGpoo4x6Rkc7smdC3yXk49djrD75VUvQkmmVa8iXOunZyAla0VKog6OVG56RVKrWsuODfrqu4V6o7xWCX8w85ymuLuldhqoeYixNZYAVj/bY/IlGlST59hW6w9qD7c+1hfTUgzRGz48XUF6NmroTiS80vDEquylaUxLeoFrTfVG6HzllVUZ3avlq5Il/2Qblw39OxCd8s2qOOihvIdpCbiBGADk X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nNfFfipOsAy//cFJoIaSta6Pyr6ubjaAWUKUF5GRfj8xSwEMLjaGIrf6Iciisukd+74Thpz3T3D2G3Z+l2xCkmlr1/uTsa1b1ofunijd+dz3nKUXKRFYO8+w4qcjjicanrw6SVHoASQFz3pQjTCz5hpZyfMj4gwVsrp4cb5nUTqoYK8fZHhj/AEowkJSOU7v3lSXuXHeS5JgZdo+Bxwm6P6sMZM3iEvgdXN+RF9lvbH4Qjl/PH2dVsbmrWy9Awef417i0u5y9IYC2Ouvp/7M60xYLE6RMxoiMm5SBUd5+GFeRKt/sKz0Xb3J8BP+majl2VH05uBTTdxDPwWb+yzEYFTWzVzbYoCi7Nos//De7Kzknl8vFeGWKENn/i/f02wfNA98HGZSR45asApwX9zvTM6arZjqvKo0KLeGztzlsyfByMtZn+kvy8Pz1nOYbJx/W4VpQnyk05yH0RDaO5zo8bdYVu4APrg5UA5KEBmKdjnKRStnlZSwuRDH0PbE9/EXrws7FzZCEqrORL1FUUvUCTNNtpC85EVoJ5ytrlj/xWTI5Dmg9OZg1Wk/DDqgSVPocGbP+I6OIFIJUEAovj+k/45Bw8Y8RFaN10yaNFtn5vXPJagNC73XGc03oNIOy+bN+Bn5tEou+n5SJ4brTI1QW87ikk2HlNNoPVST4Sl4EVNGI5BygZHqp2PxzCrVdsvHbHC1/7sDXahSuGWqlP8GUbRDmFcIj8+SuOQdHKBfAloHqWQy2fsYJzP/4jkfvfndP4xaE7mpSiLB9LMCxWH4v786BSCGNQ9WxZcG58rV+/mha5dWjaYrdpTIs1hywl5fGYDrVh2wwjDyTwzKtlS4Twe2LBbW4/rhsiUCNprCjnpW+qmE+jYZYSTLu09hwgRUmA0kxeSIa1bOFN5r/4fCDa6HZQ9lhA665zfYhOpk2Z4AcWhPNbEMRHrFhO4FeCP8BYo0lqW94cJDVxjvNI7S4g== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 18417162-daaf-4e33-b037-08d9e583ce2f 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:31.3125 (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 10/69] avcodec/wmv2: Move initializing abt_scantables to the decoder 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: t0gyBBKOvNui They are not used by the encoder at all. Signed-off-by: Andreas Rheinhardt --- libavcodec/wmv2.c | 6 ------ libavcodec/wmv2dec.c | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/wmv2.c b/libavcodec/wmv2.c index fd64a0938f..57e1267782 100644 --- a/libavcodec/wmv2.c +++ b/libavcodec/wmv2.c @@ -20,11 +20,9 @@ #include "avcodec.h" #include "idctdsp.h" -#include "mpegutils.h" #include "mpegvideo.h" #include "msmpeg4data.h" #include "wmv2.h" -#include "wmv2data.h" av_cold void ff_wmv2_common_init(Wmv2Context *w) @@ -36,10 +34,6 @@ av_cold void ff_wmv2_common_init(Wmv2Context *w) s->idsp.perm_type = w->wdsp.idct_perm; ff_init_scantable_permutation(s->idsp.idct_permutation, w->wdsp.idct_perm); - ff_init_scantable(s->idsp.idct_permutation, &w->abt_scantable[0], - ff_wmv2_scantableA); - ff_init_scantable(s->idsp.idct_permutation, &w->abt_scantable[1], - ff_wmv2_scantableB); ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, ff_wmv1_scantable[1]); ff_init_scantable(s->idsp.idct_permutation, &s->intra_h_scantable, diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c index 7518088b6a..dd0e2683f5 100644 --- a/libavcodec/wmv2dec.c +++ b/libavcodec/wmv2dec.c @@ -29,6 +29,7 @@ #include "msmpeg4data.h" #include "simple_idct.h" #include "wmv2.h" +#include "wmv2data.h" static void wmv2_add_block(Wmv2Context *w, int16_t *block1, @@ -537,12 +538,17 @@ int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64]) static av_cold int wmv2_decode_init(AVCodecContext *avctx) { Wmv2Context *const w = avctx->priv_data; + MpegEncContext *const s = &w->s; int ret; if ((ret = ff_msmpeg4_decode_init(avctx)) < 0) return ret; ff_wmv2_common_init(w); + ff_init_scantable(s->idsp.idct_permutation, &w->abt_scantable[0], + ff_wmv2_scantableA); + ff_init_scantable(s->idsp.idct_permutation, &w->abt_scantable[1], + ff_wmv2_scantableB); return ff_intrax8_common_init(avctx, &w->x8, &w->s.idsp, w->s.block, w->s.block_last_index, From patchwork Tue Feb 1 13:06:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33985 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp602163iov; Tue, 1 Feb 2022 05:09:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJxx0QLuycgES0qUi28VWb7pYXWdIgV2yc20+uThq3r2aLf6Gli82lCQRGWH1pk6X/sh00gK X-Received: by 2002:a05:6402:524d:: with SMTP id t13mr25534949edd.260.1643720964591; Tue, 01 Feb 2022 05:09:24 -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 gs39si10437210ejc.669.2022.02.01.05.09.21; Tue, 01 Feb 2022 05:09:24 -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=taQZaZWn; 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 4B59E68B2FA; Tue, 1 Feb 2022 15:07:43 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-oln040092071051.outbound.protection.outlook.com [40.92.71.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9C25768B2E4 for ; Tue, 1 Feb 2022 15:07:41 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MnVZe7iaduZM9/wAuaMnvx/IzMDONePr8k/AZEIH4xo9JcdNIwV76e/VGTZ/zBOq7Cz5Ki13ZPZ4M8YOm+aQMEvj23BomHJFAJGtkVo2OvKzApy//XaZv2m+vjymPiCzuk1rwH+6Cy9bWHXQq2CnA4P/YvQGsAUzZGahtQ4huOHu6Se8qq2kOM/XwqpGoU01Tx9EflF94SMrj/04n9Rg0GIDvPnGqMwLfjRRgnei0XJPr8Tlev/3cKBcV1D4BKIY9N2uD+xhu9JgdY8ncgucn7+7rbS3Hcr/37KrpK/1+Szs79Lx5Sziv2OXn5TjoZ4FQC1+UnkoRb59Fo4Vyo0SIg== 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=CBV717XShyx/F2OPF+V3xGJaFv57BybeWkXFJskLAbo=; b=J1FoJZJ+f5oSMJFHy3Pkh58nXCoadd+mlcYqPLr+8X/BNOSidBgIqhAMmJgcClYHH8utHr9dz96qHIHo2e7J10ie6A+S8NeZmZj3eaZ689Vy7/lhUU6ktnJepWJXqMn+CUuNdVD8Y964T/84dF4l5i37glc51vJ2I3RN+C6IbQol6tCD9/Y3Fy0OKr9hKdjT5OABxuYv2PqOVPEgJNfCHZrozU5SkNAEbkrcDwwjix+PMmJJypGa2yj5WDDukxH8UW6KoZpHvFOnHpJ7gs2jhVNLXoZZ8v38UqGFuiw8K1cZetAmlQp7o5mQYMlzYQGhhPSagKtcnw8FQEglAKHClg== 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=CBV717XShyx/F2OPF+V3xGJaFv57BybeWkXFJskLAbo=; b=taQZaZWnWXVZWb7gD5U0DfpujDX4P/uWBXauKN7bjsfkrxn5CqQWcfQ7uzXFSEGYuK93j9e0ps+uD+fXMRk8LY0U018cTVyEp62PCiSj5FqurpvzyebzdgEE6XrskZ3g/MRIE7nUJVvBXKCdRfWhqlBqKTvJ/726RXrt1vfDbfT/nVf9V91EgAH13h41MNYbG7ffV3nXl5kFksvQdXjojOYWe0uB+33O8krB4li2qSh0VqeSZFvTF42JRvmiFqXgOAACb4mKiWUnQBq9SaOenYCKHVizEd/1RrFgujr4ZV7lbHMsqfJindqjl33lrTX+epQqWxh5G64TaHKM2kubog== 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:32 +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:32 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:08 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [vG+K8Q3Tb0yQGtHzXXc9LMJOkZnrr/Kx] 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-10-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4661a273-de02-4997-34c9-08d9e583cf0b X-MS-TrafficTypeDiagnostic: AM9PR03MB6948:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SynzTeUSqwFZGR/UiZVnnONQo3jxm8PMRniw0g4gXF891w2STLLBL9jGQ5Up0s4SPacOxh08cgjcR16M7zL0svu5HGfQ+7A5bG+0DK12ZKdnqloEvNmFyhu47jE3GRk/w6l1xMGPmij0VJ95/HmQbLzVrub6xRnNHpCH+sAVu8X7HCoKIngDPUx1x37AJ/pQjebzUk/l1x6WLJiXiguabkBBwUZiPTzXm77PDbt2UdKgHiWaPTFd4FdR1VdkofxEVqGgg6Xih/qSXxAee5t4pZckfl5DkEQNQmx9VWXoAyZU/LcP1WgNHaaj43/6qjo7ctklOEJVuuXGL4qzHF8dkz5/BYdvnfLbsunBb0EwOlrMZQCu6wPZ9c1s5M1TSGX2DeqoMBXPWEyKtY5hOVfWBVRykIzOWgb24bV8Mfs/AD4Ye4++srx1lvhEQ3Se+W+b2QClCltIGgvMw+jIYAYOsoiwVG+fTfoKK0PrI6oUsuonzhJWF7hheBp1L+pj8Dzj9BDm6vRpUhmE1Zr6dIP6H3c0IKhUn/80ITDEBjjzkiq1NPRo0dDiJsIaCut/IMxF X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2Zn9PN58aA0Vuhvd1EXmPRE7/Wz85GvGmzzKzA0UDx1Sk8+3oRtlonYyLw8kQ7zEI/hwCqHLt3LZdg+V2X+IU80NN2QA+zD/1hpTDQ8G7CkUtqgXn/niaBc1HKGJZdchUkkE4oUdbjHc4369lk5YaphZoOOqeFaI9VcqyHxZPMt9hsn8a2+QmqPJCkOviAzi4k4i1wx25LoynpUAw8KLAT4bQOsIGY2iM8iX4KYM3wKkutOTw70usK9ogXrLXzOZnoovOfWZX07jJ8t70gR8vO7dKm0N6eV9MCc5sLTKLE8iyED3jdxw1l1CyTfjyNgfikFQgQKnFkfQWT9fl4OtjwMvluYD5wJ0BuOIkJQ6HThB5aHbeH5QJADRxfLPqPjvWzWUdCi6wFnHi0qihl4R9ltz/tIS/syhQuvnsSYGD4flXctc5csRyOHb054FgMcvzXn4y4MhZcfHE262XBJqc6MMkJc/BAlAH6huGILNcaOiV00zinzsYlV/xh4jj8nXSiex5sm7J0DrxaNKHLnzLMEnHsRyqndEab9vTSw7rsXe2b2SaM3cG/O7n/iJHmJuX89C0SkF1bdlGv5jcYqLbH8J3OuxG4t4TJd7b1/USOYUCQD0nqi0frhGCByhOeTRdtfNS+FdkZ6cuiI7izmjhjEtR7iWzI0YjJCfJU+f26YnTGC0AMgKtdC9WEZ4coN5krhrLWEFd2g2ifWYRYE0U6gjw23LKDVgKGDPMLiE0/proWeK+hPWFLplnxo0TwzFiR7TClNqv5YlGUV+D1pcovGqLn8z/u4VVvoq3RZEKc5Cs1tcLtX5ewxjm/Z+TTu33dx8LA5rScvZ7c5XxPsns5QCuYtFcWnYy1qld2h24sRwLqBDMsrUl4Fxvzhgxsc+P1Tt2J1nendWQGky6XIZYycaJODCy+O+is5cTPwVkkGHum5p71nsS5a4Ld+s5wfNU6llvuiYuVC5ZliH50HpyA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4661a273-de02-4997-34c9-08d9e583cf0b 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:32.7980 (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 11/69] avcodec/wmv2: Split Wmv2Context into decoder and encoder context 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: yV2BiAD1Qvdq Signed-off-by: Andreas Rheinhardt --- libavcodec/wmv2.c | 6 ++--- libavcodec/wmv2.h | 26 +++--------------- libavcodec/wmv2dec.c | 64 +++++++++++++++++++++++++++++++------------- libavcodec/wmv2enc.c | 29 +++++++++++++++----- 4 files changed, 73 insertions(+), 52 deletions(-) diff --git a/libavcodec/wmv2.c b/libavcodec/wmv2.c index 57e1267782..8d1d117dea 100644 --- a/libavcodec/wmv2.c +++ b/libavcodec/wmv2.c @@ -25,9 +25,9 @@ #include "wmv2.h" -av_cold void ff_wmv2_common_init(Wmv2Context *w) +av_cold void ff_wmv2_common_init(MpegEncContext *s) { - MpegEncContext *const s = &w->s; + WMV2Context *const w = s->private_ctx; ff_blockdsp_init(&s->bdsp, s->avctx); ff_wmv2dsp_init(&w->wdsp); @@ -52,7 +52,7 @@ void ff_mspel_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t **ref_picture, op_pixels_func (*pix_op)[4], int motion_x, int motion_y, int h) { - Wmv2Context *const w = (Wmv2Context *) s; + WMV2Context *const w = s->private_ctx; uint8_t *ptr; int dxy, mx, my, src_x, src_y, v_edge_pos; ptrdiff_t offset, linesize, uvlinesize; diff --git a/libavcodec/wmv2.h b/libavcodec/wmv2.h index 1798dbabcd..4001093881 100644 --- a/libavcodec/wmv2.h +++ b/libavcodec/wmv2.h @@ -21,9 +21,6 @@ #ifndef AVCODEC_WMV2_H #define AVCODEC_WMV2_H -#include "libavutil/mem_internal.h" - -#include "intrax8.h" #include "mpegvideo.h" #include "wmv2dsp.h" @@ -33,29 +30,12 @@ #define SKIP_TYPE_COL 3 -typedef struct Wmv2Context { - MpegEncContext s; - IntraX8Context x8; +typedef struct WMV2Context { WMV2DSPContext wdsp; - int j_type_bit; - int j_type; - int abt_flag; - int abt_type; - int abt_type_table[6]; - int per_mb_abt; - int per_block_abt; - int mspel_bit; - int cbp_table_index; - int top_left_mv_flag; - int per_mb_rl_bit; - int skip_type; int hshift; +} WMV2Context; - ScanTable abt_scantable[2]; - DECLARE_ALIGNED(32, int16_t, abt_block2)[6][64]; -} Wmv2Context; - -void ff_wmv2_common_init(Wmv2Context *w); +void ff_wmv2_common_init(MpegEncContext *s); int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64]); int ff_wmv2_encode_picture_header(MpegEncContext * s, int picture_number); diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c index dd0e2683f5..f9d91f9571 100644 --- a/libavcodec/wmv2dec.c +++ b/libavcodec/wmv2dec.c @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mem_internal.h" + #include "avcodec.h" #include "h263dec.h" #include "internal.h" @@ -31,8 +33,28 @@ #include "wmv2.h" #include "wmv2data.h" - -static void wmv2_add_block(Wmv2Context *w, int16_t *block1, +typedef struct WMV2DecContext { + MpegEncContext s; + WMV2Context common; + IntraX8Context x8; + int j_type_bit; + int j_type; + int abt_flag; + int abt_type; + int abt_type_table[6]; + int per_mb_abt; + int per_block_abt; + int mspel_bit; + int cbp_table_index; + int top_left_mv_flag; + int per_mb_rl_bit; + int skip_type; + + ScanTable abt_scantable[2]; + DECLARE_ALIGNED(32, int16_t, abt_block2)[6][64]; +} WMV2DecContext; + +static void wmv2_add_block(WMV2DecContext *w, int16_t *block1, uint8_t *dst, int stride, int n) { MpegEncContext *const s = &w->s; @@ -40,7 +62,7 @@ static void wmv2_add_block(Wmv2Context *w, int16_t *block1, if (s->block_last_index[n] >= 0) { switch (w->abt_type_table[n]) { case 0: - w->wdsp.idct_add(dst, stride, block1); + w->common.wdsp.idct_add(dst, stride, block1); break; case 1: ff_simple_idct84_add(dst, stride, block1); @@ -61,7 +83,7 @@ static void wmv2_add_block(Wmv2Context *w, int16_t *block1, void ff_wmv2_add_mb(MpegEncContext *s, int16_t block1[6][64], uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr) { - Wmv2Context *const w = (Wmv2Context *) s; + WMV2DecContext *const w = (WMV2DecContext *) s; wmv2_add_block(w, block1[0], dest_y, s->linesize, 0); wmv2_add_block(w, block1[1], dest_y + 8, s->linesize, 1); @@ -75,7 +97,7 @@ void ff_wmv2_add_mb(MpegEncContext *s, int16_t block1[6][64], wmv2_add_block(w, block1[5], dest_cr, s->uvlinesize, 5); } -static int parse_mb_skip(Wmv2Context *w) +static int parse_mb_skip(WMV2DecContext *w) { int mb_x, mb_y; int coded_mb_count = 0; @@ -140,7 +162,7 @@ static int parse_mb_skip(Wmv2Context *w) return 0; } -static int decode_ext_header(Wmv2Context *w) +static int decode_ext_header(WMV2DecContext *w) { MpegEncContext *const s = &w->s; GetBitContext gb; @@ -180,7 +202,7 @@ static int decode_ext_header(Wmv2Context *w) int ff_wmv2_decode_picture_header(MpegEncContext *s) { - Wmv2Context *const w = (Wmv2Context *) s; + WMV2DecContext *const w = (WMV2DecContext *) s; int code; if (s->picture_number == 0) @@ -215,7 +237,7 @@ int ff_wmv2_decode_picture_header(MpegEncContext *s) int ff_wmv2_decode_secondary_picture_header(MpegEncContext *s) { - Wmv2Context *const w = (Wmv2Context *) s; + WMV2DecContext *const w = (WMV2DecContext *) s; if (s->pict_type == AV_PICTURE_TYPE_I) { if (w->j_type_bit) @@ -323,19 +345,19 @@ int ff_wmv2_decode_secondary_picture_header(MpegEncContext *s) return 0; } -static inline void wmv2_decode_motion(Wmv2Context *w, int *mx_ptr, int *my_ptr) +static inline void wmv2_decode_motion(WMV2DecContext *w, int *mx_ptr, int *my_ptr) { MpegEncContext *const s = &w->s; ff_msmpeg4_decode_motion(s, mx_ptr, my_ptr); if ((((*mx_ptr) | (*my_ptr)) & 1) && s->mspel) - w->hshift = get_bits1(&s->gb); + w->common.hshift = get_bits1(&s->gb); else - w->hshift = 0; + w->common.hshift = 0; } -static int16_t *wmv2_pred_motion(Wmv2Context *w, int *px, int *py) +static int16_t *wmv2_pred_motion(WMV2DecContext *w, int *px, int *py) { MpegEncContext *const s = &w->s; int xy, wrap, diff, type; @@ -380,7 +402,7 @@ static int16_t *wmv2_pred_motion(Wmv2Context *w, int *px, int *py) return mot_val; } -static inline int wmv2_decode_inter_block(Wmv2Context *w, int16_t *block, +static inline int wmv2_decode_inter_block(WMV2DecContext *w, int16_t *block, int n, int cbp) { MpegEncContext *const s = &w->s; @@ -422,7 +444,9 @@ static inline int wmv2_decode_inter_block(Wmv2Context *w, int16_t *block, int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64]) { - Wmv2Context *const w = (Wmv2Context *) s; + /* The following is only allowed because this encoder + * does not use slice threading. */ + WMV2DecContext *const w = (WMV2DecContext *) s; int cbp, code, i, ret; uint8_t *coded_val; @@ -440,7 +464,7 @@ int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64]) s->mv[0][0][0] = 0; s->mv[0][0][1] = 0; s->mb_skipped = 1; - w->hshift = 0; + w->common.hshift = 0; return 0; } if (get_bits_left(&s->gb) <= 0) @@ -537,14 +561,16 @@ int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64]) static av_cold int wmv2_decode_init(AVCodecContext *avctx) { - Wmv2Context *const w = avctx->priv_data; + WMV2DecContext *const w = avctx->priv_data; MpegEncContext *const s = &w->s; int ret; + s->private_ctx = &w->common; + if ((ret = ff_msmpeg4_decode_init(avctx)) < 0) return ret; - ff_wmv2_common_init(w); + ff_wmv2_common_init(s); ff_init_scantable(s->idsp.idct_permutation, &w->abt_scantable[0], ff_wmv2_scantableA); ff_init_scantable(s->idsp.idct_permutation, &w->abt_scantable[1], @@ -557,7 +583,7 @@ static av_cold int wmv2_decode_init(AVCodecContext *avctx) static av_cold int wmv2_decode_end(AVCodecContext *avctx) { - Wmv2Context *w = avctx->priv_data; + WMV2DecContext *const w = avctx->priv_data; ff_intrax8_common_end(&w->x8); return ff_h263_decode_end(avctx); @@ -568,7 +594,7 @@ const AVCodec ff_wmv2_decoder = { .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 8"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_WMV2, - .priv_data_size = sizeof(Wmv2Context), + .priv_data_size = sizeof(WMV2DecContext), .init = wmv2_decode_init, .close = wmv2_decode_end, .decode = ff_h263_decode_frame, diff --git a/libavcodec/wmv2enc.c b/libavcodec/wmv2enc.c index ab5365d1f6..a7827f3194 100644 --- a/libavcodec/wmv2enc.c +++ b/libavcodec/wmv2enc.c @@ -25,8 +25,21 @@ #include "msmpeg4data.h" #include "wmv2.h" - -static int encode_ext_header(Wmv2Context *w) +typedef struct WMV2EncContext { + MpegEncContext s; + WMV2Context common; + int j_type_bit; + int j_type; + int abt_flag; + int abt_type; + int per_mb_abt; + int mspel_bit; + int cbp_table_index; + int top_left_mv_flag; + int per_mb_rl_bit; +} WMV2EncContext; + +static int encode_ext_header(WMV2EncContext *w) { MpegEncContext *const s = &w->s; PutBitContext pb; @@ -54,12 +67,14 @@ static int encode_ext_header(Wmv2Context *w) static av_cold int wmv2_encode_init(AVCodecContext *avctx) { - Wmv2Context *const w = avctx->priv_data; + WMV2EncContext *const w = avctx->priv_data; + MpegEncContext *const s = &w->s; + s->private_ctx = &w->common; if (ff_mpv_encode_init(avctx) < 0) return -1; - ff_wmv2_common_init(w); + ff_wmv2_common_init(&w->s); avctx->extradata_size = 4; avctx->extradata = av_mallocz(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); @@ -73,7 +88,7 @@ static av_cold int wmv2_encode_init(AVCodecContext *avctx) int ff_wmv2_encode_picture_header(MpegEncContext *s, int picture_number) { - Wmv2Context *const w = (Wmv2Context *) s; + WMV2EncContext *const w = (WMV2EncContext *) s; put_bits(&s->pb, 1, s->pict_type - 1); if (s->pict_type == AV_PICTURE_TYPE_I) @@ -147,7 +162,7 @@ int ff_wmv2_encode_picture_header(MpegEncContext *s, int picture_number) void ff_wmv2_encode_mb(MpegEncContext *s, int16_t block[6][64], int motion_x, int motion_y) { - Wmv2Context *const w = (Wmv2Context *) s; + WMV2EncContext *const w = (WMV2EncContext *) s; int cbp, coded_cbp, i; int pred_x, pred_y; uint8_t *coded_block; @@ -220,7 +235,7 @@ const AVCodec ff_wmv2_encoder = { .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_WMV2, .priv_class = &ff_mpv_enc_class, - .priv_data_size = sizeof(Wmv2Context), + .priv_data_size = sizeof(WMV2EncContext), .init = wmv2_encode_init, .encode2 = ff_mpv_encode_picture, .close = ff_mpv_encode_end, From patchwork Tue Feb 1 13:06:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33986 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp602347iov; Tue, 1 Feb 2022 05:09:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJxrEsvJ55NWMrMSxsIiQE9r9oIBn2pa4kEwSVNwbqhJih40uENC2KP+eNB8oQPM/6mfmlNC X-Received: by 2002:a17:907:3f9f:: with SMTP id hr31mr20563901ejc.584.1643720976871; Tue, 01 Feb 2022 05:09:36 -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 dt18si9341143ejc.735.2022.02.01.05.09.36; Tue, 01 Feb 2022 05:09:36 -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=gMcumUJQ; 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 506F468B2FE; Tue, 1 Feb 2022 15:07:44 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-oln040092071051.outbound.protection.outlook.com [40.92.71.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C920168B2CC for ; Tue, 1 Feb 2022 15:07:41 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WSJrlv7/Ov5N8Eybsayf8c7NIBQeoPY1PD9BqID7Hiov7RQq5Bxx3osZ/2acPRlV41rogUahBd+DfGmnez9EvSi+zSQs0Vo2qYDOT4fa/rsf7XRmn/00RXOJ0RhKqABXc99KLBf+hEcvQlpDOZewp9IhQtuCLzY93aqeSf/pte02sRDHl6oupB4zph7bsNAeP/DoeGxMNTJ+TH5kM0pB48ez2++xolbLwnjQl3D+Wtz9BWye3i0j9pEusIj/a1n4vfoXiVzCJA42zNCeaWKgZZSBrUdiUDtYAWNCMKHUdX7VTDFQcRcYZ+jXcIjz1VAv/N+xBan7aZFlOx5Obxr86w== 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=MpU7bxTqPeWZ6PX15mPNNXkFwudQLQEUaTOdGLyvW24=; b=ijYk8rcblo0JNzJ7xxHf0J+2AhDwdhEdeOBnd5+CDtVQAjQEHswqW/i1YQpiuLl3OJH8ml84m1rFUH3Jm9osEAf7O6SFu4+MSHSOoIPuhASnWxhCO53xm36fNP6SB4QgrTXErrenpR8Eh8i33jDzfAkVte+/apAFOFdY2qSeTQufKbmhWuTRZBkz+DkqKpnENg46kAiLoDj6GfcL3kECmbuu2r9Yc9K4aAmhTTY4EHZ++R/3QyRSCtcK0iaycMfuFu9TNmYoyiAhiL76LcvUWIxPY/TsbTtdbzCNey06AtIlNiWHDWumQOYLstey/O8Q+YrbS7THbuwbeGmxAFaJ9w== 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=MpU7bxTqPeWZ6PX15mPNNXkFwudQLQEUaTOdGLyvW24=; b=gMcumUJQx1bNZoYYPRzEI/D9fRFJbwCSr6WcbHR3UIQPlFU3933RLKx8yAeMz/oLPiSN4JhergXp87SC2VQgGtgdIL7f63diP5nwCGWfwOXI1XlIGhgKfn42WcxN2wbGlGrn5Ql6E0qtrSwGan/xnBgru8qW0bgw2D96ON0dtXw7JM63MKezUQKxPZ83fo/pWttNrtN2fm+VY9amPEgAVpTpuMrnp7tkyVdZcKVNBVSxp8IKiPO+kXMtD52ze8AUh6pZgUk38t4t2kltFrJ/37/5a65HPySLem8ZP1L33eoXV6c8ZIKT/RX+sFJ+uJ+PiD6KMnFY9GRfTIXC4KL0SQ== 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:34 +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:34 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:09 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [nse34VzIb/TG8DQsqof5LGvdWys0Ue/v] 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-11-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 242c1442-799f-4ecd-cc0f-08d9e583cff9 X-MS-TrafficTypeDiagnostic: AM9PR03MB6948:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xw0e1wZ5tspr33XWunz6vbswmDCXwJpPPIhUgKCnyLgRp19X9kst9zsmkS4joU78q9bgVtFyAp2MtZb1jWJ/L/uoSdv2kfBtyNBtUDLICjwZXpGs31J+Gh8lIVOCAS/Uge4KXFluEF+neLFOEF480/2wxjrh0MJ2nWJBIqjKk5x9O3ZyzTP8PcKTkzg7hRsQglZasjB3mtJUORETd49G0Y62t7mnBCeO2Z0gf6ecAERz6X8PpoexlzmqgXeM19/721V60IPURp2sMgTYtNR5Gmz78Kf786OWkeBAg6BEcOvntIDkbQlEQw8YdaTDnvyHiO8IjxcRwlikjzgMCuN/MxtucDnAKVCC6CKA4QHHfyOP+uUs8sWTV4cfixgoKWmjHiXM54qIR83xkXNJqrdyvfVexI2XQ881bZjLHfd9COOQUialW1nzrKcNP/IOC4gh0iQc4N45OcDtRKCiH5MYb9OsEF3VfvVJlobp7P1Pf7RMkALOWKn5ff4IjJZb6Z45VHSQv4eJu1X5j70uymOwq1kr/GbsFKbeP4/Y4QE09I+Fedyx0Yad6Z2chygOCGSv X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LAnpWl7YjuFWdcaIUh9stHxw52pQEOr09tCYO02HXGUVIMxVFobIeUNEXgJROeiqc0jgK1c0e7CX7u1UZ1B/R+JC87+k8sEX7wkDhkN6etZsCa4uwQUrFIl3k1U3iW/TymVfgRj7yeXwzAe3j1RWVTfcX0zjbew+ukB+qBONQv+npaMEJ7cS+VRN/cjJNyCGSyJVKfroZboeYOYADu9MYtO1LlYJ0oLhfLComzz4ERi0ZF1WTHtH5YuvoI0WbVTr/E3u1prcukmNeoVtCoEtKj4Ztswu8WZR2xje/FyBP3uso4uawvLJLZsEGwjFwN1myJqwUhwwRQDC3HgDBiat4H29sYRhb/8m0RoLGcQPcpX6+N2U64UHz9kXhdIwwhshBtpb/MZc6vEzaoXR/KwhldQ7RwAsJYe3/S+dXIUnKl/+LiMdn+uAUUs6Gm34gRe+ehzBCpzJx4wpxruFkqMeD7wNFjBGUTjhA73jVYGACM0jENcL33BANI5yOef3Q0+cdmbjzNat4mOcc/NDCrhk8dYQzUuxQC9OpPmGJtCbmIl17Z0cZ/UJqwudI6h/BwppCoQrApIeRzeoEWIuhs9SC93/IcAmtFqjlK51+49Aq8icD61VULjcQqsD44OF18pjEd1kEROcFvbtT5YXCzR9NH8vL31i4hDxmUMv0qZkgXeBX5cT7Xb1f65AlMLcfS3pZe+2vK3jHC845U1vjwcOod4VIeWyMzRlza7ayuvdUN2jLEhSpXWHxTQRjWdGzVC38iGwq2TM944x1ZfvCJ7QO/3L7qHHtxFQuwpEWh5UDtws3/JZ94m5fM39rgNHqXWWJSOIoLjH5hkID0qUFZ8mVP+6kV7/1sVKPEBOBH7tra79XiCe5rVw2dlRh0bXoNguVnfT1hvWnNylnI+z0hBPlZMyBDUYZNGZwcLjgugkG+wcYNEo1FWKOFJ3B+J6Pua9g/0FV1ExXM1XRqeN+Q8pvw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 242c1442-799f-4ecd-cc0f-08d9e583cff9 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:34.3304 (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 12/69] avcodec/wmv2.h: Move encoder- and decoder-only parts to new headers 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: BPkIfuuUK43S Signed-off-by: Andreas Rheinhardt --- libavcodec/h263dec.c | 2 +- libavcodec/mpegvideo.c | 2 +- libavcodec/mpegvideo_enc.c | 2 +- libavcodec/msmpeg4dec.c | 2 +- libavcodec/wmv2.h | 9 --------- libavcodec/wmv2dec.c | 1 + libavcodec/wmv2dec.h | 32 ++++++++++++++++++++++++++++++++ libavcodec/wmv2enc.c | 1 + libavcodec/wmv2enc.h | 31 +++++++++++++++++++++++++++++++ 9 files changed, 69 insertions(+), 13 deletions(-) create mode 100644 libavcodec/wmv2dec.h create mode 100644 libavcodec/wmv2enc.h diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index 3466027286..0812912f17 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -49,7 +49,7 @@ #include "msmpeg4.h" #include "qpeldsp.h" #include "thread.h" -#include "wmv2.h" +#include "wmv2dec.h" static enum AVPixelFormat h263_get_format(AVCodecContext *avctx) { diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index bbcf00b014..0e0f035526 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -44,7 +44,7 @@ #include "mpegvideodata.h" #include "qpeldsp.h" #include "thread.h" -#include "wmv2.h" +#include "wmv2dec.h" #include static void dct_unquantize_mpeg1_intra_c(MpegEncContext *s, diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index bb8d3bc908..d2365a54af 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -67,7 +67,7 @@ #include "mpeg4videodata.h" #include "internal.h" #include "bytestream.h" -#include "wmv2.h" +#include "wmv2enc.h" #include "rv10.h" #include "packet_internal.h" #include diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c index 3d2dcb9429..e1d2c342bc 100644 --- a/libavcodec/msmpeg4dec.c +++ b/libavcodec/msmpeg4dec.c @@ -33,7 +33,7 @@ #include "mpeg4video.h" #include "msmpeg4data.h" #include "vc1data.h" -#include "wmv2.h" +#include "wmv2dec.h" #define DC_VLC_BITS 9 #define V2_INTRA_CBPC_VLC_BITS 3 diff --git a/libavcodec/wmv2.h b/libavcodec/wmv2.h index 4001093881..cdd58cf011 100644 --- a/libavcodec/wmv2.h +++ b/libavcodec/wmv2.h @@ -37,15 +37,6 @@ typedef struct WMV2Context { void ff_wmv2_common_init(MpegEncContext *s); -int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64]); -int ff_wmv2_encode_picture_header(MpegEncContext * s, int picture_number); -void ff_wmv2_encode_mb(MpegEncContext * s, int16_t block[6][64], - int motion_x, int motion_y); -int ff_wmv2_decode_picture_header(MpegEncContext * s); -int ff_wmv2_decode_secondary_picture_header(MpegEncContext * s); -void ff_wmv2_add_mb(MpegEncContext *s, int16_t block[6][64], - uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr); - void ff_mspel_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, uint8_t **ref_picture, op_pixels_func (*pix_op)[4], diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c index f9d91f9571..ddf68545fc 100644 --- a/libavcodec/wmv2dec.c +++ b/libavcodec/wmv2dec.c @@ -32,6 +32,7 @@ #include "simple_idct.h" #include "wmv2.h" #include "wmv2data.h" +#include "wmv2dec.h" typedef struct WMV2DecContext { MpegEncContext s; diff --git a/libavcodec/wmv2dec.h b/libavcodec/wmv2dec.h new file mode 100644 index 0000000000..cc410afe17 --- /dev/null +++ b/libavcodec/wmv2dec.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2002 The FFmpeg Project + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_WMV2DEC_H +#define AVCODEC_WMV2DEC_H + +#include "mpegvideo.h" + +int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64]); +int ff_wmv2_decode_picture_header(MpegEncContext * s); +int ff_wmv2_decode_secondary_picture_header(MpegEncContext * s); +void ff_wmv2_add_mb(MpegEncContext *s, int16_t block[6][64], + uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr); + +#endif diff --git a/libavcodec/wmv2enc.c b/libavcodec/wmv2enc.c index a7827f3194..5cb4c4073c 100644 --- a/libavcodec/wmv2enc.c +++ b/libavcodec/wmv2enc.c @@ -24,6 +24,7 @@ #include "msmpeg4.h" #include "msmpeg4data.h" #include "wmv2.h" +#include "wmv2enc.h" typedef struct WMV2EncContext { MpegEncContext s; diff --git a/libavcodec/wmv2enc.h b/libavcodec/wmv2enc.h new file mode 100644 index 0000000000..3f7f5104a6 --- /dev/null +++ b/libavcodec/wmv2enc.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2002 The FFmpeg Project + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_WMV2ENC_H +#define AVCODEC_WMV2ENC_H + +#include "mpegvideo.h" + +int ff_wmv2_encode_picture_header(MpegEncContext * s, int picture_number); +void ff_wmv2_encode_mb(MpegEncContext * s, int16_t block[6][64], + int motion_x, int motion_y); + + +#endif From patchwork Tue Feb 1 13:06:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33987 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp602606iov; Tue, 1 Feb 2022 05:09:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJwZupLciOw6WtCz9OXiX92hDu5KRXCKQbxKecBCIUSEsAwhK7amw3r21rEYOJJ4hFypFvAE X-Received: by 2002:a17:907:1c90:: with SMTP id nb16mr9314922ejc.413.1643720993230; Tue, 01 Feb 2022 05:09:53 -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 ht13si9793818ejc.850.2022.02.01.05.09.50; Tue, 01 Feb 2022 05:09:53 -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=VTUPisUf; 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 278BD68B30C; Tue, 1 Feb 2022 15:07:45 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-oln040092071051.outbound.protection.outlook.com [40.92.71.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EB9CC68B2EB for ; Tue, 1 Feb 2022 15:07:41 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PdURrdvCeA59vaunJtdPCtNqUaqaa1CEuiDC2WtzWdcTzT7VlDl0RvmdFRKi1r14GMxNTLA465rKMXm+eck4X80gE8rAXpZZYl6ACUneanrUo9pt/ZJ6yCZLpZR5pFl80S/oG0K3BCQ2/khhBBLEW4ToSPLVz1uvdRacXyfvDtS8mia1ZYe2AsxGHifvDm3v1IIvIRYrq/188Oze7pad/9n42hWbdXIvVuVdNSJ9mecKZpCUfR+/jhAy3nGEkAMVaH+Ofta7sdf6RrGJmctEPE+IzLMGDDcxRHGft5/Em9UUeqc9EH2PqJYzzTcnEpBj8Q27xakD/S5r0AVnsDok5w== 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=scA2M7R0upie+8r5kjIThLy7FoOdJDm/O8ZZl4TkOvw=; b=nj8Qwo1a8rU619STILpRqVct4jHw2jR+9E0t+30cP1QNows19zDXhx9rVyjP/by80L+yyi3YpVq5a5jxxTQM3e+/8KBsHwvUGhzhyOQhyjDNRd8J2Hjr51fmQFK42+cOEie4Na2s0/Qzoc/UNvi1OB5AJeGyy6nBvnDZVQEtGMp98SlL0F07ZfxYbTk2i4aV7fQB6J3kMUeW3Oo+mHNDqgp5nEobZnAE4D1noU7Kcjmaddg3szqeGyIyvLTHCBveg6y/hImn8za+TDQIjdREsMrLYZFJCH6eOpa+/Hi6kT7XwUSK7bsVwd27ZsLDbHk/tZIIG/2Lj6sOmRgSMmKEwA== 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=scA2M7R0upie+8r5kjIThLy7FoOdJDm/O8ZZl4TkOvw=; b=VTUPisUfU1VAHy8cICvxsjqD+GxqJmOSs4vklQK4X1AM3MU6VvOzQqOPne0qEF/puqSP9/UXFTp0i9YjQyClMMGp+xwZEdNHP9ed6GK7lHKRUf17cSS3DWRtDaUVpNeZfV4bsWqEaoiSkuvaigILC2wN8uwDPGhFWjQOl2PgUIjJjOSW3zwOtI8ncWc/T7i9t+2/4HDx9Xrq3H7BcJXHyHnQQ8jq1jlUr0OHgY3KowDHY7Hq9TOapVatqgym+W25qntVqWdaaCxGSy9GH6c3v7lLuwIShgMUgEnrMNtZhUVq6UG+oUodqP/UAuLI9TRLkJfeIzIi51jo7makG/e18w== 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:36 +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:36 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:10 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [fYOzoWHu/5hQax1ymY7EeJDL0RIc63ot] 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-12-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e9a9cf8c-4c52-48de-927c-08d9e583d109 X-MS-TrafficTypeDiagnostic: AM9PR03MB6948:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VKeUlAe2WTAyoKlQi3Il/bBd6b90LIWBWRB7FFFqCRS4wNG4Li7KWjnjeEoyf75k7FlUzhE4uDXd374Abe6L/y3K+6kGdHOTFqVe6wTOStQJqaF90Kk0zu+p23kt+pDmwICvJFo8JW8Q6sYtipsraU0/uUmO5JwVAn9sk8DydNTz9+fRi0Arv52WiJ6YA9ARXMnBY2vOKziAXOIuB92aKRmaBuKTJUIVWu+jXXlfJdmZcYeXI4x63DdEcACxkgiUAUNhpMs6Gf+/+z7D63N+Vpl+r4D57or7P6mYiHBy3oh0Q9+n8BI2WJkR4Vgv+gP08LWTkDIopphZuLC37idUWwKTGJ8R4J9l6uAmmD5RJwKlGeaOpx+7XjAanziPq4xIdT2mtMaBqr44aH05kHPRxmop3HIxH3KLPiRG6vvBKnXDr0VuX03v8AZgMEvX4ap0S0D7eQlrLX46/BYj/2jK0Y79vk87epZIc2jHIPBxNAGh24saZHpOl4cHLYhQ/U63Iq6F2Ynyzlwmk6Of45kG8Ir7lTpHAIJ0Fp7LuKZrE8o9WqigN6+NSMmF5yl16cDR X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EZ3mlHVrw2bwqn0cv/Ts8S8tNRdjp3FYaHWg54wt+tGIgWDiLjmns1SfZCftkw0SJgcgcI1WiVE9uWCfWfQyWnBw4Ity1ZVZkgpOlMnBFjAe0952BRjsdLmuNYB0l7HXPk20SYTzOZ+6tZKtHoyCGMebr4etnYB+MNfRrREO2fOlxumFiZLBdB4+qD2qesvUcrrY24UFNMwrD44scvDy4LiELEBXp1U+qHO3D1ME9DVVpYM4WOces+nZDamYh3V/dqTQ6kUS9hK0EDYOr58VRSjeRbLCYXirkGovXBoXbRmQgamOA5USYPpilvDFLW+qbqpu9EsqXtAPiRIX+BMkM2vSGyKALpf0zI0s36iMDDGCwiklZITcQm8WW1WwPmvWOMdkkGkyKX+Qa4KTDCNAeaJwF6PvJSHkso9VKPyc/t/ALbuj69+q1tGxVmmEmLQrCYFyxSKgX4n99j3ZbONQZGlHytgIap5VQq2J2zaumkztY2HIBbRkOOKBNAbvwaF8qeaG7BMrCTeAuUsJK5DTxhejJwJUPiEwJJ6zjzt1XifnILijld1VCggHcI2Fg4yFBlCGwGMb6sFeOmpzIXUdi7UNbuUJO3hzPVfscQaKDMl+cksuXSP5kCuhBbFmGjnsrZ5oNrtYeWPDFpOj7m5OfWFU6kmbrB7I5Gqsy8cFzmIiw/4T6OibF4RhbLhCpQntM1hpgt3kvSbPTpgbvg6ov/jh3FypmWB1UOitZDBiS9bMCHouMJskbHCkXLSeto9JIY4Dk2m/GBBJ8Q4L9rCOWex9ATZismE9IHL59646coqJ0tk7GO7unQ0bGTQgJ5PcVYS7IsPJUDK/UBkFwjsgVoBNjrnWvJ2yamtG/XDbywBzIzEfiGvTcLCQI4Oe/oA2NvAInyK5ZRwKFQ0yYt2MxTiIbLbvMH1XqA4KWLV97u+f01mbypDbYJupjw0u8exdjtZ7ia9knYtosBesoihD9A== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e9a9cf8c-4c52-48de-927c-08d9e583d109 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:36.1115 (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 13/69] avcodec/msmpeg4.h: Move encoder-only stuff to a new header 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: Go6x8ZRdVnRI Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo_enc.c | 2 +- libavcodec/msmpeg4.h | 15 ------------- libavcodec/msmpeg4enc.c | 1 + libavcodec/msmpeg4enc.h | 45 ++++++++++++++++++++++++++++++++++++++ libavcodec/wmv2enc.c | 1 + 5 files changed, 48 insertions(+), 16 deletions(-) create mode 100644 libavcodec/msmpeg4enc.h diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index d2365a54af..07dc575a5b 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -56,7 +56,7 @@ #include "mpegutils.h" #include "mjpegenc.h" #include "speedhqenc.h" -#include "msmpeg4.h" +#include "msmpeg4enc.h" #include "pixblockdsp.h" #include "qpeldsp.h" #include "faandct.h" diff --git a/libavcodec/msmpeg4.h b/libavcodec/msmpeg4.h index 483c965b9d..dbe650cbbc 100644 --- a/libavcodec/msmpeg4.h +++ b/libavcodec/msmpeg4.h @@ -28,7 +28,6 @@ #include "avcodec.h" #include "mpegvideo.h" #include "msmpeg4data.h" -#include "put_bits.h" #define INTER_INTRA_VLC_BITS 3 #define MB_NON_INTRA_VLC_BITS 9 @@ -42,20 +41,10 @@ extern VLC ff_mb_non_intra_vlc[4]; extern VLC ff_inter_intra_vlc; -void ff_msmpeg4_code012(PutBitContext *pb, int n); void ff_msmpeg4_common_init(MpegEncContext *s); -void ff_msmpeg4_encode_block(MpegEncContext * s, int16_t * block, int n); -void ff_msmpeg4_handle_slices(MpegEncContext *s); -void ff_msmpeg4_encode_motion(MpegEncContext * s, int mx, int my); int ff_msmpeg4_coded_block_pred(MpegEncContext * s, int n, uint8_t **coded_block_ptr); -void ff_msmpeg4_encode_init(MpegEncContext *s); -void ff_msmpeg4_encode_picture_header(MpegEncContext *s, int picture_number); -void ff_msmpeg4_encode_ext_header(MpegEncContext *s); -void ff_msmpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64], - int motion_x, int motion_y); - int ff_msmpeg4_decode_init(AVCodecContext *avctx); int ff_msmpeg4_decode_picture_header(MpegEncContext *s); int ff_msmpeg4_decode_ext_header(MpegEncContext *s, int buf_size); @@ -72,9 +61,5 @@ int ff_msmpeg4_pred_dc(MpegEncContext *s, int n, CONFIG_WMV1_DECODER || \ CONFIG_WMV2_DECODER || \ CONFIG_VC1_DECODER) -#define CONFIG_MSMPEG4_ENCODER (CONFIG_MSMPEG4V2_ENCODER || \ - CONFIG_MSMPEG4V3_ENCODER || \ - CONFIG_WMV1_ENCODER || \ - CONFIG_WMV2_ENCODER) #endif /* AVCODEC_MSMPEG4_H */ diff --git a/libavcodec/msmpeg4enc.c b/libavcodec/msmpeg4enc.c index 2c619e1210..31920b7f0d 100644 --- a/libavcodec/msmpeg4enc.c +++ b/libavcodec/msmpeg4enc.c @@ -39,6 +39,7 @@ #include "mpeg4video.h" #include "msmpeg4.h" #include "msmpeg4data.h" +#include "msmpeg4enc.h" #include "put_bits.h" #include "rl.h" #include "vc1data.h" diff --git a/libavcodec/msmpeg4enc.h b/libavcodec/msmpeg4enc.h new file mode 100644 index 0000000000..12f8f44232 --- /dev/null +++ b/libavcodec/msmpeg4enc.h @@ -0,0 +1,45 @@ +/* + * MSMPEG4 encoder header + * copyright (c) 2007 Aurelien Jacobs + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_MSMPEG4ENC_H +#define AVCODEC_MSMPEG4ENC_H + +#include "config.h" +#include "mpegvideo.h" +#include "put_bits.h" + +void ff_msmpeg4_encode_init(MpegEncContext *s); +void ff_msmpeg4_encode_picture_header(MpegEncContext *s, int picture_number); +void ff_msmpeg4_encode_ext_header(MpegEncContext *s); +void ff_msmpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64], + int motion_x, int motion_y); +void ff_msmpeg4_encode_block(MpegEncContext * s, int16_t * block, int n); +void ff_msmpeg4_handle_slices(MpegEncContext *s); +void ff_msmpeg4_encode_motion(MpegEncContext * s, int mx, int my); + +void ff_msmpeg4_code012(PutBitContext *pb, int n); + +#define CONFIG_MSMPEG4_ENCODER (CONFIG_MSMPEG4V2_ENCODER || \ + CONFIG_MSMPEG4V3_ENCODER || \ + CONFIG_WMV1_ENCODER || \ + CONFIG_WMV2_ENCODER) + +#endif diff --git a/libavcodec/wmv2enc.c b/libavcodec/wmv2enc.c index 5cb4c4073c..2622f833b0 100644 --- a/libavcodec/wmv2enc.c +++ b/libavcodec/wmv2enc.c @@ -22,6 +22,7 @@ #include "h263.h" #include "mpegvideo.h" #include "msmpeg4.h" +#include "msmpeg4enc.h" #include "msmpeg4data.h" #include "wmv2.h" #include "wmv2enc.h" From patchwork Tue Feb 1 13:06:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33988 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp602784iov; Tue, 1 Feb 2022 05:10:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJxS9KRZ4BxcMYl8ARJGpMmFDeeeJkBWJpTvgoLVZAyDWlnHQ2n9YFUVK+uaYuJiWVT9W4VB X-Received: by 2002:a05:6402:3552:: with SMTP id f18mr25413623edd.189.1643721004884; Tue, 01 Feb 2022 05:10:04 -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 b8si9078954edk.124.2022.02.01.05.10.04; Tue, 01 Feb 2022 05:10:04 -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=QQIFeTGs; 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 21CFE68B2BA; Tue, 1 Feb 2022 15:07:46 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-oln040092071051.outbound.protection.outlook.com [40.92.71.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2F29668B2EB for ; Tue, 1 Feb 2022 15:07:42 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FWrEr2bKz/L+O5uOkuadkkEmbhdTx86UHtvlcOxKqi1yJpfzLa+AyxpcIFUPMYF0K0sExRNiM8lqcqqbK1QC5mHJdL1kG2EWHfwETP0dX3rR/xqOydEgdjjyFN9gw6iceJaKs1DBUb7hvitnrsLoxEMiM9zyQtUXbe8CnZ+DG8B0QqT2FUN31Hq2n4J8CDRSaPmYLcH5bvoXXL9WxMN1J5ggphph/oQfvhldZG0pBIYYGhD1/vH2b9BXdyUXCdMXPjK+OjsA9u9CRW14R+/Zw+5YMv0knEXl/bwHXWU4fMDjGhDeLosruY+CdQHnweKysGx0S4qI2FLEkr6mxvVvQA== 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=EQJ6TbADBp7sOYL5d6gtkwfvykV6TkwO7bhYAxi4sgU=; b=m2jGXY9JfzoGMWNDE/SKF/8mfKcQjShqyPFjWeUptUD+hXNQ7swEOFPT8l4A1mMulcnOf44gS3OnnrmHoC2DXVdUg8HJjdiuMvbBieCXpOaEpqb49Er2Zcko0hgDJygI/aqn1DEAQyP9LEDqB7nH49y1qPk42XhRe2mSUdb74VJp0kM5lHdCce1h31fpUzrT38X9Bp4EPEYXtaH0gIhmoo9Im6Oj8whr5C4zO76FFMfuFoy3DpRu16SkgVfQeimiq0tbCXS9MhfnFi31Sj6ytKwz0fpAzhz+sDwi3KL9RdwP2YOuc+7tPBm3h04Sm4tHduHPLBFQUyZ1lUuut28ZwA== 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=EQJ6TbADBp7sOYL5d6gtkwfvykV6TkwO7bhYAxi4sgU=; b=QQIFeTGsiGdbMu9rrfFDanl0WeV+1UbXcekyzWwz7Sq8pHgi/3nKI442udqeiCkH+37D914vBbfDfJNT39RpnoS9msCbe4syvpRhivHUsoWyLLF0sSbxEKV6TjdViWAgw1HQXRnfVpf6uGRGiQgroPTAYHdQDXExbaLJht7kL8pOHbkBOgE69iSxH9m64R7/+1KyKkVa43XWEGdf6+oPtnJ3YPV/0pTZfukTZSi4y1Uc31yuSSbVTJzBc8JFGj82XS9a+VaVdInooNgluzPu0omkI2ipFDiA8tXS/fx9kfcCChbhzWPpWF2Fq1ZFVwbsru09awRJSxhwF+hDqXNiWQ== 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:37 +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:37 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:11 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [fK6WatnxIOBK/Axu2TxNkMAuHvxvgBF+] 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-13-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b8db2503-00ce-4324-5b3a-08d9e583d1bc X-MS-TrafficTypeDiagnostic: AM9PR03MB6948:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TtcVxg7Eg7ITF8F9EG7AJV/CLyw8jbaawSSBZhsCHfJfFfHqgpucsQItWL0sHten2aqnZO1Z7JeKFWSJFW49FAgKgsd59QUXoG+x7WaS8EQsr8B69x8KcXORHnioqnK6yaiFTFcjITJ6Wyol0OxaTex3AfLX3ivCdMtJ1orwZdG5pEAOUQxESLxxDWw4rQxYm6yIh/3DwFAG6K/3ZVcBP0Mv/F5la+lfo91xg2l9SOapqVACnsexPSQg5PqUHl31MpwaYxzG8qyCFHgpdTQkcjXWGOL7HVn5txxs723miOX3AyVEuA2YFe4TIWfRmk4E7VRbF8XTDbRYHvwQ/WvE9jLlNdEQ2XnahARDWDLepsFnODbVKwos0b6yunmeVRMT/6lAjj9EhHQYCGG7olFBUmvJM+1e5QvRHa44as1HXg9cmA26VBVlCagULAikFzanC+D+ozcINCsVJtx+17QWRmzppcxUdxGqmlwCYS2n2fd+U9/UqiYsJuLfCTW5oRi8i4pwFCerA26b0EYgIxjBVvrmxNikrP/CiMORQxvwrDzdjxkY22DJnPqESr0D5mx5 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pwglltVoPFGJPYlcVl5X4uOmSTR3pTuC3DOA0wOXFmDLks9cnJdp1j3sVJBs6fLBvPoBchK6LfjUd/lK/syeyddg+bSEw4xanvAv41oHvKi/rUf+BjvLrKLQwHQ1dxf9wFfTiuqpQUPvfViBn/1tgrzgJkfJshgIzlc9ZHuu0Kp1yiQedji8Vd6h/rap+A8QsCUXiaVBSQ16rXkNZ20xCk6J477WbOQA8Sc6GDCTz6UNs4pxIUainH159KLeMAbX7JpM+gspd6v8EwpFQpcC+AkRP96ig2HR9BLNStqoOnYbymoFWuvDZ9zs3A1nRYtEZJ8mprb5+YkEJTuWMObXIHx0DJUOKd6rAcdHDl2jKUiOCC0e5kAY9kSyrsav/JgDOrHtsOsU77dufFHhnWBJMxHvd0GDwogPdwNuKYuJ7NIfyxT0fHXOZAjXv26CbKBMwt4opYyGRduEtA1xU3kV8/iMun+AeHCyJY1wNEtY9sh1qx4HB9J2hxMFHBqCEu0SuxaprhJd/a+9veG+PI5u4aAeePnewuvTpSAXaRgcgSN2kl8iRGnFPz100hPaP8o6kyCKwJkb53PhYOqW7KGLIAT7CGAWgzgonCB7N7v7oMi4tdHdofJSaWWkSMjsHcycL10Rey+zjd8A6TuSc4MBwRNZKFeLO37N23itOb7BzQ4rabnMFNMJTbh04HEGRAmyUQ4IHGAUhxRlnHPQWBKBio4HNH/+rWhNUWcSU424Q7EjgT0nB8AcHIsc7/blqAcxViGo7hxndTx8wEEvU/lRVv3/yrLrYntNzGBR31dSju4doykTpjJmM2NuNVsHlaM5HTChMKSeB/CXzkLFWE7JgJO8sjLd70iumMdwuemEDfVjAkdrYzXYNsF7HNBCnZYvoU0VpR1xoD06eOgBdTsL6ir7XIIRuZ1k0t7Yxtexj0M3kfx886+6KBj54slS5/Bpv44eu+By47/NA6XicyQOlg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b8db2503-00ce-4324-5b3a-08d9e583d1bc 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:37.2676 (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 14/69] avcodec/msmpeg4.h: Move decoder-only parts to a new header 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: PqgYNbqPIe11 Signed-off-by: Andreas Rheinhardt --- libavcodec/h263dec.c | 2 +- libavcodec/msmpeg4.h | 23 ------------------- libavcodec/msmpeg4dec.c | 1 + libavcodec/msmpeg4dec.h | 50 +++++++++++++++++++++++++++++++++++++++++ libavcodec/mss2.c | 2 +- libavcodec/vc1dec.c | 2 +- libavcodec/wmv2dec.c | 1 + 7 files changed, 55 insertions(+), 26 deletions(-) create mode 100644 libavcodec/msmpeg4dec.h diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index 0812912f17..5a54d57bbc 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -46,7 +46,7 @@ #endif #include "mpegutils.h" #include "mpegvideo.h" -#include "msmpeg4.h" +#include "msmpeg4dec.h" #include "qpeldsp.h" #include "thread.h" #include "wmv2dec.h" diff --git a/libavcodec/msmpeg4.h b/libavcodec/msmpeg4.h index dbe650cbbc..6dd16d3957 100644 --- a/libavcodec/msmpeg4.h +++ b/libavcodec/msmpeg4.h @@ -24,42 +24,19 @@ #include -#include "config.h" #include "avcodec.h" #include "mpegvideo.h" -#include "msmpeg4data.h" - -#define INTER_INTRA_VLC_BITS 3 -#define MB_NON_INTRA_VLC_BITS 9 -#define MB_INTRA_VLC_BITS 9 #define II_BITRATE 128*1024 #define MBAC_BITRATE 50*1024 #define DC_MAX 119 -extern VLC ff_mb_non_intra_vlc[4]; -extern VLC ff_inter_intra_vlc; - void ff_msmpeg4_common_init(MpegEncContext *s); int ff_msmpeg4_coded_block_pred(MpegEncContext * s, int n, uint8_t **coded_block_ptr); -int ff_msmpeg4_decode_init(AVCodecContext *avctx); -int ff_msmpeg4_decode_picture_header(MpegEncContext *s); -int ff_msmpeg4_decode_ext_header(MpegEncContext *s, int buf_size); -void ff_msmpeg4_decode_motion(MpegEncContext * s, int *mx_ptr, int *my_ptr); -int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * block, - int n, int coded, const uint8_t *scan_table); int ff_msmpeg4_pred_dc(MpegEncContext *s, int n, int16_t **dc_val_ptr, int *dir_ptr); - -#define CONFIG_MSMPEG4_DECODER (CONFIG_MSMPEG4V1_DECODER || \ - CONFIG_MSMPEG4V2_DECODER || \ - CONFIG_MSMPEG4V3_DECODER || \ - CONFIG_WMV1_DECODER || \ - CONFIG_WMV2_DECODER || \ - CONFIG_VC1_DECODER) - #endif /* AVCODEC_MSMPEG4_H */ diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c index e1d2c342bc..a7870f252f 100644 --- a/libavcodec/msmpeg4dec.c +++ b/libavcodec/msmpeg4dec.c @@ -27,6 +27,7 @@ #include "mpegutils.h" #include "mpegvideo.h" #include "msmpeg4.h" +#include "msmpeg4dec.h" #include "libavutil/imgutils.h" #include "h263.h" #include "h263dec.h" diff --git a/libavcodec/msmpeg4dec.h b/libavcodec/msmpeg4dec.h new file mode 100644 index 0000000000..af2591caf5 --- /dev/null +++ b/libavcodec/msmpeg4dec.h @@ -0,0 +1,50 @@ +/* + * MSMPEG4 decoder header + * copyright (c) 2007 Aurelien Jacobs + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_MSMPEG4DEC_H +#define AVCODEC_MSMPEG4DEC_H + +#include "config.h" +#include "avcodec.h" +#include "mpegvideo.h" + +#define INTER_INTRA_VLC_BITS 3 +#define MB_NON_INTRA_VLC_BITS 9 +#define MB_INTRA_VLC_BITS 9 + +extern VLC ff_mb_non_intra_vlc[4]; +extern VLC ff_inter_intra_vlc; + +int ff_msmpeg4_decode_init(AVCodecContext *avctx); +int ff_msmpeg4_decode_picture_header(MpegEncContext *s); +int ff_msmpeg4_decode_ext_header(MpegEncContext *s, int buf_size); +void ff_msmpeg4_decode_motion(MpegEncContext * s, int *mx_ptr, int *my_ptr); +int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * block, + int n, int coded, const uint8_t *scan_table); + +#define CONFIG_MSMPEG4_DECODER (CONFIG_MSMPEG4V1_DECODER || \ + CONFIG_MSMPEG4V2_DECODER || \ + CONFIG_MSMPEG4V3_DECODER || \ + CONFIG_WMV1_DECODER || \ + CONFIG_WMV2_DECODER || \ + CONFIG_VC1_DECODER) + +#endif diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c index d7a19f6ad2..dcf91f9828 100644 --- a/libavcodec/mss2.c +++ b/libavcodec/mss2.c @@ -27,7 +27,7 @@ #include "error_resilience.h" #include "internal.h" #include "mpeg_er.h" -#include "msmpeg4.h" +#include "msmpeg4dec.h" #include "qpeldsp.h" #include "vc1.h" #include "wmv2data.h" diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index 7ed5133cfa..89cccc1929 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -33,8 +33,8 @@ #include "internal.h" #include "mpeg_er.h" #include "mpegvideo.h" -#include "msmpeg4.h" #include "msmpeg4data.h" +#include "msmpeg4dec.h" #include "profiles.h" #include "vc1.h" #include "vc1data.h" diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c index ddf68545fc..7121468ae9 100644 --- a/libavcodec/wmv2dec.c +++ b/libavcodec/wmv2dec.c @@ -29,6 +29,7 @@ #include "mpegvideo.h" #include "msmpeg4.h" #include "msmpeg4data.h" +#include "msmpeg4dec.h" #include "simple_idct.h" #include "wmv2.h" #include "wmv2data.h" From patchwork Tue Feb 1 13:06:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33989 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp603017iov; Tue, 1 Feb 2022 05:10:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJx1p4biBHjn21aNaileg5mEfOQoqGuV5+ZIMydccHLlHMAUBcdCwafAjyvvTw3kJeoqxbzD X-Received: by 2002:a05:6402:d0d:: with SMTP id eb13mr25589118edb.24.1643721022402; Tue, 01 Feb 2022 05:10:22 -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 cr18si8922223ejc.858.2022.02.01.05.10.19; Tue, 01 Feb 2022 05:10:22 -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=vKhIxvfL; 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 15A4C68B318; Tue, 1 Feb 2022 15:07:47 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-oln040092071051.outbound.protection.outlook.com [40.92.71.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 50F2F68B2AF for ; Tue, 1 Feb 2022 15:07:42 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AIwPjQkUc3aHNiCbUodE5BxCN2XgB5OfNAQbcksNWXgdKcQg8IUqEu1dRmd+s5HremRfY54wqKO+mawHJGuLytkJkTsuO0GbwnAXmxscdhXMhUJ2ddmp7PbY74xvmokcDyavzbZ3YdSeOdYj4Q/VyGynBiYTgRNu8Mc65oWKZoPGKnlg+PpVwDuVAOTc3a47fsWhbf90Gx4VAHTmC9oWnpVJgxYx399bF/U133mQnh2QYEp/0FZ4x4gzMo6uLcvg5hMSp6UqA09DuPNxJmQ9tjGyOK2TN7drGQZVtxUfr/E0ZmZKKSwUgAmP6DkKNQ/TsbtPKPFVZLb4Rr2pXmuyDg== 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=gvtPO/wpf3MEkkoJtmLVVMmbPyddZDiuxm2PDRi0GF8=; b=SU75YpG7/J0ewOA9/p3cVOz5RJzHtqvohnLnhAsH8qkhj1102e0PFQnZNJkeQnmsz1fztSV3qakc+E2rj4tIU6JaeUtIODMq6YvX3yl2L4XsAoYo8JVccqYeZI8ROAPpszng3NFTRb/oOcT5AGxmLvWSS/wZKVzNdXMTy6aGA/M8S3Njb9L9acR6YopZJftIxxD9BLBk55r0o0qIffxXXS7NEBoLjnMp5RL3wj4b8pvYRRQlXoavksLnDmzc65mJ8OMH8mYlKaYv5m5l1mhMydJRKTLTXj2gvtM9EX5ggFeLcH8vagWz4Mju7UAInXxmLQiqDI/R+DHmiXMzNlVQWw== 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=gvtPO/wpf3MEkkoJtmLVVMmbPyddZDiuxm2PDRi0GF8=; b=vKhIxvfLF/VHfw51jcAmT3ckBAYTHHBCLkNAf1DyXORR5Lih1CR2T2nZmHfeMVBy4YAPDrzftu0cx4lEA/pTlDLxIJ2EO3d4rUryATBP/aS7PoQDxgsxXRg+DT3Z5j9TN+qON3wtJZajOJPet5XddmsHbYaCKIGug3KnZW2dBEVRk7qJFm2O5dWyvTp/XQW1wn+KM0V5UanJnSvRCdzf3tNEQxKPww9yVtzCnuhDAQbHhdqgXhp8fGExaqoB/+KoRzbTxdxjYlNwk+KnZHgAK48Mxz/giS7jhDPmxsIpW2mjyrX2edJuNJFu1GSRTeuhwmNy2R2dwj4BuoEdtnttHA== 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:38 +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:38 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:12 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [yh+3WTNdo1tFhZmAKy7TjUMZEY7r4Irh] 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-14-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6bc7cdba-2b8e-4e50-ca2b-08d9e583d265 X-MS-TrafficTypeDiagnostic: AM9PR03MB6948:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZdiB4x3LLdT6l1MB7/iFP5AwIGf8U5bmdCct4ouY8t4AIzQraIq0l8IgUbfdEdjpBuOcT7JbuKq8b/qlJhw9XX7uajpIVwHjxSqqMFukVSs/OjL4Ihc0VipT68ESZshlCftROo993EjEEl4FQvDiwhZRt9xMKBQB4oM7J0felDNv9Cf7RBogzkRAfJQHuVzSo7hBG7VFLzGViFYwkBeRhU/DFAC6gdcv5Rv1jVPYCb1bCC8kyFD9Mftekv7f0KjodF93Ee4+K5j/zs52snTGVDUBAfpoVrhcTG7F8g21Vsy3X/K3veWPEOAP4XPN3Oldn8WeZXNyol0UOqnVYE2tc9JbZIqzAgSnwaVEfeLPuvWggNxfrbOAdkGpeHs2IIu8Gl3KpijmJcKOQwDufGr1ZJE3NeL0h943yNK34a13vLfI3f8FawuFy6PtkrC3PmrStgqcqIR+FLe6v+P6YkG/qttNm9b9wfW35U7d8pA9TDTC6ID/lOMyFDHjFNnfFAoJ4uyYoElFCNVfDG72DR1lt4Q1ihwCjj7N5gOUmB/46mMz7ZZHoGieyhv9BFzjRz0q X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1pHVbDIGH5ZaJv65an/nPc2sdGy9zmS94ujVwMJpgcjAWMtTqq01UZ/oZMatnE/U62EmIp+RUUJD/UnAeNxbMflFGWAHK8eoUthsbK1X9dTpGSHiFE66YahDTbCPktbu0dIJzrgoA0jA/k0sDM5yEiWl5cQ/hXqiZZo4Ch2aEEn+Kr/sOkS1bz3FH7qbzKRoGCxSUo6LUNV12r5EdxTpmF+iXoLZaSzlLDFzZzc2oX/WShgP7x71+vUiuWAJ4hbMRvSgUEmTb1l56a84dVOyIu1HDCTE2Ci9Javx7y5DRcNpC0WD4jcWozcMEWu5MmSBNBZRb2VVSFnF5hkPo+ZxgM8/eRRnXXLb0GqYBSXXNDcSC5ASpo7ZRev5oBLHlR/JvuUwBm52FwzkvdBqtFAMjChSvTGBwuwaUWLJ7t7iXmJcwrfnsGsl7DLmNmwmT9qiDeGm6mTkDMxaD0XG9Si4vgYSBSM/KFEBA/RXNl98eohzLYPTTWFknwqoHZ7NKwtuhmIH/1zuRwyRHICpNAaH63yRDqQ1bZfSSHoZEUxxhVzFXTltbkR1/SZb44oVSlYMErq9/RwoKlodAvkvguJHVui69wJ88FD8JpMptniU2ueVnT4mfvKBsZGYVqInifhlVWidKyOexMW+SfSXEQAdT6lrJ6ktOLxFSyZaDu4pRXRtIHxdbAeAvchfrVUhYJ+wY4Qyp6V1g/5rtY2Xt0hQeE5li1j7YJ55Tz70Yf9bEv9ZkilUk9Hy1JAJKdCvM+6V2OkBV0O4CIDYT3IYqxxcZVscEUC/WCXtRoekl/Gpz+FWqQS8ZHIKghNBxI82Nw42JLkE6c6xpMx3gbLqYXu6PtepJxu4EgglVBquy5lbIHGRf6VfS6CAV6VC2W+rgP4f28g/uo1IfKPxRtwPldt6WsuvFqHsfjtWb+pWkPbc9bxsaiakJLEuGMD8VGQtkEljJQkdmNAZe3H+xg94f9mwkg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6bc7cdba-2b8e-4e50-ca2b-08d9e583d265 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:38.4092 (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 15/69] avcodec/msmpegenc: Add MSMPEG4EncContext and move ac_stats to it 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: Rm9cCbcevdE0 Also avoid the allocation by making it part of the context. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo.h | 2 -- libavcodec/mpegvideo_enc.c | 7 ------- libavcodec/msmpeg4enc.c | 26 +++++++++++++++----------- libavcodec/msmpeg4enc.h | 8 ++++++++ libavcodec/wmv2enc.c | 8 ++++---- 5 files changed, 27 insertions(+), 24 deletions(-) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 5e406b9a9c..f5c9789fea 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -422,8 +422,6 @@ typedef struct MpegEncContext { int per_mb_rl_table; int esc3_level_length; int esc3_run_length; - /** [mb_intra][isChroma][level][run][last] */ - int (*ac_stats)[2][MAX_LEVEL+1][MAX_RUN+1][2]; int inter_intra_pred; int mspel; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 07dc575a5b..0dde4edc73 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -813,12 +813,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) ff_pixblockdsp_init(&s->pdsp, avctx); ff_qpeldsp_init(&s->qdsp); - if (s->msmpeg4_version) { - int ac_stats_size = 2 * 2 * (MAX_LEVEL + 1) * (MAX_RUN + 1) * 2 * sizeof(int); - if (!(s->ac_stats = av_mallocz(ac_stats_size))) - return AVERROR(ENOMEM); - } - if (!(avctx->stats_out = av_mallocz(256)) || !FF_ALLOCZ_TYPED_ARRAY(s->q_intra_matrix, 32) || !FF_ALLOCZ_TYPED_ARRAY(s->q_chroma_intra_matrix, 32) || @@ -944,7 +938,6 @@ av_cold int ff_mpv_encode_end(AVCodecContext *avctx) ff_mpv_picture_free(avctx, &s->new_picture); av_freep(&avctx->stats_out); - av_freep(&s->ac_stats); if(s->q_chroma_intra_matrix != s->q_intra_matrix ) av_freep(&s->q_chroma_intra_matrix); if(s->q_chroma_intra_matrix16 != s->q_intra_matrix16) av_freep(&s->q_chroma_intra_matrix16); diff --git a/libavcodec/msmpeg4enc.c b/libavcodec/msmpeg4enc.c index 31920b7f0d..c436f78f9d 100644 --- a/libavcodec/msmpeg4enc.c +++ b/libavcodec/msmpeg4enc.c @@ -148,8 +148,9 @@ av_cold void ff_msmpeg4_encode_init(MpegEncContext *s) ff_thread_once(&init_static_once, msmpeg4_encode_init_static); } -static void find_best_tables(MpegEncContext * s) +static void find_best_tables(MSMPEG4EncContext *ms) { + MpegEncContext *const s = &ms->s; int i; int best = 0, best_size = INT_MAX; int chroma_best = 0, best_chroma_size = INT_MAX; @@ -169,9 +170,9 @@ static void find_best_tables(MpegEncContext * s) int last; const int last_size= size + chroma_size; for(last=0; last<2; last++){ - int inter_count = s->ac_stats[0][0][level][run][last] + s->ac_stats[0][1][level][run][last]; - int intra_luma_count = s->ac_stats[1][0][level][run][last]; - int intra_chroma_count= s->ac_stats[1][1][level][run][last]; + int inter_count = ms->ac_stats[0][0][level][run][last] + ms->ac_stats[0][1][level][run][last]; + int intra_luma_count = ms->ac_stats[1][0][level][run][last]; + int intra_chroma_count= ms->ac_stats[1][1][level][run][last]; if(s->pict_type==AV_PICTURE_TYPE_I){ size += intra_luma_count *rl_length[i ][level][run][last]; @@ -197,7 +198,7 @@ static void find_best_tables(MpegEncContext * s) if(s->pict_type==AV_PICTURE_TYPE_P) chroma_best= best; - memset(s->ac_stats, 0, sizeof(int)*(MAX_LEVEL+1)*(MAX_RUN+1)*2*2*2); + memset(ms->ac_stats, 0, sizeof(ms->ac_stats)); s->rl_table_index = best; s->rl_chroma_table_index= chroma_best; @@ -215,7 +216,9 @@ static void find_best_tables(MpegEncContext * s) /* write MSMPEG4 compatible frame header */ void ff_msmpeg4_encode_picture_header(MpegEncContext * s, int picture_number) { - find_best_tables(s); + MSMPEG4EncContext *const ms = (MSMPEG4EncContext*)s; + + find_best_tables(ms); align_put_bits(&s->pb); put_bits(&s->pb, 2, s->pict_type - 1); @@ -553,6 +556,7 @@ static void msmpeg4_encode_dc(MpegEncContext * s, int level, int n, int *dir_ptr * escape coding (same as H.263) and more VLC tables. */ void ff_msmpeg4_encode_block(MpegEncContext * s, int16_t * block, int n) { + MSMPEG4EncContext *const ms = (MSMPEG4EncContext*)s; int level, run, last, i, j, last_index; int last_non_zero, sign, slevel; int code, run_diff, dc_pred_dir; @@ -603,10 +607,10 @@ void ff_msmpeg4_encode_block(MpegEncContext * s, int16_t * block, int n) } if(level<=MAX_LEVEL && run<=MAX_RUN){ - s->ac_stats[s->mb_intra][n>3][level][run][last]++; + ms->ac_stats[s->mb_intra][n>3][level][run][last]++; } - s->ac_stats[s->mb_intra][n > 3][40][63][0]++; //esc3 like + ms->ac_stats[s->mb_intra][n > 3][40][63][0]++; //esc3 like code = get_rl_index(rl, last, run, level); put_bits(&s->pb, rl->table_vlc[code][1], rl->table_vlc[code][0]); @@ -679,7 +683,7 @@ const AVCodec ff_msmpeg4v2_encoder = { .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, .priv_class = &ff_mpv_enc_class, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, - .priv_data_size = sizeof(MpegEncContext), + .priv_data_size = sizeof(MSMPEG4EncContext), .init = ff_mpv_encode_init, .encode2 = ff_mpv_encode_picture, .close = ff_mpv_encode_end, @@ -693,7 +697,7 @@ const AVCodec ff_msmpeg4v3_encoder = { .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, .priv_class = &ff_mpv_enc_class, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, - .priv_data_size = sizeof(MpegEncContext), + .priv_data_size = sizeof(MSMPEG4EncContext), .init = ff_mpv_encode_init, .encode2 = ff_mpv_encode_picture, .close = ff_mpv_encode_end, @@ -707,7 +711,7 @@ const AVCodec ff_wmv1_encoder = { .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, .priv_class = &ff_mpv_enc_class, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, - .priv_data_size = sizeof(MpegEncContext), + .priv_data_size = sizeof(MSMPEG4EncContext), .init = ff_mpv_encode_init, .encode2 = ff_mpv_encode_picture, .close = ff_mpv_encode_end, diff --git a/libavcodec/msmpeg4enc.h b/libavcodec/msmpeg4enc.h index 12f8f44232..98044913b1 100644 --- a/libavcodec/msmpeg4enc.h +++ b/libavcodec/msmpeg4enc.h @@ -25,6 +25,14 @@ #include "config.h" #include "mpegvideo.h" #include "put_bits.h" +#include "rl.h" + +typedef struct MSMPEG4EncContext { + MpegEncContext s; + + /** [mb_intra][isChroma][level][run][last] */ + unsigned ac_stats[2][2][MAX_LEVEL + 1][MAX_RUN + 1][2]; +} MSMPEG4EncContext; void ff_msmpeg4_encode_init(MpegEncContext *s); void ff_msmpeg4_encode_picture_header(MpegEncContext *s, int picture_number); diff --git a/libavcodec/wmv2enc.c b/libavcodec/wmv2enc.c index 2622f833b0..227947c146 100644 --- a/libavcodec/wmv2enc.c +++ b/libavcodec/wmv2enc.c @@ -28,7 +28,7 @@ #include "wmv2enc.h" typedef struct WMV2EncContext { - MpegEncContext s; + MSMPEG4EncContext msmpeg4; WMV2Context common; int j_type_bit; int j_type; @@ -43,7 +43,7 @@ typedef struct WMV2EncContext { static int encode_ext_header(WMV2EncContext *w) { - MpegEncContext *const s = &w->s; + MpegEncContext *const s = &w->msmpeg4.s; PutBitContext pb; int code; @@ -70,13 +70,13 @@ static int encode_ext_header(WMV2EncContext *w) static av_cold int wmv2_encode_init(AVCodecContext *avctx) { WMV2EncContext *const w = avctx->priv_data; - MpegEncContext *const s = &w->s; + MpegEncContext *const s = &w->msmpeg4.s; s->private_ctx = &w->common; if (ff_mpv_encode_init(avctx) < 0) return -1; - ff_wmv2_common_init(&w->s); + ff_wmv2_common_init(s); avctx->extradata_size = 4; avctx->extradata = av_mallocz(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); From patchwork Tue Feb 1 13:06:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33990 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp603149iov; Tue, 1 Feb 2022 05:10:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJy5+gIwvp/O97JvxFz2cuLu8FTXLjPAlrZXSndaJ3lJF24c+9F3judd2A/bGMd/DNRGmjyG X-Received: by 2002:a17:907:16a9:: with SMTP id hc41mr21913664ejc.289.1643721034737; Tue, 01 Feb 2022 05:10:34 -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 di18si9811272ejc.397.2022.02.01.05.10.34; Tue, 01 Feb 2022 05:10:34 -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=oAwRCu72; 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 139AB68B316; Tue, 1 Feb 2022 15:07:48 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2064.outbound.protection.outlook.com [40.92.89.64]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B815768B2EC for ; Tue, 1 Feb 2022 15:07:42 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YG2h2iy/tDch1ThvWS0ja+fdMkYN1mWeZCNr2/EC2xTT06kWFK7xMia4b34w6XqR5A0mJzAm0SQ6iqU/4PpIARhLJb93AVQ9bCE5Bf/Z2i4hzP31XOc1rp+QjA8UBG5B5a0h8d8KtXWAiaus/C1h6d3eu3/LkbXC9HKjtCn9+a5VB5+2siiuEvfg8pVbz4Ns07eLqLq8bzyhVQhsFd/I2LDB7S8qiOXV4ii1R1CWDo4UliICvCs+A47zk+AD+qM+50j0FN04ubZckGnZ21/XhFnDYiKG+oYqsfgTlHR8NFpnTKvVVwCFTqG/GBbEizyHAY2/oz8l8sYvR5CRHPx2fw== 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=GoZFfqygUY8+iCbCz/qM5b+58EzLE5e2Q6SJxO2Y8yo=; b=haFxbUPZVh+PBi/Vbj8tk6kQzlbXEwgkZQcs5U0TBSdXlMZZ8w4f4UyvYPKyVGSf8jn3tkc+xyS9khMfDfHhp8mqb7v6CsQYYEEjyY4AU5/cFM1FUXqRUXO3pmNbvsWnaxnKSEie7p1I8odw4lgQXuSHESnpICDgDVgzx+y5vctj2FAiq0zpUH08CnKs6LU8KsRp8MhI+paQhMqhtlqTOuNyYvrju2KZF09fLbKo7RsXX41Oz33XmQ/wEdicvFKyupEzHcRlT2I2cPcAzAjcZgoASfYCMN3C9RW2stALwzR3Q3H//vVEs/hkIVGB4rVvfv2HiwUj09lCqYcd7M3w7g== 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=GoZFfqygUY8+iCbCz/qM5b+58EzLE5e2Q6SJxO2Y8yo=; b=oAwRCu72AUoLMEvgptZNhcvSTmeYzpq1CEgXIBDLdofjt82DvT58ZJNmxMZFaXhqwIBxJAeamy6p3s6nHP95SkboNjJaEJ1N0KrTA0OTTL36YnsX5/6Jf9oAAx4L59VwvCkX8GHCW5DZr5ysE3ue87KcDKdnils9RjAsCAeVqu72tOwUre9VKDtdEJBTNOx3PHZQkRzlj0/da+WPKcFOjlxxT2VRk7rAUlvi0qH2SHQ1iAJU7ZgGBQ7ze9Mhy4y5H6MeVc+Y3XhCDIstBTJ++2upvLdK007/jeML818SWhzCkZK8mViXeiTWTZnc4AXtAC/RHemMZmLG+GRF8ZAxBA== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR03MB5700.eurprd03.prod.outlook.com (2603:10a6:208:16f::32) 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:39 +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:39 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:13 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [igyq/P1qonf3tcDkWsBwGM/8H9/d8lrY] 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-15-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4b5c1184-2810-4a5e-6edc-08d9e583d2f2 X-MS-TrafficTypeDiagnostic: AM0PR03MB5700:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qbBNL+IrqxUotS1SuvmmO/WneBWIwL6IhJzg49paSkEer/jzD+f+RgWvYz91koIieLZSOdHo8LwQGUr48TuhhJ3GPlV8wbstppydSAS7lzYYo+MrP8fx864SKecz8NjoIg3TuJmhJnDS4dTPusFb0ucXykHddLiQuGaBoLXSdlxRRhLeVRieNsuPCxzc1bdhwfj1l4UWGoMNCC6UF53XAp5cOKbIAjBgZPMPru+jqE5CAVDZ7+u/9loftSodGpoWh20fSKYxRQRrfb8d4h8vvdlCvFG5MieZWpdpTfl2EybGsi+3kuDLjjgiuljPfyULRMPQnIykjzG8hVAQc0IV6d6da7snzYl2EgZ8ei7FPANpP4ebpwnbljKhjUDvOQbNnvgECazo7az206S840UARlKWxskEGV/SIzgUVZFMCe1EDCSaZEsMkbDUxXQbZRWaULaQ/B0SznGId/JyZKIjlg8lgaz+fRYdgno0otoJkN3sqQrUscyYlLJHuSvus71ZYmQ+kaNLoMw/6HleIBSSZCDEYSvkCgTec+Qguhf/rmOLsNBJtcJEfHEzJ/8IwmH1 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1xIaRj531lU/Jr/UiP+4AZFbD5Z0gNO6j1Ul8hZltGEM+BitmvA9f+VFQ3jcKMRgNVD1ViryldGAQyb/xvdDJYM0YzkSgJjbJ2ExXokJ4WlYG0i6q2/J/wdlPUj6W43lz3FMhOl9gDCya5lg1NVVTrgLVpgKEcvKnfdryAeSv79U+UZste7WkeN+3aE72Ml03ppXgc3xlf8xdHsMHt8Z7+o7v/SPuVIaAlzHmWPwjcEVbbcpmrztBcglsyXAOyN/oZg3o/C4HrIszIpe4Es0beLpClbFEyENI389gD1ZQv0s6PZVJiHn8qnSXIjc+gkBo/ymjSsC7SDm0Oe6p1UfsMIh/MNC+qd+BNzzugAf6/RHgXThSZEX/wfMPzB93NSHxMRdQmXg4uEt+vvJBRQLSIMtLrZhSjXFnuOOAWiP5mQI2PxfSFW2R9YRiOEwB9ATIAtqYWPZiIIufHL6h0Wr6NQcFJaxsDTnDygGU8xqzypsMK0uTMPz9573Au5Fmiit6IfLpsztY29GqTVsTIuC3fKC9WCa3KMnw6pJ3GXuw22qlZyrST34w7fkXgR0DlJZ/uqO0MEXB+iLX8a2ByDStc6FZAonUBfrK+gjcpazTTqNnHQqEvvibpk2ypLk+LTyq509Sv3Rw3+yWa14Y9IWhtH/uiLgDZfj9XW1E24UyqIG6YdGF8FXfGaGHD0YxmZDKKwTO30E28HZQz0TM4dXP77TjKsDH1uBHutiG8JqTBEIXiYqGY/tKJTpBkm/yrK+SR7ZV2Kr8VRdYrDCQ+3caBPj1X4Tk1r+AwYxEWMBbq2VEdUghLuHDgIUe7YeuyR2t3/YvLVjnPBI9dhHhLz73lp1lEne7QrTeiKvqOTETXtrxZljq/KMiNJM6sE2uJPNeZctu3CWr9qQ4y6jyfffXz7sBlpmfX7WX6owXueqgb9yqN79HAfy3R1b24LEj2pxZWXmrhNlPJ9kIM6TLwU7XQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4b5c1184-2810-4a5e-6edc-08d9e583d2f2 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:39.3309 (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: AM0PR03MB5700 Subject: [FFmpeg-devel] [PATCH v2 16/69] avcodec/h263.h: Move encoder-only stuff to a new header h263enc.h 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: RsTDSA/ElQGs Signed-off-by: Andreas Rheinhardt --- libavcodec/h263.h | 101 ---------------------------- libavcodec/h263enc.h | 130 +++++++++++++++++++++++++++++++++++++ libavcodec/ituh263enc.c | 1 + libavcodec/mpeg4videodec.c | 1 + libavcodec/mpeg4videoenc.c | 1 + libavcodec/mpegvideo_enc.c | 1 + libavcodec/msmpeg4dec.c | 1 + libavcodec/msmpeg4enc.c | 1 + libavcodec/rv20enc.c | 2 +- libavcodec/snowenc.c | 2 +- libavcodec/svq1enc.c | 1 + 11 files changed, 139 insertions(+), 103 deletions(-) create mode 100644 libavcodec/h263enc.h diff --git a/libavcodec/h263.h b/libavcodec/h263.h index 6dd5d2295a..27a5f31c59 100644 --- a/libavcodec/h263.h +++ b/libavcodec/h263.h @@ -20,119 +20,18 @@ #ifndef AVCODEC_H263_H #define AVCODEC_H263_H -#include #include "libavutil/rational.h" #include "mpegvideo.h" -#include "h263data.h" #define FF_ASPECT_EXTENDED 15 #define H263_GOB_HEIGHT(h) ((h) <= 400 ? 1 : (h) <= 800 ? 2 : 4) av_const int ff_h263_aspect_to_info(AVRational aspect); -void ff_h263_encode_mb(MpegEncContext *s, - int16_t block[6][64], - int motion_x, int motion_y); -void ff_h263_encode_picture_header(MpegEncContext *s, int picture_number); -void ff_h263_encode_gob_header(MpegEncContext * s, int mb_line); int16_t *ff_h263_pred_motion(MpegEncContext * s, int block, int dir, int *px, int *py); -void ff_h263_encode_init(MpegEncContext *s); void ff_h263_init_rl_inter(void); void ff_h263_update_motion_val(MpegEncContext * s); void ff_h263_loop_filter(MpegEncContext * s); -void ff_h263_encode_mba(MpegEncContext *s); -void ff_init_qscale_tab(MpegEncContext *s); - - -void ff_clean_h263_qscales(MpegEncContext *s); -void ff_h263_encode_motion(PutBitContext *pb, int val, int f_code); - - -static inline int h263_get_motion_length(int val, int f_code){ - int bit_size, code, sign; - - if (val == 0) { - return 1; /* ff_mvtab[0][1] */ - } else { - bit_size = f_code - 1; - /* modulo encoding */ - val = sign_extend(val, 6 + bit_size); - sign = val >> 31; - val = (val ^ sign) - sign; /* val = FFABS(val) */ - val--; - code = (val >> bit_size) + 1; - - return ff_mvtab[code][1] + 1 + bit_size; - } -} - -static inline void ff_h263_encode_motion_vector(MpegEncContext * s, int x, int y, int f_code){ - if (s->avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT) { - skip_put_bits(&s->pb, - h263_get_motion_length(x, f_code) - +h263_get_motion_length(y, f_code)); - }else{ - ff_h263_encode_motion(&s->pb, x, f_code); - ff_h263_encode_motion(&s->pb, y, f_code); - } -} - -static inline int get_p_cbp(MpegEncContext * s, - int16_t block[6][64], - int motion_x, int motion_y){ - int cbp, i; - - if (s->mpv_flags & FF_MPV_FLAG_CBP_RD) { - int best_cbpy_score= INT_MAX; - int best_cbpc_score= INT_MAX; - int cbpc = (-1), cbpy= (-1); - const int offset= (s->mv_type==MV_TYPE_16X16 ? 0 : 16) + (s->dquant ? 8 : 0); - const int lambda= s->lambda2 >> (FF_LAMBDA_SHIFT - 6); - - for(i=0; i<4; i++){ - int score= ff_h263_inter_MCBPC_bits[i + offset] * lambda; - if(i&1) score += s->coded_score[5]; - if(i&2) score += s->coded_score[4]; - - if(score < best_cbpc_score){ - best_cbpc_score= score; - cbpc= i; - } - } - - for(i=0; i<16; i++){ - int score= ff_h263_cbpy_tab[i ^ 0xF][1] * lambda; - if(i&1) score += s->coded_score[3]; - if(i&2) score += s->coded_score[2]; - if(i&4) score += s->coded_score[1]; - if(i&8) score += s->coded_score[0]; - - if(score < best_cbpy_score){ - best_cbpy_score= score; - cbpy= i; - } - } - cbp= cbpc + 4*cbpy; - if ((motion_x | motion_y | s->dquant) == 0 && s->mv_type==MV_TYPE_16X16){ - if(best_cbpy_score + best_cbpc_score + 2*lambda >= 0) - cbp= 0; - } - - for (i = 0; i < 6; i++) { - if (s->block_last_index[i] >= 0 && ((cbp >> (5 - i))&1)==0 ){ - s->block_last_index[i]= -1; - s->bdsp.clear_block(s->block[i]); - } - } - }else{ - cbp= 0; - for (i = 0; i < 6; i++) { - if (s->block_last_index[i] >= 0) - cbp |= 1 << (5 - i); - } - } - return cbp; -} #endif /* AVCODEC_H263_H */ diff --git a/libavcodec/h263enc.h b/libavcodec/h263enc.h new file mode 100644 index 0000000000..31f00665ce --- /dev/null +++ b/libavcodec/h263enc.h @@ -0,0 +1,130 @@ +/* + * H.263 encoder header + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef AVCODEC_H263ENC_H +#define AVCODEC_H263ENC_H + +#include +#include "h263data.h" +#include "mpegvideo.h" + +void ff_h263_encode_init(MpegEncContext *s); +void ff_h263_encode_picture_header(MpegEncContext *s, int picture_number); +void ff_h263_encode_gob_header(MpegEncContext * s, int mb_line); +void ff_h263_encode_mb(MpegEncContext *s, + int16_t block[6][64], + int motion_x, int motion_y); +void ff_h263_encode_mba(MpegEncContext *s); + +void ff_init_qscale_tab(MpegEncContext *s); +void ff_clean_h263_qscales(MpegEncContext *s); + +void ff_h263_encode_motion(PutBitContext *pb, int val, int f_code); + + +static inline int h263_get_motion_length(int val, int f_code) +{ + int bit_size, code, sign; + + if (val == 0) { + return 1; /* ff_mvtab[0][1] */ + } else { + bit_size = f_code - 1; + /* modulo encoding */ + val = sign_extend(val, 6 + bit_size); + sign = val >> 31; + val = (val ^ sign) - sign; /* val = FFABS(val) */ + val--; + code = (val >> bit_size) + 1; + + return ff_mvtab[code][1] + 1 + bit_size; + } +} + +static inline void ff_h263_encode_motion_vector(MpegEncContext * s, + int x, int y, int f_code) +{ + if (s->avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT) { + skip_put_bits(&s->pb, + h263_get_motion_length(x, f_code) + + h263_get_motion_length(y, f_code)); + } else { + ff_h263_encode_motion(&s->pb, x, f_code); + ff_h263_encode_motion(&s->pb, y, f_code); + } +} + +static inline int get_p_cbp(MpegEncContext * s, + int16_t block[6][64], + int motion_x, int motion_y){ + int cbp; + + if (s->mpv_flags & FF_MPV_FLAG_CBP_RD) { + int best_cbpy_score = INT_MAX; + int best_cbpc_score = INT_MAX; + int cbpc = (-1), cbpy = (-1); + const int offset = (s->mv_type == MV_TYPE_16X16 ? 0 : 16) + (s->dquant ? 8 : 0); + const int lambda = s->lambda2 >> (FF_LAMBDA_SHIFT - 6); + + for (int i = 0; i < 4; i++) { + int score = ff_h263_inter_MCBPC_bits[i + offset] * lambda; + if (i & 1) score += s->coded_score[5]; + if (i & 2) score += s->coded_score[4]; + + if (score < best_cbpc_score) { + best_cbpc_score = score; + cbpc = i; + } + } + + for (int i = 0; i < 16; i++) { + int score= ff_h263_cbpy_tab[i ^ 0xF][1] * lambda; + if (i & 1) score += s->coded_score[3]; + if (i & 2) score += s->coded_score[2]; + if (i & 4) score += s->coded_score[1]; + if (i & 8) score += s->coded_score[0]; + + if (score < best_cbpy_score) { + best_cbpy_score = score; + cbpy = i; + } + } + cbp = cbpc + 4 * cbpy; + if (!(motion_x | motion_y | s->dquant) && s->mv_type == MV_TYPE_16X16) { + if (best_cbpy_score + best_cbpc_score + 2 * lambda >= 0) + cbp= 0; + } + + for (int i = 0; i < 6; i++) { + if (s->block_last_index[i] >= 0 && !((cbp >> (5 - i)) & 1)) { + s->block_last_index[i] = -1; + s->bdsp.clear_block(s->block[i]); + } + } + } else { + cbp = 0; + for (int i = 0; i < 6; i++) { + if (s->block_last_index[i] >= 0) + cbp |= 1 << (5 - i); + } + } + return cbp; +} + +#endif diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c index 9253d60a16..70ac1f643b 100644 --- a/libavcodec/ituh263enc.c +++ b/libavcodec/ituh263enc.c @@ -35,6 +35,7 @@ #include "mpegvideo.h" #include "mpegvideodata.h" #include "h263.h" +#include "h263enc.h" #include "h263data.h" #include "mathops.h" #include "mpegutils.h" diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 2aea845580..c0eaa00eba 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -36,6 +36,7 @@ #include "mpeg4video.h" #include "mpeg4videodata.h" #include "h263.h" +#include "h263data.h" #include "h263dec.h" #include "profiles.h" #include "thread.h" diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index 27e16c3b72..8a1a6cbcc8 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -27,6 +27,7 @@ #include "mpegutils.h" #include "mpegvideo.h" #include "h263.h" +#include "h263enc.h" #include "mpeg4video.h" #include "mpeg4videodata.h" #include "profiles.h" diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 0dde4edc73..a57de01944 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -51,6 +51,7 @@ #include "h261enc.h" #include "h263.h" #include "h263data.h" +#include "h263enc.h" #include "mjpegenc_common.h" #include "mathops.h" #include "mpegutils.h" diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c index a7870f252f..08abece9ec 100644 --- a/libavcodec/msmpeg4dec.c +++ b/libavcodec/msmpeg4dec.c @@ -30,6 +30,7 @@ #include "msmpeg4dec.h" #include "libavutil/imgutils.h" #include "h263.h" +#include "h263data.h" #include "h263dec.h" #include "mpeg4video.h" #include "msmpeg4data.h" diff --git a/libavcodec/msmpeg4enc.c b/libavcodec/msmpeg4enc.c index c436f78f9d..16e19083da 100644 --- a/libavcodec/msmpeg4enc.c +++ b/libavcodec/msmpeg4enc.c @@ -35,6 +35,7 @@ #include "libavutil/thread.h" #include "mpegvideo.h" #include "h263.h" +#include "h263enc.h" #include "internal.h" #include "mpeg4video.h" #include "msmpeg4.h" diff --git a/libavcodec/rv20enc.c b/libavcodec/rv20enc.c index 19b6aab278..204cd03a24 100644 --- a/libavcodec/rv20enc.c +++ b/libavcodec/rv20enc.c @@ -27,8 +27,8 @@ #include "mpegvideo.h" #include "mpegvideodata.h" -#include "h263.h" #include "h263data.h" +#include "h263enc.h" #include "put_bits.h" #include "rv10.h" diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index df31eb8132..e169ae601d 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -34,7 +34,7 @@ #include "mathops.h" #include "mpegvideo.h" -#include "h263.h" +#include "h263enc.h" static av_cold int encode_init(AVCodecContext *avctx) { diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c index 11cbd97185..9cef3d8ef6 100644 --- a/libavcodec/svq1enc.c +++ b/libavcodec/svq1enc.c @@ -32,6 +32,7 @@ #include "me_cmp.h" #include "mpegvideo.h" #include "h263.h" +#include "h263enc.h" #include "internal.h" #include "mpegutils.h" #include "packet_internal.h" From patchwork Tue Feb 1 13:06:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33991 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp603537iov; Tue, 1 Feb 2022 05:11:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQHI/1hdEtqc+a3qWA4GYqC4D2v7eUcHKpx4GPUhzUcScQkkERdAVixR3FaKzaKclha7XF X-Received: by 2002:a17:906:4695:: with SMTP id a21mr3884669ejr.709.1643721050181; Tue, 01 Feb 2022 05:10:50 -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 oz9si6287804ejc.814.2022.02.01.05.10.49; Tue, 01 Feb 2022 05:10:50 -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=KUCp2+Xm; 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 0454668B326; Tue, 1 Feb 2022 15:07:49 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2064.outbound.protection.outlook.com [40.92.89.64]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E596C68B2FA for ; Tue, 1 Feb 2022 15:07:42 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ndD1FLLaeYimRAGr/8ZuZzox1Yulir5qIJ9AGnjzEF8PA9u3PX32uBAuJogdYSuOfaao7s/i0wDWOeF8rlQojr3qCAxoMd99egYh2YjAiODP2LptgzwO6IYz65TpnYmYRCyz8QvKX5CaNRJi5H780jPnSvfBqcTRQ2KN+DHreRK/C/Xsf9C63HXbN0xCIJeu2e1IwduJgB4SpoldgRKEX7zyW8Qs4N9LT6zlGJaDAZ0Tx59n0vec1UWX+jot2OniAI6q8/2fxmGZH3D2gansaJ5jRgCnTPF8NOfuOiGJV9B10eZDxn74wreaaJY9O6XmWg6BKE8sXrm1wr7DqC2hmg== 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=N1AgVmChjsmsKNZdaAXCxekFeMSOv/nm+Phec5drUD8=; b=c2ZcDCiS8IqZf43nITqM6Hd20FLjDGiFRRHnEfDNGnE6UreHuBQjN9J/iwIl2jKHGdOB8MnV1eMtvdaWVKp3umuxuBf+xreNfnB6T4fn1HGKU+LTmePsG8ZezyOFkx4LbAE42lxHPAl8FknuTxDEFyvMAlrQhUD4sgkNF264fUVWussTE797SR5CT9peYFllT1D3L/8+UD+WDHmylFM4weF94XjUM6MFFArpEfqdJiaqf1BKKCaoArTVNdzXUWqBNTgrORosKL2lvMi29lwlaFZSev4XAWeHULZHJwmbMpOrxsRr17EQR0f0BLVjmTO4uCOf/tEjlweUsXWj6TIzEA== 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=N1AgVmChjsmsKNZdaAXCxekFeMSOv/nm+Phec5drUD8=; b=KUCp2+XmlnQov9L96rFZruluJb6zLIHeeHGnFDWjO/wIX+2/Il0mmBj4maq8s8p4DHD6AQjfGfZpUvViFCD56ONhmEDDR4QGE2BIF5c3HN+wFBz+/FZaeZoIXz/b/v6haUL8pAMITS5f18Vy175tKnzAcnKOqeFQysuMOZ8Yo4DweeKbl2aTdAfydR/WbRYeFz3s7x8HLIMiUMuzmvcG2iT5Cc2AE1LbUCjPes5WkBYbhXauTHsQ0rG/CC8HIN7IZhOA5bmvInwXycYNsQ3RHp1rU/2f8NckuPQd3Si/bB8hEwtAFz5lBRp7icTXrQfiCGPnHBtcmJM/8tZkm32r1A== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR03MB5700.eurprd03.prod.outlook.com (2603:10a6:208:16f::32) 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:41 +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:41 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:14 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [3s+x0v4QVGhOv1PDs7uVjDprvDqdPG9T] 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-16-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b887adca-0158-4445-d9c7-08d9e583d3f8 X-MS-TrafficTypeDiagnostic: AM0PR03MB5700:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ONLjpp7VKemW83HcCO05rwfGyfCEf0MfA9or5TIMqtctsHN8tQZOdiQSiX5QsetgyKKlY1Hd/Spy0hjZhOyQGKX7EaBVl8aBC8scbYtAT9WJMSMPxHkaVolDsP1nrfIa73gP+UbMcoq7BjyAlIfE6yXbHhGLBLic/yu0+LfxGxIQF48Ug67baLr6QkCxWSvUSdhez5RaSh9AGG9LB6keaFuDLNmgJL7yZvY+CvgdHqHw3qdyjABz7Rdw77fW+dE4Jxn4S4jQlwTOySq9u2rMgZUWrQ9PCwVwWyelbM8YlN16peupz82AocVHurODHLZWFqDY0ifbYHy6q5WPrb1HFBYapcQfdhX+9BjtWvHb8rXY/pX/Sy9iGw5mpjRRgjgz761craKB/OHPpDVglHyqtW5yH14JRlEA+uFwc8zvN0at2RGwq+vjM4VmslPU3mG/VJrRPQIs/fmCxiQDNfhBu0SNqzaOdvpMx0fSczNyxa8LAf43jRLo2EOKazTPjTGVfzcU7udlSt9F5eFVa2LkqSYKCpU3l9B7PYIvLWYFhgTB9WmaMd/ppngdTkCl/pHn X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SVl4MnzDDgacACc5XB7LTFPfxh9PxdC2fnO3yVzeFZOuzEuhaKXtrcmAfB6PLeBltjek8IAtorMzmaBr2jxn578mRnct8aC5rxcpPpz+rA04hS4y1BAbf3O1NmHi2TAbsS2tjjLwwQs3A0HR/Tv/aGEC8dxVKU1r6B1h9rOT8aZTFRvZY1Ut/Nz0m9culgoR5JgxK+9ayTeEfsaxINyuAEtt7/tk3eOxfavIytZ6orHfS4Yiyjh1R3pu8aveG58Qbgf/B6i5Nn7izogF4okjGpuPWL46fdTWF1HtRb6Or6dAevoi5poWzfdBD35SfggHn99bGrskHSi0bfMynH44VdlIqruPSeahD/Mn/OXLK7b7qKDt1GjrHdP1Vs4yUx6siuaEq4S/R/74rr8KW+DhPItmW0iIRbrRHR36aM/OUksRHx/SFaeEoPsLWLDnPFvsZbnF/YBSXvei1Kr22GVBcrCJ6pQ28xH9JNy4h4sxT/hiFxoHRk/MMvzqeg5RJqxeL2zuRt1YQkZ69qHr26MITOk3OWUTDywaybLZmze3/HKpoP3RV0GkE46lgDgSXWCzAMJOYxDn8r7XEd3oqG+gvd+WJLBmphbVuohDd1sOz3Y8HRml1VTNv97SUI9Ja6TDF8jDQCFPZ1+Bs9osT7aWi9Mxup27f+ijjTiwFaqfFUjEoKlEDrfyGPbhbhzAwwx2an7E/vpRiyuPGlLZ5ziL/PZJKVMuVmpakGcAHU0qwCnXIJZFLBwVTrddtEtx8eEmgnLoiZ9QgKReyiJO0pRSt84eufVUZkdRo5TgfAI6FtJ4fV+fwIz9xxqPMoz70Ev4otq2CguspGfHPAAZ8In4oIrXF2s/bLv4A4YUPvuSP32KmeujMcvu5BUiEXm/NXH47HoSjNq8CSyT5zMRkhoid9N7ZtRqol+pD6b1MqXWE9xXknyNuvgrd+nZRuor4g9sP4CrIfkGHJGTl4MsyqSasg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b887adca-0158-4445-d9c7-08d9e583d3f8 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:41.0663 (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: AM0PR03MB5700 Subject: [FFmpeg-devel] [PATCH v2 17/69] avcodec/mpeg4video.h: Move decoder-only parts to a new header 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: uD34WBQYWdqk Signed-off-by: Andreas Rheinhardt --- libavcodec/h263dec.c | 1 + libavcodec/ituh263dec.c | 1 + libavcodec/mpeg4video.h | 66 ----------------------- libavcodec/mpeg4video_parser.c | 1 + libavcodec/mpeg4videodec.c | 1 + libavcodec/mpeg4videodec.h | 99 ++++++++++++++++++++++++++++++++++ libavcodec/mpegvideo.c | 2 +- libavcodec/msmpeg4dec.c | 2 +- libavcodec/nvdec_mpeg4.c | 1 + libavcodec/vaapi_mpeg4.c | 2 +- libavcodec/vdpau_mpeg4.c | 2 +- 11 files changed, 108 insertions(+), 70 deletions(-) create mode 100644 libavcodec/mpeg4videodec.h diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index 5a54d57bbc..99dc7a74d2 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -41,6 +41,7 @@ #include "internal.h" #include "mpeg_er.h" #include "mpeg4video.h" +#include "mpeg4videodec.h" #if FF_API_FLAG_TRUNCATED #include "mpeg4video_parser.h" #endif diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c index 7d7a1f01a2..b09cc9a2db 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -48,6 +48,7 @@ #include "rv10.h" #include "mpeg4video.h" #include "mpegvideodata.h" +#include "mpeg4videodec.h" // The defines below define the number of bits that are read at once for // reading vlc values. Changing these may improve speed and data cache needs diff --git a/libavcodec/mpeg4video.h b/libavcodec/mpeg4video.h index 14fc5e1396..bee52b2c29 100644 --- a/libavcodec/mpeg4video.h +++ b/libavcodec/mpeg4video.h @@ -70,86 +70,20 @@ /* smaller packets likely don't contain a real frame */ #define MAX_NVOP_SIZE 19 -typedef struct Mpeg4DecContext { - MpegEncContext m; - - /// number of bits to represent the fractional part of time - int time_increment_bits; - int shape; - int vol_sprite_usage; - int sprite_brightness_change; - int num_sprite_warping_points; - /// sprite trajectory points - uint16_t sprite_traj[4][2]; - /// sprite shift [isChroma] - int sprite_shift[2]; - - // reversible vlc - int rvlc; - /// could this stream contain resync markers - int resync_marker; - /// time distance of first I -> B, used for interlaced B-frames - int t_frame; - - int new_pred; - int enhancement_type; - int scalability; - - /// QP above which the ac VLC should be used for intra dc - int intra_dc_threshold; - - /* bug workarounds */ - int divx_version; - int divx_build; - int xvid_build; - int lavc_build; - - int vo_type; - - /// flag for having shown the warning about invalid Divx B-frames - int showed_packed_warning; - /** does the stream contain the low_delay flag, - * used to work around buggy encoders. */ - int vol_control_parameters; - int cplx_estimation_trash_i; - int cplx_estimation_trash_p; - int cplx_estimation_trash_b; - - int rgb; - - int32_t block32[12][64]; - // 0 = DCT, 1 = DPCM top to bottom scan, -1 = DPCM bottom to top scan - int dpcm_direction; - int16_t dpcm_macroblock[3][256]; -} Mpeg4DecContext; - - -void ff_mpeg4_decode_studio(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, - uint8_t *dest_cr, int block_size, int uvlinesize, - int dct_linesize, int dct_offset); void ff_mpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64], int motion_x, int motion_y); -void ff_mpeg4_pred_ac(MpegEncContext *s, int16_t *block, int n, - int dir); void ff_set_mpeg4_time(MpegEncContext *s); int ff_mpeg4_encode_picture_header(MpegEncContext *s, int picture_number); -int ff_mpeg4_decode_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb, - int header, int parse_only); void ff_mpeg4_encode_video_packet_header(MpegEncContext *s); void ff_mpeg4_clean_buffers(MpegEncContext *s); void ff_mpeg4_stuffing(PutBitContext *pbc); void ff_mpeg4_init_partitions(MpegEncContext *s); void ff_mpeg4_merge_partitions(MpegEncContext *s); void ff_clean_mpeg4_qscales(MpegEncContext *s); -int ff_mpeg4_decode_partitions(Mpeg4DecContext *ctx); int ff_mpeg4_get_video_packet_prefix_length(MpegEncContext *s); -int ff_mpeg4_decode_video_packet_header(Mpeg4DecContext *ctx); -int ff_mpeg4_decode_studio_slice_header(Mpeg4DecContext *ctx); void ff_mpeg4_init_direct_mv(MpegEncContext *s); -int ff_mpeg4_workaround_bugs(AVCodecContext *avctx); -int ff_mpeg4_frame_end(AVCodecContext *avctx, const uint8_t *buf, int buf_size); /** * @return the mb_type diff --git a/libavcodec/mpeg4video_parser.c b/libavcodec/mpeg4video_parser.c index 1f89bae490..3d0d0e4714 100644 --- a/libavcodec/mpeg4video_parser.c +++ b/libavcodec/mpeg4video_parser.c @@ -26,6 +26,7 @@ #include "parser.h" #include "mpegvideo.h" #include "mpeg4video.h" +#include "mpeg4videodec.h" #if FF_API_FLAG_TRUNCATED /* Nuke this header when removing FF_API_FLAG_TRUNCATED */ #include "mpeg4video_parser.h" diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index c0eaa00eba..a437f233ec 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -35,6 +35,7 @@ #include "mpegvideodata.h" #include "mpeg4video.h" #include "mpeg4videodata.h" +#include "mpeg4videodec.h" #include "h263.h" #include "h263data.h" #include "h263dec.h" diff --git a/libavcodec/mpeg4videodec.h b/libavcodec/mpeg4videodec.h new file mode 100644 index 0000000000..65d846aed0 --- /dev/null +++ b/libavcodec/mpeg4videodec.h @@ -0,0 +1,99 @@ +/* + * MPEG-4 decoder internal header. + * Copyright (c) 2000,2001 Fabrice Bellard + * Copyright (c) 2002-2010 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_MPEG4VIDEODEC_H +#define AVCODEC_MPEG4VIDEODEC_H + +#include + +#include "get_bits.h" +#include "mpegvideo.h" + + +typedef struct Mpeg4DecContext { + MpegEncContext m; + + /// number of bits to represent the fractional part of time + int time_increment_bits; + int shape; + int vol_sprite_usage; + int sprite_brightness_change; + int num_sprite_warping_points; + /// sprite trajectory points + uint16_t sprite_traj[4][2]; + /// sprite shift [isChroma] + int sprite_shift[2]; + + // reversible vlc + int rvlc; + /// could this stream contain resync markers + int resync_marker; + /// time distance of first I -> B, used for interlaced B-frames + int t_frame; + + int new_pred; + int enhancement_type; + int scalability; + + /// QP above which the ac VLC should be used for intra dc + int intra_dc_threshold; + + /* bug workarounds */ + int divx_version; + int divx_build; + int xvid_build; + int lavc_build; + + int vo_type; + + /// flag for having shown the warning about invalid Divx B-frames + int showed_packed_warning; + /** does the stream contain the low_delay flag, + * used to work around buggy encoders. */ + int vol_control_parameters; + int cplx_estimation_trash_i; + int cplx_estimation_trash_p; + int cplx_estimation_trash_b; + + int rgb; + + int32_t block32[12][64]; + // 0 = DCT, 1 = DPCM top to bottom scan, -1 = DPCM bottom to top scan + int dpcm_direction; + int16_t dpcm_macroblock[3][256]; +} Mpeg4DecContext; + +int ff_mpeg4_decode_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb, + int header, int parse_only); +void ff_mpeg4_decode_studio(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, + uint8_t *dest_cr, int block_size, int uvlinesize, + int dct_linesize, int dct_offset); +int ff_mpeg4_decode_partitions(Mpeg4DecContext *ctx); +int ff_mpeg4_decode_video_packet_header(Mpeg4DecContext *ctx); +int ff_mpeg4_decode_studio_slice_header(Mpeg4DecContext *ctx); +int ff_mpeg4_workaround_bugs(AVCodecContext *avctx); +void ff_mpeg4_pred_ac(MpegEncContext *s, int16_t *block, int n, + int dir); +int ff_mpeg4_frame_end(AVCodecContext *avctx, const uint8_t *buf, int buf_size); + + +#endif diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 0e0f035526..c39cf12c40 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -40,7 +40,7 @@ #include "mpeg_er.h" #include "mpegutils.h" #include "mpegvideo.h" -#include "mpeg4video.h" +#include "mpeg4videodec.h" #include "mpegvideodata.h" #include "qpeldsp.h" #include "thread.h" diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c index 08abece9ec..bc96b86507 100644 --- a/libavcodec/msmpeg4dec.c +++ b/libavcodec/msmpeg4dec.c @@ -32,7 +32,7 @@ #include "h263.h" #include "h263data.h" #include "h263dec.h" -#include "mpeg4video.h" +#include "mpeg4videodec.h" #include "msmpeg4data.h" #include "vc1data.h" #include "wmv2dec.h" diff --git a/libavcodec/nvdec_mpeg4.c b/libavcodec/nvdec_mpeg4.c index 739b049933..a134423382 100644 --- a/libavcodec/nvdec_mpeg4.c +++ b/libavcodec/nvdec_mpeg4.c @@ -22,6 +22,7 @@ #include "avcodec.h" #include "mpeg4video.h" +#include "mpeg4videodec.h" #include "nvdec.h" #include "decode.h" diff --git a/libavcodec/vaapi_mpeg4.c b/libavcodec/vaapi_mpeg4.c index 71e155154c..6800499c85 100644 --- a/libavcodec/vaapi_mpeg4.c +++ b/libavcodec/vaapi_mpeg4.c @@ -23,7 +23,7 @@ #include "h263.h" #include "hwconfig.h" #include "internal.h" -#include "mpeg4video.h" +#include "mpeg4videodec.h" #include "mpegvideo.h" #include "vaapi_decode.h" diff --git a/libavcodec/vdpau_mpeg4.c b/libavcodec/vdpau_mpeg4.c index 93b25beb1f..6e082eefc6 100644 --- a/libavcodec/vdpau_mpeg4.c +++ b/libavcodec/vdpau_mpeg4.c @@ -25,7 +25,7 @@ #include "avcodec.h" #include "hwconfig.h" -#include "mpeg4video.h" +#include "mpeg4videodec.h" #include "vdpau.h" #include "vdpau_internal.h" From patchwork Tue Feb 1 13:06:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33992 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp603621iov; Tue, 1 Feb 2022 05:11:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJwCR88jrw6QIqCcSqvxZqpU8T3/62FhUfnxw0NMuebhvabm3NmyLSS87GA31iLYkYuxCenD X-Received: by 2002:a05:6402:c15:: with SMTP id co21mr24920845edb.185.1643721065775; Tue, 01 Feb 2022 05: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 l14si10040741edb.241.2022.02.01.05.11.05; Tue, 01 Feb 2022 05: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=iez+QnVC; 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 D6B3E68B325; Tue, 1 Feb 2022 15:07:49 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2028.outbound.protection.outlook.com [40.92.89.28]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2ABC568B2FD for ; Tue, 1 Feb 2022 15:07:43 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ninVxk0u3Tvw6/IYXwhPOnJ9DxGZJ/dIgequ6xY0B+JvsyueFeSx9YqxR6T6Apc5IkuEocUVhMJ7Ta28E9ZnnurkCJh9Z06F7oOrmg2G4fbZEO48yNA8vA1me00LOYIEk8aPfQJ5CO1sbpOzy3m1Z+64kCOACpySvKhDvx8J4u50xTxGIDIOBmG0T/3oWxtnMsAVaeXVE/C+buZnkpAtsgf3406TkmZyyL/Th0Dyq9yX+KiUFURVgpEcXUG+5e/J+rbsgA1cB65S2PVKEITEmbti+hVZr5TJ4scvUIsFdhhVe2VhPUjGFbG6d3TJXYnUrsjVD2ScoLJ1WBGhzIKVMA== 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=7hRxEg/aUINXVBmqu5B2bb7WRImR9T+bKSPNSoeRJLw=; b=g6PRQ+grI1ARSdxZqmIfE2jZxJRpg5UT0bYxOMhIkbj/5AVAxuT28NRCJ8j2UrrF+IL42PQiyztho98W7Iz7WnJzOsfvMJSGzIHNj2Sz5BGY1oYkk8uF6Sp/4fihm/fosssBGQxl+k94fXCEbWv+8VuzSGc4YbHxquqDlYnZWnCsaOTlFQ1EGMzCZ686d3THknVDhEVjUhsPqd5DtjmzDfraLFpFyys6+TaTJtHNkIvwq5TfBq6M3LTdKAg/0VUM/PidaGa0H5wCeywZH/V/bb7zye9wHTyBZBVCXMXOzvPmDRpTjVgw27ns6jGPHiiR9E6quYNosRcSKq9zJlysVw== 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=7hRxEg/aUINXVBmqu5B2bb7WRImR9T+bKSPNSoeRJLw=; b=iez+QnVC+UxG8nauBfvHdPpLKV1jIpin2pEyrAfIstFql/AGsR3hqZ4EJ9vuRIrSAi5AOoYs0ZOqKra0g0J4RK3fn4DoH1gXtHJfRc6KbX0sd0Ei4ZYwz7/IFVD3iM+712FC5chhXhOLxs14WZB88Bx3r43upZsACin1UEYNtmBTtdRC9CKdUkvjx6EbHyP5/DUsi3Ldn2hcbmplWV2Y+IzG8/eL3g7KAhhqTbNX7e+vYmjUc3Q5pJ/gMYf9hSsTjjTyuGB4G9zZvVxelzFCxcd0Ze+n4u1tkoSNDYTuW1ycxG7gFyp/KzoHAuTYAgQP06csF8juVLfbyjuT12/PUQ== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR03MB5700.eurprd03.prod.outlook.com (2603:10a6:208:16f::32) 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:42 +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:42 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:15 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [jk85MIXY+MyemMvnMenmOWyZyzwMFIOL] 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-17-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 097e398b-bc7c-48b8-22e9-08d9e583d49b X-MS-TrafficTypeDiagnostic: AM0PR03MB5700:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BvzqYQwJnUh4cVKSH/EMBM+mxWAnmo3C8FT8h2TO9QEpWkVllgnnnXQ1THKTTk+dZa20p2ef+2sv6gysmS4bdPhPe+55NrsbQm/W2UmHpRGkDfXWcwkbLX2HpHR/kZTdcfWSV2zoMlJkj7DrzgjbltpDBEbHZNrE0XG2Ii/xmgkR0u9pi3IZyqdZtdZiaNAuLPNmB5Rljl6MSpnUeXFE6PjiR7ymlvQjnu9viM1C4qADrPk6BQmyF7ltSXpXTThEUm/xok8aNCp1ocOVG1ih7tTNN+EcYtdblG1nnCzJ1YIDNrbaxzFy0ZZ/zn6bRIz7cUtxcQD89FnYAwO5EF6sIC8iuDCaLV9i1MH5hvVmftCeJsK79XN7tha92gp21HsVy1I3zkGcatqSOnSqa1Kav8qfvjPRJ8r6qsF5wI4r5b2xIoG8ct5tqpPD2SC+KuEjtR7BPJg1DxwPc1bSW4ItJpzv1wwb5lYLYCcJzHDqceZKJTxJ7XKIPxhTfBomB7fxXrPHihoVo9e+wPbNWDrkZQSLj+S1Y/m+JOP0duAMEN0y0tdvdHLY3s9YYvURmaP6 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OgnVIiQWA/UhIMv0lBmBaC53DrUVLy2Vs5ZlWlWeDzgEhl0uOCeG1900X3+cfOMnLp8Sq0ikSUWY+9i8j92dWZp9nozpa1EHSecjNH5E7Wy40JFBcq4KNL8rXap2ue9mzGy98aHEURx1y0a45BU8/BLiQoXC6v3GW7A4Z0syxlfItX9UJj+gMy90FQ9Vf5QMH60NPS2QVYKtK4GQzFk0yWzqhmevYGTc3RqqZa9keI3IanHoZMfeyttvA/eIjw3BiqbsZq4MRqv6YXO4zc62zu9zPVL5NPR7V1RCRYWuj1hp+fVsRaQYSd+2DMN5KhhCh5rPBtiZoDAZyomwvvrSybm45gq0xik14m18G8Cr7mSRiOddaniEGz6FYsbti6XeqVeuGSvI+Hnq70kb45j9/x83TutS2QGLwNdiUU8v5o9jL77Fp5uIL2vERxdhkWLBJH+BM0CYaIvAeu04VYjycINM1hU5NO1e7JYp+SbmE19CVxCosgq1HKI5/v0cjWB6vlMKgOTG4WnoV003DcjyLVtsSqm5y8fh9pFgz8Bne1hCfgKA6s0neif0aj+iIxo4ztGoGeZ4xsNxtHFuEotUWkemhDJAsTvDegPHxZJeNlxuf/YEslgc+MAhcqgBEVM3T1zEk40vJr9kX4gaYuMHr20yNOH9OjSaf2tM+cnaDebV6+B2yUs+3/WBEkZafEKqOT5a46tR+qfGdJxkmmVnQ5eAz7Sz7vXV017pnNSx1BklwOG79F1cD4yaf2NcDvwGY/T24kvAtypgLFXmBB0JOkR7lT+ySTjgDWQTAHVz7JUNXRDbcz4KmSvmGUf68AdvtToRw06n5ey1mdCQVmwn+3dzXVLMIVQpvR/cT9LHUsruwmFDmh/KQq6+v7mE2sgadCHlf/GBScsT/PlAps13FobLa40o4lqoiUhKY7CWbR3EfTGpgA0nph/Ix/6tT5nGjlYANxWw3SWukh3DgQ3LdA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 097e398b-bc7c-48b8-22e9-08d9e583d49b 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:42.0986 (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: AM0PR03MB5700 Subject: [FFmpeg-devel] [PATCH v2 18/69] avcodec/mpeg4video.h: Move encoder-only parts in a new file 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: gFPa592XXuNv Signed-off-by: Andreas Rheinhardt --- libavcodec/mpeg4video.h | 12 ----------- libavcodec/mpeg4videoenc.c | 1 + libavcodec/mpeg4videoenc.h | 43 ++++++++++++++++++++++++++++++++++++++ libavcodec/mpegvideo_enc.c | 1 + 4 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 libavcodec/mpeg4videoenc.h diff --git a/libavcodec/mpeg4video.h b/libavcodec/mpeg4video.h index bee52b2c29..ab65280756 100644 --- a/libavcodec/mpeg4video.h +++ b/libavcodec/mpeg4video.h @@ -25,7 +25,6 @@ #include -#include "get_bits.h" #include "mpegvideo.h" // shapes @@ -70,18 +69,7 @@ /* smaller packets likely don't contain a real frame */ #define MAX_NVOP_SIZE 19 -void ff_mpeg4_encode_mb(MpegEncContext *s, - int16_t block[6][64], - int motion_x, int motion_y); -void ff_set_mpeg4_time(MpegEncContext *s); -int ff_mpeg4_encode_picture_header(MpegEncContext *s, int picture_number); - -void ff_mpeg4_encode_video_packet_header(MpegEncContext *s); void ff_mpeg4_clean_buffers(MpegEncContext *s); -void ff_mpeg4_stuffing(PutBitContext *pbc); -void ff_mpeg4_init_partitions(MpegEncContext *s); -void ff_mpeg4_merge_partitions(MpegEncContext *s); -void ff_clean_mpeg4_qscales(MpegEncContext *s); int ff_mpeg4_get_video_packet_prefix_length(MpegEncContext *s); void ff_mpeg4_init_direct_mv(MpegEncContext *s); diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index 8a1a6cbcc8..d55667c1a6 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -30,6 +30,7 @@ #include "h263enc.h" #include "mpeg4video.h" #include "mpeg4videodata.h" +#include "mpeg4videoenc.h" #include "profiles.h" /* The uni_DCtab_* tables below contain unified bits+length tables to encode DC diff --git a/libavcodec/mpeg4videoenc.h b/libavcodec/mpeg4videoenc.h new file mode 100644 index 0000000000..243cd297a2 --- /dev/null +++ b/libavcodec/mpeg4videoenc.h @@ -0,0 +1,43 @@ +/* + * MPEG-4 encoder internal header. + * Copyright (c) 2000,2001 Fabrice Bellard + * Copyright (c) 2002-2010 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_MPEG4VIDEOENC_H +#define AVCODEC_MPEG4VIDEOENC_H + +#include + +#include "mpegvideo.h" +#include "put_bits.h" + +void ff_mpeg4_encode_mb(MpegEncContext *s, + int16_t block[6][64], + int motion_x, int motion_y); +void ff_set_mpeg4_time(MpegEncContext *s); +int ff_mpeg4_encode_picture_header(MpegEncContext *s, int picture_number); + +void ff_mpeg4_encode_video_packet_header(MpegEncContext *s); +void ff_mpeg4_stuffing(PutBitContext *pbc); +void ff_mpeg4_init_partitions(MpegEncContext *s); +void ff_mpeg4_merge_partitions(MpegEncContext *s); +void ff_clean_mpeg4_qscales(MpegEncContext *s); + +#endif diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index a57de01944..460462d997 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -66,6 +66,7 @@ #include "flv.h" #include "mpeg4video.h" #include "mpeg4videodata.h" +#include "mpeg4videoenc.h" #include "internal.h" #include "bytestream.h" #include "wmv2enc.h" From patchwork Tue Feb 1 13:06:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33993 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp603799iov; Tue, 1 Feb 2022 05:11:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJyg76ntWuDeQd6iZLB63OcWknXqSxeGv7mQDpxPBvSJJhQNCBx090v0FsUOKSzSfJ5u4dMv X-Received: by 2002:a05:6402:3587:: with SMTP id y7mr24602575edc.224.1643721080870; Tue, 01 Feb 2022 05:11:20 -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 j8si9978463edp.379.2022.02.01.05.11.20; Tue, 01 Feb 2022 05:11:20 -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=rH4uoZlV; 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 DEC2968B2F1; Tue, 1 Feb 2022 15:07:50 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2028.outbound.protection.outlook.com [40.92.89.28]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5F3F468B2FD for ; Tue, 1 Feb 2022 15:07:44 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZEba3r6DmcZRxbIQ05V8OxfpxqP+8B5lnTWSrxTWmJy5pwgtviYjaH89csbkHvtlSoDbpbAUIfr4HbMO0H4s/+hAhxgVpksZuxm7a7rjajp+Uf5Q4MmiIIgRNzHtzHqBsKHwcm5x1+GCqb27S9Xiop7qTMvpeVLjm/eipAIM5cbvokqCBHlkmdKVU0TZr06OkvIdexSTxsbSBLB3/+32m38dWH5iRL0o9wjYxOjwxlIx+6BDVw2PloVvw8kaQKr4tjY5J24Ys7rBDnI4VDW31OSoPE37hrAIbLpvsG8rRXa2QrHQudS/+eQQvwfKt4MTSjmcbl6xp13jCkWJluqiwA== 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=TIdbaDGJm4ETMNicXGzcmfsS0Qu1oIfz9XBoY+mirzU=; b=PtzUt2G+ewAhlsnqiY8EztAf+kUM7V+VqRIBMC9tKneT9c7ey63C8Uh8aO97818fxPR0ASpENaGcciu4qrBM3AYgZka5gLEGdp+BlwyhGQnp6GCbI/tei+eom/vWI9q4lBkMbKKfl+7114Cyppqm5LFOyC6kFbXLbOwXobEbbfYf1mmLJjOHQXaEmhUnL1lyFXCqHedNb8W4BtU5W6IsGSfDU5uYJbB4cf2sh3urU367mGH6n9gnZ8RkzIiq37Yc8zX1MbBXYAR/9lT0FYg+WzDOYlodI5sIuHhxsJRSD3tOcuJ/i9BZKE0IknAc1/eXoEBfv1Pezy9n0Z2AWMJjfw== 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=TIdbaDGJm4ETMNicXGzcmfsS0Qu1oIfz9XBoY+mirzU=; b=rH4uoZlVXU6sxzH2m3WODrQN0r5xXI1CWw0MTJRH3SqaXI1+q6PiZXvOdccVcZy2tQJTeiwPueSh/iU5EWjyNUT0jPv4CbAIT1Up3Z/u12JFn0plWcXE3okfUgu2RyH1TX10G6wilQs38FhdMEKN/HZ5vqBj4rti9mX3pn21NRy6xtV3kJnFXIz4SNfSLPjBO+RG1kdywTWdFfcwgRbFSUGEFnLw59D4qqBqF5htlGpoqytCD4ACc8JLcorqoRM7DPVGJGXvFshQkUJtFNV4ekTwca9I+NZ4rEzCYfrVkQCv3DBTWJ4nExN7e8A0PdLwU7gl91zQSUR/oqtuMjZd5w== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR03MB5700.eurprd03.prod.outlook.com (2603:10a6:208:16f::32) 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:43 +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:43 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:16 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [zoWHIJHM/e5brmNiAyeWJxlhtxq8BUs+] 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-18-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5b031f2e-378b-4931-29f7-08d9e583d52a X-MS-TrafficTypeDiagnostic: AM0PR03MB5700:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 31IFHg711YWCSR7sufQQkfI4xVPqmI7YgYq0V4k14mayAarTGPPfH7qIdk/3zU3YjzexS1hnqtWimh3933F4SvaGGhAVl4fGbMSpY+GiSqrHDt1Pz0XU8T3AdsEZ+U97WVPnbNm2Qbtv/fTxtALVw9+tta1CDk1LuDsjwjhBa0emGiJymhIcOGovJw2K5nUC0V6VJP+KK+3RN7WvHWH4EBb9YegRusRjuDKzwebazkoiigWqSfr7oVw1s5dxSFCnTC8UA0PwHMCOaDnv8D79+1PO4zubjhjVlO03X4V8Gc+J5Iy6dWIScGx83TJc/eY7kYHYpwY8K9CyCO5sYBoe09sFr+RBEaHSbiqhOlln1uuF5HqutoTTDnwJjhNe9aIL5NhI7fq7EqQqZqLgqPoDu6wdZHqRNiwpCup3h2WH7nLk7HD8Yb/CAmDVgl47ySMH+pLI6JIykA1YlBl3iPSB0KC7TyX8IJTKfBQmC/Jd2vyqgH5uqZ2zmW96sajVksBjiuWh+0/aJ4ittQZMciwJUyXN8AM8gDJD7yuFyUZ37t9e+HBvfvHsdgwsMnAYhNdf X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 23UoD5GPr6+8hkBXHA2lULVeLxfOxqusKJjE3wCiJ52dBMP6BzO9/4JGowTC3NTPQy/KPYIZDuwd9pU9dbGOayMjP+hOXaIymXCngaW2xAwwz7uJI6PKyTQKBVSpfWgo+unvR1yrDO7ZYqREkhMn6ckU2fkEBjimyYQnT0E4XGWs5w276+XxUzcJV97o1ObTuCsRThjEDDQ7dUpGXPkvRfLab2uVxM6BYb+OuY+EALO9wi0x7O7knKAz34BFcIE7iUXjKbs1d4vUUAwhKo5ibPPgoZiFrxf77yhlLNleQHOKDUUadJ1dML5CPEN+fR1j01K0Qrtn63Lz87cVBKnQodHVrx9U5Q5Mi+yloQlnsEYD23KZWHKXp/kkUvwvMsuwY3c22rK3xrrVOv9c+pG2ViXOtNTDttbH5bw1ivybS7L9W9pKF1f9N2/8Ox3lNSaYn6NNBXjGtQPLY/S1Z0L89VTzsPs/sxevwb+mKsd90ZB9T15CXCdXLQbsHiLkrNf1yFHa6kNTUYYiHCzZZZzSSowKWE4F8m7BGIfiWMNN0klBw7v9wkcXu6zWR67R0L7jDwuBn4YXhLznuAKNFbFhqBR2q84ZFfd3p9dKPgsGhPwSAHVPtwxNyKqMQqs/SBXaux52t7pdTLpWqgQ0C5N099D8J/Y2UK46FaU3MaX2PPctHSsu9GI59G7gIJIRoGVp7vFszkTBjJEniK228xvlTGFVAvMZza2ZoLBhE5yJPlDM8myym5oHid4SzaJ5R+31/lapTk2EmPWOxDszfelkcmuyhMT+YqGQNt453I1XHSnQGmfgYkxXR2HRL78MUbtmSPK2NoejOvTg1SpgnNiK2HR+K/f5eaR324RgEiiZIO7O9TDbrB18PzaVo9fJ68aeJjX9mfv3RcGOd2rPazSyKASslbILz7G/6ZvqoSLAOR+R9fPp6HUas5jonWX10LNV5cRryvhCj9d0dq0VtJqnvA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5b031f2e-378b-4931-29f7-08d9e583d52a 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:43.0516 (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: AM0PR03MB5700 Subject: [FFmpeg-devel] [PATCH v2 19/69] avcodec/flv.h: Split header into encoder-only and decoder-only headers 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: IOVkbPlPjRXi Signed-off-by: Andreas Rheinhardt --- libavcodec/flvdec.c | 2 +- libavcodec/flvdec.h | 29 +++++++++++++++++++++++++++++ libavcodec/flvenc.c | 2 +- libavcodec/{flv.h => flvenc.h} | 9 +++------ libavcodec/h263dec.c | 2 +- libavcodec/ituh263dec.c | 3 --- libavcodec/ituh263enc.c | 2 +- libavcodec/mpegvideo_enc.c | 2 +- 8 files changed, 37 insertions(+), 14 deletions(-) create mode 100644 libavcodec/flvdec.h rename libavcodec/{flv.h => flvenc.h} (87%) diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c index 2bd86b5b47..62bb32bc62 100644 --- a/libavcodec/flvdec.c +++ b/libavcodec/flvdec.c @@ -20,7 +20,7 @@ #include "libavutil/imgutils.h" -#include "flv.h" +#include "flvdec.h" #include "h263dec.h" #include "mpegvideo.h" #include "mpegvideodata.h" diff --git a/libavcodec/flvdec.h b/libavcodec/flvdec.h new file mode 100644 index 0000000000..3527d82beb --- /dev/null +++ b/libavcodec/flvdec.h @@ -0,0 +1,29 @@ +/* + * FLV decoder header. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_FLVDEC_H +#define AVCODEC_FLVDEC_H + +#include "get_bits.h" +#include "mpegvideo.h" + +int ff_flv_decode_picture_header(MpegEncContext *s); + +#endif /* AVCODEC_FLVDEC_H */ diff --git a/libavcodec/flvenc.c b/libavcodec/flvenc.c index 158b399c40..7271d64af3 100644 --- a/libavcodec/flvenc.c +++ b/libavcodec/flvenc.c @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "flv.h" +#include "flvenc.h" #include "h263data.h" #include "mpegvideo.h" #include "mpegvideodata.h" diff --git a/libavcodec/flv.h b/libavcodec/flvenc.h similarity index 87% rename from libavcodec/flv.h rename to libavcodec/flvenc.h index 561cfe0baa..aaa0fcffab 100644 --- a/libavcodec/flv.h +++ b/libavcodec/flvenc.h @@ -1,5 +1,5 @@ /* - * FLV specific private header. + * FLV encoder header. * * This file is part of FFmpeg. * @@ -18,10 +18,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef AVCODEC_FLV_H -#define AVCODEC_FLV_H +#ifndef AVCODEC_FLVENC_H +#define AVCODEC_FLVENC_H -#include "get_bits.h" #include "mpegvideo.h" #include "put_bits.h" @@ -29,6 +28,4 @@ void ff_flv_encode_picture_header(MpegEncContext *s, int picture_number); void ff_flv2_encode_ac_esc(PutBitContext *pb, int slevel, int level, int run, int last); -int ff_flv_decode_picture_header(MpegEncContext *s); - #endif /* AVCODEC_FLV_H */ diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index 99dc7a74d2..bf2e9b1583 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -31,7 +31,7 @@ #include "avcodec.h" #include "error_resilience.h" -#include "flv.h" +#include "flvdec.h" #include "h263.h" #include "h263dec.h" #if FF_API_FLAG_TRUNCATED diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c index b09cc9a2db..5588840c3d 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -28,7 +28,6 @@ */ #define UNCHECKED_BITSTREAM_READER 1 -#include #include "libavutil/attributes.h" #include "libavutil/imgutils.h" @@ -40,11 +39,9 @@ #include "h263.h" #include "h263data.h" #include "h263dec.h" -#include "internal.h" #include "mathops.h" #include "mpegutils.h" #include "unary.h" -#include "flv.h" #include "rv10.h" #include "mpeg4video.h" #include "mpegvideodata.h" diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c index 70ac1f643b..c8a95574d2 100644 --- a/libavcodec/ituh263enc.c +++ b/libavcodec/ituh263enc.c @@ -34,12 +34,12 @@ #include "avcodec.h" #include "mpegvideo.h" #include "mpegvideodata.h" +#include "flvenc.h" #include "h263.h" #include "h263enc.h" #include "h263data.h" #include "mathops.h" #include "mpegutils.h" -#include "flv.h" #include "internal.h" /** diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 460462d997..7c5d013200 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -63,7 +63,7 @@ #include "faandct.h" #include "thread.h" #include "aandcttab.h" -#include "flv.h" +#include "flvenc.h" #include "mpeg4video.h" #include "mpeg4videodata.h" #include "mpeg4videoenc.h" From patchwork Tue Feb 1 13:06:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33994 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp603975iov; Tue, 1 Feb 2022 05:11:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJzEm+vGqg7AHtCfKYZunkr8veJZXTHAu9iFemQ4frGqpIjx1tVd4nHNur0nie2swOvgXcFh X-Received: by 2002:a17:907:3e1d:: with SMTP id hp29mr20678198ejc.701.1643721095026; Tue, 01 Feb 2022 05:11:35 -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 s10si10531739edd.190.2022.02.01.05.11.33; Tue, 01 Feb 2022 05:11:35 -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=CXenC5ta; 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 D52EE68B339; Tue, 1 Feb 2022 15:07:51 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2081.outbound.protection.outlook.com [40.92.89.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D9D6768B2BA for ; Tue, 1 Feb 2022 15:07:45 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fkCQwCKhgBpKetoYR64789otO8VOX0Py6sD9woOgPf3zpP/6d2NfWdPT6H0cGMKsvXPsA31GPNQ9PuDPZyQfRyBDUPsYgLdccf9+FfEH4qJCt7EU4GLlL40sYs0/KKSthGrChGKXKkafCndSbK82TTP0MpdBGXojyOLjvVLn31xN1/O08kFUdwIsgYzyJA7FH0uLS5NR6U4SmDy0xDSaZ0zUf+IBFjrZlhhesz43qVoROhalhARdagNKz+5xn9d61ooTodvOlCKxvPtgL8oqbe0C2sYGwFLTF3xzbpPveI6WTJUplZFSHYV9JKyWZQS9pXyZmJ/3gkKq+fT6VR+WzQ== 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=AHtoiIrGl378GWT2D7Iyy+hhAqqNIKxMqkb3Q3JeLrE=; b=DfmkxPmSD2TF3z1Ha3clqUyTlflpirb3OosSNreNPIsLC0wzi24+JmWQ2GHP/PTPb06brfVsCJhC3wyY/MooVxqRmLQalTUrqS42QV6MgvHPFSS7kRkkRyZkuYNw6hIMn0f/WFDkP+p7jhG4OcVFiVX4IW8Lr/a8m4244Ri/hn0Kz4oruB/jBcJEKF9Z1DDdC8L8KZkuFZZRp6BSX2SCVWZtAGfO3WTnNxyEOzFWKNyfZCNOLzzN+A0Flz7PX/W3k+RpwvSRkkQqxwp3pWKX+mUUMmdlRU5KIu2I/r4rNqFGsPFnSuEa+Q2DwDwM2PVNMrIcx8waKcUJTkcrvBDTPQ== 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=AHtoiIrGl378GWT2D7Iyy+hhAqqNIKxMqkb3Q3JeLrE=; b=CXenC5taEeGU5EJb78VESXxBhY4SOEqcT/YQfsLyOfQvj+c70uKMJGm7omstGb9xFS34yzyt5+LoMtpZ/t+FgISthKX0UeZMeEbe/uXuw1DQ3+x4n4QUWks/G5464lsJ+8oLpnqfTboOL0u0AnsnOq5qm8YdQEWW3R9vN+O/oc/JpfzB3QTDpvdGkEpItReQgqrlAHfycK9UUNFokbBuu7PaxIZfWbxuGjhrm8kTJlX3TkRpej0k1OzgzR2ZDAqz7KG9iK4AjuaqhT6TLEVSn7heEiVKxcHkZ/kNjyLxcS+VYCRyvNNVsoNHbejcmpPg+qBzdC9C+PfUW6BsA8UhzQ== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR03MB5700.eurprd03.prod.outlook.com (2603:10a6:208:16f::32) 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:44 +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:44 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:17 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [mpxcNooQjoOsY26qbAaMPuvwZqewwbEX] 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-19-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b61f37ab-3768-4db0-5df4-08d9e583d5f7 X-MS-TrafficTypeDiagnostic: AM0PR03MB5700:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3OXlCQYB+BwmHTe/WiiLdj9jnKv6g+F5StvpmlONqN/0l+i9wDVJtOVxU8akZlPLrHLFmga34jOuVBAMt0qUrwjZtsUZswRh2bhN/CwVTUQJNLUU8ily1PHlpM4zhOcYbqYMKKx3LbCTaHd6H4BUx1lDJSGsLUl6GGMt0XSs6Dn3oFNycIfCjc8B0xTtPIGKDCGf14wD+qtopWOtqmDH0G/DR82B5z+mQw5uGNqBNdOV88dvUCFIlRWKO24gjDXBXi2nB1BDxcrkh7TMBU0v3PHFutPRmQIPNhJNpRfo3QE5m0Y90U8F/mOktootaxFAorof+1iTUWdaNphB88ScOh49XetV7uL7hhThiqhz/pFuBICOq/oAntV5IRjw8l0XKIJB8ur1uD+w0NwdnNgHijznkPPwq7mW8Q5fH4RisFxTL4Bqijq2Ci7X/zFaTkRYHYq0Ga4BugRNS/DZ/0EohHqLVngC9z1dMdmXiqhcE7sbHSzBPn8hGFzElC/5Pjh7hc1ofbqoFyhHaDmLtbJByzdtRJA/fQQpyPO0EZqMQvjAaaOzzIlmvWSXoCo1WPsw X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8l2trRjCzTFA3jdAf2+51IyHhWxkGOTEaGeAhbpB/XDfxdIXPjZLFRPjKHmZ6AhYPV8k8oinIN/LlZIDKaQqiCPI39UKKTKI30Yo8exQMoT4xldP57/C8ub+DWX0/Wad/Mneoxpz9lBTtpAxKyn+u8zT0gCZiUpdWjXVF9oeh+lIAN+Clmq0Cj8BccdTigM5/x2MXDN2PXogmqxxDwKcZETmUpxz2tZbTod88vpGNfwjc2WEQn/INfkUnzL8jL9jUI8Eti9r9b34VBGpD44FXVdkg5D0ks0nxvLzG21vaTOVDTX5O4CVfYkdnkWV4TjxbxMi8a37X9TjS8S+nAbZkr1rgGL+xom1Xcb3SHmhe8fNDs2gNSk0PCl+VclLhgcul1/19vtp4bcTiXSg4IQGX0r0FW69zWqSqXq03OdppqyaNvS4CM0+RPZDr43ZCHldleRsyQPW8sMcqr/XlPAOOGdmzKaVcRcjPIY5H1hMHe0m4UBj+4+vtWtke9Pv7I1YmkUFBS7rB1IXVIS3RPJSdi0YiWw6hh5dPix2VnVHr64F4XWHtVDQjvfiE1I+5YeeRKR53CamXth3j7TwxPvrcDeZnDkWUfUK6TDuK7eyqd8VHQp+KFqtY795zfRy/dzSgtSJRPKTm+1Gb7xCxUoddPr5yHpMEYvgNaApMg3qXJIiahIa2GwUVHkti5uHTcWoGLF1XcC8EWNN8dGas8N90ZBK43qLjt9qGmIMKqn3OpplTIQa3V+qPHy/YjI7+1bZHm6753A3JNFGFqg5USyesrKm8KoPj8q1KQqTlJyPZl6Cjz97AqmA99CjzOu4rNYt5Qo5qaE/X3sWdBoraaPI1G+yK/nLrAtheLqzhUjB7WDDvOxbLdXT0VwTYze5CHluv+V7ZoHubIxdgZlnwQCnCFheaDOoPJv4qauU8h1v3UC4VV5AP1e3Y2TdzL86Pixhr/EOg1sjADeaB9UNA9/UsA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b61f37ab-3768-4db0-5df4-08d9e583d5f7 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:44.3964 (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: AM0PR03MB5700 Subject: [FFmpeg-devel] [PATCH v2 20/69] avcodec/mpeg12.h: Move decoder-only stuff to a new header 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: fWSPBtHyfyV8 Signed-off-by: Andreas Rheinhardt --- libavcodec/eatqi.c | 2 +- libavcodec/mdec.c | 3 ++- libavcodec/mpeg12.c | 7 ++--- libavcodec/mpeg12.h | 31 ---------------------- libavcodec/mpeg12dec.c | 3 +-- libavcodec/mpeg12dec.h | 60 ++++++++++++++++++++++++++++++++++++++++++ libavcodec/speedhq.c | 4 ++- 7 files changed, 69 insertions(+), 41 deletions(-) create mode 100644 libavcodec/mpeg12dec.h diff --git a/libavcodec/eatqi.c b/libavcodec/eatqi.c index 8f502b3c56..51eff20b65 100644 --- a/libavcodec/eatqi.c +++ b/libavcodec/eatqi.c @@ -36,8 +36,8 @@ #include "eaidct.h" #include "idctdsp.h" #include "internal.h" -#include "mpeg12.h" #include "mpeg12data.h" +#include "mpeg12dec.h" typedef struct TqiContext { AVCodecContext *avctx; diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c index 007e7fada8..759967e28f 100644 --- a/libavcodec/mdec.c +++ b/libavcodec/mdec.c @@ -33,8 +33,9 @@ #include "blockdsp.h" #include "bswapdsp.h" #include "idctdsp.h" -#include "mpeg12.h" +#include "internal.h" #include "mpeg12data.h" +#include "mpeg12dec.h" #include "thread.h" typedef struct MDECContext { diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 58e03c05d4..ecb0706cf5 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -29,18 +29,15 @@ #include "libavutil/attributes.h" #include "libavutil/avassert.h" -#include "libavutil/timecode.h" #include "libavutil/thread.h" #include "internal.h" #include "avcodec.h" #include "mpegvideo.h" -#include "error_resilience.h" #include "mpeg12.h" #include "mpeg12data.h" +#include "mpeg12dec.h" #include "mpegvideodata.h" -#include "bytestream.h" -#include "thread.h" static const uint8_t table_mb_ptype[7][2] = { { 3, 5 }, // 0x01 MB_INTRA @@ -238,7 +235,7 @@ int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size, int ff_mpeg1_decode_block_intra(GetBitContext *gb, const uint16_t *quant_matrix, - uint8_t *const scantable, int last_dc[3], + const uint8_t *scantable, int last_dc[3], int16_t *block, int index, int qscale) { int dc, diff, i = 0, component; diff --git a/libavcodec/mpeg12.h b/libavcodec/mpeg12.h index fb2b37e7c8..a405db6c2d 100644 --- a/libavcodec/mpeg12.h +++ b/libavcodec/mpeg12.h @@ -22,7 +22,6 @@ #ifndef AVCODEC_MPEG12_H #define AVCODEC_MPEG12_H -#include "mpeg12vlc.h" #include "mpegvideo.h" /* Start codes. */ @@ -37,38 +36,8 @@ void ff_mpeg12_common_init(MpegEncContext *s); -#define INIT_2D_VLC_RL(rl, static_size, flags)\ -{\ - static RL_VLC_ELEM rl_vlc_table[static_size];\ - rl.rl_vlc[0] = rl_vlc_table;\ - ff_init_2d_vlc_rl(&rl, static_size, flags);\ -} - -void ff_init_2d_vlc_rl(RLTable *rl, unsigned static_size, int flags); void ff_mpeg1_init_uni_ac_vlc(const RLTable *rl, uint8_t *uni_ac_vlc_len); -static inline int decode_dc(GetBitContext *gb, int component) -{ - int code, diff; - - if (component == 0) { - code = get_vlc2(gb, ff_dc_lum_vlc.table, DC_VLC_BITS, 2); - } else { - code = get_vlc2(gb, ff_dc_chroma_vlc.table, DC_VLC_BITS, 2); - } - if (code == 0) { - diff = 0; - } else { - diff = get_xbits(gb, code); - } - return diff; -} - -int ff_mpeg1_decode_block_intra(GetBitContext *gb, - const uint16_t *quant_matrix, - uint8_t *const scantable, int last_dc[3], - int16_t *block, int index, int qscale); - void ff_mpeg1_clean_buffers(MpegEncContext *s); #if FF_API_FLAG_TRUNCATED int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size, AVCodecParserContext *s); diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 4a7bd6d466..d55a4d2feb 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -34,10 +34,8 @@ #include "libavutil/mem_internal.h" #include "libavutil/stereo3d.h" #include "libavutil/timecode.h" -#include "libavutil/video_enc_params.h" #include "avcodec.h" -#include "bytestream.h" #include "error_resilience.h" #include "hwconfig.h" #include "idctdsp.h" @@ -45,6 +43,7 @@ #include "mpeg_er.h" #include "mpeg12.h" #include "mpeg12data.h" +#include "mpeg12dec.h" #include "mpegutils.h" #include "mpegvideo.h" #include "mpegvideodata.h" diff --git a/libavcodec/mpeg12dec.h b/libavcodec/mpeg12dec.h new file mode 100644 index 0000000000..b4e94a92ce --- /dev/null +++ b/libavcodec/mpeg12dec.h @@ -0,0 +1,60 @@ +/* + * MPEG-1/2 decoder header + * Copyright (c) 2007 Aurelien Jacobs + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_MPEG12DEC_H +#define AVCODEC_MPEG12DEC_H + +#include "get_bits.h" +#include "mpeg12vlc.h" +#include "rl.h" + +#define INIT_2D_VLC_RL(rl, static_size, flags)\ +{\ + static RL_VLC_ELEM rl_vlc_table[static_size];\ + rl.rl_vlc[0] = rl_vlc_table;\ + ff_init_2d_vlc_rl(&rl, static_size, flags);\ +} + +void ff_init_2d_vlc_rl(RLTable *rl, unsigned static_size, int flags); + +static inline int decode_dc(GetBitContext *gb, int component) +{ + int code, diff; + + if (component == 0) { + code = get_vlc2(gb, ff_dc_lum_vlc.table, DC_VLC_BITS, 2); + } else { + code = get_vlc2(gb, ff_dc_chroma_vlc.table, DC_VLC_BITS, 2); + } + if (code == 0) { + diff = 0; + } else { + diff = get_xbits(gb, code); + } + return diff; +} + +int ff_mpeg1_decode_block_intra(GetBitContext *gb, + const uint16_t *quant_matrix, + const uint8_t *scantable, int last_dc[3], + int16_t *block, int index, int qscale); + +#endif /* AVCODEC_MPEG12DEC_H */ diff --git a/libavcodec/speedhq.c b/libavcodec/speedhq.c index 743dacc6ce..fd4ea0d75e 100644 --- a/libavcodec/speedhq.c +++ b/libavcodec/speedhq.c @@ -31,11 +31,13 @@ #include "libavutil/mem_internal.h" #include "avcodec.h" +#include "blockdsp.h" #include "get_bits.h" +#include "idctdsp.h" #include "internal.h" #include "libavutil/thread.h" #include "mathops.h" -#include "mpeg12.h" +#include "mpeg12dec.h" #include "mpeg12data.h" #include "mpeg12vlc.h" From patchwork Tue Feb 1 13:06:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33995 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp604139iov; Tue, 1 Feb 2022 05:11:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJzFwRtPI29hCoowIpTOKE2nSqMakSS8h1/Zghs75ILd6BpYU/qdNbRzubJcm4ryLE6JC9Qn X-Received: by 2002:a50:e616:: with SMTP id y22mr25062627edm.277.1643721107451; Tue, 01 Feb 2022 05:11:47 -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 qk33si5989988ejc.636.2022.02.01.05.11.46; Tue, 01 Feb 2022 05:11:47 -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=BKxgoIye; 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 D803A68B33F; Tue, 1 Feb 2022 15:07:52 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2032.outbound.protection.outlook.com [40.92.89.32]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4DA5068B319 for ; Tue, 1 Feb 2022 15:07:47 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g25gswNbgHz88g/iu8INZrGyrRycy8Tuln92pfy4jlR3NstcZCvsjqvYbfLdGIrNnFj254K2uQaf0Jb+vkMpDbKMyLPfc09P3Byh4KW1Q7j71BBa7ui/vRF05uwDAm30O/K1RblirsX+vIquxJJ4zd0D36hDvhY9nnwzuA72MuybV/ukLie+0Bdamlj5W9UueKPS3Iww7HPFnQEf3X9AMlp68EKOCRrq6GNMEgsVcLXyWRAzbsDIwloQJG9LqTThqSqF9tweZSSjYNi7xy9zhAJosU16jh9HakMBjyab8aVKxUSPnD4hOUnxaB+wbacwzTEiv9t5fT2DSU0nJLJrHw== 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=Qz0oReIxFswJKZqhKcxgyVYwmdi1PhQRNlnuy+HJRPU=; b=LoSzN7xN+UsTHHIQTb67Ixk1nuDijIyyy23D+b2lq/ipDB7INepfIa7mKltpmPAcN5Wx4zP8MKYA7j+w1uqsZQvKImunPG+hJpNEfA50jVnXhKVb+3VZZsbS9yqtzix3r1puOpaF56nK8Ao4aDLsI1NlYAhYgljhoDzMIt2aKHv2uPN8FxHglezZ3hpWmZHpEGLZHuuK46UpBxS1CearABskwMbtx08NTR/UiAWS/KzX+TM7tTyS1G63v0NiDqHVy0jg6vEnbZOMlTLd/hRm5uc1sNZXH/uYhm7ltcQ/C/eJGWtfQ1Fi2qZHFs757g/MPVYb+AVrmCQVsoLjsYXRkQ== 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=Qz0oReIxFswJKZqhKcxgyVYwmdi1PhQRNlnuy+HJRPU=; b=BKxgoIyeZyoX6dnkN8dHHMpwPEvScTeC6UbLzWjM13WOyvXpdk48s5g470EqyHU0nTSMbOchHZZhIngiiGnYXrZpxmPA8fGIhvzNDgk7IF4XPLLAIr/isKEeLKMRpEkn2pAqMPMDk9kSYx3k5Ao33HIvFV+k0Dd4nUy832KO/wMrJNUoKT3ow2reudA277M3Fr5Pp6PauXxjXHQqR6jkFKuccM12ZHWQtkJPoPIWTT1DWAqrkwpIHPyqHMNvervCZKgKmdMB58d0bDo/pj7q96MCuuN+NkaA8AYhu/X+tUFQS6zyfJiXYF6RN2bDKVlftdpjp5iFZJtZyah7l8bQvg== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR03MB5700.eurprd03.prod.outlook.com (2603:10a6:208:16f::32) 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:45 +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:45 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:18 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [z7a2WIvc55w/Zvj1uzh8dM/3Ln5yx04l] 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-20-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4726b35d-24e1-4718-8f44-08d9e583d6cb X-MS-TrafficTypeDiagnostic: AM0PR03MB5700:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3BNomvT2Oy7CZ4T04no8kNDH9eXz/tRBFTGMutWD6KUxCLuM+2M5Whqb3EioXq/puXhphdGyNID65+rsbCBNrz2EOMM5NuHGHkdF/as5VloVtDcDCpPVQ3pIucDMo7hY/U32KTI0HetZvwZG+hU5B30faZrWkGK9yt3yrx4+eoCaO6MmbgK2IUYw9oH8hVAnddVSRNA0byzWOaG4cC2jW7p8CO/1lPXu9Pmn42kxevcUELFzvDxumgPLY9CS38uuya1655S8V+tf6ca7H8VVnmX8CMbBe8I1YtSRdfGQ1P0yX5d1CBCBeNfOfI4sdyKS7upjgCHUPXIX03r7H+qghfpOZiP1gLnoIjT0QWD8MWf7NMYy4+kmsiRnZ5PnCvxfeLwsD8f7atAE2faeXSMNhnJaKiMiSJ1L160kY/2exFlbDKdFXhW7+uIFrD9Zflg+4aLmHUgW6h+XYPp8MsErCaBmIQyv9vsPIGj39A0xmBo6kGAwa2stKIQLbFdzJOvCqdxgKIWaagvmFKlAdVI+MqY229L+apu8WLFN66axPmpq6ziV0UuY+HcG1QYQPHhH X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: h5shb6HTKbJHlCVT8cP9zQp1H3zAkGiUKsFTzdLDEDmn33ZdOYMnlH7REVLOF2l8tF0PnFa9e6b/BeEU+XhpXINJBO7CSDZwNgXi3hBAn+yWGiEq3GuQEiOcmMp25uc9N+rix0dq8EtDz/k81lqkzVQoPJgRe+22e+VB5kNLMvdJSA/ck1Xilc5FXBfI/N5t96dqqNQTxqXw+6LsT+dMWzBeyJV+dNH7KF9HuuXnxZ1K8IkEiPXDElsomEAMn7t5WOLp7IkIgtNnrViKE1OgM90UjjCiqElxroptber5JZERR/JPaC+f1SDNUJlNYv5NOVXFFsfQraVKfKeKBLp2JEV55TTdwlwRQ67GXioc2e6AFBGf19vg7mfosSflXyBO9JYKUcYLie12mU0nmYT0cqnyo2xjbmJIs5jODea/nzjRMz7YxdzDNohR4dUSmxRVblwX/qKtr8su4co7sPOQfQRFJG0FPr9NWVcpMkLv1QQgvqXACOKNbvwBgQD6WD/8qMNQchFf34QABacbPouWMFo8bKQOo09bIW0GQdRhAp3zZWbb4aTAz7f3nDtU2cmWfZJnPU5L35uZkqFPamMR6kPKXK94CoqPvetCKLUtIxWiBiInpfb6YxSQ961OaL05EaYsXYzu7rwAEPzw36aJ2OEaPIggOsEgl9eSSqB7YM/9BkxJZtAPySK1iv/YE78BWRJiCVih3+uprxK1XlXBvJsm23Lui7mecVUFt8ae9ySeoiWB3RumbjW8DnsM5hIiYT8Idv36Ma7P25saXsy73qQ73xLEYzBIZFWYGAukCgJln4wJCQyK3U6EIDpIDAMwtR39/v66Ja4pgXYLFWKmSUOmNl40UIN1eP6tfcLKvDqIUvo/WAzeAWKBhj39qVkMPmw9uxicQt0tl+ztlxzft++IQxYH396SKCevqcjggkqS13bvJEw9uhWdl4xo94wtD3p9VEq1VMs7YNVqsa9HpA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4726b35d-24e1-4718-8f44-08d9e583d6cb 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:45.8039 (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: AM0PR03MB5700 Subject: [FFmpeg-devel] [PATCH v2 21/69] avcodec/mpeg12.h: Move encoder-only stuff into a new header 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: uoH0EUENccgs Signed-off-by: Andreas Rheinhardt --- libavcodec/mpeg12.h | 8 -------- libavcodec/mpeg12enc.c | 2 +- libavcodec/mpeg12enc.h | 38 ++++++++++++++++++++++++++++++++++++++ libavcodec/mpegvideo_enc.c | 1 + libavcodec/speedhqenc.c | 3 +-- 5 files changed, 41 insertions(+), 11 deletions(-) create mode 100644 libavcodec/mpeg12enc.h diff --git a/libavcodec/mpeg12.h b/libavcodec/mpeg12.h index a405db6c2d..e0406b32d9 100644 --- a/libavcodec/mpeg12.h +++ b/libavcodec/mpeg12.h @@ -36,19 +36,11 @@ void ff_mpeg12_common_init(MpegEncContext *s); -void ff_mpeg1_init_uni_ac_vlc(const RLTable *rl, uint8_t *uni_ac_vlc_len); - void ff_mpeg1_clean_buffers(MpegEncContext *s); #if FF_API_FLAG_TRUNCATED int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size, AVCodecParserContext *s); #endif -void ff_mpeg1_encode_picture_header(MpegEncContext *s, int picture_number); -void ff_mpeg1_encode_mb(MpegEncContext *s, int16_t block[8][64], - int motion_x, int motion_y); -void ff_mpeg1_encode_init(MpegEncContext *s); -void ff_mpeg1_encode_slice_header(MpegEncContext *s); - void ff_mpeg12_find_best_frame_rate(AVRational frame_rate, int *code, int *ext_n, int *ext_d, int nonstandard); diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index 9c0be69ded..3acb82ac9d 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -37,10 +37,10 @@ #include "libavutil/stereo3d.h" #include "avcodec.h" -#include "bytestream.h" #include "mathops.h" #include "mpeg12.h" #include "mpeg12data.h" +#include "mpeg12enc.h" #include "mpegutils.h" #include "mpegvideo.h" #include "profiles.h" diff --git a/libavcodec/mpeg12enc.h b/libavcodec/mpeg12enc.h new file mode 100644 index 0000000000..fbbc43f891 --- /dev/null +++ b/libavcodec/mpeg12enc.h @@ -0,0 +1,38 @@ +/* + * MPEG-1/2 encoder header + * Copyright (c) 2007 Aurelien Jacobs + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_MPEG12ENC_H +#define AVCODEC_MPEG12ENC_H + +#include + +#include "mpegvideo.h" +#include "rl.h" + +void ff_mpeg1_init_uni_ac_vlc(const RLTable *rl, uint8_t *uni_ac_vlc_len); + +void ff_mpeg1_encode_picture_header(MpegEncContext *s, int picture_number); +void ff_mpeg1_encode_mb(MpegEncContext *s, int16_t block[8][64], + int motion_x, int motion_y); +void ff_mpeg1_encode_init(MpegEncContext *s); +void ff_mpeg1_encode_slice_header(MpegEncContext *s); + +#endif /* AVCODEC_MPEG12ENC_H */ diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 7c5d013200..aaa1488977 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -46,6 +46,7 @@ #include "idctdsp.h" #include "mpeg12.h" #include "mpeg12data.h" +#include "mpeg12enc.h" #include "mpegvideo.h" #include "mpegvideodata.h" #include "h261enc.h" diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c index 6df0316611..2a310a6c4f 100644 --- a/libavcodec/speedhqenc.c +++ b/libavcodec/speedhqenc.c @@ -27,12 +27,11 @@ * SpeedHQ encoder. */ -#include "libavutil/pixdesc.h" #include "libavutil/thread.h" #include "avcodec.h" -#include "mpeg12.h" #include "mpeg12data.h" +#include "mpeg12enc.h" #include "mpegvideo.h" #include "speedhqenc.h" From patchwork Tue Feb 1 13:06: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: 33996 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp604333iov; Tue, 1 Feb 2022 05:12:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJwf0sjXq94NQt8ODmqNbHmB90memSC+8pJIgCSv42fEwCfIYo441TiwJ3+fox6DqKML32uZ X-Received: by 2002:a05:6402:5186:: with SMTP id q6mr25187241edd.96.1643721122450; Tue, 01 Feb 2022 05:12:02 -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 ht18si4998679ejc.661.2022.02.01.05.12.02; Tue, 01 Feb 2022 05:12:02 -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=GkM+P7Yh; 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 DB9DC68B33C; Tue, 1 Feb 2022 15:07:53 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2035.outbound.protection.outlook.com [40.92.89.35]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8E67468B329 for ; Tue, 1 Feb 2022 15:07:49 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nAounY4jqJCwMFAsqSbtdm2j3VKR3kW2rkdrRSS8IwDsg09twLj6cYTnuwm224D5cb4pZI3o0yynb/0lb/uNUKEzwS4BeP48jRcgzhZ+WLOU31DF7GUJ5w3t3fX8QoPRdtstazBRo4nYvxHUQO1/tXtMY73ejikuyBNMf8O6qCFyMiFW2v1hrMIce6A5OxezpK1HwmDkSzFfIFDX5kJwcE8QRoFaH6cIjJvA3zXrrU7uSXZqyMGaf2zyCYBoy4xM2UHccRKIDsle6ev3sjy/WIQHproB9eCuE8xuSQ4H2bGeDEQBGGHgn3Ckgg3H5SKq8SyjRF3qBmpggBeZPdFHxA== 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=7vLLFz4ZqLgAopJgskKDOI0Is2KP1Sja/AIiK00DVnU=; b=hp6ckRYCC/muMJS/3R6GinrLgyp0wKiNFWpqKu7HbqdkA+krJ0KUcRasAlwIQBum91OShxpwiH7aXQWbzBq3y7opws9ekrWdaRwuqP6U3oFEIIVZkE1bXn73n07eq8pieJQuN6uwMxJpvTaK4KuJZ65H2CuvLXG7Gc9zEhsUyKBvD4dxXOQEUKSd8KlR/xjrrln69Ihb8ncMtcIb9RUt4Gok36JwbKIImzOvQTwTW61b+FFjgcI/RfdOsm2c6ZIx4UK8fpdeppC20+/cDyu9dsnGr8yw4GG6T5arykhSOMOyE7d8bHujZ0eMzvlSPvIjZYnz/jSI9+KSviT0tWtsWQ== 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=7vLLFz4ZqLgAopJgskKDOI0Is2KP1Sja/AIiK00DVnU=; b=GkM+P7YhqmhxUf7GSDyMPSAZ92yVI3acywhaDLfyqJV1lnKs6k6z5zDe4vE91VbeN/q6wqL37JT8wV36bWpuUo3QAhSyMJ+D98YMhHHbFLd18uY2g5HNZTlN5gDpOgkmeTX7i9GMdUcKjmaj2PI4XAK50yvjIHeclY3kR5biVqO9YO0D+HNk2RsNVbuhU7JX3JlpPmnW8AkdS37Id+xwteXo1zoCZ0h2ddUGjxaoO/uJ3fBeK8AA1zINSfr+qLBmBcT3gv66m4wFzfWiCC+hl3AVdSF3/5Uo3xySwfAz3lzotGQda9YiglV3sDGEUuGpUbz7Tc/JGG3IPtYMgAHSUA== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR03MB5700.eurprd03.prod.outlook.com (2603:10a6:208:16f::32) 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:48 +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:47 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:19 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [Ld1EmUs8LaoU3FoCxNIkgDSMRQhLdON3] 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-21-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bb9794cc-7793-40a0-2222-08d9e583d810 X-MS-TrafficTypeDiagnostic: AM0PR03MB5700:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dvbbDdOFmUMgd8J0Nlwp2Q2EpOZl4DjtIjHZGmEg4V9W42zuzE+T9QJKx+DUfdLL3b+mKy+a2KnKc20AH6ijByuyTUPYUIkCh4RBH6gCO0HD2JWoMvbVS2Q2Ub36RpIbMcNAhUaraz/iKKEBTYgIA/DuiULHUtX5mWvaNfqeBgKb0zJYi6DOeMhMwpfneq0eNI8i7Kv/LhU3jgiNiDatHAUZgoFy4ynt8htzaKhwB9Vf6c5D+t3qVQR2QpXTqJ0NO3/UeAwV1b3LdqDQ4Gfjuhm93i3VNwUUPAi6N9PDLdF9Rvrnbb2f/aHpj/xM21Hf8lkVr5vGtO2JSHTmTU9wRpy6xmMa+xiY1YJfgQMQsoUTeKgzckPcd0jRk5udA/t9MA//n7yTdSai8NMIAbtaYP7UHR+38s+a/6OG+L7rn3tS35dTqaWKa9ti/N0f5kv4iehwgYDf2SpV9vV//lSfvOr318B06zFOC6020fyzMlG4oSKCBjQOWg+vGA+qI4XclfznkNn858DoDVniTGcBmXuvaRhzoBbRUEtTMeaEicJeBVDTpB53ym8zndImFvH9 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GA9KORfuZPbf6yjGjTrEFU9c/+O/dxUv/AgFAOtHzguyQW4lOM8wGG6Soma68FOHiZmwQP9xt24MBF/uiciJWH4z/WtkrCTHkkEVODY+c+T5Ph6pmtozL01CN/kFgs+3QFk5EiiOH+RcU57E/EcIB4MELYIU/ylgPhfYVsq64k2GrznBshp9sVxsnkP0lt2MovVcAv75hmsot32/jSlkAgyDwyMY/PQoQC+q2EH7rS0fPX2c4w4BCFOHo2KTzCsxuFctT/irAhbMCZ/ojY20cWukXi28ZtPVcwNQrE3HuKNeiy6MSARmm+0J6huU8dSvR1eLqqR6XE8vPbeklrUtxFnAuUlLpc8ZkvdcZ8ZfF5dtEfhqHA0Ir4HO9CxdSTed+X/xVMEaimDpKO70U/BfpcGChM4f5JhBN6ZscZj+Wl5N5Ww0nwhBTLMD1myi4IUpWkkzB0guNaPCfTZIvUTEixMG8vSR7hspjqR9cYcgoOEB4LiCgIZIudgQbiXs7vsEDkI0PK5t0jasL2ix8/iB+3rVIBoZEThitPoHhL6Dw4io2KbJWBPxxn8XdgrWiOc5AmTvotTEfHE23vpDPk5/WgM9DIko5yPiQ3hSXDepBzDGadRForlcYoSwnVm42MmOext+rd+eBBl3WnFlBRAm5FHyyUp4fc9STp4u7Fx2f6Mk+pWiI3f4WWLD91DXmarcPKh+fi8hkhqd9jOz0nmxvD9awZX2WoF0NysnTqKepqQj5ZsUqpp7oHi7s/TMb6rYV0R3k4eiLEWb/ITvYRSFW/GUSCojxWAnqNbyQY2ftt3V7JcQEsDdVlt5BJ3M4L5fzl4bSeulRnMEDqQVIviqQuPW5kWV+46aOVA51mX/27STL/ZLaJZgMUI1l7CtkpMJE/Kx9QFe7AkDXuFNpZXzAKG7d0s0PmYl65wgQtK1llQ8qQ3yyIU87PnJIiSpp10e58+BGUNI1Dp3o80xsfBQjg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: bb9794cc-7793-40a0-2222-08d9e583d810 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:47.8985 (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: AM0PR03MB5700 Subject: [FFmpeg-devel] [PATCH v2 22/69] avcodec/rv10.h: Split header into decoder- and encoder-only parts 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: iu8lQ0XKuG6A Signed-off-by: Andreas Rheinhardt --- libavcodec/ituh263dec.c | 2 +- libavcodec/mpegvideo_enc.c | 2 +- libavcodec/rv10.c | 2 +- libavcodec/rv10dec.h | 28 ++++++++++++++++++++++++++++ libavcodec/rv10enc.c | 2 +- libavcodec/{rv10.h => rv10enc.h} | 12 ++++-------- libavcodec/rv20enc.c | 2 +- 7 files changed, 37 insertions(+), 13 deletions(-) create mode 100644 libavcodec/rv10dec.h rename libavcodec/{rv10.h => rv10enc.h} (85%) diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c index 5588840c3d..77ca0d7e40 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -42,7 +42,7 @@ #include "mathops.h" #include "mpegutils.h" #include "unary.h" -#include "rv10.h" +#include "rv10dec.h" #include "mpeg4video.h" #include "mpegvideodata.h" #include "mpeg4videodec.h" diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index aaa1488977..a8146c6473 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -71,7 +71,7 @@ #include "internal.h" #include "bytestream.h" #include "wmv2enc.h" -#include "rv10.h" +#include "rv10enc.h" #include "packet_internal.h" #include #include "sp5x.h" diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c index 4dfaa3460d..241ee53442 100644 --- a/libavcodec/rv10.c +++ b/libavcodec/rv10.c @@ -41,7 +41,7 @@ #include "mpegvideo.h" #include "mpeg4video.h" #include "mpegvideodata.h" -#include "rv10.h" +#include "rv10dec.h" #define RV_GET_MAJOR_VER(x) ((x) >> 28) #define RV_GET_MINOR_VER(x) (((x) >> 20) & 0xFF) diff --git a/libavcodec/rv10dec.h b/libavcodec/rv10dec.h new file mode 100644 index 0000000000..daa6b8d653 --- /dev/null +++ b/libavcodec/rv10dec.h @@ -0,0 +1,28 @@ +/* + * RV10/RV20 decoder + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_RV10DEC_H +#define AVCODEC_RV10DEC_H + +#include "mpegvideo.h" + +int ff_rv_decode_dc(MpegEncContext *s, int n); + +#endif /* AVCODEC_RV10DEC_H */ diff --git a/libavcodec/rv10enc.c b/libavcodec/rv10enc.c index 72b25e0c55..dbc7a370f4 100644 --- a/libavcodec/rv10enc.c +++ b/libavcodec/rv10enc.c @@ -27,7 +27,7 @@ #include "mpegvideo.h" #include "put_bits.h" -#include "rv10.h" +#include "rv10enc.h" int ff_rv10_encode_picture_header(MpegEncContext *s, int picture_number) { diff --git a/libavcodec/rv10.h b/libavcodec/rv10enc.h similarity index 85% rename from libavcodec/rv10.h rename to libavcodec/rv10enc.h index 364270e76a..66672f8087 100644 --- a/libavcodec/rv10.h +++ b/libavcodec/rv10enc.h @@ -1,5 +1,5 @@ /* - * RV10/RV20 decoder + * RV10/RV20 encoder * * This file is part of FFmpeg. * @@ -18,16 +18,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef AVCODEC_RV10_H -#define AVCODEC_RV10_H - -#include +#ifndef AVCODEC_RV10ENC_H +#define AVCODEC_RV10ENC_H #include "mpegvideo.h" -int ff_rv_decode_dc(MpegEncContext *s, int n); - int ff_rv10_encode_picture_header(MpegEncContext *s, int picture_number); void ff_rv20_encode_picture_header(MpegEncContext *s, int picture_number); -#endif /* AVCODEC_RV10_H */ +#endif /* AVCODEC_RV10ENC_H */ diff --git a/libavcodec/rv20enc.c b/libavcodec/rv20enc.c index 204cd03a24..892107f1f8 100644 --- a/libavcodec/rv20enc.c +++ b/libavcodec/rv20enc.c @@ -30,7 +30,7 @@ #include "h263data.h" #include "h263enc.h" #include "put_bits.h" -#include "rv10.h" +#include "rv10enc.h" void ff_rv20_encode_picture_header(MpegEncContext *s, int picture_number){ put_bits(&s->pb, 2, s->pict_type); //I 0 vs. 1 ? From patchwork Tue Feb 1 13:06:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33997 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp604609iov; Tue, 1 Feb 2022 05:12:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBDCQVYfmsgI60vPav890RN3PyUOihqOD6Fko8dhga+nmjIOa+LqHkLqFwCiPQnqZDOQqt X-Received: by 2002:a17:907:6d99:: with SMTP id sb25mr21567730ejc.15.1643721141535; Tue, 01 Feb 2022 05:12:21 -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 i11si9169978eds.292.2022.02.01.05.12.21; Tue, 01 Feb 2022 05:12:21 -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=htrFrW4R; 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 EFB7768B350; Tue, 1 Feb 2022 15:07:54 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2084.outbound.protection.outlook.com [40.92.89.84]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E182468B33A for ; Tue, 1 Feb 2022 15:07:51 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CbieBapC1GMsQH6IBOeU/6XBXv4Ho51vIuzXf0p0sxVZIkl8vzDYF41/PSKgyLGn9vVO5fPqSa8x2PhgtXexsfVhl4l8zOPBl9tBDA3o3iKat404CQFKEfBe8r9Xl3VgMzP46anDZKKE5JvRgY9h+77L73798xUWtbYMLGFm2Ma2KaEKRoh8Vg8odWWgGWiVPghEbnekW2HrAFXUuS1p+5BYwnFvnwMTMfsVfqpxVCUl0wLbuJavWL9Xb/9drBL/fb3q+0vWdJaczVGsC4mc6QutYtNpPrRmTnRyn3hfrDPhVJ7BZKKFvYEMKArq8FaFUUSE0syRWBiw6OBRm4QlAw== 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=tjm9CmfpaX7wSe8m2e9LWda/TRvIgkNON26qSYsvcZU=; b=JnT02NLcPMcQj51fKYuJJwEYxD4WQZdziDeAmIo6F5ymahLHkDau6IN0l0Z3wKziZFHB3BTbfhVwpLGKiHFDLS95HMWNQ0pCC+ub45gyXTdzEP/7dqJTQb3raM/bIB5MI5GQIqzG4zBI2H2imJW1iNO3QHn5PmGRXL96Oc3a0v7YtqB1TAcQvCvOaU01pOSonLSweJY1rZ6jboWE7aBCF+3Iyl7rlbeOB7Kpxlao77xM3voQVt1LRB3Bl3PQHUBmAyYq6KJRC6358ZrJxjZzetCU2tOUROO7QhQy8MFoPJfyrunceIDS59fLBp0sdEloN8axpn4XFF+FxQFM3yGfmQ== 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=tjm9CmfpaX7wSe8m2e9LWda/TRvIgkNON26qSYsvcZU=; b=htrFrW4RmhAF7rRawfP9OVJ8nRN3R5nBCHIPYbOwCZnm1TQMMpz+WLGD3+l6tAtycpmgXyaSdR5SXzNc6yTFGWd0xJ+fjE5JkHOPt6Tg9xb0LMChHfivi+zmbWYXsLFxah1gRbKOKutykyMnYiIaFEUsGFeaWumFRUIuP+9eVWSvXBH7gJHZJB6fp9NrFHdiB1hf6TnUFljQHdgA0+/T2oqKf80oEMjqoVFiOvPYM6z7gbFibC4m7wXejjrt3JDxKYcZh3E90cbKrafBszi1CpOeVPQJYiMeRj4WNUXlqq1qEssCvocoPay/2+hWw0ZRRPk8TD3IlhJcJTtVp+ci2g== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR03MB5700.eurprd03.prod.outlook.com (2603:10a6:208:16f::32) 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:49 +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:49 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:20 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [70lDaDBHuxM2rLRQg+t8w5mR4pnwMqXa] 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-22-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bf87e29d-dc8e-427a-7692-08d9e583d8ad X-MS-TrafficTypeDiagnostic: AM0PR03MB5700:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3pLL9G0to4F/p6hf/hzqKBfskrvKSlpSWLKkrnbpoy6fl2ZxIurVbpZtX5bu2XiVa2tiwTJEhCMhX9//hmbFHm1nDy52UKXRnZobzmPoKcDdPPv4GqCGeMQBdDgEdpdFnXKwhx7viiDHbY6ORWARiNfu9StTXkhXF9c2gwJtCt6ik4CAfKR+l9BhqnZqkg/4JaIXj23tKhaaD5FPO9aRCn4z6kL7L7XX/L/exDcjMNm6Oi7jT1/zw3mP1ehn9Si9i5Q5EHLG+rvKrl6UmCqGU8DdbnG9Q0pi65mdKx8gCca9gTQoIjML2DRf1Nnzw2tTnPIx347NghHIJK584/uZN+qhn7LNTddIwG0+YTAkllo23BlqKkF6F1XSb05gW1KLqywgdRz+r3ATsTa4Auk5/dzPqJnW0fMIUdmYme+uekLorQ139c1Dca80dMUaPjT+a+q+/ubXju+XNelzHS0RpAcNKgQFz0cCrGjon/SEVlQPZx6/gYJbw7+nvcvx5b9hNlQN74/6phrawVmpErTWjq1kXfeKcQciTR09C5bs/3BnGIWamt2EYSmjCo24hg4I X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZCHovULbQ3MvEEjTu1yJDClRTPfEdP1ENEbHRGj/XWqcWlPCCXMSvL8v7S37uBwnvWqywa/KpxvBUbSRYzXPPEWcCjOORJ63b2iIWyRDwqmMjjE6cx07WauoQ6ogphfGgyH+YGE9snLM4Rftyo8BIw1vXXnqU0cC1JIftBqFnSQZlRQ4yt/v3lSslNM2yUuvzFYKqyETPpZUUW0v9WVlQNJqEqB5RPtoTgghbfpZCL5NNw2SZ5Nkt+DMUTA6g/QupOnGpnk8C4LMeeE1XLLx6fI7+IP5cMhnEYuMkWCEPdn7eWCpFLjrACbmjrEb5kl4FXDyaUK7rsaXNkd+xGPDJ6XTay25Jnc7R3MSHxdyzp/Y+Own/Nn3ROIGij9Eu3vNzdPhr2FTmmagWX9bVnNLuxavgsk2ASN1ue1UaH8U/JksOZhMQ2eMBK9dZUppgjukx8hSxbmgjBiVSp/ppGoihdtLKcOzrxgCaeyQU5nM81Md76hMlps+LIYWzhXRLdTQVVdgBnR8TQM8MgufVKYySLEQKU/xEfZYnYMyJitMNnDPQQs3xbI1yzF7KeLjnLj3g3NXe/QIffiReblKwNwr64jSOeCwsAVJfJgdA72WlqRTs+XZtvHFLYVwuyPyjh/62DGtTzZnByKGCMebafOTML1E83dB8FUMIEt33fYTkn3iOCq3+9716/z806AHpXXsZR4thsq8aRtrQZs+x0rFvvl6eEK/Yy8FIlw/lzu0JQ8DigdFYeKr1H3AkrlnoR4xapDZommnmmyefG5cRYc853luWE1FyE5+1bdsvCrc/nJogc/Lc87wjPczk1bM5yb6HZfR8GQR/KoZU6gPNAwzhAwMTUlt1w1GOI7MlrEmDzaWt8UbDRC3UD341ettXKTq3VTEGx8WlK6paE6InkbVpTU7517CvHrXzCoFf/sYo+6lxuJi5ThWtxXritD2L/XhhgfS5BYlHreDfeiMS50eVQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: bf87e29d-dc8e-427a-7692-08d9e583d8ad 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:48.9765 (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: AM0PR03MB5700 Subject: [FFmpeg-devel] [PATCH v2 23/69] avcodec/mpegvideo: Move encoder-only stuff to a new header 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: zFZfPvhxdse+ Signed-off-by: Andreas Rheinhardt --- libavcodec/dnxhdenc.c | 1 + libavcodec/flvdec.c | 1 + libavcodec/flvenc.c | 1 + libavcodec/h261enc.c | 1 + libavcodec/h263enc.h | 2 +- libavcodec/intelh263dec.c | 1 + libavcodec/ituh263enc.c | 1 + libavcodec/libxavs2.c | 2 + libavcodec/me_cmp.c | 2 +- libavcodec/mjpegenc.c | 1 + libavcodec/motion_est.c | 2 +- libavcodec/mpeg12enc.c | 1 + libavcodec/mpeg4videoenc.c | 1 + libavcodec/mpegvideo.h | 127 ------------------------- libavcodec/mpegvideo_enc.c | 1 + libavcodec/mpegvideoenc.h | 161 ++++++++++++++++++++++++++++++++ libavcodec/msmpeg4enc.c | 1 + libavcodec/nvdec_mpeg12.c | 1 + libavcodec/nvdec_mpeg4.c | 1 + libavcodec/ratecontrol.c | 2 +- libavcodec/rv10enc.c | 1 + libavcodec/rv20enc.c | 1 + libavcodec/rv30.c | 1 + libavcodec/rv40.c | 1 + libavcodec/speedhqenc.c | 1 + libavcodec/vaapi_encode_mpeg2.c | 2 + libavcodec/wmv2enc.c | 1 + libavcodec/x86/mpegvideoenc.c | 2 +- 28 files changed, 189 insertions(+), 132 deletions(-) create mode 100644 libavcodec/mpegvideoenc.h diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index ca67964330..ac92474e56 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -34,6 +34,7 @@ #include "fdctdsp.h" #include "internal.h" #include "mpegvideo.h" +#include "mpegvideoenc.h" #include "pixblockdsp.h" #include "packet_internal.h" #include "profiles.h" diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c index 62bb32bc62..dacc64c81c 100644 --- a/libavcodec/flvdec.c +++ b/libavcodec/flvdec.c @@ -22,6 +22,7 @@ #include "flvdec.h" #include "h263dec.h" +#include "internal.h" #include "mpegvideo.h" #include "mpegvideodata.h" diff --git a/libavcodec/flvenc.c b/libavcodec/flvenc.c index 7271d64af3..663a33c959 100644 --- a/libavcodec/flvenc.c +++ b/libavcodec/flvenc.c @@ -22,6 +22,7 @@ #include "h263data.h" #include "mpegvideo.h" #include "mpegvideodata.h" +#include "mpegvideoenc.h" void ff_flv_encode_picture_header(MpegEncContext *s, int picture_number) { diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c index 66b7cc18fd..7d6a559f46 100644 --- a/libavcodec/h261enc.c +++ b/libavcodec/h261enc.c @@ -34,6 +34,7 @@ #include "h261.h" #include "h261enc.h" #include "mpegvideodata.h" +#include "mpegvideoenc.h" static uint8_t uni_h261_rl_len [64*64*2*2]; #define UNI_ENC_INDEX(last,run,level) ((last)*128*64 + (run)*128 + (level)) diff --git a/libavcodec/h263enc.h b/libavcodec/h263enc.h index 31f00665ce..fff85a18f2 100644 --- a/libavcodec/h263enc.h +++ b/libavcodec/h263enc.h @@ -22,7 +22,7 @@ #include #include "h263data.h" -#include "mpegvideo.h" +#include "mpegvideoenc.h" void ff_h263_encode_init(MpegEncContext *s); void ff_h263_encode_picture_header(MpegEncContext *s, int picture_number); diff --git a/libavcodec/intelh263dec.c b/libavcodec/intelh263dec.c index 9dde247298..b61effa4df 100644 --- a/libavcodec/intelh263dec.c +++ b/libavcodec/intelh263dec.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "internal.h" #include "mpegutils.h" #include "mpegvideo.h" #include "h263data.h" diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c index c8a95574d2..11d8873253 100644 --- a/libavcodec/ituh263enc.c +++ b/libavcodec/ituh263enc.c @@ -35,6 +35,7 @@ #include "mpegvideo.h" #include "mpegvideodata.h" #include "flvenc.h" +#include "mpegvideoenc.h" #include "h263.h" #include "h263enc.h" #include "h263data.h" diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c index 9c5a576e90..4742b18f9f 100644 --- a/libavcodec/libxavs2.c +++ b/libavcodec/libxavs2.c @@ -24,8 +24,10 @@ #include "xavs2.h" #include "encode.h" +#include "internal.h" #include "mpeg12.h" #include "libavutil/avstring.h" +#include "libavutil/opt.h" #define xavs2_opt_set2(name, format, ...) do{ \ char opt_str[16] = {0}; \ diff --git a/libavcodec/me_cmp.c b/libavcodec/me_cmp.c index 60545248b3..b2f87d2e1b 100644 --- a/libavcodec/me_cmp.c +++ b/libavcodec/me_cmp.c @@ -27,7 +27,7 @@ #include "copy_block.h" #include "simple_idct.h" #include "me_cmp.h" -#include "mpegvideo.h" +#include "mpegvideoenc.h" #include "config.h" /* (i - 256) * (i - 256) */ diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index 6a47503ab4..b9b17a50df 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -39,6 +39,7 @@ #include "mpegvideo.h" #include "mjpeg.h" #include "mjpegenc.h" +#include "mpegvideoenc.h" #include "profiles.h" /* The following is the private context of MJPEG/AMV decoder. diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index 5b0958733c..35ca40b90a 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -36,7 +36,7 @@ #include "mathops.h" #include "motion_est.h" #include "mpegutils.h" -#include "mpegvideo.h" +#include "mpegvideoenc.h" #define P_LEFT P[1] #define P_TOP P[2] diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index 3acb82ac9d..7ffbfbca5b 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -43,6 +43,7 @@ #include "mpeg12enc.h" #include "mpegutils.h" #include "mpegvideo.h" +#include "mpegvideoenc.h" #include "profiles.h" #if CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index d55667c1a6..1f67fafe34 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -31,6 +31,7 @@ #include "mpeg4video.h" #include "mpeg4videodata.h" #include "mpeg4videoenc.h" +#include "mpegvideoenc.h" #include "profiles.h" /* The uni_DCtab_* tables below contain unified bits+length tables to encode DC diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index f5c9789fea..e16f850f30 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -39,7 +39,6 @@ #include "h263dsp.h" #include "hpeldsp.h" #include "idctdsp.h" -#include "internal.h" #include "me_cmp.h" #include "motion_est.h" #include "mpegpicture.h" @@ -54,11 +53,8 @@ #endif #include "mpegutils.h" #include "qpeldsp.h" -#include "rl.h" #include "videodsp.h" -#include "libavutil/opt.h" - #define MAX_THREADS 32 #define MAX_B_FRAMES 16 @@ -302,7 +298,6 @@ typedef struct MpegEncContext { uint8_t *inter_ac_vlc_length; uint8_t *inter_ac_vlc_last_length; uint8_t *luma_dc_vlc_length; -#define UNI_AC_ENC_INDEX(run,level) ((run)*128 + (level)) int coded_score[12]; @@ -558,101 +553,6 @@ typedef struct MpegEncContext { #endif } MpegEncContext; -/* mpegvideo_enc common options */ -#define FF_MPV_FLAG_SKIP_RD 0x0001 -#define FF_MPV_FLAG_STRICT_GOP 0x0002 -#define FF_MPV_FLAG_QP_RD 0x0004 -#define FF_MPV_FLAG_CBP_RD 0x0008 -#define FF_MPV_FLAG_NAQ 0x0010 -#define FF_MPV_FLAG_MV0 0x0020 - -#define FF_MPV_OPT_CMP_FUNC \ -{ "sad", "Sum of absolute differences, fast", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SAD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "sse", "Sum of squared errors", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SSE }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "satd", "Sum of absolute Hadamard transformed differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SATD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "dct", "Sum of absolute DCT transformed differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_DCT }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "psnr", "Sum of squared quantization errors, low quality", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_PSNR }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "bit", "Number of bits needed for the block", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_BIT }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "rd", "Rate distortion optimal, slow", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_RD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "zero", "Zero", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_ZERO }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "vsad", "Sum of absolute vertical differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_VSAD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "vsse", "Sum of squared vertical differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_VSSE }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "nsse", "Noise preserving sum of squared differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_NSSE }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "dct264", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_DCT264 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "dctmax", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "chroma", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_CHROMA }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "msad", "Sum of absolute differences, median predicted", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_MEDIAN_SAD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" } - -#ifndef FF_MPV_OFFSET -#define FF_MPV_OFFSET(x) offsetof(MpegEncContext, x) -#endif -#define FF_MPV_OPT_FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM) -#define FF_MPV_COMMON_OPTS \ -FF_MPV_OPT_CMP_FUNC, \ -{ "mpv_flags", "Flags common for all mpegvideo-based encoders.", FF_MPV_OFFSET(mpv_flags), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "mpv_flags" },\ -{ "skip_rd", "RD optimal MB level residual skipping", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_SKIP_RD }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\ -{ "strict_gop", "Strictly enforce gop size", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_STRICT_GOP }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\ -{ "qp_rd", "Use rate distortion optimization for qp selection", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_QP_RD }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\ -{ "cbp_rd", "use rate distortion optimization for CBP", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_CBP_RD }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\ -{ "naq", "normalize adaptive quantization", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_NAQ }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\ -{ "mv0", "always try a mb with mv=<0,0>", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_MV0 }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\ -{ "luma_elim_threshold", "single coefficient elimination threshold for luminance (negative values also consider dc coefficient)",\ - FF_MPV_OFFSET(luma_elim_threshold), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS },\ -{ "chroma_elim_threshold", "single coefficient elimination threshold for chrominance (negative values also consider dc coefficient)",\ - FF_MPV_OFFSET(chroma_elim_threshold), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS },\ -{ "quantizer_noise_shaping", NULL, FF_MPV_OFFSET(quantizer_noise_shaping), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FF_MPV_OPT_FLAGS },\ -{ "error_rate", "Simulate errors in the bitstream to test error concealment.", \ - FF_MPV_OFFSET(error_rate), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FF_MPV_OPT_FLAGS },\ -{"qsquish", "how to keep quantizer between qmin and qmax (0 = clip, 1 = use differentiable function)", \ - FF_MPV_OFFSET(rc_qsquish), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, 0, 99, FF_MPV_OPT_FLAGS}, \ -{"rc_qmod_amp", "experimental quantizer modulation", FF_MPV_OFFSET(rc_qmod_amp), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ -{"rc_qmod_freq", "experimental quantizer modulation", FF_MPV_OFFSET(rc_qmod_freq), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS}, \ -{"rc_eq", "Set rate control equation. When computing the expression, besides the standard functions " \ - "defined in the section 'Expression Evaluation', the following functions are available: " \ - "bits2qp(bits), qp2bits(qp). Also the following constants are available: iTex pTex tex mv " \ - "fCode iCount mcVar var isI isP isB avgQP qComp avgIITex avgPITex avgPPTex avgBPTex avgTex.", \ - FF_MPV_OFFSET(rc_eq), AV_OPT_TYPE_STRING, .flags = FF_MPV_OPT_FLAGS }, \ -{"rc_init_cplx", "initial complexity for 1-pass encoding", FF_MPV_OFFSET(rc_initial_cplx), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ -{"rc_buf_aggressivity", "currently useless", FF_MPV_OFFSET(rc_buffer_aggressivity), AV_OPT_TYPE_FLOAT, {.dbl = 1.0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ -{"border_mask", "increase the quantizer for macroblocks close to borders", FF_MPV_OFFSET(border_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ -{"lmin", "minimum Lagrange factor (VBR)", FF_MPV_OFFSET(lmin), AV_OPT_TYPE_INT, {.i64 = 2*FF_QP2LAMBDA }, 0, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"lmax", "maximum Lagrange factor (VBR)", FF_MPV_OFFSET(lmax), AV_OPT_TYPE_INT, {.i64 = 31*FF_QP2LAMBDA }, 0, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"ibias", "intra quant bias", FF_MPV_OFFSET(intra_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"pbias", "inter quant bias", FF_MPV_OFFSET(inter_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"motion_est", "motion estimation algorithm", FF_MPV_OFFSET(motion_est), AV_OPT_TYPE_INT, {.i64 = FF_ME_EPZS }, FF_ME_ZERO, FF_ME_XONE, FF_MPV_OPT_FLAGS, "motion_est" }, \ -{ "zero", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_ZERO }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \ -{ "epzs", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_EPZS }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \ -{ "xone", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_XONE }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \ -{"skip_threshold", "Frame skip threshold", FF_MPV_OFFSET(frame_skip_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"skip_factor", "Frame skip factor", FF_MPV_OFFSET(frame_skip_factor), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"skip_exp", "Frame skip exponent", FF_MPV_OFFSET(frame_skip_exp), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"skip_cmp", "Frame skip compare function", FF_MPV_OFFSET(frame_skip_cmp), AV_OPT_TYPE_INT, {.i64 = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "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 }, \ -{"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 \ -{"b_strategy", "Strategy to choose between I/P/B-frames", FF_MPV_OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, FF_MPV_OPT_FLAGS }, \ -{"b_sensitivity", "Adjust sensitivity of b_frame_strategy 1", FF_MPV_OFFSET(b_sensitivity), AV_OPT_TYPE_INT, {.i64 = 40 }, 1, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"brd_scale", "Downscale frames for dynamic B-frame decision", FF_MPV_OFFSET(brd_scale), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 3, FF_MPV_OPT_FLAGS }, - -#if FF_API_MPEGVIDEO_OPTS -#define FF_MPV_DEPRECATED_MPEG_QUANT_OPT \ - { "mpeg_quant", "Deprecated, does nothing", FF_MPV_OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 0, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, -#define FF_MPV_DEPRECATED_A53_CC_OPT \ - { "a53cc", "Deprecated, does nothing", FF_MPV_OFFSET(dummy), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, -#define FF_MPV_DEPRECATED_MATRIX_OPT \ - { "force_duplicated_matrix", "Deprecated, does nothing", FF_MPV_OFFSET(dummy), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, -#define FF_MPV_DEPRECATED_BFRAME_OPTS \ - { "b_strategy", "Deprecated, does nothing", FF_MPV_OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, \ - { "b_sensitivity", "Deprecated, does nothing", FF_MPV_OFFSET(b_sensitivity), AV_OPT_TYPE_INT, { .i64 = 40 }, 1, INT_MAX, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, \ - { "brd_scale", "Deprecated, does nothing", FF_MPV_OFFSET(brd_scale), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 3, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, -#endif - -extern const AVClass ff_mpv_enc_class; /** * Set the given MpegEncContext to common defaults (same for encoding @@ -661,8 +561,6 @@ extern const AVClass ff_mpv_enc_class; */ void ff_mpv_common_defaults(MpegEncContext *s); -void ff_dct_encode_init_x86(MpegEncContext *s); - int ff_mpv_common_init(MpegEncContext *s); void ff_mpv_common_init_arm(MpegEncContext *s); void ff_mpv_common_init_axp(MpegEncContext *s); @@ -703,14 +601,6 @@ void ff_mpv_report_decode_progress(MpegEncContext *s); int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx); void ff_mpv_frame_end(MpegEncContext *s); -int ff_mpv_encode_init(AVCodecContext *avctx); -void ff_mpv_encode_init_x86(MpegEncContext *s); - -int ff_mpv_encode_end(AVCodecContext *avctx); -int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, - const AVFrame *frame, int *got_packet); -int ff_mpv_reallocate_putbitbuffer(MpegEncContext *s, size_t threshold, size_t size_increase); - void ff_clean_intra_table_entries(MpegEncContext *s); void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h); void ff_mpeg_flush(AVCodecContext *avctx); @@ -719,19 +609,11 @@ void ff_print_debug_info(MpegEncContext *s, Picture *p, AVFrame *pict); int ff_mpv_export_qp_table(MpegEncContext *s, AVFrame *f, Picture *p, int qp_type); -void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix); - int ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src); int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src); void ff_set_qscale(MpegEncContext * s, int qscale); void ff_mpv_idct_init(MpegEncContext *s); -int ff_dct_encode_init(MpegEncContext *s); -void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64], uint16_t (*qmat16)[2][64], - const uint16_t *quant_matrix, int bias, int qmin, int qmax, int intra); -int ff_dct_quantize_c(MpegEncContext *s, int16_t *block, int n, int qscale, int *overflow); -void ff_block_permute(int16_t *block, uint8_t *permutation, - const uint8_t *scantable, int last); void ff_init_block_index(MpegEncContext *s); void ff_mpv_motion(MpegEncContext *s, @@ -756,15 +638,6 @@ static inline void ff_update_block_index(MpegEncContext *s){ s->dest[2]+= (2 >> s->chroma_x_shift) * block_size; } -static inline int get_bits_diff(MpegEncContext *s){ - const int bits= put_bits_count(&s->pb); - const int last= s->last_bits; - - s->last_bits = bits; - - return bits - last; -} - static inline int mpeg_get_qscale(MpegEncContext *s) { int qscale = get_bits(&s->gb, 5); diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index a8146c6473..05c73fee87 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -49,6 +49,7 @@ #include "mpeg12enc.h" #include "mpegvideo.h" #include "mpegvideodata.h" +#include "mpegvideoenc.h" #include "h261enc.h" #include "h263.h" #include "h263data.h" diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h new file mode 100644 index 0000000000..9619f6787a --- /dev/null +++ b/libavcodec/mpegvideoenc.h @@ -0,0 +1,161 @@ +/* + * Generic DCT based hybrid video encoder + * Copyright (c) 2000, 2001, 2002 Fabrice Bellard + * Copyright (c) 2002-2004 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * mpegvideo header. + */ + +#ifndef AVCODEC_MPEGVIDEOENC_H +#define AVCODEC_MPEGVIDEOENC_H + +#include "libavutil/opt.h" +#include "internal.h" +#include "mpegvideo.h" + +#define UNI_AC_ENC_INDEX(run,level) ((run)*128 + (level)) + +/* mpegvideo_enc common options */ +#define FF_MPV_FLAG_SKIP_RD 0x0001 +#define FF_MPV_FLAG_STRICT_GOP 0x0002 +#define FF_MPV_FLAG_QP_RD 0x0004 +#define FF_MPV_FLAG_CBP_RD 0x0008 +#define FF_MPV_FLAG_NAQ 0x0010 +#define FF_MPV_FLAG_MV0 0x0020 + +#define FF_MPV_OPT_CMP_FUNC \ +{ "sad", "Sum of absolute differences, fast", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SAD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "sse", "Sum of squared errors", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SSE }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "satd", "Sum of absolute Hadamard transformed differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SATD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "dct", "Sum of absolute DCT transformed differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_DCT }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "psnr", "Sum of squared quantization errors, low quality", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_PSNR }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "bit", "Number of bits needed for the block", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_BIT }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "rd", "Rate distortion optimal, slow", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_RD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "zero", "Zero", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_ZERO }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "vsad", "Sum of absolute vertical differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_VSAD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "vsse", "Sum of squared vertical differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_VSSE }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "nsse", "Noise preserving sum of squared differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_NSSE }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "dct264", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_DCT264 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "dctmax", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "chroma", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_CHROMA }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "msad", "Sum of absolute differences, median predicted", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_MEDIAN_SAD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" } + +#define FF_MPV_OFFSET(x) offsetof(MpegEncContext, x) +#define FF_MPV_OPT_FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM) +#define FF_MPV_COMMON_OPTS \ +FF_MPV_OPT_CMP_FUNC, \ +{ "mpv_flags", "Flags common for all mpegvideo-based encoders.", FF_MPV_OFFSET(mpv_flags), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "mpv_flags" },\ +{ "skip_rd", "RD optimal MB level residual skipping", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_SKIP_RD }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\ +{ "strict_gop", "Strictly enforce gop size", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_STRICT_GOP }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\ +{ "qp_rd", "Use rate distortion optimization for qp selection", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_QP_RD }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\ +{ "cbp_rd", "use rate distortion optimization for CBP", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_CBP_RD }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\ +{ "naq", "normalize adaptive quantization", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_NAQ }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\ +{ "mv0", "always try a mb with mv=<0,0>", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_MV0 }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\ +{ "luma_elim_threshold", "single coefficient elimination threshold for luminance (negative values also consider dc coefficient)",\ + FF_MPV_OFFSET(luma_elim_threshold), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS },\ +{ "chroma_elim_threshold", "single coefficient elimination threshold for chrominance (negative values also consider dc coefficient)",\ + FF_MPV_OFFSET(chroma_elim_threshold), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS },\ +{ "quantizer_noise_shaping", NULL, FF_MPV_OFFSET(quantizer_noise_shaping), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FF_MPV_OPT_FLAGS },\ +{ "error_rate", "Simulate errors in the bitstream to test error concealment.", \ + FF_MPV_OFFSET(error_rate), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FF_MPV_OPT_FLAGS },\ +{"qsquish", "how to keep quantizer between qmin and qmax (0 = clip, 1 = use differentiable function)", \ + FF_MPV_OFFSET(rc_qsquish), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, 0, 99, FF_MPV_OPT_FLAGS}, \ +{"rc_qmod_amp", "experimental quantizer modulation", FF_MPV_OFFSET(rc_qmod_amp), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ +{"rc_qmod_freq", "experimental quantizer modulation", FF_MPV_OFFSET(rc_qmod_freq), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS}, \ +{"rc_eq", "Set rate control equation. When computing the expression, besides the standard functions " \ + "defined in the section 'Expression Evaluation', the following functions are available: " \ + "bits2qp(bits), qp2bits(qp). Also the following constants are available: iTex pTex tex mv " \ + "fCode iCount mcVar var isI isP isB avgQP qComp avgIITex avgPITex avgPPTex avgBPTex avgTex.", \ + FF_MPV_OFFSET(rc_eq), AV_OPT_TYPE_STRING, .flags = FF_MPV_OPT_FLAGS }, \ +{"rc_init_cplx", "initial complexity for 1-pass encoding", FF_MPV_OFFSET(rc_initial_cplx), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ +{"rc_buf_aggressivity", "currently useless", FF_MPV_OFFSET(rc_buffer_aggressivity), AV_OPT_TYPE_FLOAT, {.dbl = 1.0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ +{"border_mask", "increase the quantizer for macroblocks close to borders", FF_MPV_OFFSET(border_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ +{"lmin", "minimum Lagrange factor (VBR)", FF_MPV_OFFSET(lmin), AV_OPT_TYPE_INT, {.i64 = 2*FF_QP2LAMBDA }, 0, INT_MAX, FF_MPV_OPT_FLAGS }, \ +{"lmax", "maximum Lagrange factor (VBR)", FF_MPV_OFFSET(lmax), AV_OPT_TYPE_INT, {.i64 = 31*FF_QP2LAMBDA }, 0, INT_MAX, FF_MPV_OPT_FLAGS }, \ +{"ibias", "intra quant bias", FF_MPV_OFFSET(intra_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ +{"pbias", "inter quant bias", FF_MPV_OFFSET(inter_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ +{"motion_est", "motion estimation algorithm", FF_MPV_OFFSET(motion_est), AV_OPT_TYPE_INT, {.i64 = FF_ME_EPZS }, FF_ME_ZERO, FF_ME_XONE, FF_MPV_OPT_FLAGS, "motion_est" }, \ +{ "zero", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_ZERO }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \ +{ "epzs", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_EPZS }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \ +{ "xone", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_XONE }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \ +{"skip_threshold", "Frame skip threshold", FF_MPV_OFFSET(frame_skip_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ +{"skip_factor", "Frame skip factor", FF_MPV_OFFSET(frame_skip_factor), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ +{"skip_exp", "Frame skip exponent", FF_MPV_OFFSET(frame_skip_exp), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ +{"skip_cmp", "Frame skip compare function", FF_MPV_OFFSET(frame_skip_cmp), AV_OPT_TYPE_INT, {.i64 = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "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 }, \ +{"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 \ +{"b_strategy", "Strategy to choose between I/P/B-frames", FF_MPV_OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, FF_MPV_OPT_FLAGS }, \ +{"b_sensitivity", "Adjust sensitivity of b_frame_strategy 1", FF_MPV_OFFSET(b_sensitivity), AV_OPT_TYPE_INT, {.i64 = 40 }, 1, INT_MAX, FF_MPV_OPT_FLAGS }, \ +{"brd_scale", "Downscale frames for dynamic B-frame decision", FF_MPV_OFFSET(brd_scale), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 3, FF_MPV_OPT_FLAGS }, + +#if FF_API_MPEGVIDEO_OPTS +#define FF_MPV_DEPRECATED_MPEG_QUANT_OPT \ + { "mpeg_quant", "Deprecated, does nothing", FF_MPV_OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 0, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, +#define FF_MPV_DEPRECATED_A53_CC_OPT \ + { "a53cc", "Deprecated, does nothing", FF_MPV_OFFSET(dummy), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, +#define FF_MPV_DEPRECATED_MATRIX_OPT \ + { "force_duplicated_matrix", "Deprecated, does nothing", FF_MPV_OFFSET(dummy), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, +#define FF_MPV_DEPRECATED_BFRAME_OPTS \ + { "b_strategy", "Deprecated, does nothing", FF_MPV_OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, \ + { "b_sensitivity", "Deprecated, does nothing", FF_MPV_OFFSET(b_sensitivity), AV_OPT_TYPE_INT, { .i64 = 40 }, 1, INT_MAX, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, \ + { "brd_scale", "Deprecated, does nothing", FF_MPV_OFFSET(brd_scale), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 3, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, +#endif + +extern const AVClass ff_mpv_enc_class; + +int ff_mpv_encode_init(AVCodecContext *avctx); +void ff_mpv_encode_init_x86(MpegEncContext *s); + +int ff_mpv_encode_end(AVCodecContext *avctx); +int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, + const AVFrame *frame, int *got_packet); +int ff_mpv_reallocate_putbitbuffer(MpegEncContext *s, size_t threshold, size_t size_increase); + +void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix); + +int ff_dct_encode_init(MpegEncContext *s); +void ff_dct_encode_init_x86(MpegEncContext *s); + +int ff_dct_quantize_c(MpegEncContext *s, int16_t *block, int n, int qscale, int *overflow); +void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64], uint16_t (*qmat16)[2][64], + const uint16_t *quant_matrix, int bias, int qmin, int qmax, int intra); + +void ff_block_permute(int16_t *block, uint8_t *permutation, + const uint8_t *scantable, int last); + +static inline int get_bits_diff(MpegEncContext *s) +{ + const int bits = put_bits_count(&s->pb); + const int last = s->last_bits; + + s->last_bits = bits; + + return bits - last; +} + +#endif diff --git a/libavcodec/msmpeg4enc.c b/libavcodec/msmpeg4enc.c index 16e19083da..5e1ed9cc27 100644 --- a/libavcodec/msmpeg4enc.c +++ b/libavcodec/msmpeg4enc.c @@ -34,6 +34,7 @@ #include "libavutil/avutil.h" #include "libavutil/thread.h" #include "mpegvideo.h" +#include "mpegvideoenc.h" #include "h263.h" #include "h263enc.h" #include "internal.h" diff --git a/libavcodec/nvdec_mpeg12.c b/libavcodec/nvdec_mpeg12.c index 9a9030d8d3..b8db4250bb 100644 --- a/libavcodec/nvdec_mpeg12.c +++ b/libavcodec/nvdec_mpeg12.c @@ -21,6 +21,7 @@ */ #include "avcodec.h" +#include "internal.h" #include "mpegvideo.h" #include "nvdec.h" #include "decode.h" diff --git a/libavcodec/nvdec_mpeg4.c b/libavcodec/nvdec_mpeg4.c index a134423382..b7e1821754 100644 --- a/libavcodec/nvdec_mpeg4.c +++ b/libavcodec/nvdec_mpeg4.c @@ -21,6 +21,7 @@ */ #include "avcodec.h" +#include "internal.h" #include "mpeg4video.h" #include "mpeg4videodec.h" #include "nvdec.h" diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c index 6b77ccd006..f814e23ed5 100644 --- a/libavcodec/ratecontrol.c +++ b/libavcodec/ratecontrol.c @@ -32,7 +32,7 @@ #include "internal.h" #include "ratecontrol.h" #include "mpegutils.h" -#include "mpegvideo.h" +#include "mpegvideoenc.h" #include "libavutil/eval.h" void ff_write_pass1_stats(MpegEncContext *s) diff --git a/libavcodec/rv10enc.c b/libavcodec/rv10enc.c index dbc7a370f4..a9922bda50 100644 --- a/libavcodec/rv10enc.c +++ b/libavcodec/rv10enc.c @@ -26,6 +26,7 @@ */ #include "mpegvideo.h" +#include "mpegvideoenc.h" #include "put_bits.h" #include "rv10enc.h" diff --git a/libavcodec/rv20enc.c b/libavcodec/rv20enc.c index 892107f1f8..1baeea0b7d 100644 --- a/libavcodec/rv20enc.c +++ b/libavcodec/rv20enc.c @@ -27,6 +27,7 @@ #include "mpegvideo.h" #include "mpegvideodata.h" +#include "mpegvideoenc.h" #include "h263data.h" #include "h263enc.h" #include "put_bits.h" diff --git a/libavcodec/rv30.c b/libavcodec/rv30.c index 751647bebe..d11b8430e7 100644 --- a/libavcodec/rv30.c +++ b/libavcodec/rv30.c @@ -25,6 +25,7 @@ */ #include "avcodec.h" +#include "internal.h" #include "mpegutils.h" #include "mpegvideo.h" #include "golomb.h" diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c index 31a7a04e51..0b3f733bc6 100644 --- a/libavcodec/rv40.c +++ b/libavcodec/rv40.c @@ -29,6 +29,7 @@ #include "libavutil/imgutils.h" #include "avcodec.h" +#include "internal.h" #include "mpegutils.h" #include "mpegvideo.h" #include "golomb.h" diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c index 2a310a6c4f..5b40011e40 100644 --- a/libavcodec/speedhqenc.c +++ b/libavcodec/speedhqenc.c @@ -33,6 +33,7 @@ #include "mpeg12data.h" #include "mpeg12enc.h" #include "mpegvideo.h" +#include "mpegvideoenc.h" #include "speedhqenc.h" extern RLTable ff_rl_speedhq; diff --git a/libavcodec/vaapi_encode_mpeg2.c b/libavcodec/vaapi_encode_mpeg2.c index af3a63dab7..d084d8c4b9 100644 --- a/libavcodec/vaapi_encode_mpeg2.c +++ b/libavcodec/vaapi_encode_mpeg2.c @@ -20,10 +20,12 @@ #include #include "libavutil/avassert.h" +#include "libavutil/opt.h" #include "avcodec.h" #include "cbs.h" #include "cbs_mpeg2.h" +#include "internal.h" #include "mpeg12.h" #include "vaapi_encode.h" diff --git a/libavcodec/wmv2enc.c b/libavcodec/wmv2enc.c index 227947c146..f6ff697043 100644 --- a/libavcodec/wmv2enc.c +++ b/libavcodec/wmv2enc.c @@ -21,6 +21,7 @@ #include "avcodec.h" #include "h263.h" #include "mpegvideo.h" +#include "mpegvideoenc.h" #include "msmpeg4.h" #include "msmpeg4enc.h" #include "msmpeg4data.h" diff --git a/libavcodec/x86/mpegvideoenc.c b/libavcodec/x86/mpegvideoenc.c index 4bad6a87ef..3691cce26c 100644 --- a/libavcodec/x86/mpegvideoenc.c +++ b/libavcodec/x86/mpegvideoenc.c @@ -26,7 +26,7 @@ #include "libavutil/x86/cpu.h" #include "libavcodec/avcodec.h" #include "libavcodec/dct.h" -#include "libavcodec/mpegvideo.h" +#include "libavcodec/mpegvideoenc.h" /* not permutated inverse zigzag_direct + 1 for MMX quantizer */ DECLARE_ALIGNED(16, static const uint16_t, inv_zigzag_direct16)[64] = { From patchwork Tue Feb 1 13:06:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33998 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp604863iov; Tue, 1 Feb 2022 05:12:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJzSPSdsIHGd8ZfXYoK9wr75JSdZW9cOTIk8tA4kr1FKK32cqF6RSblrray0hvxtnLF6qcJu X-Received: by 2002:a05:6402:1007:: with SMTP id c7mr3625221edu.424.1643721160149; Tue, 01 Feb 2022 05:12:40 -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 c20si8746256ejj.420.2022.02.01.05.12.39; Tue, 01 Feb 2022 05:12:40 -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=Qp3PAOJJ; 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 DF8D568B347; Tue, 1 Feb 2022 15:07:55 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2084.outbound.protection.outlook.com [40.92.89.84]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 451C368B33A for ; Tue, 1 Feb 2022 15:07:52 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gyPPwz878bxW/Rtzj+jlTczUOuvBePk0e+i0cjYooyl03PAt3XVI0Z1YJmNBd7MS1atM5rkXmq0kOzM6jGETtdQy9H+FolbPg4aEJhNPdL7OujD2bRm7zX/On7+1FyJyj3kqSVHze/sob5Y+i+yPrr5nm8CFjsrFx9+2ma3QpYtXDVNHwq44ujiA7cbhWpSvbXqgazjsgKtsbjOk9WghmtD2AHyoZjwNSwSbewuiGV4CztkgB6F5chJHGk4b3AGlp+RAAp9niitp6uX8CTfyqakhuVi3dPGDUByJ59qWQUjEVNdZxh1ny87DyfXdwQWn7mO+bxCSwtQBU0g4xF78bA== 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=rJrOUxlBqTEGAKw6qSUrNppk1O8eJKTEOzsHTyNvaB4=; b=D5GFVspHDrvapo+nvlN1aygF7jnoUGfg5VbdC1OckWyNRwlIJRHXq0HkD5/0FUfteGXpBa7pPEKf1uCY7O4eE0oZcl9LkXZPoSP0jfWHaov/ProbJipISyanjxB2jkjvmvlYUFN4yseBrRDX1oJx2H9KyI3u/K0T7NzW8RoWPX2HnfV9Je5qzegGkmBwXUm7RvJJ3WdOCn58DviF8cgafOERKZYevY/auIEavAjHY8j0AR01+bD5qCQlVpFvhzPNOHVS31jNINubTALrdxo48f/AHHY7wa/iqqRg9/foM8CgEWsmIUxfBooSVX8nHkakLq09NjAevMYkP36ecsPG6w== 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=rJrOUxlBqTEGAKw6qSUrNppk1O8eJKTEOzsHTyNvaB4=; b=Qp3PAOJJcp0239Y9V2Fox5YKwSFT9VEmynDPy8vt/x3CvRZS6d+2EiEa16i6ONpjI4WAMtbx8CG+ZD8ac1dWRVnq/Yzp0f0y4SDE6a6/dDOprecBhAFL0UlhdWbNz26aj5XZgetnZk2qEGj3C4+x0uGAAcbeyJmbu7E1owxLxwREboECfgnQv5D4EcfGROJ3dhHQsonoMoD1M7R00mWHpmulIf0v1MPNGo95ssWzviAT5jhAnvLNycmW0rDK/kSpl3ovruEdmBu2DQKMYChY2N7QAWYn/lFGamlGNjcZ8hia00PBkTBbTEsJI22sKyzQFjFmNmyC3mck93Vk5lh5wA== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR03MB5700.eurprd03.prod.outlook.com (2603:10a6:208:16f::32) 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:50 +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:50 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:21 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [VkEcLv2AuCPvoELnEflaw4rEqcHqCfIy] 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-23-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b6f9c835-f7ee-41b5-e195-08d9e583d95b X-MS-TrafficTypeDiagnostic: AM0PR03MB5700:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fHntpsLPWMnqd/FvkFEOpd2Ts+2COowLjUytlOsI38sQCRk+A1V0y8WgzmaOoHLtRecYNtgkp41WRzMTL+CDkNRQ326drsGd6jMztiw3H6f/WxxFVjn+4M0l/+C+Z03Js/j8RvklWwHl261viGGluCAe9pGrbdiLzmC9wPnkA8cCDjzoKvM1kuSsgqM+Vr1prZdPO6osesAz0pUMctux8cFEAyoarlTbHw32UXaejEeekQfATNluESAL4ZKY3iPoG4fQjV/Xg4yDOt+XFv5vcTyzsGb1vS5cO+q3invWZuyUvxcmZr8boCI5PHOl0Hb7LqfOLRrfvB5BsN6Y6LIEcn6X+2Q+I2weMG698prJH0TeYRi+vgETvM1xOTfTE/CT3P0uUXn4G+FbukbcOx55z55fzhZgVjtr7Tx8If8iqYLIBLeynwJxu3Au2r02fAesEz7A055wCVVOoobTLDtEOrTpo1Xd1lZj5jTZ82MwcFNOX0rLP0hFHrmSro2uysYchklMKEnMy0PawIZOvnKABwaR8RZPcW/2hfNpTWz73IEjEDJdgraoQ0414ijK79S9 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NVyZOGVmFCYD90iJknCIIyHT2uxFLonptnJKU0uIc33l4RHeNmiIlP9f15imsaz0l4rnZO5KxS/URSNFP3+vBVyk3Kunb/hhBLypJPCjuvCZ1xPv/HmZWoLkaHzZjuqLGVc32jt8ol53aVEhL7n/L4mGnBSVyW5ocgBZbk6XVHTgsIAU78hiIDy1fkyl1g3Eqkfj3H8R65VxYTN5tdoTxUa1eHQYQ55Niwfp3xHiZ7WEXe6Y739/VRGZypDufXgjFwbvXkePrJ4HGIe1iQ7zXmLr17bWtSCytFDcpYMuCLsnTzJlUUs0FHyfngikS2FPlgLNL1lm2Ni2idC31Sh++YiFqtyUZ5JOB87IMFj98eYJK++HszDgAk57IQi5maXdWea1+ezdyBYve0LJ1l8on8NC+SNEUW3FRFkhaVg15LGRCjvBHCLnfvck9iFDXHxDS6BcZAnf02KS/VIFAdidAW7fF+SnEo6MsEI2+pfoDp0Nbz5192sYzuT8vn6+9OCiB59kZBNdJs1cIn5Xr5qufKYz+MO5NCYsrsbU0grPdTQT8tOvTmfWXftzDa1uroBVDDKpfNaCGBZKYGhVA6Fr3Zge2PgIfyNIQlawG4vTmVxNYNxGXGO2LKzvoK3gHjJub4TtY5bzvnYEcNId09vezwjNfAUD09qtYIwzpVodNNYfU/BG/DpL6uxKlN6YUNWIZ0IJQOGrLhUnffTmVkHBR91cew2i4H5WHjn4fcsVFemgJEfLU1/xO1wPMyAZ2V1A+S6qXyK5IB6ReoN3bzGlz+zPEIBVpLGLgBy7c0d6/3zUHHrbVG3LzMs3KiGD4O53/LZadt62+lH8f0qPCFk6Apx2q8rOBPoaxT4N9p9hEnYTTyCNvI+20jA39VY5cGdvMWr92JSEp09kfvcPlHofZFRa7mFOufpow0z1nU0lHQW/tUf6m4RbrRLCgGjEx8CmOp0QVb2jMI7bJlDBdcSoyg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b6f9c835-f7ee-41b5-e195-08d9e583d95b 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:50.0570 (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: AM0PR03MB5700 Subject: [FFmpeg-devel] [PATCH v2 24/69] avcodec/mpegvideo: Move decoder-only stuff to a new header 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: UUw+xKXFmUTQ Signed-off-by: Andreas Rheinhardt --- libavcodec/dxva2_vc1.c | 1 + libavcodec/h261dec.c | 1 + libavcodec/h263dec.c | 1 + libavcodec/mpeg12dec.c | 1 + libavcodec/mpeg4videodec.c | 1 + libavcodec/mpegvideo.h | 28 ---------------- libavcodec/mpegvideo_dec.c | 1 + libavcodec/mpegvideodec.h | 67 ++++++++++++++++++++++++++++++++++++++ libavcodec/mss2.c | 1 + libavcodec/rv10.c | 1 + libavcodec/rv30.c | 1 + libavcodec/rv34.c | 1 + libavcodec/rv40.c | 1 + libavcodec/vaapi_mpeg2.c | 1 + libavcodec/vaapi_mpeg4.c | 1 + libavcodec/vaapi_vc1.c | 1 + libavcodec/vc1_block.c | 1 + libavcodec/vc1dec.c | 1 + libavcodec/vdpau.c | 1 + 19 files changed, 84 insertions(+), 28 deletions(-) create mode 100644 libavcodec/mpegvideodec.h diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c index f08ac8b5a0..5fd6957d0c 100644 --- a/libavcodec/dxva2_vc1.c +++ b/libavcodec/dxva2_vc1.c @@ -22,6 +22,7 @@ #include "dxva2_internal.h" #include "mpegutils.h" +#include "mpegvideodec.h" #include "vc1.h" #include "vc1data.h" diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c index 17f1067b15..5e732b05bf 100644 --- a/libavcodec/h261dec.c +++ b/libavcodec/h261dec.c @@ -31,6 +31,7 @@ #include "mpeg_er.h" #include "mpegutils.h" #include "mpegvideo.h" +#include "mpegvideodec.h" #include "h261.h" #include "internal.h" diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index bf2e9b1583..df9ac2f831 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -47,6 +47,7 @@ #endif #include "mpegutils.h" #include "mpegvideo.h" +#include "mpegvideodec.h" #include "msmpeg4dec.h" #include "qpeldsp.h" #include "thread.h" diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index d55a4d2feb..a3a7e86ccf 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -47,6 +47,7 @@ #include "mpegutils.h" #include "mpegvideo.h" #include "mpegvideodata.h" +#include "mpegvideodec.h" #include "profiles.h" #include "thread.h" #include "xvmc_internal.h" diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index a437f233ec..6d7f7f66f9 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -33,6 +33,7 @@ #include "mpegutils.h" #include "mpegvideo.h" #include "mpegvideodata.h" +#include "mpegvideodec.h" #include "mpeg4video.h" #include "mpeg4videodata.h" #include "mpeg4videodec.h" diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index e16f850f30..c4ac7bc966 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -44,7 +44,6 @@ #include "mpegpicture.h" #include "mpegvideodsp.h" #include "mpegvideoencdsp.h" -#include "mpegvideodata.h" #include "pixblockdsp.h" #include "put_bits.h" #include "ratecontrol.h" @@ -586,31 +585,13 @@ int ff_mpv_init_context_frame(MpegEncContext *s); */ void ff_mpv_free_context_frame(MpegEncContext *s); -int ff_mpv_common_frame_size_change(MpegEncContext *s); void ff_mpv_common_end(MpegEncContext *s); -/** - * Initialize the given MpegEncContext for decoding. - * the changed fields will not depend upon - * the prior state of the MpegEncContext. - */ -void ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx); void ff_mpv_reconstruct_mb(MpegEncContext *s, int16_t block[12][64]); -void ff_mpv_report_decode_progress(MpegEncContext *s); - -int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx); -void ff_mpv_frame_end(MpegEncContext *s); void ff_clean_intra_table_entries(MpegEncContext *s); -void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h); -void ff_mpeg_flush(AVCodecContext *avctx); - -void ff_print_debug_info(MpegEncContext *s, Picture *p, AVFrame *pict); - -int ff_mpv_export_qp_table(MpegEncContext *s, AVFrame *f, Picture *p, int qp_type); int ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src); -int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src); void ff_set_qscale(MpegEncContext * s, int qscale); void ff_mpv_idct_init(MpegEncContext *s); @@ -638,13 +619,4 @@ static inline void ff_update_block_index(MpegEncContext *s){ s->dest[2]+= (2 >> s->chroma_x_shift) * block_size; } -static inline int mpeg_get_qscale(MpegEncContext *s) -{ - int qscale = get_bits(&s->gb, 5); - if (s->q_scale_type) - return ff_mpeg2_non_linear_qscale[qscale]; - else - return qscale << 1; -} - #endif /* AVCODEC_MPEGVIDEO_H */ diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c index cc23e070ea..b1b15c7fcf 100644 --- a/libavcodec/mpegvideo_dec.c +++ b/libavcodec/mpegvideo_dec.c @@ -31,6 +31,7 @@ #include "internal.h" #include "mpegutils.h" #include "mpegvideo.h" +#include "mpegvideodec.h" #include "thread.h" void ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx) diff --git a/libavcodec/mpegvideodec.h b/libavcodec/mpegvideodec.h new file mode 100644 index 0000000000..0cda0af733 --- /dev/null +++ b/libavcodec/mpegvideodec.h @@ -0,0 +1,67 @@ +/* + * MPEGVideo decoders header + * Copyright (c) 2000, 2001, 2002 Fabrice Bellard + * Copyright (c) 2002-2004 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * mpegvideo decoder header. + */ + +#ifndef AVCODEC_MPEGVIDEODEC_H +#define AVCODEC_MPEGVIDEODEC_H + +#include "libavutil/frame.h" +#include "avcodec.h" +#include "get_bits.h" +#include "mpegpicture.h" +#include "mpegvideo.h" +#include "mpegvideodata.h" + +/** + * Initialize the given MpegEncContext for decoding. + * the changed fields will not depend upon + * the prior state of the MpegEncContext. + */ +void ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx); + +int ff_mpv_common_frame_size_change(MpegEncContext *s); + +int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx); +void ff_mpv_report_decode_progress(MpegEncContext *s); +void ff_mpv_frame_end(MpegEncContext *s); + +int ff_mpv_export_qp_table(MpegEncContext *s, AVFrame *f, Picture *p, int qp_type); +int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src); +void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h); +void ff_mpeg_flush(AVCodecContext *avctx); + +void ff_print_debug_info(MpegEncContext *s, Picture *p, AVFrame *pict); + +static inline int mpeg_get_qscale(MpegEncContext *s) +{ + int qscale = get_bits(&s->gb, 5); + if (s->q_scale_type) + return ff_mpeg2_non_linear_qscale[qscale]; + else + return qscale << 1; +} + +#endif /* AVCODEC_MPEGVIDEODEC_H */ diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c index dcf91f9828..65decf0a3c 100644 --- a/libavcodec/mss2.c +++ b/libavcodec/mss2.c @@ -27,6 +27,7 @@ #include "error_resilience.h" #include "internal.h" #include "mpeg_er.h" +#include "mpegvideodec.h" #include "msmpeg4dec.h" #include "qpeldsp.h" #include "vc1.h" diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c index 241ee53442..26cb9a2294 100644 --- a/libavcodec/rv10.c +++ b/libavcodec/rv10.c @@ -39,6 +39,7 @@ #include "mpeg_er.h" #include "mpegutils.h" #include "mpegvideo.h" +#include "mpegvideodec.h" #include "mpeg4video.h" #include "mpegvideodata.h" #include "rv10dec.h" diff --git a/libavcodec/rv30.c b/libavcodec/rv30.c index d11b8430e7..c84e09dd1a 100644 --- a/libavcodec/rv30.c +++ b/libavcodec/rv30.c @@ -28,6 +28,7 @@ #include "internal.h" #include "mpegutils.h" #include "mpegvideo.h" +#include "mpegvideodec.h" #include "golomb.h" #include "rv34.h" diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index e68072de06..bfef5f84cc 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -35,6 +35,7 @@ #include "error_resilience.h" #include "mpegutils.h" #include "mpegvideo.h" +#include "mpegvideodec.h" #include "golomb.h" #include "internal.h" #include "mathops.h" diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c index 0b3f733bc6..9cec0751e1 100644 --- a/libavcodec/rv40.c +++ b/libavcodec/rv40.c @@ -32,6 +32,7 @@ #include "internal.h" #include "mpegutils.h" #include "mpegvideo.h" +#include "mpegvideodec.h" #include "golomb.h" #include "rv34.h" diff --git a/libavcodec/vaapi_mpeg2.c b/libavcodec/vaapi_mpeg2.c index 26e0cd827c..2c27986490 100644 --- a/libavcodec/vaapi_mpeg2.c +++ b/libavcodec/vaapi_mpeg2.c @@ -23,6 +23,7 @@ #include "hwconfig.h" #include "mpegutils.h" #include "mpegvideo.h" +#include "mpegvideodec.h" #include "internal.h" #include "vaapi_decode.h" diff --git a/libavcodec/vaapi_mpeg4.c b/libavcodec/vaapi_mpeg4.c index 6800499c85..94f31dd026 100644 --- a/libavcodec/vaapi_mpeg4.c +++ b/libavcodec/vaapi_mpeg4.c @@ -25,6 +25,7 @@ #include "internal.h" #include "mpeg4videodec.h" #include "mpegvideo.h" +#include "mpegvideodec.h" #include "vaapi_decode.h" /** Reconstruct bitstream intra_dc_vlc_thr */ diff --git a/libavcodec/vaapi_vc1.c b/libavcodec/vaapi_vc1.c index 4e9607d9be..0ae5a65fb2 100644 --- a/libavcodec/vaapi_vc1.c +++ b/libavcodec/vaapi_vc1.c @@ -22,6 +22,7 @@ #include "hwconfig.h" #include "internal.h" +#include "mpegvideodec.h" #include "vaapi_decode.h" #include "vc1.h" #include "vc1data.h" diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c index c922efe4c8..119df4081d 100644 --- a/libavcodec/vc1_block.c +++ b/libavcodec/vc1_block.c @@ -29,6 +29,7 @@ #include "avcodec.h" #include "mpegutils.h" #include "mpegvideo.h" +#include "mpegvideodec.h" #include "msmpeg4data.h" #include "unary.h" #include "vc1.h" diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index 89cccc1929..700c787d99 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -33,6 +33,7 @@ #include "internal.h" #include "mpeg_er.h" #include "mpegvideo.h" +#include "mpegvideodec.h" #include "msmpeg4data.h" #include "msmpeg4dec.h" #include "profiles.h" diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c index f96ac15e2a..5072071c70 100644 --- a/libavcodec/vdpau.c +++ b/libavcodec/vdpau.c @@ -26,6 +26,7 @@ #include "avcodec.h" #include "decode.h" #include "internal.h" +#include "mpegvideodec.h" #include "vc1.h" #include "vdpau.h" #include "vdpau_internal.h" From patchwork Tue Feb 1 13:06:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33999 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp605078iov; Tue, 1 Feb 2022 05:12:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+MGEz8heMurHBRutW4J80X05eB0I8+27Gm61Zj4h4GfDOHrwkbLxzORRgMAb0a7fZO/N5 X-Received: by 2002:a17:906:5d09:: with SMTP id g9mr20405711ejt.510.1643721174695; Tue, 01 Feb 2022 05:12:54 -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 g15si9382988eds.333.2022.02.01.05.12.54; Tue, 01 Feb 2022 05:12:54 -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=hnjVcc4d; 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 D116568B2F9; Tue, 1 Feb 2022 15:07:56 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2084.outbound.protection.outlook.com [40.92.89.84]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 73A8568B33E for ; Tue, 1 Feb 2022 15:07:52 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nzyx2dflk00uXC3N52rVMvRqMG7fQZDioVssRf0v54SpphsukdLQ8MAJ08hc1qqR62vWBW786U/n1+m006I48k9iYeG/iDlVhl7U/HWbyHm4xyXtvoKFjjWeHz+xyqwmw5UixHfDeuK/0ZEW3xu0rchf06TeLry1mPmkPzaJn1osIqEbbXRagOS8mC+cFCHKW35Vg+5d6RLf5Y83ywYPOc6+VOAMlDgdrX18lrgjob9aVzr6pNWK/pspfVZ+QKLsY6wY/W+vWIvTitFjwDOt/BAbMt7mYiOyA9kviFiKH7GnHwXllySRFc007nFEQKt1/qQ8xEhDaFDUrZ7+bK8SeQ== 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=j+vE5s5+u577hePKlWNaoqxCcVj6aKRFgpWgoGeI8hI=; b=aDQVSfJyLMBjBTdWw6iGliEgtJYVM+qR40hVjKoEJIiYOZz3uRP2M/v2/xXz4cJzGdh3t7ubiCFoCSIfTUa1qD6nOqET41QRG5QiYkpV+MK55i69clOI+DSwJDbTPuR8QnJF0sJtUF5fv4hz+DtcdsnWctxvH0Z0CjbgJY10WVoH9fozqV6TMMSd23GMFzUYIn5vIIBNB7NMWc4ZqeeNcThNa/DzwP8k5YDv42jhlhEVK/QXGs7G3JskfrSvWcA0QAFSU/BjTWox1is5LPB0eJ369XsQiddDYRNvxsyabQ8d5xB1l7D2sNw874l5d+J1Dj0ppE0IkftW1Qy20aRmVQ== 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=j+vE5s5+u577hePKlWNaoqxCcVj6aKRFgpWgoGeI8hI=; b=hnjVcc4dqIO/Lxb/S/y6pK3mECBJxVbEsWSChWaYhfIT9JaU1pfv+G0R1OmGOQLmvz9ORIsZSJZKOvAtNrjUjDx57Vrr6V3R3yLqByQ+OJ64JEt8uy+7HvApNadImmBvL6vSTbDrRretm3fO6sJ0Bla2lxOpQzBl6Fe6pTq6wxHpSsRsJEG2/50AbG3YquU3aewhU58W3TY1e9HOTBkQgGz/oeaoeZmi9P/2CPGLDL3MW7ZzhnuMoiZJi3ppEXhpLDXiVKOHJlCB7jic+jaz/9qmaKn0NGwzz+K7n/nZNULsY6u/glZcSo4uyDUuKRzLgCBYSkvyj6gL3f6Q0R7VuA== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR03MB5700.eurprd03.prod.outlook.com (2603:10a6:208:16f::32) 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:51 +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:51 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:22 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [XSIqgCj0R/4XJTaE9TdlCA+gy4CItqFV] 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-24-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8a9c655f-8a04-4a23-a5b8-08d9e583da15 X-MS-TrafficTypeDiagnostic: AM0PR03MB5700:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3wes3tmJpswBvgaI58S6AxtGSvlmKkZA8HvskShYR6qtNJtQXsQQrLoDPD8sEqWLTNeQys5VuHJFQqb9AxeQSTXOq28DDkVN4kUSH8pzlQ7QztBTaZhBuWFwlq0q/AH2rlsp2hi28rZsyYQvM86+gi88jDot6lXbDe5hzr7qTwEolpqumuOctXRyrKHiQM7VBZPexWvwoYXoBrnDp86PRpScWYWLx4myruxhyosm7+mXTm9Unh6umWhrf5hA1fJnrPxIo6lvUioA/I3JZAdVp9IDUdGpEbthCi+XrXwm/k2nymL95jef+neWeGJB0OcuMAMHCW4SW8sEwHfqTUovSayNasqNDonzmBRGTibpoWbj1xbYRzzJDrI3hE8BT7cO+INlA4FSfBviTVo8l1ZE6dfTQo+0TaywvzTmYibBNu/1vBPePKJWLycyQBtbdH9FC9sGli6dhLDJ/mSokLyBoODOv91RJBWOicoPI6LrOAi2bfpBdNDae3+3L9rVYwqph9vdOjexa7rdlBmLw7oJs6+1uDlmS1RYtKCH9ca1hQv3PX+Z4BlhK6fhaSzHcFqa X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uuA/WhVrOmZRS8p0LYBXb4jNTZIgByIJUYIu5MSKIHfBruNZ/rffFWekmDeJNnfuQHLMe/RRqLBjirj3q0nq6mxd7AEkMPHTanszFyJIXQv6k/R9iXyMdB0AJiS4MOfRwW05s2z9mh6NFOj/qR8+XXS3SPq6wFLV08rnSl+J+USNhRPknUIY50Dc2bkXXbuuKM/SUJchuqB6Sz3Kf8vCfb4XykeCTNRX/nll6VD/V2/b+7cAIo90FC72eDJ57AjiXcUacfgRGBwNrUy4cAt5vTyhsW4HZRJkKJ/el6MFE87hjsB789yul2+THir+/+6De1QfQb7imCekL8yL04RblBVnPVjI3H4kC4Fs6HB2SJ5r1UyCMvR5fkACgeuuAqcMw9JPhEm7l12T5yRPOgnp7OyS12No4I0dpvElSyarY+bPM8KLhJKnXhQXr6QV5gb8czDEbMpxB2EmG90H2aWk0jbRXtpLHz8zKw4EVskR/4Ahrs9s/2o5Qltqfr8gQVRTi7DOfKDWcNlkvHH0ITKHkwEyt+KcVmLWDyrZnMYwN+qiVojcuZ6mLEI+LCTzFlhe75gyvDLFGWfsuuhaRj+eoDTXG3NvQwOLREUcXOnb16Z6BcNblcpN9fSB5SGH5fy+HO7Xsxw+jzGZXPct/b90icJ0AVETetn/+XDrIa/bMjBWlU5vsyGSsK/PCW8DnBSwkBHtpUdaX3s+eX3NwlfRVRWoIBjfjd0P/SNtJW43USJuAbOAYQDIgDgbES4acKLKG7XB9nNE/0Vx5nfo8ygQU3yMarzh0wv0qQw/vQGHRj+rh5EOJzsZGRJ1Pl1ah/q1+VEKkOfgZhSebG8ACryMXN5LzqldCIRDP+2BU7avFRmCXsdAuRR1mHoKchFgLDhIxD1F9awP1dqXgNbBXtIrRUbPxCy4YtWGl7PL5bcwHi15v5jeZ/UUSRUxOQMjmx+QJzNjPKFmQMAWzE5fJ52M2w== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a9c655f-8a04-4a23-a5b8-08d9e583da15 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:51.2745 (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: AM0PR03MB5700 Subject: [FFmpeg-devel] [PATCH v2 25/69] avcodec/speedhqenc: Add SpeedHQEncContext and move slice_start to it 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: v/GBoKh87AT2 Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo.h | 3 --- libavcodec/speedhqenc.c | 19 ++++++++++++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index c4ac7bc966..e31ad2ccff 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -419,9 +419,6 @@ typedef struct MpegEncContext { int inter_intra_pred; int mspel; - /* SpeedHQ specific */ - int slice_start; - /* decompression specific */ GetBitContext gb; diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c index 5b40011e40..2a8ddebb0a 100644 --- a/libavcodec/speedhqenc.c +++ b/libavcodec/speedhqenc.c @@ -54,6 +54,12 @@ static uint32_t speedhq_chr_dc_uni[512]; static uint8_t uni_speedhq_ac_vlc_len[64 * 64 * 2]; +typedef struct SpeedHQEncContext { + MpegEncContext m; + + int slice_start; +} SpeedHQEncContext; + static av_cold void speedhq_init_static_data(void) { ff_rl_init(&ff_rl_speedhq, speedhq_static_rl_table_store); @@ -121,24 +127,27 @@ av_cold int ff_speedhq_encode_init(MpegEncContext *s) void ff_speedhq_encode_picture_header(MpegEncContext *s) { + SpeedHQEncContext *ctx = (SpeedHQEncContext*)s; + put_bits_le(&s->pb, 8, 100 - s->qscale * 2); /* FIXME why doubled */ put_bits_le(&s->pb, 24, 4); /* no second field */ + ctx->slice_start = 4; /* length of first slice, will be filled out later */ - s->slice_start = 4; put_bits_le(&s->pb, 24, 0); } void ff_speedhq_end_slice(MpegEncContext *s) { + SpeedHQEncContext *ctx = (SpeedHQEncContext*)s; int slice_len; flush_put_bits_le(&s->pb); - slice_len = s->pb.buf_ptr - (s->pb.buf + s->slice_start); - AV_WL24(s->pb.buf + s->slice_start, slice_len); + slice_len = put_bytes_output(&s->pb) - ctx->slice_start; + AV_WL24(s->pb.buf + ctx->slice_start, slice_len); /* length of next slice, will be filled out later */ - s->slice_start = s->pb.buf_ptr - s->pb.buf; + ctx->slice_start = put_bytes_output(&s->pb); put_bits_le(&s->pb, 24, 0); } @@ -271,7 +280,7 @@ const AVCodec ff_speedhq_encoder = { .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_SPEEDHQ, .priv_class = &ff_mpv_enc_class, - .priv_data_size = sizeof(MpegEncContext), + .priv_data_size = sizeof(SpeedHQEncContext), .init = ff_mpv_encode_init, .encode2 = ff_mpv_encode_picture, .close = ff_mpv_encode_end, From patchwork Tue Feb 1 13:06:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34007 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp606893iov; Tue, 1 Feb 2022 05:15:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJzQ2/0Gdn/SKhG4XtYsXmmUCrCAtkDeVx6LFzmDpEjNZ2xcLzN48y8U0SqRKo4IcgKITkY2 X-Received: by 2002:a17:907:3d9f:: with SMTP id he31mr20552877ejc.605.1643721309858; Tue, 01 Feb 2022 05:15:09 -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 o13si9909279edi.520.2022.02.01.05.15.08; Tue, 01 Feb 2022 05:15:09 -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=K+i1lJwB; 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 69FD468B34D; Tue, 1 Feb 2022 15:08:12 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2038.outbound.protection.outlook.com [40.92.89.38]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C131768B382 for ; Tue, 1 Feb 2022 15:08:04 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HIoXy2yKuv/1+iE8EdDaQR6AcCat4oawUU2VA1Y05EkS44FK+61d+8PMbrn+IN3kK8adWA1j6gZjH+l1sLCIeSuUsTv1KhMhbE/IxYiwVtfbe/mU5rUAx3on+eGn7DUW7MPgJZlTaqndaBNvMt/Fm9IERyloGALGABOKoTLXNBRxeo+XsydT+28Nhzw5cWNUMI6/yw4dDF4Y/pSkiMWoOZpq7buYa4t3wns9yv7ubrF8t73V3iyXuxDRImkxZ8KTo+JFJGCSt2ZtazjRl9Epb4QKaA/UhzyTX8yrVaHLYw2EZfl22Omr2XOMH198imlmBYaT1WSOn8F2vm44Bz5sJA== 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=i0WwTuFfZ+alPAV6zglrCOvocGxOmnYeUy9L/tJnoJ4=; b=JYURZR5lkrxpgGmSbgoNh4PgfbGGceDJqq0SlVdo5KfDhJGlvsQD3ULsNsYfMxR+0oxgpKxa5/3zAtTXUaxVa/y4QzJjdTBSlRa5XVGwe0wRZnLtPawdgH0ZiNaXbOuqI6lrVWi+0adgYYBMcANKC6Ewi7B/fOohzFjd3TvvhpvGEY99CwmMJqHLUswvlxfHMIfvTIUKi9tsA11X6IDrmaHRQaoIL/7y1GuTT8xcEsZfXJyq08HDWXajyi/tKITyyk7tVlZ+zI2ZIov/5+pXmDvExz9n0neRnuNa6nePB2l9T4ajiF1q2L1WBfjky3hBa4H6lREIPrcSRKnUfrHU6A== 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=i0WwTuFfZ+alPAV6zglrCOvocGxOmnYeUy9L/tJnoJ4=; b=K+i1lJwBbDvcr6Bvb6TyT7N/fCNogSDogm2NK1S0ObqGZ1ZPkoPbtlRnyVl6xp86E+XZSlVgtr0ts+Hy9d+06T/KJ5xkBO2sOBBzahbPjli2B0FO+iPIkYvTZFaKe4/sNW8SAE+p06qjii4J00Hnf5cdcEZmQthe/z8mrA6HR8s5xMBpz8dcmaK341zqpkVvMcRejuEwU5uOqpuk+VDAoiPi5Q2d/dCioc/nq30grOCqhTLXATpmk06o7dKhS3nbWjsmCo3P+QaECBL6E9rce63S4RI4EQ/KVJ7RMLHhbLFkOKOG96ziwGSOWvkmysAm+PkOsymR3GUzaTFkpxGs9Q== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR03MB5700.eurprd03.prod.outlook.com (2603:10a6:208:16f::32) 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:53 +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:53 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:23 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [wxXCKedna9iQYWf/V/v0gkHVCgPUYb8h] 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-25-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d3812b87-0a41-463f-ed1c-08d9e583dad6 X-MS-TrafficTypeDiagnostic: AM0PR03MB5700:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IcRaKSCHtLJxDiBwRiGMd2LynI7ccUPdbCS2FmdfA0WLGvdz+mBKJA8plrFFrzQXAvPX32DTjQKOBPxaHWXrzF25rtQzfiNUzPmRenXYmqc5lGXvfkwY/VUGmLKn5u24AKvCvORzssTytIzlded5o4bE5B0e7Utxg9ZiqQT3oNlWNZT+GQnkNaLxdGSMQk/V3PxmQUwkKp7DHzc0zfYbxcPQ78yLWnQurajJLfKpKquBkHjiLwSfzhjRIeJghIRI1QUSunwLEvNECn6tMuSXJm28c34TN9DimydjeIGhtrcvzGx5/KBJ6iy+hf1zTWsVC3xDcRs/Tjs7lcJPig5IXLhR6QjCEOdRZQXguydnYxY+ClFPF03Xw/ItNXjgMj91bGfyWOuxZ4xSmKlnCaTPkERYZxdwCisQJ/K1lcUs0fwbVh7gIaulFTXdYeUaExXcxwR47iVxev4U+JbC2kYpkLIfsfyH4QmZNrpzjyakWmqZE033+HFfJEc8+KR0NppFgQVxEjmlAa8H2uBkOKGZdNCf5CiJeWRJM7KIz9tEaFK3e9Ewoz3JGgh3RqlvEsiE X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ljkWk3JkZ8AwaKJYiX3nctbOXIcrO/aNfz4iRB34bx+iU9Rm6dsFXOGKvSggTQtWUaeAiUKOA9SE59Ia1ewq3yo78embByxh9ZNiPjdRWmJ6KK2w5LcokCqSSALe2A9yvU/sGY0VEqEpflnxnKgfXywEbsm000+3LZfmogi9hSKw7LcaLXN1DXUTUq0/ekuu9ilA41MzbqeNXNFVx5RzUohcksgfPK55Pf0tcn5FRVyGyrv8xJfxYYBewL+7rZSlWhHHXlmrf3X8alm+C7Ayur+npQ73+MG6LJL0Lj/fZe2PelKcAiPQZBZxb04XBbfJv4l/LwIv/+akJ6STR7IiYui1mQUGZwdwD9iH6Uev5MfaYFqLaxpbODwCfusDw7CFWCFV0fehhOGfqhvikGUrDQRGB2smXjaUkOHGtP/KX29/tNH2ZkgbPHTI4brPCNgl2SM88czAgmIOmet7QsldzVL+FL8nrSgnxJ1ozuvg6fvxd7BcaOpbEIJ53jI9m6BrvbTEHzDRsmIfSpauZ54rPbCXtt5bHDHfbXlRPDQQwXbMzDCkZBbHXFR+kiD/yeJZOJk19lxwaYib4utjWRiMU07URZtvZG/L7d2toqDkaId1Vly0KKE54I+PBv/PYIqeyXFpNqxz6I3CwU0iWP2hGby58lWZz+A6YtVbMTgwF4cBJdJwZoCGkBQkuadb8zxAmm1reuGmlP4GFCqiztM/PmcVAiKMahe7kzlJH6GvRfqVehHQ6xs7JVt6T4CP+vs8UFIT09hKZ33vl8tkndgn3rtVvuK05aMMvuwALQ6WhPuqZ1vQyhp98tfLF2ACr/aU8mkpdF7A3gUF0HYgIckcOC6nvjn6qtD8vFl8TqhXzHKWEUp5tvvx8McP4zeJHpQx19XNatGCqpp+woYL13UR9YEYPK4xw6PtQvlpqBH5S/URfHwn/rod9V5TntmIGZ4WVUBwaHPYzPgOS+zoDSGjoQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d3812b87-0a41-463f-ed1c-08d9e583dad6 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:53.1035 (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: AM0PR03MB5700 Subject: [FFmpeg-devel] [PATCH v2 26/69] avcodec/mpegvideo: Use typedefs for MPV(Main)?(Dec|Enc)?Context 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: gAmgrR19bfHu This is in preparation for actually adding such contexts and e.g. moving fields only used by the main thread to the corresponding "Main" context. Signed-off-by: Andreas Rheinhardt --- libavcodec/alpha/mpegvideo_alpha.c | 6 +- libavcodec/arm/asm-offsets.h | 2 +- libavcodec/arm/me_cmp_init_arm.c | 12 +-- libavcodec/arm/mpegvideo_arm.c | 18 ++-- libavcodec/arm/mpegvideo_arm.h | 2 +- libavcodec/arm/mpegvideo_armv5te.c | 6 +- libavcodec/dnxhdenc.c | 4 +- libavcodec/dnxhdenc.h | 4 +- libavcodec/dxva2_mpeg2.c | 16 ++-- libavcodec/dxva2_vc1.c | 6 +- libavcodec/flvdec.c | 6 +- libavcodec/flvdec.h | 5 +- libavcodec/flvenc.c | 5 +- libavcodec/flvenc.h | 4 +- libavcodec/h261.c | 2 +- libavcodec/h261.h | 2 +- libavcodec/h261dec.c | 29 +++--- libavcodec/h261enc.c | 16 ++-- libavcodec/h261enc.h | 10 +-- libavcodec/h263.c | 8 +- libavcodec/h263.h | 6 +- libavcodec/h263dec.c | 16 ++-- libavcodec/h263dec.h | 17 ++-- libavcodec/h263enc.h | 18 ++-- libavcodec/intelh263dec.c | 6 +- libavcodec/ituh263dec.c | 35 ++++---- libavcodec/ituh263enc.c | 23 ++--- libavcodec/me_cmp.c | 58 ++++++------ libavcodec/me_cmp.h | 6 +- libavcodec/mips/h263dsp_mips.h | 6 +- libavcodec/mips/me_cmp_mips.h | 32 +++---- libavcodec/mips/me_cmp_msa.c | 28 +++--- libavcodec/mips/mpegvideo_init_mips.c | 2 +- libavcodec/mips/mpegvideo_mips.h | 12 +-- libavcodec/mips/mpegvideo_mmi.c | 12 +-- libavcodec/mips/mpegvideo_msa.c | 6 +- libavcodec/mjpegenc.c | 32 +++---- libavcodec/mjpegenc.h | 14 +-- libavcodec/motion_est.c | 54 +++++------ libavcodec/motion_est.h | 25 +++--- libavcodec/motion_est_template.c | 34 +++---- libavcodec/mpeg12.c | 4 +- libavcodec/mpeg12.h | 4 +- libavcodec/mpeg12dec.c | 113 +++++++++++------------ libavcodec/mpeg12enc.c | 32 +++---- libavcodec/mpeg12enc.h | 10 +-- libavcodec/mpeg4video.c | 10 +-- libavcodec/mpeg4video.h | 10 +-- libavcodec/mpeg4video_parser.c | 4 +- libavcodec/mpeg4videodec.c | 80 ++++++++--------- libavcodec/mpeg4videodec.h | 8 +- libavcodec/mpeg4videoenc.c | 40 ++++----- libavcodec/mpeg4videoenc.h | 16 ++-- libavcodec/mpeg_er.c | 8 +- libavcodec/mpeg_er.h | 6 +- libavcodec/mpegvideo.c | 79 ++++++++-------- libavcodec/mpegvideo.h | 112 ++++++++++++++--------- libavcodec/mpegvideo_dec.c | 24 ++--- libavcodec/mpegvideo_enc.c | 119 ++++++++++++++----------- libavcodec/mpegvideo_motion.c | 28 +++--- libavcodec/mpegvideo_xvmc.c | 16 ++-- libavcodec/mpegvideodec.h | 25 +++--- libavcodec/mpegvideoenc.h | 19 ++-- libavcodec/msmpeg4.c | 6 +- libavcodec/msmpeg4.h | 6 +- libavcodec/msmpeg4dec.c | 30 +++---- libavcodec/msmpeg4dec.h | 10 +-- libavcodec/msmpeg4enc.c | 25 +++--- libavcodec/msmpeg4enc.h | 18 ++-- libavcodec/mss2.c | 2 +- libavcodec/neon/mpegvideo.c | 6 +- libavcodec/nvdec_mpeg12.c | 4 +- libavcodec/nvdec_mpeg4.c | 2 +- libavcodec/nvdec_vc1.c | 2 +- libavcodec/ppc/me_cmp.c | 22 ++--- libavcodec/ppc/mpegvideo_altivec.c | 4 +- libavcodec/ratecontrol.c | 24 ++--- libavcodec/ratecontrol.h | 16 ++-- libavcodec/rv10.c | 16 ++-- libavcodec/rv10dec.h | 4 +- libavcodec/rv10enc.c | 5 +- libavcodec/rv10enc.h | 6 +- libavcodec/rv20enc.c | 6 +- libavcodec/rv30.c | 4 +- libavcodec/rv34.c | 39 ++++---- libavcodec/rv34.h | 4 +- libavcodec/rv40.c | 6 +- libavcodec/snow.h | 4 +- libavcodec/snow_dwt.c | 16 ++-- libavcodec/snow_dwt.h | 9 +- libavcodec/speedhqenc.c | 12 +-- libavcodec/speedhqenc.h | 15 ++-- libavcodec/svq1enc.c | 3 +- libavcodec/svq1enc.h | 6 +- libavcodec/vaapi_mpeg2.c | 10 +-- libavcodec/vaapi_mpeg4.c | 6 +- libavcodec/vaapi_vc1.c | 10 +-- libavcodec/vc1.h | 4 +- libavcodec/vc1_block.c | 44 ++++----- libavcodec/vc1_loopfilter.c | 30 +++---- libavcodec/vc1_mc.c | 16 ++-- libavcodec/vc1_pred.c | 10 +-- libavcodec/vc1dec.c | 13 ++- libavcodec/vdpau.c | 2 +- libavcodec/vdpau_mpeg12.c | 6 +- libavcodec/vdpau_mpeg4.c | 2 +- libavcodec/vdpau_vc1.c | 4 +- libavcodec/videotoolbox.c | 4 +- libavcodec/wmv2.c | 4 +- libavcodec/wmv2.h | 6 +- libavcodec/wmv2dec.c | 25 +++--- libavcodec/wmv2dec.h | 9 +- libavcodec/wmv2enc.c | 9 +- libavcodec/wmv2enc.h | 6 +- libavcodec/x86/me_cmp.asm | 16 ++-- libavcodec/x86/me_cmp_init.c | 72 +++++++-------- libavcodec/x86/mpegvideo.c | 14 +-- libavcodec/x86/mpegvideoenc.c | 8 +- libavcodec/x86/mpegvideoenc_template.c | 2 +- libavcodec/xvmc_internal.h | 8 +- 120 files changed, 1053 insertions(+), 991 deletions(-) diff --git a/libavcodec/alpha/mpegvideo_alpha.c b/libavcodec/alpha/mpegvideo_alpha.c index 126fe264a1..de93277533 100644 --- a/libavcodec/alpha/mpegvideo_alpha.c +++ b/libavcodec/alpha/mpegvideo_alpha.c @@ -69,7 +69,7 @@ static void dct_unquantize_h263_axp(int16_t *block, int n_coeffs, } } -static void dct_unquantize_h263_intra_axp(MpegEncContext *s, int16_t *block, +static void dct_unquantize_h263_intra_axp(MPVContext *s, int16_t *block, int n, int qscale) { int n_coeffs; @@ -96,14 +96,14 @@ static void dct_unquantize_h263_intra_axp(MpegEncContext *s, int16_t *block, block[0] = block0; } -static void dct_unquantize_h263_inter_axp(MpegEncContext *s, int16_t *block, +static void dct_unquantize_h263_inter_axp(MPVContext *s, int16_t *block, int n, int qscale) { int n_coeffs = s->inter_scantable.raster_end[s->block_last_index[n]]; dct_unquantize_h263_axp(block, n_coeffs, qscale, (qscale - 1) | 1); } -av_cold void ff_mpv_common_init_axp(MpegEncContext *s) +av_cold void ff_mpv_common_init_axp(MPVContext *s) { s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_axp; s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_axp; diff --git a/libavcodec/arm/asm-offsets.h b/libavcodec/arm/asm-offsets.h index a2174b0a08..65a3f819cc 100644 --- a/libavcodec/arm/asm-offsets.h +++ b/libavcodec/arm/asm-offsets.h @@ -21,7 +21,7 @@ #ifndef AVCODEC_ARM_ASM_OFFSETS_H #define AVCODEC_ARM_ASM_OFFSETS_H -/* MpegEncContext */ +/* MPVContext */ #define Y_DC_SCALE 0x04 #define C_DC_SCALE 0x08 #define AC_PRED 0x0c diff --git a/libavcodec/arm/me_cmp_init_arm.c b/libavcodec/arm/me_cmp_init_arm.c index 03870a2bfa..981c247c75 100644 --- a/libavcodec/arm/me_cmp_init_arm.c +++ b/libavcodec/arm/me_cmp_init_arm.c @@ -23,19 +23,19 @@ #include "libavutil/arm/cpu.h" #include "libavcodec/avcodec.h" #include "libavcodec/me_cmp.h" -#include "libavcodec/mpegvideo.h" +#include "libavcodec/mpegvideoenc.h" -int ff_pix_abs16_armv6(MpegEncContext *s, uint8_t *blk1, uint8_t *blk2, +int ff_pix_abs16_armv6(MPVEncContext *s, uint8_t *blk1, uint8_t *blk2, ptrdiff_t stride, int h); -int ff_pix_abs16_x2_armv6(MpegEncContext *s, uint8_t *blk1, uint8_t *blk2, +int ff_pix_abs16_x2_armv6(MPVEncContext *s, uint8_t *blk1, uint8_t *blk2, ptrdiff_t stride, int h); -int ff_pix_abs16_y2_armv6(MpegEncContext *s, uint8_t *blk1, uint8_t *blk2, +int ff_pix_abs16_y2_armv6(MPVEncContext *s, uint8_t *blk1, uint8_t *blk2, ptrdiff_t stride, int h); -int ff_pix_abs8_armv6(MpegEncContext *s, uint8_t *blk1, uint8_t *blk2, +int ff_pix_abs8_armv6(MPVEncContext *s, uint8_t *blk1, uint8_t *blk2, ptrdiff_t stride, int h); -int ff_sse16_armv6(MpegEncContext *s, uint8_t *blk1, uint8_t *blk2, +int ff_sse16_armv6(MPVEncContext *s, uint8_t *blk1, uint8_t *blk2, ptrdiff_t stride, int h); av_cold void ff_me_cmp_init_arm(MECmpContext *c, AVCodecContext *avctx) diff --git a/libavcodec/arm/mpegvideo_arm.c b/libavcodec/arm/mpegvideo_arm.c index 008ef18eea..dc653ce641 100644 --- a/libavcodec/arm/mpegvideo_arm.c +++ b/libavcodec/arm/mpegvideo_arm.c @@ -27,21 +27,21 @@ #include "asm-offsets.h" #if HAVE_NEON -AV_CHECK_OFFSET(MpegEncContext, y_dc_scale, Y_DC_SCALE); -AV_CHECK_OFFSET(MpegEncContext, c_dc_scale, C_DC_SCALE); -AV_CHECK_OFFSET(MpegEncContext, ac_pred, AC_PRED); -AV_CHECK_OFFSET(MpegEncContext, block_last_index, BLOCK_LAST_INDEX); -AV_CHECK_OFFSET(MpegEncContext, inter_scantable.raster_end, +AV_CHECK_OFFSET(MPVContext, y_dc_scale, Y_DC_SCALE); +AV_CHECK_OFFSET(MPVContext, c_dc_scale, C_DC_SCALE); +AV_CHECK_OFFSET(MPVContext, ac_pred, AC_PRED); +AV_CHECK_OFFSET(MPVContext, block_last_index, BLOCK_LAST_INDEX); +AV_CHECK_OFFSET(MPVContext, inter_scantable.raster_end, INTER_SCANTAB_RASTER_END); -AV_CHECK_OFFSET(MpegEncContext, h263_aic, H263_AIC); +AV_CHECK_OFFSET(MPVContext, h263_aic, H263_AIC); #endif -void ff_dct_unquantize_h263_inter_neon(MpegEncContext *s, int16_t *block, +void ff_dct_unquantize_h263_inter_neon(MPVContext *s, int16_t *block, int n, int qscale); -void ff_dct_unquantize_h263_intra_neon(MpegEncContext *s, int16_t *block, +void ff_dct_unquantize_h263_intra_neon(MPVContext *s, int16_t *block, int n, int qscale); -av_cold void ff_mpv_common_init_arm(MpegEncContext *s) +av_cold void ff_mpv_common_init_arm(MPVContext *s) { int cpu_flags = av_get_cpu_flags(); diff --git a/libavcodec/arm/mpegvideo_arm.h b/libavcodec/arm/mpegvideo_arm.h index 709ae6b247..d51f608a26 100644 --- a/libavcodec/arm/mpegvideo_arm.h +++ b/libavcodec/arm/mpegvideo_arm.h @@ -21,6 +21,6 @@ #include "libavcodec/mpegvideo.h" -void ff_mpv_common_init_armv5te(MpegEncContext *s); +void ff_mpv_common_init_armv5te(MPVContext *s); #endif /* AVCODEC_ARM_MPEGVIDEO_ARM_H */ diff --git a/libavcodec/arm/mpegvideo_armv5te.c b/libavcodec/arm/mpegvideo_armv5te.c index e20bb4c645..98942ee9bb 100644 --- a/libavcodec/arm/mpegvideo_armv5te.c +++ b/libavcodec/arm/mpegvideo_armv5te.c @@ -50,7 +50,7 @@ static inline void dct_unquantize_h263_helper_c(int16_t *block, int qmul, int qa } #endif -static void dct_unquantize_h263_intra_armv5te(MpegEncContext *s, +static void dct_unquantize_h263_intra_armv5te(MPVContext *s, int16_t *block, int n, int qscale) { int level, qmul, qadd; @@ -79,7 +79,7 @@ static void dct_unquantize_h263_intra_armv5te(MpegEncContext *s, block[0] = level; } -static void dct_unquantize_h263_inter_armv5te(MpegEncContext *s, +static void dct_unquantize_h263_inter_armv5te(MPVContext *s, int16_t *block, int n, int qscale) { int qmul, qadd; @@ -95,7 +95,7 @@ static void dct_unquantize_h263_inter_armv5te(MpegEncContext *s, ff_dct_unquantize_h263_armv5te(block, qmul, qadd, nCoeffs + 1); } -av_cold void ff_mpv_common_init_armv5te(MpegEncContext *s) +av_cold void ff_mpv_common_init_armv5te(MPVContext *s) { s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_armv5te; s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_armv5te; diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index ac92474e56..74989276b9 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -115,7 +115,7 @@ void dnxhd_10bit_get_pixels_8x4_sym(int16_t *av_restrict block, memcpy(block + 4 * 8, pixels + 3 * line_size, 8 * sizeof(*block)); } -static int dnxhd_10bit_dct_quantize_444(MpegEncContext *ctx, int16_t *block, +static int dnxhd_10bit_dct_quantize_444(MPVEncContext *ctx, int16_t *block, int n, int qscale, int *overflow) { int i, j, level, last_non_zero, start_i; @@ -174,7 +174,7 @@ static int dnxhd_10bit_dct_quantize_444(MpegEncContext *ctx, int16_t *block, return last_non_zero; } -static int dnxhd_10bit_dct_quantize(MpegEncContext *ctx, int16_t *block, +static int dnxhd_10bit_dct_quantize(MPVEncContext *ctx, int16_t *block, int n, int qscale, int *overflow) { const uint8_t *scantable= ctx->intra_scantable.scantable; diff --git a/libavcodec/dnxhdenc.h b/libavcodec/dnxhdenc.h index 9e4c869bc4..ef52735ad6 100644 --- a/libavcodec/dnxhdenc.h +++ b/libavcodec/dnxhdenc.h @@ -30,8 +30,8 @@ #include "libavutil/mem_internal.h" -#include "mpegvideo.h" #include "dnxhddata.h" +#include "mpegvideoenc.h" typedef struct RCCMPEntry { uint16_t mb; @@ -46,7 +46,7 @@ typedef struct RCEntry { typedef struct DNXHDEncContext { AVClass *class; BlockDSPContext bdsp; - MpegEncContext m; ///< Used for quantization dsp functions + MPVMainEncContext m; ///< Used for quantization dsp functions int cid; int profile; diff --git a/libavcodec/dxva2_mpeg2.c b/libavcodec/dxva2_mpeg2.c index 8cc21bf199..d6b42feb57 100644 --- a/libavcodec/dxva2_mpeg2.c +++ b/libavcodec/dxva2_mpeg2.c @@ -24,7 +24,7 @@ #include "dxva2_internal.h" #include "mpegutils.h" -#include "mpegvideo.h" +#include "mpegvideodec.h" #define MAX_SLICES 1024 struct dxva2_picture_context { @@ -39,7 +39,7 @@ struct dxva2_picture_context { static void fill_picture_parameters(AVCodecContext *avctx, AVDXVAContext *ctx, - const struct MpegEncContext *s, + const MPVDecContext *s, DXVA_PictureParameters *pp) { const Picture *current_picture = s->current_picture_ptr; @@ -105,7 +105,7 @@ static void fill_picture_parameters(AVCodecContext *avctx, static void fill_quantization_matrices(AVCodecContext *avctx, AVDXVAContext *ctx, - const struct MpegEncContext *s, + const MPVDecContext *s, DXVA_QmatrixData *qm) { int i; @@ -121,7 +121,7 @@ static void fill_quantization_matrices(AVCodecContext *avctx, } static void fill_slice(AVCodecContext *avctx, - const struct MpegEncContext *s, + const MPVDecContext *s, DXVA_SliceInfo *slice, unsigned position, const uint8_t *buffer, unsigned size) @@ -151,7 +151,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, DECODER_BUFFER_DESC *bs, DECODER_BUFFER_DESC *sc) { - const struct MpegEncContext *s = avctx->priv_data; + const MPVDecContext *const s = avctx->priv_data; AVDXVAContext *ctx = DXVA_CONTEXT(avctx); struct dxva2_picture_context *ctx_pic = s->current_picture_ptr->hwaccel_picture_private; @@ -254,7 +254,7 @@ static int dxva2_mpeg2_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) { - const struct MpegEncContext *s = avctx->priv_data; + const MPVDecContext *const s = avctx->priv_data; AVDXVAContext *ctx = DXVA_CONTEXT(avctx); struct dxva2_picture_context *ctx_pic = s->current_picture_ptr->hwaccel_picture_private; @@ -275,7 +275,7 @@ static int dxva2_mpeg2_start_frame(AVCodecContext *avctx, static int dxva2_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) { - const struct MpegEncContext *s = avctx->priv_data; + const MPVDecContext *const s = avctx->priv_data; struct dxva2_picture_context *ctx_pic = s->current_picture_ptr->hwaccel_picture_private; unsigned position; @@ -297,7 +297,7 @@ static int dxva2_mpeg2_decode_slice(AVCodecContext *avctx, static int dxva2_mpeg2_end_frame(AVCodecContext *avctx) { - struct MpegEncContext *s = avctx->priv_data; + MPVDecContext *const s = avctx->priv_data; struct dxva2_picture_context *ctx_pic = s->current_picture_ptr->hwaccel_picture_private; int ret; diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c index 5fd6957d0c..e86f3ed0f2 100644 --- a/libavcodec/dxva2_vc1.c +++ b/libavcodec/dxva2_vc1.c @@ -41,7 +41,7 @@ static void fill_picture_parameters(AVCodecContext *avctx, AVDXVAContext *ctx, const VC1Context *v, DXVA_PictureParameters *pp) { - const MpegEncContext *s = &v->s; + const MPVDecContext *const s = &v->s; const Picture *current_picture = s->current_picture_ptr; int intcomp = 0; @@ -164,7 +164,7 @@ static void fill_slice(AVCodecContext *avctx, DXVA_SliceInfo *slice, unsigned position, unsigned size) { const VC1Context *v = avctx->priv_data; - const MpegEncContext *s = &v->s; + const MPVDecContext *const s = &v->s; memset(slice, 0, sizeof(*slice)); slice->wHorizontalPosition = 0; @@ -186,7 +186,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, { const VC1Context *v = avctx->priv_data; AVDXVAContext *ctx = DXVA_CONTEXT(avctx); - const MpegEncContext *s = &v->s; + const MPVDecContext *const s = &v->s; struct dxva2_picture_context *ctx_pic = s->current_picture_ptr->hwaccel_picture_private; static const uint8_t start_code[] = { 0, 0, 1, 0x0d }; diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c index dacc64c81c..bf4df242cc 100644 --- a/libavcodec/flvdec.c +++ b/libavcodec/flvdec.c @@ -23,10 +23,10 @@ #include "flvdec.h" #include "h263dec.h" #include "internal.h" -#include "mpegvideo.h" #include "mpegvideodata.h" +#include "mpegvideodec.h" -int ff_flv_decode_picture_header(MpegEncContext *s) +int ff_flv_decode_picture_header(MPVMainDecContext *s) { int format, width, height; @@ -118,7 +118,7 @@ const AVCodec ff_flv_decoder = { .long_name = NULL_IF_CONFIG_SMALL("FLV / Sorenson Spark / Sorenson H.263 (Flash Video)"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_FLV1, - .priv_data_size = sizeof(MpegEncContext), + .priv_data_size = sizeof(MPVMainDecContext), .init = ff_h263_decode_init, .close = ff_h263_decode_end, .decode = ff_h263_decode_frame, diff --git a/libavcodec/flvdec.h b/libavcodec/flvdec.h index 3527d82beb..9cbd178192 100644 --- a/libavcodec/flvdec.h +++ b/libavcodec/flvdec.h @@ -21,9 +21,8 @@ #ifndef AVCODEC_FLVDEC_H #define AVCODEC_FLVDEC_H -#include "get_bits.h" -#include "mpegvideo.h" +#include "mpegvideodec.h" -int ff_flv_decode_picture_header(MpegEncContext *s); +int ff_flv_decode_picture_header(MPVMainDecContext *m); #endif /* AVCODEC_FLVDEC_H */ diff --git a/libavcodec/flvenc.c b/libavcodec/flvenc.c index 663a33c959..41e04e1abe 100644 --- a/libavcodec/flvenc.c +++ b/libavcodec/flvenc.c @@ -20,11 +20,10 @@ #include "flvenc.h" #include "h263data.h" -#include "mpegvideo.h" #include "mpegvideodata.h" #include "mpegvideoenc.h" -void ff_flv_encode_picture_header(MpegEncContext *s, int picture_number) +void ff_flv_encode_picture_header(MPVMainEncContext *s, int picture_number) { int format; @@ -97,7 +96,7 @@ const AVCodec ff_flv_encoder = { .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_FLV1, .priv_class = &ff_mpv_enc_class, - .priv_data_size = sizeof(MpegEncContext), + .priv_data_size = sizeof(MPVMainEncContext), .init = ff_mpv_encode_init, .encode2 = ff_mpv_encode_picture, .close = ff_mpv_encode_end, diff --git a/libavcodec/flvenc.h b/libavcodec/flvenc.h index aaa0fcffab..d1582224d5 100644 --- a/libavcodec/flvenc.h +++ b/libavcodec/flvenc.h @@ -21,10 +21,10 @@ #ifndef AVCODEC_FLVENC_H #define AVCODEC_FLVENC_H -#include "mpegvideo.h" +#include "mpegvideoenc.h" #include "put_bits.h" -void ff_flv_encode_picture_header(MpegEncContext *s, int picture_number); +void ff_flv_encode_picture_header(MPVMainEncContext *m, int picture_number); void ff_flv2_encode_ac_esc(PutBitContext *pb, int slevel, int level, int run, int last); diff --git a/libavcodec/h261.c b/libavcodec/h261.c index 7dfaee7dc4..a4ad742d76 100644 --- a/libavcodec/h261.c +++ b/libavcodec/h261.c @@ -58,7 +58,7 @@ static void h261_loop_filter(uint8_t *src, int stride) } } -void ff_h261_loop_filter(MpegEncContext *s) +void ff_h261_loop_filter(MPVContext *s) { H261Context *const h = s->private_ctx; const int linesize = s->linesize; diff --git a/libavcodec/h261.h b/libavcodec/h261.h index 67c362be93..18374a9e32 100644 --- a/libavcodec/h261.h +++ b/libavcodec/h261.h @@ -49,6 +49,6 @@ extern const uint8_t ff_h261_mv_tab[17][2]; extern const uint8_t ff_h261_cbp_tab[63][2]; extern RLTable ff_h261_rl_tcoeff; -void ff_h261_loop_filter(MpegEncContext *s); +void ff_h261_loop_filter(MPVContext *s); #endif /* AVCODEC_H261_H */ diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c index 5e732b05bf..ab534e9ff1 100644 --- a/libavcodec/h261dec.c +++ b/libavcodec/h261dec.c @@ -49,7 +49,7 @@ static VLC h261_mv_vlc; static VLC h261_cbp_vlc; typedef struct H261DecContext { - MpegEncContext s; + MPVMainDecContext s; H261Context common; @@ -82,7 +82,7 @@ static av_cold int h261_decode_init(AVCodecContext *avctx) { static AVOnce init_static_once = AV_ONCE_INIT; H261DecContext *const h = avctx->priv_data; - MpegEncContext *const s = &h->s; + MPVMainDecContext *const s = &h->s; s->private_ctx = &h->common; // set defaults @@ -106,8 +106,8 @@ static av_cold int h261_decode_init(AVCodecContext *avctx) */ static int h261_decode_gob_header(H261DecContext *h) { + MPVDecContext *const s = &h->s; unsigned int val; - MpegEncContext *const s = &h->s; if (!h->gob_start_code_skipped) { /* Check for GOB Start Code */ @@ -160,7 +160,7 @@ static int h261_decode_gob_header(H261DecContext *h) */ static int h261_resync(H261DecContext *h) { - MpegEncContext *const s = &h->s; + MPVDecContext *const s = &h->s; int left, ret; if (h->gob_start_code_skipped) { @@ -201,7 +201,7 @@ static int h261_resync(H261DecContext *h) */ static int h261_decode_mb_skipped(H261DecContext *h, int mba1, int mba2) { - MpegEncContext *const s = &h->s; + MPVDecContext *const s = &h->s; int i; s->mb_intra = 0; @@ -271,7 +271,7 @@ static int decode_mv_component(GetBitContext *gb, int v) */ static int h261_decode_block(H261DecContext *h, int16_t *block, int n, int coded) { - MpegEncContext *const s = &h->s; + MPVDecContext *const s = &h->s; int level, i, j, run; RLTable *rl = &ff_h261_rl_tcoeff; const uint8_t *scan_table; @@ -363,7 +363,7 @@ static int h261_decode_block(H261DecContext *h, int16_t *block, int n, int coded static int h261_decode_mb(H261DecContext *h) { - MpegEncContext *const s = &h->s; + MPVDecContext *const s = &h->s; H261Context *const com = &h->common; int i, cbp, xy; @@ -488,7 +488,7 @@ intra: */ static int h261_decode_picture_header(H261DecContext *h) { - MpegEncContext *const s = &h->s; + MPVDecContext *const s = &h->s; int format, i; uint32_t startcode = 0; @@ -552,7 +552,7 @@ static int h261_decode_picture_header(H261DecContext *h) static int h261_decode_gob(H261DecContext *h) { - MpegEncContext *const s = &h->s; + MPVDecContext *const s = &h->s; ff_set_qscale(s, s->qscale); @@ -582,7 +582,7 @@ static int h261_decode_gob(H261DecContext *h) /** * returns the number of bytes consumed for building the current frame */ -static int get_consumed_bytes(MpegEncContext *s, int buf_size) +static int get_consumed_bytes(MPVDecContext *s, int buf_size) { int pos = get_bits_count(&s->gb) >> 3; if (pos == 0) @@ -597,9 +597,10 @@ static int h261_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { H261DecContext *const h = avctx->priv_data; + MPVMainDecContext *const s2 = &h->s; + MPVDecContext *const s = s2; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; - MpegEncContext *s = &h->s; int ret; AVFrame *pict = data; @@ -620,11 +621,11 @@ retry: } if (s->width != avctx->coded_width || s->height != avctx->coded_height) { - ff_mpv_common_end(s); + ff_mpv_common_end(s2); } if (!s->context_initialized) { - if ((ret = ff_mpv_common_init(s)) < 0) + if ((ret = ff_mpv_common_init(s2)) < 0) return ret; ret = ff_set_dimensions(avctx, s->width, s->height); @@ -674,7 +675,7 @@ retry: static av_cold int h261_decode_end(AVCodecContext *avctx) { H261DecContext *const h = avctx->priv_data; - MpegEncContext *s = &h->s; + MPVMainContext *const s = &h->s; ff_mpv_common_end(s); return 0; diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c index 7d6a559f46..5c9664ea57 100644 --- a/libavcodec/h261enc.c +++ b/libavcodec/h261enc.c @@ -40,7 +40,7 @@ static uint8_t uni_h261_rl_len [64*64*2*2]; #define UNI_ENC_INDEX(last,run,level) ((last)*128*64 + (run)*128 + (level)) typedef struct H261EncContext { - MpegEncContext s; + MPVMainEncContext s; H261Context common; @@ -60,7 +60,7 @@ int ff_h261_get_picture_format(int width, int height) return AVERROR(EINVAL); } -void ff_h261_encode_picture_header(MpegEncContext *s, int picture_number) +void ff_h261_encode_picture_header(MPVMainEncContext *s, int picture_number) { H261EncContext *const h = (H261EncContext *)s; int format, temp_ref; @@ -98,7 +98,7 @@ void ff_h261_encode_picture_header(MpegEncContext *s, int picture_number) /** * Encode a group of blocks header. */ -static void h261_encode_gob_header(MpegEncContext *s, int mb_line) +static void h261_encode_gob_header(MPVEncContext *s, int mb_line) { H261EncContext *const h = (H261EncContext *)s; if (ff_h261_get_picture_format(s->width, s->height) == 0) { @@ -115,7 +115,7 @@ static void h261_encode_gob_header(MpegEncContext *s, int mb_line) s->last_mv[0][0][1] = 0; } -void ff_h261_reorder_mb_index(MpegEncContext *s) +void ff_h261_reorder_mb_index(MPVEncContext *s) { int index = s->mb_x + s->mb_y * s->mb_width; @@ -160,7 +160,7 @@ static void h261_encode_motion(PutBitContext *pb, int val) } } -static inline int get_cbp(MpegEncContext *s, int16_t block[6][64]) +static inline int get_cbp(MPVEncContext *s, int16_t block[6][64]) { int i, cbp; cbp = 0; @@ -177,7 +177,7 @@ static inline int get_cbp(MpegEncContext *s, int16_t block[6][64]) */ static void h261_encode_block(H261EncContext *h, int16_t *block, int n) { - MpegEncContext *const s = &h->s; + MPVEncContext *const s = &h->s; int level, run, i, j, last_index, last_non_zero, sign, slevel, code; RLTable *rl; @@ -243,7 +243,7 @@ static void h261_encode_block(H261EncContext *h, int16_t *block, int n) put_bits(&s->pb, rl->table_vlc[0][1], rl->table_vlc[0][0]); // EOB } -void ff_h261_encode_mb(MpegEncContext *s, int16_t block[6][64], +void ff_h261_encode_mb(MPVEncContext *s, int16_t block[6][64], int motion_x, int motion_y) { /* The following is only allowed because this encoder @@ -381,7 +381,7 @@ static av_cold void h261_encode_init_static(void) init_uni_h261_rl_tab(&ff_h261_rl_tcoeff, uni_h261_rl_len); } -av_cold void ff_h261_encode_init(MpegEncContext *s) +av_cold void ff_h261_encode_init(MPVMainEncContext *s) { H261EncContext *const h = (H261EncContext*)s; static AVOnce init_static_once = AV_ONCE_INIT; diff --git a/libavcodec/h261enc.h b/libavcodec/h261enc.h index 0a01858be5..e482be8a40 100644 --- a/libavcodec/h261enc.h +++ b/libavcodec/h261enc.h @@ -28,13 +28,13 @@ #ifndef AVCODEC_H261ENC_H #define AVCODEC_H261ENC_H -#include "mpegvideo.h" +#include "mpegvideoenc.h" int ff_h261_get_picture_format(int width, int height); -void ff_h261_reorder_mb_index(MpegEncContext *s); -void ff_h261_encode_mb(MpegEncContext *s, int16_t block[6][64], +void ff_h261_reorder_mb_index(MPVEncContext *s); +void ff_h261_encode_mb(MPVEncContext *s, int16_t block[6][64], int motion_x, int motion_y); -void ff_h261_encode_picture_header(MpegEncContext *s, int picture_number); -void ff_h261_encode_init(MpegEncContext *s); +void ff_h261_encode_picture_header(MPVMainEncContext *m, int picture_number); +void ff_h261_encode_init(MPVMainEncContext *m); #endif diff --git a/libavcodec/h263.c b/libavcodec/h263.c index b30ffaf878..6ad8b5b7ab 100644 --- a/libavcodec/h263.c +++ b/libavcodec/h263.c @@ -50,7 +50,8 @@ av_cold void ff_h263_init_rl_inter(void) ff_thread_once(&init_static_once, h263_init_rl_inter); } -void ff_h263_update_motion_val(MpegEncContext * s){ +void ff_h263_update_motion_val(MPVContext *s) +{ const int mb_xy = s->mb_y * s->mb_stride + s->mb_x; //FIXME a lot of that is only needed for !low_delay const int wrap = s->b8_stride; @@ -102,7 +103,8 @@ void ff_h263_update_motion_val(MpegEncContext * s){ } } -void ff_h263_loop_filter(MpegEncContext * s){ +void ff_h263_loop_filter(MPVContext *s) +{ int qp_c; const int linesize = s->linesize; const int uvlinesize= s->uvlinesize; @@ -187,7 +189,7 @@ void ff_h263_loop_filter(MpegEncContext * s){ } } -int16_t *ff_h263_pred_motion(MpegEncContext * s, int block, int dir, +int16_t *ff_h263_pred_motion(MPVContext *s, int block, int dir, int *px, int *py) { int wrap; diff --git a/libavcodec/h263.h b/libavcodec/h263.h index 27a5f31c59..57050a0de6 100644 --- a/libavcodec/h263.h +++ b/libavcodec/h263.h @@ -28,10 +28,10 @@ #define H263_GOB_HEIGHT(h) ((h) <= 400 ? 1 : (h) <= 800 ? 2 : 4) av_const int ff_h263_aspect_to_info(AVRational aspect); -int16_t *ff_h263_pred_motion(MpegEncContext * s, int block, int dir, +int16_t *ff_h263_pred_motion(MPVContext *s, int block, int dir, int *px, int *py); void ff_h263_init_rl_inter(void); -void ff_h263_update_motion_val(MpegEncContext * s); -void ff_h263_loop_filter(MpegEncContext * s); +void ff_h263_update_motion_val(MPVContext *s); +void ff_h263_loop_filter(MPVContext *s); #endif /* AVCODEC_H263_H */ diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index df9ac2f831..df78867735 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -57,7 +57,7 @@ static enum AVPixelFormat h263_get_format(AVCodecContext *avctx) { /* MPEG-4 Studio Profile only, not supported by hardware */ if (avctx->bits_per_raw_sample > 8) { - av_assert1(((MpegEncContext *)avctx->priv_data)->studio_profile); + av_assert1(((MPVDecContext *)avctx->priv_data)->studio_profile); return avctx->pix_fmt; } @@ -75,7 +75,7 @@ static enum AVPixelFormat h263_get_format(AVCodecContext *avctx) av_cold int ff_h263_decode_init(AVCodecContext *avctx) { - MpegEncContext *s = avctx->priv_data; + MPVMainDecContext *const s = avctx->priv_data; int ret; s->out_format = FMT_H263; @@ -158,7 +158,7 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx) av_cold int ff_h263_decode_end(AVCodecContext *avctx) { - MpegEncContext *s = avctx->priv_data; + MPVMainDecContext *const s = avctx->priv_data; ff_mpv_common_end(s); return 0; @@ -167,7 +167,7 @@ av_cold int ff_h263_decode_end(AVCodecContext *avctx) /** * Return the number of bytes consumed for building the current frame. */ -static int get_consumed_bytes(MpegEncContext *s, int buf_size) +static int get_consumed_bytes(MPVMainDecContext *s, int buf_size) { int pos = (get_bits_count(&s->gb) + 7) >> 3; @@ -195,7 +195,7 @@ static int get_consumed_bytes(MpegEncContext *s, int buf_size) } } -static int decode_slice(MpegEncContext *s) +static int decode_slice(MPVMainDecContext *s) { const int part_mask = s->partitioned_frame ? (ER_AC_END | ER_AC_ERROR) : 0x7F; @@ -427,9 +427,9 @@ static int decode_slice(MpegEncContext *s) int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { + MPVMainDecContext *const s = avctx->priv_data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; - MpegEncContext *s = avctx->priv_data; int ret; int slice_ret = 0; AVFrame *pict = data; @@ -765,7 +765,7 @@ const AVCodec ff_h263_decoder = { .long_name = NULL_IF_CONFIG_SMALL("H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_H263, - .priv_data_size = sizeof(MpegEncContext), + .priv_data_size = sizeof(MPVMainDecContext), .init = ff_h263_decode_init, .close = ff_h263_decode_end, .decode = ff_h263_decode_frame, @@ -786,7 +786,7 @@ const AVCodec ff_h263p_decoder = { .long_name = NULL_IF_CONFIG_SMALL("H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_H263P, - .priv_data_size = sizeof(MpegEncContext), + .priv_data_size = sizeof(MPVMainDecContext), .init = ff_h263_decode_init, .close = ff_h263_decode_end, .decode = ff_h263_decode_frame, diff --git a/libavcodec/h263dec.h b/libavcodec/h263dec.h index 8d5f9a7add..bab3e03fb3 100644 --- a/libavcodec/h263dec.h +++ b/libavcodec/h263dec.h @@ -20,7 +20,7 @@ #ifndef AVCODEC_H263DEC_H #define AVCODEC_H263DEC_H -#include "mpegvideo.h" +#include "mpegvideodec.h" #include "vlc.h" // The defines below define the number of bits that are read at once for @@ -40,26 +40,25 @@ extern VLC ff_h263_mv_vlc; extern const enum AVPixelFormat ff_h263_hwaccel_pixfmt_list_420[]; -int ff_h263_decode_motion(MpegEncContext * s, int pred, int f_code); +int ff_h263_decode_motion(MPVDecContext *s, int pred, int f_code); int ff_h263_decode_init(AVCodecContext *avctx); int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt); int ff_h263_decode_end(AVCodecContext *avctx); void ff_h263_decode_init_vlc(void); -int ff_h263_decode_picture_header(MpegEncContext *s); -int ff_h263_decode_gob_header(MpegEncContext *s); -int ff_h263_decode_mba(MpegEncContext *s); +int ff_h263_decode_picture_header(MPVMainDecContext *m); +int ff_h263_decode_mba(MPVDecContext *s); /** * Print picture info if FF_DEBUG_PICT_INFO is set. */ -void ff_h263_show_pict_info(MpegEncContext *s); +void ff_h263_show_pict_info(MPVMainDecContext *m); -int ff_intel_h263_decode_picture_header(MpegEncContext *s); -int ff_h263_decode_mb(MpegEncContext *s, +int ff_intel_h263_decode_picture_header(MPVMainDecContext *m); +int ff_h263_decode_mb(MPVDecContext *s, int16_t block[6][64]); -int ff_h263_resync(MpegEncContext *s); +int ff_h263_resync(MPVMainDecContext *m); #endif diff --git a/libavcodec/h263enc.h b/libavcodec/h263enc.h index fff85a18f2..1fe1726ebe 100644 --- a/libavcodec/h263enc.h +++ b/libavcodec/h263enc.h @@ -24,16 +24,16 @@ #include "h263data.h" #include "mpegvideoenc.h" -void ff_h263_encode_init(MpegEncContext *s); -void ff_h263_encode_picture_header(MpegEncContext *s, int picture_number); -void ff_h263_encode_gob_header(MpegEncContext * s, int mb_line); -void ff_h263_encode_mb(MpegEncContext *s, +void ff_h263_encode_init(MPVMainEncContext *m); +void ff_h263_encode_picture_header(MPVMainEncContext *m, int picture_number); +void ff_h263_encode_gob_header(MPVEncContext *s, int mb_line); +void ff_h263_encode_mb(MPVEncContext *s, int16_t block[6][64], int motion_x, int motion_y); -void ff_h263_encode_mba(MpegEncContext *s); +void ff_h263_encode_mba(MPVEncContext *s); -void ff_init_qscale_tab(MpegEncContext *s); -void ff_clean_h263_qscales(MpegEncContext *s); +void ff_init_qscale_tab(MPVMainEncContext *m); +void ff_clean_h263_qscales(MPVMainEncContext *m); void ff_h263_encode_motion(PutBitContext *pb, int val, int f_code); @@ -57,7 +57,7 @@ static inline int h263_get_motion_length(int val, int f_code) } } -static inline void ff_h263_encode_motion_vector(MpegEncContext * s, +static inline void ff_h263_encode_motion_vector(MPVEncContext *s, int x, int y, int f_code) { if (s->avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT) { @@ -70,7 +70,7 @@ static inline void ff_h263_encode_motion_vector(MpegEncContext * s, } } -static inline int get_p_cbp(MpegEncContext * s, +static inline int get_p_cbp(MPVEncContext *s, int16_t block[6][64], int motion_x, int motion_y){ int cbp; diff --git a/libavcodec/intelh263dec.c b/libavcodec/intelh263dec.c index b61effa4df..45b66033c9 100644 --- a/libavcodec/intelh263dec.c +++ b/libavcodec/intelh263dec.c @@ -20,13 +20,13 @@ #include "internal.h" #include "mpegutils.h" -#include "mpegvideo.h" +#include "mpegvideodec.h" #include "h263data.h" #include "h263dec.h" #include "mpegvideodata.h" /* don't understand why they choose a different header ! */ -int ff_intel_h263_decode_picture_header(MpegEncContext *s) +int ff_intel_h263_decode_picture_header(MPVMainDecContext *s) { int format; @@ -134,7 +134,7 @@ const AVCodec ff_h263i_decoder = { .long_name = NULL_IF_CONFIG_SMALL("Intel H.263"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_H263I, - .priv_data_size = sizeof(MpegEncContext), + .priv_data_size = sizeof(MPVMainDecContext), .init = ff_h263_decode_init, .close = ff_h263_decode_end, .decode = ff_h263_decode_frame, diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c index 77ca0d7e40..17d01c2d76 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -36,6 +36,7 @@ #include "libavutil/mem_internal.h" #include "avcodec.h" #include "mpegvideo.h" +#include "mpegvideodec.h" #include "h263.h" #include "h263data.h" #include "h263dec.h" @@ -72,7 +73,8 @@ static const int h263_mb_type_b_map[15]= { MB_TYPE_INTRA4x4 | MB_TYPE_CBP | MB_TYPE_QUANT, }; -void ff_h263_show_pict_info(MpegEncContext *s){ +void ff_h263_show_pict_info(MPVMainDecContext *s) +{ if(s->avctx->debug&FF_DEBUG_PICT_INFO){ av_log(s->avctx, AV_LOG_DEBUG, "qp:%d %c size:%d rnd:%d%s%s%s%s%s%s%s%s%s %d/%d\n", s->qscale, av_get_picture_type_char(s->pict_type), @@ -134,7 +136,7 @@ av_cold void ff_h263_decode_init_vlc(void) } } -int ff_h263_decode_mba(MpegEncContext *s) +int ff_h263_decode_mba(MPVDecContext *s) { int i, mb_pos; @@ -152,7 +154,7 @@ int ff_h263_decode_mba(MpegEncContext *s) * Decode the group of blocks header or slice header. * @return <0 if an error occurred */ -static int h263_decode_gob_header(MpegEncContext *s) +static int h263_decode_gob_header(MPVDecContext *s) { unsigned int val, gob_number; int left; @@ -208,7 +210,8 @@ static int h263_decode_gob_header(MpegEncContext *s) * Decode the group of blocks / video packet header / slice header (MPEG-4 Studio). * @return bit position of the resync_marker, or <0 if none was found */ -int ff_h263_resync(MpegEncContext *s){ +int ff_h263_resync(MPVMainDecContext *s) +{ int left, pos, ret; /* In MPEG-4 studio mode look for a new slice startcode @@ -265,7 +268,7 @@ int ff_h263_resync(MpegEncContext *s){ return -1; } -int ff_h263_decode_motion(MpegEncContext * s, int pred, int f_code) +int ff_h263_decode_motion(MPVDecContext *s, int pred, int f_code) { int code, val, sign, shift; code = get_vlc2(&s->gb, ff_h263_mv_vlc.table, H263_MV_VLC_BITS, 2); @@ -303,7 +306,7 @@ int ff_h263_decode_motion(MpegEncContext * s, int pred, int f_code) /* Decode RVLC of H.263+ UMV */ -static int h263p_decode_umotion(MpegEncContext * s, int pred) +static int h263p_decode_umotion(MPVDecContext *s, int pred) { int code = 0, sign; @@ -333,7 +336,8 @@ static int h263p_decode_umotion(MpegEncContext * s, int pred) /** * read the next MVs for OBMC. yes this is an ugly hack, feel free to send a patch :) */ -static void preview_obmc(MpegEncContext *s){ +static void preview_obmc(MPVDecContext *s) +{ GetBitContext gb= s->gb; int cbpc, i, pred_x, pred_y, mx, my; @@ -425,7 +429,8 @@ end: s->gb= gb; } -static void h263_decode_dquant(MpegEncContext *s){ +static void h263_decode_dquant(MPVDecContext *s) +{ static const int8_t quant_tab[4] = { -1, -2, 1, 2 }; if(s->modified_quant){ @@ -438,7 +443,7 @@ static void h263_decode_dquant(MpegEncContext *s){ ff_set_qscale(s, s->qscale); } -static void h263_pred_acdc(MpegEncContext * s, int16_t *block, int n) +static void h263_pred_acdc(MPVDecContext *s, int16_t *block, int n) { int x, y, wrap, a, c, pred_dc, scale; int16_t *dc_val, *ac_val, *ac_val1; @@ -525,7 +530,7 @@ static void h263_pred_acdc(MpegEncContext * s, int16_t *block, int n) ac_val1[8 + i] = block[s->idsp.idct_permutation[i]]; } -static int h263_decode_block(MpegEncContext * s, int16_t * block, +static int h263_decode_block(MPVDecContext *s, int16_t * block, int n, int coded) { int level, i, j, run; @@ -672,7 +677,7 @@ not_coded: return 0; } -static int h263_skip_b_part(MpegEncContext *s, int cbp) +static int h263_skip_b_part(MPVDecContext *s, int cbp) { LOCAL_ALIGNED_32(int16_t, dblock, [64]); int i, mbi; @@ -714,7 +719,7 @@ static int h263_get_modb(GetBitContext *gb, int pb_frame, int *cbpb) #define tab_size ((signed)FF_ARRAY_ELEMS(s->direct_scale_mv[0])) #define tab_bias (tab_size / 2) -static inline void set_one_direct_mv(MpegEncContext *s, Picture *p, int i) +static inline void set_one_direct_mv(MPVDecContext *s, Picture *p, int i) { int xy = s->block_index[i]; uint16_t time_pp = s->pp_time; @@ -742,7 +747,7 @@ static inline void set_one_direct_mv(MpegEncContext *s, Picture *p, int i) /** * @return the mb_type */ -static int set_direct_mv(MpegEncContext *s) +static int set_direct_mv(MPVDecContext *s) { const int mb_index = s->mb_x + s->mb_y * s->mb_stride; Picture *p = &s->next_picture; @@ -779,7 +784,7 @@ static int set_direct_mv(MpegEncContext *s) } } -int ff_h263_decode_mb(MpegEncContext *s, +int ff_h263_decode_mb(MPVDecContext *s, int16_t block[6][64]) { int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant; @@ -1081,7 +1086,7 @@ end: } /* Most is hardcoded; should extend to handle all H.263 streams. */ -int ff_h263_decode_picture_header(MpegEncContext *s) +int ff_h263_decode_picture_header(MPVMainDecContext *s) { int format, width, height, i, ret; uint32_t startcode; diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c index 11d8873253..e0b42dd442 100644 --- a/libavcodec/ituh263enc.c +++ b/libavcodec/ituh263enc.c @@ -102,7 +102,7 @@ av_const int ff_h263_aspect_to_info(AVRational aspect){ return FF_ASPECT_EXTENDED; } -void ff_h263_encode_picture_header(MpegEncContext * s, int picture_number) +void ff_h263_encode_picture_header(MPVMainEncContext *s, int picture_number) { int format, coded_frame_rate, coded_frame_rate_base, i, temp_ref; int best_clock_code=1; @@ -240,7 +240,7 @@ void ff_h263_encode_picture_header(MpegEncContext * s, int picture_number) /** * Encode a group of blocks header. */ -void ff_h263_encode_gob_header(MpegEncContext * s, int mb_line) +void ff_h263_encode_gob_header(MPVEncContext *s, int mb_line) { put_bits(&s->pb, 17, 1); /* GBSC */ @@ -266,7 +266,8 @@ void ff_h263_encode_gob_header(MpegEncContext * s, int mb_line) /** * modify qscale so that encoding is actually possible in H.263 (limit difference to -2..2) */ -void ff_clean_h263_qscales(MpegEncContext *s){ +void ff_clean_h263_qscales(MPVMainEncContext *s) +{ int i; int8_t * const qscale_table = s->current_picture.qscale_table; @@ -299,7 +300,7 @@ static const int dquant_code[5]= {1,0,9,2,3}; * @param block the 8x8 block * @param n block index (0-3 are luma, 4-5 are chroma) */ -static void h263_encode_block(MpegEncContext * s, int16_t * block, int n) +static void h263_encode_block(MPVEncContext *s, int16_t *block, int n) { int level, run, last, i, j, last_index, last_non_zero, sign, slevel, code; RLTable *rl; @@ -447,7 +448,7 @@ static void h263p_encode_umotion(PutBitContext *pb, int val) } } -static int h263_pred_dc(MpegEncContext * s, int n, int16_t **dc_val_ptr) +static int h263_pred_dc(MPVEncContext *s, int n, int16_t **dc_val_ptr) { int x, y, wrap, a, c, pred_dc; int16_t *dc_val; @@ -488,7 +489,7 @@ static int h263_pred_dc(MpegEncContext * s, int n, int16_t **dc_val_ptr) return pred_dc; } -void ff_h263_encode_mb(MpegEncContext * s, +void ff_h263_encode_mb(MPVEncContext *s, int16_t block[6][64], int motion_x, int motion_y) { @@ -811,7 +812,7 @@ static av_cold void h263_encode_init_static(void) init_mv_penalty_and_fcode(); } -av_cold void ff_h263_encode_init(MpegEncContext *s) +av_cold void ff_h263_encode_init(MPVMainEncContext *s) { static AVOnce init_static_once = AV_ONCE_INIT; @@ -866,7 +867,7 @@ av_cold void ff_h263_encode_init(MpegEncContext *s) ff_thread_once(&init_static_once, h263_encode_init_static); } -void ff_h263_encode_mba(MpegEncContext *s) +void ff_h263_encode_mba(MPVEncContext *s) { int i, mb_pos; @@ -877,7 +878,7 @@ void ff_h263_encode_mba(MpegEncContext *s) put_bits(&s->pb, ff_mba_length[i], mb_pos); } -#define OFFSET(x) offsetof(MpegEncContext, x) +#define OFFSET(x) offsetof(MPVMainEncContext, x) #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption h263_options[] = { { "obmc", "use overlapped block motion compensation.", OFFSET(obmc), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, @@ -907,7 +908,7 @@ const AVCodec ff_h263_encoder = { .pix_fmts= (const enum AVPixelFormat[]){AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE}, .priv_class = &h263_class, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, - .priv_data_size = sizeof(MpegEncContext), + .priv_data_size = sizeof(MPVMainEncContext), .init = ff_mpv_encode_init, .encode2 = ff_mpv_encode_picture, .close = ff_mpv_encode_end, @@ -943,7 +944,7 @@ const AVCodec ff_h263p_encoder = { .priv_class = &h263p_class, .capabilities = AV_CODEC_CAP_SLICE_THREADS, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, - .priv_data_size = sizeof(MpegEncContext), + .priv_data_size = sizeof(MPVMainEncContext), .init = ff_mpv_encode_init, .encode2 = ff_mpv_encode_picture, .close = ff_mpv_encode_end, diff --git a/libavcodec/me_cmp.c b/libavcodec/me_cmp.c index b2f87d2e1b..8fa8c258ee 100644 --- a/libavcodec/me_cmp.c +++ b/libavcodec/me_cmp.c @@ -66,7 +66,7 @@ const uint32_t ff_square_tab[512] = { 57600, 58081, 58564, 59049, 59536, 60025, 60516, 61009, 61504, 62001, 62500, 63001, 63504, 64009, 64516, 65025, }; -static int sse4_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +static int sse4_c(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { int s = 0, i; @@ -83,7 +83,7 @@ static int sse4_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, return s; } -static int sse8_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +static int sse8_c(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { int s = 0, i; @@ -104,7 +104,7 @@ static int sse8_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, return s; } -static int sse16_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +static int sse16_c(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { int s = 0, i; @@ -146,7 +146,7 @@ static int sum_abs_dctelem_c(int16_t *block) #define avg2(a, b) (((a) + (b) + 1) >> 1) #define avg4(a, b, c, d) (((a) + (b) + (c) + (d) + 2) >> 2) -static inline int pix_abs16_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +static inline int pix_abs16_c(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { int s = 0, i; @@ -174,7 +174,7 @@ static inline int pix_abs16_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, return s; } -static inline int pix_median_abs16_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +static inline int pix_median_abs16_c(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { int s = 0, i, j; @@ -213,7 +213,7 @@ static inline int pix_median_abs16_c(MpegEncContext *v, uint8_t *pix1, uint8_t * return s; } -static int pix_abs16_x2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +static int pix_abs16_x2_c(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { int s = 0, i; @@ -241,7 +241,7 @@ static int pix_abs16_x2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, return s; } -static int pix_abs16_y2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +static int pix_abs16_y2_c(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { int s = 0, i; @@ -271,7 +271,7 @@ static int pix_abs16_y2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, return s; } -static int pix_abs16_xy2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +static int pix_abs16_xy2_c(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { int s = 0, i; @@ -301,7 +301,7 @@ static int pix_abs16_xy2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, return s; } -static inline int pix_abs8_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +static inline int pix_abs8_c(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { int s = 0, i; @@ -321,7 +321,7 @@ static inline int pix_abs8_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, return s; } -static inline int pix_median_abs8_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +static inline int pix_median_abs8_c(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { int s = 0, i, j; @@ -352,7 +352,7 @@ static inline int pix_median_abs8_c(MpegEncContext *v, uint8_t *pix1, uint8_t *p return s; } -static int pix_abs8_x2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +static int pix_abs8_x2_c(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { int s = 0, i; @@ -372,7 +372,7 @@ static int pix_abs8_x2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, return s; } -static int pix_abs8_y2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +static int pix_abs8_y2_c(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { int s = 0, i; @@ -394,7 +394,7 @@ static int pix_abs8_y2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, return s; } -static int pix_abs8_xy2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +static int pix_abs8_xy2_c(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { int s = 0, i; @@ -416,7 +416,7 @@ static int pix_abs8_xy2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, return s; } -static int nsse16_c(MpegEncContext *c, uint8_t *s1, uint8_t *s2, +static int nsse16_c(MPVEncContext *c, uint8_t *s1, uint8_t *s2, ptrdiff_t stride, int h) { int score1 = 0, score2 = 0, x, y; @@ -441,7 +441,7 @@ static int nsse16_c(MpegEncContext *c, uint8_t *s1, uint8_t *s2, return score1 + FFABS(score2) * 8; } -static int nsse8_c(MpegEncContext *c, uint8_t *s1, uint8_t *s2, +static int nsse8_c(MPVEncContext *c, uint8_t *s1, uint8_t *s2, ptrdiff_t stride, int h) { int score1 = 0, score2 = 0, x, y; @@ -466,7 +466,7 @@ static int nsse8_c(MpegEncContext *c, uint8_t *s1, uint8_t *s2, return score1 + FFABS(score2) * 8; } -static int zero_cmp(MpegEncContext *s, uint8_t *a, uint8_t *b, +static int zero_cmp(MPVEncContext *s, uint8_t *a, uint8_t *b, ptrdiff_t stride, int h) { return 0; @@ -552,7 +552,7 @@ void ff_set_cmp(MECmpContext *c, me_cmp_func *cmp, int type) #define BUTTERFLYA(x, y) (FFABS((x) + (y)) + FFABS((x) - (y))) -static int hadamard8_diff8x8_c(MpegEncContext *s, uint8_t *dst, +static int hadamard8_diff8x8_c(MPVEncContext *s, uint8_t *dst, uint8_t *src, ptrdiff_t stride, int h) { int i, temp[64], sum = 0; @@ -604,7 +604,7 @@ static int hadamard8_diff8x8_c(MpegEncContext *s, uint8_t *dst, return sum; } -static int hadamard8_intra8x8_c(MpegEncContext *s, uint8_t *src, +static int hadamard8_intra8x8_c(MPVEncContext *s, uint8_t *src, uint8_t *dummy, ptrdiff_t stride, int h) { int i, temp[64], sum = 0; @@ -656,7 +656,7 @@ static int hadamard8_intra8x8_c(MpegEncContext *s, uint8_t *src, return sum; } -static int dct_sad8x8_c(MpegEncContext *s, uint8_t *src1, +static int dct_sad8x8_c(MPVEncContext *s, uint8_t *src1, uint8_t *src2, ptrdiff_t stride, int h) { LOCAL_ALIGNED_16(int16_t, temp, [64]); @@ -697,7 +697,7 @@ static int dct_sad8x8_c(MpegEncContext *s, uint8_t *src1, DST(7, (a4 >> 2) - a7); \ } -static int dct264_sad8x8_c(MpegEncContext *s, uint8_t *src1, +static int dct264_sad8x8_c(MPVEncContext *s, uint8_t *src1, uint8_t *src2, ptrdiff_t stride, int h) { int16_t dct[8][8]; @@ -722,7 +722,7 @@ static int dct264_sad8x8_c(MpegEncContext *s, uint8_t *src1, } #endif -static int dct_max8x8_c(MpegEncContext *s, uint8_t *src1, +static int dct_max8x8_c(MPVEncContext *s, uint8_t *src1, uint8_t *src2, ptrdiff_t stride, int h) { LOCAL_ALIGNED_16(int16_t, temp, [64]); @@ -739,7 +739,7 @@ static int dct_max8x8_c(MpegEncContext *s, uint8_t *src1, return sum; } -static int quant_psnr8x8_c(MpegEncContext *s, uint8_t *src1, +static int quant_psnr8x8_c(MPVEncContext *s, uint8_t *src1, uint8_t *src2, ptrdiff_t stride, int h) { LOCAL_ALIGNED_16(int16_t, temp, [64 * 2]); @@ -764,7 +764,7 @@ static int quant_psnr8x8_c(MpegEncContext *s, uint8_t *src1, return sum; } -static int rd8x8_c(MpegEncContext *s, uint8_t *src1, uint8_t *src2, +static int rd8x8_c(MPVEncContext *s, uint8_t *src1, uint8_t *src2, ptrdiff_t stride, int h) { const uint8_t *scantable = s->intra_scantable.permutated; @@ -841,7 +841,7 @@ static int rd8x8_c(MpegEncContext *s, uint8_t *src1, uint8_t *src2, return distortion + ((bits * s->qscale * s->qscale * 109 + 64) >> 7); } -static int bit8x8_c(MpegEncContext *s, uint8_t *src1, uint8_t *src2, +static int bit8x8_c(MPVEncContext *s, uint8_t *src1, uint8_t *src2, ptrdiff_t stride, int h) { const uint8_t *scantable = s->intra_scantable.permutated; @@ -903,7 +903,7 @@ static int bit8x8_c(MpegEncContext *s, uint8_t *src1, uint8_t *src2, } #define VSAD_INTRA(size) \ -static int vsad_intra ## size ## _c(MpegEncContext *c, \ +static int vsad_intra ## size ## _c(MPVEncContext *c, \ uint8_t *s, uint8_t *dummy, \ ptrdiff_t stride, int h) \ { \ @@ -925,7 +925,7 @@ VSAD_INTRA(8) VSAD_INTRA(16) #define VSAD(size) \ -static int vsad ## size ## _c(MpegEncContext *c, \ +static int vsad ## size ## _c(MPVEncContext *c, \ uint8_t *s1, uint8_t *s2, \ ptrdiff_t stride, int h) \ { \ @@ -945,7 +945,7 @@ VSAD(16) #define SQ(a) ((a) * (a)) #define VSSE_INTRA(size) \ -static int vsse_intra ## size ## _c(MpegEncContext *c, \ +static int vsse_intra ## size ## _c(MPVEncContext *c, \ uint8_t *s, uint8_t *dummy, \ ptrdiff_t stride, int h) \ { \ @@ -967,7 +967,7 @@ VSSE_INTRA(8) VSSE_INTRA(16) #define VSSE(size) \ -static int vsse ## size ## _c(MpegEncContext *c, uint8_t *s1, uint8_t *s2, \ +static int vsse ## size ## _c(MPVEncContext *c, uint8_t *s1, uint8_t *s2, \ ptrdiff_t stride, int h) \ { \ int score = 0, x, y; \ @@ -985,7 +985,7 @@ VSSE(8) VSSE(16) #define WRAPPER8_16_SQ(name8, name16) \ -static int name16(MpegEncContext *s, uint8_t *dst, uint8_t *src, \ +static int name16(MPVEncContext *s, uint8_t *dst, uint8_t *src, \ ptrdiff_t stride, int h) \ { \ int score = 0; \ diff --git a/libavcodec/me_cmp.h b/libavcodec/me_cmp.h index e9b5161c9a..ca9a617a6a 100644 --- a/libavcodec/me_cmp.h +++ b/libavcodec/me_cmp.h @@ -39,13 +39,14 @@ extern const uint32_t ff_square_tab[512]; * !future video codecs might need functions with less strict alignment */ -struct MpegEncContext; +#define MPVEncContext MPVContext +struct MPVEncContext; /* Motion estimation: * h is limited to { width / 2, width, 2 * width }, * but never larger than 16 and never smaller than 2. * Although currently h < 4 is not used as functions with * width < 8 are neither used nor implemented. */ -typedef int (*me_cmp_func)(struct MpegEncContext *c, +typedef int (*me_cmp_func)(struct MPVEncContext *c, uint8_t *blk1 /* align width (8 or 16) */, uint8_t *blk2 /* align 1 */, ptrdiff_t stride, int h); @@ -89,5 +90,6 @@ void ff_me_cmp_init_mips(MECmpContext *c, AVCodecContext *avctx); void ff_set_cmp(MECmpContext *c, me_cmp_func *cmp, int type); void ff_dsputil_init_dwt(MECmpContext *c); +#undef MPVEncContext #endif /* AVCODEC_ME_CMP_H */ diff --git a/libavcodec/mips/h263dsp_mips.h b/libavcodec/mips/h263dsp_mips.h index 99a43cd44a..852856db55 100644 --- a/libavcodec/mips/h263dsp_mips.h +++ b/libavcodec/mips/h263dsp_mips.h @@ -25,11 +25,11 @@ void ff_h263_h_loop_filter_msa(uint8_t *src, int stride, int q_scale); void ff_h263_v_loop_filter_msa(uint8_t *src, int stride, int q_scale); -void ff_dct_unquantize_mpeg2_inter_msa(MpegEncContext *s, int16_t *block, +void ff_dct_unquantize_mpeg2_inter_msa(MPVContext *s, int16_t *block, int32_t index, int32_t q_scale); -void ff_dct_unquantize_h263_inter_msa(MpegEncContext *s, int16_t *block, +void ff_dct_unquantize_h263_inter_msa(MPVContext *s, int16_t *block, int32_t index, int32_t q_scale); -void ff_dct_unquantize_h263_intra_msa(MpegEncContext *s, int16_t *block, +void ff_dct_unquantize_h263_intra_msa(MPVContext *s, int16_t *block, int32_t index, int32_t q_scale); int ff_pix_sum_msa(uint8_t *pix, int line_size); diff --git a/libavcodec/mips/me_cmp_mips.h b/libavcodec/mips/me_cmp_mips.h index e0d0f51af8..71187f7a5c 100644 --- a/libavcodec/mips/me_cmp_mips.h +++ b/libavcodec/mips/me_cmp_mips.h @@ -21,38 +21,38 @@ #ifndef AVCODEC_MIPS_ME_CMP_MIPS_H #define AVCODEC_MIPS_ME_CMP_MIPS_H -#include "../mpegvideo.h" +#include "libavcodec/mpegvideoenc.h" #include "libavcodec/bit_depth_template.c" -int ff_hadamard8_diff8x8_msa(MpegEncContext *s, uint8_t *dst, uint8_t *src, +int ff_hadamard8_diff8x8_msa(MPVEncContext *s, uint8_t *dst, uint8_t *src, ptrdiff_t stride, int h); -int ff_hadamard8_intra8x8_msa(MpegEncContext *s, uint8_t *dst, uint8_t *src, +int ff_hadamard8_intra8x8_msa(MPVEncContext *s, uint8_t *dst, uint8_t *src, ptrdiff_t stride, int h); -int ff_hadamard8_diff16_msa(MpegEncContext *s, uint8_t *dst, uint8_t *src, +int ff_hadamard8_diff16_msa(MPVEncContext *s, uint8_t *dst, uint8_t *src, ptrdiff_t stride, int h); -int ff_hadamard8_intra16_msa(MpegEncContext *s, uint8_t *dst, uint8_t *src, +int ff_hadamard8_intra16_msa(MPVEncContext *s, uint8_t *dst, uint8_t *src, ptrdiff_t stride, int h); -int ff_pix_abs16_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_pix_abs16_msa(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); -int ff_pix_abs16_x2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_pix_abs16_x2_msa(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); -int ff_pix_abs16_y2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_pix_abs16_y2_msa(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); -int ff_pix_abs16_xy2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_pix_abs16_xy2_msa(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); -int ff_pix_abs8_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_pix_abs8_msa(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); -int ff_pix_abs8_x2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_pix_abs8_x2_msa(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); -int ff_pix_abs8_y2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_pix_abs8_y2_msa(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); -int ff_pix_abs8_xy2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_pix_abs8_xy2_msa(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); -int ff_sse16_msa(MpegEncContext *v, uint8_t *pu8Src, uint8_t *pu8Ref, +int ff_sse16_msa(MPVEncContext *v, uint8_t *pu8Src, uint8_t *pu8Ref, ptrdiff_t stride, int i32Height); -int ff_sse8_msa(MpegEncContext *v, uint8_t *pu8Src, uint8_t *pu8Ref, +int ff_sse8_msa(MPVEncContext *v, uint8_t *pu8Src, uint8_t *pu8Ref, ptrdiff_t stride, int i32Height); -int ff_sse4_msa(MpegEncContext *v, uint8_t *pu8Src, uint8_t *pu8Ref, +int ff_sse4_msa(MPVEncContext *v, uint8_t *pu8Src, uint8_t *pu8Ref, ptrdiff_t stride, int i32Height); void ff_add_pixels8_msa(uint8_t *av_restrict pixels, int16_t *block, ptrdiff_t stride); diff --git a/libavcodec/mips/me_cmp_msa.c b/libavcodec/mips/me_cmp_msa.c index 7cb7af0047..f71bb7e4aa 100644 --- a/libavcodec/mips/me_cmp_msa.c +++ b/libavcodec/mips/me_cmp_msa.c @@ -587,79 +587,79 @@ static int32_t hadamard_intra_8x8_msa(uint8_t *src, int32_t src_stride, return sum_res; } -int ff_pix_abs16_msa(MpegEncContext *v, uint8_t *src, uint8_t *ref, +int ff_pix_abs16_msa(MPVEncContext *v, uint8_t *src, uint8_t *ref, ptrdiff_t stride, int height) { return sad_16width_msa(src, stride, ref, stride, height); } -int ff_pix_abs8_msa(MpegEncContext *v, uint8_t *src, uint8_t *ref, +int ff_pix_abs8_msa(MPVEncContext *v, uint8_t *src, uint8_t *ref, ptrdiff_t stride, int height) { return sad_8width_msa(src, stride, ref, stride, height); } -int ff_pix_abs16_x2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_pix_abs16_x2_msa(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { return sad_horiz_bilinear_filter_16width_msa(pix1, stride, pix2, stride, h); } -int ff_pix_abs16_y2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_pix_abs16_y2_msa(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { return sad_vert_bilinear_filter_16width_msa(pix1, stride, pix2, stride, h); } -int ff_pix_abs16_xy2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_pix_abs16_xy2_msa(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { return sad_hv_bilinear_filter_16width_msa(pix1, stride, pix2, stride, h); } -int ff_pix_abs8_x2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_pix_abs8_x2_msa(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { return sad_horiz_bilinear_filter_8width_msa(pix1, stride, pix2, stride, h); } -int ff_pix_abs8_y2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_pix_abs8_y2_msa(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { return sad_vert_bilinear_filter_8width_msa(pix1, stride, pix2, stride, h); } -int ff_pix_abs8_xy2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_pix_abs8_xy2_msa(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { return sad_hv_bilinear_filter_8width_msa(pix1, stride, pix2, stride, h); } -int ff_sse16_msa(MpegEncContext *v, uint8_t *src, uint8_t *ref, +int ff_sse16_msa(MPVEncContext *v, uint8_t *src, uint8_t *ref, ptrdiff_t stride, int height) { return sse_16width_msa(src, stride, ref, stride, height); } -int ff_sse8_msa(MpegEncContext *v, uint8_t *src, uint8_t *ref, +int ff_sse8_msa(MPVEncContext *v, uint8_t *src, uint8_t *ref, ptrdiff_t stride, int height) { return sse_8width_msa(src, stride, ref, stride, height); } -int ff_sse4_msa(MpegEncContext *v, uint8_t *src, uint8_t *ref, +int ff_sse4_msa(MPVEncContext *v, uint8_t *src, uint8_t *ref, ptrdiff_t stride, int height) { return sse_4width_msa(src, stride, ref, stride, height); } -int ff_hadamard8_diff8x8_msa(MpegEncContext *s, uint8_t *dst, uint8_t *src, +int ff_hadamard8_diff8x8_msa(MPVEncContext *s, uint8_t *dst, uint8_t *src, ptrdiff_t stride, int h) { return hadamard_diff_8x8_msa(src, stride, dst, stride); } -int ff_hadamard8_intra8x8_msa(MpegEncContext *s, uint8_t *dst, uint8_t *src, +int ff_hadamard8_intra8x8_msa(MPVEncContext *s, uint8_t *dst, uint8_t *src, ptrdiff_t stride, int h) { return hadamard_intra_8x8_msa(src, stride, dst, stride); @@ -667,7 +667,7 @@ int ff_hadamard8_intra8x8_msa(MpegEncContext *s, uint8_t *dst, uint8_t *src, /* Hadamard Transform functions */ #define WRAPPER8_16_SQ(name8, name16) \ -int name16(MpegEncContext *s, uint8_t *dst, uint8_t *src, \ +int name16(MPVEncContext *s, uint8_t *dst, uint8_t *src, \ ptrdiff_t stride, int h) \ { \ int score = 0; \ diff --git a/libavcodec/mips/mpegvideo_init_mips.c b/libavcodec/mips/mpegvideo_init_mips.c index f687ad18f1..dd96592e9b 100644 --- a/libavcodec/mips/mpegvideo_init_mips.c +++ b/libavcodec/mips/mpegvideo_init_mips.c @@ -23,7 +23,7 @@ #include "h263dsp_mips.h" #include "mpegvideo_mips.h" -av_cold void ff_mpv_common_init_mips(MpegEncContext *s) +av_cold void ff_mpv_common_init_mips(MPVContext *s) { int cpu_flags = av_get_cpu_flags(); diff --git a/libavcodec/mips/mpegvideo_mips.h b/libavcodec/mips/mpegvideo_mips.h index 760d7b3295..88d675eee6 100644 --- a/libavcodec/mips/mpegvideo_mips.h +++ b/libavcodec/mips/mpegvideo_mips.h @@ -23,16 +23,16 @@ #include "libavcodec/mpegvideo.h" -void ff_dct_unquantize_h263_intra_mmi(MpegEncContext *s, int16_t *block, +void ff_dct_unquantize_h263_intra_mmi(MPVContext *s, int16_t *block, int n, int qscale); -void ff_dct_unquantize_h263_inter_mmi(MpegEncContext *s, int16_t *block, +void ff_dct_unquantize_h263_inter_mmi(MPVContext *s, int16_t *block, int n, int qscale); -void ff_dct_unquantize_mpeg1_intra_mmi(MpegEncContext *s, int16_t *block, +void ff_dct_unquantize_mpeg1_intra_mmi(MPVContext *s, int16_t *block, int n, int qscale); -void ff_dct_unquantize_mpeg1_inter_mmi(MpegEncContext *s, int16_t *block, +void ff_dct_unquantize_mpeg1_inter_mmi(MPVContext *s, int16_t *block, int n, int qscale); -void ff_dct_unquantize_mpeg2_intra_mmi(MpegEncContext *s, int16_t *block, +void ff_dct_unquantize_mpeg2_intra_mmi(MPVContext *s, int16_t *block, int n, int qscale); -void ff_denoise_dct_mmi(MpegEncContext *s, int16_t *block); +void ff_denoise_dct_mmi(MPVContext *s, int16_t *block); #endif /* AVCODEC_MIPS_MPEGVIDEO_MIPS_H */ diff --git a/libavcodec/mips/mpegvideo_mmi.c b/libavcodec/mips/mpegvideo_mmi.c index 3d5b5e20ab..e8ff72c946 100644 --- a/libavcodec/mips/mpegvideo_mmi.c +++ b/libavcodec/mips/mpegvideo_mmi.c @@ -25,7 +25,7 @@ #include "mpegvideo_mips.h" #include "libavutil/mips/mmiutils.h" -void ff_dct_unquantize_h263_intra_mmi(MpegEncContext *s, int16_t *block, +void ff_dct_unquantize_h263_intra_mmi(MPVContext *s, int16_t *block, int n, int qscale) { int64_t level, nCoeffs; @@ -101,7 +101,7 @@ void ff_dct_unquantize_h263_intra_mmi(MpegEncContext *s, int16_t *block, block[0] = level; } -void ff_dct_unquantize_h263_inter_mmi(MpegEncContext *s, int16_t *block, +void ff_dct_unquantize_h263_inter_mmi(MPVContext *s, int16_t *block, int n, int qscale) { int64_t nCoeffs; @@ -160,7 +160,7 @@ void ff_dct_unquantize_h263_inter_mmi(MpegEncContext *s, int16_t *block, ); } -void ff_dct_unquantize_mpeg1_intra_mmi(MpegEncContext *s, int16_t *block, +void ff_dct_unquantize_mpeg1_intra_mmi(MPVContext *s, int16_t *block, int n, int qscale) { int64_t nCoeffs; @@ -254,7 +254,7 @@ void ff_dct_unquantize_mpeg1_intra_mmi(MpegEncContext *s, int16_t *block, block[0] = block0; } -void ff_dct_unquantize_mpeg1_inter_mmi(MpegEncContext *s, int16_t *block, +void ff_dct_unquantize_mpeg1_inter_mmi(MPVContext *s, int16_t *block, int n, int qscale) { int64_t nCoeffs; @@ -342,7 +342,7 @@ void ff_dct_unquantize_mpeg1_inter_mmi(MpegEncContext *s, int16_t *block, ); } -void ff_dct_unquantize_mpeg2_intra_mmi(MpegEncContext *s, int16_t *block, +void ff_dct_unquantize_mpeg2_intra_mmi(MPVContext *s, int16_t *block, int n, int qscale) { uint64_t nCoeffs; @@ -435,7 +435,7 @@ void ff_dct_unquantize_mpeg2_intra_mmi(MpegEncContext *s, int16_t *block, block[0]= block0; } -void ff_denoise_dct_mmi(MpegEncContext *s, int16_t *block) +void ff_denoise_dct_mmi(MPVContext *s, int16_t *block) { const int intra = s->mb_intra; int *sum = s->dct_error_sum[intra]; diff --git a/libavcodec/mips/mpegvideo_msa.c b/libavcodec/mips/mpegvideo_msa.c index aa9ef770eb..26dc3df92c 100644 --- a/libavcodec/mips/mpegvideo_msa.c +++ b/libavcodec/mips/mpegvideo_msa.c @@ -193,7 +193,7 @@ static int32_t mpeg2_dct_unquantize_inter_msa(int16_t *block, return sum_res; } -void ff_dct_unquantize_h263_intra_msa(MpegEncContext *s, +void ff_dct_unquantize_h263_intra_msa(MPVContext *s, int16_t *block, int32_t index, int32_t qscale) { @@ -218,7 +218,7 @@ void ff_dct_unquantize_h263_intra_msa(MpegEncContext *s, h263_dct_unquantize_msa(block, qmul, qadd, nCoeffs, 1); } -void ff_dct_unquantize_h263_inter_msa(MpegEncContext *s, +void ff_dct_unquantize_h263_inter_msa(MPVContext *s, int16_t *block, int32_t index, int32_t qscale) { @@ -235,7 +235,7 @@ void ff_dct_unquantize_h263_inter_msa(MpegEncContext *s, h263_dct_unquantize_msa(block, qmul, qadd, nCoeffs, 0); } -void ff_dct_unquantize_mpeg2_inter_msa(MpegEncContext *s, +void ff_dct_unquantize_mpeg2_inter_msa(MPVContext *s, int16_t *block, int32_t index, int32_t qscale) { diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index b9b17a50df..596accfc50 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -44,10 +44,10 @@ /* The following is the private context of MJPEG/AMV decoder. * Note that when using slice threading only the main thread's - * MpegEncContext is followed by a MjpegContext; the other threads - * can access this shared context via MpegEncContext.mjpeg. */ + * MPVMainEncContext is followed by a MJpegContext; the other threads + * can access this shared context via MPVEncContext.mjpeg. */ typedef struct MJPEGEncContext { - MpegEncContext mpeg; + MPVMainEncContext mpeg; MJpegContext mjpeg; } MJPEGEncContext; @@ -75,7 +75,7 @@ static av_cold void init_uni_ac_vlc(const uint8_t huff_size_ac[256], } } -static void mjpeg_encode_picture_header(MpegEncContext *s) +static void mjpeg_encode_picture_header(MPVMainEncContext *s) { ff_mjpeg_encode_picture_header(s->avctx, &s->pb, s->mjpeg_ctx, &s->intra_scantable, 0, @@ -87,7 +87,7 @@ static void mjpeg_encode_picture_header(MpegEncContext *s) s->thread_context[i]->esc_pos = 0; } -void ff_mjpeg_amv_encode_picture_header(MpegEncContext *s) +void ff_mjpeg_amv_encode_picture_header(MPVMainEncContext *s) { MJPEGEncContext *const m = (MJPEGEncContext*)s; av_assert2(s->mjpeg_ctx == &m->mjpeg); @@ -100,9 +100,9 @@ void ff_mjpeg_amv_encode_picture_header(MpegEncContext *s) /** * Encodes and outputs the entire frame in the JPEG format. * - * @param s The MpegEncContext. + * @param s The MPVEncContext. */ -static void mjpeg_encode_picture_frame(MpegEncContext *s) +static void mjpeg_encode_picture_frame(MPVEncContext *s) { int nbits, code, table_id; MJpegContext *m = s->mjpeg_ctx; @@ -211,10 +211,10 @@ static void mjpeg_build_optimal_huffman(MJpegContext *m) * * Header + values + stuffing. * - * @param s The MpegEncContext. + * @param s The MPVEncContext. * @return int Error code, 0 if successful. */ -int ff_mjpeg_encode_stuffing(MpegEncContext *s) +int ff_mjpeg_encode_stuffing(MPVEncContext *s) { MJpegContext *const m = s->mjpeg_ctx; PutBitContext *pbc = &s->pb; @@ -260,7 +260,7 @@ fail: return ret; } -static int alloc_huffman(MpegEncContext *s) +static int alloc_huffman(MPVMainEncContext *s) { MJpegContext *m = s->mjpeg_ctx; size_t num_mbs, num_blocks, num_codes; @@ -288,7 +288,7 @@ static int alloc_huffman(MpegEncContext *s) return 0; } -av_cold int ff_mjpeg_encode_init(MpegEncContext *s) +av_cold int ff_mjpeg_encode_init(MPVMainEncContext *s) { MJpegContext *const m = &((MJPEGEncContext*)s)->mjpeg; int ret, use_slices; @@ -412,11 +412,11 @@ static void ff_mjpeg_encode_coef(MJpegContext *s, uint8_t table_id, int val, int /** * Add the block's data into the JPEG buffer. * - * @param s The MpegEncContext that contains the JPEG buffer. + * @param s The MPVEncContext that contains the JPEG buffer. * @param block The block. * @param n The block's index or number. */ -static void record_block(MpegEncContext *s, int16_t *block, int n) +static void record_block(MPVEncContext *s, int16_t *block, int n) { int i, j, table_id; int component, dc, last_index, val, run; @@ -459,7 +459,7 @@ static void record_block(MpegEncContext *s, int16_t *block, int n) ff_mjpeg_encode_code(m, table_id, 0); } -static void encode_block(MpegEncContext *s, int16_t *block, int n) +static void encode_block(MPVEncContext *s, int16_t *block, int n) { int mant, nbits, code, i, j; int component, dc, run, last_index, val; @@ -517,7 +517,7 @@ static void encode_block(MpegEncContext *s, int16_t *block, int n) put_bits(&s->pb, huff_size_ac[0], huff_code_ac[0]); } -void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[12][64]) +void ff_mjpeg_encode_mb(MPVEncContext *s, int16_t block[12][64]) { int i; if (s->mjpeg_ctx->huffman == HUFFMAN_TABLE_OPTIMAL) { @@ -589,7 +589,7 @@ void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[12][64]) static int amv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic_arg, int *got_packet) { - MpegEncContext *s = avctx->priv_data; + MPVMainEncContext *const s = avctx->priv_data; AVFrame *pic; int i, ret; int chroma_h_shift, chroma_v_shift; diff --git a/libavcodec/mjpegenc.h b/libavcodec/mjpegenc.h index a593b67e96..6db1c6e89f 100644 --- a/libavcodec/mjpegenc.h +++ b/libavcodec/mjpegenc.h @@ -36,7 +36,7 @@ #include #include "mjpeg.h" -#include "mpegvideo.h" +#include "mpegvideoenc.h" #include "put_bits.h" /** @@ -71,9 +71,9 @@ typedef struct MJpegContext { uint8_t huff_size_ac_chrominance[256]; ///< AC chrominance Huffman table size. uint16_t huff_code_ac_chrominance[256]; ///< AC chrominance Huffman table codes. - /** Storage for AC luminance VLC (in MpegEncContext) */ + /** Storage for AC luminance VLC (in MPVEncContext) */ uint8_t uni_ac_vlc_len[64 * 64 * 2]; - /** Storage for AC chrominance VLC (in MpegEncContext) */ + /** Storage for AC chrominance VLC (in MPVEncContext) */ uint8_t uni_chroma_ac_vlc_len[64 * 64 * 2]; // Default DC tables have exactly 12 values @@ -107,9 +107,9 @@ static inline void put_marker(PutBitContext *p, enum JpegMarker code) put_bits(p, 8, code); } -int ff_mjpeg_encode_init(MpegEncContext *s); -void ff_mjpeg_amv_encode_picture_header(MpegEncContext *s); -void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[12][64]); -int ff_mjpeg_encode_stuffing(MpegEncContext *s); +int ff_mjpeg_encode_init(MPVMainEncContext *m); +void ff_mjpeg_amv_encode_picture_header(MPVMainEncContext *m); +void ff_mjpeg_encode_mb(MPVEncContext *s, int16_t block[12][64]); +int ff_mjpeg_encode_stuffing(MPVEncContext *s); #endif /* AVCODEC_MJPEGENC_H */ diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index 35ca40b90a..cc305d06ff 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -47,7 +47,7 @@ #define ME_MAP_SHIFT 3 #define ME_MAP_MV_BITS 11 -static int sad_hpel_motion_search(MpegEncContext * s, +static int sad_hpel_motion_search(MPVEncContext *s, int *mx_ptr, int *my_ptr, int dmin, int src_index, int ref_index, int size, int h); @@ -104,7 +104,7 @@ static int get_flags(MotionEstContext *c, int direct, int chroma){ + (chroma ? FLAG_CHROMA : 0); } -static av_always_inline int cmp_direct_inline(MpegEncContext *s, const int x, const int y, const int subx, const int suby, +static av_always_inline int cmp_direct_inline(MPVEncContext *s, const int x, const int y, const int subx, const int suby, const int size, const int h, int ref_index, int src_index, me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, int qpel){ MotionEstContext * const c= &s->me; @@ -176,7 +176,7 @@ static av_always_inline int cmp_direct_inline(MpegEncContext *s, const int x, co return d; } -static av_always_inline int cmp_inline(MpegEncContext *s, const int x, const int y, const int subx, const int suby, +static av_always_inline int cmp_inline(MPVEncContext *s, const int x, const int y, const int subx, const int suby, const int size, const int h, int ref_index, int src_index, me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, int qpel, int chroma){ MotionEstContext * const c= &s->me; @@ -228,13 +228,13 @@ static av_always_inline int cmp_inline(MpegEncContext *s, const int x, const int return d; } -static int cmp_simple(MpegEncContext *s, const int x, const int y, +static int cmp_simple(MPVEncContext *s, const int x, const int y, int ref_index, int src_index, me_cmp_func cmp_func, me_cmp_func chroma_cmp_func){ return cmp_inline(s,x,y,0,0,0,16,ref_index,src_index, cmp_func, chroma_cmp_func, 0, 0); } -static int cmp_fpel_internal(MpegEncContext *s, const int x, const int y, +static int cmp_fpel_internal(MPVEncContext *s, const int x, const int y, const int size, const int h, int ref_index, int src_index, me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, const int flags){ if(flags&FLAG_DIRECT){ @@ -244,7 +244,7 @@ static int cmp_fpel_internal(MpegEncContext *s, const int x, const int y, } } -static int cmp_internal(MpegEncContext *s, const int x, const int y, const int subx, const int suby, +static int cmp_internal(MPVEncContext *s, const int x, const int y, const int subx, const int suby, const int size, const int h, int ref_index, int src_index, me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, const int flags){ if(flags&FLAG_DIRECT){ @@ -257,7 +257,7 @@ static int cmp_internal(MpegEncContext *s, const int x, const int y, const int s /** @brief compares a block (either a full macroblock or a partition thereof) against a proposed motion-compensated prediction of that block */ -static av_always_inline int cmp(MpegEncContext *s, const int x, const int y, const int subx, const int suby, +static av_always_inline int cmp(MPVEncContext *s, const int x, const int y, const int subx, const int suby, const int size, const int h, int ref_index, int src_index, me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, const int flags){ if(av_builtin_constant_p(flags) && av_builtin_constant_p(h) && av_builtin_constant_p(size) @@ -272,7 +272,7 @@ static av_always_inline int cmp(MpegEncContext *s, const int x, const int y, con } } -static int cmp_hpel(MpegEncContext *s, const int x, const int y, const int subx, const int suby, +static int cmp_hpel(MPVEncContext *s, const int x, const int y, const int subx, const int suby, const int size, const int h, int ref_index, int src_index, me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, const int flags){ if(flags&FLAG_DIRECT){ @@ -282,7 +282,7 @@ static int cmp_hpel(MpegEncContext *s, const int x, const int y, const int subx, } } -static int cmp_qpel(MpegEncContext *s, const int x, const int y, const int subx, const int suby, +static int cmp_qpel(MPVEncContext *s, const int x, const int y, const int subx, const int suby, const int size, const int h, int ref_index, int src_index, me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, const int flags){ if(flags&FLAG_DIRECT){ @@ -294,7 +294,7 @@ static int cmp_qpel(MpegEncContext *s, const int x, const int y, const int subx, #include "motion_est_template.c" -static int zero_cmp(MpegEncContext *s, uint8_t *a, uint8_t *b, +static int zero_cmp(MPVEncContext *s, uint8_t *a, uint8_t *b, ptrdiff_t stride, int h) { return 0; @@ -303,7 +303,7 @@ static int zero_cmp(MpegEncContext *s, uint8_t *a, uint8_t *b, static void zero_hpel(uint8_t *a, const uint8_t *b, ptrdiff_t stride, int h){ } -int ff_init_me(MpegEncContext *s){ +int ff_init_me(MPVEncContext *s){ MotionEstContext * const c= &s->me; int cache_size= FFMIN(ME_MAP_SIZE>>ME_MAP_SHIFT, 1<avctx->dia_size)&255, FFABS(s->avctx->pre_dia_size)&255); @@ -389,7 +389,7 @@ int ff_init_me(MpegEncContext *s){ COPY3_IF_LT(dminh, d, dx, x, dy, y)\ } -static int sad_hpel_motion_search(MpegEncContext * s, +static int sad_hpel_motion_search(MPVEncContext *s, int *mx_ptr, int *my_ptr, int dmin, int src_index, int ref_index, int size, int h) @@ -494,7 +494,7 @@ static int sad_hpel_motion_search(MpegEncContext * s, return dminh; } -static inline void set_p_mv_tables(MpegEncContext * s, int mx, int my, int mv4) +static inline void set_p_mv_tables(MPVEncContext *s, int mx, int my, int mv4) { const int xy= s->mb_x + s->mb_y*s->mb_stride; @@ -521,7 +521,7 @@ static inline void set_p_mv_tables(MpegEncContext * s, int mx, int my, int mv4) /** * get fullpel ME search limits. */ -static inline void get_limits(MpegEncContext *s, int x, int y) +static inline void get_limits(MPVEncContext *s, int x, int y) { MotionEstContext * const c= &s->me; int range= c->avctx->me_range >> (1 + !!(c->flags&FLAG_QPEL)); @@ -568,7 +568,7 @@ static inline void init_mv4_ref(MotionEstContext *c){ c->src[3][0] = c->src[2][0] + 8; } -static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift) +static inline int h263_mv4_search(MPVEncContext *s, int mx, int my, int shift) { MotionEstContext * const c= &s->me; const int size= 1; @@ -722,7 +722,7 @@ static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift) } } -static inline void init_interlaced_ref(MpegEncContext *s, int ref_index){ +static inline void init_interlaced_ref(MPVEncContext *s, int ref_index){ MotionEstContext * const c= &s->me; c->ref[1+ref_index][0] = c->ref[0+ref_index][0] + s->linesize; @@ -735,7 +735,7 @@ static inline void init_interlaced_ref(MpegEncContext *s, int ref_index){ } } -static int interlaced_search(MpegEncContext *s, int ref_index, +static int interlaced_search(MPVEncContext *s, int ref_index, int16_t (*mv_tables[2][2])[2], uint8_t *field_select_tables[2], int mx, int my, int user_field_select) { MotionEstContext * const c= &s->me; @@ -882,7 +882,7 @@ static inline int get_penalty_factor(int lambda, int lambda2, int type){ } } -void ff_estimate_p_frame_motion(MpegEncContext * s, +void ff_estimate_p_frame_motion(MPVEncContext *s, int mb_x, int mb_y) { MotionEstContext * const c= &s->me; @@ -1058,7 +1058,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s, s->mb_type[mb_y*s->mb_stride + mb_x]= mb_type; } -int ff_pre_estimate_p_frame_motion(MpegEncContext * s, +int ff_pre_estimate_p_frame_motion(MPVEncContext *s, int mb_x, int mb_y) { MotionEstContext * const c= &s->me; @@ -1111,7 +1111,7 @@ int ff_pre_estimate_p_frame_motion(MpegEncContext * s, return dmin; } -static int estimate_motion_b(MpegEncContext *s, int mb_x, int mb_y, +static int estimate_motion_b(MPVEncContext *s, int mb_x, int mb_y, int16_t (*mv_table)[2], int ref_index, int f_code) { MotionEstContext * const c= &s->me; @@ -1173,7 +1173,7 @@ static int estimate_motion_b(MpegEncContext *s, int mb_x, int mb_y, return dmin; } -static inline int check_bidir_mv(MpegEncContext * s, +static inline int check_bidir_mv(MPVEncContext *s, int motion_fx, int motion_fy, int motion_bx, int motion_by, int pred_fx, int pred_fy, @@ -1238,7 +1238,7 @@ static inline int check_bidir_mv(MpegEncContext * s, } /* refine the bidir vectors in hq mode and return the score in both lq & hq mode*/ -static inline int bidir_refine(MpegEncContext * s, int mb_x, int mb_y) +static inline int bidir_refine(MPVEncContext *s, int mb_x, int mb_y) { MotionEstContext * const c= &s->me; const int mot_stride = s->mb_stride; @@ -1385,7 +1385,7 @@ CHECK_BIDIR(-(a),-(b),-(c),-(d)) return fbmin; } -static inline int direct_search(MpegEncContext * s, int mb_x, int mb_y) +static inline int direct_search(MPVEncContext *s, int mb_x, int mb_y) { MotionEstContext * const c= &s->me; int P[10][2]; @@ -1487,7 +1487,7 @@ static inline int direct_search(MpegEncContext * s, int mb_x, int mb_y) return dmin; } -void ff_estimate_b_frame_motion(MpegEncContext * s, +void ff_estimate_b_frame_motion(MPVEncContext *s, int mb_x, int mb_y) { MotionEstContext * const c= &s->me; @@ -1595,7 +1595,7 @@ void ff_estimate_b_frame_motion(MpegEncContext * s, } /* find best f_code for ME which do unlimited searches */ -int ff_get_best_fcode(MpegEncContext * s, int16_t (*mv_table)[2], int type) +int ff_get_best_fcode(MPVEncContext *s, int16_t (*mv_table)[2], int type) { if (s->motion_est != FF_ME_ZERO) { int score[8]; @@ -1648,7 +1648,7 @@ int ff_get_best_fcode(MpegEncContext * s, int16_t (*mv_table)[2], int type) } } -void ff_fix_long_p_mvs(MpegEncContext * s, int type) +void ff_fix_long_p_mvs(MPVEncContext *s, int type) { MotionEstContext * const c= &s->me; const int f_code= s->f_code; @@ -1697,7 +1697,7 @@ void ff_fix_long_p_mvs(MpegEncContext * s, int type) /** * @param truncate 1 for truncation, 0 for using intra */ -void ff_fix_long_mvs(MpegEncContext * s, uint8_t *field_select_table, int field_select, +void ff_fix_long_mvs(MPVEncContext *s, uint8_t *field_select_table, int field_select, int16_t (*mv_table)[2], int f_code, int type, int truncate) { MotionEstContext * const c= &s->me; diff --git a/libavcodec/motion_est.h b/libavcodec/motion_est.h index 5742e51486..b52b91ab3f 100644 --- a/libavcodec/motion_est.h +++ b/libavcodec/motion_est.h @@ -27,7 +27,8 @@ #include "hpeldsp.h" #include "qpeldsp.h" -struct MpegEncContext; +#define MPVEncContext MPVContext +struct MPVEncContext; #if ARCH_IA64 // Limit static arrays to avoid gcc failing "short data segment overflowed" #define MAX_MV 1024 @@ -92,7 +93,7 @@ typedef struct MotionEstContext { qpel_mc_func(*qpel_avg)[16]; const uint8_t (*mv_penalty)[MAX_DMV * 2 + 1]; ///< bit amount needed to encode a MV const uint8_t *current_mv_penalty; - int (*sub_motion_search)(struct MpegEncContext *s, + int (*sub_motion_search)(struct MPVEncContext *s, int *mx_ptr, int *my_ptr, int dmin, int src_index, int ref_index, int size, int h); @@ -108,28 +109,28 @@ static inline int ff_h263_round_chroma(int x) return h263_chroma_roundtab[x & 0xf] + (x >> 3); } -int ff_init_me(struct MpegEncContext *s); +int ff_init_me(struct MPVEncContext *s); -void ff_estimate_p_frame_motion(struct MpegEncContext *s, int mb_x, int mb_y); -void ff_estimate_b_frame_motion(struct MpegEncContext *s, int mb_x, int mb_y); +void ff_estimate_p_frame_motion(struct MPVEncContext *s, int mb_x, int mb_y); +void ff_estimate_b_frame_motion(struct MPVEncContext *s, int mb_x, int mb_y); -int ff_pre_estimate_p_frame_motion(struct MpegEncContext *s, +int ff_pre_estimate_p_frame_motion(struct MPVEncContext *s, int mb_x, int mb_y); -int ff_epzs_motion_search(struct MpegEncContext *s, int *mx_ptr, int *my_ptr, +int ff_epzs_motion_search(struct MPVEncContext *s, int *mx_ptr, int *my_ptr, int P[10][2], int src_index, int ref_index, int16_t (*last_mv)[2], int ref_mv_scale, int size, int h); -int ff_get_mb_score(struct MpegEncContext *s, int mx, int my, int src_index, +int ff_get_mb_score(struct MPVEncContext *s, int mx, int my, int src_index, int ref_index, int size, int h, int add_rate); -int ff_get_best_fcode(struct MpegEncContext *s, +int ff_get_best_fcode(struct MPVEncContext *s, int16_t (*mv_table)[2], int type); -void ff_fix_long_p_mvs(struct MpegEncContext *s, int type); -void ff_fix_long_mvs(struct MpegEncContext *s, uint8_t *field_select_table, +void ff_fix_long_p_mvs(struct MPVEncContext *s, int type); +void ff_fix_long_mvs(struct MPVEncContext *s, uint8_t *field_select_table, int field_select, int16_t (*mv_table)[2], int f_code, int type, int truncate); - +#undef MPVEncContext #endif /* AVCODEC_MOTION_EST_H */ diff --git a/libavcodec/motion_est_template.c b/libavcodec/motion_est_template.c index 6ab0ea13dc..fc887b05b7 100644 --- a/libavcodec/motion_est_template.c +++ b/libavcodec/motion_est_template.c @@ -47,7 +47,7 @@ COPY3_IF_LT(dmin, d, bx, hx, by, hy)\ } -static int hpel_motion_search(MpegEncContext * s, +static int hpel_motion_search(MPVEncContext *s, int *mx_ptr, int *my_ptr, int dmin, int src_index, int ref_index, int size, int h) @@ -152,7 +152,7 @@ static int hpel_motion_search(MpegEncContext * s, return dmin; } -static int no_sub_motion_search(MpegEncContext * s, +static int no_sub_motion_search(MPVEncContext *s, int *mx_ptr, int *my_ptr, int dmin, int src_index, int ref_index, int size, int h) @@ -162,7 +162,7 @@ static int no_sub_motion_search(MpegEncContext * s, return dmin; } -static inline int get_mb_score(MpegEncContext *s, int mx, int my, +static inline int get_mb_score(MPVEncContext *s, int mx, int my, int src_index, int ref_index, int size, int h, int add_rate) { @@ -189,7 +189,7 @@ static inline int get_mb_score(MpegEncContext *s, int mx, int my, return d; } -int ff_get_mb_score(MpegEncContext *s, int mx, int my, int src_index, +int ff_get_mb_score(MPVEncContext *s, int mx, int my, int src_index, int ref_index, int size, int h, int add_rate) { return get_mb_score(s, mx, my, src_index, ref_index, size, h, add_rate); @@ -204,7 +204,7 @@ int ff_get_mb_score(MpegEncContext *s, int mx, int my, int src_index, COPY3_IF_LT(dmin, d, bx, hx, by, hy)\ } -static int qpel_motion_search(MpegEncContext * s, +static int qpel_motion_search(MPVEncContext *s, int *mx_ptr, int *my_ptr, int dmin, int src_index, int ref_index, int size, int h) @@ -413,7 +413,7 @@ if( (y)>(ymax<<(S)) ) av_log(NULL, AV_LOG_ERROR, "%d %d %d %d %d ymax" #v, ymax, const int qpel= flags&FLAG_QPEL;\ const int shift= 1+qpel;\ -static av_always_inline int small_diamond_search(MpegEncContext * s, int *best, int dmin, +static av_always_inline int small_diamond_search(MPVEncContext *s, int *best, int dmin, int src_index, int ref_index, const int penalty_factor, int size, int h, int flags) { @@ -454,7 +454,7 @@ static av_always_inline int small_diamond_search(MpegEncContext * s, int *best, } } -static int funny_diamond_search(MpegEncContext * s, int *best, int dmin, +static int funny_diamond_search(MPVEncContext *s, int *best, int dmin, int src_index, int ref_index, const int penalty_factor, int size, int h, int flags) { @@ -496,7 +496,7 @@ static int funny_diamond_search(MpegEncContext * s, int *best, int dmin, return dmin; } -static int hex_search(MpegEncContext * s, int *best, int dmin, +static int hex_search(MPVEncContext *s, int *best, int dmin, int src_index, int ref_index, const int penalty_factor, int size, int h, int flags, int dia_size) { @@ -530,7 +530,7 @@ static int hex_search(MpegEncContext * s, int *best, int dmin, return dmin; } -static int l2s_dia_search(MpegEncContext * s, int *best, int dmin, +static int l2s_dia_search(MPVEncContext *s, int *best, int dmin, int src_index, int ref_index, const int penalty_factor, int size, int h, int flags) { @@ -568,7 +568,7 @@ static int l2s_dia_search(MpegEncContext * s, int *best, int dmin, return dmin; } -static int umh_search(MpegEncContext * s, int *best, int dmin, +static int umh_search(MPVEncContext *s, int *best, int dmin, int src_index, int ref_index, const int penalty_factor, int size, int h, int flags) { @@ -615,7 +615,7 @@ static int umh_search(MpegEncContext * s, int *best, int dmin, return hex_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags, 2); } -static int full_search(MpegEncContext * s, int *best, int dmin, +static int full_search(MPVEncContext *s, int *best, int dmin, int src_index, int ref_index, const int penalty_factor, int size, int h, int flags) { @@ -678,7 +678,7 @@ static int full_search(MpegEncContext * s, int *best, int dmin, } #define MAX_SAB_SIZE ME_MAP_SIZE -static int sab_diamond_search(MpegEncContext * s, int *best, int dmin, +static int sab_diamond_search(MPVEncContext *s, int *best, int dmin, int src_index, int ref_index, const int penalty_factor, int size, int h, int flags) { @@ -768,7 +768,7 @@ static int sab_diamond_search(MpegEncContext * s, int *best, int dmin, return dmin; } -static int var_diamond_search(MpegEncContext * s, int *best, int dmin, +static int var_diamond_search(MPVEncContext *s, int *best, int dmin, int src_index, int ref_index, const int penalty_factor, int size, int h, int flags) { @@ -829,7 +829,7 @@ static int var_diamond_search(MpegEncContext * s, int *best, int dmin, return dmin; } -static av_always_inline int diamond_search(MpegEncContext * s, int *best, int dmin, +static av_always_inline int diamond_search(MPVEncContext *s, int *best, int dmin, int src_index, int ref_index, const int penalty_factor, int size, int h, int flags){ MotionEstContext * const c= &s->me; @@ -857,7 +857,7 @@ static av_always_inline int diamond_search(MpegEncContext * s, int *best, int dm it takes fewer iterations. And it increases the chance that we find the optimal mv. */ -static av_always_inline int epzs_motion_search_internal(MpegEncContext * s, int *mx_ptr, int *my_ptr, +static av_always_inline int epzs_motion_search_internal(MPVEncContext *s, int *mx_ptr, int *my_ptr, int P[10][2], int src_index, int ref_index, int16_t (*last_mv)[2], int ref_mv_scale, int flags, int size, int h) { @@ -974,7 +974,7 @@ static av_always_inline int epzs_motion_search_internal(MpegEncContext * s, int } //this function is dedicated to the brain damaged gcc -int ff_epzs_motion_search(MpegEncContext *s, int *mx_ptr, int *my_ptr, +int ff_epzs_motion_search(MPVEncContext *s, int *mx_ptr, int *my_ptr, int P[10][2], int src_index, int ref_index, int16_t (*last_mv)[2], int ref_mv_scale, int size, int h) @@ -990,7 +990,7 @@ int ff_epzs_motion_search(MpegEncContext *s, int *mx_ptr, int *my_ptr, } } -static int epzs_motion_search2(MpegEncContext * s, +static int epzs_motion_search2(MPVEncContext *s, int *mx_ptr, int *my_ptr, int P[10][2], int src_index, int ref_index, int16_t (*last_mv)[2], int ref_mv_scale, const int size) diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index ecb0706cf5..7934c7ea2a 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -100,7 +100,7 @@ av_cold void ff_init_2d_vlc_rl(RLTable *rl, unsigned static_size, int flags) } } -av_cold void ff_mpeg12_common_init(MpegEncContext *s) +av_cold void ff_mpeg12_common_init(MPVMainContext *s) { s->y_dc_scale_table = @@ -108,7 +108,7 @@ av_cold void ff_mpeg12_common_init(MpegEncContext *s) } -void ff_mpeg1_clean_buffers(MpegEncContext *s) +void ff_mpeg1_clean_buffers(MPVContext *s) { s->last_dc[0] = 1 << (7 + s->intra_dc_precision); s->last_dc[1] = s->last_dc[0]; diff --git a/libavcodec/mpeg12.h b/libavcodec/mpeg12.h index e0406b32d9..b62e32b70f 100644 --- a/libavcodec/mpeg12.h +++ b/libavcodec/mpeg12.h @@ -34,9 +34,9 @@ #define EXT_START_CODE 0x000001b5 #define USER_START_CODE 0x000001b2 -void ff_mpeg12_common_init(MpegEncContext *s); +void ff_mpeg12_common_init(MPVMainContext *m); -void ff_mpeg1_clean_buffers(MpegEncContext *s); +void ff_mpeg1_clean_buffers(MPVContext *s); #if FF_API_FLAG_TRUNCATED int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size, AVCodecParserContext *s); #endif diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index a3a7e86ccf..22e0ba5ed3 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -55,8 +55,8 @@ #define A53_MAX_CC_COUNT 2000 typedef struct Mpeg1Context { - MpegEncContext mpeg_enc_ctx; - int mpeg_enc_ctx_allocated; /* true if decoding context allocated */ + MPVMainDecContext mpeg_ctx; + int mpeg_ctx_allocated; /* true if decoding context allocated */ int repeat_field; /* true if we must repeat the field */ AVPanScan pan_scan; /* some temporary storage for the panscan */ AVStereo3D stereo3d; @@ -106,7 +106,7 @@ static const uint32_t btype2mb_type[11] = { }; /* as H.263, but only 17 codes */ -static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred) +static int mpeg_decode_motion(MPVDecContext *s, int fcode, int pred) { int code, sign, val, shift; @@ -142,7 +142,7 @@ static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred) } \ } while (0) -static inline int mpeg1_decode_block_inter(MpegEncContext *s, +static inline int mpeg1_decode_block_inter(MPVDecContext *s, int16_t *block, int n) { int level, i, j, run; @@ -231,7 +231,7 @@ end: * Changing this would eat up any speed benefits it has. * Do not use "fast" flag if you need the code to be robust. */ -static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s, +static inline int mpeg1_fast_decode_block_inter(MPVDecContext *s, int16_t *block, int n) { int level, i, j, run; @@ -316,7 +316,7 @@ end: return 0; } -static inline int mpeg2_decode_block_non_intra(MpegEncContext *s, +static inline int mpeg2_decode_block_non_intra(MPVDecContext *s, int16_t *block, int n) { int level, i, j, run; @@ -406,7 +406,7 @@ end: * Changing this would eat up any speed benefits it has. * Do not use "fast" flag if you need the code to be robust. */ -static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s, +static inline int mpeg2_fast_decode_block_non_intra(MPVDecContext *s, int16_t *block, int n) { int level, i, j, run; @@ -478,7 +478,7 @@ end: return 0; } -static inline int mpeg2_decode_block_intra(MpegEncContext *s, +static inline int mpeg2_decode_block_intra(MPVDecContext *s, int16_t *block, int n) { int level, dc, diff, i, j, run; @@ -564,7 +564,7 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s, * Changing this would eat up any speed benefits it has. * Do not use "fast" flag if you need the code to be robust. */ -static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, +static inline int mpeg2_fast_decode_block_intra(MPVDecContext *s, int16_t *block, int n) { int level, dc, diff, i, j, run; @@ -640,7 +640,7 @@ static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, /******************************************/ /* decoding */ -static inline int get_dmv(MpegEncContext *s) +static inline int get_dmv(MPVDecContext *s) { if (get_bits1(&s->gb)) return 1 - (get_bits1(&s->gb) << 1); @@ -654,7 +654,7 @@ static inline int get_dmv(MpegEncContext *s) #define MT_16X8 2 #define MT_DMV 3 -static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64]) +static int mpeg_decode_mb(MPVDecContext *s, int16_t block[12][64]) { int i, j, k, cbp, val, mb_type, motion_type; const int mb_block_count = 4 + (1 << s->chroma_format); @@ -1054,7 +1054,7 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64]) static av_cold int mpeg_decode_init(AVCodecContext *avctx) { Mpeg1Context *s = avctx->priv_data; - MpegEncContext *s2 = &s->mpeg_enc_ctx; + MPVMainDecContext *const s2 = &s->mpeg_ctx; if ( avctx->codec_tag != AV_RL32("VCR2") && avctx->codec_tag != AV_RL32("BW10")) @@ -1064,11 +1064,11 @@ static av_cold int mpeg_decode_init(AVCodecContext *avctx) /* we need some permutation to store matrices, * until the decoder sets the real permutation. */ ff_mpv_idct_init(s2); - ff_mpeg12_common_init(&s->mpeg_enc_ctx); + ff_mpeg12_common_init(&s->mpeg_ctx); ff_mpeg12_init_vlcs(); s2->chroma_format = 1; - s->mpeg_enc_ctx_allocated = 0; + s->mpeg_ctx_allocated = 0; s->repeat_field = 0; avctx->color_range = AVCOL_RANGE_MPEG; return 0; @@ -1079,11 +1079,12 @@ static int mpeg_decode_update_thread_context(AVCodecContext *avctx, const AVCodecContext *avctx_from) { Mpeg1Context *ctx = avctx->priv_data, *ctx_from = avctx_from->priv_data; - MpegEncContext *s = &ctx->mpeg_enc_ctx, *s1 = &ctx_from->mpeg_enc_ctx; + MPVMainDecContext *const s = &ctx->mpeg_ctx; + const MPVMainDecContext *const s1 = &ctx_from->mpeg_ctx; int err; if (avctx == avctx_from || - !ctx_from->mpeg_enc_ctx_allocated || + !ctx_from->mpeg_ctx_allocated || !s1->context_initialized) return 0; @@ -1091,8 +1092,8 @@ static int mpeg_decode_update_thread_context(AVCodecContext *avctx, if (err) return err; - if (!ctx->mpeg_enc_ctx_allocated) - memcpy(s + 1, s1 + 1, sizeof(Mpeg1Context) - sizeof(MpegEncContext)); + if (!ctx->mpeg_ctx_allocated) + memcpy(s + 1, s1 + 1, sizeof(Mpeg1Context) - sizeof(MPVMainDecContext)); return 0; } @@ -1164,7 +1165,7 @@ static const enum AVPixelFormat mpeg12_pixfmt_list_444[] = { static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx) { Mpeg1Context *s1 = avctx->priv_data; - MpegEncContext *s = &s1->mpeg_enc_ctx; + MPVMainDecContext *const s = &s1->mpeg_ctx; const enum AVPixelFormat *pix_fmts; if (CONFIG_GRAY && (avctx->flags & AV_CODEC_FLAG_GRAY)) @@ -1191,7 +1192,7 @@ static void setup_hwaccel_for_pixfmt(AVCodecContext *avctx) if (avctx->hwaccel && avctx->pix_fmt == AV_PIX_FMT_XVMC) { Mpeg1Context *s1 = avctx->priv_data; - MpegEncContext *s = &s1->mpeg_enc_ctx; + MPVMainDecContext *const s = &s1->mpeg_ctx; s->pack_pblocks = 1; } @@ -1202,7 +1203,7 @@ static void setup_hwaccel_for_pixfmt(AVCodecContext *avctx) static int mpeg_decode_postinit(AVCodecContext *avctx) { Mpeg1Context *s1 = avctx->priv_data; - MpegEncContext *s = &s1->mpeg_enc_ctx; + MPVMainDecContext *const s = &s1->mpeg_ctx; uint8_t old_permutation[64]; int ret; @@ -1257,7 +1258,7 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) avctx->sample_aspect_ratio = (AVRational){ 0, 1 }; } - if ((s1->mpeg_enc_ctx_allocated == 0) || + if (!s1->mpeg_ctx_allocated || avctx->coded_width != s->width || avctx->coded_height != s->height || s1->save_width != s->width || @@ -1265,7 +1266,7 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) av_cmp_q(s1->save_aspect, s->avctx->sample_aspect_ratio) || (s1->save_progressive_seq != s->progressive_sequence && FFALIGN(s->height, 16) != FFALIGN(s->height, 32)) || 0) { - if (s1->mpeg_enc_ctx_allocated) { + if (s1->mpeg_ctx_allocated) { #if FF_API_FLAG_TRUNCATED ParseContext pc = s->parse_context; s->parse_context.buffer = 0; @@ -1274,7 +1275,7 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) #else ff_mpv_common_end(s); #endif - s1->mpeg_enc_ctx_allocated = 0; + s1->mpeg_ctx_allocated = 0; } ret = ff_set_dimensions(avctx, s->width, s->height); @@ -1335,7 +1336,7 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) quant_matrix_rebuild(s->chroma_intra_matrix, old_permutation, s->idsp.idct_permutation); quant_matrix_rebuild(s->chroma_inter_matrix, old_permutation, s->idsp.idct_permutation); - s1->mpeg_enc_ctx_allocated = 1; + s1->mpeg_ctx_allocated = 1; } return 0; } @@ -1344,7 +1345,7 @@ static int mpeg1_decode_picture(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { Mpeg1Context *s1 = avctx->priv_data; - MpegEncContext *s = &s1->mpeg_enc_ctx; + MPVMainDecContext *const s = &s1->mpeg_ctx; int ref, f_code, vbv_delay, ret; ret = init_get_bits8(&s->gb, buf, buf_size); @@ -1391,7 +1392,7 @@ static int mpeg1_decode_picture(AVCodecContext *avctx, const uint8_t *buf, static void mpeg_decode_sequence_extension(Mpeg1Context *s1) { - MpegEncContext *s = &s1->mpeg_enc_ctx; + MPVMainDecContext *const s = &s1->mpeg_ctx; int horiz_size_ext, vert_size_ext; int bit_rate_ext; AVCPBProperties *cpb_props; @@ -1441,7 +1442,7 @@ static void mpeg_decode_sequence_extension(Mpeg1Context *s1) static void mpeg_decode_sequence_display_extension(Mpeg1Context *s1) { - MpegEncContext *s = &s1->mpeg_enc_ctx; + MPVMainDecContext *const s = &s1->mpeg_ctx; int color_description, w, h; skip_bits(&s->gb, 3); /* video format */ @@ -1465,7 +1466,7 @@ static void mpeg_decode_sequence_display_extension(Mpeg1Context *s1) static void mpeg_decode_picture_display_extension(Mpeg1Context *s1) { - MpegEncContext *s = &s1->mpeg_enc_ctx; + MPVMainDecContext *const s = &s1->mpeg_ctx; int i, nofco; nofco = 1; @@ -1497,7 +1498,7 @@ static void mpeg_decode_picture_display_extension(Mpeg1Context *s1) s1->pan_scan.position[2][0], s1->pan_scan.position[2][1]); } -static int load_matrix(MpegEncContext *s, uint16_t matrix0[64], +static int load_matrix(MPVMainDecContext *s, uint16_t matrix0[64], uint16_t matrix1[64], int intra) { int i; @@ -1520,7 +1521,7 @@ static int load_matrix(MpegEncContext *s, uint16_t matrix0[64], return 0; } -static void mpeg_decode_quant_matrix_extension(MpegEncContext *s) +static void mpeg_decode_quant_matrix_extension(MPVMainDecContext *s) { ff_dlog(s->avctx, "matrix extension\n"); @@ -1536,7 +1537,7 @@ static void mpeg_decode_quant_matrix_extension(MpegEncContext *s) static int mpeg_decode_picture_coding_extension(Mpeg1Context *s1) { - MpegEncContext *s = &s1->mpeg_enc_ctx; + MPVMainDecContext *const s = &s1->mpeg_ctx; s->full_pel[0] = s->full_pel[1] = 0; s->mpeg_f_code[0][0] = get_bits(&s->gb, 4); @@ -1547,7 +1548,7 @@ static int mpeg_decode_picture_coding_extension(Mpeg1Context *s1) s->mpeg_f_code[0][1] += !s->mpeg_f_code[0][1]; s->mpeg_f_code[1][0] += !s->mpeg_f_code[1][0]; s->mpeg_f_code[1][1] += !s->mpeg_f_code[1][1]; - if (!s->pict_type && s1->mpeg_enc_ctx_allocated) { + if (!s->pict_type && s1->mpeg_ctx_allocated) { av_log(s->avctx, AV_LOG_ERROR, "Missing picture start code\n"); if (s->avctx->err_recognition & AV_EF_EXPLODE) return AVERROR_INVALIDDATA; @@ -1597,7 +1598,7 @@ static int mpeg_decode_picture_coding_extension(Mpeg1Context *s1) return 0; } -static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size) +static int mpeg_field_start(MPVMainDecContext *s, const uint8_t *buf, int buf_size) { AVCodecContext *avctx = s->avctx; Mpeg1Context *s1 = (Mpeg1Context *) s; @@ -1705,11 +1706,11 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size) /** * Decode a slice. - * MpegEncContext.mb_y must be set to the MB row from the startcode. + * MPVDecContext.mb_y must be set to the MB row from the startcode. * @return DECODE_SLICE_ERROR if the slice is damaged, * DECODE_SLICE_OK if this slice is OK */ -static int mpeg_decode_slice(MpegEncContext *s, int mb_y, +static int mpeg_decode_slice(MPVDecContext *s, int mb_y, const uint8_t **buf, int buf_size) { AVCodecContext *avctx = s->avctx; @@ -1988,7 +1989,7 @@ eos: // end of slice static int slice_decode_thread(AVCodecContext *c, void *arg) { - MpegEncContext *s = *(void **) arg; + MPVDecContext *const s = *(void **) arg; const uint8_t *buf = s->gb.buffer; int mb_y = s->start_mb_y; const int field_pic = s->picture_structure != PICT_FRAME; @@ -2042,9 +2043,9 @@ static int slice_decode_thread(AVCodecContext *c, void *arg) static int slice_end(AVCodecContext *avctx, AVFrame *pict) { Mpeg1Context *s1 = avctx->priv_data; - MpegEncContext *s = &s1->mpeg_enc_ctx; + MPVMainDecContext *const s = &s1->mpeg_ctx; - if (!s1->mpeg_enc_ctx_allocated || !s->current_picture_ptr) + if (!s1->mpeg_ctx_allocated || !s->current_picture_ptr) return 0; if (s->avctx->hwaccel) { @@ -2091,7 +2092,7 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { Mpeg1Context *s1 = avctx->priv_data; - MpegEncContext *s = &s1->mpeg_enc_ctx; + MPVMainDecContext *const s = &s1->mpeg_ctx; int width, height; int i, v, j; @@ -2179,14 +2180,14 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx, static int vcr2_init_sequence(AVCodecContext *avctx) { Mpeg1Context *s1 = avctx->priv_data; - MpegEncContext *s = &s1->mpeg_enc_ctx; + MPVMainDecContext *const s = &s1->mpeg_ctx; int i, v, ret; /* start new MPEG-1 context decoding */ s->out_format = FMT_MPEG1; - if (s1->mpeg_enc_ctx_allocated) { + if (s1->mpeg_ctx_allocated) { ff_mpv_common_end(s); - s1->mpeg_enc_ctx_allocated = 0; + s1->mpeg_ctx_allocated = 0; } s->width = avctx->coded_width; s->height = avctx->coded_height; @@ -2199,7 +2200,7 @@ static int vcr2_init_sequence(AVCodecContext *avctx) ff_mpv_idct_init(s); if ((ret = ff_mpv_common_init(s)) < 0) return ret; - s1->mpeg_enc_ctx_allocated = 1; + s1->mpeg_ctx_allocated = 1; for (i = 0; i < 64; i++) { int j = s->idsp.idct_permutation[i]; @@ -2290,7 +2291,7 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx, cap[0] = cap[1] = cap[2] = 0x00; } else { field = (field == 2 ? 1 : 0); - if (!s1->mpeg_enc_ctx.top_field_first) field = !field; + if (!s1->mpeg_ctx.top_field_first) field = !field; cap[0] = 0x04 | field; cap[1] = ff_reverse[cc1]; cap[2] = ff_reverse[cc2]; @@ -2439,7 +2440,7 @@ static void mpeg_decode_gop(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { Mpeg1Context *s1 = avctx->priv_data; - MpegEncContext *s = &s1->mpeg_enc_ctx; + MPVMainDecContext *const s = &s1->mpeg_ctx; int broken_link; int64_t tc; @@ -2466,7 +2467,7 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture, int *got_output, const uint8_t *buf, int buf_size) { Mpeg1Context *s = avctx->priv_data; - MpegEncContext *s2 = &s->mpeg_enc_ctx; + MPVMainDecContext *const s2 = &s->mpeg_ctx; const uint8_t *buf_ptr = buf; const uint8_t *buf_end = buf + buf_size; int ret, input_size; @@ -2721,7 +2722,7 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture, break; } - if (!s->mpeg_enc_ctx_allocated) + if (!s->mpeg_ctx_allocated) break; if (s2->codec_id == AV_CODEC_ID_MPEG2VIDEO) { @@ -2757,7 +2758,7 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture, s2->slice_context_count; av_assert0(avctx->thread_count > 1); if (threshold <= mb_y) { - MpegEncContext *thread_context = s2->thread_context[s->slice_count]; + MPVDecContext *const thread_context = s2->thread_context[s->slice_count]; thread_context->start_mb_y = mb_y; thread_context->end_mb_y = s2->mb_height; @@ -2802,7 +2803,7 @@ static int mpeg_decode_frame(AVCodecContext *avctx, void *data, int buf_size = avpkt->size; Mpeg1Context *s = avctx->priv_data; AVFrame *picture = data; - MpegEncContext *s2 = &s->mpeg_enc_ctx; + MPVMainDecContext *const s2 = &s->mpeg_ctx; if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == SEQ_END_CODE)) { /* special case for last picture */ @@ -2830,7 +2831,7 @@ static int mpeg_decode_frame(AVCodecContext *avctx, void *data, #endif s2->codec_tag = ff_toupper4(avctx->codec_tag); - if (s->mpeg_enc_ctx_allocated == 0 && ( s2->codec_tag == AV_RL32("VCR2") + if (!s->mpeg_ctx_allocated && (s2->codec_tag == AV_RL32("VCR2") || s2->codec_tag == AV_RL32("BW10") )) vcr2_init_sequence(avctx); @@ -2889,8 +2890,8 @@ static av_cold int mpeg_decode_end(AVCodecContext *avctx) { Mpeg1Context *s = avctx->priv_data; - if (s->mpeg_enc_ctx_allocated) - ff_mpv_common_end(&s->mpeg_enc_ctx); + if (s->mpeg_ctx_allocated) + ff_mpv_common_end(&s->mpeg_ctx); av_buffer_unref(&s->a53_buf_ref); return 0; } @@ -3001,7 +3002,7 @@ const AVCodec ff_mpegvideo_decoder = { }; typedef struct IPUContext { - MpegEncContext m; + MPVMainDecContext m; int flags; DECLARE_ALIGNED(32, int16_t, block)[6][64]; @@ -3011,7 +3012,7 @@ static int ipu_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { IPUContext *s = avctx->priv_data; - MpegEncContext *m = &s->m; + MPVMainDecContext *const m = &s->m; GetBitContext *gb = &m->gb; AVFrame * const frame = data; int ret; @@ -3111,7 +3112,7 @@ static int ipu_decode_frame(AVCodecContext *avctx, void *data, static av_cold int ipu_decode_init(AVCodecContext *avctx) { IPUContext *s = avctx->priv_data; - MpegEncContext *m = &s->m; + MPVMainDecContext *const m = &s->m; avctx->pix_fmt = AV_PIX_FMT_YUV420P; diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index 7ffbfbca5b..34183cd1d5 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -64,7 +64,7 @@ static uint32_t mpeg1_lum_dc_uni[512]; static uint32_t mpeg1_chr_dc_uni[512]; typedef struct MPEG12EncContext { - MpegEncContext mpeg; + MPVMainEncContext mpeg; AVRational frame_rate_ext; unsigned frame_rate_index; @@ -122,7 +122,7 @@ av_cold void ff_mpeg1_init_uni_ac_vlc(const RLTable *rl, uint8_t *uni_ac_vlc_len #if CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER static int find_frame_rate_index(MPEG12EncContext *mpeg12) { - MpegEncContext *const s = &mpeg12->mpeg; + MPVMainEncContext *const s = &mpeg12->mpeg; int i; AVRational bestq = (AVRational) {0, 0}; AVRational ext; @@ -163,7 +163,7 @@ static int find_frame_rate_index(MPEG12EncContext *mpeg12) static av_cold int encode_init(AVCodecContext *avctx) { MPEG12EncContext *const mpeg12 = avctx->priv_data; - MpegEncContext *const s = &mpeg12->mpeg; + MPVMainEncContext *const s = &mpeg12->mpeg; int ret; int max_size = avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO ? 16383 : 4095; @@ -255,7 +255,7 @@ static av_cold int encode_init(AVCodecContext *avctx) return 0; } -static void put_header(MpegEncContext *s, int header) +static void put_header(MPVEncContext *s, int header) { align_put_bits(&s->pb); put_bits(&s->pb, 16, header >> 16); @@ -263,7 +263,7 @@ static void put_header(MpegEncContext *s, int header) } /* put sequence header if needed */ -static void mpeg1_encode_sequence_header(MpegEncContext *s) +static void mpeg1_encode_sequence_header(MPVMainEncContext *s) { MPEG12EncContext *const mpeg12 = (MPEG12EncContext*)s; unsigned int vbv_buffer_size, fps, v; @@ -422,7 +422,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s) put_bits(&s->pb, 1, 0); // broken link } -static inline void encode_mb_skip_run(MpegEncContext *s, int run) +static inline void encode_mb_skip_run(MPVEncContext *s, int run) { while (run >= 33) { put_bits(&s->pb, 11, 0x008); @@ -432,12 +432,12 @@ static inline void encode_mb_skip_run(MpegEncContext *s, int run) ff_mpeg12_mbAddrIncrTable[run][0]); } -static av_always_inline void put_qscale(MpegEncContext *s) +static av_always_inline void put_qscale(MPVEncContext *s) { put_bits(&s->pb, 5, s->qscale); } -void ff_mpeg1_encode_slice_header(MpegEncContext *s) +void ff_mpeg1_encode_slice_header(MPVEncContext *s) { if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO && s->height > 2800) { put_header(s, SLICE_MIN_START_CODE + (s->mb_y & 127)); @@ -451,7 +451,7 @@ void ff_mpeg1_encode_slice_header(MpegEncContext *s) put_bits(&s->pb, 1, 0); } -void ff_mpeg1_encode_picture_header(MpegEncContext *s, int picture_number) +void ff_mpeg1_encode_picture_header(MPVMainEncContext *s, int picture_number) { MPEG12EncContext *const mpeg12 = (MPEG12EncContext*)s; AVFrameSideData *side_data; @@ -611,7 +611,7 @@ void ff_mpeg1_encode_picture_header(MpegEncContext *s, int picture_number) ff_mpeg1_encode_slice_header(s); } -static inline void put_mb_modes(MpegEncContext *s, int n, int bits, +static inline void put_mb_modes(MPVEncContext *s, int n, int bits, int has_mv, int field_motion) { put_bits(&s->pb, n, bits); @@ -624,7 +624,7 @@ static inline void put_mb_modes(MpegEncContext *s, int n, int bits, } // RAL: Parameter added: f_or_b_code -static void mpeg1_encode_motion(MpegEncContext *s, int val, int f_or_b_code) +static void mpeg1_encode_motion(MPVEncContext *s, int val, int f_or_b_code) { if (val == 0) { /* zero vector, corresponds to ff_mpeg12_mbMotionVectorTable[0] */ @@ -661,7 +661,7 @@ static void mpeg1_encode_motion(MpegEncContext *s, int val, int f_or_b_code) } } -static inline void encode_dc(MpegEncContext *s, int diff, int component) +static inline void encode_dc(MPVEncContext *s, int diff, int component) { unsigned int diff_u = diff + 255; if (diff_u >= 511) { @@ -695,7 +695,7 @@ static inline void encode_dc(MpegEncContext *s, int diff, int component) } } -static void mpeg1_encode_block(MpegEncContext *s, int16_t *block, int n) +static void mpeg1_encode_block(MPVEncContext *s, int16_t *block, int n) { int alevel, level, last_non_zero, dc, diff, i, j, run, last_index, sign; int code, component; @@ -776,7 +776,7 @@ next_coef: put_bits(&s->pb, table_vlc[112][1], table_vlc[112][0]); } -static av_always_inline void mpeg1_encode_mb_internal(MpegEncContext *s, +static av_always_inline void mpeg1_encode_mb_internal(MPVEncContext *s, int16_t block[8][64], int motion_x, int motion_y, int mb_block_count, @@ -1057,7 +1057,7 @@ static av_always_inline void mpeg1_encode_mb_internal(MpegEncContext *s, } } -void ff_mpeg1_encode_mb(MpegEncContext *s, int16_t block[8][64], +void ff_mpeg1_encode_mb(MPVEncContext *s, int16_t block[8][64], int motion_x, int motion_y) { if (s->chroma_format == CHROMA_420) @@ -1131,7 +1131,7 @@ static av_cold void mpeg12_encode_init_static(void) fcode_tab[mv + MAX_MV] = f_code; } -av_cold void ff_mpeg1_encode_init(MpegEncContext *s) +av_cold void ff_mpeg1_encode_init(MPVMainEncContext *s) { static AVOnce init_static_once = AV_ONCE_INIT; diff --git a/libavcodec/mpeg12enc.h b/libavcodec/mpeg12enc.h index fbbc43f891..b034b1ae4e 100644 --- a/libavcodec/mpeg12enc.h +++ b/libavcodec/mpeg12enc.h @@ -24,15 +24,15 @@ #include -#include "mpegvideo.h" +#include "mpegvideoenc.h" #include "rl.h" void ff_mpeg1_init_uni_ac_vlc(const RLTable *rl, uint8_t *uni_ac_vlc_len); -void ff_mpeg1_encode_picture_header(MpegEncContext *s, int picture_number); -void ff_mpeg1_encode_mb(MpegEncContext *s, int16_t block[8][64], +void ff_mpeg1_encode_picture_header(MPVMainEncContext *m, int picture_number); +void ff_mpeg1_encode_mb(MPVEncContext *s, int16_t block[8][64], int motion_x, int motion_y); -void ff_mpeg1_encode_init(MpegEncContext *s); -void ff_mpeg1_encode_slice_header(MpegEncContext *s); +void ff_mpeg1_encode_init(MPVMainEncContext *m); +void ff_mpeg1_encode_slice_header(MPVEncContext *s); #endif /* AVCODEC_MPEG12ENC_H */ diff --git a/libavcodec/mpeg4video.c b/libavcodec/mpeg4video.c index ffeaf822b2..68be7e21ed 100644 --- a/libavcodec/mpeg4video.c +++ b/libavcodec/mpeg4video.c @@ -39,7 +39,7 @@ av_cold void ff_mpeg4_init_rl_intra(void) ff_thread_once(&init_static_once, mpeg4_init_rl_intra); } -int ff_mpeg4_get_video_packet_prefix_length(MpegEncContext *s) +int ff_mpeg4_get_video_packet_prefix_length(MPVContext *s) { switch (s->pict_type) { case AV_PICTURE_TYPE_I: @@ -54,7 +54,7 @@ int ff_mpeg4_get_video_packet_prefix_length(MpegEncContext *s) } } -void ff_mpeg4_clean_buffers(MpegEncContext *s) +void ff_mpeg4_clean_buffers(MPVContext *s) { int c_wrap, c_xy, l_wrap, l_xy; @@ -80,7 +80,7 @@ void ff_mpeg4_clean_buffers(MpegEncContext *s) #define tab_bias (tab_size / 2) // used by MPEG-4 and rv10 decoder -void ff_mpeg4_init_direct_mv(MpegEncContext *s) +void ff_mpeg4_init_direct_mv(MPVMainContext *s) { int i; for (i = 0; i < tab_size; i++) { @@ -90,7 +90,7 @@ void ff_mpeg4_init_direct_mv(MpegEncContext *s) } } -static inline void ff_mpeg4_set_one_direct_mv(MpegEncContext *s, int mx, +static inline void ff_mpeg4_set_one_direct_mv(MPVContext *s, int mx, int my, int i) { int xy = s->block_index[i]; @@ -126,7 +126,7 @@ static inline void ff_mpeg4_set_one_direct_mv(MpegEncContext *s, int mx, /** * @return the mb_type */ -int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my) +int ff_mpeg4_set_direct_mv(MPVContext *s, int mx, int my) { const int mb_index = s->mb_x + s->mb_y * s->mb_stride; const int colocated_mb_type = s->next_picture.mb_type[mb_index]; diff --git a/libavcodec/mpeg4video.h b/libavcodec/mpeg4video.h index ab65280756..4af66be5ad 100644 --- a/libavcodec/mpeg4video.h +++ b/libavcodec/mpeg4video.h @@ -69,14 +69,14 @@ /* smaller packets likely don't contain a real frame */ #define MAX_NVOP_SIZE 19 -void ff_mpeg4_clean_buffers(MpegEncContext *s); -int ff_mpeg4_get_video_packet_prefix_length(MpegEncContext *s); -void ff_mpeg4_init_direct_mv(MpegEncContext *s); +void ff_mpeg4_clean_buffers(MPVContext *s); +int ff_mpeg4_get_video_packet_prefix_length(MPVContext *s); +void ff_mpeg4_init_direct_mv(MPVMainContext *m); /** * @return the mb_type */ -int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my); +int ff_mpeg4_set_direct_mv(MPVContext *s, int mx, int my); #if 0 //3IV1 is quite rare and it slows things down a tiny bit #define IS_3IV1 s->codec_tag == AV_RL32("3IV1") @@ -91,7 +91,7 @@ int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my); * @param n block index (0-3 are luma, 4-5 are chroma) * @param dir_ptr pointer to an integer where the prediction direction will be stored */ -static inline int ff_mpeg4_pred_dc(MpegEncContext *s, int n, int level, +static inline int ff_mpeg4_pred_dc(MPVContext *s, int n, int level, int *dir_ptr, int encoding) { int a, b, c, wrap, pred, scale, ret; diff --git a/libavcodec/mpeg4video_parser.c b/libavcodec/mpeg4video_parser.c index 3d0d0e4714..81e5376a28 100644 --- a/libavcodec/mpeg4video_parser.c +++ b/libavcodec/mpeg4video_parser.c @@ -24,7 +24,7 @@ #include "internal.h" #include "parser.h" -#include "mpegvideo.h" +#include "mpegvideodec.h" #include "mpeg4video.h" #include "mpeg4videodec.h" #if FF_API_FLAG_TRUNCATED @@ -92,7 +92,7 @@ static int mpeg4_decode_header(AVCodecParserContext *s1, AVCodecContext *avctx, { struct Mp4vParseContext *pc = s1->priv_data; Mpeg4DecContext *dec_ctx = &pc->dec_ctx; - MpegEncContext *s = &dec_ctx->m; + MPVDecContext *const s = &dec_ctx->m; GetBitContext gb1, *gb = &gb1; int ret; diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 6d7f7f66f9..63fc3fa8fc 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -70,7 +70,7 @@ static const int mb_type_b_map[4] = { MB_TYPE_L0 | MB_TYPE_16x16, }; -void ff_mpeg4_decode_studio(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, +void ff_mpeg4_decode_studio(MPVContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int block_size, int uvlinesize, int dct_linesize, int dct_offset) { @@ -138,7 +138,7 @@ void ff_mpeg4_decode_studio(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb * @param n block index (0-3 are luma, 4-5 are chroma) * @param dir the ac prediction direction */ -void ff_mpeg4_pred_ac(MpegEncContext *s, int16_t *block, int n, int dir) +void ff_mpeg4_pred_ac(MPVDecContext *s, int16_t *block, int n, int dir) { int i; int16_t *ac_val, *ac_val1; @@ -195,7 +195,7 @@ void ff_mpeg4_pred_ac(MpegEncContext *s, int16_t *block, int n, int dir) */ static inline int mpeg4_is_resync(Mpeg4DecContext *ctx) { - MpegEncContext *s = &ctx->m; + MPVDecContext *const s = &ctx->m; int bits_count = get_bits_count(&s->gb); int v = show_bits(&s->gb, 16); @@ -245,7 +245,7 @@ static inline int mpeg4_is_resync(Mpeg4DecContext *ctx) static int mpeg4_decode_sprite_trajectory(Mpeg4DecContext *ctx, GetBitContext *gb) { - MpegEncContext *s = &ctx->m; + MPVDecContext *const s = &ctx->m; int a = 2 << s->sprite_warping_accuracy; int rho = 3 - s->sprite_warping_accuracy; int r = 16 / a; @@ -497,7 +497,7 @@ overflow: } static int decode_new_pred(Mpeg4DecContext *ctx, GetBitContext *gb) { - MpegEncContext *s = &ctx->m; + MPVDecContext *const s = &ctx->m; int len = FFMIN(ctx->time_increment_bits + 3, 15); get_bits(gb, len); @@ -514,7 +514,7 @@ static int decode_new_pred(Mpeg4DecContext *ctx, GetBitContext *gb) { */ int ff_mpeg4_decode_video_packet_header(Mpeg4DecContext *ctx) { - MpegEncContext *s = &ctx->m; + MPVDecContext *const s = &ctx->m; int mb_num_bits = av_log2(s->mb_num - 1) + 1; int header_extension = 0, mb_num, len; @@ -601,7 +601,7 @@ int ff_mpeg4_decode_video_packet_header(Mpeg4DecContext *ctx) return 0; } -static void reset_studio_dc_predictors(MpegEncContext *s) +static void reset_studio_dc_predictors(MPVDecContext *s) { /* Reset DC Predictors */ s->last_dc[0] = @@ -615,7 +615,7 @@ static void reset_studio_dc_predictors(MpegEncContext *s) */ int ff_mpeg4_decode_studio_slice_header(Mpeg4DecContext *ctx) { - MpegEncContext *s = &ctx->m; + MPVDecContext *const s = &ctx->m; GetBitContext *gb = &s->gb; unsigned vlc_len; uint16_t mb_num; @@ -657,7 +657,7 @@ int ff_mpeg4_decode_studio_slice_header(Mpeg4DecContext *ctx) */ static inline int get_amv(Mpeg4DecContext *ctx, int n) { - MpegEncContext *s = &ctx->m; + MPVDecContext *const s = &ctx->m; int x, y, mb_v, sum, dx, dy, shift; int len = 1 << (s->f_code + 4); const int a = s->sprite_warping_accuracy; @@ -708,7 +708,7 @@ static inline int get_amv(Mpeg4DecContext *ctx, int n) * @param dir_ptr the prediction direction will be stored here * @return the quantized dc */ -static inline int mpeg4_decode_dc(MpegEncContext *s, int n, int *dir_ptr) +static inline int mpeg4_decode_dc(MPVDecContext *s, int n, int *dir_ptr) { int level, code; @@ -757,7 +757,7 @@ static inline int mpeg4_decode_dc(MpegEncContext *s, int n, int *dir_ptr) */ static int mpeg4_decode_partition_a(Mpeg4DecContext *ctx) { - MpegEncContext *s = &ctx->m; + MPVDecContext *const s = &ctx->m; int mb_num = 0; static const int8_t quant_tab[4] = { -1, -2, 1, 2 }; @@ -949,7 +949,7 @@ try_again: * decode second partition. * @return <0 if an error occurred */ -static int mpeg4_decode_partition_b(MpegEncContext *s, int mb_count) +static int mpeg4_decode_partition_b(MPVDecContext *s, int mb_count) { int mb_num = 0; static const int8_t quant_tab[4] = { -1, -2, 1, 2 }; @@ -1044,7 +1044,7 @@ static int mpeg4_decode_partition_b(MpegEncContext *s, int mb_count) */ int ff_mpeg4_decode_partitions(Mpeg4DecContext *ctx) { - MpegEncContext *s = &ctx->m; + MPVDecContext *const s = &ctx->m; int mb_num; int ret; const int part_a_error = s->pict_type == AV_PICTURE_TYPE_I ? (ER_DC_ERROR | ER_MV_ERROR) : ER_MV_ERROR; @@ -1111,7 +1111,7 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block, int n, int coded, int intra, int use_intra_dc_vlc, int rvlc) { - MpegEncContext *s = &ctx->m; + MPVDecContext *const s = &ctx->m; int level, i, last, run, qmul, qadd; int av_uninit(dc_pred_dir); RLTable *rl; @@ -1379,7 +1379,7 @@ not_coded: * decode partition C of one MB. * @return <0 if an error occurred */ -static int mpeg4_decode_partitioned_mb(MpegEncContext *s, int16_t block[6][64]) +static int mpeg4_decode_partitioned_mb(MPVDecContext *s, int16_t block[6][64]) { Mpeg4DecContext *ctx = s->avctx->priv_data; int cbp, mb_type, use_intra_dc_vlc; @@ -1467,7 +1467,7 @@ static int mpeg4_decode_partitioned_mb(MpegEncContext *s, int16_t block[6][64]) } } -static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64]) +static int mpeg4_decode_mb(MPVDecContext *s, int16_t block[6][64]) { Mpeg4DecContext *ctx = s->avctx->priv_data; int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant; @@ -1887,7 +1887,7 @@ static const uint8_t ac_state_tab[22][2] = {0, 11} }; -static int mpeg4_decode_studio_block(MpegEncContext *s, int32_t block[64], int n) +static int mpeg4_decode_studio_block(MPVDecContext *s, int32_t block[64], int n) { Mpeg4DecContext *ctx = s->avctx->priv_data; @@ -2002,7 +2002,7 @@ static int mpeg4_decode_studio_block(MpegEncContext *s, int32_t block[64], int n return 0; } -static int mpeg4_decode_dpcm_macroblock(MpegEncContext *s, int16_t macroblock[256], int n) +static int mpeg4_decode_dpcm_macroblock(MPVDecContext *s, int16_t macroblock[256], int n) { int i, j, w, h, idx = 0; int block_mean, rice_parameter, rice_prefix_code, rice_suffix_code, @@ -2085,7 +2085,7 @@ static int mpeg4_decode_dpcm_macroblock(MpegEncContext *s, int16_t macroblock[25 return 0; } -static int mpeg4_decode_studio_mb(MpegEncContext *s, int16_t block_[12][64]) +static int mpeg4_decode_studio_mb(MPVDecContext *s, int16_t block_[12][64]) { Mpeg4DecContext *const ctx = (Mpeg4DecContext*)s; int i; @@ -2133,7 +2133,7 @@ static int mpeg4_decode_studio_mb(MpegEncContext *s, int16_t block_[12][64]) return SLICE_OK; } -static int mpeg4_decode_gop_header(MpegEncContext *s, GetBitContext *gb) +static int mpeg4_decode_gop_header(MPVMainDecContext *s, GetBitContext *gb) { int hours, minutes, seconds; @@ -2155,7 +2155,7 @@ static int mpeg4_decode_gop_header(MpegEncContext *s, GetBitContext *gb) return 0; } -static int mpeg4_decode_profile_level(MpegEncContext *s, GetBitContext *gb, int *profile, int *level) +static int mpeg4_decode_profile_level(GetBitContext *gb, int *profile, int *level) { *profile = get_bits(gb, 4); @@ -2169,7 +2169,7 @@ static int mpeg4_decode_profile_level(MpegEncContext *s, GetBitContext *gb, int return 0; } -static int mpeg4_decode_visual_object(MpegEncContext *s, GetBitContext *gb) +static int mpeg4_decode_visual_object(MPVMainDecContext *s, GetBitContext *gb) { int visual_object_type; int is_visual_object_identifier = get_bits1(gb); @@ -2201,7 +2201,7 @@ static int mpeg4_decode_visual_object(MpegEncContext *s, GetBitContext *gb) return 0; } -static void mpeg4_load_default_matrices(MpegEncContext *s) +static void mpeg4_load_default_matrices(MPVDecContext *s) { int i, v; @@ -2218,7 +2218,7 @@ static void mpeg4_load_default_matrices(MpegEncContext *s) } } -static int read_quant_matrix_ext(MpegEncContext *s, GetBitContext *gb) +static int read_quant_matrix_ext(MPVDecContext *s, GetBitContext *gb) { int i, j, v; @@ -2267,7 +2267,7 @@ static int read_quant_matrix_ext(MpegEncContext *s, GetBitContext *gb) return 0; } -static void extension_and_user_data(MpegEncContext *s, GetBitContext *gb, int id) +static void extension_and_user_data(MPVDecContext *s, GetBitContext *gb, int id) { uint32_t startcode; uint8_t extension_type; @@ -2286,7 +2286,7 @@ static void extension_and_user_data(MpegEncContext *s, GetBitContext *gb, int id static int decode_studio_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) { - MpegEncContext *s = &ctx->m; + MPVMainDecContext *const s = &ctx->m; int width, height, aspect_ratio_info; int bits_per_raw_sample; int rgb, chroma_format; @@ -2372,7 +2372,7 @@ static int decode_studio_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) { - MpegEncContext *s = &ctx->m; + MPVMainDecContext *const s = &ctx->m; int width, height, vo_ver_id, aspect_ratio_info; /* vol header */ @@ -2747,7 +2747,7 @@ no_cplx_est: */ static int decode_user_data(Mpeg4DecContext *ctx, GetBitContext *gb) { - MpegEncContext *s = &ctx->m; + MPVDecContext *const s = &ctx->m; char buf[256]; int i; int e; @@ -2805,7 +2805,7 @@ static int decode_user_data(Mpeg4DecContext *ctx, GetBitContext *gb) int ff_mpeg4_workaround_bugs(AVCodecContext *avctx) { Mpeg4DecContext *ctx = avctx->priv_data; - MpegEncContext *s = &ctx->m; + MPVMainDecContext *const s = &ctx->m; if (ctx->xvid_build == -1 && ctx->divx_version == -1 && ctx->lavc_build == -1) { if (s->codec_tag == AV_RL32("XVID") || @@ -2923,7 +2923,7 @@ int ff_mpeg4_workaround_bugs(AVCodecContext *avctx) static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb, int parse_only) { - MpegEncContext *s = &ctx->m; + MPVMainDecContext *const s = &ctx->m; int time_incr, time_increment; int64_t pts; @@ -3205,7 +3205,7 @@ end: static void decode_smpte_tc(Mpeg4DecContext *ctx, GetBitContext *gb) { - MpegEncContext *s = &ctx->m; + MPVDecContext *const s = &ctx->m; skip_bits(gb, 16); /* Time_code[63..48] */ check_marker(s->avctx, gb, "after Time_code[63..48]"); @@ -3224,7 +3224,7 @@ static void decode_smpte_tc(Mpeg4DecContext *ctx, GetBitContext *gb) */ static int decode_studio_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb) { - MpegEncContext *s = &ctx->m; + MPVMainDecContext *const s = &ctx->m; if (get_bits_left(gb) <= 32) return 0; @@ -3279,7 +3279,7 @@ static int decode_studio_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb) static int decode_studiovisualobject(Mpeg4DecContext *ctx, GetBitContext *gb) { - MpegEncContext *s = &ctx->m; + MPVDecContext *const s = &ctx->m; int visual_object_type; skip_bits(gb, 4); /* visual_object_verid */ @@ -3308,7 +3308,7 @@ static int decode_studiovisualobject(Mpeg4DecContext *ctx, GetBitContext *gb) int ff_mpeg4_decode_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb, int header, int parse_only) { - MpegEncContext *s = &ctx->m; + MPVMainDecContext *const s = &ctx->m; unsigned startcode, v; int ret; int vol = 0; @@ -3422,7 +3422,7 @@ int ff_mpeg4_decode_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb, mpeg4_decode_gop_header(s, gb); } else if (startcode == VOS_STARTCODE) { int profile, level; - mpeg4_decode_profile_level(s, gb, &profile, &level); + mpeg4_decode_profile_level(gb, &profile, &level); if (profile == FF_PROFILE_MPEG4_SIMPLE_STUDIO && (level > 0 && level < 9)) { s->studio_profile = 1; @@ -3466,7 +3466,7 @@ end: int ff_mpeg4_frame_end(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { Mpeg4DecContext *ctx = avctx->priv_data; - MpegEncContext *s = &ctx->m; + MPVMainDecContext *const s = &ctx->m; /* divx 5.01+ bitstream reorder stuff */ /* Since this clobbers the input buffer and hwaccel codecs still need the @@ -3562,8 +3562,8 @@ static int mpeg4_update_thread_context(AVCodecContext *dst, static int mpeg4_update_thread_context_for_user(AVCodecContext *dst, const AVCodecContext *src) { - MpegEncContext *m = dst->priv_data; - const MpegEncContext *m1 = src->priv_data; + MPVMainDecContext *const m = dst->priv_data; + const MPVMainDecContext *const m1 = src->priv_data; m->quarter_sample = m1->quarter_sample; m->divx_packed = m1->divx_packed; @@ -3623,7 +3623,7 @@ static av_cold int decode_init(AVCodecContext *avctx) { static AVOnce init_static_once = AV_ONCE_INIT; Mpeg4DecContext *ctx = avctx->priv_data; - MpegEncContext *s = &ctx->m; + MPVMainDecContext *const s = &ctx->m; int ret; ctx->divx_version = @@ -3646,7 +3646,7 @@ static av_cold int decode_init(AVCodecContext *avctx) return 0; } -#define OFFSET(x) offsetof(MpegEncContext, x) +#define OFFSET(x) offsetof(MPVMainDecContext, x) #define FLAGS AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY static const AVOption mpeg4_options[] = { {"quarter_sample", "1/4 subpel MC", OFFSET(quarter_sample), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS}, diff --git a/libavcodec/mpeg4videodec.h b/libavcodec/mpeg4videodec.h index 65d846aed0..191fe53836 100644 --- a/libavcodec/mpeg4videodec.h +++ b/libavcodec/mpeg4videodec.h @@ -26,11 +26,11 @@ #include #include "get_bits.h" -#include "mpegvideo.h" +#include "mpegvideodec.h" typedef struct Mpeg4DecContext { - MpegEncContext m; + MPVMainDecContext m; /// number of bits to represent the fractional part of time int time_increment_bits; @@ -84,14 +84,14 @@ typedef struct Mpeg4DecContext { int ff_mpeg4_decode_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb, int header, int parse_only); -void ff_mpeg4_decode_studio(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, +void ff_mpeg4_decode_studio(MPVContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int block_size, int uvlinesize, int dct_linesize, int dct_offset); int ff_mpeg4_decode_partitions(Mpeg4DecContext *ctx); int ff_mpeg4_decode_video_packet_header(Mpeg4DecContext *ctx); int ff_mpeg4_decode_studio_slice_header(Mpeg4DecContext *ctx); int ff_mpeg4_workaround_bugs(AVCodecContext *avctx); -void ff_mpeg4_pred_ac(MpegEncContext *s, int16_t *block, int n, +void ff_mpeg4_pred_ac(MPVDecContext *s, int16_t *block, int n, int dir); int ff_mpeg4_frame_end(AVCodecContext *avctx, const uint8_t *buf, int buf_size); diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index 1f67fafe34..03d53ab56b 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -67,7 +67,7 @@ static uint8_t uni_mpeg4_inter_rl_len[64 * 64 * 2 * 2]; * Return the number of bits that encoding the 8x8 block in block would need. * @param[in] block_last_index last index in scantable order that refers to a non zero element in block. */ -static inline int get_block_rate(MpegEncContext *s, int16_t block[64], +static inline int get_block_rate(MPVEncContext *s, int16_t block[64], int block_last_index, uint8_t scantable[64]) { int last = 0; @@ -102,7 +102,7 @@ static inline int get_block_rate(MpegEncContext *s, int16_t block[64], * @param[out] st scantable for each 8x8 block * @param[in] zigzag_last_index index referring to the last non zero coefficient in zigzag order */ -static inline void restore_ac_coeffs(MpegEncContext *s, int16_t block[6][64], +static inline void restore_ac_coeffs(MPVEncContext *s, int16_t block[6][64], const int dir[6], uint8_t *st[6], const int zigzag_last_index[6]) { @@ -133,7 +133,7 @@ static inline void restore_ac_coeffs(MpegEncContext *s, int16_t block[6][64], * @param[out] st scantable for each 8x8 block * @param[out] zigzag_last_index index referring to the last non zero coefficient in zigzag order */ -static inline int decide_ac_pred(MpegEncContext *s, int16_t block[6][64], +static inline int decide_ac_pred(MPVEncContext *s, int16_t block[6][64], const int dir[6], uint8_t *st[6], int zigzag_last_index[6]) { @@ -216,7 +216,7 @@ static inline int decide_ac_pred(MpegEncContext *s, int16_t block[6][64], /** * modify mb_type & qscale so that encoding is actually possible in MPEG-4 */ -void ff_clean_mpeg4_qscales(MpegEncContext *s) +void ff_clean_mpeg4_qscales(MPVMainEncContext *s) { int i; int8_t *const qscale_table = s->current_picture.qscale_table; @@ -285,7 +285,7 @@ static inline int mpeg4_get_dc_length(int level, int n) * Encode an 8x8 block. * @param n block index (0-3 are luma, 4-5 are chroma) */ -static inline void mpeg4_encode_block(MpegEncContext *s, +static inline void mpeg4_encode_block(MPVEncContext *s, int16_t *block, int n, int intra_dc, uint8_t *scan_table, PutBitContext *dc_pb, PutBitContext *ac_pb) @@ -346,7 +346,7 @@ static inline void mpeg4_encode_block(MpegEncContext *s, } } -static int mpeg4_get_block_length(MpegEncContext *s, +static int mpeg4_get_block_length(MPVEncContext *s, int16_t *block, int n, int intra_dc, uint8_t *scan_table) { @@ -400,7 +400,7 @@ static int mpeg4_get_block_length(MpegEncContext *s, return len; } -static inline void mpeg4_encode_blocks(MpegEncContext *s, int16_t block[6][64], +static inline void mpeg4_encode_blocks(MPVEncContext *s, int16_t block[6][64], int intra_dc[6], uint8_t **scan_table, PutBitContext *dc_pb, PutBitContext *ac_pb) @@ -434,7 +434,7 @@ static inline void mpeg4_encode_blocks(MpegEncContext *s, int16_t block[6][64], } } -static inline int get_b_cbp(MpegEncContext *s, int16_t block[6][64], +static inline int get_b_cbp(MPVEncContext *s, int16_t block[6][64], int motion_x, int motion_y, int mb_type) { int cbp = 0, i; @@ -478,7 +478,7 @@ static inline int get_b_cbp(MpegEncContext *s, int16_t block[6][64], // FIXME this is duplicated to h263.c static const int dquant_code[5] = { 1, 0, 9, 2, 3 }; -void ff_mpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64], +void ff_mpeg4_encode_mb(MPVEncContext *s, int16_t block[6][64], int motion_x, int motion_y) { int cbpc, cbpy, pred_x, pred_y; @@ -876,7 +876,7 @@ void ff_mpeg4_stuffing(PutBitContext *pbc) } /* must be called before writing the header */ -void ff_set_mpeg4_time(MpegEncContext *s) +void ff_set_mpeg4_time(MPVMainEncContext *s) { if (s->pict_type == AV_PICTURE_TYPE_B) { ff_mpeg4_init_direct_mv(s); @@ -886,7 +886,7 @@ void ff_set_mpeg4_time(MpegEncContext *s) } } -static void mpeg4_encode_gop_header(MpegEncContext *s) +static void mpeg4_encode_gop_header(MPVMainEncContext *s) { int64_t hours, minutes, seconds; int64_t time; @@ -916,7 +916,7 @@ static void mpeg4_encode_gop_header(MpegEncContext *s) ff_mpeg4_stuffing(&s->pb); } -static void mpeg4_encode_visual_object_header(MpegEncContext *s) +static void mpeg4_encode_visual_object_header(MPVMainEncContext *s) { int profile_and_level_indication; int vo_ver_id; @@ -960,7 +960,7 @@ static void mpeg4_encode_visual_object_header(MpegEncContext *s) ff_mpeg4_stuffing(&s->pb); } -static void mpeg4_encode_vol_header(MpegEncContext *s, +static void mpeg4_encode_vol_header(MPVMainEncContext *s, int vo_number, int vol_number) { @@ -1061,7 +1061,7 @@ static void mpeg4_encode_vol_header(MpegEncContext *s, } /* write MPEG-4 VOP header */ -int ff_mpeg4_encode_picture_header(MpegEncContext *s, int picture_number) +int ff_mpeg4_encode_picture_header(MPVMainEncContext *s, int picture_number) { uint64_t time_incr; int64_t time_div, time_mod; @@ -1284,7 +1284,7 @@ static av_cold void mpeg4_encode_init_static(void) static av_cold int encode_init(AVCodecContext *avctx) { static AVOnce init_static_once = AV_ONCE_INIT; - MpegEncContext *s = avctx->priv_data; + MPVMainEncContext *const s = avctx->priv_data; int ret; if (avctx->width >= (1<<13) || avctx->height >= (1<<13)) { @@ -1325,7 +1325,7 @@ static av_cold int encode_init(AVCodecContext *avctx) return 0; } -void ff_mpeg4_init_partitions(MpegEncContext *s) +void ff_mpeg4_init_partitions(MPVEncContext *s) { uint8_t *start = put_bits_ptr(&s->pb); uint8_t *end = s->pb.buf_end; @@ -1338,7 +1338,7 @@ void ff_mpeg4_init_partitions(MpegEncContext *s) init_put_bits(&s->pb2, start + pb_size + tex_size, pb_size); } -void ff_mpeg4_merge_partitions(MpegEncContext *s) +void ff_mpeg4_merge_partitions(MPVEncContext *s) { const int pb2_len = put_bits_count(&s->pb2); const int tex_pb_len = put_bits_count(&s->tex_pb); @@ -1364,7 +1364,7 @@ void ff_mpeg4_merge_partitions(MpegEncContext *s) s->last_bits = put_bits_count(&s->pb); } -void ff_mpeg4_encode_video_packet_header(MpegEncContext *s) +void ff_mpeg4_encode_video_packet_header(MPVEncContext *s) { int mb_num_bits = av_log2(s->mb_num - 1) + 1; @@ -1376,7 +1376,7 @@ void ff_mpeg4_encode_video_packet_header(MpegEncContext *s) put_bits(&s->pb, 1, 0); /* no HEC */ } -#define OFFSET(x) offsetof(MpegEncContext, x) +#define OFFSET(x) offsetof(MPVMainEncContext, x) #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { { "data_partitioning", "Use data partitioning.", OFFSET(data_partitioning), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, @@ -1405,7 +1405,7 @@ const AVCodec ff_mpeg4_encoder = { .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_MPEG4, - .priv_data_size = sizeof(MpegEncContext), + .priv_data_size = sizeof(MPVMainEncContext), .init = encode_init, .encode2 = ff_mpv_encode_picture, .close = ff_mpv_encode_end, diff --git a/libavcodec/mpeg4videoenc.h b/libavcodec/mpeg4videoenc.h index 243cd297a2..6c2d7b37c5 100644 --- a/libavcodec/mpeg4videoenc.h +++ b/libavcodec/mpeg4videoenc.h @@ -25,19 +25,19 @@ #include -#include "mpegvideo.h" +#include "mpegvideoenc.h" #include "put_bits.h" -void ff_mpeg4_encode_mb(MpegEncContext *s, +void ff_mpeg4_encode_mb(MPVEncContext *s, int16_t block[6][64], int motion_x, int motion_y); -void ff_set_mpeg4_time(MpegEncContext *s); -int ff_mpeg4_encode_picture_header(MpegEncContext *s, int picture_number); +void ff_set_mpeg4_time(MPVMainEncContext *m); +int ff_mpeg4_encode_picture_header(MPVMainEncContext *m, int picture_number); -void ff_mpeg4_encode_video_packet_header(MpegEncContext *s); +void ff_mpeg4_encode_video_packet_header(MPVEncContext *s); void ff_mpeg4_stuffing(PutBitContext *pbc); -void ff_mpeg4_init_partitions(MpegEncContext *s); -void ff_mpeg4_merge_partitions(MpegEncContext *s); -void ff_clean_mpeg4_qscales(MpegEncContext *s); +void ff_mpeg4_init_partitions(MPVEncContext *s); +void ff_mpeg4_merge_partitions(MPVEncContext *s); +void ff_clean_mpeg4_qscales(MPVMainEncContext *m); #endif diff --git a/libavcodec/mpeg_er.c b/libavcodec/mpeg_er.c index f54cb8548b..d2968b448b 100644 --- a/libavcodec/mpeg_er.c +++ b/libavcodec/mpeg_er.c @@ -17,7 +17,7 @@ */ #include "error_resilience.h" -#include "mpegvideo.h" +#include "mpegvideodec.h" #include "mpeg_er.h" static void set_erpic(ERPicture *dst, Picture *src) @@ -43,7 +43,7 @@ static void set_erpic(ERPicture *dst, Picture *src) dst->field_picture = src->field_picture; } -void ff_mpeg_er_frame_start(MpegEncContext *s) +void ff_mpeg_er_frame_start(MPVMainDecContext *s) { ERContext *er = &s->er; @@ -63,7 +63,7 @@ static void mpeg_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type, int (*mv)[2][4][2], int mb_x, int mb_y, int mb_intra, int mb_skipped) { - MpegEncContext *s = opaque; + MPVDecContext *const s = opaque; s->mv_dir = mv_dir; s->mv_type = mv_type; @@ -97,7 +97,7 @@ static void mpeg_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type, ff_mpv_reconstruct_mb(s, s->block); } -int ff_mpeg_er_init(MpegEncContext *s) +int ff_mpeg_er_init(MPVDecContext *s) { ERContext *er = &s->er; int mb_array_size = s->mb_height * s->mb_stride; diff --git a/libavcodec/mpeg_er.h b/libavcodec/mpeg_er.h index bb627a4d06..9919570795 100644 --- a/libavcodec/mpeg_er.h +++ b/libavcodec/mpeg_er.h @@ -19,9 +19,9 @@ #ifndef AVCODEC_MPEG_ER_H #define AVCODEC_MPEG_ER_H -#include "mpegvideo.h" +#include "mpegvideodec.h" -int ff_mpeg_er_init(MpegEncContext *s); -void ff_mpeg_er_frame_start(MpegEncContext *s); +int ff_mpeg_er_init(MPVDecContext *s); +void ff_mpeg_er_frame_start(MPVMainDecContext *m); #endif /* AVCODEC_MPEG_ER_H */ diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index c39cf12c40..88cd9bc6ed 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -47,7 +47,7 @@ #include "wmv2dec.h" #include -static void dct_unquantize_mpeg1_intra_c(MpegEncContext *s, +static void dct_unquantize_mpeg1_intra_c(MPVContext *s, int16_t *block, int n, int qscale) { int i, level, nCoeffs; @@ -76,7 +76,7 @@ static void dct_unquantize_mpeg1_intra_c(MpegEncContext *s, } } -static void dct_unquantize_mpeg1_inter_c(MpegEncContext *s, +static void dct_unquantize_mpeg1_inter_c(MPVContext *s, int16_t *block, int n, int qscale) { int i, level, nCoeffs; @@ -105,7 +105,7 @@ static void dct_unquantize_mpeg1_inter_c(MpegEncContext *s, } } -static void dct_unquantize_mpeg2_intra_c(MpegEncContext *s, +static void dct_unquantize_mpeg2_intra_c(MPVContext *s, int16_t *block, int n, int qscale) { int i, level, nCoeffs; @@ -135,7 +135,7 @@ static void dct_unquantize_mpeg2_intra_c(MpegEncContext *s, } } -static void dct_unquantize_mpeg2_intra_bitexact(MpegEncContext *s, +static void dct_unquantize_mpeg2_intra_bitexact(MPVContext *s, int16_t *block, int n, int qscale) { int i, level, nCoeffs; @@ -169,7 +169,7 @@ static void dct_unquantize_mpeg2_intra_bitexact(MpegEncContext *s, block[63]^=sum&1; } -static void dct_unquantize_mpeg2_inter_c(MpegEncContext *s, +static void dct_unquantize_mpeg2_inter_c(MPVContext *s, int16_t *block, int n, int qscale) { int i, level, nCoeffs; @@ -203,7 +203,7 @@ static void dct_unquantize_mpeg2_inter_c(MpegEncContext *s, block[63]^=sum&1; } -static void dct_unquantize_h263_intra_c(MpegEncContext *s, +static void dct_unquantize_h263_intra_c(MPVContext *s, int16_t *block, int n, int qscale) { int i, level, qmul, qadd; @@ -237,7 +237,7 @@ static void dct_unquantize_h263_intra_c(MpegEncContext *s, } } -static void dct_unquantize_h263_inter_c(MpegEncContext *s, +static void dct_unquantize_h263_inter_c(MPVContext *s, int16_t *block, int n, int qscale) { int i, level, qmul, qadd; @@ -277,7 +277,7 @@ static void gray8(uint8_t *dst, const uint8_t *src, ptrdiff_t linesize, int h) } /* init common dct for both encoder and decoder */ -static av_cold int dct_init(MpegEncContext *s) +static av_cold int dct_init(MPVMainContext *s) { ff_blockdsp_init(&s->bdsp, s->avctx); ff_h264chroma_init(&s->h264chroma, 8); //for lowres @@ -324,7 +324,7 @@ static av_cold int dct_init(MpegEncContext *s) return 0; } -av_cold void ff_mpv_idct_init(MpegEncContext *s) +av_cold void ff_mpv_idct_init(MPVContext *s) { if (s->codec_id == AV_CODEC_ID_MPEG4) s->idsp.mpeg4_studio_profile = s->studio_profile; @@ -344,7 +344,7 @@ av_cold void ff_mpv_idct_init(MpegEncContext *s) ff_init_scantable(s->idsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan); } -static int init_duplicate_context(MpegEncContext *s) +static int init_duplicate_context(MPVContext *s) { int y_size = s->b8_stride * (2 * s->mb_height + 1); int c_size = s->mb_stride * (s->mb_height + 1); @@ -389,7 +389,7 @@ static int init_duplicate_context(MpegEncContext *s) return 0; } -int ff_mpv_init_duplicate_contexts(MpegEncContext *s) +int ff_mpv_init_duplicate_contexts(MPVMainContext *s) { int nb_slices = s->slice_context_count, ret; @@ -397,7 +397,7 @@ int ff_mpv_init_duplicate_contexts(MpegEncContext *s) * fields allocated in init_duplicate_context are NULL after * copying. This prevents double-frees upon allocation error. */ for (int i = 1; i < nb_slices; i++) { - s->thread_context[i] = av_memdup(s, sizeof(MpegEncContext)); + s->thread_context[i] = av_memdup(s, sizeof(MPVContext)); if (!s->thread_context[i]) return AVERROR(ENOMEM); if ((ret = init_duplicate_context(s->thread_context[i])) < 0) @@ -413,7 +413,7 @@ int ff_mpv_init_duplicate_contexts(MpegEncContext *s) return init_duplicate_context(s); } -static void free_duplicate_context(MpegEncContext *s) +static void free_duplicate_context(MPVContext *s) { if (!s) return; @@ -433,7 +433,7 @@ static void free_duplicate_context(MpegEncContext *s) s->block = NULL; } -static void free_duplicate_contexts(MpegEncContext *s) +static void free_duplicate_contexts(MPVMainContext *s) { for (int i = 1; i < s->slice_context_count; i++) { free_duplicate_context(s->thread_context[i]); @@ -442,7 +442,7 @@ static void free_duplicate_contexts(MpegEncContext *s) free_duplicate_context(s); } -static void backup_duplicate_context(MpegEncContext *bak, MpegEncContext *src) +static void backup_duplicate_context(MPVContext *bak, MPVContext *src) { #define COPY(a) bak->a = src->a COPY(sc.edge_emu_buffer); @@ -469,13 +469,13 @@ static void backup_duplicate_context(MpegEncContext *bak, MpegEncContext *src) #undef COPY } -int ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src) +int ff_update_duplicate_context(MPVContext *dst, MPVContext *src) { - MpegEncContext bak; + MPVContext bak; int i, ret; // FIXME copy only needed parts backup_duplicate_context(&bak, dst); - memcpy(dst, src, sizeof(MpegEncContext)); + memcpy(dst, src, sizeof(*dst)); backup_duplicate_context(dst, &bak); for (i = 0; i < 12; i++) { dst->pblocks[i] = &dst->block[i]; @@ -495,12 +495,12 @@ int ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src) } /** - * Set the given MpegEncContext to common defaults + * Set the given MPVMainContext to common defaults * (same for encoding and decoding). * The changed fields will not depend upon the - * prior state of the MpegEncContext. + * prior state of the MPVMainContext. */ -void ff_mpv_common_defaults(MpegEncContext *s) +void ff_mpv_common_defaults(MPVMainContext *s) { s->y_dc_scale_table = s->c_dc_scale_table = ff_mpeg1_dc_scale_table; @@ -518,7 +518,7 @@ void ff_mpv_common_defaults(MpegEncContext *s) s->slice_context_count = 1; } -int ff_mpv_init_context_frame(MpegEncContext *s) +int ff_mpv_init_context_frame(MPVMainContext *s) { int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y; @@ -652,7 +652,7 @@ int ff_mpv_init_context_frame(MpegEncContext *s) return !CONFIG_MPEGVIDEODEC || s->encoding ? 0 : ff_mpeg_er_init(s); } -static void clear_context(MpegEncContext *s) +static void clear_context(MPVMainContext *s) { int i, j, k; @@ -731,7 +731,7 @@ static void clear_context(MpegEncContext *s) * init common structure for both encoder and decoder. * this assumes that some variables like width/height are already set */ -av_cold int ff_mpv_common_init(MpegEncContext *s) +av_cold int ff_mpv_common_init(MPVMainContext *s) { int i, ret; int nb_slices = (HAVE_THREADS && @@ -818,7 +818,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) return ret; } -void ff_mpv_free_context_frame(MpegEncContext *s) +void ff_mpv_free_context_frame(MPVMainContext *s) { int i, j, k; @@ -872,7 +872,7 @@ void ff_mpv_free_context_frame(MpegEncContext *s) } /* init common structure for both encoder and decoder */ -void ff_mpv_common_end(MpegEncContext *s) +void ff_mpv_common_end(MPVMainContext *s) { if (!s) return; @@ -911,7 +911,7 @@ void ff_mpv_common_end(MpegEncContext *s) } -static inline int hpel_motion_lowres(MpegEncContext *s, +static inline int hpel_motion_lowres(MPVContext *s, uint8_t *dest, uint8_t *src, int field_based, int field_select, int src_x, int src_y, @@ -958,7 +958,7 @@ static inline int hpel_motion_lowres(MpegEncContext *s, } /* apply one mpeg motion vector to the three components */ -static av_always_inline void mpeg_motion_lowres(MpegEncContext *s, +static av_always_inline void mpeg_motion_lowres(MPVContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, @@ -1097,7 +1097,7 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s, // FIXME h261 lowres loop filter } -static inline void chroma_4mv_motion_lowres(MpegEncContext *s, +static inline void chroma_4mv_motion_lowres(MPVContext *s, uint8_t *dest_cb, uint8_t *dest_cr, uint8_t **ref_picture, h264_chroma_mc_func * pix_op, @@ -1165,7 +1165,7 @@ static inline void chroma_4mv_motion_lowres(MpegEncContext *s, * @param pix_op halfpel motion compensation function (average or put normally) * the motion vectors are taken from s->mv and the MV type from s->mv_type */ -static inline void MPV_motion_lowres(MpegEncContext *s, +static inline void MPV_motion_lowres(MPVContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int dir, uint8_t **ref_picture, @@ -1299,7 +1299,7 @@ static inline void MPV_motion_lowres(MpegEncContext *s, /** * find the lowest MB row referenced in the MVs */ -static int lowest_referenced_row(MpegEncContext *s, int dir) +static int lowest_referenced_row(MPVContext *s, int dir) { int my_max = INT_MIN, my_min = INT_MAX, qpel_shift = !s->quarter_sample; int my, off, i, mvs; @@ -1335,7 +1335,7 @@ unhandled: } /* put block[] to dest[] */ -static inline void put_dct(MpegEncContext *s, +static inline void put_dct(MPVContext *s, int16_t *block, int i, uint8_t *dest, int line_size, int qscale) { s->dct_unquantize_intra(s, block, i, qscale); @@ -1343,7 +1343,7 @@ static inline void put_dct(MpegEncContext *s, } /* add block[] to dest[] */ -static inline void add_dct(MpegEncContext *s, +static inline void add_dct(MPVContext *s, int16_t *block, int i, uint8_t *dest, int line_size) { if (s->block_last_index[i] >= 0) { @@ -1351,7 +1351,7 @@ static inline void add_dct(MpegEncContext *s, } } -static inline void add_dequant_dct(MpegEncContext *s, +static inline void add_dequant_dct(MPVContext *s, int16_t *block, int i, uint8_t *dest, int line_size, int qscale) { if (s->block_last_index[i] >= 0) { @@ -1364,7 +1364,7 @@ static inline void add_dequant_dct(MpegEncContext *s, /** * Clean dc, ac, coded_block for the current non-intra MB. */ -void ff_clean_intra_table_entries(MpegEncContext *s) +void ff_clean_intra_table_entries(MPVContext *s) { int wrap = s->b8_stride; int xy = s->block_index[0]; @@ -1405,7 +1405,7 @@ void ff_clean_intra_table_entries(MpegEncContext *s) s->interlaced_dct : true if interlaced dct used (mpeg2) */ static av_always_inline -void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64], +void mpv_reconstruct_mb_internal(MPVContext *s, int16_t block[12][64], int lowres_flag, int is_mpeg12) { #define IS_ENCODER(s) (CONFIG_MPEGVIDEOENC && !lowres_flag && (s)->encoding) @@ -1642,7 +1642,7 @@ skip_idct: } } -void ff_mpv_reconstruct_mb(MpegEncContext *s, int16_t block[12][64]) +void ff_mpv_reconstruct_mb(MPVContext *s, int16_t block[12][64]) { if (CONFIG_XVMC && s->avctx->hwaccel && s->avctx->hwaccel->decode_mb) { @@ -1672,7 +1672,8 @@ void ff_mpv_reconstruct_mb(MpegEncContext *s, int16_t block[12][64]) else mpv_reconstruct_mb_internal(s, block, 0, 0); } -void ff_init_block_index(MpegEncContext *s){ //FIXME maybe rename +void ff_init_block_index(MPVContext *s) //FIXME maybe rename +{ const int linesize = s->current_picture.f->linesize[0]; //not s->linesize as this would be wrong for field pics const int uvlinesize = s->current_picture.f->linesize[1]; const int width_of_mb = (4 + (s->avctx->bits_per_raw_sample > 8)) - s->avctx->lowres; @@ -1708,7 +1709,7 @@ void ff_init_block_index(MpegEncContext *s){ //FIXME maybe rename /** * set qscale and update qscale dependent variables. */ -void ff_set_qscale(MpegEncContext * s, int qscale) +void ff_set_qscale(MPVContext *s, int qscale) { if (qscale < 1) qscale = 1; diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index e31ad2ccff..a32bd277eb 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -59,9 +59,9 @@ #define MAX_B_FRAMES 16 /** - * MpegEncContext. + * MPVContext. */ -typedef struct MpegEncContext { +typedef struct MPVContext { AVClass *class; int y_dc_scale, c_dc_scale; @@ -138,7 +138,7 @@ typedef struct MpegEncContext { int start_mb_y; ///< start mb_y of this thread (so current thread should process start_mb_y <= row < end_mb_y) int end_mb_y; ///< end mb_y of this thread (so current thread should process start_mb_y <= row < end_mb_y) - struct MpegEncContext *thread_context[MAX_THREADS]; + struct MPVContext *thread_context[MAX_THREADS]; int slice_context_count; ///< number of used thread_contexts /** @@ -472,32 +472,32 @@ typedef struct MpegEncContext { int16_t (*block)[64]; ///< points to one of the following blocks int16_t (*blocks)[12][64]; // for HQ mode we need to keep the best block - int (*decode_mb)(struct MpegEncContext *s, int16_t block[12][64]); // used by some codecs to avoid a switch() + int (*decode_mb)(struct MPVContext *s, int16_t block[12][64]); // used by some codecs to avoid a switch() #define SLICE_OK 0 #define SLICE_ERROR -1 #define SLICE_END -2 ///avctx->bits_per_raw_sample > 8); const int block_size= (8*bytes_per_pixel) >> s->avctx->lowres; diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c index b1b15c7fcf..6ed0716e0d 100644 --- a/libavcodec/mpegvideo_dec.c +++ b/libavcodec/mpegvideo_dec.c @@ -34,7 +34,7 @@ #include "mpegvideodec.h" #include "thread.h" -void ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx) +void ff_mpv_decode_init(MPVMainDecContext *s, AVCodecContext *avctx) { ff_mpv_common_defaults(s); @@ -51,8 +51,8 @@ void ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx) int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src) { - MpegEncContext *const s1 = src->priv_data; - MpegEncContext *const s = dst->priv_data; + MPVMainDecContext *const s1 = src->priv_data; + MPVMainDecContext *const s = dst->priv_data; int ret; if (dst == src) @@ -191,7 +191,7 @@ do {\ return 0; } -int ff_mpv_common_frame_size_change(MpegEncContext *s) +int ff_mpv_common_frame_size_change(MPVMainDecContext *s) { int err = 0; @@ -245,7 +245,7 @@ int ff_mpv_common_frame_size_change(MpegEncContext *s) return err; } -static int alloc_picture(MpegEncContext *s, Picture *pic) +static int alloc_picture(MPVDecContext *s, Picture *pic) { return ff_alloc_picture(s->avctx, pic, &s->me, &s->sc, 0, 0, s->chroma_x_shift, s->chroma_y_shift, s->out_format, @@ -273,7 +273,7 @@ static void gray_frame(AVFrame *frame) * generic function called after decoding * the header and before a frame is decoded. */ -int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx) +int ff_mpv_frame_start(MPVMainDecContext *s, AVCodecContext *avctx) { Picture *pic; int idx, ret; @@ -497,7 +497,7 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx) } /* called after a frame has been decoded. */ -void ff_mpv_frame_end(MpegEncContext *s) +void ff_mpv_frame_end(MPVMainDecContext *s) { emms_c(); @@ -505,14 +505,14 @@ void ff_mpv_frame_end(MpegEncContext *s) ff_thread_report_progress(&s->current_picture_ptr->tf, INT_MAX, 0); } -void ff_print_debug_info(MpegEncContext *s, Picture *p, AVFrame *pict) +void ff_print_debug_info(MPVDecContext *s, Picture *p, AVFrame *pict) { ff_print_debug_info2(s->avctx, pict, s->mbskip_table, p->mb_type, p->qscale_table, p->motion_val, s->mb_width, s->mb_height, s->mb_stride, s->quarter_sample); } -int ff_mpv_export_qp_table(MpegEncContext *s, AVFrame *f, Picture *p, int qp_type) +int ff_mpv_export_qp_table(MPVMainDecContext *s, AVFrame *f, Picture *p, int qp_type) { AVVideoEncParams *par; int mult = (qp_type == FF_QSCALE_TYPE_MPEG1) ? 2 : 1; @@ -542,7 +542,7 @@ int ff_mpv_export_qp_table(MpegEncContext *s, AVFrame *f, Picture *p, int qp_typ return 0; } -void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h) +void ff_mpeg_draw_horiz_band(MPVDecContext *s, int y, int h) { ff_draw_horiz_band(s->avctx, s->current_picture_ptr->f, s->last_picture_ptr ? s->last_picture_ptr->f : NULL, @@ -552,7 +552,7 @@ void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h) void ff_mpeg_flush(AVCodecContext *avctx) { - MpegEncContext *const s = avctx->priv_data; + MPVMainDecContext *const s = avctx->priv_data; if (!s->picture) return; @@ -579,7 +579,7 @@ void ff_mpeg_flush(AVCodecContext *avctx) s->pp_time = 0; } -void ff_mpv_report_decode_progress(MpegEncContext *s) +void ff_mpv_report_decode_progress(MPVDecContext *s) { if (s->pict_type != AV_PICTURE_TYPE_B && !s->partitioned_frame && !s->er.error_occurred) ff_thread_report_progress(&s->current_picture_ptr->tf, s->mb_y, 0); diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 05c73fee87..20c61dc0a6 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -82,11 +82,11 @@ #define QMAT_SHIFT_MMX 16 #define QMAT_SHIFT 21 -static int encode_picture(MpegEncContext *s, int picture_number); -static int dct_quantize_refine(MpegEncContext *s, int16_t *block, int16_t *weight, int16_t *orig, int n, int qscale); -static int sse_mb(MpegEncContext *s); -static void denoise_dct_c(MpegEncContext *s, int16_t *block); -static int dct_quantize_trellis_c(MpegEncContext *s, int16_t *block, int n, int qscale, int *overflow); +static int encode_picture(MPVMainEncContext *s, int picture_number); +static int dct_quantize_refine(MPVEncContext *s, int16_t *block, int16_t *weight, int16_t *orig, int n, int qscale); +static int sse_mb(MPVEncContext *s); +static void denoise_dct_c(MPVEncContext *s, int16_t *block); +static int dct_quantize_trellis_c(MPVEncContext *s, int16_t *block, int n, int qscale, int *overflow); static uint8_t default_mv_penalty[MAX_FCODE + 1][MAX_DMV * 2 + 1]; static uint8_t default_fcode_tab[MAX_MV * 2 + 1]; @@ -109,7 +109,7 @@ const AVClass ff_mpv_enc_class = { .version = LIBAVUTIL_VERSION_INT, }; -void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64], +void ff_convert_matrix(MPVEncContext *s, int (*qmat)[64], uint16_t (*qmat16)[2][64], const uint16_t *quant_matrix, int bias, int qmin, int qmax, int intra) @@ -193,7 +193,7 @@ void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64], } } -static inline void update_qscale(MpegEncContext *s) +static inline void update_qscale(MPVEncContext *s) { if (s->q_scale_type == 1 && 0) { int i; @@ -237,7 +237,7 @@ void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix) /** * init s->current_picture.qscale_table from s->lambda_table */ -void ff_init_qscale_tab(MpegEncContext *s) +void ff_init_qscale_tab(MPVMainEncContext *s) { int8_t * const qscale_table = s->current_picture.qscale_table; int i; @@ -250,8 +250,8 @@ void ff_init_qscale_tab(MpegEncContext *s) } } -static void update_duplicate_context_after_me(MpegEncContext *dst, - MpegEncContext *src) +static void update_duplicate_context_after_me(MPVEncContext *dst, + MPVEncContext *src) { #define COPY(a) dst->a= src->a COPY(pict_type); @@ -275,10 +275,10 @@ static void mpv_encode_init_static(void) } /** - * Set the given MpegEncContext to defaults for encoding. - * the changed fields will not depend upon the prior state of the MpegEncContext. + * Set the given MPVMainEncContext to defaults for encoding. + * the changed fields will not depend upon the prior state of the MPVMainEncContext. */ -static void mpv_encode_defaults(MpegEncContext *s) +static void mpv_encode_defaults(MPVMainEncContext *s) { static AVOnce init_static_once = AV_ONCE_INIT; @@ -293,7 +293,7 @@ static void mpv_encode_defaults(MpegEncContext *s) s->picture_in_gop_number = 0; } -av_cold int ff_dct_encode_init(MpegEncContext *s) +av_cold int ff_dct_encode_init(MPVEncContext *s) { if (ARCH_X86) ff_dct_encode_init_x86(s); @@ -314,7 +314,7 @@ av_cold int ff_dct_encode_init(MpegEncContext *s) /* init video encoder */ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) { - MpegEncContext *s = avctx->priv_data; + MPVMainEncContext *const s = avctx->priv_data; AVCPBProperties *cpb_props; int i, ret; @@ -929,7 +929,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) av_cold int ff_mpv_encode_end(AVCodecContext *avctx) { - MpegEncContext *s = avctx->priv_data; + MPVMainEncContext *const s = avctx->priv_data; int i; ff_rate_control_uninit(s); @@ -972,7 +972,7 @@ static int get_sae(uint8_t *src, int ref, int stride) return acc; } -static int get_intra_count(MpegEncContext *s, uint8_t *src, +static int get_intra_count(MPVMainEncContext *s, uint8_t *src, uint8_t *ref, int stride) { int x, y, w, h; @@ -995,7 +995,7 @@ static int get_intra_count(MpegEncContext *s, uint8_t *src, return acc; } -static int alloc_picture(MpegEncContext *s, Picture *pic, int shared) +static int alloc_picture(MPVMainEncContext *s, Picture *pic, int shared) { return ff_alloc_picture(s->avctx, pic, &s->me, &s->sc, shared, 1, s->chroma_x_shift, s->chroma_y_shift, s->out_format, @@ -1003,7 +1003,7 @@ static int alloc_picture(MpegEncContext *s, Picture *pic, int shared) &s->linesize, &s->uvlinesize); } -static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg) +static int load_input_picture(MPVMainEncContext *s, const AVFrame *pic_arg) { Picture *pic = NULL; int64_t pts; @@ -1154,7 +1154,7 @@ static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg) return 0; } -static int skip_check(MpegEncContext *s, Picture *p, Picture *ref) +static int skip_check(MPVMainEncContext *s, Picture *p, Picture *ref) { int x, y, plane; int score = 0; @@ -1216,7 +1216,7 @@ static int encode_frame(AVCodecContext *c, AVFrame *frame, AVPacket *pkt) return size; } -static int estimate_best_b_count(MpegEncContext *s) +static int estimate_best_b_count(MPVMainEncContext *s) { const AVCodec *codec = avcodec_find_encoder(s->avctx->codec_id); AVPacket *pkt; @@ -1363,7 +1363,7 @@ fail: return best_b_count; } -static int select_input_picture(MpegEncContext *s) +static int select_input_picture(MPVMainEncContext *s) { int i, ret; @@ -1540,7 +1540,7 @@ no_output_pic: return 0; } -static void frame_end(MpegEncContext *s) +static void frame_end(MPVMainEncContext *s) { if (s->unrestricted_mv && s->current_picture.reference && @@ -1577,7 +1577,7 @@ static void frame_end(MpegEncContext *s) s->last_non_b_pict_type = s->pict_type; } -static void update_noise_reduction(MpegEncContext *s) +static void update_noise_reduction(MPVMainEncContext *s) { int intra, i; @@ -1598,7 +1598,7 @@ static void update_noise_reduction(MpegEncContext *s) } } -static int frame_start(MpegEncContext *s) +static int frame_start(MPVMainEncContext *s) { int ret; @@ -1672,7 +1672,7 @@ static int frame_start(MpegEncContext *s) int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic_arg, int *got_packet) { - MpegEncContext *s = avctx->priv_data; + MPVMainEncContext *const s = avctx->priv_data; int i, stuffing_count, ret; int context_count = s->slice_context_count; @@ -1905,7 +1905,7 @@ vbv_retry: return 0; } -static inline void dct_single_coeff_elimination(MpegEncContext *s, +static inline void dct_single_coeff_elimination(MPVEncContext *s, int n, int threshold) { static const char tab[64] = { @@ -1961,7 +1961,7 @@ static inline void dct_single_coeff_elimination(MpegEncContext *s, s->block_last_index[n] = -1; } -static inline void clip_coeffs(MpegEncContext *s, int16_t *block, +static inline void clip_coeffs(MPVEncContext *s, int16_t *block, int last_index) { int i; @@ -2019,7 +2019,7 @@ static void get_visual_weight(int16_t *weight, uint8_t *ptr, int stride) } } -static av_always_inline void encode_mb_internal(MpegEncContext *s, +static av_always_inline void encode_mb_internal(MPVEncContext *s, int motion_x, int motion_y, int mb_block_height, int mb_block_width, @@ -2411,7 +2411,7 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, } } -static av_always_inline void encode_mb(MpegEncContext *s, int motion_x, int motion_y) +static av_always_inline void encode_mb(MPVEncContext *s, int motion_x, int motion_y) { if (s->chroma_format == CHROMA_420) encode_mb_internal(s, motion_x, motion_y, 8, 8, 6, 1, 1, CHROMA_420); @@ -2421,7 +2421,9 @@ static av_always_inline void encode_mb(MpegEncContext *s, int motion_x, int moti encode_mb_internal(s, motion_x, motion_y, 16, 16, 12, 0, 0, CHROMA_444); } -static inline void copy_context_before_encode(MpegEncContext *d, MpegEncContext *s, int type){ +static inline void copy_context_before_encode(MPVEncContext *d, + const MPVEncContext *s, int type) +{ int i; memcpy(d->last_mv, s->last_mv, 2*2*2*sizeof(int)); //FIXME is memcpy faster than a loop? @@ -2449,7 +2451,9 @@ static inline void copy_context_before_encode(MpegEncContext *d, MpegEncContext d->esc3_level_length= s->esc3_level_length; } -static inline void copy_context_after_encode(MpegEncContext *d, MpegEncContext *s, int type){ +static inline void copy_context_after_encode(MPVEncContext *d, + const MPVEncContext *s, int type) +{ int i; memcpy(d->mv, s->mv, 2*4*2*sizeof(int)); @@ -2488,7 +2492,7 @@ static inline void copy_context_after_encode(MpegEncContext *d, MpegEncContext * d->esc3_level_length= s->esc3_level_length; } -static inline void encode_mb_hq(MpegEncContext *s, MpegEncContext *backup, MpegEncContext *best, int type, +static inline void encode_mb_hq(MPVEncContext *s, MPVEncContext *backup, MPVEncContext *best, int type, PutBitContext pb[2], PutBitContext pb2[2], PutBitContext tex_pb[2], int *dmin, int *next_block, int motion_x, int motion_y) { @@ -2539,7 +2543,9 @@ static inline void encode_mb_hq(MpegEncContext *s, MpegEncContext *backup, MpegE } } -static int sse(MpegEncContext *s, uint8_t *src1, uint8_t *src2, int w, int h, int stride){ +static int sse(MPVEncContext *s, uint8_t *src1, uint8_t *src2, + int w, int h, int stride) +{ const uint32_t *sq = ff_square_tab + 256; int acc=0; int x,y; @@ -2560,7 +2566,8 @@ static int sse(MpegEncContext *s, uint8_t *src1, uint8_t *src2, int w, int h, in return acc; } -static int sse_mb(MpegEncContext *s){ +static int sse_mb(MPVEncContext *s) +{ int w= 16; int h= 16; @@ -2584,7 +2591,7 @@ static int sse_mb(MpegEncContext *s){ } static int pre_estimate_motion_thread(AVCodecContext *c, void *arg){ - MpegEncContext *s= *(void**)arg; + MPVEncContext *const s = *(void**)arg; s->me.pre_pass=1; @@ -2603,7 +2610,7 @@ static int pre_estimate_motion_thread(AVCodecContext *c, void *arg){ } static int estimate_motion_thread(AVCodecContext *c, void *arg){ - MpegEncContext *s= *(void**)arg; + MPVEncContext *const s = *(void**)arg; s->me.dia_size= s->avctx->dia_size; s->first_slice_line=1; @@ -2628,7 +2635,7 @@ static int estimate_motion_thread(AVCodecContext *c, void *arg){ } static int mb_var_thread(AVCodecContext *c, void *arg){ - MpegEncContext *s= *(void**)arg; + MPVEncContext *const s = *(void**)arg; int mb_x, mb_y; for(mb_y=s->start_mb_y; mb_y < s->end_mb_y; mb_y++) { @@ -2650,7 +2657,8 @@ static int mb_var_thread(AVCodecContext *c, void *arg){ return 0; } -static void write_slice_end(MpegEncContext *s){ +static void write_slice_end(MPVEncContext *s) +{ if(CONFIG_MPEG4_ENCODER && s->codec_id==AV_CODEC_ID_MPEG4){ if(s->partitioned_frame){ ff_mpeg4_merge_partitions(s); @@ -2670,7 +2678,7 @@ static void write_slice_end(MpegEncContext *s){ s->misc_bits+= get_bits_diff(s); } -static void write_mb_info(MpegEncContext *s) +static void write_mb_info(MPVEncContext *s) { uint8_t *ptr = s->mb_info_ptr + s->mb_info_size - 12; int offset = put_bits_count(&s->pb); @@ -2690,7 +2698,7 @@ static void write_mb_info(MpegEncContext *s) bytestream_put_byte(&ptr, 0); /* vmv2 */ } -static void update_mb_info(MpegEncContext *s, int startcode) +static void update_mb_info(MPVEncContext *s, int startcode) { if (!s->mb_info) return; @@ -2713,7 +2721,7 @@ static void update_mb_info(MpegEncContext *s, int startcode) write_mb_info(s); } -int ff_mpv_reallocate_putbitbuffer(MpegEncContext *s, size_t threshold, size_t size_increase) +int ff_mpv_reallocate_putbitbuffer(MPVEncContext *s, size_t threshold, size_t size_increase) { if (put_bytes_left(&s->pb, 0) < threshold && s->slice_context_count == 1 @@ -2748,11 +2756,11 @@ int ff_mpv_reallocate_putbitbuffer(MpegEncContext *s, size_t threshold, size_t s } static int encode_thread(AVCodecContext *c, void *arg){ - MpegEncContext *s= *(void**)arg; + MPVEncContext *const s = *(void**)arg; int mb_x, mb_y, mb_y_order; int chr_h= 16>>s->chroma_y_shift; int i, j; - MpegEncContext best_s = { 0 }, backup_s; + MPVEncContext best_s = { 0 }, backup_s; uint8_t bit_buf[2][MAX_MB_BYTES]; uint8_t bit_buf2[2][MAX_MB_BYTES]; uint8_t bit_buf_tex[2][MAX_MB_BYTES]; @@ -3386,13 +3394,15 @@ static int encode_thread(AVCodecContext *c, void *arg){ } #define MERGE(field) dst->field += src->field; src->field=0 -static void merge_context_after_me(MpegEncContext *dst, MpegEncContext *src){ +static void merge_context_after_me(MPVEncContext *dst, MPVEncContext *src) +{ MERGE(me.scene_change_score); MERGE(me.mc_mb_var_sum_temp); MERGE(me.mb_var_sum_temp); } -static void merge_context_after_encode(MpegEncContext *dst, MpegEncContext *src){ +static void merge_context_after_encode(MPVEncContext *dst, MPVEncContext *src) +{ int i; MERGE(dct_count[0]); //note, the other dct vars are not part of the context @@ -3422,7 +3432,8 @@ static void merge_context_after_encode(MpegEncContext *dst, MpegEncContext *src) flush_put_bits(&dst->pb); } -static int estimate_qp(MpegEncContext *s, int dry_run){ +static int estimate_qp(MPVMainEncContext *s, int dry_run) +{ if (s->next_lambda){ s->current_picture_ptr->f->quality = s->current_picture.f->quality = s->next_lambda; @@ -3460,7 +3471,8 @@ static int estimate_qp(MpegEncContext *s, int dry_run){ } /* must be called before writing the header */ -static void set_frame_distances(MpegEncContext * s){ +static void set_frame_distances(MPVMainEncContext *s) +{ av_assert1(s->current_picture_ptr->f->pts != AV_NOPTS_VALUE); s->time = s->current_picture_ptr->f->pts * s->avctx->time_base.num; @@ -3474,7 +3486,7 @@ static void set_frame_distances(MpegEncContext * s){ } } -static int encode_picture(MpegEncContext *s, int picture_number) +static int encode_picture(MPVMainEncContext *s, int picture_number) { int i, ret; int bits; @@ -3755,7 +3767,8 @@ static int encode_picture(MpegEncContext *s, int picture_number) return 0; } -static void denoise_dct_c(MpegEncContext *s, int16_t *block){ +static void denoise_dct_c(MPVEncContext *s, int16_t *block) +{ const int intra= s->mb_intra; int i; @@ -3779,7 +3792,7 @@ static void denoise_dct_c(MpegEncContext *s, int16_t *block){ } } -static int dct_quantize_trellis_c(MpegEncContext *s, +static int dct_quantize_trellis_c(MPVEncContext *s, int16_t *block, int n, int qscale, int *overflow){ const int *qmat; @@ -4113,7 +4126,7 @@ static void build_basis(uint8_t *perm){ } } -static int dct_quantize_refine(MpegEncContext *s, //FIXME breaks denoise? +static int dct_quantize_refine(MPVEncContext *s, //FIXME breaks denoise? int16_t *block, int16_t *weight, int16_t *orig, int n, int qscale){ int16_t rem[64]; @@ -4465,7 +4478,7 @@ void ff_block_permute(int16_t *block, uint8_t *permutation, } } -int ff_dct_quantize_c(MpegEncContext *s, +int ff_dct_quantize_c(MPVEncContext *s, int16_t *block, int n, int qscale, int *overflow) { diff --git a/libavcodec/mpegvideo_motion.c b/libavcodec/mpegvideo_motion.c index 876a7375f8..12ae984537 100644 --- a/libavcodec/mpegvideo_motion.c +++ b/libavcodec/mpegvideo_motion.c @@ -32,7 +32,7 @@ #include "qpeldsp.h" #include "wmv2.h" -static void gmc1_motion(MpegEncContext *s, +static void gmc1_motion(MPVContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, uint8_t **ref_picture) { @@ -129,7 +129,7 @@ static void gmc1_motion(MpegEncContext *s, motion_x & 15, motion_y & 15, 128 - s->no_rounding); } -static void gmc_motion(MpegEncContext *s, +static void gmc_motion(MPVContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, uint8_t **ref_picture) { @@ -187,7 +187,7 @@ static void gmc_motion(MpegEncContext *s, (s->h_edge_pos + 1) >> 1, (s->v_edge_pos + 1) >> 1); } -static inline int hpel_motion(MpegEncContext *s, +static inline int hpel_motion(MPVContext *s, uint8_t *dest, uint8_t *src, int src_x, int src_y, op_pixels_func *pix_op, @@ -223,7 +223,7 @@ static inline int hpel_motion(MpegEncContext *s, } static av_always_inline -void mpeg_motion_internal(MpegEncContext *s, +void mpeg_motion_internal(MPVContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, @@ -365,7 +365,7 @@ void mpeg_motion_internal(MpegEncContext *s, } } /* apply one mpeg motion vector to the three components */ -static void mpeg_motion(MpegEncContext *s, +static void mpeg_motion(MPVContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int field_select, uint8_t **ref_picture, op_pixels_func (*pix_op)[4], @@ -383,7 +383,7 @@ static void mpeg_motion(MpegEncContext *s, motion_x, motion_y, h, 0, is_16x8, mb_y); } -static void mpeg_motion_field(MpegEncContext *s, uint8_t *dest_y, +static void mpeg_motion_field(MPVContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int bottom_field, int field_select, uint8_t **ref_picture, @@ -456,7 +456,7 @@ static inline void put_obmc(uint8_t *dst, uint8_t *src[5], int stride) } /* obmc for 1 8x8 luma block */ -static inline void obmc_motion(MpegEncContext *s, +static inline void obmc_motion(MPVContext *s, uint8_t *dest, uint8_t *src, int src_x, int src_y, op_pixels_func *pix_op, @@ -482,7 +482,7 @@ static inline void obmc_motion(MpegEncContext *s, put_obmc(dest, ptr, s->linesize); } -static inline void qpel_motion(MpegEncContext *s, +static inline void qpel_motion(MPVContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, @@ -589,7 +589,7 @@ static inline void qpel_motion(MpegEncContext *s, /** * H.263 chroma 4mv motion compensation. */ -static void chroma_4mv_motion(MpegEncContext *s, +static void chroma_4mv_motion(MPVContext *s, uint8_t *dest_cb, uint8_t *dest_cr, uint8_t **ref_picture, op_pixels_func *pix_op, @@ -641,7 +641,7 @@ static void chroma_4mv_motion(MpegEncContext *s, pix_op[dxy](dest_cr, ptr, s->uvlinesize, 8); } -static inline void prefetch_motion(MpegEncContext *s, uint8_t **pix, int dir) +static inline void prefetch_motion(MPVContext *s, uint8_t **pix, int dir) { /* fetch pixels for estimated mv 4 macroblocks ahead * optimized for 64byte cache lines */ @@ -655,7 +655,7 @@ static inline void prefetch_motion(MpegEncContext *s, uint8_t **pix, int dir) s->vdsp.prefetch(pix[1] + off, pix[2] - pix[1], 2); } -static inline void apply_obmc(MpegEncContext *s, +static inline void apply_obmc(MPVContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, @@ -742,7 +742,7 @@ static inline void apply_obmc(MpegEncContext *s, mx, my); } -static inline void apply_8x8(MpegEncContext *s, +static inline void apply_8x8(MPVContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, @@ -826,7 +826,7 @@ static inline void apply_8x8(MpegEncContext *s, * @param qpix_op qpel motion compensation function (average or put normally) * the motion vectors are taken from s->mv and the MV type from s->mv_type */ -static av_always_inline void mpv_motion_internal(MpegEncContext *s, +static av_always_inline void mpv_motion_internal(MPVContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, @@ -969,7 +969,7 @@ static av_always_inline void mpv_motion_internal(MpegEncContext *s, } } -void ff_mpv_motion(MpegEncContext *s, +void ff_mpv_motion(MPVContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int dir, uint8_t **ref_picture, diff --git a/libavcodec/mpegvideo_xvmc.c b/libavcodec/mpegvideo_xvmc.c index bfeb453834..d279fcc759 100644 --- a/libavcodec/mpegvideo_xvmc.c +++ b/libavcodec/mpegvideo_xvmc.c @@ -24,7 +24,7 @@ #include "avcodec.h" #include "mpegutils.h" -#include "mpegvideo.h" +#include "mpegvideodec.h" #undef NDEBUG #include @@ -34,13 +34,13 @@ #include "version.h" /** - * Initialize the block field of the MpegEncContext pointer passed as + * Initialize the block field of the MPVDecContext pointer passed as * parameter after making sure that the data is not corrupted. * In order to implement something like direct rendering instead of decoding * coefficients in s->blocks and then copying them, copy them directly * into the data_blocks array provided by xvmc. */ -void ff_xvmc_init_block(MpegEncContext *s) +void ff_xvmc_init_block(MPVDecContext *s) { struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.f->data[2]; assert(render && render->xvmc_id == AV_XVMC_ID); @@ -48,7 +48,7 @@ void ff_xvmc_init_block(MpegEncContext *s) s->block = (int16_t (*)[64])(render->data_blocks + render->next_free_data_block_num * 64); } -static void exchange_uv(MpegEncContext *s) +static void exchange_uv(MPVDecContext *s) { int16_t (*tmp)[64]; @@ -61,7 +61,7 @@ static void exchange_uv(MpegEncContext *s) * Fill individual block pointers, so there are no gaps in the data_block array * in case not all blocks in the macroblock are coded. */ -void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp) +void ff_xvmc_pack_pblocks(MPVDecContext *s, int cbp) { int i, j = 0; const int mb_block_count = 4 + (1 << s->chroma_format); @@ -86,7 +86,7 @@ void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp) */ static int ff_xvmc_field_start(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size) { - struct MpegEncContext *s = avctx->priv_data; + MPVDecContext *const s = avctx->priv_data; struct xvmc_pix_fmt *last, *next, *render = (struct xvmc_pix_fmt*)s->current_picture.f->data[2]; const int mb_block_count = 4 + (1 << s->chroma_format); @@ -155,7 +155,7 @@ return -1; */ static int ff_xvmc_field_end(AVCodecContext *avctx) { - struct MpegEncContext *s = avctx->priv_data; + MPVDecContext *const s = avctx->priv_data; struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.f->data[2]; assert(render); @@ -170,7 +170,7 @@ static int ff_xvmc_field_end(AVCodecContext *avctx) */ static void ff_xvmc_decode_mb(void *opaque) { - MpegEncContext *const s = opaque; + MPVDecContext *const s = opaque; XvMCMacroBlock *mv_block; struct xvmc_pix_fmt *render; int i, cbp, blocks_per_mb; diff --git a/libavcodec/mpegvideodec.h b/libavcodec/mpegvideodec.h index 0cda0af733..54bd2ac67d 100644 --- a/libavcodec/mpegvideodec.h +++ b/libavcodec/mpegvideodec.h @@ -35,27 +35,30 @@ #include "mpegvideo.h" #include "mpegvideodata.h" +typedef MPVContext MPVDecContext; +typedef MPVMainContext MPVMainDecContext; + /** - * Initialize the given MpegEncContext for decoding. + * Initialize the given MPVMainDecContext for decoding. * the changed fields will not depend upon - * the prior state of the MpegEncContext. + * the prior state of the MPVMainDecContext. */ -void ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx); +void ff_mpv_decode_init(MPVMainDecContext *m, AVCodecContext *avctx); -int ff_mpv_common_frame_size_change(MpegEncContext *s); +int ff_mpv_common_frame_size_change(MPVMainDecContext *m); -int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx); -void ff_mpv_report_decode_progress(MpegEncContext *s); -void ff_mpv_frame_end(MpegEncContext *s); +int ff_mpv_frame_start(MPVMainDecContext *m, AVCodecContext *avctx); +void ff_mpv_report_decode_progress(MPVDecContext *s); +void ff_mpv_frame_end(MPVMainDecContext *m); -int ff_mpv_export_qp_table(MpegEncContext *s, AVFrame *f, Picture *p, int qp_type); +int ff_mpv_export_qp_table(MPVMainDecContext *m, AVFrame *f, Picture *p, int qp_type); int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src); -void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h); +void ff_mpeg_draw_horiz_band(MPVDecContext *s, int y, int h); void ff_mpeg_flush(AVCodecContext *avctx); -void ff_print_debug_info(MpegEncContext *s, Picture *p, AVFrame *pict); +void ff_print_debug_info(MPVDecContext *s, Picture *p, AVFrame *pict); -static inline int mpeg_get_qscale(MpegEncContext *s) +static inline int mpeg_get_qscale(MPVDecContext *s) { int qscale = get_bits(&s->gb, 5); if (s->q_scale_type) diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index 9619f6787a..0b63487291 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -32,6 +32,9 @@ #include "internal.h" #include "mpegvideo.h" +typedef MPVContext MPVEncContext; +typedef MPVContext MPVMainEncContext; + #define UNI_AC_ENC_INDEX(run,level) ((run)*128 + (level)) /* mpegvideo_enc common options */ @@ -59,7 +62,7 @@ { "chroma", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_CHROMA }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ { "msad", "Sum of absolute differences, median predicted", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_MEDIAN_SAD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" } -#define FF_MPV_OFFSET(x) offsetof(MpegEncContext, x) +#define FF_MPV_OFFSET(x) offsetof(MPVMainEncContext, x) #define FF_MPV_OPT_FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM) #define FF_MPV_COMMON_OPTS \ FF_MPV_OPT_CMP_FUNC, \ @@ -129,26 +132,26 @@ FF_MPV_OPT_CMP_FUNC, \ extern const AVClass ff_mpv_enc_class; int ff_mpv_encode_init(AVCodecContext *avctx); -void ff_mpv_encode_init_x86(MpegEncContext *s); +void ff_mpv_encode_init_x86(MPVMainEncContext *m); int ff_mpv_encode_end(AVCodecContext *avctx); int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet); -int ff_mpv_reallocate_putbitbuffer(MpegEncContext *s, size_t threshold, size_t size_increase); +int ff_mpv_reallocate_putbitbuffer(MPVEncContext *s, size_t threshold, size_t size_increase); void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix); -int ff_dct_encode_init(MpegEncContext *s); -void ff_dct_encode_init_x86(MpegEncContext *s); +int ff_dct_encode_init(MPVEncContext *s); +void ff_dct_encode_init_x86(MPVEncContext *s); -int ff_dct_quantize_c(MpegEncContext *s, int16_t *block, int n, int qscale, int *overflow); -void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64], uint16_t (*qmat16)[2][64], +int ff_dct_quantize_c(MPVEncContext *s, int16_t *block, int n, int qscale, int *overflow); +void ff_convert_matrix(MPVEncContext *s, int (*qmat)[64], uint16_t (*qmat16)[2][64], const uint16_t *quant_matrix, int bias, int qmin, int qmax, int intra); void ff_block_permute(int16_t *block, uint8_t *permutation, const uint8_t *scantable, int last); -static inline int get_bits_diff(MpegEncContext *s) +static inline int get_bits_diff(MPVEncContext *s) { const int bits = put_bits_count(&s->pb); const int last = s->last_bits; diff --git a/libavcodec/msmpeg4.c b/libavcodec/msmpeg4.c index f12586dd64..3658df6b08 100644 --- a/libavcodec/msmpeg4.c +++ b/libavcodec/msmpeg4.c @@ -112,7 +112,7 @@ static av_cold void msmpeg4_common_init_static(void) init_h263_dc_for_msmpeg4(); } -av_cold void ff_msmpeg4_common_init(MpegEncContext *s) +av_cold void ff_msmpeg4_common_init(MPVMainContext *s) { static AVOnce init_static_once = AV_ONCE_INIT; @@ -158,7 +158,7 @@ av_cold void ff_msmpeg4_common_init(MpegEncContext *s) } /* predict coded block */ -int ff_msmpeg4_coded_block_pred(MpegEncContext * s, int n, uint8_t **coded_block_ptr) +int ff_msmpeg4_coded_block_pred(MPVContext *s, int n, uint8_t **coded_block_ptr) { int xy, wrap, pred, a, b, c; @@ -198,7 +198,7 @@ static int get_dc(uint8_t *src, int stride, int scale, int block_size) } /* dir = 0: left, dir = 1: top prediction */ -int ff_msmpeg4_pred_dc(MpegEncContext *s, int n, +int ff_msmpeg4_pred_dc(MPVContext *s, int n, int16_t **dc_val_ptr, int *dir_ptr) { int a, b, c, wrap, pred, scale; diff --git a/libavcodec/msmpeg4.h b/libavcodec/msmpeg4.h index 6dd16d3957..c0b2e06aee 100644 --- a/libavcodec/msmpeg4.h +++ b/libavcodec/msmpeg4.h @@ -32,11 +32,11 @@ #define DC_MAX 119 -void ff_msmpeg4_common_init(MpegEncContext *s); -int ff_msmpeg4_coded_block_pred(MpegEncContext * s, int n, +void ff_msmpeg4_common_init(MPVMainContext *m); +int ff_msmpeg4_coded_block_pred(MPVContext *s, int n, uint8_t **coded_block_ptr); -int ff_msmpeg4_pred_dc(MpegEncContext *s, int n, +int ff_msmpeg4_pred_dc(MPVContext *s, int n, int16_t **dc_val_ptr, int *dir_ptr); #endif /* AVCODEC_MSMPEG4_H */ diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c index bc96b86507..c8527d18dc 100644 --- a/libavcodec/msmpeg4dec.c +++ b/libavcodec/msmpeg4dec.c @@ -26,6 +26,7 @@ #include "internal.h" #include "mpegutils.h" #include "mpegvideo.h" +#include "mpegvideodec.h" #include "msmpeg4.h" #include "msmpeg4dec.h" #include "libavutil/imgutils.h" @@ -34,7 +35,6 @@ #include "h263dec.h" #include "mpeg4videodec.h" #include "msmpeg4data.h" -#include "vc1data.h" #include "wmv2dec.h" #define DC_VLC_BITS 9 @@ -45,7 +45,7 @@ #define DEFAULT_INTER_INDEX 3 -static inline int msmpeg4v1_pred_dc(MpegEncContext * s, int n, +static inline int msmpeg4v1_pred_dc(MPVDecContext *s, int n, int32_t **dc_val_ptr) { int i; @@ -71,7 +71,7 @@ static VLC v2_mb_type_vlc; VLC ff_inter_intra_vlc; /* This is identical to H.263 except that its range is multiplied by 2. */ -static int msmpeg4v2_decode_motion(MpegEncContext * s, int pred, int f_code) +static int msmpeg4v2_decode_motion(MPVDecContext *s, int pred, int f_code) { int code, val, sign, shift; @@ -102,7 +102,7 @@ static int msmpeg4v2_decode_motion(MpegEncContext * s, int pred, int f_code) return val; } -static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64]) +static int msmpeg4v12_decode_mb(MPVDecContext *s, int16_t block[6][64]) { int cbp, code, i; uint32_t * const mb_type_ptr = &s->current_picture.mb_type[s->mb_x + s->mb_y*s->mb_stride]; @@ -203,7 +203,7 @@ static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64]) return 0; } -static int msmpeg4v34_decode_mb(MpegEncContext *s, int16_t block[6][64]) +static int msmpeg4v34_decode_mb(MPVDecContext *s, int16_t block[6][64]) { int cbp, code, i; uint8_t *coded_val; @@ -296,7 +296,7 @@ static int msmpeg4v34_decode_mb(MpegEncContext *s, int16_t block[6][64]) /* init all vlc decoding tables */ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx) { - MpegEncContext *s = avctx->priv_data; + MPVMainDecContext *const s = avctx->priv_data; static volatile int done = 0; int ret; MVTable *mv; @@ -399,7 +399,7 @@ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx) return 0; } -int ff_msmpeg4_decode_picture_header(MpegEncContext * s) +int ff_msmpeg4_decode_picture_header(MPVMainDecContext *s) { int code; @@ -555,7 +555,7 @@ int ff_msmpeg4_decode_picture_header(MpegEncContext * s) return 0; } -int ff_msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size) +int ff_msmpeg4_decode_ext_header(MPVMainDecContext *s, int buf_size) { int left= buf_size*8 - get_bits_count(&s->gb); int length= s->msmpeg4_version>=3 ? 17 : 16; @@ -583,7 +583,7 @@ int ff_msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size) return 0; } -static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr) +static int msmpeg4_decode_dc(MPVDecContext *s, int n, int *dir_ptr) { int level, pred; @@ -639,7 +639,7 @@ static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr) return level; } -int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * block, +int ff_msmpeg4_decode_block(MPVDecContext *s, int16_t *block, int n, int coded, const uint8_t *scan_table) { int level, i, last, run, run_diff; @@ -826,7 +826,7 @@ int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * block, return 0; } -void ff_msmpeg4_decode_motion(MpegEncContext *s, int *mx_ptr, int *my_ptr) +void ff_msmpeg4_decode_motion(MPVDecContext *s, int *mx_ptr, int *my_ptr) { MVTable *mv; int code, mx, my; @@ -863,7 +863,7 @@ const AVCodec ff_msmpeg4v1_decoder = { .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 1"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_MSMPEG4V1, - .priv_data_size = sizeof(MpegEncContext), + .priv_data_size = sizeof(MPVMainDecContext), .init = ff_msmpeg4_decode_init, .close = ff_h263_decode_end, .decode = ff_h263_decode_frame, @@ -881,7 +881,7 @@ const AVCodec ff_msmpeg4v2_decoder = { .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 2"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_MSMPEG4V2, - .priv_data_size = sizeof(MpegEncContext), + .priv_data_size = sizeof(MPVMainDecContext), .init = ff_msmpeg4_decode_init, .close = ff_h263_decode_end, .decode = ff_h263_decode_frame, @@ -899,7 +899,7 @@ const AVCodec ff_msmpeg4v3_decoder = { .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 3"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_MSMPEG4V3, - .priv_data_size = sizeof(MpegEncContext), + .priv_data_size = sizeof(MPVMainDecContext), .init = ff_msmpeg4_decode_init, .close = ff_h263_decode_end, .decode = ff_h263_decode_frame, @@ -917,7 +917,7 @@ const AVCodec ff_wmv1_decoder = { .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 7"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_WMV1, - .priv_data_size = sizeof(MpegEncContext), + .priv_data_size = sizeof(MPVMainDecContext), .init = ff_msmpeg4_decode_init, .close = ff_h263_decode_end, .decode = ff_h263_decode_frame, diff --git a/libavcodec/msmpeg4dec.h b/libavcodec/msmpeg4dec.h index af2591caf5..37f0f090e1 100644 --- a/libavcodec/msmpeg4dec.h +++ b/libavcodec/msmpeg4dec.h @@ -24,7 +24,7 @@ #include "config.h" #include "avcodec.h" -#include "mpegvideo.h" +#include "mpegvideodec.h" #define INTER_INTRA_VLC_BITS 3 #define MB_NON_INTRA_VLC_BITS 9 @@ -34,10 +34,10 @@ extern VLC ff_mb_non_intra_vlc[4]; extern VLC ff_inter_intra_vlc; int ff_msmpeg4_decode_init(AVCodecContext *avctx); -int ff_msmpeg4_decode_picture_header(MpegEncContext *s); -int ff_msmpeg4_decode_ext_header(MpegEncContext *s, int buf_size); -void ff_msmpeg4_decode_motion(MpegEncContext * s, int *mx_ptr, int *my_ptr); -int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * block, +int ff_msmpeg4_decode_picture_header(MPVMainDecContext *m); +int ff_msmpeg4_decode_ext_header(MPVMainDecContext *m, int buf_size); +void ff_msmpeg4_decode_motion(MPVDecContext *s, int *mx_ptr, int *my_ptr); +int ff_msmpeg4_decode_block(MPVDecContext *s, int16_t *block, int n, int coded, const uint8_t *scan_table); #define CONFIG_MSMPEG4_DECODER (CONFIG_MSMPEG4V1_DECODER || \ diff --git a/libavcodec/msmpeg4enc.c b/libavcodec/msmpeg4enc.c index 5e1ed9cc27..1a2e24f703 100644 --- a/libavcodec/msmpeg4enc.c +++ b/libavcodec/msmpeg4enc.c @@ -33,10 +33,9 @@ #include "libavutil/attributes.h" #include "libavutil/avutil.h" #include "libavutil/thread.h" -#include "mpegvideo.h" #include "mpegvideoenc.h" #include "h263.h" -#include "h263enc.h" +#include "h263data.h" #include "internal.h" #include "mpeg4video.h" #include "msmpeg4.h" @@ -44,7 +43,6 @@ #include "msmpeg4enc.h" #include "put_bits.h" #include "rl.h" -#include "vc1data.h" static uint8_t rl_length[NB_RL_TABLES][MAX_LEVEL+1][MAX_RUN+1][2]; @@ -136,7 +134,7 @@ static av_cold void msmpeg4_encode_init_static(void) } } -av_cold void ff_msmpeg4_encode_init(MpegEncContext *s) +av_cold void ff_msmpeg4_encode_init(MPVMainEncContext *s) { static AVOnce init_static_once = AV_ONCE_INIT; @@ -152,7 +150,7 @@ av_cold void ff_msmpeg4_encode_init(MpegEncContext *s) static void find_best_tables(MSMPEG4EncContext *ms) { - MpegEncContext *const s = &ms->s; + MPVEncContext *const s = &ms->s; int i; int best = 0, best_size = INT_MAX; int chroma_best = 0, best_chroma_size = INT_MAX; @@ -216,7 +214,7 @@ static void find_best_tables(MSMPEG4EncContext *ms) } /* write MSMPEG4 compatible frame header */ -void ff_msmpeg4_encode_picture_header(MpegEncContext * s, int picture_number) +void ff_msmpeg4_encode_picture_header(MPVMainEncContext *s, int picture_number) { MSMPEG4EncContext *const ms = (MSMPEG4EncContext*)s; @@ -278,7 +276,7 @@ void ff_msmpeg4_encode_picture_header(MpegEncContext * s, int picture_number) s->esc3_run_length= 0; } -void ff_msmpeg4_encode_ext_header(MpegEncContext * s) +void ff_msmpeg4_encode_ext_header(MPVEncContext *s) { unsigned fps = s->avctx->time_base.den / s->avctx->time_base.num / FFMAX(s->avctx->ticks_per_frame, 1); put_bits(&s->pb, 5, FFMIN(fps, 31)); //yes 29.97 -> 29 @@ -291,7 +289,7 @@ void ff_msmpeg4_encode_ext_header(MpegEncContext * s) av_assert0(s->flipflop_rounding==0); } -void ff_msmpeg4_encode_motion(MpegEncContext * s, +void ff_msmpeg4_encode_motion(MPVEncContext *s, int mx, int my) { int code; @@ -324,7 +322,8 @@ void ff_msmpeg4_encode_motion(MpegEncContext * s, } } -void ff_msmpeg4_handle_slices(MpegEncContext *s){ +void ff_msmpeg4_handle_slices(MPVEncContext *s) +{ if (s->mb_x == 0) { if (s->slice_height && (s->mb_y % s->slice_height) == 0) { if(s->msmpeg4_version < 4){ @@ -337,7 +336,7 @@ void ff_msmpeg4_handle_slices(MpegEncContext *s){ } } -static void msmpeg4v2_encode_motion(MpegEncContext * s, int val) +static void msmpeg4v2_encode_motion(MPVEncContext *s, int val) { int range, bit_size, sign, code, bits; @@ -370,7 +369,7 @@ static void msmpeg4v2_encode_motion(MpegEncContext * s, int val) } } -void ff_msmpeg4_encode_mb(MpegEncContext * s, +void ff_msmpeg4_encode_mb(MPVEncContext *s, int16_t block[6][64], int motion_x, int motion_y) { @@ -493,7 +492,7 @@ void ff_msmpeg4_encode_mb(MpegEncContext * s, } } -static void msmpeg4_encode_dc(MpegEncContext * s, int level, int n, int *dir_ptr) +static void msmpeg4_encode_dc(MPVEncContext *s, int level, int n, int *dir_ptr) { int sign, code; int pred; @@ -556,7 +555,7 @@ static void msmpeg4_encode_dc(MpegEncContext * s, int level, int n, int *dir_ptr /* Encoding of a block; very similar to MPEG-4 except for a different * escape coding (same as H.263) and more VLC tables. */ -void ff_msmpeg4_encode_block(MpegEncContext * s, int16_t * block, int n) +void ff_msmpeg4_encode_block(MPVEncContext *s, int16_t *block, int n) { MSMPEG4EncContext *const ms = (MSMPEG4EncContext*)s; int level, run, last, i, j, last_index; diff --git a/libavcodec/msmpeg4enc.h b/libavcodec/msmpeg4enc.h index 98044913b1..f03e94ff22 100644 --- a/libavcodec/msmpeg4enc.h +++ b/libavcodec/msmpeg4enc.h @@ -23,25 +23,25 @@ #define AVCODEC_MSMPEG4ENC_H #include "config.h" -#include "mpegvideo.h" +#include "mpegvideoenc.h" #include "put_bits.h" #include "rl.h" typedef struct MSMPEG4EncContext { - MpegEncContext s; + MPVMainEncContext s; /** [mb_intra][isChroma][level][run][last] */ unsigned ac_stats[2][2][MAX_LEVEL + 1][MAX_RUN + 1][2]; } MSMPEG4EncContext; -void ff_msmpeg4_encode_init(MpegEncContext *s); -void ff_msmpeg4_encode_picture_header(MpegEncContext *s, int picture_number); -void ff_msmpeg4_encode_ext_header(MpegEncContext *s); -void ff_msmpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64], +void ff_msmpeg4_encode_init(MPVMainEncContext *m); +void ff_msmpeg4_encode_picture_header(MPVMainEncContext *m, int picture_number); +void ff_msmpeg4_encode_ext_header(MPVEncContext *s); +void ff_msmpeg4_encode_mb(MPVEncContext *s, int16_t block[6][64], int motion_x, int motion_y); -void ff_msmpeg4_encode_block(MpegEncContext * s, int16_t * block, int n); -void ff_msmpeg4_handle_slices(MpegEncContext *s); -void ff_msmpeg4_encode_motion(MpegEncContext * s, int mx, int my); +void ff_msmpeg4_encode_block(MPVEncContext *s, int16_t *block, int n); +void ff_msmpeg4_handle_slices(MPVEncContext *s); +void ff_msmpeg4_encode_motion(MPVEncContext *s, int mx, int my); void ff_msmpeg4_code012(PutBitContext *pb, int n); diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c index 65decf0a3c..2a89bd47e8 100644 --- a/libavcodec/mss2.c +++ b/libavcodec/mss2.c @@ -382,7 +382,7 @@ static int decode_wmv9(AVCodecContext *avctx, const uint8_t *buf, int buf_size, MSS2Context *ctx = avctx->priv_data; MSS12Context *c = &ctx->c; VC1Context *v = avctx->priv_data; - MpegEncContext *s = &v->s; + MPVMainDecContext *const s = &v->s; AVFrame *f; int ret; diff --git a/libavcodec/neon/mpegvideo.c b/libavcodec/neon/mpegvideo.c index 8f05d77a65..5c5b5e4b54 100644 --- a/libavcodec/neon/mpegvideo.c +++ b/libavcodec/neon/mpegvideo.c @@ -83,7 +83,7 @@ static void inline ff_dct_unquantize_h263_neon(int qscale, int qadd, int nCoeffs vst1_s16(block, d0s16); } -static void dct_unquantize_h263_inter_neon(MpegEncContext *s, int16_t *block, +static void dct_unquantize_h263_inter_neon(MPVContext *s, int16_t *block, int n, int qscale) { int nCoeffs = s->inter_scantable.raster_end[s->block_last_index[n]]; @@ -92,7 +92,7 @@ static void dct_unquantize_h263_inter_neon(MpegEncContext *s, int16_t *block, ff_dct_unquantize_h263_neon(qscale, qadd, nCoeffs + 1, block); } -static void dct_unquantize_h263_intra_neon(MpegEncContext *s, int16_t *block, +static void dct_unquantize_h263_intra_neon(MPVContext *s, int16_t *block, int n, int qscale) { int qadd; @@ -124,7 +124,7 @@ static void dct_unquantize_h263_intra_neon(MpegEncContext *s, int16_t *block, } -av_cold void ff_mpv_common_init_neon(MpegEncContext *s) +av_cold void ff_mpv_common_init_neon(MPVContext *s) { int cpu_flags = av_get_cpu_flags(); diff --git a/libavcodec/nvdec_mpeg12.c b/libavcodec/nvdec_mpeg12.c index b8db4250bb..563f71296b 100644 --- a/libavcodec/nvdec_mpeg12.c +++ b/libavcodec/nvdec_mpeg12.c @@ -22,13 +22,13 @@ #include "avcodec.h" #include "internal.h" -#include "mpegvideo.h" +#include "mpegvideodec.h" #include "nvdec.h" #include "decode.h" static int nvdec_mpeg12_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) { - MpegEncContext *s = avctx->priv_data; + MPVDecContext *const s = avctx->priv_data; NVDECContext *ctx = avctx->internal->hwaccel_priv_data; CUVIDPICPARAMS *pp = &ctx->pic_params; diff --git a/libavcodec/nvdec_mpeg4.c b/libavcodec/nvdec_mpeg4.c index b7e1821754..b00e415b5c 100644 --- a/libavcodec/nvdec_mpeg4.c +++ b/libavcodec/nvdec_mpeg4.c @@ -30,7 +30,7 @@ static int nvdec_mpeg4_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) { Mpeg4DecContext *m = avctx->priv_data; - MpegEncContext *s = &m->m; + MPVDecContext *const s = &m->m; NVDECContext *ctx = avctx->internal->hwaccel_priv_data; CUVIDPICPARAMS *pp = &ctx->pic_params; diff --git a/libavcodec/nvdec_vc1.c b/libavcodec/nvdec_vc1.c index 10e7b5ab0d..9dc9f49b6a 100644 --- a/libavcodec/nvdec_vc1.c +++ b/libavcodec/nvdec_vc1.c @@ -28,7 +28,7 @@ static int nvdec_vc1_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) { VC1Context *v = avctx->priv_data; - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; NVDECContext *ctx = avctx->internal->hwaccel_priv_data; CUVIDPICPARAMS *pp = &ctx->pic_params; diff --git a/libavcodec/ppc/me_cmp.c b/libavcodec/ppc/me_cmp.c index 17f9a4f016..31a1881f01 100644 --- a/libavcodec/ppc/me_cmp.c +++ b/libavcodec/ppc/me_cmp.c @@ -28,7 +28,7 @@ #include "libavutil/ppc/util_altivec.h" #include "libavcodec/avcodec.h" -#include "libavcodec/mpegvideo.h" +#include "libavcodec/mpegvideoenc.h" #include "libavcodec/me_cmp.h" #if HAVE_ALTIVEC @@ -51,7 +51,7 @@ iv = vec_vsx_ld(1, pix);\ } #endif -static int sad16_x2_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +static int sad16_x2_altivec(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { int i; @@ -91,7 +91,7 @@ static int sad16_x2_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, return s; } -static int sad16_y2_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +static int sad16_y2_altivec(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { int i; @@ -141,7 +141,7 @@ static int sad16_y2_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, return s; } -static int sad16_xy2_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +static int sad16_xy2_altivec(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { int i; @@ -230,7 +230,7 @@ static int sad16_xy2_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, return s; } -static int sad16_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +static int sad16_altivec(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { int i; @@ -265,7 +265,7 @@ static int sad16_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, return s; } -static int sad8_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +static int sad8_altivec(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { int i; @@ -309,7 +309,7 @@ static int sad8_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, /* Sum of Squared Errors for an 8x8 block, AltiVec-enhanced. * It's the sad8_altivec code above w/ squaring added. */ -static int sse8_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +static int sse8_altivec(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { int i; @@ -354,7 +354,7 @@ static int sse8_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, /* Sum of Squared Errors for a 16x16 block, AltiVec-enhanced. * It's the sad16_altivec code above w/ squaring added. */ -static int sse16_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +static int sse16_altivec(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { int i; @@ -392,7 +392,7 @@ static int sse16_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, return s; } -static int hadamard8_diff8x8_altivec(MpegEncContext *s, uint8_t *dst, +static int hadamard8_diff8x8_altivec(MPVEncContext *s, uint8_t *dst, uint8_t *src, ptrdiff_t stride, int h) { int __attribute__((aligned(16))) sum; @@ -518,7 +518,7 @@ static int hadamard8_diff8x8_altivec(MpegEncContext *s, uint8_t *dst, * On the 970, the hand-made RA is still a win (around 690 vs. around 780), * but xlc goes to around 660 on the regular C code... */ -static int hadamard8_diff16x8_altivec(MpegEncContext *s, uint8_t *dst, +static int hadamard8_diff16x8_altivec(MPVEncContext *s, uint8_t *dst, uint8_t *src, ptrdiff_t stride, int h) { int __attribute__((aligned(16))) sum; @@ -709,7 +709,7 @@ static int hadamard8_diff16x8_altivec(MpegEncContext *s, uint8_t *dst, return sum; } -static int hadamard8_diff16_altivec(MpegEncContext *s, uint8_t *dst, +static int hadamard8_diff16_altivec(MPVEncContext *s, uint8_t *dst, uint8_t *src, ptrdiff_t stride, int h) { int score = hadamard8_diff16x8_altivec(s, dst, src, stride, 8); diff --git a/libavcodec/ppc/mpegvideo_altivec.c b/libavcodec/ppc/mpegvideo_altivec.c index bcb59ba845..5660b29109 100644 --- a/libavcodec/ppc/mpegvideo_altivec.c +++ b/libavcodec/ppc/mpegvideo_altivec.c @@ -38,7 +38,7 @@ /* AltiVec version of dct_unquantize_h263 this code assumes `block' is 16 bytes-aligned */ -static void dct_unquantize_h263_altivec(MpegEncContext *s, +static void dct_unquantize_h263_altivec(MPVContext *s, int16_t *block, int n, int qscale) { int i, level, qmul, qadd; @@ -116,7 +116,7 @@ static void dct_unquantize_h263_altivec(MpegEncContext *s, #endif /* HAVE_ALTIVEC */ -av_cold void ff_mpv_common_init_ppc(MpegEncContext *s) +av_cold void ff_mpv_common_init_ppc(MPVContext *s) { #if HAVE_ALTIVEC if (!PPC_ALTIVEC(av_get_cpu_flags())) diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c index f814e23ed5..c5088d6790 100644 --- a/libavcodec/ratecontrol.c +++ b/libavcodec/ratecontrol.c @@ -35,7 +35,7 @@ #include "mpegvideoenc.h" #include "libavutil/eval.h" -void ff_write_pass1_stats(MpegEncContext *s) +void ff_write_pass1_stats(MPVMainEncContext *s) { snprintf(s->avctx->stats_out, 256, "in:%d out:%d type:%d q:%d itex:%d ptex:%d mv:%d misc:%d " @@ -77,7 +77,7 @@ static inline double bits2qp(RateControlEntry *rce, double bits) return rce->qscale * (double)(rce->i_tex_bits + rce->p_tex_bits + 1) / bits; } -static double get_diff_limited_q(MpegEncContext *s, RateControlEntry *rce, double q) +static double get_diff_limited_q(MPVMainEncContext *s, RateControlEntry *rce, double q) { RateControlContext *rcc = &s->rc_context; AVCodecContext *a = s->avctx; @@ -116,7 +116,7 @@ static double get_diff_limited_q(MpegEncContext *s, RateControlEntry *rce, doubl /** * Get the qmin & qmax for pict_type. */ -static void get_qminmax(int *qmin_ret, int *qmax_ret, MpegEncContext *s, int pict_type) +static void get_qminmax(int *qmin_ret, int *qmax_ret, MPVMainEncContext *s, int pict_type) { int qmin = s->lmin; int qmax = s->lmax; @@ -144,7 +144,7 @@ static void get_qminmax(int *qmin_ret, int *qmax_ret, MpegEncContext *s, int pic *qmax_ret = qmax; } -static double modify_qscale(MpegEncContext *s, RateControlEntry *rce, +static double modify_qscale(MPVMainEncContext *s, RateControlEntry *rce, double q, int frame_num) { RateControlContext *rcc = &s->rc_context; @@ -235,7 +235,7 @@ static double modify_qscale(MpegEncContext *s, RateControlEntry *rce, /** * Modify the bitrate curve from pass1 for one frame. */ -static double get_qscale(MpegEncContext *s, RateControlEntry *rce, +static double get_qscale(MPVMainEncContext *s, RateControlEntry *rce, double rate_factor, int frame_num) { RateControlContext *rcc = &s->rc_context; @@ -308,7 +308,7 @@ static double get_qscale(MpegEncContext *s, RateControlEntry *rce, return q; } -static int init_pass2(MpegEncContext *s) +static int init_pass2(MPVMainEncContext *s) { RateControlContext *rcc = &s->rc_context; AVCodecContext *a = s->avctx; @@ -469,7 +469,7 @@ static int init_pass2(MpegEncContext *s) return 0; } -av_cold int ff_rate_control_init(MpegEncContext *s) +av_cold int ff_rate_control_init(MPVMainEncContext *s) { RateControlContext *rcc = &s->rc_context; int i, res; @@ -669,7 +669,7 @@ av_cold int ff_rate_control_init(MpegEncContext *s) return 0; } -av_cold void ff_rate_control_uninit(MpegEncContext *s) +av_cold void ff_rate_control_uninit(MPVMainEncContext *s) { RateControlContext *rcc = &s->rc_context; emms_c(); @@ -678,7 +678,7 @@ av_cold void ff_rate_control_uninit(MpegEncContext *s) av_freep(&rcc->entry); } -int ff_vbv_update(MpegEncContext *s, int frame_size) +int ff_vbv_update(MPVMainEncContext *s, int frame_size) { RateControlContext *rcc = &s->rc_context; const double fps = get_fps(s->avctx); @@ -737,7 +737,7 @@ static void update_predictor(Predictor *p, double q, double var, double size) p->coeff += new_coeff; } -static void adaptive_quantization(MpegEncContext *s, double q) +static void adaptive_quantization(MPVMainEncContext *s, double q) { int i; const float lumi_masking = s->avctx->lumi_masking / (128.0 * 128.0); @@ -854,7 +854,7 @@ static void adaptive_quantization(MpegEncContext *s, double q) } } -void ff_get_2pass_fcode(MpegEncContext *s) +void ff_get_2pass_fcode(MPVMainEncContext *s) { RateControlContext *rcc = &s->rc_context; RateControlEntry *rce = &rcc->entry[s->picture_number]; @@ -865,7 +865,7 @@ void ff_get_2pass_fcode(MpegEncContext *s) // FIXME rd or at least approx for dquant -float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run) +float ff_rate_estimate_qscale(MPVMainEncContext *s, int dry_run) { float q; int qmin, qmax; diff --git a/libavcodec/ratecontrol.h b/libavcodec/ratecontrol.h index 2a7aaec644..23f41dcca2 100644 --- a/libavcodec/ratecontrol.h +++ b/libavcodec/ratecontrol.h @@ -86,14 +86,16 @@ typedef struct RateControlContext{ AVExpr * rc_eq_eval; }RateControlContext; -struct MpegEncContext; +#define MPVMainEncContext MPVContext +struct MPVMainEncContext; /* rate control */ -int ff_rate_control_init(struct MpegEncContext *s); -float ff_rate_estimate_qscale(struct MpegEncContext *s, int dry_run); -void ff_write_pass1_stats(struct MpegEncContext *s); -void ff_rate_control_uninit(struct MpegEncContext *s); -int ff_vbv_update(struct MpegEncContext *s, int frame_size); -void ff_get_2pass_fcode(struct MpegEncContext *s); +int ff_rate_control_init(struct MPVMainEncContext *m); +float ff_rate_estimate_qscale(struct MPVMainEncContext *m, int dry_run); +void ff_write_pass1_stats(struct MPVMainEncContext *m); +void ff_rate_control_uninit(struct MPVMainEncContext *m); +int ff_vbv_update(struct MPVMainEncContext *m, int frame_size); +void ff_get_2pass_fcode(struct MPVMainEncContext *m); +#undef MPVMainEncContext #endif /* AVCODEC_RATECONTROL_H */ diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c index 26cb9a2294..10450aa791 100644 --- a/libavcodec/rv10.c +++ b/libavcodec/rv10.c @@ -52,7 +52,7 @@ #define DC_VLC_BITS 9 typedef struct RVDecContext { - MpegEncContext m; + MPVMainDecContext m; int sub_id; int orig_width, orig_height; } RVDecContext; @@ -80,7 +80,7 @@ static const uint16_t rv_chrom_len_count[15] = { static VLC rv_dc_lum, rv_dc_chrom; -int ff_rv_decode_dc(MpegEncContext *s, int n) +int ff_rv_decode_dc(MPVDecContext *s, int n) { int code; @@ -97,7 +97,7 @@ int ff_rv_decode_dc(MpegEncContext *s, int n) } /* read RV 1.0 compatible frame header */ -static int rv10_decode_picture_header(MpegEncContext *s) +static int rv10_decode_picture_header(MPVDecContext *s) { int mb_count, pb_frame, marker, mb_xy; @@ -157,7 +157,7 @@ static int rv10_decode_picture_header(MpegEncContext *s) static int rv20_decode_picture_header(RVDecContext *rv, int whole_size) { - MpegEncContext *s = &rv->m; + MPVMainDecContext *const s = &rv->m; int seq, mb_pos, i, ret; int rpr_max; @@ -367,7 +367,7 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx) { static AVOnce init_static_once = AV_ONCE_INIT; RVDecContext *rv = avctx->priv_data; - MpegEncContext *s = &rv->m; + MPVMainDecContext *const s = &rv->m; int major_ver, minor_ver, micro_ver, ret; if (avctx->extradata_size < 8) { @@ -433,7 +433,7 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx) static av_cold int rv10_decode_end(AVCodecContext *avctx) { - MpegEncContext *s = avctx->priv_data; + MPVMainDecContext *const s = avctx->priv_data; ff_mpv_common_end(s); return 0; @@ -443,7 +443,7 @@ static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf, int buf_size, int buf_size2, int whole_size) { RVDecContext *rv = avctx->priv_data; - MpegEncContext *s = &rv->m; + MPVDecContext *const s = &rv->m; int mb_count, mb_pos, left, start_mb_x, active_bits_size, ret; active_bits_size = buf_size * 8; @@ -597,7 +597,7 @@ static int rv10_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; - MpegEncContext *s = avctx->priv_data; + MPVMainDecContext *const s = avctx->priv_data; AVFrame *pict = data; int i, ret; int slice_count; diff --git a/libavcodec/rv10dec.h b/libavcodec/rv10dec.h index daa6b8d653..7cd9de9a2e 100644 --- a/libavcodec/rv10dec.h +++ b/libavcodec/rv10dec.h @@ -21,8 +21,8 @@ #ifndef AVCODEC_RV10DEC_H #define AVCODEC_RV10DEC_H -#include "mpegvideo.h" +#include "mpegvideodec.h" -int ff_rv_decode_dc(MpegEncContext *s, int n); +int ff_rv_decode_dc(MPVDecContext *s, int n); #endif /* AVCODEC_RV10DEC_H */ diff --git a/libavcodec/rv10enc.c b/libavcodec/rv10enc.c index a9922bda50..6c9305d7fe 100644 --- a/libavcodec/rv10enc.c +++ b/libavcodec/rv10enc.c @@ -25,12 +25,11 @@ * RV10 encoder */ -#include "mpegvideo.h" #include "mpegvideoenc.h" #include "put_bits.h" #include "rv10enc.h" -int ff_rv10_encode_picture_header(MpegEncContext *s, int picture_number) +int ff_rv10_encode_picture_header(MPVMainEncContext *s, int picture_number) { int full_frame= 0; @@ -70,7 +69,7 @@ const AVCodec ff_rv10_encoder = { .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_RV10, .priv_class = &ff_mpv_enc_class, - .priv_data_size = sizeof(MpegEncContext), + .priv_data_size = sizeof(MPVMainEncContext), .init = ff_mpv_encode_init, .encode2 = ff_mpv_encode_picture, .close = ff_mpv_encode_end, diff --git a/libavcodec/rv10enc.h b/libavcodec/rv10enc.h index 66672f8087..384f775dbc 100644 --- a/libavcodec/rv10enc.h +++ b/libavcodec/rv10enc.h @@ -21,9 +21,9 @@ #ifndef AVCODEC_RV10ENC_H #define AVCODEC_RV10ENC_H -#include "mpegvideo.h" +#include "mpegvideoenc.h" -int ff_rv10_encode_picture_header(MpegEncContext *s, int picture_number); -void ff_rv20_encode_picture_header(MpegEncContext *s, int picture_number); +int ff_rv10_encode_picture_header(MPVMainEncContext *m, int picture_number); +void ff_rv20_encode_picture_header(MPVMainEncContext *m, int picture_number); #endif /* AVCODEC_RV10ENC_H */ diff --git a/libavcodec/rv20enc.c b/libavcodec/rv20enc.c index 1baeea0b7d..a4b4bad277 100644 --- a/libavcodec/rv20enc.c +++ b/libavcodec/rv20enc.c @@ -25,7 +25,6 @@ * RV20 encoder */ -#include "mpegvideo.h" #include "mpegvideodata.h" #include "mpegvideoenc.h" #include "h263data.h" @@ -33,7 +32,8 @@ #include "put_bits.h" #include "rv10enc.h" -void ff_rv20_encode_picture_header(MpegEncContext *s, int picture_number){ +void ff_rv20_encode_picture_header(MPVMainEncContext *s, int picture_number) +{ put_bits(&s->pb, 2, s->pict_type); //I 0 vs. 1 ? put_bits(&s->pb, 1, 0); /* unknown bit */ put_bits(&s->pb, 5, s->qscale); @@ -67,7 +67,7 @@ const AVCodec ff_rv20_encoder = { .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_RV20, .priv_class = &ff_mpv_enc_class, - .priv_data_size = sizeof(MpegEncContext), + .priv_data_size = sizeof(MPVMainEncContext), .init = ff_mpv_encode_init, .encode2 = ff_mpv_encode_picture, .close = ff_mpv_encode_end, diff --git a/libavcodec/rv30.c b/libavcodec/rv30.c index c84e09dd1a..698765bef4 100644 --- a/libavcodec/rv30.c +++ b/libavcodec/rv30.c @@ -117,7 +117,7 @@ static int rv30_decode_mb_info(RV34DecContext *r) { static const int rv30_p_types[6] = { RV34_MB_SKIP, RV34_MB_P_16x16, RV34_MB_P_8x8, -1, RV34_MB_TYPE_INTRA, RV34_MB_TYPE_INTRA16x16 }; static const int rv30_b_types[6] = { RV34_MB_SKIP, RV34_MB_B_DIRECT, RV34_MB_B_FORWARD, RV34_MB_B_BACKWARD, RV34_MB_TYPE_INTRA, RV34_MB_TYPE_INTRA16x16 }; - MpegEncContext *s = &r->s; + MPVDecContext *const s = &r->s; GetBitContext *gb = &s->gb; unsigned code = get_interleaved_ue_golomb(gb); @@ -152,7 +152,7 @@ static inline void rv30_weak_loop_filter(uint8_t *src, const int step, static void rv30_loop_filter(RV34DecContext *r, int row) { - MpegEncContext *s = &r->s; + MPVDecContext *const s = &r->s; int mb_pos, mb_x; int i, j, k; uint8_t *Y, *C; diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index bfef5f84cc..83d601c57b 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -346,7 +346,7 @@ static inline RV34VLC* choose_vlc_set(int quant, int mod, int type) */ static int rv34_decode_intra_mb_header(RV34DecContext *r, int8_t *intra_types) { - MpegEncContext *s = &r->s; + MPVDecContext *const s = &r->s; GetBitContext *gb = &s->gb; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; int t; @@ -381,7 +381,7 @@ static int rv34_decode_intra_mb_header(RV34DecContext *r, int8_t *intra_types) */ static int rv34_decode_inter_mb_header(RV34DecContext *r, int8_t *intra_types) { - MpegEncContext *s = &r->s; + MPVDecContext *const s = &r->s; GetBitContext *gb = &s->gb; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; int i, t; @@ -459,7 +459,7 @@ static const uint8_t avail_indexes[4] = { 6, 7, 10, 11 }; */ static void rv34_pred_mv(RV34DecContext *r, int block_type, int subblock_no, int dmv_no) { - MpegEncContext *s = &r->s; + MPVDecContext *const s = &r->s; int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride; int A[2] = {0}, B[2], C[2]; int i, j; @@ -543,7 +543,7 @@ static inline void rv34_pred_b_vector(int A[2], int B[2], int C[2], */ static void rv34_pred_mv_b(RV34DecContext *r, int block_type, int dir) { - MpegEncContext *s = &r->s; + MPVDecContext *const s = &r->s; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride; int A[2] = { 0 }, B[2] = { 0 }, C[2] = { 0 }; @@ -595,7 +595,7 @@ static void rv34_pred_mv_b(RV34DecContext *r, int block_type, int dir) */ static void rv34_pred_mv_rv3(RV34DecContext *r, int block_type, int dir) { - MpegEncContext *s = &r->s; + MPVDecContext *const s = &r->s; int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride; int A[2] = {0}, B[2], C[2]; int i, j, k; @@ -663,7 +663,7 @@ static inline void rv34_mc(RV34DecContext *r, const int block_type, qpel_mc_func (*qpel_mc)[16], h264_chroma_mc_func (*chroma_mc)) { - MpegEncContext *s = &r->s; + MPVDecContext *const s = &r->s; uint8_t *Y, *U, *V, *srcY, *srcU, *srcV; int dxy, mx, my, umx, umy, lx, ly, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y; int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride + mv_off; @@ -851,7 +851,7 @@ static const int num_mvs[RV34_MB_TYPES] = { 0, 0, 1, 4, 1, 1, 0, 0, 2, 2, 2, 1 } */ static int rv34_decode_mv(RV34DecContext *r, int block_type) { - MpegEncContext *s = &r->s; + MPVDecContext *const s = &r->s; GetBitContext *gb = &s->gb; int i, j, k, l; int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride; @@ -1010,7 +1010,7 @@ static inline void rv34_process_block(RV34DecContext *r, uint8_t *pdst, int stride, int fc, int sc, int q_dc, int q_ac) { - MpegEncContext *s = &r->s; + MPVDecContext *const s = &r->s; int16_t *ptr = s->block[0]; int has_ac = rv34_decode_block(ptr, &s->gb, r->cur_vlcs, fc, sc, q_dc, q_ac, q_ac); @@ -1025,7 +1025,7 @@ static inline void rv34_process_block(RV34DecContext *r, static void rv34_output_i16x16(RV34DecContext *r, int8_t *intra_types, int cbp) { LOCAL_ALIGNED_16(int16_t, block16, [16]); - MpegEncContext *s = &r->s; + MPVDecContext *const s = &r->s; GetBitContext *gb = &s->gb; int q_dc = rv34_qscale_tab[ r->luma_dc_quant_i[s->qscale] ], q_ac = rv34_qscale_tab[s->qscale]; @@ -1087,7 +1087,7 @@ static void rv34_output_i16x16(RV34DecContext *r, int8_t *intra_types, int cbp) static void rv34_output_intra(RV34DecContext *r, int8_t *intra_types, int cbp) { - MpegEncContext *s = &r->s; + MPVDecContext *const s = &r->s; uint8_t *dst = s->dest[0]; int avail[6*8] = {0}; int i, j, k; @@ -1163,7 +1163,7 @@ static int is_mv_diff_gt_3(int16_t (*motion_val)[2], int step) static int rv34_set_deblock_coef(RV34DecContext *r) { - MpegEncContext *s = &r->s; + MPVDecContext *const s = &r->s; int hmvmask = 0, vmvmask = 0, i, j; int midx = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride; int16_t (*motion_val)[2] = &s->current_picture_ptr->motion_val[0][midx]; @@ -1193,7 +1193,7 @@ static int rv34_set_deblock_coef(RV34DecContext *r) static int rv34_decode_inter_macroblock(RV34DecContext *r, int8_t *intra_types) { - MpegEncContext *s = &r->s; + MPVDecContext *const s = &r->s; GetBitContext *gb = &s->gb; uint8_t *dst = s->dest[0]; int16_t *ptr = s->block[0]; @@ -1301,7 +1301,7 @@ static int rv34_decode_inter_macroblock(RV34DecContext *r, int8_t *intra_types) static int rv34_decode_intra_macroblock(RV34DecContext *r, int8_t *intra_types) { - MpegEncContext *s = &r->s; + MPVDecContext *const s = &r->s; int cbp, dist; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; @@ -1339,7 +1339,7 @@ static int rv34_decode_intra_macroblock(RV34DecContext *r, int8_t *intra_types) return 0; } -static int check_slice_end(RV34DecContext *r, MpegEncContext *s) +static int check_slice_end(RV34DecContext *r, MPVDecContext *s) { int bits; if(s->mb_y >= s->mb_height) @@ -1404,7 +1404,7 @@ static int rv34_decoder_realloc(RV34DecContext *r) static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int buf_size) { - MpegEncContext *s = &r->s; + MPVDecContext *const s = &r->s; GetBitContext *gb = &s->gb; int mb_pos, slice_type; int res; @@ -1488,7 +1488,7 @@ av_cold int ff_rv34_decode_init(AVCodecContext *avctx) { static AVOnce init_static_once = AV_ONCE_INIT; RV34DecContext *r = avctx->priv_data; - MpegEncContext *s = &r->s; + MPVMainDecContext *const s = &r->s; int ret; ff_mpv_decode_init(s, avctx); @@ -1517,7 +1517,8 @@ av_cold int ff_rv34_decode_init(AVCodecContext *avctx) int ff_rv34_decode_update_thread_context(AVCodecContext *dst, const AVCodecContext *src) { RV34DecContext *r = dst->priv_data, *r1 = src->priv_data; - MpegEncContext * const s = &r->s, * const s1 = &r1->s; + MPVMainDecContext *const s = &r->s; + const MPVMainDecContext *const s1 = &r1->s; int err; if (dst == src || !s1->context_initialized) @@ -1558,7 +1559,7 @@ static int get_slice_offset(AVCodecContext *avctx, const uint8_t *buf, int n, in static int finish_frame(AVCodecContext *avctx, AVFrame *pict) { RV34DecContext *r = avctx->priv_data; - MpegEncContext *s = &r->s; + MPVMainDecContext *const s = &r->s; int got_picture = 0, ret; ff_er_frame_end(&s->er); @@ -1602,7 +1603,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; RV34DecContext *r = avctx->priv_data; - MpegEncContext *s = &r->s; + MPVMainDecContext *const s = &r->s; AVFrame *pict = data; SliceInfo si; int i, ret; diff --git a/libavcodec/rv34.h b/libavcodec/rv34.h index 53b29dc245..2e71fe4047 100644 --- a/libavcodec/rv34.h +++ b/libavcodec/rv34.h @@ -30,7 +30,7 @@ #include "libavutil/mem_internal.h" #include "avcodec.h" -#include "mpegvideo.h" +#include "mpegvideodec.h" #include "h264pred.h" #include "rv34dsp.h" @@ -84,7 +84,7 @@ typedef struct SliceInfo{ /** decoder context */ typedef struct RV34DecContext{ - MpegEncContext s; + MPVMainDecContext s; RV34DSPContext rdsp; int8_t *intra_types_hist;///< old block types, used for prediction int8_t *intra_types; ///< block types diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c index 9cec0751e1..cc069b3f2b 100644 --- a/libavcodec/rv40.c +++ b/libavcodec/rv40.c @@ -169,7 +169,7 @@ static int rv40_parse_slice_header(RV34DecContext *r, GetBitContext *gb, SliceIn */ static int rv40_decode_intra_types(RV34DecContext *r, GetBitContext *gb, int8_t *dst) { - MpegEncContext *s = &r->s; + MPVDecContext *const s = &r->s; int i, j, k, v; int A, B, C; int pattern; @@ -231,7 +231,7 @@ static int rv40_decode_intra_types(RV34DecContext *r, GetBitContext *gb, int8_t */ static int rv40_decode_mb_info(RV34DecContext *r) { - MpegEncContext *s = &r->s; + MPVDecContext *const s = &r->s; GetBitContext *gb = &s->gb; int q, i; int prev_type = 0; @@ -341,7 +341,7 @@ static void rv40_adaptive_loop_filter(RV34DSPContext *rdsp, */ static void rv40_loop_filter(RV34DecContext *r, int row) { - MpegEncContext *s = &r->s; + MPVDecContext *const s = &r->s; int mb_pos, mb_x; int i, j, k; uint8_t *Y, *C; diff --git a/libavcodec/snow.h b/libavcodec/snow.h index f5beca66e9..2e09025277 100644 --- a/libavcodec/snow.h +++ b/libavcodec/snow.h @@ -32,7 +32,7 @@ #include "rangecoder.h" #include "mathops.h" -#include "mpegvideo.h" +#include "mpegvideoenc.h" #include "h264qpel.h" #define SNOW_MAX_PLANES 4 @@ -182,7 +182,7 @@ typedef struct SnowContext{ int iterative_dia_size; int scenechange_threshold; - MpegEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to eventually make the motion estimation independent of MpegEncContext, so this will be removed then (FIXME/XXX) + MPVMainEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to eventually make the motion estimation independent of mpegvideo, so this will be removed then (FIXME/XXX) uint8_t *scratchbuf; uint8_t *emu_edge_buffer; diff --git a/libavcodec/snow_dwt.c b/libavcodec/snow_dwt.c index c093ebff07..8d717b6bf8 100644 --- a/libavcodec/snow_dwt.c +++ b/libavcodec/snow_dwt.c @@ -25,6 +25,8 @@ #include "me_cmp.h" #include "snow_dwt.h" +#define MPVEncContext MPVContext + int ff_slice_buffer_init(slice_buffer *buf, int line_count, int max_allocated_lines, int line_width, IDWTELEM *base_buffer) @@ -740,7 +742,7 @@ void ff_spatial_idwt(IDWTELEM *buffer, IDWTELEM *temp, int width, int height, decomposition_count, y); } -static inline int w_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, +static inline int w_c(struct MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int w, int h, int type) { int s, i, j; @@ -809,32 +811,32 @@ static inline int w_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, pt return s >> 9; } -static int w53_8_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h) +static int w53_8_c(struct MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h) { return w_c(v, pix1, pix2, line_size, 8, h, 1); } -static int w97_8_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h) +static int w97_8_c(struct MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h) { return w_c(v, pix1, pix2, line_size, 8, h, 0); } -static int w53_16_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h) +static int w53_16_c(struct MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h) { return w_c(v, pix1, pix2, line_size, 16, h, 1); } -static int w97_16_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h) +static int w97_16_c(struct MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h) { return w_c(v, pix1, pix2, line_size, 16, h, 0); } -int ff_w53_32_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h) +int ff_w53_32_c(struct MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h) { return w_c(v, pix1, pix2, line_size, 32, h, 1); } -int ff_w97_32_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h) +int ff_w97_32_c(struct MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h) { return w_c(v, pix1, pix2, line_size, 32, h, 0); } diff --git a/libavcodec/snow_dwt.h b/libavcodec/snow_dwt.h index 390bc57130..b132961383 100644 --- a/libavcodec/snow_dwt.h +++ b/libavcodec/snow_dwt.h @@ -24,7 +24,8 @@ #include #include -struct MpegEncContext; +#define MPVEncContext MPVContext +struct MPVEncContext; typedef int DWTELEM; typedef short IDWTELEM; @@ -104,8 +105,8 @@ void ff_snow_inner_add_yblock(const uint8_t *obmc, const int obmc_stride, int src_y, int src_stride, slice_buffer *sb, int add, uint8_t *dst8); -int ff_w53_32_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h); -int ff_w97_32_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h); +int ff_w53_32_c(struct MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h); +int ff_w97_32_c(struct MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h); void ff_spatial_dwt(int *buffer, int *temp, int width, int height, int stride, int type, int decomposition_count); @@ -123,4 +124,6 @@ void ff_spatial_idwt(IDWTELEM *buffer, IDWTELEM *temp, int width, int height, void ff_dwt_init(SnowDWTContext *c); void ff_dwt_init_x86(SnowDWTContext *c); +#undef MPVEncContext + #endif /* AVCODEC_DWT_H */ diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c index 2a8ddebb0a..be80065a32 100644 --- a/libavcodec/speedhqenc.c +++ b/libavcodec/speedhqenc.c @@ -55,7 +55,7 @@ static uint32_t speedhq_chr_dc_uni[512]; static uint8_t uni_speedhq_ac_vlc_len[64 * 64 * 2]; typedef struct SpeedHQEncContext { - MpegEncContext m; + MPVMainEncContext m; int slice_start; } SpeedHQEncContext; @@ -89,7 +89,7 @@ static av_cold void speedhq_init_static_data(void) ff_mpeg1_init_uni_ac_vlc(&ff_rl_speedhq, uni_speedhq_ac_vlc_len); } -av_cold int ff_speedhq_encode_init(MpegEncContext *s) +av_cold int ff_speedhq_encode_init(MPVMainEncContext *s) { static AVOnce init_static_once = AV_ONCE_INIT; @@ -125,7 +125,7 @@ av_cold int ff_speedhq_encode_init(MpegEncContext *s) return 0; } -void ff_speedhq_encode_picture_header(MpegEncContext *s) +void ff_speedhq_encode_picture_header(MPVMainEncContext *s) { SpeedHQEncContext *ctx = (SpeedHQEncContext*)s; @@ -137,7 +137,7 @@ void ff_speedhq_encode_picture_header(MpegEncContext *s) put_bits_le(&s->pb, 24, 0); } -void ff_speedhq_end_slice(MpegEncContext *s) +void ff_speedhq_end_slice(MPVEncContext *s) { SpeedHQEncContext *ctx = (SpeedHQEncContext*)s; int slice_len; @@ -185,7 +185,7 @@ static inline void encode_dc(PutBitContext *pb, int diff, int component) } } -static void encode_block(MpegEncContext *s, int16_t *block, int n) +static void encode_block(MPVEncContext *s, int16_t *block, int n) { int alevel, level, last_non_zero, dc, i, j, run, last_index, sign; int code; @@ -234,7 +234,7 @@ static void encode_block(MpegEncContext *s, int16_t *block, int n) put_bits_le(&s->pb, 4, 6); } -void ff_speedhq_encode_mb(MpegEncContext *s, int16_t block[12][64]) +void ff_speedhq_encode_mb(MPVEncContext *s, int16_t block[12][64]) { int i; for(i=0;i<6;i++) { diff --git a/libavcodec/speedhqenc.h b/libavcodec/speedhqenc.h index 5100bb2d34..cdee69b5cf 100644 --- a/libavcodec/speedhqenc.h +++ b/libavcodec/speedhqenc.h @@ -31,17 +31,14 @@ #include -#include "mjpeg.h" -#include "mjpegenc_common.h" -#include "mpegvideo.h" -#include "put_bits.h" +#include "mpegvideoenc.h" -int ff_speedhq_encode_init(MpegEncContext *s); -void ff_speedhq_encode_close(MpegEncContext *s); -void ff_speedhq_encode_mb(MpegEncContext *s, int16_t block[12][64]); +int ff_speedhq_encode_init (MPVMainEncContext *m); +void ff_speedhq_encode_close(MPVMainEncContext *m); +void ff_speedhq_encode_mb(MPVEncContext *s, int16_t block[12][64]); -void ff_speedhq_encode_picture_header(MpegEncContext *s); -void ff_speedhq_end_slice(MpegEncContext *s); +void ff_speedhq_encode_picture_header(MPVMainEncContext *m); +void ff_speedhq_end_slice(MPVEncContext *s); int ff_speedhq_mb_y_order_to_mb(int mb_y_order, int mb_height, int *first_in_slice); diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c index 9cef3d8ef6..7af82bb3ac 100644 --- a/libavcodec/svq1enc.c +++ b/libavcodec/svq1enc.c @@ -237,7 +237,8 @@ static int encode_block(SVQ1EncContext *s, uint8_t *src, uint8_t *ref, return best_score; } -static void init_block_index(MpegEncContext *s){ +static void init_block_index(MPVEncContext *s) +{ s->block_index[0]= s->b8_stride*(s->mb_y*2 ) + s->mb_x*2; s->block_index[1]= s->b8_stride*(s->mb_y*2 ) + 1 + s->mb_x*2; s->block_index[2]= s->b8_stride*(s->mb_y*2 + 1) + s->mb_x*2; diff --git a/libavcodec/svq1enc.h b/libavcodec/svq1enc.h index bb6af082d5..86e9a9005e 100644 --- a/libavcodec/svq1enc.h +++ b/libavcodec/svq1enc.h @@ -29,14 +29,14 @@ #include "avcodec.h" #include "hpeldsp.h" #include "me_cmp.h" -#include "mpegvideo.h" +#include "mpegvideoenc.h" #include "put_bits.h" typedef struct SVQ1EncContext { /* FIXME: Needed for motion estimation, should not be used for anything * else, the idea is to make the motion estimation eventually independent - * of MpegEncContext, so this will be removed then. */ - MpegEncContext m; + * of mpegvideoenc, so this will be removed then. */ + MPVMainEncContext m; AVCodecContext *avctx; MECmpContext mecc; HpelDSPContext hdsp; diff --git a/libavcodec/vaapi_mpeg2.c b/libavcodec/vaapi_mpeg2.c index 2c27986490..92db2c31d8 100644 --- a/libavcodec/vaapi_mpeg2.c +++ b/libavcodec/vaapi_mpeg2.c @@ -28,21 +28,21 @@ #include "vaapi_decode.h" /** Reconstruct bitstream f_code */ -static inline int mpeg2_get_f_code(const MpegEncContext *s) +static inline int mpeg2_get_f_code(const MPVDecContext *s) { return (s->mpeg_f_code[0][0] << 12) | (s->mpeg_f_code[0][1] << 8) | (s->mpeg_f_code[1][0] << 4) | s->mpeg_f_code[1][1]; } /** Determine frame start: first field for field picture or frame picture */ -static inline int mpeg2_get_is_frame_start(const MpegEncContext *s) +static inline int mpeg2_get_is_frame_start(const MPVDecContext *s) { return s->first_field || s->picture_structure == PICT_FRAME; } static int vaapi_mpeg2_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) { - const MpegEncContext *s = avctx->priv_data; + const MPVDecContext *const s = avctx->priv_data; VAAPIDecodePicture *pic = s->current_picture_ptr->hwaccel_picture_private; VAPictureParameterBufferMPEG2 pic_param; VAIQMatrixBufferMPEG2 iq_matrix; @@ -115,7 +115,7 @@ fail: static int vaapi_mpeg2_end_frame(AVCodecContext *avctx) { - MpegEncContext *s = avctx->priv_data; + MPVDecContext *const s = avctx->priv_data; VAAPIDecodePicture *pic = s->current_picture_ptr->hwaccel_picture_private; int ret; @@ -131,7 +131,7 @@ fail: static int vaapi_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) { - const MpegEncContext *s = avctx->priv_data; + const MPVDecContext *const s = avctx->priv_data; VAAPIDecodePicture *pic = s->current_picture_ptr->hwaccel_picture_private; VASliceParameterBufferMPEG2 slice_param; GetBitContext gb; diff --git a/libavcodec/vaapi_mpeg4.c b/libavcodec/vaapi_mpeg4.c index 94f31dd026..1e746ecc6a 100644 --- a/libavcodec/vaapi_mpeg4.c +++ b/libavcodec/vaapi_mpeg4.c @@ -47,7 +47,7 @@ static int mpeg4_get_intra_dc_vlc_thr(Mpeg4DecContext *s) static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) { Mpeg4DecContext *ctx = avctx->priv_data; - MpegEncContext *s = &ctx->m; + MPVDecContext *const s = &ctx->m; VAAPIDecodePicture *pic = s->current_picture_ptr->hwaccel_picture_private; VAPictureParameterBufferMPEG4 pic_param; int i, err; @@ -137,7 +137,7 @@ fail: static int vaapi_mpeg4_end_frame(AVCodecContext *avctx) { - MpegEncContext *s = avctx->priv_data; + MPVDecContext *const s = avctx->priv_data; VAAPIDecodePicture *pic = s->current_picture_ptr->hwaccel_picture_private; int ret; @@ -153,7 +153,7 @@ fail: static int vaapi_mpeg4_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) { - MpegEncContext *s = avctx->priv_data; + MPVDecContext *const s = avctx->priv_data; VAAPIDecodePicture *pic = s->current_picture_ptr->hwaccel_picture_private; VASliceParameterBufferMPEG4 slice_param; int err; diff --git a/libavcodec/vaapi_vc1.c b/libavcodec/vaapi_vc1.c index 0ae5a65fb2..6830c12236 100644 --- a/libavcodec/vaapi_vc1.c +++ b/libavcodec/vaapi_vc1.c @@ -115,7 +115,7 @@ static inline int vc1_has_FORWARDMB_bitplane(const VC1Context *v) /** Reconstruct bitstream PTYPE (7.1.1.4, index into Table-35) */ static int vc1_get_PTYPE(const VC1Context *v) { - const MpegEncContext *s = &v->s; + const MPVDecContext *const s = &v->s; switch (s->pict_type) { case AV_PICTURE_TYPE_I: return 0; case AV_PICTURE_TYPE_P: return v->p_frame_skipped ? 4 : 1; @@ -127,7 +127,7 @@ static int vc1_get_PTYPE(const VC1Context *v) /** Reconstruct bitstream FPTYPE (9.1.1.42, index into Table-105) */ static int vc1_get_FPTYPE(const VC1Context *v) { - const MpegEncContext *s = &v->s; + const MPVDecContext *const s = &v->s; switch (s->pict_type) { case AV_PICTURE_TYPE_I: return 0; case AV_PICTURE_TYPE_P: return 3; @@ -251,7 +251,7 @@ static inline void vc1_pack_bitplanes(uint8_t *bitplane, int n, const uint8_t *f static int vaapi_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) { const VC1Context *v = avctx->priv_data; - const MpegEncContext *s = &v->s; + const MPVDecContext *const s = &v->s; VAAPIDecodePicture *pic = s->current_picture_ptr->hwaccel_picture_private; VAPictureParameterBufferVC1 pic_param; int err; @@ -448,7 +448,7 @@ fail: static int vaapi_vc1_end_frame(AVCodecContext *avctx) { VC1Context *v = avctx->priv_data; - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; VAAPIDecodePicture *pic = s->current_picture_ptr->hwaccel_picture_private; int ret; @@ -465,7 +465,7 @@ fail: static int vaapi_vc1_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) { const VC1Context *v = avctx->priv_data; - const MpegEncContext *s = &v->s; + const MPVDecContext *const s = &v->s; VAAPIDecodePicture *pic = s->current_picture_ptr->hwaccel_picture_private; VASliceParameterBufferVC1 slice_param; int mb_height; diff --git a/libavcodec/vc1.h b/libavcodec/vc1.h index 9b25f0872f..f203b28694 100644 --- a/libavcodec/vc1.h +++ b/libavcodec/vc1.h @@ -25,7 +25,7 @@ #include "avcodec.h" #include "h264chroma.h" -#include "mpegvideo.h" +#include "mpegvideodec.h" #include "intrax8.h" #include "vc1_common.h" #include "vc1dsp.h" @@ -171,7 +171,7 @@ enum Imode { * Many members are only used for Advanced Profile */ typedef struct VC1Context{ - MpegEncContext s; + MPVMainDecContext s; IntraX8Context x8; H264ChromaContext h264chroma; VC1DSPContext vc1dsp; diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c index 119df4081d..65c0398842 100644 --- a/libavcodec/vc1_block.c +++ b/libavcodec/vc1_block.c @@ -59,7 +59,7 @@ static const int block_map[6] = {0, 2, 1, 3, 4, 5}; static inline void init_block_index(VC1Context *v) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; ff_init_block_index(s); if (v->field_mode && !(v->second_field ^ v->tff)) { s->dest[0] += s->current_picture_ptr->f->linesize[0]; @@ -72,7 +72,7 @@ static inline void init_block_index(VC1Context *v) static void vc1_put_blocks_clamped(VC1Context *v, int put_signed) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; uint8_t *dest; int block_count = CONFIG_GRAY && (s->avctx->flags & AV_CODEC_FLAG_GRAY) ? 4 : 6; int fieldtx = 0; @@ -330,14 +330,14 @@ static inline void vc1_b_mc(VC1Context *v, int dmv_x[2], int dmv_y[2], /** Get predicted DC value for I-frames only * prediction dir: left=0, top=1 - * @param s MpegEncContext + * @param s MPVDecContext * @param overlap flag indicating that overlap filtering is used * @param pq integer part of picture quantizer * @param[in] n block index in the current MB * @param dc_val_ptr Pointer to DC predictor * @param dir_ptr Prediction direction for use in AC prediction */ -static inline int vc1_i_pred_dc(MpegEncContext *s, int overlap, int pq, int n, +static inline int vc1_i_pred_dc(MPVDecContext *s, int overlap, int pq, int n, int16_t **dc_val_ptr, int *dir_ptr) { int a, b, c, wrap, pred, scale; @@ -393,7 +393,7 @@ static inline int vc1_i_pred_dc(MpegEncContext *s, int overlap, int pq, int n, /** Get predicted DC value * prediction dir: left=0, top=1 - * @param s MpegEncContext + * @param s MPVDecContext * @param overlap flag indicating that overlap filtering is used * @param pq integer part of picture quantizer * @param[in] n block index in the current MB @@ -402,7 +402,7 @@ static inline int vc1_i_pred_dc(MpegEncContext *s, int overlap, int pq, int n, * @param dc_val_ptr Pointer to DC predictor * @param dir_ptr Prediction direction for use in AC prediction */ -static inline int ff_vc1_pred_dc(MpegEncContext *s, int overlap, int pq, int n, +static inline int ff_vc1_pred_dc(MPVDecContext *s, int overlap, int pq, int n, int a_avail, int c_avail, int16_t **dc_val_ptr, int *dir_ptr) { @@ -473,7 +473,7 @@ static inline int ff_vc1_pred_dc(MpegEncContext *s, int overlap, int pq, int n, * @{ */ -static inline int vc1_coded_block_pred(MpegEncContext * s, int n, +static inline int vc1_coded_block_pred(MPVDecContext * s, int n, uint8_t **coded_block_ptr) { int xy, wrap, pred, a, b, c; @@ -579,8 +579,8 @@ static int vc1_decode_ac_coeff(VC1Context *v, int *last, int *skip, static int vc1_decode_i_block(VC1Context *v, int16_t block[64], int n, int coded, int codingset) { + MPVDecContext *const s = &v->s; GetBitContext *gb = &v->s.gb; - MpegEncContext *s = &v->s; int dc_pred_dir = 0; /* Direction of the DC prediction used */ int i; int16_t *dc_val; @@ -717,8 +717,8 @@ static int vc1_decode_i_block(VC1Context *v, int16_t block[64], int n, static int vc1_decode_i_block_adv(VC1Context *v, int16_t block[64], int n, int coded, int codingset, int mquant) { + MPVDecContext *const s = &v->s; GetBitContext *gb = &v->s.gb; - MpegEncContext *s = &v->s; int dc_pred_dir = 0; /* Direction of the DC prediction used */ int i; int16_t *dc_val = NULL; @@ -908,8 +908,8 @@ static int vc1_decode_i_block_adv(VC1Context *v, int16_t block[64], int n, static int vc1_decode_intra_block(VC1Context *v, int16_t block[64], int n, int coded, int mquant, int codingset) { + MPVDecContext *const s = &v->s; GetBitContext *gb = &v->s.gb; - MpegEncContext *s = &v->s; int dc_pred_dir = 0; /* Direction of the DC prediction used */ int i; int16_t *dc_val = NULL; @@ -1117,7 +1117,7 @@ static int vc1_decode_p_block(VC1Context *v, int16_t block[64], int n, uint8_t *dst, int linesize, int skip_block, int *ttmb_out) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; GetBitContext *gb = &s->gb; int i, j; int subblkpat = 0; @@ -1286,7 +1286,7 @@ static const uint8_t size_table[6] = { 0, 2, 3, 4, 5, 8 }; */ static int vc1_decode_p_mb(VC1Context *v) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; GetBitContext *gb = &s->gb; int i, j; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; @@ -1518,7 +1518,7 @@ end: static int vc1_decode_p_mb_intfr(VC1Context *v) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; GetBitContext *gb = &s->gb; int i; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; @@ -1728,7 +1728,7 @@ static int vc1_decode_p_mb_intfr(VC1Context *v) static int vc1_decode_p_mb_intfi(VC1Context *v) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; GetBitContext *gb = &s->gb; int i; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; @@ -1852,7 +1852,7 @@ static int vc1_decode_p_mb_intfi(VC1Context *v) */ static int vc1_decode_b_mb(VC1Context *v) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; GetBitContext *gb = &s->gb; int i, j; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; @@ -2010,7 +2010,7 @@ static int vc1_decode_b_mb(VC1Context *v) */ static int vc1_decode_b_mb_intfi(VC1Context *v) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; GetBitContext *gb = &s->gb; int i, j; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; @@ -2177,7 +2177,7 @@ static int vc1_decode_b_mb_intfi(VC1Context *v) */ static int vc1_decode_b_mb_intfr(VC1Context *v) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; GetBitContext *gb = &s->gb; int i, j; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; @@ -2527,8 +2527,8 @@ static int vc1_decode_b_mb_intfr(VC1Context *v) */ static void vc1_decode_i_blocks(VC1Context *v) { + MPVDecContext *const s = &v->s; int k, j; - MpegEncContext *s = &v->s; int cbp, val; uint8_t *coded_val; int mb_pos; @@ -2652,8 +2652,8 @@ static void vc1_decode_i_blocks(VC1Context *v) */ static int vc1_decode_i_blocks_adv(VC1Context *v) { + MPVDecContext *const s = &v->s; int k; - MpegEncContext *s = &v->s; int cbp, val; uint8_t *coded_val; int mb_pos; @@ -2795,7 +2795,7 @@ static int vc1_decode_i_blocks_adv(VC1Context *v) static void vc1_decode_p_blocks(VC1Context *v) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; int apply_loop_filter; /* select coding mode used for VLC tables selection */ @@ -2887,7 +2887,7 @@ static void vc1_decode_p_blocks(VC1Context *v) static void vc1_decode_b_blocks(VC1Context *v) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; /* select coding mode used for VLC tables selection */ switch (v->c_ac_table_index) { @@ -2971,7 +2971,7 @@ static void vc1_decode_b_blocks(VC1Context *v) static void vc1_decode_skip_blocks(VC1Context *v) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; if (!v->s.last_picture.f->data[0]) return; diff --git a/libavcodec/vc1_loopfilter.c b/libavcodec/vc1_loopfilter.c index 0f990cccef..3eb2feea36 100644 --- a/libavcodec/vc1_loopfilter.c +++ b/libavcodec/vc1_loopfilter.c @@ -27,7 +27,7 @@ */ #include "avcodec.h" -#include "mpegvideo.h" +#include "mpegvideodec.h" #include "vc1.h" #include "vc1dsp.h" @@ -104,7 +104,7 @@ static av_always_inline void vc1_v_overlap_filter(VC1Context *v, int16_t (*top_b void ff_vc1_i_overlap_filter(VC1Context *v) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; int16_t (*topleft_blk)[64], (*top_blk)[64], (*left_blk)[64], (*cur_blk)[64]; int block_count = CONFIG_GRAY && (s->avctx->flags & AV_CODEC_FLAG_GRAY) ? 4 : 6; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; @@ -160,7 +160,7 @@ void ff_vc1_i_overlap_filter(VC1Context *v) void ff_vc1_p_overlap_filter(VC1Context *v) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; int16_t (*topleft_blk)[64], (*top_blk)[64], (*left_blk)[64], (*cur_blk)[64]; int block_count = CONFIG_GRAY && (s->avctx->flags & AV_CODEC_FLAG_GRAY) ? 4 : 6; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; @@ -206,7 +206,7 @@ void ff_vc1_p_overlap_filter(VC1Context *v) static av_always_inline void vc1_i_h_loop_filter(VC1Context *v, uint8_t *dest, uint32_t flags, int block_num) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; int pq = v->pq; uint8_t *dst; @@ -239,7 +239,7 @@ static av_always_inline void vc1_i_v_loop_filter(VC1Context *v, uint8_t *dest, uint32_t flags, uint8_t fieldtx, int block_num) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; int pq = v->pq; uint8_t *dst; @@ -270,7 +270,7 @@ static av_always_inline void vc1_i_v_loop_filter(VC1Context *v, uint8_t *dest, void ff_vc1_i_loop_filter(VC1Context *v) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; int block_count = CONFIG_GRAY && (s->avctx->flags & AV_CODEC_FLAG_GRAY) ? 4 : 6; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; uint8_t *dest, fieldtx; @@ -364,7 +364,7 @@ static av_always_inline void vc1_p_h_loop_filter(VC1Context *v, uint8_t *dest, u uint8_t *is_intra, int16_t (*mv)[2], uint8_t *mv_f, int *ttblk, uint32_t flags, int block_num) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; int pq = v->pq; uint32_t left_cbp = cbp[0] >> (block_num * 4), right_cbp; uint8_t left_is_intra, right_is_intra; @@ -417,7 +417,7 @@ static av_always_inline void vc1_p_v_loop_filter(VC1Context *v, uint8_t *dest, u uint8_t *is_intra, int16_t (*mv)[2], uint8_t *mv_f, int *ttblk, uint32_t flags, int block_num) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; int pq = v->pq; uint32_t top_cbp = cbp[0] >> (block_num * 4), bottom_cbp; uint8_t top_is_intra, bottom_is_intra; @@ -469,7 +469,7 @@ static av_always_inline void vc1_p_v_loop_filter(VC1Context *v, uint8_t *dest, u void ff_vc1_p_loop_filter(VC1Context *v) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; int block_count = CONFIG_GRAY && (s->avctx->flags & AV_CODEC_FLAG_GRAY) ? 4 : 6; uint8_t *dest; uint32_t *cbp; @@ -802,7 +802,7 @@ void ff_vc1_p_loop_filter(VC1Context *v) static av_always_inline void vc1_p_h_intfr_loop_filter(VC1Context *v, uint8_t *dest, int *ttblk, uint32_t flags, uint8_t fieldtx, int block_num) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; int pq = v->pq; int tt; int linesize = block_num > 3 ? s->uvlinesize : s->linesize; @@ -852,7 +852,7 @@ static av_always_inline void vc1_p_h_intfr_loop_filter(VC1Context *v, uint8_t *d static av_always_inline void vc1_p_v_intfr_loop_filter(VC1Context *v, uint8_t *dest, int *ttblk, uint32_t flags, uint8_t fieldtx, int block_num) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; int pq = v->pq; int tt; int linesize = block_num > 3 ? s->uvlinesize : s->linesize; @@ -908,7 +908,7 @@ static av_always_inline void vc1_p_v_intfr_loop_filter(VC1Context *v, uint8_t *d void ff_vc1_p_intfr_loop_filter(VC1Context *v) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; int block_count = CONFIG_GRAY && (s->avctx->flags & AV_CODEC_FLAG_GRAY) ? 4 : 6; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; uint8_t *dest; @@ -1112,7 +1112,7 @@ void ff_vc1_p_intfr_loop_filter(VC1Context *v) static av_always_inline void vc1_b_h_intfi_loop_filter(VC1Context *v, uint8_t *dest, uint32_t *cbp, int *ttblk, uint32_t flags, int block_num) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; int pq = v->pq; uint8_t *dst; uint32_t block_cbp = cbp[0] >> (block_num * 4); @@ -1144,7 +1144,7 @@ static av_always_inline void vc1_b_h_intfi_loop_filter(VC1Context *v, uint8_t *d static av_always_inline void vc1_b_v_intfi_loop_filter(VC1Context *v, uint8_t *dest, uint32_t *cbp, int *ttblk, uint32_t flags, int block_num) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; int pq = v->pq; uint8_t *dst; uint32_t block_cbp = cbp[0] >> (block_num * 4); @@ -1171,7 +1171,7 @@ static av_always_inline void vc1_b_v_intfi_loop_filter(VC1Context *v, uint8_t *d void ff_vc1_b_intfi_loop_filter(VC1Context *v) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; int block_count = CONFIG_GRAY && (s->avctx->flags & AV_CODEC_FLAG_GRAY) ? 4 : 6; uint8_t *dest; uint32_t *cbp; diff --git a/libavcodec/vc1_mc.c b/libavcodec/vc1_mc.c index 1b8d8799b3..3e3bf27552 100644 --- a/libavcodec/vc1_mc.c +++ b/libavcodec/vc1_mc.c @@ -29,7 +29,7 @@ #include "avcodec.h" #include "h264chroma.h" #include "mathops.h" -#include "mpegvideo.h" +#include "mpegvideodec.h" #include "vc1.h" static av_always_inline void vc1_scale_luma(uint8_t *srcY, @@ -107,7 +107,7 @@ static const uint8_t popcount4[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, static av_always_inline int get_luma_mv(VC1Context *v, int dir, int16_t *tx, int16_t *ty) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; int idx = v->mv_f[dir][s->block_index[0] + v->blocks_off] | (v->mv_f[dir][s->block_index[1] + v->blocks_off] << 1) | (v->mv_f[dir][s->block_index[2] + v->blocks_off] << 2) | @@ -139,7 +139,7 @@ static av_always_inline int get_luma_mv(VC1Context *v, int dir, int16_t *tx, int static av_always_inline int get_chroma_mv(VC1Context *v, int dir, int16_t *tx, int16_t *ty) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; int idx = !v->mb_type[0][s->block_index[0]] | (!v->mb_type[0][s->block_index[1]] << 1) | (!v->mb_type[0][s->block_index[2]] << 2) | @@ -171,7 +171,7 @@ static av_always_inline int get_chroma_mv(VC1Context *v, int dir, int16_t *tx, i */ void ff_vc1_mc_1mv(VC1Context *v, int dir) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; H264ChromaContext *h264chroma = &v->h264chroma; uint8_t *srcY, *srcU, *srcV; int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y; @@ -451,7 +451,7 @@ void ff_vc1_mc_1mv(VC1Context *v, int dir) */ void ff_vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; uint8_t *srcY; int dxy, mx, my, src_x, src_y; int off; @@ -633,7 +633,7 @@ void ff_vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg) */ void ff_vc1_mc_4mv_chroma(VC1Context *v, int dir) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; H264ChromaContext *h264chroma = &v->h264chroma; uint8_t *srcU, *srcV; int uvmx, uvmy, uvsrc_x, uvsrc_y; @@ -838,7 +838,7 @@ void ff_vc1_mc_4mv_chroma(VC1Context *v, int dir) */ void ff_vc1_mc_4mv_chroma4(VC1Context *v, int dir, int dir2, int avg) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; H264ChromaContext *h264chroma = &v->h264chroma; uint8_t *srcU, *srcV; int uvsrc_x, uvsrc_y; @@ -1003,7 +1003,7 @@ void ff_vc1_mc_4mv_chroma4(VC1Context *v, int dir, int dir2, int avg) */ void ff_vc1_interp_mc(VC1Context *v) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; H264ChromaContext *h264chroma = &v->h264chroma; uint8_t *srcY, *srcU, *srcV; int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y; diff --git a/libavcodec/vc1_pred.c b/libavcodec/vc1_pred.c index ad2caf6db2..75240e239a 100644 --- a/libavcodec/vc1_pred.c +++ b/libavcodec/vc1_pred.c @@ -28,7 +28,7 @@ #include "mathops.h" #include "mpegutils.h" -#include "mpegvideo.h" +#include "mpegvideodec.h" #include "vc1.h" #include "vc1_pred.h" #include "vc1data.h" @@ -213,7 +213,7 @@ void ff_vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y, int mv1, int r_x, int r_y, uint8_t* is_intra, int pred_flag, int dir) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; int xy, wrap, off = 0; int16_t *A, *B, *C; int px, py; @@ -470,7 +470,7 @@ void ff_vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y, void ff_vc1_pred_mv_intfr(VC1Context *v, int n, int dmv_x, int dmv_y, int mvn, int r_x, int r_y, int dir) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; int xy, wrap, off = 0; int A[2], B[2], C[2]; int px = 0, py = 0; @@ -691,7 +691,7 @@ void ff_vc1_pred_mv_intfr(VC1Context *v, int n, int dmv_x, int dmv_y, void ff_vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2], int direct, int mvtype) { - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; int xy, wrap, off = 0; int16_t *A, *B, *C; int px, py; @@ -892,7 +892,7 @@ void ff_vc1_pred_b_mv_intfi(VC1Context *v, int n, int *dmv_x, int *dmv_y, int mv1, int *pred_flag) { int dir = (v->bmvtype == BMV_TYPE_BACKWARD) ? 1 : 0; - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; if (v->bmvtype == BMV_TYPE_DIRECT) { diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index 700c787d99..6945042450 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -175,12 +175,12 @@ static int vc1_parse_sprites(VC1Context *v, GetBitContext* gb, SpriteData* sd) static void vc1_draw_sprites(VC1Context *v, SpriteData* sd) { + MPVDecContext *const s = &v->s; int i, plane, row, sprite; int sr_cache[2][2] = { { -1, -1 }, { -1, -1 } }; uint8_t* src_h[2][2]; int xoff[2], xadv[2], yoff[2], yadv[2], alpha; int ysub[2]; - MpegEncContext *s = &v->s; for (i = 0; i <= v->two_sprites; i++) { xoff[i] = av_clip(sd->coefs[i][2], 0, v->sprite_width-1 << 16); @@ -272,8 +272,8 @@ static void vc1_draw_sprites(VC1Context *v, SpriteData* sd) static int vc1_decode_sprites(VC1Context *v, GetBitContext* gb) { + MPVDecContext *const s = &v->s; int ret; - MpegEncContext *s = &v->s; AVCodecContext *avctx = s->avctx; SpriteData sd; @@ -305,7 +305,7 @@ static int vc1_decode_sprites(VC1Context *v, GetBitContext* gb) static void vc1_sprite_flush(AVCodecContext *avctx) { VC1Context *v = avctx->priv_data; - MpegEncContext *s = &v->s; + MPVDecContext *const s = &v->s; AVFrame *f = s->current_picture.f; int plane, i; @@ -324,7 +324,7 @@ static void vc1_sprite_flush(AVCodecContext *avctx) av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v) { - MpegEncContext *s = &v->s; + MPVMainDecContext *const s = &v->s; int i, ret = AVERROR(ENOMEM); int mb_height = FFALIGN(s->mb_height, 2); @@ -423,7 +423,7 @@ av_cold void ff_vc1_init_transposed_scantables(VC1Context *v) static av_cold int vc1_decode_init(AVCodecContext *avctx) { VC1Context *v = avctx->priv_data; - MpegEncContext *s = &v->s; + MPVMainDecContext *const s = &v->s; GetBitContext gb; int ret; @@ -585,7 +585,6 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) } /** Close a VC1/WMV3 decoder - * @warning Initial try at using MpegEncContext stuff */ av_cold int ff_vc1_decode_end(AVCodecContext *avctx) { @@ -626,7 +625,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, const uint8_t *buf = avpkt->data; int buf_size = avpkt->size, n_slices = 0, i, ret; VC1Context *v = avctx->priv_data; - MpegEncContext *s = &v->s; + MPVMainDecContext *const s = &v->s; AVFrame *pict = data; uint8_t *buf2 = NULL; const uint8_t *buf_start = buf, *buf_start_second_field = NULL; diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c index 5072071c70..f93056d857 100644 --- a/libavcodec/vdpau.c +++ b/libavcodec/vdpau.c @@ -367,7 +367,7 @@ int ff_vdpau_common_end_frame(AVCodecContext *avctx, AVFrame *frame, CONFIG_VC1_VDPAU_HWACCEL || CONFIG_WMV3_VDPAU_HWACCEL int ff_vdpau_mpeg_end_frame(AVCodecContext *avctx) { - MpegEncContext *s = avctx->priv_data; + MPVDecContext *const s = avctx->priv_data; Picture *pic = s->current_picture_ptr; struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; int val; diff --git a/libavcodec/vdpau_mpeg12.c b/libavcodec/vdpau_mpeg12.c index 72220ffb4e..d59a651ae0 100644 --- a/libavcodec/vdpau_mpeg12.c +++ b/libavcodec/vdpau_mpeg12.c @@ -25,14 +25,14 @@ #include "avcodec.h" #include "hwconfig.h" -#include "mpegvideo.h" +#include "mpegvideodec.h" #include "vdpau.h" #include "vdpau_internal.h" static int vdpau_mpeg_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) { - MpegEncContext * const s = avctx->priv_data; + MPVDecContext *const s = avctx->priv_data; Picture *pic = s->current_picture_ptr; struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; VdpPictureInfoMPEG1Or2 *info = &pic_ctx->info.mpeg; @@ -83,7 +83,7 @@ static int vdpau_mpeg_start_frame(AVCodecContext *avctx, static int vdpau_mpeg_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) { - MpegEncContext * const s = avctx->priv_data; + MPVDecContext *const s = avctx->priv_data; Picture *pic = s->current_picture_ptr; struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; int val; diff --git a/libavcodec/vdpau_mpeg4.c b/libavcodec/vdpau_mpeg4.c index 6e082eefc6..7fcbd06647 100644 --- a/libavcodec/vdpau_mpeg4.c +++ b/libavcodec/vdpau_mpeg4.c @@ -33,7 +33,7 @@ static int vdpau_mpeg4_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) { Mpeg4DecContext *ctx = avctx->priv_data; - MpegEncContext * const s = &ctx->m; + MPVDecContext *const s = &ctx->m; Picture *pic = s->current_picture_ptr; struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; VdpPictureInfoMPEG4Part2 *info = &pic_ctx->info.mpeg4; diff --git a/libavcodec/vdpau_vc1.c b/libavcodec/vdpau_vc1.c index 96c91b58be..e3aa36fbdd 100644 --- a/libavcodec/vdpau_vc1.c +++ b/libavcodec/vdpau_vc1.c @@ -33,7 +33,7 @@ static int vdpau_vc1_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) { VC1Context * const v = avctx->priv_data; - MpegEncContext * const s = &v->s; + MPVDecContext *const s = &v->s; Picture *pic = s->current_picture_ptr; struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; VdpPictureInfoVC1 *info = &pic_ctx->info.vc1; @@ -101,7 +101,7 @@ static int vdpau_vc1_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) { VC1Context * const v = avctx->priv_data; - MpegEncContext * const s = &v->s; + MPVDecContext *const s = &v->s; Picture *pic = s->current_picture_ptr; struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; int val; diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c index 51d4eacfd8..ff092bda38 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c @@ -31,7 +31,7 @@ #include "decode.h" #include "h264dec.h" #include "hevcdec.h" -#include "mpegvideo.h" +#include "mpegvideodec.h" #include "proresdec.h" #include #include @@ -1091,7 +1091,7 @@ static int videotoolbox_mpeg_decode_slice(AVCodecContext *avctx, static int videotoolbox_mpeg_end_frame(AVCodecContext *avctx) { - MpegEncContext *s = avctx->priv_data; + MPVDecContext *const s = avctx->priv_data; AVFrame *frame = s->current_picture_ptr->f; return ff_videotoolbox_common_end_frame(avctx, frame); diff --git a/libavcodec/wmv2.c b/libavcodec/wmv2.c index 8d1d117dea..29ed71f8aa 100644 --- a/libavcodec/wmv2.c +++ b/libavcodec/wmv2.c @@ -25,7 +25,7 @@ #include "wmv2.h" -av_cold void ff_wmv2_common_init(MpegEncContext *s) +av_cold void ff_wmv2_common_init(MPVMainContext *s) { WMV2Context *const w = s->private_ctx; @@ -47,7 +47,7 @@ av_cold void ff_wmv2_common_init(MpegEncContext *s) s->idsp.idct = NULL; } -void ff_mspel_motion(MpegEncContext *s, uint8_t *dest_y, +void ff_mspel_motion(MPVContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, uint8_t **ref_picture, op_pixels_func (*pix_op)[4], int motion_x, int motion_y, int h) diff --git a/libavcodec/wmv2.h b/libavcodec/wmv2.h index cdd58cf011..22c8a3426c 100644 --- a/libavcodec/wmv2.h +++ b/libavcodec/wmv2.h @@ -35,15 +35,15 @@ typedef struct WMV2Context { int hshift; } WMV2Context; -void ff_wmv2_common_init(MpegEncContext *s); +void ff_wmv2_common_init(MPVMainContext *m); -void ff_mspel_motion(MpegEncContext *s, +void ff_mspel_motion(MPVContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, uint8_t **ref_picture, op_pixels_func (*pix_op)[4], int motion_x, int motion_y, int h); -static av_always_inline int wmv2_get_cbp_table_index(MpegEncContext *s, int cbp_index) +static av_always_inline int wmv2_get_cbp_table_index(MPVContext *s, int cbp_index) { static const uint8_t map[3][3] = { { 0, 2, 1 }, diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c index 7121468ae9..128d78aa1d 100644 --- a/libavcodec/wmv2dec.c +++ b/libavcodec/wmv2dec.c @@ -27,6 +27,7 @@ #include "mathops.h" #include "mpegutils.h" #include "mpegvideo.h" +#include "mpegvideodec.h" #include "msmpeg4.h" #include "msmpeg4data.h" #include "msmpeg4dec.h" @@ -36,7 +37,7 @@ #include "wmv2dec.h" typedef struct WMV2DecContext { - MpegEncContext s; + MPVMainDecContext s; WMV2Context common; IntraX8Context x8; int j_type_bit; @@ -59,7 +60,7 @@ typedef struct WMV2DecContext { static void wmv2_add_block(WMV2DecContext *w, int16_t *block1, uint8_t *dst, int stride, int n) { - MpegEncContext *const s = &w->s; + MPVDecContext *const s = &w->s; if (s->block_last_index[n] >= 0) { switch (w->abt_type_table[n]) { @@ -82,7 +83,7 @@ static void wmv2_add_block(WMV2DecContext *w, int16_t *block1, } } -void ff_wmv2_add_mb(MpegEncContext *s, int16_t block1[6][64], +void ff_wmv2_add_mb(MPVDecContext *s, int16_t block1[6][64], uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr) { WMV2DecContext *const w = (WMV2DecContext *) s; @@ -103,7 +104,7 @@ static int parse_mb_skip(WMV2DecContext *w) { int mb_x, mb_y; int coded_mb_count = 0; - MpegEncContext *const s = &w->s; + MPVDecContext *const s = &w->s; uint32_t *const mb_type = s->current_picture_ptr->mb_type; w->skip_type = get_bits(&s->gb, 2); @@ -166,7 +167,7 @@ static int parse_mb_skip(WMV2DecContext *w) static int decode_ext_header(WMV2DecContext *w) { - MpegEncContext *const s = &w->s; + MPVDecContext *const s = &w->s; GetBitContext gb; int fps; int code; @@ -202,7 +203,7 @@ static int decode_ext_header(WMV2DecContext *w) return 0; } -int ff_wmv2_decode_picture_header(MpegEncContext *s) +int ff_wmv2_decode_picture_header(MPVMainDecContext *s) { WMV2DecContext *const w = (WMV2DecContext *) s; int code; @@ -237,7 +238,7 @@ int ff_wmv2_decode_picture_header(MpegEncContext *s) return 0; } -int ff_wmv2_decode_secondary_picture_header(MpegEncContext *s) +int ff_wmv2_decode_secondary_picture_header(MPVMainDecContext *s) { WMV2DecContext *const w = (WMV2DecContext *) s; @@ -349,7 +350,7 @@ int ff_wmv2_decode_secondary_picture_header(MpegEncContext *s) static inline void wmv2_decode_motion(WMV2DecContext *w, int *mx_ptr, int *my_ptr) { - MpegEncContext *const s = &w->s; + MPVDecContext *const s = &w->s; ff_msmpeg4_decode_motion(s, mx_ptr, my_ptr); @@ -361,7 +362,7 @@ static inline void wmv2_decode_motion(WMV2DecContext *w, int *mx_ptr, int *my_pt static int16_t *wmv2_pred_motion(WMV2DecContext *w, int *px, int *py) { - MpegEncContext *const s = &w->s; + MPVDecContext *const s = &w->s; int xy, wrap, diff, type; int16_t *A, *B, *C, *mot_val; @@ -407,7 +408,7 @@ static int16_t *wmv2_pred_motion(WMV2DecContext *w, int *px, int *py) static inline int wmv2_decode_inter_block(WMV2DecContext *w, int16_t *block, int n, int cbp) { - MpegEncContext *const s = &w->s; + MPVDecContext *const s = &w->s; static const int sub_cbp_table[3] = { 2, 3, 1 }; int sub_cbp, ret; @@ -444,7 +445,7 @@ static inline int wmv2_decode_inter_block(WMV2DecContext *w, int16_t *block, } } -int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64]) +int ff_wmv2_decode_mb(MPVDecContext *s, int16_t block[6][64]) { /* The following is only allowed because this encoder * does not use slice threading. */ @@ -564,7 +565,7 @@ int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64]) static av_cold int wmv2_decode_init(AVCodecContext *avctx) { WMV2DecContext *const w = avctx->priv_data; - MpegEncContext *const s = &w->s; + MPVMainDecContext *const s = &w->s; int ret; s->private_ctx = &w->common; diff --git a/libavcodec/wmv2dec.h b/libavcodec/wmv2dec.h index cc410afe17..05ca29741b 100644 --- a/libavcodec/wmv2dec.h +++ b/libavcodec/wmv2dec.h @@ -22,11 +22,12 @@ #define AVCODEC_WMV2DEC_H #include "mpegvideo.h" +#include "mpegvideodec.h" -int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64]); -int ff_wmv2_decode_picture_header(MpegEncContext * s); -int ff_wmv2_decode_secondary_picture_header(MpegEncContext * s); -void ff_wmv2_add_mb(MpegEncContext *s, int16_t block[6][64], +int ff_wmv2_decode_mb(MPVDecContext *s, int16_t block[6][64]); +int ff_wmv2_decode_picture_header(MPVMainDecContext *s); +int ff_wmv2_decode_secondary_picture_header(MPVMainDecContext *s); +void ff_wmv2_add_mb(MPVContext *s, int16_t block[6][64], uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr); #endif diff --git a/libavcodec/wmv2enc.c b/libavcodec/wmv2enc.c index f6ff697043..cd35fd19b1 100644 --- a/libavcodec/wmv2enc.c +++ b/libavcodec/wmv2enc.c @@ -20,7 +20,6 @@ #include "avcodec.h" #include "h263.h" -#include "mpegvideo.h" #include "mpegvideoenc.h" #include "msmpeg4.h" #include "msmpeg4enc.h" @@ -44,7 +43,7 @@ typedef struct WMV2EncContext { static int encode_ext_header(WMV2EncContext *w) { - MpegEncContext *const s = &w->msmpeg4.s; + MPVMainEncContext *const s = &w->msmpeg4.s; PutBitContext pb; int code; @@ -71,7 +70,7 @@ static int encode_ext_header(WMV2EncContext *w) static av_cold int wmv2_encode_init(AVCodecContext *avctx) { WMV2EncContext *const w = avctx->priv_data; - MpegEncContext *const s = &w->msmpeg4.s; + MPVMainEncContext *const s = &w->msmpeg4.s; s->private_ctx = &w->common; if (ff_mpv_encode_init(avctx) < 0) @@ -89,7 +88,7 @@ static av_cold int wmv2_encode_init(AVCodecContext *avctx) return 0; } -int ff_wmv2_encode_picture_header(MpegEncContext *s, int picture_number) +int ff_wmv2_encode_picture_header(MPVMainEncContext *s, int picture_number) { WMV2EncContext *const w = (WMV2EncContext *) s; @@ -162,7 +161,7 @@ int ff_wmv2_encode_picture_header(MpegEncContext *s, int picture_number) /* Nearly identical to wmv1 but that is just because we do not use the * useless M$ crap features. It is duplicated here in case someone wants * to add support for these crap features. */ -void ff_wmv2_encode_mb(MpegEncContext *s, int16_t block[6][64], +void ff_wmv2_encode_mb(MPVEncContext *s, int16_t block[6][64], int motion_x, int motion_y) { WMV2EncContext *const w = (WMV2EncContext *) s; diff --git a/libavcodec/wmv2enc.h b/libavcodec/wmv2enc.h index 3f7f5104a6..1b12012fdc 100644 --- a/libavcodec/wmv2enc.h +++ b/libavcodec/wmv2enc.h @@ -21,10 +21,10 @@ #ifndef AVCODEC_WMV2ENC_H #define AVCODEC_WMV2ENC_H -#include "mpegvideo.h" +#include "mpegvideoenc.h" -int ff_wmv2_encode_picture_header(MpegEncContext * s, int picture_number); -void ff_wmv2_encode_mb(MpegEncContext * s, int16_t block[6][64], +int ff_wmv2_encode_picture_header(MPVMainEncContext *s, int picture_number); +void ff_wmv2_encode_mb(MPVEncContext *s, int16_t block[6][64], int motion_x, int motion_y); diff --git a/libavcodec/x86/me_cmp.asm b/libavcodec/x86/me_cmp.asm index ad06d485ab..08ffc10f79 100644 --- a/libavcodec/x86/me_cmp.asm +++ b/libavcodec/x86/me_cmp.asm @@ -214,7 +214,7 @@ hadamard8x8_diff %+ SUFFIX: hadamard8_16_wrapper %1, 3 %elif cpuflag(mmx) ALIGN 16 -; int ff_hadamard8_diff_ ## cpu(MpegEncContext *s, uint8_t *src1, +; int ff_hadamard8_diff_ ## cpu(MPVEncContext *s, uint8_t *src1, ; uint8_t *src2, ptrdiff_t stride, int h) ; r0 = void *s = unused, int h = unused (always 8) ; note how r1, r2 and r3 are not clobbered in this function, so 16x16 @@ -279,7 +279,7 @@ INIT_XMM ssse3 %define ABS_SUM_8x8 ABS_SUM_8x8_64 HADAMARD8_DIFF 9 -; int ff_sse*_*(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +; int ff_sse*_*(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ; ptrdiff_t line_size, int h) %macro SUM_SQUARED_ERRORS 1 @@ -471,7 +471,7 @@ HF_NOISE 8 HF_NOISE 16 ;--------------------------------------------------------------------------------------- -;int ff_sad_(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); +;int ff_sad_(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); ;--------------------------------------------------------------------------------------- ;%1 = 8/16 %macro SAD 1 @@ -526,7 +526,7 @@ INIT_XMM sse2 SAD 16 ;------------------------------------------------------------------------------------------ -;int ff_sad_x2_(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); +;int ff_sad_x2_(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); ;------------------------------------------------------------------------------------------ ;%1 = 8/16 %macro SAD_X2 1 @@ -603,7 +603,7 @@ INIT_XMM sse2 SAD_X2 16 ;------------------------------------------------------------------------------------------ -;int ff_sad_y2_(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); +;int ff_sad_y2_(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); ;------------------------------------------------------------------------------------------ ;%1 = 8/16 %macro SAD_Y2 1 @@ -673,7 +673,7 @@ INIT_XMM sse2 SAD_Y2 16 ;------------------------------------------------------------------------------------------- -;int ff_sad_approx_xy2_(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); +;int ff_sad_approx_xy2_(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); ;------------------------------------------------------------------------------------------- ;%1 = 8/16 %macro SAD_APPROX_XY2 1 @@ -774,7 +774,7 @@ INIT_XMM sse2 SAD_APPROX_XY2 16 ;-------------------------------------------------------------------- -;int ff_vsad_intra(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +;int ff_vsad_intra(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ; ptrdiff_t line_size, int h); ;-------------------------------------------------------------------- ; %1 = 8/16 @@ -835,7 +835,7 @@ INIT_XMM sse2 VSAD_INTRA 16 ;--------------------------------------------------------------------- -;int ff_vsad_approx(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +;int ff_vsad_approx(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ; ptrdiff_t line_size, int h); ;--------------------------------------------------------------------- ; %1 = 8/16 diff --git a/libavcodec/x86/me_cmp_init.c b/libavcodec/x86/me_cmp_init.c index 9af911bb88..2487842a2c 100644 --- a/libavcodec/x86/me_cmp_init.c +++ b/libavcodec/x86/me_cmp_init.c @@ -28,61 +28,61 @@ #include "libavutil/x86/asm.h" #include "libavutil/x86/cpu.h" #include "libavcodec/me_cmp.h" -#include "libavcodec/mpegvideo.h" +#include "libavcodec/mpegvideoenc.h" int ff_sum_abs_dctelem_mmx(int16_t *block); int ff_sum_abs_dctelem_mmxext(int16_t *block); int ff_sum_abs_dctelem_sse2(int16_t *block); int ff_sum_abs_dctelem_ssse3(int16_t *block); -int ff_sse8_mmx(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_sse8_mmx(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); -int ff_sse16_mmx(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_sse16_mmx(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); -int ff_sse16_sse2(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_sse16_sse2(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); int ff_hf_noise8_mmx(uint8_t *pix1, ptrdiff_t stride, int h); int ff_hf_noise16_mmx(uint8_t *pix1, ptrdiff_t stride, int h); -int ff_sad8_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_sad8_mmxext(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); -int ff_sad16_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_sad16_mmxext(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); -int ff_sad16_sse2(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_sad16_sse2(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); -int ff_sad8_x2_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_sad8_x2_mmxext(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); -int ff_sad16_x2_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_sad16_x2_mmxext(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); -int ff_sad16_x2_sse2(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_sad16_x2_sse2(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); -int ff_sad8_y2_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_sad8_y2_mmxext(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); -int ff_sad16_y2_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_sad16_y2_mmxext(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); -int ff_sad16_y2_sse2(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_sad16_y2_sse2(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); -int ff_sad8_approx_xy2_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_sad8_approx_xy2_mmxext(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); -int ff_sad16_approx_xy2_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_sad16_approx_xy2_mmxext(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); -int ff_sad16_approx_xy2_sse2(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_sad16_approx_xy2_sse2(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); -int ff_vsad_intra8_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_vsad_intra8_mmxext(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); -int ff_vsad_intra16_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_vsad_intra16_mmxext(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); -int ff_vsad_intra16_sse2(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_vsad_intra16_sse2(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); -int ff_vsad8_approx_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_vsad8_approx_mmxext(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); -int ff_vsad16_approx_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_vsad16_approx_mmxext(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); -int ff_vsad16_approx_sse2(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +int ff_vsad16_approx_sse2(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); #define hadamard_func(cpu) \ - int ff_hadamard8_diff_ ## cpu(MpegEncContext *s, uint8_t *src1, \ + int ff_hadamard8_diff_ ## cpu(MPVEncContext *s, uint8_t *src1, \ uint8_t *src2, ptrdiff_t stride, int h); \ - int ff_hadamard8_diff16_ ## cpu(MpegEncContext *s, uint8_t *src1, \ + int ff_hadamard8_diff16_ ## cpu(MPVEncContext *s, uint8_t *src1, \ uint8_t *src2, ptrdiff_t stride, int h); hadamard_func(mmx) @@ -91,7 +91,7 @@ hadamard_func(sse2) hadamard_func(ssse3) #if HAVE_X86ASM -static int nsse16_mmx(MpegEncContext *c, uint8_t *pix1, uint8_t *pix2, +static int nsse16_mmx(MPVEncContext *c, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { int score1, score2; @@ -109,7 +109,7 @@ static int nsse16_mmx(MpegEncContext *c, uint8_t *pix1, uint8_t *pix2, return score1 + FFABS(score2) * 8; } -static int nsse8_mmx(MpegEncContext *c, uint8_t *pix1, uint8_t *pix2, +static int nsse8_mmx(MPVEncContext *c, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { int score1 = ff_sse8_mmx(c, pix1, pix2, stride, h); @@ -126,7 +126,7 @@ static int nsse8_mmx(MpegEncContext *c, uint8_t *pix1, uint8_t *pix2, #if HAVE_INLINE_ASM -static int vsad_intra16_mmx(MpegEncContext *v, uint8_t *pix, uint8_t *dummy, +static int vsad_intra16_mmx(MPVEncContext *v, uint8_t *pix, uint8_t *dummy, ptrdiff_t stride, int h) { int tmp; @@ -190,7 +190,7 @@ static int vsad_intra16_mmx(MpegEncContext *v, uint8_t *pix, uint8_t *dummy, } #undef SUM -static int vsad16_mmx(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, +static int vsad16_mmx(MPVEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h) { int tmp; @@ -434,7 +434,7 @@ static inline void sad8_y2a_mmx(uint8_t *blk1, uint8_t *blk2, } #define PIX_SAD(suf) \ -static int sad8_ ## suf(MpegEncContext *v, uint8_t *blk2, \ +static int sad8_ ## suf(MPVEncContext *v, uint8_t *blk2, \ uint8_t *blk1, ptrdiff_t stride, int h) \ { \ av_assert2(h == 8); \ @@ -448,7 +448,7 @@ static int sad8_ ## suf(MpegEncContext *v, uint8_t *blk2, \ return sum_ ## suf(); \ } \ \ -static int sad8_x2_ ## suf(MpegEncContext *v, uint8_t *blk2, \ +static int sad8_x2_ ## suf(MPVEncContext *v, uint8_t *blk2, \ uint8_t *blk1, ptrdiff_t stride, int h) \ { \ av_assert2(h == 8); \ @@ -463,7 +463,7 @@ static int sad8_x2_ ## suf(MpegEncContext *v, uint8_t *blk2, \ return sum_ ## suf(); \ } \ \ -static int sad8_y2_ ## suf(MpegEncContext *v, uint8_t *blk2, \ +static int sad8_y2_ ## suf(MPVEncContext *v, uint8_t *blk2, \ uint8_t *blk1, ptrdiff_t stride, int h) \ { \ av_assert2(h == 8); \ @@ -478,7 +478,7 @@ static int sad8_y2_ ## suf(MpegEncContext *v, uint8_t *blk2, \ return sum_ ## suf(); \ } \ \ -static int sad8_xy2_ ## suf(MpegEncContext *v, uint8_t *blk2, \ +static int sad8_xy2_ ## suf(MPVEncContext *v, uint8_t *blk2, \ uint8_t *blk1, ptrdiff_t stride, int h) \ { \ av_assert2(h == 8); \ @@ -492,7 +492,7 @@ static int sad8_xy2_ ## suf(MpegEncContext *v, uint8_t *blk2, \ return sum_ ## suf(); \ } \ \ -static int sad16_ ## suf(MpegEncContext *v, uint8_t *blk2, \ +static int sad16_ ## suf(MPVEncContext *v, uint8_t *blk2, \ uint8_t *blk1, ptrdiff_t stride, int h) \ { \ __asm__ volatile ( \ @@ -506,7 +506,7 @@ static int sad16_ ## suf(MpegEncContext *v, uint8_t *blk2, \ return sum_ ## suf(); \ } \ \ -static int sad16_x2_ ## suf(MpegEncContext *v, uint8_t *blk2, \ +static int sad16_x2_ ## suf(MPVEncContext *v, uint8_t *blk2, \ uint8_t *blk1, ptrdiff_t stride, int h) \ { \ __asm__ volatile ( \ @@ -521,7 +521,7 @@ static int sad16_x2_ ## suf(MpegEncContext *v, uint8_t *blk2, \ return sum_ ## suf(); \ } \ \ -static int sad16_y2_ ## suf(MpegEncContext *v, uint8_t *blk2, \ +static int sad16_y2_ ## suf(MPVEncContext *v, uint8_t *blk2, \ uint8_t *blk1, ptrdiff_t stride, int h) \ { \ __asm__ volatile ( \ @@ -536,7 +536,7 @@ static int sad16_y2_ ## suf(MpegEncContext *v, uint8_t *blk2, \ return sum_ ## suf(); \ } \ \ -static int sad16_xy2_ ## suf(MpegEncContext *v, uint8_t *blk2, \ +static int sad16_xy2_ ## suf(MPVEncContext *v, uint8_t *blk2, \ uint8_t *blk1, ptrdiff_t stride, int h) \ { \ __asm__ volatile ( \ diff --git a/libavcodec/x86/mpegvideo.c b/libavcodec/x86/mpegvideo.c index 73967cafda..d47f0fcd97 100644 --- a/libavcodec/x86/mpegvideo.c +++ b/libavcodec/x86/mpegvideo.c @@ -29,7 +29,7 @@ #if HAVE_MMX_INLINE -static void dct_unquantize_h263_intra_mmx(MpegEncContext *s, +static void dct_unquantize_h263_intra_mmx(MPVContext *s, int16_t *block, int n, int qscale) { x86_reg level, qmul, qadd, nCoeffs; @@ -104,7 +104,7 @@ __asm__ volatile( } -static void dct_unquantize_h263_inter_mmx(MpegEncContext *s, +static void dct_unquantize_h263_inter_mmx(MPVContext *s, int16_t *block, int n, int qscale) { x86_reg qmul, qadd, nCoeffs; @@ -165,7 +165,7 @@ __asm__ volatile( ); } -static void dct_unquantize_mpeg1_intra_mmx(MpegEncContext *s, +static void dct_unquantize_mpeg1_intra_mmx(MPVContext *s, int16_t *block, int n, int qscale) { x86_reg nCoeffs; @@ -234,7 +234,7 @@ __asm__ volatile( block[0]= block0; } -static void dct_unquantize_mpeg1_inter_mmx(MpegEncContext *s, +static void dct_unquantize_mpeg1_inter_mmx(MPVContext *s, int16_t *block, int n, int qscale) { x86_reg nCoeffs; @@ -300,7 +300,7 @@ __asm__ volatile( ); } -static void dct_unquantize_mpeg2_intra_mmx(MpegEncContext *s, +static void dct_unquantize_mpeg2_intra_mmx(MPVContext *s, int16_t *block, int n, int qscale) { x86_reg nCoeffs; @@ -369,7 +369,7 @@ __asm__ volatile( //Note, we do not do mismatch control for intra as errors cannot accumulate } -static void dct_unquantize_mpeg2_inter_mmx(MpegEncContext *s, +static void dct_unquantize_mpeg2_inter_mmx(MPVContext *s, int16_t *block, int n, int qscale) { x86_reg nCoeffs; @@ -451,7 +451,7 @@ __asm__ volatile( #endif /* HAVE_MMX_INLINE */ -av_cold void ff_mpv_common_init_x86(MpegEncContext *s) +av_cold void ff_mpv_common_init_x86(MPVContext *s) { #if HAVE_MMX_INLINE int cpu_flags = av_get_cpu_flags(); diff --git a/libavcodec/x86/mpegvideoenc.c b/libavcodec/x86/mpegvideoenc.c index 3691cce26c..7ce045046a 100644 --- a/libavcodec/x86/mpegvideoenc.c +++ b/libavcodec/x86/mpegvideoenc.c @@ -97,7 +97,8 @@ DECLARE_ALIGNED(16, static const uint16_t, inv_zigzag_direct16)[64] = { #if HAVE_INLINE_ASM #if HAVE_MMX_INLINE -static void denoise_dct_mmx(MpegEncContext *s, int16_t *block){ +static void denoise_dct_mmx(MPVEncContext *s, int16_t *block) +{ const int intra= s->mb_intra; int *sum= s->dct_error_sum[intra]; uint16_t *offset= s->dct_offset[intra]; @@ -153,7 +154,8 @@ static void denoise_dct_mmx(MpegEncContext *s, int16_t *block){ #endif /* HAVE_MMX_INLINE */ #if HAVE_SSE2_INLINE -static void denoise_dct_sse2(MpegEncContext *s, int16_t *block){ +static void denoise_dct_sse2(MPVEncContext *s, int16_t *block) +{ const int intra= s->mb_intra; int *sum= s->dct_error_sum[intra]; uint16_t *offset= s->dct_offset[intra]; @@ -211,7 +213,7 @@ static void denoise_dct_sse2(MpegEncContext *s, int16_t *block){ #endif /* HAVE_SSE2_INLINE */ #endif /* HAVE_INLINE_ASM */ -av_cold void ff_dct_encode_init_x86(MpegEncContext *s) +av_cold void ff_dct_encode_init_x86(MPVEncContext *s) { const int dct_algo = s->avctx->dct_algo; diff --git a/libavcodec/x86/mpegvideoenc_template.c b/libavcodec/x86/mpegvideoenc_template.c index 30c06a6b2c..19a0d3ac7e 100644 --- a/libavcodec/x86/mpegvideoenc_template.c +++ b/libavcodec/x86/mpegvideoenc_template.c @@ -100,7 +100,7 @@ "psubw "a", "b" \n\t" // out=((ABS(block[i])*qmat[0] - bias[0]*qmat[0])>>16)*sign(block[i]) #endif -static int RENAME(dct_quantize)(MpegEncContext *s, +static int RENAME(dct_quantize)(MPVEncContext *s, int16_t *block, int n, int qscale, int *overflow) { diff --git a/libavcodec/xvmc_internal.h b/libavcodec/xvmc_internal.h index d365ef0266..a08f94d60e 100644 --- a/libavcodec/xvmc_internal.h +++ b/libavcodec/xvmc_internal.h @@ -21,11 +21,9 @@ #ifndef AVCODEC_XVMC_INTERNAL_H #define AVCODEC_XVMC_INTERNAL_H -#include "avcodec.h" -#include "mpegvideo.h" -#include "version.h" +#include "mpegvideodec.h" -void ff_xvmc_init_block(MpegEncContext *s); -void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp); +void ff_xvmc_init_block(MPVDecContext *s); +void ff_xvmc_pack_pblocks(MPVDecContext *s, int cbp); #endif /* AVCODEC_XVMC_INTERNAL_H */ From patchwork Tue Feb 1 13:06:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34000 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp605245iov; Tue, 1 Feb 2022 05:13:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBgICwk1TU6CVa8QTXqr8SpKZvALI/qpa7+LSR54RgelS5d9up2NbVMvyyJ8xw0xPLwt4n X-Received: by 2002:a05:6402:693:: with SMTP id f19mr25203138edy.1.1643721189381; Tue, 01 Feb 2022 05:13:09 -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 c20si8746864ejj.420.2022.02.01.05.13.08; Tue, 01 Feb 2022 05:13:09 -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=hHwylX4z; 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 A993968B362; Tue, 1 Feb 2022 15:07:57 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-oln040092071061.outbound.protection.outlook.com [40.92.71.61]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 92E4868B347 for ; Tue, 1 Feb 2022 15:07:55 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HMpB6nMhZ6v7YtIiQrklCcgvrWFuzhpSaHtk/+siqVtWpKMI1ToU4qQXMZrVQBDpagc51ahbZDFFYUB5tY5ZfOBPh7H6wLwdObrSNJ21vqk02E+nSigwCjt9d68cgx4xMobX4OJtlt1tCx7vL6GUGGxVRhGK3Y5WWn5nZwaCokMLRFEBaa9J4pLzAazUCaCrksoSgAcVo5451OeNT01Y7KKfl/N0ezabBkSHhFHpsEI/+KK9xGNAFhW68X9geReL1iAIk8H1spF4ki5RCh/CPhLgdb7xMzwSKJCnMjLnus3EKMvdi934YXwA2j7PT4A5cgVlyW6mh2P2QNTLK3PKyQ== 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=FV0+vJnAY2hUCE1wHdQxWvDixCHHNNSGJXHFTWdK6b8=; b=hoIThLaiCaP0nOFIbyRMeoD8SRYDwJQiNPJyeTywS9EaqJ7L/gpNl+WwBBpCghXolbDQRzpLMbF8IFiiywA1LWTKqVmqgp2S3bwviUzqt1U4nKeFYzEWV0g+mmYh4Dj7CMPIvOiPBANEL4C2A0uV1Vi1DvFCAYWAZnUeb8iQdYjAwAVEoHcj85IGRDH2mwuZGTXJTPb8nuhED9ayZCLXyCFpx3wcGyvy36cCc8h8Kc8fZVS90CWU9oYe4oAZrHOqq2MIZHEVeyeWVWj1no6AcXc3oZPGjNEK4Q4GlTgeIACDhPzquD9k/rFYZImdIEItT4/v2Vo3+T2ouUt43ev/qw== 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=FV0+vJnAY2hUCE1wHdQxWvDixCHHNNSGJXHFTWdK6b8=; b=hHwylX4z3Dj8juaGC+CNrqe3ItJtjgRYp5PRj05PWdmtsOao0lexPjGdZnOudv66uYe0whrYg8THtZH+VKRI++F9vz3pwrgfGjlDXLqW4Fje7wlzuei1St89OrvJq42j1+W0qnBHvXaA78EB2qAmqdRLlKLC39i3Ciir2cxqJA261sZ+KAVXhmCsrs08XvP/isDBIey3mVmeeoXvEojvarfST+st3wFMX6lToXxaKDp5ptn1tnvPctXOqAz9xPt4TW266UatbIYYLxetlPe0kEH52RDU4zXwbhfil9zhE5RqEkZsyd7LxTPENSblQPr6AtZosNtA5pAkaHVfh1cIgA== 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:54 +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:54 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:24 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [9fm5+ukcaYfFHhmfay+WCXLHtSWrW+0x] 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-26-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8d8478fa-4fab-47e8-4403-08d9e583dbca X-MS-TrafficTypeDiagnostic: AM9PR03MB6948:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GzwNX+cGlSfi5oTVyt7aGkPHlvxUwbiZnpGWBxZPijQnMmNjFe95bvM7GpM5CYuLc6sdLhNFsP6cZJZeE+cXpqX7dzHI3TDEQjFCxIplxiqfTIVunktmcmjKubh1QbNt+UZeOPron2kaZk/0y/SnTLEI7ucQY8k1+gxRQ+dgtpBZMmMxS1nsknEsCPGmZwIh73hoSTsSgMEgW0ldbJRd3Lt+VjbPDZ1hAuhHRkOSNweNHvkOXwXvAdhIBsyDXBpN7RYUILGAp/MZ0VSSQgG8EGIk8hJPu7P6jC7+BdK6OYBTmsXrHfK3GKx4FX/lOp0maXu0p6iDfSGPgwpTBi9htd0WW3jIMfVEXexJMOvtNLVmxbf1quDI0ck5EWp46Y+A6xd4qjOazXp4/skN/6ll1H11Z+UJMAfBA53ONdu7vfulIGVR9OoeFengXmIOa854UwhcnPlaOhzD89mh8ZLlkzwGujvwhgQFtKVbf3eTZhQLTAg678fliEMqJFmXe6YxvUxJflBACa485RiD1SmF6UuNVjN3Jthw/gvii/W4qkCG9rzcIv7uAJCy+tcJqvyt X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UlxlKx/IOQS/Kkc/FA1+Pp3lDY4ma/Zppwu3IMtjt64enc97m68I6pSLkgq/NHYt0+3JRpJxOHQpHQay1dzqqqzR14bFVQFFUdeZ4AFmLrjAzYMnKSACTS3VK4dcw+kUFeRYQKK4ngpY+rhKFHN5oYy/cEVGsXUHJV8yNmk/Rw7OFkdkjhJahkkv4uUfpEKqih/R6HF5QoOO4PvWUpjVKuPq1hei6rRDsomZZSEAFR+JcT67PiwiMrAU1V6Otat0JytJO9oSzYmUE+YBy/IQaBa7dfMQaE7+CmDzz7YUyqaAHOfqTHOcimhnsq+bnB8nP+EKbIcBcnAdmELfql1Lfa/XnnpdHefCbrHZZNysZD8psfe7XNb76+4Y5XMCtN5OKrsCcQNrg1L9P0g+YYyEE/oZx5/rj+Up1Ha2LwTdM71XGXFJCL7fxfAJ5McCXco/EjshUIpvMnMx004XQF/WVlDmjEda0D5hEStrcIyYA/iKYwxA5rQlisWVPWNr7PN5RzM+uzt4B0MryahTbl5SoBasgaPdtwyf6Y8TPsWsacM19VSkwNDu33if0KzlNRU7aW8rudQp8K8sETK5v/WnqkM/X1DDWuxAw51O4ozzsk5HchB83qMtIEPRLAzLpxZKX9wVbzJTA19mmDBmr/aQtm8LH2UepmFB0N8KC29sMygBTGzf9fwW/fG5xchk6rRJ/o7BTjDDL6+9INsELvCt+kTbSTWx1gKbKeaH14hm90VONGftJ6LkDmsfenIUdxKkhU1ERO5Z7tZxDGnYB/cANSQPq6jQBCWAdkxA0lfjQ0vzFi7JsnloV3SWBPkQicpyncsaIwvpjRx0DyvpCg1g6LZBGQ8bK/gO8PwKTtaw+hHBW0PjQX63ynYEe9YKbYC1ETffy/f1Q9fgetq2skqq3OkmDQHDHgbQQFlkYyvfBycc5gUw67s5FzZYsrHjU/VmsQdpCb/ux6VZpN9xjVrMkg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d8478fa-4fab-47e8-4403-08d9e583dbca 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:54.1671 (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 27/69] avcodec/mpegvideo_enc: Don't find encoder by ID 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: GegmoBBIjCnq mpegvideo-based encoders supporting bframes implement this by opening encoders of their own to test how long the chains of bframes are supposed to be. The needed AVCodec was obtained via avcodec_find_encoder(). This is complicated, as the current encoder can be directly obtained. And it also is not guaranteed that one actually gets the current encoder or not another encoder for the same codec ID (the latter does not seem to be the case now). Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo_enc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 20c61dc0a6..5bf135bccf 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -1218,7 +1218,6 @@ static int encode_frame(AVCodecContext *c, AVFrame *frame, AVPacket *pkt) static int estimate_best_b_count(MPVMainEncContext *s) { - const AVCodec *codec = avcodec_find_encoder(s->avctx->codec_id); AVPacket *pkt; const int scale = s->brd_scale; int width = s->width >> scale; @@ -1302,7 +1301,7 @@ static int estimate_best_b_count(MPVMainEncContext *s) c->time_base = s->avctx->time_base; c->max_b_frames = s->max_b_frames; - ret = avcodec_open2(c, codec, NULL); + ret = avcodec_open2(c, s->avctx->codec, NULL); if (ret < 0) goto fail; From patchwork Tue Feb 1 13:06:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34002 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp605701iov; Tue, 1 Feb 2022 05:13:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9kQ6HVhmi68MM9oLQfemV1rplbRqyrPSdJ6ZN5gJaMBQcRT26FzfyEPVr7G8RAlS/+Wi+ X-Received: by 2002:a17:907:9619:: with SMTP id gb25mr20816591ejc.426.1643721222228; Tue, 01 Feb 2022 05:13:42 -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 sh10si8879356ejc.278.2022.02.01.05.13.41; Tue, 01 Feb 2022 05:13:42 -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=XxLtKjHf; 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 A0A2368B36F; Tue, 1 Feb 2022 15:08:01 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2079.outbound.protection.outlook.com [40.92.89.79]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0F2F068B304 for ; Tue, 1 Feb 2022 15:07:59 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QboMMEpyN3SECvueyYCLEX0eHSsnzaqpu1ps0nHvThujzQNQ7j+m5+Xv6pv4OM28qzgaWNYSH87GX7ZPqLB6oAJsag3l1RBbH4exK/KNJJLjRlf1mU9IwhoJsOKHald2vsLoVUIq5830Nii1aEBFQuXx6tYt16A8DF+YiTe4fC+PyfCIVJo1cBdOnTtWoZDEx3BA7JNIFuUIBxoWy30FoT6irYWneFbKc6acysLFPuA+Q5grIiG3pWNpg7RROZ+Um3iCDwFPoguOlqumFSeLPviIe1mCpHdFOnHpFE2BSTqu8GOH6ymW2S7D9+qZzyL/eJGiHC95TYudo8iQPyhjIg== 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=RolCVSZ2I++jsDIm8iynPtGHIDVofqwaE1+OkhfXVAQ=; b=OsA1t1fDbiop6XND8CZNWjRkSEiKYGxOvjlLjHsvTE1cLmaJJq839OHmKKq4U0nhm1N9DE3zSOhCls5j858LlXOoPtlM8VX27hxy9sAgvFjCe6U+vfNF37aUmLmSPGZZrTY9E1xj40tgdNCctW60dOpThOmlWpi2yYHCHbOd/23XsHXwd3C8Y2xSVrv0PzhNZvqL4eu2l5MqaMUT+UCIwWoJYLcmf93UulFV9rpFvMRH3LLppqpjJQN4RYPeTbw2eZSXnV2euO9BjHwUQgkL42Yz7U/v9WGvxsyhsYB4kJEcManrNpgvKQjWu6kAZUv8QNWK6Zt5DiXB6xq1GxsNzQ== 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=RolCVSZ2I++jsDIm8iynPtGHIDVofqwaE1+OkhfXVAQ=; b=XxLtKjHf7oMflaMbCxJ0+zGIflBzEqOm362t80LG5eENw8Ip/777Dq3F/26Tj77krQkINem5QFCyj51ORMHeymM5kAlGYoJm3MoFgv0+NReFAPSNWD9aT9UxLSHYuYLLyPsOYZiiolWox04wVgv8l+rvsAgrqJQo7TBLfXm0OALVepyLki1fvkgk/T61oshnF7VW1CV7NN6J9jJH3o9uw+4vPiaCodhjYxZ0hyMh18Zyt7EVCatBYQX9Roatj6nZBYUWRp6/fjTgpix9WlyX+YuzNNSAGXmxdvD7P/xMeu9bOdF2gs+nteJ5Bmrpeu7k1jODy2UJCxk/bBebEmBwKw== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR03MB5700.eurprd03.prod.outlook.com (2603:10a6:208:16f::32) 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:55 +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:55 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:25 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [iORy9LkI82l9n0BsJWXfrcaS/lvhaAia] 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-27-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 672950f4-aefa-4146-1cd7-08d9e583dc78 X-MS-TrafficTypeDiagnostic: AM0PR03MB5700:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kqwh4zCs+tAPGy9/PxRkaHho8C6jZPwUe9vWo/ty667643boGvrImO8wdSzbFGkR4BH6DAlvqy2LjPijLELadjHPLT9WK2EB/vIso7HQsoM4bl3NADbHTsmWeoggz3rNDgr7yJPHdZzWFwBntUTkScztwkQ4834a0w50pIV8zOHp15UH9Q/7zzSD14RVCw8qHnJFt3ShqZ9jMr6LoG3Q945lKq4URpvtElIhmeiTohSKQaD31B0D/kEgGAWKUNApnvYXRFgcGXsoZJ1Nvc4lMIbUEQrOOoq0+8k1zpj29ELUWOvZa53pPr+zfqEhudj1QRYxcfkV1WJKExssjjBKhTOnWkQzkGA3bmVza/SAyQLJ2aG4HMNvVsmKR0rGwBuX25TzgttBpIJVcXZFD05lotM0l1yfYHahgsAhh17vGb0jiA1yTjstSUuuKkKRq0O5lXWm8/XWOCa8Yw6A42W33p+MgAl/wIiOnw9plFWcpYE0NoITH/30dQtstX0d4p50KnEMVHMMx58GmuMAJlwzIiEyplnFmYE/205cvITFa2FV8UDTNHTjskTIrrcm+B8i X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uTPO0xUOcpLPgVa7UZ2W5IzSMquscOhGgYknw/m/6gHB/21Wf3tKd3CoVBz0ZxO+0zPATK6jYooRPT2ODRVTMFeIPt7zUjfAa/JxnkF8DdtvC1lQsPynjCUOEFngkSPWzcKct7KCnU2rhRnD1QUAUVP00sr86H1Cqf9VyNl8BgDL5k2a5ZdmJAYZiAV31p5RwB8Wk3A/wKTL/0RhoclttZTwIXwtp/osxUeNZEQRdf5hZMYzPGqlEhKgKceD+x2rHZE81tak1mD7ZKZySwAKSNda3JcBBVGJ9sHQp/YE+gGNDRkrL4SkLi/UY9CEQwZRImIR+6lLpCCuZT0O69Gr+UHvZkJDnb7XzKJqp5gFFDFgFLcerPg4rI3MGtlvxTlzapxce4dgx7XRMVxtzzU7hU8+EJnBiWKiwugo0FHqqfVZs+xz62Ni1RHyus+PNVm0Jo7L0cYKFYY1qm+vvf3BgXglbEtl6oIzrM/ShQDkz4RZlu30jTqWyKUjbSFSDG0/P+2IcC66DWWmd0BQJLr7MX+giv9E3UDRFC1ghOI0qVQ9rjzGS0tuJTOe8oTRzv4INs0gjOJmbJTJTOT0c7yTs45vAuWlxDvf7nV5gm3mlwMc2sIqNeOPeJcItZO0pRtW9yQF66skx9hAOwcy0ooNz2xoSJ/8W2aCL5RzQgahvurk+2EckNpXBgNx8VbyoDdHsU+cRnRfHYdk7hMOCrxfWRjE6/2DHbGUB+FjIkQBU19Us2n0T5Wo+aAflfvmBaq9J04Kw9lxx8a38Qns9LzLB8VOoV85oG8uHM0ec5kVkS4F0GZaeSaeb9MN+RSclKCimjJGA0FxW0vvJZ34+SaLFJRyFZLHaEcJTVaW7ymBvpHn9UU5YJZl5QYNBIhDLewM0BGWE0uZqgSzlMM7qpqRpeY0apEW9G8GW0kGc2uiX8kkYRwwiWDzw+hpoW8gvoZ1kV7aaidkWxwFwqBUakW/kA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 672950f4-aefa-4146-1cd7-08d9e583dc78 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:55.5252 (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: AM0PR03MB5700 Subject: [FFmpeg-devel] [PATCH v2 28/69] avcodec/mpegvideoenc: Add proper MPVMainEncContext 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: FVQVPHd9Roxd This is in preparation for moving fields only used by the main encoder thread from MPVContext to MPVMainEncContext. Signed-off-by: Andreas Rheinhardt --- libavcodec/dnxhdenc.c | 302 +++++++++++++++++++------------------ libavcodec/flvenc.c | 3 +- libavcodec/h261enc.c | 15 +- libavcodec/ituh263enc.c | 13 +- libavcodec/mjpegenc.c | 24 +-- libavcodec/mpeg12enc.c | 23 +-- libavcodec/mpeg4videoenc.c | 41 ++--- libavcodec/mpegvideo_enc.c | 135 +++++++++-------- libavcodec/mpegvideoenc.h | 7 +- libavcodec/msmpeg4enc.c | 12 +- libavcodec/ratecontrol.c | 59 +++++--- libavcodec/ratecontrol.h | 2 - libavcodec/rv10enc.c | 3 +- libavcodec/rv20enc.c | 3 +- libavcodec/snow.c | 11 +- libavcodec/snowenc.c | 170 +++++++++++---------- libavcodec/speedhqenc.c | 8 +- libavcodec/svq1enc.c | 159 +++++++++---------- libavcodec/wmv2enc.c | 12 +- 19 files changed, 542 insertions(+), 460 deletions(-) diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index 74989276b9..9ad95ac20a 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -267,30 +267,31 @@ static av_cold int dnxhd_init_qmat(DNXHDEncContext *ctx, int lbias, int cbias) int qscale, i; const uint8_t *luma_weight_table = ctx->cid_table->luma_weight; const uint8_t *chroma_weight_table = ctx->cid_table->chroma_weight; + MPVEncContext *const s = &ctx->m.common; - if (!FF_ALLOCZ_TYPED_ARRAY(ctx->qmatrix_l, ctx->m.avctx->qmax + 1) || - !FF_ALLOCZ_TYPED_ARRAY(ctx->qmatrix_c, ctx->m.avctx->qmax + 1) || - !FF_ALLOCZ_TYPED_ARRAY(ctx->qmatrix_l16, ctx->m.avctx->qmax + 1) || - !FF_ALLOCZ_TYPED_ARRAY(ctx->qmatrix_c16, ctx->m.avctx->qmax + 1)) + if (!FF_ALLOCZ_TYPED_ARRAY(ctx->qmatrix_l, s->avctx->qmax + 1) || + !FF_ALLOCZ_TYPED_ARRAY(ctx->qmatrix_c, s->avctx->qmax + 1) || + !FF_ALLOCZ_TYPED_ARRAY(ctx->qmatrix_l16, s->avctx->qmax + 1) || + !FF_ALLOCZ_TYPED_ARRAY(ctx->qmatrix_c16, s->avctx->qmax + 1)) return AVERROR(ENOMEM); if (ctx->bit_depth == 8) { for (i = 1; i < 64; i++) { - int j = ctx->m.idsp.idct_permutation[ff_zigzag_direct[i]]; + int j = s->idsp.idct_permutation[ff_zigzag_direct[i]]; weight_matrix[j] = ctx->cid_table->luma_weight[i]; } - ff_convert_matrix(&ctx->m, ctx->qmatrix_l, ctx->qmatrix_l16, + ff_convert_matrix(s, ctx->qmatrix_l, ctx->qmatrix_l16, weight_matrix, ctx->intra_quant_bias, 1, - ctx->m.avctx->qmax, 1); + s->avctx->qmax, 1); for (i = 1; i < 64; i++) { - int j = ctx->m.idsp.idct_permutation[ff_zigzag_direct[i]]; + int j = s->idsp.idct_permutation[ff_zigzag_direct[i]]; weight_matrix[j] = ctx->cid_table->chroma_weight[i]; } - ff_convert_matrix(&ctx->m, ctx->qmatrix_c, ctx->qmatrix_c16, + ff_convert_matrix(s, ctx->qmatrix_c, ctx->qmatrix_c16, weight_matrix, ctx->intra_quant_bias, 1, - ctx->m.avctx->qmax, 1); + s->avctx->qmax, 1); - for (qscale = 1; qscale <= ctx->m.avctx->qmax; qscale++) { + for (qscale = 1; qscale <= s->avctx->qmax; qscale++) { for (i = 0; i < 64; i++) { ctx->qmatrix_l[qscale][i] <<= 2; ctx->qmatrix_c[qscale][i] <<= 2; @@ -302,7 +303,7 @@ static av_cold int dnxhd_init_qmat(DNXHDEncContext *ctx, int lbias, int cbias) } } else { // 10-bit - for (qscale = 1; qscale <= ctx->m.avctx->qmax; qscale++) { + for (qscale = 1; qscale <= s->avctx->qmax; qscale++) { for (i = 1; i < 64; i++) { int j = ff_zigzag_direct[i]; @@ -325,22 +326,23 @@ static av_cold int dnxhd_init_qmat(DNXHDEncContext *ctx, int lbias, int cbias) } } - ctx->m.q_chroma_intra_matrix16 = ctx->qmatrix_c16; - ctx->m.q_chroma_intra_matrix = ctx->qmatrix_c; - ctx->m.q_intra_matrix16 = ctx->qmatrix_l16; - ctx->m.q_intra_matrix = ctx->qmatrix_l; + s->q_chroma_intra_matrix16 = ctx->qmatrix_c16; + s->q_chroma_intra_matrix = ctx->qmatrix_c; + s->q_intra_matrix16 = ctx->qmatrix_l16; + s->q_intra_matrix = ctx->qmatrix_l; return 0; } static av_cold int dnxhd_init_rc(DNXHDEncContext *ctx) { - if (!FF_ALLOCZ_TYPED_ARRAY(ctx->mb_rc, (ctx->m.avctx->qmax + 1) * ctx->m.mb_num)) + MPVEncContext *const s = &ctx->m.common; + if (!FF_ALLOCZ_TYPED_ARRAY(ctx->mb_rc, (s->avctx->qmax + 1) * s->mb_num)) return AVERROR(ENOMEM); - if (ctx->m.avctx->mb_decision != FF_MB_DECISION_RD) { - if (!FF_ALLOCZ_TYPED_ARRAY(ctx->mb_cmp, ctx->m.mb_num) || - !FF_ALLOCZ_TYPED_ARRAY(ctx->mb_cmp_tmp, ctx->m.mb_num)) + if (s->avctx->mb_decision != FF_MB_DECISION_RD) { + if (!FF_ALLOCZ_TYPED_ARRAY(ctx->mb_cmp, s->mb_num) || + !FF_ALLOCZ_TYPED_ARRAY(ctx->mb_cmp_tmp, s->mb_num)) return AVERROR(ENOMEM); } ctx->frame_bits = (ctx->coding_unit_size - @@ -353,6 +355,7 @@ static av_cold int dnxhd_init_rc(DNXHDEncContext *ctx) static av_cold int dnxhd_encode_init(AVCodecContext *avctx) { DNXHDEncContext *ctx = avctx->priv_data; + MPVEncContext *const s = &ctx->m.common; int i, ret; switch (avctx->pix_fmt) { @@ -412,31 +415,31 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx) ctx->cid_table = ff_dnxhd_get_cid_table(ctx->cid); av_assert0(ctx->cid_table); - ctx->m.avctx = avctx; - ctx->m.mb_intra = 1; - ctx->m.h263_aic = 1; + s->avctx = avctx; + s->mb_intra = 1; + s->h263_aic = 1; avctx->bits_per_raw_sample = ctx->bit_depth; ff_blockdsp_init(&ctx->bdsp, avctx); - ff_fdctdsp_init(&ctx->m.fdsp, avctx); - ff_mpv_idct_init(&ctx->m); - ff_mpegvideoencdsp_init(&ctx->m.mpvencdsp, avctx); - ff_pixblockdsp_init(&ctx->m.pdsp, avctx); - ff_dct_encode_init(&ctx->m); + ff_fdctdsp_init(&s->fdsp, avctx); + ff_mpv_idct_init(s); + ff_mpegvideoencdsp_init(&s->mpvencdsp, avctx); + ff_pixblockdsp_init(&s->pdsp, avctx); + ff_dct_encode_init(s); if (ctx->profile != FF_PROFILE_DNXHD) - ff_videodsp_init(&ctx->m.vdsp, ctx->bit_depth); + ff_videodsp_init(&s->vdsp, ctx->bit_depth); - if (!ctx->m.dct_quantize) - ctx->m.dct_quantize = ff_dct_quantize_c; + if (!s->dct_quantize) + s->dct_quantize = ff_dct_quantize_c; if (ctx->is_444 || ctx->profile == FF_PROFILE_DNXHR_HQX) { - ctx->m.dct_quantize = dnxhd_10bit_dct_quantize_444; + s->dct_quantize = dnxhd_10bit_dct_quantize_444; ctx->get_pixels_8x4_sym = dnxhd_10bit_get_pixels_8x4_sym; ctx->block_width_l2 = 4; } else if (ctx->bit_depth == 10) { - ctx->m.dct_quantize = dnxhd_10bit_dct_quantize; + s->dct_quantize = dnxhd_10bit_dct_quantize; ctx->get_pixels_8x4_sym = dnxhd_10bit_get_pixels_8x4_sym; ctx->block_width_l2 = 4; } else { @@ -447,12 +450,12 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx) if (ARCH_X86) ff_dnxhdenc_init_x86(ctx); - ctx->m.mb_height = (avctx->height + 15) / 16; - ctx->m.mb_width = (avctx->width + 15) / 16; + s->mb_height = (avctx->height + 15) / 16; + s->mb_width = (avctx->width + 15) / 16; if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) { ctx->interlaced = 1; - ctx->m.mb_height /= 2; + s->mb_height /= 2; } if (ctx->interlaced && ctx->profile != FF_PROFILE_DNXHD) { @@ -461,7 +464,7 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx) return AVERROR(EINVAL); } - ctx->m.mb_num = ctx->m.mb_height * ctx->m.mb_width; + s->mb_num = s->mb_height * s->mb_width; if (ctx->cid_table->frame_size == DNXHD_VARIABLE) { ctx->frame_size = ff_dnxhd_get_hr_frame_size(ctx->cid, @@ -473,8 +476,8 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx) ctx->coding_unit_size = ctx->cid_table->coding_unit_size; } - if (ctx->m.mb_height > 68) - ctx->data_offset = 0x170 + (ctx->m.mb_height << 2); + if (s->mb_height > 68) + ctx->data_offset = 0x170 + (s->mb_height << 2); else ctx->data_offset = 0x280; @@ -492,10 +495,10 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx) if ((ret = dnxhd_init_rc(ctx)) < 0) return ret; - if (!FF_ALLOCZ_TYPED_ARRAY(ctx->slice_size, ctx->m.mb_height) || - !FF_ALLOCZ_TYPED_ARRAY(ctx->slice_offs, ctx->m.mb_height) || - !FF_ALLOCZ_TYPED_ARRAY(ctx->mb_bits, ctx->m.mb_num) || - !FF_ALLOCZ_TYPED_ARRAY(ctx->mb_qscale, ctx->m.mb_num)) + if (!FF_ALLOCZ_TYPED_ARRAY(ctx->slice_size, s->mb_height) || + !FF_ALLOCZ_TYPED_ARRAY(ctx->slice_offs, s->mb_height) || + !FF_ALLOCZ_TYPED_ARRAY(ctx->mb_bits, s->mb_num) || + !FF_ALLOCZ_TYPED_ARRAY(ctx->mb_qscale, s->mb_num)) return AVERROR(ENOMEM); if (avctx->active_thread_type == FF_THREAD_SLICE) { @@ -525,6 +528,7 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx) static int dnxhd_write_header(AVCodecContext *avctx, uint8_t *buf) { DNXHDEncContext *ctx = avctx->priv_data; + MPVEncContext *const s = &ctx->m.common; memset(buf, 0, ctx->data_offset); @@ -550,8 +554,8 @@ static int dnxhd_write_header(AVCodecContext *avctx, uint8_t *buf) buf[0x5f] = 0x01; // UDL buf[0x167] = 0x02; // reserved - AV_WB16(buf + 0x16a, ctx->m.mb_height * 4 + 4); // MSIPS - AV_WB16(buf + 0x16c, ctx->m.mb_height); // Ns + AV_WB16(buf + 0x16a, s->mb_height * 4 + 4); // MSIPS + AV_WB16(buf + 0x16c, s->mb_height); // Ns buf[0x16f] = 0x10; // reserved ctx->msip = buf + 0x170; @@ -567,7 +571,7 @@ static av_always_inline void dnxhd_encode_dc(DNXHDEncContext *ctx, int diff) } else { nbits = av_log2_16bit(2 * diff); } - put_bits(&ctx->m.pb, ctx->cid_table->dc_bits[nbits] + nbits, + put_bits(&ctx->m.common.pb, ctx->cid_table->dc_bits[nbits] + nbits, (ctx->cid_table->dc_codes[nbits] << nbits) + av_mod_uintp2(diff, nbits)); } @@ -576,26 +580,27 @@ static av_always_inline void dnxhd_encode_block(DNXHDEncContext *ctx, int16_t *block, int last_index, int n) { + MPVEncContext *const s = &ctx->m.common; int last_non_zero = 0; int slevel, i, j; - dnxhd_encode_dc(ctx, block[0] - ctx->m.last_dc[n]); - ctx->m.last_dc[n] = block[0]; + dnxhd_encode_dc(ctx, block[0] - s->last_dc[n]); + s->last_dc[n] = block[0]; for (i = 1; i <= last_index; i++) { - j = ctx->m.intra_scantable.permutated[i]; + j = s->intra_scantable.permutated[i]; slevel = block[j]; if (slevel) { int run_level = i - last_non_zero - 1; int rlevel = slevel * (1 << 1) | !!run_level; - put_bits(&ctx->m.pb, ctx->vlc_bits[rlevel], ctx->vlc_codes[rlevel]); + put_bits(&s->pb, ctx->vlc_bits[rlevel], ctx->vlc_codes[rlevel]); if (run_level) - put_bits(&ctx->m.pb, ctx->run_bits[run_level], + put_bits(&s->pb, ctx->run_bits[run_level], ctx->run_codes[run_level]); last_non_zero = i; } } - put_bits(&ctx->m.pb, ctx->vlc_bits[0], ctx->vlc_codes[0]); // EOB + put_bits(&s->pb, ctx->vlc_bits[0], ctx->vlc_codes[0]); // EOB } static av_always_inline @@ -615,7 +620,7 @@ void dnxhd_unquantize_c(DNXHDEncContext *ctx, int16_t *block, int n, } for (i = 1; i <= last_index; i++) { - int j = ctx->m.intra_scantable.permutated[i]; + int j = ctx->m.common.intra_scantable.permutated[i]; level = block[j]; if (level) { if (level < 0) { @@ -663,7 +668,7 @@ int dnxhd_calc_ac_bits(DNXHDEncContext *ctx, int16_t *block, int last_index) int bits = 0; int i, j, level; for (i = 1; i <= last_index; i++) { - j = ctx->m.intra_scantable.permutated[i]; + j = ctx->m.common.intra_scantable.permutated[i]; level = block[j]; if (level) { int run_level = i - last_non_zero - 1; @@ -678,40 +683,41 @@ int dnxhd_calc_ac_bits(DNXHDEncContext *ctx, int16_t *block, int last_index) static av_always_inline void dnxhd_get_blocks(DNXHDEncContext *ctx, int mb_x, int mb_y) { + MPVEncContext *const s = &ctx->m.common; const int bs = ctx->block_width_l2; const int bw = 1 << bs; int dct_y_offset = ctx->dct_y_offset; int dct_uv_offset = ctx->dct_uv_offset; - int linesize = ctx->m.linesize; - int uvlinesize = ctx->m.uvlinesize; + int linesize = s->linesize; + int uvlinesize = s->uvlinesize; const uint8_t *ptr_y = ctx->thread[0]->src[0] + - ((mb_y << 4) * ctx->m.linesize) + (mb_x << bs + 1); + ((mb_y << 4) * s->linesize) + (mb_x << bs + 1); const uint8_t *ptr_u = ctx->thread[0]->src[1] + - ((mb_y << 4) * ctx->m.uvlinesize) + (mb_x << bs + ctx->is_444); + ((mb_y << 4) * s->uvlinesize) + (mb_x << bs + ctx->is_444); const uint8_t *ptr_v = ctx->thread[0]->src[2] + - ((mb_y << 4) * ctx->m.uvlinesize) + (mb_x << bs + ctx->is_444); - PixblockDSPContext *pdsp = &ctx->m.pdsp; - VideoDSPContext *vdsp = &ctx->m.vdsp; - - if (ctx->bit_depth != 10 && vdsp->emulated_edge_mc && ((mb_x << 4) + 16 > ctx->m.avctx->width || - (mb_y << 4) + 16 > ctx->m.avctx->height)) { - int y_w = ctx->m.avctx->width - (mb_x << 4); - int y_h = ctx->m.avctx->height - (mb_y << 4); + ((mb_y << 4) * s->uvlinesize) + (mb_x << bs + ctx->is_444); + PixblockDSPContext *pdsp = &s->pdsp; + VideoDSPContext *vdsp = &s->vdsp; + + if (ctx->bit_depth != 10 && vdsp->emulated_edge_mc && ((mb_x << 4) + 16 > s->avctx->width || + (mb_y << 4) + 16 > s->avctx->height)) { + int y_w = s->avctx->width - (mb_x << 4); + int y_h = s->avctx->height - (mb_y << 4); int uv_w = (y_w + 1) / 2; int uv_h = y_h; linesize = 16; uvlinesize = 8; vdsp->emulated_edge_mc(&ctx->edge_buf_y[0], ptr_y, - linesize, ctx->m.linesize, + linesize, s->linesize, linesize, 16, 0, 0, y_w, y_h); vdsp->emulated_edge_mc(&ctx->edge_buf_uv[0][0], ptr_u, - uvlinesize, ctx->m.uvlinesize, + uvlinesize, s->uvlinesize, uvlinesize, 16, 0, 0, uv_w, uv_h); vdsp->emulated_edge_mc(&ctx->edge_buf_uv[1][0], ptr_v, - uvlinesize, ctx->m.uvlinesize, + uvlinesize, s->uvlinesize, uvlinesize, 16, 0, 0, uv_w, uv_h); @@ -720,25 +726,25 @@ void dnxhd_get_blocks(DNXHDEncContext *ctx, int mb_x, int mb_y) ptr_y = &ctx->edge_buf_y[0]; ptr_u = &ctx->edge_buf_uv[0][0]; ptr_v = &ctx->edge_buf_uv[1][0]; - } else if (ctx->bit_depth == 10 && vdsp->emulated_edge_mc && ((mb_x << 4) + 16 > ctx->m.avctx->width || - (mb_y << 4) + 16 > ctx->m.avctx->height)) { - int y_w = ctx->m.avctx->width - (mb_x << 4); - int y_h = ctx->m.avctx->height - (mb_y << 4); + } else if (ctx->bit_depth == 10 && vdsp->emulated_edge_mc && ((mb_x << 4) + 16 > s->avctx->width || + (mb_y << 4) + 16 > s->avctx->height)) { + int y_w = s->avctx->width - (mb_x << 4); + int y_h = s->avctx->height - (mb_y << 4); int uv_w = ctx->is_444 ? y_w : (y_w + 1) / 2; int uv_h = y_h; linesize = 32; uvlinesize = 16 + 16 * ctx->is_444; vdsp->emulated_edge_mc(&ctx->edge_buf_y[0], ptr_y, - linesize, ctx->m.linesize, + linesize, s->linesize, linesize / 2, 16, 0, 0, y_w, y_h); vdsp->emulated_edge_mc(&ctx->edge_buf_uv[0][0], ptr_u, - uvlinesize, ctx->m.uvlinesize, + uvlinesize, s->uvlinesize, uvlinesize / 2, 16, 0, 0, uv_w, uv_h); vdsp->emulated_edge_mc(&ctx->edge_buf_uv[1][0], ptr_v, - uvlinesize, ctx->m.uvlinesize, + uvlinesize, s->uvlinesize, uvlinesize / 2, 16, 0, 0, uv_w, uv_h); @@ -755,7 +761,7 @@ void dnxhd_get_blocks(DNXHDEncContext *ctx, int mb_x, int mb_y) pdsp->get_pixels(ctx->blocks[2], ptr_u, uvlinesize); pdsp->get_pixels(ctx->blocks[3], ptr_v, uvlinesize); - if (mb_y + 1 == ctx->m.mb_height && ctx->m.avctx->height == 1080) { + if (mb_y + 1 == s->mb_height && s->avctx->height == 1080) { if (ctx->interlaced) { ctx->get_pixels_8x4_sym(ctx->blocks[4], ptr_y + dct_y_offset, @@ -821,17 +827,18 @@ static int dnxhd_calc_bits_thread(AVCodecContext *avctx, void *arg, int jobnr, int threadnr) { DNXHDEncContext *ctx = avctx->priv_data; + MPVEncContext *const s = &ctx->m.common; int mb_y = jobnr, mb_x; int qscale = ctx->qscale; LOCAL_ALIGNED_16(int16_t, block, [64]); ctx = ctx->thread[threadnr]; - ctx->m.last_dc[0] = - ctx->m.last_dc[1] = - ctx->m.last_dc[2] = 1 << (ctx->bit_depth + 2); + s->last_dc[0] = + s->last_dc[1] = + s->last_dc[2] = 1 << (ctx->bit_depth + 2); - for (mb_x = 0; mb_x < ctx->m.mb_width; mb_x++) { - unsigned mb = mb_y * ctx->m.mb_width + mb_x; + for (mb_x = 0; mb_x < s->mb_width; mb_x++) { + unsigned mb = mb_y * s->mb_width + mb_x; int ssd = 0; int ac_bits = 0; int dc_bits = 0; @@ -845,12 +852,12 @@ static int dnxhd_calc_bits_thread(AVCodecContext *avctx, void *arg, int n = dnxhd_switch_matrix(ctx, i); memcpy(block, src_block, 64 * sizeof(*block)); - last_index = ctx->m.dct_quantize(&ctx->m, block, + last_index = s->dct_quantize(s, block, ctx->is_444 ? 4 * (n > 0): 4 & (2*i), qscale, &overflow); ac_bits += dnxhd_calc_ac_bits(ctx, block, last_index); - diff = block[0] - ctx->m.last_dc[n]; + diff = block[0] - s->last_dc[n]; if (diff < 0) nbits = av_log2_16bit(-2 * diff); else @@ -859,16 +866,16 @@ static int dnxhd_calc_bits_thread(AVCodecContext *avctx, void *arg, av_assert1(nbits < ctx->bit_depth + 4); dc_bits += ctx->cid_table->dc_bits[nbits] + nbits; - ctx->m.last_dc[n] = block[0]; + s->last_dc[n] = block[0]; if (avctx->mb_decision == FF_MB_DECISION_RD || !RC_VARIANCE) { dnxhd_unquantize_c(ctx, block, i, qscale, last_index); - ctx->m.idsp.idct(block); + s->idsp.idct(block); ssd += dnxhd_ssd_block(block, src_block); } } - ctx->mb_rc[(qscale * ctx->m.mb_num) + mb].ssd = ssd; - ctx->mb_rc[(qscale * ctx->m.mb_num) + mb].bits = ac_bits + dc_bits + 12 + + ctx->mb_rc[(qscale * s->mb_num) + mb].ssd = ssd; + ctx->mb_rc[(qscale * s->mb_num) + mb].bits = ac_bits + dc_bits + 12 + (1 + ctx->is_444) * 8 * ctx->vlc_bits[0]; } return 0; @@ -878,50 +885,52 @@ static int dnxhd_encode_thread(AVCodecContext *avctx, void *arg, int jobnr, int threadnr) { DNXHDEncContext *ctx = avctx->priv_data; + MPVEncContext *const s = &ctx->m.common; int mb_y = jobnr, mb_x; ctx = ctx->thread[threadnr]; - init_put_bits(&ctx->m.pb, (uint8_t *)arg + ctx->data_offset + ctx->slice_offs[jobnr], + init_put_bits(&s->pb, (uint8_t *)arg + ctx->data_offset + ctx->slice_offs[jobnr], ctx->slice_size[jobnr]); - ctx->m.last_dc[0] = - ctx->m.last_dc[1] = - ctx->m.last_dc[2] = 1 << (ctx->bit_depth + 2); - for (mb_x = 0; mb_x < ctx->m.mb_width; mb_x++) { - unsigned mb = mb_y * ctx->m.mb_width + mb_x; + s->last_dc[0] = + s->last_dc[1] = + s->last_dc[2] = 1 << (ctx->bit_depth + 2); + for (mb_x = 0; mb_x < s->mb_width; mb_x++) { + unsigned mb = mb_y * s->mb_width + mb_x; int qscale = ctx->mb_qscale[mb]; int i; - put_bits(&ctx->m.pb, 11, qscale); - put_bits(&ctx->m.pb, 1, avctx->pix_fmt == AV_PIX_FMT_YUV444P10); + put_bits(&s->pb, 11, qscale); + put_bits(&s->pb, 1, avctx->pix_fmt == AV_PIX_FMT_YUV444P10); dnxhd_get_blocks(ctx, mb_x, mb_y); for (i = 0; i < 8 + 4 * ctx->is_444; i++) { int16_t *block = ctx->blocks[i]; int overflow, n = dnxhd_switch_matrix(ctx, i); - int last_index = ctx->m.dct_quantize(&ctx->m, block, + int last_index = s->dct_quantize(s, block, ctx->is_444 ? (((i >> 1) % 3) < 1 ? 0 : 4): 4 & (2*i), qscale, &overflow); dnxhd_encode_block(ctx, block, last_index, n); } } - if (put_bits_count(&ctx->m.pb) & 31) - put_bits(&ctx->m.pb, 32 - (put_bits_count(&ctx->m.pb) & 31), 0); - flush_put_bits(&ctx->m.pb); + if (put_bits_count(&s->pb) & 31) + put_bits(&s->pb, 32 - (put_bits_count(&s->pb) & 31), 0); + flush_put_bits(&s->pb); return 0; } static void dnxhd_setup_threads_slices(DNXHDEncContext *ctx) { + MPVEncContext *const s = &ctx->m.common; int mb_y, mb_x; int offset = 0; - for (mb_y = 0; mb_y < ctx->m.mb_height; mb_y++) { + for (mb_y = 0; mb_y < s->mb_height; mb_y++) { int thread_size; ctx->slice_offs[mb_y] = offset; ctx->slice_size[mb_y] = 0; - for (mb_x = 0; mb_x < ctx->m.mb_width; mb_x++) { - unsigned mb = mb_y * ctx->m.mb_width + mb_x; + for (mb_x = 0; mb_x < s->mb_width; mb_x++) { + unsigned mb = mb_y * s->mb_width + mb_x; ctx->slice_size[mb_y] += ctx->mb_bits[mb]; } ctx->slice_size[mb_y] = (ctx->slice_size[mb_y] + 31) & ~31; @@ -935,28 +944,29 @@ static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg, int jobnr, int threadnr) { DNXHDEncContext *ctx = avctx->priv_data; + MPVEncContext *const s = &ctx->m.common; int mb_y = jobnr, mb_x, x, y; - int partial_last_row = (mb_y == ctx->m.mb_height - 1) && + int partial_last_row = (mb_y == s->mb_height - 1) && ((avctx->height >> ctx->interlaced) & 0xF); ctx = ctx->thread[threadnr]; if (ctx->bit_depth == 8) { - uint8_t *pix = ctx->thread[0]->src[0] + ((mb_y << 4) * ctx->m.linesize); - for (mb_x = 0; mb_x < ctx->m.mb_width; ++mb_x, pix += 16) { - unsigned mb = mb_y * ctx->m.mb_width + mb_x; + uint8_t *pix = ctx->thread[0]->src[0] + ((mb_y << 4) * s->linesize); + for (mb_x = 0; mb_x < s->mb_width; ++mb_x, pix += 16) { + unsigned mb = mb_y * s->mb_width + mb_x; int sum; int varc; if (!partial_last_row && mb_x * 16 <= avctx->width - 16 && (avctx->width % 16) == 0) { - sum = ctx->m.mpvencdsp.pix_sum(pix, ctx->m.linesize); - varc = ctx->m.mpvencdsp.pix_norm1(pix, ctx->m.linesize); + sum = s->mpvencdsp.pix_sum(pix, s->linesize); + varc = s->mpvencdsp.pix_norm1(pix, s->linesize); } else { int bw = FFMIN(avctx->width - 16 * mb_x, 16); int bh = FFMIN((avctx->height >> ctx->interlaced) - 16 * mb_y, 16); sum = varc = 0; for (y = 0; y < bh; y++) { for (x = 0; x < bw; x++) { - uint8_t val = pix[x + y * ctx->m.linesize]; + uint8_t val = pix[x + y * s->linesize]; sum += val; varc += val * val; } @@ -968,11 +978,11 @@ static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg, ctx->mb_cmp[mb].mb = mb; } } else { // 10-bit - const int linesize = ctx->m.linesize >> 1; - for (mb_x = 0; mb_x < ctx->m.mb_width; ++mb_x) { + const int linesize = s->linesize >> 1; + for (mb_x = 0; mb_x < s->mb_width; ++mb_x) { uint16_t *pix = (uint16_t *)ctx->thread[0]->src[0] + ((mb_y << 4) * linesize) + (mb_x << 4); - unsigned mb = mb_y * ctx->m.mb_width + mb_x; + unsigned mb = mb_y * s->mb_width + mb_x; int sum = 0; int sqsum = 0; int bw = FFMIN(avctx->width - 16 * mb_x, 16); @@ -1001,6 +1011,7 @@ static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg, static int dnxhd_encode_rdo(AVCodecContext *avctx, DNXHDEncContext *ctx) { + MPVEncContext *const s = &ctx->m.common; int lambda, up_step, down_step; int last_lower = INT_MAX, last_higher = 0; int x, y, q; @@ -1008,7 +1019,7 @@ static int dnxhd_encode_rdo(AVCodecContext *avctx, DNXHDEncContext *ctx) for (q = 1; q < avctx->qmax; q++) { ctx->qscale = q; avctx->execute2(avctx, dnxhd_calc_bits_thread, - NULL, NULL, ctx->m.mb_height); + NULL, NULL, s->mb_height); } up_step = down_step = 2 << LAMBDA_FRAC_BITS; lambda = ctx->lambda; @@ -1020,14 +1031,14 @@ static int dnxhd_encode_rdo(AVCodecContext *avctx, DNXHDEncContext *ctx) lambda++; end = 1; // need to set final qscales/bits } - for (y = 0; y < ctx->m.mb_height; y++) { - for (x = 0; x < ctx->m.mb_width; x++) { + for (y = 0; y < s->mb_height; y++) { + for (x = 0; x < s->mb_width; x++) { unsigned min = UINT_MAX; int qscale = 1; - int mb = y * ctx->m.mb_width + x; + int mb = y * s->mb_width + x; int rc = 0; for (q = 1; q < avctx->qmax; q++) { - int i = (q*ctx->m.mb_num) + mb; + int i = (q*s->mb_num) + mb; unsigned score = ctx->mb_rc[i].bits * lambda + ((unsigned) ctx->mb_rc[i].ssd << LAMBDA_FRAC_BITS); if (score < min) { @@ -1078,6 +1089,7 @@ static int dnxhd_encode_rdo(AVCodecContext *avctx, DNXHDEncContext *ctx) static int dnxhd_find_qscale(DNXHDEncContext *ctx) { + MPVEncContext *const s = &ctx->m.common; int bits = 0; int up_step = 1; int down_step = 1; @@ -1091,11 +1103,11 @@ static int dnxhd_find_qscale(DNXHDEncContext *ctx) bits = 0; ctx->qscale = qscale; // XXX avoid recalculating bits - ctx->m.avctx->execute2(ctx->m.avctx, dnxhd_calc_bits_thread, - NULL, NULL, ctx->m.mb_height); - for (y = 0; y < ctx->m.mb_height; y++) { - for (x = 0; x < ctx->m.mb_width; x++) - bits += ctx->mb_rc[(qscale*ctx->m.mb_num) + (y*ctx->m.mb_width+x)].bits; + s->avctx->execute2(s->avctx, dnxhd_calc_bits_thread, + NULL, NULL, s->mb_height); + for (y = 0; y < s->mb_height; y++) { + for (x = 0; x < s->mb_width; x++) + bits += ctx->mb_rc[(qscale*s->mb_num) + (y*s->mb_width+x)].bits; bits = (bits+31)&~31; // padding if (bits > ctx->frame_bits) break; @@ -1124,7 +1136,7 @@ static int dnxhd_find_qscale(DNXHDEncContext *ctx) else qscale += up_step++; down_step = 1; - if (qscale >= ctx->m.avctx->qmax) + if (qscale >= s->avctx->qmax) return AVERROR(EINVAL); } } @@ -1190,25 +1202,26 @@ static void radix_sort(RCCMPEntry *data, RCCMPEntry *tmp, int size) static int dnxhd_encode_fast(AVCodecContext *avctx, DNXHDEncContext *ctx) { + MPVEncContext *const s = &ctx->m.common; int max_bits = 0; int ret, x, y; if ((ret = dnxhd_find_qscale(ctx)) < 0) return ret; - for (y = 0; y < ctx->m.mb_height; y++) { - for (x = 0; x < ctx->m.mb_width; x++) { - int mb = y * ctx->m.mb_width + x; - int rc = (ctx->qscale * ctx->m.mb_num ) + mb; + for (y = 0; y < s->mb_height; y++) { + for (x = 0; x < s->mb_width; x++) { + int mb = y * s->mb_width + x; + int rc = (ctx->qscale * s->mb_num ) + mb; int delta_bits; ctx->mb_qscale[mb] = ctx->qscale; ctx->mb_bits[mb] = ctx->mb_rc[rc].bits; max_bits += ctx->mb_rc[rc].bits; if (!RC_VARIANCE) { delta_bits = ctx->mb_rc[rc].bits - - ctx->mb_rc[rc + ctx->m.mb_num].bits; + ctx->mb_rc[rc + s->mb_num].bits; ctx->mb_cmp[mb].mb = mb; ctx->mb_cmp[mb].value = delta_bits ? ((ctx->mb_rc[rc].ssd - - ctx->mb_rc[rc + ctx->m.mb_num].ssd) * 100) / + ctx->mb_rc[rc + s->mb_num].ssd) * 100) / delta_bits : INT_MIN; // avoid increasing qscale } @@ -1218,15 +1231,15 @@ static int dnxhd_encode_fast(AVCodecContext *avctx, DNXHDEncContext *ctx) if (!ret) { if (RC_VARIANCE) avctx->execute2(avctx, dnxhd_mb_var_thread, - NULL, NULL, ctx->m.mb_height); - radix_sort(ctx->mb_cmp, ctx->mb_cmp_tmp, ctx->m.mb_num); - for (x = 0; x < ctx->m.mb_num && max_bits > ctx->frame_bits; x++) { + NULL, NULL, s->mb_height); + radix_sort(ctx->mb_cmp, ctx->mb_cmp_tmp, s->mb_num); + for (x = 0; x < s->mb_num && max_bits > ctx->frame_bits; x++) { int mb = ctx->mb_cmp[x].mb; - int rc = (ctx->qscale * ctx->m.mb_num ) + mb; + int rc = (ctx->qscale * s->mb_num ) + mb; max_bits -= ctx->mb_rc[rc].bits - - ctx->mb_rc[rc + ctx->m.mb_num].bits; + ctx->mb_rc[rc + s->mb_num].bits; ctx->mb_qscale[mb] = ctx->qscale + 1; - ctx->mb_bits[mb] = ctx->mb_rc[rc + ctx->m.mb_num].bits; + ctx->mb_bits[mb] = ctx->mb_rc[rc + s->mb_num].bits; } } return 0; @@ -1234,13 +1247,13 @@ static int dnxhd_encode_fast(AVCodecContext *avctx, DNXHDEncContext *ctx) static void dnxhd_load_picture(DNXHDEncContext *ctx, const AVFrame *frame) { - int i; + MPVEncContext *const s = &ctx->m.common; - for (i = 0; i < ctx->m.avctx->thread_count; i++) { - ctx->thread[i]->m.linesize = frame->linesize[0] << ctx->interlaced; - ctx->thread[i]->m.uvlinesize = frame->linesize[1] << ctx->interlaced; - ctx->thread[i]->dct_y_offset = ctx->m.linesize *8; - ctx->thread[i]->dct_uv_offset = ctx->m.uvlinesize*8; + for (int i = 0; i < s->avctx->thread_count; i++) { + ctx->thread[i]->m.common.linesize = frame->linesize[0] << ctx->interlaced; + ctx->thread[i]->m.common.uvlinesize = frame->linesize[1] << ctx->interlaced; + ctx->thread[i]->dct_y_offset = s->linesize *8; + ctx->thread[i]->dct_uv_offset = s->uvlinesize*8; } ctx->cur_field = frame->interlaced_frame && !frame->top_field_first; @@ -1250,6 +1263,7 @@ static int dnxhd_encode_picture(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet) { DNXHDEncContext *ctx = avctx->priv_data; + MPVEncContext *const s = &ctx->m.common; int first_field = 1; int offset, i, ret; uint8_t *buf; @@ -1282,13 +1296,13 @@ encode_coding_unit: dnxhd_setup_threads_slices(ctx); offset = 0; - for (i = 0; i < ctx->m.mb_height; i++) { + for (i = 0; i < s->mb_height; i++) { AV_WB32(ctx->msip + i * 4, offset); offset += ctx->slice_size[i]; av_assert1(!(ctx->slice_size[i] & 3)); } - avctx->execute2(avctx, dnxhd_encode_thread, buf, NULL, ctx->m.mb_height); + avctx->execute2(avctx, dnxhd_encode_thread, buf, NULL, s->mb_height); av_assert1(ctx->data_offset + offset + 4 <= ctx->coding_unit_size); memset(buf + ctx->data_offset + offset, 0, diff --git a/libavcodec/flvenc.c b/libavcodec/flvenc.c index 41e04e1abe..ba6bce029e 100644 --- a/libavcodec/flvenc.c +++ b/libavcodec/flvenc.c @@ -23,8 +23,9 @@ #include "mpegvideodata.h" #include "mpegvideoenc.h" -void ff_flv_encode_picture_header(MPVMainEncContext *s, int picture_number) +void ff_flv_encode_picture_header(MPVMainEncContext *m, int picture_number) { + MPVEncContext *const s = &m->common; int format; align_put_bits(&s->pb); diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c index 5c9664ea57..9c8d9d1b08 100644 --- a/libavcodec/h261enc.c +++ b/libavcodec/h261enc.c @@ -60,9 +60,10 @@ int ff_h261_get_picture_format(int width, int height) return AVERROR(EINVAL); } -void ff_h261_encode_picture_header(MPVMainEncContext *s, int picture_number) +void ff_h261_encode_picture_header(MPVMainEncContext *m, int picture_number) { - H261EncContext *const h = (H261EncContext *)s; + H261EncContext *const h = (H261EncContext *)m; + MPVEncContext *const s = &m->common; int format, temp_ref; align_put_bits(&s->pb); @@ -175,9 +176,8 @@ static inline int get_cbp(MPVEncContext *s, int16_t block[6][64]) * @param block the 8x8 block * @param n block index (0-3 are luma, 4-5 are chroma) */ -static void h261_encode_block(H261EncContext *h, int16_t *block, int n) +static void h261_encode_block(MPVEncContext *s, int16_t *block, int n) { - MPVEncContext *const s = &h->s; int level, run, i, j, last_index, last_non_zero, sign, slevel, code; RLTable *rl; @@ -326,7 +326,7 @@ void ff_h261_encode_mb(MPVEncContext *s, int16_t block[6][64], } for (i = 0; i < 6; i++) /* encode each block */ - h261_encode_block(h, block[i], i); + h261_encode_block(s, block[i], i); if (!IS_16X16(com->mtype)) { s->last_mv[0][0][0] = 0; @@ -381,9 +381,10 @@ static av_cold void h261_encode_init_static(void) init_uni_h261_rl_tab(&ff_h261_rl_tcoeff, uni_h261_rl_len); } -av_cold void ff_h261_encode_init(MPVMainEncContext *s) +av_cold void ff_h261_encode_init(MPVMainEncContext *m) { - H261EncContext *const h = (H261EncContext*)s; + H261EncContext *const h = (H261EncContext*)m; + MPVEncContext *const s = &m->common; static AVOnce init_static_once = AV_ONCE_INIT; s->private_ctx = &h->common; diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c index e0b42dd442..97173bfdc6 100644 --- a/libavcodec/ituh263enc.c +++ b/libavcodec/ituh263enc.c @@ -102,8 +102,9 @@ av_const int ff_h263_aspect_to_info(AVRational aspect){ return FF_ASPECT_EXTENDED; } -void ff_h263_encode_picture_header(MPVMainEncContext *s, int picture_number) +void ff_h263_encode_picture_header(MPVMainEncContext *m, int picture_number) { + MPVEncContext *const s = &m->common; int format, coded_frame_rate, coded_frame_rate_base, i, temp_ref; int best_clock_code=1; int best_divisor=60; @@ -266,12 +267,13 @@ void ff_h263_encode_gob_header(MPVEncContext *s, int mb_line) /** * modify qscale so that encoding is actually possible in H.263 (limit difference to -2..2) */ -void ff_clean_h263_qscales(MPVMainEncContext *s) +void ff_clean_h263_qscales(MPVMainEncContext *m) { + MPVEncContext *const s = &m->common; int i; int8_t * const qscale_table = s->current_picture.qscale_table; - ff_init_qscale_tab(s); + ff_init_qscale_tab(m); for(i=1; imb_num; i++){ if(qscale_table[ s->mb_index2xy[i] ] - qscale_table[ s->mb_index2xy[i-1] ] >2) @@ -812,8 +814,9 @@ static av_cold void h263_encode_init_static(void) init_mv_penalty_and_fcode(); } -av_cold void ff_h263_encode_init(MPVMainEncContext *s) +av_cold void ff_h263_encode_init(MPVMainEncContext *m) { + MPVEncContext *const s = &m->common; static AVOnce init_static_once = AV_ONCE_INIT; s->me.mv_penalty= mv_penalty; // FIXME exact table for MSMPEG4 & H.263+ @@ -878,7 +881,7 @@ void ff_h263_encode_mba(MPVEncContext *s) put_bits(&s->pb, ff_mba_length[i], mb_pos); } -#define OFFSET(x) offsetof(MPVMainEncContext, x) +#define OFFSET(x) offsetof(MPVMainEncContext, common.x) #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption h263_options[] = { { "obmc", "use overlapped block motion compensation.", OFFSET(obmc), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index 596accfc50..fd87186fbc 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -75,8 +75,9 @@ static av_cold void init_uni_ac_vlc(const uint8_t huff_size_ac[256], } } -static void mjpeg_encode_picture_header(MPVMainEncContext *s) +static void mjpeg_encode_picture_header(MPVMainEncContext *m) { + MPVEncContext *const s = &m->common; ff_mjpeg_encode_picture_header(s->avctx, &s->pb, s->mjpeg_ctx, &s->intra_scantable, 0, s->intra_matrix, s->chroma_intra_matrix, @@ -87,13 +88,13 @@ static void mjpeg_encode_picture_header(MPVMainEncContext *s) s->thread_context[i]->esc_pos = 0; } -void ff_mjpeg_amv_encode_picture_header(MPVMainEncContext *s) +void ff_mjpeg_amv_encode_picture_header(MPVMainEncContext *main) { - MJPEGEncContext *const m = (MJPEGEncContext*)s; - av_assert2(s->mjpeg_ctx == &m->mjpeg); + MJPEGEncContext *const m = (MJPEGEncContext*)main; + av_assert2(main->common.mjpeg_ctx == &m->mjpeg); /* s->huffman == HUFFMAN_TABLE_OPTIMAL can only be true for MJPEG. */ if (!CONFIG_MJPEG_ENCODER || m->mjpeg.huffman != HUFFMAN_TABLE_OPTIMAL) - mjpeg_encode_picture_header(s); + mjpeg_encode_picture_header(main); } #if CONFIG_MJPEG_ENCODER @@ -235,7 +236,9 @@ int ff_mjpeg_encode_stuffing(MPVEncContext *s) s->intra_chroma_ac_vlc_length = s->intra_chroma_ac_vlc_last_length = m->uni_chroma_ac_vlc_len; - mjpeg_encode_picture_header(s); + /* HUFFMAN_TABLE_OPTIMAL is incompatible with slice threading, + * therefore the following cast is allowed. */ + mjpeg_encode_picture_header((MPVMainEncContext*)s); mjpeg_encode_picture_frame(s); } #endif @@ -260,7 +263,7 @@ fail: return ret; } -static int alloc_huffman(MPVMainEncContext *s) +static int alloc_huffman(MPVEncContext *s) { MJpegContext *m = s->mjpeg_ctx; size_t num_mbs, num_blocks, num_codes; @@ -288,9 +291,10 @@ static int alloc_huffman(MPVMainEncContext *s) return 0; } -av_cold int ff_mjpeg_encode_init(MPVMainEncContext *s) +av_cold int ff_mjpeg_encode_init(MPVMainEncContext *main) { - MJpegContext *const m = &((MJPEGEncContext*)s)->mjpeg; + MJpegContext *const m = &((MJPEGEncContext*)main)->mjpeg; + MPVEncContext *const s = &main->common; int ret, use_slices; s->mjpeg_ctx = m; @@ -589,7 +593,7 @@ void ff_mjpeg_encode_mb(MPVEncContext *s, int16_t block[12][64]) static int amv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic_arg, int *got_packet) { - MPVMainEncContext *const s = avctx->priv_data; + MPVEncContext *const s = avctx->priv_data; AVFrame *pic; int i, ret; int chroma_h_shift, chroma_v_shift; diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index 34183cd1d5..4b878b2f90 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -122,7 +122,8 @@ av_cold void ff_mpeg1_init_uni_ac_vlc(const RLTable *rl, uint8_t *uni_ac_vlc_len #if CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER static int find_frame_rate_index(MPEG12EncContext *mpeg12) { - MPVMainEncContext *const s = &mpeg12->mpeg; + MPVMainEncContext *const m = &mpeg12->mpeg; + MPVEncContext *const s = &m->common; int i; AVRational bestq = (AVRational) {0, 0}; AVRational ext; @@ -163,7 +164,8 @@ static int find_frame_rate_index(MPEG12EncContext *mpeg12) static av_cold int encode_init(AVCodecContext *avctx) { MPEG12EncContext *const mpeg12 = avctx->priv_data; - MPVMainEncContext *const s = &mpeg12->mpeg; + MPVMainEncContext *const m = &mpeg12->mpeg; + MPVEncContext *const s = &m->common; int ret; int max_size = avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO ? 16383 : 4095; @@ -263,9 +265,10 @@ static void put_header(MPVEncContext *s, int header) } /* put sequence header if needed */ -static void mpeg1_encode_sequence_header(MPVMainEncContext *s) +static void mpeg1_encode_sequence_header(MPVMainEncContext *m) { - MPEG12EncContext *const mpeg12 = (MPEG12EncContext*)s; + MPEG12EncContext *const mpeg12 = (MPEG12EncContext*)m; + MPVEncContext *const s = &m->common; unsigned int vbv_buffer_size, fps, v; int constraint_parameter_flag; AVRational framerate = ff_mpeg12_frame_rate_tab[mpeg12->frame_rate_index]; @@ -451,11 +454,12 @@ void ff_mpeg1_encode_slice_header(MPVEncContext *s) put_bits(&s->pb, 1, 0); } -void ff_mpeg1_encode_picture_header(MPVMainEncContext *s, int picture_number) +void ff_mpeg1_encode_picture_header(MPVMainEncContext *m, int picture_number) { - MPEG12EncContext *const mpeg12 = (MPEG12EncContext*)s; + MPEG12EncContext *const mpeg12 = (MPEG12EncContext*)m; + MPVEncContext *const s = &m->common; AVFrameSideData *side_data; - mpeg1_encode_sequence_header(s); + mpeg1_encode_sequence_header(m); /* MPEG-1 picture header */ put_header(s, PICTURE_START_CODE); @@ -1131,11 +1135,12 @@ static av_cold void mpeg12_encode_init_static(void) fcode_tab[mv + MAX_MV] = f_code; } -av_cold void ff_mpeg1_encode_init(MPVMainEncContext *s) +av_cold void ff_mpeg1_encode_init(MPVMainEncContext *m) { + MPVEncContext *const s = &m->common; static AVOnce init_static_once = AV_ONCE_INIT; - ff_mpeg12_common_init(s); + ff_mpeg12_common_init(&m->common); s->me.mv_penalty = mv_penalty; s->fcode_tab = fcode_tab; diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index 03d53ab56b..c7b0b3ec02 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -216,12 +216,13 @@ static inline int decide_ac_pred(MPVEncContext *s, int16_t block[6][64], /** * modify mb_type & qscale so that encoding is actually possible in MPEG-4 */ -void ff_clean_mpeg4_qscales(MPVMainEncContext *s) +void ff_clean_mpeg4_qscales(MPVMainEncContext *m) { + MPVEncContext *const s = &m->common; int i; int8_t *const qscale_table = s->current_picture.qscale_table; - ff_clean_h263_qscales(s); + ff_clean_h263_qscales(m); if (s->pict_type == AV_PICTURE_TYPE_B) { int odd = 0; @@ -876,8 +877,9 @@ void ff_mpeg4_stuffing(PutBitContext *pbc) } /* must be called before writing the header */ -void ff_set_mpeg4_time(MPVMainEncContext *s) +void ff_set_mpeg4_time(MPVMainEncContext *m) { + MPVEncContext *const s = &m->common; if (s->pict_type == AV_PICTURE_TYPE_B) { ff_mpeg4_init_direct_mv(s); } else { @@ -886,8 +888,9 @@ void ff_set_mpeg4_time(MPVMainEncContext *s) } } -static void mpeg4_encode_gop_header(MPVMainEncContext *s) +static void mpeg4_encode_gop_header(MPVMainEncContext *m) { + MPVEncContext *const s = &m->common; int64_t hours, minutes, seconds; int64_t time; @@ -916,8 +919,9 @@ static void mpeg4_encode_gop_header(MPVMainEncContext *s) ff_mpeg4_stuffing(&s->pb); } -static void mpeg4_encode_visual_object_header(MPVMainEncContext *s) +static void mpeg4_encode_visual_object_header(MPVMainEncContext *m) { + MPVEncContext *const s = &m->common; int profile_and_level_indication; int vo_ver_id; @@ -960,10 +964,11 @@ static void mpeg4_encode_visual_object_header(MPVMainEncContext *s) ff_mpeg4_stuffing(&s->pb); } -static void mpeg4_encode_vol_header(MPVMainEncContext *s, +static void mpeg4_encode_vol_header(MPVMainEncContext *m, int vo_number, int vol_number) { + MPVEncContext *const s = &m->common; int vo_ver_id, vo_type, aspect_ratio_info; if (s->max_b_frames || s->quarter_sample) { @@ -1061,20 +1066,21 @@ static void mpeg4_encode_vol_header(MPVMainEncContext *s, } /* write MPEG-4 VOP header */ -int ff_mpeg4_encode_picture_header(MPVMainEncContext *s, int picture_number) +int ff_mpeg4_encode_picture_header(MPVMainEncContext *m, int picture_number) { + MPVEncContext *const s = &m->common; uint64_t time_incr; int64_t time_div, time_mod; if (s->pict_type == AV_PICTURE_TYPE_I) { if (!(s->avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER)) { if (s->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT) // HACK, the reference sw is buggy - mpeg4_encode_visual_object_header(s); + mpeg4_encode_visual_object_header(m); if (s->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT || picture_number == 0) // HACK, the reference sw is buggy - mpeg4_encode_vol_header(s, 0, 0); + mpeg4_encode_vol_header(m, 0, 0); } if (!(s->workaround_bugs & FF_BUG_MS)) - mpeg4_encode_gop_header(s); + mpeg4_encode_gop_header(m); } s->partitioned_frame = s->data_partitioning && s->pict_type != AV_PICTURE_TYPE_B; @@ -1284,7 +1290,8 @@ static av_cold void mpeg4_encode_init_static(void) static av_cold int encode_init(AVCodecContext *avctx) { static AVOnce init_static_once = AV_ONCE_INIT; - MPVMainEncContext *const s = avctx->priv_data; + MPVMainEncContext *const m = avctx->priv_data; + MPVEncContext *const s = &m->common; int ret; if (avctx->width >= (1<<13) || avctx->height >= (1<<13)) { @@ -1315,8 +1322,8 @@ static av_cold int encode_init(AVCodecContext *avctx) init_put_bits(&s->pb, s->avctx->extradata, 1024); if (!(s->workaround_bugs & FF_BUG_MS)) - mpeg4_encode_visual_object_header(s); - mpeg4_encode_vol_header(s, 0, 0); + mpeg4_encode_visual_object_header(m); + mpeg4_encode_vol_header(m, 0, 0); // ff_mpeg4_stuffing(&s->pb); ? flush_put_bits(&s->pb); @@ -1376,13 +1383,13 @@ void ff_mpeg4_encode_video_packet_header(MPVEncContext *s) put_bits(&s->pb, 1, 0); /* no HEC */ } -#define OFFSET(x) offsetof(MPVMainEncContext, x) +#define OFFSET(x) offsetof(MPVMainEncContext, common.x) #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { - { "data_partitioning", "Use data partitioning.", OFFSET(data_partitioning), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, - { "alternate_scan", "Enable alternate scantable.", OFFSET(alternate_scan), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, + { "data_partitioning", "Use data partitioning.", FF_MPV_OFFSET(data_partitioning), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, + { "alternate_scan", "Enable alternate scantable.", FF_MPV_OFFSET(alternate_scan), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, { "mpeg_quant", "Use MPEG quantizers instead of H.263", - OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, VE }, + FF_MPV_OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, VE }, FF_MPV_COMMON_BFRAME_OPTS FF_MPV_COMMON_OPTS #if FF_API_MPEGVIDEO_OPTS diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 5bf135bccf..5f607d9e11 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -237,8 +237,9 @@ void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix) /** * init s->current_picture.qscale_table from s->lambda_table */ -void ff_init_qscale_tab(MPVMainEncContext *s) +void ff_init_qscale_tab(MPVMainEncContext *m) { + MPVEncContext *const s = &m->common; int8_t * const qscale_table = s->current_picture.qscale_table; int i; @@ -278,11 +279,13 @@ static void mpv_encode_init_static(void) * Set the given MPVMainEncContext to defaults for encoding. * the changed fields will not depend upon the prior state of the MPVMainEncContext. */ -static void mpv_encode_defaults(MPVMainEncContext *s) +static void mpv_encode_defaults(MPVMainEncContext *m) { + MPVMainContext *const com = &m->common; + MPVEncContext *const s = com; static AVOnce init_static_once = AV_ONCE_INIT; - ff_mpv_common_defaults(s); + ff_mpv_common_defaults(com); ff_thread_once(&init_static_once, mpv_encode_init_static); @@ -314,11 +317,12 @@ av_cold int ff_dct_encode_init(MPVEncContext *s) /* init video encoder */ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) { - MPVMainEncContext *const s = avctx->priv_data; + MPVMainEncContext *const m = avctx->priv_data; + MPVMainContext *const s = &m->common; AVCPBProperties *cpb_props; int i, ret; - mpv_encode_defaults(s); + mpv_encode_defaults(m); switch (avctx->pix_fmt) { case AV_PIX_FMT_YUVJ444P: @@ -667,7 +671,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) case AV_CODEC_ID_AMV: s->out_format = FMT_MJPEG; s->intra_only = 1; /* force intra only for jpeg */ - if ((ret = ff_mjpeg_encode_init(s)) < 0) + if ((ret = ff_mjpeg_encode_init(m)) < 0) return ret; avctx->delay = 0; s->low_delay = 1; @@ -678,7 +682,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) s->intra_only = 1; /* force intra only for SHQ */ if (!CONFIG_SPEEDHQ_ENCODER) return AVERROR_ENCODER_NOT_FOUND; - if ((ret = ff_speedhq_encode_init(s)) < 0) + if ((ret = ff_speedhq_encode_init(m)) < 0) return ret; avctx->delay = 0; s->low_delay = 1; @@ -851,14 +855,14 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) ff_set_cmp(&s->mecc, s->mecc.frame_skip_cmp, s->frame_skip_cmp); if (CONFIG_H261_ENCODER && s->out_format == FMT_H261) { - ff_h261_encode_init(s); + ff_h261_encode_init(m); } else if ((CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER) && s->out_format == FMT_MPEG1) { - ff_mpeg1_encode_init(s); + ff_mpeg1_encode_init(m); } else if (CONFIG_H263_ENCODER && s->out_format == FMT_H263) { - ff_h263_encode_init(s); + ff_h263_encode_init(m); if (CONFIG_MSMPEG4_ENCODER && s->msmpeg4_version) - ff_msmpeg4_encode_init(s); + ff_msmpeg4_encode_init(m); } /* init q matrix */ @@ -897,7 +901,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) 31, 0); } - if ((ret = ff_rate_control_init(s)) < 0) + if ((ret = ff_rate_control_init(m)) < 0) return ret; if (s->b_frame_strategy == 2) { @@ -929,12 +933,13 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) av_cold int ff_mpv_encode_end(AVCodecContext *avctx) { - MPVMainEncContext *const s = avctx->priv_data; + MPVMainEncContext *const m = avctx->priv_data; + MPVMainContext *const s = &m->common; int i; - ff_rate_control_uninit(s); + ff_rate_control_uninit(m); - ff_mpv_common_end(s); + ff_mpv_common_end(&m->common); for (i = 0; i < FF_ARRAY_ELEMS(s->tmp_frames); i++) av_frame_free(&s->tmp_frames[i]); @@ -972,7 +977,7 @@ static int get_sae(uint8_t *src, int ref, int stride) return acc; } -static int get_intra_count(MPVMainEncContext *s, uint8_t *src, +static int get_intra_count(MPVEncContext *s, uint8_t *src, uint8_t *ref, int stride) { int x, y, w, h; @@ -995,7 +1000,7 @@ static int get_intra_count(MPVMainEncContext *s, uint8_t *src, return acc; } -static int alloc_picture(MPVMainEncContext *s, Picture *pic, int shared) +static int alloc_picture(MPVEncContext *s, Picture *pic, int shared) { return ff_alloc_picture(s->avctx, pic, &s->me, &s->sc, shared, 1, s->chroma_x_shift, s->chroma_y_shift, s->out_format, @@ -1003,8 +1008,10 @@ static int alloc_picture(MPVMainEncContext *s, Picture *pic, int shared) &s->linesize, &s->uvlinesize); } -static int load_input_picture(MPVMainEncContext *s, const AVFrame *pic_arg) +static int load_input_picture(MPVMainEncContext *m, const AVFrame *pic_arg) { + MPVMainContext *const com = &m->common; + MPVEncContext *const s = com; Picture *pic = NULL; int64_t pts; int i, display_picture_number = 0, ret; @@ -1154,8 +1161,9 @@ static int load_input_picture(MPVMainEncContext *s, const AVFrame *pic_arg) return 0; } -static int skip_check(MPVMainEncContext *s, Picture *p, Picture *ref) +static int skip_check(MPVMainEncContext *m, Picture *p, Picture *ref) { + MPVEncContext *const s = &m->common; int x, y, plane; int score = 0; int64_t score64 = 0; @@ -1216,8 +1224,9 @@ static int encode_frame(AVCodecContext *c, AVFrame *frame, AVPacket *pkt) return size; } -static int estimate_best_b_count(MPVMainEncContext *s) +static int estimate_best_b_count(MPVMainEncContext *m) { + MPVEncContext *const s = &m->common; AVPacket *pkt; const int scale = s->brd_scale; int width = s->width >> scale; @@ -1362,8 +1371,9 @@ fail: return best_b_count; } -static int select_input_picture(MPVMainEncContext *s) +static int select_input_picture(MPVMainEncContext *m) { + MPVEncContext *const s = &m->common; int i, ret; for (i = 1; i < MAX_PICTURE_COUNT; i++) @@ -1375,11 +1385,11 @@ static int select_input_picture(MPVMainEncContext *s) if (s->frame_skip_threshold || s->frame_skip_factor) { if (s->picture_in_gop_number < s->gop_size && s->next_picture_ptr && - skip_check(s, s->input_picture[0], s->next_picture_ptr)) { + skip_check(m, s->input_picture[0], s->next_picture_ptr)) { // FIXME check that the gop check above is +-1 correct av_frame_unref(s->input_picture[0]->f); - ff_vbv_update(s, 0); + ff_vbv_update(m, 0); goto no_output_pic; } @@ -1439,7 +1449,7 @@ static int select_input_picture(MPVMainEncContext *s) s->input_picture[i]->b_frame_score = 0; } } else if (s->b_frame_strategy == 2) { - b_frames = estimate_best_b_count(s); + b_frames = estimate_best_b_count(m); if (b_frames < 0) return b_frames; } @@ -1539,8 +1549,9 @@ no_output_pic: return 0; } -static void frame_end(MPVMainEncContext *s) +static void frame_end(MPVMainEncContext *m) { + MPVEncContext *const s = &m->common; if (s->unrestricted_mv && s->current_picture.reference && !s->intra_only) { @@ -1576,8 +1587,9 @@ static void frame_end(MPVMainEncContext *s) s->last_non_b_pict_type = s->pict_type; } -static void update_noise_reduction(MPVMainEncContext *s) +static void update_noise_reduction(MPVMainEncContext *m) { + MPVEncContext *const s = &m->common; int intra, i; for (intra = 0; intra < 2; intra++) { @@ -1597,8 +1609,9 @@ static void update_noise_reduction(MPVMainEncContext *s) } } -static int frame_start(MPVMainEncContext *s) +static int frame_start(MPVMainEncContext *m) { + MPVEncContext *const s = &m->common; int ret; /* mark & release old frames */ @@ -1662,7 +1675,7 @@ static int frame_start(MPVMainEncContext *s) if (s->dct_error_sum) { av_assert2(s->noise_reduction && s->encoding); - update_noise_reduction(s); + update_noise_reduction(m); } return 0; @@ -1671,7 +1684,8 @@ static int frame_start(MPVMainEncContext *s) int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic_arg, int *got_packet) { - MPVMainEncContext *const s = avctx->priv_data; + MPVMainEncContext *const m = avctx->priv_data; + MPVEncContext *const s = &m->common; int i, stuffing_count, ret; int context_count = s->slice_context_count; @@ -1679,10 +1693,10 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, s->picture_in_gop_number++; - if (load_input_picture(s, pic_arg) < 0) + if (load_input_picture(m, pic_arg) < 0) return -1; - if (select_input_picture(s) < 0) { + if (select_input_picture(m) < 0) { return -1; } @@ -1713,11 +1727,11 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, s->pict_type = s->new_picture.f->pict_type; //emms_c(); - ret = frame_start(s); + ret = frame_start(m); if (ret < 0) return ret; vbv_retry: - ret = encode_picture(s, s->picture_number); + ret = encode_picture(m, s->picture_number); if (growing_buffer) { av_assert0(s->pb.buf == avctx->internal->byte_buffer); pkt->data = s->pb.buf; @@ -1726,7 +1740,7 @@ vbv_retry: if (ret < 0) return -1; - frame_end(s); + frame_end(m); if ((CONFIG_MJPEG_ENCODER || CONFIG_AMV_ENCODER) && s->out_format == FMT_MJPEG) ff_mjpeg_encode_picture_trailer(&s->pb, s->header_bits); @@ -1774,7 +1788,7 @@ vbv_retry: } if (avctx->flags & AV_CODEC_FLAG_PASS1) - ff_write_pass1_stats(s); + ff_write_pass1_stats(m); for (i = 0; i < 4; i++) { s->current_picture_ptr->encoding_error[i] = s->current_picture.encoding_error[i]; @@ -1792,7 +1806,7 @@ vbv_retry: flush_put_bits(&s->pb); s->frame_bits = put_bits_count(&s->pb); - stuffing_count = ff_vbv_update(s, s->frame_bits); + stuffing_count = ff_vbv_update(m, s->frame_bits); s->stuffing_bits = 8*stuffing_count; if (stuffing_count) { if (put_bytes_left(&s->pb, 0) < stuffing_count + 50) { @@ -3431,14 +3445,15 @@ static void merge_context_after_encode(MPVEncContext *dst, MPVEncContext *src) flush_put_bits(&dst->pb); } -static int estimate_qp(MPVMainEncContext *s, int dry_run) +static int estimate_qp(MPVMainEncContext *m, int dry_run) { + MPVEncContext *const s = &m->common; if (s->next_lambda){ s->current_picture_ptr->f->quality = s->current_picture.f->quality = s->next_lambda; if(!dry_run) s->next_lambda= 0; } else if (!s->fixed_qscale) { - int quality = ff_rate_estimate_qscale(s, dry_run); + int quality = ff_rate_estimate_qscale(m, dry_run); s->current_picture_ptr->f->quality = s->current_picture.f->quality = quality; if (s->current_picture.f->quality < 0) @@ -3449,16 +3464,16 @@ static int estimate_qp(MPVMainEncContext *s, int dry_run) switch(s->codec_id){ case AV_CODEC_ID_MPEG4: if (CONFIG_MPEG4_ENCODER) - ff_clean_mpeg4_qscales(s); + ff_clean_mpeg4_qscales(m); break; case AV_CODEC_ID_H263: case AV_CODEC_ID_H263P: case AV_CODEC_ID_FLV1: if (CONFIG_H263_ENCODER) - ff_clean_h263_qscales(s); + ff_clean_h263_qscales(m); break; default: - ff_init_qscale_tab(s); + ff_init_qscale_tab(m); } s->lambda= s->lambda_table[0]; @@ -3470,8 +3485,9 @@ static int estimate_qp(MPVMainEncContext *s, int dry_run) } /* must be called before writing the header */ -static void set_frame_distances(MPVMainEncContext *s) +static void set_frame_distances(MPVMainEncContext *m) { + MPVEncContext *const s = &m->common; av_assert1(s->current_picture_ptr->f->pts != AV_NOPTS_VALUE); s->time = s->current_picture_ptr->f->pts * s->avctx->time_base.num; @@ -3485,8 +3501,9 @@ static void set_frame_distances(MPVMainEncContext *s) } } -static int encode_picture(MPVMainEncContext *s, int picture_number) +static int encode_picture(MPVMainEncContext *m, int picture_number) { + MPVEncContext *const s = &m->common; int i, ret; int bits; int context_count = s->slice_context_count; @@ -3500,9 +3517,9 @@ static int encode_picture(MPVMainEncContext *s, int picture_number) /* we need to initialize some time vars before we can encode B-frames */ // RAL: Condition added for MPEG1VIDEO if (s->out_format == FMT_MPEG1 || (s->h263_pred && !s->msmpeg4_version)) - set_frame_distances(s); + set_frame_distances(m); if(CONFIG_MPEG4_ENCODER && s->codec_id == AV_CODEC_ID_MPEG4) - ff_set_mpeg4_time(s); + ff_set_mpeg4_time(m); s->me.scene_change_score=0; @@ -3517,9 +3534,9 @@ static int encode_picture(MPVMainEncContext *s, int picture_number) } if (s->avctx->flags & AV_CODEC_FLAG_PASS2) { - if (estimate_qp(s,1) < 0) + if (estimate_qp(m, 1) < 0) return -1; - ff_get_2pass_fcode(s); + ff_get_2pass_fcode(m); } else if (!(s->avctx->flags & AV_CODEC_FLAG_QSCALE)) { if(s->pict_type==AV_PICTURE_TYPE_B) s->lambda= s->last_lambda_for[s->pict_type]; @@ -3637,7 +3654,7 @@ static int encode_picture(MPVMainEncContext *s, int picture_number) } } - if (estimate_qp(s, 0) < 0) + if (estimate_qp(m, 0) < 0) return -1; if (s->qscale < 3 && s->max_qcoeff <= 128 && @@ -3711,41 +3728,41 @@ static int encode_picture(MPVMainEncContext *s, int picture_number) switch(s->out_format) { #if CONFIG_MJPEG_ENCODER || CONFIG_AMV_ENCODER case FMT_MJPEG: - ff_mjpeg_amv_encode_picture_header(s); + ff_mjpeg_amv_encode_picture_header(m); break; #endif case FMT_SPEEDHQ: if (CONFIG_SPEEDHQ_ENCODER) - ff_speedhq_encode_picture_header(s); + ff_speedhq_encode_picture_header(m); break; case FMT_H261: if (CONFIG_H261_ENCODER) - ff_h261_encode_picture_header(s, picture_number); + ff_h261_encode_picture_header(m, picture_number); break; case FMT_H263: if (CONFIG_WMV2_ENCODER && s->codec_id == AV_CODEC_ID_WMV2) - ff_wmv2_encode_picture_header(s, picture_number); + ff_wmv2_encode_picture_header(m, picture_number); else if (CONFIG_MSMPEG4_ENCODER && s->msmpeg4_version) - ff_msmpeg4_encode_picture_header(s, picture_number); + ff_msmpeg4_encode_picture_header(m, picture_number); else if (CONFIG_MPEG4_ENCODER && s->h263_pred) { - ret = ff_mpeg4_encode_picture_header(s, picture_number); + ret = ff_mpeg4_encode_picture_header(m, picture_number); if (ret < 0) return ret; } else if (CONFIG_RV10_ENCODER && s->codec_id == AV_CODEC_ID_RV10) { - ret = ff_rv10_encode_picture_header(s, picture_number); + ret = ff_rv10_encode_picture_header(m, picture_number); if (ret < 0) return ret; } else if (CONFIG_RV20_ENCODER && s->codec_id == AV_CODEC_ID_RV20) - ff_rv20_encode_picture_header(s, picture_number); + ff_rv20_encode_picture_header(m, picture_number); else if (CONFIG_FLV_ENCODER && s->codec_id == AV_CODEC_ID_FLV1) - ff_flv_encode_picture_header(s, picture_number); + ff_flv_encode_picture_header(m, picture_number); else if (CONFIG_H263_ENCODER) - ff_h263_encode_picture_header(s, picture_number); + ff_h263_encode_picture_header(m, picture_number); break; case FMT_MPEG1: if (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER) - ff_mpeg1_encode_picture_header(s, picture_number); + ff_mpeg1_encode_picture_header(m, picture_number); break; default: av_assert0(0); diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index 0b63487291..37375132d7 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -33,7 +33,9 @@ #include "mpegvideo.h" typedef MPVContext MPVEncContext; -typedef MPVContext MPVMainEncContext; +typedef struct MPVMainEncContext { + MPVMainContext common; +} MPVMainEncContext; #define UNI_AC_ENC_INDEX(run,level) ((run)*128 + (level)) @@ -62,7 +64,8 @@ typedef MPVContext MPVMainEncContext; { "chroma", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_CHROMA }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ { "msad", "Sum of absolute differences, median predicted", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_MEDIAN_SAD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" } -#define FF_MPV_OFFSET(x) offsetof(MPVMainEncContext, x) +#define FF_MPV_MAIN_OFFSET(x) offsetof(MPVMainEncContext, x) +#define FF_MPV_OFFSET(x) FF_MPV_MAIN_OFFSET(common.x) #define FF_MPV_OPT_FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM) #define FF_MPV_COMMON_OPTS \ FF_MPV_OPT_CMP_FUNC, \ diff --git a/libavcodec/msmpeg4enc.c b/libavcodec/msmpeg4enc.c index 1a2e24f703..7c1fa0a1e3 100644 --- a/libavcodec/msmpeg4enc.c +++ b/libavcodec/msmpeg4enc.c @@ -134,11 +134,12 @@ static av_cold void msmpeg4_encode_init_static(void) } } -av_cold void ff_msmpeg4_encode_init(MPVMainEncContext *s) +av_cold void ff_msmpeg4_encode_init(MPVMainEncContext *m) { static AVOnce init_static_once = AV_ONCE_INIT; + MPVEncContext *const s = &m->common; - ff_msmpeg4_common_init(s); + ff_msmpeg4_common_init(&m->common); if (s->msmpeg4_version >= 4) { s->min_qcoeff = -255; s->max_qcoeff = 255; @@ -150,7 +151,7 @@ av_cold void ff_msmpeg4_encode_init(MPVMainEncContext *s) static void find_best_tables(MSMPEG4EncContext *ms) { - MPVEncContext *const s = &ms->s; + MPVEncContext *const s = &ms->s.common; int i; int best = 0, best_size = INT_MAX; int chroma_best = 0, best_chroma_size = INT_MAX; @@ -214,9 +215,10 @@ static void find_best_tables(MSMPEG4EncContext *ms) } /* write MSMPEG4 compatible frame header */ -void ff_msmpeg4_encode_picture_header(MPVMainEncContext *s, int picture_number) +void ff_msmpeg4_encode_picture_header(MPVMainEncContext *m, int picture_number) { - MSMPEG4EncContext *const ms = (MSMPEG4EncContext*)s; + MSMPEG4EncContext *const ms = (MSMPEG4EncContext*)m; + MPVEncContext *const s = &m->common; find_best_tables(ms); diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c index c5088d6790..4c326741df 100644 --- a/libavcodec/ratecontrol.c +++ b/libavcodec/ratecontrol.c @@ -35,8 +35,9 @@ #include "mpegvideoenc.h" #include "libavutil/eval.h" -void ff_write_pass1_stats(MPVMainEncContext *s) +void ff_write_pass1_stats(MPVMainEncContext *m) { + MPVEncContext *const s = &m->common; snprintf(s->avctx->stats_out, 256, "in:%d out:%d type:%d q:%d itex:%d ptex:%d mv:%d misc:%d " "fcode:%d bcode:%d mc-var:%"PRId64" var:%"PRId64" icount:%d skipcount:%d hbits:%d;\n", @@ -77,8 +78,9 @@ static inline double bits2qp(RateControlEntry *rce, double bits) return rce->qscale * (double)(rce->i_tex_bits + rce->p_tex_bits + 1) / bits; } -static double get_diff_limited_q(MPVMainEncContext *s, RateControlEntry *rce, double q) +static double get_diff_limited_q(MPVMainEncContext *m, RateControlEntry *rce, double q) { + MPVEncContext *const s = &m->common; RateControlContext *rcc = &s->rc_context; AVCodecContext *a = s->avctx; const int pict_type = rce->new_pict_type; @@ -116,7 +118,7 @@ static double get_diff_limited_q(MPVMainEncContext *s, RateControlEntry *rce, do /** * Get the qmin & qmax for pict_type. */ -static void get_qminmax(int *qmin_ret, int *qmax_ret, MPVMainEncContext *s, int pict_type) +static void get_qminmax(int *qmin_ret, int *qmax_ret, MPVEncContext *s, int pict_type) { int qmin = s->lmin; int qmax = s->lmax; @@ -144,9 +146,10 @@ static void get_qminmax(int *qmin_ret, int *qmax_ret, MPVMainEncContext *s, int *qmax_ret = qmax; } -static double modify_qscale(MPVMainEncContext *s, RateControlEntry *rce, +static double modify_qscale(MPVMainEncContext *m, RateControlEntry *rce, double q, int frame_num) { + MPVEncContext *const s = &m->common; RateControlContext *rcc = &s->rc_context; const double buffer_size = s->avctx->rc_buffer_size; const double fps = get_fps(s->avctx); @@ -235,9 +238,10 @@ static double modify_qscale(MPVMainEncContext *s, RateControlEntry *rce, /** * Modify the bitrate curve from pass1 for one frame. */ -static double get_qscale(MPVMainEncContext *s, RateControlEntry *rce, +static double get_qscale(MPVMainEncContext *m, RateControlEntry *rce, double rate_factor, int frame_num) { + MPVEncContext *const s = &m->common; RateControlContext *rcc = &s->rc_context; AVCodecContext *a = s->avctx; const int pict_type = rce->new_pict_type; @@ -308,8 +312,9 @@ static double get_qscale(MPVMainEncContext *s, RateControlEntry *rce, return q; } -static int init_pass2(MPVMainEncContext *s) +static int init_pass2(MPVMainEncContext *m) { + MPVEncContext *const s = &m->common; RateControlContext *rcc = &s->rc_context; AVCodecContext *a = s->avctx; int i, toobig; @@ -368,7 +373,7 @@ static int init_pass2(MPVMainEncContext *s) for (i = 0; i < rcc->num_entries; i++) { RateControlEntry *rce = &rcc->entry[i]; - qscale[i] = get_qscale(s, &rcc->entry[i], rate_factor, i); + qscale[i] = get_qscale(m, &rcc->entry[i], rate_factor, i); rcc->last_qscale_for[rce->pict_type] = qscale[i]; } av_assert0(filter_size % 2 == 1); @@ -377,13 +382,13 @@ static int init_pass2(MPVMainEncContext *s) for (i = FFMAX(0, rcc->num_entries - 300); i < rcc->num_entries; i++) { RateControlEntry *rce = &rcc->entry[i]; - qscale[i] = get_diff_limited_q(s, rce, qscale[i]); + qscale[i] = get_diff_limited_q(m, rce, qscale[i]); } for (i = rcc->num_entries - 1; i >= 0; i--) { RateControlEntry *rce = &rcc->entry[i]; - qscale[i] = get_diff_limited_q(s, rce, qscale[i]); + qscale[i] = get_diff_limited_q(m, rce, qscale[i]); } /* smooth curve */ @@ -413,10 +418,10 @@ static int init_pass2(MPVMainEncContext *s) RateControlEntry *rce = &rcc->entry[i]; double bits; - rce->new_qscale = modify_qscale(s, rce, blurred_qscale[i], i); + rce->new_qscale = modify_qscale(m, rce, blurred_qscale[i], i); bits = qp2bits(rce, rce->new_qscale) + rce->mv_bits + rce->misc_bits; - bits += 8 * ff_vbv_update(s, bits); + bits += 8 * ff_vbv_update(m, bits); rce->expected_bits = expected_bits; expected_bits += bits; @@ -469,8 +474,9 @@ static int init_pass2(MPVMainEncContext *s) return 0; } -av_cold int ff_rate_control_init(MPVMainEncContext *s) +av_cold int ff_rate_control_init(MPVMainEncContext *m) { + MPVEncContext *const s = &m->common; RateControlContext *rcc = &s->rc_context; int i, res; static const char * const const_names[] = { @@ -603,8 +609,8 @@ av_cold int ff_rate_control_init(MPVMainEncContext *s) p = next; } - if (init_pass2(s) < 0) { - ff_rate_control_uninit(s); + if (init_pass2(m) < 0) { + ff_rate_control_uninit(m); return -1; } } @@ -658,7 +664,7 @@ av_cold int ff_rate_control_init(MPVMainEncContext *s) rcc->mv_bits_sum[rce.pict_type] += rce.mv_bits; rcc->frame_count[rce.pict_type]++; - get_qscale(s, &rce, rcc->pass1_wanted_bits / rcc->pass1_rc_eq_output_sum, i); + get_qscale(m, &rce, rcc->pass1_wanted_bits / rcc->pass1_rc_eq_output_sum, i); // FIXME misbehaves a little for variable fps rcc->pass1_wanted_bits += s->bit_rate / get_fps(s->avctx); @@ -669,8 +675,9 @@ av_cold int ff_rate_control_init(MPVMainEncContext *s) return 0; } -av_cold void ff_rate_control_uninit(MPVMainEncContext *s) +av_cold void ff_rate_control_uninit(MPVMainEncContext *m) { + MPVEncContext *const s = &m->common; RateControlContext *rcc = &s->rc_context; emms_c(); @@ -678,8 +685,9 @@ av_cold void ff_rate_control_uninit(MPVMainEncContext *s) av_freep(&rcc->entry); } -int ff_vbv_update(MPVMainEncContext *s, int frame_size) +int ff_vbv_update(MPVMainEncContext *m, int frame_size) { + MPVEncContext *const s = &m->common; RateControlContext *rcc = &s->rc_context; const double fps = get_fps(s->avctx); const int buffer_size = s->avctx->rc_buffer_size; @@ -737,8 +745,9 @@ static void update_predictor(Predictor *p, double q, double var, double size) p->coeff += new_coeff; } -static void adaptive_quantization(MPVMainEncContext *s, double q) +static void adaptive_quantization(MPVMainEncContext *m, double q) { + MPVEncContext *const s = &m->common; int i; const float lumi_masking = s->avctx->lumi_masking / (128.0 * 128.0); const float dark_masking = s->avctx->dark_masking / (128.0 * 128.0); @@ -854,8 +863,9 @@ static void adaptive_quantization(MPVMainEncContext *s, double q) } } -void ff_get_2pass_fcode(MPVMainEncContext *s) +void ff_get_2pass_fcode(MPVMainEncContext *m) { + MPVEncContext *const s = &m->common; RateControlContext *rcc = &s->rc_context; RateControlEntry *rce = &rcc->entry[s->picture_number]; @@ -865,8 +875,9 @@ void ff_get_2pass_fcode(MPVMainEncContext *s) // FIXME rd or at least approx for dquant -float ff_rate_estimate_qscale(MPVMainEncContext *s, int dry_run) +float ff_rate_estimate_qscale(MPVMainEncContext *m, int dry_run) { + MPVEncContext *const s = &m->common; float q; int qmin, qmax; float br_compensation; @@ -971,12 +982,12 @@ float ff_rate_estimate_qscale(MPVMainEncContext *s, int dry_run) rate_factor = rcc->pass1_wanted_bits / rcc->pass1_rc_eq_output_sum * br_compensation; - q = get_qscale(s, rce, rate_factor, picture_number); + q = get_qscale(m, rce, rate_factor, picture_number); if (q < 0) return -1; av_assert0(q > 0.0); - q = get_diff_limited_q(s, rce, q); + q = get_diff_limited_q(m, rce, q); av_assert0(q > 0.0); // FIXME type dependent blur like in 2-pass @@ -990,7 +1001,7 @@ float ff_rate_estimate_qscale(MPVMainEncContext *s, int dry_run) } av_assert0(q > 0.0); - q = modify_qscale(s, rce, q, picture_number); + q = modify_qscale(m, rce, q, picture_number); rcc->pass1_wanted_bits += s->bit_rate / fps; @@ -1015,7 +1026,7 @@ float ff_rate_estimate_qscale(MPVMainEncContext *s, int dry_run) q = qmax; if (s->adaptive_quant) - adaptive_quantization(s, q); + adaptive_quantization(m, q); else q = (int)(q + 0.5); diff --git a/libavcodec/ratecontrol.h b/libavcodec/ratecontrol.h index 23f41dcca2..6b29a0a94d 100644 --- a/libavcodec/ratecontrol.h +++ b/libavcodec/ratecontrol.h @@ -86,7 +86,6 @@ typedef struct RateControlContext{ AVExpr * rc_eq_eval; }RateControlContext; -#define MPVMainEncContext MPVContext struct MPVMainEncContext; /* rate control */ @@ -96,6 +95,5 @@ void ff_write_pass1_stats(struct MPVMainEncContext *m); void ff_rate_control_uninit(struct MPVMainEncContext *m); int ff_vbv_update(struct MPVMainEncContext *m, int frame_size); void ff_get_2pass_fcode(struct MPVMainEncContext *m); -#undef MPVMainEncContext #endif /* AVCODEC_RATECONTROL_H */ diff --git a/libavcodec/rv10enc.c b/libavcodec/rv10enc.c index 6c9305d7fe..ddbea6298c 100644 --- a/libavcodec/rv10enc.c +++ b/libavcodec/rv10enc.c @@ -29,8 +29,9 @@ #include "put_bits.h" #include "rv10enc.h" -int ff_rv10_encode_picture_header(MPVMainEncContext *s, int picture_number) +int ff_rv10_encode_picture_header(MPVMainEncContext *m, int picture_number) { + MPVEncContext *const s = &m->common; int full_frame= 0; align_put_bits(&s->pb); diff --git a/libavcodec/rv20enc.c b/libavcodec/rv20enc.c index a4b4bad277..06f6751549 100644 --- a/libavcodec/rv20enc.c +++ b/libavcodec/rv20enc.c @@ -32,8 +32,9 @@ #include "put_bits.h" #include "rv10enc.h" -void ff_rv20_encode_picture_header(MPVMainEncContext *s, int picture_number) +void ff_rv20_encode_picture_header(MPVMainEncContext *m, int picture_number) { + MPVEncContext *const s = &m->common; put_bits(&s->pb, 2, s->pict_type); //I 0 vs. 1 ? put_bits(&s->pb, 1, 0); /* unknown bit */ put_bits(&s->pb, 5, s->qscale); diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 0a500695ce..de9741a888 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -689,6 +689,7 @@ int ff_snow_frame_start(SnowContext *s){ av_cold void ff_snow_common_end(SnowContext *s) { int plane_index, level, orientation, i; + MPVEncContext *const m = &s->m.common; av_freep(&s->spatial_dwt_buffer); av_freep(&s->temp_dwt_buffer); @@ -696,11 +697,11 @@ av_cold void ff_snow_common_end(SnowContext *s) av_freep(&s->temp_idwt_buffer); av_freep(&s->run_buffer); - s->m.me.temp= NULL; - av_freep(&s->m.me.scratchpad); - av_freep(&s->m.me.map); - av_freep(&s->m.me.score_map); - av_freep(&s->m.sc.obmc_scratchpad); + m->me.temp = NULL; + av_freep(&m->me.scratchpad); + av_freep(&m->me.map); + av_freep(&m->me.score_map); + av_freep(&m->sc.obmc_scratchpad); av_freep(&s->block); av_freep(&s->scratchbuf); diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index e169ae601d..028b6b91aa 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -39,6 +39,7 @@ static av_cold int encode_init(AVCodecContext *avctx) { SnowContext *s = avctx->priv_data; + MPVEncContext *const mpv = &s->m.common; int plane_index, ret; int i; @@ -72,18 +73,18 @@ static av_cold int encode_init(AVCodecContext *avctx) s->version=0; - s->m.avctx = avctx; - s->m.bit_rate= avctx->bit_rate; - s->m.lmin = avctx->mb_lmin; - s->m.lmax = avctx->mb_lmax; - s->m.mb_num = (avctx->width * avctx->height + 255) / 256; // For ratecontrol - - s->m.me.temp = - s->m.me.scratchpad = av_calloc(avctx->width + 64, 2*16*2*sizeof(uint8_t)); - s->m.me.map = av_mallocz(ME_MAP_SIZE*sizeof(uint32_t)); - s->m.me.score_map = av_mallocz(ME_MAP_SIZE*sizeof(uint32_t)); - s->m.sc.obmc_scratchpad= av_mallocz(MB_SIZE*MB_SIZE*12*sizeof(uint32_t)); - if (!s->m.me.scratchpad || !s->m.me.map || !s->m.me.score_map || !s->m.sc.obmc_scratchpad) + mpv->avctx = avctx; + mpv->bit_rate= avctx->bit_rate; + mpv->lmin = avctx->mb_lmin; + mpv->lmax = avctx->mb_lmax; + mpv->mb_num = (avctx->width * avctx->height + 255) / 256; // For ratecontrol + + mpv->me.temp = + mpv->me.scratchpad = av_calloc(avctx->width + 64, 2*16*2*sizeof(uint8_t)); + mpv->me.map = av_mallocz(ME_MAP_SIZE*sizeof(uint32_t)); + mpv->me.score_map = av_mallocz(ME_MAP_SIZE*sizeof(uint32_t)); + mpv->sc.obmc_scratchpad= av_mallocz(MB_SIZE*MB_SIZE*12*sizeof(uint32_t)); + if (!mpv->me.scratchpad || !mpv->me.map || !mpv->me.score_map || !mpv->sc.obmc_scratchpad) return AVERROR(ENOMEM); ff_h263_encode_init(&s->m); //mv_penalty @@ -216,6 +217,7 @@ static inline int get_penalty_factor(int lambda, int lambda2, int type){ #define FLAG_QPEL 1 //must be 1 static int encode_q_branch(SnowContext *s, int level, int x, int y){ + MPVEncContext *const mpv = &s->m.common; uint8_t p_buffer[1024]; uint8_t i_buffer[1024]; uint8_t p_state[sizeof(s->block_state)]; @@ -252,7 +254,7 @@ static int encode_q_branch(SnowContext *s, int level, int x, int y){ int16_t last_mv[3][2]; int qpel= !!(s->avctx->flags & AV_CODEC_FLAG_QPEL); //unused const int shift= 1+qpel; - MotionEstContext *c= &s->m.me; + MotionEstContext *c= &mpv->me; int ref_context= av_log2(2*left->ref) + av_log2(2*top->ref); int mx_context= av_log2(2*FFABS(left->mx - top->mx)); int my_context= av_log2(2*FFABS(left->my - top->my)); @@ -281,9 +283,9 @@ static int encode_q_branch(SnowContext *s, int level, int x, int y){ last_mv[2][0]= bottom->mx; last_mv[2][1]= bottom->my; - s->m.mb_stride=2; - s->m.mb_x= - s->m.mb_y= 0; + mpv->mb_stride=2; + mpv->mb_x= + mpv->mb_y= 0; c->skip= 0; av_assert1(c-> stride == stride); @@ -292,7 +294,7 @@ static int encode_q_branch(SnowContext *s, int level, int x, int y){ c->penalty_factor = get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_cmp); c->sub_penalty_factor= get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_sub_cmp); c->mb_penalty_factor = get_penalty_factor(s->lambda, s->lambda2, c->avctx->mb_cmp); - c->current_mv_penalty= c->mv_penalty[s->m.f_code=1] + MAX_DMV; + c->current_mv_penalty= c->mv_penalty[mpv->f_code=1] + MAX_DMV; c->xmin = - x*block_w - 16+3; c->ymin = - y*block_w - 16+3; @@ -323,16 +325,16 @@ static int encode_q_branch(SnowContext *s, int level, int x, int y){ for(ref=0; refref_frames; ref++){ init_ref(c, current_data, s->last_picture[ref]->data, NULL, block_w*x, block_w*y, 0); - ref_score= ff_epzs_motion_search(&s->m, &ref_mx, &ref_my, P, 0, /*ref_index*/ 0, last_mv, - (1<<16)>>shift, level-LOG2_MB_SIZE+4, block_w); + ref_score = ff_epzs_motion_search(mpv, &ref_mx, &ref_my, P, 0, /*ref_index*/ 0, last_mv, + (1<<16)>>shift, level-LOG2_MB_SIZE+4, block_w); av_assert2(ref_mx >= c->xmin); av_assert2(ref_mx <= c->xmax); av_assert2(ref_my >= c->ymin); av_assert2(ref_my <= c->ymax); - ref_score= c->sub_motion_search(&s->m, &ref_mx, &ref_my, ref_score, 0, 0, level-LOG2_MB_SIZE+4, block_w); - ref_score= ff_get_mb_score(&s->m, ref_mx, ref_my, 0, 0, level-LOG2_MB_SIZE+4, block_w, 0); + ref_score = c->sub_motion_search(mpv, &ref_mx, &ref_my, ref_score, 0, 0, level-LOG2_MB_SIZE+4, block_w); + ref_score = ff_get_mb_score(mpv, ref_mx, ref_my, 0, 0, level-LOG2_MB_SIZE+4, block_w, 0); ref_score+= 2*av_log2(2*ref)*c->penalty_factor; if(s->ref_mvs[ref]){ s->ref_mvs[ref][index][0]= ref_mx; @@ -408,7 +410,7 @@ static int encode_q_branch(SnowContext *s, int level, int x, int y){ if (vard <= 64 || vard < varc) c->scene_change_score+= ff_sqrt(vard) - ff_sqrt(varc); else - c->scene_change_score+= s->m.qscale; + c->scene_change_score+= mpv->qscale; } if(level!=s->block_max_depth){ @@ -509,7 +511,7 @@ static int get_dc(SnowContext *s, int mb_x, int mb_y, int plane_index){ const int obmc_stride= plane_index ? (2*block_size)>>s->chroma_h_shift : 2*block_size; const int ref_stride= s->current_picture->linesize[plane_index]; uint8_t *src= s-> input_picture->data[plane_index]; - IDWTELEM *dst= (IDWTELEM*)s->m.sc.obmc_scratchpad + plane_index*block_size*block_size*4; //FIXME change to unsigned + IDWTELEM *dst= (IDWTELEM*)s->m.common.sc.obmc_scratchpad + plane_index*block_size*block_size*4; //FIXME change to unsigned const int b_stride = s->b_width << s->block_max_depth; const int w= p->width; const int h= p->height; @@ -596,6 +598,7 @@ static inline int get_block_bits(SnowContext *s, int x, int y, int w){ } static int get_block_rd(SnowContext *s, int mb_x, int mb_y, int plane_index, uint8_t (*obmc_edged)[MB_SIZE * 2]){ + MPVEncContext *const mpv = &s->m.common; Plane *p= &s->plane[plane_index]; const int block_size = MB_SIZE >> s->block_max_depth; const int block_w = plane_index ? block_size>>s->chroma_h_shift : block_size; @@ -604,7 +607,7 @@ static int get_block_rd(SnowContext *s, int mb_x, int mb_y, int plane_index, uin const int ref_stride= s->current_picture->linesize[plane_index]; uint8_t *dst= s->current_picture->data[plane_index]; uint8_t *src= s-> input_picture->data[plane_index]; - IDWTELEM *pred= (IDWTELEM*)s->m.sc.obmc_scratchpad + plane_index*block_size*block_size*4; + IDWTELEM *pred= (IDWTELEM*)mpv->sc.obmc_scratchpad + plane_index*block_size*block_size*4; uint8_t *cur = s->scratchbuf; uint8_t *tmp = s->emu_edge_buffer; const int b_stride = s->b_width << s->block_max_depth; @@ -667,19 +670,19 @@ static int get_block_rd(SnowContext *s, int mb_x, int mb_y, int plane_index, uin * to improve the score of the whole frame, thus iterative motion * estimation does not always converge. */ if(s->avctx->me_cmp == FF_CMP_W97) - distortion = ff_w97_32_c(&s->m, src + sx + sy*ref_stride, dst + sx + sy*ref_stride, ref_stride, 32); + distortion = ff_w97_32_c(mpv, src + sx + sy*ref_stride, dst + sx + sy*ref_stride, ref_stride, 32); else if(s->avctx->me_cmp == FF_CMP_W53) - distortion = ff_w53_32_c(&s->m, src + sx + sy*ref_stride, dst + sx + sy*ref_stride, ref_stride, 32); + distortion = ff_w53_32_c(mpv, src + sx + sy*ref_stride, dst + sx + sy*ref_stride, ref_stride, 32); else{ distortion = 0; for(i=0; i<4; i++){ int off = sx+16*(i&1) + (sy+16*(i>>1))*ref_stride; - distortion += s->mecc.me_cmp[0](&s->m, src + off, dst + off, ref_stride, 16); + distortion += s->mecc.me_cmp[0](mpv, src + off, dst + off, ref_stride, 16); } } }else{ av_assert2(block_w==8); - distortion = s->mecc.me_cmp[0](&s->m, src + sx + sy*ref_stride, dst + sx + sy*ref_stride, ref_stride, block_w*2); + distortion = s->mecc.me_cmp[0](mpv, src + sx + sy*ref_stride, dst + sx + sy*ref_stride, ref_stride, block_w*2); } if(plane_index==0){ @@ -697,6 +700,7 @@ static int get_block_rd(SnowContext *s, int mb_x, int mb_y, int plane_index, uin } static int get_4block_rd(SnowContext *s, int mb_x, int mb_y, int plane_index){ + MPVEncContext *const mpv = &s->m.common; int i, y2; Plane *p= &s->plane[plane_index]; const int block_size = MB_SIZE >> s->block_max_depth; @@ -743,7 +747,7 @@ static int get_4block_rd(SnowContext *s, int mb_x, int mb_y, int plane_index){ } av_assert1(block_w== 8 || block_w==16); - distortion += s->mecc.me_cmp[block_w==8](&s->m, src + x + y*ref_stride, dst + x + y*ref_stride, ref_stride, block_h); + distortion += s->mecc.me_cmp[block_w==8](mpv, src + x + y*ref_stride, dst + x + y*ref_stride, ref_stride, block_h); } if(plane_index==0){ @@ -1477,6 +1481,7 @@ static int qscale2qlog(int qscale){ static int ratecontrol_1pass(SnowContext *s, AVFrame *pict) { + MPVEncContext *const mpv = &s->m.common; /* Estimate the frame's complexity as a sum of weighted dwt coefficients. * FIXME we know exact mv bits at this point, * but ratecontrol isn't set up to include them. */ @@ -1511,11 +1516,11 @@ static int ratecontrol_1pass(SnowContext *s, AVFrame *pict) coef_sum = (uint64_t)coef_sum * coef_sum >> 16; if(pict->pict_type == AV_PICTURE_TYPE_I){ - s->m.current_picture.mb_var_sum= coef_sum; - s->m.current_picture.mc_mb_var_sum= 0; + mpv->current_picture.mb_var_sum= coef_sum; + mpv->current_picture.mc_mb_var_sum= 0; }else{ - s->m.current_picture.mc_mb_var_sum= coef_sum; - s->m.current_picture.mb_var_sum= 0; + mpv->current_picture.mc_mb_var_sum= coef_sum; + mpv->current_picture.mb_var_sum= 0; } pict->quality= ff_rate_estimate_qscale(&s->m, 1); @@ -1557,6 +1562,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet) { SnowContext *s = avctx->priv_data; + MPVEncContext *const mpv = &s->m.common; RangeCoder * const c= &s->c; AVFrame *pic; const int width= s->avctx->width; @@ -1589,9 +1595,9 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, pic->pict_type = pict->pict_type; pic->quality = pict->quality; - s->m.picture_number= avctx->frame_number; + mpv->picture_number= avctx->frame_number; if(avctx->flags&AV_CODEC_FLAG_PASS2){ - s->m.pict_type = pic->pict_type = s->m.rc_context.entry[avctx->frame_number].new_pict_type; + mpv->pict_type = pic->pict_type = mpv->rc_context.entry[avctx->frame_number].new_pict_type; s->keyframe = pic->pict_type == AV_PICTURE_TYPE_I; if(!(avctx->flags&AV_CODEC_FLAG_QSCALE)) { pic->quality = ff_rate_estimate_qscale(&s->m, 0); @@ -1600,7 +1606,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, } }else{ s->keyframe= avctx->gop_size==0 || avctx->frame_number % avctx->gop_size == 0; - s->m.pict_type = pic->pict_type = s->keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; + mpv->pict_type = pic->pict_type = s->keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; } if(s->pass1_rc && avctx->frame_number == 0) @@ -1634,9 +1640,9 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, ff_snow_frame_start(s); - s->m.current_picture_ptr= &s->m.current_picture; - s->m.current_picture.f = s->current_picture; - s->m.current_picture.f->pts = pict->pts; + mpv->current_picture_ptr= &mpv->current_picture; + mpv->current_picture.f = s->current_picture; + mpv->current_picture.f->pts = pict->pts; if(pic->pict_type == AV_PICTURE_TYPE_P){ int block_width = (width +15)>>4; int block_height= (height+15)>>4; @@ -1645,37 +1651,37 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, av_assert0(s->current_picture->data[0]); av_assert0(s->last_picture[0]->data[0]); - s->m.avctx= s->avctx; - s->m. last_picture.f = s->last_picture[0]; - s->m. new_picture.f = s->input_picture; - s->m. last_picture_ptr= &s->m. last_picture; - s->m.linesize = stride; - s->m.uvlinesize= s->current_picture->linesize[1]; - s->m.width = width; - s->m.height= height; - s->m.mb_width = block_width; - s->m.mb_height= block_height; - s->m.mb_stride= s->m.mb_width+1; - s->m.b8_stride= 2*s->m.mb_width+1; - s->m.f_code=1; - s->m.pict_type = pic->pict_type; - s->m.motion_est= s->motion_est; - s->m.me.scene_change_score=0; - s->m.me.dia_size = avctx->dia_size; - s->m.quarter_sample= (s->avctx->flags & AV_CODEC_FLAG_QPEL)!=0; - s->m.out_format= FMT_H263; - s->m.unrestricted_mv= 1; - - s->m.lambda = s->lambda; - s->m.qscale= (s->m.lambda*139 + FF_LAMBDA_SCALE*64) >> (FF_LAMBDA_SHIFT + 7); - s->lambda2= s->m.lambda2= (s->m.lambda*s->m.lambda + FF_LAMBDA_SCALE/2) >> FF_LAMBDA_SHIFT; - - s->m.mecc= s->mecc; //move - s->m.qdsp= s->qdsp; //move - s->m.hdsp = s->hdsp; - ff_init_me(&s->m); - s->hdsp = s->m.hdsp; - s->mecc= s->m.mecc; + mpv->avctx= s->avctx; + mpv-> last_picture.f = s->last_picture[0]; + mpv-> new_picture.f = s->input_picture; + mpv-> last_picture_ptr= &mpv-> last_picture; + mpv->linesize = stride; + mpv->uvlinesize= s->current_picture->linesize[1]; + mpv->width = width; + mpv->height= height; + mpv->mb_width = block_width; + mpv->mb_height= block_height; + mpv->mb_stride= mpv->mb_width+1; + mpv->b8_stride= 2*mpv->mb_width+1; + mpv->f_code=1; + mpv->pict_type = pic->pict_type; + mpv->motion_est= s->motion_est; + mpv->me.scene_change_score=0; + mpv->me.dia_size = avctx->dia_size; + mpv->quarter_sample= (s->avctx->flags & AV_CODEC_FLAG_QPEL)!=0; + mpv->out_format= FMT_H263; + mpv->unrestricted_mv= 1; + + mpv->lambda = s->lambda; + mpv->qscale= (mpv->lambda*139 + FF_LAMBDA_SCALE*64) >> (FF_LAMBDA_SHIFT + 7); + s->lambda2= mpv->lambda2= (mpv->lambda*mpv->lambda + FF_LAMBDA_SCALE/2) >> FF_LAMBDA_SHIFT; + + mpv->mecc= s->mecc; //move + mpv->qdsp= s->qdsp; //move + mpv->hdsp = s->hdsp; + ff_init_me(mpv); + s->hdsp = mpv->hdsp; + s->mecc= mpv->mecc; } if(s->pass1_rc){ @@ -1696,7 +1702,7 @@ redo_frame: return AVERROR(EINVAL); } - s->m.pict_type = pic->pict_type; + mpv->pict_type = pic->pict_type; s->qbias = pic->pict_type == AV_PICTURE_TYPE_P ? 2 : 0; ff_snow_common_init_after_header(avctx); @@ -1708,9 +1714,9 @@ redo_frame: } encode_header(s); - s->m.misc_bits = 8*(s->c.bytestream - s->c.bytestream_start); + mpv->misc_bits = 8*(s->c.bytestream - s->c.bytestream_start); encode_blocks(s, 1); - s->m.mv_bits = 8*(s->c.bytestream - s->c.bytestream_start) - s->m.misc_bits; + mpv->mv_bits = 8*(s->c.bytestream - s->c.bytestream_start) - mpv->misc_bits; for(plane_index=0; plane_index < s->nb_planes; plane_index++){ Plane *p= &s->plane[plane_index]; @@ -1732,7 +1738,7 @@ redo_frame: if( plane_index==0 && pic->pict_type == AV_PICTURE_TYPE_P && !(avctx->flags&AV_CODEC_FLAG_PASS2) - && s->m.me.scene_change_score > s->scenechange_threshold){ + && mpv->me.scene_change_score > s->scenechange_threshold){ ff_init_range_encoder(c, pkt->data, pkt->size); ff_build_rac_states(c, (1LL<<32)/20, 256-8); pic->pict_type= AV_PICTURE_TYPE_I; @@ -1841,18 +1847,18 @@ redo_frame: s->current_picture->coded_picture_number = avctx->frame_number; s->current_picture->pict_type = pic->pict_type; s->current_picture->quality = pic->quality; - s->m.frame_bits = 8*(s->c.bytestream - s->c.bytestream_start); - s->m.p_tex_bits = s->m.frame_bits - s->m.misc_bits - s->m.mv_bits; - s->m.current_picture.f->display_picture_number = - s->m.current_picture.f->coded_picture_number = avctx->frame_number; - s->m.current_picture.f->quality = pic->quality; - s->m.total_bits += 8*(s->c.bytestream - s->c.bytestream_start); + mpv->frame_bits = 8*(s->c.bytestream - s->c.bytestream_start); + mpv->p_tex_bits = mpv->frame_bits - mpv->misc_bits - mpv->mv_bits; + mpv->current_picture.f->display_picture_number = + mpv->current_picture.f->coded_picture_number = avctx->frame_number; + mpv->current_picture.f->quality = pic->quality; + mpv->total_bits += 8*(s->c.bytestream - s->c.bytestream_start); if(s->pass1_rc) if (ff_rate_estimate_qscale(&s->m, 0) < 0) return -1; if(avctx->flags&AV_CODEC_FLAG_PASS1) ff_write_pass1_stats(&s->m); - s->m.last_pict_type = s->m.pict_type; + mpv->last_pict_type = mpv->pict_type; emms_c(); @@ -1901,7 +1907,7 @@ static const AVOption options[] = { "defined in the section 'Expression Evaluation', the following functions are available: " "bits2qp(bits), qp2bits(qp). Also the following constants are available: iTex pTex tex mv " "fCode iCount mcVar var isI isP isB avgQP qComp avgIITex avgPITex avgPPTex avgBPTex avgTex.", - OFFSET(m.rc_eq), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VE }, + OFFSET(m.common.rc_eq), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VE }, { NULL }, }; diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c index be80065a32..6f89927d68 100644 --- a/libavcodec/speedhqenc.c +++ b/libavcodec/speedhqenc.c @@ -89,8 +89,9 @@ static av_cold void speedhq_init_static_data(void) ff_mpeg1_init_uni_ac_vlc(&ff_rl_speedhq, uni_speedhq_ac_vlc_len); } -av_cold int ff_speedhq_encode_init(MPVMainEncContext *s) +av_cold int ff_speedhq_encode_init(MPVMainEncContext *m) { + MPVEncContext *const s = &m->common; static AVOnce init_static_once = AV_ONCE_INIT; if (s->width > 65500 || s->height > 65500) { @@ -125,9 +126,10 @@ av_cold int ff_speedhq_encode_init(MPVMainEncContext *s) return 0; } -void ff_speedhq_encode_picture_header(MPVMainEncContext *s) +void ff_speedhq_encode_picture_header(MPVMainEncContext *m) { - SpeedHQEncContext *ctx = (SpeedHQEncContext*)s; + SpeedHQEncContext *ctx = (SpeedHQEncContext*)m; + MPVEncContext *const s = &m->common; put_bits_le(&s->pb, 8, 100 - s->qscale * 2); /* FIXME why doubled */ put_bits_le(&s->pb, 24, 4); /* no second field */ diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c index 7af82bb3ac..5e26c1073a 100644 --- a/libavcodec/svq1enc.c +++ b/libavcodec/svq1enc.c @@ -253,6 +253,7 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane, unsigned char *decoded_plane, int width, int height, int src_stride, int stride) { + MPVEncContext *const mpv = &s->m.common; int x, y; int i; int block_width, block_height; @@ -271,64 +272,64 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane, block_height = (height + 15) / 16; if (s->pict_type == AV_PICTURE_TYPE_P) { - s->m.avctx = s->avctx; - s->m.current_picture_ptr = &s->m.current_picture; - s->m.last_picture_ptr = &s->m.last_picture; - s->m.last_picture.f->data[0] = ref_plane; - s->m.linesize = - s->m.last_picture.f->linesize[0] = - s->m.new_picture.f->linesize[0] = - s->m.current_picture.f->linesize[0] = stride; - s->m.width = width; - s->m.height = height; - s->m.mb_width = block_width; - s->m.mb_height = block_height; - s->m.mb_stride = s->m.mb_width + 1; - s->m.b8_stride = 2 * s->m.mb_width + 1; - s->m.f_code = 1; - s->m.pict_type = s->pict_type; - s->m.motion_est = s->motion_est; - s->m.me.scene_change_score = 0; - // s->m.out_format = FMT_H263; - // s->m.unrestricted_mv = 1; - s->m.lambda = s->quality; - s->m.qscale = s->m.lambda * 139 + + mpv->avctx = s->avctx; + mpv->current_picture_ptr = &mpv->current_picture; + mpv->last_picture_ptr = &mpv->last_picture; + mpv->last_picture.f->data[0] = ref_plane; + mpv->linesize = + mpv->last_picture.f->linesize[0] = + mpv->new_picture.f->linesize[0] = + mpv->current_picture.f->linesize[0] = stride; + mpv->width = width; + mpv->height = height; + mpv->mb_width = block_width; + mpv->mb_height = block_height; + mpv->mb_stride = mpv->mb_width + 1; + mpv->b8_stride = 2 * mpv->mb_width + 1; + mpv->f_code = 1; + mpv->pict_type = s->pict_type; + mpv->motion_est = s->motion_est; + mpv->me.scene_change_score = 0; + // mpv->out_format = FMT_H263; + // mpv->unrestricted_mv = 1; + mpv->lambda = s->quality; + mpv->qscale = mpv->lambda * 139 + FF_LAMBDA_SCALE * 64 >> FF_LAMBDA_SHIFT + 7; - s->m.lambda2 = s->m.lambda * s->m.lambda + + mpv->lambda2 = mpv->lambda * mpv->lambda + FF_LAMBDA_SCALE / 2 >> FF_LAMBDA_SHIFT; if (!s->motion_val8[plane]) { - s->motion_val8[plane] = av_mallocz((s->m.b8_stride * + s->motion_val8[plane] = av_mallocz((mpv->b8_stride * block_height * 2 + 2) * 2 * sizeof(int16_t)); - s->motion_val16[plane] = av_mallocz((s->m.mb_stride * + s->motion_val16[plane] = av_mallocz((mpv->mb_stride * (block_height + 2) + 1) * 2 * sizeof(int16_t)); if (!s->motion_val8[plane] || !s->motion_val16[plane]) return AVERROR(ENOMEM); } - s->m.mb_type = s->mb_type; + mpv->mb_type = s->mb_type; // dummies, to avoid segfaults - s->m.current_picture.mb_mean = (uint8_t *)s->dummy; - s->m.current_picture.mb_var = (uint16_t *)s->dummy; - s->m.current_picture.mc_mb_var = (uint16_t *)s->dummy; - s->m.current_picture.mb_type = s->dummy; - - s->m.current_picture.motion_val[0] = s->motion_val8[plane] + 2; - s->m.p_mv_table = s->motion_val16[plane] + - s->m.mb_stride + 1; - s->m.mecc = s->mecc; // move - ff_init_me(&s->m); - - s->m.me.dia_size = s->avctx->dia_size; - s->m.first_slice_line = 1; + mpv->current_picture.mb_mean = (uint8_t *)s->dummy; + mpv->current_picture.mb_var = (uint16_t *)s->dummy; + mpv->current_picture.mc_mb_var = (uint16_t *)s->dummy; + mpv->current_picture.mb_type = s->dummy; + + mpv->current_picture.motion_val[0] = s->motion_val8[plane] + 2; + mpv->p_mv_table = s->motion_val16[plane] + + mpv->mb_stride + 1; + mpv->mecc = s->mecc; // move + ff_init_me(mpv); + + mpv->me.dia_size = s->avctx->dia_size; + mpv->first_slice_line = 1; for (y = 0; y < block_height; y++) { - s->m.new_picture.f->data[0] = src - y * 16 * stride; // ugly - s->m.mb_y = y; + mpv->new_picture.f->data[0] = src - y * 16 * stride; // ugly + mpv->mb_y = y; for (i = 0; i < 16 && i + 16 * y < height; i++) { memcpy(&src[i * stride], &src_plane[(i + 16 * y) * src_stride], @@ -341,20 +342,20 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane, 16 * block_width); for (x = 0; x < block_width; x++) { - s->m.mb_x = x; - init_block_index(&s->m); + mpv->mb_x = x; + init_block_index(mpv); - ff_estimate_p_frame_motion(&s->m, x, y); + ff_estimate_p_frame_motion(mpv, x, y); } - s->m.first_slice_line = 0; + mpv->first_slice_line = 0; } - ff_fix_long_p_mvs(&s->m, CANDIDATE_MB_TYPE_INTRA); - ff_fix_long_mvs(&s->m, NULL, 0, s->m.p_mv_table, s->m.f_code, + ff_fix_long_p_mvs(mpv, CANDIDATE_MB_TYPE_INTRA); + ff_fix_long_mvs(mpv, NULL, 0, mpv->p_mv_table, mpv->f_code, CANDIDATE_MB_TYPE_INTER, 0); } - s->m.first_slice_line = 1; + mpv->first_slice_line = 1; for (y = 0; y < block_height; y++) { for (i = 0; i < 16 && i + 16 * y < height; i++) { memcpy(&src[i * stride], &src_plane[(i + 16 * y) * src_stride], @@ -365,7 +366,7 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane, for (; i < 16 && i + 16 * y < 16 * block_height; i++) memcpy(&src[i * stride], &src[(i - 1) * stride], 16 * block_width); - s->m.mb_y = y; + mpv->mb_y = y; for (x = 0; x < block_width; x++) { uint8_t reorder_buffer[2][6][7 * 32]; int count[2][6]; @@ -380,11 +381,11 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane, return -1; } - s->m.mb_x = x; - init_block_index(&s->m); + mpv->mb_x = x; + init_block_index(mpv); if (s->pict_type == AV_PICTURE_TYPE_I || - (s->m.mb_type[x + y * s->m.mb_stride] & + (mpv->mb_type[x + y * mpv->mb_stride] & CANDIDATE_MB_TYPE_INTRA)) { for (i = 0; i < 6; i++) init_put_bits(&s->reorder_pb[i], reorder_buffer[0][i], @@ -410,8 +411,8 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane, int mx, my, pred_x, pred_y, dxy; int16_t *motion_ptr; - motion_ptr = ff_h263_pred_motion(&s->m, 0, 0, &pred_x, &pred_y); - if (s->m.mb_type[x + y * s->m.mb_stride] & + motion_ptr = ff_h263_pred_motion(mpv, 0, 0, &pred_x, &pred_y); + if (mpv->mb_type[x + y * mpv->mb_stride] & CANDIDATE_MB_TYPE_INTER) { for (i = 0; i < 6; i++) init_put_bits(&s->reorder_pb[i], reorder_buffer[1][i], @@ -419,16 +420,16 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane, put_bits(&s->reorder_pb[5], vlc[1], vlc[0]); - s->m.pb = s->reorder_pb[5]; + mpv->pb = s->reorder_pb[5]; mx = motion_ptr[0]; my = motion_ptr[1]; av_assert1(mx >= -32 && mx <= 31); av_assert1(my >= -32 && my <= 31); av_assert1(pred_x >= -32 && pred_x <= 31); av_assert1(pred_y >= -32 && pred_y <= 31); - ff_h263_encode_motion(&s->m.pb, mx - pred_x, 1); - ff_h263_encode_motion(&s->m.pb, my - pred_y, 1); - s->reorder_pb[5] = s->m.pb; + ff_h263_encode_motion(&mpv->pb, mx - pred_x, 1); + ff_h263_encode_motion(&mpv->pb, my - pred_y, 1); + s->reorder_pb[5] = mpv->pb; score[1] += lambda * put_bits_count(&s->reorder_pb[5]); dxy = (mx & 1) + 2 * (my & 1); @@ -463,10 +464,10 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane, motion_ptr[1] = motion_ptr[2] = motion_ptr[3] = - motion_ptr[0 + 2 * s->m.b8_stride] = - motion_ptr[1 + 2 * s->m.b8_stride] = - motion_ptr[2 + 2 * s->m.b8_stride] = - motion_ptr[3 + 2 * s->m.b8_stride] = 0; + motion_ptr[0 + 2 * mpv->b8_stride] = + motion_ptr[1 + 2 * mpv->b8_stride] = + motion_ptr[2 + 2 * mpv->b8_stride] = + motion_ptr[3 + 2 * mpv->b8_stride] = 0; } } @@ -479,7 +480,7 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane, if (best == 0) s->hdsp.put_pixels_tab[0][0](decoded, temp, stride, 16); } - s->m.first_slice_line = 0; + mpv->first_slice_line = 0; } return 0; } @@ -487,6 +488,7 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane, static av_cold int svq1_encode_end(AVCodecContext *avctx) { SVQ1EncContext *const s = avctx->priv_data; + MPVEncContext *const mpv = &s->m.common; int i; if (avctx->frame_number) @@ -494,12 +496,12 @@ static av_cold int svq1_encode_end(AVCodecContext *avctx) s->rd_total / (double)(avctx->width * avctx->height * avctx->frame_number)); - s->m.mb_type = NULL; - ff_mpv_common_end(&s->m); + mpv->mb_type = NULL; + ff_mpv_common_end(&s->m.common); - av_freep(&s->m.me.scratchpad); - av_freep(&s->m.me.map); - av_freep(&s->m.me.score_map); + av_freep(&mpv->me.scratchpad); + av_freep(&mpv->me.map); + av_freep(&mpv->me.score_map); av_freep(&s->mb_type); av_freep(&s->dummy); av_freep(&s->scratchbuf); @@ -518,6 +520,7 @@ static av_cold int svq1_encode_end(AVCodecContext *avctx) static av_cold int svq1_encode_init(AVCodecContext *avctx) { SVQ1EncContext *const s = avctx->priv_data; + MPVEncContext *const mpv = &s->m.common; int ret; if (avctx->width >= 4096 || avctx->height >= 4096) { @@ -527,7 +530,7 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx) ff_hpeldsp_init(&s->hdsp, avctx->flags); ff_me_cmp_init(&s->mecc, avctx); - ff_mpegvideoencdsp_init(&s->m.mpvencdsp, avctx); + ff_mpegvideoencdsp_init(&mpv->mpvencdsp, avctx); s->current_picture = av_frame_alloc(); s->last_picture = av_frame_alloc(); @@ -545,26 +548,26 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx) s->c_block_height = (s->frame_height / 4 + 15) / 16; s->avctx = avctx; - s->m.avctx = avctx; + mpv->avctx = avctx; - if ((ret = ff_mpv_common_init(&s->m)) < 0) { + if ((ret = ff_mpv_common_init(&s->m.common)) < 0) { return ret; } - s->m.picture_structure = PICT_FRAME; - s->m.me.temp = - s->m.me.scratchpad = av_mallocz((avctx->width + 64) * + mpv->picture_structure = PICT_FRAME; + mpv->me.temp = + mpv->me.scratchpad = av_mallocz((avctx->width + 64) * 2 * 16 * 2 * sizeof(uint8_t)); - s->m.me.map = av_mallocz(ME_MAP_SIZE * sizeof(uint32_t)); - s->m.me.score_map = av_mallocz(ME_MAP_SIZE * sizeof(uint32_t)); + mpv->me.map = av_mallocz(ME_MAP_SIZE * sizeof(uint32_t)); + mpv->me.score_map = av_mallocz(ME_MAP_SIZE * sizeof(uint32_t)); s->mb_type = av_mallocz((s->y_block_width + 1) * s->y_block_height * sizeof(int16_t)); s->dummy = av_mallocz((s->y_block_width + 1) * s->y_block_height * sizeof(int32_t)); s->ssd_int8_vs_int16 = ssd_int8_vs_int16_c; - if (!s->m.me.temp || !s->m.me.scratchpad || !s->m.me.map || - !s->m.me.score_map || !s->mb_type || !s->dummy) { + if (!mpv->me.temp || !mpv->me.scratchpad || !mpv->me.map || + !mpv->me.score_map || !s->mb_type || !s->dummy) { return AVERROR(ENOMEM); } diff --git a/libavcodec/wmv2enc.c b/libavcodec/wmv2enc.c index cd35fd19b1..11d566fe5a 100644 --- a/libavcodec/wmv2enc.c +++ b/libavcodec/wmv2enc.c @@ -43,7 +43,7 @@ typedef struct WMV2EncContext { static int encode_ext_header(WMV2EncContext *w) { - MPVMainEncContext *const s = &w->msmpeg4.s; + MPVEncContext *const s = &w->msmpeg4.s.common; PutBitContext pb; int code; @@ -70,13 +70,14 @@ static int encode_ext_header(WMV2EncContext *w) static av_cold int wmv2_encode_init(AVCodecContext *avctx) { WMV2EncContext *const w = avctx->priv_data; - MPVMainEncContext *const s = &w->msmpeg4.s; + MPVMainEncContext *const m = &w->msmpeg4.s; + MPVEncContext *const s = &m->common; s->private_ctx = &w->common; if (ff_mpv_encode_init(avctx) < 0) return -1; - ff_wmv2_common_init(s); + ff_wmv2_common_init(&m->common); avctx->extradata_size = 4; avctx->extradata = av_mallocz(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); @@ -88,9 +89,10 @@ static av_cold int wmv2_encode_init(AVCodecContext *avctx) return 0; } -int ff_wmv2_encode_picture_header(MPVMainEncContext *s, int picture_number) +int ff_wmv2_encode_picture_header(MPVMainEncContext *m, int picture_number) { - WMV2EncContext *const w = (WMV2EncContext *) s; + WMV2EncContext *const w = (WMV2EncContext *) m; + MPVEncContext *const s = &m->common; put_bits(&s->pb, 1, s->pict_type - 1); if (s->pict_type == AV_PICTURE_TYPE_I) From patchwork Tue Feb 1 13:06:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34001 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp605469iov; Tue, 1 Feb 2022 05:13:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJxoFmcsgo6nzfpjvYgj7BP/5u2tDhFjJbrufzoo4u2RXO6dPTF9pDjJJ+CjobwoQflwxAJC X-Received: by 2002:aa7:c258:: with SMTP id y24mr25288904edo.288.1643721205323; Tue, 01 Feb 2022 05:13:25 -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 v28si9040723ejk.797.2022.02.01.05.13.24; Tue, 01 Feb 2022 05:13:25 -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=UBe7dOxv; 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 85F2168B369; Tue, 1 Feb 2022 15:07:59 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2100.outbound.protection.outlook.com [40.92.89.100]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AF76368B364 for ; Tue, 1 Feb 2022 15:07:58 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JJ40LoNwB1ef17h056AE4PbW3SKor+ofIIiPmh7DJBLI4IRFx4AZxzLW/4b4blHOHwvf10i65NZLVCBYhyxi8XR9r8JHu5sviVmqBUs43nzpOolte82+e6dZm10EdSlPiYMLkdPAjgdhMef0elnxGGHNSfJIACsanuem/DEbcPxQ32wWXkMTQEgOv5v9OSmrezA211a4m+RvlNN2ElAm5O1pCOtfBdo96zy2G3JIk1RyRbP2Z/7hE9wQGIuoz4BCshyXHAn2BS6c7Vv8IrIkmky8DNsKz8RqO9eJQkXCKRDVcQZvhzG7YywWUGjOQpfMAYuTWx3PdV6pWLV0QfIqCQ== 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=OxNF9x2+xqLoZo+wV4H6tUz65rrcb/7j6oV1PjTbFp8=; b=MTeATpHXxmJ5krQXkKTx6Pq2egiSfFZUS0VWp4RcCLIdTYCkXJYi+TERSiNVNlzCo3KD41wvFHA/V2tg4knJoVVBbXVpclngCyqDzzjgI+QYEvXXuPgzB0lN+f3C/47BlgPPDr4JGp3KzKWQxJl2f9CTUdwk4z6hqZ2MgwOzrPzwD2zF89oIT7KXeJIXtwCBFnqaYri88aFBFRN+qPap/H4VgIMyVrS1pfDL2Sm05YAAiYbiqgKg6yW72PyJ3HScR5CPthPfZusr9+P0eNkk2S7o1iqLCUZOPl71mZdI8/LVd2GQPUZ15gK/br0ztnfVBN/xclg4elpjXCHCCsO9SA== 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=OxNF9x2+xqLoZo+wV4H6tUz65rrcb/7j6oV1PjTbFp8=; b=UBe7dOxvol+jRjPAuuvVhAX1tFrfMnq9R/P+MtPvD2NO7Ovo/gK/5Q2nCN/gFDCxjBs57YmoTP7Q4a3Im5TrOzqFW37VZ/5vcrBMGwO0Tv8FQHBh7YoQRxqnLl0x6TtW09Fqjw1CwEvzSpvbg0Y1SntFr58MYVssd+jxM4r5AU/46H+8SveRQTTL6hXlRqixIngQYb8lCrebsiDqvu8iOsiT5icKG8X1UI87jcoq5skSPacDDEw70CU4jtDtl+rOm5rlp5lkouly8w0qQNw1wf+jxYnGrDdHKXOzt55lONUa/AsBklqsQt3ORdruqf4oYefLYwXyLsB5zPvF0Qvf/A== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR03MB5700.eurprd03.prod.outlook.com (2603:10a6:208:16f::32) 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:57 +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:56 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:26 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [3jMYMw9ZXDobZ/e3n9nML9oUdgcrLAzN] 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-28-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2f55181d-4d0e-4b26-9cda-08d9e583dd72 X-MS-TrafficTypeDiagnostic: AM0PR03MB5700:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8dzvC+F+lgCnweQNR9Er0E6hypRMVRIX/0v5EKB71cnn1BkCC8aT8gnlinL9lhqxWzOvN65YKn7wsYav8w7yFpcZVpiaHk+nMtbyruX8z3ZlfD/zDaWEsJ0ypvbCAveYnvqWNeAGjnGmECGoT7hYcOSp51vLAE3tJe1vFJ+9OZT21a1L0BFTrkNCgcqtqZhXXzDa2Gw4le3QKcQQ9KX3K/a5fp1CSjySpX9S73ZaVQe309EIt8GWaLoW4BByqYwHAvRz1hjTtQoggURsLa8hucLMaPgORJNASM+mWoBXRoQ+oTRwRb8eZzGyEb8DLf0W/VrckwznVzpS7eacEDraUiZbNvSz+EM+y/HymNuVBR7NCTX5up1sDbHn/q+120W6ye9A/cVHbNY3DytsTJmWsmFo6CaRllw4ltrc+pzAWmRhsy+AaO/I81UOjUHc766A34aZ1xOzwl3uQsqqfHavKB3R6Io5VnPexRRAt9MfXv2Y9UEUT1QgziZkwkkkf0rP1gt4QnvLjJgQWp0SJnG+TYrpBZDqkxZO4Epj9kcbHnMUfysBy4vbVB1ubEOZozie X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vUI9po1PuZDi4P1c0oj7JWMLG/1m8krCaoraElmq0Q60bXqmMsIGChQ1wTH/hegpDbbgksEg75P/PzodFF+th7U8kA6dFQuED9nV+TycBVp3MRsavs+rzDXLkqXSFRHowr1x9ZlhukTV2IX/+KvXqi0Uut2TANqrybUoex//bztRkPWIisavEFLgXkzG5/0IsAG7oG3+L/X9M82/NDgvHLDoiNRFUu/MiBQ4Y5aGM+BqDYRaeNleSLNRCchCFI/sCNUTBx0dziaKACQ9l5Xppq9uV2qlFtN2QChDvRYdd/k3jtkDiPo5cpFRCJ0zubNEMZHLEr0WGiRx4ErxC+8IVZM5pAvTCwykAhpMhuJ4BHvZpz8ojdoJOmaBZTShWAlkMJWT0IqVwc94v1ZxmHJQUZeJQl75vNGGLrdFduVlsvmOASn9ip9y1hzcdMXHo7E5DWJqIbxP16OpP1XTFCKJfzWL1yPPFbCHs4nHHlLAt0TqBpqIoMcPOXVQX59WX/KA49xeWwzGxEsTc4HVtqeT3uzvt1wZxXzaWGIUHsuoF1oAb1UGLmOdYHMwBVghv/BVMZ5OjVwB6u/Knw9uska7ktgV69c7/NWrel+1EDEaPJ6pEI0nK5Hp4wd7ZFjmjWWhdA+pandQwt3bn+U0UTtpqD5QkhoUYty9IF5RZy4HzpSF1XI7kbEdfYmmVzxl+7QN5YPWwSO21LBE7ubVAt6ssYneCpMutTlcGhzUHyN3Vbr8Pa8nUuFRpxDnwYTcsjochJ0uN8vKh+07K3a6sUaMHTPxHjTjTjhcJQmXJxUztMJJSEGrwGjQtiyd656cVfyZHiJ63byTGMR9YFecWhYTDdN1G9VoeSPiPT2n6fS/3sPEqX4JFEDwfhEktN6WpfEwMbJGggoftydBhWsM9P5Noz8Xd4bb6LwZNDaRiJeROEe+5bHiOJMsCtJHImek0FGMnP1tVBRK7hcqT3Bp+5pP4A== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2f55181d-4d0e-4b26-9cda-08d9e583dd72 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:56.9481 (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: AM0PR03MB5700 Subject: [FFmpeg-devel] [PATCH v2 29/69] avcodec/mpegvideoenc: Move tmp bframes to MPVMainEncContext 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: /E4EM84yio1K Also move b_frame_strategy and b_sensitivity; they are all only used by an encoder's main thread. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo.h | 7 ----- libavcodec/mpegvideo_enc.c | 61 +++++++++++++++++++------------------- libavcodec/mpegvideoenc.h | 15 +++++++--- 3 files changed, 41 insertions(+), 42 deletions(-) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index a32bd277eb..017aadb3e7 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -56,8 +56,6 @@ #define MAX_THREADS 32 -#define MAX_B_FRAMES 16 - /** * MPVContext. */ @@ -528,11 +526,6 @@ typedef struct MPVContext { int error_rate; - /* temporary frames used by b_frame_strategy = 2 */ - AVFrame *tmp_frames[MAX_B_FRAMES + 2]; - int b_frame_strategy; - int b_sensitivity; - /* frame skip options for encoding */ int frame_skip_threshold; int frame_skip_factor; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 5f607d9e11..e365f2fd81 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -354,10 +354,10 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) } s->gop_size = avctx->gop_size; s->avctx = avctx; - if (avctx->max_b_frames > MAX_B_FRAMES) { + if (avctx->max_b_frames > MPVENC_MAX_B_FRAMES) { av_log(avctx, AV_LOG_ERROR, "Too many B-frames requested, maximum " - "is %d.\n", MAX_B_FRAMES); - avctx->max_b_frames = MAX_B_FRAMES; + "is " AV_STRINGIFY(MPVENC_MAX_B_FRAMES) ".\n"); + avctx->max_b_frames = MPVENC_MAX_B_FRAMES; } else if (avctx->max_b_frames < 0) { av_log(avctx, AV_LOG_ERROR, "max b frames must be 0 or positive for mpegvideo based encoders\n"); @@ -612,10 +612,10 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) return AVERROR(EINVAL); } - if (s->b_frame_strategy && (avctx->flags & AV_CODEC_FLAG_PASS2)) { + if (m->b_frame_strategy && (avctx->flags & AV_CODEC_FLAG_PASS2)) { av_log(avctx, AV_LOG_INFO, "notice: b_frame_strategy only affects the first pass\n"); - s->b_frame_strategy = 0; + m->b_frame_strategy = 0; } i = av_gcd(avctx->time_base.den, avctx->time_base.num); @@ -904,17 +904,17 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) if ((ret = ff_rate_control_init(m)) < 0) return ret; - if (s->b_frame_strategy == 2) { + if (m->b_frame_strategy == 2) { for (i = 0; i < s->max_b_frames + 2; i++) { - s->tmp_frames[i] = av_frame_alloc(); - if (!s->tmp_frames[i]) + m->tmp_frames[i] = av_frame_alloc(); + if (!m->tmp_frames[i]) return AVERROR(ENOMEM); - s->tmp_frames[i]->format = AV_PIX_FMT_YUV420P; - s->tmp_frames[i]->width = s->width >> s->brd_scale; - s->tmp_frames[i]->height = s->height >> s->brd_scale; + m->tmp_frames[i]->format = AV_PIX_FMT_YUV420P; + m->tmp_frames[i]->width = s->width >> s->brd_scale; + m->tmp_frames[i]->height = s->height >> s->brd_scale; - ret = av_frame_get_buffer(s->tmp_frames[i], 0); + ret = av_frame_get_buffer(m->tmp_frames[i], 0); if (ret < 0) return ret; } @@ -935,14 +935,13 @@ av_cold int ff_mpv_encode_end(AVCodecContext *avctx) { MPVMainEncContext *const m = avctx->priv_data; MPVMainContext *const s = &m->common; - int i; ff_rate_control_uninit(m); ff_mpv_common_end(&m->common); - for (i = 0; i < FF_ARRAY_ELEMS(s->tmp_frames); i++) - av_frame_free(&s->tmp_frames[i]); + for (int i = 0; i < FF_ARRAY_ELEMS(m->tmp_frames); i++) + av_frame_free(&m->tmp_frames[i]); ff_mpv_picture_free(avctx, &s->new_picture); @@ -1267,18 +1266,18 @@ static int estimate_best_b_count(MPVMainEncContext *m) data[2] += INPLACE_OFFSET; } - s->mpvencdsp.shrink[scale](s->tmp_frames[i]->data[0], - s->tmp_frames[i]->linesize[0], + s->mpvencdsp.shrink[scale](m->tmp_frames[i]->data[0], + m->tmp_frames[i]->linesize[0], data[0], pre_input.f->linesize[0], width, height); - s->mpvencdsp.shrink[scale](s->tmp_frames[i]->data[1], - s->tmp_frames[i]->linesize[1], + s->mpvencdsp.shrink[scale](m->tmp_frames[i]->data[1], + m->tmp_frames[i]->linesize[1], data[1], pre_input.f->linesize[1], width >> 1, height >> 1); - s->mpvencdsp.shrink[scale](s->tmp_frames[i]->data[2], - s->tmp_frames[i]->linesize[2], + s->mpvencdsp.shrink[scale](m->tmp_frames[i]->data[2], + m->tmp_frames[i]->linesize[2], data[2], pre_input.f->linesize[2], width >> 1, height >> 1); @@ -1315,10 +1314,10 @@ static int estimate_best_b_count(MPVMainEncContext *m) goto fail; - s->tmp_frames[0]->pict_type = AV_PICTURE_TYPE_I; - s->tmp_frames[0]->quality = 1 * FF_QP2LAMBDA; + m->tmp_frames[0]->pict_type = AV_PICTURE_TYPE_I; + m->tmp_frames[0]->quality = 1 * FF_QP2LAMBDA; - out_size = encode_frame(c, s->tmp_frames[0], pkt); + out_size = encode_frame(c, m->tmp_frames[0], pkt); if (out_size < 0) { ret = out_size; goto fail; @@ -1329,11 +1328,11 @@ static int estimate_best_b_count(MPVMainEncContext *m) for (i = 0; i < s->max_b_frames + 1; i++) { int is_p = i % (j + 1) == j || i == s->max_b_frames; - s->tmp_frames[i + 1]->pict_type = is_p ? + m->tmp_frames[i + 1]->pict_type = is_p ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_B; - s->tmp_frames[i + 1]->quality = is_p ? p_lambda : b_lambda; + m->tmp_frames[i + 1]->quality = is_p ? p_lambda : b_lambda; - out_size = encode_frame(c, s->tmp_frames[i + 1], pkt); + out_size = encode_frame(c, m->tmp_frames[i + 1], pkt); if (out_size < 0) { ret = out_size; goto fail; @@ -1420,11 +1419,11 @@ static int select_input_picture(MPVMainEncContext *m) } } - if (s->b_frame_strategy == 0) { + if (m->b_frame_strategy == 0) { b_frames = s->max_b_frames; while (b_frames && !s->input_picture[b_frames]) b_frames--; - } else if (s->b_frame_strategy == 1) { + } else if (m->b_frame_strategy == 1) { for (i = 1; i < s->max_b_frames + 1; i++) { if (s->input_picture[i] && s->input_picture[i]->b_frame_score == 0) { @@ -1438,7 +1437,7 @@ static int select_input_picture(MPVMainEncContext *m) for (i = 0; i < s->max_b_frames + 1; i++) { if (!s->input_picture[i] || s->input_picture[i]->b_frame_score - 1 > - s->mb_num / s->b_sensitivity) + s->mb_num / m->b_sensitivity) break; } @@ -1448,7 +1447,7 @@ static int select_input_picture(MPVMainEncContext *m) for (i = 0; i < b_frames + 1; i++) { s->input_picture[i]->b_frame_score = 0; } - } else if (s->b_frame_strategy == 2) { + } else if (m->b_frame_strategy == 2) { b_frames = estimate_best_b_count(m); if (b_frames < 0) return b_frames; diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index 37375132d7..7b58ace64b 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -32,9 +32,16 @@ #include "internal.h" #include "mpegvideo.h" +#define MPVENC_MAX_B_FRAMES 16 + typedef MPVContext MPVEncContext; typedef struct MPVMainEncContext { MPVMainContext common; + + /* temporary frames used by b_frame_strategy == 2 */ + AVFrame *tmp_frames[MPVENC_MAX_B_FRAMES + 2]; + int b_frame_strategy; + int b_sensitivity; } MPVMainEncContext; #define UNI_AC_ENC_INDEX(run,level) ((run)*128 + (level)) @@ -115,8 +122,8 @@ FF_MPV_OPT_CMP_FUNC, \ {"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 \ -{"b_strategy", "Strategy to choose between I/P/B-frames", FF_MPV_OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, FF_MPV_OPT_FLAGS }, \ -{"b_sensitivity", "Adjust sensitivity of b_frame_strategy 1", FF_MPV_OFFSET(b_sensitivity), AV_OPT_TYPE_INT, {.i64 = 40 }, 1, INT_MAX, FF_MPV_OPT_FLAGS }, \ +{"b_strategy", "Strategy to choose between I/P/B-frames", FF_MPV_MAIN_OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, FF_MPV_OPT_FLAGS }, \ +{"b_sensitivity", "Adjust sensitivity of b_frame_strategy 1", FF_MPV_MAIN_OFFSET(b_sensitivity), AV_OPT_TYPE_INT, {.i64 = 40 }, 1, INT_MAX, FF_MPV_OPT_FLAGS }, \ {"brd_scale", "Downscale frames for dynamic B-frame decision", FF_MPV_OFFSET(brd_scale), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 3, FF_MPV_OPT_FLAGS }, #if FF_API_MPEGVIDEO_OPTS @@ -127,8 +134,8 @@ FF_MPV_OPT_CMP_FUNC, \ #define FF_MPV_DEPRECATED_MATRIX_OPT \ { "force_duplicated_matrix", "Deprecated, does nothing", FF_MPV_OFFSET(dummy), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, #define FF_MPV_DEPRECATED_BFRAME_OPTS \ - { "b_strategy", "Deprecated, does nothing", FF_MPV_OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, \ - { "b_sensitivity", "Deprecated, does nothing", FF_MPV_OFFSET(b_sensitivity), AV_OPT_TYPE_INT, { .i64 = 40 }, 1, INT_MAX, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, \ + { "b_strategy", "Deprecated, does nothing", FF_MPV_MAIN_OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, \ + { "b_sensitivity", "Deprecated, does nothing", FF_MPV_MAIN_OFFSET(b_sensitivity), AV_OPT_TYPE_INT, { .i64 = 40 }, 1, INT_MAX, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, \ { "brd_scale", "Deprecated, does nothing", FF_MPV_OFFSET(brd_scale), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 3, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, #endif From patchwork Tue Feb 1 13:06:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34003 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp605977iov; Tue, 1 Feb 2022 05:14:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJwyHQiV9lcqTARExNM49TgUIT2Gphb5BFCkW0YkUnJCqQBwu0nrTW24ooIjcjpgEglqrdTq X-Received: by 2002:a17:906:7315:: with SMTP id di21mr21415963ejc.515.1643721242000; Tue, 01 Feb 2022 05:14:02 -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 11si9138216eje.377.2022.02.01.05.14.01; Tue, 01 Feb 2022 05:14:01 -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=f8s+hal6; 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 9B26068B372; Tue, 1 Feb 2022 15:08:02 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2079.outbound.protection.outlook.com [40.92.89.79]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 658FD68B304 for ; Tue, 1 Feb 2022 15:08:00 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mLU66mN8UsYwIxlWQngKmrRiw0oNIxKQpPdeB+tadb/FcMgVcfRy2/hJJn9T4ypMkV6YW9CmCT7e4oa59Mrh3CyMLdfOvA6e4hTKedNIwyxpjG/dE5s1coMzuZG3Ih30VDZeEZIA+R8ySIyjJBEfu6xi7n8hCh9oewQkMwNDjTNwPwY0YQ1LMiGC3Y0/RZs6rnVonxU0N//192FFN76qvVH4b/EjB8bTypT7Wl9/4z4GTo5Cnfwujr90b6QHJFr/Pc+Fn+tvO6FmQnzfAvu0lgN/1NxmK1w4hm4L4BcYdMHiGopfVHvQidXJ3Djgd//x08nBDFD4xl1ajgZW4zhiIg== 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=Z7FnZJNkSygU97ULjTFRh2UdNzgiSRRGPC/wGe/Jmic=; b=UYP++A7QgAlKi8FHqoluIHTKSasokZCsxxITuEF1B1w3EdL9vH9nknT+bK+vHMquAp1SFpn3TdSMvMrTVNTqeOIAqEP4gzeQ7CzVgFlZxQlP4sd+taimsW/ChhD6wYvuaF4UDTzxkHtIxUTXmaTqCTAtVc1OH2X5SN9kQsdbkVD/4TKwUETh/KoS3tAM5blRSMyJL8Dnv3pKdaXefB1rcSU37uMW5tLwpWwE7EFZPKqX4v7cFUx12iMRPzTSLhW1YW7ACcY4kIIfPJyOUKw5AvP7qhMJYogukY4SQe8GmNMHAmO1sitae0qhx8xfGUw9o8rv3wGT7x8l9ctrLMiumw== 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=Z7FnZJNkSygU97ULjTFRh2UdNzgiSRRGPC/wGe/Jmic=; b=f8s+hal616EdJu7h1ZmRxEgPFP8GRkGwQ/YAQ19QuH/Nzs5gXOXf3C1m8wxxXmFTFAXzt7ujPvpo5tO/F2/5lta5P9sZvY9zAXtzhdX4gjFw/0Ir/esUkAryWee4+rVT7SL3xGSIulr2BUznw7D2VniDJ5IW8cHGzQb1ltxgRxmvD68xVy1Z2TGx0lvYuFT9Q16qUDJ9G420LadEdJvaNB454YbvrR0W+NGrKUszwhGVlp4xE18Lb4b7gN8zKNLyHyrX2cPyNzOA/fWtYpIEVV6BgHc4+vCc+3qOJHYr7dfqQmDrNbgHTqJ/CaJxuz3k4Jdzef/zlReuTsEgOBmQOg== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR03MB5700.eurprd03.prod.outlook.com (2603:10a6:208:16f::32) 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:58 +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:58 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:27 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [Eo3s4xuTtX9cRC9iviw3gabh9CxdoIhT] 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-29-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3fa05e76-843b-481c-724f-08d9e583de3d X-MS-TrafficTypeDiagnostic: AM0PR03MB5700:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: w3PKuUrHhOfBIHKlQE69hOnTlu787gFKJDjiEqiXSYIj9NCx146FSIimk/pBPSYv4P6jwRvH7YofagH8DD6dTzvFodKkbj3F9E2OPvauR40z6W1Do8SkpUckGv1b++QqWkb6PgSuno6tKxehM26eVr9qb9IYXo7rcvZqSen44IbyBnLqvT1ywuxURm5ZCG8pOF1iA/gdp0J5XbwjXzjyQHdbIxEZQi4iA/rvSswh4oqagLtYqKrDzj/a4jl7HuJAl131osj7xzyldKaNe0bjS0kiWngIcT5uiA4E8h8n165TQKFJx9d21VzpUAgZt9IUKM29/5IydX6r6n6svd/PN8MFx3bwCX9iDCiS8/hALwqy99tVC0PyahC5bZjjj8qFgbsU0aTGqDRXzo3CBnMETCj2k85BoiP1wNZj+azviIMxheOMX+zx3Yorm/mz+Kw3DSJ9SgF36Fg5RZ4CAG02HTWrCc2UrMdIx2CKZAEAqO4IbcXDPf5dRR/Z7RYtbmyQhzOjL+/XBThau2wHGilDF3hUTgQqxSTuXiHnRWtiyt96KjHeKJvWVyUI/2lW00Fp X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: e4TkBvnVZJC7fqcGYOLXi1icDwv5S9u5qIMf2Rqy/y7fcqLxOVCcSm3KNgHfYCT4kkW83kj/XGAzAW1aUV10lUN72IWHGwdYSKPJnIWBDZ5DedHORbp0JIo78CETT6ZD/ehi8u3lmaDcIUt1jScFePGWo1Mg0HNzfBGyVuXNd8rl7lgnI+gyO+iAWSeodJoiTyzB/NwF/rdahxUfIuEk80+liVgqmQtJ14p0scF9wIAlp1zuJunD+GbFzLFoNeK8JplWe02zKPNt4WSwr2ukV7IBDp6Lp73a8WiwT2wy2Z7cBqmg2Nbv5O8Uu2QkaiMseex1fFJoG1UM/xm84ypYFrKSrwGVbyCx/W7V7BD66hs+KRwb3w82K7ZEGP+OO1dNYkdVn6RM+aWWL44t5HLU2PpC2vPG3h2vsjtfb83gPd+pg5aTvZgHWaYTeQGByWecrLDVx8N1ZNIag3ZyW9YnLHKta2TWU/os6yIddnKJn81sj/1jfJd1wE3WsQqdOGsSRgb2E9kBPfJMXiPoNBRen4bS3fq2KHQY7uSfOlV7I1iE8l5haYFPQfGkesRuYz22WGEVx8l8hYqbs8ft+e+2IjzwTKTcVd4L5pOlADLcRVUTvvyiI/yIV/QdYJqs+D1vFUHcH39lNM0RqjrtlafGgckYToaamruaSfRFQDEZ8jL0FmgcMQauMfNx5RCxlbQcTrjIF6OccAToES4eEzkCKlf39ChiaKWjwvNf3cRoad2v82jvvpSzroSxZ9lFszbOssoKNHR1df+NNkAn/QWpXBYfirVmBJOV1nQ/tfU/ShoGM/VOexaBEi7oIBl/CuOoyErksUpgPc47VNJMVIKrfCVy51fhUZ458/EFbCxSUXjLy1iyTlFw4B+a+zVOt/I1qEfUxhDIRQgXWVTSfGHnquMkCnk5X5Pw+ZdNCTZvJnVs7M61gR5g31lxWOH5x8UR9ctYLnU4NQaj+Xaf21FoPg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3fa05e76-843b-481c-724f-08d9e583de3d 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:58.2931 (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: AM0PR03MB5700 Subject: [FFmpeg-devel] [PATCH v2 30/69] avcodec/mpegvideoenc: Move ratecontrol to MPVMainEncContext 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: EtCmgEtyvDBF Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo.h | 8 -------- libavcodec/mpegvideo_enc.c | 38 +++++++++++++++++++------------------- libavcodec/mpegvideoenc.h | 8 ++++++++ libavcodec/ratecontrol.c | 31 +++++++++++++++---------------- libavcodec/snowenc.c | 8 ++++---- 5 files changed, 46 insertions(+), 47 deletions(-) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 017aadb3e7..4811fc0ad6 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -46,7 +46,6 @@ #include "mpegvideoencdsp.h" #include "pixblockdsp.h" #include "put_bits.h" -#include "ratecontrol.h" #if FF_API_FLAG_TRUNCATED #include "parser.h" #endif @@ -312,13 +311,6 @@ typedef struct MPVContext { int dct_count[2]; uint16_t (*dct_offset)[64]; - /* bit rate control */ - int64_t total_bits; - int frame_bits; ///< bits used for the current frame - int stuffing_bits; ///< bits used for stuffing - int next_lambda; ///< next lambda used for retrying to encode a frame - RateControlContext rc_context; ///< contains stuff only accessed in ratecontrol.c - /* statistics, used for 2-pass encoding */ int mv_bits; int header_bits; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index e365f2fd81..37eeb68f15 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -1407,15 +1407,15 @@ static int select_input_picture(MPVMainEncContext *m) for (i = 0; i < s->max_b_frames + 1; i++) { int pict_num = s->input_picture[0]->f->display_picture_number + i; - if (pict_num >= s->rc_context.num_entries) + if (pict_num >= m->rc_context.num_entries) break; if (!s->input_picture[i]) { - s->rc_context.entry[pict_num - 1].new_pict_type = AV_PICTURE_TYPE_P; + m->rc_context.entry[pict_num - 1].new_pict_type = AV_PICTURE_TYPE_P; break; } s->input_picture[i]->f->pict_type = - s->rc_context.entry[pict_num].new_pict_type; + m->rc_context.entry[pict_num].new_pict_type; } } @@ -1745,14 +1745,14 @@ vbv_retry: ff_mjpeg_encode_picture_trailer(&s->pb, s->header_bits); if (avctx->rc_buffer_size) { - RateControlContext *rcc = &s->rc_context; + RateControlContext *rcc = &m->rc_context; int max_size = FFMAX(rcc->buffer_index * avctx->rc_max_available_vbv_use, rcc->buffer_index - 500); int hq = (avctx->mb_decision == FF_MB_DECISION_RD || avctx->trellis); int min_step = hq ? 1 : (1<<(FF_LAMBDA_SHIFT + 7))/139; if (put_bits_count(&s->pb) > max_size && s->lambda < s->lmax) { - s->next_lambda = FFMAX(s->lambda + min_step, s->lambda * + m->next_lambda = FFMAX(s->lambda + min_step, s->lambda * (s->qscale + 1) / s->qscale); if (s->adaptive_quant) { int i; @@ -1803,10 +1803,10 @@ vbv_retry: s->misc_bits + s->i_tex_bits + s->p_tex_bits); flush_put_bits(&s->pb); - s->frame_bits = put_bits_count(&s->pb); + m->frame_bits = put_bits_count(&s->pb); - stuffing_count = ff_vbv_update(m, s->frame_bits); - s->stuffing_bits = 8*stuffing_count; + stuffing_count = ff_vbv_update(m, m->frame_bits); + m->stuffing_bits = 8 * stuffing_count; if (stuffing_count) { if (put_bytes_left(&s->pb, 0) < stuffing_count + 50) { av_log(avctx, AV_LOG_ERROR, "stuffing too large\n"); @@ -1830,10 +1830,10 @@ vbv_retry: break; default: av_log(avctx, AV_LOG_ERROR, "vbv buffer overflow\n"); - s->stuffing_bits = 0; + m->stuffing_bits = 0; } flush_put_bits(&s->pb); - s->frame_bits = put_bits_count(&s->pb); + m->frame_bits = put_bits_count(&s->pb); } /* update MPEG-1/2 vbv_delay for CBR */ @@ -1848,9 +1848,9 @@ vbv_retry: int vbv_delay, min_delay; double inbits = avctx->rc_max_rate * av_q2d(avctx->time_base); - int minbits = s->frame_bits - 8 * + int minbits = m->frame_bits - 8 * (s->vbv_delay_pos - 1); - double bits = s->rc_context.buffer_index + minbits - inbits; + double bits = m->rc_context.buffer_index + minbits - inbits; uint8_t *const vbv_delay_ptr = s->pb.buf + s->vbv_delay_pos; if (bits < 0) @@ -1885,7 +1885,7 @@ vbv_retry: return ret; } } - s->total_bits += s->frame_bits; + m->total_bits += m->frame_bits; pkt->pts = s->current_picture.f->pts; if (!s->low_delay && s->pict_type != AV_PICTURE_TYPE_B) { @@ -1901,7 +1901,7 @@ vbv_retry: if (s->mb_info) av_packet_shrink_side_data(pkt, AV_PKT_DATA_H263_MB_INFO, s->mb_info_size); } else { - s->frame_bits = 0; + m->frame_bits = 0; } /* release non-reference frames */ @@ -1910,9 +1910,9 @@ vbv_retry: ff_mpeg_unref_picture(avctx, &s->picture[i]); } - av_assert1((s->frame_bits & 7) == 0); + av_assert1((m->frame_bits & 7) == 0); - pkt->size = s->frame_bits / 8; + pkt->size = m->frame_bits / 8; *got_packet = !!pkt->size; return 0; } @@ -3447,10 +3447,10 @@ static void merge_context_after_encode(MPVEncContext *dst, MPVEncContext *src) static int estimate_qp(MPVMainEncContext *m, int dry_run) { MPVEncContext *const s = &m->common; - if (s->next_lambda){ + if (m->next_lambda) { s->current_picture_ptr->f->quality = - s->current_picture.f->quality = s->next_lambda; - if(!dry_run) s->next_lambda= 0; + s->current_picture.f->quality = m->next_lambda; + if (!dry_run) m->next_lambda= 0; } else if (!s->fixed_qscale) { int quality = ff_rate_estimate_qscale(m, dry_run); s->current_picture_ptr->f->quality = diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index 7b58ace64b..b03b785769 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -31,6 +31,7 @@ #include "libavutil/opt.h" #include "internal.h" #include "mpegvideo.h" +#include "ratecontrol.h" #define MPVENC_MAX_B_FRAMES 16 @@ -38,6 +39,13 @@ typedef MPVContext MPVEncContext; typedef struct MPVMainEncContext { MPVMainContext common; + /* bit rate control */ + int64_t total_bits; + int frame_bits; ///< bits used for the current frame + int stuffing_bits; ///< bits used for stuffing + int next_lambda; ///< next lambda used for retrying to encode a frame + RateControlContext rc_context; ///< contains stuff only accessed in ratecontrol.c + /* temporary frames used by b_frame_strategy == 2 */ AVFrame *tmp_frames[MPVENC_MAX_B_FRAMES + 2]; int b_frame_strategy; diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c index 4c326741df..b0f319680b 100644 --- a/libavcodec/ratecontrol.c +++ b/libavcodec/ratecontrol.c @@ -81,7 +81,7 @@ static inline double bits2qp(RateControlEntry *rce, double bits) static double get_diff_limited_q(MPVMainEncContext *m, RateControlEntry *rce, double q) { MPVEncContext *const s = &m->common; - RateControlContext *rcc = &s->rc_context; + RateControlContext *rcc = &m->rc_context; AVCodecContext *a = s->avctx; const int pict_type = rce->new_pict_type; const double last_p_q = rcc->last_qscale_for[AV_PICTURE_TYPE_P]; @@ -150,7 +150,7 @@ static double modify_qscale(MPVMainEncContext *m, RateControlEntry *rce, double q, int frame_num) { MPVEncContext *const s = &m->common; - RateControlContext *rcc = &s->rc_context; + RateControlContext *rcc = &m->rc_context; const double buffer_size = s->avctx->rc_buffer_size; const double fps = get_fps(s->avctx); const double min_rate = s->avctx->rc_min_rate / fps; @@ -242,7 +242,7 @@ static double get_qscale(MPVMainEncContext *m, RateControlEntry *rce, double rate_factor, int frame_num) { MPVEncContext *const s = &m->common; - RateControlContext *rcc = &s->rc_context; + RateControlContext *rcc = &m->rc_context; AVCodecContext *a = s->avctx; const int pict_type = rce->new_pict_type; const double mb_num = s->mb_num; @@ -315,7 +315,7 @@ static double get_qscale(MPVMainEncContext *m, RateControlEntry *rce, static int init_pass2(MPVMainEncContext *m) { MPVEncContext *const s = &m->common; - RateControlContext *rcc = &s->rc_context; + RateControlContext *rcc = &m->rc_context; AVCodecContext *a = s->avctx; int i, toobig; double fps = get_fps(s->avctx); @@ -477,7 +477,7 @@ static int init_pass2(MPVMainEncContext *m) av_cold int ff_rate_control_init(MPVMainEncContext *m) { MPVEncContext *const s = &m->common; - RateControlContext *rcc = &s->rc_context; + RateControlContext *rcc = &m->rc_context; int i, res; static const char * const const_names[] = { "PI", @@ -677,8 +677,7 @@ av_cold int ff_rate_control_init(MPVMainEncContext *m) av_cold void ff_rate_control_uninit(MPVMainEncContext *m) { - MPVEncContext *const s = &m->common; - RateControlContext *rcc = &s->rc_context; + RateControlContext *rcc = &m->rc_context; emms_c(); av_expr_free(rcc->rc_eq_eval); @@ -688,7 +687,7 @@ av_cold void ff_rate_control_uninit(MPVMainEncContext *m) int ff_vbv_update(MPVMainEncContext *m, int frame_size) { MPVEncContext *const s = &m->common; - RateControlContext *rcc = &s->rc_context; + RateControlContext *rcc = &m->rc_context; const double fps = get_fps(s->avctx); const int buffer_size = s->avctx->rc_buffer_size; const double min_rate = s->avctx->rc_min_rate / fps; @@ -866,7 +865,7 @@ static void adaptive_quantization(MPVMainEncContext *m, double q) void ff_get_2pass_fcode(MPVMainEncContext *m) { MPVEncContext *const s = &m->common; - RateControlContext *rcc = &s->rc_context; + RateControlContext *rcc = &m->rc_context; RateControlEntry *rce = &rcc->entry[s->picture_number]; s->f_code = rce->f_code; @@ -886,7 +885,7 @@ float ff_rate_estimate_qscale(MPVMainEncContext *m, int dry_run) double fps; int picture_number = s->picture_number; int64_t wanted_bits; - RateControlContext *rcc = &s->rc_context; + RateControlContext *rcc = &m->rc_context; AVCodecContext *a = s->avctx; RateControlEntry local_rce, *rce; double bits; @@ -904,11 +903,11 @@ float ff_rate_estimate_qscale(MPVMainEncContext *m, int dry_run) const int64_t last_var = s->last_pict_type == AV_PICTURE_TYPE_I ? rcc->last_mb_var_sum : rcc->last_mc_mb_var_sum; - av_assert1(s->frame_bits >= s->stuffing_bits); + av_assert1(m->frame_bits >= m->stuffing_bits); update_predictor(&rcc->pred[s->last_pict_type], rcc->last_qscale, sqrt(last_var), - s->frame_bits - s->stuffing_bits); + m->frame_bits - m->stuffing_bits); } if (s->avctx->flags & AV_CODEC_FLAG_PASS2) { @@ -937,7 +936,7 @@ float ff_rate_estimate_qscale(MPVMainEncContext *m, int dry_run) wanted_bits = (uint64_t)(s->bit_rate * (double)dts_pic->f->pts / fps); } - diff = s->total_bits - wanted_bits; + diff = m->total_bits - wanted_bits; br_compensation = (a->bit_rate_tolerance - diff) / a->bit_rate_tolerance; if (br_compensation <= 0.0) br_compensation = 0.001; @@ -951,7 +950,7 @@ float ff_rate_estimate_qscale(MPVMainEncContext *m, int dry_run) q = rce->new_qscale / br_compensation; ff_dlog(s, "%f %f %f last:%d var:%"PRId64" type:%d//\n", q, rce->new_qscale, - br_compensation, s->frame_bits, var, pict_type); + br_compensation, m->frame_bits, var, pict_type); } else { rce->pict_type = rce->new_pict_type = pict_type; @@ -1014,8 +1013,8 @@ float ff_rate_estimate_qscale(MPVMainEncContext *m, int dry_run) "size:%d var:%"PRId64"/%"PRId64" br:%"PRId64" fps:%d\n", av_get_picture_type_char(pict_type), qmin, q, qmax, picture_number, - wanted_bits / 1000, s->total_bits / 1000, - br_compensation, short_term_q, s->frame_bits, + wanted_bits / 1000, m->total_bits / 1000, + br_compensation, short_term_q, m->frame_bits, pic->mb_var_sum, pic->mc_mb_var_sum, s->bit_rate / 1000, (int)fps); } diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index 028b6b91aa..ebed90c729 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -1597,7 +1597,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, mpv->picture_number= avctx->frame_number; if(avctx->flags&AV_CODEC_FLAG_PASS2){ - mpv->pict_type = pic->pict_type = mpv->rc_context.entry[avctx->frame_number].new_pict_type; + mpv->pict_type = pic->pict_type = s->m.rc_context.entry[avctx->frame_number].new_pict_type; s->keyframe = pic->pict_type == AV_PICTURE_TYPE_I; if(!(avctx->flags&AV_CODEC_FLAG_QSCALE)) { pic->quality = ff_rate_estimate_qscale(&s->m, 0); @@ -1847,12 +1847,12 @@ redo_frame: s->current_picture->coded_picture_number = avctx->frame_number; s->current_picture->pict_type = pic->pict_type; s->current_picture->quality = pic->quality; - mpv->frame_bits = 8*(s->c.bytestream - s->c.bytestream_start); - mpv->p_tex_bits = mpv->frame_bits - mpv->misc_bits - mpv->mv_bits; + s->m.frame_bits = 8*(s->c.bytestream - s->c.bytestream_start); + mpv->p_tex_bits = s->m.frame_bits - mpv->misc_bits - mpv->mv_bits; mpv->current_picture.f->display_picture_number = mpv->current_picture.f->coded_picture_number = avctx->frame_number; mpv->current_picture.f->quality = pic->quality; - mpv->total_bits += 8*(s->c.bytestream - s->c.bytestream_start); + s->m.total_bits += 8*(s->c.bytestream - s->c.bytestream_start); if(s->pass1_rc) if (ff_rate_estimate_qscale(&s->m, 0) < 0) return -1; 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 \ From patchwork Tue Feb 1 13:06:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34005 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp606448iov; Tue, 1 Feb 2022 05:14:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJyLZ5XhuWD8Cc1cgvTQL+zF7akcJKKWWEACkHLTXOhPCoietCKOb1KjVf6wfjAiYs6fkY2J X-Received: by 2002:a17:907:7215:: with SMTP id dr21mr20654433ejc.205.1643721274806; Tue, 01 Feb 2022 05:14:34 -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 q3si9241999edj.73.2022.02.01.05.14.34; Tue, 01 Feb 2022 05:14:34 -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=gsocVTY1; 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 8D2FF68B381; Tue, 1 Feb 2022 15:08:10 +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 79D7268B37E for ; Tue, 1 Feb 2022 15:08:06 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oPYNv1CGnBb1+Q/w6d1yz5GU4oW2TWKemZTSgt2EkmKFHcZlNnZrDEg/2bcYD0RDsPPCxFAxaLSoPUyOnrPtdQ9cad0qvy6TA4hX8Hn4TAWzeUmbEwV4y6ORFn2iTeLwn3+qClUAVlCvphqgHFdqUHLA3AnNW0gRbTjhZwMTqQ2erggeH8CsvVMs91Jz0/PJWL00sVhMkqICG/A9/d0+74jo37dD4xwkfUxiRN02wKMBw04pb9bmnQrAJPxHVIkxuzA7F37bcLaj7Yy6NMc+zO8+9+3pZ14EjAENkW3fexe+QBye+QEFqFs3vEm2zsf8OCMoyUZHLKZFWG2ejiT66A== 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=UbaRaPdK/OtpHTD4Z6s4c+wGsV7L6BqTcoxLrL2DMuM=; b=GNdmnZnEfyNUIxk854of4RmKd6mpr/q/Lc4BUBEOg5rslKZjG0bZjvT5nvZZmrq8SL4Ce/droSgUTr3pmeFfPbItFcoOh33MzOKYkbtrN05SNu2DKQ0Dq5FH9MrFV6TOAC8lotFfp6LZ0izZIDh2ZJ9jnOpMssxs2odUrvIUdFXCH3wpuF9FPY+wyBn95Byqbq/YJBH0YHn2CHedub8Z3CxoSyI+YAx5g1O5WKetD5Zo6SKgCep5Pzc5bDS0OqXFP2fYyvW+kMw/uqFtqRiA1Jl+YB2QXYTxC1hfVf+10SvKWpxKi9tHIkoQJH2u9j+/X1y9asTozJMyWiQ7IqFH8w== 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=UbaRaPdK/OtpHTD4Z6s4c+wGsV7L6BqTcoxLrL2DMuM=; b=gsocVTY1JDKX+h8zX3iwJ6Clq/fZQ7MC1zpj/pa3psnV0j0JK8G6WX/xJBA0JCfgwYMvf6Vl4+mn9MXYGF619SFdCopGLkeD1bOEXnfOFW4vb6hEy5HhnfARCsTdXffUOK9yfE8JOFzrekJoO9IA/XuJ8x+ypBXgYoYuaZXFKN2YlJJ4O3R3p/oNp3V94tUH5g5w/EmstiCpmhMeulnKPU8MnwgzrLxUv6FYb/R/bKXp1PiEStIrSCtfJl3aHlbsh6dSLc4sVXhHMXMZ2R0XIxEialP/fkMtRPj66SliPvr89OnMrWhVZWW25AYHOvoL6wYU53eXOB9hflmYxRz3hQ== 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:08:00 +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:08:00 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:29 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [Fc/EzpHsvDNbzindyNawFUsce+5alHfl] 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-31-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d331f442-4fd7-458e-2ddd-08d9e583dfa5 X-MS-TrafficTypeDiagnostic: AM9PR03MB6948:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 39dmBl8fkrGor0wZQzOdWyrgpsdDeBZ0rb2A/ZV8/mSR5I8Y3axQHRJBmV3nhOpmSOlllcJapCTbdJF1kLv2RibWBuE84bZmXivUcL/TRVlb+d8FHwGp/iUUu9PgVUqKVuJ3Dfyrb9CbeWA0+ctpZmh1uFvR4y0F/49nEyDZ7o7s1XF3gzBuCkk5w4ZBViTd+SHxJmVmaSW6INqnzcBWYTJUkIqZi2mxNp0a3O+NXWjq8VapXOwTmj0nN7K76zFviRsoMCEn9WKUjRG80VGhIAKQI1a3zqs4WcRO00Feqix0Q3j6N0Gknt44aoiSzMhGLmHaAZP72etGSoxheCvaeg1c8GYW60cZo82RVOfKPBPT4O8T5dvMBWdhoYW+H771ubqYhdsxeeh8767tPea8RPYIbsYjRC9u4OtzXw319IHuMCTngX7c7tc3+XbtkuvJ3L0AhGayV8UxcoT7Q0GsTUkk1tkKHtqfd/MImjWuXkues5KBF7LyQBKFz0qhhRoGCTXxee7IcGm+FNNvmwPm5pnX5vuqNPlr6Od8jVEyHq2wJa5V0fmFyETjmxKnZPWM X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CMEDh9Qhf65TB6N2lkBjen4KjQIVD2mZkw+mI2jm7Jz7dmR87zbbBZkh2FNFzYc9LbutONGffc18ErOHOsf2z+w9QyxeguZCPicQDmoOWlpEBRTwJS8G5nMVxIz5ro5kxBYbAHnkk0uIqw51xYYsHbOcJcYL/wmmqMRffHE+CYme35am1Xu8jgJRBWgYadesh6nfClcCHPMErvO+0kAeqAM6AiziEsEyO+EpKyrIWnkd1RSqH5XN3HZmceZmTZQFEdL45ZCM6FdwjODwmJc/AN8XB55gS+Mnr4O0RiI7WMviKqdbDeFu+hy1L9xZGLwMy7nSJEJefd2iq5e7/eYyW2VszZA/s759ZII3D2vSmJXO1RLrjBnaGo+A8nyzgVyNbgQtkZHGKFx7Zb8LKQeuFIld60ND6PE9Ot2WPTx7ndvnSev0cZo6H2QUzNUvx7XUpWvxWk+MZB4qismUh7SSbTPmEYXNMO3nmUCRJb8nD6w/ANp0A0oxK3tbiBwIOuPZLBGJhVUFGxNMLN5NrnCGo88nHd69Y+ac+Ya+LO/cJjxPsLM12j3V2KHt6oQDKQGojitulQlHeYFg+j5oQj9j2o0UFBPWu5YT6cWbAjindn/mfUVU4NaD+pAvZpDzarlf5onnz17I8Zft06Ce0J6KXtSXAyAzyf8aFNVq3b/d5w2XB6v4V4eA28IKvP7vvzsSE/gJG5UGBlHbL2nGaUNQRsHv2eI5YzhPcJBy6uqtDId++4RcpRQFl9mM6MWl1pqn9SI6T0N2PzJ4Ais3Prh8srl2hjDKfAiF0ror+JpRbVSATYmm2bTPzUPhnwMZ9Xo0F9OHAgAfoD0yDtxIsBt6SzRTK4kD7A3CqxtHD5GBuX4leapCCpOreSKzHsqUQ7XWLfb7IvfzcxRIPKg9LIEkFTDXFvgx6HrtqaqXL1ji/xZmrh3oznzeDkRSWlkQyooYq0iy0hYf0H/N+6NeaKlfAg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d331f442-4fd7-458e-2ddd-08d9e583dfa5 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:08:00.6350 (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 32/69] avcodec/mpegvideo: Move gop_size to MPVMainEncContext 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: fPVb6Chnqw6w Only used by the main encoding thread. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo.h | 1 - libavcodec/mpegvideo_enc.c | 14 +++++++------- libavcodec/mpegvideoenc.h | 2 ++ libavcodec/ratecontrol.c | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index c59d4848a8..50c0fa42c4 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -81,7 +81,6 @@ typedef struct MPVContext { void *private_ctx; /* the following parameters must be initialized before encoding */ int width, height;///< picture size. must be a multiple of 16 - int gop_size; int intra_only; ///< if true, only intra pictures are generated int64_t bit_rate; ///< wanted bit rate enum OutputFormat out_format; ///< output format diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index b67f706504..77825e5b82 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -352,7 +352,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) avctx->gop_size, 600); avctx->gop_size = 600; } - s->gop_size = avctx->gop_size; + m->gop_size = avctx->gop_size; s->avctx = avctx; if (avctx->max_b_frames > MPVENC_MAX_B_FRAMES) { av_log(avctx, AV_LOG_ERROR, "Too many B-frames requested, maximum " @@ -394,9 +394,9 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) } s->user_specified_pts = AV_NOPTS_VALUE; - if (s->gop_size <= 1) { + if (m->gop_size <= 1) { s->intra_only = 1; - s->gop_size = 12; + m->gop_size = 12; } else { s->intra_only = 0; } @@ -1382,7 +1382,7 @@ static int select_input_picture(MPVMainEncContext *m) /* set next picture type & ordering */ if (!s->reordered_input_picture[0] && s->input_picture[0]) { if (s->frame_skip_threshold || s->frame_skip_factor) { - if (s->picture_in_gop_number < s->gop_size && + if (s->picture_in_gop_number < m->gop_size && s->next_picture_ptr && skip_check(m, s->input_picture[0], s->next_picture_ptr)) { // FIXME check that the gop check above is +-1 correct @@ -1466,10 +1466,10 @@ static int select_input_picture(MPVMainEncContext *m) "warning, too many B-frames in a row\n"); } - if (s->picture_in_gop_number + b_frames >= s->gop_size) { + if (s->picture_in_gop_number + b_frames >= m->gop_size) { if ((s->mpv_flags & FF_MPV_FLAG_STRICT_GOP) && - s->gop_size > s->picture_in_gop_number) { - b_frames = s->gop_size - s->picture_in_gop_number - 1; + m->gop_size > s->picture_in_gop_number) { + b_frames = m->gop_size - s->picture_in_gop_number - 1; } else { if (s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP) b_frames = 0; diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index 06e14ad11f..09dabee223 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -42,6 +42,8 @@ typedef struct MPVMainEncContext { int me_penalty_compensation; int me_pre; ///< prepass for motion estimation + int gop_size; + /* bit rate control */ int64_t total_bits; int frame_bits; ///< bits used for the current frame diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c index b0f319680b..4e7bbe49a7 100644 --- a/libavcodec/ratecontrol.c +++ b/libavcodec/ratecontrol.c @@ -632,7 +632,7 @@ av_cold int ff_rate_control_init(MPVMainEncContext *m) double bits = s->rc_initial_cplx * (i / 10000.0 + 1.0) * s->mb_num; RateControlEntry rce; - if (i % ((s->gop_size + 3) / 4) == 0) + if (i % ((m->gop_size + 3) / 4) == 0) rce.pict_type = AV_PICTURE_TYPE_I; else if (i % (s->max_b_frames + 1)) rce.pict_type = AV_PICTURE_TYPE_B; From patchwork Tue Feb 1 13:06:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34006 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp606627iov; Tue, 1 Feb 2022 05:14:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJyd8Ky6e4R+xz34MlU/F33j6u9Dkeeupv6ZxIaWMV768rxtSkZ1Fu7gXVrRVlqvNyl0IMaX X-Received: by 2002:a05:6402:4415:: with SMTP id y21mr25035288eda.162.1643721290225; Tue, 01 Feb 2022 05:14:50 -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 hp33si12291275ejc.530.2022.02.01.05.14.49; Tue, 01 Feb 2022 05:14:50 -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=ddcAoXti; 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 7755768B392; Tue, 1 Feb 2022 15:08:11 +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-oln040092073061.outbound.protection.outlook.com [40.92.73.61]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ABDE668B381 for ; Tue, 1 Feb 2022 15:08:09 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U4o35EvweSdjorBg0p/1O1q+8/L4kcf7jGe6eGEHJHcFQlXt0dwSA9XSByzeFScSqAKQvoRlnOPNg8vf8j51QEOqoI2ryjOCxf0DcAlUCZPRPzpQgvzJrYUxC1DpCkqUx9TXZXxgpu2JO1PsdBtecnD43PBjir6xQpCBw22nRqA7BCRTR31RNpm6r5XkK0qMHuXO47DfTuJD0VoBNhCg3iqaD/a0gasPIn1mpkIvAA1cAvyx4H/hrgUSDbUZSWvC93yuyFGwuHJ7IOT7lC1nxFAOZdcizOV49kmNDGNRW5ufrMKCsAEZKPND/mQEoHCMXzX3oIxOa+IRp+erMu8KQg== 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=grt/PCKIOSCRAY2OotsVbTaSK80y+njZNnnhjFKOK9s=; b=R01ZdpCXbnP0l7HOVxEfpM7/1wDZ0GvWiqF458PGu+xbpbU6uA2fBQPSK2HDGKf/hYHTup2WGdl/DfwlafsAUq5J066dEpK0cWpDEV0y1PVRLOFtTH0sauXLXRmE6X8ggnY9xiKUV+lI2/4fwNKfU6kf/Qi9df4m35mf/7q/N7AlzWu1JvKvsyds+O9B2vjR178QeB81M0KDKeiB1h5adluMgwrKaNn4saMH5UcGKCqP2ay4J4yrdPGOnrl1E/n4X4vEm9v7C4hgvlNeXU4CzL7jf8eedB9LMmWjMNtbYpjUIg+OFY17OTvQE1pYU4OFdv98IYkvOaXXZ1wUHJBM0w== 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=grt/PCKIOSCRAY2OotsVbTaSK80y+njZNnnhjFKOK9s=; b=ddcAoXtim40/npMSrX2L5wnZIfo9vXtRpgmJJJy4kGvJSh0Iu/w8NFe16NAu0EVlv0TRyKdGrv1y+bQ1X5FzZLOVjCermiTVzll6SgXoiHvB4lTFaHFMC2I529XNHmI93BgbTYjAxscvvM/udd9rD+ZRV2iwVAr3LAwSBckEyI/iF4juSQBG92kGlm/cWGDHQpWvEnae2B4AjwH/tTTOGA054/E97Yip8QL7sT2OfBRTb/RZ9ff9p5dhbiYMx6Bf90tvjXI1GfTxE1ZzVUNpj/fMuAZhBnqBlwblaAxBfNf8nzWx3bU0AUJgVJ5VkkWa8KffAaptQmSrYEL2D8M/rw== 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:08:01 +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:08:01 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:30 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [zXWVkLWR6t8SR2q08FMXmtk8UT4JLZoS] 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-32-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a1730857-187f-4c86-69b0-08d9e583e053 X-MS-TrafficTypeDiagnostic: AM9PR03MB6948:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BwQPCIoAFeXu+d5PtKla0Xoev74iJdimTrD5AXJl34BBAY1fD/DMSh8tZU6fqeCkWLGgwt+gWAEARY7mj4V0vXKjLFihSKDubWEhS8pd1XmnD4GsI0RLk2NCCV+VJeODEuJTpnfapOaPJgxSD6GCmfBgCKUkphW22yCYiAE3Z21k3bbIskHJ8S31NFO21Cds3b2+RpeszGjmxNP5LXUNeL9ZOMXst98W5mQMjmCYNu2V2Mb3RkU2/EgDDC17yJOq8J0CVR6cmB05MWv1g3RnT0pgfAygFDA0QkTl2R7IbuJf3KG+9IFDHgAJeK4wzQpOyRRu+v1RjKLcT4S0MAAKQ+uEHK3VTiMCj1VTso41NimZlHpe8taJ+aCSg8R4ZZIFxJRdnOZjHxUMqP+KtD7RJnuiZqO60n2VH1UspIoK1ldGEmIcwChGsBM/AerRYqHmOL4ofDxoJrzIXyTlRmZAtQon72tJpZyqSs+ZQFzhOcE2dtKu/Sn+2YmbMcjtxx73zOheKu6aCWZfsNQbmg8qMGhRQed89qsnEdCErE1Wnh6EjUYqSu6UWTmsm+JJYxpZ X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FT8ARIvW/fcpnDSMChQw14+MjWmPyVAowdB2/f82pV7ZaY30F+aTqRBNsO4ZBqwjBtYs4EK0sTWCR1P/Rns0ngYwhvf1R1wp2x0GD66Z12lRAwI/+h+88AIqojUNdi2HORNbfm43Ouc9wFdnr2tZrx+D3yNAbpjXTbvGPVSHO75Cbuk3+8Uah3HWE8zKNrBVrQtT8AT3n6bOzDv+ew9HtwfXQNiLOHMR+gwJ7SpkGtf5rP/WpBiWxXdss/aauo74yqluKerpxY2f1D3XBpRiieYMrpvSXyoGytY1gCHiDIjABfCBDQ7h3ySLTZmh/0NAEhZAqsQAxapu6BtEIiqG5RUuTR8TtZrLG+iGWQCZIUb6wzoVeClxV7lIdVvatZyNTZny4+eLrVe+zOah34fSiGaej36FeTehS+P4XtQJ/Un4wEeoEbJnJMANF8BlZ6ptw8jkahUCmDiPbhKRZ+1i9JULszQiZy3bkH+ALRzfvES3na2GQKdRD+47pgDXBmaVdoGkPgGuqtD8pbI8dVjyeGuhUBNd7HOmiB/ImuFlO3kJOSBE+PmtqPVTILC7YX6lwDsE2M6P2KlhPj0wLICNB52Q3u6ZlPnVIbheVTFOdqrcq5/+6hh1zAH3Wla88WqI8krarEypCLM3pUD4myf0/KA9ZwqZigxFyaYll2hTOY965UucOC0WX+XXc/Ywlh7x6ondD7oxEOV6WgF7U0Yz1DV9YopDDdxrMz3sACgnjJjKPdW9EKKqhk/Y82Z5fqPRaGUfIMQGaH4MDeo+riZpfyyDdN7YPz+B/OHNq+SY4etcTFSEPFo8rEwRCKr7ZQSrZAqZfKUbbbx0zwvVWqhsNSUU51M5ZBke3qjC8eiBfxp9/yGlnDdrp+G0wuRf+JH5QYH6aAURE2BuGWvIJogIYnFtRvmjUSR/657qrliDrAa0be2uAjHacUZdyvKYUos0EP0wjjrz/crZkEwA6icnOA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a1730857-187f-4c86-69b0-08d9e583e053 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:08:01.8237 (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 33/69] avcodec/mpegvideo_enc: Don't set picture_in_gop_number for slice threads 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: nTwdC+TEnrRr They don't ever read this value. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo_enc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 77825e5b82..fd3f458fb7 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -262,7 +262,6 @@ static void update_duplicate_context_after_me(MPVEncContext *dst, COPY(qscale); COPY(lambda); COPY(lambda2); - COPY(picture_in_gop_number); COPY(frame_pred_frame_dct); // FIXME don't set in encode_header COPY(progressive_frame); // FIXME don't set in encode_header COPY(partitioned_frame); // FIXME don't set in encode_header From patchwork Tue Feb 1 13:06:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34008 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp607125iov; Tue, 1 Feb 2022 05:15:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJzIlI17uWfCyPd9eLiXL6g4yzOr3XXV/n2MDJ2nxBDeAmAHPS68Wdu3Ylc3LGDWdhqNNrcd X-Received: by 2002:a05:6402:1d49:: with SMTP id dz9mr25090284edb.238.1643721330269; Tue, 01 Feb 2022 05:15:30 -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 l9si9289750edq.371.2022.02.01.05.15.29; Tue, 01 Feb 2022 05:15:30 -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=DMYo0oKZ; 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 711F068B39B; Tue, 1 Feb 2022 15:08:40 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075035.outbound.protection.outlook.com [40.92.75.35]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 61CA368B317 for ; Tue, 1 Feb 2022 15:08:34 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WdQ25ui/m5lEgXIfxXGlSBXgLjhI7v51YBut53xjyWrZnBweKhd0t6oc7+pprimSMH5gMCvuiVmjmTdJuB0qpDqMGImGOo9RmB+gLZNpIBEg1A7F0ioivsFc+uHoRtxFW2Oykw6nUGf4OXszl+OCCOugDVDHWpZUr64ZKEdScDS0PztXmR64REvIs4pzKhJyjVLgRKXGbX12e6vFxAK+dcjyHKBDLEL1APg9U3CalArHiYcmmD4Z0fT2DzibUakmjpOAHqQKTrGDcnX7JgrbhF6xkEWnsITfjy3F8rueq4yjuMQtUhV+/2RzTDRXi1JQk8EHyB/HFPZLf8fWreM0WA== 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=/6gMQQRovV6JdZl1wgXniQ0MBAoSg2NpjeZpmR3WwSc=; b=VfzB2A3c74XlHO7pGmA+xt0yxYQaJbDJZLacH3cBowMmwQuWfJPyYWtys7BgTIvjzBfTShKaEDAeDN4a8FrcmOxLc7sS+IxVxxWh3V8pEzMCOH7R5qKM0URAWRZcMZnyoDgnCV1/718OeUjhmnYNCw1YnMKe3x5C3UxuY2Vr8x+v2W3XetcsnSvq4D7IT0JKGHKft+b1U+QH4pKzjQxpEmYpKzoXz32kHWKKq36bU+DfSE6SR9CEIL4KbZVMJ64NGlbbLnXNHiUFOUiqg1zGqs5P5dK4oh7EsaB2GIhsP8gaeoAvNaZ079DMb2rQ1prX4Enoa7ePniXZlhX7JZSm9Q== 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=/6gMQQRovV6JdZl1wgXniQ0MBAoSg2NpjeZpmR3WwSc=; b=DMYo0oKZEvVZQXr2NGET7W/r56TRHpkijHskwVrtMX05mlByZx3FnCfLwBDq6AEHwr7zJ1igqUsI7wZ5fCVuZP0hDMyKY+oXgbeewnROqgTinghu9xw6k0f/kDrO0+dC6edaSAGSmWPvLyn0ZbGh4L2+u3x7KZW1HLIY59Asz794oREtIzCYVZweTe8RFx8KI/KCZZyMvGuuTb6YFvOt8BdIu572lXOSTIrLgQGeVTU1JWKLadbx9mGurO6U9Zv2B7GfrKzFyOjfbLZlYp5G+//DC+3rAbj7PerIlZmXyIO+JusOjderQfhAwjKGTGk3CmUKm16DeCh/AsHUVfKDYw== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by HE1PR0301MB2330.eurprd03.prod.outlook.com (2603:10a6:3:73::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:08:33 +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:08:33 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:31 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [tocQ/tblljAYxCxGzhV4VZ3dgwsrQkCu] 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-33-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 714ce9c8-4e6d-4173-a68e-08d9e583e11b X-MS-TrafficTypeDiagnostic: HE1PR0301MB2330:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YMTrppuTj/ITSo4V/PwuL8ak1Jym1hHBnMEuwJaqLb7SE1l3YyzwiIWsZxuxj6bNEcfX2UmmIYesLEvXtctXAhRjMG5A1FTqigVUe2e/Mkh0arAfADjlHS9EcbAmn/RRZi6Smp5d9oeCe6gWXcnykuh066nC+Zms2rooOu9Tfau8qmhaztxlkYoh3/Pz8yqhw5o/D/lBCV7axmMHq9hHg6RNYke/pMhwcE1f+yFZq6o+lNy7Ykuzm+/8cCiscpvFXdhrmMXk36c/rIfn5FgVcGY9VS4WTghHTXzApnWrJV2kqBeDaqZmuS+ZpyKuhwH8mxaYD0/xh5dITBRwJS2XKRj+9KOUT4sg0DKTcU4GQ7vKfq+eWgWXhF8ewOgZAhTDCcVNccpJ797yHFhZ3xX/NwJ4ATUmsesQm2m7YvZQXhyJobmlrpY20xBpKYqGiRF19Y/T2LKm6fVE9uMiTGDaIEkCiYwlbEO+t1N8UANLCfKkJxUTe0O92CBn5eGGM0/QrlD7PBYUXGpos1prsikqL1I0yyn1LkjGtD1iP+905oHC3bXs7bYQbNt7rrGAt+2w X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 05RwZiiD8IlyIU0kXhuC+1H7yXuBcBSPW3ypDLB5MIc3M2V9+RaZWCr3TV9L6mthMHpvvcFPlpgGSUoHX+dx6NmzwxVOswuHxp4NCFQ5sipvQ1Bvp+M2YAQWOs/5QzDYgsOXI7/OaZfIrOuup9GCuyLVX3AqweXSJ1mtgJ2AK4bWSfj+Y9kbP1YjxmjrTFlHfElg+uRFedAsG/cgPLbWXYY4mPEm/mtC4wpHq+ZgFRGi4RlmJAwQw6fwreuyNkX9CHeyUb8Gm77quYUrTRkn9h49bvnsVIdVNaj9c9iK2nykvW6NR+CyFUOZVrV/lrF6oG3rPkEY5v7jFqwAJ9/sGNaS/KZxEGCHTt+njYqn1FNq9Q3g0ciWgfX+kRBOl3z0ng3lx4KNaBzXGme9ryrUYrzTW3xpH95TRGs3Qg5knxtw5AnalSp/18mvaqcanPdjNNiXcOStJdjdSVV/940moG4MaaPzIc9e4X1st4diZT6JBnu6/fMIJljhYGSRb/tTB+eiYpk0q00sLI4V8VmCAbm1UOJ0an/b1wfRVeZbhFTrAZ6/ZYBQzaGZfVCbS21SoUdLldc6WLRxvBnh1gxNFq9gSrZkHcp1QDaxP2zbZIPNPLzUPw0Xx10AUHJ1ZEyrhNs7dOPmHR5WyM6JKHMyjB+nwIqiUiIku59Ofz2aHqJGwyqaOA7nYnGUCvJo7kslqsfci50hkxWTOiZMLkW1fXaUfjctaIqdD+bBHnoUX7vid17ZydpbKSSE05GSwUavW/+8GMHRNgzZJZdAu4n/LtAWFcTFK9TVBlXqgMlUAe7FKnaEiT9Md3o6zPTezyfBQ2w7hVBnucDVc7CO0i52D/IcZactGx402xDgGFHg78oOu4DqNX40CBRHlOc0h7rEsTzMTbB7Hzt8rzCfZbmbzfT939yNQlJy0yf54aUzg9Edm9Q3tKyqZRnx/qGLAWomvExAfBGNQOXztJRlhw+HBg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 714ce9c8-4e6d-4173-a68e-08d9e583e11b 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:08:03.0891 (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: HE1PR0301MB2330 Subject: [FFmpeg-devel] [PATCH v2 34/69] avcodec/mpegvideo: Move picture_in_gop_number to MPVMainEncContext 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: WQLqcgyo+pdM Only ever used by the main encoding thread. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo.h | 1 - libavcodec/mpegvideo_enc.c | 14 +++++++------- libavcodec/mpegvideoenc.h | 1 + 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 50c0fa42c4..08c795ba17 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -107,7 +107,6 @@ typedef struct MPVContext { int input_picture_number; ///< used to set pic->display_picture_number, should not be used for/by anything else int coded_picture_number; ///< used to set pic->coded_picture_number, should not be used for/by anything else int picture_number; //FIXME remove, unclear definition - int picture_in_gop_number; ///< 0-> first pic in gop, ... int mb_width, mb_height; ///< number of MBs horizontally & vertically int mb_stride; ///< mb_width+1 used for some arrays to allow simple addressing of left & top MBs without sig11 int b8_stride; ///< 2*mb_width+1 used for some 8x8 block arrays to allow simple addressing diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index fd3f458fb7..86f2b5fcb1 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -292,7 +292,7 @@ static void mpv_encode_defaults(MPVMainEncContext *m) s->fcode_tab = default_fcode_tab; s->input_picture_number = 0; - s->picture_in_gop_number = 0; + m->picture_in_gop_number = 0; } av_cold int ff_dct_encode_init(MPVEncContext *s) @@ -1381,7 +1381,7 @@ static int select_input_picture(MPVMainEncContext *m) /* set next picture type & ordering */ if (!s->reordered_input_picture[0] && s->input_picture[0]) { if (s->frame_skip_threshold || s->frame_skip_factor) { - if (s->picture_in_gop_number < m->gop_size && + if (m->picture_in_gop_number < m->gop_size && s->next_picture_ptr && skip_check(m, s->input_picture[0], s->next_picture_ptr)) { // FIXME check that the gop check above is +-1 correct @@ -1465,10 +1465,10 @@ static int select_input_picture(MPVMainEncContext *m) "warning, too many B-frames in a row\n"); } - if (s->picture_in_gop_number + b_frames >= m->gop_size) { + if (m->picture_in_gop_number + b_frames >= m->gop_size) { if ((s->mpv_flags & FF_MPV_FLAG_STRICT_GOP) && - m->gop_size > s->picture_in_gop_number) { - b_frames = m->gop_size - s->picture_in_gop_number - 1; + m->gop_size > m->picture_in_gop_number) { + b_frames = m->gop_size - m->picture_in_gop_number - 1; } else { if (s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP) b_frames = 0; @@ -1689,7 +1689,7 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, s->vbv_ignore_qmax = 0; - s->picture_in_gop_number++; + m->picture_in_gop_number++; if (load_input_picture(m, pic_arg) < 0) return -1; @@ -3719,7 +3719,7 @@ static int encode_picture(MPVMainEncContext *m, int picture_number) s->current_picture.f->pict_type = s->pict_type; if (s->current_picture.f->key_frame) - s->picture_in_gop_number=0; + m->picture_in_gop_number=0; s->mb_x = s->mb_y = 0; s->last_bits= put_bits_count(&s->pb); diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index 09dabee223..a177b2d6c6 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -43,6 +43,7 @@ typedef struct MPVMainEncContext { int me_pre; ///< prepass for motion estimation int gop_size; + int picture_in_gop_number; ///< 0-> first pic in gop, ... /* bit rate control */ int64_t total_bits; From patchwork Tue Feb 1 13:06:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34025 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp611036iov; Tue, 1 Feb 2022 05:20:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxf6tQo5WUMDK/TLNLnCCcjjwM54xE4iccCXrLFd1qsoRD17e+GCT/PMUzFYO6FYoq5IAcL X-Received: by 2002:a17:907:7203:: with SMTP id dr3mr20240691ejc.185.1643721647700; Tue, 01 Feb 2022 05:20:47 -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 f7si9216426ejj.794.2022.02.01.05.20.47; Tue, 01 Feb 2022 05:20:47 -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=jGGDDhmy; 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 63E9A68B42B; Tue, 1 Feb 2022 15:09:00 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-oln040092074018.outbound.protection.outlook.com [40.92.74.18]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 42CC068B3CE for ; Tue, 1 Feb 2022 15:08:37 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P/bc3RZxDfjj2Ul+kPuNWQjqdBSiAYp923MiMUZ+gjWOjwogL4weT77okDDWXoXWxp+uzsYkUhJri6v0Pra1TXH4wrH0qRJRPxClmcJBnZVmRGy3WZy0wQI9fBSbuqt/F3Ukk3JrDC0OzmkK6gOVDqt0XveiKroF9BF0mLGs3rsxPpEc2JbPV7Ye1MdNU/MTxooyAo9JolGmVIn70pvxxM5yzf3x986AHVHZ0xO4zbSdwBpDQspJEJV11iZzyXbQ5mrhSaxtBnxTztrRdJu/N4ioqPk71UM1mfQtcgwz8nAhqMIfzTO1V1D2E26cImHCRmqyVNmtOlBBKyJO7QXADg== 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=8RBDcRLZDeYxwr8s8k2rBsf9w/l/ZUOxoYyKpS6QGTw=; b=Hkll809azTvwG6TGzi5v+1QyYb40Wp8Zr5dPI+773kJjrr8onMilqJYfnQcMnLr39y2zI281Gm4fa9I5903yta84SdK72G6xm8PqdEbXjq2ozyBPMOa8nT6wzS6JgNVRAqol2sKAewzIrX8iWZy3Zsqy1PjWsKdyorMEooWGAxKwNQCdqTQijqTSllpAvLI/yzhk6HnksL62Bu+FotyarOtMY2q00qBfxf9yD+2PZeSDw49nRzkmDAHqRERax3yJyPHyP2XaakZHoOGIEKwj/XYFWurBvn8YBg+dWMMPqdQ2ukNSXu5VanV6zjYNg/H+xRVSQyvjBxnrgXFMZEJqpA== 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=8RBDcRLZDeYxwr8s8k2rBsf9w/l/ZUOxoYyKpS6QGTw=; b=jGGDDhmy+okicMc/dgBsUuSzoV8+iiVZW9g4DoxRCGqg54kCeJnrxV0kF1A8MNXDT9Tk0s2p7xfXgMZ6fsdnkXG2HKbitZ+nZMNV//Ky3kIAOrn3UzpKSU6T5nyJVrSud5Q7XXTV51cuBMJnXIbbonp276R/EjRmJl0yT89i7BytzdUwZKb+0m+M77s2g4I2B4nZOM5NKeytIvXjFVYvh+zKQw5rQIopczm2qAmJwcrWWFT4mBwxUnTN5mdUyxtXLCm8E9DG2A8liLDsb+BHJni2Gn/FgZ6bjRbkRfJNVGhNwl9/W4kPo/YWa2CjTIimeQUGj9E64zZdczf1AdBupA== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by HE1PR0301MB2330.eurprd03.prod.outlook.com (2603:10a6:3:73::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:08:33 +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:08:33 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:32 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [INqR+Xfcm2cnOTBqqPMiZW5uGIBYEWHo] 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-34-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: af118a8d-b669-4e6c-a2cf-08d9e583e1ce X-MS-TrafficTypeDiagnostic: HE1PR0301MB2330:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Yjq6IDouTrVkbqZ+v2Tt9JmP9t+YhdMkHKrUgaZLt0xy8dd0rFux+M3agfVJW2bp2ObhcAz09AB4BFphNA90yUi6TiThqFR+0mAKeD92iCBp8vGetbcY/S/TLEiHcPEEyT4Z19WRO/FsnCc4FBGOKkgshBlnMLZZDar/ILZKn2+v0ZZdYnlrM1i2NXy4ODNImsqCzf6TFSVDGbC5jLPdCvO2OCQ2wRFmQRqz4C1kGZ/YilYEu9ntFaXfakAbyA4HM6BGBTdAvKMuzU04MUxzLQ83NFbeq3bUW0UPjbRhHOw6ZEIsPquVkVDon8QEteqENj6TCRE8EYMcX9Y7SK6WPrwdb/evD7lrjRzI6CVX1qi8Ivj3WLXoiHd0v70YeQfgYXlZoodcMkSZ2P1rpX02oUcqKDzerW/9dB1IZMBcUPeS9/bTQLGiNSoFfEkU9exBQlUNbZDWFmC9ksz61CoLKN8SKzkUPUOVG1rIIp6fnyMI9WWapXUP2zKLM3j9Du3uosqOBLX8doOOIiIbI9lzi3Pg/9DYbzw9f3A7w+jOBcUpLj58O+MS1HxCm96kmODn X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lYDa8rBFWjJQFWvVgqD8uhZI+QyIWp94nd6V7qg7bpusU6q5nVeAKv5Kz5PNlbV+LJeLrFQJNXUJJBNx50wnQXRYcgmL5o3vAX5rQcCkqsL1dvx89gQKNsS/DRTKddMeSVx3HJ+GdUbTx4NrY7g5+EB6+zkrsBdLyP4FqolEVSJ1osC3U23jJwTJWrClJCQ1mvvLy7ao5OpX/bqD5GMf/EjRtmHdMJK4U4HpfUASYwXn0OTOddqkEv8m5FS/RACODRWJdRdNOvo0jYHDwUybITUsWOJtSA8wb0idhQJJTKUukvb0MaNNhtkxHt1ssP/5VvJuuv6+yuao6MhrGNhftKlPjsLJngL41qrxpPA5Hnzf2hRORChMu+71msYKqWA+keiR0uaWp3YCKRNYxS+k67JxgaTIHzCfpANNojNbhllL02awGZcs6i/uXIZEFLbYPRXFJmxLCpix8vHfF5pK5A0dqCOP8hUs8P1W0Vr+IJWfJC0Byqbu60w+xZsC1WYvJp2jJpzqeNzmmr+PcXn6x/6XKlQlwbBy45rfofci+YrvoWpzMbQ6Kw0m5cLUot3PFQxXt12bVJ0dFS7nN2iNayCN+eiGfYvgiGtSqoRddUgRGoFCGnXb2yAIjmRjZJmW9Smh/PAnfGxXccGAbZm2C6zbbQySGhOdKedWrlszV/KtY1VsvMW3b5Mk4ZKpxTiIRkDGR0UW/vmY25ZLf5nHl0OnlOzwCaEDU/3fUQGlQ/VJlRQ/ZJbtXiZqcJ+yZU4owTatQ5qqVYlt1rRFrJN+SH2+SDylxTvtpklwBKtTOt7yF6OcOtfY9r8RvTcEKjmuZ0aGR0AznRRDQ34Tc1jMKx1jjILfADbplOsbsN/eCPXykN0sd1wBfsNcXXu7bs/bEyHPpH99sObF2UG0WW5xemzG92IzdlJNx1BarfPu23tmZvDHW1s+svUPQRQ4lu7x7ie5FZgsyiID1gtZ4wHufA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: af118a8d-b669-4e6c-a2cf-08d9e583e1ce 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:08:04.2465 (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: HE1PR0301MB2330 Subject: [FFmpeg-devel] [PATCH v2 35/69] avcodec/mpegvideo: Move pts and dts fields to MPVMainEncContext 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: qavdqnR7xGm9 user_specified_pts, dts_delta and reordered_pts are only used by the main thread. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo.h | 10 ---------- libavcodec/mpegvideo_enc.c | 22 +++++++++++----------- libavcodec/mpegvideoenc.h | 11 +++++++++++ 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 08c795ba17..3dd04d6e82 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -118,16 +118,6 @@ typedef struct MPVContext { Picture **input_picture; ///< next pictures on display order for encoding Picture **reordered_input_picture; ///< pointer to the next pictures in coded order for encoding - int64_t user_specified_pts; ///< last non-zero pts from AVFrame which was passed into avcodec_send_frame() - /** - * pts difference between the first and second input frame, used for - * calculating dts of the first frame when there's a delay */ - int64_t dts_delta; - /** - * reordered pts to be used as dts for the next output frame when there's - * a delay */ - int64_t reordered_pts; - /** bit output */ PutBitContext pb; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 86f2b5fcb1..4f64fd28a7 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -391,7 +391,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) av_log(avctx, AV_LOG_ERROR, "intra dc precision too large\n"); return AVERROR(EINVAL); } - s->user_specified_pts = AV_NOPTS_VALUE; + m->user_specified_pts = AV_NOPTS_VALUE; if (m->gop_size <= 1) { s->intra_only = 1; @@ -1023,8 +1023,8 @@ static int load_input_picture(MPVMainEncContext *m, const AVFrame *pic_arg) display_picture_number = s->input_picture_number++; if (pts != AV_NOPTS_VALUE) { - if (s->user_specified_pts != AV_NOPTS_VALUE) { - int64_t last = s->user_specified_pts; + if (m->user_specified_pts != AV_NOPTS_VALUE) { + int64_t last = m->user_specified_pts; if (pts <= last) { av_log(s->avctx, AV_LOG_ERROR, @@ -1034,13 +1034,13 @@ static int load_input_picture(MPVMainEncContext *m, const AVFrame *pic_arg) } if (!s->low_delay && display_picture_number == 1) - s->dts_delta = pts - last; + m->dts_delta = pts - last; } - s->user_specified_pts = pts; + m->user_specified_pts = pts; } else { - if (s->user_specified_pts != AV_NOPTS_VALUE) { - s->user_specified_pts = - pts = s->user_specified_pts + 1; + if (m->user_specified_pts != AV_NOPTS_VALUE) { + m->user_specified_pts = + pts = m->user_specified_pts + 1; av_log(s->avctx, AV_LOG_INFO, "Warning: AVFrame.pts=? trying to guess (%"PRId64")\n", pts); @@ -1889,10 +1889,10 @@ vbv_retry: pkt->pts = s->current_picture.f->pts; if (!s->low_delay && s->pict_type != AV_PICTURE_TYPE_B) { if (!s->current_picture.f->coded_picture_number) - pkt->dts = pkt->pts - s->dts_delta; + pkt->dts = pkt->pts - m->dts_delta; else - pkt->dts = s->reordered_pts; - s->reordered_pts = pkt->pts; + pkt->dts = m->reordered_pts; + m->reordered_pts = pkt->pts; } else pkt->dts = pkt->pts; if (s->current_picture.f->key_frame) diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index a177b2d6c6..836fa2eaa3 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -45,6 +45,17 @@ typedef struct MPVMainEncContext { int gop_size; int picture_in_gop_number; ///< 0-> first pic in gop, ... + /** last non-zero pts from AVFrame which was passed into avcodec_send_frame() */ + int64_t user_specified_pts; + /** + * pts difference between the first and second input frame, used for + * calculating dts of the first frame when there's a delay */ + int64_t dts_delta; + /** + * reordered pts to be used as dts for the next output frame when there's + * a delay */ + int64_t reordered_pts; + /* bit rate control */ int64_t total_bits; int frame_bits; ///< bits used for the current frame From patchwork Tue Feb 1 13:06:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34009 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp607323iov; Tue, 1 Feb 2022 05:15:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJy8pyj6ChtzNPk8Ir7Q3BncnNPvtV4lLpemj7+ya2Jc6nvMgnqPqpU8X9MRrceG9IbJKB1p X-Received: by 2002:a17:907:6297:: with SMTP id nd23mr21798700ejc.56.1643721346383; Tue, 01 Feb 2022 05:15:46 -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 r4si9363799eda.284.2022.02.01.05.15.45; Tue, 01 Feb 2022 05:15:46 -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=CHYbwfJB; 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 7722568B3C4; Tue, 1 Feb 2022 15:08:41 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075035.outbound.protection.outlook.com [40.92.75.35]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 91BED68B317 for ; Tue, 1 Feb 2022 15:08:39 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V03IwuCM5UfRNyT+IOIAS81B9O7ZSQyKJEV8T9L3Nxap0OTk97CrXILXAJVUJQgIBhzx3j+zLgpYexXflRveA8AdHEltLFqu0beKPUlDltVIiVgjfEmvf6jWHAwPeATjStOC9jwy6Evauki4DlX+4k4J9sjzZymYPFrNSPk/y2/0SZ3rKmCyhcqD9xLlTcCzon78rcCrmkI5D9EpQck1btnw1+iHmlWRoeTfTuWRfHZpqTAg01tkTBc1+XIzmxBJ8e9h46WBIlKXMqr9p7l2ZmEjx7Y78FeXox603ATAm/hf2y7kBikvMRvo51pFdLqkPGMIeTYNsqWanjTl1Pr1wA== 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=RJktWIxy7xbtvNKcpNEFHxA2Eng93cl2KJTVP6cVcK8=; b=cUAUXYAEYvWFO1sqJMtTsMFUvum6qEQ8f24EJQ9jnBQBvbj/lhUQiv3guwvslbLynfCRuw74WWV/Tj+wj3NGxanKny4WxwVNLF1/Zt/h23XLM4pLtbDTA3eeC5mEIay9e+i0+/Q+eblOOcN6bPJaQvb+bJKJtCwhfZDJNrZdkWlKEH/F9wWk6TXOE8ldLWoGy3cv6rwY1Cz+GYlQewjk0h8tRDTuEvglcZEDSRMKYpOpPhlauE5lkhO5V+kd1zkJWOa+S1jlDxcgBPkcrZqePkHM3k5TyXyFz7w6sy6rDHtz4mf5+avXh3Fr/0LE8zzcWG/xIL7VSvCL1M/WcdlC2g== 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=RJktWIxy7xbtvNKcpNEFHxA2Eng93cl2KJTVP6cVcK8=; b=CHYbwfJB0ZaEyax1spiN2b+pA0ODT+l19+ILxxp2mqYUtnnBaobW8cAq4Rw2agQadn+uda2LOfWY57AU8zXVthGh7PNxVPozfj0HIJpS+p/StcSrMRUFAcU4tRMm1w9FkEitEiv8LJ+AnJjudLFyAcZI3t0rpWoaN6uhTWoPRs7PC2WNsoK3jAlsmWRNVGWHuq0Vn5daULZ7iEkFW+EdEPt90IxMeyeeXCz7ahKnRsdTxGmgY6hb2PfYO/yHFU5Qf/pQe2lAX+pRX8RuCRnMwLP3jRIQM4uU6b1EWuJdtJ5Fwg5x1Dt4se0oHxUKi0xF7dIH7+ht75riTEeST8Q51A== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by HE1PR0301MB2330.eurprd03.prod.outlook.com (2603:10a6:3:73::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:08:33 +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:08:33 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:33 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [pWOcaE+y3ml9U4zl3/n34SIs6pew5Bcj] 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-35-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5fcc9a26-c141-430a-591c-08d9e583e27a X-MS-TrafficTypeDiagnostic: HE1PR0301MB2330:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: br0rlAMvGhSytQT0Biurm+6xBxUHRvTVmPUC8ptIAUm9q8sbQ7Lu2FFK+pAfyhbFkhVrqNIV7V5mPqXmZjpWobGhyitFUe/ksxVKYsmAIuvwTamQXhGjAx9oGpsA+1+qIyQ/ZxKWskpc7eJFqfvy6Q9R8U1h4fBBxXLfOdyIQc/xl1MBLYuS/RFXjhyTVl/rEXbDDGDs4t3LrGOBMAezCgYO/cSsFMgam9Bw3oNcRsj+JMlhwDgw9vVTnKSc606K1IbTzd8XGDHX/Pydd5ISZLK7t3X0pn9oMJdbcy0LcqE3cdj3OFkJm5ljUjlmposlWWjGslYEbAuCyhGPOfc7CSVNDrpmbVKxzSm2FvUj53f4IrNF5mpp5CGY+QO68qMVgvA0hxzJflho6bi26VEfRWSmwRmUDVgeKVyW7Q79GRkuBA7li3whW9uROIDHJABO/W2V63MFXuU5u8wy7mMY/YKT/SM52Wmd6eYKhWnf3cR51cwA5qZXYA2Bwuk0XBTBbsmYOK1QbqWTcgHQHaMaRFpQjFzFB6jTudZRaAOcDrCZQ29uRASvqbVppIFo5Ob0 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: z+M/o1MxEH1lqXbnBUPUw5KFvZiXrN7QuIXbfkGIUsK1SDxNNa5bL1U1JMvTS+tTW4+XvY7c9eTgC/tIfrn216BNh/i/C5PgQZSqt/UOryxUD7V9FPjvcOOyMTk8N1H/Kf7cZRlNCuDEbjr1dObPd+Va9Sl68f2O5rhCDQRsvBZnZh7JiKoqKM++cUkPFDUh0qllPeeTFCdl1XduSta+hNvy2BpA1w4GcHbTKP6qd9ABm1Jh1kYjag4hXvagEgfWdk/jJw9gBf34rTQQOuzsMSpD1251Nbrok6krRDQwgSRMo1zHpX7c9w/vJBS/37Bo8qiS8wlH9L85uVAm512b/TCfvl7rsG214bhyRjAV6IcV/uIPlJp2HILl/fBedCUo5Yheyb+ZKYYWIB6cO4XmFCkE4GeCkIx9HZW4Aebz7cgtkq9H4vftX10zokmd8sg8ErWeYh6IBZjKsXG8cfShSwqcSLSR65DDiQhAh8ge7UhMq5aGKUTX9kO3ttLDKxgi4TIFy7TPnw4TvbVEZaZtQyzERUxfSEqYsnp26rybvQzYgaPhaDjGwQ59Fk2kbaO/tLz3BFLMjevkIijvycvvoyz47spPx2c66z4pBM41I6jLvvgtfgobiR5qd+8NFh9MCVUJF6CaHvHXO6VIMfoYwtkPxc0ZqxeGTITAxBWyi72EszI1DFJCXZwOdofQJE+0lk0FUnYONLElFcGOXxi5Lhq7BvmGuzaDNWnNU0ndbjWqHItkxQxAKoZIUqwbVMd5u35AsrsYhShxpp/W30LBuU/diZPMk8gPWvvY5z/qOR248CqWXUSnJmE/x9NKwLH2Xvc1QZHchradThA3aASpU5nNFFQ+pzbu0bOYeK9tm3oX3uRe4YIk+nNUFtgg1YD38HJsRF7YOyslIGQCU5QmuLHjYGHkpL0eqRbuV19Gt2ZNCWC8Vxvx3t2lfi+mea5zdlehZrbtFKZvQOlO0Nsrrg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5fcc9a26-c141-430a-591c-08d9e583e27a 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:08:05.4031 (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: HE1PR0301MB2330 Subject: [FFmpeg-devel] [PATCH v2 36/69] avcodec/mpegvideo: Move input_picture list to MPVMainEncContext 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: RJI4rnCqaNqv Also avoid an allocation while doing so. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo.h | 1 - libavcodec/mpegvideo_enc.c | 60 ++++++++++++++++++-------------------- libavcodec/mpegvideoenc.h | 2 ++ 3 files changed, 31 insertions(+), 32 deletions(-) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 3dd04d6e82..06bb704dc2 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -115,7 +115,6 @@ typedef struct MPVContext { ptrdiff_t linesize; ///< line size, in bytes, may be different from width ptrdiff_t uvlinesize; ///< line size, for chroma in bytes, may be different from width Picture *picture; ///< main picture buffer - Picture **input_picture; ///< next pictures on display order for encoding Picture **reordered_input_picture; ///< pointer to the next pictures in coded order for encoding /** bit output */ diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 4f64fd28a7..7bce5c54ca 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -827,7 +827,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) !FF_ALLOCZ_TYPED_ARRAY(s->q_intra_matrix16, 32) || !FF_ALLOCZ_TYPED_ARRAY(s->q_chroma_intra_matrix16, 32) || !FF_ALLOCZ_TYPED_ARRAY(s->q_inter_matrix16, 32) || - !FF_ALLOCZ_TYPED_ARRAY(s->input_picture, MAX_PICTURE_COUNT) || !FF_ALLOCZ_TYPED_ARRAY(s->reordered_input_picture, MAX_PICTURE_COUNT)) return AVERROR(ENOMEM); @@ -954,7 +953,6 @@ av_cold int ff_mpv_encode_end(AVCodecContext *avctx) av_freep(&s->q_inter_matrix); av_freep(&s->q_intra_matrix16); av_freep(&s->q_inter_matrix16); - av_freep(&s->input_picture); av_freep(&s->reordered_input_picture); av_freep(&s->dct_offset); @@ -1139,9 +1137,9 @@ static int load_input_picture(MPVMainEncContext *m, const AVFrame *pic_arg) pic->f->pts = pts; // we set this here to avoid modifying pic_arg } else { /* Flushing: When we have not received enough input frames, - * ensure s->input_picture[0] contains the first picture */ + * ensure m->input_picture[0] contains the first picture */ for (flush_offset = 0; flush_offset < encoding_delay + 1; flush_offset++) - if (s->input_picture[flush_offset]) + if (m->input_picture[flush_offset]) break; if (flush_offset <= 1) @@ -1152,9 +1150,9 @@ static int load_input_picture(MPVMainEncContext *m, const AVFrame *pic_arg) /* shift buffer entries */ for (i = flush_offset; i < MAX_PICTURE_COUNT /*s->encoding_delay + 1*/; i++) - s->input_picture[i - flush_offset] = s->input_picture[i]; + m->input_picture[i - flush_offset] = m->input_picture[i]; - s->input_picture[encoding_delay] = (Picture*) pic; + m->input_picture[encoding_delay] = (Picture*) pic; return 0; } @@ -1251,11 +1249,11 @@ static int estimate_best_b_count(MPVMainEncContext *m) FF_LAMBDA_SHIFT; for (i = 0; i < s->max_b_frames + 2; i++) { - Picture pre_input, *pre_input_ptr = i ? s->input_picture[i - 1] : + Picture pre_input, *pre_input_ptr = i ? m->input_picture[i - 1] : s->next_picture_ptr; uint8_t *data[4]; - if (pre_input_ptr && (!i || s->input_picture[i - 1])) { + if (pre_input_ptr && (!i || m->input_picture[i - 1])) { pre_input = *pre_input_ptr; memcpy(data, pre_input_ptr->f->data, sizeof(data)); @@ -1287,7 +1285,7 @@ static int estimate_best_b_count(MPVMainEncContext *m) AVCodecContext *c; int64_t rd = 0; - if (!s->input_picture[j]) + if (!m->input_picture[j]) break; c = avcodec_alloc_context3(NULL); @@ -1379,13 +1377,13 @@ static int select_input_picture(MPVMainEncContext *m) s->reordered_input_picture[MAX_PICTURE_COUNT - 1] = NULL; /* set next picture type & ordering */ - if (!s->reordered_input_picture[0] && s->input_picture[0]) { + if (!s->reordered_input_picture[0] && m->input_picture[0]) { if (s->frame_skip_threshold || s->frame_skip_factor) { if (m->picture_in_gop_number < m->gop_size && s->next_picture_ptr && - skip_check(m, s->input_picture[0], s->next_picture_ptr)) { + skip_check(m, m->input_picture[0], s->next_picture_ptr)) { // FIXME check that the gop check above is +-1 correct - av_frame_unref(s->input_picture[0]->f); + av_frame_unref(m->input_picture[0]->f); ff_vbv_update(m, 0); @@ -1395,7 +1393,7 @@ static int select_input_picture(MPVMainEncContext *m) if (/*s->picture_in_gop_number >= s->gop_size ||*/ !s->next_picture_ptr || s->intra_only) { - s->reordered_input_picture[0] = s->input_picture[0]; + s->reordered_input_picture[0] = m->input_picture[0]; s->reordered_input_picture[0]->f->pict_type = AV_PICTURE_TYPE_I; s->reordered_input_picture[0]->f->coded_picture_number = s->coded_picture_number++; @@ -1404,38 +1402,38 @@ static int select_input_picture(MPVMainEncContext *m) if (s->avctx->flags & AV_CODEC_FLAG_PASS2) { for (i = 0; i < s->max_b_frames + 1; i++) { - int pict_num = s->input_picture[0]->f->display_picture_number + i; + int pict_num = m->input_picture[0]->f->display_picture_number + i; if (pict_num >= m->rc_context.num_entries) break; - if (!s->input_picture[i]) { + if (!m->input_picture[i]) { m->rc_context.entry[pict_num - 1].new_pict_type = AV_PICTURE_TYPE_P; break; } - s->input_picture[i]->f->pict_type = + m->input_picture[i]->f->pict_type = m->rc_context.entry[pict_num].new_pict_type; } } if (m->b_frame_strategy == 0) { b_frames = s->max_b_frames; - while (b_frames && !s->input_picture[b_frames]) + while (b_frames && !m->input_picture[b_frames]) b_frames--; } else if (m->b_frame_strategy == 1) { for (i = 1; i < s->max_b_frames + 1; i++) { - if (s->input_picture[i] && - s->input_picture[i]->b_frame_score == 0) { - s->input_picture[i]->b_frame_score = + if (m->input_picture[i] && + m->input_picture[i]->b_frame_score == 0) { + m->input_picture[i]->b_frame_score = get_intra_count(s, - s->input_picture[i ]->f->data[0], - s->input_picture[i - 1]->f->data[0], + m->input_picture[i ]->f->data[0], + m->input_picture[i - 1]->f->data[0], s->linesize) + 1; } } for (i = 0; i < s->max_b_frames + 1; i++) { - if (!s->input_picture[i] || - s->input_picture[i]->b_frame_score - 1 > + if (!m->input_picture[i] || + m->input_picture[i]->b_frame_score - 1 > s->mb_num / m->b_sensitivity) break; } @@ -1444,7 +1442,7 @@ static int select_input_picture(MPVMainEncContext *m) /* reset scores */ for (i = 0; i < b_frames + 1; i++) { - s->input_picture[i]->b_frame_score = 0; + m->input_picture[i]->b_frame_score = 0; } } else if (m->b_frame_strategy == 2) { b_frames = estimate_best_b_count(m); @@ -1455,11 +1453,11 @@ static int select_input_picture(MPVMainEncContext *m) emms_c(); for (i = b_frames - 1; i >= 0; i--) { - int type = s->input_picture[i]->f->pict_type; + int type = m->input_picture[i]->f->pict_type; if (type && type != AV_PICTURE_TYPE_B) b_frames = i; } - if (s->input_picture[b_frames]->f->pict_type == AV_PICTURE_TYPE_B && + if (m->input_picture[b_frames]->f->pict_type == AV_PICTURE_TYPE_B && b_frames == s->max_b_frames) { av_log(s->avctx, AV_LOG_ERROR, "warning, too many B-frames in a row\n"); @@ -1472,21 +1470,21 @@ static int select_input_picture(MPVMainEncContext *m) } else { if (s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP) b_frames = 0; - s->input_picture[b_frames]->f->pict_type = AV_PICTURE_TYPE_I; + m->input_picture[b_frames]->f->pict_type = AV_PICTURE_TYPE_I; } } if ((s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP) && b_frames && - s->input_picture[b_frames]->f->pict_type == AV_PICTURE_TYPE_I) + m->input_picture[b_frames]->f->pict_type == AV_PICTURE_TYPE_I) b_frames--; - s->reordered_input_picture[0] = s->input_picture[b_frames]; + s->reordered_input_picture[0] = m->input_picture[b_frames]; if (s->reordered_input_picture[0]->f->pict_type != AV_PICTURE_TYPE_I) s->reordered_input_picture[0]->f->pict_type = AV_PICTURE_TYPE_P; s->reordered_input_picture[0]->f->coded_picture_number = s->coded_picture_number++; for (i = 0; i < b_frames; i++) { - s->reordered_input_picture[i + 1] = s->input_picture[i]; + s->reordered_input_picture[i + 1] = m->input_picture[i]; s->reordered_input_picture[i + 1]->f->pict_type = AV_PICTURE_TYPE_B; s->reordered_input_picture[i + 1]->f->coded_picture_number = diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index 836fa2eaa3..d66462b19a 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -39,6 +39,8 @@ typedef MPVContext MPVEncContext; typedef struct MPVMainEncContext { MPVMainContext common; + Picture *input_picture[MAX_PICTURE_COUNT]; ///< next pictures in display order + int me_penalty_compensation; int me_pre; ///< prepass for motion estimation From patchwork Tue Feb 1 13:06:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34010 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp607519iov; Tue, 1 Feb 2022 05:16:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJwKbtk80og2ClpE3jxrz/NDgNHZcezARRpBVTk/qhme7TrMaKgSsFqf6/9kw95qAOwmkbeb X-Received: by 2002:a05:6402:754:: with SMTP id p20mr25032062edy.291.1643721360562; Tue, 01 Feb 2022 05:16:00 -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 13si8882251ejr.618.2022.02.01.05.15.59; Tue, 01 Feb 2022 05:16:00 -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=HHPVZxv1; 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 6011F68B3CF; Tue, 1 Feb 2022 15:08:42 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075035.outbound.protection.outlook.com [40.92.75.35]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B5E2468B353 for ; Tue, 1 Feb 2022 15:08:39 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ev6I5q6zkVDTn0STyCeu88lQXFT5kHxM5D3dtx0PpZMiwHSbn0/aynntsTjwzO78/DSCMY9DTgBuCFlp1hqUhB2QtXgSrVUJIVglJGWzRkZY/z6o2p9LDq+3vvCmNbFpAlNxu+s8nnxzkcDdG0kVMrVMPjf/xhO6SSx2n1VmFSspEkfizQPtPON8sOWS6G9LU2cFRTtLLSHVdd8GcThMReTtpeGLiomUc3vkfP2gKG9xZc+cWUjphjKICG3MCbxCEdHqti0EfGoh6zH3WCj91NRgFAeG8h19rUnqsVpRSRnyR9a2I6XbLuRSJ3rTCntII/RR2S1SNHJ6+56GocqzCQ== 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=a6A9IqX1LhCsHysY0aMLumbuczHQZRPmz8B9EbdQJDE=; b=cVwrlWxoEwWjvjLES1CXSZgkYgyaFbjWN0bbskP80XoG5cQnJfCPGkkqInb+bV6RGTkQhfs3pn3nT/4iaocAVgozaLRQPk/L+zXY7pJyV3L2roehJyleTVXw798/0Rw6zhOpbLWAhhM1HZ94CtU8vaZ3Ej0gDToKPvxHC4+NJIMuQ0CM/tkFHnC0lb+Wd20iryL7bDbMffIzQLVFKHjzvt4TvLzDBeI2ET30xmtfD1Sn2TfLpV/Gkjz5HOPstz4wYK6pLyEBsZFCpSI1TRv/cmwLfMhmPho7sVzDbqe2/iaQBn0yysQ4VMZCrivy87FJ1ri1ezshpslonwmsplct3Q== 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=a6A9IqX1LhCsHysY0aMLumbuczHQZRPmz8B9EbdQJDE=; b=HHPVZxv1AL7x8j4+jJGQsxIxc7DHZ4NqdxmrVLoOJLPgmBHjK8EOGqRaRtuTOBtSJFfiqXr7NxuGJyDvMiy1uKZCvILxWIgQxdg02KuYcgK42i4yWEVLt1ayqtJKqmrRnwVfyY5mPFseolhpyubp48WT+RHGujSHIOCtwGKlHiWZD80OJJ1USTfdvLhX3zGV9cVFqqkZQ581GSTqesfTpfRpAhiAWhM21BawCmidQhGgDiWraFcuJxA2srF9G4n4zwqOt+7KOosfg6AnBXFqIJNfldRAAE/C3mcxT1PTZGuA2e64TsjMi6ILqr1dwZKjAyO84Pu+74G6GgHGjR7mVA== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by HE1PR0301MB2330.eurprd03.prod.outlook.com (2603:10a6:3:73::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:08:34 +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:08:34 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:34 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [k5CwntXExK43su9U/6mxj1Rj9JbbhI3M] 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-36-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e5fe88fb-39ec-4d88-bea3-08d9e583e310 X-MS-TrafficTypeDiagnostic: HE1PR0301MB2330:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oufkSKkjpTPmckM+yNfEPby4tvjuCcedIrAO2McEsRrYbkdYaWtDYqheeJf35TqoqE+YR7agpW5TYmpAcNjf+T2xDB2hUmON6ec9UP228cGEq5sJlcK4vXP+otaI4LeFdbVIc/aEYTgyH/rnw9IwH5xQk3kP6s/O2b/2zqupGqKo1TbbLlthKByuYnJcQMx3G5liybUDCXM0E7FkwC7dcYm/whE11iq7LPUuUbowTe1Q9Pd3bMlI8keBXyl1glVI53+WfrP8bUcn+JFH9nURLZOpvMKrVp0u8HyscjHCIY2bclGetpMsvePTbc5h0/TCQacAb9xdQR3cFBgiwCQ7Y9BK7cwUgrnaoMby5xa0j2LabA1kbbuc4zvO8Q4jkwAqDeENsI6Tn003+8ZQBRlHAVpg7Vssn6I58YYUCn98xShD/8Qpzbjegy3lkBKD3dTnCGfOUuGhE5QQZWDSAjlQ59PwllDgh1zqQjwlsFdu4VCS4ZIuAJ2TO/LiiVbQ6r+Bbc7VreFWeIfvnIYGplX4h808n+0YaBOwR5jpm33kNIoKA/ZQDgm9z9QUAh4+yogw X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nDKXWldLhf+5bcHgaej+8dzL8THCSeFcznz1StmZIF4ZwJ2/L3xwdba+6/6XjotS2q1AN0hoKrTt/fXS8B8baTtl4IxEEIfEkqbo60iavxG263UAzsmpaUNF/sCLQ1nkKFM+h8IonsBqCIGUz0T+r9t5MhGewtRUlVqlAfKAUD700no2XisdeZ2OWtmrzVYn+bm7aaNF90Y73sEjv+tFL0xXrObDVpSzKfp53Cad1kSM8rCUqWeqS4OI2Qw+u82NH3O5cMnNTZ/mwKS4Vq0h7Bymo09AmGMH/HCFaz05Rd5l8AJBCK5FMRd5+anl2fdzoZXRMxtRwbOhsRi7RwuktZOjCsl3RUJVY6LvTku1yoWUC2/DgvwzzbPOMBv4aJDGpcjlTrGEqz7frrmY7W/TRV+xD+bDzDhQ/4uC+p7aavpndlYFgDZfIlijEAj6Fd0hK9m5qfOlmsXDd3qiC1hY71V9pW5sJcjJ7aixroL1o+vzoH+aVmr0WtthS5x66FuHK1xSRLJ2ISUnccracOG7TDpY++Oj2CeYdoCefJ3KStqkcStF03L6TTk/AxH0AmF6wYOjwI8TJDT2jDmUg/XcOLw9JaOuMs8EPRrQm5fQUE9k4V/KVKNxFFmhWfE0iW8ntrNafXCpHTqjudAegu5ug3vYa8UY08yxfrdTmfup6z8idLQBRhMpdlmaWoY/p14iUIGxgEmK+KpBow/LdzTnv27q0yqnFivJAlIw2K4RdJZUuREyIY1psN4s0B9saOiMl8STW4LYcohFllL9SwQI+tyGNwLpvtttU2YkPWwC5gGMoF5xj2wfTBK+vyZyiCBsbGK4rTdHinLCHxwyu3XFVlz4iDatBn+nbu9smL5SZPR5EsQdmp4mEergl5m0GNbJ4wbiDyEb/Iycp40ySHdce0taeyQrUq/23SoXmKUpeX5+SmcWMKlYV7IfiqPiuzdUo4oQu6/YWFNy5dgTtOO0dA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e5fe88fb-39ec-4d88-bea3-08d9e583e310 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:08:06.3575 (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: HE1PR0301MB2330 Subject: [FFmpeg-devel] [PATCH v2 37/69] avcodec/mpegvideo: Remove write-only [fb]_code 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: mZD9mat99F4R Signed-off-by: Andreas Rheinhardt --- libavcodec/ituh263enc.c | 1 - libavcodec/mpeg12enc.c | 5 ----- libavcodec/mpeg4videoenc.c | 8 -------- libavcodec/mpegvideo.h | 2 -- libavcodec/mpegvideo_enc.c | 8 -------- 5 files changed, 24 deletions(-) diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c index 97173bfdc6..56f9f91d19 100644 --- a/libavcodec/ituh263enc.c +++ b/libavcodec/ituh263enc.c @@ -682,7 +682,6 @@ void ff_h263_encode_mb(MPVEncContext *s, if(interleaved_stats){ if (!s->mb_intra) { s->p_tex_bits+= get_bits_diff(s); - s->f_count++; }else{ s->i_tex_bits+= get_bits_diff(s); s->i_count++; diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index 4b878b2f90..a0cbd5d8de 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -942,7 +942,6 @@ static av_always_inline void mpeg1_encode_mb_internal(MPVEncContext *s, put_sbits(&s->pb, 2, cbp); } } - s->f_count++; } else { if (s->mv_type == MV_TYPE_16X16) { if (cbp) { // With coded bloc pattern @@ -973,7 +972,6 @@ static av_always_inline void mpeg1_encode_mb_internal(MPVEncContext *s, s->last_mv[0][1][0] = s->mv[0][0][0]; s->last_mv[0][0][1] = s->last_mv[0][1][1] = s->mv[0][0][1]; - s->f_count++; } if (s->mv_dir & MV_DIR_BACKWARD) { mpeg1_encode_motion(s, @@ -986,7 +984,6 @@ static av_always_inline void mpeg1_encode_mb_internal(MPVEncContext *s, s->last_mv[1][1][0] = s->mv[1][0][0]; s->last_mv[1][0][1] = s->last_mv[1][1][1] = s->mv[1][0][1]; - s->b_count++; } } else { av_assert2(s->mv_type == MV_TYPE_FIELD); @@ -1019,7 +1016,6 @@ static av_always_inline void mpeg1_encode_mb_internal(MPVEncContext *s, s->last_mv[0][i][0] = s->mv[0][i][0]; s->last_mv[0][i][1] = s->mv[0][i][1] * 2; } - s->f_count++; } if (s->mv_dir & MV_DIR_BACKWARD) { for (i = 0; i < 2; i++) { @@ -1033,7 +1029,6 @@ static av_always_inline void mpeg1_encode_mb_internal(MPVEncContext *s, s->last_mv[1][i][0] = s->mv[1][i][0]; s->last_mv[1][i][1] = s->mv[1][i][1] * 2; } - s->b_count++; } } s->mv_bits += get_bits_diff(s); diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index c7b0b3ec02..a8c94c9d28 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -565,8 +565,6 @@ void ff_mpeg4_encode_mb(MPVEncContext *s, int16_t block[6][64], if (!mb_type) { av_assert2(s->mv_dir & MV_DIRECT); ff_h263_encode_motion_vector(s, motion_x, motion_y, 1); - s->b_count++; - s->f_count++; } else { av_assert2(mb_type > 0 && mb_type < 4); if (s->mv_type != MV_TYPE_FIELD) { @@ -579,7 +577,6 @@ void ff_mpeg4_encode_mb(MPVEncContext *s, int16_t block[6][64], s->last_mv[0][1][0] = s->mv[0][0][0]; s->last_mv[0][0][1] = s->last_mv[0][1][1] = s->mv[0][0][1]; - s->f_count++; } if (s->mv_dir & MV_DIR_BACKWARD) { ff_h263_encode_motion_vector(s, @@ -590,7 +587,6 @@ void ff_mpeg4_encode_mb(MPVEncContext *s, int16_t block[6][64], s->last_mv[1][1][0] = s->mv[1][0][0]; s->last_mv[1][0][1] = s->last_mv[1][1][1] = s->mv[1][0][1]; - s->b_count++; } } else { if (s->mv_dir & MV_DIR_FORWARD) { @@ -610,7 +606,6 @@ void ff_mpeg4_encode_mb(MPVEncContext *s, int16_t block[6][64], s->last_mv[0][i][0] = s->mv[0][i][0]; s->last_mv[0][i][1] = s->mv[0][i][1] * 2; } - s->f_count++; } if (s->mv_dir & MV_DIR_BACKWARD) { for (i = 0; i < 2; i++) { @@ -621,7 +616,6 @@ void ff_mpeg4_encode_mb(MPVEncContext *s, int16_t block[6][64], s->last_mv[1][i][0] = s->mv[1][i][0]; s->last_mv[1][i][1] = s->mv[1][i][1] * 2; } - s->b_count++; } } } @@ -797,8 +791,6 @@ void ff_mpeg4_encode_mb(MPVEncContext *s, int16_t block[6][64], if (interleaved_stats) s->p_tex_bits += get_bits_diff(s); - - s->f_count++; } } else { int cbp; diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 06bb704dc2..757c514a6d 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -302,8 +302,6 @@ typedef struct MPVContext { int i_tex_bits; int p_tex_bits; int i_count; - int f_count; - int b_count; int skip_count; int misc_bits; ///< cbp, mb_type int last_bits; ///< temp var used for calculating the above vars diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 7bce5c54ca..c537ce8c19 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -2447,8 +2447,6 @@ static inline void copy_context_before_encode(MPVEncContext *d, d->i_tex_bits= s->i_tex_bits; d->p_tex_bits= s->p_tex_bits; d->i_count= s->i_count; - d->f_count= s->f_count; - d->b_count= s->b_count; d->skip_count= s->skip_count; d->misc_bits= s->misc_bits; d->last_bits= 0; @@ -2478,8 +2476,6 @@ static inline void copy_context_after_encode(MPVEncContext *d, d->i_tex_bits= s->i_tex_bits; d->p_tex_bits= s->p_tex_bits; d->i_count= s->i_count; - d->f_count= s->f_count; - d->b_count= s->b_count; d->skip_count= s->skip_count; d->misc_bits= s->misc_bits; @@ -2787,8 +2783,6 @@ static int encode_thread(AVCodecContext *c, void *arg){ s->i_tex_bits=0; s->p_tex_bits=0; s->i_count=0; - s->f_count=0; - s->b_count=0; s->skip_count=0; for(i=0; i<3; i++){ @@ -3420,8 +3414,6 @@ static void merge_context_after_encode(MPVEncContext *dst, MPVEncContext *src) MERGE(i_tex_bits); MERGE(p_tex_bits); MERGE(i_count); - MERGE(f_count); - MERGE(b_count); MERGE(skip_count); MERGE(misc_bits); MERGE(current_picture.encoding_error[0]); From patchwork Tue Feb 1 13:06: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: 34011 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp607679iov; Tue, 1 Feb 2022 05:16:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJyLA+s9u6xlie3q+OekiAd/ze5EBz5DmCjvLWumnyhTlVHhaMUuzPLweginI4ghL3h8ccC7 X-Received: by 2002:a17:907:1b0b:: with SMTP id mp11mr20647217ejc.382.1643721374502; Tue, 01 Feb 2022 05:16:14 -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 m2si9478909edf.567.2022.02.01.05.16.13; Tue, 01 Feb 2022 05:16:14 -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=o5ic4nFc; 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 5637568B3A9; Tue, 1 Feb 2022 15:08:43 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075035.outbound.protection.outlook.com [40.92.75.35]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D2E4D68B317 for ; Tue, 1 Feb 2022 15:08:39 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SryO4UENT+F2yXqb4iT+18gU7t7xeGuH/J0YOujUDMPcjGsP6mOWObHX7dephjRxqX5voiApadP1Seik2TP5Pi1yUUlEXROZEpCk00Bwbu7uhhfFLXYvgFs0azzalTLPqmAug/8e45lToVd15H1rP+4V3GbJ1rVy/yQ1OQ4oBOAPxhvbFJMYY7fpysmcte/xNCVqZG5xQHVL1gCScfHFjdYELJij8oAwKYpILtyF/rlBmSnP3TiWLBlTh6d7/Kt/ONJactMNXuVhyyZqmnqxZ3mJ1utaezwq+CYD0LnfgtR6w+3YeLdLi0o4llVa3UvgcmmU0ZpfU8NWFnkq/OEWzw== 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=wRUQPZLGLeTJPbj5bpDtS+8+2wCqjSnYNqFUMB+mA/8=; b=BVtV2pcXQ7E5+ndstF5x+WHbE1BzBlg492bmQHrkfoWPwuiHiV2c7JWgpsMqfWwQ2aYYr7yOrlSEJkEXky1lSwQNbQDc81ui0S6bY9vLZRLy1cLNrWNnjxJAU9mEuHin6xLxJddBY90+P8Sk8qKB24NuUpq2K5ijzrcwOKje9GqRWMNuDIRBhhVKTNuISSf4DF3i0DaYCUKMyM8oS0Aoo5mW07qQSawttLIAcfnntUr9CXzFvcRLvUfYAux3n15IPy0Qcw1ZEpIpLhqcmOYwfrZWNv5zXIFJiKQP1Ix5/vythRnFTvkhYFB5onE3YCgEWGfdJlSeaU3pS71JNGvpnw== 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=wRUQPZLGLeTJPbj5bpDtS+8+2wCqjSnYNqFUMB+mA/8=; b=o5ic4nFc8YetiGeoKgGpLimZuzG8dffBwfTY1BZgNcu/UwrJ68OjtyLyxhrOrEPjPby2JBiKHuLKIz4eJrNrNksoYvGbOWVFU8eDl7IaefbDdctOFjK1TMlCmWK5mkR3QUsHA78Kr5T0qxeMck6ZZp573Y/Il9Pxu0659WgKGC6rZwVbxso6L9W6Ulm8udjnZUEnNYMN7L0xMoZ17AKDXvZSTAQdqfbEuLVIE4EJEy0rUsSTl46E1cKyacW93OVOKEIEqQSMSMOcBAp6UEW9k/YUkM9JC5SIygUBvI/mpEOkDUNSIqkt55xozP22zLX81DdNz3fVhJ1an8RcJCPQ1A== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by HE1PR0301MB2330.eurprd03.prod.outlook.com (2603:10a6:3:73::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:08:35 +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:08:34 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:35 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [gzlWhGcKkgQrOLT00yUYn3jLy4Bwhfn6] 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-37-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 15a10ffd-876f-42f0-c78f-08d9e583e3b4 X-MS-TrafficTypeDiagnostic: HE1PR0301MB2330:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KfLEuDuob0KWuNFTtki5gtMsudTniEtg0/Ju5X/aev76NvoIC1y9jv52Sj1YSo/jrtcXEx+MZGYG51OZUMurHmH9SEA4LjWO8C46glf09iLVZKkidt2ihbPm5exH/siZ5Fc48lIFNcnjbUwx1gRgJec+OV0yhymNDxYDpJcm5AIiaCDyDGvYiBSCL0GsDu3Bnf/My9P2HdwCMAcpCMYsyIXKv0zbCNgxPjLiuzEFyRVVnueohoITQjjPl1kVAaoB0OSj6aPxhH+R1JhBKW+7kuhehKQFHV6/+sjT5na5fvCBEoil78AR2RCaR+FIBVQ0+51undgJM/Ja+0RAqvCYdIEazzWoU8NMMaEq7UpVg4rtZKUz/deL+tg3lHarhrM0g22AbJnCuvfBZldupLtGS+xk0FOTQr06QAWw9C9VZFcitMFRn/2gK+SBFoE1pS7vN7Os4ilGtRqBggofY0LgC6hqvsV9MZ/e/ky33aP8W/6LbPKYT0S9ELUsy3xjHsih7fZrxYLWmk6CmAgNMlEDCL6NguphOGqpw02k0lcsPUc= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bnrYT7NimAcvW3WWeBAD1ZxYBBDtEc0VNHLqEq0Zuf0v4p3S+QFPsCtgE8tfhyI2c0oCSTKUTEJ2Qzb0QWJ+GsNfca/ULRa+FdRYxyY2NqsyfB2ghP3f5jEBo/3YwQooAjgFsfK6xzUM2gqzYdjz9/Ew7NPFLxfB6Dgp8gsEB1LABn1vaIfcn2+0egxhGiJIBSYCzh4RpPzQREUTfgy/hawHKP9jiMUSkHyrrSFx4777b/xgPb3kwQio4tG3bZliq51z8uc6cNrzWSYxAUaN0lAWBLBiiaK4tNDsbn2TdXGDhsi3fOXAsY5T5tvcuB+d3M7VXs7OOSugRRO6LGgO/b5qzkxzTFEE3ZOnGAmhMZ/sL3JtmymBodOF3SIDl/loIHghJIefH0HJD15Tq0yD9pK/WRCtQSrvD9bfuMRjD4/+QS18DjkBiag8W6vy2N795zStNDGSJKcW2J6T446oylHB1yiE7oT8tIo1PttOTsIKV4nWwnj6kfpIUiPsQrDdkD+lT2Etk3lRHY79nQt3MWPOB45Y0EQt/c+HvJQRlp7uIUFJOtjnCtuq07XnarkVfECM5C0qMbf7SR5vXb9yOvC41u1wtdmsXPp8dH9ajHqx+/8AVOuKmnLTupSBP3mITOvr4b352fGB2rHAhqsXBZTJwYGx+c2zyZEGXcxLgW916ktfSWQNJj1I25Ms82iUp36fOcLMZjia+ox4Cp2O1jZOy/1HU+0NKBGX35ERHK//59l4cQxIt3TlJZ6WSkOckCjpAVRRDTcdMYFL8qLGiieJ7yeKihjDuIIPkNGTMZ40pbswKcHIkA8laIWT77b82nb7AdHQyTyIiS0OsXIH7N5cDC0n2HXtl+hCQiuzfLjulR2MVp5u6S6ZlaAffId74DAUYN5h27QLxtFHihpD9+5k37agQMfZfPEhHpsHplTNlfX4VPybiUOpreJfMLAS991ppFn5QoP5TJlj7hKLlg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 15a10ffd-876f-42f0-c78f-08d9e583e3b4 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:08:07.4480 (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: HE1PR0301MB2330 Subject: [FFmpeg-devel] [PATCH v2 38/69] avcodec/mpegvideo: Move last-pic information to MPVMainEncContext 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: rq1Whf/Y0EvO last_pict_type, last_non_b_pict_type and last_lambda_for are only used by the encoder's main thread. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo.h | 3 --- libavcodec/mpegvideo_enc.c | 16 ++++++++-------- libavcodec/mpegvideoenc.h | 4 ++++ libavcodec/msmpeg4enc.c | 5 +++-- libavcodec/ratecontrol.c | 4 ++-- libavcodec/snowenc.c | 2 +- 6 files changed, 18 insertions(+), 16 deletions(-) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 757c514a6d..14e5e241cc 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -180,10 +180,7 @@ typedef struct MPVContext { int dquant; ///< qscale difference to prev qscale int pict_type; ///< AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ... int vbv_delay; - int last_pict_type; //FIXME removes - int last_non_b_pict_type; ///< used for MPEG-4 gmc B-frames & ratecontrol int droppable; - int last_lambda_for[5]; ///< last lambda for a specific pict type int skipdct; ///< skip dct and code zero residual /* motion compensation */ diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index c537ce8c19..6d45885185 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -1240,9 +1240,9 @@ static int estimate_best_b_count(MPVMainEncContext *m) //emms_c(); //s->next_picture_ptr->quality; - p_lambda = s->last_lambda_for[AV_PICTURE_TYPE_P]; + p_lambda = m->last_lambda_for[AV_PICTURE_TYPE_P]; //p_lambda * FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset; - b_lambda = s->last_lambda_for[AV_PICTURE_TYPE_B]; + b_lambda = m->last_lambda_for[AV_PICTURE_TYPE_B]; if (!b_lambda) // FIXME we should do this somewhere else b_lambda = p_lambda; lambda2 = (b_lambda * b_lambda + (1 << FF_LAMBDA_SHIFT) / 2) >> @@ -1577,10 +1577,10 @@ static void frame_end(MPVMainEncContext *m) emms_c(); - s->last_pict_type = s->pict_type; - s->last_lambda_for [s->pict_type] = s->current_picture_ptr->f->quality; + m->last_pict_type = s->pict_type; + m->last_lambda_for [s->pict_type] = s->current_picture_ptr->f->quality; if (s->pict_type!= AV_PICTURE_TYPE_B) - s->last_non_b_pict_type = s->pict_type; + m->last_non_b_pict_type = s->pict_type; } static void update_noise_reduction(MPVMainEncContext *m) @@ -3527,9 +3527,9 @@ static int encode_picture(MPVMainEncContext *m, int picture_number) ff_get_2pass_fcode(m); } else if (!(s->avctx->flags & AV_CODEC_FLAG_QSCALE)) { if(s->pict_type==AV_PICTURE_TYPE_B) - s->lambda= s->last_lambda_for[s->pict_type]; + s->lambda = m->last_lambda_for[s->pict_type]; else - s->lambda= s->last_lambda_for[s->last_non_b_pict_type]; + s->lambda = m->last_lambda_for[m->last_non_b_pict_type]; update_qscale(s); } @@ -3555,7 +3555,7 @@ static int encode_picture(MPVMainEncContext *m, int picture_number) 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 ((m->me_pre && s->last_non_b_pict_type == AV_PICTURE_TYPE_I) || + if ((m->me_pre && m->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 d66462b19a..8eab164d7a 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -58,6 +58,10 @@ typedef struct MPVMainEncContext { * a delay */ int64_t reordered_pts; + int last_pict_type; //FIXME remove + int last_non_b_pict_type; ///< used for MPEG-4 gmc B-frames & ratecontrol + int last_lambda_for[5]; ///< last lambda for a specific pict type + /* bit rate control */ int64_t total_bits; int frame_bits; ///< bits used for the current frame diff --git a/libavcodec/msmpeg4enc.c b/libavcodec/msmpeg4enc.c index 7c1fa0a1e3..f8080a194c 100644 --- a/libavcodec/msmpeg4enc.c +++ b/libavcodec/msmpeg4enc.c @@ -151,7 +151,8 @@ av_cold void ff_msmpeg4_encode_init(MPVMainEncContext *m) static void find_best_tables(MSMPEG4EncContext *ms) { - MPVEncContext *const s = &ms->s.common; + MPVMainEncContext *const m = &ms->s; + MPVEncContext *const s = &m->common; int i; int best = 0, best_size = INT_MAX; int chroma_best = 0, best_chroma_size = INT_MAX; @@ -204,7 +205,7 @@ static void find_best_tables(MSMPEG4EncContext *ms) s->rl_table_index = best; s->rl_chroma_table_index= chroma_best; - if(s->pict_type != s->last_non_b_pict_type){ + if (s->pict_type != m->last_non_b_pict_type) { s->rl_table_index= 2; if(s->pict_type==AV_PICTURE_TYPE_I) s->rl_chroma_table_index= 1; diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c index 4e7bbe49a7..03466a1a43 100644 --- a/libavcodec/ratecontrol.c +++ b/libavcodec/ratecontrol.c @@ -901,10 +901,10 @@ float ff_rate_estimate_qscale(MPVMainEncContext *m, int dry_run) /* update predictors */ if (picture_number > 2 && !dry_run) { const int64_t last_var = - s->last_pict_type == AV_PICTURE_TYPE_I ? rcc->last_mb_var_sum + m->last_pict_type == AV_PICTURE_TYPE_I ? rcc->last_mb_var_sum : rcc->last_mc_mb_var_sum; av_assert1(m->frame_bits >= m->stuffing_bits); - update_predictor(&rcc->pred[s->last_pict_type], + update_predictor(&rcc->pred[m->last_pict_type], rcc->last_qscale, sqrt(last_var), m->frame_bits - m->stuffing_bits); diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index ebed90c729..6ff0491a77 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -1858,7 +1858,7 @@ redo_frame: return -1; if(avctx->flags&AV_CODEC_FLAG_PASS1) ff_write_pass1_stats(&s->m); - mpv->last_pict_type = mpv->pict_type; + s->m.last_pict_type = mpv->pict_type; emms_c(); From patchwork Tue Feb 1 13:06:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34012 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp607884iov; Tue, 1 Feb 2022 05:16:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJyMqdFAl8X8BTMAxQLYnjSI+Lb1Bgt3dH/5s3HpatVpk2GzNtMjuHgCCSgBySw4L3PkdtST X-Received: by 2002:a17:907:3d9f:: with SMTP id he31mr20557535ejc.605.1643721388480; Tue, 01 Feb 2022 05:16:28 -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 ho35si9889206ejc.428.2022.02.01.05.16.28; Tue, 01 Feb 2022 05:16:28 -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=rLei1onr; 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 5F4FE68B3A1; Tue, 1 Feb 2022 15:08:44 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075035.outbound.protection.outlook.com [40.92.75.35]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EF9AA68B353 for ; Tue, 1 Feb 2022 15:08:39 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ag0p5CB27SKsiEZcLSvNRjl2TcdBeso+fIET1QAqv1okzU+dXy/krZMUhztMQO5p+XzbZ2yUlAtVPtw8dU1jpbxPW7nSPGIHSgiYAVQA0oADPEKNawA30hy0e+kPdKcI8hfbhZAnb3Cb2TQPirVjfKvt5amHfdAXw0CgbaxqgqHOW11YIO8aC/WS3u1ztaiVpUwBaH2Bs4WwGixhMEkfE45vihpbMw92bkx0/Ny27ln4q2AEICz6c1xlvD4TM2fw5G8DmJ8WJUcRaGPs3aMIGmILTfxnjUc1SrYj7eQ74qgNFlCwVq0aZqPq04LTsivHv2W0TapQpMUqFTInrZkCmg== 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=oAboh8fWBBS9V9xVG5kIJy7+1lcgyt1c2oI408ryO30=; b=NvyMg9ffwSYxXc8OWXthP24d74OeYqYfSCsOWo1ZfPE5+Jt5B9NJDgVZll67Hmc10NwRKaHGqNmAur/7yjqtb7fXoLx2yRKAs4ZG574L1WXULCbwCQjYEDrXI4eVgNQ9S4HDFxRsCsnLdewJC42rY8eXWUMOY3dTda8kECIcHILm4KmjhAE9XfOJzTy3qFBjiVSJyg8Huf6MiQ4nuW2r5LyBj4NmqswvgploHecWkieLzUPhIhADdsXhaxWDHDuFwGPeZKWfRIq4T2W3+q79cQOzPjVltaRx7BzzALXs04+h6w9lXNuL+Zniqb3QJ40wqSIyXvr0iomN2EA+5FwzzA== 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=oAboh8fWBBS9V9xVG5kIJy7+1lcgyt1c2oI408ryO30=; b=rLei1onrhS6XTjmvHNB+eewcZwpXANMGfJuY37+jp+LXlFu45Vt1+XZdF9AvULh23RoXPgMNAEPpaEQGDI31/AcAq7x15ohUvRTrltsj2gF+InO31eJoRbNf2P7rdfrPcqyTtqSFEijEXu63QvLjdL6Oz3qDj7yHzNe8L12X/fO1nbc5rJmH+4qAbuRSDzJTmLEjKmN9AJLrsk+nvkjlxtp1q2M3CYir3rupO+DNy3MeYi0b82rIX3XTaZK8lsFVxg+Mu2vGyUchv+0RsU+zsXdIumzO21UHPRnDCo3uplYTEkZqGO+RbIosLQgpIG51KBDVPwRTeLf+HVL5yDgHjA== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by HE1PR0301MB2330.eurprd03.prod.outlook.com (2603:10a6:3:73::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:08:35 +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:08:35 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:36 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [CS+47fsF2MlK+AZwXXklo+o86mUHextq] 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-38-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8cb54f2c-b8ca-468d-0db4-08d9e583e457 X-MS-TrafficTypeDiagnostic: HE1PR0301MB2330:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2MrzzLuEFOp9/+IxCJHaGTVvuLebo41Z6ppv5UIfETB85nl+zrpebNCJRmFYebigA9/GG0Nk6MaTrKQwdNKEq4FZRNVxf+yLbqBaT4jQPewufBsVQbTevWClR676F5Hm5/NAI2SV490SkZQY951EOacUusxcydla5fkDXtwgPJ45prp+67zSuq0I9rZZT5T/zMo1KztjNr591J6mOz/xVs4TGLa24w1VsYsQiq5ITRu+Rcp0w+JUL1mmkzwEn/krqHF0EuIN4geHMP0/W8O3xpsDfj27aCFDt0E2UDD6T56tOpFwpy4fmtRsGUe7kgg65QStUSYuiMrU957lkO4NlssbPXIETpamMCEhj1zXHi1ZzgvA9pJVkRWKHBOP90ijtYSbMnkBYYFt96GpLPVDxZs+OJxG8lzRbA/gBDujBlBcm/nUCOBaxmJC770XpN4k3iRVQufATma48l7ddtHzmZzx+9B1CGSAUH/BJgw4POXS2xUvLQLBUBLc+6/fUwzj1bmTX3Wpl6MfhzS8ZWz3yQopIMEE49UWxRCI95GB7TcZDOL/59aCQr2fJ7/Ine3o X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7NLikE05BnXv3ReW4EqjSzlUB771SvxhPGbOtwd8M4PpnIlMHe/5WZCqDwUhqvjYOgeqFJzw7zCxFrkIVEWuHA0paB4AlJObo8rKXSEetYDO5fOi2aF8ztFWyR4XIgBvo8c8CmTXjEGhtO6E4g2j/QH8KlB1p/jsmXlxtw3fJuq/hoT0NiV24la9/CabqUJKfK6NTYmQLc/C2SniEmaFmqDuV3CURelyS4tziTuh+rys4A3dYic22WgTr0k7Si9ktiblgeKFMbmigu+bQ1Gcysk7TQbp44lR9n6W42Ei4hlbibNszOE3NPbg67tXGzOBFerWJ4hSvZj4cAUoILHsz+Et3iwXXWo0FeqBYtARinAiSbQks/qgDfRgvEuGhOzrQILNYrY5a1fTBRpEzRhzVKfeR5b+eNDuoHgsvDE0IDNBJ0uG/bvh305EnZsuPNDnk2xAp1cZ7HcLzGzIz+Xp6ZvcimjsOZnDU+MOh5snyWp0ddSHeqE3S2SN3GbCj7tWOtN5OaIniKSdx81PhmPRiYhlcKD297N8KDhVG5WoAF5bj39Ssxt1wbx69tOlsM1RQJnGoRtJtxnZq4l0FAUXxUSnvOa1Tc+msJ9MtvSWmu+UMF0JLhxorkuDFx/ztCkT6DVQe7VlTM7wwYKCdsqegN3Av8YvEW9Oz6aIruzOIm3Fl3JJ5hxzawwBNcZRGyrrBqlGwtvfmi074oKMsoIspjrnZXDcnq1fOsx4i5pSyxDk6/XmYEx0YMR593P6v/ldhKwCV/Fx/V0QVk/UYjxdenYrouHH94+RNNepvHQlvOeJQkssgFX3Rs1qgk6AnThf3cohs5bYipWgcp4Z+1OXWoR8OxMz1/dta4uDN9N6bw390thn2BaayUcaK47DoFS+KCB6wp2oRlNTpFUGCANce13zhQ/8cn26CJYyAJRyCm5dQPhyey3uTrSDzFiwmaHqtP577XPM3+hkydlzvxzBnA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8cb54f2c-b8ca-468d-0db4-08d9e583e457 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:08:08.4960 (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: HE1PR0301MB2330 Subject: [FFmpeg-devel] [PATCH v2 39/69] avcodec/mpegvideo: Move header_bits to MPVMainEncContext 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: gnLF3+vJ3Pof The header is always written by the main thread, so it is not surprising that header_bits can be moved to MPVMainEncContext as well. Signed-off-by: Andreas Rheinhardt --- libavcodec/mjpegenc.c | 14 ++++++++------ libavcodec/mpegvideo.h | 1 - libavcodec/mpegvideo_enc.c | 6 +++--- libavcodec/mpegvideoenc.h | 2 ++ libavcodec/ratecontrol.c | 2 +- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index fd87186fbc..a8ea63a76d 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -103,8 +103,9 @@ void ff_mjpeg_amv_encode_picture_header(MPVMainEncContext *main) * * @param s The MPVEncContext. */ -static void mjpeg_encode_picture_frame(MPVEncContext *s) +static void mjpeg_encode_picture_frame(MPVMainEncContext *main) { + MPVEncContext *const s = &main->common; int nbits, code, table_id; MJpegContext *m = s->mjpeg_ctx; uint8_t *huff_size[4] = { m->huff_size_dc_luminance, @@ -118,7 +119,7 @@ static void mjpeg_encode_picture_frame(MPVEncContext *s) size_t total_bits = 0; size_t bytes_needed; - s->header_bits = get_bits_diff(s); + main->header_bits = get_bits_diff(s); // Estimate the total size first for (int i = 0; i < m->huff_ncode; i++) { table_id = m->huff_buffer[i].table_id; @@ -224,6 +225,9 @@ int ff_mjpeg_encode_stuffing(MPVEncContext *s) #if CONFIG_MJPEG_ENCODER if (m->huffman == HUFFMAN_TABLE_OPTIMAL) { + /* HUFFMAN_TABLE_OPTIMAL is incompatible with slice threading, + * therefore the following cast is allowed. */ + MPVMainEncContext *const main = (MPVMainEncContext*)s; mjpeg_build_optimal_huffman(m); @@ -236,10 +240,8 @@ int ff_mjpeg_encode_stuffing(MPVEncContext *s) s->intra_chroma_ac_vlc_length = s->intra_chroma_ac_vlc_last_length = m->uni_chroma_ac_vlc_len; - /* HUFFMAN_TABLE_OPTIMAL is incompatible with slice threading, - * therefore the following cast is allowed. */ - mjpeg_encode_picture_header((MPVMainEncContext*)s); - mjpeg_encode_picture_frame(s); + mjpeg_encode_picture_header(main); + mjpeg_encode_picture_frame(main); } #endif diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 14e5e241cc..20be21a834 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -295,7 +295,6 @@ typedef struct MPVContext { /* statistics, used for 2-pass encoding */ int mv_bits; - int header_bits; int i_tex_bits; int p_tex_bits; int i_count; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 6d45885185..03758a387d 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -1739,7 +1739,7 @@ vbv_retry: frame_end(m); if ((CONFIG_MJPEG_ENCODER || CONFIG_AMV_ENCODER) && s->out_format == FMT_MJPEG) - ff_mjpeg_encode_picture_trailer(&s->pb, s->header_bits); + ff_mjpeg_encode_picture_trailer(&s->pb, m->header_bits); if (avctx->rc_buffer_size) { RateControlContext *rcc = &m->rc_context; @@ -1796,7 +1796,7 @@ vbv_retry: s->pict_type); if (avctx->flags & AV_CODEC_FLAG_PASS1) - assert(put_bits_count(&s->pb) == s->header_bits + s->mv_bits + + assert(put_bits_count(&s->pb) == m->header_bits + s->mv_bits + s->misc_bits + s->i_tex_bits + s->p_tex_bits); flush_put_bits(&s->pb); @@ -3756,7 +3756,7 @@ static int encode_picture(MPVMainEncContext *m, int picture_number) av_assert0(0); } bits= put_bits_count(&s->pb); - s->header_bits= bits - s->last_bits; + m->header_bits = bits - s->last_bits; for(i=1; ithread_context[i], s); diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index 8eab164d7a..ab0f7d13c7 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -62,6 +62,8 @@ typedef struct MPVMainEncContext { int last_non_b_pict_type; ///< used for MPEG-4 gmc B-frames & ratecontrol int last_lambda_for[5]; ///< last lambda for a specific pict type + int header_bits; + /* bit rate control */ int64_t total_bits; int frame_bits; ///< bits used for the current frame diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c index 03466a1a43..c41682b29c 100644 --- a/libavcodec/ratecontrol.c +++ b/libavcodec/ratecontrol.c @@ -54,7 +54,7 @@ void ff_write_pass1_stats(MPVMainEncContext *m) s->current_picture.mc_mb_var_sum, s->current_picture.mb_var_sum, s->i_count, s->skip_count, - s->header_bits); + m->header_bits); } static double get_fps(AVCodecContext *avctx) From patchwork Tue Feb 1 13:06:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34013 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp608108iov; Tue, 1 Feb 2022 05:16:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJxUDFwWONjeNoNa/u3A/yvuKY47CBpnPQFswsx9dppkUspnU/DJiIHPKYkj9KJ5jWRb+W18 X-Received: by 2002:a05:6402:1508:: with SMTP id f8mr3707526edw.438.1643721404450; Tue, 01 Feb 2022 05:16:44 -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 dp11si3129153ejc.716.2022.02.01.05.16.42; Tue, 01 Feb 2022 05:16:44 -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=WGMAO30P; 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 6BCDC68B393; Tue, 1 Feb 2022 15:08:45 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075035.outbound.protection.outlook.com [40.92.75.35]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2BC5268B353 for ; Tue, 1 Feb 2022 15:08:40 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PePuCbEKEG5CCWff/Jp+6prslziZH5uu3zq5SAGaEsZDo31hlT+1iYZPH52b+2c3/JUbGW2L3YctZ6cLPaDmBJjJCrAj8zuZbEoGk1IsgiGsCzg3CmsUggLgWvtbeO/JjV2dN/XeSC5ZZBJ6hKngmw0OLjHjo6E4+BTBF0Nwy093vsCvjbZTvZG2mxhVl/eVbISaNALQSmAWWjoQ0G5Mn1q9wJtOxMKHTrYBtpLgE46uq1EKCjAzjkC+7ZliU6LDpozWowVYiQptQCM9shuSsHJjr2mu61KrWPlCLh8HizCK1HRcXrem/15qaiszYfheWarx/0hhJufTuAcJs4RaDg== 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=HthdOnP0YhAGEEYqpvjpNk8KBitdHE+dp5KWGDB0MxA=; b=SBn6/TuiYGMUvFqsqbtFlQz2iIrLqV1PZTKhVeS3xo29Qj4JafLqoe2b73rRzK7J+2pBFDej0t0WEf0iPUE8r1iYyIePujliZF+pfPhgrIkY2nTgF0Zr7E04h/Ud1ea1gVev6awJ0Iyr305rg9ZjcxOvKKgxom8ikE1cD0K2k6R03A26mzNa4PuzTdKRXI9rUA6weFA7mkMtqnipJ4YtX26eb0ZJ/FIXJsHhv/CJHvp+/FFklsfCKqiqOODVveImrae3LYVM/1DaUQ9mxcHT6FVD+R2Ni/aLbwH4ruDMZlAdzMhpuOMVGqVQwSTTIk+nT1v8Pouknkw0E9FrOuGYwQ== 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=HthdOnP0YhAGEEYqpvjpNk8KBitdHE+dp5KWGDB0MxA=; b=WGMAO30PMsooNwNLzW0pk5g0VDe6+bVHkwD4kghvaz3dRLFT+ZZrDtKxwz1+PboZiWwzkhHfF2Y52oN7r11uO5lhs8YkK3f2Yww5eTYJflKJBrR2lF3j89rmDRUn06yquzS6w/1/hNBgKUjnZ6/ZiDSFt8KiliQJl6WD3DYySDQLrBX82PPFSgzeehrYB3HC3zlSuiH88VvPvT9TzKOXgNDcTjWbnqHbjbh5MruodqhcK8+CoO5G+3OdGVWDlVDHxgr0+YyymjlcIEzkKlLdR+/iAePvD+lUnZUI86WtWdA7bqPvU45mbsbRGZYhqWd9b9N7Ic5B2DxzOskErelkNg== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by HE1PR0301MB2330.eurprd03.prod.outlook.com (2603:10a6:3:73::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:08:35 +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:08:35 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:37 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [Bnk6Hvmf87YPtPnVH8zjLFfeMWDX1UfM] 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-39-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4abe24e9-c069-476c-f200-08d9e583e534 X-MS-TrafficTypeDiagnostic: HE1PR0301MB2330:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xjnXCwh/sTaBA/jQR2uGE8ZKGZv2lUsmUUyi7U/ZSeLPCke0jona/QHWwcmmLhuw7y4WRpbUh9d/xSKSpWA+K6a6Kfq7x2iNoKpC5x+uaZ2dzI773C0C1in0FjXJ4GH7onwVTz3OoRb/05Ty8NSTsmrJs39qKMfaM48xMm8Pxda/CCfAxV9wxepLGpdLgkI1iyUNjY7BzBVDix6rYH1Eevgyns9rO6RgabFPf4n/tINVskWbh+DGC+5Qorn7fiCHo6K7KrTF3Oql5VRdlwTrv7ox1yiaBBkWqbzOxUrGT+BULlXt6xQ+GFeGI9E+JBrpXmYQb4x9CsvKh2NJZu/dRTIdYUcKoJPNY1444Hin9XaoFPR9qNFwX00gFxcCMULJYQcQS00xbySC3fuPU3rSxiyOR0E3ZBVqa/Fx66tmrqhgSvcQV+8eKdbhN88fVq/a9FLa8vGWV0rnAV+5J78X5GFChqMn1ZE8GwnVIziCzUpS/Cdr8iriei+Bo/AMavH2frEpWgR/A3MhDNu8eM28Nd2DpYJfM9m7S6qurXbSW7/KaVpcr7SWfRpUGbWsTrqd X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gor1R3Fmf2X9qsm4JkJbjyaQ/H+fj9wtA5HKM0WMksjnVLFNPGPOvmRUMvqQtQaGvahbavFGT2y3GESvtLxBml5qSvHjLjGe+O48gWfNtwpQDWYa2rp24Ulc3B9X8nYCai/pbc4Q9uHDEeLC7bud7dgqW/nUveuhDHalALdw+MF1KwpZLZ6cEhB6UJUiHIz/slS4BVMdog21EyJUN/zQVYGauIoxY1rtlyKP9bAlzHjeqCbupoqxKzTsiY7IfU9sfXvAXmd8Hgp+f4RKietUk8UuFlLSZB0KvdYrTL1ReIFKJjkmJR4rN2SjUSexYxXGiR2LWzB350lL7SjhL+tjBBkWoMeFFdAsn+pRN9vOOsURuCxFXBE3t74jBNfc8nnsl+V4unqX86SrWopWJ2jO0MwrTwZwfqGDYw5dI7o0HRFeNNbU/47w4WlhaqTYvh+4FJo0kGBFar+guECe7Hk7VQwj/ehYXWw8EfdEc+kX6ZAlKserg6xMqGHSFIT4FMgzQnmIzKGf8tUZYq6cVumD2C0SsnuXzJgZPHu1u8ol/yvcByh8xvvcF2aQsGeqo35LurT39K3bUrsNDmLVGOvlpxz/QJOXLW3MLJhBzXCCQuAuNxEkbkbVUf2CW8c2XH7htiX/YO3s3zR9jfBoNz2hLtKZdWvkrOaJkRhlzxsypzFiw5iTlIq2SYK53tDTwXazQDlsaymIxlI36ymTdEJUdy8gVKQ/63shlUe1fJMkFyelroynSJuCdLKRCAozepitTYMwTcibVxBnnqzvJlXUUkEXKBi2LZqmVPXhebDaY1AfD/917RTLIb6wA3YHGolTlBQwbH/xdrkgnaP82Oklvg58/8AFZWEGp5lDUzw3F+XlkQQzzRMRD2//Nvg21OmChSfvIHi7i2ORvhLRBy3Hlv/XWHTGH4j0/5mJn8tyFJWhs+WH7UWUhZ0TCJxdV1EWF/cb+bg0c69B9AN2RLFdHA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4abe24e9-c069-476c-f200-08d9e583e534 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:08:09.9826 (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: HE1PR0301MB2330 Subject: [FFmpeg-devel] [PATCH v2 40/69] avcodec/mpegvideo_enc: Remove unused function parameters 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: IOJ2G/cOZsfp Seems to have been always unused since these functions were introduced in 1f0cd30fd9b656122436ecd625656a04f6235fb3. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo_enc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 03758a387d..5b6f5211cc 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -2431,7 +2431,7 @@ static av_always_inline void encode_mb(MPVEncContext *s, int motion_x, int motio } static inline void copy_context_before_encode(MPVEncContext *d, - const MPVEncContext *s, int type) + const MPVEncContext *s) { int i; @@ -2459,7 +2459,7 @@ static inline void copy_context_before_encode(MPVEncContext *d, } static inline void copy_context_after_encode(MPVEncContext *d, - const MPVEncContext *s, int type) + const MPVEncContext *s) { int i; @@ -2504,7 +2504,7 @@ static inline void encode_mb_hq(MPVEncContext *s, MPVEncContext *backup, MPVEncC int score; uint8_t *dest_backup[3]; - copy_context_before_encode(s, backup, type); + copy_context_before_encode(s, backup); s->block= s->blocks[*next_block]; s->pb= pb[*next_block]; @@ -2544,7 +2544,7 @@ static inline void encode_mb_hq(MPVEncContext *s, MPVEncContext *backup, MPVEncC *dmin= score; *next_block^=1; - copy_context_after_encode(best, s, type); + copy_context_after_encode(best, s); } } @@ -2968,7 +2968,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ int next_block=0; int pb_bits_count, pb2_bits_count, tex_pb_bits_count; - copy_context_before_encode(&backup_s, s, -1); + copy_context_before_encode(&backup_s, s); backup_s.pb= s->pb; best_s.data_partitioning= s->data_partitioning; best_s.partitioned_frame= s->partitioned_frame; @@ -3202,7 +3202,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ s->current_picture.qscale_table[xy] = best_s.qscale; - copy_context_after_encode(s, &best_s, -1); + copy_context_after_encode(s, &best_s); pb_bits_count= put_bits_count(&s->pb); flush_put_bits(&s->pb); From patchwork Tue Feb 1 13:06:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34014 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp608277iov; Tue, 1 Feb 2022 05:17:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJzwt7eg6kXT3lYMTF37Qb/iz9gC7o1yc/EEuovZ6y1zb5+f1VgRnm43tkTN/EoGIqbVuTD9 X-Received: by 2002:a17:907:72c6:: with SMTP id du6mr21119452ejc.220.1643721420506; Tue, 01 Feb 2022 05:17:00 -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 hb16si9566469ejc.475.2022.02.01.05.16.56; Tue, 01 Feb 2022 05:17:00 -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=bJ3ZtZv4; 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 5C3EE68B3AB; Tue, 1 Feb 2022 15:08:46 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075035.outbound.protection.outlook.com [40.92.75.35]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 47A2568B388 for ; Tue, 1 Feb 2022 15:08:40 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J1qttCI+MXRAARvlk4j5i1/OS+IFwg6Q2HmbtNw3blb+HEOgfpyJJpEoud6y99ZJvUAIvq1XRUy5gmX34PQXLTS4d5JE9B85wd2ujqH7kRtTVLUArxHue4HlDazEaaTbol2hgYV6hWtREmPWBtP7FfVFM1Qz12rUWi6ZgirTkyAHFVFrIfaZsdkoBzcjVs/39LHaDd+z4SXp/IoqGGBUCzbG7qQs7f1THdLEyKIKZVSPAoapACynsePZV0ckJqANv/75M2M21JepMCTP+IQzMDhoUdRUt85EJMDB7FcyGcw/wSHCvXqCDEUOfcAZXPHR97TA6RCD96o3o0CLi5rLhg== 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=ZEP255T1CHixR5R4aW2jb7Xrz6eoC13fvPp21eI5zVI=; b=KUBwGA3k9zR3pwx1bl7WtOpBbpOMCEoCfHBQLr8q+ERcz7i2yDL+g9LP5/xsEGCC+ShWktWPpXscARNMJB4DxLwvxs1N3PczGl1OG342vBJgYSqAsft9ul+SeCR9TqOrwad+lZ26KueB6EZZZHYvCrOzO8N6qOCIYIrhFpthlt1B83+IHyMaTbbAA7j/Kangkk41eDYTRvr7md3ZWDDm2yol+zJVdyKCXXowsIxKMw+Zrz8JPnPaAy2P1euKTfdKIuk9jm04c3Gs35W3XDlKbvT/rs07f6UJG5zT75dYEUTulJbwkhz9p501lHqD6KTZNJBXTsep5yop5CJmeeZjzg== 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=ZEP255T1CHixR5R4aW2jb7Xrz6eoC13fvPp21eI5zVI=; b=bJ3ZtZv4e52DwfLlzCES5I8q2X0SoqwR8l6iZFndfZ1e6ErYl7RMoJzmy4flA92Xk5jMjiGoBmxYsF9obX//QBAbgd5b6A9erCUVoxE3yLFBZhOX1u+Ztlu6ISnDnmZ5ZCge1iNbwf1+wJRL013tHucB7wf7I5/s2D/nXJBhXQR0x19ksRkrrG+y6ClxMagbuhGdG24IYQer71RdMN184LjHUS3v+fq2bS7spx/1KtaOqNgT8SERUXSeGQ+dcsLXPCYmNxj2HUf0lcfG7qkzMJbIXtNvkJ9xh42iRt8ELaGwAM9B4rjAwEFIBjC8T+O/+fq8/q9K2XrXNfAFvRX28A== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by HE1PR0301MB2330.eurprd03.prod.outlook.com (2603:10a6:3:73::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:08:36 +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:08:36 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:38 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [gcytkyEJ0XpqncPeJtB19fiI5VZaurTH] 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-40-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4f87cdba-502d-4570-a945-08d9e583e5f3 X-MS-TrafficTypeDiagnostic: HE1PR0301MB2330:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Z4Kg0DmQdxLfW7VjIJT2igdPSd5MRveg89kAeRRoPB8oo0DU1RifJ9mnJtHQ6PnKqJfHOLSnGwfasifR6haGqv0AaFyGSvCPMmUfTQU4aUI44mcnjQObJ5SAEihrNrtKasICuaFcQSH+h74Mh8Yqo4MdLer90EvY5Jazi70lYrJoH43aDMrt87yAadtdKylhbQ5kNSBM8VdbXyNkyXPk++EEiUDXPbhUOKfNDufTDx9TcH7We0r11OMg/tH8VvFpHBr2Ugo1aXuoPBI4zQRD+TY83p1BTdds6VqZRmbpe2ZTSw5rKSqENnxDUPWuneQTHiOT5AmYkIjt/MWrYK8GPAb9wkDV540Z3YTr1uXz2aGq4ywVGVPPPMpoVGhluUKps9Q/xQKYBwiSj7kbwsA0ReNMOtxBffykv4otETZW6fS9kMyjQEmdHrFtdrq7DS3TPMPVmlUYQ7Qy3uqUXTrOQ891H8qRAYda9uoLdQEYunp7vEw9FFIADj19XINKTF/57hNFf1MKyQohn89Ecn8GTlrdvZNMjUm6qJszbxKqA4lzugyzpNhh2CKWB9zk8X9M X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wpLY5qlUGxBXJ0vJwTmqgXopf3E2kTczejTrgSl4VPFD7xALX7/rfKx8vCwSFhaXGSLsyvAbznP2xSvPkUkLOf6Gk7C0AwmzJM9HEjtdf6snBIgoImj32Wy5ZsgbKM14qseTgzuMwfBaJIk0E9Oy48cO97h5Gj8pSOtdnsZwa/rNiCmeO9Kxpdc+sDozew8SiXWglIOY3K8kIM4XSlg9o5lBAg7tG9Nub+1uGsED1S0rkrlCaBrw4BVfWr/A4qDXQgr0zySFW6KjoghPl+2Os6I7U+rKi+WLthRkMt1RmCsqcO6lN92NQA+gPIZ15X0BVxSEsZPNiNIdNBq4mHVPjW0d3mfOpJOsxj5Qc6y+KBrbkZeGoYEsFFdwYM/wQ6k5imqyympHQQAAeVZTVuiKfRaYiqTC4cr+4I6a6KXX283mijDHuqHGdnDnfTlpgJUZkVlvL0z1Tz84D4FtWuz4N/Znn9B0mhVF4OP6XpQwe4AldqF2ktXwaQpvoZh6WCNhvQpbDhgHeJ8cjI2xH8DbmtBQPNN/DizQql7OOebPMB/UucQ+bq5HVmBnH72DF8cverCxCsprwj9lD7Ee8IlicjwXMTMMKTTgMoGVUL5fTtGRYotRq7xOggM24X9WAZ1DlIcqvQmLpg09WnaGno16MBzOXrLpSUUd9EsotTLc8xgf6WAMvwTLDCjPHTthxWxiRIWytE/AHkhLEjE8QzOpgeLMndf3s6QcEhzQiFeNnovuM7Rg2wUITFFagt+9jq4IEojzZcb6eU+N1z8ItH+WSQ23JmUCIJqKeo8N9G6uDwY0hZxdiDcf7P+TmIeRLPnNFZj4LsKRzNE3GW53Uo87nQkV9YiLzkkD1nwWCa+O+r9G9Yp0scwxc6vE04V8qmhUZI1yTjHvhT3HewGi2O3qt+zPxjNgw2ETqmAQ4GOpvZqclnKSNcaeoqinx8BonGAXcLngTeac4Co6p8qKInMACA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4f87cdba-502d-4570-a945-08d9e583e5f3 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:08:11.2156 (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: HE1PR0301MB2330 Subject: [FFmpeg-devel] [PATCH v2 41/69] avcodec/mpegvideo_enc: Remove unused parameter from encode_mb_hq() 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: 50zUXxYQjpEW Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo_enc.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 5b6f5211cc..ab49705823 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -2497,7 +2497,7 @@ static inline void copy_context_after_encode(MPVEncContext *d, d->esc3_level_length= s->esc3_level_length; } -static inline void encode_mb_hq(MPVEncContext *s, MPVEncContext *backup, MPVEncContext *best, int type, +static inline void encode_mb_hq(MPVEncContext *s, MPVEncContext *backup, MPVEncContext *best, PutBitContext pb[2], PutBitContext pb2[2], PutBitContext tex_pb[2], int *dmin, int *next_block, int motion_x, int motion_y) { @@ -2983,7 +2983,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ s->mb_intra= 0; s->mv[0][0][0] = s->p_mv_table[xy][0]; s->mv[0][0][1] = s->p_mv_table[xy][1]; - encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER, pb, pb2, tex_pb, + encode_mb_hq(s, &backup_s, &best_s, pb, pb2, tex_pb, &dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]); } if(mb_type&CANDIDATE_MB_TYPE_INTER_I){ @@ -2995,7 +2995,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ s->mv[0][i][0] = s->p_field_mv_table[i][j][xy][0]; s->mv[0][i][1] = s->p_field_mv_table[i][j][xy][1]; } - encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER_I, pb, pb2, tex_pb, + encode_mb_hq(s, &backup_s, &best_s, pb, pb2, tex_pb, &dmin, &next_block, 0, 0); } if(mb_type&CANDIDATE_MB_TYPE_SKIPPED){ @@ -3004,7 +3004,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ s->mb_intra= 0; s->mv[0][0][0] = 0; s->mv[0][0][1] = 0; - encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_SKIPPED, pb, pb2, tex_pb, + encode_mb_hq(s, &backup_s, &best_s, pb, pb2, tex_pb, &dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]); } if(mb_type&CANDIDATE_MB_TYPE_INTER4V){ @@ -3015,7 +3015,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0]; s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1]; } - encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER4V, pb, pb2, tex_pb, + encode_mb_hq(s, &backup_s, &best_s, pb, pb2, tex_pb, &dmin, &next_block, 0, 0); } if(mb_type&CANDIDATE_MB_TYPE_FORWARD){ @@ -3024,7 +3024,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ s->mb_intra= 0; s->mv[0][0][0] = s->b_forw_mv_table[xy][0]; s->mv[0][0][1] = s->b_forw_mv_table[xy][1]; - encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_FORWARD, pb, pb2, tex_pb, + encode_mb_hq(s, &backup_s, &best_s, pb, pb2, tex_pb, &dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]); } if(mb_type&CANDIDATE_MB_TYPE_BACKWARD){ @@ -3033,7 +3033,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ s->mb_intra= 0; s->mv[1][0][0] = s->b_back_mv_table[xy][0]; s->mv[1][0][1] = s->b_back_mv_table[xy][1]; - encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BACKWARD, pb, pb2, tex_pb, + encode_mb_hq(s, &backup_s, &best_s, pb, pb2, tex_pb, &dmin, &next_block, s->mv[1][0][0], s->mv[1][0][1]); } if(mb_type&CANDIDATE_MB_TYPE_BIDIR){ @@ -3044,7 +3044,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ s->mv[0][0][1] = s->b_bidir_forw_mv_table[xy][1]; s->mv[1][0][0] = s->b_bidir_back_mv_table[xy][0]; s->mv[1][0][1] = s->b_bidir_back_mv_table[xy][1]; - encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BIDIR, pb, pb2, tex_pb, + encode_mb_hq(s, &backup_s, &best_s, pb, pb2, tex_pb, &dmin, &next_block, 0, 0); } if(mb_type&CANDIDATE_MB_TYPE_FORWARD_I){ @@ -3056,7 +3056,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ s->mv[0][i][0] = s->b_field_mv_table[0][i][j][xy][0]; s->mv[0][i][1] = s->b_field_mv_table[0][i][j][xy][1]; } - encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_FORWARD_I, pb, pb2, tex_pb, + encode_mb_hq(s, &backup_s, &best_s, pb, pb2, tex_pb, &dmin, &next_block, 0, 0); } if(mb_type&CANDIDATE_MB_TYPE_BACKWARD_I){ @@ -3068,7 +3068,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ s->mv[1][i][0] = s->b_field_mv_table[1][i][j][xy][0]; s->mv[1][i][1] = s->b_field_mv_table[1][i][j][xy][1]; } - encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BACKWARD_I, pb, pb2, tex_pb, + encode_mb_hq(s, &backup_s, &best_s, pb, pb2, tex_pb, &dmin, &next_block, 0, 0); } if(mb_type&CANDIDATE_MB_TYPE_BIDIR_I){ @@ -3082,7 +3082,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ s->mv[dir][i][1] = s->b_field_mv_table[dir][i][j][xy][1]; } } - encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BIDIR_I, pb, pb2, tex_pb, + encode_mb_hq(s, &backup_s, &best_s, pb, pb2, tex_pb, &dmin, &next_block, 0, 0); } if(mb_type&CANDIDATE_MB_TYPE_INTRA){ @@ -3091,7 +3091,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ s->mb_intra= 1; s->mv[0][0][0] = 0; s->mv[0][0][1] = 0; - encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTRA, pb, pb2, tex_pb, + encode_mb_hq(s, &backup_s, &best_s, pb, pb2, tex_pb, &dmin, &next_block, 0, 0); if(s->h263_pred || s->h263_aic){ if(best_s.mb_intra) @@ -3135,7 +3135,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ } } - encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER /* wrong but unused */, pb, pb2, tex_pb, + encode_mb_hq(s, &backup_s, &best_s, pb, pb2, tex_pb, &dmin, &next_block, s->mv[mvdir][0][0], s->mv[mvdir][0][1]); if(best_s.qscale != qp){ if(storecoefs){ @@ -3156,7 +3156,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT; s->mb_intra= 0; ff_mpeg4_set_direct_mv(s, mx, my); - encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb, + encode_mb_hq(s, &backup_s, &best_s, pb, pb2, tex_pb, &dmin, &next_block, mx, my); } if(CONFIG_MPEG4_ENCODER && mb_type&CANDIDATE_MB_TYPE_DIRECT0){ @@ -3164,7 +3164,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT; s->mb_intra= 0; ff_mpeg4_set_direct_mv(s, 0, 0); - encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb, + encode_mb_hq(s, &backup_s, &best_s, pb, pb2, tex_pb, &dmin, &next_block, 0, 0); } if (!best_s.mb_intra && s->mpv_flags & FF_MPV_FLAG_SKIP_RD) { @@ -3194,7 +3194,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ s->mv[1][0][1] = best_s.mv[1][0][1];*/ backup_s.dquant= 0; s->skipdct=1; - encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER /* wrong but unused */, pb, pb2, tex_pb, + encode_mb_hq(s, &backup_s, &best_s, pb, pb2, tex_pb, &dmin, &next_block, mx, my); s->skipdct=0; } From patchwork Tue Feb 1 13:06:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34016 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp608625iov; Tue, 1 Feb 2022 05:17:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJze9sLmWRKx0N1M3et2B63wbnqeyxngi+QLLWZpVWBw6U3wcrOHZix/gAwBVZeWCpx8cyp9 X-Received: by 2002:a17:907:2ce1:: with SMTP id hz1mr15125768ejc.681.1643721447150; Tue, 01 Feb 2022 05:17:27 -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 gb30si9783299ejc.581.2022.02.01.05.17.26; Tue, 01 Feb 2022 05:17:27 -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=FGKRjSsP; 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 20A7B68A43A; Tue, 1 Feb 2022 15:08:48 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075035.outbound.protection.outlook.com [40.92.75.35]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 73F2068B39C for ; Tue, 1 Feb 2022 15:08:40 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fYUkOJkmd3ssRkerJ3NuYEmeTw5QBhPmP7ozNcF+/45EO+O5Eb05llVME9VzyguxD3astOPYHBC49fekslBg174TFH9VAvZ67UzV32flkuZJ6jeNO1B0SzOxi+Okdsy+oBHFavtcvAT0/QaNIulj6FZWyophFTfn9RMutQVf5h37FN3lZNQ+ZHXvwF6X8Aj2eT7UbSppxC0/4L/4H83rkBn0yQIScpaP0wvi9bHDFxpg1Nv5oAJEl9tTaJuCeHUCjVTy1Kviy4RXUR1rcq0Y5pRDkO+cAcLihlRSrBRXJvagsxINvs+Ds9bMMo3sh6/PVDrpLIftKtkj7aOwK90fRg== 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=BDOk2FdvQkLu9Ym0Kit7ww1me3Bq9lv02Ixz6l5TxcM=; b=QxMhW23fPEZfdXMb8LnSkOkhctnXZgoeWnSN1AdtK80B0KiZAT0SER5zfccIHOHzv5sGkYdC2oFWJZs6sp9U02VwvtFJwKMvPoBjWSXVshY1mIs1FnBD8k8GrFS01r0sHNHryUuxbidYLTZ0zgddi+7MoVirN5JL0hKsQWjAlo/qWGRuea+uRh1d3D3eY9FJoF9vl3xW3xQgVzT/n9Vj5D1VXDBAzfFYL38qTgf7/dvSYf5H0QixXXhNmkuM14r187J/EYTm6OZ8z6yuoN30bsWyNSaL/GRRFUXc1oPyhQ6Sk6/FGvgy2RY3sJPXyeeBIk0Lx2vqZcGxZ3JwCndryQ== 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=BDOk2FdvQkLu9Ym0Kit7ww1me3Bq9lv02Ixz6l5TxcM=; b=FGKRjSsPdzGpqInN2seWX2/8RTJPj3ZSQJAiQsxISEkQPmBxmCSNsEo0Q9c+K+pYKtFfEwC0hZKm/N1zZiS04X/xMrbqh+b0w+eGVkjLS+psOOO+9ZbmifhrDRfPMGg1AP9/m923q8I6/TzhCZQFbXT1ysr/GPVo4o5gs8srWsLcIYMH0wigm6SYKjKQgpPm8D3JB/IMKwa2m08JU2v0lXFsc6LFbkmpOvBz4VAL/AHJPEs+WQHrDaPfFWTgmdX2MpIl2Hn5sCFD7jhE6YwOqBcYNXa/V9BkT9IPpuUwEe8MhcP9MLnGKnN5tL84YUPx9XQtNjCwWNNjzjBFPTaGHg== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by HE1PR0301MB2330.eurprd03.prod.outlook.com (2603:10a6:3:73::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:08:36 +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:08:36 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:39 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: