While other OMX nodes appear to now have switched to using microseconds to timestamp buffers, at least the TI AAC and MP3 decoders still use milliseconds.
diff --git a/include/media/stagefright/OMXDecoder.h b/include/media/stagefright/OMXDecoder.h
index 54a8047..e76fd4c 100644
--- a/include/media/stagefright/OMXDecoder.h
+++ b/include/media/stagefright/OMXDecoder.h
@@ -83,7 +83,8 @@
kDoesntProperlyFlushAllPortsAtOnce = 8,
kRequiresAllocateBufferOnInputPorts = 16,
kRequiresAllocateBufferOnOutputPorts = 32,
- kRequiresLoadedToIdleAfterAllocation = 64
+ kRequiresLoadedToIdleAfterAllocation = 64,
+ kMeasuresTimeInMilliseconds = 128,
};
OMXClient *mClient;
diff --git a/media/libstagefright/OMXDecoder.cpp b/media/libstagefright/OMXDecoder.cpp
index 1fc2ba0..5e44999 100644
--- a/media/libstagefright/OMXDecoder.cpp
+++ b/media/libstagefright/OMXDecoder.cpp
@@ -154,6 +154,10 @@
if (!strncmp(codec, "OMX.qcom.video.", 15)) {
quirks |= kRequiresLoadedToIdleAfterAllocation;
}
+ if (!strcmp(codec, "OMX.TI.AAC.decode")
+ || !strcmp(codec, "OMX.TI.MP3.decode")) {
+ quirks |= kMeasuresTimeInMilliseconds;
+ }
OMXDecoder *decoder = new OMXDecoder(client, node, mime, codec, quirks);
@@ -1497,7 +1501,11 @@
OMX_TICKS timestamp = 0;
if (success) {
- timestamp = ((OMX_S64)units * 1000000) / scale;
+ if (mQuirks & kMeasuresTimeInMilliseconds) {
+ timestamp = ((OMX_S64)units * 1000) / scale;
+ } else {
+ timestamp = ((OMX_S64)units * 1000000) / scale;
+ }
}
input_buffer->release();
@@ -1523,9 +1531,16 @@
media_buffer->meta_data()->clear();
- media_buffer->meta_data()->setInt32(
- kKeyTimeUnits,
- (msg.u.extended_buffer_data.timestamp + 500) / 1000);
+ if (mQuirks & kMeasuresTimeInMilliseconds) {
+ media_buffer->meta_data()->setInt32(
+ kKeyTimeUnits,
+ msg.u.extended_buffer_data.timestamp);
+ } else {
+ media_buffer->meta_data()->setInt32(
+ kKeyTimeUnits,
+ (msg.u.extended_buffer_data.timestamp + 500) / 1000);
+ }
+
media_buffer->meta_data()->setInt32(kKeyTimeScale, 1000);
if (msg.u.extended_buffer_data.flags & OMX_BUFFERFLAG_SYNCFRAME) {