float -> double in a few places.
authorCarl Hetherington <cth@carlh.net>
Wed, 15 Jul 2015 23:53:54 +0000 (00:53 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 15 Jul 2015 23:53:54 +0000 (00:53 +0100)
13 files changed:
doc/design/dcpomatic.svg
src/lib/dcp_examiner.h
src/lib/ffmpeg_examiner.cc
src/lib/ffmpeg_examiner.h
src/lib/image_examiner.cc
src/lib/image_examiner.h
src/lib/player.cc
src/lib/player_video.cc
src/lib/player_video.h
src/lib/video_content.cc
src/lib/video_content.h
src/lib/video_examiner.h
test/client_server_test.cc

index 3d1cc7b94d604ebaf28ae41eddcd2bb69e312707..f1b61f8c14ae6c6dc073e5b100db5207fd65a72d 100644 (file)
      borderopacity="1.0"
      inkscape:pageopacity="0.0"
      inkscape:pageshadow="2"
-     inkscape:zoom="1.1598677"
-     inkscape:cx="652.92066"
-     inkscape:cy="674.81101"
+     inkscape:zoom="3.0258297"
+     inkscape:cx="295.32748"
+     inkscape:cy="1324.6833"
      inkscape:document-units="px"
      inkscape:current-layer="layer1"
      showgrid="false"
-     inkscape:window-width="1366"
-     inkscape:window-height="714"
+     inkscape:window-width="1280"
+     inkscape:window-height="997"
      inkscape:window-x="1280"
-     inkscape:window-y="283"
+     inkscape:window-y="0"
      inkscape:window-maximized="1"
      showguides="true"
      inkscape:guide-bbox="true" />
         <dc:format>image/svg+xml</dc:format>
         <dc:type
            rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
-        <dc:title></dc:title>
+        <dc:title />
       </cc:Work>
     </rdf:RDF>
   </metadata>
        id="path6726-3"
        inkscape:connector-curvature="0"
        sodipodi:nodetypes="cc" />
-    <path
-       style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:1, 4;stroke-dashoffset:0"
-       d="m 623.11641,26.2839 0,431.46391"
-       id="path7445"
-       inkscape:connector-curvature="0"
-       sodipodi:nodetypes="cc" />
+    <rect
+       style="color:#000000;fill:none;stroke:#0000ff;stroke-width:0.99999988px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+       id="rect2985-0-3"
+       width="139"
+       height="98.153183"
+       x="193.67656"
+       y="-344.28204" />
+    <text
+       xml:space="preserve"
+       style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#0000ff;fill-opacity:1;stroke:none;font-family:Latin Modern Mono;-inkscape-font-specification:Latin Modern Mono"
+       x="202.67656"
+       y="-328.79272"
+       id="text2987-4-2"
+       sodipodi:linespacing="125%"><tspan
+         sodipodi:role="line"
+         id="tspan2989-9-1"
+         x="202.67656"
+         y="-328.79272">Class</tspan></text>
+    <rect
+       style="color:#000000;fill:none;stroke:#0000ff;stroke-width:0.99999988px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+       id="rect2991-8-1"
+       width="139"
+       height="24"
+       x="193.67656"
+       y="-344.28204" />
+    <text
+       xml:space="preserve"
+       style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#ff0000;fill-opacity:1;stroke:none;font-family:Latin Modern Mono;-inkscape-font-specification:Latin Modern Mono"
+       x="203.29256"
+       y="-278.13858"
+       id="text2993-9-50"
+       sodipodi:linespacing="125%"><tspan
+         sodipodi:role="line"
+         x="203.29256"
+         y="-278.13858"
+         id="tspan2997-9-6">method()</tspan></text>
+    <text
+       xml:space="preserve"
+       style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#008000;fill-opacity:1;stroke:none;font-family:Latin Modern Roman;-inkscape-font-specification:Latin Modern Roman"
+       x="202.94057"
+       y="-264.99423"
+       id="text2999-7-6"
+       sodipodi:linespacing="125%"><tspan
+         sodipodi:role="line"
+         x="202.94057"
+         y="-264.99423"
+         id="tspan6126-5">Method description</tspan></text>
+    <text
+       xml:space="preserve"
+       style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:125%;letter-spacing:0px;word-spacing:0px;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#000080;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Latin Modern Roman;-inkscape-font-specification:Latin Modern Roman"
+       x="202.78856"
+       y="-305.98245"
+       id="text3438"
+       sodipodi:linespacing="125%"><tspan
+         sodipodi:role="line"
+         id="tspan3440"
+         x="202.78856"
+         y="-305.98245">Class description.</tspan></text>
+    <rect
+       style="color:#000000;fill:none;stroke:#0000ff;stroke-width:0.99999988px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+       id="rect2991-8-1-2"
+       width="139"
+       height="24"
+       x="193.67656"
+       y="-320.29883" />
   </g>
   <g
      inkscape:groupmode="layer"
index ed457b5c246835a8243569071d1559bb10547b72..532bad60c54ba649f91b0958247e8c1474afc4d8 100644 (file)
@@ -31,7 +31,7 @@ class DCPExaminer : public VideoExaminer, public AudioExaminer
 public:
        DCPExaminer (boost::shared_ptr<const DCPContent>);
 
-       boost::optional<float> video_frame_rate () const {
+       boost::optional<double> video_frame_rate () const {
                return _video_frame_rate;
        }
 
@@ -72,7 +72,7 @@ public:
        }
 
 private:
-       boost::optional<float> _video_frame_rate;
+       boost::optional<double> _video_frame_rate;
        boost::optional<dcp::Size> _video_size;
        Frame _video_length;
        boost::optional<int> _audio_channels;
index f4b650eee8e0ca9a9f17bf0a424733d86604e4ae..bcc5a86a68dbe2b093b95f76702de22df1b64e2e 100644 (file)
@@ -191,7 +191,7 @@ FFmpegExaminer::frame_time (AVStream* s) const
        return t;
 }
 
