crash when encoding to 422

Issue #323 resolved
Selur created an issue

using:

x265 [info]: HEVC encoder version 2.2+36-9b975fec584a
x265 [info]: build info [Windows][GCC 6.3.0][64 bit] 8bit+10bit+12bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
ffmpeg -y -loglevel fatal -threads 8 -i "F:\TestClips&Co\Test-AC3-5.1.avi" -map 0:0 -an -sn  -vsync 0  -strict -1 -pix_fmt yuv422p16le  -f yuv4mpegpipe - | x265 --input - --output-depth 10 --y4m --profile main422-10 --limit-modes --no-open-gop --crf 18.00 --cbqpoffs -2 --crqpoffs -2 --psy-rd 2.50 --rdoq-level 2 --psy-rdoq 15.00 --aq-mode 2 --no-cutree --range limited --colormatrix bt470bg --output "H:\Temp\00_01_57_3410_01.265"

crashes x265 for me. Same with:

ffmpeg -y -loglevel fatal -threads 8 -i "F:\TestClips&Co\Test-AC3-5.1.avi" -map 0:0 -an -sn  -vsync 0  -strict -1 -pix_fmt yuv422p16le  -f yuv4mpegpipe - | x265 --input - --output-depth 12 --y4m --profile main422-12 --limit-modes --no-open-gop --crf 18.00 --cbqpoffs -2 --crqpoffs -2 --psy-rd 2.50 --rdoq-level 2 --psy-rdoq 15.00 --aq-mode 2 --no-cutree --range limited --colormatrix bt470bg --output "H:\Temp\00_05_00_6210_01.265"

using yuv422p12le, yuv422p10le or yuv422p instead of yuv422p16le doesn't help either.

my x265 build was compiled using: https://github.com/jb-alvarado/media-autobuild_suite I ran it on Windows 10 pro 64bit.

