Merge changes from topic 'rm-awesome'
* changes:
stagefright: Remove OMXCodec object
stagefright: allow selecting codec by name in SimpleDecodingSource
diff --git a/include/media/MediaCodecInfo.h b/include/media/MediaCodecInfo.h
index 84faa2f..ac5b075 100644
--- a/include/media/MediaCodecInfo.h
+++ b/include/media/MediaCodecInfo.h
@@ -122,8 +122,8 @@
void addQuirk(const char *name);
status_t addMime(const char *mime);
status_t updateMime(const char *mime);
- // after this call Capabilities will be owned by MediaCodecInfo
- status_t setCapabilities(const sp<Capabilities> &caps);
+
+ status_t initializeCapabilities(const sp<Capabilities> &caps);
void addDetail(const AString &key, const AString &value);
void addFeature(const AString &key, int32_t value);
void addFeature(const AString &key, const char *value);
diff --git a/media/libmedia/MediaCodecInfo.cpp b/media/libmedia/MediaCodecInfo.cpp
index 3b53f4c..06abd8d 100644
--- a/media/libmedia/MediaCodecInfo.cpp
+++ b/media/libmedia/MediaCodecInfo.cpp
@@ -238,8 +238,15 @@
}
}
-status_t MediaCodecInfo::setCapabilities(const sp<Capabilities> &caps) {
- mCurrentCaps = caps;
+status_t MediaCodecInfo::initializeCapabilities(const sp<Capabilities> &caps) {
+ // TRICKY: copy data to mCurrentCaps as it is a reference to
+ // an element of the capabilites map.
+ mCurrentCaps->mColorFormats.clear();
+ mCurrentCaps->mColorFormats.appendVector(caps->mColorFormats);
+ mCurrentCaps->mProfileLevels.clear();
+ mCurrentCaps->mProfileLevels.appendVector(caps->mProfileLevels);
+ mCurrentCaps->mFlags = caps->mFlags;
+ mCurrentCaps->mDetails = caps->mDetails;
return OK;
}
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index cb6b22f..10734e4 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -55,6 +55,10 @@
namespace android {
+enum {
+ kMaxIndicesToCheck = 32, // used when enumerating supported formats and profiles
+};
+
// OMX errors are directly mapped into status_t range if
// there is no corresponding MediaError status code.
// Use the statusFromOMXError(int32_t omxError) function.
@@ -2278,9 +2282,8 @@
InitOMXParams(&format);
format.nPortIndex = portIndex;
- for (OMX_U32 index = 0;; ++index) {
+ for (OMX_U32 index = 0; index <= kMaxIndicesToCheck; ++index) {
format.nIndex = index;
-
status_t err = mOMX->getParameter(
mNode, OMX_IndexParamAudioPortFormat,
&format, sizeof(format));
@@ -2292,6 +2295,13 @@
if (format.eEncoding == desiredFormat) {
break;
}
+
+ if (index == kMaxIndicesToCheck) {
+ ALOGW("[%s] stopping checking formats after %u: %s(%x)",
+ mComponentName.c_str(), index,
+ asString(format.eEncoding), format.eEncoding);
+ return ERROR_UNSUPPORTED;
+ }
}
return mOMX->setParameter(
@@ -2711,8 +2721,7 @@
format.nIndex = 0;
bool found = false;
- OMX_U32 index = 0;
- for (;;) {
+ for (OMX_U32 index = 0; index <= kMaxIndicesToCheck; ++index) {
format.nIndex = index;
status_t err = mOMX->getParameter(
mNode, OMX_IndexParamVideoPortFormat,
@@ -2757,7 +2766,12 @@
break;
}
- ++index;
+ if (index == kMaxIndicesToCheck) {
+ ALOGW("[%s] stopping checking formats after %u: %s(%x)/%s(%x)",
+ mComponentName.c_str(), index,
+ asString(format.eCompressionFormat), format.eCompressionFormat,
+ asString(format.eColorFormat), format.eColorFormat);
+ }
}
if (!found) {
@@ -3630,7 +3644,8 @@
InitOMXParams(¶ms);
params.nPortIndex = kPortIndexOutput;
- for (params.nProfileIndex = 0;; ++params.nProfileIndex) {
+ for (OMX_U32 index = 0; index <= kMaxIndicesToCheck; ++index) {
+ params.nProfileIndex = index;
status_t err = mOMX->getParameter(
mNode,
OMX_IndexParamVideoProfileLevelQuerySupported,
@@ -3647,7 +3662,14 @@
if (profile == supportedProfile && level <= supportedLevel) {
return OK;
}
+
+ if (index == kMaxIndicesToCheck) {
+ ALOGW("[%s] stopping checking profiles after %u: %x/%x",
+ mComponentName.c_str(), index,
+ params.eProfile, params.eLevel);
+ }
}
+ return ERROR_UNSUPPORTED;
}
status_t ACodec::configureBitrate(
@@ -6904,7 +6926,8 @@
InitOMXParams(¶m);
param.nPortIndex = isEncoder ? kPortIndexOutput : kPortIndexInput;
- for (param.nProfileIndex = 0;; ++param.nProfileIndex) {
+ for (OMX_U32 index = 0; index <= kMaxIndicesToCheck; ++index) {
+ param.nProfileIndex = index;
status_t err = omx->getParameter(
node, OMX_IndexParamVideoProfileLevelQuerySupported,
¶m, sizeof(param));
@@ -6912,6 +6935,12 @@
break;
}
builder->addProfileLevel(param.eProfile, param.eLevel);
+
+ if (index == kMaxIndicesToCheck) {
+ ALOGW("[%s] stopping checking profiles after %u: %x/%x",
+ name.c_str(), index,
+ param.eProfile, param.eLevel);
+ }
}
// Color format query
@@ -6919,9 +6948,10 @@
// prefix "flexible" standard ones with the flexible equivalent
OMX_VIDEO_PARAM_PORTFORMATTYPE portFormat;
InitOMXParams(&portFormat);
- param.nPortIndex = isEncoder ? kPortIndexInput : kPortIndexOutput;
+ portFormat.nPortIndex = isEncoder ? kPortIndexInput : kPortIndexOutput;
Vector<uint32_t> supportedColors; // shadow copy to check for duplicates
- for (portFormat.nIndex = 0;; ++portFormat.nIndex) {
+ for (OMX_U32 index = 0; index <= kMaxIndicesToCheck; ++index) {
+ portFormat.nIndex = index;
status_t err = omx->getParameter(
node, OMX_IndexParamVideoPortFormat,
&portFormat, sizeof(portFormat));
@@ -6947,6 +6977,12 @@
}
supportedColors.push(portFormat.eColorFormat);
builder->addColorFormat(portFormat.eColorFormat);
+
+ if (index == kMaxIndicesToCheck) {
+ ALOGW("[%s] stopping checking formats after %u: %s(%x)",
+ name.c_str(), index,
+ asString(portFormat.eColorFormat), portFormat.eColorFormat);
+ }
}
}
diff --git a/media/libstagefright/MediaCodecList.cpp b/media/libstagefright/MediaCodecList.cpp
index 34d85e7..0fb5072 100644
--- a/media/libstagefright/MediaCodecList.cpp
+++ b/media/libstagefright/MediaCodecList.cpp
@@ -767,7 +767,7 @@
return UNKNOWN_ERROR;
}
- return mCurrentInfo->setCapabilities(caps);
+ return mCurrentInfo->initializeCapabilities(caps);
}
status_t MediaCodecList::addQuirk(const char **attrs) {
diff --git a/media/libstagefright/SimpleDecodingSource.cpp b/media/libstagefright/SimpleDecodingSource.cpp
index 02412fe..d544e35 100644
--- a/media/libstagefright/SimpleDecodingSource.cpp
+++ b/media/libstagefright/SimpleDecodingSource.cpp
@@ -31,6 +31,7 @@
using namespace android;
const int64_t kTimeoutWaitForOutputUs = 500000; // 0.5 seconds
+const int64_t kTimeoutWaitForInputUs = 5000; // 5 milliseconds
//static
sp<SimpleDecodingSource> SimpleDecodingSource::Create(
@@ -209,13 +210,14 @@
return ERROR_END_OF_STREAM;
}
- for (int retries = 1; ++retries; ) {
+ for (int retries = 0; ++retries; ) {
// If we fill all available input buffers, we should expect that
// the codec produces at least one output buffer. Also, the codec
// should produce an output buffer in at most 1 seconds. Retry a
// few times nonetheless.
while (!me->mQueuedInputEOS) {
- res = mCodec->dequeueInputBuffer(&in_ix, 0);
+ // allow some time to get input buffer after flush
+ res = mCodec->dequeueInputBuffer(&in_ix, kTimeoutWaitForInputUs);
if (res == -EAGAIN) {
// no available input buffers
break;
diff --git a/media/libstagefright/codecs/avcenc/SoftAVCEnc.cpp b/media/libstagefright/codecs/avcenc/SoftAVCEnc.cpp
index 387d17d..d0ad4f8 100644
--- a/media/libstagefright/codecs/avcenc/SoftAVCEnc.cpp
+++ b/media/libstagefright/codecs/avcenc/SoftAVCEnc.cpp
@@ -157,8 +157,7 @@
kProfileLevels, NELEM(kProfileLevels),
176 /* width */, 144 /* height */,
callbacks, appData, component),
- mBitrateUpdated(false),
- mKeyFrameRequested(false),
+ mUpdateFlag(0),
mIvVideoColorFormat(IV_YUV_420P),
mAVCEncProfile(IV_PROFILE_BASE),
mAVCEncLevel(41),
@@ -1039,7 +1038,9 @@
return OMX_ErrorBadPortIndex;
}
- mKeyFrameRequested = params->IntraRefreshVOP;
+ if (params->IntraRefreshVOP) {
+ mUpdateFlag |= kRequestKeyFrame;
+ }
return OMX_ErrorNone;
}
@@ -1054,7 +1055,7 @@
if (mBitrate != params->nEncodeBitrate) {
mBitrate = params->nEncodeBitrate;
- mBitrateUpdated = true;
+ mUpdateFlag |= kUpdateBitrate;
}
return OMX_ErrorNone;
}
@@ -1071,7 +1072,7 @@
}
mBitrate = bitrate->nTargetBitrate;
- mBitrateUpdated = true;
+ mUpdateFlag |= kUpdateBitrate;
return OMX_ErrorNone;
}
@@ -1291,12 +1292,14 @@
return;
}
- if (mBitrateUpdated) {
- setBitRate();
- }
-
- if (mKeyFrameRequested) {
- setFrameType(IV_IDR_FRAME);
+ if (mUpdateFlag) {
+ if (mUpdateFlag & kUpdateBitrate) {
+ setBitRate();
+ }
+ if (mUpdateFlag & kRequestKeyFrame) {
+ setFrameType(IV_IDR_FRAME);
+ }
+ mUpdateFlag = 0;
}
if ((inputBufferHeader != NULL)
diff --git a/media/libstagefright/codecs/avcenc/SoftAVCEnc.h b/media/libstagefright/codecs/avcenc/SoftAVCEnc.h
index 4418a7f..6a3bc0f 100644
--- a/media/libstagefright/codecs/avcenc/SoftAVCEnc.h
+++ b/media/libstagefright/codecs/avcenc/SoftAVCEnc.h
@@ -142,6 +142,11 @@
kNumBuffers = 2,
};
+ enum {
+ kUpdateBitrate = 1 << 0,
+ kRequestKeyFrame = 1 << 1,
+ };
+
// OMX input buffer's timestamp and flags
typedef struct {
int64_t mTimeUs;
@@ -153,11 +158,7 @@
struct timeval mTimeStart; // Time at the start of decode()
struct timeval mTimeEnd; // Time at the end of decode()
-
- // If a request for a change it bitrate has been received.
- bool mBitrateUpdated;
-
- bool mKeyFrameRequested;
+ int mUpdateFlag;
#ifdef FILE_DUMP_ENABLE
char mInFile[200];
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index 3deb396..41d812b 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -2353,7 +2353,7 @@
result.appendFormat(" Resource Cost: %d\n", state.second->getCost());
result.appendFormat(" Conflicting Devices:");
for (auto& id : conflicting) {
- result.appendFormat(" %s", cameraId.string());
+ result.appendFormat(" %s", id.string());
}
if (conflicting.size() == 0) {
result.appendFormat(" NONE");