-optional<float>
+optional<double>
 FFmpegExaminer::video_frame_rate () const
 {
        /* This use of r_frame_rate is debateable; there's a few different
@@ -214,15 +214,15 @@ FFmpegExaminer::video_length () const
        return max (Frame (1), _video_length);
 }
 
-optional<float>
+optional<double>
 FFmpegExaminer::sample_aspect_ratio () const
 {
        AVRational sar = av_guess_sample_aspect_ratio (_format_context, _format_context->streams[_video_stream], 0);
        if (sar.num == 0) {
                /* I assume this means that we don't know */
-               return optional<float> ();
+               return optional<double> ();
        }
-       return float (sar.num) / sar.den;
+       return double (sar.num) / sar.den;
 }
 
 string
index 795a9c6ff7aa189ff1982ebaaa2dd56dbf559a30..96720b280bfc869269de92b041b83b4ba2b32d3e 100644 (file)
@@ -31,10 +31,10 @@ class FFmpegExaminer : public FFmpeg, public VideoExaminer
 public:
        FFmpegExaminer (boost::shared_ptr<const FFmpegContent>, boost::shared_ptr<Job> job = boost::shared_ptr<Job> ());
 
-       boost::optional<float> video_frame_rate () const;
+       boost::optional<double> video_frame_rate () const;
        dcp::Size video_size () const;
        Frame video_length () const;
-       boost::optional<float> sample_aspect_ratio () const;
+       boost::optional<double> sample_aspect_ratio () const;
 
        std::vector<boost::shared_ptr<FFmpegSubtitleStream> > subtitle_streams () const {
                return _subtitle_streams;
index 79c9f727ceed7ba710546cb8d4292eb0f58a4df5..6ad32f511e1971ddd8d24123e4bdf0ba2bcfe696 100644 (file)
@@ -80,9 +80,9 @@ ImageExaminer::video_size () const
        return _video_size.get ();
 }
 
-optional<float>
+optional<double>
 ImageExaminer::video_frame_rate () const
 {
        /* Don't know */
-       return optional<float> ();
+       return optional<double> ();
 }
index 937a565f33bc75eb36049d42ee2695f1e2a684be..f159e38f98a270d6fbce7a90af74862cba105405 100644 (file)
@@ -30,7 +30,7 @@ class ImageExaminer : public VideoExaminer
 public:
        ImageExaminer (boost::shared_ptr<const Film>, boost::shared_ptr<const ImageContent>, boost::shared_ptr<Job>);
 
-       boost::optional<float> video_frame_rate () const;
+       boost::optional<double> video_frame_rate () const;
        dcp::Size video_size () const;
        Frame video_length () const {
                return _video_length;
index 0a4eb54e7aa09367b374011d5c7a490ee10405eb..b00df4e2336b5519391bb74e164b671830c4b508 100644 (file)
@@ -309,7 +309,7 @@ Player::black_player_video_frame (DCPTime time) const
                        shared_ptr<const ImageProxy> (new RawImageProxy (_black_image)),
                        time,
                        Crop (),
-                       optional<float> (),
+                       optional<double> (),
                        _video_container_size,
                        _video_container_size,
                        EYES_BOTH,
@@ -524,6 +524,10 @@ Player::dcp_to_content_video (shared_ptr<const Piece> piece, DCPTime t) const
        shared_ptr<const VideoContent> vc = dynamic_pointer_cast<const VideoContent> (piece->content);
        DCPTime s = t - piece->content->position ();
        s = min (piece->content->length_after_trim(), s);
+       std::cout << "s=" << s << " " << ContentTime(s, piece->frc) << "\n";
+       std::cout << (ContentTime (s, piece->frc) + piece->content->trim_start ()) << "\n";
+       std::cout << s.get() << "\n";
+       std::cout << (s.get() * 24.0 / 96000) << "\n";
        return max (ContentTime (), ContentTime (s, piece->frc) + piece->content->trim_start ()).frames (vc->video_frame_rate ());
 }
 
