[videodb] remove unused seasons table from episode_view
[xbmc.git] / xbmc / cores / VideoSettings.h
bloba7135da5d8734e9f7ce89770c82196da71081691
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include "utils/Map.h"
13 #include <string_view>
15 #include <fmt/format.h>
17 // VideoSettings.h: interface for the CVideoSettings class.
19 //////////////////////////////////////////////////////////////////////
21 enum EINTERLACEMETHOD
23 VS_INTERLACEMETHOD_NONE=0,
24 VS_INTERLACEMETHOD_AUTO=1,
25 VS_INTERLACEMETHOD_RENDER_BLEND=2,
26 VS_INTERLACEMETHOD_RENDER_WEAVE=4,
27 VS_INTERLACEMETHOD_RENDER_BOB=6,
28 VS_INTERLACEMETHOD_DEINTERLACE=7,
29 VS_INTERLACEMETHOD_VDPAU_BOB=8,
30 VS_INTERLACEMETHOD_VDPAU_INVERSE_TELECINE=11,
31 VS_INTERLACEMETHOD_VDPAU_TEMPORAL=12,
32 VS_INTERLACEMETHOD_VDPAU_TEMPORAL_HALF=13,
33 VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL=14,
34 VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL_HALF=15,
35 VS_INTERLACEMETHOD_DEINTERLACE_HALF=16,
36 VS_INTERLACEMETHOD_VAAPI_BOB = 22,
37 VS_INTERLACEMETHOD_VAAPI_MADI = 23,
38 VS_INTERLACEMETHOD_VAAPI_MACI = 24,
39 VS_INTERLACEMETHOD_DXVA_AUTO = 32,
40 VS_INTERLACEMETHOD_MAX // do not use and keep as last enum value.
43 template<>
44 struct fmt::formatter<EINTERLACEMETHOD> : fmt::formatter<std::string_view>
46 template<typename FormatContext>
47 constexpr auto format(const EINTERLACEMETHOD& interlaceMethod, FormatContext& ctx)
49 const auto it = interlaceMethodMap.find(interlaceMethod);
50 if (it == interlaceMethodMap.cend())
51 throw std::range_error("no interlace method string found");
53 return fmt::formatter<string_view>::format(it->second, ctx);
56 private:
57 static constexpr auto interlaceMethodMap = make_map<EINTERLACEMETHOD, std::string_view>({
58 {VS_INTERLACEMETHOD_NONE, "none"},
59 {VS_INTERLACEMETHOD_AUTO, "auto"},
60 {VS_INTERLACEMETHOD_RENDER_BLEND, "render blend"},
61 {VS_INTERLACEMETHOD_RENDER_WEAVE, "render weave"},
62 {VS_INTERLACEMETHOD_RENDER_BOB, "render bob"},
63 {VS_INTERLACEMETHOD_DEINTERLACE, "deinterlace"},
64 {VS_INTERLACEMETHOD_VDPAU_BOB, "vdpau bob"},
65 {VS_INTERLACEMETHOD_VDPAU_INVERSE_TELECINE, "vdpau inverse telecine"},
66 {VS_INTERLACEMETHOD_VDPAU_TEMPORAL, "vdpau temporal"},
67 {VS_INTERLACEMETHOD_VDPAU_TEMPORAL_HALF, "vdpau temporal half"},
68 {VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL, "vdpau temporal spatial"},
69 {VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL_HALF, "vdpau temporal spatial half"},
70 {VS_INTERLACEMETHOD_DEINTERLACE_HALF, "deinterlace half"},
71 {VS_INTERLACEMETHOD_VAAPI_BOB, "vaapi bob"},
72 {VS_INTERLACEMETHOD_VAAPI_MADI, "vaapi madi"},
73 {VS_INTERLACEMETHOD_VAAPI_MACI, "vaapi maci"},
74 {VS_INTERLACEMETHOD_DXVA_AUTO, "dxva auto"},
75 });
78 enum ESCALINGMETHOD
80 VS_SCALINGMETHOD_NEAREST=0,
81 VS_SCALINGMETHOD_LINEAR,
82 VS_SCALINGMETHOD_CUBIC_B_SPLINE,
83 VS_SCALINGMETHOD_CUBIC_MITCHELL,
84 VS_SCALINGMETHOD_CUBIC_CATMULL,
85 VS_SCALINGMETHOD_CUBIC_0_075,
86 VS_SCALINGMETHOD_CUBIC_0_1,
87 VS_SCALINGMETHOD_LANCZOS2,
88 VS_SCALINGMETHOD_LANCZOS3_FAST,
89 VS_SCALINGMETHOD_LANCZOS3,
90 VS_SCALINGMETHOD_SINC8,
91 VS_SCALINGMETHOD_BICUBIC_SOFTWARE,
92 VS_SCALINGMETHOD_LANCZOS_SOFTWARE,
93 VS_SCALINGMETHOD_SINC_SOFTWARE,
94 VS_SCALINGMETHOD_VDPAU_HARDWARE,
95 VS_SCALINGMETHOD_DXVA_HARDWARE,
96 VS_SCALINGMETHOD_AUTO,
97 VS_SCALINGMETHOD_SPLINE36_FAST,
98 VS_SCALINGMETHOD_SPLINE36,
99 VS_SCALINGMETHOD_MAX // do not use and keep as last enum value.
102 template<>
103 struct fmt::formatter<ESCALINGMETHOD> : fmt::formatter<std::string_view>
105 public:
106 template<typename FormatContext>
107 constexpr auto format(const ESCALINGMETHOD& scalingMethod, FormatContext& ctx)
109 const auto it = scalingMethodMap.find(scalingMethod);
110 if (it == scalingMethodMap.cend())
111 throw std::range_error("no scaling method string found");
113 return fmt::formatter<string_view>::format(it->second, ctx);
116 private:
117 static constexpr auto scalingMethodMap = make_map<ESCALINGMETHOD, std::string_view>({
118 {VS_SCALINGMETHOD_NEAREST, "nearest neighbour"},
119 {VS_SCALINGMETHOD_LINEAR, "linear"},
120 {VS_SCALINGMETHOD_CUBIC_B_SPLINE, "cubic b spline"},
121 {VS_SCALINGMETHOD_CUBIC_MITCHELL, "cubic mitchell"},
122 {VS_SCALINGMETHOD_CUBIC_CATMULL, "cubic catmull"},
123 {VS_SCALINGMETHOD_CUBIC_0_075, "cubic 0/075"},
124 {VS_SCALINGMETHOD_CUBIC_0_1, "cubic 0/1"},
125 {VS_SCALINGMETHOD_LANCZOS2, "lanczos2"},
126 {VS_SCALINGMETHOD_LANCZOS3_FAST, "lanczos3 fast"},
127 {VS_SCALINGMETHOD_LANCZOS3, "lanczos3"},
128 {VS_SCALINGMETHOD_SINC8, "sinc8"},
129 {VS_SCALINGMETHOD_BICUBIC_SOFTWARE, "bicubic software"},
130 {VS_SCALINGMETHOD_LANCZOS_SOFTWARE, "lanczos software"},
131 {VS_SCALINGMETHOD_SINC_SOFTWARE, "sinc software"},
132 {VS_SCALINGMETHOD_VDPAU_HARDWARE, "vdpau"},
133 {VS_SCALINGMETHOD_DXVA_HARDWARE, "dxva"},
134 {VS_SCALINGMETHOD_AUTO, "auto"},
135 {VS_SCALINGMETHOD_SPLINE36_FAST, "spline32 fast"},
136 {VS_SCALINGMETHOD_SPLINE36, "spline32"},
139 static_assert(VS_SCALINGMETHOD_MAX == scalingMethodMap.size(),
140 "scalingMethodMap doesn't match the size of ESCALINGMETHOD, did you forget to "
141 "add/remove a mapping?");
144 enum ETONEMAPMETHOD
146 VS_TONEMAPMETHOD_OFF = 0,
147 VS_TONEMAPMETHOD_REINHARD = 1,
148 VS_TONEMAPMETHOD_ACES = 2,
149 VS_TONEMAPMETHOD_HABLE = 3,
150 VS_TONEMAPMETHOD_MAX
153 template<>
154 struct fmt::formatter<ETONEMAPMETHOD> : fmt::formatter<std::string_view>
156 public:
157 template<typename FormatContext>
158 constexpr auto format(const ETONEMAPMETHOD& tonemapMethod, FormatContext& ctx)
160 const auto it = tonemapMethodMap.find(tonemapMethod);
161 if (it == tonemapMethodMap.cend())
162 throw std::range_error("no tonemap method string found");
164 return fmt::formatter<string_view>::format(it->second, ctx);
167 private:
168 static constexpr auto tonemapMethodMap = make_map<ETONEMAPMETHOD, std::string_view>({
169 {VS_TONEMAPMETHOD_OFF, "off"},
170 {VS_TONEMAPMETHOD_REINHARD, "reinhard"},
171 {VS_TONEMAPMETHOD_ACES, "aces"},
172 {VS_TONEMAPMETHOD_HABLE, "hable"},
175 static_assert(VS_TONEMAPMETHOD_MAX == tonemapMethodMap.size(),
176 "tonemapMethodMap doesn't match the size of ETONEMAPMETHOD, did you forget to "
177 "add/remove a mapping?");
180 enum ViewMode
182 ViewModeNormal = 0,
183 ViewModeZoom,
184 ViewModeStretch4x3,
185 ViewModeWideZoom,
186 ViewModeStretch16x9,
187 ViewModeOriginal,
188 ViewModeCustom,
189 ViewModeStretch16x9Nonlin,
190 ViewModeZoom120Width,
191 ViewModeZoom110Width
194 class CVideoSettings
196 public:
197 CVideoSettings();
198 ~CVideoSettings() = default;
200 bool operator!=(const CVideoSettings &right) const;
202 EINTERLACEMETHOD m_InterlaceMethod;
203 ESCALINGMETHOD m_ScalingMethod;
204 int m_ViewMode; // current view mode
205 float m_CustomZoomAmount; // custom setting zoom amount
206 float m_CustomPixelRatio; // custom setting pixel ratio
207 float m_CustomVerticalShift; // custom setting vertical shift
208 bool m_CustomNonLinStretch;
209 int m_AudioStream;
210 float m_VolumeAmplification;
211 int m_SubtitleStream;
212 float m_SubtitleDelay;
213 int m_subtitleVerticalPosition{0};
214 bool m_subtitleVerticalPositionSave{false};
215 bool m_SubtitleOn;
216 float m_Brightness;
217 float m_Contrast;
218 float m_Gamma;
219 float m_NoiseReduction;
220 bool m_PostProcess;
221 float m_Sharpness;
222 float m_AudioDelay;
223 int m_ResumeTime;
224 int m_StereoMode;
225 bool m_StereoInvert;
226 int m_VideoStream;
227 ETONEMAPMETHOD m_ToneMapMethod;
228 float m_ToneMapParam;
229 int m_Orientation;
230 int m_CenterMixLevel; // relative to metadata or default
233 class CCriticalSection;
234 class CVideoSettingsLocked
236 public:
237 CVideoSettingsLocked(CVideoSettings &vs, CCriticalSection &critSection);
238 virtual ~CVideoSettingsLocked() = default;
240 CVideoSettingsLocked(CVideoSettingsLocked const &) = delete;
241 void operator=(CVideoSettingsLocked const &x) = delete;
243 void SetSubtitleStream(int stream);
244 void SetSubtitleVisible(bool visible);
245 void SetAudioStream(int stream);
246 void SetVideoStream(int stream);
247 void SetAudioDelay(float delay);
248 void SetSubtitleDelay(float delay);
251 * \brief Set the subtitle vertical position,
252 * it depends on current screen resolution
253 * \param value The subtitle position in pixels
254 * \param save If true, the value will be saved to resolution info
256 void SetSubtitleVerticalPosition(int value, bool save);
258 void SetViewMode(int mode, float zoom, float par, float shift, bool stretch);
259 void SetVolumeAmplification(float amp);
261 protected:
262 CVideoSettings &m_videoSettings;
263 CCriticalSection &m_critSection;