10 bit compression through ffmpeg (-pix_fmt yuv420p10le) does not work anymore.

Issue #171 resolved
rossi mario created an issue

10 bit compression through ffmpeg (-pix_fmt yuv420p10le) does not work anymore. Debian 64bit

whit x265

#!

mc@debian64:~/test$ ffmpeg -i ac36-ch.mkv -loglevel quiet -an -pix_fmt yuv420p -f yuv4mpegpipe - | x265  --preset faster  --crf 23 --no-sao  --aq-mode 3 --rc-lookahead 50 --psy-rd 0.5 -D 10  --y4m   --input - -o out3.y4m 
y4m  [info]: 716x434 fps 25/1 i420p8 sar 209:147 unknown frame count
raw  [info]: output file: out3.y4m
x265 [info]: HEVC encoder version 1.7+427-cc5ceb11f902
x265 [info]: build info [Linux][GCC 4.9.2][64 bit] 10bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.1 Cache64
x265 [info]: Main 10 profile, Level-3 (Main tier)
x265 [info]: Thread pool created using 4 threads
x265 [info]: frame threads / pool features       : 2 / wpp(7 rows)
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       : 25 / 250 / 40
x265 [info]: Lookahead / bframes / badapt        : 50 / 4 / 0
x265 [info]: b-pyramid / weightp / weightb       : 1 / 1 / 0
x265 [info]: References / ref-limit  cu / depth  : 1 / 0 / 0
x265 [info]: AQ: mode / str / qg-size / cu-tree  : 3 / 1.0 / 32 / 0
x265 [info]: Rate Control / qCompress            : CRF-23.0 / 0.60
x265 [info]: tools: rd=2 psy-rd=0.50 early-skip signhide tmvp fast-intra
x265 [info]: tools: strong-intra-smoothing deblock
x265 [info]: frame I:      3, Avg QP:17.66  kb/s: 3891.67                       
x265 [info]: frame P:    103, Avg QP:20.21  kb/s: 1373.20 
x265 [info]: frame B:    416, Avg QP:22.34  kb/s: 483.98  
x265 [info]: Weighted P-Frames: Y:6.8% UV:1.9%
x265 [info]: consecutive B-frames: 0.9% 0.0% 0.0% 0.0% 99.1%

with ffmpeg

mc@debian64:~/test$ ffmpeg -i ac36-ch.mkv  -t 30 -an -c:v libx265 -x265-params crf=22.8:rd=2:psy-rd=.5:aq-mode=3:no-sao=yes:rc-lookahead=40:deblock=-4:ssim=yes:psnr=yes -preset superfast  -pix_fmt yuv420p10le  -f matroska -map_metadata -1  test.mkv
ffmpeg version N-74514-gfffae8e Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.9.2 (Debian 4.9.2-10)
...  
x265 [info]: HEVC encoder version 1.7+427-cc5ceb11f902
x265 [info]: build info [Linux][GCC 4.9.2][64 bit] 8bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.1 Cache64
x265 [warning]: --psnr used with psy on: results will be invalid!
x265 [warning]: --tune psnr should be used if attempting to benchmark psnr!
x265 [info]: Main profile, Level-3 (Main tier)
x265 [info]: Thread pool created using 4 threads
x265 [info]: frame threads / pool features       : 2 / wpp(14 rows)
x265 [info]: Coding QT: max CU size, min CU size : 32 / 8
x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
x265 [info]: ME / range / subpel / merge         : hex / 57 / 1 / 2
x265 [info]: Keyframe min / max / scenecut       : 25 / 250 / 40
x265 [info]: Lookahead / bframes / badapt        : 40 / 3 / 0
x265 [info]: b-pyramid / weightp / weightb       : 1 / 0 / 0
x265 [info]: References / ref-limit  cu / depth  : 1 / 0 / 0
x265 [info]: Rate Control / qCompress            : CRF-22.8 / 0.60
x265 [info]: tools: rd=2 psy-rd=0.50 early-skip signhide tmvp fast-intra
x265 [info]: tools: strong-intra-smoothing deblock(tC=-4:B=-4)
Output #0, matroska, to 'test.mkv':
#!

