用MQTT.fx的JS脚本功能,5分钟实现智能家居设备自动化模拟测试
2026/5/27 19:29:11
- AppInput:svc_encoder_rtc.cc 所属 demo 的结构体,作为从命令行接受参数的结构体;
- AvxVideoWriter:输出视频写入结构体;
- aom_codec_enc_cfg_t:编码器配置结构体;
- aom_image_t:图像描述结构体,原始输入视频数据和输入图像的一些信息;
- aom_svc_layer_id_t:控制 svc 编码层 ID 结构体;
- aom_svc_params_t:控制 svc 编码参数结构体;
- aom_svc_ref_frame_config_t:svc 编码参考帧配置结构体;
- aom_svc_ref_frame_comp_pred_t:svc 编码参考帧复合预测结构体;
- aom_codec_ctx_t:编解码上下文结构体;
- RateControlMetrics:svc_encoder_rtc.cc 所属 demo 的结构体,用于统计编码过程中码率控制统计;
- aom_codec_err_t:编码配置中返回状态枚举;
- aom_codec_iface_t:封装编解码器接口的结构体;
- AvxVideoInfo:存储视频流基本信息的结构体;
- AV1RateControlRTC:针对 RTC 进行扩展的码率控制结构体;
- psnr_stats:psnr 统计相关结构体;
- aom_usec_timer:关于时间计算相关结构体;
- aom_codec_cx_pkt_t:编码器输出包结构体;
- aom_scaling_mode:图像缩放模式结构体;
- AV1FrameParamsRTC:针对 RTC 帧参数相关结构体;
./svc_encoder_rtc,即输入参数为 NULL 时,输出如下;可以发现没有输出ext_rc_arg的相关变量;Usage: ./svc_encoder_rtc<options>input_filename-ooutput_filename Options:-f<arg>,--frames=<arg>Number of frames to encode-o<arg>,--output=<arg>Output filename-w<arg>,--width=<arg>Source width-h<arg>,--height=<arg>Source height-t<arg>,--timebase=<arg>Timebase(num/den)-b<arg>, --target-bitrate=<arg>Encoding bitrate,inkilobits per second-sl<arg>, --spatial-layers=<arg>Number of spatial SVC layers-k<arg>, --kf-dist=<arg>Number of frames between keyframes-r<arg>, --scale-factors=<arg>Scale factors(lowest to highest layer)--min-q=<arg>Minimum quantizer --max-q=<arg>Maximum quantizer-tl<arg>, --temporal-layers=<arg>Number of temporal SVC layers-lm<arg>, --layering-mode=<arg>Temporal layering scheme.-th<arg>,--threads=<arg>Number of threads to use-aq<arg>,--aqmode=<arg>AQ mode off/on-d<arg>, --bit-depth=<arg>Bit depthforcodec8or10.8,10-sp<arg>,--speed=<arg>Speed configuration-bl<arg>,--bitrates=<arg>Bitrates[spatial_layer * num_temporal_layer + temporal_layer]--drop-frame=<arg>Temporal resampling threshold(buf %)--error-resilient=<arg>Error resilient flag --output-obu=<arg>Write OBUs whensetto1. OtherwisewriteIVF files. --test-decode=<arg>Attempt totestdecoding the output whensetto1. Default is1. --tune-content=<arg>Tune contenttypedefault, screen, film--psnr=<arg>Show PSNRinstatus line.staticconstarg_def_t*svc_args[]={&frames_arg,&outputfile,&width_arg,&height_arg,&timebase_arg,&bitrate_arg,&spatial_layers_arg,&kf_dist_arg,&scale_factors_arg,&min_q_arg,&max_q_arg,&temporal_layers_arg,&layering_mode_arg,&threads_arg,&aqmode_arg,#ifCONFIG_AV1_HIGHBITDEPTH&bitdepth_arg,#endif&speed_arg,&bitrates_arg,&dropframe_thresh_arg,&error_resilient_arg,&output_obu_arg,&test_decode_arg,&tune_content_arg,&psnr_arg,NULL,};staticconstarg_def_toutputfile=ARG_DEF("o","output",1,"Output filename");staticconstarg_def_tframes_arg=ARG_DEF("f","frames",1,"Number of frames to encode");staticconstarg_def_tthreads_arg=ARG_DEF("th","threads",1,"Number of threads to use");staticconstarg_def_twidth_arg=ARG_DEF("w","width",1,"Source width");staticconstarg_def_theight_arg=ARG_DEF("h","height",1,"Source height");staticconstarg_def_ttimebase_arg=ARG_DEF("t","timebase",1,"Timebase (num/den)");staticconstarg_def_tbitrate_arg=ARG_DEF("b","target-bitrate",1,"Encoding bitrate, in kilobits per second");staticconstarg_def_tspatial_layers_arg=ARG_DEF("sl","spatial-layers",1,"Number of spatial SVC layers");staticconstarg_def_ttemporal_layers_arg=ARG_DEF("tl","temporal-layers",1,"Number of temporal SVC layers");staticconstarg_def_tlayering_mode_arg=ARG_DEF("lm","layering-mode",1,"Temporal layering scheme.");staticconstarg_def_tkf_dist_arg=ARG_DEF("k","kf-dist",1,"Number of frames between keyframes");staticconstarg_def_tscale_factors_arg=ARG_DEF("r","scale-factors",1,"Scale factors (lowest to highest layer)");staticconstarg_def_tmin_q_arg=ARG_DEF(NULL,"min-q",1,"Minimum quantizer");staticconstarg_def_tmax_q_arg=ARG_DEF(NULL,"max-q",1,"Maximum quantizer");staticconstarg_def_tspeed_arg=ARG_DEF("sp","speed",1,"Speed configuration");staticconstarg_def_taqmode_arg=ARG_DEF("aq","aqmode",1,"AQ mode off/on");staticconstarg_def_tbitrates_arg=ARG_DEF("bl","bitrates",1,"Bitrates[spatial_layer * num_temporal_layer + temporal_layer]");staticconstarg_def_tdropframe_thresh_arg=ARG_DEF(NULL,"drop-frame",1,"Temporal resampling threshold (buf %)");staticconstarg_def_terror_resilient_arg=ARG_DEF(NULL,"error-resilient",1,"Error resilient flag");staticconstarg_def_toutput_obu_arg=ARG_DEF(NULL,"output-obu",1,"Write OBUs when set to 1. Otherwise write IVF files.");staticconstarg_def_ttest_decode_arg=ARG_DEF(NULL,"test-decode",1,"Attempt to test decoding the output when set to 1. Default is 1.");staticconstarg_def_tpsnr_arg=ARG_DEF(NULL,"psnr",-1,"Show PSNR in status line.");staticconstarg_def_text_rc_arg=ARG_DEF(NULL,"use-ext-rc",0,"Use external rate control.");staticconststructarg_enum_listtune_content_enum[]={{"default",AOM_CONTENT_DEFAULT},{"screen",AOM_CONTENT_SCREEN},{"film",AOM_CONTENT_FILM},{NULL,0}};staticconstarg_def_ttune_content_arg=ARG_DEF_ENUM(NULL,"tune-content",1,"Tune content type",tune_content_enum);#ifCONFIG_AV1_HIGHBITDEPTHstaticconststructarg_enum_listbitdepth_enum[]={{"8",AOM_BITS_8},{"10",AOM_BITS_10},{NULL,0}};staticconstarg_def_tbitdepth_arg=ARG_DEF_ENUM("d","bit-depth",1,"Bit depth for codec 8 or 10. ",bitdepth_enum);#endif// CONFIG_AV1_HIGHBITDEPTH/*!\brief Decoder algorithm interface * * All decoders \ref MUST expose a variable of this type. */structaom_codec_iface{constchar*name;/**< Identification String */intabi_version;/**< Implemented ABI version */aom_codec_caps_tcaps;/**< Decoder capabilities */aom_codec_init_fn_tinit;/**< \copydoc ::aom_codec_init_fn_t */aom_codec_destroy_fn_tdestroy;/**< \copydoc ::aom_codec_destroy_fn_t */aom_codec_ctrl_fn_map_t*ctrl_maps;/**< \copydoc ::aom_codec_ctrl_fn_map_t */structaom_codec_dec_iface{aom_codec_peek_si_fn_tpeek_si;/**< \copydoc ::aom_codec_peek_si_fn_t */aom_codec_get_si_fn_tget_si;/**< \copydoc ::aom_codec_get_si_fn_t */aom_codec_decode_fn_tdecode;/**< \copydoc ::aom_codec_decode_fn_t */aom_codec_get_frame_fn_tget_frame;/**< \copydoc ::aom_codec_get_frame_fn_t */aom_codec_set_fb_fn_tset_fb_fn;/**< \copydoc ::aom_codec_set_fb_fn_t */}dec;structaom_codec_enc_iface{intcfg_count;constaom_codec_enc_cfg_t*cfgs;/**< \copydoc ::aom_codec_enc_cfg_t */aom_codec_encode_fn_tencode;/**< \copydoc ::aom_codec_encode_fn_t */aom_codec_get_cx_data_fn_tget_cx_data;/**< \copydoc ::aom_codec_get_cx_data_fn_t */aom_codec_enc_config_set_fn_tcfg_set;/**< \copydoc ::aom_codec_enc_config_set_fn_t */aom_codec_get_global_headers_fn_tget_glob_hdrs;/**< \copydoc ::aom_codec_get_global_headers_fn_t */aom_codec_get_preview_frame_fn_tget_preview;/**< \copydoc ::aom_codec_get_preview_frame_fn_t */}enc;aom_codec_set_option_fn_tset_option;};app_input.layering_mode >= 0时进入该分支调用该函数配置;layering_mode对应命令行里的layering_mode_arg,即-lm <arg>, --layering-mode=<arg> Temporal layering scheme.typedefstruct{constchar*output_filename;charoptions[OPTION_BUFFER_SIZE];structAvxInputContextinput_ctx;intspeed;intaq_mode;intlayering_mode;intoutput_obu;intdecode;inttune_content;intshow_psnr;bool use_external_rc;}AppInput;0:1-layers1:2-temporal layers1350242:3-temporal layers1357260483:3-tl,跟2模式一样,但允许额外预测两个参考帧(GOLDEN和ALTREF),其中GOLDEN定期更新,而ALTREF比LAST落后大约4帧。GOLDEN和ALTREF 只能在基础时间层上更新。4:3-temporal layers,但是中间层更新了GF(Golden Frame),所以第二层时间层(TL2)将只引用GF(而不是LAST)。其他帧只引用LAST。5:2spatial layers,1-temporal6:3spatial layers,1temporal.7:2spatial and3temporal layer.8:3spatial and3temporal layer.和模式9一样9:3spatial and3temporal layer.10: 不存在11: Simulcast modefor3spatial and3temporal layers;3个空间层和3个时间层的Simulcast模式,不允许层间预测, 只允许时间上的单一参考(LAST)预测,空间层之间没有缓冲槽的重叠。/*!\brief Encoder output packet * * This structure contains the different kinds of output data the encoder * may produce while compressing a frame. */typedefstructaom_codec_cx_pkt{enumaom_codec_cx_pkt_kindkind;/**< packet variant */union{struct{void*buf;/**< compressed data buffer */size_tsz;/**< length of compressed data *//*!\brief time stamp to show frame (in timebase units) */aom_codec_pts_tpts;/*!\brief duration to show frame (in timebase units) */unsignedlongduration;aom_codec_frame_flags_tflags;/**< flags for this frame *//*!\brief the partition id defines the decoding order of the partitions. * Only applicable when "output partition" mode is enabled. First * partition has id 0.*/intpartition_id;/*!\brief size of the visible frame in this packet */size_tvis_frame_size;}frame;/**< data for compressed frame packet */aom_fixed_buf_ttwopass_stats;/**< data for two-pass packet */aom_fixed_buf_tfirstpass_mb_stats;/**< first pass mb packet */structaom_psnr_pkt{unsignedintsamples[4];/**< Number of samples, total/y/u/v */uint64_tsse[4];/**< sum squared error, total/y/u/v */doublepsnr[4];/**< PSNR, total/y/u/v *//*!\brief Number of samples, total/y/u/v when * input bit-depth < stream bit-depth.*/unsignedintsamples_hbd[4];/*!\brief sum squared error, total/y/u/v when * input bit-depth < stream bit-depth.*/uint64_tsse_hbd[4];/*!\brief PSNR, total/y/u/v when * input bit-depth < stream bit-depth.*/doublepsnr_hbd[4];}psnr;/**< data for PSNR packet */aom_fixed_buf_traw;/**< data for arbitrary packets */}data;/**< packet data */}aom_codec_cx_pkt_t;/**< alias for struct aom_codec_cx_pkt */