v4l2-tracer: track changes from syncing with kernel
Subsystems (2)
v2 cover v4l2-tracer: track changes from syncing with kernel
This patch series aims to solve the potential breakage of the v4l2-tracer every time that v4l-utils is synced with the latest kernel headers.
Currently the v4l2-tracer autogeneration script is run by meson. If the script gets confused by changes to the latest kernel headers, then the v4l2-tracer won’t compile. And, even worse, the autogeneration script will have overwritten the autogenerated files so there is no history of the changes that broke the compilation.
This series solves the problem by adding the autogenerated files to the git repository. It stops using meson to create the files and instead, patches the v4l2-tracer whenever v4l-utils is synced with the latest kernel headers. If compilation breaks, it is easy to fix by just removing the v4l2-tracer patches before committing the other changes related to the sync.
Changes in v2:
* Use a temporary directory to store the generated files and remove it afterward.
Deborah Brouwer (4):
v4l2-tracer: autogenerate files that can be added to git
v4l2-tracer: add auto-generated files to git repo
v4l2-tracer: stop auto-generating files with meson sync-with-kernel.sh: create v4l2-tracer patches
sync-with-kernel.sh | 27 + utils/v4l2-tracer/meson.build | 55 +- utils/v4l2-tracer/retrace-gen.cpp | 5664 ++++++++++++++++++++++ utils/v4l2-tracer/retrace-gen.h | 144 + utils/v4l2-tracer/trace-gen.cpp | 3225 ++++++++++++ utils/v4l2-tracer/trace-gen.h | 144 + utils/v4l2-tracer/v4l2-tracer-gen.pl | 12 +- utils/v4l2-tracer/v4l2-tracer-info-gen.h | 2419 +++++++++ 8 files changed, 11633 insertions(+), 57 deletions(-) create mode 100644 utils/v4l2-tracer/retrace-gen.cpp create mode 100644 utils/v4l2-tracer/retrace-gen.h create mode 100644 utils/v4l2-tracer/trace-gen.cpp create mode 100644 utils/v4l2-tracer/trace-gen.h create mode 100644 utils/v4l2-tracer/v4l2-tracer-info-gen.h
Signature · 1 line
2.41.0
PATCH v2 1/4 v4l2-tracer: autogenerate files that can be added to git
A comment at the beginning of the autogenerated files provides an absolute path to the location of the autogeneration script. In preparation for adding these files to the git repository, remove this absolute path.
Also, the autogeneration script was adding an extra newline to trace-gen.cpp which was causing a whitespace warning, so remove that too.
--- utils/v4l2-tracer/v4l2-tracer-gen.pl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
utils/v4l2-tracer/v4l2-tracer-gen.pl +7 -5
@@ -865,29 +865,29 @@ sub do_open($$) { $fh_trace_cpp = do_open("trace", "trace-gen.cpp"); printf $fh_trace_cpp "/* SPDX-License-Identifier: GPL-2.0-only */\n/*\n * Copyright 2022 Collabora Ltd.\n"; -printf $fh_trace_cpp " *\n * AUTOMATICALLY GENERATED BY \'%s\' DO NOT EDIT\n */\n\n", __FILE__; +printf $fh_trace_cpp " *\n * AUTOMATICALLY GENERATED BY v4l2-tracer-gen.pl DO NOT EDIT\n */\n\n"; printf $fh_trace_cpp "#include \"v4l2-tracer-common.h\"\n\n"; $fh_trace_h = do_open("trace", "trace-gen.h"); printf $fh_trace_h "/* SPDX-License-Identifier: GPL-2.0-only */\n/*\n * Copyright 2022 Collabora Ltd.\n"; -printf $fh_trace_h " *\n * AUTOMATICALLY GENERATED BY \'%s\' DO NOT EDIT\n */\n\n", __FILE__; +printf $fh_trace_h " *\n * AUTOMATICALLY GENERATED BY v4l2-tracer-gen.pl DO NOT EDIT\n */\n\n"; printf $fh_trace_h "\#ifndef TRACE_GEN_H\n"; printf $fh_trace_h "\#define TRACE_GEN_H\n\n"; $fh_retrace_cpp = do_open("retrace", "retrace-gen.cpp"); printf $fh_retrace_cpp "/* SPDX-License-Identifier: GPL-2.0-only */\n/*\n * Copyright 2022 Collabora Ltd.\n"; -printf $fh_retrace_cpp " *\n * AUTOMATICALLY GENERATED BY \'%s\' DO NOT EDIT\n */\n\n", __FILE__; +printf $fh_retrace_cpp " *\n * AUTOMATICALLY GENERATED BY v4l2-tracer-gen.pl DO NOT EDIT\n */\n\n"; printf $fh_retrace_cpp "#include \"v4l2-tracer-common.h\"\n\n"; $fh_retrace_h = do_open("retrace", "retrace-gen.h"); printf $fh_retrace_h "/* SPDX-License-Identifier: GPL-2.0-only */\n/*\n * Copyright 2022 Collabora Ltd.\n"; -printf $fh_retrace_h " *\n * AUTOMATICALLY GENERATED BY \'%s\' DO NOT EDIT\n */\n\n", __FILE__; +printf $fh_retrace_h " *\n * AUTOMATICALLY GENERATED BY v4l2-tracer-gen.pl DO NOT EDIT\n */\n\n"; printf $fh_retrace_h "\#ifndef RETRACE_GEN_H\n"; printf $fh_retrace_h "\#define RETRACE_GEN_H\n\n"; $fh_common_info_h = do_open("common", "v4l2-tracer-info-gen.h"); printf $fh_common_info_h "/* SPDX-License-Identifier: GPL-2.0-only */\n/*\n * Copyright 2022 Collabora Ltd.\n"; -printf $fh_common_info_h " *\n * AUTOMATICALLY GENERATED BY \'%s\' DO NOT EDIT\n */\n\n", __FILE__; +printf $fh_common_info_h " *\n * AUTOMATICALLY GENERATED BY v4l2-tracer-gen.pl DO NOT EDIT\n */\n\n"; printf $fh_common_info_h "\#ifndef V4L2_TRACER_INFO_GEN_H\n"; printf $fh_common_info_h "\#define V4L2_TRACER_INFO_GEN_H\n\n"; printf $fh_common_info_h "#include \"v4l2-tracer-common.h\"\n\n";
@@ -1067,6 +1067,8 @@ printf $fh_common_info_h "\t{ -1, \"\" }\n};\n"; printf $fh_trace_h "\n#endif\n"; close $fh_trace_h; +# Delete the last of two new lines to avoid a whitespace error +truncate($fh_trace_cpp, tell($fh_trace_cpp) - 1); close $fh_trace_cpp; printf $fh_retrace_h "\n#endif\n";
Signature · 1 line
2.41.0
PATCH v2 2/4 v4l2-tracer: add auto-generated files to git repo
In reply to Deborah BrouwerAdd previously untracked files that are generated by v4l2-tracer-gen.pl. The version history makes it easy to spot errors that arise when the repository is synced with the latest kernel headers.
--- utils/v4l2-tracer/retrace-gen.cpp | 5664 ++++++++++++++++++++++ utils/v4l2-tracer/retrace-gen.h | 144 + utils/v4l2-tracer/trace-gen.cpp | 3225 ++++++++++++ utils/v4l2-tracer/trace-gen.h | 144 + utils/v4l2-tracer/v4l2-tracer-info-gen.h | 2419 +++++++++ 5 files changed, 11596 insertions(+) create mode 100644 utils/v4l2-tracer/retrace-gen.cpp create mode 100644 utils/v4l2-tracer/retrace-gen.h create mode 100644 utils/v4l2-tracer/trace-gen.cpp create mode 100644 utils/v4l2-tracer/trace-gen.h create mode 100644 utils/v4l2-tracer/v4l2-tracer-info-gen.h
utils/v4l2-tracer/retrace-gen.cpp new file +5664 -0
@@ -0,0 +1,5664 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright 2022 Collabora Ltd. + * + * AUTOMATICALLY GENERATED BY v4l2-tracer-gen.pl DO NOT EDIT + */ + +#include "v4l2-tracer-common.h" + +struct v4l2_ctrl_h264_sps *retrace_v4l2_ctrl_h264_sps_gen(json_object *ctrl_obj) +{ + struct v4l2_ctrl_h264_sps *p = (struct v4l2_ctrl_h264_sps *) calloc(1, sizeof(v4l2_ctrl_h264_sps)); + json_object *v4l2_ctrl_h264_sps_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_ctrl_h264_sps", &v4l2_ctrl_h264_sps_obj)) + v4l2_ctrl_h264_sps_obj = ctrl_obj; + + json_object *profile_idc_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_sps_obj, "profile_idc", &profile_idc_obj)) + p->profile_idc = (__u8) json_object_get_int(profile_idc_obj); + + json_object *constraint_set_flags_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_sps_obj, "constraint_set_flags", &constraint_set_flags_obj)) + p->constraint_set_flags = (__u8) s2flags(json_object_get_string(constraint_set_flags_obj), v4l2_h264_sps_flag_def); + + json_object *level_idc_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_sps_obj, "level_idc", &level_idc_obj)) + p->level_idc = (__u8) json_object_get_int(level_idc_obj); + + json_object *seq_parameter_set_id_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_sps_obj, "seq_parameter_set_id", &seq_parameter_set_id_obj)) + p->seq_parameter_set_id = (__u8) json_object_get_int(seq_parameter_set_id_obj); + + json_object *chroma_format_idc_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_sps_obj, "chroma_format_idc", &chroma_format_idc_obj)) + p->chroma_format_idc = (__u8) json_object_get_int(chroma_format_idc_obj); + + json_object *bit_depth_luma_minus8_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_sps_obj, "bit_depth_luma_minus8", &bit_depth_luma_minus8_obj)) + p->bit_depth_luma_minus8 = (__u8) json_object_get_int(bit_depth_luma_minus8_obj); + + json_object *bit_depth_chroma_minus8_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_sps_obj, "bit_depth_chroma_minus8", &bit_depth_chroma_minus8_obj)) + p->bit_depth_chroma_minus8 = (__u8) json_object_get_int(bit_depth_chroma_minus8_obj); + + json_object *log2_max_frame_num_minus4_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_sps_obj, "log2_max_frame_num_minus4", &log2_max_frame_num_minus4_obj)) + p->log2_max_frame_num_minus4 = (__u8) json_object_get_int(log2_max_frame_num_minus4_obj); + + json_object *pic_order_cnt_type_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_sps_obj, "pic_order_cnt_type", &pic_order_cnt_type_obj)) + p->pic_order_cnt_type = (__u8) json_object_get_int(pic_order_cnt_type_obj); + + json_object *log2_max_pic_order_cnt_lsb_minus4_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_sps_obj, "log2_max_pic_order_cnt_lsb_minus4", &log2_max_pic_order_cnt_lsb_minus4_obj)) + p->log2_max_pic_order_cnt_lsb_minus4 = (__u8) json_object_get_int(log2_max_pic_order_cnt_lsb_minus4_obj); + + json_object *max_num_ref_frames_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_sps_obj, "max_num_ref_frames", &max_num_ref_frames_obj)) + p->max_num_ref_frames = (__u8) json_object_get_int(max_num_ref_frames_obj); + + json_object *num_ref_frames_in_pic_order_cnt_cycle_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_sps_obj, "num_ref_frames_in_pic_order_cnt_cycle", &num_ref_frames_in_pic_order_cnt_cycle_obj)) + p->num_ref_frames_in_pic_order_cnt_cycle = (__u8) json_object_get_int(num_ref_frames_in_pic_order_cnt_cycle_obj); + + /* __s32 offset_for_ref_frame[255] */ + json_object *offset_for_ref_frame_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_sps_obj, "offset_for_ref_frame", &offset_for_ref_frame_obj)) { + for (size_t i = 0; i < 255; i++) { + if (json_object_array_get_idx(offset_for_ref_frame_obj, i)) + p->offset_for_ref_frame[i] = (__s32) json_object_get_int(json_object_array_get_idx(offset_for_ref_frame_obj, i)); + } + } + + json_object *offset_for_non_ref_pic_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_sps_obj, "offset_for_non_ref_pic", &offset_for_non_ref_pic_obj)) + p->offset_for_non_ref_pic = (__s32) json_object_get_int(offset_for_non_ref_pic_obj); + + json_object *offset_for_top_to_bottom_field_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_sps_obj, "offset_for_top_to_bottom_field", &offset_for_top_to_bottom_field_obj)) + p->offset_for_top_to_bottom_field = (__s32) json_object_get_int(offset_for_top_to_bottom_field_obj); + + json_object *pic_width_in_mbs_minus1_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_sps_obj, "pic_width_in_mbs_minus1", &pic_width_in_mbs_minus1_obj)) + p->pic_width_in_mbs_minus1 = (__u16) json_object_get_int(pic_width_in_mbs_minus1_obj); + + json_object *pic_height_in_map_units_minus1_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_sps_obj, "pic_height_in_map_units_minus1", &pic_height_in_map_units_minus1_obj)) + p->pic_height_in_map_units_minus1 = (__u16) json_object_get_int(pic_height_in_map_units_minus1_obj); + + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_sps_obj, "flags", &flags_obj)) + p->flags = (__u32) s2flags(json_object_get_string(flags_obj), v4l2_h264_sps_flag_def); + + return p; +} + +struct v4l2_ctrl_h264_pps *retrace_v4l2_ctrl_h264_pps_gen(json_object *ctrl_obj) +{ + struct v4l2_ctrl_h264_pps *p = (struct v4l2_ctrl_h264_pps *) calloc(1, sizeof(v4l2_ctrl_h264_pps)); + json_object *v4l2_ctrl_h264_pps_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_ctrl_h264_pps", &v4l2_ctrl_h264_pps_obj)) + v4l2_ctrl_h264_pps_obj = ctrl_obj; + + json_object *pic_parameter_set_id_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_pps_obj, "pic_parameter_set_id", &pic_parameter_set_id_obj)) + p->pic_parameter_set_id = (__u8) json_object_get_int(pic_parameter_set_id_obj); + + json_object *seq_parameter_set_id_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_pps_obj, "seq_parameter_set_id", &seq_parameter_set_id_obj)) + p->seq_parameter_set_id = (__u8) json_object_get_int(seq_parameter_set_id_obj); + + json_object *num_slice_groups_minus1_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_pps_obj, "num_slice_groups_minus1", &num_slice_groups_minus1_obj)) + p->num_slice_groups_minus1 = (__u8) json_object_get_int(num_slice_groups_minus1_obj); + + json_object *num_ref_idx_l0_default_active_minus1_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_pps_obj, "num_ref_idx_l0_default_active_minus1", &num_ref_idx_l0_default_active_minus1_obj)) + p->num_ref_idx_l0_default_active_minus1 = (__u8) json_object_get_int(num_ref_idx_l0_default_active_minus1_obj); + + json_object *num_ref_idx_l1_default_active_minus1_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_pps_obj, "num_ref_idx_l1_default_active_minus1", &num_ref_idx_l1_default_active_minus1_obj)) + p->num_ref_idx_l1_default_active_minus1 = (__u8) json_object_get_int(num_ref_idx_l1_default_active_minus1_obj); + + json_object *weighted_bipred_idc_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_pps_obj, "weighted_bipred_idc", &weighted_bipred_idc_obj)) + p->weighted_bipred_idc = (__u8) json_object_get_int(weighted_bipred_idc_obj); + + json_object *pic_init_qp_minus26_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_pps_obj, "pic_init_qp_minus26", &pic_init_qp_minus26_obj)) + p->pic_init_qp_minus26 = (__s8) json_object_get_int(pic_init_qp_minus26_obj); + + json_object *pic_init_qs_minus26_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_pps_obj, "pic_init_qs_minus26", &pic_init_qs_minus26_obj)) + p->pic_init_qs_minus26 = (__s8) json_object_get_int(pic_init_qs_minus26_obj); + + json_object *chroma_qp_index_offset_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_pps_obj, "chroma_qp_index_offset", &chroma_qp_index_offset_obj)) + p->chroma_qp_index_offset = (__s8) json_object_get_int(chroma_qp_index_offset_obj); + + json_object *second_chroma_qp_index_offset_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_pps_obj, "second_chroma_qp_index_offset", &second_chroma_qp_index_offset_obj)) + p->second_chroma_qp_index_offset = (__s8) json_object_get_int(second_chroma_qp_index_offset_obj); + + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_pps_obj, "flags", &flags_obj)) + p->flags = (__u16) s2flags(json_object_get_string(flags_obj), v4l2_h264_pps_flag_def); + + return p; +} + +struct v4l2_ctrl_h264_scaling_matrix *retrace_v4l2_ctrl_h264_scaling_matrix_gen(json_object *ctrl_obj) +{ + struct v4l2_ctrl_h264_scaling_matrix *p = (struct v4l2_ctrl_h264_scaling_matrix *) calloc(1, sizeof(v4l2_ctrl_h264_scaling_matrix)); + json_object *v4l2_ctrl_h264_scaling_matrix_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_ctrl_h264_scaling_matrix", &v4l2_ctrl_h264_scaling_matrix_obj)) + v4l2_ctrl_h264_scaling_matrix_obj = ctrl_obj; + + /* __u8 scaling_list_4x4[6][16] */ + int count_scaling_list_4x4 = 0; + json_object *scaling_list_4x4_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_scaling_matrix_obj, "scaling_list_4x4", &scaling_list_4x4_obj)) { + for (size_t i = 0; i < 6; i++) { + for (size_t j = 0; j < 16; j++) { + if (json_object_array_get_idx(scaling_list_4x4_obj, count_scaling_list_4x4)) + p->scaling_list_4x4[i][j] = (__u8) json_object_get_int(json_object_array_get_idx(scaling_list_4x4_obj, count_scaling_list_4x4++)); + } + } + } + + /* __u8 scaling_list_8x8[6][64] */ + int count_scaling_list_8x8 = 0; + json_object *scaling_list_8x8_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_scaling_matrix_obj, "scaling_list_8x8", &scaling_list_8x8_obj)) { + for (size_t i = 0; i < 6; i++) { + for (size_t j = 0; j < 64; j++) { + if (json_object_array_get_idx(scaling_list_8x8_obj, count_scaling_list_8x8)) + p->scaling_list_8x8[i][j] = (__u8) json_object_get_int(json_object_array_get_idx(scaling_list_8x8_obj, count_scaling_list_8x8++)); + } + } + } + + return p; +} + +struct v4l2_h264_weight_factors *retrace_v4l2_h264_weight_factors_gen(json_object *ctrl_obj) +{ + struct v4l2_h264_weight_factors *p = (struct v4l2_h264_weight_factors *) calloc(1, sizeof(v4l2_h264_weight_factors)); + json_object *v4l2_h264_weight_factors_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_h264_weight_factors", &v4l2_h264_weight_factors_obj)) + v4l2_h264_weight_factors_obj = ctrl_obj; + + /* __s16 luma_weight[32] */ + json_object *luma_weight_obj; + if (json_object_object_get_ex(v4l2_h264_weight_factors_obj, "luma_weight", &luma_weight_obj)) { + for (size_t i = 0; i < 32; i++) { + if (json_object_array_get_idx(luma_weight_obj, i)) + p->luma_weight[i] = (__s16) json_object_get_int(json_object_array_get_idx(luma_weight_obj, i)); + } + } + + /* __s16 luma_offset[32] */ + json_object *luma_offset_obj; + if (json_object_object_get_ex(v4l2_h264_weight_factors_obj, "luma_offset", &luma_offset_obj)) { + for (size_t i = 0; i < 32; i++) { + if (json_object_array_get_idx(luma_offset_obj, i)) + p->luma_offset[i] = (__s16) json_object_get_int(json_object_array_get_idx(luma_offset_obj, i)); + } + } + + /* __s16 chroma_weight[32][2] */ + int count_chroma_weight = 0; + json_object *chroma_weight_obj; + if (json_object_object_get_ex(v4l2_h264_weight_factors_obj, "chroma_weight", &chroma_weight_obj)) { + for (size_t i = 0; i < 32; i++) { + for (size_t j = 0; j < 2; j++) { + if (json_object_array_get_idx(chroma_weight_obj, count_chroma_weight)) + p->chroma_weight[i][j] = (__s16) json_object_get_int(json_object_array_get_idx(chroma_weight_obj, count_chroma_weight++)); + } + } + } + + /* __s16 chroma_offset[32][2] */ + int count_chroma_offset = 0; + json_object *chroma_offset_obj; + if (json_object_object_get_ex(v4l2_h264_weight_factors_obj, "chroma_offset", &chroma_offset_obj)) { + for (size_t i = 0; i < 32; i++) { + for (size_t j = 0; j < 2; j++) { + if (json_object_array_get_idx(chroma_offset_obj, count_chroma_offset)) + p->chroma_offset[i][j] = (__s16) json_object_get_int(json_object_array_get_idx(chroma_offset_obj, count_chroma_offset++)); + } + } + } + + return p; +} + +struct v4l2_ctrl_h264_pred_weights *retrace_v4l2_ctrl_h264_pred_weights_gen(json_object *ctrl_obj) +{ + struct v4l2_ctrl_h264_pred_weights *p = (struct v4l2_ctrl_h264_pred_weights *) calloc(1, sizeof(v4l2_ctrl_h264_pred_weights)); + json_object *v4l2_ctrl_h264_pred_weights_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_ctrl_h264_pred_weights", &v4l2_ctrl_h264_pred_weights_obj)) + v4l2_ctrl_h264_pred_weights_obj = ctrl_obj; + + json_object *luma_log2_weight_denom_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_pred_weights_obj, "luma_log2_weight_denom", &luma_log2_weight_denom_obj)) + p->luma_log2_weight_denom = (__u16) json_object_get_int(luma_log2_weight_denom_obj); + + json_object *chroma_log2_weight_denom_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_pred_weights_obj, "chroma_log2_weight_denom", &chroma_log2_weight_denom_obj)) + p->chroma_log2_weight_denom = (__u16) json_object_get_int(chroma_log2_weight_denom_obj); + + /* struct v4l2_h264_weight_factors weight_factors[2] */ + json_object *weight_factors_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_pred_weights_obj, "weight_factors", &weight_factors_obj)) { + for (size_t i = 0; i < 2; i++) { + void *weight_factors_ptr = (void *) retrace_v4l2_h264_weight_factors_gen(json_object_array_get_idx(weight_factors_obj, i)); + p->weight_factors[i] = *static_cast<struct v4l2_h264_weight_factors*>(weight_factors_ptr); + free(weight_factors_ptr); + } + } + + return p; +} + +struct v4l2_h264_reference *retrace_v4l2_h264_reference_gen(json_object *ctrl_obj) +{ + struct v4l2_h264_reference *p = (struct v4l2_h264_reference *) calloc(1, sizeof(v4l2_h264_reference)); + json_object *v4l2_h264_reference_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_h264_reference", &v4l2_h264_reference_obj)) + v4l2_h264_reference_obj = ctrl_obj; + + json_object *fields_obj; + if (json_object_object_get_ex(v4l2_h264_reference_obj, "fields", &fields_obj)) + p->fields = (__u8) json_object_get_int(fields_obj); + + json_object *index_obj; + if (json_object_object_get_ex(v4l2_h264_reference_obj, "index", &index_obj)) + p->index = (__u8) json_object_get_int(index_obj); + + return p; +} + +struct v4l2_ctrl_h264_slice_params *retrace_v4l2_ctrl_h264_slice_params_gen(json_object *ctrl_obj) +{ + struct v4l2_ctrl_h264_slice_params *p = (struct v4l2_ctrl_h264_slice_params *) calloc(1, sizeof(v4l2_ctrl_h264_slice_params)); + json_object *v4l2_ctrl_h264_slice_params_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_ctrl_h264_slice_params", &v4l2_ctrl_h264_slice_params_obj)) + v4l2_ctrl_h264_slice_params_obj = ctrl_obj; + + json_object *header_bit_size_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_slice_params_obj, "header_bit_size", &header_bit_size_obj)) + p->header_bit_size = (__u32) json_object_get_int64(header_bit_size_obj); + + json_object *first_mb_in_slice_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_slice_params_obj, "first_mb_in_slice", &first_mb_in_slice_obj)) + p->first_mb_in_slice = (__u32) json_object_get_int64(first_mb_in_slice_obj); + + json_object *slice_type_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_slice_params_obj, "slice_type", &slice_type_obj)) + p->slice_type = (__u8) json_object_get_int(slice_type_obj); + + json_object *colour_plane_id_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_slice_params_obj, "colour_plane_id", &colour_plane_id_obj)) + p->colour_plane_id = (__u8) json_object_get_int(colour_plane_id_obj); + + json_object *redundant_pic_cnt_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_slice_params_obj, "redundant_pic_cnt", &redundant_pic_cnt_obj)) + p->redundant_pic_cnt = (__u8) json_object_get_int(redundant_pic_cnt_obj); + + json_object *cabac_init_idc_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_slice_params_obj, "cabac_init_idc", &cabac_init_idc_obj)) + p->cabac_init_idc = (__u8) json_object_get_int(cabac_init_idc_obj); + + json_object *slice_qp_delta_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_slice_params_obj, "slice_qp_delta", &slice_qp_delta_obj)) + p->slice_qp_delta = (__s8) json_object_get_int(slice_qp_delta_obj); + + json_object *slice_qs_delta_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_slice_params_obj, "slice_qs_delta", &slice_qs_delta_obj)) + p->slice_qs_delta = (__s8) json_object_get_int(slice_qs_delta_obj); + + json_object *disable_deblocking_filter_idc_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_slice_params_obj, "disable_deblocking_filter_idc", &disable_deblocking_filter_idc_obj)) + p->disable_deblocking_filter_idc = (__u8) json_object_get_int(disable_deblocking_filter_idc_obj); + + json_object *slice_alpha_c0_offset_div2_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_slice_params_obj, "slice_alpha_c0_offset_div2", &slice_alpha_c0_offset_div2_obj)) + p->slice_alpha_c0_offset_div2 = (__s8) json_object_get_int(slice_alpha_c0_offset_div2_obj); + + json_object *slice_beta_offset_div2_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_slice_params_obj, "slice_beta_offset_div2", &slice_beta_offset_div2_obj)) + p->slice_beta_offset_div2 = (__s8) json_object_get_int(slice_beta_offset_div2_obj); + + json_object *num_ref_idx_l0_active_minus1_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_slice_params_obj, "num_ref_idx_l0_active_minus1", &num_ref_idx_l0_active_minus1_obj)) + p->num_ref_idx_l0_active_minus1 = (__u8) json_object_get_int(num_ref_idx_l0_active_minus1_obj); + + json_object *num_ref_idx_l1_active_minus1_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_slice_params_obj, "num_ref_idx_l1_active_minus1", &num_ref_idx_l1_active_minus1_obj)) + p->num_ref_idx_l1_active_minus1 = (__u8) json_object_get_int(num_ref_idx_l1_active_minus1_obj); + + /* struct v4l2_h264_reference ref_pic_list0[V4L2_H264_REF_LIST_LEN] */ + json_object *ref_pic_list0_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_slice_params_obj, "ref_pic_list0", &ref_pic_list0_obj)) { + for (size_t i = 0; i < V4L2_H264_REF_LIST_LEN; i++) { + void *ref_pic_list0_ptr = (void *) retrace_v4l2_h264_reference_gen(json_object_array_get_idx(ref_pic_list0_obj, i)); + p->ref_pic_list0[i] = *static_cast<struct v4l2_h264_reference*>(ref_pic_list0_ptr); + free(ref_pic_list0_ptr); + } + } + + /* struct v4l2_h264_reference ref_pic_list1[V4L2_H264_REF_LIST_LEN] */ + json_object *ref_pic_list1_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_slice_params_obj, "ref_pic_list1", &ref_pic_list1_obj)) { + for (size_t i = 0; i < V4L2_H264_REF_LIST_LEN; i++) { + void *ref_pic_list1_ptr = (void *) retrace_v4l2_h264_reference_gen(json_object_array_get_idx(ref_pic_list1_obj, i)); + p->ref_pic_list1[i] = *static_cast<struct v4l2_h264_reference*>(ref_pic_list1_ptr); + free(ref_pic_list1_ptr); + } + } + + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_slice_params_obj, "flags", &flags_obj)) + p->flags = (__u32) s2flags(json_object_get_string(flags_obj), v4l2_h264_slice_flag_def); + + return p; +} + +struct v4l2_h264_dpb_entry *retrace_v4l2_h264_dpb_entry_gen(json_object *ctrl_obj) +{ + struct v4l2_h264_dpb_entry *p = (struct v4l2_h264_dpb_entry *) calloc(1, sizeof(v4l2_h264_dpb_entry)); + json_object *v4l2_h264_dpb_entry_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_h264_dpb_entry", &v4l2_h264_dpb_entry_obj)) + v4l2_h264_dpb_entry_obj = ctrl_obj; + + json_object *reference_ts_obj; + if (json_object_object_get_ex(v4l2_h264_dpb_entry_obj, "reference_ts", &reference_ts_obj)) + p->reference_ts = (__u64) json_object_get_uint64(reference_ts_obj); + + json_object *pic_num_obj; + if (json_object_object_get_ex(v4l2_h264_dpb_entry_obj, "pic_num", &pic_num_obj)) + p->pic_num = (__u32) json_object_get_int64(pic_num_obj); + + json_object *frame_num_obj; + if (json_object_object_get_ex(v4l2_h264_dpb_entry_obj, "frame_num", &frame_num_obj)) + p->frame_num = (__u16) json_object_get_int(frame_num_obj); + + json_object *fields_obj; + if (json_object_object_get_ex(v4l2_h264_dpb_entry_obj, "fields", &fields_obj)) + p->fields = (__u8) json_object_get_int(fields_obj); + + json_object *top_field_order_cnt_obj; + if (json_object_object_get_ex(v4l2_h264_dpb_entry_obj, "top_field_order_cnt", &top_field_order_cnt_obj)) + p->top_field_order_cnt = (__s32) json_object_get_int(top_field_order_cnt_obj); + + json_object *bottom_field_order_cnt_obj; + if (json_object_object_get_ex(v4l2_h264_dpb_entry_obj, "bottom_field_order_cnt", &bottom_field_order_cnt_obj)) + p->bottom_field_order_cnt = (__s32) json_object_get_int(bottom_field_order_cnt_obj); + + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_h264_dpb_entry_obj, "flags", &flags_obj)) + p->flags = (__u32) s2flags(json_object_get_string(flags_obj), v4l2_h264_dpb_entry_flag_def); + + return p; +} + +struct v4l2_ctrl_h264_decode_params *retrace_v4l2_ctrl_h264_decode_params_gen(json_object *ctrl_obj) +{ + struct v4l2_ctrl_h264_decode_params *p = (struct v4l2_ctrl_h264_decode_params *) calloc(1, sizeof(v4l2_ctrl_h264_decode_params)); + json_object *v4l2_ctrl_h264_decode_params_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_ctrl_h264_decode_params", &v4l2_ctrl_h264_decode_params_obj)) + v4l2_ctrl_h264_decode_params_obj = ctrl_obj; + + /* struct v4l2_h264_dpb_entry dpb[V4L2_H264_NUM_DPB_ENTRIES] */ + json_object *dpb_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_decode_params_obj, "dpb", &dpb_obj)) { + for (size_t i = 0; i < V4L2_H264_NUM_DPB_ENTRIES; i++) { + void *dpb_ptr = (void *) retrace_v4l2_h264_dpb_entry_gen(json_object_array_get_idx(dpb_obj, i)); + p->dpb[i] = *static_cast<struct v4l2_h264_dpb_entry*>(dpb_ptr); + free(dpb_ptr); + } + } + + json_object *nal_ref_idc_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_decode_params_obj, "nal_ref_idc", &nal_ref_idc_obj)) + p->nal_ref_idc = (__u16) json_object_get_int(nal_ref_idc_obj); + + json_object *frame_num_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_decode_params_obj, "frame_num", &frame_num_obj)) + p->frame_num = (__u16) json_object_get_int(frame_num_obj); + + json_object *top_field_order_cnt_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_decode_params_obj, "top_field_order_cnt", &top_field_order_cnt_obj)) + p->top_field_order_cnt = (__s32) json_object_get_int(top_field_order_cnt_obj); + + json_object *bottom_field_order_cnt_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_decode_params_obj, "bottom_field_order_cnt", &bottom_field_order_cnt_obj)) + p->bottom_field_order_cnt = (__s32) json_object_get_int(bottom_field_order_cnt_obj); + + json_object *idr_pic_id_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_decode_params_obj, "idr_pic_id", &idr_pic_id_obj)) + p->idr_pic_id = (__u16) json_object_get_int(idr_pic_id_obj); + + json_object *pic_order_cnt_lsb_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_decode_params_obj, "pic_order_cnt_lsb", &pic_order_cnt_lsb_obj)) + p->pic_order_cnt_lsb = (__u16) json_object_get_int(pic_order_cnt_lsb_obj); + + json_object *delta_pic_order_cnt_bottom_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_decode_params_obj, "delta_pic_order_cnt_bottom", &delta_pic_order_cnt_bottom_obj)) + p->delta_pic_order_cnt_bottom = (__s32) json_object_get_int(delta_pic_order_cnt_bottom_obj); + + json_object *delta_pic_order_cnt0_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_decode_params_obj, "delta_pic_order_cnt0", &delta_pic_order_cnt0_obj)) + p->delta_pic_order_cnt0 = (__s32) json_object_get_int(delta_pic_order_cnt0_obj); + + json_object *delta_pic_order_cnt1_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_decode_params_obj, "delta_pic_order_cnt1", &delta_pic_order_cnt1_obj)) + p->delta_pic_order_cnt1 = (__s32) json_object_get_int(delta_pic_order_cnt1_obj); + + json_object *dec_ref_pic_marking_bit_size_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_decode_params_obj, "dec_ref_pic_marking_bit_size", &dec_ref_pic_marking_bit_size_obj)) + p->dec_ref_pic_marking_bit_size = (__u32) json_object_get_int64(dec_ref_pic_marking_bit_size_obj); + + json_object *pic_order_cnt_bit_size_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_decode_params_obj, "pic_order_cnt_bit_size", &pic_order_cnt_bit_size_obj)) + p->pic_order_cnt_bit_size = (__u32) json_object_get_int64(pic_order_cnt_bit_size_obj); + + json_object *slice_group_change_cycle_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_decode_params_obj, "slice_group_change_cycle", &slice_group_change_cycle_obj)) + p->slice_group_change_cycle = (__u32) json_object_get_int64(slice_group_change_cycle_obj); + + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_ctrl_h264_decode_params_obj, "flags", &flags_obj)) + p->flags = (__u32) s2flags(json_object_get_string(flags_obj), v4l2_h264_decode_param_flag_def); + + return p; +} + +struct v4l2_ctrl_fwht_params *retrace_v4l2_ctrl_fwht_params_gen(json_object *ctrl_obj) +{ + struct v4l2_ctrl_fwht_params *p = (struct v4l2_ctrl_fwht_params *) calloc(1, sizeof(v4l2_ctrl_fwht_params)); + json_object *v4l2_ctrl_fwht_params_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_ctrl_fwht_params", &v4l2_ctrl_fwht_params_obj)) + v4l2_ctrl_fwht_params_obj = ctrl_obj; + + json_object *backward_ref_ts_obj; + if (json_object_object_get_ex(v4l2_ctrl_fwht_params_obj, "backward_ref_ts", &backward_ref_ts_obj)) + p->backward_ref_ts = (__u64) json_object_get_uint64(backward_ref_ts_obj); + + json_object *version_obj; + if (json_object_object_get_ex(v4l2_ctrl_fwht_params_obj, "version", &version_obj)) + p->version = (__u32) json_object_get_int64(version_obj); + + json_object *width_obj; + if (json_object_object_get_ex(v4l2_ctrl_fwht_params_obj, "width", &width_obj)) + p->width = (__u32) json_object_get_int64(width_obj); + + json_object *height_obj; + if (json_object_object_get_ex(v4l2_ctrl_fwht_params_obj, "height", &height_obj)) + p->height = (__u32) json_object_get_int64(height_obj); + + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_ctrl_fwht_params_obj, "flags", &flags_obj)) + p->flags = (__u32) s2flags_fwht(json_object_get_string(flags_obj)); + + json_object *colorspace_obj; + if (json_object_object_get_ex(v4l2_ctrl_fwht_params_obj, "colorspace", &colorspace_obj)) + p->colorspace = (__u32) s2val(json_object_get_string(colorspace_obj), v4l2_colorspace_val_def); + + json_object *xfer_func_obj; + if (json_object_object_get_ex(v4l2_ctrl_fwht_params_obj, "xfer_func", &xfer_func_obj)) + p->xfer_func = (__u32) s2val(json_object_get_string(xfer_func_obj), v4l2_xfer_func_val_def); + + json_object *ycbcr_enc_obj; + if (json_object_object_get_ex(v4l2_ctrl_fwht_params_obj, "ycbcr_enc", &ycbcr_enc_obj)) + p->ycbcr_enc = (__u32) s2val(json_object_get_string(ycbcr_enc_obj), v4l2_ycbcr_encoding_val_def); + + json_object *quantization_obj; + if (json_object_object_get_ex(v4l2_ctrl_fwht_params_obj, "quantization", &quantization_obj)) + p->quantization = (__u32) s2val(json_object_get_string(quantization_obj), v4l2_quantization_val_def); + + return p; +} + +struct v4l2_vp8_segment *retrace_v4l2_vp8_segment_gen(json_object *ctrl_obj) +{ + struct v4l2_vp8_segment *p = (struct v4l2_vp8_segment *) calloc(1, sizeof(v4l2_vp8_segment)); + json_object *v4l2_vp8_segment_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_vp8_segment", &v4l2_vp8_segment_obj)) + v4l2_vp8_segment_obj = ctrl_obj; + + /* __s8 quant_update[4] */ + json_object *quant_update_obj; + if (json_object_object_get_ex(v4l2_vp8_segment_obj, "quant_update", &quant_update_obj)) { + for (size_t i = 0; i < 4; i++) { + if (json_object_array_get_idx(quant_update_obj, i)) + p->quant_update[i] = (__s8) json_object_get_int(json_object_array_get_idx(quant_update_obj, i)); + } + } + + /* __s8 lf_update[4] */ + json_object *lf_update_obj; + if (json_object_object_get_ex(v4l2_vp8_segment_obj, "lf_update", &lf_update_obj)) { + for (size_t i = 0; i < 4; i++) { + if (json_object_array_get_idx(lf_update_obj, i)) + p->lf_update[i] = (__s8) json_object_get_int(json_object_array_get_idx(lf_update_obj, i)); + } + } + + /* __u8 segment_probs[3] */ + json_object *segment_probs_obj; + if (json_object_object_get_ex(v4l2_vp8_segment_obj, "segment_probs", &segment_probs_obj)) { + for (size_t i = 0; i < 3; i++) { + if (json_object_array_get_idx(segment_probs_obj, i)) + p->segment_probs[i] = (__u8) json_object_get_int(json_object_array_get_idx(segment_probs_obj, i)); + } + } + + json_object *padding_obj; + if (json_object_object_get_ex(v4l2_vp8_segment_obj, "padding", &padding_obj)) + p->padding = (__u8) json_object_get_int(padding_obj); + + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_vp8_segment_obj, "flags", &flags_obj)) + p->flags = (__u32) s2flags(json_object_get_string(flags_obj), v4l2_vp8_segment_flag_def); + + return p; +} + +struct v4l2_vp8_loop_filter *retrace_v4l2_vp8_loop_filter_gen(json_object *ctrl_obj) +{ + struct v4l2_vp8_loop_filter *p = (struct v4l2_vp8_loop_filter *) calloc(1, sizeof(v4l2_vp8_loop_filter)); + json_object *v4l2_vp8_loop_filter_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_vp8_loop_filter", &v4l2_vp8_loop_filter_obj)) + v4l2_vp8_loop_filter_obj = ctrl_obj; + + /* __s8 ref_frm_delta[4] */ + json_object *ref_frm_delta_obj; + if (json_object_object_get_ex(v4l2_vp8_loop_filter_obj, "ref_frm_delta", &ref_frm_delta_obj)) { + for (size_t i = 0; i < 4; i++) { + if (json_object_array_get_idx(ref_frm_delta_obj, i)) + p->ref_frm_delta[i] = (__s8) json_object_get_int(json_object_array_get_idx(ref_frm_delta_obj, i)); + } + } + + /* __s8 mb_mode_delta[4] */ + json_object *mb_mode_delta_obj; + if (json_object_object_get_ex(v4l2_vp8_loop_filter_obj, "mb_mode_delta", &mb_mode_delta_obj)) { + for (size_t i = 0; i < 4; i++) { + if (json_object_array_get_idx(mb_mode_delta_obj, i)) + p->mb_mode_delta[i] = (__s8) json_object_get_int(json_object_array_get_idx(mb_mode_delta_obj, i)); + } + } + + json_object *sharpness_level_obj; + if (json_object_object_get_ex(v4l2_vp8_loop_filter_obj, "sharpness_level", &sharpness_level_obj)) + p->sharpness_level = (__u8) json_object_get_int(sharpness_level_obj); + + json_object *level_obj; + if (json_object_object_get_ex(v4l2_vp8_loop_filter_obj, "level", &level_obj)) + p->level = (__u8) json_object_get_int(level_obj); + + json_object *padding_obj; + if (json_object_object_get_ex(v4l2_vp8_loop_filter_obj, "padding", &padding_obj)) + p->padding = (__u16) json_object_get_int(padding_obj); + + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_vp8_loop_filter_obj, "flags", &flags_obj)) + p->flags = (__u32) s2flags(json_object_get_string(flags_obj), v4l2_vp8_loop_filter_flag_def); + + return p; +} + +struct v4l2_vp8_quantization *retrace_v4l2_vp8_quantization_gen(json_object *ctrl_obj) +{ + struct v4l2_vp8_quantization *p = (struct v4l2_vp8_quantization *) calloc(1, sizeof(v4l2_vp8_quantization)); + json_object *v4l2_vp8_quantization_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_vp8_quantization", &v4l2_vp8_quantization_obj)) + v4l2_vp8_quantization_obj = ctrl_obj; + + json_object *y_ac_qi_obj; + if (json_object_object_get_ex(v4l2_vp8_quantization_obj, "y_ac_qi", &y_ac_qi_obj)) + p->y_ac_qi = (__u8) json_object_get_int(y_ac_qi_obj); + + json_object *y_dc_delta_obj; + if (json_object_object_get_ex(v4l2_vp8_quantization_obj, "y_dc_delta", &y_dc_delta_obj)) + p->y_dc_delta = (__s8) json_object_get_int(y_dc_delta_obj); + + json_object *y2_dc_delta_obj; + if (json_object_object_get_ex(v4l2_vp8_quantization_obj, "y2_dc_delta", &y2_dc_delta_obj)) + p->y2_dc_delta = (__s8) json_object_get_int(y2_dc_delta_obj); + + json_object *y2_ac_delta_obj; + if (json_object_object_get_ex(v4l2_vp8_quantization_obj, "y2_ac_delta", &y2_ac_delta_obj)) + p->y2_ac_delta = (__s8) json_object_get_int(y2_ac_delta_obj); + + json_object *uv_dc_delta_obj; + if (json_object_object_get_ex(v4l2_vp8_quantization_obj, "uv_dc_delta", &uv_dc_delta_obj)) + p->uv_dc_delta = (__s8) json_object_get_int(uv_dc_delta_obj); + + json_object *uv_ac_delta_obj; + if (json_object_object_get_ex(v4l2_vp8_quantization_obj, "uv_ac_delta", &uv_ac_delta_obj)) + p->uv_ac_delta = (__s8) json_object_get_int(uv_ac_delta_obj); + + json_object *padding_obj; + if (json_object_object_get_ex(v4l2_vp8_quantization_obj, "padding", &padding_obj)) + p->padding = (__u16) json_object_get_int(padding_obj); + + return p; +} + +struct v4l2_vp8_entropy *retrace_v4l2_vp8_entropy_gen(json_object *ctrl_obj) +{ + struct v4l2_vp8_entropy *p = (struct v4l2_vp8_entropy *) calloc(1, sizeof(v4l2_vp8_entropy)); + json_object *v4l2_vp8_entropy_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_vp8_entropy", &v4l2_vp8_entropy_obj)) + v4l2_vp8_entropy_obj = ctrl_obj; + + /* __u8 coeff_probs[4][8][3][V4L2_VP8_COEFF_PROB_CNT] */ + int count_coeff_probs = 0; + json_object *coeff_probs_obj; + if (json_object_object_get_ex(v4l2_vp8_entropy_obj, "coeff_probs", &coeff_probs_obj)) { + for (size_t i = 0; i < 4; i++) { + for (size_t j = 0; j < 8; j++) { + for (size_t k = 0; k < 3; k++) { + for (size_t l = 0; l < V4L2_VP8_COEFF_PROB_CNT; l++) { + if (json_object_array_get_idx(coeff_probs_obj, count_coeff_probs)) + p->coeff_probs[i][j][k][l] = (__u8) json_object_get_int(json_object_array_get_idx(coeff_probs_obj, count_coeff_probs++)); + } + } + } + } + } + + /* __u8 y_mode_probs[4] */ + json_object *y_mode_probs_obj; + if (json_object_object_get_ex(v4l2_vp8_entropy_obj, "y_mode_probs", &y_mode_probs_obj)) { + for (size_t i = 0; i < 4; i++) { + if (json_object_array_get_idx(y_mode_probs_obj, i)) + p->y_mode_probs[i] = (__u8) json_object_get_int(json_object_array_get_idx(y_mode_probs_obj, i)); + } + } + + /* __u8 uv_mode_probs[3] */ + json_object *uv_mode_probs_obj; + if (json_object_object_get_ex(v4l2_vp8_entropy_obj, "uv_mode_probs", &uv_mode_probs_obj)) { + for (size_t i = 0; i < 3; i++) { + if (json_object_array_get_idx(uv_mode_probs_obj, i)) + p->uv_mode_probs[i] = (__u8) json_object_get_int(json_object_array_get_idx(uv_mode_probs_obj, i)); + } + } + + /* __u8 mv_probs[2][V4L2_VP8_MV_PROB_CNT] */ + int count_mv_probs = 0; + json_object *mv_probs_obj; + if (json_object_object_get_ex(v4l2_vp8_entropy_obj, "mv_probs", &mv_probs_obj)) { + for (size_t i = 0; i < 2; i++) { + for (size_t j = 0; j < V4L2_VP8_MV_PROB_CNT; j++) { + if (json_object_array_get_idx(mv_probs_obj, count_mv_probs)) + p->mv_probs[i][j] = (__u8) json_object_get_int(json_object_array_get_idx(mv_probs_obj, count_mv_probs++)); + } + } + } + + /* __u8 padding[3] */ + json_object *padding_obj; + if (json_object_object_get_ex(v4l2_vp8_entropy_obj, "padding", &padding_obj)) { + for (size_t i = 0; i < 3; i++) { + if (json_object_array_get_idx(padding_obj, i)) + p->padding[i] = (__u8) json_object_get_int(json_object_array_get_idx(padding_obj, i)); + } + } + + return p; +} + +struct v4l2_vp8_entropy_coder_state *retrace_v4l2_vp8_entropy_coder_state_gen(json_object *ctrl_obj) +{ + struct v4l2_vp8_entropy_coder_state *p = (struct v4l2_vp8_entropy_coder_state *) calloc(1, sizeof(v4l2_vp8_entropy_coder_state)); + json_object *v4l2_vp8_entropy_coder_state_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_vp8_entropy_coder_state", &v4l2_vp8_entropy_coder_state_obj)) + v4l2_vp8_entropy_coder_state_obj = ctrl_obj; + + json_object *range_obj; + if (json_object_object_get_ex(v4l2_vp8_entropy_coder_state_obj, "range", &range_obj)) + p->range = (__u8) json_object_get_int(range_obj); + + json_object *value_obj; + if (json_object_object_get_ex(v4l2_vp8_entropy_coder_state_obj, "value", &value_obj)) + p->value = (__u8) json_object_get_int(value_obj); + + json_object *bit_count_obj; + if (json_object_object_get_ex(v4l2_vp8_entropy_coder_state_obj, "bit_count", &bit_count_obj)) + p->bit_count = (__u8) json_object_get_int(bit_count_obj); + + json_object *padding_obj; + if (json_object_object_get_ex(v4l2_vp8_entropy_coder_state_obj, "padding", &padding_obj)) + p->padding = (__u8) json_object_get_int(padding_obj); + + return p; +} + +struct v4l2_ctrl_vp8_frame *retrace_v4l2_ctrl_vp8_frame_gen(json_object *ctrl_obj) +{ + struct v4l2_ctrl_vp8_frame *p = (struct v4l2_ctrl_vp8_frame *) calloc(1, sizeof(v4l2_ctrl_vp8_frame)); + json_object *v4l2_ctrl_vp8_frame_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_ctrl_vp8_frame", &v4l2_ctrl_vp8_frame_obj)) + v4l2_ctrl_vp8_frame_obj = ctrl_obj; + + /* struct v4l2_vp8_segment segment */ + json_object *segment_obj; + if (!json_object_object_get_ex(v4l2_ctrl_vp8_frame_obj, "v4l2_vp8_segment", &segment_obj)) + return p; + void *segment_ptr = (void *) retrace_v4l2_vp8_segment_gen(segment_obj); + p->segment = *static_cast<struct v4l2_vp8_segment*>(segment_ptr); + free(segment_ptr); + + /* struct v4l2_vp8_loop_filter lf */ + json_object *lf_obj; + if (!json_object_object_get_ex(v4l2_ctrl_vp8_frame_obj, "v4l2_vp8_loop_filter", &lf_obj)) + return p; + void *lf_ptr = (void *) retrace_v4l2_vp8_loop_filter_gen(lf_obj); + p->lf = *static_cast<struct v4l2_vp8_loop_filter*>(lf_ptr); + free(lf_ptr); + + /* struct v4l2_vp8_quantization quant */ + json_object *quant_obj; + if (!json_object_object_get_ex(v4l2_ctrl_vp8_frame_obj, "v4l2_vp8_quantization", &quant_obj)) + return p; + void *quant_ptr = (void *) retrace_v4l2_vp8_quantization_gen(quant_obj); + p->quant = *static_cast<struct v4l2_vp8_quantization*>(quant_ptr); + free(quant_ptr); + + /* struct v4l2_vp8_entropy entropy */ + json_object *entropy_obj; + if (!json_object_object_get_ex(v4l2_ctrl_vp8_frame_obj, "v4l2_vp8_entropy", &entropy_obj)) + return p; + void *entropy_ptr = (void *) retrace_v4l2_vp8_entropy_gen(entropy_obj); + p->entropy = *static_cast<struct v4l2_vp8_entropy*>(entropy_ptr); + free(entropy_ptr); + + /* struct v4l2_vp8_entropy_coder_state coder_state */ + json_object *coder_state_obj; + if (!json_object_object_get_ex(v4l2_ctrl_vp8_frame_obj, "v4l2_vp8_entropy_coder_state", &coder_state_obj)) + return p; + void *coder_state_ptr = (void *) retrace_v4l2_vp8_entropy_coder_state_gen(coder_state_obj); + p->coder_state = *static_cast<struct v4l2_vp8_entropy_coder_state*>(coder_state_ptr); + free(coder_state_ptr); + + json_object *width_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp8_frame_obj, "width", &width_obj)) + p->width = (__u16) json_object_get_int(width_obj); + + json_object *height_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp8_frame_obj, "height", &height_obj)) + p->height = (__u16) json_object_get_int(height_obj); + + json_object *horizontal_scale_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp8_frame_obj, "horizontal_scale", &horizontal_scale_obj)) + p->horizontal_scale = (__u8) json_object_get_int(horizontal_scale_obj); + + json_object *vertical_scale_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp8_frame_obj, "vertical_scale", &vertical_scale_obj)) + p->vertical_scale = (__u8) json_object_get_int(vertical_scale_obj); + + json_object *version_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp8_frame_obj, "version", &version_obj)) + p->version = (__u8) json_object_get_int(version_obj); + + json_object *prob_skip_false_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp8_frame_obj, "prob_skip_false", &prob_skip_false_obj)) + p->prob_skip_false = (__u8) json_object_get_int(prob_skip_false_obj); + + json_object *prob_intra_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp8_frame_obj, "prob_intra", &prob_intra_obj)) + p->prob_intra = (__u8) json_object_get_int(prob_intra_obj); + + json_object *prob_last_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp8_frame_obj, "prob_last", &prob_last_obj)) + p->prob_last = (__u8) json_object_get_int(prob_last_obj); + + json_object *prob_gf_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp8_frame_obj, "prob_gf", &prob_gf_obj)) + p->prob_gf = (__u8) json_object_get_int(prob_gf_obj); + + json_object *num_dct_parts_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp8_frame_obj, "num_dct_parts", &num_dct_parts_obj)) + p->num_dct_parts = (__u8) json_object_get_int(num_dct_parts_obj); + + json_object *first_part_size_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp8_frame_obj, "first_part_size", &first_part_size_obj)) + p->first_part_size = (__u32) json_object_get_int64(first_part_size_obj); + + json_object *first_part_header_bits_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp8_frame_obj, "first_part_header_bits", &first_part_header_bits_obj)) + p->first_part_header_bits = (__u32) json_object_get_int64(first_part_header_bits_obj); + + /* __u32 dct_part_sizes[8] */ + json_object *dct_part_sizes_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp8_frame_obj, "dct_part_sizes", &dct_part_sizes_obj)) { + for (size_t i = 0; i < 8; i++) { + if (json_object_array_get_idx(dct_part_sizes_obj, i)) + p->dct_part_sizes[i] = (__u32) json_object_get_int64(json_object_array_get_idx(dct_part_sizes_obj, i)); + } + } + + json_object *last_frame_ts_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp8_frame_obj, "last_frame_ts", &last_frame_ts_obj)) + p->last_frame_ts = (__u64) json_object_get_uint64(last_frame_ts_obj); + + json_object *golden_frame_ts_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp8_frame_obj, "golden_frame_ts", &golden_frame_ts_obj)) + p->golden_frame_ts = (__u64) json_object_get_uint64(golden_frame_ts_obj); + + json_object *alt_frame_ts_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp8_frame_obj, "alt_frame_ts", &alt_frame_ts_obj)) + p->alt_frame_ts = (__u64) json_object_get_uint64(alt_frame_ts_obj); + + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp8_frame_obj, "flags", &flags_obj)) + p->flags = (__u64) s2flags(json_object_get_string(flags_obj), v4l2_vp8_frame_flag_def); + + return p; +} + +struct v4l2_ctrl_mpeg2_sequence *retrace_v4l2_ctrl_mpeg2_sequence_gen(json_object *ctrl_obj) +{ + struct v4l2_ctrl_mpeg2_sequence *p = (struct v4l2_ctrl_mpeg2_sequence *) calloc(1, sizeof(v4l2_ctrl_mpeg2_sequence)); + json_object *v4l2_ctrl_mpeg2_sequence_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_ctrl_mpeg2_sequence", &v4l2_ctrl_mpeg2_sequence_obj)) + v4l2_ctrl_mpeg2_sequence_obj = ctrl_obj; + + json_object *horizontal_size_obj; + if (json_object_object_get_ex(v4l2_ctrl_mpeg2_sequence_obj, "horizontal_size", &horizontal_size_obj)) + p->horizontal_size = (__u16) json_object_get_int(horizontal_size_obj); + + json_object *vertical_size_obj; + if (json_object_object_get_ex(v4l2_ctrl_mpeg2_sequence_obj, "vertical_size", &vertical_size_obj)) + p->vertical_size = (__u16) json_object_get_int(vertical_size_obj); + + json_object *vbv_buffer_size_obj; + if (json_object_object_get_ex(v4l2_ctrl_mpeg2_sequence_obj, "vbv_buffer_size", &vbv_buffer_size_obj)) + p->vbv_buffer_size = (__u32) json_object_get_int64(vbv_buffer_size_obj); + + json_object *profile_and_level_indication_obj; + if (json_object_object_get_ex(v4l2_ctrl_mpeg2_sequence_obj, "profile_and_level_indication", &profile_and_level_indication_obj)) + p->profile_and_level_indication = (__u16) json_object_get_int(profile_and_level_indication_obj); + + json_object *chroma_format_obj; + if (json_object_object_get_ex(v4l2_ctrl_mpeg2_sequence_obj, "chroma_format", &chroma_format_obj)) + p->chroma_format = (__u8) json_object_get_int(chroma_format_obj); + + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_ctrl_mpeg2_sequence_obj, "flags", &flags_obj)) + p->flags = (__u8) s2flags(json_object_get_string(flags_obj), v4l2_mpeg2_seq_flag_def); + + return p; +} + +struct v4l2_ctrl_mpeg2_picture *retrace_v4l2_ctrl_mpeg2_picture_gen(json_object *ctrl_obj) +{ + struct v4l2_ctrl_mpeg2_picture *p = (struct v4l2_ctrl_mpeg2_picture *) calloc(1, sizeof(v4l2_ctrl_mpeg2_picture)); + json_object *v4l2_ctrl_mpeg2_picture_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_ctrl_mpeg2_picture", &v4l2_ctrl_mpeg2_picture_obj)) + v4l2_ctrl_mpeg2_picture_obj = ctrl_obj; + + json_object *backward_ref_ts_obj; + if (json_object_object_get_ex(v4l2_ctrl_mpeg2_picture_obj, "backward_ref_ts", &backward_ref_ts_obj)) + p->backward_ref_ts = (__u64) json_object_get_uint64(backward_ref_ts_obj); + + json_object *forward_ref_ts_obj; + if (json_object_object_get_ex(v4l2_ctrl_mpeg2_picture_obj, "forward_ref_ts", &forward_ref_ts_obj)) + p->forward_ref_ts = (__u64) json_object_get_uint64(forward_ref_ts_obj); + + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_ctrl_mpeg2_picture_obj, "flags", &flags_obj)) + p->flags = (__u32) s2flags(json_object_get_string(flags_obj), v4l2_mpeg2_pic_flag_def); + + /* __u8 f_code[2][2] */ + int count_f_code = 0; + json_object *f_code_obj; + if (json_object_object_get_ex(v4l2_ctrl_mpeg2_picture_obj, "f_code", &f_code_obj)) { + for (size_t i = 0; i < 2; i++) { + for (size_t j = 0; j < 2; j++) { + if (json_object_array_get_idx(f_code_obj, count_f_code)) + p->f_code[i][j] = (__u8) json_object_get_int(json_object_array_get_idx(f_code_obj, count_f_code++)); + } + } + } + + json_object *picture_coding_type_obj; + if (json_object_object_get_ex(v4l2_ctrl_mpeg2_picture_obj, "picture_coding_type", &picture_coding_type_obj)) + p->picture_coding_type = (__u8) json_object_get_int(picture_coding_type_obj); + + json_object *picture_structure_obj; + if (json_object_object_get_ex(v4l2_ctrl_mpeg2_picture_obj, "picture_structure", &picture_structure_obj)) + p->picture_structure = (__u8) json_object_get_int(picture_structure_obj); + + json_object *intra_dc_precision_obj; + if (json_object_object_get_ex(v4l2_ctrl_mpeg2_picture_obj, "intra_dc_precision", &intra_dc_precision_obj)) + p->intra_dc_precision = (__u8) json_object_get_int(intra_dc_precision_obj); + + return p; +} + +struct v4l2_ctrl_mpeg2_quantisation *retrace_v4l2_ctrl_mpeg2_quantisation_gen(json_object *ctrl_obj) +{ + struct v4l2_ctrl_mpeg2_quantisation *p = (struct v4l2_ctrl_mpeg2_quantisation *) calloc(1, sizeof(v4l2_ctrl_mpeg2_quantisation)); + json_object *v4l2_ctrl_mpeg2_quantisation_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_ctrl_mpeg2_quantisation", &v4l2_ctrl_mpeg2_quantisation_obj)) + v4l2_ctrl_mpeg2_quantisation_obj = ctrl_obj; + + /* __u8 intra_quantiser_matrix[64] */ + json_object *intra_quantiser_matrix_obj; + if (json_object_object_get_ex(v4l2_ctrl_mpeg2_quantisation_obj, "intra_quantiser_matrix", &intra_quantiser_matrix_obj)) { + for (size_t i = 0; i < 64; i++) { + if (json_object_array_get_idx(intra_quantiser_matrix_obj, i)) + p->intra_quantiser_matrix[i] = (__u8) json_object_get_int(json_object_array_get_idx(intra_quantiser_matrix_obj, i)); + } + } + + /* __u8 non_intra_quantiser_matrix[64] */ + json_object *non_intra_quantiser_matrix_obj; + if (json_object_object_get_ex(v4l2_ctrl_mpeg2_quantisation_obj, "non_intra_quantiser_matrix", &non_intra_quantiser_matrix_obj)) { + for (size_t i = 0; i < 64; i++) { + if (json_object_array_get_idx(non_intra_quantiser_matrix_obj, i)) + p->non_intra_quantiser_matrix[i] = (__u8) json_object_get_int(json_object_array_get_idx(non_intra_quantiser_matrix_obj, i)); + } + } + + /* __u8 chroma_intra_quantiser_matrix[64] */ + json_object *chroma_intra_quantiser_matrix_obj; + if (json_object_object_get_ex(v4l2_ctrl_mpeg2_quantisation_obj, "chroma_intra_quantiser_matrix", &chroma_intra_quantiser_matrix_obj)) { + for (size_t i = 0; i < 64; i++) { + if (json_object_array_get_idx(chroma_intra_quantiser_matrix_obj, i)) + p->chroma_intra_quantiser_matrix[i] = (__u8) json_object_get_int(json_object_array_get_idx(chroma_intra_quantiser_matrix_obj, i)); + } + } + + /* __u8 chroma_non_intra_quantiser_matrix[64] */ + json_object *chroma_non_intra_quantiser_matrix_obj; + if (json_object_object_get_ex(v4l2_ctrl_mpeg2_quantisation_obj, "chroma_non_intra_quantiser_matrix", &chroma_non_intra_quantiser_matrix_obj)) { + for (size_t i = 0; i < 64; i++) { + if (json_object_array_get_idx(chroma_non_intra_quantiser_matrix_obj, i)) + p->chroma_non_intra_quantiser_matrix[i] = (__u8) json_object_get_int(json_object_array_get_idx(chroma_non_intra_quantiser_matrix_obj, i)); + } + } + + return p; +} + +struct v4l2_ctrl_hevc_sps *retrace_v4l2_ctrl_hevc_sps_gen(json_object *ctrl_obj) +{ + struct v4l2_ctrl_hevc_sps *p = (struct v4l2_ctrl_hevc_sps *) calloc(1, sizeof(v4l2_ctrl_hevc_sps)); + json_object *v4l2_ctrl_hevc_sps_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_ctrl_hevc_sps", &v4l2_ctrl_hevc_sps_obj)) + v4l2_ctrl_hevc_sps_obj = ctrl_obj; + + json_object *video_parameter_set_id_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_sps_obj, "video_parameter_set_id", &video_parameter_set_id_obj)) + p->video_parameter_set_id = (__u8) json_object_get_int(video_parameter_set_id_obj); + + json_object *seq_parameter_set_id_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_sps_obj, "seq_parameter_set_id", &seq_parameter_set_id_obj)) + p->seq_parameter_set_id = (__u8) json_object_get_int(seq_parameter_set_id_obj); + + json_object *pic_width_in_luma_samples_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_sps_obj, "pic_width_in_luma_samples", &pic_width_in_luma_samples_obj)) + p->pic_width_in_luma_samples = (__u16) json_object_get_int(pic_width_in_luma_samples_obj); + + json_object *pic_height_in_luma_samples_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_sps_obj, "pic_height_in_luma_samples", &pic_height_in_luma_samples_obj)) + p->pic_height_in_luma_samples = (__u16) json_object_get_int(pic_height_in_luma_samples_obj); + + json_object *bit_depth_luma_minus8_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_sps_obj, "bit_depth_luma_minus8", &bit_depth_luma_minus8_obj)) + p->bit_depth_luma_minus8 = (__u8) json_object_get_int(bit_depth_luma_minus8_obj); + + json_object *bit_depth_chroma_minus8_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_sps_obj, "bit_depth_chroma_minus8", &bit_depth_chroma_minus8_obj)) + p->bit_depth_chroma_minus8 = (__u8) json_object_get_int(bit_depth_chroma_minus8_obj); + + json_object *log2_max_pic_order_cnt_lsb_minus4_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_sps_obj, "log2_max_pic_order_cnt_lsb_minus4", &log2_max_pic_order_cnt_lsb_minus4_obj)) + p->log2_max_pic_order_cnt_lsb_minus4 = (__u8) json_object_get_int(log2_max_pic_order_cnt_lsb_minus4_obj); + + json_object *sps_max_dec_pic_buffering_minus1_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_sps_obj, "sps_max_dec_pic_buffering_minus1", &sps_max_dec_pic_buffering_minus1_obj)) + p->sps_max_dec_pic_buffering_minus1 = (__u8) json_object_get_int(sps_max_dec_pic_buffering_minus1_obj); + + json_object *sps_max_num_reorder_pics_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_sps_obj, "sps_max_num_reorder_pics", &sps_max_num_reorder_pics_obj)) + p->sps_max_num_reorder_pics = (__u8) json_object_get_int(sps_max_num_reorder_pics_obj); + + json_object *sps_max_latency_increase_plus1_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_sps_obj, "sps_max_latency_increase_plus1", &sps_max_latency_increase_plus1_obj)) + p->sps_max_latency_increase_plus1 = (__u8) json_object_get_int(sps_max_latency_increase_plus1_obj); + + json_object *log2_min_luma_coding_block_size_minus3_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_sps_obj, "log2_min_luma_coding_block_size_minus3", &log2_min_luma_coding_block_size_minus3_obj)) + p->log2_min_luma_coding_block_size_minus3 = (__u8) json_object_get_int(log2_min_luma_coding_block_size_minus3_obj); + + json_object *log2_diff_max_min_luma_coding_block_size_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_sps_obj, "log2_diff_max_min_luma_coding_block_size", &log2_diff_max_min_luma_coding_block_size_obj)) + p->log2_diff_max_min_luma_coding_block_size = (__u8) json_object_get_int(log2_diff_max_min_luma_coding_block_size_obj); + + json_object *log2_min_luma_transform_block_size_minus2_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_sps_obj, "log2_min_luma_transform_block_size_minus2", &log2_min_luma_transform_block_size_minus2_obj)) + p->log2_min_luma_transform_block_size_minus2 = (__u8) json_object_get_int(log2_min_luma_transform_block_size_minus2_obj); + + json_object *log2_diff_max_min_luma_transform_block_size_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_sps_obj, "log2_diff_max_min_luma_transform_block_size", &log2_diff_max_min_luma_transform_block_size_obj)) + p->log2_diff_max_min_luma_transform_block_size = (__u8) json_object_get_int(log2_diff_max_min_luma_transform_block_size_obj); + + json_object *max_transform_hierarchy_depth_inter_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_sps_obj, "max_transform_hierarchy_depth_inter", &max_transform_hierarchy_depth_inter_obj)) + p->max_transform_hierarchy_depth_inter = (__u8) json_object_get_int(max_transform_hierarchy_depth_inter_obj); + + json_object *max_transform_hierarchy_depth_intra_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_sps_obj, "max_transform_hierarchy_depth_intra", &max_transform_hierarchy_depth_intra_obj)) + p->max_transform_hierarchy_depth_intra = (__u8) json_object_get_int(max_transform_hierarchy_depth_intra_obj); + + json_object *pcm_sample_bit_depth_luma_minus1_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_sps_obj, "pcm_sample_bit_depth_luma_minus1", &pcm_sample_bit_depth_luma_minus1_obj)) + p->pcm_sample_bit_depth_luma_minus1 = (__u8) json_object_get_int(pcm_sample_bit_depth_luma_minus1_obj); + + json_object *pcm_sample_bit_depth_chroma_minus1_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_sps_obj, "pcm_sample_bit_depth_chroma_minus1", &pcm_sample_bit_depth_chroma_minus1_obj)) + p->pcm_sample_bit_depth_chroma_minus1 = (__u8) json_object_get_int(pcm_sample_bit_depth_chroma_minus1_obj); + + json_object *log2_min_pcm_luma_coding_block_size_minus3_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_sps_obj, "log2_min_pcm_luma_coding_block_size_minus3", &log2_min_pcm_luma_coding_block_size_minus3_obj)) + p->log2_min_pcm_luma_coding_block_size_minus3 = (__u8) json_object_get_int(log2_min_pcm_luma_coding_block_size_minus3_obj); + + json_object *log2_diff_max_min_pcm_luma_coding_block_size_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_sps_obj, "log2_diff_max_min_pcm_luma_coding_block_size", &log2_diff_max_min_pcm_luma_coding_block_size_obj)) + p->log2_diff_max_min_pcm_luma_coding_block_size = (__u8) json_object_get_int(log2_diff_max_min_pcm_luma_coding_block_size_obj); + + json_object *num_short_term_ref_pic_sets_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_sps_obj, "num_short_term_ref_pic_sets", &num_short_term_ref_pic_sets_obj)) + p->num_short_term_ref_pic_sets = (__u8) json_object_get_int(num_short_term_ref_pic_sets_obj); + + json_object *num_long_term_ref_pics_sps_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_sps_obj, "num_long_term_ref_pics_sps", &num_long_term_ref_pics_sps_obj)) + p->num_long_term_ref_pics_sps = (__u8) json_object_get_int(num_long_term_ref_pics_sps_obj); + + json_object *chroma_format_idc_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_sps_obj, "chroma_format_idc", &chroma_format_idc_obj)) + p->chroma_format_idc = (__u8) json_object_get_int(chroma_format_idc_obj); + + json_object *sps_max_sub_layers_minus1_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_sps_obj, "sps_max_sub_layers_minus1", &sps_max_sub_layers_minus1_obj)) + p->sps_max_sub_layers_minus1 = (__u8) json_object_get_int(sps_max_sub_layers_minus1_obj); + + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_sps_obj, "flags", &flags_obj)) + p->flags = (__u64) s2flags(json_object_get_string(flags_obj), v4l2_hevc_sps_flag_def); + + return p; +} + +struct v4l2_ctrl_hevc_pps *retrace_v4l2_ctrl_hevc_pps_gen(json_object *ctrl_obj) +{ + struct v4l2_ctrl_hevc_pps *p = (struct v4l2_ctrl_hevc_pps *) calloc(1, sizeof(v4l2_ctrl_hevc_pps)); + json_object *v4l2_ctrl_hevc_pps_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_ctrl_hevc_pps", &v4l2_ctrl_hevc_pps_obj)) + v4l2_ctrl_hevc_pps_obj = ctrl_obj; + + json_object *pic_parameter_set_id_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_pps_obj, "pic_parameter_set_id", &pic_parameter_set_id_obj)) + p->pic_parameter_set_id = (__u8) json_object_get_int(pic_parameter_set_id_obj); + + json_object *num_extra_slice_header_bits_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_pps_obj, "num_extra_slice_header_bits", &num_extra_slice_header_bits_obj)) + p->num_extra_slice_header_bits = (__u8) json_object_get_int(num_extra_slice_header_bits_obj); + + json_object *num_ref_idx_l0_default_active_minus1_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_pps_obj, "num_ref_idx_l0_default_active_minus1", &num_ref_idx_l0_default_active_minus1_obj)) + p->num_ref_idx_l0_default_active_minus1 = (__u8) json_object_get_int(num_ref_idx_l0_default_active_minus1_obj); + + json_object *num_ref_idx_l1_default_active_minus1_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_pps_obj, "num_ref_idx_l1_default_active_minus1", &num_ref_idx_l1_default_active_minus1_obj)) + p->num_ref_idx_l1_default_active_minus1 = (__u8) json_object_get_int(num_ref_idx_l1_default_active_minus1_obj); + + json_object *init_qp_minus26_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_pps_obj, "init_qp_minus26", &init_qp_minus26_obj)) + p->init_qp_minus26 = (__s8) json_object_get_int(init_qp_minus26_obj); + + json_object *diff_cu_qp_delta_depth_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_pps_obj, "diff_cu_qp_delta_depth", &diff_cu_qp_delta_depth_obj)) + p->diff_cu_qp_delta_depth = (__u8) json_object_get_int(diff_cu_qp_delta_depth_obj); + + json_object *pps_cb_qp_offset_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_pps_obj, "pps_cb_qp_offset", &pps_cb_qp_offset_obj)) + p->pps_cb_qp_offset = (__s8) json_object_get_int(pps_cb_qp_offset_obj); + + json_object *pps_cr_qp_offset_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_pps_obj, "pps_cr_qp_offset", &pps_cr_qp_offset_obj)) + p->pps_cr_qp_offset = (__s8) json_object_get_int(pps_cr_qp_offset_obj); + + json_object *num_tile_columns_minus1_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_pps_obj, "num_tile_columns_minus1", &num_tile_columns_minus1_obj)) + p->num_tile_columns_minus1 = (__u8) json_object_get_int(num_tile_columns_minus1_obj); + + json_object *num_tile_rows_minus1_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_pps_obj, "num_tile_rows_minus1", &num_tile_rows_minus1_obj)) + p->num_tile_rows_minus1 = (__u8) json_object_get_int(num_tile_rows_minus1_obj); + + /* __u8 column_width_minus1[20] */ + json_object *column_width_minus1_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_pps_obj, "column_width_minus1", &column_width_minus1_obj)) { + for (size_t i = 0; i < 20; i++) { + if (json_object_array_get_idx(column_width_minus1_obj, i)) + p->column_width_minus1[i] = (__u8) json_object_get_int(json_object_array_get_idx(column_width_minus1_obj, i)); + } + } + + /* __u8 row_height_minus1[22] */ + json_object *row_height_minus1_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_pps_obj, "row_height_minus1", &row_height_minus1_obj)) { + for (size_t i = 0; i < 22; i++) { + if (json_object_array_get_idx(row_height_minus1_obj, i)) + p->row_height_minus1[i] = (__u8) json_object_get_int(json_object_array_get_idx(row_height_minus1_obj, i)); + } + } + + json_object *pps_beta_offset_div2_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_pps_obj, "pps_beta_offset_div2", &pps_beta_offset_div2_obj)) + p->pps_beta_offset_div2 = (__s8) json_object_get_int(pps_beta_offset_div2_obj); + + json_object *pps_tc_offset_div2_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_pps_obj, "pps_tc_offset_div2", &pps_tc_offset_div2_obj)) + p->pps_tc_offset_div2 = (__s8) json_object_get_int(pps_tc_offset_div2_obj); + + json_object *log2_parallel_merge_level_minus2_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_pps_obj, "log2_parallel_merge_level_minus2", &log2_parallel_merge_level_minus2_obj)) + p->log2_parallel_merge_level_minus2 = (__u8) json_object_get_int(log2_parallel_merge_level_minus2_obj); + + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_pps_obj, "flags", &flags_obj)) + p->flags = (__u64) s2flags(json_object_get_string(flags_obj), v4l2_hevc_pps_flag_def); + + return p; +} + +struct v4l2_hevc_dpb_entry *retrace_v4l2_hevc_dpb_entry_gen(json_object *ctrl_obj) +{ + struct v4l2_hevc_dpb_entry *p = (struct v4l2_hevc_dpb_entry *) calloc(1, sizeof(v4l2_hevc_dpb_entry)); + json_object *v4l2_hevc_dpb_entry_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_hevc_dpb_entry", &v4l2_hevc_dpb_entry_obj)) + v4l2_hevc_dpb_entry_obj = ctrl_obj; + + json_object *timestamp_obj; + if (json_object_object_get_ex(v4l2_hevc_dpb_entry_obj, "timestamp", ×tamp_obj)) + p->timestamp = (__u64) json_object_get_uint64(timestamp_obj); + + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_hevc_dpb_entry_obj, "flags", &flags_obj)) + p->flags = (__u8) s2flags(json_object_get_string(flags_obj), v4l2_hevc_pps_flag_def); + + json_object *field_pic_obj; + if (json_object_object_get_ex(v4l2_hevc_dpb_entry_obj, "field_pic", &field_pic_obj)) + p->field_pic = (__u8) json_object_get_int(field_pic_obj); + + json_object *pic_order_cnt_val_obj; + if (json_object_object_get_ex(v4l2_hevc_dpb_entry_obj, "pic_order_cnt_val", &pic_order_cnt_val_obj)) + p->pic_order_cnt_val = (__s32) json_object_get_int(pic_order_cnt_val_obj); + + return p; +} + +struct v4l2_hevc_pred_weight_table *retrace_v4l2_hevc_pred_weight_table_gen(json_object *ctrl_obj) +{ + struct v4l2_hevc_pred_weight_table *p = (struct v4l2_hevc_pred_weight_table *) calloc(1, sizeof(v4l2_hevc_pred_weight_table)); + json_object *v4l2_hevc_pred_weight_table_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_hevc_pred_weight_table", &v4l2_hevc_pred_weight_table_obj)) + v4l2_hevc_pred_weight_table_obj = ctrl_obj; + + /* __s8 delta_luma_weight_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX] */ + json_object *delta_luma_weight_l0_obj; + if (json_object_object_get_ex(v4l2_hevc_pred_weight_table_obj, "delta_luma_weight_l0", &delta_luma_weight_l0_obj)) { + for (size_t i = 0; i < V4L2_HEVC_DPB_ENTRIES_NUM_MAX; i++) { + if (json_object_array_get_idx(delta_luma_weight_l0_obj, i)) + p->delta_luma_weight_l0[i] = (__s8) json_object_get_int(json_object_array_get_idx(delta_luma_weight_l0_obj, i)); + } + } + + /* __s8 luma_offset_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX] */ + json_object *luma_offset_l0_obj; + if (json_object_object_get_ex(v4l2_hevc_pred_weight_table_obj, "luma_offset_l0", &luma_offset_l0_obj)) { + for (size_t i = 0; i < V4L2_HEVC_DPB_ENTRIES_NUM_MAX; i++) { + if (json_object_array_get_idx(luma_offset_l0_obj, i)) + p->luma_offset_l0[i] = (__s8) json_object_get_int(json_object_array_get_idx(luma_offset_l0_obj, i)); + } + } + + /* __s8 delta_chroma_weight_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX][2] */ + int count_delta_chroma_weight_l0 = 0; + json_object *delta_chroma_weight_l0_obj; + if (json_object_object_get_ex(v4l2_hevc_pred_weight_table_obj, "delta_chroma_weight_l0", &delta_chroma_weight_l0_obj)) { + for (size_t i = 0; i < V4L2_HEVC_DPB_ENTRIES_NUM_MAX; i++) { + for (size_t j = 0; j < 2; j++) { + if (json_object_array_get_idx(delta_chroma_weight_l0_obj, count_delta_chroma_weight_l0)) + p->delta_chroma_weight_l0[i][j] = (__s8) json_object_get_int(json_object_array_get_idx(delta_chroma_weight_l0_obj, count_delta_chroma_weight_l0++)); + } + } + } + + /* __s8 chroma_offset_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX][2] */ + int count_chroma_offset_l0 = 0; + json_object *chroma_offset_l0_obj; + if (json_object_object_get_ex(v4l2_hevc_pred_weight_table_obj, "chroma_offset_l0", &chroma_offset_l0_obj)) { + for (size_t i = 0; i < V4L2_HEVC_DPB_ENTRIES_NUM_MAX; i++) { + for (size_t j = 0; j < 2; j++) { + if (json_object_array_get_idx(chroma_offset_l0_obj, count_chroma_offset_l0)) + p->chroma_offset_l0[i][j] = (__s8) json_object_get_int(json_object_array_get_idx(chroma_offset_l0_obj, count_chroma_offset_l0++)); + } + } + } + + /* __s8 delta_luma_weight_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX] */ + json_object *delta_luma_weight_l1_obj; + if (json_object_object_get_ex(v4l2_hevc_pred_weight_table_obj, "delta_luma_weight_l1", &delta_luma_weight_l1_obj)) { + for (size_t i = 0; i < V4L2_HEVC_DPB_ENTRIES_NUM_MAX; i++) { + if (json_object_array_get_idx(delta_luma_weight_l1_obj, i)) + p->delta_luma_weight_l1[i] = (__s8) json_object_get_int(json_object_array_get_idx(delta_luma_weight_l1_obj, i)); + } + } + + /* __s8 luma_offset_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX] */ + json_object *luma_offset_l1_obj; + if (json_object_object_get_ex(v4l2_hevc_pred_weight_table_obj, "luma_offset_l1", &luma_offset_l1_obj)) { + for (size_t i = 0; i < V4L2_HEVC_DPB_ENTRIES_NUM_MAX; i++) { + if (json_object_array_get_idx(luma_offset_l1_obj, i)) + p->luma_offset_l1[i] = (__s8) json_object_get_int(json_object_array_get_idx(luma_offset_l1_obj, i)); + } + } + + /* __s8 delta_chroma_weight_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX][2] */ + int count_delta_chroma_weight_l1 = 0; + json_object *delta_chroma_weight_l1_obj; + if (json_object_object_get_ex(v4l2_hevc_pred_weight_table_obj, "delta_chroma_weight_l1", &delta_chroma_weight_l1_obj)) { + for (size_t i = 0; i < V4L2_HEVC_DPB_ENTRIES_NUM_MAX; i++) { + for (size_t j = 0; j < 2; j++) { + if (json_object_array_get_idx(delta_chroma_weight_l1_obj, count_delta_chroma_weight_l1)) + p->delta_chroma_weight_l1[i][j] = (__s8) json_object_get_int(json_object_array_get_idx(delta_chroma_weight_l1_obj, count_delta_chroma_weight_l1++)); + } + } + } + + /* __s8 chroma_offset_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX][2] */ + int count_chroma_offset_l1 = 0; + json_object *chroma_offset_l1_obj; + if (json_object_object_get_ex(v4l2_hevc_pred_weight_table_obj, "chroma_offset_l1", &chroma_offset_l1_obj)) { + for (size_t i = 0; i < V4L2_HEVC_DPB_ENTRIES_NUM_MAX; i++) { + for (size_t j = 0; j < 2; j++) { + if (json_object_array_get_idx(chroma_offset_l1_obj, count_chroma_offset_l1)) + p->chroma_offset_l1[i][j] = (__s8) json_object_get_int(json_object_array_get_idx(chroma_offset_l1_obj, count_chroma_offset_l1++)); + } + } + } + + json_object *luma_log2_weight_denom_obj; + if (json_object_object_get_ex(v4l2_hevc_pred_weight_table_obj, "luma_log2_weight_denom", &luma_log2_weight_denom_obj)) + p->luma_log2_weight_denom = (__u8) json_object_get_int(luma_log2_weight_denom_obj); + + json_object *delta_chroma_log2_weight_denom_obj; + if (json_object_object_get_ex(v4l2_hevc_pred_weight_table_obj, "delta_chroma_log2_weight_denom", &delta_chroma_log2_weight_denom_obj)) + p->delta_chroma_log2_weight_denom = (__s8) json_object_get_int(delta_chroma_log2_weight_denom_obj); + + return p; +} + +struct v4l2_ctrl_hevc_slice_params *retrace_v4l2_ctrl_hevc_slice_params_gen(json_object *ctrl_obj) +{ + struct v4l2_ctrl_hevc_slice_params *p = (struct v4l2_ctrl_hevc_slice_params *) calloc(1, sizeof(v4l2_ctrl_hevc_slice_params)); + json_object *v4l2_ctrl_hevc_slice_params_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_ctrl_hevc_slice_params", &v4l2_ctrl_hevc_slice_params_obj)) + v4l2_ctrl_hevc_slice_params_obj = ctrl_obj; + + json_object *bit_size_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "bit_size", &bit_size_obj)) + p->bit_size = (__u32) json_object_get_int64(bit_size_obj); + + json_object *data_byte_offset_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "data_byte_offset", &data_byte_offset_obj)) + p->data_byte_offset = (__u32) json_object_get_int64(data_byte_offset_obj); + + json_object *num_entry_point_offsets_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "num_entry_point_offsets", &num_entry_point_offsets_obj)) + p->num_entry_point_offsets = (__u32) json_object_get_int64(num_entry_point_offsets_obj); + + json_object *nal_unit_type_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "nal_unit_type", &nal_unit_type_obj)) + p->nal_unit_type = (__u8) json_object_get_int(nal_unit_type_obj); + + json_object *nuh_temporal_id_plus1_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "nuh_temporal_id_plus1", &nuh_temporal_id_plus1_obj)) + p->nuh_temporal_id_plus1 = (__u8) json_object_get_int(nuh_temporal_id_plus1_obj); + + json_object *slice_type_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "slice_type", &slice_type_obj)) + p->slice_type = (__u8) json_object_get_int(slice_type_obj); + + json_object *colour_plane_id_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "colour_plane_id", &colour_plane_id_obj)) + p->colour_plane_id = (__u8) json_object_get_int(colour_plane_id_obj); + + json_object *slice_pic_order_cnt_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "slice_pic_order_cnt", &slice_pic_order_cnt_obj)) + p->slice_pic_order_cnt = (__s32) json_object_get_int(slice_pic_order_cnt_obj); + + json_object *num_ref_idx_l0_active_minus1_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "num_ref_idx_l0_active_minus1", &num_ref_idx_l0_active_minus1_obj)) + p->num_ref_idx_l0_active_minus1 = (__u8) json_object_get_int(num_ref_idx_l0_active_minus1_obj); + + json_object *num_ref_idx_l1_active_minus1_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "num_ref_idx_l1_active_minus1", &num_ref_idx_l1_active_minus1_obj)) + p->num_ref_idx_l1_active_minus1 = (__u8) json_object_get_int(num_ref_idx_l1_active_minus1_obj); + + json_object *collocated_ref_idx_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "collocated_ref_idx", &collocated_ref_idx_obj)) + p->collocated_ref_idx = (__u8) json_object_get_int(collocated_ref_idx_obj); + + json_object *five_minus_max_num_merge_cand_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "five_minus_max_num_merge_cand", &five_minus_max_num_merge_cand_obj)) + p->five_minus_max_num_merge_cand = (__u8) json_object_get_int(five_minus_max_num_merge_cand_obj); + + json_object *slice_qp_delta_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "slice_qp_delta", &slice_qp_delta_obj)) + p->slice_qp_delta = (__s8) json_object_get_int(slice_qp_delta_obj); + + json_object *slice_cb_qp_offset_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "slice_cb_qp_offset", &slice_cb_qp_offset_obj)) + p->slice_cb_qp_offset = (__s8) json_object_get_int(slice_cb_qp_offset_obj); + + json_object *slice_cr_qp_offset_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "slice_cr_qp_offset", &slice_cr_qp_offset_obj)) + p->slice_cr_qp_offset = (__s8) json_object_get_int(slice_cr_qp_offset_obj); + + json_object *slice_act_y_qp_offset_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "slice_act_y_qp_offset", &slice_act_y_qp_offset_obj)) + p->slice_act_y_qp_offset = (__s8) json_object_get_int(slice_act_y_qp_offset_obj); + + json_object *slice_act_cb_qp_offset_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "slice_act_cb_qp_offset", &slice_act_cb_qp_offset_obj)) + p->slice_act_cb_qp_offset = (__s8) json_object_get_int(slice_act_cb_qp_offset_obj); + + json_object *slice_act_cr_qp_offset_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "slice_act_cr_qp_offset", &slice_act_cr_qp_offset_obj)) + p->slice_act_cr_qp_offset = (__s8) json_object_get_int(slice_act_cr_qp_offset_obj); + + json_object *slice_beta_offset_div2_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "slice_beta_offset_div2", &slice_beta_offset_div2_obj)) + p->slice_beta_offset_div2 = (__s8) json_object_get_int(slice_beta_offset_div2_obj); + + json_object *slice_tc_offset_div2_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "slice_tc_offset_div2", &slice_tc_offset_div2_obj)) + p->slice_tc_offset_div2 = (__s8) json_object_get_int(slice_tc_offset_div2_obj); + + json_object *pic_struct_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "pic_struct", &pic_struct_obj)) + p->pic_struct = (__u8) json_object_get_int(pic_struct_obj); + + json_object *slice_segment_addr_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "slice_segment_addr", &slice_segment_addr_obj)) + p->slice_segment_addr = (__u32) json_object_get_int64(slice_segment_addr_obj); + + /* __u8 ref_idx_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX] */ + json_object *ref_idx_l0_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "ref_idx_l0", &ref_idx_l0_obj)) { + for (size_t i = 0; i < V4L2_HEVC_DPB_ENTRIES_NUM_MAX; i++) { + if (json_object_array_get_idx(ref_idx_l0_obj, i)) + p->ref_idx_l0[i] = (__u8) json_object_get_int(json_object_array_get_idx(ref_idx_l0_obj, i)); + } + } + + /* __u8 ref_idx_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX] */ + json_object *ref_idx_l1_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "ref_idx_l1", &ref_idx_l1_obj)) { + for (size_t i = 0; i < V4L2_HEVC_DPB_ENTRIES_NUM_MAX; i++) { + if (json_object_array_get_idx(ref_idx_l1_obj, i)) + p->ref_idx_l1[i] = (__u8) json_object_get_int(json_object_array_get_idx(ref_idx_l1_obj, i)); + } + } + + json_object *short_term_ref_pic_set_size_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "short_term_ref_pic_set_size", &short_term_ref_pic_set_size_obj)) + p->short_term_ref_pic_set_size = (__u16) json_object_get_int(short_term_ref_pic_set_size_obj); + + json_object *long_term_ref_pic_set_size_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "long_term_ref_pic_set_size", &long_term_ref_pic_set_size_obj)) + p->long_term_ref_pic_set_size = (__u16) json_object_get_int(long_term_ref_pic_set_size_obj); + + /* struct v4l2_hevc_pred_weight_table pred_weight_table */ + json_object *pred_weight_table_obj; + if (!json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "v4l2_hevc_pred_weight_table", &pred_weight_table_obj)) + return p; + void *pred_weight_table_ptr = (void *) retrace_v4l2_hevc_pred_weight_table_gen(pred_weight_table_obj); + p->pred_weight_table = *static_cast<struct v4l2_hevc_pred_weight_table*>(pred_weight_table_ptr); + free(pred_weight_table_ptr); + + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_slice_params_obj, "flags", &flags_obj)) + p->flags = (__u64) s2flags(json_object_get_string(flags_obj), v4l2_hevc_slice_params_flag_def); + + return p; +} + +struct v4l2_ctrl_hevc_decode_params *retrace_v4l2_ctrl_hevc_decode_params_gen(json_object *ctrl_obj) +{ + struct v4l2_ctrl_hevc_decode_params *p = (struct v4l2_ctrl_hevc_decode_params *) calloc(1, sizeof(v4l2_ctrl_hevc_decode_params)); + json_object *v4l2_ctrl_hevc_decode_params_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_ctrl_hevc_decode_params", &v4l2_ctrl_hevc_decode_params_obj)) + v4l2_ctrl_hevc_decode_params_obj = ctrl_obj; + + json_object *pic_order_cnt_val_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_decode_params_obj, "pic_order_cnt_val", &pic_order_cnt_val_obj)) + p->pic_order_cnt_val = (__s32) json_object_get_int(pic_order_cnt_val_obj); + + json_object *short_term_ref_pic_set_size_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_decode_params_obj, "short_term_ref_pic_set_size", &short_term_ref_pic_set_size_obj)) + p->short_term_ref_pic_set_size = (__u16) json_object_get_int(short_term_ref_pic_set_size_obj); + + json_object *long_term_ref_pic_set_size_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_decode_params_obj, "long_term_ref_pic_set_size", &long_term_ref_pic_set_size_obj)) + p->long_term_ref_pic_set_size = (__u16) json_object_get_int(long_term_ref_pic_set_size_obj); + + json_object *num_active_dpb_entries_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_decode_params_obj, "num_active_dpb_entries", &num_active_dpb_entries_obj)) + p->num_active_dpb_entries = (__u8) json_object_get_int(num_active_dpb_entries_obj); + + json_object *num_poc_st_curr_before_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_decode_params_obj, "num_poc_st_curr_before", &num_poc_st_curr_before_obj)) + p->num_poc_st_curr_before = (__u8) json_object_get_int(num_poc_st_curr_before_obj); + + json_object *num_poc_st_curr_after_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_decode_params_obj, "num_poc_st_curr_after", &num_poc_st_curr_after_obj)) + p->num_poc_st_curr_after = (__u8) json_object_get_int(num_poc_st_curr_after_obj); + + json_object *num_poc_lt_curr_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_decode_params_obj, "num_poc_lt_curr", &num_poc_lt_curr_obj)) + p->num_poc_lt_curr = (__u8) json_object_get_int(num_poc_lt_curr_obj); + + /* __u8 poc_st_curr_before[V4L2_HEVC_DPB_ENTRIES_NUM_MAX] */ + json_object *poc_st_curr_before_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_decode_params_obj, "poc_st_curr_before", &poc_st_curr_before_obj)) { + for (size_t i = 0; i < V4L2_HEVC_DPB_ENTRIES_NUM_MAX; i++) { + if (json_object_array_get_idx(poc_st_curr_before_obj, i)) + p->poc_st_curr_before[i] = (__u8) json_object_get_int(json_object_array_get_idx(poc_st_curr_before_obj, i)); + } + } + + /* __u8 poc_st_curr_after[V4L2_HEVC_DPB_ENTRIES_NUM_MAX] */ + json_object *poc_st_curr_after_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_decode_params_obj, "poc_st_curr_after", &poc_st_curr_after_obj)) { + for (size_t i = 0; i < V4L2_HEVC_DPB_ENTRIES_NUM_MAX; i++) { + if (json_object_array_get_idx(poc_st_curr_after_obj, i)) + p->poc_st_curr_after[i] = (__u8) json_object_get_int(json_object_array_get_idx(poc_st_curr_after_obj, i)); + } + } + + /* __u8 poc_lt_curr[V4L2_HEVC_DPB_ENTRIES_NUM_MAX] */ + json_object *poc_lt_curr_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_decode_params_obj, "poc_lt_curr", &poc_lt_curr_obj)) { + for (size_t i = 0; i < V4L2_HEVC_DPB_ENTRIES_NUM_MAX; i++) { + if (json_object_array_get_idx(poc_lt_curr_obj, i)) + p->poc_lt_curr[i] = (__u8) json_object_get_int(json_object_array_get_idx(poc_lt_curr_obj, i)); + } + } + + json_object *num_delta_pocs_of_ref_rps_idx_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_decode_params_obj, "num_delta_pocs_of_ref_rps_idx", &num_delta_pocs_of_ref_rps_idx_obj)) + p->num_delta_pocs_of_ref_rps_idx = (__u8) json_object_get_int(num_delta_pocs_of_ref_rps_idx_obj); + + /* struct v4l2_hevc_dpb_entry dpb[V4L2_HEVC_DPB_ENTRIES_NUM_MAX] */ + json_object *dpb_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_decode_params_obj, "dpb", &dpb_obj)) { + for (size_t i = 0; i < V4L2_HEVC_DPB_ENTRIES_NUM_MAX; i++) { + void *dpb_ptr = (void *) retrace_v4l2_hevc_dpb_entry_gen(json_object_array_get_idx(dpb_obj, i)); + p->dpb[i] = *static_cast<struct v4l2_hevc_dpb_entry*>(dpb_ptr); + free(dpb_ptr); + } + } + + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_decode_params_obj, "flags", &flags_obj)) + p->flags = (__u64) s2flags(json_object_get_string(flags_obj), v4l2_hevc_decode_param_flag_def); + + return p; +} + +struct v4l2_ctrl_hevc_scaling_matrix *retrace_v4l2_ctrl_hevc_scaling_matrix_gen(json_object *ctrl_obj) +{ + struct v4l2_ctrl_hevc_scaling_matrix *p = (struct v4l2_ctrl_hevc_scaling_matrix *) calloc(1, sizeof(v4l2_ctrl_hevc_scaling_matrix)); + json_object *v4l2_ctrl_hevc_scaling_matrix_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_ctrl_hevc_scaling_matrix", &v4l2_ctrl_hevc_scaling_matrix_obj)) + v4l2_ctrl_hevc_scaling_matrix_obj = ctrl_obj; + + /* __u8 scaling_list_4x4[6][16] */ + int count_scaling_list_4x4 = 0; + json_object *scaling_list_4x4_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_scaling_matrix_obj, "scaling_list_4x4", &scaling_list_4x4_obj)) { + for (size_t i = 0; i < 6; i++) { + for (size_t j = 0; j < 16; j++) { + if (json_object_array_get_idx(scaling_list_4x4_obj, count_scaling_list_4x4)) + p->scaling_list_4x4[i][j] = (__u8) json_object_get_int(json_object_array_get_idx(scaling_list_4x4_obj, count_scaling_list_4x4++)); + } + } + } + + /* __u8 scaling_list_8x8[6][64] */ + int count_scaling_list_8x8 = 0; + json_object *scaling_list_8x8_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_scaling_matrix_obj, "scaling_list_8x8", &scaling_list_8x8_obj)) { + for (size_t i = 0; i < 6; i++) { + for (size_t j = 0; j < 64; j++) { + if (json_object_array_get_idx(scaling_list_8x8_obj, count_scaling_list_8x8)) + p->scaling_list_8x8[i][j] = (__u8) json_object_get_int(json_object_array_get_idx(scaling_list_8x8_obj, count_scaling_list_8x8++)); + } + } + } + + /* __u8 scaling_list_16x16[6][64] */ + int count_scaling_list_16x16 = 0; + json_object *scaling_list_16x16_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_scaling_matrix_obj, "scaling_list_16x16", &scaling_list_16x16_obj)) { + for (size_t i = 0; i < 6; i++) { + for (size_t j = 0; j < 64; j++) { + if (json_object_array_get_idx(scaling_list_16x16_obj, count_scaling_list_16x16)) + p->scaling_list_16x16[i][j] = (__u8) json_object_get_int(json_object_array_get_idx(scaling_list_16x16_obj, count_scaling_list_16x16++)); + } + } + } + + /* __u8 scaling_list_32x32[2][64] */ + int count_scaling_list_32x32 = 0; + json_object *scaling_list_32x32_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_scaling_matrix_obj, "scaling_list_32x32", &scaling_list_32x32_obj)) { + for (size_t i = 0; i < 2; i++) { + for (size_t j = 0; j < 64; j++) { + if (json_object_array_get_idx(scaling_list_32x32_obj, count_scaling_list_32x32)) + p->scaling_list_32x32[i][j] = (__u8) json_object_get_int(json_object_array_get_idx(scaling_list_32x32_obj, count_scaling_list_32x32++)); + } + } + } + + /* __u8 scaling_list_dc_coef_16x16[6] */ + json_object *scaling_list_dc_coef_16x16_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_scaling_matrix_obj, "scaling_list_dc_coef_16x16", &scaling_list_dc_coef_16x16_obj)) { + for (size_t i = 0; i < 6; i++) { + if (json_object_array_get_idx(scaling_list_dc_coef_16x16_obj, i)) + p->scaling_list_dc_coef_16x16[i] = (__u8) json_object_get_int(json_object_array_get_idx(scaling_list_dc_coef_16x16_obj, i)); + } + } + + /* __u8 scaling_list_dc_coef_32x32[2] */ + json_object *scaling_list_dc_coef_32x32_obj; + if (json_object_object_get_ex(v4l2_ctrl_hevc_scaling_matrix_obj, "scaling_list_dc_coef_32x32", &scaling_list_dc_coef_32x32_obj)) { + for (size_t i = 0; i < 2; i++) { + if (json_object_array_get_idx(scaling_list_dc_coef_32x32_obj, i)) + p->scaling_list_dc_coef_32x32[i] = (__u8) json_object_get_int(json_object_array_get_idx(scaling_list_dc_coef_32x32_obj, i)); + } + } + + return p; +} + +struct v4l2_ctrl_hdr10_cll_info *retrace_v4l2_ctrl_hdr10_cll_info_gen(json_object *ctrl_obj) +{ + struct v4l2_ctrl_hdr10_cll_info *p = (struct v4l2_ctrl_hdr10_cll_info *) calloc(1, sizeof(v4l2_ctrl_hdr10_cll_info)); + json_object *v4l2_ctrl_hdr10_cll_info_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_ctrl_hdr10_cll_info", &v4l2_ctrl_hdr10_cll_info_obj)) + v4l2_ctrl_hdr10_cll_info_obj = ctrl_obj; + + json_object *max_content_light_level_obj; + if (json_object_object_get_ex(v4l2_ctrl_hdr10_cll_info_obj, "max_content_light_level", &max_content_light_level_obj)) + p->max_content_light_level = (__u16) json_object_get_int(max_content_light_level_obj); + + json_object *max_pic_average_light_level_obj; + if (json_object_object_get_ex(v4l2_ctrl_hdr10_cll_info_obj, "max_pic_average_light_level", &max_pic_average_light_level_obj)) + p->max_pic_average_light_level = (__u16) json_object_get_int(max_pic_average_light_level_obj); + + return p; +} + +struct v4l2_ctrl_hdr10_mastering_display *retrace_v4l2_ctrl_hdr10_mastering_display_gen(json_object *ctrl_obj) +{ + struct v4l2_ctrl_hdr10_mastering_display *p = (struct v4l2_ctrl_hdr10_mastering_display *) calloc(1, sizeof(v4l2_ctrl_hdr10_mastering_display)); + json_object *v4l2_ctrl_hdr10_mastering_display_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_ctrl_hdr10_mastering_display", &v4l2_ctrl_hdr10_mastering_display_obj)) + v4l2_ctrl_hdr10_mastering_display_obj = ctrl_obj; + + /* __u16 display_primaries_x[3] */ + json_object *display_primaries_x_obj; + if (json_object_object_get_ex(v4l2_ctrl_hdr10_mastering_display_obj, "display_primaries_x", &display_primaries_x_obj)) { + for (size_t i = 0; i < 3; i++) { + if (json_object_array_get_idx(display_primaries_x_obj, i)) + p->display_primaries_x[i] = (__u16) json_object_get_int(json_object_array_get_idx(display_primaries_x_obj, i)); + } + } + + /* __u16 display_primaries_y[3] */ + json_object *display_primaries_y_obj; + if (json_object_object_get_ex(v4l2_ctrl_hdr10_mastering_display_obj, "display_primaries_y", &display_primaries_y_obj)) { + for (size_t i = 0; i < 3; i++) { + if (json_object_array_get_idx(display_primaries_y_obj, i)) + p->display_primaries_y[i] = (__u16) json_object_get_int(json_object_array_get_idx(display_primaries_y_obj, i)); + } + } + + json_object *white_point_x_obj; + if (json_object_object_get_ex(v4l2_ctrl_hdr10_mastering_display_obj, "white_point_x", &white_point_x_obj)) + p->white_point_x = (__u16) json_object_get_int(white_point_x_obj); + + json_object *white_point_y_obj; + if (json_object_object_get_ex(v4l2_ctrl_hdr10_mastering_display_obj, "white_point_y", &white_point_y_obj)) + p->white_point_y = (__u16) json_object_get_int(white_point_y_obj); + + json_object *max_display_mastering_luminance_obj; + if (json_object_object_get_ex(v4l2_ctrl_hdr10_mastering_display_obj, "max_display_mastering_luminance", &max_display_mastering_luminance_obj)) + p->max_display_mastering_luminance = (__u32) json_object_get_int64(max_display_mastering_luminance_obj); + + json_object *min_display_mastering_luminance_obj; + if (json_object_object_get_ex(v4l2_ctrl_hdr10_mastering_display_obj, "min_display_mastering_luminance", &min_display_mastering_luminance_obj)) + p->min_display_mastering_luminance = (__u32) json_object_get_int64(min_display_mastering_luminance_obj); + + return p; +} + +struct v4l2_vp9_loop_filter *retrace_v4l2_vp9_loop_filter_gen(json_object *ctrl_obj) +{ + struct v4l2_vp9_loop_filter *p = (struct v4l2_vp9_loop_filter *) calloc(1, sizeof(v4l2_vp9_loop_filter)); + json_object *v4l2_vp9_loop_filter_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_vp9_loop_filter", &v4l2_vp9_loop_filter_obj)) + v4l2_vp9_loop_filter_obj = ctrl_obj; + + /* __s8 ref_deltas[4] */ + json_object *ref_deltas_obj; + if (json_object_object_get_ex(v4l2_vp9_loop_filter_obj, "ref_deltas", &ref_deltas_obj)) { + for (size_t i = 0; i < 4; i++) { + if (json_object_array_get_idx(ref_deltas_obj, i)) + p->ref_deltas[i] = (__s8) json_object_get_int(json_object_array_get_idx(ref_deltas_obj, i)); + } + } + + /* __s8 mode_deltas[2] */ + json_object *mode_deltas_obj; + if (json_object_object_get_ex(v4l2_vp9_loop_filter_obj, "mode_deltas", &mode_deltas_obj)) { + for (size_t i = 0; i < 2; i++) { + if (json_object_array_get_idx(mode_deltas_obj, i)) + p->mode_deltas[i] = (__s8) json_object_get_int(json_object_array_get_idx(mode_deltas_obj, i)); + } + } + + json_object *level_obj; + if (json_object_object_get_ex(v4l2_vp9_loop_filter_obj, "level", &level_obj)) + p->level = (__u8) json_object_get_int(level_obj); + + json_object *sharpness_obj; + if (json_object_object_get_ex(v4l2_vp9_loop_filter_obj, "sharpness", &sharpness_obj)) + p->sharpness = (__u8) json_object_get_int(sharpness_obj); + + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_vp9_loop_filter_obj, "flags", &flags_obj)) + p->flags = (__u8) s2flags(json_object_get_string(flags_obj), v4l2_vp9_loop_filter_flag_def); + + return p; +} + +struct v4l2_vp9_quantization *retrace_v4l2_vp9_quantization_gen(json_object *ctrl_obj) +{ + struct v4l2_vp9_quantization *p = (struct v4l2_vp9_quantization *) calloc(1, sizeof(v4l2_vp9_quantization)); + json_object *v4l2_vp9_quantization_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_vp9_quantization", &v4l2_vp9_quantization_obj)) + v4l2_vp9_quantization_obj = ctrl_obj; + + json_object *base_q_idx_obj; + if (json_object_object_get_ex(v4l2_vp9_quantization_obj, "base_q_idx", &base_q_idx_obj)) + p->base_q_idx = (__u8) json_object_get_int(base_q_idx_obj); + + json_object *delta_q_y_dc_obj; + if (json_object_object_get_ex(v4l2_vp9_quantization_obj, "delta_q_y_dc", &delta_q_y_dc_obj)) + p->delta_q_y_dc = (__s8) json_object_get_int(delta_q_y_dc_obj); + + json_object *delta_q_uv_dc_obj; + if (json_object_object_get_ex(v4l2_vp9_quantization_obj, "delta_q_uv_dc", &delta_q_uv_dc_obj)) + p->delta_q_uv_dc = (__s8) json_object_get_int(delta_q_uv_dc_obj); + + json_object *delta_q_uv_ac_obj; + if (json_object_object_get_ex(v4l2_vp9_quantization_obj, "delta_q_uv_ac", &delta_q_uv_ac_obj)) + p->delta_q_uv_ac = (__s8) json_object_get_int(delta_q_uv_ac_obj); + + return p; +} + +struct v4l2_vp9_segmentation *retrace_v4l2_vp9_segmentation_gen(json_object *ctrl_obj) +{ + struct v4l2_vp9_segmentation *p = (struct v4l2_vp9_segmentation *) calloc(1, sizeof(v4l2_vp9_segmentation)); + json_object *v4l2_vp9_segmentation_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_vp9_segmentation", &v4l2_vp9_segmentation_obj)) + v4l2_vp9_segmentation_obj = ctrl_obj; + + /* __s16 feature_data[8][4] */ + int count_feature_data = 0; + json_object *feature_data_obj; + if (json_object_object_get_ex(v4l2_vp9_segmentation_obj, "feature_data", &feature_data_obj)) { + for (size_t i = 0; i < 8; i++) { + for (size_t j = 0; j < 4; j++) { + if (json_object_array_get_idx(feature_data_obj, count_feature_data)) + p->feature_data[i][j] = (__s16) json_object_get_int(json_object_array_get_idx(feature_data_obj, count_feature_data++)); + } + } + } + + /* __u8 feature_enabled[8] */ + json_object *feature_enabled_obj; + if (json_object_object_get_ex(v4l2_vp9_segmentation_obj, "feature_enabled", &feature_enabled_obj)) { + for (size_t i = 0; i < 8; i++) { + if (json_object_array_get_idx(feature_enabled_obj, i)) + p->feature_enabled[i] = (__u8) json_object_get_int(json_object_array_get_idx(feature_enabled_obj, i)); + } + } + + /* __u8 tree_probs[7] */ + json_object *tree_probs_obj; + if (json_object_object_get_ex(v4l2_vp9_segmentation_obj, "tree_probs", &tree_probs_obj)) { + for (size_t i = 0; i < 7; i++) { + if (json_object_array_get_idx(tree_probs_obj, i)) + p->tree_probs[i] = (__u8) json_object_get_int(json_object_array_get_idx(tree_probs_obj, i)); + } + } + + /* __u8 pred_probs[3] */ + json_object *pred_probs_obj; + if (json_object_object_get_ex(v4l2_vp9_segmentation_obj, "pred_probs", &pred_probs_obj)) { + for (size_t i = 0; i < 3; i++) { + if (json_object_array_get_idx(pred_probs_obj, i)) + p->pred_probs[i] = (__u8) json_object_get_int(json_object_array_get_idx(pred_probs_obj, i)); + } + } + + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_vp9_segmentation_obj, "flags", &flags_obj)) + p->flags = (__u8) s2flags(json_object_get_string(flags_obj), v4l2_vp9_segmentation_flag_def); + + return p; +} + +struct v4l2_ctrl_vp9_frame *retrace_v4l2_ctrl_vp9_frame_gen(json_object *ctrl_obj) +{ + struct v4l2_ctrl_vp9_frame *p = (struct v4l2_ctrl_vp9_frame *) calloc(1, sizeof(v4l2_ctrl_vp9_frame)); + json_object *v4l2_ctrl_vp9_frame_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_ctrl_vp9_frame", &v4l2_ctrl_vp9_frame_obj)) + v4l2_ctrl_vp9_frame_obj = ctrl_obj; + + /* struct v4l2_vp9_loop_filter lf */ + json_object *lf_obj; + if (!json_object_object_get_ex(v4l2_ctrl_vp9_frame_obj, "v4l2_vp9_loop_filter", &lf_obj)) + return p; + void *lf_ptr = (void *) retrace_v4l2_vp9_loop_filter_gen(lf_obj); + p->lf = *static_cast<struct v4l2_vp9_loop_filter*>(lf_ptr); + free(lf_ptr); + + /* struct v4l2_vp9_quantization quant */ + json_object *quant_obj; + if (!json_object_object_get_ex(v4l2_ctrl_vp9_frame_obj, "v4l2_vp9_quantization", &quant_obj)) + return p; + void *quant_ptr = (void *) retrace_v4l2_vp9_quantization_gen(quant_obj); + p->quant = *static_cast<struct v4l2_vp9_quantization*>(quant_ptr); + free(quant_ptr); + + /* struct v4l2_vp9_segmentation seg */ + json_object *seg_obj; + if (!json_object_object_get_ex(v4l2_ctrl_vp9_frame_obj, "v4l2_vp9_segmentation", &seg_obj)) + return p; + void *seg_ptr = (void *) retrace_v4l2_vp9_segmentation_gen(seg_obj); + p->seg = *static_cast<struct v4l2_vp9_segmentation*>(seg_ptr); + free(seg_ptr); + + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_frame_obj, "flags", &flags_obj)) + p->flags = (__u32) s2flags(json_object_get_string(flags_obj), v4l2_vp9_frame_flag_def); + + json_object *compressed_header_size_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_frame_obj, "compressed_header_size", &compressed_header_size_obj)) + p->compressed_header_size = (__u16) json_object_get_int(compressed_header_size_obj); + + json_object *uncompressed_header_size_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_frame_obj, "uncompressed_header_size", &uncompressed_header_size_obj)) + p->uncompressed_header_size = (__u16) json_object_get_int(uncompressed_header_size_obj); + + json_object *frame_width_minus_1_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_frame_obj, "frame_width_minus_1", &frame_width_minus_1_obj)) + p->frame_width_minus_1 = (__u16) json_object_get_int(frame_width_minus_1_obj); + + json_object *frame_height_minus_1_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_frame_obj, "frame_height_minus_1", &frame_height_minus_1_obj)) + p->frame_height_minus_1 = (__u16) json_object_get_int(frame_height_minus_1_obj); + + json_object *render_width_minus_1_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_frame_obj, "render_width_minus_1", &render_width_minus_1_obj)) + p->render_width_minus_1 = (__u16) json_object_get_int(render_width_minus_1_obj); + + json_object *render_height_minus_1_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_frame_obj, "render_height_minus_1", &render_height_minus_1_obj)) + p->render_height_minus_1 = (__u16) json_object_get_int(render_height_minus_1_obj); + + json_object *last_frame_ts_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_frame_obj, "last_frame_ts", &last_frame_ts_obj)) + p->last_frame_ts = (__u64) json_object_get_uint64(last_frame_ts_obj); + + json_object *golden_frame_ts_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_frame_obj, "golden_frame_ts", &golden_frame_ts_obj)) + p->golden_frame_ts = (__u64) json_object_get_uint64(golden_frame_ts_obj); + + json_object *alt_frame_ts_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_frame_obj, "alt_frame_ts", &alt_frame_ts_obj)) + p->alt_frame_ts = (__u64) json_object_get_uint64(alt_frame_ts_obj); + + json_object *ref_frame_sign_bias_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_frame_obj, "ref_frame_sign_bias", &ref_frame_sign_bias_obj)) + p->ref_frame_sign_bias = (__u8) json_object_get_int(ref_frame_sign_bias_obj); + + json_object *reset_frame_context_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_frame_obj, "reset_frame_context", &reset_frame_context_obj)) + p->reset_frame_context = (__u8) json_object_get_int(reset_frame_context_obj); + + json_object *frame_context_idx_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_frame_obj, "frame_context_idx", &frame_context_idx_obj)) + p->frame_context_idx = (__u8) json_object_get_int(frame_context_idx_obj); + + json_object *profile_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_frame_obj, "profile", &profile_obj)) + p->profile = (__u8) json_object_get_int(profile_obj); + + json_object *bit_depth_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_frame_obj, "bit_depth", &bit_depth_obj)) + p->bit_depth = (__u8) json_object_get_int(bit_depth_obj); + + json_object *interpolation_filter_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_frame_obj, "interpolation_filter", &interpolation_filter_obj)) + p->interpolation_filter = (__u8) json_object_get_int(interpolation_filter_obj); + + json_object *tile_cols_log2_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_frame_obj, "tile_cols_log2", &tile_cols_log2_obj)) + p->tile_cols_log2 = (__u8) json_object_get_int(tile_cols_log2_obj); + + json_object *tile_rows_log2_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_frame_obj, "tile_rows_log2", &tile_rows_log2_obj)) + p->tile_rows_log2 = (__u8) json_object_get_int(tile_rows_log2_obj); + + json_object *reference_mode_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_frame_obj, "reference_mode", &reference_mode_obj)) + p->reference_mode = (__u8) json_object_get_int(reference_mode_obj); + + return p; +} + +struct v4l2_vp9_mv_probs *retrace_v4l2_vp9_mv_probs_gen(json_object *ctrl_obj) +{ + struct v4l2_vp9_mv_probs *p = (struct v4l2_vp9_mv_probs *) calloc(1, sizeof(v4l2_vp9_mv_probs)); + json_object *v4l2_vp9_mv_probs_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_vp9_mv_probs", &v4l2_vp9_mv_probs_obj)) + v4l2_vp9_mv_probs_obj = ctrl_obj; + + /* __u8 joint[3] */ + json_object *joint_obj; + if (json_object_object_get_ex(v4l2_vp9_mv_probs_obj, "joint", &joint_obj)) { + for (size_t i = 0; i < 3; i++) { + if (json_object_array_get_idx(joint_obj, i)) + p->joint[i] = (__u8) json_object_get_int(json_object_array_get_idx(joint_obj, i)); + } + } + + /* __u8 sign[2] */ + json_object *sign_obj; + if (json_object_object_get_ex(v4l2_vp9_mv_probs_obj, "sign", &sign_obj)) { + for (size_t i = 0; i < 2; i++) { + if (json_object_array_get_idx(sign_obj, i)) + p->sign[i] = (__u8) json_object_get_int(json_object_array_get_idx(sign_obj, i)); + } + } + + /* __u8 classes[2][10] */ + int count_classes = 0; + json_object *classes_obj; + if (json_object_object_get_ex(v4l2_vp9_mv_probs_obj, "classes", &classes_obj)) { + for (size_t i = 0; i < 2; i++) { + for (size_t j = 0; j < 10; j++) { + if (json_object_array_get_idx(classes_obj, count_classes)) + p->classes[i][j] = (__u8) json_object_get_int(json_object_array_get_idx(classes_obj, count_classes++)); + } + } + } + + /* __u8 class0_bit[2] */ + json_object *class0_bit_obj; + if (json_object_object_get_ex(v4l2_vp9_mv_probs_obj, "class0_bit", &class0_bit_obj)) { + for (size_t i = 0; i < 2; i++) { + if (json_object_array_get_idx(class0_bit_obj, i)) + p->class0_bit[i] = (__u8) json_object_get_int(json_object_array_get_idx(class0_bit_obj, i)); + } + } + + /* __u8 bits[2][10] */ + int count_bits = 0; + json_object *bits_obj; + if (json_object_object_get_ex(v4l2_vp9_mv_probs_obj, "bits", &bits_obj)) { + for (size_t i = 0; i < 2; i++) { + for (size_t j = 0; j < 10; j++) { + if (json_object_array_get_idx(bits_obj, count_bits)) + p->bits[i][j] = (__u8) json_object_get_int(json_object_array_get_idx(bits_obj, count_bits++)); + } + } + } + + /* __u8 class0_fr[2][2][3] */ + int count_class0_fr = 0; + json_object *class0_fr_obj; + if (json_object_object_get_ex(v4l2_vp9_mv_probs_obj, "class0_fr", &class0_fr_obj)) { + for (size_t i = 0; i < 2; i++) { + for (size_t j = 0; j < 2; j++) { + for (size_t k = 0; k < 3; k++) { + if (json_object_array_get_idx(class0_fr_obj, count_class0_fr)) + p->class0_fr[i][j][k] = (__u8) json_object_get_int(json_object_array_get_idx(class0_fr_obj, count_class0_fr++)); + } + } + } + } + + /* __u8 fr[2][3] */ + int count_fr = 0; + json_object *fr_obj; + if (json_object_object_get_ex(v4l2_vp9_mv_probs_obj, "fr", &fr_obj)) { + for (size_t i = 0; i < 2; i++) { + for (size_t j = 0; j < 3; j++) { + if (json_object_array_get_idx(fr_obj, count_fr)) + p->fr[i][j] = (__u8) json_object_get_int(json_object_array_get_idx(fr_obj, count_fr++)); + } + } + } + + /* __u8 class0_hp[2] */ + json_object *class0_hp_obj; + if (json_object_object_get_ex(v4l2_vp9_mv_probs_obj, "class0_hp", &class0_hp_obj)) { + for (size_t i = 0; i < 2; i++) { + if (json_object_array_get_idx(class0_hp_obj, i)) + p->class0_hp[i] = (__u8) json_object_get_int(json_object_array_get_idx(class0_hp_obj, i)); + } + } + + /* __u8 hp[2] */ + json_object *hp_obj; + if (json_object_object_get_ex(v4l2_vp9_mv_probs_obj, "hp", &hp_obj)) { + for (size_t i = 0; i < 2; i++) { + if (json_object_array_get_idx(hp_obj, i)) + p->hp[i] = (__u8) json_object_get_int(json_object_array_get_idx(hp_obj, i)); + } + } + + return p; +} + +struct v4l2_ctrl_vp9_compressed_hdr *retrace_v4l2_ctrl_vp9_compressed_hdr_gen(json_object *ctrl_obj) +{ + struct v4l2_ctrl_vp9_compressed_hdr *p = (struct v4l2_ctrl_vp9_compressed_hdr *) calloc(1, sizeof(v4l2_ctrl_vp9_compressed_hdr)); + json_object *v4l2_ctrl_vp9_compressed_hdr_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_ctrl_vp9_compressed_hdr", &v4l2_ctrl_vp9_compressed_hdr_obj)) + v4l2_ctrl_vp9_compressed_hdr_obj = ctrl_obj; + + json_object *tx_mode_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_compressed_hdr_obj, "tx_mode", &tx_mode_obj)) + p->tx_mode = (__u8) json_object_get_int(tx_mode_obj); + + /* __u8 tx8[2][1] */ + int count_tx8 = 0; + json_object *tx8_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_compressed_hdr_obj, "tx8", &tx8_obj)) { + for (size_t i = 0; i < 2; i++) { + for (size_t j = 0; j < 1; j++) { + if (json_object_array_get_idx(tx8_obj, count_tx8)) + p->tx8[i][j] = (__u8) json_object_get_int(json_object_array_get_idx(tx8_obj, count_tx8++)); + } + } + } + + /* __u8 tx16[2][2] */ + int count_tx16 = 0; + json_object *tx16_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_compressed_hdr_obj, "tx16", &tx16_obj)) { + for (size_t i = 0; i < 2; i++) { + for (size_t j = 0; j < 2; j++) { + if (json_object_array_get_idx(tx16_obj, count_tx16)) + p->tx16[i][j] = (__u8) json_object_get_int(json_object_array_get_idx(tx16_obj, count_tx16++)); + } + } + } + + /* __u8 tx32[2][3] */ + int count_tx32 = 0; + json_object *tx32_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_compressed_hdr_obj, "tx32", &tx32_obj)) { + for (size_t i = 0; i < 2; i++) { + for (size_t j = 0; j < 3; j++) { + if (json_object_array_get_idx(tx32_obj, count_tx32)) + p->tx32[i][j] = (__u8) json_object_get_int(json_object_array_get_idx(tx32_obj, count_tx32++)); + } + } + } + + /* __u8 coef[4][2][2][6][6][3] */ + int count_coef = 0; + json_object *coef_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_compressed_hdr_obj, "coef", &coef_obj)) { + for (size_t i = 0; i < 4; i++) { + for (size_t j = 0; j < 2; j++) { + for (size_t k = 0; k < 2; k++) { + for (size_t l = 0; l < 6; l++) { + for (size_t m = 0; m < 6; m++) { + for (size_t n = 0; n < 3; n++) { + if (json_object_array_get_idx(coef_obj, count_coef)) + p->coef[i][j][k][l][m][n] = (__u8) json_object_get_int(json_object_array_get_idx(coef_obj, count_coef++)); + } + } + } + } + } + } + } + + /* __u8 skip[3] */ + json_object *skip_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_compressed_hdr_obj, "skip", &skip_obj)) { + for (size_t i = 0; i < 3; i++) { + if (json_object_array_get_idx(skip_obj, i)) + p->skip[i] = (__u8) json_object_get_int(json_object_array_get_idx(skip_obj, i)); + } + } + + /* __u8 inter_mode[7][3] */ + int count_inter_mode = 0; + json_object *inter_mode_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_compressed_hdr_obj, "inter_mode", &inter_mode_obj)) { + for (size_t i = 0; i < 7; i++) { + for (size_t j = 0; j < 3; j++) { + if (json_object_array_get_idx(inter_mode_obj, count_inter_mode)) + p->inter_mode[i][j] = (__u8) json_object_get_int(json_object_array_get_idx(inter_mode_obj, count_inter_mode++)); + } + } + } + + /* __u8 interp_filter[4][2] */ + int count_interp_filter = 0; + json_object *interp_filter_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_compressed_hdr_obj, "interp_filter", &interp_filter_obj)) { + for (size_t i = 0; i < 4; i++) { + for (size_t j = 0; j < 2; j++) { + if (json_object_array_get_idx(interp_filter_obj, count_interp_filter)) + p->interp_filter[i][j] = (__u8) json_object_get_int(json_object_array_get_idx(interp_filter_obj, count_interp_filter++)); + } + } + } + + /* __u8 is_inter[4] */ + json_object *is_inter_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_compressed_hdr_obj, "is_inter", &is_inter_obj)) { + for (size_t i = 0; i < 4; i++) { + if (json_object_array_get_idx(is_inter_obj, i)) + p->is_inter[i] = (__u8) json_object_get_int(json_object_array_get_idx(is_inter_obj, i)); + } + } + + /* __u8 comp_mode[5] */ + json_object *comp_mode_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_compressed_hdr_obj, "comp_mode", &comp_mode_obj)) { + for (size_t i = 0; i < 5; i++) { + if (json_object_array_get_idx(comp_mode_obj, i)) + p->comp_mode[i] = (__u8) json_object_get_int(json_object_array_get_idx(comp_mode_obj, i)); + } + } + + /* __u8 single_ref[5][2] */ + int count_single_ref = 0; + json_object *single_ref_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_compressed_hdr_obj, "single_ref", &single_ref_obj)) { + for (size_t i = 0; i < 5; i++) { + for (size_t j = 0; j < 2; j++) { + if (json_object_array_get_idx(single_ref_obj, count_single_ref)) + p->single_ref[i][j] = (__u8) json_object_get_int(json_object_array_get_idx(single_ref_obj, count_single_ref++)); + } + } + } + + /* __u8 comp_ref[5] */ + json_object *comp_ref_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_compressed_hdr_obj, "comp_ref", &comp_ref_obj)) { + for (size_t i = 0; i < 5; i++) { + if (json_object_array_get_idx(comp_ref_obj, i)) + p->comp_ref[i] = (__u8) json_object_get_int(json_object_array_get_idx(comp_ref_obj, i)); + } + } + + /* __u8 y_mode[4][9] */ + int count_y_mode = 0; + json_object *y_mode_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_compressed_hdr_obj, "y_mode", &y_mode_obj)) { + for (size_t i = 0; i < 4; i++) { + for (size_t j = 0; j < 9; j++) { + if (json_object_array_get_idx(y_mode_obj, count_y_mode)) + p->y_mode[i][j] = (__u8) json_object_get_int(json_object_array_get_idx(y_mode_obj, count_y_mode++)); + } + } + } + + /* __u8 uv_mode[10][9] */ + int count_uv_mode = 0; + json_object *uv_mode_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_compressed_hdr_obj, "uv_mode", &uv_mode_obj)) { + for (size_t i = 0; i < 10; i++) { + for (size_t j = 0; j < 9; j++) { + if (json_object_array_get_idx(uv_mode_obj, count_uv_mode)) + p->uv_mode[i][j] = (__u8) json_object_get_int(json_object_array_get_idx(uv_mode_obj, count_uv_mode++)); + } + } + } + + /* __u8 partition[16][3] */ + int count_partition = 0; + json_object *partition_obj; + if (json_object_object_get_ex(v4l2_ctrl_vp9_compressed_hdr_obj, "partition", &partition_obj)) { + for (size_t i = 0; i < 16; i++) { + for (size_t j = 0; j < 3; j++) { + if (json_object_array_get_idx(partition_obj, count_partition)) + p->partition[i][j] = (__u8) json_object_get_int(json_object_array_get_idx(partition_obj, count_partition++)); + } + } + } + + /* struct v4l2_vp9_mv_probs mv */ + json_object *mv_obj; + if (!json_object_object_get_ex(v4l2_ctrl_vp9_compressed_hdr_obj, "v4l2_vp9_mv_probs", &mv_obj)) + return p; + void *mv_ptr = (void *) retrace_v4l2_vp9_mv_probs_gen(mv_obj); + p->mv = *static_cast<struct v4l2_vp9_mv_probs*>(mv_ptr); + free(mv_ptr); + + return p; +} + +struct v4l2_ctrl_av1_sequence *retrace_v4l2_ctrl_av1_sequence_gen(json_object *ctrl_obj) +{ + struct v4l2_ctrl_av1_sequence *p = (struct v4l2_ctrl_av1_sequence *) calloc(1, sizeof(v4l2_ctrl_av1_sequence)); + json_object *v4l2_ctrl_av1_sequence_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_ctrl_av1_sequence", &v4l2_ctrl_av1_sequence_obj)) + v4l2_ctrl_av1_sequence_obj = ctrl_obj; + + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_sequence_obj, "flags", &flags_obj)) + p->flags = (__u32) s2flags(json_object_get_string(flags_obj), v4l2_av1_sequence_flag_def); + + json_object *seq_profile_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_sequence_obj, "seq_profile", &seq_profile_obj)) + p->seq_profile = (__u8) json_object_get_int(seq_profile_obj); + + json_object *order_hint_bits_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_sequence_obj, "order_hint_bits", &order_hint_bits_obj)) + p->order_hint_bits = (__u8) json_object_get_int(order_hint_bits_obj); + + json_object *bit_depth_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_sequence_obj, "bit_depth", &bit_depth_obj)) + p->bit_depth = (__u8) json_object_get_int(bit_depth_obj); + + json_object *max_frame_width_minus_1_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_sequence_obj, "max_frame_width_minus_1", &max_frame_width_minus_1_obj)) + p->max_frame_width_minus_1 = (__u16) json_object_get_int(max_frame_width_minus_1_obj); + + json_object *max_frame_height_minus_1_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_sequence_obj, "max_frame_height_minus_1", &max_frame_height_minus_1_obj)) + p->max_frame_height_minus_1 = (__u16) json_object_get_int(max_frame_height_minus_1_obj); + + return p; +} + +struct v4l2_ctrl_av1_tile_group_entry *retrace_v4l2_ctrl_av1_tile_group_entry_gen(json_object *ctrl_obj) +{ + struct v4l2_ctrl_av1_tile_group_entry *p = (struct v4l2_ctrl_av1_tile_group_entry *) calloc(1, sizeof(v4l2_ctrl_av1_tile_group_entry)); + json_object *v4l2_ctrl_av1_tile_group_entry_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_ctrl_av1_tile_group_entry", &v4l2_ctrl_av1_tile_group_entry_obj)) + v4l2_ctrl_av1_tile_group_entry_obj = ctrl_obj; + + json_object *tile_offset_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_tile_group_entry_obj, "tile_offset", &tile_offset_obj)) + p->tile_offset = (__u32) json_object_get_int64(tile_offset_obj); + + json_object *tile_size_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_tile_group_entry_obj, "tile_size", &tile_size_obj)) + p->tile_size = (__u32) json_object_get_int64(tile_size_obj); + + json_object *tile_row_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_tile_group_entry_obj, "tile_row", &tile_row_obj)) + p->tile_row = (__u32) json_object_get_int64(tile_row_obj); + + json_object *tile_col_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_tile_group_entry_obj, "tile_col", &tile_col_obj)) + p->tile_col = (__u32) json_object_get_int64(tile_col_obj); + + return p; +} + +struct v4l2_av1_global_motion *retrace_v4l2_av1_global_motion_gen(json_object *ctrl_obj) +{ + struct v4l2_av1_global_motion *p = (struct v4l2_av1_global_motion *) calloc(1, sizeof(v4l2_av1_global_motion)); + json_object *v4l2_av1_global_motion_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_av1_global_motion", &v4l2_av1_global_motion_obj)) + v4l2_av1_global_motion_obj = ctrl_obj; + + /* __u8 flags[V4L2_AV1_TOTAL_REFS_PER_FRAME] */ + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_av1_global_motion_obj, "flags", &flags_obj)) { + for (size_t i = 0; i < V4L2_AV1_TOTAL_REFS_PER_FRAME; i++) { + if (json_object_array_get_idx(flags_obj, i)) + p->flags[i] = (__u8) json_object_get_int(json_object_array_get_idx(flags_obj, i)); + } + } + + /* enum v4l2_av1_warp_model type[V4L2_AV1_TOTAL_REFS_PER_FRAME] */ + json_object *type_obj; + if (json_object_object_get_ex(v4l2_av1_global_motion_obj, "type", &type_obj)) { + for (size_t i = 0; i < V4L2_AV1_TOTAL_REFS_PER_FRAME; i++) { + if (json_object_array_get_idx(type_obj, i)) + p->type[i] = (v4l2_av1_warp_model) json_object_get_int(json_object_array_get_idx(type_obj, i)); + } + } + + /* __s32 params[V4L2_AV1_TOTAL_REFS_PER_FRAME][6] */ + int count_params = 0; + json_object *params_obj; + if (json_object_object_get_ex(v4l2_av1_global_motion_obj, "params", ¶ms_obj)) { + for (size_t i = 0; i < V4L2_AV1_TOTAL_REFS_PER_FRAME; i++) { + for (size_t j = 0; j < 6; j++) { + if (json_object_array_get_idx(params_obj, count_params)) + p->params[i][j] = (__s32) json_object_get_int(json_object_array_get_idx(params_obj, count_params++)); + } + } + } + + json_object *invalid_obj; + if (json_object_object_get_ex(v4l2_av1_global_motion_obj, "invalid", &invalid_obj)) + p->invalid = (__u8) json_object_get_int(invalid_obj); + + return p; +} + +struct v4l2_av1_loop_restoration *retrace_v4l2_av1_loop_restoration_gen(json_object *ctrl_obj) +{ + struct v4l2_av1_loop_restoration *p = (struct v4l2_av1_loop_restoration *) calloc(1, sizeof(v4l2_av1_loop_restoration)); + json_object *v4l2_av1_loop_restoration_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_av1_loop_restoration", &v4l2_av1_loop_restoration_obj)) + v4l2_av1_loop_restoration_obj = ctrl_obj; + + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_av1_loop_restoration_obj, "flags", &flags_obj)) + p->flags = (__u8) s2flags(json_object_get_string(flags_obj), v4l2_av1_loop_restoration_flag_def); + + json_object *lr_unit_shift_obj; + if (json_object_object_get_ex(v4l2_av1_loop_restoration_obj, "lr_unit_shift", &lr_unit_shift_obj)) + p->lr_unit_shift = (__u8) json_object_get_int(lr_unit_shift_obj); + + json_object *lr_uv_shift_obj; + if (json_object_object_get_ex(v4l2_av1_loop_restoration_obj, "lr_uv_shift", &lr_uv_shift_obj)) + p->lr_uv_shift = (__u8) json_object_get_int(lr_uv_shift_obj); + + /* enum v4l2_av1_frame_restoration_type frame_restoration_type[V4L2_AV1_NUM_PLANES_MAX] */ + json_object *frame_restoration_type_obj; + if (json_object_object_get_ex(v4l2_av1_loop_restoration_obj, "frame_restoration_type", &frame_restoration_type_obj)) { + for (size_t i = 0; i < V4L2_AV1_NUM_PLANES_MAX; i++) { + if (json_object_array_get_idx(frame_restoration_type_obj, i)) + p->frame_restoration_type[i] = (v4l2_av1_frame_restoration_type) json_object_get_int(json_object_array_get_idx(frame_restoration_type_obj, i)); + } + } + + /* __u32 loop_restoration_size[V4L2_AV1_MAX_NUM_PLANES] */ + json_object *loop_restoration_size_obj; + if (json_object_object_get_ex(v4l2_av1_loop_restoration_obj, "loop_restoration_size", &loop_restoration_size_obj)) { + for (size_t i = 0; i < V4L2_AV1_MAX_NUM_PLANES; i++) { + if (json_object_array_get_idx(loop_restoration_size_obj, i)) + p->loop_restoration_size[i] = (__u32) json_object_get_int64(json_object_array_get_idx(loop_restoration_size_obj, i)); + } + } + + return p; +} + +struct v4l2_av1_cdef *retrace_v4l2_av1_cdef_gen(json_object *ctrl_obj) +{ + struct v4l2_av1_cdef *p = (struct v4l2_av1_cdef *) calloc(1, sizeof(v4l2_av1_cdef)); + json_object *v4l2_av1_cdef_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_av1_cdef", &v4l2_av1_cdef_obj)) + v4l2_av1_cdef_obj = ctrl_obj; + + json_object *damping_minus_3_obj; + if (json_object_object_get_ex(v4l2_av1_cdef_obj, "damping_minus_3", &damping_minus_3_obj)) + p->damping_minus_3 = (__u8) json_object_get_int(damping_minus_3_obj); + + json_object *bits_obj; + if (json_object_object_get_ex(v4l2_av1_cdef_obj, "bits", &bits_obj)) + p->bits = (__u8) json_object_get_int(bits_obj); + + /* __u8 y_pri_strength[V4L2_AV1_CDEF_MAX] */ + json_object *y_pri_strength_obj; + if (json_object_object_get_ex(v4l2_av1_cdef_obj, "y_pri_strength", &y_pri_strength_obj)) { + for (size_t i = 0; i < V4L2_AV1_CDEF_MAX; i++) { + if (json_object_array_get_idx(y_pri_strength_obj, i)) + p->y_pri_strength[i] = (__u8) json_object_get_int(json_object_array_get_idx(y_pri_strength_obj, i)); + } + } + + /* __u8 y_sec_strength[V4L2_AV1_CDEF_MAX] */ + json_object *y_sec_strength_obj; + if (json_object_object_get_ex(v4l2_av1_cdef_obj, "y_sec_strength", &y_sec_strength_obj)) { + for (size_t i = 0; i < V4L2_AV1_CDEF_MAX; i++) { + if (json_object_array_get_idx(y_sec_strength_obj, i)) + p->y_sec_strength[i] = (__u8) json_object_get_int(json_object_array_get_idx(y_sec_strength_obj, i)); + } + } + + /* __u8 uv_pri_strength[V4L2_AV1_CDEF_MAX] */ + json_object *uv_pri_strength_obj; + if (json_object_object_get_ex(v4l2_av1_cdef_obj, "uv_pri_strength", &uv_pri_strength_obj)) { + for (size_t i = 0; i < V4L2_AV1_CDEF_MAX; i++) { + if (json_object_array_get_idx(uv_pri_strength_obj, i)) + p->uv_pri_strength[i] = (__u8) json_object_get_int(json_object_array_get_idx(uv_pri_strength_obj, i)); + } + } + + /* __u8 uv_sec_strength[V4L2_AV1_CDEF_MAX] */ + json_object *uv_sec_strength_obj; + if (json_object_object_get_ex(v4l2_av1_cdef_obj, "uv_sec_strength", &uv_sec_strength_obj)) { + for (size_t i = 0; i < V4L2_AV1_CDEF_MAX; i++) { + if (json_object_array_get_idx(uv_sec_strength_obj, i)) + p->uv_sec_strength[i] = (__u8) json_object_get_int(json_object_array_get_idx(uv_sec_strength_obj, i)); + } + } + + return p; +} + +struct v4l2_av1_segmentation *retrace_v4l2_av1_segmentation_gen(json_object *ctrl_obj) +{ + struct v4l2_av1_segmentation *p = (struct v4l2_av1_segmentation *) calloc(1, sizeof(v4l2_av1_segmentation)); + json_object *v4l2_av1_segmentation_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_av1_segmentation", &v4l2_av1_segmentation_obj)) + v4l2_av1_segmentation_obj = ctrl_obj; + + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_av1_segmentation_obj, "flags", &flags_obj)) + p->flags = (__u8) s2flags(json_object_get_string(flags_obj), v4l2_av1_segmentation_flag_def); + + json_object *last_active_seg_id_obj; + if (json_object_object_get_ex(v4l2_av1_segmentation_obj, "last_active_seg_id", &last_active_seg_id_obj)) + p->last_active_seg_id = (__u8) json_object_get_int(last_active_seg_id_obj); + + /* __u8 feature_enabled[V4L2_AV1_MAX_SEGMENTS] */ + json_object *feature_enabled_obj; + if (json_object_object_get_ex(v4l2_av1_segmentation_obj, "feature_enabled", &feature_enabled_obj)) { + for (size_t i = 0; i < V4L2_AV1_MAX_SEGMENTS; i++) { + if (json_object_array_get_idx(feature_enabled_obj, i)) + p->feature_enabled[i] = (__u8) json_object_get_int(json_object_array_get_idx(feature_enabled_obj, i)); + } + } + + /* __s16 feature_data[V4L2_AV1_MAX_SEGMENTS][V4L2_AV1_SEG_LVL_MAX] */ + int count_feature_data = 0; + json_object *feature_data_obj; + if (json_object_object_get_ex(v4l2_av1_segmentation_obj, "feature_data", &feature_data_obj)) { + for (size_t i = 0; i < V4L2_AV1_MAX_SEGMENTS; i++) { + for (size_t j = 0; j < V4L2_AV1_SEG_LVL_MAX; j++) { + if (json_object_array_get_idx(feature_data_obj, count_feature_data)) + p->feature_data[i][j] = (__s16) json_object_get_int(json_object_array_get_idx(feature_data_obj, count_feature_data++)); + } + } + } + + return p; +} + +struct v4l2_av1_loop_filter *retrace_v4l2_av1_loop_filter_gen(json_object *ctrl_obj) +{ + struct v4l2_av1_loop_filter *p = (struct v4l2_av1_loop_filter *) calloc(1, sizeof(v4l2_av1_loop_filter)); + json_object *v4l2_av1_loop_filter_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_av1_loop_filter", &v4l2_av1_loop_filter_obj)) + v4l2_av1_loop_filter_obj = ctrl_obj; + + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_av1_loop_filter_obj, "flags", &flags_obj)) + p->flags = (__u8) s2flags(json_object_get_string(flags_obj), v4l2_av1_loop_filter_flag_def); + + /* __u8 level[4] */ + json_object *level_obj; + if (json_object_object_get_ex(v4l2_av1_loop_filter_obj, "level", &level_obj)) { + for (size_t i = 0; i < 4; i++) { + if (json_object_array_get_idx(level_obj, i)) + p->level[i] = (__u8) json_object_get_int(json_object_array_get_idx(level_obj, i)); + } + } + + json_object *sharpness_obj; + if (json_object_object_get_ex(v4l2_av1_loop_filter_obj, "sharpness", &sharpness_obj)) + p->sharpness = (__u8) json_object_get_int(sharpness_obj); + + /* __s8 ref_deltas[V4L2_AV1_TOTAL_REFS_PER_FRAME] */ + json_object *ref_deltas_obj; + if (json_object_object_get_ex(v4l2_av1_loop_filter_obj, "ref_deltas", &ref_deltas_obj)) { + for (size_t i = 0; i < V4L2_AV1_TOTAL_REFS_PER_FRAME; i++) { + if (json_object_array_get_idx(ref_deltas_obj, i)) + p->ref_deltas[i] = (__s8) json_object_get_int(json_object_array_get_idx(ref_deltas_obj, i)); + } + } + + /* __s8 mode_deltas[2] */ + json_object *mode_deltas_obj; + if (json_object_object_get_ex(v4l2_av1_loop_filter_obj, "mode_deltas", &mode_deltas_obj)) { + for (size_t i = 0; i < 2; i++) { + if (json_object_array_get_idx(mode_deltas_obj, i)) + p->mode_deltas[i] = (__s8) json_object_get_int(json_object_array_get_idx(mode_deltas_obj, i)); + } + } + + json_object *delta_lf_res_obj; + if (json_object_object_get_ex(v4l2_av1_loop_filter_obj, "delta_lf_res", &delta_lf_res_obj)) + p->delta_lf_res = (__u8) json_object_get_int(delta_lf_res_obj); + + return p; +} + +struct v4l2_av1_quantization *retrace_v4l2_av1_quantization_gen(json_object *ctrl_obj) +{ + struct v4l2_av1_quantization *p = (struct v4l2_av1_quantization *) calloc(1, sizeof(v4l2_av1_quantization)); + json_object *v4l2_av1_quantization_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_av1_quantization", &v4l2_av1_quantization_obj)) + v4l2_av1_quantization_obj = ctrl_obj; + + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_av1_quantization_obj, "flags", &flags_obj)) + p->flags = (__u8) s2flags(json_object_get_string(flags_obj), v4l2_av1_quantization_flag_def); + + json_object *base_q_idx_obj; + if (json_object_object_get_ex(v4l2_av1_quantization_obj, "base_q_idx", &base_q_idx_obj)) + p->base_q_idx = (__u8) json_object_get_int(base_q_idx_obj); + + json_object *delta_q_y_dc_obj; + if (json_object_object_get_ex(v4l2_av1_quantization_obj, "delta_q_y_dc", &delta_q_y_dc_obj)) + p->delta_q_y_dc = (__s8) json_object_get_int(delta_q_y_dc_obj); + + json_object *delta_q_u_dc_obj; + if (json_object_object_get_ex(v4l2_av1_quantization_obj, "delta_q_u_dc", &delta_q_u_dc_obj)) + p->delta_q_u_dc = (__s8) json_object_get_int(delta_q_u_dc_obj); + + json_object *delta_q_u_ac_obj; + if (json_object_object_get_ex(v4l2_av1_quantization_obj, "delta_q_u_ac", &delta_q_u_ac_obj)) + p->delta_q_u_ac = (__s8) json_object_get_int(delta_q_u_ac_obj); + + json_object *delta_q_v_dc_obj; + if (json_object_object_get_ex(v4l2_av1_quantization_obj, "delta_q_v_dc", &delta_q_v_dc_obj)) + p->delta_q_v_dc = (__s8) json_object_get_int(delta_q_v_dc_obj); + + json_object *delta_q_v_ac_obj; + if (json_object_object_get_ex(v4l2_av1_quantization_obj, "delta_q_v_ac", &delta_q_v_ac_obj)) + p->delta_q_v_ac = (__s8) json_object_get_int(delta_q_v_ac_obj); + + json_object *qm_y_obj; + if (json_object_object_get_ex(v4l2_av1_quantization_obj, "qm_y", &qm_y_obj)) + p->qm_y = (__u8) json_object_get_int(qm_y_obj); + + json_object *qm_u_obj; + if (json_object_object_get_ex(v4l2_av1_quantization_obj, "qm_u", &qm_u_obj)) + p->qm_u = (__u8) json_object_get_int(qm_u_obj); + + json_object *qm_v_obj; + if (json_object_object_get_ex(v4l2_av1_quantization_obj, "qm_v", &qm_v_obj)) + p->qm_v = (__u8) json_object_get_int(qm_v_obj); + + json_object *delta_q_res_obj; + if (json_object_object_get_ex(v4l2_av1_quantization_obj, "delta_q_res", &delta_q_res_obj)) + p->delta_q_res = (__u8) json_object_get_int(delta_q_res_obj); + + return p; +} + +struct v4l2_av1_tile_info *retrace_v4l2_av1_tile_info_gen(json_object *ctrl_obj) +{ + struct v4l2_av1_tile_info *p = (struct v4l2_av1_tile_info *) calloc(1, sizeof(v4l2_av1_tile_info)); + json_object *v4l2_av1_tile_info_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_av1_tile_info", &v4l2_av1_tile_info_obj)) + v4l2_av1_tile_info_obj = ctrl_obj; + + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_av1_tile_info_obj, "flags", &flags_obj)) + p->flags = (__u8) s2flags(json_object_get_string(flags_obj), v4l2_av1_tile_info_flag_def); + + json_object *context_update_tile_id_obj; + if (json_object_object_get_ex(v4l2_av1_tile_info_obj, "context_update_tile_id", &context_update_tile_id_obj)) + p->context_update_tile_id = (__u8) json_object_get_int(context_update_tile_id_obj); + + json_object *tile_cols_obj; + if (json_object_object_get_ex(v4l2_av1_tile_info_obj, "tile_cols", &tile_cols_obj)) + p->tile_cols = (__u8) json_object_get_int(tile_cols_obj); + + json_object *tile_rows_obj; + if (json_object_object_get_ex(v4l2_av1_tile_info_obj, "tile_rows", &tile_rows_obj)) + p->tile_rows = (__u8) json_object_get_int(tile_rows_obj); + + /* __u32 mi_col_starts[V4L2_AV1_MAX_TILE_COLS + 1] */ + json_object *mi_col_starts_obj; + if (json_object_object_get_ex(v4l2_av1_tile_info_obj, "mi_col_starts", &mi_col_starts_obj)) { + for (size_t i = 0; i < V4L2_AV1_MAX_TILE_COLS + 1; i++) { + if (json_object_array_get_idx(mi_col_starts_obj, i)) + p->mi_col_starts[i] = (__u32) json_object_get_int64(json_object_array_get_idx(mi_col_starts_obj, i)); + } + } + + /* __u32 mi_row_starts[V4L2_AV1_MAX_TILE_ROWS + 1] */ + json_object *mi_row_starts_obj; + if (json_object_object_get_ex(v4l2_av1_tile_info_obj, "mi_row_starts", &mi_row_starts_obj)) { + for (size_t i = 0; i < V4L2_AV1_MAX_TILE_ROWS + 1; i++) { + if (json_object_array_get_idx(mi_row_starts_obj, i)) + p->mi_row_starts[i] = (__u32) json_object_get_int64(json_object_array_get_idx(mi_row_starts_obj, i)); + } + } + + /* __u32 width_in_sbs_minus_1[V4L2_AV1_MAX_TILE_COLS] */ + json_object *width_in_sbs_minus_1_obj; + if (json_object_object_get_ex(v4l2_av1_tile_info_obj, "width_in_sbs_minus_1", &width_in_sbs_minus_1_obj)) { + for (size_t i = 0; i < V4L2_AV1_MAX_TILE_COLS; i++) { + if (json_object_array_get_idx(width_in_sbs_minus_1_obj, i)) + p->width_in_sbs_minus_1[i] = (__u32) json_object_get_int64(json_object_array_get_idx(width_in_sbs_minus_1_obj, i)); + } + } + + /* __u32 height_in_sbs_minus_1[V4L2_AV1_MAX_TILE_ROWS] */ + json_object *height_in_sbs_minus_1_obj; + if (json_object_object_get_ex(v4l2_av1_tile_info_obj, "height_in_sbs_minus_1", &height_in_sbs_minus_1_obj)) { + for (size_t i = 0; i < V4L2_AV1_MAX_TILE_ROWS; i++) { + if (json_object_array_get_idx(height_in_sbs_minus_1_obj, i)) + p->height_in_sbs_minus_1[i] = (__u32) json_object_get_int64(json_object_array_get_idx(height_in_sbs_minus_1_obj, i)); + } + } + + json_object *tile_size_bytes_obj; + if (json_object_object_get_ex(v4l2_av1_tile_info_obj, "tile_size_bytes", &tile_size_bytes_obj)) + p->tile_size_bytes = (__u8) json_object_get_int(tile_size_bytes_obj); + + return p; +} + +struct v4l2_ctrl_av1_frame *retrace_v4l2_ctrl_av1_frame_gen(json_object *ctrl_obj) +{ + struct v4l2_ctrl_av1_frame *p = (struct v4l2_ctrl_av1_frame *) calloc(1, sizeof(v4l2_ctrl_av1_frame)); + json_object *v4l2_ctrl_av1_frame_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_ctrl_av1_frame", &v4l2_ctrl_av1_frame_obj)) + v4l2_ctrl_av1_frame_obj = ctrl_obj; + + /* struct v4l2_av1_tile_info tile_info */ + json_object *tile_info_obj; + if (!json_object_object_get_ex(v4l2_ctrl_av1_frame_obj, "v4l2_av1_tile_info", &tile_info_obj)) + return p; + void *tile_info_ptr = (void *) retrace_v4l2_av1_tile_info_gen(tile_info_obj); + p->tile_info = *static_cast<struct v4l2_av1_tile_info*>(tile_info_ptr); + free(tile_info_ptr); + + /* struct v4l2_av1_quantization quantization */ + json_object *quantization_obj; + if (!json_object_object_get_ex(v4l2_ctrl_av1_frame_obj, "v4l2_av1_quantization", &quantization_obj)) + return p; + void *quantization_ptr = (void *) retrace_v4l2_av1_quantization_gen(quantization_obj); + p->quantization = *static_cast<struct v4l2_av1_quantization*>(quantization_ptr); + free(quantization_ptr); + + json_object *superres_denom_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_frame_obj, "superres_denom", &superres_denom_obj)) + p->superres_denom = (__u8) json_object_get_int(superres_denom_obj); + + /* struct v4l2_av1_segmentation segmentation */ + json_object *segmentation_obj; + if (!json_object_object_get_ex(v4l2_ctrl_av1_frame_obj, "v4l2_av1_segmentation", &segmentation_obj)) + return p; + void *segmentation_ptr = (void *) retrace_v4l2_av1_segmentation_gen(segmentation_obj); + p->segmentation = *static_cast<struct v4l2_av1_segmentation*>(segmentation_ptr); + free(segmentation_ptr); + + /* struct v4l2_av1_loop_filter loop_filter */ + json_object *loop_filter_obj; + if (!json_object_object_get_ex(v4l2_ctrl_av1_frame_obj, "v4l2_av1_loop_filter", &loop_filter_obj)) + return p; + void *loop_filter_ptr = (void *) retrace_v4l2_av1_loop_filter_gen(loop_filter_obj); + p->loop_filter = *static_cast<struct v4l2_av1_loop_filter*>(loop_filter_ptr); + free(loop_filter_ptr); + + /* struct v4l2_av1_cdef cdef */ + json_object *cdef_obj; + if (!json_object_object_get_ex(v4l2_ctrl_av1_frame_obj, "v4l2_av1_cdef", &cdef_obj)) + return p; + void *cdef_ptr = (void *) retrace_v4l2_av1_cdef_gen(cdef_obj); + p->cdef = *static_cast<struct v4l2_av1_cdef*>(cdef_ptr); + free(cdef_ptr); + + /* __u8 skip_mode_frame[2] */ + json_object *skip_mode_frame_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_frame_obj, "skip_mode_frame", &skip_mode_frame_obj)) { + for (size_t i = 0; i < 2; i++) { + if (json_object_array_get_idx(skip_mode_frame_obj, i)) + p->skip_mode_frame[i] = (__u8) json_object_get_int(json_object_array_get_idx(skip_mode_frame_obj, i)); + } + } + + json_object *primary_ref_frame_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_frame_obj, "primary_ref_frame", &primary_ref_frame_obj)) + p->primary_ref_frame = (__u8) json_object_get_int(primary_ref_frame_obj); + + /* struct v4l2_av1_loop_restoration loop_restoration */ + json_object *loop_restoration_obj; + if (!json_object_object_get_ex(v4l2_ctrl_av1_frame_obj, "v4l2_av1_loop_restoration", &loop_restoration_obj)) + return p; + void *loop_restoration_ptr = (void *) retrace_v4l2_av1_loop_restoration_gen(loop_restoration_obj); + p->loop_restoration = *static_cast<struct v4l2_av1_loop_restoration*>(loop_restoration_ptr); + free(loop_restoration_ptr); + + /* struct v4l2_av1_global_motion global_motion */ + json_object *global_motion_obj; + if (!json_object_object_get_ex(v4l2_ctrl_av1_frame_obj, "v4l2_av1_global_motion", &global_motion_obj)) + return p; + void *global_motion_ptr = (void *) retrace_v4l2_av1_global_motion_gen(global_motion_obj); + p->global_motion = *static_cast<struct v4l2_av1_global_motion*>(global_motion_ptr); + free(global_motion_ptr); + + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_frame_obj, "flags", &flags_obj)) + p->flags = (__u32) s2flags(json_object_get_string(flags_obj), v4l2_av1_frame_flag_def); + + json_object *frame_type_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_frame_obj, "frame_type", &frame_type_obj)) + p->frame_type = (v4l2_av1_frame_type) json_object_get_int(frame_type_obj); + + json_object *order_hint_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_frame_obj, "order_hint", &order_hint_obj)) + p->order_hint = (__u32) json_object_get_int64(order_hint_obj); + + json_object *upscaled_width_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_frame_obj, "upscaled_width", &upscaled_width_obj)) + p->upscaled_width = (__u32) json_object_get_int64(upscaled_width_obj); + + json_object *interpolation_filter_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_frame_obj, "interpolation_filter", &interpolation_filter_obj)) + p->interpolation_filter = (v4l2_av1_interpolation_filter) json_object_get_int(interpolation_filter_obj); + + json_object *tx_mode_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_frame_obj, "tx_mode", &tx_mode_obj)) + p->tx_mode = (v4l2_av1_tx_mode) json_object_get_int(tx_mode_obj); + + json_object *frame_width_minus_1_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_frame_obj, "frame_width_minus_1", &frame_width_minus_1_obj)) + p->frame_width_minus_1 = (__u32) json_object_get_int64(frame_width_minus_1_obj); + + json_object *frame_height_minus_1_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_frame_obj, "frame_height_minus_1", &frame_height_minus_1_obj)) + p->frame_height_minus_1 = (__u32) json_object_get_int64(frame_height_minus_1_obj); + + json_object *render_width_minus_1_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_frame_obj, "render_width_minus_1", &render_width_minus_1_obj)) + p->render_width_minus_1 = (__u16) json_object_get_int(render_width_minus_1_obj); + + json_object *render_height_minus_1_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_frame_obj, "render_height_minus_1", &render_height_minus_1_obj)) + p->render_height_minus_1 = (__u16) json_object_get_int(render_height_minus_1_obj); + + json_object *current_frame_id_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_frame_obj, "current_frame_id", ¤t_frame_id_obj)) + p->current_frame_id = (__u32) json_object_get_int64(current_frame_id_obj); + + /* __u32 buffer_removal_time[V4L2_AV1_MAX_OPERATING_POINTS] */ + json_object *buffer_removal_time_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_frame_obj, "buffer_removal_time", &buffer_removal_time_obj)) { + for (size_t i = 0; i < V4L2_AV1_MAX_OPERATING_POINTS; i++) { + if (json_object_array_get_idx(buffer_removal_time_obj, i)) + p->buffer_removal_time[i] = (__u32) json_object_get_int64(json_object_array_get_idx(buffer_removal_time_obj, i)); + } + } + + /* __u32 order_hints[V4L2_AV1_TOTAL_REFS_PER_FRAME] */ + json_object *order_hints_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_frame_obj, "order_hints", &order_hints_obj)) { + for (size_t i = 0; i < V4L2_AV1_TOTAL_REFS_PER_FRAME; i++) { + if (json_object_array_get_idx(order_hints_obj, i)) + p->order_hints[i] = (__u32) json_object_get_int64(json_object_array_get_idx(order_hints_obj, i)); + } + } + + /* __u64 reference_frame_ts[V4L2_AV1_TOTAL_REFS_PER_FRAME] */ + json_object *reference_frame_ts_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_frame_obj, "reference_frame_ts", &reference_frame_ts_obj)) { + for (size_t i = 0; i < V4L2_AV1_TOTAL_REFS_PER_FRAME; i++) { + if (json_object_array_get_idx(reference_frame_ts_obj, i)) + p->reference_frame_ts[i] = (__u64) json_object_get_uint64(json_object_array_get_idx(reference_frame_ts_obj, i)); + } + } + + /* __s8 ref_frame_idx[V4L2_AV1_REFS_PER_FRAME] */ + json_object *ref_frame_idx_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_frame_obj, "ref_frame_idx", &ref_frame_idx_obj)) { + for (size_t i = 0; i < V4L2_AV1_REFS_PER_FRAME; i++) { + if (json_object_array_get_idx(ref_frame_idx_obj, i)) + p->ref_frame_idx[i] = (__s8) json_object_get_int(json_object_array_get_idx(ref_frame_idx_obj, i)); + } + } + + json_object *refresh_frame_flags_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_frame_obj, "refresh_frame_flags", &refresh_frame_flags_obj)) + p->refresh_frame_flags = (__u8) s2flags(json_object_get_string(refresh_frame_flags_obj), v4l2_av1_frame_flag_def); + + return p; +} + +struct v4l2_ctrl_av1_film_grain *retrace_v4l2_ctrl_av1_film_grain_gen(json_object *ctrl_obj) +{ + struct v4l2_ctrl_av1_film_grain *p = (struct v4l2_ctrl_av1_film_grain *) calloc(1, sizeof(v4l2_ctrl_av1_film_grain)); + json_object *v4l2_ctrl_av1_film_grain_obj; + if (!json_object_object_get_ex(ctrl_obj, "v4l2_ctrl_av1_film_grain", &v4l2_ctrl_av1_film_grain_obj)) + v4l2_ctrl_av1_film_grain_obj = ctrl_obj; + + json_object *flags_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_film_grain_obj, "flags", &flags_obj)) + p->flags = (__u8) s2flags(json_object_get_string(flags_obj), v4l2_av1_film_grain_flag_def); + + json_object *cr_mult_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_film_grain_obj, "cr_mult", &cr_mult_obj)) + p->cr_mult = (__u8) json_object_get_int(cr_mult_obj); + + json_object *grain_seed_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_film_grain_obj, "grain_seed", &grain_seed_obj)) + p->grain_seed = (__u16) json_object_get_int(grain_seed_obj); + + json_object *film_grain_params_ref_idx_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_film_grain_obj, "film_grain_params_ref_idx", &film_grain_params_ref_idx_obj)) + p->film_grain_params_ref_idx = (__u8) json_object_get_int(film_grain_params_ref_idx_obj); + + json_object *num_y_points_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_film_grain_obj, "num_y_points", &num_y_points_obj)) + p->num_y_points = (__u8) json_object_get_int(num_y_points_obj); + + /* __u8 point_y_value[V4L2_AV1_MAX_NUM_Y_POINTS] */ + json_object *point_y_value_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_film_grain_obj, "point_y_value", &point_y_value_obj)) { + for (size_t i = 0; i < V4L2_AV1_MAX_NUM_Y_POINTS; i++) { + if (json_object_array_get_idx(point_y_value_obj, i)) + p->point_y_value[i] = (__u8) json_object_get_int(json_object_array_get_idx(point_y_value_obj, i)); + } + } + + /* __u8 point_y_scaling[V4L2_AV1_MAX_NUM_Y_POINTS] */ + json_object *point_y_scaling_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_film_grain_obj, "point_y_scaling", &point_y_scaling_obj)) { + for (size_t i = 0; i < V4L2_AV1_MAX_NUM_Y_POINTS; i++) { + if (json_object_array_get_idx(point_y_scaling_obj, i)) + p->point_y_scaling[i] = (__u8) json_object_get_int(json_object_array_get_idx(point_y_scaling_obj, i)); + } + } + + json_object *num_cb_points_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_film_grain_obj, "num_cb_points", &num_cb_points_obj)) + p->num_cb_points = (__u8) json_object_get_int(num_cb_points_obj); + + /* __u8 point_cb_value[V4L2_AV1_MAX_NUM_CB_POINTS] */ + json_object *point_cb_value_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_film_grain_obj, "point_cb_value", &point_cb_value_obj)) { + for (size_t i = 0; i < V4L2_AV1_MAX_NUM_CB_POINTS; i++) { + if (json_object_array_get_idx(point_cb_value_obj, i)) + p->point_cb_value[i] = (__u8) json_object_get_int(json_object_array_get_idx(point_cb_value_obj, i)); + } + } + + /* __u8 point_cb_scaling[V4L2_AV1_MAX_NUM_CB_POINTS] */ + json_object *point_cb_scaling_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_film_grain_obj, "point_cb_scaling", &point_cb_scaling_obj)) { + for (size_t i = 0; i < V4L2_AV1_MAX_NUM_CB_POINTS; i++) { + if (json_object_array_get_idx(point_cb_scaling_obj, i)) + p->point_cb_scaling[i] = (__u8) json_object_get_int(json_object_array_get_idx(point_cb_scaling_obj, i)); + } + } + + json_object *num_cr_points_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_film_grain_obj, "num_cr_points", &num_cr_points_obj)) + p->num_cr_points = (__u8) json_object_get_int(num_cr_points_obj); + + /* __u8 point_cr_value[V4L2_AV1_MAX_NUM_CR_POINTS] */ + json_object *point_cr_value_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_film_grain_obj, "point_cr_value", &point_cr_value_obj)) { + for (size_t i = 0; i < V4L2_AV1_MAX_NUM_CR_POINTS; i++) { + if (json_object_array_get_idx(point_cr_value_obj, i)) + p->point_cr_value[i] = (__u8) json_object_get_int(json_object_array_get_idx(point_cr_value_obj, i)); + } + } + + /* __u8 point_cr_scaling[V4L2_AV1_MAX_NUM_CR_POINTS] */ + json_object *point_cr_scaling_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_film_grain_obj, "point_cr_scaling", &point_cr_scaling_obj)) { + for (size_t i = 0; i < V4L2_AV1_MAX_NUM_CR_POINTS; i++) { + if (json_object_array_get_idx(point_cr_scaling_obj, i)) + p->point_cr_scaling[i] = (__u8) json_object_get_int(json_object_array_get_idx(point_cr_scaling_obj, i)); + } + } + + json_object *grain_scaling_minus_8_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_film_grain_obj, "grain_scaling_minus_8", &grain_scaling_minus_8_obj)) + p->grain_scaling_minus_8 = (__u8) json_object_get_int(grain_scaling_minus_8_obj); + + json_object *ar_coeff_lag_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_film_grain_obj, "ar_coeff_lag", &ar_coeff_lag_obj)) + p->ar_coeff_lag = (__u8) json_object_get_int(ar_coeff_lag_obj); + + /* __u8 ar_coeffs_y_plus_128[V4L2_AV1_AR_COEFFS_SIZE] */ + json_object *ar_coeffs_y_plus_128_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_film_grain_obj, "ar_coeffs_y_plus_128", &ar_coeffs_y_plus_128_obj)) { + for (size_t i = 0; i < V4L2_AV1_AR_COEFFS_SIZE; i++) { + if (json_object_array_get_idx(ar_coeffs_y_plus_128_obj, i)) + p->ar_coeffs_y_plus_128[i] = (__u8) json_object_get_int(json_object_array_get_idx(ar_coeffs_y_plus_128_obj, i)); + } + } + + /* __u8 ar_coeffs_cb_plus_128[V4L2_AV1_AR_COEFFS_SIZE] */ + json_object *ar_coeffs_cb_plus_128_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_film_grain_obj, "ar_coeffs_cb_plus_128", &ar_coeffs_cb_plus_128_obj)) { + for (size_t i = 0; i < V4L2_AV1_AR_COEFFS_SIZE; i++) { + if (json_object_array_get_idx(ar_coeffs_cb_plus_128_obj, i)) + p->ar_coeffs_cb_plus_128[i] = (__u8) json_object_get_int(json_object_array_get_idx(ar_coeffs_cb_plus_128_obj, i)); + } + } + + /* __u8 ar_coeffs_cr_plus_128[V4L2_AV1_AR_COEFFS_SIZE] */ + json_object *ar_coeffs_cr_plus_128_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_film_grain_obj, "ar_coeffs_cr_plus_128", &ar_coeffs_cr_plus_128_obj)) { + for (size_t i = 0; i < V4L2_AV1_AR_COEFFS_SIZE; i++) { + if (json_object_array_get_idx(ar_coeffs_cr_plus_128_obj, i)) + p->ar_coeffs_cr_plus_128[i] = (__u8) json_object_get_int(json_object_array_get_idx(ar_coeffs_cr_plus_128_obj, i)); + } + } + + json_object *ar_coeff_shift_minus_6_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_film_grain_obj, "ar_coeff_shift_minus_6", &ar_coeff_shift_minus_6_obj)) + p->ar_coeff_shift_minus_6 = (__u8) json_object_get_int(ar_coeff_shift_minus_6_obj); + + json_object *grain_scale_shift_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_film_grain_obj, "grain_scale_shift", &grain_scale_shift_obj)) + p->grain_scale_shift = (__u8) json_object_get_int(grain_scale_shift_obj); + + json_object *cb_mult_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_film_grain_obj, "cb_mult", &cb_mult_obj)) + p->cb_mult = (__u8) json_object_get_int(cb_mult_obj); + + json_object *cb_luma_mult_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_film_grain_obj, "cb_luma_mult", &cb_luma_mult_obj)) + p->cb_luma_mult = (__u8) json_object_get_int(cb_luma_mult_obj); + + json_object *cr_luma_mult_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_film_grain_obj, "cr_luma_mult", &cr_luma_mult_obj)) + p->cr_luma_mult = (__u8) json_object_get_int(cr_luma_mult_obj); + + json_object *cb_offset_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_film_grain_obj, "cb_offset", &cb_offset_obj)) + p->cb_offset = (__u16) json_object_get_int(cb_offset_obj); + + json_object *cr_offset_obj; + if (json_object_object_get_ex(v4l2_ctrl_av1_film_grain_obj, "cr_offset", &cr_offset_obj)) + p->cr_offset = (__u16) json_object_get_int(cr_offset_obj); + + return p; +} + +struct v4l2_rect *retrace_v4l2_rect_gen(json_object *parent_obj, std::string key_name = "") +{ + struct v4l2_rect *p = (struct v4l2_rect *) calloc(1, sizeof(v4l2_rect)); + + json_object *v4l2_rect_obj; + if (key_name.empty()) + json_object_object_get_ex(parent_obj, "v4l2_rect", &v4l2_rect_obj); + else + json_object_object_get_ex(parent_obj, key_name.c_str(), &v4l2_rect_obj); + + json_object *left_obj; + if (json_object_object_get_ex(v4l2_rect_obj, "left", &left_obj)) + p->left = (__s32) json_object_get_int(left_obj); + + json_object *top_obj; + if (json_object_object_get_ex(v4l2_rect_obj, "top", &top_obj)) + p->top = (__s32) json_object_get_int(top_obj); + + json_object *width_obj; + if (json_object_object_get_ex(v4l2_rect_obj, "width", &width_obj)) + p->width = (__u32) json_object_get_int64(width_obj); + + json_object *height_obj; + if (json_object_object_get_ex(v4l2_rect_obj, "height", &height_obj)) + p->height = (__u32) json_object_get_int64(height_obj); + + return p; +} +struct v4l2_fract *retrace_v4l2_fract_gen(json_object *parent_obj, std::string key_name = "") +{ + struct v4l2_fract *p = (struct v4l2_fract *) calloc(1, sizeof(v4l2_fract)); + + json_object *v4l2_fract_obj; + if (key_name.empty()) + json_object_object_get_ex(parent_obj, "v4l2_fract", &v4l2_fract_obj); + else + json_object_object_get_ex(parent_obj, key_name.c_str(), &v4l2_fract_obj); + + json_object *numerator_obj; + if (json_object_object_get_ex(v4l2_fract_obj, "numerator", &numerator_obj)) + p->numerator = (__u32) json_object_get_int64(numerator_obj); + + json_object *denominator_obj; + if (json_object_object_get_ex(v4l2_fract_obj, "denominator", &denominator_obj)) + p->denominator = (__u32) json_object_get_int64(denominator_obj); + + return p; +} +struct v4l2_area *retrace_v4l2_area_gen(json_object *parent_obj, std::string key_name = "") +{ + struct v4l2_area *p = (struct v4l2_area *) calloc(1, sizeof(v4l2_area)); + + json_object *v4l2_area_obj; + if (key_name.empty()) + json_object_object_get_ex(parent_obj, "v4l2_area", &v4l2_area_obj); + else + json_object_object_get_ex(parent_obj, key_name.c_str(), &v4l2_area_obj); + + json_object *width_obj; + if (json_object_object_get_ex(v4l2_area_obj, "width", &width_obj)) + p->width = (__u32) json_object_get_int64(width_obj); + + json_object *height_obj; + if (json_object_object_get_ex(v4l2_area_obj, "height", &height_obj)) + p->height = (__u32) json_object_get_int64(height_obj); + + return p; +} +struct v4l2_capability *retrace_v4l2_capability_gen(json_object *parent_obj, std::string key_name = "") +{ + struct v4l2_capability *p = (struct v4l2_capability *) calloc(1, sizeof(v4l2_capability)); + + json_object *v4l2_capability_obj; + if (key_name.empty()) + json_object_object_get_ex(parent_obj, "v4l2_capability", &v4l2_capability_obj); + else + json_object_object_get_ex(parent_obj, key_name.c_str(), &v4l2_capability_obj); + + json_object *driver_obj; + if (json_object_object_get_ex(v4l2_capability_obj, "driver", &driver_obj)) + if (json_object_get_string(driver_obj) != nullptr) + memcpy(p->driver, json_object_get_string(driver_obj), 16);
Lines of this file are not shown. View the raw message.
utils/v4l2-tracer/retrace-gen.h new file +144 -0
144 lines not on this page · raw message
utils/v4l2-tracer/trace-gen.cpp new file +3225 -0
3,225 lines not on this page · raw message
utils/v4l2-tracer/trace-gen.h new file +144 -0
144 lines not on this page · raw message
utils/v4l2-tracer/v4l2-tracer-info-gen.h new file +2419 -0
2,419 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.41.0
Part of the diff is not shown here. View the raw message.
PATCH v2 3/4 v4l2-tracer: stop auto-generating files with meson
In reply to Deborah BrouwerStop using meson to run the v4l2-tracer autogeneration script. Instead just handle these autogenerated files like any other file source.
--- utils/v4l2-tracer/meson.build | 55 ++--------------------------------- 1 file changed, 3 insertions(+), 52 deletions(-)
utils/v4l2-tracer/meson.build +3 -52
@@ -2,48 +2,6 @@ if not dep_jsonc.found() subdir_done() endif -# Generated sources - -v4l2_tracer_gen = files('v4l2-tracer-gen.pl') - -# Don't reorder the inputs The order of the input headers matters -v4l2_tracer_gen_inputs = files( - '..' / '..' / 'include' / 'linux' / 'v4l2-controls.h', - '..' / '..' / 'include' / 'linux' / 'videodev2.h', - '..' / '..' / 'include' / 'linux' / 'media.h', - '..' / '..' / 'include' / 'linux' / 'v4l2-common.h', -) - -v4l2_tracer_gen_common_sources = custom_target('v4l2-tracer-gen-common-sources', - input : v4l2_tracer_gen_inputs, - output : ['v4l2-tracer-info-gen.h'], - command : [ - v4l2_tracer_gen, - '-o', meson.current_build_dir(), - '-t', 'common', - '@INPUT@', - ]) - -v4l2_tracer_gen_retrace_sources = custom_target('v4l2-tracer-gen-retrace-sources', - input : v4l2_tracer_gen_inputs, - output : ['retrace-gen.cpp', 'retrace-gen.h'], - command : [ - v4l2_tracer_gen, - '-o', meson.current_build_dir(), - '-t', 'retrace', - '@INPUT@', - ]) - -v4l2_tracer_gen_trace_sources = custom_target('v4l2-tracer-gen-trace-sources', - input : v4l2_tracer_gen_inputs, - output : ['trace-gen.cpp', 'trace-gen.h'], - command : [ - v4l2_tracer_gen, - '-o', meson.current_build_dir(), - '-t', 'trace', - '@INPUT@', - ]) - # V4L2 tracer library libv4l2tracer_sources = files(
@@ -51,15 +9,11 @@ libv4l2tracer_sources = files( 'media-info.cpp', 'trace-helper.cpp', 'trace.cpp', + 'trace-gen.cpp', 'v4l2-info.cpp', 'v4l2-tracer-common.cpp', ) -libv4l2tracer_sources += [ - v4l2_tracer_gen_common_sources, - v4l2_tracer_gen_trace_sources, -] - libv4l2tracer_deps = [ dep_jsonc, dep_libdl,
@@ -84,15 +38,12 @@ v4l2_tracer_sources = files( 'retrace-helper.cpp', 'retrace.cpp', 'v4l2-info.cpp', + 'trace-gen.cpp', + 'retrace-gen.cpp', 'v4l2-tracer-common.cpp', 'v4l2-tracer.cpp', ) -v4l2_tracer_sources += [ - v4l2_tracer_gen_common_sources, - v4l2_tracer_gen_retrace_sources, -] - v4l2_tracer_deps = [ dep_jsonc, dep_librt,
Signature · 1 line
2.41.0
PATCH v2 4/4 sync-with-kernel.sh: create v4l2-tracer patches
In reply to Deborah BrouwerAfter v4l-utils is synced with the latest kernel headers, generate and apply patches for the changes that need to be made to the v4l2-tracer. This makes it easier to see how the kernel headers are changing the v4l2-tracer and also to revert those changes if necessary.
--- sync-with-kernel.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
sync-with-kernel.sh +27 -0
@@ -115,8 +115,35 @@ function freebsd { quilt push -a } +function v4l2-tracer { + V4L2TRACERDIR="${TOPSRCDIR}/utils/v4l2-tracer" + V4L2TRACERSOURCES="${TOPSRCDIR}/include/linux/v4l2-controls.h " + V4L2TRACERSOURCES+="${TOPSRCDIR}/include/linux/videodev2.h " + V4L2TRACERSOURCES+="${TOPSRCDIR}/include/linux/media.h " + V4L2TRACERSOURCES+="${TOPSRCDIR}/include/linux/v4l2-common.h " + + TMPDIR=$(mktemp -d "${V4L2TRACERDIR}/v4l2-tracer-gen.XXXXXXXXXX") + + perl "${V4L2TRACERDIR}/v4l2-tracer-gen.pl" -o $TMPDIR $V4L2TRACERSOURCES + + diff -Naur "${V4L2TRACERDIR}/trace-gen.cpp" "${TMPDIR}/trace-gen.cpp" > "${TMPDIR}/trace-gen.patch" + diff -Naur "${V4L2TRACERDIR}/trace-gen.h" "${TMPDIR}/trace-gen.h" > "${TMPDIR}/trace-gen-h.patch" + diff -Naur "${V4L2TRACERDIR}/retrace-gen.cpp" "${TMPDIR}/retrace-gen.cpp" > "${TMPDIR}/retrace-gen.patch" + diff -Naur "${V4L2TRACERDIR}/retrace-gen.h" "${TMPDIR}/retrace-gen.h" > "${TMPDIR}/retrace-gen-h.patch" + diff -Naur "${V4L2TRACERDIR}/v4l2-tracer-info-gen.h" "${TMPDIR}/v4l2-tracer-info-gen.h" > "${TMPDIR}/v4l2-tracer-info-gen-h.patch" + + patch -d ${V4L2TRACERDIR} --no-backup-if-mismatch <${TMPDIR}/trace-gen.patch + patch -d ${V4L2TRACERDIR} --no-backup-if-mismatch <${TMPDIR}/trace-gen-h.patch + patch -d ${V4L2TRACERDIR} --no-backup-if-mismatch <${TMPDIR}/retrace-gen.patch + patch -d ${V4L2TRACERDIR} --no-backup-if-mismatch <${TMPDIR}/retrace-gen-h.patch + patch -d ${V4L2TRACERDIR} --no-backup-if-mismatch <${TMPDIR}/v4l2-tracer-info-gen-h.patch + + rm -r "$TMPDIR" +} + keytable libdvbv5 freebsd ioctl-test xc3028-firmware +v4l2-tracer
Signature · 1 line
2.41.0
Re: [PATCH v2 4/4] sync-with-kernel.sh: create v4l2-tracer patches
Quoted 16 lines · Deborah Brouwer
After v4l-utils is synced with the latest kernel headers, generate and apply patches for the changes that need to be made to the v4l2-tracer. This makes it easier to see how the kernel headers are changing the v4l2-tracer and also to revert those changes if necessary.
Signed-off-by Deborah Brouwer <[email protected]>--- sync-with-kernel.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)sync-with-kernel.sh +0
-0@@ -115,8 +115,35 @@ function freebsd { quilt push -a
sync-with-kernel.sh function freebsd { · line 125
Quoted 10 lines
sync-with-kernel.sh +8
-0} +function v4l2-tracer { + V4L2TRACERDIR="${TOPSRCDIR}/utils/v4l2-tracer" + V4L2TRACERSOURCES="${TOPSRCDIR}/include/linux/v4l2-controls.h " + V4L2TRACERSOURCES+="${TOPSRCDIR}/include/linux/videodev2.h " + V4L2TRACERSOURCES+="${TOPSRCDIR}/include/linux/media.h " + V4L2TRACERSOURCES+="${TOPSRCDIR}/include/linux/v4l2-common.h " + + TMPDIR=$(mktemp -d "${V4L2TRACERDIR}/v4l2-tracer-gen.XXXXXXXXXX")
Hmm, bash already has TMPDIR with a special meaning.
I think it is better to pick a different name to avoid confusion.
Regards,
Hans
Quoted 24 lines
sync-with-kernel.sh +19
-0+ + perl "${V4L2TRACERDIR}/v4l2-tracer-gen.pl" -o $TMPDIR $V4L2TRACERSOURCES + + diff -Naur "${V4L2TRACERDIR}/trace-gen.cpp" "${TMPDIR}/trace-gen.cpp" > "${TMPDIR}/trace-gen.patch" + diff -Naur "${V4L2TRACERDIR}/trace-gen.h" "${TMPDIR}/trace-gen.h" > "${TMPDIR}/trace-gen-h.patch" + diff -Naur "${V4L2TRACERDIR}/retrace-gen.cpp" "${TMPDIR}/retrace-gen.cpp" > "${TMPDIR}/retrace-gen.patch" + diff -Naur "${V4L2TRACERDIR}/retrace-gen.h" "${TMPDIR}/retrace-gen.h" > "${TMPDIR}/retrace-gen-h.patch" + diff -Naur "${V4L2TRACERDIR}/v4l2-tracer-info-gen.h" "${TMPDIR}/v4l2-tracer-info-gen.h" > "${TMPDIR}/v4l2-tracer-info-gen-h.patch" + + patch -d ${V4L2TRACERDIR} --no-backup-if-mismatch <${TMPDIR}/trace-gen.patch + patch -d ${V4L2TRACERDIR} --no-backup-if-mismatch <${TMPDIR}/trace-gen-h.patch + patch -d ${V4L2TRACERDIR} --no-backup-if-mismatch <${TMPDIR}/retrace-gen.patch + patch -d ${V4L2TRACERDIR} --no-backup-if-mismatch <${TMPDIR}/retrace-gen-h.patch + patch -d ${V4L2TRACERDIR} --no-backup-if-mismatch <${TMPDIR}/v4l2-tracer-info-gen-h.patch + + rm -r "$TMPDIR" +} + keytable libdvbv5 freebsd ioctl-test xc3028-firmware +v4l2-tracer