From patchwork Tue Dec 27 22:41:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 39763 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp3744817pzb; Tue, 27 Dec 2022 14:41:47 -0800 (PST) X-Google-Smtp-Source: AMrXdXtYJMBjTsexcDbl83msO6Q4AaRFsKTLNAulnD7ki/Pj9z1AiFJ7lIcz3OV1H1Olib2gLav/ X-Received: by 2002:a17:906:6bc7:b0:7c1:1bc:7fd4 with SMTP id t7-20020a1709066bc700b007c101bc7fd4mr22205670ejs.42.1672180907338; Tue, 27 Dec 2022 14:41:47 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z10-20020a50cd0a000000b0046bdaa564bdsi11427099edi.419.2022.12.27.14.41.46; Tue, 27 Dec 2022 14:41:47 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=kM8SWR9l; 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 D5E4068BC1B; Wed, 28 Dec 2022 00:41:43 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01olkn2040.outbound.protection.outlook.com [40.92.64.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 43BC868BC1B for ; Wed, 28 Dec 2022 00:41:37 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fpp+gSONe1awjZguF69YsBFyX/FbauRSRK/9d14ogqZ/JauYoH8ceCrnWxcTJmdlMwj+i2Eaq6oxQOLXBX6DsG/nUfvPNrj41p2NcmPyzTqbYHWlQrpfVMTPbJIia+c5jzFFK7MYi7zrwd0LKz4i0gWPMEhkcunydijI/aPRKwyzk0Paq1UsOCpsPSxTq8Wct1CGaPv0bABg5JMFKbrA4gQo7IZepwCtbmwehvTyS5AsREron6yxFXpiJsIDDfhRQ14nrGOGUpjgK3HRvQ524qfgpHCUFXUxVsiHziwEncl/Jysrp+wCZwzdg2Cm25Pyh+BGKh9rFG9Xbt/2P9XKxQ== 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=KVWgYj1UIilvf79EfNNUPOIpANPaZKzeuS9/2VGYrPw=; b=ds4DhdhOCzlICUNWgJ04uv0+FXbbRa+uKLievqm+jyjj2ToJepqKzOIm4U62hAw/+/kkpwEqslGAmBEpMRUVVGGHy8rqYHBkvaCV4At/J6PYfZQfOO/gjUcYNYVZsGijD5DbFxnkG1DBDi4zmJiV42lWBl/Vo2pkWteXRV9d4ETnH6ys8b6XVJ35wKqfC1E5b0nZmU4D9jbG4ioQPPGlrXQmwyC7LreltpNK544bUNqtZbliLlhrAYTFzoniZqAG+C/Ul7hF0KvW2v//0UfhBgOtLTGORjleUsa9g+Y7lDD6JrnbXht9LQywDAsrJEiPrujCQJUAKe85V93tU7l1gg== 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=KVWgYj1UIilvf79EfNNUPOIpANPaZKzeuS9/2VGYrPw=; b=kM8SWR9l5q+U+tC4QuAurPVAF7jaeDhuoN1uRKVW6UdH947qSUEer4S7zHurZ0Okff9BQ8R8I3WCtD3AMCLmHIAgzbz2BLjUVJ/tOpu4isqJX5iwXcwcXaYZEtYtLbCbqy3i1kciPkKcW7l3llxMqBA4yqllJWeEfhxq7i7+geq4UJHrw8+gc0fVTTyjEtagWDvJMAZv6p5NB9iB5E56fTly793hT859j2++zTwgkKZDn+9jyQQmSuYnsoaOX+08gdD5/SUnbvOL2JwdF0WP0KqPoJgub5dVUbhMZwLD1Ld0E5dnBTJKJzbQ5IcljW78Ccy3qHVQg3w+DaLmXEFXYQ== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by AM8P250MB0139.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:322::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.16; Tue, 27 Dec 2022 22:41:35 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::da14:61e3:630a:70b5]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::da14:61e3:630a:70b5%8]) with mapi id 15.20.5944.016; Tue, 27 Dec 2022 22:41:35 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 27 Dec 2022 23:41:49 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 X-TMN: [f17Zi4AKgo03hJLbX9zUSxbxGGM0HY3G] X-ClientProxiedBy: ZR0P278CA0104.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:23::19) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20221227224151.1179314-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|AM8P250MB0139:EE_ X-MS-Office365-Filtering-Correlation-Id: afc4e0fe-aaa4-4fca-4f07-08dae85b823a X-MS-Exchange-SLBlob-MailProps: 3QTjV0QDnj+nkzm7U0N/h0uMUY8qE9v2CZnFlhCw4mMi9bfk5WMKn6dv43utLyJzRXF3IbYSLMFwFbEBL2qDyQOpgP/bDM3LL+j5X65DfjV2sqvPzeI0cQWyS1AyokXnxDLRTMNzfZCtGXQgMksn99itCY6NJOXEZDQy1Q0ptw3qgxl2j9m8Q0AV1nmX5IfO4OYIqC8hCOkFovj3ajsW/DYu3g0JCVE63+CLci54uj3E8GjLkk1LV+RWxmxqPKeqGQz1v+hM7ceZGlDiI6d47y8+Zpzpza+jPHKNx0Q4HF30lxxUbTZ7ARtRKtKDZ/zjjnHoX1EHWs1qzdxEqBko8qdwhW6Z4UYy9lwcOF3pVx5vomA2Nlixv9Bq6IDlGokkabHJ3OzCNuoghrhTY8HvDvGkIPANjq0D0p4+glUxRoqqEfX8/uwNE/4JvzfFlwhNQpfBe6LyNEpWFC+PKm9pKn7aba32o3kH4CnAwXmY2yWLcFt+PhBrz4BzxjeMrixD/HpTK0Mj/jL32hJu32pHkdLhGjr0CZmyYr7krIcLOtOsHmiLyvZviCsmbmaLe9kwFp6Hph/GSiv6r+iEfgB3UNW77ELSxst5aRD02BSAujSCixkoK/6D9cYuf58m15YBOUjbDFsd+Zze7u9JAS3bzt6siLfKHkgMYUPHoYXK1jNg3oZ2JghJMUf88MlTd72Mzqce2+InkxRDeBLQW7hCx/MyVfenoLoMM1UGpXsbu9IYwij6R76Mku1fFLSl00rg9pSpL9VhvWMCRkdolJkmaXX3iR/ZcvDv04LchlptikCYPFaOi7JbFMmGtgTajTiD99J+X8ZwgQPUo8a3Ze+SSJI356WmsIHRlEzgWtzFypzclX8RyWWGfw== X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WQVois17Te0gWcCpqjE/C9uGawhQBZBOALel76uZzOWHvfkn5bVH6BhiCUYZxCWeHwT/N8Mb2gkAMcCeioK+yiEAouP6il96r+mloyaV/ghbgEkqlgBX4Rlt1b1FPNvYEC9sXGELkOtQTV4djnHsRIW3befFgoG20OZHmh2vXljW4dntrhBwMC/+47k7lkFMFXL82o/7T+fsF9V8i4pZoUC6pUK1P47fNMs7y3TKUjAlDsbKyQK9IQrpGfD1hR0/JYYkmiWjnF7xJj3+7P9e5LYW+K3xyOBV6bLghXlkqhaw/nAjBmtckL8IMQFjLPenTex3e/IkgokVwCgl0NXbOtrY24dBTKaTXvjHGj0OjUYipQVkA7QjK3ESKnGqB4DQxOV/MrwaE29uK/PBL4gnR5hGFzyhgvt2kLs+IvHP73gIiqoFkvHAEpdeYRnOrddBAB2uJCiiwtQIxwH3vB+oD07711aHaAp/qcRFTy8h2GIhJPOHwh/f0i2TqTbSELzpxJAdjfnMR3DXzFEi4j208LfBdezOZceiH8pldR1g73n8gXx8lYakgLdufBKIKOpQglHb9YmrPPXTj3aqtk/F2fOCy/Lm/qWxuymTW7C+6m1IfyuDWwJFRN0ri7ojKedgyAYJXAzmR7WcZDk6fOmeEjK2+eTTNBufhyeJAjkQmLY= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GfDKmCIDW5NOL4eJACs+SP2ZEhXL+CwyfP1DUshL1bNRgzPFIXNv4uEBJp0yyxCI0JWGXY9DxN20uLQ+xpOG3TBEylw78gDVEETKKsYvRq7FvgxtzR72e5J4H2/em4J1D/ZwrewyC/WYTbmwYBKOuWAU3SvaP8AiecAf3y8gmF7l9J2GhuSt9OdJaDoMdBOSa6NicJQRSX0AZeX3IJHGKMeqGvpWWUsLZvNfcv9fcf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4= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: afc4e0fe-aaa4-4fca-4f07-08dae85b823a X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Dec 2022 22:41:35.3373 (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: AM8P250MB0139 Subject: [FFmpeg-devel] [PATCH 1/3] avcodec/bswapdsp: Don't presume src to be naturally aligned 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: /94wmCI+kkJp src typically comes from AVPackets and AVPacket.data has no alignment requirement. This means that the casts to uint32_t* might be undefined behaviour (they are if the pointer is no suitably aligned) and that the C versions of the conversion functions presume too much alignment; I don't know whether the same is true for the riscv asm. Fix this by using const void* for src. Signed-off-by: Andreas Rheinhardt --- Would be nice if someone could actually check whether riscv presumes alignment. libavcodec/4xm.c | 2 +- libavcodec/ac3dec.c | 2 +- libavcodec/alsdec.c | 2 +- libavcodec/apedec.c | 2 +- libavcodec/asvdec.c | 2 +- libavcodec/asvenc.c | 2 +- libavcodec/bswapdsp.c | 37 ++++++++++++++++++-------------- libavcodec/bswapdsp.h | 4 ++-- libavcodec/cllc.c | 2 +- libavcodec/eamad.c | 2 +- libavcodec/eatqi.c | 3 +-- libavcodec/flacenc.c | 2 +- libavcodec/fraps.c | 3 +-- libavcodec/hevcdec.c | 3 +-- libavcodec/huffyuvdec.c | 2 +- libavcodec/huffyuvenc.c | 2 +- libavcodec/imc.c | 2 +- libavcodec/imm4.c | 3 +-- libavcodec/mdec.c | 2 +- libavcodec/mimic.c | 2 +- libavcodec/mobiclip.c | 3 +-- libavcodec/motionpixels.c | 3 +-- libavcodec/rawdec.c | 4 ++-- libavcodec/riscv/bswapdsp_init.c | 6 +++--- libavcodec/shorten.c | 2 +- libavcodec/truemotion2.c | 3 +-- libavcodec/truespeech.c | 2 +- libavcodec/utvideodec.c | 2 +- libavcodec/utvideoenc.c | 3 +-- libavcodec/x86/bswapdsp.asm | 2 +- libavcodec/x86/bswapdsp_init.c | 6 +++--- libavcodec/ylc.c | 2 +- 32 files changed, 58 insertions(+), 61 deletions(-) diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c index 5636fdef2d..5708888011 100644 --- a/libavcodec/4xm.c +++ b/libavcodec/4xm.c @@ -813,7 +813,7 @@ static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length) prestream_size); if (!f->bitstream_buffer) return AVERROR(ENOMEM); - f->bbdsp.bswap_buf(f->bitstream_buffer, (const uint32_t *) prestream, + f->bbdsp.bswap_buf(f->bitstream_buffer, prestream, prestream_size / 4); init_get_bits(&f->pre_gb, f->bitstream_buffer, 8 * prestream_size); diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index 1f2949dcfd..8c7cd547bf 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -1524,7 +1524,7 @@ static int ac3_decode_frame(AVCodecContext *avctx, AVFrame *frame, // seems to be byte-swapped AC-3 int cnt = FFMIN(buf_size, AC3_FRAME_BUFFER_SIZE) >> 1; s->bdsp.bswap16_buf((uint16_t *) s->input_buffer, - (const uint16_t *) buf, cnt); + buf, cnt); } else memcpy(s->input_buffer, buf, FFMIN(buf_size, AC3_FRAME_BUFFER_SIZE)); diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c index 4605b2248f..16d6d18895 100644 --- a/libavcodec/alsdec.c +++ b/libavcodec/alsdec.c @@ -1900,7 +1900,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, *dest++ = av_bswap16(src[sample]); } else { ctx->bdsp.bswap_buf((uint32_t *) ctx->crc_buffer, - (uint32_t *) frame->data[0], + frame->data[0], ctx->cur_frame_length * channels); } crc_source = ctx->crc_buffer; diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c index c08d13d6c2..49f27ab2c1 100644 --- a/libavcodec/apedec.c +++ b/libavcodec/apedec.c @@ -1499,7 +1499,7 @@ static int ape_decode_frame(AVCodecContext *avctx, AVFrame *frame, av_fast_padded_malloc(&s->data, &s->data_size, buf_size); if (!s->data) return AVERROR(ENOMEM); - s->bdsp.bswap_buf((uint32_t *) s->data, (const uint32_t *) buf, + s->bdsp.bswap_buf((uint32_t *) s->data, buf, buf_size >> 2); memset(s->data + (buf_size & ~3), 0, buf_size & 3); s->ptr = s->data; diff --git a/libavcodec/asvdec.c b/libavcodec/asvdec.c index 699aab9f8f..f5b5800100 100644 --- a/libavcodec/asvdec.c +++ b/libavcodec/asvdec.c @@ -254,7 +254,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p, return AVERROR(ENOMEM); c->bbdsp.bswap_buf((uint32_t *) a->bitstream_buffer, - (const uint32_t *) buf, buf_size / 4); + buf, buf_size / 4); ret = init_get_bits8(&a->gb, a->bitstream_buffer, buf_size); } else { ret = init_get_bits8_le(&a->gb, buf, buf_size); diff --git a/libavcodec/asvenc.c b/libavcodec/asvenc.c index 9da7cbb986..2845ac913c 100644 --- a/libavcodec/asvenc.c +++ b/libavcodec/asvenc.c @@ -310,7 +310,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, if (avctx->codec_id == AV_CODEC_ID_ASV1) { c->bbdsp.bswap_buf((uint32_t *) pkt->data, - (uint32_t *) pkt->data, size); + pkt->data, size); } pkt->size = size * 4; diff --git a/libavcodec/bswapdsp.c b/libavcodec/bswapdsp.c index f0ea2b55c5..ebcdc1fd9b 100644 --- a/libavcodec/bswapdsp.c +++ b/libavcodec/bswapdsp.c @@ -20,30 +20,35 @@ #include "libavutil/attributes.h" #include "libavutil/bswap.h" +#include "libavutil/intreadwrite.h" #include "bswapdsp.h" -static void bswap_buf(uint32_t *dst, const uint32_t *src, int w) +static void bswap_buf(uint32_t *dst, const void *src_, int w) { - int i; + const unsigned char *src = src_; + uint32_t *const end = dst + w, *end2 = dst + (w & ~7); - for (i = 0; i + 8 <= w; i += 8) { - dst[i + 0] = av_bswap32(src[i + 0]); - dst[i + 1] = av_bswap32(src[i + 1]); - dst[i + 2] = av_bswap32(src[i + 2]); - dst[i + 3] = av_bswap32(src[i + 3]); - dst[i + 4] = av_bswap32(src[i + 4]); - dst[i + 5] = av_bswap32(src[i + 5]); - dst[i + 6] = av_bswap32(src[i + 6]); - dst[i + 7] = av_bswap32(src[i + 7]); + for (; dst < end2; dst += 8, src += 8 * 4) { + dst[0] = av_bswap32(AV_RN32(src)); + dst[1] = av_bswap32(AV_RN32(src + 4)); + dst[2] = av_bswap32(AV_RN32(src + 8)); + dst[3] = av_bswap32(AV_RN32(src + 12)); + dst[4] = av_bswap32(AV_RN32(src + 16)); + dst[5] = av_bswap32(AV_RN32(src + 20)); + dst[6] = av_bswap32(AV_RN32(src + 24)); + dst[7] = av_bswap32(AV_RN32(src + 28)); } - for (; i < w; i++) - dst[i + 0] = av_bswap32(src[i + 0]); + for (; dst < end; dst++, src += 4) + dst[0] = av_bswap32(AV_RN32(src)); } -static void bswap16_buf(uint16_t *dst, const uint16_t *src, int len) +static void bswap16_buf(uint16_t *dst, const void *src_, int len) { - while (len--) - *dst++ = av_bswap16(*src++); + const unsigned char *src = src_; + while (len--) { + *dst++ = av_bswap16(AV_RN16(src)); + src += 2; + } } av_cold void ff_bswapdsp_init(BswapDSPContext *c) diff --git a/libavcodec/bswapdsp.h b/libavcodec/bswapdsp.h index 6f4db66115..a5b1fd38bf 100644 --- a/libavcodec/bswapdsp.h +++ b/libavcodec/bswapdsp.h @@ -22,8 +22,8 @@ #include typedef struct BswapDSPContext { - void (*bswap_buf)(uint32_t *dst, const uint32_t *src, int w); - void (*bswap16_buf)(uint16_t *dst, const uint16_t *src, int len); + void (*bswap_buf)(uint32_t *dst, const void *src, int w); + void (*bswap16_buf)(uint16_t *dst, const void *src, int len); } BswapDSPContext; void ff_bswapdsp_init(BswapDSPContext *c); diff --git a/libavcodec/cllc.c b/libavcodec/cllc.c index 911717b68d..eef2506936 100644 --- a/libavcodec/cllc.c +++ b/libavcodec/cllc.c @@ -397,7 +397,7 @@ static int cllc_decode_frame(AVCodecContext *avctx, AVFrame *pic, } /* bswap16 the buffer since CLLC's bitreader works in 16-bit words */ - ctx->bdsp.bswap16_buf((uint16_t *) ctx->swapped_buf, (uint16_t *) src, + ctx->bdsp.bswap16_buf((uint16_t *) ctx->swapped_buf, src, data_size / 2); if ((ret = init_get_bits8(&gb, ctx->swapped_buf, data_size)) < 0) diff --git a/libavcodec/eamad.c b/libavcodec/eamad.c index 45012c62b8..51b34dd61e 100644 --- a/libavcodec/eamad.c +++ b/libavcodec/eamad.c @@ -304,7 +304,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, bytestream2_get_bytes_left(&gb)); if (!s->bitstream_buf) return AVERROR(ENOMEM); - s->bbdsp.bswap16_buf(s->bitstream_buf, (const uint16_t *)(buf + bytestream2_tell(&gb)), + s->bbdsp.bswap16_buf(s->bitstream_buf, buf + bytestream2_tell(&gb), bytestream2_get_bytes_left(&gb) / 2); memset((uint8_t*)s->bitstream_buf + bytestream2_get_bytes_left(&gb), 0, AV_INPUT_BUFFER_PADDING_SIZE); init_get_bits(&s->gb, s->bitstream_buf, 8*(bytestream2_get_bytes_left(&gb))); diff --git a/libavcodec/eatqi.c b/libavcodec/eatqi.c index e4f12b3db2..f9a5f9ae39 100644 --- a/libavcodec/eatqi.c +++ b/libavcodec/eatqi.c @@ -148,8 +148,7 @@ static int tqi_decode_frame(AVCodecContext *avctx, AVFrame *frame, buf_end - buf); if (!t->bitstream_buf) return AVERROR(ENOMEM); - t->bsdsp.bswap_buf(t->bitstream_buf, (const uint32_t *) buf, - (buf_end - buf) / 4); + t->bsdsp.bswap_buf(t->bitstream_buf, buf, (buf_end - buf) / 4); init_get_bits(&t->gb, t->bitstream_buf, 8 * (buf_end - buf)); t->last_dc[0] = diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index 8aacc93e28..bf5d12facb 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -1587,7 +1587,7 @@ static int update_md5_sum(FlacEncodeContext *s, const void *samples) buf = (const uint8_t *)samples; #if HAVE_BIGENDIAN s->bdsp.bswap16_buf((uint16_t *) s->md5_buffer, - (const uint16_t *) samples, buf_size / 2); + samples, buf_size / 2); buf = s->md5_buffer; #endif } else if (s->avctx->bits_per_raw_sample <= 24) { diff --git a/libavcodec/fraps.c b/libavcodec/fraps.c index 4c4c46b602..2f3365eca8 100644 --- a/libavcodec/fraps.c +++ b/libavcodec/fraps.c @@ -106,8 +106,7 @@ static int fraps2_decode_plane(FrapsContext *s, uint8_t *dst, int stride, int w, /* we have built Huffman table and are ready to decode plane */ /* convert bits so they may be used by standard bitreader */ - s->bdsp.bswap_buf((uint32_t *) s->tmpbuf, - (const uint32_t *) src, size >> 2); + s->bdsp.bswap_buf((uint32_t *) s->tmpbuf, src, size >> 2); if ((ret = init_get_bits8(&gb, s->tmpbuf, size)) < 0) return ret; diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 567e8d81d4..32f1525349 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -3274,8 +3274,7 @@ static int verify_md5(HEVCContext *s, AVFrame *frame) const uint8_t *src = frame->data[i] + j * frame->linesize[i]; #if HAVE_BIGENDIAN if (pixel_shift) { - s->bdsp.bswap16_buf((uint16_t *) s->checksum_buf, - (const uint16_t *) src, w); + s->bdsp.bswap16_buf((uint16_t *) s->checksum_buf, src, w); src = s->checksum_buf; } #endif diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c index 7d3515cc88..670f26d263 100644 --- a/libavcodec/huffyuvdec.c +++ b/libavcodec/huffyuvdec.c @@ -1240,7 +1240,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p, return AVERROR(ENOMEM); s->bdsp.bswap_buf((uint32_t *) s->bitstream_buffer, - (const uint32_t *) buf, buf_size / 4); + buf, buf_size / 4); if ((ret = ff_thread_get_buffer(avctx, p, 0)) < 0) return ret; diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c index db274e37ad..b5ed991d11 100644 --- a/libavcodec/huffyuvenc.c +++ b/libavcodec/huffyuvenc.c @@ -1018,7 +1018,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, avctx->stats_out[0] = '\0'; if (!(s->avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT)) { flush_put_bits(&s->pb); - s->bdsp.bswap_buf((uint32_t *) pkt->data, (uint32_t *) pkt->data, size); + s->bdsp.bswap_buf((uint32_t *) pkt->data, pkt->data, size); } s->picture_number++; diff --git a/libavcodec/imc.c b/libavcodec/imc.c index 174332de4d..365ec08601 100644 --- a/libavcodec/imc.c +++ b/libavcodec/imc.c @@ -986,7 +986,7 @@ static int imc_decode_frame(AVCodecContext *avctx, AVFrame *frame, for (i = 0; i < avctx->ch_layout.nb_channels; i++) { q->out_samples = (float *)frame->extended_data[i]; - q->bdsp.bswap16_buf(buf16, (const uint16_t *) buf, IMC_BLOCK_SIZE / 2); + q->bdsp.bswap16_buf(buf16, buf, IMC_BLOCK_SIZE / 2); init_get_bits(&q->gb, (const uint8_t*)buf16, IMC_BLOCK_SIZE * 8); diff --git a/libavcodec/imm4.c b/libavcodec/imm4.c index ccec5dff43..72c5cb8b64 100644 --- a/libavcodec/imm4.c +++ b/libavcodec/imm4.c @@ -369,8 +369,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, return AVERROR(ENOMEM); s->bdsp.bswap_buf((uint32_t *)s->bitstream, - (uint32_t *)avpkt->data, - (avpkt->size + 3) >> 2); + avpkt->data, (avpkt->size + 3) >> 2); if ((ret = init_get_bits8(gb, s->bitstream, FFALIGN(avpkt->size, 4))) < 0) return ret; diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c index 640b671a0f..0538b4362f 100644 --- a/libavcodec/mdec.c +++ b/libavcodec/mdec.c @@ -182,7 +182,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, av_fast_padded_malloc(&a->bitstream_buffer, &a->bitstream_buffer_size, buf_size); if (!a->bitstream_buffer) return AVERROR(ENOMEM); - a->bbdsp.bswap16_buf((uint16_t *)a->bitstream_buffer, (uint16_t *)buf, (buf_size + 1) / 2); + a->bbdsp.bswap16_buf((uint16_t *)a->bitstream_buffer, buf, (buf_size + 1) / 2); if ((ret = init_get_bits8(&a->gb, a->bitstream_buffer, buf_size)) < 0) return ret; diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c index 891471b30e..167673a8fe 100644 --- a/libavcodec/mimic.c +++ b/libavcodec/mimic.c @@ -412,7 +412,7 @@ static int mimic_decode_frame(AVCodecContext *avctx, AVFrame *rframe, return AVERROR(ENOMEM); ctx->bbdsp.bswap_buf(ctx->swap_buf, - (const uint32_t *) (buf + MIMIC_HEADER_SIZE), + buf + MIMIC_HEADER_SIZE, swap_buf_size >> 2); init_get_bits(&ctx->gb, ctx->swap_buf, swap_buf_size << 3); diff --git a/libavcodec/mobiclip.c b/libavcodec/mobiclip.c index c3b2383dbc..2197760266 100644 --- a/libavcodec/mobiclip.c +++ b/libavcodec/mobiclip.c @@ -1226,8 +1226,7 @@ static int mobiclip_decode(AVCodecContext *avctx, AVFrame *rframe, return ret; s->bdsp.bswap16_buf((uint16_t *)s->bitstream, - (uint16_t *)pkt->data, - (pkt->size + 1) >> 1); + pkt->data, (pkt->size + 1) >> 1); ret = init_get_bits8(gb, s->bitstream, FFALIGN(pkt->size, 2)); if (ret < 0) diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c index 4141c5a495..9eed773ad5 100644 --- a/libavcodec/motionpixels.c +++ b/libavcodec/motionpixels.c @@ -294,8 +294,7 @@ static int mp_decode_frame(AVCodecContext *avctx, AVFrame *rframe, av_fast_padded_malloc(&mp->bswapbuf, &mp->bswapbuf_size, buf_size); if (!mp->bswapbuf) return AVERROR(ENOMEM); - mp->bdsp.bswap_buf((uint32_t *) mp->bswapbuf, (const uint32_t *) buf, - buf_size / 4); + mp->bdsp.bswap_buf((uint32_t *) mp->bswapbuf, buf, buf_size / 4); if (buf_size & 3) memcpy(mp->bswapbuf + (buf_size & ~3), buf + (buf_size & ~3), buf_size & 3); init_get_bits(&gb, mp->bswapbuf, buf_size * 8); diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c index c20c317fed..40500a55a0 100644 --- a/libavcodec/rawdec.c +++ b/libavcodec/rawdec.c @@ -319,9 +319,9 @@ static int raw_decode(AVCodecContext *avctx, AVFrame *frame, if (!context->bitstream_buf) return AVERROR(ENOMEM); if (swap == 16) - context->bbdsp.bswap16_buf(context->bitstream_buf, (const uint16_t*)buf, buf_size / 2); + context->bbdsp.bswap16_buf(context->bitstream_buf, buf, buf_size / 2); else if (swap == 32) - context->bbdsp.bswap_buf(context->bitstream_buf, (const uint32_t*)buf, buf_size / 4); + context->bbdsp.bswap_buf(context->bitstream_buf, buf, buf_size / 4); else return AVERROR_INVALIDDATA; buf = context->bitstream_buf; diff --git a/libavcodec/riscv/bswapdsp_init.c b/libavcodec/riscv/bswapdsp_init.c index abe84ec1f7..d0089d3cc1 100644 --- a/libavcodec/riscv/bswapdsp_init.c +++ b/libavcodec/riscv/bswapdsp_init.c @@ -25,9 +25,9 @@ #include "libavutil/cpu.h" #include "libavcodec/bswapdsp.h" -void ff_bswap32_buf_rvb(uint32_t *dst, const uint32_t *src, int len); -void ff_bswap32_buf_rvv(uint32_t *dst, const uint32_t *src, int len); -void ff_bswap16_buf_rvv(uint16_t *dst, const uint16_t *src, int len); +void ff_bswap32_buf_rvb(uint32_t *dst, const void *src, int len); +void ff_bswap32_buf_rvv(uint32_t *dst, const void *src, int len); +void ff_bswap16_buf_rvv(uint16_t *dst, const void *src, int len); av_cold void ff_bswapdsp_init_riscv(BswapDSPContext *c) { diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c index 1b2abd76b1..3c13694ea6 100644 --- a/libavcodec/shorten.c +++ b/libavcodec/shorten.c @@ -758,7 +758,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, AVFrame *frame, } if (s->swap && s->internal_ftype != TYPE_U8) s->bdsp.bswap16_buf(((uint16_t **)frame->extended_data)[chan], - ((uint16_t **)frame->extended_data)[chan], + frame->extended_data[chan], s->blocksize); } diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c index b168b9cda1..02776f287c 100644 --- a/libavcodec/truemotion2.c +++ b/libavcodec/truemotion2.c @@ -907,8 +907,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, if ((ret = ff_reget_buffer(avctx, p, 0)) < 0) return ret; - l->bdsp.bswap_buf((uint32_t *) l->buffer, (const uint32_t *) buf, - buf_size >> 2); + l->bdsp.bswap_buf((uint32_t *) l->buffer, buf, buf_size >> 2); if ((ret = tm2_read_header(l, l->buffer)) < 0) { return ret; diff --git a/libavcodec/truespeech.c b/libavcodec/truespeech.c index 454121cc75..574a427239 100644 --- a/libavcodec/truespeech.c +++ b/libavcodec/truespeech.c @@ -82,7 +82,7 @@ static void truespeech_read_frame(TSContext *dec, const uint8_t *input) { GetBitContext gb; - dec->bdsp.bswap_buf((uint32_t *) dec->buffer, (const uint32_t *) input, 8); + dec->bdsp.bswap_buf((uint32_t *) dec->buffer, input, 8); init_get_bits(&gb, dec->buffer, 32 * 8); dec->vector[7] = ts_codebook[7][get_bits(&gb, 3)]; diff --git a/libavcodec/utvideodec.c b/libavcodec/utvideodec.c index 83120d1b22..85ff19dd9e 100644 --- a/libavcodec/utvideodec.c +++ b/libavcodec/utvideodec.c @@ -151,7 +151,7 @@ static int decode_plane10(UtvideoContext *c, int plane_no, memset(c->slice_bits + slice_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); c->bdsp.bswap_buf((uint32_t *) c->slice_bits, - (uint32_t *)(src + slice_data_start + c->slices * 4), + src + slice_data_start + c->slices * 4, (slice_data_end - slice_data_start + 3) >> 2); init_get_bits(&gb, c->slice_bits, slice_size * 8); diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c index d4388da8ba..2a3c50dd15 100644 --- a/libavcodec/utvideoenc.c +++ b/libavcodec/utvideoenc.c @@ -491,8 +491,7 @@ static int encode_plane(AVCodecContext *avctx, const uint8_t *src, /* Byteswap the written huffman codes */ c->bdsp.bswap_buf((uint32_t *) c->slice_bits, - (uint32_t *) c->slice_bits, - slice_len >> 2); + c->slice_bits, slice_len >> 2); /* Write the offset to the stream */ bytestream2_put_le32(pb, offset); diff --git a/libavcodec/x86/bswapdsp.asm b/libavcodec/x86/bswapdsp.asm index 31c6c48a21..16f4f8c032 100644 --- a/libavcodec/x86/bswapdsp.asm +++ b/libavcodec/x86/bswapdsp.asm @@ -99,7 +99,7 @@ SECTION .text add r0, 16 %endmacro -; void ff_bswap_buf(uint32_t *dst, const uint32_t *src, int w); +; void ff_bswap_buf(uint32_t *dst, const void *src, int w); %macro BSWAP32_BUF 0 %if cpuflag(ssse3)||cpuflag(avx2) cglobal bswap32_buf, 3,4,3 diff --git a/libavcodec/x86/bswapdsp_init.c b/libavcodec/x86/bswapdsp_init.c index 877bab1a2c..0f949033c5 100644 --- a/libavcodec/x86/bswapdsp_init.c +++ b/libavcodec/x86/bswapdsp_init.c @@ -23,9 +23,9 @@ #include "libavutil/x86/cpu.h" #include "libavcodec/bswapdsp.h" -void ff_bswap32_buf_sse2(uint32_t *dst, const uint32_t *src, int w); -void ff_bswap32_buf_ssse3(uint32_t *dst, const uint32_t *src, int w); -void ff_bswap32_buf_avx2(uint32_t *dst, const uint32_t *src, int w); +void ff_bswap32_buf_sse2(uint32_t *dst, const void *src, int w); +void ff_bswap32_buf_ssse3(uint32_t *dst, const void *src, int w); +void ff_bswap32_buf_avx2(uint32_t *dst, const void *src, int w); av_cold void ff_bswapdsp_init_x86(BswapDSPContext *c) { diff --git a/libavcodec/ylc.c b/libavcodec/ylc.c index 29c10f05da..d9cc7e33eb 100644 --- a/libavcodec/ylc.c +++ b/libavcodec/ylc.c @@ -312,7 +312,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p, memcpy(s->buffer, avpkt->data + toffset, boffset - toffset); memset(s->buffer + boffset - toffset, 0, AV_INPUT_BUFFER_PADDING_SIZE); s->bdsp.bswap_buf((uint32_t *) s->buffer, - (uint32_t *) s->buffer, + s->buffer, (boffset - toffset + 3) >> 2); if ((ret = init_get_bits8(&gb, s->buffer, boffset - toffset)) < 0) return ret; From patchwork Tue Dec 27 22:47:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 39764 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp3747646pzb; Tue, 27 Dec 2022 14:47:30 -0800 (PST) X-Google-Smtp-Source: AMrXdXtTYkCKWb1+zoe/EhPfzKSpdqDk5lYbfsIj2jARlwxdc5mCC42ngqGr3u5waVERVmzdzpoG X-Received: by 2002:a17:907:8312:b0:7c1:bb4:ea20 with SMTP id mq18-20020a170907831200b007c10bb4ea20mr18492612ejc.71.1672181250751; Tue, 27 Dec 2022 14:47:30 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id gb13-20020a170907960d00b007fcfcf3b89esi13552879ejc.368.2022.12.27.14.47.30; Tue, 27 Dec 2022 14:47:30 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=TakTEzzP; 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 6458F68BC58; Wed, 28 Dec 2022 00:47:28 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03olkn2080.outbound.protection.outlook.com [40.92.58.80]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0108368BC53 for ; Wed, 28 Dec 2022 00:47:21 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=grbSes2BmQDn9Bs7H5PL5yqmZefATbP7XyTXskVWYZ3N7l1BiyuEdoiI2n7HueGsma+tK6OG6fBqCfrW03Ce8IVq4WDO9hAxso96ZYGQXptEdeQj6Zj5HcU1qYL0ka9fpkJcideZmppw3HQvMqZQiJ3SfSMHkhzrOLeGXFNv0EKVJmk/4o8ScLuLPJ8qKaCkAUU4iFDiQ9BKGskw2dD5vR1PV0k4DnoBpGjbaVdpYN6UFO5vMI5NSZzRTwR1n7k/nt0+rFW16Uyos8ddf+uvT9W896W49Y7eMCtL+Sz7iI1xpTDfP7aF/ehDIJ5jpT9XwBOhOD7SYBvAwjv40qtrgw== 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=uLwY68lVJZrb9XwDiOJKUeD6Bf7yjk/RS7S3egE0FNA=; b=mMTgjIYn+RcPj/Jbn3P54Win1e2Pa5AeNlx7AhpLnS8UXH8HIsQzfZ8vkcPHFn/sLU2QXcmqauMYtc6DLgu0zyJWC2kEOTjRhuJOhBiCwrdlJfYbpzgHxeNSByUK3TIw0bTWdQAQm26lQJetgJwbKGISBeR/kJwTXPWV/1hJDVIzUBTbSqM+1kzjJl4S7Bwcal2/zZGm8FDqyWJKxcvbxPmoJ+vYHpBDBEnZ0pnN7OGEVUheo4ORSgD0J9Sc9zMhQPiEG/A8ab9he4OoNhbBcY/64xL4t6P5S0c1ZftDN27RSDJWZWxib4fY4qyK2FQyhJLGgXxysORzmxFH+aPOVQ== 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=uLwY68lVJZrb9XwDiOJKUeD6Bf7yjk/RS7S3egE0FNA=; b=TakTEzzPg2ilwDGr+1YJmdBckAuVmzbQqH0WdO+sEsaFRc82Mcir1w31T6wzEa1swcgXte5r2nz9VzC8W01Ny0ofRIUnMJlRkEhjf5FCUdfJmh6xBwDFEhCRBra+ReA9HXFkiB785cwQv4nip2TSLzEJe6pQIm2LYjIclwGSswVzfEVYQDY1qu3J/etx4iw2OtOkYQGObuJrLDeL1m3Q+2SN26Opd6wHtgQFsC6jcZU2HtbxGNV1oCl8od4Zn/ibbiKqvl7FO/o3fUhfaSBIrSShPwaSgtSzBq1uIrXElWkhyrHRTM+NO7FJrZZgg62Jd4pBfOXeX9m0IdFKZaqcVw== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by PR3P250MB0323.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:17e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.16; Tue, 27 Dec 2022 22:47:20 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::da14:61e3:630a:70b5]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::da14:61e3:630a:70b5%8]) with mapi id 15.20.5944.016; Tue, 27 Dec 2022 22:47:20 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 27 Dec 2022 23:47:38 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [xKOxQMz0mozJK68/CqyQr7V9nMCk7A7q] X-ClientProxiedBy: ZR0P278CA0057.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:21::8) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20221227224739.1181782-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|PR3P250MB0323:EE_ X-MS-Office365-Filtering-Correlation-Id: 3f0e60c5-12a2-4063-e412-08dae85c4fb9 X-MS-Exchange-SLBlob-MailProps: Vs63Iqe4sQmXpC4V5EEfPgtEeNpvWX9hzxmBkJ18muCg+cL0eMCH2TzmMNal5l8eYrtzqUllSgvgnfEvNUqb4ZLCs6hp9jZRwiKGIYXp0tAdjxJrMWX1uBqH5AvoSVUf94VZZSqj9lCDEz27gmqWG/f9t9mmK612oouLpbyL3SqgWHSJ1FnA9h1gyOqRnzo4VwB3afsDFm1PkldtgqPK/A4afJBu18u7U0mfbGsvD5yrdH0BqCYxAOBSDY+taMzqxCYTGL1uM+XIDoGn09Efiim6L3L1thEqCUPG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gj/tvDOM6L3kt2CJgnevw+pKhvm07TAoIzxbTLC5a20aFUnMOONIygrdDws/BqSgW5kvLAzP7hU26VSWI+Jmeo0w1UXhY6p175I9feHzPRmIKHJDEFIq4RgN07/JMlZ0b+NIrGArqNyT6BLouxdwXZU4GC2j5pOeYPAtQRD2veu6bGVPtd7c1hUThm+dd2QHdFl4MDDqfbwIMBTUKVNh4F6R+d5mlmKzvU7/9KuGT10fcj1UhfLRumgEG4B+iCpRkQubcWnVfSj01j8jiOP7W2EmFRflLDq72KA1z15X9fKod8K8aJ9gzpEJFzBAT4jYHlQYJls6caqrB5Y5VnxlvLbkJ2u6Bw0epPtSCP+foXsIPKnpodGJypEGjTTi6OM889eccg2Dp+yPqM7FQZwnpBtprEeN4m6UxvY28bWDlbqag5BpGnUarpk= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3f0e60c5-12a2-4063-e412-08dae85c4fb9 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Dec 2022 22:47:20.0595 (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: PR3P250MB0323 Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/flacenc: Don't copy buffer if avoidable 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: ZygU5iwmz55F It is avoidable for 32-bit FLAC on little endian hardware. Signed-off-by: Andreas Rheinhardt --- libavcodec/flacenc.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index bf5d12facb..adaaa77b79 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -1573,22 +1573,22 @@ static int write_frame(FlacEncodeContext *s, AVPacket *avpkt) static int update_md5_sum(FlacEncodeContext *s, const void *samples) { - const uint8_t *buf; + const uint8_t *buf = samples; int buf_size = s->frame.blocksize * s->channels * ((s->avctx->bits_per_raw_sample + 7) / 8); - if (s->avctx->bits_per_raw_sample > 16 || HAVE_BIGENDIAN) { + if (HAVE_BIGENDIAN || + s->avctx->bits_per_raw_sample > 16 && s->avctx->bits_per_raw_sample <= 24) { av_fast_malloc(&s->md5_buffer, &s->md5_buffer_size, buf_size); if (!s->md5_buffer) return AVERROR(ENOMEM); + buf = s->md5_buffer; } if (s->avctx->bits_per_raw_sample <= 16) { - buf = (const uint8_t *)samples; #if HAVE_BIGENDIAN s->bdsp.bswap16_buf((uint16_t *) s->md5_buffer, samples, buf_size / 2); - buf = s->md5_buffer; #endif } else if (s->avctx->bits_per_raw_sample <= 24) { int i; @@ -1599,16 +1599,12 @@ static int update_md5_sum(FlacEncodeContext *s, const void *samples) int32_t v = samples0[i] >> 8; AV_WL24(tmp + 3*i, v); } - buf = s->md5_buffer; } else { /* s->avctx->bits_per_raw_sample <= 32 */ - int i; - const int32_t *samples0 = samples; - uint8_t *tmp = s->md5_buffer; - - for (i = 0; i < s->frame.blocksize * s->channels; i++) - AV_WL32(tmp + 4*i, samples0[i]); - buf = s->md5_buffer; +#if HAVE_BIGENDIAN + s->bdsp.bswap_buf((uint32_t *) s->md5_buffer, + samples, s->frame.blocksize * s->channels); +#endif } av_md5_update(s->md5ctx, buf, buf_size); From patchwork Tue Dec 27 22:47:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 39765 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp3747743pzb; Tue, 27 Dec 2022 14:47:51 -0800 (PST) X-Google-Smtp-Source: AMrXdXtuSyE5roXePpoLKsRgW1jCCVuTTcOtzY0S4xrTNBuYd5rajy0m6THdaU7axxr0W/6hJu5Y X-Received: by 2002:a05:6402:d4e:b0:46f:9fa5:ec14 with SMTP id ec14-20020a0564020d4e00b0046f9fa5ec14mr17553208edb.35.1672181270737; Tue, 27 Dec 2022 14:47:50 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i15-20020a1709064fcf00b0084c6438e6bdsi3788730ejw.805.2022.12.27.14.47.50; Tue, 27 Dec 2022 14:47:50 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=SGutvEMX; 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 59BD068BC71; Wed, 28 Dec 2022 00:47:48 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03olkn2064.outbound.protection.outlook.com [40.92.58.64]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B830668BC68 for ; Wed, 28 Dec 2022 00:47:46 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T88rkuUFw+ohMuN7yIHOd1bfH1zbaq2tVF9rhmLENnfJ8/gPXa8cEOsKkSmYdwzvq40BwknkLLqaw4gyKonjspK9J0Bvmerd/XTrXfhooJILI5EMK0sl0dRw0u0iqItXQE+bUiFpgIqm497h52lne1zb/HB8fUw7aBB+N4iTzOV/QxJOCfao2+XmV3r758UYWHV2MujdrZbAswQZWuHYw+nDrvnhwI0l17GDFfj7hrnrdwsD8ypvbAieTDV8AOEQnkbfceHkZAhDST+i1ZHAKrq6NDBSFvunXLf/mIz1HTfQJ9HD7hCMM7NdZ7BKCjqAcr6DYoTZsVR6zCV6nmfRQA== 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=jq+CzQ/cmHhUD03/N/pksl5VbPcfDYrYvIETfCnhGIQ=; b=YHR9fw7NVEnR1c+aNc9UDoy5v3oNYbl/aKoUKQ95XqFF0qYZkT6TGyBu/Zwvv+OkHY8CC88ZvUmXalARXB+9jzkt2BhmlAGMX+1GZVR7mHInVO0lT5s0PHL7DS9eStG2IQPaoMnyMDdUXgSQkKJ1cECQ4Q7Ol+pPVtxhsuClK/2zwzI5ywrKQ7xUDus5CVIq6+kSm+uQ9o3opcyw4Lh5C4ihztGvPt9BXv4FJcTByHL1S7fMNb93tRNlWDWVvZ1NewxfLcgzT4QQI8/3SA2vMo9nbGlF8MXB+6oYk0JdTpVJ1zjSYF6kA4+twX80vlgScfOQo5M9C+QNfl5/ANUA2A== 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=jq+CzQ/cmHhUD03/N/pksl5VbPcfDYrYvIETfCnhGIQ=; b=SGutvEMXUligJOOACf/F90tWnbqB0/KCQ4FXMpAzvlVuFXb/FfJgaPYSf3ij7L2+J7E+96gwTjBJOGseqIDevsIesZZC548q6Af/Xxe0rY3sxNiEM1aLanAdmwzJnr9xWUApQCQ95yG/0M7K+s4WbyTWC/XeDmwAbB3iSYhp5AGgt7XJmTB8MvXgv0SCYi8EQIICkwuXFBSegBSZzUIVwNE8vcv/XvNIh0ceQpuC7EijFFc21Tl+X7e2Gntkch2PIHaRlsMfMlC29OUiipkdUbAz/LlJo+7sf+Gv6ASGLUehSoQi6o3WZal/sRDeyK1VM/4dRg8HU+BaIStmJvPMIw== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by PR3P250MB0323.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:17e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.16; Tue, 27 Dec 2022 22:47:44 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::da14:61e3:630a:70b5]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::da14:61e3:630a:70b5%8]) with mapi id 15.20.5944.016; Tue, 27 Dec 2022 22:47:44 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 27 Dec 2022 23:47:39 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [UghI4A/awjdie1ARF3RuHfMQuqQ98VUI] X-ClientProxiedBy: ZR0P278CA0057.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:21::8) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20221227224739.1181782-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|PR3P250MB0323:EE_ X-MS-Office365-Filtering-Correlation-Id: 4ecda1e3-5878-4174-ab7b-08dae85c5e7f X-MS-Exchange-SLBlob-MailProps: AZnQBsB9Xmq1cpv3c3jqXPj698IFbfnCqQVkyGhhG2RT5XZdBjAivJ80BB9rttkqoN0uwx0Dpa39m3hRQ60ljHSajdQy8vdUg99rtOlTXdIEAvQBVZGgJ1SqKG843uBWIp8C+ZfjypHtHMIgCqwYz4PBEc85bhqg+0hS0zKvPKIbrEGRZIUdYj9H59+Yv0evr4gPigj7JZax1pyx0QfedpY6JsTBScqcU4kcyXR0JQRF3+4wl1doA1wWVJRr8zLpa6CClhychplSB212tWOnc7BbmrDgxLLTnbr96F9VaTZDlCA7zWg6UCnJrbQoi5BfiA3D4LBvLy5upWfjmhE+udC+LH6FWaKM3OilmMPQiZB63E/c/tGuOI3FBder2uDMXNzhDvJxZrT9wgKfB2IBBnbIzXrDz2ym4E1r870WKtjkboT1mPZ5BU73Ob5hopq2FEf17Yl5Va3Aqhi+TyAEwyHMXJ4G0HLdPW+LzlY4Dk2oU0DWvJcCPjGjcnAB1m+eQOlIBYK47jcZUWi9pDO5y1WgdWrWjPYOHegaW2RdgOnpBkqP4GKFd/ByqgyMBhhKheW66TG/gyxhYZgjJsuovKRcU1uA0e0NyBwJROnGH0z9kXV85sN87C9t3EWJ0vMLQNz1WUjASQYKKHNZTIEmolCyz4g+ZvnVOi9bfgek+xzrfFcIS7vaMeLF7UNh+fivlV9hheGid+KOtgxcrEqijGPbTz+WICOw5bjQM050KSd0aYtvdEnp1IY4++AFbmLq6lz0jeL0ZoI= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: I/oTrZ7UB1yDdmUdyKt6f3Huj/h2eyF58lnV/bT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kciC57qn4bBr5HghHt6XAyIVZ5FSLXiy9P8obE/xDWaDB7M+dpP2Gk+v5Vgis6uCSMi1X8pMZ0Hc16Ld682hqgcKjwY7AKzYbiUIQUQoxyt79C4Jg4MRUV7gp3FMB5jkhRqjXJbDiGyB0RPdxHd6IeCz0nXqmEhg/T5MVbFQYgIfRmjviPK+TA/g/21Z1zZ+h1AeBrUHp1Avijmy80EHwA9JNehoicnaZkyPoym5KZYzDFlCSa1I401UshRYst/Tavk8ij6Ae2qy2O/WQlJrAb9HAIYaHsBmLvHa/jSW2RdefPnJTFP+7/qavw9oiVcXCYPW9TOU6tchkxvUSd3O8dOciqm6uWkJbE0rNRqIs2yd0TxuAb/L0QgPsCI/VrBcU5Fej7MKsur2lFaqZLSq0bLjPG1aicJlax+jH2upEbpcvT1hIO/dptHdsJgE2wU/SnbzqoZ7ajrJvL857eh3/LZ81ypIzcsYyCwIuDyQjS02lppNkvzwFU/ENj2zikeO8cYObPzvfcC277msyibK7Yj9JjQ0SsAwfKbDL7aeyx5JZstVejmU+6L2EX/To/UAM9w3b34anhH+EqR1uKiHIYurCbyfNyZ/03VPbXSyIrVP8IvkVEta0xPFAR367uZg66yAqlVNEQRjAc4ohh8FqjoTUVsnZ2UlO4XRmG4J5mXrRuV+uYnIWa0lbzAhzeefVshZH+t89MOHRtyiQSj1JZDbynT4sSMHPRZcDDueX42jSeG/Kaq7cRi6v0/qmsdA4z/fpM85lGyIa7Lh+QKiP2EL74LNzDxhc6bIvIj4w+hSCrajN90TRL7vhSoc5ZdYPNVJ3VoRAmLfBZDQBERoqkLAswWnp1vKMQOEB22R3ETVyTY/+bFuz+0wm/umIgx20cQ67cIuEL6jqGkjW28gIHT52MkByJA9JjTxHeRWZZanfClUDHm9jQm8B72YYYg= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4ecda1e3-5878-4174-ab7b-08dae85c5e7f X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Dec 2022 22:47:44.8375 (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: PR3P250MB0323 Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/flacenc: Don't reload bits_per_raw_sample 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: Psk94EYH/JW3 This has the advantage of allowing the compiler to check bits_per_raw_sample only once on little-endian hardware. Signed-off-by: Andreas Rheinhardt --- libavcodec/flacenc.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index adaaa77b79..cdb823a290 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -1574,23 +1574,24 @@ static int write_frame(FlacEncodeContext *s, AVPacket *avpkt) static int update_md5_sum(FlacEncodeContext *s, const void *samples) { const uint8_t *buf = samples; + int bits_per_raw_sample = s->avctx->bits_per_raw_sample; int buf_size = s->frame.blocksize * s->channels * - ((s->avctx->bits_per_raw_sample + 7) / 8); + ((bits_per_raw_sample + 7) / 8); if (HAVE_BIGENDIAN || - s->avctx->bits_per_raw_sample > 16 && s->avctx->bits_per_raw_sample <= 24) { + bits_per_raw_sample > 16 && bits_per_raw_sample <= 24) { av_fast_malloc(&s->md5_buffer, &s->md5_buffer_size, buf_size); if (!s->md5_buffer) return AVERROR(ENOMEM); buf = s->md5_buffer; } - if (s->avctx->bits_per_raw_sample <= 16) { + if (bits_per_raw_sample <= 16) { #if HAVE_BIGENDIAN s->bdsp.bswap16_buf((uint16_t *) s->md5_buffer, samples, buf_size / 2); #endif - } else if (s->avctx->bits_per_raw_sample <= 24) { + } else if (bits_per_raw_sample <= 24) { int i; const int32_t *samples0 = samples; uint8_t *tmp = s->md5_buffer; @@ -1600,7 +1601,7 @@ static int update_md5_sum(FlacEncodeContext *s, const void *samples) AV_WL24(tmp + 3*i, v); } } else { - /* s->avctx->bits_per_raw_sample <= 32 */ + /* bits_per_raw_sample <= 32 */ #if HAVE_BIGENDIAN s->bdsp.bswap_buf((uint32_t *) s->md5_buffer, samples, s->frame.blocksize * s->channels);