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
16 #include "command_parser.h"
17 #include <cinttypes>
18 #include <getopt.h>
19 #include <iostream>
20 #include <sstream>
21 #include "hcodec_log.h"
22
23 namespace OHOS::MediaAVCodec {
24 using namespace std;
25
26 enum ShortOption {
27 OPT_UNKONWN = 0,
28 OPT_HELP,
29 OPT_INPUT = 'i',
30 OPT_WIDTH = 'w',
31 OPT_HEIGHT = 'h',
32 OPT_API_TYPE = UINT8_MAX + 1,
33 OPT_IS_ENCODER,
34 OPT_IS_BUFFER_MODE,
35 OPT_REPEAT_CNT,
36 OPT_MAX_READ_CNT,
37 OPT_PROTOCOL,
38 OPT_PIXEL_FMT,
39 OPT_FRAME_RATE,
40 OPT_TIME_OUT,
41 OPT_IS_HIGH_PERF_MODE,
42 OPT_SET_PARAMETER,
43 OPT_SET_PER_FRAME,
44 OPT_SET_RESOURCE,
45 // encoder only
46 OPT_MOCK_FRAME_CNT,
47 OPT_COLOR_RANGE,
48 OPT_COLOR_PRIMARY,
49 OPT_COLOR_TRANSFER,
50 OPT_COLOR_MATRIX,
51 OPT_I_FRAME_INTERVAL,
52 OPT_PROFILE,
53 OPT_BITRATE_MODE,
54 OPT_BITRATE,
55 OPT_QUALITY,
56 OPT_QP_RANGE,
57 OPT_LTR_FRAME_COUNT,
58 OPT_REPEAT_AFTER,
59 OPT_REPEAT_MAX_CNT,
60 OPT_LAYER_COUNT,
61 OPT_WATERMARK,
62 OPT_ENABLE_PARAMS_FEEDBACK,
63 OPT_SQR_FACTOR,
64 OPT_MAX_BITRATE,
65 OPT_ENABLE_QP_MAP,
66 OPT_IS_ABS_QP_MAP,
67 OPT_QP_MAP_VALUE,
68 OPT_TARGET_QP,
69 OPT_GOP_B_MODE,
70 // decoder only
71 OPT_DEC_THEN_ENC,
72 OPT_ROTATION,
73 OPT_FLUSH_CNT,
74 OPT_SCALE_MODE,
75 };
76
77 static struct option g_longOptions[] = {
78 {"help", no_argument, nullptr, OPT_HELP},
79 {"in", required_argument, nullptr, OPT_INPUT},
80 {"width", required_argument, nullptr, OPT_WIDTH},
81 {"height", required_argument, nullptr, OPT_HEIGHT},
82 {"apiType", required_argument, nullptr, OPT_API_TYPE},
83 {"isEncoder", required_argument, nullptr, OPT_IS_ENCODER},
84 {"isBufferMode", required_argument, nullptr, OPT_IS_BUFFER_MODE},
85 {"repeatCnt", required_argument, nullptr, OPT_REPEAT_CNT},
86 {"maxReadFrameCnt", required_argument, nullptr, OPT_MAX_READ_CNT},
87 {"protocol", required_argument, nullptr, OPT_PROTOCOL},
88 {"pixelFmt", required_argument, nullptr, OPT_PIXEL_FMT},
89 {"frameRate", required_argument, nullptr, OPT_FRAME_RATE},
90 {"timeout", required_argument, nullptr, OPT_TIME_OUT},
91 {"isHighPerfMode", required_argument, nullptr, OPT_IS_HIGH_PERF_MODE},
92 {"setParameter", required_argument, nullptr, OPT_SET_PARAMETER},
93 {"setPerFrame", required_argument, nullptr, OPT_SET_PER_FRAME},
94 {"setResource", required_argument, nullptr, OPT_SET_RESOURCE},
95 // encoder only
96 {"mockFrameCnt", required_argument, nullptr, OPT_MOCK_FRAME_CNT},
97 {"colorRange", required_argument, nullptr, OPT_COLOR_RANGE},
98 {"colorPrimary", required_argument, nullptr, OPT_COLOR_PRIMARY},
99 {"colorTransfer", required_argument, nullptr, OPT_COLOR_TRANSFER},
100 {"colorMatrix", required_argument, nullptr, OPT_COLOR_MATRIX},
101 {"iFrameInterval", required_argument, nullptr, OPT_I_FRAME_INTERVAL},
102 {"profile", required_argument, nullptr, OPT_PROFILE},
103 {"bitRateMode", required_argument, nullptr, OPT_BITRATE_MODE},
104 {"bitRate", required_argument, nullptr, OPT_BITRATE},
105 {"quality", required_argument, nullptr, OPT_QUALITY},
106 {"sqrFactor", required_argument, nullptr, OPT_SQR_FACTOR},
107 {"maxBitrate", required_argument, nullptr, OPT_MAX_BITRATE},
108 {"targetQp", required_argument, nullptr, OPT_TARGET_QP},
109 {"qpRange", required_argument, nullptr, OPT_QP_RANGE},
110 {"ltrFrameCount", required_argument, nullptr, OPT_LTR_FRAME_COUNT},
111 {"repeatAfter", required_argument, nullptr, OPT_REPEAT_AFTER},
112 {"repeatMaxCnt", required_argument, nullptr, OPT_REPEAT_MAX_CNT},
113 {"layerCnt", required_argument, nullptr, OPT_LAYER_COUNT},
114 {"waterMark", required_argument, nullptr, OPT_WATERMARK},
115 {"paramsFeedback", required_argument, nullptr, OPT_ENABLE_PARAMS_FEEDBACK},
116 {"enableQPMap", required_argument, nullptr, OPT_ENABLE_QP_MAP},
117 {"isAbsQpMap", required_argument, nullptr, OPT_IS_ABS_QP_MAP},
118 {"qpMapValue", required_argument, nullptr, OPT_QP_MAP_VALUE},
119 {"gopBMode", required_argument, nullptr, OPT_GOP_B_MODE},
120 // decoder only
121 {"rotation", required_argument, nullptr, OPT_ROTATION},
122 {"decThenEnc", required_argument, nullptr, OPT_DEC_THEN_ENC},
123 {"flushCnt", required_argument, nullptr, OPT_FLUSH_CNT},
124 {"scaleMode", required_argument, nullptr, OPT_SCALE_MODE},
125 {nullptr, no_argument, nullptr, OPT_UNKONWN},
126 };
127
ShowUsage()128 void ShowUsage()
129 {
130 std::cout << "HCodec Test Options:" << std::endl;
131 std::cout << " --help help info." << std::endl;
132 std::cout << " -i, --in file name for input file." << std::endl;
133 std::cout << " -w, --width video width." << std::endl;
134 std::cout << " -h, --height video height." << std::endl;
135 std::cout << " --apiType 0: codecbase, 1: new capi, 2: old capi." << std::endl;
136 std::cout << " --isEncoder 1 is test encoder, 0 is test decoder" << std::endl;
137 std::cout << " --isBufferMode 0 is surface mode, 1 is buffer mode." << std::endl;
138 std::cout << " --repeatCnt repeat test, default is 1" << std::endl;
139 std::cout << " --maxReadFrameCnt read up to frame count from input file" << std::endl;
140 std::cout << " --protocol video protocol. 0 is H264, 1 is H265" << std::endl;
141 std::cout << " --pixelFmt video pixel fmt. 1 is I420, 2 is NV12, 3 is NV21, 5 is RGBA" << std::endl;
142 std::cout << " --frameRate video frame rate." << std::endl;
143 std::cout << " --timeout thread timeout(ms). -1 means wait forever" << std::endl;
144 std::cout << " --isHighPerfMode 0 is normal mode, 1 is high perf mode" << std::endl;
145 std::cout << " --setParameter eg. 11:frameRate,60 or 24:requestIdr,1" << std::endl;
146 std::cout << " --setPerFrame eg. 11:ltr,1,0,30 or 24:qp,3,40 or 25:discard,1 or 30:ebr,16,30,25,0 or 30:roiParams,Top1,Left1-Bottom1,Right1=Offset1;Top2,Left2-Bottom2,Right2=Offset2;..."
147 << std::endl;
148 std::cout << " --setResource eg. 11:/data/test/a.yuv,1280,720,2" << std::endl;
149 std::cout << " [encoder only]" << std::endl;
150 std::cout << " --mockFrameCnt when read up to maxReadFrameCnt, just send old frames" << std::endl;
151 std::cout << " --colorRange color range. 1 is full range, 0 is limited range." << std::endl;
152 std::cout << " --colorPrimary color primary. see H.273 standard." << std::endl;
153 std::cout << " --colorTransfer color transfer characteristic. see H.273 standard." << std::endl;
154 std::cout << " --colorMatrix color matrix coefficient. see H.273 standard." << std::endl;
155 std::cout << " --iFrameInterval <0 means only one I frame, =0 means all intra" << std::endl;
156 std::cout << " >0 means I frame interval in milliseconds" << std::endl;
157 std::cout << " --profile video profile, for 264: 0(baseline), 1(constrained baseline), " << std::endl;
158 std::cout << " 2(constrained high), 3(extended), 4(high), 8(main)" << std::endl;
159 std::cout << " for 265: 0(main), 1(main 10)" << std::endl;
160 std::cout << " --bitRateMode bit rate mode for encoder. 0(CBR), 1(VBR), 2(CQ), 3(SQR), 11(CRF)"
161 << ", 10(CBR_VIDEOCALL)" << std::endl;
162 std::cout << " --bitRate target encode bit rate (bps)" << std::endl;
163 std::cout << " --quality target encode quality" << std::endl;
164 std::cout << " --sqrFactor target encode QP" << std::endl;
165 std::cout << " --maxBitrate sqr mode max bitrate" << std::endl;
166 std::cout << " --qpRange target encode qpRange, eg. 13,42" << std::endl;
167 std::cout << " --ltrFrameCount The number of long-term reference frames." << std::endl;
168 std::cout << " --repeatAfter repeat previous frame after target ms" << std::endl;
169 std::cout << " --repeatMaxCnt repeat previous frame up to target times" << std::endl;
170 std::cout << " --layerCnt target encode layerCnt, H264:2, H265:2 and 3" << std::endl;
171 std::cout << " --waterMark eg. /data/test/a.rgba,1280,720,2:16,16,1280,720" << std::endl;
172 std::cout << " --gopBMode gop mode for b frame. 1(adaptive-b mode), 2(h3b mode)" << std::endl;
173 std::cout << " [decoder only]" << std::endl;
174 std::cout << " --rotation rotation angle after decode, eg. 0/90/180/270" << std::endl;
175 std::cout << " --paramsFeedback 0 means don't feedback, 1 means feedback" << std::endl;
176 std::cout << " --decThenEnc do surface encode after surface decode" << std::endl;
177 std::cout << " --flushCnt total flush count during decoding" << std::endl;
178 std::cout << " --scaleMode target scale mode after decode, see @OH_ScalingMode" << std::endl;
179 }
180
Parse(int argc,char * argv[])181 CommandOpt Parse(int argc, char *argv[])
182 {
183 CommandOpt opt;
184 int c;
185 while ((c = getopt_long(argc, argv, "i:w:h:", g_longOptions, nullptr)) != -1) {
186 switch (c) {
187 case OPT_HELP:
188 ShowUsage();
189 break;
190 case OPT_INPUT:
191 opt.inputFile = string(optarg);
192 break;
193 case OPT_WIDTH:
194 opt.dispW = stol(optarg);
195 break;
196 case OPT_HEIGHT:
197 opt.dispH = stol(optarg);
198 break;
199 case OPT_API_TYPE:
200 opt.apiType = static_cast<ApiType>(stol(optarg));
201 break;
202 case OPT_IS_ENCODER:
203 opt.isEncoder = stol(optarg);
204 break;
205 case OPT_IS_BUFFER_MODE:
206 opt.isBufferMode = stol(optarg);
207 break;
208 case OPT_REPEAT_CNT:
209 opt.repeatCnt = stol(optarg);
210 break;
211 case OPT_MAX_READ_CNT:
212 opt.maxReadFrameCnt = stol(optarg);
213 break;
214 case OPT_PROTOCOL:
215 opt.protocol = static_cast<CodeType>(stol(optarg));
216 break;
217 case OPT_PIXEL_FMT:
218 opt.pixFmt = static_cast<VideoPixelFormat>(stol(optarg));
219 break;
220 case OPT_FRAME_RATE:
221 opt.frameRate = stol(optarg);
222 break;
223 case OPT_TIME_OUT:
224 opt.timeout = stol(optarg);
225 break;
226 case OPT_IS_HIGH_PERF_MODE:
227 opt.isHighPerfMode = stol(optarg);
228 break;
229 case OPT_SET_PARAMETER:
230 opt.ParseParamFromCmdLine(SET_PARAM, optarg);
231 break;
232 case OPT_SET_PER_FRAME:
233 opt.ParseParamFromCmdLine(PER_FRAME_PARAM, optarg);
234 break;
235 case OPT_SET_RESOURCE:
236 opt.ParseParamFromCmdLine(RESOURCE_PARAM, optarg);
237 break;
238 // encoder only
239 case OPT_MOCK_FRAME_CNT:
240 opt.mockFrameCnt = stol(optarg);
241 break;
242 case OPT_COLOR_RANGE:
243 opt.rangeFlag = stol(optarg);
244 break;
245 case OPT_COLOR_PRIMARY:
246 opt.primary = static_cast<ColorPrimary>(stol(optarg));
247 break;
248 case OPT_COLOR_TRANSFER:
249 opt.transfer = static_cast<TransferCharacteristic>(stol(optarg));
250 break;
251 case OPT_COLOR_MATRIX:
252 opt.matrix = static_cast<MatrixCoefficient>(stol(optarg));
253 break;
254 case OPT_I_FRAME_INTERVAL:
255 opt.iFrameInterval = stol(optarg);
256 break;
257 case OPT_PROFILE:
258 opt.profile = stol(optarg);
259 break;
260 case OPT_BITRATE_MODE:
261 opt.rateMode = static_cast<VideoEncodeBitrateMode>(stol(optarg));
262 break;
263 case OPT_BITRATE:
264 opt.bitRate = stol(optarg);
265 break;
266 case OPT_QUALITY:
267 opt.quality = stol(optarg);
268 break;
269 case OPT_SQR_FACTOR:
270 opt.sqrFactor = stol(optarg);
271 break;
272 case OPT_MAX_BITRATE:
273 opt.maxBitrate = stol(optarg);
274 break;
275 case OPT_TARGET_QP:
276 opt.targetQp = stol(optarg);
277 break;
278 case OPT_QP_RANGE: {
279 istringstream is(optarg);
280 QPRange range;
281 char tmp;
282 is >> range.qpMin >> tmp >> range.qpMax;
283 opt.qpRange = range;
284 break;
285 }
286 case OPT_LTR_FRAME_COUNT:
287 opt.ltrFrameCount = stol(optarg);
288 break;
289 case OPT_REPEAT_AFTER:
290 opt.repeatAfter = stol(optarg);
291 break;
292 case OPT_REPEAT_MAX_CNT:
293 opt.repeatMaxCnt = stol(optarg);
294 break;
295 case OPT_LAYER_COUNT:
296 opt.layerCnt = stol(optarg);
297 break;
298 case OPT_WATERMARK:
299 opt.ParseWaterMark(optarg);
300 break;
301 case OPT_ENABLE_PARAMS_FEEDBACK:
302 opt.paramsFeedback = stol(optarg);
303 break;
304 case OPT_ENABLE_QP_MAP:
305 opt.enableQPMap = stol(optarg);
306 break;
307 case OPT_GOP_B_MODE:
308 opt.gopBMode = stol(optarg);
309 break;
310 // decoder only
311 case OPT_DEC_THEN_ENC:
312 opt.decThenEnc = stol(optarg);
313 break;
314 case OPT_ROTATION:
315 opt.rotation = static_cast<VideoRotation>(stol(optarg));
316 break;
317 case OPT_FLUSH_CNT:
318 opt.flushCnt = stol(optarg);
319 break;
320 case OPT_SCALE_MODE:
321 opt.scaleMode = static_cast<OH_ScalingMode>(stol(optarg));
322 break;
323 default:
324 break;
325 }
326 }
327 return opt;
328 }
329
ParseParamFromCmdLine(ParamType paramType,const char * cmd)330 void CommandOpt::ParseParamFromCmdLine(ParamType paramType, const char *cmd)
331 {
332 string s(cmd);
333 auto pos = s.find(':');
334 if (pos == string::npos) {
335 return;
336 }
337 auto frameNo = stoul(s.substr(0, pos));
338 string paramList = s.substr(pos + 1);
339 switch (paramType) {
340 case SET_PARAM: {
341 ParseSetParameter(frameNo, paramList);
342 break;
343 }
344 case PER_FRAME_PARAM: {
345 ParsePerFrameParam(frameNo, paramList);
346 break;
347 }
348 case RESOURCE_PARAM: {
349 ResourceParams dst;
350 ParseResourceParam(paramList, dst);
351 resourceParamsMap[frameNo] = dst;
352 break;
353 }
354 default: {
355 break;
356 }
357 }
358 }
359
ParseSetParameter(uint32_t frameNo,const string & s)360 void CommandOpt::ParseSetParameter(uint32_t frameNo, const string &s)
361 {
362 auto pos = s.find(',');
363 if (pos == string::npos) {
364 return;
365 }
366 char c;
367 string key = s.substr(0, pos);
368 istringstream value(s.substr(pos + 1));
369 if (key == "requestIdr") {
370 bool requestIdr;
371 value >> requestIdr;
372 setParameterParamsMap[frameNo].requestIdr = requestIdr;
373 }
374 if (key == "bitRate") {
375 uint32_t bitRate;
376 value >> bitRate;
377 setParameterParamsMap[frameNo].bitRate = bitRate;
378 }
379 if (key == "frameRate") {
380 double fr;
381 value >> fr;
382 setParameterParamsMap[frameNo].frameRate = fr;
383 }
384 if (key == "qpRange") {
385 QPRange qpRange;
386 value >> qpRange.qpMin >> c >> qpRange.qpMax;
387 setParameterParamsMap[frameNo].qpRange = qpRange;
388 }
389 if (key == "targetQp") {
390 uint32_t targetQp;
391 value >> targetQp;
392 setParameterParamsMap[frameNo].targetQp = targetQp;
393 }
394 if (key == "operatingRate") {
395 double operatingRate;
396 value >> operatingRate;
397 setParameterParamsMap[frameNo].operatingRate = operatingRate;
398 }
399 if (key == "sqr") { // sqr,bitrate(optional),maxBitrate(optional),sqrFactor(optional)
400 SQRParam sqrParam;
401 std::string token;
402 std::vector<std::optional<int>> sqrUserSet;
403 while (std::getline(value, token, ',')) {
404 sqrUserSet.push_back(token.empty() ? std::nullopt : std::optional<int32_t>(std::stoi(token)));
405 }
406 if (sqrUserSet.size() > 0) sqrParam.bitrate = sqrUserSet[0];
407 if (sqrUserSet.size() > 1) sqrParam.maxBitrate = sqrUserSet[1];
408 if (sqrUserSet.size() > 2) sqrParam.sqrFactor = sqrUserSet[2]; // sqrFactor index:2
409 setParameterParamsMap[frameNo].sqrParam = sqrParam;
410 }
411 }
412
ParsePerFrameParam(uint32_t frameNo,const string & s)413 void CommandOpt::ParsePerFrameParam(uint32_t frameNo, const string &s)
414 {
415 auto pos = s.find(',');
416 if (pos == string::npos) {
417 return;
418 }
419 string key = s.substr(0, pos);
420 istringstream value(s.substr(pos + 1));
421 char c;
422 if (key == "requestIdr") {
423 bool requestIdr;
424 value >> requestIdr;
425 perFrameParamsMap[frameNo].requestIdr = requestIdr;
426 }
427 if (key == "qpRange") {
428 QPRange qpRange;
429 value >> qpRange.qpMin >> c >> qpRange.qpMax;
430 perFrameParamsMap[frameNo].qpRange = qpRange;
431 }
432 if (key == "ltr") {
433 LTRParam ltr;
434 value >> ltr.markAsLTR >> c >> ltr.useLTR >> c >> ltr.useLTRPoc;
435 perFrameParamsMap[frameNo].ltrParam = ltr;
436 }
437 if (key == "discard") {
438 bool discard;
439 value >> discard;
440 perFrameParamsMap[frameNo].discard = discard;
441 }
442 if (key == "ebr") {
443 EBRParam ebrParam;
444 value >> ebrParam.minQp >> c >> ebrParam.maxQp >> c >> ebrParam.startQp >> c >> ebrParam.isSkip;
445 perFrameParamsMap[frameNo].ebrParam = ebrParam;
446 }
447 if (key == "roiParams") {
448 string roiParams;
449 value >> roiParams;
450 perFrameParamsMap[frameNo].roiParams = roiParams;
451 }
452 if (key == "isAbsQpMap") {
453 bool absQp;
454 value >> absQp;
455 perFrameParamsMap[frameNo].absQpMap = absQp;
456 }
457 if (key == "qpMapValue") {
458 int32_t qpMapValue;
459 value >> qpMapValue;
460 perFrameParamsMap[frameNo].qpMapValue = qpMapValue;
461 if (!perFrameParamsMap[frameNo].absQpMap.has_value()) {
462 perFrameParamsMap[frameNo].absQpMap = false;
463 }
464 }
465 }
466
ParseResourceParam(const std::string & src,ResourceParams & dst)467 void CommandOpt::ParseResourceParam(const std::string &src, ResourceParams& dst)
468 {
469 auto pos = src.find(',');
470 if (pos == string::npos) {
471 return;
472 }
473 dst.inputFile = src.substr(0, pos);
474 istringstream value(src.substr(pos + 1));
475 int pixelFmt;
476 char c;
477 value >> dst.dispW >> c >> dst.dispH >> c >> pixelFmt;
478 dst.pixFmt = static_cast<VideoPixelFormat>(pixelFmt);
479 }
480
ParseWaterMark(const char * cmd)481 void CommandOpt::ParseWaterMark(const char *cmd) // "/data/test/a.rgba,1280,720,2:16,16,1280,720"
482 {
483 string s(cmd);
484 auto pos = s.find(':');
485 if (pos == string::npos) {
486 return;
487 }
488 waterMark.isSet = true;
489 string resource = s.substr(0, pos); // "/data/test/a.rgba,1280,720,2"
490 ParseResourceParam(resource, waterMark.waterMarkFile);
491 istringstream coordinate(s.substr(pos + 1)); // "16,16,1280,720"
492 char c;
493 coordinate >> waterMark.dstX >> c >> waterMark.dstY >> c >> waterMark.dstW >> c >> waterMark.dstH;
494 }
495
Print() const496 void CommandOpt::Print() const
497 {
498 TLOGI("-----------------------------");
499 TLOGI("api type=%d, %s, %s mode", apiType,
500 (isEncoder ? "encoder" : (decThenEnc ? "dec + enc" : "decoder")),
501 isBufferMode ? "buffer" : "surface");
502 TLOGI("read inputFile %s up to %u frames", inputFile.c_str(), maxReadFrameCnt);
503 TLOGI("%u x %u @ %u fps", dispW, dispH, frameRate);
504 TLOGI("protocol = %d, pixFmt = %d", protocol, pixFmt);
505 TLOGI("repeat %u times, timeout = %d", repeatCnt, timeout);
506 TLOGI("enableHighPerfMode : %s", isHighPerfMode ? "yes" : "no");
507
508 if (gopBMode.has_value()) {
509 TLOGI("gopBMode : %d", gopBMode.value());
510 }
511 if (mockFrameCnt.has_value()) {
512 TLOGI("mockFrameCnt %u", mockFrameCnt.value());
513 }
514 if (rangeFlag.has_value()) {
515 TLOGI("rangeFlag %d", rangeFlag.value());
516 }
517 if (primary.has_value()) {
518 TLOGI("primary %d", primary.value());
519 }
520 if (transfer.has_value()) {
521 TLOGI("transfer %d", transfer.value());
522 }
523 if (matrix.has_value()) {
524 TLOGI("matrix %d", matrix.value());
525 }
526 if (iFrameInterval.has_value()) {
527 TLOGI("iFrameInterval %d", iFrameInterval.value());
528 }
529 if (profile.has_value()) {
530 TLOGI("profile %d", profile.value());
531 }
532 if (rateMode.has_value()) {
533 TLOGI("rateMode %d", rateMode.value());
534 }
535 if (bitRate.has_value()) {
536 TLOGI("bitRate %u", bitRate.value());
537 }
538 if (quality.has_value()) {
539 TLOGI("quality %u", quality.value());
540 }
541 if (sqrFactor.has_value()) {
542 TLOGI("sqrFactor %u", sqrFactor.value());
543 }
544 if (maxBitrate.has_value()) {
545 TLOGI("maxBitrate %u", maxBitrate.value());
546 }
547 if (targetQp.has_value()) {
548 TLOGI("targetQp %u", targetQp.value());
549 }
550 if (qpRange.has_value()) {
551 TLOGI("qpRange %u~%u", qpRange->qpMin, qpRange->qpMax);
552 }
553 if (roiParams.has_value()) {
554 TLOGI("roiParams: %s",roiParams->c_str());
555 }
556 if (waterMark.isSet) {
557 TLOGI("dstX %d, dstY %d, dstW %d, dstH %d",
558 waterMark.dstX, waterMark.dstY, waterMark.dstW, waterMark.dstH);
559 }
560 TLOGI("rotation angle %u", rotation);
561 TLOGI("flush cnt %d", flushCnt);
562 for (const auto &[frameNo, setparam] : setParameterParamsMap) {
563 TLOGI("frameNo = %u:", frameNo);
564 if (setparam.requestIdr.has_value()) {
565 TLOGI(" requestIdr %d", setparam.requestIdr.value());
566 }
567 if (setparam.qpRange.has_value()) {
568 TLOGI(" qpRange %u~%u", setparam.qpRange->qpMin, setparam.qpRange->qpMax);
569 }
570 if (setparam.bitRate.has_value()) {
571 TLOGI(" bitRate %u", setparam.bitRate.value());
572 }
573 if (setparam.frameRate.has_value()) {
574 TLOGI(" frameRate %f", setparam.frameRate.value());
575 }
576 if (setparam.frameRate.has_value()) {
577 TLOGI(" frameRate %f", setparam.frameRate.value());
578 }
579 if (setparam.sqrParam.has_value()) {
580 TLOGI(" sqrParam: %s %s %s",
581 setparam.sqrParam->bitrate.has_value() ?
582 ("bitrate="+std::to_string(setparam.sqrParam->bitrate.value())).c_str() : "",
583 setparam.sqrParam->maxBitrate.has_value() ?
584 ("maxBitrate="+std::to_string(setparam.sqrParam->maxBitrate.value())).c_str() : "",
585 setparam.sqrParam->sqrFactor.has_value() ?
586 ("sqrFactor="+std::to_string(setparam.sqrParam->sqrFactor.value())).c_str() : ""
587 );
588 }
589 }
590 for (const auto &[frameNo, perFrame] : perFrameParamsMap) {
591 TLOGI("frameNo = %u:", frameNo);
592 if (perFrame.requestIdr.has_value()) {
593 TLOGI(" requestIdr %d", perFrame.requestIdr.value());
594 }
595 if (perFrame.qpRange.has_value()) {
596 TLOGI(" qpRange %u~%u", perFrame.qpRange->qpMin, perFrame.qpRange->qpMax);
597 }
598 if (perFrame.ltrParam.has_value()) {
599 TLOGI(" LTR, markAsLTR %d, useLTR %d, useLTRPoc %u",
600 perFrame.ltrParam->markAsLTR, perFrame.ltrParam->useLTR, perFrame.ltrParam->useLTRPoc);
601 }
602 if (perFrame.absQpMap.has_value() && perFrame.qpMapValue.has_value()) {
603 TLOGI(" qpMap, type %d (0: delta qp, 1: abs qp), value %d",
604 perFrame.absQpMap.value(), perFrame.qpMapValue.value());
605 }
606 if (perFrame.roiParams.has_value()) {
607 TLOGI("roiParams: %s", perFrame.roiParams.value().c_str());
608 }
609 }
610 for (const auto &[frameNo, resourceParam] : resourceParamsMap) {
611 TLOGI("frameNo = %u, filePath = %s, %u x %u, pixFmt = %d", frameNo,
612 resourceParam.inputFile.c_str(), resourceParam.dispW, resourceParam.dispH, resourceParam.pixFmt);
613 }
614 TLOGI("-----------------------------");
615 }
616 }