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>
Sun, 3 Apr 2022 21:43:34 +0000 (23:43 +0200)
src/lib/image.cc
src/lib/util.cc
src/lib/util.h

index 1adcabc065a2f1d3293c504a7c5df001cb05e0fc..d0878efbd75f81b3bcead98c19a0b2d832f8150e 100644 (file)
@@ -972,9 +972,14 @@ 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 ccd505e57d8ee263eee8c20b484f9b0e55760d32..6bcacf9f2bd3733dd09e1f2bafbdeeb100b8fb9e 100644 (file)
@@ -529,18 +529,6 @@ digest_head_tail (vector<boost::filesystem::path> files, boost::uintmax_t size)
        return digester.get ();
 }
 
-/** 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
index cbf4b491b8f31acdf6ebc243eb7696d132128222..bd9eaf96e1664f5286dedd6d5683a48616187e46 100644 (file)
@@ -106,7 +106,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);