RawSpeed
fast raw decoding library
Loading...
Searching...
No Matches
Common.cpp
Go to the documentation of this file.
1/*
2 RawSpeed - RAW file decoder.
3
4 Copyright (C) 2017 Roman Lebedev
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19*/
20
21#include "rawspeedconfig.h"
22#include "bench/Common.h"
23#include "adt/Casts.h"
24#include "adt/Point.h"
25#include "common/Common.h"
26#include <cassert>
27#include <cmath>
28#include <cstdint>
29#include <cstdlib>
30
33using std::sqrt;
34
35bool RAWSPEED_READNONE __attribute__((visibility("default")))
37 // NOLINTNEXTLINE(concurrency-mt-unsafe)
38 return std::getenv("RAWSPEED_BENCHMARK_DRYRUN") != nullptr;
39}
40
41iPoint2D RAWSPEED_READNONE __attribute__((visibility("default")))
43 double sqSide = sqrt(area);
44 double sqARatio =
45 sqrt(static_cast<double>(aspect.x) / static_cast<double>(aspect.y));
46
49
52
53 assert(dim.area() >= area);
54
55 return dim;
56}
constexpr uint64_t RAWSPEED_READNONE roundUp(uint64_t value, uint64_t multiple)
Definition Common.h:134
bool RAWSPEED_READNONE __attribute__((visibility("default"))) benchmarkDryRun()
Definition Common.cpp:35
double sqARatio
Definition Common.cpp:44
iPoint2D dim(rawspeed::implicit_cast< int >(ceil(sqSide *sqARatio)), rawspeed::implicit_cast< int >(ceil(sqSide/sqARatio)))
Definition Common.cpp:55
iPoint2D RAWSPEED_READNONE iPoint2D aspect
Definition Common.cpp:42
assert(dim.area() >=area)
bool RAWSPEED_READNONE benchmarkDryRun()
rawspeed::iPoint2D RAWSPEED_READNONE areaToRectangle(uint64_t area, rawspeed::iPoint2D aspect={2, 2})
constexpr uint64_t RAWSPEED_READNONE roundUp(uint64_t value, uint64_t multiple)
Definition Common.h:134
constexpr RAWSPEED_READNONE Ttgt implicit_cast(Tsrc value)
Definition Casts.h:32