已合并
add dvvideo moduleTest #7187
add dvvideo moduleTest #7187
已合并
taihang_208创建于 2025年12月18日
20 个文件变更+5822-0
M.gitattributes+2-0
@@ -75,3 +75,5 @@ test/moduletest/resources/demuxer/rv30_cook.rm filter=lfs diff=lfs merge=lfs -te
75test/moduletest/resources/demuxer/rv40_aac.rm filter=lfs diff=lfs merge=lfs -text75test/moduletest/resources/demuxer/rv40_aac.rm filter=lfs diff=lfs merge=lfs -text
76test/moduletest/resources/demuxer/ac3.rm filter=lfs diff=lfs merge=lfs -text76test/moduletest/resources/demuxer/ac3.rm filter=lfs diff=lfs merge=lfs -text
77test/moduletest/resources/demuxer/test_error.rm filter=lfs diff=lfs merge=lfs -text77test/moduletest/resources/demuxer/test_error.rm filter=lfs diff=lfs merge=lfs -text
78+test/moduletest/resources/video_decoder/dvvideo_1280x1080_yuv422p_30_25frames.avi filter=lfs diff=lfs merge=lfs -text
79+test/moduletest/resources/video_decoder/dvvideo_1440x1080_yuv422p_25_25frames.avi filter=lfs diff=lfs merge=lfs -text
Mtest/BUILD.gn+1-0
@@ -211,6 +211,7 @@ group("av_codec_module_test") {
211 "moduletest/vcodec/encoder:encoder_native_module_test",211 "moduletest/vcodec/encoder:encoder_native_module_test",
212 "moduletest/vcodec/h263swdecoder:h263swdecoder_native_module_test",212 "moduletest/vcodec/h263swdecoder:h263swdecoder_native_module_test",
213 "moduletest/vcodec/wmv3swdecoder:wmv3swdecoder_native_module_test",213 "moduletest/vcodec/wmv3swdecoder:wmv3swdecoder_native_module_test",
214+ "moduletest/vcodec/dvvideoswdecoder:dvvideo_swdecoder_native_module_test",
214 "moduletest/vcodec/hdrcodec:hdrcodec_native_module_test",215 "moduletest/vcodec/hdrcodec:hdrcodec_native_module_test",
215 "moduletest/vcodec/avcswencoder:avcswencoder_native_module_test",216 "moduletest/vcodec/avcswencoder:avcswencoder_native_module_test",
216 "moduletest/vcodec/hevcswdecoder:hevcswdecoder_native_module_test",217 "moduletest/vcodec/hevcswdecoder:hevcswdecoder_native_module_test",
Mtest/moduletest/resources/ohos_test.xml+7-0
@@ -157,6 +157,13 @@
157 <option name="shell" value="restorecon /data/test/media"/>157 <option name="shell" value="restorecon /data/test/media"/>
158 </preparer>158 </preparer>
159 </target>159 </target>
160+ <target name="dvvideo_swdecoder_native_module_test">
161+ <preparer>
162+ <option name="shell" value="mkdir -p /data/test/media"/>
163+ <option name="push" value="video_decoder/. -> /data/test/media" src="res"/>
164+ <option name="shell" value="restorecon /data/test/media"/>
165+ </preparer>
166+ </target>
160 <target name="encoder_native_module_test">167 <target name="encoder_native_module_test">
161 <preparer>168 <preparer>
162 <option name="shell" value="mkdir -p /data/test/media"/>169 <option name="shell" value="mkdir -p /data/test/media"/>
Atest/moduletest/resources/video_decoder/dvvideo_1280x1080_yuv422p_30_25frames.avi+3-0
@@ -0,0 +1,3 @@
1+version https://git-lfs.github.com/spec/v1
2+oid sha256:e2764037b5e4a011ef13dcacd263c7944a52d24aa882ba34b9c538cbe0f70a02
3+size 12006362
Atest/moduletest/resources/video_decoder/dvvideo_1440x1080_yuv422p_25_25frames.avi+3-0
@@ -0,0 +1,3 @@
1+version https://git-lfs.github.com/spec/v1
2+oid sha256:c41f9141add01df23add125ce5e66343d78be449d10096b905fd409b49c4540d
3+size 14406362
Atest/moduletest/resources/video_decoder/dvvideo_720x480_yuv411p_30_25frames.avi+0-0
Binary files do not support preview
Atest/moduletest/resources/video_decoder/dvvideo_720x480_yuv411p_30_25frames.mkv+0-0
Binary files do not support preview
Atest/moduletest/resources/video_decoder/dvvideo_720x480_yuv411p_30_25frames.mov+0-0
Binary files do not support preview
Atest/moduletest/resources/video_decoder/dvvideo_720x480_yuv422p_30_25frames.avi+0-0
Binary files do not support preview
Atest/moduletest/resources/video_decoder/dvvideo_720x576_yuv411p_25_25frames.avi+0-0
Binary files do not support preview
Atest/moduletest/resources/video_decoder/dvvideo_720x576_yuv420p_25_25frames.avi+0-0
Binary files do not support preview
Atest/moduletest/resources/video_decoder/dvvideo_720x576_yuv422p_25_25frames.avi+0-0
Binary files do not support preview
Atest/moduletest/resources/video_decoder/dvvideo_960x720_yuv422p_50_25frames.avi+0-0
Binary files do not support preview
Atest/moduletest/resources/video_decoder/dvvideo_960x720_yuv422p_60_25frames.avi+0-0
Binary files do not support preview
Atest/moduletest/vcodec/dvvideoswdecoder/BUILD.gn+98-0
@@ -0,0 +1,98 @@
1+# Copyright (c) 2025 Huawei Device Co., Ltd.
2+# Licensed under the Apache License, Version 2.0 (the "License");
3+# you may not use this file except in compliance with the License.
4+# You may obtain a copy of the License at
5+#
6+# http://www.apache.org/licenses/LICENSE-2.0
7+#
8+# Unless required by applicable law or agreed to in writing, software
9+# distributed under the License is distributed on an "AS IS" BASIS,
10+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+# See the License for the specific language governing permissions and
12+# limitations under the License.
13+ 
14+import("//build/test.gni")
15+import("//foundation/multimedia/av_codec/config.gni")
16+ 
17+MEDIA_ROOT_DIR = "//foundation/multimedia/av_codec/"
18+module_output_path = "av_codec/AVCodec_Video/moduletest"
19+ 
20+dvvideo_swdecoder_moduletest_native_include_dirs = [
21+ "./include",
22+ "$MEDIA_ROOT_DIR/interfaces/inner_api/native",
23+ "$MEDIA_ROOT_DIR/interfaces/kits/c",
24+]
25+ 
26+dvvideo_swdecoder_moduletest_cflags = [
27+ "-std=c++17",
28+ "-fno-rtti",
29+ "-fno-exceptions",
30+ "-Wall",
31+ "-fno-common",
32+ "-fstack-protector-strong",
33+ "-Wshadow",
34+ "-FPIC",
35+ "-FS",
36+ "-O2",
37+ "-D_FORTIFY_SOURCE=2",
38+ "-fvisibility=hidden",
39+ "-Wformat=2",
40+ "-Wdate-time",
41+ "-Werror",
42+ "-Wextra",
43+ "-Wimplicit-fallthrough",
44+ "-Wsign-compare",
45+ "-Wunused-parameter",
46+]
47+ 
48+##################################################################################################################
49+ohos_unittest("dvvideo_swdecoder_native_module_test") {
50+ sanitize = av_codec_test_sanitize
51+ module_out_path = module_output_path
52+ include_dirs = dvvideo_swdecoder_moduletest_native_include_dirs
53+ include_dirs += [ "./" ]
54+ 
55+ cflags = dvvideo_swdecoder_moduletest_cflags
56+ 
57+ if (av_codec_support_codec) {
58+ sources = [
59+ "./src/api_test.cpp",
60+ "./src/func_test.cpp",
61+ 
62+ #"./src/reli_test.cpp",
63+ "./src/state_test.cpp",
64+ "./src/videodec_api11_sample.cpp",
65+ ]
66+ }
67+ 
68+ deps = [
69+ "$MEDIA_ROOT_DIR/interfaces/inner_api/native:av_codec_client",
70+ "$MEDIA_ROOT_DIR/interfaces/kits/c:native_media_codecbase",
71+ "$MEDIA_ROOT_DIR/interfaces/kits/c:native_media_vdec",
72+ "$MEDIA_ROOT_DIR/interfaces/kits/c:native_media_avdemuxer",
73+ "$MEDIA_ROOT_DIR/interfaces/kits/c:native_media_avsource",
74+ ]
75+ external_deps = [
76+ "c_utils:utils",
77+ "graphic_2d:libgraphic_utils",
78+ "graphic_2d:librender_service_client",
79+ "graphic_surface:surface",
80+ "graphic_surface:sync_fence",
81+ "hilog:libhilog",
82+ "ipc:ipc_single",
83+ "media_foundation:media_foundation",
84+ "media_foundation:native_media_core",
85+ "openssl:libcrypto_shared",
86+ "window_manager:libwm",
87+ ]
88+ 
89+ if (av_codec_support_drm) {
90+ external_deps += [
91+ "drm_framework:drm_framework",
92+ "drm_framework:native_drm",
93+ ]
94+ }
95+ 
96+ resource_config_file =
97+ "$MEDIA_ROOT_DIR/test/moduletest/resources/ohos_test.xml"
98+}
Atest/moduletest/vcodec/dvvideoswdecoder/include/videodec_api11_sample.h+196-0
@@ -0,0 +1,196 @@
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+#ifndef VIDEODEC_API11_SAMPLE_H
17+#define VIDEODEC_API11_SAMPLE_H
18+ 
19+#include <fcntl.h>
20+#include <sys/stat.h>
21+#include <unistd.h>
22+ 
23+#include <atomic>
24+#include <cstdio>
25+#include <fstream>
26+#include <iostream>
27+#include <mutex>
28+#include <queue>
29+#include <string>
30+#include <thread>
31+#include <unordered_map>
32+ 
33+#include "iconsumer_surface.h"
34+#include "native_avcodec_videodecoder.h"
35+#include "native_avdemuxer.h"
36+#include "native_averrors.h"
37+#include "native_avformat.h"
38+#include "native_avmemory.h"
39+#include "native_avsource.h"
40+#include "nocopyable.h"
41+#include "securec.h"
42+#include "surface/window.h"
43+ 
44+namespace OHOS {
45+namespace Media {
46+class VDecAPI11Signal {
47+public:
48+ std::mutex inMutex_;
49+ std::mutex outMutex_;
50+ std::condition_variable inCond_;
51+ std::condition_variable outCond_;
52+ std::queue<uint32_t> inIdxQueue_;
53+ std::queue<uint32_t> outIdxQueue_;
54+ std::queue<OH_AVCodecBufferAttr> attrQueue_;
55+ std::queue<OH_AVBuffer *> inBufferQueue_;
56+ std::queue<OH_AVBuffer *> outBufferQueue_;
57+};
58+ 
59+class VDecAPI11Sample : public NoCopyable {
60+public:
61+ VDecAPI11Sample() = default;
62+ ~VDecAPI11Sample();
63+ int32_t RunVideoDec_Surface(std::string codeName = "");
64+ int32_t RunVideoDec(std::string codeName = "");
65+ const char *IN_DIR = "/data/test/media/dvvideo_720x576_yuv420p_25_25frames.avi";
66+ const char *OUT_DIR = "/data/test/media/dvvideo_vdec_test.yuv";
67+ const char *OUT_DIR2 = "/data/test/media/dvvideo_vdec_test2.yuv";
68+ bool SF_OUTPUT = false;
69+ uint32_t DEFAULT_WIDTH = 720;
70+ uint32_t DEFAULT_HEIGHT = 576;
71+ uint32_t originalWidth = 0;
72+ uint32_t originalHeight = 0;
73+ bool SURFACE_OUTPUT = false;
74+ uint32_t defualtPixelFormat = AV_PIXEL_FORMAT_NV12;
75+ uint32_t REPEAT_CALL_TIME = 10;
76+ uint32_t MAX_SURF_NUM = 2;
77+ double DEFAULT_FRAME_RATE = 30.0;
78+ uint32_t DEFAULT_RANGE_FLAG = 0;
79+ bool BEFORE_EOS_INPUT = false;
80+ bool BEFORE_EOS_INPUT_INPUT = false;
81+ bool AFTER_EOS_DESTORY_CODEC = true;
82+ uint32_t frameCount_ = 0;
83+ bool outputYuvFlag = false;
84+ uint32_t repeat_time = 0;
85+ uint32_t outFrameCount = 0;
86+ // 解码输出数据预期
87+ bool needCheckOutputDesc = false;
88+ uint32_t expectCropTop = 0;
89+ uint32_t expectCropBottom = 0;
90+ uint32_t expectCropLeft = 0;
91+ uint32_t expectCropRight = 0;
92+ bool outputYuvSurface = false;
93+ int32_t enbleSyncMode = 0;
94+ int enbleBlankFrame = 0;
95+ int64_t syncInputWaitTime = -1;
96+ int64_t syncOutputWaitTime = -1;
97+ bool queryOutputBufferEOS = false;
98+ bool queryInputBufferEOS = false;
99+ const char *fileSourcesha256[64] = {"27", "6D", "A2", "D4", "18", "21", "A5", "CD", "50", "F6", "DD", "CA", "46",
100+ "32", "C3", "FE", "58", "FC", "BC", "51", "FD", "70", "C7", "D4", "E7", "4D",
101+ "5C", "76", "E7", "71", "8A", "B3", "C0", "51", "84", "0A", "FA", "AF", "FA",
102+ "DC", "7B", "C5", "26", "D1", "9A", "CA", "00", "DE", "FC", "C8", "4E", "34",
103+ "C5", "9A", "43", "59", "85", "DC", "AC", "97", "A3", "FB", "23", "51"};
104+ 
105+ int32_t Start();
106+ int32_t Stop();
107+ int32_t Flush();
108+ int32_t Reset();
109+ int32_t state_EOS();
110+ void SetEOS(uint32_t index, OH_AVBuffer *buffer);
111+ void WaitForEOS();
112+ int32_t ConfigureVideoDecoder();
113+ int32_t StartVideoDecoder();
114+ int32_t StartVideoDecoderForH263();
115+ int32_t StartSyncVideoDecoder();
116+ int64_t GetSystemTimeUs();
117+ int32_t CreateVideoDecoder(std::string codeName);
118+ int32_t SetVideoDecoderCallback();
119+ void testAPI();
120+ int32_t SwitchSurface();
121+ int32_t RepeatCallSetSurface();
122+ int32_t Release();
123+ int32_t SetParameter(OH_AVFormat *format);
124+ int32_t SetRotationAngle(int32_t angle);
125+ void CheckOutputDescription();
126+ void AutoSwitchSurface();
127+ int32_t DecodeSetSurface();
128+ int32_t PushData(uint32_t index, OH_AVBuffer *buffer);
129+ int32_t PushDataForH263(uint32_t index, OH_AVBuffer *buffer);
130+ int32_t CheckAndReturnBufferSize(OH_AVBuffer *buffer);
131+ uint32_t SendData(uint32_t bufferSize, uint32_t index, OH_AVBuffer *buffer);
132+ void ProcessOutputData(OH_AVBuffer *buffer, uint32_t index, int32_t size);
133+ int32_t CheckAttrFlag(OH_AVCodecBufferAttr attr);
134+ void SetAttr(OH_AVCodecBufferAttr &attr, uint32_t bufferSize);
135+ void SyncOutputFunc();
136+ int32_t SyncOutputFuncEos(OH_AVCodecBufferAttr attr, uint32_t index);
137+ void InputFuncTest();
138+ void InputFuncTestForH263();
139+ void SyncInputFunc();
140+ void OutputFuncTest();
141+ void CreateSurface();
142+ void ReleaseInFile();
143+ void StopInloop();
144+ void Flush_buffer();
145+ void StopOutloop();
146+ bool MdCompare(unsigned char *buffer, int len, const char *source[]);
147+ int64_t GetInputFileSize(const char *inputFileName);
148+ int32_t LoadInputFile(const char *inputFileName);
149+ VDecAPI11Signal *signal_;
150+ uint32_t errCount = 0;
151+ uint32_t outCount = 0;
152+ int64_t renderTimestampNs = 0;
153+ bool rsAtTime = false;
154+ int64_t outTimeArray[2000] = {};
155+ bool sleepOnFPS = false;
156+ bool repeatRun = false;
157+ int64_t decode_count = 0;
158+ int64_t start_time = 0;
159+ int32_t maxInputSize = 0;
160+ int64_t end_time = 0;
161+ bool autoSwitchSurface = false;
162+ int32_t switchSurfaceFlag = 0;
163+ std::atomic<bool> isRunning_{false};
164+ bool inputCallbackFlush = false;
165+ bool inputCallbackStop = false;
166+ bool outputCallbackFlush = false;
167+ bool outputCallbackStop = false;
168+ bool useHDRSource = false;
169+ bool isDVVideoChange = false;
170+ bool isonError = false;
171+ 
172+private:
173+ std::unique_ptr<std::ifstream> inFile_;
174+ std::unique_ptr<std::thread> inputLoop_;
175+ std::unique_ptr<std::thread> outputLoop_;
176+ std::unordered_map<uint32_t, OH_AVBuffer *> inBufferMap_;
177+ std::unordered_map<uint32_t, OH_AVBuffer *> outBufferMap_;
178+ OH_AVCodec *vdec_;
179+ OH_AVCodecCallback cb_;
180+ OHNativeWindow *nativeWindow[2] = {};
181+ sptr<Surface> cs[2] = {};
182+ sptr<Surface> ps[2] = {};
183+ 
184+ OH_AVSource *videoSource = nullptr;
185+ OH_AVDemuxer *demuxer = nullptr;
186+ OH_AVFormat *sourceFormat = nullptr;
187+ OH_AVFormat *trackFormat = nullptr;
188+};
189+} // namespace Media
190+} // namespace OHOS
191+ 
192+void VdecAPI11Error(OH_AVCodec *codec, int32_t errorCode, void *userData);
193+void VdecAPI11FormatChanged(OH_AVCodec *codec, OH_AVFormat *format, void *userData);
194+void VdecAPI11InputDataReady(OH_AVCodec *codec, uint32_t index, OH_AVBuffer *data, void *userData);
195+void VdecAPI11OutputDataReady(OH_AVCodec *codec, uint32_t index, OH_AVBuffer *data, void *userData);
196+#endif // VIDEODEC_SAMPLE_H
Atest/moduletest/vcodec/dvvideoswdecoder/src/api_test.cpp+2225-0
@@ -0,0 +1,2225 @@
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 <atomic>
17+#include <cstdio>
18+#include <fstream>
19+#include <iostream>
20+#include <mutex>
21+#include <queue>
22+#include <string>
23+#include <thread>
24+ 
25+#include "gtest/gtest.h"
26+#include "native_avcapability.h"
27+#include "native_avcodec_base.h"
28+#include "native_avcodec_videodecoder.h"
29+#include "native_averrors.h"
30+#include "native_avformat.h"
31+#include "videodec_api11_sample.h"
32+ 
33+#ifdef SUPPORT_DRM
34+#include "native_mediakeysession.h"
35+#include "native_mediakeysystem.h"
36+#endif
37+ 
38+#define PIXFORMAT_NUM 4
39+ 
40+using namespace std;
41+using namespace OHOS;
42+using namespace OHOS::Media;
43+using namespace testing::ext;
44+namespace OHOS {
45+namespace Media {
46+class DVVideoSwdecApiNdkTest : public testing::Test {
47+public:
48+ // SetUpTestCase: Called before all test cases
49+ static void SetUpTestCase(void);
50+ // TearDownTestCase: Called after all test case
51+ static void TearDownTestCase(void);
52+ // SetUp: Called before each test cases
53+ void SetUp(void);
54+ // TearDown: Called after each test cases
55+ void TearDown(void);
56+};
57+ 
58+OH_AVCodec *vdec_ = NULL;
59+OH_AVCapability *cap = nullptr;
60+const string INVALID_CODEC_NAME = "avdec_dvvideo";
61+const string CODEC_NAME = "OH.Media.Codec.Decoder.Video.DVVIDEO";
62+VDecAPI11Signal *signal_;
63+constexpr uint32_t DEFAULT_WIDTH = 720;
64+constexpr uint32_t DEFAULT_HEIGHT = 480;
65+constexpr uint32_t DEFAULT_FRAME_RATE = 30;
66+constexpr uint32_t VIDEO_INSTANCES_SIZE = 64;
67+constexpr uint32_t VIDEO_DEFAULT_FRAME_RATE_SIZE = 30;
68+constexpr uint32_t VIDEO_ALIGNMENT_SIZE = 2;
69+ 
70+OH_AVFormat *format;
71+void DVVideoSwdecApiNdkTest::SetUpTestCase()
72+{
73+}
74+void DVVideoSwdecApiNdkTest::TearDownTestCase()
75+{
76+}
77+void DVVideoSwdecApiNdkTest::SetUp()
78+{
79+ signal_ = new VDecAPI11Signal();
80+}
81+void DVVideoSwdecApiNdkTest::TearDown()
82+{
83+ if (format != nullptr) {
84+ OH_AVFormat_Destroy(format);
85+ format = nullptr;
86+ }
87+ if (signal_) {
88+ delete signal_;
89+ signal_ = nullptr;
90+ }
91+ if (vdec_ != NULL) {
92+ OH_VideoDecoder_Destroy(vdec_);
93+ vdec_ = nullptr;
94+ }
95+}
96+} // namespace Media
97+} // namespace OHOS
98+ 
99+namespace {
100+/**
101+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_0100
102+ * @tc.name : once create OH_VideoDecoder_CreateByName param error ""
103+ * @tc.desc : function test
104+ */
105+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_0100, TestSize.Level2)
106+{
107+ vdec_ = OH_VideoDecoder_CreateByName("");
108+ ASSERT_EQ(NULL, vdec_);
109+}
110+ 
111+/**
112+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_0200
113+ * @tc.name : once create OH_VideoDecoder_CreateByName param error NULL
114+ * @tc.desc : function test
115+ */
116+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_0200, TestSize.Level2)
117+{
118+ vdec_ = OH_VideoDecoder_CreateByName(NULL);
119+ ASSERT_EQ(NULL, vdec_);
120+}
121+ 
122+/**
123+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_0300
124+ * @tc.name : repeat create OH_VideoDecoder_CreateByName param correct
125+ * @tc.desc : function test
126+ */
127+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_0300, TestSize.Level2)
128+{
129+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
130+ ASSERT_NE(NULL, vdec_);
131+ OH_AVCodec *vdec_2 = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
132+ ASSERT_NE(NULL, vdec_2);
133+ OH_VideoDecoder_Destroy(vdec_2);
134+ vdec_2 = nullptr;
135+}
136+ 
137+/**
138+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_0400
139+ * @tc.name : create configure param error NULL
140+ * @tc.desc : function test
141+ */
142+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_0400, TestSize.Level2)
143+{
144+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
145+ ASSERT_NE(NULL, vdec_);
146+ 
147+ OH_AVFormat *format = OH_AVFormat_Create();
148+ ASSERT_NE(NULL, format);
149+ 
150+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
151+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
152+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
153+ 
154+ ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoDecoder_Configure(NULL, format));
155+}
156+ 
157+/**
158+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_0500
159+ * @tc.name : create configure param error NULL format
160+ * @tc.desc : function test
161+ */
162+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_0500, TestSize.Level2)
163+{
164+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
165+ ASSERT_NE(NULL, vdec_);
166+ ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoDecoder_Configure(vdec_, NULL));
167+}
168+ 
169+/**
170+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_0600
171+ * @tc.name : create configure configure param correct
172+ * @tc.desc : function test
173+ */
174+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_0600, TestSize.Level2)
175+{
176+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
177+ ASSERT_NE(NULL, vdec_);
178+ 
179+ OH_AVFormat *format = OH_AVFormat_Create();
180+ ASSERT_NE(NULL, format);
181+ 
182+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
183+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
184+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
185+ 
186+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
187+ ASSERT_EQ(AV_ERR_INVALID_STATE, OH_VideoDecoder_Configure(vdec_, format));
188+}
189+ 
190+/**
191+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_0700
192+ * @tc.name : create configure start param error NULL
193+ * @tc.desc : function test
194+ */
195+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_0700, TestSize.Level2)
196+{
197+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
198+ ASSERT_NE(NULL, vdec_);
199+ 
200+ OH_AVFormat *format = OH_AVFormat_Create();
201+ ASSERT_NE(NULL, format);
202+ 
203+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
204+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
205+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
206+ 
207+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
208+ ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoDecoder_Start(NULL));
209+}
210+ 
211+/**
212+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_0800
213+ * @tc.name : create configure start start param correct
214+ * @tc.desc : function test
215+ */
216+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_0800, TestSize.Level2)
217+{
218+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
219+ ASSERT_NE(NULL, vdec_);
220+ 
221+ OH_AVFormat *format = OH_AVFormat_Create();
222+ ASSERT_NE(NULL, format);
223+ 
224+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
225+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
226+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
227+ 
228+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
229+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
230+ ASSERT_EQ(AV_ERR_INVALID_STATE, OH_VideoDecoder_Start(vdec_));
231+}
232+ 
233+/**
234+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_0900
235+ * @tc.name : create configure start stop param error NULL
236+ * @tc.desc : function test
237+ */
238+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_0900, TestSize.Level2)
239+{
240+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
241+ ASSERT_NE(NULL, vdec_);
242+ 
243+ OH_AVFormat *format = OH_AVFormat_Create();
244+ ASSERT_NE(NULL, format);
245+ 
246+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
247+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
248+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
249+ 
250+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
251+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
252+ ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoDecoder_Stop(NULL));
253+}
254+ 
255+/**
256+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_1000
257+ * @tc.name : create configure start stop stop param correct
258+ * @tc.desc : function test
259+ */
260+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_1000, TestSize.Level2)
261+{
262+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
263+ ASSERT_NE(NULL, vdec_);
264+ 
265+ OH_AVFormat *format = OH_AVFormat_Create();
266+ ASSERT_NE(NULL, format);
267+ 
268+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
269+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
270+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
271+ 
272+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
273+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
274+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Stop(vdec_));
275+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Stop(vdec_));
276+}
277+ 
278+/**
279+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_1100
280+ * @tc.name : create configure start stop reset param error NULL
281+ * @tc.desc : function test
282+ */
283+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_1100, TestSize.Level2)
284+{
285+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
286+ ASSERT_NE(NULL, vdec_);
287+ 
288+ OH_AVFormat *format = OH_AVFormat_Create();
289+ ASSERT_NE(NULL, format);
290+ 
291+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
292+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
293+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
294+ 
295+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
296+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
297+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Stop(vdec_));
298+ ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoDecoder_Reset(NULL));
299+}
300+ 
301+/**
302+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_1200
303+ * @tc.name : create configure start stop reset reset param correct
304+ * @tc.desc : function test
305+ */
306+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_1200, TestSize.Level2)
307+{
308+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
309+ ASSERT_NE(NULL, vdec_);
310+ 
311+ OH_AVFormat *format = OH_AVFormat_Create();
312+ ASSERT_NE(NULL, format);
313+ 
314+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
315+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
316+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
317+ 
318+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
319+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
320+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Stop(vdec_));
321+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Reset(vdec_));
322+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Reset(vdec_));
323+}
324+ 
325+/**
326+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_1300
327+ * @tc.name : create configure start EOS param error NULL
328+ * @tc.desc : function test
329+ */
330+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_1300, TestSize.Level2)
331+{
332+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
333+ ASSERT_NE(NULL, vdec_);
334+ 
335+ OH_AVFormat *format = OH_AVFormat_Create();
336+ ASSERT_NE(NULL, format);
337+ 
338+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
339+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
340+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
341+ 
342+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
343+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
344+ 
345+ ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoDecoder_PushInputBuffer(NULL, 0));
346+}
347+ 
348+/**
349+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_1400
350+ * @tc.name : create configure start EOS EOS param correct
351+ * @tc.desc : function test
352+ */
353+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_1400, TestSize.Level2)
354+{
355+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
356+ ASSERT_NE(NULL, vdec_);
357+ 
358+ OH_AVFormat *format = OH_AVFormat_Create();
359+ ASSERT_NE(NULL, format);
360+ 
361+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
362+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
363+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
364+ 
365+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
366+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
367+ 
368+ ASSERT_EQ(AV_ERR_INVALID_STATE, OH_VideoDecoder_PushInputBuffer(vdec_, 0));
369+ ASSERT_EQ(AV_ERR_INVALID_STATE, OH_VideoDecoder_PushInputBuffer(vdec_, 0));
370+}
371+ 
372+/**
373+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_1500
374+ * @tc.name : create configure start flush param error NULL
375+ * @tc.desc : function test
376+ */
377+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_1500, TestSize.Level2)
378+{
379+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
380+ ASSERT_NE(NULL, vdec_);
381+ 
382+ OH_AVFormat *format = OH_AVFormat_Create();
383+ ASSERT_NE(NULL, format);
384+ 
385+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
386+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
387+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
388+ 
389+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
390+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
391+ ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoDecoder_Flush(NULL));
392+}
393+ 
394+/**
395+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_1600
396+ * @tc.name : create configure start flush flush param correct
397+ * @tc.desc : function test
398+ */
399+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_1600, TestSize.Level2)
400+{
401+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
402+ ASSERT_NE(NULL, vdec_);
403+ 
404+ OH_AVFormat *format = OH_AVFormat_Create();
405+ ASSERT_NE(NULL, format);
406+ 
407+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
408+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
409+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
410+ 
411+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
412+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
413+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Flush(vdec_));
414+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Flush(vdec_));
415+}
416+ 
417+/**
418+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_1700
419+ * @tc.name : release param error NULL
420+ * @tc.desc : function test
421+ */
422+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_1700, TestSize.Level2)
423+{
424+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
425+ ASSERT_NE(NULL, vdec_);
426+ ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoDecoder_Destroy(NULL));
427+}
428+ 
429+/**
430+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_1800
431+ * @tc.name : create configure start stop release release param correct
432+ * @tc.desc : function test
433+ */
434+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_1800, TestSize.Level2)
435+{
436+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
437+ ASSERT_NE(NULL, vdec_);
438+ 
439+ OH_AVFormat *format = OH_AVFormat_Create();
440+ ASSERT_NE(NULL, format);
441+ 
442+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
443+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
444+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
445+ 
446+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
447+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
448+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Stop(vdec_));
449+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Destroy(vdec_));
450+ vdec_ = nullptr;
451+ ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoDecoder_Destroy(vdec_));
452+}
453+ 
454+/**
455+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_1900
456+ * @tc.name : create param error NULL
457+ * @tc.desc : function test
458+ */
459+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_1900, TestSize.Level2)
460+{
461+ vdec_ = OH_VideoDecoder_CreateByMime(NULL);
462+ ASSERT_EQ(NULL, vdec_);
463+}
464+ 
465+/**
466+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_2000
467+ * @tc.name : create param error ""
468+ * @tc.desc : function test
469+ */
470+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_2000, TestSize.Level2)
471+{
472+ vdec_ = OH_VideoDecoder_CreateByMime("");
473+ ASSERT_EQ(NULL, vdec_);
474+}
475+ 
476+/**
477+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_2100
478+ * @tc.name : create create param correct
479+ * @tc.desc : function test
480+ */
481+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_2100, TestSize.Level2)
482+{
483+ vdec_ = OH_VideoDecoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO);
484+ ASSERT_NE(NULL, vdec_);
485+ OH_VideoDecoder_Destroy(vdec_);
486+ vdec_ = nullptr;
487+}
488+ 
489+/**
490+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_2200
491+ * @tc.name : create create
492+ * @tc.desc : function test
493+ */
494+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_2200, TestSize.Level2)
495+{
496+ vdec_ = OH_VideoDecoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO);
497+ ASSERT_NE(NULL, vdec_);
498+ OH_AVCodec *vdec_2 = OH_VideoDecoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO);
499+ ASSERT_NE(NULL, vdec_2);
500+ OH_VideoDecoder_Destroy(vdec_2);
501+ vdec_2 = nullptr;
502+}
503+ 
504+/**
505+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_2300
506+ * @tc.name : repeat OH_VideoDecoder_RegisterCallback onError = NULL
507+ * @tc.desc : function test
508+ */
509+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_2300, TestSize.Level2)
510+{
511+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
512+ OH_AVCodecCallback cb_;
513+ cb_.onError = NULL;
514+ cb_.onStreamChanged = VdecAPI11FormatChanged;
515+ cb_.onNeedInputBuffer = VdecAPI11InputDataReady;
516+ cb_.onNewOutputBuffer = VdecAPI11OutputDataReady;
517+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_RegisterCallback(vdec_, cb_, NULL));
518+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_RegisterCallback(vdec_, cb_, NULL));
519+}
520+ 
521+/**
522+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_2400
523+ * @tc.name : repeat OH_VideoDecoder_RegisterCallback onStreamChanged = NULL
524+ * @tc.desc : function test
525+ */
526+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_2400, TestSize.Level2)
527+{
528+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
529+ OH_AVCodecCallback cb_;
530+ cb_.onError = VdecAPI11Error;
531+ cb_.onStreamChanged = NULL;
532+ cb_.onNeedInputBuffer = VdecAPI11InputDataReady;
533+ cb_.onNewOutputBuffer = VdecAPI11OutputDataReady;
534+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_RegisterCallback(vdec_, cb_, NULL));
535+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_RegisterCallback(vdec_, cb_, NULL));
536+}
537+ 
538+/**
539+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_2500
540+ * @tc.name : repeat OH_VideoDecoder_RegisterCallback onNeedInputBuffer = NULL
541+ * @tc.desc : function test
542+ */
543+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_2500, TestSize.Level2)
544+{
545+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
546+ OH_AVCodecCallback cb_;
547+ cb_.onError = VdecAPI11Error;
548+ cb_.onStreamChanged = VdecAPI11FormatChanged;
549+ cb_.onNeedInputBuffer = NULL;
550+ cb_.onNewOutputBuffer = VdecAPI11OutputDataReady;
551+ ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoDecoder_RegisterCallback(vdec_, cb_, NULL));
552+ ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoDecoder_RegisterCallback(vdec_, cb_, NULL));
553+}
554+ 
555+/**
556+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_2600
557+ * @tc.name : repeat OH_VideoDecoder_RegisterCallback onNewOutputBuffer = NULL
558+ * @tc.desc : function test
559+ */
560+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_2600, TestSize.Level2)
561+{
562+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
563+ OH_AVCodecCallback cb_;
564+ cb_.onError = VdecAPI11Error;
565+ cb_.onStreamChanged = VdecAPI11FormatChanged;
566+ cb_.onNeedInputBuffer = VdecAPI11InputDataReady;
567+ cb_.onNewOutputBuffer = NULL;
568+ ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoDecoder_RegisterCallback(vdec_, cb_, NULL));
569+ ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoDecoder_RegisterCallback(vdec_, cb_, NULL));
570+}
571+ 
572+/**
573+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_2700
574+ * @tc.name : repeat OH_VideoDecoder_RegisterCallback param correct
575+ * @tc.desc : function test
576+ */
577+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_2700, TestSize.Level2)
578+{
579+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
580+ OH_AVCodecCallback cb_;
581+ cb_.onError = VdecAPI11Error;
582+ cb_.onStreamChanged = VdecAPI11FormatChanged;
583+ cb_.onNeedInputBuffer = VdecAPI11InputDataReady;
584+ cb_.onNewOutputBuffer = VdecAPI11OutputDataReady;
585+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_RegisterCallback(vdec_, cb_, NULL));
586+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_RegisterCallback(vdec_, cb_, NULL));
587+}
588+ 
589+/**
590+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_2800
591+ * @tc.name : repeat OH_VideoDecoder_GetOutputDescription param error NULL
592+ * @tc.desc : function test
593+ */
594+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_2800, TestSize.Level2)
595+{
596+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
597+ OH_AVFormat *format = OH_VideoDecoder_GetOutputDescription(NULL);
598+ ASSERT_EQ(NULL, format);
599+}
600+ 
601+/**
602+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_2900
603+ * @tc.name : once OH_VideoDecoder_GetOutputDescription param correct
604+ * @tc.desc : function test
605+ */
606+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_2900, TestSize.Level2)
607+{
608+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
609+ OH_AVFormat *format = OH_VideoDecoder_GetOutputDescription(vdec_);
610+ ASSERT_NE(NULL, format);
611+}
612+ 
613+/**
614+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_3000
615+ * @tc.name : repeat OH_VideoDecoder_GetOutputDescription param correct
616+ * @tc.desc : function test
617+ */
618+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_3000, TestSize.Level2)
619+{
620+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
621+ OH_AVFormat *format = OH_VideoDecoder_GetOutputDescription(vdec_);
622+ ASSERT_NE(NULL, format);
623+ format = OH_VideoDecoder_GetOutputDescription(vdec_);
624+ ASSERT_NE(NULL, format);
625+}
626+ 
627+/**
628+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_3100
629+ * @tc.name : repeat OH_VideoDecoder_SetParameter param error NULL format
630+ * @tc.desc : function test
631+ */
632+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_3100, TestSize.Level2)
633+{
634+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
635+ ASSERT_NE(NULL, vdec_);
636+ ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoDecoder_SetParameter(vdec_, NULL));
637+}
638+ 
639+/**
640+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_3200
641+ * @tc.name : repeat OH_VideoDecoder_SetParameter param error NULL
642+ * @tc.desc : function test
643+ */
644+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_3200, TestSize.Level2)
645+{
646+ OH_AVFormat *format = OH_AVFormat_Create();
647+ ASSERT_NE(NULL, format);
648+ 
649+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
650+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
651+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
652+ 
653+ ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoDecoder_SetParameter(NULL, format));
654+}
655+ 
656+/**
657+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_3300
658+ * @tc.name : repeat OH_VideoDecoder_SetParameter param correct
659+ * @tc.desc : function test
660+ */
661+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_3300, TestSize.Level2)
662+{
663+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
664+ ASSERT_NE(NULL, vdec_);
665+ 
666+ OH_AVFormat *format = OH_AVFormat_Create();
667+ ASSERT_NE(NULL, format);
668+ 
669+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
670+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
671+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
672+ 
673+ ASSERT_EQ(AV_ERR_INVALID_STATE, OH_VideoDecoder_SetParameter(vdec_, format));
674+ ASSERT_EQ(AV_ERR_INVALID_STATE, OH_VideoDecoder_SetParameter(vdec_, format));
675+}
676+ 
677+/**
678+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_3400
679+ * @tc.name : repeat OH_VideoDecoder_IsValid param error NULL
680+ * @tc.desc : function test
681+ */
682+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_3400, TestSize.Level2)
683+{
684+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
685+ ASSERT_NE(NULL, vdec_);
686+ 
687+ bool isValid = false;
688+ ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoDecoder_IsValid(NULL, &isValid));
689+}
690+ 
691+/**
692+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_3500
693+ * @tc.name : repeat OH_VideoDecoder_IsValid param error NULL IsValid
694+ * @tc.desc : function test
695+ */
696+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_3500, TestSize.Level2)
697+{
698+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
699+ ASSERT_NE(NULL, vdec_);
700+ 
701+ ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoDecoder_IsValid(vdec_, NULL));
702+}
703+ 
704+/**
705+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_3600
706+ * @tc.name : repeat OH_VideoDecoder_IsValid param correct
707+ * @tc.desc : function test
708+ */
709+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_3600, TestSize.Level2)
710+{
711+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
712+ ASSERT_NE(NULL, vdec_);
713+ 
714+ bool isValid = false;
715+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_IsValid(vdec_, &isValid));
716+ ASSERT_EQ(true, isValid);
717+}
718+ 
719+/**
720+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_3700
721+ * @tc.name : repeat OH_VideoDecoder_Prepare param error NULL
722+ * @tc.desc : function test
723+ */
724+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_3700, TestSize.Level2)
725+{
726+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
727+ ASSERT_NE(NULL, vdec_);
728+ 
729+ OH_AVFormat *format = OH_AVFormat_Create();
730+ ASSERT_NE(NULL, format);
731+ 
732+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
733+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
734+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
735+ 
736+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
737+ ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoDecoder_Prepare(NULL));
738+}
739+ 
740+/**
741+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_3800
742+ * @tc.name : repeat OH_VideoDecoder_Prepare param correct
743+ * @tc.desc : function test
744+ */
745+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_3800, TestSize.Level2)
746+{
747+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
748+ ASSERT_NE(NULL, vdec_);
749+ 
750+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Prepare(vdec_));
751+}
752+ 
753+/**
754+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_3900
755+ * @tc.name : repeat OH_VideoDecoder_Prepare param correct
756+ * @tc.desc : function test
757+ */
758+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_3900, TestSize.Level2)
759+{
760+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
761+ ASSERT_NE(NULL, vdec_);
762+ 
763+ OH_AVFormat *format = OH_AVFormat_Create();
764+ ASSERT_NE(NULL, format);
765+ 
766+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
767+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
768+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
769+ 
770+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
771+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Prepare(vdec_));
772+}
773+ 
774+/**
775+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_4000
776+ * @tc.name : repeat OH_VideoDecoder_SetSurface param error NULL
777+ * @tc.desc : function test
778+ */
779+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_4000, TestSize.Level2)
780+{
781+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
782+ ASSERT_NE(NULL, vdec_);
783+ 
784+ OH_AVFormat *format = OH_AVFormat_Create();
785+ ASSERT_NE(NULL, format);
786+ 
787+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
788+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
789+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
790+ 
791+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
792+ ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoDecoder_SetSurface(vdec_, NULL));
793+}
794+ 
795+/**
796+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_4100
797+ * @tc.name : repeat OH_VideoDecoder_SetSurface param error NULL
798+ * @tc.desc : function test
799+ */
800+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_4100, TestSize.Level2)
801+{
802+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
803+ ASSERT_NE(NULL, vdec_);
804+ 
805+ OH_AVFormat *format = OH_AVFormat_Create();
806+ ASSERT_NE(NULL, format);
807+ 
808+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
809+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
810+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
811+ 
812+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
813+ 
814+ sptr<Surface> consumerSurface = Surface::CreateSurfaceAsConsumer();
815+ ASSERT_NE(NULL, consumerSurface);
816+ 
817+ auto producer = consumerSurface->GetProducer();
818+ ASSERT_NE(NULL, producer);
819+ 
820+ sptr<Surface> producerSurface = Surface::CreateSurfaceAsProducer(producer);
821+ ASSERT_NE(NULL, producerSurface);
822+ 
823+ OHNativeWindow *nativeWindow = CreateNativeWindowFromSurface(&producerSurface);
824+ ASSERT_NE(NULL, nativeWindow);
825+ 
826+ ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoDecoder_SetSurface(NULL, nativeWindow));
827+}
828+ 
829+/**
830+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_4200
831+ * @tc.name : repeat OH_VideoDecoder_SetSurface param correct
832+ * @tc.desc : function test
833+ */
834+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_4200, TestSize.Level2)
835+{
836+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
837+ ASSERT_NE(NULL, vdec_);
838+ 
839+ OH_AVFormat *format = OH_AVFormat_Create();
840+ ASSERT_NE(NULL, format);
841+ 
842+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
843+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
844+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
845+ 
846+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
847+ 
848+ sptr<Surface> consumerSurface = Surface::CreateSurfaceAsConsumer();
849+ ASSERT_NE(NULL, consumerSurface);
850+ 
851+ auto producer = consumerSurface->GetProducer();
852+ ASSERT_NE(NULL, producer);
853+ 
854+ sptr<Surface> producerSurface = Surface::CreateSurfaceAsProducer(producer);
855+ ASSERT_NE(NULL, producerSurface);
856+ 
857+ OHNativeWindow *nativeWindow = CreateNativeWindowFromSurface(&producerSurface);
858+ ASSERT_NE(NULL, nativeWindow);
859+ 
860+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_SetSurface(vdec_, nativeWindow));
861+}
862+ 
863+/**
864+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_4300
865+ * @tc.name : repeat OH_VideoDecoder_QueryInputBuffer param error NULL
866+ * @tc.desc : function test
867+ */
868+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_4300, TestSize.Level2)
869+{
870+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
871+ ASSERT_NE(NULL, vdec_);
872+ 
873+ OH_AVFormat *format = OH_AVFormat_Create();
874+ ASSERT_NE(NULL, format);
875+ 
876+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
877+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
878+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
879+ 
880+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
881+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
882+ uint32_t index = 0;
883+ int64_t timeoutUs = 0;
884+ ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoDecoder_QueryInputBuffer(NULL, &index, timeoutUs));
885+}
886+ 
887+/**
888+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_4400
889+ * @tc.name : repeat OH_VideoDecoder_QueryInputBuffer param correct
890+ * @tc.desc : function test
891+ */
892+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_4400, TestSize.Level2)
893+{
894+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
895+ ASSERT_NE(NULL, vdec_);
896+ 
897+ OH_AVFormat *format = OH_AVFormat_Create();
898+ ASSERT_NE(NULL, format);
899+ 
900+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
901+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
902+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
903+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_ENABLE_SYNC_MODE, 2);
904+ 
905+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
906+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
907+ uint32_t index = 0;
908+ int64_t timeoutUs = -1;
909+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_QueryInputBuffer(vdec_, &index, timeoutUs));
910+}
911+ 
912+/**
913+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_4500
914+ * @tc.name : repeat OH_VideoDecoder_QueryInputBuffer param correct
915+ * @tc.desc : function test
916+ */
917+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_4500, TestSize.Level2)
918+{
919+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
920+ ASSERT_NE(NULL, vdec_);
921+ 
922+ OH_AVFormat *format = OH_AVFormat_Create();
923+ ASSERT_NE(NULL, format);
924+ 
925+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
926+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
927+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
928+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_ENABLE_SYNC_MODE, 2);
929+ 
930+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
931+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
932+ uint32_t index = 0;
933+ int64_t timeoutUs = 0;
934+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_QueryInputBuffer(vdec_, &index, timeoutUs));
935+ cout << "Query input buffer index " << index << endl;
936+ ASSERT_LE(0, index);
937+}
938+ 
939+/**
940+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_4600
941+ * @tc.name : repeat OH_VideoDecoder_GetInputBuffer param error NULL
942+ * @tc.desc : function test
943+ */
944+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_4600, TestSize.Level2)
945+{
946+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
947+ ASSERT_NE(NULL, vdec_);
948+ 
949+ OH_AVFormat *format = OH_AVFormat_Create();
950+ ASSERT_NE(NULL, format);
951+ 
952+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
953+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
954+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
955+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_ENABLE_SYNC_MODE, 2);
956+ 
957+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
958+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
959+ uint32_t index = 0;
960+ int64_t timeoutUs = 0;
961+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_QueryInputBuffer(vdec_, &index, timeoutUs));
962+ cout << "Query input buffer index " << index << endl;
963+ ASSERT_LE(0, index);
964+ 
965+ OH_AVBuffer *buffer = OH_VideoDecoder_GetInputBuffer(NULL, index);
966+ ASSERT_EQ(NULL, buffer);
967+}
968+ 
969+/**
970+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_4700
971+ * @tc.name : repeat OH_VideoDecoder_GetInputBuffer param error -1
972+ * @tc.desc : function test
973+ */
974+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_4700, TestSize.Level2)
975+{
976+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
977+ ASSERT_NE(NULL, vdec_);
978+ 
979+ OH_AVFormat *format = OH_AVFormat_Create();
980+ ASSERT_NE(NULL, format);
981+ 
982+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
983+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
984+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
985+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_ENABLE_SYNC_MODE, 2);
986+ 
987+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
988+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
989+ uint32_t index = 0;
990+ int64_t timeoutUs = 0;
991+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_QueryInputBuffer(vdec_, &index, timeoutUs));
992+ cout << "Query input buffer index " << index << endl;
993+ ASSERT_LE(0, index);
994+ 
995+ OH_AVBuffer *buffer = OH_VideoDecoder_GetInputBuffer(vdec_, -1);
996+ ASSERT_EQ(NULL, buffer);
997+}
998+ 
999+/**
1000+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_4800
1001+ * @tc.name : repeat OH_VideoDecoder_GetInputBuffer param correct
1002+ * @tc.desc : function test
1003+ */
1004+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_4800, TestSize.Level2)
1005+{
1006+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
1007+ ASSERT_NE(NULL, vdec_);
1008+ 
1009+ OH_AVFormat *format = OH_AVFormat_Create();
1010+ ASSERT_NE(NULL, format);
1011+ 
1012+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
1013+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
1014+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
1015+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_ENABLE_SYNC_MODE, 2);
1016+ 
1017+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
1018+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
1019+ uint32_t index = 0;
1020+ int64_t timeoutUs = 0;
1021+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_QueryInputBuffer(vdec_, &index, timeoutUs));
1022+ cout << "Query input buffer index " << index << endl;
1023+ ASSERT_LE(0, index);
1024+ 
1025+ OH_AVBuffer *buffer = OH_VideoDecoder_GetInputBuffer(vdec_, index);
1026+ ASSERT_NE(NULL, buffer);
1027+}
1028+ 
1029+/**
1030+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_4900
1031+ * @tc.name : repeat OH_VideoDecoder_QueryOutputBuffer param error NULL
1032+ * @tc.desc : function test
1033+ */
1034+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_4900, TestSize.Level2)
1035+{
1036+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
1037+ ASSERT_NE(NULL, vdec_);
1038+ 
1039+ OH_AVFormat *format = OH_AVFormat_Create();
1040+ ASSERT_NE(NULL, format);
1041+ 
1042+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
1043+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
1044+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
1045+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_ENABLE_SYNC_MODE, 2);
1046+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_NV12);
1047+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_VIDEO_DECODER_BLANK_FRAME_ON_SHUTDOWN, 0);
1048+ 
1049+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
1050+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
1051+ 
1052+ uint32_t index = 0;
1053+ int64_t timeoutUs = 0;
1054+ ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoDecoder_QueryOutputBuffer(NULL, &index, timeoutUs));
1055+}
1056+ 
1057+/**
1058+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_5000
1059+ * @tc.name : repeat OH_VideoDecoder_QueryOutputBuffer param correct
1060+ * @tc.desc : function test
1061+ */
1062+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_5000, TestSize.Level2)
1063+{
1064+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
1065+ ASSERT_NE(NULL, vdec_);
1066+ 
1067+ OH_AVFormat *format = OH_AVFormat_Create();
1068+ ASSERT_NE(NULL, format);
1069+ 
1070+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
1071+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
1072+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
1073+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_ENABLE_SYNC_MODE, 2);
1074+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_NV12);
1075+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_VIDEO_DECODER_BLANK_FRAME_ON_SHUTDOWN, 0);
1076+ 
1077+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
1078+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
1079+ 
1080+ uint32_t index = 0;
1081+ int64_t timeoutUs = 0;
1082+ ASSERT_EQ(AV_ERR_TRY_AGAIN_LATER, OH_VideoDecoder_QueryOutputBuffer(vdec_, &index, timeoutUs));
1083+}
1084+ 
1085+/**
1086+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_5100
1087+ * @tc.name : repeat OH_VideoDecoder_QueryOutputBuffer param correct
1088+ * @tc.desc : function test
1089+ */
1090+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_5100, TestSize.Level2)
1091+{
1092+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
1093+ ASSERT_NE(NULL, vdec_);
1094+ 
1095+ OH_AVFormat *format = OH_AVFormat_Create();
1096+ ASSERT_NE(NULL, format);
1097+ 
1098+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
1099+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
1100+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
1101+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_ENABLE_SYNC_MODE, 2);
1102+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_NV12);
1103+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_VIDEO_DECODER_BLANK_FRAME_ON_SHUTDOWN, 0);
1104+ 
1105+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
1106+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
1107+ 
1108+ uint32_t index = 0;
1109+ int64_t timeoutUs = 100;
1110+ ASSERT_EQ(AV_ERR_TRY_AGAIN_LATER, OH_VideoDecoder_QueryOutputBuffer(vdec_, &index, timeoutUs));
1111+}
1112+ 
1113+/**
1114+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_5200
1115+ * @tc.name : repeat OH_VideoDecoder_GetOutputBuffer param error NULL
1116+ * @tc.desc : function test
1117+ */
1118+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_5200, TestSize.Level2)
1119+{
1120+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
1121+ ASSERT_NE(NULL, vdec_);
1122+ 
1123+ OH_AVFormat *format = OH_AVFormat_Create();
1124+ ASSERT_NE(NULL, format);
1125+ 
1126+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
1127+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
1128+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
1129+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_ENABLE_SYNC_MODE, 2);
1130+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_YUVI420);
1131+ 
1132+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
1133+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
1134+ 
1135+ uint32_t index = 0;
1136+ OH_AVBuffer *buffer = OH_VideoDecoder_GetOutputBuffer(NULL, index);
1137+ ASSERT_EQ(NULL, buffer);
1138+}
1139+ 
1140+/**
1141+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_5300
1142+ * @tc.name : repeat OH_VideoDecoder_GetOutputBuffer param error Greater than buffer count
1143+ * @tc.desc : function test
1144+ */
1145+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_5300, TestSize.Level2)
1146+{
1147+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
1148+ ASSERT_NE(NULL, vdec_);
1149+ 
1150+ OH_AVFormat *format = OH_AVFormat_Create();
1151+ ASSERT_NE(NULL, format);
1152+ 
1153+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
1154+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
1155+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
1156+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_ENABLE_SYNC_MODE, 2);
1157+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_YUVI420);
1158+ 
1159+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
1160+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
1161+ 
1162+ uint32_t index = 100;
1163+ OH_AVBuffer *buffer = OH_VideoDecoder_GetOutputBuffer(vdec_, index);
1164+ ASSERT_EQ(NULL, buffer);
1165+}
1166+ 
1167+/**
1168+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_5400
1169+ * @tc.name : repeat OH_VideoDecoder_GetOutputBuffer param correct
1170+ * @tc.desc : function test
1171+ */
1172+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_5400, TestSize.Level2)
1173+{
1174+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
1175+ ASSERT_NE(NULL, vdec_);
1176+ 
1177+ OH_AVFormat *format = OH_AVFormat_Create();
1178+ ASSERT_NE(NULL, format);
1179+ 
1180+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
1181+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
1182+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
1183+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_ENABLE_SYNC_MODE, 2);
1184+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_YUVI420);
1185+ 
1186+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
1187+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
1188+ 
1189+ uint32_t index = 0;
1190+ OH_AVBuffer *buffer = OH_VideoDecoder_GetOutputBuffer(vdec_, index);
1191+ ASSERT_EQ(NULL, buffer);
1192+}
1193+ 
1194+/**
1195+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_5500
1196+ * @tc.name : repeat OH_VideoDecoder_FreeOutputBuffer param error NULL
1197+ * @tc.desc : function test
1198+ */
1199+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_5500, TestSize.Level2)
1200+{
1201+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
1202+ ASSERT_NE(NULL, vdec_);
1203+ 
1204+ OH_AVFormat *format = OH_AVFormat_Create();
1205+ ASSERT_NE(NULL, format);
1206+ 
1207+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
1208+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
1209+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
1210+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_ENABLE_SYNC_MODE, 2);
1211+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_YUVI420);
1212+ 
1213+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
1214+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
1215+ 
1216+ uint32_t index = 0;
1217+ ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoDecoder_FreeOutputBuffer(NULL, index));
1218+}
1219+ 
1220+/**
1221+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_5600
1222+ * @tc.name : repeat OH_VideoDecoder_FreeOutputBuffer param error Greater than buffer count
1223+ * @tc.desc : function test
1224+ */
1225+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_5600, TestSize.Level2)
1226+{
1227+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
1228+ ASSERT_NE(NULL, vdec_);
1229+ 
1230+ OH_AVFormat *format = OH_AVFormat_Create();
1231+ ASSERT_NE(NULL, format);
1232+ 
1233+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
1234+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
1235+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
1236+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_ENABLE_SYNC_MODE, 2);
1237+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_YUVI420);
1238+ 
1239+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
1240+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
1241+ 
1242+ uint32_t index = 100;
1243+ ASSERT_NE(AV_ERR_OK, OH_VideoDecoder_FreeOutputBuffer(vdec_, index));
1244+}
1245+ 
1246+/**
1247+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_5700
1248+ * @tc.name : repeat OH_VideoDecoder_FreeOutputBuffer param correct
1249+ * @tc.desc : function test
1250+ */
1251+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_5700, TestSize.Level2)
1252+{
1253+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
1254+ ASSERT_NE(NULL, vdec_);
1255+ 
1256+ OH_AVFormat *format = OH_AVFormat_Create();
1257+ ASSERT_NE(NULL, format);
1258+ 
1259+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
1260+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
1261+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
1262+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_ENABLE_SYNC_MODE, 2);
1263+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_YUVI420);
1264+ 
1265+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
1266+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
1267+ 
1268+ uint32_t index = 0;
1269+ ASSERT_NE(AV_ERR_OK, OH_VideoDecoder_FreeOutputBuffer(vdec_, index));
1270+}
1271+ 
1272+/**
1273+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_5800
1274+ * @tc.name : repeat OH_VideoDecoder_RenderOutputBuffer param error NULL
1275+ * @tc.desc : function test
1276+ */
1277+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_5800, TestSize.Level2)
1278+{
1279+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
1280+ ASSERT_NE(NULL, vdec_);
1281+ 
1282+ OH_AVFormat *format = OH_AVFormat_Create();
1283+ ASSERT_NE(NULL, format);
1284+ 
1285+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
1286+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
1287+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
1288+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_ENABLE_SYNC_MODE, 2);
1289+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_YUVI420);
1290+ 
1291+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
1292+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
1293+ 
1294+ uint32_t index = 0;
1295+ ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoDecoder_RenderOutputBuffer(NULL, index));
1296+}
1297+ 
1298+/**
1299+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_5900
1300+ * @tc.name : repeat OH_VideoDecoder_RenderOutputBuffer param correct
1301+ * @tc.desc : function test
1302+ */
1303+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_5900, TestSize.Level2)
1304+{
1305+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
1306+ ASSERT_NE(NULL, vdec_);
1307+ 
1308+ OH_AVFormat *format = OH_AVFormat_Create();
1309+ ASSERT_NE(NULL, format);
1310+ 
1311+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
1312+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
1313+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
1314+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_ENABLE_SYNC_MODE, 2);
1315+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_YUVI420);
1316+ 
1317+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
1318+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
1319+ 
1320+ uint32_t index = 0;
1321+ ASSERT_NE(AV_ERR_OK, OH_VideoDecoder_RenderOutputBuffer(vdec_, index));
1322+}
1323+ 
1324+/**
1325+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_6000
1326+ * @tc.name : repeat OH_VideoDecoder_RenderOutputBufferAtTime param error NULL
1327+ * @tc.desc : function test
1328+ */
1329+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_6000, TestSize.Level2)
1330+{
1331+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
1332+ ASSERT_NE(NULL, vdec_);
1333+ 
1334+ OH_AVFormat *format = OH_AVFormat_Create();
1335+ ASSERT_NE(NULL, format);
1336+ 
1337+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
1338+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
1339+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
1340+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_ENABLE_SYNC_MODE, 2);
1341+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_YUVI420);
1342+ 
1343+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
1344+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
1345+ 
1346+ uint32_t index = 0;
1347+ int64_t renderTimestampNs = 0;
1348+ ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoDecoder_RenderOutputBufferAtTime(NULL, index, renderTimestampNs));
1349+}
1350+ 
1351+/**
1352+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_6100
1353+ * @tc.name : repeat OH_VideoDecoder_RenderOutputBufferAtTime param error Greater than buffer count
1354+ * @tc.desc : function test
1355+ */
1356+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_6100, TestSize.Level2)
1357+{
1358+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
1359+ ASSERT_NE(NULL, vdec_);
1360+ 
1361+ OH_AVFormat *format = OH_AVFormat_Create();
1362+ ASSERT_NE(NULL, format);
1363+ 
1364+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
1365+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
1366+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
1367+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_ENABLE_SYNC_MODE, 2);
1368+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_YUVI420);
1369+ 
1370+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
1371+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
1372+ 
1373+ uint32_t index = 100;
1374+ int64_t renderTimestampNs = 0;
1375+ ASSERT_NE(AV_ERR_OK, OH_VideoDecoder_RenderOutputBufferAtTime(vdec_, index, renderTimestampNs));
1376+}
1377+ 
1378+/**
1379+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_6200
1380+ * @tc.name : repeat OH_VideoDecoder_RenderOutputBufferAtTime param correct
1381+ * @tc.desc : function test
1382+ */
1383+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_6200, TestSize.Level2)
1384+{
1385+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
1386+ ASSERT_NE(NULL, vdec_);
1387+ 
1388+ OH_AVFormat *format = OH_AVFormat_Create();
1389+ ASSERT_NE(NULL, format);
1390+ 
1391+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
1392+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
1393+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
1394+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_ENABLE_SYNC_MODE, 2);
1395+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_YUVI420);
1396+ 
1397+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
1398+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
1399+ 
1400+ uint32_t index = 0;
1401+ int64_t renderTimestampNs = 100000000;
1402+ ASSERT_NE(AV_ERR_OK, OH_VideoDecoder_RenderOutputBufferAtTime(vdec_, index, renderTimestampNs));
1403+}
1404+ 
1405+/**
1406+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API_6300
1407+ * @tc.name : repeat OH_VideoDecoder_RenderOutputBufferAtTime param correct
1408+ * @tc.desc : function test
1409+ */
1410+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_API_6300, TestSize.Level2)
1411+{
1412+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
1413+ ASSERT_NE(NULL, vdec_);
1414+ 
1415+ OH_AVFormat *format = OH_AVFormat_Create();
1416+ ASSERT_NE(NULL, format);
1417+ 
1418+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
1419+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
1420+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
1421+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_ENABLE_SYNC_MODE, 2);
1422+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_YUVI420);
1423+ 
1424+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
1425+ ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Start(vdec_));
1426+ 
1427+ uint32_t index = 0;
1428+ int64_t renderTimestampNs = 0;
1429+ ASSERT_NE(AV_ERR_OK, OH_VideoDecoder_RenderOutputBufferAtTime(vdec_, index, renderTimestampNs));
1430+}
1431+ 
1432+/**
1433+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_0100
1434+ * @tc.name : OH_AVCapability_IsHardware param error NULL
1435+ * @tc.desc : function test
1436+ */
1437+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_0100, TestSize.Level1)
1438+{
1439+ cap = OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1440+ ASSERT_NE(nullptr, cap);
1441+ ASSERT_FALSE(OH_AVCapability_IsHardware(NULL));
1442+}
1443+ 
1444+/**
1445+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_0200
1446+ * @tc.name : OH_AVCapability_IsHardware param correct
1447+ * @tc.desc : function test
1448+ */
1449+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_0200, TestSize.Level1)
1450+{
1451+ cap = OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1452+ ASSERT_NE(nullptr, cap);
1453+ ASSERT_FALSE(OH_AVCapability_IsHardware(cap));
1454+}
1455+ 
1456+/**
1457+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_0300
1458+ * @tc.name : OH_AVCapability_GetMaxSupportedInstances param error NULL
1459+ * @tc.desc : function test
1460+ */
1461+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_0300, TestSize.Level1)
1462+{
1463+ cap = OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1464+ ASSERT_NE(nullptr, cap);
1465+ ASSERT_EQ(0, OH_AVCapability_GetMaxSupportedInstances(NULL));
1466+}
1467+ 
1468+/**
1469+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_0400
1470+ * @tc.name : OH_AVCapability_GetMaxSupportedInstances param correct
1471+ * @tc.desc : function test
1472+ */
1473+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_0400, TestSize.Level1)
1474+{
1475+ cap = OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1476+ ASSERT_NE(nullptr, cap);
1477+ ASSERT_EQ(VIDEO_INSTANCES_SIZE, OH_AVCapability_GetMaxSupportedInstances(cap));
1478+}
1479+ 
1480+/**
1481+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_0500
1482+ * @tc.name : OH_AVCapability_GetName param error
1483+ * @tc.desc : function test
1484+ */
1485+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_0500, TestSize.Level1)
1486+{
1487+ cap = OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1488+ ASSERT_NE(nullptr, cap);
1489+ ASSERT_NE(CODEC_NAME, OH_AVCapability_GetName(nullptr));
1490+}
1491+ 
1492+/**
1493+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_0600
1494+ * @tc.name : OH_AVCapability_GetName param correct
1495+ * @tc.desc : function test
1496+ */
1497+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_0600, TestSize.Level1)
1498+{
1499+ cap = OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1500+ ASSERT_NE(nullptr, cap);
1501+ ASSERT_EQ(CODEC_NAME, OH_AVCapability_GetName(cap));
1502+}
1503+ 
1504+/**
1505+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_0700
1506+ * @tc.name : OH_AVCapability_GetVideoWidthAlignment param error
1507+ * @tc.desc : api test
1508+ */
1509+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_0700, TestSize.Level1)
1510+{
1511+ OH_AVErrCode ret = AV_ERR_OK;
1512+ OH_AVCapability *capability =
1513+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1514+ ASSERT_NE(nullptr, capability);
1515+ ret = OH_AVCapability_GetVideoWidthAlignment(capability, nullptr);
1516+ ASSERT_EQ(AV_ERR_INVALID_VAL, ret);
1517+}
1518+ 
1519+/**
1520+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_0800
1521+ * @tc.name : OH_AVCapability_GetVideoWidthAlignment param error
1522+ * @tc.desc : api test
1523+ */
1524+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_0800, TestSize.Level1)
1525+{
1526+ OH_AVErrCode ret = AV_ERR_OK;
1527+ OH_AVCapability *capability =
1528+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1529+ ASSERT_NE(nullptr, capability);
1530+ int32_t alignment = 0;
1531+ ret = OH_AVCapability_GetVideoWidthAlignment(NULL, &alignment);
1532+ ASSERT_EQ(AV_ERR_INVALID_VAL, ret);
1533+}
1534+ 
1535+/**
1536+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_0900
1537+ * @tc.name : OH_AVCapability_GetVideoWidthAlignment param correct
1538+ * @tc.desc : api test
1539+ */
1540+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_0900, TestSize.Level1)
1541+{
1542+ OH_AVErrCode ret = AV_ERR_OK;
1543+ OH_AVCapability *capability =
1544+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1545+ ASSERT_NE(nullptr, capability);
1546+ int32_t alignment = 0;
1547+ ret = OH_AVCapability_GetVideoWidthAlignment(capability, &alignment);
1548+ cout << "WidthAlignment " << alignment << endl;
1549+ ASSERT_EQ(AV_ERR_OK, ret);
1550+ ASSERT_EQ(VIDEO_ALIGNMENT_SIZE, alignment);
1551+}
1552+ 
1553+/**
1554+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_1000
1555+ * @tc.name : OH_AVCapability_GetVideoHeightAlignment param error
1556+ * @tc.desc : api test
1557+ */
1558+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_1000, TestSize.Level1)
1559+{
1560+ OH_AVErrCode ret = AV_ERR_OK;
1561+ OH_AVCapability *capability =
1562+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1563+ ASSERT_NE(nullptr, capability);
1564+ ret = OH_AVCapability_GetVideoHeightAlignment(capability, nullptr);
1565+ ASSERT_EQ(AV_ERR_INVALID_VAL, ret);
1566+}
1567+ 
1568+/**
1569+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_1100
1570+ * @tc.name : OH_AVCapability_GetVideoHeightAlignment param error
1571+ * @tc.desc : api test
1572+ */
1573+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_1100, TestSize.Level1)
1574+{
1575+ OH_AVErrCode ret = AV_ERR_OK;
1576+ OH_AVCapability *capability =
1577+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1578+ ASSERT_NE(nullptr, capability);
1579+ int32_t alignment = 0;
1580+ ret = OH_AVCapability_GetVideoHeightAlignment(NULL, &alignment);
1581+ ASSERT_EQ(AV_ERR_INVALID_VAL, ret);
1582+}
1583+ 
1584+/**
1585+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_1200
1586+ * @tc.name : OH_AVCapability_GetVideoHeightAlignment param correct
1587+ * @tc.desc : api test
1588+ */
1589+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_1200, TestSize.Level1)
1590+{
1591+ OH_AVErrCode ret = AV_ERR_OK;
1592+ OH_AVCapability *capability =
1593+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1594+ ASSERT_NE(nullptr, capability);
1595+ int32_t alignment = 0;
1596+ ret = OH_AVCapability_GetVideoHeightAlignment(capability, &alignment);
1597+ cout << "HeightAlignment " << alignment << endl;
1598+ ASSERT_EQ(AV_ERR_OK, ret);
1599+ ASSERT_EQ(VIDEO_ALIGNMENT_SIZE, alignment);
1600+}
1601+ 
1602+/**
1603+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_1300
1604+ * @tc.name : OH_AVCapability_GetVideoWidthRangeForHeight param error
1605+ * @tc.desc : api test
1606+ */
1607+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_1300, TestSize.Level1)
1608+{
1609+ OH_AVErrCode ret = AV_ERR_OK;
1610+ OH_AVRange range;
1611+ memset_s(&range, sizeof(OH_AVRange), 0, sizeof(OH_AVRange));
1612+ OH_AVCapability *capability =
1613+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1614+ ASSERT_NE(nullptr, capability);
1615+ ret = OH_AVCapability_GetVideoWidthRangeForHeight(nullptr, DEFAULT_HEIGHT, &range);
1616+ ASSERT_EQ(AV_ERR_INVALID_VAL, ret);
1617+}
1618+ 
1619+/**
1620+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_1400
1621+ * @tc.name : OH_AVCapability_GetVideoWidthRangeForHeight param error
1622+ * @tc.desc : api test
1623+ */
1624+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_1400, TestSize.Level1)
1625+{
1626+ OH_AVErrCode ret = AV_ERR_OK;
1627+ OH_AVCapability *capability =
1628+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1629+ ASSERT_NE(nullptr, capability);
1630+ ret = OH_AVCapability_GetVideoWidthRangeForHeight(capability, DEFAULT_HEIGHT, nullptr);
1631+ ASSERT_EQ(AV_ERR_INVALID_VAL, ret);
1632+}
1633+ 
1634+/**
1635+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_1800
1636+ * @tc.name : OH_AVCapability_GetVideoHeightRangeForWidth param error
1637+ * @tc.desc : api test
1638+ */
1639+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_1800, TestSize.Level1)
1640+{
1641+ OH_AVErrCode ret = AV_ERR_OK;
1642+ OH_AVRange range;
1643+ memset_s(&range, sizeof(OH_AVRange), 0, sizeof(OH_AVRange));
1644+ OH_AVCapability *capability =
1645+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1646+ ASSERT_NE(nullptr, capability);
1647+ ret = OH_AVCapability_GetVideoHeightRangeForWidth(nullptr, DEFAULT_WIDTH, &range);
1648+ ASSERT_EQ(AV_ERR_INVALID_VAL, ret);
1649+}
1650+ 
1651+/**
1652+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_1900
1653+ * @tc.name : OH_AVCapability_GetVideoHeightRangeForWidth param error
1654+ * @tc.desc : api test
1655+ */
1656+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_1900, TestSize.Level1)
1657+{
1658+ OH_AVErrCode ret = AV_ERR_OK;
1659+ OH_AVCapability *capability =
1660+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1661+ ASSERT_NE(nullptr, capability);
1662+ ret = OH_AVCapability_GetVideoHeightRangeForWidth(capability, DEFAULT_WIDTH, nullptr);
1663+ ASSERT_EQ(AV_ERR_INVALID_VAL, ret);
1664+}
1665+ 
1666+/**
1667+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_2300
1668+ * @tc.name : OH_AVCapability_GetVideoWidthRange param error
1669+ * @tc.desc : api test
1670+ */
1671+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_2300, TestSize.Level1)
1672+{
1673+ OH_AVErrCode ret = AV_ERR_OK;
1674+ OH_AVCapability *capability =
1675+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1676+ ASSERT_NE(nullptr, capability);
1677+ ret = OH_AVCapability_GetVideoWidthRange(capability, nullptr);
1678+ ASSERT_EQ(AV_ERR_INVALID_VAL, ret);
1679+}
1680+ 
1681+/**
1682+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_2400
1683+ * @tc.name : OH_AVCapability_GetVideoWidthRange param error
1684+ * @tc.desc : api test
1685+ */
1686+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_2400, TestSize.Level1)
1687+{
1688+ OH_AVErrCode ret = AV_ERR_OK;
1689+ OH_AVRange range;
1690+ OH_AVCapability *capability =
1691+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1692+ ASSERT_NE(nullptr, capability);
1693+ ret = OH_AVCapability_GetVideoWidthRange(nullptr, &range);
1694+ ASSERT_EQ(AV_ERR_INVALID_VAL, ret);
1695+}
1696+ 
1697+/**
1698+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_2600
1699+ * @tc.name : OH_AVCapability_GetVideoHeightRange param error
1700+ * @tc.desc : api test
1701+ */
1702+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_2600, TestSize.Level1)
1703+{
1704+ OH_AVErrCode ret = AV_ERR_OK;
1705+ OH_AVCapability *capability =
1706+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1707+ ASSERT_NE(nullptr, capability);
1708+ ret = OH_AVCapability_GetVideoHeightRange(capability, nullptr);
1709+ ASSERT_EQ(AV_ERR_INVALID_VAL, ret);
1710+}
1711+ 
1712+/**
1713+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_2700
1714+ * @tc.name : OH_AVCapability_GetVideoHeightRange param error
1715+ * @tc.desc : api test
1716+ */
1717+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_2700, TestSize.Level1)
1718+{
1719+ OH_AVErrCode ret = AV_ERR_OK;
1720+ OH_AVRange range;
1721+ OH_AVCapability *capability =
1722+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1723+ ASSERT_NE(nullptr, capability);
1724+ ret = OH_AVCapability_GetVideoHeightRange(nullptr, &range);
1725+ ASSERT_EQ(AV_ERR_INVALID_VAL, ret);
1726+}
1727+ 
1728+/**
1729+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_3000
1730+ * @tc.name : OH_AVCapability_IsVideoSizeSupported param error
1731+ * @tc.desc : api test
1732+ */
1733+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_3000, TestSize.Level1)
1734+{
1735+ OH_AVCapability *capability =
1736+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1737+ ASSERT_NE(nullptr, capability);
1738+ ASSERT_EQ(false, OH_AVCapability_IsVideoSizeSupported(NULL, DEFAULT_WIDTH, DEFAULT_HEIGHT));
1739+}
1740+ 
1741+/**
1742+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_3100
1743+ * @tc.name : OH_AVCapability_IsVideoSizeSupported param error
1744+ * @tc.desc : api test
1745+ */
1746+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_3100, TestSize.Level1)
1747+{
1748+ OH_AVCapability *capability =
1749+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1750+ ASSERT_NE(nullptr, capability);
1751+ ASSERT_EQ(false, OH_AVCapability_IsVideoSizeSupported(capability, 0, DEFAULT_HEIGHT));
1752+}
1753+ 
1754+/**
1755+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_3200
1756+ * @tc.name : OH_AVCapability_IsVideoSizeSupported param error
1757+ * @tc.desc : api test
1758+ */
1759+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_3200, TestSize.Level1)
1760+{
1761+ OH_AVCapability *capability =
1762+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1763+ ASSERT_NE(nullptr, capability);
1764+ ASSERT_EQ(false, OH_AVCapability_IsVideoSizeSupported(capability, DEFAULT_WIDTH, 0));
1765+}
1766+ 
1767+/**
1768+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_3300
1769+ * @tc.name : OH_AVCapability_IsVideoSizeSupported param correct
1770+ * @tc.desc : api test
1771+ */
1772+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_3300, TestSize.Level1)
1773+{
1774+ OH_AVCapability *capability =
1775+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1776+ ASSERT_NE(nullptr, capability);
1777+ ASSERT_EQ(false, OH_AVCapability_IsVideoSizeSupported(capability, DEFAULT_WIDTH, DEFAULT_HEIGHT));
1778+}
1779+ 
1780+/**
1781+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_3600
1782+ * @tc.name : OH_AVCapability_GetVideoFrameRateRange param error
1783+ * @tc.desc : api test
1784+ */
1785+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_3600, TestSize.Level1)
1786+{
1787+ OH_AVErrCode ret = AV_ERR_OK;
1788+ OH_AVCapability *capability =
1789+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1790+ ASSERT_NE(nullptr, capability);
1791+ ret = OH_AVCapability_GetVideoFrameRateRange(capability, nullptr);
1792+ ASSERT_EQ(AV_ERR_INVALID_VAL, ret);
1793+}
1794+ 
1795+/**
1796+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_3700
1797+ * @tc.name : OH_AVCapability_GetVideoFrameRateRange param error
1798+ * @tc.desc : api test
1799+ */
1800+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_3700, TestSize.Level1)
1801+{
1802+ OH_AVErrCode ret = AV_ERR_OK;
1803+ OH_AVCapability *capability =
1804+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1805+ ASSERT_NE(nullptr, capability);
1806+ OH_AVRange range;
1807+ memset_s(&range, sizeof(OH_AVRange), 0, sizeof(OH_AVRange));
1808+ ret = OH_AVCapability_GetVideoFrameRateRange(NULL, &range);
1809+ ASSERT_EQ(AV_ERR_INVALID_VAL, ret);
1810+}
1811+ 
1812+/**
1813+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_3800
1814+ * @tc.name : OH_AVCapability_GetVideoFrameRateRangeForSize param error
1815+ * @tc.desc : api test
1816+ */
1817+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_3800, TestSize.Level1)
1818+{
1819+ OH_AVErrCode ret = AV_ERR_OK;
1820+ OH_AVCapability *capability =
1821+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1822+ ASSERT_NE(nullptr, capability);
1823+ OH_AVRange range;
1824+ memset_s(&range, sizeof(OH_AVRange), 0, sizeof(OH_AVRange));
1825+ ret = OH_AVCapability_GetVideoFrameRateRangeForSize(NULL, DEFAULT_WIDTH, DEFAULT_HEIGHT, &range);
1826+ ASSERT_EQ(AV_ERR_INVALID_VAL, ret);
1827+}
1828+ 
1829+/**
1830+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_3900
1831+ * @tc.name : OH_AVCapability_GetVideoFrameRateRangeForSize param error
1832+ * @tc.desc : api test
1833+ */
1834+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_3900, TestSize.Level1)
1835+{
1836+ OH_AVErrCode ret = AV_ERR_OK;
1837+ OH_AVCapability *capability =
1838+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1839+ ASSERT_NE(nullptr, capability);
1840+ ret = OH_AVCapability_GetVideoFrameRateRangeForSize(capability, DEFAULT_WIDTH, DEFAULT_HEIGHT, nullptr);
1841+ ASSERT_EQ(AV_ERR_INVALID_VAL, ret);
1842+}
1843+ 
1844+/**
1845+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_4000
1846+ * @tc.name : OH_AVCapability_AreVideoSizeAndFrameRateSupported param error
1847+ * @tc.desc : api test
1848+ */
1849+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_4000, TestSize.Level1)
1850+{
1851+ OH_AVCapability *capability =
1852+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1853+ ASSERT_NE(nullptr, capability);
1854+ ASSERT_EQ(false, OH_AVCapability_AreVideoSizeAndFrameRateSupported(NULL, 0, DEFAULT_HEIGHT,
1855+ VIDEO_DEFAULT_FRAME_RATE_SIZE));
1856+}
1857+ 
1858+/**
1859+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_4400
1860+ * @tc.name : OH_AVCapability_AreVideoSizeAndFrameRateSupported param error
1861+ * @tc.desc : api test
1862+ */
1863+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_4400, TestSize.Level1)
1864+{
1865+ OH_AVCapability *capability =
1866+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1867+ ASSERT_NE(nullptr, capability);
1868+ ASSERT_EQ(false, OH_AVCapability_AreVideoSizeAndFrameRateSupported(capability, 0, DEFAULT_HEIGHT,
1869+ VIDEO_DEFAULT_FRAME_RATE_SIZE));
1870+}
1871+ 
1872+/**
1873+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_4500
1874+ * @tc.name : OH_AVCapability_AreVideoSizeAndFrameRateSupported param error
1875+ * @tc.desc : api test
1876+ */
1877+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_4500, TestSize.Level1)
1878+{
1879+ OH_AVCapability *capability =
1880+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1881+ ASSERT_NE(nullptr, capability);
1882+ ASSERT_EQ(false, OH_AVCapability_AreVideoSizeAndFrameRateSupported(capability, DEFAULT_WIDTH, 0,
1883+ VIDEO_DEFAULT_FRAME_RATE_SIZE));
1884+}
1885+ 
1886+/**
1887+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_4600
1888+ * @tc.name : OH_AVCapability_AreVideoSizeAndFrameRateSupported param error
1889+ * @tc.desc : api test
1890+ */
1891+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_4600, TestSize.Level1)
1892+{
1893+ OH_AVCapability *capability =
1894+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1895+ ASSERT_NE(nullptr, capability);
1896+ ASSERT_EQ(false, OH_AVCapability_AreVideoSizeAndFrameRateSupported(capability, DEFAULT_WIDTH, DEFAULT_HEIGHT, 0));
1897+}
1898+ 
1899+/**
1900+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_4700
1901+ * @tc.name : OH_AVCapability_AreVideoSizeAndFrameRateSupported param correct
1902+ * @tc.desc : api test
1903+ */
1904+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_4700, TestSize.Level1)
1905+{
1906+ OH_AVCapability *capability =
1907+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1908+ ASSERT_NE(nullptr, capability);
1909+ ASSERT_EQ(false, OH_AVCapability_AreVideoSizeAndFrameRateSupported(capability, DEFAULT_WIDTH, DEFAULT_HEIGHT,
1910+ VIDEO_DEFAULT_FRAME_RATE_SIZE));
1911+}
1912+ 
1913+/**
1914+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_4800
1915+ * @tc.name : OH_AVCapability_GetVideoSupportedPixelFormats param error
1916+ * @tc.desc : api test
1917+ */
1918+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_4800, TestSize.Level1)
1919+{
1920+ OH_AVErrCode ret = AV_ERR_OK;
1921+ uint32_t pixelFormatNum = 0;
1922+ OH_AVCapability *capability =
1923+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1924+ ASSERT_NE(nullptr, capability);
1925+ const int32_t *pixelFormat = nullptr;
1926+ ret = OH_AVCapability_GetVideoSupportedPixelFormats(NULL, &pixelFormat, &pixelFormatNum);
1927+ ASSERT_EQ(AV_ERR_INVALID_VAL, ret);
1928+}
1929+ 
1930+/**
1931+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_4900
1932+ * @tc.name : OH_AVCapability_GetVideoSupportedPixelFormats param error
1933+ * @tc.desc : api test
1934+ */
1935+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_4900, TestSize.Level1)
1936+{
1937+ OH_AVErrCode ret = AV_ERR_OK;
1938+ uint32_t pixelFormatNum = 0;
1939+ OH_AVCapability *capability =
1940+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1941+ ASSERT_NE(nullptr, capability);
1942+ ret = OH_AVCapability_GetVideoSupportedPixelFormats(capability, nullptr, &pixelFormatNum);
1943+ ASSERT_EQ(AV_ERR_INVALID_VAL, ret);
1944+}
1945+ 
1946+/**
1947+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_5000
1948+ * @tc.name : OH_AVCapability_GetVideoSupportedPixelFormats param error
1949+ * @tc.desc : api test
1950+ */
1951+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_5000, TestSize.Level1)
1952+{
1953+ OH_AVErrCode ret = AV_ERR_OK;
1954+ const int32_t *pixelFormat = nullptr;
1955+ OH_AVCapability *capability =
1956+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1957+ ASSERT_NE(nullptr, capability);
1958+ ret = OH_AVCapability_GetVideoSupportedPixelFormats(capability, &pixelFormat, nullptr);
1959+ ASSERT_EQ(AV_ERR_INVALID_VAL, ret);
1960+}
1961+ 
1962+/**
1963+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_5100
1964+ * @tc.name : OH_AVCapability_GetVideoSupportedPixelFormats param correct
1965+ * @tc.desc : api test
1966+ */
1967+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_5100, TestSize.Level1)
1968+{
1969+ OH_AVErrCode ret = AV_ERR_OK;
1970+ const int32_t *pixelFormat = nullptr;
1971+ uint32_t pixelFormatNum = 0;
1972+ OH_AVCapability *capability =
1973+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
1974+ ASSERT_NE(nullptr, capability);
1975+ ret = OH_AVCapability_GetVideoSupportedPixelFormats(capability, &pixelFormat, &pixelFormatNum);
1976+ ASSERT_NE(nullptr, pixelFormat);
1977+ ASSERT_EQ(PIXFORMAT_NUM, pixelFormatNum);
1978+ ASSERT_EQ(AV_ERR_OK, ret);
1979+ for (int i = 0; i < pixelFormatNum; i++) {
1980+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
1981+ ASSERT_NE(nullptr, vdec_);
1982+ format = OH_AVFormat_Create();
1983+ ASSERT_NE(nullptr, format);
1984+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
1985+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
1986+ EXPECT_EQ(pixelFormat[i], i == pixelFormatNum - 1 ? i + 2 : i + 1);
1987+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, pixelFormat[i]);
1988+ EXPECT_EQ(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
1989+ OH_AVFormat_Destroy(format);
1990+ OH_VideoDecoder_Destroy(vdec_);
1991+ }
1992+ vdec_ = OH_VideoDecoder_CreateByName(CODEC_NAME.c_str());
1993+ ASSERT_NE(nullptr, vdec_);
1994+ format = OH_AVFormat_Create();
1995+ ASSERT_NE(nullptr, format);
1996+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
1997+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
1998+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_RGBA + AV_PIXEL_FORMAT_RGBA);
1999+ ASSERT_NE(AV_ERR_OK, OH_VideoDecoder_Configure(vdec_, format));
2000+}
2001+ 
2002+/**
2003+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_5200
2004+ * @tc.name : OH_AVCapability_GetSupportedProfiles param error
2005+ * @tc.desc : api test
2006+ */
2007+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_5200, TestSize.Level1)
2008+{
2009+ OH_AVErrCode ret = AV_ERR_OK;
2010+ const int32_t *profiles = nullptr;
2011+ OH_AVCapability *capability =
2012+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
2013+ ASSERT_NE(nullptr, capability);
2014+ ret = OH_AVCapability_GetSupportedProfiles(capability, &profiles, nullptr);
2015+ ASSERT_EQ(AV_ERR_INVALID_VAL, ret);
2016+}
2017+ 
2018+/**
2019+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_5300
2020+ * @tc.name : OH_AVCapability_GetSupportedProfiles param error
2021+ * @tc.desc : api test
2022+ */
2023+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_5300, TestSize.Level1)
2024+{
2025+ OH_AVErrCode ret = AV_ERR_OK;
2026+ uint32_t profileNum = 0;
2027+ OH_AVCapability *capability =
2028+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
2029+ ASSERT_NE(nullptr, capability);
2030+ ret = OH_AVCapability_GetSupportedProfiles(capability, nullptr, &profileNum);
2031+ ASSERT_EQ(AV_ERR_INVALID_VAL, ret);
2032+}
2033+ 
2034+/**
2035+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_5400
2036+ * @tc.name : OH_AVCapability_GetSupportedProfiles param error
2037+ * @tc.desc : api test
2038+ */
2039+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_5400, TestSize.Level1)
2040+{
2041+ OH_AVErrCode ret = AV_ERR_OK;
2042+ const int32_t *profiles = nullptr;
2043+ uint32_t profileNum = 0;
2044+ OH_AVCapability *capability =
2045+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
2046+ ASSERT_NE(nullptr, capability);
2047+ ret = OH_AVCapability_GetSupportedProfiles(nullptr, &profiles, &profileNum);
2048+ ASSERT_EQ(AV_ERR_INVALID_VAL, ret);
2049+ ASSERT_EQ(0, profileNum);
2050+ ASSERT_EQ(nullptr, profiles);
2051+}
2052+ 
2053+/**
2054+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_5500
2055+ * @tc.name : OH_AVCapability_GetSupportedProfiles param error
2056+ * @tc.desc : api test
2057+ */
2058+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_5500, TestSize.Level1)
2059+{
2060+ const int32_t *profiles = nullptr;
2061+ uint32_t profileNum = 0;
2062+ OH_AVCapability *capability =
2063+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
2064+ ASSERT_NE(nullptr, capability);
2065+ OH_AVErrCode ret = OH_AVCapability_GetSupportedProfiles(nullptr, nullptr, &profileNum);
2066+ ASSERT_EQ(AV_ERR_INVALID_VAL, ret);
2067+ ASSERT_EQ(0, profileNum);
2068+ ASSERT_EQ(nullptr, profiles);
2069+}
2070+ 
2071+/**
2072+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_5800
2073+ * @tc.name : OH_AVCapability_AreProfileAndLevelSupported param error
2074+ * @tc.desc : api test
2075+ */
2076+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_5800, TestSize.Level1)
2077+{
2078+ OH_AVCapability *capability =
2079+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
2080+ ASSERT_NE(nullptr, capability);
2081+ int32_t profile = 1;
2082+ int32_t level = 1;
2083+ ASSERT_EQ(false, OH_AVCapability_AreProfileAndLevelSupported(NULL, profile, level));
2084+}
2085+ 
2086+/**
2087+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_5900
2088+ * @tc.name : OH_AVCapability_AreProfileAndLevelSupported param error
2089+ * @tc.desc : api test
2090+ */
2091+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_5900, TestSize.Level1)
2092+{
2093+ OH_AVCapability *capability =
2094+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
2095+ ASSERT_NE(nullptr, capability);
2096+ int32_t profile = -1;
2097+ int32_t level = 1;
2098+ ASSERT_EQ(false, OH_AVCapability_AreProfileAndLevelSupported(capability, profile, level));
2099+}
2100+ 
2101+/**
2102+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_6000
2103+ * @tc.name : OH_AVCapability_AreProfileAndLevelSupported param error
2104+ * @tc.desc : api test
2105+ */
2106+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_6000, TestSize.Level1)
2107+{
2108+ OH_AVCapability *capability =
2109+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
2110+ ASSERT_NE(nullptr, capability);
2111+ int32_t profile = 1;
2112+ int32_t level = -1;
2113+ ASSERT_EQ(false, OH_AVCapability_AreProfileAndLevelSupported(capability, profile, level));
2114+}
2115+ 
2116+/**
2117+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_6100
2118+ * @tc.name : OH_AVCapability_AreProfileAndLevelSupported param error
2119+ * @tc.desc : api test
2120+ */
2121+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_6100, TestSize.Level1)
2122+{
2123+ OH_AVCapability *capability =
2124+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
2125+ ASSERT_NE(nullptr, capability);
2126+ int32_t profile = 1;
2127+ int32_t level = 1;
2128+ ASSERT_EQ(false, OH_AVCapability_AreProfileAndLevelSupported(capability, profile, level));
2129+}
2130+ 
2131+/**
2132+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_7000
2133+ * @tc.name : OH_AVCapability_IsFeatureSupported param error
2134+ * @tc.desc : api test
2135+ */
2136+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_7000, TestSize.Level1)
2137+{
2138+ OH_AVCapability *capability =
2139+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
2140+ ASSERT_NE(nullptr, capability);
2141+ ASSERT_EQ(false, OH_AVCapability_IsFeatureSupported(capability, VIDEO_LOW_LATENCY));
2142+}
2143+ 
2144+/**
2145+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_7100
2146+ * @tc.name : OH_AVCapability_GetFeatureProperties param error
2147+ * @tc.desc : api test
2148+ */
2149+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_7100, TestSize.Level1)
2150+{
2151+ OH_AVCapability *capability =
2152+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
2153+ ASSERT_NE(nullptr, capability);
2154+ OH_AVFormat *format = OH_AVCapability_GetFeatureProperties(capability, VIDEO_LOW_LATENCY);
2155+ ASSERT_EQ(nullptr, format);
2156+}
2157+ 
2158+/**
2159+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_7200
2160+ * @tc.name : OH_AVCodec_GetCapabilityByCategory param error NULL
2161+ * @tc.desc : api test
2162+ */
2163+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_7200, TestSize.Level1)
2164+{
2165+ OH_AVCapability *capability = OH_AVCodec_GetCapabilityByCategory(NULL, false, SOFTWARE);
2166+ ASSERT_EQ(nullptr, capability);
2167+}
2168+ 
2169+/**
2170+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_7300
2171+ * @tc.name : OH_AVCodec_GetCapabilityByCategory param error NULL
2172+ * @tc.desc : api test
2173+ */
2174+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_7300, TestSize.Level1)
2175+{
2176+ OH_AVCapability *capability = OH_AVCodec_GetCapabilityByCategory("", false, SOFTWARE);
2177+ ASSERT_EQ(nullptr, capability);
2178+}
2179+ 
2180+/**
2181+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_7400
2182+ * @tc.name : OH_AVCodec_GetCapabilityByCategory param correct
2183+ * @tc.desc : api test
2184+ */
2185+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_7400, TestSize.Level1)
2186+{
2187+ OH_AVCapability *capability =
2188+ OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
2189+ ASSERT_NE(nullptr, capability);
2190+}
2191+ 
2192+/**
2193+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_7500
2194+ * @tc.name : OH_AVCodec_GetCapability param error NULL
2195+ * @tc.desc : api test
2196+ */
2197+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_7500, TestSize.Level1)
2198+{
2199+ OH_AVCapability *capability = OH_AVCodec_GetCapability(NULL, false);
2200+ ASSERT_EQ(nullptr, capability);
2201+}
2202+ 
2203+/**
2204+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_7600
2205+ * @tc.name : OH_AVCodec_GetCapability param error NULL
2206+ * @tc.desc : api test
2207+ */
2208+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_7600, TestSize.Level1)
2209+{
2210+ OH_AVCapability *capability = OH_AVCodec_GetCapability("", false);
2211+ ASSERT_EQ(nullptr, capability);
2212+}
2213+ 
2214+/**
2215+ * @tc.number : VIDEO_SWDEC_DVVIDEO_CAP_API_7700
2216+ * @tc.name : OH_AVCodec_GetCapability param correct
2217+ * @tc.desc : api test
2218+ */
2219+HWTEST_F(DVVideoSwdecApiNdkTest, VIDEO_SWDEC_DVVIDEO_CAP_API_7700, TestSize.Level1)
2220+{
2221+ OH_AVCapability *capability = OH_AVCodec_GetCapability(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false);
2222+ ASSERT_NE(nullptr, capability);
2223+}
2224+ 
2225+} // namespace
Atest/moduletest/vcodec/dvvideoswdecoder/src/func_test.cpp+1364-0
@@ -0,0 +1,1364 @@
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+#include <string>
16+ 
17+#include "avcodec_codec_name.h"
18+#include "gtest/gtest.h"
19+#include "native_avcapability.h"
20+#include "native_avcodec_base.h"
21+#include "native_avcodec_videodecoder.h"
22+#include "native_averrors.h"
23+#include "native_avformat.h"
24+#include "videodec_api11_sample.h"
25+ 
26+#ifdef SUPPORT_DRM
27+#include "native_mediakeysession.h"
28+#include "native_mediakeysystem.h"
29+#endif
30+ 
31+using namespace std;
32+using namespace OHOS;
33+using namespace OHOS::Media;
34+using namespace testing::ext;
35+ 
36+namespace OHOS {
37+namespace Media {
38+class DVVideoSwdecFuncNdkTest : public testing::Test {
39+public:
40+ static void SetUpTestCase();
41+ static void TearDownTestCase();
42+ void SetUp() override;
43+ void TearDown() override;
44+ void InputFunc();
45+ void OutputFunc();
46+ void Release();
47+ int32_t Stop();
48+ 
49+protected:
50+ const char *INP_DIR_0 = "/data/test/media/dvvideo_720x576_yuv420p_25_25frames.avi";
51+ const char *INP_DIR_1 = "/data/test/media/dvvideo_720x576_yuv422p_25_25frames.avi";
52+ const char *INP_DIR_2 = "/data/test/media/dvvideo_720x576_yuv411p_25_25frames.avi";
53+ const char *INP_DIR_3 = "/data/test/media/dvvideo_720x480_yuv422p_30_25frames.avi";
54+ const char *INP_DIR_4 = "/data/test/media/dvvideo_720x480_yuv411p_30_25frames.avi";
55+ const char *INP_DIR_5 = "/data/test/media/dvvideo_960x720_yuv422p_50_25frames.avi";
56+ const char *INP_DIR_6 = "/data/test/media/dvvideo_960x720_yuv422p_60_25frames.avi";
57+ const char *INP_DIR_7 = "/data/test/media/dvvideo_1280x1080_yuv422p_30_25frames.avi";
58+ const char *INP_DIR_8 = "/data/test/media/dvvideo_1440x1080_yuv422p_25_25frames.avi";
59+ const char *INP_DIR_9 = "/data/test/media/dvvideo_720x480_yuv411p_30_25frames.mkv";
60+ const char *INP_DIR_10 = "/data/test/media/dvvideo_720x480_yuv411p_30_25frames.mov";
61+};
62+} // namespace Media
63+} // namespace OHOS
64+ 
65+namespace {
66+static OH_AVCapability *cap_dvvideo = nullptr;
67+static string g_codecNameDVVideo = "";
68+static OH_AVCapability *cap_264 = nullptr;
69+static string g_codecName264 = "";
70+constexpr uint32_t FRAMESIZE25 = 25;
71+ 
72+} // namespace
73+ 
74+void DVVideoSwdecFuncNdkTest::SetUpTestCase()
75+{
76+ cap_dvvideo = OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO, false, SOFTWARE);
77+ g_codecNameDVVideo = OH_AVCapability_GetName(cap_dvvideo);
78+ cout << "g_codecNameDVVideo: " << g_codecNameDVVideo << endl;
79+ cap_264 = OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_AVC, false, SOFTWARE);
80+ g_codecName264 = OH_AVCapability_GetName(cap_264);
81+ cout << "g_codecName264: " << g_codecName264 << endl;
82+}
83+ 
84+void DVVideoSwdecFuncNdkTest::TearDownTestCase()
85+{
86+}
87+void DVVideoSwdecFuncNdkTest::SetUp()
88+{
89+}
90+void DVVideoSwdecFuncNdkTest::TearDown()
91+{
92+}
93+ 
94+namespace {
95+ 
96+/**
97+ * @tc.number : VIDEO_SWDEC_DVVIDEO_FUNCTION_0010
98+ * @tc.name : decoder dvvideo,buffer,AsyncMode,dvvideo_720x576_yuv420p_25_25frames OutputPixelFormat:yuv420->NV12
99+ * @tc.desc : function test
100+ */
101+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_FUNCTION_0010, TestSize.Level0)
102+{
103+ auto vDecSample = make_shared<VDecAPI11Sample>();
104+ vDecSample->DEFAULT_WIDTH = 720;
105+ vDecSample->DEFAULT_HEIGHT = 576;
106+ vDecSample->DEFAULT_FRAME_RATE = 25;
107+ vDecSample->outputYuvFlag = true;
108+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV12;
109+ vDecSample->OUT_DIR = "/data/test/media/dv_func_0010_720x576_25fps_nv12.yuv";
110+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_0));
111+ ASSERT_EQ(AV_ERR_OK, vDecSample->CreateVideoDecoder("OH.Media.Codec.Decoder.Video.DVVIDEO"));
112+ ASSERT_EQ(AV_ERR_OK, vDecSample->ConfigureVideoDecoder());
113+ ASSERT_EQ(AV_ERR_OK, vDecSample->SetVideoDecoderCallback());
114+ ASSERT_EQ(AV_ERR_OK, vDecSample->StartVideoDecoder());
115+ vDecSample->WaitForEOS();
116+ ASSERT_EQ(0, vDecSample->errCount);
117+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
118+}
119+ 
120+/**
121+ * @tc.number : VIDEO_SWDEC_DVVIDEO_FUNCTION_0020
122+ * @tc.name : decoder dvvideo,buffer,AsyncMode,dvvideo_720x576_yuv420p_25_25frames OutputPixelFormat:yuv420->NV21
123+ * @tc.desc : function test
124+ */
125+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_FUNCTION_0020, TestSize.Level0)
126+{
127+ auto vDecSample = make_shared<VDecAPI11Sample>();
128+ vDecSample->DEFAULT_WIDTH = 720;
129+ vDecSample->DEFAULT_HEIGHT = 576;
130+ vDecSample->DEFAULT_FRAME_RATE = 25;
131+ vDecSample->outputYuvFlag = true;
132+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV21;
133+ vDecSample->OUT_DIR = "/data/test/media/dv_func_0020_720x576_25fps_nv21.yuv";
134+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_0));
135+ ASSERT_EQ(AV_ERR_OK, vDecSample->CreateVideoDecoder("OH.Media.Codec.Decoder.Video.DVVIDEO"));
136+ ASSERT_EQ(AV_ERR_OK, vDecSample->ConfigureVideoDecoder());
137+ ASSERT_EQ(AV_ERR_OK, vDecSample->SetVideoDecoderCallback());
138+ ASSERT_EQ(AV_ERR_OK, vDecSample->StartVideoDecoder());
139+ vDecSample->WaitForEOS();
140+ ASSERT_EQ(0, vDecSample->errCount);
141+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
142+}
143+ 
144+/**
145+ * @tc.number : VIDEO_SWDEC_DVVIDEO_FUNCTION_0030
146+ * @tc.name : decoder dvvideo,buffer,AsyncMode,dvvideo_720x576_yuv420p_25_25frames OutputPixelFormat:yuv420->I420
147+ * @tc.desc : function test
148+ */
149+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_FUNCTION_0030, TestSize.Level0)
150+{
151+ auto vDecSample = make_shared<VDecAPI11Sample>();
152+ vDecSample->DEFAULT_WIDTH = 720;
153+ vDecSample->DEFAULT_HEIGHT = 576;
154+ vDecSample->DEFAULT_FRAME_RATE = 25;
155+ vDecSample->outputYuvFlag = true;
156+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_YUVI420;
157+ vDecSample->OUT_DIR = "/data/test/media/dv_func_0030_720x576_25fps_I420.yuv";
158+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_0));
159+ ASSERT_EQ(AV_ERR_OK, vDecSample->CreateVideoDecoder("OH.Media.Codec.Decoder.Video.DVVIDEO"));
160+ ASSERT_EQ(AV_ERR_OK, vDecSample->ConfigureVideoDecoder());
161+ ASSERT_EQ(AV_ERR_OK, vDecSample->SetVideoDecoderCallback());
162+ ASSERT_EQ(AV_ERR_OK, vDecSample->StartVideoDecoder());
163+ vDecSample->WaitForEOS();
164+ ASSERT_EQ(0, vDecSample->errCount);
165+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
166+}
167+ 
168+/**
169+ * @tc.number : VIDEO_SWDEC_DVVIDEO_FUNCTION_0040
170+ * @tc.name : decoder dvvideo,buffer,AsyncMode,dvvideo_720x576_yuv420p_25_25frames OutputPixelFormat:yuv420->RGBA
171+ * @tc.desc : function test
172+ */
173+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_FUNCTION_0040, TestSize.Level0)
174+{
175+ auto vDecSample = make_shared<VDecAPI11Sample>();
176+ vDecSample->DEFAULT_WIDTH = 720;
177+ vDecSample->DEFAULT_HEIGHT = 576;
178+ vDecSample->DEFAULT_FRAME_RATE = 25;
179+ vDecSample->outputYuvFlag = true;
180+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_RGBA;
181+ vDecSample->OUT_DIR = "/data/test/media/dv_func_0040_720x576_25fps_rgba.rgba";
182+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_0));
183+ ASSERT_EQ(AV_ERR_OK, vDecSample->CreateVideoDecoder("OH.Media.Codec.Decoder.Video.DVVIDEO"));
184+ ASSERT_EQ(AV_ERR_OK, vDecSample->ConfigureVideoDecoder());
185+ ASSERT_EQ(AV_ERR_OK, vDecSample->SetVideoDecoderCallback());
186+ ASSERT_EQ(AV_ERR_OK, vDecSample->StartVideoDecoder());
187+ vDecSample->WaitForEOS();
188+ ASSERT_EQ(0, vDecSample->errCount);
189+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
190+}
191+ 
192+/**
193+ * @tc.number : VIDEO_SWDEC_DVVIDEO_FUNCTION_0050
194+ * @tc.name : decoder dvvideo,buffer,AsyncMode,dvvideo_720x576_yuv422p_25_25frames OutputPixelFormat:yuv422p->NV12
195+ * @tc.desc : function test
196+ */
197+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_FUNCTION_0050, TestSize.Level1)
198+{
199+ auto vDecSample = make_shared<VDecAPI11Sample>();
200+ vDecSample->DEFAULT_WIDTH = 720;
201+ vDecSample->DEFAULT_HEIGHT = 576;
202+ vDecSample->DEFAULT_FRAME_RATE = 25;
203+ vDecSample->outputYuvFlag = true;
204+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV12;
205+ vDecSample->OUT_DIR = "/data/test/media/dv_func_0050_720x576_25fps_nv12.yuv";
206+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_1));
207+ ASSERT_EQ(AV_ERR_OK, vDecSample->CreateVideoDecoder("OH.Media.Codec.Decoder.Video.DVVIDEO"));
208+ ASSERT_EQ(AV_ERR_OK, vDecSample->ConfigureVideoDecoder());
209+ ASSERT_EQ(AV_ERR_OK, vDecSample->SetVideoDecoderCallback());
210+ ASSERT_EQ(AV_ERR_OK, vDecSample->StartVideoDecoder());
211+ vDecSample->WaitForEOS();
212+ ASSERT_EQ(0, vDecSample->errCount);
213+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
214+}
215+ 
216+/**
217+ * @tc.number : VIDEO_SWDEC_DVVIDEO_FUNCTION_0060
218+ * @tc.name : decode dvvideo buffer,nv21,dvvideo_720x576_yuv411p_25_25frames
219+ * @tc.desc : function test
220+ */
221+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_FUNCTION_0060, TestSize.Level1)
222+{
223+ auto vDecSample = make_shared<VDecAPI11Sample>();
224+ vDecSample->DEFAULT_WIDTH = 720;
225+ vDecSample->DEFAULT_HEIGHT = 576;
226+ vDecSample->DEFAULT_FRAME_RATE = 25;
227+ vDecSample->outputYuvFlag = true;
228+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV21;
229+ vDecSample->OUT_DIR = "/data/test/media/dv_func_0060_720x576_25fps_nv21.yuv";
230+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_2));
231+ ASSERT_EQ(AV_ERR_OK, vDecSample->CreateVideoDecoder("OH.Media.Codec.Decoder.Video.DVVIDEO"));
232+ ASSERT_EQ(AV_ERR_OK, vDecSample->ConfigureVideoDecoder());
233+ ASSERT_EQ(AV_ERR_OK, vDecSample->SetVideoDecoderCallback());
234+ ASSERT_EQ(AV_ERR_OK, vDecSample->StartVideoDecoder());
235+ vDecSample->WaitForEOS();
236+ ASSERT_EQ(0, vDecSample->errCount);
237+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
238+}
239+ 
240+/**
241+ * @tc.number : VIDEO_SWDEC_DVVIDEO_FUNCTION_0070
242+ * @tc.name : decoder dvvideo,buffer,AsyncMode,dvvideo_720x480_yuv422p_30_25frames OutputPixelFormat:yuv422p->NV12
243+ * @tc.desc : function test
244+ */
245+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_FUNCTION_0070, TestSize.Level1)
246+{
247+ auto vDecSample = make_shared<VDecAPI11Sample>();
248+ vDecSample->DEFAULT_WIDTH = 720;
249+ vDecSample->DEFAULT_HEIGHT = 480;
250+ vDecSample->DEFAULT_FRAME_RATE = 30;
251+ vDecSample->outputYuvFlag = true;
252+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV12;
253+ vDecSample->OUT_DIR = "/data/test/media/dv_func_0070_720x480_30fps_nv12.yuv";
254+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_3));
255+ ASSERT_EQ(AV_ERR_OK, vDecSample->CreateVideoDecoder("OH.Media.Codec.Decoder.Video.DVVIDEO"));
256+ ASSERT_EQ(AV_ERR_OK, vDecSample->ConfigureVideoDecoder());
257+ ASSERT_EQ(AV_ERR_OK, vDecSample->SetVideoDecoderCallback());
258+ ASSERT_EQ(AV_ERR_OK, vDecSample->StartVideoDecoder());
259+ vDecSample->WaitForEOS();
260+ ASSERT_EQ(0, vDecSample->errCount);
261+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
262+}
263+ 
264+/**
265+ * @tc.number : VIDEO_SWDEC_DVVIDEO_FUNCTION_0080
266+ * @tc.name : decoder dvvideo,buffer,AsyncMode,dvvideo_720x480_yuv411p_30_25frames OutputPixelFormat:yuv411p->NV12
267+ * @tc.desc : function test
268+ */
269+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_FUNCTION_0080, TestSize.Level1)
270+{
271+ auto vDecSample = make_shared<VDecAPI11Sample>();
272+ vDecSample->DEFAULT_WIDTH = 720;
273+ vDecSample->DEFAULT_HEIGHT = 480;
274+ vDecSample->DEFAULT_FRAME_RATE = 30;
275+ vDecSample->outputYuvFlag = true;
276+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV12;
277+ vDecSample->OUT_DIR = "/data/test/media/dv_func_0080_720x480_30fps_nv12.yuv";
278+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_4));
279+ ASSERT_EQ(AV_ERR_OK, vDecSample->CreateVideoDecoder("OH.Media.Codec.Decoder.Video.DVVIDEO"));
280+ ASSERT_EQ(AV_ERR_OK, vDecSample->ConfigureVideoDecoder());
281+ ASSERT_EQ(AV_ERR_OK, vDecSample->SetVideoDecoderCallback());
282+ ASSERT_EQ(AV_ERR_OK, vDecSample->StartVideoDecoder());
283+ vDecSample->WaitForEOS();
284+ ASSERT_EQ(0, vDecSample->errCount);
285+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
286+}
287+ 
288+/**
289+ * @tc.number : VIDEO_SWDEC_DVVIDEO_FUNCTION_0090
290+ * @tc.name : decoder dvvideo,buffer,AsyncMode,dvvideo_960x720_yuv422p_50_25frames OutputPixelFormat:yuv422p->NV12
291+ * @tc.desc : function test
292+ */
293+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_FUNCTION_0090, TestSize.Level1)
294+{
295+ auto vDecSample = make_shared<VDecAPI11Sample>();
296+ vDecSample->DEFAULT_WIDTH = 960;
297+ vDecSample->DEFAULT_HEIGHT = 720;
298+ vDecSample->DEFAULT_FRAME_RATE = 50;
299+ vDecSample->outputYuvFlag = true;
300+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV12;
301+ vDecSample->OUT_DIR = "/data/test/media/dv_func_0090_960x720_50fps_nv12.yuv";
302+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_5));
303+ ASSERT_EQ(AV_ERR_OK, vDecSample->CreateVideoDecoder("OH.Media.Codec.Decoder.Video.DVVIDEO"));
304+ ASSERT_EQ(AV_ERR_OK, vDecSample->ConfigureVideoDecoder());
305+ ASSERT_EQ(AV_ERR_OK, vDecSample->SetVideoDecoderCallback());
306+ ASSERT_EQ(AV_ERR_OK, vDecSample->StartVideoDecoder());
307+ vDecSample->WaitForEOS();
308+ ASSERT_EQ(0, vDecSample->errCount);
309+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
310+}
311+ 
312+/**
313+ * @tc.number : VIDEO_SWDEC_DVVIDEO_FUNCTION_0100
314+ * @tc.name : decoder dvvideo,buffer,AsyncMode,dvvideo_960x720_yuv422p_60_25frames OutputPixelFormat:yuv422p->NV12
315+ * @tc.desc : function test
316+ */
317+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_FUNCTION_0100, TestSize.Level1)
318+{
319+ auto vDecSample = make_shared<VDecAPI11Sample>();
320+ vDecSample->DEFAULT_WIDTH = 960;
321+ vDecSample->DEFAULT_HEIGHT = 720;
322+ vDecSample->DEFAULT_FRAME_RATE = 60;
323+ vDecSample->outputYuvFlag = true;
324+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV12;
325+ vDecSample->OUT_DIR = "/data/test/media/dv_func_0100_960x720_60fps_nv12.yuv";
326+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_6));
327+ ASSERT_EQ(AV_ERR_OK, vDecSample->CreateVideoDecoder("OH.Media.Codec.Decoder.Video.DVVIDEO"));
328+ ASSERT_EQ(AV_ERR_OK, vDecSample->ConfigureVideoDecoder());
329+ ASSERT_EQ(AV_ERR_OK, vDecSample->SetVideoDecoderCallback());
330+ ASSERT_EQ(AV_ERR_OK, vDecSample->StartVideoDecoder());
331+ vDecSample->WaitForEOS();
332+ ASSERT_EQ(0, vDecSample->errCount);
333+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
334+}
335+ 
336+/**
337+ * @tc.number : VIDEO_SWDEC_DVVIDEO_FUNCTION_0110
338+ * @tc.name : decoder dvvideo,buffer,AsyncMode,dvvideo_1280_1080_yuv422p_25frames OutputPixelFormat:yuv422p->NV12
339+ * @tc.desc : function test
340+ */
341+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_FUNCTION_0110, TestSize.Level1)
342+{
343+ auto vDecSample = make_shared<VDecAPI11Sample>();
344+ vDecSample->DEFAULT_WIDTH = 1280;
345+ vDecSample->DEFAULT_HEIGHT = 1080;
346+ vDecSample->DEFAULT_FRAME_RATE = 30;
347+ vDecSample->outputYuvFlag = true;
348+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV12;
349+ vDecSample->OUT_DIR = "/data/test/media/dv_func_0110_1280x1080_30fps_nv12.yuv";
350+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_7));
351+ ASSERT_EQ(AV_ERR_OK, vDecSample->CreateVideoDecoder("OH.Media.Codec.Decoder.Video.DVVIDEO"));
352+ ASSERT_EQ(AV_ERR_OK, vDecSample->ConfigureVideoDecoder());
353+ ASSERT_EQ(AV_ERR_OK, vDecSample->SetVideoDecoderCallback());
354+ ASSERT_EQ(AV_ERR_OK, vDecSample->StartVideoDecoder());
355+ vDecSample->WaitForEOS();
356+ ASSERT_EQ(0, vDecSample->errCount);
357+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
358+}
359+ 
360+/**
361+ * @tc.number : VIDEO_SWDEC_DVVIDEO_FUNCTION_0120
362+ * @tc.name : decoder dvvideo,buffer,AsyncMode,dvvideo_1440_1080_yuv422p_25frames OutputPixelFormat:yuv422p->NV12
363+ * @tc.desc : function test
364+ */
365+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_FUNCTION_0120, TestSize.Level1)
366+{
367+ auto vDecSample = make_shared<VDecAPI11Sample>();
368+ vDecSample->DEFAULT_WIDTH = 1440;
369+ vDecSample->DEFAULT_HEIGHT = 1080;
370+ vDecSample->DEFAULT_FRAME_RATE = 25;
371+ vDecSample->outputYuvFlag = true;
372+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV12;
373+ vDecSample->OUT_DIR = "/data/test/media/dv_func_0120_1440x1080_25fps_nv12.yuv";
374+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_8));
375+ ASSERT_EQ(AV_ERR_OK, vDecSample->CreateVideoDecoder("OH.Media.Codec.Decoder.Video.DVVIDEO"));
376+ ASSERT_EQ(AV_ERR_OK, vDecSample->ConfigureVideoDecoder());
377+ ASSERT_EQ(AV_ERR_OK, vDecSample->SetVideoDecoderCallback());
378+ ASSERT_EQ(AV_ERR_OK, vDecSample->StartVideoDecoder());
379+ vDecSample->WaitForEOS();
380+ ASSERT_EQ(0, vDecSample->errCount);
381+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
382+}
383+ 
384+/**
385+ * @tc.number : VIDEO_SWDEC_DVVIDEO_FUNCTION_0130
386+ * @tc.name : decoder dvvideo,surface,AsyncMode,dvvideo_720_480_yuv411p_29fps OutputPixelFormat yuv411p->NV12
387+ * @tc.desc : function test
388+ */
389+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_FUNCTION_0130, TestSize.Level1)
390+{
391+ if (cap_dvvideo != nullptr) {
392+ auto vDecSample = make_shared<VDecAPI11Sample>();
393+ vDecSample->DEFAULT_WIDTH = 720;
394+ vDecSample->DEFAULT_HEIGHT = 480;
395+ vDecSample->DEFAULT_FRAME_RATE = 30;
396+ vDecSample->outputYuvSurface = true;
397+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV12;
398+ vDecSample->OUT_DIR = "/data/test/media/dv_func_surf_0130_720x480_30fps_nv12.yuv";
399+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_4));
400+ ASSERT_EQ(AV_ERR_OK, vDecSample->RunVideoDec_Surface(g_codecNameDVVideo));
401+ vDecSample->WaitForEOS();
402+ ASSERT_EQ(0, vDecSample->errCount);
403+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
404+ }
405+}
406+ 
407+/**
408+ * @tc.number : VIDEO_SWDEC_DVVIDEO_FUNCTION_0140
409+ * @tc.name : decode dvvideo surface,AsyncMode,dvvideo_720_576_yuv422p_25fps OutputPixelFormat yuv422p-> NV12
410+ * @tc.desc : function test
411+ */
412+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_FUNCTION_0140, TestSize.Level1)
413+{
414+ if (cap_dvvideo != nullptr) {
415+ auto vDecSample = make_shared<VDecAPI11Sample>();
416+ vDecSample->DEFAULT_WIDTH = 720;
417+ vDecSample->DEFAULT_HEIGHT = 576;
418+ vDecSample->DEFAULT_FRAME_RATE = 25;
419+ vDecSample->outputYuvSurface = true;
420+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV12;
421+ vDecSample->OUT_DIR = "/data/test/media/dv_func_surf_0140_720x576_25fps_nv12.yuv";
422+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_1));
423+ ASSERT_EQ(AV_ERR_OK, vDecSample->RunVideoDec_Surface(g_codecNameDVVideo));
424+ vDecSample->WaitForEOS();
425+ ASSERT_EQ(0, vDecSample->errCount);
426+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
427+ }
428+}
429+ 
430+/**
431+ * @tc.number : VIDEO_SWDEC_DVVIDEO_FUNCTION_0150
432+ * @tc.name : decode dvvideo surface,AsyncMode,dvvideo_960_720_yuv422p_59fps OutputPixelFormat yuv422p-> NV12
433+ * @tc.desc : function test
434+ */
435+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_FUNCTION_0150, TestSize.Level1)
436+{
437+ if (cap_dvvideo != nullptr) {
438+ auto vDecSample = make_shared<VDecAPI11Sample>();
439+ vDecSample->DEFAULT_WIDTH = 960;
440+ vDecSample->DEFAULT_HEIGHT = 720;
441+ vDecSample->DEFAULT_FRAME_RATE = 60;
442+ vDecSample->outputYuvSurface = true;
443+ vDecSample->sleepOnFPS = true;
444+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV12;
445+ vDecSample->OUT_DIR = "/data/test/media/dv_func_surf_0150_960x720_60fps_nv12.yuv";
446+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_6));
447+ ASSERT_EQ(AV_ERR_OK, vDecSample->RunVideoDec_Surface(g_codecNameDVVideo));
448+ vDecSample->WaitForEOS();
449+ ASSERT_EQ(0, vDecSample->errCount);
450+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
451+ }
452+}
453+ 
454+/**
455+ * @tc.number : VIDEO_SWDEC_DVVIDEO_FUNCTION_0160
456+ * @tc.name : decode dvvideo surface,AsyncMode,dvvideo_1280_1080_yuv422p_30fps OutputPixelFormat yuv422p-> NV12
457+ * @tc.desc : function test
458+ */
459+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_FUNCTION_0160, TestSize.Level1)
460+{
461+ if (cap_dvvideo != nullptr) {
462+ auto vDecSample = make_shared<VDecAPI11Sample>();
463+ vDecSample->DEFAULT_WIDTH = 1280;
464+ vDecSample->DEFAULT_HEIGHT = 1080;
465+ vDecSample->DEFAULT_FRAME_RATE = 30;
466+ vDecSample->outputYuvSurface = true;
467+ vDecSample->sleepOnFPS = true;
468+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV12;
469+ vDecSample->OUT_DIR = "/data/test/media/dv_func_surf_0160_1280x1080_30fps_nv12.yuv";
470+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_7));
471+ ASSERT_EQ(AV_ERR_OK, vDecSample->RunVideoDec_Surface(g_codecNameDVVideo));
472+ vDecSample->WaitForEOS();
473+ ASSERT_EQ(0, vDecSample->errCount);
474+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
475+ }
476+}
477+ 
478+/**
479+ * @tc.number : VIDEO_SWDEC_DVVIDEO_FUNCTION_0170
480+ * @tc.name : decode dvvideo surface,AsyncMode,dvvideo_1440_1080_yuv422p_30fps OutputPixelFormat yuv422p->NV12
481+ * @tc.desc : function test
482+ */
483+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_FUNCTION_0170, TestSize.Level1)
484+{
485+ if (cap_dvvideo != nullptr) {
486+ auto vDecSample = make_shared<VDecAPI11Sample>();
487+ vDecSample->DEFAULT_WIDTH = 1440;
488+ vDecSample->DEFAULT_HEIGHT = 1080;
489+ vDecSample->DEFAULT_FRAME_RATE = 25;
490+ vDecSample->outputYuvSurface = true;
491+ vDecSample->sleepOnFPS = true;
492+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV12;
493+ vDecSample->OUT_DIR = "/data/test/media/dv_func_surf_0170_1440x1080_25fps_nv12.yuv";
494+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_8));
495+ ASSERT_EQ(AV_ERR_OK, vDecSample->RunVideoDec_Surface(g_codecNameDVVideo));
496+ vDecSample->WaitForEOS();
497+ ASSERT_EQ(0, vDecSample->errCount);
498+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
499+ }
500+}
501+ 
502+/**
503+ * @tc.number : VIDEO_SWDEC_DVVIDEO_FUNCTION_0180
504+ * @tc.name : decode dvvideo buffer,PixelFormat,NV12,mkv
505+ * @tc.desc : function test
506+ */
507+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_FUNCTION_0180, TestSize.Level1)
508+{
509+ auto vDecSample = make_shared<VDecAPI11Sample>();
510+ vDecSample->DEFAULT_WIDTH = 720;
511+ vDecSample->DEFAULT_HEIGHT = 480;
512+ vDecSample->DEFAULT_FRAME_RATE = 30;
513+ vDecSample->outputYuvFlag = true;
514+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV12;
515+ vDecSample->OUT_DIR = "/data/test/media/dv_func_0180_720x480_30fps_nv12.yuv";
516+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_9));
517+ ASSERT_EQ(AV_ERR_OK, vDecSample->CreateVideoDecoder("OH.Media.Codec.Decoder.Video.DVVIDEO"));
518+ ASSERT_EQ(AV_ERR_OK, vDecSample->ConfigureVideoDecoder());
519+ ASSERT_EQ(AV_ERR_OK, vDecSample->SetVideoDecoderCallback());
520+ ASSERT_EQ(AV_ERR_OK, vDecSample->StartVideoDecoder());
521+ vDecSample->WaitForEOS();
522+ ASSERT_EQ(0, vDecSample->errCount);
523+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
524+}
525+ 
526+/**
527+ * @tc.number : VIDEO_SWDEC_DVVIDEO_FUNCTION_0190
528+ * @tc.name : decode dvvideo buffer,PixelFormat,NV21,mov
529+ * @tc.desc : function test
530+ */
531+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_FUNCTION_0190, TestSize.Level1)
532+{
533+ auto vDecSample = make_shared<VDecAPI11Sample>();
534+ vDecSample->DEFAULT_WIDTH = 720;
535+ vDecSample->DEFAULT_HEIGHT = 480;
536+ vDecSample->DEFAULT_FRAME_RATE = 30;
537+ vDecSample->outputYuvFlag = true;
538+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV21;
539+ vDecSample->OUT_DIR = "/data/test/media/dv_func_0190_720x480_30fps_nv21.yuv";
540+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_10));
541+ ASSERT_EQ(AV_ERR_OK, vDecSample->CreateVideoDecoder("OH.Media.Codec.Decoder.Video.DVVIDEO"));
542+ ASSERT_EQ(AV_ERR_OK, vDecSample->ConfigureVideoDecoder());
543+ ASSERT_EQ(AV_ERR_OK, vDecSample->SetVideoDecoderCallback());
544+ ASSERT_EQ(AV_ERR_OK, vDecSample->StartVideoDecoder());
545+ vDecSample->WaitForEOS();
546+ ASSERT_EQ(0, vDecSample->errCount);
547+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
548+}
549+ 
550+/**
551+ * @tc.number : VIDEO_SWDEC_DVVIDEO_FUNCTION_0200
552+ * @tc.name : decode dvvideo buffer,PixelFormat,NV21,avi
553+ * @tc.desc : function test
554+ */
555+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_FUNCTION_0200, TestSize.Level1)
556+{
557+ auto vDecSample = make_shared<VDecAPI11Sample>();
558+ vDecSample->DEFAULT_WIDTH = 720;
559+ vDecSample->DEFAULT_HEIGHT = 480;
560+ vDecSample->DEFAULT_FRAME_RATE = 30;
561+ vDecSample->outputYuvFlag = true;
562+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV21;
563+ vDecSample->OUT_DIR = "/data/test/media/dv_func_0200_720x480_30fps_nv21.yuv";
564+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_4));
565+ ASSERT_EQ(AV_ERR_OK, vDecSample->CreateVideoDecoder("OH.Media.Codec.Decoder.Video.DVVIDEO"));
566+ ASSERT_EQ(AV_ERR_OK, vDecSample->ConfigureVideoDecoder());
567+ ASSERT_EQ(AV_ERR_OK, vDecSample->SetVideoDecoderCallback());
568+ ASSERT_EQ(AV_ERR_OK, vDecSample->StartVideoDecoder());
569+ vDecSample->WaitForEOS();
570+ ASSERT_EQ(0, vDecSample->errCount);
571+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
572+}
573+ 
574+/**
575+ * @tc.number : VIDEO_SWDEC_DVVIDEO_FUNCTION_0210
576+ * @tc.name : decode H263 buffer and handle error
577+ * @tc.desc : function test
578+ */
579+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_FUNCTION_0210, TestSize.Level2)
580+{
581+ auto vDecSample = make_shared<VDecAPI11Sample>();
582+ vDecSample->DEFAULT_WIDTH = 1280;
583+ vDecSample->DEFAULT_HEIGHT = 720;
584+ vDecSample->DEFAULT_FRAME_RATE = 60;
585+ vDecSample->outputYuvFlag = true;
586+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV21;
587+ vDecSample->IN_DIR = "/data/test/media/profile2_level50_gop60_1280x720.h263";
588+ ASSERT_EQ(AV_ERR_OK, vDecSample->CreateVideoDecoder("OH.Media.Codec.Decoder.Video.DVVIDEO"));
589+ ASSERT_EQ(AV_ERR_OK, vDecSample->ConfigureVideoDecoder());
590+ ASSERT_EQ(AV_ERR_OK, vDecSample->SetVideoDecoderCallback());
591+ ASSERT_EQ(AV_ERR_OK, vDecSample->StartVideoDecoderForH263());
592+ vDecSample->WaitForEOS();
593+ cout << "outFrameCount" << vDecSample->outFrameCount << endl;
594+ ASSERT_EQ(true, vDecSample->isonError);
595+}
596+ 
597+/**
598+ * @tc.number : VIDEO_SWDEC_DVVIDEO_RESOLUTION_0010
599+ * @tc.name : dvvideo Resolution Change,buffer, nv12, INP_DIR_6
600+ * @tc.desc : function test
601+ */
602+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_RESOLUTION_0010, TestSize.Level3)
603+{
604+ if (g_codecNameDVVideo.find("DVVIDEO") != string::npos) {
605+ auto vDecSample = make_shared<VDecAPI11Sample>();
606+ vDecSample->DEFAULT_WIDTH = 960;
607+ vDecSample->DEFAULT_HEIGHT = 720;
608+ vDecSample->DEFAULT_FRAME_RATE = 60;
609+ vDecSample->outputYuvFlag = true;
610+ vDecSample->isDVVideoChange = true;
611+ vDecSample->SF_OUTPUT = false;
612+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV12;
613+ vDecSample->OUT_DIR = "/data/test/media/dv_resolution_0010_960x720_60fps_nv12.yuv";
614+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_6));
615+ ASSERT_EQ(AV_ERR_OK, vDecSample->CreateVideoDecoder(g_codecNameDVVideo));
616+ ASSERT_EQ(AV_ERR_OK, vDecSample->ConfigureVideoDecoder());
617+ ASSERT_EQ(AV_ERR_OK, vDecSample->SetVideoDecoderCallback());
618+ ASSERT_EQ(AV_ERR_OK, vDecSample->StartVideoDecoder());
619+ vDecSample->WaitForEOS();
620+ ASSERT_EQ(0, vDecSample->errCount);
621+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
622+ }
623+}
624+ 
625+/**
626+ * @tc.number : VIDEO_SWDEC_DVVIDEO_RESOLUTION_0020
627+ * @tc.name : dvvideo Resolution Change,buffer, nv21, INP_DIR_6
628+ * @tc.desc : function test
629+ */
630+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_RESOLUTION_0020, TestSize.Level3)
631+{
632+ if (g_codecNameDVVideo.find("DVVIDEO") != string::npos) {
633+ auto vDecSample = make_shared<VDecAPI11Sample>();
634+ vDecSample->DEFAULT_WIDTH = 960;
635+ vDecSample->DEFAULT_HEIGHT = 720;
636+ vDecSample->DEFAULT_FRAME_RATE = 60;
637+ vDecSample->outputYuvFlag = true;
638+ vDecSample->isDVVideoChange = true;
639+ vDecSample->SF_OUTPUT = false;
640+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV21;
641+ vDecSample->OUT_DIR = "/data/test/media/dv_resolution_0020_960x720_60fps_nv21.yuv";
642+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_6));
643+ ASSERT_EQ(AV_ERR_OK, vDecSample->CreateVideoDecoder(g_codecNameDVVideo));
644+ ASSERT_EQ(AV_ERR_OK, vDecSample->ConfigureVideoDecoder());
645+ ASSERT_EQ(AV_ERR_OK, vDecSample->SetVideoDecoderCallback());
646+ ASSERT_EQ(AV_ERR_OK, vDecSample->StartVideoDecoder());
647+ vDecSample->WaitForEOS();
648+ ASSERT_EQ(0, vDecSample->errCount);
649+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
650+ }
651+}
652+ 
653+/**
654+ * @tc.number : VIDEO_SWDEC_DVVIDEO_RESOLUTION_0030
655+ * @tc.name : dvvideo Resolution Change,buffer, nv12, INP_DIR_6
656+ * @tc.desc : function test
657+ */
658+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_RESOLUTION_0030, TestSize.Level3)
659+{
660+ if (g_codecNameDVVideo.find("DVVIDEO") != string::npos) {
661+ auto vDecSample = make_shared<VDecAPI11Sample>();
662+ vDecSample->DEFAULT_WIDTH = 960;
663+ vDecSample->DEFAULT_HEIGHT = 720;
664+ vDecSample->DEFAULT_FRAME_RATE = 60;
665+ vDecSample->outputYuvFlag = true;
666+ vDecSample->isDVVideoChange = true;
667+ vDecSample->SF_OUTPUT = false;
668+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_YUVI420;
669+ vDecSample->OUT_DIR = "/data/test/media/dv_resolution_0030_960x720_60fps_i420.yuv";
670+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_6));
671+ ASSERT_EQ(AV_ERR_OK, vDecSample->CreateVideoDecoder(g_codecNameDVVideo));
672+ ASSERT_EQ(AV_ERR_OK, vDecSample->ConfigureVideoDecoder());
673+ ASSERT_EQ(AV_ERR_OK, vDecSample->SetVideoDecoderCallback());
674+ ASSERT_EQ(AV_ERR_OK, vDecSample->StartVideoDecoder());
675+ vDecSample->WaitForEOS();
676+ ASSERT_EQ(0, vDecSample->errCount);
677+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
678+ }
679+}
680+ 
681+/**
682+ * @tc.number : VIDEO_SWDEC_DVVIDEO_RESOLUTION_0040
683+ * @tc.name : dvvideo Resolution Change,surface, nv21, INP_DIR_6
684+ * @tc.desc : function test
685+ */
686+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_RESOLUTION_0040, TestSize.Level3)
687+{
688+ if (g_codecNameDVVideo.find("DVVIDEO") != string::npos) {
689+ auto vDecSample = make_shared<VDecAPI11Sample>();
690+ vDecSample->DEFAULT_WIDTH = 960;
691+ vDecSample->DEFAULT_HEIGHT = 720;
692+ vDecSample->DEFAULT_FRAME_RATE = 60;
693+ vDecSample->outputYuvSurface = true;
694+ vDecSample->SF_OUTPUT = true;
695+ vDecSample->isDVVideoChange = true;
696+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV21;
697+ vDecSample->OUT_DIR = "/data/test/media/dv_resolution_0040_960x720_60fps_nv21.yuv";
698+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_6));
699+ ASSERT_EQ(AV_ERR_OK, vDecSample->RunVideoDec_Surface(g_codecNameDVVideo));
700+ vDecSample->WaitForEOS();
701+ ASSERT_EQ(0, vDecSample->errCount);
702+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
703+ }
704+}
705+ 
706+/**
707+ * @tc.number : VIDEO_SWDEC_DVVIDEO_RESOLUTION_0050
708+ * @tc.name : dvvideo Resolution Change,surface, nv21, profile1_1440x1080_24
709+ * @tc.desc : function test
710+ */
711+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_RESOLUTION_0050, TestSize.Level3)
712+{
713+ if (g_codecNameDVVideo.find("DVVIDEO") != string::npos) {
714+ auto vDecSample = make_shared<VDecAPI11Sample>();
715+ vDecSample->DEFAULT_WIDTH = 1280;
716+ vDecSample->DEFAULT_HEIGHT = 1080;
717+ vDecSample->DEFAULT_FRAME_RATE = 30;
718+ vDecSample->outputYuvSurface = true;
719+ vDecSample->isDVVideoChange = true;
720+ vDecSample->SF_OUTPUT = true;
721+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV21;
722+ vDecSample->OUT_DIR = "/data/test/media/dv_resolution_0050_1280x1080_30fps_nv21.yuv";
723+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_7));
724+ ASSERT_EQ(AV_ERR_OK, vDecSample->RunVideoDec_Surface(g_codecNameDVVideo));
725+ vDecSample->WaitForEOS();
726+ ASSERT_EQ(0, vDecSample->errCount);
727+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
728+ }
729+}
730+ 
731+/**
732+ * @tc.number : VIDEO_SWDEC_DVVIDEO_RESOLUTION_0060
733+ * @tc.name : dvvideo Resolution Change,surface, nv21, profile1_1920x1080_24
734+ * @tc.desc : function test
735+ */
736+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_RESOLUTION_0060, TestSize.Level3)
737+{
738+ if (g_codecNameDVVideo.find("DVVIDEO") != string::npos) {
739+ auto vDecSample = make_shared<VDecAPI11Sample>();
740+ vDecSample->DEFAULT_WIDTH = 1280;
741+ vDecSample->DEFAULT_HEIGHT = 1080;
742+ vDecSample->DEFAULT_FRAME_RATE = 30;
743+ vDecSample->outputYuvSurface = true;
744+ vDecSample->isDVVideoChange = true;
745+ vDecSample->SF_OUTPUT = true;
746+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV12;
747+ vDecSample->OUT_DIR = "/data/test/media/dv_resolution_0060_1280x1080_30fps_nv12.yuv";
748+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_7));
749+ ASSERT_EQ(AV_ERR_OK, vDecSample->RunVideoDec_Surface(g_codecNameDVVideo));
750+ vDecSample->WaitForEOS();
751+ ASSERT_EQ(0, vDecSample->errCount);
752+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
753+ }
754+}
755+ 
756+/**
757+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API11_ROTATION_ANGLE_FUNC_001
758+ * @tc.name : decoder dvvideo,func,surface settransform rotate 90 degree,INP_DIR_6
759+ * @tc.desc : function test
760+ */
761+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_API11_ROTATION_ANGLE_FUNC_001, TestSize.Level3)
762+{
763+ if (cap_dvvideo != nullptr) {
764+ auto vDecSample = make_shared<VDecAPI11Sample>();
765+ vDecSample->DEFAULT_WIDTH = 960;
766+ vDecSample->DEFAULT_HEIGHT = 720;
767+ vDecSample->DEFAULT_FRAME_RATE = 60;
768+ vDecSample->outputYuvSurface = true;
769+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV12;
770+ vDecSample->OUT_DIR = "/data/test/media/dv_rotation_angle_001_960x720_60fps_nv12.yuv";
771+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_6));
772+ ASSERT_EQ(AV_ERR_OK, vDecSample->RunVideoDec_Surface(g_codecNameDVVideo));
773+ ASSERT_EQ(AV_ERR_OK, vDecSample->SetRotationAngle(90));
774+ vDecSample->WaitForEOS();
775+ ASSERT_EQ(AV_ERR_OK, vDecSample->errCount);
776+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
777+ }
778+}
779+ 
780+/**
781+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API11_ROTATION_ANGLE_FUNC_002
782+ * @tc.name : decoder dvvideo,func,surface settransform rotate 180 degree,INP_DIR_6
783+ * @tc.desc : function test
784+ */
785+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_API11_ROTATION_ANGLE_FUNC_002, TestSize.Level3)
786+{
787+ if (cap_dvvideo != nullptr) {
788+ auto vDecSample = make_shared<VDecAPI11Sample>();
789+ vDecSample->DEFAULT_WIDTH = 960;
790+ vDecSample->DEFAULT_HEIGHT = 720;
791+ vDecSample->DEFAULT_FRAME_RATE = 60;
792+ vDecSample->outputYuvSurface = true;
793+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV12;
794+ vDecSample->OUT_DIR = "/data/test/media/dv_rotation_angle_002_960x720_60fps_nv12.yuv";
795+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_6));
796+ ASSERT_EQ(AV_ERR_OK, vDecSample->RunVideoDec_Surface(g_codecNameDVVideo));
797+ ASSERT_EQ(AV_ERR_OK, vDecSample->SetRotationAngle(180));
798+ vDecSample->WaitForEOS();
799+ ASSERT_EQ(AV_ERR_OK, vDecSample->errCount);
800+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
801+ }
802+}
803+ 
804+/**
805+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API11_ROTATION_ANGLE_FUNC_003
806+ * @tc.name : decoder dvvideo,func,surface settransform rotate 270 degree,INP_DIR_6
807+ * @tc.desc : function test
808+ */
809+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_API11_ROTATION_ANGLE_FUNC_003, TestSize.Level3)
810+{
811+ if (cap_dvvideo != nullptr) {
812+ auto vDecSample = make_shared<VDecAPI11Sample>();
813+ vDecSample->DEFAULT_WIDTH = 960;
814+ vDecSample->DEFAULT_HEIGHT = 720;
815+ vDecSample->DEFAULT_FRAME_RATE = 60;
816+ vDecSample->outputYuvSurface = true;
817+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV12;
818+ vDecSample->OUT_DIR = "/data/test/media/dv_rotation_angle_003_960x720_60fps_nv12.yuv";
819+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_6));
820+ ASSERT_EQ(AV_ERR_OK, vDecSample->RunVideoDec_Surface(g_codecNameDVVideo));
821+ ASSERT_EQ(AV_ERR_OK, vDecSample->SetRotationAngle(270));
822+ vDecSample->WaitForEOS();
823+ ASSERT_EQ(AV_ERR_OK, vDecSample->errCount);
824+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
825+ }
826+}
827+ 
828+/**
829+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_001
830+ * @tc.name : surf model change in normal state
831+ * @tc.desc : function test
832+ */
833+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_001, TestSize.Level2)
834+{
835+ if (cap_dvvideo != nullptr) {
836+ auto vDecSample = make_shared<VDecAPI11Sample>();
837+ vDecSample->DEFAULT_WIDTH = 960;
838+ vDecSample->DEFAULT_HEIGHT = 720;
839+ vDecSample->DEFAULT_FRAME_RATE = 60;
840+ vDecSample->outputYuvSurface = true;
841+ vDecSample->autoSwitchSurface = true;
842+ vDecSample->AFTER_EOS_DESTORY_CODEC = false;
843+ vDecSample->sleepOnFPS = true;
844+ vDecSample->OUT_DIR = "/data/test/media/dv_surf_001_960x720_60fps_nv12_1.yuv";
845+ vDecSample->OUT_DIR2 = "/data/test/media/dv_surf_001_960x720_60fps_nv12_2.yuv";
846+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_6));
847+ ASSERT_EQ(AV_ERR_OK, vDecSample->RunVideoDec_Surface(g_codecNameDVVideo));
848+ vDecSample->WaitForEOS();
849+ ASSERT_EQ(AV_ERR_OK, vDecSample->Reset());
850+ ASSERT_EQ(AV_ERR_INVALID_STATE, vDecSample->SwitchSurface());
851+ ASSERT_EQ(AV_ERR_OK, vDecSample->Release());
852+ }
853+}
854+ 
855+/**
856+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_002
857+ * @tc.name : surf model change in flushed state
858+ * @tc.desc : function test
859+ */
860+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_002, TestSize.Level2)
861+{
862+ if (cap_dvvideo != nullptr) {
863+ auto vDecSample = make_shared<VDecAPI11Sample>();
864+ vDecSample->DEFAULT_WIDTH = 960;
865+ vDecSample->DEFAULT_HEIGHT = 720;
866+ vDecSample->DEFAULT_FRAME_RATE = 60;
867+ vDecSample->outputYuvSurface = true;
868+ vDecSample->autoSwitchSurface = true;
869+ vDecSample->sleepOnFPS = true;
870+ vDecSample->OUT_DIR = "/data/test/media/dv_surf_002_960x720_60fps_nv12_1.yuv";
871+ vDecSample->OUT_DIR2 = "/data/test/media/dv_surf_002_960x720_60fps_nv12_2.yuv";
872+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_6));
873+ ASSERT_EQ(AV_ERR_OK, vDecSample->RunVideoDec_Surface(g_codecNameDVVideo));
874+ ASSERT_EQ(AV_ERR_OK, vDecSample->Flush());
875+ ASSERT_EQ(AV_ERR_OK, vDecSample->SwitchSurface());
876+ ASSERT_EQ(AV_ERR_OK, vDecSample->Stop());
877+ }
878+}
879+ 
880+/**
881+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_003
882+ * @tc.name : surf model change in runing state
883+ * @tc.desc : function test
884+ */
885+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_003, TestSize.Level2)
886+{
887+ if (cap_dvvideo != nullptr) {
888+ auto vDecSample = make_shared<VDecAPI11Sample>();
889+ vDecSample->DEFAULT_WIDTH = 960;
890+ vDecSample->DEFAULT_HEIGHT = 720;
891+ vDecSample->DEFAULT_FRAME_RATE = 60;
892+ vDecSample->outputYuvSurface = true;
893+ vDecSample->autoSwitchSurface = false;
894+ vDecSample->SF_OUTPUT = true;
895+ vDecSample->OUT_DIR = "/data/test/media/dv_surf_003_960x720_60fps_nv12.yuv";
896+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_6));
897+ vDecSample->CreateSurface();
898+ ASSERT_EQ(AV_ERR_OK, vDecSample->RunVideoDec(g_codecNameDVVideo));
899+ ASSERT_EQ(AV_ERR_OPERATE_NOT_PERMIT, vDecSample->SwitchSurface());
900+ vDecSample->WaitForEOS();
901+ ASSERT_EQ(AV_ERR_OK, vDecSample->errCount);
902+ }
903+}
904+ 
905+/**
906+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_004
907+ * @tc.name : repeat call setSurface fastly
908+ * @tc.desc : function test
909+ */
910+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_004, TestSize.Level2)
911+{
912+ if (cap_dvvideo != nullptr) {
913+ auto vDecSample = make_shared<VDecAPI11Sample>();
914+ vDecSample->DEFAULT_WIDTH = 960;
915+ vDecSample->DEFAULT_HEIGHT = 720;
916+ vDecSample->DEFAULT_FRAME_RATE = 60;
917+ vDecSample->outputYuvSurface = true;
918+ vDecSample->autoSwitchSurface = true;
919+ vDecSample->sleepOnFPS = true;
920+ vDecSample->OUT_DIR = "/data/test/media/dv_surf_004_960x720_60fps_nv12_1.yuv";
921+ vDecSample->OUT_DIR2 = "/data/test/media/dv_surf_004_960x720_60fps_nv12_2.yuv";
922+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_6));
923+ ASSERT_EQ(AV_ERR_OK, vDecSample->RunVideoDec_Surface(g_codecNameDVVideo));
924+ ASSERT_EQ(AV_ERR_OK, vDecSample->SwitchSurface());
925+ vDecSample->WaitForEOS();
926+ }
927+}
928+ 
929+/**
930+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_005
931+ * @tc.name : surf model change in flush to runnig state
932+ * @tc.desc : function test
933+ */
934+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_005, TestSize.Level2)
935+{
936+ if (cap_dvvideo != nullptr) {
937+ auto vDecSample = make_shared<VDecAPI11Sample>();
938+ vDecSample->DEFAULT_WIDTH = 960;
939+ vDecSample->DEFAULT_HEIGHT = 720;
940+ vDecSample->DEFAULT_FRAME_RATE = 60;
941+ vDecSample->outputYuvSurface = true;
942+ vDecSample->autoSwitchSurface = true;
943+ vDecSample->AFTER_EOS_DESTORY_CODEC = false;
944+ vDecSample->sleepOnFPS = true;
945+ vDecSample->OUT_DIR = "/data/test/media/dv_surf_005_960x720_60fps_nv12_1.yuv";
946+ vDecSample->OUT_DIR2 = "/data/test/media/dv_surf_005_960x720_60fps_nv12_2.yuv";
947+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_6));
948+ ASSERT_EQ(AV_ERR_OK, vDecSample->RunVideoDec_Surface(g_codecNameDVVideo));
949+ ASSERT_EQ(AV_ERR_OK, vDecSample->Flush());
950+ ASSERT_EQ(AV_ERR_OK, vDecSample->Start());
951+ ASSERT_EQ(AV_ERR_OK, vDecSample->SwitchSurface());
952+ }
953+}
954+ 
955+/**
956+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_006
957+ * @tc.name : surf model change in decoder finish to End-of-Stream state
958+ * @tc.desc : function test
959+ */
960+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_006, TestSize.Level2)
961+{
962+ if (cap_dvvideo != nullptr) {
963+ auto vDecSample = make_shared<VDecAPI11Sample>();
964+ vDecSample->DEFAULT_WIDTH = 960;
965+ vDecSample->DEFAULT_HEIGHT = 720;
966+ vDecSample->DEFAULT_FRAME_RATE = 60;
967+ vDecSample->outputYuvSurface = true;
968+ vDecSample->autoSwitchSurface = true;
969+ vDecSample->AFTER_EOS_DESTORY_CODEC = false;
970+ vDecSample->sleepOnFPS = true;
971+ vDecSample->OUT_DIR = "/data/test/media/dv_surf_006_960x720_60fps_nv12_1.yuv";
972+ vDecSample->OUT_DIR2 = "/data/test/media/dv_surf_006_960x720_60fps_nv12_2.yuv";
973+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_6));
974+ ASSERT_EQ(AV_ERR_OK, vDecSample->RunVideoDec_Surface(g_codecNameDVVideo));
975+ vDecSample->WaitForEOS();
976+ ASSERT_EQ(AV_ERR_OK, vDecSample->SwitchSurface());
977+ }
978+}
979+ 
980+/**
981+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_007
982+ * @tc.name : buffer model change in decoder finish to End-of-Stream state
983+ * @tc.desc : function test
984+ */
985+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_007, TestSize.Level2)
986+{
987+ if (cap_dvvideo != nullptr) {
988+ auto vDecSample = make_shared<VDecAPI11Sample>();
989+ vDecSample->DEFAULT_WIDTH = 960;
990+ vDecSample->DEFAULT_HEIGHT = 720;
991+ vDecSample->DEFAULT_FRAME_RATE = 60;
992+ vDecSample->outputYuvFlag = true;
993+ vDecSample->outputYuvSurface = true;
994+ vDecSample->autoSwitchSurface = false;
995+ vDecSample->SF_OUTPUT = true;
996+ vDecSample->OUT_DIR = "/data/test/media/dv_surf_007_960x720_60fps_nv12_1.yuv";
997+ vDecSample->OUT_DIR = "/data/test/media/dv_surf_007_960x720_60fps_nv12_2.yuv";
998+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_6));
999+ vDecSample->CreateSurface();
1000+ ASSERT_EQ(AV_ERR_OK, vDecSample->RunVideoDec(g_codecNameDVVideo));
1001+ vDecSample->WaitForEOS();
1002+ ASSERT_EQ(AV_ERR_OPERATE_NOT_PERMIT, vDecSample->SwitchSurface());
1003+ ASSERT_EQ(AV_ERR_OK, vDecSample->errCount);
1004+ }
1005+}
1006+ 
1007+/**
1008+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_008
1009+ * @tc.name : buffer model change in runing to flushed state
1010+ * @tc.desc : function test
1011+ */
1012+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_008, TestSize.Level2)
1013+{
1014+ if (cap_dvvideo != nullptr) {
1015+ auto vDecSample = make_shared<VDecAPI11Sample>();
1016+ vDecSample->DEFAULT_WIDTH = 960;
1017+ vDecSample->DEFAULT_HEIGHT = 720;
1018+ vDecSample->DEFAULT_FRAME_RATE = 60;
1019+ vDecSample->outputYuvFlag = true;
1020+ vDecSample->outputYuvSurface = true;
1021+ vDecSample->autoSwitchSurface = false;
1022+ vDecSample->SF_OUTPUT = true;
1023+ vDecSample->OUT_DIR = "/data/test/media/dv_surf_008_960x720_60fps_nv12.yuv";
1024+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_6));
1025+ vDecSample->CreateSurface();
1026+ ASSERT_EQ(AV_ERR_OK, vDecSample->RunVideoDec(g_codecNameDVVideo));
1027+ ASSERT_EQ(AV_ERR_OK, vDecSample->Flush());
1028+ ASSERT_EQ(AV_ERR_OPERATE_NOT_PERMIT, vDecSample->SwitchSurface());
1029+ ASSERT_EQ(AV_ERR_OK, vDecSample->errCount);
1030+ }
1031+}
1032+ 
1033+/**
1034+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_009
1035+ * @tc.name : buffer model change in flushed to runing state
1036+ * @tc.desc : function test
1037+ */
1038+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_009, TestSize.Level2)
1039+{
1040+ if (cap_dvvideo != nullptr) {
1041+ auto vDecSample = make_shared<VDecAPI11Sample>();
1042+ vDecSample->DEFAULT_WIDTH = 960;
1043+ vDecSample->DEFAULT_HEIGHT = 720;
1044+ vDecSample->DEFAULT_FRAME_RATE = 60;
1045+ vDecSample->outputYuvFlag = true;
1046+ vDecSample->outputYuvSurface = true;
1047+ vDecSample->autoSwitchSurface = false;
1048+ vDecSample->SF_OUTPUT = true;
1049+ vDecSample->OUT_DIR = "/data/test/media/dv_surf_008_960x720_60fps_nv12.yuv";
1050+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_6));
1051+ vDecSample->CreateSurface();
1052+ ASSERT_EQ(AV_ERR_OK, vDecSample->RunVideoDec(g_codecNameDVVideo));
1053+ ASSERT_EQ(AV_ERR_OK, vDecSample->Flush());
1054+ ASSERT_EQ(AV_ERR_OK, vDecSample->Start());
1055+ ASSERT_EQ(AV_ERR_OPERATE_NOT_PERMIT, vDecSample->SwitchSurface());
1056+ ASSERT_EQ(AV_ERR_OK, vDecSample->errCount);
1057+ }
1058+}
1059+ 
1060+/**
1061+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_010
1062+ * @tc.name : buffer model change in normal state
1063+ * @tc.desc : function test
1064+ */
1065+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_010, TestSize.Level2)
1066+{
1067+ if (cap_dvvideo != nullptr) {
1068+ auto vDecSample = make_shared<VDecAPI11Sample>();
1069+ vDecSample->DEFAULT_WIDTH = 960;
1070+ vDecSample->DEFAULT_HEIGHT = 720;
1071+ vDecSample->DEFAULT_FRAME_RATE = 60;
1072+ vDecSample->outputYuvFlag = true;
1073+ vDecSample->outputYuvSurface = true;
1074+ vDecSample->autoSwitchSurface = false;
1075+ vDecSample->OUT_DIR = "/data/test/media/dv_surf_010_960x720_60fps_nv12.yuv";
1076+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_6));
1077+ vDecSample->CreateSurface();
1078+ ASSERT_EQ(AV_ERR_OK, vDecSample->RunVideoDec(g_codecNameDVVideo));
1079+ vDecSample->WaitForEOS();
1080+ ASSERT_EQ(AV_ERR_OK, vDecSample->Reset());
1081+ ASSERT_EQ(AV_ERR_INVALID_STATE, vDecSample->SwitchSurface());
1082+ ASSERT_EQ(AV_ERR_OK, vDecSample->Release());
1083+ ASSERT_EQ(AV_ERR_OK, vDecSample->errCount);
1084+ }
1085+}
1086+ 
1087+/**
1088+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_011
1089+ * @tc.name : surf model change in config state
1090+ * @tc.desc : function test
1091+ */
1092+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_011, TestSize.Level1)
1093+{
1094+ if (cap_dvvideo != nullptr) {
1095+ auto vDecSample = make_shared<VDecAPI11Sample>();
1096+ vDecSample->DEFAULT_WIDTH = 960;
1097+ vDecSample->DEFAULT_HEIGHT = 720;
1098+ vDecSample->DEFAULT_FRAME_RATE = 60;
1099+ vDecSample->outputYuvSurface = true;
1100+ vDecSample->autoSwitchSurface = false;
1101+ vDecSample->OUT_DIR = "/data/test/media/dv_surf_011_960x720_60fps_nv12.yuv";
1102+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_6));
1103+ vDecSample->CreateSurface();
1104+ ASSERT_EQ(AV_ERR_OK, vDecSample->CreateVideoDecoder(g_codecNameDVVideo));
1105+ ASSERT_EQ(AV_ERR_OK, vDecSample->ConfigureVideoDecoder());
1106+ ASSERT_EQ(AV_ERR_OK, vDecSample->SwitchSurface());
1107+ vDecSample->WaitForEOS();
1108+ ASSERT_EQ(AV_ERR_OK, vDecSample->errCount);
1109+ }
1110+}
1111+ 
1112+/**
1113+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_012
1114+ * @tc.name : surf model change in config state
1115+ * @tc.desc : function test
1116+ */
1117+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_012, TestSize.Level1)
1118+{
1119+ if (cap_dvvideo != nullptr) {
1120+ auto vDecSample = make_shared<VDecAPI11Sample>();
1121+ vDecSample->DEFAULT_WIDTH = 960;
1122+ vDecSample->DEFAULT_HEIGHT = 720;
1123+ vDecSample->DEFAULT_FRAME_RATE = 60;
1124+ vDecSample->outputYuvFlag = true;
1125+ vDecSample->outputYuvSurface = true;
1126+ vDecSample->autoSwitchSurface = false;
1127+ vDecSample->OUT_DIR = "/data/test/media/dv_surf_012_960x720_60fps_nv12.yuv";
1128+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_6));
1129+ vDecSample->CreateSurface();
1130+ ASSERT_EQ(AV_ERR_OK, vDecSample->CreateVideoDecoder(g_codecNameDVVideo));
1131+ ASSERT_EQ(AV_ERR_INVALID_STATE, vDecSample->SwitchSurface());
1132+ vDecSample->WaitForEOS();
1133+ ASSERT_EQ(AV_ERR_OK, vDecSample->errCount);
1134+ }
1135+}
1136+ 
1137+/**
1138+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_013
1139+ * @tc.name : Two object repeat call setSurface fastly
1140+ * @tc.desc : function test
1141+ */
1142+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_013, TestSize.Level2)
1143+{
1144+ if (cap_dvvideo != nullptr) {
1145+ auto vDecSample = make_shared<VDecAPI11Sample>();
1146+ vDecSample->DEFAULT_WIDTH = 960;
1147+ vDecSample->DEFAULT_HEIGHT = 720;
1148+ vDecSample->DEFAULT_FRAME_RATE = 60;
1149+ vDecSample->outputYuvSurface = true;
1150+ vDecSample->autoSwitchSurface = true;
1151+ vDecSample->sleepOnFPS = true;
1152+ vDecSample->OUT_DIR = "/data/test/media/dv_surf_013_960x720_60fps_nv12_1.yuv";
1153+ vDecSample->OUT_DIR2 = "/data/test/media/dv_surf_013_960x720_60fps_nv12_2.yuv";
1154+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_6));
1155+ ASSERT_EQ(AV_ERR_OK, vDecSample->RunVideoDec_Surface(g_codecNameDVVideo));
1156+ ASSERT_EQ(AV_ERR_OK, vDecSample->SwitchSurface());
1157+ vDecSample->WaitForEOS();
1158+ 
1159+ auto vDecSample_1 = make_shared<VDecAPI11Sample>();
1160+ vDecSample_1->DEFAULT_WIDTH = 720;
1161+ vDecSample_1->DEFAULT_HEIGHT = 480;
1162+ vDecSample_1->DEFAULT_FRAME_RATE = 30;
1163+ vDecSample_1->outputYuvSurface = true;
1164+ vDecSample_1->autoSwitchSurface = true;
1165+ vDecSample_1->sleepOnFPS = true;
1166+ vDecSample_1->OUT_DIR = "/data/test/media/dv_surf_013_720x480_30fps_nv12_1.yuv";
1167+ vDecSample_1->OUT_DIR2 = "/data/test/media/dv_surf_013_720x480_30fps_nv12_2.yuv";
1168+ ASSERT_EQ(AV_ERR_OK, vDecSample_1->LoadInputFile(INP_DIR_10));
1169+ ASSERT_EQ(AV_ERR_OK, vDecSample_1->RunVideoDec_Surface(g_codecNameDVVideo));
1170+ ASSERT_EQ(AV_ERR_OK, vDecSample_1->SwitchSurface());
1171+ vDecSample_1->WaitForEOS();
1172+ }
1173+}
1174+ 
1175+/**
1176+ * @tc.number : VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_014
1177+ * @tc.name : repeat call setSurface fastly 2 time
1178+ * @tc.desc : function test
1179+ */
1180+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_SWDEC_DVVIDEO_API11_SURF_CHANGE_FUNC_014, TestSize.Level2)
1181+{
1182+ if (cap_dvvideo != nullptr) {
1183+ for (int i = 0; i < 2; i++) {
1184+ auto vDecSample = make_shared<VDecAPI11Sample>();
1185+ vDecSample->DEFAULT_WIDTH = 960;
1186+ vDecSample->DEFAULT_HEIGHT = 720;
1187+ vDecSample->DEFAULT_FRAME_RATE = 60;
1188+ vDecSample->autoSwitchSurface = true;
1189+ vDecSample->sleepOnFPS = true;
1190+ vDecSample->outputYuvSurface = true;
1191+ vDecSample->OUT_DIR = std::string("/data/test/media/dv_surf_func_014_960x720_60fps_"
1192+ + std::to_string(i) + "_1.yuv").c_str();
1193+ vDecSample->OUT_DIR2 = std::string("/data/test/media/dv_surf_func_014_960x720_60fps_"
1194+ + std::to_string(i) + "_2.yuv").c_str();
1195+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_6));
1196+ ASSERT_EQ(AV_ERR_OK, vDecSample->RunVideoDec_Surface(g_codecNameDVVideo));
1197+ ASSERT_EQ(AV_ERR_OK, vDecSample->RepeatCallSetSurface());
1198+ vDecSample->WaitForEOS();
1199+ }
1200+ }
1201+}
1202+ 
1203+/**
1204+ * @tc.number : VIDEO_DECODE_SYNC_SWDVVIDEO_FUNC_0010
1205+ * @tc.name : SyncMode OutputPixelFormat:yuv420p->nv12
1206+ * @tc.desc : function test
1207+ */
1208+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_DECODE_SYNC_SWDVVIDEO_FUNC_0010, TestSize.Level0)
1209+{
1210+ if (cap_dvvideo != nullptr) {
1211+ auto vDecSample = make_shared<VDecAPI11Sample>();
1212+ vDecSample->DEFAULT_WIDTH = 720;
1213+ vDecSample->DEFAULT_HEIGHT = 576;
1214+ vDecSample->DEFAULT_FRAME_RATE = 25;
1215+ vDecSample->outputYuvFlag = true;
1216+ vDecSample->enbleSyncMode = 1;
1217+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV12;
1218+ vDecSample->OUT_DIR = "/data/test/media/dv_sync_func_0010_720x576_25fps_nv12.yuv";
1219+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_0));
1220+ ASSERT_EQ(AV_ERR_OK, vDecSample->CreateVideoDecoder(g_codecNameDVVideo));
1221+ ASSERT_EQ(AV_ERR_OK, vDecSample->ConfigureVideoDecoder());
1222+ ASSERT_EQ(AV_ERR_OK, vDecSample->StartSyncVideoDecoder());
1223+ vDecSample->WaitForEOS();
1224+ ASSERT_EQ(0, vDecSample->errCount);
1225+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
1226+ }
1227+}
1228+ 
1229+/**
1230+ * @tc.number : VIDEO_DECODE_SYNC_SWDVVIDEO_FUNC_0020
1231+ * @tc.name : SyncMode OutputPixelFormat:yuv422p->nv21
1232+ * @tc.desc : function test
1233+ */
1234+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_DECODE_SYNC_SWDVVIDEO_FUNC_0020, TestSize.Level0)
1235+{
1236+ if (cap_dvvideo != nullptr) {
1237+ auto vDecSample = make_shared<VDecAPI11Sample>();
1238+ vDecSample->DEFAULT_WIDTH = 720;
1239+ vDecSample->DEFAULT_HEIGHT = 576;
1240+ vDecSample->DEFAULT_FRAME_RATE = 25;
1241+ vDecSample->outputYuvFlag = true;
1242+ vDecSample->enbleSyncMode = 1;
1243+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV21;
1244+ vDecSample->OUT_DIR = "/data/test/media/dv_sync_func_0020_720x576_25fps_nv21.yuv";
1245+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_0));
1246+ ASSERT_EQ(AV_ERR_OK, vDecSample->CreateVideoDecoder(g_codecNameDVVideo));
1247+ ASSERT_EQ(AV_ERR_OK, vDecSample->ConfigureVideoDecoder());
1248+ ASSERT_EQ(AV_ERR_OK, vDecSample->StartSyncVideoDecoder());
1249+ vDecSample->WaitForEOS();
1250+ ASSERT_EQ(0, vDecSample->errCount);
1251+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
1252+ }
1253+}
1254+ 
1255+/**
1256+ * @tc.number : VIDEO_DECODE_SYNC_SWDVVIDEO_FUNC_0030
1257+ * @tc.name : SyncMode Surface output
1258+ * @tc.desc : function test
1259+ */
1260+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_DECODE_SYNC_SWDVVIDEO_FUNC_0030, TestSize.Level0)
1261+{
1262+ if (cap_dvvideo != nullptr) {
1263+ auto vDecSample = make_shared<VDecAPI11Sample>();
1264+ vDecSample->DEFAULT_WIDTH = 720;
1265+ vDecSample->DEFAULT_HEIGHT = 576;
1266+ vDecSample->DEFAULT_FRAME_RATE = 25;
1267+ vDecSample->enbleSyncMode = 1;
1268+ vDecSample->outputYuvFlag = true;
1269+ vDecSample->outputYuvSurface = true;
1270+ vDecSample->autoSwitchSurface = false;
1271+ vDecSample->SF_OUTPUT = true;
1272+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV21;
1273+ vDecSample->OUT_DIR = "/data/test/media/dv_sync_surf_func_0030_720x576_25fps_nv21.yuv";
1274+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_0));
1275+ ASSERT_EQ(AV_ERR_OK, vDecSample->CreateVideoDecoder(g_codecNameDVVideo));
1276+ ASSERT_EQ(AV_ERR_OK, vDecSample->ConfigureVideoDecoder());
1277+ ASSERT_EQ(AV_ERR_OK, vDecSample->DecodeSetSurface());
1278+ ASSERT_EQ(AV_ERR_OK, vDecSample->StartSyncVideoDecoder());
1279+ vDecSample->WaitForEOS();
1280+ ASSERT_EQ(0, vDecSample->errCount);
1281+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
1282+ }
1283+}
1284+ 
1285+/**
1286+ * @tc.number : VIDEO_DECODE_SYNC_SWDVVIDEO_FUNC_0040
1287+ * @tc.name : SyncMode OutputPixelFormat:yuv420p->RGBA
1288+ * @tc.desc : function test
1289+ */
1290+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_DECODE_SYNC_SWDVVIDEO_FUNC_0040, TestSize.Level1)
1291+{
1292+ if (cap_dvvideo != nullptr) {
1293+ auto vDecSample = make_shared<VDecAPI11Sample>();
1294+ vDecSample->DEFAULT_WIDTH = 720;
1295+ vDecSample->DEFAULT_HEIGHT = 576;
1296+ vDecSample->DEFAULT_FRAME_RATE = 25;
1297+ vDecSample->outputYuvFlag = true;
1298+ vDecSample->enbleSyncMode = 1;
1299+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_RGBA;
1300+ vDecSample->OUT_DIR = "/data/test/media/dv_sync_func_0040_720x576_25fps_rgba.rgba";
1301+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_0));
1302+ ASSERT_EQ(AV_ERR_OK, vDecSample->CreateVideoDecoder(g_codecNameDVVideo));
1303+ ASSERT_EQ(AV_ERR_OK, vDecSample->ConfigureVideoDecoder());
1304+ ASSERT_EQ(AV_ERR_OK, vDecSample->StartSyncVideoDecoder());
1305+ vDecSample->WaitForEOS();
1306+ ASSERT_EQ(0, vDecSample->errCount);
1307+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
1308+ }
1309+}
1310+ 
1311+/**
1312+ * @tc.number : VIDEO_DECODE_SWDVVIDEO_BLANK_FRAME_0010
1313+ * @tc.name : config OH_MD_KEY_VIDEO_DECODER_BLANK_FRAME_ON_SHUTDOWN,buffer
1314+ * @tc.desc : function test
1315+ */
1316+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_DECODE_SWDVVIDEO_BLANK_FRAME_0010, TestSize.Level2)
1317+{
1318+ if (cap_dvvideo != nullptr) {
1319+ auto vDecSample = make_shared<VDecAPI11Sample>();
1320+ vDecSample->DEFAULT_WIDTH = 720;
1321+ vDecSample->DEFAULT_HEIGHT = 576;
1322+ vDecSample->DEFAULT_FRAME_RATE = 25;
1323+ vDecSample->enbleBlankFrame = 1;
1324+ vDecSample->outputYuvFlag = true;
1325+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV12;
1326+ vDecSample->OUT_DIR = "/data/test/media/dv_blank_frame_buffer_0010_720x576_25fps_nv12.yuv";
1327+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_0));
1328+ ASSERT_EQ(AV_ERR_OK, vDecSample->CreateVideoDecoder(g_codecNameDVVideo));
1329+ ASSERT_EQ(AV_ERR_OK, vDecSample->ConfigureVideoDecoder());
1330+ ASSERT_EQ(AV_ERR_OK, vDecSample->SetVideoDecoderCallback());
1331+ ASSERT_EQ(AV_ERR_OK, vDecSample->StartVideoDecoder());
1332+ vDecSample->WaitForEOS();
1333+ ASSERT_EQ(0, vDecSample->errCount);
1334+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
1335+ }
1336+}
1337+ 
1338+/**
1339+ * @tc.number : VIDEO_DECODE_SWDVVIDEO_BLANK_FRAME_0020
1340+ * @tc.name : config OH_MD_KEY_VIDEO_DECODER_BLANK_FRAME_ON_SHUTDOWN, surface
1341+ * @tc.desc : function test
1342+ */
1343+HWTEST_F(DVVideoSwdecFuncNdkTest, VIDEO_DECODE_SWDVVIDEO_BLANK_FRAME_0020, TestSize.Level2)
1344+{
1345+ if (cap_dvvideo != nullptr) {
1346+ auto vDecSample = make_shared<VDecAPI11Sample>();
1347+ vDecSample->DEFAULT_WIDTH = 720;
1348+ vDecSample->DEFAULT_HEIGHT = 576;
1349+ vDecSample->DEFAULT_FRAME_RATE = 25;
1350+ vDecSample->outputYuvSurface = true;
1351+ vDecSample->autoSwitchSurface = false;
1352+ vDecSample->enbleBlankFrame = 1;
1353+ vDecSample->sleepOnFPS = true;
1354+ vDecSample->defualtPixelFormat = AV_PIXEL_FORMAT_NV12;
1355+ vDecSample->OUT_DIR = "/data/test/media/dv_blank_frame_surface_0020_720x576_25fps_nv12.yuv";
1356+ ASSERT_EQ(AV_ERR_OK, vDecSample->LoadInputFile(INP_DIR_0));
1357+ ASSERT_EQ(AV_ERR_OK, vDecSample->RunVideoDec_Surface(g_codecNameDVVideo));
1358+ vDecSample->WaitForEOS();
1359+ ASSERT_EQ(0, vDecSample->errCount);
1360+ ASSERT_EQ(FRAMESIZE25, vDecSample->outFrameCount);
1361+ }
1362+}
1363+ 
1364+} // namespace
Atest/moduletest/vcodec/dvvideoswdecoder/src/state_test.cpp+664-0
@@ -0,0 +1,664 @@
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 <cstdio>
17+#include <iostream>
18+#include <atomic>
19+#include <fstream>
20+#include <mutex>
21+#include <queue>
22+#include <string>
23+#include <thread>
24+ 
25+#include "gtest/gtest.h"
26+#include "videodec_api11_sample.h"
27+using namespace std;
28+using namespace OHOS;
29+using namespace OHOS::Media;
30+using namespace testing::ext;
31+namespace OHOS {
32+namespace Media {
33+class DVVideoSwdecStateNdkTest : public testing::Test {
34+public:
35+ // SetUpTestCase: Called before all test cases
36+ static void SetUpTestCase(void);
37+ // TearDownTestCase: Called after all test case
38+ static void TearDownTestCase(void);
39+ // SetUp: Called before each test cases
40+ void SetUp(void);
41+ // TearDown: Called after each test cases
42+ void TearDown(void);
43+ 
44+protected:
45+ const ::testing::TestInfo *testInfo_ = nullptr;
46+ bool createCodecSuccess_ = false;
47+};
48+ 
49+void DVVideoSwdecStateNdkTest::SetUpTestCase(void) {}
50+void DVVideoSwdecStateNdkTest::TearDownTestCase(void) {}
51+VDecAPI11Sample *vDecSample = NULL;
52+ 
53+void DVVideoSwdecStateNdkTest::SetUp(void)
54+{
55+ vDecSample = new VDecAPI11Sample();
56+ int32_t ret = vDecSample->LoadInputFile("/data/test/media/dvvideo_720x576_yuv420p_25_25frames.avi");
57+ ASSERT_EQ(AV_ERR_OK, ret);
58+ string codeName = "OH.Media.Codec.Decoder.Video.DVVIDEO";
59+ ret = vDecSample->CreateVideoDecoder(codeName);
60+ ASSERT_EQ(AV_ERR_OK, ret);
61+ ret = vDecSample->SetVideoDecoderCallback();
62+ ASSERT_EQ(AV_ERR_OK, ret);
63+ ret = vDecSample->ConfigureVideoDecoder();
64+ ASSERT_EQ(AV_ERR_OK, ret);
65+}
66+ 
67+void DVVideoSwdecStateNdkTest::TearDown(void)
68+{
69+ vDecSample->Release();
70+ delete vDecSample;
71+ vDecSample = nullptr;
72+}
73+ 
74+} // namespace Media
75+} // namespace OHOS
76+ 
77+namespace {
78+/**
79+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_0100
80+ * @tc.name : create-configure-error
81+ * @tc.desc : function test
82+ */
83+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_0100, TestSize.Level3)
84+{
85+ int32_t ret = vDecSample->Flush();
86+ ASSERT_EQ(AV_ERR_INVALID_STATE, ret);
87+ ret = vDecSample->SetVideoDecoderCallback();
88+ ASSERT_EQ(AV_ERR_OK, ret);
89+}
90+ 
91+/**
92+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_0200
93+ * @tc.name : create-configure-start-stop-start
94+ * @tc.desc : function test
95+ */
96+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_0200, TestSize.Level3)
97+{
98+ int32_t ret = vDecSample->Start();
99+ ASSERT_EQ(AV_ERR_OK, ret);
100+ ret = vDecSample->Stop();
101+ ASSERT_EQ(AV_ERR_OK, ret);
102+ ret = vDecSample->Start();
103+ ASSERT_EQ(AV_ERR_OK, ret);
104+}
105+ 
106+/**
107+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_0300
108+ * @tc.name : create-configure-start-stop-release
109+ * @tc.desc : function test
110+ */
111+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_0300, TestSize.Level3)
112+{
113+ int32_t ret = vDecSample->Start();
114+ ASSERT_EQ(AV_ERR_OK, ret);
115+ ret = vDecSample->Stop();
116+ ASSERT_EQ(AV_ERR_OK, ret);
117+ ret = vDecSample->Release();
118+ ASSERT_EQ(AV_ERR_OK, ret);
119+}
120+ 
121+/**
122+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_0400
123+ * @tc.name : create-configure-start-stop-reset
124+ * @tc.desc : function test
125+ */
126+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_0400, TestSize.Level3)
127+{
128+ int32_t ret = vDecSample->Start();
129+ ASSERT_EQ(AV_ERR_OK, ret);
130+ ret = vDecSample->Stop();
131+ ASSERT_EQ(AV_ERR_OK, ret);
132+ ret = vDecSample->Reset();
133+ ASSERT_EQ(AV_ERR_OK, ret);
134+}
135+ 
136+/**
137+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_0500
138+ * @tc.name : create-configure-start-stop-error
139+ * @tc.desc : function test
140+ */
141+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_0500, TestSize.Level3)
142+{
143+ int32_t ret = vDecSample->Start();
144+ ASSERT_EQ(AV_ERR_OK, ret);
145+ ret = vDecSample->Stop();
146+ ASSERT_EQ(AV_ERR_OK, ret);
147+ ret = vDecSample->Flush();
148+ ASSERT_EQ(AV_ERR_INVALID_STATE, ret);
149+ ret = vDecSample->SetVideoDecoderCallback();
150+ ASSERT_EQ(AV_ERR_OK, ret);
151+}
152+ 
153+/**
154+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_0600
155+ * @tc.name : create-configure-start-EOS-stop-start
156+ * @tc.desc : function test
157+ */
158+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_0600, TestSize.Level3)
159+{
160+ vDecSample->AFTER_EOS_DESTORY_CODEC = false;
161+ int32_t ret = vDecSample->StartVideoDecoder();
162+ ASSERT_EQ(AV_ERR_OK, ret);
163+ vDecSample->WaitForEOS();
164+ ASSERT_EQ(AV_ERR_OK, ret);
165+ ASSERT_EQ(0, vDecSample->errCount);
166+ ret = vDecSample->Stop();
167+ ASSERT_EQ(AV_ERR_OK, ret);
168+ ret = vDecSample->Start();
169+ ASSERT_EQ(AV_ERR_OK, ret);
170+}
171+ 
172+/**
173+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_0700
174+ * @tc.name : create-configure-start-EOS-stop-release
175+ * @tc.desc : function test
176+ */
177+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_0700, TestSize.Level3)
178+{
179+ int32_t ret = vDecSample->StartVideoDecoder();
180+ vDecSample->AFTER_EOS_DESTORY_CODEC = false;
181+ vDecSample->WaitForEOS();
182+ ASSERT_EQ(AV_ERR_OK, ret);
183+ ASSERT_EQ(0, vDecSample->errCount);
184+ ret = vDecSample->Stop();
185+ ASSERT_EQ(AV_ERR_OK, ret);
186+ ret = vDecSample->Release();
187+ ASSERT_EQ(AV_ERR_OK, ret);
188+}
189+ 
190+/**
191+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_0800
192+ * @tc.name : create-configure-start-EOS-stop-reset
193+ * @tc.desc : function test
194+ */
195+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_0800, TestSize.Level3)
196+{
197+ int32_t ret = vDecSample->StartVideoDecoder();
198+ ASSERT_EQ(AV_ERR_OK, ret);
199+ vDecSample->AFTER_EOS_DESTORY_CODEC = false;
200+ vDecSample->WaitForEOS();
201+ ASSERT_EQ(AV_ERR_OK, ret);
202+ ASSERT_EQ(0, vDecSample->errCount);
203+ ret = vDecSample->Stop();
204+ ASSERT_EQ(AV_ERR_OK, ret);
205+ ret = vDecSample->Reset();
206+ ASSERT_EQ(AV_ERR_OK, ret);
207+}
208+ 
209+/**
210+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_0900
211+ * @tc.name : create-configure-start-EOS-flush
212+ * @tc.desc : function test
213+ */
214+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_0900, TestSize.Level3)
215+{
216+ int32_t ret = vDecSample->StartVideoDecoder();
217+ vDecSample->AFTER_EOS_DESTORY_CODEC = false;
218+ vDecSample->WaitForEOS();
219+ ASSERT_EQ(AV_ERR_OK, ret);
220+ ASSERT_EQ(0, vDecSample->errCount);
221+ ret = vDecSample->Flush();
222+ ASSERT_EQ(AV_ERR_OK, ret);
223+}
224+ 
225+/**
226+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_1000
227+ * @tc.name : create-configure-start-EOS-flush-start
228+ * @tc.desc : function test
229+ */
230+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_1000, TestSize.Level3)
231+{
232+ int32_t ret = vDecSample->StartVideoDecoder();
233+ vDecSample->AFTER_EOS_DESTORY_CODEC = false;
234+ vDecSample->WaitForEOS();
235+ ASSERT_EQ(AV_ERR_OK, ret);
236+ ASSERT_EQ(0, vDecSample->errCount);
237+ ret = vDecSample->Flush();
238+ ASSERT_EQ(AV_ERR_OK, ret);
239+ ret = vDecSample->Start();
240+ ASSERT_EQ(AV_ERR_OK, ret);
241+}
242+ 
243+/**
244+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_1100
245+ * @tc.name : create-configure-start-EOS-flush-stop
246+ * @tc.desc : function test
247+ */
248+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_1100, TestSize.Level3)
249+{
250+ int32_t ret = vDecSample->StartVideoDecoder();
251+ vDecSample->AFTER_EOS_DESTORY_CODEC = false;
252+ vDecSample->WaitForEOS();
253+ ASSERT_EQ(AV_ERR_OK, ret);
254+ ASSERT_EQ(0, vDecSample->errCount);
255+ ret = vDecSample->Flush();
256+ ASSERT_EQ(AV_ERR_OK, ret);
257+ ret = vDecSample->Stop();
258+ ASSERT_EQ(AV_ERR_OK, ret);
259+}
260+ 
261+/**
262+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_1200
263+ * @tc.name : create-configure-start-EOS-flush-reset
264+ * @tc.desc : function test
265+ */
266+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_1200, TestSize.Level3)
267+{
268+ int32_t ret = vDecSample->StartVideoDecoder();
269+ vDecSample->AFTER_EOS_DESTORY_CODEC = false;
270+ vDecSample->WaitForEOS();
271+ ASSERT_EQ(AV_ERR_OK, ret);
272+ ASSERT_EQ(0, vDecSample->errCount);
273+ ret = vDecSample->Flush();
274+ ASSERT_EQ(AV_ERR_OK, ret);
275+ ret = vDecSample->Reset();
276+ ASSERT_EQ(AV_ERR_OK, ret);
277+}
278+ 
279+/**
280+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_1300
281+ * @tc.name : create-configure-start-EOS-flush-error
282+ * @tc.desc : function test
283+ */
284+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_1300, TestSize.Level3)
285+{
286+ int32_t ret = vDecSample->StartVideoDecoder();
287+ vDecSample->AFTER_EOS_DESTORY_CODEC = false;
288+ vDecSample->WaitForEOS();
289+ ASSERT_EQ(AV_ERR_OK, ret);
290+ ASSERT_EQ(0, vDecSample->errCount);
291+ ret = vDecSample->Flush();
292+ ASSERT_EQ(AV_ERR_OK, ret);
293+ ret = vDecSample->Release();
294+ ASSERT_EQ(AV_ERR_OK, ret);
295+ ret = vDecSample->ConfigureVideoDecoder();
296+ ASSERT_EQ(AV_ERR_INVALID_VAL, ret);
297+}
298+ 
299+/**
300+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_1400
301+ * @tc.name : create-configure-start-EOS-reset-configure
302+ * @tc.desc : function test
303+ */
304+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_1400, TestSize.Level3)
305+{
306+ int32_t ret = vDecSample->StartVideoDecoder();
307+ vDecSample->AFTER_EOS_DESTORY_CODEC = false;
308+ vDecSample->WaitForEOS();
309+ ASSERT_EQ(AV_ERR_OK, ret);
310+ ASSERT_EQ(0, vDecSample->errCount);
311+ ret = vDecSample->Reset();
312+ ASSERT_EQ(AV_ERR_OK, ret);
313+ ret = vDecSample->ConfigureVideoDecoder();
314+ ASSERT_EQ(AV_ERR_OK, ret);
315+}
316+ 
317+/**
318+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_1500
319+ * @tc.name : create-configure-start-EOS-reset-release
320+ * @tc.desc : function test
321+ */
322+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_1500, TestSize.Level3)
323+{
324+ int32_t ret = vDecSample->StartVideoDecoder();
325+ vDecSample->AFTER_EOS_DESTORY_CODEC = false;
326+ vDecSample->WaitForEOS();
327+ ASSERT_EQ(AV_ERR_OK, ret);
328+ ASSERT_EQ(0, vDecSample->errCount);
329+ ret = vDecSample->Reset();
330+ ASSERT_EQ(AV_ERR_OK, ret);
331+ ret = vDecSample->Release();
332+ ASSERT_EQ(AV_ERR_OK, ret);
333+}
334+ 
335+/**
336+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_1600
337+ * @tc.name : create-configure-start-EOS-reset-error
338+ * @tc.desc : function test
339+ */
340+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_1600, TestSize.Level3)
341+{
342+ int32_t ret = vDecSample->StartVideoDecoder();
343+ vDecSample->AFTER_EOS_DESTORY_CODEC = false;
344+ vDecSample->WaitForEOS();
345+ ASSERT_EQ(AV_ERR_OK, ret);
346+ ASSERT_EQ(0, vDecSample->errCount);
347+ ret = vDecSample->Reset();
348+ ASSERT_EQ(AV_ERR_OK, ret);
349+ ret = vDecSample->Start();
350+ ASSERT_EQ(AV_ERR_INVALID_STATE, ret);
351+ ret = vDecSample->Stop();
352+ ASSERT_EQ(AV_ERR_INVALID_STATE, ret);
353+ ret = vDecSample->Flush();
354+ ASSERT_EQ(AV_ERR_INVALID_STATE, ret);
355+}
356+ 
357+/**
358+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_1700
359+ * @tc.name : create-configure-start-flush-start-flush
360+ * @tc.desc : function test
361+ */
362+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_1700, TestSize.Level3)
363+{
364+ int32_t ret = vDecSample->Start();
365+ ASSERT_EQ(AV_ERR_OK, ret);
366+ ret = vDecSample->Flush();
367+ ASSERT_EQ(AV_ERR_OK, ret);
368+ ret = vDecSample->Start();
369+ ASSERT_EQ(AV_ERR_OK, ret);
370+ ret = vDecSample->Flush();
371+ ASSERT_EQ(AV_ERR_OK, ret);
372+}
373+ 
374+/**
375+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_1800
376+ * @tc.name : create-configure-start-flush-start-eos
377+ * @tc.desc : function test
378+ */
379+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_1800, TestSize.Level3)
380+{
381+ int32_t ret = vDecSample->Start();
382+ ASSERT_EQ(AV_ERR_OK, ret);
383+ ret = vDecSample->Flush();
384+ ASSERT_EQ(AV_ERR_OK, ret);
385+ ret = vDecSample->Start();
386+ ASSERT_EQ(AV_ERR_OK, ret);
387+ ret = vDecSample->state_EOS();
388+ ASSERT_EQ(AV_ERR_OK, ret);
389+}
390+ 
391+/**
392+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_1900
393+ * @tc.name : create-configure-start-flush-start-stop
394+ * @tc.desc : function test
395+ */
396+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_1900, TestSize.Level3)
397+{
398+ int32_t ret = vDecSample->Start();
399+ ASSERT_EQ(AV_ERR_OK, ret);
400+ ret = vDecSample->Flush();
401+ ASSERT_EQ(AV_ERR_OK, ret);
402+ ret = vDecSample->Start();
403+ ASSERT_EQ(AV_ERR_OK, ret);
404+ ret = vDecSample->Stop();
405+ ASSERT_EQ(AV_ERR_OK, ret);
406+}
407+ 
408+/**
409+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_2000
410+ * @tc.name : create-configure-start-flush-start-reset
411+ * @tc.desc : function test
412+ */
413+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_2000, TestSize.Level3)
414+{
415+ int32_t ret = vDecSample->Start();
416+ ASSERT_EQ(AV_ERR_OK, ret);
417+ ret = vDecSample->Flush();
418+ ASSERT_EQ(AV_ERR_OK, ret);
419+ ret = vDecSample->Start();
420+ ASSERT_EQ(AV_ERR_OK, ret);
421+ ret = vDecSample->Reset();
422+ ASSERT_EQ(AV_ERR_OK, ret);
423+}
424+ 
425+/**
426+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_2100
427+ * @tc.name : create-configure-start-flush-start-error
428+ * @tc.desc : function test
429+ */
430+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_2100, TestSize.Level3)
431+{
432+ int32_t ret = vDecSample->Start();
433+ ASSERT_EQ(AV_ERR_OK, ret);
434+ ret = vDecSample->Flush();
435+ ASSERT_EQ(AV_ERR_OK, ret);
436+ ret = vDecSample->Start();
437+ ASSERT_EQ(AV_ERR_OK, ret);
438+ ret = vDecSample->ConfigureVideoDecoder();
439+ ASSERT_EQ(AV_ERR_INVALID_STATE, ret);
440+ ret = vDecSample->SetVideoDecoderCallback();
441+ ASSERT_EQ(AV_ERR_OK, ret);
442+ ret = vDecSample->Release();
443+ ASSERT_EQ(AV_ERR_OK, ret);
444+}
445+ 
446+/**
447+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_2200
448+ * @tc.name : create-configure-start-flush-start
449+ * @tc.desc : function test
450+ */
451+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_2200, TestSize.Level3)
452+{
453+ int32_t ret = vDecSample->Start();
454+ ASSERT_EQ(AV_ERR_OK, ret);
455+ ret = vDecSample->Flush();
456+ ASSERT_EQ(AV_ERR_OK, ret);
457+ ret = vDecSample->Stop();
458+ ASSERT_EQ(AV_ERR_OK, ret);
459+ ret = vDecSample->Start();
460+ ASSERT_EQ(AV_ERR_OK, ret);
461+}
462+ 
463+/**
464+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_2300
465+ * @tc.name : create-configure-start-flush-stop-start
466+ * @tc.desc : function test
467+ */
468+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_2300, TestSize.Level3)
469+{
470+ int32_t ret = vDecSample->Start();
471+ ASSERT_EQ(AV_ERR_OK, ret);
472+ ret = vDecSample->Flush();
473+ ASSERT_EQ(AV_ERR_OK, ret);
474+ ret = vDecSample->Stop();
475+ ASSERT_EQ(AV_ERR_OK, ret);
476+ ret = vDecSample->Start();
477+ ASSERT_EQ(AV_ERR_OK, ret);
478+}
479+ 
480+/**
481+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_2400
482+ * @tc.name : create-configure-start-flush-stop-reset
483+ * @tc.desc : function test
484+ */
485+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_2400, TestSize.Level3)
486+{
487+ int32_t ret = vDecSample->Start();
488+ ASSERT_EQ(AV_ERR_OK, ret);
489+ ret = vDecSample->Flush();
490+ ASSERT_EQ(AV_ERR_OK, ret);
491+ ret = vDecSample->Stop();
492+ ASSERT_EQ(AV_ERR_OK, ret);
493+ ret = vDecSample->Reset();
494+ ASSERT_EQ(AV_ERR_OK, ret);
495+}
496+ 
497+/**
498+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_2500
499+ * @tc.name : create-configure-start-flush-stop-error
500+ * @tc.desc : function test
501+ */
502+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_2500, TestSize.Level3)
503+{
504+ int32_t ret = vDecSample->Start();
505+ ASSERT_EQ(AV_ERR_OK, ret);
506+ ret = vDecSample->Flush();
507+ ASSERT_EQ(AV_ERR_OK, ret);
508+ ret = vDecSample->Stop();
509+ ASSERT_EQ(AV_ERR_OK, ret);
510+ ret = vDecSample->Flush();
511+ ASSERT_EQ(AV_ERR_INVALID_STATE, ret);
512+ ret = vDecSample->SetVideoDecoderCallback();
513+ ASSERT_EQ(AV_ERR_OK, ret);
514+}
515+ 
516+/**
517+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_2600
518+ * @tc.name : create-configure-start-flush-reset-configure
519+ * @tc.desc : function test
520+ */
521+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_2600, TestSize.Level3)
522+{
523+ int32_t ret = vDecSample->Start();
524+ ASSERT_EQ(AV_ERR_OK, ret);
525+ ret = vDecSample->Flush();
526+ ASSERT_EQ(AV_ERR_OK, ret);
527+ ret = vDecSample->Reset();
528+ ASSERT_EQ(AV_ERR_OK, ret);
529+ ret = vDecSample->ConfigureVideoDecoder();
530+ ASSERT_EQ(AV_ERR_OK, ret);
531+}
532+ 
533+/**
534+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_2700
535+ * @tc.name : create-configure-start-flush-reset-release
536+ * @tc.desc : function test
537+ */
538+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_2700, TestSize.Level3)
539+{
540+ int32_t ret = vDecSample->Start();
541+ ASSERT_EQ(AV_ERR_OK, ret);
542+ ret = vDecSample->Flush();
543+ ASSERT_EQ(AV_ERR_OK, ret);
544+ ret = vDecSample->Reset();
545+ ASSERT_EQ(AV_ERR_OK, ret);
546+ ret = vDecSample->Release();
547+ ASSERT_EQ(AV_ERR_OK, ret);
548+}
549+ 
550+/**
551+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_2800
552+ * @tc.name : create-configure-start-flush-reset-error
553+ * @tc.desc : function test
554+ */
555+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_2800, TestSize.Level3)
556+{
557+ int32_t ret = vDecSample->Start();
558+ ASSERT_EQ(AV_ERR_OK, ret);
559+ ret = vDecSample->Flush();
560+ ASSERT_EQ(AV_ERR_OK, ret);
561+ ret = vDecSample->Reset();
562+ ASSERT_EQ(AV_ERR_OK, ret);
563+ ret = vDecSample->Start();
564+ ASSERT_EQ(AV_ERR_INVALID_STATE, ret);
565+ ret = vDecSample->Stop();
566+ ASSERT_EQ(AV_ERR_INVALID_STATE, ret);
567+ ret = vDecSample->Flush();
568+ ASSERT_EQ(AV_ERR_INVALID_STATE, ret);
569+ ret = vDecSample->SetVideoDecoderCallback();
570+ ASSERT_EQ(AV_ERR_OK, ret);
571+}
572+ 
573+/**
574+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_2900
575+ * @tc.name : create-configure-start-reset-configure
576+ * @tc.desc : function test
577+ */
578+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_2900, TestSize.Level3)
579+{
580+ int32_t ret = vDecSample->Start();
581+ ASSERT_EQ(AV_ERR_OK, ret);
582+ ret = vDecSample->Reset();
583+ ASSERT_EQ(AV_ERR_OK, ret);
584+ ret = vDecSample->ConfigureVideoDecoder();
585+ ASSERT_EQ(AV_ERR_OK, ret);
586+}
587+ 
588+/**
589+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_3000
590+ * @tc.name : create-configure-start-reset-release
591+ * @tc.desc : function test
592+ */
593+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_3000, TestSize.Level3)
594+{
595+ int32_t ret = vDecSample->Start();
596+ ASSERT_EQ(AV_ERR_OK, ret);
597+ ret = vDecSample->Reset();
598+ ASSERT_EQ(AV_ERR_OK, ret);
599+ ret = vDecSample->Release();
600+ ASSERT_EQ(AV_ERR_OK, ret);
601+}
602+ 
603+/**
604+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_3100
605+ * @tc.name : create-configure-start-reset-error
606+ * @tc.desc : function test
607+ */
608+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_3100, TestSize.Level3)
609+{
610+ int32_t ret = vDecSample->Start();
611+ ASSERT_EQ(AV_ERR_OK, ret);
612+ ret = vDecSample->Reset();
613+ ASSERT_EQ(AV_ERR_OK, ret);
614+ ret = vDecSample->Start();
615+ ASSERT_EQ(AV_ERR_INVALID_STATE, ret);
616+ ret = vDecSample->Stop();
617+ ASSERT_EQ(AV_ERR_INVALID_STATE, ret);
618+ ret = vDecSample->Flush();
619+ ASSERT_EQ(AV_ERR_INVALID_STATE, ret);
620+ ret = vDecSample->SetVideoDecoderCallback();
621+ ASSERT_EQ(AV_ERR_OK, ret);
622+}
623+ 
624+/**
625+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_3200
626+ * @tc.name : create-configure-start-error
627+ * @tc.desc : function test
628+ */
629+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_3200, TestSize.Level3)
630+{
631+ int32_t ret = vDecSample->Start();
632+ ASSERT_EQ(AV_ERR_OK, ret);
633+ ret = vDecSample->ConfigureVideoDecoder();
634+ ASSERT_EQ(AV_ERR_INVALID_STATE, ret);
635+ ret = vDecSample->SetVideoDecoderCallback();
636+ ASSERT_EQ(AV_ERR_OK, ret);
637+ ret = vDecSample->Release();
638+ ASSERT_EQ(AV_ERR_OK, ret);
639+}
640+ 
641+/**
642+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_3300
643+ * @tc.name : create-configure-reset-configure
644+ * @tc.desc : function test
645+ */
646+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_3300, TestSize.Level3)
647+{
648+ int32_t ret = vDecSample->Reset();
649+ ASSERT_EQ(AV_ERR_OK, ret);
650+ ret = vDecSample->ConfigureVideoDecoder();
651+ ASSERT_EQ(AV_ERR_OK, ret);
652+}
653+ 
654+/**
655+ * @tc.number : VIDEO_SWDEC_DVVIDEO_STATE_3400
656+ * @tc.name : create-configure-release
657+ * @tc.desc : function test
658+ */
659+HWTEST_F(DVVideoSwdecStateNdkTest, VIDEO_SWDEC_DVVIDEO_STATE_3400, TestSize.Level3)
660+{
661+ int32_t ret = vDecSample->Release();
662+ ASSERT_EQ(AV_ERR_OK, ret);
663+}
664+} // namespace
Atest/moduletest/vcodec/dvvideoswdecoder/src/videodec_api11_sample.cpp+1259-0
@@ -0,0 +1,1259 @@
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+#include "videodec_api11_sample.h"
16+ 
17+#include <arpa/inet.h>
18+#include <sys/time.h>
19+ 
20+#include <utility>
21+ 
22+#include "openssl/crypto.h"
23+#include "openssl/sha.h"
24+using namespace OHOS;
25+using namespace OHOS::Media;
26+using namespace std;
27+namespace {
28+constexpr int64_t NANOS_IN_SECOND = 1000000000L;
29+constexpr int64_t MICRO_IN_SECOND = 1000000L;
30+constexpr int64_t NANOS_IN_MICRO = 1000L;
31+constexpr int32_t THREE = 3;
32+constexpr int32_t EIGHT = 8;
33+constexpr int32_t TEN = 10;
34+constexpr int32_t SIXTEEN = 16;
35+constexpr int32_t TWENTY_FOUR = 24;
36+constexpr uint32_t START_CODE_SIZE = 4;
37+constexpr int32_t DEFAULT_ANGLE = 90;
38+constexpr uint32_t MILLION = 1000000;
39+SHA512_CTX g_c;
40+unsigned char g_md[SHA512_DIGEST_LENGTH];
41+VDecAPI11Sample *dec_sample = nullptr;
42+int32_t g_strideSurface = 0;
43+int32_t g_sliceSurface = 0;
44+bool g_yuvSurface = false;
45+ 
46+int32_t g_inputFIleFd = -1;
47+int32_t g_trackCount = 0;
48+int32_t g_trackIndex = -1;
49+ 
50+void clearIntqueue(std::queue<uint32_t> &q)
51+{
52+ std::queue<uint32_t> empty;
53+ swap(empty, q);
54+}
55+ 
56+void clearBufferqueue(std::queue<OH_AVCodecBufferAttr> &q)
57+{
58+ std::queue<OH_AVCodecBufferAttr> empty;
59+ swap(empty, q);
60+}
61+} // namespace
62+ 
63+class ConsumerListenerBuffer : public IBufferConsumerListener {
64+public:
65+ ConsumerListenerBuffer(sptr<Surface> cs, std::string_view name) : cs(cs)
66+ {
67+ outFile_ = std::make_unique<std::ofstream>();
68+ outFile_->open(name.data(), std::ios::out | std::ios::binary);
69+ cout << "in surface buffer open file : " << name.data() << endl;
70+ };
71+ ~ConsumerListenerBuffer()
72+ {
73+ if (outFile_ != nullptr) {
74+ outFile_->close();
75+ }
76+ }
77+ void OnBufferAvailable() override
78+ {
79+ sptr<SurfaceBuffer> buffer;
80+ int32_t flushFence;
81+ cs->AcquireBuffer(buffer, flushFence, timestamp, damage);
82+ if (buffer == nullptr) {
83+ cout << "surface is nullptr" << endl;
84+ return;
85+ } else {
86+ int32_t frameSize = (g_strideSurface * g_sliceSurface * THREE) >> 1;
87+ cout << "surface buffer written frameSize:" << frameSize << ", buffer size:" << buffer->GetSize() << endl;
88+ if (g_yuvSurface && outFile_ != nullptr && frameSize <= buffer->GetSize()) {
89+ outFile_->write(reinterpret_cast<char *>(buffer->GetVirAddr()), frameSize);
90+ }
91+ }
92+ cs->ReleaseBuffer(buffer, -1);
93+ }
94+ 
95+private:
96+ int64_t timestamp = 0;
97+ Rect damage = {};
98+ sptr<Surface> cs{nullptr};
99+ std::unique_ptr<std::ofstream> outFile_;
100+};
101+ 
102+VDecAPI11Sample::~VDecAPI11Sample()
103+{
104+ cout << "VDecAPI11Sample::~VDecAPI11Sample()" << endl;
105+ g_yuvSurface = false;
106+ for (int i = 0; i < MAX_SURF_NUM; i++) {
107+ if (nativeWindow[i]) {
108+ OH_NativeWindow_DestroyNativeWindow(nativeWindow[i]);
109+ nativeWindow[i] = nullptr;
110+ }
111+ }
112+ Stop();
113+ Release();
114+ 
115+ if (trackFormat != nullptr) {
116+ OH_AVFormat_Destroy(trackFormat);
117+ trackFormat = nullptr;
118+ }
119+ 
120+ if (sourceFormat != nullptr) {
121+ OH_AVFormat_Destroy(sourceFormat);
122+ sourceFormat = nullptr;
123+ }
124+ 
125+ if (demuxer != nullptr) {
126+ OH_AVDemuxer_Destroy(demuxer);
127+ demuxer = nullptr;
128+ }
129+ 
130+ if (videoSource != nullptr) {
131+ OH_AVSource_Destroy(videoSource);
132+ videoSource = nullptr;
133+ }
134+ 
135+ if (g_inputFIleFd > 0) {
136+ close(g_inputFIleFd);
137+ g_inputFIleFd = -1;
138+ }
139+ 
140+ g_trackCount = 0;
141+ g_trackIndex = -1;
142+}
143+ 
144+void VdecAPI11Error(OH_AVCodec *codec, int32_t errorCode, void *userData)
145+{
146+ if (errorCode == AV_ERR_UNKNOWN) {
147+ dec_sample->isRunning_.store(false);
148+ dec_sample->signal_->inCond_.notify_all();
149+ dec_sample->signal_->outCond_.notify_all();
150+ dec_sample->isonError = true;
151+ }
152+ cout << "Error errorCode=" << errorCode << endl;
153+}
154+ 
155+void VdecAPI11FormatChanged(OH_AVCodec *codec, OH_AVFormat *format, void *userData)
156+{
157+ int32_t currentWidth = 0;
158+ int32_t currentHeight = 0;
159+ int32_t stride = 0;
160+ int32_t sliceHeight = 0;
161+ OH_AVFormat_GetIntValue(format, OH_MD_KEY_WIDTH, &currentWidth);
162+ OH_AVFormat_GetIntValue(format, OH_MD_KEY_HEIGHT, &currentHeight);
163+ OH_AVFormat_GetIntValue(format, OH_MD_KEY_VIDEO_STRIDE, &stride);
164+ OH_AVFormat_GetIntValue(format, OH_MD_KEY_VIDEO_SLICE_HEIGHT, &sliceHeight);
165+ dec_sample->DEFAULT_WIDTH = currentWidth;
166+ dec_sample->DEFAULT_HEIGHT = currentHeight;
167+ g_strideSurface = stride;
168+ g_sliceSurface = sliceHeight;
169+ cout << "currentWidth:" << currentWidth << ", currentHeight:" << currentHeight
170+ << ", g_strideSurface:" << g_strideSurface << ", g_sliceSurface:" << g_sliceSurface << endl;
171+ if (stride <= 0 || sliceHeight <= 0) {
172+ dec_sample->errCount++;
173+ }
174+}
175+ 
176+void VdecAPI11InputDataReady(OH_AVCodec *codec, uint32_t index, OH_AVBuffer *data, void *userData)
177+{
178+ if (dec_sample->inputCallbackFlush && dec_sample->outCount > 1) {
179+ OH_VideoDecoder_Flush(codec);
180+ cout << "OH_VideoDecoder_Flush end" << endl;
181+ dec_sample->isRunning_.store(false);
182+ dec_sample->signal_->inCond_.notify_all();
183+ dec_sample->signal_->outCond_.notify_all();
184+ return;
185+ }
186+ if (dec_sample->inputCallbackStop && dec_sample->outCount > 1) {
187+ OH_VideoDecoder_Stop(codec);
188+ cout << "OH_VideoDecoder_Stop end" << endl;
189+ dec_sample->isRunning_.store(false);
190+ dec_sample->signal_->inCond_.notify_all();
191+ dec_sample->signal_->outCond_.notify_all();
192+ return;
193+ }
194+ VDecAPI11Signal *signal = static_cast<VDecAPI11Signal *>(userData);
195+ unique_lock<mutex> lock(signal->inMutex_);
196+ signal->inIdxQueue_.push(index);
197+ signal->inBufferQueue_.push(data);
198+ signal->inCond_.notify_all();
199+}
200+ 
201+void VdecAPI11OutputDataReady(OH_AVCodec *codec, uint32_t index, OH_AVBuffer *data, void *userData)
202+{
203+ if (dec_sample->outputCallbackFlush && dec_sample->outCount > 1) {
204+ OH_VideoDecoder_Flush(codec);
205+ cout << "OH_VideoDecoder_Flush end" << endl;
206+ dec_sample->isRunning_.store(false);
207+ dec_sample->signal_->inCond_.notify_all();
208+ dec_sample->signal_->outCond_.notify_all();
209+ return;
210+ }
211+ if (dec_sample->outputCallbackStop && dec_sample->outCount > 1) {
212+ OH_VideoDecoder_Stop(codec);
213+ cout << "OH_VideoDecoder_Stop end" << endl;
214+ dec_sample->isRunning_.store(false);
215+ dec_sample->signal_->inCond_.notify_all();
216+ dec_sample->signal_->outCond_.notify_all();
217+ return;
218+ }
219+ VDecAPI11Signal *signal = static_cast<VDecAPI11Signal *>(userData);
220+ unique_lock<mutex> lock(signal->outMutex_);
221+ signal->outIdxQueue_.push(index);
222+ signal->outBufferQueue_.push(data);
223+ signal->outCond_.notify_all();
224+}
225+ 
226+void VDecAPI11Sample::Flush_buffer()
227+{
228+ unique_lock<mutex> inLock(signal_->inMutex_);
229+ clearIntqueue(signal_->inIdxQueue_);
230+ std::queue<OH_AVBuffer *> empty;
231+ swap(empty, signal_->inBufferQueue_);
232+ signal_->inCond_.notify_all();
233+ inLock.unlock();
234+ unique_lock<mutex> outLock(signal_->outMutex_);
235+ clearIntqueue(signal_->outIdxQueue_);
236+ clearBufferqueue(signal_->attrQueue_);
237+ signal_->outCond_.notify_all();
238+ outLock.unlock();
239+}
240+ 
241+bool VDecAPI11Sample::MdCompare(unsigned char buffer[], int len, const char *source[])
242+{
243+ (void)buffer;
244+ (void)source;
245+ bool result = true;
246+ for (int i = 0; i < len; i++) {
247+ }
248+ return result;
249+}
250+ 
251+int64_t VDecAPI11Sample::GetInputFileSize(const char *inputFileName)
252+{
253+ int64_t fileSize = 0;
254+ if (inputFileName != nullptr) {
255+ struct stat fileStatus {};
256+ if (stat(inputFileName, &fileStatus) == 0) {
257+ fileSize = static_cast<int64_t>(fileStatus.st_size);
258+ }
259+ }
260+ return fileSize;
261+}
262+ 
263+int32_t VDecAPI11Sample::LoadInputFile(const char *inputFileName)
264+{
265+ g_inputFIleFd = open(inputFileName, O_RDONLY);
266+ int64_t size = GetInputFileSize(inputFileName);
267+ cout << "LoadInputFile() inputFileName is " << inputFileName << ", g_inputFIleFd is " << g_inputFIleFd
268+ << ", size is " << size << endl;
269+ if (g_inputFIleFd < 0) {
270+ cout << "open intputFile failed !" << endl;
271+ return AV_ERR_UNKNOWN;
272+ }
273+ videoSource = OH_AVSource_CreateWithFD(g_inputFIleFd, 0, size);
274+ if (videoSource == nullptr) {
275+ cout << "open intputFile failed !" << endl;
276+ return AV_ERR_UNKNOWN;
277+ }
278+ demuxer = OH_AVDemuxer_CreateWithSource(videoSource);
279+ if (demuxer == nullptr) {
280+ cout << "OH_AVDemuxer_CreateWithSource failed !" << endl;
281+ return AV_ERR_UNKNOWN;
282+ }
283+ sourceFormat = OH_AVSource_GetSourceFormat(videoSource);
284+ if (sourceFormat == nullptr) {
285+ cout << "OH_AVSource_GetSourceFormat failed !" << endl;
286+ return AV_ERR_UNKNOWN;
287+ }
288+ if (!OH_AVFormat_GetIntValue(sourceFormat, OH_MD_KEY_TRACK_COUNT, &g_trackCount)) {
289+ cout << "Get track_count failed !" << endl;
290+ return AV_ERR_UNKNOWN;
291+ }
292+ if (g_trackCount < 0) {
293+ cout << "this video have no video track. g_trackCount is " << g_trackCount << endl;
294+ return AV_ERR_UNKNOWN;
295+ }
296+ for (int32_t index = 0; index < g_trackCount; index++) {
297+ trackFormat = OH_AVSource_GetTrackFormat(videoSource, index);
298+ int trackType = 0;
299+ if (trackFormat && OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &trackType)) {
300+ if (trackType == MEDIA_TYPE_VID) {
301+ g_trackIndex = index;
302+ break;
303+ }
304+ }
305+ }
306+ OH_AVErrCode ret = OH_AVDemuxer_SelectTrackByID(demuxer, g_trackIndex);
307+ if (ret != AV_ERR_OK) {
308+ cout << "OH_AVDemuxer_SelectTrackByID failed ! by g_trackIndex[" << g_trackIndex << "]" << endl;
309+ return AV_ERR_UNKNOWN;
310+ }
311+ return AV_ERR_OK;
312+}
313+ 
314+int64_t VDecAPI11Sample::GetSystemTimeUs()
315+{
316+ struct timespec now;
317+ (void)clock_gettime(CLOCK_BOOTTIME, &now);
318+ int64_t nanoTime = (int64_t)now.tv_sec * NANOS_IN_SECOND + now.tv_nsec;
319+ return nanoTime / NANOS_IN_MICRO;
320+}
321+ 
322+int32_t VDecAPI11Sample::ConfigureVideoDecoder()
323+{
324+ if (autoSwitchSurface) {
325+ switchSurfaceFlag = (switchSurfaceFlag == 1) ? 0 : 1;
326+ if (OH_VideoDecoder_SetSurface(vdec_, nativeWindow[switchSurfaceFlag]) != AV_ERR_INVALID_STATE) {
327+ errCount++;
328+ }
329+ }
330+ OH_AVFormat *format = OH_AVFormat_Create();
331+ if (format == nullptr) {
332+ cout << "Fatal: Failed to create format" << endl;
333+ return AV_ERR_UNKNOWN;
334+ }
335+ if (maxInputSize > 0) {
336+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_MAX_INPUT_SIZE, maxInputSize);
337+ }
338+ originalWidth = DEFAULT_WIDTH;
339+ originalHeight = DEFAULT_HEIGHT;
340+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
341+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
342+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, defualtPixelFormat);
343+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
344+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_ENABLE_SYNC_MODE, enbleSyncMode);
345+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_VIDEO_DECODER_BLANK_FRAME_ON_SHUTDOWN, enbleBlankFrame);
346+ int ret = OH_VideoDecoder_Configure(vdec_, format);
347+ OH_AVFormat_Destroy(format);
348+ return ret;
349+}
350+ 
351+void VDecAPI11Sample::CreateSurface()
352+{
353+ cs[0] = Surface::CreateSurfaceAsConsumer();
354+ if (cs[0] == nullptr) {
355+ cout << "Create the surface consummer fail" << endl;
356+ return;
357+ }
358+ GSError err = cs[0]->SetDefaultUsage(BUFFER_USAGE_MEM_DMA | BUFFER_USAGE_VIDEO_DECODER | BUFFER_USAGE_CPU_READ);
359+ if (err == GSERROR_OK) {
360+ cout << "set consumer usage succ" << endl;
361+ } else {
362+ cout << "set consumer usage failed" << endl;
363+ }
364+ sptr<IBufferConsumerListener> listener = new ConsumerListenerBuffer(cs[0], OUT_DIR);
365+ cs[0]->RegisterConsumerListener(listener);
366+ auto p = cs[0]->GetProducer();
367+ ps[0] = Surface::CreateSurfaceAsProducer(p);
368+ nativeWindow[0] = CreateNativeWindowFromSurface(&ps[0]);
369+ if (autoSwitchSurface) {
370+ cs[1] = Surface::CreateSurfaceAsConsumer();
371+ sptr<IBufferConsumerListener> listener2 = new ConsumerListenerBuffer(cs[1], OUT_DIR2);
372+ cs[1]->RegisterConsumerListener(listener2);
373+ auto p2 = cs[1]->GetProducer();
374+ ps[1] = Surface::CreateSurfaceAsProducer(p2);
375+ nativeWindow[1] = CreateNativeWindowFromSurface(&ps[1]);
376+ }
377+}
378+ 
379+int32_t VDecAPI11Sample::RunVideoDec_Surface(string codeName)
380+{
381+ SF_OUTPUT = true;
382+ int err = AV_ERR_OK;
383+ CreateSurface();
384+ if (!nativeWindow[0]) {
385+ cout << "Failed to create surface" << endl;
386+ return AV_ERR_UNKNOWN;
387+ }
388+ err = CreateVideoDecoder(codeName);
389+ if (err != AV_ERR_OK) {
390+ cout << "Failed to create video decoder" << endl;
391+ return err;
392+ }
393+ err = SetVideoDecoderCallback();
394+ if (err != AV_ERR_OK) {
395+ cout << "Failed to setCallback" << endl;
396+ Release();
397+ return err;
398+ }
399+ err = ConfigureVideoDecoder();
400+ if (err != AV_ERR_OK) {
401+ cout << "Failed to configure video decoder" << endl;
402+ Release();
403+ return err;
404+ }
405+ err = OH_VideoDecoder_SetSurface(vdec_, nativeWindow[0]);
406+ if (err != AV_ERR_OK) {
407+ cout << "Failed to set surface" << endl;
408+ return err;
409+ }
410+ err = StartVideoDecoder();
411+ if (err != AV_ERR_OK) {
412+ cout << "Failed to start video decoder" << endl;
413+ Release();
414+ return err;
415+ }
416+ return err;
417+}
418+ 
419+int32_t VDecAPI11Sample::RunVideoDec(string codeName)
420+{
421+ SF_OUTPUT = false;
422+ int err = CreateVideoDecoder(codeName);
423+ if (err != AV_ERR_OK) {
424+ cout << "Failed to create video decoder" << endl;
425+ return err;
426+ }
427+ 
428+ err = ConfigureVideoDecoder();
429+ if (err != AV_ERR_OK) {
430+ cout << "Failed to configure video decoder" << endl;
431+ Release();
432+ return err;
433+ }
434+ 
435+ err = SetVideoDecoderCallback();
436+ if (err != AV_ERR_OK) {
437+ cout << "Failed to setCallback" << endl;
438+ Release();
439+ return err;
440+ }
441+ 
442+ err = StartVideoDecoder();
443+ if (err != AV_ERR_OK) {
444+ cout << "Failed to start video decoder" << endl;
445+ Release();
446+ return err;
447+ }
448+ return err;
449+}
450+ 
451+int32_t VDecAPI11Sample::SetVideoDecoderCallback()
452+{
453+ signal_ = new VDecAPI11Signal();
454+ if (signal_ == nullptr) {
455+ cout << "Failed to new VDecAPI11Signal" << endl;
456+ return AV_ERR_UNKNOWN;
457+ }
458+ 
459+ cb_.onError = VdecAPI11Error;
460+ cb_.onStreamChanged = VdecAPI11FormatChanged;
461+ cb_.onNeedInputBuffer = VdecAPI11InputDataReady;
462+ cb_.onNewOutputBuffer = VdecAPI11OutputDataReady;
463+ return OH_VideoDecoder_RegisterCallback(vdec_, cb_, static_cast<void *>(signal_));
464+}
465+ 
466+void VDecAPI11Sample::ReleaseInFile()
467+{
468+ if (inFile_ != nullptr) {
469+ if (inFile_->is_open()) {
470+ inFile_->close();
471+ }
472+ inFile_.reset();
473+ inFile_ = nullptr;
474+ }
475+}
476+ 
477+void VDecAPI11Sample::StopInloop()
478+{
479+ if (inputLoop_ != nullptr && inputLoop_->joinable()) {
480+ unique_lock<mutex> lock(signal_->inMutex_);
481+ clearIntqueue(signal_->inIdxQueue_);
482+ isRunning_.store(false);
483+ signal_->inCond_.notify_all();
484+ lock.unlock();
485+ 
486+ inputLoop_->join();
487+ inputLoop_.reset();
488+ }
489+}
490+ 
491+int32_t VDecAPI11Sample::CreateVideoDecoder(string codeName)
492+{
493+ vdec_ = OH_VideoDecoder_CreateByName(codeName.c_str());
494+ dec_sample = this;
495+ return vdec_ == nullptr ? AV_ERR_UNKNOWN : AV_ERR_OK;
496+}
497+ 
498+int32_t VDecAPI11Sample::StartVideoDecoder()
499+{
500+ isRunning_.store(true);
501+ int ret = OH_VideoDecoder_Start(vdec_);
502+ if (ret != AV_ERR_OK) {
503+ cout << "Failed to start codec" << endl;
504+ isRunning_.store(false);
505+ ReleaseInFile();
506+ Release();
507+ return ret;
508+ }
509+ inputLoop_ = make_unique<thread>(&VDecAPI11Sample::InputFuncTest, this);
510+ if (inputLoop_ == nullptr) {
511+ cout << "Failed to create input loop" << endl;
512+ isRunning_.store(false);
513+ (void)OH_VideoDecoder_Stop(vdec_);
514+ ReleaseInFile();
515+ return AV_ERR_UNKNOWN;
516+ }
517+ outputLoop_ = make_unique<thread>(&VDecAPI11Sample::OutputFuncTest, this);
518+ if (outputLoop_ == nullptr) {
519+ cout << "Failed to create output loop" << endl;
520+ isRunning_.store(false);
521+ (void)OH_VideoDecoder_Stop(vdec_);
522+ ReleaseInFile();
523+ StopInloop();
524+ Release();
525+ return AV_ERR_UNKNOWN;
526+ }
527+ 
528+ return AV_ERR_OK;
529+}
530+ 
531+int32_t VDecAPI11Sample::StartVideoDecoderForH263()
532+{
533+ isRunning_.store(true);
534+ int ret = OH_VideoDecoder_Start(vdec_);
535+ if (ret != AV_ERR_OK) {
536+ cout << "Failed to start codec" << endl;
537+ isRunning_.store(false);
538+ ReleaseInFile();
539+ Release();
540+ return ret;
541+ }
542+ inFile_ = make_unique<ifstream>();
543+ if (inFile_ == nullptr) {
544+ isRunning_.store(false);
545+ (void)OH_VideoDecoder_Stop(vdec_);
546+ return AV_ERR_UNKNOWN;
547+ }
548+ inFile_->open(IN_DIR, ios::in | ios::binary);
549+ if (!inFile_->is_open()) {
550+ cout << "failed open file " << IN_DIR << endl;
551+ isRunning_.store(false);
552+ (void)OH_VideoDecoder_Stop(vdec_);
553+ inFile_->close();
554+ inFile_.reset();
555+ inFile_ = nullptr;
556+ return AV_ERR_UNKNOWN;
557+ }
558+ inputLoop_ = make_unique<thread>(&VDecAPI11Sample::InputFuncTestForH263, this);
559+ if (inputLoop_ == nullptr) {
560+ cout << "Failed to create input loop" << endl;
561+ isRunning_.store(false);
562+ (void)OH_VideoDecoder_Stop(vdec_);
563+ ReleaseInFile();
564+ return AV_ERR_UNKNOWN;
565+ }
566+ outputLoop_ = make_unique<thread>(&VDecAPI11Sample::OutputFuncTest, this);
567+ if (outputLoop_ == nullptr) {
568+ cout << "Failed to create output loop" << endl;
569+ isRunning_.store(false);
570+ (void)OH_VideoDecoder_Stop(vdec_);
571+ ReleaseInFile();
572+ StopInloop();
573+ Release();
574+ return AV_ERR_UNKNOWN;
575+ }
576+ 
577+ return AV_ERR_OK;
578+}
579+ 
580+int32_t VDecAPI11Sample::StartSyncVideoDecoder()
581+{
582+ isRunning_.store(true);
583+ int ret = OH_VideoDecoder_Start(vdec_);
584+ if (ret != AV_ERR_OK) {
585+ cout << "Failed to start codec" << endl;
586+ isRunning_.store(false);
587+ ReleaseInFile();
588+ Release();
589+ return ret;
590+ }
591+ signal_ = new VDecAPI11Signal();
592+ inputLoop_ = make_unique<thread>(&VDecAPI11Sample::SyncInputFunc, this);
593+ if (inputLoop_ == nullptr) {
594+ cout << "Failed to create input loop" << endl;
595+ isRunning_.store(false);
596+ (void)OH_VideoDecoder_Stop(vdec_);
597+ ReleaseInFile();
598+ return AV_ERR_UNKNOWN;
599+ }
600+ outputLoop_ = make_unique<thread>(&VDecAPI11Sample::SyncOutputFunc, this);
601+ if (outputLoop_ == nullptr) {
602+ cout << "Failed to create output loop" << endl;
603+ isRunning_.store(false);
604+ (void)OH_VideoDecoder_Stop(vdec_);
605+ ReleaseInFile();
606+ StopInloop();
607+ Release();
608+ return AV_ERR_UNKNOWN;
609+ }
610+ 
611+ return AV_ERR_OK;
612+}
613+ 
614+void VDecAPI11Sample::testAPI()
615+{
616+ cs[0] = Surface::CreateSurfaceAsConsumer();
617+ sptr<IBufferConsumerListener> listener = new ConsumerListenerBuffer(cs[0], OUT_DIR);
618+ cs[0]->RegisterConsumerListener(listener);
619+ auto p = cs[0]->GetProducer();
620+ ps[0] = Surface::CreateSurfaceAsProducer(p);
621+ nativeWindow[0] = CreateNativeWindowFromSurface(&ps[0]);
622+ OH_VideoDecoder_SetSurface(vdec_, nativeWindow[0]);
623+ 
624+ OH_VideoDecoder_Prepare(vdec_);
625+ OH_VideoDecoder_Start(vdec_);
626+ 
627+ OH_AVFormat *format = OH_AVFormat_Create();
628+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
629+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
630+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_NV12);
631+ (void)OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
632+ OH_VideoDecoder_SetParameter(vdec_, format);
633+ OH_AVFormat_Destroy(format);
634+ OH_VideoDecoder_GetOutputDescription(vdec_);
635+ OH_VideoDecoder_Flush(vdec_);
636+ OH_VideoDecoder_Stop(vdec_);
637+ OH_VideoDecoder_Reset(vdec_);
638+ bool isvalid = false;
639+ OH_VideoDecoder_IsValid(vdec_, &isvalid);
640+}
641+ 
642+void VDecAPI11Sample::WaitForEOS()
643+{
644+ if (!AFTER_EOS_DESTORY_CODEC && inputLoop_ && inputLoop_->joinable()) {
645+ inputLoop_->join();
646+ }
647+ 
648+ if (outputLoop_ && outputLoop_->joinable()) {
649+ outputLoop_->join();
650+ }
651+}
652+ 
653+void VDecAPI11Sample::InputFuncTest()
654+{
655+ if (outputYuvSurface) {
656+ g_yuvSurface = true;
657+ }
658+ bool flag = true;
659+ while (flag) {
660+ if (!isRunning_.load()) {
661+ flag = false;
662+ break;
663+ }
664+ uint32_t index;
665+ unique_lock<mutex> lock(signal_->inMutex_);
666+ signal_->inCond_.wait(lock, [this]() {
667+ if (!isRunning_.load()) {
668+ return true;
669+ }
670+ return signal_->inIdxQueue_.size() > 0;
671+ });
672+ if (!isRunning_.load()) {
673+ flag = false;
674+ break;
675+ }
676+ index = signal_->inIdxQueue_.front();
677+ auto buffer = signal_->inBufferQueue_.front();
678+ signal_->inIdxQueue_.pop();
679+ signal_->inBufferQueue_.pop();
680+ lock.unlock();
681+ int ret = PushData(index, buffer);
682+ if (ret == 1) {
683+ flag = false;
684+ break;
685+ }
686+ if (sleepOnFPS) {
687+ usleep(MICRO_IN_SECOND / (int32_t)DEFAULT_FRAME_RATE);
688+ }
689+ }
690+}
691+ 
692+void VDecAPI11Sample::InputFuncTestForH263()
693+{
694+ if (outputYuvSurface) {
695+ g_yuvSurface = true;
696+ }
697+ bool flag = true;
698+ while (flag) {
699+ if (!isRunning_.load()) {
700+ flag = false;
701+ break;
702+ }
703+ uint32_t index;
704+ unique_lock<mutex> lock(signal_->inMutex_);
705+ signal_->inCond_.wait(lock, [this]() {
706+ if (!isRunning_.load()) {
707+ return true;
708+ }
709+ return signal_->inIdxQueue_.size() > 0;
710+ });
711+ if (!isRunning_.load()) {
712+ flag = false;
713+ break;
714+ }
715+ index = signal_->inIdxQueue_.front();
716+ auto buffer = signal_->inBufferQueue_.front();
717+ signal_->inIdxQueue_.pop();
718+ signal_->inBufferQueue_.pop();
719+ lock.unlock();
720+ if (!inFile_->eof()) {
721+ int ret = PushDataForH263(index, buffer);
722+ if (ret == 1) {
723+ flag = false;
724+ break;
725+ }
726+ }
727+ if (sleepOnFPS) {
728+ usleep(MICRO_IN_SECOND / (int32_t)DEFAULT_FRAME_RATE);
729+ }
730+ }
731+}
732+ 
733+void VDecAPI11Sample::SyncInputFunc()
734+{
735+ if (outputYuvSurface) {
736+ g_yuvSurface = true;
737+ }
738+ bool flag = true;
739+ while (flag) {
740+ if (!isRunning_.load()) {
741+ flag = false;
742+ break;
743+ }
744+ uint32_t index;
745+ if (OH_VideoDecoder_QueryInputBuffer(vdec_, &index, syncInputWaitTime) != AV_ERR_OK) {
746+ cout << "OH_VideoDecoder_QueryInputBuffer fail" << endl;
747+ continue;
748+ }
749+ OH_AVBuffer *buffer = OH_VideoDecoder_GetInputBuffer(vdec_, index);
750+ if (buffer == nullptr) {
751+ cout << "OH_VideoDecoder_GetInputBuffer fail" << endl;
752+ errCount = errCount + 1;
753+ continue;
754+ }
755+ int ret = PushData(index, buffer);
756+ if (ret == 1) {
757+ flag = false;
758+ break;
759+ }
760+ if (sleepOnFPS) {
761+ usleep(MICRO_IN_SECOND / (int32_t)DEFAULT_FRAME_RATE);
762+ }
763+ }
764+}
765+ 
766+int32_t VDecAPI11Sample::PushData(uint32_t index, OH_AVBuffer *buffer)
767+{
768+ OH_AVCodecBufferAttr attr;
769+ OH_AVDemuxer_ReadSampleBuffer(demuxer, g_trackIndex, buffer);
770+ OH_AVBuffer_GetBufferAttr(buffer, &attr);
771+ if (attr.flags & AVCODEC_BUFFER_FLAGS_EOS) {
772+ SetEOS(index, buffer);
773+ return 1;
774+ }
775+ 
776+ if (isRunning_.load()) {
777+ OH_VideoDecoder_PushInputBuffer(vdec_, index) == AV_ERR_OK ? (0) : (errCount++);
778+ frameCount_ = frameCount_ + 1;
779+ outCount = outCount + 1;
780+ if (autoSwitchSurface && (frameCount_ % (int32_t)DEFAULT_FRAME_RATE == 0)) {
781+ switchSurfaceFlag = (switchSurfaceFlag == 1) ? 0 : 1;
782+ OH_VideoDecoder_SetSurface(vdec_, nativeWindow[switchSurfaceFlag]) == AV_ERR_OK ? (0) : (errCount++);
783+ }
784+ }
785+ return 0;
786+}
787+ 
788+int32_t VDecAPI11Sample::PushDataForH263(uint32_t index, OH_AVBuffer *buffer)
789+{
790+ OH_AVCodecBufferAttr attr;
791+ if (BEFORE_EOS_INPUT && frameCount_ > TEN) {
792+ SetEOS(index, buffer);
793+ return 1;
794+ }
795+ if (BEFORE_EOS_INPUT_INPUT && frameCount_ > TEN) {
796+ memset_s(&attr, sizeof(OH_AVCodecBufferAttr), 0, sizeof(OH_AVCodecBufferAttr));
797+ attr.flags = AVCODEC_BUFFER_FLAGS_EOS;
798+ BEFORE_EOS_INPUT_INPUT = false;
799+ }
800+ char ch[4] = {};
801+ (void)inFile_->read(ch, START_CODE_SIZE);
802+ if (repeatRun && inFile_->eof()) {
803+ static uint32_t repeat_count = 0;
804+ inFile_->clear();
805+ inFile_->seekg(0, ios::beg);
806+ cout << "repeat run " << repeat_count << endl;
807+ repeat_count++;
808+ return 0;
809+ }
810+ if (inFile_->eof()) {
811+ SetEOS(index, buffer);
812+ return 1;
813+ }
814+ uint32_t bufferSize = (uint32_t)(((ch[3] & 0xFF)) | ((ch[2] & 0xFF) << EIGHT) | ((ch[1] & 0xFF) << SIXTEEN) |
815+ ((ch[0] & 0xFF) << TWENTY_FOUR));
816+ if (useHDRSource) {
817+ uint32_t zero = 0;
818+ uint32_t one = 1;
819+ uint32_t two = 2;
820+ uint32_t three = 3;
821+ bufferSize = (uint32_t)(((ch[zero] & 0xFF)) | ((ch[one] & 0xFF) << EIGHT) | ((ch[two] & 0xFF) << SIXTEEN) |
822+ ((ch[three] & 0xFF) << TWENTY_FOUR));
823+ }
824+ if (bufferSize >= DEFAULT_WIDTH * DEFAULT_HEIGHT * THREE >> 1) {
825+ cout << "read bufferSize abnormal. buffersize = " << bufferSize << endl;
826+ }
827+ return SendData(bufferSize, index, buffer);
828+}
829+ 
830+int32_t VDecAPI11Sample::CheckAndReturnBufferSize(OH_AVBuffer *buffer)
831+{
832+ int32_t size = OH_AVBuffer_GetCapacity(buffer);
833+ if (maxInputSize > 0 && (size > maxInputSize)) {
834+ errCount++;
835+ }
836+ return size;
837+}
838+ 
839+void VDecAPI11Sample::SetAttr(OH_AVCodecBufferAttr &attr, uint32_t bufferSize)
840+{
841+ int64_t startPts = GetSystemTimeUs();
842+ attr.pts = startPts;
843+ attr.size = bufferSize;
844+ attr.offset = 0;
845+}
846+ 
847+uint32_t VDecAPI11Sample::SendData(uint32_t bufferSize, uint32_t index, OH_AVBuffer *buffer)
848+{
849+ OH_AVCodecBufferAttr attr;
850+ uint8_t *fileBuffer = nullptr;
851+ if (bufferSize > 0) {
852+ fileBuffer = new uint8_t[bufferSize];
853+ } else {
854+ delete[] fileBuffer;
855+ return 0;
856+ }
857+ (void)inFile_->read(reinterpret_cast<char *>(fileBuffer), bufferSize);
858+ if (bufferSize != 0) {
859+ attr.flags = AVCODEC_BUFFER_FLAGS_SYNC_FRAME + AVCODEC_BUFFER_FLAGS_CODEC_DATA;
860+ } else {
861+ if (!isDVVideoChange) {
862+ SetEOS(index, buffer);
863+ return 1;
864+ } else {
865+ return 0;
866+ }
867+ }
868+ int32_t size = CheckAndReturnBufferSize(buffer);
869+ if (size < bufferSize) {
870+ delete[] fileBuffer;
871+ return 0;
872+ }
873+ uint8_t *avBuffer = OH_AVBuffer_GetAddr(buffer);
874+ if (avBuffer == nullptr) {
875+ inFile_->clear();
876+ inFile_->seekg(0, ios::beg);
877+ delete[] fileBuffer;
878+ return 0;
879+ }
880+ if (memcpy_s(avBuffer, size, fileBuffer, bufferSize) != EOK) {
881+ delete[] fileBuffer;
882+ return 0;
883+ }
884+ SetAttr(attr, bufferSize);
885+ if (isRunning_.load()) {
886+ OH_AVBuffer_SetBufferAttr(buffer, &attr);
887+ OH_VideoDecoder_PushInputBuffer(vdec_, index) == AV_ERR_OK ? (0) : (errCount++);
888+ frameCount_ = frameCount_ + 1;
889+ outCount = outCount + 1;
890+ if (autoSwitchSurface && (frameCount_ % (int32_t)DEFAULT_FRAME_RATE == 0)) {
891+ switchSurfaceFlag = (switchSurfaceFlag == 1) ? 0 : 1;
892+ OH_VideoDecoder_SetSurface(vdec_, nativeWindow[switchSurfaceFlag]) == AV_ERR_OK ? (0) : (errCount++);
893+ }
894+ }
895+ delete[] fileBuffer;
896+ return 0;
897+}
898+ 
899+void VDecAPI11Sample::CheckOutputDescription()
900+{
901+ OH_AVFormat *newFormat = OH_VideoDecoder_GetOutputDescription(vdec_);
902+ if (newFormat != nullptr) {
903+ int32_t cropTop = 0;
904+ int32_t cropBottom = 0;
905+ int32_t cropLeft = 0;
906+ int32_t cropRight = 0;
907+ int32_t stride = 0;
908+ int32_t sliceHeight = 0;
909+ int32_t picWidth = 0;
910+ int32_t picHeight = 0;
911+ OH_AVFormat_GetIntValue(newFormat, OH_MD_KEY_VIDEO_CROP_TOP, &cropTop);
912+ OH_AVFormat_GetIntValue(newFormat, OH_MD_KEY_VIDEO_CROP_BOTTOM, &cropBottom);
913+ OH_AVFormat_GetIntValue(newFormat, OH_MD_KEY_VIDEO_CROP_LEFT, &cropLeft);
914+ OH_AVFormat_GetIntValue(newFormat, OH_MD_KEY_VIDEO_CROP_RIGHT, &cropRight);
915+ OH_AVFormat_GetIntValue(newFormat, OH_MD_KEY_VIDEO_STRIDE, &stride);
916+ OH_AVFormat_GetIntValue(newFormat, OH_MD_KEY_VIDEO_SLICE_HEIGHT, &sliceHeight);
917+ OH_AVFormat_GetIntValue(newFormat, OH_MD_KEY_VIDEO_PIC_WIDTH, &picWidth);
918+ OH_AVFormat_GetIntValue(newFormat, OH_MD_KEY_VIDEO_PIC_HEIGHT, &picHeight);
919+ if (cropTop != expectCropTop || cropBottom != expectCropBottom || cropLeft != expectCropLeft) {
920+ std::cout << "cropTop:" << cropTop << " cropBottom:" << cropBottom << " cropLeft:" << cropLeft << std::endl;
921+ errCount++;
922+ }
923+ if (cropRight != expectCropRight || stride <= 0 || sliceHeight <= 0) {
924+ std::cout << "cropRight:" << cropRight << std::endl;
925+ std::cout << "stride:" << stride << " sliceHeight:" << sliceHeight << std::endl;
926+ errCount++;
927+ }
928+ if (picWidth != originalWidth || picHeight != originalHeight) {
929+ std::cout << "picWidth:" << picWidth << " picHeight:" << picHeight << std::endl;
930+ errCount++;
931+ }
932+ } else {
933+ errCount++;
934+ }
935+ OH_AVFormat_Destroy(newFormat);
936+}
937+ 
938+void VDecAPI11Sample::AutoSwitchSurface()
939+{
940+ if (autoSwitchSurface) {
941+ switchSurfaceFlag = (switchSurfaceFlag == 1) ? 0 : 1;
942+ if (OH_VideoDecoder_SetSurface(vdec_, nativeWindow[switchSurfaceFlag]) != AV_ERR_OK) {
943+ errCount++;
944+ }
945+ OH_AVFormat *format = OH_AVFormat_Create();
946+ int32_t angle = DEFAULT_ANGLE * reinterpret_cast<int32_t>(switchSurfaceFlag);
947+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_ROTATION, angle);
948+ OH_VideoDecoder_SetParameter(vdec_, format);
949+ OH_AVFormat_Destroy(format);
950+ }
951+}
952+int32_t VDecAPI11Sample::CheckAttrFlag(OH_AVCodecBufferAttr attr)
953+{
954+ if (needCheckOutputDesc) {
955+ CheckOutputDescription();
956+ needCheckOutputDesc = false;
957+ }
958+ if (attr.flags & AVCODEC_BUFFER_FLAGS_EOS) {
959+ cout << "AVCODEC_BUFFER_FLAGS_EOS" << endl;
960+ AutoSwitchSurface();
961+ SHA512_Final(g_md, &g_c);
962+ OPENSSL_cleanse(&g_c, sizeof(g_c));
963+ MdCompare(g_md, SHA512_DIGEST_LENGTH, fileSourcesha256);
964+ return -1;
965+ }
966+ outFrameCount = outFrameCount + 1;
967+ return 0;
968+}
969+ 
970+void VDecAPI11Sample::OutputFuncTest()
971+{
972+ FILE *outFile = nullptr;
973+ if (outputYuvFlag) {
974+ outFile = fopen(OUT_DIR, "wb");
975+ }
976+ SHA512_Init(&g_c);
977+ bool flag = true;
978+ while (flag) {
979+ if (!isRunning_.load()) {
980+ flag = false;
981+ break;
982+ }
983+ OH_AVCodecBufferAttr attr;
984+ unique_lock<mutex> lock(signal_->outMutex_);
985+ signal_->outCond_.wait(lock, [this]() {
986+ if (!isRunning_.load()) {
987+ return true;
988+ }
989+ return signal_->outIdxQueue_.size() > 0;
990+ });
991+ if (!isRunning_.load()) {
992+ flag = false;
993+ break;
994+ }
995+ uint32_t index = signal_->outIdxQueue_.front();
996+ OH_AVBuffer *buffer = signal_->outBufferQueue_.front();
997+ signal_->outBufferQueue_.pop();
998+ signal_->outIdxQueue_.pop();
999+ if (OH_AVBuffer_GetBufferAttr(buffer, &attr) != AV_ERR_OK) {
1000+ errCount = errCount + 1;
1001+ }
1002+ lock.unlock();
1003+ if (CheckAttrFlag(attr) == -1) {
1004+ flag = false;
1005+ break;
1006+ }
1007+ if (outFile != nullptr) {
1008+ fwrite(OH_AVBuffer_GetAddr(buffer), 1, attr.size, outFile);
1009+ }
1010+ ProcessOutputData(buffer, index, attr.size);
1011+ if (errCount > 0) {
1012+ flag = false;
1013+ break;
1014+ }
1015+ }
1016+ if (outFile) {
1017+ (void)fclose(outFile);
1018+ }
1019+}
1020+ 
1021+void VDecAPI11Sample::SyncOutputFunc()
1022+{
1023+ FILE *outFile = nullptr;
1024+ if (outputYuvFlag) {
1025+ outFile = fopen(OUT_DIR, "wb");
1026+ }
1027+ SHA512_Init(&g_c);
1028+ bool flag = true;
1029+ while (flag) {
1030+ if (!isRunning_.load()) {
1031+ flag = false;
1032+ break;
1033+ }
1034+ OH_AVCodecBufferAttr attr;
1035+ uint32_t index = 0;
1036+ if (OH_VideoDecoder_QueryOutputBuffer(vdec_, &index, syncOutputWaitTime) != AV_ERR_OK) {
1037+ cout << "OH_VideoDecoder_QueryOutputBuffer fail" << endl;
1038+ continue;
1039+ }
1040+ OH_AVBuffer *buffer = OH_VideoDecoder_GetOutputBuffer(vdec_, index);
1041+ if (buffer == nullptr) {
1042+ cout << "OH_VideoDecoder_GetOutputBuffer fail" << endl;
1043+ errCount = errCount + 1;
1044+ continue;
1045+ }
1046+ if (OH_AVBuffer_GetBufferAttr(buffer, &attr) != AV_ERR_OK) {
1047+ errCount = errCount + 1;
1048+ }
1049+ if (SyncOutputFuncEos(attr, index) != AV_ERR_OK) {
1050+ flag = false;
1051+ break;
1052+ }
1053+ if (outFile != nullptr) {
1054+ fwrite(OH_AVBuffer_GetAddr(buffer), 1, attr.size, outFile);
1055+ }
1056+ ProcessOutputData(buffer, index, attr.size);
1057+ if (errCount > 0) {
1058+ flag = false;
1059+ break;
1060+ }
1061+ }
1062+ if (outFile) {
1063+ (void)fclose(outFile);
1064+ }
1065+}
1066+ 
1067+int32_t VDecAPI11Sample::SyncOutputFuncEos(OH_AVCodecBufferAttr attr, uint32_t index)
1068+{
1069+ if (CheckAttrFlag(attr) == -1) {
1070+ if (queryInputBufferEOS) {
1071+ OH_VideoDecoder_QueryInputBuffer(vdec_, &index, 0);
1072+ OH_VideoDecoder_QueryInputBuffer(vdec_, &index, MILLION);
1073+ OH_VideoDecoder_QueryInputBuffer(vdec_, &index, -1);
1074+ }
1075+ if (queryOutputBufferEOS) {
1076+ OH_VideoDecoder_QueryOutputBuffer(vdec_, &index, 0);
1077+ OH_VideoDecoder_QueryOutputBuffer(vdec_, &index, MILLION);
1078+ OH_VideoDecoder_QueryOutputBuffer(vdec_, &index, -1);
1079+ }
1080+ return AV_ERR_UNKNOWN;
1081+ }
1082+ return AV_ERR_OK;
1083+}
1084+ 
1085+void VDecAPI11Sample::ProcessOutputData(OH_AVBuffer *buffer, uint32_t index, int32_t size)
1086+{
1087+ if (!SF_OUTPUT) {
1088+ if (size >= DEFAULT_WIDTH * DEFAULT_HEIGHT * THREE >> 1) {
1089+ uint8_t *cropBuffer = new uint8_t[size];
1090+ if (memcpy_s(cropBuffer, size, OH_AVBuffer_GetAddr(buffer), DEFAULT_WIDTH * DEFAULT_HEIGHT) != EOK) {
1091+ cout << "Fatal: memory copy failed Y" << endl;
1092+ }
1093+ // copy UV
1094+ uint32_t uvSize = size - DEFAULT_WIDTH * DEFAULT_HEIGHT;
1095+ if (memcpy_s(cropBuffer + DEFAULT_WIDTH * DEFAULT_HEIGHT, uvSize,
1096+ OH_AVBuffer_GetAddr(buffer) + DEFAULT_WIDTH * DEFAULT_HEIGHT, uvSize) != EOK) {
1097+ cout << "Fatal: memory copy failed UV" << endl;
1098+ }
1099+ SHA512_Update(&g_c, cropBuffer, size);
1100+ delete[] cropBuffer;
1101+ }
1102+ if (OH_VideoDecoder_FreeOutputBuffer(vdec_, index) != AV_ERR_OK) {
1103+ cout << "Fatal: ReleaseOutputBuffer fail" << endl;
1104+ errCount = errCount + 1;
1105+ }
1106+ } else {
1107+ if (rsAtTime) {
1108+ int32_t usTimeNum = 1000;
1109+ int32_t msTimeNum = 1000000;
1110+ if (renderTimestampNs == 0) {
1111+ renderTimestampNs = GetSystemTimeUs() * usTimeNum;
1112+ }
1113+ renderTimestampNs = renderTimestampNs + (usTimeNum / DEFAULT_FRAME_RATE * msTimeNum);
1114+ if (OH_VideoDecoder_RenderOutputBufferAtTime(vdec_, index, renderTimestampNs) != AV_ERR_OK) {
1115+ cout << "Fatal: RenderOutputBufferAtTime fail" << endl;
1116+ errCount = errCount + 1;
1117+ }
1118+ } else {
1119+ if (OH_VideoDecoder_RenderOutputBuffer(vdec_, index) != AV_ERR_OK) {
1120+ cout << "Fatal: RenderOutputBuffer fail" << endl;
1121+ errCount = errCount + 1;
1122+ }
1123+ }
1124+ }
1125+}
1126+ 
1127+int32_t VDecAPI11Sample::state_EOS()
1128+{
1129+ uint32_t index;
1130+ unique_lock<mutex> lock(signal_->inMutex_);
1131+ signal_->inCond_.wait(lock, [this]() { return signal_->inIdxQueue_.size() > 0; });
1132+ index = signal_->inIdxQueue_.front();
1133+ signal_->inIdxQueue_.pop();
1134+ signal_->inBufferQueue_.pop();
1135+ lock.unlock();
1136+ return OH_VideoDecoder_PushInputBuffer(vdec_, index);
1137+}
1138+ 
1139+void VDecAPI11Sample::SetEOS(uint32_t index, OH_AVBuffer *buffer)
1140+{
1141+ OH_AVCodecBufferAttr attr;
1142+ attr.pts = 0;
1143+ attr.size = 0;
1144+ attr.offset = 0;
1145+ attr.flags = AVCODEC_BUFFER_FLAGS_EOS;
1146+ OH_AVBuffer_SetBufferAttr(buffer, &attr);
1147+ int32_t res = OH_VideoDecoder_PushInputBuffer(vdec_, index);
1148+ cout << "OH_VideoDecoder_PushInputBuffer EOS res: " << res << endl;
1149+}
1150+ 
1151+int32_t VDecAPI11Sample::Flush()
1152+{
1153+ unique_lock<mutex> inLock(signal_->inMutex_);
1154+ clearIntqueue(signal_->inIdxQueue_);
1155+ signal_->inCond_.notify_all();
1156+ inLock.unlock();
1157+ unique_lock<mutex> outLock(signal_->outMutex_);
1158+ clearIntqueue(signal_->outIdxQueue_);
1159+ clearBufferqueue(signal_->attrQueue_);
1160+ signal_->outCond_.notify_all();
1161+ outLock.unlock();
1162+ isRunning_.store(false);
1163+ return OH_VideoDecoder_Flush(vdec_);
1164+}
1165+ 
1166+int32_t VDecAPI11Sample::Reset()
1167+{
1168+ isRunning_.store(false);
1169+ StopInloop();
1170+ StopOutloop();
1171+ ReleaseInFile();
1172+ return OH_VideoDecoder_Reset(vdec_);
1173+}
1174+ 
1175+int32_t VDecAPI11Sample::Release()
1176+{
1177+ int ret = 0;
1178+ if (vdec_ != nullptr) {
1179+ ret = OH_VideoDecoder_Destroy(vdec_);
1180+ vdec_ = nullptr;
1181+ }
1182+ 
1183+ if (signal_ != nullptr) {
1184+ delete signal_;
1185+ signal_ = nullptr;
1186+ }
1187+ return ret;
1188+}
1189+ 
1190+int32_t VDecAPI11Sample::Stop()
1191+{
1192+ StopInloop();
1193+ StopOutloop();
1194+ ReleaseInFile();
1195+ return OH_VideoDecoder_Stop(vdec_);
1196+}
1197+ 
1198+int32_t VDecAPI11Sample::Start()
1199+{
1200+ isRunning_.store(true);
1201+ return OH_VideoDecoder_Start(vdec_);
1202+}
1203+ 
1204+void VDecAPI11Sample::StopOutloop()
1205+{
1206+ if (outputLoop_ != nullptr && outputLoop_->joinable()) {
1207+ unique_lock<mutex> lock(signal_->outMutex_);
1208+ clearIntqueue(signal_->outIdxQueue_);
1209+ clearBufferqueue(signal_->attrQueue_);
1210+ isRunning_.store(false);
1211+ signal_->outCond_.notify_all();
1212+ lock.unlock();
1213+ outputLoop_->join();
1214+ outputLoop_.reset();
1215+ }
1216+}
1217+ 
1218+int32_t VDecAPI11Sample::SetRotationAngle(int32_t angle)
1219+{
1220+ int32_t ret = 0;
1221+ OH_AVFormat *format = OH_AVFormat_Create();
1222+ if (angle > 0) {
1223+ (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_ROTATION, angle);
1224+ }
1225+ ret = OH_VideoDecoder_SetParameter(vdec_, format);
1226+ OH_AVFormat_Destroy(format);
1227+ return ret;
1228+}
1229+ 
1230+int32_t VDecAPI11Sample::SetParameter(OH_AVFormat *format)
1231+{
1232+ return OH_VideoDecoder_SetParameter(vdec_, format);
1233+}
1234+ 
1235+int32_t VDecAPI11Sample::SwitchSurface()
1236+{
1237+ int32_t ret = OH_VideoDecoder_SetSurface(vdec_, nativeWindow[switchSurfaceFlag]);
1238+ switchSurfaceFlag = (switchSurfaceFlag == 1) ? 0 : 1;
1239+ cout << "manual switch surf " << switchSurfaceFlag << endl;
1240+ return ret;
1241+}
1242+ 
1243+int32_t VDecAPI11Sample::RepeatCallSetSurface()
1244+{
1245+ for (int i = 0; i < REPEAT_CALL_TIME; i++) {
1246+ switchSurfaceFlag = (switchSurfaceFlag == 1) ? 0 : 1;
1247+ int32_t ret = OH_VideoDecoder_SetSurface(vdec_, nativeWindow[switchSurfaceFlag]);
1248+ if (ret != AV_ERR_OK && ret != AV_ERR_OPERATE_NOT_PERMIT && ret != AV_ERR_INVALID_STATE) {
1249+ return AV_ERR_OPERATE_NOT_PERMIT;
1250+ }
1251+ }
1252+ return AV_ERR_OK;
1253+}
1254+ 
1255+int32_t VDecAPI11Sample::DecodeSetSurface()
1256+{
1257+ CreateSurface();
1258+ return OH_VideoDecoder_SetSurface(vdec_, nativeWindow[0]);
1259+}