Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Add crf ratecontrol support #70

Open
wants to merge 106 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
e2e977b
Add crf ratecontrol support
kirithika7 Jan 9, 2019
ac871ee
Merge branch 'master' into master
kirithika7 Jan 17, 2019
808457f
Add CLI support for vbv
bhavnahariMCW Dec 11, 2018
de97249
Enable vbv for abr mode
bhavnahariMCW Dec 18, 2018
488721b
Added VBV frame level support
dinesh0603 Jan 8, 2019
8f74ea2
1. Fixed Index comparision to compare with current Index + lookAheadD…
dinesh0603 Jan 22, 2019
8f3b2a4
Enforce vbv buffer update to happen in decode order
kirithika7 Jan 23, 2019
f1e1a17
Add new cli -hrd (default 0) + enable flags to signal hrd
kirithika7 Jan 23, 2019
8c2f324
Add support for HRD SEI signalling
kirithika7 Jan 24, 2019
bfd35f2
Add support for Active Parameter Set SEI
kirithika7 Jan 30, 2019
38b744d
Control VBV bufferFill access using mutex
arunaMathes Jan 25, 2019
853a45e
Add cli -vbv-init and remove hard-coded vbv buffer initialization
arunaMathes Jan 31, 2019
87f7729
If rate control is ON, base layer picture will not be processed until…
anaghdin Jan 27, 2019
708bd26
VBV Code clean up and made VBV as function call
dinesh0603 Feb 18, 2019
32dc411
Fix for the deadlock encoding frames fewer than 48
anaghdin Feb 18, 2019
88d1bef
Move vbv algorithm before using picture Qp for other RC context updates
kirithika7 Feb 22, 2019
f4d19b8
Fix Warning: When NAL Unit is non-VCL NAL, TemporalId shall be greate…
kirithika7 Feb 22, 2019
cddec5a
Fix bug:The value of rbsp_stop_one_bit shall be equal to 1 in vps
kirithika7 Feb 25, 2019
96524c4
Fix cbr signalling
kirithika7 Feb 26, 2019
a199b68
Fix Hrd Issue
kirithika7 Feb 27, 2019
e692a04
Fix uninitialized BPnumber value error when hrd is disabled
kirithika7 Feb 28, 2019
c8a7166
Fix Hrd signalling for fixed GOP length
kirithika7 Feb 28, 2019
54eceb4
-Fix 1. encoded bitrate will be within target Bitrate limit 2. previo…
dinesh0603 Mar 5, 2019
429edb5
Add code to copy the pcs context into the Packetization Reorder Queue…
kirithika7 Mar 12, 2019
d857190
Add code to splice the bitstream and insert pic timing SEI
kirithika7 Mar 12, 2019
0d74be5
Fix bugs and cleanup
kirithika7 Mar 12, 2019
22f80ea
Refactor byte shifting code with memcpy+cleanup
kirithika7 Mar 13, 2019
5f52a2f
Add support for strict cbr to prevent hrd buffer overflow
kirithika7 Mar 13, 2019
dd24050
Add code to consider filler bits for RC
kirithika7 Mar 13, 2019
713643e
Merged Master to VBV-DEV branch
dinesh0603 Mar 19, 2019
6311c66
Merge branch 'master' tip into vbv_dev
dinesh0603 Mar 20, 2019
f268574
Update the filler bit error in the packetization feedback to rate con…
kirithika7 Mar 21, 2019
f1cd4c5
Added feedback from packetization to picturemanager to address a dead…
anaghdin Mar 26, 2019
0b1103a
Fix the demux port
anaghdin Mar 27, 2019
494cb24
update the pictureDemuxResultsProducerFifoPtrArray ports
anaghdin Mar 27, 2019
7b70491
Revert the feedback of filler bits error to GOP's virtual Buffer level
kirithika7 Mar 27, 2019
07c3947
Fix for deadlock when vbv is not enabled
kirithika7 Mar 29, 2019
3df55f3
Fix compiler warnings
kirithika7 Mar 29, 2019
e3b304d
Fix for Final Bitrate is greater than TBR in Strict CBR
dinesh0603 Apr 4, 2019
603afa8
Fix:Remove the duplicated use of current frame bits for lookahead bas…
kirithika7 Apr 15, 2019
aa3d3f6
Add support for vbv-end and vbv-end-fr-adj
kirithika7 Apr 5, 2019
c82520c
Add proxy entropy coding call into Encdec process to support block le…
kirithika7 Feb 6, 2019
1397357
Create and initialize row stats structure
kirithika7 Feb 11, 2019
742a38e
Add code to assign baseqp for each LCU
kirithika7 Feb 12, 2019
6926341
Update rowstats based on the CU history
kirithika7 Feb 12, 2019
1d6bce7
Add code for Low level RC
kirithika7 Feb 26, 2019
c977220
Add code to estimate frame size at vbv checkpoints
kirithika7 Feb 13, 2019
9234146
Code clean up & removed warnings
dinesh0603 Mar 1, 2019
0560e9c
Add code to predict bits for each LCU
kirithika7 Mar 11, 2019
9703118
Fix Buffer Fill based on the lookahead buffer Fill for the current frame
kirithika7 Apr 22, 2019
01d52a4
Fix exception due to null frame rate
kirithika7 Apr 22, 2019
501e5a4
Move the low-level QP calculation after MD Fix the confromant part fo…
anaghdin Mar 12, 2019
037d7c2
Add cli support to enable/disable low level vbv
kirithika7 Mar 19, 2019
d1b7dea
Add additional checks for -low-level-vbv introduced
kirithika7 Mar 19, 2019
5a8dc53
Fix the run time error "No RC interval found" when
kirithika7 Apr 29, 2019
d55a18b
Fix: Reset encodedBitsSoFar to 0 before recomputing frame size
kirithika7 Apr 29, 2019
e337b62
Merge branch with Master (Commit:97eafda)
dinesh0603 May 30, 2019
f7ebfc3
-Modified code as per review comments and coding guidelines
dinesh0603 May 30, 2019
c5cdcfe
Fix for Deadlock
dinesh0603 May 31, 2019
beda1ec
Remove the macro PACK_FEEDBACK
anaghdin Mar 27, 2019
d1386a6
Implement 16x16 SATD C and AVX2 functions.
LuanZhanKuangGe Jun 6, 2019
2442880
Fix compiler errors on Linux.
LuanZhanKuangGe Jun 6, 2019
c8e2fcd
Fixed hrd 1 crash issues caused by writeUvlc long bits, memmove and S…
Jun 11, 2019
20e2bf9
Merge CRF branch with master
dinesh0603 Jun 13, 2019
6431e5c
Merge CRF with Master Tip(commit:054b1bf)
dinesh0603 Jun 13, 2019
80d1d8a
Modifed code as per coding guidelines
dinesh0603 Jun 14, 2019
8997bc3
Merge branch VBV Code with CRF
dinesh0603 Jun 20, 2019
8570171
Merge branch 'master' into master
tianjunwork Jun 25, 2019
ceb6347
Fix linux build errors
kavithasampath Jun 27, 2019
5bb446b
Merge branch 'master' of https://github.com/OpenVisualCloud/SVT-HEVC
kirithika7 Jul 10, 2019
c9ce68b
Cleanup unused variables
kirithika7 Jul 10, 2019
5f95710
Update CMakeLists.txt
kirithika7 Jul 10, 2019
015a2bc
Merge branch 'master' of https://github.com/OpenVisualCloud/SVT-HEVC
kirithika7 Jul 10, 2019
1165741
Revert "Update CMakeLists.txt "
kirithika7 Jul 10, 2019
5e6e924
Fix make error caught while linking math library
kirithika7 Jul 15, 2019
d3d530c
Fix SVT-HEVC ffmpeg integration error
kirithika7 Jul 15, 2019
85a36e2
Fix license header in newly added files
kirithika7 Jul 30, 2019
c5bd916
Fix initialization of Neighbor arrays in EstimateLcu()
kirithika7 Aug 1, 2019
e393fd0
Update Estimatelcu() to that of master
kirithika7 Aug 8, 2019
d499b4f
Fix the Encoder crash when Frames exceeds the CircularQueue length
kirithika7 Aug 9, 2019
c710fc5
Remove reassignment of lcu qp by Entropy process
kirithika7 Aug 9, 2019
84979ba
Fix reset of Row stats once per picture
kirithika7 Aug 9, 2019
b6ae721
Use Sad Interval Index updated by Motion Estimation Process for LCU b…
kirithika7 Aug 9, 2019
ce88bc4
Clean up
kirithika7 Aug 9, 2019
b07731f
Revert vbv-end and vbv end frame adjust option
kirithika7 Aug 10, 2019
1e85639
Merge branch 'master' of https://github.com/OpenVisualCloud/SVT-HEVC
kirithika7 Aug 10, 2019
ef9c29a
Cleanup unneccesary file changes
kirithika7 Aug 10, 2019
c849c55
Merge branch 'master' of https://github.com/OpenVisualCloud/SVT-HEVC
kirithika7 Aug 12, 2019
72a99e9
Cleanup the usage of a udeclared variable
kirithika7 Aug 12, 2019
c16092c
Enable Low level VBV only if frame level VBV is enabled and remove re…
kirithika7 Aug 12, 2019
c0b0ece
Fix inconsistent line endings in EbEncDecProcess.c
kirithika7 Aug 12, 2019
1335e73
Remove the SATD asm implementation
kirithika7 Aug 12, 2019
40a5f97
Move PredictBits() to a new file to remove redundant copy of it as Pr…
kirithika7 Aug 12, 2019
ce4672c
Remove unused variable rowIndex+Move tempCoeffPtr assignment after
kirithika7 Aug 13, 2019
3ee527f
Add Macro for Rc Tolerance and Step size values + Add VBV control to…
kirithika7 Aug 14, 2019
a5d6a00
Add code for planning VBV Buffer Fullness after lookahead VBV to use …
kirithika7 Aug 14, 2019
a984744
Restrict low level vbv when lookahead predictions are not done + enab…
kirithika7 Aug 14, 2019
8c2612f
Merge branch 'master' of https://github.com/OpenVisualCloud/SVT-HEVC
kirithika7 Aug 14, 2019
2e231e2
Fix build error + update BKC for frame level VBV
kirithika7 Aug 14, 2019
a218fa7
Remove -DPIC as it is not needed for SATD C implementation
kirithika7 Aug 15, 2019
93f6794
Merge branch 'master' into master
tianjunwork Oct 17, 2019
e93b4e9
Fixed the compiling errors/warnings for rebasing PR #70.
Austin-Hu Oct 17, 2019
b7effc8
Refined the CRF usage.
Austin-Hu Oct 17, 2019
8ba809c
Update EbEncHandle.c
Austin-Hu Oct 18, 2019
7135294
Fixed some rebasing errors in EbEncDecProcess.c
Austin-Hu Oct 24, 2019
79f187c
Merge branch 'master' into master
Austin-Hu Nov 4, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Config/Sample.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,19 @@ SearchAreaHeight : 7 # Number of search posit
ConstrainedIntra : 0 # Enable the use of Constrained Intra which results in sending two PPSs (0: OFF, 1: ON)

