OpenVisualCloud / SVT-HEVC

SVT HEVC encoder. Scalable Video Technology (SVT) is a software-based video coding technology that is highly optimized for Intel® Xeon® processors. Using the open source SVT-HEVC encoder, it is possible to spread video encoding processing across multiple Intel® Xeon® processors to achieve a real advantage of processing efficiency.
Other
519 stars 169 forks source link

Rate control problem when set option lookaheadistance=0 and hierarchical-levels=3 #602

Closed spartazhc closed 3 years ago

spartazhc commented 3 years ago

When enable rate control and both -lad 0 -hierarchical-levels 3, there will have problem on QP assignment:

Command I use:

SvtHevcEncApp -w 1920 -h 1080 -i test.yuv -b out.hevc -pred-struct 0 -lad 0 -hierarchical-levels 3 -encMode 10 -bit-depth 8 -rc 1 -tbr 3000000

-lad 0 -hierarchical-levels 3 result: l3_lad0 -lad 4 -hierarchical-levels 3 result, normal: l3_lad4

Any response would be appreciated!

tianjunwork commented 3 years ago

Hi @spartazhc , -lad 0 -rc 1 is not recommended. Please read related discussion: https://github.com/OpenVisualCloud/SVT-HEVC/issues/588#issuecomment-827332741 If you use -lad 0 to get lower encoding delay, try -lad 1, number of frames queued is reduced and performance of rate control is much better.

spartazhc commented 3 years ago

Thanks for your reply! -lad 0 -hierarchical-levels 0 -rc 1 works. -lad 0 -hierarchical-levels 3 -rc1 fail. But my use case requires low encoding delay (-lad 0) and high throughout (-hierarchical-levels 3). I have read some code in InitialRateControlProcess and RateControlProcess, it is difficult for me to understand the idea behind code. Is there any meterial about the rate control algorithm used in SVT? And, If I want to fix this problem, do you have any advice?

Thanks a lot.

tianjunwork commented 3 years ago

Hi @spartazhc , for low latency use case, we've been suggesting to use -lad 1 to other users also. SVT-HEVC is not designed for ultra low latency or real time use case. To support that, the estimated engineering effort will cost at least a quarter for SVT algorithm team. Could you try -lad 1 and check if the delay is within your target? I understand the lower the better. But as you found out, the rate control is not performing with -lad 0.

spartazhc commented 3 years ago

Thanks Jun, I understand the difficulty of this problem. When I try -lad 1, there will be a floating point exception caused by trying to divide by zero.

https://github.com/OpenVisualCloud/SVT-HEVC/blob/31014e960e599f0e7769b293ed44a3ed8d3c8543/Source/Lib/Codec/EbInitialRateControlProcess.c#L679

https://github.com/OpenVisualCloud/SVT-HEVC/blob/31014e960e599f0e7769b293ed44a3ed8d3c8543/Source/Lib/Codec/EbInitialRateControlProcess.c#L703

tianjunwork commented 3 years ago

No problem. Can I have your command line to reproduce?

spartazhc commented 3 years ago
SvtHevcEncApp -w 1920 -h 1080 -i test.yuv -b out.hevc -pred-struct 0 -lad 1 -hierarchical-levels 3 -encMode 10 -bit-depth 8 -rc 1 -tbr 3000000

-------------------------------------------
SVT-HEVC Encoder
SVT [version]:  SVT-HEVC Encoder Lib v1.5.1
SVT [build]  :  GCC 9.3.0        64 bit
LIB Build date: Jun 18 2021 13:26:18
-------------------------------------------
Number of logical cores available: 72
Number of PPCS 91
-------------------------------------------
SVT [config]: Main Profile      Tier (auto)     Level (auto)
SVT [config]: EncoderMode / Tune                                                        : 10 / 1
SVT [config]: EncoderBitDepth / CompressedTenBitFormat / EncoderColorFormat             : 8 / 0 / 1
SVT [config]: SourceWidth / SourceHeight / InterlacedVideo                              : 1920 / 1080 / 0
SVT [config]: FrameRate / Gop Size                                                      : 60 / 64
SVT [config]: HierarchicalLevels / BaseLayerSwitchMode / PredStructure                  : 3 / 0 / 0
SVT [config]: RCMode / TargetBitrate / LAD / SceneChange / QP Range [10 ~ 48]           : VBR / 3000000 / 1 / 1
SVT [config]: BitRateReduction / ImproveSharpness                                       : 0 / 0
SVT [config]: tileColumnCount / tileRowCount / tileSliceMode / Constraint MV            : 1 / 1 / 0 / 0
SVT [config]: De-blocking Filter / SAO Filter                                           : 1 / 1
SVT [config]: HME / UseDefaultHME                                                       : 1 / 1
SVT [config]: MV Search Area Width / Height                                             : 16 / 7
SVT [config]: HRD / VBV MaxRate / BufSize / BufInit                                     : 0 / 0 / 0 / 90
-------------------------------------------

SVT [WARNING] Elevated privileges required to run with real-time policies! Check Linux Best Known Configuration in User Guide to run application in real-time without elevated privileges!

Encoding          zsh: floating point exception (core dumped) 
tianjunwork commented 3 years ago

Hi @spartazhc, I tried with several test clips. I didn't reproduce what you saw. Could you try other input yuv files? Does the crash show with other yuv files or just this one? image

spartazhc commented 3 years ago

That is strange, I tried all VVC B class sequences, and several C class sequences, all failed.

