Purge rint() and use llrint and friends.
authorCarl Hetherington <cth@carlh.net>
Tue, 25 Aug 2015 21:17:23 +0000 (22:17 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 25 Aug 2015 21:17:23 +0000 (22:17 +0100)
19 files changed:
src/lib/audio_content.cc
src/lib/dcp_content.cc
src/lib/dcpomatic_time.cc
src/lib/dcpomatic_time.h
src/lib/ffmpeg_content.cc
src/lib/ffmpeg_decoder.cc
src/lib/image.cc
src/lib/image_content.cc
src/lib/job.cc
src/lib/player.cc
src/lib/util.cc
src/lib/video_content_scale.cc
src/lib/writer.cc
src/wx/film_viewer.cc
src/wx/subtitle_panel.cc
src/wx/timeline_time_axis_view.cc
src/wx/wx_util.cc
test/audio_decoder_test.cc
test/frame_rate_test.cc

index 4d821ad6008e0b36f78fde9655e63642fb7e15e8..5e14fb232234be625e78dfae349fe9ae49df8a14 100644 (file)
@@ -206,7 +206,7 @@ AudioContent::resampled_audio_frame_rate () const
                t /= frc.speed_up;
        }
 
-       return rint (t);
+       return lrint (t);
 }
 
 string
index b1c9e3815fd916b8edb57ee7e9bad8576052a3c6..57c103e03113f931ae8c56249ab3d7b44329b705 100644 (file)
@@ -146,7 +146,7 @@ DCPContent::full_length () const
        shared_ptr<const Film> film = _film.lock ();
        DCPOMATIC_ASSERT (film);
        FrameRateChange const frc (video_frame_rate (), film->video_frame_rate ());
-       return DCPTime::from_frames (rint (video_length () * frc.factor ()), film->video_frame_rate ());
+       return DCPTime::from_frames (llrint (video_length () * frc.factor ()), film->video_frame_rate ());
 }
 
 string
index 3d4ed11398d67d5f4c034c18406561f75fa694d5..6f8f5efa2d4eb01b8b7249447c271ac79dc33bc4 100644 (file)
@@ -23,14 +23,14 @@ using std::ostream;
 
 template <>
 Time<ContentTimeDifferentiator, DCPTimeDifferentiator>::Time (DCPTime d, FrameRateChange f)
-       : _t (rint (d.get() * f.speed_up))
+       : _t (llrint (d.get() * f.speed_up))
 {
 
 }
 
 template <>
 Time<DCPTimeDifferentiator, ContentTimeDifferentiator>::Time (ContentTime d, FrameRateChange f)
-       : _t (rint (d.get() / f.speed_up))
+       : _t (llrint (d.get() / f.speed_up))
 {
 
 }
index c1d27407a90d2c4c8ba49fb57162109c087187bb..ba3c8fcad106186ca07947726e7065bbe2acbf10 100644 (file)
@@ -118,7 +118,7 @@ public:
         *  @param r Sampling rate.
         */
        Time<S, O> round_up (float r) {
-               Type const n = rint (HZ / r);
+               Type const n = llrintf (HZ / r);
                Type const a = _t + n - 1;
                return Time<S, O> (a - (a % n));
        }
@@ -180,7 +180,7 @@ public:
 
 
        static Time<S, O> from_seconds (double s) {
-               return Time<S, O> (rint (s * HZ));
+               return Time<S, O> (llrint (s * HZ));
        }
 
        template <class T>
index 071f9861281cb2d236a7ad3c3c518b888a198d7b..4e49e12548f7dfb7c11720a37695c21f0f95a4de 100644 (file)
@@ -281,7 +281,7 @@ FFmpegContent::full_length () const
        shared_ptr<const Film> film = _film.lock ();
        DCPOMATIC_ASSERT (film);
        FrameRateChange const frc (video_frame_rate (), film->video_frame_rate ());
-       return DCPTime::from_frames (rint (video_length_after_3d_combine() * frc.factor()), film->video_frame_rate());
+       return DCPTime::from_frames (llrint (video_length_after_3d_combine() * frc.factor()), film->video_frame_rate());
 }
 
 void
index a17419dc7b143f8f37432d24ea5043a0b7a70b02..eab85c04ed48c626516b31a03dd4cd91af76327b 100644 (file)
@@ -418,7 +418,7 @@ FFmpegDecoder::decode_video_packet ()
                        double const pts = i->second * av_q2d (_format_context->streams[_video_stream]->time_base) + _pts_offset.seconds ();
                        video (
                                shared_ptr<ImageProxy> (new RawImageProxy (image)),
-                               rint (pts * _ffmpeg_content->video_frame_rate ())
+                               llrint (pts * _ffmpeg_content->video_frame_rate ())
                                );
                } else {
                        LOG_WARNING_NC ("Dropping frame without PTS");
index 0c7a0ef0da26bfad6ea20f96ec2a5316af678a9a..fcdcca95aad3909353a99e8a60a62edebf929d4e 100644 (file)
@@ -76,8 +76,8 @@ Image::sample_size (int n) const
        }
 
        return dcp::Size (
-               rint (ceil (static_cast<double>(size().width) / horizontal_factor)),
-               rint (ceil (static_cast<double>(size().height) / line_factor (n)))
+               lrint (ceil (static_cast<double>(size().width) / horizontal_factor)),
+               lrint (ceil (static_cast<double>(size().height) / line_factor (n)))
                );
 }
 