# ====================== Rate Control ===============================
RateControlMode : 0 # Rate control mode (0: OFF(CQP), 1: VBR)
RateControlMode : 0 # Rate control mode (0: OFF(CQP), 1: VBR, 2: CRF)
TargetBitRate : 7000000 # Target Bit Rate (in bits per second)
vbvMaxrate : 0 # VBV MaxRate (in bits per second)
vbvBufsize : 0 # VBV Bufsize (in bits per second)
vbvBufInit : 90 # Sets how full the VBV buffer to be - [0 - 100]
hrdFlag : 0 # hrdflag (When hrdFlag is set to 1 it requires vbvMaxrate and vbvBufsize to be greater than 0)(0: disable , 1: enable)
lowLevelVbv : 0 # Enables lowLevelVBV Algorithm (When lowLevelVbv is set to 1 it requires vbvMaxrate and vbvBufsize to be greater than 0)(0: OFF, 1: ON)
MaxQpAllowed : 48 # maximum allowed QP when rate control is on - [0-51]
MinQpAllowed : 10 # minimum allowed QP when rate control is on - [0-51]
LookAheadDistance : 17 # Enable Look Ahead [0-250]
SceneChangeDetection : 1 # Enable Scene Change Detection (0: OFF, 1: ON)
ConstantRateFactor : 28 # CRF value allowed for rate control use - [0-51]


