From: "Tomas Härdin" <git@haerdin.se> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: [FFmpeg-devel] [PATCH 8/8] Make mime-type award a bonus probe score Date: Wed, 05 Feb 2025 15:24:24 +0100 Message-ID: <e696cd3d93990301b890ecd749f83ba9cbf96d34.camel@haerdin.se> (raw) In-Reply-To: <f4713629c8248e1c33e109b919d6149a3a1f4c82.camel@haerdin.se> [-- Attachment #1: Type: text/plain, Size: 47 bytes --] Seems reasonable to me and passes FATE /Tomas [-- Attachment #2: 0008-Make-mime-type-award-a-bonus-probe-score.patch --] [-- Type: text/x-patch, Size: 3407 bytes --] From ecc3459990f2871fd907f96fe66362b8fea41bd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Zeb=C3=BChr?= <peterz@spotify.com> Date: Tue, 21 Nov 2023 14:16:49 +0100 Subject: [PATCH 8/8] Make mime-type award a bonus probe score This changes the default behaviour of ffmpeg where content-type headers on an input gives an absolut probe score (of 75) to instead give a bonus score (of 30). This gives the probe a better chance to arrive at the correct format by (hopefully) giving a large enough bonus to push edge cases in the right direction (MPEG-PS vs MP3, I am looking at you) while also not adversly punishing clearer cases (raw ADTS marked as "audio/mpeg" for example). This patch was regression tested against 20 million recent podcast submissions (after content-type propagation was added to original-storage), and 50k Juno vodcasts submissions (dito). No adverse effects observed (but the bonus may still need tweaking if other edge cases are detected in production). --- libavformat/avformat.h | 2 +- libavformat/format.c | 8 ++++---- libavformat/libopenmpt.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 6abdb6d480..498c557a3c 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -459,7 +459,7 @@ typedef struct AVProbeData { #define AVPROBE_SCORE_STREAM_RETRY (AVPROBE_SCORE_MAX/4-1) #define AVPROBE_SCORE_EXTENSION 50 ///< score for file extension -#define AVPROBE_SCORE_MIME 75 ///< score for file mime type +#define AVPROBE_SCORE_MIME_BONUS 30 ///< score added for matching mime type #define AVPROBE_SCORE_MAX 100 ///< maximum score #define AVPROBE_PADDING_SIZE 32 ///< extra allocated bytes at the end of the probe buffer diff --git a/libavformat/format.c b/libavformat/format.c index e65a6fc05e..71018ea6ab 100644 --- a/libavformat/format.c +++ b/libavformat/format.c @@ -212,10 +212,10 @@ const AVInputFormat *av_probe_input_format3(const AVProbeData *pd, score = AVPROBE_SCORE_EXTENSION; } if (av_match_name(lpd.mime_type, fmt1->mime_type)) { - if (AVPROBE_SCORE_MIME > score) { - av_log(NULL, AV_LOG_DEBUG, "Probing %s score:%d increased to %d due to MIME type\n", fmt1->name, score, AVPROBE_SCORE_MIME); - score = AVPROBE_SCORE_MIME; - } + int old_score = score; + score += AVPROBE_SCORE_MIME_BONUS; + if (score > AVPROBE_SCORE_MAX) score = AVPROBE_SCORE_MAX; + av_log(NULL, AV_LOG_DEBUG, "Probing %s score:%d increased to %d due to MIME type\n", fmt1->name, old_score, score); } if (score > score_max) { score_max = score; diff --git a/libavformat/libopenmpt.c b/libavformat/libopenmpt.c index 736af7caf2..dee975c9c2 100644 --- a/libavformat/libopenmpt.c +++ b/libavformat/libopenmpt.c @@ -244,7 +244,7 @@ static int read_probe_openmpt(const AVProbeData *p) * AVPROBE_SCORE_MAX in order to reduce the impact in the rare * cases of false positives. */ - return AVPROBE_SCORE_MIME + 1; + return (AVPROBE_SCORE_MAX * 3) / 4 + 1; } else if (probe_result == OPENMPT_PROBE_FILE_HEADER_RESULT_WANTMOREDATA) { if (probe_openmpt_extension(p) > 0) { return AVPROBE_SCORE_RETRY; -- 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".
prev parent reply other threads:[~2025-02-05 14:24 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 ` [FFmpeg-devel] [PATCH 3/8] libavformat/flacdec: Export samples md5 as metadata Tomas Härdin 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 ` Tomas Härdin [this message]
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=e696cd3d93990301b890ecd749f83ba9cbf96d34.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