3333#include "oapv_app_util.h"
3434#include "oapv_app_args.h"
3535#include "oapv_app_y4m.h"
36+ #include "oapv_port.h"
3637
3738#define MAX_BS_BUF (128 * 1024 * 1024)
3839#define MAX_NUM_FRMS (1) // supports only 1-frame in an access unit
@@ -45,6 +46,24 @@ typedef enum _STATES {
4546 STATE_STOP
4647} STATES ;
4748
49+ /* Mastering display colour volume metadata*/
50+ typedef struct md_mdcv md_mdcv_t ;
51+ struct md_mdcv {
52+ u16 primary_chromaticity_x [3 ];
53+ u16 primary_chromaticity_y [3 ];
54+ u16 white_point_chromaticity_x ;
55+ u16 white_point_chromaticity_y ;
56+ u32 max_mastering_luminance ;
57+ u32 min_mastering_luminance ;
58+ };
59+
60+ /* Content light level information*/
61+ typedef struct md_cll md_cll_t ;
62+ struct md_cll {
63+ u16 max_cll ;
64+ u16 max_fall ;
65+ };
66+
4867// clang-format off
4968
5069/* define various command line options as a table */
@@ -275,6 +294,14 @@ static const args_opt_t enc_args_opts[] = {
275294 ARGS_NO_KEY , "hash" , ARGS_VAL_TYPE_NONE , 0 , NULL ,
276295 "embed frame hash value for conformance checking in decoding"
277296 },
297+ {
298+ ARGS_NO_KEY , "master-display" , ARGS_VAL_TYPE_STRING , 0 , NULL ,
299+ "mastering display color volume metadata"
300+ },
301+ {
302+ ARGS_NO_KEY , "max-cll" , ARGS_VAL_TYPE_STRING , 0 , NULL ,
303+ "content light level information metadata"
304+ },
278305 {ARGS_END_KEY , "" , ARGS_VAL_TYPE_NONE , 0 , NULL , "" } /* termination */
279306};
280307
@@ -318,11 +345,14 @@ typedef struct args_var {
318345 char tile_w [16 ];
319346 char tile_h [16 ];
320347
321- int color_primaries ;
322- int color_transfer ;
323- int color_matrix ;
324- int color_range ;
348+ int color_primaries ;
349+ int color_transfer ;
350+ int color_matrix ;
351+ int color_range ;
325352
353+ char master_display [512 ];
354+ char max_cll [64 ];
355+
326356 oapve_param_t * param ;
327357} args_var_t ;
328358
@@ -393,6 +423,10 @@ static args_var_t *args_init_vars(args_parser_t *args, oapve_param_t *param)
393423 args_set_variable_by_key_long (opts , "color-range" , & vars -> color_range );
394424 vars -> color_range = -1 ; /* unset */
395425
426+ args_set_variable_by_key_long (opts , "master-display" , vars -> master_display );
427+ args_set_variable_by_key_long (opts , "max-cll" , vars -> max_cll );
428+
429+
396430 return vars ;
397431}
398432
@@ -750,6 +784,13 @@ static int update_param(args_var_t *vars, oapve_param_t *param)
750784
751785 UPDATE_A_PARAM_W_KEY_VAL (param , "tile-w" , vars -> tile_w );
752786 UPDATE_A_PARAM_W_KEY_VAL (param , "tile-h" , vars -> tile_h );
787+
788+ UPDATE_A_PARAM_W_KEY_VAL (param , "tile-w" , vars -> tile_w );
789+ UPDATE_A_PARAM_W_KEY_VAL (param , "tile-h" , vars -> tile_h );
790+
791+ UPDATE_A_PARAM_W_KEY_VAL (param , "master-display" , vars -> master_display );
792+ UPDATE_A_PARAM_W_KEY_VAL (param , "max-cll" , vars -> max_cll );
793+
753794 return 0 ;
754795}
755796
@@ -962,6 +1003,46 @@ int main(int argc, const char **argv)
9621003 ret = -1 ;
9631004 goto ERR ;
9641005 }
1006+
1007+ if (param -> mdcv_flag ) {
1008+ md_mdcv_t mdcv ;
1009+
1010+ mdcv .primary_chromaticity_x [0 ] = param -> mdcv_primary_chromaticity_x [0 ];
1011+ mdcv .primary_chromaticity_x [1 ] = param -> mdcv_primary_chromaticity_x [1 ];
1012+ mdcv .primary_chromaticity_x [2 ] = param -> mdcv_primary_chromaticity_x [2 ];
1013+
1014+ mdcv .primary_chromaticity_y [0 ] = param -> mdcv_primary_chromaticity_y [0 ];
1015+ mdcv .primary_chromaticity_y [1 ] = param -> mdcv_primary_chromaticity_y [1 ];
1016+ mdcv .primary_chromaticity_y [2 ] = param -> mdcv_primary_chromaticity_y [2 ];
1017+
1018+ mdcv .white_point_chromaticity_x = param -> mdcv_white_point_chromaticity_x ;
1019+ mdcv .white_point_chromaticity_y = param -> mdcv_white_point_chromaticity_y ;
1020+
1021+ mdcv .min_mastering_luminance = param -> mdcv_min_mastering_luminance ;
1022+ mdcv .max_mastering_luminance = param -> mdcv_max_mastering_luminance ;
1023+
1024+ void * data = & mdcv ;
1025+ size_t size = sizeof (md_mdcv_t );
1026+ if (oapvm_set (mid , 1 , OAPV_METADATA_MDCV , data , size )) {
1027+ logerr ("ERR: cannot set mastering display color metadata\n" );
1028+ ret = -1 ;
1029+ goto ERR ;
1030+ }
1031+ }
1032+
1033+ if (param -> cll_flag ) {
1034+ md_cll_t cll ;
1035+ cll .max_cll = param -> cll_max_cll ;
1036+ cll .max_fall = param -> cll_max_fall ;
1037+
1038+ void * data = & cll ;
1039+ size_t size = sizeof (md_cll_t );
1040+ if (oapvm_set (mid , 1 , OAPV_METADATA_CLL , data , size )) {
1041+ logerr ("ERR: cannot set content light level metadata\n" );
1042+ ret = -1 ;
1043+ goto ERR ;
1044+ }
1045+ }
9651046
9661047 if (set_extra_config (id , args_var , param )) {
9671048 logerr ("ERR: cannot set extra configurations\n" );
0 commit comments