@@ -166,7 +166,7 @@ Image::crop_scale_window (
                   round down so that we don't crop a subsampled pixel until
                   we've cropped all of its Y-channel pixels.
                */
-               int const x = int (rint (bytes_per_pixel(c) * crop.left)) & ~ ((int) desc->log2_chroma_w);
+               int const x = lrintf (bytes_per_pixel(c) * crop.left) & ~ ((int) desc->log2_chroma_w);
                scale_in_data[c] = data()[c] + x + stride()[c] * (crop.top / line_factor(c));
        }
 
@@ -175,7 +175,7 @@ Image::crop_scale_window (
 
        uint8_t* scale_out_data[out->planes()];
        for (int c = 0; c < out->planes(); ++c) {
-               scale_out_data[c] = out->data()[c] + int (rint (out->bytes_per_pixel(c) * corner.x)) + out->stride()[c] * corner.y;
+               scale_out_data[c] = out->data()[c] + lrintf (out->bytes_per_pixel(c) * corner.x) + out->stride()[c] * corner.y;
        }
 
        sws_scale (
index 920d7ae54753db4b4b4bbe1f223e48b4cb94d766..87aa1d66d65ee21f215a97d011172dcc374f32e6 100644 (file)
@@ -142,7 +142,7 @@ ImageContent::full_length () const
        shared_ptr<const Film> film = _film.lock ();
        DCPOMATIC_ASSERT (film);
        FrameRateChange const frc (video_frame_rate(), film->video_frame_rate());
-       return DCPTime::from_frames (rint (video_length_after_3d_combine() * frc.factor ()), film->video_frame_rate ());
+       return DCPTime::from_frames (llrint (video_length_after_3d_combine() * frc.factor ()), film->video_frame_rate ());
 }
 
 string
index 25a533654a0afa08d466e9f5f906b6fdc9ec2532..d9715aa18535603d6040b6c8287b2788e385f086 100644 (file)
@@ -332,7 +332,7 @@ Job::status () const
 
        SafeStringStream s;
        if (!finished () && p) {
-               int pc = rint (p.get() * 100);
+               int pc = lrintf (p.get() * 100);
                if (pc == 100) {
                        /* 100% makes it sound like we've finished when we haven't */
                        pc = 99;
index c51f80067fbd87745aa366f202e48a67b858ac65..a40c65cd54027e7a553ea416098793302f490533 100644 (file)
@@ -293,8 +293,8 @@ Player::transform_image_subtitles (list<ImageSubtitle> subs) const
                                        true
                                        ),
                                Position<int> (
-                                       rint (_video_container_size.width * i->rectangle.x),
-                                       rint (_video_container_size.height * i->rectangle.y)
+                                       lrint (_video_container_size.width * i->rectangle.x),
+                                       lrint (_video_container_size.height * i->rectangle.y)
                                        )
                                )
                        );
index 76e76328d861110a5441ce36f95dabcb0982c307..bccc368da51442a0ff51028c6b7a665d7bed6874 100644 (file)
@@ -539,10 +539,10 @@ dcp::Size
 fit_ratio_within (float ratio, dcp::Size full_frame)
 {
        if (ratio < full_frame.ratio ()) {
-               return dcp::Size (rint (full_frame.height * ratio), full_frame.height);
+               return dcp::Size (lrintf (full_frame.height * ratio), full_frame.height);
        }
 
-       return dcp::Size (full_frame.width, rint (full_frame.width / ratio));
+       return dcp::Size (full_frame.width, lrintf (full_frame.width / ratio));
 }
 
 void *
index c8c29536117c83fc1e89db36c20cdbada8caf559..aae135311c9a23375ff6a16cdfde28c219799549 100644 (file)
@@ -155,8 +155,8 @@ VideoContentScale::size (shared_ptr<const VideoContent> c, dcp::Size display_con
                        float (display_container.height) / film_container.height
                        );
 
-               size.width = rint (size.width * scale);
-               size.height = rint (size.height * scale);
+               size.width = lrintf (size.width * scale);
+               size.height = lrintf (size.height * scale);
        }
 
        return size;
index 053c18451aec1498091c48ea59ad23ab0251c76a..b7c85c2ae06f6f25dadecea75ba3d01a3f619296 100644 (file)
@@ -770,7 +770,7 @@ operator== (QueueItem const & a, QueueItem const & b)
 void
 Writer::set_encoder_threads (int threads)
 {
-       _maximum_frames_in_memory = rint (threads * 1.1);
+       _maximum_frames_in_memory = lrint (threads * 1.1);
 }
 
 long