# ====================== Adaptive QP Params ===============================
BitRateReduction : 1 # BitRate Reduction (only applicable when Tune is set to 0) (0= OFF, 1=ON )
Expand Down
23 changes: 20 additions & 3 deletions Docs/svt-hevc_encoder_user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,14 @@ The encoder parameters present in the Sample.cfg file are listed in this table b
| **SearchAreaWidth** | -search-w | [1 - 256] | Depends on input resolution | Motion vector search area width |
| **SearchAreaHeight** | -search-h | [1 - 256] | Depends on input resolution | Motion vector search area height |
| **ConstrainedIntra** | -constrd-intra | [0,1] | 0 | Allow the use of Constrained Intra, when enabled, this features yields to sending two PPSs in the HEVC Elementary streams <br>0 = OFF, 1 = ON |
| **RateControlMode** | -rc | [0,1] | 0 | 0 : CQP , 1 : VBR |
| **RateControlMode** | -rc | [0 - 2] | 0 | 0 : CQP , 1 : VBR , 2 : CRF |
| **ConstantRateFactor** | -crf | [0 - 51] | 28 | CRF value allowed for rate control use, only apllicable when RateControlMode is set to 2 |
| **TargetBitRate** | -tbr | Any Number | 7000000 | Target bitrate in bits / second. Only used when RateControlMode is set to 1 |
| **vbvMaxrate** | -vbv-maxrate | Any Number | 0 | VBVMaxrate in bits / second. Only used when RateControlMode is set to 1 |
| **vbvBufsize** | -vbv-bufsize | Any Number | 0 | VBV BufferSize in bits / second. Only used when RateControlMode is set to 1 |
| **vbvBufInit** | -vbv-init | [0 - 100] | 90 | Sets the initial percentage size that the VBV buffer is filled to |
| **hrdFlag** | -hrd | [0,1] | 0 | Sets the HRD (Hypothetical Reference Decoder) Flag in the encoded stream, 0 = OFF, 1 = ON When<br/>hrdFlag is set to 1, vbvMaxrate and vbvBufsize must be greater than 0 |
| **vbvBufInit** | -vbv-init | [0 - 100] | 90 | Sets how full the VBV buffer to be|
| **hrdFlag** | -hrd | [0,1] | 0 | HRD Flag, 0 = OFF, 1 = ON |When hrdFlag is set to 1 it requires vbvMaxrate and vbvBufsize to be greater than 0 |
| **lowLevelVbv** | -low-level-vbv | [0,1] | 0 | Enable lowLevelVBV algorithm. it requires vbvMaxrate and vbvBufsize to be greater than 0 0 = OFF, 1 = ON |
| **MaxQpAllowed** | -max-qp | [0 - 51] | 48 | Maximum QP value allowed for rate control use. Only used when RateControlMode is set to 1. Has to be >= MinQpAllowed |
| **MinQpAllowed** | -min-qp | [0 - 50] | 10 | Minimum QP value allowed for rate control use. Only used when RateControlMode is set to 1. Has to be < MaxQpAllowed |
| **LookAheadDistance** | -lad | [0 - 250] | Depending on BRC mode | When RateControlMode is set to 1 it&#39;s best to set this parameter to be equal to the Intra period value (such is the default set by the encoder). When CQP is chosen, then a (2 \* minigopsize +1) look ahead is recommended. |
Expand Down Expand Up @@ -449,6 +451,21 @@ Similarly, in order to enable VBV and run a 2-stream 8kp50 simultaneous encode o

