本文整理汇总了C++中mm_io_c::getline2方法的典型用法代码示例。如果您正苦于以下问题:C++ mm_io_c::getline2方法的具体用法?C++ mm_io_c::getline2怎么用?C++ mm_io_c::getline2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mm_io_c
的用法示例。
在下文中一共展示了mm_io_c::getline2方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void
timecode_factory_v2_c::parse(mm_io_c &in) {
std::string line;
std::map<int64_t, int64_t> dur_map;
int64_t dur_sum = 0;
int line_no = 0;
double previous_timecode = 0;
while (in.getline2(line)) {
line_no++;
strip(line);
if ((line.length() == 0) || (line[0] == '#'))
continue;
double timecode;
if (!parse_double(line.c_str(), timecode))
mxerror(boost::format(Y("The line %1% of the timecode file '%2%' does not contain a valid floating point number.\n")) % line_no % m_file_name);
if ((2 == m_version) && (timecode < previous_timecode))
mxerror(boost::format(Y("The timecode v2 file '%1%' contains timecodes that are not ordered. "
"Due to a bug in mkvmerge versions up to and including v1.5.0 this was necessary "
"if the track to which the timecode file was applied contained B frames. "
"Starting with v1.5.1 mkvmerge now handles this correctly, and the timecodes in the timecode file must be ordered normally. "
"For example, the frame sequence 'IPBBP...' at 25 FPS requires a timecode file with "
"the first timecodes being '0', '40', '80', '120' etc and not '0', '120', '40', '80' etc.\n\n"
"If you really have to specify non-sorted timecodes then use the timecode format v4. "
"It is identical to format v2 but allows non-sorted timecodes.\n"))
% in.get_file_name());
previous_timecode = timecode;
m_timecodes.push_back((int64_t)(timecode * 1000000));
if (m_timecodes.size() > 1) {
int64_t duration = m_timecodes[m_timecodes.size() - 1] - m_timecodes[m_timecodes.size() - 2];
if (dur_map.find(duration) == dur_map.end())
dur_map[duration] = 1;
else
dur_map[duration] = dur_map[duration] + 1;
dur_sum += duration;
m_durations.push_back(duration);
}
}
if (m_timecodes.empty())
mxerror(boost::format(Y("The timecode file '%1%' does not contain any valid entry.\n")) % m_file_name);
dur_sum = -1;
std::pair<int64_t, int64_t> entry;
for (auto entry : dur_map) {
if ((0 > dur_sum) || (dur_map[dur_sum] < entry.second))
dur_sum = entry.first;
mxverb(4, boost::format("ext_m_timecodes v2 dur_map %1% = %2%\n") % entry.first % entry.second);
}
mxverb(4, boost::format("ext_m_timecodes v2 max is %1% = %2%\n") % dur_sum % dur_map[dur_sum]);
if (0 < dur_sum)
m_default_fps = (double)1000000000.0 / dur_sum;
m_durations.push_back(dur_sum);
}
示例2: mxerror
void
timecode_factory_v1_c::parse(mm_io_c &in) {
std::string line;
timecode_range_c t;
std::vector<timecode_range_c>::iterator iit;
std::vector<timecode_range_c>::const_iterator pit;
int line_no = 1;
do {
if (!in.getline2(line))
mxerror(boost::format(Y("The timecode file '%1%' does not contain a valid 'Assume' line with the default number of frames per second.\n")) % m_file_name);
line_no++;
strip(line);
if (!line.empty() && ('#' != line[0]))
break;
} while (true);
if (!ba::istarts_with(line, "assume "))
mxerror(boost::format(Y("The timecode file '%1%' does not contain a valid 'Assume' line with the default number of frames per second.\n")) % m_file_name);
line.erase(0, 6);
strip(line);
if (!parse_double(line.c_str(), m_default_fps))
mxerror(boost::format(Y("The timecode file '%1%' does not contain a valid 'Assume' line with the default number of frames per second.\n")) % m_file_name);
while (in.getline2(line)) {
line_no++;
strip(line, true);
if (line.empty() || ('#' == line[0]))
continue;
std::vector<std::string> parts = split(line, ",", 3);
if ( (parts.size() != 3)
|| !parse_uint(parts[0], t.start_frame)
|| !parse_uint(parts[1], t.end_frame)
|| !parse_double(parts[2], t.fps)) {
mxwarn(boost::format(Y("Line %1% of the timecode file '%2%' could not be parsed.\n")) % line_no % m_file_name);
continue;
}
if ((t.fps <= 0) || (t.end_frame < t.start_frame)) {
mxwarn(boost::format(Y("Line %1% of the timecode file '%2%' contains inconsistent data (e.g. the start frame number is bigger than the end frame "
"number, or some values are smaller than zero).\n")) % line_no % m_file_name);
continue;
}
m_ranges.push_back(t);
}
mxverb(3, boost::format("ext_timecodes: Version 1, default fps %1%, %2% entries.\n") % m_default_fps % m_ranges.size());
if (m_ranges.size() == 0)
t.start_frame = 0;
else {
std::sort(m_ranges.begin(), m_ranges.end());
bool done;
do {
done = true;
iit = m_ranges.begin();
size_t i;
for (i = 0; i < (m_ranges.size() - 1); i++) {
iit++;
if (m_ranges[i].end_frame < (m_ranges[i + 1].start_frame - 1)) {
t.start_frame = m_ranges[i].end_frame + 1;
t.end_frame = m_ranges[i + 1].start_frame - 1;
t.fps = m_default_fps;
m_ranges.insert(iit, t);
done = false;
break;
}
}
} while (!done);
if (m_ranges[0].start_frame != 0) {
t.start_frame = 0;
t.end_frame = m_ranges[0].start_frame - 1;
t.fps = m_default_fps;
m_ranges.insert(m_ranges.begin(), t);
}
t.start_frame = m_ranges[m_ranges.size() - 1].end_frame + 1;
}
t.end_frame = 0xfffffffffffffffll;
t.fps = m_default_fps;
m_ranges.push_back(t);
m_ranges[0].base_timecode = 0.0;
pit = m_ranges.begin();
for (iit = m_ranges.begin() + 1; iit < m_ranges.end(); iit++, pit++)
iit->base_timecode = pit->base_timecode + ((double)pit->end_frame - (double)pit->start_frame + 1) * 1000000000.0 / pit->fps;
for (iit = m_ranges.begin(); iit < m_ranges.end(); iit++)
mxverb(3, boost::format("ranges: entry %1% -> %2% at %3% with %4%\n") % iit->start_frame % iit->end_frame % iit->fps % iit->base_timecode);
}
示例3: if
void
timecode_factory_v3_c::parse(mm_io_c &in) {
std::string line;
timecode_duration_c t;
std::vector<timecode_duration_c>::iterator iit;
std::vector<timecode_duration_c>::const_iterator pit;
std::string err_msg_assume = (boost::format(Y("The timecode file '%1%' does not contain a valid 'Assume' line with the default number of frames per second.\n")) % m_file_name).str();
int line_no = 1;
do {
if (!in.getline2(line))
mxerror(err_msg_assume);
line_no++;
strip(line);
if ((line.length() != 0) && (line[0] != '#'))
break;
} while (true);
if (!ba::istarts_with(line, "assume "))
mxerror(err_msg_assume);
line.erase(0, 6);
strip(line);
if (!parse_double(line.c_str(), m_default_fps))
mxerror(err_msg_assume);
while (in.getline2(line)) {
line_no++;
strip(line, true);
if ((line.length() == 0) || (line[0] == '#'))
continue;
double dur;
if (ba::istarts_with(line, "gap,")) {
line.erase(0, 4);
strip(line);
t.is_gap = true;
t.fps = m_default_fps;
if (!parse_double(line.c_str(), dur))
mxerror(boost::format(Y("The timecode file '%1%' does not contain a valid 'Gap' line with the duration of the gap.\n")) % m_file_name);
t.duration = (int64_t)(1000000000.0 * dur);
} else {
t.is_gap = false;
std::vector<std::string> parts = split(line, ",");
if ((1 == parts.size()) && parse_double(parts[0], dur))
t.fps = m_default_fps;
else if ((2 != parts.size()) || !parse_double(parts[1], t.fps)) {
mxwarn(boost::format(Y("Line %1% of the timecode file '%2%' could not be parsed.\n")) % line_no % m_file_name);
continue;
}
t.duration = (int64_t)(1000000000.0 * dur);
}
if ((t.fps < 0) || (t.duration <= 0)) {
mxwarn(boost::format(Y("Line %1% of the timecode file '%2%' contains inconsistent data (e.g. the duration or the FPS are smaller than zero).\n"))
% line_no % m_file_name);
continue;
}
m_durations.push_back(t);
}
mxverb(3, boost::format("ext_timecodes: Version 3, default fps %1%, %2% entries.\n") % m_default_fps % m_durations.size());
if (m_durations.size() == 0)
mxwarn(boost::format(Y("The timecode file '%1%' does not contain any valid entry.\n")) % m_file_name);
t.duration = 0xfffffffffffffffll;
t.is_gap = false;
t.fps = m_default_fps;
m_durations.push_back(t);
for (iit = m_durations.begin(); iit < m_durations.end(); iit++)
mxverb(4, boost::format("durations:%1% entry for %2% with %3% FPS\n") % (iit->is_gap ? " gap" : "") % iit->duration % iit->fps);
}