From: Carl Hetherington Date: Mon, 24 Jan 2022 21:30:20 +0000 (+0100) Subject: Cleanup: move stride_round_up into the only place it is used. X-Git-Tag: v2.16.9~15 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=4b74bd9f359b9fe4f841cd9a361f3b2b24c2351e Cleanup: move stride_round_up into the only place it is used. --- diff --git a/src/lib/image.cc b/src/lib/image.cc index 1adcabc06..d0878efbd 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -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. diff --git a/src/lib/util.cc b/src/lib/util.cc index ccd505e57..6bcacf9f2 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -529,18 +529,6 @@ digest_head_tail (vector 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 diff --git a/src/lib/util.h b/src/lib/util.h index cbf4b491b..bd9eaf96e 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -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 split_get_request (std::string url);