0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 03:52:22 +02: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:
wm4 2013-06-23 22:16:47 +02:00
parent 9ee7364172
commit 29cec6f98b
3 changed files with 3 additions and 1 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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)