[FFmpeg-devel] [PATCH 2/2] avformat/framecrcenc: Make side-data checksums endian-independent

Michael Niedermayer michael at niedermayer.cc
Sun Dec 6 17:22:50 EET 2020


On Sun, Dec 06, 2020 at 04:09:34AM +0100, Andreas Rheinhardt wrote:
> Do this by converting big-endian side data to little endian for
> checksumming. Fixes the ts-demux FATE test.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> ---
> a) When commenting the #if HAVE_BIGENDIAN out, I get the same checksum
> for the test in [1] as Andriy got on a real BE system; I have not done
> more testing, lacking actual BE hardware. In particular, the claim about
> the ts-demux FATE test is untested.

fate-ts-demux passes with this set on qemu mips


> b) If side data doesn't have the expected size, then LE and BE might
> still produce different results (but then there must be a bigger problem
> elsewhere).
> c) This code here is designed to work even after the next major version
> bump when the size of some members of AVCPBProperties change. (Of course,
> some FATE checksums will need to be adapted then, but for both LE and BE
> in the same manner.)
> 
>  libavformat/framecrcenc.c | 61 +++++++++++++++++++++++++++++++++++----
>  1 file changed, 56 insertions(+), 5 deletions(-)
> 
> diff --git a/libavformat/framecrcenc.c b/libavformat/framecrcenc.c
> index f7c48779a0..390024dbe8 100644
> --- a/libavformat/framecrcenc.c
> +++ b/libavformat/framecrcenc.c
> @@ -21,9 +21,11 @@
>  
>  #include <inttypes.h>
>  
> +#include "config.h"
>  #include "libavutil/adler32.h"
>  #include "libavutil/avstring.h"
>  #include "libavutil/intreadwrite.h"
> +#include "libavcodec/avcodec.h"
>  #include "avformat.h"
>  #include "internal.h"
>  
> @@ -43,6 +45,19 @@ static int framecrc_write_header(struct AVFormatContext *s)
>      return ff_framehash_write_header(s);
>  }
>  
> +#if HAVE_BIGENDIAN
> +static void inline bswap(char *buf, int offset, int size)
> +{
> +    if (size == 8) {
> +        uint64_t val = AV_RN64(buf + offset);
> +        AV_WN64(buf + offset, av_bswap64(val));
> +    } else if (size == 4) {
> +        uint32_t val = AV_RN32(buf + offset);
> +        AV_WN32(buf + offset, av_bswap32(val));
> +    }
> +}
> +#endif

instead of the #if a av_unused could be used
that way the code is compile tested on LE and its a bit cleaner

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Never trust a computer, one day, it may think you are the virus. -- Compn
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20201206/28c734c9/attachment.sig>


More information about the ffmpeg-devel mailing list