aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPin-chih Lin <johnylin@google.com>2018-09-11 15:41:39 +0800
committerPin-chih Lin <johnylin@google.com>2018-09-12 11:29:18 +0800
commit41db963edef0129a5d5dcda319e9946779b3985d (patch)
tree7f1842dbe7fb43022e4fd61eec44dd1ee045e5a8
parent3fe0c8d0909e8b3429e187c1de88c90a635f07ea (diff)
downloadv4l2_codec2-41db963edef0129a5d5dcda319e9946779b3985d.tar.gz
Unfortuneately the previous assumption of getting monotonic increasing timestamp as display order of output buffers is not always right. In testH264_adaptiveSkipBack, the timestamp goes back and forth. For such cases we cannot rely on timestamp for checking work done anymore, we cannot help but rely on input flags for recognizing CSD buffer works, which doesn't have a correlated output buffer; otherwise, work is done only if both input and output buffer are returned from VDA. Bug: 80402878 Test: android.media.cts.AdaptivePlaybackTest#testH264_adaptiveSkipBack for codec2.0 on eve-arcnext Change-Id: Ib3af3ca0ee90925187662af4ae0eb4d628ad21a6
-rw-r--r--C2VDAComponent.cpp28
-rw-r--r--include/C2VDAComponent.h3
2 files changed, 5 insertions, 26 deletions
diff --git a/C2VDAComponent.cpp b/C2VDAComponent.cpp
index 78e5814..fd7b313 100644
--- a/C2VDAComponent.cpp
+++ b/C2VDAComponent.cpp
@@ -208,7 +208,6 @@ C2VDAComponent::C2VDAComponent(C2String name, c2_node_id_t id,
mVDAInitResult(VideoDecodeAcceleratorAdaptor::Result::ILLEGAL_STATE),
mComponentState(ComponentState::UNINITIALIZED),
mPendingOutputEOS(false),
- mLastOutputTimestamp(-1),
mCodecProfile(media::VIDEO_CODEC_PROFILE_UNKNOWN),
mState(State::UNLOADED),
mWeakThisFactory(this) {
@@ -423,11 +422,6 @@ void C2VDAComponent::onOutputBufferDone(int32_t pictureBufferId, int32_t bitstre
C2Buffer::CreateGraphicBuffer(std::move(constBlock)));
info->mGraphicBlock.reset();
- // TODO: this does not work for timestamps as they can wrap around
- int64_t currentTimestamp = ::base::checked_cast<int64_t>(work->input.ordinal.timestamp.peek());
- CHECK_GE(currentTimestamp, mLastOutputTimestamp);
- mLastOutputTimestamp = currentTimestamp;
-
reportFinishedWorkIfAny();
}
@@ -481,9 +475,6 @@ void C2VDAComponent::onDrainDone() {
// mPendingWorks must be empty after draining is finished.
CHECK(mPendingWorks.empty());
- // Last stream is finished. Reset the timestamp record.
- mLastOutputTimestamp = -1;
-
// Work dequeueing was stopped while component draining. Restart it.
mTaskRunner->PostTask(FROM_HERE,
::base::Bind(&C2VDAComponent::onDequeueWork, ::base::Unretained(this)));
@@ -545,8 +536,6 @@ void C2VDAComponent::onResetDone() {
void C2VDAComponent::onFlushDone() {
ALOGV("onFlushDone");
reportAbandonedWorks();
- // Reset the timestamp record.
- mLastOutputTimestamp = -1;
mComponentState = ComponentState::STARTED;
// Work dequeueing was stopped while component flushing. Restart it.
@@ -562,7 +551,6 @@ void C2VDAComponent::onStopDone() {
// do something for them?
reportAbandonedWorks();
mPendingOutputFormat.reset();
- mLastOutputTimestamp = -1;
if (mVDAAdaptor.get()) {
mVDAAdaptor->destroy();
mVDAAdaptor.reset(nullptr);
@@ -1120,11 +1108,6 @@ void C2VDAComponent::reportFinishedWorkIfAny() {
std::list<std::unique_ptr<C2Work>> finishedWorks;
// Work should be reported as done if both input and output buffer are returned by VDA.
-
- // Note that not every input buffer has matched output (ex. CSD header for H.264).
- // However, the timestamp is guaranteed to be monotonic increasing for buffers in display order.
- // That is, since VDA output is in display order, if we get a returned output with timestamp T,
- // it implies all works with timestamp <= T are done.
// EOS work will not be reported here. reportEOSWork() does it.
auto iter = mPendingWorks.begin();
while (iter != mPendingWorks.end()) {
@@ -1157,13 +1140,12 @@ bool C2VDAComponent::isWorkDone(const C2Work* work) const {
// returned by reportEOSWork() instead.
return false;
}
- if (mLastOutputTimestamp < 0) {
- return false; // No output buffer is returned yet.
- }
- if (work->input.ordinal.timestamp > static_cast<uint64_t>(mLastOutputTimestamp)) {
- return false; // Output buffer is not returned by VDA yet.
+ if (!(work->input.flags & C2FrameData::FLAG_CODEC_CONFIG) &&
+ work->worklets.front()->output.buffers.empty()) {
+ // Output buffer is not returned from VDA yet.
+ return false;
}
- return true; // Output buffer is returned, or it has no related output buffer.
+ return true; // Output buffer is returned, or it has no related output buffer (CSD work).
}
void C2VDAComponent::reportEOSWork() {
diff --git a/include/C2VDAComponent.h b/include/C2VDAComponent.h
index 254b9b0..477bc1c 100644
--- a/include/C2VDAComponent.h
+++ b/include/C2VDAComponent.h
@@ -293,9 +293,6 @@ private:
// The pending output format. We need to wait until all buffers are returned back to apply the
// format change.
std::unique_ptr<VideoFormat> mPendingOutputFormat;
- // Record the timestamp of the last output buffer. This is used to determine if the work is
- // finished.
- int64_t mLastOutputTimestamp;
// The indicator of whether component is in secure mode.
bool mSecureMode;