Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: "Tomas Härdin" <git@haerdin.se>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH 3/8] libavformat/flacdec: Export samples md5 as metadata
Date: Wed, 05 Feb 2025 15:20:09 +0100
Message-ID: <1d49ecd046da86394024e1c3407e8ffd88ef23d7.camel@haerdin.se> (raw)
In-Reply-To: <f4713629c8248e1c33e109b919d6149a3a1f4c82.camel@haerdin.se>

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: 0003-libavformat-flacdec-Export-samples-md5-as-metadata.patch --]
[-- Type: text/x-patch, Size: 3776 bytes --]

From e1c4dfa4cc7a574f6fac76c11591547d3cd90ad2 Mon Sep 17 00:00:00 2001
From: Mattias Wadman <wader@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);
         } else if (metadata_type == FLAC_METADATA_TYPE_CUESHEET) {
             uint8_t isrc[13];
             uint64_t start;
diff --git a/tests/ref/fate/cover-art-aiff-id3v2-remux b/tests/ref/fate/cover-art-aiff-id3v2-remux
index a59ba37c65..57c5a9f387 100644
--- a/tests/ref/fate/cover-art-aiff-id3v2-remux
+++ b/tests/ref/fate/cover-art-aiff-id3v2-remux
@@ -1,5 +1,5 @@
-330ad2bf538e91a31752b38024461df1 *tests/data/fate/cover-art-aiff-id3v2-remux.aiff
-608914 tests/data/fate/cover-art-aiff-id3v2-remux.aiff
+d8caddad3af3879f5957f71adcaedd23 *tests/data/fate/cover-art-aiff-id3v2-remux.aiff
+608970 tests/data/fate/cover-art-aiff-id3v2-remux.aiff
 #tb 0: 1/44100
 #media_type 0: audio
 #codec_id 0: pcm_s16be
@@ -68,6 +68,7 @@ TAG:comment=Composer
 [/STREAM]
 [FORMAT]
 TAG:artist=Мельница
+TAG:samples_md5=03462731b2dba8e6a9da639b07054121
 TAG:RATING=0
 TAG:album=Ангелофрения
 TAG:title=Дороги
diff --git a/tests/ref/fate/cover-art-flac-remux b/tests/ref/fate/cover-art-flac-remux
index fa91975881..109bf7395e 100644
--- a/tests/ref/fate/cover-art-flac-remux
+++ b/tests/ref/fate/cover-art-flac-remux
@@ -90,6 +90,7 @@ TAG:comment=Publisher/Studio logotype
 TAG:title=White King Granulated Soap
 [/STREAM]
 [FORMAT]
+TAG:samples_md5=496206705f222f9a63bf23dc874d9d71
 TAG:major_brand=M4A 
 TAG:minor_version=0
 TAG:compatible_brands=M4A mp42isom
diff --git a/tests/ref/fate/id3v2-utf16-bom b/tests/ref/fate/id3v2-utf16-bom
index dd2566de2b..a1adb4730d 100644
--- a/tests/ref/fate/id3v2-utf16-bom
+++ b/tests/ref/fate/id3v2-utf16-bom
@@ -1,5 +1,5 @@
-9b8bfdf87a8d3d089819ef9f6f264ec4 *tests/data/fate/id3v2-utf16-bom.aiff
-885482 tests/data/fate/id3v2-utf16-bom.aiff
+b712d97d4ab0cfd77d79235c312c438a *tests/data/fate/id3v2-utf16-bom.aiff
+885538 tests/data/fate/id3v2-utf16-bom.aiff
 #tb 0: 1/90000
 #media_type 0: video
 #codec_id 0: mjpeg
@@ -31,6 +31,7 @@ TAG:comment=Other
 [/STREAM]
 [FORMAT]
 TAG:artist=Мельница
+TAG:samples_md5=03462731b2dba8e6a9da639b07054121
 TAG:RATING=0
 TAG:album=Ангелофрения
 TAG:title=Дороги
-- 
2.39.5


[-- Attachment #3: Type: text/plain, Size: 251 bytes --]

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2025-02-05 14:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-05 14:18 [FFmpeg-devel] [PATCH 1/8] avformat/http: Return EIO for prematurely broken connection Tomas Härdin
2025-02-05 14:19 ` [FFmpeg-devel] [PATCH 2/8] libavcodec/wmadec: Return AVERROR_INVALIDDATA on decoding errors Tomas Härdin
2025-02-05 16:28   ` Marth64
2025-02-05 14:20 ` Tomas Härdin [this message]
2025-02-05 14:20 ` [FFmpeg-devel] [PATCH 4/8] avformat/flacdec: Return correct error-codes on read-failure Tomas Härdin
2025-02-05 14:21 ` [FFmpeg-devel] [PATCH 5/8] rtmp: Set correct message stream id when writing as server Tomas Härdin
2025-02-05 14:22 ` [FFmpeg-devel] [PATCH 6/8] GOL-1361: Remove invalid CTTS sample_offset check Tomas Härdin
2025-02-05 14:23 ` [FFmpeg-devel] [PATCH 7/8] avformat/mp3dec: Subtract known padding from duration Tomas Härdin
2025-02-05 14:24 ` [FFmpeg-devel] [PATCH 8/8] Make mime-type award a bonus probe score Tomas Härdin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1d49ecd046da86394024e1c3407e8ffd88ef23d7.camel@haerdin.se \
    --to=git@haerdin.se \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git