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
517 stars 171 forks source link

Crash when encoding with specific resolution #459

Closed rxtsolar closed 4 years ago

rxtsolar commented 4 years ago

I got a crash when encoding a video with resolution 720x1440. However, I tested videos with 1440x720 or even 960x1920 do not have such issue.

Here is an example.

$ SvtHevcEncApp -w 720 -h 1440 -i 720x1440.yuv -b 720x1440.h265
-------------------------------------------
SVT-HEVC Encoder
SVT [version]:  SVT-HEVC Encoder Lib v1.4.3
SVT [build]  :  GCC 7.4.0    64 bit
LIB Build date: Jan 15 2020 01:42:52
-------------------------------------------
Number of logical cores available: 4
Number of PPCS 107
-------------------------------------------
SVT [config]: Main Profile  Tier (auto) Level (auto)
SVT [config]: EncoderMode / Tune                            : 7 / 1
SVT [config]: EncoderBitDepth / CompressedTenBitFormat / EncoderColorFormat         : 8 / 0 / 1
SVT [config]: SourceWidth / SourceHeight / InterlacedVideo              : 720 / 1440 / 0
SVT [config]: FrameRate / Gop Size                          : 60 / 64
SVT [config]: HierarchicalLevels / BaseLayerSwitchMode / PredStructure          : 3 / 0 / 2
SVT [config]: BRC Mode / QP / LookaheadDistance / SceneChange               : CQP / 32 / 17 / 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 [config]: More configurations for debugging:
SVT [config]: Channel ID / ActiveChannelCount                       : 0 / 1
SVT [config]: Number of Logical Processors / Target Socket              : 0 / -1
SVT [config]: Threads To RT / Thread Count / ASM Type                   : 1 / 0 / 1
SVT [config]: Speed Control / Injector Frame Rate                   : 0 / 60
SVT [config]: MaxCLL / MaxFALL / Output Reconstructed YUV               : 0 / 0 / 0
SVT [config]: MasterDisplayColorVolume / DolbyVisionProfile             : 0 / 0
SVT [config]: DisplayPrimaryX[0], DisplayPrimaryX[1], DisplayPrimaryX[2]        : 0 / 0 / 0
SVT [config]: DisplayPrimaryY[0], DisplayPrimaryY[1], DisplayPrimaryY[2]        : 0 / 0 / 0
SVT [config]: WhitePointX (0, 0) / DisplayMasteringLuminance Range [0 ~ 0]
SVT [config]: Constrained Intra / HDR / Code VPS SPS PPS / Code EOS         : 0 / 0 / 1 / 0
SVT [config]: Sending VUI / Temporal ID / VPS Timing Info               : 0 / 1 / 1
SVT [config]: SEI Message:
SVT [config]: AccessUnitDelimiter / BufferingPeriod / PictureTiming         : 0 / 0 / 0
SVT [config]: RegisteredUserData / UnregisteredUserData / RecoveryPoint         : 0 / 0 / 0
-------------------------------------------

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          Segmentation fault

Sample file 720x1440.yuv can be generated with ffmpeg. I used 1 frame for simplicity.

ffmpeg -f lavfi -i testsrc=720x1440 -vframes 1 -pix_fmt yuv420p 720x1440.yuv

Source code is downloaded from https://github.com/OpenVisualCloud/SVT-HEVC/archive/v1.4.3.tar.gz. I also tried current master, it has the same issue.

My environment is docker on my mac book with clean Ubuntu 18.04. I also tested on AWS EC2 with Ubuntu and got the same crash.

Some debugging shows that SvtHevcEncApp crashes at EbEncDecProcess.c:1626

1623         // Bottom-left Neighbor
1624         if (rowSegmentIndex < segmentPtr->segmentRowCount - 1 && bottomLeftSegmentIndex >= segmentPtr->rowArray[rowSegmentIndex + 1].startingSegIndex)
1625         {
1626             EbBlockOnMutex(segmentPtr->rowArray[rowSegmentIndex + 1].assignmentMutex);
1627

where segmentPtr->rowArray[rowSegmentIndex + 1].assignmentMutex is NULL.

intelmark commented 4 years ago

@rxtsolar Thanks for reporting this crash and providing much appreciated detail on how to reproduce. We verified your steps and will look into this bug in more detail.

rxtsolar commented 4 years ago

I verified that the crash no longer happens with the patch above. Thanks!

Austin-Hu commented 4 years ago

Thanks for your verification, @rxtsolar ! We will go through the review and merging process for PR #462 soon.