From 7ddd6c86c9b06daacc90418abe8c8336ae287ef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hubert=20G=C5=82uchowski?= Date: Wed, 14 Jan 2026 15:16:31 +0100 Subject: [PATCH] sub/sd_sbr: pass track language to `sbr_load_text` The language hint is required for *correct* handling of RTL in srv3 so provide the best-effort guess from the subtitle track. Without this hint some RTL paragraphs are going to be wrongly assumed LTR and reorder incorrectly. Additionally, subrandr may soon start treating srv3 segments as `inline-block`s which means guessing is not going to be possible anymore (at least as part of unicode bidi algorithm). --- sub/dec_sub.c | 3 +++ sub/sd.h | 1 + sub/sd_sbr.c | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sub/dec_sub.c b/sub/dec_sub.c index 3e32c86e02cfb..17a32c7f8ef20 100644 --- a/sub/dec_sub.c +++ b/sub/dec_sub.c @@ -75,6 +75,7 @@ struct dec_sub { struct mp_codec_params *codec; double start, end; + char *lang; double last_vo_pts; struct sd *sd; @@ -171,6 +172,7 @@ static struct sd *init_decoder(struct dec_sub *sub) .order = sub->order, .attachments = sub->attachments, .codec = sub->codec, + .lang = sub->lang, .preload_ok = true, }; @@ -204,6 +206,7 @@ struct dec_sub *sub_create(struct mpv_global *global, struct track *track, .shared_opts_cache = m_config_cache_alloc(sub, global, &mp_subtitle_shared_sub_opts), .sh = track->stream, .codec = track->stream->codec, + .lang = track->lang, .attachments = talloc_steal(sub, attachments), .play_dir = 1, .order = order, diff --git a/sub/sd.h b/sub/sd.h index 8db7c41dd8dae..ccd472f9de959 100644 --- a/sub/sd.h +++ b/sub/sd.h @@ -29,6 +29,7 @@ struct sd { struct attachment_list *attachments; struct mp_codec_params *codec; + const char *lang; // Set to false as soon as the decoder discards old subtitle events. // (only needed if sd_functions.accept_packets_in_advance == false) diff --git a/sub/sd_sbr.c b/sub/sd_sbr.c index 58dce3b493288..3d7f595062480 100644 --- a/sub/sd_sbr.c +++ b/sub/sd_sbr.c @@ -148,7 +148,7 @@ static void decode(struct sd *sd, struct demux_packet *packet) packet->buffer, packet->len, fmt, - NULL + sd->lang ); // Since `demux_sbr` only ever sends us one packet,