X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fstl_binary_reader.cc;h=d47768419996409129648bcb73ee7bd3cad30585;hb=d848eed414a5d5c8bc35a3ec843f01e8b609f60d;hp=ff3d9a0ee5af692085eb769061ae1a5669437e9c;hpb=4ada3e7583dfdc658dbebca3c3603be1e3477c12;p=libsub.git diff --git a/src/stl_binary_reader.cc b/src/stl_binary_reader.cc index ff3d9a0..d477684 100644 --- a/src/stl_binary_reader.cc +++ b/src/stl_binary_reader.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,6 +25,7 @@ #include #include #include +#include using std::map; using std::vector; @@ -77,7 +78,7 @@ STLBinaryReader::STLBinaryReader (istream& in) editor_contact_details = get_string (341, 32); for (int i = 0; i < tti_blocks; ++i) { - + in.read ((char *) _buffer, 128); if (in.gcount() != 128) { throw STLError ("Could not read TTI block from binary STL file"); @@ -95,9 +96,10 @@ STLBinaryReader::STLBinaryReader (istream& in) for (size_t i = 0; i < lines.size(); ++i) { RawSubtitle sub; - sub.from.set_frame (get_timecode (5)); - sub.to.set_frame (get_timecode (9)); + sub.from = get_timecode (5); + sub.to = get_timecode (9); sub.vertical_position.line = get_int (13, 1) + i; + sub.vertical_position.lines = maximum_rows; sub.vertical_position.reference = TOP_OF_SCREEN; string text; @@ -140,7 +142,7 @@ STLBinaryReader::STLBinaryReader (istream& in) sub.text = utf_to_utf (iso6937_to_utf16 (text.c_str())); _subs.push_back (sub); } - + /* XXX: justification */ } } @@ -173,10 +175,10 @@ STLBinaryReader::get_int (int offset, int length) const return v; } -FrameTime +Time STLBinaryReader::get_timecode (int offset) const { - return FrameTime (_buffer[offset], _buffer[offset + 1], _buffer[offset + 2], _buffer[offset + 3]); + return Time::from_hmsf (_buffer[offset], _buffer[offset + 1], _buffer[offset + 2], _buffer[offset + 3], Rational (frame_rate, 1)); } map