12bpp support

Issue #16 resolved
Steve Borho created an issue

Several customers are very interested in using 12bit input pixels.

There are two relatively understood tasks for this:

1 - test dynamic range of key functions to make sure we do not need to increase intermediate data types. 2 - test performance primitives to ensure they can function correctly at 12bits

Beyond these two issues, it would be good if a single HIGH_BIT_DEPTH build could encode 8, 10, or 12 bit streams and this would require either duplicating a large number of assembly code, or making them aware of the g_bitDepth global variable. But this shouldn't be evaluated until 12bit is functional (it may require substantial changes on its own, requiring 12bit to be a compile time option).

Comments (9)

  1. Steve Borho reporter

    Feedback from a consortium member:

    Yep, having to have three versions of the static library for 8bit, 10 bit and 12 bit encodes would be problematic for us.   So in order of preference, 
    
    1)  It's all handled in a single static library with the different code pieces switched out by you :-)
    2)  Different namespaces for different bit depths
    3)  The DLL option
    
  2. Ben Waggoner

    The size of x265 is pretty minuscule, really. I think it would be good to have the default builds (command line and dll) include support for all three modes, even if they are largely parallel code paths. Needing different binaries and paths makes version control a headache and complicates things for both new users and for app developers.

  3. djcj

    The 10 bit version is able to create 8 bit output, right? On Linux and OSX you could provide x265-10bit and x265-12bit binaries via symbolic links and x265 could make the default output bit depth dependend on its file name.

  4. Steve Borho reporter

    no, currently HIGH_BIT_DEPTH builds can only generate 8bit outputs; though x265 is completely agnostic about input bit depth; any build will accept any input bit depth (and adjust sample size of the input pictures to the internal bit depth)

  5. Former user Account Deleted

    What about 14bit support? (for the future) Not for videos, but for images: there is a new image format that currently supports everything there is http://bellard.org/bpg/

    it is based on HVEC high profile (up to 4:4:4), support 8-14bit depth monochrome encoding (alpha channels)

    in terms of compression it's superior to all formats out there further information can be found on the webpage linked above

    for fast encoding they recommend the usage of x265 but for alpha channels and bit depth up to 14 bit you still need to use JCTVC as an encoder which is of course very slow.

    Of course you can start developing on it later when more important stuff is done, this is just a suggestion.

  6. Steve Borho reporter

    Main12 support is getting started; we hope to have C-only support working soonish, then assembly code coverage will slowly catch up.

    No-one else has requested Main14. HEVC RExt has "Main 4:4:4 16 Intra" and "Main 4:4:4 16 Still Picture" profiles; we would have to implement those, but we would need much more user demand before we embarked on such a large project.

  7. Steve Borho reporter

    Also note that we now support statically linking multiple builds of libx265 into a single binary if you disable the exported C API (all but x265_api_get())

  8. djcj

    By the way I made a Makefile as a replacement for the multilib build script in x265/build/linux. I find it easier or more convenient to use as a Makefile, especially when it comes to using custom build flags.

    CMAKE  := cmake
    MAKE   := make
    AR     := ar
    SOURCE := ../../../source
    PREFIX := /usr/local
    
    ifeq ($(shared),0)
    ENABLE_SHARED = OFF
    ENABLE_PIC    = OFF
    else
    ENABLE_SHARED = ON
    ENABLE_PIC    = ON
    endif
    
    ifeq ($(multilib),0)
    x265     = x265
    builddir = build
    else
    x265     = x265_multilib
    builddir = 8bit
    endif
    
    MAKEFLAGS ?= 
    ifneq ($(DESTDIR),)
    MAKEFLAGS += DESTDIR=$(DESTDIR)
    endif
    
    ifeq ($(V),1)
    VERBOSE = ON
    else
    VERBOSE = OFF
    endif
    
    CXXFLAGS ?= 
    CXXFLAGS += $(CPPFLAGS)
    export CXXFLAGS
    
    
    
    all: $(x265)
    
    clean:
        rm -rf 8bit 10bit 12bit build
    
    distclean: clean
    
    install:
        $(MAKE) -C $(builddir) install $(MAKEFLAGS)
    
    x265:
        mkdir -p build
        cd build && \
            $(CMAKE) $(SOURCE) \
            -DCMAKE_INSTALL_PREFIX=$(PREFIX) \
            -DENABLE_SHARED=$(ENABLE_SHARED) \
            -DENABLE_CLI=ON \
            -DENABLE_PIC=$(ENABLE_PIC) \
            -DLINKED_10BIT=OFF \
            -DLINKED_12BIT=OFF \
            -DCMAKE_VERBOSE_MAKEFILE=$(VERBOSE) \
            $(CMAKEFLAGS)
        $(MAKE) -C build $(MAKEFLAGS)
    
    x265_multilib: 8bit/libx265_main10.a 8bit/libx265_main12.a
        cd 8bit && \
        $(CMAKE) $(SOURCE) \
            -DCMAKE_INSTALL_PREFIX=$(PREFIX) \
            -DHIGH_BIT_DEPTH=OFF \
            -DEXPORT_C_API=ON \
            -DENABLE_SHARED=$(ENABLE_SHARED) \
            -DENABLE_CLI=ON \
            -DENABLE_PIC=$(ENABLE_PIC) \
            -DEXTRA_LIB="x265_main10.a;x265_main12.a" \
            -DEXTRA_LINK_FLAGS=-L. \
            -DLINKED_10BIT=ON \
            -DLINKED_12BIT=ON \
            -DCMAKE_VERBOSE_MAKEFILE=$(VERBOSE) \
            $(CMAKEFLAGS)
        $(MAKE) -C 8bit $(MAKEFLAGS)
        mv -f 8bit/libx265.a 8bit/libx265_main.a
    ifeq ($(shell uname),Linux)
        printf 'CREATE 8bit/libx265.a\nADDLIB 8bit/libx265_main.a\nADDLIB 8bit/libx265_main10.a\nADDLIB 8bit/libx265_main12.a\nSAVE\nEND' | $(AR) -M
    else
        libtool -static -o 8bit/libx265.a 8bit/libx265_main.a $^ 2>/dev/null
    endif
    
    8bit/libx265_main10.a: dirs
        cd 10bit && \
        $(CMAKE) $(SOURCE) \
            $(CMAKEFLAGS) \
            -DHIGH_BIT_DEPTH=ON \
            -DEXPORT_C_API=OFF \
            -DENABLE_SHARED=OFF \
            -DENABLE_CLI=OFF \
            -DENABLE_PIC=$(ENABLE_PIC) \
            -DCMAKE_VERBOSE_MAKEFILE=$(VERBOSE)
        $(MAKE) -C 10bit $(MAKEFLAGS)
        cp -f 10bit/libx265.a $@
    
    8bit/libx265_main12.a: dirs
        cd 12bit && \
        $(CMAKE) $(SOURCE) \
            $(CMAKEFLAGS) \
            -DHIGH_BIT_DEPTH=ON \
            -DEXPORT_C_API=OFF \
            -DENABLE_SHARED=OFF \
            -DENABLE_CLI=OFF \
            -DENABLE_PIC=$(ENABLE_PIC) \
            -DMAIN12=ON \
            -DCMAKE_VERBOSE_MAKEFILE=$(VERBOSE)
        $(MAKE) -C 12bit $(MAKEFLAGS)
        cp -f 12bit/libx265.a $@
    
    dirs:
        mkdir -p 8bit 10bit 12bit
    
  9. Log in to comment