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: References: X-TMN: [EzlKnynmEFFn9upcKXgvPnbazWAfL8kV] 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-41-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 13a915c1-247e-4280-f112-08d9e583e6b4 X-MS-TrafficTypeDiagnostic: HE1PR0301MB2330:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0CDc2/80UCCA6NmXIZ+C56FPqZn7h2kUBcPFdOKwPHwrenPGqAkxTJKCkI1NFoG5BRNPb3gTP2dFBvRKKCamHjxqUGx5uHiNAUsxoOEiU4w7aDIfYjv8YOk2w81pr/4FtlTuoSja0ypRkn0mbsIDASGIhyghbau8nfOdKaiGxDzrx0omXTo8xuxF04HvTdPMmvcJuH49Nl6osUTo3ClzrSPHyQ9etusBq/5Irf1oQcoU/zVPT8xh8dSTJqvJrQN/IodA9cTRd5zt3baUxGzbgn8rqbiyug1bL3Dp3yEB5mVRMrDdUStKy49qIgfR8OzWkXuJexYTNZ6nBkZaA5LjmpYPJ7EsU1ZnIzGsO8YHb57XlfwOlFx0s+XFrXQyiCp4Eyg5gYfC0zFWviRKRMUS60cxdH8DYMWi/SJOX/nboYFz1vXW2x49KoS5utMq40PPTYEBgXDMB1AI97UKIl+QfPd74irlomPaYLcH5vS3zze6dY1mnByYtSanzGC0E7HqCBAWAT2VrxopPvsZvECy5WTIsG/djCzmU21luzMsdH8KcQxcVi52JQiOu6yFaRau X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: onTyWIFWvOVKaWUZtQL/KpdOhGFtmKwhFLizRwAZIfMN1umDbmtlQpaFrIjtXI8697e2ZCurG6xj6kT/5qlCoKfcWq0CQYNd62mNzMxxYlvdHxn9DQlohTBDIFDuOdWDrOsHJgukBTa+bkA0yUpWzwdcKVp0LZNJPL2G7oY4/TeltagEH5I7htoBgzKxG/r73/NMubwNR61jmII0qaxn8cfV3sCAeGd8lfZwOw6F7nAqOxJjb7D36cfWqJLNPyelMX4vBt5/e1+fKhZFT5o/iOlpA7g/DDqqoCkjFusnDJgp3T3MPEUNrroRmQqf4KL9X6hTa/PKbuE/97nODy1HMVHIKDeibBViqwec77xDEVLk07vP3YysFbjsuXjoiYdgjBx8Dg+h3QxJqFaxKEbP2eCqIosteW3Mhk50XHnF8tr5TgOuPyA4hohgT7H92qc+NaNFdIFSzu/++VkEvP995aw4uMjTlNF7E9Q/FpbVg6qjkjO+ebtUqxKwezVM6izJ3nsV8UTWtwbPdDDSRbC/Wg8BmtSKy61S8Jo1TR7/GFST0nD92aew70hA3OuIhtzTB/F74OtPsmfcnrg5cIVRvwhxxXnEVPiHm8ofnAn4h6b/cfyAQibj/lLgAgFUW3bWUuDgf7Iy17K2vaUUoOoWYDRMfIHZUex1MDYLYGik98izJ2Fuyqtftw3zLOZWILB5maHHtRyKjkRIVJlby8TT1YN6HiXfJDD3d5OA2NE8Rv5EEbpMWD4tC5y70Hd7W1slfJrUsNatwk9ncWXzA6wy7mp0rrF1s/T9gnNsvNXf6aghKTO57QRnj7PbCPJ2epI8rzJHdoM9PZ7+5FZ9VjiO7AygbGiONPVpdOxm/sH5NvfQXAORBohSYWPn1Y5tSLwWxefPilal83A3MOg3TNDIlMvJtY5tqJB2HRRkzM4/eCL07ZgO01w0mazbZf+JN4kH9c9u3SptQtiguA+iKVr9Lg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 13a915c1-247e-4280-f112-08d9e583e6b4 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:12.4667 (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 42/69] avcodec/mpegvideo: Move vbv_delay to Mpeg1Context 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: dONcDiIaLA0d Only used there and only by the main thread. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpeg12dec.c | 5 +++-- libavcodec/mpegvideo.h | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 22e0ba5ed3..d3c32818cf 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -69,6 +69,7 @@ typedef struct Mpeg1Context { AVRational save_aspect; int save_width, save_height, save_progressive_seq; int rc_buffer_size; + int vbv_delay; AVRational frame_rate_ext; /* MPEG-2 specific framerate modificator */ unsigned frame_rate_index; int sync; /* Did we reach a sync point like a GOP/SEQ/KEYFrame? */ @@ -1285,7 +1286,7 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) if (avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO && s->bit_rate) { avctx->rc_max_rate = s->bit_rate; } else if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO && s->bit_rate && - (s->bit_rate != 0x3FFFF*400 || s->vbv_delay != 0xFFFF)) { + (s->bit_rate != 0x3FFFF*400 || s1->vbv_delay != 0xFFFF)) { avctx->bit_rate = s->bit_rate; } s1->save_aspect = s->avctx->sample_aspect_ratio; @@ -1358,7 +1359,7 @@ static int mpeg1_decode_picture(AVCodecContext *avctx, const uint8_t *buf, return AVERROR_INVALIDDATA; vbv_delay = get_bits(&s->gb, 16); - s->vbv_delay = vbv_delay; + s1->vbv_delay = vbv_delay; if (s->pict_type == AV_PICTURE_TYPE_P || s->pict_type == AV_PICTURE_TYPE_B) { s->full_pel[0] = get_bits1(&s->gb); diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 20be21a834..0153abde3b 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -179,7 +179,6 @@ typedef struct MPVContext { int adaptive_quant; ///< use adaptive quantization 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 droppable; int skipdct; ///< skip dct and code zero residual From patchwork Tue Feb 1 13:06:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34018 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp608943iov; Tue, 1 Feb 2022 05:17:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJyLE3FpZVvXJ71A2pMcu7VF+tXn8T3LJnlBSN+rO33f7QhxvDvZOc7QXVJkNQtgxw5t0zh7 X-Received: by 2002:a17:906:5d16:: with SMTP id g22mr20836005ejt.753.1643721473667; Tue, 01 Feb 2022 05:17: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 z17si10966734edc.147.2022.02.01.05.17.53; Tue, 01 Feb 2022 05:17: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=Nk0Foq1j; 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 0276968B3E1; Tue, 1 Feb 2022 15:08:50 +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 8FCBE68B3A0 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=l1yDIFOdmqOj+3ECQYtu8YpFg3Dcs36FsA2XIVMwJbMemgw6CzjEmK3QJ/DGmwh9I+Nq4G61LMNiF/2s8UAScM5qd7wec+2hhqif7EZnTxDT9EBJxk4oi9/kkAJzOvXYKeJu1TeR/mk3suzWXRYhE6go5ygisbUGYne1H11eGTlEbE17TkZSovMV36iuKeSZycrdZ334DkTYah0AqPOQFOc33DVHIaJRqAtPmSa3mjC5mEBssqPE+r7+0hayvHTmKaPRya6xl8TVIBYQY76vDGNt1Jy9m9fksrzCQuMOlaBrmYe/kcRZMzHPNu/465Bz87QwlegTwLjPc8xz81utpw== 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=aHWT8YfIaP58s+6z0EQK5GdUpoLGBcyC2dzhtWBrgOo=; b=Ny7DuIn3wU/c8Ltf8G1RQydYbWzO7XVkPhG65yWfGuYsNGpQn68+KgP3Q6EVA/ISyBokLqtKXKtjGKMGobopJjMekPTbLUZWFexDTIMkAWEXhO5UqBtsorIz0F/reP8O82V/ALrQoXZeJ0DHb1dFfNeVxPjzIMAIox7gKvzMTAm9qmE4BuOD1/+c1KFIcVdoK40E2yM7BMDDet2BamAAWEcnM847Z2J80cyRDKvmstZKQpsHHIF2tdcG/RxclTgMSqehuMDZlshcwIrVsD1N6ASe5XQW2N2M++K967e965cGSj5VdbIBTGB9o1sw8Zr3AWsErvw5JVlbVHd8Hg97HQ== 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=aHWT8YfIaP58s+6z0EQK5GdUpoLGBcyC2dzhtWBrgOo=; b=Nk0Foq1jinOY3trbbylFmrut/cZuwkuKPzZOLHLpksl+P4teH4LZAwREnPIemC+kL9c8iXozhBFFw4oicyQeX1LMY+lz96eX8fVrTD7OyG8cJQsazwx7piZPUi/zGFwa+s9SCqAu5WFvFhRk2titXxp7BWbkm/1MJ36QR+y7XmmxOBhMuzGyYddfHHrE3yfl+lnOizmHf4LtCP2LpkFBYEQQ6D2UO7rw7KZiKq52Nth/BSu0E1UYO/1NOyOmP2lVG+5eoxkUcz0d9wUf0BbYhaLOJCv3fuH+4BBGdddQtQG2uYukArMBRd9N0fbQr+2vwFYonhLppjqtptqE0nT+uQ== 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:40 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [WmAdulL1/rnPa+MAqSKhsz4Y6cZOeDue] 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-42-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1c26c73f-cfc6-4727-eda9-08d9e583ead2 X-MS-TrafficTypeDiagnostic: HE1PR0301MB2330:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OMSEUKQg8wuwrD3HEGU6tM+2nhBXO5Z0a6WrIv+Lo+e281Sm8yOhREJ3uStEPiPCgUzcEX/QLGagluknhBJ8gQllvvRrql6hYVtcW2lK7nQHtGbRa+1pq9/F4RpdUzVhdKjceoe+pFElW8/HWqqeBN/8cS8IM2m4nQF8JNT5GpMC1uSzp12+/4BWE/uNqhztOisN2h4CuKKZO+jjnFG0+5WzTPr2dA3bbBVYdtcw2Nd9487bpOujzXa4Y1yLAUatNWZyNJ5hcgYETMir1u/GB0W3MyTBJ91drBO8oBOpXYfRtfwUOMcDcd8JdMi5y98JfDaCzs+zArcaV+R0USaN2ncEA81gYNNys19eWNb1Pq74BAPGAHIv4y888fqk2IvgitSYXq4afSDdq3KuZ1ZFuRdZ+U98VNZfxfQ0/JEaUU1vFhVZkE3yWQeHCgQrKXX0DhqsUBKPDh+mmsWw50tfqZsRXQCfcJbaA/k8UErIxjsBhh1mdpukwdhsI/b24ClyFH0WYzrj0DyELLyjUhkr4Qfa+Akhy7JD9UpkYxY4qSs= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ySjLrzGWZPkqucpts9efA3G6G5NaI3zKgCbFJKzcpZL178K3GEW1x5+mnsYPdXaSrxcPZSpfi8OK11tle+nIGyaa+mLW/snRlaRirevzYjWYYVIHSkYl5zRu2M77J+7ArQ3mmZr28WSxcAfPdS2+C7ouapnhdqZWZnwyhqLjhW3sbDv8wyRwcN8ryafYKGLXwZEoooyME/u8HaxxGehl6LIsTKdx745EkhcSX9uHtScaTvz5lN2CiBs175pwcBUt3ZEM8aHvzNxXlhov+2ce/oCrjmKrZXB7I+jW0gHyrFJl/rmaD0PCCGdtDZuDBtk0UQwg2Ep5oJ0js3yjekLYGKOFkArAKd4PnGgwWG1WC6FWHQWdACOcq+4T2IcvOIT1zOkKorTuwyUouv7BSlJcDDZlJWoD/fBXA3yqhi8uNRIC0pzO9BbnYb+2RFQpM6+87osvaYZ4pvA2+kkyL6j6C82KueB/UV9opLsSj3dZTiDEUxvhxj5NjcZmDxB71lvVNbytJ/oZozBrVuB9YMf+7zCCoWWRytU8lza35RE1boRqOc8KY7NQri2c8oy8GquWySKxZMO6gd+s7DMM2ni5dfsrxTNEuCq2hfQPgzX/PCOGzgjcCScNQybngR299Ocjs9M5vsB16+TUF/ukQ/cDAzq0b0TksQEg6H2fjGyHkx+ZYOCP0YcTefufaz3guY0RxqyHMmxHjGkbGinH6zPDIU9iqZLqedbL+6/oHjbQmIlyhIT4FC6IVBJlbHoTK+7TQamdLZjnv2c6ke2LHjPNSzepvs+YWvDNG3Vb/syCg6vI/eDqbeLnqGcIVZjz8E7Lu+OLa5Mf48KNd+xbmzowwXrpXFDEOhluxqixYkQzQ7JKdHWCe4OPsHLfy64qaSe6HAJuGCbaEUlzUPbi1kXV+MQAM8x6Zr8Qq8zwVv8kVLt8ta5Brd5q2ooA+TnWvCR4kVzXpWNLNOMUezLQzRHMjA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1c26c73f-cfc6-4727-eda9-08d9e583ead2 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:19.4054 (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 43/69] avcodec/mpegvideo: Move brd_scale 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: w6heLhfjlwV6 Only used by the main encoding thread. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo.h | 1 - libavcodec/mpegvideo_enc.c | 6 +++--- libavcodec/mpegvideoenc.h | 5 +++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 0153abde3b..62347eff81 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -406,7 +406,6 @@ typedef struct MPVContext { int top_field_first; int concealment_motion_vectors; int q_scale_type; - int brd_scale; int intra_vlc_format; int alternate_scan; #define VIDEO_FORMAT_COMPONENT 0 diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index ab49705823..a1ea875546 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -909,8 +909,8 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) return AVERROR(ENOMEM); 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; + m->tmp_frames[i]->width = s->width >> m->brd_scale; + m->tmp_frames[i]->height = s->height >> m->brd_scale; ret = av_frame_get_buffer(m->tmp_frames[i], 0); if (ret < 0) @@ -1224,7 +1224,7 @@ static int estimate_best_b_count(MPVMainEncContext *m) { MPVEncContext *const s = &m->common; AVPacket *pkt; - const int scale = s->brd_scale; + const int scale = m->brd_scale; int width = s->width >> scale; int height = s->height >> scale; int i, j, out_size, p_lambda, b_lambda, lambda2; diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index ab0f7d13c7..350a1f70a6 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -75,6 +75,7 @@ typedef struct MPVMainEncContext { AVFrame *tmp_frames[MPVENC_MAX_B_FRAMES + 2]; int b_frame_strategy; int b_sensitivity; + int brd_scale; } MPVMainEncContext; #define UNI_AC_ENC_INDEX(run,level) ((run)*128 + (level)) @@ -157,7 +158,7 @@ FF_MPV_OPT_CMP_FUNC, \ #define FF_MPV_COMMON_BFRAME_OPTS \ {"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 }, +{"brd_scale", "Downscale frames for dynamic B-frame decision", FF_MPV_MAIN_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 \ @@ -169,7 +170,7 @@ FF_MPV_OPT_CMP_FUNC, \ #define FF_MPV_DEPRECATED_BFRAME_OPTS \ { "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 }, + { "brd_scale", "Deprecated, does nothing", FF_MPV_MAIN_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; From patchwork Tue Feb 1 13:06:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34020 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp609432iov; Tue, 1 Feb 2022 05:18:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJzr55Ld2YHWbZryIP6lIalIkJM3ytGykTrWbmlWRJ2TlwI7skCftYOL0BH4ZsNiPvrxydxu X-Received: by 2002:aa7:d459:: with SMTP id q25mr24720580edr.212.1643721513914; Tue, 01 Feb 2022 05:18:33 -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 g19si9014243ejt.914.2022.02.01.05.18.20; Tue, 01 Feb 2022 05:18:33 -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=A4VcWJtB; 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 DF46468B3F2; Tue, 1 Feb 2022 15:08:51 +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 ABB8A68B3A4 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=M4elRfTKCorGDelPGFdTIoSiCIDe7C30IsciYHmo/4IVo9kwusSuy3fsg5bUaDLZTEKt89MUkQFoI/8X5NoFKpPv7aOzPLC4hf/LuISh0TgYxVgstH+zM2Z6Y3o4hOd31ST3x5WzekzDQXc+N6cAy/w5uNz3wQaZy4Hl7IgaOFdHHSZrffN7Z/thGPEezMzME3fwWmYczPmQXI3VRpAM0Oy3kbbJ9jzk2fImckkabTgdeJOE1+gnoW5rniTgTRfhH1OJtaukFCGoYHwOKR3c4x3m6Vj6N9jQ1ez5yVa6vA/RWpe/7VlE4dHD4mwMWJfFUPR05H9SLzs7FWykWwpilA== 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=jkZ22pY+xjsp6ZOrMFqMbXVeGksMv+8hf4TtKQb0o6w=; b=I781Sr01iLxavrMduesLHlGofFFAX6YcWb4BgtTye2so8aZo8aJKpzC/FPrK764Ya2M01Ga719vAqOAV4/675JyOXXLVEl+ehM/35Y1czNyQqJ9/+mlXvvCWAFWIewRd0hxIEWk5KPLnpUr36jV5y2m0kTVb4LCTk0lhsGkRZyUkK4hZ3ch3zfzbggS4FFf7+wz3N/i/Rq+FzPKNp/zwyznnMqMRmB8/ILZlqH8cuZF3R40MI5/hHfmXLDcoQ8EUW3INVtGqLmYHXsGgt5HZqytDjNFM+5MpwSvLQxM7tV5HfwL5+YLLnp8vi5VC+P5OlVNqXNDQj2v9H/lEmlyvUg== 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=jkZ22pY+xjsp6ZOrMFqMbXVeGksMv+8hf4TtKQb0o6w=; b=A4VcWJtBKvhHz6z4dutuuvz0f8Y3UfrqapOZ8hCO3NFJJqSGHv5MVLmBhv6NqXIXWmM/zuRozLz8vqhYY0zkR+tSZ5D8AMLx+YnpVwaMFJZHHmfT2beAQc0GfUT/T4TM5WlTx8KF2ND/Jr+89qGejbMVMaOAYNqU0PXaY/kl87+xOvIBpCY5QCvyl8e9yj7lmQa1tcQM3sBldNKn1E+ib5w6G8erPoj/35LepKwE5TlghCfzFwbN8cIh0hPJ3QbeF6KvTGua/4NLNiT4+kVRq4hwwmmcXqQ9TbVeScemZJPpZYnPmwz0Oy2+hYadMvfHuAuqMKQYnjMLxbnDPBV8UQ== 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: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:08:37 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:41 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [SbYVpO9ZsgJxaf+sBmba2XtbYPp4VLeQ] 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-43-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 153ec003-7f5a-4708-3213-08d9e583eb62 X-MS-TrafficTypeDiagnostic: HE1PR0301MB2330:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 19Otz3r9i1hqdDy7Jy6RoWJtZ3Q7jTQh6BuU3IHJvVvielY5QgshF14Y6rhgAcMBOHkRyLaormcjjn3Yoa/IHbOgF9qzpMooW2/X4Y0Hzf4zhwLDgsE6IGHBULBo9cTYiWqZc50lIq0FkbJ1OKsfm6g3eg5HoogbBxUo068wW7Hduda8WjBHYPC6Jokgy7wZQxqkH2gEeBlseVptr7Amk7+3NEGb3V/TmF9xTXMuqPu9AXCMlMCAF9KovKJRwFk0YPPGIqzzWBrgrRBG3bdqTX46Cq1IwvhfJ+igNeVMrNc2hJi4lawshfEKcJsElVvca+J5/TPrH8p05zFYnptqv0tnO0d48KLWpjZKfLw3P0yUfCp9EwNjX7O28Wq8HrA0/aCKatQsLEp/o0L9vYwVIyei28HlVerlA3RWcuykEObD4PdsTfnlPvE/6VUVB37rwUXon9dK0mvzHIkGSbtAX4/GQiPc3Gn676Bj06MDSCuciAGRkRKVEcF4+VmRdC08sJf0aaYKqqLU61nJYQwZJxgFGbVnfdg6wfMBNwydThW4pYKP7T20eEbZliulPQcX X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qJUinUlKDP8KBQ07YBgpL7N/uoa+V/qHmG+jh+DBTCR48EnYHFRdW+7alree+wptK8G9rsd8477d51Y7Vk4stskoLEHoq3e8vfg0wCNLZ2lRepM2Gc179DN8sIT4RAcY20uq4i2EpHr3/Vk33a5zAVgWrZff27OD7xphwbiF9f+f32i6UPZQDSCyKEobDOqisBTN171XTwFUlYIWciZgj7/C4r2scJUtdHoaBGF6RS0tl0wChTuAEIlpKkIQUkt/BdLyIfdvk+4ewEY144ztz6Q1Ve6N6lTBCF2c6oFTdw+5lMG9td5Dd5KTT1bYhWrzktBYtbkMURoMVwqVthcXFwPdYAmtS8bnn0OnciuO6wA0cPb2+O/zDQv8dBoAqEQZJhMygJSaJSBqsuuv2oTXGH/3xpdnQVAyImfF+k6R6exyGnSTlQwFlVu13RWhZIPHy+tpIqLLo/8L0BJugpIVu9pTsgasXlxuq1mwnW1XNUZsdsF2otGjwWzYNLBa+xDB5n0e4n2DHFDEKiBnmXDynvrzFs/7D3wTegMPFrXzkVqAKcJGofpXRXGHK4kMbh8/RvASTsBHCsrGPeYnUD6T/ql9KgoNEiHSZBBlwA/9knVLZFf8uRdIZ3/K8yIqEN024URJQ7nkj3nbw304y5YmaIiTHQNmEssEPHULGHYgAMj8UjbiilUwPJ54LTXm83AM4u3VDXGRE1Uoh/LMfUoROq74PyGpJ2Hy2tF4HPUb3T3EqIIoepflKCYIPpF9TzCQQi848BDzc2g9f6IUxfvseIJQUolzz2PBqi2079JhOhTIAVxnm5RGPmzM0kFp0NFcZ43TmYMUHoZNVzwgvB9dZgp4YvDXUukZ7nk2SOdLb9xR0Gn05wLKLD2R03EeodPfNQl1mkN/JHMHP1vU/9Ui41G6r6GcjLT0IG9VucTSniXFBarOnp8Y+DRxg/z4ssInbZzcLQfebYZzPzDg+iKBhg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 153ec003-7f5a-4708-3213-08d9e583eb62 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:20.3130 (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 44/69] avcodec/mpegvideo: Move ratecontrol parameters 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: uYxUG71vs3Kz All except vbv_ignore_qmax are only ever used by the main encoding thread. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo.h | 13 ------------- libavcodec/mpegvideo_enc.c | 4 ++-- libavcodec/mpegvideoenc.h | 31 ++++++++++++++++++++++--------- libavcodec/ratecontrol.c | 38 ++++++++++++++++++++------------------ libavcodec/snowenc.c | 6 +++--- 5 files changed, 47 insertions(+), 45 deletions(-) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 62347eff81..307964b10e 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -469,21 +469,8 @@ typedef struct MPVContext { int mpv_flags; ///< flags set by private options int quantizer_noise_shaping; - /** - * ratecontrol qmin qmax limiting method - * 0-> clipping, 1-> use a nice continuous function to limit qscale within qmin/qmax. - */ - float rc_qsquish; - float rc_qmod_amp; - int rc_qmod_freq; - float rc_initial_cplx; - float rc_buffer_aggressivity; - float border_masking; - int lmin, lmax; int vbv_ignore_qmax; - char *rc_eq; - /* temp buffers for rate control */ float *cplx_tab, *bits_tab; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index a1ea875546..da417acfae 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -408,7 +408,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) avctx->temporal_cplx_masking || avctx->spatial_cplx_masking || avctx->p_masking || - s->border_masking || + m->border_masking || (s->mpv_flags & FF_MPV_FLAG_QP_RD)) && !s->fixed_qscale; @@ -1748,7 +1748,7 @@ vbv_retry: int min_step = hq ? 1 : (1<<(FF_LAMBDA_SHIFT + 7))/139; if (put_bits_count(&s->pb) > max_size && - s->lambda < s->lmax) { + s->lambda < m->lmax) { m->next_lambda = FFMAX(s->lambda + min_step, s->lambda * (s->qscale + 1) / s->qscale); if (s->adaptive_quant) { diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index 350a1f70a6..86c86e0ddf 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -70,6 +70,19 @@ typedef struct MPVMainEncContext { 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 + /** + * ratecontrol qmin qmax limiting method + * 0-> clipping, 1-> use a nice continuous function to limit qscale within qmin/qmax. + */ + float rc_qsquish; + float rc_qmod_amp; + int rc_qmod_freq; + float rc_initial_cplx; + float rc_buffer_aggressivity; + float border_masking; + int lmin, lmax; + + char *rc_eq; /* temporary frames used by b_frame_strategy == 2 */ AVFrame *tmp_frames[MPVENC_MAX_B_FRAMES + 2]; @@ -125,19 +138,19 @@ FF_MPV_OPT_CMP_FUNC, \ { "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}, \ + FF_MPV_MAIN_OFFSET(rc_qsquish), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, 0, 99, FF_MPV_OPT_FLAGS}, \ +{"rc_qmod_amp", "experimental quantizer modulation", FF_MPV_MAIN_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_MAIN_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 }, \ + FF_MPV_MAIN_OFFSET(rc_eq), AV_OPT_TYPE_STRING, .flags = FF_MPV_OPT_FLAGS }, \ +{"rc_init_cplx", "initial complexity for 1-pass encoding", FF_MPV_MAIN_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_MAIN_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_MAIN_OFFSET(border_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ +{"lmin", "minimum Lagrange factor (VBR)", FF_MPV_MAIN_OFFSET(lmin), AV_OPT_TYPE_INT, {.i64 = 2*FF_QP2LAMBDA }, 0, INT_MAX, FF_MPV_OPT_FLAGS }, \ +{"lmax", "maximum Lagrange factor (VBR)", FF_MPV_MAIN_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" }, \ diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c index c41682b29c..fa28e6d61d 100644 --- a/libavcodec/ratecontrol.c +++ b/libavcodec/ratecontrol.c @@ -118,10 +118,12 @@ static double get_diff_limited_q(MPVMainEncContext *m, RateControlEntry *rce, do /** * Get the qmin & qmax for pict_type. */ -static void get_qminmax(int *qmin_ret, int *qmax_ret, MPVEncContext *s, int pict_type) +static void get_qminmax(int *qmin_ret, int *qmax_ret, + MPVMainEncContext *m, int pict_type) { - int qmin = s->lmin; - int qmax = s->lmax; + MPVEncContext *const s = &m->common; + int qmin = m->lmin; + int qmax = m->lmax; av_assert0(qmin <= qmax); @@ -158,13 +160,13 @@ static double modify_qscale(MPVMainEncContext *m, RateControlEntry *rce, const int pict_type = rce->new_pict_type; int qmin, qmax; - get_qminmax(&qmin, &qmax, s, pict_type); + get_qminmax(&qmin, &qmax, m, pict_type); /* modulation */ - if (s->rc_qmod_freq && - frame_num % s->rc_qmod_freq == 0 && + if (m->rc_qmod_freq && + frame_num % m->rc_qmod_freq == 0 && pict_type == AV_PICTURE_TYPE_P) - q *= s->rc_qmod_amp; + q *= m->rc_qmod_amp; /* buffer overflow/underflow protection */ if (buffer_size) { @@ -177,7 +179,7 @@ static double modify_qscale(MPVMainEncContext *m, RateControlEntry *rce, d = 1.0; else if (d < 0.0001) d = 0.0001; - q *= pow(d, 1.0 / s->rc_buffer_aggressivity); + q *= pow(d, 1.0 / m->rc_buffer_aggressivity); q_limit = bits2qp(rce, FFMAX((min_rate - buffer_size + rcc->buffer_index) * @@ -197,7 +199,7 @@ static double modify_qscale(MPVMainEncContext *m, RateControlEntry *rce, d = 1.0; else if (d < 0.0001) d = 0.0001; - q /= pow(d, 1.0 / s->rc_buffer_aggressivity); + q /= pow(d, 1.0 / m->rc_buffer_aggressivity); q_limit = bits2qp(rce, FFMAX(rcc->buffer_index * @@ -213,8 +215,8 @@ static double modify_qscale(MPVMainEncContext *m, RateControlEntry *rce, } ff_dlog(s, "q:%f max:%f min:%f size:%f index:%f agr:%f\n", q, max_rate, min_rate, buffer_size, rcc->buffer_index, - s->rc_buffer_aggressivity); - if (s->rc_qsquish == 0.0 || qmin == qmax) { + m->rc_buffer_aggressivity); + if (m->rc_qsquish == 0.0 || qmin == qmax) { if (q < qmin) q = qmin; else if (q > qmax) @@ -275,7 +277,7 @@ static double get_qscale(MPVMainEncContext *m, RateControlEntry *rce, bits = av_expr_eval(rcc->rc_eq_eval, const_values, rce); if (isnan(bits)) { - av_log(s->avctx, AV_LOG_ERROR, "Error evaluating rc_eq \"%s\"\n", s->rc_eq); + av_log(s->avctx, AV_LOG_ERROR, "Error evaluating rc_eq \"%s\"\n", m->rc_eq); return -1; } @@ -522,11 +524,11 @@ av_cold int ff_rate_control_init(MPVMainEncContext *m) } res = av_expr_parse(&rcc->rc_eq_eval, - s->rc_eq ? s->rc_eq : "tex^qComp", + m->rc_eq ? m->rc_eq : "tex^qComp", const_names, func1_names, func1, NULL, NULL, 0, s->avctx); if (res < 0) { - av_log(s->avctx, AV_LOG_ERROR, "Error parsing rc_eq \"%s\"\n", s->rc_eq); + av_log(s->avctx, AV_LOG_ERROR, "Error parsing rc_eq \"%s\"\n", m->rc_eq); return res; } @@ -627,9 +629,9 @@ av_cold int ff_rate_control_init(MPVMainEncContext *m) return -1; } /* init stuff with the user specified complexity */ - if (s->rc_initial_cplx) { + if (m->rc_initial_cplx) { for (i = 0; i < 60 * 30; i++) { - double bits = s->rc_initial_cplx * (i / 10000.0 + 1.0) * s->mb_num; + double bits = m->rc_initial_cplx * (i / 10000.0 + 1.0) * s->mb_num; RateControlEntry rce; if (i % ((m->gop_size + 3) / 4) == 0) @@ -753,7 +755,7 @@ static void adaptive_quantization(MPVMainEncContext *m, double q) const float temp_cplx_masking = s->avctx->temporal_cplx_masking; const float spatial_cplx_masking = s->avctx->spatial_cplx_masking; const float p_masking = s->avctx->p_masking; - const float border_masking = s->border_masking; + const float border_masking = m->border_masking; float bits_sum = 0.0; float cplx_sum = 0.0; float *cplx_tab = s->cplx_tab; @@ -895,7 +897,7 @@ float ff_rate_estimate_qscale(MPVMainEncContext *m, int dry_run) Picture * const pic = &s->current_picture; emms_c(); - get_qminmax(&qmin, &qmax, s, pict_type); + get_qminmax(&qmin, &qmax, m, pict_type); fps = get_fps(s->avctx); /* update predictors */ diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index 6ff0491a77..ce5baa754f 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -75,8 +75,8 @@ static av_cold int encode_init(AVCodecContext *avctx) mpv->avctx = avctx; mpv->bit_rate= avctx->bit_rate; - mpv->lmin = avctx->mb_lmin; - mpv->lmax = avctx->mb_lmax; + s->m.lmin = avctx->mb_lmin; + s->m.lmax = avctx->mb_lmax; mpv->mb_num = (avctx->width * avctx->height + 255) / 256; // For ratecontrol mpv->me.temp = @@ -1907,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.common.rc_eq), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VE }, + OFFSET(m.rc_eq), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VE }, { NULL }, }; From patchwork Tue Feb 1 13:06:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34059 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a0c:e44f:0:0:0:0:0 with SMTP id d15csp3768578qvm; Tue, 1 Feb 2022 05:19:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJxZpJ2S536N2s39nM5NxMGdB2GzKNTquYU/QYR7KLvAuEBLxQLpHNfzKHfU9t+/MiVwtCuC X-Received: by 2002:a17:907:7241:: with SMTP id ds1mr21652351ejc.199.1643721555833; Tue, 01 Feb 2022 05:19:15 -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 s7si9678691edq.265.2022.02.01.05.19.14; Tue, 01 Feb 2022 05:19:15 -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=fSp+mB62; 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 03E5368B3FF; Tue, 1 Feb 2022 15:08:55 +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 C82C468B3A8 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=RIq7oabks8BtW1ixFqz0Qn/ahUh72O52jFMD9D3uf/2ujLfVcl7gTOHNskctpNZ8n9A98ZH22GLOBuiZobGLJW8eWi+bG0lmkbZYC5kbApCXykVqMSrrQVQFpEVuqdo3AVvJP0rloEjtCTkFffLQSRZ/HmYDHKxcbng1FjuwqUKOBVpVXDeWnPRx5Nnj2Eiux9L+oSjZ9Nf9Vpxklw7a3Dltp2DwE5qgHzQ+opaaojswgJ26mi2jgACF3dI7i96VQJaK8SOQpTXVv76kX0zp0DQP3flnrZUR37mtP3wlzd34p2RkMgTxLK8u0c/q0Yd9ZL+T9rjSLnzb7panygcZPg== 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=Y6SV4GGHzzAqztA45nhQeJjo7pWYMmRykJvkPalxQDA=; b=APtMlhqUCKoQIPQZHWrJMHdr2xeRtfPRotLleyVZkFIfZglml5hRAMLfuhfJm84bqb1RdH2i+vkEPHQg2nxnydSililmX0HBRvp46GWQScrI9UAV3BuhCjjrewBVhRQUGyI/Urfe52vZHMS/0EXmVBnYZcA5RpOnEcHxk0otWXn8OPuOt7gKg1+F2mJycbYK4j4LqR/Tfq16aIACW1oNChS7X2ZpSot2/H474POOldQ5BvTWxGP3nWqStGfL1vHMyCyFYal26fJGixNMR9avHTuVb1C8A0KoM8QisrgH/y+E3zEX4w/eQ/3TGSHjZY+2uofeGSCJTVh59KH449S3rg== 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=Y6SV4GGHzzAqztA45nhQeJjo7pWYMmRykJvkPalxQDA=; b=fSp+mB62Fg2+Jl9z71/JNW5Q2DVJV+OhIybrfFb4m6HqMRkrEqNhdAcm7IjgYbrjdD26oFz3hr0wI2m/qTvSeHqAJoRMRXQUtSp+vcHwoTQu5lF3opEdpHlkF+8zhwyxab0FXax3UOC0iC4v0uWZKXT/dznbZrgrpAm3oGpV2lxZWBvZyXa42B9Gm3zLWIi+Bk1LQ1jM5FLqKilp8QSrKk1mBk5+Dl3lqZLAbywpdzOfv683pGqmrYlqVO1o+rbZXYmiPIgGl5DThp3lS1V7vIxmBSATWztTanFQfyGL5geYP8yIo5Ipqnk30IsyJ14cQd/IeHY6smzzo0pTsyZbUg== 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: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:08:37 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:42 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [byfjDtpnm+tEGoDqbrwULOOUrD/chU8b] 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-44-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 40928543-2558-4898-748c-08d9e583ebec X-MS-TrafficTypeDiagnostic: HE1PR0301MB2330:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EUfHg2WLb/dxrG8mDzJ3J4Zm7tgxJf6ew0gFGpgWRbCUqkpq8EAk9L8xhnZ91g9hKN9c7JA+alWeUDCY65BcRrfnJ/ljou5BP3S/8Z/oForp+m6SP6TqrtlZpP5bWGFNsdY9CS0pHd5RRCbsu63IdHNvn+KmFlRd2gMepT8Gf6xsrOJeNsOS1zMv62sxsPINZvlCSizAp3qSwwJNZ61eBz6k/jJrnmvgrCqdXNSIb2I1EIz8mY5GrqpbPYCxYo2MCegy0IH57jZTCR+SybTCRLMzLH6qtK6ZMkcC6+w+CC9S+j+qjEMX45dWVthkvKj5pIJqqzrdvDc5czcOuwqf0GuOyaz+bJ+hDDND+zYq/FV6cFbaDv4KdZkWXI0pX0CxRRkHqqHYFEpO1bwu+dtq6i08A3fHGRgtDjDYoorcFYM81qlEP6iTP5ALpU7zvIejvpmuE7SUTey8yqOvxhq/AdFQixqyWpTOzrFhuKQtFe69IJbx3e8KY9qrj/apJxdqJY70e52EjgVixgTKlssM9L1Xqz5Q1HWdpsq4UuwhoXimmPksSqMGjdOvrrk6Lzcf X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BRYM5oW4YZhEc3YoGaVCcfPbhujeADqgv52zeJyAGneUkZMWri1oeYoxB4RdcEQvV/q4boQhK8qItuf3GNBPU7y9jnLsliEkMcw5p6ZAYNg1aO8vqGFuDZVcScd1ldKeXZd6FbegfdVviTM6EDXkpEfUmRtcu3ethbklp4/25tKvJwi+za9ObWDshnC/L63zklompUx+Wa9jzWPj8GOlJsBvyXiXyusH9pTRcWCXp2NQb4EAejvd/mr+wCMdAg3TL5bX2mpyRrlyYdk1sYvLmalFLC668Rco6lEw2AnqR+qRrn7K4cQUtGYHm6gRIlwIoq4s8uSBbxz6hI7oSPHZACUtrD3JRDT0BdxJEc5w3ayH29O39ZDkiFtVnooNxd3sHXz3PWJrQe7RnJSYRy5sZrHcl/7SJyvt7xmaUzNzxyWcOCVy15PuRO/zl3yuqZxKEHbRyJk2jsYIkFGqEedKh+5CDOiD4ZxlhjTg1nsTy8IlmK1jmN2SK8JsvIE1BlqqaTq2UcOdhAR8aFlFzyeHqEITkfNBxTOQ5m1fFgX1ubEDq2Qi6sjlxdHf7XzVsee4+MGitArxLofqMlD5F8S4glNBEUcYfVUpbQdFzw5Mw93wpdXwzj8IahXaB55HcnzluPsmMfQOHSHeKzKeOGyO7/duU3GWoDgY+2kAdsWN2Kq3OmusH02YgREIRdPTc/hVllti1fGfTyUoL6p+v7XtOl7ANp8Vj4hJPzVAdXLpvHeswWdh25RYFpWCcmEgbb2or6DHqr1YdIIiRmtLJ/Rxx2ie+Ig2A6aypF/Ww5dXUdstbB2u8I+r0pWMOceztirJ7eNWAZIgjUJykIDcu9UWzNi6bjN1qVxcZlk9C0iTd2GfPyp/XkFRtrnxsjJ7Y2ONOiOUmJTVn4NuRo7KogzzPXqhxnDZUzBoSUDSSfg1LGWiUdtj3pkKBlPIjamTMJdoI5e3FpJAxWciRyivuqLL8A== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 40928543-2558-4898-748c-08d9e583ebec 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:21.2972 (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 45/69] avcodec/mpegvideo: Allocate encoder-only tables in mpegvideo_enc.c 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: zDRvhG+f/Qdp Content-Length: 12360 This commit moves the encoder-only allocations of the tables owned solely by the main encoder context to mpegvideo_enc.c. This avoids checks in mpegvideo.c for whether we are dealing with an encoder; it also improves modularity (if encoders are disabled, this code will no longer be included in the binary). And it also avoids having to reset these pointers at the beginning of ff_mpv_common_init() (in case the dst context is uninitialized, ff_mpeg_update_thread_context() simply copies the src context into dst which therefore may contain pointers not owned by it, but this does not happen for encoders at all). Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo.c | 118 +++---------------------------------- libavcodec/mpegvideo_enc.c | 68 ++++++++++++++++++++- 2 files changed, 74 insertions(+), 112 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 88cd9bc6ed..5a68a7cf07 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -557,61 +557,13 @@ int ff_mpv_init_context_frame(MPVMainContext *s) s->mb_index2xy[s->mb_height * s->mb_width] = (s->mb_height - 1) * s->mb_stride + s->mb_width; // FIXME really needed? - if (s->encoding) { - /* Allocate MV tables */ - if (!FF_ALLOCZ_TYPED_ARRAY(s->p_mv_table_base, mv_table_size) || - !FF_ALLOCZ_TYPED_ARRAY(s->b_forw_mv_table_base, mv_table_size) || - !FF_ALLOCZ_TYPED_ARRAY(s->b_back_mv_table_base, mv_table_size) || - !FF_ALLOCZ_TYPED_ARRAY(s->b_bidir_forw_mv_table_base, mv_table_size) || - !FF_ALLOCZ_TYPED_ARRAY(s->b_bidir_back_mv_table_base, mv_table_size) || - !FF_ALLOCZ_TYPED_ARRAY(s->b_direct_mv_table_base, mv_table_size)) - return AVERROR(ENOMEM); - s->p_mv_table = s->p_mv_table_base + s->mb_stride + 1; - s->b_forw_mv_table = s->b_forw_mv_table_base + s->mb_stride + 1; - s->b_back_mv_table = s->b_back_mv_table_base + s->mb_stride + 1; - s->b_bidir_forw_mv_table = s->b_bidir_forw_mv_table_base + s->mb_stride + 1; - s->b_bidir_back_mv_table = s->b_bidir_back_mv_table_base + s->mb_stride + 1; - s->b_direct_mv_table = s->b_direct_mv_table_base + s->mb_stride + 1; - - /* Allocate MB type table */ - if (!FF_ALLOCZ_TYPED_ARRAY(s->mb_type, mb_array_size) || - !FF_ALLOCZ_TYPED_ARRAY(s->lambda_table, mb_array_size) || - !FF_ALLOC_TYPED_ARRAY (s->cplx_tab, mb_array_size) || - !FF_ALLOC_TYPED_ARRAY (s->bits_tab, mb_array_size)) - return AVERROR(ENOMEM); - -#define ALLOCZ_ARRAYS(p, mult, numb) ((p) = av_calloc(numb, mult * sizeof(*(p)))) - if (s->codec_id == AV_CODEC_ID_MPEG4 || - (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_ME)) { - int16_t (*tmp1)[2]; - uint8_t *tmp2; - if (!(tmp1 = ALLOCZ_ARRAYS(s->b_field_mv_table_base, 8, mv_table_size)) || - !(tmp2 = ALLOCZ_ARRAYS(s->b_field_select_table[0][0], 2 * 4, mv_table_size)) || - !ALLOCZ_ARRAYS(s->p_field_select_table[0], 2 * 2, mv_table_size)) - return AVERROR(ENOMEM); - - s->p_field_select_table[1] = s->p_field_select_table[0] + 2 * mv_table_size; - tmp1 += s->mb_stride + 1; - - for (int i = 0; i < 2; i++) { - for (int j = 0; j < 2; j++) { - for (int k = 0; k < 2; k++) { - s->b_field_mv_table[i][j][k] = tmp1; - tmp1 += mv_table_size; - } - s->b_field_select_table[i][j] = tmp2; - tmp2 += 2 * mv_table_size; - } - } - } - } - if (s->codec_id == AV_CODEC_ID_MPEG4 || (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_ME)) { - int16_t (*tmp)[2]; /* interlaced direct mode decoding tables */ - if (!(tmp = ALLOCZ_ARRAYS(s->p_field_mv_table_base, 4, mv_table_size))) + int16_t (*tmp)[2] = av_calloc(mv_table_size, 4 * sizeof(*tmp)); + if (!tmp) return AVERROR(ENOMEM); + s->p_field_mv_table_base = tmp; tmp += s->mb_stride + 1; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { @@ -654,8 +606,6 @@ int ff_mpv_init_context_frame(MPVMainContext *s) static void clear_context(MPVMainContext *s) { - int i, j, k; - memset(&s->next_picture, 0, sizeof(s->next_picture)); memset(&s->last_picture, 0, sizeof(s->last_picture)); memset(&s->current_picture, 0, sizeof(s->current_picture)); @@ -684,31 +634,10 @@ static void clear_context(MPVMainContext *s) s->bitstream_buffer = NULL; s->allocated_bitstream_buffer_size = 0; s->picture = NULL; - s->mb_type = NULL; - s->p_mv_table_base = NULL; - s->b_forw_mv_table_base = NULL; - s->b_back_mv_table_base = NULL; - s->b_bidir_forw_mv_table_base = NULL; - s->b_bidir_back_mv_table_base = NULL; - s->b_direct_mv_table_base = NULL; - s->p_mv_table = NULL; - s->b_forw_mv_table = NULL; - s->b_back_mv_table = NULL; - s->b_bidir_forw_mv_table = NULL; - s->b_bidir_back_mv_table = NULL; - s->b_direct_mv_table = NULL; - s->b_field_mv_table_base = NULL; s->p_field_mv_table_base = NULL; - for (i = 0; i < 2; i++) { - for (j = 0; j < 2; j++) { - for (k = 0; k < 2; k++) { - s->b_field_mv_table[i][j][k] = NULL; - } - s->b_field_select_table[i][j] = NULL; + for (int i = 0; i < 2; i++) + for (int j = 0; j < 2; j++) s->p_field_mv_table[i][j] = NULL; - } - s->p_field_select_table[i] = NULL; - } s->dc_val_base = NULL; s->coded_block_base = NULL; @@ -721,10 +650,6 @@ static void clear_context(MPVMainContext *s) s->er.error_status_table = NULL; s->er.er_temp_buffer = NULL; s->mb_index2xy = NULL; - s->lambda_table = NULL; - - s->cplx_tab = NULL; - s->bits_tab = NULL; } /** @@ -820,37 +745,12 @@ av_cold int ff_mpv_common_init(MPVMainContext *s) void ff_mpv_free_context_frame(MPVMainContext *s) { - int i, j, k; - free_duplicate_contexts(s); - av_freep(&s->mb_type); - av_freep(&s->p_mv_table_base); - av_freep(&s->b_forw_mv_table_base); - av_freep(&s->b_back_mv_table_base); - av_freep(&s->b_bidir_forw_mv_table_base); - av_freep(&s->b_bidir_back_mv_table_base); - av_freep(&s->b_direct_mv_table_base); - s->p_mv_table = NULL; - s->b_forw_mv_table = NULL; - s->b_back_mv_table = NULL; - s->b_bidir_forw_mv_table = NULL; - s->b_bidir_back_mv_table = NULL; - s->b_direct_mv_table = NULL; - av_freep(&s->b_field_mv_table_base); - av_freep(&s->b_field_select_table[0][0]); av_freep(&s->p_field_mv_table_base); - av_freep(&s->p_field_select_table[0]); - for (i = 0; i < 2; i++) { - for (j = 0; j < 2; j++) { - for (k = 0; k < 2; k++) { - s->b_field_mv_table[i][j][k] = NULL; - } - s->b_field_select_table[i][j] = NULL; + for (int i = 0; i < 2; i++) + for (int j = 0; j < 2; j++) s->p_field_mv_table[i][j] = NULL; - } - s->p_field_select_table[i] = NULL; - } av_freep(&s->dc_val_base); av_freep(&s->coded_block_base); @@ -863,10 +763,6 @@ void ff_mpv_free_context_frame(MPVMainContext *s) av_freep(&s->er.error_status_table); av_freep(&s->er.er_temp_buffer); av_freep(&s->mb_index2xy); - av_freep(&s->lambda_table); - - av_freep(&s->cplx_tab); - av_freep(&s->bits_tab); s->linesize = s->uvlinesize = 0; } diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index da417acfae..1739472352 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -319,7 +319,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) MPVMainEncContext *const m = avctx->priv_data; MPVMainContext *const s = &m->common; AVCPBProperties *cpb_props; - int i, ret; + int i, ret, mv_table_size, mb_array_size; mpv_encode_defaults(m); @@ -820,6 +820,56 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) ff_pixblockdsp_init(&s->pdsp, avctx); ff_qpeldsp_init(&s->qdsp); + /* Allocate MV tables; the MV and MB tables will be copied + * to slice contexts by ff_update_duplicate_context(). */ + mv_table_size = (s->mb_height + 2) * s->mb_stride + 1; + if (!FF_ALLOCZ_TYPED_ARRAY(s->p_mv_table_base, mv_table_size) || + !FF_ALLOCZ_TYPED_ARRAY(s->b_forw_mv_table_base, mv_table_size) || + !FF_ALLOCZ_TYPED_ARRAY(s->b_back_mv_table_base, mv_table_size) || + !FF_ALLOCZ_TYPED_ARRAY(s->b_bidir_forw_mv_table_base, mv_table_size) || + !FF_ALLOCZ_TYPED_ARRAY(s->b_bidir_back_mv_table_base, mv_table_size) || + !FF_ALLOCZ_TYPED_ARRAY(s->b_direct_mv_table_base, mv_table_size)) + return AVERROR(ENOMEM); + s->p_mv_table = s->p_mv_table_base + s->mb_stride + 1; + s->b_forw_mv_table = s->b_forw_mv_table_base + s->mb_stride + 1; + s->b_back_mv_table = s->b_back_mv_table_base + s->mb_stride + 1; + s->b_bidir_forw_mv_table = s->b_bidir_forw_mv_table_base + s->mb_stride + 1; + s->b_bidir_back_mv_table = s->b_bidir_back_mv_table_base + s->mb_stride + 1; + s->b_direct_mv_table = s->b_direct_mv_table_base + s->mb_stride + 1; + + /* Allocate MB type table */ + mb_array_size = s->mb_height * s->mb_stride; + if (!FF_ALLOCZ_TYPED_ARRAY(s->mb_type, mb_array_size) || + !FF_ALLOCZ_TYPED_ARRAY(s->lambda_table, mb_array_size) || + !FF_ALLOC_TYPED_ARRAY (s->cplx_tab, mb_array_size) || + !FF_ALLOC_TYPED_ARRAY (s->bits_tab, mb_array_size)) + return AVERROR(ENOMEM); + +#define ALLOCZ_ARRAYS(p, mult, numb) ((p) = av_calloc(numb, mult * sizeof(*(p)))) + if (s->codec_id == AV_CODEC_ID_MPEG4 || + (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_ME)) { + int16_t (*tmp1)[2]; + uint8_t *tmp2; + if (!(tmp1 = ALLOCZ_ARRAYS(s->b_field_mv_table_base, 8, mv_table_size)) || + !(tmp2 = ALLOCZ_ARRAYS(s->b_field_select_table[0][0], 2 * 4, mv_table_size)) || + !ALLOCZ_ARRAYS(s->p_field_select_table[0], 2 * 2, mv_table_size)) + return AVERROR(ENOMEM); + + s->p_field_select_table[1] = s->p_field_select_table[0] + 2 * mv_table_size; + tmp1 += s->mb_stride + 1; + + for (int i = 0; i < 2; i++) { + for (int j = 0; j < 2; j++) { + for (int k = 0; k < 2; k++) { + s->b_field_mv_table[i][j][k] = tmp1; + tmp1 += mv_table_size; + } + s->b_field_select_table[i][j] = tmp2; + tmp2 += 2 * mv_table_size; + } + } + } + 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) || @@ -945,6 +995,22 @@ av_cold int ff_mpv_encode_end(AVCodecContext *avctx) av_freep(&avctx->stats_out); + av_freep(&s->p_mv_table_base); + av_freep(&s->b_forw_mv_table_base); + av_freep(&s->b_back_mv_table_base); + av_freep(&s->b_bidir_forw_mv_table_base); + av_freep(&s->b_bidir_back_mv_table_base); + av_freep(&s->b_direct_mv_table_base); + av_freep(&s->b_field_mv_table_base); + av_freep(&s->b_field_select_table[0][0]); + av_freep(&s->p_field_select_table[0]); + + av_freep(&s->mb_type); + av_freep(&s->lambda_table); + + av_freep(&s->cplx_tab); + av_freep(&s->bits_tab); + 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); s->q_chroma_intra_matrix= NULL; From patchwork Tue Feb 1 13:06:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34015 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp608434iov; Tue, 1 Feb 2022 05:17:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJzlCDD8OOKvDQ8pCcPYpnZMX8QBeNU/ya5hQuSMzvCXrqOvyTE6zE/Yu7ym0yfF5MDAfKA6 X-Received: by 2002:a17:906:1d14:: with SMTP id n20mr20935989ejh.714.1643721432717; Tue, 01 Feb 2022 05:17:12 -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 he20si7496262ejc.771.2022.02.01.05.17.11; Tue, 01 Feb 2022 05:17:12 -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=Ia9PMz5D; 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 4ADF868B3AA; Tue, 1 Feb 2022 15:08:47 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2064.outbound.protection.outlook.com [40.92.91.64]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6FEC168B388 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=QI0Iel1Si+8i4LIm0fUVsKNIKaawBps1D6dbG+s8apqo59/ms0K7DuAI/DS8ge+2AJwYBomPEcLahhXoDU4CgX0j6On7nuf2JuKBWZhT0LdsQdVD53cZ2Omv/k0cOK0xRcRp11pxWqs0vG++iyGki9eizmIi0Km6UEGR69k/6waBbvRbsmo3C0N3OjWkfpnEXV9PshOUGGVvZsphFfwr950LRULsOWm93ckxi+itnbxCK3QjqWMueZxnK9MR+6uHS8q6ax64TPU8nTt28oTdkREK7drtGf5mHAtV0xYkwSw8aXp15tJjpCmtR4lfOxyRyI2fYPD0Zy2mjlELdX2bOw== 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=0M4Cbf8y89pumiEouTDl8EYkfry3aVGZZNIeZA+rtI8=; b=IaXcszz5mVYyO1x/23fcXLy3ilzRDkeSc4rds4S4B1fbiqdjB/Nug4227Z7ZTvVzwVrZ+JGuldHwmaM7assbAV/i57Eyu8kbTdKQsIoUDBgyYHr7FniFtvTJG50w+1mmATgdX4mU4JtDgnmN22PeVmSeheO/iwXVOT+07zn6/mxxQmUHdTr1vGd/Ujn6pSpnVQzWtjXzPo49W2qmZSHCDM/DXuLeIIYKuQH7YGNQeKcQ9apSlrAAs5Q2FZMZ+dKltOBHV+d2F+By+/2sM7MitWJFVdEzbfvF9VFZfLP8JNwjaU0gMoOuFO3aJbCkIgwLcjAdddMTGTEkZiGV5r4XCQ== 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=0M4Cbf8y89pumiEouTDl8EYkfry3aVGZZNIeZA+rtI8=; b=Ia9PMz5DFKP4V8uK1SHCY8aCJQzQP0407HQ/xRVHdc/3y+Q7CM4/QnpUY370NUhVmVF8zJJ8R2Dy/bD22RyD342i6+sPtCUixIHaAPCM2vkrbMO2SGbfLxHcBUhJPtFWWMtSaCHgBnIA4EAULicsA6k5WZGouGwkxIDStEWEaNeZ1F+v4oT0TQ0zES0H5NflbzKiXBxXwS4b+D5Jqbxwy3HzY/xS4UE+h8sdWCuGe44dkld9CNbeLzLcaMkoDRp+46RANKlHAqebuXPKO3AbZZoUQulQ+/DSxr8qyv2fyJ7I7siSmKdMwYwGKr6nO1cx2RemMFSgdb9NhWoXjtqSPg== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM9PR03MB7962.eurprd03.prod.outlook.com (2603:10a6:20b:439::17) 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: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:08:38 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:43 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [NEQDE5bUEtqZY79OaEB30H4ULDAkyogF] 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-45-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: df731c87-b192-42b1-9474-08d9e583ecc5 X-MS-TrafficTypeDiagnostic: AM9PR03MB7962:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Oiy+VU1MGOrKmDaCPs4mBvV7CoRZPkPBAIfF4FbIrw1xms7FjhsHXShUn+QEPHKDnMcnRwxxWpa/PrMWdxK0bgUi0E6nKr6kNea5Y1k2boP+g+faEPMsH8Fh6xjSdf4wuQBFmNpANN6TIo4sjHicoLkLEEfQ4gNor/VcsVtvTErZCU2GvfXwYQhCyxuHC5jWcav9P4/i4x27VH5MnZ3xmaBiJ0qnWBKVQQdbucO1K3BfbjYBtYBPy1twvZe7bVuUx5xkPpPIy4DHBiyku1G3YesXDe4nwChcX+UlC3R8NIMp0LMfH7tqyzObc8kyfVYdN/CmyQpqoj0hfNNtn4x/HfCsz3vQeYM9+5+wcywOV+CZkH9OZqW46giZXBrd6t14K6akC4t31XhOCgA2spKo7Qw5nZUlz1KdSOVTsQtuZqqcGxTh0cF1Z1+yOXvbNO7A5VphxoZk3ftKfUgPz47OW5HQdWoS5aPoxH8u2odU9Ob1/j2xqYPTL5NCBNUBo/n8aQiW9T2/vI9ZpcMI25VYP+gKfV3V/c/Jzd8Lujx2iftuo+PI88dSyrSeeLVPDUnB X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uanMWmkYwV/S2xp2zAuMZHuXhHWAJZgtREmRkEGjda1rFe5VyqGFxT5/QW99SFRVeLGYTKMAet8pzux9ovAIyVoW+z7GkE9oC0n3wfv6JhOEW4vOOvamwkO/QTc/QB6SnL/GCjE5GE5XGvrJ6yIiVM+XK60PfhKl4ETNsGqCD+BCFOKedmXHoPM7VnFVB7wbmqeWRpj8We6kA8VeHXAA+5CpWEp9CKzrKhTW8o+4PjUyVwiHiWCpAU3+fBBLekZjdcWzM5Yo9HAC4VxNAPiqPsW8ZF92HyUcgIcjC16D7slK5YY6ogF0KTMe/RdLo1awmpuZ/C08ivpE54s7N/U5jpgs9Hij8OT5cT0hjDBzt0kAC78H/Dgf1/ysomyn74lD8o8FOkN3DVbHoP7q90vdzWD/XVPi5D1A6qqId7XHYX4cA34miC0vH13BKCiOwMIFSrQq56XoTK3zjzf8RTq+Zu7o1xuzdWppQbSpcV7mN67SmKtc6EpqiRflrcfLSipnrOMwTayWbesXsrz1F1x513wXawZLYG5glIBwFoxJlQfnlG96eSN50PzzW1M2XvyV4kMXLFafi3ltg3JCm+pKI167ODXnXMi1u4TCgMSQ3LsvbEnsao/ycYs2y/linrSX7Vr5FXmEKCFtaakBUozKvAdaqnrgBliOkW0HXKNiS8VSnJQgGsIUGuwAPr/GrD8JVnuM4iyxh8dyETeib3ekx5xbOJk4RzdBbQnV5mC9fKGnBvmXiXPpRqtVeQsWTlWjihIZmZrSu3XkYn4Suy6x3pEa0bhGV9AxItzbjSYD/J6CmIGk3TV1vtOjt39zjER4F8QN1PEs6HelJWhTjVUViND2Ss6EpFvO9MimvNe6UH9wYmZ65Jl9zdB0YwJtVYjRfECH46SARsiXqnX4lWUcvlxrS2txL8f++9I7mKYqzAk/z09RYh8hGnFnPrmQoNW+10pXUbSpr4QInCT4EqdFPA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: df731c87-b192-42b1-9474-08d9e583ecc5 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:22.6265 (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: AM9PR03MB7962 Subject: [FFmpeg-devel] [PATCH v2 46/69] avcodec/mpegvideo: Move encoder-only base-arrays 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: KJ6diioplRgr Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo.h | 10 -------- libavcodec/mpegvideo_enc.c | 48 +++++++++++++++++++------------------- libavcodec/mpegvideoenc.h | 11 +++++++++ libavcodec/ratecontrol.c | 4 ++-- 4 files changed, 37 insertions(+), 36 deletions(-) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 307964b10e..0d6b79fe5d 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -200,14 +200,7 @@ typedef struct MPVContext { H263DSPContext h263dsp; int f_code; ///< forward MV resolution int b_code; ///< backward MV resolution for B-frames (MPEG-4) - int16_t (*p_mv_table_base)[2]; - int16_t (*b_forw_mv_table_base)[2]; - int16_t (*b_back_mv_table_base)[2]; - int16_t (*b_bidir_forw_mv_table_base)[2]; - int16_t (*b_bidir_back_mv_table_base)[2]; - int16_t (*b_direct_mv_table_base)[2]; int16_t (*p_field_mv_table_base)[2]; - int16_t (*b_field_mv_table_base)[2]; int16_t (*p_mv_table)[2]; ///< MV table (1MV per MB) P-frame encoding int16_t (*b_forw_mv_table)[2]; ///< MV table (1MV per MB) forward mode B-frame encoding int16_t (*b_back_mv_table)[2]; ///< MV table (1MV per MB) backward mode B-frame encoding @@ -471,9 +464,6 @@ typedef struct MPVContext { int vbv_ignore_qmax; - /* temp buffers for rate control */ - float *cplx_tab, *bits_tab; - /* flag to indicate a reinitialization is required, e.g. after * a frame size change */ int context_reinit; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 1739472352..8b2de4770b 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -823,26 +823,26 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) /* Allocate MV tables; the MV and MB tables will be copied * to slice contexts by ff_update_duplicate_context(). */ mv_table_size = (s->mb_height + 2) * s->mb_stride + 1; - if (!FF_ALLOCZ_TYPED_ARRAY(s->p_mv_table_base, mv_table_size) || - !FF_ALLOCZ_TYPED_ARRAY(s->b_forw_mv_table_base, mv_table_size) || - !FF_ALLOCZ_TYPED_ARRAY(s->b_back_mv_table_base, mv_table_size) || - !FF_ALLOCZ_TYPED_ARRAY(s->b_bidir_forw_mv_table_base, mv_table_size) || - !FF_ALLOCZ_TYPED_ARRAY(s->b_bidir_back_mv_table_base, mv_table_size) || - !FF_ALLOCZ_TYPED_ARRAY(s->b_direct_mv_table_base, mv_table_size)) + if (!FF_ALLOCZ_TYPED_ARRAY(m->p_mv_table_base, mv_table_size) || + !FF_ALLOCZ_TYPED_ARRAY(m->b_forw_mv_table_base, mv_table_size) || + !FF_ALLOCZ_TYPED_ARRAY(m->b_back_mv_table_base, mv_table_size) || + !FF_ALLOCZ_TYPED_ARRAY(m->b_bidir_forw_mv_table_base, mv_table_size) || + !FF_ALLOCZ_TYPED_ARRAY(m->b_bidir_back_mv_table_base, mv_table_size) || + !FF_ALLOCZ_TYPED_ARRAY(m->b_direct_mv_table_base, mv_table_size)) return AVERROR(ENOMEM); - s->p_mv_table = s->p_mv_table_base + s->mb_stride + 1; - s->b_forw_mv_table = s->b_forw_mv_table_base + s->mb_stride + 1; - s->b_back_mv_table = s->b_back_mv_table_base + s->mb_stride + 1; - s->b_bidir_forw_mv_table = s->b_bidir_forw_mv_table_base + s->mb_stride + 1; - s->b_bidir_back_mv_table = s->b_bidir_back_mv_table_base + s->mb_stride + 1; - s->b_direct_mv_table = s->b_direct_mv_table_base + s->mb_stride + 1; + s->p_mv_table = m->p_mv_table_base + s->mb_stride + 1; + s->b_forw_mv_table = m->b_forw_mv_table_base + s->mb_stride + 1; + s->b_back_mv_table = m->b_back_mv_table_base + s->mb_stride + 1; + s->b_bidir_forw_mv_table = m->b_bidir_forw_mv_table_base + s->mb_stride + 1; + s->b_bidir_back_mv_table = m->b_bidir_back_mv_table_base + s->mb_stride + 1; + s->b_direct_mv_table = m->b_direct_mv_table_base + s->mb_stride + 1; /* Allocate MB type table */ mb_array_size = s->mb_height * s->mb_stride; if (!FF_ALLOCZ_TYPED_ARRAY(s->mb_type, mb_array_size) || !FF_ALLOCZ_TYPED_ARRAY(s->lambda_table, mb_array_size) || - !FF_ALLOC_TYPED_ARRAY (s->cplx_tab, mb_array_size) || - !FF_ALLOC_TYPED_ARRAY (s->bits_tab, mb_array_size)) + !FF_ALLOC_TYPED_ARRAY (m->cplx_tab, mb_array_size) || + !FF_ALLOC_TYPED_ARRAY (m->bits_tab, mb_array_size)) return AVERROR(ENOMEM); #define ALLOCZ_ARRAYS(p, mult, numb) ((p) = av_calloc(numb, mult * sizeof(*(p)))) @@ -850,7 +850,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_ME)) { int16_t (*tmp1)[2]; uint8_t *tmp2; - if (!(tmp1 = ALLOCZ_ARRAYS(s->b_field_mv_table_base, 8, mv_table_size)) || + if (!(tmp1 = ALLOCZ_ARRAYS(m->b_field_mv_table_base, 8, mv_table_size)) || !(tmp2 = ALLOCZ_ARRAYS(s->b_field_select_table[0][0], 2 * 4, mv_table_size)) || !ALLOCZ_ARRAYS(s->p_field_select_table[0], 2 * 2, mv_table_size)) return AVERROR(ENOMEM); @@ -995,21 +995,21 @@ av_cold int ff_mpv_encode_end(AVCodecContext *avctx) av_freep(&avctx->stats_out); - av_freep(&s->p_mv_table_base); - av_freep(&s->b_forw_mv_table_base); - av_freep(&s->b_back_mv_table_base); - av_freep(&s->b_bidir_forw_mv_table_base); - av_freep(&s->b_bidir_back_mv_table_base); - av_freep(&s->b_direct_mv_table_base); - av_freep(&s->b_field_mv_table_base); + av_freep(&m->p_mv_table_base); + av_freep(&m->b_forw_mv_table_base); + av_freep(&m->b_back_mv_table_base); + av_freep(&m->b_bidir_forw_mv_table_base); + av_freep(&m->b_bidir_back_mv_table_base); + av_freep(&m->b_direct_mv_table_base); + av_freep(&m->b_field_mv_table_base); av_freep(&s->b_field_select_table[0][0]); av_freep(&s->p_field_select_table[0]); av_freep(&s->mb_type); av_freep(&s->lambda_table); - av_freep(&s->cplx_tab); - av_freep(&s->bits_tab); + av_freep(&m->cplx_tab); + av_freep(&m->bits_tab); 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/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index 86c86e0ddf..e124555b0a 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -84,11 +84,22 @@ typedef struct MPVMainEncContext { char *rc_eq; + /* temp buffers for rate control */ + float *cplx_tab, *bits_tab; + /* temporary frames used by b_frame_strategy == 2 */ AVFrame *tmp_frames[MPVENC_MAX_B_FRAMES + 2]; int b_frame_strategy; int b_sensitivity; int brd_scale; + + int16_t (*p_mv_table_base)[2]; + int16_t (*b_forw_mv_table_base)[2]; + int16_t (*b_back_mv_table_base)[2]; + int16_t (*b_bidir_forw_mv_table_base)[2]; + int16_t (*b_bidir_back_mv_table_base)[2]; + int16_t (*b_direct_mv_table_base)[2]; + int16_t (*b_field_mv_table_base)[2]; } MPVMainEncContext; #define UNI_AC_ENC_INDEX(run,level) ((run)*128 + (level)) diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c index fa28e6d61d..bbaa9191a0 100644 --- a/libavcodec/ratecontrol.c +++ b/libavcodec/ratecontrol.c @@ -758,8 +758,8 @@ static void adaptive_quantization(MPVMainEncContext *m, double q) const float border_masking = m->border_masking; float bits_sum = 0.0; float cplx_sum = 0.0; - float *cplx_tab = s->cplx_tab; - float *bits_tab = s->bits_tab; + float *cplx_tab = m->cplx_tab; + float *bits_tab = m->bits_tab; const int qmin = s->avctx->mb_lmin; const int qmax = s->avctx->mb_lmax; Picture *const pic = &s->current_picture; From patchwork Tue Feb 1 13:06:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34017 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp608787iov; Tue, 1 Feb 2022 05:17:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJwfqQV0m07tZZgaI4u2SfYqMqJF9abfYLut4+8r+Ux2/TR8Qp0oja0pDNY8fJOvJaYPDMrC X-Received: by 2002:a05:6402:548:: with SMTP id i8mr25092283edx.60.1643721460701; Tue, 01 Feb 2022 05:17: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 f2si8332242ejk.839.2022.02.01.05.17.39; Tue, 01 Feb 2022 05:17: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=R6LE8J4i; 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 16F8668AC87; Tue, 1 Feb 2022 15:08:49 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2064.outbound.protection.outlook.com [40.92.91.64]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8B11668B39E 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=WcSPSq7KpYDGIzo9L9ThC0aR7CpyWNwB8TCZLRxMASkV0FfzRS9E9Aj07lAvuzHeHPqPnzrROWZq5JfXx2DvHC8/CVOwtu4HnviU84Wrcelmpm4v3qnEIVFliAx1Jxi4gexSnmHdVXePo8i2ly5gdxje8gLXLubjkhX1zaS47171K8ZLKjSys3R/XXDA3BC3oY6UedLOZRY2WTV/8PCJ8bSeXNJuLP439xquep9N+AmCCCLjUM1I3hUD++BlE/m6XqmROPKhrkdYoVtw+7KVfCqnKh+HCociKvmJ6uQfPUDvkvvKbdp4Hxu3+R2je21T+VKWW2xliYMwKg+62qSeVA== 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=HSIfec9IqmyEleOgL7gVcuoQyPkwC53gLfWVM5Bv9uI=; b=m7hBgMGwAA5A+WVxSc2LebAVdxaXQDPpPENp6LXrg/gyJzrsTQ+6bWx9OtOQSbE4llclTs/NsctNOjg+7LFQg0ldZTqlZB0wn1eeNB9dUtn35HQX2T+Jxtk5NWflMgLlGel2bIN7CGRE8XMhS+J7Jz1DFlW2OuYeCrfnksK0SyQCY2mcCTDYxZia+vp7Rhsf+sdt/0XtCn+IMwJzLc7R5nBwfZAm/NjdE2sQMGGvVAqm60Fi1F2vjM0Cj5FlaWI762mdG0Mfhv/8DiEWn0GlQFk0amidO8AZ90E2DlmHlog07wHDN7ebjrltwByWVuWp08tsSaUegKd4cTSksFP7mw== 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=HSIfec9IqmyEleOgL7gVcuoQyPkwC53gLfWVM5Bv9uI=; b=R6LE8J4iFrp6zeXSi6yuHEBJTqhEJPZpJawuKRVEjDyjL+FNYy4p7XuJtRs7VmoPNK41BXIZA5o2eg4Oxq+ysJZDaox3hINVloEgR4gktOGaPSnz5Yk343/GF7n5aGBO7H+9IQf0RT2jtByWd7s1z/SsUKG+5kIOMJtU2uO6iojCybLBVoE9c98ZeOrpeKJV5xNX5DANzIfykxcUiLQxbEQGnZ0049WHQ8XhHkYA8581XmLfdvNGHRcJVtj3/X7pJqgypmfxIq3Z0yyU/qFdFV/WxddJoLl/c5n/cfFkZZFMxrjZT++/sQVf0XlSD9RU8lHzBlMT2aGH7t5+gF5uPQ== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM9PR03MB7962.eurprd03.prod.outlook.com (2603:10a6:20b:439::17) 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: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:08:38 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:44 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [VwwuFWvPj+yX1/PUK+fczp5AzaRTvDe5] 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-46-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 49513215-a87d-4e59-318f-08d9e583ee43 X-MS-TrafficTypeDiagnostic: AM9PR03MB7962:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AHkxJOkGDw3J8/cIcEjfhs+qlG1oUXYs9WBKqlap7J05GJU71fPyICgTonvF0N3SwlR7adOfqaRio2VGK0gzgQK0vQT4HIRYsVV7ZAUamCtlp6Bl+KnHZZJvT2WTaaEV6sppQfs55Wm7s4puHsGKsrazF4ZfW+NJe5KiMBK7k5GIux8J7mrZzrg9lLrkJjq0gNLApi3AnccU8T/OUrUCmVoFNTVKxye4yRjGocG/SBkL7zUy3HV4VfUaafqkzynj+qgjEqU1z59axeBuU45CqHsnMvrJQl3XHdoS89Rxdz21qpxfp0Gt9/OJ3cfgkPEM9c5RvN4Nj4HJYYUELmqfR6eUQIJ7PK2+fA0VTED00koESIY6s9PZtQqD+nmoVt1NdRG/6KghZGQzIQID8SgP36RJ9PnxZESMd99Z8URWaBbFY3+6UrXKDeBABnvrMAzQOGVfJURONLM7H2P7rfTwmfxg6xC7dsIi98226BxVfgNgtYZw2dZPNf4h3nFsOsGE/DmvO+23EdnGZh+7N21bJrNi6WMYov8LeyC3h0T7yieKxYCmbg9iWlmSERtcnPzA X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cC+Ge1iScjlbV7ncadobQbCBZPWN2fOLzRC3LoRQaO2prgA6mvjnl4JKxyDVhswr+fmkkwmwfatTBPJxqcgJPIGngamuFvhFRupEN3Ck5lMqM6PlXRtIyUY0qMqf67mjiJ5MTcKPtv4631TCkJxNChZ57RK8uKGXH/Jv+wxPuwczyxHDXNEj8q5xMR81VMglT+SBcq2l60oRY4z/ABqUbUKI2v+TsbXr/6Kze4/RfknIg8VAuuXPSxE+Rxa7qRX7tu3562rpRVkY2v9HdLaZ4nrbqqkTtaebT0ne33awQDXhBSat/dj/9fgoj5vhRRfRxr3tDxxvya55V8FmckNy9Adlxy6iLNyCiI9Z9FHAk59znZOmj28AGhr8ClNoc8n/K27So6i2miXwFZim3UlCzOggzE0dinjYYHj9TrrHXJoInq4FCBy5vYdb7svLvxp/CP13UWTNxbKj+uJNwJFKpHD28C4yp+5WYux20CRmBmabrcMtziZtqsNDpLTeZ9RQIWjQx+J3gkwB95QHRx1Tq+NR7SDBx03Hy/pCsoMUsFgmS6B7n5kjztAwNSUwkW79RzrK8JV+FQRjvVMbolMrEf6Dl/r96jkYZ50M/GMX/Cqi4FmktxSqgVtFXgqNlvOCvLnOsLfshCyuzW6RrFQmpakWHGuzZez+xJzyw1qflgv4O07B1lNHKzwFxbhSVoM+GB3wYoIzogQ/jCT5fYkoncAprxTVJKxZW23VnJv4DQzkAZW2M6dvzFJiJJq6hK3o7KP1kH87jvYbjyA5LeOk7r208mXEWN+fhzCRg0YVumuhksxtISOmGdaC1Zsxlw5mqX02gjbZglvs6g6P5y18G70gOjTKmk7w1ilY8nn6OeGuPcBvOUXD4pr/6AtbvQsMaF3c+BAAcQnljJ25ns/+hdHcMw4EvJRKvmxv/4rQkK29POp91rdpm3M12WuWma49O7K01JoHMKyoMDmFQDBXNg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 49513215-a87d-4e59-318f-08d9e583ee43 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:25.1418 (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: AM9PR03MB7962 Subject: [FFmpeg-devel] [PATCH v2 47/69] avcodec/mpegvideo_enc: Initialize non-JPEG q-matrices only once X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: xWfodoHN2LtW Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo_enc.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 8b2de4770b..75f1db2a76 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -947,6 +947,10 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) ff_convert_matrix(s, s->q_inter_matrix, s->q_inter_matrix16, s->inter_matrix, s->inter_quant_bias, avctx->qmin, 31, 0); + av_freep(&s->q_chroma_intra_matrix); + av_freep(&s->q_chroma_intra_matrix16); + s->q_chroma_intra_matrix = s->q_intra_matrix; + s->q_chroma_intra_matrix16 = s->q_intra_matrix16; } if ((ret = ff_rate_control_init(m)) < 0) @@ -3599,13 +3603,6 @@ static int encode_picture(MPVMainEncContext *m, int picture_number) update_qscale(s); } - if (s->out_format != FMT_MJPEG) { - 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); - s->q_chroma_intra_matrix = s->q_intra_matrix; - s->q_chroma_intra_matrix16 = s->q_intra_matrix16; - } - s->mb_intra=0; //for the rate distortion & bit compare functions for(i=1; ithread_context[i], s); From patchwork Tue Feb 1 13:06:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34019 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp609097iov; Tue, 1 Feb 2022 05:18:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJyW8zCWoo8446D5MSDszwsEsSrZwtu91c6jR1G2pTGnzvPDp31EUWtM2OI4ZbZJ20k/ihum X-Received: by 2002:a05:6402:1c95:: with SMTP id cy21mr24927929edb.172.1643721486940; Tue, 01 Feb 2022 05:18:06 -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 b65si9644538edf.281.2022.02.01.05.18.05; Tue, 01 Feb 2022 05:18:06 -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="fqLc/DhD"; 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 0485068B3EA; Tue, 1 Feb 2022 15:08:51 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2064.outbound.protection.outlook.com [40.92.91.64]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A01DA68B3A2 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=fqd7lNc1GDF5LeYPV/5Ch3FZSJDTGyqmSo3v5EPIHbbnEMGIRUoTDY5arqR9n451IpK3kXW31M24NXVEa5OPqS+vdfMxt4b7CcRUvX6xytEJVGDz7CK7cVUvMw40n9mLNvt7lMvXZosqv98VMsLwVJse1Hthbz42EV14kwTYdnWn9Maq6Zl+O8Pjbhs63zyTzJ9ryNK3o1C3aiprcPcgHGC2RqFuHdJ73plRWpuv+/al2TDxpcsZUYkhlZAzBhjSsx28vZE/9qq4aVmBhn+f39krkaABS6Q5E6EXGxqX8ecH/l0+PgSd9adWU+Iq/Pud987EKF9h2MlxlelqXhslGA== 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=S0AKOU2h+huf5lKV+vazlhjENf1krprjBFc2k2VhqUM=; b=iuh1uU/9F29AvnDFuLLHMyA9ct93jMN3PZGmvfAAP3l2ikezt2b96WwdHUZCxZy92fxjcDWn+b7EAVLfdtz12JvAU0Mt+BzbpEj+puKF/GJcmHBCRFxQ80OxQDzdPd+wd2QS3i1b7VPxBKjZfakWnt4/NlUtKtM9wvqZpJg0YA6EdFyrQPXqyS6x/uUgpM53fkm/xnT/aJsJ72AoR8LCkqvC6ITxDDFKbk2KwaLNiQgZlcpKHFHfuEYwQmA3J/X/0joRXfPO2tZrUfE1RdM4wXwDOD5hX5N9NunCIvNMdGLbZPSCYUhk/07M4d8HGovqqQ8b+X2M+uL+rGxX4CIpHg== 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=S0AKOU2h+huf5lKV+vazlhjENf1krprjBFc2k2VhqUM=; b=fqLc/DhD++FMmLDTJpMaxA7CeZ95ov03a3ZGKFU/hAuN9E67Z1N9AVp++lthUkvU9cC0FtufaQhfHsW82xZ6rgT4GXzUGjDOhxoRNs4TRlz/7n9K79A5icRnKMn8BDj95CK+/okUtS/TngdyZlW1To9e55DIlwZVfQf/8oU0CmNGzOkylKAYVR2RR05kLEmUjM0ZSWTTLdtcAkpDRVjASv268FXgEFdfmbI9OHr/Ey+HaRq0+1iVLciGyV7S6ClsA7eDLDEP6GReCrQS2jbZEtavfHqh7vfiF44GDmRObmH4/WRiy+ZY0K8C5XCHB/3I7rAHrZuzgL6dGKeJGTOvNw== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM9PR03MB7962.eurprd03.prod.outlook.com (2603:10a6:20b:439::17) 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: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:08:38 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:45 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [SetAAD0LwmfuVQLcfWQVRRPD+GuwRNI2] 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-47-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f72828a1-48c6-4b0a-fea4-08d9e583ef33 X-MS-TrafficTypeDiagnostic: AM9PR03MB7962:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7bv3ZJHwOvANnFF0R32aWPhdq8fq5tYRqKXN4VJ9eR27pq9mwV4Bo+c86Y5Ncs889dsYZv8sI9vCRhiZ+Udz8griXDxXEeSCUzw0tnxnqkKMBBR853N9hplbB8zvMBQW73LaOish3V1UNiw55fyuCD7MRYOW3MA+mTII9pp7HWA0Vw5EvJRIRI6plFAGUeQLBa1VCu+sZsfS2Nz7SWG/N1KdqphYKuFgI13oZMUnOipZLcyfn/PN5vJSo+09odBlpx/pEU94+NUp+BlieS+28l6tQwnTwGr6jzu/nuBWO1fHy+WAXpUjlngkULYiyRTS6UKRtw3qtfPGpXNoUKmAhhWkY+HO1WIPArk/7f6mg+LkVb/A/yymHwpYvtyXFzTiMFqMiMuxO93Z71UiXBBan4txEUscw6gRzZUvi2gB95+heJWqOQNDyV2R8AxCawAzUcMVOnupEO7rcxNk+AAhpDsypkHhYQRdBeKJEr9XWZzjW1het4cPwWDcbG8917QHlQSxV46AnHHU2+OKrwZHrhMAYzvbcALYpRw+pfcApIc= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: clg8y+u9PyVYJpa0EQo2FtzQZZxjEvS72tJ6fPyjTz0FZ+0ptVV5TYKQeLR3zFV6srAeebzaBVFzyh2+0rfRaZyP1c2hd/BwoyG4g0B3FLFto3HVNKNOnsNcXfp6aZnkd5FDcuOLc4bI0xce2y2sauvuiMr1vWBH8gZJdCVmtu0ocdyImp+om43fzMWNbkMJ0gVkySO8yGlB/KF2A5+LoHFzlu8fWBk6NETEh8a05rD/KsTD9bQiNaUXOXl63ceHFf4n0HMZyNG6sCdNkhcdrMMIhQAZktmD1nQvTSfKavQUb/mT5+BZxAB/BGkRiYsMxlN6I3v00codKEDfpDdct1Pnj/kM9YGYMbP6ayK8qnRD708GFJVRFuqmgCn2wuJsr8bNnYdjNxKff9wZIL3uwdve4nqum5heKTWYkzFvuhfL7AoU00Rj60yZWN1B5w0doypl4FnogjBGTUGJhR/8GtWMwj+fzu5giaMcynO45Jya62OYgS1IsiR67SrCg9siUkxF3wZVm7n5j/tkFpColpgwBK0qTj7i1E4X58+N0s2dFfL4Foo4cbfaL9yG1OMz3Qrox7+gLOBk9Olw3VKFO2TnVUSzw556PRnQxHLuiAfmxHVGTFEjxCBD6qZsoQSXLXdfuYFnE9ryconr1lzgNinS+c2PJuTFXsKctmMokAJK2d668U4drTE/Hd322K4t511qxl+6p2PyINqdrbVNE/As9sUOGdIcavV1zwvAQokw9dRlMzx4v9iap9ffc03DU4lqeH/RBhxxw3+BAtzzSmw5bKyAgHqynROuorqkl+REEYBskf6P5zruuPNVGN6SXx6ddtwSVSCu9ayNCvAoJCIa8fcQIPcnxDIJuEl2fbY7s5bjOLOJgnBesktZlEo8VJz86WUum7GaF6NLCLcagmBSb7DFBYXuODJsjFxF0h6IPZGbzr38Cyc22Q5pndzr52GtPMjDLyRkNCUV43ElVw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f72828a1-48c6-4b0a-fea4-08d9e583ef33 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:26.7055 (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: AM9PR03MB7962 Subject: [FFmpeg-devel] [PATCH v2 48/69] avcodec/mpegvideo_enc: Avoid allocations for q_int(er|ra)_matrix tables 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: uIxXhSzn+n6s Do this by making them part of an MPVMainEncContext; the MPVEncContexts still retain their pointers to access them. (These tables are quite big, so that putting them in the MpegEncContext would have been very wasteful for all the decoders using said structure. But this is no longer a problem: MPVMainEncContext is only used by encoders and allows to directly share the tables when slice-threading is in use.) Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo_enc.c | 24 ++++++++---------------- libavcodec/mpegvideoenc.h | 7 +++++++ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 75f1db2a76..0e14cebb3f 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -871,12 +871,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) } 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) || - !FF_ALLOCZ_TYPED_ARRAY(s->q_inter_matrix, 32) || - !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->reordered_input_picture, MAX_PICTURE_COUNT)) return AVERROR(ENOMEM); @@ -938,6 +932,11 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) s->inter_matrix[j] = avctx->inter_matrix[i]; } + s->q_inter_matrix = m->q_inter_matrix; + s->q_intra_matrix = m->q_intra_matrix; + s->q_inter_matrix16 = m->q_inter_matrix16; + s->q_intra_matrix16 = m->q_intra_matrix16; + /* precompute matrix */ /* for mjpeg, we do include qscale in the matrix */ if (s->out_format != FMT_MJPEG) { @@ -947,10 +946,11 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) ff_convert_matrix(s, s->q_inter_matrix, s->q_inter_matrix16, s->inter_matrix, s->inter_quant_bias, avctx->qmin, 31, 0); - av_freep(&s->q_chroma_intra_matrix); - av_freep(&s->q_chroma_intra_matrix16); s->q_chroma_intra_matrix = s->q_intra_matrix; s->q_chroma_intra_matrix16 = s->q_intra_matrix16; + } else { + s->q_chroma_intra_matrix = m->q_chroma_intra_matrix; + s->q_chroma_intra_matrix16 = m->q_chroma_intra_matrix16; } if ((ret = ff_rate_control_init(m)) < 0) @@ -1015,14 +1015,6 @@ av_cold int ff_mpv_encode_end(AVCodecContext *avctx) av_freep(&m->cplx_tab); av_freep(&m->bits_tab); - 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); - s->q_chroma_intra_matrix= NULL; - s->q_chroma_intra_matrix16= NULL; - av_freep(&s->q_intra_matrix); - av_freep(&s->q_inter_matrix); - av_freep(&s->q_intra_matrix16); - av_freep(&s->q_inter_matrix16); av_freep(&s->reordered_input_picture); av_freep(&s->dct_offset); diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index e124555b0a..b83c24debb 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -100,6 +100,13 @@ typedef struct MPVMainEncContext { int16_t (*b_bidir_back_mv_table_base)[2]; int16_t (*b_direct_mv_table_base)[2]; int16_t (*b_field_mv_table_base)[2]; + + int q_inter_matrix[32][64]; + int q_intra_matrix[32][64]; + int q_chroma_intra_matrix[32][64]; + uint16_t q_inter_matrix16[32][2][64]; + uint16_t q_intra_matrix16[32][2][64]; + uint16_t q_chroma_intra_matrix16[32][2][64]; } MPVMainEncContext; #define UNI_AC_ENC_INDEX(run,level) ((run)*128 + (level)) From patchwork Tue Feb 1 13:06:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34021 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp609465iov; Tue, 1 Feb 2022 05:18:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJy46H75rgRuSYDXgZcHnH+sbXnpZXJ+pLsOxFWBtZDJ+h+Ixv1vK0yORmtf6XFp5/tB0Ag8 X-Received: by 2002:a05:6402:3554:: with SMTP id f20mr25535706edd.375.1643721515790; Tue, 01 Feb 2022 05:18: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 x18si9786699edd.417.2022.02.01.05.18.35; Tue, 01 Feb 2022 05:18: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=NsQ3I8g8; 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 C3ABA68AED4; Tue, 1 Feb 2022 15:08:52 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2064.outbound.protection.outlook.com [40.92.91.64]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B79BE68B39E 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=FEPoUCbeP061hTj1NS3dh4HnZ9kf+mAkXTA4T8TZMcumZeWnxqwlvuIAcHKNmkBU7gg7yCduztplPT7Wff8FNWpvks/sBDfLy+l3Z54AVZLdsFrXyQnboUEtRdE8/FWe1UbbCP1Tuc8FtoNCLZ65rJrs2k9Yd6JS0eAgEsRebXGNI3Gr4AKe+Lnrt7xUylS4Y09n2tWwN5A83ategXC2y3fqjNGMobJTSzUtUJAKFIKfjvrT+6hOY8hH4ofB2uMqf/03GMxz6tNP755/prXEt66yU3Pxv/SIvlcBao52GC5DMQS2EaC/QvuWVbGd4paBJwBrO9tdb6ZrNvkr1NhocA== 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=5spjA3VrLbRtd0qBtg/WvJ4j3cbYtjbrJoaeM+WXsiA=; b=kp11xZ5tKTA19sw2V679NnJ8o3V6jeYhhzKy3eTV8VaoHQs6f0jMlqG8WHEhm8NA25s5h7oEHKbR9a7GShgaw7JY0hV4QgUrDBs2zS0phXa61evop9+6kcOsRLnWQIgmB7LfrikPLYnQ4t+dSO52uFrQoMCwJdmHrNLDKoUSXwaQpYuinor5fqzFi3wlV7Dk0O/9ozg84AopsYy8YONe/6NoMRIdgxNB74Z/9D3Y/dtaW9AwV9ccaOZ1WYCP7aU1fU1asNSRhdeRcOrQHFX2sJDZa5kUNp+kz7q0gfeYVHTzcLONqxNMG5YFxxGYbZAyO5xCRmxCIMwdubkT3ijQSw== 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=5spjA3VrLbRtd0qBtg/WvJ4j3cbYtjbrJoaeM+WXsiA=; b=NsQ3I8g8pKrBswTsJnN+DywRUrxE7z8d2rZZG+tlQHFyMVh8EkH5/D620s7hyk1QwpT1c87eKDDpM+jhzi9lptiqTO8j8PxXPJR5+rIme9YOPlMjsz+zy5ddH9l1sR3CKTkV3iI2Kcw9tfZ4YUhwZ8CxDa9EPwA7q9A0ynUJK8h8ggRqAvqLYT41/IAFVI294U7XkzpyuiJ7bTwJcvxO7f1p9E45p4nwvQQW566adp4/K0ci6nVOMAw+YGoE34nTZY/BFKcCEoMb6eM06MGBi8wQa6aqWnavnT/dUnfU+QRk5F6mm9p15EtQwKSwt85E1NBFI6ByVpPfU3925fn6yA== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM9PR03MB7962.eurprd03.prod.outlook.com (2603:10a6:20b:439::17) 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: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:08:38 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:46 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [fna8eURrTzofBYRZuEYqFcyqyjQHAHgB] 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-48-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 981af294-2692-4782-decf-08d9e583efdf X-MS-TrafficTypeDiagnostic: AM9PR03MB7962:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k2hQsAp6/PkhVSlUAkf6lHYjedxi0zZ4r6DaVhqJsLcNHFciRc69bXxCBqEtYaV1fmrX2eN+qjfa/gpl5vW13Xc9UMKRu1fdb/dN1FUInXYA25Q6dzeEZco5zarILmrkFcaIjfoRuOnZyAEFHVdBu7aH9IM19YM7SOj4DZIgMLdKQUqdhLgtipu2QhqwC+FM9puxXhKDpNJc3i/yeMuLLL2DmwVZrlJLrRMaaqpsUTGr6Wt+LxiN02sV6LB1eBX/uCu+dNf+LItzU4UmCTAzkIA7e7bB92OXn453AfFO/i05fJtmnIdtGOWKL6LHPQVtUS+qJyEhpPoCVfIueX7zcBfVt/XGGHAL8/SrT4FQF0N05VNlwIrE9CE4HBP3/c7xvddKd93rG/AsXqu4FpKe6/zcmHVqcKjBEfyTDttuCo58xGAtH4E4WWlA5DhHtkmkv7xkF6cPysKV0cSEgCMjT0B1xLv3IpPvS2JxRC4XZMX4qMigbyjYMOvtrBZuR1eIajDNBxB7bGaTW1RqCQUtEJYvjWs7l7eKbj0itHKAErm+cImGYQYywMRhrfppGT7l X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zEPDlsYUkh6s6+XtuReQG4IsgPdGwyR6I31N4U3muKDAu6frJsbJI9Ug0O4u3mx97czMdCKTvm7g2O9BMb4+CqUd02U+Vj31XuXWRZYgEZisuGJ/mFUSzVjTxkjxKDVWLPs4ZGACXnoLZAvy0lL8FjmeoIrBhJ3ctljhKCcX+XM31YRWu8x/pWT1TiuAGwuwEYHfGi7zhL1bQ/JaSGy9EV3dbHUK28s2VfsJ8XVQOv2ZWLtpnC8XSLDnTgx3NYBRCkqy9QvPcqrCeC/2buc3LxFBgdT8RTialbSNzFrcA/H1GmUGhQMKL9zWdPKLGiFmeyF3WBp4d7YQQoT/Y9BNY+3bwj2sSEyJ7AUEGdRftXBeA/bpkK3YRr9xa0f6FOqKdPH1eZq4TiBktmSoNCRHQvL8LJT/lFaoLzN5A3Lti3+IGvnifwiOAJSP9Do0fKNQhaHoM0lj3QOR7Yw1uC4ipG6f5RuzTivAgXCee9hTh2B6PHNI0b/vPpH9w10nsHSbcq/85bfO6BFV7bdDTRQ6kHB/0tIxISIE2OcTdhlweP+GbhZdaLK4TfoOnAXfwkaKCqtQoeSCBNCZRoe1rDfes2kg5hGtNxw3xopyNQZLkJ5sVIcyRNrzJhApe+ScFdAB4HA8P4uCMjkXdC9TmtFF+vWZ6oqw3+v2xQvem4LJZXNS4mL32EovgeQGOvYiN9GPv4Mp+29CHMK5b8LDpald0y+aidawirDHC3drFO37g3uVJP8sixE2SxdWrYHoSILBxS21asqr5TuPI7owBSekJB4MN+/ovamtW7DLSKbXbCDYxk70xkeORBguPxMbpIgePYATAi+lpYrip9fX7lzC1DjHGeuLZAFqzV1T6K2xsPgND3uHBMXo5AMubeEYPMWhPJFSsdhaBQTMT1a6dbtRexkjsTkPb9Bi0yuEzPLAGEtOfO++Q8sfvP27tYQPZXCNezCKNnJJM80Iu0f6ldI51A== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 981af294-2692-4782-decf-08d9e583efdf 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:27.8475 (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: AM9PR03MB7962 Subject: [FFmpeg-devel] [PATCH v2 49/69] avcodec/mpegvideo: Move scenechange_threshold 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: oeECNk46D3Uq Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo.h | 1 - libavcodec/mpegvideo_enc.c | 4 ++-- libavcodec/mpegvideoenc.h | 4 +++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 0d6b79fe5d..4601c4be64 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -478,7 +478,6 @@ typedef struct MPVContext { int frame_skip_exp; int frame_skip_cmp; - int scenechange_threshold; int noise_reduction; int intra_penalty; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 0e14cebb3f..093f3b948f 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -574,7 +574,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) return AVERROR(EINVAL); } - if (s->scenechange_threshold < 1000000000 && + if (m->scenechange_threshold < 1000000000 && (avctx->flags & AV_CODEC_FLAG_CLOSED_GOP)) { av_log(avctx, AV_LOG_ERROR, "closed gop with scene change detection are not supported yet, " @@ -3634,7 +3634,7 @@ static int encode_picture(MPVMainEncContext *m, int picture_number) s->current_picture. mb_var_sum= s->current_picture_ptr-> mb_var_sum= s->me. mb_var_sum_temp; emms_c(); - if (s->me.scene_change_score > s->scenechange_threshold && + if (s->me.scene_change_score > m->scenechange_threshold && s->pict_type == AV_PICTURE_TYPE_P) { s->pict_type= AV_PICTURE_TYPE_I; for(i=0; imb_stride*s->mb_height; i++) diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index b83c24debb..0abd315846 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -44,6 +44,8 @@ typedef struct MPVMainEncContext { int me_penalty_compensation; int me_pre; ///< prepass for motion estimation + int scenechange_threshold; + int gop_size; int picture_in_gop_number; ///< 0-> first pic in gop, ... @@ -179,7 +181,7 @@ FF_MPV_OPT_CMP_FUNC, \ {"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 }, \ +{"sc_threshold", "Scene change threshold", FF_MPV_MAIN_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_MAIN_OFFSET(me_penalty_compensation), AV_OPT_TYPE_INT, {.i64 = 256 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ From patchwork Tue Feb 1 13:06:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34022 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp609622iov; Tue, 1 Feb 2022 05:18:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJwlscVAAq8hfPLwJFcqFKLclVgMaMNxImtb062i/htdXg9SsdKWW/qpidZtNWNd5kfpWzcy X-Received: by 2002:a17:907:86a1:: with SMTP id qa33mr20603510ejc.516.1643721531305; Tue, 01 Feb 2022 05:18:51 -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 d16si9331797edq.80.2022.02.01.05.18.50; Tue, 01 Feb 2022 05:18:51 -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=Ss+vJI8q; 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 C473A68B3E8; Tue, 1 Feb 2022 15:08:53 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2064.outbound.protection.outlook.com [40.92.91.64]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CD2D668B3AD 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=NG7u9f86CdpGlohWjgT7CQTo6F+vPYYrOg0bQt4hVdP2vmG1lWIOLRapVrh8tykIyCvwO3Vtsx4SZFmXHcMoA3UdpRRTfoXY5yJ5iqW/KqyOWeI918cvik2myfxherO+dJTE2cIq2jZKIXQ2QVPqS+8Vl8Tj5GhwSQzM0VSjJRj9bxtrG02m4P8OhQr0GLwxknlObchKSVGXtcXrPuk6ubnAspdya40bRAa0+za9pZ/rV33feMdv4hXznT0+12NOCMnr81ZXy27DVlED6GaqGTbUzOSOGP+uXK6wGgdF1AaVDQa+TIGRyia22Xgd6S8jhuTai4b+ttrRlCj117lGwg== 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=x9iKCoUHq57DKckfRVlqdJ1v8691yv2nrrBoNS6aUZE=; b=KvQo77M4x+Tq/sV3Ksu+3fpp4Etq8jHM45b/K9DBSwJb2ziwwMq0cQAvSFARfouCAGtTYdxTiQ+lB+Ofwync0/gryY0s+GsIQgx2lVNj8fh/TRAeL2UmNtU+c8kYj2Z9b1KQ5b/J/xtdahcBgwbr9hjZKL+Q7v2NDcI8r5sID+hNoAiF2O7PB9T7kgstsPc6bhRW2FEMRYb3wRk58T+C4s6x0mbRL+29m0dceVtfZojwztG6Xz0lAuyPSWhgosqQ5a25sGB2x3IiftXbXd8OFwy22veO57a/MnQ2soMoVo/YQAJYxUltKSO5WZg4paOCw4ewHpS/0qTXY/9YaL0djQ== 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=x9iKCoUHq57DKckfRVlqdJ1v8691yv2nrrBoNS6aUZE=; b=Ss+vJI8q97mFegWMuULbRDo44yh5z64HMEytjrt/S0PZXYQvFZtsHqyNPPUPJaS7zicvi6InExOH4jypRE2P9s6uVS/3nN/pHLllnk2rdhJrwBiMri95W1ECEctfvO6GjL1Vla8HQaSDnd+RvTFyeUcG2y+26Oc+kSUijIPFmbn/J/w+wRl7Zbw/Pryvbrdtk8AlM0iM2UjhuXBjIMGS6ItO/+cLgQ2CW31N+0jN1nc3j9OkQbpwPa4ZIIBITMd5+d9OcRELH9D04PdSMVA1wiRfOUw+eKIVc0FcNak+MnDvHx8KocCurE0Th7D/7L2f9ToB6rGJJB8Ad65Gj52Z5g== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM9PR03MB7962.eurprd03.prod.outlook.com (2603:10a6:20b:439::17) 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: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:08:39 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:47 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [I5GHKDejcbKkRDm4PZXydcajfEaIP1wf] 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-49-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 64db5053-4a08-4bce-694b-08d9e583f0b6 X-MS-TrafficTypeDiagnostic: AM9PR03MB7962:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uzetZCPZduBvH9cL0AUtReilrllKYgRL/rxnsijKIcHdKVib7nywFZNvDIhhbjpCV4jKnLVz7pg+dpN9Dx5bIVBlbSWrMeg8fH7M6TlFWAUDNAu44nNMl/CgNa4OOEThQ3NxaQOF76AS+1xJHDxyDSlqJ0IFXRYlePSJutNnTpqL20BpRI5s1YXGx565ReiYIbWoSssxU4El14Ec6uV4Pb6TuhfPyq19ZUSIUSIc302EkldJ7L23b22ISaBFDzm4TjG7AUherhKD2WbNcE7wAnTyfJYWmB5ey4HFuTyloxs5ResRUCBdC/xAJXiU1Jg4rshTjUviCDf/HYGTqiRLK+g/32I6XxGR3fQaztsD2TmtxIVS058vcLpZHYL9khvVjgeTw9BoOx9/mgpy/0VjKNuOlq2sAUnqU56PKUH+7Ui1EHBUIxz1ULB7t+HUmsU6OelERYC2jqUALRKD3AiMl5D/vik1cuiX6ChHFJ6v8Q/HJ6uqsMGDjWa30ZH8M6pdB59AGacvktJLYZzFr5zo6uDC4cvdxxJAoWZT8mepmfln5GEJkzySfd6YU6WXshwn X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Fz4lUn+L5U+jsaCnGAXwHcgk6o5H2W06giv/2Rqk4mFtiGpgzI7I9W2Ct/PNWF1sJ3xMRftTrN08DSIswj5yVySwKG29ZrEVmUhEJL/8lk1PT8VNi5gsKJqpUu9DpX1CNuhEaIEqpSjz+45087yvlMMOKbBBcH6200+KY30OhQrKtC2G5uCLxATXIJLPwiOvQhD4xQb5TJ9dMMGKvQbO3Xx2DNDhkOiRxX3vg3h07m3SGziXwmxYTH4v5MShI2/yqdeEn/8NeQkmU1zh0j/T6lcFk7VUX+FebuFx3lzMfHcVh19MQV1BaihV2Tc7+3dCORSRwMV0bq5q/Ey+UBIgRTmnKUIaz+vzufu+gHw97+0LlumPitJnodhaLZravV1RVNRsSpZzVFg0JPZcOzo1OFe0EQksFBE9Y/lxNSVM2q0GHMqfP5HpaVv5UyGC3vmNCs4f9idK5EnlfQd3CHqraiTf+HQ2s/19cJjwzmpZAkqw+CiU57hy8V6frTSqOfp+TbHVn9MKYPlslJh6dhp1koOwuN4J1fJqzDxGzRcMMU+KRG/OVw0fhbtm123zKSvjiAc0G4IXrRNSel0sOlTlKBGRec1ZWF4f5Be/il7Mcfgxs+cppS7DXl1TOqdjujcbYeotKp/QbA+pN76gwWBpQdXzYxCqmIRuUW4aPxv5YQ7MbK27AZ+PZXj5Ayd0weAcxhTpy9qr2dUrlS/k/cnAk/9cifswODAgWHOb0Mj6zChA4Npo86bSM8P8RrWlP3RufGE5NWhZOr0S/P/kjMuT5UpjHxNkRMx8ki+LN9mVJHm9aJjhIUDKD39wVTt1wZmpYFS3HlPCgGQkoxBh/T2ihatv0789Jq/tdp3GlHui1KEjdd5XhBvEbmUs7RCCCYK+FODoGWgiQZjO/rSv3EZiXxvHzz9rtF4aJqHWE5HbmvLjKtiy4b4ltMEfMooPgDr/o7cEbU6xwvMAg751q66CTg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 64db5053-4a08-4bce-694b-08d9e583f0b6 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:29.2848 (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: AM9PR03MB7962 Subject: [FFmpeg-devel] [PATCH v2 50/69] avcodec/mpegvideo: Move dummy dst for depr. opts 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: RnX3do7Dumt2 Signed-off-by: Andreas Rheinhardt --- libavcodec/mjpegenc.c | 2 +- libavcodec/mpegvideo.h | 4 ---- libavcodec/mpegvideoenc.h | 8 ++++++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index a8ea63a76d..360653c5a1 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -631,7 +631,7 @@ static int amv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, static const AVOption options[] = { FF_MPV_COMMON_OPTS #if FF_API_MJPEG_PRED -{ "pred", "Deprecated, does nothing", FF_MPV_OFFSET(dummy), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, 3, VE, "pred" }, +{ "pred", "Deprecated, does nothing", FF_MPV_MAIN_OFFSET(dummy), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, 3, VE, "pred" }, { "left", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "pred" }, { "plane", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, INT_MIN, INT_MAX, VE, "pred" }, { "median", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 3 }, INT_MIN, INT_MAX, VE, "pred" }, diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 4601c4be64..9002c0549e 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -481,10 +481,6 @@ typedef struct MPVContext { int noise_reduction; int intra_penalty; - -#if FF_API_MPEGVIDEO_OPTS || FF_API_MJPEG_PRED - int dummy; ///< used as target for deprecated options -#endif } MPVContext; /** diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index 0abd315846..51610c051b 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -109,6 +109,10 @@ typedef struct MPVMainEncContext { uint16_t q_inter_matrix16[32][2][64]; uint16_t q_intra_matrix16[32][2][64]; uint16_t q_chroma_intra_matrix16[32][2][64]; + +#if FF_API_MPEGVIDEO_OPTS || FF_API_MJPEG_PRED + int dummy; ///< used as target for deprecated options +#endif } MPVMainEncContext; #define UNI_AC_ENC_INDEX(run,level) ((run)*128 + (level)) @@ -197,9 +201,9 @@ FF_MPV_OPT_CMP_FUNC, \ #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 }, + { "a53cc", "Deprecated, does nothing", FF_MPV_MAIN_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 }, + { "force_duplicated_matrix", "Deprecated, does nothing", FF_MPV_MAIN_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_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 }, \ From patchwork Tue Feb 1 13:06:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34064 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a0c:e44f:0:0:0:0:0 with SMTP id d15csp3768711qvm; Tue, 1 Feb 2022 05:19:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJzrKTncttOtjtaW6XTNmb+dQ9DbXOk7iZsmRtxxw3GtkrIZD0w+p4YH/GvSjTU+KyrEwhU5 X-Received: by 2002:a05:6402:1601:: with SMTP id f1mr25040765edv.165.1643721567306; Tue, 01 Feb 2022 05:19: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 hb7si8224040ejc.437.2022.02.01.05.19.26; Tue, 01 Feb 2022 05:19: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=T2V658jH; 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 855D868B411; Tue, 1 Feb 2022 15:08:55 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2064.outbound.protection.outlook.com [40.92.91.64]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E1FFC68B315 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=FB4GkrjmZ+Zpj8qfeeDap3leKlsGmGbnDa6KtLE7+jREf/iHerwFz4sx5reKtZBqM3kuBT5M0+3VOkNLZVPQIbyJ/4613phJx4OV07JVOQEk+eCBJzv0EMU/yCNfAU2qZOJTX2kCDCaryrefqVmu6oCV9tOpJCPJTriqlu46CUWjF7Ke1fqCIDd4ztMw6SmUgozdhk0TYzPaI/4aJH8VVeLwnIXqfuQ4J20SjsTAmTib0fRgQg1djVtkMJqnaiQz8DZ2DLNsBZ+seA/cK/Ske8mJasOztmqVtD5AwbNU96+jNCtSGrbpzty9bPom9k6uJvHFu4fiSWJgVhjNzUNWyQ== 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=1/SwwgSOkTVYrPb2u4swP0eOkeOE4u8goLabIYyT5hA=; b=e3ey3pQf1OoUj5M3/NpqEYdgvlwFtJYmOrXFcCzvRGnsFWsi2ctv8HAVuNQIi8WkIIKDnZS0xw1UmmBMRI1sovFeJt3gLlVrCKuGumJuBcn5oxwRMCXbOx2ZAAsHvN5EwDbPVkJgyqxDRXD1rxVv8BJF+bZD2TFHjdXS+LuBZCV769I58DtvBnQRNCiitt63jBCPSVSuSEt0aXAhdM0zdtkea2jNg/wXwgaRjy0rSMyOs4yfHfBKy7a5jbVvqvBd4cjQeUSaKonsBzAm4xj4DdrqZ7KuvY8yNq2CrtScS4LfEX/UaiaOwxlBOvPCdXwB0DtmEgI8p4JsbL/dEMJHQQ== 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=1/SwwgSOkTVYrPb2u4swP0eOkeOE4u8goLabIYyT5hA=; b=T2V658jH00ZojnWKPAJVmhoCukrU83W3TuXt9KLyQU3j7n3bKGLkskraZbsXhQCgr+0CG2m5ptjie2OHK9An82+lBm42Kn2IrfryY21aLSBvdZ0tkrtq+/WGR89ViCT6tglKTCWDEfvq42uRmhBL+7de5grhU00hi/7pFVtfI8XJVF/SotY7Q+RzHBq0kcDtpgggDUHahz1YaBio4oaKDo9jQOZllj1h9LAF53vImLeUvJm8/Ri5aII/Td9X1jKAiX7lDCKMzKbvyzqh30MLswI0zduKEbsrHORv/73UW39JRnjnYmunGORIvtzd9QfA8mL/iAmroiN1rSrnCOm0qw== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM9PR03MB7962.eurprd03.prod.outlook.com (2603:10a6:20b:439::17) 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: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:08:39 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:48 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [AIOJu7sEgK5InM73FpTcdbrKFGiOyCw2] 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-50-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cd0f4e18-ab75-4e49-8c99-08d9e583f170 X-MS-TrafficTypeDiagnostic: AM9PR03MB7962:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vK5g/80836DTmXnSvT6YTD4GB6pNtegKsequlVcnSbQi9kmF+QKA2DSn6MGnzNN27qeCyiQBUupNz5fDZptNqWzI+lbjj7p8OUWSBahD9x6lNTTdfPa0DoOBU/Le8oOuErNUS8Zu4He+cBi2I1OpQ+Sa1SSjJnw7GU5JUF16n9zmDwVnSveXH4QRlbtuF0ViMS00iNzvsW51Ti8Yua3AaM0ULZ+NtVPKB4K7ApYoBzy9AAITIPL1XmzbW5u3FDLORmjpSUKhAbPulteCzIdZPIVTvKG18RJM4anuraCZXlK1V5O8EVY2BVwoaoU2tcc1OoyrOK1WVI5TK+QxJrXynuiFyPvGfZGtdVFpWKF591bX3fhK+GJW1WpZPfoBxBFBJj52DF2IZwFaz5hKfX6GS8T1jApvN+JA24tGXuSTHaXgfj1N0Og/2R4/q0vETctTTwzEJNJlT6vJjwDUk8EooAN1EGHaORDSAHM0zXyGNPFEbON7Up5KxQRvGujGpyesc8Ub8kBF2irnxofqYot7BGYnyyXjFd1RhCmibokYH9n1jV2oco0+CyH8wX/Cxhyr X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Jd2l1tj9Z+IyL3SbYJ2iI89ZoIRlHs+YW9Wxg+ZZ1n0VQAyYftel89ho7R1jMDeSdqfY9LseW96zDk7y5Rc4Gx+BuqIGIjyj8A2Zxmpb7JJG+eWTRcxy0mhg6iPEaPOnBJiDIXCbLJbJC5uxC20OdwT5URN0I6FzrE7zVeR1l3aYTEvWoBIXNuaey0uup/7IbQk7hE+udwUWXlGvDOrcB21Or0LRlGulG1usljBYMO/crQk8jjWla86x4CaGqMpFBHB2jbojm4VJ3lwqpSKRWlciGcht7KYN98+ILolFbnasE4XCJ8n6ukwHRm2AhYPXkVvKsSNXt9MLxMR9wq2SQ73LLpmuuHe7SZZAkVa6AeX4Y1/A4b6uyGuR4BeuzatJN/qKxFJvmZKf3gMa7zIObEJQB07KzclSvWq2gHKCfWecMPiAerg9Tp7EzYGtXBndP2K7CZ+n1bm4VpD9cyBAhNbyf2+p5+9vJEhUT8zVT89yw372Wc232T7O2wcwl4ZGUtODUCd1bLAu9CT3HYiW93H2QzDJixIWInhVvhm3wr2ZBZgRql3OXDgGTFWs1LZYEUbvg0bAgCJeggbxLUZzyPPpz5KXWjIocduZghjY5XyGtS88CMJCqqrlErYnlbHlzOUqFbMxILhLMg/CfJ2VlqveVjwSYnakYsl4c5Z+L+Eqmn2IAF5OAwb5tHCdIg61FjPcomBaoaoSlfcxk27BUwdZPWr6TjLj8axkgvRlKqHa/6JT9g5Fml5axFwKx8EjXpVhKvj7SmU22BQOKN7aeKQaawNwqW9Q5jNXLuwTqFPqrZznQu8JFZ+uAlNj54JYaYJP+7oPYYNSLTdQxyuRhT1cXiX9JiQH/DjvgnnJGKDkGc1pSG+Gcdz6pDRxu49lUQhOhe9iLW+AAMYuAnRlFC/e6eNOFSJznnL+2ePIL0pG3GpSVgjCTgAAgwpW+hAg098FZhQhTYH78AWVAbSvSA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: cd0f4e18-ab75-4e49-8c99-08d9e583f170 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:30.5047 (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: AM9PR03MB7962 Subject: [FFmpeg-devel] [PATCH v2 51/69] avcodec/mpegvideo: Move frame_skip_(exp|cmp) 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: ypnPLR06NmIM Content-Length: 4754 Only used by the main encoding thread. 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 9002c0549e..ce2d36ab15 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -475,8 +475,6 @@ typedef struct MPVContext { /* frame skip options for encoding */ int frame_skip_threshold; int frame_skip_factor; - int frame_skip_exp; - int frame_skip_cmp; int noise_reduction; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 093f3b948f..06c6e5cca1 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -894,7 +894,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) s->quant_precision = 5; ff_set_cmp(&s->mecc, s->mecc.ildct_cmp, avctx->ildct_cmp); - ff_set_cmp(&s->mecc, s->mecc.frame_skip_cmp, s->frame_skip_cmp); + ff_set_cmp(&s->mecc, s->mecc.frame_skip_cmp, m->frame_skip_cmp); if (CONFIG_H261_ENCODER && s->out_format == FMT_H261) { ff_h261_encode_init(m); @@ -1236,7 +1236,7 @@ static int skip_check(MPVMainEncContext *m, Picture *p, Picture *ref) uint8_t *rptr = ref->f->data[plane] + 8 * (x + y * stride); int v = s->mecc.frame_skip_cmp[1](s, dptr, rptr, stride, 8); - switch (FFABS(s->frame_skip_exp)) { + switch (FFABS(m->frame_skip_exp)) { case 0: score = FFMAX(score, v); break; case 1: score += FFABS(v); break; case 2: score64 += v * (int64_t)v; break; @@ -1250,9 +1250,9 @@ static int skip_check(MPVMainEncContext *m, Picture *p, Picture *ref) if (score) score64 = score; - if (s->frame_skip_exp < 0) + if (m->frame_skip_exp < 0) score64 = pow(score64 / (double)(s->mb_width * s->mb_height), - -1.0/s->frame_skip_exp); + -1.0/m->frame_skip_exp); if (score64 < s->frame_skip_threshold) return 1; diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index 51610c051b..8f6d069369 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -89,6 +89,9 @@ typedef struct MPVMainEncContext { /* temp buffers for rate control */ float *cplx_tab, *bits_tab; + int frame_skip_exp; + int frame_skip_cmp; + /* temporary frames used by b_frame_strategy == 2 */ AVFrame *tmp_frames[MPVENC_MAX_B_FRAMES + 2]; int b_frame_strategy; @@ -183,8 +186,8 @@ FF_MPV_OPT_CMP_FUNC, \ { "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" }, \ +{"skip_exp", "Frame skip exponent", FF_MPV_MAIN_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_MAIN_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_MAIN_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 }, \ From patchwork Tue Feb 1 13:06:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34066 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a0c:e44f:0:0:0:0:0 with SMTP id d15csp3768938qvm; Tue, 1 Feb 2022 05:19:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJxz1UuR8jH1dhjUdMNjHvova5oISFBnGRLp3p6AYUhoNPLbMXLMiXwbkhDJJJKOxejqSgyC X-Received: by 2002:a17:906:2e8b:: with SMTP id o11mr21424561eji.383.1643721590027; Tue, 01 Feb 2022 05:19: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 dr7si10724500ejc.798.2022.02.01.05.19.49; Tue, 01 Feb 2022 05:19: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=WTnaNoV7; 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 C000068B3B0; Tue, 1 Feb 2022 15:08:56 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2064.outbound.protection.outlook.com [40.92.91.64]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1590F68B3B2 for ; Tue, 1 Feb 2022 15:08:41 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CWzq4xcSdTfPiLscmrblS1mV4YI2WobCSH6nbWNpAF4LuWA/LexLAWIm9oiZTJtIRqb6JpkzW0igDfFkzZjfIbLgKy3atP4peRG8rrx9vsXZnmCztQp023iCyb2a756E86fPl2pk9+5/Shuq1p2z5MAjcMEYcR+c1Bb6fcEZVsClAnXPCTgf7ZOBm5mi2KTNm47Zu9At+B9AMB20h4jNHq3HXrF4I8kWB9KW9AIjPJ4dUmkyubNd3rmUYPELvh5CoHChqgnGVOx/Z1S6f0ZFAVN6aocTgIg20bVdAQ89o+YPQrBWIuUTWpScr1JHsA1XTOuWT+XV/rvDe18jMoPiwA== 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=nBaED/XnwDL/+ZUAuJpzU9iMcsphrJ2rc203Q0cSKrk=; b=cjglRmNJPQ37d+yNeOgg4AOeFLCj173vAl7RgrjAYcWbnKzA98+IXil7IEhHFdnM+06aku1YasCEewAlpi+v+6efLdpJ0JBdVr8rFnwEgLN+J7BuJHi4xicXNeldFPM9nQ+SFmiCM3EMWaQy+QtWhYXWZwj7HBg+FJSmYQBN2mVFy/L9HqKlh5HBLs8yHaua72Ff8QnufPAYZBqY75dGI2Vjew2sNBr4HUgsY2xV2hdsV0upGgawCSMVg+/IQJhttOyYw31BNQdZ+7IElSFPL6nGqgcBzLzkKfuMB0mPFe9cgnHgy3y09YBp5MjKH1ZP/zox1Ak2t+D2Gf8uR+JqCQ== 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=nBaED/XnwDL/+ZUAuJpzU9iMcsphrJ2rc203Q0cSKrk=; b=WTnaNoV7NLjtwAyIYvOvhw+PP5IrIakAjwaILD/bN+7tmD7k3vaIInmhzCJpWQGRueLTMKudrVUV0bjWfVBp8pccH15tF2cQsU5dlnuGzzOhl1C8Xoet0iomW3y9Ej0aZ/W4RQxjbUOF3i2NqHk0kSCL7miRVR8wUmw42vEtqfb++b52QUBS6c8K4zVYCNPxgRx/V6B/+C1kx7mZ6ROcALY/OTtuBAUkGLUBpiOHDIYn6CfOvxI5WUKAoeqXNPrCYuNykP+3Of6n8MD8FBPVRfj6L9u3MbOFUM83VMOL3Oas5CKOslNucIIY7mexHBYxi183Am0GxL2OHcw7tX7vGg== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM9PR03MB7962.eurprd03.prod.outlook.com (2603:10a6:20b:439::17) 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: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:08:39 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:49 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [sjaIQBlV1teAjGWWevc4jN5j7MyCrbs6] 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-51-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e6776889-a8df-43e0-cb63-08d9e583f43e X-MS-TrafficTypeDiagnostic: AM9PR03MB7962:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6wlNuoqOEGtyjWID8ptyng26rW3O2HacRHUNAGmXfHxnjfF46dGrjh5Yw6J9nRzMNSTzg4Su7m+VI3HKDXuawhNKiPmW/dovoXkJrUV04je4Qff62MfYMVHJK2QX4wLL/EZmcCrDIRrq0dDdim3maKxiGxPH72Sih8pPY0o3/+cCd3KPXr5xt2WztHpGt2jSQw5RbCxHOV6UbfrvvY9fgZ0QQwCJq/raYM+qox8W03H19OYSgVtdy8qpicHrsi3GP4wZBjk8xycO9SyQRCDamrVNmxXRntaw8vEye6/5HJrA5N/BM5qxb9nC+doFYSAFXSS0VAt+cLfjm7lycXGXSnsbiyUHIVz3xs9tgvG59SCgUw39wgQNn63wFR1O/fchRP03MFp35cLVWbJw09qSou1cUG8CQClvuaxFphZLIAnEM9JRF/0nxJbkKgn/973Y2TSFKYDJl9vzGpreRPNPoGxCM+4/EQpKaCwUfCEtzHfVWNSmCpTKYILVPLkrFVenY0DbAWcxvs9wOcCY113LGg4FWwaNv4W5gHxysmyoJ2Y= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +QzujVY5zWqbP18Zegyej7aAMTLTRkJy7wZPCB/6EXYRF5mx9PIQ2bkP4HeHrxfHAm0PPAGgYvLWUpKTFtN+ZPQGQQ6Y2urnmpS26hYI9WA3rYYRuWLNH9RMR8ycvbj3MCUOTuTSeaXLSa6PqDjwDBKs+LwPuCDFplwjS05DH4kYGdNOiS0rVPFURzuz//Bt8WYBC/0dPnRs923g1sSZPj8oA2poBUREOnUX2ZWAj2HlIFUI5ZwXD2FgB8mPuqeJi3BDpXED1e+O3c7kK3kmvQlukJ7Z+Y20vtS59SpVwG5I83V7izXMdtRH+XbfHwx0T0KHTI/ERajNTzbOT30x84tqEJEnwnx2wgdJMoe6IAxI7N6BDZ8RCkCNnfOzpC7OoY3rf/u2skDls6958IgbS/RAj84Y6paWLpy3p1r2bYatfVOZL/UdA3Ne9HWTT+eWZBawxzvtUNL+ydzPNM46UdZAxFTiNN7hOADGpl7WoLBfF8/aRFqyT0jLxRoCA0n7Aqlpjo1rinDY3U00Yex4S6Cfq+GEe1/ocLI+zAQbMuyvnQ4iO+ZbjSxcCORM8zpYkSzc9lvivUBwa/TFdeYy6bRVtSUMX5QmQR+TtO6CCaydlUvUkVIb0GfTx/iB9ZKelF36bde3i1OONUBTuWoEgVTg7mivD/IOIjUa74jS/X34/HfDrStKDCdbyyWlItrggPPfQiXv+RgNB0g08oR1q4BRI8cuCGNCC6WvEIOFQpEmr4eaMxm3WscR8b+TiXcfCZPVLtJPMbPlUhP46KZgMohq9DBBIaO2KJ7DC7p18uzIAA3izpfQpmbm/8FcdgBf9/L91CeU+1zdn5efYMc3AKyMSeGrhNk1Iqee0+BbbsxhY1zyOfHEkE1HkZoXMteqT9yPhSSjqwiVQDld1jZqEL8NOidjVR5XMffVSu4yvMGhOz/ph/6WnwV8aBits3qhxH7p29k1KTqX+bNUhf2+TA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e6776889-a8df-43e0-cb63-08d9e583f43e 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:35.1800 (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: AM9PR03MB7962 Subject: [FFmpeg-devel] [PATCH v2 52/69] avcodec/mpegvideo: Move input_picture_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: KZ2bgvnWUxiN Content-Length: 2538 Only used by the main encoder thread. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo.h | 1 - libavcodec/mpegvideo_enc.c | 4 ++-- libavcodec/mpegvideoenc.h | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index ce2d36ab15..99361f0733 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -104,7 +104,6 @@ typedef struct MPVContext { /* sequence parameters */ int context_initialized; - 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 mb_width, mb_height; ///< number of MBs horizontally & vertically diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 06c6e5cca1..ecc25ba8a2 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -291,7 +291,7 @@ static void mpv_encode_defaults(MPVMainEncContext *m) s->me.mv_penalty = default_mv_penalty; s->fcode_tab = default_fcode_tab; - s->input_picture_number = 0; + m->input_picture_number = 0; m->picture_in_gop_number = 0; } @@ -1080,7 +1080,7 @@ static int load_input_picture(MPVMainEncContext *m, const AVFrame *pic_arg) if (pic_arg) { pts = pic_arg->pts; - display_picture_number = s->input_picture_number++; + display_picture_number = m->input_picture_number++; if (pts != AV_NOPTS_VALUE) { if (m->user_specified_pts != AV_NOPTS_VALUE) { diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index 8f6d069369..42731a5edc 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -48,6 +48,7 @@ typedef struct MPVMainEncContext { int gop_size; int picture_in_gop_number; ///< 0-> first pic in gop, ... + int input_picture_number; ///< used to set pic->display_picture_number, should not be used for/by anything else /** last non-zero pts from AVFrame which was passed into avcodec_send_frame() */ int64_t user_specified_pts; From patchwork Tue Feb 1 13:06:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34065 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a0c:e44f:0:0:0:0:0 with SMTP id d15csp3769068qvm; Tue, 1 Feb 2022 05:19:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJwCKcvZkp1fWF+pQ4dAhZduzrsqqdljHn0IEy+Ga15veyKJR6cOx1mPFRP8dTg2a34v/JL7 X-Received: by 2002:aa7:d7c8:: with SMTP id e8mr25586553eds.110.1643721599272; Tue, 01 Feb 2022 05:19:59 -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 he20si7500006ejc.771.2022.02.01.05.19.58; Tue, 01 Feb 2022 05:19:59 -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=SXVTjLjq; 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 2BA1768B41A; Tue, 1 Feb 2022 15:08:57 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2064.outbound.protection.outlook.com [40.92.91.64]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2ADC068B3B7 for ; Tue, 1 Feb 2022 15:08:41 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ev0XRYDwpttmsf93Oi+sqqcL/oNN29cSn5ZpeehHddzlrKmDWu88eMeMlztBaeW+u8KZnfYcW0ynxP45j34YYFFPLRPNvKBj6qca1tuyrggKriNEHbnTOb7yRd3hwBGEmxKzzI8wGC1SJgw9l2lK41FlcGH0qHgNd0dGLLlaEnVVK0dERnsndlZXpNwMx967sCYm0uMtAR7aq1TUkgqY6XOFQ365wi9ZqxU/95EjoIJMA+15Yzb/RXU8L8g6vxDCiTYFxiVDqykQoV1REUeIQfHpD6hNEMcmwYAxXqWkPcfpkJVQgfgCkaid/wK4DSZGCpBJ67GHe3naGVklzsQ6/g== 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=zyza43r6vio4vqqTaL53xVTsL/wJ0nBgrweTUDYf1Ng=; b=KuGWgwRzMtqXleBzCFQY+k5eNfB82RBAhUR+/1sOFTPUVAOkUjlGjq/S13rn1t4qbCdvDQqKHIjntiJ39EOo18ANCcTfTLuZKqZqRD/FuMZohY9n/rsBbmRfiz6/I4Jjq01G4geORATBwaSGlF/DIo8cMy8v/KCIX9VaGGfiIkD0ov8DnIIAkF5oCE9Cxgh2Rv9US+lzJr+S3q+9n2/k4eTYe08fHigwIssqGn0DH8lTYmD9AyQbke2eTtt9zk3DoGVssp5M2jIbb0ZIFS5Hh3HiwqONBX8aHsPK/e7EKcPvQhRy4uAT33a2eSN44Q4KHsT3KKsqKCflwLl5PJiFsw== 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=zyza43r6vio4vqqTaL53xVTsL/wJ0nBgrweTUDYf1Ng=; b=SXVTjLjqzzlvnAGhX3o08tq9hmn2jpnFFlMvDlmBlRAhM42sGRgqydOXW8GWZ/GRJwa7I20Teu2ehtnjxF5eKrQhd8z83t8I5Z7HWWuVUoobtig/WCRCuxChIlyt3FfiZ9NWn7eOJDyr4s7ttQgGz39gXd82KwPRcEzQRXH11HD5R3ynkwmSeyjS0+zkIEJnACNqfvg2htVDoSTTnNEUjfHh3SdYe0XPhLP3amis2G9l7N1Cl8jZPXBzLYy9XdSizJmVMrQSfmwLbDIzPUDj4ADGETAIMTezP4dkSYfi0cOGJMRbLxZlSex/H4ayXuH81zNOwL+dNxYRsQ3xKHJWIw== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM9PR03MB7962.eurprd03.prod.outlook.com (2603:10a6:20b:439::17) 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:40 +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:40 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:50 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [nhnNqcZe9dpiz5dZiQL+7XuRggsfoepc] 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-52-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d876ab18-c77c-43ed-09e3-08d9e583f570 X-MS-TrafficTypeDiagnostic: AM9PR03MB7962:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jdqsThG3lC1lxyBHDofgYbKiK7gT9EjFBi6D2Qj88KELszyvo0SVaELc5HIAReQWZyEYO443dONB/eSOuDqtbcuYwWST8TiJMITDEH6/k3uwfRsgP6MzRYk8RY4YqqFMEXTioK0bBdWY2jJNTWEspq7ao+jy+sWHKMqNcAiSOz4H6Rw7huYXaHPVdB3IdSuMtGe8whav5fVjGtR2v1zkjcGa1oKRKl2+MSDjD//gjb5BzPTyvhFI2A78YLodz6/mHBUfjSdDgvGx8Wtjb3kU7FMDAGi3WMZfvV4H1u8ta5bFQ8l/EfNurw1oS7xIEaCzqIPKVyU/jVeXwy26Dw6Oj8iZoimnzTBX3ihd9jEeOMz3T7NxnE/dazWCT4hVnrCJZY1Y7tydHYwE7k0F3XFvQY3fMXa2BA+btyMuReWZF9KqAYLlsSGHw8cFB6kZG04wcRF7vs80krnTuEsxOoi0141I0rX31b7QX/r0ATmARd9UXfp5jxv5NdxXAmP0nR9e3PeILXUCwQh5NHv73IB74G9bef0MavYZU0ZSSSwqUIJzCJGQScav54yUt9SaMQJj X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xSTgl6uGEY6Tp8/bG1IGPQ/n8GQxcfuLHr4ZHxXouJ3KxkEqotq7Soqrh3rmqtzA/4mOzG+4QnGIBYYozgYNURBl4hIiXmna60ligVO5y7H6ZxQ6nL+DAsZqa5w+BV8v5r806SiT9EFScog+KyEm+U1GXWi5Z/6qQBscYSZNNfAxNt1q+Ftj97VN4mJp33mZsaXOEPhxpsyij/ZcHN/mJjRlwrjgKnQv1NUCTUFb3UzZO0bjwnxIyZgWGiLFxrL060MTnOWhgTy4o3nCMRUZ1NAh16MB+OhEa76DOTK9D+6+ctpD6gHOT29Rw5+MWFurn4vNOgtiap/aB0VkLdBYdwTQDUnccDzUmXM59bCGj3DHqRm3yF+2GlScmVR63V4BpDKoF3GvGGYFk5Jc14m/YUQgxaLmputyqv4N07W3b8xq8PqWKzDQFWceTsJtIcM4gFRClyoQhM2N0R0VfYZQuHJUAubpV5BwsU6YTsFqavzaHTSorSTTXhM8j1D6snHQxrdNUeUXDM17WBMTAGNkiWRNxYNUVo7+kfsTdQyEljYXqk5ZdsndhtjfVUf0T6FHGMheNi5Jv4JW9K5nCpgoVDrlC3bLq/Eq3ceCnsmT8pqQX9+uxOCJCRvcWZzlK6eB4XpDZfmqPPOMCA4tYhy5HAXJMHXWxrP3tIAetIGSjwgSvsom4IJhQvsW6nE7ahGWPHYPX9/j3SHDnapMVha28DVgd/5OGHRC4gR1BcNZuAwCGkU8+wL6Vnqvg78x3kYA3v3nzEYC1tjFxjRx7MQ+3lFhWKPF8POhcbk5Fua+wjkXR0/LX8By+Iq2S/gKwUWHQjIkAGLViUsDFX3aYQR1qYSGeBqNs9FTxZ7Mayx1VdkuLQSIO/kC3N7FRveJiCJTU8fYC8i5LQoxF2+RMzmdRhmZp/GvR/UDUqytE8o6j2/ZOTLesad5Ml0pEMunW35INtuKi5gRfOyFqGIQzMcRLg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d876ab18-c77c-43ed-09e3-08d9e583f570 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:37.1653 (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: AM9PR03MB7962 Subject: [FFmpeg-devel] [PATCH v2 53/69] avcodec/mpegvideo: Move fixed_qscale 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: NnYR11OhLNHw Content-Length: 3750 Only used by the main encoding thread. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo.h | 1 - libavcodec/mpegvideo_enc.c | 10 +++++----- libavcodec/mpegvideoenc.h | 2 ++ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 99361f0733..a379f65143 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -92,7 +92,6 @@ typedef struct MPVContext { int h263_flv; ///< use flv H.263 header enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */ - int fixed_qscale; ///< fixed qscale if non zero int encoding; ///< true if we are encoding (vs decoding) int max_b_frames; ///< max number of B-frames for encoding int luma_elim_threshold; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index ecc25ba8a2..4dafc68cdd 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -401,7 +401,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) } /* Fixed QSCALE */ - s->fixed_qscale = !!(avctx->flags & AV_CODEC_FLAG_QSCALE); + m->fixed_qscale = !!(avctx->flags & AV_CODEC_FLAG_QSCALE); s->adaptive_quant = (avctx->lumi_masking || avctx->dark_masking || @@ -410,7 +410,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) avctx->p_masking || m->border_masking || (s->mpv_flags & FF_MPV_FLAG_QP_RD)) && - !s->fixed_qscale; + !m->fixed_qscale; s->loop_filter = !!(avctx->flags & AV_CODEC_FLAG_LOOP_FILTER); @@ -474,7 +474,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) return AVERROR(EINVAL); } - if (!s->fixed_qscale && + if (!m->fixed_qscale && avctx->bit_rate * av_q2d(avctx->time_base) > avctx->bit_rate_tolerance) { double nbt = avctx->bit_rate * av_q2d(avctx->time_base) * 5; @@ -3502,7 +3502,7 @@ static int estimate_qp(MPVMainEncContext *m, int dry_run) s->current_picture_ptr->f->quality = s->current_picture.f->quality = m->next_lambda; if (!dry_run) m->next_lambda= 0; - } else if (!s->fixed_qscale) { + } else if (!m->fixed_qscale) { int quality = ff_rate_estimate_qscale(m, dry_run); s->current_picture_ptr->f->quality = s->current_picture.f->quality = quality; @@ -3622,7 +3622,7 @@ static int encode_picture(MPVMainEncContext *m, int picture_number) for(i=0; imb_stride*s->mb_height; i++) s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA; - if(!s->fixed_qscale){ + if (!m->fixed_qscale) { /* finding spatial complexity for I-frame rate control */ s->avctx->execute(s->avctx, mb_var_thread, &s->thread_context[0], NULL, context_count, sizeof(void*)); } diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index 42731a5edc..5c579cc155 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -46,6 +46,8 @@ typedef struct MPVMainEncContext { int scenechange_threshold; + int fixed_qscale; ///< fixed qscale if non zero + int gop_size; int picture_in_gop_number; ///< 0-> first pic in gop, ... int input_picture_number; ///< used to set pic->display_picture_number, should not be used for/by anything else From patchwork Tue Feb 1 13:06:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34023 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp610669iov; Tue, 1 Feb 2022 05:20:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJxjKALExhuA5LVH2e1HsXjxZB2TLnV1kzzxQjoMbVhVPXCE3PqxJprqp3UuzTW6RIODEvNA X-Received: by 2002:a17:906:6a20:: with SMTP id qw32mr20477386ejc.40.1643721618222; Tue, 01 Feb 2022 05:20:18 -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 i16si9429535ejo.352.2022.02.01.05.20.17; Tue, 01 Feb 2022 05:20:18 -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=YqeVNdz6; 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 8E9D068B41F; Tue, 1 Feb 2022 15:08:58 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2064.outbound.protection.outlook.com [40.92.91.64]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4033E68B3AD for ; Tue, 1 Feb 2022 15:08:41 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Efd4SYaIF341dpZwZIb+WXUdQNcWdKKRIz4EPtibiX15r1AdhA7euk+6SuDu5zfJgny6qTwVN0Nvdta0BIbTEaFikPvMc9g+49+4pcvb1odh7utfk9L6nY1oatvb6DfP6gBFXvm5mpTRjppyWrqem6nXdJE0MbJW4dFraixefc6+O7ieUsgG9CHaskwrh4ZxCC0Bvk0PasLqK2iAcHeiemoMN1z4Ect5nGYUnuuYDdwVzy1bXXKBYmKgJSzSE4+P7b+p/BxK0y41xMSTTJVnmzKzngtEliBlFvNUdBnvveXrAMUnhj1XA6ikbnFjBiP+xs874H5wxy2C9OPZGRfRSA== 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=+iCAUxHVpd0+1DqO+wxVvU/7W4uhPW50BmdIGcNw+3E=; b=H3EZSWejmRUOL2T10fzy876Xvz4Agfi/PSB+VOnQcY9c2oejGn8MXZrizmzmi6x9qHxEVE9OMN9qEW6UsIgqdilMoytmJTY36nOb1Jxt0Mq3OMPtm0kZqwc0pYtjgHgJ3pshoAUcHmNK5NMTZtdyqYvRSyG8z/MyJ7dPxEP6JlZykHBNxcDp2sNXu+6+MKoKjgDrKXuqZbLU515Q40B/iL3NP2N25l3f2w6Peb95Ytliys/owOfeNRztssH6dJbxbaAL9VecRjBUkPkh8J2nh8r5nSE97TsJ7SFM/+SG74GQbix7w/hQiXZtjH8isDVQpnulbQzkE1Hn1/YJM8gH6Q== 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=+iCAUxHVpd0+1DqO+wxVvU/7W4uhPW50BmdIGcNw+3E=; b=YqeVNdz6p1jAiXk8/AfgcIhZ8WWhqOdNwdI6kPLPV/KfSiFp738dugMW0vdph5AvI7Sauc6f/sg65TA8+EaqNbGBjoDk6l5/0zElxGjCHNQfNF3VxLU24SZ5Q2hGAVqhjWtnaTkJ6W0Tw09sfs5wFeZYQNFZlUJftRLX1R8VsxIzIQERdQtaIdXiegWrKkkkgkg+TgdYWFWsbpH2iHd2n01qnqZHYga6X4WyYRhNRnv9josZCUw8Jt4+jc66rT2sg0nwuNBCXoe4HkTQWafizapB03qlGhWiHliLZyPwW8a+6HklxOgviRvz65NfKsATRs5iisQ6NgaOMms5E/AGsg== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM9PR03MB7962.eurprd03.prod.outlook.com (2603:10a6:20b:439::17) 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:40 +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:40 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:51 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [j5cBT5iPEtR3gxqFOe+x/mv0z0NvV71z] 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-53-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 498c0b61-9318-4f63-55d4-08d9e583f612 X-MS-TrafficTypeDiagnostic: AM9PR03MB7962:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ISQujYocKM8ceq6su0zvXaYNGQfmhtADkiNSid22H+FKyZeZHZ2NoJAG55xbLs+ZCTBCx65v/cW7wMqNoc8W8CAPFTM/1jPXV4MPJKh31ZDDRih0Kp7Ge0ICINGXlow88w/W1UNxpK5bpqVpgZYUhsNnjyhn7ty2HaoZgRoA5zkLD78hQVg4BcdbcSyyyiarDXgumoErodyF8L56Yw54Gr6vg5tzoxrNaqE3J1J7iJzmIjaRMCrZJdZP/h0rUTNw+WdujprOxvptE5M5HmNMytR6oJxKb9MGTg1GzABmTMLWqGv8kXmUHnM0VgaF83g0NDB9Y60CSx6PyHwcaoy0sv2crCLAoLz3IawNblyA+1vwpra1lkXIXAQtQ909TVGYoYsb4MGDAapTtRJLd5ms1/NVx7cah0Q/gmAe+KPoeoh/Jj7oAe7YtUyg8wVE+FuCyLlNX6Wlaf4dgpJkavbd8kXAcYXoWNxi+2Hn+K9GvE5IlgnSwp4lY9Bg5IMJImGbv0NayK73Dkkv2uXpFpWoNySbwoUwqmkpdCAQYsij2AfPF+Vdz6RUqWjVHhzzMRS5 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MP0CCrHKFWidQkq/V3lTWDtgJguMwTzT0SPOekth4BX4G7heXzFkJmnk2fhFD+cchQnPFRStPWzAZgNMY2UqreZkEJGtm/8UjFSrbyxozvzRPoNybiV96br62vZ011hOptVR4C49Dw4MofoQHjWFzZUOTS+pt/BdchJHHO65GJsqa6g3VKcrmW62rJQ9wsCRDbyhYGPQsLieY4SrsR9W+hwRMdpD4NpLI0v0NNWdupH8ePPsM5YewjAnkCJGh2qPp+3iGEYrTQTNGV32/zwLCTCeXBrXkez4L0gefvqdqTvBSvk5wDsoG2hHPHf6BYRLYadeegXCuKMVc0/bHxBeLla7N4Ag9dxFNJG/rf/ViAv3ne4Ida3onMr/PiDH/zV17CRAjpONS0lRhaLNpG0Ute8xisBJ3rx51vkLFXlKExUhBzresDU0l044g6aCwnkbJlyxQ0X521cQZCNzzoElgfZzpl0ysVDJno2tShY7uMtMYFLCNDFJ5B98YZ809Z6yF4++e50cAuBeLktTyUXBmjSUp/6wibCoMnodYSbT/EetBHCjYB4E3ycPTW/gzLqQyoETT7aNGr8TAxYQ8XkA9tLniyuDKVCIWhFOaWyGWYe6w1D04SQB2VPqpAbc4fMnnZREoqpCd//+ESzR5qkl0l90pr71fqewGiIa0bv4ikyikMYMVU2T91kwXu2T943m2+jGTC+6fxRojwxCnYzPLh08mmKaqE0bRnVofdZZloU6TudiGpWe99PWPmf0Vd5OovbNqLVAU7Jm/FMVyUQ0uyLhViNGgDikjdgfuErhIHHoEy2tuWr47/ODESGbhiEHXuGlsvyMqf0C2gi9u4feJIXGdOqhNwos/kws96xAB4gTisPGhHQr+0HfyVgWbCNi3HaONo/UpwDnINP9wlumQlr7MWjPPjptj66zta6v2WA4Lf7KGQRkJTWe665VR+SFh3v9Ikw9bsWEmHw+cBLdRQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 498c0b61-9318-4f63-55d4-08d9e583f612 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:38.2445 (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: AM9PR03MB7962 Subject: [FFmpeg-devel] [PATCH v2 54/69] avcodec/motion_est: Constify mv-table parameters where possible 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: v3a3RAIy8loO Signed-off-by: Andreas Rheinhardt --- libavcodec/motion_est.c | 2 +- libavcodec/motion_est.h | 6 +++--- libavcodec/motion_est_template.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index cc305d06ff..3df1e4f40a 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -1595,7 +1595,7 @@ void ff_estimate_b_frame_motion(MPVEncContext *s, } /* find best f_code for ME which do unlimited searches */ -int ff_get_best_fcode(MPVEncContext *s, int16_t (*mv_table)[2], int type) +int ff_get_best_fcode(MPVEncContext *s, const int16_t (*mv_table)[2], int type) { if (s->motion_est != FF_ME_ZERO) { int score[8]; diff --git a/libavcodec/motion_est.h b/libavcodec/motion_est.h index b52b91ab3f..01ca14f9a9 100644 --- a/libavcodec/motion_est.h +++ b/libavcodec/motion_est.h @@ -119,14 +119,14 @@ int ff_pre_estimate_p_frame_motion(struct MPVEncContext *s, 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); + const int16_t (*last_mv)[2], int ref_mv_scale, + int size, int h); 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 MPVEncContext *s, - int16_t (*mv_table)[2], int type); + const int16_t (*mv_table)[2], int type); void ff_fix_long_p_mvs(struct MPVEncContext *s, int type); void ff_fix_long_mvs(struct MPVEncContext *s, uint8_t *field_select_table, diff --git a/libavcodec/motion_est_template.c b/libavcodec/motion_est_template.c index fc887b05b7..a8525afc6f 100644 --- a/libavcodec/motion_est_template.c +++ b/libavcodec/motion_est_template.c @@ -858,7 +858,7 @@ static av_always_inline int diamond_search(MPVEncContext *s, int *best, int dmin optimal mv. */ 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 P[10][2], int src_index, int ref_index, const int16_t (*last_mv)[2], int ref_mv_scale, int flags, int size, int h) { MotionEstContext * const c= &s->me; @@ -976,7 +976,7 @@ static av_always_inline int epzs_motion_search_internal(MPVEncContext *s, int *m //this function is dedicated to the brain damaged gcc 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, + const int16_t (*last_mv)[2], int ref_mv_scale, int size, int h) { MotionEstContext * const c= &s->me; @@ -992,7 +992,7 @@ int ff_epzs_motion_search(MPVEncContext *s, int *mx_ptr, int *my_ptr, 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 src_index, int ref_index, const int16_t (*last_mv)[2], int ref_mv_scale, const int size) { MotionEstContext * const c= &s->me; From patchwork Tue Feb 1 13:06:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34024 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp610878iov; Tue, 1 Feb 2022 05:20:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJzPTzX56U5AN56lrYe99BfgBuJg8uTXH8Slkfwj+ssJYUi7D89utuS8aWC8tODBV6i0eUuP X-Received: by 2002:a05:6402:74d:: with SMTP id p13mr3760926edy.422.1643721633283; Tue, 01 Feb 2022 05:20:33 -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 w13si8408007edx.213.2022.02.01.05.20.32; Tue, 01 Feb 2022 05:20:33 -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=StHFM6w4; 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 7B6C568B2C2; Tue, 1 Feb 2022 15:08:59 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2064.outbound.protection.outlook.com [40.92.91.64]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 552C468B3BD for ; Tue, 1 Feb 2022 15:08:41 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G5DjPO6Yo/dMP7GWvuw7/AkJTlPOb4I0VprSxMVKQE0fuVHF1iA0mUKEP1YCV6JRn+09nL4N360/gz/HtpP/JUuJ5m1vdutUwxrMK/4l8QI+Z8zfUdCYgxKCdQ0lPqtsWBrGV5BmRjyW43qi4s6JvC1Q3Vw/LSQ5nQuEQqsUJEMzyGO9XghQh6JnuqBc9rZwcZO68YIe24iB4sfteSuiIhRD3FO94bXwt1lmqXvSms1I2y3MU/pINq5Gg1kafmPXVO3jBZTxVMeov5kd9IjsUnhReEV/PwpoFAfchkMmgBbMrfZXlROQeHtEp3dJWXuHy37hjqy/Izyaa7AiMdM79A== 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=2EK9s26BeSM5FaSeha4KTfCL7A8Es4qrXL4cafBag5w=; b=CT1yLZj6qv3prUO8ELnqMGczZoFPiKZx0YB24shYqtaMwkhvgx+zFvR+E+SpP9sGmQ2taEMO33hfcGZ9c7rnNHdClFZeuBlMUM4pu+yvLZcwzE+5HqSy6okgKLhm5qOn11edUIjk5HZYTih1Aq8NVzRFqYqDD/LpINAXBQk2JPACK1obT13LjRd2re9aqk1rXq/d3bZX/HrIcTmpEsDbtvFg7FX0rIAo06hgyBbezB+AWTMS2l6LRKmH0DTc6lqSUVRbBCp960Bhqw03nja2lX7FcPdLkSDyRMN/ML62zRWS4aXI5JxGR2lT13/EwwyomvdCwhYWWBFzAltoBrAnVQ== 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=2EK9s26BeSM5FaSeha4KTfCL7A8Es4qrXL4cafBag5w=; b=StHFM6w45Du6QSSGCnJ49ltzrmrA0Aqp5AJmAU76IntT4NK54ZsMQzHaGpBizrAP/0RUQGb0rKgdzrMvv6/OFMMzVBJwIOm8VyWYlktbM7jr3cxtlx19q9hoacSUtvPQHl2KgfwMsLgFIORM6yiWmalH3CbVUpoj9Tuz5smT7KSIXswAB8PIBZhVPsK/+I1PGY+2CGiI2hewwS/C/iXXvaeYr4/yuxqiF+u9B3FvoupqUyMDsJ2qBBcebTL94mnk+I952UqKl1qt4Eh2GCzuldMNiz7tRieJVr6cSxc8QLDSlZQk4LnDMdm2D9hpy/y38Mb09VldITOlwVG5KaXmhQ== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM9PR03MB7962.eurprd03.prod.outlook.com (2603:10a6:20b:439::17) 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:40 +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:40 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:52 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [eRo++aVSbbvSPrz7GjiyCT4M3eDaEGKv] 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-54-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2363c589-68a0-46fd-a17a-08d9e583f729 X-MS-TrafficTypeDiagnostic: AM9PR03MB7962:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pNrnczOR5/2y4f/XXON2oTwps0mGDdrzEKhzBZ2513cLQAxzUkcIOn1Xq5e/O3Ae8PJ4zAloJIdy12YROqsog+8cITwvRXXjY7OZAqmpUfDjvimpo10rStZdY0VPbeY9VnGITGkGUTUbtj7h0Ue7d0h5/ginnQtyCTcYV4wFwWJyXBQ2ZcQPesWfQnQOLO2dxwws3NHkMkcoRJKNp0cEe+OwCt6dLXYdld96kfMz68oxHKxrErQe4LieLPQXAtwLB15aoWyJtxjcnC7GjGVV43/SQRrzU9Kl5DJwhUXZUTKHisFudxTwCaP/RMrFC8b8DRmRkVSDJxWivNaf/zKjHti38RZLSDqrra9pj1L44M7x8N3tily3hLqYMIIP4T7rO9FsYO4XNcxsc5Us8UU/4sv4ND91hGJOqY4T1irX51RcG/GH1uesSsvDKudDy3sTz/z//LuLKyEboFaRk2FhfxRPDinwCkOWGlQ7gSMgerEaOmaUosm8Lboy85z4kxm8FFjvL+wUXz8j1g8TLpacCC1RC9xM2jGt04j8DZtfgRWzVjIHqZPeoo9YRMaAPveK X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +Y21dcU4AGsMYdH1+Lrffj0Mue0jSy42VFMC0b4VJsiuCKFXuYNr5SLAzr9Y1MmlSd6O6gsHhb6COR0ZwPZJuWPH+BU3TLUlUSGPobcPPPDTJklDO+wW6aCOm5IbRiSxUs//AvZwXs3jfFhumd90OITQ/SNgvtg95LzEBVT4kvWTkdmN0wKs7oMBsz7R/Dn0V9RAE0WuGpoNY5egyxBmYtARWB1tpC9BCEKZGYnsQBeK1G2KkbKXNDAtC1evmnXSc+YKh6Hf6KoalD2ZsbREkDbfgHn2/XcQA8tkQF3Y4GufUz6rCVLZVnjHxjdXXVgmOD3Ciekm9/MvonDo60KZcc/Z7NsBAFuF3dcwLiRJrpPCtW4kWEwI5/868txKxD2l4ZCladOjWC7Wklfilf6z94wvy/jd2CjWuLC1da5wDE2DZCigmqYe1GyZxe59yfkRjUSeql25APTdq3Hy4GBWje7FeAHKftk6+H1bSexS3wvR/NPZo7NZAyGVgz/Jz2aXjX0j+VhzOvETxllr5zHCwXKOljiBoRj9LNRs/TJYualX/GR0kPemIOw1D07TdiDXa5PwZ8wsT14MjzuEnC+W9/O88J3nbTgBTPbuC8+8seVleoamPVj+vUdXCj5Vk0tTjYt8JEkAFrPvAznlL96LBNVwXaXPJUVmhng6Ey952EKHDkUh2+mEO3vbyRXSA6lTHR2wVtJWMIx9OQRlUGHn3PnKHXZfWfsp/8Ci/wF8OsJNyIH5PfGybSanEuZPsXHhaHxWWPWfTW9AYe6GDHzJHgyYLme6LEli7GaxerRfC1YjqjgvvtgHBUWSETAuHJ8t7iINi1t0ORJ2XMoOzJxcz79ELEf63jf3j0mJ2T9w0WghgDlD5w1WW0A0U+vYKIBZLukKPqqw8UFMMiBCAI5JzcAoFSDtDG3mnkbYkMuwED0e8ce0oIniuz0ynLRkrAeMC2Eq8wl6Qw7pglD5mrfnWA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2363c589-68a0-46fd-a17a-08d9e583f729 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:40.1062 (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: AM9PR03MB7962 Subject: [FFmpeg-devel] [PATCH v2 55/69] avcodec/mpegvideo: Constify src of ff_update_duplicate_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: tTXTUqFQn/sw Also do the same for update_duplicate_context_after_me() in mpegvideo_enc.c. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo.c | 2 +- libavcodec/mpegvideo.h | 2 +- libavcodec/mpegvideo_enc.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 5a68a7cf07..b71e12c3d9 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -469,7 +469,7 @@ static void backup_duplicate_context(MPVContext *bak, MPVContext *src) #undef COPY } -int ff_update_duplicate_context(MPVContext *dst, MPVContext *src) +int ff_update_duplicate_context(MPVContext *dst, const MPVContext *src) { MPVContext bak; int i, ret; diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index a379f65143..cb947ff56b 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -545,7 +545,7 @@ void ff_mpv_reconstruct_mb(MPVContext *s, int16_t block[12][64]); void ff_clean_intra_table_entries(MPVContext *s); -int ff_update_duplicate_context(MPVContext *dst, MPVContext *src); +int ff_update_duplicate_context(MPVContext *dst, const MPVContext *src); void ff_set_qscale(MPVContext *s, int qscale); void ff_mpv_idct_init(MPVContext *s); diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 4dafc68cdd..6c40bdb39e 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -252,7 +252,7 @@ void ff_init_qscale_tab(MPVMainEncContext *m) } static void update_duplicate_context_after_me(MPVEncContext *dst, - MPVEncContext *src) + const MPVEncContext *src) { #define COPY(a) dst->a= src->a COPY(pict_type); From patchwork Tue Feb 1 13:06:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34026 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp611338iov; Tue, 1 Feb 2022 05:21:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJyb/oSRXRTKS7O893rBM7BRjXyA9/n9FeqaNicwIwQG5SDRvku1bBJvR2uWcd9fqoB/g6ke X-Received: by 2002:a17:906:9b87:: with SMTP id dd7mr16415563ejc.758.1643721674210; Tue, 01 Feb 2022 05:21: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 u9si10928768edf.395.2022.02.01.05.21.02; Tue, 01 Feb 2022 05:21: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=Yxcy5fLL; 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 3D19868B192; Tue, 1 Feb 2022 15:09:01 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2048.outbound.protection.outlook.com [40.92.91.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 01CE068B388 for ; Tue, 1 Feb 2022 15:08:44 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hVUtQ5wj0mRJI/dtiYO8yYJBt4uxBxWXzp1VwITERMFLGaXATq5Z9XKmhUcYaAoKRvvkkvODDCFxB2wms5qcd8YHZGJ8Ai9fqLQtu4QZQmB+p3mz9VZvD8sjhSg2Is5lUtbBUYeADAXYV5aOZRDphEsFzudj81VkCfoOLfyuiXhIytMsjqYTvM8v1mI3I10EgCCJImYBVBkFVciY9ExNLDOzJ1EsSkYuYisz5qtgA0Pu6fd9Adngys6XzYicWQTmgHqC1LfXYaqEPQS9R3H/SmQS6dRdl8DT4KvrVqLkcxxUJh+ViZPkwmFmp/q8EnLxKh24W1FulSD6ljIjni1APw== 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=92dr/xUlGIAzAm3kGZNa+Q0xO3zzm199OmpaCzPMSq4=; b=B7F4R+KCHOXOOxYKfjzFQnK4toRAFCzJs2AXNQCsqEfRufOwYQ30VIrlWXokmbALeuY+Uis6ZRbFiR3XrHyCibcHFT1x89Uc56/Onlskj+/KglPb4+g1IqA0y8obwngC7DcRv3mTrSe/0iKVeXj0b8f6Bgg0Yz4RKj1qKDPCDg32RG270Xd/i7gGLhqNv2ha2aXDlx4CIM+q4fNxI8xfsvHG0RGwBhSUczaw8Ap149AOzxV20tJSG9to32pKNlMIzn0cqrW5XLkOa9eFlRgUtuo69MJaJ3X6yZnez5ZQM1J0d4Sb7LsSSIMu/nr8gLQU06m08+OAY6IZsjD8EQ8zwg== 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=92dr/xUlGIAzAm3kGZNa+Q0xO3zzm199OmpaCzPMSq4=; b=Yxcy5fLL8t98thmcOmgXFYuIhIJZCGy5+KNSlykq1a8lff5rERJ75QKQH192vBObqAwfdlW7QYME+5YDk/ShODIJphoyxEIWnBSAOnN/s/LLqeCrscZTwWYpwDhYIgr60Pyy+8UHL61n9E2/O3hxjr4Sin09SBNAWaXJDbj9WK6sWlc0N7XzFPkrhc7aXjhJs3zC8sgxsfG+jZtFofpndVp2tuWn4u89+1zP+Ev9KL3jNQWNbcUZXc/AYxyp+uXuSSoklE3b4L3I1h1S+eGk/qAIa4AJxSRVMgXUiXuH3PfDlkwKNEi5sTVAXixU7dA/c4PDQH0P4gIhPfYmUPfioQ== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM9PR03MB7962.eurprd03.prod.outlook.com (2603:10a6:20b:439::17) 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: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:08:41 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:53 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [cBAvQHCHQWFDSF3DwdFd1HKNy8IKsIkO] 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-55-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: da1c5ffb-c47e-4a5f-ea67-08d9e583f80b X-MS-TrafficTypeDiagnostic: AM9PR03MB7962:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7ifwu6jaQDTkyUsE0zvk9MvvXaKe8tzNJ8YX7kAsmsFQeStW5m+AkwOzZKb5rAEdfSU0XgeIaBcwxhHhd3Pkyzz85dxzjvZEFV2pkLWNui3aoRfhLnNv6bINSDmQPfdxQt+RvFsa/D+9IXk9GhVVNqI22RMgE7KStN58jae+19byy+omM8dvbKYridkfw76VFF3c9RjYFC7znAju84Rdh64kM9lMc0H/BA3qJFHj3sf3gXKy3312R73KicL3y6hC7GHb5x9BprrITJQrq4GFUqiXkrfo2/0jIuMbDDx9AfaUb4oLymTysqzh+E1Rzic5qa0R7uMxTP88ORqRaXZRjfhHVJV21JlgGbyIWL+J4R15M7CdQwNxlPb3bycB2Jbm2iBIO2qab/QdiSr8DNp/qhw7vt3RvYjLIYw9unh3ei8g38M+LanfNKXIFaBUOOSdiYL9qZwJ2h1b3eiuxMJXdp2y3OhlzBlWwkkGs1yaMYspCzzdMVPLfETJNU98+4Z+NleJOXcqQuoYP7B2oQxAJLiQN09KT90XBTfeicMsxbU3Z/vNKu6LZbrSI3qKF4Ez X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /F2/Xwd8N3AvmVMzYJPiFhIHCwTdKbb2dV6oPB0LAGEA9ocU9qNMipCHwZMNO67EKp3c+G9NBYkNElp6HZNl9tN9T1bG5DlG9Xgr6/5t7hscYfNyR3Y9DBJRVEAmV2wOqQdmbjvrsYeLrF9JzBQlmOkLqd5EXzZK59HOTICmLPKO7XQf8Nx0WbUvXFSY5dIH0IeTc0uhXGVDU5vQ/P8Q4AV0lbYHYGXj/rrhLBmK2isXePHbxl7aYi+u2OHtYKihfuMA9lc9iSMU2ZO17wFJT4mXnF7Ic7HSyxfwnQT5cc3albUL8tefujW9N1Bt4dPSzmdyz5LMwiyT8rn3ubHqCxcYYxG6KXHRicqjwghMQPWodcDq5P+Q9Qr7WsmAwVEUDhTOWyFtyOr+Ptu4W2YwS32MqCfhOhRD9B/1pteB9hy3xpmlp79ubPzDa0WzzHAw/bbSb2crxwGFojfWISETl6ItUPy0J71JH4zSNl1kGJyzYYhLbO5TtOB4dFKnQuEnADReNbHOgKYn5RZoNx7nHBZC356qgGl+/3FB7gVW2hFHwO88mcK7OFlhArheRJxl3ld81dzEmGXI+iOcq28IJwMmlslraNe/fq9ScQ6KF7qUD0uOKckRBRrCpCoF0j6d+scPtVpqYchBRQE/sRUq4Gud6s1y5lOly7ANbCeyT02rgV2dUtphKETMahBM/1/RxozjcjQM91BE+9um+/hS8qh7GqgtGjVYTJrnSLv0ozFL/+hjrtrit/Qyqj+Gn6d74yg2OT5WD3VOeDI/4pxQ/inGF3VEqFdsMVDzBfGpbh70fTpG4ZqSPOC0VzVXbqkQHDMgkMZJwp6Y21IHu36pL6niWG3IzRoZQU0ZSnukpku9ZvE0BZsbtMSfTxJ6n2WA788h3WgkKX8WIgEQe1eodrWzEl+BhBAkiZimsXE2Hu0/5c3XwjuFZQ+/jFOj49PdjfV5zimvWKvJh7XLpj+OrA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: da1c5ffb-c47e-4a5f-ea67-08d9e583f80b 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:41.5736 (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: AM9PR03MB7962 Subject: [FFmpeg-devel] [PATCH v2 56/69] avcodec/mpegpicture: Constify src parameter of ff_update_picture_tables 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: hk/jKuJxaYCH Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegpicture.c | 2 +- libavcodec/mpegpicture.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c index 27e497c404..07fc79685c 100644 --- a/libavcodec/mpegpicture.c +++ b/libavcodec/mpegpicture.c @@ -333,7 +333,7 @@ void ff_mpeg_unref_picture(AVCodecContext *avctx, Picture *pic) memset((uint8_t*)pic + off, 0, sizeof(*pic) - off); } -int ff_update_picture_tables(Picture *dst, Picture *src) +int ff_update_picture_tables(Picture *dst, const Picture *src) { int i, ret; diff --git a/libavcodec/mpegpicture.h b/libavcodec/mpegpicture.h index e1e9f8d7e0..67f83404fa 100644 --- a/libavcodec/mpegpicture.h +++ b/libavcodec/mpegpicture.h @@ -109,7 +109,7 @@ int ff_mpeg_ref_picture(AVCodecContext *avctx, Picture *dst, Picture *src); void ff_mpeg_unref_picture(AVCodecContext *avctx, Picture *picture); void ff_mpv_picture_free(AVCodecContext *avctx, Picture *pic); -int ff_update_picture_tables(Picture *dst, Picture *src); +int ff_update_picture_tables(Picture *dst, const Picture *src); int ff_find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared); From patchwork Tue Feb 1 13:06:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34030 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp612079iov; Tue, 1 Feb 2022 05:22:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJwGZK5jct89mvHnLAYY8dOPUymZa88Fa96y2ptSpL2Qf+vejhBxKSBodVOoyOHeUz9QA7dT X-Received: by 2002:a05:6402:2750:: with SMTP id z16mr25331769edd.312.1643721729525; Tue, 01 Feb 2022 05:22: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 ds4si9350324ejc.828.2022.02.01.05.22.09; Tue, 01 Feb 2022 05:22: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=YgjgS5wF; 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 E246668B44A; Tue, 1 Feb 2022 15:09:04 +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-oln040092074054.outbound.protection.outlook.com [40.92.74.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0013968B3F4 for ; Tue, 1 Feb 2022 15:08:51 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KMjxyyi2yrXl55TDJ0kbodE2RUqOOhncuroC1NOXAKw17bbmBfzijzpSUmILacTK6y2r0pyNjIGtpUJJScCKqr32ItMfxxWBmFiNtC3ASiCL+wsgqE9Eqetgl3cw+BWtHQjaOuk/QgnvCs2Jl6IokV96zmqQwR0qFlaONDGnFSSwK3rwfse1GigmR83ZveIoWt5AvQLSmQxmok/5lAYRNkBQGQR7mw7wetk+jpyQI4KeC2MLDmQ+KZBGUDxqQVrSr1gNjinBnm05rkcmJ5gy5/1ZCsF6iow6FF3BkoyZ8rSqsuj6DJXLjbwOPYJ3TJowfwQVzWw+kOiAJLZdhdDCmw== 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=P4m3lLk9JucmpaoSI4t+D+WE/wgb2Q8ejaWOs8bP+ro=; b=O9jrOGWJ/MPntObGgaS+XjxkE7wIsgaKpLyz8KbzNF/9S2qxCKZr2AZ2Y0LrFnFqF28iB+FxgYGtNOpJN6Ff63EnavfXbOIxtNk7UhnVAbmXuQi02vwkSMTNkg1uEcRe1Pkx1HyGvj77shTKFaAQ60eZnCxpy7M2lzSZ6iNDQRkoypROSCvTQp8D4HUhPT6J6j2y5nP4UGK8ZqeiwnZHMzaM7BibmHhOtscJFjszpv+S7gSI1MZ2mexsoKxV+LYVkBpm54z4noRIDhXKuMsPesbAWfm9wUpkZnuiN7pAlqx98EDTeiVUCRk/WY1xQFfZf4plkZgm2mHCsEskYvyTSw== 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=P4m3lLk9JucmpaoSI4t+D+WE/wgb2Q8ejaWOs8bP+ro=; b=YgjgS5wFU3fHjKRjZqqEZQx8uf/Q2JivLWslQH7SCfBIg2rtgVTBmoQstM+4IFG1oD57IDvl2W80WLkgP25KIc4/GI77QdD5gV0cf6DHFbarmyy2P5CIC6ksovKwW395DhbZK28OuVmUMxDBuj12jDiwWlohwenzHRZZo57B7uErcU8H/go35QPFTv45tK21tRagMryM41UtahazgHJeL+XOwlq/7ISqo9TnxBH4XqzvgGY1FHp92hlfT/W9AhDi236dnBlGofzuxNgx2ZBtd5d3EbpAWvZxV6yrrRENYbbT7sQULxr8wx3KWFSnG7o2NzzVtXY4Bv0iWW9E/wRhFg== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR03MB5025.eurprd03.prod.outlook.com (2603:10a6:208:102::19) 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: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:08:43 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:54 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [aUv/xP1MdxOo3g452zOrLmC7Z6baOb/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-56-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 246b5758-4cd9-441b-dff1-08d9e583f8dd X-MS-TrafficTypeDiagnostic: AM0PR03MB5025:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: y/w83RJ4iLlVhG0KBXNxkLesymGe4d5u2QmvHgGguESxKmvA9gaoEH11c3nYrUHVGDWAY9S/YYi54qARkRQfoKrwpK+RhvHXeXiR/6cl31U0OXpmEaTC8cP0+ZQ5xD16eGALKnbMvDVhanDBv63BJaMtksSkmx5lj/TQj2gpod52oo59EHju2jGnACZU5uJMEpxPKwPV1DR63VTwNLEYQux7SjcigLGmUJ1Md7MQ34FGvuIdp1toLV4lZpnaBoRN83p83M1YzkUj4EV6VezqXeUYcts8yNO0IVU1tH5BgCVw1E79nspupts2pIWaEK6HM1NHgWsxCt3HYJMQnWXKutgNBBgUI/z+hnWwl/GK76zyR7CTmSuNHvxBmWyxgFU4Gxt0Yjbwq1LyFPjeCxSuvgLKDHOPKznnSUBdP4CbhBQqLvrGOeddttKMRvZtI2Er69z11b95rEOA0GpSZzrKCFH7fnUWXbwn0Kb6usnKm6uqmchp/olqDBOfAVPlY+A79CoYyzqdClfyiprAlqRk5m4uHxNHYg8eSSUuFQe0fjPGdAj+UaXFclrZKpht/Q0E X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YW4u8SAOpKcGD5txpVGD7ShbHDJvvY3inX49R6hVYX3WSTn4yd7KohbzoQtfYaGERZIdlThufd/WMdiva00nQJISeDSbt4E1thqnowCn9dgBUtS8bQJ7ly7sxgnBgmw0vQD3kag+XsbWFIc4D9DyCFpQIvg5UIHsptA8PTvFkFVMnYgdS3fCywgWtb/bfNa6xZrVd7PQxYLeGGElOhhDKFc7tS1s4bm5YKgd1KW7zSGVf0fXz+vYxgN+szfceKk1JNdF4N7Z2sjboYaugj+c8SMjXNdaKZvZANtOzhFbWemaG2v7Tw2J/5aQ5C781R8o1lY5gDEV59dSq348w4b9QLfs2514mPAXIbnJF8XG+QC1fEblt8CRAFWhppvPh3he6ZXH9Gt52wRjcfQ4SiPGGUn60s2dN++PIxatjM9Edt8fLb7Qh0Kw0FNpCF3nApkd6DDS7jyyxsf/cMYl0dBfO5VyHv/pVCimpKjgk4vcxlqRXlJzq1AnYJM7rs4JxLoTuQ+IP/5vQmJzw4OQgpRTi0Fzv5Xs3NMVsoL7kzCEnN37EAVy6qUo2+BrXnl+IxYX94aj8VikrP5bg6g3XD3fFiLuaiItfhGG4Hnmem4A4C1dqWKuyOb67mU8l68qTLHys6OvWFbN9dG9VPiJoWAy+OTpaNhIFwpu6/CO6Sax1XqNeFaAC6R2yRvBVTnQKGlGOZEGCWg7iFlGTu1zEpJ0/7yk0v0g0R3I09R40tPdQTQ8YTkEnpoOr25Pq/9iM63kEQWLEv30J8pSFz3cltNLWdlPS3gsVjoGnWuWnCE3qdre+Uqb4jZgDipH4Nq9zUBVMgCqSID8LASBgudpTd6xlPOVHIH09iJ0cfqThqPMjRS+AmTs4TbK6CS70ORpWBcoPiBW4vwt0NAj/9FBsMfOK76zAYxb/xoGDO6llnSzlFSjKYedLRofIaSiFZ7fQQ06RvWJtXrAuP/++Br2z9+vag== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 246b5758-4cd9-441b-dff1-08d9e583f8dd 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:43.7320 (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: AM0PR03MB5025 Subject: [FFmpeg-devel] [PATCH v2 57/69] avcodec/mpegvideo: Add proper MPVMainContext 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: KTEDLYD66QTJ This will allow to remove the array of slice context pointers from MPVContext (and therefore from the slice contexts). Signed-off-by: Andreas Rheinhardt --- libavcodec/dnxhdenc.c | 40 ++-- libavcodec/dxva2_vc1.c | 16 +- libavcodec/flvdec.c | 3 +- libavcodec/flvenc.c | 2 +- libavcodec/h261dec.c | 33 ++-- libavcodec/h261enc.c | 4 +- libavcodec/h263dec.c | 58 +++--- libavcodec/intelh263dec.c | 5 +- libavcodec/ituh263dec.c | 11 +- libavcodec/ituh263enc.c | 8 +- libavcodec/mjpegenc.c | 9 +- libavcodec/mpeg12.c | 3 +- libavcodec/mpeg12dec.c | 98 ++++++---- libavcodec/mpeg12enc.c | 10 +- libavcodec/mpeg4video.c | 2 +- libavcodec/mpeg4video.h | 2 +- libavcodec/mpeg4video_parser.c | 6 +- libavcodec/mpeg4videodec.c | 68 ++++--- libavcodec/mpeg4videoenc.c | 14 +- libavcodec/mpeg_er.c | 3 +- libavcodec/mpegvideo.c | 49 +++-- libavcodec/mpegvideo.h | 4 +- libavcodec/mpegvideo_dec.c | 39 ++-- libavcodec/mpegvideo_enc.c | 37 ++-- libavcodec/mpegvideoenc.h | 2 +- libavcodec/msmpeg4.c | 3 +- libavcodec/msmpeg4dec.c | 13 +- libavcodec/msmpeg4enc.c | 6 +- libavcodec/mss2.c | 27 +-- libavcodec/nvdec_mpeg4.c | 2 +- libavcodec/nvdec_vc1.c | 4 +- libavcodec/ratecontrol.c | 22 +-- libavcodec/rv10.c | 32 ++-- libavcodec/rv10enc.c | 2 +- libavcodec/rv20enc.c | 2 +- libavcodec/rv30.c | 16 +- libavcodec/rv34.c | 105 ++++++----- libavcodec/rv40.c | 18 +- libavcodec/snow.c | 2 +- libavcodec/snowenc.c | 14 +- libavcodec/speedhqenc.c | 4 +- libavcodec/svq1enc.c | 6 +- libavcodec/vaapi_mpeg4.c | 2 +- libavcodec/vaapi_vc1.c | 50 ++--- libavcodec/vc1.c | 333 +++++++++++++++++---------------- libavcodec/vc1_block.c | 178 +++++++++--------- libavcodec/vc1_loopfilter.c | 28 +-- libavcodec/vc1_mc.c | 30 +-- libavcodec/vc1_parser.c | 8 +- libavcodec/vc1_pred.c | 22 +-- libavcodec/vc1dec.c | 63 ++++--- libavcodec/vdpau_mpeg4.c | 2 +- libavcodec/vdpau_vc1.c | 8 +- libavcodec/wmv2.c | 3 +- libavcodec/wmv2dec.c | 37 ++-- libavcodec/wmv2enc.c | 6 +- 56 files changed, 838 insertions(+), 736 deletions(-) diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index 9ad95ac20a..141ecdb5cf 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -267,7 +267,7 @@ 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; + MPVEncContext *const s = &ctx->m.common.s; if (!FF_ALLOCZ_TYPED_ARRAY(ctx->qmatrix_l, s->avctx->qmax + 1) || !FF_ALLOCZ_TYPED_ARRAY(ctx->qmatrix_c, s->avctx->qmax + 1) || @@ -336,7 +336,7 @@ static av_cold int dnxhd_init_qmat(DNXHDEncContext *ctx, int lbias, int cbias) static av_cold int dnxhd_init_rc(DNXHDEncContext *ctx) { - MPVEncContext *const s = &ctx->m.common; + MPVEncContext *const s = &ctx->m.common.s; if (!FF_ALLOCZ_TYPED_ARRAY(ctx->mb_rc, (s->avctx->qmax + 1) * s->mb_num)) return AVERROR(ENOMEM); @@ -355,7 +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; + MPVEncContext *const s = &ctx->m.common.s; int i, ret; switch (avctx->pix_fmt) { @@ -528,7 +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; + MPVEncContext *const s = &ctx->m.common.s; memset(buf, 0, ctx->data_offset); @@ -571,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.common.pb, ctx->cid_table->dc_bits[nbits] + nbits, + put_bits(&ctx->m.common.s.pb, ctx->cid_table->dc_bits[nbits] + nbits, (ctx->cid_table->dc_codes[nbits] << nbits) + av_mod_uintp2(diff, nbits)); } @@ -580,7 +580,7 @@ static av_always_inline void dnxhd_encode_block(DNXHDEncContext *ctx, int16_t *block, int last_index, int n) { - MPVEncContext *const s = &ctx->m.common; + MPVEncContext *const s = &ctx->m.common.s; int last_non_zero = 0; int slevel, i, j; @@ -620,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.common.intra_scantable.permutated[i]; + int j = ctx->m.common.s.intra_scantable.permutated[i]; level = block[j]; if (level) { if (level < 0) { @@ -668,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.common.intra_scantable.permutated[i]; + j = ctx->m.common.s.intra_scantable.permutated[i]; level = block[j]; if (level) { int run_level = i - last_non_zero - 1; @@ -683,7 +683,7 @@ 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; + MPVEncContext *const s = &ctx->m.common.s; const int bs = ctx->block_width_l2; const int bw = 1 << bs; int dct_y_offset = ctx->dct_y_offset; @@ -827,7 +827,7 @@ 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; + MPVEncContext *const s = &ctx->m.common.s; int mb_y = jobnr, mb_x; int qscale = ctx->qscale; LOCAL_ALIGNED_16(int16_t, block, [64]); @@ -885,7 +885,7 @@ static int dnxhd_encode_thread(AVCodecContext *avctx, void *arg, int jobnr, int threadnr) { DNXHDEncContext *ctx = avctx->priv_data; - MPVEncContext *const s = &ctx->m.common; + MPVEncContext *const s = &ctx->m.common.s; int mb_y = jobnr, mb_x; ctx = ctx->thread[threadnr]; init_put_bits(&s->pb, (uint8_t *)arg + ctx->data_offset + ctx->slice_offs[jobnr], @@ -922,7 +922,7 @@ static int dnxhd_encode_thread(AVCodecContext *avctx, void *arg, static void dnxhd_setup_threads_slices(DNXHDEncContext *ctx) { - MPVEncContext *const s = &ctx->m.common; + MPVEncContext *const s = &ctx->m.common.s; int mb_y, mb_x; int offset = 0; for (mb_y = 0; mb_y < s->mb_height; mb_y++) { @@ -944,7 +944,7 @@ 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; + MPVEncContext *const s = &ctx->m.common.s; int mb_y = jobnr, mb_x, x, y; int partial_last_row = (mb_y == s->mb_height - 1) && ((avctx->height >> ctx->interlaced) & 0xF); @@ -1011,7 +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; + MPVEncContext *const s = &ctx->m.common.s; int lambda, up_step, down_step; int last_lower = INT_MAX, last_higher = 0; int x, y, q; @@ -1089,7 +1089,7 @@ static int dnxhd_encode_rdo(AVCodecContext *avctx, DNXHDEncContext *ctx) static int dnxhd_find_qscale(DNXHDEncContext *ctx) { - MPVEncContext *const s = &ctx->m.common; + MPVEncContext *const s = &ctx->m.common.s; int bits = 0; int up_step = 1; int down_step = 1; @@ -1202,7 +1202,7 @@ 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; + MPVEncContext *const s = &ctx->m.common.s; int max_bits = 0; int ret, x, y; if ((ret = dnxhd_find_qscale(ctx)) < 0) @@ -1247,11 +1247,11 @@ static int dnxhd_encode_fast(AVCodecContext *avctx, DNXHDEncContext *ctx) static void dnxhd_load_picture(DNXHDEncContext *ctx, const AVFrame *frame) { - MPVEncContext *const s = &ctx->m.common; + MPVEncContext *const s = &ctx->m.common.s; 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]->m.common.s.linesize = frame->linesize[0] << ctx->interlaced; + ctx->thread[i]->m.common.s.uvlinesize = frame->linesize[1] << ctx->interlaced; ctx->thread[i]->dct_y_offset = s->linesize *8; ctx->thread[i]->dct_uv_offset = s->uvlinesize*8; } @@ -1263,7 +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; + MPVEncContext *const s = &ctx->m.common.s; int first_field = 1; int offset, i, ret; uint8_t *buf; diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c index e86f3ed0f2..836367ffe8 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 MPVDecContext *const s = &v->s; + const MPVDecContext *const s = &v->s.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 MPVDecContext *const s = &v->s; + const MPVDecContext *const s = &v->s.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 MPVDecContext *const s = &v->s; + const MPVDecContext *const s = &v->s.s; struct dxva2_picture_context *ctx_pic = s->current_picture_ptr->hwaccel_picture_private; static const uint8_t start_code[] = { 0, 0, 1, 0x0d }; @@ -313,7 +313,7 @@ static int dxva2_vc1_start_frame(AVCodecContext *avctx, { const VC1Context *v = avctx->priv_data; AVDXVAContext *ctx = DXVA_CONTEXT(avctx); - struct dxva2_picture_context *ctx_pic = v->s.current_picture_ptr->hwaccel_picture_private; + struct dxva2_picture_context *ctx_pic = v->s.s.current_picture_ptr->hwaccel_picture_private; if (!DXVA_CONTEXT_VALID(avctx, ctx)) return -1; @@ -332,7 +332,7 @@ static int dxva2_vc1_decode_slice(AVCodecContext *avctx, uint32_t size) { const VC1Context *v = avctx->priv_data; - const Picture *current_picture = v->s.current_picture_ptr; + const Picture *current_picture = v->s.s.current_picture_ptr; struct dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private; unsigned position; @@ -360,18 +360,18 @@ static int dxva2_vc1_decode_slice(AVCodecContext *avctx, static int dxva2_vc1_end_frame(AVCodecContext *avctx) { VC1Context *v = avctx->priv_data; - struct dxva2_picture_context *ctx_pic = v->s.current_picture_ptr->hwaccel_picture_private; + struct dxva2_picture_context *ctx_pic = v->s.s.current_picture_ptr->hwaccel_picture_private; int ret; if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0) return -1; - ret = ff_dxva2_common_end_frame(avctx, v->s.current_picture_ptr->f, + ret = ff_dxva2_common_end_frame(avctx, v->s.s.current_picture_ptr->f, &ctx_pic->pp, sizeof(ctx_pic->pp), NULL, 0, commit_bitstream_and_slice_buffer); if (!ret) - ff_mpeg_draw_horiz_band(&v->s, 0, avctx->height); + ff_mpeg_draw_horiz_band(&v->s.s, 0, avctx->height); return ret; } diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c index bf4df242cc..469a8ceae9 100644 --- a/libavcodec/flvdec.c +++ b/libavcodec/flvdec.c @@ -26,8 +26,9 @@ #include "mpegvideodata.h" #include "mpegvideodec.h" -int ff_flv_decode_picture_header(MPVMainDecContext *s) +int ff_flv_decode_picture_header(MPVMainDecContext *m) { + MPVDecContext *const s = &m->s; int format, width, height; /* picture header */ diff --git a/libavcodec/flvenc.c b/libavcodec/flvenc.c index ba6bce029e..ad6fb9ebd3 100644 --- a/libavcodec/flvenc.c +++ b/libavcodec/flvenc.c @@ -25,7 +25,7 @@ void ff_flv_encode_picture_header(MPVMainEncContext *m, int picture_number) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; int format; align_put_bits(&s->pb); diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c index ab534e9ff1..8113d2ff7d 100644 --- a/libavcodec/h261dec.c +++ b/libavcodec/h261dec.c @@ -82,11 +82,12 @@ static av_cold int h261_decode_init(AVCodecContext *avctx) { static AVOnce init_static_once = AV_ONCE_INIT; H261DecContext *const h = avctx->priv_data; - MPVMainDecContext *const s = &h->s; + MPVMainDecContext *const m = &h->s; + MPVDecContext *const s = &m->s; s->private_ctx = &h->common; // set defaults - ff_mpv_decode_init(s, avctx); + ff_mpv_decode_init(m, avctx); s->out_format = FMT_H261; s->low_delay = 1; @@ -106,7 +107,7 @@ static av_cold int h261_decode_init(AVCodecContext *avctx) */ static int h261_decode_gob_header(H261DecContext *h) { - MPVDecContext *const s = &h->s; + MPVDecContext *const s = &h->s.s; unsigned int val; if (!h->gob_start_code_skipped) { @@ -160,7 +161,7 @@ static int h261_decode_gob_header(H261DecContext *h) */ static int h261_resync(H261DecContext *h) { - MPVDecContext *const s = &h->s; + MPVDecContext *const s = &h->s.s; int left, ret; if (h->gob_start_code_skipped) { @@ -201,7 +202,7 @@ static int h261_resync(H261DecContext *h) */ static int h261_decode_mb_skipped(H261DecContext *h, int mba1, int mba2) { - MPVDecContext *const s = &h->s; + MPVDecContext *const s = &h->s.s; int i; s->mb_intra = 0; @@ -271,7 +272,7 @@ static int decode_mv_component(GetBitContext *gb, int v) */ static int h261_decode_block(H261DecContext *h, int16_t *block, int n, int coded) { - MPVDecContext *const s = &h->s; + MPVDecContext *const s = &h->s.s; int level, i, j, run; RLTable *rl = &ff_h261_rl_tcoeff; const uint8_t *scan_table; @@ -363,7 +364,7 @@ static int h261_decode_block(H261DecContext *h, int16_t *block, int n, int coded static int h261_decode_mb(H261DecContext *h) { - MPVDecContext *const s = &h->s; + MPVDecContext *const s = &h->s.s; H261Context *const com = &h->common; int i, cbp, xy; @@ -488,7 +489,7 @@ intra: */ static int h261_decode_picture_header(H261DecContext *h) { - MPVDecContext *const s = &h->s; + MPVDecContext *const s = &h->s.s; int format, i; uint32_t startcode = 0; @@ -552,7 +553,7 @@ static int h261_decode_picture_header(H261DecContext *h) static int h261_decode_gob(H261DecContext *h) { - MPVDecContext *const s = &h->s; + MPVDecContext *const s = &h->s.s; ff_set_qscale(s, s->qscale); @@ -597,8 +598,8 @@ 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; + MPVMainDecContext *const m = &h->s; + MPVDecContext *const s = &m->s; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; int ret; @@ -621,11 +622,11 @@ retry: } if (s->width != avctx->coded_width || s->height != avctx->coded_height) { - ff_mpv_common_end(s2); + ff_mpv_common_end(m); } if (!s->context_initialized) { - if ((ret = ff_mpv_common_init(s2)) < 0) + if ((ret = ff_mpv_common_init(m)) < 0) return ret; ret = ff_set_dimensions(avctx, s->width, s->height); @@ -644,10 +645,10 @@ retry: avctx->skip_frame >= AVDISCARD_ALL) return get_consumed_bytes(s, buf_size); - if (ff_mpv_frame_start(s, avctx) < 0) + if (ff_mpv_frame_start(m, avctx) < 0) return -1; - ff_mpeg_er_frame_start(s); + ff_mpeg_er_frame_start(m); /* decode each macroblock */ s->mb_x = 0; @@ -658,7 +659,7 @@ retry: break; h261_decode_gob(h); } - ff_mpv_frame_end(s); + ff_mpv_frame_end(m); av_assert0(s->current_picture.f->pict_type == s->current_picture_ptr->f->pict_type); av_assert0(s->current_picture.f->pict_type == s->pict_type); diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c index 9c8d9d1b08..0146ec9985 100644 --- a/libavcodec/h261enc.c +++ b/libavcodec/h261enc.c @@ -63,7 +63,7 @@ int ff_h261_get_picture_format(int width, int height) void ff_h261_encode_picture_header(MPVMainEncContext *m, int picture_number) { H261EncContext *const h = (H261EncContext *)m; - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; int format, temp_ref; align_put_bits(&s->pb); @@ -384,7 +384,7 @@ static av_cold void h261_encode_init_static(void) av_cold void ff_h261_encode_init(MPVMainEncContext *m) { H261EncContext *const h = (H261EncContext*)m; - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; static AVOnce init_static_once = AV_ONCE_INIT; s->private_ctx = &h->common; diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index df78867735..20a1348d88 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -75,13 +75,14 @@ static enum AVPixelFormat h263_get_format(AVCodecContext *avctx) av_cold int ff_h263_decode_init(AVCodecContext *avctx) { - MPVMainDecContext *const s = avctx->priv_data; + MPVMainDecContext *const m = avctx->priv_data; + MPVDecContext *const s = &m->s; int ret; s->out_format = FMT_H263; // set defaults - ff_mpv_decode_init(s, avctx); + ff_mpv_decode_init(m, avctx); s->quant_precision = 5; s->decode_mb = ff_h263_decode_mb; @@ -145,7 +146,7 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx) avctx->codec->id != AV_CODEC_ID_MPEG4) { avctx->pix_fmt = h263_get_format(avctx); ff_mpv_idct_init(s); - if ((ret = ff_mpv_common_init(s)) < 0) + if ((ret = ff_mpv_common_init(m)) < 0) return ret; } @@ -167,8 +168,9 @@ 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(MPVMainDecContext *s, int buf_size) +static int get_consumed_bytes(MPVMainDecContext *m, int buf_size) { + MPVDecContext *const s = &m->s; int pos = (get_bits_count(&s->gb) + 7) >> 3; if (s->divx_packed || s->avctx->hwaccel) { @@ -195,8 +197,9 @@ static int get_consumed_bytes(MPVMainDecContext *s, int buf_size) } } -static int decode_slice(MPVMainDecContext *s) +static int decode_slice(MPVMainDecContext *m) { + MPVDecContext *const s = &m->s; const int part_mask = s->partitioned_frame ? (ER_AC_END | ER_AC_ERROR) : 0x7F; const int mb_size = 16 >> s->avctx->lowres; @@ -427,7 +430,8 @@ static int decode_slice(MPVMainDecContext *s) int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { - MPVMainDecContext *const s = avctx->priv_data; + MPVMainDecContext *const m = avctx->priv_data; + MPVDecContext *const s = &m->s; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; int ret; @@ -500,9 +504,9 @@ retry: /* let's go :-) */ if (CONFIG_WMV2_DECODER && s->msmpeg4_version == 5) { - ret = ff_wmv2_decode_picture_header(s); + ret = ff_wmv2_decode_picture_header(m); } else if (CONFIG_MSMPEG4_DECODER && s->msmpeg4_version) { - ret = ff_msmpeg4_decode_picture_header(s); + ret = ff_msmpeg4_decode_picture_header(m); } else if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) { if (s->avctx->extradata_size && s->picture_number == 0) { GetBitContext gb; @@ -512,11 +516,11 @@ retry: } ret = ff_mpeg4_decode_picture_header(avctx->priv_data, &s->gb, 0, 0); } else if (CONFIG_H263I_DECODER && s->codec_id == AV_CODEC_ID_H263I) { - ret = ff_intel_h263_decode_picture_header(s); + ret = ff_intel_h263_decode_picture_header(m); } else if (CONFIG_FLV_DECODER && s->h263_flv) { - ret = ff_flv_decode_picture_header(s); + ret = ff_flv_decode_picture_header(m); } else { - ret = ff_h263_decode_picture_header(s); + ret = ff_h263_decode_picture_header(m); } if (ret < 0 || ret == FRAME_SKIPPED) { @@ -528,7 +532,7 @@ retry: } } if (ret == FRAME_SKIPPED) - return get_consumed_bytes(s, buf_size); + return get_consumed_bytes(m, buf_size); /* skip if the header was thrashed */ if (ret < 0) { @@ -538,7 +542,7 @@ retry: if (!s->context_initialized) { avctx->pix_fmt = h263_get_format(avctx); - if ((ret = ff_mpv_common_init(s)) < 0) + if ((ret = ff_mpv_common_init(m)) < 0) return ret; } @@ -574,7 +578,7 @@ retry: ff_set_sar(avctx, avctx->sample_aspect_ratio); - if ((ret = ff_mpv_common_frame_size_change(s))) + if ((ret = ff_mpv_common_frame_size_change(m))) return ret; if (avctx->pix_fmt != h263_get_format(avctx)) { @@ -596,13 +600,13 @@ retry: /* skip B-frames if we don't have reference frames */ if (!s->last_picture_ptr && (s->pict_type == AV_PICTURE_TYPE_B || s->droppable)) - return get_consumed_bytes(s, buf_size); + return get_consumed_bytes(m, buf_size); if ((avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B) || (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I) || avctx->skip_frame >= AVDISCARD_ALL) - return get_consumed_bytes(s, buf_size); + return get_consumed_bytes(m, buf_size); if ((!s->no_rounding) || s->pict_type == AV_PICTURE_TYPE_B) { s->me.qpel_put = s->qdsp.put_qpel_pixels_tab; @@ -612,7 +616,7 @@ retry: s->me.qpel_avg = s->qdsp.avg_qpel_pixels_tab; } - if ((ret = ff_mpv_frame_start(s, avctx)) < 0) + if ((ret = ff_mpv_frame_start(m, avctx)) < 0) return ret; if (!s->divx_packed && !avctx->hwaccel) @@ -625,13 +629,13 @@ retry: return ret; } - ff_mpeg_er_frame_start(s); + ff_mpeg_er_frame_start(m); /* the second part of the wmv2 header contains the MB skip bits which * are stored in current_picture->mb_type which is not available before * ff_mpv_frame_start() */ if (CONFIG_WMV2_DECODER && s->msmpeg4_version == 5) { - ret = ff_wmv2_decode_secondary_picture_header(s); + ret = ff_wmv2_decode_secondary_picture_header(m); if (ret < 0) return ret; if (ret == 1) @@ -642,7 +646,7 @@ retry: s->mb_x = 0; s->mb_y = 0; - slice_ret = decode_slice(s); + slice_ret = decode_slice(m); while (s->mb_y < s->mb_height) { if (s->msmpeg4_version) { if (s->slice_height == 0 || s->mb_x != 0 || slice_ret < 0 || @@ -650,7 +654,7 @@ retry: break; } else { int prev_x = s->mb_x, prev_y = s->mb_y; - if (ff_h263_resync(s) < 0) + if (ff_h263_resync(m) < 0) break; if (prev_y * s->mb_width + prev_x < s->mb_y * s->mb_width + s->mb_x) s->er.error_occurred = 1; @@ -659,14 +663,14 @@ retry: if (s->msmpeg4_version < 4 && s->h263_pred) ff_mpeg4_clean_buffers(s); - if (decode_slice(s) < 0) + if (decode_slice(m) < 0) slice_ret = AVERROR_INVALIDDATA; } if (s->msmpeg4_version && s->msmpeg4_version < 4 && s->pict_type == AV_PICTURE_TYPE_I) if (!CONFIG_MSMPEG4_DECODER || - ff_msmpeg4_decode_ext_header(s, buf_size) < 0) + ff_msmpeg4_decode_ext_header(m, buf_size) < 0) s->er.error_status_table[s->mb_num - 1] = ER_MB_ERROR; av_assert1(s->bitstream_buffer_size == 0); @@ -680,7 +684,7 @@ frame_end: return ret; } - ff_mpv_frame_end(s); + ff_mpv_frame_end(m); if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) ff_mpeg4_frame_end(avctx, buf, buf_size); @@ -694,12 +698,12 @@ frame_end: if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0) return ret; ff_print_debug_info(s, s->current_picture_ptr, pict); - ff_mpv_export_qp_table(s, pict, s->current_picture_ptr, FF_QSCALE_TYPE_MPEG1); + ff_mpv_export_qp_table(m, pict, s->current_picture_ptr, FF_QSCALE_TYPE_MPEG1); } else if (s->last_picture_ptr) { if ((ret = av_frame_ref(pict, s->last_picture_ptr->f)) < 0) return ret; ff_print_debug_info(s, s->last_picture_ptr, pict); - ff_mpv_export_qp_table(s, pict, s->last_picture_ptr, FF_QSCALE_TYPE_MPEG1); + ff_mpv_export_qp_table(m, pict, s->last_picture_ptr, FF_QSCALE_TYPE_MPEG1); } if (s->last_picture_ptr || s->low_delay) { @@ -724,7 +728,7 @@ frame_end: if (slice_ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE)) return slice_ret; else - return get_consumed_bytes(s, buf_size); + return get_consumed_bytes(m, buf_size); } const enum AVPixelFormat ff_h263_hwaccel_pixfmt_list_420[] = { diff --git a/libavcodec/intelh263dec.c b/libavcodec/intelh263dec.c index 45b66033c9..e26d45ec20 100644 --- a/libavcodec/intelh263dec.c +++ b/libavcodec/intelh263dec.c @@ -26,8 +26,9 @@ #include "mpegvideodata.h" /* don't understand why they choose a different header ! */ -int ff_intel_h263_decode_picture_header(MPVMainDecContext *s) +int ff_intel_h263_decode_picture_header(MPVMainDecContext *m) { + MPVDecContext *const s = &m->s; int format; if (get_bits_left(&s->gb) == 64) { /* special dummy frames */ @@ -124,7 +125,7 @@ int ff_intel_h263_decode_picture_header(MPVMainDecContext *s) s->y_dc_scale_table= s->c_dc_scale_table= ff_mpeg1_dc_scale_table; - ff_h263_show_pict_info(s); + ff_h263_show_pict_info(m); return 0; } diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c index 17d01c2d76..9cfdac63d6 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -73,8 +73,9 @@ static const int h263_mb_type_b_map[15]= { MB_TYPE_INTRA4x4 | MB_TYPE_CBP | MB_TYPE_QUANT, }; -void ff_h263_show_pict_info(MPVMainDecContext *s) +void ff_h263_show_pict_info(MPVMainDecContext *m) { + MPVDecContext *const s = &m->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), @@ -210,8 +211,9 @@ static int h263_decode_gob_header(MPVDecContext *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(MPVMainDecContext *s) +int ff_h263_resync(MPVMainDecContext *m) { + MPVDecContext *const s = &m->s; int left, pos, ret; /* In MPEG-4 studio mode look for a new slice startcode @@ -1086,8 +1088,9 @@ end: } /* Most is hardcoded; should extend to handle all H.263 streams. */ -int ff_h263_decode_picture_header(MPVMainDecContext *s) +int ff_h263_decode_picture_header(MPVMainDecContext *m) { + MPVDecContext *const s = &m->s; int format, width, height, i, ret; uint32_t startcode; @@ -1366,7 +1369,7 @@ int ff_h263_decode_picture_header(MPVMainDecContext *s) s->c_dc_scale_table= ff_mpeg1_dc_scale_table; } - ff_h263_show_pict_info(s); + ff_h263_show_pict_info(m); if (s->pict_type == AV_PICTURE_TYPE_I && s->codec_tag == AV_RL32("ZYGO") && get_bits_left(&s->gb) >= 85 + 13*3*16 + 50){ int i,j; for(i=0; i<85; i++) av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&s->gb)); diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c index 56f9f91d19..a2f895dfc0 100644 --- a/libavcodec/ituh263enc.c +++ b/libavcodec/ituh263enc.c @@ -104,7 +104,7 @@ av_const int ff_h263_aspect_to_info(AVRational aspect){ void ff_h263_encode_picture_header(MPVMainEncContext *m, int picture_number) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; int format, coded_frame_rate, coded_frame_rate_base, i, temp_ref; int best_clock_code=1; int best_divisor=60; @@ -269,7 +269,7 @@ void ff_h263_encode_gob_header(MPVEncContext *s, int mb_line) */ void ff_clean_h263_qscales(MPVMainEncContext *m) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; int i; int8_t * const qscale_table = s->current_picture.qscale_table; @@ -815,7 +815,7 @@ static av_cold void h263_encode_init_static(void) av_cold void ff_h263_encode_init(MPVMainEncContext *m) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; static AVOnce init_static_once = AV_ONCE_INIT; s->me.mv_penalty= mv_penalty; // FIXME exact table for MSMPEG4 & H.263+ @@ -880,7 +880,7 @@ void ff_h263_encode_mba(MPVEncContext *s) put_bits(&s->pb, ff_mba_length[i], mb_pos); } -#define OFFSET(x) offsetof(MPVMainEncContext, common.x) +#define OFFSET(x) offsetof(MPVMainEncContext, common.s.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 360653c5a1..faf59566b1 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -77,7 +77,8 @@ static av_cold void init_uni_ac_vlc(const uint8_t huff_size_ac[256], static void mjpeg_encode_picture_header(MPVMainEncContext *m) { - MPVEncContext *const s = &m->common; + MPVMainContext *const m2 = &m->common; + MPVEncContext *const s = &m2->s; ff_mjpeg_encode_picture_header(s->avctx, &s->pb, s->mjpeg_ctx, &s->intra_scantable, 0, s->intra_matrix, s->chroma_intra_matrix, @@ -91,7 +92,7 @@ static void mjpeg_encode_picture_header(MPVMainEncContext *m) void ff_mjpeg_amv_encode_picture_header(MPVMainEncContext *main) { MJPEGEncContext *const m = (MJPEGEncContext*)main; - av_assert2(main->common.mjpeg_ctx == &m->mjpeg); + av_assert2(main->common.s.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(main); @@ -105,7 +106,7 @@ void ff_mjpeg_amv_encode_picture_header(MPVMainEncContext *main) */ static void mjpeg_encode_picture_frame(MPVMainEncContext *main) { - MPVEncContext *const s = &main->common; + MPVEncContext *const s = &main->common.s; int nbits, code, table_id; MJpegContext *m = s->mjpeg_ctx; uint8_t *huff_size[4] = { m->huff_size_dc_luminance, @@ -296,7 +297,7 @@ static int alloc_huffman(MPVEncContext *s) av_cold int ff_mjpeg_encode_init(MPVMainEncContext *main) { MJpegContext *const m = &((MJPEGEncContext*)main)->mjpeg; - MPVEncContext *const s = &main->common; + MPVEncContext *const s = &main->common.s; int ret, use_slices; s->mjpeg_ctx = m; diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 7934c7ea2a..dc1ea8287e 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -100,8 +100,9 @@ av_cold void ff_init_2d_vlc_rl(RLTable *rl, unsigned static_size, int flags) } } -av_cold void ff_mpeg12_common_init(MPVMainContext *s) +av_cold void ff_mpeg12_common_init(MPVMainContext *m) { + MPVContext *const s = &m->s; s->y_dc_scale_table = s->c_dc_scale_table = ff_mpeg2_dc_scale_table[s->intra_dc_precision]; diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index d3c32818cf..ef2fa80aba 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -1056,6 +1056,7 @@ static av_cold int mpeg_decode_init(AVCodecContext *avctx) { Mpeg1Context *s = avctx->priv_data; MPVMainDecContext *const s2 = &s->mpeg_ctx; + MPVDecContext *const s3 = &s2->s; if ( avctx->codec_tag != AV_RL32("VCR2") && avctx->codec_tag != AV_RL32("BW10")) @@ -1064,11 +1065,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_mpv_idct_init(s3); ff_mpeg12_common_init(&s->mpeg_ctx); ff_mpeg12_init_vlcs(); - s2->chroma_format = 1; + s3->chroma_format = 1; s->mpeg_ctx_allocated = 0; s->repeat_field = 0; avctx->color_range = AVCOL_RANGE_MPEG; @@ -1086,7 +1087,7 @@ static int mpeg_decode_update_thread_context(AVCodecContext *avctx, if (avctx == avctx_from || !ctx_from->mpeg_ctx_allocated || - !s1->context_initialized) + !s1->s.context_initialized) return 0; err = ff_mpeg_update_thread_context(avctx, avctx_from); @@ -1166,7 +1167,8 @@ static const enum AVPixelFormat mpeg12_pixfmt_list_444[] = { static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx) { Mpeg1Context *s1 = avctx->priv_data; - MPVMainDecContext *const s = &s1->mpeg_ctx; + MPVMainDecContext *const m = &s1->mpeg_ctx; + MPVDecContext *const s = &m->s; const enum AVPixelFormat *pix_fmts; if (CONFIG_GRAY && (avctx->flags & AV_CODEC_FLAG_GRAY)) @@ -1195,7 +1197,7 @@ static void setup_hwaccel_for_pixfmt(AVCodecContext *avctx) Mpeg1Context *s1 = avctx->priv_data; MPVMainDecContext *const s = &s1->mpeg_ctx; - s->pack_pblocks = 1; + s->s.pack_pblocks = 1; } } @@ -1204,7 +1206,8 @@ static void setup_hwaccel_for_pixfmt(AVCodecContext *avctx) static int mpeg_decode_postinit(AVCodecContext *avctx) { Mpeg1Context *s1 = avctx->priv_data; - MPVMainDecContext *const s = &s1->mpeg_ctx; + MPVMainDecContext *const m = &s1->mpeg_ctx; + MPVDecContext *const s = &m->s; uint8_t old_permutation[64]; int ret; @@ -1271,7 +1274,7 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) #if FF_API_FLAG_TRUNCATED ParseContext pc = s->parse_context; s->parse_context.buffer = 0; - ff_mpv_common_end(s); + ff_mpv_common_end(m); s->parse_context = pc; #else ff_mpv_common_end(s); @@ -1329,7 +1332,7 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) memcpy(old_permutation, s->idsp.idct_permutation, 64 * sizeof(uint8_t)); ff_mpv_idct_init(s); - if ((ret = ff_mpv_common_init(s)) < 0) + if ((ret = ff_mpv_common_init(m)) < 0) return ret; quant_matrix_rebuild(s->intra_matrix, old_permutation, s->idsp.idct_permutation); @@ -1346,7 +1349,8 @@ static int mpeg1_decode_picture(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { Mpeg1Context *s1 = avctx->priv_data; - MPVMainDecContext *const s = &s1->mpeg_ctx; + MPVMainDecContext *const m = &s1->mpeg_ctx; + MPVDecContext *const s = &m->s; int ref, f_code, vbv_delay, ret; ret = init_get_bits8(&s->gb, buf, buf_size); @@ -1393,7 +1397,8 @@ static int mpeg1_decode_picture(AVCodecContext *avctx, const uint8_t *buf, static void mpeg_decode_sequence_extension(Mpeg1Context *s1) { - MPVMainDecContext *const s = &s1->mpeg_ctx; + MPVMainDecContext *const m = &s1->mpeg_ctx; + MPVDecContext *const s = &m->s; int horiz_size_ext, vert_size_ext; int bit_rate_ext; AVCPBProperties *cpb_props; @@ -1443,7 +1448,8 @@ static void mpeg_decode_sequence_extension(Mpeg1Context *s1) static void mpeg_decode_sequence_display_extension(Mpeg1Context *s1) { - MPVMainDecContext *const s = &s1->mpeg_ctx; + MPVMainDecContext *const m = &s1->mpeg_ctx; + MPVDecContext *const s = &m->s; int color_description, w, h; skip_bits(&s->gb, 3); /* video format */ @@ -1467,7 +1473,8 @@ static void mpeg_decode_sequence_display_extension(Mpeg1Context *s1) static void mpeg_decode_picture_display_extension(Mpeg1Context *s1) { - MPVMainDecContext *const s = &s1->mpeg_ctx; + MPVMainDecContext *const m = &s1->mpeg_ctx; + MPVDecContext *const s = &m->s; int i, nofco; nofco = 1; @@ -1499,7 +1506,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(MPVMainDecContext *s, uint16_t matrix0[64], +static int load_matrix(MPVDecContext *s, uint16_t matrix0[64], uint16_t matrix1[64], int intra) { int i; @@ -1522,7 +1529,7 @@ static int load_matrix(MPVMainDecContext *s, uint16_t matrix0[64], return 0; } -static void mpeg_decode_quant_matrix_extension(MPVMainDecContext *s) +static void mpeg_decode_quant_matrix_extension(MPVDecContext *s) { ff_dlog(s->avctx, "matrix extension\n"); @@ -1538,7 +1545,8 @@ static void mpeg_decode_quant_matrix_extension(MPVMainDecContext *s) static int mpeg_decode_picture_coding_extension(Mpeg1Context *s1) { - MPVMainDecContext *const s = &s1->mpeg_ctx; + MPVMainDecContext *const m = &s1->mpeg_ctx; + MPVDecContext *const s = &m->s; s->full_pel[0] = s->full_pel[1] = 0; s->mpeg_f_code[0][0] = get_bits(&s->gb, 4); @@ -1599,10 +1607,11 @@ static int mpeg_decode_picture_coding_extension(Mpeg1Context *s1) return 0; } -static int mpeg_field_start(MPVMainDecContext *s, const uint8_t *buf, int buf_size) +static int mpeg_field_start(Mpeg1Context *s1, const uint8_t *buf, int buf_size) { + MPVMainDecContext *const m = &s1->mpeg_ctx; + MPVDecContext *const s = &m->s; AVCodecContext *avctx = s->avctx; - Mpeg1Context *s1 = (Mpeg1Context *) s; int ret; if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS)) { @@ -1614,10 +1623,10 @@ static int mpeg_field_start(MPVMainDecContext *s, const uint8_t *buf, int buf_si if (s->first_field || s->picture_structure == PICT_FRAME) { AVFrameSideData *pan_scan; - if ((ret = ff_mpv_frame_start(s, avctx)) < 0) + if ((ret = ff_mpv_frame_start(m, avctx)) < 0) return ret; - ff_mpeg_er_frame_start(s); + ff_mpeg_er_frame_start(m); /* first check if we must repeat the frame */ s->current_picture_ptr->f->repeat_pict = 0; @@ -2044,7 +2053,8 @@ static int slice_decode_thread(AVCodecContext *c, void *arg) static int slice_end(AVCodecContext *avctx, AVFrame *pict) { Mpeg1Context *s1 = avctx->priv_data; - MPVMainDecContext *const s = &s1->mpeg_ctx; + MPVMainDecContext *const m = &s1->mpeg_ctx; + MPVDecContext *const s = &m->s; if (!s1->mpeg_ctx_allocated || !s->current_picture_ptr) return 0; @@ -2064,14 +2074,14 @@ static int slice_end(AVCodecContext *avctx, AVFrame *pict) ff_er_frame_end(&s->er); - ff_mpv_frame_end(s); + ff_mpv_frame_end(m); if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { int ret = av_frame_ref(pict, s->current_picture_ptr->f); if (ret < 0) return ret; ff_print_debug_info(s, s->current_picture_ptr, pict); - ff_mpv_export_qp_table(s, pict, s->current_picture_ptr, FF_QSCALE_TYPE_MPEG2); + ff_mpv_export_qp_table(m, pict, s->current_picture_ptr, FF_QSCALE_TYPE_MPEG2); } else { /* latency of 1 frame for I- and P-frames */ if (s->last_picture_ptr) { @@ -2079,7 +2089,7 @@ static int slice_end(AVCodecContext *avctx, AVFrame *pict) if (ret < 0) return ret; ff_print_debug_info(s, s->last_picture_ptr, pict); - ff_mpv_export_qp_table(s, pict, s->last_picture_ptr, FF_QSCALE_TYPE_MPEG2); + ff_mpv_export_qp_table(m, pict, s->last_picture_ptr, FF_QSCALE_TYPE_MPEG2); } } @@ -2093,7 +2103,8 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { Mpeg1Context *s1 = avctx->priv_data; - MPVMainDecContext *const s = &s1->mpeg_ctx; + MPVMainDecContext *const m = &s1->mpeg_ctx; + MPVDecContext *const s = &m->s; int width, height; int i, v, j; @@ -2181,13 +2192,14 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx, static int vcr2_init_sequence(AVCodecContext *avctx) { Mpeg1Context *s1 = avctx->priv_data; - MPVMainDecContext *const s = &s1->mpeg_ctx; + MPVMainDecContext *const m = &s1->mpeg_ctx; + MPVDecContext *const s = &m->s; int i, v, ret; /* start new MPEG-1 context decoding */ s->out_format = FMT_MPEG1; if (s1->mpeg_ctx_allocated) { - ff_mpv_common_end(s); + ff_mpv_common_end(m); s1->mpeg_ctx_allocated = 0; } s->width = avctx->coded_width; @@ -2199,7 +2211,7 @@ static int vcr2_init_sequence(AVCodecContext *avctx) setup_hwaccel_for_pixfmt(avctx); ff_mpv_idct_init(s); - if ((ret = ff_mpv_common_init(s)) < 0) + if ((ret = ff_mpv_common_init(m)) < 0) return ret; s1->mpeg_ctx_allocated = 1; @@ -2292,7 +2304,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_ctx.top_field_first) field = !field; + if (!s1->mpeg_ctx.s.top_field_first) field = !field; cap[0] = 0x04 | field; cap[1] = ff_reverse[cc1]; cap[2] = ff_reverse[cc2]; @@ -2441,7 +2453,8 @@ static void mpeg_decode_gop(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { Mpeg1Context *s1 = avctx->priv_data; - MPVMainDecContext *const s = &s1->mpeg_ctx; + MPVMainDecContext *const m = &s1->mpeg_ctx; + MPVDecContext *const s = &m->s; int broken_link; int64_t tc; @@ -2468,7 +2481,9 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture, int *got_output, const uint8_t *buf, int buf_size) { Mpeg1Context *s = avctx->priv_data; - MPVMainDecContext *const s2 = &s->mpeg_ctx; + MPVMainDecContext *const m = &s->mpeg_ctx; + MPVMainContext *const m2 = m; + MPVDecContext *const s2 = &m2->s; const uint8_t *buf_ptr = buf; const uint8_t *buf_end = buf + buf_size; int ret, input_size; @@ -2742,7 +2757,7 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture, if (s->first_slice) { skip_frame = 0; s->first_slice = 0; - if ((ret = mpeg_field_start(s2, buf, buf_size)) < 0) + if ((ret = mpeg_field_start(s, buf, buf_size)) < 0) return ret; } if (!s2->current_picture_ptr) { @@ -2803,8 +2818,9 @@ static int mpeg_decode_frame(AVCodecContext *avctx, void *data, int ret; int buf_size = avpkt->size; Mpeg1Context *s = avctx->priv_data; + MPVMainDecContext *const m = &s->mpeg_ctx; + MPVDecContext *const s2 = &m->s; AVFrame *picture = data; - MPVMainDecContext *const s2 = &s->mpeg_ctx; if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == SEQ_END_CODE)) { /* special case for last picture */ @@ -3013,7 +3029,8 @@ static int ipu_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { IPUContext *s = avctx->priv_data; - MPVMainDecContext *const m = &s->m; + MPVMainDecContext *const m2 = &s->m; + MPVDecContext *const m = &m2->s; GetBitContext *gb = &m->gb; AVFrame * const frame = data; int ret; @@ -3114,26 +3131,27 @@ static av_cold int ipu_decode_init(AVCodecContext *avctx) { IPUContext *s = avctx->priv_data; MPVMainDecContext *const m = &s->m; + MPVDecContext *const s2 = &m->s; avctx->pix_fmt = AV_PIX_FMT_YUV420P; ff_mpv_decode_init(m, avctx); - ff_mpv_idct_init(m); + ff_mpv_idct_init(s2); ff_mpeg12_common_init(m); ff_mpeg12_init_vlcs(); for (int i = 0; i < 64; i++) { - int j = m->idsp.idct_permutation[i]; + int j = s2->idsp.idct_permutation[i]; int v = ff_mpeg1_default_intra_matrix[i]; - m->intra_matrix[j] = v; - m->chroma_intra_matrix[j] = v; + s2->intra_matrix[j] = v; + s2->chroma_intra_matrix[j] = v; } for (int i = 0; i < 64; i++) { - int j = m->idsp.idct_permutation[i]; + int j = s2->idsp.idct_permutation[i]; int v = ff_mpeg1_default_non_intra_matrix[i]; - m->inter_matrix[j] = v; - m->chroma_inter_matrix[j] = v; + s2->inter_matrix[j] = v; + s2->chroma_inter_matrix[j] = v; } return 0; diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index a0cbd5d8de..4b885669bc 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -123,7 +123,7 @@ av_cold void ff_mpeg1_init_uni_ac_vlc(const RLTable *rl, uint8_t *uni_ac_vlc_len static int find_frame_rate_index(MPEG12EncContext *mpeg12) { MPVMainEncContext *const m = &mpeg12->mpeg; - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; int i; AVRational bestq = (AVRational) {0, 0}; AVRational ext; @@ -165,7 +165,7 @@ static av_cold int encode_init(AVCodecContext *avctx) { MPEG12EncContext *const mpeg12 = avctx->priv_data; MPVMainEncContext *const m = &mpeg12->mpeg; - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; int ret; int max_size = avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO ? 16383 : 4095; @@ -268,7 +268,7 @@ static void put_header(MPVEncContext *s, int header) static void mpeg1_encode_sequence_header(MPVMainEncContext *m) { MPEG12EncContext *const mpeg12 = (MPEG12EncContext*)m; - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; unsigned int vbv_buffer_size, fps, v; int constraint_parameter_flag; AVRational framerate = ff_mpeg12_frame_rate_tab[mpeg12->frame_rate_index]; @@ -457,7 +457,7 @@ void ff_mpeg1_encode_slice_header(MPVEncContext *s) void ff_mpeg1_encode_picture_header(MPVMainEncContext *m, int picture_number) { MPEG12EncContext *const mpeg12 = (MPEG12EncContext*)m; - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; AVFrameSideData *side_data; mpeg1_encode_sequence_header(m); @@ -1132,7 +1132,7 @@ static av_cold void mpeg12_encode_init_static(void) av_cold void ff_mpeg1_encode_init(MPVMainEncContext *m) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; static AVOnce init_static_once = AV_ONCE_INIT; ff_mpeg12_common_init(&m->common); diff --git a/libavcodec/mpeg4video.c b/libavcodec/mpeg4video.c index 68be7e21ed..6a5b368a17 100644 --- a/libavcodec/mpeg4video.c +++ b/libavcodec/mpeg4video.c @@ -80,7 +80,7 @@ void ff_mpeg4_clean_buffers(MPVContext *s) #define tab_bias (tab_size / 2) // used by MPEG-4 and rv10 decoder -void ff_mpeg4_init_direct_mv(MPVMainContext *s) +void ff_mpeg4_init_direct_mv(MPVContext *s) { int i; for (i = 0; i < tab_size; i++) { diff --git a/libavcodec/mpeg4video.h b/libavcodec/mpeg4video.h index 4af66be5ad..2a7e106a7a 100644 --- a/libavcodec/mpeg4video.h +++ b/libavcodec/mpeg4video.h @@ -71,7 +71,7 @@ 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); +void ff_mpeg4_init_direct_mv(MPVContext *s); /** * @return the mb_type diff --git a/libavcodec/mpeg4video_parser.c b/libavcodec/mpeg4video_parser.c index 81e5376a28..adc2409953 100644 --- a/libavcodec/mpeg4video_parser.c +++ b/libavcodec/mpeg4video_parser.c @@ -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; - MPVDecContext *const s = &dec_ctx->m; + MPVDecContext *const s = &dec_ctx->m.s; GetBitContext gb1, *gb = &gb1; int ret; @@ -131,8 +131,8 @@ static av_cold int mpeg4video_parse_init(AVCodecParserContext *s) struct Mp4vParseContext *pc = s->priv_data; pc->first_picture = 1; - pc->dec_ctx.m.quant_precision = 5; - pc->dec_ctx.m.slice_context_count = 1; + pc->dec_ctx.m.s.quant_precision = 5; + pc->dec_ctx.m.s.slice_context_count = 1; pc->dec_ctx.showed_packed_warning = 1; return 0; } diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 63fc3fa8fc..6e3981b523 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -195,7 +195,7 @@ void ff_mpeg4_pred_ac(MPVDecContext *s, int16_t *block, int n, int dir) */ static inline int mpeg4_is_resync(Mpeg4DecContext *ctx) { - MPVDecContext *const s = &ctx->m; + MPVDecContext *const s = &ctx->m.s; 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) { - MPVDecContext *const s = &ctx->m; + MPVDecContext *const s = &ctx->m.s; 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) { - MPVDecContext *const s = &ctx->m; + MPVDecContext *const s = &ctx->m.s; 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) { - MPVDecContext *const s = &ctx->m; + MPVDecContext *const s = &ctx->m.s; int mb_num_bits = av_log2(s->mb_num - 1) + 1; int header_extension = 0, mb_num, len; @@ -615,7 +615,7 @@ static void reset_studio_dc_predictors(MPVDecContext *s) */ int ff_mpeg4_decode_studio_slice_header(Mpeg4DecContext *ctx) { - MPVDecContext *const s = &ctx->m; + MPVDecContext *const s = &ctx->m.s; 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) { - MPVDecContext *const s = &ctx->m; + MPVDecContext *const s = &ctx->m.s; int x, y, mb_v, sum, dx, dy, shift; int len = 1 << (s->f_code + 4); const int a = s->sprite_warping_accuracy; @@ -757,7 +757,7 @@ static inline int mpeg4_decode_dc(MPVDecContext *s, int n, int *dir_ptr) */ static int mpeg4_decode_partition_a(Mpeg4DecContext *ctx) { - MPVDecContext *const s = &ctx->m; + MPVDecContext *const s = &ctx->m.s; 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(MPVDecContext *s, int mb_count) */ int ff_mpeg4_decode_partitions(Mpeg4DecContext *ctx) { - MPVDecContext *const s = &ctx->m; + MPVDecContext *const s = &ctx->m.s; 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) { - MPVDecContext *const s = &ctx->m; + MPVDecContext *const s = &ctx->m.s; int level, i, last, run, qmul, qadd; int av_uninit(dc_pred_dir); RLTable *rl; @@ -2133,8 +2133,9 @@ static int mpeg4_decode_studio_mb(MPVDecContext *s, int16_t block_[12][64]) return SLICE_OK; } -static int mpeg4_decode_gop_header(MPVMainDecContext *s, GetBitContext *gb) +static int mpeg4_decode_gop_header(MPVMainDecContext *m, GetBitContext *gb) { + MPVDecContext *const s = &m->s; int hours, minutes, seconds; if (!show_bits(gb, 23)) { @@ -2169,8 +2170,9 @@ static int mpeg4_decode_profile_level(GetBitContext *gb, int *profile, int *leve return 0; } -static int mpeg4_decode_visual_object(MPVMainDecContext *s, GetBitContext *gb) +static int mpeg4_decode_visual_object(MPVMainDecContext *m, GetBitContext *gb) { + MPVDecContext *const s = &m->s; int visual_object_type; int is_visual_object_identifier = get_bits1(gb); @@ -2286,7 +2288,8 @@ static void extension_and_user_data(MPVDecContext *s, GetBitContext *gb, int id) static int decode_studio_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) { - MPVMainDecContext *const s = &ctx->m; + MPVMainDecContext *const m = &ctx->m; + MPVDecContext *const s = &m->s; int width, height, aspect_ratio_info; int bits_per_raw_sample; int rgb, chroma_format; @@ -2372,7 +2375,8 @@ static int decode_studio_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) { - MPVMainDecContext *const s = &ctx->m; + MPVMainDecContext *const m = &ctx->m; + MPVDecContext *const s = &m->s; int width, height, vo_ver_id, aspect_ratio_info; /* vol header */ @@ -2747,7 +2751,7 @@ no_cplx_est: */ static int decode_user_data(Mpeg4DecContext *ctx, GetBitContext *gb) { - MPVDecContext *const s = &ctx->m; + MPVDecContext *const s = &ctx->m.s; char buf[256]; int i; int e; @@ -2805,7 +2809,8 @@ static int decode_user_data(Mpeg4DecContext *ctx, GetBitContext *gb) int ff_mpeg4_workaround_bugs(AVCodecContext *avctx) { Mpeg4DecContext *ctx = avctx->priv_data; - MPVMainDecContext *const s = &ctx->m; + MPVMainDecContext *const m = &ctx->m; + MPVDecContext *const s = &m->s; if (ctx->xvid_build == -1 && ctx->divx_version == -1 && ctx->lavc_build == -1) { if (s->codec_tag == AV_RL32("XVID") || @@ -2923,7 +2928,8 @@ int ff_mpeg4_workaround_bugs(AVCodecContext *avctx) static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb, int parse_only) { - MPVMainDecContext *const s = &ctx->m; + MPVMainDecContext *const m = &ctx->m; + MPVDecContext *const s = &m->s; int time_incr, time_increment; int64_t pts; @@ -3205,7 +3211,7 @@ end: static void decode_smpte_tc(Mpeg4DecContext *ctx, GetBitContext *gb) { - MPVDecContext *const s = &ctx->m; + MPVDecContext *const s = &ctx->m.s; skip_bits(gb, 16); /* Time_code[63..48] */ check_marker(s->avctx, gb, "after Time_code[63..48]"); @@ -3224,7 +3230,8 @@ static void decode_smpte_tc(Mpeg4DecContext *ctx, GetBitContext *gb) */ static int decode_studio_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb) { - MPVMainDecContext *const s = &ctx->m; + MPVMainDecContext *const m = &ctx->m; + MPVDecContext *const s = &m->s; if (get_bits_left(gb) <= 32) return 0; @@ -3279,7 +3286,7 @@ static int decode_studio_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb) static int decode_studiovisualobject(Mpeg4DecContext *ctx, GetBitContext *gb) { - MPVDecContext *const s = &ctx->m; + MPVDecContext *const s = &ctx->m.s; int visual_object_type; skip_bits(gb, 4); /* visual_object_verid */ @@ -3308,7 +3315,8 @@ static int decode_studiovisualobject(Mpeg4DecContext *ctx, GetBitContext *gb) int ff_mpeg4_decode_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb, int header, int parse_only) { - MPVMainDecContext *const s = &ctx->m; + MPVMainDecContext *const m = &ctx->m; + MPVDecContext *const s = &m->s; unsigned startcode, v; int ret; int vol = 0; @@ -3419,7 +3427,7 @@ int ff_mpeg4_decode_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb, } else if (startcode == USER_DATA_STARTCODE) { decode_user_data(ctx, gb); } else if (startcode == GOP_STARTCODE) { - mpeg4_decode_gop_header(s, gb); + mpeg4_decode_gop_header(m, gb); } else if (startcode == VOS_STARTCODE) { int profile, level; mpeg4_decode_profile_level(gb, &profile, &level); @@ -3439,7 +3447,7 @@ int ff_mpeg4_decode_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb, if ((ret = decode_studiovisualobject(ctx, gb)) < 0) return ret; } else - mpeg4_decode_visual_object(s, gb); + mpeg4_decode_visual_object(m, gb); } else if (startcode == VOP_STARTCODE) { break; } @@ -3466,7 +3474,8 @@ end: int ff_mpeg4_frame_end(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { Mpeg4DecContext *ctx = avctx->priv_data; - MPVMainDecContext *const s = &ctx->m; + MPVMainDecContext *const m = &ctx->m; + MPVDecContext *const s = &m->s; /* divx 5.01+ bitstream reorder stuff */ /* Since this clobbers the input buffer and hwaccel codecs still need the @@ -3518,7 +3527,7 @@ static int mpeg4_update_thread_context(AVCodecContext *dst, { Mpeg4DecContext *s = dst->priv_data; const Mpeg4DecContext *s1 = src->priv_data; - int init = s->m.context_initialized; + int init = s->m.s.context_initialized; int ret = ff_mpeg_update_thread_context(dst, src); @@ -3554,7 +3563,7 @@ static int mpeg4_update_thread_context(AVCodecContext *dst, memcpy(s->sprite_traj, s1->sprite_traj, sizeof(s1->sprite_traj)); if (CONFIG_MPEG4_DECODER && !init && s1->xvid_build >= 0) - ff_xvid_idct_init(&s->m.idsp, dst); + ff_xvid_idct_init(&s->m.s.idsp, dst); return 0; } @@ -3565,8 +3574,8 @@ static int mpeg4_update_thread_context_for_user(AVCodecContext *dst, 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; + m->s.quarter_sample = m1->s.quarter_sample; + m->s.divx_packed = m1->s.divx_packed; return 0; } @@ -3623,7 +3632,8 @@ static av_cold int decode_init(AVCodecContext *avctx) { static AVOnce init_static_once = AV_ONCE_INIT; Mpeg4DecContext *ctx = avctx->priv_data; - MPVMainDecContext *const s = &ctx->m; + MPVMainDecContext *const m = &ctx->m; + MPVDecContext *const s = &m->s; int ret; ctx->divx_version = @@ -3646,7 +3656,7 @@ static av_cold int decode_init(AVCodecContext *avctx) return 0; } -#define OFFSET(x) offsetof(MPVMainDecContext, x) +#define OFFSET(x) offsetof(MPVMainDecContext, s.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/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index a8c94c9d28..7ad93f9e4c 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -218,7 +218,7 @@ static inline int decide_ac_pred(MPVEncContext *s, int16_t block[6][64], */ void ff_clean_mpeg4_qscales(MPVMainEncContext *m) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; int i; int8_t *const qscale_table = s->current_picture.qscale_table; @@ -871,7 +871,7 @@ void ff_mpeg4_stuffing(PutBitContext *pbc) /* must be called before writing the header */ void ff_set_mpeg4_time(MPVMainEncContext *m) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; if (s->pict_type == AV_PICTURE_TYPE_B) { ff_mpeg4_init_direct_mv(s); } else { @@ -882,7 +882,7 @@ void ff_set_mpeg4_time(MPVMainEncContext *m) static void mpeg4_encode_gop_header(MPVMainEncContext *m) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; int64_t hours, minutes, seconds; int64_t time; @@ -913,7 +913,7 @@ static void mpeg4_encode_gop_header(MPVMainEncContext *m) static void mpeg4_encode_visual_object_header(MPVMainEncContext *m) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; int profile_and_level_indication; int vo_ver_id; @@ -960,7 +960,7 @@ static void mpeg4_encode_vol_header(MPVMainEncContext *m, int vo_number, int vol_number) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; int vo_ver_id, vo_type, aspect_ratio_info; if (s->max_b_frames || s->quarter_sample) { @@ -1060,7 +1060,7 @@ static void mpeg4_encode_vol_header(MPVMainEncContext *m, /* write MPEG-4 VOP header */ int ff_mpeg4_encode_picture_header(MPVMainEncContext *m, int picture_number) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; uint64_t time_incr; int64_t time_div, time_mod; @@ -1283,7 +1283,7 @@ static av_cold int encode_init(AVCodecContext *avctx) { static AVOnce init_static_once = AV_ONCE_INIT; MPVMainEncContext *const m = avctx->priv_data; - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; int ret; if (avctx->width >= (1<<13) || avctx->height >= (1<<13)) { diff --git a/libavcodec/mpeg_er.c b/libavcodec/mpeg_er.c index d2968b448b..b788a2f8fd 100644 --- a/libavcodec/mpeg_er.c +++ b/libavcodec/mpeg_er.c @@ -43,8 +43,9 @@ static void set_erpic(ERPicture *dst, Picture *src) dst->field_picture = src->field_picture; } -void ff_mpeg_er_frame_start(MPVMainDecContext *s) +void ff_mpeg_er_frame_start(MPVMainDecContext *m) { + MPVDecContext *const s = &m->s; ERContext *er = &s->er; set_erpic(&er->cur_pic, s->current_picture_ptr); diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index b71e12c3d9..072a82e6b3 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -277,8 +277,10 @@ 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(MPVMainContext *s) +static av_cold int dct_init(MPVMainContext *m) { + MPVContext *const s = &m->s; + ff_blockdsp_init(&s->bdsp, s->avctx); ff_h264chroma_init(&s->h264chroma, 8); //for lowres ff_hpeldsp_init(&s->hdsp, s->avctx->flags); @@ -389,8 +391,9 @@ static int init_duplicate_context(MPVContext *s) return 0; } -int ff_mpv_init_duplicate_contexts(MPVMainContext *s) +int ff_mpv_init_duplicate_contexts(MPVMainContext *m) { + MPVContext *const s = &m->s; int nb_slices = s->slice_context_count, ret; /* We initialize the copies before the original so that @@ -433,8 +436,10 @@ static void free_duplicate_context(MPVContext *s) s->block = NULL; } -static void free_duplicate_contexts(MPVMainContext *s) +static void free_duplicate_contexts(MPVMainContext *m) { + MPVContext *const s = &m->s; + for (int i = 1; i < s->slice_context_count; i++) { free_duplicate_context(s->thread_context[i]); av_freep(&s->thread_context[i]); @@ -500,8 +505,10 @@ int ff_update_duplicate_context(MPVContext *dst, const MPVContext *src) * The changed fields will not depend upon the * prior state of the MPVMainContext. */ -void ff_mpv_common_defaults(MPVMainContext *s) +void ff_mpv_common_defaults(MPVMainContext *m) { + MPVContext *const s = &m->s; + s->y_dc_scale_table = s->c_dc_scale_table = ff_mpeg1_dc_scale_table; s->chroma_qscale_table = ff_default_chroma_qscale_table; @@ -518,8 +525,9 @@ void ff_mpv_common_defaults(MPVMainContext *s) s->slice_context_count = 1; } -int ff_mpv_init_context_frame(MPVMainContext *s) +int ff_mpv_init_context_frame(MPVMainContext *m) { + MPVContext *const s = &m->s; int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y; s->mb_width = (s->width + 15) / 16; @@ -604,8 +612,10 @@ int ff_mpv_init_context_frame(MPVMainContext *s) return !CONFIG_MPEGVIDEODEC || s->encoding ? 0 : ff_mpeg_er_init(s); } -static void clear_context(MPVMainContext *s) +static void clear_context(MPVMainContext *m) { + MPVContext *const s = &m->s; + memset(&s->next_picture, 0, sizeof(s->next_picture)); memset(&s->last_picture, 0, sizeof(s->last_picture)); memset(&s->current_picture, 0, sizeof(s->current_picture)); @@ -656,14 +666,15 @@ static void clear_context(MPVMainContext *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(MPVMainContext *s) +av_cold int ff_mpv_common_init(MPVMainContext *m) { + MPVContext *const s = &m->s; int i, ret; int nb_slices = (HAVE_THREADS && s->avctx->active_thread_type & FF_THREAD_SLICE) ? s->avctx->thread_count : 1; - clear_context(s); + clear_context(m); if (s->encoding && s->avctx->slices) nb_slices = s->avctx->slices; @@ -694,7 +705,7 @@ av_cold int ff_mpv_common_init(MPVMainContext *s) av_image_check_size(s->width, s->height, 0, s->avctx)) return AVERROR(EINVAL); - dct_init(s); + dct_init(m); /* set chroma shifts */ ret = av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt, @@ -717,7 +728,7 @@ av_cold int ff_mpv_common_init(MPVMainContext *s) !(s->new_picture.f = av_frame_alloc())) goto fail_nomem; - if ((ret = ff_mpv_init_context_frame(s))) + if ((ret = ff_mpv_init_context_frame(m))) goto fail; #if FF_API_FLAG_TRUNCATED @@ -730,7 +741,7 @@ av_cold int ff_mpv_common_init(MPVMainContext *s) s->slice_context_count = nb_slices; // if (s->width && s->height) { - ret = ff_mpv_init_duplicate_contexts(s); + ret = ff_mpv_init_duplicate_contexts(m); if (ret < 0) goto fail; // } @@ -739,13 +750,15 @@ av_cold int ff_mpv_common_init(MPVMainContext *s) fail_nomem: ret = AVERROR(ENOMEM); fail: - ff_mpv_common_end(s); + ff_mpv_common_end(m); return ret; } -void ff_mpv_free_context_frame(MPVMainContext *s) +void ff_mpv_free_context_frame(MPVMainContext *m) { - free_duplicate_contexts(s); + MPVContext *const s = &m->s; + + free_duplicate_contexts(m); av_freep(&s->p_field_mv_table_base); for (int i = 0; i < 2; i++) @@ -768,12 +781,14 @@ void ff_mpv_free_context_frame(MPVMainContext *s) } /* init common structure for both encoder and decoder */ -void ff_mpv_common_end(MPVMainContext *s) +void ff_mpv_common_end(MPVMainContext *m) { - if (!s) + MPVContext *s; + if (!m) return; + s = &m->s; - ff_mpv_free_context_frame(s); + ff_mpv_free_context_frame(m); if (s->slice_context_count > 1) s->slice_context_count = 1; diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index cb947ff56b..9adadc5b02 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -504,7 +504,9 @@ typedef struct MPVContext { * also show what needs to be resolved in order for a codec to * support slice threading. */ -typedef MPVContext MPVMainContext; +typedef struct MPVMainContext { + MPVContext s; +} MPVMainContext; /** * Set the given MPVMainContext to common defaults (same for encoding diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c index 6ed0716e0d..e70e306cf9 100644 --- a/libavcodec/mpegvideo_dec.c +++ b/libavcodec/mpegvideo_dec.c @@ -34,9 +34,11 @@ #include "mpegvideodec.h" #include "thread.h" -void ff_mpv_decode_init(MPVMainDecContext *s, AVCodecContext *avctx) +void ff_mpv_decode_init(MPVMainDecContext *m, AVCodecContext *avctx) { - ff_mpv_common_defaults(s); + MPVDecContext *const s = &m->s; + + ff_mpv_common_defaults(m); s->avctx = avctx; s->width = avctx->coded_width; @@ -51,8 +53,10 @@ void ff_mpv_decode_init(MPVMainDecContext *s, AVCodecContext *avctx) int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src) { - MPVMainDecContext *const s1 = src->priv_data; - MPVMainDecContext *const s = dst->priv_data; + MPVMainDecContext *const m1 = src->priv_data; + MPVMainDecContext *const m = dst->priv_data; + MPVDecContext *const s1 = &m1->s; + MPVDecContext *const s = &m->s; int ret; if (dst == src) @@ -76,7 +80,7 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst, // s->picture_range_start += MAX_PICTURE_COUNT; // s->picture_range_end += MAX_PICTURE_COUNT; ff_mpv_idct_init(s); - if ((err = ff_mpv_common_init(s)) < 0) { + if ((err = ff_mpv_common_init(m)) < 0) { memset(s, 0, sizeof(*s)); s->avctx = dst; s->private_ctx = private_ctx; @@ -88,7 +92,7 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst, if (s->height != s1->height || s->width != s1->width || s->context_reinit) { s->height = s1->height; s->width = s1->width; - if ((ret = ff_mpv_common_frame_size_change(s)) < 0) + if ((ret = ff_mpv_common_frame_size_change(m)) < 0) return ret; } @@ -191,14 +195,15 @@ do {\ return 0; } -int ff_mpv_common_frame_size_change(MPVMainDecContext *s) +int ff_mpv_common_frame_size_change(MPVMainDecContext *m) { + MPVDecContext *const s = &m->s; int err = 0; if (!s->context_initialized) return AVERROR(EINVAL); - ff_mpv_free_context_frame(s); + ff_mpv_free_context_frame(m); if (s->picture) for (int i = 0; i < MAX_PICTURE_COUNT; i++) @@ -225,14 +230,14 @@ int ff_mpv_common_frame_size_change(MPVMainDecContext *s) if (err < 0) goto fail; - if ((err = ff_mpv_init_context_frame(s))) + if ((err = ff_mpv_init_context_frame(m))) goto fail; memset(s->thread_context, 0, sizeof(s->thread_context)); s->thread_context[0] = s; if (s->width && s->height) { - err = ff_mpv_init_duplicate_contexts(s); + err = ff_mpv_init_duplicate_contexts(m); if (err < 0) goto fail; } @@ -240,7 +245,7 @@ int ff_mpv_common_frame_size_change(MPVMainDecContext *s) return 0; fail: - ff_mpv_free_context_frame(s); + ff_mpv_free_context_frame(m); s->context_reinit = 1; return err; } @@ -273,8 +278,9 @@ static void gray_frame(AVFrame *frame) * generic function called after decoding * the header and before a frame is decoded. */ -int ff_mpv_frame_start(MPVMainDecContext *s, AVCodecContext *avctx) +int ff_mpv_frame_start(MPVMainDecContext *m, AVCodecContext *avctx) { + MPVDecContext *const s = &m->s; Picture *pic; int idx, ret; @@ -497,8 +503,9 @@ int ff_mpv_frame_start(MPVMainDecContext *s, AVCodecContext *avctx) } /* called after a frame has been decoded. */ -void ff_mpv_frame_end(MPVMainDecContext *s) +void ff_mpv_frame_end(MPVMainDecContext *m) { + MPVDecContext *const s = &m->s; emms_c(); if (s->current_picture.reference) @@ -512,8 +519,9 @@ void ff_print_debug_info(MPVDecContext *s, Picture *p, AVFrame *pict) s->mb_width, s->mb_height, s->mb_stride, s->quarter_sample); } -int ff_mpv_export_qp_table(MPVMainDecContext *s, AVFrame *f, Picture *p, int qp_type) +int ff_mpv_export_qp_table(MPVMainDecContext *m, AVFrame *f, Picture *p, int qp_type) { + MPVDecContext *const s = &m->s; AVVideoEncParams *par; int mult = (qp_type == FF_QSCALE_TYPE_MPEG1) ? 2 : 1; unsigned int nb_mb = p->alloc_mb_height * p->alloc_mb_width; @@ -552,7 +560,8 @@ void ff_mpeg_draw_horiz_band(MPVDecContext *s, int y, int h) void ff_mpeg_flush(AVCodecContext *avctx) { - MPVMainDecContext *const s = avctx->priv_data; + MPVMainDecContext *const m = avctx->priv_data; + MPVDecContext *const s = &m->s; if (!s->picture) return; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 6c40bdb39e..656aab04cf 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -239,7 +239,7 @@ void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix) */ void ff_init_qscale_tab(MPVMainEncContext *m) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; int8_t * const qscale_table = s->current_picture.qscale_table; int i; @@ -281,7 +281,7 @@ static void mpv_encode_init_static(void) static void mpv_encode_defaults(MPVMainEncContext *m) { MPVMainContext *const com = &m->common; - MPVEncContext *const s = com; + MPVEncContext *const s = &com->s; static AVOnce init_static_once = AV_ONCE_INIT; ff_mpv_common_defaults(com); @@ -317,7 +317,8 @@ av_cold int ff_dct_encode_init(MPVEncContext *s) av_cold int ff_mpv_encode_init(AVCodecContext *avctx) { MPVMainEncContext *const m = avctx->priv_data; - MPVMainContext *const s = &m->common; + MPVMainContext *const m2 = &m->common; + MPVEncContext *const s = &m2->s; AVCPBProperties *cpb_props; int i, ret, mv_table_size, mb_array_size; @@ -811,7 +812,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) /* init */ ff_mpv_idct_init(s); - if ((ret = ff_mpv_common_init(s)) < 0) + if ((ret = ff_mpv_common_init(m2)) < 0) return ret; ff_fdctdsp_init(&s->fdsp, avctx); @@ -986,7 +987,8 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) av_cold int ff_mpv_encode_end(AVCodecContext *avctx) { MPVMainEncContext *const m = avctx->priv_data; - MPVMainContext *const s = &m->common; + MPVMainContext *const m2 = &m->common; + MPVEncContext *const s = &m2->s; ff_rate_control_uninit(m); @@ -1069,7 +1071,7 @@ static int alloc_picture(MPVEncContext *s, Picture *pic, int shared) static int load_input_picture(MPVMainEncContext *m, const AVFrame *pic_arg) { MPVMainContext *const com = &m->common; - MPVEncContext *const s = com; + MPVEncContext *const s = &com->s; Picture *pic = NULL; int64_t pts; int i, display_picture_number = 0, ret; @@ -1221,7 +1223,7 @@ static int load_input_picture(MPVMainEncContext *m, const AVFrame *pic_arg) static int skip_check(MPVMainEncContext *m, Picture *p, Picture *ref) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; int x, y, plane; int score = 0; int64_t score64 = 0; @@ -1284,7 +1286,7 @@ static int encode_frame(AVCodecContext *c, AVFrame *frame, AVPacket *pkt) static int estimate_best_b_count(MPVMainEncContext *m) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; AVPacket *pkt; const int scale = m->brd_scale; int width = s->width >> scale; @@ -1431,7 +1433,8 @@ fail: static int select_input_picture(MPVMainEncContext *m) { - MPVEncContext *const s = &m->common; + MPVMainContext *const m2 = &m->common; + MPVEncContext *const s = &m2->s; int i, ret; for (i = 1; i < MAX_PICTURE_COUNT; i++) @@ -1609,7 +1612,7 @@ no_output_pic: static void frame_end(MPVMainEncContext *m) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; if (s->unrestricted_mv && s->current_picture.reference && !s->intra_only) { @@ -1647,7 +1650,7 @@ static void frame_end(MPVMainEncContext *m) static void update_noise_reduction(MPVMainEncContext *m) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; int intra, i; for (intra = 0; intra < 2; intra++) { @@ -1669,7 +1672,7 @@ static void update_noise_reduction(MPVMainEncContext *m) static int frame_start(MPVMainEncContext *m) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; int ret; /* mark & release old frames */ @@ -1743,7 +1746,8 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic_arg, int *got_packet) { MPVMainEncContext *const m = avctx->priv_data; - MPVEncContext *const s = &m->common; + MPVMainContext *const m2 = &m->common; + MPVEncContext *const s = &m2->s; int i, stuffing_count, ret; int context_count = s->slice_context_count; @@ -3497,7 +3501,7 @@ static void merge_context_after_encode(MPVEncContext *dst, MPVEncContext *src) static int estimate_qp(MPVMainEncContext *m, int dry_run) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; if (m->next_lambda) { s->current_picture_ptr->f->quality = s->current_picture.f->quality = m->next_lambda; @@ -3537,7 +3541,7 @@ static int estimate_qp(MPVMainEncContext *m, int dry_run) /* must be called before writing the header */ static void set_frame_distances(MPVMainEncContext *m) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.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; @@ -3553,7 +3557,8 @@ static void set_frame_distances(MPVMainEncContext *m) static int encode_picture(MPVMainEncContext *m, int picture_number) { - MPVEncContext *const s = &m->common; + MPVMainContext *const m2 = &m->common; + MPVEncContext *const s = &m2->s; int i, ret; int bits; int context_count = s->slice_context_count; diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index 5c579cc155..6dc940d3aa 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -149,7 +149,7 @@ typedef struct MPVMainEncContext { { "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_MAIN_OFFSET(x) offsetof(MPVMainEncContext, x) -#define FF_MPV_OFFSET(x) FF_MPV_MAIN_OFFSET(common.x) +#define FF_MPV_OFFSET(x) FF_MPV_MAIN_OFFSET(common.s.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/msmpeg4.c b/libavcodec/msmpeg4.c index 3658df6b08..8c364ef356 100644 --- a/libavcodec/msmpeg4.c +++ b/libavcodec/msmpeg4.c @@ -112,9 +112,10 @@ static av_cold void msmpeg4_common_init_static(void) init_h263_dc_for_msmpeg4(); } -av_cold void ff_msmpeg4_common_init(MPVMainContext *s) +av_cold void ff_msmpeg4_common_init(MPVMainContext *m) { static AVOnce init_static_once = AV_ONCE_INIT; + MPVContext *const s = &m->s; switch(s->msmpeg4_version){ case 1: diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c index c8527d18dc..f02181e075 100644 --- a/libavcodec/msmpeg4dec.c +++ b/libavcodec/msmpeg4dec.c @@ -296,7 +296,8 @@ static int msmpeg4v34_decode_mb(MPVDecContext *s, int16_t block[6][64]) /* init all vlc decoding tables */ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx) { - MPVMainDecContext *const s = avctx->priv_data; + MPVMainDecContext *const m = avctx->priv_data; + MPVDecContext *const s = &m->s; static volatile int done = 0; int ret; MVTable *mv; @@ -307,7 +308,7 @@ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx) if (ff_h263_decode_init(avctx) < 0) return -1; - ff_msmpeg4_common_init(s); + ff_msmpeg4_common_init(m); if (!done) { INIT_FIRST_VLC_RL(ff_rl_table[0], 642); @@ -399,8 +400,9 @@ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx) return 0; } -int ff_msmpeg4_decode_picture_header(MPVMainDecContext *s) +int ff_msmpeg4_decode_picture_header(MPVMainDecContext *m) { + MPVDecContext *const s = &m->s; int code; // at minimum one bit per macroblock is required at least in a valid frame, @@ -467,7 +469,7 @@ int ff_msmpeg4_decode_picture_header(MPVMainDecContext *s) s->dc_table_index = get_bits1(&s->gb); break; case 4: - ff_msmpeg4_decode_ext_header(s, (2+5+5+17+7)/8); + ff_msmpeg4_decode_ext_header(m, (2+5+5+17+7)/8); if(s->bit_rate > MBAC_BITRATE) s->per_mb_rl_table= get_bits1(&s->gb); else s->per_mb_rl_table= 0; @@ -555,8 +557,9 @@ int ff_msmpeg4_decode_picture_header(MPVMainDecContext *s) return 0; } -int ff_msmpeg4_decode_ext_header(MPVMainDecContext *s, int buf_size) +int ff_msmpeg4_decode_ext_header(MPVMainDecContext *m, int buf_size) { + MPVDecContext *const s = &m->s; int left= buf_size*8 - get_bits_count(&s->gb); int length= s->msmpeg4_version>=3 ? 17 : 16; /* the alt_bitstream reader could read over the end so we need to check it */ diff --git a/libavcodec/msmpeg4enc.c b/libavcodec/msmpeg4enc.c index f8080a194c..b25c0df063 100644 --- a/libavcodec/msmpeg4enc.c +++ b/libavcodec/msmpeg4enc.c @@ -137,7 +137,7 @@ static av_cold void msmpeg4_encode_init_static(void) av_cold void ff_msmpeg4_encode_init(MPVMainEncContext *m) { static AVOnce init_static_once = AV_ONCE_INIT; - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; ff_msmpeg4_common_init(&m->common); if (s->msmpeg4_version >= 4) { @@ -152,7 +152,7 @@ av_cold void ff_msmpeg4_encode_init(MPVMainEncContext *m) static void find_best_tables(MSMPEG4EncContext *ms) { MPVMainEncContext *const m = &ms->s; - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; int i; int best = 0, best_size = INT_MAX; int chroma_best = 0, best_chroma_size = INT_MAX; @@ -219,7 +219,7 @@ static void find_best_tables(MSMPEG4EncContext *ms) void ff_msmpeg4_encode_picture_header(MPVMainEncContext *m, int picture_number) { MSMPEG4EncContext *const ms = (MSMPEG4EncContext*)m; - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; find_best_tables(ms); diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c index 2a89bd47e8..66ce266b51 100644 --- a/libavcodec/mss2.c +++ b/libavcodec/mss2.c @@ -382,7 +382,8 @@ 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; - MPVMainDecContext *const s = &v->s; + MPVMainDecContext *const m = &v->s; + MPVDecContext *const s = &m->s; AVFrame *f; int ret; @@ -394,24 +395,24 @@ static int decode_wmv9(AVCodecContext *avctx, const uint8_t *buf, int buf_size, s->loop_filter = avctx->skip_loop_filter < AVDISCARD_ALL; if (ff_vc1_parse_frame_header(v, &s->gb) < 0) { - av_log(v->s.avctx, AV_LOG_ERROR, "header error\n"); + av_log(s->avctx, AV_LOG_ERROR, "header error\n"); return AVERROR_INVALIDDATA; } if (s->pict_type != AV_PICTURE_TYPE_I) { - av_log(v->s.avctx, AV_LOG_ERROR, "expected I-frame\n"); + av_log(s->avctx, AV_LOG_ERROR, "expected I-frame\n"); return AVERROR_INVALIDDATA; } avctx->pix_fmt = AV_PIX_FMT_YUV420P; - if ((ret = ff_mpv_frame_start(s, avctx)) < 0) { - av_log(v->s.avctx, AV_LOG_ERROR, "ff_mpv_frame_start error\n"); + if ((ret = ff_mpv_frame_start(m, avctx)) < 0) { + av_log(s->avctx, AV_LOG_ERROR, "ff_mpv_frame_start error\n"); avctx->pix_fmt = AV_PIX_FMT_RGB24; return ret; } - ff_mpeg_er_frame_start(s); + ff_mpeg_er_frame_start(m); v->end_mb_x = (w + 15) >> 4; s->end_mb_y = (h + 15) >> 4; @@ -425,12 +426,12 @@ static int decode_wmv9(AVCodecContext *avctx, const uint8_t *buf, int buf_size, if (v->end_mb_x == s->mb_width && s->end_mb_y == s->mb_height) { ff_er_frame_end(&s->er); } else { - av_log(v->s.avctx, AV_LOG_WARNING, + av_log(s->avctx, AV_LOG_WARNING, "disabling error correction due to block count mismatch %dx%d != %dx%d\n", v->end_mb_x, s->end_mb_y, s->mb_width, s->mb_height); } - ff_mpv_frame_end(s); + ff_mpv_frame_end(m); f = s->current_picture.f; @@ -439,7 +440,7 @@ static int decode_wmv9(AVCodecContext *avctx, const uint8_t *buf, int buf_size, ctx->dsp.upsample_plane(f->data[1], f->linesize[1], w+1 >> 1, h+1 >> 1); ctx->dsp.upsample_plane(f->data[2], f->linesize[2], w+1 >> 1, h+1 >> 1); } else if (v->respic) - avpriv_request_sample(v->s.avctx, + avpriv_request_sample(s->avctx, "Asymmetric WMV9 rectangle subsampling"); av_assert0(f->linesize[1] == f->linesize[2]); @@ -750,7 +751,7 @@ static av_cold int wmv9_init(AVCodecContext *avctx) VC1Context *v = avctx->priv_data; int ret; - v->s.avctx = avctx; + v->s.s.avctx = avctx; ff_vc1_init_common(v); @@ -782,7 +783,7 @@ static av_cold int wmv9_init(AVCodecContext *avctx) v->resync_marker = 0; v->rangered = 0; - v->s.max_b_frames = avctx->max_b_frames = 0; + v->s.s.max_b_frames = avctx->max_b_frames = 0; v->quantizer_mode = 0; v->finterpflag = 0; @@ -796,8 +797,8 @@ static av_cold int wmv9_init(AVCodecContext *avctx) return ret; /* error concealment */ - v->s.me.qpel_put = v->s.qdsp.put_qpel_pixels_tab; - v->s.me.qpel_avg = v->s.qdsp.avg_qpel_pixels_tab; + v->s.s.me.qpel_put = v->s.s.qdsp.put_qpel_pixels_tab; + v->s.s.me.qpel_avg = v->s.s.qdsp.avg_qpel_pixels_tab; return 0; } diff --git a/libavcodec/nvdec_mpeg4.c b/libavcodec/nvdec_mpeg4.c index b00e415b5c..5c37dba3e4 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; - MPVDecContext *const s = &m->m; + MPVDecContext *const s = &m->m.s; 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 9dc9f49b6a..afec5c1f7c 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; - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.s; NVDECContext *ctx = avctx->internal->hwaccel_priv_data; CUVIDPICPARAMS *pp = &ctx->pic_params; @@ -87,7 +87,7 @@ static int nvdec_vc1_start_frame(AVCodecContext *avctx, const uint8_t *buffer, u .extended_mv = v->extended_mv, .dquant = v->dquant, .vstransform = v->vstransform, - .loopfilter = v->s.loop_filter, + .loopfilter = v->s.s.loop_filter, .fastuvmc = v->fastuvmc, .overlap = v->overlap, .quantizer = v->quantizer_mode, diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c index bbaa9191a0..bdf5c82aa1 100644 --- a/libavcodec/ratecontrol.c +++ b/libavcodec/ratecontrol.c @@ -37,7 +37,7 @@ void ff_write_pass1_stats(MPVMainEncContext *m) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; 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", @@ -80,7 +80,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; + MPVEncContext *const s = &m->common.s; RateControlContext *rcc = &m->rc_context; AVCodecContext *a = s->avctx; const int pict_type = rce->new_pict_type; @@ -121,7 +121,7 @@ static double get_diff_limited_q(MPVMainEncContext *m, RateControlEntry *rce, do static void get_qminmax(int *qmin_ret, int *qmax_ret, MPVMainEncContext *m, int pict_type) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; int qmin = m->lmin; int qmax = m->lmax; @@ -151,7 +151,7 @@ static void get_qminmax(int *qmin_ret, int *qmax_ret, static double modify_qscale(MPVMainEncContext *m, RateControlEntry *rce, double q, int frame_num) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; RateControlContext *rcc = &m->rc_context; const double buffer_size = s->avctx->rc_buffer_size; const double fps = get_fps(s->avctx); @@ -243,7 +243,7 @@ static double modify_qscale(MPVMainEncContext *m, RateControlEntry *rce, static double get_qscale(MPVMainEncContext *m, RateControlEntry *rce, double rate_factor, int frame_num) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; RateControlContext *rcc = &m->rc_context; AVCodecContext *a = s->avctx; const int pict_type = rce->new_pict_type; @@ -316,7 +316,7 @@ static double get_qscale(MPVMainEncContext *m, RateControlEntry *rce, static int init_pass2(MPVMainEncContext *m) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; RateControlContext *rcc = &m->rc_context; AVCodecContext *a = s->avctx; int i, toobig; @@ -478,7 +478,7 @@ static int init_pass2(MPVMainEncContext *m) av_cold int ff_rate_control_init(MPVMainEncContext *m) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; RateControlContext *rcc = &m->rc_context; int i, res; static const char * const const_names[] = { @@ -688,7 +688,7 @@ av_cold void ff_rate_control_uninit(MPVMainEncContext *m) int ff_vbv_update(MPVMainEncContext *m, int frame_size) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; RateControlContext *rcc = &m->rc_context; const double fps = get_fps(s->avctx); const int buffer_size = s->avctx->rc_buffer_size; @@ -748,7 +748,7 @@ static void update_predictor(Predictor *p, double q, double var, double size) static void adaptive_quantization(MPVMainEncContext *m, double q) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; 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); @@ -866,7 +866,7 @@ static void adaptive_quantization(MPVMainEncContext *m, double q) void ff_get_2pass_fcode(MPVMainEncContext *m) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; RateControlContext *rcc = &m->rc_context; RateControlEntry *rce = &rcc->entry[s->picture_number]; @@ -878,7 +878,7 @@ void ff_get_2pass_fcode(MPVMainEncContext *m) float ff_rate_estimate_qscale(MPVMainEncContext *m, int dry_run) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; float q; int qmin, qmax; float br_compensation; diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c index 10450aa791..1a59b2a578 100644 --- a/libavcodec/rv10.c +++ b/libavcodec/rv10.c @@ -157,7 +157,8 @@ static int rv10_decode_picture_header(MPVDecContext *s) static int rv20_decode_picture_header(RVDecContext *rv, int whole_size) { - MPVMainDecContext *const s = &rv->m; + MPVMainDecContext *const m = &rv->m; + MPVDecContext *const s = &m->s; int seq, mb_pos, i, ret; int rpr_max; @@ -237,7 +238,7 @@ static int rv20_decode_picture_header(RVDecContext *rv, int whole_size) if (whole_size < (new_w + 15)/16 * ((new_h + 15)/16) / 8) return AVERROR_INVALIDDATA; - ff_mpv_common_end(s); + ff_mpv_common_end(m); // attempt to keep aspect during typical resolution switches if (!old_aspect.num) @@ -253,7 +254,7 @@ static int rv20_decode_picture_header(RVDecContext *rv, int whole_size) s->width = new_w; s->height = new_h; - if ((ret = ff_mpv_common_init(s)) < 0) + if ((ret = ff_mpv_common_init(m)) < 0) return ret; } @@ -367,7 +368,8 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx) { static AVOnce init_static_once = AV_ONCE_INIT; RVDecContext *rv = avctx->priv_data; - MPVMainDecContext *const s = &rv->m; + MPVMainDecContext *const m = &rv->m; + MPVDecContext *const s = &m->s; int major_ver, minor_ver, micro_ver, ret; if (avctx->extradata_size < 8) { @@ -378,7 +380,7 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx) avctx->coded_height, 0, avctx)) < 0) return ret; - ff_mpv_decode_init(s, avctx); + ff_mpv_decode_init(m, avctx); s->out_format = FMT_H263; @@ -420,7 +422,7 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx) avctx->pix_fmt = AV_PIX_FMT_YUV420P; ff_mpv_idct_init(s); - if ((ret = ff_mpv_common_init(s)) < 0) + if ((ret = ff_mpv_common_init(m)) < 0) return ret; ff_h263dsp_init(&s->h263dsp); @@ -443,7 +445,8 @@ 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; - MPVDecContext *const s = &rv->m; + MPVMainDecContext *const m = &rv->m; + MPVDecContext *const s = &m->s; int mb_count, mb_pos, left, start_mb_x, active_bits_size, ret; active_bits_size = buf_size * 8; @@ -477,12 +480,12 @@ static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf, // FIXME write parser so we always have complete frames? if (s->current_picture_ptr) { ff_er_frame_end(&s->er); - ff_mpv_frame_end(s); + ff_mpv_frame_end(m); s->mb_x = s->mb_y = s->resync_mb_x = s->resync_mb_y = 0; } - if ((ret = ff_mpv_frame_start(s, avctx)) < 0) + if ((ret = ff_mpv_frame_start(m, avctx)) < 0) return ret; - ff_mpeg_er_frame_start(s); + ff_mpeg_er_frame_start(m); } else { if (s->current_picture_ptr->f->pict_type != s->pict_type) { av_log(s->avctx, AV_LOG_ERROR, "Slice type mismatch\n"); @@ -595,9 +598,10 @@ static int get_slice_offset(AVCodecContext *avctx, const uint8_t *buf, int n) static int rv10_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { + MPVMainDecContext *const m = avctx->priv_data; + MPVDecContext *const s = &m->s; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; - MPVMainDecContext *const s = avctx->priv_data; AVFrame *pict = data; int i, ret; int slice_count; @@ -656,18 +660,18 @@ static int rv10_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, if (s->current_picture_ptr && s->mb_y >= s->mb_height) { ff_er_frame_end(&s->er); - ff_mpv_frame_end(s); + ff_mpv_frame_end(m); if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0) return ret; ff_print_debug_info(s, s->current_picture_ptr, pict); - ff_mpv_export_qp_table(s, pict, s->current_picture_ptr, FF_QSCALE_TYPE_MPEG1); + ff_mpv_export_qp_table(m, pict, s->current_picture_ptr, FF_QSCALE_TYPE_MPEG1); } else if (s->last_picture_ptr) { if ((ret = av_frame_ref(pict, s->last_picture_ptr->f)) < 0) return ret; ff_print_debug_info(s, s->last_picture_ptr, pict); - ff_mpv_export_qp_table(s, pict,s->last_picture_ptr, FF_QSCALE_TYPE_MPEG1); + ff_mpv_export_qp_table(m, pict,s->last_picture_ptr, FF_QSCALE_TYPE_MPEG1); } if (s->last_picture_ptr || s->low_delay) { diff --git a/libavcodec/rv10enc.c b/libavcodec/rv10enc.c index ddbea6298c..4940e35de3 100644 --- a/libavcodec/rv10enc.c +++ b/libavcodec/rv10enc.c @@ -31,7 +31,7 @@ int ff_rv10_encode_picture_header(MPVMainEncContext *m, int picture_number) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; int full_frame= 0; align_put_bits(&s->pb); diff --git a/libavcodec/rv20enc.c b/libavcodec/rv20enc.c index 06f6751549..3e26151513 100644 --- a/libavcodec/rv20enc.c +++ b/libavcodec/rv20enc.c @@ -34,7 +34,7 @@ void ff_rv20_encode_picture_header(MPVMainEncContext *m, int picture_number) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; 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/rv30.c b/libavcodec/rv30.c index 698765bef4..edaf4c0e1e 100644 --- a/libavcodec/rv30.c +++ b/libavcodec/rv30.c @@ -37,9 +37,9 @@ static int rv30_parse_slice_header(RV34DecContext *r, GetBitContext *gb, SliceInfo *si) { - AVCodecContext *avctx = r->s.avctx; + AVCodecContext *avctx = r->s.s.avctx; int mb_bits; - int w = r->s.width, h = r->s.height; + int w = r->s.s.width, h = r->s.s.height; int mb_size; int rpr; @@ -67,8 +67,8 @@ static int rv30_parse_slice_header(RV34DecContext *r, GetBitContext *gb, SliceIn return AVERROR(EINVAL); } - w = r->s.avctx->extradata[6 + rpr*2] << 2; - h = r->s.avctx->extradata[7 + rpr*2] << 2; + w = r->s.s.avctx->extradata[6 + rpr*2] << 2; + h = r->s.s.avctx->extradata[7 + rpr*2] << 2; } else { w = r->orig_width; h = r->orig_height; @@ -93,7 +93,7 @@ static int rv30_decode_intra_types(RV34DecContext *r, GetBitContext *gb, int8_t for(j = 0; j < 4; j+= 2){ unsigned code = get_interleaved_ue_golomb(gb) << 1; if (code > 80U*2U) { - av_log(r->s.avctx, AV_LOG_ERROR, "Incorrect intra prediction code\n"); + av_log(r->s.s.avctx, AV_LOG_ERROR, "Incorrect intra prediction code\n"); return -1; } for(k = 0; k < 2; k++){ @@ -101,7 +101,7 @@ static int rv30_decode_intra_types(RV34DecContext *r, GetBitContext *gb, int8_t int B = dst[-1] + 1; *dst++ = rv30_itype_from_context[A * 90 + B * 9 + rv30_itype_code[code + k]]; if(dst[-1] == 9){ - av_log(r->s.avctx, AV_LOG_ERROR, "Incorrect intra prediction mode\n"); + av_log(r->s.s.avctx, AV_LOG_ERROR, "Incorrect intra prediction mode\n"); return -1; } } @@ -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 }; - MPVDecContext *const s = &r->s; + MPVDecContext *const s = &r->s.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) { - MPVDecContext *const s = &r->s; + MPVDecContext *const s = &r->s.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 83d601c57b..a3437099b2 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) { - MPVDecContext *const s = &r->s; + MPVDecContext *const s = &r->s.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) { - MPVDecContext *const s = &r->s; + MPVDecContext *const s = &r->s.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) { - MPVDecContext *const s = &r->s; + MPVDecContext *const s = &r->s.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) { - MPVDecContext *const s = &r->s; + MPVDecContext *const s = &r->s.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) { - MPVDecContext *const s = &r->s; + MPVDecContext *const s = &r->s.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)) { - MPVDecContext *const s = &r->s; + MPVDecContext *const s = &r->s.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; @@ -783,24 +783,24 @@ static void rv34_mc_1mv(RV34DecContext *r, const int block_type, static void rv4_weight(RV34DecContext *r) { - r->rdsp.rv40_weight_pixels_tab[r->scaled_weight][0](r->s.dest[0], + r->rdsp.rv40_weight_pixels_tab[r->scaled_weight][0](r->s.s.dest[0], r->tmp_b_block_y[0], r->tmp_b_block_y[1], r->weight1, r->weight2, - r->s.linesize); - r->rdsp.rv40_weight_pixels_tab[r->scaled_weight][1](r->s.dest[1], + r->s.s.linesize); + r->rdsp.rv40_weight_pixels_tab[r->scaled_weight][1](r->s.s.dest[1], r->tmp_b_block_uv[0], r->tmp_b_block_uv[2], r->weight1, r->weight2, - r->s.uvlinesize); - r->rdsp.rv40_weight_pixels_tab[r->scaled_weight][1](r->s.dest[2], + r->s.s.uvlinesize); + r->rdsp.rv40_weight_pixels_tab[r->scaled_weight][1](r->s.s.dest[2], r->tmp_b_block_uv[1], r->tmp_b_block_uv[3], r->weight1, r->weight2, - r->s.uvlinesize); + r->s.s.uvlinesize); } static void rv34_mc_2mv(RV34DecContext *r, const int block_type) @@ -829,11 +829,11 @@ static void rv34_mc_2mv_skip(RV34DecContext *r) for(j = 0; j < 2; j++) for(i = 0; i < 2; i++){ - rv34_mc(r, RV34_MB_P_8x8, i*8, j*8, i+j*r->s.b8_stride, 1, 1, 0, r->rv30, + rv34_mc(r, RV34_MB_P_8x8, i*8, j*8, i+j*r->s.s.b8_stride, 1, 1, 0, r->rv30, weighted, r->rdsp.put_pixels_tab, r->rdsp.put_chroma_pixels_tab); - rv34_mc(r, RV34_MB_P_8x8, i*8, j*8, i+j*r->s.b8_stride, 1, 1, 1, r->rv30, + rv34_mc(r, RV34_MB_P_8x8, i*8, j*8, i+j*r->s.s.b8_stride, 1, 1, 1, r->rv30, weighted, weighted ? r->rdsp.put_pixels_tab : r->rdsp.avg_pixels_tab, weighted ? r->rdsp.put_chroma_pixels_tab : r->rdsp.avg_chroma_pixels_tab); @@ -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) { - MPVDecContext *const s = &r->s; + MPVDecContext *const s = &r->s.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) { - MPVDecContext *const s = &r->s; + MPVDecContext *const s = &r->s.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]); - MPVDecContext *const s = &r->s; + MPVDecContext *const s = &r->s.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) { - MPVDecContext *const s = &r->s; + MPVDecContext *const s = &r->s.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) { - MPVDecContext *const s = &r->s; + MPVDecContext *const s = &r->s.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) { - MPVDecContext *const s = &r->s; + MPVDecContext *const s = &r->s.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) { - MPVDecContext *const s = &r->s; + MPVDecContext *const s = &r->s.s; int cbp, dist; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; @@ -1346,7 +1346,7 @@ static int check_slice_end(RV34DecContext *r, MPVDecContext *s) return 1; if(!s->mb_num_left) return 1; - if(r->s.mb_skip_run > 1) + if(r->s.s.mb_skip_run > 1) return 0; bits = get_bits_left(&s->gb); if(bits <= 0 || (bits < 8 && !show_bits(&s->gb, bits))) @@ -1369,22 +1369,22 @@ static void rv34_decoder_free(RV34DecContext *r) static int rv34_decoder_alloc(RV34DecContext *r) { - r->intra_types_stride = r->s.mb_width * 4 + 4; + r->intra_types_stride = r->s.s.mb_width * 4 + 4; - r->cbp_chroma = av_mallocz(r->s.mb_stride * r->s.mb_height * + r->cbp_chroma = av_mallocz(r->s.s.mb_stride * r->s.s.mb_height * sizeof(*r->cbp_chroma)); - r->cbp_luma = av_mallocz(r->s.mb_stride * r->s.mb_height * + r->cbp_luma = av_mallocz(r->s.s.mb_stride * r->s.s.mb_height * sizeof(*r->cbp_luma)); - r->deblock_coefs = av_mallocz(r->s.mb_stride * r->s.mb_height * + r->deblock_coefs = av_mallocz(r->s.s.mb_stride * r->s.s.mb_height * sizeof(*r->deblock_coefs)); r->intra_types_hist = av_malloc(r->intra_types_stride * 4 * 2 * sizeof(*r->intra_types_hist)); - r->mb_type = av_mallocz(r->s.mb_stride * r->s.mb_height * + r->mb_type = av_mallocz(r->s.s.mb_stride * r->s.s.mb_height * sizeof(*r->mb_type)); if (!(r->cbp_chroma && r->cbp_luma && r->deblock_coefs && r->intra_types_hist && r->mb_type)) { - r->s.context_reinit = 1; + r->s.s.context_reinit = 1; rv34_decoder_free(r); return AVERROR(ENOMEM); } @@ -1404,12 +1404,12 @@ static int rv34_decoder_realloc(RV34DecContext *r) static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int buf_size) { - MPVDecContext *const s = &r->s; + MPVDecContext *const s = &r->s.s; GetBitContext *gb = &s->gb; int mb_pos, slice_type; int res; - init_get_bits(&r->s.gb, buf, buf_size*8); + init_get_bits(&r->s.s.gb, buf, buf_size*8); res = r->parse_slice_header(r, gb, &r->si); if(res < 0){ av_log(s->avctx, AV_LOG_ERROR, "Incorrect or unknown slice header\n"); @@ -1429,7 +1429,7 @@ static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int r->si.end = end; s->qscale = r->si.quant; s->mb_num_left = r->si.end - r->si.start; - r->s.mb_skip_run = 0; + r->s.s.mb_skip_run = 0; mb_pos = s->mb_x + s->mb_y * s->mb_width; if(r->si.start != mb_pos){ @@ -1488,10 +1488,11 @@ av_cold int ff_rv34_decode_init(AVCodecContext *avctx) { static AVOnce init_static_once = AV_ONCE_INIT; RV34DecContext *r = avctx->priv_data; - MPVMainDecContext *const s = &r->s; + MPVMainDecContext *const m = &r->s; + MPVDecContext *const s = &m->s; int ret; - ff_mpv_decode_init(s, avctx); + ff_mpv_decode_init(m, avctx); s->out_format = FMT_H263; avctx->pix_fmt = AV_PIX_FMT_YUV420P; @@ -1499,7 +1500,7 @@ av_cold int ff_rv34_decode_init(AVCodecContext *avctx) s->low_delay = 0; ff_mpv_idct_init(s); - if ((ret = ff_mpv_common_init(s)) < 0) + if ((ret = ff_mpv_common_init(m)) < 0) return ret; ff_h264_pred_init(&r->h, AV_CODEC_ID_RV40, 8, 1); @@ -1517,8 +1518,10 @@ 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; - MPVMainDecContext *const s = &r->s; - const MPVMainDecContext *const s1 = &r1->s; + MPVMainDecContext *const m = &r->s; + MPVDecContext *const s = &m->s; + const MPVMainDecContext *const m1 = &r1->s; + const MPVDecContext *const s1 = &m1->s; int err; if (dst == src || !s1->context_initialized) @@ -1527,7 +1530,7 @@ int ff_rv34_decode_update_thread_context(AVCodecContext *dst, const AVCodecConte if (s->height != s1->height || s->width != s1->width || s->context_reinit) { s->height = s1->height; s->width = s1->width; - if ((err = ff_mpv_common_frame_size_change(s)) < 0) + if ((err = ff_mpv_common_frame_size_change(m)) < 0) return err; if ((err = rv34_decoder_realloc(r)) < 0) return err; @@ -1559,11 +1562,12 @@ 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; - MPVMainDecContext *const s = &r->s; + MPVMainDecContext *const m = &r->s; + MPVDecContext *const s = &m->s; int got_picture = 0, ret; ff_er_frame_end(&s->er); - ff_mpv_frame_end(s); + ff_mpv_frame_end(m); s->mb_num_left = 0; if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) @@ -1573,13 +1577,13 @@ static int finish_frame(AVCodecContext *avctx, AVFrame *pict) if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0) return ret; ff_print_debug_info(s, s->current_picture_ptr, pict); - ff_mpv_export_qp_table(s, pict, s->current_picture_ptr, FF_QSCALE_TYPE_MPEG1); + ff_mpv_export_qp_table(m, pict, s->current_picture_ptr, FF_QSCALE_TYPE_MPEG1); got_picture = 1; } else if (s->last_picture_ptr) { if ((ret = av_frame_ref(pict, s->last_picture_ptr->f)) < 0) return ret; ff_print_debug_info(s, s->last_picture_ptr, pict); - ff_mpv_export_qp_table(s, pict, s->last_picture_ptr, FF_QSCALE_TYPE_MPEG1); + ff_mpv_export_qp_table(m, pict, s->last_picture_ptr, FF_QSCALE_TYPE_MPEG1); got_picture = 1; } @@ -1603,7 +1607,8 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; RV34DecContext *r = avctx->priv_data; - MPVMainDecContext *const s = &r->s; + MPVMainDecContext *const m = &r->s; + MPVDecContext *const s = &m->s; AVFrame *pict = data; SliceInfo si; int i, ret; @@ -1641,7 +1646,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, return AVERROR_INVALIDDATA; } init_get_bits(&s->gb, buf+offset, (buf_size-offset)*8); - if(r->parse_slice_header(r, &r->s.gb, &si) < 0 || si.start){ + if(r->parse_slice_header(r, &r->s.s.gb, &si) < 0 || si.start){ av_log(avctx, AV_LOG_ERROR, "First slice header is incorrect\n"); return AVERROR_INVALIDDATA; } @@ -1663,7 +1668,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, s->mb_num_left); if (!s->context_reinit) ff_er_frame_end(&s->er); - ff_mpv_frame_end(s); + ff_mpv_frame_end(m); } if (s->width != si.width || s->height != si.height || s->context_reinit) { @@ -1684,7 +1689,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, err = ff_set_dimensions(s->avctx, s->width, s->height); if (err < 0) return err; - if ((err = ff_mpv_common_frame_size_change(s)) < 0) + if ((err = ff_mpv_common_frame_size_change(m)) < 0) return err; if ((err = rv34_decoder_realloc(r)) < 0) return err; @@ -1692,9 +1697,9 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, if (faulty_b) return AVERROR_INVALIDDATA; s->pict_type = si.type ? si.type : AV_PICTURE_TYPE_I; - if (ff_mpv_frame_start(s, s->avctx) < 0) + if (ff_mpv_frame_start(m, s->avctx) < 0) return -1; - ff_mpeg_er_frame_start(s); + ff_mpeg_er_frame_start(m); if (!r->tmp_b_block_base) { int i; @@ -1761,7 +1766,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, size = offset1 - offset; r->si.end = s->mb_width * s->mb_height; - s->mb_num_left = r->s.mb_x + r->s.mb_y*r->s.mb_width - r->si.start; + s->mb_num_left = r->s.s.mb_x + r->s.s.mb_y*r->s.s.mb_width - r->si.start; if(i+1 < slice_count){ int offset2 = get_slice_offset(avctx, slices_hdr, i+2, slice_count, buf_size); @@ -1770,7 +1775,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, break; } init_get_bits(&s->gb, buf+offset1, (buf_size-offset1)*8); - if(r->parse_slice_header(r, &r->s.gb, &si) < 0){ + if(r->parse_slice_header(r, &r->s.s.gb, &si) < 0){ size = offset2 - offset; }else r->si.end = si.start; @@ -1796,7 +1801,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, /* always mark the current frame as finished, frame-mt supports * only complete frames */ ff_er_frame_end(&s->er); - ff_mpv_frame_end(s); + ff_mpv_frame_end(m); s->mb_num_left = 0; ff_thread_report_progress(&s->current_picture_ptr->tf, INT_MAX, 0); return AVERROR_INVALIDDATA; diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c index cc069b3f2b..89b6a8c46a 100644 --- a/libavcodec/rv40.c +++ b/libavcodec/rv40.c @@ -136,7 +136,7 @@ static void rv40_parse_picture_size(GetBitContext *gb, int *w, int *h) static int rv40_parse_slice_header(RV34DecContext *r, GetBitContext *gb, SliceInfo *si) { int mb_bits; - int w = r->s.width, h = r->s.height; + int w = r->s.s.width, h = r->s.s.height; int mb_size; int ret; @@ -153,7 +153,7 @@ static int rv40_parse_slice_header(RV34DecContext *r, GetBitContext *gb, SliceIn si->pts = get_bits(gb, 13); if(!si->type || !get_bits1(gb)) rv40_parse_picture_size(gb, &w, &h); - if ((ret = av_image_check_size(w, h, 0, r->s.avctx)) < 0) + if ((ret = av_image_check_size(w, h, 0, r->s.s.avctx)) < 0) return ret; si->width = w; si->height = h; @@ -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) { - MPVDecContext *const s = &r->s; + MPVDecContext *const s = &r->s.s; int i, j, k, v; int A, B, C; int pattern; @@ -231,19 +231,19 @@ static int rv40_decode_intra_types(RV34DecContext *r, GetBitContext *gb, int8_t */ static int rv40_decode_mb_info(RV34DecContext *r) { - MPVDecContext *const s = &r->s; + MPVDecContext *const s = &r->s.s; GetBitContext *gb = &s->gb; int q, i; int prev_type = 0; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; - if(!r->s.mb_skip_run) { - r->s.mb_skip_run = get_interleaved_ue_golomb(gb) + 1; - if(r->s.mb_skip_run > (unsigned)s->mb_num) + if (!s->mb_skip_run) { + s->mb_skip_run = get_interleaved_ue_golomb(gb) + 1; + if (s->mb_skip_run > (unsigned)s->mb_num) return -1; } - if(--r->s.mb_skip_run) + if (--s->mb_skip_run) return RV34_MB_SKIP; if(r->avail_cache[6-4]){ @@ -341,7 +341,7 @@ static void rv40_adaptive_loop_filter(RV34DSPContext *rdsp, */ static void rv40_loop_filter(RV34DecContext *r, int row) { - MPVDecContext *const s = &r->s; + MPVDecContext *const s = &r->s.s; int mb_pos, mb_x; int i, j, k; uint8_t *Y, *C; diff --git a/libavcodec/snow.c b/libavcodec/snow.c index de9741a888..073943a594 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -689,7 +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; + MPVEncContext *const m = &s->m.common.s; av_freep(&s->spatial_dwt_buffer); av_freep(&s->temp_dwt_buffer); diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index ce5baa754f..7200d94f65 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -39,7 +39,7 @@ static av_cold int encode_init(AVCodecContext *avctx) { SnowContext *s = avctx->priv_data; - MPVEncContext *const mpv = &s->m.common; + MPVEncContext *const mpv = &s->m.common.s; int plane_index, ret; int i; @@ -217,7 +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; + MPVEncContext *const mpv = &s->m.common.s; uint8_t p_buffer[1024]; uint8_t i_buffer[1024]; uint8_t p_state[sizeof(s->block_state)]; @@ -511,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.common.sc.obmc_scratchpad + plane_index*block_size*block_size*4; //FIXME change to unsigned + IDWTELEM *dst= (IDWTELEM*)s->m.common.s.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; @@ -598,7 +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; + MPVEncContext *const mpv = &s->m.common.s; 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; @@ -700,7 +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; + MPVEncContext *const mpv = &s->m.common.s; int i, y2; Plane *p= &s->plane[plane_index]; const int block_size = MB_SIZE >> s->block_max_depth; @@ -1481,7 +1481,7 @@ static int qscale2qlog(int qscale){ static int ratecontrol_1pass(SnowContext *s, AVFrame *pict) { - MPVEncContext *const mpv = &s->m.common; + MPVEncContext *const mpv = &s->m.common.s; /* 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. */ @@ -1562,7 +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; + MPVEncContext *const mpv = &s->m.common.s; RangeCoder * const c= &s->c; AVFrame *pic; const int width= s->avctx->width; diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c index 6f89927d68..cfd5beea04 100644 --- a/libavcodec/speedhqenc.c +++ b/libavcodec/speedhqenc.c @@ -91,7 +91,7 @@ static av_cold void speedhq_init_static_data(void) av_cold int ff_speedhq_encode_init(MPVMainEncContext *m) { - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; static AVOnce init_static_once = AV_ONCE_INIT; if (s->width > 65500 || s->height > 65500) { @@ -129,7 +129,7 @@ av_cold int ff_speedhq_encode_init(MPVMainEncContext *m) void ff_speedhq_encode_picture_header(MPVMainEncContext *m) { SpeedHQEncContext *ctx = (SpeedHQEncContext*)m; - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; 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 5e26c1073a..3a84bb6a07 100644 --- a/libavcodec/svq1enc.c +++ b/libavcodec/svq1enc.c @@ -253,7 +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; + MPVEncContext *const mpv = &s->m.common.s; int x, y; int i; int block_width, block_height; @@ -488,7 +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; + MPVEncContext *const mpv = &s->m.common.s; int i; if (avctx->frame_number) @@ -520,7 +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; + MPVEncContext *const mpv = &s->m.common.s; int ret; if (avctx->width >= 4096 || avctx->height >= 4096) { diff --git a/libavcodec/vaapi_mpeg4.c b/libavcodec/vaapi_mpeg4.c index 1e746ecc6a..0a0c2d0f8e 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; - MPVDecContext *const s = &ctx->m; + MPVDecContext *const s = &ctx->m.s; VAAPIDecodePicture *pic = s->current_picture_ptr->hwaccel_picture_private; VAPictureParameterBufferMPEG4 pic_param; int i, err; diff --git a/libavcodec/vaapi_vc1.c b/libavcodec/vaapi_vc1.c index 6830c12236..fd3b963e33 100644 --- a/libavcodec/vaapi_vc1.c +++ b/libavcodec/vaapi_vc1.c @@ -46,7 +46,7 @@ static inline int vc1_has_MVTYPEMB_bitplane(const VC1Context *v) if (v->mv_type_is_raw) return 0; return v->fcm == PROGRESSIVE && - (v->s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) && + (v->s.s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) && (v->mv_mode == MV_PMODE_MIXED_MV || (v->mv_mode == MV_PMODE_INTENSITY_COMP && v->mv_mode2 == MV_PMODE_MIXED_MV)); @@ -58,8 +58,8 @@ static inline int vc1_has_SKIPMB_bitplane(const VC1Context *v) if (v->skip_is_raw) return 0; return (v->fcm == PROGRESSIVE || v->fcm == ILACE_FRAME) && - ((v->s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) || - (v->s.pict_type == AV_PICTURE_TYPE_B && !v->bi_type)); + ((v->s.s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) || + (v->s.s.pict_type == AV_PICTURE_TYPE_B && !v->bi_type)); } /** Check whether the DIRECTMB bitplane is present */ @@ -68,7 +68,7 @@ static inline int vc1_has_DIRECTMB_bitplane(const VC1Context *v) if (v->dmb_is_raw) return 0; return (v->fcm == PROGRESSIVE || v->fcm == ILACE_FRAME) && - (v->s.pict_type == AV_PICTURE_TYPE_B && !v->bi_type); + (v->s.s.pict_type == AV_PICTURE_TYPE_B && !v->bi_type); } /** Check whether the ACPRED bitplane is present */ @@ -77,8 +77,8 @@ static inline int vc1_has_ACPRED_bitplane(const VC1Context *v) if (v->acpred_is_raw) return 0; return v->profile == PROFILE_ADVANCED && - (v->s.pict_type == AV_PICTURE_TYPE_I || - (v->s.pict_type == AV_PICTURE_TYPE_B && v->bi_type)); + (v->s.s.pict_type == AV_PICTURE_TYPE_I || + (v->s.s.pict_type == AV_PICTURE_TYPE_B && v->bi_type)); } /** Check whether the OVERFLAGS bitplane is present */ @@ -87,8 +87,8 @@ static inline int vc1_has_OVERFLAGS_bitplane(const VC1Context *v) if (v->overflg_is_raw) return 0; return v->profile == PROFILE_ADVANCED && - (v->s.pict_type == AV_PICTURE_TYPE_I || - (v->s.pict_type == AV_PICTURE_TYPE_B && v->bi_type)) && + (v->s.s.pict_type == AV_PICTURE_TYPE_I || + (v->s.s.pict_type == AV_PICTURE_TYPE_B && v->bi_type)) && (v->overlap && v->pq <= 8) && v->condover == CONDOVER_SELECT; } @@ -99,8 +99,8 @@ static inline int vc1_has_FIELDTX_bitplane(const VC1Context *v) if (v->fieldtx_is_raw) return 0; return v->fcm == ILACE_FRAME && - (v->s.pict_type == AV_PICTURE_TYPE_I || - (v->s.pict_type == AV_PICTURE_TYPE_B && v->bi_type)); + (v->s.s.pict_type == AV_PICTURE_TYPE_I || + (v->s.s.pict_type == AV_PICTURE_TYPE_B && v->bi_type)); } /** Check whether the FORWARDMB bitplane is present */ @@ -109,13 +109,13 @@ static inline int vc1_has_FORWARDMB_bitplane(const VC1Context *v) if (v->fmb_is_raw) return 0; return v->fcm == ILACE_FIELD && - (v->s.pict_type == AV_PICTURE_TYPE_B && !v->bi_type); + (v->s.s.pict_type == AV_PICTURE_TYPE_B && !v->bi_type); } /** Reconstruct bitstream PTYPE (7.1.1.4, index into Table-35) */ static int vc1_get_PTYPE(const VC1Context *v) { - const MPVDecContext *const s = &v->s; + const MPVDecContext *const s = &v->s.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 MPVDecContext *const s = &v->s; + const MPVDecContext *const s = &v->s.s; switch (s->pict_type) { case AV_PICTURE_TYPE_I: return 0; case AV_PICTURE_TYPE_P: return 3; @@ -140,8 +140,8 @@ static int vc1_get_FPTYPE(const VC1Context *v) static inline VAMvModeVC1 vc1_get_MVMODE(const VC1Context *v) { if ((v->fcm == PROGRESSIVE || v->fcm == ILACE_FIELD) && - ((v->s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) || - (v->s.pict_type == AV_PICTURE_TYPE_B && !v->bi_type))) + ((v->s.s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) || + (v->s.s.pict_type == AV_PICTURE_TYPE_B && !v->bi_type))) return get_VAMvModeVC1(v->mv_mode); return 0; } @@ -150,7 +150,7 @@ static inline VAMvModeVC1 vc1_get_MVMODE(const VC1Context *v) static inline VAMvModeVC1 vc1_get_MVMODE2(const VC1Context *v) { if ((v->fcm == PROGRESSIVE || v->fcm == ILACE_FIELD) && - (v->s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) && + (v->s.s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) && v->mv_mode == MV_PMODE_INTENSITY_COMP) return get_VAMvModeVC1(v->mv_mode2); return 0; @@ -158,7 +158,7 @@ static inline VAMvModeVC1 vc1_get_MVMODE2(const VC1Context *v) av_unused static inline int vc1_get_INTCOMPFIELD(const VC1Context *v) { - if ((v->s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) && + if ((v->s.s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) && v->fcm == ILACE_FIELD && v->mv_mode == MV_PMODE_INTENSITY_COMP) switch (v->intcompfield) { @@ -171,7 +171,7 @@ av_unused static inline int vc1_get_INTCOMPFIELD(const VC1Context *v) static inline int vc1_get_LUMSCALE(const VC1Context *v) { - if (v->s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) { + if (v->s.s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) { if ((v->fcm == PROGRESSIVE && v->mv_mode == MV_PMODE_INTENSITY_COMP) || (v->fcm == ILACE_FRAME && v->intcomp)) return v->lumscale; @@ -187,7 +187,7 @@ static inline int vc1_get_LUMSCALE(const VC1Context *v) static inline int vc1_get_LUMSHIFT(const VC1Context *v) { - if (v->s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) { + if (v->s.s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) { if ((v->fcm == PROGRESSIVE && v->mv_mode == MV_PMODE_INTENSITY_COMP) || (v->fcm == ILACE_FRAME && v->intcomp)) return v->lumshift; @@ -203,7 +203,7 @@ static inline int vc1_get_LUMSHIFT(const VC1Context *v) av_unused static inline int vc1_get_LUMSCALE2(const VC1Context *v) { - if ((v->s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) && + if ((v->s.s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) && v->fcm == ILACE_FIELD && v->mv_mode == MV_PMODE_INTENSITY_COMP && v->intcompfield == 3) @@ -213,7 +213,7 @@ av_unused static inline int vc1_get_LUMSCALE2(const VC1Context *v) av_unused static inline int vc1_get_LUMSHIFT2(const VC1Context *v) { - if ((v->s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) && + if ((v->s.s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) && v->fcm == ILACE_FIELD && v->mv_mode == MV_PMODE_INTENSITY_COMP && v->intcompfield == 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 MPVDecContext *const s = &v->s; + const MPVDecContext *const s = &v->s.s; VAAPIDecodePicture *pic = s->current_picture_ptr->hwaccel_picture_private; VAPictureParameterBufferVC1 pic_param; int err; @@ -367,7 +367,7 @@ static int vaapi_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t .frame_level_transform_type = vc1_get_TTFRM(v), .transform_ac_codingset_idx1 = v->c_ac_table_index, .transform_ac_codingset_idx2 = v->y_ac_table_index, - .intra_transform_dc_table = v->s.dc_table_index, + .intra_transform_dc_table = v->s.s.dc_table_index, }, }; @@ -448,7 +448,7 @@ fail: static int vaapi_vc1_end_frame(AVCodecContext *avctx) { VC1Context *v = avctx->priv_data; - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.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 MPVDecContext *const s = &v->s; + const MPVDecContext *const s = &v->s.s; VAAPIDecodePicture *pic = s->current_picture_ptr->hwaccel_picture_private; VASliceParameterBufferVC1 slice_param; int mb_height; diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c index 40e2b4d692..d9061b1f74 100644 --- a/libavcodec/vc1.c +++ b/libavcodec/vc1.c @@ -97,15 +97,16 @@ static void decode_colskip(uint8_t* plane, int width, int height, int stride, */ static int bitplane_decoding(uint8_t* data, int *raw_flag, VC1Context *v) { - GetBitContext *gb = &v->s.gb; + MPVDecContext *const s = &v->s.s; + GetBitContext *gb = &s->gb; int imode, x, y, code, offset; uint8_t invert, *planep = data; int width, height, stride; - width = v->s.mb_width; - height = v->s.mb_height >> v->field_mode; - stride = v->s.mb_stride; + width = s->mb_width; + height = s->mb_height >> v->field_mode; + stride = s->mb_stride; invert = get_bits1(gb); imode = get_vlc2(gb, ff_vc1_imode_vlc.table, VC1_IMODE_VLC_BITS, 1); @@ -151,7 +152,7 @@ static int bitplane_decoding(uint8_t* data, int *raw_flag, VC1Context *v) for (x = width & 1; x < width; x += 2) { code = get_vlc2(gb, ff_vc1_norm6_vlc.table, VC1_NORM6_VLC_BITS, 2); if (code < 0) { - av_log(v->s.avctx, AV_LOG_DEBUG, "invalid NORM-6 VLC\n"); + av_log(s->avctx, AV_LOG_DEBUG, "invalid NORM-6 VLC\n"); return -1; } planep[x + 0] = (code >> 0) & 1; @@ -164,14 +165,14 @@ static int bitplane_decoding(uint8_t* data, int *raw_flag, VC1Context *v) planep += stride * 3; } if (width & 1) - decode_colskip(data, 1, height, stride, &v->s.gb); + decode_colskip(data, 1, height, stride, gb); } else { // 3x2 planep += (height & 1) * stride; for (y = height & 1; y < height; y += 2) { for (x = width % 3; x < width; x += 3) { code = get_vlc2(gb, ff_vc1_norm6_vlc.table, VC1_NORM6_VLC_BITS, 2); if (code < 0) { - av_log(v->s.avctx, AV_LOG_DEBUG, "invalid NORM-6 VLC\n"); + av_log(s->avctx, AV_LOG_DEBUG, "invalid NORM-6 VLC\n"); return -1; } planep[x + 0] = (code >> 0) & 1; @@ -185,16 +186,16 @@ static int bitplane_decoding(uint8_t* data, int *raw_flag, VC1Context *v) } x = width % 3; if (x) - decode_colskip(data, x, height, stride, &v->s.gb); + decode_colskip(data, x, height, stride, gb); if (height & 1) - decode_rowskip(data + x, width - x, 1, stride, &v->s.gb); + decode_rowskip(data + x, width - x, 1, stride, gb); } break; case IMODE_ROWSKIP: - decode_rowskip(data, width, height, stride, &v->s.gb); + decode_rowskip(data, width, height, stride, gb); break; case IMODE_COLSKIP: - decode_colskip(data, width, height, stride, &v->s.gb); + decode_colskip(data, width, height, stride, gb); break; default: break; @@ -230,7 +231,7 @@ static int bitplane_decoding(uint8_t* data, int *raw_flag, VC1Context *v) */ static int vop_dquant_decoding(VC1Context *v) { - GetBitContext *gb = &v->s.gb; + GetBitContext *gb = &v->s.s.gb; int pqdiff; //variable size @@ -276,6 +277,8 @@ static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb); */ int ff_vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitContext *gb) { + MPVDecContext *const s = &v->s.s; + av_log(avctx, AV_LOG_DEBUG, "Header: %0X\n", show_bits_long(gb, 32)); v->profile = get_bits(gb, 2); if (v->profile == PROFILE_COMPLEX) { @@ -303,13 +306,13 @@ int ff_vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitCo v->frmrtq_postproc = get_bits(gb, 3); //common // (bitrate-32kbps)/64kbps v->bitrtq_postproc = get_bits(gb, 5); //common - v->s.loop_filter = get_bits1(gb); //common - if (v->s.loop_filter == 1 && v->profile == PROFILE_SIMPLE) { + s->loop_filter = get_bits1(gb); //common + if (s->loop_filter == 1 && v->profile == PROFILE_SIMPLE) { av_log(avctx, AV_LOG_ERROR, "LOOPFILTER shall not be enabled in Simple Profile\n"); } - if (v->s.avctx->skip_loop_filter >= AVDISCARD_ALL) - v->s.loop_filter = 0; + if (s->avctx->skip_loop_filter >= AVDISCARD_ALL) + s->loop_filter = 0; v->res_x8 = get_bits1(gb); //reserved v->multires = get_bits1(gb); @@ -356,7 +359,7 @@ int ff_vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitCo "RANGERED should be set to 0 in Simple Profile\n"); } - v->s.max_b_frames = avctx->max_b_frames = get_bits(gb, 3); //common + s->max_b_frames = avctx->max_b_frames = get_bits(gb, 3); //common v->quantizer_mode = get_bits(gb, 2); //common v->finterpflag = get_bits1(gb); //common @@ -364,7 +367,7 @@ int ff_vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitCo if (v->res_sprite) { int w = get_bits(gb, 11); int h = get_bits(gb, 11); - int ret = ff_set_dimensions(v->s.avctx, w, h); + int ret = ff_set_dimensions(s->avctx, w, h); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Failed to set dimensions %d %d\n", w, h); return ret; @@ -389,7 +392,7 @@ int ff_vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitCo "Rangered=%i, VSTransform=%i, Overlap=%i, SyncMarker=%i\n" "DQuant=%i, Quantizer mode=%i, Max B-frames=%i\n", v->profile, v->frmrtq_postproc, v->bitrtq_postproc, - v->s.loop_filter, v->multires, v->fastuvmc, v->extended_mv, + s->loop_filter, v->multires, v->fastuvmc, v->extended_mv, v->rangered, v->vstransform, v->overlap, v->resync_marker, v->dquant, v->quantizer_mode, avctx->max_b_frames); return 0; @@ -397,14 +400,16 @@ int ff_vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitCo static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb) { + MPVDecContext *const s = &v->s.s; + v->res_rtm_flag = 1; v->level = get_bits(gb, 3); if (v->level >= 5) { - av_log(v->s.avctx, AV_LOG_ERROR, "Reserved LEVEL %i\n",v->level); + av_log(s->avctx, AV_LOG_ERROR, "Reserved LEVEL %i\n",v->level); } v->chromaformat = get_bits(gb, 2); if (v->chromaformat != 1) { - av_log(v->s.avctx, AV_LOG_ERROR, + av_log(s->avctx, AV_LOG_ERROR, "Only 4:2:0 chroma format supported\n"); return -1; } @@ -423,65 +428,65 @@ static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb) v->finterpflag = get_bits1(gb); skip_bits1(gb); // reserved - av_log(v->s.avctx, AV_LOG_DEBUG, + av_log(s->avctx, AV_LOG_DEBUG, "Advanced Profile level %i:\nfrmrtq_postproc=%i, bitrtq_postproc=%i\n" "LoopFilter=%i, ChromaFormat=%i, Pulldown=%i, Interlace: %i\n" "TFCTRflag=%i, FINTERPflag=%i\n", v->level, v->frmrtq_postproc, v->bitrtq_postproc, - v->s.loop_filter, v->chromaformat, v->broadcast, v->interlace, + s->loop_filter, v->chromaformat, v->broadcast, v->interlace, v->tfcntrflag, v->finterpflag); v->psf = get_bits1(gb); if (v->psf) { //PsF, 6.1.13 - av_log(v->s.avctx, AV_LOG_ERROR, "Progressive Segmented Frame mode: not supported (yet)\n"); + av_log(s->avctx, AV_LOG_ERROR, "Progressive Segmented Frame mode: not supported (yet)\n"); return -1; } - v->s.max_b_frames = v->s.avctx->max_b_frames = 7; + s->max_b_frames = s->avctx->max_b_frames = 7; if (get_bits1(gb)) { //Display Info - decoding is not affected by it int w, h, ar = 0; - av_log(v->s.avctx, AV_LOG_DEBUG, "Display extended info:\n"); + av_log(s->avctx, AV_LOG_DEBUG, "Display extended info:\n"); w = get_bits(gb, 14) + 1; h = get_bits(gb, 14) + 1; - av_log(v->s.avctx, AV_LOG_DEBUG, "Display dimensions: %ix%i\n", w, h); + av_log(s->avctx, AV_LOG_DEBUG, "Display dimensions: %ix%i\n", w, h); if (get_bits1(gb)) ar = get_bits(gb, 4); if (ar && ar < 14) { - v->s.avctx->sample_aspect_ratio = ff_vc1_pixel_aspect[ar]; + s->avctx->sample_aspect_ratio = ff_vc1_pixel_aspect[ar]; } else if (ar == 15) { w = get_bits(gb, 8) + 1; h = get_bits(gb, 8) + 1; - v->s.avctx->sample_aspect_ratio = (AVRational){w, h}; + s->avctx->sample_aspect_ratio = (AVRational){w, h}; } else { - if (v->s.avctx->width > v->max_coded_width || - v->s.avctx->height > v->max_coded_height) { - avpriv_request_sample(v->s.avctx, "Huge resolution"); + if (s->avctx->width > v->max_coded_width || + s->avctx->height > v->max_coded_height) { + avpriv_request_sample(s->avctx, "Huge resolution"); } else - av_reduce(&v->s.avctx->sample_aspect_ratio.num, - &v->s.avctx->sample_aspect_ratio.den, - v->s.avctx->height * w, - v->s.avctx->width * h, + av_reduce(&s->avctx->sample_aspect_ratio.num, + &s->avctx->sample_aspect_ratio.den, + s->avctx->height * w, + s->avctx->width * h, 1 << 30); } - ff_set_sar(v->s.avctx, v->s.avctx->sample_aspect_ratio); - av_log(v->s.avctx, AV_LOG_DEBUG, "Aspect: %i:%i\n", - v->s.avctx->sample_aspect_ratio.num, - v->s.avctx->sample_aspect_ratio.den); + ff_set_sar(s->avctx, s->avctx->sample_aspect_ratio); + av_log(s->avctx, AV_LOG_DEBUG, "Aspect: %i:%i\n", + s->avctx->sample_aspect_ratio.num, + s->avctx->sample_aspect_ratio.den); if (get_bits1(gb)) { //framerate stuff if (get_bits1(gb)) { - v->s.avctx->framerate.den = 32; - v->s.avctx->framerate.num = get_bits(gb, 16) + 1; + s->avctx->framerate.den = 32; + s->avctx->framerate.num = get_bits(gb, 16) + 1; } else { int nr, dr; nr = get_bits(gb, 8); dr = get_bits(gb, 4); if (nr > 0 && nr < 8 && dr > 0 && dr < 3) { - v->s.avctx->framerate.den = ff_vc1_fps_dr[dr - 1]; - v->s.avctx->framerate.num = ff_vc1_fps_nr[nr - 1] * 1000; + s->avctx->framerate.den = ff_vc1_fps_dr[dr - 1]; + s->avctx->framerate.num = ff_vc1_fps_nr[nr - 1] * 1000; } } if (v->broadcast) { // Pulldown may be present - v->s.avctx->ticks_per_frame = 2; + s->avctx->ticks_per_frame = 2; } } @@ -517,9 +522,9 @@ int ff_vc1_decode_entry_point(AVCodecContext *avctx, VC1Context *v, GetBitContex v->closed_entry = get_bits1(gb); v->panscanflag = get_bits1(gb); v->refdist_flag = get_bits1(gb); - v->s.loop_filter = get_bits1(gb); - if (v->s.avctx->skip_loop_filter >= AVDISCARD_ALL) - v->s.loop_filter = 0; + v->s.s.loop_filter = get_bits1(gb); + if (v->s.s.avctx->skip_loop_filter >= AVDISCARD_ALL) + v->s.s.loop_filter = 0; v->fastuvmc = get_bits1(gb); v->extended_mv = get_bits1(gb); v->dquant = get_bits(gb, 2); @@ -560,7 +565,7 @@ int ff_vc1_decode_entry_point(AVCodecContext *avctx, VC1Context *v, GetBitContex "BrokenLink=%i, ClosedEntry=%i, PanscanFlag=%i\n" "RefDist=%i, Postproc=%i, FastUVMC=%i, ExtMV=%i\n" "DQuant=%i, VSTransform=%i, Overlap=%i, Qmode=%i\n", - v->broken_link, v->closed_entry, v->panscanflag, v->refdist_flag, v->s.loop_filter, + v->broken_link, v->closed_entry, v->panscanflag, v->refdist_flag, v->s.s.loop_filter, v->fastuvmc, v->extended_mv, v->dquant, v->vstransform, v->overlap, v->quantizer_mode); return 0; @@ -592,7 +597,7 @@ int ff_vc1_decode_entry_point(AVCodecContext *avctx, VC1Context *v, GetBitContex static void rotate_luts(VC1Context *v) { #define ROTATE(DEF, L, N, C, A) do { \ - if (v->s.pict_type == AV_PICTURE_TYPE_BI || v->s.pict_type == AV_PICTURE_TYPE_B) { \ + if (v->s.s.pict_type == AV_PICTURE_TYPE_BI || v->s.s.pict_type == AV_PICTURE_TYPE_B) { \ C = A; \ } else { \ DEF; \ @@ -616,7 +621,7 @@ static int read_bfraction(VC1Context *v, GetBitContext* gb) { int bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1); if (bfraction_lut_index == 21 || bfraction_lut_index < 0) { - av_log(v->s.avctx, AV_LOG_ERROR, "bfraction invalid\n"); + av_log(v->s.s.avctx, AV_LOG_ERROR, "bfraction invalid\n"); return AVERROR_INVALIDDATA; } v->bfraction_lut_index = bfraction_lut_index; @@ -626,15 +631,16 @@ static int read_bfraction(VC1Context *v, GetBitContext* gb) { int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* gb) { + MPVDecContext *const s = &v->s.s; int pqindex, lowquant, status; v->field_mode = 0; v->fcm = PROGRESSIVE; if (v->finterpflag) v->interpfrm = get_bits1(gb); - if (!v->s.avctx->codec) + if (!s->avctx->codec) return -1; - if (v->s.avctx->codec_id == AV_CODEC_ID_MSS2) + if (s->avctx->codec_id == AV_CODEC_ID_MSS2) v->respic = v->rangered = v->multires = get_bits(gb, 2) == 1; @@ -644,32 +650,32 @@ int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* gb) if (v->rangered) v->rangeredfrm = get_bits1(gb); if (get_bits1(gb)) { - v->s.pict_type = AV_PICTURE_TYPE_P; + s->pict_type = AV_PICTURE_TYPE_P; } else { - if (v->s.avctx->max_b_frames && !get_bits1(gb)) { - v->s.pict_type = AV_PICTURE_TYPE_B; + if (s->avctx->max_b_frames && !get_bits1(gb)) { + s->pict_type = AV_PICTURE_TYPE_B; } else - v->s.pict_type = AV_PICTURE_TYPE_I; + s->pict_type = AV_PICTURE_TYPE_I; } v->bi_type = 0; - if (v->s.pict_type == AV_PICTURE_TYPE_B) { + if (s->pict_type == AV_PICTURE_TYPE_B) { if (read_bfraction(v, gb) < 0) return AVERROR_INVALIDDATA; if (v->bfraction == 0) { - v->s.pict_type = AV_PICTURE_TYPE_BI; + s->pict_type = AV_PICTURE_TYPE_BI; } } - if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI) + if (s->pict_type == AV_PICTURE_TYPE_I || s->pict_type == AV_PICTURE_TYPE_BI) skip_bits(gb, 7); // skip buffer fullness if (v->parse_only) return 0; /* calculate RND */ - if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI) + if (s->pict_type == AV_PICTURE_TYPE_I || s->pict_type == AV_PICTURE_TYPE_BI) v->rnd = 1; - if (v->s.pict_type == AV_PICTURE_TYPE_P) + if (s->pict_type == AV_PICTURE_TYPE_P) v->rnd ^= 1; if (get_bits_left(gb) < 5) @@ -708,21 +714,21 @@ int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* gb) v->k_y = v->mvrange + 8; //k_y can be 8 9 10 11 v->range_x = 1 << (v->k_x - 1); v->range_y = 1 << (v->k_y - 1); - if (v->multires && v->s.pict_type != AV_PICTURE_TYPE_B) + if (v->multires && s->pict_type != AV_PICTURE_TYPE_B) v->respic = get_bits(gb, 2); - if (v->res_x8 && (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI)) { + if (v->res_x8 && (s->pict_type == AV_PICTURE_TYPE_I || s->pict_type == AV_PICTURE_TYPE_BI)) { v->x8_type = get_bits1(gb); } else v->x8_type = 0; - ff_dlog(v->s.avctx, "%c Frame: QP=[%i]%i (+%i/2) %i\n", - (v->s.pict_type == AV_PICTURE_TYPE_P) ? 'P' : ((v->s.pict_type == AV_PICTURE_TYPE_I) ? 'I' : 'B'), + ff_dlog(s->avctx, "%c Frame: QP=[%i]%i (+%i/2) %i\n", + (s->pict_type == AV_PICTURE_TYPE_P) ? 'P' : ((s->pict_type == AV_PICTURE_TYPE_I) ? 'I' : 'B'), pqindex, v->pq, v->halfpq, v->rangeredfrm); if (v->first_pic_header_flag) rotate_luts(v); - switch (v->s.pict_type) { + switch (s->pict_type) { case AV_PICTURE_TYPE_P: v->tt_index = (v->pq > 4) + (v->pq > 12); @@ -737,15 +743,15 @@ int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* gb) INIT_LUT(v->lumscale, v->lumshift, v->last_luty[0], v->last_lutuv[0], 1); INIT_LUT(v->lumscale, v->lumshift, v->last_luty[1], v->last_lutuv[1], 1); } - v->qs_last = v->s.quarter_sample; + v->qs_last = s->quarter_sample; if (v->mv_mode == MV_PMODE_INTENSITY_COMP) { - v->s.quarter_sample = (v->mv_mode2 != MV_PMODE_1MV_HPEL && - v->mv_mode2 != MV_PMODE_1MV_HPEL_BILIN); - v->s.mspel = (v->mv_mode2 != MV_PMODE_1MV_HPEL_BILIN); + s->quarter_sample = (v->mv_mode2 != MV_PMODE_1MV_HPEL && + v->mv_mode2 != MV_PMODE_1MV_HPEL_BILIN); + s->mspel = (v->mv_mode2 != MV_PMODE_1MV_HPEL_BILIN); } else { - v->s.quarter_sample = (v->mv_mode != MV_PMODE_1MV_HPEL && - v->mv_mode != MV_PMODE_1MV_HPEL_BILIN); - v->s.mspel = (v->mv_mode != MV_PMODE_1MV_HPEL_BILIN); + s->quarter_sample = (v->mv_mode != MV_PMODE_1MV_HPEL && + v->mv_mode != MV_PMODE_1MV_HPEL_BILIN); + s->mspel = (v->mv_mode != MV_PMODE_1MV_HPEL_BILIN); } if ((v->mv_mode == MV_PMODE_INTENSITY_COMP && @@ -754,28 +760,28 @@ int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* gb) status = bitplane_decoding(v->mv_type_mb_plane, &v->mv_type_is_raw, v); if (status < 0) return -1; - av_log(v->s.avctx, AV_LOG_DEBUG, "MB MV Type plane encoding: " + av_log(s->avctx, AV_LOG_DEBUG, "MB MV Type plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); } else { v->mv_type_is_raw = 0; - memset(v->mv_type_mb_plane, 0, v->s.mb_stride * v->s.mb_height); + memset(v->mv_type_mb_plane, 0, s->mb_stride * s->mb_height); } - status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v); + status = bitplane_decoding(s->mbskip_table, &v->skip_is_raw, v); if (status < 0) return -1; - av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: " + av_log(s->avctx, AV_LOG_DEBUG, "MB Skip plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); if (get_bits_left(gb) < 4) return AVERROR_INVALIDDATA; /* Hopefully this is correct for P-frames */ - v->s.mv_table_index = get_bits(gb, 2); //but using ff_vc1_ tables + s->mv_table_index = get_bits(gb, 2); //but using ff_vc1_ tables v->cbptab = get_bits(gb, 2); v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[v->cbptab]; if (v->dquant) { - av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n"); + av_log(s->avctx, AV_LOG_DEBUG, "VOP DQuant info\n"); vop_dquant_decoding(v); } @@ -793,28 +799,28 @@ int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* gb) case AV_PICTURE_TYPE_B: v->tt_index = (v->pq > 4) + (v->pq > 12); - v->mv_mode = get_bits1(gb) ? MV_PMODE_1MV : MV_PMODE_1MV_HPEL_BILIN; - v->qs_last = v->s.quarter_sample; - v->s.quarter_sample = (v->mv_mode == MV_PMODE_1MV); - v->s.mspel = v->s.quarter_sample; + v->mv_mode = get_bits1(gb) ? MV_PMODE_1MV : MV_PMODE_1MV_HPEL_BILIN; + v->qs_last = s->quarter_sample; + s->quarter_sample = (v->mv_mode == MV_PMODE_1MV); + s->mspel = s->quarter_sample; status = bitplane_decoding(v->direct_mb_plane, &v->dmb_is_raw, v); if (status < 0) return -1; - av_log(v->s.avctx, AV_LOG_DEBUG, "MB Direct Type plane encoding: " + av_log(s->avctx, AV_LOG_DEBUG, "MB Direct Type plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); - status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v); + status = bitplane_decoding(s->mbskip_table, &v->skip_is_raw, v); if (status < 0) return -1; - av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: " + av_log(s->avctx, AV_LOG_DEBUG, "MB Skip plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); - v->s.mv_table_index = get_bits(gb, 2); + s->mv_table_index = get_bits(gb, 2); v->cbptab = get_bits(gb, 2); v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[v->cbptab]; if (v->dquant) { - av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n"); + av_log(s->avctx, AV_LOG_DEBUG, "VOP DQuant info\n"); vop_dquant_decoding(v); } @@ -834,15 +840,15 @@ int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* gb) if (!v->x8_type) { /* AC Syntax */ v->c_ac_table_index = decode012(gb); - if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI) { + if (s->pict_type == AV_PICTURE_TYPE_I || s->pict_type == AV_PICTURE_TYPE_BI) { v->y_ac_table_index = decode012(gb); } /* DC Syntax */ - v->s.dc_table_index = get_bits1(gb); + s->dc_table_index = get_bits1(gb); } - if (v->s.pict_type == AV_PICTURE_TYPE_BI) { - v->s.pict_type = AV_PICTURE_TYPE_B; + if (s->pict_type == AV_PICTURE_TYPE_BI) { + s->pict_type = AV_PICTURE_TYPE_B; v->bi_type = 1; } return 0; @@ -850,6 +856,7 @@ int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* gb) int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) { + MPVDecContext *const s = &v->s.s; int pqindex, lowquant; int status; int field_mode, fcm; @@ -860,10 +867,10 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) if (v->fcm != ILACE_FIELD || v->field_mode!=1) return -1; if (v->fptype & 4) - v->s.pict_type = (v->fptype & 1) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B; + s->pict_type = (v->fptype & 1) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B; else - v->s.pict_type = (v->fptype & 1) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I; - v->s.current_picture_ptr->f->pict_type = v->s.pict_type; + s->pict_type = (v->fptype & 1) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I; + s->current_picture_ptr->f->pict_type = s->pict_type; if (!v->pic_header_flag) goto parse_common_info; } @@ -883,32 +890,32 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) v->field_mode = field_mode; v->fcm = fcm; - av_assert0( v->s.mb_height == v->s.height + 15 >> 4 - || v->s.mb_height == FFALIGN(v->s.height + 15 >> 4, 2)); + av_assert0(s->mb_height == s->height + 15 >> 4 || + s->mb_height == FFALIGN(s->height + 15 >> 4, 2)); if (v->field_mode) { - v->s.mb_height = FFALIGN(v->s.height + 15 >> 4, 2); + s->mb_height = FFALIGN(s->height + 15 >> 4, 2); v->fptype = get_bits(gb, 3); if (v->fptype & 4) // B-picture - v->s.pict_type = (v->fptype & 2) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B; + s->pict_type = (v->fptype & 2) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B; else - v->s.pict_type = (v->fptype & 2) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I; + s->pict_type = (v->fptype & 2) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I; } else { - v->s.mb_height = v->s.height + 15 >> 4; + s->mb_height = s->height + 15 >> 4; switch (get_unary(gb, 0, 4)) { case 0: - v->s.pict_type = AV_PICTURE_TYPE_P; + s->pict_type = AV_PICTURE_TYPE_P; break; case 1: - v->s.pict_type = AV_PICTURE_TYPE_B; + s->pict_type = AV_PICTURE_TYPE_B; break; case 2: - v->s.pict_type = AV_PICTURE_TYPE_I; + s->pict_type = AV_PICTURE_TYPE_I; break; case 3: - v->s.pict_type = AV_PICTURE_TYPE_BI; + s->pict_type = AV_PICTURE_TYPE_BI; break; case 4: - v->s.pict_type = AV_PICTURE_TYPE_P; // skipped pic + s->pict_type = AV_PICTURE_TYPE_P; // skipped pic v->p_frame_skipped = 1; break; } @@ -926,7 +933,7 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) v->tff = 1; } if (v->panscanflag) { - avpriv_report_missing_feature(v->s.avctx, "Pan-scan"); + avpriv_report_missing_feature(s->avctx, "Pan-scan"); //... } if (v->p_frame_skipped) { @@ -940,14 +947,14 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) if (v->field_mode) { if (!v->refdist_flag) v->refdist = 0; - else if ((v->s.pict_type != AV_PICTURE_TYPE_B) && (v->s.pict_type != AV_PICTURE_TYPE_BI)) { + else if ((s->pict_type != AV_PICTURE_TYPE_B) && (s->pict_type != AV_PICTURE_TYPE_BI)) { v->refdist = get_bits(gb, 2); if (v->refdist == 3) v->refdist += get_unary(gb, 0, 14); if (v->refdist > 16) return AVERROR_INVALIDDATA; } - if ((v->s.pict_type == AV_PICTURE_TYPE_B) || (v->s.pict_type == AV_PICTURE_TYPE_BI)) { + if ((s->pict_type == AV_PICTURE_TYPE_B) || (s->pict_type == AV_PICTURE_TYPE_BI)) { if (read_bfraction(v, gb) < 0) return AVERROR_INVALIDDATA; v->frfd = (v->bfraction * v->refdist) >> 8; @@ -960,11 +967,11 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) if (v->fcm == PROGRESSIVE) { if (v->finterpflag) v->interpfrm = get_bits1(gb); - if (v->s.pict_type == AV_PICTURE_TYPE_B) { + if (s->pict_type == AV_PICTURE_TYPE_B) { if (read_bfraction(v, gb) < 0) return AVERROR_INVALIDDATA; if (v->bfraction == 0) { - v->s.pict_type = AV_PICTURE_TYPE_BI; /* XXX: should not happen here */ + s->pict_type = AV_PICTURE_TYPE_BI; /* XXX: should not happen here */ } } } @@ -1008,21 +1015,21 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) if (v->first_pic_header_flag) rotate_luts(v); - switch (v->s.pict_type) { + switch (s->pict_type) { case AV_PICTURE_TYPE_I: case AV_PICTURE_TYPE_BI: if (v->fcm == ILACE_FRAME) { //interlace frame picture status = bitplane_decoding(v->fieldtx_plane, &v->fieldtx_is_raw, v); if (status < 0) return -1; - av_log(v->s.avctx, AV_LOG_DEBUG, "FIELDTX plane encoding: " + av_log(s->avctx, AV_LOG_DEBUG, "FIELDTX plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); } else v->fieldtx_is_raw = 0; status = bitplane_decoding(v->acpred_plane, &v->acpred_is_raw, v); if (status < 0) return -1; - av_log(v->s.avctx, AV_LOG_DEBUG, "ACPRED plane encoding: " + av_log(s->avctx, AV_LOG_DEBUG, "ACPRED plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); v->condover = CONDOVER_NONE; if (v->overlap && v->pq <= 8) { @@ -1031,7 +1038,7 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) status = bitplane_decoding(v->over_flags_plane, &v->overflg_is_raw, v); if (status < 0) return -1; - av_log(v->s.avctx, AV_LOG_DEBUG, "CONDOVER plane encoding: " + av_log(s->avctx, AV_LOG_DEBUG, "CONDOVER plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); } } @@ -1063,10 +1070,10 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) INIT_LUT(v->lumscale, v->lumshift, v->last_luty[1], v->last_lutuv[1], 1); v->last_use_ic = 1; } - status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v); + status = bitplane_decoding(s->mbskip_table, &v->skip_is_raw, v); if (status < 0) return -1; - av_log(v->s.avctx, AV_LOG_DEBUG, "SKIPMB plane encoding: " + av_log(s->avctx, AV_LOG_DEBUG, "SKIPMB plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); v->mbmodetab = get_bits(gb, 2); if (v->fourmvswitch) @@ -1134,15 +1141,15 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) } v->last_use_ic = 1; } - v->qs_last = v->s.quarter_sample; + v->qs_last = s->quarter_sample; if (v->mv_mode == MV_PMODE_INTENSITY_COMP) { - v->s.quarter_sample = (v->mv_mode2 != MV_PMODE_1MV_HPEL && - v->mv_mode2 != MV_PMODE_1MV_HPEL_BILIN); - v->s.mspel = (v->mv_mode2 != MV_PMODE_1MV_HPEL_BILIN); + s->quarter_sample = (v->mv_mode2 != MV_PMODE_1MV_HPEL && + v->mv_mode2 != MV_PMODE_1MV_HPEL_BILIN); + s->mspel = (v->mv_mode2 != MV_PMODE_1MV_HPEL_BILIN); } else { - v->s.quarter_sample = (v->mv_mode != MV_PMODE_1MV_HPEL && - v->mv_mode != MV_PMODE_1MV_HPEL_BILIN); - v->s.mspel = (v->mv_mode != MV_PMODE_1MV_HPEL_BILIN); + s->quarter_sample = (v->mv_mode != MV_PMODE_1MV_HPEL && + v->mv_mode != MV_PMODE_1MV_HPEL_BILIN); + s->mspel = (v->mv_mode != MV_PMODE_1MV_HPEL_BILIN); } } if (v->fcm == PROGRESSIVE) { // progressive @@ -1152,26 +1159,26 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) status = bitplane_decoding(v->mv_type_mb_plane, &v->mv_type_is_raw, v); if (status < 0) return -1; - av_log(v->s.avctx, AV_LOG_DEBUG, "MB MV Type plane encoding: " + av_log(s->avctx, AV_LOG_DEBUG, "MB MV Type plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); } else { v->mv_type_is_raw = 0; - memset(v->mv_type_mb_plane, 0, v->s.mb_stride * v->s.mb_height); + memset(v->mv_type_mb_plane, 0, s->mb_stride * s->mb_height); } - status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v); + status = bitplane_decoding(s->mbskip_table, &v->skip_is_raw, v); if (status < 0) return -1; - av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: " + av_log(s->avctx, AV_LOG_DEBUG, "MB Skip plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); /* Hopefully this is correct for P-frames */ - v->s.mv_table_index = get_bits(gb, 2); //but using ff_vc1_ tables + s->mv_table_index = get_bits(gb, 2); //but using ff_vc1_ tables v->cbptab = get_bits(gb, 2); v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[v->cbptab]; } else if (v->fcm == ILACE_FRAME) { // frame interlaced - v->qs_last = v->s.quarter_sample; - v->s.quarter_sample = 1; - v->s.mspel = 1; + v->qs_last = s->quarter_sample; + s->quarter_sample = 1; + s->mspel = 1; } else { // field interlaced v->mbmodetab = get_bits(gb, 3); v->imvtab = get_bits(gb, 2 + v->numref); @@ -1191,7 +1198,7 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) } } if (v->dquant) { - av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n"); + av_log(s->avctx, AV_LOG_DEBUG, "VOP DQuant info\n"); vop_dquant_decoding(v); } @@ -1227,19 +1234,19 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) if (v->field_mode) { int mvmode; - av_log(v->s.avctx, AV_LOG_DEBUG, "B Fields\n"); + av_log(s->avctx, AV_LOG_DEBUG, "B Fields\n"); if (v->extended_dmv) v->dmvrange = get_unary(gb, 0, 3); mvmode = get_unary(gb, 1, 3); lowquant = (v->pq > 12) ? 0 : 1; - v->mv_mode = ff_vc1_mv_pmode_table2[lowquant][mvmode]; - v->qs_last = v->s.quarter_sample; - v->s.quarter_sample = (v->mv_mode == MV_PMODE_1MV || v->mv_mode == MV_PMODE_MIXED_MV); - v->s.mspel = (v->mv_mode != MV_PMODE_1MV_HPEL_BILIN); + v->mv_mode = ff_vc1_mv_pmode_table2[lowquant][mvmode]; + v->qs_last = s->quarter_sample; + s->quarter_sample = (v->mv_mode == MV_PMODE_1MV || v->mv_mode == MV_PMODE_MIXED_MV); + s->mspel = (v->mv_mode != MV_PMODE_1MV_HPEL_BILIN); status = bitplane_decoding(v->forward_mb_plane, &v->fmb_is_raw, v); if (status < 0) return -1; - av_log(v->s.avctx, AV_LOG_DEBUG, "MB Forward Type plane encoding: " + av_log(s->avctx, AV_LOG_DEBUG, "MB Forward Type plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); v->mbmodetab = get_bits(gb, 3); if (v->mv_mode == MV_PMODE_MIXED_MV) @@ -1259,22 +1266,22 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) if (v->extended_dmv) v->dmvrange = get_unary(gb, 0, 3); if (get_bits1(gb)) /* intcomp - present but shall always be 0 */ - av_log(v->s.avctx, AV_LOG_WARNING, "Intensity compensation set for B picture\n"); + av_log(s->avctx, AV_LOG_WARNING, "Intensity compensation set for B picture\n"); v->intcomp = 0; v->mv_mode = MV_PMODE_1MV; v->fourmvswitch = 0; - v->qs_last = v->s.quarter_sample; - v->s.quarter_sample = 1; - v->s.mspel = 1; + v->qs_last = s->quarter_sample; + s->quarter_sample = 1; + s->mspel = 1; status = bitplane_decoding(v->direct_mb_plane, &v->dmb_is_raw, v); if (status < 0) return -1; - av_log(v->s.avctx, AV_LOG_DEBUG, "MB Direct Type plane encoding: " + av_log(s->avctx, AV_LOG_DEBUG, "MB Direct Type plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); - status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v); + status = bitplane_decoding(s->mbskip_table, &v->skip_is_raw, v); if (status < 0) return -1; - av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: " + av_log(s->avctx, AV_LOG_DEBUG, "MB Skip plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); v->mbmodetab = get_bits(gb, 2); v->mbmode_vlc = &ff_vc1_intfr_non4mv_mbmode_vlc[v->mbmodetab]; @@ -1288,27 +1295,27 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) v->fourmvbptab = get_bits(gb, 2); v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[v->fourmvbptab]; } else { - v->mv_mode = get_bits1(gb) ? MV_PMODE_1MV : MV_PMODE_1MV_HPEL_BILIN; - v->qs_last = v->s.quarter_sample; - v->s.quarter_sample = (v->mv_mode == MV_PMODE_1MV); - v->s.mspel = v->s.quarter_sample; + v->mv_mode = get_bits1(gb) ? MV_PMODE_1MV : MV_PMODE_1MV_HPEL_BILIN; + v->qs_last = s->quarter_sample; + s->quarter_sample = (v->mv_mode == MV_PMODE_1MV); + s->mspel = s->quarter_sample; status = bitplane_decoding(v->direct_mb_plane, &v->dmb_is_raw, v); if (status < 0) return -1; - av_log(v->s.avctx, AV_LOG_DEBUG, "MB Direct Type plane encoding: " + av_log(s->avctx, AV_LOG_DEBUG, "MB Direct Type plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); - status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v); + status = bitplane_decoding(s->mbskip_table, &v->skip_is_raw, v); if (status < 0) return -1; - av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: " + av_log(s->avctx, AV_LOG_DEBUG, "MB Skip plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); - v->s.mv_table_index = get_bits(gb, 2); + s->mv_table_index = get_bits(gb, 2); v->cbptab = get_bits(gb, 2); v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[v->cbptab]; } if (v->dquant) { - av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n"); + av_log(s->avctx, AV_LOG_DEBUG, "VOP DQuant info\n"); vop_dquant_decoding(v); } @@ -1328,25 +1335,25 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) /* AC Syntax */ v->c_ac_table_index = decode012(gb); - if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI) { + if (s->pict_type == AV_PICTURE_TYPE_I || s->pict_type == AV_PICTURE_TYPE_BI) { v->y_ac_table_index = decode012(gb); } - else if (v->fcm != PROGRESSIVE && !v->s.quarter_sample) { + else if (v->fcm != PROGRESSIVE && !s->quarter_sample) { v->range_x <<= 1; v->range_y <<= 1; } /* DC Syntax */ - v->s.dc_table_index = get_bits1(gb); - if ((v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI) + s->dc_table_index = get_bits1(gb); + if ((s->pict_type == AV_PICTURE_TYPE_I || s->pict_type == AV_PICTURE_TYPE_BI) && v->dquant) { - av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n"); + av_log(s->avctx, AV_LOG_DEBUG, "VOP DQuant info\n"); vop_dquant_decoding(v); } - v->bi_type = (v->s.pict_type == AV_PICTURE_TYPE_BI); + v->bi_type = (s->pict_type == AV_PICTURE_TYPE_BI); if (v->bi_type) - v->s.pict_type = AV_PICTURE_TYPE_B; + s->pict_type = AV_PICTURE_TYPE_B; return 0; } diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c index 65c0398842..081c47894f 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) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.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) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.s; uint8_t *dest; int block_count = CONFIG_GRAY && (s->avctx->flags & AV_CODEC_FLAG_GRAY) ? 4 : 6; int fieldtx = 0; @@ -209,7 +209,7 @@ static void vc1_put_blocks_clamped(VC1Context *v, int put_signed) s->mb_y == ((s->mb_height >> v->field_mode) - 1)) \ mquant = -v->altpq; \ if (!mquant || mquant > 31 || mquant < -31) { \ - av_log(v->s.avctx, AV_LOG_ERROR, \ + av_log(s->avctx, AV_LOG_ERROR, \ "Overriding invalid mquant %d\n", mquant); \ mquant = 1; \ } \ @@ -265,7 +265,7 @@ static av_always_inline void get_mvdata_interlaced(VC1Context *v, int *dmv_x, { int index, index1; int extend_x, extend_y; - GetBitContext *gb = &v->s.gb; + GetBitContext *const gb = &v->s.s.gb; int bits, esc; int val, sign; @@ -512,7 +512,8 @@ static inline int vc1_coded_block_pred(MPVDecContext * s, int n, static int vc1_decode_ac_coeff(VC1Context *v, int *last, int *skip, int *value, int codingset) { - GetBitContext *gb = &v->s.gb; + MPVDecContext *const s = &v->s.s; + GetBitContext *gb = &s->gb; int index, run, level, lst, sign; index = get_vlc2(gb, ff_vc1_ac_coeff_table[codingset].table, AC_VLC_BITS, 3); @@ -546,19 +547,19 @@ static int vc1_decode_ac_coeff(VC1Context *v, int *last, int *skip, sign = get_bits1(gb); } else { lst = get_bits1(gb); - if (v->s.esc3_level_length == 0) { + if (s->esc3_level_length == 0) { if (v->pq < 8 || v->dquantfrm) { // table 59 - v->s.esc3_level_length = get_bits(gb, 3); - if (!v->s.esc3_level_length) - v->s.esc3_level_length = get_bits(gb, 2) + 8; + s->esc3_level_length = get_bits(gb, 3); + if (!s->esc3_level_length) + s->esc3_level_length = get_bits(gb, 2) + 8; } else { // table 60 - v->s.esc3_level_length = get_unary(gb, 1, 6) + 2; + s->esc3_level_length = get_unary(gb, 1, 6) + 2; } - v->s.esc3_run_length = 3 + get_bits(gb, 2); + s->esc3_run_length = 3 + get_bits(gb, 2); } - run = get_bits(gb, v->s.esc3_run_length); + run = get_bits(gb, s->esc3_run_length); sign = get_bits1(gb); - level = get_bits(gb, v->s.esc3_level_length); + level = get_bits(gb, s->esc3_level_length); } } @@ -579,8 +580,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; + MPVDecContext *const s = &v->s.s; + GetBitContext *gb = &s->gb; int dc_pred_dir = 0; /* Direction of the DC prediction used */ int i; int16_t *dc_val; @@ -606,7 +607,7 @@ static int vc1_decode_i_block(VC1Context *v, int16_t block[64], int n, } /* Prediction */ - dcdiff += vc1_i_pred_dc(&v->s, v->overlap, v->pq, n, &dc_val, &dc_pred_dir); + dcdiff += vc1_i_pred_dc(s, v->overlap, v->pq, n, &dc_val, &dc_pred_dir); *dc_val = dcdiff; /* Store the quantized DC coeff, used for prediction */ @@ -633,7 +634,7 @@ static int vc1_decode_i_block(VC1Context *v, int16_t block[64], int n, const uint8_t *zz_table; int k; - if (v->s.ac_pred) { + if (s->ac_pred) { if (!dc_pred_dir) zz_table = v->zz_8x8[2]; else @@ -717,8 +718,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; + MPVDecContext *const s = &v->s.s; + GetBitContext *gb = &s->gb; int dc_pred_dir = 0; /* Direction of the DC prediction used */ int i; int16_t *dc_val = NULL; @@ -750,7 +751,8 @@ static int vc1_decode_i_block_adv(VC1Context *v, int16_t block[64], int n, } /* Prediction */ - dcdiff += ff_vc1_pred_dc(&v->s, v->overlap, quant, n, v->a_avail, v->c_avail, &dc_val, &dc_pred_dir); + dcdiff += ff_vc1_pred_dc(s, v->overlap, quant, n, v->a_avail, + v->c_avail, &dc_val, &dc_pred_dir); *dc_val = dcdiff; /* Store the quantized DC coeff, used for prediction */ @@ -796,7 +798,7 @@ static int vc1_decode_i_block_adv(VC1Context *v, int16_t block[64], int n, const uint8_t *zz_table; int k; - if (v->s.ac_pred) { + if (s->ac_pred) { if (!use_pred && v->fcm == ILACE_FRAME) { zz_table = v->zzi_8x8; } else { @@ -908,8 +910,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; + MPVDecContext *const s = &v->s.s; + GetBitContext *gb = &s->gb; int dc_pred_dir = 0; /* Direction of the DC prediction used */ int i; int16_t *dc_val = NULL; @@ -950,7 +952,8 @@ static int vc1_decode_intra_block(VC1Context *v, int16_t block[64], int n, } /* Prediction */ - dcdiff += ff_vc1_pred_dc(&v->s, v->overlap, quant, n, a_avail, c_avail, &dc_val, &dc_pred_dir); + dcdiff += ff_vc1_pred_dc(s, v->overlap, quant, n, a_avail, + c_avail, &dc_val, &dc_pred_dir); *dc_val = dcdiff; /* Store the quantized DC coeff, used for prediction */ @@ -1117,7 +1120,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) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.s; GetBitContext *gb = &s->gb; int i, j; int subblkpat = 0; @@ -1286,7 +1289,7 @@ static const uint8_t size_table[6] = { 0, 2, 3, 4, 5, 8 }; */ static int vc1_decode_p_mb(VC1Context *v) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.s; GetBitContext *gb = &s->gb; int i, j; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; @@ -1312,7 +1315,7 @@ static int vc1_decode_p_mb(VC1Context *v) if (v->skip_is_raw) skipped = get_bits1(gb); else - skipped = v->s.mbskip_table[mb_pos]; + skipped = s->mbskip_table[mb_pos]; if (!fourmv) { /* 1MV mode */ if (!skipped) { @@ -1333,7 +1336,7 @@ static int vc1_decode_p_mb(VC1Context *v) } else if (mb_has_coeffs) { if (s->mb_intra) s->ac_pred = get_bits1(gb); - cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); + cbp = get_vlc2(gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); GET_MQUANT(); } else { mquant = v->pq; @@ -1398,7 +1401,7 @@ static int vc1_decode_p_mb(VC1Context *v) int intra_count = 0, coded_inter = 0; int is_intra[6], is_coded[6]; /* Get CBPCY */ - cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); + cbp = get_vlc2(gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); for (i = 0; i < 6; i++) { val = ((cbp >> (5 - i)) & 1); s->dc_val[0][s->block_index[i]] = 0; @@ -1518,7 +1521,7 @@ end: static int vc1_decode_p_mb_intfr(VC1Context *v) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.s; GetBitContext *gb = &s->gb; int i; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; @@ -1541,7 +1544,7 @@ static int vc1_decode_p_mb_intfr(VC1Context *v) if (v->skip_is_raw) skipped = get_bits1(gb); else - skipped = v->s.mbskip_table[mb_pos]; + skipped = s->mbskip_table[mb_pos]; if (!skipped) { if (v->fourmvswitch) idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_INTFR_4MV_MBMODE_VLC_BITS, 2); // try getting this done @@ -1588,8 +1591,8 @@ static int vc1_decode_p_mb_intfr(VC1Context *v) fieldtx = v->fieldtx_plane[mb_pos] = get_bits1(gb); mb_has_coeffs = get_bits1(gb); if (mb_has_coeffs) - cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); - v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb); + cbp = 1 + get_vlc2(gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); + s->ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb); GET_MQUANT(); s->current_picture.qscale_table[mb_pos] = mquant; /* Set DC scale - y and c use the same (not sure if necessary here) */ @@ -1622,7 +1625,7 @@ static int vc1_decode_p_mb_intfr(VC1Context *v) } else { // inter MB mb_has_coeffs = ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][3]; if (mb_has_coeffs) - cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); + cbp = 1 + get_vlc2(gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); if (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_2MV_FIELD) { v->twomvbp = get_vlc2(gb, v->twomvbp_vlc->table, VC1_2MV_BLOCK_PATTERN_VLC_BITS, 1); } else { @@ -1728,7 +1731,7 @@ static int vc1_decode_p_mb_intfr(VC1Context *v) static int vc1_decode_p_mb_intfi(VC1Context *v) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.s; GetBitContext *gb = &s->gb; int i; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; @@ -1759,10 +1762,10 @@ static int vc1_decode_p_mb_intfi(VC1Context *v) /* Set DC scale - y and c use the same (not sure if necessary here) */ s->y_dc_scale = s->y_dc_scale_table[FFABS(mquant)]; s->c_dc_scale = s->c_dc_scale_table[FFABS(mquant)]; - v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb); + s->ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb); mb_has_coeffs = idx_mbmode & 1; if (mb_has_coeffs) - cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_ICBPCY_VLC_BITS, 2); + cbp = 1 + get_vlc2(gb, v->cbpcy_vlc->table, VC1_ICBPCY_VLC_BITS, 2); dst_idx = 0; for (i = 0; i < 6; i++) { v->a_avail = v->c_avail = 0; @@ -1809,7 +1812,7 @@ static int vc1_decode_p_mb_intfi(VC1Context *v) mb_has_coeffs = idx_mbmode & 1; } if (mb_has_coeffs) - cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); + cbp = 1 + get_vlc2(gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); if (cbp) { GET_MQUANT(); } @@ -1852,7 +1855,7 @@ static int vc1_decode_p_mb_intfi(VC1Context *v) */ static int vc1_decode_b_mb(VC1Context *v) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.s; GetBitContext *gb = &s->gb; int i, j; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; @@ -1878,7 +1881,7 @@ static int vc1_decode_b_mb(VC1Context *v) if (v->skip_is_raw) skipped = get_bits1(gb); else - skipped = v->s.mbskip_table[mb_pos]; + skipped = s->mbskip_table[mb_pos]; dmv_x[0] = dmv_x[1] = dmv_y[0] = dmv_y[1] = 0; for (i = 0; i < 6; i++) { @@ -1919,7 +1922,7 @@ static int vc1_decode_b_mb(VC1Context *v) return 0; } if (direct) { - cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); + cbp = get_vlc2(gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); GET_MQUANT(); s->mb_intra = 0; s->current_picture.qscale_table[mb_pos] = mquant; @@ -1957,7 +1960,7 @@ static int vc1_decode_b_mb(VC1Context *v) } if (s->mb_intra) s->ac_pred = get_bits1(gb); - cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); + cbp = get_vlc2(gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); GET_MQUANT(); s->current_picture.qscale_table[mb_pos] = mquant; if (!v->ttmbf && !s->mb_intra && mb_has_coeffs) @@ -2010,7 +2013,7 @@ static int vc1_decode_b_mb(VC1Context *v) */ static int vc1_decode_b_mb_intfi(VC1Context *v) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.s; GetBitContext *gb = &s->gb; int i, j; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; @@ -2042,10 +2045,10 @@ static int vc1_decode_b_mb_intfi(VC1Context *v) /* Set DC scale - y and c use the same (not sure if necessary here) */ s->y_dc_scale = s->y_dc_scale_table[FFABS(mquant)]; s->c_dc_scale = s->c_dc_scale_table[FFABS(mquant)]; - v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb); + s->ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb); mb_has_coeffs = idx_mbmode & 1; if (mb_has_coeffs) - cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_ICBPCY_VLC_BITS, 2); + cbp = 1 + get_vlc2(gb, v->cbpcy_vlc->table, VC1_ICBPCY_VLC_BITS, 2); dst_idx = 0; for (i = 0; i < 6; i++) { v->a_avail = v->c_avail = 0; @@ -2139,7 +2142,7 @@ static int vc1_decode_b_mb_intfi(VC1Context *v) mb_has_coeffs = idx_mbmode & 1; } if (mb_has_coeffs) - cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); + cbp = 1 + get_vlc2(gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); if (cbp) { GET_MQUANT(); } @@ -2177,7 +2180,7 @@ static int vc1_decode_b_mb_intfi(VC1Context *v) */ static int vc1_decode_b_mb_intfr(VC1Context *v) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.s; GetBitContext *gb = &s->gb; int i, j; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; @@ -2202,7 +2205,7 @@ static int vc1_decode_b_mb_intfr(VC1Context *v) if (v->skip_is_raw) skipped = get_bits1(gb); else - skipped = v->s.mbskip_table[mb_pos]; + skipped = s->mbskip_table[mb_pos]; if (!skipped) { idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_INTFR_NON4MV_MBMODE_VLC_BITS, 2); @@ -2233,8 +2236,8 @@ static int vc1_decode_b_mb_intfr(VC1Context *v) fieldtx = v->fieldtx_plane[mb_pos] = get_bits1(gb); mb_has_coeffs = get_bits1(gb); if (mb_has_coeffs) - cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); - v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb); + cbp = 1 + get_vlc2(gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); + s->ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb); GET_MQUANT(); s->current_picture.qscale_table[mb_pos] = mquant; /* Set DC scale - y and c use the same (not sure if necessary here) */ @@ -2328,7 +2331,7 @@ static int vc1_decode_b_mb_intfr(VC1Context *v) if (!skipped) { // inter MB mb_has_coeffs = ff_vc1_mbmode_intfrp[0][idx_mbmode][3]; if (mb_has_coeffs) - cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); + cbp = 1 + get_vlc2(gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); if (!direct) { if (bmvtype == BMV_TYPE_INTERPOLATED && twomv) { v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1); @@ -2527,7 +2530,7 @@ static int vc1_decode_b_mb_intfr(VC1Context *v) */ static void vc1_decode_i_blocks(VC1Context *v) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.s; int k, j; int cbp, val; uint8_t *coded_val; @@ -2581,8 +2584,8 @@ static void vc1_decode_i_blocks(VC1Context *v) } // do actual MB decoding and displaying - cbp = get_vlc2(&v->s.gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2); - v->s.ac_pred = get_bits1(&v->s.gb); + cbp = get_vlc2(&s->gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2); + s->ac_pred = get_bits1(&s->gb); for (k = 0; k < 6; k++) { v->mb_type[0][s->block_index[k]] = 1; @@ -2590,7 +2593,7 @@ static void vc1_decode_i_blocks(VC1Context *v) val = ((cbp >> (5 - k)) & 1); if (k < 4) { - int pred = vc1_coded_block_pred(&v->s, k, &coded_val); + int pred = vc1_coded_block_pred(s, k, &coded_val); val = val ^ pred; *coded_val = val; } @@ -2618,7 +2621,7 @@ static void vc1_decode_i_blocks(VC1Context *v) vc1_put_blocks_clamped(v, 0); } - if (v->s.loop_filter) + if (s->loop_filter) ff_vc1_i_loop_filter(v); if (get_bits_left(&s->gb) < 0) { @@ -2633,14 +2636,14 @@ static void vc1_decode_i_blocks(VC1Context *v) v->left_blk_idx = (v->left_blk_idx + 1) % (v->end_mb_x + 2); v->cur_blk_idx = (v->cur_blk_idx + 1) % (v->end_mb_x + 2); } - if (!v->s.loop_filter) + if (!s->loop_filter) ff_mpeg_draw_horiz_band(s, s->mb_y * 16, 16); else if (s->mb_y) ff_mpeg_draw_horiz_band(s, (s->mb_y - 1) * 16, 16); s->first_slice_line = 0; } - if (v->s.loop_filter) + if (s->loop_filter) ff_mpeg_draw_horiz_band(s, (s->end_mb_y - 1) * 16, 16); /* This is intentionally mb_height and not end_mb_y - unlike in advanced @@ -2652,7 +2655,7 @@ static void vc1_decode_i_blocks(VC1Context *v) */ static int vc1_decode_i_blocks_adv(VC1Context *v) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.s; int k; int cbp, val; uint8_t *coded_val; @@ -2716,20 +2719,20 @@ static int vc1_decode_i_blocks_adv(VC1Context *v) // do actual MB decoding and displaying if (v->fieldtx_is_raw) - v->fieldtx_plane[mb_pos] = get_bits1(&v->s.gb); - if (get_bits_left(&v->s.gb) <= 1) { + v->fieldtx_plane[mb_pos] = get_bits1(gb); + if (get_bits_left(gb) <= 1) { ff_er_add_slice(&s->er, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR); return 0; } - cbp = get_vlc2(&v->s.gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2); + cbp = get_vlc2(gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2); if (v->acpred_is_raw) - v->s.ac_pred = get_bits1(&v->s.gb); + s->ac_pred = get_bits1(gb); else - v->s.ac_pred = v->acpred_plane[mb_pos]; + s->ac_pred = v->acpred_plane[mb_pos]; if (v->condover == CONDOVER_SELECT && v->overflg_is_raw) - v->over_flags_plane[mb_pos] = get_bits1(&v->s.gb); + v->over_flags_plane[mb_pos] = get_bits1(gb); GET_MQUANT(); @@ -2744,7 +2747,7 @@ static int vc1_decode_i_blocks_adv(VC1Context *v) val = ((cbp >> (5 - k)) & 1); if (k < 4) { - int pred = vc1_coded_block_pred(&v->s, k, &coded_val); + int pred = vc1_coded_block_pred(s, k, &coded_val); val = val ^ pred; *coded_val = val; } @@ -2764,7 +2767,7 @@ static int vc1_decode_i_blocks_adv(VC1Context *v) if (v->overlap && (v->pq >= 9 || v->condover != CONDOVER_NONE)) ff_vc1_i_overlap_filter(v); vc1_put_blocks_clamped(v, 1); - if (v->s.loop_filter) + if (s->loop_filter) ff_vc1_i_loop_filter(v); if (get_bits_left(&s->gb) < 0) { @@ -2779,14 +2782,14 @@ static int vc1_decode_i_blocks_adv(VC1Context *v) inc_blk_idx(v->left_blk_idx); inc_blk_idx(v->cur_blk_idx); } - if (!v->s.loop_filter) + if (!s->loop_filter) ff_mpeg_draw_horiz_band(s, s->mb_y * 16, 16); else if (s->mb_y) ff_mpeg_draw_horiz_band(s, (s->mb_y-1) * 16, 16); s->first_slice_line = 0; } - if (v->s.loop_filter) + if (s->loop_filter) ff_mpeg_draw_horiz_band(s, (s->end_mb_y - 1) * 16, 16); ff_er_add_slice(&s->er, 0, s->start_mb_y << v->field_mode, s->mb_width - 1, (s->end_mb_y << v->field_mode) - 1, ER_MB_END); @@ -2795,7 +2798,7 @@ static int vc1_decode_i_blocks_adv(VC1Context *v) static void vc1_decode_p_blocks(VC1Context *v) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.s; int apply_loop_filter; /* select coding mode used for VLC tables selection */ @@ -2833,7 +2836,7 @@ static void vc1_decode_p_blocks(VC1Context *v) ff_update_block_index(s); if (v->fcm == ILACE_FIELD || (v->fcm == PROGRESSIVE && v->mv_type_is_raw) || v->skip_is_raw) - if (get_bits_left(&v->s.gb) <= 1) { + if (get_bits_left(&s->gb) <= 1) { ff_er_add_slice(&s->er, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR); return; } @@ -2887,7 +2890,7 @@ static void vc1_decode_p_blocks(VC1Context *v) static void vc1_decode_b_blocks(VC1Context *v) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.s; /* select coding mode used for VLC tables selection */ switch (v->c_ac_table_index) { @@ -2922,22 +2925,22 @@ static void vc1_decode_b_blocks(VC1Context *v) ff_update_block_index(s); if (v->fcm == ILACE_FIELD || v->skip_is_raw || v->dmb_is_raw) - if (get_bits_left(&v->s.gb) <= 1) { + if (get_bits_left(&s->gb) <= 1) { ff_er_add_slice(&s->er, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR); return; } if (v->fcm == ILACE_FIELD) { vc1_decode_b_mb_intfi(v); - if (v->s.loop_filter) + if (s->loop_filter) ff_vc1_b_intfi_loop_filter(v); } else if (v->fcm == ILACE_FRAME) { vc1_decode_b_mb_intfr(v); - if (v->s.loop_filter) + if (s->loop_filter) ff_vc1_p_intfr_loop_filter(v); } else { vc1_decode_b_mb(v); - if (v->s.loop_filter) + if (s->loop_filter) ff_vc1_i_loop_filter(v); } if (get_bits_left(&s->gb) < 0 || get_bits_count(&s->gb) < 0) { @@ -2957,13 +2960,13 @@ static void vc1_decode_b_blocks(VC1Context *v) memmove(v->is_intra_base, v->is_intra - s->mb_stride, sizeof(v->is_intra_base[0]) * 2 * s->mb_stride); - if (!v->s.loop_filter) + if (!s->loop_filter) ff_mpeg_draw_horiz_band(s, s->mb_y * 16, 16); else if (s->mb_y) ff_mpeg_draw_horiz_band(s, (s->mb_y - 1) * 16, 16); s->first_slice_line = 0; } - if (v->s.loop_filter) + if (s->loop_filter) ff_mpeg_draw_horiz_band(s, (s->end_mb_y - 1) * 16, 16); ff_er_add_slice(&s->er, 0, s->start_mb_y << v->field_mode, s->mb_width - 1, (s->end_mb_y << v->field_mode) - 1, ER_MB_END); @@ -2971,9 +2974,9 @@ static void vc1_decode_b_blocks(VC1Context *v) static void vc1_decode_skip_blocks(VC1Context *v) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.s; - if (!v->s.last_picture.f->data[0]) + if (!s->last_picture.f->data[0]) return; ff_er_add_slice(&s->er, 0, s->start_mb_y, s->mb_width - 1, s->end_mb_y - 1, ER_MB_END); @@ -2993,23 +2996,24 @@ static void vc1_decode_skip_blocks(VC1Context *v) void ff_vc1_decode_blocks(VC1Context *v) { + MPVDecContext *const s = &v->s.s; - v->s.esc3_level_length = 0; + s->esc3_level_length = 0; if (v->x8_type) { - ff_intrax8_decode_picture(&v->x8, &v->s.current_picture, - &v->s.gb, &v->s.mb_x, &v->s.mb_y, + ff_intrax8_decode_picture(&v->x8, &s->current_picture, + &s->gb, &s->mb_x, &s->mb_y, 2 * v->pq + v->halfpq, v->pq * !v->pquantizer, - v->s.loop_filter, v->s.low_delay); + s->loop_filter, s->low_delay); - ff_er_add_slice(&v->s.er, 0, 0, - (v->s.mb_x >> 1) - 1, (v->s.mb_y >> 1) - 1, + ff_er_add_slice(&s->er, 0, 0, + (s->mb_x >> 1) - 1, (s->mb_y >> 1) - 1, ER_MB_END); } else { v->cur_blk_idx = 0; v->left_blk_idx = -1; v->topleft_blk_idx = 1; v->top_blk_idx = 2; - switch (v->s.pict_type) { + switch (s->pict_type) { case AV_PICTURE_TYPE_I: if (v->profile == PROFILE_ADVANCED) vc1_decode_i_blocks_adv(v); diff --git a/libavcodec/vc1_loopfilter.c b/libavcodec/vc1_loopfilter.c index 3eb2feea36..d664392fc4 100644 --- a/libavcodec/vc1_loopfilter.c +++ b/libavcodec/vc1_loopfilter.c @@ -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) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.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) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.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) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.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) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.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) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.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) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.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) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.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) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.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) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.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) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.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) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.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) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.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) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.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) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.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 3e3bf27552..7942f6f373 100644 --- a/libavcodec/vc1_mc.c +++ b/libavcodec/vc1_mc.c @@ -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) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.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) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.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) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.s; H264ChromaContext *h264chroma = &v->h264chroma; uint8_t *srcY, *srcU, *srcV; int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y; @@ -184,7 +184,7 @@ void ff_vc1_mc_1mv(VC1Context *v, int dir) if ((!v->field_mode || (v->ref_field_type[dir] == 1 && v->cur_field_type == 1)) && - !v->s.last_picture.f->data[0]) + !s->last_picture.f->data[0]) return; linesize = s->current_picture_ptr->f->linesize[0]; @@ -246,7 +246,7 @@ void ff_vc1_mc_1mv(VC1Context *v, int dir) } if (!srcY || !srcU) { - av_log(v->s.avctx, AV_LOG_ERROR, "Referenced frame missing.\n"); + av_log(s->avctx, AV_LOG_ERROR, "Referenced frame missing.\n"); return; } @@ -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) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.s; uint8_t *srcY; int dxy, mx, my, src_x, src_y; int off; @@ -464,7 +464,7 @@ void ff_vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg) if ((!v->field_mode || (v->ref_field_type[dir] == 1 && v->cur_field_type == 1)) && - !v->s.last_picture.f->data[0]) + !s->last_picture.f->data[0]) return; linesize = s->current_picture_ptr->f->linesize[0]; @@ -492,7 +492,7 @@ void ff_vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg) } if (!srcY) { - av_log(v->s.avctx, AV_LOG_ERROR, "Referenced frame missing.\n"); + av_log(s->avctx, AV_LOG_ERROR, "Referenced frame missing.\n"); return; } @@ -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) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.s; H264ChromaContext *h264chroma = &v->h264chroma; uint8_t *srcU, *srcV; int uvmx, uvmy, uvsrc_x, uvsrc_y; @@ -645,7 +645,7 @@ void ff_vc1_mc_4mv_chroma(VC1Context *v, int dir) int interlace; int uvlinesize; - if (!v->field_mode && !v->s.last_picture.f->data[0]) + if (!v->field_mode && !s->last_picture.f->data[0]) return; if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY) return; @@ -664,7 +664,7 @@ void ff_vc1_mc_4mv_chroma(VC1Context *v, int dir) int opp_count = get_luma_mv(v, dir, &tx, &ty); chroma_ref_type = v->cur_field_type ^ (opp_count > 2); } - if (v->field_mode && chroma_ref_type == 1 && v->cur_field_type == 1 && !v->s.last_picture.f->data[0]) + if (v->field_mode && chroma_ref_type == 1 && v->cur_field_type == 1 && !s->last_picture.f->data[0]) return; s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][0] = tx; s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][1] = ty; @@ -719,7 +719,7 @@ void ff_vc1_mc_4mv_chroma(VC1Context *v, int dir) } if (!srcU) { - av_log(v->s.avctx, AV_LOG_ERROR, "Referenced frame missing.\n"); + av_log(s->avctx, AV_LOG_ERROR, "Referenced frame missing.\n"); return; } @@ -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) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.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) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.s; H264ChromaContext *h264chroma = &v->h264chroma; uint8_t *srcY, *srcU, *srcV; int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y; @@ -1012,7 +1012,7 @@ void ff_vc1_interp_mc(VC1Context *v) int interlace; int linesize, uvlinesize; - if (!v->field_mode && !v->s.next_picture.f->data[0]) + if (!v->field_mode && !s->next_picture.f->data[0]) return; linesize = s->current_picture_ptr->f->linesize[0]; diff --git a/libavcodec/vc1_parser.c b/libavcodec/vc1_parser.c index 00896ddb09..b320826e5b 100644 --- a/libavcodec/vc1_parser.c +++ b/libavcodec/vc1_parser.c @@ -65,7 +65,7 @@ static void vc1_extract_header(AVCodecParserContext *s, AVCodecContext *avctx, VC1ParseContext *vpc = s->priv_data; GetBitContext gb; int ret; - vpc->v.s.avctx = avctx; + vpc->v.s.s.avctx = avctx; vpc->v.parse_only = 1; init_get_bits8(&gb, buf, buf_size); switch (vpc->prev_start_code) { @@ -85,10 +85,10 @@ static void vc1_extract_header(AVCodecParserContext *s, AVCodecContext *avctx, break; /* keep AV_PICTURE_TYPE_BI internal to VC1 */ - if (vpc->v.s.pict_type == AV_PICTURE_TYPE_BI) + if (vpc->v.s.s.pict_type == AV_PICTURE_TYPE_BI) s->pict_type = AV_PICTURE_TYPE_B; else - s->pict_type = vpc->v.s.pict_type; + s->pict_type = vpc->v.s.s.pict_type; if (avctx->ticks_per_frame > 1){ // process pulldown flags @@ -259,7 +259,7 @@ static int vc1_parse(AVCodecParserContext *s, static av_cold int vc1_parse_init(AVCodecParserContext *s) { VC1ParseContext *vpc = s->priv_data; - vpc->v.s.slice_context_count = 1; + vpc->v.s.s.slice_context_count = 1; vpc->v.first_pic_header_flag = 1; vpc->prev_start_code = 0; vpc->bytes_to_skip = 0; diff --git a/libavcodec/vc1_pred.c b/libavcodec/vc1_pred.c index 75240e239a..2924aff9e6 100644 --- a/libavcodec/vc1_pred.c +++ b/libavcodec/vc1_pred.c @@ -40,7 +40,7 @@ static av_always_inline int scaleforsame_x(VC1Context *v, int n /* MV */, int di int scalezone1_x, zone1offset_x; int table_index = dir ^ v->second_field; - if (v->s.pict_type != AV_PICTURE_TYPE_B) + if (v->s.s.pict_type != AV_PICTURE_TYPE_B) refdist = v->refdist; else refdist = dir ? v->brfd : v->frfd; @@ -73,7 +73,7 @@ static av_always_inline int scaleforsame_y(VC1Context *v, int i, int n /* MV */, int scalezone1_y, zone1offset_y; int table_index = dir ^ v->second_field; - if (v->s.pict_type != AV_PICTURE_TYPE_B) + if (v->s.s.pict_type != AV_PICTURE_TYPE_B) refdist = v->refdist; else refdist = dir ? v->brfd : v->frfd; @@ -165,10 +165,10 @@ static av_always_inline int scaleforsame(VC1Context *v, int i, int n /* MV */, int dim, int dir) { int brfd, scalesame; - int hpel = 1 - v->s.quarter_sample; + int hpel = 1 - v->s.s.quarter_sample; n >>= hpel; - if (v->s.pict_type != AV_PICTURE_TYPE_B || v->second_field || !dir) { + if (v->s.s.pict_type != AV_PICTURE_TYPE_B || v->second_field || !dir) { if (dim) n = scaleforsame_y(v, i, n, dir) * (1 << hpel); else @@ -186,17 +186,17 @@ static av_always_inline int scaleforopp(VC1Context *v, int n /* MV */, int dim, int dir) { int refdist, scaleopp; - int hpel = 1 - v->s.quarter_sample; + int hpel = 1 - v->s.s.quarter_sample; n >>= hpel; - if (v->s.pict_type == AV_PICTURE_TYPE_B && !v->second_field && dir == 1) { + if (v->s.s.pict_type == AV_PICTURE_TYPE_B && !v->second_field && dir == 1) { if (dim) n = scaleforopp_y(v, n, dir) * (1 << hpel); else n = scaleforopp_x(v, n) * (1 << hpel); return n; } - if (v->s.pict_type != AV_PICTURE_TYPE_B) + if (v->s.s.pict_type != AV_PICTURE_TYPE_B) refdist = v->refdist; else refdist = dir ? v->brfd : v->frfd; @@ -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) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.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) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.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) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.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; - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.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 6945042450..502ea2bae4 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -104,7 +104,7 @@ static void vc1_sprite_parse_transform(GetBitContext* gb, int c[7]) static int vc1_parse_sprites(VC1Context *v, GetBitContext* gb, SpriteData* sd) { - AVCodecContext *avctx = v->s.avctx; + AVCodecContext *avctx = v->s.s.avctx; int sprite, i; for (sprite = 0; sprite <= v->two_sprites; sprite++) { @@ -175,7 +175,7 @@ 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; + MPVDecContext *const s = &v->s.s; int i, plane, row, sprite; int sr_cache[2][2] = { { -1, -1 }, { -1, -1 } }; uint8_t* src_h[2][2]; @@ -272,7 +272,7 @@ static void vc1_draw_sprites(VC1Context *v, SpriteData* sd) static int vc1_decode_sprites(VC1Context *v, GetBitContext* gb) { - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.s; int ret; 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; - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.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) { - MPVMainDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.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; - MPVMainDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.s; GetBitContext gb; int ret; @@ -433,7 +433,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) if (!avctx->extradata_size || !avctx->extradata) return AVERROR_INVALIDDATA; - v->s.avctx = avctx; + s->avctx = avctx; ff_vc1_init_common(v); @@ -625,7 +625,8 @@ 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; - MPVMainDecContext *const s = &v->s; + MPVMainDecContext *const m = &v->s; + MPVDecContext *const s = &m->s; AVFrame *pict = data; uint8_t *buf2 = NULL; const uint8_t *buf_start = buf, *buf_start_second_field = NULL; @@ -806,7 +807,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, if ((ret = ff_msmpeg4_decode_init(avctx)) < 0) goto err; if ((ret = ff_vc1_decode_init_alloc_tables(v)) < 0) { - ff_mpv_common_end(s); + ff_mpv_common_end(m); goto err; } @@ -837,22 +838,22 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, v->first_pic_header_flag = 0; if (avctx->debug & FF_DEBUG_PICT_INFO) - av_log(v->s.avctx, AV_LOG_DEBUG, "pict_type: %c\n", av_get_picture_type_char(s->pict_type)); + av_log(s->avctx, AV_LOG_DEBUG, "pict_type: %c\n", av_get_picture_type_char(s->pict_type)); if ((avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) && s->pict_type != AV_PICTURE_TYPE_I) { - av_log(v->s.avctx, AV_LOG_ERROR, "Sprite decoder: expected I-frame\n"); + av_log(s->avctx, AV_LOG_ERROR, "Sprite decoder: expected I-frame\n"); ret = AVERROR_INVALIDDATA; goto err; } if ((avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) && v->field_mode) { - av_log(v->s.avctx, AV_LOG_ERROR, "Sprite decoder: expected Frames not Fields\n"); + av_log(s->avctx, AV_LOG_ERROR, "Sprite decoder: expected Frames not Fields\n"); ret = AVERROR_INVALIDDATA; goto err; } if ((s->mb_height >> v->field_mode) == 0) { - av_log(v->s.avctx, AV_LOG_ERROR, "image too short\n"); + av_log(s->avctx, AV_LOG_ERROR, "image too short\n"); ret = AVERROR_INVALIDDATA; goto err; } @@ -863,7 +864,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, /* skip B-frames if we don't have reference frames */ if (!s->last_picture_ptr && s->pict_type == AV_PICTURE_TYPE_B) { - av_log(v->s.avctx, AV_LOG_DEBUG, "Skipping B frame without reference frames\n"); + av_log(s->avctx, AV_LOG_DEBUG, "Skipping B frame without reference frames\n"); goto end; } if ((avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B) || @@ -872,13 +873,13 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, goto end; } - if ((ret = ff_mpv_frame_start(s, avctx)) < 0) { + if ((ret = ff_mpv_frame_start(m, avctx)) < 0) { goto err; } - v->s.current_picture_ptr->field_picture = v->field_mode; - v->s.current_picture_ptr->f->interlaced_frame = (v->fcm != PROGRESSIVE); - v->s.current_picture_ptr->f->top_field_first = v->tff; + s->current_picture_ptr->field_picture = v->field_mode; + s->current_picture_ptr->f->interlaced_frame = (v->fcm != PROGRESSIVE); + s->current_picture_ptr->f->top_field_first = v->tff; // process pulldown flags s->current_picture_ptr->f->repeat_pict = 0; @@ -918,7 +919,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, v->pic_header_flag = get_bits1(&s->gb); if (v->pic_header_flag) { if (ff_vc1_parse_frame_header_adv(v, &s->gb) < 0) { - av_log(v->s.avctx, AV_LOG_ERROR, "Slice header damaged\n"); + av_log(s->avctx, AV_LOG_ERROR, "Slice header damaged\n"); ret = AVERROR_INVALIDDATA; if (avctx->err_recognition & AV_EF_EXPLODE) goto err; @@ -945,7 +946,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, ret = AVERROR_INVALIDDATA; goto err; } - v->s.current_picture_ptr->f->pict_type = v->s.pict_type; + s->current_picture_ptr->f->pict_type = s->pict_type; if ((ret = avctx->hwaccel->start_frame(avctx, buf_start_second_field, (buf + buf_size) - buf_start_second_field)) < 0) goto err; @@ -965,7 +966,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, v->pic_header_flag = get_bits1(&s->gb); if (v->pic_header_flag) { if (ff_vc1_parse_frame_header_adv(v, &s->gb) < 0) { - av_log(v->s.avctx, AV_LOG_ERROR, "Slice header damaged\n"); + av_log(s->avctx, AV_LOG_ERROR, "Slice header damaged\n"); ret = AVERROR_INVALIDDATA; if (avctx->err_recognition & AV_EF_EXPLODE) goto err; @@ -1002,7 +1003,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, v->pic_header_flag = get_bits1(&s->gb); if (v->pic_header_flag) { if (ff_vc1_parse_frame_header_adv(v, &s->gb) < 0) { - av_log(v->s.avctx, AV_LOG_ERROR, "Slice header damaged\n"); + av_log(s->avctx, AV_LOG_ERROR, "Slice header damaged\n"); ret = AVERROR_INVALIDDATA; if (avctx->err_recognition & AV_EF_EXPLODE) goto err; @@ -1020,7 +1021,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, } else { int header_ret = 0; - ff_mpeg_er_frame_start(s); + ff_mpeg_er_frame_start(m); v->end_mb_x = s->mb_width; if (v->field_mode) { @@ -1037,7 +1038,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, for (i = 0; i <= n_slices; i++) { if (i > 0 && slices[i - 1].mby_start >= mb_height) { if (v->field_mode <= 0) { - av_log(v->s.avctx, AV_LOG_ERROR, "Slice %d starts beyond " + av_log(s->avctx, AV_LOG_ERROR, "Slice %d starts beyond " "picture boundary (%d >= %d)\n", i, slices[i - 1].mby_start, mb_height); continue; @@ -1055,7 +1056,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, v->pic_header_flag = 0; if (v->field_mode && i == n_slices1 + 2) { if ((header_ret = ff_vc1_parse_frame_header_adv(v, &s->gb)) < 0) { - av_log(v->s.avctx, AV_LOG_ERROR, "Field header damaged\n"); + av_log(s->avctx, AV_LOG_ERROR, "Field header damaged\n"); ret = AVERROR_INVALIDDATA; if (avctx->err_recognition & AV_EF_EXPLODE) goto err; @@ -1064,7 +1065,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, } else if (get_bits1(&s->gb)) { v->pic_header_flag = 1; if ((header_ret = ff_vc1_parse_frame_header_adv(v, &s->gb)) < 0) { - av_log(v->s.avctx, AV_LOG_ERROR, "Slice header damaged\n"); + av_log(s->avctx, AV_LOG_ERROR, "Slice header damaged\n"); ret = AVERROR_INVALIDDATA; if (avctx->err_recognition & AV_EF_EXPLODE) goto err; @@ -1079,19 +1080,19 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, s->end_mb_y = (i == n_slices ) ? mb_height : FFMIN(mb_height, slices[i].mby_start % mb_height); else { if (i >= n_slices) { - av_log(v->s.avctx, AV_LOG_ERROR, "first field slice count too large\n"); + av_log(s->avctx, AV_LOG_ERROR, "first field slice count too large\n"); continue; } s->end_mb_y = (i == n_slices1 + 1) ? mb_height : FFMIN(mb_height, slices[i].mby_start % mb_height); } if (s->end_mb_y <= s->start_mb_y) { - av_log(v->s.avctx, AV_LOG_ERROR, "end mb y %d %d invalid\n", s->end_mb_y, s->start_mb_y); + av_log(s->avctx, AV_LOG_ERROR, "end mb y %d %d invalid\n", s->end_mb_y, s->start_mb_y); continue; } if (((s->pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) || (s->pict_type == AV_PICTURE_TYPE_B && !v->bi_type)) && !v->cbpcy_vlc) { - av_log(v->s.avctx, AV_LOG_ERROR, "missing cbpcy_vlc\n"); + av_log(s->avctx, AV_LOG_ERROR, "missing cbpcy_vlc\n"); continue; } ff_vc1_decode_blocks(v); @@ -1106,7 +1107,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, s->current_picture.f->linesize[2] >>= 1; s->linesize >>= 1; s->uvlinesize >>= 1; - if (v->s.pict_type != AV_PICTURE_TYPE_BI && v->s.pict_type != AV_PICTURE_TYPE_B) { + if (s->pict_type != AV_PICTURE_TYPE_BI && s->pict_type != AV_PICTURE_TYPE_B) { FFSWAP(uint8_t *, v->mv_f_next[0], v->mv_f[0]); FFSWAP(uint8_t *, v->mv_f_next[1], v->mv_f[1]); } @@ -1125,7 +1126,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, ff_er_frame_end(&s->er); } - ff_mpv_frame_end(s); + ff_mpv_frame_end(m); if (avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) { image: diff --git a/libavcodec/vdpau_mpeg4.c b/libavcodec/vdpau_mpeg4.c index 7fcbd06647..e9483168aa 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; - MPVDecContext *const s = &ctx->m; + MPVDecContext *const s = &ctx->m.s; 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 e3aa36fbdd..f13b62f723 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; - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.s; Picture *pic = s->current_picture_ptr; struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; VdpPictureInfoVC1 *info = &pic_ctx->info.vc1; @@ -80,7 +80,7 @@ static int vdpau_vc1_start_frame(AVCodecContext *avctx, info->extended_dmv = v->extended_dmv; info->overlap = v->overlap; info->vstransform = v->vstransform; - info->loopfilter = v->s.loop_filter; + info->loopfilter = v->s.s.loop_filter; info->fastuvmc = v->fastuvmc; info->range_mapy_flag = v->range_mapy_flag; info->range_mapy = v->range_mapy; @@ -90,7 +90,7 @@ static int vdpau_vc1_start_frame(AVCodecContext *avctx, info->multires = v->multires; info->syncmarker = v->resync_marker; info->rangered = v->rangered | (v->rangeredfrm << 1); - info->maxbframes = v->s.max_b_frames; + info->maxbframes = v->s.s.max_b_frames; info->deblockEnable = v->postprocflag & 1; info->pquant = v->pq; @@ -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; - MPVDecContext *const s = &v->s; + MPVDecContext *const s = &v->s.s; Picture *pic = s->current_picture_ptr; struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; int val; diff --git a/libavcodec/wmv2.c b/libavcodec/wmv2.c index 29ed71f8aa..bfb14e2da3 100644 --- a/libavcodec/wmv2.c +++ b/libavcodec/wmv2.c @@ -25,8 +25,9 @@ #include "wmv2.h" -av_cold void ff_wmv2_common_init(MPVMainContext *s) +av_cold void ff_wmv2_common_init(MPVMainContext *m) { + MPVContext *const s = &m->s; WMV2Context *const w = s->private_ctx; ff_blockdsp_init(&s->bdsp, s->avctx); diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c index 128d78aa1d..7c4dc51782 100644 --- a/libavcodec/wmv2dec.c +++ b/libavcodec/wmv2dec.c @@ -60,7 +60,7 @@ typedef struct WMV2DecContext { static void wmv2_add_block(WMV2DecContext *w, int16_t *block1, uint8_t *dst, int stride, int n) { - MPVDecContext *const s = &w->s; + MPVDecContext *const s = &w->s.s; if (s->block_last_index[n] >= 0) { switch (w->abt_type_table[n]) { @@ -102,9 +102,9 @@ void ff_wmv2_add_mb(MPVDecContext *s, int16_t block1[6][64], static int parse_mb_skip(WMV2DecContext *w) { + MPVDecContext *const s = &w->s.s; int mb_x, mb_y; int coded_mb_count = 0; - MPVDecContext *const s = &w->s; uint32_t *const mb_type = s->current_picture_ptr->mb_type; w->skip_type = get_bits(&s->gb, 2); @@ -167,7 +167,7 @@ static int parse_mb_skip(WMV2DecContext *w) static int decode_ext_header(WMV2DecContext *w) { - MPVDecContext *const s = &w->s; + MPVDecContext *const s = &w->s.s; GetBitContext gb; int fps; int code; @@ -203,9 +203,10 @@ static int decode_ext_header(WMV2DecContext *w) return 0; } -int ff_wmv2_decode_picture_header(MPVMainDecContext *s) +int ff_wmv2_decode_picture_header(MPVMainDecContext *m) { - WMV2DecContext *const w = (WMV2DecContext *) s; + WMV2DecContext *const w = (WMV2DecContext *)m; + MPVDecContext *const s = &m->s; int code; if (s->picture_number == 0) @@ -238,9 +239,10 @@ int ff_wmv2_decode_picture_header(MPVMainDecContext *s) return 0; } -int ff_wmv2_decode_secondary_picture_header(MPVMainDecContext *s) +int ff_wmv2_decode_secondary_picture_header(MPVMainDecContext *m) { - WMV2DecContext *const w = (WMV2DecContext *) s; + WMV2DecContext *const w = (WMV2DecContext *)m; + MPVDecContext *const s = &m->s; if (s->pict_type == AV_PICTURE_TYPE_I) { if (w->j_type_bit) @@ -339,8 +341,8 @@ int ff_wmv2_decode_secondary_picture_header(MPVMainDecContext *s) 2 * s->qscale, (s->qscale - 1) | 1, s->loop_filter, s->low_delay); - ff_er_add_slice(&w->s.er, 0, 0, - (w->s.mb_x >> 1) - 1, (w->s.mb_y >> 1) - 1, + ff_er_add_slice(&s->er, 0, 0, + (s->mb_x >> 1) - 1, (s->mb_y >> 1) - 1, ER_MB_END); return 1; } @@ -350,7 +352,7 @@ int ff_wmv2_decode_secondary_picture_header(MPVMainDecContext *s) static inline void wmv2_decode_motion(WMV2DecContext *w, int *mx_ptr, int *my_ptr) { - MPVDecContext *const s = &w->s; + MPVDecContext *const s = &w->s.s; ff_msmpeg4_decode_motion(s, mx_ptr, my_ptr); @@ -362,7 +364,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) { - MPVDecContext *const s = &w->s; + MPVDecContext *const s = &w->s.s; int xy, wrap, diff, type; int16_t *A, *B, *C, *mot_val; @@ -408,7 +410,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) { - MPVDecContext *const s = &w->s; + MPVDecContext *const s = &w->s.s; static const int sub_cbp_table[3] = { 2, 3, 1 }; int sub_cbp, ret; @@ -565,7 +567,8 @@ int ff_wmv2_decode_mb(MPVDecContext *s, int16_t block[6][64]) static av_cold int wmv2_decode_init(AVCodecContext *avctx) { WMV2DecContext *const w = avctx->priv_data; - MPVMainDecContext *const s = &w->s; + MPVMainDecContext *const m = &w->s; + MPVDecContext *const s = &m->s; int ret; s->private_ctx = &w->common; @@ -573,15 +576,15 @@ static av_cold int wmv2_decode_init(AVCodecContext *avctx) if ((ret = ff_msmpeg4_decode_init(avctx)) < 0) return ret; - ff_wmv2_common_init(s); + ff_wmv2_common_init(m); 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, - w->s.mb_width, w->s.mb_height); + return ff_intrax8_common_init(avctx, &w->x8, &s->idsp, + s->block, s->block_last_index, + s->mb_width, s->mb_height); } static av_cold int wmv2_decode_end(AVCodecContext *avctx) diff --git a/libavcodec/wmv2enc.c b/libavcodec/wmv2enc.c index 11d566fe5a..cd21677955 100644 --- a/libavcodec/wmv2enc.c +++ b/libavcodec/wmv2enc.c @@ -43,7 +43,7 @@ typedef struct WMV2EncContext { static int encode_ext_header(WMV2EncContext *w) { - MPVEncContext *const s = &w->msmpeg4.s.common; + MPVEncContext *const s = &w->msmpeg4.s.common.s; PutBitContext pb; int code; @@ -71,7 +71,7 @@ static av_cold int wmv2_encode_init(AVCodecContext *avctx) { WMV2EncContext *const w = avctx->priv_data; MPVMainEncContext *const m = &w->msmpeg4.s; - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; s->private_ctx = &w->common; if (ff_mpv_encode_init(avctx) < 0) @@ -92,7 +92,7 @@ static av_cold int wmv2_encode_init(AVCodecContext *avctx) int ff_wmv2_encode_picture_header(MPVMainEncContext *m, int picture_number) { WMV2EncContext *const w = (WMV2EncContext *) m; - MPVEncContext *const s = &m->common; + MPVEncContext *const s = &m->common.s; put_bits(&s->pb, 1, s->pict_type - 1); if (s->pict_type == AV_PICTURE_TYPE_I) From patchwork Tue Feb 1 13:06:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34027 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp611456iov; Tue, 1 Feb 2022 05:21:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJyZxANX2x/ilqwey/DXAFHWY7BhrzoE/lMyHdrqPNAeI7JxDzCU+du1zLT9YPU1M1od85gP X-Received: by 2002:a50:ed16:: with SMTP id j22mr25815862eds.114.1643721680083; Tue, 01 Feb 2022 05:21: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 hr42si9568715ejc.818.2022.02.01.05.21.19; Tue, 01 Feb 2022 05:21: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=gRoRRRuq; 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 0F1B768B3DC; Tue, 1 Feb 2022 15:09:02 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2045.outbound.protection.outlook.com [40.92.91.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0B05468B3C6 for ; Tue, 1 Feb 2022 15:08:46 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MmNTXXyD5uAmZroiTK2tTeoM0ja1G3OsXXA29j5Xn7Ve1YusMDm6afQWqtoorZPo307PUDJ/TX3IQkTVRv72pqcEhEA2JwbA26iwuuKbUg3gGiFYFjFKZEdBUGMtbyb6BDOMAspbITHni/DzaC8QRnoblaox/lWmn/uD6l3vsnydG6lr7UAU7meoBVfMtufMciM4B099VDNDCZKBfilT9B4ZiJUeVFrl+k4yt/sWyWhdd1S3kSaiXBQmR+mHK0qEO4nnW5jITr5+uBgqOdywdEBUfVQ7sVkRwZ50JE5vTd2XS6X4OQlOFES4XsuDEEgsUQQYNseBOqCBgWTxHJhX/Q== 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=uBjdnAki5p2D7OfXfXAtIDiWfNkihoE1X2BP8WuzRbA=; b=jPQRfFVBuz7Y6A47gO3aeXCxckM5C8T6LxCfMeGmLPHxQCJ0JKWCG5wdiEyBxQKCj66tfrvoL4gPMrgfCh+OUv5sJ5rejoou+IEJo/vf38QV8ltXAh/6SeegBCkHkmaNFbf+AKxm/2KVDptKpypU+kAFoPVAoJ4SoPnkebFTQCchjWCv9P/8qCC2svOvXOI2ovTnvEagYOvDzxvdo+eRzUpVRZ2PjM0a/XGTTRRMuY72UO7eNgXRg0sBMOokh733unjN7UCgBdbL++7R90AgLlUGWs74S/HAsftQ2yzvCBKEWcLVQnl85ZNjJn/wqsKsToBwMLqrJmuHyYk5FL7Yvg== 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=uBjdnAki5p2D7OfXfXAtIDiWfNkihoE1X2BP8WuzRbA=; b=gRoRRRuq0GDFm3tEBQds54NtX4JGVgIlA8GNfmjyX0GvxznZxp/SczbscJqjEm5TJ3zbp3pf+sFqE6xY1nmt/P0W/bJDlrTrQLFvOD9ckmnzwVbDdY1Ds2AgECQ9ZHgB+EEX2WuN9TG+F+iIqDTCJdQNva1cwjqzslD7S7V4Y9QBhgWVNrEqxz7swPxcP8BEXKPzR8vaLVFAhhhWKXvKyyj/MzPMieOb8TnVOrHwU0fNzIbAB43A5wlAj+ES5U7Clwc5Pg/XcD51hA0aVbZp7NCT8Y7nrJpDlgXsg2IUPGNBbRK4Y9cijdI+xK43k95kf7hqC13AbQ5hyl4Pre+6zw== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM9PR03MB7962.eurprd03.prod.outlook.com (2603:10a6:20b:439::17) 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: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:08:45 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:55 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [jTa4telLy9IxPHOHi/HcpgtedP6lFUTH] 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-57-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1d9c9ad5-ab2d-46bc-31f8-08d9e583fa2e X-MS-TrafficTypeDiagnostic: AM9PR03MB7962:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: F/NiQbwBih84SeBd0MsksLW7BVMMCF8+n8zA0SoywmYowff0w07Dv0b6v8c5HrqsKyXY7oLwLC8Q6E/O+EvfzBs7UpyHqdxuNOWZMKs70LLBAfWfjAI+3avw1wi4IrOSwBlUwm0cdJ51GpLCZdLF2HwuXzyNABPw4COyE2GR+T+MljlIEGUnQdFCIyrm60nsrrrmFYGKW7vFhyj0hA7Yng31pil6VZJ0yM/rnd9fjrrjYSuPX4eDf55eOK+qrvEq4vQRMNm1N+ZfCQEPYXK+l02LS+ezBhkTaIMIMKh43F+CK3sQcH564Oj29+Ahlj8Cc6dYL0YX9d8YZ58L76RTu16bcUU21zP+ABDi8lTd88Q6EeueJ0rKtTtLLNiwKBiOaQ9dBwOQzON6w33MRGVhK36jUm7+ccSwrcmO5NsAWOjRUADlh4sjMLEAjHqZXPmtuf9xSCJIRPGnMKFXF95xnLUwnET2iqF2AQnj0CPJ6egnNo/8pMm/RagDTTP6pTSGKSomN/LYCv6uyDdL6AmkKMVphWU12d7LQ7TMtvSqF1c= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nplhTCE+g2383LuFKrd2ibl7jhWvO5Gyi/xmfPTdDeiNie8mHbdbuBZhETZvVkX59vE71QyrctC1kHc2Ex7LkG3Ff0V+L2MxzOpxwnMDHNt8HUgLaKuh2DsCRjlKiAwUWJB1LNwdSNS7zn1alJhybZVJK2d1jIHqIikO/M9LKDms56pHExrS9H1mogj9gjEPwhZZ2EXFJKDqSGgUnlS1gFqVmpnnNDcV05nzkT8kLJ0mJZE3wAp4o1q4ouWT7wmhQANe6Igw6IlM72d0yFu3R+hGlAzHn9ZlxheSdbwPtdrCjnIFar0ko79EaM4H9Euu9vbEnG1PX/2c2CePf51dC4ISY1ygi5wjZxtmOC1yqUuPj5u0kRAfTFkrzvnzxJGf/xskfa5TQMsJ32ke2BFSfg9jpgJw9ZeDay1V7hW9IS8bgWpokOZlG2MclHhgiZmgnF2rEDSf/pMDAw4WzMaIO9xfeed2hmHEyQa4GP0Lr2kvNaYClOoux4Acx739KrmD7lGupim0YgqIkZfpW3qPFUp+xtwHHuxxksiF6FVc/AHb00IPkS8w8DxtliNwdXoQrqfQm6GzWw6HAvnhRVlw6D3CWUkRSfyG2mqEr5te7iNuPGvvnhzox3aI9buX64EQC7pqprXWUniCMa7jMMrtYEcZEJgYlf/6s6yuaHl+AOmFPdrP57l528EomUUvNm0ustQ2vvkwM8pdwfXd3t3mbDh5lf/8m2MiX2CtovpOxx085ZtTwypSg5NhWuwk+wY5kSk0koH9Mc9O+KoOnevv9q47OQ272zT6VU/6346qhZATRN3WCT4no8wNvrf+BEA+4eH+FuPFIWz737bvTVHYBMyY3uQeBySDEmt6a7ab1AdF4r24Aeiwa2HItzxSLUEJ2WGxyjZE+g9/4o2WEiq9ihpiaWNBfLPEtY7/7mBddNrvTN0toINVCADjK28tNHR3ZJDQQg2V9nqJcrsMwZEmqg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1d9c9ad5-ab2d-46bc-31f8-08d9e583fa2e 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:45.1455 (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: AM9PR03MB7962 Subject: [FFmpeg-devel] [PATCH v2 58/69] avcodec/mpegvideo: Move slice-context ptr array to MPVMainContext 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: VZzfAr/SZ+kT The slice contexts don't have sub-slice contexts, so it makes no sense for them to have an array of pointers to slice contexts. Signed-off-by: Andreas Rheinhardt --- libavcodec/mjpegenc.c | 2 +- libavcodec/mpeg12dec.c | 12 ++++++------ libavcodec/mpegvideo.c | 21 ++++++++++----------- libavcodec/mpegvideo.h | 3 ++- libavcodec/mpegvideo_dec.c | 11 ++++++----- libavcodec/mpegvideo_enc.c | 29 +++++++++++++++-------------- 6 files changed, 40 insertions(+), 38 deletions(-) diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index faf59566b1..70636ffc91 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -86,7 +86,7 @@ static void mjpeg_encode_picture_header(MPVMainEncContext *m) s->esc_pos = put_bytes_count(&s->pb, 0); for (int i = 1; i < s->slice_context_count; i++) - s->thread_context[i]->esc_pos = 0; + m2->thread_context[i]->esc_pos = 0; } void ff_mjpeg_amv_encode_picture_header(MPVMainEncContext *main) diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index ef2fa80aba..925c72e8ff 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -2503,10 +2503,10 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture, av_assert0(avctx->thread_count > 1); avctx->execute(avctx, slice_decode_thread, - &s2->thread_context[0], NULL, + &m2->thread_context[0], NULL, s->slice_count, sizeof(void *)); for (i = 0; i < s->slice_count; i++) - s2->er.error_count += s2->thread_context[i]->er.error_count; + s2->er.error_count += m2->thread_context[i]->er.error_count; } ret = slice_end(avctx, picture); @@ -2575,10 +2575,10 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture, int i; avctx->execute(avctx, slice_decode_thread, - s2->thread_context, NULL, + m2->thread_context, NULL, s->slice_count, sizeof(void *)); for (i = 0; i < s->slice_count; i++) - s2->er.error_count += s2->thread_context[i]->er.error_count; + s2->er.error_count += m2->thread_context[i]->er.error_count; s->slice_count = 0; } if (last_code == 0 || last_code == SLICE_MIN_START_CODE) { @@ -2774,12 +2774,12 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture, s2->slice_context_count; av_assert0(avctx->thread_count > 1); if (threshold <= mb_y) { - MPVDecContext *const thread_context = s2->thread_context[s->slice_count]; + MPVDecContext *const thread_context = m2->thread_context[s->slice_count]; thread_context->start_mb_y = mb_y; thread_context->end_mb_y = s2->mb_height; if (s->slice_count) { - s2->thread_context[s->slice_count - 1]->end_mb_y = mb_y; + m2->thread_context[s->slice_count - 1]->end_mb_y = mb_y; ret = ff_update_duplicate_context(thread_context, s2); if (ret < 0) return ret; diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 072a82e6b3..220f1c39f0 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -400,14 +400,15 @@ int ff_mpv_init_duplicate_contexts(MPVMainContext *m) * 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(MPVContext)); - if (!s->thread_context[i]) + MPVContext *const s2 = av_memdup(s, sizeof(MPVContext)); + if (!s2) return AVERROR(ENOMEM); - if ((ret = init_duplicate_context(s->thread_context[i])) < 0) + m->thread_context[i] = s2; + if ((ret = init_duplicate_context(s2)) < 0) return ret; - s->thread_context[i]->start_mb_y = + s2->start_mb_y = (s->mb_height * (i ) + nb_slices / 2) / nb_slices; - s->thread_context[i]->end_mb_y = + s2->end_mb_y = (s->mb_height * (i + 1) + nb_slices / 2) / nb_slices; } s->start_mb_y = 0; @@ -441,8 +442,8 @@ static void free_duplicate_contexts(MPVMainContext *m) MPVContext *const s = &m->s; for (int i = 1; i < s->slice_context_count; i++) { - free_duplicate_context(s->thread_context[i]); - av_freep(&s->thread_context[i]); + free_duplicate_context(m->thread_context[i]); + av_freep(&m->thread_context[i]); } free_duplicate_context(s); } @@ -621,8 +622,7 @@ static void clear_context(MPVMainContext *m) memset(&s->current_picture, 0, sizeof(s->current_picture)); memset(&s->new_picture, 0, sizeof(s->new_picture)); - memset(s->thread_context, 0, sizeof(s->thread_context)); - + s->slice_context_count = 1; s->me.map = NULL; s->me.score_map = NULL; s->dct_error_sum = NULL; @@ -736,8 +736,7 @@ av_cold int ff_mpv_common_init(MPVMainContext *m) #endif s->context_initialized = 1; - memset(s->thread_context, 0, sizeof(s->thread_context)); - s->thread_context[0] = s; + m->thread_context[0] = s; s->slice_context_count = nb_slices; // if (s->width && s->height) { diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 9adadc5b02..9005dcb58a 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -120,7 +120,6 @@ typedef struct MPVContext { 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 MPVContext *thread_context[MAX_THREADS]; int slice_context_count; ///< number of used thread_contexts /** @@ -506,6 +505,8 @@ typedef struct MPVContext { */ typedef struct MPVMainContext { MPVContext s; + /* The first entry of this array points to the above MPVContext. */ + MPVContext *thread_context[MAX_THREADS]; } MPVMainContext; /** diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c index e70e306cf9..f202db33e9 100644 --- a/libavcodec/mpegvideo_dec.c +++ b/libavcodec/mpegvideo_dec.c @@ -197,13 +197,14 @@ do {\ int ff_mpv_common_frame_size_change(MPVMainDecContext *m) { + MPVMainContext *const m2 = m; MPVDecContext *const s = &m->s; int err = 0; if (!s->context_initialized) return AVERROR(EINVAL); - ff_mpv_free_context_frame(m); + ff_mpv_free_context_frame(m2); if (s->picture) for (int i = 0; i < MAX_PICTURE_COUNT; i++) @@ -233,11 +234,11 @@ int ff_mpv_common_frame_size_change(MPVMainDecContext *m) if ((err = ff_mpv_init_context_frame(m))) goto fail; - memset(s->thread_context, 0, sizeof(s->thread_context)); - s->thread_context[0] = s; + memset(m2->thread_context, 0, sizeof(m2->thread_context)); + m2->thread_context[0] = s; if (s->width && s->height) { - err = ff_mpv_init_duplicate_contexts(m); + err = ff_mpv_init_duplicate_contexts(m2); if (err < 0) goto fail; } @@ -245,7 +246,7 @@ int ff_mpv_common_frame_size_change(MPVMainDecContext *m) return 0; fail: - ff_mpv_free_context_frame(m); + ff_mpv_free_context_frame(m2); s->context_reinit = 1; return err; } diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 656aab04cf..735c9d322f 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -1778,13 +1778,13 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, } for (i = 0; i < context_count; i++) { - int start_y = s->thread_context[i]->start_mb_y; - int end_y = s->thread_context[i]-> end_mb_y; + int start_y = m2->thread_context[i]->start_mb_y; + int end_y = m2->thread_context[i]-> end_mb_y; int h = s->mb_height; uint8_t *start = pkt->data + (size_t)(((int64_t) pkt->size) * start_y / h); uint8_t *end = pkt->data + (size_t)(((int64_t) pkt->size) * end_y / h); - init_put_bits(&s->thread_context[i]->pb, start, end - start); + init_put_bits(&m2->thread_context[i]->pb, start, end - start); } s->pict_type = s->new_picture.f->pict_type; @@ -1838,7 +1838,7 @@ vbv_retry: s->last_non_b_time = s->time - s->pp_time; } for (i = 0; i < context_count; i++) { - PutBitContext *pb = &s->thread_context[i]->pb; + PutBitContext *pb = &m2->thread_context[i]->pb; init_put_bits(pb, pb->buf, pb->buf_end - pb->buf); } s->vbv_ignore_qmax = 1; @@ -3602,7 +3602,7 @@ static int encode_picture(MPVMainEncContext *m, int picture_number) s->mb_intra=0; //for the rate distortion & bit compare functions for(i=1; ithread_context[i], s); + ret = ff_update_duplicate_context(m2->thread_context[i], s); if (ret < 0) return ret; } @@ -3617,11 +3617,11 @@ static int encode_picture(MPVMainEncContext *m, int picture_number) if (s->pict_type != AV_PICTURE_TYPE_B) { 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*)); + s->avctx->execute(s->avctx, pre_estimate_motion_thread, &m2->thread_context[0], NULL, context_count, sizeof(void*)); } } - s->avctx->execute(s->avctx, estimate_motion_thread, &s->thread_context[0], NULL, context_count, sizeof(void*)); + s->avctx->execute(s->avctx, estimate_motion_thread, &m2->thread_context[0], NULL, context_count, sizeof(void*)); }else /* if(s->pict_type == AV_PICTURE_TYPE_I) */{ /* I-Frame */ for(i=0; imb_stride*s->mb_height; i++) @@ -3629,11 +3629,11 @@ static int encode_picture(MPVMainEncContext *m, int picture_number) if (!m->fixed_qscale) { /* finding spatial complexity for I-frame rate control */ - s->avctx->execute(s->avctx, mb_var_thread, &s->thread_context[0], NULL, context_count, sizeof(void*)); + s->avctx->execute(s->avctx, mb_var_thread, &m2->thread_context[0], NULL, context_count, sizeof(void*)); } } for(i=1; ithread_context[i]); + merge_context_after_me(s, m2->thread_context[i]); } s->current_picture.mc_mb_var_sum= s->current_picture_ptr->mc_mb_var_sum= s->me.mc_mb_var_sum_temp; s->current_picture. mb_var_sum= s->current_picture_ptr-> mb_var_sum= s->me. mb_var_sum_temp; @@ -3819,13 +3819,14 @@ static int encode_picture(MPVMainEncContext *m, int picture_number) m->header_bits = bits - s->last_bits; for(i=1; ithread_context[i], s); + update_duplicate_context_after_me(m2->thread_context[i], s); } - s->avctx->execute(s->avctx, encode_thread, &s->thread_context[0], NULL, context_count, sizeof(void*)); + s->avctx->execute(s->avctx, encode_thread, &m2->thread_context[0], NULL, context_count, sizeof(void*)); for(i=1; ipb.buf_end == s->thread_context[i]->pb.buf) - set_put_bits_buffer_size(&s->pb, FFMIN(s->thread_context[i]->pb.buf_end - s->pb.buf, INT_MAX/8-BUF_BITS)); - merge_context_after_encode(s, s->thread_context[i]); + MPVEncContext *const slice = m2->thread_context[i]; + if (s->pb.buf_end == slice->pb.buf) + set_put_bits_buffer_size(&s->pb, FFMIN(slice->pb.buf_end - s->pb.buf, INT_MAX/8-BUF_BITS)); + merge_context_after_encode(s, slice); } emms_c(); return 0; From patchwork Tue Feb 1 13:06:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34028 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp611719iov; Tue, 1 Feb 2022 05:21:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJyk0a7VSACN8osq5Ki9vSMtwN4oAoxgv/mGbhdDhydMjzebnd4sN2IspLcHG+ft7IKt3xQZ X-Received: by 2002:a17:907:1c8d:: with SMTP id nb13mr20393959ejc.150.1643721698368; Tue, 01 Feb 2022 05:21:38 -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 b6si10139963ejb.527.2022.02.01.05.21.34; Tue, 01 Feb 2022 05:21:38 -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=kcMNjije; 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 DF1AE68B43E; Tue, 1 Feb 2022 15:09:02 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2045.outbound.protection.outlook.com [40.92.91.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3A57368B3C6 for ; Tue, 1 Feb 2022 15:08:47 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eSRdSA0vQOherycpr/DeJXT62nHJ36G23Cchp8z1u9ohNlfXMjlNkJ6ZX+XsYBLzqxtvnRuwMS7jsCjsJ9h3js6OXwMpi/wU4MXMmigAvjV1omt9wvW1WDDllQqiXm6IEnRfZcieQPfHdskf2ZM8RdwKvdInfuQe54t6stcfSbwg0h0LodFcSrTTZCgkUdRBu2a89Csr9Vc2yvFQqE+2QieJW13mf8IZFQvmQU1e1o85DONPv/1XqgNOe4w1ChRbOQoZik4m08/euSCgNga7vHZPLE+bVxtXr16qOBe2m6fKpQShCisuZI+txbBxUK08MX4TOObagj90fMET1H7xXg== 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=sJ4xb0rp/Fcjj+I28foot4JESrD/iMVy3ItgAnRW3RI=; b=istiJZpu35uyiG9NGJ5gXRfDee0gZ5iuS0ci7KWEYkwqiPy8dKTuX60kv0c2iWVGETp7gHwvugGmckTraXTmddobDGDBX/HQ3rqyWBx/pRlvXRRqZTCypO02MuKssPb0mtVnLpyOdXejN87atFKk0uz+kL6l61Z2KYCvRE/05fyGFQwLUW8NTpFXEaPQHfIAbtet8k0itn946BcX5m+5dUxyONGbpeUEdutj+hjK7L5NR3DjK2pzd7wLaMTVpcwNvbws1kpZSBA9xsduw9QHFoATGPOhi0+UvKxgra86mI+rhG0bDik3uQ/dsWWxIY5mTd+KgFom3QOYAskR3sDWxg== 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=sJ4xb0rp/Fcjj+I28foot4JESrD/iMVy3ItgAnRW3RI=; b=kcMNjijeH4OwvQQ/Wv9JEi6t9jKGaPI9NmSwK7N6Ziv3M+nXoVY2LLyQ7+/u80QCE1+Ha3IQy1+Xc1ZRgVr3UMU/0B1dcEnSBw+a9CSQ3VPgi/Lfx+Y6QpGLq+YJLvAGmsqBAgt2cxCCAQrw72mU+VYQYK/2UKanmZzEluDXeGXTOp1mL/VOnU1YBOxMJwh3fUx71Fz/pcgxvmJcXTSJxXf+2/i6eGLGr8BU7iKwYupIUjOnvemAP89bCCi4TOTaqLt+EU/Y4fqqlIGgvXRERs88HS6Hq11gkPeng1QXakGsrliZHnIhWPIbeciUSQW3HVjX3KezuphTy5BXH6HCDg== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM9PR03MB7962.eurprd03.prod.outlook.com (2603:10a6:20b:439::17) 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:46 +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:46 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:56 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [5yEmtcyEzl5RIXthKjalLVgeWDMxTaE5] 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-58-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eeecb7b3-7062-46bc-ed19-08d9e583faec X-MS-TrafficTypeDiagnostic: AM9PR03MB7962:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: niwZdgxgwIOJTfCi9Zic2+kN0APKEEG1ZFU9vJWsrEgiwdI8V8RjBuNDCbZYAAKE3YLhot1unClJSGRr5eRIAEW5lnQEhYilQlp4nvVb8Qn+Y1/w9upLdD+aN7tU2LFGwXB6im/2Nxjbpqw8uC3WfyFxiwrMErxTR01FebNEQOTsgsAZfh3WWnn0q4xWQe50iIADRnfkwwr25+BvJ0Z3k8imHP9T7ts2/VJqlbndYvHlPmejnNNKEp5URT8VmS6+QIAaH8pKttVMs96q6VvF+QLLQAr/43hPDcvIIqLgusUhtdT86D6EvNsEm+G1NwaX4CgCZhlCrk9BadHR78TtBleFOd9myIGkN9GirQtEGhl0QxKbNbvVABprMuq3RlhUKRxEjF4TzLem4BLvMlL8vwd6iuL3gM0JMi2KRggci3/BMj6td9hTqCYdbIjulyGJrIXhwzUFI91hJi1CCAaftRgRtBlvsa62MeGKUYFzc/9OYq1fmh5dh/OzaSU+Nxi7iNDdNoKUuvDoRVGbI7vygFuXlX9osvWRkWSVzHjBJJg/kkuJzQjNwlrqinOv+9b/ X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uoyhMvQ8opZyJBclbUXD8+GVQrheeFUP80gYJ/SdyiKKxdWYShrJ6OpAZroBIh5MZz3HkcOT8KOoLMXQSCBmmAiqnRflVjZDye+7R5i7PC75EsgTwyFSuOwQWlvqDT+qF8srhr5Bxwcq61IzsZMtEisTdrQ6uQ/IEyYFgCfniiduesnPNDWgnko/xtFaTcO3WZ44A9FQwBKrHz/W7jaIBVWv4Y2a1gaVkGPD1WtcycT9tClGj9Kp5d2pGMLK/LEf5AthtXEMYQ+rQW992tGEW8u5nSySV3328KpIChOc5+geQLASlmoDzHcePO+2aI6S+H52JOABftNtG95UTQZepUfyUwEbEPevv7b1BJHn0A1/HeAyiBQ6Arv8DTg7WxLHOpD6aOdVyNVSEqwasd7YRgWhCz0lyZ2DDFymdx5gghN2qCO4L59MCkMzMjtF7eZTtu5IqgBGuZ8Xtf6eczCQWlUdY9E8yBwtcknVN9xL+zbtgR6QYlm9eotiRMXXkysNtxiHvO62kyiAMne3B1pS+1HUt+EcE4LPZQ6wtvom37HR6mb8PbZog1/1EHgisLWpg7wx6sbgm/deQUfG74rE4j+7cDbm1Z3MHfkBsZayRUH9IKHr3a5qECHT/Q8U3LGuRbE40PCQtd4qdAC1KDLILbAplXWPw1czikpbQ3x0cSbsc0yLzeOAOCw/hI2QWC21pcxWi25yVvmvWGNBpkV9bFv9UUa7LlaC5QQYOHlDJtahUp+1p61rjSTO786WRZ1lQJQm/N1ElXNx4Xt1QMLR/NS0Sp3qPIAPnn+m38S2Efztnqjc0lV+uMESRno7D8u00tAm3ePbKHlzV1Y60JBmbNTXYkO2/+oDWeb27NAa/TQt0uAt/a1iIyReERCdENSFH8jKRuwu+o6ZHCwN/QxlwCAvi3y1ts9LWQsRmgsvkvK9e3mP503h5enLgiRiP46zb4CJrM2e+nsofDvRnhHbBA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: eeecb7b3-7062-46bc-ed19-08d9e583faec 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:46.3880 (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: AM9PR03MB7962 Subject: [FFmpeg-devel] [PATCH v2 59/69] avcodec/mpegvideo: Add ptr to main MPVMainContext to slice 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: 8bHNfEoRbAGz It is a pointer to const to allow the slice threads to inspect values without modifying them. Signed-off-by: Andreas Rheinhardt --- I am unsure whether this should be a pointer to const void or a pointer to const MPVMainContext. libavcodec/mpegvideo.c | 3 +++ libavcodec/mpegvideo.h | 2 ++ libavcodec/mpegvideo_dec.c | 2 ++ 3 files changed, 7 insertions(+) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 220f1c39f0..4b22eb746a 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -396,6 +396,8 @@ int ff_mpv_init_duplicate_contexts(MPVMainContext *m) MPVContext *const s = &m->s; int nb_slices = s->slice_context_count, ret; + s->parent_ctx = m; + /* We initialize the copies before the original so that * fields allocated in init_duplicate_context are NULL after * copying. This prevents double-frees upon allocation error. */ @@ -524,6 +526,7 @@ void ff_mpv_common_defaults(MPVMainContext *m) s->b_code = 1; s->slice_context_count = 1; + s->parent_ctx = m; } int ff_mpv_init_context_frame(MPVMainContext *m) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 9005dcb58a..1c44e9be2f 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -76,6 +76,8 @@ typedef struct MPVContext { * offsets used in ASM. */ struct AVCodecContext *avctx; + /* A pointer to this context's parent MPVMainContext. */ + const struct MPVMainContext *parent_ctx; /* 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; diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c index f202db33e9..fd97e6ac1a 100644 --- a/libavcodec/mpegvideo_dec.c +++ b/libavcodec/mpegvideo_dec.c @@ -72,6 +72,7 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst, memcpy(s, s1, sizeof(*s)); s->avctx = dst; + s->parent_ctx = m; s->private_ctx = private_ctx; s->bitstream_buffer = NULL; s->bitstream_buffer_size = s->allocated_bitstream_buffer_size = 0; @@ -83,6 +84,7 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst, if ((err = ff_mpv_common_init(m)) < 0) { memset(s, 0, sizeof(*s)); s->avctx = dst; + s->parent_ctx = m; s->private_ctx = private_ctx; return err; } From patchwork Tue Feb 1 13:06:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34029 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp611870iov; Tue, 1 Feb 2022 05:21:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwXxNVW7ksCUZzwSb4KDfR2m9KVflYFZgBdUDcL3s8hlKHr1RUu8m+d+n423cYV2ww1Aznw X-Received: by 2002:a17:907:72c6:: with SMTP id du6mr21766620ejc.224.1643721710799; Tue, 01 Feb 2022 05:21: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 p17si8977917edx.495.2022.02.01.05.21.50; Tue, 01 Feb 2022 05:21: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=Pvv+r1Cl; 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 E98AF68B445; Tue, 1 Feb 2022 15:09:03 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2076.outbound.protection.outlook.com [40.92.91.76]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4D54F68B3E5 for ; Tue, 1 Feb 2022 15:08:50 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MEpM7wcnEc5eZh8SDWQYb7ffwXhJOY5Q+xGkI0mzFr2LnpM7D9FM0Ajb1YDEzyLPC4Vo12NceGNe6g42YohMqe5Omb8hpwVJt8OMLDLeYF6yfJeHRsAGaoV8KjeXk3zHWlXUYhDjxaweWgjSSauyySdVi+C2rWO3AzgPg4onEx+6iOkHpwtl0bScXKtRy/4/auogjHPdyVUM0RHuLgxvElsDrG4StypOGVUIAsavdljbjjagQJWjTHZo0UWVC5uWtx6E8B26sWtz3VUgG9iWKNEV2zDA1/UCHHYXHeRIzjhz7HPPa4PFqGk2WqzDGbrDv4ShYSUVaQugaamHSBEk8g== 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=jbdspMP6qUkCfj2j6a27v7eU2SZNoIzNVBtE4OYxoC4=; b=HPJEMjmtCwRbnLvpaD3czpjV2zPMHy5rYY+qduLrXTFRIckFr6AEn4gxnbv5dQX/jkj4u70yRnyuoO+LlqNOMQ8BjfD/GkvGDLDg5RiZp3xRlNdN0vLBO00lMWQ1c39AWa68XxOj0ktJHuaov3jsg3OEom/vdRo8X2dwSgvTqeXv1mOlLQf0NEQl7jzS+3dN5O/aLZ5R/nkSqV3WIeDHknDAG7xwBHAoqKooIdcILmuZNRPE149boCEprDmIhdr9AHTbasxF/RmxUaMJngl2sZVgjcnlpJOoGJ86Q9GOG7+ZD70Nt9aQNKC0VTlJogqTUxEFR8NlBQ4dHeyf6mgHZQ== 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=jbdspMP6qUkCfj2j6a27v7eU2SZNoIzNVBtE4OYxoC4=; b=Pvv+r1Cl19wtquNmwM4a2yyzNOe7vJNnXdlZvgUuVj7pkftUBFnwM4LfXfdvTf2aBoiEsig81AOIGvaIER8xABR9xTsIBVM+mSsA4Us/yx3UlXtPF5ouvr072mtD1hd8Fpq8Za8XpUWadEUQEu7Vsx6dCRrTIarBWoXQfZj6CV5m6KO+sNgCumODy35/8/I5lw5skMgMYyy2kmkIvt6i/8maFSpAHHu6Yw05WbmzWehN9Tm1+95sOJW7A1s5wUGpBtZGAiIpY+cqpwPI6t8nsjCq9XnbKi/Ww7mrVvw4+oeHl4JNI0P5FlvaT/8n2VS19vWJ9/XnI6qZfCQACqlcMg== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM9PR03MB7962.eurprd03.prod.outlook.com (2603:10a6:20b:439::17) 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: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:08:48 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:57 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [1KSEKsXxXR5opeUu93R12ZdJQbUl0TPT] 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-59-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eae15c4f-e9eb-488b-d834-08d9e583fc3a X-MS-TrafficTypeDiagnostic: AM9PR03MB7962:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5Q8uHVixix3k1UrTA7RhlElsMSfyaUZj7qOxs81etvLMYFK3nfTQO0yapk3CmiytfEnbbQe+ukPvHz5tcHf6sS+JtRn8h5K9XSrNKKB79ao036hpvF4ijLK9xy4jBuqAJQVH8OW4BsuUUlY//F7l0VV5G1/3Pk4nTxSz1c/86t0TbUnVosyayeSZnWj0o4W5bnloC4aT+r8OQHJ0MkHiWZJ1Y3YVqvCS3IOjQuNvXvVvVbq4/Cg3o4+1hDle/gjz9zq3tj+8qY/zp24b/Mq9HfTXUhJV5Lym8yZ67vW9jFNENh0HZIG+B9SqVVRPKNViF5w1MDrk4KUjYzhzZAbhlxlC6lx8Yryl8Hk+kjKYnwIjQuEd30oGiTvVvL4J6qDL8AK++pVhJIeib950DDSUA6n/pTDLgoH8Nso80BX0ohFpKPylio17cNsaSMavrSjgX1LNICjlzSpatlYLYIeqv/yEs5ZFyp7AP+i5Wy6wj7WRW2ejK2Cctg+kNVgrhkLaGs/fkWdCP5hx8tQw4UNK8V34f6cBnhvyh7xOVLGtNM0fzlR0rpYI0eEHWb46+H9q X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UAyNQWiY7ILqKN9hRQFqglzjm+UL7QHxTzeStUAocCzd0p45hDi59eTrrJQhQl+O/qOe+A7ky00hYq44mJ1fMHITp4S7O5j3p4JF9F2UZFTbbVCtHkSO+8y868RDJF6lXamDauOj826SuQ4vCB3CdAkHFGsUfXUC/WsbxkgH7WZt0mlT7M/ATG8PCfA5Qo/pevXjbKfVvE7daEL+54X3WlH89cPth9ufd36BakAfrsA56K01+Ql8hKsyPFaqUrRM9UCbUbpcIUk+3ViL4/u9Qo7uUt0rZ6hk6Gd88PYoVftVTDM0CGyLT5AMPb0lXhElhrR6MSKBPi010aLAg0URT5Qs/6wbVxvFy7bZncaLq7e26h1WXtkP1z/9FcbFvQycKixqkMYw2TpSX3xrCbGyEAE3Eb2dN7KeFtO1K+tLolDIone7Na7bZL5TXujotOuzKbBTmWMjcnbsKpNidw7KD/7TGUrR2tLGFoxNIyofR1ijoNK3/n5MeAkJKKAgpLu7z0q+Y9WWf1YDgn5MEC4jzJ43+U7hSy8TUehzkDQqIcikHF9lYoKTrXZ5mgWVc9hhQKGr+SEY8zdxmMt59iwzqnNEHeMbGWoyTX/vsXe3mYC5XyyOHLLobvoPnypOupM1rcal2RJkSK2TEYU/dj3pN2FIThQEhiqOvjouBV1ZQsyPrfva9MHT4uBtrizPCdjWKsNZgdNWlqqls5g77LYHjhMc+i8L+cC9FFd8OzrrtQJDtHHGstNH5aCYpo1RRkGmq/Jg+KLlLd8kpBpYOPnTTjATBFiH26JSEs1Au+bbHDlknadWLrjz3Z3MDVaIFQ1rTP/siQ16FIx7BtoMOxbk0qOYtiwZd8PQ6tmWWpRGxy1RAs7EIrIcazgpwA7DIB0P5S1VxOzmgH3Ha1ZFaYtvvRLeX9rdCYf6aCpkf8S40hBeNk/D3CtHZXYsyeeTd4Av4qioKS7sH/zMx+y8UCGYNg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: eae15c4f-e9eb-488b-d834-08d9e583fc3a 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:48.5921 (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: AM9PR03MB7962 Subject: [FFmpeg-devel] [PATCH v2 60/69] avcodec/mpegvideo: Move slice_context_count to MPVMainContext 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: 204R6htPJpvx Signed-off-by: Andreas Rheinhardt --- libavcodec/mjpegenc.c | 6 +++--- libavcodec/mpeg12dec.c | 4 ++-- libavcodec/mpeg4video_parser.c | 2 +- libavcodec/mpegvideo.c | 13 ++++++------- libavcodec/mpegvideo.h | 3 ++- libavcodec/mpegvideo_enc.c | 8 ++++---- libavcodec/vc1_parser.c | 2 +- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index 70636ffc91..bf6371768a 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -82,10 +82,10 @@ static void mjpeg_encode_picture_header(MPVMainEncContext *m) ff_mjpeg_encode_picture_header(s->avctx, &s->pb, s->mjpeg_ctx, &s->intra_scantable, 0, s->intra_matrix, s->chroma_intra_matrix, - s->slice_context_count > 1); + m2->slice_context_count > 1); s->esc_pos = put_bytes_count(&s->pb, 0); - for (int i = 1; i < s->slice_context_count; i++) + for (int i = 1; i < m2->slice_context_count; i++) m2->thread_context[i]->esc_pos = 0; } @@ -255,7 +255,7 @@ int ff_mjpeg_encode_stuffing(MPVEncContext *s) ff_mjpeg_escape_FF(pbc, s->esc_pos); - if (s->slice_context_count > 1 && mb_y < s->mb_height - 1) + if (s->parent_ctx->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); diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 925c72e8ff..69d0bb809b 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -2770,8 +2770,8 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture, (avctx->active_thread_type & FF_THREAD_SLICE) && !avctx->hwaccel) { int threshold = (s2->mb_height * s->slice_count + - s2->slice_context_count / 2) / - s2->slice_context_count; + m2->slice_context_count / 2) / + m2->slice_context_count; av_assert0(avctx->thread_count > 1); if (threshold <= mb_y) { MPVDecContext *const thread_context = m2->thread_context[s->slice_count]; diff --git a/libavcodec/mpeg4video_parser.c b/libavcodec/mpeg4video_parser.c index adc2409953..a7909d92ec 100644 --- a/libavcodec/mpeg4video_parser.c +++ b/libavcodec/mpeg4video_parser.c @@ -132,7 +132,7 @@ static av_cold int mpeg4video_parse_init(AVCodecParserContext *s) pc->first_picture = 1; pc->dec_ctx.m.s.quant_precision = 5; - pc->dec_ctx.m.s.slice_context_count = 1; + pc->dec_ctx.m.slice_context_count = 1; pc->dec_ctx.showed_packed_warning = 1; return 0; } diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 4b22eb746a..0e98680056 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -394,7 +394,7 @@ static int init_duplicate_context(MPVContext *s) int ff_mpv_init_duplicate_contexts(MPVMainContext *m) { MPVContext *const s = &m->s; - int nb_slices = s->slice_context_count, ret; + int nb_slices = m->slice_context_count, ret; s->parent_ctx = m; @@ -443,7 +443,7 @@ static void free_duplicate_contexts(MPVMainContext *m) { MPVContext *const s = &m->s; - for (int i = 1; i < s->slice_context_count; i++) { + for (int i = 1; i < m->slice_context_count; i++) { free_duplicate_context(m->thread_context[i]); av_freep(&m->thread_context[i]); } @@ -525,7 +525,7 @@ void ff_mpv_common_defaults(MPVMainContext *m) s->f_code = 1; s->b_code = 1; - s->slice_context_count = 1; + m->slice_context_count = 1; s->parent_ctx = m; } @@ -625,7 +625,6 @@ static void clear_context(MPVMainContext *m) memset(&s->current_picture, 0, sizeof(s->current_picture)); memset(&s->new_picture, 0, sizeof(s->new_picture)); - s->slice_context_count = 1; s->me.map = NULL; s->me.score_map = NULL; s->dct_error_sum = NULL; @@ -740,7 +739,7 @@ av_cold int ff_mpv_common_init(MPVMainContext *m) s->context_initialized = 1; m->thread_context[0] = s; - s->slice_context_count = nb_slices; + m->slice_context_count = nb_slices; // if (s->width && s->height) { ret = ff_mpv_init_duplicate_contexts(m); @@ -791,8 +790,8 @@ void ff_mpv_common_end(MPVMainContext *m) s = &m->s; ff_mpv_free_context_frame(m); - if (s->slice_context_count > 1) - s->slice_context_count = 1; + if (m->slice_context_count > 1) + m->slice_context_count = 1; #if FF_API_FLAG_TRUNCATED av_freep(&s->parse_context.buffer); diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 1c44e9be2f..4a03cde7fe 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -122,7 +122,6 @@ typedef struct MPVContext { 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) - int slice_context_count; ///< number of used thread_contexts /** * copy of the previous picture structure. @@ -507,6 +506,8 @@ typedef struct MPVContext { */ typedef struct MPVMainContext { MPVContext s; + + int slice_context_count; ///< number of used thread_contexts /* The first entry of this array points to the above MPVContext. */ MPVContext *thread_context[MAX_THREADS]; } MPVMainContext; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 735c9d322f..aef4de0fe6 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -885,7 +885,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) if ((CONFIG_H263P_ENCODER || CONFIG_RV20_ENCODER) && s->modified_quant) s->chroma_qscale_table = ff_h263_chroma_qscale_table; - if (s->slice_context_count > 1) { + if (m2->slice_context_count > 1) { s->rtp_mode = 1; if (avctx->codec_id == AV_CODEC_ID_H263P) @@ -1749,7 +1749,7 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, MPVMainContext *const m2 = &m->common; MPVEncContext *const s = &m2->s; int i, stuffing_count, ret; - int context_count = s->slice_context_count; + int context_count = m2->slice_context_count; s->vbv_ignore_qmax = 0; @@ -2795,7 +2795,7 @@ static void update_mb_info(MPVEncContext *s, int startcode) 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 + && s->parent_ctx->slice_context_count == 1 && s->pb.buf == s->avctx->internal->byte_buffer) { int lastgob_pos = s->ptr_lastgob - s->pb.buf; @@ -3561,7 +3561,7 @@ static int encode_picture(MPVMainEncContext *m, int picture_number) MPVEncContext *const s = &m2->s; int i, ret; int bits; - int context_count = s->slice_context_count; + int context_count = m2->slice_context_count; s->picture_number = picture_number; diff --git a/libavcodec/vc1_parser.c b/libavcodec/vc1_parser.c index b320826e5b..af5ff5028a 100644 --- a/libavcodec/vc1_parser.c +++ b/libavcodec/vc1_parser.c @@ -259,7 +259,7 @@ static int vc1_parse(AVCodecParserContext *s, static av_cold int vc1_parse_init(AVCodecParserContext *s) { VC1ParseContext *vpc = s->priv_data; - vpc->v.s.s.slice_context_count = 1; + vpc->v.s.slice_context_count = 1; vpc->v.first_pic_header_flag = 1; vpc->prev_start_code = 0; vpc->bytes_to_skip = 0; From patchwork Tue Feb 1 13:06:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34031 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp612282iov; Tue, 1 Feb 2022 05:22:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJztwp+np2xEiBhErwkNusZP7/dVVsxGu2YNCErIDMGrcdrPGbv3qh/JDZKxLxwm+g1n9tLe X-Received: by 2002:a17:907:7da7:: with SMTP id oz39mr14614539ejc.324.1643721747963; Tue, 01 Feb 2022 05:22: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 4si8975543ejl.73.2022.02.01.05.22.27; Tue, 01 Feb 2022 05:22: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=MBHOIVKf; 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 0912168B454; Tue, 1 Feb 2022 15:09:06 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2057.outbound.protection.outlook.com [40.92.91.57]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 42F3568B383 for ; Tue, 1 Feb 2022 15:08:51 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OOndWZoED972bHkwD43AKXQ0WNBE+2ooceMS4mKebkdKaOlNJGOfCID9JIZjVAF+hiVSZYUgkfkc2b43kYqQKu/db34ypEnPzrN+IRxRVn4Ih0klPUTMffmGEuhJ/nJjdeHw6xx0wWHLHyZsq5eCjymHSbFZKtCKky2Pu8r6iTAR9KaW5ZfBhU5wod+YKEh3xDYr+xtaoiTAa9auHJ48C+ye6jORiV48t43xjhMB0wOdrgCDKIjwn9H2rv07YFWenwPM8aWlM7hxKmvogoSymm9/DJ2um+QAjKa9hlijcIxvg3Osv0ArbulyntklE7Gqbm2w2gP7YffSkukPyUxYPA== 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=WPRYeS507bdalWf9Fledjr/JNi/rRnKmIPEQo/xXwcg=; b=niJP2Lu1OcZDJnvZj8rzCFn3IvKRot6l6acCfjfg4a/fCZSTnJo9/IqQ5q3CzA+0htVNALgXD8bT8zh9kGRy+WHgwE8JLy0dCcGGNnIoc3Isfllg4uxXccWUkMhZ1uWpMYkcUeKn0Z4NOpfXy1he+QNsD6ClSOtDrHukFfMKXLcakq2UI6S++dzB+7jpvoVySXwH2EqmoVo4SfDLWHZbCta1bq7jyWBPt2vUN33Uyptcu/f8MvAH1H+ASNu72+7jkKvtT+yiWBRxAMOi9Hcv4gv1tsGXcq5LuCzPtcHulHX+/wJTkf8gmGVuL2Xc3b2hqPTPc/Qg6C3pJ5/Nn10IJg== 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=WPRYeS507bdalWf9Fledjr/JNi/rRnKmIPEQo/xXwcg=; b=MBHOIVKfqBDhpfjlp3/qw6u1LSjagW96bUoHzEoWmzqBWkCPxVxSnK+AnzvMyX2Z3RlKVNEcMQqxAzYXq4OPfI7Q7Ji6ViY69KpPDrUhKSIkeTPCqbXHXDuErtj22c0IiWdvYoTnMtRmQjv1R6n6N6+/UdRIE0UQUw5IUXGa1AKRoQGcjRX9fp53c0/dC4ix5Oet8edmYe6vzYcKlBdT8qBgt7eurOT3BgnwVpxIlsUE7VX0bDwXdAabXPinIjBLeGyWKvRwmpN5pjQfFjQLqHnRsMpPMrldE9f+GsEY1qFOoVnImVXHr6Z0ztjrmj5Vs7NIQgB4K7sgaDM7OU6L7A== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM9PR03MB7962.eurprd03.prod.outlook.com (2603:10a6:20b:439::17) 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: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:08:50 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:58 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [mhPYKYSmnQQ1kiWwNrJ5NZhrLNvKy4EA] 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-60-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 120ac214-3845-4144-440c-08d9e583fd86 X-MS-TrafficTypeDiagnostic: AM9PR03MB7962:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 58twTGNODDT0k+xgZMKkMQvzqkVsFz706S2r6N8uotoAZx7M4E06k9JMK9Kw/92ueCTspseTBuKuizdUPnYC5Cv5HwYZzzEBDRSby+ND6BEXNNbZ+sOSNlAdgdWwg0aeuetIpb+dSYnKqfaDHzpRIHMf6JwSkMdinScc3CS2xax3/lGYlM/QGyaPEjINI0anJ1CUkbeOHtHNib0ewhPA+bYla0Wa2EU9rR5d1zTiIDKAfUUg2TIhHWaJewFwyp1dNUjSyNPHEScq5uCJXyy3hTHhyDWo1367kQgDIatnBgUOJP++AKHXQWKYrm4BalyhEvcLVHVeDUYvATxXr/S02CtcRrzKZkFz0F/fBIho2iSVDjwEljukt9iGujLdkUoGrtWdWfbyHSQXk0U5Bs/3jND1kVoNjOhqDeg1NcTkWBKB1av83v4PKNlOsxbmBGkftP2Dc1dYNUnw4ooiv18l2jTECLLwxiNskDfFi/MJ4vPKdAw8a3ocuZyEIi3EPSy89USQUjV2m9BzTzuhGfJtUA00XLvFIkWOztMwklaILxFLY1atcfNIkdtaTDYysuRr X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0r3qRgCWTqQ2qa/fDzXQp28wYwDYnFvdAdeD7qaDAVDiRLE5VW1mCmfHbLLGMMjcyjpH89mLqkstUUxZTj543DA37nIMz+DjE2FRaA/y06qiuxRPgBNGqtML2/becKfOEeWOEhAqX/dnEkJ8TsTockVH5BuNFud/VNALiKbdKl4j2oc8erKbz3LJj/X0JJ1YJVvfreNBIlQ6QLdgdyi4l4OIpHgnkDhkMsDHmREteiFJZLrItSgzTQg4NjaHGFuXyq2Dy/Pl3x8DBy3rQyY0YkEcMkV/MbCFh7ZBrW7n3cBptNI09VEbvtUFb5otiaIDY6KIJhivZMTwv1pwe199fZscxhBu8ea/NOc8xZUsQ96hgB34sfIlqf3U7K6aHBPP4BbU32E3Rz/+RuJaphlOinxZkpU9MVua2s9C2y+/MKPF+RVn2ECJJv9vta8p5ry3KrI9PKmquS4TR05uC8GWXVnaZr/TtVFwVp7hLuijSWqNcKGIULC5q0YiHX4FMycXQKd/zH3i3+47bEgJPV8Z74bOAfLF2GZey27l5WqodCdpoKXq+FP5bFdloAnKXGmIwc3xH7fvjGQ0NJaOHlftGGJ7lIY00jo2oIwaG1U73tEYS4ddKefLjdaj1wFlshi9TQ88GpIwIbYlzxTH65Lc8a6E6GIIynrikrXaZjQLZwnVhFAwZXPVnDa1t37RD9yE7zXOOBDWR/H/5xcy+x92QiZ3Wc/arWbjzbmkt3pvrlvcQV8e8J5HaPNMUZjnpPB2lCGTjMgE9B6j+3pL3yIwqu0QJIBB7QfRZeSK0WVcN190A8DmZeiWzPdj9A3DeP2Si7TcEzILh+3Mx6TYfYiqF9VhycaF7/TLgqUY7QFLhPRwaTTsslzupZJXcKSyriAiHGqLmJQP8QJk/Pn3abQC9fYWl2O2h5UbgCUWacbTBCb74BBrrc4Bg8vueoWAeAvPrpKoWRReMagDuJDT5CNniQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 120ac214-3845-4144-440c-08d9e583fd86 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:50.7953 (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: AM9PR03MB7962 Subject: [FFmpeg-devel] [PATCH v2 61/69] avcodec/mpegvideo: Move reordered_input_picture 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: SRSzezKJTZ00 Also avoid an allocation while at it. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpeg4videoenc.c | 8 +++--- libavcodec/mpegvideo.h | 1 - libavcodec/mpegvideo_enc.c | 51 +++++++++++++++++++------------------- libavcodec/mpegvideoenc.h | 2 ++ 4 files changed, 32 insertions(+), 30 deletions(-) diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index 7ad93f9e4c..07c82cc54d 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -632,6 +632,8 @@ void ff_mpeg4_encode_mb(MPVEncContext *s, int16_t block[6][64], if ((cbp | motion_x | motion_y | s->dquant) == 0 && s->mv_type == MV_TYPE_16X16) { + const MPVMainEncContext *const m = + (MPVMainEncContext *)s->parent_ctx; /* Check if the B-frames can skip it too, as we must skip it * if we skip here why didn't they just compress * the skip-mb bits instead of reusing them ?! */ @@ -648,9 +650,9 @@ void ff_mpeg4_encode_mb(MPVEncContext *s, int16_t block[6][64], s->mb_skipped = 1; for (i = 0; i < s->max_b_frames; i++) { + const Picture *const pic = m->reordered_input_picture[i + 1]; uint8_t *b_pic; int diff; - Picture *pic = s->reordered_input_picture[i + 1]; if (!pic || pic->f->pict_type != AV_PICTURE_TYPE_B) break; @@ -890,8 +892,8 @@ static void mpeg4_encode_gop_header(MPVMainEncContext *m) put_bits(&s->pb, 16, GOP_STARTCODE); time = s->current_picture_ptr->f->pts; - if (s->reordered_input_picture[1]) - time = FFMIN(time, s->reordered_input_picture[1]->f->pts); + if (m->reordered_input_picture[1]) + time = FFMIN(time, m->reordered_input_picture[1]->f->pts); time = time * s->avctx->time_base.num; s->last_time_base = FFUDIV(time, s->avctx->time_base.den); diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 4a03cde7fe..fefcb90188 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 **reordered_input_picture; ///< pointer to the next pictures in coded order for encoding /** bit output */ PutBitContext pb; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index aef4de0fe6..4a90799d17 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -871,8 +871,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) } } - if (!(avctx->stats_out = av_mallocz(256)) || - !FF_ALLOCZ_TYPED_ARRAY(s->reordered_input_picture, MAX_PICTURE_COUNT)) + if (!(avctx->stats_out = av_mallocz(256))) return AVERROR(ENOMEM); if (s->noise_reduction) { @@ -1017,7 +1016,6 @@ av_cold int ff_mpv_encode_end(AVCodecContext *avctx) av_freep(&m->cplx_tab); av_freep(&m->bits_tab); - av_freep(&s->reordered_input_picture); av_freep(&s->dct_offset); return 0; @@ -1438,11 +1436,11 @@ static int select_input_picture(MPVMainEncContext *m) int i, ret; for (i = 1; i < MAX_PICTURE_COUNT; i++) - s->reordered_input_picture[i - 1] = s->reordered_input_picture[i]; - s->reordered_input_picture[MAX_PICTURE_COUNT - 1] = NULL; + m->reordered_input_picture[i - 1] = m->reordered_input_picture[i]; + m->reordered_input_picture[MAX_PICTURE_COUNT - 1] = NULL; /* set next picture type & ordering */ - if (!s->reordered_input_picture[0] && m->input_picture[0]) { + if (!m->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 && @@ -1458,9 +1456,9 @@ 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] = 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 = + m->reordered_input_picture[0] = m->input_picture[0]; + m->reordered_input_picture[0]->f->pict_type = AV_PICTURE_TYPE_I; + m->reordered_input_picture[0]->f->coded_picture_number = s->coded_picture_number++; } else { int b_frames = 0; @@ -1543,16 +1541,16 @@ static int select_input_picture(MPVMainEncContext *m) m->input_picture[b_frames]->f->pict_type == AV_PICTURE_TYPE_I) 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 = + m->reordered_input_picture[0] = m->input_picture[b_frames]; + if (m->reordered_input_picture[0]->f->pict_type != AV_PICTURE_TYPE_I) + m->reordered_input_picture[0]->f->pict_type = AV_PICTURE_TYPE_P; + m->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] = m->input_picture[i]; - s->reordered_input_picture[i + 1]->f->pict_type = + m->reordered_input_picture[i + 1] = m->input_picture[i]; + m->reordered_input_picture[i + 1]->f->pict_type = AV_PICTURE_TYPE_B; - s->reordered_input_picture[i + 1]->f->coded_picture_number = + m->reordered_input_picture[i + 1]->f->coded_picture_number = s->coded_picture_number++; } } @@ -1560,15 +1558,16 @@ static int select_input_picture(MPVMainEncContext *m) no_output_pic: ff_mpeg_unref_picture(s->avctx, &s->new_picture); - if (s->reordered_input_picture[0]) { - s->reordered_input_picture[0]->reference = - s->reordered_input_picture[0]->f->pict_type != + if (m->reordered_input_picture[0]) { + m->reordered_input_picture[0]->reference = + m->reordered_input_picture[0]->f->pict_type != AV_PICTURE_TYPE_B ? 3 : 0; - if ((ret = ff_mpeg_ref_picture(s->avctx, &s->new_picture, s->reordered_input_picture[0]))) + if ((ret = ff_mpeg_ref_picture(s->avctx, &s->new_picture, + m->reordered_input_picture[0]))) return ret; - if (s->reordered_input_picture[0]->shared || s->avctx->rc_buffer_size) { + if (m->reordered_input_picture[0]->shared || s->avctx->rc_buffer_size) { // input is a shared pix, so we can't modify it -> allocate a new // one & ensure that the shared one is reuseable @@ -1578,23 +1577,23 @@ no_output_pic: return i; pic = &s->picture[i]; - pic->reference = s->reordered_input_picture[0]->reference; + pic->reference = m->reordered_input_picture[0]->reference; if (alloc_picture(s, pic, 0) < 0) { return -1; } - ret = av_frame_copy_props(pic->f, s->reordered_input_picture[0]->f); + ret = av_frame_copy_props(pic->f, m->reordered_input_picture[0]->f); if (ret < 0) return ret; /* mark us unused / free shared pic */ - av_frame_unref(s->reordered_input_picture[0]->f); - s->reordered_input_picture[0]->shared = 0; + av_frame_unref(m->reordered_input_picture[0]->f); + m->reordered_input_picture[0]->shared = 0; s->current_picture_ptr = pic; } else { // input is not a shared pix -> reuse buffer for current_pix - s->current_picture_ptr = s->reordered_input_picture[0]; + s->current_picture_ptr = m->reordered_input_picture[0]; for (i = 0; i < 4; i++) { if (s->new_picture.f->data[i]) s->new_picture.f->data[i] += INPLACE_OFFSET; diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index 6dc940d3aa..91d41f86e8 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -40,6 +40,8 @@ typedef struct MPVMainEncContext { MPVMainContext common; Picture *input_picture[MAX_PICTURE_COUNT]; ///< next pictures in display order + /** pointer to the next pictures in coded order */ + Picture *reordered_input_picture[MAX_PICTURE_COUNT]; int me_penalty_compensation; int me_pre; ///< prepass for motion estimation From patchwork Tue Feb 1 13:06: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: 34032 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp612454iov; Tue, 1 Feb 2022 05:22:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJwA08dXC6yzuXfqjw/mWhkkcNF9z9zCZ6wSxerti9G2GT2Kvii8tQtxZL4TTPhTPe+msUwP X-Received: by 2002:a17:907:3f99:: with SMTP id hr25mr20671891ejc.588.1643721762191; Tue, 01 Feb 2022 05:22: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 hz3si10390051ejc.575.2022.02.01.05.22.41; Tue, 01 Feb 2022 05:22: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=QOajouan; 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 E9DBF68B45A; Tue, 1 Feb 2022 15:09:06 +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-oln040092074058.outbound.protection.outlook.com [40.92.74.58]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 60FC768B402 for ; Tue, 1 Feb 2022 15:08:54 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rf5QdKJrPHDQ9l7yR2CbY5IF9wvBSx7eXtUetd6ZcmSlqyJbAsLkr5QSosZYKgtQbLuDkN0xEueDxL0c/RZFUlzhxfaPahoiYJyC8zPVbmLl0aKHV5zFSOTAJ7pTmv/IOXSTFJGKp4lHAB2GwB4bKqqIgrb9rH8vGAaqX20zTviIt30iAd/e3CppxCDRATRf7YKMShbXZHuzegrw+TR2PwZFZbF5S48EZKrf51nJYkCxB4YFfy83BihBYT5GnMRCPsXE/kPWqyOJ+IMLPPJDRpEEhdsjQx0yHPFKnxGWNw2rWBj6fLAIULiLpnpsilf3bYY3GTeS1HzM2pQ1zSJavA== 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=lQMwKQKKlmNmvoQdVI4h91heJ/GUpDqTykYWyZsQm0Q=; b=M3WftZubAHkTk2wi8S8vSv0A9xthHYlHsINrtRlQ4GXa+0jBgww1PnfId4We3Yb3x2Awcy3n75/VF0IcOQlSWaMMIyi267j0VlzuW9PggDRnz5RABO70dCIWr4iGcDg5sFSeEsI7/DjfpaoMMZNRFQ1uLOC8RPv289g8n9CpdoiLLbk+cAU6mnNXi/hNGOd4QdbedQoJEwxvtC3Juf9ixoNpxZ/zI8Mclmu6riILwrfsCis+4jQFoh5hU5ZZaA39WE0uU+NEM4U3DAVO5jUKw2fjAZK06T7qnWJ4RYzPGExguZ2x8px/X0xx5xpAxEuc3SqHh0A4SPcYBNGLXYGAWw== 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=lQMwKQKKlmNmvoQdVI4h91heJ/GUpDqTykYWyZsQm0Q=; b=QOajouan3Srv93hWCeW3j/CJ1YT0yaWFqZSQXch6aL5gVIzNnZNyqPRPtjTC6GThF3aeAJPh8ThbKnyCVdi0rwVV75MmK7Qdglc2/zGYyb2CYL0zPVdtXPI46dWf/mLrIhONEPW5vOqtbVDtzxVj8Ok7BKycptylffz2zZsv+RPfzXMpeImORinJaEruEVYAVco/YHxEUKgFGEQhwX7VxnxlBnJdYK+J+myY9iJSRrEgLlYOU3r15KHiiKL4frqZrZK2+DxmlT3E0Ls7nkfGqa9baOB+xgTFPGMIKM8GRC3tIwEbmDsXD447sfl4EXPHyeS5/uh3Y3j5NxBsmYp0GA== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR03MB5025.eurprd03.prod.outlook.com (2603:10a6:208:102::19) 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:52 +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:52 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:59 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [4iVcarNOoI4Px2lqJcQsLP0VY9ORV2OA] 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-61-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 351dc3cf-6de1-4f2c-12f3-08d9e583fe8f X-MS-TrafficTypeDiagnostic: AM0PR03MB5025:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8lGWWcH7ptr+lYxOzG6SE2eYYNCT+LsLDiUxdc1CozFN2anvzCzZsHw2ptaJyGUV6jxF/hokcG7oxTMLQjd/s7U0ke+39YO70opyWdEn/cl//cGNF7NC2ah9bQjuaMjEuVItrXBfkTPcGHGQ8QPGen+VZYXufYQm5Rir+hgoghUV8YHG9R6jgE/dETsyeFudQ3sE+D+CQ7U1xvAY6cJQNkfXL5jG1TF05tEDQg0+AcK38ALiUHJvwUi9kw/+xpeaRaZPczCu05tS2SFq1tOLMYlzBiaBBx1v3cru38Z0ZVfF4vjLq6jSwDdeF336EU2hSjQU8UDiMKtkrF94N5kZS/LqHkI3tI1L6SWeXfVXv+itFWlaVF28YtY8wux+r3xDFq+5aSmjfYUgjaxfw/CXQnL3BHRJ46AxWu6KLX3TlIA5gi1UXPaN7+2n9qnoenUv4HBBZjNJ+f5Och5J0RumXJlW9JoaV7Ws2zcl0LxDqhzwoN9tQkyiL9ajFGYmS/DOfYrBejPNb3JFsYjCdaoxZv1WcSbapTmwwJSMAOCxerA= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CDeqQgcRtZGLn6cTRR265b5Z+9sCIozG9oqiLkRZsULngYzoN5TdTFsNSe9KOYYUuyWoEpDAvwG7L3WBolE+Z6Lu2EiXpxDGFm8I+pVpTxOvzqIVBSiYNW4edXHqKHQc28Frzc6u+B1XrzBE4a5jF7jbltBIEioS1VLyVGB6IKbNkR+K3aK5r0QBkSCWc+ecXZydgZu1jynxg7YeF440VLmqjWCp5dQBUwv8xNRijxJvEndGVJsaoPHNuKzp9oTNps04v5r7uunFAPJA0Qr5r1sj2duboRbQGixV9IZ/ZQ+Vgt5wQrvyFfuuiTR4f//V2Q1LL3/qw76yaQGg9526V+yY7sySFF56oOrjc1HBKFkyZH+V0uvvJL70ohf1LymAbk3Nqfa/+zOQnSTigxzQFHOSJWHVd+NDz5PYsf6Idf07a6DuLzQdP+XyFFU+IxUnuMod5NP0ZmrZ8fzL8AA7iHBqIheQOmcY6GE+bRnQ8LFCKSEJqxqC58tUsbFcPZUDmrUyXcAHJA8I5J9UkBhpFbUnbOJB+5vSO6GFL7KKUs9IzyYGftM375HfoCRRQ8cYbu/2WCvZiEw5h9fcaWeCqD99U+92IwmjailU6prFGkNxa3DqYK1ujxhjFWLTDmSpuwhKI5/LyI2wRGIatZipaTYUYHz3QRM2wmE+mXiLkt9qhxGlVVQ+h1q3jA5i2ZxAH6u4sgXrkGaXQTz8eu89W9x7Jm4A2HuTt6UN9wu4LthAJ/MNqiqqcPwSAADhkC96hxeip1LUkF93nl4Xd2mpRyk4Mn1zlUymbmi5q1xTrV9BU4EvXBP9FyQnXSr+t88bW1HMDQxt+oKp/VXsIjAPJYvQVHidpI+OFr7aUvI7DQxuH8ikDs/xU5Dy4yW91UfTIimSbammOUA1yHiw6QV/iAypn8qu8wpobN7XcLsmKqy9wmM6hNk1je0bqJKqw36pwFCyLQotd5vgvyWFZvU6UA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 351dc3cf-6de1-4f2c-12f3-08d9e583fe8f 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:52.5307 (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: AM0PR03MB5025 Subject: [FFmpeg-devel] [PATCH v2 62/69] avcodec/mpegvideo: Move max_b_frames 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: nzKTIzVvpKCZ With the exception of VC-1-based decoders no decoder sets this, so move it to MPVMainEncContext and add a replacement field to VC1Context. Signed-off-by: Andreas Rheinhardt --- libavcodec/dxva2_vc1.c | 2 +- libavcodec/mpeg4videoenc.c | 8 ++++---- libavcodec/mpegvideo.h | 1 - libavcodec/mpegvideo_dec.c | 1 - libavcodec/mpegvideo_enc.c | 38 +++++++++++++++++++------------------- libavcodec/mpegvideoenc.h | 1 + libavcodec/mss2.c | 2 +- libavcodec/nvdec_vc1.c | 2 +- libavcodec/ratecontrol.c | 6 +++--- libavcodec/vc1.c | 4 ++-- libavcodec/vc1.h | 1 + libavcodec/vdpau_vc1.c | 2 +- 12 files changed, 34 insertions(+), 34 deletions(-) diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c index 836367ffe8..d901f023df 100644 --- a/libavcodec/dxva2_vc1.c +++ b/libavcodec/dxva2_vc1.c @@ -113,7 +113,7 @@ static void fill_picture_parameters(AVCodecContext *avctx, (v->multires << 5) | (v->resync_marker << 4) | (v->rangered << 3) | - (s->max_b_frames ); + (v->max_b_frames ); pp->bPicExtrapolation = (!v->interlace || v->fcm == PROGRESSIVE) ? 1 : 2; pp->bPicDeblocked = ((!pp->bPicBackwardPrediction && v->overlap) << 6) | ((v->profile != PROFILE_ADVANCED && v->rangeredfrm) << 5) | diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index 07c82cc54d..9bc6fb9388 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -637,7 +637,7 @@ void ff_mpeg4_encode_mb(MPVEncContext *s, int16_t block[6][64], /* Check if the B-frames can skip it too, as we must skip it * if we skip here why didn't they just compress * the skip-mb bits instead of reusing them ?! */ - if (s->max_b_frames > 0) { + if (m->max_b_frames > 0) { int i; int x, y, offset; uint8_t *p_pic; @@ -649,7 +649,7 @@ void ff_mpeg4_encode_mb(MPVEncContext *s, int16_t block[6][64], p_pic = s->new_picture.f->data[0] + offset; s->mb_skipped = 1; - for (i = 0; i < s->max_b_frames; i++) { + for (i = 0; i < m->max_b_frames; i++) { const Picture *const pic = m->reordered_input_picture[i + 1]; uint8_t *b_pic; int diff; @@ -921,7 +921,7 @@ static void mpeg4_encode_visual_object_header(MPVMainEncContext *m) if (s->avctx->profile != FF_PROFILE_UNKNOWN) { profile_and_level_indication = s->avctx->profile << 4; - } else if (s->max_b_frames || s->quarter_sample) { + } else if (m->max_b_frames || s->quarter_sample) { profile_and_level_indication = 0xF0; // adv simple } else { profile_and_level_indication = 0x00; // simple @@ -965,7 +965,7 @@ static void mpeg4_encode_vol_header(MPVMainEncContext *m, MPVEncContext *const s = &m->common.s; int vo_ver_id, vo_type, aspect_ratio_info; - if (s->max_b_frames || s->quarter_sample) { + if (m->max_b_frames || s->quarter_sample) { vo_ver_id = 5; vo_type = ADV_SIMPLE_VO_TYPE; } else { diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index fefcb90188..8632fadae5 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -95,7 +95,6 @@ typedef struct MPVContext { enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */ int encoding; ///< true if we are encoding (vs decoding) - int max_b_frames; ///< max number of B-frames for encoding int luma_elim_threshold; int chroma_elim_threshold; int strict_std_compliance; ///< strictly follow the std (MPEG-4, ...) diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c index fd97e6ac1a..57c93de621 100644 --- a/libavcodec/mpegvideo_dec.c +++ b/libavcodec/mpegvideo_dec.c @@ -151,7 +151,6 @@ do {\ (char *) &s1->last_time_base); // B-frame info - s->max_b_frames = s1->max_b_frames; s->low_delay = s1->low_delay; s->droppable = s1->droppable; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 4a90799d17..2fbcfd56e1 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -363,9 +363,9 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) "max b frames must be 0 or positive for mpegvideo based encoders\n"); return AVERROR(EINVAL); } - s->max_b_frames = avctx->max_b_frames; + m->max_b_frames = avctx->max_b_frames; s->codec_id = avctx->codec->id; - if (s->max_b_frames && !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) { + if (m->max_b_frames && !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) { av_log(avctx, AV_LOG_ERROR, "B-frames not supported by codec\n"); return AVERROR(EINVAL); } @@ -591,7 +591,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) "set strict_std_compliance to 'unofficial' or lower in order to allow it\n"); return AVERROR(EINVAL); } - if (s->max_b_frames != 0) { + if (m->max_b_frames != 0) { av_log(avctx, AV_LOG_ERROR, "B-frames cannot be used with low delay\n"); return AVERROR(EINVAL); @@ -658,12 +658,12 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) case AV_CODEC_ID_MPEG1VIDEO: s->out_format = FMT_MPEG1; s->low_delay = !!(avctx->flags & AV_CODEC_FLAG_LOW_DELAY); - avctx->delay = s->low_delay ? 0 : (s->max_b_frames + 1); + avctx->delay = s->low_delay ? 0 : (m->max_b_frames + 1); break; case AV_CODEC_ID_MPEG2VIDEO: s->out_format = FMT_MPEG1; s->low_delay = !!(avctx->flags & AV_CODEC_FLAG_LOW_DELAY); - avctx->delay = s->low_delay ? 0 : (s->max_b_frames + 1); + avctx->delay = s->low_delay ? 0 : (m->max_b_frames + 1); s->rtp_mode = 1; break; #if CONFIG_MJPEG_ENCODER || CONFIG_AMV_ENCODER @@ -759,8 +759,8 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) s->out_format = FMT_H263; s->h263_pred = 1; s->unrestricted_mv = 1; - s->low_delay = s->max_b_frames ? 0 : 1; - avctx->delay = s->low_delay ? 0 : (s->max_b_frames + 1); + s->low_delay = m->max_b_frames ? 0 : 1; + avctx->delay = s->low_delay ? 0 : (m->max_b_frames + 1); break; case AV_CODEC_ID_MSMPEG4V2: s->out_format = FMT_H263; @@ -957,7 +957,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) return ret; if (m->b_frame_strategy == 2) { - for (i = 0; i < s->max_b_frames + 2; i++) { + for (i = 0; i < m->max_b_frames + 2; i++) { m->tmp_frames[i] = av_frame_alloc(); if (!m->tmp_frames[i]) return AVERROR(ENOMEM); @@ -1073,7 +1073,7 @@ static int load_input_picture(MPVMainEncContext *m, const AVFrame *pic_arg) Picture *pic = NULL; int64_t pts; int i, display_picture_number = 0, ret; - int encoding_delay = s->max_b_frames ? s->max_b_frames + int encoding_delay = m->max_b_frames ? m->max_b_frames : (s->low_delay ? 0 : 1); int flush_offset = 1; int direct = 1; @@ -1310,7 +1310,7 @@ static int estimate_best_b_count(MPVMainEncContext *m) lambda2 = (b_lambda * b_lambda + (1 << FF_LAMBDA_SHIFT) / 2) >> FF_LAMBDA_SHIFT; - for (i = 0; i < s->max_b_frames + 2; i++) { + for (i = 0; i < m->max_b_frames + 2; i++) { Picture pre_input, *pre_input_ptr = i ? m->input_picture[i - 1] : s->next_picture_ptr; uint8_t *data[4]; @@ -1343,7 +1343,7 @@ static int estimate_best_b_count(MPVMainEncContext *m) } } - for (j = 0; j < s->max_b_frames + 1; j++) { + for (j = 0; j < m->max_b_frames + 1; j++) { AVCodecContext *c; int64_t rd = 0; @@ -1366,7 +1366,7 @@ static int estimate_best_b_count(MPVMainEncContext *m) c->me_sub_cmp = s->avctx->me_sub_cmp; c->pix_fmt = AV_PIX_FMT_YUV420P; c->time_base = s->avctx->time_base; - c->max_b_frames = s->max_b_frames; + c->max_b_frames = m->max_b_frames; ret = avcodec_open2(c, s->avctx->codec, NULL); if (ret < 0) @@ -1384,8 +1384,8 @@ static int estimate_best_b_count(MPVMainEncContext *m) //rd += (out_size * lambda2) >> FF_LAMBDA_SHIFT; - for (i = 0; i < s->max_b_frames + 1; i++) { - int is_p = i % (j + 1) == j || i == s->max_b_frames; + for (i = 0; i < m->max_b_frames + 1; i++) { + int is_p = i % (j + 1) == j || i == m->max_b_frames; m->tmp_frames[i + 1]->pict_type = is_p ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_B; @@ -1464,7 +1464,7 @@ static int select_input_picture(MPVMainEncContext *m) int b_frames = 0; if (s->avctx->flags & AV_CODEC_FLAG_PASS2) { - for (i = 0; i < s->max_b_frames + 1; i++) { + for (i = 0; i < m->max_b_frames + 1; i++) { int pict_num = m->input_picture[0]->f->display_picture_number + i; if (pict_num >= m->rc_context.num_entries) @@ -1480,11 +1480,11 @@ static int select_input_picture(MPVMainEncContext *m) } if (m->b_frame_strategy == 0) { - b_frames = s->max_b_frames; + b_frames = m->max_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++) { + for (i = 1; i < m->max_b_frames + 1; i++) { if (m->input_picture[i] && m->input_picture[i]->b_frame_score == 0) { m->input_picture[i]->b_frame_score = @@ -1494,7 +1494,7 @@ static int select_input_picture(MPVMainEncContext *m) s->linesize) + 1; } } - for (i = 0; i < s->max_b_frames + 1; i++) { + for (i = 0; i < m->max_b_frames + 1; i++) { if (!m->input_picture[i] || m->input_picture[i]->b_frame_score - 1 > s->mb_num / m->b_sensitivity) @@ -1521,7 +1521,7 @@ static int select_input_picture(MPVMainEncContext *m) b_frames = i; } if (m->input_picture[b_frames]->f->pict_type == AV_PICTURE_TYPE_B && - b_frames == s->max_b_frames) { + b_frames == m->max_b_frames) { av_log(s->avctx, AV_LOG_ERROR, "warning, too many B-frames in a row\n"); } diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index 91d41f86e8..ef9b92112c 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -99,6 +99,7 @@ typedef struct MPVMainEncContext { /* temporary frames used by b_frame_strategy == 2 */ AVFrame *tmp_frames[MPVENC_MAX_B_FRAMES + 2]; + int max_b_frames; ///< max number of B-frames int b_frame_strategy; int b_sensitivity; int brd_scale; diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c index 66ce266b51..f650a84e8d 100644 --- a/libavcodec/mss2.c +++ b/libavcodec/mss2.c @@ -783,7 +783,7 @@ static av_cold int wmv9_init(AVCodecContext *avctx) v->resync_marker = 0; v->rangered = 0; - v->s.s.max_b_frames = avctx->max_b_frames = 0; + v->max_b_frames = avctx->max_b_frames = 0; v->quantizer_mode = 0; v->finterpflag = 0; diff --git a/libavcodec/nvdec_vc1.c b/libavcodec/nvdec_vc1.c index afec5c1f7c..e8cae4d724 100644 --- a/libavcodec/nvdec_vc1.c +++ b/libavcodec/nvdec_vc1.c @@ -80,7 +80,7 @@ static int nvdec_vc1_start_frame(AVCodecContext *avctx, const uint8_t *buffer, u .multires = v->multires, .syncmarker = v->resync_marker, .rangered = v->rangered, - .maxbframes = s->max_b_frames, + .maxbframes = v->max_b_frames, .panscan_flag = v->panscanflag, .refdist_flag = v->refdist_flag, diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c index bdf5c82aa1..980f8c59f2 100644 --- a/libavcodec/ratecontrol.c +++ b/libavcodec/ratecontrol.c @@ -557,7 +557,7 @@ av_cold int ff_rate_control_init(MPVMainEncContext *m) p = s->avctx->stats_in; for (i = -1; p; i++) p = strchr(p + 1, ';'); - i += s->max_b_frames; + i += m->max_b_frames; if (i <= 0 || i >= INT_MAX / sizeof(RateControlEntry)) return -1; rcc->entry = av_mallocz(i * sizeof(RateControlEntry)); @@ -578,7 +578,7 @@ av_cold int ff_rate_control_init(MPVMainEncContext *m) /* read stats */ p = s->avctx->stats_in; - for (i = 0; i < rcc->num_entries - s->max_b_frames; i++) { + for (i = 0; i < rcc->num_entries - m->max_b_frames; i++) { RateControlEntry *rce; int picture_number; int e; @@ -636,7 +636,7 @@ av_cold int ff_rate_control_init(MPVMainEncContext *m) if (i % ((m->gop_size + 3) / 4) == 0) rce.pict_type = AV_PICTURE_TYPE_I; - else if (i % (s->max_b_frames + 1)) + else if (i % (m->max_b_frames + 1)) rce.pict_type = AV_PICTURE_TYPE_B; else rce.pict_type = AV_PICTURE_TYPE_P; diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c index d9061b1f74..13a211e916 100644 --- a/libavcodec/vc1.c +++ b/libavcodec/vc1.c @@ -359,7 +359,7 @@ int ff_vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitCo "RANGERED should be set to 0 in Simple Profile\n"); } - s->max_b_frames = avctx->max_b_frames = get_bits(gb, 3); //common + v->max_b_frames = avctx->max_b_frames = get_bits(gb, 3); //common v->quantizer_mode = get_bits(gb, 2); //common v->finterpflag = get_bits1(gb); //common @@ -441,7 +441,7 @@ static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb) av_log(s->avctx, AV_LOG_ERROR, "Progressive Segmented Frame mode: not supported (yet)\n"); return -1; } - s->max_b_frames = s->avctx->max_b_frames = 7; + v->max_b_frames = s->avctx->max_b_frames = 7; if (get_bits1(gb)) { //Display Info - decoding is not affected by it int w, h, ar = 0; av_log(s->avctx, AV_LOG_DEBUG, "Display extended info:\n"); diff --git a/libavcodec/vc1.h b/libavcodec/vc1.h index f203b28694..6aa1a32352 100644 --- a/libavcodec/vc1.h +++ b/libavcodec/vc1.h @@ -222,6 +222,7 @@ typedef struct VC1Context{ int dquant; ///< How qscale varies with MBs, 2 bits (not in Simple) int vstransform; ///< variable-size [48]x[48] transform type + info int overlap; ///< overlapped transforms in use + int max_b_frames; int quantizer_mode; ///< 2 bits, quantizer mode used for sequence, see QUANT_* int finterpflag; ///< INTERPFRM present //@} diff --git a/libavcodec/vdpau_vc1.c b/libavcodec/vdpau_vc1.c index f13b62f723..b91b158511 100644 --- a/libavcodec/vdpau_vc1.c +++ b/libavcodec/vdpau_vc1.c @@ -90,7 +90,7 @@ static int vdpau_vc1_start_frame(AVCodecContext *avctx, info->multires = v->multires; info->syncmarker = v->resync_marker; info->rangered = v->rangered | (v->rangeredfrm << 1); - info->maxbframes = v->s.s.max_b_frames; + info->maxbframes = v->max_b_frames; info->deblockEnable = v->postprocflag & 1; info->pquant = v->pq; From patchwork Tue Feb 1 13:07: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: 34039 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp614093iov; Tue, 1 Feb 2022 05:24:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJwn5Obr2EOOKJ/zUgCu4+pURG+ZMl/fX4eCaV+H2P2A3ZVnAnK0alEUAzaPu6Fq+kbM7Z/D X-Received: by 2002:a17:906:1e06:: with SMTP id g6mr20809163ejj.517.1643721892428; Tue, 01 Feb 2022 05:24:52 -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 n3si9610996edd.566.2022.02.01.05.24.51; Tue, 01 Feb 2022 05:24:52 -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=T9NluCnZ; 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 B558468B4B5; Tue, 1 Feb 2022 15:24:01 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-oln040092066070.outbound.protection.outlook.com [40.92.66.70]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 15E0C68B2EA for ; Tue, 1 Feb 2022 15:23:55 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aYuADXLgwmFSSv0GWaxobUX0PvM9Ho35j+xBWksMA2KmwP8Y6CgyO6NtJwpWZ6spzLJirLtlUM3Q7CjGw3fFBop+X89YBbkYbdwNRjfT4xm1U8vfEHqmqSPvO521/68nuIO06U1M0+ONFRTKNf7QOceCRRUGXqrDYvxrlKL2iQu0eJpOSeUutAKcgjpKwpPDP+XOJZQwnhfQsWMaQOmLBLaslVnEzFoU0ddbNCCg+P2yVJZjcndNfGG9z2lPXRl5e8HS8UhQVoNvdHus9Z0sYFGI/hmbEdfmwfD7VPZ6k0dULA3O0kJK2UMRmEdGtu/zO8Fwzyg/7H/oyaRvssCOlQ== 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=4aaie7ZmOHFzoDvtzhT+byOcLzu1eMfxYG31LzGjtHI=; b=MypsOuvAFtRjLt400Mj7gCi9owQYzPFurfEs1n65XPTtAPJ8JEnXABKIoJ2+jkePNz3pCRXyIcMlMBSFyAgLXe6kEyiXqBMoPPJ2Z2av632CdOYbC1/7cMwANMtExWpdv7t6oSswEPGKs+bifcNZXpe2nrIiyz7Nb0xRGh8/wx10PVbOaKG4o10lCbDwcL+7F/8nD+NLtpm1azcX7Jcbfq/yl6nJdnr4gFXbIDw6l84p6ztf6gX0q95B+baflwOaFswXR8HnxIceFvBhEbZLFB3IaLDdqXEFDsUoICNv+4BUoNAVx4vEv0FvYE2lvz5UlaByW3cXW6QjLGw1kTJZdA== 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=4aaie7ZmOHFzoDvtzhT+byOcLzu1eMfxYG31LzGjtHI=; b=T9NluCnZ4zMofYaq2wMNPU7FcCxls6XBSh9j9B0rKm0uTWcsfsZlM0iSDte50DpjSoao7E3gwrOaumDHeA2o/u3O6XcTPXd9/PCuppDqSkEPZatmkhjmbFmsiKZXiQNCJi1sX90xaSRWKMWzyaqr7vn52gCi9qx8xGe6yALA+YKT8mN1dxbw+3dADf7s/QAnXvQRF2a/QOjOVuD9jwTNEIPwClJSkXgxaHV3xCj5KlfMHln+pS/AG20tvDwfqTYTbywHUnI4beTm5WesvitSK/iCfQKBoRTbiSSwjQEPcVdvctFA9PWSgdLM12NwEYpdz70ZBmXc+wm5PdkL4HWGvQ== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR03MB5025.eurprd03.prod.outlook.com (2603:10a6:208:102::19) 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: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:08:53 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:07:00 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [lJogryWbNgQzhXWF3oPjtLzOzDsVTqFM] 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-62-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 72a5a1e1-049f-4305-5295-08d9e583ff57 X-MS-TrafficTypeDiagnostic: AM0PR03MB5025:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: raOh/3o9bSkK0umiAr9PUs+vdJk2cRHRE/azzYoRL4m40WVX3ZLG3z2SAjOSwazHLbWyrxY8SLS1ooLC6YR7vsFsZ4ujiDqXvM1NGGpzfqOgMKeIAINQcpbhQb59qj8lFI/lPHud3aWAVwt3YDfJtHH9Mqm644Uxl+YHtPuDGuPJwI5YVrSTbMdHckU9AtwI781jEWMAY90tpzmVJah+NI/EqKYk8doFVm4tUp+s0yy+8/F5DqzGMPXuO5xvC531fWkN/pIVk3ABS0+MiZRSs1ZgV/3ai/OHcPjnpCmMLce6+ksflbKMOAPWUC9Uotggi38R29ZcxfLczOJnPy2dzqmVTUoy1RhXHLUtFfSHJF17SmD2j9kjLKYwucXn8jwrGmo6N3PxQKLVbfsNZvAvSzRl9VDgV+RnPHSysXIbPak6JV9yjnPB0Txe6arj5zFScEv3AEZAz667uelXi+dozCBaMf7xjQt0H8n9NgD4nmrePJg6srM2V7WrxoQVyIGkagibPfRMJdduIMD7s/LdCamz7bdSAVfO8r6k8/JfwtGK3FawoP2DVHK5qYDhANiI X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fjYwkbYINKiGVglmxv++z26MrkLMdxUIvp7U/nwW/EVPFjPFSAtOGjeNSuKrmp7tH7MZCSwF2pV9SEcuvcMj8P8pJ85VP1i75m3TUGjuz7fSjnpxnRX0SMykz88ySyWrZ5cDOgj3TxFhK1BFkZ4kyHMmHH4eYE0wrRBLRSz3enZE+8xHF+2jFrsJ9koHXZq4/oqfunJt56dbW525ULM9ggl3KSQpxlWb5CqWx3K8q/aES4XcMfJrqMJLIvqQXwsm0N+BmI7lg8a8jt29R08wjvUhFAj7dK1xQ/IMD5sgtggWPVYIzHUMzqHm2Q1kkrqJUxgscjK/Emrz0ZIzWWYlJDcOS9WM/gbin10Qxg/3DV2paLW2sc9txSRepiQodmdy38rYEmGi1EHL7hAORRChaOVSoiecR1gcb5mIKQ7Tmm5yEkrdXeddoT8IhHZfYAPzV3gl1JQwkkaOuKasqMbonOr5JL/WdbwyPgNedJrP22Z/9wNbmEYEen7yObnAfy2gi0PYQL6XpAd4Z4RAGwJ95O8EHBCYHvk/re08ThRFoh7e6Ntsf2EBxS2LRTq9SglwKk1KXjmX73/SINC1yVorOUB8OyAab6h58euteOYtvrJAj/31UdSYGKrXK9t8SXEeKhdRL7qZ3c9yZ0bPcRUfLmJKBaXlcnxkKElxRm/2Rk6sx31BICxcbNwRVW84uaxP6qpws9rbM7sXInV7iF5xGfmegJgmhpUMSInbUR8aXXufPmmGDK9ScrlbirDE2XOaIdG6zhWOpt6O7ATOH4rlpwAsMQy3bVkj641trEZcASZHbn5m0vmgDjZ0PzYUM5LcVk8zUvkz+2WcuROiHe+nVu8PofrfYYePefT8smcxmKkvy1j8FbNzcCqJSMJ/z1Um05rJUmX6VL5O4h0x93uJ01PN2x4AeRFwErnmjMflSqfUkhzhs6SvxI7yDax3eN4ACkQIkKOhu38siDJwtxFGaQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72a5a1e1-049f-4305-5295-08d9e583ff57 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:53.7975 (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: AM0PR03MB5025 Subject: [FFmpeg-devel] [PATCH v2 63/69] avcodec/mpegvideo: Move context_initialized flag to MPVMainContext 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: Nc1PZfYhfchP This is not a per-slice property. Also move context_reinit. Signed-off-by: Andreas Rheinhardt --- libavcodec/h261dec.c | 2 +- libavcodec/h263dec.c | 8 ++++---- libavcodec/mpeg12dec.c | 2 +- libavcodec/mpeg4videodec.c | 8 ++++---- libavcodec/mpegvideo.c | 6 +++--- libavcodec/mpegvideo.h | 10 +++++----- libavcodec/mpegvideo_dec.c | 12 ++++++------ libavcodec/rv10.c | 2 +- libavcodec/rv34.c | 14 +++++++------- libavcodec/vc1dec.c | 4 ++-- 10 files changed, 34 insertions(+), 34 deletions(-) diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c index 8113d2ff7d..8774f4e7ad 100644 --- a/libavcodec/h261dec.c +++ b/libavcodec/h261dec.c @@ -625,7 +625,7 @@ retry: ff_mpv_common_end(m); } - if (!s->context_initialized) { + if (!m->context_initialized) { if ((ret = ff_mpv_common_init(m)) < 0) return ret; diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index 20a1348d88..b502878a4a 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -498,7 +498,7 @@ retry: if (ret < 0) return ret; - if (!s->context_initialized) + if (!m->context_initialized) // we need the idct permutation for reading a custom matrix ff_mpv_idct_init(s); @@ -540,7 +540,7 @@ retry: return ret; } - if (!s->context_initialized) { + if (!m->context_initialized) { avctx->pix_fmt = h263_get_format(avctx); if ((ret = ff_mpv_common_init(m)) < 0) return ret; @@ -568,9 +568,9 @@ retry: * an H263EncContext */ if (s->width != avctx->coded_width || s->height != avctx->coded_height || - s->context_reinit) { + m->context_reinit) { /* H.263 could change picture size any time */ - s->context_reinit = 0; + m->context_reinit = 0; ret = ff_set_dimensions(avctx, s->width, s->height); if (ret < 0) diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 69d0bb809b..3b21b88337 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -1087,7 +1087,7 @@ static int mpeg_decode_update_thread_context(AVCodecContext *avctx, if (avctx == avctx_from || !ctx_from->mpeg_ctx_allocated || - !s1->s.context_initialized) + !s1->context_initialized) return 0; err = ff_mpeg_update_thread_context(avctx, avctx_from); diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 6e3981b523..ca6988fc48 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -2324,7 +2324,7 @@ static int decode_studio_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) return AVERROR_PATCHWELCOME; } if (rgb != ctx->rgb || s->chroma_format != chroma_format) - s->context_reinit = 1; + m->context_reinit = 1; s->avctx->bits_per_raw_sample = bits_per_raw_sample; ctx->rgb = rgb; s->chroma_format = chroma_format; @@ -2340,7 +2340,7 @@ static int decode_studio_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) if (width && height) { if (s->width && s->height && (s->width != width || s->height != height)) - s->context_reinit = 1; + m->context_reinit = 1; s->width = width; s->height = height; } @@ -2489,7 +2489,7 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) !(s->width && s->codec_tag == AV_RL32("MP4S"))) { if (s->width && s->height && (s->width != width || s->height != height)) - s->context_reinit = 1; + m->context_reinit = 1; s->width = width; s->height = height; } @@ -3527,7 +3527,7 @@ static int mpeg4_update_thread_context(AVCodecContext *dst, { Mpeg4DecContext *s = dst->priv_data; const Mpeg4DecContext *s1 = src->priv_data; - int init = s->m.s.context_initialized; + int init = s->m.context_initialized; int ret = ff_mpeg_update_thread_context(dst, src); diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 0e98680056..be18b428f5 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -737,7 +737,7 @@ av_cold int ff_mpv_common_init(MPVMainContext *m) s->parse_context.state = -1; #endif - s->context_initialized = 1; + m->context_initialized = 1; m->thread_context[0] = s; m->slice_context_count = nb_slices; @@ -814,8 +814,8 @@ void ff_mpv_common_end(MPVMainContext *m) ff_mpv_picture_free(s->avctx, &s->next_picture); ff_mpv_picture_free(s->avctx, &s->new_picture); - s->context_initialized = 0; - s->context_reinit = 0; + m->context_initialized = 0; + m->context_reinit = 0; s->last_picture_ptr = s->next_picture_ptr = s->current_picture_ptr = NULL; diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 8632fadae5..df5a51577a 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -103,7 +103,6 @@ typedef struct MPVContext { /* the following fields are managed internally by the encoder */ /* sequence parameters */ - int context_initialized; 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 mb_width, mb_height; ///< number of MBs horizontally & vertically @@ -460,10 +459,6 @@ typedef struct MPVContext { int vbv_ignore_qmax; - /* flag to indicate a reinitialization is required, e.g. after - * a frame size change */ - int context_reinit; - ERContext er; int error_rate; @@ -505,6 +500,11 @@ typedef struct MPVContext { typedef struct MPVMainContext { MPVContext s; + int context_initialized; + /* flag to indicate a reinitialization is required, e.g. after + * a frame size change */ + int context_reinit; + int slice_context_count; ///< number of used thread_contexts /* The first entry of this array points to the above MPVContext. */ MPVContext *thread_context[MAX_THREADS]; diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c index 57c93de621..a4f751af71 100644 --- a/libavcodec/mpegvideo_dec.c +++ b/libavcodec/mpegvideo_dec.c @@ -66,7 +66,7 @@ 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) { + if (!m->context_initialized) { void *private_ctx = s->private_ctx; int err; memcpy(s, s1, sizeof(*s)); @@ -77,7 +77,7 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst, s->bitstream_buffer = NULL; s->bitstream_buffer_size = s->allocated_bitstream_buffer_size = 0; - if (s1->context_initialized) { + if (m1->context_initialized) { // s->picture_range_start += MAX_PICTURE_COUNT; // s->picture_range_end += MAX_PICTURE_COUNT; ff_mpv_idct_init(s); @@ -91,7 +91,7 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst, } } - if (s->height != s1->height || s->width != s1->width || s->context_reinit) { + if (s->height != s1->height || s->width != s1->width || m->context_reinit) { s->height = s1->height; s->width = s1->width; if ((ret = ff_mpv_common_frame_size_change(m)) < 0) @@ -202,7 +202,7 @@ int ff_mpv_common_frame_size_change(MPVMainDecContext *m) MPVDecContext *const s = &m->s; int err = 0; - if (!s->context_initialized) + if (!m2->context_initialized) return AVERROR(EINVAL); ff_mpv_free_context_frame(m2); @@ -243,12 +243,12 @@ int ff_mpv_common_frame_size_change(MPVMainDecContext *m) if (err < 0) goto fail; } - s->context_reinit = 0; + m2->context_reinit = 0; return 0; fail: ff_mpv_free_context_frame(m2); - s->context_reinit = 1; + m2->context_reinit = 1; return err; } diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c index 1a59b2a578..27e17c8677 100644 --- a/libavcodec/rv10.c +++ b/libavcodec/rv10.c @@ -228,7 +228,7 @@ static int rv20_decode_picture_header(RVDecContext *rv, int whole_size) new_w = rv->orig_width; new_h = rv->orig_height; } - if (new_w != s->width || new_h != s->height || !s->context_initialized) { + if (new_w != s->width || new_h != s->height || !m->context_initialized) { AVRational old_aspect = s->avctx->sample_aspect_ratio; av_log(s->avctx, AV_LOG_DEBUG, "attempting to change resolution to %dx%d\n", new_w, new_h); diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index a3437099b2..4ed23b65dd 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -1384,7 +1384,7 @@ static int rv34_decoder_alloc(RV34DecContext *r) if (!(r->cbp_chroma && r->cbp_luma && r->deblock_coefs && r->intra_types_hist && r->mb_type)) { - r->s.s.context_reinit = 1; + r->s.context_reinit = 1; rv34_decoder_free(r); return AVERROR(ENOMEM); } @@ -1524,10 +1524,10 @@ int ff_rv34_decode_update_thread_context(AVCodecContext *dst, const AVCodecConte const MPVDecContext *const s1 = &m1->s; int err; - if (dst == src || !s1->context_initialized) + if (dst == src || !m1->context_initialized) return 0; - if (s->height != s1->height || s->width != s1->width || s->context_reinit) { + if (s->height != s1->height || s->width != s1->width || m->context_reinit) { s->height = s1->height; s->width = s1->width; if ((err = ff_mpv_common_frame_size_change(m)) < 0) @@ -1544,7 +1544,7 @@ int ff_rv34_decode_update_thread_context(AVCodecContext *dst, const AVCodecConte // Do no call ff_mpeg_update_thread_context on a partially initialized // decoder context. - if (!s1->context_initialized) + if (!m1->context_initialized) return 0; return ff_mpeg_update_thread_context(dst, src); @@ -1666,12 +1666,12 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, if (s->mb_num_left > 0 && s->current_picture_ptr) { av_log(avctx, AV_LOG_ERROR, "New frame but still %d MB left.\n", s->mb_num_left); - if (!s->context_reinit) + if (!m->context_reinit) ff_er_frame_end(&s->er); ff_mpv_frame_end(m); } - if (s->width != si.width || s->height != si.height || s->context_reinit) { + if (s->width != si.width || s->height != si.height || m->context_reinit) { int err; av_log(s->avctx, AV_LOG_WARNING, "Changing dimensions to %dx%d\n", @@ -1743,7 +1743,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, } s->mb_x = s->mb_y = 0; ff_thread_finish_setup(s->avctx); - } else if (s->context_reinit) { + } else if (m->context_reinit) { av_log(s->avctx, AV_LOG_ERROR, "Decoder needs full frames to " "reinitialize (start MB is %d).\n", si.start); return AVERROR_INVALIDDATA; diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index 502ea2bae4..995761700b 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -797,13 +797,13 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, } } - if (s->context_initialized && + if (m->context_initialized && (s->width != avctx->coded_width || s->height != avctx->coded_height)) { ff_vc1_decode_end(avctx); } - if (!s->context_initialized) { + if (!m->context_initialized) { if ((ret = ff_msmpeg4_decode_init(avctx)) < 0) goto err; if ((ret = ff_vc1_decode_init_alloc_tables(v)) < 0) { From patchwork Tue Feb 1 13:07: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: 34033 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp612598iov; Tue, 1 Feb 2022 05:22:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6i/RquErB+cVmOwjLFdxSmu6PR2/CccRg3Ib9cSPJykfpCaIK2YJ+RyiE6LKAWB/eQeXr X-Received: by 2002:a17:907:3e1d:: with SMTP id hp29mr20717861ejc.701.1643721776460; Tue, 01 Feb 2022 05:22:56 -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 dp15si7021443ejc.414.2022.02.01.05.22.55; Tue, 01 Feb 2022 05:22:56 -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=Xwiua2sJ; 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 D48C968B3D2; Tue, 1 Feb 2022 15:09:27 +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-oln040092074106.outbound.protection.outlook.com [40.92.74.106]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9A6D368B2C4 for ; Tue, 1 Feb 2022 15:09:26 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HCcc+TmD+xV81jTvZUo+e07PDqOUdFLZWHWPjdw95kk/FWcwv++PHMX85mCtq4C3/X5xThnqhnYOB7HUpE87+NkeBOR/CLGr6VEOEXaY+MYTl3iI5tkK8QuDWnbH/lQnt7li+/NDHyz0u0kwLwbd4CCKYA4TEbsnZR3R2teTaU3W95bIwdSZZrRbRuBtZ2Iqd/g/YMpePx7SipWHsE+GgKeYKu353YWydxjY0ImA9S/WCCKCNsQoevjbb28Q/MZFO5oVz1rAkBJ5g5AV49dgjhQ22TooO9UOPvmyMbOipTAhZnpHS6GGjRMtFnOmQj4UkRmBgXpCF75p0dZzcxYNdA== 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=G0LEqgRcZMHFrsVzGmK9tJfumv6D1kG4FjII/05DqVI=; b=M9YPEU6q5c7iVwjZplhIGLwtpXr3JxuLGC7fbOv0RVPelsLLR6dbrQGMYdZhxG95HdUDrWzIC8tGJm8728caML1uSWqh27tmWPrCi62+ogD5qU9DEbbqiMlZl0lxQYK4XmM3b8TzPwyhwOF9o4L2uQH06aFrLtH3Z1nP1xnRbNocFHYrcy5gTheWuioiBMAH5o6hRocAJ5iPlCoS75hdWlibqU6cFMERapWcm95baIq752yHUwSGKhZRmj04qhU9kFk9AY2IJ/HeJGKkD+F7cx8twQOypqEJiEINiZF4TSk2m22TNdrVhRAlkOdjW467eSwx0iO0+Sb51x/RXL3mNg== 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=G0LEqgRcZMHFrsVzGmK9tJfumv6D1kG4FjII/05DqVI=; b=Xwiua2sJrOhK8SKC7K+ho9JTnsVtMJaqu3sVhSvKGNnKoOiinFKJOn3f0lCF7+ZFX3CBDl88+0fGrtXBpsK4HVYwIbuEE5goMxo4HMw5pP+GUOM7vqYyKHuIwHcn5f2Gl3LqfRBfBj2Fcdz4Ykyv7dhEnpg5O0RgGo3aJNbV1cSIXH0x0cNB289DOhgSt1tWh7zQayFITNcbo/0od1g93DOwc3lFISduP+NJqGwElVDZsdcQ5dSrAqZVQlgVVs5o5w/VjTNaF1nWjJX3TxKZRyJr8mHrqdjPC/SRsfQIDVZEJ27g42U2QRAg7+83yN0cRcdQQiXmcnDaLOz/pfkNZw== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR03MB5025.eurprd03.prod.outlook.com (2603:10a6:208:102::19) 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:09:25 +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:09:25 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:07:01 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [MPFqIfTDw5OFXCKCl6J/Wt/i975g42yE] 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-63-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cc454e32-ff0d-48c4-ae5e-08d9e584000c X-MS-TrafficTypeDiagnostic: AM0PR03MB5025:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 935bDZ1z2qCkFSXEVv2756sQdyc4AzTgAWvsNJ88DubDJi0TxucVO05SdQ5xB2Ozox4Po6OUyBF9UMqCGicyp1iuUfx+6n3G9phDs84Y8yCtILJiPzP5aS49QVB48NF/5kW2hModxffKCUBxRIM9rLAgfX7AIHdD+K0jpnLoxywFQI0VYHHE5jTGYKrTydoWyIxv5vyK8A5kUrDgQPH/E3BNuytxBonYNprkLhspe+8LtHeO424DG3lEGtDI+70OQMoV833A3D2B3bn7VoVrytQySNQf4uPweDSAJwRuhEoMLQf6GjzHCypR3aLC2apLVuObsoIB2PUuvbuM5wEcULgfPtd0xhgKASjJcfkjjT6SO/01H+p6JEy8+mNhwnRx5t+oT8GFRd22ZB6s6P7WoBfIftnuCym1Zde2exfA9D3yUdhFJRtpdc/BD7NaJoqQivVOdq6ZIFOVL/4WBKtTc88oXB1LKTIuO6z8utPjGWzF6DtKWojTDiYaEXNsQewR+7Ztlg1V/AqZ0AZDx702loGgRAgqWZdTRXwNNui2r5Nhq54lX2fqbdcshYw1ng6o X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WICe908eeEfucrgCKeMV2BQMFzhw9AixjpnW9DyC4dGikIr8Xp1r41iApHQIAaBFkHwdzYqcgOV4dJnKbJU3eQIrdxmaQZeUxZYe0alCAbBHin4pdERvREPZhyJ2x/H1i0FLAiHTt44RRvGDx/FbEaXVQYmaHAge1caKXe6sQjRGQ2+Y4utj2JnLPAaxBpp3ibQUF5F+R+XSioxrVGF8M+U/JoDxdOx7DVh9rTt2OM2LRJFyXG7rcGWE/TdDURy2HCz62swMT2+Vs4AX48m3xr+Qk/4fUSq/zkkBV57/3FND6/GbJa7+3gVn+3acyLLBa3f27lKiS07Qi0WaHJf9uC3tUuRsNeq5cDKq3EE6GqAK50knzifnWb5eEn4OugIjog/CoI3qk7vLKuIssBVurrOnIQbO97NdQFMNVY+1OgYYRz53wLM8mD+Kl/OrZDE0Zb/uypwP8wL5u0hrTGiNS0uYAz0SwR7QV7kTjCf6ZT1KdZxhySYq/ighaTLCHNGBv0sqUrR7T9/2xhdigx50ZbJ02MMiiqBxYPwFyIYbzk6o+IYH1cYVN5bBhTrEVP8MKQk1ZF0Op8PM0X3NjboYtT1LCQP4p7uR10stsUxDK18p36/v/0C+nJLw4AXdaWRN8nd0i+nmHv58vnLYzwVWSR6zrniLmd57LkkZCo78BpxCm6GyHjnhtSveF9fE/okCyqyyzwRiG927cdbzBb6aOLhl8Xnq+eVrIs2W7MHBWKNZakgd846ki8hB5zTrKmrtOlN9qpkKm/nDiyNlRAHMMiOCDR6Xi20ga/QeDlGK+M8BausuIdKTXgZIc1NZig40YaF3/E+xQdb+ix6oLAFT3bVnRHjwOFjOYQ0tImVNXw1otxZae/fw3mumnZCREz2U3EB8dlVsdar1UZRbkNBTf3Cz1dk8SXAgEVu8vFWFaJvntueoIs2skJzyTN0+MfElQ2Tzm5IsW/0fYRGQHBJPAA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc454e32-ff0d-48c4-ae5e-08d9e584000c 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:54.9848 (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: AM0PR03MB5025 Subject: [FFmpeg-devel] [PATCH v2 64/69] avcodec/mpegvideo: Move coded_picture_number to MPVMainContext 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: XK5tdkYqlRmo It is not used by slice threads at all. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo.c | 2 +- libavcodec/mpegvideo.h | 3 ++- libavcodec/mpegvideo_dec.c | 4 ++-- libavcodec/mpegvideo_enc.c | 6 +++--- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index be18b428f5..8debf4d6ab 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -519,7 +519,7 @@ void ff_mpv_common_defaults(MPVMainContext *m) s->progressive_sequence = 1; s->picture_structure = PICT_FRAME; - s->coded_picture_number = 0; + m->coded_picture_number = 0; s->picture_number = 0; s->f_code = 1; diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index df5a51577a..99d474991a 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -103,7 +103,6 @@ typedef struct MPVContext { /* the following fields are managed internally by the encoder */ /* sequence parameters */ - 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 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 @@ -505,6 +504,8 @@ typedef struct MPVMainContext { * a frame size change */ int context_reinit; + int coded_picture_number; ///< used to set pic->coded_picture_number, should not be used for/by anything else + int slice_context_count; ///< number of used thread_contexts /* The first entry of this array points to the above MPVContext. */ MPVContext *thread_context[MAX_THREADS]; diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c index a4f751af71..48371aa886 100644 --- a/libavcodec/mpegvideo_dec.c +++ b/libavcodec/mpegvideo_dec.c @@ -105,7 +105,7 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst, s->quarter_sample = s1->quarter_sample; - s->coded_picture_number = s1->coded_picture_number; + m->coded_picture_number = m1->coded_picture_number; s->picture_number = s1->picture_number; av_assert0(!s->picture || s->picture != s1->picture); @@ -339,7 +339,7 @@ int ff_mpv_frame_start(MPVMainDecContext *m, AVCodecContext *avctx) pic->reference = 3; } - pic->f->coded_picture_number = s->coded_picture_number++; + pic->f->coded_picture_number = m->coded_picture_number++; if (alloc_picture(s, pic) < 0) return -1; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 2fbcfd56e1..3e9f8b4e42 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -1459,7 +1459,7 @@ static int select_input_picture(MPVMainEncContext *m) m->reordered_input_picture[0] = m->input_picture[0]; m->reordered_input_picture[0]->f->pict_type = AV_PICTURE_TYPE_I; m->reordered_input_picture[0]->f->coded_picture_number = - s->coded_picture_number++; + m2->coded_picture_number++; } else { int b_frames = 0; @@ -1545,13 +1545,13 @@ static int select_input_picture(MPVMainEncContext *m) if (m->reordered_input_picture[0]->f->pict_type != AV_PICTURE_TYPE_I) m->reordered_input_picture[0]->f->pict_type = AV_PICTURE_TYPE_P; m->reordered_input_picture[0]->f->coded_picture_number = - s->coded_picture_number++; + m2->coded_picture_number++; for (i = 0; i < b_frames; i++) { m->reordered_input_picture[i + 1] = m->input_picture[i]; m->reordered_input_picture[i + 1]->f->pict_type = AV_PICTURE_TYPE_B; m->reordered_input_picture[i + 1]->f->coded_picture_number = - s->coded_picture_number++; + m2->coded_picture_number++; } } } From patchwork Tue Feb 1 13:07: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: 34034 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp612829iov; Tue, 1 Feb 2022 05:23:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJzbei7nCWe1tMbTveRrYpuB5a/XdXYvo8eNIxugglGSRHrIDH+1wkhbohOYyIxXToGypDNs X-Received: by 2002:a17:907:7412:: with SMTP id gj18mr20115119ejc.379.1643721790457; Tue, 01 Feb 2022 05:23:10 -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 nc2si10787521ejc.65.2022.02.01.05.23.10; Tue, 01 Feb 2022 05:23:10 -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=Sl5+eBA6; 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 CC88D68B461; Tue, 1 Feb 2022 15:09:28 +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-oln040092074106.outbound.protection.outlook.com [40.92.74.106]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BC8DB68B2BB for ; Tue, 1 Feb 2022 15:09:26 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ot5IVdEi5TuymhL730h6xpzMEf6DmEf7bDebEJQU+cGrOMSc8ahQ4WUfcdiDdZxYJyxeSF1832Wd0kC1gRSX6Ss9DW0q6qfO0g9JyqJCFLNTokJWSnzMDHnR92tMZ0Qyr6vKEr0wOty7VwnmY1X0axEG4Mnlf5VJ8iky7a8Hq2QEMQcaVeNeaQiVtGMpaMdG0CfqqhfPlZ95ugZ0cmEz5Jcvul3fL3X2q/H+gy6gCCqJSenjPPu5qXhRrQglgZJGwlyfgHZopoQdODP/Z294DAcse9fOJ8WsGAZx4Bq6i6gOxWcMRIRFCYdR6V+CrrqLwNCooXiMAePPTA9QVXuuqg== 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=siCQRHxnLP0hqtjTdW479WoNqHVd3fI5f9HM7m41QpU=; b=igd/UepLBwXQ256FdOiDEAga2mrOUjGueZ3lkLajdZ+P/MUG2JkqVD4j8LYZ8cllATWhlw8g4udmgpfaQUGXCGDhzNnaaAKou07bgUFSsoleitd7dWMo7vCseJigrQzIplF8KV8cOq4DbnKl4Htwq7NnyMtk+SMvEEckAAaRqBSFmER3J1REjJGl1RVEN59Fcmuusf2n3SdpjTzNXrbZM3jPzQX49o8W87TpgtbRvDYpt36wpaMduSGr7sGlUjgEb/w1wLD9znR+nrfMgx7mw6DHJf9DDQBGmBrdx20fMdPKuvSxAwDyK3F0cYY2bUZdWF/2FijYELkRFYJ+BJFteA== 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=siCQRHxnLP0hqtjTdW479WoNqHVd3fI5f9HM7m41QpU=; b=Sl5+eBA61vRGtvx5cRiZ24pgYFGPIEZABjOhz2OsoRcSy0IXw9YupTJt5KQvrSVI51ADp53ETKFck9WHOXSqSjS8mQ2/wKjHGgNwFmS64zJ98FHSWy35uG5akNlwaV4XDTE+VBb6eSfmadIt8gwQKDTR9Xg2tCH4KxOAUWYHJvurxYLJ9P5E+QRFkV2NlO9m/2wqOd5RTk+2JhUgjBlToWZKFliguRHlbqh6IPQtfPeyrlPmoFwEWS5RZEY+Dl0joQT3xuLn2pWXaXwa4T7m/RH7XjR4z90JfXXRvs3/gkZS/RdCi/Ne4UoZ0txGihzq3L7J2sz16gMfM3vWqBv8sQ== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR03MB5025.eurprd03.prod.outlook.com (2603:10a6:208:102::19) 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:09:25 +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:09:25 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:07:02 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [KwmS1wXSIB8a3LiSy0C+RbpD+kSDN2zn] 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-64-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ada52469-fac5-4054-a3fc-08d9e58400d6 X-MS-TrafficTypeDiagnostic: AM0PR03MB5025:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dwZVITZGy8ro6RerrQP4kgpPofzmdcz6vo/HomWZl8IPIbeqTSXKh0NoqGga1NHSlKtpVTAEXXLHqmrarDmyoXYHaNNl63uaO0INnGaDaQ6W80K73PpJYj77KPpD/2L+IX1x8UcvGN2uo15TLYMEAJ8QoRCk/vl3y4TUId+aIsKHc0pZlDQyPr8jshEmxCc14RQFu04GImTuhSF4QfQRKYMr67Huf4poKEc5hWuW5zRcAyFf6LfZvwVS8YEwfWYh6gUAfpFqNORyfWZ5n5nu2sgSjd/SwQHfIRYzbpq9Lh1hvs+JxREkgUM7aqpBxJkJXx+Ax5hbhroOjlZVWdK//NYs8APFpu/gzJ1/bmfFMnPioG5WWa3dwAC5JYsq1gQiVB/iX3/dgQbavte3IyvH0qw0FE8O+Roea4BFgp92JQY5QOXK+knmC5cBUcFgNVSQmq5fg43WAOJVHrqeSUIoNwgkq8KMzHaKpzNUg7Y5IPhAJwCLaxCn5vn6Ar/zh7rsh64SeeT1yKERaIsObPn2GgLEa0N/2FiLO5no806SjBYVE2UKlAURinw6t4VZk3pr X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Culvx7zK3+L2K7cfwYd4t1V0Q0lT0wMuMYOssFebjhmUzs/0rYffymEIiHoOEMehMZaQclL6nLUX5OubSRbDbqWpWuKyMTDsl0e6Y4UCLZVb7ay59QzMr6xEy5Y6zpTI6lBcVHfAtrSO/ij7I512Bc43FN6KJc0ojz+PlpyhnLlX2CfYRkoTCtj7MK3klqKKT2nvKzCACXRWk18n44qfX5uAJV4nJ0jcA0Uq5YH4LVEiWH8piJowQJT832D7uxsBHR74ekEEJHJL+c5BheIzyuQ5BTYS7m2sv7XKKXsVUQWrycIyBSgOBnzezxziL3oSYBJciE8KM9eIVg+Ef6IWPVL1dRw0rKcdza76PsTbhsOu90F4UjKf620dp7vK4fNuqw9DUM5E8ux+B/QkQSz+3tj9HtgsyQb8GUGBw42qp3dZUxvgMNTnqJwXCW4qVe1dK68j5t///W4dtRJLW8Omr3CigufTl73Mp1+mkmpjSxUDjiz5iV8BjYIrqgqzJSJV5vZLq70cN8mRMiKXYf8Wbh80RYM+3wXmwaz6TuARalAWYj9Cz1yxlNuHWyMl4vxXPK77wF6LpQaywSZgamY66kar2SvDzscyH8nIY5j8AECDWnN47ro76e2mCPcrlFxCWQr1mPYhraK+OMJ+Tg7Kha8zzMwH4T9jXBtAogVp3nKWWFlKW/ylVFTVELK7h+TzjR6eaVyIMNLQxf6V1zGu1LFDOVCl1w7AjO7uHmUDtWvD/uicbl/NWof/bV3D382BB6Ltp3AkPTBUbxMwHL7ChMFlmuvS0NUIbLzgzr+KeVwkGNuYIkMVs557dNz5GcDgA3xPQx1/8Gf8ndV7j2WEge41QbKYGYJppKmJMLf+pjQ2xkRYDBwAhOlJXfZvK0FZpv+Is/fec2Ullm/yrQl8ItsAEttraq6AUIwgDEhHwWBCqB1LTKXruQK6LX/vzysICrVclk8x2YwiKwA0SwSHxg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ada52469-fac5-4054-a3fc-08d9e58400d6 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:56.3552 (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: AM0PR03MB5025 Subject: [FFmpeg-devel] [PATCH v2 65/69] avcodec/mpegvideo: Move arrays owned by main thread to MPVMainContext 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: FKP+1+9WnUxp This commit moves the base pointers of arrays only allocated by the main thread to MPVMainContext (in case there is a base pointer). Signed-off-by: Andreas Rheinhardt --- These arrays are no longer reset in clear_context() because it is my understanding that there is only one place in the code where these array pointers could become invalid: in ff_mpeg_update_thread_context() where one context is copied over another. Yet only the MPVContext, not the MPVMainContext is copied, so that these base array pointers are always valid. Hopefully this can be checked with the testcase from commit b160fc290cf49b516c5b6ee0730fd9da7fc623b1. libavcodec/mpegvideo.c | 23 ++++++++++------------- libavcodec/mpegvideo.h | 7 ++++--- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 8debf4d6ab..c8eaafcc1c 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -575,7 +575,7 @@ int ff_mpv_init_context_frame(MPVMainContext *m) int16_t (*tmp)[2] = av_calloc(mv_table_size, 4 * sizeof(*tmp)); if (!tmp) return AVERROR(ENOMEM); - s->p_field_mv_table_base = tmp; + m->p_field_mv_table_base = tmp; tmp += s->mb_stride + 1; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { @@ -587,23 +587,23 @@ int ff_mpv_init_context_frame(MPVMainContext *m) if (s->out_format == FMT_H263) { /* cbp values, cbp, ac_pred, pred_dir */ - if (!(s->coded_block_base = av_mallocz(y_size + (s->mb_height&1)*2*s->b8_stride)) || + if (!(m->coded_block_base = av_mallocz(y_size + (s->mb_height&1)*2*s->b8_stride)) || !(s->cbp_table = av_mallocz(mb_array_size)) || !(s->pred_dir_table = av_mallocz(mb_array_size))) return AVERROR(ENOMEM); - s->coded_block = s->coded_block_base + s->b8_stride + 1; + s->coded_block = m->coded_block_base + s->b8_stride + 1; } if (s->h263_pred || s->h263_plus || !s->encoding) { /* dc values */ // MN: we need these for error resilience of intra-frames - if (!FF_ALLOCZ_TYPED_ARRAY(s->dc_val_base, yc_size)) + if (!FF_ALLOCZ_TYPED_ARRAY(m->dc_val_base, yc_size)) return AVERROR(ENOMEM); - s->dc_val[0] = s->dc_val_base + s->b8_stride + 1; - s->dc_val[1] = s->dc_val_base + y_size + s->mb_stride + 1; + s->dc_val[0] = m->dc_val_base + s->b8_stride + 1; + s->dc_val[1] = m->dc_val_base + y_size + s->mb_stride + 1; s->dc_val[2] = s->dc_val[1] + c_size; for (i = 0; i < yc_size; i++) - s->dc_val_base[i] = 1024; + m->dc_val_base[i] = 1024; } /* which mb is an intra block, init macroblock skip table */ @@ -646,13 +646,10 @@ static void clear_context(MPVMainContext *m) s->bitstream_buffer = NULL; s->allocated_bitstream_buffer_size = 0; s->picture = NULL; - s->p_field_mv_table_base = NULL; for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) s->p_field_mv_table[i][j] = NULL; - s->dc_val_base = NULL; - s->coded_block_base = NULL; s->mbintra_table = NULL; s->cbp_table = NULL; s->pred_dir_table = NULL; @@ -761,13 +758,13 @@ void ff_mpv_free_context_frame(MPVMainContext *m) free_duplicate_contexts(m); - av_freep(&s->p_field_mv_table_base); + av_freep(&m->p_field_mv_table_base); for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) s->p_field_mv_table[i][j] = NULL; - av_freep(&s->dc_val_base); - av_freep(&s->coded_block_base); + av_freep(&m->dc_val_base); + av_freep(&m->coded_block_base); av_freep(&s->mbintra_table); av_freep(&s->cbp_table); av_freep(&s->pred_dir_table); diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 99d474991a..56c1d8118c 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -147,12 +147,10 @@ typedef struct MPVContext { Picture *next_picture_ptr; ///< pointer to the next picture (for bidir pred) Picture *current_picture_ptr; ///< pointer to the current picture int last_dc[3]; ///< last DC values for MPEG-1 - int16_t *dc_val_base; int16_t *dc_val[3]; ///< used for MPEG-4 DC prediction, all 3 arrays must be continuous const uint8_t *y_dc_scale_table; ///< qscale -> y_dc_scale table const uint8_t *c_dc_scale_table; ///< qscale -> c_dc_scale table const uint8_t *chroma_qscale_table; ///< qscale -> chroma_qscale (H.263) - uint8_t *coded_block_base; uint8_t *coded_block; ///< used for coded block pattern prediction (msmpeg4v3, wmv1) int16_t (*ac_val_base)[16]; int16_t (*ac_val[3])[16]; ///< used for MPEG-4 AC prediction, all 3 arrays must be continuous @@ -194,7 +192,6 @@ typedef struct MPVContext { H263DSPContext h263dsp; int f_code; ///< forward MV resolution int b_code; ///< backward MV resolution for B-frames (MPEG-4) - int16_t (*p_field_mv_table_base)[2]; int16_t (*p_mv_table)[2]; ///< MV table (1MV per MB) P-frame encoding int16_t (*b_forw_mv_table)[2]; ///< MV table (1MV per MB) forward mode B-frame encoding int16_t (*b_back_mv_table)[2]; ///< MV table (1MV per MB) backward mode B-frame encoding @@ -509,6 +506,10 @@ typedef struct MPVMainContext { int slice_context_count; ///< number of used thread_contexts /* The first entry of this array points to the above MPVContext. */ MPVContext *thread_context[MAX_THREADS]; + + int16_t *dc_val_base; + uint8_t *coded_block_base; + int16_t (*p_field_mv_table_base)[2]; } MPVMainContext; /** From patchwork Tue Feb 1 13:07: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: 34035 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp613023iov; Tue, 1 Feb 2022 05:23:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQZ1mNIdC8sTEHNB3NFU/83sdiCAhKLuIUu6/LU4z4/6BWTpO7FYAfm+MI8Lk7hbsG9dCH X-Received: by 2002:a05:6402:3450:: with SMTP id l16mr25292414edc.225.1643721804044; Tue, 01 Feb 2022 05:23: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 u25si9484949edq.22.2022.02.01.05.23.23; Tue, 01 Feb 2022 05:23: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=WK+KLV5u; 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 B80BA68B46E; Tue, 1 Feb 2022 15:09:29 +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-oln040092074106.outbound.protection.outlook.com [40.92.74.106]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DE74068B360 for ; Tue, 1 Feb 2022 15:09:26 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CkvjsEYCj8DGEZ4P7KYa3Yg4uI6tlPPcmdtbwtyRocqau6bCmg/Ai46/d8XCk2l/83XIZ4hVa2aBgOQ+G1gLI+7jpHGrKEM6dF+FGYNvQGZZpXQgf2zJu1hptc0FLreLHKJY1pU0GeifbzhvTyZK8jMynMkVh6nbONDSiefFaf0glkPwNeWLEC9aVQQt6Qnvm/7iffNMqQf0DjnOG0sXmftjaunATVQqCbk9lJwU0TJRoya8a8+9gZpz6iiqEvRqXVy7zyPBYEu9ikRIT+grpEebjvR0eJurtUUzOKlOR1WY2kZMIeJ6zun/ilggfHI0bVX9Yfyet1vvffgwdYj34w== 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=F2Ts4j1f8nNGIvjW7wWCJa0e4TAUq6Zy0piLgW1/x2Y=; b=MiWwIdwdzQLQYRnrXS3c315ZgYQy5oh19WJMgbid+r3PrjfG8Lhk/u+fr1Xpf2YWTaMBZOt8ZCtF9XQ2tozzm7QsP45PbGtPpc2ZUWyXw5dh//2JsPxilXAHTlq5+ImmSoWlLGs8qMhJ6MLGDJtMFtRN8DBQUfeJr63ZpVK/MOQDJ1cIqiUvcPYOdDhLzXo/hSbwKblFaZvHLUwNR9iZX1j0BSV5EMYrurUXi0rsD+Qj9/ZqPIpWcLFVHXAfVhyyeoGtdeagEvCkbGUMjfBJcbR7N0bM2oKQPhL9vvku1V+x7/5Xm5ZSYV+oNDdO0Qhiw89tuC66M+PdUPdegSyuYg== 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=F2Ts4j1f8nNGIvjW7wWCJa0e4TAUq6Zy0piLgW1/x2Y=; b=WK+KLV5uuEK1UYkK7d5/hladEnB8TyS4fF2cX9gAztayNfuo3qDfAvh2e6h8vM2arSSX6KUN98i3BNpPcI+R8A8hoS2LYVrqxH6Nf5VtlgmtYoxAAsThKXi7CqRRtjstFYxLK9+zanVKqK9X1iMALhjuAchT4C+bVu8zyKHgJNJG8egt0ID9GcR55YKWukae+08cH+flfW7faqg/OQbK+romANfZYl3abhHzpZuQMRX1q3htMI9amOyl9PARuVMXNh+hAX8lvHo/eCe6ZlHBk28hY8dDLiab8Wn28/2XU3dM420j8NBDeO2C/r74PcFsY2scbswaosNPCtlgnTDIKQ== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR03MB5025.eurprd03.prod.outlook.com (2603:10a6:208:102::19) 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:09: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:09:26 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:07:03 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [bLK4aZdrfKw/WJrGW/HHMRMuh+Nmiq/O] 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-65-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 55ef0dd9-e3dc-41c6-7ea7-08d9e584019c X-MS-TrafficTypeDiagnostic: AM0PR03MB5025:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1C8gRjZmTxr4Xfg1M6GVi7193rnyGxii2n9lsNQiEv3eTGk5Q48atBZaWd5cTGugWRryJGXyGYCOEtX8Mlt6Z5GgFi4rjl/jxmsEYon0OyrlBPSILL1CG89MvWLchukMp1eb2Lt0zyo41A/kOniQsrombjTDN0DFOSWHpfFGJLtPFX8XDmw/Ks3FutgxpoVGg7jomTMKj1ONY0VROMhcDSwKLYznK5a9FsV84epp3FXczDtHkhjL1pBgk7md4OhlNTp2fbzVaBiC55DSEZTgCbvRVjRWlvXnQoCkuHJEivgMLfwvO1V1W/CT4e0Z+s0jebQG6aUhoVUtE5V5Tkb6KDOc7VcuBsi12w28zgqzUb00zUmdX7ObR8SLBx0ior8p7R4KpUlyNbTQ3p4EbJzmIKJHKN7Lmsy2ye/1hcjfA4MH6fJyb6r3lkx0CeVIuPSiNoni33Jfxy3Fbp5WPf6UJCB3KVoSp5CKagCsB/dOgQQCMCMMqEPru8hZKVxGvjqSS5rPS1fVxO+5cUix2wQ++uPCvBxPOEEc5vztQZ2n/I4VOM8jjvq8pFev1omo+ru1 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9VadBGzBl9AOzCeq8kgux9Z/nj4SUt8SB8sTlVn82sB8J8WqzWoaOlEGJCYHvxt7NbL894H+VQFYvvDuvSfNN3kQ4EpnPRjH92zF5MsLuwlPufBiAUrEf6g3ZBtpYFYN+L8DtBIqZyLAl4qIjmEx4B91NjiEYRhbxjL2FS9AArIaDfYVLMqOqAtvlb2SAqW+lf2wP8Pjs4zV8MO6ubMkcGXRPQsWNJfRAVcw1T2U7ugOzGeFGUcEKyNpOqvbZzbYTpiEAvm8vtlj83l+v+rPRVG+iWFgjLOj7CnOg/qBYJhGZxy0XwTLzIaELFawJSBld0V/NYfLQiBg4eWEzC+GhCOB/D2hE9fV2xazWcfwqpjFCdTJVSh82CLLgkdrar4VaMcDA9/eRihqfYybzPU56a8c/LjD9SopwJ0YxQoo8eL6lRY1vVniK7AQgIlrjduyG+NZVlEK7mLOA6U4EoAF/y7k0Gd6TCwVsviEdQvjDp+E2wq/Iu7bDHomQXGIDS+YKJAPOTdOHwcM6VWlqnzzcgAwSyLFAj/1PI0SsAZD1RqeKFafW3N4bneV/yRjfT3fz0BKaqTt5CF4SGkTPiNgh/pY1fduk1rCiXNrSCvXxsM1es9XnL3T8EcuPv+rX8/7XqY6TJ0inRskOy18mWAr7QoQlnoKEc21tzBZ+S3T6nV0qTalDwj8mht8tVOkInYKm6L+R05x0Xd71F/cVxqz08nfb441bAx43LQlUsd/WmpchAwHP1xfWhd5OICvb+L98LMpjCwxcnja9wXOxgaRs/5eVcZsKGW61v+O75ODnDfqsLDRO6YZMmxLLrZSW7ktUU3lM4C+wlzHeSyu3QTA2zOO9rQQofSx9QJhapWwgX3aZNQOJfA+l+xM0odJ1DLRzP28ABRvBLG5onMg6NrVdVu4RUC3XE5nyaV6Orj0f0S8Y+Ei3ptqJ4icYH69H8in/mKUvhT0AGGQIdkH8Dxpcw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 55ef0dd9-e3dc-41c6-7ea7-08d9e584019c 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:57.5893 (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: AM0PR03MB5025 Subject: [FFmpeg-devel] [PATCH v2 66/69] avcodec/mpegvideo: Remove strict_std_compliance from MPVContext 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: z86bC/NumnMN It just duplicates AVCodecContext.strict_std_compliance. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpeg12enc.c | 2 +- libavcodec/mpeg4videoenc.c | 4 ++-- libavcodec/mpegvideo.h | 1 - libavcodec/mpegvideo_enc.c | 3 +-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index 4b885669bc..a9d87f6854 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -223,7 +223,7 @@ static av_cold int encode_init(AVCodecContext *avctx) return ret; if (find_frame_rate_index(mpeg12) < 0) { - if (s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) { + if (avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) { av_log(avctx, AV_LOG_ERROR, "MPEG-1/2 does not support %d/%d fps\n", avctx->time_base.den, avctx->time_base.num); return AVERROR(EINVAL); diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index 9bc6fb9388..2f78763344 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -1068,9 +1068,9 @@ int ff_mpeg4_encode_picture_header(MPVMainEncContext *m, int picture_number) 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 + if (s->avctx->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT) // HACK, the reference sw is buggy mpeg4_encode_visual_object_header(m); - if (s->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT || picture_number == 0) // HACK, the reference sw is buggy + if (s->avctx->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT || picture_number == 0) // HACK, the reference sw is buggy mpeg4_encode_vol_header(m, 0, 0); } if (!(s->workaround_bugs & FF_BUG_MS)) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 56c1d8118c..a65c23f1d1 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -97,7 +97,6 @@ typedef struct MPVContext { int encoding; ///< true if we are encoding (vs decoding) int luma_elim_threshold; int chroma_elim_threshold; - int strict_std_compliance; ///< strictly follow the std (MPEG-4, ...) int workaround_bugs; ///< workaround bugs in encoders which cannot be detected automatically int codec_tag; ///< internal codec_tag upper case converted from avctx codec_tag /* the following fields are managed internally by the encoder */ diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 3e9f8b4e42..d3e52126d7 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -370,7 +370,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) return AVERROR(EINVAL); } - s->strict_std_compliance = avctx->strict_std_compliance; s->quarter_sample = (avctx->flags & AV_CODEC_FLAG_QPEL) != 0; s->rtp_mode = !!s->rtp_payload_size; s->intra_dc_precision = avctx->intra_dc_precision; @@ -585,7 +584,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) if (avctx->flags & AV_CODEC_FLAG_LOW_DELAY) { if (s->codec_id != AV_CODEC_ID_MPEG2VIDEO && - s->strict_std_compliance >= FF_COMPLIANCE_NORMAL) { + avctx->strict_std_compliance >= FF_COMPLIANCE_NORMAL) { av_log(avctx, AV_LOG_ERROR, "low delay forcing is only available for mpeg2, " "set strict_std_compliance to 'unofficial' or lower in order to allow it\n"); From patchwork Tue Feb 1 13:07: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: 34036 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp613162iov; Tue, 1 Feb 2022 05:23:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJyszqan77mr3y2YcMiFqcs9MkQ2TeFW99nYy1KvtFRtROOJkCE9/bltNyI1hGKjHgLlnIhV X-Received: by 2002:a17:906:4fd6:: with SMTP id i22mr20760122ejw.502.1643721816534; Tue, 01 Feb 2022 05:23: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 di21si9108364ejc.981.2022.02.01.05.23.36; Tue, 01 Feb 2022 05:23: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=jvEgYM1D; 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 935C268B475; Tue, 1 Feb 2022 15:09:30 +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-oln040092074106.outbound.protection.outlook.com [40.92.74.106]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1F5B268B2C4 for ; Tue, 1 Feb 2022 15:09:27 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fctchc+1VgMX7cNqCrwwL2FF6MON4OKcmyHI2XzlDZ1vsvh/6OWu864ySjr9O7Y2jgBiqe98AC4BYo2fNx5vB2u9OuAW5rU4Um/aKo2eL04AbQ2Ohk73VYXEJeTRI/jpgaD+Dbi68Plw33N5g8CZLg0KVdCq8MvXbS/to253jvg+N4/i4OPwYXnFpRd3v9YJWxoRFdReYSBuX1Vmso5QD115H3i1PoG9ZpAzQ2LaMlsGtnvyBx1hRt8pqj829VUmGoPUcAganqZJ5/sxHopJC60TaCwL19I9O9fxh432xEWtiw/OFra947/SzxH3fKMzZ4F1D3WqFZDcUfug2HJ5Yg== 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=VVlKDYFftvOr7dW7n+qOXaHMxgku0HHODCS31nl120M=; b=ky+cUKGIqy579biHqec998vOPeUWkgPVWh1Ulhn6sBzm1ZmnbAJdJ+hn83nuPM9C2BtXvAQ4npdqvlP+w2A2egcW19raJrZgFtc5Gjq0Vss3i+7mInS2Wr1ZOIzkKNjodFjaf4B0PBAzaTvREAryeQu65IHuBX26BTIk53X0xAp3cmIhyO1wW6TUWRGW3PSr/QEnVNyC5P3dwrjmdbzhSYaPlqO+RnvGgJG7vwy4kLg/OZcIhi5BBDE5VCpOfXOnZa2FLnLiDAqwHHcB/iHZlMZxUkUjNpW8iWeQvhxE78uh/wpbsnqU3lgedGLCRdQB+KXzMtkTjdl+O5Wk9ksmSQ== 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=VVlKDYFftvOr7dW7n+qOXaHMxgku0HHODCS31nl120M=; b=jvEgYM1DQbt8dyqMjkJ+Wq/lpLCAYoSrkGx6yIcp5FEcelwUcXclZVLjyDECBQLw+DVEELlKzpeX/LMR90oKLk4hJV2ez76PSMYn84pToOA7uyHHuJrirS3oyCU0HveuDxhnLy1ohVigl+MLOs3pvwRsFeqC5sjHTs7RpDEdKHEiq4rLMDBRuAkdAe3iZsSzwmV0SVbI420EtCsIEIA4g/S6eGQkLWOrD06plhn2qDFkdGqHOt8tZ2W2b9IAhRlTUBIZovxESyZy5suscIoed2qWFbY89fiBrlMje3rspqw8Z6MDAYFqIjhq2zqdpb7nCyRAp1h2E391CbYdemfRUA== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR03MB5025.eurprd03.prod.outlook.com (2603:10a6:208:102::19) 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:09: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:09:26 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:07:04 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [SAM7MfU8lcnkYUeiOsihlX3L3FI6k0xN] 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-66-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 37b70b24-09b7-47de-0704-08d9e584023a X-MS-TrafficTypeDiagnostic: AM0PR03MB5025:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eAobDiEV6Yf7NvLE778aGJBgj88Crfki9T+bO5hAvLpFSWkDfGrbpkMrpXYsmb3h3JJ0YjjGnBDVuMFYdgy0jCnzikEA+yvmLHWzFYlEeFtcUdJCnfJobz5muURcIreAkXxxk5V4XTVEfAMNxlAIb/vO27oKMXIMeVVaoFjHDbKppLmbs2HmaGAlNWOwJOptSQMFSYnRPzP7qNT+a8AovDgU6iYW7Ia7s9Iun+HFAFDHMoCCZDch7aTNpzZl5lNgkJEU0Jv4zAhtU55y69ACG427ng52RiWvqnpIR+eWvXUU3+i8veWz93bQA1F6R6x8tOYkQSKeqk4xuZpJnVd2mqI8YYpa2tIDkRi3LpELA2P6g8gG1/kW0ihAji3UDppsb6cJR0ZwQxXD5uzm8eSpeOouxQ7PEVbzQsb0ChMpmjTUIu0+ZgKVJpWz6yUsXPeY1T1WgiKowRU3mO49SF4omc/V2/UNqrsT00tkrVzNb2racIVow1d/2id58KseeJ9V72VLLBx55qatGZWIJNN2rks1yPL5G9mKOtorrVJ7txnzmp2MCkvz42EB952VQhzT X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5H347+zBeYpbIWw+aVnxM5zcSeagFseHSe2KI0ED2orxyEOyaFCFYcQi+nsLcwR53tFGMWU8tlK7f1qoENftbUXqjP4Z4lYOQauvRonh+tFpi+0Qj/mfrvPx/L5dnxbi1scLJNt9kc5LBLaaipas3PBj+JjweDDUjd3e+wMTs7IKeez/uFiQDCVX2ObH4bB/DrF2u5YztYK+XzbkKjjJ07X6EgzESwsmXiQQM8AvlOSyDntqqtEfzMEAmzF8aZUqmjfZgR3N6Z0MP4gre6OzBMkJPi3Zp6lYFbN1jznrxSDrzw6Z825TT23RCXHCWAzvk+Ks137I/BlbKAFwR4i2tbEMCm1Xheu7gRC4HJrTi8X8O2Sxa1sH63o62UBmSct+Pw1ncjcGsqC90HwAzOtgxkMcOEp8+ukJ6jbRvBzAUnNFguA/ufyS7p5sIiVm3+jMA1/eI5yYz5XtTPe9DxMOkdocVlkMi4g/ZNDCqd7sf+dzI14JHNvhBJtnwJySIyXBqbi7Na9dhNsBPa4Wg6XYPSLoj79LSSyNiY/WAGUkgOpSE/XQ1tk8XPS3a2S0gSaQqr1qDh3N5WOmrH8HyUWCBWvuy68HUkUIsEI1U6mlTFADfv7pVS0Lc8G8JaZrP6zs2MP/No6UUNl3KzBlnzR6Jhe1sG6qxxf2/Y2cPo+LKVfVa2IBDIFsNgNHtsI0mPHmrwF7l8+MnkvIZ2LHEiramsdmTmBY/k3EJxYf/OHG6kebCvXQBTUeTTXnYR+w/ch658fo7wmra5egu2coDZp+eitZCsUL4+wPusSLKR/H63jAg9I4gyYy0yVThQakLnLGhRk3lzxOGGZJOWS/DXvxu/z8+y6HnSC4JP8VWCILxCTw9vU/ET0ll9CFMmdC+twr+Q6wJuRlBX2cRqSXv917ZZjOC4yQm2Gc+wL/yORjZC4WJxhllQCFcXULr+F/enshceAJMuE28hRDOcYc4nKbzQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 37b70b24-09b7-47de-0704-08d9e584023a 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:58.6218 (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: AM0PR03MB5025 Subject: [FFmpeg-devel] [PATCH v2 67/69] avcodec/mpegvideo_dec: Remove commented-out cruft 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: 4u1osVALPxo6 This piece of code has been added in an already commented-out state in commit 158c7f059c3906b0116ae73a7669a3bb7bc570bb. It certainly doesn't make sense now (if ever) because new_picture_ptr it used has been removed in 6571e41dcdee4655237bca0a3277df8976167aee (and new_picture is only used for encoding). Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo_dec.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c index 48371aa886..8927a0a21b 100644 --- a/libavcodec/mpegvideo_dec.c +++ b/libavcodec/mpegvideo_dec.c @@ -358,8 +358,6 @@ int ff_mpv_frame_start(MPVMainDecContext *m, AVCodecContext *avctx) s->current_picture_ptr->field_picture = s->picture_structure != PICT_FRAME; s->current_picture_ptr->f->pict_type = s->pict_type; - // if (s->avctx->flags && AV_CODEC_FLAG_QSCALE) - // s->current_picture_ptr->quality = s->new_picture_ptr->quality; s->current_picture_ptr->f->key_frame = s->pict_type == AV_PICTURE_TYPE_I; if ((ret = ff_mpeg_ref_picture(s->avctx, &s->current_picture, From patchwork Tue Feb 1 13:07: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: 34037 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp613308iov; Tue, 1 Feb 2022 05:23:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwh9RfJVLyX3OBqU/aTh3HA8+3JUARhh+zqBxluC76ldqJ2Pex4tfToScxYAVINoQJXlkcR X-Received: by 2002:a17:906:3b84:: with SMTP id u4mr20830320ejf.689.1643721830140; Tue, 01 Feb 2022 05:23: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 z26si9554103edi.339.2022.02.01.05.23.49; Tue, 01 Feb 2022 05:23: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=dD3WtVSk; 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 7A8B168B47B; Tue, 1 Feb 2022 15:09:31 +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-oln040092074029.outbound.protection.outlook.com [40.92.74.29]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2966F68B413 for ; Tue, 1 Feb 2022 15:09:27 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h7mPoCxTa2vjPdFLUhkGZEs8lYxX6DqTmlpGRx2KgtApnj9I5neQybO2rjffhX4ytr6LJliwUWn5SmEL+GYebnNsIJl8A7VAv2NdvhzEakN64iXn0pZ/SgxlPLOnFXpiEDY1HzJ6CC6MioVt848GgfYzrFfnS+8n2jVHngpE2QlYWwtupzW+2GpduP13sPPg491TeTqxI7jAhfXPyokTuzShZSWC2deE+T3K6YLYyGUW2ZvN7NsMuzo1jdrhFJmjBwq+TahXG02ME5X33MaUU7VTwWhcqHzviV/Nl6DvwFYlBpVurgv9Yb47yiAM6HtUQQcRChse2oMzBizPFHtxFA== 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=Bd0RGkaLBkrCW3H0wqRLHhKy/Xe4bLeYBSIGCZOCzWU=; b=YAMKIhaRWIDIn2pZtRuRtIS5SEriKNXwz3ufuQC8pCpK5HRk3qF7/Ky7fOBqRq1eVcpDcO05PRnx1wBE6YKY0izQ3jfnY31ZzFArpjmZithzua/l5+T77sXZMh6wfVlXoe26fLliq1o40hhBY0PciYPtEs99vSAWNCk3B/zm67QhHaCI7JJrNQpTYwoYVozlshu5nAhLpqt5tBIPN+rjjGueB6emVsHFLevEaE55015NdlqpVxRjJdqZP25jG4aZmYXbwJVhw1jCB6r/sH9EmgGd0StFiMMUH29Cb/gERyNmMt1BPRodmLxR2X+Mzeb2nEMPwq5cbhVaKA5T/WX/aw== 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=Bd0RGkaLBkrCW3H0wqRLHhKy/Xe4bLeYBSIGCZOCzWU=; b=dD3WtVSkinbAUmcDyTCFcs0sI3tqgzidod2RaNCV9dT/cV+HTPwJcKxY5yOKDZWlHJaL5Zh18eQMGeUaIsxK8tiJps5oudO8EDyfayit7ViH1frBeNyI6Sq0Ub++E7MDNk0NllEFdje9O0fCPyJF61425oRJlakqO73svvZAbxJlk7xjK/3z0ZDBZe1biNBrFeDoIYc/xqDOXBFIsqENVmRHYLnj68CC1wpuH2xrMnBS4m3S1O+i2BgyGITblgvQNmFSzOyeMZe7C+9tXFowGmQjWb5fVrNRzzMXayr0ncCANV7Tjf0ketoyP/yOzHtgMvtTaLBtGUtUG/uWo6rfeQ== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by DBBPR03MB6778.eurprd03.prod.outlook.com (2603:10a6:10:201::19) 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:09: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:09:26 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:07:05 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [uDAQrzOS6Fch7gQO6EDI55s6X5UoRNYG] 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-67-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a5239189-f231-4071-9cd3-08d9e584030e X-MS-TrafficTypeDiagnostic: DBBPR03MB6778:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DDuM/1lkl64E/mjNmpLLt0jFwYNeN7dHkfThED/vYHuPgM8ArCKoZhDlkgVSmxY99ILhlD6HpZygFmeBUci4umOR0mm3gdYoubezN+EVQbIU1Yh53DWLwaCkGFFwjPWSwiajD4BRkHEAAt7pxqVQ7VaqwjpyWlP4zZD2bm6s7NsvXb2jcq+7tP92S4hFCHkx7qUSm6M1jo2GrMy0D28lZHPAqqAW+3E4y4DtTgNA3ZYqFUFX/AbPXSXi/WPozn6TOy4Wk7ccYFDPZXXoHjjkokgvD30He3iLmVeCOuH0MQcR44+E2Qd7GIWJMwlHF3NAqpZzL6nJe/ifv4xvfGuzKTOaujyh+jjq0yzrnrsx9LPJL3kRiW3t4JxoX3za4Ay7eETztflKCVMebdeebepic7D8Nog46bUYCQMBnt4eaWhJQeAIPj4NMim/w3F+Ehtpouu+wlmWlFg7KL2QSyEdDzS4JrSTTgU6Uc3VlHykH0um4+y06a720stb0wUSs2mC4tunbTqiQ+hx5nVZPAfqJ8RyRW0UzLevHWwzdoWQvVA= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VR/nA3pTRiRyPekiz4S8tBAOIKPjfSsmomuKjjGIoZukglZL/vCAu2cM2NienrBkGtEGmgNCyDCLk8Q96tvhV+w62ex4lIZJVFzjqvdlnH/TOIV7vqSxubDFRTkluWR5kyndq45iPKaM4+pDznfPH6jOs0+Vks/pfeVkmsmLRJNztntLXJB6sdVIT00dE6KQCTVPl/N13F1cxcmMsbQJCRxle9lgAVAu3A4XVrglwPXzhAgqLPILAr9UvH4xR1fohz6ongmjv6hwTg8PxkLYJaM/e+tsw0gY/bFWJtpJWDPsvXqPdAoEgMdGbltPL/fZ3okmiPhejt8pa3i/YBoh7dY7SFcrw2xONy6DXCkvnQULHgw+Ii3JL2FhE1HW7hp1brgxflQ6Is8O/mvVBSXunQuv5OBJYuTN0/Ts+JXvnvs/kcvCvF3EwFxxh2NpMwHwSRYCkrOhfw2FjqUQtY0Es+a2ONLpg18tLts3EcFYJt5GbvHho1rkDcSYs9gnMj1g7liu0y0S+dcKBOKQP4a0IpA33+XKF1f7F/I+yZsGLrgZ8UOqqdYeD/KwjkH7xiEB3IbgzZgPM8N3etOhSsqZ2bOWZ0dE7D1gmc3gc3AKISVsD+GfuqpGYMD86YBwBY4Ryes+k/GHuIcSx8bWdbJhbS4+V+ITde7PzreQhV/IsL34LtmyVK/PYqBw3Pqxyt6vkaIVAWJqcHSinObgPbEKrSlTcNpvOOnHd350MkxBZEyg0EAszHYXQawLD5l4k45sELkP8FE5t6IobWZBt0H2REXm7oQ+zpltq0lPaCSog5R9C6AV7MOUfpNUHqVSJ11KTPXuMvY9w+diIXVtU+Gv6xkI8e5JAY7iE1QhdBTNH2sySolc3ItrV/P6vhpFgpkOU+WiPLGhEDRjbK1+Yo8u38MUBsfWQOVHRuSbLQ6BQtR5Tk0uo1Dwbw8IyKNVi+fPI9zWoQNZ65sKaNohGeJpAw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a5239189-f231-4071-9cd3-08d9e584030e 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:09:00.0306 (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: DBBPR03MB6778 Subject: [FFmpeg-devel] [PATCH v2 68/69] avcodec/mpegvideo_dec: Remove potentially UB always-true checks 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: 6IngSbqDw2re ff_mpeg_update_thread_context() currently checks for whether the source (current|last|next)_picture_ptr points into the src context's picture array by performing a pointer comparison. Yet pointer comparisons are only legal when the pointers point into the same array object (or one past the last element); otherwise they are undefined behaviour that happen to work (at least with a flat address space). In this case this code is moreover a remnant of the time when the H.264 decoder used H.264 (see the commit message of d9df93efbf59b1dc8b013d174ca4ad9c634c28f7); the current decoders never set these pointers to anything outside of the picture array (except NULL). So remove these checks. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo.h | 3 +++ libavcodec/mpegvideo_dec.c | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index a65c23f1d1..af1d9af2bd 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -142,6 +142,9 @@ typedef struct MPVContext { */ Picture current_picture; ///< buffer to store the decompressed current picture + /* The following three pointers must be either NULL or point + * to a picture in the main picture buffer (i.e. picture) + * for users of mpegvideodec. */ Picture *last_picture_ptr; ///< pointer to the previous picture. Picture *next_picture_ptr; ///< pointer to the next picture (for bidir pred) Picture *current_picture_ptr; ///< pointer to the current picture diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c index 8927a0a21b..137b47efa7 100644 --- a/libavcodec/mpegvideo_dec.c +++ b/libavcodec/mpegvideo_dec.c @@ -74,6 +74,9 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst, s->avctx = dst; s->parent_ctx = m; s->private_ctx = private_ctx; + s->current_picture_ptr = NULL; + s->next_picture_ptr = NULL; + s->last_picture_ptr = NULL; s->bitstream_buffer = NULL; s->bitstream_buffer_size = s->allocated_bitstream_buffer_size = 0; @@ -133,9 +136,7 @@ do {\ UPDATE_PICTURE(next_picture); #define REBASE_PICTURE(pic, new_ctx, old_ctx) \ - ((pic && pic >= old_ctx->picture && \ - pic < old_ctx->picture + MAX_PICTURE_COUNT) ? \ - &new_ctx->picture[pic - old_ctx->picture] : NULL) + ((pic) ? &(new_ctx)->picture[(pic) - (old_ctx)->picture] : NULL) s->last_picture_ptr = REBASE_PICTURE(s1->last_picture_ptr, s, s1); s->current_picture_ptr = REBASE_PICTURE(s1->current_picture_ptr, s, s1); From patchwork Tue Feb 1 13:07: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: 34038 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp613527iov; Tue, 1 Feb 2022 05:24:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJw8H6wFeT+fvV411SE9Ek/PwE8ue7kblLhFyaAgAwkH6lRanzQA8DJWOPFSwQM7U9K0+gR5 X-Received: by 2002:a17:906:fcd8:: with SMTP id qx24mr20626784ejb.391.1643721848969; Tue, 01 Feb 2022 05:24:08 -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 hv11si9011976ejc.176.2022.02.01.05.24.08; Tue, 01 Feb 2022 05:24:08 -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=ZekbRk9w; 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 5D0A668B485; Tue, 1 Feb 2022 15:09:32 +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-oln040092074079.outbound.protection.outlook.com [40.92.74.79]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D62BC68B360 for ; Tue, 1 Feb 2022 15:09:28 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BYGkx5+28rtTsEWWByxybE0Mo9MsHuwaupOFwIc+q71zoJOg6H/H4MD8huVzrsOUsaWfndXcpWWUJTFokMzeRLJ2saG5T6d8DQjIdmkM+ShiGA41Cn2aTyb75gEQ+tcm9II5ot9zo4rnRXUCPsEjalPHKXyaEG1sOQqjPo2OAb9z8Vwp2R0ZhAr24z6NOrbM1LhUEtwzDGiumyj7gYBNovpqijutNr7DLwrQdAk7/TOUp04hd5KlTbdR/jw0hWr/oTv5qwBnY2I8d4m2FU4Y0xRD4px7lmw0tjAayQmA3787hSERohTJZsq/QEHdzsj2xd8b3HxvjYH171YybJeX4Q== 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=OI6slrNh4T5950gGm0UiYJQWugBVyh+Atsq1A4eeBKI=; b=RSG5v2WhS7SIzpqihntwKEB4XReGWgw4LpYRs9+MufpBxDUXk1v2dROG427df6S96IIUlU7mndE3OBnOARjxdHK/A6Pyp7yIYNzJ/U3MNZZJCT7bN5UdaGX+lhxOR9dGg0stnnVKIBfM57d66rSgNGE7cvND5K40fHhIJgETy6JKuaKkuFohJCNAnybkmXFWYVPEYLiUTiqdevDulTyyTNEDDNh2wSUBEVmKBLjzGiiJdRa4MAr6vw8muAREfn0zMAmYkC2q0axga4I7GhcJPIAVsoYxfwvrpn8t2sREs9Yk8fliewVWC3MB3ramzTZxm0+OP65bUOVDb5bL8w5FPA== 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=OI6slrNh4T5950gGm0UiYJQWugBVyh+Atsq1A4eeBKI=; b=ZekbRk9wz9g7kzwe48YFFTh4w9h2V7OIvCy4KggAI+9r7HVhslBjoB39goxngI4FzTmSa6FwxN95+qIPuch+joOHqxtH8aoslWLHXUCzqDbTRl6mJtxA2La0PejoXXNFmIYxRExna6/YQSJFJC3a/XBBto5C4CH1Aq4FoT5GM2E7FfCuvuIlJwkQDql6VjShr9CGGLl/G3IVuWrHCBg/X2I20TEdu5pVhrVgTr4+EGO/GLiONfoMaj2u7uYe60qp9qSRqpCp3+oynljkkHES681iaOh/700jZzu/VbwULX0rFeM0pkKbIoe+4MWCmG6zC6+c3bCX0MJrlAOYCnT0gQ== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR03MB5025.eurprd03.prod.outlook.com (2603:10a6:208:102::19) 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:09: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:09:27 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:07:06 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [VTVOJUyQxQ/kW9HQIIfMMmM9jmHdAG2E] 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-68-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5e510dcd-02de-4b21-35e3-08d9e584041e X-MS-TrafficTypeDiagnostic: AM0PR03MB5025:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: z2xfpTV5p97IZU3qzaDSGV3ucX2cOk9g/owv7Zft3KrjrSLt2fzkRMXVTwGHfgtfznHSZEiQJTzngxzfK+E+YJYNpfXknol48jhpuClMu6cr1rqSBtBPU1Ga9RoaOOG3W9rQztAfPGYGGLhZ9mSe7HprXMIolh6rnR5ivps6Aywv5aUQrt1wn2LZjO/x926ExUoEEnzNbY6vSPByC9Q+EUqzZrX+lZnPNGpoaOFAxHlfL1sYkMsipTXFqRMCif10Uk+xLx8MUEUfwTgxg0LuakJFs9P1LwXgD84izociZg6puuXbFW4vSssyS/r8FA0zaEAjH1fSWE7ACXvyNuEILGhUpVWtXVaOK34z8p3r70IXjvfq9NF4Lw5tjbYQAa8e1Z68jTk5Npk6NPr/N7FfuOYOcM2/h6ZGxJ/vh0L/l0LRH9ZrIgwZycmeau8aiQ8ySiJH2co/7nI+Ey7IqxjsP7vZdPSa2YX3WZGEnzPeLTGxAAzX400KJCfK/CzSqnDKIE4DVIWluq+oeqpn/HPlLL7//4L9vub3JfB3hPdPnhg= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2/OGomu4ATkkfB8+FbZFMxZfcd2gRVdGujyeOG/lixQWjHkBrQNmrrJIxr4dy1KM/TLMnsnRC+MFC5aCmOjZ7+M7FksG8BsNghxajNRRjeKELZS/yXmdD3OOISDo4kNAdpW4l5wBagbTYdSJu7WYARzPSLPWIo9eyU7n14kDwet2YvXozeoAXCnslzeIrEG6WRABsCK9tqlwGi+jGYdvWbhxm5DixZfBgLZEotcLfrueB4/frQYNzYhygUmKrX+P2IKZGxFZDVMw9nN4hN9/OsD6Qb1maDV151mI38ekDxNqpaRu130zxEH6BCT9ikhsYlVw0BQ63lFZtEnxay9vpaZm1Ag+T8V0kMZyIc0GdDXNqcEvGZ8HDNI/RpCV5rnu6SiKu6UOlUbQtLhWFq9FyBFenj856ZAK7WlBq5qbR7L1jMtQxvj4arpBZJqa+tiLnIbMQiP41I91k0FWk6Y0DBh+X463/ljk1cGR47pz00bGOoCANAM2Ij49P8w5mhIl/4yt1HVSL/XeAA8jOqjdhCozBYFAZpBEYRm85nsCDTF2XvqANvA2SR1VgArP+zSf71mTB9ZApJJGfMHAP6+mqZoWxE49sIwmyxu3wre+RLLJxPIwriTYu/j+kQTo3F5ryy6oPF+VDwczaj3xlEXcNBpnBzWrlC5eSKkRB7h8RFqFk7HeiTFd2lVQXpycDmjdWKBWXDQYmfzEj4BI6LFY/RrEsyCenohP91hy94trLikVdfoijEF866yXUnN8MhER05KQUJWDq8HDe3CZuu1RMiyQv9VNqzoSn7VhvgjSGW3BYcfUvtY/P54Ba5/P5i05CFKiGwXtRhQfW1ZfkYy8mIkTw/LhYkybCv4F2ULU33+nPpRf8+IlSBzAYApfoXfWQ/SVjrisGUsoQYVxyn/a+LXkUbDriukcclWVRa6hZlVlIOfISjxkDz8Udm3alY7Ug6OUiOdPZw0/aJ9jfqIF5g== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e510dcd-02de-4b21-35e3-08d9e584041e 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:09:01.8119 (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: AM0PR03MB5025 Subject: [FFmpeg-devel] [PATCH v2 69/69] avcodec/mpegvideo: Move picture array to MPVMainContext 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: h6u3wYtAIG5E Also avoid an allocation while at it. Signed-off-by: Andreas Rheinhardt --- libavcodec/h263dec.c | 7 ++--- libavcodec/mpegvideo.c | 14 +++------- libavcodec/mpegvideo.h | 5 +++- libavcodec/mpegvideo_dec.c | 54 +++++++++++++++++++------------------- libavcodec/mpegvideo_enc.c | 12 ++++----- 5 files changed, 45 insertions(+), 47 deletions(-) diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index b502878a4a..dc09d2e15c 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -431,7 +431,8 @@ int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { MPVMainDecContext *const m = avctx->priv_data; - MPVDecContext *const s = &m->s; + MPVMainContext *const m2 = m; + MPVDecContext *const s = &m2->s; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; int ret; @@ -547,10 +548,10 @@ retry: } if (!s->current_picture_ptr || s->current_picture_ptr->f->data[0]) { - int i = ff_find_unused_picture(s->avctx, s->picture, 0); + int i = ff_find_unused_picture(s->avctx, m2->picture, 0); if (i < 0) return i; - s->current_picture_ptr = &s->picture[i]; + s->current_picture_ptr = &m2->picture[i]; } avctx->has_b_frames = !s->low_delay; diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index c8eaafcc1c..7314f1b39e 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -645,7 +645,6 @@ static void clear_context(MPVMainContext *m) s->bitstream_buffer = NULL; s->allocated_bitstream_buffer_size = 0; - s->picture = NULL; for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) s->p_field_mv_table[i][j] = NULL; @@ -713,11 +712,9 @@ av_cold int ff_mpv_common_init(MPVMainContext *m) if (ret) return ret; - if (!FF_ALLOCZ_TYPED_ARRAY(s->picture, MAX_PICTURE_COUNT)) - return AVERROR(ENOMEM); for (i = 0; i < MAX_PICTURE_COUNT; i++) { - s->picture[i].f = av_frame_alloc(); - if (!s->picture[i].f) + m->picture[i].f = av_frame_alloc(); + if (!m->picture[i].f) goto fail_nomem; } @@ -801,11 +798,8 @@ void ff_mpv_common_end(MPVMainContext *m) if (!s->avctx) return; - if (s->picture) { - for (int i = 0; i < MAX_PICTURE_COUNT; i++) - ff_mpv_picture_free(s->avctx, &s->picture[i]); - } - av_freep(&s->picture); + for (int i = 0; i < MAX_PICTURE_COUNT; i++) + ff_mpv_picture_free(s->avctx, &m->picture[i]); ff_mpv_picture_free(s->avctx, &s->last_picture); ff_mpv_picture_free(s->avctx, &s->current_picture); ff_mpv_picture_free(s->avctx, &s->next_picture); diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index af1d9af2bd..ba081a9087 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -110,7 +110,6 @@ typedef struct MPVContext { int mb_num; ///< number of MBs of a picture 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 /** bit output */ PutBitContext pb; @@ -498,6 +497,10 @@ typedef struct MPVContext { typedef struct MPVMainContext { MPVContext s; + /* The main picture buffer. The pictures therein are usable iff + * the context is initialized. */ + Picture picture[MAX_PICTURE_COUNT]; + int context_initialized; /* flag to indicate a reinitialization is required, e.g. after * a frame size change */ diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c index 137b47efa7..8f3c401aff 100644 --- a/libavcodec/mpegvideo_dec.c +++ b/libavcodec/mpegvideo_dec.c @@ -111,12 +111,11 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst, m->coded_picture_number = m1->coded_picture_number; s->picture_number = s1->picture_number; - av_assert0(!s->picture || s->picture != s1->picture); - if (s->picture) + if (m->context_initialized) for (int i = 0; i < MAX_PICTURE_COUNT; i++) { - ff_mpeg_unref_picture(s->avctx, &s->picture[i]); - if (s1->picture && s1->picture[i].f->buf[0] && - (ret = ff_mpeg_ref_picture(s->avctx, &s->picture[i], &s1->picture[i])) < 0) + ff_mpeg_unref_picture(s->avctx, &m->picture[i]); + if (m1->context_initialized && m1->picture[i].f->buf[0] && + (ret = ff_mpeg_ref_picture(s->avctx, &m->picture[i], &m1->picture[i])) < 0) return ret; } @@ -138,9 +137,9 @@ do {\ #define REBASE_PICTURE(pic, new_ctx, old_ctx) \ ((pic) ? &(new_ctx)->picture[(pic) - (old_ctx)->picture] : NULL) - s->last_picture_ptr = REBASE_PICTURE(s1->last_picture_ptr, s, s1); - s->current_picture_ptr = REBASE_PICTURE(s1->current_picture_ptr, s, s1); - s->next_picture_ptr = REBASE_PICTURE(s1->next_picture_ptr, s, s1); + s->last_picture_ptr = REBASE_PICTURE(s1->last_picture_ptr, m, m1); + s->current_picture_ptr = REBASE_PICTURE(s1->current_picture_ptr, m, m1); + s->next_picture_ptr = REBASE_PICTURE(s1->next_picture_ptr, m, m1); // Error/bug resilience s->workaround_bugs = s1->workaround_bugs; @@ -208,9 +207,8 @@ int ff_mpv_common_frame_size_change(MPVMainDecContext *m) ff_mpv_free_context_frame(m2); - if (s->picture) - for (int i = 0; i < MAX_PICTURE_COUNT; i++) - s->picture[i].needs_realloc = 1; + for (int i = 0; i < MAX_PICTURE_COUNT; i++) + m2->picture[i].needs_realloc = 1; s->last_picture_ptr = s->next_picture_ptr = @@ -283,7 +281,8 @@ static void gray_frame(AVFrame *frame) */ int ff_mpv_frame_start(MPVMainDecContext *m, AVCodecContext *avctx) { - MPVDecContext *const s = &m->s; + MPVMainContext *const m2 = m; + MPVDecContext *const s = &m2->s; Picture *pic; int idx, ret; @@ -304,10 +303,10 @@ int ff_mpv_frame_start(MPVMainDecContext *m, AVCodecContext *avctx) /* release forgotten pictures */ /* if (MPEG-124 / H.263) */ for (int i = 0; i < MAX_PICTURE_COUNT; i++) { - if (&s->picture[i] != s->last_picture_ptr && - &s->picture[i] != s->next_picture_ptr && - s->picture[i].reference && !s->picture[i].needs_realloc) { - ff_mpeg_unref_picture(s->avctx, &s->picture[i]); + if (&m2->picture[i] != s->last_picture_ptr && + &m2->picture[i] != s->next_picture_ptr && + m2->picture[i].reference && !m2->picture[i].needs_realloc) { + ff_mpeg_unref_picture(s->avctx, &m2->picture[i]); } } @@ -317,8 +316,8 @@ int ff_mpv_frame_start(MPVMainDecContext *m, AVCodecContext *avctx) /* release non reference frames */ for (int i = 0; i < MAX_PICTURE_COUNT; i++) { - if (!s->picture[i].reference) - ff_mpeg_unref_picture(s->avctx, &s->picture[i]); + if (!m2->picture[i].reference) + ff_mpeg_unref_picture(s->avctx, &m2->picture[i]); } if (s->current_picture_ptr && !s->current_picture_ptr->f->buf[0]) { @@ -326,12 +325,12 @@ int ff_mpv_frame_start(MPVMainDecContext *m, AVCodecContext *avctx) // (maybe it was set before reading the header) pic = s->current_picture_ptr; } else { - idx = ff_find_unused_picture(s->avctx, s->picture, 0); + idx = ff_find_unused_picture(s->avctx, m2->picture, 0); if (idx < 0) { av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n"); return idx; } - pic = &s->picture[idx]; + pic = &m2->picture[idx]; } pic->reference = 0; @@ -390,12 +389,12 @@ int ff_mpv_frame_start(MPVMainDecContext *m, AVCodecContext *avctx) "warning: first frame is no keyframe\n"); /* Allocate a dummy frame */ - idx = ff_find_unused_picture(s->avctx, s->picture, 0); + idx = ff_find_unused_picture(s->avctx, m2->picture, 0); if (idx < 0) { av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n"); return idx; } - s->last_picture_ptr = &s->picture[idx]; + s->last_picture_ptr = &m2->picture[idx]; s->last_picture_ptr->reference = 3; s->last_picture_ptr->f->key_frame = 0; @@ -432,12 +431,12 @@ int ff_mpv_frame_start(MPVMainDecContext *m, AVCodecContext *avctx) if ((!s->next_picture_ptr || !s->next_picture_ptr->f->buf[0]) && s->pict_type == AV_PICTURE_TYPE_B) { /* Allocate a dummy frame */ - idx = ff_find_unused_picture(s->avctx, s->picture, 0); + idx = ff_find_unused_picture(s->avctx, m2->picture, 0); if (idx < 0) { av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n"); return idx; } - s->next_picture_ptr = &s->picture[idx]; + s->next_picture_ptr = &m2->picture[idx]; s->next_picture_ptr->reference = 3; s->next_picture_ptr->f->key_frame = 0; @@ -562,13 +561,14 @@ void ff_mpeg_draw_horiz_band(MPVDecContext *s, int y, int h) void ff_mpeg_flush(AVCodecContext *avctx) { MPVMainDecContext *const m = avctx->priv_data; - MPVDecContext *const s = &m->s; + MPVMainContext *const m2 = m; + MPVDecContext *const s = &m2->s; - if (!s->picture) + if (!m2->context_initialized) return; for (int i = 0; i < MAX_PICTURE_COUNT; i++) - ff_mpeg_unref_picture(s->avctx, &s->picture[i]); + ff_mpeg_unref_picture(s->avctx, &m2->picture[i]); s->current_picture_ptr = s->last_picture_ptr = s->next_picture_ptr = NULL; ff_mpeg_unref_picture(s->avctx, &s->current_picture); diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index d3e52126d7..1d1cd6e3d3 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -1123,11 +1123,11 @@ static int load_input_picture(MPVMainEncContext *m, const AVFrame *pic_arg) ff_dlog(s->avctx, "%d %d %"PTRDIFF_SPECIFIER" %"PTRDIFF_SPECIFIER"\n", pic_arg->linesize[0], pic_arg->linesize[1], s->linesize, s->uvlinesize); - i = ff_find_unused_picture(s->avctx, s->picture, direct); + i = ff_find_unused_picture(s->avctx, com->picture, direct); if (i < 0) return i; - pic = &s->picture[i]; + pic = &com->picture[i]; pic->reference = 3; if (direct) { @@ -1571,10 +1571,10 @@ no_output_pic: // one & ensure that the shared one is reuseable Picture *pic; - int i = ff_find_unused_picture(s->avctx, s->picture, 0); + int i = ff_find_unused_picture(s->avctx, m2->picture, 0); if (i < 0) return i; - pic = &s->picture[i]; + pic = &m2->picture[i]; pic->reference = m->reordered_input_picture[0]->reference; if (alloc_picture(s, pic, 0) < 0) { @@ -1967,8 +1967,8 @@ vbv_retry: /* release non-reference frames */ for (i = 0; i < MAX_PICTURE_COUNT; i++) { - if (!s->picture[i].reference) - ff_mpeg_unref_picture(avctx, &s->picture[i]); + if (!m2->picture[i].reference) + ff_mpeg_unref_picture(avctx, &m2->picture[i]); } av_assert1((m->frame_bits & 7) == 0); From patchwork Wed Feb 2 06:01:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34071 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp1266387iov; Tue, 1 Feb 2022 22:02:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJz5E/vC0TAg4snTlZXAGPhI672qMlJgMriHVTpVG056zoOfhZZsjQ7+Xb1rQ7nzhNcF6FY2 X-Received: by 2002:a05:6402:2052:: with SMTP id bc18mr28254094edb.63.1643781740455; Tue, 01 Feb 2022 22:02: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 cq4si10993384edb.132.2022.02.01.22.02.19; Tue, 01 Feb 2022 22:02: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=GVFIVym+; 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 E789768A631; Wed, 2 Feb 2022 08:02:14 +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-oln040092067012.outbound.protection.outlook.com [40.92.67.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1BC2D68A631 for ; Wed, 2 Feb 2022 08:02:07 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LTaWev8eYXaLMqHlr5Z6xSmkx+1jUjRSW2Ocx3XgTGB6y1Mnbhnb9LlRO8R/xgELpJktXxyTEXgu1+U7Xof9ksRvOpJRTF8+0OmwfpR8/CA4SsYc3RJFEdwHncYK1NxOz7bSqj5LHi/Ssti+gsa4lbDW4HEsdmvyuA6Ul6aQHs1Et1uFSoPoHc195pRkaO3eNPKJ1dk3P8HnMAUJ2cBgpR5x0s/doZO6FGl9yJlsMapA+D4jsGiIJM75aorLq96Zun7YVdh/15ktag4I4T63K+abmcUQWHWDKHa/8DrbR1l2TpaRPBdWuLludQTmVe0JvTn6bSwLFJv6mFynRQJEKw== 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=NFVa8Uy4R3zBhW9mI+4ufC9PRWqQa3gFhdMF+nxTbzM=; b=H10VIFUXVTJYWYQGP/1u7PzVCVvmFGlq/5QIFiqYTFbKMe2I5LEJWbeohXLcegRzwUIU51bU5nvOElQ+TCQAF/ZiXLhy3/GAWfSvD6GFQmKVNFR7/48lU7W10xjQbWoi6mV7toyjTscOeILRTY9xvS9EtZDx5JfLvWu07AACSAKr8OrDo7BcVjE769xkXKcdEYScdfU1s177RuZTmYvyg84ofMWvk7BTO7s+0jP2d1T99lqBxXuWkxRqKAG9DKlSAHrUhb2L9CpWzTl5JgdwzzEf2oqf7hIrEbGFfjk6kp+3ift3RFN+qwLxbv0UXCy/Ebi4Q8/lhPJdkNcanjSu1Q== 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=NFVa8Uy4R3zBhW9mI+4ufC9PRWqQa3gFhdMF+nxTbzM=; b=GVFIVym+OCo0RZNzC0NdGehICNa5Kix0RH8htLfhjLtGAxMVW7GOvEReg2eo9TTnfpZcyGw2duFW8K55Nqkr/RJ/7P5UpWyqby8Casy/6Bx6u0oS3epCQAEE5i0qZc9I306tlhUPEGwjn7ZZfiNqNVSvsz4eCSTaXuN18wULR0oBcXtUc+HncqrtBK10OFci9e1oRDoBDQDNYhvBdGG/ra3hKXvWf0+eN7ntGjHBTCNX0fCyTUM/yMR/w9UZXrhf+1jdAbLoy3Xq67wie4llfOA3bJciRMGRZDg/7H4rxO2g0TJDzkF0xNQEJ2BUIesZX+lgx3FPkEIEmZ6dxXcl0g== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by VI1PR0302MB2813.eurprd03.prod.outlook.com (2603:10a6:800:e2::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.22; Wed, 2 Feb 2022 06:02:05 +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; Wed, 2 Feb 2022 06:02:05 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 2 Feb 2022 07:01:56 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [Ycp4tcSYzhGoR3jPJGcXJjDAbiicVl7R] X-ClientProxiedBy: AS9PR06CA0280.eurprd06.prod.outlook.com (2603:10a6:20b:45a::17) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220202060158.1636121-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 697fc757-9744-4593-2caa-08d9e61189e7 X-MS-TrafficTypeDiagnostic: VI1PR0302MB2813:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jsrF0Gz8Lt/cEpsjL1GvOwmrfqtECVXV4k1r3r5HPnsWOiQykKOYjnZsUwGhOhxy/+2jra3ZBjzUmo5dr4C6keaL3tbhzIPlvlR4uIc+OlU0JUNGSeDUckwodeRQRaGPinXTafbQCIBEIroOKSl2rmZIdcaU1nbAH/cgTmT58lPjEQqkvtUe2dawyytRefvU4H8BWrgiSKiOEgGn0LhHYtVZ1Em9ZOHYOKxZ0rj4KnS/M0tZMvZ3sfIadMJeuk9nPDwuEBLhxwChoVA03utjUyO1QuvNgvg1sBxEvlc9UomayLq7g9bFUM/yBtcjuvSzvhDZ+BCR5EebCV69d/42Q7ZmEcG5KbNfvi0atWJ4ZB4DRb/WHgPgMVYJ7TKHfSYWU07wlmenhJ+q/BJ+yNaHGxCHXw9TA8w1zCXrYdJuuc8IfWcWhTTCCuJnYF1HSX1c/btt+0spbaIff6FXr9U2T2rvpz4hyoHtpvT26M/Gjkaqhc0hTGX0KzsWT5cui0AwuD4wucRG16YajK2g4iwK85/un4X8b72svsB9j8zm4We12za9pVQNzhC1zB3hnCnn X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1lIzqjYRtStuCoubMHwBPBftnkkq4girjJ9StAXgzWOpZ6pSwSI3ZiueCpQwYpyvGFv5icb01JL4ENvFHIweqLh9uqzCgbKtrAKGvNr8R3GcLWcuL21Uyjtht6xR/RjXVNr8fQG2Gp0uoe9022W/HmNipvl2GRrxziCNe0r4rYcCwPdHSlkkzqzn7YEpI5aKjqATNqVHIsfTEBA9v76b2Nx8PCM1VaNpybmZ1hLS81SUFvtgMcL87EA8G25UqMBYWCh0aSp76pkvUV9La23OgEiAxoRRu/EGI5bCAUgpcT2HhEoRzpX6bNVbr4uvpEcfHl/2UVVMubsiuXs074ClBnHb/BHua1mKMBc5d89cDyWF99MRaX7b4po3S7tta0p2QNJsDPsZBsE0Fo/VRQoYu5mh5o4VHngrllft3AGAR/B6o/grIe2yxh8/i/ipX2iPErwyuFS5M3zEYZCpEFvIqlevrjdLyxxbVblswQx3UnwlC13cSomfgrzV/JnPgebYMH0HQPKQ/hjEnALtXH0Rec4Mvvz4kHXQ3i83WjSMHjQe6T4ET4KwaOXvkJEeXbbRPkdHMSG0ZLw5twehqIJfOtVDqJ4Qo4VofuK8p70zQZA8rVz0TNdxy+z77NvJ7mEvTobgG3x6MiuBq3oj8F7IzK+C0kX96jI6XQ0h2Z7TtUmyBx57R4/6dhacr+9M8zccu9i46QiEooQauH3esJ0+nqOZI7WAnAg2ITv5I2I46pP+yPqGcyaIctTKsZWa81GmWUj5CST7QfwSWwuFmtrWVi6CJ7CygVeyKJtY+e6S6TIdYOWEiM4iJV9Bqz+XKCcMXuJJfPwdZakg1A22DCCfiQEtzYSJuekHe4zS6zbcUGuUeOV0pmX8urp8HZsP/Z1MXvjEtG0RcvE4H9Q2iwKAVhdrJaamOFdLZtUd6PodQV6mNq2riuLH9Pduh+27gA6n+zvnRlZYTfIEt+ViWoaMhA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 697fc757-9744-4593-2caa-08d9e61189e7 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2022 06:02:05.4752 (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: VI1PR0302MB2813 Subject: [FFmpeg-devel] [PATCH 70/72] avcodec/mpegpicture: Don't check for DELAYED_PIC_REF 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: mAuwreYyHOMg It is not set any more by any user of mpegvideo/mpegpicture. Signed-off-by: Andreas Rheinhardt --- I think that needs_realloc could also be removed now that the buffers that this flag is all about are refcounted. libavcodec/mpegpicture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c index 07fc79685c..4f39cf89ba 100644 --- a/libavcodec/mpegpicture.c +++ b/libavcodec/mpegpicture.c @@ -418,7 +418,7 @@ static inline int pic_is_unused(Picture *pic) { if (!pic->f->buf[0]) return 1; - if (pic->needs_realloc && !(pic->reference & DELAYED_PIC_REF)) + if (pic->needs_realloc) return 1; return 0; } From patchwork Wed Feb 2 06:01:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34072 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp1266485iov; Tue, 1 Feb 2022 22:02:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJx/q6YeJJbWrSCfq5q+VUYEcOkK1ZWi4gJj2+/FW2TCdKb6Ak4/T/8l0lBi4OCtRN4088We X-Received: by 2002:a17:907:968f:: with SMTP id hd15mr15633137ejc.208.1643781749889; Tue, 01 Feb 2022 22:02: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 z12si12493469edc.406.2022.02.01.22.02.29; Tue, 01 Feb 2022 22:02: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=SBxKaabG; 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 191D368AF81; Wed, 2 Feb 2022 08:02:20 +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-oln040092067012.outbound.protection.outlook.com [40.92.67.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3C27568B195 for ; Wed, 2 Feb 2022 08:02:13 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZelGYQS0Tn+N3IR9mQlUff6rl8E/ST73kKTcFXlM7XqOOahQsvEYZpfgp1zQ+nU0uzf23/zWwasWu/4F/YdjNrHj2e7422BwPOvQf477nHmsJJ/ZtJZMN1z2M+Yue1kwTRhg8KgfAc6+Pn9HBSmD0In8JS69NXWfE1D8FyLJVAAVoAyRJs5nQ/hGjdf4YIAEEc3Yd7R/Ji0U3ZziCyq9AAFk+ktfhjnLRo0S2uwp0ZA1l4VPT1C6Od6MZ4GkQVVQ32M+HuexDf1tMRYxpiBfMsFW6gjmADq+t9JQhyZxe6C9eq1ar/Di63gsXqyltKueUJ9yR5dnLff4P4ca4gNRQw== 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=z2zIAGlayOlV8Uc9K88nNWqxuJE8r5MxFe/jLwUayeQ=; b=XqlCoUUqas0CXLJNyH0We9ZLdKexJvyj6+6exUJ6g1840erLgmxw5sopjeZwiev6wQwXS5QpnL4A8FfF5RqDejUKUaz6A35bMShib8SE0PzH/WsqAqdK2wfmmpqPKSbhMnTKvkjTe8U9G92yFwBOsbxt3H8Be4sXVszuae0qgWBVQl6tTWzAPBT+XQM9/+cowlMc3pw6cIgc+wBYzHiuLIGHivZUIdf87WUGoYTx/Qp1i8iyFfdKC/MZD4IapWli120WIbw3Z1y5AszO4kHKnB1svUoS+0epBFKm8KUKc4KjMPCVSQi2i9ZMxAZD444IdQzYAXNJpxreX78uECLdkg== 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=z2zIAGlayOlV8Uc9K88nNWqxuJE8r5MxFe/jLwUayeQ=; b=SBxKaabGDO3wWdTTUmm+fa0VA6EoCvWmRYormbxbDHy+EWMo+Z5Y+krCzuu99yOYvqRhJUP2Bm0lhiZGAe2bQmeHuhW8smuOqj4K4HP5gomtrLrOzcw4Zz6IGu0WBEB6KoqusPIr1IM2Prpljkc+N5UsgAXn94BYyKAexeGc8zZxlfc4GJCwkGw+7P+EGzV6D3v+ILmkEFynp3UePIVnvumQ96Xq2NDCwb3PbIts3AEgCar7BOzzvO91fG33jgzRinu+8vW8coL3GdilRKOKWAIxsPWmMwA4N+QNrBY5DfEqObjlNBQ8J1/+g1xPMeYTe1tyRrwThDljSjOQ6H7f5Q== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by VI1PR0302MB2813.eurprd03.prod.outlook.com (2603:10a6:800:e2::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.22; Wed, 2 Feb 2022 06:02:07 +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; Wed, 2 Feb 2022 06:02:07 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 2 Feb 2022 07:01:57 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [zPikoPYXbE0hOMQFlpLzgpigUM6aHKhv] X-ClientProxiedBy: AS9PR06CA0280.eurprd06.prod.outlook.com (2603:10a6:20b:45a::17) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220202060158.1636121-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 440b7541-95c9-4d0e-9724-08d9e6118b43 X-MS-TrafficTypeDiagnostic: VI1PR0302MB2813:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tnYG0Q+EzkL6sdv74NPqlEMBC0WhhBAIzVTh+MOJlruFMrORPezTh3F0m4otHgq2kSVE6DbozfxaoV0kIJ8yzi9Vk3vGPZAWzFdBSB1l6EKjbfzABSp37cyJXx4LkFRsf2NVHHDpOVPa7R2bihwtmM84LsiaqauYx7EAhGkVnn3hN563l/j/ZOMYPuvdrFpiUu83bmKJGwvTGkP9n/wC/e2L6RkyvgOJ7w3myNEy+k2ZLcHi9pG8VZWK2E9/ZUXPbXlbO1lpdc2GcHYYhA2sRSHzakPH38VNM4hZSF7XbpaG52v3wlQ91IUzZeScYYpeYQg3TbokD2PyuTge+Gj6f6L1WTO/nZ2o91XPoPmN8ToecQhthP+P6VeqEv1xz2d/QKIMa+Cw7WKB8YAWXTydfHNbllLK20JcYnjQ5mcrjk/0iIZNuo8SmjEW1h43IdXjNn+h41z0wJSgBMlced4XNOWN19PUX8j6djWWHZ5WJ9obRHIQK6q3FnW5CuaGypBJ9Nd6BYfVGt40g81CkiB2oHGKVMkB145y+p/HS7qhBEHbMC8j9KtWDaxI7456i+tt X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sZKpHzDiI5qJkLwgXVp95/xXznaRgkZj8fGBFbmZA2pOfxnKrPJnTe9o8vWj3pcYpmTl6FmYRQdH9VQR1qSSP0iuN0bWewOrVLncPqKlgV01wNb119LYdmhO9Kx/j1WUuUxuNUnOWNQ1DU7sTTIEvafE/58UcfeoOp+MZT9t3JMcW0bCqpXWLQCBEzt/4IOtt4QnicyNqv4+D9i0WByMpzuZ26jekjXqUiUgTyqRYF38QeLCuSvCR037IUK0jQsASiZddrvtcxBXl2/mNC61nRMFlPWEjYF2DtZpoRI6VZexLjJm/UUZk59I5ds9h4jEpMsV1AK79v4Jn6Frkwje8rcV1fH64uELu/6dk/K6alkJUUJVv/B3k8GaSH++TEZ5BF2U/Oc2MKrSqC3QhOWbQoq5PVZjqNNbJsFHrSiXZwyjd4+W1FaCH2TbtLyuXyRB22daQd86uCz9dzt8VP3jAnY9B7kfeuWYXRMa8qqcFuaILnPCqesHVbGNzKl31cvPEJ0ZNmkiUqgnvQO6yQLLb6BH1EQ1MtYix/kEZt9qE6nIaPR2v9CsC8jNYAdmi62RCnJkoiLXFa5rpZ/npwxstHIP3v9x6OeNOTbpz4u4HbE9JEffttqF7Lsp+e065EBQ9R+HibcHj4Zo0l4wD6HL9vkoYPOqihJU8VIpLnLBpRbpc+4NGTWwswgi/EZKFzwBQsS0a4YsEd//KzteB2SDsXEr0+NwNKOOdhM+7T/syhRHK45tMeudy4FbUS5lDLtSdH4akYTC+CKwcXH9+w9KA1vqUr7w1cQVR5OdS3HOXWFIqv1t0lK6aZB0/Z3B3s5WZbpBmvdtzFE4NLI7ANKstoIdXK1MAEdmcKetcyUNJ+MTOqy9p3YjQgqLq9+rWLtEkmRpo9kN7BzwZwnNz6wvHaX/4Pk6sejFa0HNWsuc1gkW+xXWJRKezGfrvQuDzV/8A1Z/xRcl1WCtpVDP3xxXOQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 440b7541-95c9-4d0e-9724-08d9e6118b43 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2022 06:02:07.6493 (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: VI1PR0302MB2813 Subject: [FFmpeg-devel] [PATCH 71/72] avcodec/mpegutils.h: Move DELAYED_PIC_REF macro to h264dec.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: ASVg6Ra0ZHzG It is only used by the H.264 decoder (as well as the dirac decoder, which already uses a local copy). Signed-off-by: Andreas Rheinhardt --- libavcodec/h264dec.h | 5 +++++ libavcodec/mpegutils.h | 6 ------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h index 8168c8e97b..2a06d9a092 100644 --- a/libavcodec/h264dec.h +++ b/libavcodec/h264dec.h @@ -139,6 +139,11 @@ typedef struct H264Picture { int mbaff; ///< 1 -> MBAFF frame 0-> not MBAFF int field_picture; ///< whether or not picture was encoded in separate fields +/** + * H264Picture.reference has this flag set, + * when the picture is held for delayed output. + */ +#define DELAYED_PIC_REF (1 << 2) int reference; int recovered; ///< picture at IDR or recovery point + recovery count int invalid_gap; diff --git a/libavcodec/mpegutils.h b/libavcodec/mpegutils.h index 07705854b3..c92f9192db 100644 --- a/libavcodec/mpegutils.h +++ b/libavcodec/mpegutils.h @@ -37,12 +37,6 @@ #define PICT_BOTTOM_FIELD 2 #define PICT_FRAME 3 -/** - * Value of Picture.reference when Picture is not a reference picture, but - * is held for delayed output. - */ -#define DELAYED_PIC_REF 4 - #define MAX_MB_BYTES (30 * 16 * 16 * 3 / 8 + 120) #define MAX_FCODE 7 From patchwork Wed Feb 2 06:01:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34073 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp1266572iov; Tue, 1 Feb 2022 22:02:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJxrEFEESdFi7pDu9CmREYSTmeGNkntLviyRDHEpOKOFl35bFGZT+xfsZcXsN8FXYRQbR9hA X-Received: by 2002:a05:6402:1543:: with SMTP id p3mr28698543edx.273.1643781760136; Tue, 01 Feb 2022 22:02: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 se21si8543188ejb.330.2022.02.01.22.02.39; Tue, 01 Feb 2022 22:02: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=PpUpuZAF; 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 24A6C68B384; Wed, 2 Feb 2022 08:02:25 +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-oln040092067012.outbound.protection.outlook.com [40.92.67.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5D1A168AE25 for ; Wed, 2 Feb 2022 08:02:18 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G31yy+5LjvUhhAS9OsLmhW0mcEBQjTzLpUWadGJGEAlKRtwg6UAEDhqgr1vUADLynw/XbIyNPODy9NCQ7iSwpaXQqKXcAO6LoDHNzktv+ZO9aJqIvFM8p8U+X5Du0L3OJPmDmdhNm7iOjIZjqIwMhb91v1YzG4AVoXAhZcjnbpaRtc5enXvy59VaKeR9hFzwlIRvBjfR6YSxk6TtutxPtS5jqDwxcWznhKorHE6/OZdeke7U3WXwOM0+OmdrDkKfeza2lETP1ACC7Wt5OVVbOSW93absSRF3fQlS3nU1qEM4oeGsinn3PuRDwZ/bQHOiQ45RmLa9gGi43fuqle9bzQ== 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=Iyg/CvDu2oTARWDO1Tn1/v+ZjffmJRbqfWlUbW5Qa+s=; b=Mph3CTglpcJJVbJ3k2RRvwDCEDm26THdoEYfzhum3hbbRPZAev7l9egqivAwDJXlAzt54Zl7qATHjkkCxedXHC+uF38PI2DkXcVTStgNeCVAbbHd0oWZ13gkHqV98CuI1bD9BCWZnHyUxynhyPW7a22mtHh8DDzUkGtGudDa+wNYrcuQFs4jBhrz+vwdP2zDfFqZM17H1npwb+hG4w+AmNhpI7MIbidwR1a10BRAkqLZMHEZmIP8v66bAglVSiRYZuhYhGPVhlGTAywn27c5BalpE6W0EPB9q+57fRdQNkj1+0rVk7pRN2zcDsUa+Sih4WgSjP7GNQfEqTu82OTg4A== 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=Iyg/CvDu2oTARWDO1Tn1/v+ZjffmJRbqfWlUbW5Qa+s=; b=PpUpuZAFEfiGCrO2cAULvDAbuVNGhVqdZj64LtbR7i29voxe1Kr1rXlkFKSKiPEtBhfvDMX7SaUAufDHlyvMjLLOOf1LRFwIo/prlvJIF8UgEt/MZC1H4JAtpVcr2PWQCe/REbOsfSjoOwZT71lqe6EW/FUnQbzSCLhApSHdEl+u3lShPY85/Va4tgBx5LZ+RfUTpNIo9qoI363o4AQ3f36O2H8pB4lnpckF54MpVrlpumod0KmLoalzyTNL92rg1OFBSIpOv/F5Bg1cGtfjgxYdPZ6KM43XIMUyTpuNGT7YlH7RXfw9n7nawOookivzEsXZL/81fx7APX2KdyRYfw== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by VI1PR0302MB2813.eurprd03.prod.outlook.com (2603:10a6:800:e2::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.22; Wed, 2 Feb 2022 06:02:09 +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; Wed, 2 Feb 2022 06:02:09 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 2 Feb 2022 07:01:58 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [HE2c1zKnBn9uzfEYphR9yv50xC68DyMz] X-ClientProxiedBy: AS9PR06CA0280.eurprd06.prod.outlook.com (2603:10a6:20b:45a::17) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220202060158.1636121-3-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5b83f424-e477-4442-5741-08d9e6118c91 X-MS-TrafficTypeDiagnostic: VI1PR0302MB2813:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JCPu7PyE0Q7bPi2/cC84dCdkNiMIjpDQdqCSrM7i4HEZvF4FdxHY3F4Ynh+bTHAJG5g24CFM9PK81A5l0dmQ93y36OmKOU3PXSao3Zlzn507pnZe9cRw/i2zIK0lpi2pRt0I0xLduwzfVIqgL3NwsKiXhproNWAMFj84JV0rrstDg7voMhziEip73dWkWcYlY7Ls5R2KCzcRDKqI6pSM+9gI1e6DPNa8ovKE76ZU3Mvgs5RkuUwLxKnHbZjVjskImW+Hx5KsIj4pryubdcS5dnd9p/JIW8yeSg3q+LUwtRFbzZuCg0TAj8zX30mJHlYb87oGT596omEJu9utwAIGSzHxpxe6CkNpOJZlC/xuXcLQYNxrydkozgldIMT0zoP73GJg/93M+KuTnxcwVJPJzIlzaUlhK/0LOaETybzeZPIo5T6eHwuORJTk3yLDlK6kVwDyqrUuwOZpRcoIt+XTD93ADav8QIAk62MKYlMKZLo85Mh9TYnd1m3mOqty6hb9V/WvBQGL9tLUThBNEiN2ztzZYG/VG1cs6YMXbJ/NqChZ564m9dg7/4BiCI/mNV+H X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fJFchEIVXh6/dsdOE/CZl5FXCHbTeDWr1QezZ+FISvu1CDP+w9nl/gt+bx29ccMGD26MfL8/I4znB6nEAQuARkiWt6ogcChHKTSCqghQCFyjEjX4fZ5+kkI5eu99fL685CATQqTsDpLxVTjxYnZvYDYUKAarwY4V7LIcBhOJa5KpTFno+Vy6l2mBr+lYUbasallxS0G01e3q3tC2xg1RG9dbrrWgzNRyaeVRRRRrfrlYeiUZxFWrBjuNijdO1x5Yc7+pbauGaEfKAINiDZem+Ik/LL8lXUeEAAAC7+UmmEV4hyT7oMxh34LFzZfpdfXZpsa3jIzRcd1np7ZWDpGw7M1+6vDGhc08OUdgE77mtpJK8D/P9WwwrgD9Ai8M02QORz5mdf38/RLgStUVNy1xlScIpsjlwXUG086wUblQxzAJ/6jZaR+9/WsH/IEXqSrMUkQ1r5FedFFq/yTfvkkOGXKMrA22FoI3pn4HXvnXcKjY/tjLrx0wPFlwlBF2q0BA4hfMB4llfcJ40+wCQdnn4XXDNisaHOCy4PGa5Fgrv9WtHlJ0KI+eyjH3Rw2NSDxYKAq/8Agzm8mt4ykRmlawMYzjdLjdXBzUBWU1LS6Lp/vldGWVASUDoff2a5Xr2cI1yC1ezfEn0tdtTHqSBl4f+D1/e7/mIkUyMuAIxISyEltIUXZQ9Czwp3R6kbLAAf6EHyhnIqDyTuyQ77Z13II9uuwYPIw66j2GAyV7pvvZmY9qU9XVJjWD0iZqLsNaafYuRkhvd4VC/fB1l+QqVUZ1U9D/NWXf2B11TLRIFjc25gYm15ZxFNKjrSAHEmT2yc62CGPE8G3xj2XcIgmTPX2Xodl356NPBUeUpo3+XZZa1bJsFqtm9PeWvBu2sB9ZspP+ntXA1c8iYr52RVsNxhnPLuh5Jn5Y91PFOe81yNZ0UK/BPIl6OT+LOeRgIQvGbYwolZO5+CZftfoJy937K7FnNw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5b83f424-e477-4442-5741-08d9e6118c91 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2022 06:02:09.8053 (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: VI1PR0302MB2813 Subject: [FFmpeg-devel] [PATCH 72/72] avcodec/mpegvideo: Make new_picture an ordinary AVFrame 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: abcA3BerDTHF It is currently a "Picture", an mpegvideo-specific type that has a lot of baggage, all of which is unnecessary for new_picture, because only its embedded AVFrame is ever used. So just use an ordinary AVFrame. Signed-off-by: Andreas Rheinhardt --- libavcodec/motion_est.c | 12 ++++----- libavcodec/mpeg4videoenc.c | 2 +- libavcodec/mpegvideo.c | 4 +-- libavcodec/mpegvideo.h | 4 +-- libavcodec/mpegvideo_enc.c | 50 +++++++++++++++++++------------------- libavcodec/snowenc.c | 2 +- libavcodec/svq1enc.c | 4 +-- 7 files changed, 39 insertions(+), 39 deletions(-) diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index 3df1e4f40a..69e1455c3e 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -681,7 +681,7 @@ static inline int h263_mv4_search(MPVEncContext *s, int mx, int my, int shift) if (s->mecc.me_sub_cmp[0] != s->mecc.mb_cmp[0]) { dmin_sum += s->mecc.mb_cmp[0](s, - s->new_picture.f->data[0] + + s->new_picture->data[0] + s->mb_x * 16 + s->mb_y * 16 * stride, c->scratchpad, stride, 16); } @@ -705,8 +705,8 @@ static inline int h263_mv4_search(MPVEncContext *s, int mx, int my, int shift) s->hdsp.put_pixels_tab [1][dxy](c->scratchpad + 8, s->last_picture.f->data[2] + offset, s->uvlinesize, 8); } - dmin_sum += s->mecc.mb_cmp[1](s, s->new_picture.f->data[1] + s->mb_x * 8 + s->mb_y * 8 * s->uvlinesize, c->scratchpad, s->uvlinesize, 8); - dmin_sum += s->mecc.mb_cmp[1](s, s->new_picture.f->data[2] + s->mb_x * 8 + s->mb_y * 8 * s->uvlinesize, c->scratchpad + 8, s->uvlinesize, 8); + dmin_sum += s->mecc.mb_cmp[1](s, s->new_picture->data[1] + s->mb_x * 8 + s->mb_y * 8 * s->uvlinesize, c->scratchpad, s->uvlinesize, 8); + dmin_sum += s->mecc.mb_cmp[1](s, s->new_picture->data[2] + s->mb_x * 8 + s->mb_y * 8 * s->uvlinesize, c->scratchpad + 8, s->uvlinesize, 8); } c->pred_x= mx; @@ -895,7 +895,7 @@ void ff_estimate_p_frame_motion(MPVEncContext *s, int mb_type=0; Picture * const pic= &s->current_picture; - init_ref(c, s->new_picture.f->data, s->last_picture.f->data, NULL, 16*mb_x, 16*mb_y, 0); + init_ref(c, s->new_picture->data, s->last_picture.f->data, NULL, 16*mb_x, 16*mb_y, 0); av_assert0(s->quarter_sample==0 || s->quarter_sample==1); av_assert0(s->linesize == c->stride); @@ -1066,7 +1066,7 @@ int ff_pre_estimate_p_frame_motion(MPVEncContext *s, int P[10][2]; const int shift= 1+s->quarter_sample; const int xy= mb_x + mb_y*s->mb_stride; - init_ref(c, s->new_picture.f->data, s->last_picture.f->data, NULL, 16*mb_x, 16*mb_y, 0); + init_ref(c, s->new_picture->data, s->last_picture.f->data, NULL, 16*mb_x, 16*mb_y, 0); av_assert0(s->quarter_sample==0 || s->quarter_sample==1); @@ -1495,7 +1495,7 @@ void ff_estimate_b_frame_motion(MPVEncContext *s, int fmin, bmin, dmin, fbmin, bimin, fimin; int type=0; const int xy = mb_y*s->mb_stride + mb_x; - init_ref(c, s->new_picture.f->data, s->last_picture.f->data, + init_ref(c, s->new_picture->data, s->last_picture.f->data, s->next_picture.f->data, 16 * mb_x, 16 * mb_y, 2); get_limits(s, 16*mb_x, 16*mb_y); diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index 2f78763344..81fbd918ca 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -646,7 +646,7 @@ void ff_mpeg4_encode_mb(MPVEncContext *s, int16_t block[6][64], y = s->mb_y * 16; offset = x + y * s->linesize; - p_pic = s->new_picture.f->data[0] + offset; + p_pic = s->new_picture->data[0] + offset; s->mb_skipped = 1; for (i = 0; i < m->max_b_frames; i++) { diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 7314f1b39e..d0fbdaf1b4 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -721,7 +721,7 @@ av_cold int ff_mpv_common_init(MPVMainContext *m) if (!(s->next_picture.f = av_frame_alloc()) || !(s->last_picture.f = av_frame_alloc()) || !(s->current_picture.f = av_frame_alloc()) || - !(s->new_picture.f = av_frame_alloc())) + !(s->new_picture = av_frame_alloc())) goto fail_nomem; if ((ret = ff_mpv_init_context_frame(m))) @@ -803,7 +803,7 @@ void ff_mpv_common_end(MPVMainContext *m) ff_mpv_picture_free(s->avctx, &s->last_picture); ff_mpv_picture_free(s->avctx, &s->current_picture); ff_mpv_picture_free(s->avctx, &s->next_picture); - ff_mpv_picture_free(s->avctx, &s->new_picture); + av_frame_free(&s->new_picture); m->context_initialized = 0; m->context_reinit = 0; diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index ba081a9087..2d5ee61a27 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -130,10 +130,10 @@ typedef struct MPVContext { Picture next_picture; /** - * copy of the source picture structure for encoding. + * Reference to the source picture for encoding. * note, linesize & data, might not match the source picture (for field pictures) */ - Picture new_picture; + AVFrame *new_picture; /** * copy of the current picture structure. diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 1d1cd6e3d3..ddfd123c46 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -995,7 +995,7 @@ av_cold int ff_mpv_encode_end(AVCodecContext *avctx) 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); + av_frame_free(&s->new_picture); av_freep(&avctx->stats_out); @@ -1555,15 +1555,15 @@ static int select_input_picture(MPVMainEncContext *m) } } no_output_pic: - ff_mpeg_unref_picture(s->avctx, &s->new_picture); + av_frame_unref(s->new_picture); if (m->reordered_input_picture[0]) { m->reordered_input_picture[0]->reference = m->reordered_input_picture[0]->f->pict_type != AV_PICTURE_TYPE_B ? 3 : 0; - if ((ret = ff_mpeg_ref_picture(s->avctx, &s->new_picture, - m->reordered_input_picture[0]))) + if ((ret = av_frame_ref(s->new_picture, + m->reordered_input_picture[0]->f))) return ret; if (m->reordered_input_picture[0]->shared || s->avctx->rc_buffer_size) { @@ -1594,8 +1594,8 @@ no_output_pic: // input is not a shared pix -> reuse buffer for current_pix s->current_picture_ptr = m->reordered_input_picture[0]; for (i = 0; i < 4; i++) { - if (s->new_picture.f->data[i]) - s->new_picture.f->data[i] += INPLACE_OFFSET; + if (s->new_picture->data[i]) + s->new_picture->data[i] += INPLACE_OFFSET; } } ff_mpeg_unref_picture(s->avctx, &s->current_picture); @@ -1603,7 +1603,7 @@ no_output_pic: s->current_picture_ptr)) < 0) return ret; - s->picture_number = s->new_picture.f->display_picture_number; + s->picture_number = s->new_picture->display_picture_number; } return 0; } @@ -1761,7 +1761,7 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, } /* output? */ - if (s->new_picture.f->data[0]) { + if (s->new_picture->data[0]) { int growing_buffer = context_count == 1 && !pkt->data && !s->data_partitioning; int pkt_size = growing_buffer ? FFMAX(s->mb_width*s->mb_height*64+10000, avctx->internal->byte_buffer_size) - AV_INPUT_BUFFER_PADDING_SIZE : @@ -1785,7 +1785,7 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, init_put_bits(&m2->thread_context[i]->pb, start, end - start); } - s->pict_type = s->new_picture.f->pict_type; + s->pict_type = s->new_picture->pict_type; //emms_c(); ret = frame_start(m); if (ret < 0) @@ -2151,11 +2151,11 @@ static av_always_inline void encode_mb_internal(MPVEncContext *s, wrap_y = s->linesize; wrap_c = s->uvlinesize; - ptr_y = s->new_picture.f->data[0] + + ptr_y = s->new_picture->data[0] + (mb_y * 16 * wrap_y) + mb_x * 16; - ptr_cb = s->new_picture.f->data[1] + + ptr_cb = s->new_picture->data[1] + (mb_y * mb_block_height * wrap_c) + mb_x * mb_block_width; - ptr_cr = s->new_picture.f->data[2] + + ptr_cr = s->new_picture->data[2] + (mb_y * mb_block_height * wrap_c) + mb_x * mb_block_width; if((mb_x * 16 + 16 > s->width || mb_y * 16 + 16 > s->height) && s->codec_id != AV_CODEC_ID_AMV){ @@ -2645,18 +2645,18 @@ static int sse_mb(MPVEncContext *s) if(w==16 && h==16) if(s->avctx->mb_cmp == FF_CMP_NSSE){ - return s->mecc.nsse[0](s, s->new_picture.f->data[0] + s->mb_x * 16 + s->mb_y * s->linesize * 16, s->dest[0], s->linesize, 16) + - s->mecc.nsse[1](s, s->new_picture.f->data[1] + s->mb_x * 8 + s->mb_y * s->uvlinesize * 8, s->dest[1], s->uvlinesize, 8) + - s->mecc.nsse[1](s, s->new_picture.f->data[2] + s->mb_x * 8 + s->mb_y * s->uvlinesize * 8, s->dest[2], s->uvlinesize, 8); + return s->mecc.nsse[0](s, s->new_picture->data[0] + s->mb_x * 16 + s->mb_y * s->linesize * 16, s->dest[0], s->linesize, 16) + + s->mecc.nsse[1](s, s->new_picture->data[1] + s->mb_x * 8 + s->mb_y * s->uvlinesize * 8, s->dest[1], s->uvlinesize, 8) + + s->mecc.nsse[1](s, s->new_picture->data[2] + s->mb_x * 8 + s->mb_y * s->uvlinesize * 8, s->dest[2], s->uvlinesize, 8); }else{ - return s->mecc.sse[0](NULL, s->new_picture.f->data[0] + s->mb_x * 16 + s->mb_y * s->linesize * 16, s->dest[0], s->linesize, 16) + - s->mecc.sse[1](NULL, s->new_picture.f->data[1] + s->mb_x * 8 + s->mb_y * s->uvlinesize * 8, s->dest[1], s->uvlinesize, 8) + - s->mecc.sse[1](NULL, s->new_picture.f->data[2] + s->mb_x * 8 + s->mb_y * s->uvlinesize * 8, s->dest[2], s->uvlinesize, 8); + return s->mecc.sse[0](NULL, s->new_picture->data[0] + s->mb_x * 16 + s->mb_y * s->linesize * 16, s->dest[0], s->linesize, 16) + + s->mecc.sse[1](NULL, s->new_picture->data[1] + s->mb_x * 8 + s->mb_y * s->uvlinesize * 8, s->dest[1], s->uvlinesize, 8) + + s->mecc.sse[1](NULL, s->new_picture->data[2] + s->mb_x * 8 + s->mb_y * s->uvlinesize * 8, s->dest[2], s->uvlinesize, 8); } else - return sse(s, s->new_picture.f->data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], w, h, s->linesize) - +sse(s, s->new_picture.f->data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], w>>1, h>>1, s->uvlinesize) - +sse(s, s->new_picture.f->data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], w>>1, h>>1, s->uvlinesize); + return sse(s, s->new_picture->data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], w, h, s->linesize) + +sse(s, s->new_picture->data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], w>>1, h>>1, s->uvlinesize) + +sse(s, s->new_picture->data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], w>>1, h>>1, s->uvlinesize); } static int pre_estimate_motion_thread(AVCodecContext *c, void *arg){ @@ -2711,7 +2711,7 @@ static int mb_var_thread(AVCodecContext *c, void *arg){ for(mb_x=0; mb_x < s->mb_width; mb_x++) { int xx = mb_x * 16; int yy = mb_y * 16; - uint8_t *pix = s->new_picture.f->data[0] + (yy * s->linesize) + xx; + uint8_t *pix = s->new_picture->data[0] + (yy * s->linesize) + xx; int varc; int sum = s->mpvencdsp.pix_sum(pix, s->linesize); @@ -3433,13 +3433,13 @@ static int encode_thread(AVCodecContext *c, void *arg){ if(s->mb_y*16 + 16 > s->height) h= s->height- s->mb_y*16; s->current_picture.encoding_error[0] += sse( - s, s->new_picture.f->data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, + s, s->new_picture->data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], w, h, s->linesize); s->current_picture.encoding_error[1] += sse( - s, s->new_picture.f->data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*chr_h, + s, s->new_picture->data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*chr_h, s->dest[1], w>>1, h>>s->chroma_y_shift, s->uvlinesize); s->current_picture.encoding_error[2] += sse( - s, s->new_picture.f->data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*chr_h, + s, s->new_picture->data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*chr_h, s->dest[2], w>>1, h>>s->chroma_y_shift, s->uvlinesize); } if(s->loop_filter){ diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index 7200d94f65..fa0bb77994 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -1653,7 +1653,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, mpv->avctx= s->avctx; mpv-> last_picture.f = s->last_picture[0]; - mpv-> new_picture.f = s->input_picture; + mpv-> new_picture = s->input_picture; mpv-> last_picture_ptr= &mpv-> last_picture; mpv->linesize = stride; mpv->uvlinesize= s->current_picture->linesize[1]; diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c index 3a84bb6a07..64c856ddb5 100644 --- a/libavcodec/svq1enc.c +++ b/libavcodec/svq1enc.c @@ -278,7 +278,7 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane, mpv->last_picture.f->data[0] = ref_plane; mpv->linesize = mpv->last_picture.f->linesize[0] = - mpv->new_picture.f->linesize[0] = + mpv->new_picture->linesize[0] = mpv->current_picture.f->linesize[0] = stride; mpv->width = width; mpv->height = height; @@ -328,7 +328,7 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane, mpv->me.dia_size = s->avctx->dia_size; mpv->first_slice_line = 1; for (y = 0; y < block_height; y++) { - mpv->new_picture.f->data[0] = src - y * 16 * stride; // ugly + mpv->new_picture->data[0] = src - y * 16 * stride; // ugly mpv->mb_y = y; for (i = 0; i < 16 && i + 16 * y < height; i++) { From patchwork Thu Feb 3 01: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: 34081 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp2043167iov; Wed, 2 Feb 2022 17:07:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJxDE5uOp1cS6sisZeytWwRETXD1UzWLyZe7u6EEYQ7RWtFDk0rUaISiHt2UcnPDHR8S5na/ X-Received: by 2002:a17:907:3d9f:: with SMTP id he31mr26852527ejc.605.1643850424726; Wed, 02 Feb 2022 17:07: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 z7si11258929edr.286.2022.02.02.17.07.03; Wed, 02 Feb 2022 17:07: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=ETyFYHyX; 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 685AA68B0E4; Thu, 3 Feb 2022 03:06:55 +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-oln040092074042.outbound.protection.outlook.com [40.92.74.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 44DAB68AEC7 for ; Thu, 3 Feb 2022 03:06:49 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nbX8WoBvb/PaVWgorLfAujGuuXwZFgzenGRhePA4BUcHmi1owZEXyb8hqikVGILlMy8h+/0k9Cbs/50Qns9rsZD4dMwgCBjaygA5FTECJ0eCWoBycvDF+1swKpijYgtuHN+MhZLlHRQfYpOuzrAhK/EX1CVm7CiKowPQmzlKnCj3ZKi0SzEGu6zkUTueikuCJA8luIhEs8TTMBlyYSIvYT2c8bMj//DmJb7HD1cF2ghCQQJqLKMvVSocH9glejzLoI1IVFDTCUmzjA3zrdVD0/8dhqPr1PReKDozCbCgt+VHEQFUIJap6t6Bil0NuB35RgwpYAS5qREZ9PAyQQU3qw== 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=oY8/A/gi1w5rUHdGQjjI04e+kUV4W4aS7H7Y7EpkOxE=; b=IHmdIZs2PJgXR7pIH11yvg5EYfshu7cIxMB+600c55eYkY0roj/KmFExInzxnJvU7flG4w+Fq0VOBeUCkQyDsuazBZxteDnQcDryQ6o0VW71l2vWxW2CLYuMLUEzr9kyhjturhYgJ3IUA+sjhmBaML00ViW8rd27+0TZjjzutTEDvbfZamseOdJTNl9FADJpQFDIabyJPn/jMTseqfoi0tzdt0ntIp4tAaZr8pxRVvvHmOt4FgA0jvGAY7WGi6/vaAP+cpIyggKWfmHc+FtSIgH9v5E+s4Ua4lXZiX49DMSitLbGSkcU2OCmDluU1ByOGy14ShAGIUMvF+bbrwRYxg== 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=oY8/A/gi1w5rUHdGQjjI04e+kUV4W4aS7H7Y7EpkOxE=; b=ETyFYHyXYTfVbjjo/+d/3uL6tUzrXdyUw6pc14booToUPl0WE0wpacN5zjgJ7asSkNHgb8sleJLaYjL4IyEAUCm5LDUDgJaV628tCs/8IR1QPgRBN6tIdUmMoJkSFl1aK1kHC3k9Wmy0Q31pUnCb8fDZtoPBMrGt4Yz9gpB1F0o9tiWdohg9r+KnNt5rpNE74YfdefzrTjqPXsAAQMDbNcmVC1iCR0WM+XOGRMVN+RSFHhytHg5M4mUNTJXOllQAcdFwPArjUxUR+mScB1y+L/o5IZ1Va48Vvu/1BZ06Ot5WnQWYGv3lTvw75YUubSvYg1vmuMxNDV8mZlgP6tpMEw== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR0302MB3203.eurprd03.prod.outlook.com (2603:10a6:208:11::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.22; Thu, 3 Feb 2022 01:06:40 +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; Thu, 3 Feb 2022 01:06:40 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 3 Feb 2022 02:06:24 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [I6cAn1FhmU88aMzPsDt/zF1NkOMt5qrK] X-ClientProxiedBy: AS8PR04CA0125.eurprd04.prod.outlook.com (2603:10a6:20b:127::10) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220203010631.1929837-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a7e945ef-6fa9-4b2c-7810-08d9e6b16eb3 X-MS-Exchange-SLBlob-MailProps: +LiGfBxqLEs6bi2B2Md8122fePlSqn4e/SWDZso4xSgsF9PDrLsy9iMrWI+d6ofSnWBNsGTo6KxGHeS4H1eWdMsIIpzz0AdO/SE1t3HTEYCrtAMI74X3QW/+pbjbIhLoBZcH3rnK3GC4bcd7Ump/lf5a7CtCSIrTweP9ACP223KC+XF58iI2h0Z76eqCqmaVND/k0iDokmHpIxHP672MuQ1JwIufPoItBktlDWXLG8gyVuwIAlsfIDI6SvM+0p8pk3NUvinHiz6MhHUeHNNUSqHT/Av9eV9d+4rWkMHKQaVu7HxUAL7gMl6Ja3PTnGG+8hwqt62cTy0XDULiI+9DAV3wf/vTFVl4XOY8ip/BpSmL3qGtJAdK76fT4cJGulE6xE39DmDHRVEoxtCuWIrGomMCDKMFnj7tJERf7Z++nKpdFaz7fWvWkxeswoDgiOCluqq8XgfPxqJMyb1otgjNP/W1Ab0S/YfWBrM8Y96OGZdyK2tFmwYbUtF0dxIO55US+7buI0v1RN1fayUAaSmMd4r9EbtSUlL4B34Dtej6Y+4ZdrtY92PIwuNoa18tITmmxe2btLI8G+M+kba49mvUAnQ7XBw+6vJsRqQdrIExq4xyEBsF24ziV59uSVT+VqzkJ9xXV+a7bOu+rSZoa7P828smAHwEAFsmZrP0KwlI6McTf54cIf/irxpOIqSVCDRHjnR/3qWZwevp56tWbIF+d97sG6Xr3OuaoM9vrwEKiMebrask/KBTebYwUW7qMXNSkbT6JKXOwXXYEqylJR4nRmuMT58h85uz X-MS-TrafficTypeDiagnostic: AM0PR0302MB3203:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: V0iot54/PJWQuf9NfxVHsd8WlJ/8ZSThpwpdRYH6arTYUo0qIv88rhwaz8srnaV948GN5NB8USCIwYK5oHF2f6+JG43m6qiysHrRZ+6yVAkzWawawee9lgbsGHVFyLzGdkbJq+Wbg8H0JNvYs9fIJ78szunodcjXlOHKGdHApuUYMHgR1leUVjFjq8kK2Z8YxGX6wFI/ldStnmZCa1VHkHqdCqWMBPUJt7ZDSfq6MUZvmlabJcBWIencBOz3TpwLMXxQLna6DrQYlVTuW50yUCuQwY9BJ5xCN6j1QzPvz+ahzkzmJFnN/Kr26AlEiqK1qOaUSwM4HbhVbveXoeMK3FsNK5GQaQCMK6K79aZmsvQwP8sGfV85bG6VdIc/drU4BJJ/wPchnXxBf6T/1DQNJ9Bqpd3djJ8GfFme0AjxAAOAtsda8LSUFOjmG29ysLX3SAVoDgD6FfR+aH05lZ1TB9w8ov17CvxdCcHqJjiChOKFPHWmKDtMCP+HvXdugDOdHJBG7yL7AwaoeSdv7r5jBLdWo8OCmKbjxReLxX1bJbXboYDLSnXByldkShe3oa3FXhM30qTPIf31ByZ+ADiLBg== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OL5xSiUSYin3h/SsVNo7A4U5+DnrnyWzsdwZ3wvL0p30WGKLV3P0Y+6QSU8WIvUo6p4z5FA/W2MDobPWIppINJT+OpFpzw+/J+PJcIh6GUWm8u/WPJ4LgHeNKH+9DFYABUB7nM2kwLO44t1jBzjCBrTFmhebzxzU4OxGaEtMBBtdra3uWMIPEAOU8aTAXCatVhs0EoiEV90rDSaBnNjoyqK6NXm0ARryRb3mwG55PdCehKTn+FOJLVbptdX6+X6yMaqH9jJhQwjdLf9vW7cmJf2C3BlX/IplJzTq4DtPUJdk6lsYpzyro2/pdCqMkY7/kpnNfWPxBodkbDmEoR9gv8rN25VCsAp3L+qRnSB/PE/pJJxoRgRd8EVQx0QTdNsGPy/Hc7l32M/wS6N1hDRDEzAVAzb2lD1Czu524g7iWnMX7TOmbpZW54FTkMrkQEFjJDJvrIWDC2nxuVwHM53H8tzghepGKVvT1D+cgEtXQKqOpTinsWETlqoYleygCS2FIQszmszcbc2hII9T32/rnYb+x+5Gpu0eI/hzz7+CRD2bc+w7u3kim4E/U7qGELnY5toiFdud6nLuMZ5y6ZeF2qpld2VjOrUG3Vobjy6GFoZAb2fMv4auiD0wOp8F6D4HG77PdUONv0bZvUDyMj79JdCN5t7tPm0Ndj/3Vr9q81JFcnD9ofo2FBdYt01GfVz2Gp8MouEk9P90BLhrMBU7os/N5G5Q0Ys48KYyE0ilNgy0oF3PQRxiyuzvIMAZhx2GP4XILEOWwYeTPfPPNNZ2Tq5Ca60twrxHuOqRdRfOnFmNx9cQr0Pfl0R6tgNiYtjL4YWLdF5/99Lw2LrQSKPggP/ItkrGlxzk4hTdnoyiXynqI9SSvQw85DFsDYj1k1VEFoHvQgjbE3IqpPZlUlNt26eLkbF0uON8CQzafrOYMFsdOYktkX+ONLwo0IgfE9ufHzn52FlnOqTkxD9YsnBKhw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a7e945ef-6fa9-4b2c-7810-08d9e6b16eb3 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2022 01:06:40.4383 (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: AM0PR0302MB3203 Subject: [FFmpeg-devel] [PATCH 73/80] avcodec/h263dec.h: Add H263DecContext 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: S63GaVGtIwGl This is in preparation for moving fields only used by h263dec-based decoders from MPVContext. Signed-off-by: Andreas Rheinhardt --- libavcodec/dxva2_vc1.c | 16 +++++------ libavcodec/flvdec.c | 6 ++-- libavcodec/flvdec.h | 4 +-- libavcodec/h263dec.c | 34 ++++++++++++----------- libavcodec/h263dec.h | 10 +++++-- libavcodec/intelh263dec.c | 8 +++--- libavcodec/ituh263dec.c | 10 +++---- libavcodec/mpeg4video_parser.c | 6 ++-- libavcodec/mpeg4videodec.c | 51 +++++++++++++++++++--------------- libavcodec/mpeg4videodec.h | 3 +- libavcodec/msmpeg4dec.c | 21 +++++++------- libavcodec/msmpeg4dec.h | 5 ++-- libavcodec/mss2.c | 8 +++--- libavcodec/nvdec_mpeg4.c | 3 +- libavcodec/nvdec_vc1.c | 4 +-- libavcodec/rv10.c | 10 ++++--- libavcodec/vaapi_mpeg4.c | 2 +- libavcodec/vaapi_vc1.c | 50 ++++++++++++++++----------------- libavcodec/vc1.c | 24 ++++++++-------- libavcodec/vc1.h | 4 +-- libavcodec/vc1_block.c | 40 +++++++++++++------------- libavcodec/vc1_loopfilter.c | 28 +++++++++---------- libavcodec/vc1_mc.c | 14 +++++----- libavcodec/vc1_parser.c | 8 +++--- libavcodec/vc1_pred.c | 22 +++++++-------- libavcodec/vc1dec.c | 16 +++++------ libavcodec/vdpau_mpeg4.c | 2 +- libavcodec/vdpau_vc1.c | 6 ++-- libavcodec/wmv2dec.c | 28 +++++++++---------- libavcodec/wmv2dec.h | 5 ++-- 30 files changed, 234 insertions(+), 214 deletions(-) diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c index d901f023df..e30b432fc6 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 MPVDecContext *const s = &v->s.s; + const MPVDecContext *const s = &v->h.m.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 MPVDecContext *const s = &v->s.s; + const MPVDecContext *const s = &v->h.m.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 MPVDecContext *const s = &v->s.s; + const MPVDecContext *const s = &v->h.m.s; struct dxva2_picture_context *ctx_pic = s->current_picture_ptr->hwaccel_picture_private; static const uint8_t start_code[] = { 0, 0, 1, 0x0d }; @@ -313,7 +313,7 @@ static int dxva2_vc1_start_frame(AVCodecContext *avctx, { const VC1Context *v = avctx->priv_data; AVDXVAContext *ctx = DXVA_CONTEXT(avctx); - struct dxva2_picture_context *ctx_pic = v->s.s.current_picture_ptr->hwaccel_picture_private; + struct dxva2_picture_context *ctx_pic = v->h.m.s.current_picture_ptr->hwaccel_picture_private; if (!DXVA_CONTEXT_VALID(avctx, ctx)) return -1; @@ -332,7 +332,7 @@ static int dxva2_vc1_decode_slice(AVCodecContext *avctx, uint32_t size) { const VC1Context *v = avctx->priv_data; - const Picture *current_picture = v->s.s.current_picture_ptr; + const Picture *current_picture = v->h.m.s.current_picture_ptr; struct dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private; unsigned position; @@ -360,18 +360,18 @@ static int dxva2_vc1_decode_slice(AVCodecContext *avctx, static int dxva2_vc1_end_frame(AVCodecContext *avctx) { VC1Context *v = avctx->priv_data; - struct dxva2_picture_context *ctx_pic = v->s.s.current_picture_ptr->hwaccel_picture_private; + struct dxva2_picture_context *ctx_pic = v->h.m.s.current_picture_ptr->hwaccel_picture_private; int ret; if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0) return -1; - ret = ff_dxva2_common_end_frame(avctx, v->s.s.current_picture_ptr->f, + ret = ff_dxva2_common_end_frame(avctx, v->h.m.s.current_picture_ptr->f, &ctx_pic->pp, sizeof(ctx_pic->pp), NULL, 0, commit_bitstream_and_slice_buffer); if (!ret) - ff_mpeg_draw_horiz_band(&v->s.s, 0, avctx->height); + ff_mpeg_draw_horiz_band(&v->h.m.s, 0, avctx->height); return ret; } diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c index 469a8ceae9..3c14f2c54c 100644 --- a/libavcodec/flvdec.c +++ b/libavcodec/flvdec.c @@ -26,9 +26,9 @@ #include "mpegvideodata.h" #include "mpegvideodec.h" -int ff_flv_decode_picture_header(MPVMainDecContext *m) +int ff_flv_decode_picture_header(H263DecContext *h) { - MPVDecContext *const s = &m->s; + MPVDecContext *const s = &h->m.s; int format, width, height; /* picture header */ @@ -119,7 +119,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(MPVMainDecContext), + .priv_data_size = sizeof(H263DecContext), .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 9cbd178192..7a9c9ff5c0 100644 --- a/libavcodec/flvdec.h +++ b/libavcodec/flvdec.h @@ -21,8 +21,8 @@ #ifndef AVCODEC_FLVDEC_H #define AVCODEC_FLVDEC_H -#include "mpegvideodec.h" +#include "h263dec.h" -int ff_flv_decode_picture_header(MPVMainDecContext *m); +int ff_flv_decode_picture_header(H263DecContext *m); #endif /* AVCODEC_FLVDEC_H */ diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index dc09d2e15c..4327aec54d 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -75,7 +75,8 @@ static enum AVPixelFormat h263_get_format(AVCodecContext *avctx) av_cold int ff_h263_decode_init(AVCodecContext *avctx) { - MPVMainDecContext *const m = avctx->priv_data; + H263DecContext *const h = avctx->priv_data; + MPVMainDecContext *const m = &h->m; MPVDecContext *const s = &m->s; int ret; @@ -168,9 +169,9 @@ 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(MPVMainDecContext *m, int buf_size) +static int get_consumed_bytes(H263DecContext *h, int buf_size) { - MPVDecContext *const s = &m->s; + MPVDecContext *const s = &h->m.s; int pos = (get_bits_count(&s->gb) + 7) >> 3; if (s->divx_packed || s->avctx->hwaccel) { @@ -430,6 +431,7 @@ static int decode_slice(MPVMainDecContext *m) int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { + H263DecContext *const h = avctx->priv_data; MPVMainDecContext *const m = avctx->priv_data; MPVMainContext *const m2 = m; MPVDecContext *const s = &m2->s; @@ -505,9 +507,9 @@ retry: /* let's go :-) */ if (CONFIG_WMV2_DECODER && s->msmpeg4_version == 5) { - ret = ff_wmv2_decode_picture_header(m); + ret = ff_wmv2_decode_picture_header(h); } else if (CONFIG_MSMPEG4_DECODER && s->msmpeg4_version) { - ret = ff_msmpeg4_decode_picture_header(m); + ret = ff_msmpeg4_decode_picture_header(h); } else if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) { if (s->avctx->extradata_size && s->picture_number == 0) { GetBitContext gb; @@ -517,11 +519,11 @@ retry: } ret = ff_mpeg4_decode_picture_header(avctx->priv_data, &s->gb, 0, 0); } else if (CONFIG_H263I_DECODER && s->codec_id == AV_CODEC_ID_H263I) { - ret = ff_intel_h263_decode_picture_header(m); + ret = ff_intel_h263_decode_picture_header(h); } else if (CONFIG_FLV_DECODER && s->h263_flv) { - ret = ff_flv_decode_picture_header(m); + ret = ff_flv_decode_picture_header(h); } else { - ret = ff_h263_decode_picture_header(m); + ret = ff_h263_decode_picture_header(h); } if (ret < 0 || ret == FRAME_SKIPPED) { @@ -533,7 +535,7 @@ retry: } } if (ret == FRAME_SKIPPED) - return get_consumed_bytes(m, buf_size); + return get_consumed_bytes(h, buf_size); /* skip if the header was thrashed */ if (ret < 0) { @@ -601,13 +603,13 @@ retry: /* skip B-frames if we don't have reference frames */ if (!s->last_picture_ptr && (s->pict_type == AV_PICTURE_TYPE_B || s->droppable)) - return get_consumed_bytes(m, buf_size); + return get_consumed_bytes(h, buf_size); if ((avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B) || (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I) || avctx->skip_frame >= AVDISCARD_ALL) - return get_consumed_bytes(m, buf_size); + return get_consumed_bytes(h, buf_size); if ((!s->no_rounding) || s->pict_type == AV_PICTURE_TYPE_B) { s->me.qpel_put = s->qdsp.put_qpel_pixels_tab; @@ -636,7 +638,7 @@ retry: * are stored in current_picture->mb_type which is not available before * ff_mpv_frame_start() */ if (CONFIG_WMV2_DECODER && s->msmpeg4_version == 5) { - ret = ff_wmv2_decode_secondary_picture_header(m); + ret = ff_wmv2_decode_secondary_picture_header(h); if (ret < 0) return ret; if (ret == 1) @@ -671,7 +673,7 @@ retry: if (s->msmpeg4_version && s->msmpeg4_version < 4 && s->pict_type == AV_PICTURE_TYPE_I) if (!CONFIG_MSMPEG4_DECODER || - ff_msmpeg4_decode_ext_header(m, buf_size) < 0) + ff_msmpeg4_decode_ext_header(h, buf_size) < 0) s->er.error_status_table[s->mb_num - 1] = ER_MB_ERROR; av_assert1(s->bitstream_buffer_size == 0); @@ -729,7 +731,7 @@ frame_end: if (slice_ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE)) return slice_ret; else - return get_consumed_bytes(m, buf_size); + return get_consumed_bytes(h, buf_size); } const enum AVPixelFormat ff_h263_hwaccel_pixfmt_list_420[] = { @@ -770,7 +772,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(MPVMainDecContext), + .priv_data_size = sizeof(H263DecContext), .init = ff_h263_decode_init, .close = ff_h263_decode_end, .decode = ff_h263_decode_frame, @@ -791,7 +793,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(MPVMainDecContext), + .priv_data_size = sizeof(H263DecContext), .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 bab3e03fb3..b007372f64 100644 --- a/libavcodec/h263dec.h +++ b/libavcodec/h263dec.h @@ -40,6 +40,10 @@ extern VLC ff_h263_mv_vlc; extern const enum AVPixelFormat ff_h263_hwaccel_pixfmt_list_420[]; +typedef struct H263DecContext { + MPVMainDecContext m; +} H263DecContext; + 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, @@ -47,15 +51,15 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVPacket *avpkt); int ff_h263_decode_end(AVCodecContext *avctx); void ff_h263_decode_init_vlc(void); -int ff_h263_decode_picture_header(MPVMainDecContext *m); +int ff_h263_decode_picture_header(H263DecContext *h); int ff_h263_decode_mba(MPVDecContext *s); /** * Print picture info if FF_DEBUG_PICT_INFO is set. */ -void ff_h263_show_pict_info(MPVMainDecContext *m); +void ff_h263_show_pict_info(H263DecContext *h); -int ff_intel_h263_decode_picture_header(MPVMainDecContext *m); +int ff_intel_h263_decode_picture_header(H263DecContext *h); int ff_h263_decode_mb(MPVDecContext *s, int16_t block[6][64]); diff --git a/libavcodec/intelh263dec.c b/libavcodec/intelh263dec.c index e26d45ec20..deed9152ea 100644 --- a/libavcodec/intelh263dec.c +++ b/libavcodec/intelh263dec.c @@ -26,9 +26,9 @@ #include "mpegvideodata.h" /* don't understand why they choose a different header ! */ -int ff_intel_h263_decode_picture_header(MPVMainDecContext *m) +int ff_intel_h263_decode_picture_header(H263DecContext *h) { - MPVDecContext *const s = &m->s; + MPVDecContext *const s = &h->m.s; int format; if (get_bits_left(&s->gb) == 64) { /* special dummy frames */ @@ -125,7 +125,7 @@ int ff_intel_h263_decode_picture_header(MPVMainDecContext *m) s->y_dc_scale_table= s->c_dc_scale_table= ff_mpeg1_dc_scale_table; - ff_h263_show_pict_info(m); + ff_h263_show_pict_info(h); return 0; } @@ -135,7 +135,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(MPVMainDecContext), + .priv_data_size = sizeof(H263DecContext), .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 9cfdac63d6..9e92ed94ce 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -73,9 +73,9 @@ static const int h263_mb_type_b_map[15]= { MB_TYPE_INTRA4x4 | MB_TYPE_CBP | MB_TYPE_QUANT, }; -void ff_h263_show_pict_info(MPVMainDecContext *m) +void ff_h263_show_pict_info(H263DecContext *h) { - MPVDecContext *const s = &m->s; + MPVDecContext *const s = &h->m.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), @@ -1088,9 +1088,9 @@ end: } /* Most is hardcoded; should extend to handle all H.263 streams. */ -int ff_h263_decode_picture_header(MPVMainDecContext *m) +int ff_h263_decode_picture_header(H263DecContext *h) { - MPVDecContext *const s = &m->s; + MPVDecContext *const s = &h->m.s; int format, width, height, i, ret; uint32_t startcode; @@ -1369,7 +1369,7 @@ int ff_h263_decode_picture_header(MPVMainDecContext *m) s->c_dc_scale_table= ff_mpeg1_dc_scale_table; } - ff_h263_show_pict_info(m); + ff_h263_show_pict_info(h); if (s->pict_type == AV_PICTURE_TYPE_I && s->codec_tag == AV_RL32("ZYGO") && get_bits_left(&s->gb) >= 85 + 13*3*16 + 50){ int i,j; for(i=0; i<85; i++) av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&s->gb)); diff --git a/libavcodec/mpeg4video_parser.c b/libavcodec/mpeg4video_parser.c index a7909d92ec..fc6fffdf99 100644 --- a/libavcodec/mpeg4video_parser.c +++ b/libavcodec/mpeg4video_parser.c @@ -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; - MPVDecContext *const s = &dec_ctx->m.s; + MPVDecContext *const s = &dec_ctx->h.m.s; GetBitContext gb1, *gb = &gb1; int ret; @@ -131,8 +131,8 @@ static av_cold int mpeg4video_parse_init(AVCodecParserContext *s) struct Mp4vParseContext *pc = s->priv_data; pc->first_picture = 1; - pc->dec_ctx.m.s.quant_precision = 5; - pc->dec_ctx.m.slice_context_count = 1; + pc->dec_ctx.h.m.s.quant_precision = 5; + pc->dec_ctx.h.m.slice_context_count = 1; pc->dec_ctx.showed_packed_warning = 1; return 0; } diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index ca6988fc48..854ccd5ade 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -195,7 +195,7 @@ void ff_mpeg4_pred_ac(MPVDecContext *s, int16_t *block, int n, int dir) */ static inline int mpeg4_is_resync(Mpeg4DecContext *ctx) { - MPVDecContext *const s = &ctx->m.s; + MPVDecContext *const s = &ctx->h.m.s; 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) { - MPVDecContext *const s = &ctx->m.s; + MPVDecContext *const s = &ctx->h.m.s; 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) { - MPVDecContext *const s = &ctx->m.s; + MPVDecContext *const s = &ctx->h.m.s; 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) { - MPVDecContext *const s = &ctx->m.s; + MPVDecContext *const s = &ctx->h.m.s; int mb_num_bits = av_log2(s->mb_num - 1) + 1; int header_extension = 0, mb_num, len; @@ -615,7 +615,7 @@ static void reset_studio_dc_predictors(MPVDecContext *s) */ int ff_mpeg4_decode_studio_slice_header(Mpeg4DecContext *ctx) { - MPVDecContext *const s = &ctx->m.s; + MPVDecContext *const s = &ctx->h.m.s; 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) { - MPVDecContext *const s = &ctx->m.s; + MPVDecContext *const s = &ctx->h.m.s; int x, y, mb_v, sum, dx, dy, shift; int len = 1 << (s->f_code + 4); const int a = s->sprite_warping_accuracy; @@ -757,7 +757,7 @@ static inline int mpeg4_decode_dc(MPVDecContext *s, int n, int *dir_ptr) */ static int mpeg4_decode_partition_a(Mpeg4DecContext *ctx) { - MPVDecContext *const s = &ctx->m.s; + MPVDecContext *const s = &ctx->h.m.s; 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(MPVDecContext *s, int mb_count) */ int ff_mpeg4_decode_partitions(Mpeg4DecContext *ctx) { - MPVDecContext *const s = &ctx->m.s; + MPVDecContext *const s = &ctx->h.m.s; 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) { - MPVDecContext *const s = &ctx->m.s; + MPVDecContext *const s = &ctx->h.m.s; int level, i, last, run, qmul, qadd; int av_uninit(dc_pred_dir); RLTable *rl; @@ -2288,7 +2288,7 @@ static void extension_and_user_data(MPVDecContext *s, GetBitContext *gb, int id) static int decode_studio_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) { - MPVMainDecContext *const m = &ctx->m; + MPVMainDecContext *const m = &ctx->h.m; MPVDecContext *const s = &m->s; int width, height, aspect_ratio_info; int bits_per_raw_sample; @@ -2375,7 +2375,8 @@ static int decode_studio_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) { - MPVMainDecContext *const m = &ctx->m; + H263DecContext *const h = &ctx->h; + MPVMainDecContext *const m = &h->m; MPVDecContext *const s = &m->s; int width, height, vo_ver_id, aspect_ratio_info; @@ -2751,7 +2752,8 @@ no_cplx_est: */ static int decode_user_data(Mpeg4DecContext *ctx, GetBitContext *gb) { - MPVDecContext *const s = &ctx->m.s; + H263DecContext *const h = &ctx->h; + MPVDecContext *const s = &h->m.s; char buf[256]; int i; int e; @@ -2809,7 +2811,7 @@ static int decode_user_data(Mpeg4DecContext *ctx, GetBitContext *gb) int ff_mpeg4_workaround_bugs(AVCodecContext *avctx) { Mpeg4DecContext *ctx = avctx->priv_data; - MPVMainDecContext *const m = &ctx->m; + MPVMainDecContext *const m = &ctx->h.m; MPVDecContext *const s = &m->s; if (ctx->xvid_build == -1 && ctx->divx_version == -1 && ctx->lavc_build == -1) { @@ -2928,7 +2930,8 @@ int ff_mpeg4_workaround_bugs(AVCodecContext *avctx) static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb, int parse_only) { - MPVMainDecContext *const m = &ctx->m; + H263DecContext *const h = &ctx->h; + MPVMainDecContext *const m = &h->m; MPVDecContext *const s = &m->s; int time_incr, time_increment; int64_t pts; @@ -3211,7 +3214,7 @@ end: static void decode_smpte_tc(Mpeg4DecContext *ctx, GetBitContext *gb) { - MPVDecContext *const s = &ctx->m.s; + MPVDecContext *const s = &ctx->h.m.s; skip_bits(gb, 16); /* Time_code[63..48] */ check_marker(s->avctx, gb, "after Time_code[63..48]"); @@ -3230,7 +3233,8 @@ static void decode_smpte_tc(Mpeg4DecContext *ctx, GetBitContext *gb) */ static int decode_studio_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb) { - MPVMainDecContext *const m = &ctx->m; + H263DecContext *const h = &ctx->h; + MPVMainDecContext *const m = &h->m; MPVDecContext *const s = &m->s; if (get_bits_left(gb) <= 32) @@ -3286,7 +3290,7 @@ static int decode_studio_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb) static int decode_studiovisualobject(Mpeg4DecContext *ctx, GetBitContext *gb) { - MPVDecContext *const s = &ctx->m.s; + MPVDecContext *const s = &ctx->h.m.s; int visual_object_type; skip_bits(gb, 4); /* visual_object_verid */ @@ -3315,7 +3319,8 @@ static int decode_studiovisualobject(Mpeg4DecContext *ctx, GetBitContext *gb) int ff_mpeg4_decode_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb, int header, int parse_only) { - MPVMainDecContext *const m = &ctx->m; + H263DecContext *const h = &ctx->h; + MPVMainDecContext *const m = &h->m; MPVDecContext *const s = &m->s; unsigned startcode, v; int ret; @@ -3474,7 +3479,8 @@ end: int ff_mpeg4_frame_end(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { Mpeg4DecContext *ctx = avctx->priv_data; - MPVMainDecContext *const m = &ctx->m; + H263DecContext *const h = &ctx->h; + MPVMainDecContext *const m = &h->m; MPVDecContext *const s = &m->s; /* divx 5.01+ bitstream reorder stuff */ @@ -3527,7 +3533,7 @@ static int mpeg4_update_thread_context(AVCodecContext *dst, { Mpeg4DecContext *s = dst->priv_data; const Mpeg4DecContext *s1 = src->priv_data; - int init = s->m.context_initialized; + int init = s->h.m.context_initialized; int ret = ff_mpeg_update_thread_context(dst, src); @@ -3563,7 +3569,7 @@ static int mpeg4_update_thread_context(AVCodecContext *dst, memcpy(s->sprite_traj, s1->sprite_traj, sizeof(s1->sprite_traj)); if (CONFIG_MPEG4_DECODER && !init && s1->xvid_build >= 0) - ff_xvid_idct_init(&s->m.s.idsp, dst); + ff_xvid_idct_init(&s->h.m.s.idsp, dst); return 0; } @@ -3632,7 +3638,8 @@ static av_cold int decode_init(AVCodecContext *avctx) { static AVOnce init_static_once = AV_ONCE_INIT; Mpeg4DecContext *ctx = avctx->priv_data; - MPVMainDecContext *const m = &ctx->m; + H263DecContext *const h = &ctx->h; + MPVMainDecContext *const m = &h->m; MPVDecContext *const s = &m->s; int ret; diff --git a/libavcodec/mpeg4videodec.h b/libavcodec/mpeg4videodec.h index 191fe53836..2d682c0c78 100644 --- a/libavcodec/mpeg4videodec.h +++ b/libavcodec/mpeg4videodec.h @@ -26,11 +26,12 @@ #include #include "get_bits.h" +#include "h263dec.h" #include "mpegvideodec.h" typedef struct Mpeg4DecContext { - MPVMainDecContext m; + H263DecContext h; /// number of bits to represent the fractional part of time int time_increment_bits; diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c index f02181e075..b1f4df7aa9 100644 --- a/libavcodec/msmpeg4dec.c +++ b/libavcodec/msmpeg4dec.c @@ -296,7 +296,8 @@ static int msmpeg4v34_decode_mb(MPVDecContext *s, int16_t block[6][64]) /* init all vlc decoding tables */ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx) { - MPVMainDecContext *const m = avctx->priv_data; + H263DecContext *const h = avctx->priv_data; + MPVMainDecContext *const m = &h->m; MPVDecContext *const s = &m->s; static volatile int done = 0; int ret; @@ -400,9 +401,9 @@ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx) return 0; } -int ff_msmpeg4_decode_picture_header(MPVMainDecContext *m) +int ff_msmpeg4_decode_picture_header(H263DecContext *h) { - MPVDecContext *const s = &m->s; + MPVDecContext *const s = &h->m.s; int code; // at minimum one bit per macroblock is required at least in a valid frame, @@ -469,7 +470,7 @@ int ff_msmpeg4_decode_picture_header(MPVMainDecContext *m) s->dc_table_index = get_bits1(&s->gb); break; case 4: - ff_msmpeg4_decode_ext_header(m, (2+5+5+17+7)/8); + ff_msmpeg4_decode_ext_header(h, (2+5+5+17+7)/8); if(s->bit_rate > MBAC_BITRATE) s->per_mb_rl_table= get_bits1(&s->gb); else s->per_mb_rl_table= 0; @@ -557,9 +558,9 @@ int ff_msmpeg4_decode_picture_header(MPVMainDecContext *m) return 0; } -int ff_msmpeg4_decode_ext_header(MPVMainDecContext *m, int buf_size) +int ff_msmpeg4_decode_ext_header(H263DecContext *h, int buf_size) { - MPVDecContext *const s = &m->s; + MPVDecContext *const s = &h->m.s; int left= buf_size*8 - get_bits_count(&s->gb); int length= s->msmpeg4_version>=3 ? 17 : 16; /* the alt_bitstream reader could read over the end so we need to check it */ @@ -866,7 +867,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(MPVMainDecContext), + .priv_data_size = sizeof(H263DecContext), .init = ff_msmpeg4_decode_init, .close = ff_h263_decode_end, .decode = ff_h263_decode_frame, @@ -884,7 +885,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(MPVMainDecContext), + .priv_data_size = sizeof(H263DecContext), .init = ff_msmpeg4_decode_init, .close = ff_h263_decode_end, .decode = ff_h263_decode_frame, @@ -902,7 +903,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(MPVMainDecContext), + .priv_data_size = sizeof(H263DecContext), .init = ff_msmpeg4_decode_init, .close = ff_h263_decode_end, .decode = ff_h263_decode_frame, @@ -920,7 +921,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(MPVMainDecContext), + .priv_data_size = sizeof(H263DecContext), .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 37f0f090e1..d3b18bbe05 100644 --- a/libavcodec/msmpeg4dec.h +++ b/libavcodec/msmpeg4dec.h @@ -24,6 +24,7 @@ #include "config.h" #include "avcodec.h" +#include "h263dec.h" #include "mpegvideodec.h" #define INTER_INTRA_VLC_BITS 3 @@ -34,8 +35,8 @@ 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(MPVMainDecContext *m); -int ff_msmpeg4_decode_ext_header(MPVMainDecContext *m, int buf_size); +int ff_msmpeg4_decode_picture_header(H263DecContext *h); +int ff_msmpeg4_decode_ext_header(H263DecContext *h, 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); diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c index f650a84e8d..5ee156d56a 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; - MPVMainDecContext *const m = &v->s; + MPVMainDecContext *const m = &v->h.m; MPVDecContext *const s = &m->s; AVFrame *f; int ret; @@ -751,7 +751,7 @@ static av_cold int wmv9_init(AVCodecContext *avctx) VC1Context *v = avctx->priv_data; int ret; - v->s.s.avctx = avctx; + v->h.m.s.avctx = avctx; ff_vc1_init_common(v); @@ -797,8 +797,8 @@ static av_cold int wmv9_init(AVCodecContext *avctx) return ret; /* error concealment */ - v->s.s.me.qpel_put = v->s.s.qdsp.put_qpel_pixels_tab; - v->s.s.me.qpel_avg = v->s.s.qdsp.avg_qpel_pixels_tab; + v->h.m.s.me.qpel_put = v->h.m.s.qdsp.put_qpel_pixels_tab; + v->h.m.s.me.qpel_avg = v->h.m.s.qdsp.avg_qpel_pixels_tab; return 0; } diff --git a/libavcodec/nvdec_mpeg4.c b/libavcodec/nvdec_mpeg4.c index 5c37dba3e4..6d5ac8cd07 100644 --- a/libavcodec/nvdec_mpeg4.c +++ b/libavcodec/nvdec_mpeg4.c @@ -30,7 +30,8 @@ static int nvdec_mpeg4_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) { Mpeg4DecContext *m = avctx->priv_data; - MPVDecContext *const s = &m->m.s; + H263DecContext *const h = &m->h; + MPVDecContext *const s = &h->m.s; 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 e8cae4d724..78b3213e04 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; - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.s; NVDECContext *ctx = avctx->internal->hwaccel_priv_data; CUVIDPICPARAMS *pp = &ctx->pic_params; @@ -87,7 +87,7 @@ static int nvdec_vc1_start_frame(AVCodecContext *avctx, const uint8_t *buffer, u .extended_mv = v->extended_mv, .dquant = v->dquant, .vstransform = v->vstransform, - .loopfilter = v->s.s.loop_filter, + .loopfilter = v->h.m.s.loop_filter, .fastuvmc = v->fastuvmc, .overlap = v->overlap, .quantizer = v->quantizer_mode, diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c index 27e17c8677..1fbd99a965 100644 --- a/libavcodec/rv10.c +++ b/libavcodec/rv10.c @@ -52,7 +52,7 @@ #define DC_VLC_BITS 9 typedef struct RVDecContext { - MPVMainDecContext m; + H263DecContext h; int sub_id; int orig_width, orig_height; } RVDecContext; @@ -157,7 +157,7 @@ static int rv10_decode_picture_header(MPVDecContext *s) static int rv20_decode_picture_header(RVDecContext *rv, int whole_size) { - MPVMainDecContext *const m = &rv->m; + MPVMainDecContext *const m = &rv->h.m; MPVDecContext *const s = &m->s; int seq, mb_pos, i, ret; int rpr_max; @@ -368,7 +368,8 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx) { static AVOnce init_static_once = AV_ONCE_INIT; RVDecContext *rv = avctx->priv_data; - MPVMainDecContext *const m = &rv->m; + H263DecContext *const h = &rv->h; + MPVMainDecContext *const m = &h->m; MPVDecContext *const s = &m->s; int major_ver, minor_ver, micro_ver, ret; @@ -445,7 +446,8 @@ 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; - MPVMainDecContext *const m = &rv->m; + H263DecContext *const h = &rv->h; + MPVMainDecContext *const m = &h->m; MPVDecContext *const s = &m->s; int mb_count, mb_pos, left, start_mb_x, active_bits_size, ret; diff --git a/libavcodec/vaapi_mpeg4.c b/libavcodec/vaapi_mpeg4.c index 0a0c2d0f8e..ccee6fb06e 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; - MPVDecContext *const s = &ctx->m.s; + MPVDecContext *const s = &ctx->h.m.s; VAAPIDecodePicture *pic = s->current_picture_ptr->hwaccel_picture_private; VAPictureParameterBufferMPEG4 pic_param; int i, err; diff --git a/libavcodec/vaapi_vc1.c b/libavcodec/vaapi_vc1.c index fd3b963e33..e8dc79ba62 100644 --- a/libavcodec/vaapi_vc1.c +++ b/libavcodec/vaapi_vc1.c @@ -46,7 +46,7 @@ static inline int vc1_has_MVTYPEMB_bitplane(const VC1Context *v) if (v->mv_type_is_raw) return 0; return v->fcm == PROGRESSIVE && - (v->s.s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) && + (v->h.m.s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) && (v->mv_mode == MV_PMODE_MIXED_MV || (v->mv_mode == MV_PMODE_INTENSITY_COMP && v->mv_mode2 == MV_PMODE_MIXED_MV)); @@ -58,8 +58,8 @@ static inline int vc1_has_SKIPMB_bitplane(const VC1Context *v) if (v->skip_is_raw) return 0; return (v->fcm == PROGRESSIVE || v->fcm == ILACE_FRAME) && - ((v->s.s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) || - (v->s.s.pict_type == AV_PICTURE_TYPE_B && !v->bi_type)); + ((v->h.m.s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) || + (v->h.m.s.pict_type == AV_PICTURE_TYPE_B && !v->bi_type)); } /** Check whether the DIRECTMB bitplane is present */ @@ -68,7 +68,7 @@ static inline int vc1_has_DIRECTMB_bitplane(const VC1Context *v) if (v->dmb_is_raw) return 0; return (v->fcm == PROGRESSIVE || v->fcm == ILACE_FRAME) && - (v->s.s.pict_type == AV_PICTURE_TYPE_B && !v->bi_type); + (v->h.m.s.pict_type == AV_PICTURE_TYPE_B && !v->bi_type); } /** Check whether the ACPRED bitplane is present */ @@ -77,8 +77,8 @@ static inline int vc1_has_ACPRED_bitplane(const VC1Context *v) if (v->acpred_is_raw) return 0; return v->profile == PROFILE_ADVANCED && - (v->s.s.pict_type == AV_PICTURE_TYPE_I || - (v->s.s.pict_type == AV_PICTURE_TYPE_B && v->bi_type)); + (v->h.m.s.pict_type == AV_PICTURE_TYPE_I || + (v->h.m.s.pict_type == AV_PICTURE_TYPE_B && v->bi_type)); } /** Check whether the OVERFLAGS bitplane is present */ @@ -87,8 +87,8 @@ static inline int vc1_has_OVERFLAGS_bitplane(const VC1Context *v) if (v->overflg_is_raw) return 0; return v->profile == PROFILE_ADVANCED && - (v->s.s.pict_type == AV_PICTURE_TYPE_I || - (v->s.s.pict_type == AV_PICTURE_TYPE_B && v->bi_type)) && + (v->h.m.s.pict_type == AV_PICTURE_TYPE_I || + (v->h.m.s.pict_type == AV_PICTURE_TYPE_B && v->bi_type)) && (v->overlap && v->pq <= 8) && v->condover == CONDOVER_SELECT; } @@ -99,8 +99,8 @@ static inline int vc1_has_FIELDTX_bitplane(const VC1Context *v) if (v->fieldtx_is_raw) return 0; return v->fcm == ILACE_FRAME && - (v->s.s.pict_type == AV_PICTURE_TYPE_I || - (v->s.s.pict_type == AV_PICTURE_TYPE_B && v->bi_type)); + (v->h.m.s.pict_type == AV_PICTURE_TYPE_I || + (v->h.m.s.pict_type == AV_PICTURE_TYPE_B && v->bi_type)); } /** Check whether the FORWARDMB bitplane is present */ @@ -109,13 +109,13 @@ static inline int vc1_has_FORWARDMB_bitplane(const VC1Context *v) if (v->fmb_is_raw) return 0; return v->fcm == ILACE_FIELD && - (v->s.s.pict_type == AV_PICTURE_TYPE_B && !v->bi_type); + (v->h.m.s.pict_type == AV_PICTURE_TYPE_B && !v->bi_type); } /** Reconstruct bitstream PTYPE (7.1.1.4, index into Table-35) */ static int vc1_get_PTYPE(const VC1Context *v) { - const MPVDecContext *const s = &v->s.s; + const MPVDecContext *const s = &v->h.m.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 MPVDecContext *const s = &v->s.s; + const MPVDecContext *const s = &v->h.m.s; switch (s->pict_type) { case AV_PICTURE_TYPE_I: return 0; case AV_PICTURE_TYPE_P: return 3; @@ -140,8 +140,8 @@ static int vc1_get_FPTYPE(const VC1Context *v) static inline VAMvModeVC1 vc1_get_MVMODE(const VC1Context *v) { if ((v->fcm == PROGRESSIVE || v->fcm == ILACE_FIELD) && - ((v->s.s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) || - (v->s.s.pict_type == AV_PICTURE_TYPE_B && !v->bi_type))) + ((v->h.m.s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) || + (v->h.m.s.pict_type == AV_PICTURE_TYPE_B && !v->bi_type))) return get_VAMvModeVC1(v->mv_mode); return 0; } @@ -150,7 +150,7 @@ static inline VAMvModeVC1 vc1_get_MVMODE(const VC1Context *v) static inline VAMvModeVC1 vc1_get_MVMODE2(const VC1Context *v) { if ((v->fcm == PROGRESSIVE || v->fcm == ILACE_FIELD) && - (v->s.s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) && + (v->h.m.s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) && v->mv_mode == MV_PMODE_INTENSITY_COMP) return get_VAMvModeVC1(v->mv_mode2); return 0; @@ -158,7 +158,7 @@ static inline VAMvModeVC1 vc1_get_MVMODE2(const VC1Context *v) av_unused static inline int vc1_get_INTCOMPFIELD(const VC1Context *v) { - if ((v->s.s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) && + if ((v->h.m.s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) && v->fcm == ILACE_FIELD && v->mv_mode == MV_PMODE_INTENSITY_COMP) switch (v->intcompfield) { @@ -171,7 +171,7 @@ av_unused static inline int vc1_get_INTCOMPFIELD(const VC1Context *v) static inline int vc1_get_LUMSCALE(const VC1Context *v) { - if (v->s.s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) { + if (v->h.m.s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) { if ((v->fcm == PROGRESSIVE && v->mv_mode == MV_PMODE_INTENSITY_COMP) || (v->fcm == ILACE_FRAME && v->intcomp)) return v->lumscale; @@ -187,7 +187,7 @@ static inline int vc1_get_LUMSCALE(const VC1Context *v) static inline int vc1_get_LUMSHIFT(const VC1Context *v) { - if (v->s.s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) { + if (v->h.m.s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) { if ((v->fcm == PROGRESSIVE && v->mv_mode == MV_PMODE_INTENSITY_COMP) || (v->fcm == ILACE_FRAME && v->intcomp)) return v->lumshift; @@ -203,7 +203,7 @@ static inline int vc1_get_LUMSHIFT(const VC1Context *v) av_unused static inline int vc1_get_LUMSCALE2(const VC1Context *v) { - if ((v->s.s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) && + if ((v->h.m.s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) && v->fcm == ILACE_FIELD && v->mv_mode == MV_PMODE_INTENSITY_COMP && v->intcompfield == 3) @@ -213,7 +213,7 @@ av_unused static inline int vc1_get_LUMSCALE2(const VC1Context *v) av_unused static inline int vc1_get_LUMSHIFT2(const VC1Context *v) { - if ((v->s.s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) && + if ((v->h.m.s.pict_type == AV_PICTURE_TYPE_P && !v->p_frame_skipped) && v->fcm == ILACE_FIELD && v->mv_mode == MV_PMODE_INTENSITY_COMP && v->intcompfield == 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 MPVDecContext *const s = &v->s.s; + const MPVDecContext *const s = &v->h.m.s; VAAPIDecodePicture *pic = s->current_picture_ptr->hwaccel_picture_private; VAPictureParameterBufferVC1 pic_param; int err; @@ -367,7 +367,7 @@ static int vaapi_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t .frame_level_transform_type = vc1_get_TTFRM(v), .transform_ac_codingset_idx1 = v->c_ac_table_index, .transform_ac_codingset_idx2 = v->y_ac_table_index, - .intra_transform_dc_table = v->s.s.dc_table_index, + .intra_transform_dc_table = v->h.m.s.dc_table_index, }, }; @@ -448,7 +448,7 @@ fail: static int vaapi_vc1_end_frame(AVCodecContext *avctx) { VC1Context *v = avctx->priv_data; - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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 MPVDecContext *const s = &v->s.s; + const MPVDecContext *const s = &v->h.m.s; VAAPIDecodePicture *pic = s->current_picture_ptr->hwaccel_picture_private; VASliceParameterBufferVC1 slice_param; int mb_height; diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c index 13a211e916..b923daf732 100644 --- a/libavcodec/vc1.c +++ b/libavcodec/vc1.c @@ -97,7 +97,7 @@ static void decode_colskip(uint8_t* plane, int width, int height, int stride, */ static int bitplane_decoding(uint8_t* data, int *raw_flag, VC1Context *v) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.s; GetBitContext *gb = &s->gb; int imode, x, y, code, offset; @@ -231,7 +231,7 @@ static int bitplane_decoding(uint8_t* data, int *raw_flag, VC1Context *v) */ static int vop_dquant_decoding(VC1Context *v) { - GetBitContext *gb = &v->s.s.gb; + GetBitContext *gb = &v->h.m.s.gb; int pqdiff; //variable size @@ -277,7 +277,7 @@ static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb); */ int ff_vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitContext *gb) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.s; av_log(avctx, AV_LOG_DEBUG, "Header: %0X\n", show_bits_long(gb, 32)); v->profile = get_bits(gb, 2); @@ -400,7 +400,7 @@ int ff_vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitCo static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.s; v->res_rtm_flag = 1; v->level = get_bits(gb, 3); @@ -522,9 +522,9 @@ int ff_vc1_decode_entry_point(AVCodecContext *avctx, VC1Context *v, GetBitContex v->closed_entry = get_bits1(gb); v->panscanflag = get_bits1(gb); v->refdist_flag = get_bits1(gb); - v->s.s.loop_filter = get_bits1(gb); - if (v->s.s.avctx->skip_loop_filter >= AVDISCARD_ALL) - v->s.s.loop_filter = 0; + v->h.m.s.loop_filter = get_bits1(gb); + if (v->h.m.s.avctx->skip_loop_filter >= AVDISCARD_ALL) + v->h.m.s.loop_filter = 0; v->fastuvmc = get_bits1(gb); v->extended_mv = get_bits1(gb); v->dquant = get_bits(gb, 2); @@ -565,7 +565,7 @@ int ff_vc1_decode_entry_point(AVCodecContext *avctx, VC1Context *v, GetBitContex "BrokenLink=%i, ClosedEntry=%i, PanscanFlag=%i\n" "RefDist=%i, Postproc=%i, FastUVMC=%i, ExtMV=%i\n" "DQuant=%i, VSTransform=%i, Overlap=%i, Qmode=%i\n", - v->broken_link, v->closed_entry, v->panscanflag, v->refdist_flag, v->s.s.loop_filter, + v->broken_link, v->closed_entry, v->panscanflag, v->refdist_flag, v->h.m.s.loop_filter, v->fastuvmc, v->extended_mv, v->dquant, v->vstransform, v->overlap, v->quantizer_mode); return 0; @@ -597,7 +597,7 @@ int ff_vc1_decode_entry_point(AVCodecContext *avctx, VC1Context *v, GetBitContex static void rotate_luts(VC1Context *v) { #define ROTATE(DEF, L, N, C, A) do { \ - if (v->s.s.pict_type == AV_PICTURE_TYPE_BI || v->s.s.pict_type == AV_PICTURE_TYPE_B) { \ + if (v->h.m.s.pict_type == AV_PICTURE_TYPE_BI || v->h.m.s.pict_type == AV_PICTURE_TYPE_B) { \ C = A; \ } else { \ DEF; \ @@ -621,7 +621,7 @@ static int read_bfraction(VC1Context *v, GetBitContext* gb) { int bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1); if (bfraction_lut_index == 21 || bfraction_lut_index < 0) { - av_log(v->s.s.avctx, AV_LOG_ERROR, "bfraction invalid\n"); + av_log(v->h.m.s.avctx, AV_LOG_ERROR, "bfraction invalid\n"); return AVERROR_INVALIDDATA; } v->bfraction_lut_index = bfraction_lut_index; @@ -631,7 +631,7 @@ static int read_bfraction(VC1Context *v, GetBitContext* gb) { int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* gb) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.s; int pqindex, lowquant, status; v->field_mode = 0; @@ -856,7 +856,7 @@ int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* gb) int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.s; int pqindex, lowquant; int status; int field_mode, fcm; diff --git a/libavcodec/vc1.h b/libavcodec/vc1.h index 6aa1a32352..850bf05d2c 100644 --- a/libavcodec/vc1.h +++ b/libavcodec/vc1.h @@ -24,8 +24,8 @@ #define AVCODEC_VC1_H #include "avcodec.h" +#include "h263dec.h" #include "h264chroma.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{ - MPVMainDecContext s; + H263DecContext h; IntraX8Context x8; H264ChromaContext h264chroma; VC1DSPContext vc1dsp; diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c index 081c47894f..6284b75991 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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.s; uint8_t *dest; int block_count = CONFIG_GRAY && (s->avctx->flags & AV_CODEC_FLAG_GRAY) ? 4 : 6; int fieldtx = 0; @@ -263,9 +263,9 @@ static void vc1_put_blocks_clamped(VC1Context *v, int put_signed) static av_always_inline void get_mvdata_interlaced(VC1Context *v, int *dmv_x, int *dmv_y, int *pred_flag) { + GetBitContext *const gb = &v->h.m.s.gb; int index, index1; int extend_x, extend_y; - GetBitContext *const gb = &v->s.s.gb; int bits, esc; int val, sign; @@ -512,7 +512,7 @@ static inline int vc1_coded_block_pred(MPVDecContext * s, int n, static int vc1_decode_ac_coeff(VC1Context *v, int *last, int *skip, int *value, int codingset) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.s; GetBitContext *gb = &s->gb; int index, run, level, lst, sign; @@ -580,7 +580,7 @@ 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.s; + MPVDecContext *const s = &v->h.m.s; GetBitContext *gb = &s->gb; int dc_pred_dir = 0; /* Direction of the DC prediction used */ int i; @@ -718,7 +718,7 @@ 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.s; + MPVDecContext *const s = &v->h.m.s; GetBitContext *gb = &s->gb; int dc_pred_dir = 0; /* Direction of the DC prediction used */ int i; @@ -910,7 +910,7 @@ 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.s; + MPVDecContext *const s = &v->h.m.s; GetBitContext *gb = &s->gb; int dc_pred_dir = 0; /* Direction of the DC prediction used */ int i; @@ -1120,7 +1120,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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.s; GetBitContext *gb = &s->gb; int i, j; int subblkpat = 0; @@ -1289,7 +1289,7 @@ static const uint8_t size_table[6] = { 0, 2, 3, 4, 5, 8 }; */ static int vc1_decode_p_mb(VC1Context *v) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.s; GetBitContext *gb = &s->gb; int i, j; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; @@ -1521,7 +1521,7 @@ end: static int vc1_decode_p_mb_intfr(VC1Context *v) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.s; GetBitContext *gb = &s->gb; int i; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; @@ -1731,7 +1731,7 @@ static int vc1_decode_p_mb_intfr(VC1Context *v) static int vc1_decode_p_mb_intfi(VC1Context *v) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.s; GetBitContext *gb = &s->gb; int i; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; @@ -1855,7 +1855,7 @@ static int vc1_decode_p_mb_intfi(VC1Context *v) */ static int vc1_decode_b_mb(VC1Context *v) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.s; GetBitContext *gb = &s->gb; int i, j; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; @@ -2013,7 +2013,7 @@ static int vc1_decode_b_mb(VC1Context *v) */ static int vc1_decode_b_mb_intfi(VC1Context *v) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.s; GetBitContext *gb = &s->gb; int i, j; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; @@ -2180,7 +2180,7 @@ static int vc1_decode_b_mb_intfi(VC1Context *v) */ static int vc1_decode_b_mb_intfr(VC1Context *v) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.s; GetBitContext *gb = &s->gb; int i, j; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; @@ -2530,7 +2530,7 @@ static int vc1_decode_b_mb_intfr(VC1Context *v) */ static void vc1_decode_i_blocks(VC1Context *v) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.s; int k, j; int cbp, val; uint8_t *coded_val; @@ -2655,7 +2655,7 @@ static void vc1_decode_i_blocks(VC1Context *v) */ static int vc1_decode_i_blocks_adv(VC1Context *v) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.s; int k; int cbp, val; uint8_t *coded_val; @@ -2798,7 +2798,7 @@ static int vc1_decode_i_blocks_adv(VC1Context *v) static void vc1_decode_p_blocks(VC1Context *v) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.s; int apply_loop_filter; /* select coding mode used for VLC tables selection */ @@ -2890,7 +2890,7 @@ static void vc1_decode_p_blocks(VC1Context *v) static void vc1_decode_b_blocks(VC1Context *v) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.s; /* select coding mode used for VLC tables selection */ switch (v->c_ac_table_index) { @@ -2974,7 +2974,7 @@ static void vc1_decode_b_blocks(VC1Context *v) static void vc1_decode_skip_blocks(VC1Context *v) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.s; if (!s->last_picture.f->data[0]) return; @@ -2996,7 +2996,7 @@ static void vc1_decode_skip_blocks(VC1Context *v) void ff_vc1_decode_blocks(VC1Context *v) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.s; s->esc3_level_length = 0; if (v->x8_type) { diff --git a/libavcodec/vc1_loopfilter.c b/libavcodec/vc1_loopfilter.c index d664392fc4..1438c073e8 100644 --- a/libavcodec/vc1_loopfilter.c +++ b/libavcodec/vc1_loopfilter.c @@ -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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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 7942f6f373..b188a3e307 100644 --- a/libavcodec/vc1_mc.c +++ b/libavcodec/vc1_mc.c @@ -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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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_parser.c b/libavcodec/vc1_parser.c index af5ff5028a..513f2ce192 100644 --- a/libavcodec/vc1_parser.c +++ b/libavcodec/vc1_parser.c @@ -65,7 +65,7 @@ static void vc1_extract_header(AVCodecParserContext *s, AVCodecContext *avctx, VC1ParseContext *vpc = s->priv_data; GetBitContext gb; int ret; - vpc->v.s.s.avctx = avctx; + vpc->v.h.m.s.avctx = avctx; vpc->v.parse_only = 1; init_get_bits8(&gb, buf, buf_size); switch (vpc->prev_start_code) { @@ -85,10 +85,10 @@ static void vc1_extract_header(AVCodecParserContext *s, AVCodecContext *avctx, break; /* keep AV_PICTURE_TYPE_BI internal to VC1 */ - if (vpc->v.s.s.pict_type == AV_PICTURE_TYPE_BI) + if (vpc->v.h.m.s.pict_type == AV_PICTURE_TYPE_BI) s->pict_type = AV_PICTURE_TYPE_B; else - s->pict_type = vpc->v.s.s.pict_type; + s->pict_type = vpc->v.h.m.s.pict_type; if (avctx->ticks_per_frame > 1){ // process pulldown flags @@ -259,7 +259,7 @@ static int vc1_parse(AVCodecParserContext *s, static av_cold int vc1_parse_init(AVCodecParserContext *s) { VC1ParseContext *vpc = s->priv_data; - vpc->v.s.slice_context_count = 1; + vpc->v.h.m.slice_context_count = 1; vpc->v.first_pic_header_flag = 1; vpc->prev_start_code = 0; vpc->bytes_to_skip = 0; diff --git a/libavcodec/vc1_pred.c b/libavcodec/vc1_pred.c index 2924aff9e6..85f3ba8b13 100644 --- a/libavcodec/vc1_pred.c +++ b/libavcodec/vc1_pred.c @@ -40,7 +40,7 @@ static av_always_inline int scaleforsame_x(VC1Context *v, int n /* MV */, int di int scalezone1_x, zone1offset_x; int table_index = dir ^ v->second_field; - if (v->s.s.pict_type != AV_PICTURE_TYPE_B) + if (v->h.m.s.pict_type != AV_PICTURE_TYPE_B) refdist = v->refdist; else refdist = dir ? v->brfd : v->frfd; @@ -73,7 +73,7 @@ static av_always_inline int scaleforsame_y(VC1Context *v, int i, int n /* MV */, int scalezone1_y, zone1offset_y; int table_index = dir ^ v->second_field; - if (v->s.s.pict_type != AV_PICTURE_TYPE_B) + if (v->h.m.s.pict_type != AV_PICTURE_TYPE_B) refdist = v->refdist; else refdist = dir ? v->brfd : v->frfd; @@ -165,10 +165,10 @@ static av_always_inline int scaleforsame(VC1Context *v, int i, int n /* MV */, int dim, int dir) { int brfd, scalesame; - int hpel = 1 - v->s.s.quarter_sample; + int hpel = 1 - v->h.m.s.quarter_sample; n >>= hpel; - if (v->s.s.pict_type != AV_PICTURE_TYPE_B || v->second_field || !dir) { + if (v->h.m.s.pict_type != AV_PICTURE_TYPE_B || v->second_field || !dir) { if (dim) n = scaleforsame_y(v, i, n, dir) * (1 << hpel); else @@ -186,17 +186,17 @@ static av_always_inline int scaleforopp(VC1Context *v, int n /* MV */, int dim, int dir) { int refdist, scaleopp; - int hpel = 1 - v->s.s.quarter_sample; + int hpel = 1 - v->h.m.s.quarter_sample; n >>= hpel; - if (v->s.s.pict_type == AV_PICTURE_TYPE_B && !v->second_field && dir == 1) { + if (v->h.m.s.pict_type == AV_PICTURE_TYPE_B && !v->second_field && dir == 1) { if (dim) n = scaleforopp_y(v, n, dir) * (1 << hpel); else n = scaleforopp_x(v, n) * (1 << hpel); return n; } - if (v->s.s.pict_type != AV_PICTURE_TYPE_B) + if (v->h.m.s.pict_type != AV_PICTURE_TYPE_B) refdist = v->refdist; else refdist = dir ? v->brfd : v->frfd; @@ -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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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; - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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 995761700b..7f97e962d9 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -104,7 +104,7 @@ static void vc1_sprite_parse_transform(GetBitContext* gb, int c[7]) static int vc1_parse_sprites(VC1Context *v, GetBitContext* gb, SpriteData* sd) { - AVCodecContext *avctx = v->s.s.avctx; + AVCodecContext *avctx = v->h.m.s.avctx; int sprite, i; for (sprite = 0; sprite <= v->two_sprites; sprite++) { @@ -175,7 +175,7 @@ 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.s; + MPVDecContext *const s = &v->h.m.s; int i, plane, row, sprite; int sr_cache[2][2] = { { -1, -1 }, { -1, -1 } }; uint8_t* src_h[2][2]; @@ -272,7 +272,7 @@ static void vc1_draw_sprites(VC1Context *v, SpriteData* sd) static int vc1_decode_sprites(VC1Context *v, GetBitContext* gb) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.s; int ret; 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; - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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) { - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.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; - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.s; GetBitContext gb; int ret; @@ -595,7 +595,7 @@ av_cold int ff_vc1_decode_end(AVCodecContext *avctx) for (i = 0; i < 4; i++) av_freep(&v->sr_rows[i >> 1][i & 1]); - ff_mpv_common_end(&v->s); + ff_mpv_common_end(&v->h.m); av_freep(&v->mv_type_mb_plane); av_freep(&v->direct_mb_plane); av_freep(&v->forward_mb_plane); @@ -625,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; - MPVMainDecContext *const m = &v->s; + MPVMainDecContext *const m = &v->h.m; MPVDecContext *const s = &m->s; AVFrame *pict = data; uint8_t *buf2 = NULL; diff --git a/libavcodec/vdpau_mpeg4.c b/libavcodec/vdpau_mpeg4.c index e9483168aa..88e9abefd8 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; - MPVDecContext *const s = &ctx->m.s; + MPVDecContext *const s = &ctx->h.m.s; 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 b91b158511..7cb626eb61 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; - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.s; Picture *pic = s->current_picture_ptr; struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; VdpPictureInfoVC1 *info = &pic_ctx->info.vc1; @@ -80,7 +80,7 @@ static int vdpau_vc1_start_frame(AVCodecContext *avctx, info->extended_dmv = v->extended_dmv; info->overlap = v->overlap; info->vstransform = v->vstransform; - info->loopfilter = v->s.s.loop_filter; + info->loopfilter = v->h.m.s.loop_filter; info->fastuvmc = v->fastuvmc; info->range_mapy_flag = v->range_mapy_flag; info->range_mapy = v->range_mapy; @@ -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; - MPVDecContext *const s = &v->s.s; + MPVDecContext *const s = &v->h.m.s; Picture *pic = s->current_picture_ptr; struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; int val; diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c index 7c4dc51782..58830f935c 100644 --- a/libavcodec/wmv2dec.c +++ b/libavcodec/wmv2dec.c @@ -37,7 +37,7 @@ #include "wmv2dec.h" typedef struct WMV2DecContext { - MPVMainDecContext s; + H263DecContext h; WMV2Context common; IntraX8Context x8; int j_type_bit; @@ -60,7 +60,7 @@ typedef struct WMV2DecContext { static void wmv2_add_block(WMV2DecContext *w, int16_t *block1, uint8_t *dst, int stride, int n) { - MPVDecContext *const s = &w->s.s; + MPVDecContext *const s = &w->h.m.s; if (s->block_last_index[n] >= 0) { switch (w->abt_type_table[n]) { @@ -102,7 +102,7 @@ void ff_wmv2_add_mb(MPVDecContext *s, int16_t block1[6][64], static int parse_mb_skip(WMV2DecContext *w) { - MPVDecContext *const s = &w->s.s; + MPVDecContext *const s = &w->h.m.s; int mb_x, mb_y; int coded_mb_count = 0; uint32_t *const mb_type = s->current_picture_ptr->mb_type; @@ -167,7 +167,7 @@ static int parse_mb_skip(WMV2DecContext *w) static int decode_ext_header(WMV2DecContext *w) { - MPVDecContext *const s = &w->s.s; + MPVDecContext *const s = &w->h.m.s; GetBitContext gb; int fps; int code; @@ -203,10 +203,10 @@ static int decode_ext_header(WMV2DecContext *w) return 0; } -int ff_wmv2_decode_picture_header(MPVMainDecContext *m) +int ff_wmv2_decode_picture_header(H263DecContext *h) { - WMV2DecContext *const w = (WMV2DecContext *)m; - MPVDecContext *const s = &m->s; + WMV2DecContext *const w = (WMV2DecContext *)h; + MPVDecContext *const s = &h->m.s; int code; if (s->picture_number == 0) @@ -239,10 +239,10 @@ int ff_wmv2_decode_picture_header(MPVMainDecContext *m) return 0; } -int ff_wmv2_decode_secondary_picture_header(MPVMainDecContext *m) +int ff_wmv2_decode_secondary_picture_header(H263DecContext *h) { - WMV2DecContext *const w = (WMV2DecContext *)m; - MPVDecContext *const s = &m->s; + WMV2DecContext *const w = (WMV2DecContext *)h; + MPVDecContext *const s = &h->m.s; if (s->pict_type == AV_PICTURE_TYPE_I) { if (w->j_type_bit) @@ -352,7 +352,7 @@ int ff_wmv2_decode_secondary_picture_header(MPVMainDecContext *m) static inline void wmv2_decode_motion(WMV2DecContext *w, int *mx_ptr, int *my_ptr) { - MPVDecContext *const s = &w->s.s; + MPVDecContext *const s = &w->h.m.s; ff_msmpeg4_decode_motion(s, mx_ptr, my_ptr); @@ -364,7 +364,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) { - MPVDecContext *const s = &w->s.s; + MPVDecContext *const s = &w->h.m.s; int xy, wrap, diff, type; int16_t *A, *B, *C, *mot_val; @@ -410,7 +410,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) { - MPVDecContext *const s = &w->s.s; + MPVDecContext *const s = &w->h.m.s; static const int sub_cbp_table[3] = { 2, 3, 1 }; int sub_cbp, ret; @@ -567,7 +567,7 @@ int ff_wmv2_decode_mb(MPVDecContext *s, int16_t block[6][64]) static av_cold int wmv2_decode_init(AVCodecContext *avctx) { WMV2DecContext *const w = avctx->priv_data; - MPVMainDecContext *const m = &w->s; + MPVMainDecContext *const m = &w->h.m; MPVDecContext *const s = &m->s; int ret; diff --git a/libavcodec/wmv2dec.h b/libavcodec/wmv2dec.h index 05ca29741b..22aa81c0d6 100644 --- a/libavcodec/wmv2dec.h +++ b/libavcodec/wmv2dec.h @@ -21,12 +21,13 @@ #ifndef AVCODEC_WMV2DEC_H #define AVCODEC_WMV2DEC_H +#include "h263dec.h" #include "mpegvideo.h" #include "mpegvideodec.h" 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); +int ff_wmv2_decode_picture_header(H263DecContext *h); +int ff_wmv2_decode_secondary_picture_header(H263DecContext *h); void ff_wmv2_add_mb(MPVContext *s, int16_t block[6][64], uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr); From patchwork Thu Feb 3 01: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: 34080 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp2043013iov; Wed, 2 Feb 2022 17:06:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJxiZEKg1xcy3aBah9n/n6eVqNqnf4tnvzYlc9X/9/U2MfkKU29T4JA72iOJEQ/nR/V2HgaM X-Received: by 2002:a17:907:2d1e:: with SMTP id gs30mr26974739ejc.14.1643850413652; Wed, 02 Feb 2022 17:06: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 h5si12313147edf.98.2022.02.02.17.06.53; Wed, 02 Feb 2022 17:06: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=MsenZxRt; 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 6D37A68B07F; Thu, 3 Feb 2022 03:06:50 +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-oln040092074042.outbound.protection.outlook.com [40.92.74.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 63D2A68AD9E for ; Thu, 3 Feb 2022 03:06:43 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YOg/EyHESVh0V2VuBxH/E5bLrQVR7s/qbzfFeHgGqGE8yEqCNVY/43iNYH7hD8YbKU0MzHOei7cCzmT7zhOW6pO8LGD29GTHAUWc+tu5oSyhAt7rYw8Eztnl8Wsdu/al/ga8gRSmlbmJn3EIGoa4rxIDWB9oVOxwIUzRznvbUHIEXOtWzpWcXePjLzbQJh6j0Vdf4Z1nRjpzlrkYaYx8hH3yLyLxXIs1IkctFQbk0WXcoKd2XDHTFxiUOjHOKpnHgRMpWvvwYDwWcHNSNW3kMlj4D2jt3t7f2BAJ0rKvOT8zJTduy7xChVlKFgd6obo3pZ7S6GD2io9Z8lhykRHRkQ== 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=XnULPCROzCBXYtHtBr9MIF6SqTrr8QUED5Sh5TOuFlg=; b=C0RxtXfeLWZJnTo8A7JOh4lK03eNtgBtTPrCfYhUALwtJgY+HX0H4z4Ax23UJrQ3r8tEVo0wNcLFsEk+sULdffcTGZabSUWPzqCiWna+QXTbyDKms2VEEbZH1iCSmH1PKT966enNcuglwjLgI/9YXchgFMSXkVl4cFlxtNRTO+Gs7nR+F4BnSIRySpYcfOPjxY0ekG2FWV2egk+YDx1YJY/7X3PdDKJoYW9w4z+Kj03mbkWGPqCH/aAFHfLmpJHWv+SQ7NjJVxq45/7BiRUSYcc94Jd3nqrm0k9IolgYyNZTSiVxi8qh7m4VscqHHIqVWxBRLqi579AOhYm7qTKWZg== 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=XnULPCROzCBXYtHtBr9MIF6SqTrr8QUED5Sh5TOuFlg=; b=MsenZxRtZZGsiIVNUpPHtbV7cp+7s2npR/jSi7hDNf/8VNVNI907XW6AhBHXbPjoNxNIQI3GSXEoxCTKhwVahKoZQWnsVY1qPzEXd76XjmYU2NpF4KdnfSW65E1QiVAYC6cYS0kDqVYDNEvgkLL5Mu4dIZ92/hf08B7/SsvUFCH5qkImZnAUe3f2u2qWSami9CYSFepOQD0erhvPrjsNbSdLBd1xtJjxPGS0J5i7CTMsQ1nC+fWgKzQ0HO9mYxvzLlg6W5eycufZrq+cZYJ3YEUKN6diy+wyerVqULvEyC+g5XMfphQ7vQvUf+5ozks6o0xb37Qb6iFQAOyaNxsjVQ== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR0302MB3203.eurprd03.prod.outlook.com (2603:10a6:208:11::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.22; Thu, 3 Feb 2022 01:06: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; Thu, 3 Feb 2022 01:06:41 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 3 Feb 2022 02:06:25 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [yDSUoFoldf9p53xaLtxGGlMggfrjfd2Q] X-ClientProxiedBy: AS8PR04CA0125.eurprd04.prod.outlook.com (2603:10a6:20b:127::10) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220203010631.1929837-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9e3f1ac5-5de9-4a21-cdee-08d9e6b1703c X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiTIIJz7w/iaHvlKLnqIyVAxL6lUd79U9nsMyJ4smsIlziYILN7BFyicy1K+6gQ0rJut3y0WRxX81u5F2EzOkG5O6Wvkt8LIVjfB3uN8cMRK3pJtb3bjxClJYuiLUGF28FfJQH5ModI/vRjSNx34pfKoWYkltCmFdwDwxOJqwqTim4ysgiZZJwe+wLBu4K+spUP9NvnrfnloE5fz7PfIBdRPS6cW2rC6fMuukKpfo5vIKcBNk8xfX1oGQkeZy0YERC93nkS/IUQ1+hjC3qqukBeCWS21fFklVFZ+Mp5doU8trTRvOvHQOsrS3OIhahLRs5AdcPEUr4UPAyroadJlyiwb2opd/xO8qSKpOiGWuwf/mQ1IRmvUjF/aWwFoA2aF0dEk1asJvHkOdJg3sUwvvjzjcceYc73CE0QN11weCXYt1Y/zk80jZpcp2jSngvirEsxmGHaaidmP4i4M33PXvCTXIPW/qRVGnVdcmjkrj5t9I6xvA6C9D0SMGYZ7Eooz5WKsiF8XGyciHZt0CkUs12bcebtbyD+EDVA8eWsz7fttyyo9jxC/nCZdfnUEgiz+5qwVdOzfnMziKIs5Ssdei+exvXKyb/2poWplB0d2mpgBVIFY40+SUplU4H5boRPKxS/69ahSTwx/YY9/wytnWKpewdJXaGBjClUvOK2OnzlMaAlce+91A2YR4c6UE7jXJP8cvvD/m5woDrLb0O79SHHrrsze3xgIAKMQbsZloknQkLIzDjV+FEzuTE9Q5UuZmlM= X-MS-TrafficTypeDiagnostic: AM0PR0302MB3203:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3b/c8ip0lj5X5QZTiTFTCN251YrqyCKPaPdJUemPiNOGYBM5eDJs2G9V+UyN/Xrd1bYXp7DpPSL1FDnfmbtWV2Hvl/s8mANGenC6k4v4++x/F3fH59heSWhhr6S5a6NsI0Hd5APesrZ0ixh4Kd0ebHLdRkt2ugtmLLr8Qm+mPTuPzdZgRUBEU3d7UOxV3+nI1hsqwqemanQ8U8eizRK570L9ElD3BvhooNtvgSJVEt16f7PNWye43It3Z1M0lmvNk6z8iIbplHUFA7Xy1P+UZtuBeSp+WanjaCK6Jj/UrD2TiMwvAdeIluZug/dva5Yzq28dNsSCNJEmAbo/Z+TWxMj6Ag4DcKhXz2Dlsq1h5O6ZP3Q/EFmIBOQUNr7YiKw8JPpAxpamH0Y1lWi5jXTw2Em8rlJX0szZ4HNDFHQTdNfa/qQd62Ae6TGLqqa6IzO3/5S8XY585LuKF0A97iOvO4omgVx9rGV/X+6GGGtRxibVZ74K28lzlnoWiqAjx/kA3PeFMiv8/ccI/T3eK2laEMIZmOBkEQZiDW13xXeqfgECLcDZbzm09cn5UmEKHysJdHY2MsLBI2mPGsS/32qulg== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JqIER7GyefWMMj53YcQzdkUl6g8SV1E4gsL9iO8RkVq9kp3q1JuQzweomjlVPHVoweBre04iwo6C6W0eetplRruyX1lGqSh7DfDg356E+TKPqcur9zF8trTaEw55EkeNXdeN+fXSoXpWAybBciFB859wuNERMxdFMmzU68C5THePWVhqD1r7/gZV+LEnbgjd82p+PrGK3F8snSJe16cNccegdJsT2Pjp+GFdKoxWo/+TGDop9GiAK8OMKWi0fCMm/zXXtDy5hEH8epfE5AndZIgv2CByw5pni4dDtUP71q58wBHwbmae/pH6DCKruAbTLu5+c716dquftnV8yPuFIUJ22aO3O1u8/Wyi4+raug/xF+7AOQFnrwzz7z4a41itOQWtUVrYzY/HQXb5+YkewWeFqfL51Pf9odKb46FBM+2Fw1AiuwflrWF67LGoWiFiJv1RTzB1EsQL6tF33Eamu7LT3rbChJQnwIo0cYPbjHjISE3Osxp3mWUnK4PI2lS41WNiLPwXVdZ+tkq/PFVN5TrZ3dukeJqECaFR//iq2/VUKGrhrcagSpKpGE6qmDagCbk76woTsaokZzlHRw0YoF6jbcXereT1WKPnPUSUq1kKBheetsDe1343718I3tclyPZgLNZUF1M3Q99MVRteWerk22Kg61JtmMf9r2sPaPsWGeljxanIpdu2W39fECk48qVvgPiVBoRe789aBKYdfIQIAExbCCVF+HQdZKz9GshQnF8N8PlnX/MxUarTMikYcQwivOtNd+UQZLWpDSnKpgToPmlNWsoIXR2KiEZp3PFljJiFxFbDfRfiKqp+aTmFx4ZT9SjVMiMggbcL/2+FiKfXPMmsHiD4Cp4Lyirki9RhuoEkc5cEo3R2XgibRsoC7upYEiBE5YsgIUjQEv3eBCoChIivhPu/iOWD848M1Lc9ADz0p/85u2Gy1zfeM7FqpB1IVR7BmeYZCKjwey4shw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9e3f1ac5-5de9-4a21-cdee-08d9e6b1703c X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2022 01:06:41.9237 (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: AM0PR0302MB3203 Subject: [FFmpeg-devel] [PATCH 74/80] avcodec/mpegvideo: Move decode_mb to H263DecContext 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: 3CKA9xFC3EjJ Only used by h263dec-based decoders; and only set by them in their main threads. Signed-off-by: Andreas Rheinhardt --- libavcodec/h263dec.c | 7 +++++-- libavcodec/h263dec.h | 2 ++ libavcodec/mpeg4videodec.c | 8 ++++---- libavcodec/mpegvideo.h | 1 - libavcodec/msmpeg4dec.c | 6 +++--- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index 4327aec54d..91e95b910e 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -86,7 +86,7 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx) ff_mpv_decode_init(m, avctx); s->quant_precision = 5; - s->decode_mb = ff_h263_decode_mb; + h->decode_mb = ff_h263_decode_mb; s->low_delay = 1; /* select sub codec */ @@ -201,6 +201,9 @@ static int get_consumed_bytes(H263DecContext *h, int buf_size) static int decode_slice(MPVMainDecContext *m) { MPVDecContext *const s = &m->s; + /* The following is only allowed because no h263dec based decoder + * uses slice threading. */ + H263DecContext *const h = (H263DecContext*)s; const int part_mask = s->partitioned_frame ? (ER_AC_END | ER_AC_ERROR) : 0x7F; const int mb_size = 16 >> s->avctx->lowres; @@ -274,7 +277,7 @@ static int decode_slice(MPVMainDecContext *m) get_bits_count(&s->gb), show_bits(&s->gb, 24)); ff_tlog(NULL, "Decoding MB at %dx%d\n", s->mb_x, s->mb_y); - ret = s->decode_mb(s, s->block); + ret = h->decode_mb(s, s->block); if (s->pict_type != AV_PICTURE_TYPE_B) ff_h263_update_motion_val(s); diff --git a/libavcodec/h263dec.h b/libavcodec/h263dec.h index b007372f64..13e097358f 100644 --- a/libavcodec/h263dec.h +++ b/libavcodec/h263dec.h @@ -42,6 +42,8 @@ extern const enum AVPixelFormat ff_h263_hwaccel_pixfmt_list_420[]; typedef struct H263DecContext { MPVMainDecContext m; + + int (*decode_mb)(MPVDecContext *s, int16_t block[12][64]); // used to avoid a switch } H263DecContext; int ff_h263_decode_motion(MPVDecContext *s, int pred, int f_code); diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 854ccd5ade..7e3b672312 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -2946,9 +2946,9 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb, s->partitioned_frame = s->data_partitioning && s->pict_type != AV_PICTURE_TYPE_B; if (s->partitioned_frame) - s->decode_mb = mpeg4_decode_partitioned_mb; + h->decode_mb = mpeg4_decode_partitioned_mb; else - s->decode_mb = mpeg4_decode_mb; + h->decode_mb = mpeg4_decode_mb; time_incr = 0; while (get_bits1(gb) != 0) @@ -3242,7 +3242,7 @@ static int decode_studio_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb) s->partitioned_frame = 0; s->interlaced_dct = 0; - s->decode_mb = mpeg4_decode_studio_mb; + h->decode_mb = mpeg4_decode_studio_mb; decode_smpte_tc(ctx, gb); @@ -3653,7 +3653,7 @@ static av_cold int decode_init(AVCodecContext *avctx) s->h263_pred = 1; s->low_delay = 0; /* default, might be overridden in the vol header during header parsing */ - s->decode_mb = mpeg4_decode_mb; + h->decode_mb = mpeg4_decode_mb; ctx->time_increment_bits = 4; /* default value for broken headers */ avctx->chroma_sample_location = AVCHROMA_LOC_LEFT; diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 2d5ee61a27..d0e4e8e9ff 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -424,7 +424,6 @@ typedef struct MPVContext { 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 MPVContext *s, int16_t block[12][64]); // used by some codecs to avoid a switch() #define SLICE_OK 0 #define SLICE_ERROR -1 diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c index b1f4df7aa9..c0d5d60cc6 100644 --- a/libavcodec/msmpeg4dec.c +++ b/libavcodec/msmpeg4dec.c @@ -382,15 +382,15 @@ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx) switch(s->msmpeg4_version){ case 1: case 2: - s->decode_mb= msmpeg4v12_decode_mb; + h->decode_mb = msmpeg4v12_decode_mb; break; case 3: case 4: - s->decode_mb= msmpeg4v34_decode_mb; + h->decode_mb = msmpeg4v34_decode_mb; break; case 5: if (CONFIG_WMV2_DECODER) - s->decode_mb= ff_wmv2_decode_mb; + h->decode_mb = ff_wmv2_decode_mb; case 6: //FIXME + TODO VC1 decode mb break; From patchwork Thu Feb 3 01: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: 34082 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp2043290iov; Wed, 2 Feb 2022 17:07:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJyR/Cm18SrxM4EkwjkO473ePx3qHBzwxHvZ5D2Hq2Wp5goWlPH9YzPVZfG89OTxCdYrq6Gr X-Received: by 2002:a05:6402:1395:: with SMTP id b21mr32891825edv.305.1643850436274; Wed, 02 Feb 2022 17:07: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 hb32si11800450ejc.467.2022.02.02.17.07.16; Wed, 02 Feb 2022 17:07: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=DtkEKAWO; 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 6F8B668B116; Thu, 3 Feb 2022 03:06:58 +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-oln040092074078.outbound.protection.outlook.com [40.92.74.78]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B336F68AEC7 for ; Thu, 3 Feb 2022 03:06:52 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=btTjCDaqb0tGo2P8rf9F9cyghdwQiIRGjEgsEX2mGbzF2Nswdu/D6zEvCaWh5yc8zhGXV2CyCW658eO1T2V/BYYg7ppvSP7M9GyrfaP1jq9l0UPQFhsm3dawHMI7bw+elLTf4z0/lEJgqvWaoQq8nLoYqkBwVra3x4b+rPa1q1bAxi19GrZAm7MtbZ3YHU4vergOggOyCp6oyD0Vq+lK1ZmLl8DPoMUqEdLGFi9rzn7RfR85HRgOi00256QGQd/xCuFDmjqYulbd5SUaORfaxhoCzeN9mLga26J1mwlCO5N3108ID/t/zMQsW4qMjecB5xgUF9Dh6JXHoVDxHEUB/Q== 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=1uA96x3tkHqlp5ZHRBHFCEixUOM/5YTqBqMiRQ76VtA=; b=e2gsQ5g1l4hDE+O/D1Ci5ThJZ711P53RZiqdQUSURJbB9cQasvgbb/I1qjgvK1QgTzWOjKREaPHpXxwmz4FjNsLEmU/qpLzm6zQ5EGpgqRLHIA5YRhm4oJkJIN0V2O4bcozXmIu9ih7KGXhRJB+2wb9EfJ4sleYUrSv1ondKy6WiEi2F+hD4HenNuZLSXAn5Lb0mDtFswg7pWTrObK70PJsUVhqwbrHhK2gWXsRcdQ2X6wxbSJeZ+hiwMhy2elecYEtQegIjSF/THYPhMRuArbHn1bdqjEaKmNm6gvhaGiT/txX52KG5WX22Od8fCVcVAFbJDRs8LMK1G4jnOg43oQ== 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=1uA96x3tkHqlp5ZHRBHFCEixUOM/5YTqBqMiRQ76VtA=; b=DtkEKAWO1bC22BiUDmrrTXAv1Kpdkn3dok7PLeAfUyOaSqRXT9UPc6fbnpRmi41NGEl6LESNKmCzxmORDpuj9E8RvJ2G/T4ATLFeCGzVt5vSH8oamotz+1oZ//bKjb+KFYYTQznAxDwW+VKNu0W2Htltc8C97FcOeT5Gcclk0b+cJ+iVKXEV1dFt7EMK4tqXaJe+2IF35j5JWCQ+XLC1fzMklnVU5Q0hCkXmftKchQtdl6yu4IQ3hy91pnFYV2Zxcr5wWpL97TICAW0vZ+VQWqGGzZROShIFLi8D7OWdWQr00M7Pw5LkSAA06NJDBLeU2Ry9Gl58pB/GJ9gifw+pfw== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR0302MB3203.eurprd03.prod.outlook.com (2603:10a6:208:11::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.22; Thu, 3 Feb 2022 01:06: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; Thu, 3 Feb 2022 01:06:43 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 3 Feb 2022 02:06:26 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [5UdhADEIIT6EdgfvNiUg5W3AoIUe/Syu] X-ClientProxiedBy: AS8PR04CA0125.eurprd04.prod.outlook.com (2603:10a6:20b:127::10) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220203010631.1929837-3-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e862b7a5-d203-47c8-bd61-08d9e6b170f6 X-MS-Exchange-SLBlob-MailProps: +LiGfBxqLEs6bi2B2Md8122fePlSqn4e0AppNUzC/imJ8aiRvLq1amk79hBsKAur7ZJpx4A5kbLxUvWOnPqr1D2p8qbaI6ea93zfrrSfQ/T09mPlCLFAgOANNnTnOcWqhGk3VxnDABvb8P4/AY+Ghhv5AAOJhvmZPXaxaM9OoVahaAmzEq4HhDCcS2nhcqhCsD9KY649Jg96dyky374jL1E1vm/713qt2xXwKmrqztEweoVuFW8M9dx+FoXPOUm3zZuWhXB1r2MtLZ2B6Mbz3uyxL7bqFesRqjlQ62IvwAaR4qPaSbXZs0kfh69NTSArp+GNqdfBXbJnWkSV8H4SESyzES+Kuop/hvrURmWGqmzbNP6etWft0AtEQH1Is71LLib6r0mYUMOVImviGLgdS/qDyf2JgqQrGygPRH3Rtacl0cAAgZumTR2QDosiQdM2yy+T4pfMOGQK/i6Nx17eyQrYCoknb6mex4cE1dvkSzqSP569Arp21YgYsZcgl9selZKbXFHpfa+c/Im6Tu+q13Erc5CkzWbXO4AvF2eljx3ZdMfrircTMFkXGdbkZuGYdq+PazHp4WZgwTgZT4oq2E1i/T/WcOIOwCcrMR/dti4lGWSBBsddYWMz3N47ujmJSyDYaOqpfNoFARpp6te6QKqiIR1R2wWK6L/MeQcQHDhK9mfKaSsoj5yFkyp9OOiyIN2NtfNcsHwJ3P4a1XPnVnQ/ytYWZEUPUavmN83FU0lgOHPlR3b69Se//ypl0uRFn3gWiei5cJBJEysL7Wt4+sDUZgTBYDMw X-MS-TrafficTypeDiagnostic: AM0PR0302MB3203:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MwM1SuG0GVaSXq4uedLTOxSfww2zi34TlDMSkWdmKrOeKfecup9p8ZCoeO81HNbkHb+M5vWLBZG1wxwS7M69T3ZpAB+UMfrOd2I6ISUTrLxjc8/JL8KHCPUbRZFg5Um8fWYTt/eBob6nDOyODI2HEvP7KXRWxomFBRlS20bmlIJvUW4vLqgKS9CFqJF72G6cT2+4xOu8jL3f0NOFyKnB6qWgqM0jdwor72T2jc3EwR5IaQwucd8lqIETQQp9HgTpJI20kW18tgi6sm4Gm4JNLFAo/Pa5J9+MOotWOxRo0ehUQlroSon7IVoC/i/yG7zbz433mt8eV1i2YYvme7MTs3N/Fd8pDjBEAZIMYPdEGLEFam3ynH8+DTpozC7j8Gh0MtH9nMF3lFteqBmDsW7miTy+/xo59QJiLU6U1hPa/K1khTEMc7wKvNk7go6tdqndtJ28o44OTSLYGeaAOpEgf4faQeoNuDJ7it+wfMKGwc3+NDz0hTz1WXlYWOErnjKYs6GsAAzqDlRjN20iAGxy+zIGpz5bm3zw7IRdkjJn5EMSHtcWgObbC2KOUueFztqA0zYhxeGISr8JiJd6fvrviA== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: f4G/JR7dOT0uz1X8ag+TX/1AtrdJrosnm9v5AT6y1m6+iZQPl3GcADq6eAlTFYaLSRmc0qc98am+JHE+v5WnN68TVJLIZW51QpcW/Geuz7XbPZCJJjseMa3ZN90KnUlJTBYygGaAlmtSh2OjNiS0ZChnbQYg60U5PZG/3YvSkOGLNfyAF1xy3SKsyVypM15k14z5CS/6FDHz8VMqExYw/C6o3U0LN1X3dz13ffE7ahO1bePw3eY5id/ZpsCWpgT/j6raeWfZNlMTrVMlTdT5cddflhft/9zTF0hE6uow1eqm8v565nnblUx8+Kwx9HY8dPct42VCaJV1MZi79YjySZjtHGKWdGFEf0MVB4l9CSPnBGiwWWIhOKCQK3L5jlX/5Fk/RL1qxC8VaLSrFHtK1YVLRjiAE3dHQ8V3UITQsnHQSgHqDvp/8rWjZ883nWFgFvYe3e9JLGwlcvPmdBwgETgJK75m5sV2Vlsi+YNFQFCkHefGux6CRcTcfNDjKuj1gTW8CuYdHP1xtbk5KndIpsZEymsngUlFYbbXo4Cj1/YmRP6C/wA1aM1Qe/lUm02OITmhdGhy49k+Fpea9yAuFJc1HixzFP0Yuuj1NjBd22iEp06derHPEFy3il/34nZg4JwGYUE2uAMIrvXuGMgz+rIKLTArcBQqn9Wa4mdbe1fGf0hN14WYUEZ4V/kBBOYRfDyJbx168710OAJQUOtsWPNe0o44PU5OTo6i/5C1mImSBaZTCso+ycqOJbSW3O7EpU32GgbvP8ucxkkJIr54GiKPQ/2RG8vNgFJvlenRZUkSgQaj14DgVWPdlpDiRTc7YxMZSt5kpAAYU/7IrBB+/b4aQpLVULVqo333STu1xqjGIzgS8vdYU+7SPYwzsOUq1jQIeWadcnKwP3gttAJHLTPiqiPtV92esXMuIJiutht0usU6E24ljgnpRaPwdcA8t++CKrBUx3vLAjPH9jiOBQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e862b7a5-d203-47c8-bd61-08d9e6b170f6 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2022 01:06:43.0498 (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: AM0PR0302MB3203 Subject: [FFmpeg-devel] [PATCH 75/80] avcodec/mpegvideo: Move h263_long_vectors to H263DecContext 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: gDI9lvima32Z Signed-off-by: Andreas Rheinhardt --- libavcodec/flvdec.c | 2 +- libavcodec/h263dec.h | 1 + libavcodec/intelh263dec.c | 2 +- libavcodec/ituh263dec.c | 9 ++++++--- libavcodec/mpegvideo.h | 1 - libavcodec/rv10.c | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c index 3c14f2c54c..8ff4c03100 100644 --- a/libavcodec/flvdec.c +++ b/libavcodec/flvdec.c @@ -92,7 +92,7 @@ int ff_flv_decode_picture_header(H263DecContext *h) s->h263_plus = 0; - s->h263_long_vectors = 0; + h->long_vectors = 0; /* PEI */ if (skip_1stop_8data_bits(&s->gb) < 0) diff --git a/libavcodec/h263dec.h b/libavcodec/h263dec.h index 13e097358f..9c4c26242c 100644 --- a/libavcodec/h263dec.h +++ b/libavcodec/h263dec.h @@ -44,6 +44,7 @@ typedef struct H263DecContext { MPVMainDecContext m; int (*decode_mb)(MPVDecContext *s, int16_t block[12][64]); // used to avoid a switch + int long_vectors; ///< use horrible H.263v1 long vector mode } H263DecContext; int ff_h263_decode_motion(MPVDecContext *s, int pred, int f_code); diff --git a/libavcodec/intelh263dec.c b/libavcodec/intelh263dec.c index deed9152ea..f621c9686c 100644 --- a/libavcodec/intelh263dec.c +++ b/libavcodec/intelh263dec.c @@ -62,7 +62,7 @@ int ff_intel_h263_decode_picture_header(H263DecContext *h) s->pict_type = AV_PICTURE_TYPE_I + get_bits1(&s->gb); - s->h263_long_vectors = get_bits1(&s->gb); + h->long_vectors = get_bits1(&s->gb); if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "SAC not supported\n"); diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c index 9e92ed94ce..299a668290 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -82,7 +82,7 @@ void ff_h263_show_pict_info(H263DecContext *h) s->gb.size_in_bits, 1-s->no_rounding, s->obmc ? " AP" : "", s->umvplus ? " UMV" : "", - s->h263_long_vectors ? " LONG" : "", + h->long_vectors ? " LONG" : "", s->h263_plus ? " +" : "", s->h263_aic ? " AIC" : "", s->alt_inter_vlc ? " AIV" : "", @@ -272,6 +272,9 @@ int ff_h263_resync(MPVMainDecContext *m) int ff_h263_decode_motion(MPVDecContext *s, int pred, int f_code) { + /* The following is only allowed because no h263dec-based + * decoder uses slice-threading. */ + const H263DecContext *const h = (H263DecContext*)s; int code, val, sign, shift; code = get_vlc2(&s->gb, ff_h263_mv_vlc.table, H263_MV_VLC_BITS, 2); @@ -293,7 +296,7 @@ int ff_h263_decode_motion(MPVDecContext *s, int pred, int f_code) val += pred; /* modulo decoding */ - if (!s->h263_long_vectors) { + if (!h->long_vectors) { val = sign_extend(val, 5 + f_code); } else { /* horrible H.263 long vector mode */ @@ -1150,7 +1153,7 @@ int ff_h263_decode_picture_header(H263DecContext *h) s->pict_type = AV_PICTURE_TYPE_I + get_bits1(&s->gb); - s->h263_long_vectors = get_bits1(&s->gb); + h->long_vectors = get_bits1(&s->gb); if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "H.263 SAC not supported\n"); diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index d0e4e8e9ff..0e26bed7fd 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -177,7 +177,6 @@ typedef struct MPVContext { /* motion compensation */ int unrestricted_mv; ///< mv can point outside of the coded picture - int h263_long_vectors; ///< use horrible H.263v1 long vector mode BlockDSPContext bdsp; FDCTDSPContext fdsp; diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c index 1fbd99a965..e1379b634c 100644 --- a/libavcodec/rv10.c +++ b/libavcodec/rv10.c @@ -390,7 +390,7 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx) rv->orig_height = s->height = avctx->coded_height; - s->h263_long_vectors = ((uint8_t *) avctx->extradata)[3] & 1; + h->long_vectors = avctx->extradata[3] & 1; rv->sub_id = AV_RB32((uint8_t *) avctx->extradata + 4); major_ver = RV_GET_MAJOR_VER(rv->sub_id); From patchwork Thu Feb 3 01: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: 34083 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp2043402iov; Wed, 2 Feb 2022 17:07:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJz6J5jruVaaWlP9aIVYppUP7DrSroXWGv7hgYl8K+3p6mOcPMm4vl5CbsH9UQie+bkJ/f5R X-Received: by 2002:a17:907:7f1c:: with SMTP id qf28mr27152870ejc.94.1643850447522; Wed, 02 Feb 2022 17:07: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 cw1si13617955ejc.47.2022.02.02.17.07.27; Wed, 02 Feb 2022 17:07: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=tPshJ029; 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 6879F68B10F; Thu, 3 Feb 2022 03:07: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-oln040092074042.outbound.protection.outlook.com [40.92.74.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7C88768B09C for ; Thu, 3 Feb 2022 03:06:54 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PmIbcEgig0GL6IBIYCQmGpz7+jnZ3DjvVh5NMlctV82hrJSRQZ0QA6csQvH7Pj4Wsnoa0Ag9DPaK93Zfb9P2/PL+1QEItPYRYYn6cvzdfvrxKAX5aNcOrqSyJeEoG/EpSRZf+OdRJrp4P04F+jd87/Yzubm3WbHcGdNUXdf1wy8x1us7xIKY+zaQt/iFknUolGm4ThirssHIJZle4lgwzDC4pZP2GigFsyVw8Xz+ez+3neM9OwsbToP+VaMqD5FUp4TEbcT/O2mBBdMnyVm09Pui9fqjsy9wd6YN+UEz38Oz1EmraQwODHBArJX1VPfPjyvBVj8oIJXfzO9b6B01gw== 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=zb8JhCPLVtr9aEk7Tz+u7RjsCA4pSo+pBRRM77LfvfI=; b=JDHOi16znJTs6hiNWHWW9RTC2CssnaMtKk2n4A2BxNQ9TAIpehSB6ShKIo83u2Asrko151QFu7ERCLfDM9ziNTU8OUV6lPWXEAEF+zNStqxJkvvoIyy0zJ1tCjC/itOSqPq7C563Jm8ZU+9OpcFcHU/gn6V1hvDuT0AHT9QgSQwH1+Ry1xJfsMd/jJ9zpCeq/pWt7zEcQv3Uos3pHS7DUyJVtXb3++gMo4coX3nqYP1M8dCxGcuH0YX0ttMkfaLarClv5jrDRG9XK2Ll4aFgcaEhmmy3NK1SsjSEeTF/V0S3i9Ehf2V9q3/p7WdPD4wPlZjkzXNCHx232L8OasWVOg== 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=zb8JhCPLVtr9aEk7Tz+u7RjsCA4pSo+pBRRM77LfvfI=; b=tPshJ029kuQmSPMp3gQ0N+0vzYEj+o8v5y7FCKIUYWYI+66mR2+6g0Xms53Au7E/ggbER/Nf8Gbz7m7lVobERWFg27SU51Jw7Xd8xkCDHnkDZjQ2dl6hXzoBThAL/DrdlKiUpopT8PWCRh0pQF95WnTtpODaq78wp1f23UuVgVyp3+iz+ECgHKqgPln2NHPnwYlocQPnQ6szOCjzAp9UU5lamvsHJ5ODUtK1oU8P5PFvd4Js9ZHhkLevSBvJKfJwkWHKPoR+m0JgEEUkVukrVEv7zB8Cqw3mgvouLw6ev7CNhiz2aAbfxLdDDAj+WxnImbprUNksyg1lO9vFpVJJzA== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR0302MB3203.eurprd03.prod.outlook.com (2603:10a6:208:11::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.22; Thu, 3 Feb 2022 01:06: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; Thu, 3 Feb 2022 01:06:44 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 3 Feb 2022 02:06:27 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [znDYuJaCeLxMQJj+FteZyNGYSaAB0UCE] X-ClientProxiedBy: AS8PR04CA0125.eurprd04.prod.outlook.com (2603:10a6:20b:127::10) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220203010631.1929837-4-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e636f6d5-3a42-4130-30dc-08d9e6b171a0 X-MS-Exchange-SLBlob-MailProps: +LiGfBxqLEs6bi2B2Md8122fePlSqn4ekpOhm8wG9HdVRcR/O36BB1orijMEWbsWYHZAOfVPZLPf1PV6z5zFTCcT8iXFXofi/eQLG9fsGM+gWam5FZkFIzQp/nob3iTSNADO/7rzgL357MLGH7PpbRMOMyj0swKa3CtQCJYWcI5Q3dDkdBDzbUtnh4ya44699rpi9W/VN3LzpIbMdUELK/scfRSkujY9Yq6E3xtr2enwPaCUDFnijkYwvpihcPXyaazRatwocPAaCcYyL3o5WPrQg6hQ30YGGlSBLEJYgrDnTZgXbHEo3MZtDc2w0WU3KlZKnamBQks6Wj/6UUMA4l1t1C405RBasnlTW2XFC5cChWmrxnvGF3L3BEY/hXV6t0EhVfyfbxtSOQO/pv3402POVaZ0CgArRPR71ATe2wWrLe3e5kqMFDzt4Y4U1if1GBgCH0zXw5zXbBl4MZe0nBeSWqqj1TWH1kLKYzoDV8WQEtYMPmuFuWh1vynqvT2EPF+nHmakXa1rv3wbAewN7cuMogUIlesOjGQOXamwvMTHWcZgA5jKXCEttp5wzdw945OUIRHDnuvKqVdUVoyAScLPElU4gsAXtTkSx/ObbIW924G90keaILX+4piPN2APhaW4CqcVxhNaa7xvzr/T4EqizoaZwdiBWdPBuAnzjYZ9Y555VqLOR+5eYa4DMtEL9JlS5/BY88fRg0JEGL9jGtkHv3MlYqDGnp9TORrsiM+6HM3yETKWqiyc/r2TZklBTuTTRZRbBB0xHu0IzZIjK1f8hH0PamEt X-MS-TrafficTypeDiagnostic: AM0PR0302MB3203:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HyVZFwmDE/PiD3Xtdox7yjSaplr5li0gCtcm97QtpmjM43qeZuyvtXZhnkR4WXbDJh8bbAxFQSFjR62ecVLYhmbePkNs4Dkt5ESQ8GLs0ap3VMpToS+O5ZOiEXxlrt6tLcYx9XHz6cFhp8Yvr/QJvVt5Z+NjzMnG5a+yaxqeiiqUg+99O8Tr9oEzIf3qk6MqtFdR3xAn6x+ErqHpj8S3F+nIyI3/0LZv/m9OJPITu6sSbW5my27rfTYKFxLfFXPI6C7aVgSepfnaB3Q8VP9VRgRjQXTS1B+0IW77UlO9U30Yok/d4zPRnuJDs831YESxUOsVnZQsHEIjfMQEozUzLn+fqMy4egmZ5g4Lv641HzWpr6Fh2ZnVxHhgwZoolWEStSOm7q2pxIXzlb8YDOC3ISlo+0eNk9p3DWpQ41Qt2zJqvHXx8oiIZcGHQttYwOM2hINNO1Iqk0iI7afDK/Bom+6MSNYOaZ9vSP0TC8lla54d4YoAzZAN3a0wXSn5kT4noAzPoVnrs2JVDjy3wII93WVoFwhIO0M8YRsLo83UPDaKp506MVVCoZ8FBBGMN7l3WEUZ1MJKBx+T+fvUylHOaw== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rz7Q2fXKSm5yRkl4J4GWvksGiGCs03I/BGjGC7NGjk3Z3s4jKCUYsxJtLXlDFszcvgFdP4IptD7cJsJlLbe38uJBn5Iod0TC9z2gRfiHWPZps4kwyXzDDgosjIkX3YrLk6cSyAqHatRfmnqzFI6yLehlq4V5j1cjWRy7Nfg1BZt96epCzJucFh3B/3JYR9FeHKEWY2OYL8sJJVFzr8wJh9jDuuo+M/zEuFha9LFYAEKz5NmLq6xlJU9TF8BCnEh3FrtkQlyc0wyEf/zVZgbzBr7ERkT5PctM6bA6SJ8n+hR4wYAuLCy/czivJyft4KVwwmQYMfovaKl1cQvatlqNqiZbS9AJLUpGHF7m0e16ZLiioGLlNdeWppJ7j8GK9HwTslyjGRQLF1Y74rXs0FPm8bRMXQZbOQPQq7MkGAYmWU5RKdCxdN8VwpXTzXd/SRtLFRGOy6E9qEPwW9G0QD68j3e7IvGuP2/GNZiElP09xjGAv5+YCR9XvQzylu4UwYUvXYI4NGvfFjmuaP9zy64iELk9I6Hfb/Dqsf2PbGy2+QJ5hVxJd9Ja0aaYjYrfk3m+Dt1U7pDy7h5Gjpog62DjcATv2Qo0PPlyw72j2gWaCokpdPFnp6IDDADw/s3JZgXcBIe4n7Kkbu1EgSTYCwBzDPkYSNk/07GPYRs7rP+HtTaFsHc+/3N0To2AWQFL0lZsRZ7XguxEvLB1nAf3qe5T/Mq8hK4uNukIXZHKVR3spadbA3Y6fcAUSydDMmBN7o9fPP5fahtklc2OuoDUwqCRYxjw2M+8NXx1ZGobP17d9nwsgQqVwxIORh6cyyg3TTq7AD919JkwpGTyjT/I8thAXobmg81/NfCzomneUVECmvWNHyzOYuI4HzGRyjNw9GOgFSTfCwwuEfbLfvFQulfa1qJH8YDKK/1vL2hQVqlje4C9LmdKn2QQySUiVUYx//lIuPTLM88aEdvtvxUZO/CaGQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e636f6d5-3a42-4130-30dc-08d9e6b171a0 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2022 01:06:44.1590 (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: AM0PR0302MB3203 Subject: [FFmpeg-devel] [PATCH 76/80] avcodec/mpegvideo: Move ehc_mode to H263DecContext 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: DmdVEFE7Uqvn Signed-off-by: Andreas Rheinhardt --- libavcodec/flvdec.c | 2 +- libavcodec/h263dec.c | 2 +- libavcodec/h263dec.h | 1 + libavcodec/ituh263dec.c | 2 +- libavcodec/mpegvideo.h | 1 - 5 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c index 8ff4c03100..d33cc11b27 100644 --- a/libavcodec/flvdec.c +++ b/libavcodec/flvdec.c @@ -100,7 +100,7 @@ int ff_flv_decode_picture_header(H263DecContext *h) s->f_code = 1; - if (s->ehc_mode) + if (h->ehc_mode) s->avctx->sample_aspect_ratio= (AVRational){1,2}; if (s->avctx->debug & FF_DEBUG_PICT_INFO) { diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index 91e95b910e..db03e04143 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -139,7 +139,7 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx) if (avctx->codec_tag == AV_RL32("L263") || avctx->codec_tag == AV_RL32("S263")) if (avctx->extradata_size == 56 && avctx->extradata[0] == 1) - s->ehc_mode = 1; + h->ehc_mode = 1; /* for H.263, we allocate the images after having read the header */ if (avctx->codec->id != AV_CODEC_ID_H263 && diff --git a/libavcodec/h263dec.h b/libavcodec/h263dec.h index 9c4c26242c..e090f4b39b 100644 --- a/libavcodec/h263dec.h +++ b/libavcodec/h263dec.h @@ -45,6 +45,7 @@ typedef struct H263DecContext { int (*decode_mb)(MPVDecContext *s, int16_t block[12][64]); // used to avoid a switch int long_vectors; ///< use horrible H.263v1 long vector mode + int ehc_mode; } H263DecContext; int ff_h263_decode_motion(MPVDecContext *s, int pred, int f_code); diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c index 299a668290..8467746a0e 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -1258,7 +1258,7 @@ int ff_h263_decode_picture_header(H263DecContext *h) height = ff_h263_format[format][1]; s->avctx->sample_aspect_ratio= (AVRational){12,11}; } - s->avctx->sample_aspect_ratio.den <<= s->ehc_mode; + s->avctx->sample_aspect_ratio.den <<= h->ehc_mode; if ((width == 0) || (height == 0)) return -1; s->width = width; diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 0e26bed7fd..7be9b889ea 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -302,7 +302,6 @@ typedef struct MPVContext { int prev_mb_info, last_mb_info; uint8_t *mb_info_ptr; int mb_info_size; - int ehc_mode; /* H.263+ specific */ int umvplus; ///< == H.263+ && unrestricted_mv From patchwork Thu Feb 3 01: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: 34084 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp2043515iov; Wed, 2 Feb 2022 17:07:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOnFUDHUZRzhH0RTMHILAzToufiLCjarA1Hk1up8LMeoVUJ4714p84ihOKRReYSlORr3Cx X-Received: by 2002:a17:906:3b9a:: with SMTP id u26mr28078786ejf.125.1643850458170; Wed, 02 Feb 2022 17:07:38 -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 js1si11754517ejc.557.2022.02.02.17.07.37; Wed, 02 Feb 2022 17:07:38 -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="MMat/AsT"; 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 61F3C68B170; Thu, 3 Feb 2022 03:07:05 +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-oln040092074078.outbound.protection.outlook.com [40.92.74.78]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D4A1668B09C for ; Thu, 3 Feb 2022 03:06:57 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eN0BmelrYJrvDh7sBAPuWalOLW81BCaxnAHZwCWURWnDl52J7sSHQG75tGrY9mdEpWe7y6FZP0LDMEWW6HiOumDvEUvtwo2lKIVrNkH79H2psWOApAIDrDVM7Yrs2HfSQ7xPmpbx/yEeXJtcbsBEuOtVYfzInynN23QEBSS6zauhy6V7VjnN1cR9Hjhi9MbWz1iWa7l7gaDWUbKDUNEIyLo7q6yL61OramAB+Ma4TcdurZi2+lVKOyYgW3pwNB3cq3Tk9bWIuNt7KpJYXADlrUKhbE4vhRLCivDBBO2h8oKouz7AVBq3QbPd+6VH9Zvbvr0MFenENxdLHppWqF7fXA== 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=rF7GEQpjc1mRQcqhfZwDPg3Gq8Z2xoQRpIov3YIGisM=; b=CcUyIba+wsE+T0sPdMEmVeP7H2xdUlj9vpEqGu4PagaWyi0frPHNAKvu/QE1opqgtEGd5jfl+SdxiLTTZJ3vdNobv7EGGUbtyA6ORunQN8DuLGmlEIceVCak6IdWDM3b8elvlSf7Vh1HgO32/raw4fPzNlDn6bxje88nMeUnb/iGNbum6lsY/dExKM/yhCkcbmcCuKZt7RcTqEg/pVSt3N2bwCU41QimctI7OY0muOg9pfL7nuU7GqTWweNEfvXWGdCEVG3T/UKKMs2nHfdwn2j3m9A3X43ovxqq5ZNlDBuGP46wUDZsVMuCSSJ1RyhevujU7muGhT69MAOBgFWGQw== 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=rF7GEQpjc1mRQcqhfZwDPg3Gq8Z2xoQRpIov3YIGisM=; b=MMat/AsTxke/oZ2T/BOX4onI9RgXSr4Yd24eAchNF3U6Hpb9n9xPfQlksY9f6Iqy7Wyo1y0FNHz06fhAiR2upwToefepXUBhzCl1lgNfCWDYwRWWgg6Nc7wZKVlFyP2SMNCkttWZsaGa1QtFeJpWxjqR5Xlpde5xgvmWHdfmhQgA1p4WrlV3jaRkk4W1/1artxXjI19hzQfJNmmZ5yEOQuxqhopkqXXQYZMqsFADSdnY8rlZCAn64hrIBzVHc/pD4K8+1AXpbvJh93pCmRsDIIJG2hoRQv2G9jz0yTk1Kxxce7+ljJhXTltocMCRuJRK6FpeutpY463Jf8xrwW7w9g== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR0302MB3203.eurprd03.prod.outlook.com (2603:10a6:208:11::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.22; Thu, 3 Feb 2022 01:06: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; Thu, 3 Feb 2022 01:06:45 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 3 Feb 2022 02:06:28 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [Fb3AMzUr5WmcGCiEJ1JMRSuayh3VmgRE] X-ClientProxiedBy: AS8PR04CA0125.eurprd04.prod.outlook.com (2603:10a6:20b:127::10) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220203010631.1929837-5-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 798e04d2-6d83-471d-ddfa-08d9e6b17236 X-MS-Exchange-SLBlob-MailProps: +LiGfBxqLEs6bi2B2Md8122fePlSqn4eMZjbaD/cDyyKwwjlAHcHogy4mgkxEwqsMtxA1p3jnED3T/w2Ynq3S27LmW21JgtrqR1Faxtus0TQxQHM+s4eiCgI3zmlnQUtFnEaH3dhWEo0o6MXrpyKUtZdQ/S/OVGc11JsGLmIY+Dmh/gLEkHwptT//nVRkd+cKjYau+Y0aJfaxkoPSDLfIUTbCwc8V3Xq93COWfOhuIfn6g4rLjqLV6WZJRqh5tPh5gBqpKbyU20BV2XTgi9BnFjfqpIv+TWb9z9hc7RSwh41t2lYSKpszeF1kytss9TZnLf/IuDW2IbRpJAl0XC/lzb8LHgNmT1CTt24xQReUO0/j/uAKdHqqSn3DwWc0Yl4j3yNdvdvCJPD+CWSZ96eKRPg6LvaOAvlo4xm+cqLXpznBPL76VUSmLmE3e4nDjvh/bz9hQeff+xtYHd41lkQifzisV9oD+Oe2jojdJontfr6FzfP0TDZt11u52nPtfBaMxQGrDuV5bhYXtFtM3F1YJub8jSt5qZaTPaIIC8byKo79kO3CjnK+AurlxGB/ZhA+HUoA9wgWfn/IcErEh7ZqEdPAv7WiiqA+QUrpzjcD+ui/cdqgRCSjUFNV4WC6STp6OeKtPyShFZe9nCSgPK7JK77hQ1L7jOlC98JRIiloNP3y3BLdDxgyX7VMb0hsnYQrOUhYMftAKz7dE0pdOr9pqYEkUZGUZ0kIJt1N1eiy0Ls7GA1sA8ac8+DPdfd934OBiOeDVcvOtp/m6aGUOYA9FYPuAUZOLLn X-MS-TrafficTypeDiagnostic: AM0PR0302MB3203:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HPu1sZpoIS514RTCyOXKi5BBw61D41iheZaD3oHgd+iifT56ON92VyKvrqRrsOR/8k0x3nJawaFLH79cxHDkBPXBfpiZroEeZBEOAruWUzRdCTgvg4MmDLqhBbp6035cKR2Bre19mpAl45gBp5H5eeaNK715YPGpGq8aCyxIKdUe+RtQbrFpOYSU0o2aLQTbtriLjBOh9+1m2uL5m7qB3GA5cd78ciFRQ4jPbZCs4BI71f4jsxBxRfPvVHzf2Ee9TTtpT0PS6Fl4mENb+FJL5UEPxs8n5tF0KjqicF7K74ynrmdr9YJFJUa4yJaAEgm9JIXgIazWTRO3TT0+FVObsRxfNKYyZcxgwNl9rBk7G2GN+f9dnNMUeMTv+u5IE90W7AdnGmNzJ2dNqyz0Vk+1h/zuT5rx/HTZP3iy0LZnaC6jbGJRy2i19S1NWecAjr9lfu509IbcaGsaEltbdUczXL/n+J5y9OP6LEfVGJVjANcAW96RA41zkrRIJVrX/+2C8Purryyhv0kMToyZU9MjbUB8zGRL8dqzjMC46fHVGlrcRLDdoyZ70MohlgsU3rGkemG2bBzu+mBEjl/t4CR2YA== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Rbl962toUVw0WZBk4UcTDMh2K1I0qefdpzm4BLZSKSQwQw1IMsxVxxWeFVQv0KVkbvNLkLpjMhyBUDkTYfBQLvv8TnPD8vxYtUqm4IHT23SnMK3scBIaeoenLokENK8eeiobqLsKabBMo16ijm/5KICntzs9mwOHL2/vpUNcEgOMawJSUdqJIfK+8mvt2LdoVd/VAlh8IyQwXXgd95gTWaPIQ/D9/DjViqwQHlG9ZHaCAwmadxShy+S5yrVvQPllJpQYxtmID9TWiPJhwuZoNVqrLfimr6zsvqE6ss3+FfaXDWT8yz7Du24tn4jF5be0s1K/pdwhbP5qGNSgGnD+FXYhdryfW7M8ihmt0sjZ3cOTpyQPQazkVmPCaUUuWr5nW2LfBCvnJvMyCTTRKi9xjsmGVcsZRNurTWXmdzTOn6WDAv0u5f2OMNBYdQqXEAgpxr/iZKFrC7lU+V8LSfzA93eYQMiWAADL2lg6HKZHimWGuOBkurRxs8tatQydLxiqyUC+czDhycCFtK1jJHyjsIlono1h9hkGrz6SYNkVLX7ilmaYYvTtV6W7Yq1eEfvoDDhbGxfGZGpX6KgyMt0lWRzVpfI3O7q7gjhTxGYBUmLtGyXHuwkHHNJVAGMA5AnZcu/nKaYcSio1YG2aazy5l0Jz56dHl4mv3noq4UKIw1/CIr2GVhu77HkOGxuzX8ZnYNQIzf5KiGXkuLSpNPme++x6f+NKK2sJXqZ4yXd6fDWNe4AbFvNEzC/ayq/N/4Nd+PjMPPPT65fZK50/a1EITGeZHHyj1c0jJAP6jPUERvLDIiLwMJpoTqbiUTECbM4Lr2/4zkK6vge4Y6XolopjyPeJiWUgxTuziiCoZGeqKPd7scj/n8HwZymHVPo9mbGdA/BhQ6rV4TyOgP4qR/eGFZC4vPR3IKFfx8sunCWBeRSA2BRX3+3Lvk4hTNzrIPVH/bRmuzY/C8TBPs0v08ETNw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 798e04d2-6d83-471d-ddfa-08d9e6b17236 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2022 01:06:45.0996 (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: AM0PR0302MB3203 Subject: [FFmpeg-devel] [PATCH 77/80] avcodec/mpegvideo: Move pb_frame to H263DecContext 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: gkm7yw5EDPIt Signed-off-by: Andreas Rheinhardt --- libavcodec/h263dec.h | 1 + libavcodec/intelh263dec.c | 6 +++--- libavcodec/ituh263dec.c | 21 ++++++++++++--------- libavcodec/mpegvideo.h | 1 - 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/libavcodec/h263dec.h b/libavcodec/h263dec.h index e090f4b39b..7eebffc91c 100644 --- a/libavcodec/h263dec.h +++ b/libavcodec/h263dec.h @@ -44,6 +44,7 @@ typedef struct H263DecContext { MPVMainDecContext m; int (*decode_mb)(MPVDecContext *s, int16_t block[12][64]); // used to avoid a switch + int pb_frame; ///< PB-frame mode (0 = none, 1 = base, 2 = improved) int long_vectors; ///< use horrible H.263v1 long vector mode int ehc_mode; } H263DecContext; diff --git a/libavcodec/intelh263dec.c b/libavcodec/intelh263dec.c index f621c9686c..a5cd6dd1de 100644 --- a/libavcodec/intelh263dec.c +++ b/libavcodec/intelh263dec.c @@ -69,7 +69,7 @@ int ff_intel_h263_decode_picture_header(H263DecContext *h) return -1; /* SAC: off */ } s->obmc= get_bits1(&s->gb); - s->pb_frame = get_bits1(&s->gb); + h->pb_frame = get_bits1(&s->gb); if (format < 6) { s->width = ff_h263_format[format][0]; @@ -88,7 +88,7 @@ int ff_intel_h263_decode_picture_header(H263DecContext *h) if(get_bits1(&s->gb)) av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n"); if(get_bits1(&s->gb)) - s->pb_frame = 2; + h->pb_frame = 2; if(get_bits(&s->gb, 5)) av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n"); if(get_bits(&s->gb, 5) != 1) @@ -112,7 +112,7 @@ int ff_intel_h263_decode_picture_header(H263DecContext *h) s->chroma_qscale= s->qscale = get_bits(&s->gb, 5); skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */ - if(s->pb_frame){ + if (h->pb_frame) { skip_bits(&s->gb, 3); //temporal reference for B-frame skip_bits(&s->gb, 2); //dbquant } diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c index 8467746a0e..15365afebc 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -792,6 +792,9 @@ static int set_direct_mv(MPVDecContext *s) int ff_h263_decode_mb(MPVDecContext *s, int16_t block[6][64]) { + /* The following is only allowed because no h263dec-based + * decoder uses slice-threading. */ + const H263DecContext *const h = (H263DecContext*)s; int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant; int16_t *mot_val; const int xy= s->mb_x + s->mb_y * s->mb_stride; @@ -827,8 +830,8 @@ int ff_h263_decode_mb(MPVDecContext *s, s->mb_intra = ((cbpc & 4) != 0); if (s->mb_intra) goto intra; - if(s->pb_frame && get_bits1(&s->gb)) - pb_mv_count = h263_get_modb(&s->gb, s->pb_frame, &cbpb); + if (h->pb_frame && get_bits1(&s->gb)) + pb_mv_count = h263_get_modb(&s->gb, h->pb_frame, &cbpb); cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1); if (cbpy < 0) { @@ -1037,8 +1040,8 @@ intra: }else s->ac_pred = 0; - if(s->pb_frame && get_bits1(&s->gb)) - pb_mv_count = h263_get_modb(&s->gb, s->pb_frame, &cbpb); + if (h->pb_frame && get_bits1(&s->gb)) + pb_mv_count = h263_get_modb(&s->gb, h->pb_frame, &cbpb); cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1); if(cbpy<0){ av_log(s->avctx, AV_LOG_ERROR, "I cbpy damaged at %d %d\n", s->mb_x, s->mb_y); @@ -1049,7 +1052,7 @@ intra: h263_decode_dquant(s); } - pb_mv_count += !!s->pb_frame; + pb_mv_count += !!h->pb_frame; } while(pb_mv_count--){ @@ -1064,7 +1067,7 @@ intra: cbp+=cbp; } - if(s->pb_frame && h263_skip_b_part(s, cbpb) < 0) + if (h->pb_frame && h263_skip_b_part(s, cbpb) < 0) return -1; if(s->obmc && !s->mb_intra){ if(s->pict_type == AV_PICTURE_TYPE_P && s->mb_x+1mb_width && s->mb_num_left != 1) @@ -1161,7 +1164,7 @@ int ff_h263_decode_picture_header(H263DecContext *h) } s->obmc= get_bits1(&s->gb); /* Advanced prediction mode */ - s->pb_frame = get_bits1(&s->gb); + h->pb_frame = get_bits1(&s->gb); s->chroma_qscale= s->qscale = get_bits(&s->gb, 5); skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */ @@ -1217,7 +1220,7 @@ int ff_h263_decode_picture_header(H263DecContext *h) switch(s->pict_type){ case 0: s->pict_type= AV_PICTURE_TYPE_I;break; case 1: s->pict_type= AV_PICTURE_TYPE_P;break; - case 2: s->pict_type= AV_PICTURE_TYPE_P;s->pb_frame = 3;break; + case 2: s->pict_type= AV_PICTURE_TYPE_P; h->pb_frame = 3;break; case 3: s->pict_type= AV_PICTURE_TYPE_B;break; case 7: s->pict_type= AV_PICTURE_TYPE_I;break; //ZYGO default: @@ -1321,7 +1324,7 @@ int ff_h263_decode_picture_header(H263DecContext *h) s->mb_height = (s->height + 15) / 16; s->mb_num = s->mb_width * s->mb_height; - if (s->pb_frame) { + if (h->pb_frame) { skip_bits(&s->gb, 3); /* Temporal reference for B-pictures */ if (s->custom_pcf) skip_bits(&s->gb, 2); //extended Temporal reference diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 7be9b889ea..8697f0108c 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -87,7 +87,6 @@ typedef struct MPVContext { int64_t bit_rate; ///< wanted bit rate enum OutputFormat out_format; ///< output format int h263_pred; ///< use MPEG-4/H.263 ac/dc predictions - int pb_frame; ///< PB-frame mode (0 = none, 1 = base, 2 = improved) /* the following codec id fields are deprecated in favor of codec_id */ int h263_plus; ///< H.263+ headers From patchwork Thu Feb 3 01: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: 34087 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp2043822iov; Wed, 2 Feb 2022 17:08:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJwi3FSGxLs11YHc+Rh5cgFjJwFu77AMBbD2+PAjCbvornOz7Hl28c/RoTEHRvHeq2N1PZS1 X-Received: by 2002:a05:6402:b6a:: with SMTP id cb10mr32935688edb.191.1643850487248; Wed, 02 Feb 2022 17:08:07 -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 z17si14591345edc.147.2022.02.02.17.08.06; Wed, 02 Feb 2022 17:08:07 -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=T+YJa9PY; 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 3CB2868B18B; Thu, 3 Feb 2022 03:07:08 +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-oln040092074042.outbound.protection.outlook.com [40.92.74.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9E1E268B09C for ; Thu, 3 Feb 2022 03:06:59 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iaZJVXhpZh9vIsD7QBlPX9mowiOhYKguu++umLo26oIGe6D2DIVRFS8bcSNz2CVbYLYGkjA4K7NSVSR/wRgV9bvsz/l2sHwfVkZ3qwR49UhewfLRs8V95R3JuIhyMqemLVoNnx90mhsOWYJBA+2m52qBSkn0PluL1U6fGhCqsiVPvKUBYs3l55/flsvtBuN5EeMnT70Dv/MW1DnNhu8ZFvBvXBYehhfyaZZDn2o7hJmY4QYnYPyUtPFgE1LOVjwthRfZ78TMsY49G9++QZ74HCDq9QymMmvWYMeB61hBpcSPsRqEahlWrjWC1egWwiA/w7WjQIU4h1TB3iHwTqqXfA== 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=5L/BGuifGXMbIigfBznG7KCO0yuGapneVikwpTlEVkc=; b=GjCCmRJZEBNQ4mCt8nJDs4bb5a0CmVeX9mDf5SYFqgUCdf9qMYVQgOZ5Ibk9iHxPEKIAJoM55Q/xdry2D2OUbQgMagk+0jNRDhbAX/REKRatfjChwOqW/wNdolb+PMF8D3zW+DT18HV+wdJ8wBmqYlB+7dXUP4dRfcrxVgUtRkH29/8ynpBeKfls2FuCy3I7cM8h5RK+EZXTRqBVJQmSMzwmkit7hhXau4p88T5v9Xnk7pziAE3VszlhX/rJ+Gy8cKTGPCnU9sbdqFOtKUCXMNFwu3URdZkqkRHNbPXTQ3ENTD5PQTzVOIvuRw5/5bIXrQGue+XyBArjI1ygibALHA== 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=5L/BGuifGXMbIigfBznG7KCO0yuGapneVikwpTlEVkc=; b=T+YJa9PY8qO3KUukPmwpzvtcW+qHd/NDykdur6s5fGeeAmsLQpp3zJG5PMMlCyXrieH5wbaT2bkoOGB/9gEpFINHuk4zyLizp1zdt6mZw+nJrc0teoYLc/ExndmxntkHXd5sFbsI+Fq2I347VRmGUx8dkofZHqJIyEriy921cImvPRSPINX4/sZvVeAUlhyvKCXnUn8u5OeVE+WKfJ1Yi/oEZwXizxd3nTj+BI/fW8RHLEOI8FUUXRT8AerPpd0T4bWy8Bi+tIOqeXmh0WaqrNUdvCurn+MvPNv32WmgABdT4h8SCo3Gppjtk3BQT2Cs2kEjl1Zdw2b/Ei6ezrF40g== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR0302MB3203.eurprd03.prod.outlook.com (2603:10a6:208:11::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.22; Thu, 3 Feb 2022 01:06:46 +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; Thu, 3 Feb 2022 01:06:46 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 3 Feb 2022 02:06:29 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [CHuZeuf/qVk2EcYgIE6vT+QHsOP9c9t7] X-ClientProxiedBy: AS8PR04CA0125.eurprd04.prod.outlook.com (2603:10a6:20b:127::10) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220203010631.1929837-6-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: efdbdb95-8b65-488b-bd84-08d9e6b172c5 X-MS-Exchange-SLBlob-MailProps: +LiGfBxqLEs6bi2B2Md8122fePlSqn4eTvlpIxzoVgYpTaYRpsPv+/jC+4wupklb6o3wWhbzeQaJrvhSu7swrq9BaXkDN+jp5eynwOAJBts9kdedDQ9Qvnd2uPJGD7r1XvYb3N0AF5fQFUwic5AVkC934q/EQazbIGcR4MmCTKNTvYOhaBON1wnFxjxwl1DIOoi0mkSDK+HLIKKbhHhfcnR+Er6IHXVZegI9/Qri8xuTrwcvDteB3qU611UrHFYb3TRrgxKps3QqPTTSl2h982Z5f67HsSaQDAzr40FMVzyRenkl9D7f6tkhqgjgioyNzyEgXp2dYQxpMpQleSJEaA7FshEuvxAsNNaE0hd0RFK/LDn1XQlAlXS06Yap6JlDdsh2HSRY90ePQuGmX5wYpULzSwkUbrpl0m1w3vXgiJtr4nb1R41mBrNAz5GWNknjNjr/vu5FM/5ntpGyF4J/lSwCXTKoi7TvRZwSStEDbWs3rUMiJ5vPFHJumo6Ud3BI7Vqi2fXZJd9axniq3F9Y6NKLO9kNhV0x5qU8ah9okgCLLEXlZMWmwfea5A0Xhrqdf7D5P1otg7D3wPmCRlpt8a60mAVl5Al9NyyVn4rPyEBUN3x7LaliCzim2SMiorVJB2Ou4KLKVG7VQqraIiJyQMFeLGJ2QneLhoah7V0fQdQ6HO0VH9JstrFFwrnK09qFIQH/xkMP3sFVLDLfb4QK1lTjmFH1FJGUKWwel5iGykmniPToPxlB5Ntq1TI2Z6W9b7PCaOELQn/JutvkPxaEh0+LVsHPx6Bx X-MS-TrafficTypeDiagnostic: AM0PR0302MB3203:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TBiTu39eePOGJROx7Q489NYa6u5L8KjJ95X1GXWW9IZySW4Yi6DBC96pXXNExrXvx63jJkc8WxJ+uTZBhuq6YGf6ANLnmYJMgMG4tJmsJLx1LCFKbPc4RygjqN4VRBUVe5qp7NA69WLEtqRVYwwWjt1oa4woKeUbP1OKz8j+CONnaobX+dyKzwfVdpulWkpt+EZrndPNBKkSdaakRg/6QpImYLJPi3kuWYdY+r8JSUj0OXBa61JyVl/9sw9uyU3S5pIS7/3wEjNbFAK8JTA+vDeLjUFmGNJs/jmjNFNgyDpCbZ6RZGKg8HuwD8Ms9iDaWtmr3+vnyeIg3C84DyCn0RoTj8Hf2whVrfie+PlqJCcLtayPfQMTBzs4VXC6WIJTr//FJBtJs9ja3h+5EteE0pdgTuh4IBl5C0oB6VLRXK84OFk6nxMorWh03O2t0r+knbjpQt1rucvnuNJfhzCGirYuHe8ZpBGEmUz3+m0pbZhi74r2b5Dq18cDD07iYlM6YVwC56GhDUqkf545v5Ubh0A2fazxe8/o1KW6PKSbgtX8eDRRfK4jmp4JUBcJ4z8fByYQaEnGS5HbmhESRmiNYA== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Gxo/Gw2AJkAjudKPhaoRKIMQ1cfmiDVG0RYTXy5ceifUgXOivGj2dPrO5G0p3POUZnBn4OehUWz5hq1qOQ7zPQGhQsTRDIWHxfbEs558Ei3JId1o3XZd9RHCL0tUhNfIpyqfkeHMCC2gUg1Nj3ycsT1vuJ9MxwdD/yr5r2964rKV8Ni1vm2E9u8KsHHNC3JD/Cs3KPBeeCnvN8iN5MFT6LCv/eIR9bOAoif2kRZnnYJ1pMZ7YFIx7FRrRLmu+GzrFJBqceMBgL2nhR6TaJ+ka6ASav49yzVaXYTE2o2JS+tfPMgr+OiEgqGbEXc148iLBtU0kFfckW/qJVuQrp2TozYrepI4L2JF6lPp4Gm4xno1mt0rvN2QBjowbkkqhFKDWqlF7s70aEBCJZNZvwN5rH4hQr0Ll3n2iMCKjcSlaZU7DCYA6lfsYzj5W0X78k9lLlUXBsGVCydehFnBvNKiA+RUbqxb83obA2lEA76Wqb4XVWGd7j146x/8gh2c5Bl3wSupaIvcwErKJeyr8TwPVGruZmYX43ewBz72lmiq92ugAULvtjl47ObNGhAjeon7HmzibW4CQt6Pl8/mYRKYOc8PRIlc4+L4I3p2PgX4Ka9HVAw2rl5aGpbjps0D6BkiN6hLwzQ++OYWPcObrPw8GxhEaGJDrhRuCJRHbnMSYfSLuZ4wFHeJ0w1ldsihVRE2VhRfd3i8+ll+f9Pfh8IIylo2kSIEVlDUkU9nb3KrBCuRk1myB31hYn9HsPMtXe/Qk5+iHr1S+tef3SdDaQsUZkRI/MM+4M+5K6vuUtTUjJAdRO0NQXTDC8vlLBKKzPEbRWNYE8smczHlZaTkffitBFkO5CGRIrW71LEUhM1sTHZaRI61usiT2Au2q5bVt1l53Z0xd2hz5ZV7HcZ1jgNLuYl1hzGwitjCjYbrax6gLl7NV/s9aWcJcGGB29U7eZnGjcLoo1vDH6zWs91oG16sqg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: efdbdb95-8b65-488b-bd84-08d9e6b172c5 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2022 01:06:46.0984 (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: AM0PR0302MB3203 Subject: [FFmpeg-devel] [PATCH 78/80] avcodec/mpegvideo: Move packed-b-frames stuff to H263DecContext 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: EQeBYyNpUrgp It is only used by the MPEG-4 decoder, yet it is used in the common H.263-code (i.e. in libavcodec/h263dec.c) and can therefore not be put in Mpeg4DecContext. Yet moving it to H263DecContext is possible. Given that this is nevertheless an MPEG-4 only field, it is kept in sync in the MPEG-4-decoder's update_thread_context and not in a (currently inexisting) update_thread_context for H.263 decoders. Signed-off-by: Andreas Rheinhardt --- libavcodec/h263dec.c | 27 ++++++++------- libavcodec/h263dec.h | 6 ++++ libavcodec/mpeg4videodec.c | 70 +++++++++++++++++++++++++++----------- libavcodec/mpegvideo.c | 5 --- libavcodec/mpegvideo.h | 6 ---- libavcodec/mpegvideo_dec.c | 24 ------------- libavcodec/nvdec_mpeg4.c | 2 +- 7 files changed, 73 insertions(+), 67 deletions(-) diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index db03e04143..3b0ebbdf9b 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -160,9 +160,12 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx) av_cold int ff_h263_decode_end(AVCodecContext *avctx) { - MPVMainDecContext *const s = avctx->priv_data; + H263DecContext *const h263 = avctx->priv_data; - ff_mpv_common_end(s); + av_freep(&h263->bitstream_buffer); + h263->allocated_bitstream_buffer_size = 0; + + ff_mpv_common_end(&h263->m); return 0; } @@ -174,7 +177,7 @@ static int get_consumed_bytes(H263DecContext *h, int buf_size) MPVDecContext *const s = &h->m.s; int pos = (get_bits_count(&s->gb) + 7) >> 3; - if (s->divx_packed || s->avctx->hwaccel) { + if (h->divx_packed || s->avctx->hwaccel) { /* We would have to scan through the whole buf to handle the weird * reordering ... */ return buf_size; @@ -481,26 +484,26 @@ int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, #endif retry: - if (s->divx_packed && s->bitstream_buffer_size) { + if (h->divx_packed && h->bitstream_buffer_size) { int i; for(i=0; i < buf_size-3; i++) { if (buf[i]==0 && buf[i+1]==0 && buf[i+2]==1) { if (buf[i+3]==0xB0) { av_log(s->avctx, AV_LOG_WARNING, "Discarding excessive bitstream in packed xvid\n"); - s->bitstream_buffer_size = 0; + h->bitstream_buffer_size = 0; } break; } } } - if (s->bitstream_buffer_size && (s->divx_packed || buf_size <= MAX_NVOP_SIZE)) // divx 5.01+/xvid frame reorder - ret = init_get_bits8(&s->gb, s->bitstream_buffer, - s->bitstream_buffer_size); + if (h->bitstream_buffer_size && (h->divx_packed || buf_size <= MAX_NVOP_SIZE)) // divx 5.01+/xvid frame reorder + ret = init_get_bits8(&s->gb, h->bitstream_buffer, + h->bitstream_buffer_size); else ret = init_get_bits8(&s->gb, buf, buf_size); - s->bitstream_buffer_size = 0; + h->bitstream_buffer_size = 0; if (ret < 0) return ret; @@ -625,7 +628,7 @@ retry: if ((ret = ff_mpv_frame_start(m, avctx)) < 0) return ret; - if (!s->divx_packed && !avctx->hwaccel) + if (!h->divx_packed && !avctx->hwaccel) ff_thread_finish_setup(avctx); if (avctx->hwaccel) { @@ -679,7 +682,7 @@ retry: ff_msmpeg4_decode_ext_header(h, buf_size) < 0) s->er.error_status_table[s->mb_num - 1] = ER_MB_ERROR; - av_assert1(s->bitstream_buffer_size == 0); + av_assert1(h->bitstream_buffer_size == 0); frame_end: if (!s->studio_profile) ff_er_frame_end(&s->er); @@ -695,7 +698,7 @@ frame_end: if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) ff_mpeg4_frame_end(avctx, buf, buf_size); - if (!s->divx_packed && avctx->hwaccel) + if (!h->divx_packed && avctx->hwaccel) ff_thread_finish_setup(avctx); av_assert1(s->current_picture.f->pict_type == s->current_picture_ptr->f->pict_type); diff --git a/libavcodec/h263dec.h b/libavcodec/h263dec.h index 7eebffc91c..04c238d90a 100644 --- a/libavcodec/h263dec.h +++ b/libavcodec/h263dec.h @@ -47,6 +47,12 @@ typedef struct H263DecContext { int pb_frame; ///< PB-frame mode (0 = none, 1 = base, 2 = improved) int long_vectors; ///< use horrible H.263v1 long vector mode int ehc_mode; + + /* divx specific, used to workaround (many) bugs in divx5 */ + int divx_packed; + uint8_t *bitstream_buffer; //Divx 5.01 puts several frames in a single one, this is used to reorder them + int bitstream_buffer_size; + unsigned int allocated_bitstream_buffer_size; } H263DecContext; int ff_h263_decode_motion(MPVDecContext *s, int pred, int f_code); diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 7e3b672312..2d1463d564 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -2774,7 +2774,7 @@ static int decode_user_data(Mpeg4DecContext *ctx, GetBitContext *gb) if (e >= 2) { ctx->divx_version = ver; ctx->divx_build = build; - s->divx_packed = e == 3 && last == 'p'; + h->divx_packed = e == 3 && last == 'p'; } /* libavcodec detection */ @@ -2811,7 +2811,8 @@ static int decode_user_data(Mpeg4DecContext *ctx, GetBitContext *gb) int ff_mpeg4_workaround_bugs(AVCodecContext *avctx) { Mpeg4DecContext *ctx = avctx->priv_data; - MPVMainDecContext *const m = &ctx->h.m; + H263DecContext *const h = &ctx->h; + MPVMainDecContext *const m = &h->m; MPVDecContext *const s = &m->s; if (ctx->xvid_build == -1 && ctx->divx_version == -1 && ctx->lavc_build == -1) { @@ -2914,7 +2915,7 @@ int ff_mpeg4_workaround_bugs(AVCodecContext *avctx) av_log(s->avctx, AV_LOG_DEBUG, "bugs: %X lavc_build:%d xvid_build:%d divx_version:%d divx_build:%d %s\n", s->workaround_bugs, ctx->lavc_build, ctx->xvid_build, - ctx->divx_version, ctx->divx_build, s->divx_packed ? "p" : ""); + ctx->divx_version, ctx->divx_build, h->divx_packed ? "p" : ""); if (CONFIG_MPEG4_DECODER && ctx->xvid_build >= 0 && s->codec_id == AV_CODEC_ID_MPEG4 && @@ -3486,8 +3487,8 @@ int ff_mpeg4_frame_end(AVCodecContext *avctx, const uint8_t *buf, int buf_size) /* divx 5.01+ bitstream reorder stuff */ /* Since this clobbers the input buffer and hwaccel codecs still need the * data during hwaccel->end_frame we should not do this any earlier */ - if (s->divx_packed) { - int current_pos = s->gb.buffer == s->bitstream_buffer ? 0 : (get_bits_count(&s->gb) >> 3); + if (h->divx_packed) { + int current_pos = s->gb.buffer == h->bitstream_buffer ? 0 : (get_bits_count(&s->gb) >> 3); int startcode_found = 0; if (buf_size - current_pos > 7) { @@ -3511,16 +3512,16 @@ int ff_mpeg4_frame_end(AVCodecContext *avctx, const uint8_t *buf, int buf_size) "Consider using the mpeg4_unpack_bframes bitstream filter without encoding but stream copy to fix it.\n"); ctx->showed_packed_warning = 1; } - av_fast_padded_malloc(&s->bitstream_buffer, - &s->allocated_bitstream_buffer_size, + av_fast_padded_malloc(&h->bitstream_buffer, + &h->allocated_bitstream_buffer_size, buf_size - current_pos); - if (!s->bitstream_buffer) { - s->bitstream_buffer_size = 0; + if (!h->bitstream_buffer) { + h->bitstream_buffer_size = 0; return AVERROR(ENOMEM); } - memcpy(s->bitstream_buffer, buf + current_pos, + memcpy(h->bitstream_buffer, buf + current_pos, buf_size - current_pos); - s->bitstream_buffer_size = buf_size - current_pos; + h->bitstream_buffer_size = buf_size - current_pos; } } @@ -3532,7 +3533,9 @@ static int mpeg4_update_thread_context(AVCodecContext *dst, const AVCodecContext *src) { Mpeg4DecContext *s = dst->priv_data; + H263DecContext *const h = &s->h; const Mpeg4DecContext *s1 = src->priv_data; + const H263DecContext *const h1 = &s1->h; int init = s->h.m.context_initialized; int ret = ff_mpeg_update_thread_context(dst, src); @@ -3565,6 +3568,26 @@ static int mpeg4_update_thread_context(AVCodecContext *dst, s->cplx_estimation_trash_b = s1->cplx_estimation_trash_b; s->rgb = s1->rgb; + // DivX handling (doesn't work) + h->divx_packed = h1->divx_packed; + if (h1->bitstream_buffer) { + if (h1->bitstream_buffer_size + + AV_INPUT_BUFFER_PADDING_SIZE > h->allocated_bitstream_buffer_size) { + av_fast_malloc(&h->bitstream_buffer, + &h->allocated_bitstream_buffer_size, + h1->allocated_bitstream_buffer_size); + if (!h->bitstream_buffer) { + h->bitstream_buffer_size = 0; + return AVERROR(ENOMEM); + } + } + h->bitstream_buffer_size = h1->bitstream_buffer_size; + memcpy(h->bitstream_buffer, h1->bitstream_buffer, + h1->bitstream_buffer_size); + memset(h->bitstream_buffer + h->bitstream_buffer_size, 0, + AV_INPUT_BUFFER_PADDING_SIZE); + } + memcpy(s->sprite_shift, s1->sprite_shift, sizeof(s1->sprite_shift)); memcpy(s->sprite_traj, s1->sprite_traj, sizeof(s1->sprite_traj)); @@ -3577,16 +3600,25 @@ static int mpeg4_update_thread_context(AVCodecContext *dst, static int mpeg4_update_thread_context_for_user(AVCodecContext *dst, const AVCodecContext *src) { - MPVMainDecContext *const m = dst->priv_data; - const MPVMainDecContext *const m1 = src->priv_data; + Mpeg4DecContext *const ctx = dst->priv_data; + const Mpeg4DecContext *const ctx1 = src->priv_data; - m->s.quarter_sample = m1->s.quarter_sample; - m->s.divx_packed = m1->s.divx_packed; + ctx->h.m.s.quarter_sample = ctx1->h.m.s.quarter_sample; + ctx->h.divx_packed = ctx1->h.divx_packed; return 0; } #endif +static void mpeg4_flush(AVCodecContext *avctx) +{ + Mpeg4DecContext *const ctx = avctx->priv_data; + H263DecContext *const h = &ctx->h; + + h->bitstream_buffer_size = 0; + ff_mpeg_flush(avctx); +} + static av_cold void mpeg4_init_static(void) { static uint8_t mpeg4_rvlc_rl_tables[2][2][2 * MAX_RUN + MAX_LEVEL + 3]; @@ -3663,11 +3695,11 @@ static av_cold int decode_init(AVCodecContext *avctx) return 0; } -#define OFFSET(x) offsetof(MPVMainDecContext, s.x) +#define OFFSET(x) offsetof(Mpeg4DecContext, 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}, - {"divx_packed", "divx style packed b frames", OFFSET(divx_packed), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS}, + {"quarter_sample", "1/4 subpel MC", OFFSET(h.m.s.quarter_sample), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS}, + {"divx_packed", "divx style packed b frames", OFFSET(h.divx_packed), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS}, {NULL} }; @@ -3694,7 +3726,7 @@ const AVCodec ff_mpeg4_decoder = { AV_CODEC_CAP_DELAY | AV_CODEC_CAP_FRAME_THREADS, .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_ALLOCATE_PROGRESS, - .flush = ff_mpeg_flush, + .flush = mpeg4_flush, .max_lowres = 3, .pix_fmts = ff_h263_hwaccel_pixfmt_list_420, .profiles = NULL_IF_CONFIG_SMALL(ff_mpeg4_video_profiles), diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index d0fbdaf1b4..1ee8e7458b 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -643,8 +643,6 @@ static void clear_context(MPVMainContext *m) s->sc.obmc_scratchpad = NULL; - s->bitstream_buffer = NULL; - s->allocated_bitstream_buffer_size = 0; for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) s->p_field_mv_table[i][j] = NULL; @@ -792,9 +790,6 @@ void ff_mpv_common_end(MPVMainContext *m) s->parse_context.buffer_size = 0; #endif - av_freep(&s->bitstream_buffer); - s->allocated_bitstream_buffer_size = 0; - if (!s->avctx) return; diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 8697f0108c..2b5267f1c3 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -339,12 +339,6 @@ typedef struct MPVContext { int mpeg_quant; int padding_bug_score; ///< used to detect the VERY common padding bug in MPEG-4 - /* divx specific, used to workaround (many) bugs in divx5 */ - int divx_packed; - uint8_t *bitstream_buffer; //Divx 5.01 puts several frames in a single one, this is used to reorder them - int bitstream_buffer_size; - unsigned int allocated_bitstream_buffer_size; - /* RV10 specific */ int rv10_version; ///< RV10 version: 0 or 3 int rv10_first_dc_coded[3]; diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c index 8f3c401aff..7bbae2fa47 100644 --- a/libavcodec/mpegvideo_dec.c +++ b/libavcodec/mpegvideo_dec.c @@ -77,8 +77,6 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst, s->current_picture_ptr = NULL; s->next_picture_ptr = NULL; s->last_picture_ptr = NULL; - s->bitstream_buffer = NULL; - s->bitstream_buffer_size = s->allocated_bitstream_buffer_size = 0; if (m1->context_initialized) { // s->picture_range_start += MAX_PICTURE_COUNT; @@ -154,27 +152,6 @@ do {\ s->low_delay = s1->low_delay; s->droppable = s1->droppable; - // DivX handling (doesn't work) - s->divx_packed = s1->divx_packed; - - if (s1->bitstream_buffer) { - if (s1->bitstream_buffer_size + - AV_INPUT_BUFFER_PADDING_SIZE > s->allocated_bitstream_buffer_size) { - av_fast_malloc(&s->bitstream_buffer, - &s->allocated_bitstream_buffer_size, - s1->allocated_bitstream_buffer_size); - if (!s->bitstream_buffer) { - s->bitstream_buffer_size = 0; - return AVERROR(ENOMEM); - } - } - s->bitstream_buffer_size = s1->bitstream_buffer_size; - memcpy(s->bitstream_buffer, s1->bitstream_buffer, - s1->bitstream_buffer_size); - memset(s->bitstream_buffer + s->bitstream_buffer_size, 0, - AV_INPUT_BUFFER_PADDING_SIZE); - } - // linesize-dependent scratch buffer allocation if (!s->sc.edge_emu_buffer) if (s1->linesize) { @@ -585,7 +562,6 @@ void ff_mpeg_flush(AVCodecContext *avctx) s->parse_context.index = 0; s->parse_context.last_index = 0; #endif - s->bitstream_buffer_size = 0; s->pp_time = 0; } diff --git a/libavcodec/nvdec_mpeg4.c b/libavcodec/nvdec_mpeg4.c index 6d5ac8cd07..61e9900c32 100644 --- a/libavcodec/nvdec_mpeg4.c +++ b/libavcodec/nvdec_mpeg4.c @@ -71,7 +71,7 @@ static int nvdec_mpeg4_start_frame(AVCodecContext *avctx, const uint8_t *buffer, .quant_type = s->mpeg_quant, .quarter_sample = s->quarter_sample, .short_video_header = avctx->codec->id == AV_CODEC_ID_H263, - .divx_flags = s->divx_packed ? 5 : 0, + .divx_flags = m->h.divx_packed ? 5 : 0, .vop_coding_type = s->pict_type - AV_PICTURE_TYPE_I, .vop_coded = 1, From patchwork Thu Feb 3 01: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: 34085 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp2043610iov; Wed, 2 Feb 2022 17:07:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJxz/72dOMixdBOeP8xqEWTXmlJQvrgLUb4+cQ3CjacBaikqkwe7SZghkOqBuZpSY2HH43uF X-Received: by 2002:a05:6402:26ce:: with SMTP id x14mr28641967edd.211.1643850468019; Wed, 02 Feb 2022 17: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 jg27si12680543ejc.363.2022.02.02.17.07.47; Wed, 02 Feb 2022 17: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=hDU5K5eO; 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 58E2468B175; Thu, 3 Feb 2022 03:07:06 +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-oln040092074078.outbound.protection.outlook.com [40.92.74.78]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 15E9468B09C for ; Thu, 3 Feb 2022 03:07:03 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OKqp7gNKsA2o//uVr5uBnh1GLwveqyIJtBusxP94wxLdDrcK39Rx/tdu10P7iw7VttfOkAcke2pZARz8qKmH7tprSqMrDOqhjBfehnscS6JhQYKUvwrIoLr00abWwhvpAfEVAHuwWdxEEUBbHwJ/YMTJkkzxq+3ojzXr7rmFHCFx2btHwIxQD+3UewfTf5rAXyXIlvGpT5K6sGFZhqgxIIyAbre6UCC4glrDGMyZmNmhlXAWuAVDarCf5E86v88kMUsBhFXR3yLisgnZeus/40icWPhJ3EQvhHwOOc21MtAAXvdWuAIp4WH+NDrpRg+TdFMdWLuvKgjnbb21O1cZiw== 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=KPVvmZCStk7KTmHBFBmZMBTf4bjzie+uKrEYRF2R55Y=; b=fK23zbW5DjUo0H9ZaNtt3j0HySZAeZBpYMwAkyHrOYUlatPo2v2Kk3UIbTZIk6LW/T/f1Nt1uQpi0s7AMWlS88aQP1oCY1X1scBp9MfZ2/HXoHnje92qZ25vOge3lOgGNPVuYoywfZ+zNWmrb9enpIFU2W4qudctyiI7xCCg6Lf8U4FmjM82KWVouY3TtDzksJb/sMsRKXTCjGs6MN6/ncWDOl3VGjqNRzTyLwQ3s4cUE3pdsbUpERPZI1S9ZWbnMqA+xZbge1vDRgOP/8SSgXEEMp3unRQqyF/Do8n9sWp6j/r/zns3dpxeQmKY+LT1B4IJ0M38WnBHiX/8O6O2wA== 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=KPVvmZCStk7KTmHBFBmZMBTf4bjzie+uKrEYRF2R55Y=; b=hDU5K5eOZGQeny3pb8BxG+O+9BgmCe3OFWeWyE1GGGgDggk3Clynule7dqaoXrAOWAKUYIIVX144wD31Hg3C5hKRk6TeJxw0m2MX7hVgEs0oloAnR1xocwdUEy+e29/u4ovTrjOfFwbo5PFKC1pvXDKRE8CrP6FBp5UQy8PdaHZgPQf9dRNluir2nEC7lTiTtovIm5bz3MU0y4sT6O63Fi98+A8NsNtt+g+0sTkfovpN8Xz+Or2KNNE/RWqjL5b/uPsFIqtv/5PbEgBaFogeMhBA4DpBu4YF8njafzeUgInfEedSvlV3CXDgMKzcSPVmHFVzHMyL7IygGIA9s1qcAA== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR0302MB3203.eurprd03.prod.outlook.com (2603:10a6:208:11::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.22; Thu, 3 Feb 2022 01:06:47 +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; Thu, 3 Feb 2022 01:06:47 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 3 Feb 2022 02:06:30 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [RCjwjR8KyUUxj2Mg++Mia0YYUluYvMPU] X-ClientProxiedBy: AS8PR04CA0125.eurprd04.prod.outlook.com (2603:10a6:20b:127::10) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220203010631.1929837-7-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3e2753ca-c596-4179-6429-08d9e6b17389 X-MS-Exchange-SLBlob-MailProps: +LiGfBxqLEs6bi2B2Md8122fePlSqn4ekpOhm8wG9HdVRcR/O36BBy+6lZRurYZrHu5s1uyNXR2d+AsVsH/Zq2rW4jn3IGv6U+ew6Lwkdbvhyp1QHJz8JyLr54q7AMJABkZan2WbgXKuec34b3Fd6YKJwEveTA7FMyJTyZCcuRoB3rjxPN7JIHZIuHhpm/ErkIQVIOl+nIDQElZ4EeMF8vQUg+Y24UJJzfKhK9E39KM7Cf2cMsAWz/W96mauppWYSW7x3dLASvcM4JZPu55b3i8UhZtm+LTU5Mq/JmO6wQCzgOG+e5YlrfMPKaark9v2/6/L5C0odVpxXMO8PMTH+4L1XixC1K76j8QnSGP9Mf/VIdQgCHSperr4PqFJh7GKczLhujJJ6g6KMsbwt78r5odLh7p6JS+RM5qKNMECv0wFtUXRKJloyXVWHpeDow2x5zW1HiJqTKhOFL1kv1a67MsoWXpxuzJVo7/z7KVCwoQw412qNfbfspE/FpDK77MX5lGcteHd0Wbzcoq1y5nsFdsMmelRc01/QibmfRQdLIFNFNXz2jsH5dk2MmL4QVtXKlNFZkS1KrbfneylOWU/UtCtfcf9mL5nJbfQcqA+YNrVCk6lH7QyWJtujrBk5KTU2lvOFmo74Er+EtOpNj8xdGzd49PUdd7e8oEQnffi00tuZ6mq3dc3J6pumQ+qc3xyuTCmGm26AOntfm0+5NjrukGK0xZIsq4PUwQ2tpTtH9821Y+tKYdwHxBIct19zRJVPpJMBNj2M9JiWhs+BOXSXZT5GfcFZpnF X-MS-TrafficTypeDiagnostic: AM0PR0302MB3203:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YxL8utlo94faqQSI59OpegHjrKuvxWoI7owJSjEDQZFMnHJjEQmExw4CjZlNdGufrc0GxzJjYVE4Xa+z6eePBxHQlpio2I8wbPFNiRo8HYKHjMBi/GN8oKNfhVYNkaSQ/8c7kGRI9W/BVDnET9yYL6IJafvGn5LptbKi4MVbbN3IzRlKMKuLQ2pR8goFiNiTcsQbVHnE86AqwHbvv/SboT/M4FFEfnNlnixMcCXjK4GYtq8am7Wl9NElNgFhORSuAAnn0VQLjiIkQjDREFWZWDErMIr19LEida1Nh/43V8LYWbASk64NT6ut4PcX7kcVESqItbPc6npJasez6/+vvXXqR47dzwF0JZtbR75XQnpMDHiokuyhnN1id592R4tOs+CVfocmEZQAS8qwN4jwinq5qYllLZQXhJpt6aU8evmjd+QNBq1T+PeKSbjZEb1f6H5ovpQjDP3rfSctwq3QVJYuSuYzvG0K8pRC3GOwC4wbSWPwThm7Nc1uWxL/m+XqJCIgJoUxsIFuQmmKq/a3XeBQQzyhTfrX8zdxQEy1FSK4oNft4gS5SRSDrxeFvxICTeNDx+oaKmunIC2Do+CJzw== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XGBc5s2x01szd8gcve1vV9tBUNkLXKmqwtRm0Rzz0Q6Gr0aeVC7oEVxasaYIEcgWvTWH3F+U0Y0d6Or7pPnvxQcXisPX1DgXRYtKjuR/4EF6OnfBshBJXccnAKoAiPk3jgUbKh3K18xXxo/NRqn9gUEFWn8/ezwnK4mozJAbQMfBayY83HyulPQMBPHdWwu9p66+VqBfYsBsyU8q0d+sf/1/ILDBRTZ9xvOM7CpkWrZt1S6ScV1KpDt3eRd9S5lB+0u4pj37ZFLS+4yF+YaZBXWvrPEywBXb7/l2hp0LFG9C1GL2N+FnHO10Kua5LfQN6hoIPL/aRDfHPhUvT1nVGD/Ir4WFvkzsJQ7Ow1Ib5tL9o/IZAXYjI+SjYmkd6Er0FvQ7V5PmDBQznKJcnRMRaxR0bA1yKB//9qBf/6WxPTbKgGt2PTlDAYnkhI+af8XH2uOIdx/uptJvsygqM/BhbZucBLP18nBTMfQAEKD745/Dz46f8wQOv/6Z81PEdEGUjHdlvUY+pwchDNQGke+fPK/LTNYPwMvOmRDlb/u47MRk2+9Z/RHJ3KIAahSJ58dnEvHGPG+FNsG5KwkdqIWePnlEDATRNqihPxRLzBh7GBdeMaV00yZi4MNOyfyk6b8lz5lbUJhPYNEf/qztf5rgbPTxR3npjqT1X9YaKiVOz179/3aykS/Y2Od82tF6Ii21m674nGzR3WdLdwrJTkO4fhn5zF8uDmMaLQirTdn7ubThTENeLGE2C66ILKZ5a6vbwNmEzIcZJmfZJKEJH48Fydi/HYGzOiyCOZoGNuKzfF89VilD3RVMGM4JjG4SAsMcMWkAYVVbQgRzZwLssKkbIdgQ1IQFNqer+lIuNvDA3AGXO0vR6M/9Uhc6mKyzudFr5rzDddgBfP30SL5vC+sb9dBt6UmiqKOs2uz+QdNEj3+l0M2uoF8ohCnVgsOn8x2UI+kciDC1bJ2YijPH0+Hh5g== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3e2753ca-c596-4179-6429-08d9e6b17389 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2022 01:06:47.3650 (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: AM0PR0302MB3203 Subject: [FFmpeg-devel] [PATCH 79/80] avcodec/mpegvideo: Move custom_pcf to H263DecContext 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: KEKlWrvWkh27 Signed-off-by: Andreas Rheinhardt --- libavcodec/h263dec.h | 1 + libavcodec/ituh263dec.c | 9 ++++----- libavcodec/mpegvideo.h | 1 - 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/libavcodec/h263dec.h b/libavcodec/h263dec.h index 04c238d90a..539f2df01a 100644 --- a/libavcodec/h263dec.h +++ b/libavcodec/h263dec.h @@ -47,6 +47,7 @@ typedef struct H263DecContext { int pb_frame; ///< PB-frame mode (0 = none, 1 = base, 2 = improved) int long_vectors; ///< use horrible H.263v1 long vector mode int ehc_mode; + int custom_pcf; /* divx specific, used to workaround (many) bugs in divx5 */ int divx_packed; diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c index 15365afebc..0ce0b1c795 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -1184,7 +1184,7 @@ int ff_h263_decode_picture_header(H263DecContext *h) /* OPPTYPE */ format = get_bits(&s->gb, 3); ff_dlog(s->avctx, "ufep=1, format: %d\n", format); - s->custom_pcf= get_bits1(&s->gb); + h->custom_pcf = get_bits1(&s->gb); s->umvplus = get_bits1(&s->gb); /* Unrestricted Motion Vector */ if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "Syntax-based Arithmetic Coding (SAC) not supported\n"); @@ -1267,7 +1267,7 @@ int ff_h263_decode_picture_header(H263DecContext *h) s->width = width; s->height = height; - if(s->custom_pcf){ + if (h->custom_pcf) { int gcd; s->avctx->framerate.num = 1800000; s->avctx->framerate.den = 1000 + get_bits1(&s->gb); @@ -1284,9 +1284,8 @@ int ff_h263_decode_picture_header(H263DecContext *h) } } - if(s->custom_pcf){ + if (h->custom_pcf) skip_bits(&s->gb, 2); //extended Temporal reference - } if (ufep) { if (s->umvplus) { @@ -1326,7 +1325,7 @@ int ff_h263_decode_picture_header(H263DecContext *h) if (h->pb_frame) { skip_bits(&s->gb, 3); /* Temporal reference for B-pictures */ - if (s->custom_pcf) + if (h->custom_pcf) skip_bits(&s->gb, 2); //extended Temporal reference skip_bits(&s->gb, 2); /* Quantization information for B-pictures */ } diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 2b5267f1c3..1be77bc83b 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -309,7 +309,6 @@ typedef struct MPVContext { int alt_inter_vlc; ///< alternative inter vlc int modified_quant; int loop_filter; - int custom_pcf; /* MPEG-4 specific */ int studio_profile; From patchwork Thu Feb 3 01: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: 34086 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp2043709iov; Wed, 2 Feb 2022 17:07:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJxK5XBP7k/2Tc5xcdz6Pcb8SVHGKJ02ROiJ4pWFF4zRMLNysFeAGGnPsnvkkojERZKv6ETN X-Received: by 2002:a17:906:a002:: with SMTP id p2mr27819484ejy.129.1643850477463; Wed, 02 Feb 2022 17:07:57 -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 ne16si14986970ejc.424.2022.02.02.17.07.57; Wed, 02 Feb 2022 17:07:57 -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=TXnw4u4N; 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 489EE68B169; Thu, 3 Feb 2022 03:07:07 +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-oln040092074078.outbound.protection.outlook.com [40.92.74.78]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3705268B158 for ; Thu, 3 Feb 2022 03:07:03 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VfgxAbk9Zl+6QDRDJyvj78lbRL/O+nM1u7od/lxEn0LEndXS/AW54+Jrxjw46DygKkTBlOJ+3fcvZ2BPYzVRBkAIlZgaRRLnD4M54jJ5o/GOrFWx9tQWwB+C2hNr0d4MOAtB2k8Tkw/68BtFcvlzV426IzQr2NC2KA7xK+d63nDc+yrnhyQoqFDx4P49aRW5h1qHZMipyum1EGC0SGuV6W2rLcUrZ8DRtlWxM4/Y1qedDaNtCsA1bQwk/PVa91IRbhQALSc4eA7a7mbgBNbo/nH8gmDINoznNmuTefDT10I1HPLIGq6y/SzZ4l7cQ9Tmo9ZdLoo5/Uh6VEGrMGt4gQ== 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=VKOsKvgh1N0TTS/NOoDZz5v0Dz14fF4VLOG2CyFGzpM=; b=d3dGQVl8FxYsp6SQEZvR9GYpjHvihtccB+9G1SBbym3lTpQ8Jq0fmjz3ta/e3/Zz+yrxVQXup7Qg2G/Cce0lrD6/HnBvAwaOHdTTN5/q1iUGxEt9ekd8ROBEpbGhnmKxHH/5LGVjBC9i5p3RWGwdxQk5hKrFXOVv/tpMENRUDRIHqUM/auzVSpqu/yRo6+LogU3syXfZtQwl9pSHESzSCDeVFFXuTfvetHYkCopQ5srhEjAil52mbfZk/U+4SBliQEUI98hyVBwNZLP963B7QWHXBjzGFD6x8VR7PmUoUQGerqiEkzIlhuXx+lSKPVZiDjratAGUzR7DgNB+cIG8ag== 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=VKOsKvgh1N0TTS/NOoDZz5v0Dz14fF4VLOG2CyFGzpM=; b=TXnw4u4NVPg5vhwUA0ZpvCXelc78ihhyaJo8+eg5dlBmzPZXDN4T1YpvS3nWKAkBd9XhdpmisN5gcV91gut4a8BeF1e1mPcmTj9pQK5rSH3wsS8l5Q7312Rm1rRhT1wqFfjsiUOjfuEGiAy2RZiSAnI8wObXXRp+QKaJi5Zj/ijydux3YPUu7K2Bm/ptzaATWDFfbNCS9R2sWg/DikB5SrD+HKkWtcVEejWyzsgNzPj8t6naSQ2AsiwhJnv6bzp5pPWrY4kLOvOzVZOsQMgwsRbncAB3tzwN+IYtgChIZzjl5xVMQLrAhQbtx8Kz85tiwOx/t3uvwsi1yoq+dbx2OA== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR0302MB3203.eurprd03.prod.outlook.com (2603:10a6:208:11::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.22; Thu, 3 Feb 2022 01:06: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; Thu, 3 Feb 2022 01:06:49 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 3 Feb 2022 02:06:31 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [VK8pY2pwy1vga+nTmNzYnFMpjnXzMkMB] X-ClientProxiedBy: AS8PR04CA0125.eurprd04.prod.outlook.com (2603:10a6:20b:127::10) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220203010631.1929837-8-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e0b03e2e-f11b-4700-b1bd-08d9e6b17483 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiTIIJz7w/iaHvlKLnqIyVAx6qv6WnZ0arBwNe2fmGE34zrSbu/0BNkYsKVMRTwWJQvjRBijxnYRBrmVv2QkohvxY5qcTFWH8YhUSlrisiC5HJG8etCi4VDpbcO6juQbElEv3g9NGAfjD/rxMSX4AbpOBXOgWLaMcbZWPVM18UFNtkhHEp0o9ieM0sTeOmd24OvXTkhiEJLafS8Z+nRkRLEACJzr6qzoLO1ZkzryzSyzO6aLGdvHG4nMvH/47dOAJzLNWvzZ4ph1Qmzx33JB64CGg0V+66OEZfalNXSN498Bqo/yoLKE7nNQXc1obx2dluHFTArzJEyhtel6LJycGxJx1YURsbC9hRc2et308awCu9gr5bVz+Rt5HD2n8DlIfpwmy3G2fSQ7DPP9lK+EgzJ3jyECWZmZjlDSjfYz/+HtGJXWoh4fX6h96lzGVE7MdKzc1yJRuLcRun7oRBdAhJPtYd39VmedmKYOe10ApYiP7v2tygpty5MRqrFXvD6wfX+wUNiIJ6pfqYvCw3xLbmSYTI5n18Gar2TraB0tFBqc+e0KmzLTNSmdQ2UOWUJ3KfMWlNWuB6Daf7mHfdgm23HMsmgFlTObDOpuOfhoC7da67rXVUy4UumPaNNYiIpoLBlgFM82MFBBvHz6uj60k4DNiAJBx22YcEqsHztFYDkyd5S8FjZ2li5/DoCE2P0is7nZ/8GKkcKjUd6kwLe+EOLjmBG2MiYminDZTEEIzBrdH39DezsyHobq5zj70/5T7C8= X-MS-TrafficTypeDiagnostic: AM0PR0302MB3203:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rrZwX0ejZ75cqeN6hfz5uttJ9u0vBrBAA2/Z2gEhljuUjlUmmkDI+AcZOnSueW6LqpGTQ0uFWPWuMK2Q1ehaoAPW5pdsG84u2fHEVo0E6qGYM+IaKvqUuf6Ffs+6H5pnJf7tQyCbXRwUhxqRkYvNBOT6Zhw8gJVLTv4Q8ozDVFGu2ilOHTfRqIB9Vv4K2foORUPfKytO84wm/lemVXnyqlwvK5pSzg6sOrAYqiM/QVtsk9Bnimu76jaygLqq9C+n3Xvt8agMOd5Km31SopQEDj1QJtOCKl+QDiPhNRmP3sadJyR/LXRTGh7+onm4Ye9heAhHNwVI0ucPZdjQ61CXCwXefpsry6ado5LDBqSAzdeujg17Qu51GmXi82iVj7AoBqX3eN1Ny3qpIBjmJ6x0YVid2bTAJ7YS1IUdXCSapfWfwBmcxUcq8Qz51GX/5gf1Lw8o9AnB6kW1Rr2xn1/9Aypuiva4SWtslnP4KHp7FbT6y7poxlQdmgQXmJy+Rzm4on76Yqm/mber3jyvdAkRqDuXDrCIRNmAc9uLJKBc6R7L2vlNwMTNZTvs40c2Wed/JPRAHNxsg+dJOQyY6L4WRA== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dJ6JzrFvy3ELrr2NT7mTWv2NwsZGLkOhB0pGQ4b9fVgKzSA8kwHzOItJKH93P4Ei9eCgaloFj+2snX/SBWD3ZT53f3MpBwUpEd5jEMRilTWu1btEC1+A5W2z9wWmQaySmO3zq7ae2yv0/LXzQbw3u6YRdpfX5pQhK+Dx9IKHojGa57LV6/yVAfzkkoIaOVYo+g0XXhwINYN9PrAr4zoDjl+kKqh9sAi2Nt89uK3QRm4+agckhIqMjFk/xCRaz3bhylhHXKaKPWZXuNqzYej06Dp1UZYG3ZpxVhMUCfn6G0fiJWqkPmaD4rxipHbOGv7yuc0bok30iNExqkFNhLOMARsC6G10RfKy/S4/RJ2CWvxSva7o08Bq+477J4kBsBG3LdgylMVIaDcZNYmPjbXywIeNshysRUdX9Qt2cKkDYkSdB4cyG40fQeZIClrwXE99KknqCdHkgwZa0rAhW+/3TCEcxpTQQkzOkE8o4SCma+vtztoCWJPl8IuKxChO8s6gn9DS88Qn70Ka2EtZeV1HYi0jPJ+T+qQvpjx/HcEqBq0vY9VruGonPKYhtsgTApbeHN5KqcxeRZvYjBuQgUHV5nJzB+h5G5Pjbhlp41j8yvEewj7eQPjX9ru2iTqVSGuG6vgZ3uoLiXqNQYYMRZPteaQ+T/nk68xqEh+3YPLzgFKvy/9YqTs5TKbSayhavGYO2IthEHMdyt/mKD7KyJzH6pA1tBtjWa71f5McTHHZzbZQ6RRfLT2v2H5Fm0fLhvpZz6Dnd2/rBUHWLrMKW9Y1H30Oz6qLhPWd7T0c6ovLBHOzYIvt3JfBFG9xEDxqI3S1AGCsYXWOjUh9GHgwwCWdK8zRpJnwGnb+HkDy3mvzopNvyEi3B377O6CE5FJU2eGLhaqBE2QEt+Zg/eFZN18ZYOkRkH5z5liMXAdMOdDb1NcQ3H6U+VTuTJDI3uYaYyQ2P1R2qWE3UjhiRd1eZVuAOA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e0b03e2e-f11b-4700-b1bd-08d9e6b17483 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2022 01:06:49.0378 (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: AM0PR0302MB3203 Subject: [FFmpeg-devel] [PATCH 80/80] avcodec/mpegvideo_enc: Remove redundant unref+ref 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: lK6MCYv6Akd1 Setting current_picture will already be done in frame_start(). Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo_enc.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index ddfd123c46..9c68983205 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -1598,11 +1598,6 @@ no_output_pic: s->new_picture->data[i] += INPLACE_OFFSET; } } - ff_mpeg_unref_picture(s->avctx, &s->current_picture); - if ((ret = ff_mpeg_ref_picture(s->avctx, &s->current_picture, - s->current_picture_ptr)) < 0) - return ret; - s->picture_number = s->new_picture->display_picture_number; } return 0;