From 8f974d2392da4e6fa422a67050e90f1471d72966 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Fri, 13 Mar 2026 12:30:02 +0100 Subject: [PATCH] mtmd : rename mtmd_get_audio_bitrate to mtmd_get_audio_sample_rate (#20105) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit renames the the function `mtmd_get_audio_bitrate` to `mtmd_get_audio_sample_rate` to better reflect its purpose. The motivation for this is that the function currently returns the audio sample rate, not the bitrate (sample_rate × bit_depth × channels), and that is how it is used in the code as well. This is a breaking change, but I believe mtmd is still in experimental/development phase so it might be alright to simply rename. --- tools/mtmd/mtmd-helper.cpp | 6 +++--- tools/mtmd/mtmd.cpp | 2 +- tools/mtmd/mtmd.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/mtmd/mtmd-helper.cpp b/tools/mtmd/mtmd-helper.cpp index c75f90730f..5bcb7ec1bc 100644 --- a/tools/mtmd/mtmd-helper.cpp +++ b/tools/mtmd/mtmd-helper.cpp @@ -470,12 +470,12 @@ static bool decode_audio_from_buf(const unsigned char * buf_in, size_t len, int mtmd_bitmap * mtmd_helper_bitmap_init_from_buf(mtmd_context * ctx, const unsigned char * buf, size_t len) { if (audio_helpers::is_audio_file((const char *)buf, len)) { std::vector pcmf32; - int bitrate = mtmd_get_audio_bitrate(ctx); - if (bitrate < 0) { + const int sample_rate = mtmd_get_audio_sample_rate(ctx); + if (sample_rate < 0) { LOG_ERR("This model does not support audio input\n"); return nullptr; } - if (!audio_helpers::decode_audio_from_buf(buf, len, bitrate, pcmf32)) { + if (!audio_helpers::decode_audio_from_buf(buf, len, sample_rate, pcmf32)) { LOG_ERR("Unable to read WAV audio file from buffer\n"); return nullptr; } diff --git a/tools/mtmd/mtmd.cpp b/tools/mtmd/mtmd.cpp index ccafb80b2b..1a95acd439 100644 --- a/tools/mtmd/mtmd.cpp +++ b/tools/mtmd/mtmd.cpp @@ -912,7 +912,7 @@ bool mtmd_support_audio(mtmd_context * ctx) { return ctx->ctx_a != nullptr; } -int mtmd_get_audio_bitrate(mtmd_context * ctx) { +int mtmd_get_audio_sample_rate(mtmd_context * ctx) { if (!ctx->ctx_a) { return -1; } diff --git a/tools/mtmd/mtmd.h b/tools/mtmd/mtmd.h index ef25d32bbe..ebb4a18fb3 100644 --- a/tools/mtmd/mtmd.h +++ b/tools/mtmd/mtmd.h @@ -125,9 +125,9 @@ MTMD_API bool mtmd_support_vision(mtmd_context * ctx); // whether the current model supports audio input MTMD_API bool mtmd_support_audio(mtmd_context * ctx); -// get audio bitrate in Hz, for example 16000 for Whisper +// get audio sample rate in Hz, for example 16000 for Whisper // return -1 if audio is not supported -MTMD_API int mtmd_get_audio_bitrate(mtmd_context * ctx); +MTMD_API int mtmd_get_audio_sample_rate(mtmd_context * ctx); // mtmd_bitmap //