1 /***************************************************************************** 2 3 FmtAvs.h 4 Author: Laurent de Soras, 2021 5 6 --- Legal stuff --- 7 8 This program is free software. It comes without any warranty, to 9 the extent permitted by applicable law. You can redistribute it 10 and/or modify it under the terms of the Do What The Fuck You Want 11 To Public License, Version 2, as published by Sam Hocevar. See 12 http://www.wtfpl.net/ for more details. 13 14 *Tab=3***********************************************************************/ 15 16 17 18 #pragma once 19 #if ! defined (fmtcavs_FmtAvs_HEADER_INCLUDED) 20 #define fmtcavs_FmtAvs_HEADER_INCLUDED 21 22 23 24 /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 25 26 #include "fmtcl/ColorFamily.h" 27 28 #include <string> 29 30 31 32 struct VideoInfo; 33 34 namespace fmtcavs 35 { 36 37 38 39 class FmtAvs 40 { 41 42 /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 43 44 public: 45 46 static constexpr int _max_css = 3; 47 48 explicit FmtAvs (std::string fmt_str); 49 explicit FmtAvs (const VideoInfo &vi) noexcept; 50 FmtAvs () = default; 51 FmtAvs (const FmtAvs &other) = default; 52 FmtAvs (FmtAvs &&other) = default; 53 ~FmtAvs () = default; 54 FmtAvs & operator = (const FmtAvs &other) = default; 55 FmtAvs & operator = (FmtAvs &&other) = default; 56 57 void invalidate () noexcept; 58 int conv_from_str (std::string fmt_str); 59 void conv_from_vi (const VideoInfo &vi); 60 int conv_to_vi (VideoInfo &vi) const; 61 62 bool is_valid () const noexcept; 63 64 void set_bitdepth (int bitdepth) noexcept; 65 int get_bitdepth () const noexcept; 66 bool is_float () const noexcept; 67 void set_col_fam (fmtcl::ColorFamily col_fam) noexcept; 68 fmtcl::ColorFamily 69 get_col_fam () const noexcept; 70 bool is_planar () const noexcept; 71 bool has_alpha () const noexcept; 72 void set_subspl_h (int ss) noexcept; 73 int get_subspl_h () const noexcept; 74 void set_subspl_v (int ss) noexcept; 75 int get_subspl_v () const noexcept; 76 77 int get_nbr_comp_non_alpha () const noexcept; 78 79 static bool is_bitdepth_valid (int bitdepth) noexcept; 80 81 82 83 /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 84 85 protected: 86 87 88 89 /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 90 91 private: 92 93 static std::string 94 remove_outer_spaces (std::string str); 95 static bool is_eq_leftstr_and_eat (std::string &str, std::string stest); 96 static bool check_planar_bits_and_eat (std::string &str, int &res); 97 static int check_bits_and_eat (std::string &str, bool allow_s_flag); 98 99 int _bitdepth = -1; 100 fmtcl::ColorFamily 101 _col_fam = fmtcl::ColorFamily_INVALID; 102 bool _planar_flag = false; // Y formats are considered planar 103 bool _alpha_flag = false; 104 int _subspl_h = -1; // Bitshift, >= 0. Negative: invalid 105 int _subspl_v = -1; // Same 106 107 108 109 /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 110 111 private: 112 113 bool operator == (const FmtAvs &other) const = delete; 114 bool operator != (const FmtAvs &other) const = delete; 115 116 }; // class FmtAvs 117 118 119 120 } // namespace fmtcavs 121 122 123 124 //#include "fmtcavs/FmtAvs.hpp" 125 126 127 128 #endif // fmtcavs_FmtAvs_HEADER_INCLUDED 129 130 131 132 /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 133