--sub-charset now also needs a track ID.

This commit is contained in:
Moritz Bunkus 2003-06-22 12:11:54 +00:00
parent e5134cdde4
commit 63f0156422
4 changed files with 52 additions and 4 deletions

View File

@ -1,5 +1,7 @@
2003-06-22 Moritz Bunkus <moritz@bunkus.org>
* --sub-charset now also needs a track ID.
* Modified the verbosity levels for mkvinfo: The seek head subentries
and cue subentries will only be shown at level 2 to make the
output easier to read.

View File

@ -234,7 +234,8 @@ static void usage(void) {
" Works only for video tracks.\n"
" --aspect-ratio <f|a/b> Sets the aspect ratio.\n"
"\n Options that only apply to text subtitle tracks:\n"
" --sub-charset <charset> Sets the charset the text subtitles are\n"
" --sub-charset <TID:charset>\n"
" Sets the charset the text subtitles are\n"
" written in for the conversion to UTF-8.\n"
"\n\n Other options:\n"
" -i, --identify <file> Print information about the source file.\n"
@ -579,6 +580,29 @@ static void parse_language(char *s, language_t &lang) {
lang.language = s;
}
static void parse_sub_charset(char *s, language_t &sub_charset) {
char *colon;
// Extract the track number.
if ((colon = strchr(s, ':')) == NULL) {
fprintf(stderr, "Error: Invalid sub charset option. No track ID specified "
"(%s).\n", s);
exit(1);
}
*colon = 0;
if (!parse_int(s, sub_charset.id)) {
fprintf(stderr, "Error: Invalid track ID specified.\n");
exit(1);
}
s = &colon[1];
if (*s == 0) {
fprintf(stderr, "Error: Invalid sub charset specified.\n");
exit(1);
}
sub_charset.language = s;
}
static void render_headers(mm_io_c *out, bool last_file, bool first_file) {
EbmlHead head;
int i;
@ -773,6 +797,7 @@ static void identify(const char *filename) {
ti.cue_creations = new vector<cue_creation_t>;
ti.default_track_flags = new vector<int64_t>;
ti.languages = new vector<language_t>;
ti.sub_charsets = new vector<language_t>;
ti.aspect_ratio = 1.0;
ti.atracks = new vector<int64_t>;
ti.vtracks = new vector<int64_t>;
@ -820,6 +845,7 @@ static void parse_args(int argc, char **argv) {
ti.cue_creations = new vector<cue_creation_t>;
ti.default_track_flags = new vector<int64_t>;
ti.languages = new vector<language_t>;
ti.sub_charsets = new vector<language_t>;
ti.aspect_ratio = 1.0;
ti.atracks = new vector<int64_t>;
ti.vtracks = new vector<int64_t>;
@ -1095,8 +1121,8 @@ static void parse_args(int argc, char **argv) {
fprintf(stderr, "Error: --sub-charset lacks its argument.\n");
exit(1);
}
ti.sub_charset = argv[i + 1];
parse_sub_charset(argv[i + 1], lang);
ti.sub_charsets->push_back(lang);
i++;
}
@ -1145,11 +1171,13 @@ static void parse_args(int argc, char **argv) {
delete ti.cue_creations;
delete ti.default_track_flags;
delete ti.languages;
delete ti.sub_charsets;
memset(&ti, 0, sizeof(track_info_t));
ti.audio_syncs = new vector<audio_sync_t>;
ti.cue_creations = new vector<cue_creation_t>;
ti.default_track_flags = new vector<int64_t>;
ti.languages = new vector<language_t>;
ti.sub_charsets = new vector<language_t>;
ti.aspect_ratio = 1.0;
ti.atracks = new vector<int64_t>;
ti.vtracks = new vector<int64_t>;

View File

@ -91,6 +91,16 @@ generic_packetizer_c::generic_packetizer_c(generic_reader_c *nreader,
}
}
// Let's see if the user has specified a sub charset for this track.
for (i = 0; i < ti->sub_charsets->size(); i++) {
lang = &(*ti->sub_charsets)[i];
if ((lang->id == ti->id) || (lang->id == -1)) { // -1 == all tracks
safefree(ti->sub_charset);
ti->sub_charset = safestrdup(lang->language);
break;
}
}
// Set default header values to 'unset'.
hserialno = track_number++;
huid = 0;
@ -520,6 +530,10 @@ track_info_t *duplicate_track_info(track_info_t *src) {
for (i = 0; i < src->languages->size(); i++)
(*dst->languages)[i].language = safestrdup((*src->languages)[i].language);
dst->language = safestrdup(src->language);
dst->sub_charsets = new vector<language_t>(*src->sub_charsets);
for (i = 0; i < src->sub_charsets->size(); i++)
(*dst->sub_charsets)[i].language =
safestrdup((*src->sub_charsets)[i].language);
dst->private_data = (unsigned char *)safememdup(src->private_data,
src->private_size);
dst->sub_charset = safestrdup(src->sub_charset);
@ -543,6 +557,9 @@ void free_track_info(track_info_t *ti) {
for (i = 0; i < ti->languages->size(); i++)
safefree((*ti->languages)[i].language);
delete ti->languages;
for (i = 0; i < ti->sub_charsets->size(); i++)
safefree((*ti->sub_charsets)[i].language);
delete ti->sub_charsets;
safefree(ti->language);
safefree(ti->private_data);
safefree(ti->sub_charset);

View File

@ -94,7 +94,8 @@ typedef struct {
vector<language_t> *languages; // As given on the command line
char *language; // For this very track
char *sub_charset;
vector<language_t> *sub_charsets; // As given on the command line
char *sub_charset; // For this very track
} track_info_t;
class generic_reader_c;