diff options
author | Steve Kondik <steve@cyngn.com> | 2015-12-28 13:08:26 -0800 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-12-28 13:13:07 -0800 |
commit | b19f3604b0abc7d3b835acb11c8dbc37fee8fe3d (patch) | |
tree | f2bd8d9e7f554c59f5da5ae6f08232e701a45478 | |
parent | 020adf202a6a485808a686566cb10e7549ac4cf1 (diff) | |
download | frameworks_av-b19f3604b0abc7d3b835acb11c8dbc37fee8fe3d.zip frameworks_av-b19f3604b0abc7d3b835acb11c8dbc37fee8fe3d.tar.gz frameworks_av-b19f3604b0abc7d3b835acb11c8dbc37fee8fe3d.tar.bz2 |
stagefright: Those who cannot remember history are doomed to repeat it
* A new sniffer might want to defer it's work based on the
knowledge already gained by those who have already sniffed.
* This is the case for our FFMPEG sniffer, which is pretty awesome
in that it is able to fill in all the gaps and detect almost
anything, however the cost is additional latency during scanning
and startup.
* As we cycle thru each sniffer, feed the current score to the next.
It is up to the extractor to use this knowledge wisely.
* Additionally, print some metrics on how long the sniff took.
Change-Id: I5dc8de11ed4939a01eabb0cae0b4e1e71d991eea
-rw-r--r-- | media/libstagefright/DataSource.cpp | 17 | ||||
-rw-r--r-- | media/libstagefright/MediaExtractor.cpp | 6 |
2 files changed, 18 insertions, 5 deletions
diff --git a/media/libstagefright/DataSource.cpp b/media/libstagefright/DataSource.cpp index 3d8688f..b833f9e 100644 --- a/media/libstagefright/DataSource.cpp +++ b/media/libstagefright/DataSource.cpp @@ -136,6 +136,7 @@ bool DataSource::gSniffersRegistered = false; bool DataSource::sniff( String8 *mimeType, float *confidence, sp<AMessage> *meta) { + *mimeType = ""; *confidence = 0.0f; meta->clear(); @@ -147,11 +148,18 @@ bool DataSource::sniff( } } + String8 newMimeType; + if (mimeType != NULL) { + newMimeType.setTo(*mimeType); + } + float newConfidence = *confidence; + for (List<SnifferFunc>::iterator it = gSniffers.begin(); it != gSniffers.end(); ++it) { - String8 newMimeType; - float newConfidence; - sp<AMessage> newMeta; + int64_t sniffStart = ALooper::GetNowUs(); + String8 newMimeType = *mimeType; + float newConfidence = *confidence; + sp<AMessage> newMeta = *meta; if ((*it)(this, &newMimeType, &newConfidence, &newMeta)) { if (newConfidence > *confidence) { *mimeType = newMimeType; @@ -159,6 +167,9 @@ bool DataSource::sniff( *meta = newMeta; } } + ALOGV("Sniffer (%p) completed in %.2f ms (mime=%s confidence=%.2f", + this, ((float)(ALooper::GetNowUs() - sniffStart) / 1000.0f), + mimeType == NULL ? NULL : (*mimeType).string(), *confidence); } return *confidence > 0.0; diff --git a/media/libstagefright/MediaExtractor.cpp b/media/libstagefright/MediaExtractor.cpp index ac6decdb6..8c63de2 100644 --- a/media/libstagefright/MediaExtractor.cpp +++ b/media/libstagefright/MediaExtractor.cpp @@ -63,6 +63,7 @@ sp<MediaExtractor> MediaExtractor::Create( String8 tmp; if (mime == NULL) { + int64_t sniffStart = ALooper::GetNowUs(); float confidence; if (!source->sniff(&tmp, &confidence, &meta)) { ALOGV("FAILED to autodetect media content."); @@ -71,8 +72,9 @@ sp<MediaExtractor> MediaExtractor::Create( } mime = tmp.string(); - ALOGV("Autodetected media content as '%s' with confidence %.2f", - mime, confidence); + ALOGV("Autodetected media content as '%s' with confidence %.2f (%.2f ms)", + mime, confidence, + ((float)(ALooper::GetNowUs() - sniffStart) / 1000.0f)); } else if (prevMeta != NULL) { meta = *prevMeta; } |