VLC  4.0.0-dev
clock_internal.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * clock_internal.h: Clock internal functions
3  *****************************************************************************
4  * Copyright (C) 2018 VLC authors and VideoLAN
5  *
6  * Authors: Christophe Massiot <massiot@via.ecp.fr>
7  * Laurent Aimar < fenrir _AT_ videolan _DOT_ org >
8  *
9  * This program is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23 
24 #ifndef CLOCK_INTERNAL_H
25 # define CLOCK_INTERNAL_H
26 
27 #include <vlc_common.h>
28 
29 /*****************************************************************************
30  * Structures
31  *****************************************************************************/
32 
33 /**
34  * This structure holds long term moving average
35  */
36 typedef struct
37 {
38  double value; /* The average value */
39  int count; /* The number of sample evaluated */
40  int range; /* The maximum range of sample on which we calculate the average*/
41 } average_t;
42 
43 void AvgInit(average_t *, int range);
44 void AvgClean(average_t *);
45 
46 void AvgReset(average_t *);
47 
48 /* calculates (previous_average * (range - 1) + new_value)/range */
49 void AvgUpdate(average_t *, double value);
50 
51 double AvgGet(average_t *);
52 void AvgRescale(average_t *, int range);
53 
54 /* */
55 typedef struct
56 {
60 
62 {
63  return (clock_point_t) { .system = system, .stream = stream };
64 }
65 
66 #endif
count
size_t count
Definition: core.c:401
clock_point_t::stream
vlc_tick_t stream
Definition: clock_internal.h:58
average_t
This structure holds long term moving average.
Definition: clock_internal.h:36
clock_internal.h
average_t::count
int count
Definition: clock_internal.h:62
vlc_common.h
clock_point_Create
static clock_point_t clock_point_Create(vlc_tick_t system, vlc_tick_t stream)
Definition: clock_internal.h:61
AvgInit
void AvgInit(average_t *, int range)
Definition: clock_internal.c:33
AvgUpdate
void AvgUpdate(average_t *avg, double value)
Definition: clock_internal.c:50
AvgReset
void AvgReset(average_t *avg)
Definition: clock_internal.c:44
clock_point_t
Definition: clock_internal.h:55
average_t::value
double value
Definition: clock_internal.h:61
AvgClean
void AvgClean(average_t *)
Definition: clock_internal.c:39
clock_point_t::system
vlc_tick_t system
Definition: clock_internal.h:57
AvgClean
void AvgClean(average_t *avg)
Definition: clock_internal.c:39
AvgReset
void AvgReset(average_t *)
Definition: clock_internal.c:44
vlc_tick_t
int64_t vlc_tick_t
High precision date or time interval.
Definition: vlc_tick.h:45
AvgInit
void AvgInit(average_t *avg, int range)
Definition: clock_internal.c:33
AvgGet
double AvgGet(average_t *avg)
Definition: clock_internal.c:70
AvgRescale
void AvgRescale(average_t *avg, int range)
Definition: clock_internal.c:75
VLC_UNUSED
#define VLC_UNUSED(x)
Definition: vlc_common.h:1105
AvgUpdate
void AvgUpdate(average_t *, double value)
Definition: clock_internal.c:50
average_t::range
int range
Definition: clock_internal.h:63
AvgGet
double AvgGet(average_t *)
Definition: clock_internal.c:70
AvgRescale
void AvgRescale(average_t *, int range)
Definition: clock_internal.c:75