From patchwork Wed Sep 28 18:56: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: 38452 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp443577pzh; Wed, 28 Sep 2022 11:57:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7yaeWiN1XaCognvfFg8LMIbD6Hsv1UQiPBtoaeDGdVpscx9dCthk8bbloYPxyvNir3tunK X-Received: by 2002:aa7:c04f:0:b0:457:1b08:d056 with SMTP id k15-20020aa7c04f000000b004571b08d056mr22197915edo.146.1664391435520; Wed, 28 Sep 2022 11:57:15 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ss17-20020a170907c01100b0077ab738911fsi4760671ejc.140.2022.09.28.11.57.14; Wed, 28 Sep 2022 11:57:15 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=D+r2esJb; 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 BD47C68BBE8; Wed, 28 Sep 2022 21:57:11 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2085.outbound.protection.outlook.com [40.92.91.85]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1D95468BBB5 for ; Wed, 28 Sep 2022 21:57:06 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nLvaV2x/B1LFhXa3+TAHdC5EjveaZ5LHnvtU446JwFNdWC4zlm7ob6989NctiD+PxVyeuQvJnJWO/jbiNQWLtMu3Cec3pdoONVWFKZTze3oIziTt7pRaLl6ngWzd/VwjSWMixo/6/bvcztId7XFGvby8Aw1UXiSJUwSpfiVz3M2fUJQl7sS4ICbUGp9m4BX98L/IVEw5etfb7+/FgUjWFI5JOwB62LgnxOIdT2Tl+eCgZ3Am19K8Q0iYAl80p8MB5WUZUpBZkvSBclvpCpb2zTNitAVzYeT7z75EQmjl3amlYyM7sdsfqKadF1W0DJYJvTYX71uy7QXg/cxWvVjFhA== 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=pSupCD7u0ydRf3UnPQ7ah6j5ggwWw78jMdfrEBYIVKU=; b=oWXjhuSUfoJFexsoqZ47xk7YT+ldMH2Kxy7QRtF4aTpibPKlCqxRYuvyK2l7X+eM2DH6cU9omfrGwvOXMRgrVnuPVxr2sxSCIDH7ExJ8VfJymwY9IrbpIPhrlQCfmU54N/b+XRbgfZ9MHiCdkF8P5qoixMkgETU2lNWYQtM8baC/Ba1+IkSB0uWU815zbo37PNr+286cAH6TRUo+2oqc2H7g+vlqabBP61sddexHNpghIc5qJS+Si+qRonHzS8ncKrfWK4oPn3EKygrd+FdGn4fnXTp/nKVqWE5A52tLk7xDdrNVEBujhD4GqAUB9c1nhneXID5PLjs5jFz7IrFKjA== 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=pSupCD7u0ydRf3UnPQ7ah6j5ggwWw78jMdfrEBYIVKU=; b=D+r2esJb5h8ATIAmAXCOBDgGDmYGdI4gV5+a7ZSBvCCMpcOsD6XRagnXPOOxTDkj6vm/b+O4Kn55ZkDH9MU794xnvqCEbARTJRZdZbVQFi1YB5OVpKcujOQ1glcj9n1zmPqJCl9dzpUEMmQipGzBV/Pme1oR7lMqPmde1I7QGYH5eLi3WW11WwyilbPR+5LQeCXZZ+wA7wqJwXW3KeMLNI8G7vu7VQuFxCbdg9XfAR//5Eq7DEYfd7Zm4XzpTE+xYnRI9Z5zTv8xl82c2fSEB4HfYYJJgrqUxfD/qbfvYs5PUULhwDozN0nLE3Xf1Oq62ZBIt9Ipr6Q1+oEccFESwA== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by DU2P250MB0014.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:2b7::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.17; Wed, 28 Sep 2022 18:57:04 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::68bd:2fc7:ac52:38f8]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::68bd:2fc7:ac52:38f8%9]) with mapi id 15.20.5654.025; Wed, 28 Sep 2022 18:57:04 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Sep 2022 20:56:58 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 X-TMN: [waEomSohf6NchLth5iLpI2wA+u3eCfU9I29yNrtkj94=] X-ClientProxiedBy: FR3P281CA0133.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:94::20) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20220928185703.1074619-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|DU2P250MB0014:EE_ X-MS-Office365-Filtering-Correlation-Id: bbc59797-4d71-4172-6286-08daa1833b99 X-MS-Exchange-SLBlob-MailProps: AZnQBsB9XmpPcoZqFl/i/jhf7c/pX34TUjbnGLyPb8pZ1fNimH9z3btIpOSs9LikfBpSDZCuNhEfre45suy3plxSs8zJL1T0jMqTeoTyoCUw+m1KvXQz4GqhiFZvSOXoP6D7bDPPJtW9EFGMNe5SOCi7PLpJ9k/1VtsXm/AW3JsGictk0Wh7mOs8Nm76F8V7rHK35Mog0ix4BimvmtZOfRpFoJ3EOmbIrtda07PxX+kbkyJBweShFGn8mwc937cBFGH8o+khVMHCW7roRMvoDdXI0h+xJBlWu0a7Kvc9NjmezRrDjh3DzbjtQp5JoZGo9XgxUJEQpgbtVPNR84FvNf5kLcO0HJtnW9rpZV2smqUrjydZyHhJP0kqWWHMsV3CyS+0aBDeWOTKpA8ga1LT0nRIxpc98D5/pWqLGVxq2WglQzeBdeJjXKzZNIOHCQnUhTvJP4M/tmqSJ34vu3sgXF18wH9Sidz0rKX/+a2qKqmo+ZTI5zJBdEZkvubQbJOO7TN/CeVmgWH1L9soyJiJ3K3r0cGEuie0A0Ot0WrHp0IOnbKZcWHkLsjqErEWsz9TgX3Gt06yT0SPCCRhnJooaoW+7it+r4oWnCXRLIazswWmfbw1i0Nn879ELzKKhqY8yzSboyWFgdRAycxxsimdGnKbhl6H4+AmIRH4e5Nf7DEmpkk75hlc4NxPDn1XVoxYdSZQcsqDcBeXQBz2i2KxqZCPI8V8x5Lb9GvWcvSE22Hf6cHz2dP2Nr0MZxFCfnxggwp/tJs73Nk= X-Microsoft-Antispam: BCL:0; X-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 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2022 18:57:04.1385 (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: DU2P250MB0014 Subject: [FFmpeg-devel] [PATCH 1/6] avcodec/g723_1enc: Remove unnecessary av_clipl_int32() 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: buSyjiiW6htV partial_corr is an int16_t and so the av_clipl_int32() never clips and can be removed. This also avoids undefined left-shifts of negative numbers. Signed-off-by: Andreas Rheinhardt --- libavcodec/g723_1enc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/g723_1enc.c b/libavcodec/g723_1enc.c index f3baf7b4ec..a22985ca44 100644 --- a/libavcodec/g723_1enc.c +++ b/libavcodec/g723_1enc.c @@ -200,8 +200,7 @@ static void levinson_durbin(int16_t *lpc, int16_t *autocorr, int16_t error) partial_corr = temp / (error << 1); - lpc[i] = av_clipl_int32((int64_t) (partial_corr << 14) + - (1 << 15)) >> 16; + lpc[i] = (partial_corr + (1 << 1)) >> 2; /* Update the prediction error */ temp = MULL2(temp, partial_corr); From patchwork Wed Sep 28 18:58: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: 38453 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp444210pzh; Wed, 28 Sep 2022 11:58:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Lre+g7tSv1e+WSRv8gg08Y3eNF1jY8wxCfpIKVfzgv1BupG1Kzfo5m4e8P2FnltY39AnE X-Received: by 2002:a05:6402:1f84:b0:455:27b8:27aa with SMTP id c4-20020a0564021f8400b0045527b827aamr33426706edc.243.1664391511014; Wed, 28 Sep 2022 11:58:31 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n22-20020a170906725600b007824cd8d165si4882063ejk.577.2022.09.28.11.58.30; Wed, 28 Sep 2022 11:58:31 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=CMIFhrua; 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 BA9D868BBCA; Wed, 28 Sep 2022 21:58:28 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2096.outbound.protection.outlook.com [40.92.91.96]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CEA3268BBC0 for ; Wed, 28 Sep 2022 21:58:21 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rd7g7s8IASGcpb8BP3gKofzXi6zEL9N4dTk1F+3e3pAuazgNzNVGf7wHha01q1yMbiFU1bOlb2Qd0my8Nlgf3pMPaylPZCu1g4n8WLXe1uVZtS7VpIx9HK8nOUnB3YRIG/GA3HnWYlJCaRRt2c0ApMfsNVdQDkN4pRtgBc0uPmQFqJGtnD1SYZakuspakfOD4KbdWP7CH5vRCQRHv25S2u10uaRa+rDjuZG1yhaaIYoGblCuKW7tGtZ0J+SxybLThty4b23Hy0IXbYNvlKS+8aLQkjrGlUVkBcpv0e/SJLEEJFo2jr/Jq563pXk1LT8g6LyboL5Z7t2KGMQHL1QfzA== 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=yYMBpA12A6PG7TCC30humVcSNjTSJBzttwgUZ0lVmdQ=; b=KE9Fe+wTAUE7uYQ+d4KSA9Laqo3o0ccvXTm4tgDyIVoml9G1/Dde0W0idIgUcQR36ZQ2hez22oU5vUVgHufgMFzGxWJKII1b4I5Y1/PX8/DcxZYkS5OGZglP1FiVb1r4OL5DpEiEhJYbDE8De8qWX6UmEiMxRSnx6AALAsq9Fq7rv0BLFjqgmG8qjeydJRV2IUOMW00X7fvMVe/yB5RIZ3/etgNQn5iIqfDPHuRblRObj2rqHaGvorHGtZS5/HIts5tjQdtaAe9JGUKpZPTRomoYXl9Fid2pOqbza0Qqt+UKo2EBMRXanZkX0gn1UR8jajN3wB6tZHcSp5CdpnxuvA== 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=yYMBpA12A6PG7TCC30humVcSNjTSJBzttwgUZ0lVmdQ=; b=CMIFhrua/TsoBnVIiuU8j77en9HHJsRirfsT4/ZLekzs5gv8jHCRT2xkvub++ibhXqF7yyC66VG7mU0XGIag4NS1vrW23GTk7r48CgxuvVwwFjSJY3WRwbMjIAzA1551V4zSqzolXaYEovNLuutkOGlG0qedxtRhaFkuB/pDtUTQ8O9UV5ST79dCt6Nh4xqXprCiLODdJ/vAxMM50deVFzl0pS03Kbd+F26R3wSGf0YbTt5j4Ej9hbc23SHRVvlORRxNGLcyiR+2l8OJQ7aAXIfIrnIRF5C8d7YBSDvBnXYH8smeApBQam4IIfV00Nur2Ox+fc3pqs6YD447czrZlg== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by DU2P250MB0014.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:2b7::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.17; Wed, 28 Sep 2022 18:58:19 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::68bd:2fc7:ac52:38f8]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::68bd:2fc7:ac52:38f8%9]) with mapi id 15.20.5654.025; Wed, 28 Sep 2022 18:58:19 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Sep 2022 20:58:14 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [F2NTc4JPsz2GuaHYdR876Q9CdKF+Mv9wmD2SCBfxdiw=] X-ClientProxiedBy: FR0P281CA0051.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:48::12) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20220928185818.1074689-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|DU2P250MB0014:EE_ X-MS-Office365-Filtering-Correlation-Id: d0a2f1e3-82c9-4eca-1049-08daa1836861 X-MS-Exchange-SLBlob-MailProps: AZnQBsB9XmpPcoZqFl/i/jhf7c/pX34TY967m/IjD11CuwgsfHovdSLLdyQfxy4uC3SN07XZJWsryHv+053Jnxm8R8I4ZCiL3ECNuzcWsHyyTAEaphJmlAjBuFoH/8tXtOWL73y2HpPEkuVChYYPnNJjfcRjnLYBOryiHhXPPZNglKfKtVmi0g/ZzRViRE6gKSlGgll32yRWTlW8wKu8ZXhzfJCdNdlRsJiweNqJRkvaed1bSW3TLBn8toEgyUdt9cEOtx9h1dn3RxE5WZXwSotpZE8hEnsadUDoQ8k9J+WjzlgEDsDh31M87ikyrvjjCeQegKyew2pavHjHKtMNTphJvhJK8ZTSjbyAtVEarhejSqsRLsA4GkPzefxi1xJHeDCZjloLTVeW1N9kVUiNS3mMD1bcVx8WM3VT+kg/ZoS9dfa8mp77DbIvHk7mzC/tKedzO2dv+pY6w7VnD5ibDkU56Va0bgx9lCBQ46XRpjA8+/1pqZOievwZwXgmwxz+B6syWF4jZ48cTAXS2MB6gOpuiF9ywTgrEklaA0Rvyqjba4yFAKkB7XoxHCMzzOUcrl0HtxJ+jLGKLzSqf8vVg2Yow+mFv6fbdTTPhBV/oQxedQ/ViH1DI8MM1STFiQt91vT568l0Ro+tdL+m5m91lET8urTu+9Zpan73QNHHjNZjlsGZuyPlANYAdyfVvHITm8UDdy6Fc70SSWUpS5E6xVCxitWE35H8Bqu4r2kZksceVdnVTbK5xEBpZjbchxFBvV77AexbGw0= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zR9oUR4kj9RUhwGZ61rlC95OP4U7yZJXZq3Ynahi9hqcZwa+Aa8Z9hITDsCXCiWa7ftbc1v4181iyCMNeN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rghhNvsYQj6yvgx48uvP5z0fHxv9oOMV8/ftV23l35cbAjW0cxnKPEfSHXIhWB8GadrgIsQIg4oPyhAMF1sCQ7fEJ+6anPehsmb09k4zTNapwE2owDCERTEwXKNSchSkEh7znFN6bEpiebPG8XKp5u1gOLyDVnBj8IhUdG8dJrmp+XRwj/uzOyyDcf9tept/OGC2ZLVHnVJSbV+RunN9tz5zd1hQewTupRPgo6zflKCHCKFwuJ0iQhuwOf5/ScJsZm6gFpjMJ2tfehgqD6NhdYHN+ME6/rZl+rSHrt3qaBXIezLUNsfFIJAdBSxrzrLrf3cXEi1i2kXVer6QTevjYvwDPExl/mYeEuukC8la2SLKinDUSxenI6tt5dMy1G48h5OEqPlS1NyHya6VOkrzkdNU0/tRbPMijMe5+aGhBMYHFYS7vSs/lWjFWQSc9mNHjrCFpGw1ijLgxGzlamWqfZv7ni+tsEZ9j8yVlk6YDNlIguwpvflW7mi+mwJGvcz8KHJXUfY7wkylm8U3SrdgZ1AAMDSIs2RKNUoMMAnaj3eP4kMzW+4z9wZysbRwXf0KCgWlLd+YV4EPxR+vEL/KCeSHcjUCgX6BVfI6FQU9zlIgl0pgWmZ9JsU4EnahD3QTQmU84ChguUdCN4fGTeJ/73RtTlbe0oIPU/n2YNWWvRkTkwbcr4WmDBh4Fr2LTKWG1+4Mao2ergiqEsukrD9buHpXXRQQNw+pZZLWYXyEUD+Oy7MiSn6r8Ucjwd6D/gD7UMNVDq0x85R/2ObKWGqrvcY0J24VWdDCHOQyeR6eq3LzNI2X2//fRLxOA+dl5ysohH5Ook6TTjbPo0S/PQ6YskBU8rxKMrJoixODpEIRgxr/k5BaA5hLXS65434AQJhw/KN2yr X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d0a2f1e3-82c9-4eca-1049-08daa1836861 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2022 18:58:19.2045 (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: DU2P250MB0014 Subject: [FFmpeg-devel] [PATCH 2/6] avcodec/g723_1enc: Fix undefined left-shifts of negative numbers 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: damtCJ2m2miw Affected the acodec-g723_1 FATE-test. Signed-off-by: Andreas Rheinhardt --- libavcodec/g723_1enc.c | 71 +++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/libavcodec/g723_1enc.c b/libavcodec/g723_1enc.c index a22985ca44..8466067185 100644 --- a/libavcodec/g723_1enc.c +++ b/libavcodec/g723_1enc.c @@ -126,7 +126,7 @@ static void highpass_filter(int16_t *buf, int16_t *fir, int *iir) { int i; for (i = 0; i < FRAME_LEN; i++) { - *iir = (buf[i] << 15) + ((-*fir) << 15) + MULL2(*iir, 0x7f00); + *iir = (buf[i] - *fir) * (1 << 15) + MULL2(*iir, 0x7f00); *fir = buf[i]; buf[i] = av_clipl_int32((int64_t)*iir + (1 << 15)) >> 16; } @@ -166,7 +166,7 @@ static void comp_autocorr(int16_t *buf, int16_t *autocorr) } else { for (i = 1; i <= LPC_ORDER; i++) { temp = ff_dot_product(vector, vector + i, LPC_FRAME - i); - temp = MULL2((temp << scale), binomial_window[i - 1]); + temp = MULL2(temp * (1 << scale), binomial_window[i - 1]); autocorr[i] = av_clipl_int32((int64_t) temp + (1 << 15)) >> 16; } } @@ -193,7 +193,7 @@ static void levinson_durbin(int16_t *lpc, int16_t *autocorr, int16_t error) temp = 0; for (j = 0; j < i; j++) temp -= lpc[j] * autocorr[i - j - 1]; - temp = ((autocorr[i] << 13) + temp) << 3; + temp = (autocorr[i] * (1 << 13) + temp) * (1 << 3); if (FFABS(temp) >= (error << 16)) break; @@ -209,8 +209,8 @@ static void levinson_durbin(int16_t *lpc, int16_t *autocorr, int16_t error) memcpy(vector, lpc, i * sizeof(int16_t)); for (j = 0; j < i; j++) { - temp = partial_corr * vector[i - j - 1] << 1; - lpc[j] = av_clipl_int32((int64_t) (lpc[j] << 16) - temp + + temp = partial_corr * vector[i - j - 1] * 2; + lpc[j] = av_clipl_int32((int64_t) (lpc[j] * (1 << 16)) - temp + (1 << 15)) >> 16; } } @@ -259,9 +259,9 @@ static void lpc2lsp(int16_t *lpc, int16_t *prev_lsp, int16_t *lsp) /* Compute the remaining coefficients */ for (i = 0; i < LPC_ORDER / 2; i++) { /* f1 */ - f[2 * i + 2] = -f[2 * i] - ((lsp[i] + lsp[LPC_ORDER - 1 - i]) << 12); + f[2 * i + 2] = -f[2 * i] - (lsp[i] + lsp[LPC_ORDER - 1 - i]) * (1 << 12); /* f2 */ - f[2 * i + 3] = f[2 * i + 1] - ((lsp[i] - lsp[LPC_ORDER - 1 - i]) << 12); + f[2 * i + 3] = f[2 * i + 1] - (lsp[i] - lsp[LPC_ORDER - 1 - i]) * (1 << 12); } /* Divide f1[5] and f2[5] by 2 for use in polynomial evaluation */ @@ -276,7 +276,7 @@ static void lpc2lsp(int16_t *lpc, int16_t *prev_lsp, int16_t *lsp) shift = ff_g723_1_normalize_bits(max, 31); for (i = 0; i < LPC_ORDER + 2; i++) - f[i] = av_clipl_int32((int64_t) (f[i] << shift) + (1 << 15)) >> 16; + f[i] = av_clipl_int32((int64_t) (f[i] * (1 << shift)) + (1 << 15)) >> 16; /** * Evaluate F1 and F2 at uniform intervals of pi/256 along the @@ -293,7 +293,7 @@ static void lpc2lsp(int16_t *lpc, int16_t *prev_lsp, int16_t *lsp) temp = 0; for (j = 0; j <= LPC_ORDER / 2; j++) temp += f[LPC_ORDER - 2 * j + p] * ff_g723_1_cos_tab[i * j % COS_TBL_SIZE]; - cur_val = av_clipl_int32(temp << 1); + cur_val = av_clipl_int32(temp * 2); /* Check for sign change, indicating a zero crossing */ if ((cur_val ^ prev_val) < 0) { @@ -317,7 +317,7 @@ static void lpc2lsp(int16_t *lpc, int16_t *prev_lsp, int16_t *lsp) for (j = 0; j <= LPC_ORDER / 2; j++) temp += f[LPC_ORDER - 2 * j + p] * ff_g723_1_cos_tab[i * j % COS_TBL_SIZE]; - cur_val = av_clipl_int32(temp << 1); + cur_val = av_clipl_int32(temp * 2); } prev_val = cur_val; } @@ -344,7 +344,7 @@ static void lpc2lsp(int16_t *lpc, int16_t *prev_lsp, int16_t *lsp) temp[j] = (weight[j + (offset)] * ff_g723_1_lsp_band##num[i][j] + \ (1 << 14)) >> 15; \ } \ - error = ff_g723_1_dot_product(lsp + (offset), temp, size) << 1; \ + error = ff_g723_1_dot_product(lsp + (offset), temp, size) * 2; \ error -= ff_g723_1_dot_product(ff_g723_1_lsp_band##num[i], temp, size); \ if (error > max) { \ max = error; \ @@ -419,7 +419,7 @@ static void iir_filter(int16_t *fir_coef, int16_t *iir_coef, iir_coef[n - 1] * dest[m - n]; } - dest[m] = av_clipl_int32((src[m] << 16) + (filter << 3) + + dest[m] = av_clipl_int32(src[m] * (1 << 16) + filter * (1 << 3) + (1 << 15)) >> 16; } } @@ -559,7 +559,7 @@ static void comp_harmonic_coeff(int16_t *buf, int16_t pitch_lag, HFParam *hf) exp = ff_g723_1_normalize_bits(max, 31); for (i = 0; i < 15; i++) { - energy[i] = av_clipl_int32((int64_t)(energy[i] << exp) + + energy[i] = av_clipl_int32((int64_t)(energy[i] * (1 << exp)) + (1 << 15)) >> 16; } @@ -613,8 +613,8 @@ static void harmonic_filter(HFParam *hf, const int16_t *src, int16_t *dest) int i; for (i = 0; i < SUBFRAME_LEN; i++) { - int64_t temp = hf->gain * src[i - hf->index] << 1; - dest[i] = av_clipl_int32((src[i] << 16) - temp + (1 << 15)) >> 16; + int64_t temp = hf->gain * src[i - hf->index] * 2; + dest[i] = av_clipl_int32(src[i] * (1 << 16) - temp + (1 << 15)) >> 16; } } @@ -622,8 +622,8 @@ static void harmonic_noise_sub(HFParam *hf, const int16_t *src, int16_t *dest) { int i; for (i = 0; i < SUBFRAME_LEN; i++) { - int64_t temp = hf->gain * src[i - hf->index] << 1; - dest[i] = av_clipl_int32(((dest[i] - src[i]) << 16) + temp + + int64_t temp = hf->gain * src[i - hf->index] * 2; + dest[i] = av_clipl_int32((dest[i] - src[i]) * (1 << 16) + temp + (1 << 15)) >> 16; } } @@ -655,7 +655,7 @@ static void synth_percept_filter(int16_t *qnt_lpc, int16_t *perf_lpc, for (j = 1; j <= LPC_ORDER; j++) temp -= qnt_lpc[j - 1] * bptr_16[i - j]; - buf[i] = (src[i] << 15) + (temp << 3); + buf[i] = src[i] * (1 << 15) + temp * (1 << 3); bptr_16[i] = av_clipl_int32(buf[i] + (1 << 15)) >> 16; } @@ -665,7 +665,7 @@ static void synth_percept_filter(int16_t *qnt_lpc, int16_t *perf_lpc, fir -= perf_lpc[j - 1] * bptr_16[i - j]; iir += perf_lpc[j + LPC_ORDER - 1] * dest[i - j]; } - dest[i] = av_clipl_int32(((buf[i] + (fir << 3)) << scale) + (iir << 3) + + dest[i] = av_clipl_int32((buf[i] + fir * (1 << 3)) * (1 << scale) + iir * (1 << 3) + (1 << 15)) >> 16; } memcpy(perf_fir, buf_16 + SUBFRAME_LEN, sizeof(int16_t) * LPC_ORDER); @@ -714,23 +714,22 @@ static void acb_search(G723_1_ChannelContext *p, int16_t *residual, temp = 0; for (k = 0; k <= j; k++) temp += residual[PITCH_ORDER - 1 + k] * impulse_resp[j - k]; - flt_buf[PITCH_ORDER - 1][j] = av_clipl_int32((temp << 1) + - (1 << 15)) >> 16; + flt_buf[PITCH_ORDER - 1][j] = av_clipl_int32(temp * 2 + (1 << 15)) >> 16; } for (j = PITCH_ORDER - 2; j >= 0; j--) { - flt_buf[j][0] = ((residual[j] << 13) + (1 << 14)) >> 15; + flt_buf[j][0] = (residual[j] + (1 << 1)) >> 2; for (k = 1; k < SUBFRAME_LEN; k++) { - temp = (flt_buf[j + 1][k - 1] << 15) + + temp = flt_buf[j + 1][k - 1] * (1 << 15) + residual[j] * impulse_resp[k]; - flt_buf[j][k] = av_clipl_int32((temp << 1) + (1 << 15)) >> 16; + flt_buf[j][k] = av_clipl_int32(temp * 2 + (1 << 15)) >> 16; } } /* Compute crosscorrelation with the signal */ for (j = 0; j < PITCH_ORDER; j++) { temp = ff_dot_product(buf, flt_buf[j], SUBFRAME_LEN); - ccr_buf[count++] = av_clipl_int32(temp << 1); + ccr_buf[count++] = av_clipl_int32(temp * 2); } /* Compute energies */ @@ -742,7 +741,7 @@ static void acb_search(G723_1_ChannelContext *p, int16_t *residual, for (j = 1; j < PITCH_ORDER; j++) { for (k = 0; k < j; k++) { temp = ff_dot_product(flt_buf[j], flt_buf[k], SUBFRAME_LEN); - ccr_buf[count++] = av_clipl_int32(temp << 2); + ccr_buf[count++] = av_clipl_int32(temp * (1 << 2)); } } } @@ -755,7 +754,7 @@ static void acb_search(G723_1_ChannelContext *p, int16_t *residual, temp = ff_g723_1_normalize_bits(max, 31); for (i = 0; i < 20 * iter; i++) - ccr_buf[i] = av_clipl_int32((int64_t) (ccr_buf[i] << temp) + + ccr_buf[i] = av_clipl_int32((int64_t) (ccr_buf[i] * (1 << temp)) + (1 << 15)) >> 16; max = 0; @@ -803,11 +802,11 @@ static void sub_acb_contrib(const int16_t *residual, const int16_t *impulse_resp int i, j; /* Subtract adaptive CB contribution to obtain the residual */ for (i = 0; i < SUBFRAME_LEN; i++) { - int64_t temp = buf[i] << 14; + int64_t temp = buf[i] * (1 << 14); for (j = 0; j <= i; j++) temp -= residual[j] * impulse_resp[i - j]; - buf[i] = av_clipl_int32((temp << 2) + (1 << 15)) >> 16; + buf[i] = av_clipl_int32(temp * (1 << 2) + (1 << 15)) >> 16; } } @@ -851,7 +850,7 @@ static void get_fcb_param(FCBParam *optim, int16_t *impulse_resp, for (i = 1; i < SUBFRAME_LEN; i++) { temp = ff_g723_1_dot_product(temp_corr + i, temp_corr, SUBFRAME_LEN - i); - impulse_corr[i] = av_clipl_int32((temp << scale) + (1 << 15)) >> 16; + impulse_corr[i] = av_clipl_int32(temp * (1 << scale) + (1 << 15)) >> 16; } /* Compute crosscorrelation of impulse response with residual signal */ @@ -861,7 +860,7 @@ static void get_fcb_param(FCBParam *optim, int16_t *impulse_resp, if (scale < 0) ccr1[i] = temp >> -scale; else - ccr1[i] = av_clipl_int32(temp << scale); + ccr1[i] = av_clipl_int32(temp * (1 << scale)); } /* Search loop */ @@ -910,7 +909,7 @@ static void get_fcb_param(FCBParam *optim, int16_t *impulse_resp, continue; temp = impulse_corr[FFABS(l - param.pulse_pos[k - 1])]; temp = av_clipl_int32((int64_t) temp * - param.pulse_sign[k - 1] << 1); + param.pulse_sign[k - 1] * 2); ccr2[l] -= temp; temp = FFABS(ccr2[l]); if (temp > max) { @@ -934,17 +933,17 @@ static void get_fcb_param(FCBParam *optim, int16_t *impulse_resp, temp = 0; for (l = 0; l <= k; l++) { int prod = av_clipl_int32((int64_t) temp_corr[l] * - impulse_r[k - l] << 1); + impulse_r[k - l] * 2); temp = av_clipl_int32(temp + prod); } - temp_corr[k] = temp << 2 >> 16; + temp_corr[k] = temp >> 14; } /* Compute square of error */ err = 0; for (k = 0; k < SUBFRAME_LEN; k++) { int64_t prod; - prod = av_clipl_int32((int64_t) buf[k] * temp_corr[k] << 1); + prod = av_clipl_int32((int64_t) buf[k] * temp_corr[k] * 2); err = av_clipl_int32(err - prod); prod = av_clipl_int32((int64_t) temp_corr[k] * temp_corr[k]); err = av_clipl_int32(err + prod); @@ -1204,7 +1203,7 @@ static int g723_1_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, memmove(p->prev_excitation, p->prev_excitation + SUBFRAME_LEN, sizeof(int16_t) * (PITCH_MAX - SUBFRAME_LEN)); for (j = 0; j < SUBFRAME_LEN; j++) - in[j] = av_clip_int16((in[j] << 1) + impulse_resp[j]); + in[j] = av_clip_int16(in[j] * 2 + impulse_resp[j]); memcpy(p->prev_excitation + PITCH_MAX - SUBFRAME_LEN, in, sizeof(int16_t) * SUBFRAME_LEN); From patchwork Wed Sep 28 18:58: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: 38454 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp444273pzh; Wed, 28 Sep 2022 11:58:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM71R9Lv6wV9Iag19+jUt2q8kYvQjYI1Z89GeHy+2oOB26UXCPR5eiMuwf74bt/IJHYcPbjH X-Received: by 2002:aa7:d407:0:b0:457:5a15:62fd with SMTP id z7-20020aa7d407000000b004575a1562fdmr15336854edq.295.1664391518280; Wed, 28 Sep 2022 11:58:38 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q18-20020a056402041200b00450f1234f3esi6019559edv.199.2022.09.28.11.58.38; Wed, 28 Sep 2022 11:58:38 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=sa6IyxBD; 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 B98CA68BC07; Wed, 28 Sep 2022 21:58:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2096.outbound.protection.outlook.com [40.92.91.96]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 023D568BB72 for ; Wed, 28 Sep 2022 21:58:27 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gtiY/JJG0BUOhePODnQVDG5DjaCRO4okaqaeme3VDTCcaOXxFrn30wTMU9Ez2nhkz2PdWNHDV5cTN9yg+hZcIeZSS7l7NERmqs0eIWaN4zMziMl6vmSr14tzG95hV6EHwGNVtlpXTr9iPWdKrPlloXDixC8UyxL576RJ52iCVFb/ei6ELPbej4wRsYSI3Ui2qEXQ4ZOLKQvqYqjktsjds4p7uMIzH6Snbqjfj7+HBb2oVk/vZM5HWfUFNXIHX0squ289YrBHqVPmeXeuuZjueQRpSsOGeXK3XWw4hZJX0UrI/LJmfBq3xFASnqODs8QgOtsttMPvkG/UYeyTVciRsA== 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=TkDvEtRATFxx+Tv22mGIYPZskCHIRUkEErzLhO35o78=; b=Mix8g2f/oH26u08/706UBsae7UdiNwycKvCRUwtdwkS70XF68NgL2lGnqGQXXaRlSPeedsSCfFXFqO75iJQM6A0f716+i34tZOW6MI1b81IqHrQ/9+p1fCfEfcgReNQlTVJLHcXHIkY4a+RzlR/6muG7nXxj8NzrVWpXYkGRs0j/S1eQDC6A1eMkZYLC27moeDJP3FoSPPjT0BirTWuOd9I6yE31Ez+T7u9203zuQsLUFecemGD7iLBivZzZAV7QXMgM44fLfw9qvaqkEbcO1Eub3Y9oLh6K4i4lA1uYt7YxXUAnblDw2s7TF1siQeAjPrtnLaH/8Xv/DySpku1cOw== 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=TkDvEtRATFxx+Tv22mGIYPZskCHIRUkEErzLhO35o78=; b=sa6IyxBDO6FyTRaTe2B1+052iFeX1dLenz868AWol/eJltuvilY2KpNRlsJhm/KZqJIW74jSde7L6oq6TuvpOUzpNPUfbrZfAj2GWU480OHpxDP2fzzkfphIXk6DcUgZwWhLoXrqqP0a6brGZx3S9U/60+mSFUaWCK4UeVraW8CX36ywYtZDCXGXKYA4vlNvBsp98WX55hIVrXB2aG/+owEwFqVWYMbk2QBn3Nl0V7ZIw8GzCYrYfDO8vBo0O8A+AG5/5IvSkNAtxJ8kXzTCM14ATbH30sAra02arYnyWWRsiva56Kexo1plDV28vpMfzFkj0o+F28sCojHoFM72Hg== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by DU2P250MB0014.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:2b7::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.17; Wed, 28 Sep 2022 18:58:24 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::68bd:2fc7:ac52:38f8]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::68bd:2fc7:ac52:38f8%9]) with mapi id 15.20.5654.025; Wed, 28 Sep 2022 18:58:24 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Sep 2022 20:58:15 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [5nSp4FdDwSFnlRxoQGMR8tMqzcr72N08WSyqJIGUJFM=] X-ClientProxiedBy: FR0P281CA0051.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:48::12) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20220928185818.1074689-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|DU2P250MB0014:EE_ X-MS-Office365-Filtering-Correlation-Id: 7a34a7e7-8d97-4f7f-fd02-08daa1836bb6 X-MS-Exchange-SLBlob-MailProps: AZnQBsB9XmpPcoZqFl/i/jhf7c/pX34TQU1c/ZvMHcsK6zUU6iEJQAxXGtzfLRIXsjNxw8Aew2LvGgdC3BygyfdC66Q4b4+f6VNRaKobwslHcMuBLddKRdHuY8KTQ/ltrfD5p9pWoJlKHPFgfdU26iC58VqX42krjcA+XdCqA0vPRVDoOc4eFwDUscsGJoCIK0kvOOmnyEWPwY65UGL1+lm7FpGNOb2rcogQFB7Es3iAa/Zdr1l31dYjwfYcXLLBTwA5DNi2hsKInNLVHnGPjj6vbM15l/Dr6JcvLmz6bk2hkfZfdKsjl0aqHnQUd3Pwj0MrX1cXzK2R4vu5wsCzjQzqkAH9YEiZsPCuGuiEhDQ3Rft0YjtZHHBl1V5IGDqfYLiYaMoNyDm/01Y0bhgzeJk4aXO3SkEc5VzyOsSt7urwqKFr4wyvATaSPH+bBy/6HG2ebFUgHWfzggzZPxeL6Dk8/0C/ta3UrjPpQWdvnFmNJAnN/lPaBiTjjaMFqnCW+vg4O8eccs0g/a9PMt7RiThf4XXa4v/c3Rf9rm5bTD6UpwbjzrQU3jdjINHLoq5ShxqpMto9KxwKD7Qkpti4abqDyc3gwUZUY2xeTTCZiJU0qyhNe3whVnjHMmyjzkvduXOPMOg7R31TPgetUhRxCnbC+xXzmJB5DClt513DZbDdMw+OOxeezLeznod7XqTmpISDH8SY6f8tHmQNVlaxpzwDusilJJU8K3JkhV63J70EjqlgO4lwDU2NqJc67ypi89xFmsdO1/8= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AS23jsixWB5u9CcZdU0sLCoGkkmFecApdZF4BazvzoRwxL2/zldjVBgJl1SvOcYZG9sKqh7U3eu7B69FItpTte/IQgieSNjPepOYSqurpN7KQ2WOl7Qq+hZbLLWOkkYB1ZzW8HRW50+kvMA+6Qv+ora7GJgaQvENPGxAXCC66+CkkvG8qelL9tUzvC+Ct9GXIDWVMygQv7e+8jySfAdxEvgTUdx5r0ssVkZvQciZWbWyhRW9ChEeVb7TJVC/r6xny62BkwgXpi8mWtMhXTt86K9RezI7RzgfpN2vXSNinPAlbksFTmG6AayUVngQbrJNW3YdVOflWqw4hA64qqGItEkBqJB1US7POAdHYNHQQBwDuyzaZVe2zOro/LdcxRek1TschnwXaBCFNm3p5dkJANKW+KBtKEtYZp9XS/D8g20D51IPGJj8VzTN871H18xHnWBxVmV4wlYU3N9R9LTwUQfuuzBFL3Nodea7yh9Vkwv8FjWOdItUc5jeKKu6XZGtj81WLxfSGjRti4Yd0TaS5616qU48bOqU89lVgOaGVWB5z15yfd/xs1ZCz/ODCQqrVLZieUs/r8JOZ59Vc4asiEiqthCNihBeJPetpbmieLFyGHlrqX8Lw3+YVuvwC3jU5BdU9+H0dlQ6rXpdXpF8fQ== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /c6xPnExWkNPEmnDatJ6hBTo4VjCZqci1bB+sT4PFuX0p1vDetzTtWaUh37ps0vMAbLuKjCpLkaQV1os41HUZD4gnvsDtuT1+qoEnePlLPjlkrgJFu2ao84odQ7oA/e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EF/xgAbKlzjcBpkzan59KpHUl0eiMnqy86LcChRaQEw+5QQoNRovFYIj/GpuqTzAl7LFhHnxWI/qYQslbkEY8uZ8tNhlfjjU7z4Otfuj92xeHVT0tBFZtuy3uUYVJwqlMPB5G X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7a34a7e7-8d97-4f7f-fd02-08daa1836bb6 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2022 18:58:24.8319 (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: DU2P250MB0014 Subject: [FFmpeg-devel] [PATCH 3/6] avformat/aviobuf: Don't use NULL as src for memcpy 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: 9EdlYPa1f4fc This might happen in avio_write() if size == 0 when the direct codepath is taken. It is undefined behaviour according to the spec although it happens to work in practice. Fixes the webm-webvtt-remux FATE-test under UBSan. Signed-off-by: Andreas Rheinhardt --- libavformat/aviobuf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index b20b1a611a..5b6a42d7f4 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -231,6 +231,8 @@ void ffio_fill(AVIOContext *s, int b, int64_t count) void avio_write(AVIOContext *s, const unsigned char *buf, int size) { + if (size <= 0) + return; if (s->direct && !s->update_checksum) { avio_flush(s); writeout(s, buf, size); @@ -246,7 +248,7 @@ void avio_write(AVIOContext *s, const unsigned char *buf, int size) buf += len; size -= len; - } + } while (size > 0); } void avio_flush(AVIOContext *s) From patchwork Wed Sep 28 18:58: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: 38455 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp444332pzh; Wed, 28 Sep 2022 11:58:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7mILATiECGik5Z43+YrZ9fvQWgdinuuojKgquEPbM+JrvnQuLcYRE7cU0YXSbmnG9A2usL X-Received: by 2002:a17:907:7d8d:b0:781:fd6b:4545 with SMTP id oz13-20020a1709077d8d00b00781fd6b4545mr29722584ejc.117.1664391526523; Wed, 28 Sep 2022 11:58:46 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id hr38-20020a1709073fa600b007867dcd3ee8si6489618ejc.810.2022.09.28.11.58.46; Wed, 28 Sep 2022 11:58:46 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=tWc8ct5P; 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 CF47768B357; Wed, 28 Sep 2022 21:58:38 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2096.outbound.protection.outlook.com [40.92.91.96]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2217968BBBD for ; Wed, 28 Sep 2022 21:58:32 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l0CBbPZYiBf1ZYYo3NwrHc+KD53Ecus+HOTNpxCUAOSUOfvNC8UcgSqwtsXQeuSk8poZjlmR5+3CqINvWVS6UrmiXjf6iwVtdwQJ9wt/RoZoa0nwP6M/y7NAO7TgwR0Ybo/m3j2iCh0wsUTIrg/pQz5G+1Kg3rYLrXGVtkaN2Hg3ZIzzIGKq/YvIdc8GB0QYFvxArOnIrkViugPZqSi7aZsH2HTd9Cf/WDwIxX5sxqbRmAZiss9f19J4v9G0gr/L47A8MeegmFWQlIMMzkIWoM0jr9AyHyS/J57rhMiE/mnvq/zqYwImhV7fV/EDzKYhjvDiEsuBcwBaocvUAVtdYw== 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=8hEu5/r4wuNIxhoUNESat05UH7x6EisL1QE+F+oOYeY=; b=inSvYaDgWkmSFfdoJm1ljD2yPh1mXjA7uk/5k4tAvrtMBDhR3STcnHDZgqPZq+0oMgvySx4JSnjS8eH7ejpWweVKG2Qs2sz+pv3i1YPB6Jxf4Qz9ajcH7BOR3S+RKPxXipZ0LdLli/oYL1FRqZiGH9YQ48t5Rkp7JMsOVIf2zCfnk9JcZ3nQcslt36Jp6jpnNCkmEpfmvjWfHIZvdXMtZODCHAFaiz5AAncdS4pRP6ncpRnttBfWrgorCzkSJ1TaT8s6OZvwaMf5AOwKPAhzP7hqBDnzeDWHyhzPk/LNYAcyKvdi5vQGXTqW5fGdqWeAh2UWtIkXnWrNJXtbDvBkVA== 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=8hEu5/r4wuNIxhoUNESat05UH7x6EisL1QE+F+oOYeY=; b=tWc8ct5PpipG44QvbXlXuiGfRU5YjN/uG2xvVskO7FUHuD3Wvc4p3SUnoPGZ9JptUo1o7P4FsvvauU5ybpkaDMuYY/BSYxfneU1SDJx4xzQ3u0oE4RcXWMkgwHvWNPU4YyDfQTFmz3zX+6i/F63IYiwFTQMDh8/9naJeDqaRKEZO1ObOjIe64gnOnDJsVdsuZvPdeqH5QTPq+G+h8btyp8Tmi79kcruC0BLEobFZUBvx5KN5Z+KA72mkZrmcRFaCrdFBG9PVVPlV8Wc/i+x5Q68xk4TZRqWh3gasTcfXy8ylTXlDgJqwss8xjpq1FQEMXWq3wVgI86Q3rIt8ClLiCw== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by DU2P250MB0014.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:2b7::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.17; Wed, 28 Sep 2022 18:58:26 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::68bd:2fc7:ac52:38f8]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::68bd:2fc7:ac52:38f8%9]) with mapi id 15.20.5654.025; Wed, 28 Sep 2022 18:58:26 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Sep 2022 20:58:16 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [YVoguzegjZuWD9F72+GU0GGKYBF9aQg60/YvdDvA+50=] X-ClientProxiedBy: FR0P281CA0051.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:48::12) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20220928185818.1074689-3-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|DU2P250MB0014:EE_ X-MS-Office365-Filtering-Correlation-Id: d52fe29a-3498-4916-761d-08daa1836c78 X-MS-Exchange-SLBlob-MailProps: EgT5Wr3QDKyaZg3Nqsb2Hykb5+EITt3rPgoizaLs1HqW8ByCzlics+Jad1NwaVPmXMCOvo9u1Q7AjdXdF2H0RpCNesnBH0e63Zg51aUMumq+rqnZm09WPuGnjmnKnZ6DkU9+WO3ZFzPBTu8vq5df0IkihvdhOf9Kv/hbnm01EHF1TbJqJcZ5Mcc8FNFFjrPmXkQwbaEJDVEzzs+m6oBc5JTtPvhKAMGa4hhiVBSG46+tWO9df7BUtGUlBx2mZTLkswZB8tX92bZ4v3ZZHaY4dJwQmcZhCSS2IDz3zJETZNGKV4/6On6JMl7ZYvToQ1TI1pa0Pf4vvQShEuk2tqCpY0llex9LkFR4ko/4J5fp/GdYk5b45rQwf5hV/n86Q+fbOPH0Bz0Iix4t5yCnzLPwmUB573r22NATD0bULwtbUlIZKOITTQGkGQiG6Y7GyjcWVfcr15Z8pigBiyKZYNIW8LqttiOMHQxakcsGKJwXskWbrWbrppk4JuMjbx6SP51uPybOcmZylRmXJObrdFc5WAfHsO7UybT3B9xGwsb64EwVRH3NCsss/naWlsYMLH4FIWvegijx1CUEEOBLnVnDuC0eC/dqoS/DC9T4aKtUtRq7z/yOj5kW2n3OKiXCnWvbRoX6SrXu9pFyTJiItgYDrUUD9DCui7CS/e9f5/ZodeAzCEKjHgHMLdJ/c+DW2runWVajM8j/JFWeuuMYjW4iW0InEDRVzgE5bKNCRds/Lxw= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ARWpaucfBdYWMLwB1zS1ZzcRDsI2v73R0vBv+ohP9dnfETdV4jO4trLH1W5xrUJwjZfZaQfbocAPzyac2I4m3Qtvjcz1GZ9Nh1W8A3JYvWCvJcpvCW5GcMCiFn7yJ5T5ZkuLOGiIWQ34WiOIwLTklQzy0sATm/AMNPtMW9nlVMubskHrgFNFlqFasDAeUl1v0wrdWRjl9bLkRSB/B3/JZJqnu344lFgddZjhFPf+9t+HguGpKrWCAR39nKyj6fpdecAgbtC+mX5GMDYi1eCyXS8WboeZZs3FbHzrT27kdvbFo90PqSywws+AZOON8gcvJLBwtTpLXfM3BcFT/WHKz1t9lONTgR9M8zWsr3aRGb4eT567UtD25bhmMX+PVdfx/i8cDHSsC8wL768WsvSD2mzqdLIExZPLo8xFIQroDY54Y5kUYOAdKQEfAecNNkzUM4oERCkMCC1jfKNldBPChEifaGq69D5h2dwSBuH4JGvWkyeMJHSelwndXL7rh8JVv4R5Gw55NTNEqk27PJ90lCwuzEK78MsxVDclzNFfYMXR0SwiBljryCXMPy1s2J0ru1zKUIMG9Rb14XT/LkEgY+hz6RUnUUcUe7xykxcORve+gOoSZZ4KlAHZGC9lPDMBaj0U/V7NIHReAtxnaV0CMw== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: U0W9l5YRpdS7W9rleogYcgeIC9JxgLT244AoUzbLwyRpibZaHI9xLD+NDCVoKCkbf3/551LlXJWriFFrI+6I9rw5ftkdtTahrt3Y3g+UTDrnpXgw2ijrtBqu2nVhVsWX7278rIEVeM0LwG7Abphst/rrgHJ3IpylldfDA6xfhltCzVrkc6LVG5iZgYI2CDM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ejJcTsF22wViN2/PNyQNG7OgFd/nz4hLDBcS53gtKGjYDNwQgT7HYm90cDtL9qg2etv54CTRXiG1nMNZBdYCuulZ9Ow X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d52fe29a-3498-4916-761d-08daa1836c78 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2022 18:58:26.0530 (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: DU2P250MB0014 Subject: [FFmpeg-devel] [PATCH 4/6] avcodec/jrevdct: Fix UB left shifts of negative numbers 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: cgbGOixwDZb/ Affected the rv20-1239 FATE test. Signed-off-by: Andreas Rheinhardt --- libavcodec/jrevdct.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/libavcodec/jrevdct.c b/libavcodec/jrevdct.c index 36160cb663..7f1863515f 100644 --- a/libavcodec/jrevdct.c +++ b/libavcodec/jrevdct.c @@ -255,7 +255,7 @@ void ff_j_rev_dct(DCTBLOCK data) if (d0) { /* Compute a 32 bit value to assign. */ int16_t dcval = (int16_t) (d0 * (1 << PASS1_BITS)); - register int v = (dcval & 0xffff) | ((dcval * (1 << 16)) & 0xffff0000); + register unsigned v = (dcval & 0xffff) | ((uint32_t)dcval << 16); AV_WN32A(&idataptr[ 0], v); AV_WN32A(&idataptr[ 4], v); @@ -988,8 +988,8 @@ void ff_j_rev_dct4(DCTBLOCK data) /* AC terms all zero */ if (d0) { /* Compute a 32 bit value to assign. */ - int16_t dcval = (int16_t) (d0 << PASS1_BITS); - register int v = (dcval & 0xffff) | ((dcval << 16) & 0xffff0000); + int16_t dcval = (int16_t) (d0 * (1 << PASS1_BITS)); + register unsigned v = (dcval & 0xffff) | ((uint32_t)dcval << 16); AV_WN32A(&idataptr[0], v); AV_WN32A(&idataptr[4], v); @@ -1008,8 +1008,8 @@ void ff_j_rev_dct4(DCTBLOCK data) tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065); tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865); - tmp0 = (d0 + d4) << CONST_BITS; - tmp1 = (d0 - d4) << CONST_BITS; + tmp0 = (d0 + d4) * (1 << CONST_BITS); + tmp1 = (d0 - d4) * (1 << CONST_BITS); tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; @@ -1020,8 +1020,8 @@ void ff_j_rev_dct4(DCTBLOCK data) tmp2 = MULTIPLY(-d6, FIX_1_306562965); tmp3 = MULTIPLY(d6, FIX_0_541196100); - tmp0 = (d0 + d4) << CONST_BITS; - tmp1 = (d0 - d4) << CONST_BITS; + tmp0 = (d0 + d4) * (1 << CONST_BITS); + tmp1 = (d0 - d4) * (1 << CONST_BITS); tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; @@ -1034,8 +1034,8 @@ void ff_j_rev_dct4(DCTBLOCK data) tmp2 = MULTIPLY(d2, FIX_0_541196100); tmp3 = MULTIPLY(d2, FIX_1_306562965); - tmp0 = (d0 + d4) << CONST_BITS; - tmp1 = (d0 - d4) << CONST_BITS; + tmp0 = (d0 + d4) * (1 << CONST_BITS); + tmp1 = (d0 - d4) * (1 << CONST_BITS); tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; @@ -1043,8 +1043,8 @@ void ff_j_rev_dct4(DCTBLOCK data) tmp12 = tmp1 - tmp2; } else { /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */ - tmp10 = tmp13 = (d0 + d4) << CONST_BITS; - tmp11 = tmp12 = (d0 - d4) << CONST_BITS; + tmp10 = tmp13 = (d0 + d4) * (1 << CONST_BITS); + tmp11 = tmp12 = (d0 - d4) * (1 << CONST_BITS); } } @@ -1086,8 +1086,8 @@ void ff_j_rev_dct4(DCTBLOCK data) tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065); tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865); - tmp0 = (d0 + d4) << CONST_BITS; - tmp1 = (d0 - d4) << CONST_BITS; + tmp0 = (d0 + d4) * (1 << CONST_BITS); + tmp1 = (d0 - d4) * (1 << CONST_BITS); tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; @@ -1098,8 +1098,8 @@ void ff_j_rev_dct4(DCTBLOCK data) tmp2 = MULTIPLY(-d6, FIX_1_306562965); tmp3 = MULTIPLY(d6, FIX_0_541196100); - tmp0 = (d0 + d4) << CONST_BITS; - tmp1 = (d0 - d4) << CONST_BITS; + tmp0 = (d0 + d4) * (1 << CONST_BITS); + tmp1 = (d0 - d4) * (1 << CONST_BITS); tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; @@ -1112,8 +1112,8 @@ void ff_j_rev_dct4(DCTBLOCK data) tmp2 = MULTIPLY(d2, FIX_0_541196100); tmp3 = MULTIPLY(d2, FIX_1_306562965); - tmp0 = (d0 + d4) << CONST_BITS; - tmp1 = (d0 - d4) << CONST_BITS; + tmp0 = (d0 + d4) * (1 << CONST_BITS); + tmp1 = (d0 - d4) * (1 << CONST_BITS); tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; @@ -1121,8 +1121,8 @@ void ff_j_rev_dct4(DCTBLOCK data) tmp12 = tmp1 - tmp2; } else { /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */ - tmp10 = tmp13 = (d0 + d4) << CONST_BITS; - tmp11 = tmp12 = (d0 - d4) << CONST_BITS; + tmp10 = tmp13 = (d0 + d4) * (1 << CONST_BITS); + tmp11 = tmp12 = (d0 - d4) * (1 << CONST_BITS); } } From patchwork Wed Sep 28 18:58: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: 38456 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp444413pzh; Wed, 28 Sep 2022 11:58:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Fh3r9GLaSUHM4MAcrR9PZY5P2ko1jhjSnPt5y1+YH6z5cRoQCZZViPVRcHTQ61pA6bpD2 X-Received: by 2002:a05:6402:11c8:b0:451:7220:6343 with SMTP id j8-20020a05640211c800b0045172206343mr34266097edw.184.1664391535198; Wed, 28 Sep 2022 11:58:55 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z3-20020a05640240c300b0044615ee1b6fsi7149989edb.218.2022.09.28.11.58.54; Wed, 28 Sep 2022 11:58:55 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=ey17GdYR; 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 F04A868BBE7; Wed, 28 Sep 2022 21:58:43 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2096.outbound.protection.outlook.com [40.92.91.96]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3F85C68BBE7 for ; Wed, 28 Sep 2022 21:58:37 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k2ulq3a2MKaifqKLM2oth4jyVwAZfQjwm3EnjdBc51izzvuxMOT3Eh6gisbwynW1ktks4jXlo6hQWCI7USANQlCo9kGqF+TlePxBdY6OgH7/BJtkm+m7RhZhJTD/pn2COWCnmXrxp2fTIxsioT9IbQW7NhrIyX4gDZACClQulNmRu1css5YfoQmmdh8ZwYSM4+tJ7EgH06dnVEX3UGy8FZx7bOUAQhYqFaa4h//L/Wu8PwWdfWkVyuktjY8LAb1km6qMytvwuuqmpOM2vXu+SXa1WQ4af1VTAhsHQpeBDy5X3x2mCS7u0q7YQvUVCN0yhK3sEJK8cvhSHQjKE0mCiQ== 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=aboKi2jD+xaWRnfNz9ClREDsDscDsj7Q/W3u8Hworco=; b=NXlJipBUgzIst4RLUNZU7kUxICA2cUjlrucs0VX2Bh0hYzTndPsrdFabz1/1UPGCzvu1+6YmaYWKKe7pifhvECaF/spVGICW7YjeChjIXIZreE98UIEmaSzhg0SehqBGoc0MlGR+EDn+Wr/iS1Qn0Vmmo20ajTj2c2LziBG8+9PApevnDOfbsybujN+j74I1JYy+uJ/YpERpij5QsEAz9iDRQrBVDYN5eM+4CYn6yBsvA6qd2LN7QRgbGcOdb269RlOqPoAIuF7jjOHQW7wiV/RYl4sLYgF2ogI2aAcdjEbiJ2VW2CNzm4OxDYQ4XcPAZHF5DvxTLNlGFZ+DzG9qSw== 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=aboKi2jD+xaWRnfNz9ClREDsDscDsj7Q/W3u8Hworco=; b=ey17GdYR4v919aEzUAqHRM4HYu9oSMU/vrFmYUBssbShYVHO4S2JYMJspOcsWgs4Anio0Akvj/Firr1SkntO1tXwvuykswIuAclD9FqHYLWJPjpcrsoBAD2eYhDz3RX3PaRGSqdpP5CVKJBc/xDxy5Mm60taFUWQ6UytnjBxNH+EbQgaTLWqSUJseMWQWHoQx0XMniBvavguoMRbjPNF53ZMTbkq2Jge4OCF4JrMqhXRTMPgYPy8p+p3BHYDulAntovadTlBE47mXscCuTNyOu9fr6UoDJdx7KrbcwKRSADNBc0Q6CwHMDkrC1FG2XiyUlJ6gDwPN2cvTc1OyishSw== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by DU2P250MB0014.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:2b7::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.17; Wed, 28 Sep 2022 18:58:27 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::68bd:2fc7:ac52:38f8]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::68bd:2fc7:ac52:38f8%9]) with mapi id 15.20.5654.025; Wed, 28 Sep 2022 18:58:27 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Sep 2022 20:58:17 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [unk0Ga+grwq1s4KXe+9lEXrK5H2y7aJ6iUCTiZ9ASQE=] X-ClientProxiedBy: FR0P281CA0051.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:48::12) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20220928185818.1074689-4-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|DU2P250MB0014:EE_ X-MS-Office365-Filtering-Correlation-Id: 9b410672-d5f5-49a0-793f-08daa1836d26 X-MS-Exchange-SLBlob-MailProps: ZILSnhm0P3kh+Zs0i80mamVaMOhNuFW0ItgOLPTsrHB9HeI1UiHAIivQ60n21KrwlFs7ivuKypCZEmAH1atQBoHdjvpV09TT3YFXREa1Tkg5sVAZjzJVcnZOxS58cmIlOlo1DCpoxXvAYjdL5CliAFs/iUkai4H/LKAI0fHl/c+YTFTfLY7YNmV3cdf2ckwV9X+td9z1fzXyOqno2R9vznawLjUgRQ5AmFGfLsP6s4t3UVWM4MRbctMXCXzxCCaIunWUFtjDfqwXmTaO+QvE9YNhB/FKGrGEvnUaxcRpmyYN2YlDWsQCWQFVbwU792GiTDWKGxxp2Ypb6702UWX1LcMq8RKkKdWrSZdVgtGg8uGj4mfSXsVZhVUp0GdLTT4qdBznJHp7Btz6qegrUiELYDzVfNDGivwcdHLZGdDZRcJOwYm2+Ogv/5VyvwhfpMQiAJNouFBHMD7gjA+OFOfWwjSRN567mNwLFXFF44MQ96pSKRhDHSixAirZJJNwIqadXpsJC9MujCp27UgBtZvftbmHhrfmm6c4qCUbnGWoTQyW1YnZFk+Y7fCslIj3W5DHUpRaQDWL1019+kk2D8p2cOWDOmz/9Se0YzVDTfi4g8tdXIyXVs4/k/jRoc9eZGSFNojX88AS9jja8as/udturI1vAz2zks1HJAhETi+Du1o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L7dF5JX1QQGXCPbZJeF74C6r/DPtcCfAYv2+0Sx7mRU2aqTf3JmgI9nk5po5PwlJAkvoAGw7X15HG4m3b X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9b410672-d5f5-49a0-793f-08daa1836d26 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2022 18:58:27.2246 (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: DU2P250MB0014 Subject: [FFmpeg-devel] [PATCH 5/6] avcodec/mpegvideo: Fix undefined left shift of negative numbers 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: vbuKuU5I9hNK Fixes the rv20-1239 FATE-test. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index d8c7bc687d..5095149eaa 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -843,7 +843,7 @@ static inline int hpel_motion_lowres(MpegEncContext *s, s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, src, s->linesize, s->linesize, w + 1, (h + 1) << field_based, - src_x, src_y << field_based, + src_x, src_y * (1 << field_based), h_edge_pos, v_edge_pos); src = s->sc.edge_emu_buffer; emu = 1; @@ -945,7 +945,7 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s, s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr_y, linesize >> field_based, linesize >> field_based, 17, 17 + field_based, - src_x, src_y << field_based, h_edge_pos, + src_x, src_y * (1 << field_based), h_edge_pos, v_edge_pos); ptr_y = s->sc.edge_emu_buffer; if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { @@ -956,12 +956,12 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s, s->vdsp.emulated_edge_mc(ubuf, ptr_cb, uvlinesize >> field_based, uvlinesize >> field_based, 9, 9 + field_based, - uvsrc_x, uvsrc_y << field_based, + uvsrc_x, uvsrc_y * (1 << field_based), h_edge_pos >> 1, v_edge_pos >> 1); s->vdsp.emulated_edge_mc(vbuf, ptr_cr, uvlinesize >> field_based,uvlinesize >> field_based, 9, 9 + field_based, - uvsrc_x, uvsrc_y << field_based, + uvsrc_x, uvsrc_y * (1 << field_based), h_edge_pos >> 1, v_edge_pos >> 1); ptr_cb = ubuf; ptr_cr = vbuf; From patchwork Wed Sep 28 18:58: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: 38457 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp444482pzh; Wed, 28 Sep 2022 11:59:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM41fZmMqgylIJDqYS85oJm3AeL2cqoScl5uoC9kPHkxjHJBJu3QGwtbq7zPPUw1ytqUoraB X-Received: by 2002:aa7:cd92:0:b0:456:cbb5:2027 with SMTP id x18-20020aa7cd92000000b00456cbb52027mr28509131edv.384.1664391544811; Wed, 28 Sep 2022 11:59:04 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id p22-20020a170906785600b0077d6d63bd0dsi4733274ejm.184.2022.09.28.11.59.04; Wed, 28 Sep 2022 11:59:04 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=cpsmjcUO; 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 078F368BC12; Wed, 28 Sep 2022 21:58:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2096.outbound.protection.outlook.com [40.92.91.96]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6F2C868BBE7 for ; Wed, 28 Sep 2022 21:58:42 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nGLZZEfTYzRNw/cSB8a9SBJyCMSu7TjxNISvpqNQUM5L3WTHAI1PlSbAkvm9CNnFNMCdMqew2bMjb2tGix6bfiIwz/6MJKv0DZNsI0THMo/cdjf6ldSDTgPIgPyDBfu1HXmhuZ6OdC9CxtyVofx/zpuL6dXMVTHPMnvbUiOFnUa/x7Jqz8qLjCNolRuQ4HLwkEL9xyM4rsCeRFZd3U2n54R7ad7B9QN4dSAbthVimIYeRsr8D+3rNwJoz218K+V6wWow8+DpT5ZZhWwtpVxDNjyJEKJHBeKHe5KoRzF8xUAEQECg8wCNNjQjGg1S7gJM25Ki5qGceUKkTiH1NzTlBQ== 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=50lf45X2QHs4P5Kyv+vkWxQE7TNeg7vK/2Ugv8XX8JU=; b=NZdJk+D1phyGbDDLdkeJ1D9WSMp56fWqI6rnkO+aI8TIm8OgEhYRdRAY824BcLScqfAtLgtCrjdjDOgGQPlFN8seuvGIo2+UaOUVn1mWZg7+kvZfA92w9nUYPqgEZ7PV73FNTPuSOYCVyqPTW2IkHM3GF84IpDbxpt1AcN5dzBepYrUSpJ+PRMlqiB78wwYHwqDPNBsu0L4sqwStWoK+Y6WL18hqEvPr83IV5m31/6WMcaYIH+g1K254XOztrojTZYw4fDAdzz22ffdpbmCC44R6prpmLO5F/opUrgaBdrvgIessL/cHYa+c6/pLCVUhsscal7JqEdUlGv60KgNjtA== 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=50lf45X2QHs4P5Kyv+vkWxQE7TNeg7vK/2Ugv8XX8JU=; b=cpsmjcUOrjg4cNQrPqzW3VciAGnr0X1R9qUbTqTVFJdHP5nxndsh1SPujgBfIPuEp3CwQWKolgJ17ujEwcwjp6jnTTcZKIqdSBLStbzm3EsyYk/2ZB6Z4kefZb01+RS7sAxWQ3EqabwuKWBq+N0Czwfxm3CxgvfCnet6sR3mLIB+aKNaDlk9WymuNUDI/p1RkVqbIE07JXSlFYZg1nCD+ZPm49PFiuobuFU5y8mLhMnflyocomMm8+p2wS+n1EdQeqevUXiED3JpBW8KwuLmAygcvlJFwVzvcqjVz5YYx7ukH6CM8cVkwF+0r+AxkQcCXBfKY1vagPepu7rY2BWTtQ== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by DU2P250MB0014.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:2b7::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.17; Wed, 28 Sep 2022 18:58:28 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::68bd:2fc7:ac52:38f8]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::68bd:2fc7:ac52:38f8%9]) with mapi id 15.20.5654.025; Wed, 28 Sep 2022 18:58:28 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Sep 2022 20:58:18 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [bgGZ/kqdwVzlffuhJ4u0jMt0G3pKI2TdS5mXOga0aU4=] X-ClientProxiedBy: FR0P281CA0051.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:48::12) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20220928185818.1074689-5-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|DU2P250MB0014:EE_ X-MS-Office365-Filtering-Correlation-Id: b5b19b6f-7469-4d54-e31d-08daa1836e1b X-MS-Exchange-SLBlob-MailProps: AZnQBsB9XmpPcoZqFl/i/jhf7c/pX34TIhRZ4XrMf6uy90tcnaIzqphrYHfs7JEykXRQA0LFejH+0Cy4K3dTMm0ha6Z///TxhyT9NSUQTIVta2GgLS+JbiQQtO3m88ZO24nmE1O3Vay+t3+T6lvi27ToDb54aKcyz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2e2u0ohYP8mkcahz9vCcYZ736vPZhdcmx6DZflEHPij265Zu9OWSCr/GAxyCzsx1rRkrKagjqb8T1QiU+JOtTsXKlACZ79WFXINYJQQ8MvA2r6yxLUbo8AyCDvHTRMfEEmwv12F2J4F8r4qlF3sHDX5GZc3n/IdfZBJ6a8A1tcNMnY/xZ1iG1z8uNHOfPC+AFVoZW1zFIf+T2UePWfZHcsjbqu1nyWHAU4lG4Acyt1GHzgfzaqCByBH6z7wY9F6h4ALhplO5e3VlCL8F5vt14wMKq+995HkTymXPlssdNtyndcPv4vSzvKBuhleev529Vd89JVyDCX3/Yxle65UV4b+euA93PwRS7tyLoUbL0Di/63oyCnndFF7RqR6dNCMyFfF9xJBkb39Il68ESEAQyJcOed2ed1+E6KddXOQ7O1AiilcEpURPifdIctWdV8FuKKky8lWKu5k0qIpEJtUw0iTB7ORn5eEcPBjI/pgPen2ze/BkihwvIzaZvlYiCjekAbyiAh+e454GQU8bGjUICF3T/71S2jxSf95n1mg07+ X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b5b19b6f-7469-4d54-e31d-08daa1836e1b X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2022 18:58:28.8642 (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: DU2P250MB0014 Subject: [FFmpeg-devel] [PATCH 6/6] avcodec/mpegvideo_dec: Fix UB NULL + 0 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: UtRcJQD4VzUx Affected the mpeg2-field-enc FATE-test. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo_dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c index 5b37e79e36..6d1edc027a 100644 --- a/libavcodec/mpegvideo_dec.c +++ b/libavcodec/mpegvideo_dec.c @@ -446,8 +446,8 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx) if (s->picture_structure != PICT_FRAME) { for (int i = 0; i < 4; i++) { if (s->picture_structure == PICT_BOTTOM_FIELD) { - s->current_picture.f->data[i] += - s->current_picture.f->linesize[i]; + s->current_picture.f->data[i] = FF_PTR_ADD(s->current_picture.f->data[i], + s->current_picture.f->linesize[i]); } s->current_picture.f->linesize[i] *= 2; s->last_picture.f->linesize[i] *= 2;