Merge "bug fix: configure input port buffer size" into oc-mr1-dev

This commit is contained in:
TreeHugger Robot 2017-08-16 04:23:43 +00:00 committed by Android (Google) Code Review
commit 97d68ba8f2
3 changed files with 55 additions and 4 deletions

View file

@ -60,6 +60,25 @@ Return<android::hardware::media::omx::V1_0::Status> setRole(
return setParam(omxNode, OMX_IndexParamStandardComponentRole, &params);
}
Return<android::hardware::media::omx::V1_0::Status> setPortBufferSize(
sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_U32 size) {
android::hardware::media::omx::V1_0::Status status;
OMX_PARAM_PORTDEFINITIONTYPE portDef;
status = getPortParam(omxNode, OMX_IndexParamPortDefinition, portIndex,
&portDef);
if (status != ::android::hardware::media::omx::V1_0::Status::OK)
return status;
if (portDef.nBufferSize < size) {
portDef.nBufferSize = size;
status = setPortParam(omxNode, OMX_IndexParamPortDefinition, portIndex,
&portDef);
if (status != ::android::hardware::media::omx::V1_0::Status::OK)
return status;
}
return status;
}
// get/set video component port format
Return<android::hardware::media::omx::V1_0::Status> setVideoPortFormat(
sp<IOmxNode> omxNode, OMX_U32 portIndex,

View file

@ -54,6 +54,9 @@
*/
#define RANDOM_INDEX 1729
#define ALIGN_POWER_OF_TWO(value, n) \
(((value) + ((1 << (n)) - 1)) & ~((1 << (n)) - 1))
enum bufferOwner {
client,
component,
@ -282,6 +285,9 @@ Return<android::hardware::media::omx::V1_0::Status> setPortConfig(
Return<android::hardware::media::omx::V1_0::Status> setRole(
sp<IOmxNode> omxNode, const char* role);
Return<android::hardware::media::omx::V1_0::Status> setPortBufferSize(
sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_U32 size);
Return<android::hardware::media::omx::V1_0::Status> setVideoPortFormat(
sp<IOmxNode> omxNode, OMX_U32 portIndex,
OMX_VIDEO_CODINGTYPE eCompressionFormat, OMX_COLOR_FORMATTYPE eColorFormat,

View file

@ -897,7 +897,7 @@ TEST_F(VideoDecHidlTest, DecodeTest) {
eleInfo.open(info);
ASSERT_EQ(eleInfo.is_open(), true);
android::Vector<FrameData> Info;
int bytesCount = 0;
int bytesCount = 0, maxBytesCount = 0;
uint32_t flags = 0;
uint32_t timestamp = 0;
timestampDevTest = true;
@ -908,9 +908,15 @@ TEST_F(VideoDecHidlTest, DecodeTest) {
Info.push_back({bytesCount, flags, timestamp});
if (flags != OMX_BUFFERFLAG_CODECCONFIG)
timestampUslist.push_back(timestamp);
if (maxBytesCount < bytesCount) maxBytesCount = bytesCount;
}
eleInfo.close();
// As the frame sizes are known ahead, use it to configure i/p buffer size
maxBytesCount = ALIGN_POWER_OF_TWO(maxBytesCount, 10);
status = setPortBufferSize(omxNode, kPortIndexInput, maxBytesCount);
ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
// set port mode
portMode[0] = PortMode::PRESET_BYTE_BUFFER;
portMode[1] = PortMode::DYNAMIC_ANW_BUFFER;
@ -938,6 +944,8 @@ TEST_F(VideoDecHidlTest, DecodeTest) {
EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused,
eColorFormat, nFrameWidth, nFrameHeight, 0, xFramerate);
// disabling adaptive playback.
omxNode->prepareForAdaptivePlayback(kPortIndexOutput, false, 1920, 1080);
android::Vector<BufferInfo> iBuffer, oBuffer;
@ -1067,7 +1075,7 @@ TEST_F(VideoDecHidlTest, ThumbnailTest) {
eleInfo.open(info);
ASSERT_EQ(eleInfo.is_open(), true);
android::Vector<FrameData> Info;
int bytesCount = 0;
int bytesCount = 0, maxBytesCount = 0;
uint32_t flags = 0;
uint32_t timestamp = 0;
while (1) {
@ -1075,9 +1083,15 @@ TEST_F(VideoDecHidlTest, ThumbnailTest) {
eleInfo >> flags;
eleInfo >> timestamp;
Info.push_back({bytesCount, flags, timestamp});
if (maxBytesCount < bytesCount) maxBytesCount = bytesCount;
}
eleInfo.close();
// As the frame sizes are known ahead, use it to configure i/p buffer size
maxBytesCount = ALIGN_POWER_OF_TWO(maxBytesCount, 10);
status = setPortBufferSize(omxNode, kPortIndexInput, maxBytesCount);
ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
// set port mode
status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
@ -1174,7 +1188,7 @@ TEST_F(VideoDecHidlTest, SimpleEOSTest) {
eleInfo.open(info);
ASSERT_EQ(eleInfo.is_open(), true);
android::Vector<FrameData> Info;
int bytesCount = 0;
int bytesCount = 0, maxBytesCount = 0;
uint32_t flags = 0;
uint32_t timestamp = 0;
while (1) {
@ -1182,9 +1196,15 @@ TEST_F(VideoDecHidlTest, SimpleEOSTest) {
eleInfo >> flags;
eleInfo >> timestamp;
Info.push_back({bytesCount, flags, timestamp});
if (maxBytesCount < bytesCount) maxBytesCount = bytesCount;
}
eleInfo.close();
// As the frame sizes are known ahead, use it to configure i/p buffer size
maxBytesCount = ALIGN_POWER_OF_TWO(maxBytesCount, 10);
status = setPortBufferSize(omxNode, kPortIndexInput, maxBytesCount);
ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
// set port mode
status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
@ -1263,7 +1283,7 @@ TEST_F(VideoDecHidlTest, FlushTest) {
eleInfo.open(info);
ASSERT_EQ(eleInfo.is_open(), true);
android::Vector<FrameData> Info;
int bytesCount = 0;
int bytesCount = 0, maxBytesCount = 0;
uint32_t flags = 0;
uint32_t timestamp = 0;
while (1) {
@ -1271,9 +1291,15 @@ TEST_F(VideoDecHidlTest, FlushTest) {
eleInfo >> flags;
eleInfo >> timestamp;
Info.push_back({bytesCount, flags, timestamp});
if (maxBytesCount < bytesCount) maxBytesCount = bytesCount;
}
eleInfo.close();
// As the frame sizes are known ahead, use it to configure i/p buffer size
maxBytesCount = ALIGN_POWER_OF_TWO(maxBytesCount, 10);
status = setPortBufferSize(omxNode, kPortIndexInput, maxBytesCount);
ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
// set port mode
status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);