diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-10-02 11:08:37 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-10-02 11:08:37 +0200 |
| commit | fae11d166fd4f1d56ce8cfe59a3af78feb336733 (patch) | |
| tree | 0e81b9ad882fb53470f4f3a4c89c4e45bb9ffade /src | |
| parent | d8a20fef494065a9b3ccf2d93328861b1eea1d4f (diff) | |
Add round_to_log_2()
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/image.cc | 4 | ||||
| -rw-r--r-- | src/lib/util.cc | 7 | ||||
| -rw-r--r-- | src/lib/util.h | 1 |
3 files changed, 10 insertions, 2 deletions
diff --git a/src/lib/image.cc b/src/lib/image.cc index 8e6c5717b..548c3a2b7 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -144,7 +144,7 @@ static int round_width_for_subsampling (int p, AVPixFmtDescriptor const * desc) { - return p & ~ ((1 << desc->log2_chroma_w) - 1); + return round_to_log_2 (p, desc->log2_chroma_w); } @@ -152,7 +152,7 @@ static int round_height_for_subsampling (int p, AVPixFmtDescriptor const * desc) { - return p & ~ ((1 << desc->log2_chroma_h) - 1); + return round_to_log_2 (p, desc->log2_chroma_h); } diff --git a/src/lib/util.cc b/src/lib/util.cc index 0646a4787..33f24eeeb 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -1183,6 +1183,13 @@ to_upper (string s) } +int +round_to_log_2 (int x, int b) +{ + return x & ~ ((1 << b) - 1); +} + + /* Set to 1 to print the IDs of some of our threads to stdout on creation */ #define DCPOMATIC_DEBUG_THREADS 0 diff --git a/src/lib/util.h b/src/lib/util.h index 013eabe12..e134804ae 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -124,6 +124,7 @@ extern dcp::DecryptedKDM decrypt_kdm_with_helpful_error (dcp::EncryptedKDM kdm); extern boost::filesystem::path default_font_file (); extern std::string to_upper (std::string s); extern void start_of_thread (std::string name); +extern int round_to_log_2 (int x, int b); template <class T> std::list<T> |
