Set default track flags correctly.

This commit is contained in:
Moritz Bunkus 2004-07-03 08:49:00 +00:00
parent c8d86da5a3
commit 3768bc3738
4 changed files with 40 additions and 27 deletions

View File

@ -1,5 +1,8 @@
2004-07-03 Moritz Bunkus <moritz@bunkus.org> 2004-07-03 Moritz Bunkus <moritz@bunkus.org>
* mkvmerge: bug fix: The default track feature did not work
correctly with the new --track-order.
* mkvmerge: new feature: Added support for TTA lossless audio * mkvmerge: new feature: Added support for TTA lossless audio
files. files.

View File

@ -1233,6 +1233,9 @@ render_headers(mm_io_c *rout) {
for (i = 0; i < files.size(); i++) for (i = 0; i < files.size(); i++)
if (files[i]->first) if (files[i]->first)
files[i]->reader->set_headers(); files[i]->reader->set_headers();
for (i = 0; i < packetizers.size(); i++)
if (packetizers[i]->packetizer != NULL)
packetizers[i]->packetizer->fix_headers();
kax_tracks->Render(*rout, !hack_engaged(ENGAGE_NO_DEFAULT_HEADER_VALUES)); kax_tracks->Render(*rout, !hack_engaged(ENGAGE_NO_DEFAULT_HEADER_VALUES));
kax_sh_main->IndexThis(*kax_tracks, *kax_segment); kax_sh_main->IndexThis(*kax_tracks, *kax_segment);

View File

@ -62,6 +62,7 @@ generic_packetizer_c::generic_packetizer_c(generic_reader_c *nreader,
safety_last_timecode = 0; safety_last_timecode = 0;
last_cue_timecode = -1; last_cue_timecode = -1;
timecode_offset = 0; timecode_offset = 0;
default_track_warning_printed = false;
// Let's see if the user specified audio sync for this track. // Let's see if the user specified audio sync for this track.
found = false; found = false;
@ -296,10 +297,6 @@ generic_packetizer_c::set_track_type(int type) {
if ((type == track_audio) && (ti->cues == CUES_UNSPECIFIED)) if ((type == track_audio) && (ti->cues == CUES_UNSPECIFIED))
ti->cues = CUES_SPARSE; ti->cues = CUES_SPARSE;
if (ti->default_track)
set_as_default_track(type, DEFAULT_TRACK_PRIORITY_CMDLINE);
else
set_as_default_track(type, DEFAULT_TRACK_PRIORITY_FROM_TYPE);
} }
void void
@ -459,27 +456,18 @@ generic_packetizer_c::set_video_display_height(int height) {
void void
generic_packetizer_c::set_as_default_track(int type, generic_packetizer_c::set_as_default_track(int type,
int priority) { int priority) {
int idx; if (default_tracks_priority[type] < priority) {
default_tracks_priority[type] = priority;
idx = 0; default_tracks[type] = hserialno;
if (type == track_audio) } else if ((priority == DEFAULT_TRACK_PRIORITY_CMDLINE) &&
idx = 0; (default_tracks[type] != hserialno) &&
else if (type == track_video) !default_track_warning_printed) {
idx = 1;
else if (type == track_subtitle)
idx = 2;
else
die("pr_generic.cpp/generic_packetizer_c::set_as_default_track(): Unknown "
"track type %d.", type);
if (default_tracks_priority[idx] < priority) {
default_tracks_priority[idx] = priority;
default_tracks[idx] = hserialno;
} else if (priority == DEFAULT_TRACK_PRIORITY_CMDLINE)
mxwarn("Another default track for %s tracks has already " mxwarn("Another default track for %s tracks has already "
"been set. Not setting the 'default' flag for track %lld of " "been set. Not setting the 'default' flag for track %lld of "
"'%s'.\n", idx == 0 ? "audio" : idx == 'v' ? "video" : "subtitle", "'%s'.\n", type == 0 ? "audio" : type == 'v' ? "video" : "subtitle",
ti->id, ti->fname); ti->id, ti->fname);
default_track_warning_printed = true;
}
} }
void void
@ -548,12 +536,10 @@ generic_packetizer_c::set_headers() {
else else
idx = 2; idx = 2;
if (default_tracks[idx] == hserialno) if (ti->default_track)
*(static_cast<EbmlUInteger *> set_as_default_track(idx, DEFAULT_TRACK_PRIORITY_CMDLINE);
(&GetChild<KaxTrackFlagDefault>(*track_entry))) = 1;
else else
*(static_cast<EbmlUInteger *> set_as_default_track(idx, DEFAULT_TRACK_PRIORITY_FROM_TYPE);
(&GetChild<KaxTrackFlagDefault>(*track_entry))) = 0;
if (ti->language != NULL) if (ti->language != NULL)
*(static_cast<EbmlString *> *(static_cast<EbmlString *>
@ -682,6 +668,25 @@ generic_packetizer_c::set_headers() {
} }
} }
void
generic_packetizer_c::fix_headers() {
int idx;
if (htrack_type == track_audio)
idx = 0;
else if (htrack_type == track_video)
idx = 1;
else
idx = 2;
if (default_tracks[idx] == hserialno)
*(static_cast<EbmlUInteger *>
(&GetChild<KaxTrackFlagDefault>(*track_entry))) = 1;
else
*(static_cast<EbmlUInteger *>
(&GetChild<KaxTrackFlagDefault>(*track_entry))) = 0;
}
void void
generic_packetizer_c::add_packet(memory_c &mem, generic_packetizer_c::add_packet(memory_c &mem,
int64_t timecode, int64_t timecode,

View File

@ -296,6 +296,7 @@ protected:
// by set_headers(). // by set_headers().
int hserialno, htrack_type, htrack_min_cache, htrack_max_cache; int hserialno, htrack_type, htrack_min_cache, htrack_max_cache;
int64_t htrack_default_duration; int64_t htrack_default_duration;
bool default_track_warning_printed;
uint32_t huid; uint32_t huid;
char *hcodec_id; char *hcodec_id;
@ -364,6 +365,7 @@ public:
return free_refs; return free_refs;
} }
virtual void set_headers(); virtual void set_headers();
virtual void fix_headers();
virtual int process(memory_c &mem, virtual int process(memory_c &mem,
int64_t timecode = -1, int64_t length = -1, int64_t timecode = -1, int64_t length = -1,
int64_t bref = -1, int64_t fref = -1) = 0; int64_t bref = -1, int64_t fref = -1) = 0;