>taskset 0xFFFFFFF0000000FFFFFFF0000000 ./SvtHevcEncApp -encMode 11 -w 3840 -h 2160 -bit-depth 10 -compressed-ten-bit-format 1 -i in.yuv -rc 1 –tbr 10000000 -vbv-maxrate 10000000 -vbv-bufsize 10000000 -fps 50 -b out3.bin -n 5000 –nb 500 &amp;

<br>
Similarly, in order to enable VBV and run a 2-stream 8kp50 simultaneous encode on a Xeon Platinum 8180 system the following command lines should be used:

#### *Running Windows\* Server 2016:*

>start /node 0 SvtHevcEncApp.exe -encMode 12 -tune 0 -w 3840 -h 2160 -bit-depth 10 -compressed-ten-bit-format 1 -i in.yuv -rc 1 –tbr 10000000 -vbv-maxrate 10000000 -vbv-bufsize 20000000 -fps 50 -b out1.bin -n 5000 –nb 500

>start /node 1 SvtHevcEncApp.exe -encMode 12 -tune 0 -w 3840 -h 2160 -bit-depth 10 -compressed-ten-bit-format 1 -i in.yuv -rc 1 –tbr 10000000 -vbv-maxrate 10000000 -vbv-bufsize 20000000 -fps 50 -b out3.bin -n 5000 –nb 500

