@scrypted/libav 1.0.181 → 1.0.183
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/_openh264install/include/wels/codec_api.h +0 -592
- package/_openh264install/include/wels/codec_app_def.h +0 -820
- package/_openh264install/include/wels/codec_def.h +0 -216
- package/_openh264install/include/wels/codec_ver.h +0 -15
- package/_openh264install/lib/libopenh264.a +0 -0
- package/_openh264install/lib/pkgconfig/openh264.pc +0 -10
- package/openh264/.reviewboardrc +0 -3
- package/openh264/.travis.yml +0 -42
- package/openh264/CODING_STYLE +0 -8
- package/openh264/CONTRIBUTORS +0 -55
- package/openh264/LICENSE +0 -23
- package/openh264/Makefile +0 -408
- package/openh264/README.md +0 -197
- package/openh264/RELEASES +0 -467
- package/openh264/SECURITY.md +0 -16
- package/openh264/autotest/codec_comparision/run_MultiCodecComparision.sh +0 -431
- package/openh264/autotest/performanceTest/android/run_AutoTest_android.sh +0 -180
- package/openh264/autotest/performanceTest/ios/fruitstrap +0 -0
- package/openh264/autotest/performanceTest/ios/iFileTransfer +0 -0
- package/openh264/autotest/performanceTest/ios/run_AutoTest_ios.sh +0 -193
- package/openh264/autotest/performanceTest/ios/uiascript.js +0 -19
- package/openh264/autotest/performanceTest/parsePerfData.sh +0 -107
- package/openh264/autotest/performanceTest/run_perfTest.sh +0 -122
- package/openh264/autotest/unitTest/android/run_AutoTest_android.sh +0 -112
- package/openh264/autotest/unitTest/ios/run_AutoTest_ios.sh +0 -167
- package/openh264/autotest/unitTest/run_ParseUTxml.sh +0 -70
- package/openh264/autotest/unitTest/run_unitTest.sh +0 -98
- package/openh264/build.gradle +0 -30
- package/openh264/code-coverage.sh +0 -6
- package/openh264/codec/api/meson.build +0 -1
- package/openh264/codec/api/wels/codec_api.h +0 -592
- package/openh264/codec/api/wels/codec_app_def.h +0 -820
- package/openh264/codec/api/wels/codec_def.h +0 -216
- package/openh264/codec/api/wels/codec_ver.h +0 -15
- package/openh264/codec/api/wels/meson.build +0 -9
- package/openh264/codec/common/arm/arm_arch_common_macro.S +0 -83
- package/openh264/codec/common/arm/copy_mb_neon.S +0 -161
- package/openh264/codec/common/arm/deblocking_neon.S +0 -857
- package/openh264/codec/common/arm/expand_picture_neon.S +0 -154
- package/openh264/codec/common/arm/intra_pred_common_neon.S +0 -82
- package/openh264/codec/common/arm/mc_neon.S +0 -2283
- package/openh264/codec/common/arm64/arm_aarch64_common.h +0 -85
- package/openh264/codec/common/arm64/arm_arch64_common_macro.S +0 -79
- package/openh264/codec/common/arm64/copy_mb_aarch64_neon.S +0 -202
- package/openh264/codec/common/arm64/deblocking_aarch64_neon.S +0 -852
- package/openh264/codec/common/arm64/expand_picture_aarch64_neon.S +0 -150
- package/openh264/codec/common/arm64/intra_pred_common_aarch64_neon.S +0 -58
- package/openh264/codec/common/arm64/mc_aarch64_neon.S +0 -2614
- package/openh264/codec/common/generate_version.sh +0 -28
- package/openh264/codec/common/inc/WelsList.h +0 -287
- package/openh264/codec/common/inc/WelsLock.h +0 -97
- package/openh264/codec/common/inc/WelsTask.h +0 -75
- package/openh264/codec/common/inc/WelsTaskThread.h +0 -83
- package/openh264/codec/common/inc/WelsThread.h +0 -106
- package/openh264/codec/common/inc/WelsThreadLib.h +0 -151
- package/openh264/codec/common/inc/WelsThreadPool.h +0 -124
- package/openh264/codec/common/inc/asmdefs_mmi.h +0 -345
- package/openh264/codec/common/inc/copy_mb.h +0 -103
- package/openh264/codec/common/inc/cpu.h +0 -81
- package/openh264/codec/common/inc/cpu_core.h +0 -103
- package/openh264/codec/common/inc/crt_util_safe_x.h +0 -104
- package/openh264/codec/common/inc/deblocking_common.h +0 -124
- package/openh264/codec/common/inc/expand_pic.h +0 -107
- package/openh264/codec/common/inc/golomb_common.h +0 -166
- package/openh264/codec/common/inc/intra_pred_common.h +0 -86
- package/openh264/codec/common/inc/loongson_intrinsics.h +0 -1919
- package/openh264/codec/common/inc/ls_defines.h +0 -130
- package/openh264/codec/common/inc/macros.h +0 -329
- package/openh264/codec/common/inc/mc.h +0 -407
- package/openh264/codec/common/inc/measure_time.h +0 -88
- package/openh264/codec/common/inc/memory_align.h +0 -116
- package/openh264/codec/common/inc/msa_macros.h +0 -2393
- package/openh264/codec/common/inc/sad_common.h +0 -139
- package/openh264/codec/common/inc/typedefs.h +0 -86
- package/openh264/codec/common/inc/utils.h +0 -95
- package/openh264/codec/common/inc/version.h +0 -10
- package/openh264/codec/common/inc/version_gen.h.template +0 -6
- package/openh264/codec/common/inc/welsCodecTrace.h +0 -64
- package/openh264/codec/common/inc/wels_common_defs.h +0 -373
- package/openh264/codec/common/inc/wels_const_common.h +0 -63
- package/openh264/codec/common/loongarch/copy_mb_lsx.c +0 -194
- package/openh264/codec/common/loongarch/deblock_lsx.c +0 -1489
- package/openh264/codec/common/loongarch/intra_pred_com_lasx.c +0 -112
- package/openh264/codec/common/loongarch/intra_pred_com_lsx.c +0 -91
- package/openh264/codec/common/loongarch/mc_chroma_lsx.c +0 -192
- package/openh264/codec/common/loongarch/mc_horver_lsx.c +0 -654
- package/openh264/codec/common/loongarch/satd_sad_lasx.c +0 -568
- package/openh264/codec/common/meson.build +0 -84
- package/openh264/codec/common/mips/copy_mb_mmi.c +0 -477
- package/openh264/codec/common/mips/copy_mb_msa.c +0 -80
- package/openh264/codec/common/mips/deblock_mmi.c +0 -2826
- package/openh264/codec/common/mips/deblock_msa.c +0 -1024
- package/openh264/codec/common/mips/expand_picture_mmi.c +0 -673
- package/openh264/codec/common/mips/intra_pred_com_mmi.c +0 -548
- package/openh264/codec/common/mips/satd_sad_mmi.c +0 -2154
- package/openh264/codec/common/targets.mk +0 -136
- package/openh264/codec/common/x86/asm_inc.asm +0 -743
- package/openh264/codec/common/x86/cpuid.asm +0 -263
- package/openh264/codec/common/x86/dct.asm +0 -1036
- package/openh264/codec/common/x86/deblock.asm +0 -848
- package/openh264/codec/common/x86/expand_picture.asm +0 -728
- package/openh264/codec/common/x86/intra_pred_com.asm +0 -117
- package/openh264/codec/common/x86/mb_copy.asm +0 -615
- package/openh264/codec/common/x86/mc_chroma.asm +0 -313
- package/openh264/codec/common/x86/mc_luma.asm +0 -4490
- package/openh264/codec/common/x86/satd_sad.asm +0 -2734
- package/openh264/codec/common/x86/vaa.asm +0 -411
- package/openh264/codec/console/common/inc/read_config.h +0 -68
- package/openh264/codec/console/common/meson.build +0 -12
- package/openh264/codec/console/common/targets.mk +0 -20
- package/openh264/codec/console/dec/inc/d3d9_utils.h +0 -148
- package/openh264/codec/console/dec/meson.build +0 -15
- package/openh264/codec/console/dec/targets.mk +0 -20
- package/openh264/codec/console/enc/meson.build +0 -9
- package/openh264/codec/console/enc/targets.mk +0 -19
- package/openh264/codec/console/meson.build +0 -3
- package/openh264/codec/decoder/core/arm/block_add_neon.S +0 -129
- package/openh264/codec/decoder/core/arm/intra_pred_neon.S +0 -635
- package/openh264/codec/decoder/core/arm64/block_add_aarch64_neon.S +0 -131
- package/openh264/codec/decoder/core/arm64/intra_pred_aarch64_neon.S +0 -524
- package/openh264/codec/decoder/core/inc/au_parser.h +0 -199
- package/openh264/codec/decoder/core/inc/bit_stream.h +0 -62
- package/openh264/codec/decoder/core/inc/cabac_decoder.h +0 -111
- package/openh264/codec/decoder/core/inc/deblocking.h +0 -118
- package/openh264/codec/decoder/core/inc/dec_frame.h +0 -156
- package/openh264/codec/decoder/core/inc/dec_golomb.h +0 -344
- package/openh264/codec/decoder/core/inc/decode_mb_aux.h +0 -83
- package/openh264/codec/decoder/core/inc/decode_slice.h +0 -104
- package/openh264/codec/decoder/core/inc/decoder.h +0 -186
- package/openh264/codec/decoder/core/inc/decoder_context.h +0 -590
- package/openh264/codec/decoder/core/inc/decoder_core.h +0 -206
- package/openh264/codec/decoder/core/inc/error_code.h +0 -222
- package/openh264/codec/decoder/core/inc/error_concealment.h +0 -68
- package/openh264/codec/decoder/core/inc/fmo.h +0 -114
- package/openh264/codec/decoder/core/inc/get_intra_predictor.h +0 -191
- package/openh264/codec/decoder/core/inc/manage_dec_ref.h +0 -62
- package/openh264/codec/decoder/core/inc/mb_cache.h +0 -80
- package/openh264/codec/decoder/core/inc/memmgr_nal_unit.h +0 -66
- package/openh264/codec/decoder/core/inc/mv_pred.h +0 -195
- package/openh264/codec/decoder/core/inc/nal_prefix.h +0 -56
- package/openh264/codec/decoder/core/inc/nalu.h +0 -79
- package/openh264/codec/decoder/core/inc/parameter_sets.h +0 -217
- package/openh264/codec/decoder/core/inc/parse_mb_syn_cabac.h +0 -89
- package/openh264/codec/decoder/core/inc/parse_mb_syn_cavlc.h +0 -137
- package/openh264/codec/decoder/core/inc/pic_queue.h +0 -62
- package/openh264/codec/decoder/core/inc/picture.h +0 -112
- package/openh264/codec/decoder/core/inc/rec_mb.h +0 -104
- package/openh264/codec/decoder/core/inc/slice.h +0 -208
- package/openh264/codec/decoder/core/inc/vlc_decoder.h +0 -177
- package/openh264/codec/decoder/core/inc/wels_common_basis.h +0 -317
- package/openh264/codec/decoder/core/inc/wels_const.h +0 -65
- package/openh264/codec/decoder/core/inc/wels_decoder_thread.h +0 -170
- package/openh264/codec/decoder/core/loongarch/mb_aux_lsx.c +0 -296
- package/openh264/codec/decoder/core/mips/dct_mmi.c +0 -786
- package/openh264/codec/decoder/core/x86/dct.asm +0 -72
- package/openh264/codec/decoder/core/x86/intra_pred.asm +0 -1456
- package/openh264/codec/decoder/meson.build +0 -69
- package/openh264/codec/decoder/plus/inc/welsDecoderExt.h +0 -170
- package/openh264/codec/decoder/targets.mk +0 -115
- package/openh264/codec/encoder/core/arm/intra_pred_neon.S +0 -589
- package/openh264/codec/encoder/core/arm/intra_pred_sad_3_opt_neon.S +0 -735
- package/openh264/codec/encoder/core/arm/memory_neon.S +0 -62
- package/openh264/codec/encoder/core/arm/pixel_neon.S +0 -882
- package/openh264/codec/encoder/core/arm/reconstruct_neon.S +0 -903
- package/openh264/codec/encoder/core/arm/svc_motion_estimation.S +0 -366
- package/openh264/codec/encoder/core/arm64/intra_pred_aarch64_neon.S +0 -505
- package/openh264/codec/encoder/core/arm64/intra_pred_sad_3_opt_aarch64_neon.S +0 -611
- package/openh264/codec/encoder/core/arm64/memory_aarch64_neon.S +0 -63
- package/openh264/codec/encoder/core/arm64/pixel_aarch64_neon.S +0 -621
- package/openh264/codec/encoder/core/arm64/reconstruct_aarch64_neon.S +0 -717
- package/openh264/codec/encoder/core/arm64/svc_motion_estimation_aarch64_neon.S +0 -350
- package/openh264/codec/encoder/core/inc/as264_common.h +0 -138
- package/openh264/codec/encoder/core/inc/au_set.h +0 -152
- package/openh264/codec/encoder/core/inc/deblocking.h +0 -92
- package/openh264/codec/encoder/core/inc/decode_mb_aux.h +0 -112
- package/openh264/codec/encoder/core/inc/dq_map.h +0 -58
- package/openh264/codec/encoder/core/inc/encode_mb_aux.h +0 -199
- package/openh264/codec/encoder/core/inc/encoder.h +0 -148
- package/openh264/codec/encoder/core/inc/encoder_context.h +0 -240
- package/openh264/codec/encoder/core/inc/extern.h +0 -124
- package/openh264/codec/encoder/core/inc/get_intra_predictor.h +0 -186
- package/openh264/codec/encoder/core/inc/mb_cache.h +0 -141
- package/openh264/codec/encoder/core/inc/md.h +0 -181
- package/openh264/codec/encoder/core/inc/mt_defs.h +0 -91
- package/openh264/codec/encoder/core/inc/mv_pred.h +0 -191
- package/openh264/codec/encoder/core/inc/nal_encap.h +0 -143
- package/openh264/codec/encoder/core/inc/param_svc.h +0 -576
- package/openh264/codec/encoder/core/inc/parameter_sets.h +0 -181
- package/openh264/codec/encoder/core/inc/paraset_strategy.h +0 -310
- package/openh264/codec/encoder/core/inc/picture.h +0 -137
- package/openh264/codec/encoder/core/inc/picture_handle.h +0 -66
- package/openh264/codec/encoder/core/inc/rc.h +0 -284
- package/openh264/codec/encoder/core/inc/ref_list_mgr_svc.h +0 -148
- package/openh264/codec/encoder/core/inc/sample.h +0 -154
- package/openh264/codec/encoder/core/inc/set_mb_syn_cabac.h +0 -127
- package/openh264/codec/encoder/core/inc/set_mb_syn_cavlc.h +0 -92
- package/openh264/codec/encoder/core/inc/slice.h +0 -212
- package/openh264/codec/encoder/core/inc/slice_multi_threading.h +0 -97
- package/openh264/codec/encoder/core/inc/stat.h +0 -102
- package/openh264/codec/encoder/core/inc/svc_base_layer_md.h +0 -102
- package/openh264/codec/encoder/core/inc/svc_enc_frame.h +0 -136
- package/openh264/codec/encoder/core/inc/svc_enc_golomb.h +0 -123
- package/openh264/codec/encoder/core/inc/svc_enc_macroblock.h +0 -82
- package/openh264/codec/encoder/core/inc/svc_enc_slice_segment.h +0 -212
- package/openh264/codec/encoder/core/inc/svc_encode_mb.h +0 -63
- package/openh264/codec/encoder/core/inc/svc_encode_slice.h +0 -184
- package/openh264/codec/encoder/core/inc/svc_mode_decision.h +0 -94
- package/openh264/codec/encoder/core/inc/svc_motion_estimate.h +0 -369
- package/openh264/codec/encoder/core/inc/svc_set_mb_syn.h +0 -70
- package/openh264/codec/encoder/core/inc/svc_set_mb_syn_cavlc.h +0 -67
- package/openh264/codec/encoder/core/inc/vlc_encoder.h +0 -92
- package/openh264/codec/encoder/core/inc/wels_common_basis.h +0 -160
- package/openh264/codec/encoder/core/inc/wels_const.h +0 -174
- package/openh264/codec/encoder/core/inc/wels_func_ptr_def.h +0 -300
- package/openh264/codec/encoder/core/inc/wels_preprocess.h +0 -251
- package/openh264/codec/encoder/core/inc/wels_task_base.h +0 -79
- package/openh264/codec/encoder/core/inc/wels_task_encoder.h +0 -142
- package/openh264/codec/encoder/core/inc/wels_task_management.h +0 -135
- package/openh264/codec/encoder/core/inc/wels_transpose_matrix.h +0 -58
- package/openh264/codec/encoder/core/loongarch/dct_lasx.c +0 -452
- package/openh264/codec/encoder/core/loongarch/get_intra_predictor_lsx.c +0 -166
- package/openh264/codec/encoder/core/loongarch/quant_lsx.c +0 -153
- package/openh264/codec/encoder/core/loongarch/sample_lasx.c +0 -87
- package/openh264/codec/encoder/core/loongarch/svc_motion_estimate_lsx.c +0 -104
- package/openh264/codec/encoder/core/mips/dct_mmi.c +0 -529
- package/openh264/codec/encoder/core/mips/quant_mmi.c +0 -553
- package/openh264/codec/encoder/core/mips/score_mmi.c +0 -324
- package/openh264/codec/encoder/core/x86/coeff.asm +0 -695
- package/openh264/codec/encoder/core/x86/dct.asm +0 -108
- package/openh264/codec/encoder/core/x86/intra_pred.asm +0 -1129
- package/openh264/codec/encoder/core/x86/matrix_transpose.asm +0 -395
- package/openh264/codec/encoder/core/x86/memzero.asm +0 -132
- package/openh264/codec/encoder/core/x86/quant.asm +0 -507
- package/openh264/codec/encoder/core/x86/sample_sc.asm +0 -1829
- package/openh264/codec/encoder/core/x86/score.asm +0 -363
- package/openh264/codec/encoder/meson.build +0 -98
- package/openh264/codec/encoder/plus/inc/welsEncoderExt.h +0 -129
- package/openh264/codec/encoder/targets.mk +0 -146
- package/openh264/codec/meson.build +0 -9
- package/openh264/codec/processing/interface/IWelsVP.h +0 -310
- package/openh264/codec/processing/meson.build +0 -71
- package/openh264/codec/processing/targets.mk +0 -117
- package/openh264/docs/doxygen/Doxyfile +0 -1865
- package/openh264/docs/doxygen/Home.rest +0 -25
- package/openh264/docs/doxygen/ISVCDecoder.rest +0 -19
- package/openh264/docs/doxygen/ISVCEncoder.rest +0 -16
- package/openh264/docs/doxygen/UsageExampleForDecoder.rest +0 -10
- package/openh264/docs/doxygen/UsageExampleForEncoder.rest +0 -15
- package/openh264/docs/doxygen2rst.py +0 -619
- package/openh264/gmpopenh264.info +0 -4
- package/openh264/gradlew +0 -172
- package/openh264/meson.build +0 -218
- package/openh264/meson_options.txt +0 -1
- package/openh264/module/RefCounted.h +0 -141
- package/openh264/module/gmp-openh264.cpp +0 -1196
- package/openh264/module/targets.mk +0 -14
- package/openh264/module/task_utils.h +0 -38
- package/openh264/module/task_utils.py +0 -207
- package/openh264/module/task_utils_generated.h +0 -2087
- package/openh264/openh264.def +0 -7
- package/openh264/openh264.pc.in +0 -10
- package/openh264/openh264.rc +0 -61
- package/openh264/openh264.rc.template +0 -61
- package/openh264/res/Adobe_PDF_sample_a_1024x768_50Frms.264 +0 -0
- package/openh264/res/BA1_FT_C.264 +0 -0
- package/openh264/res/BA1_Sony_D.jsv +0 -0
- package/openh264/res/BAMQ1_JVC_C.264 +0 -0
- package/openh264/res/BAMQ2_JVC_C.264 +0 -0
- package/openh264/res/BANM_MW_D.264 +0 -0
- package/openh264/res/BASQP1_Sony_C.jsv +0 -0
- package/openh264/res/BA_MW_D.264 +0 -0
- package/openh264/res/BA_MW_D_IDR_LOST.264 +0 -0
- package/openh264/res/BA_MW_D_P_LOST.264 +0 -0
- package/openh264/res/CI1_FT_B.264 +0 -0
- package/openh264/res/CI_MW_D.264 +0 -0
- package/openh264/res/CVFC1_Sony_C.jsv +0 -0
- package/openh264/res/CVPCMNL1_SVA_C.264 +0 -0
- package/openh264/res/CiscoVT2people_160x96_6fps.yuv +0 -1
- package/openh264/res/CiscoVT2people_320x192_12fps.yuv +0 -1
- package/openh264/res/Cisco_Absolute_Power_1280x720_30fps.yuv +0 -3607
- package/openh264/res/Cisco_Adobe_PDF_sample_a_1024x768_CAVLC_Bframe_9.264 +0 -0
- package/openh264/res/Cisco_Men_whisper_640x320_CABAC_Bframe_9.264 +0 -0
- package/openh264/res/Cisco_Men_whisper_640x320_CAVLC_Bframe_9.264 +0 -0
- package/openh264/res/Error_I_P.264 +0 -0
- package/openh264/res/LS_SVA_D.264 +0 -0
- package/openh264/res/MIDR_MW_D.264 +0 -0
- package/openh264/res/MPS_MW_A.264 +0 -0
- package/openh264/res/MR1_BT_A.h264 +0 -0
- package/openh264/res/MR1_MW_A.264 +0 -0
- package/openh264/res/MR2_MW_A.264 +0 -0
- package/openh264/res/MR2_TANDBERG_E.264 +0 -0
- package/openh264/res/NL1_Sony_D.jsv +0 -0
- package/openh264/res/NLMQ1_JVC_C.264 +0 -0
- package/openh264/res/NLMQ2_JVC_C.264 +0 -0
- package/openh264/res/NRF_MW_E.264 +0 -0
- package/openh264/res/QCIF_2P_I_allIPCM.264 +0 -0
- package/openh264/res/SVA_BA1_B.264 +0 -0
- package/openh264/res/SVA_BA2_D.264 +0 -0
- package/openh264/res/SVA_Base_B.264 +0 -0
- package/openh264/res/SVA_CL1_E.264 +0 -0
- package/openh264/res/SVA_FM1_E.264 +0 -0
- package/openh264/res/SVA_NL1_B.264 +0 -0
- package/openh264/res/SVA_NL2_E.264 +0 -0
- package/openh264/res/SarVui.264 +0 -0
- package/openh264/res/Static.264 +0 -0
- package/openh264/res/Static_152_100.yuv +0 -1
- package/openh264/res/VID_1280x544_cabac_temporal_direct.264 +0 -0
- package/openh264/res/VID_1280x544_cavlc_temporal_direct.264 +0 -0
- package/openh264/res/VID_1280x720_cabac_temporal_direct.264 +0 -0
- package/openh264/res/VID_1280x720_cavlc_temporal_direct.264 +0 -0
- package/openh264/res/VID_1920x1080_cabac_temporal_direct.264 +0 -0
- package/openh264/res/VID_1920x1080_cavlc_temporal_direct.264 +0 -0
- package/openh264/res/Zhling_1280x720.264 +0 -0
- package/openh264/res/jm_1080p_allslice.264 +0 -0
- package/openh264/res/sps_subsetsps_bothVUI.264 +0 -0
- package/openh264/res/test_cif_I_CABAC_PCM.264 +0 -0
- package/openh264/res/test_cif_I_CABAC_slice.264 +0 -0
- package/openh264/res/test_cif_P_CABAC_slice.264 +0 -0
- package/openh264/res/test_qcif_cabac.264 +0 -0
- package/openh264/res/test_scalinglist_jm.264 +0 -0
- package/openh264/res/test_vd_1d.264 +0 -0
- package/openh264/res/test_vd_rc.264 +0 -0
- package/openh264/run_Test.sh +0 -91
- package/openh264/settings.gradle +0 -4
- package/openh264/subprojects/gtest.wrap +0 -10
- package/openh264/testbin/AutoBuild_Windows_VS2008.bat +0 -59
- package/openh264/testbin/CmdLineExample.sh +0 -7
- package/openh264/testbin/CmdLineReadMe +0 -22
- package/openh264/testbin/layer2.cfg +0 -37
- package/openh264/testbin/layer2_arbitrary_res.cfg +0 -37
- package/openh264/testbin/layer2_vd.cfg +0 -38
- package/openh264/testbin/layer2_vd_rc.cfg +0 -38
- package/openh264/testbin/welsenc.cfg +0 -71
- package/openh264/testbin/welsenc_arbitrary_res.cfg +0 -70
- package/openh264/testbin/welsenc_ios.cfg +0 -71
- package/openh264/testbin/welsenc_vd_1d.cfg +0 -70
- package/openh264/testbin/welsenc_vd_rc.cfg +0 -69
- package/openh264/ut.def +0 -2
|
@@ -1,1196 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* \copy
|
|
3
|
-
* Copyright (c) 2009-2014, Cisco Systems
|
|
4
|
-
* All rights reserved.
|
|
5
|
-
*
|
|
6
|
-
* Redistribution and use in source and binary forms, with or without
|
|
7
|
-
* modification, are permitted provided that the following conditions
|
|
8
|
-
* are met:
|
|
9
|
-
*
|
|
10
|
-
* * Redistributions of source code must retain the above copyright
|
|
11
|
-
* notice, this list of conditions and the following disclaimer.
|
|
12
|
-
*
|
|
13
|
-
* * Redistributions in binary form must reproduce the above copyright
|
|
14
|
-
* notice, this list of conditions and the following disclaimer in
|
|
15
|
-
* the documentation and/or other materials provided with the
|
|
16
|
-
* distribution.
|
|
17
|
-
*
|
|
18
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
19
|
-
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
20
|
-
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
21
|
-
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
22
|
-
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
23
|
-
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
24
|
-
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
25
|
-
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
27
|
-
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
28
|
-
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
29
|
-
* POSSIBILITY OF SUCH DAMAGE.
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*************************************************************************************
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
#include <stdint.h>
|
|
36
|
-
#include <time.h>
|
|
37
|
-
#include <cmath>
|
|
38
|
-
#include <cstdio>
|
|
39
|
-
#include <cstring>
|
|
40
|
-
#include <iostream>
|
|
41
|
-
#include <string>
|
|
42
|
-
#include <memory>
|
|
43
|
-
#include <assert.h>
|
|
44
|
-
#include <limits.h>
|
|
45
|
-
|
|
46
|
-
#include "gmp-platform.h"
|
|
47
|
-
#include "gmp-video-host.h"
|
|
48
|
-
#include "gmp-video-encode.h"
|
|
49
|
-
#include "gmp-video-decode.h"
|
|
50
|
-
#include "gmp-video-frame-i420.h"
|
|
51
|
-
#include "gmp-video-frame-encoded.h"
|
|
52
|
-
|
|
53
|
-
#include "codec_def.h"
|
|
54
|
-
#include "codec_app_def.h"
|
|
55
|
-
#include "codec_api.h"
|
|
56
|
-
|
|
57
|
-
#if defined(_MSC_VER)
|
|
58
|
-
#define PUBLIC_FUNC __declspec(dllexport)
|
|
59
|
-
#else
|
|
60
|
-
#define PUBLIC_FUNC
|
|
61
|
-
#endif
|
|
62
|
-
|
|
63
|
-
// This is for supporting older versions which do not have support for nullptr.
|
|
64
|
-
#if defined(nullptr)
|
|
65
|
-
# define GMP_HAVE_NULLPTR
|
|
66
|
-
|
|
67
|
-
#elif defined(__clang__)
|
|
68
|
-
# ifndef __has_extension
|
|
69
|
-
# define __has_extension __has_feature
|
|
70
|
-
# endif
|
|
71
|
-
|
|
72
|
-
# if __has_extension(cxx_nullptr)
|
|
73
|
-
# define GMP_HAVE_NULLPTR
|
|
74
|
-
# endif
|
|
75
|
-
|
|
76
|
-
#elif defined(__GNUC__)
|
|
77
|
-
# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
|
|
78
|
-
# if (__GNU_C__ >=4)
|
|
79
|
-
# if (__GNU_C_MINOR__ >= 6)
|
|
80
|
-
# define GMP_HAVE_NULLPTR
|
|
81
|
-
# endif
|
|
82
|
-
# endif
|
|
83
|
-
# endif
|
|
84
|
-
|
|
85
|
-
#elif defined(_MSC_VER)
|
|
86
|
-
# define GMP_HAVE_NULLPTR
|
|
87
|
-
#endif
|
|
88
|
-
|
|
89
|
-
#if !defined (GMP_HAVE_NULLPTR)
|
|
90
|
-
# define nullptr __null
|
|
91
|
-
#endif
|
|
92
|
-
|
|
93
|
-
#include "task_utils.h"
|
|
94
|
-
|
|
95
|
-
static int g_log_level = 0;
|
|
96
|
-
|
|
97
|
-
#define GMPLOG(l, x) do { \
|
|
98
|
-
if (l <= g_log_level) { \
|
|
99
|
-
const char *log_string = "unknown"; \
|
|
100
|
-
if ((l >= 0) && (l <= 3)) { \
|
|
101
|
-
log_string = kLogStrings[l]; \
|
|
102
|
-
} \
|
|
103
|
-
std::cerr << log_string << ": " << x << std::endl; \
|
|
104
|
-
} \
|
|
105
|
-
} while(0)
|
|
106
|
-
|
|
107
|
-
#define GL_CRIT 0
|
|
108
|
-
#define GL_ERROR 1
|
|
109
|
-
#define GL_INFO 2
|
|
110
|
-
#define GL_DEBUG 3
|
|
111
|
-
|
|
112
|
-
const char* kLogStrings[] = {
|
|
113
|
-
"Critical",
|
|
114
|
-
"Error",
|
|
115
|
-
"Info",
|
|
116
|
-
"Debug"
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
#define OPENH264_MAX_MB 36864
|
|
120
|
-
|
|
121
|
-
GMPPlatformAPI* g_platform_api = nullptr;
|
|
122
|
-
|
|
123
|
-
class OpenH264VideoEncoder;
|
|
124
|
-
|
|
125
|
-
static uint32_t GMPLogLevelToWelsLogLevel(GMPLogLevel aLevel) {
|
|
126
|
-
switch (aLevel) {
|
|
127
|
-
default:
|
|
128
|
-
case kGMPLogInvalid:
|
|
129
|
-
case kGMPLogDefault:
|
|
130
|
-
return WELS_LOG_DEFAULT;
|
|
131
|
-
case kGMPLogQuiet:
|
|
132
|
-
return WELS_LOG_QUIET;
|
|
133
|
-
case kGMPLogError:
|
|
134
|
-
return WELS_LOG_ERROR;
|
|
135
|
-
case kGMPLogWarning:
|
|
136
|
-
return WELS_LOG_WARNING;
|
|
137
|
-
case kGMPLogInfo:
|
|
138
|
-
return WELS_LOG_INFO;
|
|
139
|
-
case kGMPLogDebug:
|
|
140
|
-
return WELS_LOG_DEBUG;
|
|
141
|
-
case kGMPLogDetail:
|
|
142
|
-
return WELS_LOG_DETAIL;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
static EUsageType GMPVideoCodecModeToWelsUsageType(GMPVideoCodecMode aMode) {
|
|
147
|
-
switch (aMode) {
|
|
148
|
-
default:
|
|
149
|
-
case kGMPRealtimeVideo:
|
|
150
|
-
return CAMERA_VIDEO_REAL_TIME;
|
|
151
|
-
case kGMPScreensharing:
|
|
152
|
-
return SCREEN_CONTENT_REAL_TIME;
|
|
153
|
-
case kGMPStreamingVideo:
|
|
154
|
-
return SCREEN_CONTENT_NON_REAL_TIME;
|
|
155
|
-
case kGMPNonRealtimeVideo:
|
|
156
|
-
return CAMERA_VIDEO_NON_REAL_TIME;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
static RC_MODES GMPRateControlModeToWelsRcModes(GMPRateControlMode aMode) {
|
|
161
|
-
switch (aMode) {
|
|
162
|
-
default:
|
|
163
|
-
case kGMPRateControlUnknown:
|
|
164
|
-
case kGMPRateControlBitrate:
|
|
165
|
-
return RC_BITRATE_MODE;
|
|
166
|
-
case kGMPRateControlQuality:
|
|
167
|
-
return RC_QUALITY_MODE;
|
|
168
|
-
case kGMPRateControlBufferBased:
|
|
169
|
-
return RC_BUFFERBASED_MODE;
|
|
170
|
-
case kGMPRateControlTimestamp:
|
|
171
|
-
return RC_TIMESTAMP_MODE;
|
|
172
|
-
case kGMPRateControlBitratePostskip:
|
|
173
|
-
return RC_BITRATE_MODE_POST_SKIP;
|
|
174
|
-
case kGMPRateControlOff:
|
|
175
|
-
return RC_OFF_MODE;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
EProfileIdc GMPProfileToWelsProfile(GMPProfile aProfile) {
|
|
180
|
-
switch (aProfile) {
|
|
181
|
-
default:
|
|
182
|
-
case kGMPH264ProfileUnknown:
|
|
183
|
-
return PRO_UNKNOWN;
|
|
184
|
-
case kGMPH264ProfileBaseline:
|
|
185
|
-
return PRO_BASELINE;
|
|
186
|
-
case kGMPH264ProfileMain:
|
|
187
|
-
return PRO_MAIN;
|
|
188
|
-
case kGMPH264ProfileExtended:
|
|
189
|
-
return PRO_EXTENDED;
|
|
190
|
-
case kGMPH264ProfileHigh:
|
|
191
|
-
return PRO_HIGH;
|
|
192
|
-
case kGMPH264ProfileHigh10:
|
|
193
|
-
return PRO_HIGH10;
|
|
194
|
-
case kGMPH264ProfileHigh422:
|
|
195
|
-
return PRO_HIGH422;
|
|
196
|
-
case kGMPH264ProfileHigh444:
|
|
197
|
-
return PRO_HIGH444;
|
|
198
|
-
case kGMPH264ProfileCavlc444:
|
|
199
|
-
return PRO_CAVLC444;
|
|
200
|
-
case kGMPH264ProfileScalableBaseline:
|
|
201
|
-
return PRO_SCALABLE_BASELINE;
|
|
202
|
-
case kGMPH264ProfileScalableHigh:
|
|
203
|
-
return PRO_SCALABLE_HIGH;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
ELevelIdc GMPLevelToWelsLevel(GMPLevel aLevel) {
|
|
208
|
-
switch (aLevel) {
|
|
209
|
-
default:
|
|
210
|
-
case kGMPH264LevelUnknown:
|
|
211
|
-
return LEVEL_UNKNOWN;
|
|
212
|
-
case kGMPH264Level1_0:
|
|
213
|
-
return LEVEL_1_0;
|
|
214
|
-
case kGMPH264Level1_B:
|
|
215
|
-
return LEVEL_1_B;
|
|
216
|
-
case kGMPH264Level1_1:
|
|
217
|
-
return LEVEL_1_1;
|
|
218
|
-
case kGMPH264Level1_2:
|
|
219
|
-
return LEVEL_1_2;
|
|
220
|
-
case kGMPH264Level1_3:
|
|
221
|
-
return LEVEL_1_3;
|
|
222
|
-
case kGMPH264Level2_0:
|
|
223
|
-
return LEVEL_2_0;
|
|
224
|
-
case kGMPH264Level2_1:
|
|
225
|
-
return LEVEL_2_1;
|
|
226
|
-
case kGMPH264Level2_2:
|
|
227
|
-
return LEVEL_2_2;
|
|
228
|
-
case kGMPH264Level3_0:
|
|
229
|
-
return LEVEL_3_0;
|
|
230
|
-
case kGMPH264Level3_1:
|
|
231
|
-
return LEVEL_3_1;
|
|
232
|
-
case kGMPH264Level3_2:
|
|
233
|
-
return LEVEL_3_2;
|
|
234
|
-
case kGMPH264Level4_0:
|
|
235
|
-
return LEVEL_4_0;
|
|
236
|
-
case kGMPH264Level4_1:
|
|
237
|
-
return LEVEL_4_1;
|
|
238
|
-
case kGMPH264Level4_2:
|
|
239
|
-
return LEVEL_4_2;
|
|
240
|
-
case kGMPH264Level5_0:
|
|
241
|
-
return LEVEL_5_0;
|
|
242
|
-
case kGMPH264Level5_1:
|
|
243
|
-
return LEVEL_5_1;
|
|
244
|
-
case kGMPH264Level5_2:
|
|
245
|
-
return LEVEL_5_2;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
SliceModeEnum GMPSliceToWelsSliceMode(GMPSliceMode aMode) {
|
|
250
|
-
switch (aMode) {
|
|
251
|
-
default:
|
|
252
|
-
case kGMPSliceUnknown:
|
|
253
|
-
case kGMPSliceSingle:
|
|
254
|
-
return SM_SINGLE_SLICE;
|
|
255
|
-
case kGMPSliceSizeLimited:
|
|
256
|
-
return SM_SIZELIMITED_SLICE;
|
|
257
|
-
case kGMPSliceFixedSlcNum:
|
|
258
|
-
return SM_FIXEDSLCNUM_SLICE;
|
|
259
|
-
case kGMPSliceRaster:
|
|
260
|
-
return SM_RASTER_SLICE;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
template <typename T> class SelfDestruct {
|
|
265
|
-
public:
|
|
266
|
-
SelfDestruct (T* t) : t_ (t) {}
|
|
267
|
-
~SelfDestruct() {
|
|
268
|
-
if (t_) {
|
|
269
|
-
t_->Destroy();
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
T* forget() {
|
|
274
|
-
T* t = t_;
|
|
275
|
-
t_ = nullptr;
|
|
276
|
-
|
|
277
|
-
return t;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
private:
|
|
281
|
-
T* t_;
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
class FrameStats {
|
|
285
|
-
public:
|
|
286
|
-
FrameStats (const char* type) :
|
|
287
|
-
frames_in_ (0),
|
|
288
|
-
frames_out_ (0),
|
|
289
|
-
start_time_ (time (0)),
|
|
290
|
-
last_time_ (start_time_),
|
|
291
|
-
type_ (type) {}
|
|
292
|
-
|
|
293
|
-
void FrameIn() {
|
|
294
|
-
++frames_in_;
|
|
295
|
-
time_t now = time (0);
|
|
296
|
-
|
|
297
|
-
if (now == last_time_) {
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
if (! (frames_in_ % 10)) {
|
|
302
|
-
GMPLOG (GL_INFO, type_ << ": " << now << " Frame count "
|
|
303
|
-
<< frames_in_
|
|
304
|
-
<< "(" << (frames_in_ / (now - start_time_)) << "/"
|
|
305
|
-
<< (30 / (now - last_time_)) << ")"
|
|
306
|
-
<< " -- " << frames_out_);
|
|
307
|
-
last_time_ = now;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
void FrameOut() {
|
|
312
|
-
++frames_out_;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
private:
|
|
316
|
-
uint64_t frames_in_;
|
|
317
|
-
uint64_t frames_out_;
|
|
318
|
-
time_t start_time_;
|
|
319
|
-
time_t last_time_;
|
|
320
|
-
const std::string type_;
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
class OpenH264VideoEncoder : public GMPVideoEncoder, public RefCounted {
|
|
324
|
-
public:
|
|
325
|
-
OpenH264VideoEncoder (GMPVideoHost* hostAPI) :
|
|
326
|
-
host_ (hostAPI),
|
|
327
|
-
worker_thread_ (nullptr),
|
|
328
|
-
encoder_ (nullptr),
|
|
329
|
-
max_payload_size_ (0),
|
|
330
|
-
callback_ (nullptr),
|
|
331
|
-
stats_ ("Encoder"),
|
|
332
|
-
gmp_api_version_ (kGMPVersion33),
|
|
333
|
-
shutting_down(false) {
|
|
334
|
-
AddRef();
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
virtual void InitEncode (const GMPVideoCodec& codecSettings,
|
|
338
|
-
const uint8_t* aCodecSpecific,
|
|
339
|
-
uint32_t aCodecSpecificSize,
|
|
340
|
-
GMPVideoEncoderCallback* callback,
|
|
341
|
-
int32_t numberOfCores,
|
|
342
|
-
uint32_t maxPayloadSize) {
|
|
343
|
-
gmp_api_version_ = codecSettings.mGMPApiVersion;
|
|
344
|
-
callback_ = callback;
|
|
345
|
-
|
|
346
|
-
GMPErr err = g_platform_api->createthread (&worker_thread_);
|
|
347
|
-
if (err != GMPNoErr) {
|
|
348
|
-
GMPLOG (GL_ERROR, "Couldn't create new thread");
|
|
349
|
-
Error (GMPGenericErr);
|
|
350
|
-
return;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
int rv = WelsCreateSVCEncoder (&encoder_);
|
|
354
|
-
if (rv) {
|
|
355
|
-
Error (GMPGenericErr);
|
|
356
|
-
return;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
if (gmp_api_version_ >= kGMPVersion34) {
|
|
360
|
-
uint32_t logLevel = GMPLogLevelToWelsLogLevel(codecSettings.mLogLevel);
|
|
361
|
-
long rv = encoder_->SetOption(ENCODER_OPTION_TRACE_LEVEL, &logLevel);
|
|
362
|
-
if (rv != cmResultSuccess) {
|
|
363
|
-
GMPLOG (GL_ERROR, "Encoder SetOption OPTION_TRACE_LEVEL failed " << rv);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
SEncParamExt param;
|
|
368
|
-
memset (¶m, 0, sizeof (param));
|
|
369
|
-
encoder_->GetDefaultParams (¶m);
|
|
370
|
-
|
|
371
|
-
GMPLOG (GL_INFO, "Initializing encoder at "
|
|
372
|
-
<< codecSettings.mWidth
|
|
373
|
-
<< "x"
|
|
374
|
-
<< codecSettings.mHeight
|
|
375
|
-
<< "@"
|
|
376
|
-
<< static_cast<int> (codecSettings.mMaxFramerate));
|
|
377
|
-
|
|
378
|
-
// Translate parameters.
|
|
379
|
-
if (gmp_api_version_ >= kGMPVersion35) {
|
|
380
|
-
param.iUsageType = GMPVideoCodecModeToWelsUsageType(codecSettings.mMode);
|
|
381
|
-
} else if (codecSettings.mMode == kGMPScreensharing) {
|
|
382
|
-
param.iUsageType = SCREEN_CONTENT_REAL_TIME;
|
|
383
|
-
} else {
|
|
384
|
-
param.iUsageType = CAMERA_VIDEO_REAL_TIME;
|
|
385
|
-
}
|
|
386
|
-
param.iPicWidth = codecSettings.mWidth;
|
|
387
|
-
param.iPicHeight = codecSettings.mHeight;
|
|
388
|
-
if (gmp_api_version_ >= kGMPVersion35) {
|
|
389
|
-
param.iRCMode = GMPRateControlModeToWelsRcModes(codecSettings.mRateControlMode);
|
|
390
|
-
} else {
|
|
391
|
-
param.iRCMode = RC_BITRATE_MODE;
|
|
392
|
-
}
|
|
393
|
-
param.iTargetBitrate = codecSettings.mStartBitrate * 1000;
|
|
394
|
-
param.iMaxBitrate = codecSettings.mMaxBitrate * 1000;
|
|
395
|
-
GMPLOG (GL_INFO, "Initializing Bit Rate at: Start: "
|
|
396
|
-
<< codecSettings.mStartBitrate
|
|
397
|
-
<< "; Min: "
|
|
398
|
-
<< codecSettings.mMinBitrate
|
|
399
|
-
<< "; Max: "
|
|
400
|
-
<< codecSettings.mMaxBitrate
|
|
401
|
-
<< "; Max payload size:"
|
|
402
|
-
<< maxPayloadSize);
|
|
403
|
-
|
|
404
|
-
param.uiMaxNalSize = maxPayloadSize;
|
|
405
|
-
|
|
406
|
-
// TODO(ekr@rtfm.com). Scary conversion from unsigned char to float below.
|
|
407
|
-
param.fMaxFrameRate = static_cast<float> (codecSettings.mMaxFramerate);
|
|
408
|
-
|
|
409
|
-
// Set up layers. Currently we have one layer.
|
|
410
|
-
SSpatialLayerConfig* layer = ¶m.sSpatialLayers[0];
|
|
411
|
-
|
|
412
|
-
// Make sure the output resolution doesn't exceed the Openh264 capability
|
|
413
|
-
double width_mb = std::ceil(codecSettings.mWidth/16.0);
|
|
414
|
-
double height_mb = std::ceil(codecSettings.mHeight/16.0);
|
|
415
|
-
double input_mb = width_mb * height_mb;
|
|
416
|
-
if (static_cast<uint32_t>(input_mb) > OPENH264_MAX_MB) {
|
|
417
|
-
double scale = std::sqrt(OPENH264_MAX_MB / input_mb);
|
|
418
|
-
layer->iVideoWidth = static_cast<uint32_t>(width_mb * 16 * scale);
|
|
419
|
-
layer->iVideoHeight = static_cast<uint32_t>(height_mb * 16 * scale);
|
|
420
|
-
GMPLOG (GL_INFO, "InitEncode: the output resolution overflows, w x h = " << codecSettings.mWidth << " x " << codecSettings.mHeight
|
|
421
|
-
<< ", turned to be " << layer->iVideoWidth << " x " << layer->iVideoHeight);
|
|
422
|
-
} else {
|
|
423
|
-
layer->iVideoWidth = codecSettings.mWidth;
|
|
424
|
-
layer->iVideoHeight = codecSettings.mHeight;
|
|
425
|
-
}
|
|
426
|
-
if (layer->iVideoWidth < 16) {
|
|
427
|
-
layer->iVideoWidth = 16;
|
|
428
|
-
}
|
|
429
|
-
if (layer->iVideoHeight < 16) {
|
|
430
|
-
layer->iVideoHeight = 16;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
layer->fFrameRate = param.fMaxFrameRate;
|
|
434
|
-
layer->iSpatialBitrate = param.iTargetBitrate;
|
|
435
|
-
layer->iMaxSpatialBitrate = param.iMaxBitrate;
|
|
436
|
-
|
|
437
|
-
if (gmp_api_version_ >= kGMPVersion35) {
|
|
438
|
-
layer->uiProfileIdc = GMPProfileToWelsProfile(codecSettings.mProfile);
|
|
439
|
-
layer->uiLevelIdc = GMPLevelToWelsLevel(codecSettings.mLevel);
|
|
440
|
-
layer->sSliceArgument.uiSliceMode = GMPSliceToWelsSliceMode(codecSettings.mSliceMode);
|
|
441
|
-
if (codecSettings.mUseThreadedEncode) {
|
|
442
|
-
param.iMultipleThreadIdc = numberOfCores;
|
|
443
|
-
} else {
|
|
444
|
-
param.iMultipleThreadIdc = 1; // disabled
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
if (gmp_api_version_ >= kGMPVersion36) {
|
|
449
|
-
param.iTemporalLayerNum = codecSettings.mTemporalLayerNum;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
//for controlling the NAL size (normally for packetization-mode=0)
|
|
453
|
-
if (maxPayloadSize != 0) {
|
|
454
|
-
if (gmp_api_version_ < kGMPVersion35) {
|
|
455
|
-
layer->sSliceArgument.uiSliceMode = SM_SIZELIMITED_SLICE;
|
|
456
|
-
}
|
|
457
|
-
layer->sSliceArgument.uiSliceSizeConstraint = maxPayloadSize;
|
|
458
|
-
}
|
|
459
|
-
rv = encoder_->InitializeExt (¶m);
|
|
460
|
-
if (rv) {
|
|
461
|
-
GMPLOG (GL_ERROR, "Couldn't initialize encoder");
|
|
462
|
-
Error (GMPGenericErr);
|
|
463
|
-
return;
|
|
464
|
-
}
|
|
465
|
-
max_payload_size_ = maxPayloadSize;
|
|
466
|
-
GMPLOG (GL_INFO, "Initialized encoder");
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
virtual void Encode (GMPVideoi420Frame* inputImage,
|
|
470
|
-
const uint8_t* aCodecSpecificInfo,
|
|
471
|
-
uint32_t aCodecSpecificInfoLength,
|
|
472
|
-
const GMPVideoFrameType* aFrameTypes,
|
|
473
|
-
uint32_t aFrameTypesLength) {
|
|
474
|
-
GMPLOG (GL_DEBUG,
|
|
475
|
-
__FUNCTION__
|
|
476
|
-
<< " size="
|
|
477
|
-
<< inputImage->Width() << "x" << inputImage->Height());
|
|
478
|
-
|
|
479
|
-
stats_.FrameIn();
|
|
480
|
-
|
|
481
|
-
assert (aFrameTypesLength != 0);
|
|
482
|
-
|
|
483
|
-
worker_thread_->Post (WrapTaskRefCounted (
|
|
484
|
-
this, &OpenH264VideoEncoder::Encode_w,
|
|
485
|
-
inputImage,
|
|
486
|
-
(aFrameTypes)[0]));
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
virtual void SetChannelParameters (uint32_t aPacketLoss, uint32_t aRTT) {
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
virtual void SetRates (uint32_t aNewBitRate, uint32_t aFrameRate) {
|
|
493
|
-
GMPLOG (GL_INFO, "[SetRates] Begin with: "
|
|
494
|
-
<< aNewBitRate << " , " << aFrameRate);
|
|
495
|
-
//update bitrate if needed
|
|
496
|
-
const int32_t newBitRate = aNewBitRate * 1000; //kbps->bps
|
|
497
|
-
SBitrateInfo existEncoderBitRate;
|
|
498
|
-
existEncoderBitRate.iLayer = SPATIAL_LAYER_ALL;
|
|
499
|
-
int rv = encoder_->GetOption (ENCODER_OPTION_BITRATE, &existEncoderBitRate);
|
|
500
|
-
if (rv != cmResultSuccess) {
|
|
501
|
-
GMPLOG (GL_ERROR, "[SetRates] Error in Getting Bit Rate at Layer:"
|
|
502
|
-
<< rv
|
|
503
|
-
<< " ; Layer = "
|
|
504
|
-
<< existEncoderBitRate.iLayer
|
|
505
|
-
<< " ; BR = "
|
|
506
|
-
<< existEncoderBitRate.iBitrate);
|
|
507
|
-
Error (GMPGenericErr);
|
|
508
|
-
return;
|
|
509
|
-
}
|
|
510
|
-
if (rv == cmResultSuccess && existEncoderBitRate.iBitrate != newBitRate) {
|
|
511
|
-
SBitrateInfo newEncoderBitRate;
|
|
512
|
-
newEncoderBitRate.iLayer = SPATIAL_LAYER_ALL;
|
|
513
|
-
newEncoderBitRate.iBitrate = newBitRate;
|
|
514
|
-
rv = encoder_->SetOption (ENCODER_OPTION_BITRATE, &newEncoderBitRate);
|
|
515
|
-
if (rv == cmResultSuccess) {
|
|
516
|
-
GMPLOG (GL_INFO, "[SetRates] Update Encoder Bandwidth (AllLayers): ReturnValue: "
|
|
517
|
-
<< rv
|
|
518
|
-
<< "BitRate(kbps): "
|
|
519
|
-
<< aNewBitRate);
|
|
520
|
-
} else {
|
|
521
|
-
GMPLOG (GL_ERROR, "[SetRates] Error in Setting Bit Rate at Layer:"
|
|
522
|
-
<< rv
|
|
523
|
-
<< " ; Layer = "
|
|
524
|
-
<< newEncoderBitRate.iLayer
|
|
525
|
-
<< " ; BR = "
|
|
526
|
-
<< newEncoderBitRate.iBitrate);
|
|
527
|
-
Error (GMPGenericErr);
|
|
528
|
-
return;
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
//update framerate if needed
|
|
532
|
-
float existFrameRate = 0;
|
|
533
|
-
rv = encoder_->GetOption (ENCODER_OPTION_FRAME_RATE, &existFrameRate);
|
|
534
|
-
if (rv != cmResultSuccess) {
|
|
535
|
-
GMPLOG (GL_ERROR, "[SetRates] Error in Getting Frame Rate:"
|
|
536
|
-
<< rv << " FrameRate: " << existFrameRate);
|
|
537
|
-
Error (GMPGenericErr);
|
|
538
|
-
return;
|
|
539
|
-
}
|
|
540
|
-
if (rv == cmResultSuccess &&
|
|
541
|
-
(aFrameRate - existFrameRate > 0.001f ||
|
|
542
|
-
existFrameRate - aFrameRate > 0.001f)) {
|
|
543
|
-
float newFrameRate = static_cast<float> (aFrameRate);
|
|
544
|
-
rv = encoder_->SetOption (ENCODER_OPTION_FRAME_RATE, &newFrameRate);
|
|
545
|
-
if (rv == cmResultSuccess) {
|
|
546
|
-
GMPLOG (GL_INFO, "[SetRates] Update Encoder Frame Rate: ReturnValue: "
|
|
547
|
-
<< rv << " FrameRate: " << aFrameRate);
|
|
548
|
-
} else {
|
|
549
|
-
GMPLOG (GL_ERROR, "[SetRates] Error in Setting Frame Rate: ReturnValue: "
|
|
550
|
-
<< rv << " FrameRate: " << aFrameRate);
|
|
551
|
-
Error (GMPGenericErr);
|
|
552
|
-
return;
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
virtual void SetPeriodicKeyFrames (bool aEnable) {
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
virtual void EncodingComplete() {
|
|
561
|
-
shutting_down = true;
|
|
562
|
-
|
|
563
|
-
// Release the reference to the external objects, because it is no longer safe to call them
|
|
564
|
-
host_ = nullptr;
|
|
565
|
-
callback_ = nullptr;
|
|
566
|
-
TearDownEncoder();
|
|
567
|
-
|
|
568
|
-
Release();
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
private:
|
|
572
|
-
virtual ~OpenH264VideoEncoder() {
|
|
573
|
-
// Tear down the internal encoder in case of EncodingComplete() not being called
|
|
574
|
-
TearDownEncoder();
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
void TearDownEncoder() {
|
|
578
|
-
// Stop the worker thread first
|
|
579
|
-
if (worker_thread_) {
|
|
580
|
-
worker_thread_->Join();
|
|
581
|
-
worker_thread_ = nullptr;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
// Destroy OpenH264 encoder
|
|
585
|
-
if (encoder_) {
|
|
586
|
-
WelsDestroySVCEncoder(encoder_);
|
|
587
|
-
encoder_ = nullptr;
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
void TrySyncRunOnMainThread(GMPTask* aTask) {
|
|
592
|
-
if (!shutting_down && g_platform_api) {
|
|
593
|
-
g_platform_api->syncrunonmainthread (aTask);
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
void Error (GMPErr error) {
|
|
598
|
-
if (callback_) {
|
|
599
|
-
callback_->Error (error);
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
void Encode_w (GMPVideoi420Frame* inputImage,
|
|
604
|
-
GMPVideoFrameType frame_type) {
|
|
605
|
-
SFrameBSInfo encoded;
|
|
606
|
-
|
|
607
|
-
if (frame_type == kGMPKeyFrame) {
|
|
608
|
-
encoder_->ForceIntraFrame (true);
|
|
609
|
-
if (!inputImage)
|
|
610
|
-
return;
|
|
611
|
-
}
|
|
612
|
-
if (!inputImage) {
|
|
613
|
-
GMPLOG (GL_ERROR, "no input image");
|
|
614
|
-
return;
|
|
615
|
-
}
|
|
616
|
-
SSourcePicture src;
|
|
617
|
-
|
|
618
|
-
src.iColorFormat = videoFormatI420;
|
|
619
|
-
src.iStride[0] = inputImage->Stride (kGMPYPlane);
|
|
620
|
-
src.pData[0] = reinterpret_cast<unsigned char*> (
|
|
621
|
-
const_cast<uint8_t*> (inputImage->Buffer (kGMPYPlane)));
|
|
622
|
-
src.iStride[1] = inputImage->Stride (kGMPUPlane);
|
|
623
|
-
src.pData[1] = reinterpret_cast<unsigned char*> (
|
|
624
|
-
const_cast<uint8_t*> (inputImage->Buffer (kGMPUPlane)));
|
|
625
|
-
src.iStride[2] = inputImage->Stride (kGMPVPlane);
|
|
626
|
-
src.pData[2] = reinterpret_cast<unsigned char*> (
|
|
627
|
-
const_cast<uint8_t*> (inputImage->Buffer (kGMPVPlane)));
|
|
628
|
-
src.iStride[3] = 0;
|
|
629
|
-
src.pData[3] = nullptr;
|
|
630
|
-
src.iPicWidth = inputImage->Width();
|
|
631
|
-
src.iPicHeight = inputImage->Height();
|
|
632
|
-
src.uiTimeStamp = inputImage->Timestamp() / 1000; //encoder needs millisecond
|
|
633
|
-
const SSourcePicture* pics = &src;
|
|
634
|
-
|
|
635
|
-
int result = encoder_->EncodeFrame (pics, &encoded);
|
|
636
|
-
if (result != cmResultSuccess) {
|
|
637
|
-
GMPLOG (GL_ERROR, "Couldn't encode frame. Error = " << result);
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
// Translate int to enum
|
|
642
|
-
GMPVideoFrameType encoded_type;
|
|
643
|
-
bool has_frame = false;
|
|
644
|
-
|
|
645
|
-
switch (encoded.eFrameType) {
|
|
646
|
-
case videoFrameTypeIDR:
|
|
647
|
-
encoded_type = kGMPKeyFrame;
|
|
648
|
-
has_frame = true;
|
|
649
|
-
break;
|
|
650
|
-
case videoFrameTypeI:
|
|
651
|
-
encoded_type = kGMPKeyFrame;
|
|
652
|
-
has_frame = true;
|
|
653
|
-
break;
|
|
654
|
-
case videoFrameTypeP:
|
|
655
|
-
encoded_type = kGMPDeltaFrame;
|
|
656
|
-
has_frame = true;
|
|
657
|
-
break;
|
|
658
|
-
case videoFrameTypeSkip:
|
|
659
|
-
// Can skip the call back since no actual bitstream will be generated
|
|
660
|
-
break;
|
|
661
|
-
case videoFrameTypeIPMixed://this type is currently not suppported
|
|
662
|
-
case videoFrameTypeInvalid:
|
|
663
|
-
GMPLOG (GL_ERROR, "Couldn't encode frame. Type = "
|
|
664
|
-
<< encoded.eFrameType);
|
|
665
|
-
break;
|
|
666
|
-
default:
|
|
667
|
-
// The API is defined as returning a type.
|
|
668
|
-
assert (false);
|
|
669
|
-
break;
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
if (!has_frame) {
|
|
673
|
-
// This frame must be destroyed on the main thread.
|
|
674
|
-
TrySyncRunOnMainThread (WrapTask (
|
|
675
|
-
this,
|
|
676
|
-
&OpenH264VideoEncoder::DestroyInputFrame_m,
|
|
677
|
-
inputImage));
|
|
678
|
-
return;
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
// Synchronously send this back to the main thread for delivery.
|
|
682
|
-
TrySyncRunOnMainThread (WrapTask (
|
|
683
|
-
this,
|
|
684
|
-
&OpenH264VideoEncoder::Encode_m,
|
|
685
|
-
inputImage,
|
|
686
|
-
&encoded,
|
|
687
|
-
encoded_type));
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
void Encode_m (GMPVideoi420Frame* frame, SFrameBSInfo* encoded,
|
|
691
|
-
GMPVideoFrameType frame_type) {
|
|
692
|
-
// Attach a self-destructor so that this dies on return.
|
|
693
|
-
SelfDestruct<GMPVideoi420Frame> ifd (frame);
|
|
694
|
-
|
|
695
|
-
if (!host_) {
|
|
696
|
-
return;
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
// Now return the encoded data back to the parent.
|
|
700
|
-
GMPVideoFrame* ftmp;
|
|
701
|
-
GMPErr err = host_->CreateFrame (kGMPEncodedVideoFrame, &ftmp);
|
|
702
|
-
if (err != GMPNoErr) {
|
|
703
|
-
GMPLOG (GL_ERROR, "Error creating encoded frame");
|
|
704
|
-
return;
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
GMPVideoEncodedFrame* f = static_cast<GMPVideoEncodedFrame*> (ftmp);
|
|
708
|
-
// Buffer up the data.
|
|
709
|
-
uint32_t length = 0;
|
|
710
|
-
std::vector<uint32_t> lengths;
|
|
711
|
-
unsigned char temporalId = 0;
|
|
712
|
-
|
|
713
|
-
for (int i = 0; i < encoded->iLayerNum; ++i) {
|
|
714
|
-
lengths.push_back (0);
|
|
715
|
-
uint8_t* tmp = encoded->sLayerInfo[i].pBsBuf;
|
|
716
|
-
assert(encoded->sLayerInfo[i].uiSpatialId == 0);
|
|
717
|
-
temporalId = encoded->sLayerInfo[i].uiTemporalId;
|
|
718
|
-
for (int j = 0; j < encoded->sLayerInfo[i].iNalCount; ++j) {
|
|
719
|
-
lengths[i] += encoded->sLayerInfo[i].pNalLengthInByte[j];
|
|
720
|
-
// Convert from 4-byte start codes to GMP_BufferLength32 (NAL lengths)
|
|
721
|
-
assert (* (reinterpret_cast<uint32_t*> (tmp)) == 0x01000000);
|
|
722
|
-
// BufferType32 doesn't include the length of the length itself!
|
|
723
|
-
* (reinterpret_cast<uint32_t*> (tmp)) = encoded->sLayerInfo[i].pNalLengthInByte[j] - sizeof (uint32_t);
|
|
724
|
-
length += encoded->sLayerInfo[i].pNalLengthInByte[j];
|
|
725
|
-
tmp += encoded->sLayerInfo[i].pNalLengthInByte[j];
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
err = f->CreateEmptyFrame (length);
|
|
730
|
-
if (err != GMPNoErr) {
|
|
731
|
-
GMPLOG (GL_ERROR, "Error allocating frame data");
|
|
732
|
-
f->Destroy();
|
|
733
|
-
return;
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
// Copy the data.
|
|
737
|
-
// Here we concatenate into one big buffer
|
|
738
|
-
uint8_t* tmp = f->Buffer();
|
|
739
|
-
for (int i = 0; i < encoded->iLayerNum; ++i) {
|
|
740
|
-
memcpy (tmp, encoded->sLayerInfo[i].pBsBuf, lengths[i]);
|
|
741
|
-
tmp += lengths[i];
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
f->SetEncodedWidth (frame->Width());
|
|
745
|
-
f->SetEncodedHeight (frame->Height());
|
|
746
|
-
f->SetTimeStamp (frame->Timestamp());
|
|
747
|
-
f->SetFrameType (frame_type);
|
|
748
|
-
f->SetCompleteFrame (true);
|
|
749
|
-
f->SetBufferType (GMP_BufferLength32);
|
|
750
|
-
|
|
751
|
-
if (gmp_api_version_ >= kGMPVersion36) {
|
|
752
|
-
f->SetTemporalLayerId (temporalId);
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
GMPLOG (GL_DEBUG, "Encoding complete. type= "
|
|
756
|
-
<< f->FrameType()
|
|
757
|
-
<< " length="
|
|
758
|
-
<< f->Size()
|
|
759
|
-
<< " timestamp="
|
|
760
|
-
<< f->TimeStamp());
|
|
761
|
-
|
|
762
|
-
// Return the encoded frame.
|
|
763
|
-
GMPCodecSpecificInfo info;
|
|
764
|
-
memset (&info, 0, sizeof (info)); // shouldn't be needed, we init everything
|
|
765
|
-
info.mCodecType = kGMPVideoCodecH264;
|
|
766
|
-
info.mBufferType = GMP_BufferLength32;
|
|
767
|
-
info.mCodecSpecific.mH264.mSimulcastIdx = 0;
|
|
768
|
-
|
|
769
|
-
if (callback_) {
|
|
770
|
-
callback_->Encoded (f, reinterpret_cast<uint8_t*> (&info), sizeof (info));
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
stats_.FrameOut();
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
// These frames must be destroyed on the main thread.
|
|
777
|
-
void DestroyInputFrame_m (GMPVideoi420Frame* frame) {
|
|
778
|
-
frame->Destroy();
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
private:
|
|
783
|
-
GMPVideoHost* host_;
|
|
784
|
-
GMPThread* worker_thread_;
|
|
785
|
-
ISVCEncoder* encoder_;
|
|
786
|
-
uint32_t max_payload_size_;
|
|
787
|
-
GMPVideoEncoderCallback* callback_;
|
|
788
|
-
FrameStats stats_;
|
|
789
|
-
uint32_t gmp_api_version_;
|
|
790
|
-
bool shutting_down;
|
|
791
|
-
};
|
|
792
|
-
|
|
793
|
-
uint16_t readU16BE(const uint8_t* in) {
|
|
794
|
-
return in[0] << 8 | in[1];
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
void copyWithStartCode(std::vector<uint8_t>& out, const uint8_t* in, size_t size) {
|
|
798
|
-
static const uint8_t code[] = { 0x00, 0x00, 0x00, 0x01 };
|
|
799
|
-
out.insert(out.end(), code, code + sizeof(code));
|
|
800
|
-
out.insert(out.end(), in, in + size);
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
class OpenH264VideoDecoder : public GMPVideoDecoder, public RefCounted {
|
|
804
|
-
public:
|
|
805
|
-
OpenH264VideoDecoder (GMPVideoHost* hostAPI) :
|
|
806
|
-
host_ (hostAPI),
|
|
807
|
-
worker_thread_ (nullptr),
|
|
808
|
-
callback_ (nullptr),
|
|
809
|
-
decoder_ (nullptr),
|
|
810
|
-
stats_ ("Decoder"),
|
|
811
|
-
gmp_api_version_ (kGMPVersion33),
|
|
812
|
-
shutting_down(false) {
|
|
813
|
-
AddRef();
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
virtual void InitDecode (const GMPVideoCodec& codecSettings,
|
|
817
|
-
const uint8_t* aCodecSpecific,
|
|
818
|
-
uint32_t aCodecSpecificSize,
|
|
819
|
-
GMPVideoDecoderCallback* callback,
|
|
820
|
-
int32_t coreCount) {
|
|
821
|
-
gmp_api_version_ = codecSettings.mGMPApiVersion;
|
|
822
|
-
callback_ = callback;
|
|
823
|
-
|
|
824
|
-
GMPLOG (GL_INFO, "InitDecode");
|
|
825
|
-
|
|
826
|
-
GMPErr err = g_platform_api->createthread (&worker_thread_);
|
|
827
|
-
if (err != GMPNoErr) {
|
|
828
|
-
GMPLOG (GL_ERROR, "Couldn't create new thread");
|
|
829
|
-
Error (GMPGenericErr);
|
|
830
|
-
return;
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
if (WelsCreateDecoder (&decoder_)) {
|
|
834
|
-
GMPLOG (GL_ERROR, "Couldn't create decoder");
|
|
835
|
-
Error (GMPGenericErr);
|
|
836
|
-
return;
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
if (!decoder_) {
|
|
840
|
-
GMPLOG (GL_ERROR, "Couldn't create decoder");
|
|
841
|
-
Error (GMPGenericErr);
|
|
842
|
-
return;
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
if (gmp_api_version_ >= kGMPVersion34) {
|
|
846
|
-
if (codecSettings.mUseThreadedDecode) {
|
|
847
|
-
long rv = decoder_->SetOption(DECODER_OPTION_NUM_OF_THREADS, &coreCount);
|
|
848
|
-
if (rv != cmResultSuccess) {
|
|
849
|
-
GMPLOG (GL_ERROR, "Decoder SetOption NUM_OF_THREADS failed " << rv);
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
uint32_t logLevel = GMPLogLevelToWelsLogLevel(codecSettings.mLogLevel);
|
|
854
|
-
long rv = decoder_->SetOption(DECODER_OPTION_TRACE_LEVEL, &logLevel);
|
|
855
|
-
if (rv != cmResultSuccess) {
|
|
856
|
-
GMPLOG (GL_ERROR, "Decoder SetOption OPTION_TRACE_LEVEL failed " << rv);
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
SDecodingParam param;
|
|
861
|
-
memset (¶m, 0, sizeof (param));
|
|
862
|
-
param.uiTargetDqLayer = UCHAR_MAX; // Default value
|
|
863
|
-
param.eEcActiveIdc = ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE; // Error concealment on.
|
|
864
|
-
param.sVideoProperty.size = sizeof(param.sVideoProperty);
|
|
865
|
-
param.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
|
|
866
|
-
|
|
867
|
-
if (decoder_->Initialize (¶m)) {
|
|
868
|
-
GMPLOG (GL_ERROR, "Couldn't initialize decoder");
|
|
869
|
-
Error (GMPGenericErr);
|
|
870
|
-
return;
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
if (aCodecSpecific && aCodecSpecificSize >= sizeof(GMPVideoCodecH264)) {
|
|
874
|
-
std::vector<uint8_t> annexb;
|
|
875
|
-
|
|
876
|
-
// Convert the AVCC data, starting at the byte containing
|
|
877
|
-
// numOfSequenceParameterSets, to Annex B format.
|
|
878
|
-
const uint8_t* avcc = aCodecSpecific + offsetof(GMPVideoCodecH264, mAVCC.mNumSPS);
|
|
879
|
-
|
|
880
|
-
static const int kSPSMask = (1 << 5) - 1;
|
|
881
|
-
uint8_t spsCount = *avcc++ & kSPSMask;
|
|
882
|
-
for (int i = 0; i < spsCount; ++i) {
|
|
883
|
-
size_t size = readU16BE(avcc);
|
|
884
|
-
avcc += 2;
|
|
885
|
-
copyWithStartCode(annexb, avcc, size);
|
|
886
|
-
avcc += size;
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
uint8_t ppsCount = *avcc++;
|
|
890
|
-
for (int i = 0; i < ppsCount; ++i) {
|
|
891
|
-
size_t size = readU16BE(avcc);
|
|
892
|
-
avcc += 2;
|
|
893
|
-
copyWithStartCode(annexb, avcc, size);
|
|
894
|
-
avcc += size;
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
SBufferInfo decoded;
|
|
898
|
-
memset (&decoded, 0, sizeof (decoded));
|
|
899
|
-
unsigned char* data[3] = {nullptr, nullptr, nullptr};
|
|
900
|
-
DECODING_STATE dState = decoder_->DecodeFrame2 (&*annexb.begin(),
|
|
901
|
-
annexb.size(),
|
|
902
|
-
data,
|
|
903
|
-
&decoded);
|
|
904
|
-
if (dState) {
|
|
905
|
-
GMPLOG (GL_ERROR, "Decoding error dState=" << dState);
|
|
906
|
-
}
|
|
907
|
-
GMPLOG (GL_ERROR, "InitDecode iBufferStatus=" << decoded.iBufferStatus);
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
virtual void Decode (GMPVideoEncodedFrame* inputFrame,
|
|
912
|
-
bool missingFrames,
|
|
913
|
-
const uint8_t* aCodecSpecificInfo,
|
|
914
|
-
uint32_t aCodecSpecificInfoLength,
|
|
915
|
-
int64_t renderTimeMs = -1) {
|
|
916
|
-
GMPLOG (GL_DEBUG, __FUNCTION__
|
|
917
|
-
<< "Decoding frame size=" << inputFrame->Size()
|
|
918
|
-
<< " timestamp=" << inputFrame->TimeStamp());
|
|
919
|
-
stats_.FrameIn();
|
|
920
|
-
//const GMPCodecSpecificInfo *codecSpecificInfo = (GMPCodecSpecificInfo) aCodecSpecificInfo;
|
|
921
|
-
|
|
922
|
-
// Convert to H.264 start codes
|
|
923
|
-
switch (inputFrame->BufferType()) {
|
|
924
|
-
case GMP_BufferSingle:
|
|
925
|
-
case GMP_BufferLength8:
|
|
926
|
-
case GMP_BufferLength16:
|
|
927
|
-
case GMP_BufferLength24:
|
|
928
|
-
// We should look to support these, especially GMP_BufferSingle
|
|
929
|
-
assert (false);
|
|
930
|
-
break;
|
|
931
|
-
|
|
932
|
-
case GMP_BufferLength32: {
|
|
933
|
-
uint8_t* start_code = inputFrame->Buffer();
|
|
934
|
-
// start code should be at least four bytes from the end or we risk
|
|
935
|
-
// reading/writing outside the buffer.
|
|
936
|
-
while (start_code < inputFrame->Buffer() + inputFrame->Size() - 4) {
|
|
937
|
-
static const uint8_t code[] = { 0x00, 0x00, 0x00, 0x01 };
|
|
938
|
-
uint8_t* lenp = start_code;
|
|
939
|
-
start_code += * (reinterpret_cast<int32_t*> (lenp));
|
|
940
|
-
memcpy (lenp, code, 4);
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
break;
|
|
944
|
-
|
|
945
|
-
default:
|
|
946
|
-
assert (false);
|
|
947
|
-
break;
|
|
948
|
-
}
|
|
949
|
-
DECODING_STATE dState = dsErrorFree;
|
|
950
|
-
worker_thread_->Post (WrapTaskRefCounted (
|
|
951
|
-
this, &OpenH264VideoDecoder::Decode_w,
|
|
952
|
-
inputFrame,
|
|
953
|
-
missingFrames,
|
|
954
|
-
dState,
|
|
955
|
-
renderTimeMs));
|
|
956
|
-
if (dState) {
|
|
957
|
-
Error (GMPGenericErr);
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
virtual void Reset() {
|
|
962
|
-
if (gmp_api_version_ >= kGMPVersion34) {
|
|
963
|
-
worker_thread_->Post (WrapTaskRefCounted (
|
|
964
|
-
this, &OpenH264VideoDecoder::Reset_w));
|
|
965
|
-
} else if (callback_) {
|
|
966
|
-
callback_->ResetComplete ();
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
virtual void Drain() {
|
|
971
|
-
if (callback_) {
|
|
972
|
-
callback_->DrainComplete ();
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
virtual void DecodingComplete() {
|
|
977
|
-
shutting_down = true;
|
|
978
|
-
|
|
979
|
-
// Release the reference to the external objects, because it is no longer safe to call them
|
|
980
|
-
host_ = nullptr;
|
|
981
|
-
callback_ = nullptr;
|
|
982
|
-
TearDownDecoder();
|
|
983
|
-
|
|
984
|
-
Release();
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
private:
|
|
988
|
-
virtual ~OpenH264VideoDecoder() {
|
|
989
|
-
// Tear down the internal decoder in case of DecodingComplete() not being called
|
|
990
|
-
TearDownDecoder();
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
void TearDownDecoder() {
|
|
994
|
-
// Stop the worker thread first
|
|
995
|
-
if (worker_thread_) {
|
|
996
|
-
worker_thread_->Join();
|
|
997
|
-
worker_thread_ = nullptr;
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
|
-
// Destroy OpenH264 decoder
|
|
1001
|
-
if (decoder_) {
|
|
1002
|
-
WelsDestroyDecoder(decoder_);
|
|
1003
|
-
decoder_ = nullptr;
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
void TrySyncRunOnMainThread(GMPTask* aTask) {
|
|
1008
|
-
if (!shutting_down && g_platform_api) {
|
|
1009
|
-
g_platform_api->syncrunonmainthread (aTask);
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
void Error (GMPErr error) {
|
|
1014
|
-
if (callback_) {
|
|
1015
|
-
callback_->Error (error);
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
void Decode_w (GMPVideoEncodedFrame* inputFrame,
|
|
1020
|
-
bool missingFrames,
|
|
1021
|
-
DECODING_STATE& dState,
|
|
1022
|
-
int64_t renderTimeMs = -1) {
|
|
1023
|
-
GMPLOG (GL_DEBUG, "Frame decode on worker thread length = "
|
|
1024
|
-
<< inputFrame->Size());
|
|
1025
|
-
|
|
1026
|
-
SBufferInfo decoded;
|
|
1027
|
-
bool valid = false;
|
|
1028
|
-
memset (&decoded, 0, sizeof (decoded));
|
|
1029
|
-
if (gmp_api_version_ >= kGMPVersion34) {
|
|
1030
|
-
decoded.uiInBsTimeStamp = inputFrame->TimeStamp();
|
|
1031
|
-
}
|
|
1032
|
-
unsigned char* data[3] = {nullptr, nullptr, nullptr};
|
|
1033
|
-
|
|
1034
|
-
dState = decoder_->DecodeFrameNoDelay (inputFrame->Buffer(),
|
|
1035
|
-
inputFrame->Size(),
|
|
1036
|
-
data,
|
|
1037
|
-
&decoded);
|
|
1038
|
-
|
|
1039
|
-
if (dState) {
|
|
1040
|
-
GMPLOG (GL_ERROR, "Decoding error dState=" << dState);
|
|
1041
|
-
} else {
|
|
1042
|
-
valid = true;
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
TrySyncRunOnMainThread (WrapTask (
|
|
1046
|
-
this,
|
|
1047
|
-
&OpenH264VideoDecoder::Decode_m,
|
|
1048
|
-
inputFrame,
|
|
1049
|
-
&decoded,
|
|
1050
|
-
data,
|
|
1051
|
-
renderTimeMs,
|
|
1052
|
-
valid));
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
// Return the decoded data back to the parent.
|
|
1056
|
-
void Decode_m (GMPVideoEncodedFrame* inputFrame,
|
|
1057
|
-
SBufferInfo* decoded,
|
|
1058
|
-
unsigned char* data[3],
|
|
1059
|
-
int64_t renderTimeMs,
|
|
1060
|
-
bool valid) {
|
|
1061
|
-
// Attach a self-destructor so that this dies on return.
|
|
1062
|
-
SelfDestruct<GMPVideoEncodedFrame> ifd (inputFrame);
|
|
1063
|
-
|
|
1064
|
-
// If we don't actually have data, just abort.
|
|
1065
|
-
if (!valid) {
|
|
1066
|
-
GMPLOG (GL_ERROR, "No valid data decoded");
|
|
1067
|
-
Error (GMPDecodeErr);
|
|
1068
|
-
return;
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
if (decoded->iBufferStatus != 1) {
|
|
1072
|
-
GMPLOG (GL_ERROR, "iBufferStatus=" << decoded->iBufferStatus);
|
|
1073
|
-
if (callback_) {
|
|
1074
|
-
callback_->InputDataExhausted();
|
|
1075
|
-
}
|
|
1076
|
-
return;
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
|
-
int width = decoded->UsrData.sSystemBuffer.iWidth;
|
|
1080
|
-
int height = decoded->UsrData.sSystemBuffer.iHeight;
|
|
1081
|
-
int ystride = decoded->UsrData.sSystemBuffer.iStride[0];
|
|
1082
|
-
int uvstride = decoded->UsrData.sSystemBuffer.iStride[1];
|
|
1083
|
-
|
|
1084
|
-
GMPLOG (GL_DEBUG, "Video frame ready for display "
|
|
1085
|
-
<< width
|
|
1086
|
-
<< "x"
|
|
1087
|
-
<< height
|
|
1088
|
-
<< " timestamp="
|
|
1089
|
-
<< inputFrame->TimeStamp());
|
|
1090
|
-
|
|
1091
|
-
GMPVideoFrame* ftmp = nullptr;
|
|
1092
|
-
|
|
1093
|
-
if (!host_) {
|
|
1094
|
-
return;
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
// Translate the image.
|
|
1098
|
-
GMPErr err = host_->CreateFrame (kGMPI420VideoFrame, &ftmp);
|
|
1099
|
-
if (err != GMPNoErr) {
|
|
1100
|
-
GMPLOG (GL_ERROR, "Couldn't allocate empty I420 frame");
|
|
1101
|
-
return;
|
|
1102
|
-
}
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
GMPVideoi420Frame* frame = static_cast<GMPVideoi420Frame*> (ftmp);
|
|
1106
|
-
err = frame->CreateFrame (
|
|
1107
|
-
ystride * height, static_cast<uint8_t*> (data[0]),
|
|
1108
|
-
uvstride * height / 2, static_cast<uint8_t*> (data[1]),
|
|
1109
|
-
uvstride * height / 2, static_cast<uint8_t*> (data[2]),
|
|
1110
|
-
width, height,
|
|
1111
|
-
ystride, uvstride, uvstride);
|
|
1112
|
-
if (err != GMPNoErr) {
|
|
1113
|
-
GMPLOG (GL_ERROR, "Couldn't make decoded frame");
|
|
1114
|
-
return;
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
|
-
GMPLOG (GL_DEBUG, "Allocated size = "
|
|
1118
|
-
<< frame->AllocatedSize (kGMPYPlane));
|
|
1119
|
-
frame->SetTimestamp (inputFrame->TimeStamp());
|
|
1120
|
-
if (gmp_api_version_ >= kGMPVersion34) {
|
|
1121
|
-
frame->SetUpdatedTimestamp (decoded->uiOutYuvTimeStamp);
|
|
1122
|
-
}
|
|
1123
|
-
frame->SetDuration (inputFrame->Duration());
|
|
1124
|
-
if (callback_) {
|
|
1125
|
-
callback_->Decoded (frame);
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
stats_.FrameOut();
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
|
-
void Reset_w () {
|
|
1132
|
-
int eos = 1;
|
|
1133
|
-
long rv = decoder_->SetOption(DECODER_OPTION_END_OF_STREAM, &eos);
|
|
1134
|
-
if (rv != cmResultSuccess) {
|
|
1135
|
-
GMPLOG (GL_ERROR, "Decoder SetOption END_OF_STREAM failed " << rv);
|
|
1136
|
-
}
|
|
1137
|
-
|
|
1138
|
-
DECODING_STATE dState;
|
|
1139
|
-
SBufferInfo decoded;
|
|
1140
|
-
unsigned char* data[3];
|
|
1141
|
-
do {
|
|
1142
|
-
memset (&decoded, 0, sizeof (decoded));
|
|
1143
|
-
memset (data, 0, sizeof (data));
|
|
1144
|
-
dState = decoder_->FlushFrame(data, &decoded);
|
|
1145
|
-
if (dState) {
|
|
1146
|
-
GMPLOG (GL_ERROR, "Flush error dState=" << dState);
|
|
1147
|
-
break;
|
|
1148
|
-
}
|
|
1149
|
-
} while (decoded.iBufferStatus == 1);
|
|
1150
|
-
|
|
1151
|
-
TrySyncRunOnMainThread (WrapTask (
|
|
1152
|
-
this,
|
|
1153
|
-
&OpenH264VideoDecoder::Reset_m));
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
|
-
void Reset_m () {
|
|
1157
|
-
if (callback_) {
|
|
1158
|
-
callback_->ResetComplete ();
|
|
1159
|
-
}
|
|
1160
|
-
}
|
|
1161
|
-
|
|
1162
|
-
GMPVideoHost* host_;
|
|
1163
|
-
GMPThread* worker_thread_;
|
|
1164
|
-
GMPVideoDecoderCallback* callback_;
|
|
1165
|
-
ISVCDecoder* decoder_;
|
|
1166
|
-
FrameStats stats_;
|
|
1167
|
-
uint32_t gmp_api_version_;
|
|
1168
|
-
bool shutting_down;
|
|
1169
|
-
};
|
|
1170
|
-
|
|
1171
|
-
extern "C" {
|
|
1172
|
-
|
|
1173
|
-
PUBLIC_FUNC GMPErr
|
|
1174
|
-
GMPInit (GMPPlatformAPI* aPlatformAPI) {
|
|
1175
|
-
g_platform_api = aPlatformAPI;
|
|
1176
|
-
return GMPNoErr;
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
|
-
PUBLIC_FUNC GMPErr
|
|
1180
|
-
GMPGetAPI (const char* aApiName, void* aHostAPI, void** aPluginApi) {
|
|
1181
|
-
if (!strcmp (aApiName, "decode-video")) {
|
|
1182
|
-
*aPluginApi = new OpenH264VideoDecoder (static_cast<GMPVideoHost*> (aHostAPI));
|
|
1183
|
-
return GMPNoErr;
|
|
1184
|
-
} else if (!strcmp (aApiName, "encode-video")) {
|
|
1185
|
-
*aPluginApi = new OpenH264VideoEncoder (static_cast<GMPVideoHost*> (aHostAPI));
|
|
1186
|
-
return GMPNoErr;
|
|
1187
|
-
}
|
|
1188
|
-
return GMPGenericErr;
|
|
1189
|
-
}
|
|
1190
|
-
|
|
1191
|
-
PUBLIC_FUNC void
|
|
1192
|
-
GMPShutdown (void) {
|
|
1193
|
-
g_platform_api = nullptr;
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
} // extern "C"
|