summaryrefslogtreecommitdiff
path: root/src/lib/image.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-01-24 22:30:20 +0100
committerCarl Hetherington <cth@carlh.net>2022-01-25 19:44:56 +0100
commitf471db4e8dc7f3dd1eb7a9cf4d8d11e7d340df65 (patch)
tree183c602f84b0fd54230d622406ecc1b550981a40 /src/lib/image.cc
parent07befde2cbbad4d979631727fc35399164d0aa1c (diff)
Cleanup: move stride_round_up into the only place it is used.
Diffstat (limited to 'src/lib/image.cc')
-rw-r--r--src/lib/image.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lib/image.cc b/src/lib/image.cc
index 2e1d3fbf5..20aece3e8 100644
--- a/src/lib/image.cc
+++ b/src/lib/image.cc
@@ -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.