projects
/
libsub.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Small C++11 tweaks.
[libsub.git]
/
src
/
dcp_reader.cc
diff --git
a/src/dcp_reader.cc
b/src/dcp_reader.cc
index bedd0e24bc9861ce926fbe9876ac12317cded0a5..0c7a29a90aaa9d564f3f18932c00e305599fbd55 100644
(file)
--- a/
src/dcp_reader.cc
+++ b/
src/dcp_reader.cc
@@
-1,5
+1,5
@@
/*
/*
- Copyright (C) 2014-20
17
Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-20
21
Carl Hetherington <cth@carlh.net>
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
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
@@
-23,14
+23,13
@@
#include <dcp/subtitle_string.h>
#include <dcp/interop_subtitle_asset.h>
#include <dcp/smpte_subtitle_asset.h>
#include <dcp/subtitle_string.h>
#include <dcp/interop_subtitle_asset.h>
#include <dcp/smpte_subtitle_asset.h>
-#include <boost/foreach.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem.hpp>
-using std::list;
-using std::cout;
-using std::string;
+using std::dynamic_pointer_cast;
using std::exception;
using std::exception;
-using boost::shared_ptr;
+using std::make_shared;
+using std::shared_ptr;
+using std::string;
using boost::optional;
using namespace sub;
using boost::optional;
using namespace sub;
@@
-53,78
+52,85
@@
DCPReader::DCPReader (boost::filesystem::path file)
string smpte_error;
try {
string smpte_error;
try {
- sc
.reset (new dcp::InteropSubtitleAsset (file)
);
+ sc
= make_shared<dcp::InteropSubtitleAsset>(file
);
} catch (exception& e) {
interop_error = e.what ();
}
if (!sc) {
try {
} catch (exception& e) {
interop_error = e.what ();
}
if (!sc) {
try {
- sc
.reset (new dcp::SMPTESubtitleAsset (file)
);
+ sc
= make_shared<dcp::SMPTESubtitleAsset>(file
);
} catch (exception& e) {
smpte_error = e.what();
}
}
if (!sc) {
} catch (exception& e) {
smpte_error = e.what();
}
}
if (!sc) {
- throw DCPError
(String::compose
("Could not read subtitles (%1 / %2)", interop_error, smpte_error));
+ throw DCPError
(String::compose
("Could not read subtitles (%1 / %2)", interop_error, smpte_error));
}
}
- BOOST_FOREACH (dcp::SubtitleString const & i, sc->subtitles ()) {
+ for (auto i: sc->subtitles()) {
+
+ /* We don't deal with image subs */
+ auto is = dynamic_pointer_cast<const dcp::SubtitleString>(i);
+ if (!is) {
+ continue;
+ }
+
RawSubtitle rs;
RawSubtitle rs;
- rs.text = i
.
text ();
- rs.font = i
.
font ();
- rs.font_size = FontSize::from_proportional (i
.
size() / (72.0 * 11.0));
+ rs.text = i
s->
text ();
+ rs.font = i
s->
font ();
+ rs.font_size = FontSize::from_proportional (i
s->
size() / (72.0 * 11.0));
- switch (i
.
effect ()) {
- case dcp::BORDER:
+ switch (i
s->
effect ()) {
+ case dcp::
Effect::
BORDER:
rs.effect = BORDER;
break;
rs.effect = BORDER;
break;
- case dcp::SHADOW:
+ case dcp::
Effect::
SHADOW:
rs.effect = SHADOW;
break;
default:
break;
}
rs.effect = SHADOW;
break;
default:
break;
}
- rs.effect_colour = dcp_to_sub_colour (i
.
effect_colour());
+ rs.effect_colour = dcp_to_sub_colour (i
s->
effect_colour());
- rs.colour = dcp_to_sub_colour (i
.
colour());
- rs.bold = i
.
bold ();
- rs.italic = i
.
italic ();
- rs.underline = i
.
underline ();
+ rs.colour = dcp_to_sub_colour (i
s->
colour());
+ rs.bold = i
s->
bold ();
+ rs.italic = i
s->
italic ();
+ rs.underline = i
s->
underline ();
- switch (i
.
h_align()) {
- case dcp::HA
LIGN_
LEFT:
- rs.horizontal_position
= LEFT
;
+ switch (i
s->
h_align()) {
+ case dcp::HA
lign::
LEFT:
+ rs.horizontal_position
.reference = LEFT_OF_SCREEN
;
break;
break;
- case dcp::HA
LIGN_
CENTER:
- rs.horizontal_position
= CENTRE
;
+ case dcp::HA
lign::
CENTER:
+ rs.horizontal_position
.reference = HORIZONTAL_CENTRE_OF_SCREEN
;
break;
break;
- case dcp::HA
LIGN_
RIGHT:
- rs.horizontal_position
= RIGHT
;
+ case dcp::HA
lign::
RIGHT:
+ rs.horizontal_position
.reference = RIGHT_OF_SCREEN
;
break;
}
break;
}
- rs.vertical_position.proportional = i
.
v_position();
- switch (i
.
v_align()) {
- case dcp::VA
LIGN_
TOP:
+ rs.vertical_position.proportional = i
s->
v_position();
+ switch (i
s->
v_align()) {
+ case dcp::VA
lign::
TOP:
rs.vertical_position.reference = TOP_OF_SCREEN;
break;
rs.vertical_position.reference = TOP_OF_SCREEN;
break;
- case dcp::VA
LIGN_
CENTER:
+ case dcp::VA
lign::
CENTER:
rs.vertical_position.reference = VERTICAL_CENTRE_OF_SCREEN;
break;
rs.vertical_position.reference = VERTICAL_CENTRE_OF_SCREEN;
break;
- case dcp::VA
LIGN_
BOTTOM:
+ case dcp::VA
lign::
BOTTOM:
rs.vertical_position.reference = BOTTOM_OF_SCREEN;
break;
}
rs.vertical_position.reference = BOTTOM_OF_SCREEN;
break;
}
- rs.from = dcp_to_sub_time (i
.
in ());
- rs.to = dcp_to_sub_time (i
.
out ());
+ rs.from = dcp_to_sub_time (i
s->
in ());
+ rs.to = dcp_to_sub_time (i
s->
out ());
- rs.fade_up = dcp_to_sub_time (i
.
fade_up_time ());
- rs.fade_down = dcp_to_sub_time (i
.
fade_down_time ());
+ rs.fade_up = dcp_to_sub_time (i
s->
fade_up_time ());
+ rs.fade_down = dcp_to_sub_time (i
s->
fade_down_time ());
_subs.push_back (rs);
}
_subs.push_back (rs);
}