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

Gyan Doshi ffmpeg at gyani.pro
Thu Feb 13 13:52:24 EET 2025


On 2025-02-13 05:11 pm, Tomas Härdin wrote:
> ons 2025-02-12 klockan 22:55 +0100 skrev Michael Niedermayer:
>> Hi
>> On Wed, Feb 12, 2025 at 11:56:16AM +0100, Tomas Härdin wrote:
>>> 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:
>> [...]
>>>>> 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?
>> honestly, i didnt think about "where", just that it should be
>> documented
>> somewhere
> A similar question was raised on IRC. I think a new doc entry for it is
> warranted. I'll make a new thread about it

This looks like a product of the FLAC decoder, so it goes within its entry.

Regards,
Gyan



More information about the ffmpeg-devel mailing list