From bcf858bb7b346769ee1a55f2e3a282e4e7e60302 Mon Sep 17 00:00:00 2001 From: zhangguorong Date: Thu, 9 Mar 2023 16:21:11 +0800 Subject: [PATCH] feat: support 4 pixel format Signed-off-by: zhangguorong --- .../hdi_adapter/codec_hdi_adapter_test.cpp | 32 ++++++++++-- hdf/codec/hdi_v1.0/codec_proxy_test.cpp | 50 ++++++++++++++++--- 2 files changed, 71 insertions(+), 11 deletions(-) diff --git a/hdf/codec/hdi_adapter/codec_hdi_adapter_test.cpp b/hdf/codec/hdi_adapter/codec_hdi_adapter_test.cpp index f3ea6996..9ac054b2 100644 --- a/hdf/codec/hdi_adapter/codec_hdi_adapter_test.cpp +++ b/hdf/codec/hdi_adapter/codec_hdi_adapter_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -48,6 +48,9 @@ constexpr int32_t INT_TO_STR_LEN = 32; constexpr int32_t ARRAY_TO_STR_LEN = 1000; union OMX_VERSIONTYPE g_version; +constexpr int32_t FRAME_RATE = 24; +constexpr int32_t VIDEO_WIDHT = 640; +constexpr int32_t VIDEO_HEIGHT = 480; constexpr int32_t BUFFER_SIZE = (640 * 480 * 3); constexpr int32_t ROLE_LEN = 240; constexpr int32_t FRAMERATE = (30 << 16); @@ -448,15 +451,38 @@ HWTEST_F(CodecHdiAdapterTest, SUB_DriverSystem_CodecHdi_adapter_0140, Function | ASSERT_NE(ret, HDF_SUCCESS); } /** -* @tc.name HdfCodecHdiSetParameterSuccessTest_001 +* @tc.name HdfCodecHdiSetPortDefineSuccessTest_001 * @tc.number SUB_DriverSystem_CodecHdi_adapter_0150 +* @tc.desc Invoke the GetParameter interface to obtain component parameters, +* then invoke SetParameter interface to set back the modified component parameters +*/ +HWTEST_F(CodecHdiAdapterTest, HdfCodecHdiSetPortDefineSuccessTest_0150, TestSize.Level1) +{ + ASSERT_TRUE(g_component != nullptr); + OMX_PARAM_PORTDEFINITIONTYPE param; + InitParam(param); + param.nPortIndex = (uint32_t)PortIndex::PORT_INDEX_INPUT; + int32_t ret = g_component->GetParameter(g_component, OMX_IndexParamPortDefinition, + reinterpret_cast(¶m), sizeof(param)); + ASSERT_EQ(ret, HDF_SUCCESS); + + param.format.video.nFrameWidth = VIDEO_WIDHT; + param.format.video.nFrameHeight = VIDEO_HEIGHT; + ret = g_component->SetParameter(g_component, OMX_IndexParamPortDefinition, + reinterpret_cast(¶m), sizeof(param)); + ASSERT_EQ(ret, HDF_SUCCESS); +} +/** +* @tc.name HdfCodecHdiSetParameterSuccessTest_001 +* @tc.number SUB_DriverSystem_CodecHdi_adapter_0151 * @tc.desc The SetParameter interface is invoked to set component parameters */ -HWTEST_F(CodecHdiAdapterTest, SUB_DriverSystem_CodecHdi_adapter_0150, Function | MediumTest | Level3) +HWTEST_F(CodecHdiAdapterTest, SUB_DriverSystem_CodecHdi_adapter_0151, Function | MediumTest | Level3) { ASSERT_TRUE(g_component != nullptr); OMX_VIDEO_PARAM_PORTFORMATTYPE param; InitParam(param); + param.xFramerate = FRAME_RATE; param.nPortIndex = (uint32_t)PortIndex::PORT_INDEX_INPUT; int32_t ret = g_component->SetParameter(g_component, OMX_IndexParamVideoPortFormat, reinterpret_cast(¶m), sizeof(param)); diff --git a/hdf/codec/hdi_v1.0/codec_proxy_test.cpp b/hdf/codec/hdi_v1.0/codec_proxy_test.cpp index cef3e99d..812e4ba1 100644 --- a/hdf/codec/hdi_v1.0/codec_proxy_test.cpp +++ b/hdf/codec/hdi_v1.0/codec_proxy_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -31,11 +31,13 @@ using namespace testing::ext; namespace { constexpr const char *TEST_SERVICE_NAME = "codec_hdi_service"; constexpr const int TEST_PACKET_BUFFER_SIZE = 4096; -constexpr const int TEST_FRAME_BUFFER_SIZE = 640 * 480 * 3 / 2; +constexpr const int TEST_FRAME_BUFFER_SIZE = (640 * 480 * 3 / 2); constexpr const uint32_t QUEUE_TIME_OUT = 10; constexpr const int CAPABILITY_COUNT = 9; constexpr int32_t INT_TO_STR_LEN = 32; constexpr int32_t ARRAY_TO_STR_LEN = 1000; +constexpr int32_t VIDEO_WIDHT = 640; +constexpr int32_t VIDEO_HEIGHT = 480; struct ICodec *g_codecObj = nullptr; ShareMemory g_inputBuffer; ShareMemory g_outputBuffer; @@ -258,10 +260,10 @@ HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0130, TestSize.Level1) int paramCnt = 1; params = (Param *)OsalMemAlloc(sizeof(Param)*paramCnt); ASSERT_TRUE(params != nullptr); - params->key = KEY_CODEC_TYPE; - CodecType ct = VIDEO_DECODER; - params->val = (void *)&ct; - params->size = sizeof(ct); + params->key = KEY_VIDEO_WIDTH; + int32_t width = VIDEO_WIDHT; + params->val = (void *)&width; + params->size = sizeof(width); int32_t errorCode = g_codecObj->CodecSetParameter(g_codecObj, g_handle, params, paramCnt); OsalMemFree(params); @@ -269,6 +271,38 @@ HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0130, TestSize.Level1) } HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0131, TestSize.Level1) +{ + Param *params; + int paramCnt = 1; + params = (Param *)OsalMemAlloc(sizeof(Param)*paramCnt); + ASSERT_TRUE(params != nullptr); + params->key = KEY_VIDEO_HEIGHT; + int32_t height = VIDEO_HEIGHT; + params->val = (void *)&height; + params->size = sizeof(height); + + int32_t errorCode = g_codecObj->CodecSetParameter(g_codecObj, g_handle, params, paramCnt); + OsalMemFree(params); + ASSERT_EQ(errorCode, HDF_SUCCESS); +} + +HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0132, TestSize.Level1) +{ + Param *params; + int paramCnt = 1; + params = (Param *)OsalMemAlloc(sizeof(Param)*paramCnt); + ASSERT_TRUE(params != nullptr); + params->key = KEY_CODEC_TYPE; + CodecType type = VIDEO_DECODER; + params->val = (void *)&type; + params->size = sizeof(type); + + int32_t errorCode = g_codecObj->CodecSetParameter(g_codecObj, g_handle, params, paramCnt); + OsalMemFree(params); + ASSERT_EQ(errorCode, HDF_SUCCESS); +} + +HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0133, TestSize.Level1) { Param *params; int paramCnt = 1; @@ -288,7 +322,7 @@ HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0131, TestSize.Level1) ASSERT_EQ(errorCode, HDF_SUCCESS); } -HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0132, TestSize.Level1) +HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0134, TestSize.Level1) { Param *params; int paramCnt = 1; @@ -304,7 +338,7 @@ HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0132, TestSize.Level1) ASSERT_EQ(errorCode, HDF_SUCCESS); } -HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0133, TestSize.Level1) +HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0135, TestSize.Level1) { Param *params; int paramCnt = 1;