Skip to content

Commit 7ddd6c8

Browse files
committed
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).
1 parent 7a7d871 commit 7ddd6c8

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

sub/dec_sub.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ struct dec_sub {
7575

7676
struct mp_codec_params *codec;
7777
double start, end;
78+
char *lang;
7879

7980
double last_vo_pts;
8081
struct sd *sd;
@@ -171,6 +172,7 @@ static struct sd *init_decoder(struct dec_sub *sub)
171172
.order = sub->order,
172173
.attachments = sub->attachments,
173174
.codec = sub->codec,
175+
.lang = sub->lang,
174176
.preload_ok = true,
175177
};
176178

@@ -204,6 +206,7 @@ struct dec_sub *sub_create(struct mpv_global *global, struct track *track,
204206
.shared_opts_cache = m_config_cache_alloc(sub, global, &mp_subtitle_shared_sub_opts),
205207
.sh = track->stream,
206208
.codec = track->stream->codec,
209+
.lang = track->lang,
207210
.attachments = talloc_steal(sub, attachments),
208211
.play_dir = 1,
209212
.order = order,

sub/sd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ struct sd {
2929

3030
struct attachment_list *attachments;
3131
struct mp_codec_params *codec;
32+
const char *lang;
3233

3334
// Set to false as soon as the decoder discards old subtitle events.
3435
// (only needed if sd_functions.accept_packets_in_advance == false)

sub/sd_sbr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ static void decode(struct sd *sd, struct demux_packet *packet)
148148
packet->buffer,
149149
packet->len,
150150
fmt,
151-
NULL
151+
sd->lang
152152
);
153153

154154
// Since `demux_sbr` only ever sends us one packet,

0 commit comments

Comments
 (0)