1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5  * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 #ifndef _ENCODING_CONSTRAINTS_H_
8 #define _ENCODING_CONSTRAINTS_H_
9 
10 #include <algorithm>
11 
12 namespace mozilla {
13 class EncodingConstraints {
14  public:
EncodingConstraints()15   EncodingConstraints()
16       : maxWidth(0),
17         maxHeight(0),
18         maxFps(0),
19         maxFs(0),
20         maxBr(0),
21         maxPps(0),
22         maxMbps(0),
23         maxCpb(0),
24         maxDpb(0),
25         scaleDownBy(1.0) {}
26 
27   bool operator==(const EncodingConstraints& constraints) const {
28     return maxWidth == constraints.maxWidth &&
29            maxHeight == constraints.maxHeight && maxFps == constraints.maxFps &&
30            maxFs == constraints.maxFs && maxBr == constraints.maxBr &&
31            maxPps == constraints.maxPps && maxMbps == constraints.maxMbps &&
32            maxCpb == constraints.maxCpb && maxDpb == constraints.maxDpb &&
33            scaleDownBy == constraints.scaleDownBy;
34   }
35 
36   /**
37    * This returns true if the constraints affecting resolution are equal.
38    */
ResolutionEquals(const EncodingConstraints & constraints)39   bool ResolutionEquals(const EncodingConstraints& constraints) const {
40     return maxWidth == constraints.maxWidth &&
41            maxHeight == constraints.maxHeight && maxFs == constraints.maxFs &&
42            scaleDownBy == constraints.scaleDownBy;
43   }
44 
45   uint32_t maxWidth;
46   uint32_t maxHeight;
47   uint32_t maxFps;
48   uint32_t maxFs;
49   uint32_t maxBr;
50   uint32_t maxPps;
51   uint32_t maxMbps;    // macroblocks per second
52   uint32_t maxCpb;     // coded picture buffer size
53   uint32_t maxDpb;     // decoded picture buffer size
54   double scaleDownBy;  // To preserve resolution
55 };
56 }  // namespace mozilla
57 
58 #endif  // _ENCODING_CONSTRAINTS_H_
59