Comments (16)

  1. Pradeep Ramachandran Account Deactivated

    Is this only on the multilib build? What happens if you run this on a main12 build (enable HIGH_BIT_DEPTH, and MAIN12 in CMake when compiling).

  2. Selur reporter

    No, this also happens with direct 10bit and 12bit builds. So this isn't a multilib issue, but a general issue.

  3. Pradeep Ramachandran Account Deactivated

    Thanks for confirming that. Our tests already extensively test these builds so I have a fleeting suspicion on the yuv4mpegpipe. Would it be possible for you to decompress the AVI to YUV and then feed that as input to x265 instead of piping the result from ffmpeg?

  4. Selur reporter

    Saving the input as y4m beforehand

    ffmpeg -y -loglevel fatal -threads 8 -i "F:\TestClips&Co\Test-AC3-5.1.avi" -map 0:0 -an -sn  -vsync 0  -strict -1 -pix_fmt yuv422p16le  -f yuv4mpegpipe h:\test.y4m
    x265 --input h:\test.y4m --output-depth 12 --y4m --profile main422-12 --limit-modes --no-open-gop --crf 18.00 --cbqpoffs -2 --crqpoffs -2 --psy-rd 2.50 --rdoq-level 2 --psy-rdoq 15.00 --aq-mode 2 --no-cutree --range limited --colormatrix bt470bg --output "H:\Temp\00_05_00_6210_01.26
    

    also causes x265 to crash.

    I suspect this is related to https://bitbucket.org/multicoreware/x265/issues/322/artifacts-when-encoding-444-10bit-input and might be caused by ffmpeg not properly restricting the ranges of non-420 color spaces. (side note, since x264 and x265 share some code: encoding 10bit 422 with x264 works fine)

  5. Pradeep Ramachandran Account Deactivated

    Thanks for verifying. We do also test 422 and 444 videos (10-bit and 12-bit) in our tests, but clearly this issue isn't being exercised. Would it be possible to share the source with us to root-cause and fix?

  6. Radhakrishnan Venugopal Rajaganesan

    I tried your x265 command line, but it is not crashing for me. x265-log.PNG

    For your ffmpeg command line: ffmpeg -y -loglevel fatal -threads 8 -i "F:\TestClips&Co\Test-AC3-5.1.avi" -map 0:0 -an -sn -vsync 0 -strict -1 -pix_fmt yuv422p16le -f yuv4mpegpipe - | x265 --input - --output-depth 10 --y4m --profile main422-10 --limit-modes --no-open-gop --crf 18.00 --cbqpoffs -2 --crqpoffs -2 --psy-rd 2.50 --rdoq-level 2 --psy-rdoq 15.00 --aq-mode 2 --no-cutree --range limited --colormatrix bt470bg --output "H:\Temp\00_01_57_3410_01.265"

    x265 is reporting error because of mismatch between internal bit depth which is 12 and output bit depth which is 10. When I changed x265's output bit depth and profile to main 12 it is not crashing.

  7. Selur reporter

    I tried your x265 command line, but it is not crashing for me

    strange for me it crashes,... 64bit x265 and 12bit: x265_12bit.png Did you create your test.y4m using ffmpeg and my source?

    x265 is reporting error because of mismatch between internal bit depth which is 12 and output bit depth which is 10. When I changed x265's output bit depth and profile to main 12 it is not crashing.

    a. Here it doesn't report anything to stderr or stdout. It just crashes.

    b. internal bit depth shouldn't be 12bit for "--output-depth 10" and "--profile main422-10"

    Sorry, but my goal with that command was to get 4:2:2 10bit HEVC not 4:2:2 12bit, 4:2:2 16bit.

    So saying that it works for you if you by changing the goal is not really helpful unless you also wanted to say that x265 can't produce 10bit 4:2:2 content and one should switch to another encoder (x264 can create H.264 content with 4:2:2).! Out of curiosity I also made a 32bit build and tried it: x265_32bit.png

  8. Radhakrishnan Venugopal Rajaganesan

    In windows, multilib build generated with visual studio is not crashing.Linux multilib build is crashing.

  9. Radhakrishnan Venugopal Rajaganesan

    Windows multilib build: check the logs working fine in windows multilib build generated with visual studio without fix patch.

    x265 [info]: HEVC encoder version 2.3+2-912dd749bdb5
    x265 [info]: build info [Windows][**MSVC** 1800][64 bit] 8bit+10bit+12bit
    x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
    
    x265.exe --input test.y4m --output-depth 10 --y4m --profile main422-10 --limit-modes --no-open-gop --crf 18.00 --cbqpoffs -2 --crqpoffs -2 --psy-rd 2.50 --rdoq-level 2 --psy-rdoq 15.00 --aq-mode 2 --no-cutree --range limited --colormatrix bt470bg --output 00_05_00_6210_01.265
    y4m  [info]: 640x480 fps 25/1 i422p16 sar 1:1 frames 0 - 834 of 835
    raw  [info]: output file: 00_05_00_6210_01.265
    x265 [info]: HEVC encoder version 2.3+2-912dd749bdb5
    x265 [info]: build info [Windows][MSVC 1800][64 bit] 10bit
    x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
    x265 [info]: Main 4:2:2 10 profile, Level-3 (Main tier)
    x265 [info]: Thread pool created using 4 threads
    x265 [info]: Slices                              : 1
    x265 [info]: frame threads / pool features       : 2 / wpp(8 rows)
    x265 [warning]: Source height < 720p; disabling lookahead-slices
    x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
    x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
    x265 [info]: ME / range / subpel / merge         : hex / 57 / 2 / 2
    x265 [info]: Keyframe min / max / scenecut / bias: 25 / 250 / 40 / 5.00
    x265 [info]: Cb/Cr QP Offset                     : -2 / -2
    x265 [info]: Lookahead / bframes / badapt        : 20 / 4 / 2
    x265 [info]: b-pyramid / weightp / weightb       : 1 / 1 / 0
    x265 [info]: References / ref-limit  cu / depth  : 3 / on / on
    x265 [info]: AQ: mode / str / qg-size / cu-tree  : 2 / 1.0 / 32 / 0
    x265 [info]: Rate Control / qCompress            : CRF-18.0 / 0.60
    x265 [info]: tools: limit-modes rd=3 psy-rd=2.50 rdoq=2 psy-rdoq=15.00 rskip
    x265 [info]: tools: signhide tmvp strong-intra-smoothing deblock sao
    x265 [info]: frame I:      4, Avg QP:6.53  kb/s: 3940.75
    x265 [info]: frame P:    301, Avg QP:7.32  kb/s: 117.18
    x265 [info]: frame B:    530, Avg QP:10.70  kb/s: 13.30
    x265 [info]: Weighted P-Frames: Y:0.0% UV:0.0%
    x265 [info]: consecutive B-frames: 39.7% 7.9% 21.3% 1.3% 29.8%
    
    encoded 835 frames in 9.07s (92.04 fps), 69.56 kb/s, Avg QP:9.46
    

    The same tip is crashing in linux:

    ./x265 --input test.y4m --output-depth 10 --y4m --profile main422-10 --limit-modes --no-open-gop --crf 18.00 --cbqpoffs -2 --crqpoffs -2 --psy-rd 2.50 --rdoq-level 2 --psy-rdoq 15.00 --aq-mode 2 --no-cutree --range limited --colormatrix bt470bg --output 00_05_00_6210_01.265
    y4m  [info]: 640x480 fps 25/1 i422p16 sar 1:1 frames 0 - 834 of 835
    raw  [info]: output file: 00_05_00_6210_01.265
    x265 [info]: HEVC encoder version 2.3+2-912dd749bdb5
    x265 [info]: build info [Linux][GCC 5.4.0][64 bit] 10bit
    x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
    x265 [info]: Main 4:2:2 10 profile, Level-3 (Main tier)
    x265 [info]: Thread pool created using 8 threads
    x265 [info]: Slices                              : 1
    x265 [info]: frame threads / pool features       : 3 / wpp(8 rows)
    x265 [warning]: Source height < 720p; disabling lookahead-slices
    x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
    x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
    x265 [info]: ME / range / subpel / merge         : hex / 57 / 2 / 2
    x265 [info]: Keyframe min / max / scenecut / bias: 25 / 250 / 40 / 5.00
    x265 [info]: Cb/Cr QP Offset                     : -2 / -2
    x265 [info]: Lookahead / bframes / badapt        : 20 / 4 / 2
    x265 [info]: b-pyramid / weightp / weightb       : 1 / 1 / 0
    x265 [info]: References / ref-limit  cu / depth  : 3 / on / on
    x265 [info]: AQ: mode / str / qg-size / cu-tree  : 2 / 1.0 / 32 / 0
    x265 [info]: Rate Control / qCompress            : CRF-18.0 / 0.60
    x265 [info]: tools: limit-modes rd=3 psy-rd=2.50 rdoq=2 psy-rdoq=15.00 rskip
    x265 [info]: tools: signhide tmvp strong-intra-smoothing deblock sao
    Floating point exception (core dumped) kb/s, eta 0:02:03
    

    With the fix patch x265 working fine in linux

  10. Log in to comment