mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-12-24 20:01:53 +00:00
Made chapter selection based on a timeframe public.
This commit is contained in:
parent
c2010e1a65
commit
0d7fe88692
@ -601,6 +601,38 @@ bool probe_xml_chapters(mm_text_io_c *in) {
|
||||
return false;
|
||||
}
|
||||
|
||||
KaxChapters *select_chapters_in_timeframe(KaxChapters *chapters,
|
||||
int64_t min_tc, int64_t max_tc,
|
||||
int64_t offset, bool validate) {
|
||||
uint32_t i;
|
||||
KaxEditionEntry *eentry;
|
||||
|
||||
for (i = 0; i < chapters->ListSize(); i++) {
|
||||
if (validate)
|
||||
validate_chapters(0, -1, *static_cast<EbmlMaster *>((*chapters)[i]));
|
||||
remove_entries(min_tc, max_tc, offset,
|
||||
*static_cast<EbmlMaster *>((*chapters)[i]));
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (i < chapters->ListSize()) {
|
||||
eentry = static_cast<KaxEditionEntry *>((*chapters)[i]);
|
||||
if (eentry->ListSize() == 0) {
|
||||
chapters->Remove(i);
|
||||
delete eentry;
|
||||
|
||||
} else
|
||||
i++;
|
||||
}
|
||||
|
||||
if (chapters->ListSize() == 0) {
|
||||
delete chapters;
|
||||
chapters = NULL;
|
||||
}
|
||||
|
||||
return chapters;
|
||||
}
|
||||
|
||||
KaxChapters *parse_xml_chapters(mm_text_io_c *in, int64_t min_tc,
|
||||
int64_t max_tc, int64_t offset) {
|
||||
bool done;
|
||||
@ -608,10 +640,8 @@ KaxChapters *parse_xml_chapters(mm_text_io_c *in, int64_t min_tc,
|
||||
XML_Parser parser;
|
||||
XML_Error xerror;
|
||||
char *emsg;
|
||||
int i;
|
||||
string buffer;
|
||||
KaxChapters *chapters;
|
||||
KaxEditionEntry *eentry;
|
||||
|
||||
done = 0;
|
||||
|
||||
@ -650,29 +680,9 @@ KaxChapters *parse_xml_chapters(mm_text_io_c *in, int64_t min_tc,
|
||||
|
||||
chapters = pdata->chapters;
|
||||
if (chapters != NULL) {
|
||||
|
||||
for (i = 0; i < chapters->ListSize(); i++) {
|
||||
validate_chapters(0, -1, *static_cast<EbmlMaster *>((*chapters)[i]));
|
||||
remove_entries(min_tc, max_tc, offset,
|
||||
*static_cast<EbmlMaster *>((*chapters)[i]));
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (i < chapters->ListSize()) {
|
||||
eentry = static_cast<KaxEditionEntry *>((*chapters)[i]);
|
||||
if (eentry->ListSize() == 0) {
|
||||
chapters->Remove(i);
|
||||
delete eentry;
|
||||
|
||||
} else
|
||||
i++;
|
||||
}
|
||||
|
||||
if (chapters->ListSize() == 0) {
|
||||
delete chapters;
|
||||
chapters = NULL;
|
||||
|
||||
} else if (!chapters->CheckMandatory())
|
||||
chapters = select_chapters_in_timeframe(chapters, min_tc, max_tc, offset,
|
||||
true);
|
||||
if ((chapters != NULL) && !chapters->CheckMandatory())
|
||||
die("chapters->CheckMandatory() failed. Should not have happened!");
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,9 @@ void write_chapters_xml(KaxChapters *chapters, FILE *out);
|
||||
void write_chapters_simple(int &chapter_num, KaxChapters *chapters, FILE *out);
|
||||
|
||||
KaxChapters *copy_chapters(KaxChapters *source);
|
||||
KaxChapters *select_chapters_in_timeframe(KaxChapters *chapters,
|
||||
int64_t min_tc, int64_t max_tc,
|
||||
int64_t offset, bool validate);
|
||||
|
||||
#endif // __CHAPTERS_H
|
||||
|
||||
|
@ -1900,8 +1900,9 @@ void finish_file() {
|
||||
start = cluster_helper->get_first_timecode() + offset;
|
||||
end = cluster_helper->get_max_timecode() + offset;
|
||||
|
||||
chapters_here = parse_chapters(chapter_file_name, start, end, offset,
|
||||
chapter_language, chapter_charset);
|
||||
chapters_here = copy_chapters(kax_chapters);
|
||||
chapters_here = select_chapters_in_timeframe(chapters_here, start, end,
|
||||
offset, false);
|
||||
if (chapters_here != NULL)
|
||||
kax_chapters_void->ReplaceWith(*chapters_here, *out, true);
|
||||
delete kax_chapters_void;
|
||||
|
Loading…
Reference in New Issue
Block a user