mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-12-24 11:54:01 +00:00
Properly handle the default track flags, even when reading Matroska files.
This commit is contained in:
parent
967bd1090a
commit
6368102c5e
@ -1,5 +1,8 @@
|
||||
2004-01-12 Moritz Bunkus <moritz@bunkus.org>
|
||||
|
||||
* mkvmerge: bug fix: The default track flags could not be
|
||||
overriden on the command line when reading Matroska files.
|
||||
|
||||
* Windows binaries after v0.8.1 require a new runtime DLL
|
||||
archive. Please download it from
|
||||
http://www.bunkus.org/videotools/mkvtoolnix/ Thanks.
|
||||
|
@ -82,6 +82,8 @@ using namespace std;
|
||||
using namespace libmatroska;
|
||||
|
||||
#define PFX "matroska_reader: "
|
||||
#define MAP_TRACK_TYPE(c) ((c) == 'a' ? track_audio : \
|
||||
(c) == 'v' ? track_video : track_subtitle)
|
||||
|
||||
// }}}
|
||||
|
||||
@ -1247,8 +1249,6 @@ void kax_reader_c::create_packetizer(int64_t tid) {
|
||||
nti->private_data =
|
||||
(unsigned char *)safememdup(t->private_data, t->private_size);
|
||||
nti->private_size = t->private_size;
|
||||
if (nti->default_track == 0)
|
||||
nti->default_track = t->default_track;
|
||||
if (nti->language == NULL)
|
||||
nti->language = safestrdup(t->language);
|
||||
if (nti->track_name == NULL)
|
||||
@ -1447,6 +1447,9 @@ void kax_reader_c::create_packetizer(int64_t tid) {
|
||||
mxerror(PFX "Unsupported track type for track %d.\n", t->tnum);
|
||||
break;
|
||||
}
|
||||
if (t->default_track)
|
||||
t->packetizer->set_as_default_track(MAP_TRACK_TYPE(t->type),
|
||||
DEFAULT_TRACK_PRIORITY_FROM_SOURCE);
|
||||
if (t->tuid != 0)
|
||||
if (!t->packetizer->set_uid(t->tuid))
|
||||
mxwarn(PFX "Could not keep the track UID %u because it is already "
|
||||
|
@ -152,7 +152,7 @@ bool dump_splitpoints = false;
|
||||
bool use_timeslices = false, use_durations = false;
|
||||
|
||||
float video_fps = -1.0;
|
||||
int default_tracks[3];
|
||||
int default_tracks[3], default_tracks_priority[3];
|
||||
|
||||
bool identifying = false, identify_verbose = false;
|
||||
|
||||
@ -1924,9 +1924,8 @@ static void init_globals() {
|
||||
kax_sh_cues = NULL;
|
||||
kax_sh_void = NULL;
|
||||
video_fps = -1.0;
|
||||
default_tracks[0] = 0;
|
||||
default_tracks[1] = 0;
|
||||
default_tracks[2] = 0;
|
||||
memset(default_tracks, 0, sizeof(default_tracks));
|
||||
memset(default_tracks_priority, 0, sizeof(default_tracks_priority));
|
||||
display_counter = 1;
|
||||
display_reader = NULL;
|
||||
clear_list_of_unique_uint32();
|
||||
|
@ -71,7 +71,7 @@ extern int pass, file_num;
|
||||
extern bool fast_mode;
|
||||
|
||||
extern int max_ms_per_cluster, max_blocks_per_cluster;
|
||||
extern int default_tracks[3];
|
||||
extern int default_tracks[3], default_tracks_priority[3];
|
||||
extern int64_t split_after;
|
||||
extern int split_max_num_files;
|
||||
extern bool split_by_time;
|
||||
|
@ -316,9 +316,9 @@ void generic_packetizer_c::set_track_type(int type) {
|
||||
htrack_type = type;
|
||||
|
||||
if (ti->default_track)
|
||||
force_default_track(type);
|
||||
set_as_default_track(type, DEFAULT_TRACK_PRIORITY_CMDLINE);
|
||||
else
|
||||
set_as_default_track(type);
|
||||
set_as_default_track(type, DEFAULT_TRACK_PRIORITY_FROM_TYPE);
|
||||
}
|
||||
|
||||
int generic_packetizer_c::get_track_type() {
|
||||
@ -472,7 +472,7 @@ void generic_packetizer_c::set_video_aspect_ratio(float ar) {
|
||||
ti->aspect_ratio = ar;
|
||||
}
|
||||
|
||||
void generic_packetizer_c::set_as_default_track(int type) {
|
||||
void generic_packetizer_c::set_as_default_track(int type, int priority) {
|
||||
int idx;
|
||||
|
||||
idx = 0;
|
||||
@ -486,30 +486,14 @@ void generic_packetizer_c::set_as_default_track(int type) {
|
||||
die("pr_generic.cpp/generic_packetizer_c::set_as_default_track(): Unknown "
|
||||
"track type %d.", type);
|
||||
|
||||
if (default_tracks[idx] == 0)
|
||||
default_tracks[idx] = -1 * hserialno;
|
||||
}
|
||||
|
||||
void generic_packetizer_c::force_default_track(int type) {
|
||||
int idx;
|
||||
|
||||
idx = 0;
|
||||
if (type == track_audio)
|
||||
idx = 0;
|
||||
else if (type == track_video)
|
||||
idx = 1;
|
||||
else if (type == track_subtitle)
|
||||
idx = 2;
|
||||
else
|
||||
die("pr_generic.cpp/generic_packetizer_c::force_default_track(): Unknown "
|
||||
"track type %d.", type);
|
||||
|
||||
if ((default_tracks[idx] > 0) && !identifying)
|
||||
mxwarn("Another default track for %s tracks has already "
|
||||
"been set. Not setting the 'default' flag for this track.\n",
|
||||
idx == 0 ? "audio" : idx == 'v' ? "video" : "subtitle");
|
||||
else
|
||||
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 "
|
||||
"been set. Not setting the 'default' flag for track %lld of "
|
||||
"'%s'.\n", idx == 0 ? "audio" : idx == 'v' ? "video" : "subtitle",
|
||||
ti->id, ti->fname);
|
||||
}
|
||||
|
||||
void generic_packetizer_c::set_language(const char *language) {
|
||||
@ -580,8 +564,7 @@ void generic_packetizer_c::set_headers() {
|
||||
else
|
||||
idx = 2;
|
||||
|
||||
if ((default_tracks[idx] == hserialno) ||
|
||||
(default_tracks[idx] == -1 * hserialno))
|
||||
if (default_tracks[idx] == hserialno)
|
||||
*(static_cast<EbmlUInteger *>
|
||||
(&GetChild<KaxTrackFlagDefault>(*track_entry))) = 1;
|
||||
else
|
||||
|
@ -56,6 +56,11 @@ enum copy_packet_mode_t {
|
||||
cp_no
|
||||
};
|
||||
|
||||
#define DEFAULT_TRACK_PRIOIRTY_NONE 0
|
||||
#define DEFAULT_TRACK_PRIORITY_FROM_TYPE 10
|
||||
#define DEFAULT_TRACK_PRIORITY_FROM_SOURCE 50
|
||||
#define DEFAULT_TRACK_PRIORITY_CMDLINE 255
|
||||
|
||||
typedef struct {
|
||||
KaxBlockGroup *group;
|
||||
KaxBlock *block;
|
||||
@ -273,8 +278,7 @@ public:
|
||||
virtual void set_video_display_height(int height);
|
||||
virtual void set_video_aspect_ratio(float ar);
|
||||
|
||||
virtual void set_as_default_track(int type);
|
||||
virtual void force_default_track(int type);
|
||||
virtual void set_as_default_track(int type, int priority);
|
||||
|
||||
virtual void set_tag_track_uid();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user