index 2b1e85fc95cb2fd33af6b96b7875b496daa17137..018f04737acec4df8a050b086aff84be1fbe5659 100644 (file)
@@ -34,7 +34,7 @@ PlayerVideo::PlayerVideo (
        shared_ptr<const ImageProxy> in,
        DCPTime time,
        Crop crop,
-       boost::optional<float> fade,
+       boost::optional<double> fade,
        dcp::Size inter_size,
        dcp::Size out_size,
        Eyes eyes,
@@ -58,7 +58,7 @@ PlayerVideo::PlayerVideo (shared_ptr<cxml::Node> node, shared_ptr<Socket> socket
 {
        _time = DCPTime (node->number_child<DCPTime::Type> ("Time"));
        _crop = Crop (node);
-       _fade = node->optional_number_child<float> ("Fade");
+       _fade = node->optional_number_child<double> ("Fade");
 
        _inter_size = dcp::Size (node->number_child<int> ("InterWidth"), node->number_child<int> ("InterHeight"));
        _out_size = dcp::Size (node->number_child<int> ("OutWidth"), node->number_child<int> ("OutHeight"));
index 0dcc2eeec422295e1bd5e2c8ac108a90ea99c68e..0a6cab9069e189c9ea6bdf1161a1a9912edf59a1 100644 (file)
@@ -42,7 +42,7 @@ public:
                boost::shared_ptr<const ImageProxy>,
                DCPTime,
                Crop,
-               boost::optional<float>,
+               boost::optional<double>,
                dcp::Size,
                dcp::Size,
                Eyes,
@@ -88,7 +88,7 @@ private:
        boost::shared_ptr<const ImageProxy> _in;
        DCPTime _time;
        Crop _crop;
-       boost::optional<float> _fade;
+       boost::optional<double> _fade;
        dcp::Size _inter_size;
        dcp::Size _out_size;
        Eyes _eyes;
index e2fba5829a6f489e6638b94d376f624371dc4f1e..1c0bc5a60d045f758a17cf1948decf3dc1aa71c5 100644 (file)
@@ -103,10 +103,10 @@ VideoContent::VideoContent (shared_ptr<const Film> film, cxml::ConstNodePtr node
 {
        _video_size.width = node->number_child<int> ("VideoWidth");
        _video_size.height = node->number_child<int> ("VideoHeight");
-       _video_frame_rate = node->number_child<float> ("VideoFrameRate");
+       _video_frame_rate = node->number_child<double> ("VideoFrameRate");
        _video_length = node->number_child<Frame> ("VideoLength");
        _video_frame_type = static_cast<VideoFrameType> (node->number_child<int> ("VideoFrameType"));
-       _sample_aspect_ratio = node->optional_number_child<float> ("SampleAspectRatio");
+       _sample_aspect_ratio = node->optional_number_child<double> ("SampleAspectRatio");
        _crop.left = node->number_child<int> ("LeftCrop");
        _crop.right = node->number_child<int> ("RightCrop");
        _crop.top = node->number_child<int> ("TopCrop");
@@ -218,9 +218,9 @@ VideoContent::take_from_video_examiner (shared_ptr<VideoExaminer> d)
 {
        /* These examiner calls could call other content methods which take a lock on the mutex */
        dcp::Size const vs = d->video_size ();
-       optional<float> const vfr = d->video_frame_rate ();
+       optional<double> const vfr = d->video_frame_rate ();
        Frame vl = d->video_length ();
-       optional<float> const ar = d->sample_aspect_ratio ();
+       optional<double> const ar = d->sample_aspect_ratio ();
 
        {
                boost::mutex::scoped_lock lm (_mutex);
@@ -232,7 +232,7 @@ VideoContent::take_from_video_examiner (shared_ptr<VideoExaminer> d)
 
                /* Guess correct scale from size and sample aspect ratio */
                _scale = VideoContentScale (
-                       Ratio::nearest_from_ratio (float (_video_size.width) * ar.get_value_or (1) / _video_size.height)
+                       Ratio::nearest_from_ratio (double (_video_size.width) * ar.get_value_or (1) / _video_size.height)
                        );
        }
 
@@ -473,7 +473,7 @@ VideoContent::scale_and_crop_to_fit_height ()
 }
 
 void
-VideoContent::set_video_frame_rate (float r)
+VideoContent::set_video_frame_rate (double r)
 {
        {
                boost::mutex::scoped_lock lm (_mutex);
@@ -487,21 +487,21 @@ VideoContent::set_video_frame_rate (float r)
        signal_changed (VideoContentProperty::VIDEO_FRAME_RATE);
 }
 
-optional<float>
+optional<double>
 VideoContent::fade (Frame f) const
 {
        DCPOMATIC_ASSERT (f >= 0);
 
        if (f < fade_in()) {
-               return float (f) / fade_in();
+               return double (f) / fade_in();
        }
 
        Frame fade_out_start = video_length() - fade_out();
        if (f >= fade_out_start) {
-               return 1 - float (f - fade_out_start) / fade_out();
+               return 1 - double (f - fade_out_start) / fade_out();
        }
 
-       return optional<float> ();
+       return optional<double> ();
 }
 
 string
@@ -518,7 +518,7 @@ VideoContent::processing_description () const
                        );
 
 
-               float ratio = video_size_after_3d_split().ratio ();
+               double ratio = video_size_after_3d_split().ratio ();
 
                if (sample_aspect_ratio ()) {
                        d << ", " << _("pixel aspect ratio") << " " << fixed << setprecision(2) << sample_aspect_ratio().get () << ":1";
index 71c20e7373d772c822ef4b029b0a9dc612603379..fdd27498514e5cc95af219b059db0c6b812c63d6 100644 (file)
@@ -74,13 +74,13 @@ public:
                return _video_size;
        }
 
-       float video_frame_rate () const {
+       double video_frame_rate () const {
                boost::mutex::scoped_lock lm (_mutex);
                return _video_frame_rate;
        }
 
        void set_video_frame_type (VideoFrameType);
-       void set_video_frame_rate (float);
+       void set_video_frame_rate (double);
 
        void set_left_crop (int);
        void set_right_crop (int);
@@ -135,7 +135,7 @@ public:
                return _colour_conversion;
        }
 
-       boost::optional<float> sample_aspect_ratio () const {
+       boost::optional<double> sample_aspect_ratio () const {
                boost::mutex::scoped_lock lm (_mutex);
                return _sample_aspect_ratio;
        }
@@ -155,7 +155,7 @@ public:
 
        ContentTime dcp_time_to_content_time (DCPTime) const;
 
-       boost::optional<float> fade (Frame) const;
+       boost::optional<double> fade (Frame) const;
 
        void scale_and_crop_to_fit_width ();
        void scale_and_crop_to_fit_height ();
@@ -167,7 +167,7 @@ protected:
        void add_properties (std::list<std::pair<std::string, std::string> > &) const;
 
        Frame _video_length;
-       float _video_frame_rate;
+       double _video_frame_rate;
        boost::optional<ColourConversion> _colour_conversion;
 
 private:
@@ -185,7 +185,7 @@ private:
        /** Sample aspect ratio obtained from the content file's header,
            if there is one.
        */
-       boost::optional<float> _sample_aspect_ratio;
+       boost::optional<double> _sample_aspect_ratio;
        Frame _fade_in;
        Frame _fade_out;
 };
index f8d247d1542a41a9c229681bda6d2247457dd008..66d3ae5b57ea2b056a9678ac737b660de38ee0c9 100644 (file)
@@ -32,10 +32,10 @@ class VideoExaminer
 {
 public:
        virtual ~VideoExaminer () {}
-       virtual boost::optional<float> video_frame_rate () const = 0;
+       virtual boost::optional<double> video_frame_rate () const = 0;
        virtual dcp::Size video_size () const = 0;
        virtual Frame video_length () const = 0;
-       virtual boost::optional<float> sample_aspect_ratio () const {
-               return boost::optional<float> ();
+       virtual boost::optional<double> sample_aspect_ratio () const {
+               return boost::optional<double> ();
        }
 };
index 99cc845bcd1eb5f9ba5c2a60bb68c0e8d0284071..e326e00fb5a6da8c93467f40427751759b71a2c5 100644 (file)
@@ -85,7 +85,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_rgb)
                        shared_ptr<ImageProxy> (new RawImageProxy (image)),
                        DCPTime (),
                        Crop (),
-                       optional<float> (),
+                       optional<double> (),
                        dcp::Size (1998, 1080),
                        dcp::Size (1998, 1080),
                        EYES_BOTH,
@@ -166,7 +166,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_yuv)
                        shared_ptr<ImageProxy> (new RawImageProxy (image)),
                        DCPTime (),
                        Crop (),
-                       optional<float> (),
+                       optional<double> (),
                        dcp::Size (1998, 1080),
                        dcp::Size (1998, 1080),
                        EYES_BOTH,