1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-23 20:00:56 +00:00

demux_cue: auto-detect CUE sheet charset

This commit is contained in:
wnoun 2019-04-07 21:10:52 +08:00 committed by wm4
parent a35da6612e
commit 1c43920fb8
5 changed files with 38 additions and 0 deletions

View File

@ -90,6 +90,7 @@ Interface changes
does not affect --vo=vdpau or --hwdec=vdpau-copy. does not affect --vo=vdpau or --hwdec=vdpau-copy.
- remove deprecated --chapter option - remove deprecated --chapter option
- deprecate --record-file - deprecate --record-file
- add `--demuxer-cue-codepage`
--- mpv 0.29.0 --- --- mpv 0.29.0 ---
- drop --opensles-sample-rate, as --audio-samplerate should be used if desired - drop --opensles-sample-rate, as --audio-samplerate should be used if desired
- drop deprecated --videotoolbox-format, --ff-aid, --ff-vid, --ff-sid, - drop deprecated --videotoolbox-format, --ff-aid, --ff-vid, --ff-sid,

View File

@ -3180,6 +3180,9 @@ Demuxer
``--demuxer-rawvideo-size=<value>`` ``--demuxer-rawvideo-size=<value>``
Frame size in bytes when using ``--demuxer=rawvideo``. Frame size in bytes when using ``--demuxer=rawvideo``.
``--demuxer-cue-codepage=<codepage>``
Specify the CUE sheet codepage. (See ``--sub-codepage`` for details.)
``--demuxer-max-bytes=<bytesize>`` ``--demuxer-max-bytes=<bytesize>``
This controls how much the demuxer is allowed to buffer ahead. The demuxer This controls how much the demuxer is allowed to buffer ahead. The demuxer
will normally try to read ahead as much as necessary, or as much is will normally try to read ahead as much as necessary, or as much is

View File

@ -28,8 +28,11 @@
#include "mpv_talloc.h" #include "mpv_talloc.h"
#include "misc/bstr.h" #include "misc/bstr.h"
#include "misc/charset_conv.h"
#include "common/msg.h" #include "common/msg.h"
#include "demux/demux.h" #include "demux/demux.h"
#include "options/m_config.h"
#include "options/m_option.h"
#include "options/path.h" #include "options/path.h"
#include "common/common.h" #include "common/common.h"
#include "stream/stream.h" #include "stream/stream.h"
@ -39,8 +42,25 @@
#define PROBE_SIZE 512 #define PROBE_SIZE 512
#define OPT_BASE_STRUCT struct demux_cue_opts
struct demux_cue_opts {
char *cue_cp;
};
const struct m_sub_options demux_cue_conf = {
.opts = (const m_option_t[]) {
OPT_STRING("codepage", cue_cp, 0),
{0}
},
.size = sizeof(struct demux_cue_opts),
.defaults = &(const struct demux_cue_opts) {
.cue_cp = "auto"
}
};
struct priv { struct priv {
struct cue_file *f; struct cue_file *f;
struct demux_cue_opts *opts;
}; };
static void add_source(struct timeline *tl, struct demuxer *d) static void add_source(struct timeline *tl, struct demuxer *d)
@ -252,10 +272,21 @@ static int try_open_file(struct demuxer *demuxer, enum demux_check check)
struct priv *p = talloc_zero(demuxer, struct priv); struct priv *p = talloc_zero(demuxer, struct priv);
demuxer->priv = p; demuxer->priv = p;
demuxer->fully_read = true; demuxer->fully_read = true;
p->opts = mp_get_config_group(p, demuxer->global, &demux_cue_conf);
struct demux_cue_opts *cue_opts = p->opts;
bstr data = stream_read_complete(s, p, 1000000); bstr data = stream_read_complete(s, p, 1000000);
if (data.start == NULL) if (data.start == NULL)
return -1; return -1;
const char *charset = mp_charset_guess(p, demuxer->log, data, cue_opts->cue_cp, 0);
if (charset && !mp_charset_is_utf8(charset)) {
MP_INFO(demuxer, "Using CUE charset: %s\n", charset);
bstr utf8 = mp_iconv_to_utf8(demuxer->log, data, charset, MP_ICONV_VERBOSE);
if (utf8.start && utf8.start != data.start) {
ta_steal(data.start, utf8.start);
data = utf8;
}
}
p->f = mp_parse_cue(data); p->f = mp_parse_cue(data);
talloc_steal(p, p->f); talloc_steal(p, p->f);
if (!p->f) { if (!p->f) {

View File

@ -65,6 +65,7 @@ extern const struct m_sub_options demux_rawaudio_conf;
extern const struct m_sub_options demux_rawvideo_conf; extern const struct m_sub_options demux_rawvideo_conf;
extern const struct m_sub_options demux_lavf_conf; extern const struct m_sub_options demux_lavf_conf;
extern const struct m_sub_options demux_mkv_conf; extern const struct m_sub_options demux_mkv_conf;
extern const struct m_sub_options demux_cue_conf;
extern const struct m_sub_options vd_lavc_conf; extern const struct m_sub_options vd_lavc_conf;
extern const struct m_sub_options ad_lavc_conf; extern const struct m_sub_options ad_lavc_conf;
extern const struct m_sub_options input_config; extern const struct m_sub_options input_config;
@ -527,6 +528,7 @@ const m_option_t mp_opts[] = {
OPT_SUBSTRUCT("demuxer-rawaudio", demux_rawaudio, demux_rawaudio_conf, 0), OPT_SUBSTRUCT("demuxer-rawaudio", demux_rawaudio, demux_rawaudio_conf, 0),
OPT_SUBSTRUCT("demuxer-rawvideo", demux_rawvideo, demux_rawvideo_conf, 0), OPT_SUBSTRUCT("demuxer-rawvideo", demux_rawvideo, demux_rawvideo_conf, 0),
OPT_SUBSTRUCT("demuxer-mkv", demux_mkv, demux_mkv_conf, 0), OPT_SUBSTRUCT("demuxer-mkv", demux_mkv, demux_mkv_conf, 0),
OPT_SUBSTRUCT("demuxer-cue", demux_cue, demux_cue_conf, 0),
// ------------------------- subtitles options -------------------- // ------------------------- subtitles options --------------------

View File

@ -303,6 +303,7 @@ typedef struct MPOpts {
struct demux_rawvideo_opts *demux_rawvideo; struct demux_rawvideo_opts *demux_rawvideo;
struct demux_lavf_opts *demux_lavf; struct demux_lavf_opts *demux_lavf;
struct demux_mkv_opts *demux_mkv; struct demux_mkv_opts *demux_mkv;
struct demux_cue_opts *demux_cue;
struct demux_opts *demux_opts; struct demux_opts *demux_opts;
struct demux_cache_opts *demux_cache_opts; struct demux_cache_opts *demux_cache_opts;