Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avformat/libopenmpt: add configurable interpolation options (PR #20800)
@ 2025-10-31  4:48 paper via ffmpeg-devel
  0 siblings, 0 replies; only message in thread
From: paper via ffmpeg-devel @ 2025-10-31  4:48 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: paper

PR #20800 opened by paper
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20800
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20800.patch


>From 711fcb5f8a287727184664313451240686de178a Mon Sep 17 00:00:00 2001
From: Paper <paper@tflc.us>
Date: Tue, 2 Sep 2025 10:47:06 -0400
Subject: [PATCH 1/2] 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>
---
 libavformat/libopenmpt.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/libavformat/libopenmpt.c b/libavformat/libopenmpt.c
index 46af4bff22..1721e59372 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);
-- 
2.49.1


>From a6de836961f6813fa58f452161f876f52aa31cc5 Mon Sep 17 00:00:00 2001
From: Paper <paper@tflc.us>
Date: Tue, 2 Sep 2025 12:37:43 -0400
Subject: [PATCH 2/2] avformat/libopenmpt: align AVOptions and remove
 unnecessary whitespace

This is a purely cosmetic change.

Signed-off-by: Paper <paper@tflc.us>
---
 libavformat/libopenmpt.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/libavformat/libopenmpt.c b/libavformat/libopenmpt.c
index 1721e59372..d7c9d4a7d6 100644
--- a/libavformat/libopenmpt.c
+++ b/libavformat/libopenmpt.c
@@ -53,17 +53,17 @@ typedef struct OpenMPTContext {
 #define A AV_OPT_FLAG_AUDIO_PARAM
 #define D AV_OPT_FLAG_DECODING_PARAM
 static const AVOption options[] = {
-    { "sample_rate", "set sample rate",    OFFSET(sample_rate), AV_OPT_TYPE_INT,            { .i64 = 48000 },               1000, INT_MAX,   A | D },
-    { "layout",      "set channel layout", OFFSET(ch_layout),   AV_OPT_TYPE_CHLAYOUT,       { .str = "stereo" },            0,    0,         A | D },
-    { "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"},
+    { "sample_rate",   "set sample rate",          OFFSET(sample_rate), AV_OPT_TYPE_INT,      { .i64 = 48000 },    1000, INT_MAX, A | D },
+    { "layout",        "set channel layout",       OFFSET(ch_layout),   AV_OPT_TYPE_CHLAYOUT, { .str = "stereo" }, 0,    0,       A | D },
+    { "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 }
 };
 
-- 
2.49.1

_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-10-31 14:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-31  4:48 [FFmpeg-devel] [PATCH] avformat/libopenmpt: add configurable interpolation options (PR #20800) paper via ffmpeg-devel

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