mirror of
https://github.com/mpv-player/mpv
synced 2025-01-24 00:23:27 +00:00
sub: prevent subtitle conversion if subs are known UTF-8
Currently this happens only in an obscure case (reading UTF-16 files with the old subreader).
This commit is contained in:
parent
9ee7364172
commit
29cec6f98b
@ -1348,6 +1348,7 @@ static int d_check_file(struct demuxer *demuxer)
|
||||
p->sh = new_sh_stream(demuxer, STREAM_SUB);
|
||||
p->sh->codec = sd->codec;
|
||||
p->sh->sub->frame_based = !sd->sub_uses_time;
|
||||
p->sh->sub->is_utf8 = sr.args.utf16 != 0; // converted from utf-16 -> utf-8
|
||||
|
||||
add_sub_data(demuxer, sd);
|
||||
subdata_free(sd);
|
||||
|
@ -164,6 +164,7 @@ typedef struct sh_sub {
|
||||
unsigned char *extradata; // extra header data passed from demuxer
|
||||
int extradata_len;
|
||||
int frame_based; // timestamps are frame-based
|
||||
bool is_utf8; // if false, subtitle packet charset is unknown
|
||||
struct ass_track *track; // loaded by libass
|
||||
struct dec_sub *dec_sub; // decoder context
|
||||
} sh_sub_t;
|
||||
|
@ -312,7 +312,7 @@ bool sub_read_all_packets(struct dec_sub *sub, struct sh_sub *sh)
|
||||
|
||||
// Can't run auto-detection on movtext packets: it's the only codec that
|
||||
// even though it decodes to text has binary input data.
|
||||
if (opts->sub_cp && strcmp(codec, "movtext") != 0)
|
||||
if (opts->sub_cp && !sh->is_utf8 && strcmp(codec, "movtext") != 0)
|
||||
sub->charset = guess_sub_cp(&subs, opts->sub_cp);
|
||||
|
||||
if (sub->charset)
|
||||
|
Loading…
Reference in New Issue
Block a user