[FFmpeg-devel] [PATCH 1/3] avcodec/bswapdsp: Don't presume src to be naturally aligned

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Wed Dec 28 00:41:49 EET 2022


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 <andreas.rheinhardt at outlook.com>
---
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 <stdint.h>
 
 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;
-- 
2.34.1



More information about the ffmpeg-devel mailing list