mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-12-24 11:54:01 +00:00
The OGM reader uses a memory file as temporary storage for the chapters and not a file on disc.
This commit is contained in:
parent
b9da49770a
commit
d088d6de07
@ -264,18 +264,38 @@ parse_chapters(const string &file_name,
|
|||||||
bool *is_simple_format,
|
bool *is_simple_format,
|
||||||
KaxTags **tags) {
|
KaxTags **tags) {
|
||||||
mm_text_io_c *in;
|
mm_text_io_c *in;
|
||||||
|
KaxChapters *result;
|
||||||
|
|
||||||
in = NULL;
|
in = NULL;
|
||||||
|
result = NULL;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
in = new mm_text_io_c(new mm_file_io_c(file_name));
|
in = new mm_text_io_c(new mm_file_io_c(file_name));
|
||||||
|
result = parse_chapters(in, min_tc, max_tc, offset, language, charset,
|
||||||
|
exception_on_error, is_simple_format, tags);
|
||||||
|
delete in;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
if (in != NULL)
|
||||||
|
delete in;
|
||||||
if (exception_on_error)
|
if (exception_on_error)
|
||||||
throw error_c(mxsprintf("Could not open '%s' for reading.\n",
|
throw error_c(mxsprintf("Could not open '%s' for reading.\n",
|
||||||
file_name.c_str()));
|
file_name.c_str()));
|
||||||
else
|
else
|
||||||
mxerror("Could not open '%s' for reading.\n", file_name.c_str());
|
mxerror("Could not open '%s' for reading.\n", file_name.c_str());
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
KaxChapters *
|
||||||
|
parse_chapters(mm_text_io_c *in,
|
||||||
|
int64_t min_tc,
|
||||||
|
int64_t max_tc,
|
||||||
|
int64_t offset,
|
||||||
|
const string &language,
|
||||||
|
const string &charset,
|
||||||
|
bool exception_on_error,
|
||||||
|
bool *is_simple_format,
|
||||||
|
KaxTags **tags) {
|
||||||
try {
|
try {
|
||||||
if (probe_simple_chapters(in)) {
|
if (probe_simple_chapters(in)) {
|
||||||
if (is_simple_format != NULL)
|
if (is_simple_format != NULL)
|
||||||
@ -294,11 +314,9 @@ parse_chapters(const string &file_name,
|
|||||||
return parse_xml_chapters(in, min_tc, max_tc, offset,
|
return parse_xml_chapters(in, min_tc, max_tc, offset,
|
||||||
exception_on_error);
|
exception_on_error);
|
||||||
|
|
||||||
delete in;
|
|
||||||
|
|
||||||
throw error_c(mxsprintf("Unknown file format for '%s'. It does not "
|
throw error_c(mxsprintf("Unknown file format for '%s'. It does not "
|
||||||
"contain a support chapter format.\n",
|
"contain a support chapter format.\n",
|
||||||
file_name.c_str()));
|
in->get_file_name().c_str()));
|
||||||
} catch (error_c e) {
|
} catch (error_c e) {
|
||||||
if (exception_on_error)
|
if (exception_on_error)
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -42,6 +42,15 @@ parse_chapters(const string &file_name, int64_t min_tc = 0,
|
|||||||
bool *is_simple_format = NULL,
|
bool *is_simple_format = NULL,
|
||||||
KaxTags **tags = NULL);
|
KaxTags **tags = NULL);
|
||||||
|
|
||||||
|
KaxChapters *MTX_DLL_API
|
||||||
|
parse_chapters(mm_text_io_c *io, int64_t min_tc = 0,
|
||||||
|
int64_t max_tc = -1, int64_t offset = 0,
|
||||||
|
const string &language = "",
|
||||||
|
const string &charset = "",
|
||||||
|
bool exception_on_error = false,
|
||||||
|
bool *is_simple_format = NULL,
|
||||||
|
KaxTags **tags = NULL);
|
||||||
|
|
||||||
bool MTX_DLL_API probe_xml_chapters(mm_text_io_c *in);
|
bool MTX_DLL_API probe_xml_chapters(mm_text_io_c *in);
|
||||||
KaxChapters *MTX_DLL_API parse_xml_chapters(mm_text_io_c *in, int64_t min_tc,
|
KaxChapters *MTX_DLL_API parse_xml_chapters(mm_text_io_c *in, int64_t min_tc,
|
||||||
int64_t max_tc, int64_t offset,
|
int64_t max_tc, int64_t offset,
|
||||||
|
@ -1088,11 +1088,11 @@ void
|
|||||||
ogm_reader_c::handle_stream_comments() {
|
ogm_reader_c::handle_stream_comments() {
|
||||||
int i, j;
|
int i, j;
|
||||||
ogm_demuxer_t *dmx;
|
ogm_demuxer_t *dmx;
|
||||||
char **comments, name[100];
|
char **comments;
|
||||||
const char *iso639_2;
|
const char *iso639_2;
|
||||||
vector<string> comment;
|
vector<string> comment;
|
||||||
vector<char *> chapters;
|
vector<char *> chapters;
|
||||||
mm_io_c *out;
|
mm_mem_io_c *out;
|
||||||
bool comments_in_utf8;
|
bool comments_in_utf8;
|
||||||
|
|
||||||
for (i = 0; i < sdemuxers.size(); i++) {
|
for (i = 0; i < sdemuxers.size(); i++) {
|
||||||
@ -1176,25 +1176,20 @@ ogm_reader_c::handle_stream_comments() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((chapters.size() > 0) && !ti->no_chapters && (kax_chapters == NULL)) {
|
if ((chapters.size() > 0) && !ti->no_chapters && (kax_chapters == NULL)) {
|
||||||
#if defined(SYS_WINDOWS)
|
out = NULL;
|
||||||
sprintf(name, "mkvmerge-ogm-reader-chapters-%d-%d",
|
|
||||||
(int)GetCurrentProcessId(), (int)time(NULL));
|
|
||||||
#else
|
|
||||||
sprintf(name, "mkvmerge-ogm-reader-chapters-%d-%d", getpid(),
|
|
||||||
(int)time(NULL));
|
|
||||||
#endif
|
|
||||||
try {
|
try {
|
||||||
out = new mm_file_io_c(name, MODE_WRITE);
|
out = new mm_mem_io_c(NULL, 0, 1000);
|
||||||
out->write_bom("UTF-8");
|
out->write_bom("UTF-8");
|
||||||
for (j = 0; j < chapters.size(); j++) {
|
for (j = 0; j < chapters.size(); j++) {
|
||||||
out->puts_unl(chapters[j]);
|
out->puts_unl(chapters[j]);
|
||||||
out->puts_unl("\n");
|
out->puts_unl("\n");
|
||||||
}
|
}
|
||||||
delete out;
|
out->set_file_name(ti->fname);
|
||||||
kax_chapters = parse_chapters(name);
|
kax_chapters = parse_chapters(new mm_text_io_c(out));
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
if (out != NULL)
|
||||||
|
delete out;
|
||||||
}
|
}
|
||||||
unlink(name);
|
|
||||||
}
|
}
|
||||||
for (j = 0; j < chapters.size(); j++)
|
for (j = 0; j < chapters.size(); j++)
|
||||||
safefree(chapters[j]);
|
safefree(chapters[j]);
|
||||||
|
@ -13,8 +13,8 @@ T_012ssa:9ecbc6bdfa5dec6495f99c7a97342844:passed:20040825-175700
|
|||||||
T_013vobsubs:8983288ea21b811fbb85d2ea272ccfe5:passed:20040825-175700
|
T_013vobsubs:8983288ea21b811fbb85d2ea272ccfe5:passed:20040825-175700
|
||||||
T_014splitting_by_size:feeb1aba481b5a51d7142599359f2eac-5c639e8a08cf526d051fdf64f856c0d2:passed:20040825-175700
|
T_014splitting_by_size:feeb1aba481b5a51d7142599359f2eac-5c639e8a08cf526d051fdf64f856c0d2:passed:20040825-175700
|
||||||
T_015splitting_by_time:d0e769a906ec4eacc9c9af929add6474-c32e2d8c31e21e71f68875f2d9735565:passed:20040825-175700
|
T_015splitting_by_time:d0e769a906ec4eacc9c9af929add6474-c32e2d8c31e21e71f68875f2d9735565:passed:20040825-175700
|
||||||
T_016cuesheet:01f54d36479c8ae4b4d357607a42a967:passed:20040825-175700
|
T_016cuesheet:01f54d36479c8ae4b4d357607a42a967:failed:20040825-175700
|
||||||
T_017chapters:990b4b6b0931b7d52e589f715c919e10-4fff45a76f54708f881312aca04fd887:passed:20040825-175700
|
T_017chapters:990b4b6b0931b7d52e589f715c919e10-4fff45a76f54708f881312aca04fd887:failed:20040825-175700
|
||||||
T_018attachments:bac27359516bab4984df3021aa295213-7e8e1f17615f157db0e98fba9ad88bad:passed:20040825-175700
|
T_018attachments:bac27359516bab4984df3021aa295213-7e8e1f17615f157db0e98fba9ad88bad:passed:20040825-175700
|
||||||
T_019attachments2:8d9ba46c4edbf3daf50175f9de2f87b4-94349d68c9b7d493ec0d5a49f7291e40-8d9ba46c4edbf3daf50175f9de2f87b4-5c639e8a08cf526d051fdf64f856c0d2:passed:20040825-175700
|
T_019attachments2:8d9ba46c4edbf3daf50175f9de2f87b4-94349d68c9b7d493ec0d5a49f7291e40-8d9ba46c4edbf3daf50175f9de2f87b4-5c639e8a08cf526d051fdf64f856c0d2:passed:20040825-175700
|
||||||
T_020languages:7d853f21fe2d3e73b3ca0d29801e8d39:passed:20040825-234208
|
T_020languages:7d853f21fe2d3e73b3ca0d29801e8d39:passed:20040825-234208
|
||||||
|
Loading…
Reference in New Issue
Block a user