[FFmpeg-devel] [PATCH 3/8] libavformat/flacdec: Export samples md5 as metadata

Tomas Härdin git at haerdin.se
Wed Feb 12 12:56:16 EET 2025


tor 2025-02-06 klockan 16:07 +0100 skrev Michael Niedermayer:
> Hi Tomas
> 
> On Wed, Feb 05, 2025 at 03:20:09PM +0100, Tomas Härdin wrote:
> > 
> 
> >  libavformat/flacdec.c                     |    6 ++++++
> >  tests/ref/fate/cover-art-aiff-id3v2-remux |    5 +++--
> >  tests/ref/fate/cover-art-flac-remux       |    1 +
> >  tests/ref/fate/id3v2-utf16-bom            |    5 +++--
> >  4 files changed, 13 insertions(+), 4 deletions(-)
> > 685b0c4be452dc7138f993a3cbeb85320a045545  0003-libavformat-flacdec-
> > Export-samples-md5-as-metadata.patch
> > From e1c4dfa4cc7a574f6fac76c11591547d3cd90ad2 Mon Sep 17 00:00:00
> > 2001
> > From: Mattias Wadman <wader at spotify.com>
> > Date: Mon, 11 Oct 2021 15:38:13 +0200
> > Subject: [PATCH 3/8] libavformat/flacdec: Export samples md5 as
> > metadata
> > 
> > Will be used by mal to compare metadat md5 with decoded samples
> > md5.
> > 
> > Part of fixing https://jira.spotify.net/browse/GOL-681
> > ---
> >  libavformat/flacdec.c                     | 6 ++++++
> >  tests/ref/fate/cover-art-aiff-id3v2-remux | 5 +++--
> >  tests/ref/fate/cover-art-flac-remux       | 1 +
> >  tests/ref/fate/id3v2-utf16-bom            | 5 +++--
> >  4 files changed, 13 insertions(+), 4 deletions(-)
> > 
> > diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c
> > index 3c317acaee..9f65c25864 100644
> > --- a/libavformat/flacdec.c
> > +++ b/libavformat/flacdec.c
> > @@ -33,6 +33,7 @@
> >  #include "replaygain.h"
> >  
> >  #define SEEKPOINT_SIZE 18
> > +#define MD5_BYTE_SIZE 16
> >  
> >  typedef struct FLACDecContext {
> >      FFRawDemuxerContext rawctx;
> > @@ -109,6 +110,7 @@ static int flac_read_header(AVFormatContext *s)
> >          if (metadata_type == FLAC_METADATA_TYPE_STREAMINFO) {
> >              uint32_t samplerate;
> >              uint64_t samples;
> > +            char md5hex[MD5_BYTE_SIZE*2+1]; // hex representation
> > plus null terminator
> >  
> >              /* STREAMINFO can only occur once */
> >              if (found_streaminfo) {
> > @@ -133,6 +135,10 @@ static int flac_read_header(AVFormatContext
> > *s)
> >                  if (samples > 0)
> >                      st->duration = samples;
> >              }
> > +
> > +            ff_data_to_hex(md5hex, st->codecpar->extradata+18,
> > MD5_BYTE_SIZE, 1 /* lowercase */);
> > +            md5hex[sizeof(md5hex)-1] = '\0';
> > +            av_dict_set(&s->metadata, "samples_md5", md5hex, 0);
> 
> I think "samples_md5" should be documented, so that other decoders
> can use
> the same
> i also see a verify_md5() in hevc
> and crc seems frequently used in decoders

Documented where? doc/metadata.texi doesn't seem like the place for it.
doc/demuxers.texi maybe?

/Tomas


More information about the ffmpeg-devel mailing list