├── .gitignore ├── .travis.yml ├── Build ├── linux │ └── build.sh └── windows │ └── build.bat ├── CMakeLists.txt ├── Config └── Sample.cfg ├── Docs ├── 8bit_yuv420p.png └── svt-vp9_encoder_user_guide.md ├── LICENSE.md ├── NOTICES.md ├── README.md ├── STYLE.md ├── Source ├── API │ ├── EbApi.version │ ├── EbApiVersion.h.in │ ├── EbExport_List │ ├── EbSvtVp9Enc.h │ └── EbSvtVp9ErrorCodes.h ├── App │ ├── CMakeLists.txt │ ├── EbAppConfig.c │ ├── EbAppConfig.h │ ├── EbAppContext.c │ ├── EbAppContext.h │ ├── EbAppFifo.c │ ├── EbAppMain.c │ ├── EbAppProcessCmd.c │ ├── EbAppTime.c │ └── EbAppTime.h └── Lib │ ├── ASM_AVX2 │ ├── CMakeLists.txt │ ├── EbAvcStyleMcp_AVX2.h │ ├── EbAvcStyleMcp_Intrinsic_AVX2.c │ ├── EbCombinedAveragingSAD_Intrinsic_AVX2.c │ ├── EbCombinedAveragingSAD_Intrinsic_AVX2.h │ ├── EbCombinedAveragingSAD_Intrinsic_AVX512.c │ ├── EbCombinedAveragingSAD_Intrinsic_AVX512.h │ ├── EbComputeSAD_AVX2.h │ ├── EbComputeSAD_Intrinsic_AVX2.c │ ├── EbComputeSAD_SadLoopKernel_AVX512.c │ ├── EbComputeSAD_SadLoopKernel_AVX512.h │ ├── EbFdct_Intrinsic_AVX2.c │ ├── EbIdct_Intrinsic_AVX2.c │ ├── EbIntraPrediction_Intrinsic_AVX2.c │ ├── EbMemory_AVX2.h │ ├── EbNoiseExtractAVX2.c │ ├── EbNoiseExtractAVX2.h │ ├── EbPackUnPack_Intrinsic_AVX2.c │ ├── EbPackUnPack_Intrinsic_AVX2.h │ ├── EbPictureOperators_AVX2.h │ ├── EbPictureOperators_Intrinsic_AVX2.c │ ├── EbTransforms_AVX2.h │ ├── EbTranspose_AVX2.h │ ├── fwd_dct32x32_impl_avx2.c │ ├── loopfilter_avx2.c │ ├── quantize_avx.c │ └── vpx_subpixel_8t_intrin_avx2.c │ ├── ASM_SSE2 │ ├── CMakeLists.txt │ ├── EbAvcStyleMcp_Intrinsic_SSE2.c │ ├── EbAvcStyleMcp_SSE2.h │ ├── EbCombinedAveragingSAD_Intrinsic_SSE2.c │ ├── EbComputeMean_Intrinsic_SSE2.c │ ├── EbComputeMean_SSE2.h │ ├── EbComputeSAD_SSE2.h │ ├── EbIntrinMacros16bit_SSE2.h │ ├── EbIntrinMacros_SSE2.h │ ├── EbMcp_SSE2.h │ ├── EbMeSadCalculation_Intrinsic_SSE2.c │ ├── EbMeSadCalculation_SSE2.h │ ├── EbPackUnPack_Intrinsic_SSE2.c │ ├── EbPackUnPack_SSE2.h │ ├── EbPictureOperators_Intrinsic_SSE2.c │ ├── EbPictureOperators_SSE2.asm │ ├── EbPictureOperators_SSE2.h │ ├── fwd_txfm_sse2.h │ ├── intrapred_sse2.asm │ ├── inv_txfm_sse2.c │ ├── inv_txfm_sse2.h │ ├── loopfilter_sse2.c │ ├── mem_sse2.h │ ├── subtract_sse2.asm │ ├── transpose_sse2.h │ ├── txfm_common_sse2.h │ ├── vp9_dct_intrin_sse2.c │ ├── vp9_idct_intrin_sse2.c │ ├── x64Macro.asm │ ├── x64RegisterUtil.asm │ ├── x64inc.asm │ └── x86inc.asm │ ├── ASM_SSE4_1 │ ├── CMakeLists.txt │ ├── EbComputeSAD_Intrinsic_SSE4_1.c │ ├── EbComputeSAD_SSE4_1.h │ ├── EbPictureOperators_Intrinsic_SSE4_1.c │ └── EbPictureOperators_SSE4_1.h │ ├── ASM_SSSE3 │ ├── CMakeLists.txt │ ├── EbAvcStyleMcp_SSSE3.h │ ├── EbIntraPrediction_Intrinsic_SSSE3.c │ ├── intrapred_ssse3.asm │ ├── inv_txfm_ssse3.c │ ├── inv_txfm_ssse3.h │ ├── vpx_subpixel_8t_ssse3.asm │ ├── vpx_subpixel_bilinear_ssse3.asm │ └── x86_abi_support.asm │ ├── C_DEFAULT │ ├── CMakeLists.txt │ ├── EbAvcStyleMcp_C.c │ ├── EbAvcStyleMcp_C.h │ ├── EbComputeMean_C.c │ ├── EbComputeMean_C.h │ ├── EbComputeSAD_C.c │ ├── EbComputeSAD_C.h │ ├── EbMeSadCalculation_C.c │ ├── EbMeSadCalculation_C.h │ ├── EbPackUnPack_C.c │ ├── EbPackUnPack_C.h │ ├── EbPictureOperators_C.c │ └── EbPictureOperators_C.h │ ├── Codec │ ├── CMakeLists.txt │ ├── EbApiSei.h │ ├── EbAvcStyleMcp.c │ ├── EbAvcStyleMcp.h │ ├── EbBitstreamUnit.c │ ├── EbBitstreamUnit.h │ ├── EbCodingUnit.c │ ├── EbCodingUnit.h │ ├── EbComputeMean.h │ ├── EbComputeSAD.h │ ├── EbDefinitions.h │ ├── EbEncDecProcess.c │ ├── EbEncDecProcess.h │ ├── EbEncDecResults.c │ ├── EbEncDecResults.h │ ├── EbEncDecSegments.c │ ├── EbEncDecSegments.h │ ├── EbEncDecTasks.c │ ├── EbEncDecTasks.h │ ├── EbEncHandle.c │ ├── EbEncHandle.h │ ├── EbEncodeContext.c │ ├── EbEncodeContext.h │ ├── EbEntropyCoding.c │ ├── EbEntropyCoding.h │ ├── EbEntropyCodingObject.h │ ├── EbEntropyCodingProcess.c │ ├── EbEntropyCodingProcess.h │ ├── EbEntropyCodingResults.c │ ├── EbEntropyCodingResults.h │ ├── EbInitialRateControlProcess.c │ ├── EbInitialRateControlProcess.h │ ├── EbInitialRateControlReorderQueue.c │ ├── EbInitialRateControlReorderQueue.h │ ├── EbInitialRateControlResults.c │ ├── EbInitialRateControlResults.h │ ├── EbIntraPrediction.c │ ├── EbIntraPrediction.h │ ├── EbMcp.c │ ├── EbMcp.h │ ├── EbMeSadCalculation.h │ ├── EbModeDecision.c │ ├── EbModeDecision.h │ ├── EbModeDecisionConfigurationProcess.c │ ├── EbModeDecisionConfigurationProcess.h │ ├── EbModeDecisionProcess.c │ ├── EbMotionEstimation.c │ ├── EbMotionEstimation.h │ ├── EbMotionEstimationContext.c │ ├── EbMotionEstimationContext.h │ ├── EbMotionEstimationLcuResults.h │ ├── EbMotionEstimationProcess.c │ ├── EbMotionEstimationProcess.h │ ├── EbMotionEstimationResults.c │ ├── EbMotionEstimationResults.h │ ├── EbNeighborArrays.c │ ├── EbNeighborArrays.h │ ├── EbPackUnPack.h │ ├── EbPacketizationProcess.c │ ├── EbPacketizationProcess.h │ ├── EbPacketizationReorderQueue.c │ ├── EbPacketizationReorderQueue.h │ ├── EbPictureAnalysisProcess.c │ ├── EbPictureAnalysisProcess.h │ ├── EbPictureAnalysisResults.c │ ├── EbPictureAnalysisResults.h │ ├── EbPictureBufferDesc.c │ ├── EbPictureBufferDesc.h │ ├── EbPictureControlSet.c │ ├── EbPictureControlSet.h │ ├── EbPictureDecisionProcess.c │ ├── EbPictureDecisionProcess.h │ ├── EbPictureDecisionQueue.c │ ├── EbPictureDecisionQueue.h │ ├── EbPictureDecisionReorderQueue.c │ ├── EbPictureDecisionReorderQueue.h │ ├── EbPictureDecisionResults.c │ ├── EbPictureDecisionResults.h │ ├── EbPictureDemuxResults.c │ ├── EbPictureDemuxResults.h │ ├── EbPictureManagerProcess.c │ ├── EbPictureManagerProcess.h │ ├── EbPictureManagerQueue.c │ ├── EbPictureManagerQueue.h │ ├── EbPictureManagerReorderQueue.c │ ├── EbPictureManagerReorderQueue.h │ ├── EbPictureOperators.c │ ├── EbPictureOperators.h │ ├── EbPredictionStructure.c │ ├── EbPredictionStructure.h │ ├── EbRateControlProcess.c │ ├── EbRateControlProcess.h │ ├── EbRateControlResults.c │ ├── EbRateControlResults.h │ ├── EbRateControlTables.c │ ├── EbRateControlTables.h │ ├── EbRateControlTasks.c │ ├── EbRateControlTasks.h │ ├── EbRateDistortionCost.c │ ├── EbRateDistortionCost.h │ ├── EbReferenceObject.c │ ├── EbReferenceObject.h │ ├── EbResourceCoordinationProcess.c │ ├── EbResourceCoordinationProcess.h │ ├── EbResourceCoordinationResults.c │ ├── EbResourceCoordinationResults.h │ ├── EbSei.c │ ├── EbSei.h │ ├── EbSequenceControlSet.c │ ├── EbSequenceControlSet.h │ ├── EbSourceBasedOperationsProcess.c │ ├── EbSourceBasedOperationsProcess.h │ ├── EbSyntaxElements.h │ ├── EbSystemResourceManager.c │ ├── EbSystemResourceManager.h │ ├── EbThreads.c │ ├── EbThreads.h │ ├── EbTime.c │ ├── EbTime.h │ ├── EbTransQuantBuffers.c │ ├── EbTransQuantBuffers.h │ ├── EbUtility.c │ └── EbUtility.h │ ├── VPX │ ├── CMakeLists.txt │ ├── LICENSE │ ├── bitops.h │ ├── bitwriter.c │ ├── bitwriter.h │ ├── bitwriter_buffer.c │ ├── bitwriter_buffer.h │ ├── convolve.h │ ├── fwd_txfm.c │ ├── fwd_txfm.h │ ├── intrapred.c │ ├── inv_txfm.c │ ├── inv_txfm.h │ ├── loopfilter.c │ ├── mem.h │ ├── mem_ops.h │ ├── mem_ops_aligned.h │ ├── prob.c │ ├── prob.h │ ├── psnr.c │ ├── psnr.h │ ├── quantize.c │ ├── subtract.c │ ├── tools_common.h │ ├── txfm_common.h │ ├── vp9_alloccommon.c │ ├── vp9_alloccommon.h │ ├── vp9_bitstream.c │ ├── vp9_bitstream.h │ ├── vp9_block.h │ ├── vp9_blockd.c │ ├── vp9_blockd.h │ ├── vp9_common.h │ ├── vp9_common_data.c │ ├── vp9_common_data.h │ ├── vp9_context_tree.c │ ├── vp9_context_tree.h │ ├── vp9_cost.c │ ├── vp9_cost.h │ ├── vp9_dct.c │ ├── vp9_encodemv.c │ ├── vp9_encodemv.h │ ├── vp9_encoder.c │ ├── vp9_encoder.h │ ├── vp9_entropy.c │ ├── vp9_entropy.h │ ├── vp9_entropymode.c │ ├── vp9_entropymode.h │ ├── vp9_entropymv.c │ ├── vp9_entropymv.h │ ├── vp9_enums.h │ ├── vp9_filter.c │ ├── vp9_filter.h │ ├── vp9_idct.c │ ├── vp9_idct.h │ ├── vp9_loopfilter.c │ ├── vp9_loopfilter.h │ ├── vp9_mv.h │ ├── vp9_mvref_common.c │ ├── vp9_mvref_common.h │ ├── vp9_onyxc_int.h │ ├── vp9_picklpf.c │ ├── vp9_picklpf.h │ ├── vp9_pred_common.c │ ├── vp9_pred_common.h │ ├── vp9_quant_common.c │ ├── vp9_quant_common.h │ ├── vp9_quantize.c │ ├── vp9_quantize.h │ ├── vp9_ratectrl.c │ ├── vp9_ratectrl.h │ ├── vp9_rd.c │ ├── vp9_rd.h │ ├── vp9_rdopt.c │ ├── vp9_rdopt.h │ ├── vp9_reconinter.c │ ├── vp9_reconinter.h │ ├── vp9_reconintra.c │ ├── vp9_reconintra.h │ ├── vp9_rtcd.h │ ├── vp9_scale.c │ ├── vp9_scale.h │ ├── vp9_scan.c │ ├── vp9_scan.h │ ├── vp9_seg_common.c │ ├── vp9_seg_common.h │ ├── vp9_segmentation.c │ ├── vp9_segmentation.h │ ├── vp9_speed_features.h │ ├── vp9_subexp.c │ ├── vp9_subexp.h │ ├── vp9_tile_common.c │ ├── vp9_tile_common.h │ ├── vp9_tokenize.c │ ├── vp9_tokenize.h │ ├── vp9_treewriter.c │ ├── vp9_treewriter.h │ ├── vpx_codec.c │ ├── vpx_codec.h │ ├── vpx_codec_internal.h │ ├── vpx_convolve.c │ ├── vpx_convolve.h │ ├── vpx_dsp_common.h │ ├── vpx_dsp_rtcd.h │ ├── vpx_encoder.h │ ├── vpx_filter.h │ ├── vpx_image.c │ ├── vpx_image.h │ ├── vpx_once.h │ ├── vpxenc.h │ └── yv12config.h │ └── pkg-config.pc.in ├── appveyor.yml ├── ffmpeg_plugin ├── 0001-Add-ability-for-ffmpeg-to-run-svt-vp9.patch ├── README.md ├── master-0001-Add-ability-for-ffmpeg-to-run-svt-vp9.patch ├── n4.2.3-0001-Add-ability-for-ffmpeg-to-run-svt-vp9.patch └── n4.3.1-0001-Add-ability-for-ffmpeg-to-run-svt-vp9.patch └── gstreamer-plugin ├── CMakeLists.txt ├── README.md ├── gstsvtvp9enc.c ├── gstsvtvp9enc.h └── meson.build /.gitignore: -------------------------------------------------------------------------------- 1 | *.265 2 | *.bin 3 | *.yuv 4 | *.user 5 | *.o 6 | *.db 7 | *.sdf 8 | *.suo 9 | *.opendb 10 | *.vs 11 | *.bin 12 | *.opensdf 13 | *.log 14 | *.ivf 15 | *.exe 16 | *.bat 17 | Bin 18 | Build 19 | !Build/linux/build.sh 20 | !Build/windows/build.bat 21 | Source/API/EbApiVersion.h 22 | -------------------------------------------------------------------------------- /Docs/8bit_yuv420p.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenVisualCloud/SVT-VP9/f5039ec08465e21b15131f6bdc97bfa250ded1c9/Docs/8bit_yuv420p.png -------------------------------------------------------------------------------- /NOTICES.md: -------------------------------------------------------------------------------- 1 | # Notices and Disclaimers 2 | 3 | Optimization Notice: Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice. 4 | Notice Revision #20110804 5 | Intel technologies’ features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. No computer system can be absolutely secure. Check with your system manufacturer or retailer. 6 | No license (express or implied, by estoppel or otherwise) to any intellectual property rights is granted by this document except under the terms of the OSI-approved BSD+Patent license. See LICENSE for details. 7 | Intel disclaims all express and implied warranties, including without limitation, the implied warranties of merchantability, fitness for a particular purpose, and non-infringement, as well as any warranty arising from course of performance, course of dealing, or usage in trade. 8 | The products and services described may contain defects or errors known as errata which may cause deviations from published specifications. Current characterized errata are available on request. No product or component can be absolutely secure. 9 | This document contains information on products, services and/or processes in development. All information provided here is subject to change without notice. Contact your Intel representative to obtain the latest forecast, schedule, specifications and roadmaps. 10 | Intel, the Intel logo, Intel Core, Intel Xeon, and others are trademarks of Intel Corporation or its subsidiaries in the U.S. and/or other countries. 11 | *Other names and brands may be claimed as the property of others. 12 | Copyright 2019 Intel Corporation 13 | -------------------------------------------------------------------------------- /Source/API/EbApi.version: -------------------------------------------------------------------------------- 1 | SVT_VP9_0 { 2 | global: 3 | Eb*; 4 | eb*; 5 | local: 6 | *; 7 | }; 8 | -------------------------------------------------------------------------------- /Source/API/EbApiVersion.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbApiVersion_h 7 | #define EbApiVersion_h 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif // __cplusplus 12 | 13 | // API Version 14 | #define SVT_VERSION_MAJOR (@SVT_VP9_VERSION_MAJOR@) 15 | #define SVT_VERSION_MINOR (@SVT_VP9_VERSION_MINOR@) 16 | #define SVT_VERSION_PATCHLEVEL (@SVT_VP9_VERSION_PATCHLEVEL@) 17 | 18 | #define SVT_CHECK_VERSION(major,minor,patch) \ 19 | (SVT_VERSION_MAJOR > (major) || \ 20 | (SVT_VERSION_MAJOR == (major) && SVT_VERSION_MINOR > (minor)) || \ 21 | (SVT_VERSION_MAJOR == (major) && SVT_VERSION_MINOR == (minor) && \ 22 | SVT_VERSION_PATCHLEVEL >= (patch))) 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif // __cplusplus 27 | 28 | #endif // EbApiVersion_h 29 | -------------------------------------------------------------------------------- /Source/API/EbExport_List: -------------------------------------------------------------------------------- 1 | Eb* 2 | eb* 3 | -------------------------------------------------------------------------------- /Source/API/EbSvtVp9ErrorCodes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbSvtVp9ErrorCodes_h 7 | #define EbSvtVp9ErrorCodes_h 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif // __cplusplus 12 | 13 | #define CHECK_REPORT_ERROR(cond, app_callback_ptr, error_code) { if(!(cond)){(app_callback_ptr)->error_handler(((app_callback_ptr)->handle),(error_code));while(1);} } 14 | #define CHECK_REPORT_ERROR_NC(app_callback_ptr, error_code) { {(app_callback_ptr)->error_handler(((app_callback_ptr)->handle),(error_code));while(1);} } 15 | //#define CHECK_REPORT_ERROR(cond, app_callback_ptr, error_code) { (void)app_callback_ptr,(void)error_code; } 16 | //#define CHECK_REPORT_ERROR_NC(app_callback_ptr, error_code) { (void)app_callback_ptr,(void)error_code; } 17 | 18 | typedef enum EncoderErrorCodes 19 | { 20 | 21 | //EB_ENC_PM_ERRORS = 0x0000, 22 | EB_ENC_PM_ERROR0 = 0x0000, 23 | EB_ENC_PM_ERROR1 = 0x0001, 24 | EB_ENC_PM_ERROR2 = 0x0002, 25 | EB_ENC_PM_ERROR3 = 0x0003, 26 | EB_ENC_PM_ERROR4 = 0x0004, 27 | EB_ENC_PM_ERROR5 = 0x0005, 28 | EB_ENC_PM_ERROR6 = 0x0006, 29 | EB_ENC_PM_ERROR7 = 0x0007, 30 | EB_ENC_PM_ERROR8 = 0x0008, 31 | 32 | //EB_ENC_RC_ERRORS = 0x0100 33 | EB_ENC_RC_ERROR0 = 0x0100, 34 | 35 | //EB_ENC_ERRORS = 0x0200, 36 | EB_ENC_ROB_OF_ERROR = 0x0200, 37 | 38 | //EB_ENC_PD_ERRORS = 0x0300, 39 | EB_ENC_PD_ERROR1 = 0x0300, 40 | EB_ENC_PD_ERROR2 = 0x0301, 41 | EB_ENC_PD_ERROR3 = 0x0302, 42 | EB_ENC_PD_ERROR4 = 0x0303, 43 | EB_ENC_PD_ERROR5 = 0x0304, 44 | EB_ENC_PD_ERROR6 = 0x0306, 45 | EB_ENC_PD_ERROR7 = 0x0307, 46 | 47 | } EncoderErrorCodes; 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif // __cplusplus 52 | 53 | #endif // EbSvtVp9ErrorCodes_h 54 | -------------------------------------------------------------------------------- /Source/App/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ~~~ 2 | # Copyright(c) 2019 Intel Corporation 3 | # SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | # ~~~ 5 | 6 | # APP Directory CMakeLists.txt 7 | 8 | # Include Subdirectories 9 | include_directories(${PROJECT_SOURCE_DIR}/Source/API 10 | ${PROJECT_SOURCE_DIR}/Bin/${CMAKE_BUILD_TYPE}) 11 | 12 | file(GLOB 13 | all_files 14 | "*.h" 15 | "../API/*.h" 16 | "../../Config/*.cfg" 17 | "*.c" 18 | "*.asm") 19 | 20 | # App Source Files 21 | add_executable(SvtVp9EncApp ${all_files}) 22 | 23 | # ********** SET COMPILE FLAGS************ 24 | 25 | # Link the Encoder App 26 | target_link_libraries(SvtVp9EncApp SvtVp9Enc) 27 | 28 | if(UNIX) 29 | target_link_libraries(SvtVp9EncApp pthread) 30 | if(NOT APPLE) 31 | target_link_libraries(SvtVp9EncApp rt m) # math library 32 | endif() 33 | endif() 34 | 35 | install(TARGETS SvtVp9EncApp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) 36 | -------------------------------------------------------------------------------- /Source/App/EbAppContext.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbAppContext_h 7 | #define EbAppContext_h 8 | 9 | #include "EbSvtVp9Enc.h" 10 | #include "EbAppConfig.h" 11 | 12 | /*************************************** 13 | 14 | * App Callback data struct 15 | ***************************************/ 16 | typedef struct EbAppContext_s 17 | { 18 | EbSvtVp9EncConfiguration eb_enc_parameters; 19 | 20 | // Output Ports Active Flags 21 | AppPortActiveType output_stream_port_active; 22 | 23 | // Component Handle 24 | EbComponentType* svt_encoder_handle; 25 | 26 | // Buffer Pools 27 | EbBufferHeaderType *input_buffer_pool; 28 | EbBufferHeaderType *recon_buffer; 29 | 30 | // Instance Index 31 | uint8_t instance_idx; 32 | 33 | } EbAppContext; 34 | 35 | /******************************** 36 | * External Function 37 | ********************************/ 38 | extern EbErrorType init_encoder( 39 | EbConfig *config, 40 | EbAppContext *callback_data, 41 | uint32_t instance_idx); 42 | 43 | extern EbErrorType de_init_encoder( 44 | EbAppContext *callback_data_ptr, 45 | uint32_t instance_index); 46 | 47 | #endif // EbAppContext_h 48 | -------------------------------------------------------------------------------- /Source/App/EbAppTime.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifdef _WIN32 7 | #include 8 | #include 9 | #elif !defined(__USE_POSIX199309) 10 | #define __USE_POSIX199309 11 | #endif 12 | 13 | #include 14 | 15 | #if !defined(CLOCK_MONOTONIC) && !defined(_WIN32) 16 | #include 17 | #endif 18 | 19 | #include "EbAppTime.h" 20 | 21 | void app_svt_vp9_sleep(const unsigned milliseconds) { 22 | if (!milliseconds) return; 23 | #ifdef _WIN32 24 | Sleep(milliseconds); 25 | #else 26 | nanosleep(&(struct timespec){milliseconds / 1000, 27 | (milliseconds % 1000) * 1000000}, 28 | NULL); 29 | #endif 30 | } 31 | 32 | double app_svt_vp9_compute_overall_elapsed_time( 33 | const uint64_t start_seconds, const uint64_t start_useconds, 34 | const uint64_t finish_seconds, const uint64_t finish_useconds) { 35 | const int64_t s_diff = (int64_t)finish_seconds - (int64_t)start_seconds, 36 | u_diff = (int64_t)finish_useconds - (int64_t)start_useconds; 37 | return ((double)s_diff * 1000.0 + (double)u_diff / 1000.0 + 0.5) / 1000.0; 38 | } 39 | 40 | void app_svt_vp9_get_time(uint64_t *const seconds, uint64_t *const useconds) { 41 | #ifdef _WIN32 42 | struct _timeb curr_time; 43 | _ftime_s(&curr_time); 44 | *seconds = curr_time.time; 45 | *useconds = curr_time.millitm; 46 | #elif defined(CLOCK_MONOTONIC) 47 | struct timespec curr_time; 48 | clock_gettime(CLOCK_MONOTONIC, &curr_time); 49 | *seconds = (uint64_t)curr_time.tv_sec; 50 | *useconds = (uint64_t)curr_time.tv_nsec / 1000UL; 51 | #else 52 | struct timeval curr_time; 53 | gettimeofday(&curr_time, NULL); 54 | *seconds = curr_time.tv_sec; 55 | *useconds = curr_time.tv_usec; 56 | #endif 57 | } 58 | -------------------------------------------------------------------------------- /Source/App/EbAppTime.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbAppTime_h 7 | #define EbAppTime_h 8 | 9 | #include 10 | 11 | void app_svt_vp9_sleep(const unsigned milliseconds); 12 | double app_svt_vp9_compute_overall_elapsed_time(const uint64_t start_seconds, 13 | const uint64_t start_useconds, 14 | const uint64_t finish_seconds, 15 | const uint64_t finish_useconds); 16 | void app_svt_vp9_get_time(uint64_t *const seconds, uint64_t *const useconds); 17 | 18 | #endif // EbAppTime_h 19 | -------------------------------------------------------------------------------- /Source/Lib/ASM_AVX2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ~~~ 2 | # Copyright(c) 2019 Intel Corporation 3 | # SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | # ~~~ 5 | 6 | # ASM_AVX2 Directory CMakeLists.txt 7 | 8 | # Include Encoder Subdirectories 9 | include_directories(${PROJECT_SOURCE_DIR}/Source/API 10 | ${PROJECT_SOURCE_DIR}/Source/Lib/Codec 11 | ${PROJECT_SOURCE_DIR}/Source/Lib/C_DEFAULT 12 | ${PROJECT_SOURCE_DIR}/Source/Lib/ASM_SSE2 13 | ${PROJECT_SOURCE_DIR}/Source/Lib/ASM_SSSE3 14 | ${PROJECT_SOURCE_DIR}/Source/Lib/ASM_SSE4_1 15 | ${PROJECT_SOURCE_DIR}/Source/Lib/ASM_AVX2 16 | ${PROJECT_SOURCE_DIR}/Source/Lib/VPX) 17 | 18 | set(flags_to_test -mavx2) 19 | 20 | if(CMAKE_C_COMPILER_ID STREQUAL "Intel") 21 | if(WIN32) 22 | # Intel Windows (*Note - The Warning level /W0 should be made to /W4 at 23 | # some point) 24 | list(APPEND flags_to_test /Qdiag-disable:10010,10148,10157 /W0) 25 | else() 26 | list(APPEND flags_to_test -static-intel -w) 27 | endif() 28 | endif() 29 | 30 | if(MSVC) 31 | list(APPEND flags_to_test /arch:AVX2) 32 | endif() 33 | 34 | test_apply_compiler_flags(${flags_to_test}) 35 | 36 | file(GLOB 37 | all_files 38 | "*.h" 39 | "*.c" 40 | "*.asm") 41 | 42 | add_library(VP9_ASM_AVX2 OBJECT ${all_files}) 43 | -------------------------------------------------------------------------------- /Source/Lib/ASM_AVX2/EbAvcStyleMcp_AVX2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EBAVCSTYLEMCP_AVX2_H 7 | #define EBAVCSTYLEMCP_AVX2_H 8 | 9 | #include "EbDefinitions.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | void eb_vp9_avc_style_luma_interpolation_filter_horizontal_avx2_intrin( 16 | EbByte ref_pic, 17 | uint32_t src_stride, 18 | EbByte dst, 19 | uint32_t dst_stride, 20 | uint32_t pu_width, 21 | uint32_t pu_height, 22 | EbByte temp_buf, 23 | uint32_t frac_pos); 24 | 25 | void eb_vp9_avc_style_luma_interpolation_filter_vertical_avx2_intrin( 26 | EbByte ref_pic, 27 | uint32_t src_stride, 28 | EbByte dst, 29 | uint32_t dst_stride, 30 | uint32_t pu_width, 31 | uint32_t pu_height, 32 | EbByte temp_buf, 33 | uint32_t frac_pos); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | #endif // EBAVCSTYLEMCP_AVX2_H 39 | -------------------------------------------------------------------------------- /Source/Lib/ASM_AVX2/EbCombinedAveragingSAD_Intrinsic_AVX2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbCombinedAveragingSAD_AVX2_h 7 | #define EbCombinedAveragingSAD_AVX2_h 8 | 9 | #include "EbDefinitions.h" 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | uint32_t eb_vp9_combined_averaging8x_msad_avx2_intrin( 15 | uint8_t *src, 16 | uint32_t src_stride, 17 | uint8_t *ref1, 18 | uint32_t ref1_stride, 19 | uint8_t *ref2, 20 | uint32_t ref2_stride, 21 | uint32_t height, 22 | uint32_t width); 23 | 24 | uint32_t eb_vp9_combined_averaging16x_msad_avx2_intrin( 25 | uint8_t *src, 26 | uint32_t src_stride, 27 | uint8_t *ref1, 28 | uint32_t ref1_stride, 29 | uint8_t *ref2, 30 | uint32_t ref2_stride, 31 | uint32_t height, 32 | uint32_t width); 33 | 34 | uint32_t eb_vp9_combined_averaging24x_msad_avx2_intrin( 35 | uint8_t *src, 36 | uint32_t src_stride, 37 | uint8_t *ref1, 38 | uint32_t ref1_stride, 39 | uint8_t *ref2, 40 | uint32_t ref2_stride, 41 | uint32_t height, 42 | uint32_t width); 43 | 44 | uint32_t eb_vp9_combined_averaging32x_msad_avx2_intrin( 45 | uint8_t *src, 46 | uint32_t src_stride, 47 | uint8_t *ref1, 48 | uint32_t ref1_stride, 49 | uint8_t *ref2, 50 | uint32_t ref2_stride, 51 | uint32_t height, 52 | uint32_t width); 53 | 54 | uint32_t eb_vp9_combined_averaging48x_msad_avx2_intrin( 55 | uint8_t *src, 56 | uint32_t src_stride, 57 | uint8_t *ref1, 58 | uint32_t ref1_stride, 59 | uint8_t *ref2, 60 | uint32_t ref2_stride, 61 | uint32_t height, 62 | uint32_t width); 63 | 64 | uint32_t eb_vp9_combined_averaging64x_msad_avx2_intrin( 65 | uint8_t *src, 66 | uint32_t src_stride, 67 | uint8_t *ref1, 68 | uint32_t ref1_stride, 69 | uint8_t *ref2, 70 | uint32_t ref2_stride, 71 | uint32_t height, 72 | uint32_t width); 73 | 74 | uint64_t eb_vp9_compute_mean8x8_avx2_intrin( 75 | uint8_t *input_samples, // input parameter, input samples Ptr 76 | uint32_t input_stride, // input parameter, input stride 77 | uint32_t input_area_width, // input parameter, input area width 78 | uint32_t input_area_height); 79 | 80 | void eb_vp9_compute_interm_var_four8x8_avx2_intrin( 81 | uint8_t *input_samples, 82 | uint16_t input_stride, 83 | uint64_t *mean_of8x8_blocks, // mean of four 8x8 84 | uint64_t *mean_of_squared8x8_blocks); 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | #endif 90 | -------------------------------------------------------------------------------- /Source/Lib/ASM_AVX2/EbCombinedAveragingSAD_Intrinsic_AVX512.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbCombinedAveragingSAD_AVX512_h 7 | #define EbCombinedAveragingSAD_AVX512_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbDefinitions.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | uint64_t eb_vp9_compute_mean8x8_avx2_intrin( 17 | uint8_t *input_samples, // input parameter, input samples Ptr 18 | uint32_t input_stride, // input parameter, input stride 19 | uint32_t input_area_width, // input parameter, input area width 20 | uint32_t input_area_height); 21 | 22 | void eb_vp9_compute_interm_var_four8x8_avx2_intrin( 23 | uint8_t *input_samples, 24 | uint16_t input_stride, 25 | uint64_t *mean_of8x8_blocks, // mean of four 8x8 26 | uint64_t *mean_of_squared8x8_blocks); 27 | 28 | #ifndef DISABLE_AVX512 29 | void bi_pred_average_kernel_avx512_intrin( 30 | EbByte src0, 31 | uint32_t src0_stride, 32 | EbByte src1, 33 | uint32_t src1_stride, 34 | EbByte dst, 35 | uint32_t dst_stride, 36 | uint32_t area_width, 37 | uint32_t area_height); 38 | #else 39 | void bi_pred_average_kernel_avx2_intrin( 40 | EbByte src0, 41 | uint32_t src0_stride, 42 | EbByte src1, 43 | uint32_t src1_stride, 44 | EbByte dst, 45 | uint32_t dst_stride, 46 | uint32_t area_width, 47 | uint32_t area_height); 48 | #endif 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | #endif 54 | -------------------------------------------------------------------------------- /Source/Lib/ASM_AVX2/EbComputeSAD_SadLoopKernel_AVX512.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbComputeSAD_AVX512_h 7 | #define EbComputeSAD_AVX512_h 8 | 9 | #include "EbComputeSAD_AVX2.h" 10 | #include "EbMotionEstimation.h" 11 | #include "EbDefinitions.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | #ifndef DISABLE_AVX512 17 | void eb_vp9_sad_loop_kernel_avx512_hme_l0_intrin( 18 | uint8_t *src, // input parameter, source samples Ptr 19 | uint32_t src_stride, // input parameter, source stride 20 | uint8_t *ref, // input parameter, reference samples Ptr 21 | uint32_t ref_stride, // input parameter, reference stride 22 | uint32_t height, // input parameter, block height (M) 23 | uint32_t width, // input parameter, block width (N) 24 | uint64_t *best_sad, 25 | int16_t *x_search_center, 26 | int16_t *y_search_center, 27 | uint32_t src_stride_raw, // input parameter, source stride (no line skipping) 28 | int16_t search_area_width, 29 | int16_t search_area_height); 30 | #else 31 | void eb_vp9_sad_loop_kernel_avx2_hme_l0_intrin( 32 | uint8_t *src, // input parameter, source samples Ptr 33 | uint32_t src_stride, // input parameter, source stride 34 | uint8_t *ref, // input parameter, reference samples Ptr 35 | uint32_t ref_stride, // input parameter, reference stride 36 | uint32_t height, // input parameter, block height (M) 37 | uint32_t width, // input parameter, block width (N) 38 | uint64_t *best_sad, 39 | int16_t *x_search_center, 40 | int16_t *y_search_center, 41 | uint32_t src_stride_raw, // input parameter, source stride (no line skipping) 42 | int16_t search_area_width, 43 | int16_t search_area_height); 44 | #endif 45 | 46 | #ifndef DISABLE_AVX512 47 | extern void eb_vp9_get_eight_horizontal_search_point_results_all85_p_us_avx512_intrin( 48 | MeContext *context_ptr, 49 | uint32_t list_index, 50 | uint32_t search_region_index, 51 | uint32_t x_search_index, 52 | uint32_t y_search_index 53 | ); 54 | #endif 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | #endif // EbComputeSAD_AVX512_h 60 | -------------------------------------------------------------------------------- /Source/Lib/ASM_AVX2/EbNoiseExtractAVX2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbNoiseExtractAVX2_h 7 | #define EbNoiseExtractAVX2_h 8 | 9 | #include "immintrin.h" 10 | #include "EbDefinitions.h" 11 | #include "EbPictureBufferDesc.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /******************************************* 17 | * eb_vp9_noise_extract_luma_weak 18 | * weak filter Luma and store noise. 19 | *******************************************/ 20 | void eb_vp9_noise_extract_luma_weak_avx2_intrin( 21 | EbPictureBufferDesc *input_picture_ptr, 22 | EbPictureBufferDesc *denoised_picture_ptr, 23 | EbPictureBufferDesc *noise_picture_ptr, 24 | uint32_t sb_origin_y, 25 | uint32_t sb_origin_x 26 | ); 27 | 28 | void eb_vp9_noise_extract_luma_weak_sb_avx2_intrin( 29 | EbPictureBufferDesc *input_picture_ptr, 30 | EbPictureBufferDesc *denoised_picture_ptr, 31 | EbPictureBufferDesc *noise_picture_ptr, 32 | uint32_t sb_origin_y, 33 | uint32_t sb_origin_x 34 | ); 35 | 36 | void eb_vp9_noise_extract_chroma_strong_avx2_intrin( 37 | EbPictureBufferDesc *input_picture_ptr, 38 | EbPictureBufferDesc *denoised_picture_ptr, 39 | uint32_t sb_origin_y, 40 | uint32_t sb_origin_x); 41 | 42 | void eb_vp9_noise_extract_chroma_weak_avx2_intrin( 43 | EbPictureBufferDesc *input_picture_ptr, 44 | EbPictureBufferDesc *denoised_picture_ptr, 45 | uint32_t sb_origin_y, 46 | uint32_t sb_origin_x); 47 | 48 | void eb_vp9_noise_extract_luma_strong_avx2_intrin( 49 | EbPictureBufferDesc *input_picture_ptr, 50 | EbPictureBufferDesc *denoised_picture_ptr, 51 | uint32_t sb_origin_y, 52 | uint32_t sb_origin_x); 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | #endif // EbNoiseExtractAVX2_h 58 | -------------------------------------------------------------------------------- /Source/Lib/ASM_AVX2/EbPackUnPack_Intrinsic_AVX2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbPackUnPack_AVX2_h 7 | #define EbPackUnPack_AVX2_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbDefinitions.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | #ifndef DISABLE_AVX512 17 | void eb_enc_msb_un_pack2_d_avx512_intrin( 18 | uint16_t *in16_bit_buffer, 19 | uint32_t in_stride, 20 | uint8_t *out8_bit_buffer, 21 | uint8_t *outn_bit_buffer, 22 | uint32_t out8_stride, 23 | uint32_t outn_stride, 24 | uint32_t width, 25 | uint32_t height); 26 | #else 27 | void eb_enc_msb_un_pack2_d_sse2_intrin( 28 | uint16_t *in16_bit_buffer, 29 | uint32_t in_stride, 30 | uint8_t *out8_bit_buffer, 31 | uint8_t *outn_bit_buffer, 32 | uint32_t out8_stride, 33 | uint32_t outn_stride, 34 | uint32_t width, 35 | uint32_t height); 36 | #endif 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif // EbPackUnPack_AVX2_h 43 | -------------------------------------------------------------------------------- /Source/Lib/ASM_AVX2/EbTransforms_AVX2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbTransforms_AVX2_h 7 | #define EbTransforms_AVX2_h 8 | 9 | #include "immintrin.h" 10 | 11 | #include "EbDefinitions.h" 12 | #include "vpx_dsp_rtcd.h" 13 | #include "txfm_common.h" 14 | #include "EbMemory_AVX2.h" 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | static INLINE __m256i dct_const_round_shift_avx2(const __m256i in) { 20 | const __m256i t = 21 | _mm256_add_epi32(in, _mm256_set1_epi32(DCT_CONST_ROUNDING)); 22 | return _mm256_srai_epi32(t, DCT_CONST_BITS); 23 | } 24 | 25 | static INLINE __m256i idct_madd_round_shift_avx2(const __m256i in, 26 | const __m256i cospi) { 27 | const __m256i t = _mm256_madd_epi16(in, cospi); 28 | return dct_const_round_shift_avx2(t); 29 | } 30 | 31 | // Calculate the dot product between in0/1 and x and wrap to short. 32 | static INLINE __m256i idct_calc_wraplow_avx2(const __m256i in0, 33 | const __m256i in1, const __m256i x) { 34 | const __m256i t0 = idct_madd_round_shift_avx2(in0, x); 35 | const __m256i t1 = idct_madd_round_shift_avx2(in1, x); 36 | return _mm256_packs_epi32(t0, t1); 37 | } 38 | 39 | // Multiply elements by constants and add them together. 40 | static INLINE void butterfly_avx2(const __m256i in0, const __m256i in1, 41 | const int c0, const int c1, __m256i *const out0, 42 | __m256i *const out1) { 43 | const __m256i cst0 = pair_set_epi16_avx2(c0, -c1); 44 | const __m256i cst1 = pair_set_epi16_avx2(c1, c0); 45 | const __m256i lo = _mm256_unpacklo_epi16(in0, in1); 46 | const __m256i hi = _mm256_unpackhi_epi16(in0, in1); 47 | *out0 = idct_calc_wraplow_avx2(lo, hi, cst0); 48 | *out1 = idct_calc_wraplow_avx2(lo, hi, cst1); 49 | } 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | #endif // EbTransforms_AVX2_h 55 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ~~~ 2 | # Copyright(c) 2019 Intel Corporation 3 | # SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | # ~~~ 5 | 6 | # ASM_SSE2 Directory CMakeLists.txt 7 | 8 | # Include Encoder Subdirectories 9 | include_directories(${PROJECT_SOURCE_DIR}/Source/API 10 | ${PROJECT_SOURCE_DIR}/Source/Lib/Codec 11 | ${PROJECT_SOURCE_DIR}/Source/Lib/C_DEFAULT 12 | ${PROJECT_SOURCE_DIR}/Source/Lib/ASM_SSE2 13 | ${PROJECT_SOURCE_DIR}/Source/Lib/VPX) 14 | 15 | set(flags_to_test -msse2) 16 | 17 | if(CMAKE_C_COMPILER_ID STREQUAL "Intel" AND NOT WIN32) 18 | list(APPEND flags_to_test -static-intel -w) 19 | endif() 20 | 21 | test_apply_compiler_flags(${flags_to_test}) 22 | 23 | file(GLOB 24 | all_files 25 | "*.h" 26 | "*.c" 27 | "*.asm") 28 | 29 | add_library(VP9_ASM_SSE2 OBJECT ${all_files}) 30 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE2/EbAvcStyleMcp_Intrinsic_SSE2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include "EbAvcStyleMcp_SSE2.h" 7 | #include "EbMcp_SSE2.h" // THIS SHOULD BE _SSE2 in the future 8 | 9 | void eb_vp9_avc_style_copy_sse2( 10 | EbByte ref_pic, 11 | uint32_t src_stride, 12 | EbByte dst, 13 | uint32_t dst_stride, 14 | uint32_t pu_width, 15 | uint32_t pu_height, 16 | EbByte temp_buf, 17 | uint32_t frac_pos) 18 | { 19 | (void)temp_buf; 20 | (void)frac_pos; 21 | 22 | eb_vp9_picture_copy_kernel_sse2(ref_pic, src_stride, dst, dst_stride, pu_width, pu_height); 23 | } 24 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE2/EbAvcStyleMcp_SSE2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EBAVCSTYLEMCP_SSE2_H 7 | #define EBAVCSTYLEMCP_SSE2_H 8 | 9 | #include "EbDefinitions.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | void eb_vp9_avc_style_copy_sse2( 16 | EbByte ref_pic, 17 | uint32_t src_stride, 18 | EbByte dst, 19 | uint32_t dst_stride, 20 | uint32_t pu_width, 21 | uint32_t pu_height, 22 | EbByte temp_buf, 23 | uint32_t frac_pos); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | #endif //EBAVCSTYLEMCP_H 29 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE2/EbCombinedAveragingSAD_Intrinsic_SSE2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include "stdint.h" 7 | #include "emmintrin.h" 8 | #include "EbComputeSAD_SSE2.h" 9 | 10 | uint32_t eb_vp9_combined_averaging4x_msad_sse2_intrin( 11 | uint8_t *src, 12 | uint32_t src_stride, 13 | uint8_t *ref1, 14 | uint32_t ref1_stride, 15 | uint8_t *ref2, 16 | uint32_t ref2_stride, 17 | uint32_t height, 18 | uint32_t width) 19 | { 20 | __m128i sad0,sad1; 21 | uint32_t y; 22 | (void)width; 23 | sad0 = sad1 = _mm_setzero_si128(); 24 | 25 | for (y = 0; y < height; y+=2) { 26 | 27 | sad0 = _mm_add_epi32(sad0, _mm_sad_epu8(_mm_cvtsi32_si128(*(uint32_t *)src), _mm_avg_epu8(_mm_cvtsi32_si128(*(uint32_t *)ref1), _mm_cvtsi32_si128(*(uint32_t *)ref2)))); 28 | 29 | sad1 = _mm_add_epi32(sad1, _mm_sad_epu8(_mm_cvtsi32_si128(*(uint32_t *)(src+src_stride)), _mm_avg_epu8(_mm_cvtsi32_si128(*(uint32_t *)(ref1+ref1_stride)), _mm_cvtsi32_si128(*(uint32_t *)(ref2+ref2_stride))))); 30 | src += src_stride << 1; 31 | ref1 += ref1_stride << 1; 32 | ref2 += ref2_stride << 1; 33 | } 34 | return _mm_cvtsi128_si32(_mm_add_epi32(sad0, sad1)); 35 | } 36 | 37 | uint32_t eb_vp9_combined_averaging8x_msad_sse2_intrin( 38 | uint8_t *src, 39 | uint32_t src_stride, 40 | uint8_t *ref1, 41 | uint32_t ref1_stride, 42 | uint8_t *ref2, 43 | uint32_t ref2_stride, 44 | uint32_t height, 45 | uint32_t width) 46 | { 47 | __m128i sad0, sad1; 48 | uint32_t y; 49 | (void)width; 50 | 51 | sad0 = sad1 = _mm_setzero_si128(); 52 | 53 | for (y = 0; y < height; y += 2) { 54 | 55 | sad0 = _mm_add_epi32(sad0, _mm_sad_epu8(_mm_loadl_epi64((__m128i*)src), _mm_avg_epu8(_mm_loadl_epi64((__m128i*)ref1), _mm_loadl_epi64((__m128i*)ref2)))); 56 | sad1 = _mm_add_epi32(sad1, _mm_sad_epu8(_mm_loadl_epi64((__m128i*)(src + src_stride)), _mm_avg_epu8(_mm_loadl_epi64((__m128i*)(ref1 + ref1_stride)), _mm_loadl_epi64((__m128i*)(ref2 + ref2_stride))))); 57 | src += src_stride << 1; 58 | ref1 += ref1_stride << 1; 59 | ref2 += ref2_stride << 1; 60 | 61 | } 62 | return _mm_cvtsi128_si32(_mm_add_epi32(sad0, sad1)); 63 | } 64 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE2/EbComputeMean_SSE2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbComputeMean_SS2_h 7 | #define EbComputeMean_SS2_h 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | #include "EbDefinitions.h" 13 | 14 | uint64_t eb_vp9_compute_sub_mean8x8_sse2_intrin( 15 | uint8_t * input_samples, // input parameter, input samples Ptr 16 | uint16_t input_stride); 17 | 18 | uint64_t eb_vp9_compute_subd_mean_of_squared_values8x8_sse2_intrin( 19 | uint8_t * input_samples, // input parameter, input samples Ptr 20 | uint16_t input_stride); 21 | 22 | uint64_t eb_vp9_compute_mean_of_squared_values8x8_sse2_intrin( 23 | uint8_t * input_samples, // input parameter, input samples Ptr 24 | uint32_t input_stride, // input parameter, input stride 25 | uint32_t input_area_width, // input parameter, input area width 26 | uint32_t input_area_height); // input parameter, input area height 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE2/EbComputeSAD_SSE2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbComputeSAD_SSE2_h 7 | #define EbComputeSAD_SSE2_h 8 | 9 | #include "EbDefinitions.h" 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | extern uint32_t eb_vp9_combined_averaging4x_msad_sse2_intrin( 15 | uint8_t *src, 16 | uint32_t src_stride, 17 | uint8_t *ref1, 18 | uint32_t ref1_stride, 19 | uint8_t *ref2, 20 | uint32_t ref2_stride, 21 | uint32_t height, 22 | uint32_t width); 23 | 24 | extern uint32_t eb_vp9_combined_averaging8x_msad_sse2_intrin( 25 | uint8_t *src, 26 | uint32_t src_stride, 27 | uint8_t *ref1, 28 | uint32_t ref1_stride, 29 | uint8_t *ref2, 30 | uint32_t ref2_stride, 31 | uint32_t height, 32 | uint32_t width); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | #endif // EbComputeSAD_SSE2_h 38 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE2/EbIntrinMacros16bit_SSE2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #define MACRO_VERTICAL_LUMA_8(ARG1, ARG2, ARG3)\ 7 | _mm_storeu_si128((__m128i *)prediction_ptr, _mm_or_si128(_mm_and_si128(ARG1, ARG2), ARG3));\ 8 | ARG1 = _mm_srli_si128(ARG1, 2);\ 9 | _mm_storeu_si128((__m128i *)(prediction_ptr + pStride), _mm_or_si128(_mm_and_si128(ARG1, ARG2), ARG3));\ 10 | ARG1 = _mm_srli_si128(ARG1, 2);\ 11 | _mm_storeu_si128((__m128i *)(prediction_ptr + 2 * pStride), _mm_or_si128(_mm_and_si128(ARG1, ARG2), ARG3));\ 12 | ARG1 = _mm_srli_si128(ARG1, 2);\ 13 | _mm_storeu_si128((__m128i *)(prediction_ptr + 3 * pStride), _mm_or_si128(_mm_and_si128(ARG1, ARG2), ARG3));\ 14 | ARG1 = _mm_srli_si128(ARG1, 2); 15 | 16 | #define MACRO_UNPACK(ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7, ARG8, ARG9, ARG10, ARG11, ARG12, ARG13)\ 17 | ARG10 = _mm_unpackhi_epi##ARG1(ARG2, ARG3);\ 18 | ARG2 = _mm_unpacklo_epi##ARG1(ARG2, ARG3);\ 19 | ARG11 = _mm_unpackhi_epi##ARG1(ARG4, ARG5);\ 20 | ARG4 = _mm_unpacklo_epi##ARG1(ARG4, ARG5);\ 21 | ARG12 = _mm_unpackhi_epi##ARG1(ARG6, ARG7);\ 22 | ARG6 = _mm_unpacklo_epi##ARG1(ARG6, ARG7);\ 23 | ARG13 = _mm_unpackhi_epi##ARG1(ARG8, ARG9);\ 24 | ARG8 = _mm_unpacklo_epi##ARG1(ARG8, ARG9); 25 | 26 | #define MACRO_UNPACK_V2(ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7, ARG8, ARG9, ARG10, ARG11)\ 27 | ARG10 = _mm_unpackhi_epi##ARG1(ARG2, ARG3);\ 28 | ARG2 = _mm_unpacklo_epi##ARG1(ARG2, ARG3);\ 29 | ARG11 = _mm_unpackhi_epi##ARG1(ARG4, ARG5);\ 30 | ARG4 = _mm_unpacklo_epi##ARG1(ARG4, ARG5);\ 31 | ARG6 = _mm_unpacklo_epi##ARG1(ARG6, ARG7);\ 32 | ARG8 = _mm_unpacklo_epi##ARG1(ARG8, ARG9); 33 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE2/EbIntrinMacros_SSE2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #define MACRO_VERTICAL_LUMA_8(A, B, C)\ 7 | _mm_storel_epi64((__m128i*)prediction_ptr, _mm_or_si128(_mm_and_si128(A, B), C)); \ 8 | A = _mm_srli_si128(A, 1); \ 9 | _mm_storel_epi64((__m128i*)(prediction_ptr + pStride), _mm_or_si128(_mm_and_si128(A, B), C)); \ 10 | A = _mm_srli_si128(A, 1); \ 11 | _mm_storel_epi64((__m128i*)(prediction_ptr + 2*pStride), _mm_or_si128(_mm_and_si128(A, B), C)); \ 12 | A = _mm_srli_si128(A, 1); \ 13 | _mm_storel_epi64((__m128i*)(prediction_ptr + 3*pStride), _mm_or_si128(_mm_and_si128(A, B), C)); \ 14 | A = _mm_srli_si128(A, 1); 15 | 16 | #define MACRO_VERTICAL_LUMA_16(A, B, C)\ 17 | _mm_storeu_si128((__m128i*)prediction_ptr, _mm_or_si128(_mm_and_si128(A, B), C)); \ 18 | A = _mm_srli_si128(A, 1); \ 19 | _mm_storeu_si128((__m128i*)(prediction_ptr + pStride), _mm_or_si128(_mm_and_si128(A, B), C)); \ 20 | A = _mm_srli_si128(A, 1); \ 21 | _mm_storeu_si128((__m128i*)(prediction_ptr + 2*pStride), _mm_or_si128(_mm_and_si128(A, B), C)); \ 22 | A = _mm_srli_si128(A, 1); \ 23 | _mm_storeu_si128((__m128i*)(prediction_ptr + 3*pStride), _mm_or_si128(_mm_and_si128(A, B), C)); \ 24 | A = _mm_srli_si128(A, 1); 25 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE2/EbMcp_SSE2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EBMCP_SSE2_H 7 | #define EBMCP_SSE2_H 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbDefinitions.h" 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | /************************************************** 15 | * Assembly Declarations 16 | **************************************************/ 17 | extern void eb_vp9_picture_copy_kernel_sse2( 18 | EbByte src, 19 | uint32_t src_stride, 20 | EbByte dst, 21 | uint32_t dst_stride, 22 | uint32_t area_width, 23 | uint32_t area_height); 24 | 25 | void eb_vp9_picture_average_kernel_sse2( 26 | EbByte src0, 27 | uint32_t src0_stride, 28 | EbByte src1, 29 | uint32_t src1_stride, 30 | EbByte dst, 31 | uint32_t dst_stride, 32 | uint32_t area_width, 33 | uint32_t area_height); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | #endif //EBMCP_SSE2_H 39 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE2/EbMeSadCalculation_SSE2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbMeSadCalculation_asm_h 7 | #define EbMeSadCalculation_asm_h 8 | 9 | #include "EbDefinitions.h" 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | extern void eb_vp9_initialize_buffer_32bits_sse2_intrin( 15 | uint32_t *pointer, 16 | uint32_t count128, 17 | uint32_t count32, 18 | uint32_t value); 19 | 20 | void eb_vp9_sad_calculation_8x8_16x16_sse2_intrin( 21 | uint8_t *src, 22 | uint32_t src_stride, 23 | uint8_t *ref, 24 | uint32_t ref_stride, 25 | uint32_t *p_best_sad8x8, 26 | uint32_t *p_best_sad16x16, 27 | uint32_t *p_best_mv8x8, 28 | uint32_t *p_best_mv16x16, 29 | uint32_t mv, 30 | uint32_t *p_sad16x16); 31 | 32 | void eb_vp9_sad_calculation_32x32_64x64_sse2_intrin( 33 | uint32_t *p_sad16x16, 34 | uint32_t *p_best_sad32x32, 35 | uint32_t *p_best_sad64x64, 36 | uint32_t *p_best_mv32x32, 37 | uint32_t *p_best_mv64x64, 38 | uint32_t mv); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | #endif // EbMeSadCalculation_asm_h 44 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE2/EbPackUnPack_SSE2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbPackUnPack_asm_h 7 | #define EbPackUnPack_asm_h 8 | 9 | #include "EbDefinitions.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | void eb_enc_un_pack8_bit_data_sse2_intrin( 16 | uint16_t *in16_bit_buffer, 17 | uint32_t in_stride, 18 | uint8_t *out8_bit_buffer, 19 | uint32_t out8_stride, 20 | uint32_t width, 21 | uint32_t height); 22 | 23 | void eb_enc_un_pack8_bit_data_safe_sub_sse2_intrin( 24 | uint16_t *in16_bit_buffer, 25 | uint32_t in_stride, 26 | uint8_t *out8_bit_buffer, 27 | uint32_t out8_stride, 28 | uint32_t width, 29 | uint32_t height); 30 | 31 | void eb_vp9_unpack_avg_sse2_intrin( 32 | uint16_t *ref16_l0, 33 | uint32_t ref_l0_stride, 34 | uint16_t *ref16_l1, 35 | uint32_t ref_l1_stride, 36 | uint8_t *dst_ptr, 37 | uint32_t dst_stride, 38 | uint32_t width, 39 | uint32_t height); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | #endif // EbPackUnPack_asm_h 45 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE2/x64Macro.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright(c) 2018 Intel Corporation 3 | ; SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | ; 5 | 6 | %macro MACRO_INIT_MMX 3 7 | mov %2, %3 8 | movq %1, %2 9 | %endmacro 10 | 11 | %macro MACRO_INIT_XMM 3 12 | mov %2, %3 13 | movq %1, %2 14 | punpcklqdq %1, %1 15 | %endmacro 16 | 17 | %macro MACRO_UNPACK 13 18 | movdqa xmm%10, xmm%2 19 | movdqa xmm%11, xmm%4 20 | movdqa xmm%12, xmm%6 21 | movdqa xmm%13, xmm%8 22 | punpckl%1 xmm%2, xmm%3 ; 07 06 05 04 03 02 01 00 wd: 13 03 12 02 11 01 10 00 dq: 31 21 11 01 30 20 10 00 qdq: 70 60 50 40 30 20 10 00 23 | punpckh%1 xmm%10, xmm%3 ; 17 16 15 14 13 12 11 10 17 07 16 06 15 05 14 04 33 23 13 03 32 22 12 02 71 61 51 41 31 21 11 01 24 | punpckl%1 xmm%4, xmm%5 ; 27 26 25 24 23 22 21 20 33 23 32 22 31 21 30 20 35 25 15 05 34 24 14 04 72 62 52 42 32 22 12 02 25 | punpckh%1 xmm%11, xmm%5 ; 37 36 35 34 33 32 31 30 37 27 36 26 35 25 34 24 37 27 17 07 36 26 16 06 73 63 53 43 33 23 13 03 26 | punpckl%1 xmm%6, xmm%7 ; 47 46 45 44 43 42 41 40 53 43 52 42 51 41 50 40 71 61 51 41 70 60 50 40 74 64 54 44 34 24 14 04 27 | punpckh%1 xmm%12, xmm%7 ; 57 56 55 54 53 52 51 50 57 47 56 46 55 45 54 44 73 63 53 43 72 62 52 42 75 65 55 45 35 25 15 05 28 | punpckl%1 xmm%8, xmm%9 ; 67 66 65 64 63 62 61 60 73 63 72 62 71 61 70 60 75 65 55 45 74 64 54 44 76 66 56 46 36 26 16 06 29 | punpckh%1 xmm%13, xmm%9 ; 77 76 75 74 73 72 71 70 77 67 76 66 75 65 74 64 77 67 57 47 76 66 56 46 77 67 57 47 37 27 17 07 30 | %endmacro 31 | 32 | %define FORMAT_ELF 0 33 | %ifidn __OUTPUT_FORMAT__,elf 34 | %define FORMAT_ELF 1 35 | %elifidn __OUTPUT_FORMAT__,elf32 36 | %define FORMAT_ELF 1 37 | %elifidn __OUTPUT_FORMAT__,elf64 38 | %define FORMAT_ELF 1 39 | %endif 40 | 41 | ; This is needed for ELF, otherwise the GNU linker assumes the stack is executable by default. 42 | %if FORMAT_ELF 43 | [SECTION .note.GNU-stack noalloc noexec nowrite progbits] 44 | %endif 45 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE2/x64RegisterUtil.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright(c) 2019 Intel Corporation 3 | ; SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | ; 5 | 6 | %include "x64inc.asm" 7 | 8 | section .text 9 | 10 | ; (Copied from Intel 64 and IA-32 Architectures Software Developer's Manual) 11 | ; ("9.6.3 Using the EMMS Instruction") 12 | ; The EMMS instruction should be used in each of the following cases: 13 | ; 1. When an application using the x87 FPU instructions calls an MMX technology 14 | ; library/DLL (use the EMMS instruction at the end of the MMX code). 15 | ; 2. When an application using MMX instructions calls a x87 FPU floating-point 16 | ; library/DLL (use the EMMS instruction before calling the x87 FPU code). 17 | ; 3. When a switch is made between MMX code in a task or thread and other tasks or 18 | ; threads in cooperative operating systems, unless it is certain that more MMX 19 | ; instructions will be executed before any x87 FPU code. 20 | 21 | ; So if eb_vp9_RunEmms() is called according to the above cases, 22 | ; then the "emms" instruction in all other assembly functions can be removed. 23 | 24 | cglobal eb_vp9_RunEmms 25 | emms 26 | ret 27 | 28 | ; ---------------------------------------------------------------------------------------- 29 | 30 | cglobal eb_vp9_SaveRegister 31 | %ifdef WIN64 32 | movdqa [r0], xmm6 33 | movdqa [r0+0x10], xmm7 34 | movdqa [r0+0x20], xmm8 35 | movdqa [r0+0x30], xmm9 36 | movdqa [r0+0x40], xmm10 37 | movdqa [r0+0x50], xmm11 38 | movdqa [r0+0x60], xmm12 39 | movdqa [r0+0x70], xmm13 40 | movdqa [r0+0x80], xmm14 41 | movdqa [r0+0x90], xmm15 42 | %endif 43 | ret 44 | 45 | ; ---------------------------------------------------------------------------------------- 46 | 47 | cglobal eb_vp9_RestoreRegister 48 | %ifdef WIN64 49 | movdqa xmm6, [r0] 50 | movdqa xmm7, [r0+0x10] 51 | movdqa xmm8, [r0+0x20] 52 | movdqa xmm9, [r0+0x30] 53 | movdqa xmm10, [r0+0x40] 54 | movdqa xmm11, [r0+0x50] 55 | movdqa xmm12, [r0+0x60] 56 | movdqa xmm13, [r0+0x70] 57 | movdqa xmm14, [r0+0x80] 58 | movdqa xmm15, [r0+0x90] 59 | %endif 60 | ret 61 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE4_1/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ~~~ 2 | # Copyright(c) 2019 Intel Corporation 3 | # SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | # ~~~ 5 | 6 | # ASM_SSE4.1 Directory CMakeLists.txt 7 | 8 | # Include Encoder Subdirectories 9 | include_directories(${PROJECT_SOURCE_DIR}/Source/API 10 | ${PROJECT_SOURCE_DIR}/Source/Lib/Codec 11 | ${PROJECT_SOURCE_DIR}/Source/Lib/C_DEFAULT 12 | ${PROJECT_SOURCE_DIR}/Source/Lib/ASM_SSE2 13 | ${PROJECT_SOURCE_DIR}/Source/Lib/ASM_SSSE3 14 | ${PROJECT_SOURCE_DIR}/Source/Lib/ASM_SSE4_1 15 | ${PROJECT_SOURCE_DIR}/Source/Lib/ASM_AVX2 16 | ${PROJECT_SOURCE_DIR}/Source/Lib/VPX) 17 | 18 | set(flags_to_test -msse4.1) 19 | 20 | if(CMAKE_C_COMPILER_ID STREQUAL "Intel" AND NOT WIN32) 21 | list(APPEND flags_to_test -static-intel -w) 22 | endif() 23 | 24 | test_apply_compiler_flags(${flags_to_test}) 25 | 26 | file(GLOB 27 | all_files 28 | "*.h" 29 | "*.c" 30 | "*.asm") 31 | 32 | add_library(VP9_ASM_SSE4_1 OBJECT ${all_files}) 33 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE4_1/EbComputeSAD_SSE4_1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbComputeSAD_SSE4_1_h 7 | #define EbComputeSAD_SSE4_1_h 8 | 9 | #include "EbDefinitions.h" 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | void eb_vp9_sad_loop_kernel_sse4_1_hme_l0_intrin( 15 | uint8_t *src, // input parameter, source samples Ptr 16 | uint32_t src_stride, // input parameter, source stride 17 | uint8_t *ref, // input parameter, reference samples Ptr 18 | uint32_t ref_stride, // input parameter, reference stride 19 | uint32_t height, // input parameter, block height (M) 20 | uint32_t width, // input parameter, block width (N) 21 | uint64_t *best_sad, 22 | int16_t *x_search_center, 23 | int16_t *y_search_center, 24 | uint32_t src_stride_raw, // input parameter, source stride (no line skipping) 25 | int16_t search_area_width, 26 | int16_t search_area_height); 27 | 28 | void eb_vp9_get_eight_horizontal_search_point_results_8x8_16x16_pu_sse41_intrin( 29 | uint8_t *src, 30 | uint32_t src_stride, 31 | uint8_t *ref, 32 | uint32_t ref_stride, 33 | uint32_t *p_best_sad8x8, 34 | uint32_t *p_best_mv8x8, 35 | uint32_t *p_best_sad16x16, 36 | uint32_t *p_best_mv16x16, 37 | uint32_t mv, 38 | uint16_t *p_sad16x16); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | #endif // EbComputeSAD_asm_h 44 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE4_1/EbPictureOperators_SSE4_1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbPictureOperators_SSE4_1_h 7 | #define EbPictureOperators_SSE4_1_h 8 | 9 | #include "EbDefinitions.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | uint64_t spatialfull_distortion_kernel4x4_ssse3_intrin( 16 | uint8_t *input, 17 | uint32_t input_stride, 18 | uint8_t *recon, 19 | uint32_t recon_stride, 20 | uint32_t area_width, 21 | uint32_t area_height); 22 | 23 | uint64_t spatialfull_distortion_kernel8x8_ssse3_intrin( 24 | uint8_t *input, 25 | uint32_t input_stride, 26 | uint8_t *recon, 27 | uint32_t recon_stride, 28 | uint32_t area_width, 29 | uint32_t area_height); 30 | 31 | uint64_t spatialfull_distortion_kernel16_mx_n_ssse3_intrin( 32 | uint8_t *input, 33 | uint32_t input_stride, 34 | uint8_t *recon, 35 | uint32_t recon_stride, 36 | uint32_t area_width, 37 | uint32_t area_height); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | #endif // EbPictureOperators_SSE4_1_h 43 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSSE3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ~~~ 2 | # Copyright(c) 2019 Intel Corporation 3 | # SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | # ~~~ 5 | 6 | # ASM_SSSE3 Directory CMakeLists.txt 7 | 8 | # Include Encoder Subdirectories 9 | include_directories(${PROJECT_SOURCE_DIR}/Source/API 10 | ${PROJECT_SOURCE_DIR}/Source/Lib/Codec 11 | ${PROJECT_SOURCE_DIR}/Source/Lib/VPX 12 | ${PROJECT_SOURCE_DIR}/Source/Lib/C_DEFAULT 13 | ${PROJECT_SOURCE_DIR}/Source/Lib/ASM_SSE2 14 | ${PROJECT_SOURCE_DIR}/Source/Lib/ASM_SSSE3 15 | ${PROJECT_SOURCE_DIR}/Source/Lib/ASM_SSE4_1 16 | ${PROJECT_SOURCE_DIR}/Source/Lib/ASM_AVX2) 17 | 18 | set(flags_to_test -mssse3) 19 | 20 | if(CMAKE_C_COMPILER_ID STREQUAL "Intel" AND NOT WIN32) 21 | list(APPEND flags_to_test -static-intel -w) 22 | endif() 23 | 24 | test_apply_compiler_flags(${flags_to_test}) 25 | 26 | file(GLOB 27 | all_files 28 | "*.h" 29 | "*.c" 30 | "*.asm") 31 | 32 | add_library(VP9_ASM_SSSE3 OBJECT ${all_files}) 33 | -------------------------------------------------------------------------------- /Source/Lib/C_DEFAULT/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ~~~ 2 | # Copyright(c) 2019 Intel Corporation 3 | # SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | # ~~~ 5 | 6 | # C_DEFAULT Directory CMakeLists.txt 7 | 8 | # Include Encoder Subdirectories 9 | include_directories(${PROJECT_SOURCE_DIR}/Source/API 10 | ${PROJECT_SOURCE_DIR}/Source/Lib/Codec 11 | ${PROJECT_SOURCE_DIR}/Source/Lib/C_DEFAULT 12 | ${PROJECT_SOURCE_DIR}/Source/Lib/VPX) 13 | 14 | file(GLOB 15 | all_files 16 | "*.h" 17 | "*.c") 18 | 19 | # Utility Source Files 20 | add_library(VP9_C_DEFAULT OBJECT ${all_files}) 21 | -------------------------------------------------------------------------------- /Source/Lib/C_DEFAULT/EbAvcStyleMcp_C.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EBAVCSTYLEMCP_C_H 7 | #define EBAVCSTYLEMCP_C_H 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbDefinitions.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | void avc_style_copy_new( 17 | EbByte ref_pic, 18 | uint32_t src_stride, 19 | EbByte dst, 20 | uint32_t dst_stride, 21 | uint32_t pu_width, 22 | uint32_t pu_height, 23 | EbByte temp_buf, 24 | uint32_t frac_pos); 25 | 26 | void eb_vp9_avc_style_luma_interpolation_filter_horizontal( 27 | EbByte ref_pic, 28 | uint32_t src_stride, 29 | EbByte dst, 30 | uint32_t dst_stride, 31 | uint32_t pu_width, 32 | uint32_t pu_height, 33 | EbByte temp_buf, 34 | uint32_t frac_pos); 35 | 36 | void eb_vp9_avc_style_luma_interpolation_filter_vertical( 37 | EbByte ref_pic, 38 | uint32_t src_stride, 39 | EbByte dst, 40 | uint32_t dst_stride, 41 | uint32_t pu_width, 42 | uint32_t pu_height, 43 | EbByte temp_buf, 44 | uint32_t frac_pos); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | #endif //EBAVCSTYLEMCP_C_H 50 | -------------------------------------------------------------------------------- /Source/Lib/C_DEFAULT/EbComputeMean_C.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbComputeMean_C_h 7 | #define EbComputeMean_C_h 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | #include "EbDefinitions.h" 13 | 14 | uint64_t compute_mean( 15 | uint8_t *input_samples, // input parameter, input samples Ptr 16 | uint32_t input_stride, // input parameter, input stride 17 | uint32_t input_area_width, // input parameter, input area width 18 | uint32_t input_area_height); // input parameter, input area height 19 | 20 | uint64_t compute_mean_of_squared_values( 21 | uint8_t *input_samples, // input parameter, input samples Ptr 22 | uint32_t input_stride, // input parameter, input stride 23 | uint32_t input_area_width, // input parameter, input area width 24 | uint32_t input_area_height); // input parameter, input area height 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /Source/Lib/C_DEFAULT/EbMeSadCalculation_C.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbMeSadCalculation_C_h 7 | #define EbMeSadCalculation_C_h 8 | 9 | #include "EbDefinitions.h" 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | extern void eb_vp9_sad_calculation_8x8_16x16( 15 | uint8_t *src, 16 | uint32_t src_stride, 17 | uint8_t *ref, 18 | uint32_t ref_stride, 19 | uint32_t *p_best_sad8x8, 20 | uint32_t *p_best_sad16x16, 21 | uint32_t *p_best_mv8x8, 22 | uint32_t *p_best_mv16x16, 23 | uint32_t mv, 24 | uint32_t *p_sad16x16); 25 | 26 | extern void eb_vp9_sad_calculation_32x32_64x64( 27 | uint32_t *p_sad16x16, 28 | uint32_t *p_best_sad32x32, 29 | uint32_t *p_best_sad64x64, 30 | uint32_t *p_best_mv32x32, 31 | uint32_t *p_best_mv64x64, 32 | uint32_t mv); 33 | 34 | extern void eb_vp9_initialize_buffer_32bits( 35 | uint32_t *pointer, 36 | uint32_t count128, 37 | uint32_t count32, 38 | uint32_t value); 39 | 40 | void weight_search_region( 41 | uint8_t *input_buffer, 42 | uint32_t input_stride, 43 | uint8_t *dst_buffer, 44 | uint32_t dst_stride, 45 | uint32_t search_area_width, 46 | uint32_t search_area_height, 47 | int16_t wp_weight, 48 | int16_t wp_offset, 49 | uint32_t wp_luma_weight_denominator_shift); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | #endif // EbMeSadCalculation_C_h 55 | -------------------------------------------------------------------------------- /Source/Lib/C_DEFAULT/EbPackUnPack_C.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbPackUnPack_C_h 7 | #define EbPackUnPack_C_h 8 | 9 | #include "EbDefinitions.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | void eb_vp9_enc_msb_pack2_d( 16 | uint8_t *in8_bit_buffer, 17 | uint32_t in8_stride, 18 | uint8_t *inn_bit_buffer, 19 | uint16_t *out16_bit_buffer, 20 | uint32_t inn_stride, 21 | uint32_t out_stride, 22 | uint32_t width, 23 | uint32_t height); 24 | 25 | void eb_vp9_compressed_packmsb( 26 | uint8_t *in8_bit_buffer, 27 | uint32_t in8_stride, 28 | uint8_t *inn_bit_buffer, 29 | uint16_t *out16_bit_buffer, 30 | uint32_t inn_stride, 31 | uint32_t out_stride, 32 | uint32_t width, 33 | uint32_t height); 34 | 35 | void eb_vp9_c_pack_c( 36 | const uint8_t *inn_bit_buffer, 37 | uint32_t inn_stride, 38 | uint8_t *in_compn_bit_buffer, 39 | uint32_t out_stride, 40 | uint8_t *local_cache, 41 | uint32_t width, 42 | uint32_t height); 43 | 44 | void eb_enc_msb_un_pack_2d( 45 | uint16_t *in16_bit_buffer, 46 | uint32_t in_stride, 47 | uint8_t *out8_bit_buffer, 48 | uint8_t *outn_bit_buffer, 49 | uint32_t out8_stride, 50 | uint32_t outn_stride, 51 | uint32_t width, 52 | uint32_t height); 53 | 54 | void unpack_8bit_data( 55 | uint16_t *in16_bit_buffer, 56 | uint32_t in_stride, 57 | uint8_t *out8_bit_buffer, 58 | uint32_t out8_stride, 59 | uint32_t width, 60 | uint32_t height); 61 | 62 | void eb_vp9_unpack_avg( 63 | uint16_t *ref16_l0, 64 | uint32_t ref_l0_stride, 65 | uint16_t *ref16_l1, 66 | uint32_t ref_l1_stride, 67 | uint8_t *dst_ptr, 68 | uint32_t dst_stride, 69 | uint32_t width, 70 | uint32_t height); 71 | 72 | void un_pack8_bit_data_safe_sub( 73 | uint16_t *in16_bit_buffer, 74 | uint32_t in_stride, 75 | uint8_t *out8_bit_buffer, 76 | uint32_t out8_stride, 77 | uint32_t width, 78 | uint32_t height); 79 | 80 | void eb_vp9_unpack_avg_safe_sub( 81 | uint16_t *ref16_l0, 82 | uint32_t ref_l0_stride, 83 | uint16_t *ref16_l1, 84 | uint32_t ref_l1_stride, 85 | uint8_t *dst_ptr, 86 | uint32_t dst_stride, 87 | uint32_t width, 88 | uint32_t height); 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | #endif // EbPackUnPack_C_h 94 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbBitstreamUnit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbBitstreamUnit_h 7 | #define EbBitstreamUnit_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbUtility.h" 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | // Bistream Slice Buffer Size 15 | #define EB_BITSTREAM_SLICE_BUFFER_SIZE 0x300000 16 | #define SLICE_HEADER_COUNT 256 17 | 18 | /********************************** 19 | * Bitstream Unit Types 20 | **********************************/ 21 | typedef struct OutputBitstreamUnit 22 | { 23 | uint32_t size; // allocated buffer size 24 | uint32_t byte_holder; // holds bytes and partial bytes 25 | int32_t valid_bits_count; // count of valid bits in byte_holder 26 | uint32_t written_bits_count; // count of written bits 27 | uint32_t slice_num; // Number of slices 28 | uint32_t slice_location[SLICE_HEADER_COUNT]; // Location of each slice in byte 29 | uint8_t *buffer_begin; // the byte buffer 30 | uint8_t *buffer; // the byte buffe 31 | 32 | } OutputBitstreamUnit; 33 | 34 | /********************************** 35 | * Extern Function Declarations 36 | **********************************/ 37 | extern EbErrorType eb_vp9_output_bitstream_unit_ctor( 38 | OutputBitstreamUnit *bitstream_ptr, 39 | uint32_t buffer_size ); 40 | 41 | extern EbErrorType eb_vp9_output_bitstream_reset(OutputBitstreamUnit *bitstream_ptr); 42 | 43 | extern EbErrorType output_bitstream_write ( 44 | OutputBitstreamUnit *bitstream_ptr, 45 | uint32_t bits, 46 | uint32_t number_of_bits ); 47 | 48 | extern EbErrorType output_bitstream_write_byte( 49 | OutputBitstreamUnit *bitstream_ptr, 50 | uint32_t bits); 51 | 52 | extern EbErrorType output_bitstream_write_align_zero(OutputBitstreamUnit *bitstream_ptr); 53 | 54 | extern EbErrorType eb_vp9_output_bitstream_rbsp_to_payload( 55 | OutputBitstreamUnit *bitstream_ptr, 56 | EbByte output_buffer, 57 | uint32_t *output_buffer_index, 58 | uint32_t *output_buffer_size, 59 | uint32_t start_location); 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif // EbBitstreamUnit_h 66 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbCodingUnit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbCodingUnit_h 7 | #define EbCodingUnit_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbSyntaxElements.h" 11 | #include "EbMotionEstimationLcuResults.h" 12 | #include "EbDefinitions.h" 13 | #include "EbPictureBufferDesc.h" 14 | 15 | #include "vp9_enums.h" 16 | #include "vp9_blockd.h" 17 | #include "vp9_block.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | struct PictureControlSet; 24 | 25 | #define MAX_BLOCK_COST 0xFFFFFFFFFFFFFFFFull 26 | #define INVALID_FAST_CANDIDATE_INDEX ~0 27 | 28 | typedef struct CodingUnit 29 | { 30 | uint8_t split_flag; 31 | int partition_context; 32 | uint16_t eob[MAX_MB_PLANE][4]; 33 | MbModeInfoExt *mbmi_ext; 34 | PARTITION_TYPE part; 35 | Part shape; 36 | uint16_t ep_block_index; 37 | 38 | } CodingUnit; 39 | 40 | typedef struct EdgeSbResults 41 | { 42 | uint8_t edge_block_num; 43 | uint8_t isolated_high_intensity_sb; 44 | 45 | } EdgeSbResults; 46 | 47 | typedef struct SbUnit 48 | { 49 | struct PictureControlSet *picture_control_set_ptr; 50 | CodingUnit **coded_block_array_ptr; 51 | 52 | // Coding Units 53 | EB_AURA_STATUS aura_status; 54 | 55 | unsigned pred64 : 2; 56 | unsigned sb_index : 14; // supports up to 8k resolution 57 | unsigned origin_x : 13; // supports up to 8k resolution 8191 58 | unsigned origin_y : 13; // supports up to 8k resolution 8191 59 | 60 | //Bits only used for quantized coeffs 61 | uint32_t sb_total_bits; 62 | 63 | // Quantized Coefficients 64 | #if VP9_PERFORM_EP 65 | int16_t *quantized_coeff_buffer[MAX_MB_PLANE]; 66 | 67 | int quantized_coeff_buffer_block_offset[MAX_MB_PLANE]; 68 | #else 69 | EbPictureBufferDesc *quantized_coeff; 70 | #endif 71 | 72 | #if BEA 73 | int8_t segment_id; 74 | #endif 75 | } SbUnit; 76 | 77 | extern EbErrorType sb_unit_ctor( 78 | SbUnit **sb_unit_dbl_ptr, 79 | uint32_t picture_width, 80 | uint32_t picture_height, 81 | uint16_t sb_origin_x, 82 | uint16_t sb_origin_y, 83 | uint16_t sb_index, 84 | struct PictureControlSet *picture_control_set); 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | #endif // EbCodingUnit_h 90 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbComputeMean.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbComputeMean_h 7 | #define EbComputeMean_h 8 | 9 | #include "EbComputeMean_SSE2.h" 10 | #include "EbComputeMean_C.h" 11 | #include "EbCombinedAveragingSAD_Intrinsic_AVX2.h" 12 | #include "EbDefinitions.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | typedef uint64_t(*EbComputeMeanFunc)( 19 | uint8_t *input_samples, 20 | uint32_t input_stride, 21 | uint32_t input_area_width, 22 | uint32_t input_area_height); 23 | 24 | static const EbComputeMeanFunc compute_mean_func[2][ASM_TYPE_TOTAL] = { 25 | { 26 | // C_DEFAULT 27 | compute_mean, 28 | // AVX2 29 | eb_vp9_compute_mean8x8_avx2_intrin 30 | }, 31 | { 32 | // C_DEFAULT 33 | compute_mean_of_squared_values, 34 | // AVX2 35 | eb_vp9_compute_mean_of_squared_values8x8_sse2_intrin 36 | } 37 | }; 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbEncDecResults.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | #include "EbDefinitions.h" 8 | #include "EbEncDecResults.h" 9 | 10 | EbErrorType eb_vp9_enc_dec_results_ctor( 11 | EbPtr *object_dbl_ptr, 12 | EbPtr object_init_data_ptr) 13 | { 14 | EncDecResults *context_ptr; 15 | EB_MALLOC(EncDecResults*, context_ptr, sizeof(EncDecResults), EB_N_PTR); 16 | 17 | *object_dbl_ptr = (EbPtr) context_ptr; 18 | 19 | (void) object_init_data_ptr; 20 | 21 | return EB_ErrorNone; 22 | } 23 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbEncDecResults.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbEncDecResults_h 7 | #define EbEncDecResults_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbSystemResourceManager.h" 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | /************************************** 15 | * Process Results 16 | **************************************/ 17 | typedef struct EncDecResults 18 | { 19 | EbObjectWrapper *picture_control_set_wrapper_ptr; 20 | uint32_t completed_sb_row_index_start; 21 | uint32_t completed_sb_row_count; 22 | 23 | } EncDecResults; 24 | 25 | typedef struct EncDecResultsInitData { 26 | uint32_t junk; 27 | } EncDecResultsInitData; 28 | 29 | /************************************** 30 | * Extern Function Declarations 31 | **************************************/ 32 | extern EbErrorType eb_vp9_enc_dec_results_ctor( 33 | EbPtr *object_dbl_ptr, 34 | EbPtr object_init_data_ptr); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | #endif // EbEncDecResults_h 40 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbEncDecTasks.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | 8 | #include "EbDefinitions.h" 9 | #include "EbEncDecTasks.h" 10 | 11 | EbErrorType eb_vp9_enc_dec_tasks_ctor( 12 | EbPtr *object_dbl_ptr, 13 | EbPtr object_init_data_ptr) 14 | { 15 | EncDecTasks *context_ptr; 16 | EB_MALLOC(EncDecTasks*, context_ptr, sizeof(EncDecTasks), EB_N_PTR); 17 | 18 | *object_dbl_ptr = (EbPtr) context_ptr; 19 | 20 | (void) object_init_data_ptr; 21 | 22 | return EB_ErrorNone; 23 | } 24 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbEncDecTasks.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbEncDecTasks_h 7 | #define EbEncDecTasks_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbSystemResourceManager.h" 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | #define ENCDEC_TASKS_MDC_INPUT 0 15 | #define ENCDEC_TASKS_ENCDEC_INPUT 1 16 | #define ENCDEC_TASKS_CONTINUE 2 17 | 18 | /************************************** 19 | * Process Results 20 | **************************************/ 21 | typedef struct EncDecTasks 22 | { 23 | EbObjectWrapper *picture_control_set_wrapper_ptr; 24 | uint32_t input_type; 25 | int16_t enc_dec_segment_row; 26 | 27 | } EncDecTasks; 28 | 29 | typedef struct EncDecTasksInitData { 30 | unsigned enc_dec_segment_row_count; 31 | } EncDecTasksInitData; 32 | 33 | /************************************** 34 | * Extern Function Declarations 35 | **************************************/ 36 | extern EbErrorType eb_vp9_enc_dec_tasks_ctor( 37 | EbPtr *object_dbl_ptr, 38 | EbPtr object_init_data_ptr); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | #endif // EbEncDecTasks_h 44 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbEntropyCoding.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | #include 8 | 9 | #include "EbEntropyCoding.h" 10 | #include "EbDefinitions.h" 11 | #include "EbThreads.h" 12 | #include "EbEntropyCodingObject.h" 13 | 14 | #define DECODED_PICTURE_HASH 132 15 | 16 | EbErrorType eb_vp9_reset_bitstream( 17 | EbPtr bitstream_ptr) 18 | { 19 | EbErrorType return_error = EB_ErrorNone; 20 | OutputBitstreamUnit *output_bitstream_ptr = (OutputBitstreamUnit*)bitstream_ptr; 21 | 22 | eb_vp9_output_bitstream_reset( 23 | output_bitstream_ptr); 24 | 25 | return return_error; 26 | } 27 | 28 | EbErrorType eb_vp9_bitstream_ctor( 29 | Bitstream **bitstream_dbl_ptr, 30 | uint32_t buffer_size) 31 | { 32 | EbErrorType return_error = EB_ErrorNone; 33 | EB_MALLOC(Bitstream*, *bitstream_dbl_ptr, sizeof(Bitstream), EB_N_PTR); 34 | 35 | EB_MALLOC(EbPtr, (*bitstream_dbl_ptr)->output_bitstream_ptr, sizeof(OutputBitstreamUnit), EB_N_PTR); 36 | 37 | return_error = eb_vp9_output_bitstream_unit_ctor( 38 | (OutputBitstreamUnit*)(*bitstream_dbl_ptr)->output_bitstream_ptr, 39 | buffer_size); 40 | 41 | return return_error; 42 | } 43 | 44 | EbErrorType eb_vp9_entropy_coder_ctor( 45 | EntropyCoder **entropy_coder_dbl_ptr, 46 | uint32_t buffer_size) 47 | { 48 | EbErrorType return_error = EB_ErrorNone; 49 | EB_MALLOC(EntropyCoder*, *entropy_coder_dbl_ptr, sizeof(EntropyCoder), EB_N_PTR); 50 | 51 | EB_MALLOC(EbPtr, (*entropy_coder_dbl_ptr)->ec_output_bitstream_ptr, sizeof(OutputBitstreamUnit ), EB_N_PTR); 52 | 53 | return_error = eb_vp9_output_bitstream_unit_ctor( 54 | (OutputBitstreamUnit*)(*entropy_coder_dbl_ptr)->ec_output_bitstream_ptr, 55 | buffer_size); 56 | 57 | return return_error; 58 | } 59 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbEntropyCoding.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbEntropyCoding_h 7 | #define EbEntropyCoding_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbEntropyCodingObject.h" 11 | #include "EbCodingUnit.h" 12 | #include "EbPictureBufferDesc.h" 13 | #include "EbSequenceControlSet.h" 14 | #include "EbPictureControlSet.h" 15 | 16 | #include "EbModeDecision.h" 17 | #include "EbIntraPrediction.h" 18 | #include "EbBitstreamUnit.h" 19 | #include "EbPacketizationProcess.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | /************************************** 26 | * Extern Function Declarations 27 | **************************************/ 28 | extern EbErrorType eb_vp9_reset_bitstream( 29 | EbPtr bitstream_ptr); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | #endif //EbEntropyCoding_h 35 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbEntropyCodingObject.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbEntropyCodingObject_h 7 | #define EbEntropyCodingObject_h 8 | 9 | #include 10 | #include "EbDefinitions.h" 11 | #include "bitwriter.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | typedef struct Bitstream { 17 | EbPtr output_bitstream_ptr; 18 | } Bitstream; 19 | 20 | typedef struct EntropyCoder 21 | { 22 | VpxWriter residual_bc; 23 | EbPtr ec_output_bitstream_ptr; 24 | 25 | } EntropyCoder; 26 | 27 | extern EbErrorType eb_vp9_bitstream_ctor( 28 | Bitstream **bitstream_dbl_ptr, 29 | uint32_t buffer_size); 30 | 31 | extern EbErrorType eb_vp9_entropy_coder_ctor( 32 | EntropyCoder **entropy_coder_dbl_ptr, 33 | uint32_t buffer_size); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | #endif // EbEntropyCodingObject_h 39 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbEntropyCodingProcess.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbEntropyCodingProcess_h 7 | #define EbEntropyCodingProcess_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbSyntaxElements.h" 11 | 12 | #include "EbSystemResourceManager.h" 13 | #include "EbPictureBufferDesc.h" 14 | #include "EbModeDecision.h" 15 | 16 | #include "EbEntropyCoding.h" 17 | #include "EbTransQuantBuffers.h" 18 | #include "EbReferenceObject.h" 19 | #include "EbNeighborArrays.h" 20 | #include "EbCodingUnit.h" 21 | #include "vp9_blockd.h" 22 | 23 | /************************************** 24 | * Entropy Coding Context 25 | **************************************/ 26 | typedef struct EntropyCodingContext 27 | { 28 | EbFifo *enc_dec_input_fifo_ptr; 29 | EbFifo *entropy_coding_output_fifo_ptr; 30 | EbFifo *rate_control_output_fifo_ptr; 31 | 32 | CodingUnit *block_ptr; 33 | const EpBlockStats *ep_block_stats_ptr; 34 | 35 | uint32_t block_width; 36 | uint32_t block_height; 37 | uint32_t block_origin_x; 38 | uint32_t block_origin_y; 39 | 40 | EB_BOOL is16bit; 41 | 42 | int mi_row; 43 | int mi_col; 44 | 45 | MACROBLOCKD *e_mbd; 46 | 47 | TOKENEXTRA *tok; 48 | TOKENEXTRA *tok_start; 49 | TOKENEXTRA *tok_end; 50 | 51 | } EntropyCodingContext; 52 | 53 | /************************************** 54 | * Extern Function Declarations 55 | **************************************/ 56 | extern EbErrorType eb_vp9_entropy_coding_context_ctor( 57 | EntropyCodingContext **context_dbl_ptr, 58 | EbFifo *enc_dec_input_fifo_ptr, 59 | EbFifo *packetization_output_fifo_ptr, 60 | EbFifo *rate_control_output_fifo_ptr, 61 | EB_BOOL is16bit); 62 | 63 | extern void* eb_vp9_entropy_coding_kernel(void *input_ptr); 64 | 65 | #endif // EbEntropyCodingProcess_h 66 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbEntropyCodingResults.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | 8 | #include "EbDefinitions.h" 9 | #include "EbEntropyCodingResults.h" 10 | 11 | EbErrorType eb_vp9_entropy_coding_results_ctor( 12 | EbPtr *object_dbl_ptr, 13 | EbPtr object_init_data_ptr) 14 | { 15 | EntropyCodingResults *context_ptr; 16 | EB_MALLOC(EntropyCodingResults*, context_ptr, sizeof(EntropyCodingResults), EB_N_PTR); 17 | 18 | *object_dbl_ptr = (EbPtr) context_ptr; 19 | 20 | (void) object_init_data_ptr; 21 | 22 | return EB_ErrorNone; 23 | } 24 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbEntropyCodingResults.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbEntropyCodingResults_h 7 | #define EbEntropyCodingResults_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbSystemResourceManager.h" 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | /************************************** 15 | * Process Results 16 | **************************************/ 17 | typedef struct EntropyCodingResults { 18 | EbObjectWrapper *picture_control_set_wrapper_ptr; 19 | } EntropyCodingResults; 20 | 21 | typedef struct EntropyCodingResultsInitData { 22 | uint32_t junk; 23 | } EntropyCodingResultsInitData; 24 | 25 | /************************************** 26 | * Extern Function Declarations 27 | **************************************/ 28 | extern EbErrorType eb_vp9_entropy_coding_results_ctor( 29 | EbPtr *object_dbl_ptr, 30 | EbPtr object_init_data_ptr); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | #endif // EbEntropyCodingResults_h 36 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbInitialRateControlProcess.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbInitialRateControl_h 7 | #define EbInitialRateControl_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbSystemResourceManager.h" 11 | #include "EbRateControlProcess.h" 12 | 13 | /************************************** 14 | * Context 15 | **************************************/ 16 | typedef struct InitialRateControlContext 17 | { 18 | EbFifo *motion_estimation_results_input_fifo_ptr; 19 | EbFifo *initialrate_control_results_output_fifo_ptr; 20 | 21 | } InitialRateControlContext; 22 | 23 | /*************************************** 24 | * Extern Function Declaration 25 | ***************************************/ 26 | extern EbErrorType eb_vp9_initial_eb_vp9_rate_control_context_ctor( 27 | InitialRateControlContext **context_dbl_ptr, 28 | EbFifo *motion_estimation_results_input_fifo_ptr, 29 | EbFifo *picture_demux_results_output_fifo_ptr); 30 | 31 | extern void* eb_vp9_initial_eb_vp9_rate_control_kernel(void *input_ptr); 32 | 33 | #endif // EbInitialRateControl_h 34 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbInitialRateControlReorderQueue.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | #include "EbInitialRateControlReorderQueue.h" 8 | 9 | EbErrorType eb_vp9_initial_rate_control_reorder_entry_ctor( 10 | InitialRateControlReorderEntry **entry_dbl_ptr, 11 | uint32_t picture_number) 12 | { 13 | EB_MALLOC(InitialRateControlReorderEntry*, *entry_dbl_ptr, sizeof(InitialRateControlReorderEntry), EB_N_PTR); 14 | 15 | (*entry_dbl_ptr)->picture_number = picture_number; 16 | (*entry_dbl_ptr)->parent_pcs_wrapper_ptr = (EbObjectWrapper *)EB_NULL; 17 | 18 | return EB_ErrorNone; 19 | } 20 | 21 | EbErrorType eb_vp9_hl_rate_control_histogram_entry_ctor( 22 | HlRateControlHistogramEntry **entry_dbl_ptr, 23 | uint32_t picture_number) 24 | { 25 | EB_MALLOC(HlRateControlHistogramEntry*, *entry_dbl_ptr, sizeof(HlRateControlHistogramEntry), EB_N_PTR); 26 | 27 | (*entry_dbl_ptr)->picture_number = picture_number; 28 | (*entry_dbl_ptr)->life_count = 0; 29 | 30 | (*entry_dbl_ptr)->parent_pcs_wrapper_ptr = (EbObjectWrapper *)EB_NULL; 31 | 32 | // ME and OIS Distortion Histograms 33 | EB_MALLOC(uint16_t*, (*entry_dbl_ptr)->me_distortion_histogram, sizeof(uint16_t) * NUMBER_OF_SAD_INTERVALS, EB_N_PTR); 34 | 35 | EB_MALLOC(uint16_t*, (*entry_dbl_ptr)->ois_distortion_histogram, sizeof(uint16_t) * NUMBER_OF_INTRA_SAD_INTERVALS, EB_N_PTR); 36 | 37 | return EB_ErrorNone; 38 | } 39 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbInitialRateControlReorderQueue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbInitialRateControlReorderQueue_h 7 | #define EbInitialRateControlReorderQueue_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbSystemResourceManager.h" 11 | #include "EbRateControlTables.h" 12 | #include "EbPictureControlSet.h" 13 | 14 | /************************************************ 15 | * Initial Rate Control Reorder Queue Entry 16 | ************************************************/ 17 | typedef struct InitialRateControlReorderEntry 18 | { 19 | uint64_t picture_number; 20 | EbObjectWrapper *parent_pcs_wrapper_ptr; 21 | 22 | } InitialRateControlReorderEntry; 23 | 24 | extern EbErrorType eb_vp9_initial_rate_control_reorder_entry_ctor( 25 | InitialRateControlReorderEntry **entry_dbl_ptr, 26 | uint32_t picture_number); 27 | 28 | /************************************************ 29 | * High Level Rate Control Histogram Queue Entry 30 | ************************************************/ 31 | typedef struct HlRateControlHistogramEntry 32 | { 33 | uint64_t picture_number; 34 | int16_t life_count; 35 | EB_BOOL passed_to_hlrc; 36 | EB_BOOL is_coded; 37 | uint64_t total_num_bitsCoded; 38 | EbObjectWrapper *parent_pcs_wrapper_ptr; 39 | EB_BOOL end_of_sequence_flag; 40 | uint64_t pred_bits_ref_qp[MAX_REF_QP_NUM]; 41 | EB_SLICE slice_type; 42 | uint32_t temporal_layer_index; 43 | uint32_t frames_in_sw; 44 | 45 | // Motion Estimation Distortion and OIS Historgram 46 | uint16_t *me_distortion_histogram; 47 | uint16_t *ois_distortion_histogram; 48 | uint32_t full_sb_count; 49 | 50 | } HlRateControlHistogramEntry; 51 | 52 | extern EbErrorType eb_vp9_hl_rate_control_histogram_entry_ctor( 53 | HlRateControlHistogramEntry **entry_dbl_ptr, 54 | uint32_t picture_number); 55 | 56 | #endif //EbInitialRateControlReorderQueue_h 57 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbInitialRateControlResults.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | 8 | #include "EbInitialRateControlResults.h" 9 | 10 | EbErrorType eb_vp9_initial_eb_vp9_rate_control_results_ctor( 11 | EbPtr *object_dbl_ptr, 12 | EbPtr object_init_data_ptr) 13 | { 14 | InitialRateControlResults *object_ptr; 15 | EB_MALLOC(InitialRateControlResults *, object_ptr, sizeof(InitialRateControlResults), EB_N_PTR); 16 | 17 | *object_dbl_ptr = (EbPtr) object_ptr; 18 | object_init_data_ptr = 0; 19 | (void) object_init_data_ptr; 20 | 21 | return EB_ErrorNone; 22 | } 23 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbInitialRateControlResults.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbInitialRateControlResults_h 7 | #define EbInitialRateControlResults_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbSystemResourceManager.h" 11 | 12 | /************************************** 13 | * Process Results 14 | **************************************/ 15 | typedef struct InitialRateControlResults { 16 | EbObjectWrapper *picture_control_set_wrapper_ptr; 17 | } InitialRateControlResults; 18 | 19 | typedef struct InitialRateControlResultInitData { 20 | int junk; 21 | } InitialRateControlResultInitData; 22 | 23 | /************************************** 24 | * Extern Function Declarations 25 | **************************************/ 26 | extern EbErrorType eb_vp9_initial_eb_vp9_rate_control_results_ctor( 27 | EbPtr *object_dbl_ptr, 28 | EbPtr object_init_data_ptr); 29 | 30 | #endif //EbInitialRateControlResults_h 31 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbIntraPrediction.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | #include 8 | 9 | #include "EbIntraPrediction.h" 10 | #include "EbDefinitions.h" 11 | 12 | #include "vp9_reconintra.h" 13 | #include "vp9_reconinter.h" 14 | 15 | void intra_prediction( 16 | EncDecContext *context_ptr, 17 | EbByte pred_buffer, 18 | uint16_t pred_stride, 19 | int plane) 20 | { 21 | MACROBLOCKD *const xd = context_ptr->e_mbd; 22 | 23 | #if 0 24 | const TX_SIZE tx_size = plane ? get_uv_tx_size(xd->mi[0], pd) : xd->mi[0]->tx_size; 25 | #else 26 | const TX_SIZE tx_size = plane ? context_ptr->ep_block_stats_ptr->tx_size_uv : context_ptr->ep_block_stats_ptr->tx_size; 27 | #endif 28 | 29 | PREDICTION_MODE mode; 30 | int block = context_ptr->bmi_index; 31 | 32 | if (tx_size == TX_4X4) { 33 | mode = plane == 0 ? get_y_mode(xd->mi[0], block) : xd->mi[0]->uv_mode; 34 | } 35 | else { 36 | mode = plane == 0 ? xd->mi[0]->mode : xd->mi[0]->uv_mode; 37 | } 38 | 39 | eb_vp9_predict_intra_block( 40 | context_ptr, 41 | #if 0 // Hsan: reference samples generation done per block prior to fast loop @ generate_intra_reference_samples() 42 | xd, 43 | #endif 44 | tx_size, 45 | mode, 46 | pred_buffer, 47 | pred_stride, 48 | #if 0 49 | 0, 50 | 0, 51 | #endif 52 | plane); 53 | } 54 | 55 | void inter_prediction( 56 | struct EncDecContext *context_ptr, 57 | EbByte pred_buffer, 58 | uint16_t pred_stride, 59 | int plane) 60 | { 61 | MACROBLOCKD *const xd = context_ptr->e_mbd; 62 | 63 | const int mi_x = context_ptr->block_origin_x; 64 | const int mi_y = context_ptr->block_origin_y; 65 | 66 | const BLOCK_SIZE plane_bsize = plane ? context_ptr->ep_block_stats_ptr->bsize_uv: context_ptr->ep_block_stats_ptr->bsize; 67 | 68 | const int num_4x4_w = eb_vp9_num_4x4_blocks_wide_lookup[plane_bsize]; 69 | const int num_4x4_h = eb_vp9_num_4x4_blocks_high_lookup[plane_bsize]; 70 | const int bw = num_4x4_w << 2; 71 | const int bh = num_4x4_h << 2; 72 | 73 | if (xd->mi[0]->sb_type < BLOCK_8X8) { 74 | int i = 0, x, y; 75 | assert(xd->mi[0]->sb_type == BLOCK_8X8); 76 | for (y = 0; y < num_4x4_h; ++y) 77 | for (x = 0; x < num_4x4_w; ++x) 78 | build_inter_predictors(context_ptr, pred_buffer, pred_stride, xd, plane, i++, bw, bh, 4 * x, 4 * y, 4, 4, mi_x, mi_y); 79 | } 80 | else { 81 | build_inter_predictors(context_ptr, pred_buffer, pred_stride, xd, plane, 0, bw, bh, 0, 0, bw, bh, mi_x, mi_y); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbIntraPrediction.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbIntraPrediction_h 7 | #define EbIntraPrediction_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbUtility.h" 11 | #include "EbPictureBufferDesc.h" 12 | #include "EbPictureControlSet.h" 13 | #include "EbCodingUnit.h" 14 | #include "EbPictureControlSet.h" 15 | #include "EbModeDecision.h" 16 | #include "EbNeighborArrays.h" 17 | #include "EbMotionEstimationProcess.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | extern void intra_prediction( 24 | struct EncDecContext *context_ptr, 25 | EbByte pred_buffer, 26 | uint16_t pred_stride, 27 | int plane); 28 | 29 | extern void inter_prediction( 30 | struct EncDecContext *context_ptr, 31 | EbByte pred_buffer, 32 | uint16_t pred_stride, 33 | int plane); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | #endif // EbIntraPrediction_h 39 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbMcp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | // Hassene: to rename the file as no MCP here 7 | 8 | #ifndef EBMCP_H 9 | #define EBMCP_H 10 | 11 | #include "EbMcp_SSE2.h" 12 | #include "EbDefinitions.h" 13 | #include "EbUtility.h" 14 | #include "EbPictureBufferDesc.h" 15 | #include "EbPictureControlSet.h" 16 | #include "EbSequenceControlSet.h" 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | extern void eb_vp9_generate_padding( 23 | EbByte src_pic, 24 | uint32_t src_stride, 25 | uint32_t original_src_width, 26 | uint32_t original_src_height, 27 | uint32_t padding_width, 28 | uint32_t padding_height); 29 | 30 | extern void eb_vp9_generate_padding_16bit( 31 | EbByte src_pic, 32 | uint32_t src_stride, 33 | uint32_t original_src_width, 34 | uint32_t original_src_height, 35 | uint32_t padding_width, 36 | uint32_t padding_height); 37 | 38 | extern void eb_vp9_pad_input_picture( 39 | EbByte src_pic, 40 | uint32_t src_stride, 41 | uint32_t original_src_width, 42 | uint32_t original_src_height, 43 | uint32_t pad_right, 44 | uint32_t pad_bottom); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | #endif // EBMCP_H 50 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbMeSadCalculation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbMeSadCalculation_h 7 | #define EbMeSadCalculation_h 8 | 9 | #include "EbMeSadCalculation_C.h" 10 | #include "EbMeSadCalculation_SSE2.h" 11 | 12 | #include "EbDefinitions.h" 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /*************************************** 18 | * Function Types 19 | ***************************************/ 20 | typedef void(*EbSadCalculation8x8and16x16Type)( 21 | uint8_t *src, 22 | uint32_t src_stride, 23 | uint8_t *ref, 24 | uint32_t ref_stride, 25 | uint32_t *p_best_sad8x8, 26 | uint32_t *p_best_sad16x16, 27 | uint32_t *p_best_mv8x8, 28 | uint32_t *p_best_mv16x16, 29 | uint32_t mv, 30 | uint32_t *p_sad16x16); 31 | 32 | typedef void(*EbSadCalculation32x32and64x64Type)( 33 | uint32_t *p_sad16x16, 34 | uint32_t *p_best_sad32x32, 35 | uint32_t *p_best_sad64x64, 36 | uint32_t *p_best_mv32x32, 37 | uint32_t *p_best_mv64x64, 38 | uint32_t mv); 39 | 40 | typedef void(*EbInializeBuffer32Bits)( 41 | uint32_t *pointer, 42 | uint32_t count128, 43 | uint32_t count32, 44 | uint32_t value); 45 | 46 | /*************************************** 47 | * Function Tables 48 | ***************************************/ 49 | static EbSadCalculation8x8and16x16Type eb_vp9_sad_calculation_8x8_16x16_func_ptr_array[ASM_TYPE_TOTAL] = { 50 | // C_DEFAULT 51 | eb_vp9_sad_calculation_8x8_16x16, 52 | // AVX2 53 | eb_vp9_sad_calculation_8x8_16x16_sse2_intrin, 54 | }; 55 | 56 | static EbSadCalculation32x32and64x64Type eb_vp9_sad_calculation_32x32_64x64_func_ptr_array[ASM_TYPE_TOTAL] = { 57 | // C_DEFAULT 58 | eb_vp9_sad_calculation_32x32_64x64, 59 | // AVX2 60 | eb_vp9_sad_calculation_32x32_64x64_sse2_intrin, 61 | }; 62 | 63 | static EbInializeBuffer32Bits eb_vp9_initialize_buffer_32bits_func_ptr_array[ASM_TYPE_TOTAL] = { 64 | // C_DEFAULT 65 | eb_vp9_initialize_buffer_32bits, 66 | // AVX2 67 | eb_vp9_initialize_buffer_32bits_sse2_intrin 68 | }; 69 | 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | #endif // EbMeSadCalculation_h 74 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbMotionEstimation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbMotionEstimation_h 7 | #define EbMotionEstimation_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbCodingUnit.h" 11 | 12 | #include "EbMotionEstimationProcess.h" 13 | #include "EbMotionEstimationContext.h" 14 | #include "EbPictureBufferDesc.h" 15 | #include "EbSequenceControlSet.h" 16 | #include "EbReferenceObject.h" 17 | #include "EbPictureDecisionProcess.h" 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | extern EbErrorType motion_estimate_sb( 22 | PictureParentControlSet *picture_control_set_ptr, 23 | uint32_t sb_index, 24 | uint32_t sb_origin_x, 25 | uint32_t sb_origin_y, 26 | MeContext *context_ptr, 27 | EbPictureBufferDesc *input_ptr); 28 | 29 | extern void eb_vp9_decimation_2d( 30 | uint8_t *input_samples, 31 | uint32_t input_stride, 32 | uint32_t input_area_width, 33 | uint32_t input_area_height, 34 | uint8_t *decim_samples, 35 | uint32_t decim_stride, 36 | uint32_t decim_step); 37 | 38 | extern void eb_vp9_get_mv( 39 | PictureParentControlSet *picture_control_set_ptr, 40 | uint32_t sb_index, 41 | int32_t *x_current_mv, 42 | int32_t *y_current_mv); 43 | 44 | int8_t sort3_elements(uint32_t a, uint32_t b, uint32_t c); 45 | #define a_b_c 0 46 | #define a_c_b 1 47 | #define b_a_c 2 48 | #define b_c_a 3 49 | #define c_a_b 4 50 | #define c_b_a 5 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | #endif // EbMotionEstimation_h 56 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbMotionEstimationLcuResults.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbMotionEstimationLcuResults_h 7 | #define EbMotionEstimationLcuResults_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbDefinitions.h" 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | #define MAX_ME_PU_COUNT 85 // Sum of all the possible partitions which have both deminsions greater than 4. 15 | // i.e. no 4x4, 8x4, or 4x8 partitions 16 | #define SQUARE_PU_COUNT 85 17 | #define MAX_ME_CANDIDATE_PER_PU 3 18 | 19 | typedef struct MeCandidate 20 | { 21 | union { 22 | struct { 23 | signed short x_mv_l0 ; //Note: Do not change the order of these fields 24 | signed short y_mv_l0 ; 25 | signed short x_mv_l1 ; 26 | signed short y_mv_l1 ; 27 | }mv; 28 | uint64_t MVs; 29 | }; 30 | 31 | unsigned distortion : 32; // 20-bits holds maximum SAD of 64x64 PU 32 | 33 | unsigned direction : 8; // 0: uni-pred L0, 1: uni-pred L1, 2: bi-pred 34 | 35 | } MeCandidate; 36 | 37 | typedef struct DistDir 38 | { 39 | unsigned distortion : 32; 40 | unsigned direction : 2; 41 | } DistDir; 42 | 43 | typedef struct MeCuResults 44 | { 45 | union { 46 | struct { 47 | signed short x_mv_l0; 48 | signed short y_mv_l0; 49 | signed short x_mv_l1; 50 | signed short y_mv_l1; 51 | }; 52 | uint64_t MVs; 53 | }; 54 | 55 | DistDir distortion_direction[3]; 56 | 57 | uint8_t total_me_candidate_index; 58 | 59 | } MeCuResults; 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | #endif // EbMotionEstimationLcuResults_h 65 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbMotionEstimationProcess.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbEstimationProcess_h 7 | #define EbEstimationProcess_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbSystemResourceManager.h" 11 | #include "EbSequenceControlSet.h" 12 | #include "EbPictureControlSet.h" 13 | #include "EbMotionEstimationContext.h" 14 | 15 | /************************************** 16 | * Context 17 | **************************************/ 18 | typedef struct MotionEstimationContext 19 | { 20 | EbFifo *picture_decision_results_input_fifo_ptr; 21 | EbFifo *motion_estimation_results_output_fifo_ptr; 22 | MeContext *me_context_ptr; 23 | 24 | } MotionEstimationContext; 25 | 26 | /*************************************** 27 | * Extern Function Declaration 28 | ***************************************/ 29 | extern EbErrorType eb_vp9_motion_estimation_context_ctor( 30 | MotionEstimationContext **context_dbl_ptr, 31 | EbFifo *picture_decision_results_input_fifo_ptr, 32 | EbFifo *motion_estimation_results_output_fifo_ptr); 33 | 34 | extern void* eb_vp9_motion_estimation_kernel(void *input_ptr); 35 | 36 | #endif // EbMotionEstimationProcess_h 37 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbMotionEstimationResults.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | 8 | #include "EbDefinitions.h" 9 | #include "EbMotionEstimationResults.h" 10 | 11 | EbErrorType eb_vp9_motion_estimation_results_ctor( 12 | EbPtr *object_dbl_ptr, 13 | EbPtr object_init_data_ptr) 14 | { 15 | MotionEstimationResults *context_ptr; 16 | EB_MALLOC(MotionEstimationResults*, context_ptr, sizeof(MotionEstimationResults), EB_N_PTR); 17 | 18 | *object_dbl_ptr = (EbPtr) context_ptr; 19 | object_init_data_ptr = 0; 20 | 21 | (void)(object_init_data_ptr); 22 | return EB_ErrorNone; 23 | } 24 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbMotionEstimationResults.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbMotionEstimationResults_h 7 | #define EbMotionEstimationResults_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbSystemResourceManager.h" 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | /************************************** 15 | * Process Results 16 | **************************************/ 17 | typedef struct MotionEstimationResults 18 | { 19 | EbObjectWrapper *picture_control_set_wrapper_ptr; 20 | uint32_t segment_index; 21 | } MotionEstimationResults; 22 | 23 | typedef struct MotionEstimationResultsInitData { 24 | int junk; 25 | } MotionEstimationResultsInitData; 26 | 27 | /************************************** 28 | * Extern Function Declarations 29 | **************************************/ 30 | extern EbErrorType eb_vp9_motion_estimation_results_ctor( 31 | EbPtr *object_dbl_ptr, 32 | EbPtr object_init_data_ptr); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | #endif // EbMotionEstimationResults_h 38 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPacketizationProcess.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbPacketization_h 7 | #define EbPacketization_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbSystemResourceManager.h" 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | /************************************** 16 | * Context 17 | **************************************/ 18 | typedef struct PacketizationContext 19 | { 20 | EbFifo *entropy_coding_input_fifo_ptr; 21 | EbFifo *rate_control_tasks_output_fifo_ptr; 22 | uint64_t dpb_disp_order[8]; 23 | uint64_t dpb_dec_order[8]; 24 | uint64_t tot_shown_frames; 25 | uint64_t disp_order_continuity_count; 26 | } PacketizationContext; 27 | 28 | /************************************** 29 | * Extern Function Declarations 30 | **************************************/ 31 | extern EbErrorType eb_vp9_packetization_context_ctor( 32 | PacketizationContext **context_dbl_ptr, 33 | EbFifo *entropy_coding_input_fifo_ptr, 34 | EbFifo *rate_control_tasks_output_fifo_ptr); 35 | 36 | extern void* eb_vp9_packetization_kernel(void *input_ptr); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | #endif // EbPacketization_h 42 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPacketizationReorderQueue.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | #include "EbPacketizationReorderQueue.h" 8 | 9 | EbErrorType eb_vp9_packetization_reorder_entry_ctor( 10 | PacketizationReorderEntry **entry_dbl_ptr, 11 | uint32_t picture_number) 12 | { 13 | EB_MALLOC(PacketizationReorderEntry*, *entry_dbl_ptr, sizeof(PacketizationReorderEntry), EB_N_PTR); 14 | 15 | (*entry_dbl_ptr)->picture_number = picture_number; 16 | (*entry_dbl_ptr)->output_stream_wrapper_ptr = (EbObjectWrapper *)EB_NULL; 17 | 18 | return EB_ErrorNone; 19 | } 20 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPacketizationReorderQueue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbPacketizationReorderQueue_h 7 | #define EbPacketizationReorderQueue_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbSystemResourceManager.h" 11 | #include "EbPredictionStructure.h" 12 | 13 | #include "vp9_blockd.h" 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | /************************************************ 18 | * Packetization Reorder Queue Entry 19 | ************************************************/ 20 | typedef struct PacketizationReorderEntry 21 | { 22 | uint64_t picture_number; 23 | EbObjectWrapper *output_stream_wrapper_ptr; 24 | 25 | uint64_t start_time_seconds; 26 | uint64_t start_timeu_seconds; 27 | 28 | FRAME_TYPE frame_type; 29 | uint8_t intra_only; 30 | uint64_t poc; 31 | uint64_t total_num_bits; 32 | 33 | uint8_t slice_type; 34 | uint64_t ref_poc_list0; 35 | uint64_t ref_poc_list1; 36 | RpsNode ref_signal; 37 | EB_BOOL show_frame; 38 | int show_existing_frame; 39 | uint8_t show_existing_frame_index_array[4]; 40 | uint64_t actual_bits; 41 | } PacketizationReorderEntry; 42 | 43 | extern EbErrorType eb_vp9_packetization_reorder_entry_ctor( 44 | PacketizationReorderEntry **entry_dbl_ptr, 45 | uint32_t picture_number); 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | #endif //EbPacketizationReorderQueue_h 51 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureAnalysisResults.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | 8 | #include "EbPictureAnalysisResults.h" 9 | 10 | EbErrorType eb_vp9_picture_analysis_result_ctor( 11 | EbPtr *object_dbl_ptr, 12 | EbPtr object_init_data_ptr) 13 | { 14 | PictureAnalysisResults *object_ptr; 15 | EB_MALLOC(PictureAnalysisResults*, object_ptr, sizeof(PictureAnalysisResults), EB_N_PTR); 16 | 17 | *object_dbl_ptr = (EbPtr) object_ptr; 18 | object_init_data_ptr = 0; 19 | (void) object_init_data_ptr; 20 | 21 | return EB_ErrorNone; 22 | } 23 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureAnalysisResults.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbPictureAnalysisResults_h 7 | #define EbPictureAnalysisResults_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbSystemResourceManager.h" 11 | 12 | /************************************** 13 | * Process Results 14 | **************************************/ 15 | typedef struct PictureAnalysisResults { 16 | EbObjectWrapper *picture_control_set_wrapper_ptr; 17 | } PictureAnalysisResults; 18 | 19 | typedef struct PictureAnalysisResultInitData { 20 | int junk; 21 | } PictureAnalysisResultInitData; 22 | 23 | /************************************** 24 | * Extern Function Declarations 25 | **************************************/ 26 | extern EbErrorType eb_vp9_picture_analysis_result_ctor( 27 | EbPtr *object_dbl_ptr, 28 | EbPtr object_init_data_ptr); 29 | 30 | #endif //EbPictureAnalysisResults_h 31 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureDecisionProcess.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbPictureDecision_h 7 | #define EbPictureDecision_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbSystemResourceManager.h" 11 | 12 | /************************************** 13 | * Context 14 | **************************************/ 15 | typedef struct PictureDecisionContext 16 | { 17 | EbFifo *picture_analysis_results_input_fifo_ptr; 18 | EbFifo *picture_decision_results_output_fifo_ptr; 19 | 20 | uint64_t last_solid_color_frame_poc; 21 | 22 | EB_BOOL reset_running_avg; 23 | 24 | uint32_t **ahd_running_avg_cb; 25 | uint32_t **ahd_running_avg_cr; 26 | uint32_t **ahd_running_avg; 27 | 28 | // Dynamic GOP 29 | uint32_t total_region_activity_cost[MAX_NUMBER_OF_REGIONS_IN_WIDTH][MAX_NUMBER_OF_REGIONS_IN_HEIGHT]; 30 | 31 | uint32_t total_number_of_mini_gops; 32 | 33 | uint32_t mini_gop_start_index[MINI_GOP_WINDOW_MAX_COUNT]; 34 | uint32_t mini_gop_end_index[MINI_GOP_WINDOW_MAX_COUNT]; 35 | uint32_t mini_gop_length[MINI_GOP_WINDOW_MAX_COUNT]; 36 | uint32_t mini_gop_intra_count[MINI_GOP_WINDOW_MAX_COUNT]; 37 | uint32_t mini_gop_idr_count[MINI_GOP_WINDOW_MAX_COUNT]; 38 | uint32_t mini_gop_hierarchical_levels[MINI_GOP_WINDOW_MAX_COUNT]; 39 | EB_BOOL mini_gop_activity_array[MINI_GOP_MAX_COUNT]; 40 | EB_BOOL mini_gop_toggle; // mini GOP toggling since last Key Frame K-0-1-0-1-0-K-0-1-0-1-K-0-1..... 41 | 42 | } PictureDecisionContext; 43 | 44 | /*************************************** 45 | * Extern Function Declaration 46 | ***************************************/ 47 | extern EbErrorType eb_vp9_picture_decision_context_ctor( 48 | PictureDecisionContext **context_dbl_ptr, 49 | EbFifo *picture_analysis_results_input_fifo_ptr, 50 | EbFifo *picture_decision_results_output_fifo_ptr); 51 | 52 | extern void* eb_vp9_picture_decision_kernel(void *input_ptr); 53 | 54 | #endif // EbPictureDecision_h 55 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureDecisionQueue.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | #include "EbPictureDecisionQueue.h" 8 | 9 | EbErrorType eb_vp9_pa_eb_vp9_reference_queue_entry_ctor( 10 | PaReferenceQueueEntry **entry_dbl_ptr) 11 | { 12 | PaReferenceQueueEntry *entry_ptr; 13 | EB_MALLOC(PaReferenceQueueEntry*, entry_ptr, sizeof(PaReferenceQueueEntry), EB_N_PTR); 14 | *entry_dbl_ptr = entry_ptr; 15 | 16 | entry_ptr->input_object_ptr = (EbObjectWrapper*) EB_NULL; 17 | entry_ptr->picture_number = 0; 18 | entry_ptr->reference_entry_index = 0; 19 | entry_ptr->dependent_count = 0; 20 | entry_ptr->list0_ptr = (ReferenceList*) EB_NULL; 21 | entry_ptr->list1_ptr = (ReferenceList*) EB_NULL; 22 | EB_MALLOC(int32_t*, entry_ptr->list0.list, sizeof(int32_t) * (1 << MAX_TEMPORAL_LAYERS) , EB_N_PTR); 23 | 24 | EB_MALLOC(int32_t*, entry_ptr->list1.list, sizeof(int32_t) * (1 << MAX_TEMPORAL_LAYERS) , EB_N_PTR); 25 | 26 | return EB_ErrorNone; 27 | } 28 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureDecisionQueue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbPictureDecisionQueue_h 7 | #define EbPictureDecisionQueue_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbSei.h" 11 | #include "EbDefinitions.h" 12 | #include "EbSystemResourceManager.h" 13 | #include "EbPredictionStructure.h" 14 | #include "EbApiSei.h" 15 | #include"EbPictureControlSet.h" 16 | /************************************************ 17 | * PA Reference Queue Entry 18 | ************************************************/ 19 | typedef struct PaReferenceQueueEntry 20 | { 21 | EbObjectWrapper *input_object_ptr; 22 | uint64_t picture_number; 23 | uint32_t dependent_count; 24 | uint32_t reference_entry_index; 25 | ReferenceList *list0_ptr; 26 | ReferenceList *list1_ptr; 27 | uint32_t dep_list0_count; 28 | uint32_t dep_list1_count; 29 | DependentList list0; 30 | DependentList list1; 31 | PictureParentControlSet *p_pcs_ptr; 32 | 33 | } PaReferenceQueueEntry; 34 | 35 | extern EbErrorType eb_vp9_pa_eb_vp9_reference_queue_entry_ctor( 36 | PaReferenceQueueEntry **entry_dbl_ptr); 37 | 38 | #endif // EbPictureDecisionQueue_h 39 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureDecisionReorderQueue.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | #include "EbPictureManagerReorderQueue.h" 8 | 9 | EbErrorType eb_vp9_picture_manager_reorder_entry_ctor( 10 | PictureManagerReorderEntry **entry_dbl_ptr, 11 | uint32_t picture_number) 12 | { 13 | EB_MALLOC(PictureManagerReorderEntry*, *entry_dbl_ptr, sizeof(PictureManagerReorderEntry), EB_N_PTR); 14 | 15 | (*entry_dbl_ptr)->picture_number = picture_number; 16 | (*entry_dbl_ptr)->parent_pcs_wrapper_ptr = (EbObjectWrapper *)EB_NULL; 17 | 18 | return EB_ErrorNone; 19 | } 20 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureDecisionReorderQueue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbPictureDecisionReorderQueue_h 7 | #define EbPictureDecisionReorderQueue_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbSystemResourceManager.h" 11 | 12 | /************************************************ 13 | * Packetization Reorder Queue Entry 14 | ************************************************/ 15 | typedef struct PictureDecisionReorderEntry 16 | { 17 | uint64_t picture_number; 18 | EbObjectWrapper *parent_pcs_wrapper_ptr; 19 | 20 | } PictureDecisionReorderEntry; 21 | 22 | extern EbErrorType eb_vp9_picture_decision_reorder_entry_ctor( 23 | PictureDecisionReorderEntry **entry_dbl_ptr, 24 | uint32_t picture_number); 25 | 26 | #endif //EbPictureDecisionReorderQueue_h 27 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureDecisionResults.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | 8 | #include "EbPictureDecisionResults.h" 9 | 10 | EbErrorType eb_vp9_picture_decision_result_ctor( 11 | EbPtr *object_dbl_ptr, 12 | EbPtr object_init_data_ptr) 13 | { 14 | PictureDecisionResults *object_ptr; 15 | EB_MALLOC(PictureDecisionResults *, object_ptr, sizeof(PictureDecisionResults), EB_N_PTR); 16 | 17 | *object_dbl_ptr = (EbPtr) object_ptr; 18 | object_init_data_ptr = 0; 19 | (void) object_init_data_ptr; 20 | 21 | return EB_ErrorNone; 22 | } 23 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureDecisionResults.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbPictureDecisionResults_h 7 | #define EbPictureDecisionResults_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbSystemResourceManager.h" 11 | 12 | /************************************** 13 | * Process Results 14 | **************************************/ 15 | typedef struct PictureDecisionResults 16 | { 17 | EbObjectWrapper *picture_control_set_wrapper_ptr; 18 | uint32_t segment_index; 19 | 20 | } PictureDecisionResults; 21 | 22 | typedef struct PictureDecisionResultInitData { 23 | int junk; 24 | } PictureDecisionResultInitData; 25 | 26 | /************************************** 27 | * Extern Function Declarations 28 | **************************************/ 29 | extern EbErrorType eb_vp9_picture_decision_result_ctor( 30 | EbPtr *object_dbl_ptr, 31 | EbPtr object_init_data_ptr); 32 | 33 | #endif //EbPictureDecisionResults_h 34 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureDemuxResults.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | #include "EbPictureDemuxResults.h" 8 | 9 | EbErrorType eb_vp9_picture_results_ctor( 10 | EbPtr *object_dbl_ptr, 11 | EbPtr object_init_data_ptr) 12 | { 13 | PictureDemuxResults *object_ptr; 14 | EB_MALLOC(PictureDemuxResults*, object_ptr, sizeof(PictureDemuxResults), EB_N_PTR); 15 | 16 | *object_dbl_ptr = object_ptr; 17 | 18 | object_ptr->picture_type = EB_PIC_INVALID; 19 | object_ptr->picture_control_set_wrapper_ptr = 0; 20 | object_ptr->reference_picture_wrapper_ptr = 0; 21 | object_ptr->picture_number = 0; 22 | 23 | (void) object_init_data_ptr; 24 | 25 | return EB_ErrorNone; 26 | } 27 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureDemuxResults.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbPictureResults_h 7 | #define EbPictureResults_h 8 | 9 | #include "EbSystemResourceManager.h" 10 | 11 | /************************************** 12 | * Enums 13 | **************************************/ 14 | typedef enum EbPicType 15 | { 16 | EB_PIC_INVALID = 0, 17 | EB_PIC_INPUT = 1, 18 | EB_PIC_REFERENCE = 2 19 | 20 | } EbPicType; 21 | 22 | /************************************** 23 | * Picture Demux Results 24 | **************************************/ 25 | typedef struct PictureDemuxResults 26 | { 27 | EbPicType picture_type; 28 | 29 | // Only valid for input pictures 30 | EbObjectWrapper *picture_control_set_wrapper_ptr; 31 | 32 | // Only valid for reference pictures 33 | EbObjectWrapper *reference_picture_wrapper_ptr; 34 | EbObjectWrapper *sequence_control_set_wrapper_ptr; 35 | uint64_t picture_number; 36 | 37 | } PictureDemuxResults; 38 | 39 | typedef struct PictureResultInitData { 40 | int junk; 41 | } PictureResultInitData; 42 | 43 | /************************************** 44 | * Extern Function Declarations 45 | **************************************/ 46 | extern EbErrorType eb_vp9_picture_results_ctor( 47 | EbPtr *object_dbl_ptr, 48 | EbPtr object_init_data_ptr); 49 | 50 | #endif //EbPictureResults_h 51 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureManagerProcess.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbPictureManager_h 7 | #define EbPictureManager_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbSystemResourceManager.h" 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | /*************************************** 15 | * Context 16 | ***************************************/ 17 | typedef struct PictureManagerContext 18 | { 19 | EbFifo *picture_input_fifo_ptr; 20 | EbFifo *picture_manager_output_fifo_ptr; 21 | EbFifo **picture_control_set_fifo_ptr_array; 22 | 23 | } PictureManagerContext; 24 | 25 | /*************************************** 26 | * Extern Function Declaration 27 | ***************************************/ 28 | extern EbErrorType eb_vp9_picture_manager_context_ctor( 29 | PictureManagerContext **context_dbl_ptr, 30 | EbFifo *picture_input_fifo_ptr, 31 | EbFifo *picture_manager_output_fifo_ptr, 32 | EbFifo **picture_control_set_fifo_ptr_array); 33 | 34 | extern void* eb_vp9_PictureManagerKernel(void *input_ptr); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | #endif // EbPictureManager_h 40 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureManagerQueue.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | #include "EbPictureManagerQueue.h" 8 | 9 | EbErrorType eb_vp9_input_queue_entry_ctor( 10 | InputQueueEntry **entry_dbl_ptr) 11 | { 12 | InputQueueEntry *entry_ptr; 13 | EB_MALLOC(InputQueueEntry*, entry_ptr, sizeof(InputQueueEntry), EB_N_PTR); 14 | *entry_dbl_ptr = entry_ptr; 15 | 16 | entry_ptr->input_object_ptr = (EbObjectWrapper*) EB_NULL; 17 | entry_ptr->reference_entry_index = 0; 18 | entry_ptr->dependent_count = 0; 19 | 20 | entry_ptr->list0_ptr = (ReferenceList*) EB_NULL; 21 | entry_ptr->list1_ptr = (ReferenceList*) EB_NULL; 22 | 23 | return EB_ErrorNone; 24 | } 25 | 26 | EbErrorType eb_vp9_reference_queue_entry_ctor( 27 | ReferenceQueueEntry **entry_dbl_ptr) 28 | { 29 | ReferenceQueueEntry *entry_ptr; 30 | EB_MALLOC(ReferenceQueueEntry*, entry_ptr, sizeof(ReferenceQueueEntry), EB_N_PTR); 31 | *entry_dbl_ptr = entry_ptr; 32 | 33 | entry_ptr->reference_object_ptr = (EbObjectWrapper*) EB_NULL; 34 | entry_ptr->picture_number = ~0u; 35 | entry_ptr->dependent_count = 0; 36 | entry_ptr->reference_available = EB_FALSE; 37 | 38 | EB_MALLOC(int32_t*, entry_ptr->list0.list, sizeof(int32_t) * (1 << MAX_TEMPORAL_LAYERS) , EB_N_PTR); 39 | 40 | EB_MALLOC(int32_t*, entry_ptr->list1.list, sizeof(int32_t) * (1 << MAX_TEMPORAL_LAYERS) , EB_N_PTR); 41 | 42 | return EB_ErrorNone; 43 | } 44 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureManagerQueue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbPictureManagerQueue_h 7 | #define EbPictureManagerQueue_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbSei.h" 11 | #include "EbDefinitions.h" 12 | #include "EbSystemResourceManager.h" 13 | #include "EbPredictionStructure.h" 14 | #include "EbApiSei.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | /************************************************ 20 | * Input Queue Entry 21 | ************************************************/ 22 | struct ReferenceQueueEntry; // empty struct definition 23 | 24 | typedef struct InputQueueEntry 25 | { 26 | EbObjectWrapper *input_object_ptr; 27 | uint32_t dependent_count; 28 | uint32_t reference_entry_index; 29 | ReferenceList *list0_ptr; 30 | ReferenceList *list1_ptr; 31 | 32 | } InputQueueEntry; 33 | 34 | /************************************************ 35 | * Reference Queue Entry 36 | ************************************************/ 37 | typedef struct ReferenceQueueEntry 38 | { 39 | 40 | uint64_t picture_number; 41 | uint64_t decode_order; 42 | EbObjectWrapper *reference_object_ptr; 43 | uint32_t dependent_count; 44 | EB_BOOL release_enable; 45 | EB_BOOL reference_available; 46 | uint32_t dep_list0_count; 47 | uint32_t dep_list1_count; 48 | DependentList list0; 49 | DependentList list1; 50 | EB_BOOL is_used_as_reference_flag; 51 | EB_BOOL feedback_arrived; 52 | } ReferenceQueueEntry; 53 | 54 | /************************************************ 55 | * Rate Control Input Queue Entry 56 | ************************************************/ 57 | 58 | typedef struct RcInputQueueEntry 59 | { 60 | uint64_t picture_number; 61 | EbObjectWrapper *input_object_ptr; 62 | EB_BOOL release_enabled; 63 | uint32_t gop_index; 64 | 65 | } RcInputQueueEntry; 66 | 67 | /************************************************ 68 | * Rate Control FeedBack Queue Entry 69 | ************************************************/ 70 | typedef struct RcFeedbackQueueEntry 71 | { 72 | uint64_t picture_number; 73 | EB_BOOL release_enabled; 74 | uint32_t gop_index; 75 | 76 | } RcFeedbackQueueEntry; 77 | 78 | extern EbErrorType eb_vp9_input_queue_entry_ctor( 79 | InputQueueEntry **entry_dbl_ptr); 80 | 81 | extern EbErrorType eb_vp9_reference_queue_entry_ctor( 82 | ReferenceQueueEntry **entry_dbl_ptr); 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | #endif // EbPictureManagerQueue_h 88 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureManagerReorderQueue.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | #include "EbPictureDecisionReorderQueue.h" 8 | 9 | EbErrorType eb_vp9_picture_decision_reorder_entry_ctor( 10 | PictureDecisionReorderEntry **entry_dbl_ptr, 11 | uint32_t picture_number) 12 | { 13 | EB_MALLOC(PictureDecisionReorderEntry*, *entry_dbl_ptr, sizeof(PictureDecisionReorderEntry), EB_N_PTR); 14 | 15 | (*entry_dbl_ptr)->picture_number = picture_number; 16 | (*entry_dbl_ptr)->parent_pcs_wrapper_ptr = (EbObjectWrapper *)EB_NULL; 17 | 18 | return EB_ErrorNone; 19 | } 20 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureManagerReorderQueue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbPictureManagerReorderQueue_h 7 | #define EbPictureManagerReorderQueue_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbSystemResourceManager.h" 11 | 12 | /************************************************ 13 | * Packetization Reorder Queue Entry 14 | ************************************************/ 15 | typedef struct PictureManagerReorderEntry 16 | { 17 | uint64_t picture_number; 18 | EbObjectWrapper *parent_pcs_wrapper_ptr; 19 | } PictureManagerReorderEntry; 20 | 21 | extern EbErrorType eb_vp9_picture_manager_reorder_entry_ctor( 22 | PictureManagerReorderEntry **entry_dbl_ptr, 23 | uint32_t picture_number); 24 | 25 | #endif //EbPictureManagerReorderQueue_h 26 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbRateControlResults.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | 8 | #include "EbDefinitions.h" 9 | #include "EbRateControlResults.h" 10 | 11 | EbErrorType eb_vp9_rate_control_results_ctor( 12 | EbPtr *object_dbl_ptr, 13 | EbPtr object_init_data_ptr) 14 | { 15 | RateControlResults *context_ptr; 16 | EB_MALLOC(RateControlResults*, context_ptr, sizeof(RateControlResults), EB_N_PTR); 17 | *object_dbl_ptr = (EbPtr) context_ptr; 18 | 19 | object_init_data_ptr = 0; 20 | 21 | (void) object_init_data_ptr; 22 | 23 | return EB_ErrorNone; 24 | } 25 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbRateControlResults.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbRateControlResults_h 7 | #define EbRateControlResults_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbSystemResourceManager.h" 11 | #include "EbPictureControlSet.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | /************************************** 16 | * Process Results 17 | **************************************/ 18 | typedef struct RateControlResults { 19 | EbObjectWrapper *picture_control_set_wrapper_ptr; 20 | } RateControlResults; 21 | 22 | typedef struct RateControlResultsInitData { 23 | int junk; 24 | } RateControlResultsInitData; 25 | 26 | /************************************** 27 | * Extern Function Declarations 28 | **************************************/ 29 | extern EbErrorType eb_vp9_rate_control_results_ctor( 30 | EbPtr *object_dbl_ptr, 31 | EbPtr object_init_data_ptr); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | #endif // EbRateControlResults_h 37 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbRateControlTables.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbRateControlTables_h 7 | #define EbRateControlTables_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbDefinitions.h" 11 | #include "EbUtility.h" 12 | 13 | /************************************** 14 | * Rate Control Defines 15 | **************************************/ 16 | #define SAD_PRECISION_INTERVAL 4 17 | 18 | #define VAR_ROUND_INTERVAL 20 19 | #define NUMBER_OF_SAD_INTERVALS 128 // number of intervals in SAD tables 20 | 21 | #define NUMBER_OF_INTRA_SAD_INTERVALS NUMBER_OF_SAD_INTERVALS // number of intervals in intra Sad tables 22 | 23 | #define TOTAL_NUMBER_OF_INTERVALS (NUMBER_OF_SAD_INTERVALS + \ 24 | NUMBER_OF_INTRA_SAD_INTERVALS ) 25 | 26 | #define TOTAL_NUMBER_OF_REF_QP_VALUES 64 27 | 28 | #define TOTAL_NUMBER_OF_INITIAL_RC_TABLES_ENTRY (TOTAL_NUMBER_OF_REF_QP_VALUES) 29 | 30 | /************************************** 31 | * The EB_BitFraction is used to define the bit fraction numbers 32 | **************************************/ 33 | typedef uint16_t EbBitNumber; 34 | 35 | /************************************** 36 | * Initial Rate Control Structure 37 | **************************************/ 38 | typedef struct InitialRateControlTables 39 | { 40 | EbBitNumber sad_bits_array [MAX_TEMPORAL_LAYERS][NUMBER_OF_SAD_INTERVALS]; 41 | EbBitNumber intra_sad_bits_array [MAX_TEMPORAL_LAYERS][NUMBER_OF_INTRA_SAD_INTERVALS]; 42 | } RateControlTables; 43 | /************************************** 44 | * Extern Function Declarations 45 | **************************************/ 46 | extern EbErrorType rate_control_tables_ctor( 47 | RateControlTables *rate_control_tables_array 48 | ); 49 | 50 | #endif //EbRateControlTables_h 51 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbRateControlTasks.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | 8 | #include "EbDefinitions.h" 9 | #include "EbRateControlTasks.h" 10 | 11 | EbErrorType eb_vp9_rate_control_tasks_ctor( 12 | EbPtr *object_dbl_ptr, 13 | EbPtr object_init_data_ptr) 14 | { 15 | RateControlTasks *context_ptr; 16 | EB_MALLOC(RateControlTasks*, context_ptr, sizeof(RateControlTasks), EB_N_PTR); 17 | 18 | *object_dbl_ptr = (EbPtr) context_ptr; 19 | object_init_data_ptr = EB_NULL; 20 | 21 | (void) object_init_data_ptr; 22 | 23 | return EB_ErrorNone; 24 | } 25 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbRateControlTasks.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbRateControlTasks_h 7 | #define EbRateControlTasks_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbSystemResourceManager.h" 11 | #include "EbPictureControlSet.h" 12 | 13 | /************************************** 14 | * Tasks Types 15 | **************************************/ 16 | typedef enum RateControlTaskTypes 17 | { 18 | RC_PICTURE_MANAGER_RESULT, 19 | RC_PACKETIZATION_FEEDBACK_RESULT, 20 | RC_ENTROPY_CODING_ROW_FEEDBACK_RESULT, 21 | RC_INVALID_TASK 22 | } RateControlTaskTypes; 23 | 24 | /************************************** 25 | * Process Results 26 | **************************************/ 27 | typedef struct RateControlTasks 28 | { 29 | RateControlTaskTypes task_type; 30 | EbObjectWrapper *picture_control_set_wrapper_ptr; 31 | uint32_t segment_index; 32 | 33 | // Following are valid for RC_ENTROPY_CODING_ROW_FEEDBACK_RESULT only 34 | uint64_t picture_number; 35 | uint32_t row_number; 36 | uint32_t bit_count; 37 | 38 | } RateControlTasks; 39 | 40 | typedef struct RateControlTasksInitData { 41 | int junk; 42 | } RateControlTasksInitData; 43 | 44 | /************************************** 45 | * Extern Function Declarations 46 | **************************************/ 47 | extern EbErrorType eb_vp9_rate_control_tasks_ctor( 48 | EbPtr *object_dbl_ptr, 49 | EbPtr object_init_data_ptr); 50 | 51 | #endif // EbRateControlTasks_h 52 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbReferenceObject.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbReferenceObject_h 7 | #define EbReferenceObject_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbDefinitions.h" 11 | #include "EbPictureControlSet.h" 12 | 13 | typedef struct EbReferenceObject 14 | { 15 | EbPictureBufferDesc *reference_picture; 16 | EbPictureBufferDesc *reference_picture16bit; 17 | EbPictureBufferDesc *ref_den_src_picture; 18 | 19 | uint64_t ref_poc; 20 | 21 | uint8_t qp; 22 | EB_SLICE slice_type; 23 | 24 | uint32_t non_moving_index_array[MAX_NUMBER_OF_TREEBLOCKS_PER_PICTURE];//array to hold non-moving blocks in reference frames 25 | 26 | uint8_t tmp_layer_idx; 27 | EB_BOOL is_scene_change; 28 | uint16_t pic_avg_variance; 29 | uint8_t average_intensity; 30 | 31 | } EbReferenceObject; 32 | 33 | typedef struct EbReferenceObjectDescInitData { 34 | EbPictureBufferDescInitData reference_picture_desc_init_data; 35 | } EbReferenceObjectDescInitData; 36 | 37 | typedef struct EbPaReferenceObject 38 | { 39 | EbPictureBufferDesc *input_padded_picture_ptr; 40 | EbPictureBufferDesc *quarter_decimated_picture_ptr; 41 | EbPictureBufferDesc *sixteenth_decimated_picture_ptr; 42 | uint16_t variance[MAX_NUMBER_OF_TREEBLOCKS_PER_PICTURE]; 43 | uint8_t y_mean[MAX_NUMBER_OF_TREEBLOCKS_PER_PICTURE]; 44 | EB_SLICE slice_type; 45 | uint32_t dependent_pictures_count; //number of pic using this reference frame 46 | PictureParentControlSet *p_pcs_ptr; 47 | 48 | } EbPaReferenceObject; 49 | 50 | typedef struct EbPaReferenceObjectDescInitData 51 | { 52 | EbPictureBufferDescInitData reference_picture_desc_init_data; 53 | EbPictureBufferDescInitData quarter_picture_desc_init_data; 54 | EbPictureBufferDescInitData sixteenth_picture_desc_init_data; 55 | } EbPaReferenceObjectDescInitData; 56 | 57 | /************************************** 58 | * Extern Function Declarations 59 | **************************************/ 60 | extern EbErrorType eb_vp9_reference_object_ctor( 61 | EbPtr *object_dbl_ptr, 62 | EbPtr object_init_data_ptr); 63 | 64 | extern EbErrorType eb_vp9_pa_reference_object_ctor( 65 | EbPtr *object_dbl_ptr, 66 | EbPtr object_init_data_ptr); 67 | 68 | #endif //EbReferenceObject_h 69 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbResourceCoordinationResults.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | 8 | #include "EbResourceCoordinationResults.h" 9 | 10 | EbErrorType eb_vp9_resource_coordination_result_ctor( 11 | EbPtr *object_dbl_ptr, 12 | EbPtr object_init_data_ptr) 13 | { 14 | ResourceCoordinationResults *object_ptr; 15 | EB_MALLOC(ResourceCoordinationResults*, object_ptr, sizeof(ResourceCoordinationResults), EB_N_PTR); 16 | 17 | *object_dbl_ptr = object_ptr; 18 | 19 | object_init_data_ptr = 0; 20 | (void)object_init_data_ptr; 21 | 22 | return EB_ErrorNone; 23 | } 24 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbResourceCoordinationResults.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbResourceCoordinationResults_h 7 | #define EbResourceCoordinationResults_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbSystemResourceManager.h" 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | /************************************** 15 | * Process Results 16 | **************************************/ 17 | typedef struct ResourceCoordinationResults { 18 | EbObjectWrapper *picture_control_set_wrapper_ptr; 19 | } ResourceCoordinationResults; 20 | 21 | typedef struct ResourceCoordinationResultInitData { 22 | int junk; 23 | } ResourceCoordinationResultInitData; 24 | 25 | /************************************** 26 | * Extern Function Declarations 27 | **************************************/ 28 | extern EbErrorType eb_vp9_resource_coordination_result_ctor( 29 | EbPtr *object_dbl_ptr, 30 | EbPtr object_init_data_ptr); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | #endif //EbResourceCoordinationResults_h 36 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbSei.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EBSEI_h 7 | #define EBSEI_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbApiSei.h" 11 | #include "EbDefinitions.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | extern EbErrorType eb_video_usability_info_ctor( 16 | AppVideoUsabilityInfo *vui_ptr); 17 | 18 | extern void eb_video_usability_info_copy( 19 | AppVideoUsabilityInfo *dst_vui_ptr, 20 | AppVideoUsabilityInfo *src_vui_ptr); 21 | 22 | extern void eb_picture_timeing_sei_ctor( 23 | AppPictureTimingSei *pic_timing_ptr); 24 | 25 | extern void eb_buffering_period_sei_ctor( 26 | AppBufferingPeriodSei *buffering_period_ptr); 27 | 28 | extern void eb_recovery_point_sei_ctor( 29 | AppRecoveryPoint *recovery_point_sei_ptr); 30 | 31 | extern uint32_t get_picture_timing_sei_length( 32 | AppPictureTimingSei *pic_timing_sei_ptr, 33 | AppVideoUsabilityInfo *vui_ptr); 34 | 35 | extern uint32_t get_buf_period_sei_length( 36 | AppBufferingPeriodSei *buffering_period_ptr, 37 | AppVideoUsabilityInfo *vui_ptr); 38 | 39 | extern uint32_t get_recovery_point_sei_length( 40 | AppRecoveryPoint *recovery_point_sei_ptr); 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | #endif // EBSEI_h 45 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbSourceBasedOperationsProcess.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbSourceBasedOperations_h 7 | #define EbSourceBasedOperations_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbSystemResourceManager.h" 11 | #include "EbNoiseExtractAVX2.h" 12 | 13 | /************************************** 14 | * Context 15 | **************************************/ 16 | 17 | typedef struct SourceBasedOperationsContext 18 | { 19 | EbFifo *initial_rate_control_results_input_fifo_ptr; 20 | EbFifo *picture_demux_results_output_fifo_ptr; 21 | 22 | // local zz cost array 23 | uint32_t picture_num_grass_sb; 24 | uint32_t high_contrast_num; 25 | 26 | EB_BOOL high_dist; 27 | uint8_t *y_mean_ptr; 28 | uint8_t *cr_mean_ptr; 29 | uint8_t *cb_mean_ptr; 30 | 31 | } SourceBasedOperationsContext; 32 | 33 | /*************************************** 34 | * Extern Function Declaration 35 | ***************************************/ 36 | 37 | extern EbErrorType eb_vp9_source_based_operations_context_ctor( 38 | SourceBasedOperationsContext **context_dbl_ptr, 39 | EbFifo *initial_rate_control_results_input_fifo_ptr, 40 | EbFifo *picture_demux_results_output_fifo_ptr); 41 | 42 | extern void* eb_vp9_source_based_operations_kernel(void *input_ptr); 43 | 44 | #endif // EbSourceBasedOperations_h 45 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbSyntaxElements.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbSyntaxElements_h 7 | #define EbSyntaxElements_h 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | typedef enum NalRefIdc 12 | { 13 | NAL_REF_IDC_PRIORITY_LOWEST = 0, 14 | NAL_REF_IDC_PRIORITY_LOW, 15 | NAL_REF_IDC_PRIORITY_HIGH, 16 | NAL_REF_IDC_PRIORITY_HIGHEST 17 | } NalRefIdc; 18 | 19 | #define EB_INTRA_PLANAR 0 20 | #define EB_INTRA_DC 1 21 | #define EB_INTRA_MODE_2 2 22 | #define EB_INTRA_MODE_3 3 23 | #define EB_INTRA_MODE_4 4 24 | #define EB_INTRA_MODE_5 5 25 | #define EB_INTRA_MODE_6 6 26 | #define EB_INTRA_MODE_7 7 27 | #define EB_INTRA_MODE_8 8 28 | #define EB_INTRA_MODE_9 9 29 | #define EB_INTRA_HORIZONTAL 10 30 | #define EB_INTRA_MODE_11 11 31 | #define EB_INTRA_MODE_12 12 32 | #define EB_INTRA_MODE_13 13 33 | #define EB_INTRA_MODE_14 14 34 | #define EB_INTRA_MODE_15 15 35 | #define EB_INTRA_MODE_16 16 36 | #define EB_INTRA_MODE_17 17 37 | #define EB_INTRA_MODE_18 18 38 | #define EB_INTRA_MODE_19 19 39 | #define EB_INTRA_MODE_20 20 40 | #define EB_INTRA_MODE_21 21 41 | #define EB_INTRA_MODE_22 22 42 | #define EB_INTRA_MODE_23 23 43 | #define EB_INTRA_MODE_24 24 44 | #define EB_INTRA_MODE_25 25 45 | #define EB_INTRA_VERTICAL 26 46 | #define EB_INTRA_MODE_27 27 47 | #define EB_INTRA_MODE_28 28 48 | #define EB_INTRA_MODE_29 29 49 | #define EB_INTRA_MODE_30 30 50 | #define EB_INTRA_MODE_31 31 51 | #define EB_INTRA_MODE_32 32 52 | #define EB_INTRA_MODE_33 33 53 | #define EB_INTRA_MODE_34 34 54 | #define EB_INTRA_MODE_35 35 55 | #define EB_INTRA_MODE_4x4 36 56 | #define EB_INTRA_MODE_INVALID ~0u 57 | 58 | #define EB_INTRA_CHROMA_PLANAR 0 59 | #define EB_INTRA_CHROMA_VERTICAL 1 60 | #define EB_INTRA_CHROMA_HORIZONTAL 2 61 | #define EB_INTRA_CHROMA_DC 3 62 | #define EB_INTRA_CHROMA_DM 4 63 | #define EB_INTRA_CHROMA_TOTAL_COUNT 5 64 | #define EB_INTRA_CHROMA_INVALID ~0u 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | #endif // EbSyntaxElements_h 70 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbTime.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifdef _WIN32 7 | #include 8 | #include 9 | #elif !defined(__USE_POSIX199309) 10 | #define __USE_POSIX199309 11 | #endif 12 | 13 | #include 14 | 15 | #if !defined(CLOCK_MONOTONIC) && !defined(_WIN32) 16 | #include 17 | #endif 18 | 19 | #include "EbTime.h" 20 | 21 | void svt_vp9_sleep(const int milliseconds) { 22 | if (!milliseconds) return; 23 | #ifdef _WIN32 24 | Sleep(milliseconds); 25 | #else 26 | nanosleep(&(struct timespec){milliseconds / 1000, 27 | (milliseconds % 1000) * 1000000}, 28 | NULL); 29 | #endif 30 | } 31 | 32 | double svt_vp9_compute_overall_elapsed_time_ms(const uint64_t start_seconds, 33 | const uint64_t start_useconds, 34 | const uint64_t finish_seconds, 35 | const uint64_t finish_useconds) { 36 | const int64_t s_diff = (int64_t)finish_seconds - (int64_t)start_seconds, 37 | u_diff = (int64_t)finish_useconds - (int64_t)start_useconds; 38 | return (double)s_diff * 1000.0 + (double)u_diff / 1000.0 + 0.5; 39 | } 40 | 41 | double svt_vp9_compute_overall_elapsed_time(const uint64_t start_seconds, 42 | const uint64_t start_useconds, 43 | const uint64_t finish_seconds, 44 | const uint64_t finish_useconds) { 45 | return svt_vp9_compute_overall_elapsed_time_ms( 46 | start_seconds, start_useconds, finish_seconds, finish_useconds) / 47 | 1000.0; 48 | } 49 | 50 | void svt_vp9_get_time(uint64_t *const seconds, uint64_t *const useconds) { 51 | #ifdef _WIN32 52 | struct _timeb curr_time; 53 | _ftime_s(&curr_time); 54 | *seconds = curr_time.time; 55 | *useconds = curr_time.millitm; 56 | #elif defined(CLOCK_MONOTONIC) 57 | struct timespec curr_time; 58 | clock_gettime(CLOCK_MONOTONIC, &curr_time); 59 | *seconds = curr_time.tv_sec; 60 | *useconds = curr_time.tv_nsec / 1000; 61 | #else 62 | struct timeval curr_time; 63 | gettimeofday(&curr_time, NULL); 64 | *seconds = curr_time.tv_sec; 65 | *useconds = curr_time.tv_usec; 66 | #endif 67 | } 68 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbTime.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbTime_h 7 | #define EbTime_h 8 | 9 | #include 10 | 11 | void svt_vp9_sleep(const int milliseconds); 12 | double svt_vp9_compute_overall_elapsed_time_ms(const uint64_t start_seconds, 13 | const uint64_t start_useconds, 14 | const uint64_t finish_seconds, 15 | const uint64_t finish_useconds); 16 | double svt_vp9_compute_overall_elapsed_time(const uint64_t start_seconds, 17 | const uint64_t start_useconds, 18 | const uint64_t finish_seconds, 19 | const uint64_t finish_useconds); 20 | void svt_vp9_get_time(uint64_t *const seconds, uint64_t *const useconds); 21 | 22 | #endif // EbTime_h 23 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbTransQuantBuffers.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include "EbDefinitions.h" 7 | #include "EbTransQuantBuffers.h" 8 | #include "EbPictureBufferDesc.h" 9 | 10 | EbErrorType eb_vp9_trans_quant_buffers_ctor( 11 | EbTransQuantBuffers *trans_quant_buffers_ptr) 12 | { 13 | EbErrorType return_error = EB_ErrorNone; 14 | EbPictureBufferDescInitData trans_coeff_init_array; 15 | 16 | trans_coeff_init_array.max_width = MAX_SB_SIZE; 17 | trans_coeff_init_array.max_height = MAX_SB_SIZE; 18 | trans_coeff_init_array.bit_depth = EB_16BIT; 19 | trans_coeff_init_array.buffer_enable_mask = PICTURE_BUFFER_DESC_FULL_MASK; 20 | trans_coeff_init_array.left_padding = 0; 21 | trans_coeff_init_array.right_padding = 0; 22 | trans_coeff_init_array.top_padding = 0; 23 | trans_coeff_init_array.bot_padding = 0; 24 | trans_coeff_init_array.split_mode = EB_FALSE; 25 | 26 | return_error = eb_vp9_picture_buffer_desc_ctor( 27 | (EbPtr *) &(trans_quant_buffers_ptr->tu_trans_coeff2_nx2_n_ptr), 28 | (EbPtr ) &trans_coeff_init_array); 29 | if (return_error == EB_ErrorInsufficientResources){ 30 | return EB_ErrorInsufficientResources; 31 | } 32 | 33 | return_error = eb_vp9_picture_buffer_desc_ctor( 34 | (EbPtr *) &(trans_quant_buffers_ptr->tu_trans_coeff_nx_n_ptr), 35 | (EbPtr ) &trans_coeff_init_array); 36 | if (return_error == EB_ErrorInsufficientResources){ 37 | return EB_ErrorInsufficientResources; 38 | } 39 | 40 | return_error = eb_vp9_picture_buffer_desc_ctor( 41 | (EbPtr *) &(trans_quant_buffers_ptr->tu_trans_coeff_n2x_n2_ptr), 42 | (EbPtr ) &trans_coeff_init_array); 43 | if (return_error == EB_ErrorInsufficientResources){ 44 | return EB_ErrorInsufficientResources; 45 | } 46 | return_error = eb_vp9_picture_buffer_desc_ctor( 47 | (EbPtr *) &(trans_quant_buffers_ptr->tu_quant_coeff_nx_n_ptr), 48 | (EbPtr ) &trans_coeff_init_array); 49 | if (return_error == EB_ErrorInsufficientResources){ 50 | return EB_ErrorInsufficientResources; 51 | } 52 | 53 | return_error = eb_vp9_picture_buffer_desc_ctor( 54 | (EbPtr *) &(trans_quant_buffers_ptr->tu_quant_coeff_n2x_n2_ptr), 55 | (EbPtr ) &trans_coeff_init_array); 56 | if (return_error == EB_ErrorInsufficientResources){ 57 | return EB_ErrorInsufficientResources; 58 | } 59 | 60 | return EB_ErrorNone; 61 | } 62 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbTransQuantBuffers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbTransQuantBuffers_h 7 | #define EbTransQuantBuffers_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbPictureBufferDesc.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | typedef struct EbTransQuantBuffers 16 | { 17 | EbPictureBufferDesc *tu_trans_coeff2_nx2_n_ptr; 18 | EbPictureBufferDesc *tu_trans_coeff_nx_n_ptr; 19 | EbPictureBufferDesc *tu_trans_coeff_n2x_n2_ptr; 20 | EbPictureBufferDesc *tu_quant_coeff_nx_n_ptr; 21 | EbPictureBufferDesc *tu_quant_coeff_n2x_n2_ptr; 22 | 23 | } EbTransQuantBuffers; 24 | 25 | extern EbErrorType eb_vp9_trans_quant_buffers_ctor( 26 | EbTransQuantBuffers *trans_quant_buffers_ptr); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | #endif // EbTransQuantBuffers_h 32 | -------------------------------------------------------------------------------- /Source/Lib/VPX/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ~~~ 2 | # Copyright(c) 2019 Intel Corporation 3 | # SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | # ~~~ 5 | 6 | # VPX Directory CMakeLists.txt 7 | 8 | # Include Encoder Subdirectories 9 | include_directories(${PROJECT_SOURCE_DIR}/Source/API 10 | ${PROJECT_SOURCE_DIR}/Source/Lib/Codec 11 | ${PROJECT_SOURCE_DIR}/Source/Lib/ASM_AVX2 12 | ${PROJECT_SOURCE_DIR}/Source/Lib/ASM_SSE2 13 | ${PROJECT_SOURCE_DIR}/Source/Lib/ASM_SSE4_1 14 | ${PROJECT_SOURCE_DIR}/Source/Lib/ASM_SSSE3 15 | ${PROJECT_SOURCE_DIR}/Source/Lib/C_DEFAULT 16 | ${PROJECT_SOURCE_DIR}/Source/Lib/VPX) 17 | 18 | file(GLOB 19 | all_vpx_files 20 | "*.h" 21 | "*.c") 22 | 23 | # VPX Source Files 24 | add_library(libVPX OBJECT ${all_vpx_files}) 25 | -------------------------------------------------------------------------------- /Source/Lib/VPX/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010, The WebM Project authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the 13 | distribution. 14 | 15 | * Neither the name of Google, nor the WebM Project, nor the names 16 | of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written 18 | permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /Source/Lib/VPX/bitops.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VPX_PORTS_BITOPS_H_ 12 | #define VPX_VPX_PORTS_BITOPS_H_ 13 | 14 | #define INLINE __inline 15 | 16 | #include 17 | #include 18 | 19 | #if defined(_WIN32) && (defined(_M_X64) || defined(_M_IX86)) 20 | #include 21 | #define USE_MSC_INTRINSICS 22 | #endif 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | // These versions of get_msb() are only valid when n != 0 because all 29 | // of the optimized versions are undefined when n == 0: 30 | // https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html 31 | 32 | // use GNU builtins where available. 33 | #if defined(__GNUC__) && \ 34 | ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4) 35 | static INLINE int get_msb(unsigned int n) { 36 | assert(n != 0); 37 | return 31 ^ __builtin_clz(n); 38 | } 39 | #elif defined(USE_MSC_INTRINSICS) 40 | #pragma intrinsic(_BitScanReverse) 41 | 42 | static INLINE int get_msb(unsigned int n) { 43 | unsigned long first_set_bit; 44 | assert(n != 0); 45 | _BitScanReverse(&first_set_bit, n); 46 | return first_set_bit; 47 | } 48 | #undef USE_MSC_INTRINSICS 49 | #else 50 | // Returns (int)floor(log2(n)). n must be > 0. 51 | static INLINE int get_msb(unsigned int n) { 52 | int log = 0; 53 | unsigned int value = n; 54 | int i; 55 | 56 | assert(n != 0); 57 | 58 | for (i = 4; i >= 0; --i) { 59 | const int shift = (1 << i); 60 | const unsigned int x = value >> shift; 61 | if (x != 0) { 62 | value = x; 63 | log += shift; 64 | } 65 | } 66 | return log; 67 | } 68 | #endif 69 | 70 | #ifdef __cplusplus 71 | } // extern "C" 72 | #endif 73 | 74 | #endif // VPX_VPX_PORTS_BITOPS_H_ 75 | -------------------------------------------------------------------------------- /Source/Lib/VPX/bitwriter.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "./bitwriter.h" 12 | 13 | void eb_vp9_start_encode(VpxWriter *br, uint8_t *source) { 14 | br->lowvalue = 0; 15 | br->range = 255; 16 | br->count = -24; 17 | br->buffer = source; 18 | br->pos = 0; 19 | vpx_write_bit(br, 0); 20 | } 21 | 22 | void eb_vp9_stop_encode(VpxWriter *br) { 23 | int i; 24 | 25 | for (i = 0; i < 32; i++) vpx_write_bit(br, 0); 26 | 27 | // Ensure there's no ambigous collision with any index marker bytes 28 | if ((br->buffer[br->pos - 1] & 0xe0) == 0xc0) br->buffer[br->pos++] = 0; 29 | } 30 | -------------------------------------------------------------------------------- /Source/Lib/VPX/bitwriter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VPX_DSP_BITWRITER_H_ 12 | #define VPX_VPX_DSP_BITWRITER_H_ 13 | 14 | #define INLINE __inline 15 | 16 | #include 17 | #include "prob.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | typedef struct VpxWriter { 24 | unsigned int lowvalue; 25 | unsigned int range; 26 | int count; 27 | unsigned int pos; 28 | uint8_t *buffer; 29 | } VpxWriter; 30 | 31 | void eb_vp9_start_encode(VpxWriter *bc, uint8_t *buffer); 32 | void eb_vp9_stop_encode(VpxWriter *bc); 33 | 34 | static INLINE void vpx_write(VpxWriter *br, int bit, int probability) { 35 | unsigned int split; 36 | int count = br->count; 37 | unsigned int range = br->range; 38 | unsigned int lowvalue = br->lowvalue; 39 | int shift; 40 | 41 | split = 1 + (((range - 1) * probability) >> 8); 42 | 43 | range = split; 44 | 45 | if (bit) { 46 | lowvalue += split; 47 | range = br->range - split; 48 | } 49 | 50 | shift = eb_vp9_norm[range]; 51 | 52 | range <<= shift; 53 | count += shift; 54 | 55 | if (count >= 0) { 56 | int offset = shift - count; 57 | 58 | if ((lowvalue << (offset - 1)) & 0x80000000) { 59 | int x = br->pos - 1; 60 | 61 | while (x >= 0 && br->buffer[x] == 0xff) { 62 | br->buffer[x] = 0; 63 | x--; 64 | } 65 | 66 | br->buffer[x] += 1; 67 | } 68 | 69 | br->buffer[br->pos++] = (uint8_t)((lowvalue >> (24 - offset))); 70 | lowvalue <<= offset; 71 | shift = count; 72 | lowvalue &= 0xffffff; 73 | count -= 8; 74 | } 75 | 76 | lowvalue <<= shift; 77 | br->count = count; 78 | br->lowvalue = lowvalue; 79 | br->range = range; 80 | } 81 | 82 | static INLINE void vpx_write_bit(VpxWriter *w, int bit) { 83 | vpx_write(w, bit, 128); // vpx_prob_half 84 | } 85 | 86 | static INLINE void vpx_write_literal(VpxWriter *w, int data, int bits) { 87 | int bit; 88 | 89 | for (bit = bits - 1; bit >= 0; bit--) vpx_write_bit(w, 1 & (data >> bit)); 90 | } 91 | 92 | #define vpx_write_prob(w, v) vpx_write_literal((w), (v), 8) 93 | 94 | #ifdef __cplusplus 95 | } // extern "C" 96 | #endif 97 | 98 | #endif // VPX_VPX_DSP_BITWRITER_H_ 99 | -------------------------------------------------------------------------------- /Source/Lib/VPX/bitwriter_buffer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #define INLINE __inline 15 | 16 | #include 17 | #include "bitwriter_buffer.h" 18 | 19 | size_t eb_vp9_wb_bytes_written(const struct vpx_write_bit_buffer *wb) { 20 | return wb->bit_offset / CHAR_BIT + (wb->bit_offset % CHAR_BIT > 0); 21 | } 22 | 23 | void eb_vp9_wb_write_bit(struct vpx_write_bit_buffer *wb, int bit) { 24 | const int off = (int)wb->bit_offset; 25 | const int p = off / CHAR_BIT; 26 | const int q = CHAR_BIT - 1 - off % CHAR_BIT; 27 | if (q == CHAR_BIT - 1) { 28 | wb->bit_buffer[p] = (uint8_t)(bit << q); 29 | } else { 30 | wb->bit_buffer[p] &= ~(1 << q); 31 | wb->bit_buffer[p] |= bit << q; 32 | } 33 | wb->bit_offset = off + 1; 34 | } 35 | 36 | void eb_vp9_wb_write_literal(struct vpx_write_bit_buffer *wb, int data, int bits) { 37 | int bit; 38 | for (bit = bits - 1; bit >= 0; bit--) eb_vp9_wb_write_bit(wb, (data >> bit) & 1); 39 | } 40 | 41 | void eb_vp9_wb_write_inv_signed_literal(struct vpx_write_bit_buffer *wb, int data, 42 | int bits) { 43 | eb_vp9_wb_write_literal(wb, abs(data), bits); 44 | eb_vp9_wb_write_bit(wb, data < 0); 45 | } 46 | -------------------------------------------------------------------------------- /Source/Lib/VPX/bitwriter_buffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VPX_DSP_BITWRITER_BUFFER_H_ 12 | #define VPX_VPX_DSP_BITWRITER_BUFFER_H_ 13 | 14 | #define INLINE __inline 15 | 16 | #include 17 | #include "stddef.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | struct vpx_write_bit_buffer { 24 | uint8_t *bit_buffer; 25 | size_t bit_offset; 26 | }; 27 | 28 | size_t eb_vp9_wb_bytes_written(const struct vpx_write_bit_buffer *wb); 29 | 30 | void eb_vp9_wb_write_bit(struct vpx_write_bit_buffer *wb, int bit); 31 | 32 | void eb_vp9_wb_write_literal(struct vpx_write_bit_buffer *wb, int data, int bits); 33 | 34 | void eb_vp9_wb_write_inv_signed_literal(struct vpx_write_bit_buffer *wb, int data, 35 | int bits); 36 | 37 | #ifdef __cplusplus 38 | } // extern "C" 39 | #endif 40 | 41 | #endif // VPX_VPX_DSP_BITWRITER_BUFFER_H_ 42 | -------------------------------------------------------------------------------- /Source/Lib/VPX/fwd_txfm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VPX_DSP_FWD_TXFM_H_ 12 | #define VPX_VPX_DSP_FWD_TXFM_H_ 13 | 14 | #include "txfm_common.h" 15 | #include "mem.h" 16 | 17 | static INLINE tran_high_t fdct_round_shift(tran_high_t input) { 18 | tran_high_t rv = ROUND_POWER_OF_TWO(input, DCT_CONST_BITS); 19 | // TODO(debargha, peter.derivaz): Find new bounds for this assert 20 | // and make the bounds consts. 21 | // assert(INT16_MIN <= rv && rv <= INT16_MAX); 22 | return rv; 23 | } 24 | 25 | void eb_vp9_fdct32(const tran_high_t *input, tran_high_t *output, int round); 26 | #endif // VPX_VPX_DSP_FWD_TXFM_H_ 27 | -------------------------------------------------------------------------------- /Source/Lib/VPX/mem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VPX_PORTS_MEM_H_ 12 | #define VPX_VPX_PORTS_MEM_H_ 13 | 14 | #if (defined(__GNUC__) && __GNUC__) || defined(__SUNPRO_C) 15 | #define DECLARE_ALIGNED(n, typ, val) typ val __attribute__((aligned(n))) 16 | #elif defined(_MSC_VER) 17 | #define DECLARE_ALIGNED(n, typ, val) __declspec(align(n)) typ val 18 | #else 19 | #warning No alignment directives known for this compiler. 20 | #define DECLARE_ALIGNED(n, typ, val) typ val 21 | #endif 22 | 23 | #if HAVE_NEON && defined(_MSC_VER) 24 | #define __builtin_prefetch(x) 25 | #endif 26 | 27 | /* Shift down with rounding */ 28 | #define ROUND_POWER_OF_TWO(value, n) (((value) + (1 << ((n)-1))) >> (n)) 29 | #define ROUND64_POWER_OF_TWO(value, n) (((value) + (1ULL << ((n)-1))) >> (n)) 30 | 31 | #define ALIGN_POWER_OF_TWO(value, n) \ 32 | (((value) + ((1 << (n)) - 1)) & ~((1 << (n)) - 1)) 33 | 34 | #define CONVERT_TO_SHORTPTR(x) ((uint16_t *)(((uintptr_t)(x)) << 1)) 35 | #define CAST_TO_SHORTPTR(x) ((uint16_t *)((uintptr_t)(x))) 36 | #if CONFIG_VP9_HIGHBITDEPTH 37 | #define CONVERT_TO_BYTEPTR(x) ((uint8_t *)(((uintptr_t)(x)) >> 1)) 38 | #define CAST_TO_BYTEPTR(x) ((uint8_t *)((uintptr_t)(x))) 39 | #endif // CONFIG_VP9_HIGHBITDEPTH 40 | 41 | #if !defined(__has_feature) 42 | #define __has_feature(x) 0 43 | #endif // !defined(__has_feature) 44 | 45 | #if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__) 46 | #define VPX_WITH_ASAN 1 47 | #else 48 | #define VPX_WITH_ASAN 0 49 | #endif // __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__) 50 | 51 | #endif // VPX_VPX_PORTS_MEM_H_ 52 | -------------------------------------------------------------------------------- /Source/Lib/VPX/prob.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #define INLINE __inline 12 | 13 | #include 14 | #include "prob.h" 15 | 16 | const uint8_t eb_vp9_norm[256] = { 17 | 0, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 18 | 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 19 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 20 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 21 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 22 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 27 | }; 28 | 29 | static unsigned int tree_merge_probs_impl(unsigned int i, 30 | const vpx_tree_index *tree, 31 | const vpx_prob *pre_probs, 32 | const unsigned int *counts, 33 | vpx_prob *probs) { 34 | const int l = tree[i]; 35 | const unsigned int left_count = 36 | (l <= 0) ? counts[-l] 37 | : tree_merge_probs_impl(l, tree, pre_probs, counts, probs); 38 | const int r = tree[i + 1]; 39 | const unsigned int right_count = 40 | (r <= 0) ? counts[-r] 41 | : tree_merge_probs_impl(r, tree, pre_probs, counts, probs); 42 | const unsigned int ct[2] = { left_count, right_count }; 43 | probs[i >> 1] = mode_mv_merge_probs(pre_probs[i >> 1], ct); 44 | return left_count + right_count; 45 | } 46 | 47 | void eb_vp9_tree_merge_probs(const vpx_tree_index *tree, const vpx_prob *pre_probs, 48 | const unsigned int *counts, vpx_prob *probs) { 49 | tree_merge_probs_impl(0, tree, pre_probs, counts, probs); 50 | } 51 | -------------------------------------------------------------------------------- /Source/Lib/VPX/psnr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VPX_DSP_PSNR_H_ 12 | #define VPX_VPX_DSP_PSNR_H_ 13 | 14 | #include "yv12config.h" 15 | 16 | #define MAX_PSNR 100.0 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | typedef struct { 23 | double psnr[4]; // total/y/u/v 24 | uint64_t sse[4]; // total/y/u/v 25 | uint32_t samples[4]; // total/y/u/v 26 | } PSNR_STATS; 27 | 28 | // TODO(dkovalev) change eb_vp9_sse_to_psnr signature: double -> int64_t 29 | 30 | /*!\brief Converts SSE to PSNR 31 | * 32 | * Converts sum of squared errros (SSE) to peak signal-to-noise ratio (PNSR). 33 | * 34 | * \param[in] samples Number of samples 35 | * \param[in] peak Max sample value 36 | * \param[in] sse Sum of squared errors 37 | */ 38 | double eb_vp9_sse_to_psnr(double samples, double peak, double sse); 39 | int64_t eb_vp9_get_y_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b); 40 | #if CONFIG_VP9_HIGHBITDEPTH 41 | int64_t vpx_highbd_get_y_sse(const YV12_BUFFER_CONFIG *a, 42 | const YV12_BUFFER_CONFIG *b); 43 | void vpx_calc_highbd_psnr(const YV12_BUFFER_CONFIG *a, 44 | const YV12_BUFFER_CONFIG *b, PSNR_STATS *psnr, 45 | unsigned int bit_depth, unsigned int in_bit_depth); 46 | #endif 47 | void eb_vp9_calc_psnr(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b, 48 | PSNR_STATS *psnr); 49 | 50 | double vpx_psnrhvs(const YV12_BUFFER_CONFIG *source, 51 | const YV12_BUFFER_CONFIG *dest, double *phvs_y, 52 | double *phvs_u, double *phvs_v, uint32_t bd, uint32_t in_bd); 53 | 54 | #ifdef __cplusplus 55 | } // extern "C" 56 | #endif 57 | #endif // VPX_VPX_DSP_PSNR_H_ 58 | -------------------------------------------------------------------------------- /Source/Lib/VPX/subtract.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include 12 | #include 13 | #include "vpx_dsp_rtcd.h" 14 | 15 | void eb_vp9_subtract_block_c(int rows, int cols, int16_t *diff, 16 | ptrdiff_t diff_stride, const uint8_t *src, 17 | ptrdiff_t src_stride, const uint8_t *pred, 18 | ptrdiff_t pred_stride) { 19 | int r, c; 20 | 21 | for (r = 0; r < rows; r++) { 22 | for (c = 0; c < cols; c++) diff[c] = src[c] - pred[c]; 23 | 24 | diff += diff_stride; 25 | pred += pred_stride; 26 | src += src_stride; 27 | } 28 | } 29 | 30 | #if CONFIG_VP9_HIGHBITDEPTH 31 | void vpx_highbd_subtract_block_c(int rows, int cols, int16_t *diff, 32 | ptrdiff_t diff_stride, const uint8_t *src8, 33 | ptrdiff_t src_stride, const uint8_t *pred8, 34 | ptrdiff_t pred_stride, int bd) { 35 | int r, c; 36 | uint16_t *src = CONVERT_TO_SHORTPTR(src8); 37 | uint16_t *pred = CONVERT_TO_SHORTPTR(pred8); 38 | (void)bd; 39 | 40 | for (r = 0; r < rows; r++) { 41 | for (c = 0; c < cols; c++) { 42 | diff[c] = src[c] - pred[c]; 43 | } 44 | 45 | diff += diff_stride; 46 | pred += pred_stride; 47 | src += src_stride; 48 | } 49 | } 50 | #endif // CONFIG_VP9_HIGHBITDEPTH 51 | -------------------------------------------------------------------------------- /Source/Lib/VPX/txfm_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VPX_DSP_TXFM_COMMON_H_ 12 | #define VPX_VPX_DSP_TXFM_COMMON_H_ 13 | 14 | #include "vpx_dsp_common.h" 15 | 16 | // Constants and Macros used by all idct/dct functions 17 | #define DCT_CONST_BITS 14 18 | #define DCT_CONST_ROUNDING (1 << (DCT_CONST_BITS - 1)) 19 | 20 | #define UNIT_QUANT_SHIFT 2 21 | #define UNIT_QUANT_FACTOR (1 << UNIT_QUANT_SHIFT) 22 | 23 | // Constants: 24 | // for (int i = 1; i< 32; ++i) 25 | // SVT_LOG("static const int cospi_%d_64 = %.0f;\n", i, 26 | // round(16384 * cos(i*M_PI/64))); 27 | // Note: sin(k*Pi/64) = cos((32-k)*Pi/64) 28 | static const tran_coef_t cospi_1_64 = 16364; 29 | static const tran_coef_t cospi_2_64 = 16305; 30 | static const tran_coef_t cospi_3_64 = 16207; 31 | static const tran_coef_t cospi_4_64 = 16069; 32 | static const tran_coef_t cospi_5_64 = 15893; 33 | static const tran_coef_t cospi_6_64 = 15679; 34 | static const tran_coef_t cospi_7_64 = 15426; 35 | static const tran_coef_t cospi_8_64 = 15137; 36 | static const tran_coef_t cospi_9_64 = 14811; 37 | static const tran_coef_t cospi_10_64 = 14449; 38 | static const tran_coef_t cospi_11_64 = 14053; 39 | static const tran_coef_t cospi_12_64 = 13623; 40 | static const tran_coef_t cospi_13_64 = 13160; 41 | static const tran_coef_t cospi_14_64 = 12665; 42 | static const tran_coef_t cospi_15_64 = 12140; 43 | static const tran_coef_t cospi_16_64 = 11585; 44 | static const tran_coef_t cospi_17_64 = 11003; 45 | static const tran_coef_t cospi_18_64 = 10394; 46 | static const tran_coef_t cospi_19_64 = 9760; 47 | static const tran_coef_t cospi_20_64 = 9102; 48 | static const tran_coef_t cospi_21_64 = 8423; 49 | static const tran_coef_t cospi_22_64 = 7723; 50 | static const tran_coef_t cospi_23_64 = 7005; 51 | static const tran_coef_t cospi_24_64 = 6270; 52 | static const tran_coef_t cospi_25_64 = 5520; 53 | static const tran_coef_t cospi_26_64 = 4756; 54 | static const tran_coef_t cospi_27_64 = 3981; 55 | static const tran_coef_t cospi_28_64 = 3196; 56 | static const tran_coef_t cospi_29_64 = 2404; 57 | static const tran_coef_t cospi_30_64 = 1606; 58 | static const tran_coef_t cospi_31_64 = 804; 59 | 60 | // 16384 * sqrt(2) * sin(kPi/9) * 2 / 3 61 | static const tran_coef_t sinpi_1_9 = 5283; 62 | static const tran_coef_t sinpi_2_9 = 9929; 63 | static const tran_coef_t sinpi_3_9 = 13377; 64 | static const tran_coef_t sinpi_4_9 = 15212; 65 | 66 | #endif // VPX_VPX_DSP_TXFM_COMMON_H_ 67 | -------------------------------------------------------------------------------- /Source/Lib/VPX/vp9_alloccommon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VP9_COMMON_VP9_ALLOCCOMMON_H_ 12 | #define VPX_VP9_COMMON_VP9_ALLOCCOMMON_H_ 13 | 14 | #define INVALID_IDX -1 // Invalid buffer index. 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | struct VP9Common; 21 | struct BufferPool; 22 | #if 0 23 | void vp9_remove_common(struct VP9Common *cm); 24 | 25 | int vp9_alloc_loop_filter(struct VP9Common *cm); 26 | int vp9_alloc_context_buffers(struct VP9Common *cm, int width, int height); 27 | void eb_vp9_init_context_buffers(struct VP9Common *cm); 28 | void vp9_free_context_buffers(struct VP9Common *cm); 29 | 30 | void vp9_free_ref_frame_buffers(struct BufferPool *pool); 31 | void vp9_free_postproc_buffers(struct VP9Common *cm); 32 | 33 | int vp9_alloc_state_buffers(struct VP9Common *cm, int width, int height); 34 | void vp9_free_state_buffers(struct VP9Common *cm); 35 | #endif 36 | void eb_vp9_set_mb_mi(struct VP9Common *cm, int width, int height); 37 | #if 0 38 | void eb_vp9_swap_current_and_last_seg_map(struct VP9Common *cm); 39 | #endif 40 | 41 | #ifdef __cplusplus 42 | } // extern "C" 43 | #endif 44 | 45 | #endif // VPX_VP9_COMMON_VP9_ALLOCCOMMON_H_ 46 | -------------------------------------------------------------------------------- /Source/Lib/VPX/vp9_bitstream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VP9_ENCODER_VP9_BITSTREAM_H_ 12 | #define VPX_VP9_ENCODER_VP9_BITSTREAM_H_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #define INLINE __inline 19 | 20 | #include 21 | #include "vp9_encoder.h" 22 | #include "bitwriter.h" 23 | #include "EbPictureControlSet.h" 24 | #include "EbBitstreamUnit.h" 25 | #include "EbEntropyCodingProcess.h" 26 | 27 | typedef struct VP9BitstreamWorkerData { 28 | uint8_t *dest; 29 | int dest_size; 30 | VpxWriter bit_writer; 31 | int tile_idx; 32 | unsigned int max_mv_magnitude; 33 | // The size of interp_filter_selected in VP9_COMP is actually 34 | // MAX_REFERENCE_FRAMES x SWITCHABLE. But when encoding tiles, all we ever do 35 | // is increment the very first index (index 0) for the first dimension. Hence 36 | // this is sufficient. 37 | int interp_filter_selected[1][SWITCHABLE]; 38 | DECLARE_ALIGNED(16, MACROBLOCKD, xd); 39 | } VP9BitstreamWorkerData; 40 | #if 0 41 | int vp9_get_refresh_mask(VP9_COMP *cpi); 42 | #endif 43 | void vp9_bitstream_encode_tiles_buffer_dealloc(VP9_COMP *const cpi); 44 | 45 | void eb_vp9_pack_bitstream( 46 | PictureControlSet *picture_control_set_ptr, 47 | VP9_COMP *cpi, 48 | uint8_t *dest, 49 | size_t *size, 50 | int show_existing_frame, 51 | int show_existing_frame_index); 52 | 53 | #if 0 54 | static INLINE int vp9_preserve_existing_gf(VP9_COMP *cpi) { 55 | return cpi->refresh_golden_frame && cpi->rc.is_src_frame_alt_ref && 56 | !cpi->use_svc; 57 | } 58 | #endif 59 | 60 | void write_partition(const VP9_COMMON *const cm, 61 | const MACROBLOCKD *const xd, int hbs, int mi_row, 62 | int mi_col, PARTITION_TYPE p, BLOCK_SIZE bsize, 63 | VpxWriter *w); 64 | 65 | void eb_vp9_write_modes_b( 66 | EntropyCodingContext *context_ptr, 67 | VP9_COMP *cpi, MACROBLOCKD *const xd, const TileInfo *const tile, 68 | VpxWriter *w, TOKENEXTRA **tok, const TOKENEXTRA *const tok_end, 69 | int mi_row, int mi_col, unsigned int *const max_mv_magnitude, 70 | int interp_filter_selected[MAX_REF_FRAMES][SWITCHABLE]); 71 | 72 | size_t write_compressed_header(VP9_COMP *cpi, uint8_t *data); 73 | 74 | #ifdef __cplusplus 75 | } // extern "C" 76 | #endif 77 | 78 | #endif // VPX_VP9_ENCODER_VP9_BITSTREAM_H_ 79 | -------------------------------------------------------------------------------- /Source/Lib/VPX/vp9_common_data.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VP9_COMMON_VP9_COMMON_DATA_H_ 12 | #define VPX_VP9_COMMON_VP9_COMMON_DATA_H_ 13 | 14 | #define INLINE __inline 15 | 16 | #include 17 | #include "vp9_enums.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | extern const uint8_t eb_vp9_b_width_log2_lookup[BLOCK_SIZES]; 24 | extern const uint8_t eb_vp9_b_height_log2_lookup[BLOCK_SIZES]; 25 | extern const uint8_t eb_vp9_mi_width_log2_lookup[BLOCK_SIZES]; 26 | extern const uint8_t eb_vp9_num_8x8_blocks_wide_lookup[BLOCK_SIZES]; 27 | extern const uint8_t eb_vp9_num_8x8_blocks_high_lookup[BLOCK_SIZES]; 28 | extern const uint8_t eb_vp9_num_4x4_blocks_high_lookup[BLOCK_SIZES]; 29 | extern const uint8_t eb_vp9_num_4x4_blocks_wide_lookup[BLOCK_SIZES]; 30 | extern const uint8_t eb_vp9_size_group_lookup[BLOCK_SIZES]; 31 | extern const uint8_t eb_vp9_num_pels_log2_lookup[BLOCK_SIZES]; 32 | extern const PARTITION_TYPE eb_vp9_partition_lookup[][BLOCK_SIZES]; 33 | extern const BLOCK_SIZE eb_vp9_subsize_lookup[PARTITION_TYPES][BLOCK_SIZES]; 34 | extern const TX_SIZE eb_vp9_max_txsize_lookup[BLOCK_SIZES]; 35 | extern const BLOCK_SIZE eb_vp9_txsize_to_bsize[TX_SIZES]; 36 | extern const TX_SIZE eb_vp9_tx_mode_to_biggest_tx_size[TX_MODES]; 37 | extern const BLOCK_SIZE eb_vp9_ss_size_lookup[BLOCK_SIZES][2][2]; 38 | extern const TX_SIZE eb_vp9_uv_txsize_lookup[BLOCK_SIZES][TX_SIZES][2][2]; 39 | #if CONFIG_BETTER_HW_COMPATIBILITY && CONFIG_VP9_HIGHBITDEPTH 40 | extern const uint8_t need_top_left[INTRA_MODES]; 41 | #endif // CONFIG_BETTER_HW_COMPATIBILITY && CONFIG_VP9_HIGHBITDEPTH 42 | 43 | #ifdef __cplusplus 44 | } // extern "C" 45 | #endif 46 | 47 | #endif // VPX_VP9_COMMON_VP9_COMMON_DATA_H_ 48 | -------------------------------------------------------------------------------- /Source/Lib/VPX/vp9_cost.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VP9_ENCODER_VP9_COST_H_ 12 | #define VPX_VP9_ENCODER_VP9_COST_H_ 13 | 14 | #define INLINE __inline 15 | 16 | #include 17 | #include "prob.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | extern const uint16_t eb_vp9_prob_cost[256]; 24 | 25 | // The factor to scale from cost in bits to cost in eb_vp9_prob_cost units. 26 | #define VP9_PROB_COST_SHIFT 9 27 | 28 | #define vp9_cost_zero(prob) (eb_vp9_prob_cost[prob]) 29 | 30 | #define vp9_cost_one(prob) vp9_cost_zero(256 - (prob)) 31 | 32 | #define vp9_cost_bit(prob, bit) vp9_cost_zero((bit) ? 256 - (prob) : (prob)) 33 | 34 | static INLINE unsigned int cost_branch256(const unsigned int ct[2], 35 | vpx_prob p) { 36 | assert(p > 0); 37 | return ct[0] * vp9_cost_zero(p) + ct[1] * vp9_cost_one(p); 38 | } 39 | 40 | static INLINE int treed_cost(vpx_tree tree, const vpx_prob *probs, int bits, 41 | int len) { 42 | int cost = 0; 43 | vpx_tree_index i = 0; 44 | 45 | do { 46 | const int bit = (bits >> --len) & 1; 47 | cost += vp9_cost_bit(probs[i >> 1], bit); 48 | i = tree[i + bit]; 49 | } while (len); 50 | 51 | return cost; 52 | } 53 | 54 | void eb_vp9_cost_tokens(int *costs, const vpx_prob *probs, vpx_tree tree); 55 | void eb_vp9_cost_tokens_skip(int *costs, const vpx_prob *probs, vpx_tree tree); 56 | 57 | #ifdef __cplusplus 58 | } // extern "C" 59 | #endif 60 | 61 | #endif // VPX_VP9_ENCODER_VP9_COST_H_ 62 | -------------------------------------------------------------------------------- /Source/Lib/VPX/vp9_encodemv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VP9_ENCODER_VP9_ENCODEMV_H_ 12 | #define VPX_VP9_ENCODER_VP9_ENCODEMV_H_ 13 | #if 1 14 | #define INLINE __inline 15 | 16 | #include 17 | #include "vp9_encoder.h" 18 | #else 19 | #include "vp9/encoder/vp9_encoder.h" 20 | #endif 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | void eb_vp9_entropy_mv_init(void); 26 | 27 | void eb_vp9_write_nmv_probs(VP9_COMMON *cm, int usehp, VpxWriter *w, 28 | nmv_context_counts *const counts); 29 | 30 | void eb_vp9_encode_mv(VP9_COMP *cpi, VpxWriter *w, const MV *mv, const MV *ref, 31 | const nmv_context *mvctx, int usehp, 32 | unsigned int *const max_mv_magnitude); 33 | 34 | void eb_vp9_build_nmv_cost_table(int *mvjoint, int *mvcost[2], 35 | const nmv_context *mvctx, int usehp); 36 | 37 | void vp9_update_mv_count(ThreadData *td); 38 | 39 | #ifdef __cplusplus 40 | } // extern "C" 41 | #endif 42 | 43 | #endif // VPX_VP9_ENCODER_VP9_ENCODEMV_H_ 44 | -------------------------------------------------------------------------------- /Source/Lib/VPX/vp9_filter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VP9_COMMON_VP9_FILTER_H_ 12 | #define VPX_VP9_COMMON_VP9_FILTER_H_ 13 | 14 | #include "vpx_filter.h" 15 | #include "mem.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #define EIGHTTAP 0 22 | #define EIGHTTAP_SMOOTH 1 23 | #define EIGHTTAP_SHARP 2 24 | #define SWITCHABLE_FILTERS 3 /* Number of switchable filters */ 25 | #define BILINEAR 3 26 | // The codec can operate in four possible inter prediction filter mode: 27 | // 8-tap, 8-tap-smooth, 8-tap-sharp, and switching between the three. 28 | #define SWITCHABLE_FILTER_CONTEXTS (SWITCHABLE_FILTERS + 1) 29 | #define SWITCHABLE 4 /* should be the last one */ 30 | 31 | typedef uint8_t INTERP_FILTER; 32 | 33 | extern const InterpKernel *eb_vp9_filter_kernels[4]; 34 | 35 | #ifdef __cplusplus 36 | } // extern "C" 37 | #endif 38 | 39 | #endif // VPX_VP9_COMMON_VP9_FILTER_H_ 40 | -------------------------------------------------------------------------------- /Source/Lib/VPX/vp9_mv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VP9_COMMON_VP9_MV_H_ 12 | #define VPX_VP9_COMMON_VP9_MV_H_ 13 | 14 | #define INLINE __inline 15 | 16 | #include 17 | #include 18 | #include "vpx_dsp_common.h" 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | typedef struct mv { 25 | int16_t row; 26 | int16_t col; 27 | } MV; 28 | 29 | typedef union int_mv { 30 | uint32_t as_int; 31 | MV as_mv; 32 | } int_mv; /* facilitates faster equality tests and copies */ 33 | 34 | typedef struct mv32 { 35 | int32_t row; 36 | int32_t col; 37 | } MV32; 38 | 39 | static INLINE int is_zero_mv(const MV *mv) { 40 | return *((const uint32_t *)mv) == 0; 41 | } 42 | 43 | static INLINE int is_equal_mv(const MV *a, const MV *b) { 44 | return *((const uint32_t *)a) == *((const uint32_t *)b); 45 | } 46 | 47 | static INLINE void clamp_mv(MV *mv, int min_col, int max_col, int min_row, 48 | int max_row) { 49 | mv->col = (int16_t)clamp(mv->col, min_col, max_col); 50 | mv->row = (int16_t)clamp(mv->row, min_row, max_row); 51 | } 52 | 53 | #ifdef __cplusplus 54 | } // extern "C" 55 | #endif 56 | 57 | #endif // VPX_VP9_COMMON_VP9_MV_H_ 58 | -------------------------------------------------------------------------------- /Source/Lib/VPX/vp9_picklpf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VP9_ENCODER_VP9_PICKLPF_H_ 12 | #define VPX_VP9_ENCODER_VP9_PICKLPF_H_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #include "vp9_encoder.h" 19 | 20 | struct yv12_buffer_config; 21 | struct VP9_COMP; 22 | 23 | void eb_vp9_pick_filter_level( 24 | #if 0 25 | const struct yv12_buffer_config *sd, 26 | #endif 27 | struct VP9_COMP *cpi, 28 | LPF_PICK_METHOD method); 29 | 30 | #ifdef __cplusplus 31 | } // extern "C" 32 | #endif 33 | 34 | #endif // VPX_VP9_ENCODER_VP9_PICKLPF_H_ 35 | -------------------------------------------------------------------------------- /Source/Lib/VPX/vp9_quant_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VP9_COMMON_VP9_QUANT_COMMON_H_ 12 | #define VPX_VP9_COMMON_VP9_QUANT_COMMON_H_ 13 | 14 | #define INLINE __inline 15 | 16 | #include 17 | #include "vpx_codec.h" 18 | #include "vp9_seg_common.h" 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #define MINQ 0 25 | #define MAXQ 255 26 | #define QINDEX_RANGE (MAXQ - MINQ + 1) 27 | #define QINDEX_BITS 8 28 | 29 | int16_t eb_vp9_dc_quant(int qindex, int delta, vpx_bit_depth_t bit_depth); 30 | int16_t eb_vp9_ac_quant(int qindex, int delta, vpx_bit_depth_t bit_depth); 31 | 32 | int eb_vp9_get_qindex(const struct segmentation *seg, int segment_id, 33 | int base_qindex); 34 | 35 | #ifdef __cplusplus 36 | } // extern "C" 37 | #endif 38 | 39 | #endif // VPX_VP9_COMMON_VP9_QUANT_COMMON_H_ 40 | -------------------------------------------------------------------------------- /Source/Lib/VPX/vp9_quantize.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VP9_ENCODER_VP9_QUANTIZE_H_ 12 | #define VPX_VP9_ENCODER_VP9_QUANTIZE_H_ 13 | 14 | #include "vp9_block.h" 15 | #include "vp9_quant_common.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | typedef struct { 22 | DECLARE_ALIGNED(16, int16_t, y_quant[QINDEX_RANGE][8]); 23 | DECLARE_ALIGNED(16, int16_t, y_quant_shift[QINDEX_RANGE][8]); 24 | DECLARE_ALIGNED(16, int16_t, y_zbin[QINDEX_RANGE][8]); 25 | DECLARE_ALIGNED(16, int16_t, y_round[QINDEX_RANGE][8]); 26 | 27 | // TODO(jingning): in progress of re-working the quantization. will decide 28 | // if we want to deprecate the current use of y_quant. 29 | DECLARE_ALIGNED(16, int16_t, y_quant_fp[QINDEX_RANGE][8]); 30 | DECLARE_ALIGNED(16, int16_t, uv_quant_fp[QINDEX_RANGE][8]); 31 | DECLARE_ALIGNED(16, int16_t, y_round_fp[QINDEX_RANGE][8]); 32 | DECLARE_ALIGNED(16, int16_t, uv_round_fp[QINDEX_RANGE][8]); 33 | 34 | DECLARE_ALIGNED(16, int16_t, uv_quant[QINDEX_RANGE][8]); 35 | DECLARE_ALIGNED(16, int16_t, uv_quant_shift[QINDEX_RANGE][8]); 36 | DECLARE_ALIGNED(16, int16_t, uv_zbin[QINDEX_RANGE][8]); 37 | DECLARE_ALIGNED(16, int16_t, uv_round[QINDEX_RANGE][8]); 38 | } QUANTS; 39 | 40 | void vp9_regular_quantize_b_4x4(MACROBLOCK *x, int plane, int block, 41 | const int16_t *scan, const int16_t *iscan); 42 | 43 | struct VP9_COMP; 44 | struct VP9Common; 45 | 46 | void vp9_frame_init_quantizer(struct VP9_COMP *cpi); 47 | 48 | void vp9_init_plane_quantizers(struct VP9_COMP *cpi, MACROBLOCK *x); 49 | 50 | void eb_vp9_init_quantizer(struct VP9_COMP *cpi); 51 | 52 | void vp9_set_quantizer(struct VP9Common *cm, int q); 53 | 54 | int eb_vp9_quantizer_to_qindex(int quantizer); 55 | 56 | int eb_vp9_qindex_to_quantizer(int qindex); 57 | 58 | #ifdef __cplusplus 59 | } // extern "C" 60 | #endif 61 | 62 | #endif // VPX_VP9_ENCODER_VP9_QUANTIZE_H_ 63 | -------------------------------------------------------------------------------- /Source/Lib/VPX/vp9_reconintra.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VP9_COMMON_VP9_RECONINTRA_H_ 12 | #define VPX_VP9_COMMON_VP9_RECONINTRA_H_ 13 | 14 | #define INLINE __inline 15 | 16 | #include 17 | #include "vp9_blockd.h" 18 | #include "EbSequenceControlSet.h" 19 | #include "EbEncDecProcess.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | void eb_vp9_init_intra_predictors(void); 26 | 27 | void eb_vp9_predict_intra_block(EncDecContext *context_ptr, 28 | #if 0 // Hsan: reference samples generation done per block prior to fast loop @ generate_intra_reference_samples() 29 | const MACROBLOCKD *xd, 30 | #endif 31 | TX_SIZE tx_size, 32 | PREDICTION_MODE mode, 33 | #if 0 // Hsan: reference samples generation done per block prior to fast loop @ generate_intra_reference_samples() 34 | const uint8_t *ref, 35 | int ref_stride, 36 | #endif 37 | uint8_t *dst, int dst_stride, 38 | #if 0 39 | int aoff, int loff, 40 | #endif 41 | int plane); 42 | #ifdef __cplusplus 43 | } // extern "C" 44 | #endif 45 | 46 | #endif // VPX_VP9_COMMON_VP9_RECONINTRA_H_ 47 | -------------------------------------------------------------------------------- /Source/Lib/VPX/vp9_scale.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VP9_COMMON_VP9_SCALE_H_ 12 | #define VPX_VP9_COMMON_VP9_SCALE_H_ 13 | 14 | #define INLINE __inline 15 | 16 | #include 17 | #include "vp9_mv.h" 18 | #include "vpx_convolve.h" 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #define REF_SCALE_SHIFT 14 25 | #define REF_NO_SCALE (1 << REF_SCALE_SHIFT) 26 | #define REF_INVALID_SCALE -1 27 | 28 | struct scale_factors { 29 | int x_scale_fp; // horizontal fixed point scale factor 30 | int y_scale_fp; // vertical fixed point scale factor 31 | int x_step_q4; 32 | int y_step_q4; 33 | 34 | int (*scale_value_x)(int val, const struct scale_factors *sf); 35 | int (*scale_value_y)(int val, const struct scale_factors *sf); 36 | 37 | convolve_fn_t predict[2][2][2]; // horiz, vert, avg 38 | 39 | #if CONFIG_VP9_HIGHBITDEPTH 40 | highbd_convolve_fn_t highbd_predict[2][2][2]; // horiz, vert, avg 41 | #endif 42 | }; 43 | 44 | MV32 eb_vp9_scale_mv(const MV *mv, int x, int y, const struct scale_factors *sf); 45 | 46 | #if CONFIG_VP9_HIGHBITDEPTH 47 | void eb_vp9_setup_scale_factors_for_frame(struct scale_factors *sf, int other_w, 48 | int other_h, int this_w, int this_h, 49 | int use_high); 50 | #else 51 | void eb_vp9_setup_scale_factors_for_frame(struct scale_factors *sf, int other_w, 52 | int other_h, int this_w, int this_h); 53 | #endif 54 | 55 | static INLINE int vp9_is_valid_scale(const struct scale_factors *sf) { 56 | return sf->x_scale_fp != REF_INVALID_SCALE && 57 | sf->y_scale_fp != REF_INVALID_SCALE; 58 | } 59 | 60 | static INLINE int vp9_is_scaled(const struct scale_factors *sf) { 61 | return vp9_is_valid_scale(sf) && 62 | (sf->x_scale_fp != REF_NO_SCALE || sf->y_scale_fp != REF_NO_SCALE); 63 | } 64 | 65 | static INLINE int valid_ref_frame_size(int ref_width, int ref_height, 66 | int this_width, int this_height) { 67 | return 2 * this_width >= ref_width && 2 * this_height >= ref_height && 68 | this_width <= 16 * ref_width && this_height <= 16 * ref_height; 69 | } 70 | 71 | #ifdef __cplusplus 72 | } // extern "C" 73 | #endif 74 | 75 | #endif // VPX_VP9_COMMON_VP9_SCALE_H_ 76 | -------------------------------------------------------------------------------- /Source/Lib/VPX/vp9_scan.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VP9_COMMON_VP9_SCAN_H_ 12 | #define VPX_VP9_COMMON_VP9_SCAN_H_ 13 | 14 | #include "mem.h" 15 | 16 | #include "vp9_enums.h" 17 | #include "vp9_blockd.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | #define MAX_NEIGHBORS 2 24 | 25 | typedef struct { 26 | const int16_t *scan; 27 | const int16_t *iscan; 28 | const int16_t *neighbors; 29 | } scan_order; 30 | 31 | extern const scan_order eb_vp9_default_scan_orders[TX_SIZES]; 32 | extern const scan_order eb_vp9_scan_orders[TX_SIZES][TX_TYPES]; 33 | 34 | static INLINE int get_coef_context(const int16_t *neighbors, 35 | const uint8_t *token_cache, int c) { 36 | return (1 + token_cache[neighbors[MAX_NEIGHBORS * c + 0]] + 37 | token_cache[neighbors[MAX_NEIGHBORS * c + 1]]) >> 38 | 1; 39 | } 40 | 41 | static INLINE const scan_order *get_scan(const MACROBLOCKD *xd, TX_SIZE tx_size, 42 | PLANE_TYPE type, int block_idx) { 43 | const ModeInfo *const mi = xd->mi[0]; 44 | 45 | if (is_inter_block(mi) || type != PLANE_TYPE_Y || xd->lossless) { 46 | return &eb_vp9_default_scan_orders[tx_size]; 47 | } else { 48 | const PREDICTION_MODE mode = get_y_mode(mi, block_idx); 49 | return &eb_vp9_scan_orders[tx_size][eb_vp9_intra_mode_to_tx_type_lookup[mode]]; 50 | } 51 | } 52 | 53 | #ifdef __cplusplus 54 | } // extern "C" 55 | #endif 56 | 57 | #endif // VPX_VP9_COMMON_VP9_SCAN_H_ 58 | -------------------------------------------------------------------------------- /Source/Lib/VPX/vp9_seg_common.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include 12 | 13 | #define INLINE __inline 14 | 15 | #include 16 | #include "vp9_seg_common.h" 17 | #include "vp9_loopfilter.h" 18 | #include "prob.h" 19 | #include "string.h" 20 | #include "vp9_common.h" 21 | #include "vp9_quant_common.h" 22 | 23 | static const int seg_feature_data_signed[SEG_LVL_MAX] = { 1, 1, 0, 0 }; 24 | #if 1// SEG_SUPPORT 25 | static const int seg_feature_data_max[SEG_LVL_MAX] = { MAXQ, MAX_LOOP_FILTER, 3, 26 | 0 }; 27 | #endif 28 | // These functions provide access to new segment level features. 29 | // Eventually these function may be "optimized out" but for the moment, 30 | // the coding mechanism is still subject to change so these provide a 31 | // convenient single point of change. 32 | 33 | void eb_vp9_clearall_segfeatures(struct segmentation *seg) { 34 | vp9_zero(seg->feature_data); 35 | vp9_zero(seg->feature_mask); 36 | seg->aq_av_offset = 0; 37 | } 38 | 39 | void eb_vp9_enable_segfeature(struct segmentation *seg, int segment_id, 40 | SEG_LVL_FEATURES feature_id) { 41 | seg->feature_mask[segment_id] |= 1 << feature_id; 42 | } 43 | #if 1// SEG_SUPPORT 44 | int eb_vp9_seg_feature_data_max(SEG_LVL_FEATURES feature_id) { 45 | return seg_feature_data_max[feature_id]; 46 | } 47 | #endif 48 | int eb_vp9_is_segfeature_signed(SEG_LVL_FEATURES feature_id) { 49 | return seg_feature_data_signed[feature_id]; 50 | } 51 | #if 1// SEG_SUPPORT 52 | void eb_vp9_set_segdata(struct segmentation *seg, int segment_id, 53 | SEG_LVL_FEATURES feature_id, int seg_data) { 54 | assert(seg_data <= seg_feature_data_max[feature_id]); 55 | if (seg_data < 0) { 56 | assert(seg_feature_data_signed[feature_id]); 57 | assert(-seg_data <= seg_feature_data_max[feature_id]); 58 | } 59 | 60 | seg->feature_data[segment_id][feature_id] = (int16_t)seg_data; 61 | } 62 | #endif 63 | 64 | const vpx_tree_index eb_vp9_segment_tree[TREE_SIZE(MAX_SEGMENTS)] = { 65 | 2, 4, 6, 8, 10, 12, 0, -1, -2, -3, -4, -5, -6, -7 66 | }; 67 | 68 | // TBD? Functions to read and write segment data with range / validity checking 69 | -------------------------------------------------------------------------------- /Source/Lib/VPX/vp9_segmentation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VP9_ENCODER_VP9_SEGMENTATION_H_ 12 | #define VPX_VP9_ENCODER_VP9_SEGMENTATION_H_ 13 | 14 | #include "vp9_blockd.h" 15 | #include "vp9_encoder.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | void calc_segtree_probs(int *segcounts, vpx_prob *segment_tree_probs); 22 | 23 | void eb_vp9_enable_segmentation(struct segmentation *seg); 24 | void eb_vp9_disable_segmentation(struct segmentation *seg); 25 | 26 | void eb_vp9_disable_segfeature(struct segmentation *seg, int segment_id, 27 | SEG_LVL_FEATURES feature_id); 28 | void eb_vp9_clear_segdata(struct segmentation *seg, int segment_id, 29 | SEG_LVL_FEATURES feature_id); 30 | 31 | // The values given for each segment can be either deltas (from the default 32 | // value chosen for the frame) or absolute values. 33 | // 34 | // Valid range for abs values is (0-127 for MB_LVL_ALT_Q), (0-63 for 35 | // SEGMENT_ALT_LF) 36 | // Valid range for delta values are (+/-127 for MB_LVL_ALT_Q), (+/-63 for 37 | // SEGMENT_ALT_LF) 38 | // 39 | // abs_delta = SEGMENT_DELTADATA (deltas) abs_delta = SEGMENT_ABSDATA (use 40 | // the absolute values given). 41 | void eb_vp9_set_segment_data(struct segmentation *seg, signed char *feature_data, 42 | unsigned char abs_delta); 43 | 44 | void vp9_choose_segmap_coding_method(VP9_COMMON *cm, MACROBLOCKD *xd); 45 | 46 | void eb_vp9_reset_segment_features(struct segmentation *seg); 47 | 48 | #ifdef __cplusplus 49 | } // extern "C" 50 | #endif 51 | 52 | #endif // VPX_VP9_ENCODER_VP9_SEGMENTATION_H_ 53 | -------------------------------------------------------------------------------- /Source/Lib/VPX/vp9_subexp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VP9_ENCODER_VP9_SUBEXP_H_ 12 | #define VPX_VP9_ENCODER_VP9_SUBEXP_H_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #define INLINE __inline 19 | 20 | #include 21 | 22 | struct VpxWriter; 23 | 24 | void eb_vp9_write_prob_diff_update(struct VpxWriter *w, vpx_prob newp, 25 | vpx_prob oldp); 26 | 27 | void eb_vp9_cond_prob_diff_update(struct VpxWriter *w, vpx_prob *oldp, 28 | const unsigned int ct[2]); 29 | 30 | int eb_vp9_prob_diff_update_savings_search(const unsigned int *ct, vpx_prob oldp, 31 | vpx_prob *bestp, vpx_prob upd); 32 | 33 | int eb_vp9_prob_diff_update_savings_search_model(const unsigned int *ct, 34 | const vpx_prob oldp, 35 | vpx_prob *bestp, vpx_prob upd, 36 | int stepsize); 37 | 38 | #ifdef __cplusplus 39 | } // extern "C" 40 | #endif 41 | 42 | #endif // VPX_VP9_ENCODER_VP9_SUBEXP_H_ 43 | -------------------------------------------------------------------------------- /Source/Lib/VPX/vp9_tile_common.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | #define INLINE __inline 11 | 12 | #include "vp9_onyxc_int.h" 13 | #include "vp9_enums.h" 14 | #include "vpx_dsp_common.h" 15 | 16 | #define MIN_TILE_WIDTH_B64 4 17 | #define MAX_TILE_WIDTH_B64 64 18 | 19 | static int get_tile_offset(int idx, int mis, int log2) { 20 | const int sb_cols = mi_cols_aligned_to_sb(mis) >> MI_BLOCK_SIZE_LOG2; 21 | const int offset = ((idx * sb_cols) >> log2) << MI_BLOCK_SIZE_LOG2; 22 | return VPXMIN(offset, mis); 23 | } 24 | 25 | void eb_vp9_tile_set_row(TileInfo *tile, const VP9_COMMON *cm, int row) { 26 | tile->mi_row_start = get_tile_offset(row, cm->mi_rows, cm->log2_tile_rows); 27 | tile->mi_row_end = get_tile_offset(row + 1, cm->mi_rows, cm->log2_tile_rows); 28 | } 29 | 30 | void eb_vp9_tile_set_col(TileInfo *tile, const VP9_COMMON *cm, int col) { 31 | tile->mi_col_start = get_tile_offset(col, cm->mi_cols, cm->log2_tile_cols); 32 | tile->mi_col_end = get_tile_offset(col + 1, cm->mi_cols, cm->log2_tile_cols); 33 | } 34 | 35 | void eb_vp9_tile_init(TileInfo *tile, const VP9_COMMON *cm, int row, int col) { 36 | eb_vp9_tile_set_row(tile, cm, row); 37 | eb_vp9_tile_set_col(tile, cm, col); 38 | } 39 | 40 | static int get_min_log2_tile_cols(const int sb64_cols) { 41 | int min_log2 = 0; 42 | while ((MAX_TILE_WIDTH_B64 << min_log2) < sb64_cols) ++min_log2; 43 | return min_log2; 44 | } 45 | 46 | static int get_max_log2_tile_cols(const int sb64_cols) { 47 | int max_log2 = 1; 48 | while ((sb64_cols >> max_log2) >= MIN_TILE_WIDTH_B64) ++max_log2; 49 | return max_log2 - 1; 50 | } 51 | 52 | void eb_vp9_get_tile_n_bits(int mi_cols, int *min_log2_tile_cols, 53 | int *max_log2_tile_cols) { 54 | const int sb64_cols = mi_cols_aligned_to_sb(mi_cols) >> MI_BLOCK_SIZE_LOG2; 55 | *min_log2_tile_cols = get_min_log2_tile_cols(sb64_cols); 56 | *max_log2_tile_cols = get_max_log2_tile_cols(sb64_cols); 57 | assert(*min_log2_tile_cols <= *max_log2_tile_cols); 58 | } 59 | -------------------------------------------------------------------------------- /Source/Lib/VPX/vp9_tile_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VP9_COMMON_VP9_TILE_COMMON_H_ 12 | #define VPX_VP9_COMMON_VP9_TILE_COMMON_H_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | struct VP9Common; 19 | 20 | typedef struct TileInfo { 21 | int mi_row_start, mi_row_end; 22 | int mi_col_start, mi_col_end; 23 | } TileInfo; 24 | 25 | // initializes 'tile->mi_(row|col)_(start|end)' for (row, col) based on 26 | // 'cm->log2_tile_(rows|cols)' & 'cm->mi_(rows|cols)' 27 | void eb_vp9_tile_init(TileInfo *tile, const struct VP9Common *cm, int row, 28 | int col); 29 | 30 | void eb_vp9_tile_set_row(TileInfo *tile, const struct VP9Common *cm, int row); 31 | void eb_vp9_tile_set_col(TileInfo *tile, const struct VP9Common *cm, int col); 32 | 33 | void eb_vp9_get_tile_n_bits(int mi_cols, int *min_log2_tile_cols, 34 | int *max_log2_tile_cols); 35 | 36 | #ifdef __cplusplus 37 | } // extern "C" 38 | #endif 39 | 40 | #endif // VPX_VP9_COMMON_VP9_TILE_COMMON_H_ 41 | -------------------------------------------------------------------------------- /Source/Lib/VPX/vp9_treewriter.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | #define INLINE __inline 11 | 12 | #include 13 | #include "vp9_treewriter.h" 14 | 15 | static void tree2tok(struct vp9_token *tokens, const vpx_tree_index *tree, 16 | int i, int v, int l) { 17 | v += v; 18 | ++l; 19 | 20 | do { 21 | const vpx_tree_index j = tree[i++]; 22 | if (j <= 0) { 23 | tokens[-j].value = v; 24 | tokens[-j].len = l; 25 | } else { 26 | tree2tok(tokens, tree, j, v, l); 27 | } 28 | } while (++v & 1); 29 | } 30 | 31 | void eb_vp9_tokens_from_tree(struct vp9_token *tokens, 32 | const vpx_tree_index *tree) { 33 | tree2tok(tokens, tree, 0, 0, 0); 34 | } 35 | 36 | static unsigned int convert_distribution(unsigned int i, vpx_tree tree, 37 | unsigned int branch_ct[][2], 38 | const unsigned int num_events[]) { 39 | unsigned int left, right; 40 | 41 | if (tree[i] <= 0) 42 | left = num_events[-tree[i]]; 43 | else 44 | left = convert_distribution(tree[i], tree, branch_ct, num_events); 45 | 46 | if (tree[i + 1] <= 0) 47 | right = num_events[-tree[i + 1]]; 48 | else 49 | right = convert_distribution(tree[i + 1], tree, branch_ct, num_events); 50 | 51 | branch_ct[i >> 1][0] = left; 52 | branch_ct[i >> 1][1] = right; 53 | return left + right; 54 | } 55 | 56 | void eb_vp9_tree_probs_from_distribution(vpx_tree tree, 57 | unsigned int branch_ct[/* n-1 */][2], 58 | const unsigned int num_events[/* n */]) { 59 | convert_distribution(0, tree, branch_ct, num_events); 60 | } 61 | -------------------------------------------------------------------------------- /Source/Lib/VPX/vp9_treewriter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VP9_ENCODER_VP9_TREEWRITER_H_ 12 | #define VPX_VP9_ENCODER_VP9_TREEWRITER_H_ 13 | 14 | #include "vp9_treewriter.h" 15 | #include "prob.h" 16 | #include "bitwriter.h" 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | void eb_vp9_tree_probs_from_distribution(vpx_tree tree, 23 | unsigned int branch_ct[/* n - 1 */][2], 24 | const unsigned int num_events[/* n */]); 25 | 26 | struct vp9_token { 27 | int value; 28 | int len; 29 | }; 30 | 31 | void eb_vp9_tokens_from_tree(struct vp9_token *, const vpx_tree_index *); 32 | 33 | static INLINE void vp9_write_tree(VpxWriter *w, const vpx_tree_index *tree, 34 | const vpx_prob *probs, int bits, int len, 35 | vpx_tree_index i) { 36 | do { 37 | const int bit = (bits >> --len) & 1; 38 | vpx_write(w, bit, probs[i >> 1]); 39 | i = tree[i + bit]; 40 | } while (len); 41 | } 42 | 43 | static INLINE void vp9_write_token(VpxWriter *w, const vpx_tree_index *tree, 44 | const vpx_prob *probs, 45 | const struct vp9_token *token) { 46 | vp9_write_tree(w, tree, probs, token->value, token->len, 0); 47 | } 48 | 49 | #ifdef __cplusplus 50 | } // extern "C" 51 | #endif 52 | 53 | #endif // VPX_VP9_ENCODER_VP9_TREEWRITER_H_ 54 | -------------------------------------------------------------------------------- /Source/Lib/VPX/vpx_convolve.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | #ifndef VPX_VPX_DSP_VPX_CONVOLVE_H_ 11 | #define VPX_VPX_DSP_VPX_CONVOLVE_H_ 12 | 13 | #include 14 | #include "vpx_filter.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | typedef void (*convolve_fn_t)(const uint8_t *src, ptrdiff_t src_stride, 21 | uint8_t *dst, ptrdiff_t dst_stride, 22 | const InterpKernel *filter, int x0_q4, 23 | int x_step_q4, int y0_q4, int y_step_q4, int w, 24 | int h); 25 | 26 | #if CONFIG_VP9_HIGHBITDEPTH 27 | typedef void (*highbd_convolve_fn_t)(const uint16_t *src, ptrdiff_t src_stride, 28 | uint16_t *dst, ptrdiff_t dst_stride, 29 | const InterpKernel *filter, int x0_q4, 30 | int x_step_q4, int y0_q4, int y_step_q4, 31 | int w, int h, int bd); 32 | #endif 33 | 34 | #ifdef __cplusplus 35 | } // extern "C" 36 | #endif 37 | 38 | #endif // VPX_VPX_DSP_VPX_CONVOLVE_H_ 39 | -------------------------------------------------------------------------------- /Source/Lib/VPX/vpx_dsp_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VPX_DSP_VPX_DSP_COMMON_H_ 12 | #define VPX_VPX_DSP_VPX_DSP_COMMON_H_ 13 | 14 | #define INLINE __inline 15 | 16 | #include 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | #define VPXMIN(x, y) (((x) < (y)) ? (x) : (y)) 23 | #define VPXMAX(x, y) (((x) > (y)) ? (x) : (y)) 24 | 25 | #define VPX_SWAP(type, a, b) \ 26 | do { \ 27 | type c = (b); \ 28 | b = a; \ 29 | a = c; \ 30 | } while (0) 31 | 32 | #if CONFIG_VP9_HIGHBITDEPTH 33 | // Note: 34 | // tran_low_t is the datatype used for final transform coefficients. 35 | // tran_high_t is the datatype used for intermediate transform stages. 36 | typedef int64_t tran_high_t; 37 | typedef int32_t tran_low_t; 38 | #else 39 | // Note: 40 | // tran_low_t is the datatype used for final transform coefficients. 41 | // tran_high_t is the datatype used for intermediate transform stages. 42 | typedef int32_t tran_high_t; 43 | typedef int16_t tran_low_t; 44 | #endif // CONFIG_VP9_HIGHBITDEPTH 45 | 46 | typedef int16_t tran_coef_t; 47 | 48 | static INLINE int clip_pixel(int val) { 49 | return (uint8_t)((val > 255) ? 255 : (val < 0) ? 0 : val); 50 | } 51 | 52 | static INLINE int clamp(int value, int low, int high) { 53 | return value < low ? low : (value > high ? high : value); 54 | } 55 | 56 | static INLINE double fclamp(double value, double low, double high) { 57 | return value < low ? low : (value > high ? high : value); 58 | } 59 | #if 0 60 | static INLINE uint16_t clip_pixel_highbd(int val, int bd) { 61 | switch (bd) { 62 | case 8: 63 | default: return (uint16_t)clamp(val, 0, 255); 64 | case 10: return (uint16_t)clamp(val, 0, 1023); 65 | case 12: return (uint16_t)clamp(val, 0, 4095); 66 | } 67 | } 68 | #endif 69 | #ifdef __cplusplus 70 | } // extern "C" 71 | #endif 72 | 73 | #endif // VPX_VPX_DSP_VPX_DSP_COMMON_H_ 74 | -------------------------------------------------------------------------------- /Source/Lib/VPX/vpx_filter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VPX_DSP_VPX_FILTER_H_ 12 | #define VPX_VPX_DSP_VPX_FILTER_H_ 13 | 14 | #include 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #define FILTER_BITS 7 21 | 22 | #define SUBPEL_BITS 4 23 | #define SUBPEL_MASK ((1 << SUBPEL_BITS) - 1) 24 | #define SUBPEL_SHIFTS (1 << SUBPEL_BITS) 25 | #define SUBPEL_TAPS 8 26 | 27 | typedef int16_t InterpKernel[SUBPEL_TAPS]; 28 | 29 | #ifdef __cplusplus 30 | } // extern "C" 31 | #endif 32 | 33 | #endif // VPX_VPX_DSP_VPX_FILTER_H_ 34 | -------------------------------------------------------------------------------- /Source/Lib/VPX/vpxenc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | #ifndef VPX_VPXENC_H_ 11 | #define VPX_VPXENC_H_ 12 | 13 | #define INLINE __inline 14 | #include 15 | #include 16 | #include "vpx_encoder.h" 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | enum TestDecodeFatality { 23 | TEST_DECODE_OFF, 24 | TEST_DECODE_FATAL, 25 | TEST_DECODE_WARN, 26 | }; 27 | 28 | typedef enum { 29 | I420, // 4:2:0 8+ bit-depth 30 | I422, // 4:2:2 8+ bit-depth 31 | I444, // 4:4:4 8+ bit-depth 32 | I440, // 4:4:0 8+ bit-depth 33 | YV12, // 4:2:0 with uv flipped, only 8-bit depth 34 | } ColorInputType; 35 | 36 | struct VpxInterface; 37 | 38 | /* Configuration elements common to all streams. */ 39 | struct VpxEncoderConfig { 40 | const struct VpxInterface *codec; 41 | int passes; 42 | int pass; 43 | int usage; 44 | int deadline; 45 | ColorInputType color_type; 46 | int quiet; 47 | int verbose; 48 | int limit; 49 | int skip_frames; 50 | int show_psnr; 51 | enum TestDecodeFatality test_decode; 52 | int have_framerate; 53 | struct vpx_rational frame_rate; 54 | int out_part; 55 | int debug; 56 | int show_q_hist_buckets; 57 | int show_rate_hist_buckets; 58 | int disable_warnings; 59 | int disable_warning_prompt; 60 | int experimental_bitstream; 61 | }; 62 | 63 | #ifdef __cplusplus 64 | } // extern "C" 65 | #endif 66 | 67 | #endif // VPX_VPXENC_H_ 68 | -------------------------------------------------------------------------------- /Source/Lib/pkg-config.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@/svt-vp9 3 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 4 | 5 | Name: SvtVp9Enc 6 | Description: SVT (Scalable Video Technology) for VP9 encoder library 7 | Version: @SVT_VP9_VERSION_MAJOR@.@SVT_VP9_VERSION_MINOR@.@SVT_VP9_VERSION_PATCHLEVEL@ 8 | Libs: -L${libdir} -lSvtVp9Enc @LIBS@ 9 | Cflags: -I${includedir} 10 | -------------------------------------------------------------------------------- /ffmpeg_plugin/README.md: -------------------------------------------------------------------------------- 1 | # SVT-VP9 ffmpeg plugin installation 2 | 3 | Assumes you have a bash (or similar) shell along with commands such as 4 | 5 | - git 6 | - cmake 7 | - make 8 | - pkg-config 9 | - cc 10 | 11 | If you do not have any of these, please consult your friendly web browser to determine what is the best way to get these on your system, else ask IT. 12 | 13 | If you are on windows, the recommended way to get these tools and build FFmpeg is through [msys2](https://www.msys2.org/). The way to get these specific tools will not be provided here though. 14 | 15 | If you are trying to compile FFmpeg using MSVC, please try to consult FFmpeg's [wiki page](https://trac.ffmpeg.org/wiki/CompilationGuide/MSVC) about it. 16 | 17 | ## Build and install SVT-VP9 18 | 19 | ```bash 20 | git clone https://github.com/OpenVisualCloud/SVT-VP9.git 21 | cd SVT-VP9/Build 22 | # Adjust this line to add any other cmake related options 23 | cmake .. -DCMAKE_BUILD_TYPE=Release 24 | make -j $(nproc) 25 | sudo make install 26 | cd .. 27 | ``` 28 | 29 | ## Enable SVT-VP9 plugin 30 | 31 | ```bash 32 | # Adjust /usr/local to your chosen prefix 33 | export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib 34 | export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig 35 | git clone https://github.com/FFmpeg/FFmpeg.git ffmpeg 36 | cd ffmpeg 37 | ``` 38 | 39 | Which patch to apply will depend on which version of FFmpeg you are going to use. 40 | 41 | master: 42 | 43 | ```bash 44 | git apply ../ffmpeg_plugin/master-0001-Add-ability-for-ffmpeg-to-run-svt-vp9.patch 45 | ``` 46 | 47 | n4.3.1 tag: 48 | 49 | ```bash 50 | git checkout n4.3.1 51 | git apply ../ffmpeg_plugin/n4.3.1-0001-Add-ability-for-ffmpeg-to-run-svt-vp9.patch 52 | ``` 53 | 54 | n4.2.3 tag: 55 | 56 | ```bash 57 | git checkout n4.2.3 58 | git apply ../ffmpeg_plugin/n4.2.3-0001-Add-ability-for-ffmpeg-to-run-svt-vp9.patch 59 | ``` 60 | 61 | n4.2.2 tag: 62 | 63 | ```bash 64 | git checkout n4.2.2 65 | git apply ../ffmpeg_plugin/0001-Add-ability-for-ffmpeg-to-run-svt-vp9.patch 66 | ``` 67 | 68 | ```bash 69 | ./configure --enable-libsvtvp9 70 | make -j $(nproc) 71 | ``` 72 | 73 | ## Verify 74 | 75 | Run basic tests to check if `libsvt_vp9` works 76 | 77 | ```bash 78 | ./ffmpeg -f lavfi -i testsrc=duration=1:size=1280x720:rate=30 -c:v libsvt_vp9 -rc 1 -b:v 10M -preset 1 -y test.ivf 79 | ./ffmpeg -f lavfi -i testsrc=duration=1:size=1280x720:rate=30 -vframes 1000 -c:v libsvt_vp9 -y test.mp4 80 | ``` 81 | 82 | ## Note 83 | 84 | These patches can be applied in any ordering permutation along with the other SVT encoders, there is no strict ordering 85 | -------------------------------------------------------------------------------- /gstreamer-plugin/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | 3 | if(NOT MSVC AND NOT CMAKE_BUILD_TYPE) 4 | set(CMAKE_BUILD_TYPE Release) 5 | endif() 6 | 7 | project(gst-svt-vp9 C) 8 | 9 | set(POSITION_INDEPENDENT_CODE ON) 10 | 11 | include(CheckCCompilerFlag) 12 | 13 | find_package(PkgConfig REQUIRED) 14 | pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0>=1.8) 15 | pkg_check_modules(GSTREAMER_BASE REQUIRED gstreamer-base-1.0>=1.8) 16 | pkg_check_modules(GSTREAMER_VIDEO REQUIRED gstreamer-video-1.0>=1.8) 17 | pkg_check_modules(SVT_VP9 REQUIRED SvtVp9Enc) 18 | include_directories(${GSTREAMER_INCLUDE_DIRS} 19 | ${GSTREAMER_BASE_INCLUDE_DIRS} 20 | ${GSTREAMER_VIDEO_INCLUDE_DIRS} 21 | ${SVT_VP9_INCLUDE_DIRS}) 22 | 23 | set(flags_to_test 24 | -Wextra 25 | -Wformat 26 | -Wformat-security 27 | -fstack-protector-strong 28 | -fPIE 29 | -fPIC 30 | -flto 31 | -D_FORTIFY_SOURCE=2) 32 | if(MSVC) 33 | list(APPEND flags_to_test /MP) 34 | else() 35 | list(INSERT flags_to_test 0 -Wall) 36 | endif() 37 | 38 | foreach(flag ${flags_to_test}) 39 | string(REGEX 40 | REPLACE "[^A-Za-z0-9]" 41 | "_" 42 | flag_var 43 | "${flag}") 44 | set(test_c_flag "C_FLAG${flag_var}") 45 | check_c_compiler_flag(${flag} "${test_c_flag}") 46 | if(${test_c_flag}) 47 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}") 48 | endif() 49 | endforeach() 50 | 51 | if(UNIX AND NOT APPLE) 52 | set(CMAKE_SHARED_LINKER_FLAGS 53 | "${CMAKE_SHARED_LINKER_FLAGS} -z noexecstack -z relro -z now -pie") 54 | endif() 55 | 56 | add_library(gstsvtvp9enc SHARED gstsvtvp9enc.c) 57 | target_link_libraries(gstsvtvp9enc 58 | ${GSTREAMER_LIBRARIES} 59 | ${GSTREAMER_BASE_LIBRARIES} 60 | ${GSTREAMER_VIDEO_LIBRARIES} 61 | ${SVT_VP9_LIBRARIES}) 62 | 63 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 64 | set(CMAKE_INSTALL_PREFIX "${GSTREAMER_LIBDIR}") 65 | message("Install to: " ${GSTREAMER_LIBDIR}) 66 | endif() 67 | 68 | install(TARGETS gstsvtvp9enc LIBRARY DESTINATION gstreamer-1.0) 69 | 70 | message(STATUS "Build: " ${CMAKE_BUILD_TYPE}) 71 | -------------------------------------------------------------------------------- /gstreamer-plugin/gstsvtvp9enc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * Authors: Jun Tian Xavier Hallade 4 | * SPDX - License - Identifier: LGPL-2.1-or-later 5 | */ 6 | 7 | #ifndef _GST_SVTVP9ENC_H_ 8 | #define _GST_SVTVP9ENC_H_ 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | G_BEGIN_DECLS 17 | #define GST_TYPE_SVTVP9ENC \ 18 | (gst_svtvp9enc_get_type()) 19 | #define GST_SVTVP9ENC(obj) \ 20 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SVTVP9ENC,GstSvtVp9Enc)) 21 | #define GST_SVTVP9ENC_CLASS(klass) \ 22 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SVTVP9ENC,GstSvtHevcEncClass)) 23 | #define GST_IS_SVTVP9ENC(obj) \ 24 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SVTVP9ENC)) 25 | #define GST_IS_SVTVP9ENC_CLASS(obj) \ 26 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SVTVP9ENC)) 27 | 28 | typedef struct _GstSvtVp9Enc 29 | { 30 | GstVideoEncoder video_encoder; 31 | 32 | /* SVT-VP9 Encoder Handle */ 33 | EbComponentType *svt_encoder; 34 | 35 | /* GStreamer Codec state */ 36 | GstVideoCodecState *state; 37 | 38 | /* SVT-VP9 configuration */ 39 | EbSvtVp9EncConfiguration *svt_config; 40 | 41 | EbBufferHeaderType *input_buf; 42 | 43 | long long int frame_count; 44 | int dts_offset; 45 | } GstSvtVp9Enc; 46 | 47 | typedef struct _GstSvtVp9EncClass 48 | { 49 | GstVideoEncoderClass video_encoder_class; 50 | } GstSvtVp9EncClass; 51 | 52 | GType gst_svtvp9enc_get_type (void); 53 | 54 | G_END_DECLS 55 | #endif 56 | -------------------------------------------------------------------------------- /gstreamer-plugin/meson.build: -------------------------------------------------------------------------------- 1 | # standalone plugin meson configuration 2 | project('gst-svt-vp9', 'c', 3 | version : '0.1', 4 | meson_version : '>= 0.29', 5 | default_options : [ 'buildtype=debugoptimized' ]) 6 | 7 | # standard gst-plugins-bad dependencies and configuration 8 | gst_req = '>= 1.8.0' 9 | gst_dep = dependency('gstreamer-1.0', version : gst_req, 10 | fallback : ['gstreamer', 'gst_dep']) 11 | gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req, 12 | fallback : ['gstreamer', 'gstbase_dep']) 13 | gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req, 14 | fallback : ['gstreamer', 'gstvideo_dep']) 15 | plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir')) 16 | 17 | # common meson configuration 18 | svtvp9enc_dep = dependency('SvtVp9Enc') 19 | 20 | cc = meson.get_compiler('c') 21 | cc_flags = [ 22 | '-O2', 23 | '-D_FORTIFY_SOURCE=2', 24 | '-Wformat', 25 | '-Wformat-security', 26 | '-fPIE', 27 | '-fPIC', 28 | '-fstack-protector-strong', 29 | ] 30 | foreach flag: cc_flags 31 | if cc.has_argument(flag) 32 | add_global_arguments(flag, language: 'c') 33 | endif 34 | endforeach 35 | 36 | ldflags = [ 37 | '-Wl,-z,now', 38 | '-Wl,-z,relro', 39 | '-Wl,-z,noexecstack', 40 | ] 41 | foreach lflag : ldflags 42 | add_global_link_arguments(lflag, language : 'c') 43 | endforeach 44 | 45 | if svtvp9enc_dep.found() 46 | gstsvtvp9enc = library('gstsvtvp9enc', 47 | 'gstsvtvp9enc.c', 48 | dependencies: [gstbase_dep, gstvideo_dep, svtvp9enc_dep], 49 | install: true, 50 | install_dir: plugins_install_dir, 51 | ) 52 | endif 53 | --------------------------------------------------------------------------------