#### *Running Ubuntu\* 18.04:*

>taskset 0x0000000FFFFFFF0000000FFFFFFF ./SvtHevcEncApp -encMode 12 -tune 0 -w 3840 -h 2160 -bit-depth 10 -compressed-ten-bit-format 1 -i in.yuv -rc 1 –tbr 10000000 -vbv-maxrate 10000000 -vbv-bufsize 10000000 -fps 50 -b out3.bin -n 5000 –nb 500 &amp;

>taskset 0xFFFFFFF0000000FFFFFFF0000000 ./SvtHevcEncApp -encMode 12 -tune 0 -w 3840 -h 2160 -bit-depth 10 -compressed-ten-bit-format 1 -i in.yuv -rc 1 –tbr 10000000 -vbv-maxrate 10000000 -vbv-bufsize 10000000 -fps 50 -b out3.bin -n 5000 –nb 500 &amp;

<br>
Where 0x0000000FFFFFFF0000000FFFFFFF and 0xFFFFFFF0000000FFFFFFF0000000 are masks for sockets 0 and 1 respectively on a dual 8180 system.

Expand Down
13 changes: 12 additions & 1 deletion Source/API/EbApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,11 @@ typedef struct EB_H265_ENC_CONFIGURATION
*
* Default is 10. */
uint32_t minQpAllowed;
/* CRF value allowed for rate control use, only apllicable when rate
* control mode is set to 2.
*
* Default is 28. */
uint32_t crf;


// bitstream options
Expand Down Expand Up @@ -545,7 +550,13 @@ typedef struct EB_H265_ENC_CONFIGURATION

/* Active channel count. */
uint32_t activeChannelCount;

/* Enables lowLevelVBV Algorithm
*
* 0 = disable.
* 1 = enable.
*
* Default is 0. */
uint8_t lowLevelVbv;

// Threads management

Expand Down
12 changes: 6 additions & 6 deletions Source/App/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ target_link_libraries(SvtHevcEncApp
SvtHevcEnc)

if(UNIX)
target_link_libraries(SvtHevcEncApp
pthread)
if(NOT APPLE)
target_link_libraries(SvtHevcEncApp
rt)
endif()
target_link_libraries(SvtHevcEncApp
pthread m)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needed ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is included as CRF algorithm uses pow and log from math lib

if(NOT APPLE)
target_link_libraries(SvtHevcEncApp
rt)
endif()
endif()

install(TARGETS SvtHevcEncApp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
11 changes: 10 additions & 1 deletion Source/App/EbAppConfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@
#define NALU_FILE_TOKEN "-nalu-file"
#define RATE_CONTROL_ENABLE_TOKEN "-rc"
#define TARGET_BIT_RATE_TOKEN "-tbr"
#define CRF_TOKEN "-crf"
#define VBV_MAX_RATE_TOKEN "-vbv-maxrate"
#define VBV_BUFFER_SIZE_TOKEN "-vbv-bufsize"
#define VBV_BUFFER_INIT_TOKEN "-vbv-init"
#define ENABLE_LOW_LEVEL_VBV_TOKEN "-low-level-vbv"
#define HRD_TOKEN "-hrd"
#define MAX_QP_TOKEN "-max-qp"
#define MIN_QP_TOKEN "-min-qp"
Expand Down Expand Up @@ -192,6 +194,7 @@ static void SetFrameRate (const char *value, EbConfig_t *
cfg->frameRate = cfg->frameRate << 16;
}
}

