- /* Here we are converting from time (in the DCP) to a frame number in the content.
- Hence we need to use the DCP's frame rate and the double/skip correction, not
- the source's rate; source rate will be equal to DCP rate if we ignore
- double/skip. There's no need to call Film::active_frame_rate_change() here
- as we know that we are it (since we're video).
- */
- FrameRateChange frc (video_frame_rate(), film->video_frame_rate());
- return ceil (t * film->video_frame_rate() / (frc.factor() * TIME_HZ));
+ if (_ratio) {
+ s << _ratio->id () << "_";
+ } else {
+ s << (_scale ? "S1" : "S0");
+ }
+
+ return s.str ();
+}
+
+string
+VideoContentScale::name () const
+{
+ if (_ratio) {
+ return _ratio->nickname ();
+ }
+
+ if (_scale) {
+ return _("No stretch");
+ }
+
+ return _("No scale");
+}
+
+dcp::Size
+VideoContentScale::size (shared_ptr<const VideoContent> c, dcp::Size container) const
+{
+ if (_ratio) {
+ return fit_ratio_within (_ratio->ratio (), container);
+ }
+
+ /* Force scale if the container is smaller than the content's image */
+ if (_scale || container.width < c->video_size().width || container.height < c->video_size().height) {
+ return fit_ratio_within (c->video_size().ratio (), container);
+ }
+
+ return c->video_size ();
+}
+
+void
+VideoContentScale::setup_scales ()
+{
+ vector<Ratio const *> ratios = Ratio::all ();
+ for (vector<Ratio const *>::const_iterator i = ratios.begin(); i != ratios.end(); ++i) {
+ _scales.push_back (VideoContentScale (*i));
+ }
+
+ _scales.push_back (VideoContentScale (true));
+ _scales.push_back (VideoContentScale (false));
+}
+
+bool
+operator== (VideoContentScale const & a, VideoContentScale const & b)
+{
+ return (a.ratio() == b.ratio() && a.scale() == b.scale());
+}
+
+bool
+operator!= (VideoContentScale const & a, VideoContentScale const & b)
+{
+ return (a.ratio() != b.ratio() || a.scale() != b.scale());