139 lines
5.2 KiB
Diff
139 lines
5.2 KiB
Diff
From bf69673517df3b7c1f90cc07621f8af998310110 Mon Sep 17 00:00:00 2001
|
|
From: Wonsik Kim <wonsik@google.com>
|
|
Date: Tue, 22 Sep 2020 18:44:47 -0700
|
|
Subject: [PATCH 23/30] ACodec: submit extra output metadata buffers if in low
|
|
latency mode
|
|
|
|
Bug: 166250452
|
|
Test: atest CtsMediaTestCases:DecoderTest
|
|
Merged-In: I134a16a70e8ac94dbd4f505c0a5553a3ca0f87a2
|
|
Change-Id: I134a16a70e8ac94dbd4f505c0a5553a3ca0f87a2
|
|
(cherry picked from commit 7e0bb3845b3059c0ee5bd33e506368828cca40fe)
|
|
---
|
|
media/libstagefright/ACodec.cpp | 39 ++++++++++++++++++-
|
|
.../include/media/stagefright/ACodec.h | 2 +
|
|
2 files changed, 39 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
|
|
index 7ea444dc77..0f8cd39edb 100644
|
|
--- a/media/libstagefright/ACodec.cpp
|
|
+++ b/media/libstagefright/ACodec.cpp
|
|
@@ -279,6 +279,13 @@ protected:
|
|
|
|
void postFillThisBuffer(BufferInfo *info);
|
|
|
|
+ void maybePostExtraOutputMetadataBufferRequest() {
|
|
+ if (!mPendingExtraOutputMetadataBufferRequest) {
|
|
+ (new AMessage(kWhatSubmitExtraOutputMetadataBuffer, mCodec))->post();
|
|
+ mPendingExtraOutputMetadataBufferRequest = true;
|
|
+ }
|
|
+ }
|
|
+
|
|
private:
|
|
// Handles an OMX message. Returns true iff message was handled.
|
|
bool onOMXMessage(const sp<AMessage> &msg);
|
|
@@ -302,6 +309,8 @@ private:
|
|
|
|
void getMoreInputDataIfPossible();
|
|
|
|
+ bool mPendingExtraOutputMetadataBufferRequest;
|
|
+
|
|
DISALLOW_EVIL_CONSTRUCTORS(BaseState);
|
|
};
|
|
|
|
@@ -555,6 +564,7 @@ ACodec::ACodec()
|
|
mShutdownInProgress(false),
|
|
mExplicitShutdown(false),
|
|
mIsLegacyVP9Decoder(false),
|
|
+ mIsLowLatency(false),
|
|
mEncoderDelay(0),
|
|
mEncoderPadding(0),
|
|
mRotationDegrees(0),
|
|
@@ -2425,6 +2435,7 @@ status_t ACodec::setLowLatency(int32_t lowLatency) {
|
|
if (err != OK) {
|
|
ALOGE("decoder can not set low-latency to %d (err %d)", lowLatency, err);
|
|
}
|
|
+ mIsLowLatency = (lowLatency && err == OK);
|
|
return err;
|
|
}
|
|
|
|
@@ -5785,7 +5796,8 @@ status_t ACodec::requestIDRFrame() {
|
|
|
|
ACodec::BaseState::BaseState(ACodec *codec, const sp<AState> &parentState)
|
|
: AState(parentState),
|
|
- mCodec(codec) {
|
|
+ mCodec(codec),
|
|
+ mPendingExtraOutputMetadataBufferRequest(false) {
|
|
}
|
|
|
|
ACodec::BaseState::PortMode ACodec::BaseState::getPortMode(
|
|
@@ -5886,6 +5898,21 @@ bool ACodec::BaseState::onMessageReceived(const sp<AMessage> &msg) {
|
|
break;
|
|
}
|
|
|
|
+ case kWhatSubmitExtraOutputMetadataBuffer: {
|
|
+ mPendingExtraOutputMetadataBufferRequest = false;
|
|
+ if (getPortMode(kPortIndexOutput) == RESUBMIT_BUFFERS && mCodec->mIsLowLatency) {
|
|
+ // Decoders often need more than one output buffer to be
|
|
+ // submitted before processing a single input buffer.
|
|
+ // For low latency codecs, we don't want to wait for more input
|
|
+ // to be queued to get those output buffers submitted.
|
|
+ if (mCodec->submitOutputMetadataBuffer() == OK
|
|
+ && mCodec->mMetadataBuffersToSubmit > 0) {
|
|
+ maybePostExtraOutputMetadataBufferRequest();
|
|
+ }
|
|
+ }
|
|
+ break;
|
|
+ }
|
|
+
|
|
default:
|
|
return false;
|
|
}
|
|
@@ -6242,7 +6269,12 @@ void ACodec::BaseState::onInputBufferFilled(const sp<AMessage> &msg) {
|
|
(outputMode == FREE_BUFFERS ? "FREE" :
|
|
outputMode == KEEP_BUFFERS ? "KEEP" : "RESUBMIT"));
|
|
if (outputMode == RESUBMIT_BUFFERS) {
|
|
- mCodec->submitOutputMetadataBuffer();
|
|
+ status_t err = mCodec->submitOutputMetadataBuffer();
|
|
+ if (mCodec->mIsLowLatency
|
|
+ && err == OK
|
|
+ && mCodec->mMetadataBuffersToSubmit > 0) {
|
|
+ maybePostExtraOutputMetadataBufferRequest();
|
|
+ }
|
|
}
|
|
}
|
|
info->checkReadFence("onInputBufferFilled");
|
|
@@ -7388,6 +7420,9 @@ void ACodec::ExecutingState::submitOutputMetaBuffers() {
|
|
break;
|
|
}
|
|
}
|
|
+ if (mCodec->mIsLowLatency) {
|
|
+ maybePostExtraOutputMetadataBufferRequest();
|
|
+ }
|
|
|
|
// *** NOTE: THE FOLLOWING WORKAROUND WILL BE REMOVED ***
|
|
mCodec->signalSubmitOutputMetadataBufferIfEOS_workaround();
|
|
diff --git a/media/libstagefright/include/media/stagefright/ACodec.h b/media/libstagefright/include/media/stagefright/ACodec.h
|
|
index 105e7f7f98..8ef92783ec 100644
|
|
--- a/media/libstagefright/include/media/stagefright/ACodec.h
|
|
+++ b/media/libstagefright/include/media/stagefright/ACodec.h
|
|
@@ -147,6 +147,7 @@ private:
|
|
kWhatReleaseCodecInstance = 'relC',
|
|
kWhatForceStateTransition = 'fstt',
|
|
kWhatCheckIfStuck = 'Cstk',
|
|
+ kWhatSubmitExtraOutputMetadataBuffer = 'sbxo',
|
|
};
|
|
|
|
enum {
|
|
@@ -272,6 +273,7 @@ private:
|
|
bool mShutdownInProgress;
|
|
bool mExplicitShutdown;
|
|
bool mIsLegacyVP9Decoder;
|
|
+ bool mIsLowLatency;
|
|
|
|
// If "mKeepComponentAllocated" we only transition back to Loaded state
|
|
// and do not release the component instance.
|
|
--
|
|
2.25.1
|
|
|