aboutsummaryrefslogtreecommitdiff
path: root/baselibs
diff options
context:
space:
mode:
authorPacketVideo CM <engbuild@pv.com>2009-12-04 11:48:28 -0800
committerPacketVideo CM <engbuild@pv.com>2009-12-04 11:48:28 -0800
commit41b5610abe3c96c7f455c8f6d45b10d62cb0101b (patch)
tree737aec4e5253b25e1cbd43a1b4a21e25052e4da7 /baselibs
parent385ecf559487e3f8d0813e7536b95045a816a92c (diff)
downloadopencore-41b5610abe3c96c7f455c8f6d45b10d62cb0101b.tar.gz
RIO-7492: MP4 file parser and parser node modified to support a very large value of timescale
Diffstat (limited to 'baselibs')
-rw-r--r--baselibs/media_data_structures/src/media_clock_converter.cpp86
-rw-r--r--baselibs/media_data_structures/src/media_clock_converter.h29
-rw-r--r--baselibs/media_data_structures/src/pv_gau.h2
3 files changed, 104 insertions, 13 deletions
diff --git a/baselibs/media_data_structures/src/media_clock_converter.cpp b/baselibs/media_data_structures/src/media_clock_converter.cpp
index a3188c537..5f6115e34 100644
--- a/baselibs/media_data_structures/src/media_clock_converter.cpp
+++ b/baselibs/media_data_structures/src/media_clock_converter.cpp
@@ -44,14 +44,25 @@ OSCL_EXPORT_REF void MediaClockConverter::set_value(const MediaClockConverter& s
OSCL_LEAVE(OsclErrCorrupt);
}
- uint64 value = (uint64(src.get_wrap_count())) << 32;
+ uint64 value = 0;
+ if (src.current_ts64_upper32 == 0)
+ {
+ value = (uint64(src.get_wrap_count())) << 32;
+ }
+ else
+ {
+ value = (uint64(src.current_ts64_upper32)) << 32;
+ }
+
value += src.get_current_timestamp();
// rounding up
value = (uint64(value) * timescale + uint64(src.get_timescale() - 1)) / src.get_timescale();
- wrap_count = ((uint32)(value >> 32)) % timescale;
+ current_ts64_upper32 = (uint32)(value >> 32);
+
+ wrap_count = current_ts64_upper32 % timescale;
current_ts = (uint32)(value & 0xFFFFFFFF);
}
@@ -72,7 +83,15 @@ OSCL_EXPORT_REF void MediaClockConverter::set_timescale(uint32 new_timescale)
OSCL_LEAVE(OsclErrCorrupt);
}
- uint64 value = ((uint64)wrap_count) << 32;
+ uint64 value = 0;
+ if (current_ts64_upper32 == 0)
+ {
+ value = ((uint64)wrap_count) << 32;
+ }
+ else
+ {
+ value = ((uint64)current_ts64_upper32) << 32;
+ }
value += current_ts;
// rounding up
@@ -80,7 +99,8 @@ OSCL_EXPORT_REF void MediaClockConverter::set_timescale(uint32 new_timescale)
timescale = new_timescale;
- wrap_count = ((uint32)(value >> 32)) % timescale;
+ current_ts64_upper32 = (uint32)(value >> 32);
+ wrap_count = current_ts64_upper32 % timescale;
current_ts = (uint32)(value & 0xFFFFFFFF);
}
@@ -109,8 +129,8 @@ OSCL_EXPORT_REF void MediaClockConverter::set_clock_other_timescale(uint32 value
new_value = new_value + in_timescale64Comp ;
new_value /= in_timescale;
- wrap_count = ((uint32)(new_value >> 32)) % timescale;
-
+ current_ts64_upper32 = ((uint32)(new_value >> 32));
+ wrap_count = current_ts64_upper32 % timescale;
current_ts = (uint32)(new_value & 0xFFFFFFFF);
}
@@ -165,7 +185,6 @@ OSCL_EXPORT_REF uint32 MediaClockConverter::get_timediff_and_update_clock(uint32
return 0;
}
-
//////////////////////////////////////////////////////////////////////////////////
OSCL_EXPORT_REF bool MediaClockConverter::update_clock(uint32 new_ts)
{
@@ -196,6 +215,23 @@ OSCL_EXPORT_REF bool MediaClockConverter::update_clock(uint32 new_ts)
}
//////////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool MediaClockConverter::update_clock(uint64 new_ts)
+{
+ uint64 current_ts64 = 0;
+ current_ts64 = ((uint64)current_ts64_upper32) << 32;
+ current_ts64 += current_ts;
+ uint64 diff = new_ts - current_ts64;
+ if (diff < MISORDER_THRESHOLD)
+ {
+ current_ts = (uint32)(new_ts & 0xFFFFFFFF);
+ current_ts64_upper32 = ((uint32)(new_ts >> 32));
+ return true;
+ }
+ // otherwise this an earlier value so ignore it.
+ return false;
+}
+
+//////////////////////////////////////////////////////////////////////////////////
OSCL_EXPORT_REF uint32 MediaClockConverter::get_converted_ts(uint32 new_timescale) const
{
// Timescale value cannot be zero
@@ -204,11 +240,41 @@ OSCL_EXPORT_REF uint32 MediaClockConverter::get_converted_ts(uint32 new_timescal
{
OSCL_LEAVE(OsclErrCorrupt);
}
-
- uint64 value = ((uint64)wrap_count) << 32;
+ uint64 value = 0;
+ if (current_ts64_upper32)
+ {
+ value = ((uint64)current_ts64_upper32) << 32;
+ }
+ else
+ {
+ value = ((uint64)wrap_count) << 32;
+ }
// rounding up
value = ((value + uint64(current_ts)) * uint64(new_timescale) + uint64(timescale - 1)) / uint64(timescale);
-
return ((uint32) value);
}
+
+OSCL_EXPORT_REF uint64 MediaClockConverter::get_converted_ts64(uint32 new_timescale) const
+{
+ //This function ignores wrap_count
+ // Timescale value cannot be zero
+ OSCL_ASSERT(timescale != 0);
+ if (0 == timescale)
+ {
+ OSCL_LEAVE(OsclErrCorrupt);
+ }
+
+ uint64 value = ((uint64)current_ts64_upper32) << 32;
+ // rounding up
+ value = ((value + uint64(current_ts)) * uint64(new_timescale) + uint64(timescale - 1)) / uint64(timescale);
+ return value;
+}
+
+OSCL_EXPORT_REF uint64 MediaClockConverter::get_current_timestamp64() const
+{
+ uint64 value = ((uint64)current_ts64_upper32) << 32;
+ value = value + uint64(current_ts);
+ return value;
+}
+
diff --git a/baselibs/media_data_structures/src/media_clock_converter.h b/baselibs/media_data_structures/src/media_clock_converter.h
index 406436f9a..fa7259e15 100644
--- a/baselibs/media_data_structures/src/media_clock_converter.h
+++ b/baselibs/media_data_structures/src/media_clock_converter.h
@@ -31,7 +31,11 @@ class MediaClockConverter
{
public:
- MediaClockConverter(uint32 in_timescale = 1, uint32 init_ts = 0)
+ //As of now we cannot provide 64 bit ts in the arg as overloaded ctor.
+ //Reason: if we do so, then in the existing codebase, that is passing in const number say 1000
+ //as param has to be explicitly typecasted to uint32 in all over the codebase.
+ //So intead we can pass in the upper 32 bits of the uint64 as uint32
+ MediaClockConverter(uint32 in_timescale = 1, uint32 init_ts = 0, uint32 init_ts64_upper32 = 0)
{
// Timescale value cannot be zero
OSCL_ASSERT(in_timescale != 0);
@@ -42,6 +46,7 @@ class MediaClockConverter
timescale = in_timescale;
current_ts = init_ts;
wrap_count = 0;
+ current_ts64_upper32 = init_ts64_upper32;
};
MediaClockConverter(const MediaClockConverter& a)
@@ -55,6 +60,7 @@ class MediaClockConverter
timescale = a.timescale;
current_ts = a.current_ts;
wrap_count = a.wrap_count;
+ current_ts64_upper32 = a.current_ts64_upper32;
};
/**
@@ -73,6 +79,7 @@ class MediaClockConverter
timescale = a.timescale;
current_ts = a.current_ts;
wrap_count = a.wrap_count;
+ current_ts64_upper32 = a.current_ts64_upper32;
}
return *this;
};
@@ -80,6 +87,7 @@ class MediaClockConverter
void set_clock(uint32 init_ts, uint32 in_wrap_count)
{
current_ts = init_ts;
+ current_ts64_upper32 = 0;
// Timescale value cannot be zero
OSCL_ASSERT(timescale != 0);
@@ -90,13 +98,26 @@ class MediaClockConverter
wrap_count = in_wrap_count % timescale;
};
+ void set_clock(uint64 init_ts, uint32 in_wrap_count)
+ {
+ // Timescale value cannot be zero
+ OSCL_ASSERT(timescale != 0);
+ if (0 == timescale)
+ {
+ OSCL_LEAVE(OsclErrCorrupt);
+ }
+ current_ts = (uint32)(init_ts & 0xFFFFFFFF);
+ current_ts64_upper32 = ((uint32)(init_ts >> 32)) % timescale;
+ wrap_count = in_wrap_count % timescale;
+ }
+
// set the clock with value from another timescale
OSCL_IMPORT_REF void set_clock_other_timescale(uint32 value, uint32 timescale);
OSCL_IMPORT_REF void set_timescale(uint32 new_timescale);
OSCL_IMPORT_REF bool update_clock(uint32 new_ts);
-
+ OSCL_IMPORT_REF bool update_clock(uint64 new_ts);
OSCL_IMPORT_REF uint32 get_timediff_and_update_clock(uint32 value, uint32 timescale,
uint32 output_timescale);
@@ -104,6 +125,7 @@ class MediaClockConverter
uint32 output_timescale);
OSCL_IMPORT_REF uint32 get_converted_ts(uint32 new_timscale) const;
+ OSCL_IMPORT_REF uint64 get_converted_ts64(uint32 new_timscale) const;
OSCL_IMPORT_REF uint32 get_wrap_count() const
{
return wrap_count;
@@ -112,6 +134,8 @@ class MediaClockConverter
{
return current_ts;
};
+ OSCL_IMPORT_REF uint64 get_current_timestamp64() const;
+
OSCL_IMPORT_REF uint32 get_timescale() const
{
return timescale;
@@ -123,6 +147,7 @@ class MediaClockConverter
uint32 timescale;
uint32 current_ts;
uint32 wrap_count;
+ uint32 current_ts64_upper32;
};
diff --git a/baselibs/media_data_structures/src/pv_gau.h b/baselibs/media_data_structures/src/pv_gau.h
index ef7fa4b16..c9a2f3e7f 100644
--- a/baselibs/media_data_structures/src/pv_gau.h
+++ b/baselibs/media_data_structures/src/pv_gau.h
@@ -39,7 +39,7 @@ struct SimpleBufferFragGroup
struct MediaMetaInfo
{
uint32 len; //size of the frame
- uint32 ts; //time stamp
+ uint64 ts; //time stamp
uint32 ts_delta; // timestamp delta from the previous timestamp
uint32 sample_info; //4 uint8 information together
bool dropFlag;