From patchwork Sun Nov 7 14:35:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 31321 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5e:dc01:0:0:0:0:0 with SMTP id b1csp2579129iok; Sun, 7 Nov 2021 06:35:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwCG6OkHDnTni2u8lTv5YDcPBEEw8y48PVAkKJHe8FaXbUIEwy+iWMZ8bXzftFT6Rue+e2o X-Received: by 2002:a05:6402:41a:: with SMTP id q26mr53633310edv.387.1636295736569; Sun, 07 Nov 2021 06:35: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 k19si13435047ejv.762.2021.11.07.06.35.36; Sun, 07 Nov 2021 06:35: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=ikKwF7cy; 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 3E635689A2B; Sun, 7 Nov 2021 16:35:34 +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-oln040092066037.outbound.protection.outlook.com [40.92.66.37]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C147E689A2B for ; Sun, 7 Nov 2021 16:35:27 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OB8H8hMXeQHy2sZFRMszJ8EhdWDzCN7rH8G+1ULJQRqixy58xBt9NOBppYAVLv7DDC/yLBpUZch0OaTc8UBZZPvJtStMY4FaN0p5+UH8B0zgGv7s8GnZ3E9E2PBut8PG383oPWApHpokGYpChNYLq990GamyZtkAfbTbLM+P7qXo+HeA8gu5AsLWaEYujfRJDoH58a1mTFuz+VPORNlv39S5IBoxBzuMNoZnYqfmKpaGj99f1jtgZljiaBVnsq6kV+2XmjPHKfMgYW6FHwALqv9QBci+8ubPwOw8pR0olzSxT5KiUv/2/GAxtDx5stnW3QCKXq8RKN7j/H95S3b58Q== 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=UpaF6MgI+D0MUqnIBMJMO0IwjoQyDmRMxp39S+9Axms=; b=WiLAfJ4yjonzLnGIPuDuKvhZPVMWWgbaTI8D895zPz4MnbiDbeUPiV7Z+UCMeYLT6yYarCummXBtwTBNg/VEZ1tAjm8WdSns+PCjq/4m+iXXmFOYdnVA90qqLbU/fS/u4b6Z01I24/+pu1o8fVu+jqmgHbI1cPy3AuvdGtDtDs357oD6IVql+wNRWkPWQsL9sr1moozYEDlerojDBy8O7ru3wam5imY8VL0U6+FDBeZh2N9QPcWQ1KUPp8EyA9t8nEg7lbZZQhOjFXm1EOEszzmnX+1z8rSWz8UMV7qKgqs/OIWUC0UpvyLE50j1O8CG2i9OrBQ6mEpu4jrQ3GZgBA== 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=UpaF6MgI+D0MUqnIBMJMO0IwjoQyDmRMxp39S+9Axms=; b=ikKwF7cymwjS1zBU3C4qazNDpNzvXZFqAMSc+v0fpGdt/SK19IO/bbvw8frGqf+wzLb92rKnFAmRE1+vev43cPGgUIRvT48MKY+afyH8b4aaVQdAQtaeQWUXWMUOy784Bo/U2lMK4qIFL0mbKzyqDWcPvYxy38KVOEr60rDXHBSytFQkxrX/uehza/42iwguT5soRrWH96x/f6d6xT7QUbVVhcVdJtGa4m6Oyn5wQqdthYiYI+Wd6R2YBPLIQ+1JQOnRaj+UvN0z7jU+1yNUuqxFyAuryoI9ESTQ4hdyoTN2g0eX0fjmt3en7SU26CpS6eLjsHxjR/ueB4A2FjKRKg== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM5PR03MB3009.eurprd03.prod.outlook.com (2603:10a6:206:18::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11; Sun, 7 Nov 2021 14:35:26 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::700f:d70b:3bb8:4d51]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::700f:d70b:3bb8:4d51%8]) with mapi id 15.20.4669.016; Sun, 7 Nov 2021 14:35:26 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 7 Nov 2021 15:35:16 +0100 Message-ID: X-Mailer: git-send-email 2.30.2 X-TMN: [cTC8HTOCzlX6Fjykts7CswgqN+B1tAwf] X-ClientProxiedBy: AS9PR06CA0350.eurprd06.prod.outlook.com (2603:10a6:20b:466::10) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20211107143518.213841-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.193.171.90) by AS9PR06CA0350.eurprd06.prod.outlook.com (2603:10a6:20b:466::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Sun, 7 Nov 2021 14:35:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d15c6013-bd2a-4ee6-7bc9-08d9a1fbd6b7 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNUrfGsDrLJjePn49Wzo4gGl9LU1bWZ/a+EGzNFIeEQXPsGQGhk+RHbzwpleLvNkFCx/+2NViWsKN0ItHqCFiblFJFRqxQDWmF8OwnjsN9uXYFquzUj/piUHEfG8pOcm5JL8P2xX7JsQQGr7GccG6WP1/QFnyatwmPh+d3PV+gMhB9MB6biOxtENq+8ZRXMsGN8xHNkmA2a3xGzk9JD9VXez3BWhiXpxhAjgKIE7MkupXWG+1dxdRdKAG6RCsMlFFBvUJTXYSCHP7Lz72jtp/QtAr3yV3X/UC9iZot9+oocRlGVVhFVwYin6AhZHT6IZEh52NFg6gb4InsSciV0wX4P5kdcExfr4e/E/NTr/lQVjXitUWhYdk8aoIXWEq28NPW811YITk8mzI4Zu81B7fzIWrxGsLh8W2T24X1yp3T/vaAnxZLiSGQookjtv9rHQhtzsYj1A4xGPdeRz1ajWY4CiMAB8sJt2hvSZ6R4mX+lJy638ndyS+Atm8dGRo+fCcgZkCmAJpJugteBk5W7kQfsncahm9pqXVBVFwqn9Ts6eoRLKms2SOJRFjCjCeVMM+bxoEt1nsRQckobjmrIyXcWoVZhmBoLsUFNoIeAUDEwQAjFM4yc0HbzhmVFBF9qrgY6mpd8UseaAz2db4C3T6eIFKWdIXFm58mOFoL7xVqUU+N/n3cX20bv3PwetiS8v865ThApA4oLGOfGKOrJ+P+WWlIdyBIciark= X-MS-TrafficTypeDiagnostic: AM5PR03MB3009: X-Microsoft-Antispam: BCL:0;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3sfDovBvsW8bT3d0UFrgpMxYQqw1wQPlT0x51HfPxOMHT3/ybbbIPATOHnDQ8kivoUqDdPbhTf/qaKoxe3tXbCkozZKMeubAPtMSUwmvIhbOPzWnbd7DFAm0D9ztB2o0DctTGzvqykGDnMHc2emywnjYBfoqhtuWeWpUW3ORKLo38GigvyvXvCIpsjORB9wtSy5RvO9kJmpeedXl/WSDTkpM/ee74agzMDnC/QcIlyRokwsjxbQLOM9lg/lV3nhppMc2ARK3u5ESNBxiz9DtW7zRw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d15c6013-bd2a-4ee6-7bc9-08d9a1fbd6b7 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2021 14:35:26.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: AM5PR03MB3009 Subject: [FFmpeg-devel] [PATCH 1/3] avcodec/libx264: Check for overflow if necessary 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: KfBGsEXLHVlc Signed-off-by: Andreas Rheinhardt --- libavcodec/libx264.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 0766b4a950..8711c72131 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -138,13 +138,23 @@ static int encode_nals(AVCodecContext *ctx, AVPacket *pkt, { X264Context *x4 = ctx->priv_data; uint8_t *p; - int i, size = x4->sei_size, ret; + uint64_t size = x4->sei_size; + int i; + int ret; if (!nnal) return 0; - for (i = 0; i < nnal; i++) + for (int i = 0; i < nnal; i++) { size += nals[i].i_payload; + /* ff_get_encode_buffer() accepts an int64_t and + * so we need to make sure that no overflow happens before + * that. With 32bit ints this is automatically true. */ +#if INT_MAX > INT64_MAX / INT_MAX - 1 + if ((int64_t)size < 0) + return AVERROR(ERANGE); +#endif + } if ((ret = ff_get_encode_buffer(ctx, pkt, size, 0)) < 0) return ret; From patchwork Sun Nov 7 14:36:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 31323 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5e:dc01:0:0:0:0:0 with SMTP id b1csp2580204iok; Sun, 7 Nov 2021 06:36:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJwRrh4m7WJ9hbkWxtCF4HNXybNYAWgaO2nEPEyaqxOSksnK6DH3u4IkU4RfkIW5raT2zhQv X-Received: by 2002:a05:6402:4403:: with SMTP id y3mr53992309eda.163.1636295812790; Sun, 07 Nov 2021 06:36: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 gn14si12163398ejc.379.2021.11.07.06.36.52; Sun, 07 Nov 2021 06:36: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=NLUdnd3E; 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 7ABF06806D9; Sun, 7 Nov 2021 16:36:50 +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-oln040092066059.outbound.protection.outlook.com [40.92.66.59]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B7AB96806D9 for ; Sun, 7 Nov 2021 16:36:43 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eqnfeocy02+LlfJa/yhOUoaWR+evES3KaBq2nozqsTR/LIucdRf3QPmboAW8veOoDKHODABi9NrpYOYKeRQw8co2te2NaDe3d+rfxpI9pFRxeO7Sh/FJa2CqUvS0Xz4HVv1X+QuHroR4a7IazEt8JAaxQSNGwJQ/BlQNcT9H+F3uqc955RZCL3WYimeX52jJxGvFDfVBcmqBfu2C/SjWdIidzyIF2mgxKTq7ZzPKD+b+fOQQpE5AvBjUnAeuuPFBTwRDmw7wF+qm2mpDvI9X1fXhGUhq0E+HsVt0bbeaY6bz9Qsb+4mN3jLrWdq7cFFk+FyXhKaSQgGK3zDODlIxtQ== 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=a1Ucgn/JXendYpVa+16ttkhkg5Z87ntBwS505lkJwPQ=; b=Qd51D+X/BRJY2u5/6LN/dRcoBf4XG3e6FRTIfXkB4hHaYUDDkPBLu4pJunT+zHkEbtoPqzUvT+IKuLsFHWlu3a83DkiyCko12uSOLkPYvUehElG6wjyTJhAxpxKS36qTaqoPv2EkvA3vi6BOGlq8PRvEPcu3kgNfVQkDJS+Fi2l8wCHHNdEt/O1JpbDM5ostqCLRJhMK5XLgnHbKFWco+lQyd7mzf/BiwO1c79XQDcMDsvF/xRK1gx7rx1o/jSMX4enGAcgi8JkRf9txaEBjjSpwHGccb8GhFqqxoTnnKo1CICtpmaPCEBYjCs0Fwvvmy8vzvsKovC6rG2SDbScjtQ== 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=a1Ucgn/JXendYpVa+16ttkhkg5Z87ntBwS505lkJwPQ=; b=NLUdnd3ELy8LarxIUgPh3GLFlpc0xAivDm1Y3xz3vBxlekgYqcRA1kqh6DV2kDO20yu2fHYBaQsX+w6z0id0hl28FNmo68JVw/0yGJLVty7ClWbA6KSX5QooZq+u1eeZKc3lzcCumAKAWNQ1wZ0965JG7HH3MkiDdbaH2uTP6W5UGxcUP7Ge0Zu1rJRYLxhHs2mGTXw0vqU0HzdeLO0EdtCy+UYBuomgIOJrSzpe1G/bOMK9OyN+CxECh2Xwsu1YZSoO1FqNcFO8QKad/pPfvJJomSN/XwcKd2oSKm3gOO012rvf4sMS9in9czrkOJxjnlE9vrtAwqgdj+WCvsAOdw== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM5PR03MB3009.eurprd03.prod.outlook.com (2603:10a6:206:18::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11; Sun, 7 Nov 2021 14:36:42 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::700f:d70b:3bb8:4d51]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::700f:d70b:3bb8:4d51%8]) with mapi id 15.20.4669.016; Sun, 7 Nov 2021 14:36:42 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 7 Nov 2021 15:36:34 +0100 Message-ID: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: X-TMN: [sUErZGgiSMRD3dayKhEc+ec3QeQSj3t0] X-ClientProxiedBy: AM6PR05CA0017.eurprd05.prod.outlook.com (2603:10a6:20b:2e::30) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20211107143635.214018-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.193.171.90) by AM6PR05CA0017.eurprd05.prod.outlook.com (2603:10a6:20b:2e::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Sun, 7 Nov 2021 14:36:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ae361deb-2efe-4ff0-ac28-08d9a1fc0425 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNUrfGsDrLJjePn49Wzo4gGlLjJdGnJrzW+9+is3LHP0WHq5E1cP+EgI20DwQwxA17bbm+iLCi1uje90pQOJojq9guvkkC8YUhny4Ag2hyl5ymqmQQggCM5l2b2ISjBTTstoWNonqveDtr0zHKXlrufi1RMy3ayETnBgWPXSeE3fgwqyTB7puzf5p23QaRCa0/hpBdLOlM2poq4KkktKZvIcf2TXr8gDf1VmYf/GwT70CGTbtZITe/OcIg81s6YGQ3FKLYmukQV8HLbbEyC+UdfVwpFKd0Nl/Z1sAQdPveBcVGteNKZAWLV/ob7XKgB7kQ4RPQlHsy2L41pbwNXhXsWc1VHVWVubQk2OG6cMOu3G8UGK0nByk5jzBw+7g9edBhXLnwoKVy5j6rjM3ryRk7Eanz7bpPIaYKOUaOi8mVxB4aBeEprhQVQPQgNg/LPu683AsgS96aLfsjq+gqq4FKevUvPHAZQ+0pTOWMCFRhj/MjrLz6eConAQ1URCNufdlam49+9V5o6AYjvfGOMONHxQE/eN/+hw2bjam18kxTBZu2NzFX914t9r3YEgAav+bkFdj6+7OlcEqaUDDvprgKF9yVigOE39aUBj9R1nOovnZoo7oQorqedZrckcXl4nABVa3ocHwj/jepF9Rolir+tfJ5JHEycahI/CaXotpUfJGClaGw1MvVm1K8rShavaZczYOuS8lTse3QdnSRQe9gfqCv85Hgqdze0= X-MS-TrafficTypeDiagnostic: AM5PR03MB3009: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kNama9c+8b5PKZcKBogplIflOn7X8wGOaC3g+qkyIDir11LCLuPDHYLZj7AWsWyDC3KmVfoSr64a//ECOh04A+trs2ARiVx27IA+zAHoHyK8Et8CgLdC8GKmbnGbzAWNoIVNCI/i7rPMMAKww6rmi+I2+r5y5CShaY2PsT9Y3QRW7u4VM/Fa6YOjOlPatlIc4sqKxPqZ2EAO+e5gfJSzKNJWHWd/MAkWDESxqIeStlUF7oJtPNZXtT5LRTnTI53t6JGzjcCRBmsQvjSzCvEl1KrAoJvyCmSqyBANueoaZo3UBXC3ztU7OZEOSQXCVAVOqUXz7hw+4/Gr4Nh8suwuMUFFTEg9ueXcRnLSDE9hmbU6SSTHTkQj+qwhl9SD/7+JeM6sGNFlE7F/S0bxVg6XAUuwFsCEQoDK20yuonq4YsNX0EPMXkZ5GcAIPeM058RAE9/fh5grMVQuVrgi+bQ0DUggATEqXtgfodnIA/sy7x0Bmaydx67vGTr1uRUEQ5Ak6daYbIRho9eh3bvKU317AXqna6HtXOCf3i9xIC5xI20= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YLcaTB6kPIk1E/LYdYOogTVVKZ+A8Tq7yAyO9Es24IIITuyFxxAqpRyLlfeb3Isd9RG2111n1n7vLBeK1uyr7EXVpK2iN+b6WgESzIYOraans/jik6OlTC+ZJT/jDEDVuUPXGzUGfVm3QxXw1P0Wv2ggli9oeaWhObul8Cjv0GryXC5U6LrWRkb9BQpmCNrwhAaiV5PabfK65ZSgBgbIdS7Bzj+Gyto8zIgJYoR9wPxx5Fy2WbPzl5Vph0bafTVpTiCx47ivh6AvinilMSJ4rd0tIJv4po+KkSsJHI491xNm/NEepGj7chTgd3F3Cg0U2oTlYUp/gz0I7TNAcnG8bNEEaor+1k62+Byc98IvwXXhMS++osNCuzP+AI76koCQiUFZkF8Sil3mYAop2sHirSKcI4v0TDYDbmFNPvtmVl8pq0WyfLrdX9kgwXE0UUMW7WQ4q9oQ/q3F+8J08TfmaCmEadpziUUs0qhnG4NkV6o7TUR6IEY1qx5F5QCpJxngwJwhw3OlELNkAdodGGNWhmIwLw6x6/evFB+9WXS4y7YXJYx4UsKDOdWeYxvzyen1QEy3v4L0onkKoutcWlvhV5a4eJPtmV2IR1KUcKbKWKtbf5e060HtCOCudQGhX31RcXYJcbsiDHGvEbC7f+uyHc0y2tDHtF8puuuyj032IOaRZm2Ic0+XHyWVhsgbl2MFLkK+8BiGbOQHKoR2OKKFqA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae361deb-2efe-4ff0-ac28-08d9a1fc0425 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2021 14:36:42.4876 (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: AM5PR03MB3009 Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/libx264: Remove always-false 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: TlYFpUPkg++G Always false since this encoder was switched to encode2 and ff_alloc_packet() in 06484d0b8a7d4d1a694ba7ab277e2ec32d6558d7 and f2b20b7a8b6fcbcd8cc669f5211e4e2ed7d8e9f3. Signed-off-by: Andreas Rheinhardt --- libavcodec/libx264.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 8711c72131..4fe02dd11c 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -162,11 +162,7 @@ static int encode_nals(AVCodecContext *ctx, AVPacket *pkt, p = pkt->data; /* Write the SEI as part of the first frame. */ - if (x4->sei_size > 0 && nnal > 0) { - if (x4->sei_size > size) { - av_log(ctx, AV_LOG_ERROR, "Error: nal buffer is too small\n"); - return -1; - } + if (x4->sei_size > 0) { memcpy(p, x4->sei, x4->sei_size); p += x4->sei_size; x4->sei_size = 0; From patchwork Sun Nov 7 14:36:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 31322 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5e:dc01:0:0:0:0:0 with SMTP id b1csp2580337iok; Sun, 7 Nov 2021 06:37:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJzcRekykePxSV/FpRZ23N9LboK+VvIEbB/ds3c7KJUcVBTI7smZtorn+jGGlzQvLHClZSxq X-Received: by 2002:a17:907:1b1f:: with SMTP id mp31mr87308329ejc.319.1636295822332; Sun, 07 Nov 2021 06:37: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 b8si12491580edz.535.2021.11.07.06.37.01; Sun, 07 Nov 2021 06:37: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=ap+uiUMi; 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 8B4B568A7FD; Sun, 7 Nov 2021 16:36:55 +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-oln040092066059.outbound.protection.outlook.com [40.92.66.59]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D4218689972 for ; Sun, 7 Nov 2021 16:36:48 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CfJ5JVdlBoMtVm4Ob76uAF+sgXERLQZD9hC2wfywHSqdLInCs8qMcUcNyPr25Hj6bnYh2D0xMwyMyshDs7QrXhzgvfyXT3sTabLcHD66GhvldfFQBwdu1pLgeGH4RW8jnP0E2lIRQbB7KCcyHk1E8ia0AG8dcBslcQZSnJZGXmC96qWEXoyF1kw6CxqoL91asqCPaNaZFRTfX/dbZymg9AD8hJMhEoGwn4IRO4Ej7vQiJ4fO9t7JjiouANFtQbjk3EgzlcQIK7xNiCxStoM6grRJjxj/pXbFiLGlP5yHv+KJJi9AW5M8CltjUX9cXMJ0S0X0oXtN452+ziANllZdYA== 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=HZTNhA4MuHep2j8IIV0QLr+Ufdd3UKaHRpscelUqKoU=; b=fVTuyfZYOfQ5SZiqhscPhB8mOIpmwOX5xnmwPtXRcqeWZ5jm8vMXJIBRG7HOJK9WjeFyWQUhAf+G+y4Fs1IQaCiu4UWWJItHLmxLVScxm6kvlQq1gT5+QnO+i5BtPv0pV2imNyyei0hSKH+WwRiM+GIrPbOKMD6u18oSbngkoI8tLbb3hKWiAQKyqKIDlRmmWHBs8QE/qCyBcJZ395RSlRjWycH5xbiLlaNTGZTFQ++GExx/NmbiYirPd6PI07gtrk47jwV6vygjDcMg9hkrBUqldnqC+x7H3qQ0kVPLxnu/nC4bkk3m3j06joLtMc3kBi7CFwel0jfI4H/3qn0/nw== 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=HZTNhA4MuHep2j8IIV0QLr+Ufdd3UKaHRpscelUqKoU=; b=ap+uiUMivJumv1V5ahtqo12vm2AhgTRLdPUlu4dQRzw8y+3UtO66zih9iKseUQJ9fjK9Kg5ZVJcyfQKT2R1EkQBH+jy1p3Rd6GrBJFKxVcslXAb128BBb2j2nr5v9YirU61/7W7BdzNGjnXdLLhrzaxyXXjRrruht4tU6AnYEi94Bsq1dFhTHVzKiCO2ueUvRQKxAXPFb8GmM35KVT+cp9bbb3ji7OZkCYZy04ZLUI6psl+UQlw5FoGlwX59fp6m1jnH+qFxkiwwMhoXaQDq5vSq6TSIgRNrk2i3Z6eSat056Trhbm4XiUe5X3XkjjZ7e5i1vssWbPJ9uMW1qvSQiA== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM5PR03MB3009.eurprd03.prod.outlook.com (2603:10a6:206:18::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11; Sun, 7 Nov 2021 14:36:47 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::700f:d70b:3bb8:4d51]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::700f:d70b:3bb8:4d51%8]) with mapi id 15.20.4669.016; Sun, 7 Nov 2021 14:36:47 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 7 Nov 2021 15:36:35 +0100 Message-ID: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: X-TMN: [5uYUqW6kBL+JiLKLvKiP0rTNJw3rP/48] X-ClientProxiedBy: AM6PR05CA0017.eurprd05.prod.outlook.com (2603:10a6:20b:2e::30) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20211107143635.214018-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.193.171.90) by AM6PR05CA0017.eurprd05.prod.outlook.com (2603:10a6:20b:2e::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Sun, 7 Nov 2021 14:36:46 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 53bd9e79-cae9-4366-90e8-08d9a1fc06c4 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiToJ1zOhCTJM+/mZKD4SWs2fsknwzn/sFDyR02o3yBb/7SggtTQA6CELNJcN1eXTSt8gkfs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Qv0ZQ9+Xo8ji1PIgGFyq9/bLx9QpY5wPvxb/86if7zsCXuyrB05v1Z4UJekwvT4ZMPmTbU2otMOQijn6/R+LtJqQ2XOnEvYwkxks+Tr42aWhjqfc2YqmYsMW+9U9mnulU63W6Xo3YxwBxUwBBHkmjICRkO+6HhGa8otBDQ6tr8Tflw+eGlYeFA/279eRqeGxUKza5LK1iNC7V1BKmDN/L65pUaxOIGadKMc0FpDsb9/eUoPGJZsOCofNlA= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NmMzjTQHDaQ8pVlrfv8lt637d0OEofXSlSU8gCCCxKr3k3/8D8sMc3AiB/w1W3T0fkemHTpe/mkxaqBiqAI4E10iH1nZLUEVxoBGps1XdKbJkScFf0elX23NZOOQLD50dCqQdksfKnJq/4/W1Vatn6bDoeDraPEJtxfnRVlTPsrUalwJG//Z7JYuTfUe1hFCEFCN0f8sWHXengcYiMWjJn8k9AZ8+zAgPtSq9Why2s7vsnmKYUkhmEUp/l33i5GDg+N4mcggapii79RMJYn9wNiZz63pJKC8EqQYY290sVBnSOLoKvw1/ofKqZCTOMTzRslOn5awtY80TnrJax7S4IyQ1yUBLVgSFJhakMrek6aVj/bQ85I2yqlXFJ77DfYtn6LwW+XV3jByNorWqSG4ySejFDGO/ta3x/xAmiDw2eUbMBXC4MB5Edbt6lewYYGJ0zH7mSeE8ojI9WtKx9RLbIY7ivkbZHEoYmnCQzflIw4PaigOexVJfTB2JWgF2YRGlid04dUbdDQs27ldxNVXVe5clk0S0G1wOtxPFl3gylJ1pzSVNaw9XOfIUxAAMmc6JcutlYG/jeDbLeFJIOgcDZw6camLg+ooPXwxbn7PVt+zTFcSfJnv/l9Jhor5RCvyUTvBm2TGRnuaUMf5prSxz4lJNFguu4HwMn9XyCRNIqfy71u899M8/tykCZ5Zh71/0aVj4sSeZngJwMNJvr5Dvw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 53bd9e79-cae9-4366-90e8-08d9a1fc06c4 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2021 14:36:46.9690 (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: AM5PR03MB3009 Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/libx264: Simplify copying packet data 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: m+YpX26W4+ew x264.h: "the payloads of all output NALs are guaranteed to be sequential in memory." Therefore we can omit the loop. Signed-off-by: Andreas Rheinhardt --- libavcodec/libx264.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 4fe02dd11c..5f62c7b1d8 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -139,7 +139,6 @@ static int encode_nals(AVCodecContext *ctx, AVPacket *pkt, X264Context *x4 = ctx->priv_data; uint8_t *p; uint64_t size = x4->sei_size; - int i; int ret; if (!nnal) @@ -165,14 +164,14 @@ static int encode_nals(AVCodecContext *ctx, AVPacket *pkt, if (x4->sei_size > 0) { memcpy(p, x4->sei, x4->sei_size); p += x4->sei_size; + size -= x4->sei_size; x4->sei_size = 0; av_freep(&x4->sei); } - for (i = 0; i < nnal; i++){ - memcpy(p, nals[i].p_payload, nals[i].i_payload); - p += nals[i].i_payload; - } + /* x264 guarantees the payloads of the NALs + * to be sequential in memory. */ + memcpy(p, nals[0].p_payload, size); return 1; }