mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
bug fix: configure input port buffer size
In video decoders, size of a single input frame (elementary-stream)
is dependent on width, height, color format, profile settings, ...
Most of this information is part of sps, pps and requires parsing.
But as the max size of the stream is known ahead, use it to configure
the input buffer size requirements
Bug: 63875287
Bug: 63796949
Merged-In: Ib760c4f55b094260a0abd120f852dcf1899df4e0
Change-Id: Ib760c4f55b094260a0abd120f852dcf1899df4e0
(cherry picked from commit 9ce313a7b3)
This commit is contained in:
committed by
Keun Soo Yim
parent
7409a9312d
commit
9a18ceb557
@@ -46,47 +46,6 @@ using ::android::sp;
|
||||
#include <media_hidl_test_common.h>
|
||||
#include <memory>
|
||||
|
||||
Return<android::hardware::media::omx::V1_0::Status> setAudioPortFormat(
|
||||
sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE eEncoding) {
|
||||
OMX_U32 index = 0;
|
||||
OMX_AUDIO_PARAM_PORTFORMATTYPE portFormat;
|
||||
std::vector<OMX_AUDIO_CODINGTYPE> arrEncoding;
|
||||
android::hardware::media::omx::V1_0::Status status;
|
||||
|
||||
while (1) {
|
||||
portFormat.nIndex = index;
|
||||
status = getPortParam(omxNode, OMX_IndexParamAudioPortFormat, portIndex,
|
||||
&portFormat);
|
||||
if (status != ::android::hardware::media::omx::V1_0::Status::OK) break;
|
||||
arrEncoding.push_back(portFormat.eEncoding);
|
||||
index++;
|
||||
if (index == 512) {
|
||||
// enumerated way too many formats, highly unusual for this to
|
||||
// happen.
|
||||
EXPECT_LE(index, 512U)
|
||||
<< "Expecting OMX_ErrorNoMore but not received";
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!index) return status;
|
||||
for (index = 0; index < arrEncoding.size(); index++) {
|
||||
if (arrEncoding[index] == eEncoding) {
|
||||
portFormat.eEncoding = arrEncoding[index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index == arrEncoding.size()) {
|
||||
ALOGE("setting default Port format %x", (int)arrEncoding[0]);
|
||||
portFormat.eEncoding = arrEncoding[0];
|
||||
}
|
||||
// In setParam call nIndex shall be ignored as per omx-il specification.
|
||||
// see how this holds up by corrupting nIndex
|
||||
portFormat.nIndex = RANDOM_INDEX;
|
||||
status = setPortParam(omxNode, OMX_IndexParamAudioPortFormat, portIndex,
|
||||
&portFormat);
|
||||
return status;
|
||||
}
|
||||
|
||||
void enumerateProfile(sp<IOmxNode> omxNode, OMX_U32 portIndex,
|
||||
std::vector<int32_t>* arrProfile) {
|
||||
android::hardware::media::omx::V1_0::Status status;
|
||||
|
||||
@@ -27,9 +27,6 @@
|
||||
/*
|
||||
* Common audio utils
|
||||
*/
|
||||
Return<android::hardware::media::omx::V1_0::Status> setAudioPortFormat(
|
||||
sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE eEncoding);
|
||||
|
||||
void enumerateProfile(sp<IOmxNode> omxNode, OMX_U32 portIndex,
|
||||
std::vector<int32_t>* arrProfile);
|
||||
|
||||
|
||||
@@ -60,6 +60,132 @@ Return<android::hardware::media::omx::V1_0::Status> setRole(
|
||||
return setParam(omxNode, OMX_IndexParamStandardComponentRole, ¶ms);
|
||||
}
|
||||
|
||||
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,
|
||||
OMX_VIDEO_CODINGTYPE eCompressionFormat, OMX_COLOR_FORMATTYPE eColorFormat,
|
||||
OMX_U32 xFramerate) {
|
||||
OMX_U32 index = 0;
|
||||
OMX_VIDEO_PARAM_PORTFORMATTYPE portFormat;
|
||||
std::vector<OMX_COLOR_FORMATTYPE> arrColorFormat;
|
||||
std::vector<OMX_VIDEO_CODINGTYPE> arrCompressionFormat;
|
||||
android::hardware::media::omx::V1_0::Status status;
|
||||
|
||||
while (1) {
|
||||
portFormat.nIndex = index;
|
||||
status = getPortParam(omxNode, OMX_IndexParamVideoPortFormat, portIndex,
|
||||
&portFormat);
|
||||
if (status != ::android::hardware::media::omx::V1_0::Status::OK) break;
|
||||
if (eCompressionFormat == OMX_VIDEO_CodingUnused)
|
||||
arrColorFormat.push_back(portFormat.eColorFormat);
|
||||
else
|
||||
arrCompressionFormat.push_back(portFormat.eCompressionFormat);
|
||||
index++;
|
||||
if (index == 512) {
|
||||
// enumerated way too many formats, highly unusual for this to
|
||||
// happen.
|
||||
EXPECT_LE(index, 512U)
|
||||
<< "Expecting OMX_ErrorNoMore but not received";
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!index) return status;
|
||||
if (eCompressionFormat == OMX_VIDEO_CodingUnused) {
|
||||
for (index = 0; index < arrColorFormat.size(); index++) {
|
||||
if (arrColorFormat[index] == eColorFormat) {
|
||||
portFormat.eColorFormat = arrColorFormat[index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index == arrColorFormat.size()) {
|
||||
ALOGE("setting default color format %x", (int)arrColorFormat[0]);
|
||||
portFormat.eColorFormat = arrColorFormat[0];
|
||||
}
|
||||
portFormat.eCompressionFormat = OMX_VIDEO_CodingUnused;
|
||||
} else {
|
||||
for (index = 0; index < arrCompressionFormat.size(); index++) {
|
||||
if (arrCompressionFormat[index] == eCompressionFormat) {
|
||||
portFormat.eCompressionFormat = arrCompressionFormat[index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index == arrCompressionFormat.size()) {
|
||||
ALOGE("setting default compression format %x",
|
||||
(int)arrCompressionFormat[0]);
|
||||
portFormat.eCompressionFormat = arrCompressionFormat[0];
|
||||
}
|
||||
portFormat.eColorFormat = OMX_COLOR_FormatUnused;
|
||||
}
|
||||
// In setParam call nIndex shall be ignored as per omx-il specification.
|
||||
// see how this holds up by corrupting nIndex
|
||||
portFormat.nIndex = RANDOM_INDEX;
|
||||
portFormat.xFramerate = xFramerate;
|
||||
status = setPortParam(omxNode, OMX_IndexParamVideoPortFormat, portIndex,
|
||||
&portFormat);
|
||||
return status;
|
||||
}
|
||||
|
||||
// get/set audio component port format
|
||||
Return<android::hardware::media::omx::V1_0::Status> setAudioPortFormat(
|
||||
sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE eEncoding) {
|
||||
OMX_U32 index = 0;
|
||||
OMX_AUDIO_PARAM_PORTFORMATTYPE portFormat;
|
||||
std::vector<OMX_AUDIO_CODINGTYPE> arrEncoding;
|
||||
android::hardware::media::omx::V1_0::Status status;
|
||||
|
||||
while (1) {
|
||||
portFormat.nIndex = index;
|
||||
status = getPortParam(omxNode, OMX_IndexParamAudioPortFormat, portIndex,
|
||||
&portFormat);
|
||||
if (status != ::android::hardware::media::omx::V1_0::Status::OK) break;
|
||||
arrEncoding.push_back(portFormat.eEncoding);
|
||||
index++;
|
||||
if (index == 512) {
|
||||
// enumerated way too many formats, highly unusual for this to
|
||||
// happen.
|
||||
EXPECT_LE(index, 512U)
|
||||
<< "Expecting OMX_ErrorNoMore but not received";
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!index) return status;
|
||||
for (index = 0; index < arrEncoding.size(); index++) {
|
||||
if (arrEncoding[index] == eEncoding) {
|
||||
portFormat.eEncoding = arrEncoding[index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index == arrEncoding.size()) {
|
||||
ALOGE("setting default Port format %x", (int)arrEncoding[0]);
|
||||
portFormat.eEncoding = arrEncoding[0];
|
||||
}
|
||||
// In setParam call nIndex shall be ignored as per omx-il specification.
|
||||
// see how this holds up by corrupting nIndex
|
||||
portFormat.nIndex = RANDOM_INDEX;
|
||||
status = setPortParam(omxNode, OMX_IndexParamAudioPortFormat, portIndex,
|
||||
&portFormat);
|
||||
return status;
|
||||
}
|
||||
|
||||
// allocate buffers needed on a component port
|
||||
void allocatePortBuffers(sp<IOmxNode> omxNode,
|
||||
android::Vector<BufferInfo>* buffArray,
|
||||
|
||||
@@ -36,6 +36,14 @@
|
||||
#define DEFAULT_TIMEOUT 100000
|
||||
#define TIMEOUT_COUNTER (10000000 / DEFAULT_TIMEOUT)
|
||||
|
||||
/*
|
||||
* Random Index used for monkey testing while get/set parameters
|
||||
*/
|
||||
#define RANDOM_INDEX 1729
|
||||
|
||||
#define ALIGN_POWER_OF_TWO(value, n) \
|
||||
(((value) + ((1 << (n)) - 1)) & ~((1 << (n)) - 1))
|
||||
|
||||
enum bufferOwner {
|
||||
client,
|
||||
component,
|
||||
@@ -265,6 +273,17 @@ 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,
|
||||
OMX_U32 xFramerate);
|
||||
|
||||
Return<android::hardware::media::omx::V1_0::Status> setAudioPortFormat(
|
||||
sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE eEncoding);
|
||||
|
||||
void allocatePortBuffers(sp<IOmxNode> omxNode,
|
||||
android::Vector<BufferInfo>* buffArray,
|
||||
OMX_U32 portIndex,
|
||||
|
||||
@@ -225,113 +225,6 @@ void initPortMode(PortMode* pm, bool isSecure,
|
||||
return;
|
||||
}
|
||||
|
||||
// get/set video component port format
|
||||
Return<android::hardware::media::omx::V1_0::Status> setVideoPortFormat(
|
||||
sp<IOmxNode> omxNode, OMX_U32 portIndex,
|
||||
OMX_VIDEO_CODINGTYPE eCompressionFormat, OMX_COLOR_FORMATTYPE eColorFormat,
|
||||
OMX_U32 xFramerate) {
|
||||
OMX_U32 index = 0;
|
||||
OMX_VIDEO_PARAM_PORTFORMATTYPE portFormat;
|
||||
std::vector<OMX_COLOR_FORMATTYPE> arrColorFormat;
|
||||
std::vector<OMX_VIDEO_CODINGTYPE> arrCompressionFormat;
|
||||
android::hardware::media::omx::V1_0::Status status;
|
||||
|
||||
while (1) {
|
||||
portFormat.nIndex = index;
|
||||
status = getPortParam(omxNode, OMX_IndexParamVideoPortFormat, portIndex,
|
||||
&portFormat);
|
||||
if (status != ::android::hardware::media::omx::V1_0::Status::OK) break;
|
||||
if (eCompressionFormat == OMX_VIDEO_CodingUnused)
|
||||
arrColorFormat.push_back(portFormat.eColorFormat);
|
||||
else
|
||||
arrCompressionFormat.push_back(portFormat.eCompressionFormat);
|
||||
index++;
|
||||
if (index == 512) {
|
||||
// enumerated way too many formats, highly unusual for this to
|
||||
// happen.
|
||||
EXPECT_LE(index, 512U)
|
||||
<< "Expecting OMX_ErrorNoMore but not received";
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!index) return status;
|
||||
if (eCompressionFormat == OMX_VIDEO_CodingUnused) {
|
||||
for (index = 0; index < arrColorFormat.size(); index++) {
|
||||
if (arrColorFormat[index] == eColorFormat) {
|
||||
portFormat.eColorFormat = arrColorFormat[index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index == arrColorFormat.size()) {
|
||||
ALOGE("setting default color format %x", (int)arrColorFormat[0]);
|
||||
portFormat.eColorFormat = arrColorFormat[0];
|
||||
}
|
||||
portFormat.eCompressionFormat = OMX_VIDEO_CodingUnused;
|
||||
} else {
|
||||
for (index = 0; index < arrCompressionFormat.size(); index++) {
|
||||
if (arrCompressionFormat[index] == eCompressionFormat) {
|
||||
portFormat.eCompressionFormat = arrCompressionFormat[index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index == arrCompressionFormat.size()) {
|
||||
ALOGE("setting default compression format %x",
|
||||
(int)arrCompressionFormat[0]);
|
||||
portFormat.eCompressionFormat = arrCompressionFormat[0];
|
||||
}
|
||||
portFormat.eColorFormat = OMX_COLOR_FormatUnused;
|
||||
}
|
||||
// In setParam call nIndex shall be ignored as per omx-il specification.
|
||||
// see how this holds up by corrupting nIndex
|
||||
portFormat.nIndex = RANDOM_INDEX;
|
||||
portFormat.xFramerate = xFramerate;
|
||||
status = setPortParam(omxNode, OMX_IndexParamVideoPortFormat, portIndex,
|
||||
&portFormat);
|
||||
return status;
|
||||
}
|
||||
|
||||
// get/set audio component port format
|
||||
Return<android::hardware::media::omx::V1_0::Status> setAudioPortFormat(
|
||||
sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE eEncoding) {
|
||||
OMX_U32 index = 0;
|
||||
OMX_AUDIO_PARAM_PORTFORMATTYPE portFormat;
|
||||
std::vector<OMX_AUDIO_CODINGTYPE> arrEncoding;
|
||||
android::hardware::media::omx::V1_0::Status status;
|
||||
|
||||
while (1) {
|
||||
portFormat.nIndex = index;
|
||||
status = getPortParam(omxNode, OMX_IndexParamAudioPortFormat, portIndex,
|
||||
&portFormat);
|
||||
if (status != ::android::hardware::media::omx::V1_0::Status::OK) break;
|
||||
arrEncoding.push_back(portFormat.eEncoding);
|
||||
index++;
|
||||
if (index == 512) {
|
||||
// enumerated way too many formats, highly unusual for this to
|
||||
// happen.
|
||||
EXPECT_LE(index, 512U)
|
||||
<< "Expecting OMX_ErrorNoMore but not received";
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!index) return status;
|
||||
for (index = 0; index < arrEncoding.size(); index++) {
|
||||
if (arrEncoding[index] == eEncoding) {
|
||||
portFormat.eEncoding = arrEncoding[index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index == arrEncoding.size()) {
|
||||
ALOGE("setting default Port format %x", (int)arrEncoding[0]);
|
||||
portFormat.eEncoding = arrEncoding[0];
|
||||
}
|
||||
// In setParam call nIndex shall be ignored as per omx-il specification.
|
||||
// see how this holds up by corrupting nIndex
|
||||
portFormat.nIndex = RANDOM_INDEX;
|
||||
status = setPortParam(omxNode, OMX_IndexParamAudioPortFormat, portIndex,
|
||||
&portFormat);
|
||||
return status;
|
||||
}
|
||||
|
||||
// test dispatch message API call
|
||||
TEST_F(ComponentHidlTest, dispatchMsg) {
|
||||
description("test dispatch message API call");
|
||||
|
||||
@@ -768,7 +768,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;
|
||||
@@ -779,9 +779,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;
|
||||
@@ -801,6 +807,8 @@ TEST_F(VideoDecHidlTest, DecodeTest) {
|
||||
&xFramerate);
|
||||
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;
|
||||
@@ -923,7 +931,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) {
|
||||
@@ -931,9 +939,21 @@ 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);
|
||||
status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
|
||||
ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
|
||||
|
||||
// set Port Params
|
||||
uint32_t nFrameWidth, nFrameHeight, xFramerate;
|
||||
OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatYUV420Planar;
|
||||
@@ -1024,7 +1044,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) {
|
||||
@@ -1032,9 +1052,21 @@ 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);
|
||||
status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
|
||||
ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
|
||||
|
||||
// set Port Params
|
||||
uint32_t nFrameWidth, nFrameHeight, xFramerate;
|
||||
OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatYUV420Planar;
|
||||
@@ -1107,7 +1139,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) {
|
||||
@@ -1115,9 +1147,21 @@ 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);
|
||||
status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
|
||||
ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
|
||||
|
||||
// set Port Params
|
||||
uint32_t nFrameWidth, nFrameHeight, xFramerate;
|
||||
OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatYUV420Planar;
|
||||
|
||||
@@ -52,68 +52,6 @@ using ::android::sp;
|
||||
#include <media_video_hidl_test_common.h>
|
||||
#include <memory>
|
||||
|
||||
Return<android::hardware::media::omx::V1_0::Status> setVideoPortFormat(
|
||||
sp<IOmxNode> omxNode, OMX_U32 portIndex,
|
||||
OMX_VIDEO_CODINGTYPE eCompressionFormat, OMX_COLOR_FORMATTYPE eColorFormat,
|
||||
OMX_U32 xFramerate) {
|
||||
OMX_U32 index = 0;
|
||||
OMX_VIDEO_PARAM_PORTFORMATTYPE portFormat;
|
||||
std::vector<OMX_COLOR_FORMATTYPE> arrColorFormat;
|
||||
std::vector<OMX_VIDEO_CODINGTYPE> arrCompressionFormat;
|
||||
android::hardware::media::omx::V1_0::Status status;
|
||||
|
||||
while (1) {
|
||||
portFormat.nIndex = index;
|
||||
status = getPortParam(omxNode, OMX_IndexParamVideoPortFormat, portIndex,
|
||||
&portFormat);
|
||||
if (status != ::android::hardware::media::omx::V1_0::Status::OK) break;
|
||||
if (eCompressionFormat == OMX_VIDEO_CodingUnused)
|
||||
arrColorFormat.push_back(portFormat.eColorFormat);
|
||||
else
|
||||
arrCompressionFormat.push_back(portFormat.eCompressionFormat);
|
||||
index++;
|
||||
if (index == 512) {
|
||||
// enumerated way too many formats, highly unusual for this to
|
||||
// happen.
|
||||
EXPECT_LE(index, 512U)
|
||||
<< "Expecting OMX_ErrorNoMore but not received";
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!index) return status;
|
||||
if (eCompressionFormat == OMX_VIDEO_CodingUnused) {
|
||||
for (index = 0; index < arrColorFormat.size(); index++) {
|
||||
if (arrColorFormat[index] == eColorFormat) {
|
||||
portFormat.eColorFormat = arrColorFormat[index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index == arrColorFormat.size()) {
|
||||
ALOGE("setting default color format %x", (int)arrColorFormat[0]);
|
||||
portFormat.eColorFormat = arrColorFormat[0];
|
||||
}
|
||||
portFormat.eCompressionFormat = OMX_VIDEO_CodingUnused;
|
||||
} else {
|
||||
for (index = 0; index < arrCompressionFormat.size(); index++) {
|
||||
if (arrCompressionFormat[index] == eCompressionFormat) {
|
||||
portFormat.eCompressionFormat = arrCompressionFormat[index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index == arrCompressionFormat.size()) {
|
||||
ALOGE("setting default compression format %x",
|
||||
(int)arrCompressionFormat[0]);
|
||||
portFormat.eCompressionFormat = arrCompressionFormat[0];
|
||||
}
|
||||
portFormat.eColorFormat = OMX_COLOR_FormatUnused;
|
||||
}
|
||||
portFormat.nIndex = 0;
|
||||
portFormat.xFramerate = xFramerate;
|
||||
status = setPortParam(omxNode, OMX_IndexParamVideoPortFormat, portIndex,
|
||||
&portFormat);
|
||||
return status;
|
||||
}
|
||||
|
||||
void enumerateProfileAndLevel(sp<IOmxNode> omxNode, OMX_U32 portIndex,
|
||||
std::vector<int32_t>* arrProfile,
|
||||
std::vector<int32_t>* arrLevel) {
|
||||
|
||||
@@ -26,11 +26,6 @@
|
||||
* Common video utils
|
||||
*/
|
||||
|
||||
Return<android::hardware::media::omx::V1_0::Status> setVideoPortFormat(
|
||||
sp<IOmxNode> omxNode, OMX_U32 portIndex,
|
||||
OMX_VIDEO_CODINGTYPE eCompressionFormat, OMX_COLOR_FORMATTYPE eColorFormat,
|
||||
OMX_U32 xFramerate);
|
||||
|
||||
void enumerateProfileAndLevel(sp<IOmxNode> omxNode, OMX_U32 portIndex,
|
||||
std::vector<int32_t>* arrProfile,
|
||||
std::vector<int32_t>* arrLevel);
|
||||
|
||||
Reference in New Issue
Block a user