// Copyright (c) the JPEG XL Project Authors. All rights reserved. // // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file.
// Macro to define the Fields' derived class Name when compiling with debug // names. #if (JXL_IS_DEBUG_BUILD) #define JXL_FIELDS_NAME(X) \ constchar* Name() const override { return#X; } #else #define JXL_FIELDS_NAME(X) #endif// JXL_IS_DEBUG_BUILD
class Visitor; class Fields { public: virtual ~Fields() = default; #if (JXL_IS_DEBUG_BUILD) virtualconstchar* Name() const = 0; #endif// JXL_IS_DEBUG_BUILD virtual Status VisitFields(Visitor* JXL_RESTRICT visitor) = 0;
};
// Distribution of U32 values for one particular selector. Represents either a // power of two-sized range, or a single value. A separate type ensures this is // only passed to the U32Enc ctor. struct U32Distr { // No need to validate - all `d` are legitimate.
constexpr explicit U32Distr(uint32_t d) : d(d) {}
// Returns bit with the given `index` (0 = least significant). template <typename T> staticinline constexpr uint64_t MakeBit(T index) { return 1ULL << static_cast<uint32_t>(index);
}
// Returns vector of all possible values of an Enum type. Relies on each Enum // providing an overload of EnumBits() that returns a bit array of its values, // which implies values must be in [0, 64). template <typenameEnum>
std::vector<Enum> Values() {
uint64_t bits = EnumBits(Enum());
// For each 1-bit in bits: add its index as value while (bits != 0) { constint index = Num0BitsBelowLS1Bit_Nonzero(bits);
values.push_back(static_cast<Enum>(index));
bits &= bits - 1; // clear least-significant bit
} return values;
}
// Returns true if value is one of Values<Enum>(). template <classEnum>
Status EnumValid(constEnum value) { if (static_cast<uint32_t>(value) >= 64) { return JXL_FAILURE("Value %u too large for %s\n", static_cast<uint32_t>(value), EnumName(Enum()));
} const uint64_t bit = MakeBit(value); if ((EnumBits(Enum()) & bit) == 0) { return JXL_FAILURE("Invalid value %u for %s\n", static_cast<uint32_t>(value), EnumName(Enum()));
} returntrue;
}
} // namespace jxl
#endif// LIB_JXL_FIELD_ENCODINGS_H_
Messung V0.5
¤ Dauer der Verarbeitung: 0.0 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.