#include "stl_binary_writer.h"
#include "subtitle.h"
+#include "iso6937.h"
+#include "stl_util.h"
#include "compose.hpp"
+#include <boost/locale.hpp>
#include <list>
#include <cmath>
#include <fstream>
using std::setfill;
using std::max;
using std::cout;
+using boost::locale::conv::utf_to_utf;
using namespace sub;
static void
assert (editor_contact_details.size() <= 32);
char* buffer = new char[1024];
+ memset (buffer, 0, 1024);
ofstream output (file_name.string().c_str ());
STLBinaryTables tables;
set<int> check_rows;
for (list<Subtitle>::const_iterator i = subtitles.begin(); i != subtitles.end(); ++i) {
- int t = 0;
for (list<Line>::const_iterator j = i->lines.begin(); j != i->lines.end(); ++j) {
+ int t = 0;
for (list<Block>::const_iterator k = j->blocks.begin(); k != j->blocks.end(); ++k) {
t += k->text.size ();
}
/* Code page: 850 */
put_string (buffer + 0, "850");
/* Disk format code */
- put_string (buffer + 3, String::compose ("STL%1.01", rint (frames_per_second)));
+ put_string (buffer + 3, stl_frame_rate_to_dfc (frames_per_second));
/* Display standard code: open subtitling */
put_string (buffer + 11, "0");
/* Character code table: Latin (ISO 6937) */
/* Total number of subtitles */
put_int_as_string (buffer + 243, subtitles.size (), 5);
/* Total number of subtitle groups */
- put_string (buffer + 248, "000");
+ put_string (buffer + 248, "001");
/* Maximum number of displayable characters in any text row */
- put_int_as_string (buffer + 251, 2, longest);
+ put_int_as_string (buffer + 251, longest, 2);
/* Maximum number of displayable rows */
- put_int_as_string (buffer + 253, 2, rows);
+ put_int_as_string (buffer + 253, rows, 2);
/* Time code status */
put_string (buffer + 255, "1");
/* Start-of-programme time code */
put_string (buffer + 272, "1");
/* Disk sequence number */
put_string (buffer + 273, "1");
- put_string (buffer + 274, 32, country_of_origin);
+ put_string (buffer + 274, 3, country_of_origin);
put_string (buffer + 277, 32, publisher);
put_string (buffer + 309, 32, editor_name);
put_string (buffer + 341, 32, editor_contact_details);
int N = 0;
for (list<Subtitle>::const_iterator i = subtitles.begin(); i != subtitles.end(); ++i) {
+ memset (buffer, 0, 1024);
+
/* Subtitle group number */
- put_int_as_int (buffer + 0, 0, 1);
+ put_int_as_int (buffer + 0, 1, 1);
/* Subtitle number */
put_int_as_int (buffer + 1, N, 2);
- /* Extension block number */
- put_int_as_int (buffer + 3, 0, 1);
+ /* Extension block number. Use 0xff here to indicate that it is the last TTI
+ block in this subtitle "set", as we only ever use one.
+ */
+ put_int_as_int (buffer + 3, 255, 1);
/* Cumulative status */
put_int_as_int (buffer + 4, tables.cumulative_status_enum_to_file (CUMULATIVE_STATUS_NOT_CUMULATIVE), 1);
/* Time code in */
italic = false;
}
- text += k->text;
+ text += utf16_to_iso6937 (utf_to_utf<wchar_t> (k->text));
}
text += "\x8A";