mirror of
https://gitee.com/openharmony/xts_hats
synced 2025-03-03 16:08:08 +00:00
update codec omx tests
Signed-off-by: wwx1010008 <wangqian214@huawei.com> Change-Id: Ia70934221521c980258aaba4473f567056a16bbb
This commit is contained in:
parent
9ad84fe892
commit
75ff82203b
@ -48,6 +48,8 @@ constexpr int32_t ROLE_LEN = 240;
|
||||
constexpr int32_t BUFFER_SIZE = WIDTH * HEIGHT * 3;
|
||||
constexpr int32_t FRAMERATE = 30 << 16;
|
||||
constexpr uint32_t BUFFER_ID_ERROR = 65000;
|
||||
constexpr uint32_t WAIT_TIME = 1000;
|
||||
constexpr uint32_t MAX_WAIT = 50;
|
||||
static IDisplayBuffer *gralloc_ = nullptr;
|
||||
|
||||
static void InitCodecBuffer(OmxCodecBuffer& buffer, CodecBufferType type, OMX_VERSIONTYPE& version)
|
||||
@ -181,6 +183,39 @@ public:
|
||||
buffer.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
void waitState(OMX_STATETYPE objState)
|
||||
{
|
||||
OMX_STATETYPE state = OMX_StateInvalid;
|
||||
uint32_t count = 0;
|
||||
do {
|
||||
usleep(WAIT_TIME);
|
||||
auto ret = component_->GetState(component_, &state);
|
||||
ASSERT_EQ(ret, HDF_SUCCESS);
|
||||
count++;
|
||||
} while (state != objState && count <= MAX_WAIT);
|
||||
}
|
||||
|
||||
void InitBufferHandle(std::shared_ptr<OmxCodecBuffer> &omxBuffer, BufferHandle **bufferHandle)
|
||||
{
|
||||
ASSERT_TRUE(gralloc_ != nullptr);
|
||||
AllocInfo alloc = {.width = WIDTH,
|
||||
.height = HEIGHT,
|
||||
.usage = HBM_USE_CPU_READ | HBM_USE_CPU_WRITE | HBM_USE_MEM_DMA,
|
||||
.format = PIXEL_FMT_YCBCR_420_SP};
|
||||
|
||||
auto err = gralloc_->AllocMem(alloc, *bufferHandle);
|
||||
ASSERT_EQ(err, DISPLAY_SUCCESS);
|
||||
|
||||
omxBuffer->size = static_cast<uint32_t>(sizeof(OmxCodecBuffer));
|
||||
omxBuffer->version = version_;
|
||||
omxBuffer->bufferLen = static_cast<uint32_t>(sizeof(BufferHandle));
|
||||
omxBuffer->buffer = reinterpret_cast<uint8_t *>(*bufferHandle);
|
||||
omxBuffer->allocLen = static_cast<uint32_t>(sizeof(BufferHandle));
|
||||
omxBuffer->fenceFd = -1;
|
||||
omxBuffer->pts = 0;
|
||||
omxBuffer->flag = 0;
|
||||
}
|
||||
static void SetUpTestCase()
|
||||
{
|
||||
manager_ = GetCodecComponentManager();
|
||||
@ -865,25 +900,12 @@ HWTEST_F(CodecHdiOmxTest, SUB_DriverSystem_CodecHdi_V2_0490, Function | MediumTe
|
||||
ASSERT_TRUE(component_ != nullptr);
|
||||
auto err = component_->SendCommand(component_, OMX_CommandStateSet, OMX_StateIdle, NULL, 0);
|
||||
ASSERT_EQ(err, HDF_SUCCESS);
|
||||
AllocInfo alloc = {.width = WIDTH,
|
||||
.height = HEIGHT,
|
||||
.usage = HBM_USE_CPU_READ | HBM_USE_CPU_WRITE | HBM_USE_MEM_DMA,
|
||||
.format = PIXEL_FMT_YCBCR_420_SP};
|
||||
ASSERT_TRUE(gralloc_ != nullptr);
|
||||
BufferHandle *bufferHandle = nullptr;
|
||||
err = gralloc_->AllocMem(alloc, bufferHandle);
|
||||
ASSERT_EQ(err, DISPLAY_SUCCESS);
|
||||
|
||||
std::shared_ptr<OmxCodecBuffer> omxBuffer = std::make_shared<OmxCodecBuffer>();
|
||||
ASSERT_TRUE(omxBuffer != nullptr);
|
||||
omxBuffer->size = sizeof(OmxCodecBuffer);
|
||||
omxBuffer->version = version_;
|
||||
BufferHandle *bufferHandle = nullptr;
|
||||
InitBufferHandle(omxBuffer, &bufferHandle);
|
||||
omxBuffer->bufferType = CODEC_BUFFER_TYPE_HANDLE;
|
||||
omxBuffer->bufferLen = sizeof(BufferHandle);
|
||||
omxBuffer->buffer = reinterpret_cast<uint8_t *>(bufferHandle);
|
||||
omxBuffer->allocLen = sizeof(BufferHandle);
|
||||
omxBuffer->fenceFd = -1;
|
||||
omxBuffer->pts = 0;
|
||||
omxBuffer->flag = 0;
|
||||
|
||||
err = component_->UseBuffer(component_, (uint32_t)PortIndex::PORT_INDEX_INPUT, omxBuffer.get());
|
||||
if (err != HDF_SUCCESS) {
|
||||
@ -1028,6 +1050,23 @@ HWTEST_F(CodecHdiOmxTest, SUB_DriverSystem_CodecHdi_V2_0550, Function | MediumTe
|
||||
ASSERT_EQ(err, HDF_SUCCESS);
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* @tc.name HdfCodecHdiUseBufferTest_011
|
||||
* @tc.number SUB_DriverSystem_CodecHdi_V2_0551
|
||||
* @tc.desc The output buffer is full
|
||||
*/
|
||||
HWTEST_F(CodecHdiOmxTest, SUB_DriverSystem_CodecHdi_V2_0551, TestSize.Level1)
|
||||
{
|
||||
ASSERT_TRUE(component_ != nullptr);
|
||||
std::shared_ptr<OmxCodecBuffer> omxBuffer = std::make_shared<OmxCodecBuffer>();
|
||||
ASSERT_TRUE(omxBuffer != nullptr);
|
||||
BufferHandle *bufferHandle = nullptr;
|
||||
InitBufferHandle(omxBuffer, &bufferHandle);
|
||||
omxBuffer->bufferType = CODEC_BUFFER_TYPE_INVALID;
|
||||
auto err = component_->UseBuffer(component_, static_cast<uint32_t>(PortIndex::PORT_INDEX_INPUT), omxBuffer.get());
|
||||
ASSERT_NE(err, HDF_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name HdfCodecHdiUseEglImageTest_001
|
||||
* @tc.number SUB_DriverSystem_CodecHdi_V2_0560
|
||||
@ -1053,9 +1092,8 @@ HWTEST_F(CodecHdiOmxTest, SUB_DriverSystem_CodecHdi_V2_0560, Function | MediumTe
|
||||
ASSERT_NE(ret, HDF_SUCCESS);
|
||||
eglImage = nullptr;
|
||||
}
|
||||
#ifndef SUPPORT_OMX
|
||||
/**
|
||||
* @tc.name HdfCodecHdiFillThisBufferTest_001
|
||||
* @tc.name HdfCodecHdiBufferFillAndEmptyTest_001
|
||||
* @tc.number SUB_DriverSystem_CodecHdi_V2_0580
|
||||
* @tc.desc FillThisBuffer test
|
||||
*/
|
||||
@ -1079,14 +1117,7 @@ HWTEST_F(CodecHdiOmxTest, SUB_DriverSystem_CodecHdi_V2_0580, Function | MediumTe
|
||||
ret = UseBufferOnPort(PortIndex::PORT_INDEX_OUTPUT, param.nBufferCountActual, param.nBufferSize);
|
||||
ASSERT_TRUE(ret);
|
||||
err = component_->SendCommand(component_, OMX_CommandStateSet, OMX_StateExecuting, NULL, 0);
|
||||
|
||||
OMX_STATETYPE state = OMX_StateInvalid;
|
||||
do {
|
||||
usleep(10);
|
||||
auto ret = component_->GetState(component_, &state);
|
||||
ASSERT_EQ(ret, HDF_SUCCESS);
|
||||
} while (state != OMX_StateExecuting);
|
||||
|
||||
waitState(OMX_StateExecuting);
|
||||
auto iter = outputBuffers_.begin();
|
||||
if (iter != outputBuffers_.end()) {
|
||||
auto ret = component_->FillThisBuffer(component_, iter->second->omxBuffer.get());
|
||||
@ -1099,18 +1130,14 @@ HWTEST_F(CodecHdiOmxTest, SUB_DriverSystem_CodecHdi_V2_0580, Function | MediumTe
|
||||
}
|
||||
|
||||
err = component_->SendCommand(component_, OMX_CommandStateSet, OMX_StateIdle, nullptr, 0);
|
||||
waitState(OMX_StateIdle);
|
||||
|
||||
err = component_->SendCommand(component_, OMX_CommandStateSet, OMX_StateLoaded, nullptr, 0);
|
||||
FreeBufferOnPort(PortIndex::PORT_INDEX_INPUT);
|
||||
FreeBufferOnPort(PortIndex::PORT_INDEX_OUTPUT);
|
||||
|
||||
err = component_->SendCommand(component_, OMX_CommandStateSet, OMX_StateLoaded, nullptr, 0);
|
||||
do {
|
||||
usleep(10);
|
||||
auto ret = component_->GetState(component_, &state);
|
||||
ASSERT_EQ(ret, HDF_SUCCESS);
|
||||
} while (state != OMX_StateLoaded);
|
||||
component_->ComponentDeInit(component_);
|
||||
waitState(OMX_StateLoaded);
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* @tc.name HdfCodecHdiFillThisBufferTest_002
|
||||
* @tc.number SUB_DriverSystem_CodecHdi_V2_0590
|
||||
|
Loading…
x
Reference in New Issue
Block a user