1 /* 2 * Copyright (c) 2023 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 * Description: header of HCode System test command parse 16 */ 17 18 #ifndef HCODEC_TEST_COMMAND_PARSE_H 19 #define HCODEC_TEST_COMMAND_PARSE_H 20 21 #include <string> 22 #include <optional> 23 #include "av_common.h" 24 #include "avcodec_info.h" 25 #include "media_description.h" 26 #include "start_code_detector.h" 27 28 namespace OHOS::MediaAVCodec { 29 30 enum class ApiType { 31 TEST_CODEC_BASE, 32 TEST_C_API_NEW, 33 TEST_C_API_OLD, 34 }; 35 36 struct CommandOpt { 37 ApiType apiType = ApiType::TEST_CODEC_BASE; 38 bool isEncoder = false; 39 bool isBufferMode = false; 40 uint32_t repeatCnt = 1; 41 std::string inputFile; 42 uint32_t maxReadFrameCnt = 0; // 0 means read whole file 43 uint32_t dispW = 0; 44 uint32_t dispH = 0; 45 CodeType protocol = H264; 46 VideoPixelFormat pixFmt = VideoPixelFormat::NV12; 47 uint32_t frameRate = 30; 48 int32_t timeout = -1; 49 bool isHighPerfMode = false; 50 // encoder only 51 std::optional<uint32_t> mockFrameCnt; // when read up to maxReadFrameCnt, stop read and send input directly 52 std::optional<bool> rangeFlag; 53 std::optional<ColorPrimary> primary; 54 std::optional<TransferCharacteristic> transfer; 55 std::optional<MatrixCoefficient> matrix; 56 std::optional<int32_t> iFrameInterval; 57 std::optional<uint32_t> idrFrameNo; 58 std::optional<int> profile; 59 std::optional<VideoEncodeBitrateMode> rateMode; 60 std::optional<uint32_t> bitRate; // bps 61 std::optional<uint32_t> quality; 62 // decoder only 63 bool render = false; 64 bool decThenEnc = false; 65 VideoRotation rotation = VIDEO_ROTATION_0; 66 int flushCnt = 0; 67 68 void Print() const; 69 }; 70 71 CommandOpt Parse(int argc, char *argv[]); 72 void ShowUsage(); 73 } 74 #endif