UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
get_framerate_test.cpp File Reference
#include <cmath>
#include <iostream>
#include <string>
#include "unit_common.h"
#include "utils/misc.h"
Include dependency graph for get_framerate_test.cpp:

Go to the source code of this file.

Macros

#define EPS   0.0049
 

Functions

int get_framerate_test_2997 ()
 
int get_framerate_test_3000 ()
 
int get_framerate_test_free ()
 

Macro Definition Documentation

◆ EPS

#define EPS   0.0049

for 10 FPS the difference between 10000/1000 and 10000/1001 is ~0.001 and this needs to be less than a half of that

Definition at line 15 of file get_framerate_test.cpp.

Referenced by get_framerate_test_2997(), get_framerate_test_3000(), and get_framerate_test_free().

Function Documentation

◆ get_framerate_test_2997()

int get_framerate_test_2997 ( )

Definition at line 27 of file get_framerate_test.cpp.

28{
29 // approx
30 ASSERT_EQUAL(30000, get_framerate_n(29.97));
31 ASSERT_EQUAL(1001, get_framerate_d(29.97));
32
33 // "exactly" 30000/1001
34 ASSERT_EQUAL(30000, get_framerate_n(30000.0/1001));
35 ASSERT_EQUAL(1001, get_framerate_d(30000.0/1001));
36
37 // with epsilon
38 ASSERT_EQUAL(30000, get_framerate_n(30000.0/1001 + EPS));
39 ASSERT_EQUAL(30000, get_framerate_n(30000.0/1001 + EPS));
40 ASSERT_EQUAL(1001, get_framerate_d(30000.0/1001 - EPS));
41 ASSERT_EQUAL(1001, get_framerate_d(30000.0/1001 - EPS));
42 return 0;
43}
#define EPS
int get_framerate_d(double fps)
Definition misc.cpp:190
int get_framerate_n(double fps)
Definition misc.cpp:184
#define ASSERT_EQUAL(expected, actual)
Definition unit_common.h:35

References ASSERT_EQUAL, EPS, get_framerate_d(), and get_framerate_n().

Here is the call graph for this function:

◆ get_framerate_test_3000()

int get_framerate_test_3000 ( )

Definition at line 45 of file get_framerate_test.cpp.

46{
47 ASSERT_EQUAL(30000, get_framerate_n(30));
49
50 ASSERT_EQUAL(30000, get_framerate_n(30 + EPS));
51 ASSERT_EQUAL(1000, get_framerate_d(30 + EPS));
52 ASSERT_EQUAL(30000, get_framerate_n(30 - EPS));
53 ASSERT_EQUAL(1000, get_framerate_d(30 - EPS));
54 return 0;
55}

References ASSERT_EQUAL, EPS, get_framerate_d(), and get_framerate_n().

Here is the call graph for this function:

◆ get_framerate_test_free()

int get_framerate_test_free ( )

Definition at line 57 of file get_framerate_test.cpp.

58{
59 for (int i = 10; i < 480; ++i) {
60 // base 1000
61 string num_str = to_string(i);
62 ASSERT_EQUAL_MESSAGE(num_str, i * 1000, get_framerate_n(i));
63 ASSERT_EQUAL_MESSAGE(num_str, 1000, get_framerate_d(i));
64 ASSERT_EQUAL_MESSAGE(num_str, i * 1000, get_framerate_n(i + EPS));
65 ASSERT_EQUAL_MESSAGE(num_str, 1000, get_framerate_d(i + EPS));
66 ASSERT_EQUAL_MESSAGE(num_str, i * 1000, get_framerate_n(i - EPS));
67 ASSERT_EQUAL_MESSAGE(num_str, 1000, get_framerate_d(i - EPS));
68
69 // base 1001
70 double num = i * 1000.0 / 1001.0;
71 num_str = to_string(num);
72 ASSERT_EQUAL_MESSAGE(num_str, i * 1000, get_framerate_n(num));
73 ASSERT_EQUAL_MESSAGE(num_str, 1001, get_framerate_d(num));
74 ASSERT_EQUAL_MESSAGE(num_str, i * 1000, get_framerate_n(num + EPS));
75 ASSERT_EQUAL_MESSAGE(num_str, 1001, get_framerate_d(num + EPS));
76 ASSERT_EQUAL_MESSAGE(num_str, i * 1000, get_framerate_n(num - EPS));
77 ASSERT_EQUAL_MESSAGE(num_str, 1001, get_framerate_d(num - EPS));
78
79 // halves
80 num = i + 0.5;
81 num_str = to_string(num);
82 ASSERT_EQUAL_MESSAGE(num_str, (int) round(num * 1000), get_framerate_n(num));
83 ASSERT_EQUAL_MESSAGE(num_str, 1000, get_framerate_d(num));
84 }
85 return 0;
86}
static __device__ vec3 round(const vec3 &v)
Definition cuda_dxt.cu:122
#define ASSERT_EQUAL_MESSAGE(msg, expected, actual)
Definition unit_common.h:53

References ASSERT_EQUAL_MESSAGE, EPS, get_framerate_d(), get_framerate_n(), and round().

Here is the call graph for this function: