1 /* 2 mkvmerge -- utility for splicing together matroska files 3 from component media subtypes 4 5 Distributed under the GPL v2 6 see the file COPYING for details 7 or visit https://www.gnu.org/licenses/old-licenses/gpl-2.0.html 8 9 the stereo mode helper 10 11 Written by Moritz Bunkus <moritz@bunkus.org>. 12 */ 13 14 #include "common/common_pch.h" 15 16 #include "common/stereo_mode.h" 17 18 #include <sstream> 19 #include <string> 20 #include <vector> 21 22 std::vector<std::string> stereo_mode_c::s_modes; 23 std::vector<translatable_string_c> stereo_mode_c::s_translations; 24 25 void init()26stereo_mode_c::init() { 27 s_modes.emplace_back("mono"); 28 s_modes.emplace_back("side_by_side_left_first"); 29 s_modes.emplace_back("top_bottom_right_first"); 30 s_modes.emplace_back("top_bottom_left_first"); 31 s_modes.emplace_back("checkerboard_right_first"); 32 s_modes.emplace_back("checkerboard_left_first"); 33 s_modes.emplace_back("row_interleaved_right_first"); 34 s_modes.emplace_back("row_interleaved_left_first"); 35 s_modes.emplace_back("column_interleaved_right_first"); 36 s_modes.emplace_back("column_interleaved_left_first"); 37 s_modes.emplace_back("anaglyph_cyan_red"); 38 s_modes.emplace_back("side_by_side_right_first"); 39 s_modes.emplace_back("anaglyph_green_magenta"); 40 s_modes.emplace_back("both_eyes_laced_left_first"); 41 s_modes.emplace_back("both_eyes_laced_right_first"); 42 } 43 44 void init_translations()45stereo_mode_c::init_translations() { 46 if (!s_translations.empty()) 47 return; 48 49 s_translations.emplace_back(YT("mono")); 50 s_translations.emplace_back(YT("side by side (left first)")); 51 s_translations.emplace_back(YT("top bottom (right first)")); 52 s_translations.emplace_back(YT("top bottom (left first)")); 53 s_translations.emplace_back(YT("checkerboard (right first)")); 54 s_translations.emplace_back(YT("checkerboard (left first)")); 55 s_translations.emplace_back(YT("row interleaved (right first)")); 56 s_translations.emplace_back(YT("row interleaved (left first)")); 57 s_translations.emplace_back(YT("column interleaved (right first)")); 58 s_translations.emplace_back(YT("column interleaved (left first)")); 59 s_translations.emplace_back(YT("anaglyph (cyan/red)")); 60 s_translations.emplace_back(YT("side by side (right first)")); 61 s_translations.emplace_back(YT("anaglyph (green/magenta)")); 62 s_translations.emplace_back(YT("both eyes laced in one block (left first)")); 63 s_translations.emplace_back(YT("both eyes laced in one block (right first)")); 64 } 65 66 const std::string translate(unsigned int mode)67stereo_mode_c::translate(unsigned int mode) { 68 init_translations(); 69 return mode < s_translations.size() ? s_translations[mode].get_translated() : Y("unknown"); 70 } 71 72 stereo_mode_c::mode parse_mode(const std::string & mode)73stereo_mode_c::parse_mode(const std::string &mode) { 74 unsigned int idx; 75 for (idx = 0; s_modes.size() > idx; ++idx) 76 if (s_modes[idx] == mode) 77 return static_cast<stereo_mode_c::mode>(idx); 78 return invalid; 79 } 80 81 const std::string displayable_modes_list()82stereo_mode_c::displayable_modes_list() { 83 std::stringstream keywords_str; 84 for (auto &keyword : s_modes) { 85 if (!keywords_str.str().empty()) 86 keywords_str << ", "; 87 keywords_str << "'" << keyword << "'"; 88 } 89 90 return keywords_str.str(); 91 } 92 93 bool valid_index(int idx)94stereo_mode_c::valid_index(int idx) { 95 return (0 <= idx) && (static_cast<int>(s_modes.size()) > idx); 96 } 97