From patchwork Sun Apr 7 21:09:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 47907 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp2147379pzd; Sun, 7 Apr 2024 14:11:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX+zemBQvPWIzvNMYfxOSY8eWX+Yi2CbaXrTWnKCBQvNd1XCxaFDTWvYt8ogtJOi6Vd+vEFcV106Bz6KojfKTptOGRswlwgaZQJDw== X-Google-Smtp-Source: AGHT+IEw7fB2k8gnN7h4FdxBORH8YGS2iGI60LSrWez2BQdX0dw4zLrMuuLI5h6tnzIPVg/SqLdq X-Received: by 2002:a17:906:6a1a:b0:a4e:4278:8a01 with SMTP id qw26-20020a1709066a1a00b00a4e42788a01mr6079612ejc.11.1712524287071; Sun, 07 Apr 2024 14:11:27 -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 dr20-20020a170907721400b00a4e8e3cef51si3105517ejc.236.2024.04.07.14.11.26; Sun, 07 Apr 2024 14:11:27 -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=iu52gS1r; 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 CC2A668D292; Mon, 8 Apr 2024 00:10:01 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01olkn2043.outbound.protection.outlook.com [40.92.64.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C5DEA68D1FC for ; Mon, 8 Apr 2024 00:09:50 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GzpVufFVdN8SPM0gGf+BVjJ0osmBbFJ9p6UD+F6QFVnpj5q8qxXwLYsFxKb/sowd1pq6FEQ3cDXCCTWuRNYXWexlxFfxTRVJ1OSOLa9CDjVBfzZ6ngS6WmoJbYHd2+tlTmVOHc+sx+yesl+J4hqemJ5vsxQnU0bzvQsnxv6kMzC08ESwHHCXsZFeOs6SlOF3l0Yp0a/JhwntutppeXpBwN30+Vrp2RCL2RgxHs2yPmujfjX+KddK61vC/3vVCVgmc3wNkCiaRlM68ZrVuffLhlwSlKYwXrBRbJV4nZZ0z8SD7eBgwyQ82DZ88fgKK70X7OnRyjNKyMYL59QvJVHyEg== 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=EayljZj/HypV/+pY1T+jCxKRfgvciz2vhmSFjhphzis=; b=U5b55PflI9OPSpCUoFV85nyPyf5iVz+6djQf22NeNeQtn/5k4Kwh3p2Uwkr3kqBliOJ9qNLmKJcL5XtIXMV0+MaVK6uZo35cZ3cBH/K0wZgEP6vMlkGlnrRCkrK+UsyOhvv/Mn+zQ30Udvut70fx9QnYI/hhEpjSoXkJb5fx6sB6rbXZ/q3oKDxNDWTGKXXxodQ0a712x5ZBlwnVrRRahop7sgxJQEZQrPMinXK2At9PEyRkJ2ib8A2aU+RODuY9OPl19ECnsLaG6UNtLG5a1q6EsipJerYKiOdVFuiTvfZqq3q3y6EPCeYcwATJM4hfv3krsug4HgbOov0ygQGAdw== 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=EayljZj/HypV/+pY1T+jCxKRfgvciz2vhmSFjhphzis=; b=iu52gS1rn36qb1m3K6984aC4kj/zDqOL6Fv9jsw5g6TSRMLcBrTwU9mK/83keDUifFkxfotTcGdRVWDHUCOwbO6hynLuJMXQBg9nZdiZUDxIsxai5gs4HdP0tuDcbbpik4jpW+jx1Iuq4M7RGYtSXoW0QDUrzIX+cXW6vzca1M+anIY1UtaBO9tXQ/NJOs7BRhk/8saKYQc6sirRkNtlSudXKd1kzoT+oW9h3nnS+E60zBY+/DGWu3cLsmADJ4AXvvftD8i/CgJ0QV7ry9dmTjVTREGRUrKfMupvLKbDcWTYeKy/IZOXEp4oghyDvI2wZIb469xIRdwOrcbkDce1bw== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by AS8P250MB0234.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:379::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.55; Sun, 7 Apr 2024 21:09:45 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::4a3b:cf76:cddc:c68d]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::4a3b:cf76:cddc:c68d%4]) with mapi id 15.20.7409.042; Sun, 7 Apr 2024 21:09:45 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 7 Apr 2024 23:09:14 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [SVStuiAfzAOsNorFcMhaCNP7UfO3YeMiatJOHVdK7Ow=] X-ClientProxiedBy: ZR0P278CA0038.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::7) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20240407210915.895619-15-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|AS8P250MB0234:EE_ X-MS-Office365-Filtering-Correlation-Id: 0406d06c-0833-473b-23f1-08dc57470d24 X-MS-Exchange-SLBlob-MailProps: 9IecXKUgicDNEbE0encsoirT0ZUrgC9m66YWS3aH0G7UdId6l2jJGzSaJ6eA1yMszHnR5Z8zRi7BlXr5H0rTyuBeKZRXGt6w/lyMGqUaihVaqAckxqOMz9xqcVchLFnqpCf7XUBTgIigev2mAOv4/XHUBUvof2e081q1kgLARQoKZbwosXL3akRf884hvmVqcQdiegCQcVVsZLeW3UNfSzEdBYqpEOrN4oo60npHbKQzBaWQ7PniJiUxvk1DBA3O2skth6UAKSrp7PaUGiIDMX4/9oRVI2e21G+EVpDXqg4lF0niuJAH0zGSVYvds+ZwvRoyJnWUZpTQLO1uvkYqg2/68PgotDdd3qNR3aH4qp0woSpB52UIFVVYvcRZTpjvnj9Fv+UmzrcwrCgSAncOwu5vWpiDkeEw5YwOdvfKKXtdDxCXZcVDMQVbp+Fsiy9G8C5IRDHbUQLCLJP6HdzDgKQQwV7aHeYRd1b3kipApe1seASohBOQn11cnGiW4xpMQxkBhkh2Jf69qvug+l4sAi0x5lcsX/+sybq41Q11uLgUmr/nRfgfmuLGeIjmL/xhv+rkw/GpNdeM1N61RBeXYaX9dwZS+u4ZekdFRl9fzB9kqG9knreF6nCld9cTuBerNOiE39yUuXBTjqa1txrAjJr7dYL9XUKMCx0eXtmA0H0jMfUKozFp9pLHcP7UKhqRETw7qZlAmUCpjXMgHiLiYpwbN/gu+EvddbWNxbDHMamJR4B8LViwNg== X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tUVIojI0iOWBRtR+YRMpqc0izqZ47n6M6ezmiT2Nshgp26jeq0lc9g22yD1w6nBnYbTtC+hyMYuKpqoQBIhQNoas2Mk6PB0p/fIbQbUSAHwytji/hQQ2aIMfsTS0OVyhxpxJlf5gWeoV6DbrrBX93WsHTzlKK7Xy3QFIg13v5W7vhFAh1NoaMZPFgQESGfmIUvo3ISfgdHX2N7HOC4QZBiubfT6EmdGH4Toj4VNs5fyuGrvonjlD+juyoS+GJPkeXMMNnm1jsMYamVvawByW8EX1xP4BKklb4GFSV6xUZX4QyQ6rGbv2UYwX+QVKtS80loJLPDTPmM3vb2PQKdDwuNybpc37VTBq6JO2glhKumzmZCllMz5jJnDPnBAAypBsg4c9m+6i9UvMdM4KkLBblbEKWy9nK2ga0RRIYvxSbaV/y5uSUCFHmqzZFfRuOQkmXBiliCY1OJC9eVaVcq5bhhmUirMsWrC4NZzQUXmka4heuAzSbM+BQO9FGdNce9HOpDQKpA+dC+3CTRCXw/63u5NuzcJX0Z3TX7uWYDdgMr8CF5AOs2kSi5LxpRSp5467QlyEGNKwdV6+vG7Mzi8oFi7fjHJqPKREatfN52Y8eaSv3JxINxMUxwYW/Hk6McQW X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rE2YHtQJLXcHeByR/HAGm2egoC2iOCzb/F7tcIvIJ3iiPZkSiqlSdZyEAqjfW+7WNd63IY8LNlmVN97RVE1+5xcELtlZ7KHP3wNnwCfKQPDg73kRpGCEYcV06Qd7N3Z5cnGNXikHRBdjlQCY7kTcGaufzS/JHq1QhbBYdXtVG6H0FjbLU3xZIk3607oLb9Y8aymk/OUT/ojORWIzEzBrAg2J3a+N3JW//Rm5n9wHFpvBlv0NYCILjymxjfEXu9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-MS-Exchange-CrossTenant-Network-Message-Id: 0406d06c-0833-473b-23f1-08dc57470d24 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Apr 2024 21:09:45.6189 (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: AS8P250MB0234 Subject: [FFmpeg-devel] [PATCH 16/17] avcodec/flacenc: Avoid shift 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: wrlPIJbPip/X Signed-off-by: Andreas Rheinhardt --- libavcodec/flacenc.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index e29be5822b..3a9578f5cd 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -525,11 +525,10 @@ static void copy_samples(FlacEncodeContext *s, const void *samples) { int i, j, ch; FlacFrame *frame; - int shift = av_get_bytes_per_sample(s->avctx->sample_fmt) * 8 - - s->avctx->bits_per_raw_sample; -#define COPY_SAMPLES(bits) do { \ +#define COPY_SAMPLES(bits, shift0) do { \ const int ## bits ## _t *samples0 = samples; \ + const int shift = shift0; \ frame = &s->frame; \ for (i = 0, j = 0; i < frame->blocksize; i++) \ for (ch = 0; ch < s->channels; ch++, j++) \ @@ -537,9 +536,9 @@ static void copy_samples(FlacEncodeContext *s, const void *samples) } while (0) if (s->avctx->sample_fmt == AV_SAMPLE_FMT_S16) - COPY_SAMPLES(16); + COPY_SAMPLES(16, 0); else - COPY_SAMPLES(32); + COPY_SAMPLES(32, 32 - s->avctx->bits_per_raw_sample); }