summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRam Mohan M2017-08-09 01:41:23 -0500
committerKeun Soo Yim2018-01-23 16:22:12 -0600
commit9a18ceb557110ce33e5b4662dcf4a8aab5fa23d3 (patch)
tree5798092f4912c426cdfaff8917ccda9710f6e1b0 /media/omx/1.0
parent7409a9312d9f6002ae64bc24e6ced988dbb7838a (diff)
downloadplatform-hardware-interfaces-9a18ceb557110ce33e5b4662dcf4a8aab5fa23d3.tar.gz
platform-hardware-interfaces-9a18ceb557110ce33e5b4662dcf4a8aab5fa23d3.tar.xz
platform-hardware-interfaces-9a18ceb557110ce33e5b4662dcf4a8aab5fa23d3.zip
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 9ce313a7b3d6dba0fb1b2fa1888fcb4824a022c8)
Diffstat (limited to 'media/omx/1.0')
-rw-r--r--media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.cpp41
-rw-r--r--media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.h3
-rwxr-xr-xmedia/omx/1.0/vts/functional/common/media_hidl_test_common.cpp126
-rw-r--r--media/omx/1.0/vts/functional/common/media_hidl_test_common.h19
-rw-r--r--media/omx/1.0/vts/functional/component/VtsHalMediaOmxV1_0TargetComponentTest.cpp107
-rw-r--r--media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp52
-rw-r--r--media/omx/1.0/vts/functional/video/media_video_hidl_test_common.cpp62
-rw-r--r--media/omx/1.0/vts/functional/video/media_video_hidl_test_common.h5
8 files changed, 193 insertions, 222 deletions
diff --git a/media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.cpp b/media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.cpp
index 7240964e..4c68219b 100644
--- a/media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.cpp
+++ b/media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.cpp
@@ -46,47 +46,6 @@ using ::android::sp;
46#include <media_hidl_test_common.h> 46#include <media_hidl_test_common.h>
47#include <memory> 47#include <memory>
48 48
49Return<android::hardware::media::omx::V1_0::Status> setAudioPortFormat(
50 sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE eEncoding) {
51 OMX_U32 index = 0;
52 OMX_AUDIO_PARAM_PORTFORMATTYPE portFormat;
53 std::vector<OMX_AUDIO_CODINGTYPE> arrEncoding;
54 android::hardware::media::omx::V1_0::Status status;
55
56 while (1) {
57 portFormat.nIndex = index;
58 status = getPortParam(omxNode, OMX_IndexParamAudioPortFormat, portIndex,
59 &portFormat);
60 if (status != ::android::hardware::media::omx::V1_0::Status::OK) break;
61 arrEncoding.push_back(portFormat.eEncoding);
62 index++;
63 if (index == 512) {
64 // enumerated way too many formats, highly unusual for this to
65 // happen.
66 EXPECT_LE(index, 512U)
67 << "Expecting OMX_ErrorNoMore but not received";
68 break;
69 }
70 }
71 if (!index) return status;
72 for (index = 0; index < arrEncoding.size(); index++) {
73 if (arrEncoding[index] == eEncoding) {
74 portFormat.eEncoding = arrEncoding[index];
75 break;
76 }
77 }
78 if (index == arrEncoding.size()) {
79 ALOGE("setting default Port format %x", (int)arrEncoding[0]);
80 portFormat.eEncoding = arrEncoding[0];
81 }
82 // In setParam call nIndex shall be ignored as per omx-il specification.
83 // see how this holds up by corrupting nIndex
84 portFormat.nIndex = RANDOM_INDEX;
85 status = setPortParam(omxNode, OMX_IndexParamAudioPortFormat, portIndex,
86 &portFormat);
87 return status;
88}
89
90void enumerateProfile(sp<IOmxNode> omxNode, OMX_U32 portIndex, 49void enumerateProfile(sp<IOmxNode> omxNode, OMX_U32 portIndex,
91 std::vector<int32_t>* arrProfile) { 50 std::vector<int32_t>* arrProfile) {
92 android::hardware::media::omx::V1_0::Status status; 51 android::hardware::media::omx::V1_0::Status status;
diff --git a/media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.h b/media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.h
index 70142f2b..08b3d9cd 100644
--- a/media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.h
+++ b/media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.h
@@ -27,9 +27,6 @@
27/* 27/*
28 * Common audio utils 28 * Common audio utils
29 */ 29 */
30Return<android::hardware::media::omx::V1_0::Status> setAudioPortFormat(
31 sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE eEncoding);
32
33void enumerateProfile(sp<IOmxNode> omxNode, OMX_U32 portIndex, 30void enumerateProfile(sp<IOmxNode> omxNode, OMX_U32 portIndex,
34 std::vector<int32_t>* arrProfile); 31 std::vector<int32_t>* arrProfile);
35 32
diff --git a/media/omx/1.0/vts/functional/common/media_hidl_test_common.cpp b/media/omx/1.0/vts/functional/common/media_hidl_test_common.cpp
index 700d2f31..1f67e2b6 100755
--- a/media/omx/1.0/vts/functional/common/media_hidl_test_common.cpp
+++ b/media/omx/1.0/vts/functional/common/media_hidl_test_common.cpp
@@ -60,6 +60,132 @@ Return<android::hardware::media::omx::V1_0::Status> setRole(
60 return setParam(omxNode, OMX_IndexParamStandardComponentRole, &params); 60 return setParam(omxNode, OMX_IndexParamStandardComponentRole, &params);
61} 61}
62 62
63Return<android::hardware::media::omx::V1_0::Status> setPortBufferSize(
64 sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_U32 size) {
65 android::hardware::media::omx::V1_0::Status status;
66 OMX_PARAM_PORTDEFINITIONTYPE portDef;
67
68 status = getPortParam(omxNode, OMX_IndexParamPortDefinition, portIndex,
69 &portDef);
70 if (status != ::android::hardware::media::omx::V1_0::Status::OK)
71 return status;
72 if (portDef.nBufferSize < size) {
73 portDef.nBufferSize = size;
74 status = setPortParam(omxNode, OMX_IndexParamPortDefinition, portIndex,
75 &portDef);
76 if (status != ::android::hardware::media::omx::V1_0::Status::OK)
77 return status;
78 }
79 return status;
80}
81
82// get/set video component port format
83Return<android::hardware::media::omx::V1_0::Status> setVideoPortFormat(
84 sp<IOmxNode> omxNode, OMX_U32 portIndex,
85 OMX_VIDEO_CODINGTYPE eCompressionFormat, OMX_COLOR_FORMATTYPE eColorFormat,
86 OMX_U32 xFramerate) {
87 OMX_U32 index = 0;
88 OMX_VIDEO_PARAM_PORTFORMATTYPE portFormat;
89 std::vector<OMX_COLOR_FORMATTYPE> arrColorFormat;
90 std::vector<OMX_VIDEO_CODINGTYPE> arrCompressionFormat;
91 android::hardware::media::omx::V1_0::Status status;
92
93 while (1) {
94 portFormat.nIndex = index;
95 status = getPortParam(omxNode, OMX_IndexParamVideoPortFormat, portIndex,
96 &portFormat);
97 if (status != ::android::hardware::media::omx::V1_0::Status::OK) break;
98 if (eCompressionFormat == OMX_VIDEO_CodingUnused)
99 arrColorFormat.push_back(portFormat.eColorFormat);
100 else
101 arrCompressionFormat.push_back(portFormat.eCompressionFormat);
102 index++;
103 if (index == 512) {
104 // enumerated way too many formats, highly unusual for this to
105 // happen.
106 EXPECT_LE(index, 512U)
107 << "Expecting OMX_ErrorNoMore but not received";
108 break;
109 }
110 }
111 if (!index) return status;
112 if (eCompressionFormat == OMX_VIDEO_CodingUnused) {
113 for (index = 0; index < arrColorFormat.size(); index++) {
114 if (arrColorFormat[index] == eColorFormat) {
115 portFormat.eColorFormat = arrColorFormat[index];
116 break;
117 }
118 }
119 if (index == arrColorFormat.size()) {
120 ALOGE("setting default color format %x", (int)arrColorFormat[0]);
121 portFormat.eColorFormat = arrColorFormat[0];
122 }
123 portFormat.eCompressionFormat = OMX_VIDEO_CodingUnused;
124 } else {
125 for (index = 0; index < arrCompressionFormat.size(); index++) {
126 if (arrCompressionFormat[index] == eCompressionFormat) {
127 portFormat.eCompressionFormat = arrCompressionFormat[index];
128 break;
129 }
130 }
131 if (index == arrCompressionFormat.size()) {
132 ALOGE("setting default compression format %x",
133 (int)arrCompressionFormat[0]);
134 portFormat.eCompressionFormat = arrCompressionFormat[0];
135 }
136 portFormat.eColorFormat = OMX_COLOR_FormatUnused;
137 }
138 // In setParam call nIndex shall be ignored as per omx-il specification.
139 // see how this holds up by corrupting nIndex
140 portFormat.nIndex = RANDOM_INDEX;
141 portFormat.xFramerate = xFramerate;
142 status = setPortParam(omxNode, OMX_IndexParamVideoPortFormat, portIndex,
143 &portFormat);
144 return status;
145}
146
147// get/set audio component port format
148Return<android::hardware::media::omx::V1_0::Status> setAudioPortFormat(
149 sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE eEncoding) {
150 OMX_U32 index = 0;
151 OMX_AUDIO_PARAM_PORTFORMATTYPE portFormat;
152 std::vector<OMX_AUDIO_CODINGTYPE> arrEncoding;
153 android::hardware::media::omx::V1_0::Status status;
154
155 while (1) {
156 portFormat.nIndex = index;
157 status = getPortParam(omxNode, OMX_IndexParamAudioPortFormat, portIndex,
158 &portFormat);
159 if (status != ::android::hardware::media::omx::V1_0::Status::OK) break;
160 arrEncoding.push_back(portFormat.eEncoding);
161 index++;
162 if (index == 512) {
163 // enumerated way too many formats, highly unusual for this to
164 // happen.
165 EXPECT_LE(index, 512U)
166 << "Expecting OMX_ErrorNoMore but not received";
167 break;
168 }
169 }
170 if (!index) return status;
171 for (index = 0; index < arrEncoding.size(); index++) {
172 if (arrEncoding[index] == eEncoding) {
173 portFormat.eEncoding = arrEncoding[index];
174 break;
175 }
176 }
177 if (index == arrEncoding.size()) {
178 ALOGE("setting default Port format %x", (int)arrEncoding[0]);
179 portFormat.eEncoding = arrEncoding[0];
180 }
181 // In setParam call nIndex shall be ignored as per omx-il specification.
182 // see how this holds up by corrupting nIndex
183 portFormat.nIndex = RANDOM_INDEX;
184 status = setPortParam(omxNode, OMX_IndexParamAudioPortFormat, portIndex,
185 &portFormat);
186 return status;
187}
188
63// allocate buffers needed on a component port 189// allocate buffers needed on a component port
64void allocatePortBuffers(sp<IOmxNode> omxNode, 190void allocatePortBuffers(sp<IOmxNode> omxNode,
65 android::Vector<BufferInfo>* buffArray, 191 android::Vector<BufferInfo>* buffArray,
diff --git a/media/omx/1.0/vts/functional/common/media_hidl_test_common.h b/media/omx/1.0/vts/functional/common/media_hidl_test_common.h
index 354b7a7e..0adea14e 100644
--- a/media/omx/1.0/vts/functional/common/media_hidl_test_common.h
+++ b/media/omx/1.0/vts/functional/common/media_hidl_test_common.h
@@ -36,6 +36,14 @@
36#define DEFAULT_TIMEOUT 100000 36#define DEFAULT_TIMEOUT 100000
37#define TIMEOUT_COUNTER (10000000 / DEFAULT_TIMEOUT) 37#define TIMEOUT_COUNTER (10000000 / DEFAULT_TIMEOUT)
38 38
39/*
40 * Random Index used for monkey testing while get/set parameters
41 */
42#define RANDOM_INDEX 1729
43
44#define ALIGN_POWER_OF_TWO(value, n) \
45 (((value) + ((1 << (n)) - 1)) & ~((1 << (n)) - 1))
46
39enum bufferOwner { 47enum bufferOwner {
40 client, 48 client,
41 component, 49 component,
@@ -265,6 +273,17 @@ Return<android::hardware::media::omx::V1_0::Status> setPortConfig(
265Return<android::hardware::media::omx::V1_0::Status> setRole( 273Return<android::hardware::media::omx::V1_0::Status> setRole(
266 sp<IOmxNode> omxNode, const char* role); 274 sp<IOmxNode> omxNode, const char* role);
267 275
276Return<android::hardware::media::omx::V1_0::Status> setPortBufferSize(
277 sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_U32 size);
278
279Return<android::hardware::media::omx::V1_0::Status> setVideoPortFormat(
280 sp<IOmxNode> omxNode, OMX_U32 portIndex,
281 OMX_VIDEO_CODINGTYPE eCompressionFormat, OMX_COLOR_FORMATTYPE eColorFormat,
282 OMX_U32 xFramerate);
283
284Return<android::hardware::media::omx::V1_0::Status> setAudioPortFormat(
285 sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE eEncoding);
286
268void allocatePortBuffers(sp<IOmxNode> omxNode, 287void allocatePortBuffers(sp<IOmxNode> omxNode,
269 android::Vector<BufferInfo>* buffArray, 288 android::Vector<BufferInfo>* buffArray,
270 OMX_U32 portIndex, 289 OMX_U32 portIndex,
diff --git a/media/omx/1.0/vts/functional/component/VtsHalMediaOmxV1_0TargetComponentTest.cpp b/media/omx/1.0/vts/functional/component/VtsHalMediaOmxV1_0TargetComponentTest.cpp
index 357c11e2..38860edc 100644
--- a/media/omx/1.0/vts/functional/component/VtsHalMediaOmxV1_0TargetComponentTest.cpp
+++ b/media/omx/1.0/vts/functional/component/VtsHalMediaOmxV1_0TargetComponentTest.cpp
@@ -225,113 +225,6 @@ void initPortMode(PortMode* pm, bool isSecure,
225 return; 225 return;
226} 226}
227 227
228// get/set video component port format
229Return<android::hardware::media::omx::V1_0::Status> setVideoPortFormat(
230 sp<IOmxNode> omxNode, OMX_U32 portIndex,
231 OMX_VIDEO_CODINGTYPE eCompressionFormat, OMX_COLOR_FORMATTYPE eColorFormat,
232 OMX_U32 xFramerate) {
233 OMX_U32 index = 0;
234 OMX_VIDEO_PARAM_PORTFORMATTYPE portFormat;
235 std::vector<OMX_COLOR_FORMATTYPE> arrColorFormat;
236 std::vector<OMX_VIDEO_CODINGTYPE> arrCompressionFormat;
237 android::hardware::media::omx::V1_0::Status status;
238
239 while (1) {
240 portFormat.nIndex = index;
241 status = getPortParam(omxNode, OMX_IndexParamVideoPortFormat, portIndex,
242 &portFormat);
243 if (status != ::android::hardware::media::omx::V1_0::Status::OK) break;
244 if (eCompressionFormat == OMX_VIDEO_CodingUnused)
245 arrColorFormat.push_back(portFormat.eColorFormat);
246 else
247 arrCompressionFormat.push_back(portFormat.eCompressionFormat);
248 index++;
249 if (index == 512) {
250 // enumerated way too many formats, highly unusual for this to
251 // happen.
252 EXPECT_LE(index, 512U)
253 << "Expecting OMX_ErrorNoMore but not received";
254 break;
255 }
256 }
257 if (!index) return status;
258 if (eCompressionFormat == OMX_VIDEO_CodingUnused) {
259 for (index = 0; index < arrColorFormat.size(); index++) {
260 if (arrColorFormat[index] == eColorFormat) {
261 portFormat.eColorFormat = arrColorFormat[index];
262 break;
263 }
264 }
265 if (index == arrColorFormat.size()) {
266 ALOGE("setting default color format %x", (int)arrColorFormat[0]);
267 portFormat.eColorFormat = arrColorFormat[0];
268 }
269 portFormat.eCompressionFormat = OMX_VIDEO_CodingUnused;
270 } else {
271 for (index = 0; index < arrCompressionFormat.size(); index++) {
272 if (arrCompressionFormat[index] == eCompressionFormat) {
273 portFormat.eCompressionFormat = arrCompressionFormat[index];
274 break;
275 }
276 }
277 if (index == arrCompressionFormat.size()) {
278 ALOGE("setting default compression format %x",
279 (int)arrCompressionFormat[0]);
280 portFormat.eCompressionFormat = arrCompressionFormat[0];
281 }
282 portFormat.eColorFormat = OMX_COLOR_FormatUnused;
283 }
284 // In setParam call nIndex shall be ignored as per omx-il specification.
285 // see how this holds up by corrupting nIndex
286 portFormat.nIndex = RANDOM_INDEX;
287 portFormat.xFramerate = xFramerate;
288 status = setPortParam(omxNode, OMX_IndexParamVideoPortFormat, portIndex,
289 &portFormat);
290 return status;
291}
292
293// get/set audio component port format
294Return<android::hardware::media::omx::V1_0::Status> setAudioPortFormat(
295 sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE eEncoding) {
296 OMX_U32 index = 0;
297 OMX_AUDIO_PARAM_PORTFORMATTYPE portFormat;
298 std::vector<OMX_AUDIO_CODINGTYPE> arrEncoding;
299 android::hardware::media::omx::V1_0::Status status;
300
301 while (1) {
302 portFormat.nIndex = index;
303 status = getPortParam(omxNode, OMX_IndexParamAudioPortFormat, portIndex,
304 &portFormat);
305 if (status != ::android::hardware::media::omx::V1_0::Status::OK) break;
306 arrEncoding.push_back(portFormat.eEncoding);
307 index++;
308 if (index == 512) {
309 // enumerated way too many formats, highly unusual for this to
310 // happen.
311 EXPECT_LE(index, 512U)
312 << "Expecting OMX_ErrorNoMore but not received";
313 break;
314 }
315 }
316 if (!index) return status;
317 for (index = 0; index < arrEncoding.size(); index++) {
318 if (arrEncoding[index] == eEncoding) {
319 portFormat.eEncoding = arrEncoding[index];
320 break;
321 }
322 }
323 if (index == arrEncoding.size()) {
324 ALOGE("setting default Port format %x", (int)arrEncoding[0]);
325 portFormat.eEncoding = arrEncoding[0];
326 }
327 // In setParam call nIndex shall be ignored as per omx-il specification.
328 // see how this holds up by corrupting nIndex
329 portFormat.nIndex = RANDOM_INDEX;
330 status = setPortParam(omxNode, OMX_IndexParamAudioPortFormat, portIndex,
331 &portFormat);
332 return status;
333}
334
335// test dispatch message API call 228// test dispatch message API call
336TEST_F(ComponentHidlTest, dispatchMsg) { 229TEST_F(ComponentHidlTest, dispatchMsg) {
337 description("test dispatch message API call"); 230 description("test dispatch message API call");
diff --git a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp
index 9773cb00..f13d88c1 100644
--- a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp
+++ b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp
@@ -768,7 +768,7 @@ TEST_F(VideoDecHidlTest, DecodeTest) {
768 eleInfo.open(info); 768 eleInfo.open(info);
769 ASSERT_EQ(eleInfo.is_open(), true); 769 ASSERT_EQ(eleInfo.is_open(), true);
770 android::Vector<FrameData> Info; 770 android::Vector<FrameData> Info;
771 int bytesCount = 0; 771 int bytesCount = 0, maxBytesCount = 0;
772 uint32_t flags = 0; 772 uint32_t flags = 0;
773 uint32_t timestamp = 0; 773 uint32_t timestamp = 0;
774 timestampDevTest = true; 774 timestampDevTest = true;
@@ -779,9 +779,15 @@ TEST_F(VideoDecHidlTest, DecodeTest) {
779 Info.push_back({bytesCount, flags, timestamp}); 779 Info.push_back({bytesCount, flags, timestamp});
780 if (flags != OMX_BUFFERFLAG_CODECCONFIG) 780 if (flags != OMX_BUFFERFLAG_CODECCONFIG)
781 timestampUslist.push_back(timestamp); 781 timestampUslist.push_back(timestamp);
782 if (maxBytesCount < bytesCount) maxBytesCount = bytesCount;
782 } 783 }
783 eleInfo.close(); 784 eleInfo.close();
784 785
786 // As the frame sizes are known ahead, use it to configure i/p buffer size
787 maxBytesCount = ALIGN_POWER_OF_TWO(maxBytesCount, 10);
788 status = setPortBufferSize(omxNode, kPortIndexInput, maxBytesCount);
789 ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
790
785 // set port mode 791 // set port mode
786 portMode[0] = PortMode::PRESET_BYTE_BUFFER; 792 portMode[0] = PortMode::PRESET_BYTE_BUFFER;
787 portMode[1] = PortMode::DYNAMIC_ANW_BUFFER; 793 portMode[1] = PortMode::DYNAMIC_ANW_BUFFER;
@@ -801,6 +807,8 @@ TEST_F(VideoDecHidlTest, DecodeTest) {
801 &xFramerate); 807 &xFramerate);
802 setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, 808 setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused,
803 eColorFormat, nFrameWidth, nFrameHeight, 0, xFramerate); 809 eColorFormat, nFrameWidth, nFrameHeight, 0, xFramerate);
810
811 // disabling adaptive playback.
804 omxNode->prepareForAdaptivePlayback(kPortIndexOutput, false, 1920, 1080); 812 omxNode->prepareForAdaptivePlayback(kPortIndexOutput, false, 1920, 1080);
805 813
806 android::Vector<BufferInfo> iBuffer, oBuffer; 814 android::Vector<BufferInfo> iBuffer, oBuffer;
@@ -923,7 +931,7 @@ TEST_F(VideoDecHidlTest, ThumbnailTest) {
923 eleInfo.open(info); 931 eleInfo.open(info);
924 ASSERT_EQ(eleInfo.is_open(), true); 932 ASSERT_EQ(eleInfo.is_open(), true);
925 android::Vector<FrameData> Info; 933 android::Vector<FrameData> Info;
926 int bytesCount = 0; 934 int bytesCount = 0, maxBytesCount = 0;
927 uint32_t flags = 0; 935 uint32_t flags = 0;
928 uint32_t timestamp = 0; 936 uint32_t timestamp = 0;
929 while (1) { 937 while (1) {
@@ -931,9 +939,21 @@ TEST_F(VideoDecHidlTest, ThumbnailTest) {
931 eleInfo >> flags; 939 eleInfo >> flags;
932 eleInfo >> timestamp; 940 eleInfo >> timestamp;
933 Info.push_back({bytesCount, flags, timestamp}); 941 Info.push_back({bytesCount, flags, timestamp});
942 if (maxBytesCount < bytesCount) maxBytesCount = bytesCount;
934 } 943 }
935 eleInfo.close(); 944 eleInfo.close();
936 945
946 // As the frame sizes are known ahead, use it to configure i/p buffer size
947 maxBytesCount = ALIGN_POWER_OF_TWO(maxBytesCount, 10);
948 status = setPortBufferSize(omxNode, kPortIndexInput, maxBytesCount);
949 ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
950
951 // set port mode
952 status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
953 ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
954 status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
955 ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
956
937 // set Port Params 957 // set Port Params
938 uint32_t nFrameWidth, nFrameHeight, xFramerate; 958 uint32_t nFrameWidth, nFrameHeight, xFramerate;
939 OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatYUV420Planar; 959 OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatYUV420Planar;
@@ -1024,7 +1044,7 @@ TEST_F(VideoDecHidlTest, SimpleEOSTest) {
1024 eleInfo.open(info); 1044 eleInfo.open(info);
1025 ASSERT_EQ(eleInfo.is_open(), true); 1045 ASSERT_EQ(eleInfo.is_open(), true);
1026 android::Vector<FrameData> Info; 1046 android::Vector<FrameData> Info;
1027 int bytesCount = 0; 1047 int bytesCount = 0, maxBytesCount = 0;
1028 uint32_t flags = 0; 1048 uint32_t flags = 0;
1029 uint32_t timestamp = 0; 1049 uint32_t timestamp = 0;
1030 while (1) { 1050 while (1) {
@@ -1032,9 +1052,21 @@ TEST_F(VideoDecHidlTest, SimpleEOSTest) {
1032 eleInfo >> flags; 1052 eleInfo >> flags;
1033 eleInfo >> timestamp; 1053 eleInfo >> timestamp;
1034 Info.push_back({bytesCount, flags, timestamp}); 1054 Info.push_back({bytesCount, flags, timestamp});
1055 if (maxBytesCount < bytesCount) maxBytesCount = bytesCount;
1035 } 1056 }
1036 eleInfo.close(); 1057 eleInfo.close();
1037 1058
1059 // As the frame sizes are known ahead, use it to configure i/p buffer size
1060 maxBytesCount = ALIGN_POWER_OF_TWO(maxBytesCount, 10);
1061 status = setPortBufferSize(omxNode, kPortIndexInput, maxBytesCount);
1062 ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
1063
1064 // set port mode
1065 status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
1066 ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
1067 status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
1068 ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
1069
1038 // set Port Params 1070 // set Port Params
1039 uint32_t nFrameWidth, nFrameHeight, xFramerate; 1071 uint32_t nFrameWidth, nFrameHeight, xFramerate;
1040 OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatYUV420Planar; 1072 OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatYUV420Planar;
@@ -1107,7 +1139,7 @@ TEST_F(VideoDecHidlTest, FlushTest) {
1107 eleInfo.open(info); 1139 eleInfo.open(info);
1108 ASSERT_EQ(eleInfo.is_open(), true); 1140 ASSERT_EQ(eleInfo.is_open(), true);
1109 android::Vector<FrameData> Info; 1141 android::Vector<FrameData> Info;
1110 int bytesCount = 0; 1142 int bytesCount = 0, maxBytesCount = 0;
1111 uint32_t flags = 0; 1143 uint32_t flags = 0;
1112 uint32_t timestamp = 0; 1144 uint32_t timestamp = 0;
1113 while (1) { 1145 while (1) {
@@ -1115,9 +1147,21 @@ TEST_F(VideoDecHidlTest, FlushTest) {
1115 eleInfo >> flags; 1147 eleInfo >> flags;
1116 eleInfo >> timestamp; 1148 eleInfo >> timestamp;
1117 Info.push_back({bytesCount, flags, timestamp}); 1149 Info.push_back({bytesCount, flags, timestamp});
1150 if (maxBytesCount < bytesCount) maxBytesCount = bytesCount;
1118 } 1151 }
1119 eleInfo.close(); 1152 eleInfo.close();
1120 1153
1154 // As the frame sizes are known ahead, use it to configure i/p buffer size
1155 maxBytesCount = ALIGN_POWER_OF_TWO(maxBytesCount, 10);
1156 status = setPortBufferSize(omxNode, kPortIndexInput, maxBytesCount);
1157 ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
1158
1159 // set port mode
1160 status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
1161 ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
1162 status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
1163 ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
1164
1121 // set Port Params 1165 // set Port Params
1122 uint32_t nFrameWidth, nFrameHeight, xFramerate; 1166 uint32_t nFrameWidth, nFrameHeight, xFramerate;
1123 OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatYUV420Planar; 1167 OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatYUV420Planar;
diff --git a/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.cpp b/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.cpp
index 77763d17..91aecf22 100644
--- a/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.cpp
+++ b/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.cpp
@@ -52,68 +52,6 @@ using ::android::sp;
52#include <media_video_hidl_test_common.h> 52#include <media_video_hidl_test_common.h>
53#include <memory> 53#include <memory>
54 54
55Return<android::hardware::media::omx::V1_0::Status> setVideoPortFormat(
56 sp<IOmxNode> omxNode, OMX_U32 portIndex,
57 OMX_VIDEO_CODINGTYPE eCompressionFormat, OMX_COLOR_FORMATTYPE eColorFormat,
58 OMX_U32 xFramerate) {
59 OMX_U32 index = 0;
60 OMX_VIDEO_PARAM_PORTFORMATTYPE portFormat;
61 std::vector<OMX_COLOR_FORMATTYPE> arrColorFormat;
62 std::vector<OMX_VIDEO_CODINGTYPE> arrCompressionFormat;
63 android::hardware::media::omx::V1_0::Status status;
64
65 while (1) {
66 portFormat.nIndex = index;
67 status = getPortParam(omxNode, OMX_IndexParamVideoPortFormat, portIndex,
68 &portFormat);
69 if (status != ::android::hardware::media::omx::V1_0::Status::OK) break;
70 if (eCompressionFormat == OMX_VIDEO_CodingUnused)
71 arrColorFormat.push_back(portFormat.eColorFormat);
72 else
73 arrCompressionFormat.push_back(portFormat.eCompressionFormat);
74 index++;
75 if (index == 512) {
76 // enumerated way too many formats, highly unusual for this to
77 // happen.
78 EXPECT_LE(index, 512U)
79 << "Expecting OMX_ErrorNoMore but not received";
80 break;
81 }
82 }
83 if (!index) return status;
84 if (eCompressionFormat == OMX_VIDEO_CodingUnused) {
85 for (index = 0; index < arrColorFormat.size(); index++) {
86 if (arrColorFormat[index] == eColorFormat) {
87 portFormat.eColorFormat = arrColorFormat[index];
88 break;
89 }
90 }
91 if (index == arrColorFormat.size()) {
92 ALOGE("setting default color format %x", (int)arrColorFormat[0]);
93 portFormat.eColorFormat = arrColorFormat[0];
94 }
95 portFormat.eCompressionFormat = OMX_VIDEO_CodingUnused;
96 } else {
97 for (index = 0; index < arrCompressionFormat.size(); index++) {
98 if (arrCompressionFormat[index] == eCompressionFormat) {
99 portFormat.eCompressionFormat = arrCompressionFormat[index];
100 break;
101 }
102 }
103 if (index == arrCompressionFormat.size()) {
104 ALOGE("setting default compression format %x",
105 (int)arrCompressionFormat[0]);
106 portFormat.eCompressionFormat = arrCompressionFormat[0];
107 }
108 portFormat.eColorFormat = OMX_COLOR_FormatUnused;
109 }
110 portFormat.nIndex = 0;
111 portFormat.xFramerate = xFramerate;
112 status = setPortParam(omxNode, OMX_IndexParamVideoPortFormat, portIndex,
113 &portFormat);
114 return status;
115}
116
117void enumerateProfileAndLevel(sp<IOmxNode> omxNode, OMX_U32 portIndex, 55void enumerateProfileAndLevel(sp<IOmxNode> omxNode, OMX_U32 portIndex,
118 std::vector<int32_t>* arrProfile, 56 std::vector<int32_t>* arrProfile,
119 std::vector<int32_t>* arrLevel) { 57 std::vector<int32_t>* arrLevel) {
diff --git a/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.h b/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.h
index e4927792..c1d7aeae 100644
--- a/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.h
+++ b/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.h
@@ -26,11 +26,6 @@
26 * Common video utils 26 * Common video utils
27 */ 27 */
28 28
29Return<android::hardware::media::omx::V1_0::Status> setVideoPortFormat(
30 sp<IOmxNode> omxNode, OMX_U32 portIndex,
31 OMX_VIDEO_CODINGTYPE eCompressionFormat, OMX_COLOR_FORMATTYPE eColorFormat,
32 OMX_U32 xFramerate);
33
34void enumerateProfileAndLevel(sp<IOmxNode> omxNode, OMX_U32 portIndex, 29void enumerateProfileAndLevel(sp<IOmxNode> omxNode, OMX_U32 portIndex,
35 std::vector<int32_t>* arrProfile, 30 std::vector<int32_t>* arrProfile,
36 std::vector<int32_t>* arrLevel); 31 std::vector<int32_t>* arrLevel);