[FFmpeg-user] What's the purpose of bswap_buf() function?

Carl Eugen Hoyos ceffmpeg at gmail.com
Sun Feb 14 21:30:43 EET 2021


Am So., 14. Feb. 2021 um 19:07 Uhr schrieb Vasily Postnicov
<shamaz.mazum at gmail.com>:
>
> Hello. I try to add APE decoder support to my own library of audio
> codecs. Since APE is a closed format, I use ffmpeg as a reference
> trying to understand how it works.

> I cannot understand how this line works in libavcodec/apedec.c:
> s->bdsp.bswap_buf((uint32_t *) s->data, (const uint32_t *) buf, buf_size >> 2);
> I thought it swaps even and odd bytes,

No, bswap_buf() is about doing a byte swap on 32bit data, what
you describe would be a byte swap on 16 bit data.

> but it does something more than
> that. It's written in assembly code which I can not read clearly.

A debugger has many disadvantages over running git grep:
See libavcodec/bswapdsp.c and libavutil/bswap.h

> Also it lacks any documentation.

The function is only for internal use and byte swapping is
assumed to be common knowledge, FFmpeg is supposed
to run on both little- and big-endian hardware.

Carl Eugen


More information about the ffmpeg-user mailing list