2 Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "convert_time.h"
27 sub::operator< (Subtitle const & a, Subtitle const & b)
29 if (a.from.frame && b.from.frame) {
30 return a.from.frame.get() < b.from.frame.get();
33 if (a.from.metric && b.from.metric) {
34 return a.from.metric.get() < b.from.metric.get();
41 sub::convert_font_sizes (list<Subtitle>& subs, int screen_height_in_points)
43 for (list<Subtitle>::iterator i = subs.begin(); i != subs.end(); ++i) {
44 if (i->font_size.proportional) {
45 i->font_size.points = i->font_size.proportional.get() * screen_height_in_points;
47 i->font_size.proportional = float (i->font_size.points.get()) / screen_height_in_points;
53 sub::convert_times (list<Subtitle>& subs, float frames_per_second)
55 for (list<Subtitle>::iterator i = subs.begin(); i != subs.end(); ++i) {
57 i->from.metric = frame_to_metric (i->from.frame.get(), frames_per_second);
59 i->from.frame = metric_to_frame (i->from.metric.get(), frames_per_second);
63 i->to.metric = frame_to_metric (i->to.frame.get(), frames_per_second);
65 i->to.frame = metric_to_frame (i->to.metric.get(), frames_per_second);