mirror of
https://github.com/mpv-player/mpv
synced 2025-04-21 14:49:08 +00:00
subs: remove --utf8, simplify code
Remove the options --utf8 and --unicode which had no effect any more (what they once did should be doable with --subcp). The only use of corresponding variables left in code was subreader.c code using sub_utf8 as a flag indicating whether iconv conversion was active. Change the code to test the existence of iconv context instead. Conflicts: DOCS/man/en/options.rst core/cfg-mplayer.h sub/sub.c sub/sub.h sub/subreader.c Merged from mplayer2 commit ea7311. Note: --unicode was already removed
This commit is contained in:
parent
3486f59fe2
commit
72205635ab
@ -2170,10 +2170,6 @@
|
||||
--user-agent=<string>
|
||||
Use <string> as user agent for HTTP streaming.
|
||||
|
||||
--utf8
|
||||
Tells mpv to handle the subtitle file as UTF-8. By default, the subtitle
|
||||
file encoding is guessed, and all text converted to UTF-8 internally.
|
||||
|
||||
-v
|
||||
Increment verbosity level, one level for each ``-v`` found on the command
|
||||
line.
|
||||
|
@ -497,8 +497,7 @@ const m_option_t common_opts[] = {
|
||||
{"sub-delay", &sub_delay, CONF_TYPE_FLOAT, 0, 0.0, 10.0, NULL},
|
||||
{"subfps", &sub_fps, CONF_TYPE_FLOAT, 0, 0.0, 10.0, NULL},
|
||||
OPT_MAKE_FLAGS("autosub", sub_auto, 0),
|
||||
{"utf8", &sub_utf8, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
||||
{"sub-forced-only", &forced_subs_only, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
||||
{"forcedsubsonly", &forced_subs_only, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
||||
// specify IFO file for VOBSUB subtitle
|
||||
{"ifo", &spudec_ifo, CONF_TYPE_STRING, 0, 0, 0, NULL},
|
||||
// enable Closed Captioning display
|
||||
|
@ -58,7 +58,6 @@ char * const sub_osd_names[]={
|
||||
};
|
||||
char * const sub_osd_names_short[] ={ "", "|>", "||", "[]", "<<" , ">>", "", "", "", "", "", "", "" };
|
||||
|
||||
int sub_utf8=0;
|
||||
int sub_pos=100;
|
||||
int sub_visibility=1;
|
||||
|
||||
|
@ -195,8 +195,6 @@ extern const struct m_sub_options osd_style_conf;
|
||||
extern char * const sub_osd_names[];
|
||||
extern char * const sub_osd_names_short[];
|
||||
|
||||
extern int sub_utf8;
|
||||
|
||||
extern char *sub_cp;
|
||||
extern int sub_pos;
|
||||
|
||||
|
@ -1166,9 +1166,6 @@ static int sub_autodetect (stream_t* st, int *uses_time, int utf16) {
|
||||
return SUB_INVALID; // too many bad lines
|
||||
}
|
||||
|
||||
extern int sub_utf8;
|
||||
int sub_utf8_prev=0;
|
||||
|
||||
extern float sub_delay;
|
||||
extern float sub_fps;
|
||||
|
||||
@ -1196,7 +1193,6 @@ void subcp_open (stream_t *st)
|
||||
#endif
|
||||
if ((icdsc = iconv_open (tocp, cp_tmp)) != (iconv_t)(-1)){
|
||||
mp_msg(MSGT_SUBREADER,MSGL_V,"SUB: opened iconv descriptor.\n");
|
||||
sub_utf8 = 2;
|
||||
} else
|
||||
mp_msg(MSGT_SUBREADER,MSGL_ERR,"SUB: error opening iconv descriptor.\n");
|
||||
}
|
||||
@ -1223,10 +1219,8 @@ subtitle* subcp_recode (subtitle *sub)
|
||||
ileft = strlen(ip);
|
||||
oleft = 4 * ileft;
|
||||
|
||||
if (!(ot = malloc(oleft + 1))){
|
||||
mp_msg(MSGT_SUBREADER,MSGL_WARN,"SUB: error allocating mem.\n");
|
||||
continue;
|
||||
}
|
||||
if (!(ot = malloc(oleft + 1)))
|
||||
abort();
|
||||
op = ot;
|
||||
if (iconv(icdsc, &ip, &ileft,
|
||||
&op, &oleft) == (size_t)(-1)) {
|
||||
@ -1424,7 +1418,6 @@ sub_data* sub_read_file(char *filename, float fps, struct MPOpts *opts)
|
||||
mp_msg(MSGT_SUBREADER, MSGL_V, "SUB: Detected subtitle file format: %s\n", srp->name);
|
||||
|
||||
#ifdef CONFIG_ICONV
|
||||
sub_utf8_prev=sub_utf8;
|
||||
{
|
||||
int l,k;
|
||||
k = -1;
|
||||
@ -1432,7 +1425,6 @@ sub_data* sub_read_file(char *filename, float fps, struct MPOpts *opts)
|
||||
char *exts[] = {".utf", ".utf8", ".utf-8" };
|
||||
for (k=3;--k>=0;)
|
||||
if (l >= strlen(exts[k]) && !strcasecmp(filename+(l - strlen(exts[k])), exts[k])){
|
||||
sub_utf8 = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1442,14 +1434,8 @@ sub_data* sub_read_file(char *filename, float fps, struct MPOpts *opts)
|
||||
|
||||
sub_num=0;n_max=32;
|
||||
first=malloc(n_max*sizeof(subtitle));
|
||||
if(!first){
|
||||
#ifdef CONFIG_ICONV
|
||||
subcp_close();
|
||||
sub_utf8=sub_utf8_prev;
|
||||
#endif
|
||||
free_stream(fd);
|
||||
return NULL;
|
||||
}
|
||||
if (!first)
|
||||
abort();
|
||||
|
||||
#ifdef CONFIG_SORTSUB
|
||||
alloced_sub =
|
||||
@ -1470,7 +1456,7 @@ sub_data* sub_read_file(char *filename, float fps, struct MPOpts *opts)
|
||||
sub=srp->read(fd, sub, &(struct readline_args){utf16, opts});
|
||||
if(!sub) break; // EOF
|
||||
#ifdef CONFIG_ICONV
|
||||
if ((sub!=ERR) && sub_utf8 == 2) sub=subcp_recode(sub);
|
||||
if (sub!=ERR) sub=subcp_recode(sub);
|
||||
#endif
|
||||
if ( sub == ERR )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user