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.
This commit is contained in:
TheM14 committed 2026-11-13 15:31:31 +08:00
1 parent 66359ff089
commit 9f698ad694
1 file changed
+5 -1
+5 -1
View File
@@ -45,7 +45,8 @@ WRAPPER_BLOCK = """#if HAVE_JOC
* objects (binaural or a speaker layout) instead of letting FFmpeg * objects (binaural or a speaker layout) instead of letting FFmpeg
* downmix. Opt-in, so default playback is untouched. */ * downmix. Opt-in, so default playback is untouched. */
if (driver == &ad_lavc && p->codec->codec && 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")) decoder_name_listed(user_list, "joc"))
{ {
struct mp_decoder_list *joc_list = struct mp_decoder_list *joc_list =
@@ -150,6 +151,9 @@ def main():
tree.put("filters/f_decoder_wrapper.c", tree.put("filters/f_decoder_wrapper.c",
s[:pos] + WRAPPER_BLOCK.replace("\n", eol) + eol + s[pos:]) 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", add_after(tree, "filters/f_decoder_wrapper.h",
"extern const struct mp_decoder_fns ad_dsd;", "extern const struct mp_decoder_fns ad_dsd;",
"extern const struct mp_decoder_fns ad_joc;", "ad_dsd extern") "extern const struct mp_decoder_fns ad_joc;", "ad_dsd extern")