Comments (11)

  1. rossi mario reporter

    the previous HEVC encoder version 1.7+418-d56b2466c044 work:

    $ ffmpeg-i ac36-ch.mkv  -t 30 -an -c:v libx265 -x265-params crf=22.8:rd=2:psy-rd=.5:aq-mode=3:no-sao=yes:rc-lookahead=40:deblock=-4:ssim=yes:psnr=yes -preset superfast  -pix_fmt yuv420p10le  -f matroska -map_metadata -1  test.mkv
    ffmpeg version N-74390-g8b63a88 Copyright (c) 2000-2015 the FFmpeg developers
      built with gcc 4.9.2 (Debian 4.9.2-10)
    ..  
    x265 [info]: HEVC encoder version 1.7+418-d56b2466c044
    x265 [info]: build info [Linux][GCC 4.9.2][64 bit] 10bit
    x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.1 Cache64
    x265 [warning]: --psnr used with psy on: results will be invalid!
    x265 [warning]: --tune psnr should be used if attempting to benchmark psnr!
    x265 [info]: Main 10 profile, Level-3 (Main tier)
    x265 [info]: Thread pool created using 4 threads
    x265 [info]: frame threads / pool features       : 2 / wpp(14 rows)
    x265 [info]: Coding QT: max CU size, min CU size : 32 / 8
    x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
    x265 [info]: ME / range / subpel / merge         : hex / 57 / 1 / 2
    x265 [info]: Keyframe min / max / scenecut       : 25 / 250 / 40
    x265 [info]: Lookahead / bframes / badapt        : 40 / 3 / 0
    x265 [info]: b-pyramid / weightp / weightb       : 1 / 0 / 0
    x265 [info]: References / ref-limit  cu / depth  : 1 / 0 / 0
    x265 [info]: Rate Control / qCompress            : CRF-22.8 / 0.60
    x265 [info]: tools: rd=2 psy-rd=0.50 early-skip signhide tmvp fast-intra
    x265 [info]: tools: strong-intra-smoothing deblock(tC=-4:B=-4)
    #!
    
  2. rossi mario reporter

    also 1.7+419-c04c48a97472 work:

    $ ffmpeg -i "ac36-ch.mkv" -an -c:v libx265 -x265-params crf=22.8:rd=2:psy-rd=.5:aq-mode=3:no-sao=yes:rc-lookahead=40:deblock=-4:ssim=yes:psnr=yes -preset superfast  -pix_fmt yuv420p10le  -f matroska -map_metadata -1  "test.mkv"
    ffmpeg version N-74390-g8b63a88 Copyright (c) 2000-2015 the FFmpeg developers
      built with gcc 4.9.2 (Debian 4.9.2-10)
    ...
    x265 [info]: HEVC encoder version 1.7+419-c04c48a97472
    x265 [info]: build info [Linux][GCC 4.9.2][64 bit] 10bit
    x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.1 Cache64
    x265 [warning]: --psnr used with psy on: results will be invalid!
    x265 [warning]: --tune psnr should be used if attempting to benchmark psnr!
    x265 [info]: Main 10 profile, Level-3 (Main tier)
    x265 [info]: Thread pool created using 4 threads
    x265 [info]: frame threads / pool features       : 2 / wpp(14 rows)
    x265 [info]: Coding QT: max CU size, min CU size : 32 / 8
    x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
    x265 [info]: ME / range / subpel / merge         : hex / 57 / 1 / 2
    x265 [info]: Keyframe min / max / scenecut       : 25 / 250 / 40
    x265 [info]: Lookahead / bframes / badapt        : 40 / 3 / 0
    x265 [info]: b-pyramid / weightp / weightb       : 1 / 0 / 0
    x265 [info]: References / ref-limit  cu / depth  : 1 / 0 / 0
    x265 [info]: Rate Control / qCompress            : CRF-22.8 / 0.60
    x265 [info]: tools: rd=2 psy-rd=0.50 early-skip signhide tmvp fast-intra
    x265 [info]: tools: strong-intra-smoothing deblock(tC=-4:B=-4)
    #!
    
  3. rossi mario reporter

    revert the commit: b99b494 work in my system:

    #!
    $ ffmpeg -i "ac36-ch.mkv"  -t 30 -an -c:v libx265 -x265-params crf=22.8:rd=2:psy-rd=.5:aq-mode=3:no-sao=yes:rc-lookahead=40:deblock=-4:ssim=yes:psnr=yes -preset superfast  -pix_fmt yuv420p10le  -f matroska -map_metadata -1  "test.mkv"
    ffmpeg version N-74514-gfffae8e Copyright (c) 2000-2015 the FFmpeg developers
      built with gcc 4.9.2 (Debian 4.9.2-10)
    ........
    x265 [info]: HEVC encoder version 1.7+427-cc5ceb11f902 - REVERTED commit b99b494
    x265 [info]: build info [Linux][GCC 4.9.2][64 bit] 10bit
    x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.1 Cache64
    x265 [warning]: --psnr used with psy on: results will be invalid!
    x265 [warning]: --tune psnr should be used if attempting to benchmark psnr!
    x265 [info]: Main 10 profile, Level-3 (Main tier)
    x265 [info]: Thread pool created using 4 threads
    x265 [info]: frame threads / pool features       : 2 / wpp(14 rows)
    x265 [info]: Coding QT: max CU size, min CU size : 32 / 8
    x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
    x265 [info]: ME / range / subpel / merge         : hex / 57 / 1 / 2
    x265 [info]: Keyframe min / max / scenecut       : 25 / 250 / 40
    x265 [info]: Lookahead / bframes / badapt        : 40 / 3 / 0
    x265 [info]: b-pyramid / weightp / weightb       : 1 / 0 / 0
    x265 [info]: References / ref-limit  cu / depth  : 1 / 0 / 0
    x265 [info]: Rate Control / qCompress            : CRF-22.8 / 0.60
    x265 [info]: tools: rd=2 psy-rd=0.50 early-skip signhide tmvp fast-intra
    x265 [info]: tools: strong-intra-smoothing deblock(tC=-4:B=-4)
    ...
    encoded 749 frames in 21.69s (34.54 fps), 638.33 kb/s, Avg QP:25.20, Global PSNR: 44.747, SSIM Mean Y: 0.9740784 (15.863 dB)
    
  4. rossi mario reporter

    1.7+427-cc5ceb11f902 + Ma0 api.diff:

    #!
    $ ffmpeg -i "ac36-ch.mkv"  -t 30 -an -c:v libx265 -x265-params crf=22.8:psnr=1 -preset superfast  -f matroska -map_metadata -1  "ac36-ch x265.mkv"
    ffmpeg version N-74514-gfffae8e Copyright (c) 2000-2015 the FFmpeg developers
    ...
    x265 [info]: HEVC encoder version 1.7+427-cc5ceb11f902 [+ api.diff]
    x265 [info]: build info [Linux][GCC 4.9.2][64 bit] 8bit
    x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.1 Cache64
    ...
    encoded 749 frames in 17.75s (42.21 fps), 655.58 kb/s, Avg QP:25.13, Global PSNR: 44.642
    
    
    $ ffmpeg -i "ac36-ch.mkv"  -t 30 -an -c:v libx265 -x265-params crf=22.8:psnr=1 -preset superfast  -pix_fmt yuv420p10le  -f matroska -map_metadata -1  "ac36-ch x265_2_.mkv"
    ffmpeg version N-74514-gfffae8e Copyright (c) 2000-2015 the FFmpeg developers
    ...
    x265 [info]: HEVC encoder version 1.7+427-cc5ceb11f902 [+ api.diff]
    x265 [info]: build info [Linux][GCC 4.9.2][64 bit] 10bit
    x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.1 Cache64
    ...
    encoded 749 frames in 21.74s (34.45 fps), 642.00 kb/s, Avg QP:25.20, Global PSNR: 45.040
    
  5. Steve Borho

    Does this simpler fix work?

    # HG changeset patch
    # User Steve Borho <steve@borho.org>
    # Date 1440042668 -19800
    #      Thu Aug 20 09:21:08 2015 +0530
    # Branch stable
    # Node ID c8fb20a9e6048507bff10efcefc51b40f988c2ae
    # Parent  b4ea62725219c3c8a784a33998d97147d763f603
    api: move recursion check to just before generic libx265 load (fixes #171)
    
    diff -r b4ea62725219 -r c8fb20a9e604 source/encoder/api.cpp
    --- a/source/encoder/api.cpp    Wed Aug 19 13:59:38 2015 +0530
    +++ b/source/encoder/api.cpp    Thu Aug 20 09:21:08 2015 +0530
    @@ -342,11 +342,6 @@
     {
         if (bitDepth && bitDepth != X265_DEPTH)
         {
    -        if (g_recursion)
    -            return NULL;
    -        else
    -            g_recursion = 1;
    -
     #if LINKED_8BIT
             if (bitDepth == 8) return x265_8bit::x265_api_get(0);
     #endif
    @@ -377,6 +372,11 @@
             HMODULE h = LoadLibraryA(libname);
             if (!h)
             {
    +            if (g_recursion)
    +                return NULL;
    +            else
    +                g_recursion = 1;
    +
                 h = LoadLibraryA(multilibname);
                 reqDepth = bitDepth;
             }
    @@ -390,6 +390,11 @@
             void* h = dlopen(libname, RTLD_LAZY | RTLD_LOCAL);
             if (!h)
             {
    +            if (g_recursion)
    +                return NULL;
    +            else
    +                g_recursion = 1;
    +
                 h = dlopen(multilibname, RTLD_LAZY | RTLD_LOCAL);
                 reqDepth = bitDepth;
             }
    @@ -422,14 +427,6 @@
             return NULL;
         }
    
    -    if (g_recursion)
    -    {
    -        if (err) *err = X265_API_QUERY_ERR_LIB_NOT_FOUND;
    -        return NULL;
    -    }
    -    else
    -        g_recursion = 1;
    -
         if (err) *err = X265_API_QUERY_ERR_NONE;
    
         if (bitDepth && bitDepth != X265_DEPTH)
    @@ -468,6 +465,14 @@
             HMODULE h = LoadLibraryA(libname);
             if (!h)
             {
    +            if (g_recursion)
    +            {
    +                if (err) *err = X265_API_QUERY_ERR_LIB_NOT_FOUND;
    +                return NULL;
    +            }
    +            else
    +                g_recursion = 1;
    +
                 h = LoadLibraryA(multilibname);
                 reqDepth = bitDepth;
             }
    @@ -482,6 +487,14 @@
             void* h = dlopen(libname, RTLD_LAZY | RTLD_LOCAL);
             if (!h)
             {
    +            if (g_recursion)
    +            {
    +                if (err) *err = X265_API_QUERY_ERR_LIB_NOT_FOUND;
    +                return NULL;
    +            }
    +            else
    +                g_recursion = 1;
    +
                 h = dlopen(multilibname, RTLD_LAZY | RTLD_LOCAL);
                 reqDepth = bitDepth;
             }
    
  6. Steve Borho

    FYI: there's a reason we request bit-depth 0 most of the time. This is to prevent an infinite recursion from a misnamed library. A 10bit library named libx265_main12 would cause an infinite recursion loop if we requested bit depth 12 from it.

  7. Ma0

    I think you should check this first. Result from my tests (3 test is 10bit exe + 10bit libx265_main12.dll + 12 bit libx265.dll):

    i:\t3\x265\build\ma>x265-10b -V
    x265 [info]: HEVC encoder version 1.7+427-cc5ceb11f902
    x265 [info]: build info [Windows][GCC 5.2.0][64 bit] 10bit
    x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
    
    i:\t3\x265\build\ma>x265-10b -D12 -V
    x265 [warning]: falling back to default bit-depth
    x265 [info]: HEVC encoder version 1.7+427-cc5ceb11f902
    x265 [info]: build info [Windows][GCC 5.2.0][64 bit] 10bit
    x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
    
    i:\t3\x265\build\ma>x265-10b -D12 -V
    x265 [info]: HEVC encoder version 1.7+427-cc5ceb11f902
    x265 [info]: build info [Windows][GCC 5.2.0][64 bit] 12bit
    x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
    
  8. rossi mario reporter

    1.7+427-cc5ceb11f902 + Steve Borho patch work fine:

    #!
    mc@debian64:~/test$ ffmpeg2 -i "ac36-ch.mkv"  -t 10 -an -c:v libx265 -x265-params crf=22.8:ssim=yes:psnr=yes -preset superfast  -f matroska  "ac36-ch x265.mkv"                       
    ffmpeg version N-74514-gfffae8e Copyright (c) 2000-2015 the FFmpeg developers
      built with gcc 4.9.2 (Debian 4.9.2-10)
    ... 
    x265 [info]: HEVC encoder version 1.7+427-cc5ceb11f902
    x265 [info]: build info [Linux][GCC 4.9.2][64 bit] 8bit
    x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.1 Cache64
    ...
    encoded 249 frames in 4.25s (58.58 fps), 274.46 kb/s, Avg QP:23.52, Global PSNR: 46.107, SSIM Mean Y: 0.9796039 (16.905 dB)
    
    
    mc@debian64:~/test$ ffmpeg2 -i "ac36-ch.mkv"  -t 10 -an -c:v libx265 -x265-params crf=22.8:ssim=yes:psnr=yes -preset superfast  -pix_fmt yuv420p10le  -f matroska  "ac36-ch x265.mkv"
    ffmpeg version N-74514-gfffae8e Copyright (c) 2000-2015 the FFmpeg developers
      built with gcc 4.9.2 (Debian 4.9.2-10)
    ... 
    x265 [info]: HEVC encoder version 1.7+427-cc5ceb11f902
    x265 [info]: build info [Linux][GCC 4.9.2][64 bit] 10bit
    x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.1 Cache64
    ...
    encoded 249 frames in 5.29s (47.11 fps), 267.72 kb/s, Avg QP:23.54, Global PSNR: 46.645, SSIM Mean Y: 0.9824464 (17.556 dB)
    
    
    
    mc@debian64:~$ x265 -V
    x265 [info]: HEVC encoder version 1.7+427-cc5ceb11f902
    x265 [info]: build info [Linux][GCC 4.9.2][64 bit] 8bit
    x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.1 Cache64
    
    mc@debian64:~$ x265 -V -D10
    x265 [info]: HEVC encoder version 1.7+427-cc5ceb11f902
    x265 [info]: build info [Linux][GCC 4.9.2][64 bit] 10bit
    x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.1 Cache64
    
    mc@debian64:~$ x265 -V -D12
    x265 [info]: HEVC encoder version 1.7+427-cc5ceb11f902
    x265 [info]: build info [Linux][GCC 4.9.2][64 bit] 12bit
    x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.1 Cache64
    

    lib265.so.71 build with build/linux/multilib.sh

  9. Log in to comment