Commit eab1c88448 for ffmpeg

commit eab1c88448b22abb4013d0152a1cb3e409c86196
Author: Paper <paper@tflc.us>
Date:   Tue Sep 2 10:47:06 2025 -0400

    avformat/libopenmpt: add configurable interpolation options

    This commit adds an interpolation setting to the AVOptions
    structure, allowing the user to choose which method they
    would like to use. For modules, this is fairly important.
    Most modules use lo-fi samples (read: 8khz 8-bit possibly
    adpcm) which can sound terrible when mixing using high
    quality interpolation algorithms. This becomes especially
    prevalent in chiptune compositions, where hi-fi
    interpolation completely changes the sound.

    Virtually any value is accepted by libopenmpt, but only
    [1,2,4,8] produce any tangible difference in output. All
    other values seemingly get routed to the default, which
    is equivalent to passing 8 (8-tap windowed sinc).

    Signed-off-by: Paper <paper@tflc.us>

diff --git a/libavformat/libopenmpt.c b/libavformat/libopenmpt.c
index 46af4bff22..1238d8a0ff 100644
--- a/libavformat/libopenmpt.c
+++ b/libavformat/libopenmpt.c
@@ -46,6 +46,7 @@ typedef struct OpenMPTContext {
     int sample_rate;
     AVChannelLayout ch_layout;
     int subsong;
+    int interp;
 } OpenMPTContext;

 #define OFFSET(x) offsetof(OpenMPTContext, x)
@@ -57,6 +58,12 @@ static const AVOption options[] = {
     { "subsong",     "set subsong",        OFFSET(subsong),     AV_OPT_TYPE_INT,            { .i64 = -2 },                  -2,   INT_MAX,   A | D, .unit = "subsong"},
     { "all",         "all",                0,                   AV_OPT_TYPE_CONST,          { .i64 = -1},                   0,    0,         A | D, .unit = "subsong" },
     { "auto",        "auto",               0,                   AV_OPT_TYPE_CONST,          { .i64 = -2},                   0,    0,         A | D, .unit = "subsong" },
+    { "interpolation", "set interpolation method", OFFSET(interp),      AV_OPT_TYPE_INT,      { .i64 = 0 },        0,    INT_MAX, A | D, .unit = "interpolation"},
+    { "default",       "default",                  0,                   AV_OPT_TYPE_CONST,    { .i64 = 0 },        0,    0,       A | D, .unit = "interpolation"},
+    { "none",          "none",                     0,                   AV_OPT_TYPE_CONST,    { .i64 = 1 },        0,    0,       A | D, .unit = "interpolation"},
+    { "linear",        "linear",                   0,                   AV_OPT_TYPE_CONST,    { .i64 = 2 },        0,    0,       A | D, .unit = "interpolation"},
+    { "cubic",         "cubic",                    0,                   AV_OPT_TYPE_CONST,    { .i64 = 4 },        0,    0,       A | D, .unit = "interpolation"},
+    { "8-tap-sinc",    "8-tap windowed sinc",      0,                   AV_OPT_TYPE_CONST,    { .i64 = 8 },        0,    0,       A | D, .unit = "interpolation"},
     { NULL }
 };

@@ -120,6 +127,14 @@ static int read_header_openmpt(AVFormatContext *s)
             return AVERROR_INVALIDDATA;
 #endif

+    ret = openmpt_module_set_render_param(openmpt->module,
+        OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH,
+        openmpt->interp);
+    if (!ret) {
+        av_log(s, AV_LOG_ERROR, "Invalid interpolation setting: %d\n", openmpt->interp);
+        return AVERROR(EINVAL);
+    }
+
     if (openmpt->subsong >= openmpt_module_get_num_subsongs(openmpt->module)) {
         av_log(s, AV_LOG_ERROR, "Invalid subsong index: %d\n", openmpt->subsong);
         return AVERROR(EINVAL);