1 /*
2  * Copyright (c) 2024 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 <gtest/gtest.h>
17 #include "native_avcodec_base.h"
18 #include "native_avformat.h"
19 #include "format.h"
20 #include "native_avcodec_videoencoder.h"
21 #include "native_avcodec_videodecoder.h"
22 #include "native_avcapability.h"
23 
24 using namespace testing::ext;
25 using namespace OHOS::Media;
26 
27 namespace {
28 constexpr double DEFAULT_FRAME_RATE = 30.0;
29 constexpr uint32_t DEFAULT_QUALITY = 30;
30 constexpr uint32_t VALID_ROTATION_ANGLE[] = {0, 90, 180, 270};
31 constexpr uint32_t DIVISOR = 2;
32 std::vector<uint32_t> PIXEL_FORMATS = {
33     AV_PIXEL_FORMAT_YUVI420,
34     AV_PIXEL_FORMAT_NV12,
35     AV_PIXEL_FORMAT_NV21,
36     AV_PIXEL_FORMAT_RGBA
37 };
38 uint32_t DEFAULT_WIDTH = 1280;
39 uint32_t DEFAULT_HEIGHT = 720;
40 uint32_t DEFAULT_BITRATE = 10000000;
41 uint32_t ENCODER_PIXEL_FORMAT = AV_PIXEL_FORMAT_SURFACE_FORMAT;
42 uint32_t DECODER_PIXEL_FORMAT = AV_PIXEL_FORMAT_SURFACE_FORMAT;
43 OH_AVFormat *g_format;
44 OH_AVCodec *g_videoEnc;
45 OH_AVCodec *g_videoDec;
46 
47 class AVCodecParamCheckerTest : public testing::Test {
48 public:
49     static void SetUpTestCase(void);
TearDownTestCase(void)50     static void TearDownTestCase(void){};
51     void SetUp(void);
52     void TearDown(void);
53 };
54 
SetUpTestCase(void)55 void AVCodecParamCheckerTest::SetUpTestCase(void)
56 {
57     OH_AVCapability *encoderCapability = OH_AVCodec_GetCapability(OH_AVCODEC_MIMETYPE_VIDEO_AVC, true);
58     OH_AVRange range;
59     if (OH_AVCapability_GetVideoWidthRange(encoderCapability, &range) == AV_ERR_OK) {
60         std::cout << "width min = " << range.minVal << " width max = " << range.maxVal << std::endl;
61         DEFAULT_WIDTH = (range.minVal + range.maxVal) / DIVISOR;
62     }
63 
64     if (OH_AVCapability_GetVideoHeightRange(encoderCapability, &range) == AV_ERR_OK) {
65         std::cout << "height min = " << range.minVal << " height max = " << range.maxVal << std::endl;
66         DEFAULT_HEIGHT = (range.minVal + range.maxVal) / DIVISOR;
67     }
68 
69     if (OH_AVCapability_GetEncoderBitrateRange(encoderCapability, &range) == AV_ERR_OK) {
70         std::cout << "bitrate min = " << range.minVal << " bitrate max = " << range.maxVal << std::endl;
71         DEFAULT_BITRATE = (range.minVal + range.maxVal) / DIVISOR;
72     }
73 
74     const int32_t *pixFormats = nullptr;
75     uint32_t pixFormatNum = 0;
76     auto ret = OH_AVCapability_GetVideoSupportedPixelFormats(encoderCapability, &pixFormats, &pixFormatNum);
77     if (ret == AV_ERR_OK) {
78         ENCODER_PIXEL_FORMAT = pixFormatNum > 0 ? pixFormats[0] : ENCODER_PIXEL_FORMAT;
79         std::cout << "encoder pixel format = " << ENCODER_PIXEL_FORMAT << std::endl;
80     }
81 
82     OH_AVCapability *decoderCapability = OH_AVCodec_GetCapability(OH_AVCODEC_MIMETYPE_VIDEO_AVC, false);
83     pixFormats = nullptr;
84     pixFormatNum = 0;
85     ret = OH_AVCapability_GetVideoSupportedPixelFormats(decoderCapability, &pixFormats, &pixFormatNum);
86     if (ret == AV_ERR_OK) {
87         DECODER_PIXEL_FORMAT = pixFormatNum > 0 ? pixFormats[0] : DECODER_PIXEL_FORMAT;
88         std::cout << "decoder pixel format = " << DECODER_PIXEL_FORMAT << std::endl;
89     }
90 }
91 
SetUp(void)92 void AVCodecParamCheckerTest::SetUp(void)
93 {
94     g_videoEnc = OH_VideoEncoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC);
95     ASSERT_NE(nullptr, g_videoEnc);
96     g_videoDec = OH_VideoDecoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC);
97     ASSERT_NE(nullptr, g_videoDec);
98     g_format = OH_AVFormat_Create();
99     ASSERT_NE(nullptr, g_format);
100 }
101 
TearDown(void)102 void AVCodecParamCheckerTest::TearDown(void)
103 {
104     OH_AVFormat_Destroy(g_format);
105     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Destroy(g_videoEnc));
106     ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Destroy(g_videoDec));
107 }
108 
SetFormatBasicParam(bool isDecoder)109 void SetFormatBasicParam(bool isDecoder)
110 {
111     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH));
112     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT));
113     if (!isDecoder) {
114         ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_PIXEL_FORMAT, ENCODER_PIXEL_FORMAT));
115     }
116 }
117 
118 /**
119  * @tc.name: ENCODE_KEY_WIDTH_INVAILD_TEST_0101
120  * @tc.desc: codec video configure not exsit width
121  * @tc.type: FUNC
122  */
123 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_WIDTH_INVAILD_TEST_0101, TestSize.Level3)
124 {
125     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT));
126     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_PIXEL_FORMAT, ENCODER_PIXEL_FORMAT));
127     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
128     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
129 }
130 
131 /**
132  * @tc.name: ENCODE_KEY_WIDTH_INVALID_TEST_0102
133  * @tc.desc: codec video configure width out of range
134  * @tc.type: FUNC
135  */
136 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_WIDTH_INVALID_TEST_0102, TestSize.Level3)
137 {
138     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT));
139     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_PIXEL_FORMAT, ENCODER_PIXEL_FORMAT));
140     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_WIDTH, INT32_MIN));
141     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
142     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
143 }
144 
145 /**
146  * @tc.name: ENCODE_KEY_WIDTH_INVAILD_TEST_0103
147  * @tc.desc: codec video configure width out of range
148  * @tc.type: FUNC
149  */
150 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_WIDTH_INVAILD_TEST_0103, TestSize.Level3)
151 {
152     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT));
153     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_PIXEL_FORMAT, ENCODER_PIXEL_FORMAT));
154     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_WIDTH, INT32_MAX));
155     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
156     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
157 }
158 
159 /**
160  * @tc.name: ENCODE_KEY_WIDTH_VAILD_TEST_0104
161  * @tc.desc: codec video configure default width
162  * @tc.type: FUNC
163  */
164 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_WIDTH_VAILD_TEST_0104, TestSize.Level3)
165 {
166     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT));
167     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_PIXEL_FORMAT, ENCODER_PIXEL_FORMAT));
168     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH));
169     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
170     ASSERT_EQ(ret, AV_ERR_OK);
171 }
172 
173 /**
174  * @tc.name: ENCODE_KEY_HEIGHT_INVALID_TEST_0201
175  * @tc.desc: codec video configure not exsit height
176  * @tc.type: FUNC
177  */
178 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_HEIGHT_INVALID_TEST_0201, TestSize.Level3)
179 {
180     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH));
181     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_PIXEL_FORMAT, ENCODER_PIXEL_FORMAT));
182     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
183     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
184 }
185 
186 /**
187  * @tc.name: ENCODE_KEY_HEIGHT_INVALID_TEST_0202
188  * @tc.desc: codec video configure height out of range
189  * @tc.type: FUNC
190  */
191 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_HEIGHT_INVALID_TEST_0202, TestSize.Level3)
192 {
193     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH));
194     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_PIXEL_FORMAT, ENCODER_PIXEL_FORMAT));
195     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_HEIGHT, INT32_MIN));
196     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
197     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
198 }
199 
200 /**
201  * @tc.name: ENCODE_KEY_HEIGHT_INVALID_TEST_0203
202  * @tc.desc: codec video configure height out of range
203  * @tc.type: FUNC
204  */
205 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_HEIGHT_INVALID_TEST_0203, TestSize.Level3)
206 {
207     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH));
208     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_PIXEL_FORMAT, ENCODER_PIXEL_FORMAT));
209     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_HEIGHT, INT32_MAX));
210     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
211     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
212 }
213 
214 /**
215  * @tc.name: ENCODE_KEY_HEIGHT_VALID_TEST_0204
216  * @tc.desc: codec video configure default height
217  * @tc.type: FUNC
218  */
219 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_HEIGHT_VALID_TEST_0204, TestSize.Level3)
220 {
221     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH));
222     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_PIXEL_FORMAT, ENCODER_PIXEL_FORMAT));
223     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT));
224     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
225     ASSERT_EQ(ret, AV_ERR_OK);
226 }
227 
228 /**
229  * @tc.name: ENCODE_KEY_PIXEL_FORMAT_INVALID_TEST_0301
230  * @tc.desc: codec video configure not exsit pixel format
231  * @tc.type: FUNC
232  */
233 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_PIXEL_FORMAT_INVALID_TEST_0301, TestSize.Level3)
234 {
235     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH));
236     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT));
237     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
238     ASSERT_EQ(ret, AV_ERR_OK);
239 }
240 
241 /**
242  * @tc.name: ENCODE_KEY_PIXEL_FORMAT_INVALID_TEST_0302
243  * @tc.desc: codec video configure pixel format unsupport
244  * @tc.type: FUNC
245  */
246 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_PIXEL_FORMAT_INVALID_TEST_0302, TestSize.Level3)
247 {
248     OH_AVCapability *encoderCapability = OH_AVCodec_GetCapability(OH_AVCODEC_MIMETYPE_VIDEO_AVC, true);
249     const int32_t *pixFormats = nullptr;
250     uint32_t pixFormatNum = 0;
251     auto ret = OH_AVCapability_GetVideoSupportedPixelFormats(encoderCapability, &pixFormats, &pixFormatNum);
252     ASSERT_EQ(AV_ERR_OK, ret);
253 
254     std::vector<uint32_t> unsupportedPixelFormats = PIXEL_FORMATS;
255     for (int32_t i = 0; i < pixFormatNum; i++) {
256         int32_t pixelFormat = pixFormats[i];
257         std::cout << "Capability Supported pixelFormat = " << pixelFormat << std::endl;
258         auto iter = std::remove(unsupportedPixelFormats.begin(), unsupportedPixelFormats.end(), pixelFormat);
259         unsupportedPixelFormats.erase(iter, unsupportedPixelFormats.end());
260     }
261 
262     for (int32_t i = 0; i < unsupportedPixelFormats.size(); i++) {
263         int32_t unsupportedPixelFormat = unsupportedPixelFormats[i];
264         std::cout << "Unsupported Pixel Format = " << unsupportedPixelFormat << std::endl;
265 
266         OH_AVCodec *videoEnc = OH_VideoEncoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC);
267         ASSERT_NE(nullptr, videoEnc);
268         OH_AVFormat *format = OH_AVFormat_Create();
269         ASSERT_NE(nullptr, format);
270         ASSERT_EQ(true, OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH));
271         ASSERT_EQ(true, OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT));
272         ASSERT_EQ(true, OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, unsupportedPixelFormat));
273         OH_AVErrCode ret = OH_VideoEncoder_Configure(videoEnc, format);
274         ASSERT_EQ(ret, AV_ERR_UNSUPPORT);
275 
276         OH_AVFormat_Destroy(format);
277         ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Destroy(videoEnc));
278     }
279 }
280 
281 /**
282  * @tc.name: ENCODE_KEY_PIXEL_FORMAT_VALID_TEST_0303
283  * @tc.desc: codec video configure default pixel format
284  * @tc.type: FUNC
285  */
286 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_PIXEL_FORMAT_VALID_TEST_0303, TestSize.Level3)
287 {
288     SetFormatBasicParam(false);
289     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
290     ASSERT_EQ(ret, AV_ERR_OK);
291 }
292 
293 /**
294  * @tc.name: ENCODE_KEY_FRAME_RATE_VALID_TEST_0401
295  * @tc.desc: codec video configure not exsit frame rate
296  * @tc.type: FUNC
297  */
298 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_FRAME_RATE_VALID_TEST_0401, TestSize.Level3)
299 {
300     SetFormatBasicParam(false);
301     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
302     ASSERT_EQ(ret, AV_ERR_OK);
303 }
304 
305 /**
306  * @tc.name: ENCODE_KEY_FRAME_RATE_INVALID_TEST_0402
307  * @tc.desc: codec video configure frame rate out of range
308  * @tc.type: FUNC
309  */
310 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_FRAME_RATE_INVALID_TEST_0402, TestSize.Level3)
311 {
312     constexpr double frameRate = 0.0;
313     SetFormatBasicParam(false);
314     ASSERT_EQ(true, OH_AVFormat_SetDoubleValue(g_format, OH_MD_KEY_FRAME_RATE, frameRate));
315     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
316     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
317 }
318 
319 /**
320  * @tc.name: ENCODE_KEY_FRAME_RATE_INVALID_TEST_0403
321  * @tc.desc: codec video configure frame rate out of range
322  * @tc.type: FUNC
323  */
324 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_FRAME_RATE_INVALID_TEST_0403, TestSize.Level3)
325 {
326     constexpr double frameRate = -1.0;
327     SetFormatBasicParam(false);
328     ASSERT_EQ(true, OH_AVFormat_SetDoubleValue(g_format, OH_MD_KEY_FRAME_RATE, frameRate));
329     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
330     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
331 }
332 
333 /**
334  * @tc.name: ENCODE_KEY_FRAME_RATE_INVALID_TEST_0404
335  * @tc.desc: codec video configure default frame rate
336  * @tc.type: FUNC
337  */
338 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_FRAME_RATE_INVALID_TEST_0404, TestSize.Level3)
339 {
340     SetFormatBasicParam(false);
341     ASSERT_EQ(true, OH_AVFormat_SetDoubleValue(g_format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE));
342     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
343     ASSERT_EQ(ret, AV_ERR_OK);
344 }
345 
346 /**
347  * @tc.name: ENCODE_KEY_BITRATE_QUALLITY_VALID_TEST_0501
348  * @tc.desc: codec video configure not exsit bitrate and bitrate mode is CBR
349  * @tc.type: FUNC
350  */
351 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_BITRATE_QUALLITY_VALID_TEST_0501, TestSize.Level3)
352 {
353     SetFormatBasicParam(false);
354     OH_AVCapability *capability = OH_AVCodec_GetCapability(OH_AVCODEC_MIMETYPE_VIDEO_AVC, true);
355     if (OH_AVCapability_IsEncoderBitrateModeSupported(capability, BITRATE_MODE_CBR)) {
356         ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE, CBR));
357         OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
358         ASSERT_EQ(ret, AV_ERR_OK);
359     }
360 }
361 
362 /**
363  * @tc.name: ENCODE_KEY_BITRATE_QUALLITY_VALID_TEST_0502
364  * @tc.desc: codec video configure not exsit bitrate and bitrate mode is VBR
365  * @tc.type: FUNC
366  */
367 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_BITRATE_QUALLITY_VALID_TEST_0502, TestSize.Level3)
368 {
369     SetFormatBasicParam(false);
370     OH_AVCapability *capability = OH_AVCodec_GetCapability(OH_AVCODEC_MIMETYPE_VIDEO_AVC, true);
371     if (OH_AVCapability_IsEncoderBitrateModeSupported(capability, BITRATE_MODE_VBR)) {
372         ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE, VBR));
373         OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
374         ASSERT_EQ(ret, AV_ERR_OK);
375     }
376 }
377 
378 /**
379  * @tc.name: ENCODE_KEY_BITRATE_QUALLITY_VALID_TEST_0503
380  * @tc.desc: codec video configure no exist bitrate mode and bitrate value in range
381  * @tc.type: FUNC
382  */
383 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_BITRATE_QUALLITY_VALID_TEST_0503, TestSize.Level3)
384 {
385     SetFormatBasicParam(false);
386     ASSERT_EQ(true, OH_AVFormat_SetLongValue(g_format, OH_MD_KEY_BITRATE, DEFAULT_BITRATE));
387     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
388     ASSERT_EQ(ret, AV_ERR_OK);
389 }
390 
391 /**
392  * @tc.name: ENCODE_KEY_BITRATE_QUALLITY_VALID_TEST_0504
393  * @tc.desc: codec video configure bitrate in range and bitrate mode is VBR
394  * @tc.type: FUNC
395  */
396 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_BITRATE_QUALLITY_VALID_TEST_0504, TestSize.Level3)
397 {
398     SetFormatBasicParam(false);
399     ASSERT_EQ(true, OH_AVFormat_SetLongValue(g_format, OH_MD_KEY_BITRATE, DEFAULT_BITRATE));
400 
401     OH_AVCapability *capability = OH_AVCodec_GetCapability(OH_AVCODEC_MIMETYPE_VIDEO_AVC, true);
402     if (OH_AVCapability_IsEncoderBitrateModeSupported(capability, BITRATE_MODE_VBR)) {
403         ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE, VBR));
404         OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
405         ASSERT_EQ(ret, AV_ERR_OK);
406     }
407 }
408 
409 /**
410  * @tc.name: ENCODE_KEY_BITRATE_QUALLITY_VALID_TEST_0505
411  * @tc.desc: codec video configure bitrate in range and bitrate mode is CBR
412  * @tc.type: FUNC
413  */
414 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_BITRATE_QUALLITY_VALID_TEST_0505, TestSize.Level3)
415 {
416     SetFormatBasicParam(false);
417     ASSERT_EQ(true, OH_AVFormat_SetLongValue(g_format, OH_MD_KEY_BITRATE, DEFAULT_BITRATE));
418 
419     OH_AVCapability *capability = OH_AVCodec_GetCapability(OH_AVCODEC_MIMETYPE_VIDEO_AVC, true);
420     if (OH_AVCapability_IsEncoderBitrateModeSupported(capability, BITRATE_MODE_CBR)) {
421         ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE, CBR));
422         OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
423         ASSERT_EQ(ret, AV_ERR_OK);
424     }
425 }
426 
427 /**
428  * @tc.name: ENCODE_KEY_BITRATE_QUALLITY_INVALID_TEST_0506
429  * @tc.desc: codec video configure bitrate in range and bitrate mode is CQ
430  * @tc.type: FUNC
431  */
432 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_BITRATE_QUALLITY_INVALID_TEST_0506, TestSize.Level3)
433 {
434     SetFormatBasicParam(false);
435     ASSERT_EQ(true, OH_AVFormat_SetLongValue(g_format, OH_MD_KEY_BITRATE, DEFAULT_BITRATE));
436 
437     OH_AVCapability *capability = OH_AVCodec_GetCapability(OH_AVCODEC_MIMETYPE_VIDEO_AVC, true);
438     if (OH_AVCapability_IsEncoderBitrateModeSupported(capability, BITRATE_MODE_CQ)) {
439         ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE, CQ));
440         OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
441         ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
442     }
443 }
444 
445 /**
446  * @tc.name: ENCODE_KEY_BITRATE_QUALLITY_INVALID_TEST_0507
447  * @tc.desc: codec video configure bitrate invalid value
448  * @tc.type: FUNC
449  */
450 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_BITRATE_QUALLITY_INVALID_TEST_0507, TestSize.Level3)
451 {
452     SetFormatBasicParam(false);
453     ASSERT_EQ(true, OH_AVFormat_SetLongValue(g_format, OH_MD_KEY_BITRATE, INT64_MAX));
454     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
455     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
456 }
457 
458 /**
459  * @tc.name: ENCODE_KEY_BITRATE_QUALLITY_INVALID_TEST_0508
460  * @tc.desc: codec video configure bitrate invalid value
461  * @tc.type: FUNC
462  */
463 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_BITRATE_QUALLITY_INVALID_TEST_0508, TestSize.Level3)
464 {
465     SetFormatBasicParam(false);
466     ASSERT_EQ(true, OH_AVFormat_SetLongValue(g_format, OH_MD_KEY_BITRATE, INT64_MIN));
467     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
468     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
469 }
470 
471 /**
472  * @tc.name: ENCODE_KEY_BITRATE_QUALLITY_INVALID_TEST_0509
473  * @tc.desc: codec video configure bitrate and quality exist value
474  * @tc.type: FUNC
475  */
476 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_BITRATE_QUALLITY_INVALID_TEST_0509, TestSize.Level3)
477 {
478     SetFormatBasicParam(false);
479     ASSERT_EQ(true, OH_AVFormat_SetLongValue(g_format, OH_MD_KEY_BITRATE, DEFAULT_BITRATE));
480     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_QUALITY, DEFAULT_QUALITY));
481     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
482     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
483 }
484 
485 /**
486  * @tc.name: ENCODE_KEY_BITRATE_QUALLITY_VALID_TEST_0510
487  * @tc.desc: codec video configure quality in range and bitrate mode not exist
488  * @tc.type: FUNC
489  */
490 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_BITRATE_QUALLITY_VALID_TEST_0510, TestSize.Level3)
491 {
492     SetFormatBasicParam(false);
493     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_QUALITY, DEFAULT_QUALITY));
494     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
495     ASSERT_EQ(ret, AV_ERR_OK);
496 }
497 
498 /**
499  * @tc.name: ENCODE_KEY_BITRATE_QUALLITY_INVALID_TEST_0511
500  * @tc.desc: codec video configure quality in range and bitrate mode is VBR
501  * @tc.type: FUNC
502  */
503 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_BITRATE_QUALLITY_INVALID_TEST_0511, TestSize.Level3)
504 {
505     SetFormatBasicParam(false);
506     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_QUALITY, DEFAULT_QUALITY));
507 
508     OH_AVCapability *capability = OH_AVCodec_GetCapability(OH_AVCODEC_MIMETYPE_VIDEO_AVC, true);
509     if (OH_AVCapability_IsEncoderBitrateModeSupported(capability, BITRATE_MODE_VBR)) {
510         ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE, VBR));
511         OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
512         ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
513     }
514 }
515 
516 /**
517  * @tc.name: ENCODE_KEY_BITRATE_QUALLITY_INVALID_TEST_0512
518  * @tc.desc: codec video configure quality in range and bitrate mode is CBR
519  * @tc.type: FUNC
520  */
521 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_BITRATE_QUALLITY_INVALID_TEST_0512, TestSize.Level3)
522 {
523     SetFormatBasicParam(false);
524     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_QUALITY, DEFAULT_QUALITY));
525 
526     OH_AVCapability *capability = OH_AVCodec_GetCapability(OH_AVCODEC_MIMETYPE_VIDEO_AVC, true);
527     if (OH_AVCapability_IsEncoderBitrateModeSupported(capability, BITRATE_MODE_CBR)) {
528         ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE, CBR));
529         OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
530         ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
531     }
532 }
533 
534 /**
535  * @tc.name: ENCODE_KEY_BITRATE_QUALLITY_VALID_TEST_0513
536  * @tc.desc: codec video configure quality in range and bitrate mode is CQ
537  * @tc.type: FUNC
538  */
539 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_BITRATE_QUALLITY_VALID_TEST_0513, TestSize.Level3)
540 {
541     SetFormatBasicParam(false);
542     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_QUALITY, DEFAULT_QUALITY));
543 
544     OH_AVCapability *capability = OH_AVCodec_GetCapability(OH_AVCODEC_MIMETYPE_VIDEO_AVC, true);
545     if (OH_AVCapability_IsEncoderBitrateModeSupported(capability, BITRATE_MODE_CQ)) {
546         ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE, CQ));
547         OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
548         ASSERT_EQ(ret, AV_ERR_OK);
549     }
550 }
551 
552 /**
553  * @tc.name: ENCODE_KEY_BITRATE_QUALLITY_INVALID_TEST_0514
554  * @tc.desc: codec video configure quality out of range
555  * @tc.type: FUNC
556  */
557 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_BITRATE_QUALLITY_INVALID_TEST_0514, TestSize.Level3)
558 {
559     SetFormatBasicParam(false);
560     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_QUALITY, INT32_MIN));
561     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
562     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
563 }
564 
565 /**
566  * @tc.name: ENCODE_KEY_BITRATE_QUALLITY_INVALID_TEST_0515
567  * @tc.desc: codec video configure quality out of range
568  * @tc.type: FUNC
569  */
570 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_BITRATE_QUALLITY_INVALID_TEST_0515, TestSize.Level3)
571 {
572     SetFormatBasicParam(false);
573     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_QUALITY, INT32_MAX));
574     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
575     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
576 }
577 
578 /**
579  * @tc.name: ENCODE_KEY_BITRATE_QUALLITY_INVALID_TEST_0516
580  * @tc.desc: codec video configure quality not exist and bitrate mode is CQ
581  * @tc.type: FUNC
582  */
583 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_BITRATE_QUALLITY_INVALID_TEST_0516, TestSize.Level3)
584 {
585     SetFormatBasicParam(false);
586     OH_AVCapability *capability = OH_AVCodec_GetCapability(OH_AVCODEC_MIMETYPE_VIDEO_AVC, true);
587     if (OH_AVCapability_IsEncoderBitrateModeSupported(capability, BITRATE_MODE_CQ)) {
588         ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE, CQ));
589         OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
590         ASSERT_EQ(ret, AV_ERR_OK);
591     }
592 }
593 
594 /**
595  * @tc.name: ENCODE_KEY_BITRATE_QUALLITY_INVALID_TEST_0517
596  * @tc.desc: codec video configure bitrate mode invalid value
597  * @tc.type: FUNC
598  */
599 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_BITRATE_QUALLITY_INVALID_TEST_0517, TestSize.Level3)
600 {
601     SetFormatBasicParam(false);
602     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE, INT32_MIN));
603     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
604     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
605 }
606 
607 /**
608  * @tc.name: ENCODE_KEY_BITRATE_QUALLITY_INVALID_TEST_0518
609  * @tc.desc: codec video configure bitrate mode invalid value
610  * @tc.type: FUNC
611  */
612 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_BITRATE_QUALLITY_INVALID_TEST_0518, TestSize.Level3)
613 {
614     SetFormatBasicParam(false);
615     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE, INT32_MAX));
616     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
617     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
618 }
619 
620 /**
621  * @tc.name: ENCODE_KEY_PROFILE_VALID_TEST_0601
622  * @tc.desc: codec video configure profile support
623  * @tc.type: FUNC
624  */
625 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_PROFILE_VALID_TEST_0601, TestSize.Level3)
626 {
627     OH_AVCapability *capability = OH_AVCodec_GetCapability(OH_AVCODEC_MIMETYPE_VIDEO_AVC, true);
628     const int32_t *profiles = nullptr;
629     uint32_t profilesNum = 0;
630     int profilesRet = OH_AVCapability_GetSupportedProfiles(capability, &profiles, &profilesNum);
631     ASSERT_EQ(AV_ERR_OK, profilesRet);
632 
633     for (int32_t i = 0; i < profilesNum; i++) {
634         std::cout << "Capability Supported Profile = " << profiles[i] << std::endl;
635 
636         OH_AVCodec *videoEnc = OH_VideoEncoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC);
637         ASSERT_NE(nullptr, videoEnc);
638         OH_AVFormat *format = OH_AVFormat_Create();
639         ASSERT_NE(nullptr, format);
640         ASSERT_EQ(true, OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH));
641         ASSERT_EQ(true, OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT));
642         ASSERT_EQ(true, OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, ENCODER_PIXEL_FORMAT));
643         ASSERT_EQ(true, OH_AVFormat_SetIntValue(format, OH_MD_KEY_PROFILE, profiles[i]));
644         OH_AVErrCode ret = OH_VideoEncoder_Configure(videoEnc, format);
645         ASSERT_EQ(ret, AV_ERR_OK);
646 
647         OH_AVFormat_Destroy(format);
648         ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Destroy(videoEnc));
649     }
650 }
651 
652 /**
653  * @tc.name: ENCODE_KEY_PROFILE_INVALID_TEST_0602
654  * @tc.desc: codec video configure profile unsupport
655  * @tc.type: FUNC
656  */
657 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_PROFILE_INVALID_TEST_0602, TestSize.Level3)
658 {
659     SetFormatBasicParam(false);
660     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_PROFILE, INT32_MIN));
661     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
662     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
663 }
664 
665 /**
666  * @tc.name: ENCODE_KEY_PROFILE_INVALID_TEST_0602
667  * @tc.desc: codec video configure profile unsupport
668  * @tc.type: FUNC
669  */
670 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_PROFILE_INVALID_TEST_0603, TestSize.Level3)
671 {
672     SetFormatBasicParam(false);
673     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_PROFILE, INT32_MAX));
674     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
675     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
676 }
677 
678 /**
679  * @tc.name: ENCODE_KEY_COLOR_PRIMARIES_INVALID_TEST_0701
680  * @tc.desc: codec video configure color primaries unsupport
681  * @tc.type: FUNC
682  */
683 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_COLOR_PRIMARIES_INVALID_TEST_0701, TestSize.Level3)
684 {
685     SetFormatBasicParam(false);
686     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_COLOR_PRIMARIES, INT32_MIN));
687     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
688     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
689 }
690 
691 /**
692  * @tc.name: ENCODE_KEY_COLOR_PRIMARIES_INVALID_TEST_0702
693  * @tc.desc: codec video configure color primaries unsupport
694  * @tc.type: FUNC
695  */
696 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_COLOR_PRIMARIES_INVALID_TEST_0702, TestSize.Level3)
697 {
698     SetFormatBasicParam(false);
699     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_COLOR_PRIMARIES, INT32_MAX));
700     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
701     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
702 }
703 
704 /**
705  * @tc.name: ENCODE_KEY_COLOR_PRIMARIES_VALID_TEST_0703
706  * @tc.desc: codec video configure color primaries support
707  * @tc.type: FUNC
708  */
709 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_COLOR_PRIMARIES_VALID_TEST_0703, TestSize.Level3)
710 {
711     SetFormatBasicParam(false);
712     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format,
713         OH_MD_KEY_COLOR_PRIMARIES,
714         OH_ColorPrimary::COLOR_PRIMARY_BT709));
715     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
716     ASSERT_EQ(ret, AV_ERR_OK);
717 }
718 
719 /**
720  * @tc.name: ENCODE_KEY_TRANSFER_CHARACTERISTICS_VALID_TEST_0801
721  * @tc.desc: codec video configure transfer characteristics support
722  * @tc.type: FUNC
723  */
724 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_TRANSFER_CHARACTERISTICS_VALID_TEST_0801, TestSize.Level3)
725 {
726     SetFormatBasicParam(false);
727     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_TRANSFER_CHARACTERISTICS,
728         OH_TransferCharacteristic::TRANSFER_CHARACTERISTIC_LINEAR));
729     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
730     ASSERT_EQ(ret, AV_ERR_OK);
731 }
732 
733 /**
734  * @tc.name: ENCODE_KEY_TRANSFER_CHARACTERISTICS_INVALID_TEST_0802
735  * @tc.desc: codec video configure transfer characteristics unsupport
736  * @tc.type: FUNC
737  */
738 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_TRANSFER_CHARACTERISTICS_INVALID_TEST_0802, TestSize.Level3)
739 {
740     SetFormatBasicParam(false);
741     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_TRANSFER_CHARACTERISTICS, INT32_MIN));
742     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
743     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
744 }
745 
746 /**
747  * @tc.name: ENCODE_KEY_TRANSFER_CHARACTERISTICS_INVALID_TEST_0803
748  * @tc.desc: codec video configure transfer characteristics unsupport
749  * @tc.type: FUNC
750  */
751 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_TRANSFER_CHARACTERISTICS_INVALID_TEST_0803, TestSize.Level3)
752 {
753     SetFormatBasicParam(false);
754     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_TRANSFER_CHARACTERISTICS, INT32_MAX));
755     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
756     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
757 }
758 
759 /**
760  * @tc.name: ENCODE_KEY_MATRIX_COEFFICIENTS_VALID_TEST_0901
761  * @tc.desc: codec video configure matrix coefficients support
762  * @tc.type: FUNC
763  */
764 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_MATRIX_COEFFICIENTS_VALID_TEST_0901, TestSize.Level3)
765 {
766     SetFormatBasicParam(false);
767     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_MATRIX_COEFFICIENTS,
768         OH_MatrixCoefficient::MATRIX_COEFFICIENT_YCGCO));
769     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
770     ASSERT_EQ(ret, AV_ERR_OK);
771 }
772 
773 /**
774  * @tc.name: ENCODE_KEY_MATRIX_COEFFICIENTS_VALID_TEST_0902
775  * @tc.desc: codec video configure matrix coefficients unsupport
776  * @tc.type: FUNC
777  */
778 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_MATRIX_COEFFICIENTS_VALID_TEST_0902, TestSize.Level3)
779 {
780     SetFormatBasicParam(false);
781     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_MATRIX_COEFFICIENTS, INT32_MIN));
782     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
783     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
784 }
785 
786 /**
787  * @tc.name: ENCODE_KEY_I_FRAME_INTERVAL_VALID_TEST_1001
788  * @tc.desc: codec video configure key i frame interval set default value 1500
789  * @tc.type: FUNC
790  */
791 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_I_FRAME_INTERVAL_VALID_TEST_1001, TestSize.Level3)
792 {
793     constexpr int32_t defaultIFrameInterval = 1500;
794     SetFormatBasicParam(false);
795     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_I_FRAME_INTERVAL, defaultIFrameInterval));
796     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
797     ASSERT_EQ(ret, AV_ERR_OK);
798 }
799 
800 /**
801  * @tc.name: ENCODE_KEY_I_FRAME_INTERVAL_VALID_TEST_1002
802  * @tc.desc: codec video configure key i frame interval set a negative value
803  * @tc.type: FUNC
804  */
805 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_I_FRAME_INTERVAL_VALID_TEST_1002, TestSize.Level3)
806 {
807     constexpr int32_t defaultIFrameInterval = -2;
808     SetFormatBasicParam(false);
809     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_I_FRAME_INTERVAL, defaultIFrameInterval));
810     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
811     ASSERT_EQ(ret, AV_ERR_OK);
812 }
813 
814 /**
815  * @tc.name: ENCODE_KEY_I_FRAME_INTERVAL_VALID_TEST_1003
816  * @tc.desc: codec video configure key i frame interval not set
817  * @tc.type: FUNC
818  */
819 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_I_FRAME_INTERVAL_VALID_TEST_1003, TestSize.Level3)
820 {
821     SetFormatBasicParam(false);
822     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
823     ASSERT_EQ(ret, AV_ERR_OK);
824 }
825 
826 /**
827  * @tc.name: ENCODE_KEY_MATRIX_COEFFICIENTS_VALID_TEST_0903
828  * @tc.desc: codec video configure matrix coefficients unsupport
829  * @tc.type: FUNC
830  */
831 HWTEST_F(AVCodecParamCheckerTest, ENCODE_KEY_MATRIX_COEFFICIENTS_VALID_TEST_0903, TestSize.Level3)
832 {
833     SetFormatBasicParam(false);
834     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_MATRIX_COEFFICIENTS, INT32_MAX));
835     OH_AVErrCode ret = OH_VideoEncoder_Configure(g_videoEnc, g_format);
836     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
837 }
838 
839 /**
840  * @tc.name: DECODE_KEY_WIDTH_INVALID_TEST_1101
841  * @tc.desc: codec video configure not exsit width
842  * @tc.type: FUNC
843  */
844 HWTEST_F(AVCodecParamCheckerTest, DECODE_KEY_WIDTH_INVALID_TEST_1101, TestSize.Level3)
845 {
846     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT));
847     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_PIXEL_FORMAT, DECODER_PIXEL_FORMAT));
848     OH_AVErrCode ret = OH_VideoDecoder_Configure(g_videoDec, g_format);
849     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
850 }
851 
852 /**
853  * @tc.name: DECODE_KEY_WIDTH_INVALID_TEST_1102
854  * @tc.desc: codec video configure width out of range
855  * @tc.type: FUNC
856  */
857 HWTEST_F(AVCodecParamCheckerTest, DECODE_KEY_WIDTH_INVALID_TEST_1102, TestSize.Level3)
858 {
859     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT));
860     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_PIXEL_FORMAT, DECODER_PIXEL_FORMAT));
861     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_WIDTH, INT32_MIN));
862     OH_AVErrCode ret = OH_VideoDecoder_Configure(g_videoDec, g_format);
863     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
864 }
865 
866 /**
867  * @tc.name: DECODE_KEY_WIDTH_INVALID_TEST_1103
868  * @tc.desc: codec video configure width out of range
869  * @tc.type: FUNC
870  */
871 HWTEST_F(AVCodecParamCheckerTest, DECODE_KEY_WIDTH_INVALID_TEST_1103, TestSize.Level3)
872 {
873     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT));
874     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_PIXEL_FORMAT, DECODER_PIXEL_FORMAT));
875     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_WIDTH, INT32_MAX));
876     OH_AVErrCode ret = OH_VideoDecoder_Configure(g_videoDec, g_format);
877     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
878 }
879 
880 /**
881  * @tc.name: DECODE_KEY_WIDTH_VALID_TEST_1104
882  * @tc.desc: codec video configure default width
883  * @tc.type: FUNC
884  */
885 HWTEST_F(AVCodecParamCheckerTest, DECODE_KEY_WIDTH_VALID_TEST_1104, TestSize.Level3)
886 {
887     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT));
888     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_PIXEL_FORMAT, DECODER_PIXEL_FORMAT));
889     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH));
890     OH_AVErrCode ret = OH_VideoDecoder_Configure(g_videoDec, g_format);
891     ASSERT_EQ(ret, AV_ERR_OK);
892 }
893 
894 /**
895  * @tc.name: DECODE_KEY_HEIGHT_INVALID_TEST_1201
896  * @tc.desc: codec video configure not exsit height
897  * @tc.type: FUNC
898  */
899 HWTEST_F(AVCodecParamCheckerTest, DECODE_KEY_HEIGHT_INVALID_TEST_1201, TestSize.Level3)
900 {
901     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH));
902     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_PIXEL_FORMAT, DECODER_PIXEL_FORMAT));
903     OH_AVErrCode ret = OH_VideoDecoder_Configure(g_videoDec, g_format);
904     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
905 }
906 
907 /**
908  * @tc.name: DECODE_KEY_HEIGHT_INVALID_TEST_1202
909  * @tc.desc: codec video configure height out of range
910  * @tc.type: FUNC
911  */
912 HWTEST_F(AVCodecParamCheckerTest, DECODE_KEY_HEIGHT_INVALID_TEST_1202, TestSize.Level3)
913 {
914     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH));
915     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_PIXEL_FORMAT, DECODER_PIXEL_FORMAT));
916     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_HEIGHT, INT32_MIN));
917     OH_AVErrCode ret = OH_VideoDecoder_Configure(g_videoDec, g_format);
918     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
919 }
920 
921 /**
922  * @tc.name: DECODE_KEY_HEIGHT_INVALID_TEST_1203
923  * @tc.desc: codec video configure height out of range
924  * @tc.type: FUNC
925  */
926 HWTEST_F(AVCodecParamCheckerTest, DECODE_KEY_HEIGHT_INVALID_TEST_1203, TestSize.Level3)
927 {
928     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH));
929     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_PIXEL_FORMAT, DECODER_PIXEL_FORMAT));
930     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_HEIGHT, INT32_MAX));
931     OH_AVErrCode ret = OH_VideoDecoder_Configure(g_videoDec, g_format);
932     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
933 }
934 
935 /**
936  * @tc.name: DECODE_KEY_HEIGHT_VALID_TEST_1204
937  * @tc.desc: codec video configure default height
938  * @tc.type: FUNC
939  */
940 HWTEST_F(AVCodecParamCheckerTest, DECODE_KEY_HEIGHT_VALID_TEST_1204, TestSize.Level3)
941 {
942     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH));
943     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_PIXEL_FORMAT, DECODER_PIXEL_FORMAT));
944     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT));
945     OH_AVErrCode ret = OH_VideoDecoder_Configure(g_videoDec, g_format);
946     ASSERT_EQ(ret, AV_ERR_OK);
947 }
948 
949 /**
950  * @tc.name: DECODE_KEY_PIXEL_FORMAT_VALID_TEST_1301
951  * @tc.desc: codec video configure not exsit pixel format
952  * @tc.type: FUNC
953  */
954 HWTEST_F(AVCodecParamCheckerTest, DECODE_KEY_PIXEL_FORMAT_VALID_TEST_1301, TestSize.Level3)
955 {
956     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH));
957     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT));
958     OH_AVErrCode ret = OH_VideoDecoder_Configure(g_videoDec, g_format);
959     ASSERT_EQ(ret, AV_ERR_OK);
960 }
961 
962 /**
963  * @tc.name: DECODE_KEY_PIXEL_FORMAT_INVALID_TEST_1302
964  * @tc.desc: codec video configure pixel format unsupport
965  * @tc.type: FUNC
966  */
967 HWTEST_F(AVCodecParamCheckerTest, DECODE_KEY_PIXEL_FORMAT_VALID_TEST_1302, TestSize.Level3)
968 {
969     OH_AVCapability *encoderCapability = OH_AVCodec_GetCapability(OH_AVCODEC_MIMETYPE_VIDEO_AVC, false);
970     const int32_t *pixFormats = nullptr;
971     uint32_t pixFormatNum = 0;
972     auto ret = OH_AVCapability_GetVideoSupportedPixelFormats(encoderCapability, &pixFormats, &pixFormatNum);
973     ASSERT_EQ(AV_ERR_OK, ret);
974 
975     std::vector<uint32_t> unsupportedPixelFormats = PIXEL_FORMATS;
976     for (int32_t i = 0; i < pixFormatNum; i++) {
977         int32_t pixelFormat = pixFormats[i];
978         std::cout << "Capability Supported pixelFormat = " << pixelFormat << std::endl;
979         auto iter = std::remove(unsupportedPixelFormats.begin(), unsupportedPixelFormats.end(), pixelFormat);
980         unsupportedPixelFormats.erase(iter, unsupportedPixelFormats.end());
981     }
982 
983     for (int32_t i = 0; i < unsupportedPixelFormats.size(); i++) {
984         int32_t unsupportedPixelFormat = unsupportedPixelFormats[i];
985         std::cout << "Unsupported Pixel Format = " << unsupportedPixelFormat << std::endl;
986 
987         OH_AVCodec *videoDec = OH_VideoDecoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC);
988         ASSERT_NE(nullptr, videoDec);
989         OH_AVFormat *format = OH_AVFormat_Create();
990         ASSERT_NE(nullptr, format);
991         ASSERT_EQ(true, OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH));
992         ASSERT_EQ(true, OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT));
993         ASSERT_EQ(true, OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, unsupportedPixelFormat));
994         OH_AVErrCode ret = OH_VideoDecoder_Configure(videoDec, format);
995         ASSERT_EQ(ret, AV_ERR_UNSUPPORT);
996 
997         OH_AVFormat_Destroy(format);
998         ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Destroy(videoDec));
999     }
1000 }
1001 
1002 /**
1003  * @tc.name: DECODE_KEY_PIXEL_FORMAT_VALID_TEST_1303
1004  * @tc.desc: codec video configure default pixel format
1005  * @tc.type: FUNC
1006  */
1007 HWTEST_F(AVCodecParamCheckerTest, DECODE_KEY_PIXEL_FORMAT_VALID_TEST_1303, TestSize.Level3)
1008 {
1009     SetFormatBasicParam(true);
1010     OH_AVErrCode ret = OH_VideoDecoder_Configure(g_videoDec, g_format);
1011     ASSERT_EQ(ret, AV_ERR_OK);
1012 }
1013 
1014 /**
1015  * @tc.name: DECODE_KEY_FRAME_RATE_VALID_TEST_1401
1016  * @tc.desc: codec video configure not exsit frame rate
1017  * @tc.type: FUNC
1018  */
1019 HWTEST_F(AVCodecParamCheckerTest, DECODE_KEY_FRAME_RATE_VALID_TEST_1401, TestSize.Level3)
1020 {
1021     SetFormatBasicParam(true);
1022     OH_AVErrCode ret = OH_VideoDecoder_Configure(g_videoDec, g_format);
1023     ASSERT_EQ(ret, AV_ERR_OK);
1024 }
1025 
1026 /**
1027  * @tc.name: DECODE_KEY_FRAME_RATE_INVALID_TEST_1402
1028  * @tc.desc: codec video configure frame rate out of range
1029  * @tc.type: FUNC
1030  */
1031 HWTEST_F(AVCodecParamCheckerTest, DECODE_KEY_FRAME_RATE_INVALID_TEST_1402, TestSize.Level3)
1032 {
1033     constexpr double frameRate = 0.0;
1034     SetFormatBasicParam(true);
1035     ASSERT_EQ(true, OH_AVFormat_SetDoubleValue(g_format, OH_MD_KEY_FRAME_RATE, frameRate));
1036     OH_AVErrCode ret = OH_VideoDecoder_Configure(g_videoDec, g_format);
1037     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
1038 }
1039 
1040 /**
1041  * @tc.name: DECODE_KEY_FRAME_RATE_INVALID_TEST_1403
1042  * @tc.desc: codec video configure frame rate out of range
1043  * @tc.type: FUNC
1044  */
1045 HWTEST_F(AVCodecParamCheckerTest, DECODE_KEY_FRAME_RATE_INVALID_TEST_1403, TestSize.Level3)
1046 {
1047     constexpr double frameRate = -1.0;
1048     SetFormatBasicParam(true);
1049     ASSERT_EQ(true, OH_AVFormat_SetDoubleValue(g_format, OH_MD_KEY_FRAME_RATE, frameRate));
1050     OH_AVErrCode ret = OH_VideoDecoder_Configure(g_videoDec, g_format);
1051     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
1052 }
1053 
1054 /**
1055  * @tc.name: DECODE_KEY_FRAME_RATE_VALID_TEST_1404
1056  * @tc.desc: codec video configure default frame rate
1057  * @tc.type: FUNC
1058  */
1059 HWTEST_F(AVCodecParamCheckerTest, DECODE_KEY_FRAME_RATE_VALID_TEST_1404, TestSize.Level3)
1060 {
1061     SetFormatBasicParam(true);
1062     ASSERT_EQ(true, OH_AVFormat_SetDoubleValue(g_format, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE));
1063     OH_AVErrCode ret = OH_VideoDecoder_Configure(g_videoDec, g_format);
1064     ASSERT_EQ(ret, AV_ERR_OK);
1065 }
1066 
1067 /**
1068  * @tc.name: DECODE_KEY_ROTATION_VALID_TEST_1501
1069  * @tc.desc: codec video configure rotation angle support
1070  * @tc.type: FUNC
1071  */
1072 HWTEST_F(AVCodecParamCheckerTest, DECODE_KEY_ROTATION_VALID_TEST_1501, TestSize.Level3)
1073 {
1074     int32_t len = sizeof(VALID_ROTATION_ANGLE) / sizeof(VALID_ROTATION_ANGLE[0]);
1075     for (int32_t i = 0; i < len; i++) {
1076         uint32_t rotationAngle = VALID_ROTATION_ANGLE[i];
1077         std::cout << "Valid Rotation Angle = " << rotationAngle << std::endl;
1078 
1079         OH_AVCodec *videoDec = OH_VideoDecoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC);
1080         ASSERT_NE(nullptr, videoDec);
1081         OH_AVFormat *format = OH_AVFormat_Create();
1082         ASSERT_NE(nullptr, format);
1083         ASSERT_EQ(true, OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH));
1084         ASSERT_EQ(true, OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT));
1085         ASSERT_EQ(true, OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, DECODER_PIXEL_FORMAT));
1086         ASSERT_EQ(true, OH_AVFormat_SetIntValue(format, OH_MD_KEY_ROTATION, rotationAngle));
1087         OH_AVErrCode ret = OH_VideoDecoder_Configure(videoDec, format);
1088         ASSERT_EQ(ret, AV_ERR_OK);
1089 
1090         OH_AVFormat_Destroy(format);
1091         ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Destroy(videoDec));
1092     }
1093 }
1094 
1095 /**
1096  * @tc.name: DECODE_KEY_ROTATION_INVALID_TEST_1502
1097  * @tc.desc: codec video configure rotation angle support
1098  * @tc.type: FUNC
1099  */
1100 HWTEST_F(AVCodecParamCheckerTest, DECODE_KEY_ROTATION_INVALID_TEST_1502, TestSize.Level3)
1101 {
1102     int32_t minRotationAngle = 0;
1103     int32_t maxRotationAngle = 360;
1104     int32_t len = sizeof(VALID_ROTATION_ANGLE) / sizeof(VALID_ROTATION_ANGLE[0]);
1105     for (int32_t i = minRotationAngle; i < maxRotationAngle; i++) {
1106         if (std::find(VALID_ROTATION_ANGLE, VALID_ROTATION_ANGLE + len, i) == VALID_ROTATION_ANGLE + len) {
1107             uint32_t rotationAngle = i;
1108             std::cout << "Invalid Rotation Angle =" << rotationAngle << std::endl;
1109 
1110             OH_AVCodec *videoDec = OH_VideoDecoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC);
1111             ASSERT_NE(nullptr, videoDec);
1112             OH_AVFormat *format = OH_AVFormat_Create();
1113             ASSERT_NE(nullptr, format);
1114             ASSERT_EQ(true, OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH));
1115             ASSERT_EQ(true, OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT));
1116             ASSERT_EQ(true, OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, DECODER_PIXEL_FORMAT));
1117             ASSERT_EQ(true, OH_AVFormat_SetIntValue(format, OH_MD_KEY_ROTATION, rotationAngle));
1118             OH_AVErrCode ret = OH_VideoDecoder_Configure(videoDec, format);
1119             ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
1120 
1121             OH_AVFormat_Destroy(format);
1122             ASSERT_EQ(AV_ERR_OK, OH_VideoDecoder_Destroy(videoDec));
1123         }
1124     }
1125 }
1126 
1127 /**
1128  * @tc.name: DECODE_KEY_SCALING_MODE_VALID_TEST_1601
1129  * @tc.desc: video codec configure valid scaling mode
1130  * @tc.type: FUNC
1131  */
1132 HWTEST_F(AVCodecParamCheckerTest, DECODE_KEY_SCALING_MODE_VALID_TEST_1601, TestSize.Level3)
1133 {
1134     SetFormatBasicParam(true);
1135     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_SCALING_MODE,
1136         OH_ScalingMode::SCALING_MODE_SCALE_CROP));
1137     OH_AVErrCode ret = OH_VideoDecoder_Configure(g_videoDec, g_format);
1138     ASSERT_EQ(ret, AV_ERR_OK);
1139 }
1140 
1141 /**
1142  * @tc.name: DECODE_KEY_SCALING_MODE_VALID_TEST_1602
1143  * @tc.desc: video codec configure invalid scaling mode
1144  * @tc.type: FUNC
1145  */
1146 HWTEST_F(AVCodecParamCheckerTest, DECODE_KEY_SCALING_MODE_VALID_TEST_1602, TestSize.Level3)
1147 {
1148     SetFormatBasicParam(true);
1149     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_SCALING_MODE, INT32_MAX));
1150     OH_AVErrCode ret = OH_VideoDecoder_Configure(g_videoDec, g_format);
1151     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
1152 }
1153 
1154 /**
1155  * @tc.name: DECODE_KEY_SCALING_MODE_VALID_TEST_1603
1156  * @tc.desc: video codec configure invalid scaling mode
1157  * @tc.type: FUNC
1158  */
1159 HWTEST_F(AVCodecParamCheckerTest, DECODE_KEY_SCALING_MODE_VALID_TEST_1603, TestSize.Level3)
1160 {
1161     SetFormatBasicParam(true);
1162     ASSERT_EQ(true, OH_AVFormat_SetIntValue(g_format, OH_MD_KEY_SCALING_MODE, INT32_MIN));
1163     OH_AVErrCode ret = OH_VideoDecoder_Configure(g_videoDec, g_format);
1164     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
1165 }
1166 }