Cleanup: move stride_round_up into the only place it is used.
authorCarl Hetherington <cth@carlh.net>
Mon, 24 Jan 2022 21:30:20 +0000 (22:30 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 25 Jan 2022 18:44:56 +0000 (19:44 +0100)
src/lib/image.cc
src/lib/util.cc
src/lib/util.h

index 2e1d3fbf58bffb7724861bfe2f5ed0d2f1ea9996..20aece3e8e07818fdc8c2aefd07fdbbce5c085a0 100644 (file)
@@ -973,9 +973,15 @@ Image::allocate ()
        _stride = (int *) wrapped_av_malloc (4 * sizeof (int));
        _stride[0] = _stride[1] = _stride[2] = _stride[3] = 0;
 
+       auto stride_round_up = [](int stride, int t) {
+               int const a = stride + (t - 1);
+               return a - (a % t);
+       };
+
        for (int i = 0; i < planes(); ++i) {
                _line_size[i] = ceil (_size.width * bytes_per_pixel(i));
-               _stride[i] = stride_round_up (i, _line_size, _alignment == Alignment::PADDED ? ALIGNMENT : 1);
+               _stride[i] = stride_round_up (_line_size[i], _alignment == Alignment::PADDED ? ALIGNMENT : 1);
+
 
                /* The assembler function ff_rgb24ToY_avx (in libswscale/x86/input.asm)
                   uses a 16-byte fetch to read three bytes (R/G/B) of image data.
index 1984ed4766e58473285ae0d41d2fba85d4d51de7..2767068d4ddb6d41cf477b32a9f94b5b73cf52ca 100644 (file)
@@ -551,20 +551,6 @@ simple_digest (vector<boost::filesystem::path> paths)
 }
 
 
-/** Round a number up to the nearest multiple of another number.
- *  @param c Index.
- *  @param stride Array of numbers to round, indexed by c.
- *  @param t Multiple to round to.
- *  @return Rounded number.
- */
-int
-stride_round_up (int c, int const * stride, int t)
-{
-       int const a = stride[c] + (t - 1);
-       return a - (a % t);
-}
-
-
 /** Trip an assert if the caller is not in the UI thread */
 void
 ensure_ui_thread ()
index 790feea05242a08a7b4df65a7770fe92bfbe7b62..a369034374a5c38d62205f0e974e5d614f3725af 100644 (file)
@@ -102,7 +102,6 @@ extern boost::filesystem::path mo_path ();
 #endif
 extern std::string tidy_for_filename (std::string);
 extern dcp::Size fit_ratio_within (float ratio, dcp::Size);
-extern int stride_round_up (int, int const *, int);
 extern void* wrapped_av_malloc (size_t);
 extern void set_backtrace_file (boost::filesystem::path);
 extern std::map<std::string, std::string> split_get_request (std::string url);