[vlc-devel] commit: Moved date_Decrement to libvlc core from dirac. (Laurent Aimar )
git version control
git at videolan.org
Fri May 8 00:28:26 CEST 2009
vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Thu May 7 23:28:57 2009 +0200| [331625d9dcae5c28c02a8f78a9bf0598784a61f2] | committer: Laurent Aimar
Moved date_Decrement to libvlc core from dirac.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=331625d9dcae5c28c02a8f78a9bf0598784a61f2
---
include/vlc_mtime.h | 1 +
modules/packetizer/dirac.c | 20 --------------------
src/libvlccore.sym | 1 +
src/misc/mtime.c | 27 +++++++++++++++++++++++++++
4 files changed, 29 insertions(+), 20 deletions(-)
diff --git a/include/vlc_mtime.h b/include/vlc_mtime.h
index f3bb895..0a75dac 100644
--- a/include/vlc_mtime.h
+++ b/include/vlc_mtime.h
@@ -136,5 +136,6 @@ VLC_EXPORT( void, date_Set, ( date_t *, mtime_t ) );
VLC_EXPORT( mtime_t, date_Get, ( const date_t * ) );
VLC_EXPORT( void, date_Move, ( date_t *, mtime_t ) );
VLC_EXPORT( mtime_t, date_Increment, ( date_t *, uint32_t ) );
+VLC_EXPORT( mtime_t, date_Decrement, ( date_t *, uint32_t ) );
VLC_EXPORT( uint64_t, NTPtime64, ( void ) );
#endif /* !__VLC_MTIME_ */
diff --git a/modules/packetizer/dirac.c b/modules/packetizer/dirac.c
index b666591..af3f50f 100644
--- a/modules/packetizer/dirac.c
+++ b/modules/packetizer/dirac.c
@@ -266,26 +266,6 @@ static dirac_block_encap_t *dirac_GetBlockEncap( block_t *p_block )
* General utility funcions
*/
-/* decrement a date. opposite to date_Increment */
-static mtime_t date_Decrement( date_t *p_date, uint32_t i_nb_samples )
-{
- mtime_t i_dividend = (mtime_t)i_nb_samples * 1000000 * p_date->i_divider_den;
- p_date->date -= i_dividend / p_date->i_divider_num;
- unsigned u_rem_adjust = i_dividend % p_date->i_divider_num;
-
- if( p_date->i_remainder < u_rem_adjust )
- {
- /* This is Bresenham algorithm. */
- assert( p_date->i_remainder > -p_date->i_divider_num);
- p_date->date -= 1;
- p_date->i_remainder += p_date->i_divider_num;
- }
-
- p_date->i_remainder -= u_rem_adjust;
-
- return p_date->date;
-}
-
/**
* given a chain of block_t, allocate and return an array containing
* pointers to all the blocks. (Acts as a replacement for the old p_prev
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 91f2d79..9f7c950 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -74,6 +74,7 @@ config_StringEscape
config_StringUnescape
convert_xml_special_chars
date_Change
+date_Decrement
date_Get
date_Increment
date_Init
diff --git a/src/misc/mtime.c b/src/misc/mtime.c
index 0dbb4df..c735bdf 100644
--- a/src/misc/mtime.c
+++ b/src/misc/mtime.c
@@ -536,6 +536,33 @@ mtime_t date_Increment( date_t *p_date, uint32_t i_nb_samples )
return p_date->date;
}
+/**
+ * Decrement the date and return the result, taking into account
+ * rounding errors.
+ *
+ * \param date to decrement
+ * \param decrementation in number of samples
+ * \return date value
+ */
+mtime_t date_Decrement( date_t *p_date, uint32_t i_nb_samples )
+{
+ mtime_t i_dividend = (mtime_t)i_nb_samples * 1000000 * p_date->i_divider_den;
+ p_date->date -= i_dividend / p_date->i_divider_num;
+ unsigned i_rem_adjust = i_dividend % p_date->i_divider_num;
+
+ if( p_date->i_remainder < i_rem_adjust )
+ {
+ /* This is Bresenham algorithm. */
+ assert( p_date->i_remainder > -p_date->i_divider_num);
+ p_date->date -= 1;
+ p_date->i_remainder += p_date->i_divider_num;
+ }
+
+ p_date->i_remainder -= i_rem_adjust;
+
+ return p_date->date;
+}
+
#ifndef HAVE_GETTIMEOFDAY
#ifdef WIN32
More information about the vlc-devel
mailing list