static void SetFrameRateNumerator (const char *value, EbConfig_t *cfg) {cfg->frameRateNumerator = strtoul(value, NULL, 0);};
static void SetFrameRateDenominator (const char *value, EbConfig_t *cfg) {cfg->frameRateDenominator = strtoul(value, NULL, 0);};
static void SetEncoderBitDepth (const char *value, EbConfig_t *cfg) {cfg->encoderBitDepth = strtoul(value, NULL, 0);}
Expand All @@ -204,6 +207,7 @@ static void SetCfgIntraRefreshType (const char *value, EbConfig_t *
static void SetHierarchicalLevels (const char *value, EbConfig_t *cfg) {cfg->hierarchicalLevels = strtol(value, NULL, 0); };
static void SetCfgPredStructure (const char *value, EbConfig_t *cfg) {cfg->predStructure = strtol(value, NULL, 0); };
static void SetCfgQp (const char *value, EbConfig_t *cfg) {cfg->qp = strtoul(value, NULL, 0);};
static void SetCfgCrf (const char *value, EbConfig_t *cfg) {cfg->crf = strtoul(value, NULL, 0); };
static void SetCfgUseQpFile (const char *value, EbConfig_t *cfg) {cfg->useQpFile = (EB_BOOL)strtol(value, NULL, 0); };
static void SetCfgTileColumnCount (const char *value, EbConfig_t *cfg) { cfg->tileColumnCount = (EB_BOOL)strtol(value, NULL, 0); };
static void SetCfgTileRowCount (const char *value, EbConfig_t *cfg) { cfg->tileRowCount = (EB_BOOL)strtol(value, NULL, 0); };
Expand All @@ -228,6 +232,7 @@ static void SetVbvMaxrate (const char *value, EbConfig_t *
static void SetVbvBufsize (const char *value, EbConfig_t *cfg) { cfg->vbvBufsize = strtoul(value, NULL, 0);};
static void SetVbvBufInit (const char *value, EbConfig_t *cfg) { cfg->vbvBufInit = strtoul(value, NULL, 0);};
static void SetHrdFlag (const char *value, EbConfig_t *cfg) { cfg->hrdFlag = strtoul(value, NULL, 0);};
static void SetLowLevelVbv (const char *value, EbConfig_t *cfg) { cfg->lowLevelVbv = (EB_BOOL)strtol(value, NULL, 0); };
static void SetVideoUsabilityInfo (const char *value, EbConfig_t *cfg) {cfg->videoUsabilityInfo = strtol(value, NULL, 0);};
static void SetHighDynamicRangeInput (const char *value, EbConfig_t *cfg) {cfg->highDynamicRangeInput = strtol(value, NULL, 0);};
static void SetAccessUnitDelimiter (const char *value, EbConfig_t *cfg) {cfg->accessUnitDelimiter = strtol(value, NULL, 0);};
Expand Down Expand Up @@ -348,6 +353,7 @@ config_entry_t config_entry[] = {
{ SINGLE_INPUT, VBV_BUFFER_SIZE_TOKEN, "vbvBufsize", SetVbvBufsize },
{ SINGLE_INPUT, HRD_TOKEN, "hrd", SetHrdFlag },
{ SINGLE_INPUT, VBV_BUFFER_INIT_TOKEN, "vbvBufInit", SetVbvBufInit},
{ SINGLE_INPUT, ENABLE_LOW_LEVEL_VBV_TOKEN,"lowLevelVbv",SetLowLevelVbv},


// Deblock Filter
Expand All @@ -368,7 +374,8 @@ config_entry_t config_entry[] = {
{ SINGLE_INPUT, CONSTRAINED_INTRA_ENABLE_TOKEN, "ConstrainedIntra", SetEnableConstrainedIntra },

// Rate Control
{ SINGLE_INPUT, RATE_CONTROL_ENABLE_TOKEN, "RateControlMode", SetRateControlMode },
{ SINGLE_INPUT, CRF_TOKEN, "CRF", SetCfgCrf },
{ SINGLE_INPUT, RATE_CONTROL_ENABLE_TOKEN, "RateControlMode", SetRateControlMode },
{ SINGLE_INPUT, TARGET_BIT_RATE_TOKEN, "TargetBitRate", SetTargetBitRate },
{ SINGLE_INPUT, MAX_QP_TOKEN, "MaxQpAllowed", SetMaxQpAllowed },
{ SINGLE_INPUT, MIN_QP_TOKEN, "MinQpAllowed", SetMinQpAllowed },
Expand Down Expand Up @@ -570,6 +577,8 @@ void EbConfigCtor(EbConfig_t *configPtr)
configPtr->vbvBufsize = 0;
configPtr->vbvBufInit = 90;
configPtr->hrdFlag = 0;
configPtr->crf = 28;
configPtr->lowLevelVbv = 0;

// Testing
configPtr->testUserData = 0;
Expand Down
2 changes: 2 additions & 0 deletions Source/App/EbAppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ typedef struct EbConfig_s
uint32_t targetBitRate;
uint32_t maxQpAllowed;
uint32_t minQpAllowed;
uint32_t crf;
uint32_t vbvMaxRate;
uint32_t vbvBufsize;
uint64_t vbvBufInit;
Expand Down Expand Up @@ -348,6 +349,7 @@ typedef struct EbConfig_s
EB_BOOL switchThreadsToRtPriority;
EB_BOOL fpsInVps;
uint32_t hrdFlag;
EB_BOOL lowLevelVbv;
EB_BOOL unrestrictedMotionVector;

/****************************************
Expand Down
2 changes: 2 additions & 0 deletions Source/App/EbAppContext.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,11 @@ EB_ERRORTYPE CopyConfigurationParameters(
callbackData->ebEncParameters.maxQpAllowed = config->maxQpAllowed;
callbackData->ebEncParameters.minQpAllowed = config->minQpAllowed;
callbackData->ebEncParameters.qp = config->qp;
callbackData->ebEncParameters.crf = config->crf;
callbackData->ebEncParameters.vbvMaxrate = config->vbvMaxRate;
callbackData->ebEncParameters.vbvBufsize = config->vbvBufsize;
callbackData->ebEncParameters.vbvBufInit = config->vbvBufInit;
callbackData->ebEncParameters.lowLevelVbv = config->lowLevelVbv;
callbackData->ebEncParameters.useQpFile = (EB_BOOL)config->useQpFile;
callbackData->ebEncParameters.tileColumnCount = (EB_BOOL)config->tileColumnCount;
callbackData->ebEncParameters.tileRowCount = (EB_BOOL)config->tileRowCount;
Expand Down
4 changes: 3 additions & 1 deletion Source/Lib/C_DEFAULT/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ set(C_DEFAULT_SOURCE
EbIntraPrediction_C.c
EbMcp_C.c
EbMeSadCalculation_C.c
EbPackUnPack_C.c
EbMeSatdCalculation_C.c
EbPackUnPack_C.c
EbPictureOperators_C.c
EbSampleAdaptiveOffset_C.c
EbTransforms_C.c)
Expand All @@ -38,6 +39,7 @@ add_library(HEVC_C_DEFAULT OBJECT
EbIntraPrediction_C.h
EbMcp_C.h
EbMeSadCalculation_C.h
EbMeSatdCalculation_C.h
EbPackUnPack_C.h
EbPictureOperators_C.h
EbSampleAdaptiveOffset_C.h
Expand Down
80 changes: 80 additions & 0 deletions Source/Lib/C_DEFAULT/EbMeSatdCalculation_C.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright(c) 2018 Intel Corporation
* SPDX - License - Identifier: BSD - 2 - Clause - Patent
*/

#include "EbMeSatdCalculation_C.h"

#define BITS_PER_SUM (8 * sizeof(EB_U16))

static inline EB_U32 abs2(EB_U32 a)
{
EB_U32 s = ((a >> (BITS_PER_SUM - 1)) & (((EB_U32)1 << BITS_PER_SUM) + 1)) * ((EB_U32)-1);

return (a + s) ^ s;
}

#define HADAMARD4(d0, d1, d2, d3, s0, s1, s2, s3) { \
EB_U32 t0 = s0 + s1; \
EB_U32 t1 = s0 - s1; \
EB_U32 t2 = s2 + s3; \
EB_U32 t3 = s2 - s3; \
d0 = t0 + t2; \
d2 = t0 - t2; \
d1 = t1 + t3; \
d3 = t1 - t3; \
}

/*******************************************
Calcualte SATD for 8x4 sublcoks.
*******************************************/
EB_U32 SatdCalculation_8x4(
EB_U8 *src,
EB_U32 srcStride,
EB_U8 *ref,
EB_U32 refStride)
{
EB_U32 tmp[4][4];
EB_U32 a0, a1, a2, a3;
EB_U32 sum = 0;

for (EB_U64 i = 0; i < 4; i++, src += srcStride, ref += refStride)
{
a0 = (src[0] - ref[0]) + ((EB_U32)(src[4] - ref[4]) << BITS_PER_SUM);
a1 = (src[1] - ref[1]) + ((EB_U32)(src[5] - ref[5]) << BITS_PER_SUM);
a2 = (src[2] - ref[2]) + ((EB_U32)(src[6] - ref[6]) << BITS_PER_SUM);
a3 = (src[3] - ref[3]) + ((EB_U32)(src[7] - ref[7]) << BITS_PER_SUM);
HADAMARD4(tmp[i][0], tmp[i][1], tmp[i][2], tmp[i][3], a0, a1, a2, a3);
}

for (EB_U64 i = 0; i < 4; i++)
{
HADAMARD4(a0, a1, a2, a3, tmp[0][i], tmp[1][i], tmp[2][i], tmp[3][i]);
sum += abs2(a0) + abs2(a1) + abs2(a2) + abs2(a3);
}

return (((EB_U16)sum) + (sum >> BITS_PER_SUM)) >> 1;
}

/*******************************************
Calcualte SATD for 16x16 sublcoks.
*******************************************/
EB_U32 SatdCalculation_16x16(
EB_U8 *src,
EB_U32 srcStride,
EB_U8 *ref,
EB_U32 refStride)
{
EB_U32 satd = 0;

for (EB_U64 row = 0; row < 16; row += 4)
{
for (EB_U64 col = 0; col < 16; col += 8)
{
satd += SatdCalculation_8x4(src + row * srcStride + col, srcStride,
ref + row * refStride + col, refStride);
}
}

return satd;
}
23 changes: 23 additions & 0 deletions Source/Lib/C_DEFAULT/EbMeSatdCalculation_C.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright(c) 2018 Intel Corporation
* SPDX - License - Identifier: BSD - 2 - Clause - Patent
*/

#ifndef EbMeSatdCalculation_C_h
#define EbMeSatdCalculation_C_h

#include "EbDefinitions.h"
#ifdef __cplusplus
extern "C" {
#endif

EB_U32 SatdCalculation_16x16(
EB_U8 *src,
EB_U32 srcStride,
EB_U8 *ref,
EB_U32 refStride);

#ifdef __cplusplus
}
#endif
#endif // EbMeSadCalculation_C_h
3 changes: 3 additions & 0 deletions Source/Lib/Codec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ set(Codec_Source
EbMotionEstimationResults.c
EbPacketizationProcess.c
EbPacketizationReorderQueue.c
EbPerFramePrediction.c
EbPictureAnalysisProcess.c
EbPictureAnalysisResults.c
EbPictureBufferDesc.c
Expand Down Expand Up @@ -154,6 +155,7 @@ add_library(SvtHevcEnc
EbPacketizationProcess.h
EbPacketizationReorderQueue.h
EbPackUnPack.h
EbPerFramePrediction.h
EbPictureAnalysisProcess.h
EbPictureAnalysisResults.h
EbPictureBufferDesc.h
Expand Down Expand Up @@ -191,6 +193,7 @@ add_library(SvtHevcEnc

if(UNIX)
set(LIBS "-lpthread")
set(LIBS "${LIBS} -lm")
# Set version number for SONAME.
set_target_properties(SvtHevcEnc
PROPERTIES SOVERSION ${SVT_HEVC_SOVERSION})
Expand Down
Loading