summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2012-08-31 14:00:05 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-08-31 14:00:05 -0700
commit45cfc5fefda49b5691fd757ab712ba6a4100525e (patch)
tree39775c5114fc82af9ceab8895c6341ea8272ac0e /media
parentfbb83b2db6a3c30bd0756cdba1c223ea09495c21 (diff)
parent7468828497435ed88534508537714149aa66ead3 (diff)
downloadframeworks_av-45cfc5fefda49b5691fd757ab712ba6a4100525e.zip
frameworks_av-45cfc5fefda49b5691fd757ab712ba6a4100525e.tar.gz
frameworks_av-45cfc5fefda49b5691fd757ab712ba6a4100525e.tar.bz2
am 892020e4: Merge "Special mode for ESQueue that allows for earlier dequeuing of access units" into jb-mr1-dev
* commit '892020e46b97adfa012be7a9dd688a2d6d528de4': Special mode for ESQueue that allows for earlier dequeuing of access units
Diffstat (limited to 'media')
-rw-r--r--media/libstagefright/mpeg2ts/ESQueue.cpp32
-rw-r--r--media/libstagefright/mpeg2ts/ESQueue.h8
2 files changed, 36 insertions, 4 deletions
diff --git a/media/libstagefright/mpeg2ts/ESQueue.cpp b/media/libstagefright/mpeg2ts/ESQueue.cpp
index 1cab077..e58e9bf 100644
--- a/media/libstagefright/mpeg2ts/ESQueue.cpp
+++ b/media/libstagefright/mpeg2ts/ESQueue.cpp
@@ -33,8 +33,9 @@
namespace android {
-ElementaryStreamQueue::ElementaryStreamQueue(Mode mode)
- : mMode(mode) {
+ElementaryStreamQueue::ElementaryStreamQueue(Mode mode, uint32_t flags)
+ : mMode(mode),
+ mFlags(flags) {
}
sp<MetaData> ElementaryStreamQueue::getFormat() {
@@ -289,6 +290,31 @@ status_t ElementaryStreamQueue::appendData(
}
sp<ABuffer> ElementaryStreamQueue::dequeueAccessUnit() {
+ if ((mFlags & kFlag_AlignedData) && mMode == H264) {
+ if (mRangeInfos.empty()) {
+ return NULL;
+ }
+
+ RangeInfo info = *mRangeInfos.begin();
+ mRangeInfos.erase(mRangeInfos.begin());
+
+ sp<ABuffer> accessUnit = new ABuffer(info.mLength);
+ memcpy(accessUnit->data(), mBuffer->data(), info.mLength);
+ accessUnit->meta()->setInt64("timeUs", info.mTimestampUs);
+
+ memmove(mBuffer->data(),
+ mBuffer->data() + info.mLength,
+ mBuffer->size() - info.mLength);
+
+ mBuffer->setRange(0, mBuffer->size() - info.mLength);
+
+ if (mFormat == NULL) {
+ mFormat = MakeAVCCodecSpecificData(accessUnit);
+ }
+
+ return accessUnit;
+ }
+
switch (mMode) {
case H264:
return dequeueAccessUnitH264();
@@ -436,8 +462,8 @@ struct NALPosition {
sp<ABuffer> ElementaryStreamQueue::dequeueAccessUnitH264() {
const uint8_t *data = mBuffer->data();
- size_t size = mBuffer->size();
+ size_t size = mBuffer->size();
Vector<NALPosition> nals;
size_t totalSize = 0;
diff --git a/media/libstagefright/mpeg2ts/ESQueue.h b/media/libstagefright/mpeg2ts/ESQueue.h
index 4035ed3..72aa2e7 100644
--- a/media/libstagefright/mpeg2ts/ESQueue.h
+++ b/media/libstagefright/mpeg2ts/ESQueue.h
@@ -36,7 +36,12 @@ struct ElementaryStreamQueue {
MPEG_VIDEO,
MPEG4_VIDEO,
};
- ElementaryStreamQueue(Mode mode);
+
+ enum Flags {
+ // Data appended to the queue is always at access unit boundaries.
+ kFlag_AlignedData = 1,
+ };
+ ElementaryStreamQueue(Mode mode, uint32_t flags = 0);
status_t appendData(const void *data, size_t size, int64_t timeUs);
void clear(bool clearFormat);
@@ -52,6 +57,7 @@ private:
};
Mode mMode;
+ uint32_t mFlags;
sp<ABuffer> mBuffer;
List<RangeInfo> mRangeInfos;