/* * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Description: header of HCode System test command parse */ #ifndef HCODEC_TEST_COMMAND_PARSE_H #define HCODEC_TEST_COMMAND_PARSE_H #include #include #include "native_avcodec_base.h" #include "av_common.h" #include "avcodec_info.h" #include "media_description.h" #include "start_code_detector.h" namespace OHOS::MediaAVCodec { enum class ApiType { TEST_CODEC_BASE, TEST_C_API_NEW, TEST_C_API_OLD, }; struct QPRange { uint32_t qpMin; uint32_t qpMax; }; struct LTRParam { bool markAsLTR; bool useLTR; uint32_t useLTRPoc; }; struct EBRParam { int32_t minQp; int32_t maxQp; int32_t startQp; int32_t isSkip; }; enum ParamType { SET_PARAM, PER_FRAME_PARAM, RESOURCE_PARAM, }; struct SetParameterParams { std::optional requestIdr; std::optional bitRate; std::optional frameRate; std::optional qpRange; std::optional rotate; std::optional scaleMode; }; struct PerFrameParams { std::optional requestIdr; std::optional qpRange; std::optional ltrParam; std::optional discard; std::optional ebrParam; }; struct ResourceParams { std::string inputFile; uint32_t dispW = 0; uint32_t dispH = 0; VideoPixelFormat pixFmt = VideoPixelFormat::NV12; }; struct WaterMarkParam { bool isSet = false; ResourceParams waterMarkFile; int32_t dstX; int32_t dstY; int32_t dstW; int32_t dstH; }; struct CommandOpt { ApiType apiType = ApiType::TEST_CODEC_BASE; bool isEncoder = false; bool isBufferMode = false; uint32_t ltrFrameCount = 0; uint32_t repeatCnt = 1; std::string inputFile; uint32_t maxReadFrameCnt = 0; // 0 means read whole file uint32_t dispW = 0; uint32_t dispH = 0; CodeType protocol = H264; VideoPixelFormat pixFmt = VideoPixelFormat::NV12; uint32_t frameRate = 30; int32_t timeout = -1; bool isHighPerfMode = false; // encoder only bool enableInputCb = false; std::optional mockFrameCnt; // when read up to maxReadFrameCnt, stop read and send input directly std::optional rangeFlag; std::optional primary; std::optional transfer; std::optional matrix; std::optional iFrameInterval; std::optional profile; std::optional rateMode; std::optional bitRate; // bps std::optional quality; std::optional qpRange; std::optional ltrListLen; std::optional repeatAfter; std::optional repeatMaxCnt; std::optional layerCnt; std::optional isVrrEnable; WaterMarkParam waterMark; bool paramsFeedback; // decoder only bool render = false; bool decThenEnc = false; VideoRotation rotation = VIDEO_ROTATION_0; int flushCnt = 0; std::optional scaleMode; // associate with frame number std::map setParameterParamsMap; std::map perFrameParamsMap; std::map resourceParamsMap; void Print() const; void ParseParamFromCmdLine(ParamType paramType, const char *cmd); void ParseSetParameter(uint32_t frameNo, const std::string &s); void ParsePerFrameParam(uint32_t frameNo, const std::string &s); static void ParseResourceParam(const std::string &src, ResourceParams& dst); void ParseWaterMark(const char *cmd); }; CommandOpt Parse(int argc, char *argv[]); void ShowUsage(); } #endif