libjxl

FORK: libjxl patches used on blog
git clone https://git.neptards.moe/blog/libjxl.git
Log | Files | Refs | Submodules | README | LICENSE

override.h (866B)


      1 // Copyright (c) the JPEG XL Project Authors. All rights reserved.
      2 //
      3 // Use of this source code is governed by a BSD-style
      4 // license that can be found in the LICENSE file.
      5 
      6 #ifndef LIB_JXL_BASE_OVERRIDE_H_
      7 #define LIB_JXL_BASE_OVERRIDE_H_
      8 
      9 #include <cstdint>
     10 
     11 // 'Trool' for command line arguments: force enable/disable, or use default.
     12 
     13 namespace jxl {
     14 
     15 // No effect if kDefault, otherwise forces a feature (typically a FrameHeader
     16 // flag) on or off.
     17 enum class Override : int8_t { kOn = 1, kOff = 0, kDefault = -1 };
     18 
     19 static inline Override OverrideFromBool(bool flag) {
     20   return flag ? Override::kOn : Override::kOff;
     21 }
     22 
     23 static inline bool ApplyOverride(Override o, bool default_condition) {
     24   if (o == Override::kOn) return true;
     25   if (o == Override::kOff) return false;
     26   return default_condition;
     27 }
     28 
     29 }  // namespace jxl
     30 
     31 #endif  // LIB_JXL_BASE_OVERRIDE_H_