[vlc-commits] clock: split files to reuse average functions
Denis Charmet
git at videolan.org
Fri May 4 09:39:08 CEST 2018
vlc | branch: master | Denis Charmet <typx at videolan.org> | Wed May 2 15:47:55 2018 +0200| [675151bfc142941911b43c2f9c31d45d92b9633d] | committer: RĂ©mi Denis-Courmont
clock: split files to reuse average functions
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=675151bfc142941911b43c2f9c31d45d92b9633d
---
src/Makefile.am | 2 ++
src/clock/clock.c | 79 +---------------------------------------------
src/clock/clock_internal.c | 76 ++++++++++++++++++++++++++++++++++++++++++++
src/clock/clock_internal.h | 62 ++++++++++++++++++++++++++++++++++++
4 files changed, 141 insertions(+), 78 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index b82bef0898..b80ed96417 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -230,6 +230,7 @@ libvlccore_la_SOURCES = \
playlist/renderer.c \
input/item.c \
input/access.c \
+ clock/clock_internal.c \
clock/clock.c \
input/control.c \
input/decoder.c \
@@ -242,6 +243,7 @@ libvlccore_la_SOURCES = \
input/info.h \
input/meta.c \
clock/clock.h \
+ clock/clock_internal.h \
input/decoder.h \
input/demux.h \
input/es_out.h \
diff --git a/src/clock/clock.c b/src/clock/clock.c
index 8ccbd92f1b..f56c9db842 100644
--- a/src/clock/clock.c
+++ b/src/clock/clock.c
@@ -32,6 +32,7 @@
#include <vlc_common.h>
#include <vlc_input.h>
#include "clock.h"
+#include "clock_internal.h"
#include <assert.h>
/* TODO:
@@ -98,42 +99,6 @@
/* Due to some problems in es_out, we cannot use a large value yet */
#define CR_BUFFERING_TARGET (100000)
-/*****************************************************************************
- * Structures
- *****************************************************************************/
-
-/**
- * This structure holds long term average
- */
-typedef struct
-{
- mtime_t i_value;
- int i_residue;
-
- int i_count;
- int i_divider;
-} average_t;
-static void AvgInit( average_t *, int i_divider );
-static void AvgClean( average_t * );
-
-static void AvgReset( average_t * );
-static void AvgUpdate( average_t *, mtime_t i_value );
-static mtime_t AvgGet( average_t * );
-static void AvgRescale( average_t *, int i_divider );
-
-/* */
-typedef struct
-{
- mtime_t i_stream;
- mtime_t i_system;
-} clock_point_t;
-
-static inline clock_point_t clock_point_Create( mtime_t i_stream, mtime_t i_system )
-{
- clock_point_t p = { .i_stream = i_stream, .i_system = i_system };
- return p;
-}
-
/* */
#define INPUT_CLOCK_LATE_COUNT (3)
@@ -630,45 +595,3 @@ static mtime_t ClockGetTsOffset( input_clock_t *cl )
return cl->i_pts_delay * ( cl->i_rate - INPUT_RATE_DEFAULT ) / INPUT_RATE_DEFAULT;
}
-/*****************************************************************************
- * Long term average helpers
- *****************************************************************************/
-static void AvgInit( average_t *p_avg, int i_divider )
-{
- p_avg->i_divider = i_divider;
- AvgReset( p_avg );
-}
-static void AvgClean( average_t *p_avg )
-{
- VLC_UNUSED(p_avg);
-}
-static void AvgReset( average_t *p_avg )
-{
- p_avg->i_value = 0;
- p_avg->i_residue = 0;
- p_avg->i_count = 0;
-}
-static void AvgUpdate( average_t *p_avg, mtime_t i_value )
-{
- const int i_f0 = __MIN( p_avg->i_divider - 1, p_avg->i_count );
- const int i_f1 = p_avg->i_divider - i_f0;
-
- const mtime_t i_tmp = i_f0 * p_avg->i_value + i_f1 * i_value + p_avg->i_residue;
-
- p_avg->i_value = i_tmp / p_avg->i_divider;
- p_avg->i_residue = i_tmp % p_avg->i_divider;
-
- p_avg->i_count++;
-}
-static mtime_t AvgGet( average_t *p_avg )
-{
- return p_avg->i_value;
-}
-static void AvgRescale( average_t *p_avg, int i_divider )
-{
- const mtime_t i_tmp = p_avg->i_value * p_avg->i_divider + p_avg->i_residue;
-
- p_avg->i_divider = i_divider;
- p_avg->i_value = i_tmp / p_avg->i_divider;
- p_avg->i_residue = i_tmp % p_avg->i_divider;
-}
diff --git a/src/clock/clock_internal.c b/src/clock/clock_internal.c
new file mode 100644
index 0000000000..77f9758aaa
--- /dev/null
+++ b/src/clock/clock_internal.c
@@ -0,0 +1,76 @@
+/*****************************************************************************
+ * clock_internal.c: Clock internal functions
+ *****************************************************************************
+ * Copyright (C) 2018 VLC authors and VideoLAN
+ *
+ * Authors: Christophe Massiot <massiot at via.ecp.fr>
+ * Laurent Aimar < fenrir _AT_ videolan _DOT_ org >
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "clock_internal.h"
+
+/*****************************************************************************
+ * Long term average helpers
+ *****************************************************************************/
+void AvgInit( average_t *p_avg, int i_divider )
+{
+ p_avg->i_divider = i_divider;
+ AvgReset( p_avg );
+}
+
+void AvgClean( average_t *p_avg )
+{
+ VLC_UNUSED(p_avg);
+}
+
+void AvgReset( average_t *p_avg )
+{
+ p_avg->i_value = 0;
+ p_avg->i_residue = 0;
+ p_avg->i_count = 0;
+}
+
+void AvgUpdate( average_t *p_avg, mtime_t i_value )
+{
+ const int i_f0 = __MIN( p_avg->i_divider - 1, p_avg->i_count );
+ const int i_f1 = p_avg->i_divider - i_f0;
+
+ const mtime_t i_tmp = i_f0 * p_avg->i_value + i_f1 * i_value + p_avg->i_residue;
+
+ p_avg->i_value = i_tmp / p_avg->i_divider;
+ p_avg->i_residue = i_tmp % p_avg->i_divider;
+
+ p_avg->i_count++;
+}
+
+mtime_t AvgGet( average_t *p_avg )
+{
+ return p_avg->i_value;
+}
+
+void AvgRescale( average_t *p_avg, int i_divider )
+{
+ const mtime_t i_tmp = p_avg->i_value * p_avg->i_divider + p_avg->i_residue;
+
+ p_avg->i_divider = i_divider;
+ p_avg->i_value = i_tmp / p_avg->i_divider;
+ p_avg->i_residue = i_tmp % p_avg->i_divider;
+}
diff --git a/src/clock/clock_internal.h b/src/clock/clock_internal.h
new file mode 100644
index 0000000000..d974901cff
--- /dev/null
+++ b/src/clock/clock_internal.h
@@ -0,0 +1,62 @@
+/*****************************************************************************
+ * clock_internal.h: Clock internal functions
+ *****************************************************************************
+ * Copyright (C) 2018 VLC authors and VideoLAN
+ *
+ * Authors: Christophe Massiot <massiot at via.ecp.fr>
+ * Laurent Aimar < fenrir _AT_ videolan _DOT_ org >
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#include <vlc_common.h>
+
+/*****************************************************************************
+ * Structures
+ *****************************************************************************/
+
+ /**
+ * This structure holds long term average
+ */
+typedef struct
+{
+ mtime_t i_value;
+ int i_residue;
+
+ int i_count;
+ int i_divider;
+} average_t;
+
+void AvgInit( average_t *, int i_divider );
+void AvgClean( average_t * );
+
+void AvgReset( average_t * );
+void AvgUpdate( average_t *, mtime_t i_value );
+mtime_t AvgGet( average_t * );
+void AvgRescale( average_t *, int i_divider );
+
+/* */
+typedef struct
+{
+ mtime_t i_stream;
+ mtime_t i_system;
+} clock_point_t;
+
+static inline clock_point_t clock_point_Create( mtime_t i_stream, mtime_t i_system )
+{
+ clock_point_t p = { .i_stream = i_stream, .i_system = i_system };
+ return p;
+}
+
More information about the vlc-commits
mailing list