File chromium-100-InMilliseconds-constexpr.patch of Package chromium-ffmpeg-extra (Revision acf13cd4d3b182c723d1231bb1ce7ca6)
Currently displaying revision acf13cd4d3b182c723d1231bb1ce7ca6 , Show latest
98
1
From da6e3f6071fdabeb96c0805626418414b4a4cea8 Mon Sep 17 00:00:00 2001
2
From: Stephan Hartmann <stha09@googlemail.com>
3
Date: Wed, 9 Feb 2022 17:56:21 +0000
4
Subject: [PATCH] GCC: make base::InMilliseconds(F,RoundedUp) constexpr
5
6
media::DecodeTimestamp uses it in several constexpr methods.
7
---
8
base/time/time.cc | 24 ------------------------
9
base/time/time.h | 30 +++++++++++++++++++++++++++---
10
2 files changed, 27 insertions(+), 27 deletions(-)
11
12
diff --git a/base/time/time.cc b/base/time/time.cc
13
index 0de273e..e0acda2 100644
14
--- a/base/time/time.cc
15
+++ b/base/time/time.cc
16
17
: std::numeric_limits<int>::max();
18
}
19
20
-double TimeDelta::InMillisecondsF() const {
21
- if (!is_inf())
22
- return static_cast<double>(delta_) / Time::kMicrosecondsPerMillisecond;
23
- return (delta_ < 0) ? -std::numeric_limits<double>::infinity()
24
- : std::numeric_limits<double>::infinity();
25
-}
26
-
27
-int64_t TimeDelta::InMilliseconds() const {
28
- if (!is_inf())
29
- return delta_ / Time::kMicrosecondsPerMillisecond;
30
- return (delta_ < 0) ? std::numeric_limits<int64_t>::min()
31
- : std::numeric_limits<int64_t>::max();
32
-}
33
-
34
-int64_t TimeDelta::InMillisecondsRoundedUp() const {
35
- if (!is_inf()) {
36
- const int64_t result = delta_ / Time::kMicrosecondsPerMillisecond;
37
- // Convert |result| from truncating to ceiling.
38
- return (delta_ > result * Time::kMicrosecondsPerMillisecond) ? (result + 1)
39
- : result;
40
- }
41
- return delta_;
42
-}
43
-
44
double TimeDelta::InMicrosecondsF() const {
45
if (!is_inf())
46
return static_cast<double>(delta_);
47
diff --git a/base/time/time.h b/base/time/time.h
48
index c027aab..fb1d78d 100644
49
--- a/base/time/time.h
50
+++ b/base/time/time.h
51
52
constexpr int InMinutes() const;
53
constexpr double InSecondsF() const;
54
constexpr int64_t InSeconds() const;
55
- double InMillisecondsF() const;
56
- int64_t InMilliseconds() const;
57
- int64_t InMillisecondsRoundedUp() const;
58
+ constexpr double InMillisecondsF() const;
59
+ constexpr int64_t InMilliseconds() const;
60
+ constexpr int64_t InMillisecondsRoundedUp() const;
61
constexpr int64_t InMicroseconds() const { return delta_; }
62
double InMicrosecondsF() const;
63
constexpr int64_t InNanoseconds() const;
64
65
return is_inf() ? delta_ : (delta_ / Time::kMicrosecondsPerSecond);
66
}
67
68
+constexpr double TimeDelta::InMillisecondsF() const {
69
+ if (!is_inf())
70
+ return static_cast<double>(delta_) / Time::kMicrosecondsPerMillisecond;
71
+ return (delta_ < 0) ? -std::numeric_limits<double>::infinity()
72
+ : std::numeric_limits<double>::infinity();
73
+}
74
+
75
+constexpr int64_t TimeDelta::InMilliseconds() const {
76
+ if (!is_inf())
77
+ return delta_ / Time::kMicrosecondsPerMillisecond;
78
+ return (delta_ < 0) ? std::numeric_limits<int64_t>::min()
79
+ : std::numeric_limits<int64_t>::max();
80
+}
81
+
82
+constexpr int64_t TimeDelta::InMillisecondsRoundedUp() const {
83
+ if (!is_inf()) {
84
+ const int64_t result = delta_ / Time::kMicrosecondsPerMillisecond;
85
+ // Convert |result| from truncating to ceiling.
86
+ return (delta_ > result * Time::kMicrosecondsPerMillisecond) ? (result + 1)
87
+ : result;
88
+ }
89
+ return delta_;
90
+}
91
+
92
constexpr int64_t TimeDelta::InNanoseconds() const {
93
return base::ClampMul(delta_, Time::kNanosecondsPerMicrosecond);
94
}
95
--
96
2.34.1
97
98