From 9f698ad6941aeb56a317aaa1f4c0414259e2f9e7 Mon Sep 17 00:00:00 2001 From: TheM14 Date: Fri, 13 Nov 2026 15:31:31 +0800 Subject: [PATCH] Route ad-joc-pcm inputs to ad_joc The generated f_decoder_wrapper patch only switched to ad_joc when the codec was E-AC-3. ad-joc-pcm=yes was read by the decoder but never had any effect, because PCM/FLAC/TrueHD inputs were still handed to the default lavc decoder. Extend the wrapper condition to select ad_joc for non-E-AC-3 codecs when ad_joc_params->pcm is enabled. With ad-joc-pcm=no (or the option absent) those inputs continue through the default decoder. The E-AC-3 JOC path is unchanged. Include audio/decode/ad_joc.h in f_decoder_wrapper.c so the generated code can access ad_joc_params->pcm; options.h only forward-declares the struct. Rebuild mpv after this change; existing binaries still contain the old eac3-only routing. --- fork/tools/apply_edits.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fork/tools/apply_edits.py b/fork/tools/apply_edits.py index 65245d7..776b22d 100644 --- a/fork/tools/apply_edits.py +++ b/fork/tools/apply_edits.py @@ -45,7 +45,8 @@ WRAPPER_BLOCK = """#if HAVE_JOC * objects (binaural or a speaker layout) instead of letting FFmpeg * downmix. Opt-in, so default playback is untouched. */ if (driver == &ad_lavc && p->codec->codec && - strcmp(p->codec->codec, "eac3") == 0 && + (strcmp(p->codec->codec, "eac3") == 0 || + (p->opts->ad_joc_params && p->opts->ad_joc_params->pcm)) && decoder_name_listed(user_list, "joc")) { struct mp_decoder_list *joc_list = @@ -150,6 +151,9 @@ def main(): tree.put("filters/f_decoder_wrapper.c", s[:pos] + WRAPPER_BLOCK.replace("\n", eol) + eol + s[pos:]) + add_after(tree, "filters/f_decoder_wrapper.c", + '#include "options/options.h"', + '#include "audio/decode/ad_joc.h"', "ad_joc params include") add_after(tree, "filters/f_decoder_wrapper.h", "extern const struct mp_decoder_fns ad_dsd;", "extern const struct mp_decoder_fns ad_joc;", "ad_dsd extern")