diff options
author | v0lt <v0lt@users.sourceforge.net> | 2012-02-27 20:24:53 +0400 |
---|---|---|
committer | v0lt <v0lt@users.sourceforge.net> | 2012-02-27 20:24:53 +0400 |
commit | 9713530199112f565b01cc205d7ffb1da29198a5 (patch) | |
tree | 97c5ea987e2e6f9aa90ffa585c7cc9d1814d2dbe /src/filters/parser/MP4Splitter/AP4 | |
parent | 7965643b3098783e429e64f11648ba8678aea3e8 (diff) |
MP4Splitter: a more accurate calculation (micro update for Bento4)
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@4104 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/parser/MP4Splitter/AP4')
-rw-r--r-- | src/filters/parser/MP4Splitter/AP4/Core/Ap4Utils.cpp | 30 | ||||
-rw-r--r-- | src/filters/parser/MP4Splitter/AP4/Core/Ap4Utils.h | 10 |
2 files changed, 20 insertions, 20 deletions
diff --git a/src/filters/parser/MP4Splitter/AP4/Core/Ap4Utils.cpp b/src/filters/parser/MP4Splitter/AP4/Core/Ap4Utils.cpp index 43bb44e14..5af188e9a 100644 --- a/src/filters/parser/MP4Splitter/AP4/Core/Ap4Utils.cpp +++ b/src/filters/parser/MP4Splitter/AP4/Core/Ap4Utils.cpp @@ -162,26 +162,26 @@ AP4_MakePrefixString(AP4_Offset indent, char* prefix, AP4_Size size) }
/*----------------------------------------------------------------------
-| AP4_DurationMsFromUnits
+| AP4_DurationMsFromUnits
+---------------------------------------------------------------------*/
-unsigned long
-AP4_DurationMsFromUnits(AP4_UI64 units, unsigned long units_per_second)
+AP4_UI32
+AP4_DurationMsFromUnits(AP4_UI64 units, AP4_UI32 units_per_second)
{
if (units_per_second == 0) return 0;
- return (unsigned long)(((float)units*1000.0f)/(float)units_per_second);
+ return (AP4_UI32)(((double)units*1000.0)/(double)units_per_second);
}
-/*----------------------------------------------------------------------
-| AP4_ConvertTime
-+---------------------------------------------------------------------*/
-AP4_UI64
-AP4_ConvertTime(AP4_UI64 time_value,
- unsigned long from_time_scale,
- unsigned long to_time_scale)
-{
- if (from_time_scale == 0) return 0;
- float ratio = (float)to_time_scale/(float)from_time_scale;
- return ((AP4_UI64)((float)time_value*ratio));
+/*---------------------------------------------------------------------- +| AP4_ConvertTime ++---------------------------------------------------------------------*/ +AP4_UI64 +AP4_ConvertTime(AP4_UI64 time_value, + AP4_UI32 from_time_scale, + AP4_UI32 to_time_scale) +{ + if (from_time_scale == 0) return 0; + double ratio = (double)to_time_scale/(double)from_time_scale; + return ((AP4_UI64)((double)time_value*ratio)); }
/*----------------------------------------------------------------------
diff --git a/src/filters/parser/MP4Splitter/AP4/Core/Ap4Utils.h b/src/filters/parser/MP4Splitter/AP4/Core/Ap4Utils.h index 885d37a86..cf45b1506 100644 --- a/src/filters/parser/MP4Splitter/AP4/Core/Ap4Utils.h +++ b/src/filters/parser/MP4Splitter/AP4/Core/Ap4Utils.h @@ -54,11 +54,11 @@ void AP4_BytesFromUInt64BE(unsigned char* bytes, unsigned long long value); void AP4_BytesFromUInt32BE(unsigned char* bytes, unsigned long value);
void AP4_BytesFromUInt24BE(unsigned char* bytes, unsigned long value);
void AP4_BytesFromUInt16BE(unsigned char* bytes, unsigned short value);
-unsigned long AP4_DurationMsFromUnits(AP4_UI64 units,
- unsigned long units_per_second);
-AP4_UI64 AP4_ConvertTime(AP4_UI64 time_value,
- unsigned long from_time_scale,
- unsigned long to_time_scale);
+AP4_UI32 AP4_DurationMsFromUnits(AP4_UI64 units,
+ AP4_UI32 units_per_second);
+AP4_UI64 AP4_ConvertTime(AP4_UI64 time_value, + AP4_UI32 from_time_scale, + AP4_UI32 to_time_scale);
/*----------------------------------------------------------------------
| string utils
|