> Bin/Release/SvtHevcEncApp -w 1920 -h 1080 -i /mnt/hdd0/VVCSeq/B/RitualDance_1920x1080_60fps_10bit_420.yuv -b /tmp/out.hevc -pred-struct 0 -lad 1 -hierarchical-levels 3 -encMode 10 -bit-depth 8 -rc 1 -tbr 3000000
-------------------------------------------
SVT-HEVC Encoder
SVT [version]:  SVT-HEVC Encoder Lib v1.5.1
SVT [build]  :  GCC 9.3.0        64 bit
LIB Build date: Jun 22 2021 08:43:14
-------------------------------------------
Number of logical cores available: 72
Number of PPCS 91
------------------------------------------- 
SVT [config]: Main Profile      Tier (auto)     Level (auto)
SVT [config]: EncoderMode / Tune                                     : 10 / 1 
SVT [config]: EncoderBitDepth / CompressedTenBitFormat / EncoderColorFormat           : 8 / 0 / 1
SVT [config]: SourceWidth / SourceHeight / InterlacedVideo           : 1920 / 1080 / 0
SVT [config]: FrameRate / Gop Size                                   : 60 / 64 
SVT [config]: HierarchicalLevels / BaseLayerSwitchMode / PredStructure: 3 / 0 / 0 
SVT [config]: RCMode / TargetBitrate / LAD / SceneChange / QP Range [10 ~ 48]         : VBR / 3000000 / 1 / 1 
SVT [config]: BitRateReduction / ImproveSharpness                    : 0 / 0 
SVT [config]: tileColumnCount / tileRowCount / tileSliceMode / Constraint MV          : 1 / 1 / 0 / 0
SVT [config]: De-blocking Filter / SAO Filter                        : 1 / 1 
SVT [config]: HME / UseDefaultHME                                    : 1 / 1 
SVT [config]: MV Search Area Width / Height                          : 16 / 7 
SVT [config]: HRD / VBV MaxRate / BufSize / BufInit                  : 0 / 0 / 0 / 90
------------------------------------------- 

SVT [WARNING] Elevated privileges required to run with real-time policies! Check Linux Best Known Configuration in User Guide to run application in real-time without elevated privileges!

Encoding          zsh: floating point exception (core dumped)  Bin/Release/SvtHevcEncApp -w 1920 -h 1080 -i  -b /tmp/out.hevc -pred-struct 0
> Bin/Release/SvtHevcEncApp -w 832 -h 480 -i /mnt/hdd0/VVCSeq/C/BasketballDrill_832x480_50.yuv  -b /tmp/out.hevc -pred-struct 0 -lad 1 -hierarchical-levels 3 -encMode 9 -bit-depth 8 -rc 1 -tbr 3000000
-------------------------------------------
SVT-HEVC Encoder
SVT [version]:  SVT-HEVC Encoder Lib v1.5.1
SVT [build]  :  GCC 9.3.0        64 bit
LIB Build date: Jun 22 2021 08:43:14
-------------------------------------------
Number of logical cores available: 72
Number of PPCS 91
------------------------------------------- 
SVT [config]: Main Profile      Tier (auto)Level (auto)
SVT [config]: EncoderMode / Tune          : 9 / 1 
SVT [config]: EncoderBitDepth / CompressedTenBitFormat / EncoderColorFormat          : 8 / 0 / 1
SVT [config]: SourceWidth / SourceHeight / InterlacedVideo                         : 832 / 480 / 0
SVT [config]: FrameRate / Gop Size        : 60 / 64 
SVT [config]: HierarchicalLevels / BaseLayerSwitchMode / PredStructure               : 3 / 0 / 0 
SVT [config]: RCMode / TargetBitrate / LAD / SceneChange / QP Range [10 ~ 48]        : VBR / 3000000 / 1 / 1 
SVT [config]: BitRateReduction / ImproveSharpness                                  : 0 / 0 
SVT [config]: tileColumnCount / tileRowCount / tileSliceMode / Constraint MV         : 1 / 1 / 0 / 0
SVT [config]: De-blocking Filter / SAO Filter                                        : 1 / 1 
SVT [config]: HME / UseDefaultHME         : 1 / 1 
SVT [config]: MV Search Area Width / Height                                          : 16 / 7 
SVT [config]: HRD / VBV MaxRate / BufSize / BufInit                                  : 0 / 0 / 0 / 90
------------------------------------------- 

SVT [WARNING] Elevated privileges required to run with real-time policies! Check Linux Best Known Configuration in User Guide to run application in real-time without elevated privileges!

Encoding          zsh: floating point exception (core dumped)  Bin/Release/SvtHevcEncApp -w 832 -h 480 -i  -b /tmp/out.hevc -pred-struct 0
tianjunwork commented 3 years ago

I can encode BasketballDrill_832x480_50 with no issue. image Let's try something:

  1. Run ./build.sh and attach build print here.
  2. Build debug version (./build.sh debug) and use gdb to get call stack after crash.
spartazhc commented 3 years ago
  1. build log svthevc-build.log
  2. gdb log ( run with same command encode BasketballDrill_832x480_50: image
tianjunwork commented 3 years ago

Hi @spartazhc, I reproduced it with gcc-10, but it works OK with gcc-8. It maybe a variable initiation issue. Will work on fixing. Thank you for reporting the issue. If this issue block you, please revert gcc to 8 before I fix it. Using this method, you can switch gcc versions: https://askubuntu.com/a/26502 Make sure to delete the CMake build folder in Build/linux before you build.

tianjunwork commented 3 years ago

Hi @spartazhc , the exception is fixed. Let me know if you have other questions.

spartazhc commented 3 years ago

No other questions for now, thanks a lot for your help