Coverage Report

Created: 2026-04-01 07:49

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/vvenc/source/Lib/apputils/VVEncAppCfg.h
Line
Count
Source
1
/* -----------------------------------------------------------------------------
2
The copyright in this software is being made available under the Clear BSD
3
License, included below. No patent rights, trademark rights and/or 
4
other Intellectual Property Rights other than the copyrights concerning 
5
the Software are granted under this license.
6
7
The Clear BSD License
8
9
Copyright (c) 2019-2026, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. & The VVenC Authors.
10
All rights reserved.
11
12
Redistribution and use in source and binary forms, with or without modification,
13
are permitted (subject to the limitations in the disclaimer below) provided that
14
the following conditions are met:
15
16
     * Redistributions of source code must retain the above copyright notice,
17
     this list of conditions and the following disclaimer.
18
19
     * Redistributions in binary form must reproduce the above copyright
20
     notice, this list of conditions and the following disclaimer in the
21
     documentation and/or other materials provided with the distribution.
22
23
     * Neither the name of the copyright holder nor the names of its
24
     contributors may be used to endorse or promote products derived from this
25
     software without specific prior written permission.
26
27
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY
28
THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
29
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
31
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
32
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
33
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
34
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
35
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
36
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38
POSSIBILITY OF SUCH DAMAGE.
39
40
------------------------------------------------------------------------------------------- */
41
/** \file     VVEncAppCfg.h
42
    \brief    Handle encoder configuration parameters (header)
43
*/
44
45
#pragma once
46
47
#include "vvenc/vvencCfg.h"
48
#include "vvenc/vvenc.h"
49
50
51
#include <string>
52
#include <vector>
53
#include <tuple>
54
#include <functional>
55
56
#include <cstring>
57
#include <fstream>
58
#include <sstream>
59
#include <algorithm>
60
#include <cstdarg>
61
62
#include "IStreamIO.h"
63
#include "ParseArg.h"
64
#include "YuvFileIO.h"
65
66
#define MACRO_TO_STRING_HELPER(val) #val
67
#define MACRO_TO_STRING(val) MACRO_TO_STRING_HELPER(val)
68
69
using namespace std;
70
namespace po = apputils::program_options;
71
72
namespace apputils {
73
74
//! \ingroup apputils
75
//! \{
76
77
78
// ====================================================================================================================
79
// enums
80
// ====================================================================================================================
81
enum BitDepthAndColorSpace
82
{
83
  YUV420_8,
84
  YUV420_10,
85
  YUV422_8,
86
  YUV422_10,
87
  YUV444_8,
88
  YUV444_10,
89
  YUV400_8,
90
  YUV400_10,
91
  YUV420_10_PACKED
92
};
93
94
// ====================================================================================================================
95
// string <-> enum fixed mappings
96
// ====================================================================================================================
97
const std::vector<SVPair<vvencMsgLevel>> MsgLevelToEnumMap =
98
{
99
  { "silent",  vvencMsgLevel::VVENC_SILENT  },
100
  { "error",   vvencMsgLevel::VVENC_ERROR   },
101
  { "warning", vvencMsgLevel::VVENC_WARNING },
102
  { "info",    vvencMsgLevel::VVENC_INFO    },
103
  { "notice",  vvencMsgLevel::VVENC_NOTICE  },
104
  { "verbose", vvencMsgLevel::VVENC_VERBOSE },
105
  { "details", vvencMsgLevel::VVENC_DETAILS },
106
  { "0",       vvencMsgLevel::VVENC_SILENT  },
107
  { "1",       vvencMsgLevel::VVENC_ERROR   },
108
  { "2",       vvencMsgLevel::VVENC_WARNING },
109
  { "3",       vvencMsgLevel::VVENC_INFO    },
110
  { "4",       vvencMsgLevel::VVENC_NOTICE  },
111
  { "5",       vvencMsgLevel::VVENC_VERBOSE },
112
  { "6",       vvencMsgLevel::VVENC_DETAILS },
113
};
114
115
116
const std::vector<SVPair<vvencPresetMode>> PresetToEnumMap =
117
{
118
  { "none",      vvencPresetMode::VVENC_NONE },
119
  { "faster",    vvencPresetMode::VVENC_FASTER },
120
  { "fast",      vvencPresetMode::VVENC_FAST },
121
  { "medium",    vvencPresetMode::VVENC_MEDIUM },
122
  { "slow",      vvencPresetMode::VVENC_SLOW },
123
  { "slower",    vvencPresetMode::VVENC_SLOWER },
124
  { "0",         vvencPresetMode::VVENC_FASTER },
125
  { "1",         vvencPresetMode::VVENC_FAST },
126
  { "2",         vvencPresetMode::VVENC_MEDIUM },
127
  { "3",         vvencPresetMode::VVENC_SLOW },
128
  { "4",         vvencPresetMode::VVENC_SLOWER },
129
  { "medium_lowDecEnergy", vvencPresetMode::VVENC_MEDIUM_LOWDECNRG },
130
  { "medium_lowdecenergy", vvencPresetMode::VVENC_MEDIUM_LOWDECNRG },
131
  { "firstpass", vvencPresetMode::VVENC_FIRSTPASS },
132
  { "tooltest",  vvencPresetMode::VVENC_TOOLTEST },
133
};
134
135
const std::vector<SVPair<vvencSegmentMode>> SegmentToEnumMap =
136
{
137
  { "off",      vvencSegmentMode::VVENC_SEG_OFF },
138
  { "first",    vvencSegmentMode::VVENC_SEG_FIRST },
139
  { "mid",      vvencSegmentMode::VVENC_SEG_MID },
140
  { "last",     vvencSegmentMode::VVENC_SEG_LAST },
141
};
142
143
144
const std::vector<SVPair<vvencProfile>> ProfileToEnumMap =
145
{
146
  { "main_10",                               vvencProfile::VVENC_MAIN_10 },
147
  { "main_10_444",                           vvencProfile::VVENC_MAIN_10_444 },
148
  { "main_10_still_picture",                 vvencProfile::VVENC_MAIN_10_STILL_PICTURE },
149
  { "main_10_444_still_picture",             vvencProfile::VVENC_MAIN_10_444_STILL_PICTURE },
150
  { "multilayer_main_10",                    vvencProfile::VVENC_MULTILAYER_MAIN_10 },
151
  { "multilayer_main_10_444",                vvencProfile::VVENC_MULTILAYER_MAIN_10_444 },
152
  { "multilayer_main_10_still_picture",      vvencProfile::VVENC_MULTILAYER_MAIN_10_STILL_PICTURE },
153
  { "multilayer_main_10_444_still_picture",  vvencProfile::VVENC_MULTILAYER_MAIN_10_444_STILL_PICTURE },
154
  { "auto",                                  vvencProfile::VVENC_PROFILE_AUTO },
155
};
156
157
const std::vector<SVPair<vvencLevel>> LevelToEnumMap =
158
{
159
  { "auto",                    VVENC_LEVEL_AUTO},
160
  { "1",                       VVENC_LEVEL1    },
161
  { "1.0",                     VVENC_LEVEL1    },
162
  { "2",                       VVENC_LEVEL2    },
163
  { "2.0",                     VVENC_LEVEL2    },
164
  { "2.1",                     VVENC_LEVEL2_1  },
165
  { "3",                       VVENC_LEVEL3    },
166
  { "3.0",                     VVENC_LEVEL3    },
167
  { "3.1",                     VVENC_LEVEL3_1  },
168
  { "4",                       VVENC_LEVEL4    },
169
  { "4.0",                     VVENC_LEVEL4    },
170
  { "4.1",                     VVENC_LEVEL4_1  },
171
  { "5",                       VVENC_LEVEL5    },
172
  { "5.0",                     VVENC_LEVEL5    },
173
  { "5.1",                     VVENC_LEVEL5_1  },
174
  { "5.2",                     VVENC_LEVEL5_2  },
175
  { "6",                       VVENC_LEVEL6    },
176
  { "6.0",                     VVENC_LEVEL6    },
177
  { "6.1",                     VVENC_LEVEL6_1  },
178
  { "6.2",                     VVENC_LEVEL6_2  },
179
  { "6.3",                     VVENC_LEVEL6_3  },
180
  { "15.5",                    VVENC_LEVEL15_5 },
181
};
182
183
const std::vector<SVPair<vvencTier>> TierToEnumMap =
184
{
185
  { "main",                    vvencTier::VVENC_TIER_MAIN },
186
  { "high",                    vvencTier::VVENC_TIER_HIGH },
187
};
188
189
const std::vector<SVPair<vvencCostMode>> CostModeToEnumMap =
190
{
191
  { "lossy",                   VVENC_COST_STANDARD_LOSSY              },
192
  { "sequence_level_lossless", VVENC_COST_SEQUENCE_LEVEL_LOSSLESS     },
193
  { "lossless",                VVENC_COST_LOSSLESS_CODING             },
194
  { "mixed_lossless_lossy",    VVENC_COST_MIXED_LOSSLESS_LOSSY_CODING }
195
};
196
197
const std::vector<SVPair<vvencChromaFormat>> ChromaFormatToEnumMap =
198
{
199
  { "400",                     VVENC_CHROMA_400 },
200
  { "420",                     VVENC_CHROMA_420 },
201
  { "422",                     VVENC_CHROMA_422 },
202
  { "444",                     VVENC_CHROMA_444 },
203
  { "0",                       VVENC_NUM_CHROMA_FORMAT }
204
};
205
206
const std::vector<SVPair<vvencHashType>> HashTypeToEnumMap =
207
{
208
  { "md5",                     VVENC_HASHTYPE_MD5          },
209
  { "crc",                     VVENC_HASHTYPE_CRC          },
210
  { "checksum",                VVENC_HASHTYPE_CHECKSUM     },
211
  { "log_md5",                 VVENC_HASHTYPE_MD5_LOG      },
212
  { "log_crc",                 VVENC_HASHTYPE_CRC_LOG      },
213
  { "log_checksum",            VVENC_HASHTYPE_CHECKSUM_LOG },
214
  { "off",                     VVENC_HASHTYPE_NONE         },
215
  // for backward compatibility support values as well
216
  { "1",                       VVENC_HASHTYPE_MD5          },
217
  { "2",                       VVENC_HASHTYPE_CRC          },
218
  { "3",                       VVENC_HASHTYPE_CHECKSUM     },
219
  { "11",                      VVENC_HASHTYPE_MD5_LOG      },
220
  { "12",                      VVENC_HASHTYPE_CRC_LOG      },
221
  { "13",                      VVENC_HASHTYPE_CHECKSUM_LOG },
222
  { "0",                       VVENC_HASHTYPE_NONE         }
223
};
224
225
const std::vector<SVPair<vvencDecodingRefreshType>> DecodingRefreshTypeToEnumMap =
226
{
227
  { "none",                  VVENC_DRT_NONE },
228
  { "cra",                   VVENC_DRT_CRA },
229
  { "idr",                   VVENC_DRT_IDR },
230
  { "rpsei",                 VVENC_DRT_RECOVERY_POINT_SEI },
231
  { "idr2",                  VVENC_DRT_IDR2 }, //deprecated
232
  { "cra_cre",               VVENC_DRT_CRA_CRE },
233
  { "idr_no_radl",           VVENC_DRT_IDR_NO_RADL },
234
  { "0",                     VVENC_DRT_NONE },
235
  { "1",                     VVENC_DRT_CRA },
236
  { "2",                     VVENC_DRT_IDR },
237
  { "3",                     VVENC_DRT_RECOVERY_POINT_SEI },
238
  { "4",                     VVENC_DRT_IDR2 },  //deprecated
239
  { "5",                     VVENC_DRT_CRA_CRE },
240
  { "6",                     VVENC_DRT_IDR_NO_RADL },
241
};
242
243
const std::vector<SVPair<BitDepthAndColorSpace>> BitColorSpaceToIntMap =
244
{
245
  { "yuv420",                    YUV420_8 },
246
  { "yuv420_10",                 YUV420_10 },
247
  { "yuv420_10_packed",          YUV420_10_PACKED },
248
  { "yuv400",                    YUV400_8 },
249
  { "gray",                      YUV400_8 },
250
  { "yuv400_10",                 YUV400_10 },
251
  { "gray10",                    YUV400_10 },
252
};
253
254
const std::vector<SVPair<int>> SaoToIntMap =
255
{
256
  { "0", 0 },
257
  { "1", 1 },
258
  { "2", 2 },
259
};
260
261
const std::vector<SVPair<vvencHDRMode>> SdrModeToIntMap =
262
{
263
  { "off",                 VVENC_HDR_OFF },
264
  { "sdr",                 VVENC_SDR_BT709},
265
  { "sdr_709",             VVENC_SDR_BT709},
266
  { "sdr709",              VVENC_SDR_BT709},
267
  { "sdr_2020",            VVENC_SDR_BT2020},
268
  { "sdr2020",             VVENC_SDR_BT2020},
269
  { "sdr_470bg",           VVENC_SDR_BT470BG},
270
  { "sdr470bg",            VVENC_SDR_BT470BG},
271
};
272
273
const std::vector<SVPair<vvencHDRMode>> HdrModeToIntMap =
274
{
275
  { "off",                 VVENC_HDR_OFF },
276
  { "pq",                  VVENC_HDR_PQ},
277
  { "hdr10",               VVENC_HDR_PQ},
278
  { "pq_2020",             VVENC_HDR_PQ_BT2020},
279
  { "hdr10_2020",          VVENC_HDR_PQ_BT2020},
280
  { "hlg",                 VVENC_HDR_HLG},
281
  { "hlg_2020",            VVENC_HDR_HLG_BT2020},
282
};
283
284
285
const std::vector<SVPair<int>> ColourPrimariesToIntMap =
286
{
287
  { "reserved",            0 },
288
  { "bt709",               1 },
289
  { "unknown",             2 },
290
  { "empty",               3 },
291
  { "bt470m",              4 },
292
  { "bt470bg",             5 },
293
  { "smpte170m",           6 },
294
  { "smpte240m",           7 },
295
  { "film",                8 },
296
  { "bt2020",              9 },
297
  { "smpte428",           10 },
298
  { "smpte431",           11 },
299
  { "smpte432",           12 },
300
  { "0", 0 }, { "1", 1 }, { "2", 2 }, { "3", 3 }, { "4", 4 }, { "5", 5 },
301
  { "6", 6 }, { "7", 7 }, { "8", 8 }, { "9", 9 }, { "10",10 }, { "11",11 }, { "12",12 }
302
};
303
304
const std::vector<SVPair<int>> TransferCharacteristicsToIntMap =
305
{
306
  { "auto",               -1 },
307
  { "reserved",            0 },
308
  { "bt709",               1 },
309
  { "unknown",             2 },
310
  { "empty",               3 },
311
  { "bt470m",              4 },
312
  { "bt470bg",             5 },
313
  { "smpte170m",           6 },
314
  { "smpte240m",           7 },
315
  { "linear",              8 },
316
  { "log100",              9 },
317
  { "log316",             10 },
318
  { "iec61966",           11 },
319
  { "bt1361e",            12 },
320
  { "iec61966-2-1",       13 },
321
  { "bt2020-10",          14 },
322
  { "bt2020-12",          15 },
323
  { "smpte2084",          16 },
324
  { "smpte428",           17 },
325
  { "arib-std-b67",       18 },
326
  { "0", 0 }, { "1", 1 }, { "2", 2 }, { "3", 3 }, { "4", 4 }, { "5", 5 },
327
  { "6", 6 }, { "7", 7 }, { "8", 8 }, { "9", 9 }, { "10",10 }, { "11",11 },
328
  { "12",12 },{ "13",13 },{ "14",14 },{ "15",15 },{ "16",16 },{ "17",17 },{ "18",18 }
329
};
330
331
const std::vector<SVPair<int>> ColourMatrixToIntMap =
332
{
333
  { "gbr",              0 },
334
  { "bt709",            1 },
335
  { "unknown",          2 },
336
  { "empty",            3 },
337
  { "fcc",              4 },
338
  { "bt470bg",          5 },
339
  { "smpte170m",        6 },
340
  { "smpte240m",        7 },
341
  { "ycgco",            8 },
342
  { "bt2020nc",         9 },
343
  { "bt2020c",          10 },
344
  { "smpte2085",        11 },
345
  { "chroma-derived-nc",12 },
346
  { "chroma-derived-c", 13 },
347
  { "ictcp",            14 },
348
  { "0", 0 }, { "1", 1 }, { "2", 2 }, { "3", 3 }, { "4", 4 }, { "5", 5 },
349
  { "6", 6 }, { "7", 7 }, { "8", 8 }, { "9", 9 }, { "10",10 }, { "11",11 },
350
  { "12",12 },{ "13",13 },{ "14",14 }
351
};
352
353
template<typename T>
354
const std::vector<SVPair<T>> FlagToIntMap =
355
{
356
  { "auto",        T(-1) },
357
  { "-1",          T(-1) },
358
359
  { "off",         T( 0) },
360
  { "disable",     T( 0) },
361
  { "0",           T( 0) },
362
363
  { "on",          T( 1) },
364
  { "enable",      T( 1) },
365
  { "1",           T( 1) },
366
};
367
368
// this is only needed for backward compatibility and will be removed in the next release
369
const std::vector<SVPair<bool>> QPAToIntMap =
370
{
371
  { "off",          0 },
372
  { "disable",      0 },
373
  { "0",            0 },
374
375
  { "on",           1 },
376
  { "enable",       1 },
377
  { "1",            1 },
378
  { "2",            1 }, // map deprecated modes 2-5 to qpa enabled
379
  { "3",            1 },
380
  { "4",            1 },
381
  { "5",            1 },
382
};
383
384
// abbreviations for target bitrates that are converted into bps internally (lower/upper case independent)
385
const std::vector<SVPair<int>> BitrateAbrevToIntMap =
386
{
387
  { "Mbps",         1000000 },  // mega bit/sec
388
  { "M",            1000000 },
389
  { "kbps",            1000 },  // kilo bit/sec
390
  { "k",               1000 },
391
  { "bps",                1 }   // bit/sec
392
};
393
394
const std::vector<SVPair<int>> BitrateOrScaleAbrevToIntMap =
395
{
396
  { "Mbps",         1000000 },  // mega bit/sec
397
  { "M",            1000000 },
398
  { "kbps",            1000 },  // kilo bit/sec
399
  { "k",               1000 },
400
  { "bps",                1 },  //      bit/sec
401
  { "x",                -16 }   // negative value: multiplier of target bitrate, with a fixed-point accuracy of 4 bit
402
};
403
404
const std::vector<SVPair<int8_t>> MtAbrevToIntMap =
405
{
406
  { "auto",     -1 },
407
  { "-1",       -1 },
408
409
  { "off",       0 },
410
  { "disable",   0 },
411
  { "0",         0 },
412
413
  { "1",         1 },
414
  { "2",         2 },
415
  { "3",         3 }
416
};
417
418
const std::vector<SVPair<int>> RangeToFullRangeFlagMap =
419
{
420
  { "unknown",     0 },
421
  { "unspecified", 0 },
422
  { "limited",     1 },
423
  { "mpeg",        1 },
424
  { "tv",          1 },
425
  { "0",           1 },
426
  { "full",        2 },
427
  { "jpeg",        2 },
428
  { "pc",          2 },
429
  { "1",           2 },
430
};
431
432
//// ====================================================================================================================
433
//// string <-> enum
434
//// ====================================================================================================================
435
436
class VVEncAppCfg;
437
438
static void setPresets( VVEncAppCfg* appcfg, vvenc_config* cfg,  int preset );
439
440
static void setInputBitDepthAndColorSpace( VVEncAppCfg* appcfg, vvenc_config* cfg, int dbcs );
441
442
static void setSAO( VVEncAppCfg *appcfg, vvenc_config *cfg, int saoVal );
443
444
static void setColourRange( VVEncAppCfg* appcfg, vvenc_config *cfg, int colourRange );
445
446
447
// ====================================================================================================================
448
// Class definition
449
// ====================================================================================================================
450
451
/// application params and parser class for app+lib options
452
class VVEncAppCfg
453
{
454
public:
455
  typedef std::function<void( vvenc_config*, vvencPresetMode ) > presetChangeCallback;
456
457
public:
458
  std::string  m_inputFileName;                                ///< source file name
459
  std::string  m_bitstreamFileName;                            ///< output bitstream file
460
  std::string  m_reconFileName;                                ///< output reconstruction file
461
  std::string  m_RCStatsFileName;                              ///< rate control statistics file
462
  vvencChromaFormat m_inputFileChromaFormat    = VVENC_CHROMA_420;
463
  int          m_FrameSkip                     = 0;            ///< number of skipped frames from the beginning
464
  bool         m_bClipInputVideoToRec709Range  = false;
465
  bool         m_bClipOutputVideoToRec709Range = false;
466
  bool         m_packedYUVInput                = false;        ///< If true, packed 10-bit YUV ( 4 samples packed into 5-bytes consecutively )
467
  bool         m_packedYUVOutput               = false;        ///< If true, output 10-bit and 12-bit YUV data as 5-byte and 3-byte (respectively) packed YUV data
468
  bool         m_forceY4mInput                 = false;        ///< If true, y4m input file syntax is forced (only needed for input via std::cin)
469
  bool         m_showVersion                   = false;
470
  bool         m_showHelp                      = false;
471
  bool         m_printStats                    = true;
472
473
  std::string  m_additionalSettings;                           ///< set additional settings (always parsed and set after other params are set)
474
                                                               ///< options must be defined as tuple key=value, entries must be separated by space' ' or colon ':'
475
                                                               ///< values that are not arbitrary must be quoted "\"values\""
476
                                                               ///< e.b. "bitrate=1000000 passes=1 QpInValCb=\"17 22 34 42\"" 
477
  std::string  m_logoFileName;                                 ///< logo overlay file
478
private:
479
  const bool   m_easyMode                      = false;        ///< internal state flag, if expert or easy mode
480
481
  presetChangeCallback  m_changePresetCallback = nullptr;
482
public:
483
484
  VVEncAppCfg( bool easyMode = false )
485
0
  : m_easyMode (easyMode )
486
0
  {
487
488
0
  }
489
0
  virtual ~VVEncAppCfg(){}
490
491
  void setPresetChangeCallback( presetChangeCallback callback )
492
0
  {
493
0
    m_changePresetCallback = callback;
494
0
  }
495
496
  presetChangeCallback getPresetChangeCallback( )
497
0
  {
498
0
    return m_changePresetCallback ;
499
0
  }
500
501
public:
502
503
/* parse
504
  This method parses a list of command line arguments and sets them in the vvenc_config
505
  \param[in]  argc number or arguments in argv string list
506
  \param[in]  argv list of char* (argv[]); option name must be defined by prefix -- or -
507
  \param[in]  vvenc_config* pointer to vvenc_config struct that contains encoder parameters
508
  \param[in]  std::ostream& reference to ostream where info,warnings and errors are written to
509
  \retval     returns 0 on success,
510
              < o on error
511
              > 0 :  1 when information is printed into ostream (help)
512
                      2 when warning is printed into ostream
513
*/
514
int parse( int argc, char* argv[], vvenc_config* c, std::ostream& rcOstr )
515
0
{
516
0
  int ret = 0;
517
518
  //
519
  // setup configuration parameters
520
  //
521
0
  bool do_help                = false;
522
0
  bool do_full_help           = false;
523
524
0
  int  warnUnknowParameter    = 0;
525
0
  std::string ignoreParams;
526
527
0
  std::string writeCfg = "";
528
529
0
  vvencHDRMode hdrMode = c->m_HdrMode;
530
0
  vvencHDRMode sdrMode = c->m_HdrMode;
531
532
0
  IStreamToEnum<vvencMsgLevel>      toMsgLevel                   ( &c->m_verbosity,   &MsgLevelToEnumMap );
533
0
  IStreamToFunc<vvencPresetMode>    toPreset                     ( setPresets, this, c, &PresetToEnumMap,vvencPresetMode::VVENC_MEDIUM);
534
0
  IStreamToRefVec<int>              toSourceSize                 ( { &c->m_SourceWidth, &c->m_SourceHeight }, true, 'x' );
535
0
  IStreamToRefVec<int>              toMaxPicSize                 ( { &c->m_maxPicWidth, &c->m_maxPicHeight }, true, 'x' );
536
0
  IStreamToRefVec<int>              toSarSize                    ( { &c->m_sarWidth, &c->m_sarHeight }, true, 'x' );
537
0
  IStreamToRefVec<int>              toFps                        ( { &c->m_FrameRate, &c->m_FrameScale }, false, '/' );
538
539
0
  IStreamToEnum<vvencProfile>       toProfile                    ( &c->m_profile,                     &ProfileToEnumMap      );
540
0
  IStreamToEnum<vvencTier>          toLevelTier                  ( &c->m_levelTier,                   &TierToEnumMap         );
541
0
  IStreamToEnum<vvencLevel>         toLevel                      ( &c->m_level,                       &LevelToEnumMap        );
542
0
  IStreamToEnum<vvencSegmentMode>   toSegment                    ( &c->m_SegmentMode,                 &SegmentToEnumMap      );
543
0
  IStreamToEnum<vvencHDRMode>       toSDRMode                    ( &sdrMode,                          &SdrModeToIntMap       );
544
0
  IStreamToEnum<vvencHDRMode>       toHDRMode                    ( &hdrMode,                          &HdrModeToIntMap       );
545
0
  IStreamToFunc<int>                toColourRangeMode            ( setColourRange, this, c, &RangeToFullRangeFlagMap, 0 );
546
547
0
  IStreamToRefVec<int32_t>          toNumTiles                   ( { &c->m_numTileCols, &c->m_numTileRows }, true, 'x'       );
548
549
0
  IStreamToFunc<BitDepthAndColorSpace>    toInputFormatBitdepth  ( setInputBitDepthAndColorSpace, this, c, &BitColorSpaceToIntMap, YUV420_8 );
550
0
  IStreamToAbbr<int,int>                  toBitrate              ( &c->m_RCTargetBitrate,             &BitrateAbrevToIntMap );
551
0
  IStreamToAbbr<int,int>                  toMaxRate              ( &c->m_RCMaxBitrate,                &BitrateOrScaleAbrevToIntMap );
552
0
  IStreamToEnum<vvencDecodingRefreshType> toDecRefreshType       ( &c->m_DecodingRefreshType,         &DecodingRefreshTypeToEnumMap );
553
554
0
  IStreamToEnum<int>                toAud                        ( &c->m_AccessUnitDelimiter,         &FlagToIntMap<int> );
555
0
  IStreamToEnum<int>                toVui                        ( &c->m_vuiParametersPresent,        &FlagToIntMap<int> );
556
0
  IStreamToEnum<int8_t>             toGOPQPA                     ( &c->m_GOPQPA,                      &FlagToIntMap<int8_t> );
557
0
  IStreamToEnum<bool>               toQPA                        ( &c->m_usePerceptQPA,               &QPAToIntMap );
558
  
559
560
0
  IStreamToRefVec<double>           toLambdaModifier             ( { &c->m_adLambdaModifier[0], &c->m_adLambdaModifier[1], &c->m_adLambdaModifier[2], &c->m_adLambdaModifier[3], &c->m_adLambdaModifier[4], &c->m_adLambdaModifier[5], &c->m_adLambdaModifier[6] }, false );
561
0
  IStreamToEnum<vvencCostMode>      toCostMode                   ( &c->m_costMode,                    &CostModeToEnumMap     );
562
0
  IStreamToEnum<vvencChromaFormat>  toInputFileChromaFormat      ( &m_inputFileChromaFormat,       &ChromaFormatToEnumMap  );
563
0
  IStreamToEnum<vvencChromaFormat>  toInternChromaFormat         ( &c->m_internChromaFormat,          &ChromaFormatToEnumMap  );
564
0
  IStreamToEnum<vvencHashType>      toHashType                   ( &c->m_decodedPictureHashSEIType,   &HashTypeToEnumMap     );
565
0
  IStreamToArr<int>                 toQpInCb                     ( &c->m_qpInValsCb[0], VVENC_MAX_QP_VALS_CHROMA            );
566
0
  IStreamToArr<int>                 toQpOutCb                    ( &c->m_qpOutValsCb[0], VVENC_MAX_QP_VALS_CHROMA           );
567
0
  IStreamToArr<int>                 toQpInCr                     ( &c->m_qpInValsCr[0], VVENC_MAX_QP_VALS_CHROMA            );
568
0
  IStreamToArr<int>                 toQpOutCr                    ( &c->m_qpOutValsCr[0], VVENC_MAX_QP_VALS_CHROMA           );
569
0
  IStreamToArr<int>                 toQpInCbCr                   ( &c->m_qpInValsCbCr[0], VVENC_MAX_QP_VALS_CHROMA          );
570
0
  IStreamToArr<int>                 toQpOutCbCr                  ( &c->m_qpOutValsCbCr[0], VVENC_MAX_QP_VALS_CHROMA         );
571
0
  IStreamToArr<double>              toIntraLambdaModifier        ( &c->m_adIntraLambdaModifier[0], VVENC_MAX_TLAYER );
572
573
0
  IStreamToArr<unsigned int>        toTileColumnWidth            ( &c->m_tileColumnWidth[0], 10 );
574
0
  IStreamToArr<unsigned int>        toTileRowHeight              ( &c->m_tileRowHeight[0], 10 );
575
576
0
  IStreamToArr<int>                 toMCTFFrames                 ( &c->m_vvencMCTF.MCTFFrames[0], VVENC_MAX_MCTF_FRAMES, &c->m_vvencMCTF.numFrames );
577
0
  IStreamToArr<double>              toMCTFStrengths              ( &c->m_vvencMCTF.MCTFStrengths[0], VVENC_MAX_MCTF_FRAMES, &c->m_vvencMCTF.numStrength );
578
0
  IStreamToEnum<int>                toColourPrimaries            ( &c->m_colourPrimaries,        &ColourPrimariesToIntMap );
579
0
  IStreamToEnum<int>                toTransferCharacteristics    ( &c->m_transferCharacteristics,&TransferCharacteristicsToIntMap );
580
0
  IStreamToEnum<int>                toColourMatrix               ( &c->m_matrixCoefficients,     &ColourMatrixToIntMap );
581
0
  IStreamToEnum<int>                toPrefTransferCharacteristics( &c->m_preferredTransferCharacteristics, &TransferCharacteristicsToIntMap );
582
583
0
  IStreamToArr<unsigned int>        toMasteringDisplay            ( &c->m_masteringDisplay[0], 10  );
584
0
  IStreamToArr<unsigned int>        toContentLightLevel           ( &c->m_contentLightLevel[0], 2 );
585
586
0
  IStreamToArr<char>                toTraceRule                   ( &c->m_traceRule[0], VVENC_MAX_STRING_LEN  );
587
0
  IStreamToArr<char>                toTraceFile                   ( &c->m_traceFile[0], VVENC_MAX_STRING_LEN  );
588
0
  IStreamToArr<char>                toSummaryOutFilename          ( &c->m_summaryOutFilename[0], VVENC_MAX_STRING_LEN  );
589
0
  IStreamToArr<char>                toSummaryPicFilenameBase      ( &c->m_summaryPicFilenameBase[0], VVENC_MAX_STRING_LEN  );
590
591
0
  IStreamToFunc<int>                toSaoWithScc                  ( setSAO, this, c, &SaoToIntMap, 0 );
592
593
0
  IStreamToInt8                     toSliceTypeAdapt              ( &c->m_sliceTypeAdapt );
594
0
  IStreamToInt8                     toSelectiveRDOQ               ( &c->m_useSelectiveRDOQ );
595
0
  IStreamToInt8                     toForceScc                    ( &c->m_forceScc );
596
0
  IStreamToInt8                     toIfpLines                    ( &c->m_ifpLines );
597
0
  IStreamToInt8                     toPOC0IDR                     ( &c->m_poc0idr );
598
599
0
  IStreamToEnum<int8_t>             toUseWpp                      ( &c->m_entropyCodingSyncEnabled,    &FlagToIntMap<int8_t> );
600
0
  IStreamToEnum<int8_t>             toUseIfp                      ( &c->m_ifp,                         &FlagToIntMap<int8_t> );
601
0
  IStreamToEnum<int8_t>             toChromaLocInfo               ( &c->m_chromaLocInfoPresent,        &FlagToIntMap<int8_t> );
602
0
  IStreamToEnum<int8_t>             toMtProfile                   ( &c->m_mtProfile,                   &MtAbrevToIntMap );
603
0
  IStreamToInt8                     toNumParallelGOPs             ( &c->m_numParallelGOPs );
604
605
0
  po::Options opts;
606
0
  if( m_easyMode )
607
0
  {
608
0
    opts.setLowerCaseOnly(); // easy app uses lower case option names only
609
0
  }
610
611
0
  opts.setSubSection("General Options");
612
0
  opts.addOptions()
613
0
  ("help,h",                                          do_help,                                             "show default help")
614
0
  ("fullhelp",                                        do_full_help,                                        "show full help")
615
0
  ("Verbosity,v",                                     toMsgLevel,                                          "verbosity level (0: silent, 1: error, 2: warning, 3: info, 4: notice, 5: verbose, 6: debug)")
616
0
  ("stats",                                           m_printStats,                                        "enable or disable printing of statistics (fps, bitrate, estimation of encoding time)")
617
0
  ("version",                                         m_showVersion,                                       "show version ")
618
0
  ;
619
620
0
  opts.setSubSection("Input Options");
621
0
  if( m_easyMode)
622
0
  {
623
0
    opts.addOptions()
624
0
    ("input,i",                                         m_inputFileName,                                     "original YUV input file name or '-' for reading from stdin")
625
0
    ("size,s",                                          toSourceSize,                                        "specify input resolution (WidthxHeight)")
626
0
    ("format,c",                                        toInputFormatBitdepth,                               "set input format (yuv420, yuv420_10, yuv420_10_packed, yuv400 (gray), yuv400_10 (gray10)")
627
0
    ("framerate,r",                                     c->m_FrameRate,                                      "temporal rate (framerate numerator) e.g. 25,30, 30000, 50,60, 60000 ")
628
0
    ("framescale",                                      c->m_FrameScale,                                     "temporal scale (framerate denominator) e.g. 1, 1001 ")
629
0
    ("fps",                                             toFps,                                               "framerate as int or fraction (num/denom) ")
630
631
0
    ("tickspersec",                                     c->m_TicksPerSecond,                                 "ticks per second for dts generation, (1..27000000, -1: ticks per frame=1)")
632
0
    ("frames,f",                                        c->m_framesToBeEncoded,                              "max. frames to encode [all]")
633
0
    ;
634
0
  }
635
0
  else
636
0
  {
637
0
    opts.addOptions()
638
0
    ("InputFile,i",                                     m_inputFileName,                                     "Original YUV input file name or '-' for reading from stdin")
639
0
    ("Size,s",                                          toSourceSize,                                        "Input resolution (WidthxHeight)")
640
0
    ("InputBitDepth",                                   c->m_inputBitDepth[ 0 ],                             "Bit-depth of input file")
641
0
    ("FramesToBeEncoded,f",                             c->m_framesToBeEncoded,                              "Number of frames to be encoded (default=all)")
642
0
    ("FrameRate,-fr",                                   c->m_FrameRate,                                      "Temporal rate (framerate numerator) e.g. 25,30, 30000, 50,60, 60000")
643
0
    ("FrameScale",                                      c->m_FrameScale,                                     "Temporal scale (framerate denominator) e.g. 1, 1001")
644
0
    ("fps",                                             toFps,                                               "Framerate as int or fraction (num/denom) ")
645
0
    ("TicksPerSecond",                                  c->m_TicksPerSecond,                                 "Ticks Per Second for dts generation, (1..27000000, -1: ticks per frame=1)")
646
0
    ("LeadFrames",                                      c->m_leadFrames,                                     "Number of leading frames to be read before starting the encoding, use when splitting the video into overlapping segments")
647
0
    ("TrailFrames",                                     c->m_trailFrames,                                    "Number of trailing frames to be read after frames to be encoded, use when splitting the video into overlapping segments")
648
0
    ;
649
0
  }
650
651
0
  opts.addOptions()
652
0
  ("FrameSkip,-fs",                                     m_FrameSkip,                                         "number of frames to skip at start of input YUV [off]")
653
0
  ;
654
655
0
  if( m_easyMode )
656
0
  {
657
0
    opts.setSubSection("Output Options");
658
0
    opts.addOptions()
659
0
    ("output,o",                                        m_bitstreamFileName,                                 "bitstream output file name")
660
0
    ;
661
0
  }
662
0
  else
663
0
  {
664
0
    opts.setSubSection("Output options");
665
0
    opts.addOptions()
666
0
    ("BitstreamFile,b",                                 m_bitstreamFileName,                                 "Bitstream output file name")
667
0
    ("ReconFile,o",                                     m_reconFileName,                                     "Reconstructed YUV output file name")
668
0
    ("OutputBitDepth",                                  c->m_outputBitDepth[ 0 ],                            "Bit-depth of output file")
669
0
    ;
670
0
  }
671
672
0
  if( m_easyMode )
673
0
  {
674
0
    opts.setSubSection("Encoder Options");
675
0
    opts.addOptions()
676
0
    ("preset",                                          toPreset,                                            "preset for detailed parameter configuration (faster, fast, medium, slow, slower, medium_lowDecEnergy)")
677
0
    ("bitrate,b",                                       toBitrate,                                           "bitrate for rate control (0: constant-QP encoding without rate control; otherwise\n"
678
0
                                                                                                             "bits/second; use e.g. 1.5M, 1.5Mbps, 1500k, 1500kbps, 1500000bps, 1500000)")
679
0
    ("maxrate,m",                                       toMaxRate,                                           "approximate maximum instantaneous bitrate for constrained VBR in rate control (0:\n"
680
0
                                                                                                             "no rate cap; use e.g. 3.5M, 3.5Mbps, 3500k, 3500kbps, 3500000bps, 3500000), use suffix 'x' "
681
0
                                                                                                             "to specify as a multiple of target bitrate")
682
0
    ("passes,p",                                        c->m_RCNumPasses,                                    "number of encoding passes with rate control (1: single-pass, -1, 2: two-pass RC)")
683
0
    ("pass",                                            c->m_RCPass,                                         "rate control pass for two-pass rate control (-1: both, 1: first, 2: second pass)")
684
0
    ("rcstatsfile",                                     m_RCStatsFileName,                                   "rate control statistics file name")
685
0
    ("qp,q",                                            c->m_QP,                                             "quantization parameter, QP (0, 1, .. 63)")
686
0
    ("qpa",                                             toQPA,                                               "enable perceptually motivated QP adaptation based on XPSNR model (0: off, 1: on)", true)
687
0
    ("threads,t",                                       c->m_numThreads,                                     "number of threads (multithreading; -1: resolution < 720p: 4, < 5K 2880p: 8, >= 5K 2880p: 12 threads)")
688
0
    ("mtprofile",                                       toMtProfile,                                         "set automatic multi-threading setting (-1: auto, 0: off, 1,2,3: on, enables tiles, IFP and WPP automatically depending on the number of threads)")
689
0
    ("refreshtype,-rt",                                 toDecRefreshType,                                    "intra refresh type (none, cra, idr, rpsei: Recovery Point SEI, cra_cre: CRA, constrained RASL picture encoding, idr_no_radl: IDR w/o leading pictures, use for DASH, implies POC0IDR)")
690
0
    ("refreshsec,-rs",                                  c->m_IntraPeriodSec,                                 "intra period/refresh in seconds")
691
0
    ("intraperiod,-ip",                                 c->m_IntraPeriod,                                    "intra period in frames (0: specify intra period in seconds instead, see -refreshsec)")
692
0
    ;
693
0
  }
694
0
  else
695
0
  {
696
0
    opts.setSubSection("Threading, performance");
697
0
    opts.addOptions()
698
0
    ("Threads,t",                                       c->m_numThreads,                                     "number of threads (multithreading; -1: resolution < 720p: 4, < 5K 2880p: 8, >= 5K 2880p: 12 threads)")
699
0
    ("MTProfile",                                       toMtProfile,                                         "set automatic multi-threading setting (-1: auto, 0: off, 1,2,3: on, enables tiles, IFP and WPP automatically depending on the number of threads)")
700
0
    ("preset",                                          toPreset,                                            "select preset for specific encoding setting (faster, fast, medium, slow, slower, medium_lowDecEnergy)")
701
0
    ("Tiles",                                           toNumTiles,                                          "Set number of tile columns and rows")
702
0
    ;
703
704
0
    opts.setSubSection("Slice decision options");
705
0
    opts.addOptions()
706
0
    ("IntraPeriod,-ip",                                c->m_IntraPeriod,                                     "Intra period in frames (0: use intra period in seconds (refreshsec), else: n*gopsize)")
707
0
    ("RefreshSec,-rs",                                 c->m_IntraPeriodSec,                                  "Intra period/refresh in seconds")
708
0
    ("DecodingRefreshType,-dr",                        toDecRefreshType,                                     "intra refresh type (none, cra, idr, rpsei: Recovery Point SEI, cra_cre: CRA, constrained RASL picture encoding, idr_no_radl: IDR w/o leading pictures, use for DASH, implies POC0IDR)")
709
0
    ("GOPSize,g",                                      c->m_GOPSize,                                         "GOP size of temporal structure (16,32)")
710
0
    ("PicReordering",                                  c->m_picReordering,                                   "Allow reordering of pictures (0:off, 1:on), should be disabled for low delay requirements")
711
0
    ("POC0IDR",                                        toPOC0IDR,                                            "encoding with first IRAP at POC 0 (0: off, 1: on, -1: default automatic setting (on for idr_no_radl, disabled picture reorderding and non-first segments; off otherwise))" )
712
0
    ;
713
714
0
    opts.setSubSection("Rate control, Perceptual Quantization");
715
0
    opts.addOptions()
716
0
    ("NumPasses",                                       c->m_RCNumPasses,                                    "number of rate control passes (1,2)" )
717
0
    ("Passes",                                          c->m_RCNumPasses,                                    "number of rate control passes (1,2)" )
718
0
    ("Pass",                                            c->m_RCPass,                                         "rate control pass for two-pass rate control (-1,1,2)" )
719
0
    ("LookAhead",                                       c->m_LookAhead,                                      "Enable pre-analysis pass with picture look-ahead (-1,0,1)")
720
0
    ("RCStatsFile",                                     m_RCStatsFileName,                                   "rate control statistics file" )
721
0
    ("TargetBitrate",                                   toBitrate,                                           "Rate control: target bitrate [bits/second], use e.g. 1.5M, 1.5Mbps, 1500k, 1500kbps, 1500000bps, 1500000" )
722
0
    ("MaxBitrate",                                      toMaxRate,                                           "Rate control: approximate maximum instantaneous bitrate [bits/second] (0: no rate cap; least constraint)" )
723
0
    ("PerceptQPA,-qpa",                                 c->m_usePerceptQPA,                                  "Enable perceptually motivated QP adaptation, XPSNR based (0:off, 1:on)", true)
724
0
    ("STA",                                             toSliceTypeAdapt,                                    "Enable slice type adaptation at GOPSize>8 (-1: auto, 0: off, 1: adapt slice type, 2: adapt NAL unit type)")
725
0
    ("MinIntraDistance",                                c->m_minIntraDist,                                   "With STA: set a minimum coded frame distance to the previous intra frame (-1: GOPSize)" )
726
0
    ;
727
728
0
    opts.setSubSection("Quantization parameters");
729
0
    opts.addOptions()
730
0
    ("QP,q",                                            c->m_QP,                                             "Qp value (0-63)")
731
0
    ;
732
0
  }
733
734
0
  opts.setSubSection("Profile, Level, Tier");
735
0
  opts.addOptions()
736
0
  ("Profile",                                           toProfile,                                           "profile (auto, main_10, main_10_still_picture)")
737
0
  ("Level",                                             toLevel,                                             "level limit (auto, 1.0, 2.0,2.1, 3.0,3.1, 4.0,4.1, 5.0,5.1,5.2, 6.0,6.1,6.2,6.3, 15.5)")
738
0
  ("Tier",                                              toLevelTier,                                         "tier for interpretation of level (main, high)")
739
0
  ;
740
741
0
  opts.setSubSection("HDR/SDR and Color Options");
742
0
  if( m_easyMode )
743
0
  {
744
0
    opts.addOptions()
745
0
    ("sdr",                                             toSDRMode,                                           "set SDR mode + BT.709, BT.2020, BT.470 color space. "
746
0
                                                                                                             "use: off, sdr|sdr_709, sdr_2020, sdr_470bg")
747
0
    ("hdr",                                             toHDRMode,                                           "set HDR mode + BT.709 or BT.2020 color space (+ SEI messages for hlg) "
748
0
                                                                                                             "use: off, pq|hdr10, pq_2020|hdr10_2020, hlg, hlg_2020")
749
0
    ("range",                                           toColourRangeMode,                                   "set colour range: unknown, limited | mpeg | tv, full | jpeg | pc")
750
0
    ;
751
0
  }
752
0
  else
753
0
  {
754
0
    opts.addOptions()
755
0
    ("Sdr",                                             toSDRMode,                                           "set SDR mode + BT.709, BT.2020, BT.470 color space. "
756
0
                                                                                                             "use: off, sdr|sdr_709, sdr_2020, sdr_470bg")
757
0
    ("Hdr",                                             toHDRMode,                                           "set HDR mode + BT.709 or BT.2020 color space (+SEI messages for hlg) "
758
0
                                                                                                             "If maxcll or masteringdisplay is set, HDR10/PQ is enabled. use: off, pq|hdr10, pq_2020|hdr10_2020, hlg, hlg_2020")
759
0
    ;
760
761
0
    opts.setSubSection("SEI and auxiliary options");
762
0
    opts.setSubSection("VUI options");
763
0
  }
764
765
766
0
  std::ostringstream easyOpts;
767
0
  po::doHelp( easyOpts, opts );
768
  // ---------------------------------------------------
769
770
0
  if( m_easyMode )
771
0
  {
772
0
    opts.setSubSection("Encoder Options");
773
0
    opts.addOptions()
774
0
    ("internal-bitdepth",                               c->m_internalBitDepth[0],                           "internal bitdepth (8, 10)")
775
0
    ("ifp",                                             toUseIfp,                                           "inter-frame parallelization(IFP) (-1: auto, 0: off, 1: on, with sync. offset of two CTU lines)")
776
0
    ("tiles",                                           toNumTiles,                                         "number of tile columns and rows")
777
0
    ("accessunitdelimiter,-aud",                        toAud,                                              "emit Access Unit Delimiter NALUs (-1: auto, 0: off, 1: on; default: auto - only if needed by dependent options)", true)
778
0
    ("vuiparameterspresent,-vui",                       toVui,                                              "emit VUI information (-1: auto, 0: off, 1: on; default: auto - only if needed by dependent options)", true)
779
0
    ("hrdparameterspresent,-hrd",                       c->m_hrdParametersPresent,                          "emit VUI HRD information (0: off, 1: on)")
780
0
    ("decodedpicturehash,-dph",                         toHashType,                                         "control generation of decode picture hash SEI messages, (0: off, 1: md5, 2: crc, 3: checksum)")
781
0
    ;
782
0
  }
783
784
  // ---------------------------------------------------
785
786
0
  opts.setSubSection("General Options");
787
0
  opts.addOptions()
788
0
  ("additional",                                        m_additionalSettings,                               "additional options as string (e.g: \"bitrate=1000000 passes=1\")")
789
0
  ;
790
791
0
  opts.setSubSection("Input Options");
792
0
  opts.addOptions()
793
0
  ("segment",                                           toSegment,                                         "when encoding multiple separate segments, specify segment position to enable segment concatenation (first, mid, last) [off]\n"
794
0
                                                                                                           " first: first segment           \n"
795
0
                                                                                                           " mid  : all segments between first and last segment\n"
796
0
                                                                                                           " last : last segment")
797
0
  ("y4m",                                               m_forceY4mInput,                                   "force y4m input (only needed for input pipe, else enabled by .y4m file extension)")
798
0
  ("logofile",                                          m_logoFileName,                                    "set logo overlay filename (json)")
799
0
  ;
800
801
0
  if( !m_easyMode )
802
0
  {
803
0
    opts.setSubSection("General Options");
804
0
    opts.addOptions()
805
0
    ("c",                                               po::parseConfigFile,                                "configuration file name")
806
0
    ("WriteConfig",                                     writeCfg,                                           "write the encoder config into configuration file")
807
0
    ("WarnUnknowParameter,w",                           warnUnknowParameter,                                "warn for unknown configuration parameters instead of failing")
808
0
#if defined( __x86_64__ ) || defined( _M_X64 ) || defined( __i386__ ) || defined( __i386 ) || defined( _M_IX86 )
809
0
    ("SIMD",                                            ignoreParams,                                       "SIMD extension to use (SCALAR, SSE41, SSE42, AVX, AVX2, AVX512), default: the highest supported extension")
810
#elif defined( __aarch64__ ) || defined( _M_ARM64 ) || defined( __arm__ ) || defined( _M_ARM )
811
    ("SIMD",                                            ignoreParams,                                       "SIMD extension to use (SCALAR, NEON), default: the highest supported extension")
812
#elif defined( __wasm__ ) || defined( __wasm32__ )
813
    ("SIMD",                                            ignoreParams,                                       "SIMD extension to use (SCALAR, WASM), default: the highest supported extension")
814
#elif defined( __loongarch__ )
815
    ("SIMD",                                            ignoreParams,                                       "SIMD extension to use (SCALAR, LSX), default: the highest supported extension")
816
#else
817
    ("SIMD",                                            ignoreParams,                                       "SIMD extension to use (SCALAR, SIMDE), default: the highest supported extension")
818
#  endif
819
0
    ;
820
821
0
    opts.setSubSection("Input Options");
822
0
    opts.addOptions()
823
0
    ("SourceWidth",                                     c->m_SourceWidth,                                    "Source picture width")
824
0
    ("SourceHeight",                                    c->m_SourceHeight,                                   "Source picture height")
825
0
    ("ConformanceWindowMode",                           c->m_conformanceWindowMode,                          "Window conformance mode (0:off, 1:automatic padding, 2:padding, 3:conformance")
826
0
    ("ConfWinLeft",                                     c->m_confWinLeft,                                    "Left offset for window conformance mode 3")
827
0
    ("ConfWinRight",                                    c->m_confWinRight,                                   "Right offset for window conformance mode 3")
828
0
    ("ConfWinTop",                                      c->m_confWinTop,                                     "Top offset for window conformance mode 3")
829
0
    ("ConfWinBottom",                                   c->m_confWinBottom,                                  "Bottom offset for window conformance mode 3")
830
0
    ("HorizontalPadding",                               c->m_aiPad[0],                                       "Horizontal source padding for conformance window mode 2")
831
0
    ("VerticalPadding",                                 c->m_aiPad[1],                                       "Vertical source padding for conformance window mode 2")
832
0
    ("InputChromaFormat",                               toInputFileChromaFormat,                             "input file chroma format (400, 420, 422, 444)")
833
0
    ("PackedInput",                                     m_packedYUVInput,                                    "Enable 10-bit packed YUV input data ( pack 4 samples( 8-byte) into 5-bytes consecutively.")
834
835
0
    ("MaxPicSize",                                      toMaxPicSize,                                        "Maximum resolution (maxWidth x maxHeight)")
836
0
    ("MaxPicWidth",                                     c->m_maxPicWidth,                                    "Maximum picture width")
837
0
    ("MaxPicHeight",                                    c->m_maxPicHeight,                                   "Maximum picture height")
838
0
    ;
839
840
0
    opts.setSubSection("Profile, Level, Tier");
841
0
    opts.addOptions()
842
0
    ("SubProfile",                                      c->m_subProfile,                                     "Sub-profile idc")
843
0
    ("MaxBitDepthConstraint",                           c->m_bitDepthConstraintValue,                        "Bit depth to use for profile-constraint for RExt profiles. (0: automatically choose based upon other parameters)")
844
0
    ("IntraConstraintFlag",                             c->m_intraOnlyConstraintFlag,                        "Value of general_intra_constraint_flag to use for RExt profiles (not used if an explicit RExt sub-profile is specified)")
845
0
    ;
846
0
    ;
847
848
0
    opts.setSubSection("Quality reporting metrics");
849
0
    opts.addOptions()
850
0
    ("MSEBasedSequencePSNR",                            c->m_printMSEBasedSequencePSNR,                      "Emit sequence PSNR (0: only as a linear average of the frame PSNRs, 1: also based on an average of the frame MSEs")
851
0
    ("PrintHexPSNR",                                    c->m_printHexPsnr,                                   "Emit hexadecimal PSNR for each frame (0: off , 1:on")
852
0
    ("PrintFrameMSE",                                   c->m_printFrameMSE,                                  "Emit MSE values for each frame (0: off , 1:on")
853
0
    ("PrintSequenceMSE",                                c->m_printSequenceMSE,                               "Emit MSE values for the whole sequence (0: off , 1:on)")
854
0
    ;
855
856
0
    opts.setSubSection("Bitstream options");
857
0
    opts.addOptions()
858
0
    ("CabacZeroWordPaddingEnabled",                     c->m_cabacZeroWordPaddingEnabled,                    "Add conforming cabac-zero-words to bit streams (0: do not add, 1: add as required)")
859
0
    ;
860
861
0
    opts.setSubSection("Rate control, Perceptual Quantization");
862
0
    opts.addOptions()
863
0
    ("RCInitialQP",                                     c->m_RCInitialQP,                                    "Rate control: initial QP. With two-pass encoding, this specifies the first-pass base QP (instead of using a default QP). Activated if value is greater than zero" )
864
0
    ("PerceptQPATempFiltIPic",                          c->m_usePerceptQPATempFiltISlice,                    "Temporal high-pass filter in QPA activity calculation for key pictures (0:off, 1:on, 2:on incl. temporal pumping reduction, 3:mode 1 without force 2nd order filter in key frames, 4:mode 2 without force 2nd order filter in key frames, -1:auto, -2:auto without force 2nd order filter in key frames)")
865
0
    ;
866
867
    // Coding structure parameters
868
0
    opts.setSubSection("Coding structure parameters");
869
0
    opts.addOptions()
870
0
    ("ReWriteParamSets",                                c->m_rewriteParamSets,                               "Enable rewriting of Parameter sets before every (intra) random access point")
871
0
    ("IDRRefParamList",                                 c->m_idrRefParamList,                                "Enable indication of reference picture list syntax elements in slice headers of IDR pictures")
872
0
    ;
873
874
    /* Quantization parameters */
875
0
    opts.setSubSection("Quantization parameters");
876
0
    opts.addOptions()
877
0
    ("SameCQPTablesForAllChroma",                       c->m_useSameChromaQPTables,                          "0: Different tables for Cb, Cr and joint Cb-Cr components, 1 (default): Same tables for all three chroma components")
878
0
    ("IntraQPOffset",                                   c->m_intraQPOffset,                                  "Qp offset value for intra slice, typically determined based on GOP size")
879
0
    ("LambdaFromQpEnable",                              c->m_lambdaFromQPEnable,                             "Enable flag for derivation of lambda from QP")
880
0
    ("LambdaModifier",                                  toLambdaModifier,                                    "Lambda modifier list for temporal layers. If LambdaModifierI is used, this will not affect intra pictures")
881
0
    ("LambdaModifierI",                                 toIntraLambdaModifier,                               "Lambda modifiers for Intra pictures, comma separated, up to one the number of temporal layer. If entry for temporalLayer exists, then use it, else if some are specified, use the last, else use the standard LambdaModifiers.")
882
0
    ("IQPFactor",                                       c->m_dIntraQpFactor,                                 "Intra QP Factor for Lambda Computation. If negative, the default will scale lambda based on GOP size (unless LambdaFromQpEnable then IntraQPOffset is used instead)")
883
0
    ("QpInValCb",                                       toQpInCb,                                            "Input coordinates for the QP table for Cb component")
884
0
    ("QpInValCr",                                       toQpInCr,                                            "Input coordinates for the QP table for Cr component")
885
0
    ("QpInValCbCr",                                     toQpInCbCr,                                          "Input coordinates for the QP table for joint Cb-Cr component")
886
0
    ("QpOutValCb",                                      toQpOutCb,                                           "Output coordinates for the QP table for Cb component")
887
0
    ("QpOutValCr",                                      toQpOutCr,                                           "Output coordinates for the QP table for Cr component")
888
0
    ("QpOutValCbCr",                                    toQpOutCbCr,                                         "Output coordinates for the QP table for joint Cb-Cr component")
889
0
    ("MaxCuDQPSubdiv",                                  c->m_cuQpDeltaSubdiv,                                "Maximum subdiv for CU luma Qp adjustment")
890
0
    ("MaxCuChromaQpOffsetSubdiv",                       c->m_cuChromaQpOffsetSubdiv,                         "Maximum subdiv for CU chroma Qp adjustment - set less than 0 to disable")
891
0
    ("CbQpOffset",                                      c->m_chromaCbQpOffset,                               "Chroma Cb QP Offset")
892
0
    ("CrQpOffset",                                      c->m_chromaCrQpOffset,                               "Chroma Cr QP Offset")
893
0
    ("CbQpOffsetDualTree",                              c->m_chromaCbQpOffsetDualTree,                       "Chroma Cb QP Offset for dual tree")
894
0
    ("CrQpOffsetDualTree",                              c->m_chromaCrQpOffsetDualTree,                       "Chroma Cr QP Offset for dual tree")
895
0
    ("CbCrQpOffset",                                    c->m_chromaCbCrQpOffset,                             "QP Offset for joint Cb-Cr mode")
896
0
    ("CbCrQpOffsetDualTree",                            c->m_chromaCbCrQpOffsetDualTree,                     "QP Offset for joint Cb-Cr mode in dual tree")
897
0
    ("SliceChromaQPOffsetPeriodicity",                  c->m_sliceChromaQpOffsetPeriodicity,                 "Used in conjunction with Slice Cb/Cr QpOffsetIntraOrPeriodic. Use 0 (default) to disable periodic nature.")
898
0
    ("SliceCbQpOffsetIntraOrPeriodic",                  c->m_sliceChromaQpOffsetIntraOrPeriodic[0],          "Chroma Cb QP Offset at slice level for I slice or for periodic inter slices as defined by SliceChromaQPOffsetPeriodicity. Replaces offset in the GOP table.")
899
0
    ("SliceCrQpOffsetIntraOrPeriodic",                  c->m_sliceChromaQpOffsetIntraOrPeriodic[1],          "Chroma Cr QP Offset at slice level for I slice or for periodic inter slices as defined by SliceChromaQPOffsetPeriodicity. Replaces offset in the GOP table.")
900
901
0
    ("LumaLevelToDeltaQPMode",                          c->m_lumaLevelToDeltaQPEnabled,                      "Luma based Delta QP 0(default): not used. 1: Based on CTU average")
902
0
    ("GOPQPA",                                          toGOPQPA,                                            "Enable GOP QP-cascade (0: off, 1: on, -1: auto - enable when QPA is disabled)")
903
0
    ; 
904
905
0
    opts.setSubSection("Misc. options");
906
0
    opts.addOptions()
907
0
    ("ChromaFormatIDC,-cf",                             toInternChromaFormat,                                "intern chroma format (400, 420, 422, 444) or set to 0 (default), same as InputChromaFormat")
908
0
    ("UseIdentityTableForNon420Chroma",                 c->m_useIdentityTableForNon420Chroma,                "True: Indicates that 422/444 chroma uses identity chroma QP mapping tables; False: explicit Qp table may be specified in config")
909
0
    ("InputBitDepthC",                                  c->m_inputBitDepth[ 1 ],                             "As per InputBitDepth but for chroma component. (default:InputBitDepth)")
910
0
    ("InternalBitDepth",                                c->m_internalBitDepth[ 0 ],                          "Bit-depth the codec operates at. (default: MSBExtendedBitDepth). If different to MSBExtendedBitDepth, source data will be converted")
911
0
    ("OutputBitDepthC",                                 c->m_outputBitDepth[ 1 ],                            "As per OutputBitDepth but for chroma component. (default: use luma output bit-depth)")
912
0
    ("MSBExtendedBitDepth",                             c->m_MSBExtendedBitDepth[ 0 ],                       "bit depth of luma component after addition of MSBs of value 0 (used for synthesising High Dynamic Range source material). (default:InputBitDepth)")
913
0
    ("MSBExtendedBitDepthC",                            c->m_MSBExtendedBitDepth[ 1 ],                       "As per MSBExtendedBitDepth but for chroma component. (default:MSBExtendedBitDepth)")
914
915
0
    ("WaveFrontSynchro",                                toUseWpp,                                            "Enable entropy coding sync (WPP) (-1: auto, 0: off, 1: on)")
916
0
    ("EntryPointsPresent",                              c->m_entryPointsPresent,                             "Enable entry points in slice header")
917
918
0
    ("TreatAsSubPic",                                   c->m_treatAsSubPic,                                  "Allow generation of subpicture streams. Disable LMCS, AlfTempPred and JCCR")
919
0
    ("ExplicitAPSid",                                   c->m_explicitAPSid,                                  "Set ALF APS id")
920
    
921
0
    ("AddGOP32refPics",                                 c->m_addGOP32refPics,                                "Use different QP offsets and reference pictures in GOP structure")
922
0
    ("NumRefPics",                                      c->m_numRefPics,                                     "Number of reference pictures in RPL (0: default for RPL, <10: apply for all temporal layers, >=10: each decimal digit specifies the number for a temporal layer, last digit applying to the highest TL)" )
923
0
    ("NumRefPicsSCC",                                   c->m_numRefPicsSCC,                                  "Number of reference pictures in RPL for SCC pictures (semantic analogue to NumRefPics, -1: equal to NumRefPics)" )
924
0
    ("ForceSCC",                                        toForceScc,                                          "Force SCC treatment, instead of detection (<=0: use detection, 1: treat all frames as not SCC, 2: treat all frames as weak SCC, 3: treat all frames as strong SCC)" )
925
0
    ;
926
927
0
    opts.setSubSection("Low-level QT-BTT partitioning options");
928
0
    opts.addOptions()
929
0
    ("CTUSize",                                         c->m_CTUSize,                                        "CTU size")
930
0
    ("MinQTISlice",                                     c->m_MinQT[0],                                       "Min QT size for (luma in) I slices")
931
0
    ("MinQTLumaISlice",                                 c->m_MinQT[0],                                       "Min QT size for (luma in) I slices")
932
0
    ("MinQTNonISlice",                                  c->m_MinQT[1],                                       "Min QT size for P/B slices")
933
0
    ("MinQTChromaISliceInChromaSamples",                c->m_MinQT[2],                                       "Min QT size for chroma in I slices (in chroma samples, i.e. inclusive subsampling)")
934
0
    ("MaxMTTDepth",                                     c->m_maxMTTDepth,                                    "Max MTT depth for P/B slices (<10: apply for all temporal layers, >=10: each decimal digit specifies the depth for a temporal layer, last digit applying to the highest TL)")
935
0
    ("MaxMTTDepthI",                                    c->m_maxMTTDepthI,                                   "Max MTT depth for (luma in) I slices")
936
0
    ("MaxMTTDepthISliceL",                              c->m_maxMTTDepthI,                                   "Max MTT depth for (luma in) I slices")
937
0
    ("MaxMTTDepthISliceC",                              c->m_maxMTTDepthIChroma,                             "Max MTT depth for chroma in I slices")
938
0
    ("MaxBTLumaISlice",                                 c->m_maxBT[0],                                       "Max BT size for (luma in) I slices")
939
0
    ("MaxBTChromaISlice",                               c->m_maxBT[2],                                       "Max BT size for chroma in I slices")
940
0
    ("MaxBTNonISlice",                                  c->m_maxBT[1],                                       "Max BT size for P/B slices")
941
0
    ("MaxTTLumaISlice",                                 c->m_maxTT[0],                                       "Max TT size for (luma in) I slices")
942
0
    ("MaxTTChromaISlice",                               c->m_maxTT[2],                                       "Max TT size for chroma in I slices")
943
0
    ("MaxTTNonISlice",                                  c->m_maxTT[1],                                       "Max TT size for P/B slices")
944
0
    ("DualITree",                                       c->m_dualITree,                                      "Use separate luma and chroma QTBTT trees for intra slice (if off, luma constraint apply to all channels)")
945
0
    ("Log2MaxTbSize",                                   c->m_log2MaxTbSize,                                  "Maximum transform block size in logarithm base 2")
946
0
    ("Log2MinCodingBlockSize",                          c->m_log2MinCodingBlockSize,                         "Minimum coding block size in logarithm base 2")
947
0
    ;
948
949
0
    opts.setSubSection("Coding tools");
950
0
    opts.addOptions()
951
0
    ("CostMode",                                        toCostMode,                                          "Use alternative cost functions: choose between 'lossy', 'sequence_level_lossless', 'lossless' (which forces QP to " MACRO_TO_STRING(LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP) ") and 'mixed_lossless_lossy' (which used QP'=" MACRO_TO_STRING(LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME) " for pre-estimates of transquant-bypass blocks).")
952
0
    ("ASR",                                             c->m_bUseASR,                                        "Adaptive motion search range")
953
0
    ("HadamardME",                                      c->m_bUseHADME,                                      "Hadamard ME for fractional-pel")
954
0
    ("FastHAD",                                         c->m_fastHad,                                        "Use fast sub-sampled hadamard for square blocks >=32x32")
955
0
    ("RDOQ",                                            c->m_RDOQ,                                           "Rate-Distortion Optimized Quantization mode")
956
0
    ("RDOQTS",                                          c->m_useRDOQTS,                                      "Rate-Distortion Optimized Quantization mode for TransformSkip")
957
0
    ("SelectiveRDOQ",                                   toSelectiveRDOQ,                                     "Enable selective RDOQ (0: never, 1: always, 2: for natural content)")
958
959
0
    ("JointCbCr",                                       c->m_JointCbCrMode,                                  "Enable joint coding of chroma residuals (0:off, 1:on)")
960
0
    ("CabacInitPresent",                                c->m_cabacInitPresent,                               "Enable cabac table index selection based on previous frame")
961
0
    ("LCTUFast",                                        c->m_useFastLCTU,                                    "Fast methods for large CTU")
962
0
    ("PBIntraFast",                                     c->m_usePbIntraFast,                                 "Intra mode pre-check dependent on best Inter mode, skip intra if it is not probable (0:off ... 2:fastest)")
963
0
    ("FastMrg",                                         c->m_useFastMrg,                                     "Fast methods for inter merge")
964
0
    ("AMaxBT",                                          c->m_useAMaxBT,                                      "Adaptive maximal BT-size")
965
0
    ("FastQtBtEnc",                                     c->m_fastQtBtEnc,                                    "Fast encoding setting for QTBT")
966
0
    ("ContentBasedFastQtbt",                            c->m_contentBasedFastQtbt,                           "Signal based QTBT speed-up")
967
0
    ("FEN",                                             c->m_fastInterSearchMode,                            "fast encoder setting")
968
0
    ("ECU",                                             c->m_useEarlyCU,                                     "Early CU setting (1: ECU limited to specific block size and TL, 2: unconstrained ECU)")
969
0
    ("FDM",                                             c->m_useFastDecisionForMerge,                        "Fast decision for Merge RD Cost")
970
971
0
    ("DisableIntraInInter",                             c->m_bDisableIntraCUsInInterSlices,                  "Flag to disable intra CUs in inter slices")
972
0
    ("FastUDIUseMPMEnabled",                            c->m_bFastUDIUseMPMEnabled,                          "If enabled, adapt intra direction search, accounting for MPM")
973
0
    ("FastMEForGenBLowDelayEnabled",                    c->m_bFastMEForGenBLowDelayEnabled,                  "If enabled use a fast ME for generalised B Low Delay slices")
974
975
0
    ("MTSImplicit",                                     c->m_MTSImplicit,                                    "Enable implicit MTS when explicit MTS is off\n")
976
0
    ("TMVPMode",                                        c->m_TMVPModeId,                                     "TMVP mode enable(0: off 1: for all slices 2: for certain slices only)")
977
0
    ("DepQuant",                                        c->m_DepQuantEnabled,                                "Enable dependent quantization" )
978
0
    ("QuantThrVal",                                     c->m_quantThresholdVal,                              "Quantization threshold value for DQ last coefficient search" )
979
0
    ("SignHideFlag",                                    c->m_SignDataHidingEnabled,                          "Enable sign data hiding" )
980
0
    ("MIP",                                             c->m_MIP,                                            "Enable MIP (matrix-based intra prediction)")
981
0
    ("FastMIP",                                         c->m_useFastMIP,                                     "Fast encoder search for MIP (matrix-based intra prediction)")
982
0
    ("MaxNumMergeCand",                                 c->m_maxNumMergeCand,                                "Maximum number of merge candidates")
983
0
    ("MaxNumAffineMergeCand",                           c->m_maxNumAffineMergeCand,                          "Maximum number of affine merge candidates")
984
0
    ("Geo",                                             c->m_Geo,                                            "Enable geometric partitioning mode (0:off, 1:on)")
985
0
    ("MaxNumGeoCand",                                   c->m_maxNumGeoCand,                                  "Maximum number of geometric partitioning mode candidates")
986
0
    ("FastIntraTools",                                  c->m_FastIntraTools,                                 "SpeedUPIntraTools:LFNST,ISP,MTS. (0:off, 1:speed1, 2:speed2)")
987
0
    ("IntraEstDecBit",                                  c->m_IntraEstDecBit,                                 "Intra estimation decimation binary exponent for first pass directional modes screening (only test each (2^N)-th mode in the first estimation pass)")
988
0
    ;
989
990
    // motion search options
991
0
    opts.setSubSection("Motion search options");
992
0
    opts.addOptions()
993
0
    ("FastSearch",                                      c->m_motionEstimationSearchMethod,                   "Search mode (0:Full search 1:Diamond 2:Deprecated 3:Enhanced Diamond 4: FastDiamond)")
994
0
    ("FastSearchSCC",                                   c->m_motionEstimationSearchMethodSCC,                "Search mode for SCC (0:use non SCC-search 1:Deprecated 2:DiamondSCC 3:FastDiamondSCC)")
995
0
    ("SearchRange,-sr",                                 c->m_SearchRange,                                    "Motion search range")
996
0
    ("BipredSearchRange",                               c->m_bipredSearchRange,                              "Motion search range for bipred refinement")
997
0
    ("MinSearchWindow",                                 c->m_minSearchWindow,                                "Minimum motion search window size for the adaptive window ME")
998
0
    ("ClipForBiPredMEEnabled",                          c->m_bClipForBiPredMeEnabled,                        "Enable clipping in the Bi-Pred ME.")
999
0
    ("FastMEAssumingSmootherMVEnabled",                 c->m_bFastMEAssumingSmootherMVEnabled,               "Enable fast ME assuming a smoother MV.")
1000
0
    ("IntegerET",                                       c->m_bIntegerET,                                     "Enable early termination for integer motion search")
1001
0
    ("FastSubPel",                                      c->m_fastSubPel,                                     "Enable fast sub-pel ME (1: enable fast sub-pel ME, 2: completely disable sub-pel ME)")
1002
0
    ("ReduceFilterME",                                  c->m_meReduceTap,                                    "Use reduced filter taps during subpel refinement (0 - use 8-tap; 1 - 6-tap; 2 - 4-tap)")
1003
0
    ;
1004
1005
    // Deblocking filter parameters
1006
0
    opts.setSubSection("Loop filters (deblock and SAO)");
1007
0
    opts.addOptions()
1008
0
    ("LoopFilterDisable",                               c->m_bLoopFilterDisable,                             "")
1009
0
    ("LoopFilterOffsetInPPS",                           c->m_loopFilterOffsetInPPS,                          "")
1010
0
    ("LoopFilterBetaOffset_div2",                       c->m_loopFilterBetaOffsetDiv2[0],                    "")
1011
0
    ("LoopFilterTcOffset_div2",                         c->m_loopFilterTcOffsetDiv2[0],                      "")
1012
0
    ("LoopFilterCbBetaOffset_div2",                     c->m_loopFilterBetaOffsetDiv2[1],                    "")
1013
0
    ("LoopFilterCbTcOffset_div2",                       c->m_loopFilterTcOffsetDiv2[1],                      "")
1014
0
    ("LoopFilterCrBetaOffset_div2",                     c->m_loopFilterBetaOffsetDiv2[2],                    "")
1015
0
    ("LoopFilterCrTcOffset_div2",                       c->m_loopFilterTcOffsetDiv2[2],                      "")
1016
1017
0
    ("DeblockLastTLayers",                              c->m_deblockLastTLayers,                             "Deblock only the highest n temporal layers, 0: all temporal layers are deblocked")
1018
1019
0
    ("DisableLoopFilterAcrossTiles",                    c->m_bDisableLFCrossTileBoundaryFlag,                "Loop filtering applied across tile boundaries or not (0: filter across tile boundaries  1: do not filter across tile boundaries)")
1020
0
    ("DisableLoopFilterAcrossSlices",                   c->m_bDisableLFCrossSliceBoundaryFlag,               "Loop filtering applied across tile boundaries or not (0: filter across slice boundaries  1: do not filter across slice boundaries)")
1021
1022
0
    ("SAO",                                             toSaoWithScc,                                        "Enable Sample Adaptive Offset (1: always, 2: only for screen content frames)")
1023
0
    ("SaoEncodingRate",                                 c->m_saoEncodingRate,                                "When >0 SAO early picture termination is enabled for luma and chroma")
1024
0
    ("SaoEncodingRateChroma",                           c->m_saoEncodingRateChroma,                          "The SAO early picture termination rate to use for chroma (when m_SaoEncodingRate is >0). If <=0, use results for luma")
1025
0
    ("SaoLumaOffsetBitShift",                           c->m_saoOffsetBitShift[ 0 ],                         "Specify the luma SAO bit-shift. If negative, automatically calculate a suitable value based upon bit depth and initial QP")
1026
0
    ("SaoChromaOffsetBitShift",                         c->m_saoOffsetBitShift[ 1 ],                         "Specify the chroma SAO bit-shift. If negative, automatically calculate a suitable value based upon bit depth and initial QP")
1027
0
    ;
1028
1029
0
    opts.setSubSection("SEI and auxiliary options");
1030
0
    opts.addOptions()
1031
0
    ("SEIDecodedPictureHash,-dph",                      toHashType,                                          "Control generation of decode picture hash SEI messages, (0:off, 1:md5, 2:crc, 3:checksum)" )
1032
0
    ("SEIBufferingPeriod",                              c->m_bufferingPeriodSEIEnabled,                      "Control generation of buffering period SEI messages")
1033
0
    ("SEIPictureTiming",                                c->m_pictureTimingSEIEnabled,                        "Control generation of picture timing SEI messages")
1034
0
    ("SEIDecodingUnitInfo",                             c->m_decodingUnitInfoSEIEnabled,                     "Control generation of decoding unit information SEI message.")
1035
0
    ("MasteringDisplayColourVolume",                    toMasteringDisplay,                                  "SMPTE ST 2086 mastering display colour volume info SEI (HDR), "
1036
0
                                                                                                             "vec(uint) size 10, x,y,x,y,x,y,x,y,max,min where: \"G(x,y)B(x,y)R(x,y)WP(x,y)L(max,min)\""
1037
0
                                                                                                             "range: 0 <= GBR,WP <= 50000, 0 <= L <= uint; GBR xy coordinates in increment of 1/50000, min/max luminance in units of 1/10000 cd/m2 "
1038
0
                                                                                                             "e.g. for P3D65 1000-nits, where G(x=0.265, y=0.690), B(x=0.150, y=0.060), R(x=0.680, y=0.320), WP(x=0.3127, y=0.3290), L(max=1000, min=0.0001): 13250,34500,7500,3000,34000,16000,15635,16450,10000000,1" )
1039
0
    ("MaxContentLightLevel",                            toContentLightLevel,                                 "Specify content light level info SEI as \"cll,fall\" (HDR) max. content light level, "
1040
0
                                                                                                             "max. frame average light level, range: 1 <= cll,fall <= 65535', e.g. 1000,400")
1041
0
    ("PreferredTransferCharacteristics",                toPrefTransferCharacteristics,                       "Specify preferred transfer characteristics SEI and overwrite transfer entry in VUI (0-18): reserved, bt709, unknown, empty, bt470m, bt470bg, smpte170m, "
1042
0
                                                                                                             "smpte240m, linear, log100, log316, iec61966-2-4, bt1361e, iec61966-2-1, "
1043
0
                                                                                                             "bt2020-10, bt2020-12, smpte2084, smpte428, arib-std-b67")
1044
0
    ("AccessUnitDelimiter,-aud",                        toAud,                                               "Enable Access Unit Delimiter NALUs (-1: auto, 0: off, 1: on; default: auto - enable only if needed by dependent options)" , true)
1045
0
    ("HrdParametersPresent,-hrd",                       c->m_hrdParametersPresent,                           "Enable generation of hrd_parameters() (0: off, 1: on)")
1046
0
    ("EnableDecodingParameterSet",                      c->m_decodingParameterSetEnabled,                    "Enable writing of Decoding Parameter Set")
1047
0
    ;
1048
      
1049
0
    opts.setSubSection("VUI options");
1050
0
    opts.addOptions()
1051
0
    ("VuiParametersPresent,-vui",                       toVui,                                               "Enable generation of vui_parameters() (-1: auto, 0: off, 1: on; default: auto - enable only if needed by dependent options)", true)
1052
0
    ("AspectRatioInfoPresent",                          c->m_aspectRatioInfoPresent,                         "Signals whether aspect_ratio_idc is present")
1053
0
    ("AspectRatioIdc",                                  c->m_aspectRatioIdc,                                 "Aspect ratio idc (0-16,255) 0=undef, 1=1:1, 2=12:11, 3=10:11, 4=16:11, 5=40:33, 6=24:11, 7=20:11, 8=32:11, 9=80:33, 10=18:11, 11=15:11, 12=64:33, "
1054
0
                                                                                                             "13=160:99, 14=4:3, 15=3:2, 16=2:1")
1055
0
    ("Sar",                                             toSarSize,                                           "Sample aspect ratio - ratio of width to height (WidthxHeight)")
1056
0
    ("SarWidth",                                        c->m_sarWidth,                                       "horizontal size of the sample aspect ratio")
1057
0
    ("SarHeight",                                       c->m_sarHeight,                                      "vertical size of the sample aspect ratio")
1058
1059
0
    ("ColourDescriptionPresent",                        c->m_colourDescriptionPresent,                       "Signals whether colour_primaries, transfer_characteristics, matrix_coefficients, full_range_flag are present")
1060
0
    ("ColourPrimaries",                                 toColourPrimaries,                                   "Specify colour primaries (0-13): reserved, bt709, unknown, empty, bt470m, bt470bg, smpte170m, "
1061
0
                                                                                                             "smpte240m, film, bt2020, smpte428, smpte431, smpte432")
1062
1063
0
    ("TransferCharacteristics",                         toTransferCharacteristics,                           "Specify opto-electronic transfer characteristics (0-18): reserved, bt709, unknown, empty, bt470m, bt470bg, smpte170m, "
1064
0
                                                                                                             "smpte240m, linear, log100, log316, iec61966-2-4, bt1361e, iec61966-2-1, "
1065
0
                                                                                                             "bt2020-10, bt2020-12, smpte2084, smpte428, arib-std-b67")
1066
0
    ("MatrixCoefficients",                              toColourMatrix,                                      "Specify colour matrix setting to derive luma/chroma from RGB primaries (0-14): gbr, bt709, unknown, empty, fcc, bt470bg, smpte170m, "
1067
0
                                                                                                             "smpte240m, ycgco, bt2020nc, bt2020c, smpte2085, chroma-derived-nc, chroma-derived-c, ictcp")
1068
1069
0
    ("ChromaLocInfoPresent",                            toChromaLocInfo,                                     "Signals whether chroma_sample_loc_type is present (-1: auto, 0: off, 1: on)")
1070
0
    ("ChromaSampleLocType",                             c->m_chromaSampleLocType,                            "Specifies the location of chroma samples for progressive content(-1 auto, 0-5 Chroma420LocType)")
1071
0
    ("OverscanInfoPresent",                             c->m_overscanInfoPresent,                            "Indicates whether conformant decoded pictures are suitable for display using overscan")
1072
0
    ("OverscanAppropriate",                             c->m_overscanAppropriateFlag,                        "Indicates whether conformant decoded pictures are suitable for display using overscan")
1073
0
    ("VideoFullRange",                                  toColourRangeMode,                                   "Indicates the black level and range of luma and chroma signals")
1074
0
    ("Range",                                           toColourRangeMode,                                   "set colour range: unknown, limited | mpeg | tv, full | jpeg | pc")
1075
0
    ;
1076
1077
0
    opts.setSubSection("Summary options (debugging)");
1078
0
    opts.addOptions()
1079
0
    ("SummaryOutFilename",                              toSummaryOutFilename,                                "Filename to use for producing summary output file. If empty, do not produce a file.")
1080
0
    ("SummaryPicFilenameBase",                          toSummaryPicFilenameBase,                            "Base filename to use for producing summary picture output files. The actual filenames used will have I.txt, P.txt and B.txt appended. If empty, do not produce a file.")
1081
0
    ("SummaryVerboseness",                              c->m_summaryVerboseness,                             "Specifies the level of the verboseness of the text output")
1082
0
    ;
1083
1084
0
    opts.setSubSection("Coding tools");
1085
0
    opts.addOptions()
1086
0
    ("SMVD",                                            c->m_SMVD,                                           "Enable Symmetric MVD (0:off 1:vtm 2:fast 3:faster\n")
1087
0
    ("AMVR",                                            c->m_AMVRspeed,                                      "Enable Adaptive MV precision Mode (IMV)")
1088
    // added for backward compatibility with VTM
1089
0
    ("IMV",                                             c->m_AMVRspeed,                                      "Enable Adaptive MV precision Mode (IMV)")
1090
0
    ("LMChroma",                                        c->m_LMChroma,                                       "Enable LMChroma prediction")
1091
0
    ("MRL",                                             c->m_MRL,                                            "MultiRefernceLines")
1092
0
    ("BDOF",                                            c->m_BDOF,                                           "Enable bi-directional optical flow")
1093
    // added for backward compatibility with VTM
1094
0
    ("BIO",                                             c->m_BDOF,                                           "Enable bi-directional optical flow")
1095
0
    ("DMVR",                                            c->m_DMVR,                                           "Decoder-side Motion Vector Refinement")
1096
0
    ("EncDbOpt",                                        c->m_EDO,                                            "Encoder optimization with deblocking filter 0:off 1:vtm 2:fast")
1097
0
    ("EDO",                                             c->m_EDO,                                            "Encoder optimization with deblocking filter 0:off 1:vtm 2:fast")
1098
0
    ("LMCSEnable",                                      c->m_lumaReshapeEnable,                              "LMCS is deprecated and will be removed")
1099
0
    ("LMCS",                                            c->m_lumaReshapeEnable,                              "LMCS is deprecated and will be removed")
1100
0
    ("LMCSSignalType",                                  c->m_reshapeSignalType,                              "Input signal type (0:SDR, 1:HDR-PQ, 2:HDR-HLG)")
1101
0
    ("LMCSUpdateCtrl",                                  c->m_updateCtrl,                                     "LMCS model update control (0:RA, 1:AI, 2:LDB/LDP)")
1102
0
    ("LMCSAdpOption",                                   c->m_adpOption,                                      "LMCS adaptation options: 0:automatic, "
1103
0
                                                                                                               "1: rsp both (CW66 for QP<=22), 2: rsp TID0 (for all QP), "
1104
0
                                                                                                               "3: rsp inter(CW66 for QP<=22), 4: rsp inter(for all QP).")
1105
0
    ("LMCSInitialCW",                                   c->m_initialCW,                                      "LMCS initial total codeword (0~1023) when LMCSAdpOption > 0")
1106
0
    ("LMCSOffset",                                      c->m_LMCSOffset,                                     "LMCS chroma residual scaling offset")
1107
0
    ("ALF",                                             c->m_alf,                                            "Adaptive Loop Filter" )
1108
0
    ("ALFSpeed",                                        c->m_alfSpeed,                                       "ALF speed (skip filtering of non-referenced frames) [0-1]" )
1109
0
    ("CCALF",                                           c->m_ccalf,                                          "Cross-component Adaptive Loop Filter" )
1110
0
    ("UseNonLinearAlfLuma",                             c->m_useNonLinearAlfLuma,                            "Non-linear adaptive loop filters for Luma Channel")
1111
0
    ("UseNonLinearAlfChroma",                           c->m_useNonLinearAlfChroma,                          "Non-linear adaptive loop filters for Chroma Channels")
1112
0
    ("MaxNumAlfAlternativesChroma",                     c->m_maxNumAlfAlternativesChroma,                    std::string("Maximum number of alternative Chroma filters (1-") + std::to_string(VVENC_MAX_NUM_ALF_ALTERNATIVES_CHROMA) + std::string (", inclusive)") )
1113
0
    ("ALFTempPred",                                     c->m_alfTempPred,                                    "Enable usage of ALF temporal prediction for filter data\n" )
1114
0
    ("ALFUnitSize",                                     c->m_alfUnitSize,                                    "Size of ALF Search Unit [-1:default size(CTU)]\n" )
1115
0
    ("PROF",                                            c->m_PROF,                                           "Enable prediction refinement with optical flow for affine mode")
1116
0
    ("Affine",                                          c->m_Affine,                                         "Enable affine prediction")
1117
0
    ("AffineType",                                      c->m_AffineType,                                     "Enable affine type prediction")
1118
0
    ("MMVD",                                            c->m_MMVD,                                           "Enable Merge mode with Motion Vector Difference")
1119
0
    ("MmvdDisNum",                                      c->m_MmvdDisNum,                                     "Number of MMVD Distance Entries")
1120
0
    ("AllowDisFracMMVD",                                c->m_allowDisFracMMVD,                               "Disable fractional MVD in MMVD mode adaptively")
1121
0
    ("MCTF",                                            c->m_vvencMCTF.MCTF,                                 "Enable GOP based temporal filter. (0:off, 1:filter all frames, 2:use SCC detection to disable for screen coded content)")
1122
0
    ("MCTFSpeed",                                       c->m_vvencMCTF.MCTFSpeed,                            "MCTF Fast Mode (0:best quality ... 4:fastest operation)")
1123
0
    ("MCTFUnitSize",                                    c->m_vvencMCTF.MCTFUnitSize,                         "Size of MCTF operation area (block size for motion compensation).")
1124
0
    ("MCTFFutureReference",                             c->m_vvencMCTF.MCTFFutureReference,                  "Enable referencing of future frames in the GOP based temporal filter. This is typically disabled for Low Delay configurations.")
1125
0
    ("MCTFFrame",                                       toMCTFFrames,                                        "Frame to filter Strength for frame in GOP based temporal filter")
1126
0
    ("MCTFStrength",                                    toMCTFStrengths,                                     "Strength for  frame in GOP based temporal filter.")
1127
0
    ("BIM",                                             c->m_blockImportanceMapping,                         "Block importance mapping (basic temporal RDO based on MCTF).")
1128
1129
0
    ("FastLocalDualTreeMode",                           c->m_fastLocalDualTreeMode,                          "Fast intra pass coding for local dual-tree in intra coding region (0:off, 1:use threshold, 2:one intra mode only)")
1130
0
    ("QtbttExtraFast",                                  c->m_qtbttSpeedUp,                                   "Non-VTM compatible QTBTT speed-ups" )
1131
0
    ("FastTTSplit",                                     c->m_fastTTSplit,                                    "Fast method for TT split" )
1132
0
    ;
1133
1134
0
    opts.setSubSection("Threading, performance");
1135
0
    opts.addOptions()
1136
0
    ("MaxParallelFrames",                               c->m_maxParallelFrames,                              "Maximum number of frames to be processed in parallel(0:off, >=2: enable parallel frames)")
1137
0
    ("WppBitEqual",                                     c->m_ensureWppBitEqual,                              "Ensure bit equality with WPP case (0:off (sequencial mode), 1:copy from wpp line above, 2:line wise reset)")
1138
0
    ("EnablePicPartitioning",                           c->m_picPartitionFlag,                               "Enable picture partitioning (0: single tile, single slice, 1: multiple tiles/slices)")
1139
0
    ("TileColumnWidthArray",                            toTileColumnWidth,                                   "Tile column widths in units of CTUs. Last column width in list will be repeated uniformly to cover any remaining picture width")
1140
0
    ("TileRowHeightArray",                              toTileRowHeight,                                     "Tile row heights in units of CTUs. Last row height in list will be repeated uniformly to cover any remaining picture height")
1141
0
    ("TileParallelCtuEnc",                              c->m_tileParallelCtuEnc,                             "Allow parallel CTU block search in different tiles")
1142
0
    ("FppLinesSynchro",                                 toIfpLines,                                          "(deprecated) Inter-Frame Parallelization(IFP) explicit CTU-lines synchronization offset (-1: default mode with two lines, 0: off)")
1143
0
    ("IFPLines",                                        toIfpLines,                                          "Inter-Frame Parallelization(IFP) explicit CTU-lines synchronization offset (-1: default mode with two lines, 0: off)")
1144
0
    ("IFP",                                             toUseIfp,                                            "Inter-Frame Parallelization(IFP) (-1: auto, 0: off, 1: on, with default setting of IFPLines)")
1145
0
    ("NumParallelGOPs",                                 toNumParallelGOPs,                                   "Number of additional GOPs processed in parallel")
1146
0
    ;
1147
1148
0
    opts.setSubSection("Coding tools");
1149
0
    opts.addOptions()
1150
0
    ("SbTMVP",                                          c->m_SbTMVP,                                         "Enable Subblock Temporal Motion Vector Prediction (0: off, 1: on)")
1151
0
    ("CIIP",                                            c->m_CIIP,                                           "Enable CIIP mode, 0: off, 1: vtm, 2: fast, 3: faster ")
1152
0
    ("SBT",                                             c->m_SBT,                                            "Enable Sub-Block Transform for inter blocks (0: off 1: vtm, 2: fast, 3: faster)" )
1153
0
    ("LFNST",                                           c->m_LFNST,                                          "Enable LFNST (0: off, 1: on)" )
1154
0
    ("MTS",                                             c->m_MTS,                                            "Multiple Transform Set (MTS)" )
1155
0
    ("MTSIntraMaxCand",                                 c->m_MTSIntraMaxCand,                                "Number of additional candidates to test for MTS in intra slices")
1156
0
    ("ISP",                                             c->m_ISP,                                            "Intra Sub-Partitions Mode (0: off, 1: vtm, 2: fast, 3: faster)")
1157
0
    ("TransformSkip",                                   c->m_TS,                                             "Transform skipping, 0: off, 1: TS, 2: TS with SCC detection ")
1158
0
    ("TransformSkipLog2MaxSize",                        c->m_TSsize,                                         "Specify transform-skip maximum log2-size. Minimum 2, Maximum 5")
1159
0
    ("ChromaTS",                                        c->m_useChromaTS,                                    "Transform skipping for chroma, 0:off, 1:on (requires transform skipping)")
1160
0
    ("BDPCM",                                           c->m_useBDPCM,                                       "BDPCM (0:off, 1:luma and chroma, 2: BDPCM with SCC detection)")
1161
0
    ("RPR",                                             c->m_rprEnabledFlag,                                 "Reference Sample Resolution (0: disable, 1: enabled, 2: RPR ready")
1162
0
    ("IBC",                                             c->m_IBCMode,                                        "IBC (0:off, 1:IBC, 2: IBC with SCC detection)")
1163
0
    ("IBCFastMethod",                                   c->m_IBCFastMethod,                                  "Fast methods for IBC. 1:default, [2..6] speedups")
1164
0
    ("BCW",                                             c->m_BCW,                                            "Enable Generalized Bi-prediction(Bcw) 0: disabled, 1: enabled, 2: fast")
1165
0
    ("FastInferMerge",                                  c->m_FIMMode,                                        "Fast method to skip Inter/Intra modes. 0: off, [1..4] speedups")
1166
0
    ("NumIntraModesFullRD",                             c->m_numIntraModesFullRD,                            "Number modes for full RD intra search [-1, 1..3] (default: -1 auto)")
1167
0
    ("ReduceIntraChromaModesFullRD",                    c->m_reduceIntraChromaModesFullRD,                   "Reduce modes for chroma full RD intra search")
1168
0
    ("FirstPassMode",                                   c->m_FirstPassMode,                                  "Mode for first encoding pass when using rate control "
1169
0
                                                                                                               "(0: default, 1: faster, 2: faster with temporal downsampling, "
1170
0
                                                                                                                "3: faster with resolution downsampling, "
1171
0
                                                                                                                "4: faster with temporal and resolution downsampling)" )
1172
0
    ;
1173
1174
0
    opts.setSubSection("Input Options");
1175
0
    opts.addOptions()
1176
0
    ("HorCollocatedChroma",                             c->m_horCollocatedChromaFlag,                        "Specifies location of a chroma sample relatively to the luma sample in horizontal direction in the reference picture resampling"
1177
0
                                                                                                             "(0: horizontally shifted by 0.5 units of luma samples, 1: collocated)")
1178
0
    ("VerCollocatedChroma",                             c->m_verCollocatedChromaFlag,                        "Specifies location of a chroma sample relatively to the luma sample in vertical direction in the cross-component linear model intra prediction and the reference picture resampling"
1179
0
                                                                                                             "(0: horizontally co-sited, vertically shifted by 0.5 units of luma samples, 1: collocated)")
1180
0
    ("ClipInputVideoToRec709Range",                     m_bClipInputVideoToRec709Range,                      "Enable clipping input video to the Rec. 709 Range on loading when InternalBitDepth is less than MSBExtendedBitDepth")
1181
0
    ;
1182
1183
0
    opts.setSubSection("Reconstructed video options");
1184
0
    opts.addOptions()
1185
0
    ("ClipOutputVideoToRec709Range",                    m_bClipOutputVideoToRec709Range,                     "Enable clipping output video to the Rec. 709 Range on saving when OutputBitDepth is less than InternalBitDepth")
1186
0
    ("PYUV",                                            m_packedYUVOutput,                                   "Enable output 10-bit and 12-bit YUV data as 5-byte and 3-byte (respectively) packed YUV data. Ignored for interlaced output.")
1187
0
    ;
1188
0
  }
1189
1190
0
  {
1191
0
    opts.setSubSection( "Tracing" );
1192
0
    opts.addOptions()
1193
0
    ("tracechannellist",              c->m_listTracingChannels,  "list all available tracing channels")
1194
0
    ("tracerule",                     toTraceRule,               "tracing rule (ex: \"D_CABAC:poc==8\" or \"D_REC_CB_LUMA:poc==8\")")
1195
0
    ("tracefile",                     toTraceFile,               "tracing file")
1196
0
    ;
1197
0
  }
1198
1199
0
  {
1200
0
    opts.setSubSection("Film grain analysis");
1201
0
    opts.addOptions()
1202
0
    ("fga",                           c->m_fga,                  "Experimental: Enable film grain analysis and generate FGC SEI message ")
1203
0
    ;
1204
0
  }
1205
1206
0
  std::ostringstream fullOpts;
1207
0
  po::doHelp( fullOpts, opts );
1208
1209
0
  for ( int i = 0; i < VVENC_MAX_GOP; i++ )
1210
0
  {
1211
0
    std::ostringstream cOSS;
1212
0
    cOSS << "Frame" << i+1;
1213
0
    opts.addOptions()(cOSS.str(), c->m_GOPList[i] );
1214
0
  }
1215
1216
0
  if( !m_easyMode )
1217
0
  {
1218
    // enable access to easy app param names as hidden option (usable for e.g. vvenc_set_param(c,"bitrate", 500000) )
1219
0
    opts.setSubSection("Extra");
1220
0
    opts.addOptions()
1221
0
    ("tickspersec",                                     c->m_TicksPerSecond,                                 "Ticks Per Second for dts generation, (1..27000000)")
1222
0
    ("framerate,r",                                     c->m_FrameRate,                                      "temporal rate (framerate) e.g. 25,29,30,50,59,60 ")
1223
0
    ("frames",                                          c->m_framesToBeEncoded,                              "max. frames to encode [all]")
1224
0
    ("bitrate",                                         toBitrate,                                           "bitrate for rate control (0: constant-QP encoding without rate control, otherwise "
1225
0
                                                                                                             "bits/second; use e.g. 1.5M, 1.5Mbps, 1500k, 1500kbps, 1500000bps, 1500000)")
1226
0
    ("maxrate",                                         toMaxRate,                                           "approximate maximum instantaneous bitrate for constrained VBR in rate control (0: "
1227
0
                                                                                                             "no rate cap; use e.g. 3.5M, 3.5Mbps, 3500k, 3500kbps, 3500000bps, 3500000), use suffix 'x' "
1228
0
                                                                                                             "to specify as a multiple of target bitrate")
1229
0
    ("qpa",                                             toQPA,                                               "Enable perceptually motivated QP adaptation, XPSNR based (0:off, 1:on)", true)
1230
0
    ("internal-bitdepth",                               c->m_internalBitDepth[0],                            "internal bitdepth (8, 10)")
1231
0
    ("refreshtype,-rt",                                 toDecRefreshType,                                    "intra refresh type (idr, cra, cra_cre: CRA, constrained RASL picture encoding)")
1232
0
    ("decodedpicturehash,-dph",                         toHashType,                                          "control generation of decode picture hash SEI messages, (0: off, 1: md5, 2: crc, 3: checksum)")
1233
0
    ;
1234
0
  }
1235
1236
  //
1237
  // parse command line parameters and read configuration files
1238
  //
1239
0
  try
1240
0
  {
1241
0
    po::ErrorReporter err;
1242
0
    const std::list<const char*>& argv_unhandled = po::scanArgv( opts, argc, (const char**) argv, err );
1243
1244
0
    if ( do_help || argc == 0 )
1245
0
    {
1246
0
      m_showHelp = true;
1247
0
      rcOstr << easyOpts.str();
1248
0
      return 1;
1249
0
    }
1250
0
    else if ( do_full_help )
1251
0
    {
1252
0
      m_showHelp = true;
1253
0
      rcOstr << fullOpts.str();
1254
1255
0
      if( m_easyMode )
1256
0
      {
1257
0
        std::ostringstream additionalStr;
1258
0
        additionalStr << std::endl << "#======== string options by option 'additional' ================" << std::endl;
1259
0
        additionalStr << "Additional useful options of full feature app can be used with string option 'additional'." << std::endl;
1260
0
        additionalStr << "All available options of full feature app and vvencapp can be used in 'additional'." << std::endl;
1261
0
        additionalStr << "Options are assigned by '(long)optionname=value'. Concatenate options with ':'" << std::endl;
1262
0
        additionalStr << "For instance set hdr10 bt2020 mode (corresponds to option '--hdr pq_2020')" << std::endl;
1263
0
        additionalStr << "vvencapp  --additional ColourPrimaries=bt2020:TransferCharacteristics=smpte2084:MatrixCoefficients=bt2020nc" << std::endl;
1264
0
        additionalStr << "'additional' options are always parsed after all other options have been parsed!" << std::endl;
1265
0
        additionalStr << "Overview of usefull additional options:" << std::endl;
1266
0
        rcOstr << additionalStr.str();
1267
1268
0
        po::Options unusedOpts;
1269
0
        std::ostringstream addOpts;
1270
0
        unusedOpts.setSubSection("additional - VUI options");
1271
0
        unusedOpts.addOptions()
1272
0
        ("AspectRatioIdc",                                  c->m_aspectRatioIdc,           "Aspect ratio idc (0-16,255) 0=undef, 1=1:1, 2=12:11, 3=10:11, 4=16:11, 5=40:33, 6=24:11, 7=20:11, 8=32:11, 9=80:33, 10=18:11, 11=15:11, 12=64:33, 13=160:99, 14=4:3, 15=3:2, 16=2:1 "
1273
0
                                                                                           "e.g. --additional AspectRatioIdc=14")
1274
0
        ("Sar",                                             toSarSize,                     "Sample aspect ratio - ratio of width to height (WidthxHeight)")
1275
0
        ("ColourDescriptionPresent",                        c->m_colourDescriptionPresent, "Signals whether colour_primaries, transfer_characteristics, matrix_coefficients, full_range_flag are present")
1276
0
        ("ColourPrimaries",                                 toColourPrimaries,             "Specify colour primaries (0-13): reserved, bt709, unknown, empty, bt470m, bt470bg, smpte170m, "
1277
0
                                                                                           "smpte240m, film, bt2020, smpte428, smpte431, smpte432")
1278
0
        ("TransferCharacteristics",                         toTransferCharacteristics,     "Specify opto-electronic transfer characteristics (0-18): reserved, bt709, unknown, empty, bt470m, bt470bg, smpte170m, "
1279
0
                                                                                           "smpte240m, linear, log100, log316, iec61966-2-4, bt1361e, iec61966-2-1, "
1280
0
                                                                                           "bt2020-10, bt2020-12, smpte2084, smpte428, arib-std-b67")
1281
0
        ("MatrixCoefficients",                              toColourMatrix,                "Specify colour matrix setting to derive luma/chroma from RGB primaries (0-14): gbr, bt709, unknown, empty, fcc, bt470bg, smpte170m, "
1282
0
                                                                                           "smpte240m, ycgco, bt2020nc, bt2020c, smpte2085, chroma-derived-nc, chroma-derived-c, ictcp")
1283
0
        ("ChromaLocInfoPresent",                            toChromaLocInfo,               "Signals whether chroma_sample_loc_type is present (-1: auto, 0: off, 1: on)")
1284
0
        ("ChromaSampleLocType",                             c->m_chromaSampleLocType,      "Specifies the location of chroma samples for progressive content(-1 auto, 0-5 Chroma420LocType)")
1285
0
        ("OverscanAppropriate",                             c->m_overscanAppropriateFlag,  "Indicates whether conformant decoded pictures are suitable for display using overscan")
1286
0
        ;
1287
1288
0
        unusedOpts.setSubSection("additional - SEI and auxiliary options");
1289
0
        unusedOpts.addOptions()
1290
0
        ("MasteringDisplayColourVolume",                    toMasteringDisplay,            "SMPTE ST 2086 mastering display colour volume info SEI (HDR), "
1291
0
                                                                                           "vec(uint) size 10, x,y,x,y,x,y,x,y,max,min where: \"G(x,y)B(x,y)R(x,y)WP(x,y)L(max,min)\""
1292
0
                                                                                           "range: 0 <= GBR,WP <= 50000, 0 <= L <= uint; GBR xy coordinates in increment of 1/50000, min/max luminance in units of 1/10000 cd/m2 "
1293
0
                                                                                           "e.g. for P3D65 1000-nits, where G(x=0.265, y=0.690), B(x=0.150, y=0.060), R(x=0.680, y=0.320), WP(x=0.3127, y=0.3290), L(max=1000, min=0.0001): "
1294
0
                                                                                           "--additional MasteringDisplayColourVolume=13250,34500,7500,3000,34000,16000,15635,16450,10000000,1" )
1295
0
        ("MaxContentLightLevel",                            toContentLightLevel,           "Specify content light level info SEI as \"cll,fall\" (HDR) max. content light level, "
1296
0
                                                                                           "max. frame average light level, range: 1 <= cll,fall <= 65535', e.g. --additional MaxContentLightLevel=1000,400")
1297
0
        ("PreferredTransferCharacteristics",                toPrefTransferCharacteristics, "Specify preferred transfer characteristics SEI and overwrite transfer entry in VUI (0-18): reserved, bt709, unknown, empty, bt470m, bt470bg, smpte170m, "
1298
0
                                                                                           "smpte240m, linear, log100, log316, iec61966-2-4, bt1361e, iec61966-2-1, "
1299
0
                                                                                           "bt2020-10, bt2020-12, smpte2084, smpte428, arib-std-b67 , e.g. --additional PreferredTransferCharacteristics=arib-std-b67")
1300
0
        ;
1301
0
       unusedOpts.setSubSection("additional - Slice decision options");
1302
0
        unusedOpts.addOptions()
1303
0
        ("PicReordering",                                   c->m_picReordering,            "Allow reordering of pictures (0:off, 1:on), should be disabled for low delay requirements")
1304
0
        ;
1305
1306
0
        po::doAdditionalOptList( addOpts, unusedOpts );
1307
0
        rcOstr << addOpts.str();
1308
1309
0
      }
1310
0
      return 1;
1311
0
    }
1312
1313
0
    if( !m_easyMode && !writeCfg.empty() )
1314
0
    {
1315
0
      std::ofstream cfgFile;
1316
0
      cfgFile.open( writeCfg.c_str(), std::ios::out | std::ios::trunc);
1317
0
      if( !cfgFile.is_open() )
1318
0
      {
1319
0
        rcOstr << " [error]: failed to open output config file " << writeCfg << std::endl;
1320
0
        return -1;
1321
0
      }
1322
0
      else
1323
0
      {
1324
0
        std::list<std::string> ignoreParamsLst;
1325
0
        ignoreParamsLst.push_back( "help" );
1326
0
        ignoreParamsLst.push_back( "longhelp" );
1327
0
        ignoreParamsLst.push_back( "fullhelp" );
1328
0
        ignoreParamsLst.push_back( "WriteConfig" );
1329
0
        ignoreParamsLst.push_back( "configfile" );
1330
0
        ignoreParamsLst.push_back( "c" );
1331
1332
0
        ignoreParamsLst.push_back( "decode" );
1333
0
        for ( int i = 0; i < VVENC_MAX_GOP; i++ )
1334
0
        {
1335
0
          std::ostringstream cOSS;
1336
0
          cOSS << "Frame" << i+1;
1337
0
          ignoreParamsLst.push_back( cOSS.str() );
1338
0
        }
1339
1340
0
        std::ostringstream cfgStream;
1341
0
        po::saveConfig( cfgStream, opts, ignoreParamsLst );
1342
0
        cfgFile << cfgStream.str() << std::endl;
1343
0
        cfgFile.close();
1344
0
      }
1345
0
    }
1346
1347
0
    if ( m_showVersion )
1348
0
    {
1349
0
      return 1;
1350
0
    }
1351
1352
    // file check
1353
0
    std::string cErr;
1354
0
    if( !m_inputFileName.empty() && !apputils::FileIOHelper::checkInputFile( m_inputFileName, cErr ) )
1355
0
    {
1356
0
      err.warn( "Input file" ) << cErr;
1357
0
    }
1358
1359
0
    if( !m_bitstreamFileName.empty() && !apputils::FileIOHelper::checkBitstreamFile( m_bitstreamFileName, cErr ) )
1360
0
    {
1361
0
      err.warn( "Bitstream file" ) << cErr;
1362
0
    }
1363
1364
0
    if( !m_inputFileName.empty() && m_inputFileName != "-" )
1365
0
    {
1366
0
      if( !m_bitstreamFileName.empty() && m_inputFileName == m_bitstreamFileName )
1367
0
      {
1368
0
        err.error( "Bitstream file" ) <<  "Bitstream file and Input file are the same.\n";
1369
0
      }
1370
0
      if( !m_reconFileName.empty() && m_inputFileName == m_reconFileName )
1371
0
      {
1372
0
        err.error( "Reconstructed YUV file" ) <<  "Reconstructed YUV file and Input file are the same.\n";
1373
0
      }
1374
0
      if( !m_RCStatsFileName.empty() && m_inputFileName == m_RCStatsFileName )
1375
0
      {
1376
0
        err.error( "rate control statistics file" ) <<  "rate control statistics file and Input file are the same.\n";
1377
0
      }
1378
0
    }
1379
1380
0
    if ( m_FrameSkip < 0 )
1381
0
    {
1382
0
      err.error( "number of frames to skip" ) << (m_easyMode ? "frameskip must be >= 0\n" : "FrameSkip must be >= 0\n");
1383
0
    }
1384
1385
    // check for y4m input
1386
0
    bool isY4m = ( m_forceY4mInput || apputils::FileIOHelper::isY4mInputFilename( m_inputFileName ) ) ? true : false;
1387
0
    if( !isY4m && apputils::FileIOHelper::isY4mHeaderAvailable( m_inputFileName ) )
1388
0
    {
1389
0
      err.warn( "Input file" ) << "Y4M file signature detected. Enable Y4M mode.\n";
1390
0
      isY4m = true;
1391
0
      m_forceY4mInput = true;
1392
0
    }
1393
1394
0
    if ( isY4m )
1395
0
    {
1396
0
      if( 0 > apputils::FileIOHelper::parseY4mHeader( m_inputFileName, *c, m_inputFileChromaFormat ))
1397
0
      {
1398
0
        err.error( "y4m parser" ) << "cannot parse y4m metadata.\n";
1399
0
      }
1400
0
    }
1401
1402
0
    if( sdrMode != VVENC_HDR_OFF || hdrMode != VVENC_HDR_OFF )
1403
0
    {
1404
      // check if at least one mode has changed, but error when both changed
1405
0
      if( sdrMode != hdrMode && sdrMode != VVENC_HDR_OFF && hdrMode != VVENC_HDR_OFF )
1406
0
      {
1407
0
        err.error( "Dynamic range" ) << "cannot combine hdr and sdr mode. use one or another.\n";
1408
0
      }
1409
1410
0
      c->m_HdrMode = (sdrMode != VVENC_HDR_OFF) ? sdrMode : hdrMode;
1411
0
    }
1412
1413
0
    for( auto& a : argv_unhandled )
1414
0
    {
1415
0
      rcOstr << "Unknown argument: '" << a << "'\n";
1416
0
      ret = warnUnknowParameter ? 2 : -1;
1417
0
    }
1418
1419
0
    if( err.is_errored )
1420
0
    {
1421
0
      rcOstr << err.outstr.str();
1422
0
      if( argc == 2 ) return VVENC_PARAM_BAD_NAME;
1423
0
      else            return warnUnknowParameter ? 2 : -1;
1424
0
    }
1425
0
    else if( err.is_warning )
1426
0
    {
1427
0
      rcOstr << err.outstr.str() << "\n";
1428
0
      return 2;
1429
0
    }
1430
0
  }
1431
0
  catch( program_options::ParseFailure &e )
1432
0
  {
1433
0
    rcOstr << "Error parsing option \"" << e.arg << "\" with argument \"" << e.val << "\".\n";
1434
0
    if( argc == 2 )
1435
0
      ret = VVENC_PARAM_BAD_VALUE;
1436
0
    else
1437
0
      ret = -1;
1438
0
  }
1439
1440
0
  return ret;
1441
0
}
1442
1443
bool checkCfg( vvenc_config* c, std::ostream& rcOstr )
1444
0
{
1445
0
  bool ret = false;
1446
0
1447
0
  // check bitstream file name in encode and decode mode
1448
0
  if( m_bitstreamFileName.empty() )
1449
0
  {
1450
0
    // if rc statsfile is defined and in 1st pass, bitstream file is not needed
1451
0
    if ( !(c->m_RCPass == 1 && !m_RCStatsFileName.empty()) )
1452
0
    {
1453
0
      rcOstr << "error: bitstream file name must be specified (" << (m_easyMode ? "--output" : "--BitstreamFile") << "=bit.266)" << std::endl;
1454
0
      ret = true;
1455
0
    }
1456
0
  }
1457
0
1458
0
  // check remaining parameter set
1459
0
  if( !xCheckCfg( c, rcOstr ) )
1460
0
  {
1461
0
    ret = true;
1462
0
  }
1463
0
  return ret;
1464
0
}
1465
1466
static inline std::string getDynamicRangeStr( int dynamicRange )
1467
0
{
1468
0
  std::string cT;
1469
0
  switch( dynamicRange )
1470
0
  {
1471
0
    case VVENC_HDR_OFF            : cT = "SDR"; break;
1472
0
    case VVENC_HDR_PQ             : cT = "HDR10/PQ"; break;
1473
0
    case VVENC_HDR_HLG            : cT = "HDR HLG"; break;
1474
0
    case VVENC_HDR_PQ_BT2020      : cT = "HDR10/PQ BT.2020"; break;
1475
0
    case VVENC_HDR_HLG_BT2020     : cT = "HDR HLG BT.2020"; break;
1476
0
    case VVENC_HDR_USER_DEFINED   : cT = "HDR user defined"; break;
1477
0
    case VVENC_SDR_BT709          : cT = "SDR BT.709"; break;
1478
0
    case VVENC_SDR_BT2020         : cT = "SDR BT.2020"; break;
1479
0
    case VVENC_SDR_BT470BG        : cT = "SDR BT.470 B/G"; break;
1480
0
    default                       : cT = "unknown"; break;
1481
0
  }
1482
0
  return cT;
1483
0
}
1484
1485
static int64_t getFrameCount( std::string fileName, unsigned int width, unsigned int height, vvencChromaFormat chromaFormat, int bitdepth, bool packed = false )
1486
0
{
1487
0
  int64_t packetCount = 0;
1488
1489
0
  if( !strcmp( fileName.c_str(), "-" ) )
1490
0
  {
1491
0
    return -1;
1492
0
  }
1493
1494
0
  std::fstream fhandle;
1495
0
  fhandle.open( fileName.c_str(), std::ios::binary | std::ios::in );
1496
0
  if( fhandle.fail() )
1497
0
    return -1;
1498
1499
0
  fhandle.seekg( 0, std::ios::end );
1500
0
  std::streamoff filelength = fhandle.tellg();
1501
0
  fhandle.close();
1502
1503
0
  unsigned int uiBitsPerPx = bitdepth == 8 ? 12 : 24;
1504
0
  switch ( chromaFormat )
1505
0
  {
1506
0
    case VVENC_CHROMA_400: uiBitsPerPx = bitdepth == 8 ?  8 : 16; break;
1507
0
    case VVENC_CHROMA_420: uiBitsPerPx = bitdepth == 8 ? 12 : 24; break;
1508
0
    case VVENC_CHROMA_422: uiBitsPerPx = bitdepth == 8 ? 16 : 32; break;
1509
0
    case VVENC_CHROMA_444: uiBitsPerPx = bitdepth == 8 ? 24 : 48; break;
1510
0
    default: break;
1511
0
  }
1512
1513
0
  size_t frameSize = (width * height * uiBitsPerPx) >> 3;
1514
1515
0
  if ( packed && bitdepth == 10 && chromaFormat == VVENC_CHROMA_420 )
1516
0
  {
1517
0
    size_t stride = width * 5 / 4;
1518
0
    size_t lumaSize = stride * height;
1519
0
    size_t chromaSize = lumaSize >> 2;
1520
0
    frameSize = lumaSize + chromaSize + chromaSize;
1521
0
  }
1522
1523
0
  packetCount = (int64_t)filelength / frameSize;
1524
0
  return packetCount;
1525
0
}
1526
1527
virtual std::string getAppConfigAsString( vvenc_config* c, vvencMsgLevel eMsgLevel ) const
1528
0
{
1529
0
  std::stringstream css;
1530
0
  std::string loglvl("vvenc ");
1531
0
  switch ( eMsgLevel )
1532
0
  {
1533
0
    case VVENC_SILENT : loglvl.append("[silent]: ");  break;
1534
0
    case VVENC_ERROR  : loglvl.append("[error]: ");   break;
1535
0
    case VVENC_WARNING: loglvl.append("[warning]: "); break;
1536
0
    case VVENC_INFO   : loglvl.append("[info]: ");    break;
1537
0
    case VVENC_NOTICE : loglvl.append("[notice]: ");  break;
1538
0
    case VVENC_VERBOSE: loglvl.append("[verbose]: "); break;
1539
0
    case VVENC_DETAILS: loglvl.append("[details]: "); break;
1540
0
    default: break;
1541
0
  }
1542
1543
0
  bool isY4m = ( m_forceY4mInput || apputils::FileIOHelper::isY4mInputFilename( m_inputFileName ) ) ? true : false;
1544
0
  std::string ext = apputils::FileIOHelper::getFileExtension( m_inputFileName );
1545
0
  std::transform( ext.begin(), ext.end(), ext.begin(), ::tolower );
1546
0
  std::string format = isY4m ? "y4m" : "yuv";
1547
1548
0
  if( eMsgLevel >= VVENC_INFO )
1549
0
  {
1550
0
    if( format != ext )
1551
0
      css << loglvl << "Input File                             : " << m_inputFileName << "  (" << format << ")\n";
1552
0
    else
1553
0
      css << loglvl << "Input File                             : " << m_inputFileName << "\n";
1554
0
    css << loglvl << "Bitstream File                         : " << m_bitstreamFileName << "\n";
1555
0
  }
1556
0
  if( eMsgLevel >= VVENC_DETAILS )
1557
0
  {
1558
0
    if( !m_easyMode )
1559
0
      css << loglvl << "Reconstruction File                    : " << m_reconFileName << "\n";
1560
0
    if ( c->m_RCTargetBitrate > 0 )
1561
0
      css << loglvl << "RC Statistics  File                    : " << m_RCStatsFileName << "\n";
1562
0
  }
1563
1564
0
  if ( c )
1565
0
  {
1566
0
    if( eMsgLevel >= VVENC_INFO )
1567
0
    {
1568
0
      std::string inputFmt;
1569
0
      switch ( c->m_internChromaFormat)
1570
0
      {
1571
0
        case VVENC_CHROMA_400: inputFmt= "yuv400p"; break;
1572
0
        case VVENC_CHROMA_422: inputFmt= "yuv422p"; break;
1573
0
        case VVENC_CHROMA_444: inputFmt= "yuv444p"; break;
1574
0
        case VVENC_CHROMA_420: 
1575
0
        default:
1576
0
          inputFmt= "yuv420p"; break;
1577
0
      }
1578
0
      if( c->m_inputBitDepth[ 0 ] == 10 )
1579
0
      {
1580
0
        inputFmt.append("10");
1581
0
        if ( m_packedYUVInput )
1582
0
          inputFmt.append("(packed)");
1583
0
      }
1584
1585
0
      std::stringstream frameCountStr;
1586
0
      std::stringstream framesStr;
1587
1588
0
      if( strcmp( m_inputFileName.c_str(), "-" ) )
1589
0
      {
1590
0
        int64_t frameCount = getFrameCount( m_inputFileName, c->m_SourceWidth, c->m_SourceHeight, c->m_internChromaFormat, c->m_inputBitDepth[ 0 ], m_packedYUVInput );
1591
0
        frameCountStr << frameCount << (frameCount > 1 ? " frames" : " frame");
1592
1593
0
        int64_t framesToEncode = (c->m_framesToBeEncoded == 0 || c->m_framesToBeEncoded >= frameCount) ? frameCount : c->m_framesToBeEncoded;
1594
0
        framesStr << "encode " << framesToEncode << ( framesToEncode > 1 ? " frames " : " frame ");
1595
0
      }
1596
0
      else 
1597
0
      {
1598
0
        framesStr << "encode "  << c->m_framesToBeEncoded << ( c->m_framesToBeEncoded > 1 ? " frames " : " frame ");
1599
0
      }
1600
1601
0
      if ( m_FrameSkip )
1602
0
        framesStr << " skip " << m_FrameSkip << ( m_FrameSkip > 1 ? " frames " : " frame ");         
1603
        
1604
0
      css << loglvl << "Real Format                            : ";      
1605
0
      css << c->m_PadSourceWidth - c->m_confWinLeft - c->m_confWinRight << "x" << c->m_PadSourceHeight - c->m_confWinTop - c->m_confWinBottom << "  "
1606
0
          << inputFmt << "  " << (double)c->m_FrameRate/c->m_FrameScale << " Hz  " << getDynamicRangeStr(c->m_HdrMode) << "  " << frameCountStr.str() << "\n";
1607
0
      css << loglvl << "Frames                                 : " << framesStr.str() << "\n";
1608
0
    }
1609
0
  }
1610
1611
0
  return css.str();
1612
0
}
1613
1614
std::vector <std::tuple<std::string, std::string>> getAdditionalSettingList()
1615
0
{
1616
0
  std::vector <std::tuple<std::string, std::string>> settingsDictionary;
1617
0
  if ( !m_additionalSettings.empty())
1618
0
  {
1619
0
    char delimiter =':'; // delimiter to mark entry beside space
1620
0
    std::vector<std::string> tokenvec = tokenize( m_additionalSettings, delimiter );
1621
0
1622
0
    for( auto &t : tokenvec )
1623
0
    {
1624
0
      char delimiterEntryValue = '='; // delimiter to mark entry from value
1625
0
      std::vector<std::string> entry = tokenize( t, delimiterEntryValue );
1626
0
1627
0
      if( !entry.empty() )
1628
0
      {
1629
0
        std::string key   = entry.front();
1630
0
        std::string value = entry.size() > 1 ? entry[1] : "";
1631
0
1632
0
        settingsDictionary.push_back(std::make_tuple( key, value) );
1633
0
      }
1634
0
    }
1635
0
  }
1636
0
1637
0
  return settingsDictionary;
1638
0
}
1639
1640
private:
1641
1642
bool xCheckCfg( vvenc_config* c, std::ostream& rcOstr )
1643
0
{
1644
0
  bool ret = true;
1645
0
1646
0
  if( m_inputFileName.empty() )
1647
0
  {
1648
0
    rcOstr << "error: input yuv file name must be specified (--input=video.yuv)" << std::endl;
1649
0
    ret = false;
1650
0
  }
1651
0
  if( ! strcmp( m_inputFileName.c_str(), "-" )
1652
0
      && c->m_RCNumPasses > 1
1653
0
      && c->m_RCPass < 0 )
1654
0
  {
1655
0
    rcOstr << "error: two pass rate control within single application call and reading from stdin not supported" << std::endl;
1656
0
    ret = false;
1657
0
  }
1658
0
1659
0
#ifndef VVENC_ENABLE_THIRDPARTY_JSON
1660
0
  if( c->m_RCPass > 0 )
1661
0
  {
1662
0
    rcOstr << "error: reading/writing rate control statistics file not supported, please disable pass parameter or compile with json enabled" << std::endl;
1663
0
    ret = false;
1664
0
  }
1665
0
  if( ! m_RCStatsFileName.empty() )
1666
0
  {
1667
0
    rcOstr << "error: reading/writing rate control statistics file not supported, please disable rcstatsfile parameter or compile with json enabled" << std::endl;
1668
0
    ret = false;
1669
0
  }
1670
0
  if( ! m_logoFileName.empty() )
1671
0
  {
1672
0
    rcOstr << "error: reading of logo overlay file not supported, please disable logofile parameter or compile with json enabled" << std::endl;
1673
0
    ret = false;
1674
0
  }
1675
0
#endif
1676
0
1677
0
  if( c->m_RCPass > 0 && m_RCStatsFileName.empty() )
1678
0
  {
1679
0
    rcOstr << "error: rate control statistics file name must be specify, when pass parameter is set (--rcstatsfile=stats.json)" << std::endl;
1680
0
    ret = false;
1681
0
  }
1682
0
  if( c->m_RCNumPasses == 1 && ! m_RCStatsFileName.empty() )
1683
0
  {
1684
0
    rcOstr << "error: rate control statistics file not supported in single pass encoding" << std::endl;
1685
0
    ret = false;
1686
0
  }
1687
0
1688
0
  if( m_inputFileChromaFormat != VVENC_CHROMA_400 && m_inputFileChromaFormat != VVENC_CHROMA_420 )
1689
0
  {
1690
0
    rcOstr << "error: input chroma format must be either 400, 420" << std::endl;
1691
0
    ret = false;
1692
0
  }
1693
0
1694
0
  if( m_packedYUVInput )
1695
0
  {
1696
0
    if( get_width_of_component( c->m_internChromaFormat, c->m_SourceWidth, 0 ) % 4 != 0 )
1697
0
    {
1698
0
      rcOstr <<  "error: unsupported input width for packed input (width must be a multiple of 4)" << std::endl;
1699
0
      ret = false;
1700
0
    }
1701
0
1702
0
    if( (c->m_internChromaFormat == VVENC_CHROMA_420 || c->m_internChromaFormat == VVENC_CHROMA_422) &&
1703
0
         get_width_of_component( c->m_internChromaFormat, c->m_SourceWidth, 1 ) % 4 != 0 )
1704
0
    {
1705
0
      rcOstr <<  "error: unsupported input width for packed input (chroma width must be a multiple of 4)" << std::endl;
1706
0
      ret = false;
1707
0
    }
1708
0
  }
1709
0
1710
0
  if( m_packedYUVOutput && ! m_reconFileName.empty() )
1711
0
  {
1712
0
    // if output bitdepth not defined, use internal bitdepth as default value
1713
0
    if (c->m_outputBitDepth[0] == 0) c->m_outputBitDepth[0] = c->m_internalBitDepth[0];
1714
0
    if (c->m_outputBitDepth[1] == 0) c->m_outputBitDepth[1] = c->m_outputBitDepth[0];
1715
0
1716
0
    if( ( c->m_outputBitDepth[ 0 ] != 10 && c->m_outputBitDepth[ 0 ] != 12 )
1717
0
        || ( ( ( c->m_SourceWidth ) & ( 1 + ( c->m_outputBitDepth[ 0 ] & 3 ) ) ) != 0 ) )
1718
0
    {
1719
0
      rcOstr << "error: invalid output bit-depth or image width for packed YUV output" << std::endl;
1720
0
      ret = false;
1721
0
    }
1722
0
    if( ( c->m_internChromaFormat != VVENC_CHROMA_400 ) && ( ( c->m_outputBitDepth[ 1 ] != 10 && c->m_outputBitDepth[ 1 ] != 12 )
1723
0
          || ( ( get_width_of_component( c->m_internChromaFormat, c->m_SourceWidth, 1 ) & ( 1 + ( c->m_outputBitDepth[ 1 ] & 3 ) ) ) != 0 ) ) )
1724
0
    {
1725
0
      rcOstr << "error: invalid chroma output bit-depth or image width for packed YUV output" << std::endl;
1726
0
      ret = false;
1727
0
    }
1728
0
  }
1729
0
1730
0
  return ret;
1731
0
}
1732
1733
1734
std::vector<std::string> tokenize(std::string str, char delimiter )
1735
0
{
1736
0
  std::vector<std::string> tokenvec;
1737
0
  bool tupleRequired=false;
1738
0
  std::string cDefDel = " ";
1739
0
  if ( delimiter == '=' )
1740
0
  {
1741
0
    // when searching for "=" we always want to return a tuple of "key value"
1742
0
    replace_if( str.begin(), str.end(), []( int c ){ return isspace( c ) || c == '='; }, ' ' );
1743
0
    tupleRequired=true;
1744
0
  }
1745
0
  else if ( delimiter == ':' )
1746
0
    replace_if( str.begin(), str.end(), []( int c ){ return isspace( c ) || c == ':'; }, ' ' );
1747
0
  else
1748
0
    replace_if( str.begin(), str.end(), []( int c ){ return isspace( c ); }, ' ' );
1749
0
1750
0
  std::string cDelList = "\"";  // lists must be defined within " "
1751
0
1752
0
  size_t start = str.find_first_not_of(cDefDel);
1753
0
  size_t end=std::string::npos;
1754
0
1755
0
  while (start != std::string::npos)
1756
0
  {
1757
0
    size_t startL = str.find(cDelList, start);  // Find occurence of a list
1758
0
    size_t endL = str.find(cDelList, startL+1); // Find occurence of list end
1759
0
1760
0
    end = str.find(cDefDel, start); // Find next occurence of delimiter
1761
0
1762
0
    if( startL != std::string::npos && endL != std::string::npos && startL <= end)
1763
0
    {
1764
0
      // extract a value as list, when " " was found ( only when both " was found a next space is in current statement)
1765
0
      std::string listItem = str.substr(start, endL-start );
1766
0
      std::string::iterator end_pos = std::remove(listItem.begin(), listItem.end(), '\"');
1767
0
      listItem.erase(end_pos, listItem.end());
1768
0
      tokenvec.push_back( listItem );
1769
0
1770
0
      end = str.find(cDefDel, endL);
1771
0
      start = str.find_first_not_of(cDefDel, end);
1772
0
    }
1773
0
    else if( startL != std::string::npos && endL == std::string::npos)
1774
0
    {
1775
0
      // error case, found start ", but without end
1776
0
      tokenvec.clear();
1777
0
      return tokenvec;
1778
0
    }
1779
0
    else
1780
0
    {
1781
0
      // Push back the token found into vector
1782
0
      if( (start==0 && tokenvec.empty()) || start>0 )
1783
0
      {
1784
0
        if( tupleRequired && !tokenvec.empty() )
1785
0
        {
1786
0
          // when in tuple mode, we extract everything after = as a value
1787
0
          end=std::string::npos;
1788
0
          tokenvec.push_back( str.substr(start, end) );
1789
0
        }
1790
0
        else
1791
0
        {
1792
0
          tokenvec.push_back( str.substr(start, end-start) );
1793
0
        }
1794
0
      }
1795
0
      // Skip all occurences of the delimiter to find new start
1796
0
      start = str.find_first_not_of(cDefDel, end);
1797
0
    }
1798
0
  }
1799
0
1800
0
  return tokenvec;
1801
0
}
1802
1803
1804
static int get_width_of_component( const vvencChromaFormat chFmt, const int frameWidth, const int compId )
1805
0
{
1806
0
  int w = frameWidth;
1807
0
  if ( compId > 0 )
1808
0
  {
1809
0
    switch ( chFmt )
1810
0
    {
1811
0
      case VVENC_CHROMA_400: w = 0;      break;
1812
0
      case VVENC_CHROMA_420:
1813
0
      case VVENC_CHROMA_422: w = w >> 1; break;
1814
0
      default: break;
1815
0
    }
1816
0
  }
1817
0
  return w;
1818
0
}
1819
1820
static int get_height_of_component( const vvencChromaFormat chFmt, const int frameHeight, const int compId )
1821
0
{
1822
0
  int h = frameHeight;
1823
0
  if ( compId > 0 )
1824
0
  {
1825
0
    switch ( chFmt )
1826
0
    {
1827
0
      case VVENC_CHROMA_400: h = 0;      break;
1828
0
      case VVENC_CHROMA_420: h = h >> 1; break;
1829
0
      case VVENC_CHROMA_422:
1830
0
      default: break;
1831
0
    }
1832
0
  }
1833
0
  return h;
1834
0
}
1835
1836
};
1837
1838
void setPresets( VVEncAppCfg* appcfg, vvenc_config* cfg,  int preset )
1839
0
{
1840
0
  VVEncAppCfg::presetChangeCallback callback = appcfg->getPresetChangeCallback();
1841
0
  if( callback )
1842
0
  {
1843
0
    callback( cfg, (vvencPresetMode)preset );
1844
0
  }
1845
0
}
1846
1847
void setInputBitDepthAndColorSpace( VVEncAppCfg* appcfg, vvenc_config* cfg, int dbcs )
1848
0
{
1849
0
  switch( dbcs )
1850
0
  {
1851
0
  case YUV420_8 :         appcfg->m_inputFileChromaFormat = VVENC_CHROMA_420; cfg->m_inputBitDepth[0] = 8;  break;
1852
0
  case YUV420_10 :        appcfg->m_inputFileChromaFormat = VVENC_CHROMA_420; cfg->m_inputBitDepth[0] = 10; break;
1853
0
  case YUV420_10_PACKED : appcfg->m_inputFileChromaFormat = VVENC_CHROMA_420; cfg->m_inputBitDepth[0] = 10; appcfg->m_packedYUVInput=true; break;
1854
0
  case YUV422_8 :         appcfg->m_inputFileChromaFormat = VVENC_CHROMA_422; cfg->m_inputBitDepth[0] = 8;  break;
1855
0
  case YUV422_10 :        appcfg->m_inputFileChromaFormat = VVENC_CHROMA_422; cfg->m_inputBitDepth[0] = 10; break;
1856
0
  case YUV444_8 :         appcfg->m_inputFileChromaFormat = VVENC_CHROMA_444; cfg->m_inputBitDepth[0] = 8;  break;
1857
0
  case YUV444_10 :        appcfg->m_inputFileChromaFormat = VVENC_CHROMA_444; cfg->m_inputBitDepth[0] = 10; break;
1858
0
  case YUV400_8 :         appcfg->m_inputFileChromaFormat = VVENC_CHROMA_400; cfg->m_inputBitDepth[0] = 8;  break;
1859
0
  case YUV400_10 :        appcfg->m_inputFileChromaFormat = VVENC_CHROMA_400; cfg->m_inputBitDepth[0] = 10; break;
1860
0
  default: break;
1861
0
  }
1862
0
}
1863
1864
static void setSAO( VVEncAppCfg*, vvenc_config *cfg, int saoVal )
1865
0
{
1866
0
  cfg->m_bUseSAO = !!saoVal;
1867
0
  cfg->m_saoScc  = saoVal == 2;
1868
0
}
1869
1870
static void setColourRange( VVEncAppCfg*, vvenc_config *cfg, int colourRange )
1871
0
{
1872
0
  if( colourRange ) // enable vui/colour description if colour range is specified
1873
0
  {
1874
0
    cfg->m_videoFullRangeFlag = (colourRange == 2) ? true : false;
1875
0
    cfg->m_colourDescriptionPresent = true;
1876
0
    cfg->m_vuiParametersPresent = true;
1877
0
  }
1878
0
}
1879
1880
} // namespace
1881
1882
//! \}
1883