├── .github ├── pull_request_template.md └── workflows │ └── ci.yml ├── .gitignore ├── Build ├── linux │ └── build.sh └── windows │ └── build.bat ├── CMakeLists.txt ├── Config ├── SVTQPFile.txt ├── SVTSegmentOvFile.txt └── Sample.cfg ├── Docs ├── 10bit_packed.png ├── 10bit_unpacked.png ├── 10bit_yuv420p.png ├── 3-layer-hierarchical-low-delay.png ├── 3-layer-hierarchical-low-delay2.png ├── 3-layer-hierarchical-low-delay3.png ├── 64x64_after_2bit_compression.png ├── 64x64_after_unrolling.png ├── 64x64_block_after_unrolling.png ├── 8bit_yuv420p_1.png ├── encoding_mode_res_table.png └── svt-hevc_encoder_user_guide.md ├── LICENSE.md ├── NOTICES.md ├── README.md ├── STYLE.md ├── Source ├── API │ ├── EbApi.h │ ├── EbApi.version │ ├── EbApiVersion.h.in │ └── EbErrorCodes.h ├── App │ ├── CMakeLists.txt │ ├── EbAppConfig.c │ ├── EbAppConfig.h │ ├── EbAppContext.c │ ├── EbAppContext.h │ ├── EbAppInputy4m.c │ ├── EbAppInputy4m.h │ ├── EbAppMain.c │ ├── EbAppProcessCmd.c │ ├── EbAppString.c │ ├── EbAppString.h │ ├── EbTime.c │ └── EbTime.h └── Lib │ ├── ASM_AVX2 │ ├── CMakeLists.txt │ ├── 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 │ ├── EbIntraPrediction_AVX2.h │ ├── EbIntraPrediction_Intrinsic_AVX2.c │ ├── EbMCP16bit_Intrinsic_AVX2.c │ ├── EbMcp_AVX2.h │ ├── EbNoiseExtractAVX2.c │ ├── EbNoiseExtractAVX2.h │ ├── EbPackUnPack_Intrinsic_AVX2.c │ ├── EbPackUnPack_Intrinsic_AVX2.h │ ├── EbPictureOperators_AVX2.h │ ├── EbPictureOperators_Intrinsic_AVX2.c │ ├── EbTransforms_AVX2.h │ └── EbTransforms_Intrinsic_AVX2.c │ ├── ASM_SSE2 │ ├── CMakeLists.txt │ ├── EbApplySaoLcu16bit_Intrinsic_SSE2.c │ ├── EbAvcStyleMcp_Intrinsic_SSE2.c │ ├── EbAvcStyleMcp_SSE2.h │ ├── EbCombinedAveragingSAD_Intrinsic_SSE2.c │ ├── EbComputeMean_Intrinsic_SSE2.c │ ├── EbComputeMean_SSE2.h │ ├── EbComputeSAD_SSE2.h │ ├── EbDeblockingFilter_Intrinsic_SSE2.c │ ├── EbDeblockingFilter_SSE2.h │ ├── EbGatherSaoStatistics16bit_Intrinsic_SSE2.c │ ├── EbGatherSaoStatistics16bit_SSE2.asm │ ├── EbIntraPrediction16bit_Intrinsic_SSE2.c │ ├── EbIntraPrediction_Intrinsic_SSE2.c │ ├── EbIntraPrediction_SSE2.h │ ├── EbIntrinMacros16bit_SSE2.h │ ├── EbIntrinMacros_SSE2.h │ ├── EbInvTransform_Intrinsic_SSE2.c │ ├── EbMcp16bit_Intrinsic_SSE2.c │ ├── EbMcp_Intrinsic_SSE2.c │ ├── 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 │ ├── EbSampleAdaptiveOffset_SSE2.h │ ├── EbSaoStatistics_Intrinsic_SSE2.c │ ├── EbTransforms_Intrinsic_SSE2.c │ ├── EbTransforms_SSE2.h │ ├── x64Macro.asm │ ├── x64RegisterUtil.asm │ └── x64inc.asm │ ├── ASM_SSE4_1 │ ├── CMakeLists.txt │ ├── EbIntraPrediction16bit_Intrinsic_SSE4_1.c │ ├── EbIntraPrediction_SSE4_1.h │ ├── EbPictureOperators_Intrinsic_SSE4_1.c │ ├── EbPictureOperators_SSE4_1.h │ ├── EbTransforms_Intrinsic_SSE4_1.c │ └── EbTransforms_SSE4_1.h │ ├── ASM_SSSE3 │ ├── CMakeLists.txt │ ├── EbAvcStyleMcp_Intrinsic_SSSE3.c │ ├── EbAvcStyleMcp_SSSE3.h │ ├── EbDeblockingFilter16bit_Intrinsic_SSSE3.c │ ├── EbDeblockingFilter_Intrinsic_SSSE3.c │ ├── EbDeblockingFilter_SSSE3.h │ ├── EbIntraPrediction16bit_Intrinsic_SSSE3.c │ ├── EbIntraPrediction_SSSE3.h │ ├── EbMcp_Intrinsic_SSSE3.c │ ├── EbMcp_SSSE3.h │ ├── EbSaoApplication_Intrinsic_SSSE3.c │ ├── EbSaoApplication_SSSE3.h │ ├── EbTransforms_Intrinsic_SSSE3.c │ └── EbTransforms_SSSE3.h │ ├── CMakeLists.txt │ ├── C_DEFAULT │ ├── CMakeLists.txt │ ├── EbAvcStyleMcp_C.c │ ├── EbAvcStyleMcp_C.h │ ├── EbComputeMean_C.c │ ├── EbComputeMean_C.h │ ├── EbComputeSAD_C.c │ ├── EbComputeSAD_C.h │ ├── EbDeblockingFilter_C.c │ ├── EbDeblockingFilter_C.h │ ├── EbIntraPrediction_C.c │ ├── EbIntraPrediction_C.h │ ├── EbMcp_C.c │ ├── EbMcp_C.h │ ├── EbMeSadCalculation_C.c │ ├── EbMeSadCalculation_C.h │ ├── EbPackUnPack_C.c │ ├── EbPackUnPack_C.h │ ├── EbPictureOperators_C.c │ ├── EbPictureOperators_C.h │ ├── EbSampleAdaptiveOffset_C.c │ ├── EbSampleAdaptiveOffset_C.h │ ├── EbTransforms_C.c │ └── EbTransforms_C.h │ ├── Codec │ ├── CMakeLists.txt │ ├── EbAdaptiveMotionVectorPrediction.c │ ├── EbAdaptiveMotionVectorPrediction.h │ ├── EbAvailability.c │ ├── EbAvailability.h │ ├── EbAvcStyleMcp.c │ ├── EbAvcStyleMcp.h │ ├── EbBitstreamUnit.c │ ├── EbBitstreamUnit.h │ ├── EbCabacContextModel.c │ ├── EbCabacContextModel.h │ ├── EbCodingLoop.c │ ├── EbCodingLoop.h │ ├── EbCodingUnit.c │ ├── EbCodingUnit.h │ ├── EbCoeffEstimation_Intrinsic.c │ ├── EbComputeMean.h │ ├── EbComputeSAD.h │ ├── EbDeblockingFilter.c │ ├── EbDeblockingFilter.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 │ ├── EbEntropyCodingUtil.c │ ├── EbEntropyCodingUtil.h │ ├── EbErrorHandling.h │ ├── EbFullLoop.c │ ├── EbFullLoop.h │ ├── EbHmCode.c │ ├── EbHmCode.h │ ├── EbInitialRateControlProcess.c │ ├── EbInitialRateControlProcess.h │ ├── EbInitialRateControlReorderQueue.c │ ├── EbInitialRateControlReorderQueue.h │ ├── EbInitialRateControlResults.c │ ├── EbInitialRateControlResults.h │ ├── EbInterPrediction.c │ ├── EbInterPrediction.h │ ├── EbIntraPrediction.c │ ├── EbIntraPrediction.h │ ├── EbLambdaRateTables.h │ ├── EbMalloc.c │ ├── EbMalloc.h │ ├── EbMcp.c │ ├── EbMcp.h │ ├── EbMcpTables.c │ ├── EbMdRateEstimation.c │ ├── EbMdRateEstimation.h │ ├── EbMeSadCalculation.h │ ├── EbModeDecision.c │ ├── EbModeDecision.h │ ├── EbModeDecisionConfiguration.c │ ├── EbModeDecisionConfiguration.h │ ├── EbModeDecisionConfigurationProcess.c │ ├── EbModeDecisionConfigurationProcess.h │ ├── EbModeDecisionProcess.c │ ├── EbModeDecisionProcess.h │ ├── EbModeDecisionSegments.h │ ├── EbMotionEstimation.c │ ├── EbMotionEstimation.h │ ├── EbMotionEstimationContext.c │ ├── EbMotionEstimationContext.h │ ├── EbMotionEstimationLcuResults.h │ ├── EbMotionEstimationProcess.c │ ├── EbMotionEstimationProcess.h │ ├── EbMotionEstimationResults.c │ ├── EbMotionEstimationResults.h │ ├── EbMotionVectorUnit.h │ ├── EbMvMerge.h │ ├── EbNeighborArrays.c │ ├── EbNeighborArrays.h │ ├── EbObject.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 │ ├── EbPredictionUnit.h │ ├── EbProductCodingLoop.c │ ├── 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 │ ├── EbSampleAdaptiveOffset.h │ ├── EbSampleAdaptiveOffsetGenerationDecision.c │ ├── EbSei.c │ ├── EbSei.h │ ├── EbSequenceControlSet.c │ ├── EbSequenceControlSet.h │ ├── EbSourceBasedOperationsProcess.c │ ├── EbSourceBasedOperationsProcess.h │ ├── EbString.c │ ├── EbString.h │ ├── EbSyntaxElements.h │ ├── EbSystemResourceManager.c │ ├── EbSystemResourceManager.h │ ├── EbThreads.c │ ├── EbThreads.h │ ├── EbTransQuantBuffers.c │ ├── EbTransQuantBuffers.h │ ├── EbTransformUnit.h │ ├── EbTransforms.c │ ├── EbTransforms.h │ ├── EbUnPackProcess.c │ ├── EbUnPackProcess.h │ ├── EbUtility.c │ └── EbUtility.h │ └── pkg-config.pc.in ├── Tests ├── README.md └── SVT-HEVC_FunctionalTests.py ├── ffmpeg_plugin ├── 0002-doc-Add-libsvt_hevc-encoder-docs.patch ├── README.md ├── master-0001-lavc-svt_hevc-add-libsvt-hevc-encoder-wrapper.patch └── n4.4-0001-lavc-svt_hevc-add-libsvt-hevc-encoder-wrapper.patch └── gstreamer-plugin ├── CMakeLists.txt ├── README.md ├── gstsvthevcenc.c ├── gstsvthevcenc.h └── meson.build /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | # Description 2 | 3 | 4 | # Issue 5 | 6 | 13 | 14 | # Author(s) 15 | 16 | 17 | # Performance impact 18 | 23 | - [ ] quality 24 | - [ ] memory 25 | - [ ] speed 26 | - [ ] 8 bit 27 | - [ ] 10 bit 28 | - [ ] N/A 29 | 30 | # Merge method 31 | - [ ] Allow the maintainer to squash and merge when PR is ready to create a 1-commit to the master branch. The maintainer will be able to fix typos / combine commit messages to create a more readable 1-commit message or use whatever is stated in the 'Description' section 32 | - [ ] I will clean up my commits and the maintainer shall use 'rebase and merge' to the master branch 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.265 2 | *.hevc 3 | *.bin 4 | *.yuv 5 | *.o 6 | *.bin 7 | *.log 8 | Bin 9 | Build 10 | !Build/linux/build.sh 11 | !Build/windows/build.bat 12 | 13 | # Visual Studio user-specific files 14 | *.rsuser 15 | *.suo 16 | *.user 17 | *.userosscache 18 | *.sln.docstates 19 | .vscode 20 | 21 | # Visual C++ cache files 22 | *.aps 23 | *.ncb 24 | *.opendb 25 | *.opensdf 26 | *.sdf 27 | *.cachefile 28 | *.VC.db 29 | *.VC.VC.opendb 30 | 31 | # Visual Studio cache/options directory 32 | *.vs 33 | 34 | # Visual Studio project files 35 | *.filters 36 | *.vcxproj 37 | *.sln 38 | 39 | #cmake 40 | CMakeLists.txt.user 41 | CMakeCache.txt 42 | CMakeFiles 43 | CMakeScripts 44 | Testing 45 | Makefile 46 | cmake_install.cmake 47 | install_manifest.txt 48 | compile_commands.json 49 | CTestTestfile.cmake 50 | 51 | Source/App/SvtHevcEncApp.dir/ 52 | Source/Lib/ASM_AVX2/ASM_AVX2.dir/ 53 | Source/Lib/ASM_SSE2/ASM_SSE2.dir/ 54 | Source/Lib/ASM_SSE4_1/ASM_SSE4_1.dir/ 55 | Source/Lib/ASM_SSSE3/ASM_SSSE3.dir/ 56 | Source/Lib/C_DEFAULT/C_DEFAULT.dir/ 57 | Source/Lib/Codec/SvtHevcEnc.dir/ 58 | Source/API/EbApiVersion.h 59 | -------------------------------------------------------------------------------- /Config/SVTQPFile.txt: -------------------------------------------------------------------------------- 1 | # Copyright(c) 2018 Intel Corporation 2 | # SPDX-License-Identifier: BSD-2-Clause-Patent 3 | 4 | #====================== QP File ====================== 5 | # QP values must be passed one per line matching the frames in display order. 6 | # If the number of frames > number of QPs, the application will loop to the beginning of the file 7 | # Values should be between 1 and 51 any values other than that will be clipped to that range 8 | 9 | 23 10 | 24 11 | 25 12 | 26 13 | 23 14 | 24 15 | 25 16 | 26 17 | 27 18 | 28 19 | 29 20 | 30 -------------------------------------------------------------------------------- /Config/SVTSegmentOvFile.txt: -------------------------------------------------------------------------------- 1 | # Copyright(c) 2019 Intel Corporation 2 | # SPDX-License-Identifier: BSD-2-Clause-Patent 3 | 4 | #====================== Segment Override File ====================== 5 | # 1. Purpose/use case of this feature 6 | # This feature is for very specific use-cases like surveillance systems, where dynamic objects such as pedestrians or vehicles are detected and tracked (encoded with higher quality) while the static background is encoded with worse quality. 7 | # By encoding only the important/key areas with good quality, the resulting bitstream is smaller and still has high usefulness. 8 | # 2. Usage: 9 | # For each frame in the video, the user can specify regions with better or worse quality. 10 | # One input frame have to be preceded by the number of regions. 11 | # Each region consists of 6 numbers (X1, Y1, X2, Y2, data, mode) i.e (X1,Y1) is the top left and (X2,Y2) is the bottom right corner. Regions are allowed to overlap in the same frame. 12 | # Each region is translated into a subset of LCU(largest coding unit) for which the user can override the default qp. 13 | # The mode parameter has to be in range [1..5]. This allows the user to specify what to override by the [data] 14 | # Mode 1 Set the qp value for each region. [data] is clipped to [0:51] . 15 | # Mode 2 Change the qp value (i.e increase or decrease by [data]). [data] is clipped to [-25:25] , 16 | # Mode 3 Modify not only the quality but also blocks splitting(LCU partition). The behaviour depends on parameter 1 and 2 and the 5th parameter is unused. 17 | # Mode 4 Only modify the block's splitting(LCU partition) (i.e increase or decrease by[data]). [data] is clipped to [-25:25]. Negative value increase block division. 18 | # Mode 5 Update first stage of quantization in range [-7;7] positive value reduce bitrate, negative increase bitrate. 19 | # 20 | # If the number of frames > number of "rules" the application will loop to the beginning of the file 21 | # 22 | # There are several ways to use mode 3. You can set: 23 | # 0 0 500 500 35 1 // Set new qp value 24 | # 0 0 500 500 35 3 // Also modify the block splitting. The 5th value is skipped 25 | # or 26 | # 0 0 500 500 -5 2 // Increase the block quality by 5 27 | # 0 0 500 500 -5 3 // Also modify block splitting. The 5th value is skipped 28 | # 29 | # 3. Example: 30 | # If you want to increase the quality by 10 of an object of size 100x100 which is moving from left to right on the screen, you can use: 31 | # 1 // one region for frame 0 32 | # 0 0 100 100 -10 2 33 | # 1 // one region for frame 1 34 | # 10 0 110 100 -10 2 35 | # 1 // one region for frame 2 36 | # 20 0 120 100 -10 2 37 | # 1 // one region for frame 3 38 | # 30 0 130 100 -10 2 39 | # 1 // one region for frame 4 40 | # 40 0 140 100 -10 2 41 | # 1 // one region for frame 5 42 | # 50 0 150 100 -10 2 43 | # 1 // one region for frame 6 44 | # 60 0 160 100 -10 2 45 | 3 46 | 0 0 500 500 50 1 47 | 500 500 1000 0 -20 4 48 | 500 500 1000 1000 20 4 49 | 2 50 | 0 0 500 500 20 1 51 | 0 0 300 200 20 1 52 | -------------------------------------------------------------------------------- /Docs/10bit_packed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenVisualCloud/SVT-HEVC/4181c9ee0611baefb40b4c0ed10023cfd837d522/Docs/10bit_packed.png -------------------------------------------------------------------------------- /Docs/10bit_unpacked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenVisualCloud/SVT-HEVC/4181c9ee0611baefb40b4c0ed10023cfd837d522/Docs/10bit_unpacked.png -------------------------------------------------------------------------------- /Docs/10bit_yuv420p.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenVisualCloud/SVT-HEVC/4181c9ee0611baefb40b4c0ed10023cfd837d522/Docs/10bit_yuv420p.png -------------------------------------------------------------------------------- /Docs/3-layer-hierarchical-low-delay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenVisualCloud/SVT-HEVC/4181c9ee0611baefb40b4c0ed10023cfd837d522/Docs/3-layer-hierarchical-low-delay.png -------------------------------------------------------------------------------- /Docs/3-layer-hierarchical-low-delay2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenVisualCloud/SVT-HEVC/4181c9ee0611baefb40b4c0ed10023cfd837d522/Docs/3-layer-hierarchical-low-delay2.png -------------------------------------------------------------------------------- /Docs/3-layer-hierarchical-low-delay3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenVisualCloud/SVT-HEVC/4181c9ee0611baefb40b4c0ed10023cfd837d522/Docs/3-layer-hierarchical-low-delay3.png -------------------------------------------------------------------------------- /Docs/64x64_after_2bit_compression.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenVisualCloud/SVT-HEVC/4181c9ee0611baefb40b4c0ed10023cfd837d522/Docs/64x64_after_2bit_compression.png -------------------------------------------------------------------------------- /Docs/64x64_after_unrolling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenVisualCloud/SVT-HEVC/4181c9ee0611baefb40b4c0ed10023cfd837d522/Docs/64x64_after_unrolling.png -------------------------------------------------------------------------------- /Docs/64x64_block_after_unrolling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenVisualCloud/SVT-HEVC/4181c9ee0611baefb40b4c0ed10023cfd837d522/Docs/64x64_block_after_unrolling.png -------------------------------------------------------------------------------- /Docs/8bit_yuv420p_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenVisualCloud/SVT-HEVC/4181c9ee0611baefb40b4c0ed10023cfd837d522/Docs/8bit_yuv420p_1.png -------------------------------------------------------------------------------- /Docs/encoding_mode_res_table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenVisualCloud/SVT-HEVC/4181c9ee0611baefb40b4c0ed10023cfd837d522/Docs/encoding_mode_res_table.png -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # BSD+Patent 2 | 3 | **SPDX short identifier: BSD-2-Clause-Patent** 4 | 5 | *Note: This license is designed to provide: a) a simple permissive license; b) that is compatible with the GNU General Public License (GPL), version 2; and c) which also has an express patent grant included.* 6 | 7 | Copyright (c) 2018 Intel Corporation 8 | 9 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | 15 | Subject to the terms and conditions of this license, each copyright holder and contributor hereby grants to those receiving rights under this license a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except for failure to satisfy the conditions of this license) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer this software, where such license applies only to those patent claims, already acquired or hereafter acquired, licensable by such copyright holder or contributor that are necessarily infringed by: 16 | 17 | (a) their Contribution(s) (the licensed copyrights of copyright holders and non-copyrightable additions of contributors, in source or binary form) alone; or 18 | 19 | (b) combination of their Contribution(s) with the work of authorship to which such Contribution(s) was added by such copyright holder or contributor, if, at the time the Contribution is added, such addition causes such combination to be necessarily infringed. The patent license shall not apply to any other combinations which include the Contribution. 20 | 21 | Except as expressly stated above, no rights or licenses from any copyright holder or contributor is granted under this license, whether expressly, by implication, estoppel or otherwise. 22 | 23 | DISCLAIMER 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /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.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenVisualCloud/SVT-HEVC/4181c9ee0611baefb40b4c0ed10023cfd837d522/Source/API/EbApi.h -------------------------------------------------------------------------------- /Source/API/EbApi.version: -------------------------------------------------------------------------------- 1 | SVT_HEVC_1 { 2 | global: 3 | Eb*; 4 | local: 5 | *; 6 | }; 7 | -------------------------------------------------------------------------------- /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_HEVC_VERSION_MAJOR@) 15 | #define SVT_VERSION_MINOR (@SVT_HEVC_VERSION_MINOR@) 16 | #define SVT_VERSION_PATCHLEVEL (@SVT_HEVC_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/App/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright(c) 2018 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 | # App Source Files 13 | set(SvtHevcEncApp_Source 14 | EbAppConfig.c 15 | EbAppContext.c 16 | EbAppString.c 17 | EbAppMain.c 18 | EbAppProcessCmd.c 19 | EbTime.c 20 | EbAppInputy4m.c) 21 | 22 | if(COMPILE_AS_CPP) 23 | set_source_files_properties(${SvtHevcEncApp_Source} 24 | PROPERTIES LANGUAGE CXX) 25 | endif() 26 | 27 | add_executable(SvtHevcEncApp 28 | ${SvtHevcEncApp_Source} 29 | ../API/EbApi.h 30 | EbAppConfig.h 31 | EbAppContext.h 32 | EbAppString.h 33 | ../API/EbErrorCodes.h) 34 | 35 | #********** SET COMPILE FLAGS************ 36 | 37 | # Link the Encoder App 38 | target_link_libraries(SvtHevcEncApp 39 | SvtHevcEnc) 40 | 41 | if(UNIX) 42 | target_link_libraries(SvtHevcEncApp 43 | pthread) 44 | if(NOT APPLE) 45 | target_link_libraries(SvtHevcEncApp 46 | rt) 47 | endif() 48 | endif() 49 | 50 | install(TARGETS SvtHevcEncApp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) 51 | -------------------------------------------------------------------------------- /Source/App/EbAppContext.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbAppContext_h 7 | #define EbAppContext_h 8 | 9 | #include "EbApi.h" 10 | #include "EbAppConfig.h" 11 | 12 | /*************************************** 13 | 14 | * App Callback data struct 15 | ***************************************/ 16 | typedef struct EbAppContext_s { 17 | void *cmdSemaphoreHandle; 18 | void *inputSemaphoreHandle; 19 | void *streamSemaphoreHandle; 20 | EB_H265_ENC_CONFIGURATION ebEncParameters; 21 | 22 | // Output Ports Active Flags 23 | APPPORTACTIVETYPE outputStreamPortActive; 24 | 25 | // Component Handle 26 | EB_COMPONENTTYPE* svtEncoderHandle; 27 | 28 | // Buffer Pools 29 | EB_BUFFERHEADERTYPE *inputBufferPool; 30 | EB_BUFFERHEADERTYPE *reconBuffer; 31 | 32 | // Instance Index 33 | uint8_t instanceIdx; 34 | 35 | } EbAppContext_t; 36 | 37 | 38 | /******************************** 39 | * External Function 40 | ********************************/ 41 | extern EB_ERRORTYPE InitEncoder(EbConfig_t *config, EbAppContext_t *callbackData, uint32_t instanceIdx); 42 | extern EB_ERRORTYPE DeInitEncoder(EbAppContext_t *callbackDataPtr, uint32_t instanceIndex); 43 | 44 | #endif // EbAppContext_h -------------------------------------------------------------------------------- /Source/App/EbAppInputy4m.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "EbAppConfig.h" 12 | 13 | #define YUV4MPEG2_IND_SIZE 9 // EB_STRLEN("YUV4MPEG2", MAX_STRING_LENGTH) 14 | 15 | int32_t read_y4m_header(EbConfig_t *cfg); 16 | 17 | int32_t read_y4m_frame_delimiter(EbConfig_t *cfg); 18 | 19 | EB_BOOL check_if_y4m(EbConfig_t *cfg); 20 | -------------------------------------------------------------------------------- /Source/App/EbTime.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | #include 6 | #ifndef EbTime_h 7 | #define EbTime_h 8 | 9 | void EbHevcStartTime(uint64_t *Startseconds, uint64_t *Startuseconds); 10 | void EbHevcFinishTime(uint64_t *Finishseconds, uint64_t *Finishuseconds); 11 | void EbHevcComputeOverallElapsedTime(uint64_t Startseconds, uint64_t Startuseconds,uint64_t Finishseconds, uint64_t Finishuseconds, double *duration); 12 | void EbAppStartTime(uint64_t *Startseconds, uint64_t *Startuseconds); 13 | void EbAppFinishTime(uint64_t *Finishseconds, uint64_t *Finishuseconds); 14 | void EbAppComputeOverallElapsedTime(uint64_t Startseconds, uint64_t Startuseconds,uint64_t Finishseconds, uint64_t Finishuseconds, double *duration); 15 | void EbHevcComputeOverallElapsedTimeMs(uint64_t Startseconds, uint64_t Startuseconds, uint64_t Finishseconds, uint64_t Finishuseconds, double *duration); 16 | void EbSleep(uint64_t milliSeconds); 17 | void EbInjector(uint64_t processedFrameCount, uint32_t injectorFrameRate); 18 | 19 | #endif // EbTime_h 20 | /* File EOF */ 21 | -------------------------------------------------------------------------------- /Source/Lib/ASM_AVX2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright(c) 2018 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 | link_directories(${PROJECT_SOURCE_DIR}/Source/Lib/ASM_SSSE3/) 17 | 18 | set(flags_to_test 19 | -mavx2 20 | -static-intel 21 | /Qwd10148 22 | /Qwd10010 23 | /Qwd10157) 24 | 25 | foreach(cflag ${flags_to_test}) 26 | string(REGEX REPLACE "[^A-Za-z0-9]" "_" cflag_var "${cflag}") 27 | set(test_c_flag "C_FLAG${cflag_var}") 28 | if(COMPILE_AS_CPP) 29 | set(test_cxx_flag "CXX_FLAG${cflag_var}") 30 | endif() 31 | check_c_compiler_flag(${cflag} "${test_c_flag}") 32 | if(COMPILE_AS_CPP) 33 | check_cxx_compiler_flag(${cflag} "${test_cxx_flag}") 34 | endif() 35 | if(${test_c_flag}) 36 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${cflag}") 37 | endif() 38 | if(COMPILE_AS_CPP) 39 | if(${test_cxx_flag}) 40 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cflag}") 41 | endif() 42 | endif() 43 | endforeach() 44 | 45 | if(MSVC) 46 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:AVX2") 47 | if(COMPILE_AS_CPP) 48 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2") 49 | endif() 50 | elseif(CMAKE_C_COMPILER_ID STREQUAL "Intel") 51 | if(WIN32) 52 | # Intel Windows (*Note - The Warning level /W0 should be made to /W4 at some point) 53 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W0") 54 | if(COMPILE_AS_CPP) 55 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0") 56 | endif() 57 | else() 58 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") 59 | if(COMPILE_AS_CPP) 60 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") 61 | endif() 62 | endif() 63 | endif() 64 | 65 | if(CMAKE_C_COMPILER_VERSION VERSION_EQUAL 5.4) 66 | string(REPLACE "-flto" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") 67 | if(COMPILE_AS_CPP) 68 | string(REPLACE "-flto" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 69 | endif() 70 | endif() 71 | 72 | set(ASM_AVX2_SOURCE 73 | EbCombinedAveragingSAD_Intrinsic_AVX2.c 74 | EbCombinedAveragingSAD_Intrinsic_AVX512.c 75 | EbComputeSAD_Intrinsic_AVX2.c 76 | EbComputeSAD_SadLoopKernel_AVX512.c 77 | EbIntraPrediction_Intrinsic_AVX2.c 78 | EbMCP16bit_Intrinsic_AVX2.c 79 | EbNoiseExtractAVX2.c 80 | EbPackUnPack_Intrinsic_AVX2.c 81 | EbPictureOperators_Intrinsic_AVX2.c 82 | EbTransforms_Intrinsic_AVX2.c) 83 | 84 | if(COMPILE_AS_CPP) 85 | set_source_files_properties(${ASM_AVX2_SOURCE} 86 | PROPERTIES LANGUAGE CXX) 87 | endif() 88 | 89 | add_library(HEVC_ASM_AVX2 OBJECT 90 | ${ASM_AVX2_SOURCE} 91 | EbCombinedAveragingSAD_Intrinsic_AVX2.h 92 | EbCombinedAveragingSAD_Intrinsic_AVX512.h 93 | EbComputeSAD_AVX2.h 94 | EbComputeSAD_SadLoopKernel_AVX512.h 95 | EbIntraPrediction_AVX2.h 96 | EbMcp_AVX2.h 97 | EbNoiseExtractAVX2.h 98 | EbPackUnPack_Intrinsic_AVX2.h 99 | EbPictureOperators_AVX2.h 100 | EbTransforms_AVX2.h) 101 | -------------------------------------------------------------------------------- /Source/Lib/ASM_AVX2/EbCombinedAveragingSAD_Intrinsic_AVX2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | EB_U64 ComputeMean8x8_AVX2_INTRIN( 15 | EB_U8 * inputSamples, // input parameter, input samples Ptr 16 | EB_U32 inputStride, // input parameter, input stride 17 | EB_U32 inputAreaWidth, // input parameter, input area width 18 | EB_U32 inputAreaHeight); 19 | 20 | void ComputeIntermVarFour8x8_AVX2_INTRIN( 21 | EB_U8 * inputSamples, 22 | EB_U16 inputStride, 23 | EB_U64 * meanOf8x8Blocks, // mean of four 8x8 24 | EB_U64 * meanOfSquared8x8Blocks); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | #endif 30 | -------------------------------------------------------------------------------- /Source/Lib/ASM_AVX2/EbCombinedAveragingSAD_Intrinsic_AVX512.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | EB_U64 ComputeMean8x8_AVX2_INTRIN( 16 | EB_U8 * inputSamples, // input parameter, input samples Ptr 17 | EB_U32 inputStride, // input parameter, input stride 18 | EB_U32 inputAreaWidth, // input parameter, input area width 19 | EB_U32 inputAreaHeight); 20 | 21 | void ComputeIntermVarFour8x8_AVX2_INTRIN( 22 | EB_U8 * inputSamples, 23 | EB_U16 inputStride, 24 | EB_U64 * meanOf8x8Blocks, // mean of four 8x8 25 | EB_U64 * meanOfSquared8x8Blocks); 26 | #ifndef NON_AVX512_SUPPORT 27 | void BiPredAverageKernel_AVX512_INTRIN( 28 | EB_BYTE src0, 29 | EB_U32 src0Stride, 30 | EB_BYTE src1, 31 | EB_U32 src1Stride, 32 | EB_BYTE dst, 33 | EB_U32 dstStride, 34 | EB_U32 areaWidth, 35 | EB_U32 areaHeight); 36 | #else 37 | void BiPredAverageKernel_AVX2_INTRIN( 38 | EB_BYTE src0, 39 | EB_U32 src0Stride, 40 | EB_BYTE src1, 41 | EB_U32 src1Stride, 42 | EB_BYTE dst, 43 | EB_U32 dstStride, 44 | EB_U32 areaWidth, 45 | EB_U32 areaHeight); 46 | #endif 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | #endif 52 | -------------------------------------------------------------------------------- /Source/Lib/ASM_AVX2/EbComputeSAD_SadLoopKernel_AVX512.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 NON_AVX512_SUPPORT 17 | void SadLoopKernel_AVX512_HmeL0_INTRIN( 18 | EB_U8 *src, // input parameter, source samples Ptr 19 | EB_U32 srcStride, // input parameter, source stride 20 | EB_U8 *ref, // input parameter, reference samples Ptr 21 | EB_U32 refStride, // input parameter, reference stride 22 | EB_U32 height, // input parameter, block height (M) 23 | EB_U32 width, // input parameter, block width (N) 24 | EB_U64 *bestSad, 25 | EB_S16 *xSearchCenter, 26 | EB_S16 *ySearchCenter, 27 | EB_U32 srcStrideRaw, // input parameter, source stride (no line skipping) 28 | EB_S16 searchAreaWidth, 29 | EB_S16 searchAreaHeight); 30 | #else 31 | void SadLoopKernel_AVX2_HmeL0_INTRIN( 32 | EB_U8 *src, // input parameter, source samples Ptr 33 | EB_U32 srcStride, // input parameter, source stride 34 | EB_U8 *ref, // input parameter, reference samples Ptr 35 | EB_U32 refStride, // input parameter, reference stride 36 | EB_U32 height, // input parameter, block height (M) 37 | EB_U32 width, // input parameter, block width (N) 38 | EB_U64 *bestSad, 39 | EB_S16 *xSearchCenter, 40 | EB_S16 *ySearchCenter, 41 | EB_U32 srcStrideRaw, // input parameter, source stride (no line skipping) 42 | EB_S16 searchAreaWidth, 43 | EB_S16 searchAreaHeight); 44 | #endif 45 | 46 | #ifndef NON_AVX512_SUPPORT 47 | extern void GetEightHorizontalSearchPointResultsAll85PUs_AVX512_INTRIN( 48 | MeContext_t *contextPtr, 49 | EB_U32 listIndex, 50 | EB_U32 searchRegionIndex, 51 | EB_U32 xSearchIndex, 52 | EB_U32 ySearchIndex 53 | ); 54 | #endif 55 | 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | #endif // EbComputeSAD_AVX512_h 61 | 62 | -------------------------------------------------------------------------------- /Source/Lib/ASM_AVX2/EbMcp_AVX2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | 7 | #ifndef EBMCP_AVX2_H 8 | #define EBMCP_AVX2_H 9 | 10 | #include "EbDefinitions.h" 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #define USE_PRE_COMPUTE 0 16 | 17 | // extern EB_ALIGN(16) const EB_S16 IntraPredictionConst_AVX2[344]; 18 | 19 | void ChromaInterpolationFilterOneDOutRaw16bitHorizontal_AVX2_INTRIN(EB_U16 *refPic, EB_U32 srcStride, EB_S16 *dst, EB_U32 puWidth, EB_U32 puHeight, EB_S16 *firstPassIFDst, EB_U32 fracPosx, EB_U32 fracPosy); 20 | void ChromaInterpolationFilterTwoD16bit_AVX2_INTRIN(EB_U16 *refPic, EB_U32 srcStride, EB_U16 *dst, EB_U32 dstStride, EB_U32 puWidth, EB_U32 puHeight, EB_S16 *firstPassIFDst, EB_U32 fracPosx, EB_U32 fracPosy); 21 | void ChromaInterpolationFilterTwoDOutRaw16bit_AVX2_INTRIN(EB_U16 *refPic, EB_U32 srcStride, EB_S16 *dst, EB_U32 puWidth, EB_U32 puHeight, EB_S16 *firstPassIFDst, EB_U32 fracPosx, EB_U32 fracPosy); 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | #endif // EBMCP_AVX2_H 27 | -------------------------------------------------------------------------------- /Source/Lib/ASM_AVX2/EbNoiseExtractAVX2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | /******************************************* 18 | * noiseExtractLumaWeak 19 | * weak filter Luma and store noise. 20 | *******************************************/ 21 | void noiseExtractLumaWeak_AVX2_INTRIN( 22 | EbPictureBufferDesc_t *inputPicturePtr, 23 | EbPictureBufferDesc_t *denoisedPicturePtr, 24 | EbPictureBufferDesc_t *noisePicturePtr, 25 | EB_U32 lcuOriginY, 26 | EB_U32 lcuOriginX 27 | ); 28 | 29 | void noiseExtractLumaWeakLcu_AVX2_INTRIN( 30 | EbPictureBufferDesc_t *inputPicturePtr, 31 | EbPictureBufferDesc_t *denoisedPicturePtr, 32 | EbPictureBufferDesc_t *noisePicturePtr, 33 | EB_U32 lcuOriginY, 34 | EB_U32 lcuOriginX 35 | ); 36 | 37 | void noiseExtractChromaStrong_AVX2_INTRIN( 38 | EbPictureBufferDesc_t *inputPicturePtr, 39 | EbPictureBufferDesc_t *denoisedPicturePtr, 40 | EB_U32 lcuOriginY, 41 | EB_U32 lcuOriginX); 42 | 43 | void noiseExtractChromaWeak_AVX2_INTRIN( 44 | EbPictureBufferDesc_t *inputPicturePtr, 45 | EbPictureBufferDesc_t *denoisedPicturePtr, 46 | EB_U32 lcuOriginY, 47 | EB_U32 lcuOriginX); 48 | 49 | void noiseExtractLumaStrong_AVX2_INTRIN( 50 | EbPictureBufferDesc_t *inputPicturePtr, 51 | EbPictureBufferDesc_t *denoisedPicturePtr, 52 | EB_U32 lcuOriginY, 53 | EB_U32 lcuOriginX); 54 | 55 | void ChromaStrong_AVX2_INTRIN( 56 | __m256i top, 57 | __m256i curr, 58 | __m256i bottom, 59 | __m256i currPrev, 60 | __m256i currNext, 61 | __m256i topPrev, 62 | __m256i topNext, 63 | __m256i bottomPrev, 64 | __m256i bottomNext, 65 | EB_U8 *ptrDenoised); 66 | 67 | void lumaWeakFilter_AVX2_INTRIN( 68 | __m256i top, 69 | __m256i curr, 70 | __m256i bottom, 71 | __m256i currPrev, 72 | __m256i currNext, 73 | EB_U8 *ptrDenoised, 74 | EB_U8 *ptrNoise); 75 | 76 | 77 | void chromaWeakLumaStrongFilter_AVX2_INTRIN( 78 | __m256i top, 79 | __m256i curr, 80 | __m256i bottom, 81 | __m256i currPrev, 82 | __m256i currNext, 83 | __m256i topPrev, 84 | __m256i topNext, 85 | __m256i bottomPrev, 86 | __m256i bottomNext, 87 | EB_U8 *ptrDenoised); 88 | 89 | #ifdef __cplusplus 90 | } 91 | #endif 92 | #endif // EbNoiseExtractAVX2_h 93 | 94 | -------------------------------------------------------------------------------- /Source/Lib/ASM_AVX2/EbPackUnPack_Intrinsic_AVX2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #ifndef NON_AVX512_SUPPORT 16 | void EB_ENC_msbUnPack2D_AVX512_INTRIN( 17 | EB_U16 *in16BitBuffer, 18 | EB_U32 inStride, 19 | EB_U8 *out8BitBuffer, 20 | EB_U8 *outnBitBuffer, 21 | EB_U32 out8Stride, 22 | EB_U32 outnStride, 23 | EB_U32 width, 24 | EB_U32 height); 25 | #else 26 | void EB_ENC_msbUnPack2D_AVX2_INTRIN( 27 | EB_U16 *in16BitBuffer, 28 | EB_U32 inStride, 29 | EB_U8 *out8BitBuffer, 30 | EB_U8 *outnBitBuffer, 31 | EB_U32 out8Stride, 32 | EB_U32 outnStride, 33 | EB_U32 width, 34 | EB_U32 height); 35 | #endif 36 | 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif // EbPackUnPack_AVX2_h 43 | -------------------------------------------------------------------------------- /Source/Lib/ASM_AVX2/EbPictureOperators_AVX2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbPictureOperators_AVX2 7 | #define EbPictureOperators_AVX2 8 | 9 | #include "EbDefinitions.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | extern void EB_ENC_msbPack2D_AVX2_INTRIN_AL( 16 | EB_U8 *in8BitBuffer, 17 | EB_U32 in8Stride, 18 | EB_U8 *innBitBuffer, 19 | EB_U16 *out16BitBuffer, 20 | EB_U32 innStride, 21 | EB_U32 outStride, 22 | EB_U32 width, 23 | EB_U32 height); 24 | 25 | 26 | extern void CompressedPackmsb_AVX2_INTRIN( 27 | EB_U8 *in8BitBuffer, 28 | EB_U32 in8Stride, 29 | EB_U8 *innBitBuffer, 30 | EB_U16 *out16BitBuffer, 31 | EB_U32 innStride, 32 | EB_U32 outStride, 33 | EB_U32 width, 34 | EB_U32 height); 35 | 36 | 37 | void CPack_AVX2_INTRIN( 38 | const EB_U8 *innBitBuffer, 39 | EB_U32 innStride, 40 | EB_U8 *inCompnBitBuffer, 41 | EB_U32 outStride, 42 | EB_U8 *localCache, 43 | EB_U32 width, 44 | EB_U32 height); 45 | 46 | 47 | void UnpackAvg_AVX2_INTRIN( 48 | EB_U16 *ref16L0, 49 | EB_U32 refL0Stride, 50 | EB_U16 *ref16L1, 51 | EB_U32 refL1Stride, 52 | EB_U8 *dstPtr, 53 | EB_U32 dstStride, 54 | EB_U32 width, 55 | EB_U32 height); 56 | 57 | EB_S32 sumResidual8bit_AVX2_INTRIN( 58 | EB_S16 * inPtr, 59 | EB_U32 size, 60 | EB_U32 strideIn ); 61 | void memset16bitBlock_AVX2_INTRIN ( 62 | EB_S16 * inPtr, 63 | EB_U32 strideIn, 64 | EB_U32 size, 65 | EB_S16 value 66 | ); 67 | 68 | 69 | void UnpackAvgSafeSub_AVX2_INTRIN( 70 | EB_U16 *ref16L0, 71 | EB_U32 refL0Stride, 72 | EB_U16 *ref16L1, 73 | EB_U32 refL1Stride, 74 | EB_U8 *dstPtr, 75 | EB_U32 dstStride, 76 | EB_U32 width, 77 | EB_U32 height); 78 | 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | #endif // EbPictureOperators_AVX2 83 | -------------------------------------------------------------------------------- /Source/Lib/ASM_AVX2/EbTransforms_AVX2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 "EbDefinitions.h" 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | void QuantizeInvQuantize8x8_AVX2_INTRIN( 15 | EB_S16 *coeff, 16 | const EB_U32 coeffStride, 17 | EB_S16 *quantCoeff, 18 | EB_S16 *reconCoeff, 19 | const EB_U32 qFunc, 20 | const EB_U32 q_offset, 21 | const EB_S32 shiftedQBits, 22 | const EB_S32 shiftedFFunc, 23 | const EB_S32 iq_offset, 24 | const EB_S32 shiftNum, 25 | const EB_U32 areaSize, 26 | EB_U32 *nonzerocoeff); 27 | 28 | void QuantizeInvQuantizeNxN_AVX2_INTRIN( 29 | EB_S16 *coeff, 30 | const EB_U32 coeffStride, 31 | EB_S16 *quantCoeff, 32 | EB_S16 *reconCoeff, 33 | const EB_U32 qFunc, 34 | const EB_U32 q_offset, 35 | const EB_S32 shiftedQBits, 36 | const EB_S32 shiftedFFunc, 37 | const EB_S32 iq_offset, 38 | const EB_S32 shiftNum, 39 | const EB_U32 areaSize, 40 | EB_U32 *nonzerocoeff); 41 | 42 | void lowPrecisionTransform16x16_AVX2_INTRIN(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_stride, EB_S16 *intermediate, EB_U32 addshift); 43 | void lowPrecisionTransform32x32_AVX2_INTRIN(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_stride, EB_S16 *intermediate, EB_U32 addshift); 44 | 45 | void PfreqTransform32x32_AVX2_INTRIN( 46 | EB_S16 *src, 47 | const EB_U32 src_stride, 48 | EB_S16 *dst, 49 | const EB_U32 dst_stride, 50 | EB_S16 *intermediate, 51 | EB_U32 addshift); 52 | 53 | void PfreqN4Transform32x32_AVX2_INTRIN( 54 | EB_S16 *src, 55 | const EB_U32 src_stride, 56 | EB_S16 *dst, 57 | const EB_U32 dst_stride, 58 | EB_S16 *intermediate, 59 | EB_U32 addshift); 60 | 61 | void MatMult4x4_AVX2_INTRIN( 62 | EB_S16* coeff, 63 | const EB_U32 coeffStride, 64 | const EB_U16 *maskingMatrix, 65 | const EB_U32 maskingMatrixStride, //Matrix size 66 | const EB_U32 computeSize, //Computation area size 67 | const EB_S32 offset, //(PMP_MAX >> 1) 68 | const EB_S32 shiftNum, //PMP_PRECISION 69 | EB_U32* nonzerocoeff); 70 | 71 | void MatMult4x4_OutBuff_AVX2_INTRIN( 72 | EB_S16* coeff, 73 | const EB_U32 coeffStride, 74 | EB_S16* coeffOut, 75 | const EB_U32 coeffOutStride, 76 | 77 | const EB_U16 *maskingMatrix, 78 | const EB_U32 maskingMatrixStride, 79 | const EB_U32 computeSize, 80 | const EB_S32 offset, 81 | const EB_S32 shiftNum, 82 | EB_U32* nonzerocoeff); 83 | 84 | 85 | void MatMult8x8_AVX2_INTRIN( 86 | EB_S16* coeff, 87 | const EB_U32 coeffStride, 88 | const EB_U16 *maskingMatrix, 89 | const EB_U32 maskingMatrixStride, //Matrix size 90 | const EB_U32 computeSize, //Computation area size 91 | const EB_S32 offset, //(PMP_MAX >> 1) 92 | const EB_S32 shiftNum, //PMP_PRECISION 93 | EB_U32* nonzerocoeff); 94 | 95 | void MatMultNxN_AVX2_INTRIN( 96 | EB_S16* coeff, 97 | const EB_U32 coeffStride, 98 | const EB_U16 *maskingMatrix, 99 | const EB_U32 maskingMatrixStride, //Matrix size 100 | const EB_U32 computeSize, //Computation area size 101 | const EB_S32 offset, //(PMP_MAX >> 1) 102 | const EB_S32 shiftNum, //PMP_PRECISION 103 | EB_U32* nonzerocoeff); 104 | 105 | 106 | 107 | #ifdef __cplusplus 108 | } 109 | #endif 110 | #endif // EbTransforms_AVX2_h 111 | 112 | 113 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright(c) 2018 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 | 14 | set(flags_to_test 15 | -msse2 16 | -msse4.1 17 | -static-intel) 18 | 19 | foreach(cflag ${flags_to_test}) 20 | string(REGEX REPLACE "[^A-Za-z0-9]" "_" cflag_var "${cflag}") 21 | set(test_c_flag "C_FLAG${cflag_var}") 22 | if(COMPILE_AS_CPP) 23 | set(test_cxx_flag "CXX_FLAG${cflag_var}") 24 | endif() 25 | check_c_compiler_flag(${cflag} "${test_c_flag}") 26 | if(COMPILE_AS_CPP) 27 | check_cxx_compiler_flag(${cflag} "${test_cxx_flag}") 28 | endif() 29 | if(${test_c_flag}) 30 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${cflag}") 31 | endif() 32 | if(COMPILE_AS_CPP) 33 | if(${test_cxx_flag}) 34 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cflag}") 35 | endif() 36 | endif() 37 | endforeach() 38 | 39 | if(CMAKE_C_COMPILER_ID STREQUAL "Intel") 40 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") 41 | if(COMPILE_AS_CPP) 42 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") 43 | endif() 44 | endif() 45 | 46 | set(ASM_SSE2_SOURCE 47 | EbApplySaoLcu16bit_Intrinsic_SSE2.c 48 | EbAvcStyleMcp_Intrinsic_SSE2.c 49 | EbCombinedAveragingSAD_Intrinsic_SSE2.c 50 | EbComputeMean_Intrinsic_SSE2.c 51 | EbDeblockingFilter_Intrinsic_SSE2.c 52 | EbGatherSaoStatistics16bit_Intrinsic_SSE2.c 53 | EbIntraPrediction16bit_Intrinsic_SSE2.c 54 | EbIntraPrediction_Intrinsic_SSE2.c 55 | EbInvTransform_Intrinsic_SSE2.c 56 | EbMcp16bit_Intrinsic_SSE2.c 57 | EbMcp_Intrinsic_SSE2.c 58 | EbMeSadCalculation_Intrinsic_SSE2.c 59 | EbPackUnPack_Intrinsic_SSE2.c 60 | EbPictureOperators_Intrinsic_SSE2.c 61 | EbSaoStatistics_Intrinsic_SSE2.c 62 | EbTransforms_Intrinsic_SSE2.c) 63 | 64 | if(COMPILE_AS_CPP) 65 | set_source_files_properties(${ASM_SSE2_SOURCE} 66 | PROPERTIES LANGUAGE CXX) 67 | endif() 68 | 69 | # Utility Source Files 70 | add_library(HEVC_ASM_SSE2 OBJECT 71 | ${ASM_SSE2_SOURCE} 72 | EbAvcStyleMcp_SSE2.h 73 | EbComputeMean_SSE2.h 74 | EbComputeSAD_SSE2.h 75 | EbDeblockingFilter_SSE2.h 76 | EbIntraPrediction_SSE2.h 77 | EbIntrinMacros16bit_SSE2.h 78 | EbIntrinMacros_SSE2.h 79 | EbMcp_SSE2.h 80 | EbMeSadCalculation_SSE2.h 81 | EbPackUnPack_SSE2.h 82 | EbPictureOperators_SSE2.h 83 | EbSampleAdaptiveOffset_SSE2.h 84 | EbTransforms_SSE2.h 85 | EbGatherSaoStatistics16bit_SSE2.asm 86 | EbPictureOperators_SSE2.asm 87 | x64inc.asm 88 | x64Macro.asm 89 | x64RegisterUtil.asm) 90 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE2/EbAvcStyleMcp_SSE2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 AvcStyleCopy_SSE2(EB_BYTE refPic, EB_U32 srcStride, EB_BYTE dst, EB_U32 dstStride, EB_U32 puWidth, EB_U32 puHeight, EB_BYTE tempBuf, EB_U32 fracPos); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | #endif //EBAVCSTYLEMCP_H -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE2/EbComputeMean_SSE2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | EB_U64 ComputeSubMean8x8_SSE2_INTRIN( 15 | EB_U8 * inputSamples, // input parameter, input samples Ptr 16 | EB_U16 inputStride); 17 | EB_U64 ComputeSubdMeanOfSquaredValues8x8_SSE2_INTRIN( 18 | EB_U8 * inputSamples, // input parameter, input samples Ptr 19 | EB_U16 inputStride); 20 | 21 | EB_U64 ComputeMeanOfSquaredValues8x8_SSE2_INTRIN( 22 | EB_U8 * inputSamples, // input parameter, input samples Ptr 23 | EB_U32 inputStride, // input parameter, input stride 24 | EB_U32 inputAreaWidth, // input parameter, input area width 25 | EB_U32 inputAreaHeight); // input parameter, input area height 26 | 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE2/EbDeblockingFilter_SSE2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbDeblockingFilter_SSE2_h 7 | #define EbDeblockingFilter_SSE2_h 8 | 9 | #include "EbDefinitions.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | extern void Chroma2SampleEdgeDLFCore16bit_SSE2_INTRIN( 16 | EB_U16 *edgeStartSampleCb, 17 | EB_U16 *edgeStartSampleCr, 18 | EB_U32 reconChromaPicStride, 19 | EB_BOOL isVerticalEdge, 20 | EB_U8 cbTc, 21 | EB_U8 crTc); 22 | 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | #endif -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE2/EbIntrinMacros16bit_SSE2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | #define MACRO_VERTICAL_LUMA_8(ARG1, ARG2, ARG3)\ 10 | _mm_storeu_si128((__m128i *)predictionPtr, _mm_or_si128(_mm_and_si128(ARG1, ARG2), ARG3));\ 11 | ARG1 = _mm_srli_si128(ARG1, 2);\ 12 | _mm_storeu_si128((__m128i *)(predictionPtr + pStride), _mm_or_si128(_mm_and_si128(ARG1, ARG2), ARG3));\ 13 | ARG1 = _mm_srli_si128(ARG1, 2);\ 14 | _mm_storeu_si128((__m128i *)(predictionPtr + 2 * pStride), _mm_or_si128(_mm_and_si128(ARG1, ARG2), ARG3));\ 15 | ARG1 = _mm_srli_si128(ARG1, 2);\ 16 | _mm_storeu_si128((__m128i *)(predictionPtr + 3 * pStride), _mm_or_si128(_mm_and_si128(ARG1, ARG2), ARG3));\ 17 | ARG1 = _mm_srli_si128(ARG1, 2); 18 | 19 | #define MACRO_UNPACK(ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7, ARG8, ARG9, ARG10, ARG11, ARG12, ARG13)\ 20 | ARG10 = _mm_unpackhi_epi##ARG1(ARG2, ARG3);\ 21 | ARG2 = _mm_unpacklo_epi##ARG1(ARG2, ARG3);\ 22 | ARG11 = _mm_unpackhi_epi##ARG1(ARG4, ARG5);\ 23 | ARG4 = _mm_unpacklo_epi##ARG1(ARG4, ARG5);\ 24 | ARG12 = _mm_unpackhi_epi##ARG1(ARG6, ARG7);\ 25 | ARG6 = _mm_unpacklo_epi##ARG1(ARG6, ARG7);\ 26 | ARG13 = _mm_unpackhi_epi##ARG1(ARG8, ARG9);\ 27 | ARG8 = _mm_unpacklo_epi##ARG1(ARG8, ARG9); 28 | 29 | #define MACRO_UNPACK_V2(ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7, ARG8, ARG9, ARG10, ARG11)\ 30 | ARG10 = _mm_unpackhi_epi##ARG1(ARG2, ARG3);\ 31 | ARG2 = _mm_unpacklo_epi##ARG1(ARG2, ARG3);\ 32 | ARG11 = _mm_unpackhi_epi##ARG1(ARG4, ARG5);\ 33 | ARG4 = _mm_unpacklo_epi##ARG1(ARG4, ARG5);\ 34 | ARG6 = _mm_unpacklo_epi##ARG1(ARG6, ARG7);\ 35 | ARG8 = _mm_unpacklo_epi##ARG1(ARG8, ARG9); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE2/EbIntrinMacros_SSE2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #define MACRO_VERTICAL_LUMA_8(A, B, C)\ 11 | _mm_storel_epi64((__m128i*)predictionPtr, _mm_or_si128(_mm_and_si128(A, B), C)); \ 12 | A = _mm_srli_si128(A, 1); \ 13 | _mm_storel_epi64((__m128i*)(predictionPtr + pStride), _mm_or_si128(_mm_and_si128(A, B), C)); \ 14 | A = _mm_srli_si128(A, 1); \ 15 | _mm_storel_epi64((__m128i*)(predictionPtr + 2*pStride), _mm_or_si128(_mm_and_si128(A, B), C)); \ 16 | A = _mm_srli_si128(A, 1); \ 17 | _mm_storel_epi64((__m128i*)(predictionPtr + 3*pStride), _mm_or_si128(_mm_and_si128(A, B), C)); \ 18 | A = _mm_srli_si128(A, 1); 19 | 20 | #define MACRO_VERTICAL_LUMA_16(A, B, C)\ 21 | _mm_storeu_si128((__m128i*)predictionPtr, _mm_or_si128(_mm_and_si128(A, B), C)); \ 22 | A = _mm_srli_si128(A, 1); \ 23 | _mm_storeu_si128((__m128i*)(predictionPtr + pStride), _mm_or_si128(_mm_and_si128(A, B), C)); \ 24 | A = _mm_srli_si128(A, 1); \ 25 | _mm_storeu_si128((__m128i*)(predictionPtr + 2*pStride), _mm_or_si128(_mm_and_si128(A, B), C)); \ 26 | A = _mm_srli_si128(A, 1); \ 27 | _mm_storeu_si128((__m128i*)(predictionPtr + 3*pStride), _mm_or_si128(_mm_and_si128(A, B), C)); \ 28 | A = _mm_srli_si128(A, 1); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE2/EbMcp_Intrinsic_SSE2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include "EbDefinitions.h" 7 | #include "EbMcp_SSE2.h" 8 | 9 | #ifdef __GNUC__ 10 | #ifndef __cplusplus 11 | __attribute__((visibility("hidden"))) 12 | #endif 13 | #endif 14 | EB_ALIGN(16) const EB_S16 IntraPredictionConst_SSE2[344]= { 15 | 17, 19, 21, 23, 25, 27, 29, 31, 16 | 1, 3, 5, 7, 9, 11, 13, 15, 17 | 25, 26, 27, 28, 29, 30, 31, 32, 18 | 17, 18, 19, 20, 21, 22, 23, 24, 19 | 9, 10, 11, 12, 13, 14, 15, 16, 20 | 1, 2, 3, 4, 5, 6, 7, 8, 21 | 31, 30, 29, 28, 27, 26, 25, 24, 22 | 23, 22, 21, 20, 19, 18, 17, 16, 23 | 15, 14, 13, 12, 11, 10, 9, 8, 24 | 7, 6, 5, 4, 3, 2, 1, 0, 25 | 0, 0, 0, 0, 0, 0, 0, 0, 26 | 1, 1, 1, 1, 1, 1, 1, 1, 27 | 2, 2, 2, 2, 2, 2, 2, 2, 28 | 3, 3, 3, 3, 3, 3, 3, 3, 29 | 4, 4, 4, 4, 4, 4, 4, 4, 30 | 5, 5, 5, 5, 5, 5, 5, 5, 31 | 6, 6, 6, 6, 6, 6, 6, 6, 32 | 7, 7, 7, 7, 7, 7, 7, 7, 33 | 8, 8, 8, 8, 8, 8, 8, 8, 34 | 9, 9, 9, 9, 9, 9, 9, 9, 35 | 10, 10, 10, 10, 10, 10, 10, 10, 36 | 11, 11, 11, 11, 11, 11, 11, 11, 37 | 12, 12, 12, 12, 12, 12, 12, 12, 38 | 13, 13, 13, 13, 13, 13, 13, 13, 39 | 14, 14, 14, 14, 14, 14, 14, 14, 40 | 15, 15, 15, 15, 15, 15, 15, 15, 41 | 16, 16, 16, 16, 16, 16, 16, 16, 42 | 17, 17, 17, 17, 17, 17, 17, 17, 43 | 18, 18, 18, 18, 18, 18, 18, 18, 44 | 19, 19, 19, 19, 19, 19, 19, 19, 45 | 20, 20, 20, 20, 20, 20, 20, 20, 46 | 21, 21, 21, 21, 21, 21, 21, 21, 47 | 22, 22, 22, 22, 22, 22, 22, 22, 48 | 23, 23, 23, 23, 23, 23, 23, 23, 49 | 24, 24, 24, 24, 24, 24, 24, 24, 50 | 25, 25, 25, 25, 25, 25, 25, 25, 51 | 26, 26, 26, 26, 26, 26, 26, 26, 52 | 27, 27, 27, 27, 27, 27, 27, 27, 53 | 28, 28, 28, 28, 28, 28, 28, 28, 54 | 29, 29, 29, 29, 29, 29, 29, 29, 55 | 30, 30, 30, 30, 30, 30, 30, 30, 56 | 31, 31, 31, 31, 31, 31, 31, 31, 57 | 32, 32, 32, 32, 32, 32, 32, 32, 58 | }; 59 | 60 | #ifdef __GNUC__ 61 | #ifndef __cplusplus 62 | __attribute__((visibility("hidden"))) 63 | #endif 64 | #endif 65 | void LumaInterpolationCopy16bit_SSE2( 66 | EB_U16 *refPic, 67 | EB_U32 srcStride, 68 | EB_U16 *dst, 69 | EB_U32 dstStride, 70 | EB_U32 puWidth, 71 | EB_U32 puHeight, 72 | EB_S16 *firstPassIFDst) 73 | { 74 | (void)firstPassIFDst; 75 | PictureCopyKernel_SSE2((EB_BYTE)refPic, srcStride*sizeof(EB_U16), (EB_BYTE)dst, dstStride*sizeof(EB_U16), puWidth*sizeof(EB_U16), puHeight); 76 | } 77 | 78 | #ifdef __GNUC__ 79 | #ifndef __cplusplus 80 | __attribute__((visibility("hidden"))) 81 | #endif 82 | #endif 83 | void ChromaInterpolationCopy16bit_SSE2( 84 | EB_U16* refPic, 85 | EB_U32 srcStride, 86 | EB_U16* dst, 87 | EB_U32 dstStride, 88 | EB_U32 puWidth, 89 | EB_U32 puHeight, 90 | EB_S16 *firstPassIFDst, 91 | EB_U32 fracPosx, 92 | EB_U32 fracPosy) 93 | { 94 | (void)firstPassIFDst; 95 | (void)fracPosx; 96 | (void)fracPosy; 97 | PictureCopyKernel_SSE2((EB_BYTE)refPic, srcStride*sizeof(EB_U16), (EB_BYTE)dst, dstStride*sizeof(EB_U16), puWidth*sizeof(EB_U16), puHeight); 98 | } 99 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE2/EbMeSadCalculation_SSE2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | 15 | extern void InitializeBuffer_32bits_SSE2_INTRIN( 16 | EB_U32* Pointer, 17 | EB_U32 Count128, 18 | EB_U32 Count32, 19 | EB_U32 Value); 20 | 21 | void SadCalculation_8x8_16x16_SSE2_INTRIN( 22 | EB_U8 *src, 23 | EB_U32 srcStride, 24 | EB_U8 *ref, 25 | EB_U32 refStride, 26 | EB_U32 *pBestSad8x8, 27 | EB_U32 *pBestSad16x16, 28 | EB_U32 *pBestMV8x8, 29 | EB_U32 *pBestMV16x16, 30 | EB_U32 mv, 31 | EB_U32 *pSad16x16); 32 | 33 | 34 | void SadCalculation_32x32_64x64_SSE2_INTRIN( 35 | EB_U32 *pSad16x16, 36 | EB_U32 *pBestSad32x32, 37 | EB_U32 *pBestSad64x64, 38 | EB_U32 *pBestMV32x32, 39 | EB_U32 *pBestMV64x64, 40 | EB_U32 mv); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | #endif // EbMeSadCalculation_asm_h 46 | 47 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE2/EbPackUnPack_SSE2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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_UnPack8BitData_SSE2_INTRIN( 16 | EB_U16 *in16BitBuffer, 17 | EB_U32 inStride, 18 | EB_U8 *out8BitBuffer, 19 | EB_U32 out8Stride, 20 | EB_U32 width, 21 | EB_U32 height); 22 | 23 | void EB_ENC_UnPack8BitDataSafeSub_SSE2_INTRIN( 24 | EB_U16 *in16BitBuffer, 25 | EB_U32 inStride, 26 | EB_U8 *out8BitBuffer, 27 | EB_U32 out8Stride, 28 | EB_U32 width, 29 | EB_U32 height 30 | ); 31 | 32 | void UnpackAvg_SSE2_INTRIN( 33 | EB_U16 *ref16L0, 34 | EB_U32 refL0Stride, 35 | EB_U16 *ref16L1, 36 | EB_U32 refL1Stride, 37 | EB_U8 *dstPtr, 38 | EB_U32 dstStride, 39 | EB_U32 width, 40 | EB_U32 height); 41 | 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | #endif // EbPackUnPack_asm_h 47 | 48 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE2/EbSampleAdaptiveOffset_SSE2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbSampleAdaptiveOffset_SSE2_h 7 | #define EbSampleAdaptiveOffset_SSE2_h 8 | 9 | #include "EbDefinitions.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | EB_ERRORTYPE GatherSaoStatisticsLcu_OnlyEo_90_45_135_16bit_SSE2_INTRIN( 16 | EB_U16 *inputSamplePtr, // input parameter, source Picture Ptr 17 | EB_U32 inputStride, // input parameter, source stride 18 | EB_U16 *reconSamplePtr, // input parameter, deblocked Picture Ptr 19 | EB_U32 reconStride, // input parameter, deblocked stride 20 | EB_U32 lcuWidth, // input parameter, LCU width 21 | EB_U32 lcuHeight, // input parameter, LCU height 22 | EB_S32 eoDiff[SAO_EO_TYPES][SAO_EO_CATEGORIES + 1], // output parameter, used to store Edge Offset diff, eoDiff[SAO_EO_TYPES] [SAO_EO_CATEGORIES] 23 | EB_U16 eoCount[SAO_EO_TYPES][SAO_EO_CATEGORIES + 1]); // output parameter, used to store Edge Offset count, eoCount[SAO_EO_TYPES] [SAO_EO_CATEGORIES] 24 | 25 | extern EB_ERRORTYPE SAOApplyBO16bit_SSE2_INTRIN( 26 | EB_U16 *reconSamplePtr, 27 | EB_U32 reconStride, 28 | EB_U32 saoBandPosition, 29 | EB_S8 *saoOffsetPtr, 30 | EB_U32 lcuHeight, 31 | EB_U32 lcuWidth); 32 | 33 | extern EB_ERRORTYPE SAOApplyEO_45_16bit_SSE2_INTRIN( 34 | EB_U16 *reconSamplePtr, 35 | EB_U32 reconStride, 36 | EB_U16 *temporalBufferLeft, 37 | EB_U16 *temporalBufferUpper, 38 | EB_S8 *saoOffsetPtr, 39 | EB_U32 lcuHeight, 40 | EB_U32 lcuWidth); 41 | 42 | extern EB_ERRORTYPE SAOApplyEO_135_16bit_SSE2_INTRIN( 43 | EB_U16 *reconSamplePtr, 44 | EB_U32 reconStride, 45 | EB_U16 *temporalBufferLeft, 46 | EB_U16 *temporalBufferUpper, 47 | EB_S8 *saoOffsetPtr, 48 | EB_U32 lcuHeight, 49 | EB_U32 lcuWidth); 50 | 51 | extern EB_ERRORTYPE SAOApplyEO_90_16bit_SSE2_INTRIN( 52 | EB_U16 *reconSamplePtr, 53 | EB_U32 reconStride, 54 | EB_U16 *temporalBufferUpper, 55 | EB_S8 *saoOffsetPtr, 56 | EB_U32 lcuHeight, 57 | EB_U32 lcuWidth); 58 | 59 | extern EB_ERRORTYPE SAOApplyEO_0_16bit_SSE2_INTRIN( 60 | EB_U16 *reconSamplePtr, 61 | EB_U32 reconStride, 62 | EB_U16 *temporalBufferLeft, 63 | EB_S8 *saoOffsetPtr, 64 | EB_U32 lcuHeight, 65 | EB_U32 lcuWidth); 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | #endif -------------------------------------------------------------------------------- /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) 2018 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 EbHevcRunEmms() is called according to the above cases, 22 | ; then the "emms" instruction in all other assembly functions can be removed. 23 | 24 | cglobal EbHevcRunEmms 25 | emms 26 | ret 27 | 28 | ; ---------------------------------------------------------------------------------------- 29 | 30 | cglobal EbHevcSaveRegister 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 EbHevcRestoreRegister 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) 2018 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 | 17 | set(flags_to_test 18 | -msse4.1 19 | -static-intel) 20 | 21 | foreach(cflag ${flags_to_test}) 22 | string(REGEX REPLACE "[^A-Za-z0-9]" "_" cflag_var "${cflag}") 23 | set(test_c_flag "C_FLAG${cflag_var}") 24 | if(COMPILE_AS_CPP) 25 | set(test_cxx_flag "CXX_FLAG${cflag_var}") 26 | endif() 27 | check_c_compiler_flag(${cflag} "${test_c_flag}") 28 | if(COMPILE_AS_CPP) 29 | check_cxx_compiler_flag(${cflag} "${test_cxx_flag}") 30 | endif() 31 | if(${test_c_flag}) 32 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${cflag}") 33 | endif() 34 | if(COMPILE_AS_CPP) 35 | if(${test_cxx_flag}) 36 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cflag}") 37 | endif() 38 | endif() 39 | endforeach() 40 | 41 | if(CMAKE_C_COMPILER_ID STREQUAL "Intel") 42 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") 43 | if(COMPILE_AS_CPP) 44 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") 45 | endif() 46 | endif() 47 | 48 | set(ASM_SSE4_1_SOURCE 49 | EbIntraPrediction16bit_Intrinsic_SSE4_1.c 50 | EbPictureOperators_Intrinsic_SSE4_1.c 51 | EbTransforms_Intrinsic_SSE4_1.c) 52 | 53 | if(COMPILE_AS_CPP) 54 | set_source_files_properties(${ASM_SSE4_1_SOURCE} 55 | PROPERTIES LANGUAGE CXX) 56 | endif() 57 | 58 | # Utility Source Files 59 | add_library(HEVC_ASM_SSE4_1 OBJECT 60 | ${ASM_SSE4_1_SOURCE} 61 | EbIntraPrediction_SSE4_1.h 62 | EbPictureOperators_SSE4_1.h 63 | EbTransforms_SSE4_1.h) 64 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE4_1/EbIntraPrediction_SSE4_1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbIntraPrediction_SSE4_1_h 7 | #define EbIntraPrediction_SSE4_1_h 8 | 9 | #include "EbDefinitions.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | extern void IntraModeDCLuma16bit_SSE4_1_INTRIN( 16 | const EB_U32 size, //input parameter, denotes the size of the current PU 17 | EB_U16 *refSamples, //input parameter, pointer to the reference samples 18 | EB_U16 *predictionPtr, //output parameter, pointer to the prediction 19 | const EB_U32 predictionBufferStride, //input parameter, denotes the stride for the prediction ptr 20 | const EB_BOOL skip); //skip half rows 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | #endif // EbIntraPrediction_SSE4_1_h -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE4_1/EbPictureOperators_SSE4_1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | EB_U64 Compute8x8Satd_SSE4( 16 | EB_S16 *diff); // input parameter, diff samples Ptr 17 | 18 | EB_U64 Compute8x8Satd_U8_SSE4( 19 | EB_U8 *src, // input parameter, diff samples Ptr 20 | EB_U64 *dcValue, 21 | EB_U32 srcStride); 22 | 23 | EB_U64 SpatialFullDistortionKernel4x4_SSSE3_INTRIN( 24 | EB_U8 *input, 25 | EB_U32 inputStride, 26 | EB_U8 *recon, 27 | EB_U32 reconStride, 28 | EB_U32 areaWidth, 29 | EB_U32 areaHeight); 30 | 31 | EB_U64 SpatialFullDistortionKernel8x8_SSSE3_INTRIN( 32 | EB_U8 *input, 33 | EB_U32 inputStride, 34 | EB_U8 *recon, 35 | EB_U32 reconStride, 36 | EB_U32 areaWidth, 37 | EB_U32 areaHeight); 38 | 39 | EB_U64 SpatialFullDistortionKernel16MxN_SSSE3_INTRIN( 40 | EB_U8 *input, 41 | EB_U32 inputStride, 42 | EB_U8 *recon, 43 | EB_U32 reconStride, 44 | EB_U32 areaWidth, 45 | EB_U32 areaHeight); 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | #endif // EbPictureOperators_SSE4_1_h 51 | 52 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSE4_1/EbTransforms_SSE4_1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbTransforms_SSE4_1_h 7 | #define EbTransforms_SSE4_1_h 8 | 9 | #include "EbDefinitions.h" 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | extern EB_ALIGN(16) const EB_S16 TransformAsmConst_SSE4_1[1632]; 14 | 15 | extern void Transform8x8_SSE4_1_INTRIN( 16 | EB_S16 *residual, 17 | const EB_U32 srcStride, 18 | EB_S16 *transformCoefficients, 19 | const EB_U32 dstStride, 20 | EB_S16 *transformInnerArrayPtr, 21 | EB_U32 bitIncrement); 22 | extern void PfreqTransform8x8_SSE4_1_INTRIN( 23 | EB_S16 *residual, 24 | const EB_U32 srcStride, 25 | EB_S16 *transformCoefficients, 26 | const EB_U32 dstStride, 27 | EB_S16 *transformInnerArrayPtr, 28 | EB_U32 bitIncrement); 29 | extern void PfreqN4Transform8x8_SSE4_1_INTRIN( 30 | EB_S16 *residual, 31 | const EB_U32 srcStride, 32 | EB_S16 *transformCoefficients, 33 | const EB_U32 dstStride, 34 | EB_S16 *transformInnerArrayPtr, 35 | EB_U32 bitIncrement); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | #endif // EbTransforms_SSE4_1_h -------------------------------------------------------------------------------- /Source/Lib/ASM_SSSE3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright(c) 2018 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/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 | 17 | set(flags_to_test 18 | -mssse3 19 | -msse4.1 20 | -static-intel) 21 | 22 | foreach(cflag ${flags_to_test}) 23 | string(REGEX REPLACE "[^A-Za-z0-9]" "_" cflag_var "${cflag}") 24 | set(test_c_flag "C_FLAG${cflag_var}") 25 | if(COMPILE_AS_CPP) 26 | set(test_cxx_flag "CXX_FLAG${cflag_var}") 27 | endif() 28 | check_c_compiler_flag(${cflag} "${test_c_flag}") 29 | if(COMPILE_AS_CPP) 30 | check_cxx_compiler_flag(${cflag} "${test_cxx_flag}") 31 | endif() 32 | if(${test_c_flag}) 33 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${cflag}") 34 | endif() 35 | if(COMPILE_AS_CPP) 36 | if(${test_cxx_flag}) 37 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cflag}") 38 | endif() 39 | endif() 40 | endforeach() 41 | 42 | if(CMAKE_C_COMPILER_ID STREQUAL "Intel") 43 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") 44 | if(COMPILE_AS_CPP) 45 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") 46 | endif() 47 | endif() 48 | 49 | set(ASM_SSSE3_SOURCE 50 | EbAvcStyleMcp_Intrinsic_SSSE3.c 51 | EbDeblockingFilter16bit_Intrinsic_SSSE3.c 52 | EbDeblockingFilter_Intrinsic_SSSE3.c 53 | EbIntraPrediction16bit_Intrinsic_SSSE3.c 54 | EbMcp_Intrinsic_SSSE3.c 55 | EbSaoApplication_Intrinsic_SSSE3.c 56 | EbTransforms_Intrinsic_SSSE3.c) 57 | 58 | if(COMPILE_AS_CPP) 59 | set_source_files_properties(${ASM_SSSE3_SOURCE} 60 | PROPERTIES LANGUAGE CXX) 61 | endif() 62 | 63 | # Utility Source Files 64 | add_library(HEVC_ASM_SSSE3 OBJECT 65 | ${ASM_SSSE3_SOURCE} 66 | EbAvcStyleMcp_SSSE3.h 67 | EbDeblockingFilter_SSSE3.h 68 | EbIntraPrediction_SSSE3.h 69 | EbMcp_SSSE3.h 70 | EbSaoApplication_SSSE3.h 71 | EbTransforms_SSSE3.h) 72 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSSE3/EbAvcStyleMcp_SSSE3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EBAVCSTYLEMCP_SSSE3_H 7 | #define EBAVCSTYLEMCP_SSSE3_H 8 | 9 | #include "EbDefinitions.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | void AvcStyleLumaInterpolationFilterHorizontal_SSSE3_INTRIN(EB_BYTE refPic, EB_U32 srcStride, EB_BYTE dst, EB_U32 dstStride, EB_U32 puWidth, EB_U32 puHeight, EB_BYTE tempBuf, EB_U32 fracPos); 16 | void AvcStyleLumaInterpolationFilterVertical_SSSE3_INTRIN(EB_BYTE refPic, EB_U32 srcStride, EB_BYTE dst, EB_U32 dstStride, EB_U32 puWidth, EB_U32 puHeight, EB_BYTE tempBuf, EB_U32 fracPos); 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | #endif //EBAVCSTYLEMCP_H 21 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSSE3/EbDeblockingFilter_SSSE3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbDeblockingAsm_h 7 | #define EbDeblockingAsm_h 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | #include "EbDefinitions.h" 13 | 14 | extern void Luma4SampleEdgeDLFCore_SSSE3( 15 | EB_BYTE edgeStartSample, 16 | EB_U32 reconLumaPicStride, 17 | EB_BOOL isVerticalEdge, 18 | EB_S32 tc, 19 | EB_S32 beta); 20 | 21 | void Chroma2SampleEdgeDLFCore_SSSE3( 22 | EB_BYTE edgeStartSampleCb, 23 | EB_BYTE edgeStartSampleCr, 24 | EB_U32 reconChromaPicStride, 25 | EB_BOOL isVerticalEdge, 26 | EB_U8 cbTc, 27 | EB_U8 crTc); 28 | 29 | void Luma4SampleEdgeDLFCore16bit_SSSE3_INTRIN( 30 | EB_U16 *edgeStartFilteredSamplePtr, 31 | EB_U32 reconLumaPicStride, 32 | EB_BOOL isVerticalEdge, 33 | EB_S32 tc, 34 | EB_S32 beta); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | #endif // EbDeblockingAsm_h 40 | -------------------------------------------------------------------------------- /Source/Lib/ASM_SSSE3/EbIntraPrediction_SSSE3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbIntraPrediction_SSSE3_h 7 | #define EbIntraPrediction_SSSE3_h 8 | 9 | #include "EbDefinitions.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | extern void IntraModeDCChroma16bit_SSSE3_INTRIN( 16 | const EB_U32 size, //input parameter, denotes the size of the current PU 17 | EB_U16 *refSamples, //input parameter, pointer to the reference samples 18 | EB_U16 *predictionPtr, //output parameter, pointer to the prediction 19 | const EB_U32 predictionBufferStride, //input parameter, denotes the stride for the prediction ptr 20 | const EB_BOOL skip); 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | #endif // EbIntraPrediction_SSSE3_h -------------------------------------------------------------------------------- /Source/Lib/ASM_SSSE3/EbSaoApplication_SSSE3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbSampleAdaptiveOffset_SSSE3_h 7 | #define EbSampleAdaptiveOffset_SSSE3_h 8 | 9 | #include "EbDefinitions.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | EB_ERRORTYPE SAOApplyBO_BT_SSSE3( 16 | EB_U8 *reconSamplePtr, 17 | EB_U32 reconStride, 18 | EB_U32 saoBandPosition, 19 | EB_S8 *saoOffsetPtr, 20 | EB_U32 lcuHeight, 21 | EB_U32 lcuWidth); 22 | 23 | EB_ERRORTYPE SAOApplyEO_0_BT_SSSE3( 24 | EB_U8 *reconSamplePtr, 25 | EB_U32 reconStride, 26 | EB_U8 *temporalBufferLeft, 27 | EB_S8 *saoOffsetPtr, 28 | EB_U32 lcuHeight, 29 | EB_U32 lcuWidth); 30 | 31 | EB_ERRORTYPE SAOApplyEO_90_BT_SSSE3( 32 | EB_U8 *reconSamplePtr, 33 | EB_U32 reconStride, 34 | EB_U8 *temporalBufferUpper, 35 | EB_S8 *saoOffsetPtr, 36 | EB_U32 lcuHeight, 37 | EB_U32 lcuWidth); 38 | 39 | EB_ERRORTYPE SAOApplyEO_135_BT_SSSE3( 40 | EB_U8 *reconSamplePtr, 41 | EB_U32 reconStride, 42 | EB_U8 *temporalBufferLeft, 43 | EB_U8 *temporalBufferUpper, 44 | EB_S8 *saoOffsetPtr, 45 | EB_U32 lcuHeight, 46 | EB_U32 lcuWidth); 47 | 48 | EB_ERRORTYPE SAOApplyEO_45_BT_SSSE3( 49 | EB_U8 *reconSamplePtr, 50 | EB_U32 reconStride, 51 | EB_U8 *temporalBufferLeft, 52 | EB_U8 *temporalBufferUpper, 53 | EB_S8 *saoOffsetPtr, 54 | EB_U32 lcuHeight, 55 | EB_U32 lcuWidth); 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | #endif -------------------------------------------------------------------------------- /Source/Lib/ASM_SSSE3/EbTransforms_SSSE3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbTransforms_SSSE3_h 7 | #define EbTransforms_SSSE3_h 8 | 9 | #include "EbDefinitions.h" 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | void QuantizeInvQuantize4x4_SSE3( 15 | EB_S16 *coeff, 16 | const EB_U32 coeffStride, 17 | EB_S16 *quantCoeff, 18 | EB_S16 *reconCoeff, 19 | const EB_U32 qFunc, 20 | const EB_U32 q_offset, 21 | const EB_S32 shiftedQBits, 22 | const EB_S32 shiftedFFunc, 23 | const EB_S32 iq_offset, 24 | const EB_S32 shiftNum, 25 | const EB_U32 areaSize, 26 | EB_U32 *nonzerocoeff); 27 | 28 | 29 | void PFinvTransform32x32_SSSE3(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_stride, EB_S16 *intermediate, EB_U32 addshift); 30 | void PFinvTransform16x16_SSSE3(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_stride, EB_S16 *intermediate, EB_U32 addshift); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | #endif // EbTransforms_SSSE3_h 36 | 37 | -------------------------------------------------------------------------------- /Source/Lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright(c) 2018 Intel Corporation 3 | # SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | # 5 | 6 | # Libraries Directory CMakeLists.txt 7 | 8 | add_subdirectory(C_DEFAULT) 9 | add_subdirectory(ASM_SSE2) 10 | add_subdirectory(ASM_SSSE3) 11 | add_subdirectory(ASM_SSE4_1) 12 | add_subdirectory(ASM_AVX2) 13 | add_subdirectory(Codec) 14 | -------------------------------------------------------------------------------- /Source/Lib/C_DEFAULT/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright(c) 2018 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 | 13 | # Utility Source Files 14 | set(C_DEFAULT_SOURCE 15 | EbAvcStyleMcp_C.c 16 | EbComputeMean_C.c 17 | EbComputeSAD_C.c 18 | EbDeblockingFilter_C.c 19 | EbIntraPrediction_C.c 20 | EbMcp_C.c 21 | EbMeSadCalculation_C.c 22 | EbPackUnPack_C.c 23 | EbPictureOperators_C.c 24 | EbSampleAdaptiveOffset_C.c 25 | EbTransforms_C.c) 26 | 27 | if(COMPILE_AS_CPP) 28 | set_source_files_properties(${C_DEFAULT_SOURCE} 29 | PROPERTIES LANGUAGE CXX) 30 | endif() 31 | 32 | add_library(HEVC_C_DEFAULT OBJECT 33 | ${C_DEFAULT_SOURCE} 34 | EbAvcStyleMcp_C.h 35 | EbComputeMean_C.h 36 | EbComputeSAD_C.h 37 | EbDeblockingFilter_C.h 38 | EbIntraPrediction_C.h 39 | EbMcp_C.h 40 | EbMeSadCalculation_C.h 41 | EbPackUnPack_C.h 42 | EbPictureOperators_C.h 43 | EbSampleAdaptiveOffset_C.h 44 | EbTransforms_C.h) 45 | -------------------------------------------------------------------------------- /Source/Lib/C_DEFAULT/EbAvcStyleMcp_C.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | void AvcStyleCopyNew(EB_BYTE refPic, EB_U32 srcStride, EB_BYTE dst, EB_U32 dstStride, EB_U32 puWidth, EB_U32 puHeight, EB_BYTE tempBuf, EB_U32 fracPos); 16 | void AvcStyleLumaInterpolationFilterHorizontal(EB_BYTE refPic, EB_U32 srcStride, EB_BYTE dst, EB_U32 dstStride, EB_U32 puWidth, EB_U32 puHeight, EB_BYTE tempBuf, EB_U32 fracPos); 17 | void AvcStyleLumaInterpolationFilterVertical(EB_BYTE refPic, EB_U32 srcStride, EB_BYTE dst, EB_U32 dstStride, EB_U32 puWidth, EB_U32 puHeight, EB_BYTE tempBuf, EB_U32 fracPos); 18 | 19 | void WpAvcStyleCopy(EB_BYTE refPic, EB_U32 srcStride, EB_BYTE dst, EB_U32 dstStride, EB_U32 puWidth, EB_U32 puHeight, EB_BYTE tempBuf, EB_U32 fracPos, EB_S16 wpWeight, EB_S16 wpOffset, EB_U8 wpDenominator); 20 | void WpAvcStyleLumaInterpolationFilterHorizontal(EB_BYTE refPic, EB_U32 srcStride, EB_BYTE dst, EB_U32 dstStride, EB_U32 puWidth, EB_U32 puHeight, EB_BYTE tempBuf, EB_U32 fracPos, EB_S16 wpWeight, EB_S16 wpOffset, EB_U8 wpDenominator); 21 | void WpAvcStyleLumaInterpolationFilterVertical(EB_BYTE refPic, EB_U32 srcStride, EB_BYTE dst, EB_U32 dstStride, EB_U32 puWidth, EB_U32 puHeight, EB_BYTE tempBuf, EB_U32 fracPos, EB_S16 wpWeight, EB_S16 wpOffset, EB_U8 wpDenominator); 22 | void WpAvcStyleLumaInterpolationFilterPose(EB_BYTE refPic, EB_U32 srcStride, EB_BYTE dst, EB_U32 dstStride, EB_U32 puWidth, EB_U32 puHeight, EB_BYTE tempBuf, EB_U32 fracPos, EB_S16 wpWeight, EB_S16 wpOffset, EB_U8 wpDenominator); 23 | void WpAvcStyleLumaInterpolationFilterPosf(EB_BYTE refPic, EB_U32 srcStride, EB_BYTE dst, EB_U32 dstStride, EB_U32 puWidth, EB_U32 puHeight, EB_BYTE tempBuf, EB_U32 fracPos, EB_S16 wpWeight, EB_S16 wpOffset, EB_U8 wpDenominator); 24 | void WpAvcStyleLumaInterpolationFilterPosg(EB_BYTE refPic, EB_U32 srcStride, EB_BYTE dst, EB_U32 dstStride, EB_U32 puWidth, EB_U32 puHeight, EB_BYTE tempBuf, EB_U32 fracPos, EB_S16 wpWeight, EB_S16 wpOffset, EB_U8 wpDenominator); 25 | void WpAvcStyleLumaInterpolationFilterPosi(EB_BYTE refPic, EB_U32 srcStride, EB_BYTE dst, EB_U32 dstStride, EB_U32 puWidth, EB_U32 puHeight, EB_BYTE tempBuf, EB_U32 fracPos, EB_S16 wpWeight, EB_S16 wpOffset, EB_U8 wpDenominator); 26 | void WpAvcStyleLumaInterpolationFilterPosj(EB_BYTE refPic, EB_U32 srcStride, EB_BYTE dst, EB_U32 dstStride, EB_U32 puWidth, EB_U32 puHeight, EB_BYTE tempBuf, EB_U32 fracPos, EB_S16 wpWeight, EB_S16 wpOffset, EB_U8 wpDenominator); 27 | void WpAvcStyleLumaInterpolationFilterPosk(EB_BYTE refPic, EB_U32 srcStride, EB_BYTE dst, EB_U32 dstStride, EB_U32 puWidth, EB_U32 puHeight, EB_BYTE tempBuf, EB_U32 fracPos, EB_S16 wpWeight, EB_S16 wpOffset, EB_U8 wpDenominator); 28 | void WpAvcStyleLumaInterpolationFilterPosp(EB_BYTE refPic, EB_U32 srcStride, EB_BYTE dst, EB_U32 dstStride, EB_U32 puWidth, EB_U32 puHeight, EB_BYTE tempBuf, EB_U32 fracPos, EB_S16 wpWeight, EB_S16 wpOffset, EB_U8 wpDenominator); 29 | void WpAvcStyleLumaInterpolationFilterPosq(EB_BYTE refPic, EB_U32 srcStride, EB_BYTE dst, EB_U32 dstStride, EB_U32 puWidth, EB_U32 puHeight, EB_BYTE tempBuf, EB_U32 fracPos, EB_S16 wpWeight, EB_S16 wpOffset, EB_U8 wpDenominator); 30 | void WpAvcStyleLumaInterpolationFilterPosr(EB_BYTE refPic, EB_U32 srcStride, EB_BYTE dst, EB_U32 dstStride, EB_U32 puWidth, EB_U32 puHeight, EB_BYTE tempBuf, EB_U32 fracPos, EB_S16 wpWeight, EB_S16 wpOffset, EB_U8 wpDenominator); 31 | 32 | 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | #endif //EBAVCSTYLEMCP_C_H -------------------------------------------------------------------------------- /Source/Lib/C_DEFAULT/EbComputeMean_C.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | EB_U64 ComputeMean( 15 | EB_U8 * inputSamples, // input parameter, input samples Ptr 16 | EB_U32 inputStride, // input parameter, input stride 17 | EB_U32 inputAreaWidth, // input parameter, input area width 18 | EB_U32 inputAreaHeight); // input parameter, input area height 19 | 20 | EB_U64 ComputeMeanOfSquaredValues( 21 | EB_U8 * inputSamples, // input parameter, input samples Ptr 22 | EB_U32 inputStride, // input parameter, input stride 23 | EB_U32 inputAreaWidth, // input parameter, input area width 24 | EB_U32 inputAreaHeight); // input parameter, input area height 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | 30 | #endif -------------------------------------------------------------------------------- /Source/Lib/C_DEFAULT/EbComputeSAD_C.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbComputeSAD_C_h 7 | #define EbComputeSAD_C_h 8 | 9 | #include "EbDefinitions.h" 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | EB_U32 FastLoop_NxMSadKernel( 15 | EB_U8 *src, // input parameter, source samples Ptr 16 | EB_U32 srcStride, // input parameter, source stride 17 | EB_U8 *ref, // input parameter, reference samples Ptr 18 | EB_U32 refStride, // input parameter, reference stride 19 | EB_U32 height, // input parameter, block height (M) 20 | EB_U32 width); // input parameter, block width (N) 21 | 22 | EB_U32 CombinedAveragingSAD( 23 | EB_U8 *src, 24 | EB_U32 srcStride, 25 | EB_U8 *ref1, 26 | EB_U32 ref1Stride, 27 | EB_U8 *ref2, 28 | EB_U32 ref2Stride, 29 | EB_U32 height, 30 | EB_U32 width); 31 | 32 | EB_U32 Compute8x4SAD_Kernel( 33 | EB_U8 *src, // input parameter, source samples Ptr 34 | EB_U32 srcStride, // input parameter, source stride 35 | EB_U8 *ref, // input parameter, reference samples Ptr 36 | EB_U32 refStride); // input parameter, reference stride 37 | 38 | void SadLoopKernel( 39 | EB_U8 *src, // input parameter, source samples Ptr 40 | EB_U32 srcStride, // input parameter, source stride 41 | EB_U8 *ref, // input parameter, reference samples Ptr 42 | EB_U32 refStride, // input parameter, reference stride 43 | EB_U32 height, // input parameter, block height (M) 44 | EB_U32 width, // input parameter, block width (N) 45 | EB_U64 *bestSad, 46 | EB_S16 *xSearchCenter, 47 | EB_S16 *ySearchCenter, 48 | EB_U32 srcStrideRaw, // input parameter, source stride (no line skipping) 49 | EB_S16 searchAreaWidth, 50 | EB_S16 searchAreaHeight); 51 | 52 | 53 | void SadLoopKernelSparse( 54 | EB_U8 *src, // input parameter, source samples Ptr 55 | EB_U32 srcStride, // input parameter, source stride 56 | EB_U8 *ref, // input parameter, reference samples Ptr 57 | EB_U32 refStride, // input parameter, reference stride 58 | EB_U32 height, // input parameter, block height (M) 59 | EB_U32 width, // input parameter, block width (N) 60 | EB_U64 *bestSad, 61 | EB_S16 *xSearchCenter, 62 | EB_S16 *ySearchCenter, 63 | EB_U32 srcStrideRaw, // input parameter, source stride (no line skipping) 64 | EB_S16 searchAreaWidth, 65 | EB_S16 searchAreaHeight); 66 | 67 | void GetEightHorizontalSearchPointResults_8x8_16x16_PU( 68 | EB_U8 *src, 69 | EB_U32 srcStride, 70 | EB_U8 *ref, 71 | EB_U32 refStride, 72 | EB_U32 *pBestSad8x8, 73 | EB_U32 *pBestMV8x8, 74 | EB_U32 *pBestSad16x16, 75 | EB_U32 *pBestMV16x16, 76 | EB_U32 mv, 77 | EB_U16 *pSad16x16); 78 | 79 | void GetEightHorizontalSearchPointResults_32x32_64x64( 80 | EB_U16 *pSad16x16, 81 | EB_U32 *pBestSad32x32, 82 | EB_U32 *pBestSad64x64, 83 | EB_U32 *pBestMV32x32, 84 | EB_U32 *pBestMV64x64, 85 | EB_U32 mv); 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | #endif // EbComputeSAD_C_h -------------------------------------------------------------------------------- /Source/Lib/C_DEFAULT/EbDeblockingFilter_C.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbDeblockingFilter_C_h 7 | #define EbDeblockingFilter_C_h 8 | 9 | #include "EbDefinitions.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #define MAX_CHROMA_SAMPLE_VALUE_10BIT 1023 16 | #define MAX_CHROMA_SAMPLE_VALUE 255 17 | 18 | void Luma4SampleEdgeDLFCore( 19 | EB_BYTE edgeStartSample, 20 | EB_U32 reconLumaPicStride, 21 | EB_BOOL isVerticalEdge, 22 | EB_S32 tc, 23 | EB_S32 beta); 24 | 25 | void Luma4SampleEdgeDLFCore16bit( 26 | EB_U16 *edgeStartFilteredSamplePtr, 27 | EB_U32 reconLumaPicStride, 28 | EB_BOOL isVerticalEdge, 29 | EB_S32 tc, 30 | EB_S32 beta); 31 | 32 | void Chroma2SampleEdgeDLFCore( 33 | EB_BYTE edgeStartSampleCb, 34 | EB_BYTE edgeStartSampleCr, 35 | EB_U32 reconChromaPicStride, 36 | EB_BOOL isVerticalEdge, 37 | EB_U8 cbTc, 38 | EB_U8 crTc); 39 | 40 | void Chroma2SampleEdgeDLFCore16bit( 41 | EB_U16 *edgeStartSampleCb, 42 | EB_U16 *edgeStartSampleCr, 43 | EB_U32 reconChromaPicStride, 44 | EB_BOOL isVerticalEdge, 45 | EB_U8 cbTc, 46 | EB_U8 crTc); 47 | 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | #endif -------------------------------------------------------------------------------- /Source/Lib/C_DEFAULT/EbMeSadCalculation_C.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 SadCalculation_8x8_16x16( 15 | EB_U8 *src, 16 | EB_U32 srcStride, 17 | EB_U8 *ref, 18 | EB_U32 refStride, 19 | EB_U32 *pBestSad8x8, 20 | EB_U32 *pBestSad16x16, 21 | EB_U32 *pBestMV8x8, 22 | EB_U32 *pBestMV16x16, 23 | EB_U32 mv, 24 | EB_U32 *pSad16x16); 25 | 26 | extern void SadCalculation_32x32_64x64( 27 | EB_U32 *pSad16x16, 28 | EB_U32 *pBestSad32x32, 29 | EB_U32 *pBestSad64x64, 30 | EB_U32 *pBestMV32x32, 31 | EB_U32 *pBestMV64x64, 32 | EB_U32 mv); 33 | 34 | extern void InitializeBuffer_32bits( 35 | EB_U32* Pointer, 36 | EB_U32 Count128, 37 | EB_U32 Count32, 38 | EB_U32 Value); 39 | 40 | void WeightSearchRegion( 41 | EB_U8 *inputBuffer, 42 | EB_U32 inputStride, 43 | EB_U8 *dstBuffer, 44 | EB_U32 dstStride, 45 | EB_U32 searchAreaWidth, 46 | EB_U32 searchAreaHeight, 47 | EB_S16 wpWeight, 48 | EB_S16 wpOffset, 49 | EB_U32 wpLumaWeightDenominatorShift); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | #endif // EbMeSadCalculation_C_h -------------------------------------------------------------------------------- /Source/Lib/C_DEFAULT/EbPackUnPack_C.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | 16 | 17 | void EB_ENC_msbPack2D( 18 | EB_U8 *in8BitBuffer, 19 | EB_U32 in8Stride, 20 | EB_U8 *innBitBuffer, 21 | EB_U16 *out16BitBuffer, 22 | EB_U32 innStride, 23 | EB_U32 outStride, 24 | EB_U32 width, 25 | EB_U32 height); 26 | 27 | void CompressedPackmsb( 28 | EB_U8 *in8BitBuffer, 29 | EB_U32 in8Stride, 30 | EB_U8 *innBitBuffer, 31 | EB_U16 *out16BitBuffer, 32 | EB_U32 innStride, 33 | EB_U32 outStride, 34 | EB_U32 width, 35 | EB_U32 height); 36 | void CPack_C( 37 | const EB_U8 *innBitBuffer, 38 | EB_U32 innStride, 39 | EB_U8 *inCompnBitBuffer, 40 | EB_U32 outStride, 41 | EB_U8 *localCache, 42 | EB_U32 width, 43 | EB_U32 height); 44 | 45 | 46 | 47 | void EB_ENC_msbUnPack2D( 48 | EB_U16 *in16BitBuffer, 49 | EB_U32 inStride, 50 | EB_U8 *out8BitBuffer, 51 | EB_U8 *outnBitBuffer, 52 | EB_U32 out8Stride, 53 | EB_U32 outnStride, 54 | EB_U32 width, 55 | EB_U32 height); 56 | void UnPack8BitData( 57 | EB_U16 *in16BitBuffer, 58 | EB_U32 inStride, 59 | EB_U8 *out8BitBuffer, 60 | EB_U32 out8Stride, 61 | EB_U32 width, 62 | EB_U32 height); 63 | void UnpackAvg( 64 | EB_U16 *ref16L0, 65 | EB_U32 refL0Stride, 66 | EB_U16 *ref16L1, 67 | EB_U32 refL1Stride, 68 | EB_U8 *dstPtr, 69 | EB_U32 dstStride, 70 | EB_U32 width, 71 | EB_U32 height); 72 | 73 | void UnPack8BitDataSafeSub( 74 | EB_U16 *in16BitBuffer, 75 | EB_U32 inStride, 76 | EB_U8 *out8BitBuffer, 77 | EB_U32 out8Stride, 78 | EB_U32 width, 79 | EB_U32 height 80 | ); 81 | 82 | void UnpackAvgSafeSub( 83 | EB_U16 *ref16L0, 84 | EB_U32 refL0Stride, 85 | EB_U16 *ref16L1, 86 | EB_U32 refL1Stride, 87 | EB_U8 *dstPtr, 88 | EB_U32 dstStride, 89 | EB_U32 width, 90 | EB_U32 height); 91 | 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | #endif // EbPackUnPack_C_h 97 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbAvailability.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbAvailability_h 7 | #define EbAvailability_h 8 | 9 | #include "EbDefinitions.h" 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | extern EB_BOOL isBottomLeftAvailable( 14 | EB_U32 depth, 15 | EB_U32 partIndex); 16 | 17 | extern EB_BOOL isUpperRightAvailable( 18 | EB_U32 depth, 19 | EB_U32 partIndex); 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | #endif // EbAvailability_h -------------------------------------------------------------------------------- /Source/Lib/Codec/EbBitstreamUnit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | #include "EbObject.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | // Bistream Slice Buffer Size 16 | #define EB_BITSTREAM_SLICE_BUFFER_SIZE 0x300000 17 | // Table A.6 General tier and level limits 18 | #define SLICE_HEADER_COUNT 600 19 | 20 | /********************************** 21 | * Bitstream Unit Types 22 | **********************************/ 23 | typedef struct OutputBitstreamUnit_s { 24 | EbDctor dctor; 25 | EB_U32 size; // allocated buffer size 26 | EB_U32 byteHolder; // holds bytes and partial bytes 27 | EB_S32 validBitsCount; // count of valid bits in byteHolder 28 | EB_U32 writtenBitsCount; // count of written bits 29 | EB_U32 sliceNum; // Number of slices 30 | EB_U32 sliceLocation[SLICE_HEADER_COUNT]; // Location of each slice in byte 31 | EB_U32 *bufferBegin; // the byte buffer 32 | EB_U32 *buffer; // the byte buffer 33 | 34 | } OutputBitstreamUnit_t; 35 | 36 | /********************************** 37 | * Extern Function Declarations 38 | **********************************/ 39 | extern EB_ERRORTYPE OutputBitstreamUnitCtor( 40 | OutputBitstreamUnit_t *bitstreamPtr, 41 | EB_U32 bufferSize ); 42 | 43 | 44 | extern EB_ERRORTYPE OutputBitstreamReset(OutputBitstreamUnit_t *bitstreamPtr); 45 | 46 | extern EB_ERRORTYPE OutputBitstreamFlushBuffer(OutputBitstreamUnit_t *bitstreamPtr); 47 | 48 | 49 | extern EB_ERRORTYPE OutputBitstreamWrite ( 50 | OutputBitstreamUnit_t *bitstreamPtr, 51 | EB_U32 bits, 52 | EB_U32 numberOfBits ); 53 | 54 | extern EB_ERRORTYPE OutputBitstreamWriteByte(OutputBitstreamUnit_t *bitstreamPtr, EB_U32 bits); 55 | 56 | extern EB_ERRORTYPE OutputBitstreamWriteAlignZero(OutputBitstreamUnit_t *bitstreamPtr); 57 | 58 | extern EB_ERRORTYPE OutputBitstreamRBSPToPayload( 59 | OutputBitstreamUnit_t *bitstreamPtr, 60 | EB_BYTE outputBuffer, 61 | EB_U32 *outputBufferIndex, 62 | EB_U32 *outputBufferSize, 63 | EB_U32 startLocation, 64 | NalUnitType nalType); 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | #endif // EbBitstreamUnit_h 70 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbComputeMean.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | 19 | typedef EB_U64(*EB_COMPUTE_MEAN_FUNC)( 20 | EB_U8 *inputSamples, 21 | EB_U32 inputStride, 22 | EB_U32 inputAreaWidth, 23 | EB_U32 inputAreaHeight); 24 | 25 | static const EB_COMPUTE_MEAN_FUNC ComputeMeanFunc[2][EB_ASM_TYPE_TOTAL] = { 26 | { 27 | // C_DEFAULT 28 | ComputeMean, 29 | // AVX2 30 | ComputeMean8x8_AVX2_INTRIN 31 | }, 32 | { 33 | // C_DEFAULT 34 | ComputeMeanOfSquaredValues, 35 | // AVX2 36 | ComputeMeanOfSquaredValues8x8_SSE2_INTRIN 37 | } 38 | }; 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | #endif -------------------------------------------------------------------------------- /Source/Lib/Codec/EbEncDecResults.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | #include "EbDefinitions.h" 8 | #include "EbEncDecResults.h" 9 | 10 | EB_ERRORTYPE EncDecResultsCtor( 11 | EncDecResults_t *contextPtr, 12 | EB_PTR objectInitDataPtr) 13 | { 14 | (void)contextPtr; 15 | (void)objectInitDataPtr; 16 | 17 | return EB_ErrorNone; 18 | } 19 | 20 | EB_ERRORTYPE EncDecResultsCreator( 21 | EB_PTR *objectDblPtr, 22 | EB_PTR objectInitDataPtr) 23 | { 24 | EncDecResults_t* obj; 25 | 26 | *objectDblPtr = NULL; 27 | EB_NEW(obj, EncDecResultsCtor, objectInitDataPtr); 28 | *objectDblPtr = obj; 29 | 30 | return EB_ErrorNone; 31 | } -------------------------------------------------------------------------------- /Source/Lib/Codec/EbEncDecResults.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | #include "EbObject.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | /************************************** 16 | * Process Results 17 | **************************************/ 18 | typedef struct EncDecResults_s 19 | { 20 | EbDctor dctor; 21 | EbObjectWrapper_t *pictureControlSetWrapperPtr; 22 | EB_U32 completedLcuRowIndexStart; 23 | EB_U32 completedLcuRowCount; 24 | 25 | EB_U32 tileIndex; 26 | } EncDecResults_t; 27 | 28 | typedef struct EncDecResultsInitData_s 29 | { 30 | EB_U32 junk; 31 | } EncDecResultsInitData_t; 32 | 33 | /************************************** 34 | * Extern Function Declarations 35 | **************************************/ 36 | extern EB_ERRORTYPE EncDecResultsCreator( 37 | EB_PTR *objectDblPtr, 38 | EB_PTR objectInitDataPtr); 39 | 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | #endif // EbEncDecResults_h 45 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbEncDecSegments.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbEncDecSegments_h 7 | #define EbEncDecSegments_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbThreads.h" 11 | #include "EbObject.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | /************************************** 16 | * Defines 17 | **************************************/ 18 | #define ENCDEC_SEGMENTS_MAX_COL_COUNT 60 19 | #define ENCDEC_SEGMENTS_MAX_ROW_COUNT 37 20 | #define ENCDEC_SEGMENTS_MAX_BAND_COUNT ENCDEC_SEGMENTS_MAX_COL_COUNT + ENCDEC_SEGMENTS_MAX_ROW_COUNT 21 | #define ENCDEC_SEGMENTS_MAX_COUNT ENCDEC_SEGMENTS_MAX_BAND_COUNT * ENCDEC_SEGMENTS_MAX_ROW_COUNT 22 | #define ENCDEC_SEGMENT_INVALID 0xFFFF 23 | 24 | /************************************** 25 | * Macros 26 | **************************************/ 27 | #define BAND_TOTAL_COUNT(lcuRowTotalCount, lcuColTotalCount) \ 28 | ((lcuRowTotalCount) + (lcuColTotalCount) - 1) 29 | #define ROW_INDEX(yLcuIndex, segmentRowCount, lcuRowTotalCount) \ 30 | (((yLcuIndex) * (segmentRowCount)) / (lcuRowTotalCount)) 31 | #define BAND_INDEX(xLcuIndex, yLcuIndex, segmentBandCount, lcuBandTotalCount) \ 32 | ((((xLcuIndex) + (yLcuIndex)) * (segmentBandCount)) / (lcuBandTotalCount)) 33 | #define SEGMENT_INDEX(rowIndex, bandIndex, segmentBandCount) \ 34 | (((rowIndex) * (segmentBandCount)) + (bandIndex)) 35 | 36 | /************************************** 37 | * Member definitions 38 | **************************************/ 39 | typedef struct { 40 | EB_U8 *dependencyMap; 41 | EB_HANDLE updateMutex; 42 | } EncDecSegDependencyMap_t; 43 | 44 | typedef struct { 45 | EB_U16 startingSegIndex; 46 | EB_U16 endingSegIndex; 47 | EB_U16 currentSegIndex; 48 | EB_HANDLE assignmentMutex; 49 | } EncDecSegSegmentRow_t; 50 | 51 | /************************************** 52 | * ENCDEC Segments 53 | **************************************/ 54 | typedef struct 55 | { 56 | EbDctor dctor; 57 | EncDecSegDependencyMap_t depMap; 58 | EncDecSegSegmentRow_t *rowArray; 59 | 60 | EB_U16 *xStartArray; 61 | EB_U16 *yStartArray; 62 | EB_U16 *validLcuCountArray; 63 | 64 | EB_U32 segmentBandCount; 65 | EB_U32 segmentRowCount; 66 | EB_U32 segmentTotalCount; 67 | EB_U32 lcuBandCount; 68 | EB_U32 lcuRowCount; 69 | 70 | EB_U32 segmentMaxBandCount; 71 | EB_U32 segmentMaxRowCount; 72 | EB_U32 segmentMaxTotalCount; 73 | 74 | } EncDecSegments_t; 75 | 76 | /************************************** 77 | * Extern Function Declarations 78 | **************************************/ 79 | extern EB_ERRORTYPE EncDecSegmentsCtor( 80 | EncDecSegments_t *segmentsPtr, 81 | EB_U32 segmentColCount, 82 | EB_U32 segmentRowCount); 83 | 84 | 85 | extern void EncDecSegmentsInit( 86 | EncDecSegments_t *segmentsPtr, 87 | EB_U32 colCount, 88 | EB_U32 rowCount, 89 | EB_U32 picWidthLcu, 90 | EB_U32 picHeightLcu); 91 | #ifdef __cplusplus 92 | } 93 | #endif 94 | #endif // EbEncDecResults_h -------------------------------------------------------------------------------- /Source/Lib/Codec/EbEncDecTasks.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | EB_ERRORTYPE EncDecTasksCtor( 12 | EncDecTasks_t *contextPtr, 13 | EB_PTR objectInitDataPtr) 14 | { 15 | (void)contextPtr; 16 | (void)objectInitDataPtr; 17 | 18 | return EB_ErrorNone; 19 | } 20 | 21 | EB_ERRORTYPE EncDecTasksCreator( 22 | EB_PTR *objectDblPtr, 23 | EB_PTR objectInitDataPtr) 24 | { 25 | EncDecTasks_t *obj; 26 | 27 | *objectDblPtr = NULL; 28 | EB_NEW(obj, EncDecTasksCtor, objectInitDataPtr); 29 | *objectDblPtr = obj; 30 | 31 | return EB_ErrorNone; 32 | } 33 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbEncDecTasks.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | #include "EbObject.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | #define ENCDEC_TASKS_MDC_INPUT 0 16 | #define ENCDEC_TASKS_ENCDEC_INPUT 1 17 | #define ENCDEC_TASKS_CONTINUE 2 18 | 19 | /************************************** 20 | * Process Results 21 | **************************************/ 22 | typedef struct EncDecTasks_s 23 | { 24 | EbDctor dctor; 25 | EbObjectWrapper_t *pictureControlSetWrapperPtr; 26 | EB_U32 inputType; 27 | EB_S16 encDecSegmentRow; 28 | 29 | EB_U32 tileGroupIndex; 30 | } EncDecTasks_t; 31 | 32 | typedef struct EncDecTasksInitData_s 33 | { 34 | unsigned encDecSegmentRowCount; 35 | } EncDecTasksInitData_t; 36 | 37 | /************************************** 38 | * Extern Function Declarations 39 | **************************************/ 40 | extern EB_ERRORTYPE EncDecTasksCreator( 41 | EB_PTR *objectDblPtr, 42 | EB_PTR objectInitDataPtr); 43 | 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | #endif // EbEncDecTasks_h 49 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbEntropyCodingObject.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbEntropyCodingObject_h 7 | #define EbEntropyCodingObject_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbCabacContextModel.h" 11 | #include "EbObject.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | typedef struct Bitstream_s { 16 | EbDctor dctor; 17 | EB_PTR outputBitstreamPtr; 18 | } Bitstream_t; 19 | 20 | typedef struct EntropyCoder_s { 21 | EbDctor dctor; 22 | EB_PTR cabacEncodeContextPtr; 23 | } EntropyCoder_t; 24 | 25 | extern EB_ERRORTYPE BitstreamCtor( 26 | Bitstream_t *bitstreamPtr, 27 | EB_U32 bufferSize); 28 | 29 | extern EB_ERRORTYPE EntropyCoderCtor( 30 | EntropyCoder_t *entropyCoderPtr, 31 | EB_U32 bufferSize); 32 | 33 | extern EB_PTR EntropyCoderGetBitstreamPtr( 34 | EntropyCoder_t *entropyCoderPtr); 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | #endif // EbEntropyCodingObject_h -------------------------------------------------------------------------------- /Source/Lib/Codec/EbEntropyCodingResults.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | EB_ERRORTYPE EntropyCodingResultsCtor( 12 | EntropyCodingResults_t *contextPtr, 13 | EB_PTR objectInitDataPtr) 14 | { 15 | (void)contextPtr; 16 | (void)objectInitDataPtr; 17 | 18 | return EB_ErrorNone; 19 | } 20 | 21 | 22 | EB_ERRORTYPE EntropyCodingResultsCreator( 23 | EB_PTR *objectDblPtr, 24 | EB_PTR objectInitDataPtr) 25 | { 26 | EntropyCodingResults_t* obj; 27 | 28 | *objectDblPtr = NULL; 29 | EB_NEW(obj, EntropyCodingResultsCtor, objectInitDataPtr); 30 | *objectDblPtr = obj; 31 | 32 | return EB_ErrorNone; 33 | } 34 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbEntropyCodingResults.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | #include "EbObject.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | /************************************** 16 | * Process Results 17 | **************************************/ 18 | typedef struct 19 | { 20 | EbDctor dctor; 21 | EbObjectWrapper_t *pictureControlSetWrapperPtr; 22 | } EntropyCodingResults_t; 23 | 24 | typedef struct 25 | { 26 | EB_U32 junk; 27 | } EntropyCodingResultsInitData_t; 28 | 29 | /************************************** 30 | * Extern Function Declarations 31 | **************************************/ 32 | extern EB_ERRORTYPE EntropyCodingResultsCreator( 33 | EB_PTR *objectDblPtr, 34 | EB_PTR objectInitDataPtr); 35 | 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | #endif // EbEntropyCodingResults_h -------------------------------------------------------------------------------- /Source/Lib/Codec/EbErrorHandling.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbErrorHandling_h 7 | #define EbErrorHandling_h 8 | 9 | #include "EbErrorCodes.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #define CHECK_REPORT_ERROR(cond, appCallbackPtr, errorCode) { if(!(cond)){(appCallbackPtr)->ErrorHandler(((appCallbackPtr)->handle),(errorCode));while(1);} } 16 | 17 | #define CHECK_REPORT_ERROR_NC(appCallbackPtr, errorCode) { {(appCallbackPtr)->ErrorHandler(((appCallbackPtr)->handle),(errorCode));while(1);} } 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | #endif // EbErrorHandling_h 23 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbFullLoop.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbFullLoop_h 7 | #define EbFullLoop_h 8 | 9 | #include "EbModeDecisionProcess.h" 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | void FullLoop_R( 15 | LargestCodingUnit_t *lcuPtr, 16 | ModeDecisionCandidateBuffer_t *candidateBuffer, 17 | ModeDecisionContext_t *contextPtr, 18 | const CodedUnitStats_t *cuStatsPtr, 19 | EbPictureBufferDesc_t *inputPicturePtr, 20 | PictureControlSet_t *pictureControlSetPtr, 21 | EB_U32 componentMask, 22 | EB_U32 cbQp, 23 | EB_U32 crQp, 24 | EB_U32 *cbCountNonZeroCoeffs, 25 | EB_U32 *crCountNonZeroCoeffs); 26 | 27 | void CuFullDistortionFastTuMode_R( 28 | EbPictureBufferDesc_t *inputPicturePtr, 29 | EB_U32 inputCbOriginIndex, 30 | LargestCodingUnit_t *lcuPtr, 31 | ModeDecisionCandidateBuffer_t *candidateBuffer, 32 | ModeDecisionContext_t *contextPtr, 33 | ModeDecisionCandidate_t *candidatePtr, 34 | const CodedUnitStats_t *cuStatsPtr, 35 | EB_U64 cbFullDistortion[DIST_CALC_TOTAL], 36 | EB_U64 crFullDistortion[DIST_CALC_TOTAL], 37 | EB_U32 countNonZeroCoeffs[3][MAX_NUM_OF_TU_PER_CU], 38 | EB_U32 componentMask, 39 | EB_U64 *cbCoeffBits, 40 | EB_U64 *crCoeffBits); 41 | 42 | void ProductFullLoop( 43 | EbPictureBufferDesc_t *inputPicturePtr, 44 | EB_U32 inputOriginIndex, 45 | ModeDecisionCandidateBuffer_t *candidateBuffer, 46 | ModeDecisionContext_t *contextPtr, 47 | const CodedUnitStats_t *cuStatsPtr, 48 | PictureControlSet_t *pictureControlSetPtr, 49 | EB_U32 qp, 50 | EB_U32 *yCountNonZeroCoeffs, 51 | EB_U64 *yCoeffBits, 52 | EB_U64 *yFullDistortion); 53 | 54 | extern EB_U32 ProductPerformInterDepthDecision( 55 | ModeDecisionContext_t *contextPtr, 56 | EB_U32 leafIndex, 57 | LargestCodingUnit_t *tbPtr, 58 | EB_U32 lcuAddr, 59 | EB_U32 tbOriginX, 60 | EB_U32 tbOriginY, 61 | EB_U64 fullLambda, 62 | MdRateEstimationContext_t *mdRateEstimationPtr, 63 | PictureControlSet_t *pictureControlSetPtr); 64 | 65 | EB_U32 ExitInterDepthDecision( 66 | ModeDecisionContext_t *contextPtr, 67 | EB_U32 leafIndex, 68 | LargestCodingUnit_t *tbPtr, 69 | EB_U32 lcuAddr, 70 | EB_U32 tbOriginX, 71 | EB_U32 tbOriginY, 72 | EB_U64 fullLambda, 73 | MdRateEstimationContext_t *mdRateEstimationPtr, 74 | PictureControlSet_t *pictureControlSetPtr); 75 | 76 | extern EB_U32 PillarInterDepthDecision( 77 | ModeDecisionContext_t *contextPtr, 78 | EB_U32 leafIndex, 79 | LargestCodingUnit_t *tbPtr, 80 | EB_U32 tbOriginX, 81 | EB_U32 tbOriginY, 82 | EB_U64 fullLambda, 83 | MdRateEstimationContext_t *mdRateEstimationPtr, 84 | PictureControlSet_t *pictureControlSetPtr); 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | #endif // EbFullLoop_h -------------------------------------------------------------------------------- /Source/Lib/Codec/EbHmCode.h: -------------------------------------------------------------------------------- 1 | /* The copyright in this software is being made available under the BSD 2 | * License, included below. This software may be subject to other third party 3 | * and contributor rights, including patent rights, and no such rights are 4 | * granted under this license. 5 | * 6 | * Copyright (c) 2010-2014, ITU/ISO/IEC 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * * Redistributions in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may 18 | * be used to endorse or promote products derived from this software without 19 | * specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 31 | * THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | #ifndef EbHmCode_h 35 | #define EbHmCode_h 36 | 37 | #include "EbDefinitions.h" 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | 43 | EB_U64 Compute4x4Satd( 44 | EB_S16 *diff); 45 | 46 | 47 | EB_U64 Compute4x4Satd_U8( 48 | EB_U8 *src, 49 | EB_U64 *dcValue, 50 | EB_U32 srcStride); 51 | 52 | extern const EB_U32 NextStateMpsLps[]; 53 | extern const EB_U32 CabacEstimatedBits[]; 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | #endif // EbHmCode_h -------------------------------------------------------------------------------- /Source/Lib/Codec/EbInitialRateControlProcess.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | #include "EbObject.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | /************************************** 19 | * Context 20 | **************************************/ 21 | typedef struct InitialRateControlContext_s 22 | { 23 | EbDctor dctor; 24 | EbFifo_t *motionEstimationResultsInputFifoPtr; 25 | EbFifo_t *initialrateControlResultsOutputFifoPtr; 26 | 27 | } InitialRateControlContext_t; 28 | 29 | /*************************************** 30 | * Extern Function Declaration 31 | ***************************************/ 32 | extern EB_ERRORTYPE InitialRateControlContextCtor( 33 | InitialRateControlContext_t *contextPtr, 34 | EbFifo_t *motionEstimationResultsInputFifoPtr, 35 | EbFifo_t *pictureDemuxResultsOutputFifoPtr); 36 | 37 | extern void* InitialRateControlKernel(void *inputPtr); 38 | 39 | extern void EbHevcMeBasedGlobalMotionDetection( 40 | SequenceControlSet_t *sequenceControlSetPtr, 41 | PictureParentControlSet_t *pictureControlSetPtr); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | #endif // EbInitialRateControl_h 47 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbInitialRateControlReorderQueue.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | #include "EbInitialRateControlReorderQueue.h" 8 | 9 | EB_ERRORTYPE InitialRateControlReorderEntryCtor( 10 | InitialRateControlReorderEntry_t *entryPtr, 11 | EB_U32 pictureNumber) 12 | { 13 | entryPtr->pictureNumber = pictureNumber; 14 | return EB_ErrorNone; 15 | } 16 | 17 | static void HlRateControlHistogramEntryDctor(EB_PTR p) 18 | { 19 | HlRateControlHistogramEntry_t* obj = (HlRateControlHistogramEntry_t*)p; 20 | EB_FREE_ARRAY(obj->meDistortionHistogram); 21 | EB_FREE_ARRAY(obj->oisDistortionHistogram); 22 | } 23 | 24 | EB_ERRORTYPE HlRateControlHistogramEntryCtor( 25 | HlRateControlHistogramEntry_t *entryPtr, 26 | EB_U32 pictureNumber) 27 | { 28 | entryPtr->dctor = HlRateControlHistogramEntryDctor; 29 | entryPtr->pictureNumber = pictureNumber; 30 | 31 | // ME and OIS Distortion Histograms 32 | EB_MALLOC_ARRAY(entryPtr->meDistortionHistogram, NUMBER_OF_SAD_INTERVALS); 33 | EB_MALLOC_ARRAY(entryPtr->oisDistortionHistogram, NUMBER_OF_INTRA_SAD_INTERVALS); 34 | 35 | return EB_ErrorNone; 36 | } 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbInitialRateControlReorderQueue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | #include "EbObject.h" 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | /************************************************ 18 | * Initial Rate Control Reorder Queue Entry 19 | ************************************************/ 20 | typedef struct InitialRateControlReorderEntry_s { 21 | EbDctor dctor; 22 | EB_U64 pictureNumber; 23 | EbObjectWrapper_t *parentPcsWrapperPtr; 24 | } InitialRateControlReorderEntry_t; 25 | 26 | extern EB_ERRORTYPE InitialRateControlReorderEntryCtor( 27 | InitialRateControlReorderEntry_t *entryPtr, 28 | EB_U32 pictureNumber); 29 | 30 | 31 | /************************************************ 32 | * High Level Rate Control Histogram Queue Entry 33 | ************************************************/ 34 | typedef struct HlRateControlHistogramEntry_s { 35 | EbDctor dctor; 36 | EB_U64 pictureNumber; 37 | EB_S16 lifeCount; 38 | EB_BOOL passedToHlrc; 39 | EB_BOOL isCoded; 40 | EB_U64 totalNumBitsCoded; 41 | EbObjectWrapper_t *parentPcsWrapperPtr; 42 | EB_BOOL endOfSequenceFlag; 43 | EB_U64 predBitsRefQp[MAX_REF_QP_NUM]; 44 | EB_PICTURE sliceType; 45 | EB_U32 temporalLayerIndex; 46 | 47 | 48 | // Motion Estimation Distortion and OIS Historgram 49 | EB_U16 *meDistortionHistogram; 50 | EB_U16 *oisDistortionHistogram; 51 | EB_U32 fullLcuCount; 52 | } HlRateControlHistogramEntry_t; 53 | 54 | extern EB_ERRORTYPE HlRateControlHistogramEntryCtor( 55 | HlRateControlHistogramEntry_t *entryPtr, 56 | EB_U32 pictureNumber); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | #endif //EbInitialRateControlReorderQueue_h 62 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbInitialRateControlResults.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | 8 | #include "EbInitialRateControlResults.h" 9 | 10 | EB_ERRORTYPE InitialRateControlResultsCtor( 11 | InitialRateControlResults_t *objectPtr, 12 | EB_PTR objectInitDataPtr) 13 | { 14 | (void)objectPtr; 15 | (void)objectInitDataPtr; 16 | return EB_ErrorNone; 17 | } 18 | 19 | EB_ERRORTYPE InitialRateControlResultsCreator( 20 | EB_PTR *objectDblPtr, 21 | EB_PTR objectInitDataPtr) 22 | { 23 | InitialRateControlResults_t* obj; 24 | 25 | *objectDblPtr = NULL; 26 | EB_NEW(obj, InitialRateControlResultsCtor, objectInitDataPtr); 27 | *objectDblPtr = obj; 28 | 29 | return EB_ErrorNone; 30 | } 31 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbInitialRateControlResults.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | #include "EbObject.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | /************************************** 16 | * Process Results 17 | **************************************/ 18 | typedef struct InitialRateControlResults_s 19 | { 20 | EbDctor dctor; 21 | EbObjectWrapper_t *pictureControlSetWrapperPtr; 22 | } InitialRateControlResults_t; 23 | 24 | typedef struct InitialRateControlResultInitData_s 25 | { 26 | int junk; 27 | } InitialRateControlResultInitData_t; 28 | 29 | /************************************** 30 | * Extern Function Declarations 31 | **************************************/ 32 | extern EB_ERRORTYPE InitialRateControlResultsCreator( 33 | EB_PTR *objectDblPtr, 34 | EB_PTR objectInitDataPtr); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | #endif //EbInitialRateControlResults_h -------------------------------------------------------------------------------- /Source/Lib/Codec/EbInterPrediction.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbInterPrediction_h 7 | #define EbInterPrediction_h 8 | 9 | #include "EbDefinitions.h" 10 | 11 | #include "EbPictureControlSet.h" 12 | #include "EbCodingUnit.h" 13 | #include "EbPredictionUnit.h" 14 | #include "EbModeDecision.h" 15 | #include "EbMcp.h" 16 | #include "EbMvMerge.h" 17 | #include "EbObject.h" 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | #define MVBOUNDLOW 36 // (80-71)<<2 // 80 = ReferencePadding ; minus 71 is derived from the expression -64 + 1 - 8, and plus 7 is derived from expression -1 + 8 23 | #define MVBOUNDHIGH 348 // (80+7)<<2 24 | #define REFPADD_QPEL 320 // (16+64)<<2 25 | 26 | void RoundMvOnTheFly( 27 | EB_S16 *motionVector_x, 28 | EB_S16 *motionVector_y); 29 | 30 | struct ModeDecisionContext_s; 31 | 32 | typedef struct InterPredictionContext_s { 33 | EbDctor dctor; 34 | // mcp context 35 | MotionCompensationPredictionContext_t *mcpContext; 36 | 37 | // MV Merge 38 | EB_U32 mvMergeCandidateCount; 39 | MvMergeCandidate_t mvMergeCandidateArray[MAX_NUM_OF_MV_MERGE_CANDIDATE]; 40 | 41 | } InterPredictionContext_t; 42 | 43 | extern EB_ERRORTYPE InterPredictionContextCtor( 44 | InterPredictionContext_t *contextPtr, 45 | EB_U16 maxCUWidth, 46 | EB_U16 maxCUHeight, 47 | EB_BOOL is16bit); 48 | 49 | 50 | extern EB_ERRORTYPE Inter2Nx2NPuPredictionInterpolationFree( 51 | struct ModeDecisionContext_s *contextPtr, 52 | EB_U32 componentMask, 53 | PictureControlSet_t *pictureControlSetPtr, 54 | ModeDecisionCandidateBuffer_t *candidateBufferPtr); 55 | 56 | EB_ERRORTYPE Inter2Nx2NPuPredictionHevc( 57 | struct ModeDecisionContext_s *contextPtr, 58 | EB_U32 componentMask, 59 | PictureControlSet_t *pictureControlSetPtr, 60 | ModeDecisionCandidateBuffer_t *candidateBufferPtr); 61 | 62 | 63 | 64 | extern EB_ERRORTYPE EncodePassInterPrediction( 65 | MvUnit_t *mvUnit, 66 | EB_U16 puOriginX, 67 | EB_U16 puOriginY, 68 | EB_U8 puWidth, 69 | EB_U8 puHeight, 70 | PictureControlSet_t *pictureControlSetPtr, 71 | EbPictureBufferDesc_t *predictionPtr, 72 | MotionCompensationPredictionContext_t *mcpContext); 73 | 74 | extern EB_ERRORTYPE EncodePassInterPrediction16bit( 75 | MvUnit_t *mvUnit, 76 | EB_U16 puOriginX, 77 | EB_U16 puOriginY, 78 | EB_U8 puWidth, 79 | EB_U8 puHeight, 80 | PictureControlSet_t *pictureControlSetPtr, 81 | EbPictureBufferDesc_t *predictionPtr, 82 | MotionCompensationPredictionContext_t *mcpContext); 83 | 84 | EB_ERRORTYPE ChooseMVPIdx_V2( 85 | ModeDecisionCandidate_t *candidatePtr, 86 | EB_U32 cuOriginX, 87 | EB_U32 cuOriginY, 88 | EB_U32 puIndex, 89 | EB_U32 tbSize, 90 | EB_S16 *ref0AMVPCandArray_x, 91 | EB_S16 *ref0AMVPCandArray_y, 92 | EB_U32 ref0NumAvailableAMVPCand, 93 | EB_S16 *ref1AMVPCandArray_x, 94 | EB_S16 *ref1AMVPCandArray_y, 95 | EB_U32 ref1NumAvailableAMVPCand, 96 | PictureControlSet_t *pictureControlSetPtr); 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | #endif //EbInterPrediction_h 101 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbMeSadCalculation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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(*EB_SADCALCULATION8X8AND16X16_TYPE)( 21 | EB_U8 *src, 22 | EB_U32 srcStride, 23 | EB_U8 *ref, 24 | EB_U32 refStride, 25 | EB_U32 *pBestSad8x8, 26 | EB_U32 *pBestSad16x16, 27 | EB_U32 *pBestMV8x8, 28 | EB_U32 *pBestMV16x16, 29 | EB_U32 mv, 30 | EB_U32 *pSad16x16); 31 | 32 | typedef void(*EB_SADCALCULATION32X32AND64X64_TYPE)( 33 | EB_U32 *pSad16x16, 34 | EB_U32 *pBestSad32x32, 35 | EB_U32 *pBestSad64x64, 36 | EB_U32 *pBestMV32x32, 37 | EB_U32 *pBestMV64x64, 38 | EB_U32 mv); 39 | 40 | typedef void(*EB_INIALIZEBUFFER_32BITS)( 41 | EB_U32* Pointer, 42 | EB_U32 Count128, 43 | EB_U32 Count32, 44 | EB_U32 Value); 45 | 46 | typedef void(*EB_RECTAMPSADCALCULATION8X8AND16X16_TYPE)( 47 | EB_U8 *src, 48 | EB_U32 srcStride, 49 | EB_U8 *ref, 50 | EB_U32 refStride, 51 | EB_U32 *pBestSad8x8, 52 | EB_U32 *pBestSad16x16, 53 | EB_U32 *pBestMV8x8, 54 | EB_U32 *pBestMV16x16, 55 | EB_U32 mv, 56 | EB_U32 *pSad16x16, 57 | EB_U32 *pSad8x8); 58 | 59 | typedef void(*EB_RECTAMPSADCALCULATION32X32AND64X64_TYPE)( 60 | EB_U32 *pSad16x16, 61 | EB_U32 *pSad32x32, 62 | EB_U32 *pBestSad32x32, 63 | EB_U32 *pBestSad64x64, 64 | EB_U32 *pBestMV32x32, 65 | EB_U32 *pBestMV64x64, 66 | EB_U32 mv); 67 | 68 | typedef void(*EB_RECTAMPSADCALCULATION_TYPE)( 69 | EB_U32 *pSad8x8, 70 | EB_U32 *pSad16x16, 71 | EB_U32 *pSad32x32, 72 | EB_U32 *pBestSad64x32, 73 | EB_U32 *pBestMV64x32, 74 | EB_U32 *pBestSad32x16, 75 | EB_U32 *pBestMV32x16, 76 | EB_U32 *pBestSad16x8, 77 | EB_U32 *pBestMV16x8, 78 | EB_U32 *pBestSad32x64, 79 | EB_U32 *pBestMV32x64, 80 | EB_U32 *pBestSad16x32, 81 | EB_U32 *pBestMV16x32, 82 | EB_U32 *pBestSad8x16, 83 | EB_U32 *pBestMV8x16, 84 | EB_U32 *pBestSad64x16, 85 | EB_U32 *pBestMV64x16, 86 | EB_U32 *pBestSad32x8, 87 | EB_U32 *pBestMV32x8, 88 | EB_U32 *pBestSad64x48, 89 | EB_U32 *pBestMV64x48, 90 | EB_U32 *pBestSad32x24, 91 | EB_U32 *pBestMV32x24, 92 | EB_U32 *pBestSad16x64, 93 | EB_U32 *pBestMV16x64, 94 | EB_U32 *pBestSad8x32, 95 | EB_U32 *pBestMV8x32, 96 | EB_U32 *pBestSad48x64, 97 | EB_U32 *pBestMV48x64, 98 | EB_U32 *pBestSad24x32, 99 | EB_U32 *pBestMV24x32, 100 | EB_U32 mv); 101 | 102 | 103 | /*************************************** 104 | * Function Tables 105 | ***************************************/ 106 | static EB_SADCALCULATION8X8AND16X16_TYPE SadCalculation_8x8_16x16_funcPtrArray[EB_ASM_TYPE_TOTAL] = { 107 | // C_DEFAULT 108 | SadCalculation_8x8_16x16, 109 | // AVX2 110 | SadCalculation_8x8_16x16_SSE2_INTRIN, 111 | }; 112 | 113 | static EB_SADCALCULATION32X32AND64X64_TYPE SadCalculation_32x32_64x64_funcPtrArray[EB_ASM_TYPE_TOTAL] = { 114 | // C_DEFAULT 115 | SadCalculation_32x32_64x64, 116 | // AVX2 117 | SadCalculation_32x32_64x64_SSE2_INTRIN, 118 | }; 119 | 120 | 121 | static EB_INIALIZEBUFFER_32BITS InitializeBuffer_32bits_funcPtrArray[EB_ASM_TYPE_TOTAL] = { 122 | // C_DEFAULT 123 | InitializeBuffer_32bits, 124 | // AVX2 125 | InitializeBuffer_32bits_SSE2_INTRIN 126 | }; 127 | 128 | 129 | #ifdef __cplusplus 130 | } 131 | #endif 132 | #endif // EbMeSadCalculation_h -------------------------------------------------------------------------------- /Source/Lib/Codec/EbModeDecisionConfigurationProcess.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbModeDecisionConfigurationProcess_h 7 | #define EbModeDecisionConfigurationProcess_h 8 | 9 | #include "EbSystemResourceManager.h" 10 | #include "EbMdRateEstimation.h" 11 | #include "EbDefinitions.h" 12 | #include "EbRateControlProcess.h" 13 | #include "EbSequenceControlSet.h" 14 | #include "EbObject.h" 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /************************************** 20 | * Defines 21 | **************************************/ 22 | 23 | typedef struct MdcpLocalCodingUnit_s 24 | { 25 | EB_U64 earlyCost; 26 | EB_BOOL earlySplitFlag; 27 | EB_U32 splitContext; 28 | EB_BOOL slectedCu; 29 | EB_BOOL stopSplit; 30 | } MdcpLocalCodingUnit_t; 31 | 32 | typedef struct ModeDecisionConfigurationContext_s 33 | { 34 | EbDctor dctor; 35 | EbFifo_t *rateControlInputFifoPtr; 36 | EbFifo_t *modeDecisionConfigurationOutputFifoPtr; 37 | 38 | MdRateEstimationContext_t *mdRateEstimationPtr; 39 | 40 | EB_U8 qp; 41 | EB_U64 lambda; 42 | MdcpLocalCodingUnit_t localCuArray[CU_MAX_COUNT]; 43 | 44 | // Inter depth decision 45 | EB_U8 groupOf8x8BlocksCount; 46 | EB_U8 groupOf16x16BlocksCount; 47 | EB_U64 interComplexityMinimum; 48 | EB_U64 interComplexityMaximum; 49 | EB_U64 interComplexityAverage; 50 | EB_U64 intraComplexityMinimum; 51 | EB_U64 intraComplexityMaximum; 52 | EB_U64 intraComplexityAverage; 53 | EB_S16 minDeltaQpWeight; 54 | EB_S16 maxDeltaQpWeight; 55 | EB_S8 minDeltaQp[4]; 56 | EB_S8 maxDeltaQp[4]; 57 | 58 | // Budgeting 59 | EB_U32 *lcuScoreArray; 60 | EB_U8 costDepthMode[LCU_PRED_OPEN_LOOP_1_NFL_DEPTH_MODE]; 61 | EB_U8 *lcuCostArray; 62 | EB_U32 predictedCost; 63 | EB_U32 budget; 64 | EB_S8 scoreTh[MAX_SUPPORTED_SEGMENTS]; 65 | EB_U8 intervalCost[MAX_SUPPORTED_SEGMENTS]; 66 | EB_U8 numberOfSegments; 67 | EB_U32 lcuMinScore; 68 | EB_U32 lcuMaxScore; 69 | 70 | EB_ADP_DEPTH_SENSITIVE_PIC_CLASS adpDepthSensitivePictureClass; 71 | 72 | EB_ADP_REFINEMENT_MODE adpRefinementMode; 73 | 74 | // Multi - Mode signal(s) 75 | EB_U8 adpLevel; 76 | EB_U8 chromaQpOffsetLevel; 77 | 78 | } ModeDecisionConfigurationContext_t; 79 | 80 | 81 | 82 | /************************************** 83 | * Extern Function Declarations 84 | **************************************/ 85 | extern EB_ERRORTYPE ModeDecisionConfigurationContextCtor( 86 | ModeDecisionConfigurationContext_t *contextPtr, 87 | EbFifo_t *rateControlInputFifoPtr, 88 | 89 | EbFifo_t *modeDecisionConfigurationOutputFifoPtr, 90 | EB_U16 lcuTotalCount); 91 | 92 | 93 | extern void* ModeDecisionConfigurationKernel(void *inputPtr); 94 | #ifdef __cplusplus 95 | } 96 | #endif 97 | #endif // EbModeDecisionConfigurationProcess_h -------------------------------------------------------------------------------- /Source/Lib/Codec/EbModeDecisionSegments.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | #ifndef EbModeDecisionSegments_h 6 | #define EbModeDecisionSegments_h 7 | 8 | #include "EbDefinitions.h" 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | /************************************** 15 | * Mode Decision Segments 16 | **************************************/ 17 | typedef struct 18 | { 19 | EB_U64 completionMask; 20 | EB_HANDLE writeLockMutex; 21 | 22 | EB_U32 totalCount; 23 | EB_U32 columnCount; 24 | EB_U32 rowCount; 25 | 26 | EB_BOOL inProgress; 27 | EB_U32 currentRowIdx; 28 | 29 | } MdSegments_t; 30 | 31 | /************************************** 32 | * Extern Function Declarations 33 | **************************************/ 34 | extern void ModeDecisionSegmentsCtor( 35 | MdSegments_t **contextDblPtr); 36 | 37 | extern void ModeDecisionSegmentsDtor( 38 | MdSegments_t *contextPtr); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | #endif // EbModeDecisionSegments_h -------------------------------------------------------------------------------- /Source/Lib/Codec/EbMotionEstimation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 EB_ERRORTYPE MotionEstimateLcu( 22 | PictureParentControlSet_t *pictureControlSetPtr, 23 | EB_U32 lcuIndex, 24 | EB_U32 lcuOriginX, 25 | EB_U32 lcuOriginY, 26 | MeContext_t *contextPtr, 27 | EbPictureBufferDesc_t *inputPtr); 28 | 29 | extern EB_ERRORTYPE OpenLoopIntraCandidateSearchLcu( 30 | PictureParentControlSet_t *pictureControlSetPtr, 31 | EB_U32 lcuIndex, 32 | MotionEstimationContext_t *contextPtr, 33 | EbPictureBufferDesc_t *inputPtr); 34 | 35 | extern void Decimation2D( 36 | EB_U8 *inputSamples, 37 | EB_U32 inputStride, 38 | EB_U32 inputAreaWidth, 39 | EB_U32 inputAreaHeight, 40 | EB_U8 *decimSamples, 41 | EB_U32 decimStride, 42 | EB_U32 decimStep); 43 | 44 | extern EB_ERRORTYPE OpenLoopIntraSearchLcu( 45 | PictureParentControlSet_t *pictureControlSetPtr, 46 | EB_U32 lcuIndex, 47 | MotionEstimationContext_t *contextPtr, 48 | EbPictureBufferDesc_t *inputPtr); 49 | 50 | extern void EbHevcGetMv( 51 | PictureParentControlSet_t *pictureControlSetPtr, 52 | EB_U32 lcuIndex, 53 | EB_S32 *xCurrentMv, 54 | EB_S32 *yCurrentMv); 55 | 56 | extern void EbHevcGetMeDist( 57 | PictureParentControlSet_t *pictureControlSetPtr, 58 | EB_U32 lcuIndex, 59 | EB_U32 *distortion); 60 | 61 | EB_S8 Sort3Elements(EB_U32 a, EB_U32 b, EB_U32 c); 62 | #define a_b_c 0 63 | #define a_c_b 1 64 | #define b_a_c 2 65 | #define b_c_a 3 66 | #define c_a_b 4 67 | #define c_b_a 5 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | #endif // EbMotionEstimation_h -------------------------------------------------------------------------------- /Source/Lib/Codec/EbMotionEstimationLcuResults.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 "EbObject.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_s { 20 | 21 | union { 22 | struct { 23 | signed short xMvL0 ; //Note: Do not change the order of these fields 24 | signed short yMvL0 ; 25 | signed short xMvL1 ; 26 | signed short yMvL1 ; 27 | }mv; 28 | EB_U64 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_t; 36 | 37 | // move this to a new file with ctor & dtor 38 | typedef struct MeLcuResults_s { 39 | EbDctor dctor; 40 | EB_U32 lcuDistortion; 41 | EB_U8 *totalMeCandidateIndex; 42 | EB_S16 xMvHmeSearchCenter[MAX_NUM_OF_REF_PIC_LIST][MAX_REF_IDX]; 43 | EB_S16 yMvHmeSearchCenter[MAX_NUM_OF_REF_PIC_LIST][MAX_REF_IDX]; 44 | MeCandidate_t **meCandidate; 45 | MeCandidate_t *meCandidateArray; 46 | 47 | } MeLcuResults_t; 48 | 49 | 50 | 51 | 52 | typedef struct DistDir_s{ 53 | unsigned distortion : 32; //20bits are enough 54 | unsigned direction : 2; 55 | } DistDir_t; 56 | 57 | 58 | typedef struct MeCuResults_s { 59 | union { 60 | struct { 61 | signed short xMvL0; 62 | signed short yMvL0; 63 | signed short xMvL1; 64 | signed short yMvL1; 65 | }; 66 | EB_U64 MVs; 67 | }; 68 | 69 | DistDir_t distortionDirection[3]; 70 | 71 | EB_U8 totalMeCandidateIndex; 72 | 73 | } MeCuResults_t; 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | #endif // EbMotionEstimationLcuResults_h 79 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbMotionEstimationProcess.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | #include "EbObject.h" 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /************************************** 20 | * Context 21 | **************************************/ 22 | typedef struct MotionEstimationContext_s 23 | { 24 | EbDctor dctor; 25 | EbFifo_t *pictureDecisionResultsInputFifoPtr; 26 | EbFifo_t *motionEstimationResultsOutputFifoPtr; 27 | 28 | MeContext_t *meContextPtr; 29 | 30 | IntraReferenceSamplesOpenLoop_t *intraRefPtr; 31 | 32 | // Multi-Mode signal(s) 33 | EB_BOOL oisKernelLevel; // used by P/B Slices 34 | EB_U8 oisThSet; // used by P/B Slices 35 | EB_BOOL setBestOisDistortionToValid; // used by I/P/B Slices 36 | 37 | } MotionEstimationContext_t; 38 | 39 | /*************************************** 40 | * Extern Function Declaration 41 | ***************************************/ 42 | extern EB_ERRORTYPE MotionEstimationContextCtor( 43 | MotionEstimationContext_t *contextPtr, 44 | EbFifo_t *pictureDecisionResultsInputFifoPtr, 45 | EbFifo_t *motionEstimationResultsOutputFifoPtr); 46 | 47 | 48 | extern void* MotionEstimationKernel(void *inputPtr); 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | #endif // EbMotionEstimationProcess_h -------------------------------------------------------------------------------- /Source/Lib/Codec/EbMotionEstimationResults.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | EB_ERRORTYPE MotionEstimationResultsCtor( 12 | MotionEstimationResults_t *contexPtr, 13 | EB_PTR objectInitDataPtr) 14 | { 15 | (void)contexPtr; 16 | (void)objectInitDataPtr; 17 | return EB_ErrorNone; 18 | } 19 | 20 | EB_ERRORTYPE MotionEstimationResultsCreator( 21 | EB_PTR *objectDblPtr, 22 | EB_PTR objectInitDataPtr) 23 | { 24 | MotionEstimationResults_t *obj; 25 | 26 | *objectDblPtr = NULL; 27 | EB_NEW(obj, MotionEstimationResultsCtor, objectInitDataPtr); 28 | *objectDblPtr = obj; 29 | return EB_ErrorNone; 30 | } 31 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbMotionEstimationResults.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | #include "EbObject.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | /************************************** 16 | * Process Results 17 | **************************************/ 18 | typedef struct MotionEstimationResults_s 19 | { 20 | EbDctor dctor; 21 | EbObjectWrapper_t *pictureControlSetWrapperPtr; 22 | EB_U32 segmentIndex; 23 | } MotionEstimationResults_t; 24 | 25 | typedef struct MotionEstimationResultsInitData_s 26 | { 27 | int junk; 28 | } MotionEstimationResultsInitData_t; 29 | 30 | /************************************** 31 | * Extern Function Declarations 32 | **************************************/ 33 | extern EB_ERRORTYPE MotionEstimationResultsCreator( 34 | EB_PTR *objectDblPtr, 35 | EB_PTR objectInitDataPtr); 36 | 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | #endif // EbMotionEstimationResults_h -------------------------------------------------------------------------------- /Source/Lib/Codec/EbMotionVectorUnit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbMotionVectorUnit_h 7 | #define EbMotionVectorUnit_h 8 | 9 | #include "EbDefinitions.h" 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | #pragma pack(push, 1) 14 | 15 | typedef union { 16 | struct 17 | { 18 | signed short x; 19 | signed short y; 20 | }; 21 | EB_U32 mvUnion; 22 | } Mv_t; 23 | 24 | #pragma pack(pop) 25 | 26 | #pragma pack(push, 1) 27 | typedef struct 28 | { 29 | signed mvdX : 16; 30 | signed mvdY : 16; 31 | unsigned refIdx : 1; 32 | unsigned : 7; 33 | unsigned predIdx : 1; 34 | unsigned : 7; 35 | 36 | } Mvd_t; 37 | #pragma pack(pop) 38 | 39 | typedef struct 40 | { 41 | Mv_t mv[MAX_NUM_OF_REF_PIC_LIST]; 42 | EB_U8 predDirection; 43 | } MvUnit_t; 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | #endif // EbMotionVectorUnit_h -------------------------------------------------------------------------------- /Source/Lib/Codec/EbMvMerge.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbMvMerge_h 7 | #define EbMvMerge_h 8 | 9 | #include "EbDefinitions.h" 10 | #include "EbPictureControlSet.h" 11 | #include "EbCodingUnit.h" 12 | #include "EbPredictionUnit.h" 13 | #include "EbNeighborArrays.h" 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | /** This macro is used to compare if two PUs have the same MVs (same refPicIndex, same MV_x and same MV_y) 18 | in a particular reference picture list. 19 | */ 20 | #define CHECK_MV_EQUIVALENT(pu1PredDir, pu1RefIdx, pu1Mv_x, pu1Mv_y, pu2PredDir, pu2RefIdx, pu2Mv_x, pu2Mv_y, refPicList) ( \ 21 | (!(((pu1PredDir) + 1) & ( 1 << (refPicList))) && \ 22 | !(((pu2PredDir) + 1) & ( 1 << (refPicList)))) || \ 23 | ((((pu1PredDir) + 1) & ( 1 << (refPicList))) && \ 24 | (((pu2PredDir) + 1) & ( 1 << (refPicList))) && \ 25 | ((pu1RefIdx) == (pu2RefIdx)) && \ 26 | ((pu1Mv_x) == (pu2Mv_x)) && \ 27 | ((pu1Mv_y) == (pu2Mv_y))) \ 28 | ) 29 | 30 | typedef struct MvMergeCandidate_s { 31 | Mv_t mv[MAX_NUM_OF_REF_PIC_LIST]; 32 | EB_U8 predictionDirection; 33 | } MvMergeCandidate_t; 34 | 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | #endif // EbMvMerge_h 40 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbObject.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | #ifndef EbObject_h 6 | #define EbObject_h 7 | #include 8 | 9 | #include "EbMalloc.h" 10 | 11 | /*typical usage like this. 12 | 13 | typedef A { 14 | EbDctor dctor; 15 | //... 16 | }; 17 | 18 | a_dctor(void* p) 19 | { 20 | A* a = (A*)p; 21 | //free everything allocated by A; 22 | } 23 | 24 | a_ctor(A* a) 25 | { 26 | //this not need if you do not need a deconsturctor. 27 | a->dctor = a_dctor; 28 | //consturct everything 29 | } 30 | 31 | A* o; 32 | EB_NEW(o, a_ctor); 33 | //... 34 | EB_RELEASE(o); 35 | 36 | } 37 | */ 38 | 39 | typedef void(*EbDctor)(void* pobj); 40 | 41 | #define EB_DELETE_UNCHECKED(pobj) \ 42 | do { \ 43 | if ((pobj)->dctor) (pobj)->dctor(pobj); \ 44 | EB_FREE((pobj)); \ 45 | } while (0) 46 | 47 | //trick: to support zero param constructor 48 | #define EB_VA_ARGS(...) ,##__VA_ARGS__ 49 | 50 | #define EB_NO_THROW_NEW(pobj, ctor, ...) \ 51 | do { \ 52 | EB_ERRORTYPE err; \ 53 | size_t size = sizeof(*pobj); \ 54 | EB_NO_THROW_CALLOC(pobj, 1, size); \ 55 | if (pobj) { \ 56 | err = ctor(pobj EB_VA_ARGS(__VA_ARGS__)); \ 57 | if (err != EB_ErrorNone) EB_DELETE_UNCHECKED(pobj); \ 58 | } \ 59 | } while (0) 60 | 61 | #define EB_NEW(pobj, ctor, ...) \ 62 | do { \ 63 | EB_ERRORTYPE err; \ 64 | size_t size = sizeof(*pobj); \ 65 | EB_CALLOC(pobj, 1, size); \ 66 | err = ctor(pobj EB_VA_ARGS(__VA_ARGS__)); \ 67 | if (err != EB_ErrorNone) { \ 68 | EB_DELETE_UNCHECKED(pobj); \ 69 | return err; \ 70 | } \ 71 | } while (0) 72 | 73 | #define EB_DELETE(pobj) \ 74 | do { \ 75 | if (pobj) EB_DELETE_UNCHECKED(pobj); \ 76 | } while (0) 77 | 78 | #define EB_DELETE_PTR_ARRAY(pa, count) \ 79 | do {\ 80 | uint32_t i; \ 81 | if (pa) { \ 82 | for (i = 0; i < count; i++) { \ 83 | EB_DELETE(pa[i]); \ 84 | } \ 85 | EB_FREE(pa); \ 86 | } \ 87 | } while (0) 88 | 89 | #undef EB_DELETE_UNCHECK //do not use this outside 90 | //#undef EB_VA_ARGS 91 | 92 | #endif //EbObject_h 93 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPacketizationProcess.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | #include "EbObject.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /************************************** 17 | * Type Declarations 18 | **************************************/ 19 | typedef struct EbPPSConfig_s 20 | { 21 | EB_U8 ppsId; 22 | EB_U8 constrainedFlag; 23 | 24 | } EbPPSConfig_t; 25 | 26 | /************************************** 27 | * Context 28 | **************************************/ 29 | typedef struct PacketizationContext_s 30 | { 31 | EbDctor dctor; 32 | EbFifo_t *entropyCodingInputFifoPtr; 33 | EbFifo_t *rateControlTasksOutputFifoPtr; 34 | EbPPSConfig_t *ppsConfig; 35 | EbFifo_t *pictureManagerOutputFifoPtr; // to picture-manager 36 | 37 | } PacketizationContext_t; 38 | 39 | /************************************** 40 | * Extern Function Declarations 41 | **************************************/ 42 | extern EB_ERRORTYPE PacketizationContextCtor( 43 | PacketizationContext_t *contextPtr, 44 | EbFifo_t *entropyCodingInputFifoPtr, 45 | EbFifo_t *rateControlTasksOutputFifoPtr, 46 | EbFifo_t *pictureManagerOutputFifoPtr 47 | ); 48 | 49 | 50 | extern void* PacketizationKernel(void *inputPtr); 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | #endif // EbPacketization_h 55 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPacketizationReorderQueue.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | #include "EbPacketizationReorderQueue.h" 8 | #include "EbPictureControlSet.h" 9 | 10 | static void PacketizationReorderEntryDctor(EB_PTR p) 11 | { 12 | PacketizationReorderEntry_t *obj = (PacketizationReorderEntry_t*)p; 13 | EB_FREE(obj->picTimingEntry); 14 | EB_DELETE(obj->bitStreamPtr2); 15 | } 16 | 17 | EB_ERRORTYPE PacketizationReorderEntryCtor( 18 | PacketizationReorderEntry_t *entryPtr, 19 | EB_U32 pictureNumber) 20 | { 21 | entryPtr->dctor = PacketizationReorderEntryDctor; 22 | EB_CALLOC(entryPtr->picTimingEntry, 1, sizeof(PicTimingEntry_t)); 23 | 24 | EB_NEW( 25 | entryPtr->bitStreamPtr2, 26 | BitstreamCtor, 27 | PACKETIZATION_PROCESS_BUFFER_SIZE); 28 | 29 | entryPtr->pictureNumber = pictureNumber; 30 | return EB_ErrorNone; 31 | } 32 | 33 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPacketizationReorderQueue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 "EbEntropyCodingObject.h" 12 | #include "EbObject.h" 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | /************************************************ 17 | * Packetization Reorder Queue Entry 18 | ************************************************/ 19 | typedef struct PicTimingEntry_s 20 | { 21 | EB_PICT_STRUCT picStruct; 22 | EB_U8 temporalId; 23 | EB_U64 decodeOrder; 24 | EB_U64 poc; 25 | } PicTimingEntry_t; 26 | 27 | typedef struct PacketizationReorderEntry_s { 28 | EbDctor dctor; 29 | EB_U64 pictureNumber; 30 | EbObjectWrapper_t *outputStreamWrapperPtr; 31 | 32 | EB_U64 startTimeSeconds; 33 | EB_U64 startTimeuSeconds; 34 | EB_U64 actualBits; 35 | EB_PICTURE sliceType; 36 | PicTimingEntry_t *picTimingEntry; 37 | Bitstream_t *bitStreamPtr2; 38 | EB_U32 startSplicing; 39 | EB_U64 fillerBitsSent; 40 | EB_U64 fillerBitsFinal; 41 | EB_BOOL isUsedAsReferenceFlag; 42 | } PacketizationReorderEntry_t; 43 | 44 | extern EB_ERRORTYPE PacketizationReorderEntryCtor( 45 | PacketizationReorderEntry_t *entryPtr, 46 | EB_U32 pictureNumber); 47 | 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | #endif //EbPacketizationReorderQueue_h 53 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureAnalysisResults.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | 8 | #include "EbPictureAnalysisResults.h" 9 | 10 | EB_ERRORTYPE PictureAnalysisResultCtor( 11 | PictureAnalysisResults_t *objectPtr, 12 | EB_PTR objectInitDataPtr) 13 | { 14 | (void)objectPtr; 15 | (void)objectInitDataPtr; 16 | return EB_ErrorNone; 17 | } 18 | 19 | EB_ERRORTYPE PictureAnalysisResultCreator( 20 | EB_PTR *objectDblPtr, 21 | EB_PTR objectInitDataPtr) 22 | { 23 | PictureAnalysisResults_t *obj; 24 | 25 | *objectDblPtr = NULL; 26 | EB_NEW(obj, PictureAnalysisResultCtor, objectInitDataPtr); 27 | *objectDblPtr = (EB_PTR)obj; 28 | 29 | return EB_ErrorNone; 30 | } 31 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureAnalysisResults.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | #include "EbObject.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /************************************** 17 | * Process Results 18 | **************************************/ 19 | typedef struct PictureAnalysisResults_s 20 | { 21 | EbDctor dctor; 22 | EbObjectWrapper_t *pictureControlSetWrapperPtr; 23 | } PictureAnalysisResults_t; 24 | 25 | typedef struct PictureAnalysisResultInitData_s 26 | { 27 | int junk; 28 | } PictureAnalysisResultInitData_t; 29 | 30 | /************************************** 31 | * Extern Function Declarations 32 | **************************************/ 33 | extern EB_ERRORTYPE PictureAnalysisResultCreator( 34 | EB_PTR *objectDblPtr, 35 | EB_PTR objectInitDataPtr); 36 | 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | #endif //EbPictureAnalysisResults_h -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureDecisionProcess.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | #include "EbObject.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /************************************** 17 | * Context 18 | **************************************/ 19 | typedef struct PictureDecisionContext_s 20 | { 21 | EbDctor dctor; 22 | EbFifo_t *pictureAnalysisResultsInputFifoPtr; 23 | EbFifo_t *pictureDecisionResultsOutputFifoPtr; 24 | 25 | EB_U64 lastSolidColorFramePoc; 26 | 27 | EB_BOOL resetRunningAvg; 28 | 29 | EB_U32 **ahdRunningAvgCb; 30 | EB_U32 **ahdRunningAvgCr; 31 | EB_U32 **ahdRunningAvg; 32 | EB_BOOL isSceneChangeDetected; 33 | 34 | // Dynamic GOP 35 | EB_U32 totalRegionActivityCost[MAX_NUMBER_OF_REGIONS_IN_WIDTH][MAX_NUMBER_OF_REGIONS_IN_HEIGHT]; 36 | 37 | 38 | EB_U32 totalNumberOfMiniGops; 39 | 40 | EB_U32 miniGopStartIndex[MINI_GOP_WINDOW_MAX_COUNT]; 41 | EB_U32 miniGopEndIndex [MINI_GOP_WINDOW_MAX_COUNT]; 42 | EB_U32 miniGopLenght [MINI_GOP_WINDOW_MAX_COUNT]; 43 | EB_U32 miniGopIntraCount[MINI_GOP_WINDOW_MAX_COUNT]; 44 | EB_U32 miniGopIdrCount [MINI_GOP_WINDOW_MAX_COUNT]; 45 | EB_U32 miniGopHierarchicalLevels[MINI_GOP_WINDOW_MAX_COUNT]; 46 | EB_BOOL miniGopActivityArray [MINI_GOP_MAX_COUNT]; 47 | EB_U32 miniGopRegionActivityCostArray[MINI_GOP_MAX_COUNT][MAX_NUMBER_OF_REGIONS_IN_WIDTH][MAX_NUMBER_OF_REGIONS_IN_HEIGHT]; 48 | 49 | EB_U32 miniGopGroupFadedInPicturesCount [MINI_GOP_MAX_COUNT]; 50 | EB_U32 miniGopGroupFadedOutPicturesCount[MINI_GOP_MAX_COUNT]; 51 | } PictureDecisionContext_t; 52 | 53 | /*************************************** 54 | * Extern Function Declaration 55 | ***************************************/ 56 | extern EB_ERRORTYPE PictureDecisionContextCtor( 57 | PictureDecisionContext_t *contextPtr, 58 | EbFifo_t *pictureAnalysisResultsInputFifoPtr, 59 | EbFifo_t *pictureDecisionResultsOutputFifoPtr); 60 | 61 | 62 | extern void* PictureDecisionKernel(void *inputPtr); 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | #endif // EbPictureDecision_h 68 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureDecisionQueue.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | #include "EbPictureDecisionQueue.h" 8 | 9 | static void PaReferenceQueueEntryDctor(EB_PTR p) 10 | { 11 | PaReferenceQueueEntry_t* obj = (PaReferenceQueueEntry_t*)p; 12 | EB_FREE_ARRAY(obj->list0.list); 13 | EB_FREE_ARRAY(obj->list1.list); 14 | } 15 | 16 | EB_ERRORTYPE PaReferenceQueueEntryCtor( 17 | PaReferenceQueueEntry_t *entryPtr) 18 | { 19 | entryPtr->dctor = PaReferenceQueueEntryDctor; 20 | EB_MALLOC_ARRAY(entryPtr->list0.list, (1 << MAX_TEMPORAL_LAYERS)); 21 | EB_MALLOC_ARRAY(entryPtr->list1.list, (1 << MAX_TEMPORAL_LAYERS)); 22 | 23 | return EB_ErrorNone; 24 | } 25 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureDecisionQueue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbPictureDecisionQueue_h 7 | #define EbPictureDecisionQueue_h 8 | 9 | #include "EbSei.h" 10 | #include "EbDefinitions.h" 11 | #include "EbSystemResourceManager.h" 12 | #include "EbPredictionStructure.h" 13 | #include"EbPictureControlSet.h" 14 | #include "EbObject.h" 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /************************************************ 20 | * PA Reference Queue Entry 21 | ************************************************/ 22 | typedef struct PaReferenceQueueEntry_s { 23 | EbDctor dctor; 24 | EbObjectWrapper_t *inputObjectPtr; 25 | EB_U64 pictureNumber; 26 | EB_U32 dependentCount; 27 | EB_U32 referenceEntryIndex; 28 | ReferenceList_t *list0Ptr; 29 | ReferenceList_t *list1Ptr; 30 | EB_U32 depList0Count; 31 | EB_U32 depList1Count; 32 | DependentList_t list0; 33 | DependentList_t list1; 34 | 35 | PictureParentControlSet_t *pPcsPtr; 36 | } PaReferenceQueueEntry_t; 37 | 38 | extern EB_ERRORTYPE PaReferenceQueueEntryCtor( 39 | PaReferenceQueueEntry_t *entryPtr); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | #endif // EbPictureDecisionQueue_h -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureDecisionReorderQueue.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | #include "EbPictureDecisionReorderQueue.h" 8 | 9 | EB_ERRORTYPE PictureDecisionReorderEntryCtor( 10 | PictureDecisionReorderEntry_t *entryPtr, 11 | EB_U32 pictureNumber) 12 | { 13 | entryPtr->pictureNumber = pictureNumber; 14 | 15 | return EB_ErrorNone; 16 | } 17 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureDecisionReorderQueue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | #include "EbObject.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /************************************************ 17 | * Packetization Reorder Queue Entry 18 | ************************************************/ 19 | typedef struct PictureDecisionReorderEntry_s { 20 | EbDctor dctor; 21 | EB_U64 pictureNumber; 22 | EbObjectWrapper_t *parentPcsWrapperPtr; 23 | } PictureDecisionReorderEntry_t; 24 | 25 | extern EB_ERRORTYPE PictureDecisionReorderEntryCtor( 26 | PictureDecisionReorderEntry_t *entryPtr, 27 | EB_U32 pictureNumber); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | #endif //EbPictureDecisionReorderQueue_h 33 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureDecisionResults.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | 8 | #include "EbPictureDecisionResults.h" 9 | 10 | EB_ERRORTYPE PictureDecisionResultCtor( 11 | PictureDecisionResults_t *objectPtr, 12 | EB_PTR objectInitDataPtr) 13 | { 14 | (void)objectPtr; 15 | (void)objectInitDataPtr; 16 | return EB_ErrorNone; 17 | } 18 | 19 | EB_ERRORTYPE PictureDecisionResultCreator( 20 | EB_PTR *objectDblPtr, 21 | EB_PTR objectInitDataPtr) 22 | { 23 | PictureDecisionResults_t* obj; 24 | 25 | *objectDblPtr = NULL; 26 | EB_NEW(obj, PictureDecisionResultCtor, objectInitDataPtr); 27 | *objectDblPtr = obj; 28 | 29 | return EB_ErrorNone; 30 | } 31 | 32 | 33 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureDecisionResults.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | #include "EbObject.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /************************************** 17 | * Process Results 18 | **************************************/ 19 | typedef struct PictureDecisionResults_s 20 | { 21 | EbDctor dctor; 22 | EbObjectWrapper_t *pictureControlSetWrapperPtr; 23 | EB_U32 segmentIndex; 24 | } PictureDecisionResults_t; 25 | 26 | typedef struct PictureDecisionResultInitData_s 27 | { 28 | int junk; 29 | } PictureDecisionResultInitData_t; 30 | 31 | /************************************** 32 | * Extern Function Declarations 33 | **************************************/ 34 | extern EB_ERRORTYPE PictureDecisionResultCreator( 35 | EB_PTR *objectDblPtr, 36 | EB_PTR objectInitDataPtr); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | #endif //EbPictureDecisionResults_h 42 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureDemuxResults.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | #include "EbPictureDemuxResults.h" 8 | 9 | EB_ERRORTYPE PictureResultsCtor( 10 | PictureDemuxResults_t *objectPtr, 11 | EB_PTR objectInitDataPtr) 12 | { 13 | objectPtr->pictureType = EB_PIC_INVALID; 14 | (void) objectInitDataPtr; 15 | return EB_ErrorNone; 16 | } 17 | 18 | EB_ERRORTYPE PictureResultsCreator( 19 | EB_PTR *objectDblPtr, 20 | EB_PTR objectInitDataPtr) 21 | { 22 | PictureDemuxResults_t* obj; 23 | 24 | *objectDblPtr = NULL; 25 | EB_NEW(obj, PictureResultsCtor, objectInitDataPtr); 26 | *objectDblPtr = obj; 27 | 28 | return EB_ErrorNone; 29 | } 30 | 31 | 32 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureDemuxResults.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | #include "EbObject.h" 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | /************************************** 16 | * Enums 17 | **************************************/ 18 | typedef enum EB_PIC_TYPE { 19 | EB_PIC_INVALID = 0, 20 | EB_PIC_INPUT = 1, 21 | EB_PIC_REFERENCE = 2, 22 | EB_PIC_FEEDBACK = 3 23 | } EB_PIC_TYPE; 24 | 25 | /************************************** 26 | * Picture Demux Results 27 | **************************************/ 28 | typedef struct PictureDemuxResults_s 29 | { 30 | EbDctor dctor; 31 | EB_PIC_TYPE pictureType; 32 | 33 | // Only valid for input pictures 34 | EbObjectWrapper_t *pictureControlSetWrapperPtr; 35 | 36 | // Only valid for reference pictures 37 | EbObjectWrapper_t *referencePictureWrapperPtr; 38 | EbObjectWrapper_t *sequenceControlSetWrapperPtr; 39 | EB_U64 pictureNumber; 40 | 41 | } PictureDemuxResults_t; 42 | 43 | typedef struct PictureResultInitData_s 44 | { 45 | int junk; 46 | } PictureResultInitData_t; 47 | 48 | /************************************** 49 | * Extern Function Declarations 50 | **************************************/ 51 | extern EB_ERRORTYPE PictureResultsCreator( 52 | EB_PTR *objectDblPtr, 53 | EB_PTR objectInitDataPtr); 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | #endif //EbPictureResults_h 59 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureManagerProcess.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | #include "EbObject.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | /*************************************** 16 | * Context 17 | ***************************************/ 18 | typedef struct PictureManagerContext_s 19 | { 20 | EbDctor dctor; 21 | EbFifo_t *pictureInputFifoPtr; 22 | EbFifo_t *pictureManagerOutputFifoPtr; 23 | EbFifo_t **pictureControlSetFifoPtrArray; 24 | 25 | } PictureManagerContext_t; 26 | 27 | /*************************************** 28 | * Extern Function Declaration 29 | ***************************************/ 30 | extern EB_ERRORTYPE PictureManagerContextCtor( 31 | PictureManagerContext_t *contextPtr, 32 | EbFifo_t *pictureInputFifoPtr, 33 | EbFifo_t *pictureManagerOutputFifoPtr, 34 | EbFifo_t **pictureControlSetFifoPtrArray); 35 | 36 | 37 | 38 | extern void* PictureManagerKernel(void *inputPtr); 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | #endif // EbPictureManager_h -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureManagerQueue.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | #include "EbPictureManagerQueue.h" 8 | 9 | EB_ERRORTYPE InputQueueEntryCtor( 10 | InputQueueEntry_t *entryPtr) 11 | { 12 | (void)entryPtr; 13 | return EB_ErrorNone; 14 | } 15 | 16 | static void ReferenceQueueEntryDctor(EB_PTR p) 17 | { 18 | ReferenceQueueEntry_t* obj = (ReferenceQueueEntry_t*)p; 19 | EB_FREE_ARRAY(obj->list0.list); 20 | EB_FREE_ARRAY(obj->list1.list); 21 | } 22 | 23 | EB_ERRORTYPE ReferenceQueueEntryCtor( 24 | ReferenceQueueEntry_t *entryPtr) 25 | { 26 | entryPtr->dctor = ReferenceQueueEntryDctor; 27 | entryPtr->pictureNumber = ~0u; 28 | EB_MALLOC_ARRAY(entryPtr->list0.list, (1 << MAX_TEMPORAL_LAYERS)); 29 | EB_MALLOC_ARRAY(entryPtr->list1.list, (1 << MAX_TEMPORAL_LAYERS)); 30 | 31 | return EB_ErrorNone; 32 | } 33 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureManagerQueue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 "EbObject.h" 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | /************************************************ 19 | * Input Queue Entry 20 | ************************************************/ 21 | struct ReferenceQueueEntry_s; // empty struct definition 22 | 23 | typedef struct InputQueueEntry_s { 24 | EbDctor dctor; 25 | EbObjectWrapper_t *inputObjectPtr; 26 | EB_U32 dependentCount; 27 | EB_U32 referenceEntryIndex; 28 | ReferenceList_t *list0Ptr; 29 | ReferenceList_t *list1Ptr; 30 | EB_U32 useCount; 31 | EB_BOOL memoryMgmtLoopDone; 32 | EB_BOOL rateControlLoopDone; 33 | EB_BOOL encodingHasBegun; 34 | 35 | } InputQueueEntry_t; 36 | 37 | /************************************************ 38 | * Reference Queue Entry 39 | ************************************************/ 40 | typedef struct ReferenceQueueEntry_s { 41 | EbDctor dctor; 42 | EB_U64 pictureNumber; 43 | EB_U64 decodeOrder; 44 | EbObjectWrapper_t *referenceObjectPtr; 45 | EB_U32 dependentCount; 46 | EB_BOOL releaseEnable; 47 | EB_BOOL referenceAvailable; 48 | EB_U32 depList0Count; 49 | EB_U32 depList1Count; 50 | DependentList_t list0; 51 | DependentList_t list1; 52 | EB_BOOL isUsedAsReferenceFlag; 53 | 54 | EB_U64 rcGroupIndex; 55 | EB_BOOL feedbackArrived; 56 | 57 | } ReferenceQueueEntry_t; 58 | 59 | /************************************************ 60 | * Rate Control Input Queue Entry 61 | ************************************************/ 62 | 63 | typedef struct RcInputQueueEntry_s { 64 | EB_U64 pictureNumber; 65 | EbObjectWrapper_t *inputObjectPtr; 66 | 67 | EB_BOOL isPassed; 68 | EB_BOOL releaseEnabled; 69 | EB_U64 groupId; 70 | EB_U64 gopFirstPoc; 71 | EB_U32 gopIndex; 72 | 73 | 74 | } RcInputQueueEntry_t; 75 | 76 | /************************************************ 77 | * Rate Control FeedBack Queue Entry 78 | ************************************************/ 79 | typedef struct RcFeedbackQueueEntry_s { 80 | EB_U64 pictureNumber; 81 | EbObjectWrapper_t *feedbackObjectPtr; 82 | 83 | EB_BOOL isAvailable; 84 | EB_BOOL isUpdated; 85 | EB_BOOL releaseEnabled; 86 | EB_U64 groupId; 87 | EB_U64 gopFirstPoc; 88 | EB_U32 gopIndex; 89 | 90 | } RcFeedbackQueueEntry_t; 91 | 92 | extern EB_ERRORTYPE InputQueueEntryCtor( 93 | InputQueueEntry_t *entryPtr); 94 | 95 | extern EB_ERRORTYPE ReferenceQueueEntryCtor( 96 | ReferenceQueueEntry_t *entryPtr); 97 | 98 | 99 | #ifdef __cplusplus 100 | } 101 | #endif 102 | #endif // EbPictureManagerQueue_h -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureManagerReorderQueue.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | #include "EbPictureManagerReorderQueue.h" 8 | 9 | EB_ERRORTYPE PictureManagerReorderEntryCtor( 10 | PictureManagerReorderEntry_t *entryPtr, 11 | EB_U32 pictureNumber) 12 | { 13 | entryPtr->pictureNumber = pictureNumber; 14 | 15 | return EB_ErrorNone; 16 | } 17 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPictureManagerReorderQueue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | #include "EbObject.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /************************************************ 17 | * Packetization Reorder Queue Entry 18 | ************************************************/ 19 | typedef struct PictureManagerReorderEntry_s { 20 | EbDctor dctor; 21 | EB_U64 pictureNumber; 22 | EbObjectWrapper_t *parentPcsWrapperPtr; 23 | } PictureManagerReorderEntry_t; 24 | 25 | extern EB_ERRORTYPE PictureManagerReorderEntryCtor( 26 | PictureManagerReorderEntry_t *entryPtr, 27 | EB_U32 pictureNumber); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | #endif //EbPictureManagerReorderQueue_h 33 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbPredictionUnit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbPredictionUnit_h 7 | #define EbPredictionUnit_h 8 | 9 | #include "EbSyntaxElements.h" 10 | #include "EbDefinitions.h" 11 | #include "EbMotionVectorUnit.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | #pragma pack(push, 1) 16 | typedef struct PredictionUnit_s 17 | { 18 | Mv_t mv [MAX_NUM_OF_REF_PIC_LIST]; // 16-bytes 19 | Mvd_t mvd[MAX_NUM_OF_REF_PIC_LIST]; // 16-bytes 20 | unsigned mergeIndex : 5; 21 | unsigned mergeFlag : 1; 22 | 23 | unsigned interPredDirectionIndex : 2; 24 | unsigned intraLumaMode : 6; 25 | unsigned intraLumaLeftMode : 6; 26 | unsigned intraLumaTopMode : 6; 27 | 28 | } PredictionUnit_t; 29 | #pragma pack(pop) 30 | 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | #endif //EbPredictionUnit_h -------------------------------------------------------------------------------- /Source/Lib/Codec/EbRateControlResults.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | EB_ERRORTYPE RateControlResultsCtor( 12 | RateControlResults_t *objectPtr, 13 | EB_PTR objectInitDataPtr) 14 | { 15 | (void)objectPtr; 16 | (void)objectInitDataPtr; 17 | 18 | return EB_ErrorNone; 19 | } 20 | 21 | EB_ERRORTYPE RateControlResultsCreator( 22 | EB_PTR *objectDblPtr, 23 | EB_PTR objectInitDataPtr) 24 | { 25 | RateControlResults_t* obj; 26 | 27 | *objectDblPtr = NULL; 28 | EB_NEW(obj, RateControlResultsCtor, objectInitDataPtr); 29 | *objectDblPtr = obj; 30 | 31 | return EB_ErrorNone; 32 | } 33 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbRateControlResults.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | #include "EbObject.h" 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | /************************************** 17 | * Process Results 18 | **************************************/ 19 | typedef struct RateControlResults_s 20 | { 21 | EbDctor dctor; 22 | EbObjectWrapper_t *pictureControlSetWrapperPtr; 23 | } RateControlResults_t; 24 | 25 | typedef struct RateControlResultsInitData_s 26 | { 27 | int junk; 28 | } RateControlResultsInitData_t; 29 | 30 | /************************************** 31 | * Extern Function Declarations 32 | **************************************/ 33 | extern EB_ERRORTYPE RateControlResultsCreator( 34 | EB_PTR *objectDblPtr, 35 | EB_PTR objectInitDataPtr); 36 | 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | #endif // EbRateControlResults_h -------------------------------------------------------------------------------- /Source/Lib/Codec/EbRateControlTables.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 "EbUtility.h" 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | /************************************** 16 | * Rate Control Defines 17 | **************************************/ 18 | #define SAD_PRECISION_INTERVAL 4 19 | 20 | #define VAR_ROUND_INTERVAL 20 21 | #define NUMBER_OF_SAD_INTERVALS 128 // number of intervals in SAD tables 22 | 23 | #define NUMBER_OF_INTRA_SAD_INTERVALS NUMBER_OF_SAD_INTERVALS // number of intervals in intra Sad tables 24 | 25 | #define TOTAL_NUMBER_OF_INTERVALS (NUMBER_OF_SAD_INTERVALS + \ 26 | NUMBER_OF_INTRA_SAD_INTERVALS ) 27 | 28 | #define TOTAL_NUMBER_OF_REF_QP_VALUES 1 29 | 30 | #define TOTAL_NUMBER_OF_INITIAL_RC_TABLES_ENTRY (TOTAL_NUMBER_OF_REF_QP_VALUES * TOTAL_NUMBER_OF_INTERVALS) 31 | 32 | /************************************** 33 | * The EB_BitFraction is used to define the bit fraction numbers 34 | **************************************/ 35 | typedef EB_U16 EB_Bit_Number; 36 | 37 | /************************************** 38 | * Initial Rate Control Structure 39 | **************************************/ 40 | typedef struct InitialRateControlTables_s { 41 | EB_Bit_Number sadBitsArray [MAX_TEMPORAL_LAYERS][NUMBER_OF_SAD_INTERVALS]; 42 | EB_Bit_Number intraSadBitsArray [MAX_TEMPORAL_LAYERS][NUMBER_OF_INTRA_SAD_INTERVALS]; 43 | 44 | 45 | } RateControlTables_t; 46 | static const EB_U8 refQpListTable [] = 47 | 48 | { 0, 1, 2, 3, 4, 5, 6, 7, 49 | 8, 9, 10, 11, 12, 13, 14, 15, 50 | 16, 17, 18, 19, 20, 21, 22, 23, 51 | 24, 25, 26, 27, 28, 29, 30, 31, 52 | 32, 33, 34, 35, 36, 37, 38, 39, 53 | 40, 41, 42, 43, 44, 45, 46, 47, 54 | 48, 49, 50, 51}; 55 | 56 | /************************************** 57 | * Extern Function Declarations 58 | **************************************/ 59 | extern EB_ERRORTYPE RateControlTablesInit( 60 | RateControlTables_t *rateControlTablesArray 61 | ); 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | #endif //EbRateControlTables_h 67 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbRateControlTasks.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | EB_ERRORTYPE RateControlTasksCtor( 12 | RateControlTasks_t *objectPtr, 13 | EB_PTR objectInitDataPtr) 14 | { 15 | (void)objectPtr; 16 | (void)objectInitDataPtr; 17 | 18 | return EB_ErrorNone; 19 | } 20 | 21 | EB_ERRORTYPE RateControlTasksCreator( 22 | EB_PTR *objectDblPtr, 23 | EB_PTR objectInitDataPtr) 24 | { 25 | RateControlTasks_t* obj; 26 | 27 | *objectDblPtr = NULL; 28 | EB_NEW(obj, RateControlTasksCtor, objectInitDataPtr); 29 | *objectDblPtr = obj; 30 | 31 | return EB_ErrorNone; 32 | } 33 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbRateControlTasks.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | #include "EbObject.h" 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /************************************** 18 | * Tasks Types 19 | **************************************/ 20 | typedef enum RATE_CONTROL_TASKTYPES { 21 | RC_PICTURE_MANAGER_RESULT, 22 | RC_PACKETIZATION_FEEDBACK_RESULT, 23 | RC_ENTROPY_CODING_ROW_FEEDBACK_RESULT, 24 | RC_INVALID_TASK 25 | } RATE_CONTROL_TASKTYPES; 26 | 27 | /************************************** 28 | * Process Results 29 | **************************************/ 30 | typedef struct RateControlTasks_s 31 | { 32 | EbDctor dctor; 33 | RATE_CONTROL_TASKTYPES taskType; 34 | EbObjectWrapper_t *pictureControlSetWrapperPtr; 35 | EB_U32 segmentIndex; 36 | 37 | // Following are valid for RC_ENTROPY_CODING_ROW_FEEDBACK_RESULT only 38 | EB_U64 pictureNumber; 39 | EB_U16 tileIndex; 40 | EB_U32 rowNumber; 41 | EB_U32 bitCount; 42 | 43 | } RateControlTasks_t; 44 | 45 | typedef struct RateControlTasksInitData_s 46 | { 47 | int junk; 48 | } RateControlTasksInitData_t; 49 | 50 | /************************************** 51 | * Extern Function Declarations 52 | **************************************/ 53 | extern EB_ERRORTYPE RateControlTasksCreator( 54 | EB_PTR *objectDblPtr, 55 | EB_PTR objectInitDataPtr); 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | #endif // EbRateControlTasks_h 61 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbReferenceObject.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 "EbAdaptiveMotionVectorPrediction.h" 11 | #include "EbObject.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | typedef struct EbReferenceObject_s { 17 | EbDctor dctor; 18 | EbPictureBufferDesc_t *referencePicture; 19 | EbPictureBufferDesc_t *referencePicture16bit; 20 | EbPictureBufferDesc_t *refDenSrcPicture; 21 | 22 | TmvpUnit_t *tmvpMap; 23 | EB_BOOL tmvpEnableFlag; 24 | EB_U64 refPOC; 25 | 26 | EB_U8 qp; 27 | EB_PICTURE sliceType; 28 | 29 | EB_U8 intraCodedArea;//percentage of intra coded area 0-100% 30 | 31 | EB_U8 intraCodedAreaLCU[MAX_NUMBER_OF_TREEBLOCKS_PER_PICTURE];//percentage of intra coded area 0-100% 32 | EB_U32 nonMovingIndexArray[MAX_NUMBER_OF_TREEBLOCKS_PER_PICTURE];//array to hold non-moving blocks in reference frames 33 | EB_U32 picSampleValue[MAX_NUMBER_OF_REGIONS_IN_WIDTH][MAX_NUMBER_OF_REGIONS_IN_HEIGHT][3];// [Y U V]; 34 | 35 | EB_BOOL penalizeSkipflag; 36 | 37 | EB_U8 tmpLayerIdx; 38 | EB_BOOL isSceneChange; 39 | EB_U16 picAvgVariance; 40 | EB_U8 averageIntensity; 41 | 42 | } EbReferenceObject_t; 43 | 44 | typedef struct EbReferenceObjectDescInitData_s { 45 | EbPictureBufferDescInitData_t referencePictureDescInitData; 46 | } EbReferenceObjectDescInitData_t; 47 | 48 | typedef struct EbPaReferenceObject_s { 49 | EbDctor dctor; 50 | EbPictureBufferDesc_t *inputPaddedPicturePtr; 51 | EbPictureBufferDesc_t *quarterDecimatedPicturePtr; 52 | EbPictureBufferDesc_t *sixteenthDecimatedPicturePtr; 53 | EB_U16 variance[MAX_NUMBER_OF_TREEBLOCKS_PER_PICTURE]; 54 | EB_U8 yMean[MAX_NUMBER_OF_TREEBLOCKS_PER_PICTURE]; 55 | EB_PICTURE sliceType; 56 | 57 | EB_S32 dependentPicturesCount; //number of pic using this reference frame 58 | PictureParentControlSet_t *pPcsPtr; 59 | } EbPaReferenceObject_t; 60 | 61 | typedef struct EbPaReferenceObjectDescInitData_s { 62 | EbPictureBufferDescInitData_t referencePictureDescInitData; 63 | EbPictureBufferDescInitData_t quarterPictureDescInitData; 64 | EbPictureBufferDescInitData_t sixteenthPictureDescInitData; 65 | } EbPaReferenceObjectDescInitData_t; 66 | 67 | /************************************** 68 | * Extern Function Declarations 69 | **************************************/ 70 | extern EB_ERRORTYPE EbReferenceObjectCreator( 71 | EB_PTR *objectDblPtr, 72 | EB_PTR objectInitDataPtr); 73 | 74 | extern EB_ERRORTYPE EbPaReferenceObjectCreator( 75 | EB_PTR *objectDblPtr, 76 | EB_PTR objectInitDataPtr); 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | #endif //EbReferenceObject_h -------------------------------------------------------------------------------- /Source/Lib/Codec/EbResourceCoordinationProcess.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbResourceCoordination_h 7 | #define EbResourceCoordination_h 8 | 9 | #include "EbSystemResourceManager.h" 10 | #include "EbDefinitions.h" 11 | #include "EbObject.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | /*************************************** 16 | * Context 17 | ***************************************/ 18 | typedef struct ResourceCoordinationContext_s 19 | { 20 | EbDctor dctor; 21 | EbFifo_t *inputBufferFifoPtr; 22 | EbFifo_t *resourceCoordinationResultsOutputFifoPtr; 23 | EbFifo_t **pictureControlSetFifoPtrArray; 24 | EbSequenceControlSetInstance_t **sequenceControlSetInstanceArray; 25 | EbObjectWrapper_t **sequenceControlSetActiveArray; 26 | EbFifo_t *sequenceControlSetEmptyFifoPtr; 27 | EbCallback_t **appCallbackPtrArray; 28 | 29 | // Compute Segments 30 | EB_U32 *computeSegmentsTotalCountArray; 31 | EB_U32 encodeInstancesTotalCount; 32 | 33 | // Picture Number Array 34 | EB_U64 *pictureNumberArray; 35 | 36 | EB_U64 averageEncMod; 37 | EB_U8 prevEncMod; 38 | EB_S8 prevEncModeDelta; 39 | EB_U8 prevChangeCond; 40 | 41 | EB_S64 previousModeChangeBuffer; 42 | EB_S64 previousModeChangeFrameIn; 43 | EB_S64 previousBufferCheck1; 44 | EB_S64 previousFrameInCheck1; 45 | EB_S64 previousFrameInCheck2; 46 | EB_S64 previousFrameInCheck3; 47 | 48 | 49 | EB_U64 curSpeed; // speed x 1000 50 | EB_U64 prevsTimeSeconds; 51 | EB_U64 prevsTimeuSeconds; 52 | EB_S64 prevFrameOut; 53 | 54 | EB_U64 firstInPicArrivedTimeSeconds; 55 | EB_U64 firstInPicArrivedTimeuSeconds; 56 | EB_BOOL startFlag; 57 | 58 | } ResourceCoordinationContext_t; 59 | 60 | /*************************************** 61 | * Extern Function Declaration 62 | ***************************************/ 63 | extern EB_ERRORTYPE ResourceCoordinationContextCtor( 64 | ResourceCoordinationContext_t *contextPtr, 65 | EbFifo_t *inputBufferFifoPtr, 66 | EbFifo_t *resourceCoordinationResultsOutputFifoPtr, 67 | EbFifo_t **pictureControlSetFifoPtrArray, 68 | EbSequenceControlSetInstance_t **sequenceControlSetInstanceArray, 69 | EbFifo_t *sequenceControlSetEmptyFifoPtr, 70 | EbCallback_t **appCallbackPtrArray, 71 | EB_U32 *computeSegmentsTotalCountArray, 72 | EB_U32 encodeInstancesTotalCount); 73 | 74 | 75 | 76 | extern void* ResourceCoordinationKernel(void *inputPtr); 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | #endif // EbResourceCoordination_h -------------------------------------------------------------------------------- /Source/Lib/Codec/EbResourceCoordinationResults.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | 8 | #include "EbResourceCoordinationResults.h" 9 | 10 | 11 | EB_ERRORTYPE ResourceCoordinationResultCtor( 12 | ResourceCoordinationResults_t *objectPtr, 13 | EB_PTR objectInitDataPtr) 14 | { 15 | (void)objectPtr; 16 | (void)objectInitDataPtr; 17 | 18 | return EB_ErrorNone; 19 | } 20 | 21 | 22 | EB_ERRORTYPE ResourceCoordinationResultCreator( 23 | EB_PTR *objectDblPtr, 24 | EB_PTR objectInitDataPtr) 25 | { 26 | ResourceCoordinationResults_t* obj; 27 | 28 | *objectDblPtr = NULL; 29 | EB_NEW(obj, ResourceCoordinationResultCtor, objectInitDataPtr); 30 | *objectDblPtr = obj; 31 | 32 | return EB_ErrorNone; 33 | } 34 | 35 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbResourceCoordinationResults.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | #include "EbObject.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | /************************************** 16 | * Process Results 17 | **************************************/ 18 | typedef struct ResourceCoordinationResults_s 19 | { 20 | EbDctor dctor; 21 | EbObjectWrapper_t *pictureControlSetWrapperPtr; 22 | 23 | } ResourceCoordinationResults_t; 24 | 25 | typedef struct ResourceCoordinationResultInitData_s 26 | { 27 | int junk; 28 | } ResourceCoordinationResultInitData_t; 29 | 30 | /************************************** 31 | * Extern Function Declarations 32 | **************************************/ 33 | extern EB_ERRORTYPE ResourceCoordinationResultCreator( 34 | EB_PTR *objectDblPtr, 35 | EB_PTR objectInitDataPtr); 36 | 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | #endif //EbResourceCoordinationResults_h -------------------------------------------------------------------------------- /Source/Lib/Codec/EbSourceBasedOperationsProcess.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 "EbObject.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | typedef struct CuComplexityInfo_s 17 | { 18 | EB_U32 spatioTemporalWeight; 19 | EB_U32 currentTemporalComplexity; 20 | EB_U32 currentSpatialComplexity; 21 | EB_U64 spatioTemporalComplexity; 22 | EB_U32 currentMotionComplexity; 23 | EB_U32 currentspatioTemporalComplexity; 24 | EB_U32 spatialComplexity; 25 | EB_U32 temporalComplexity; 26 | EB_U8 complextityDecreaseFactor; 27 | } CuComplexityInfo_t; 28 | 29 | 30 | /************************************** 31 | * Context 32 | **************************************/ 33 | 34 | typedef struct SourceBasedOperationsContext_s 35 | { 36 | EbDctor dctor; 37 | EbFifo_t *initialrateControlResultsInputFifoPtr; 38 | EbFifo_t *pictureDemuxResultsOutputFifoPtr; 39 | 40 | // Delta QP Map 41 | EB_S8 minDeltaQP; 42 | EB_U8 maxDeltaQP; 43 | 44 | EB_S16 minDeltaQpWeight[3][4]; 45 | EB_S16 maxDeltaQpWeight[3][4]; 46 | 47 | 48 | 49 | // Skin 50 | EB_U8 grassPercentageInPicture; 51 | EB_U8 picturePercentageFaceSkinLcu; 52 | 53 | // local zz cost array 54 | EB_U32 pictureNumGrassLcu; 55 | 56 | EB_U32 highContrastNum; 57 | 58 | EB_BOOL highDist; 59 | EB_U32 countOfMovingLcus; 60 | EB_U32 countOfNonMovingLcus; 61 | EB_U64 yNonMovingMean; 62 | EB_U64 yMovingMean; 63 | EB_U32 toBeIntraCodedProbability; 64 | EB_U32 depth1BlockNum; 65 | EB_U8 *yMeanPtr; 66 | EB_U8 *crMeanPtr; 67 | EB_U8 *cbMeanPtr; 68 | 69 | } SourceBasedOperationsContext_t; 70 | 71 | /*************************************** 72 | * Extern Function Declaration 73 | ***************************************/ 74 | 75 | extern EB_ERRORTYPE SourceBasedOperationsContextCtor( 76 | SourceBasedOperationsContext_t *contextPtr, 77 | EbFifo_t *initialrateControlResultsInputFifoPtr, 78 | EbFifo_t *pictureDemuxResultsOutputFifoPtr); 79 | 80 | extern void* SourceBasedOperationsKernel(void *inputPtr); 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | #endif // EbSourceBasedOperations_h -------------------------------------------------------------------------------- /Source/Lib/Codec/EbSyntaxElements.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | NAL_REF_IDC_PRIORITY_LOWEST = 0, 13 | NAL_REF_IDC_PRIORITY_LOW, 14 | NAL_REF_IDC_PRIORITY_HIGH, 15 | NAL_REF_IDC_PRIORITY_HIGHEST 16 | } NalRefIdc; 17 | 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 | // SAO 67 | #define SE_SAO_LUMA_OFFSET_COUNT 4 68 | #define SE_SAO_CHROMA_OFFSET_COUNT 4 69 | #define CTB_SPLIT_FLAG_MAX_COUNT 4 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | #endif // EbSyntaxElements_h -------------------------------------------------------------------------------- /Source/Lib/Codec/EbTransQuantBuffers.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | 7 | #include "EbDefinitions.h" 8 | #include "EbTransQuantBuffers.h" 9 | #include "EbPictureBufferDesc.h" 10 | 11 | 12 | static void EbTransQuantBuffersDctor(EB_PTR p) 13 | { 14 | EbTransQuantBuffers_t* obj = (EbTransQuantBuffers_t*)p; 15 | EB_DELETE(obj->tuTransCoeff2Nx2NPtr); 16 | EB_DELETE(obj->tuTransCoeffNxNPtr); 17 | EB_DELETE(obj->tuTransCoeffN2xN2Ptr); 18 | EB_DELETE(obj->tuQuantCoeffNxNPtr); 19 | EB_DELETE(obj->tuQuantCoeffN2xN2Ptr); 20 | } 21 | 22 | EB_ERRORTYPE EbTransQuantBuffersCtor( 23 | EbTransQuantBuffers_t *transQuantBuffersPtr) 24 | { 25 | transQuantBuffersPtr->dctor = EbTransQuantBuffersDctor; 26 | 27 | EbPictureBufferDescInitData_t transCoeffInitArray; 28 | transCoeffInitArray.maxWidth = MAX_LCU_SIZE; 29 | transCoeffInitArray.maxHeight = MAX_LCU_SIZE; 30 | transCoeffInitArray.bitDepth = EB_16BIT; 31 | transCoeffInitArray.colorFormat = EB_YUV420; 32 | transCoeffInitArray.bufferEnableMask = PICTURE_BUFFER_DESC_FULL_MASK; 33 | transCoeffInitArray.leftPadding = 0; 34 | transCoeffInitArray.rightPadding = 0; 35 | transCoeffInitArray.topPadding = 0; 36 | transCoeffInitArray.botPadding = 0; 37 | transCoeffInitArray.splitMode = EB_FALSE; 38 | 39 | EB_NEW( 40 | transQuantBuffersPtr->tuTransCoeff2Nx2NPtr, 41 | EbPictureBufferDescCtor, 42 | (EB_PTR)&transCoeffInitArray); 43 | 44 | EB_NEW( 45 | transQuantBuffersPtr->tuTransCoeffNxNPtr, 46 | EbPictureBufferDescCtor, 47 | (EB_PTR)&transCoeffInitArray); 48 | 49 | EB_NEW( 50 | transQuantBuffersPtr->tuTransCoeffN2xN2Ptr, 51 | EbPictureBufferDescCtor, 52 | (EB_PTR)&transCoeffInitArray); 53 | 54 | EB_NEW( 55 | transQuantBuffersPtr->tuQuantCoeffNxNPtr, 56 | EbPictureBufferDescCtor, 57 | (EB_PTR)&transCoeffInitArray); 58 | 59 | EB_NEW( 60 | transQuantBuffersPtr->tuQuantCoeffN2xN2Ptr, 61 | EbPictureBufferDescCtor, 62 | (EB_PTR)&transCoeffInitArray); 63 | 64 | return EB_ErrorNone; 65 | } 66 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbTransQuantBuffers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 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 | #include "EbObject.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | typedef struct EbTransQuantBuffers_s 16 | { 17 | EbDctor dctor; 18 | EbPictureBufferDesc_t *tuTransCoeff2Nx2NPtr; 19 | EbPictureBufferDesc_t *tuTransCoeffNxNPtr; 20 | EbPictureBufferDesc_t *tuTransCoeffN2xN2Ptr; 21 | EbPictureBufferDesc_t *tuQuantCoeffNxNPtr; 22 | EbPictureBufferDesc_t *tuQuantCoeffN2xN2Ptr; 23 | 24 | } EbTransQuantBuffers_t; 25 | 26 | 27 | extern EB_ERRORTYPE EbTransQuantBuffersCtor( 28 | EbTransQuantBuffers_t *transQuantBuffersPtr); 29 | 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | #endif // EbTransQuantBuffers_h -------------------------------------------------------------------------------- /Source/Lib/Codec/EbTransformUnit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2018 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbTransformUnit_h 7 | #define EbTransformUnit_h 8 | 9 | #include "EbDefinitions.h" 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | #define TRANSFORM_UNIT_MAX_COUNT 5 14 | #define TRANSFORM_UNIT_2Nx2N_AREA 16 15 | #define TRANSFORM_UNIT_NxN_AREA 4 16 | 17 | #pragma pack(push, 1) 18 | typedef struct TransformUnit_s { 19 | unsigned tuIndex : 5; 20 | unsigned lumaCbfContext : 1; 21 | unsigned splitFlag : 1; 22 | unsigned chromaCbfContext : 2; 23 | unsigned cbCbf : 1; 24 | unsigned crCbf : 1; 25 | unsigned lumaCbf : 1; 26 | unsigned transCoeffShapeLuma : 2; 27 | unsigned transCoeffShapeChroma : 2; 28 | unsigned transCoeffShapeChroma2 : 2; 29 | 30 | unsigned cbCbf2 : 1; 31 | unsigned crCbf2 : 1; 32 | EB_U16 nzCoefCount[3]; 33 | EB_BOOL isOnlyDc[3]; 34 | 35 | EB_U16 nzCoefCount2[2]; 36 | EB_BOOL isOnlyDc2[3]; 37 | } TransformUnit_t; 38 | #pragma pack(pop) 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | #endif // EbTransformUnit_h 43 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbUnPackProcess.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2020 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #include 7 | #include "EbDefinitions.h" 8 | #include "EbUnPackProcess.h" 9 | 10 | /****************************************************** 11 | * Enc Dec Context Constructor 12 | ******************************************************/ 13 | EB_ERRORTYPE UnPackContextCtor( 14 | UnPackContext_t *contextPtr, 15 | EbFifo_t *copyFrameInputFifoPtr, 16 | EbFifo_t *copyFrameOutPutFifoPtr, 17 | EbFifo_t *unPackInputFifoPtr, 18 | EbFifo_t *unPackOutPutFifoPtr, 19 | EB_U8 nbLumaThreads, 20 | EB_U8 nbChromaThreads) 21 | { 22 | contextPtr->copyFrameInputFifoPtr = copyFrameInputFifoPtr; 23 | contextPtr->copyFrameOutputFifoPtr = copyFrameOutPutFifoPtr; 24 | contextPtr->unPackInputFifoPtr = unPackInputFifoPtr; 25 | contextPtr->unPackOutPutFifoPtr = unPackOutPutFifoPtr; 26 | contextPtr->nbLumaThreads = nbLumaThreads; 27 | contextPtr->nbChromaThreads = nbChromaThreads; 28 | 29 | return EB_ErrorNone; 30 | } 31 | 32 | EB_ERRORTYPE UnPackCreator( 33 | EB_PTR *objectDblPtr, 34 | EB_PTR objectInitDataPtr) 35 | { 36 | EBUnPack2DType_t* obj; 37 | 38 | *objectDblPtr = NULL; 39 | EB_CALLOC(obj, 1, sizeof(EBUnPack2DType_t)); 40 | *objectDblPtr = obj; 41 | 42 | return EB_ErrorNone; 43 | } 44 | 45 | void UnPackDestoryer(EB_PTR p) 46 | { 47 | EBUnPack2DType_t *obj = (EBUnPack2DType_t*)p; 48 | EB_FREE(obj); 49 | } 50 | -------------------------------------------------------------------------------- /Source/Lib/Codec/EbUnPackProcess.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2020 Intel Corporation 3 | * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 | */ 5 | 6 | #ifndef EbUnPackProcess_h 7 | #define EbUnPackProcess_h 8 | 9 | #include "EbSystemResourceManager.h" 10 | #include "EbErrorCodes.h" 11 | #include "EbDefinitions.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | typedef struct EBUnPack2DType_s 17 | { 18 | EB_U16 *in16BitBuffer; 19 | EB_U32 inStride; 20 | EB_U8 *out8BitBuffer; 21 | EB_U32 out8Stride; 22 | EB_U8 *outnBitBuffer; 23 | EB_U32 outnStride; 24 | EB_U32 width; 25 | EB_U32 height; 26 | }EBUnPack2DType_t; 27 | 28 | /*************************************** 29 | * Context 30 | ***************************************/ 31 | typedef struct UnPackContext_s 32 | { 33 | EbDctor dctor; 34 | EbFifo_t *copyFrameInputFifoPtr; 35 | EbFifo_t *copyFrameOutputFifoPtr; 36 | EbFifo_t *unPackInputFifoPtr; 37 | EbFifo_t *unPackOutPutFifoPtr; 38 | EB_U8 nbLumaThreads; 39 | EB_U8 nbChromaThreads; 40 | }UnPackContext_t; 41 | 42 | /*************************************** 43 | * Extern Function Declaration 44 | ***************************************/ 45 | extern EB_ERRORTYPE UnPackContextCtor( 46 | UnPackContext_t *contextPtr, 47 | EbFifo_t *copyFrameInputFifoPtr, 48 | EbFifo_t *copyFrameOutPutFifoPtr, 49 | EbFifo_t *unPackInputFifoPtr, 50 | EbFifo_t *unPackOutPutFifoPtr, 51 | EB_U8 nbLumaThreads, 52 | EB_U8 nbChromaThreads); 53 | 54 | extern EB_ERRORTYPE UnPackCreator( 55 | EB_PTR *objectDblPtr, 56 | EB_PTR objectInitDataPtr); 57 | 58 | extern void UnPackDestoryer(EB_PTR p); 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | #endif // EbUnPackProcess.h -------------------------------------------------------------------------------- /Source/Lib/pkg-config.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@/svt-hevc 3 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 4 | 5 | Name: SvtHevcEnc 6 | Description: SVT (Scalable Video Technology) for HEVC encoder library 7 | Version: @SVT_HEVC_VERSION_MAJOR@.@SVT_HEVC_VERSION_MINOR@.@SVT_HEVC_VERSION_PATCHLEVEL@ 8 | Libs: -L${libdir} -lSvtHevcEnc @LIBS@ 9 | Cflags: -I${includedir} 10 | -------------------------------------------------------------------------------- /ffmpeg_plugin/README.md: -------------------------------------------------------------------------------- 1 | # SVT-HEVC ffmpeg plugin installation 2 | 3 | These instructions build a version of ffmpeg with the SVT-HEVC plugin. The steps differ depending 4 | on whether using a Linux or Windows build machine. 5 | 6 | ## For Linux: 7 | 8 | 1\. Build and install SVT-HEVC 9 | 10 | ``` bash 11 | git clone https://github.com/OpenVisualCloud/SVT-HEVC 12 | cd SVT-HEVC/Build/linux 13 | ./build.sh release 14 | cd Release 15 | make install 16 | export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib 17 | export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig 18 | ``` 19 | ## For Windows: 20 | 0\. Setup environment 21 | ``` bash 22 | Install Visual Studio 2017 23 | Install msys2-x86_64 to C:\msys64 following instructions found on http://www.msys2.org/ 24 | Run "C:\msys64\mingw64.exe" to open a msys2 mingw-w64 shell. All subsequent build steps should be done in this shell. 25 | Execute "pacman -S --needed make mingw-w64-x86_64-cmake mingw-w64-x86_64-gcc mingw-w64-x86_64-yasm mingw-w64-x86_64-SDL2 perl diffutils pkg-config git tar" in the console 26 | ``` 27 | 1\. Build and install SVT-HEVC 28 | ``` bash 29 | git clone https://github.com/OpenVisualCloud/SVT-HEVC 30 | ``` 31 | Option 1: use msvc compiler 32 | ``` bash 33 | cd SVT-HEVC/Build/windows 34 | ./build.bat 2017 release 35 | cmake --install . --config Release 36 | ``` 37 | Option 2: use mingw-w64 gcc 38 | ``` bash 39 | mkdir release 40 | cd release 41 | cmake .. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=C:/svt-encoders -DBUILD_SHARED_LIBS=off 42 | make -j $(nproc) install 43 | cd ../.. 44 | ``` 45 | The location c:/svt-encoders is used to store a package configuration for the SvtHevcEnc library. 46 | ``` bash 47 | export PKG_CONFIG_PATH=/c/svt-encoders/lib/pkgconfig:$PKG_CONFIG_PATH 48 | ``` 49 | This instruction will verify that the SvtHevcEnc library can be found when building ffmpeg 50 | ``` bash 51 | pkg-config --print-errors SvtHevcEnc 52 | export PATH=$PATH:/c/svt-encoders/lib/ 53 | ``` 54 | ## For Both: 55 | 2\. Install FFmpeg with SVT-HEVC FFmpeg plugin 56 | ``` bash 57 | git clone https://github.com/FFmpeg/FFmpeg ffmpeg 58 | cd ffmpeg 59 | 60 | # The patch n4.4-0001-lavc-svt_hevc-add-libsvt-hevc-encoder-wrapper.patch has been validated on n4.2/n4.3/n4.4 release tag 61 | git checkout n4.2 62 | or 63 | git checkout n4.3 64 | or 65 | git checkout n4.4 66 | 67 | git am ../SVT-HEVC/ffmpeg_plugin/n4.4-0001-lavc-svt_hevc-add-libsvt-hevc-encoder-wrapper.patch 68 | 69 | # If the above patch failed when you work on master branch or newer version of FFmpeg, 70 | # please try the patch for master branch: master-0001-lavc-svt_hevc-add-libsvt-hevc-encoder-wrapper.patch 71 | git am ../SVT-HEVC/ffmpeg_plugin/master-0001-lavc-svt_hevc-add-libsvt-hevc-encoder-wrapper.patch 72 | 73 | ./configure --enable-libsvthevc 74 | make -j $(nproc) 75 | ``` 76 | 3\. Verify that ffmpeg can encode media files using the SVT-HEVC plug-in 77 | ``` bash 78 | ./ffmpeg -i input.mp4 -c:v libsvt_hevc -rc 1 -b:v 10M -tune 0 -preset 9 -y test.265 79 | ./ffmpeg -i input.mp4 -c:v libsvt_hevc -vframes 1000 -y test.mp4 80 | ``` 81 | -------------------------------------------------------------------------------- /gstreamer-plugin/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | if(NOT CMAKE_BUILD_TYPE) 3 | set(CMAKE_BUILD_TYPE Release) 4 | endif() 5 | project(gst-svt-hevc C) 6 | 7 | include(CheckCCompilerFlag) 8 | 9 | find_package(PkgConfig REQUIRED) 10 | pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0>=1.8) 11 | pkg_check_modules(GSTREAMER_BASE REQUIRED gstreamer-base-1.0>=1.8) 12 | pkg_check_modules(GSTREAMER_VIDEO REQUIRED gstreamer-video-1.0>=1.8) 13 | pkg_check_modules(GSTREAMER_PBUTILS REQUIRED gstreamer-pbutils-1.0>=1.8) 14 | pkg_check_modules(SVT_HEVC REQUIRED SvtHevcEnc>=1.3) 15 | include_directories(${GSTREAMER_INCLUDE_DIRS} 16 | ${GSTREAMER_BASE_INCLUDE_DIRS} 17 | ${GSTREAMER_VIDEO_INCLUDE_DIRS} 18 | ${GSTREAMER_PBUTILS_INCLUDE_DIRS} 19 | ${SVT_HEVC_INCLUDE_DIRS}) 20 | 21 | set(flags_to_test 22 | -Wextra 23 | -Wformat 24 | -Wformat-security 25 | -fstack-protector-strong 26 | -fPIE 27 | -fPIC 28 | -flto 29 | -D_FORTIFY_SOURCE=2) 30 | if(NOT MSVC) 31 | list(INSERT flags_to_test 0 -Wall) 32 | else() 33 | list(APPEND flags_to_test /MP) 34 | endif() 35 | set(release_flags_to_test 36 | -O2 37 | -O3) 38 | set(debug_flags_to_test 39 | -g 40 | -O0 41 | -Og) 42 | 43 | foreach(flag ${flags_to_test};${release_flags_to_test};${debug_flags_to_test}) 44 | string(REGEX REPLACE "[^A-Za-z0-9]" "_" flag_var "${flag}") 45 | set(test_c_flag "C_FLAG${flag_var}") 46 | check_c_compiler_flag(${flag} "${test_c_flag}") 47 | list(FIND release_flags_to_test ${flag} r_flag) 48 | list(FIND debug_flags_to_test ${flag} d_flag) 49 | if(${test_c_flag}) 50 | if(NOT r_flag EQUAL -1) 51 | set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${flag}") 52 | elseif(NOT d_flag EQUAL -1) 53 | set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${flag}") 54 | else() 55 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}") 56 | endif() 57 | endif() 58 | endforeach() 59 | 60 | if(UNIX AND NOT APPLE) 61 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z noexecstack -z relro -z now -pie") 62 | endif() 63 | 64 | add_library(gstsvthevcenc SHARED gstsvthevcenc.c) 65 | target_link_libraries(gstsvthevcenc 66 | ${GSTREAMER_LIBRARIES} 67 | ${GSTREAMER_BASE_LIBRARIES} 68 | ${GSTREAMER_VIDEO_LIBRARIES} 69 | ${GSTREAMER_PBUTILS_LIBRARIES} 70 | ${SVT_HEVC_LIBRARIES}) 71 | 72 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 73 | set(CMAKE_INSTALL_PREFIX "${GSTREAMER_LIBDIR}") 74 | message("Install to: " ${GSTREAMER_LIBDIR}) 75 | endif() 76 | 77 | install(TARGETS gstsvthevcenc 78 | LIBRARY DESTINATION gstreamer-1.0) 79 | 80 | message("Build: " ${CMAKE_BUILD_TYPE}) 81 | -------------------------------------------------------------------------------- /gstreamer-plugin/README.md: -------------------------------------------------------------------------------- 1 | # GStreamer-SVT-HEVC 2 | ## Overview 3 | This plugin provides the svthevcenc element to GStreamer in order to use the Scalable Video Technology for HEVC Encoder ([SVT-HEVC](https://github.com/intel/SVT-HEVC)). 4 | 5 | ## Requirements 6 | * GStreamer 1.8 or later 7 | * Scalable Video Technology for HEVC Encoder ([SVT-HEVC](https://github.com/intel/SVT-HEVC)) 1.3.0 or later 8 | * SvtHevcEnc.dll or libSvtHevcEnc.so has to be in the PATH or next to the plugin's DLL/.so. 9 | * Windows or Linux operating system 10 | * A 64-bit CPU with AVX2 support 11 | 12 | ## Usage 13 | Make sure that the SvtHevcEnc library is in a path the OS looks for when loading dynamic libraries. If using default install locations, this means for example: 14 | 15 | export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH # Linux 16 | set PATH=C:\svt-encoders\lib;%PATH% # Windows 17 | 18 | Then a sample GStreamer pipeline is: 19 | 20 | gst-launch-1.0 -e videotestsrc ! video/x-raw ! svthevcenc ! mpegtsmux ! filesink location=out.ts 21 | 22 | If you're not familiar with GStreamer, gst-launch-1.0 is part of GStreamer tools, mpegtsmux is part of GStreamer Bad plugins, and the `-e` option allows CTRL+C to translate to an EOS (end of stream) signal on the pipeline. 23 | 24 | ## Compiling and Installing 25 | ### Build Dependencies 26 | * GStreamer and GStreamer-plugins-base dev 1.8 or later 27 | * on Debian/Ubuntu: `apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev` 28 | * on Windows: [gstreamer-1.0-devel-x86_64-*.msi](https://gstreamer.freedesktop.org/data/pkg/windows/) 29 | * Scalable Video Technology for HEVC Encoder ([SVT-HEVC](https://github.com/intel/SVT-HEVC)) 1.3.0 or later 30 | * meson 0.29 or later 31 | * install python3 and run `pip3 install meson` 32 | * pkg-config 33 | * on Debian/Ubuntu: `apt-get install pkg-config` 34 | * on Windows, we recommend [pkgconfiglite](https://sourceforge.net/projects/pkgconfiglite/) 35 | * ninja 36 | * on Windows (ninja is optional. Review instructions on https://github.com/GStreamer/gst-build#windows-prerequisites-setup) 37 | * on Debian/Ubuntu: 38 | * install python3 and run `pip3 install ninja` 39 | * apt install ninja-build 40 | 41 | This plugin uses `meson` build tools and the dependency on SVT-HEVC library is set-up using `pkg-config`. 42 | 43 | ### Linux specific instructions 44 | Make sure first that SVT-HEVC library is installed and can be found using pkg-config. You can do that using CMake: 45 | 46 | cmake -P SVT-HEVC/Build/linux/Release/cmake_install.cmake 47 | 48 | Then you can compile and install the plugin the following way: 49 | 50 | meson -Dprefix=/usr build && ninja -C build && sudo ninja -C build install 51 | 52 | ### Windows specific instructions 53 | Make sure first that SVT-HEVC library is installed and can be found using pkg-config. You can do that using CMake: 54 | 55 | cmake -P SVT-HEVC\Build\Windows\cmake_install.cmake 56 | 57 | The following commands should be run from a Visual Studio command prompt or another build environment like MinGW, not Windows built-in command prompt. 58 | 59 | Specify the path to pkgconfig configuration files for GStreamer and SVT-HEVC, and installation prefix to _%GSTREAMER_1_0_ROOT_X86_64%_: 60 | 61 | set PKG_CONFIG_PATH=%GSTREAMER_1_0_ROOT_X86_64%lib\pkgconfig;C:\svt-encoders\lib\pkgconfig 62 | 63 | Then the plugin can be compiled and installed using Ninja: 64 | 65 | meson -Dprefix=%GSTREAMER_1_0_ROOT_X86_64% build && ninja -C build && ninja -C build install 66 | 67 | Or made available as a Visual Studio project: 68 | 69 | meson -Dprefix=%GSTREAMER_1_0_ROOT_X86_64% build --backend=vs2017 70 | 71 | ### Verifying installation 72 | 73 | You can verify that the svthevcenc GStreamer plugin is properly built and installed by running: 74 | 75 | ``` 76 | gst-inspect-1.0 svthevcenc 77 | ``` 78 | 79 | Inspect the output for usage instructions. 80 | -------------------------------------------------------------------------------- /gstreamer-plugin/gstsvthevcenc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2019 Intel Corporation 3 | * Authors: Xavier Hallade Jun Tian 4 | * SPDX - License - Identifier: LGPL-2.1-or-later 5 | */ 6 | 7 | #ifndef _GST_SVTHEVCENC_H_ 8 | #define _GST_SVTHEVCENC_H_ 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | G_BEGIN_DECLS 16 | #define GST_TYPE_SVTHEVCENC \ 17 | (gst_svthevcenc_get_type()) 18 | #define GST_SVTHEVCENC(obj) \ 19 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SVTHEVCENC,GstSvtHevcEnc)) 20 | #define GST_SVTHEVCENC_CLASS(klass) \ 21 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SVTHEVCENC,GstSvtHevcEncClass)) 22 | #define GST_IS_SVTHEVCENC(obj) \ 23 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SVTHEVCENC)) 24 | #define GST_IS_SVTHEVCENC_CLASS(obj) \ 25 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SVTHEVCENC)) 26 | 27 | typedef enum 28 | { 29 | GST_SVTHEVC_ENC_B_PYRAMID_FLAT, 30 | GST_SVTHEVC_ENC_B_PYRAMID_2LEVEL_HIERARCHY, 31 | GST_SVTHEVC_ENC_B_PYRAMID_3LEVEL_HIERARCHY, 32 | GST_SVTHEVC_ENC_B_PYRAMID_4LEVEL_HIERARCHY, 33 | } GstSvtHevcEncBPyramid; 34 | 35 | typedef enum 36 | { 37 | GST_SVTHEVC_ENC_BASE_LAYER_MODE_BFRAME, 38 | GST_SVTHEVC_ENC_BASE_LAYER_MODE_PFRAME, 39 | } GstSvtHevcEncBaseLayerMode; 40 | 41 | typedef enum 42 | { 43 | GST_SVTHEVC_ENC_RC_CQP, 44 | GST_SVTHEVC_ENC_RC_VBR, 45 | } GstSvtHevcEncRC; 46 | 47 | typedef enum 48 | { 49 | GST_SVTHEVC_ENC_TUNE_SQ, 50 | GST_SVTHEVC_ENC_TUNE_OQ, 51 | GST_SVTHEVC_ENC_TUNE_VMAF, 52 | } GstSvtHevcEncTune; 53 | 54 | typedef enum 55 | { 56 | GST_SVTHEVC_ENC_PRED_STRUCT_LOW_DELAY_P, 57 | GST_SVTHEVC_ENC_PRED_STRUCT_LOW_DELAY_B, 58 | GST_SVTHEVC_ENC_PRED_STRUCT_RANDOM_ACCESS, 59 | } GstSvtHevcEncPredStruct; 60 | 61 | typedef struct _GstSvtHevcEnc 62 | { 63 | GstVideoEncoder video_encoder; 64 | 65 | /* SVT-HEVC Encoder Handle */ 66 | EB_COMPONENTTYPE *svt_encoder; 67 | 68 | /* GStreamer Codec state */ 69 | GstVideoCodecState *state; 70 | 71 | /* GStreamer properties */ 72 | gboolean enable_open_gop; 73 | guint config_interval; 74 | 75 | /* SVT-HEVC configuration */ 76 | EB_H265_ENC_CONFIGURATION *svt_config; 77 | 78 | EB_BUFFERHEADERTYPE *input_buf; 79 | 80 | long long int frame_count; 81 | int dts_offset; 82 | const gchar *svt_version; 83 | gboolean inited; 84 | } GstSvtHevcEnc; 85 | 86 | typedef struct _GstSvtHevcEncClass 87 | { 88 | GstVideoEncoderClass video_encoder_class; 89 | } GstSvtHevcEncClass; 90 | 91 | GType gst_svthevcenc_get_type (void); 92 | 93 | G_END_DECLS 94 | #endif 95 | -------------------------------------------------------------------------------- /gstreamer-plugin/meson.build: -------------------------------------------------------------------------------- 1 | # standalone plugin meson configuration 2 | project('gst-svt-hevc', 'c', 3 | version : '0.9.5', 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 | gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req, 16 | fallback : ['gst-plugins-base', 'pbutils_dep']) 17 | plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir')) 18 | 19 | # common meson configuration 20 | svthevcenc_dep = dependency('SvtHevcEnc') 21 | 22 | cc = meson.get_compiler('c') 23 | cc_flags = [ 24 | '-O2', 25 | '-D_FORTIFY_SOURCE=2', 26 | '-Wformat', 27 | '-Wformat-security', 28 | '-fPIE', 29 | '-fPIC', 30 | '-fstack-protector-strong', 31 | ] 32 | foreach flag: cc_flags 33 | if cc.has_argument(flag) 34 | add_global_arguments(flag, language: 'c') 35 | endif 36 | endforeach 37 | 38 | 39 | ldflags = [ 40 | '-Wl,-z,now', 41 | '-Wl,-z,relro', 42 | '-Wl,-z,noexecstack', 43 | ] 44 | foreach lflag : ldflags 45 | add_global_link_arguments(lflag, language : 'c') 46 | endforeach 47 | 48 | gstSvtHevcEnc = library('gstsvthevcenc', 49 | 'gstsvthevcenc.c', 50 | dependencies: [gstbase_dep, gstpbutils_dep , gstvideo_dep, svthevcenc_dep], 51 | install: true, 52 | install_dir: plugins_install_dir 53 | ) 54 | --------------------------------------------------------------------------------