index 9b648a8b970ed28c3fb031a72e70d9b18d8ef237..b43db0d7b04867d52f560e63d11bce06e8f21c4c 100644 (file)
@@ -316,11 +316,11 @@ FilmViewer::calculate_sizes ()
        if (panel_ratio < film_ratio) {
                /* panel is less widscreen than the film; clamp width */
                _out_size.width = _panel_size.width;
-               _out_size.height = rint (_out_size.width / film_ratio);
+               _out_size.height = lrintf (_out_size.width / film_ratio);
        } else {
                /* panel is more widescreen than the film; clamp height */
                _out_size.height = _panel_size.height;
-               _out_size.width = rint (_out_size.height * film_ratio);
+               _out_size.width = lrintf (_out_size.height * film_ratio);
        }
 
        /* Catch silly values */
@@ -379,7 +379,7 @@ FilmViewer::update_position_label ()
 
        double const fps = _film->video_frame_rate ();
        /* Count frame number from 1 ... not sure if this is the best idea */
-       _frame_number->SetLabel (wxString::Format (wxT("%d"), int (rint (_position.seconds() * fps)) + 1));
+       _frame_number->SetLabel (wxString::Format (wxT("%d"), lrint (_position.seconds() * fps) + 1));
        _timecode->SetLabel (time_to_timecode (_position, fps));
 }
 
index 3d6e5c8c37b0d6f1bc857bfeabae68d8558357b2..d99b545587393104aeb1f0731d1a8b0f3b3ebd42 100644 (file)
@@ -173,9 +173,9 @@ SubtitlePanel::film_content_changed (int property)
        } else if (property == SubtitleContentProperty::SUBTITLE_Y_OFFSET) {
                checked_set (_y_offset, scs ? (scs->subtitle_y_offset() * 100) : 0);
        } else if (property == SubtitleContentProperty::SUBTITLE_X_SCALE) {
-               checked_set (_x_scale, scs ? int (rint (scs->subtitle_x_scale() * 100)) : 100);
+               checked_set (_x_scale, scs ? lrint (scs->subtitle_x_scale() * 100) : 100);
        } else if (property == SubtitleContentProperty::SUBTITLE_Y_SCALE) {
-               checked_set (_y_scale, scs ? int (rint (scs->subtitle_y_scale() * 100)) : 100);
+               checked_set (_y_scale, scs ? lrint (scs->subtitle_y_scale() * 100) : 100);
        } else if (property == SubtitleContentProperty::SUBTITLE_LANGUAGE) {
                checked_set (_language, scs ? scs->subtitle_language() : "");
        }
index 7882c1231d2041e0023e8d645013a6fb70f501fb..2667d9834a7ecd5497e8cb8330722e653b7e09e3 100644 (file)
@@ -55,16 +55,16 @@ TimelineTimeAxisView::do_paint (wxGraphicsContext* gc)
 
        double mark_interval = rint (128 / pps);
        if (mark_interval > 5) {
-               mark_interval -= int (rint (mark_interval)) % 5;
+               mark_interval -= lrint (mark_interval) % 5;
        }
        if (mark_interval > 10) {
-               mark_interval -= int (rint (mark_interval)) % 10;
+               mark_interval -= lrint (mark_interval) % 10;
        }
        if (mark_interval > 60) {
-               mark_interval -= int (rint (mark_interval)) % 60;
+               mark_interval -= lrint (mark_interval) % 60;
        }
        if (mark_interval > 3600) {
-               mark_interval -= int (rint (mark_interval)) % 3600;
+               mark_interval -= lrint (mark_interval) % 3600;
        }
 
        if (mark_interval < 1) {
index 5acc2d6cd1781b9585a8e7b1d44ca430df73247b..3d37c373b0aee49177c5a55397a54ebd8dc98161 100644 (file)
@@ -341,6 +341,6 @@ time_to_timecode (DCPTime t, double fps)
        w -= m * 60;
        int const s = floor (w);
        w -= s;
-       int const f = rint (w * fps);
+       int const f = lrint (w * fps);
        return wxString::Format (wxT("%02d:%02d:%02d.%02d"), h, m, s, f);
 }
index 8af5dfb11102585764fe89bbc8678bca3801c7b0..00d555d86298ff600946b9002189d061bd3514ad 100644 (file)
@@ -51,7 +51,7 @@ public:
        }
 
        Frame audio_length () const {
-               return rint (61.2942 * audio_stream()->frame_rate ());
+               return llrint (61.2942 * audio_stream()->frame_rate ());
        }
 };
 
index b9fd51391e043a926530cb2b52d16cd7c9a6ac28..a318ada11e66c6e844bf3b8ae6bdef1e53755249 100644 (file)
@@ -301,5 +301,5 @@ BOOST_AUTO_TEST_CASE (audio_sampling_rate_test)
        /* The FrameRateChange within resampled_audio_frame_rate should choose to double-up
           the 14.99 fps video to 30 and then run it slow at 25.
        */
-       BOOST_CHECK_EQUAL (content->resampled_audio_frame_rate(), rint (48000 * 2 * 14.99 / 25));
+       BOOST_CHECK_EQUAL (content->resampled_audio_frame_rate(), lrint (48000 * 2 * 14.99 / 25));
 }