1
mirror of https://github.com/mpv-player/mpv synced 2024-10-02 16:25:33 +02:00

demux_mkv: simplify subtitle type recognition

Remove indirection through MATROSKA_SUBTYPE_* and instead set the
per-track type field to the letter identifier used in public sh_sub.
This commit is contained in:
Uoti Urpala 2011-03-31 03:23:55 +03:00
parent 56504de6ff
commit 9d4d5b4469
2 changed files with 8 additions and 20 deletions

View File

@ -604,17 +604,15 @@ static void parse_trackentry(struct demuxer *demuxer,
|| !strcmp(track->codec_id, MKV_A_ACM))
track->ms_compat = 1;
else if (!strcmp(track->codec_id, MKV_S_VOBSUB))
track->subtitle_type = MATROSKA_SUBTYPE_VOBSUB;
track->subtitle_type = 'v';
else if (!strcmp(track->codec_id, MKV_S_TEXTSSA)
|| !strcmp(track->codec_id, MKV_S_TEXTASS)
|| !strcmp(track->codec_id, MKV_S_SSA)
|| !strcmp(track->codec_id, MKV_S_ASS)) {
track->subtitle_type = MATROSKA_SUBTYPE_SSA;
} else if (!strcmp(track->codec_id, MKV_S_TEXTASCII))
track->subtitle_type = MATROSKA_SUBTYPE_TEXT;
if (!strcmp(track->codec_id, MKV_S_TEXTUTF8)) {
track->subtitle_type = MATROSKA_SUBTYPE_TEXT;
}
|| !strcmp(track->codec_id, MKV_S_ASS))
track->subtitle_type = 'a';
else if (!strcmp(track->codec_id, MKV_S_TEXTASCII)
|| !strcmp(track->codec_id, MKV_S_TEXTUTF8))
track->subtitle_type = 't';
mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Codec ID: %s\n",
track->codec_id);
} else
@ -1567,16 +1565,12 @@ static int demux_mkv_open_audio(demuxer_t *demuxer, mkv_track_t *track,
static int demux_mkv_open_sub(demuxer_t *demuxer, mkv_track_t *track,
int sid)
{
if (track->subtitle_type != MATROSKA_SUBTYPE_UNKNOWN) {
if (track->subtitle_type) {
int size;
uint8_t *buffer;
sh_sub_t *sh = new_sh_sub(demuxer, sid);
track->sh_sub = sh;
sh->type = 't';
if (track->subtitle_type == MATROSKA_SUBTYPE_VOBSUB)
sh->type = 'v';
if (track->subtitle_type == MATROSKA_SUBTYPE_SSA)
sh->type = 'a';
sh->type = track->subtitle_type;
size = track->private_size;
demux_mkv_decode(track, track->private_data, &buffer, &size, 2);
if (buffer && buffer != track->private_data) {

View File

@ -76,12 +76,6 @@ struct ebml_parse_ctx {
#define MATROSKA_TRACK_SUBTITLE 0x11 /* text-subtitles */
#define MATROSKA_TRACK_CONTROL 0x20 /* control-codes for menu or other stuff*/
/* matroska subtitle types */
#define MATROSKA_SUBTYPE_UNKNOWN 0
#define MATROSKA_SUBTYPE_TEXT 1
#define MATROSKA_SUBTYPE_SSA 2
#define MATROSKA_SUBTYPE_VOBSUB 3
#ifndef UINT64_MAX
#define UINT64_MAX 18446744073709551615ULL
#endif