Merged 2394:2396, 2399

This commit is contained in:
Moritz Bunkus 2004-10-28 16:39:22 +00:00
parent 4796bb8ea0
commit a95f1f182f
26 changed files with 840 additions and 890 deletions

View File

@ -59,7 +59,7 @@ probe_cue_chapters(mm_text_io_c *in) {
return false;
}
char *cue_to_chapter_name_format = NULL;
string cue_to_chapter_name_format;
static void
cue_entries_to_chapter_name(string &performer,
@ -76,10 +76,10 @@ cue_entries_to_chapter_name(string &performer,
if (performer.length() == 0)
performer = global_performer;
if (cue_to_chapter_name_format == NULL)
if (cue_to_chapter_name_format == "")
this_char = "%p - %t";
else
this_char = cue_to_chapter_name_format;
this_char = cue_to_chapter_name_format.c_str();
next_char = this_char + 1;
while (*this_char != 0) {
if (*this_char == '%') {
@ -134,7 +134,7 @@ typedef struct {
vector<string> global_rem;
vector<string> global_comment;
vector<string> comment;
const char *language;
string language;
int line_num;
int cc_utf8;
} cue_parser_args_t;
@ -142,17 +142,10 @@ typedef struct {
static UTFstring
cue_str_internal_to_utf(cue_parser_args_t &a,
const string &s) {
if (a.do_convert) {
UTFstring wchar_string;
char *recoded_string;
recoded_string = to_utf8(a.cc_utf8, s.c_str());
wchar_string = cstrutf8_to_UTFstring(recoded_string);
safefree(recoded_string);
return wchar_string;
} else
return cstrutf8_to_UTFstring(s.c_str());
if (a.do_convert)
return cstrutf8_to_UTFstring(to_utf8(a.cc_utf8, s));
else
return cstrutf8_to_UTFstring(s);
}
static KaxTagSimple *
@ -369,8 +362,8 @@ parse_cue_chapters(mm_text_io_c *in,
int64_t min_tc,
int64_t max_tc,
int64_t offset,
const char *language,
const char *charset,
const string &language,
const string &charset,
bool exception_on_error,
KaxTags **tags) {
cue_parser_args_t a;
@ -381,14 +374,14 @@ parse_cue_chapters(mm_text_io_c *in,
if (in->get_byte_order() == BO_NONE) {
a.do_convert = true;
a.cc_utf8 = utf8_init(charset);
a.cc_utf8 = utf8_init(charset.c_str());
} else {
a.do_convert = false;
a.cc_utf8 = 0;
}
if (language == NULL)
if (language == "")
a.language = "eng";
else
a.language = language;

View File

@ -126,18 +126,17 @@ parse_simple_chapters(mm_text_io_c *in,
int64_t min_tc,
int64_t max_tc,
int64_t offset,
const char *language,
const char *charset,
const string &language,
const string &charset,
bool exception_on_error) {
KaxChapters *chaps;
KaxEditionEntry *edition;
KaxChapterAtom *atom;
KaxChapterDisplay *display;
int64_t start, hour, minute, second, msecs;
string name, line;
string name, line, use_language;
int mode, num, cc_utf8;
bool do_convert;
char *recoded_string;
UTFstring wchar_string;
in->setFilePointer(0);
@ -160,17 +159,18 @@ parse_simple_chapters(mm_text_io_c *in,
if (in->get_byte_order() == BO_NONE) {
do_convert = true;
cc_utf8 = utf8_init(charset);
cc_utf8 = utf8_init(charset.c_str());
} else
do_convert = false;
if (language == NULL) {
if (language == "") {
if (default_chapter_language.length() > 0)
language = default_chapter_language.c_str();
use_language = default_chapter_language;
else
language = "eng";
}
use_language = "eng";
} else
use_language = language;
try {
while (in->getline2(line)) {
@ -181,10 +181,10 @@ parse_simple_chapters(mm_text_io_c *in,
if (mode == 0) {
if (!ischapterline(line.c_str()))
chapter_error("'%s' is not a CHAPTERxx=... line.", line.c_str());
parse_int(line.substr(10, 2).c_str(), hour);
parse_int(line.substr(13, 2).c_str(), minute);
parse_int(line.substr(16, 2).c_str(), second);
parse_int(line.substr(19, 3).c_str(), msecs);
parse_int(line.substr(10, 2), hour);
parse_int(line.substr(13, 2), minute);
parse_int(line.substr(16, 2), second);
parse_int(line.substr(19, 3), msecs);
if (hour > 23)
chapter_error("Invalid hour: %d", hour);
if (minute > 59)
@ -217,17 +217,15 @@ parse_simple_chapters(mm_text_io_c *in,
display = &GetChild<KaxChapterDisplay>(*atom);
if (do_convert) {
recoded_string = to_utf8(cc_utf8, name.c_str());
wchar_string = cstrutf8_to_UTFstring(recoded_string);
safefree(recoded_string);
} else
wchar_string = cstrutf8_to_UTFstring(name.c_str());
if (do_convert)
wchar_string = cstrutf8_to_UTFstring(to_utf8(cc_utf8, name));
else
wchar_string = cstrutf8_to_UTFstring(name);
*static_cast<EbmlUnicodeString *>
(&GetChild<KaxChapterString>(*display)) = wchar_string;
*static_cast<EbmlString *>(&GetChild<KaxChapterLanguage>(*display)) =
language;
use_language;
if (default_chapter_country.length() > 0)
*static_cast<EbmlString *>
@ -257,12 +255,12 @@ parse_simple_chapters(mm_text_io_c *in,
// }}}
KaxChapters *
parse_chapters(const char *file_name,
parse_chapters(const string &file_name,
int64_t min_tc,
int64_t max_tc,
int64_t offset,
const char *language,
const char *charset,
const string &language,
const string &charset,
bool exception_on_error,
bool *is_simple_format,
KaxTags **tags) {
@ -273,10 +271,10 @@ parse_chapters(const char *file_name,
in = new mm_text_io_c(file_name);
} catch (...) {
if (exception_on_error)
throw error_c(string("Could not open '") + string(file_name) +
string("' for reading.\n"));
throw error_c(mxsprintf("Could not open '%s' for reading.\n",
file_name.c_str()));
else
mxerror("Could not open '%s' for reading.\n", file_name);
mxerror("Could not open '%s' for reading.\n", file_name.c_str());
}
try {
@ -299,9 +297,9 @@ parse_chapters(const char *file_name,
delete in;
throw error_c(string("Unknown file format for '") + string(file_name) +
string("'. It does not contain a supported chapter "
"format.\n"));
throw error_c(mxsprintf("Unknown file format for '%s'. It does not "
"contain a support chapter format.\n",
file_name.c_str()));
} catch (error_c e) {
if (exception_on_error)
throw e;

View File

@ -34,10 +34,10 @@ using namespace libebml;
using namespace libmatroska;
KaxChapters *MTX_DLL_API
parse_chapters(const char *file_name, int64_t min_tc = 0,
parse_chapters(const string &file_name, int64_t min_tc = 0,
int64_t max_tc = -1, int64_t offset = 0,
const char *language = NULL,
const char *charset = NULL,
const string &language = "",
const string &charset = "",
bool exception_on_error = false,
bool *is_simple_format = NULL,
KaxTags **tags = NULL);
@ -51,15 +51,15 @@ bool MTX_DLL_API probe_simple_chapters(mm_text_io_c *in);
KaxChapters *MTX_DLL_API
parse_simple_chapters(mm_text_io_c *in, int64_t min_tc,
int64_t max_tc, int64_t offset,
const char *language, const char *charset,
const string &language, const string &charset,
bool exception_on_error = false);
extern char *MTX_DLL_API cue_to_chapter_name_format;
extern string MTX_DLL_API cue_to_chapter_name_format;
bool MTX_DLL_API probe_cue_chapters(mm_text_io_c *in);
KaxChapters *MTX_DLL_API parse_cue_chapters(mm_text_io_c *in, int64_t min_tc,
int64_t max_tc, int64_t offset,
const char *language,
const char *charset,
const string &language,
const string &charset,
bool exception_on_error = false,
KaxTags **tags = NULL);

View File

@ -69,12 +69,12 @@ bitvalue_c::bitvalue_c(const bitvalue_c &src) {
#define upperchar(c) (((c) >= 'a') ? ((c) - 'a' + 'A') : (c))
#define hextodec(c) (isdigit(c) ? ((c) - '0') : ((c) - 'A' + 10))
bitvalue_c::bitvalue_c(const char *s,
bitvalue_c::bitvalue_c(string s,
int allowed_bitlength) {
int len, i;
string s2;
len = strlen(s);
len = s.size();
if (len < 2)
throw exception();
@ -94,8 +94,8 @@ bitvalue_c::bitvalue_c(const char *s,
i++;
}
}
s = s2.c_str();
len = strlen(s);
s = s2;
len = s.size();
}
if ((len % 2) == 1)
@ -552,7 +552,7 @@ utf8_init(const char *charset) {
lc_charset = "CP" + to_string(GetACP());
#elif defined(SYS_SOLARIS)
lc_charset = nl_langinfo(CODESET);
if (parse_int(lc_charset.c_str(), i))
if (parse_int(lc_charset, i))
lc_charset = string("ISO") + lc_charset + string("-US");
#else
lc_charset = nl_langinfo(CODESET);
@ -627,8 +627,8 @@ convert_charset(iconv_t ict,
}
char *
to_utf8(int handle,
const char *local) {
to_utf8_c(int handle,
const char *local) {
char *copy;
if (handle == -1) {
@ -643,21 +643,22 @@ to_utf8(int handle,
return convert_charset(kax_convs[handle].ict_to_utf8, local);
}
string &
string
to_utf8(int handle,
string &local) {
const string &local) {
string s;
char *cutf8;
cutf8 = to_utf8(handle, local.c_str());
local = cutf8;
cutf8 = to_utf8_c(handle, local.c_str());
s = cutf8;
safefree(cutf8);
return local;
return s;
}
char *
from_utf8(int handle,
const char *utf8) {
from_utf8_c(int handle,
const char *utf8) {
char *copy;
if (handle == -1) {
@ -672,16 +673,17 @@ from_utf8(int handle,
return convert_charset(kax_convs[handle].ict_from_utf8, utf8);
}
string &
string
from_utf8(int handle,
string &utf8) {
const string &utf8) {
string s;
char *clocal;
clocal = from_utf8(handle, utf8.c_str());
utf8 = clocal;
clocal = from_utf8_c(handle, utf8.c_str());
s = clocal;
safefree(clocal);
return utf8;
return s;
}
/*
@ -1043,6 +1045,30 @@ starts_with_case(const string &s,
return strncasecmp(s.c_str(), start.c_str(), start.length()) == 0;
}
string
upcase(const string &s) {
string dst;
int i;
dst.reserve(s.size());
for (i = 0; i < s.size(); i++)
dst += toupper(s[i]);
return dst;
}
string
downcase(const string &s) {
string dst;
int i;
dst.reserve(s.size());
for (i = 0; i < s.size(); i++)
dst += tolower(s[i]);
return dst;
}
/*
* Integer parsing
*/

View File

@ -184,10 +184,20 @@ extern int MTX_DLL_API cc_local_utf8;
int MTX_DLL_API utf8_init(const char *charset);
void MTX_DLL_API utf8_done();
char *MTX_DLL_API to_utf8(int handle, const char *local);
char *MTX_DLL_API from_utf8(int handle, const char *utf8);
string &MTX_DLL_API to_utf8(int handle, string &local);
string &MTX_DLL_API from_utf8(int handle, string &utf8);
char *MTX_DLL_API to_utf8_c(int handle, const char *local);
inline char *
to_utf8_c(int handle,
const string &local) {
return to_utf8_c(handle, local.c_str());
}
char *MTX_DLL_API from_utf8_c(int handle, const char *utf8);
inline char *
from_utf8_c(int handle,
const string &utf8) {
return from_utf8_c(handle, utf8.c_str());
}
string MTX_DLL_API to_utf8(int handle, const string &local);
string MTX_DLL_API from_utf8(int handle, const string &utf8);
#define UNIQUE_ALL_IDS -1
#define UNIQUE_TRACK_IDS 0
@ -206,6 +216,12 @@ uint32_t MTX_DLL_API create_unique_uint32(int category);
void *MTX_DLL_API _safemalloc(size_t size, const char *file, int line);
#define safestrdup(s) _safestrdup(s, __FILE__, __LINE__)
char *MTX_DLL_API _safestrdup(const char *s, const char *file, int line);
inline char *
_safestrdup(const string &s,
const char *file,
int line) {
return _safestrdup(s.c_str(), file, line);
}
unsigned char *_safestrdup(const unsigned char *s, const char *file, int line);
#define safememdup(src, size) _safememdup(src, size, __FILE__, __LINE__)
void *MTX_DLL_API _safememdup(const void *src, size_t size, const char *file,
@ -216,6 +232,12 @@ void *MTX_DLL_API _saferealloc(void *mem, size_t size, const char *file,
vector<string> MTX_DLL_API split(const char *src, const char *pattern = ",",
int max_num = -1);
inline vector<string>
split(const string &src,
const string &pattern = string(","),
int max_num = -1) {
return split(src.c_str(), pattern.c_str(), max_num);
}
string MTX_DLL_API join(const char *pattern, vector<string> &strings);
void MTX_DLL_API strip(string &s, bool newlines = false);
void MTX_DLL_API strip(vector<string> &v, bool newlines = false);
@ -226,6 +248,8 @@ bool MTX_DLL_API starts_with(const string &s, const char *start);
bool MTX_DLL_API starts_with(const string &s, const string &start);
bool MTX_DLL_API starts_with_case(const string &s, const char *start);
bool MTX_DLL_API starts_with_case(const string &s, const string &start);
string MTX_DLL_API upcase(const string &s);
string MTX_DLL_API downcase(const string &s);
#define irnd(a) ((int64_t)((double)(a) + 0.5))
#define iabs(a) ((a) < 0 ? (a) * -1 : (a))
@ -233,6 +257,16 @@ bool MTX_DLL_API starts_with_case(const string &s, const string &start);
uint32_t MTX_DLL_API round_to_nearest_pow2(uint32_t value);
bool MTX_DLL_API parse_int(const char *s, int64_t &value);
bool MTX_DLL_API parse_int(const char *s, int &value);
inline bool
parse_int(const string &s,
int64_t &value) {
return parse_int(s.c_str(), value);
}
inline bool
parse_int(const string &s,
int &value) {
return parse_int(s.c_str(), value);
}
string MTX_DLL_API to_string(int64_t i);
bool MTX_DLL_API parse_double(const char *s, double &value);
@ -434,7 +468,7 @@ private:
public:
bitvalue_c(int nsize);
bitvalue_c(const bitvalue_c &src);
bitvalue_c(const char *s, int allowed_bitlength = -1);
bitvalue_c(string s, int allowed_bitlength = -1);
virtual ~bitvalue_c();
bitvalue_c &operator =(const bitvalue_c &src);

View File

@ -38,23 +38,21 @@ static const char *mosu_hacks[] = {
ENGAGE_FORCE_PASSTHROUGH_PACKETIZER,
NULL
};
static vector<const char *> engaged_hacks;
static vector<string> engaged_hacks;
bool
hack_engaged(const char *hack) {
uint32_t i;
hack_engaged(const string &hack) {
vector<string>::const_iterator hit;
if (hack == NULL)
return false;
for (i = 0; i < engaged_hacks.size(); i++)
if (!strcmp(engaged_hacks[i], hack))
foreach(hit, engaged_hacks)
if (*hit == hack)
return true;
return false;
}
void
engage_hacks(const char *hacks) {
engage_hacks(const string &hacks) {
vector<string> engage_args;
int aidx, hidx;
bool valid_hack;

View File

@ -18,6 +18,10 @@
#include "os.h"
#include <string>
using namespace std;
// Some hacks that are configurable via command line but which should ONLY!
// be used by the author.
#define ENGAGE_SPACE_AFTER_CHAPTERS "space_after_chapters"
@ -30,7 +34,7 @@
#define ENGAGE_NO_DEFAULT_HEADER_VALUES "no_default_header_values"
#define ENGAGE_FORCE_PASSTHROUGH_PACKETIZER "force_passthrough_packetizer"
void MTX_DLL_API engage_hacks(const char *hacks);
bool MTX_DLL_API hack_engaged(const char *hack);
void MTX_DLL_API engage_hacks(const string &hacks);
bool MTX_DLL_API hack_engaged(const string &hack);
#endif // __HACKS_H

View File

@ -34,7 +34,7 @@
using namespace std;
#if !defined(SYS_WINDOWS)
mm_io_c::mm_io_c(const char *path,
mm_io_c::mm_io_c(const string &path,
const open_mode mode) {
char *cmode;
@ -55,24 +55,24 @@ mm_io_c::mm_io_c(const char *path,
throw 0;
}
file = (FILE *)fopen(path, cmode);
file = (FILE *)fopen(path.c_str(), cmode);
if (file == NULL)
throw exception();
file_name = safestrdup(path);
file_name = path;
dos_style_newlines = false;
}
mm_io_c::mm_io_c() {
file_name = NULL;
file_name = "";
file = NULL;
dos_style_newlines = false;
}
mm_io_c::~mm_io_c() {
close();
safefree(file_name);
file_name = "";
}
uint64
@ -133,7 +133,7 @@ mm_io_c::truncate(int64_t pos) {
#else // SYS_UNIX
mm_io_c::mm_io_c(const char *path,
mm_io_c::mm_io_c(const string &path,
const open_mode mode) {
DWORD access_mode, share_mode, disposition;
@ -162,18 +162,18 @@ mm_io_c::mm_io_c(const char *path,
throw exception();
}
file = (void *)CreateFile(path, access_mode, share_mode, NULL, disposition,
0, NULL);
file = (void *)CreateFile(path.c_str(), access_mode, share_mode, NULL,
disposition, 0, NULL);
_eof = false;
if ((HANDLE)file == (HANDLE)0xFFFFFFFF)
throw exception();
file_name = safestrdup(path);
file_name = path;
dos_style_newlines = true;
}
mm_io_c::mm_io_c() {
file_name = NULL;
file_name = "";
file = NULL;
dos_style_newlines = true;
}
@ -186,6 +186,7 @@ void
mm_io_c::close() {
if (file != NULL)
CloseHandle((HANDLE)file);
file_name = "";
}
uint64
@ -300,11 +301,6 @@ mm_io_c::truncate(int64_t pos) {
#endif
const char *
mm_io_c::get_file_name() {
return file_name;
}
string
mm_io_c::getline() {
char c;
@ -346,14 +342,16 @@ mm_io_c::setFilePointer2(int64 offset, seek_mode mode) {
}
size_t
mm_io_c::puts_unl(const char *s) {
mm_io_c::puts_unl(const string &s) {
int i;
size_t bytes_written;
const char *cs;
cs = s.c_str();
bytes_written = 0;
for (i = 0; i < strlen(s); i++)
if (s[i] != '\r')
bytes_written += write(&s[i], 1);
for (i = 0; cs[i] != 0; i++)
if (cs[i] != '\r')
bytes_written += write(&cs[i], 1);
return bytes_written;
}
@ -549,7 +547,7 @@ mm_io_c::restore_pos() {
}
bool
mm_io_c::write_bom(const char *charset) {
mm_io_c::write_bom(const string &charset) {
const unsigned char utf8_bom[3] = {0xef, 0xbb, 0xbf};
const unsigned char utf16le_bom[2] = {0xff, 0xfe};
const unsigned char utf16be_bom[2] = {0xfe, 0xff};
@ -558,24 +556,24 @@ mm_io_c::write_bom(const char *charset) {
const unsigned char *bom;
int bom_len;
if (charset == NULL)
if (charset == "")
return false;
if (!strcmp(charset, "UTF-8") || !strcmp(charset, "UTF8")) {
if ((charset =="UTF-8") || (charset =="UTF8")) {
bom_len = 3;
bom = utf8_bom;
} else if (!strcmp(charset, "UTF-16") || !strcmp(charset, "UTF-16LE") ||
!strcmp(charset, "UTF16") || !strcmp(charset, "UTF16LE")) {
} else if ((charset =="UTF-16") || (charset =="UTF-16LE") ||
(charset =="UTF16") || (charset =="UTF16LE")) {
bom_len = 2;
bom = utf16le_bom;
} else if (!strcmp(charset, "UTF-16BE") || !strcmp(charset, "UTF16BE")) {
} else if ((charset =="UTF-16BE") || (charset =="UTF16BE")) {
bom_len = 2;
bom = utf16be_bom;
} else if (!strcmp(charset, "UTF-32") || !strcmp(charset, "UTF-32LE") ||
!strcmp(charset, "UTF32") || !strcmp(charset, "UTF32LE")) {
} else if ((charset =="UTF-32") || (charset =="UTF-32LE") ||
(charset =="UTF32") || (charset =="UTF32LE")) {
bom_len = 4;
bom = utf32le_bom;
} else if (!strcmp(charset, "UTF-32BE") || !strcmp(charset, "UTF32BE")) {
} else if ((charset =="UTF-32BE") || (charset =="UTF32BE")) {
bom_len = 4;
bom = utf32be_bom;
} else
@ -756,7 +754,7 @@ mm_mem_io_c::eof() {
* Class for handling UTF-8/UTF-16/UTF-32 text files.
*/
mm_text_io_c::mm_text_io_c(const char *path):
mm_text_io_c::mm_text_io_c(const string &path):
mm_io_c(path, MODE_READ) {
unsigned char buffer[4];

View File

@ -31,14 +31,14 @@ protected:
#if defined(SYS_WINDOWS)
bool _eof;
#endif
char *file_name;
string file_name;
void *file;
stack<int64_t> positions;
bool dos_style_newlines;
public:
mm_io_c();
mm_io_c(const char *path, const open_mode mode);
mm_io_c(const string &path, const open_mode mode);
virtual ~mm_io_c();
virtual uint64 getFilePointer();
@ -68,8 +68,8 @@ public:
virtual bool eof();
virtual string getline();
virtual bool getline2(string &s);
virtual size_t puts_unl(const char *s);
virtual bool write_bom(const char *charset);
virtual size_t puts_unl(const string &s);
virtual bool write_bom(const string &charset);
virtual int getch();
virtual void save_pos(int64_t new_pos = -1);
@ -77,7 +77,9 @@ public:
virtual int64_t get_size();
virtual const char *get_file_name();
virtual const string &get_file_name() {
return file_name;
}
virtual int truncate(int64_t pos);
@ -126,7 +128,7 @@ protected:
int bom_len;
public:
mm_text_io_c(const char *path);
mm_text_io_c(const string &path);
virtual void setFilePointer(int64 offset, seek_mode mode=seek_beginning);
virtual string getline();

View File

@ -395,7 +395,7 @@ parse_xml_elements(const char *parser_name,
pdata = (parser_data_t *)safemalloc(sizeof(parser_data_t));
memset(pdata, 0, sizeof(parser_data_t));
pdata->parser = parser;
pdata->file_name = in->get_file_name();
pdata->file_name = in->get_file_name().c_str();
pdata->parser_name = parser_name;
pdata->mapping = mapping;
pdata->parents = new vector<EbmlElement *>;

View File

@ -581,8 +581,8 @@ create_output_files() {
(sconv[sconv.length()- 1] != '\n'))
sconv += "\n";
from_utf8(tracks[i].conv_handle, sconv);
tracks[i].out->puts_unl(sconv.c_str());
sconv = from_utf8(tracks[i].conv_handle, sconv);
tracks[i].out->puts_unl(sconv);
} else if (tracks[i].type == TYPEFLAC) {
if (!tracks[i].embed_in_ogg)
@ -711,7 +711,7 @@ handle_data(KaxBlock *block,
s = (char *)safemalloc(data.Size() + 1);
memcpy(s, data.Buffer(), data.Size());
s[data.Size()] = 0;
s2 = from_utf8(track->conv_handle, s);
s2 = from_utf8_c(track->conv_handle, s);
safefree(s);
len = strlen(s2);
s = (char *)safemalloc(len + 3);
@ -766,7 +766,7 @@ handle_data(KaxBlock *block,
// Convert the ReadOrder entry so that we can re-order the entries
// later.
if (!parse_int(fields[0].c_str(), num)) {
if (!parse_int(fields[0], num)) {
mxwarn(_("Invalid format for a SSA line ('%s'). "
"This entry will be skipped.\n"), s);
continue;
@ -815,7 +815,7 @@ handle_data(KaxBlock *block,
fields[8] + string("\n"); // Text
// Do the charset conversion.
from_utf8(track->conv_handle, line);
line = from_utf8(track->conv_handle, line);
// Now store that entry.
ssa_line.num = num;

View File

@ -953,7 +953,7 @@ kax_reader_c::read_headers() {
for (idx = 0; idx < 4; idx++) {
int num;
if (!parse_int(ver_parts[idx].c_str(), num) || (num < 0) ||
if (!parse_int(ver_parts[idx], num) || (num < 0) ||
(num > 255)) {
failed = true;
break;

View File

@ -1120,13 +1120,8 @@ ogm_reader_c::handle_stream_comments() {
if (comment.size() != 2)
continue;
if (!comments_in_utf8) {
char *utf8_comment;
utf8_comment = to_utf8(cc_local_utf8, comment[1].c_str());
comment[1] = utf8_comment;
safefree(utf8_comment);
}
if (!comments_in_utf8)
comment[1] = to_utf8(cc_local_utf8, comment[1]);
if (comment[0] == "LANGUAGE") {
iso639_2 = map_english_name_to_iso639_2(comment[1].c_str());
@ -1177,7 +1172,7 @@ ogm_reader_c::handle_stream_comments() {
if (comments_in_utf8)
chapters.push_back(safestrdup(comments[j]));
else
chapters.push_back(to_utf8(cc_local_utf8, comments[j]));
chapters.push_back(to_utf8_c(cc_local_utf8, comments[j]));
}
}
if ((chapters.size() > 0) && !ti->no_chapters && (kax_chapters == NULL)) {

View File

@ -50,7 +50,7 @@ srt_reader_c::probe_file(mm_text_io_c *mm_io,
mm_io->setFilePointer(0, seek_beginning);
s = mm_io->getline();
strip(s);
if (!parse_int(s.c_str(), dummy))
if (!parse_int(s, dummy))
return 0;
s = mm_io->getline();
if ((s.length() < 29) || !issrttimecode(s.c_str()))

View File

@ -175,7 +175,7 @@ ssa_reader_c::parse_time(string &stime) {
return -1;
s = stime.substr(0, pos);
if (!parse_int(s.c_str(), th))
if (!parse_int(s, th))
return -1;
stime.erase(0, pos + 1);
@ -184,7 +184,7 @@ ssa_reader_c::parse_time(string &stime) {
return -1;
s = stime.substr(0, pos);
if (!parse_int(s.c_str(), tm))
if (!parse_int(s, tm))
return -1;
stime.erase(0, pos + 1);
@ -193,11 +193,11 @@ ssa_reader_c::parse_time(string &stime) {
return -1;
s = stime.substr(0, pos);
if (!parse_int(s.c_str(), ts))
if (!parse_int(s, ts))
return -1;
stime.erase(0, pos + 1);
if (!parse_int(stime.c_str(), tds))
if (!parse_int(stime, tds))
return -1;
return (tds * 10 + ts * 1000 + tm * 60 * 1000 + th * 60 * 60 * 1000) *
@ -206,16 +206,8 @@ ssa_reader_c::parse_time(string &stime) {
string
ssa_reader_c::recode_text(vector<string> &fields) {
char *s;
string res;
// TODO: Handle \fe encoding changes.
res = get_element("Text", fields);
s = to_utf8(cc_utf8, res.c_str());
res = s;
safefree(s);
return res;
return to_utf8(cc_utf8, get_element("Text", fields));
}
int

File diff suppressed because it is too large Load Diff

View File

@ -51,8 +51,6 @@ extern bool no_lacing, no_linking, use_durations;
extern bool identifying, identify_verbose;
extern char *dump_packets;
int64_t create_track_number(generic_reader_c *reader, int64_t tid);
void add_packetizer_globally(generic_packetizer_c *packetizer);

View File

@ -441,7 +441,7 @@ to_utf8(const wxString &src) {
utf8 = (char *)safemalloc(len + 1);
wxConvUTF8.WC2MB(utf8, src.c_str(), len + 1);
#else
utf8 = to_utf8(cc_local_utf8, src.c_str());
utf8 = to_utf8_c(cc_local_utf8, src);
#endif
retval = utf8;
safefree(utf8);

View File

@ -1945,7 +1945,7 @@ tab_chapters::parse_time(wxString s) {
}
c++;
}
if (!parse_int(utf8s.c_str(), nsecs))
if (!parse_int(utf8s, nsecs))
return -1;
return nsecs * 1000000000;
}

View File

@ -469,7 +469,7 @@ tab_global::validate_settings() {
wxOK | wxCENTER | wxICON_ERROR);
return false;
}
if ((s.length() == 0) || !parse_int(s.c_str(), dummy_i)) {
if ((s.length() == 0) || !parse_int(s, dummy_i)) {
wxMessageBox(wxT("The format of the split size is invalid."),
wxT("mkvmerge GUI error"),
wxOK | wxCENTER | wxICON_ERROR);
@ -494,7 +494,7 @@ tab_global::validate_settings() {
c = s[s.length() - 1];
if (tolower(c) == 's') {
s.erase(s.length() - 1);
if ((s.length() == 0) || !parse_int(s.c_str(), dummy_i) ||
if ((s.length() == 0) || !parse_int(s, dummy_i) ||
(dummy_i <= 0)) {
wxMessageBox(wxT("The format of the split time is invalid."),
wxT("mkvmerge GUI error"), wxOK | wxCENTER |
@ -523,7 +523,7 @@ tab_global::validate_settings() {
s = wxMB(tc_split_max_files->GetValue());
strip(s);
if ((s.length() > 0) && (!parse_int(s.c_str(), dummy_i) ||
if ((s.length() > 0) && (!parse_int(s, dummy_i) ||
(dummy_i <= 1))) {
wxMessageBox(wxT("Invalid number of max. split files given."),
wxT("mkvmerge GUI error"), wxOK | wxCENTER | wxICON_ERROR);

View File

@ -623,7 +623,7 @@ from_utf8(const wxString &src) {
wxString retval;
char *local;
local = from_utf8(cc_local_utf8, src.c_str());
local = from_utf8_c(cc_local_utf8, src.c_str());
retval = local;
safefree(local);
return retval;
@ -1591,7 +1591,7 @@ tab_input::validate_settings() {
s = wxMB(*t->delay);
strip(s);
if ((s.length() > 0) && !parse_int(s.c_str(), dummy_i)) {
if ((s.length() > 0) && !parse_int(s, dummy_i)) {
wxMessageBox(wxT("The delay setting for track nr. ") + sid +
wxT(" in file '") + *f->file_name + wxT("' is invalid."),
wxT("mkvmerge GUI: error"),

View File

@ -203,10 +203,6 @@ mp3_packetizer_c::process(memory_c &mem,
byte_buffer.add(mem.data, mem.size);
while ((packet = get_mp3_packet(&mp3header)) != NULL) {
#ifdef DEBUG
dump_packet(packet, mp3header.framesize);
#endif
if (timecode == -1)
my_timecode = (int64_t)(1000000000.0 * packetno * spf / samples_per_sec);
else

View File

@ -129,7 +129,7 @@ textsubs_packetizer_c::process(memory_c &mem,
*idx2 = 0;
if (recode) {
utf8_subs = to_utf8(cc_utf8, subs);
utf8_subs = to_utf8_c(cc_utf8, subs);
safefree(subs);
memory_c mem((unsigned char *)utf8_subs, strlen(utf8_subs), true);
add_packet(mem, start, length, true);

View File

@ -243,8 +243,6 @@ generic_packetizer_c::generic_packetizer_c(generic_reader_c *nreader,
hcompression = COMPRESSION_UNSPECIFIED;
compressor = NULL;
dumped_packet_number = 0;
timecode_factory = timecode_factory_c::create(ti->ext_timecodes,
ti->fname, ti->id);
}
@ -881,28 +879,6 @@ generic_packetizer_c::get_packet() {
return pack;
}
void
generic_packetizer_c::dump_packet(const void *buffer,
int size) {
char *path;
mm_io_c *out;
if (dump_packets == NULL)
return;
path = (char *)safemalloc(strlen(dump_packets) + 1 + 30);
mxprints(path, "%s/%u-%010lld", dump_packets, hserialno,
dumped_packet_number);
dumped_packet_number++;
try {
out = new mm_io_c(path, MODE_CREATE);
out->write(buffer, size);
delete out;
} catch(...) {
}
safefree(path);
}
void
generic_packetizer_c::displace(float by_ns) {
ti->async.displacement += (int64_t)by_ns;

View File

@ -319,8 +319,6 @@ protected:
int hvideo_pixel_width, hvideo_pixel_height;
int hvideo_display_width, hvideo_display_height;
int64_t dumped_packet_number;
int hcompression;
compression_c *compressor;
@ -475,9 +473,6 @@ public:
if (ti->avi_block_sizes != NULL)
ti->avi_block_sizes->push_back(block_size);
}
protected:
virtual void dump_packet(const void *buffer, int size);
};
extern vector<generic_packetizer_c *> ptzrs_in_header_order;

View File

@ -43,7 +43,7 @@ timecode_factory_c::create(const char *_file_name,
}
if (!in->getline2(line) || !starts_with_case(line, "# timecode format v") ||
!parse_int(&line.c_str()[strlen("# timecode format v")], version))
!parse_int(&line[strlen("# timecode format v")], version))
mxerror(_("The timecode file '%s' contains an unsupported/unrecognized "
"format line. The very first line must look like "
"'# timecode format v1'.\n"), _file_name);