• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <iostream>
17 #include <cstdio>
18 #include <atomic>
19 #include <fstream>
20 #include <thread>
21 #include <mutex>
22 #include <queue>
23 #include <string>
24 
25 #include "gtest/gtest.h"
26 #include "native_avcodec_videodecoder.h"
27 #include "native_avcodec_base.h"
28 #include "videodec_api11_sample.h"
29 using namespace std;
30 using namespace OHOS;
31 using namespace OHOS::Media;
32 using namespace testing::ext;
33 
34 namespace OHOS {
35 namespace Media {
36 class H263SwdecReliNdkTest : public testing::Test {
37 public:
38     static void SetUpTestCase();    // 第一个测试用例执行前
39     static void TearDownTestCase(); // 最后一个测试用例执行后
40     void SetUp() override;          // 每个测试用例执行前
41     void TearDown() override;       // 每个测试用例执行后
42     void InputFunc();
43     void OutputFunc();
44     void Release();
45     int32_t Stop();
46 
47 protected:
48     const char *inpDir1920x1080Array[16] = {
49         "/data/test/media/profile2_level60_gop60_1920x1080.h263",
50         "/data/test/media/profile2_level60_gop60_1920x1080_1.h263",
51         "/data/test/media/profile2_level60_gop60_1920x1080_2.h263",
52         "/data/test/media/profile2_level60_gop60_1920x1080_3.h263",
53         "/data/test/media/profile2_level60_gop60_1920x1080_8.h263",
54         "/data/test/media/profile2_level60_gop60_1920x1080_12.h263",
55         "/data/test/media/profile2_level60_gop60_1920x1080_4.h263",
56         "/data/test/media/profile2_level60_gop60_1920x1080_9.h263",
57         "/data/test/media/profile2_level60_gop60_1920x1080_13.h263",
58         "/data/test/media/profile2_level60_gop60_1920x1080_5.h263",
59         "/data/test/media/profile2_level60_gop60_1920x1080_10.h263",
60         "/data/test/media/profile2_level60_gop60_1920x1080_14.h263",
61         "/data/test/media/profile2_level60_gop60_1920x1080_6.h263",
62         "/data/test/media/profile2_level60_gop60_1920x1080_11.h263",
63         "/data/test/media/profile2_level60_gop60_1920x1080_15.h263",
64         "/data/test/media/profile2_level60_gop60_1920x1080_7.h263"};
65 };
66 } // namespace Media
67 } // namespace OHOS
68 
SetUpTestCase()69 void H263SwdecReliNdkTest::SetUpTestCase() {}
TearDownTestCase()70 void H263SwdecReliNdkTest::TearDownTestCase() {}
SetUp()71 void H263SwdecReliNdkTest::SetUp() {}
TearDown()72 void H263SwdecReliNdkTest::TearDown() {}
73 
74 namespace {
75 /**
76  * @tc.number    : VIDEO_H263SWDEC_RELI_WHILE_0100
77  * @tc.name      : 16 instances
78  * @tc.desc      : reliable test
79  */
80 HWTEST_F(H263SwdecReliNdkTest, VIDEO_H263SWDEC_RELI_WHILE_0100, TestSize.Level2)
81 {
82     for (int i = 0; i < 16; i++) {
83         auto vDecSample = make_shared<VDecAPI11Sample>();
84         vDecSample->SURFACE_OUTPUT = false;
85         vDecSample->INP_DIR = inpDir1920x1080Array[i];
86         vDecSample->DEFAULT_WIDTH = 1920;
87         vDecSample->DEFAULT_HEIGHT = 1080;
88         vDecSample->DEFAULT_FRAME_RATE = 30;
89         ASSERT_EQ(AV_ERR_OK, vDecSample->CreateVideoDecoder("OH.Media.Codec.Decoder.Video.H263"));
90         ASSERT_EQ(AV_ERR_OK, vDecSample->ConfigureVideoDecoder());
91         ASSERT_EQ(AV_ERR_OK, vDecSample->SetVideoDecoderCallback());
92         ASSERT_EQ(AV_ERR_OK, vDecSample->StartVideoDecoder());
93         if (i == 15) {
94             vDecSample->WaitForEOS();
95             ASSERT_EQ(AV_ERR_OK, vDecSample->errCount);
96         }
97     }
98 }
99 
100 
101 /**
102  * @tc.number    : VIDEO_H263SWDEC_RELI_WHILE_0200
103  * @tc.name      : create Destroy
104  * @tc.desc      : reliable test
105  */
106 HWTEST_F(H263SwdecReliNdkTest, VIDEO_H263SWDEC_RELI_WHILE_0200, TestSize.Level2)
107 {
108     for (int i = 0; i < 1000; i++) {
109         OH_AVCodec *vdec_ = OH_VideoDecoder_CreateByName("OH.Media.Codec.Decoder.Video.H263");
110         ASSERT_NE(nullptr, vdec_);
111         OH_AVFormat *format = OH_AVFormat_Create();
112         ASSERT_NE(nullptr, format);
113         (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, 1920);
114         (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, 1080);
115         (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_FRAME_RATE, 30);
116         (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_NV12);
117         ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
118         OH_AVFormat_Destroy(format);
119         ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
120         OH_VideoDecoder_Stop(vdec_);
121         OH_VideoDecoder_Destroy(vdec_);
122     }
123 }
124 } // namespace