From 469b69f5c02854f2227da9a9234f54ab09dc48fa Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 4 Oct 2004 19:18:25 +0000 Subject: [PATCH] Added a new warning if there is no corresponding track in a source file for a track UID used on the command line. --- ChangeLog | 8 +++++ src/input/r_avi.cpp | 9 ++++++ src/input/r_avi.h | 1 + src/input/r_matroska.cpp | 8 +++++ src/input/r_matroska.h | 1 + src/input/r_ogm.cpp | 9 ++++++ src/input/r_ogm.h | 1 + src/input/r_qtmp4.cpp | 8 +++++ src/input/r_qtmp4.h | 1 + src/input/r_real.cpp | 8 +++++ src/input/r_real.h | 1 + src/input/r_vobsub.cpp | 8 +++++ src/input/r_vobsub.h | 1 + src/pr_generic.cpp | 67 ++++++++++++++++++++++++++++++++++++++-- src/pr_generic.h | 5 +++ 15 files changed, 134 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index f20400070..2c550a09e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-10-04 Moritz Bunkus + + * mkvmerge: new feature: Added two warnings. One about invalid + track IDs that were used on the command line but that don't + correspond to an available track in a file and one if no track + will be copied from a source file. Both warnings hint at bad + command line arguments. + 2004-10-03 Moritz Bunkus * mkvmerge: Only write the segment duration as a 64bit float if diff --git a/src/input/r_avi.cpp b/src/input/r_avi.cpp index e455ee966..c971e303e 100644 --- a/src/input/r_avi.cpp +++ b/src/input/r_avi.cpp @@ -607,4 +607,13 @@ avi_reader_c::identify() { } } +void +avi_reader_c::add_available_track_ids() { + int i; + + // Yes, this is correct. Don't forget the video track! + for (i = 0; i <= AVI_audio_tracks(avi); i++) + available_track_ids.push_back(i); +} + // }}} diff --git a/src/input/r_avi.h b/src/input/r_avi.h index 6a3fa04fc..b6f773977 100644 --- a/src/input/r_avi.h +++ b/src/input/r_avi.h @@ -62,6 +62,7 @@ public: virtual void identify(); virtual void create_packetizers(); virtual void create_packetizer(int64_t tid); + virtual void add_available_track_ids(); static int probe_file(mm_io_c *mm_io, int64_t size); diff --git a/src/input/r_matroska.cpp b/src/input/r_matroska.cpp index 875506679..93a4a2e82 100644 --- a/src/input/r_matroska.cpp +++ b/src/input/r_matroska.cpp @@ -2194,3 +2194,11 @@ kax_reader_c::flush_packetizers() { PTZR(tracks[i]->ptzr)->flush(); } +void +kax_reader_c::add_available_track_ids() { + int i; + + for (i = 0; i < tracks.size(); i++) + available_track_ids.push_back(tracks[i]->tnum); +} + diff --git a/src/input/r_matroska.h b/src/input/r_matroska.h index d0f0a3c30..0586108a0 100644 --- a/src/input/r_matroska.h +++ b/src/input/r_matroska.h @@ -142,6 +142,7 @@ public: virtual void create_packetizers(); virtual void create_packetizer(int64_t tid); virtual void add_attachments(KaxAttachments *a); + virtual void add_available_track_ids(); static int probe_file(mm_io_c *mm_io, int64_t size); diff --git a/src/input/r_ogm.cpp b/src/input/r_ogm.cpp index 47b5c03b1..1be0beff2 100644 --- a/src/input/r_ogm.cpp +++ b/src/input/r_ogm.cpp @@ -1247,3 +1247,12 @@ ogm_reader_c::handle_stream_comments() { free_string_array(comments); } } + +void +ogm_reader_c::add_available_track_ids() { + int i; + + for (i = 0; i < sdemuxers.size(); i++) + available_track_ids.push_back(i); +} + diff --git a/src/input/r_ogm.h b/src/input/r_ogm.h index ca80d2b1e..18733f25d 100644 --- a/src/input/r_ogm.h +++ b/src/input/r_ogm.h @@ -110,6 +110,7 @@ public: virtual void identify(); virtual void create_packetizers(); virtual void create_packetizer(int64_t tid); + virtual void add_available_track_ids(); virtual int display_priority(); virtual void display_progress(bool final = false); diff --git a/src/input/r_qtmp4.cpp b/src/input/r_qtmp4.cpp index 6674c4b69..1684ba7ca 100644 --- a/src/input/r_qtmp4.cpp +++ b/src/input/r_qtmp4.cpp @@ -1274,3 +1274,11 @@ qtmp4_reader_c::flush_packetizers() { if (demuxers[i]->ptzr != -1) PTZR(demuxers[i]->ptzr)->flush(); } + +void +qtmp4_reader_c::add_available_track_ids() { + int i; + + for (i =0 ; i < demuxers.size(); i++) + available_track_ids.push_back(demuxers[i]->id); +} diff --git a/src/input/r_qtmp4.h b/src/input/r_qtmp4.h index 7cf29c007..e429446e0 100644 --- a/src/input/r_qtmp4.h +++ b/src/input/r_qtmp4.h @@ -126,6 +126,7 @@ public: virtual void identify(); virtual void create_packetizers(); virtual void create_packetizer(int64_t tid); + virtual void add_available_track_ids(); static int probe_file(mm_io_c *in, int64_t size); diff --git a/src/input/r_real.cpp b/src/input/r_real.cpp index d54cb1f3d..d4af33225 100644 --- a/src/input/r_real.cpp +++ b/src/input/r_real.cpp @@ -803,3 +803,11 @@ real_reader_c::flush_packetizers() { if (demuxers[i]->ptzr != -1) PTZR(demuxers[i]->ptzr)->flush(); } + +void +real_reader_c::add_available_track_ids() { + int i; + + for (i = 0; i < demuxers.size(); i++) + available_track_ids.push_back(demuxers[i]->track->id); +} diff --git a/src/input/r_real.h b/src/input/r_real.h index 661f8ed78..344ff5855 100644 --- a/src/input/r_real.h +++ b/src/input/r_real.h @@ -74,6 +74,7 @@ public: virtual void identify(); virtual void create_packetizers(); virtual void create_packetizer(int64_t tid); + virtual void add_available_track_ids(); static int probe_file(mm_io_c *mm_io, int64_t size); diff --git a/src/input/r_vobsub.cpp b/src/input/r_vobsub.cpp index 15ce0af3f..4ec37c1c7 100644 --- a/src/input/r_vobsub.cpp +++ b/src/input/r_vobsub.cpp @@ -612,3 +612,11 @@ vobsub_reader_c::flush_packetizers() { if (tracks[i]->ptzr != -1) PTZR(tracks[i]->ptzr)->flush(); } + +void +vobsub_reader_c::add_available_track_ids() { + int i; + + for (i = 0; i < tracks.size(); i++) + available_track_ids.push_back(i); +} diff --git a/src/input/r_vobsub.h b/src/input/r_vobsub.h index ac942eb10..5c9d34bba 100644 --- a/src/input/r_vobsub.h +++ b/src/input/r_vobsub.h @@ -76,6 +76,7 @@ public: virtual void identify(); virtual void create_packetizers(); virtual void create_packetizer(int64_t tid); + virtual void add_available_track_ids(); static int probe_file(mm_io_c *mm_io, int64_t size); diff --git a/src/pr_generic.cpp b/src/pr_generic.cpp index b6e9dccbe..a9fc98ae5 100644 --- a/src/pr_generic.cpp +++ b/src/pr_generic.cpp @@ -951,8 +951,8 @@ generic_packetizer_c::parse_ext_timecode_file_v1(mm_io_c *in, line_no = 1; do { if (!in->getline2(line)) - mxerror(_("The timecode file '%s' does not contain a valid 'Assume' line " - "with the default number of frames per second.\n"), name); + mxerror(_("The timecode file '%s' does not contain a valid 'Assume' line" + " with the default number of frames per second.\n"), name); line_no++; strip(line); if ((line.length() != 0) && (line[0] != '#')) @@ -1205,10 +1205,37 @@ generic_packetizer_c::handle_avi_audio_sync(int64_t num_bytes, //-------------------------------------------------------------------- +#define add_all_requested_track_ids(container) \ + for (i = 0; i < ti->container->size(); i++) \ + add_requested_track_id((*ti->container)[i].id); +#define add_all_requested_track_ids2(container) \ + for (i = 0; i < ti->container->size(); i++) \ + add_requested_track_id((*ti->container)[i]); + generic_reader_c::generic_reader_c(track_info_c *nti) { + int i; + ti = new track_info_c(*nti); connected_to = NULL; max_timecode_seen = 0; + + add_all_requested_track_ids2(atracks); + add_all_requested_track_ids2(vtracks); + add_all_requested_track_ids2(stracks); + add_all_requested_track_ids(all_fourccs); + add_all_requested_track_ids(display_properties); + add_all_requested_track_ids(audio_syncs); + add_all_requested_track_ids(cue_creations); + add_all_requested_track_ids2(default_track_flags); + add_all_requested_track_ids(languages); + add_all_requested_track_ids(sub_charsets); + add_all_requested_track_ids(all_tags); + add_all_requested_track_ids2(aac_is_sbr); + add_all_requested_track_ids(packet_delays); + add_all_requested_track_ids(compression_list); + add_all_requested_track_ids(track_names); + add_all_requested_track_ids(all_ext_timecodes); + add_all_requested_track_ids(pixel_crop_list); } generic_reader_c::~generic_reader_c() { @@ -1316,9 +1343,45 @@ generic_reader_c::display_progress(bool) { void generic_reader_c::check_track_ids_and_packetizers() { + int r, a; + bool found; + + add_available_track_ids(); if (reader_packetizers.size() == 0) mxwarn(FMT_FN "No tracks will be copied from this file. This usually " "indicates a mistake in the command line.\n", ti->fname); + + for (r = 0; r < requested_track_ids.size(); r++) { + found = false; + for (a = 0; a < available_track_ids.size(); a++) + if (requested_track_ids[r] == available_track_ids[a]) { + found = true; + break; + } + + if (!found) + mxwarn(FMT_FN "A track with the ID %lld was requested but not found " + "in the file. The corresponding option will be ignored.\n", + ti->fname, requested_track_ids[r]); + } +} + +void +generic_reader_c::add_requested_track_id(int64_t id) { + int i; + bool found; + + if (id == -1) + return; + + found = false; + for (i = 0; i < requested_track_ids.size(); i++) + if (requested_track_ids[i] == id) { + found = true; + break; + } + if (!found) + requested_track_ids.push_back(id); } // diff --git a/src/pr_generic.h b/src/pr_generic.h index 87ae13649..0a3b66c39 100644 --- a/src/pr_generic.h +++ b/src/pr_generic.h @@ -262,6 +262,7 @@ class generic_reader_c { public: track_info_c *ti; vector reader_packetizers; + vector requested_track_ids, available_track_ids; generic_reader_c *connected_to; int64_t max_timecode_seen; @@ -287,6 +288,10 @@ public: virtual void set_timecode_offset(int64_t offset); virtual void check_track_ids_and_packetizers(); + virtual void add_requested_track_id(int64_t id); + virtual void add_available_track_ids() { + available_track_ids.push_back(0); + } protected: virtual bool demuxing_requested(char type, int64_t id);