What's the purpose of bswap_buf() function?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

What's the purpose of bswap_buf() function?

Vasily Postnicov
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, but it does something more than
that. It's written in assembly code which I can not read clearly. Also
it lacks any documentation. Can anyone explain what it does?
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: What's the purpose of bswap_buf() function?

Carl Eugen Hoyos-2
Am So., 14. Feb. 2021 um 19:07 Uhr schrieb Vasily Postnicov
<[hidden email]>:
>
> 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
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: What's the purpose of bswap_buf() function?

Vasily Postnicov
Thanks a lot. I thought for some reason that bswap is for 16-bit values.

вс, 14 февр. 2021 г. в 22:31, Carl Eugen Hoyos <[hidden email]>:

>
> Am So., 14. Feb. 2021 um 19:07 Uhr schrieb Vasily Postnicov
> <[hidden email]>:
> >
> > 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
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".