MCPcopy Create free account
hub / github.com/OpenShot/libopenshot / formattedFPS

Method formattedFPS

src/Profiles.cpp:142–170  ·  view source on GitHub ↗

Return a formatted FPS

Source from the content-addressed store, hash-verified

140
141// Return a formatted FPS
142std::string Profile::formattedFPS(bool include_decimal) {
143 // Format FPS to use 2 decimals (if needed)
144 if (!include_decimal) {
145 int fps_code = 0;
146
147 if (info.fps.den == 1) {
148 // Exact integer FPS (e.g. 24 → 0024)
149 fps_code = info.fps.num;
150 } else {
151 // Fractional FPS, scale by 100 (e.g. 29.97 → 2997)
152 fps_code = static_cast<int>((info.fps.num * 100.0) / info.fps.den + 0.5);
153 }
154
155 char buffer[5];
156 std::snprintf(buffer, sizeof(buffer), "%04d", fps_code);
157 return std::string(buffer);
158 }
159
160 // Human-readable version for display
161 float fps = info.fps.ToFloat();
162
163 if (std::fabs(fps - std::round(fps)) < 0.01) {
164 return std::to_string(static_cast<int>(std::round(fps)));
165 }
166
167 char buffer[16];
168 std::snprintf(buffer, sizeof(buffer), "%.2f", fps);
169 return std::string(buffer);
170}
171
172// Return a unique key of this profile (01920x1080i2997_16-09)
173std::string Profile::Key() {

Callers

nothing calls this directly

Calls 1

ToFloatMethod · 0.80

Tested by

no test coverage detected