• Home
  • Raw
  • Download

Lines Matching refs:re

35 void rate_estimator_destroy(struct rate_estimator *re)  in rate_estimator_destroy()  argument
37 if (re) in rate_estimator_destroy()
38 free(re); in rate_estimator_destroy()
45 struct rate_estimator *re; in rate_estimator_create() local
47 re = (struct rate_estimator *)calloc(1, sizeof(*re)); in rate_estimator_create()
48 if (re == NULL) in rate_estimator_create()
51 re->window_size = *window_size; in rate_estimator_create()
52 re->estimated_rate = rate; in rate_estimator_create()
53 re->smooth_factor = smooth_factor; in rate_estimator_create()
55 return re; in rate_estimator_create()
58 void rate_estimator_add_frames(struct rate_estimator *re, int fr) in rate_estimator_add_frames() argument
60 re->level_diff += fr; in rate_estimator_add_frames()
63 double rate_estimator_get_rate(struct rate_estimator *re) in rate_estimator_get_rate() argument
65 return re->estimated_rate; in rate_estimator_get_rate()
68 void rate_estimator_reset_rate(struct rate_estimator *re, unsigned int rate) in rate_estimator_reset_rate() argument
70 re->estimated_rate = rate; in rate_estimator_reset_rate()
71 least_square_reset(&re->lsq); in rate_estimator_reset_rate()
72 re->window_start_ts.tv_sec = 0; in rate_estimator_reset_rate()
73 re->window_start_ts.tv_nsec = 0; in rate_estimator_reset_rate()
74 re->window_frames = 0; in rate_estimator_reset_rate()
75 re->level_diff = 0; in rate_estimator_reset_rate()
76 re->last_level = 0; in rate_estimator_reset_rate()
79 int rate_estimator_check(struct rate_estimator *re, int level, in rate_estimator_check() argument
84 if (re->window_start_ts.tv_sec == 0) { in rate_estimator_check()
85 re->window_start_ts = *now; in rate_estimator_check()
89 subtract_timespecs(now, &re->window_start_ts, &td); in rate_estimator_check()
90 re->window_frames += abs(re->last_level - level + re->level_diff); in rate_estimator_check()
91 re->level_diff = 0; in rate_estimator_check()
92 re->last_level = level; in rate_estimator_check()
94 least_square_add_sample(&re->lsq, in rate_estimator_check()
96 re->window_frames); in rate_estimator_check()
97 if (timespec_after(&td, &re->window_size) && in rate_estimator_check()
98 re->lsq.num_samples > 1) { in rate_estimator_check()
99 double rate = least_square_best_fit_slope(&re->lsq); in rate_estimator_check()
100 if (fabs(re->estimated_rate - rate) < MAX_RATE_SKEW) in rate_estimator_check()
101 re->estimated_rate = rate * (1 - re->smooth_factor) + in rate_estimator_check()
102 re->smooth_factor * re->estimated_rate; in rate_estimator_check()
103 least_square_reset(&re->lsq); in rate_estimator_check()
104 re->window_start_ts = *now; in rate_estimator_check()
105 re->window_frames = 0; in rate_estimator_check()