├── sherlock265 ├── .gitignore ├── COPYING ├── README ├── Makefile.am ├── sherlock265.cc ├── VideoPlayer.hh ├── VideoWidget.hh ├── VideoWidget.cc └── VideoDecoder.hh ├── README ├── valgrind.supp ├── NEWS ├── libde265.png ├── ChangeLog ├── Makefile.vc7 ├── AUTHORS ├── libde265.pc.in ├── enc265 ├── CMakeLists.txt ├── Makefile.am ├── Makefile.vc7 ├── COPYING ├── image-io-png.h └── image-io-png.cc ├── ci.sh ├── libde265 ├── wasm │ ├── CMakeLists.txt │ ├── simd.h │ ├── simd-dct.h │ └── simd.cc ├── encoder │ ├── CMakeLists.txt │ ├── algo │ │ ├── CMakeLists.txt │ │ ├── Makefile.am │ │ ├── tb-rateestim.cc │ │ ├── ctb-qscale.cc │ │ ├── cb-skip.h │ │ ├── cb-intra-inter.h │ │ ├── cb-mergeindex.h │ │ ├── cb-split.h │ │ ├── algo.cc │ │ ├── tb-transform.h │ │ ├── ctb-qscale.h │ │ ├── cb-interpartmode.h │ │ ├── algo.h │ │ ├── cb-skip.cc │ │ └── tb-rateestim.h │ ├── Makefile.am │ ├── encoder-motion.h │ ├── encoder-intrapred.h │ ├── encoder-motion.cc │ ├── encoder-params.cc │ ├── sop.cc │ ├── encoder-params.h │ └── encoder-syntax.h ├── x86 │ ├── Makefile.am │ ├── sse.h │ ├── CMakeLists.txt │ ├── avx-motion.h │ └── sse-dct.h ├── arm │ ├── Makefile.am │ ├── arm.h │ ├── cpudetect.S │ └── neon.S ├── fallback.h ├── deblock.h ├── de265-version.h.in ├── scan.h ├── sao.h ├── md5.h ├── alloc_pool.h ├── quality.h ├── bitstream.h ├── visualize.h ├── refpic.h ├── transform.h ├── alloc_pool.cc ├── Makefile.am ├── Makefile.vc7 ├── quality.cc ├── sei.h ├── image-io.h ├── CMakeLists.txt └── bitstream.cc ├── acceleration-speed ├── Makefile.am ├── dct-scalar.cc ├── acceleration-speed.h ├── dct.h └── dct.cc ├── Makefile.am ├── dec265 ├── Makefile.vc7 ├── CMakeLists.txt ├── Makefile.am ├── COPYING ├── sdl.hh └── hdrcopy.cc ├── .gitignore ├── extra ├── libde265 │ └── de265-version.h ├── stdbool.h ├── win32cond.h └── getopt.h ├── autogen.sh ├── appveyor.yml ├── scripts ├── ci-before-script.sh ├── ci-before-install-osx.sh ├── check_licenses.sh ├── ci-before-install-linux.sh └── ci-run.sh ├── tools ├── Makefile.am ├── tests.cc ├── yuv-distortion.cc └── block-rate-estim.cc ├── m4 ├── visibility.m4 └── m4_ax_check_compile_flag.m4 ├── CMakeLists.txt └── .travis.yml /sherlock265/.gitignore: -------------------------------------------------------------------------------- 1 | moc_*.cpp 2 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | See README.md for further information. 2 | -------------------------------------------------------------------------------- /valgrind.supp: -------------------------------------------------------------------------------- 1 | # Add valgrind suppressions here. 2 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | See https://github.com/strukturag/libde265 for further information. 2 | -------------------------------------------------------------------------------- /libde265.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenIPC/libde265/HEAD/libde265.png -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | See https://github.com/strukturag/libde265 for further information. 2 | -------------------------------------------------------------------------------- /Makefile.vc7: -------------------------------------------------------------------------------- 1 | clean all: 2 | cd libde265 && $(MAKE) -f Makefile.vc7 $* 3 | cd dec265 && $(MAKE) -f Makefile.vc7 $* 4 | cd enc265 && $(MAKE) -f Makefile.vc7 $* 5 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Authors of libde265 2 | See also the files THANKS and ChangeLog 3 | 4 | Dirk Farin 5 | - designed and implemented libde265 6 | 7 | Joachim Bauch 8 | - bugfixes, optimizations and support for Windows 9 | -------------------------------------------------------------------------------- /libde265.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libde265 7 | Description: H.265/HEVC video decoder. 8 | URL: https://github.com/strukturag/libde265 9 | Version: @VERSION@ 10 | Requires: 11 | Libs: -lde265 -L@libdir@ 12 | Libs.private: @LIBS@ -lstdc++ 13 | Cflags: -I@includedir@ 14 | -------------------------------------------------------------------------------- /enc265/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable (enc265 2 | enc265.cc 3 | image-io-png.cc 4 | ) 5 | 6 | if(MSVC) 7 | target_sources(enc265 PRIVATE 8 | ../extra/getopt.c 9 | ../extra/getopt_long.c 10 | ) 11 | endif() 12 | 13 | target_link_libraries (enc265 PRIVATE ${PROJECT_NAME}) 14 | 15 | install (TARGETS enc265 DESTINATION ${CMAKE_INSTALL_BINDIR}) 16 | -------------------------------------------------------------------------------- /ci.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | 4 | function build { 5 | rm -rf build 6 | $1 -H. -Bbuild $2|| return 1 7 | pushd build 8 | make -j$(nproc) || return 1 9 | popd 10 | return 0 11 | } 12 | 13 | set -e 14 | build "cmake -DDISABLE_SIMD=ON" 15 | build "cmake -DDISABLE_SIMD=OFF" 16 | build "emcmake cmake -DDISABLE_SIMD=ON" 17 | build "emcmake cmake -DDISABLE_SIMD=OFF" 18 | -------------------------------------------------------------------------------- /enc265/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | bin_PROGRAMS = enc265 3 | 4 | AM_CPPFLAGS = -I$(top_srcdir)/libde265 -I$(top_srcdir) 5 | 6 | enc265_DEPENDENCIES = ../libde265/libde265.la 7 | enc265_CXXFLAGS = 8 | enc265_LDFLAGS = 9 | enc265_LDADD = ../libde265/libde265.la -lstdc++ 10 | enc265_SOURCES = enc265.cc image-io-png.cc image-io-png.h 11 | 12 | if HAVE_VIDEOGFX 13 | enc265_CXXFLAGS += $(VIDEOGFX_CFLAGS) 14 | enc265_LDFLAGS += $(VIDEOGFX_LIBS) 15 | endif 16 | 17 | EXTRA_DIST = \ 18 | CMakeLists.txt \ 19 | Makefile.vc7 20 | -------------------------------------------------------------------------------- /libde265/wasm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set (wasm_sources 2 | simd.cc simd.h 3 | ) 4 | 5 | set (wasm_simd_sources 6 | simd-motion.cc simd-motion.h simd-dct.h simd-dct.cc 7 | ) 8 | 9 | add_library(wasm OBJECT ${wasm_sources}) 10 | 11 | add_library(wasm_simd OBJECT ${wasm_simd_sources}) 12 | 13 | set(wasm_flags "-msse4.2 -msimd128 -fno-vectorize") 14 | 15 | set(WASM_OBJECTS $ $ PARENT_SCOPE) 16 | 17 | set_target_properties(wasm_simd PROPERTIES COMPILE_FLAGS "${wasm_flags}") 18 | -------------------------------------------------------------------------------- /acceleration-speed/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | bin_PROGRAMS = acceleration_speed 3 | 4 | AM_CPPFLAGS = -I$(top_srcdir)/libde265 -I$(top_srcdir) 5 | 6 | acceleration_speed_DEPENDENCIES = ../libde265/libde265.la 7 | acceleration_speed_CXXFLAGS = 8 | acceleration_speed_LDFLAGS = 9 | acceleration_speed_LDADD = ../libde265/libde265.la -lstdc++ 10 | acceleration_speed_SOURCES = \ 11 | acceleration-speed.cc acceleration-speed.h \ 12 | dct.cc dct.h \ 13 | dct-scalar.cc dct-scalar.h 14 | 15 | if ENABLE_SSE_OPT 16 | acceleration_speed_SOURCES += dct-sse.cc 17 | endif 18 | -------------------------------------------------------------------------------- /libde265/encoder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set (encoder_sources 2 | encoder-core.cc encoder-core.h 3 | encoder-types.h encoder-types.cc 4 | encoder-params.h encoder-params.cc 5 | encoder-context.h encoder-context.cc 6 | encoder-syntax.h encoder-syntax.cc 7 | encoder-intrapred.h encoder-intrapred.cc 8 | encoder-motion.h encoder-motion.cc 9 | encpicbuf.h encpicbuf.cc 10 | sop.h sop.cc 11 | ) 12 | 13 | add_subdirectory (algo) 14 | add_library(encoder OBJECT ${encoder_sources}) 15 | set(ENCODER_OBJECTS $ ${ALGO_OBJECTS} PARENT_SCOPE) 16 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ## Makefile.am for libde265 2 | 3 | SUBDIRS = libde265 4 | 5 | ACLOCAL_AMFLAGS = -I m4 6 | 7 | if ENABLE_DEC265 8 | SUBDIRS+=dec265 9 | endif 10 | 11 | if ENABLE_ENCODER 12 | SUBDIRS+=enc265 13 | endif 14 | 15 | SUBDIRS+=tools 16 | SUBDIRS+=acceleration-speed 17 | 18 | if ENABLE_SHERLOCK265 19 | SUBDIRS+=sherlock265 20 | endif 21 | 22 | EXTRA_DIST = .travis.yml \ 23 | autogen.sh \ 24 | build.bat \ 25 | m4/m4_ax_check_compile_flag.m4 \ 26 | Makefile.vc7 \ 27 | CMakeLists.txt \ 28 | README.md \ 29 | libde265.png \ 30 | */COPYING 31 | 32 | pkgconfigdir = $(libdir)/pkgconfig 33 | pkgconfig_DATA = libde265.pc 34 | -------------------------------------------------------------------------------- /libde265/encoder/algo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set (algo_sources 2 | algo.h algo.cc 3 | coding-options.h coding-options.cc 4 | ctb-qscale.h ctb-qscale.cc 5 | cb-split.h cb-split.cc 6 | cb-intrapartmode.h cb-intrapartmode.cc 7 | cb-interpartmode.h cb-interpartmode.cc 8 | cb-skip.h cb-skip.cc 9 | cb-intra-inter.h cb-intra-inter.cc 10 | cb-mergeindex.h cb-mergeindex.cc 11 | tb-split.h tb-split.cc 12 | tb-transform.h tb-transform.cc 13 | tb-intrapredmode.h tb-intrapredmode.cc 14 | tb-rateestim.h tb-rateestim.cc 15 | pb-mv.h pb-mv.cc 16 | ) 17 | 18 | add_library(algo OBJECT ${algo_sources}) 19 | set(ALGO_OBJECTS $ PARENT_SCOPE) 20 | -------------------------------------------------------------------------------- /libde265/encoder/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libde265_encoder.la 2 | 3 | libde265_encoder_la_CXXFLAGS = -I$(top_srcdir) -I$(top_builddir) -I$(top_srcdir)/libde265 4 | libde265_encoder_la_SOURCES = \ 5 | encoder-core.cc encoder-core.h \ 6 | encoder-types.h encoder-types.cc \ 7 | encoder-params.h encoder-params.cc \ 8 | encoder-context.h encoder-context.cc \ 9 | encoder-syntax.h encoder-syntax.cc \ 10 | encoder-intrapred.h encoder-intrapred.cc \ 11 | encoder-motion.h encoder-motion.cc \ 12 | encpicbuf.h encpicbuf.cc \ 13 | sop.h sop.cc 14 | 15 | SUBDIRS=algo 16 | libde265_encoder_la_LIBADD = algo/libde265_encoder_algo.la 17 | 18 | EXTRA_DIST = \ 19 | CMakeLists.txt 20 | -------------------------------------------------------------------------------- /libde265/x86/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libde265_x86.la libde265_x86_sse.la 2 | 3 | libde265_x86_la_CXXFLAGS = -I$(top_srcdir)/libde265 $(CFLAG_VISIBILITY) 4 | libde265_x86_la_SOURCES = sse.cc sse.h 5 | libde265_x86_la_LIBADD = libde265_x86_sse.la 6 | 7 | if HAVE_VISIBILITY 8 | libde265_x86_la_CXXFLAGS += -DHAVE_VISIBILITY 9 | endif 10 | 11 | 12 | # SSE4 specific functions 13 | 14 | libde265_x86_sse_la_CXXFLAGS = -msse4.1 -I$(top_srcdir) -I$(top_srcdir)/libde265 $(CFLAG_VISIBILITY) 15 | libde265_x86_sse_la_SOURCES = sse-motion.cc sse-motion.h sse-dct.h sse-dct.cc 16 | 17 | if HAVE_VISIBILITY 18 | libde265_x86_sse_la_CXXFLAGS += -DHAVE_VISIBILITY 19 | endif 20 | 21 | EXTRA_DIST = \ 22 | CMakeLists.txt 23 | -------------------------------------------------------------------------------- /libde265/encoder/algo/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libde265_encoder_algo.la 2 | 3 | libde265_encoder_algo_la_CXXFLAGS = -I$(top_srcdir) -I$(top_builddir) 4 | libde265_encoder_algo_la_SOURCES = \ 5 | algo.h algo.cc \ 6 | coding-options.h coding-options.cc \ 7 | ctb-qscale.h ctb-qscale.cc \ 8 | cb-split.h cb-split.cc \ 9 | cb-intrapartmode.h cb-intrapartmode.cc \ 10 | cb-interpartmode.h cb-interpartmode.cc \ 11 | cb-skip.h cb-skip.cc \ 12 | cb-intra-inter.h cb-intra-inter.cc \ 13 | cb-mergeindex.h cb-mergeindex.cc \ 14 | tb-split.h tb-split.cc \ 15 | tb-transform.h tb-transform.cc \ 16 | tb-intrapredmode.h tb-intrapredmode.cc \ 17 | tb-rateestim.h tb-rateestim.cc \ 18 | pb-mv.h pb-mv.cc 19 | 20 | EXTRA_DIST = \ 21 | CMakeLists.txt 22 | -------------------------------------------------------------------------------- /dec265/Makefile.vc7: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Microsoft Visual Studio 2003 3 | # 4 | CFLAGS=/I.. /I..\libde265 /I..\extra 5 | CC=cl /nologo 6 | LINK=link /nologo /subsystem:console 7 | DEFINES=/DWIN32 8 | 9 | CFLAGS=$(CFLAGS) /MT /Ob2 /Oi /W4 /EHsc 10 | CFLAGS=$(CFLAGS) $(DEFINES) 11 | 12 | # unreferenced formal parameter 13 | CFLAGS=$(CFLAGS) /wd4100 14 | 15 | OBJS=\ 16 | ..\extra\getopt_long.obj \ 17 | ..\extra\getopt.obj \ 18 | dec265.obj 19 | 20 | all: dec265.exe 21 | 22 | dec265.obj: dec265.cc 23 | $(CC) /c $*.cc /Fo$*.obj /TP $(CFLAGS) 24 | 25 | .c.obj: 26 | $(CC) /c $*.c /Fo$*.obj $(CFLAGS) 27 | 28 | .cc.obj: 29 | $(CC) /c $*.cc /Fo$*.obj $(CFLAGS) 30 | 31 | dec265.exe: $(OBJS) ..\libde265\libde265.lib 32 | $(LINK) /out:dec265.exe $** ..\libde265\libde265.lib 33 | 34 | clean: 35 | del dec265.exe 36 | del $(OBJS) 37 | -------------------------------------------------------------------------------- /enc265/Makefile.vc7: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Microsoft Visual Studio 2003 3 | # 4 | CFLAGS=/I.. /I..\libde265 /I..\extra 5 | CC=cl /nologo 6 | LINK=link /nologo /subsystem:console 7 | DEFINES=/DWIN32 8 | 9 | CFLAGS=$(CFLAGS) /MT /Ob2 /Oi /W4 /EHsc 10 | CFLAGS=$(CFLAGS) $(DEFINES) 11 | 12 | # unreferenced formal parameter 13 | CFLAGS=$(CFLAGS) /wd4100 14 | 15 | 16 | OBJS=\ 17 | ..\extra\getopt_long.obj \ 18 | ..\extra\getopt.obj \ 19 | enc265.obj 20 | 21 | all: enc265.exe 22 | 23 | enc265.obj: enc265.cc 24 | $(CC) /c $*.cc /Fo$*.obj /TP $(CFLAGS) 25 | 26 | .c.obj: 27 | $(CC) /c $*.c /Fo$*.obj $(CFLAGS) 28 | 29 | .cc.obj: 30 | $(CC) /c $*.cc /Fo$*.obj $(CFLAGS) 31 | 32 | enc265.exe: $(OBJS) ..\libde265\libde265.lib 33 | $(LINK) /out:enc265.exe $** ..\libde265\libde265.lib 34 | 35 | clean: 36 | del enc265.exe 37 | del $(OBJS) 38 | -------------------------------------------------------------------------------- /dec265/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable (dec265 dec265.cc) 2 | 3 | target_link_libraries (dec265 PRIVATE ${PROJECT_NAME}) 4 | 5 | if(SDL_FOUND) 6 | target_sources(dec265 PRIVATE sdl.cc) 7 | target_compile_definitions(dec265 PRIVATE HAVE_SDL) 8 | target_include_directories (dec265 PRIVATE "${SDL_INCLUDE_DIR}") 9 | target_link_libraries (dec265 PRIVATE ${SDL_LIBRARY}) 10 | endif() 11 | 12 | if(MSVC) 13 | target_sources(dec265 PRIVATE 14 | ../extra/getopt.c 15 | ../extra/getopt_long.c 16 | ) 17 | endif() 18 | 19 | install (TARGETS dec265 DESTINATION ${CMAKE_INSTALL_BINDIR}) 20 | 21 | if(NOT MSVC) 22 | # hdrcopy uses internal APIs that are not available when compiled for Windows 23 | add_executable (hdrcopy hdrcopy.cc) 24 | 25 | target_link_libraries (hdrcopy PRIVATE ${PROJECT_NAME}) 26 | 27 | install (TARGETS hdrcopy DESTINATION ${CMAKE_INSTALL_BINDIR}) 28 | endif() 29 | -------------------------------------------------------------------------------- /dec265/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | bin_PROGRAMS = dec265 hdrcopy 3 | 4 | AM_CPPFLAGS = -I$(top_srcdir)/libde265 -I$(top_srcdir) 5 | 6 | dec265_DEPENDENCIES = ../libde265/libde265.la 7 | dec265_CXXFLAGS = 8 | dec265_LDFLAGS = 9 | dec265_LDADD = ../libde265/libde265.la -lstdc++ 10 | dec265_SOURCES = dec265.cc 11 | 12 | hdrcopy_DEPENDENCIES = ../libde265/libde265.la 13 | hdrcopy_CXXFLAGS = 14 | hdrcopy_LDFLAGS = 15 | hdrcopy_LDADD = ../libde265/libde265.la -lstdc++ 16 | hdrcopy_SOURCES = hdrcopy.cc 17 | 18 | if HAVE_VIDEOGFX 19 | dec265_CXXFLAGS += $(VIDEOGFX_CFLAGS) 20 | dec265_LDFLAGS += $(VIDEOGFX_LIBS) 21 | endif 22 | 23 | if HAVE_SDL 24 | dec265_CXXFLAGS += $(SDL_CFLAGS) 25 | dec265_LDFLAGS += $(SDL_LIBS) 26 | dec265_SOURCES += sdl.cc sdl.hh 27 | endif 28 | 29 | if MINGW 30 | dec265_LDFLAGS += -static-libgcc -static-libstdc++ 31 | endif 32 | 33 | EXTRA_DIST = Makefile.vc7 \ 34 | CMakeLists.txt \ 35 | ../extra/getopt.c \ 36 | ../extra/getopt.h \ 37 | ../extra/getopt_long.c 38 | -------------------------------------------------------------------------------- /libde265/arm/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libde265_arm.la 2 | 3 | libde265_arm_la_CXXFLAGS = -I.. $(CFLAG_VISIBILITY) 4 | libde265_arm_la_SOURCES = arm.cc arm.h 5 | libde265_arm_la_LIBADD = 6 | 7 | if HAVE_VISIBILITY 8 | libde265_arm_la_CXXFLAGS += -DHAVE_VISIBILITY 9 | endif 10 | 11 | 12 | if ENABLE_NEON_OPT 13 | # NEON specific functions 14 | 15 | noinst_LTLIBRARIES += libde265_arm_neon.la 16 | libde265_arm_la_LIBADD += libde265_arm_neon.la 17 | libde265_arm_neon_la_CXXFLAGS = -mfpu=neon -I.. $(CFLAG_VISIBILITY) 18 | libde265_arm_neon_la_CCASFLAGS = -mfpu=neon -I.. \ 19 | -DHAVE_NEON \ 20 | -DEXTERN_ASM= \ 21 | -DHAVE_AS_FUNC \ 22 | -DHAVE_SECTION_DATA_REL_RO 23 | 24 | if ENABLE_ARM_THUMB 25 | libde265_arm_neon_la_CCASFLAGS += -DCONFIG_THUMB 26 | endif 27 | 28 | libde265_arm_neon_la_SOURCES = \ 29 | asm.S \ 30 | cpudetect.S \ 31 | hevcdsp_qpel_neon.S \ 32 | neon.S 33 | 34 | if HAVE_VISIBILITY 35 | libde265_arm_neon_la_CXXFLAGS += -DHAVE_VISIBILITY 36 | endif 37 | 38 | endif 39 | -------------------------------------------------------------------------------- /libde265/wasm/simd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2020, Dmitry Ilyin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #ifndef DE265_SIMD_H 22 | #define DE265_SIMD_H 23 | 24 | #include "acceleration.h" 25 | 26 | void init_acceleration_functions_wasm(struct acceleration_functions *accel); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | .libs 3 | .dirstamp 4 | .gitignore 5 | *.o 6 | *.lo 7 | *~ 8 | Makefile 9 | Makefile.in 10 | config.log 11 | config.h 12 | config.h.in 13 | config.status 14 | config.guess 15 | config.sub 16 | stamp-h1 17 | configure 18 | *.obj 19 | *.la 20 | de265-config.h 21 | libde265.pc 22 | 23 | # MSVC 24 | *.sln 25 | *.ncb 26 | *.suo 27 | *.vcproj* 28 | 29 | # Automake generated files 30 | /m4/libtool.m4 31 | /m4/ltoptions.m4 32 | /m4/ltsugar.m4 33 | /m4/ltversion.m4 34 | /m4/lt~obsolete.m4 35 | /aclocal.m4 36 | /ar-lib 37 | /autom4te.cache/ 38 | /missing 39 | /install-sh 40 | /INSTALL 41 | /test-driver 42 | /compile 43 | /depcomp 44 | /libtool 45 | /ltmain.sh 46 | /stamp-h1 47 | /test-suite.log 48 | 49 | # ctags 50 | tags 51 | 52 | # other 53 | acceleration-speed/acceleration_speed 54 | dec265/dec265 55 | dec265/hdrcopy 56 | enc265/enc265 57 | libde265/de265-version.h 58 | sherlock265/sherlock265 59 | tools/bjoentegaard 60 | tools/block-rate-estim 61 | tools/gen-enc-table 62 | tools/rd-curves 63 | tools/tests 64 | tools/yuv-distortion 65 | -------------------------------------------------------------------------------- /libde265/x86/sse.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #ifndef DE265_SSE_H 22 | #define DE265_SSE_H 23 | 24 | #include "acceleration.h" 25 | 26 | void init_acceleration_functions_sse(struct acceleration_functions* accel); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /libde265/fallback.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #ifndef DE265_FALLBACK_H 22 | #define DE265_FALLBACK_H 23 | 24 | #include "acceleration.h" 25 | 26 | void init_acceleration_functions_fallback(struct acceleration_functions* lowlevel); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /libde265/arm/arm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2015 struktur AG, Joachim Bauch 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #ifndef LIBDE265_ARM_H 22 | #define LIBDE265_ARM_H 23 | 24 | #include "acceleration.h" 25 | 26 | void init_acceleration_functions_arm(struct acceleration_functions* accel); 27 | 28 | #endif // LIBDE265_ARM_H 29 | -------------------------------------------------------------------------------- /extra/libde265/de265-version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #ifndef LIBDE265_VERSION_H 22 | #define LIBDE265_VERSION_H 23 | 24 | /* Numeric representation of the version */ 25 | #define LIBDE265_NUMERIC_VERSION 0x01000800 26 | 27 | #define LIBDE265_VERSION "1.0.8" 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /libde265/deblock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #ifndef DE265_DEBLOCK_H 22 | #define DE265_DEBLOCK_H 23 | 24 | #include "libde265/decctx.h" 25 | 26 | void add_deblocking_tasks(image_unit* imgunit); 27 | void apply_deblocking_filter(de265_image* img); //decoder_context* ctx); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /libde265/x86/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set (x86_sources 2 | sse.cc sse.h 3 | ) 4 | 5 | set (x86_sse_sources 6 | sse-motion.cc sse-motion.h sse-dct.h sse-dct.cc 7 | ) 8 | 9 | set (x86_avx_sources 10 | avx-motion.cc 11 | ) 12 | 13 | add_library(x86 OBJECT ${x86_sources}) 14 | 15 | add_library(x86_sse OBJECT ${x86_sse_sources}) 16 | set(sse_flags "") 17 | 18 | if(MSVC) 19 | elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") 20 | set(sse_flags "${sse_flags} -xSSE4.2") 21 | else() 22 | set(sse_flags "${sse_flags} -msse4.1") 23 | endif() 24 | 25 | if (SUPPORTS_AVX) 26 | add_library(x86_avx OBJECT ${x86_avx_sources}) 27 | set(avx_flags "") 28 | 29 | if(MSVC) 30 | set(avx_flags "${avx_flags} /arch:AVX") 31 | elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") 32 | set(avx_flags "${avx_flags} -xAVX") 33 | else() 34 | set(avx_flags "${avx_flags} -mavx2") 35 | endif() 36 | endif() 37 | 38 | set(X86_OBJECTS $ $ $ PARENT_SCOPE) 39 | 40 | SET_TARGET_PROPERTIES(x86_sse PROPERTIES COMPILE_FLAGS "${sse_flags}") 41 | SET_TARGET_PROPERTIES(x86_avx PROPERTIES COMPILE_FLAGS "${avx_flags}") 42 | -------------------------------------------------------------------------------- /libde265/arm/cpudetect.S: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2015 struktur AG, Joachim Bauch 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #include "asm.S" 22 | #include "neon.S" 23 | 24 | // we execute a simple NEON instruction and check if SIGILL is triggered to 25 | // detect if the CPU support NEON code 26 | function libde265_detect_neon, export=1 27 | vand q0, q0, q0 28 | bx lr 29 | endfunc 30 | -------------------------------------------------------------------------------- /dec265/COPYING: -------------------------------------------------------------------------------- 1 | 2 | MIT License 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | -------------------------------------------------------------------------------- /enc265/COPYING: -------------------------------------------------------------------------------- 1 | 2 | MIT License 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | -------------------------------------------------------------------------------- /sherlock265/COPYING: -------------------------------------------------------------------------------- 1 | 2 | MIT License 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -eu 3 | # 4 | # H.265 video codec. 5 | # Copyright (c) 2013 struktur AG, Joachim Bauch 6 | # 7 | # This file is part of libde265. 8 | # 9 | # libde265 is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # libde265 is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with libde265. If not, see . 21 | # 22 | if [ -x "`which autoreconf 2>/dev/null`" ] ; then 23 | exec autoreconf -ivf 24 | fi 25 | 26 | LIBTOOLIZE=libtoolize 27 | SYSNAME=`uname` 28 | if [ "x$SYSNAME" = "xDarwin" ] ; then 29 | LIBTOOLIZE=glibtoolize 30 | fi 31 | aclocal -I m4 && \ 32 | autoheader && \ 33 | $LIBTOOLIZE && \ 34 | autoconf && \ 35 | automake --add-missing --force-missing --copy 36 | -------------------------------------------------------------------------------- /libde265/x86/avx-motion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2020 Dmitry Ilyin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #ifndef AVX_MOTION_H 22 | #define AVX_MOTION_H 23 | 24 | #include 25 | #include 26 | 27 | 28 | void ff_hevc_put_unweighted_pred_8_avx(uint8_t *_dst, ptrdiff_t dststride, 29 | const int16_t *src, ptrdiff_t srcstride, 30 | int width, int height); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /acceleration-speed/dct-scalar.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2015 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #include "dct-scalar.h" 22 | 23 | 24 | DSPFunc_FDCT_Scalar_4x4 fdct_scalar_4x4; 25 | DSPFunc_FDCT_Scalar_8x8 fdct_scalar_8x8; 26 | DSPFunc_FDCT_Scalar_16x16 fdct_scalar_16x16; 27 | DSPFunc_FDCT_Scalar_32x32 fdct_scalar_32x32; 28 | 29 | 30 | DSPFunc_IDCT_Scalar_4x4 idct_scalar_4x4; 31 | DSPFunc_IDCT_Scalar_8x8 idct_scalar_8x8; 32 | DSPFunc_IDCT_Scalar_16x16 idct_scalar_16x16; 33 | DSPFunc_IDCT_Scalar_32x32 idct_scalar_32x32; 34 | -------------------------------------------------------------------------------- /libde265/de265-version.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | /* de265-version.h 22 | * 23 | * This file was generated by autoconf when libde265 was built. 24 | * 25 | * DO NOT EDIT THIS FILE. 26 | */ 27 | #ifndef LIBDE265_VERSION_H 28 | #define LIBDE265_VERSION_H 29 | 30 | /* Numeric representation of the version */ 31 | #define LIBDE265_NUMERIC_VERSION @NUMERIC_VERSION@ 32 | 33 | /* Version string */ 34 | #define LIBDE265_VERSION "@PACKAGE_VERSION@" 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # stats available at 2 | # https://ci.appveyor.com/project/strukturag/libde265 3 | version: 1.0.{build} 4 | 5 | os: 6 | - Windows Server 2012 R2 7 | 8 | environment: 9 | matrix: 10 | - GENERATOR: "Visual Studio 11 2012" 11 | - GENERATOR: "Visual Studio 12 2013" 12 | 13 | platform: 14 | - x86 15 | - x64 16 | 17 | configuration: 18 | - Debug 19 | 20 | build: 21 | verbosity: normal 22 | 23 | install: 24 | - git clone https://github.com/strukturag/libde265-data.git 25 | 26 | build_script: 27 | - ps: if($env:PLATFORM -eq "x64") { $env:CMAKE_GEN_SUFFIX=" Win64" } 28 | - cmake "-G%GENERATOR%%CMAKE_GEN_SUFFIX%" -H. -Bbuild 29 | - cmake --build build --config %CONFIGURATION% 30 | 31 | before_test: 32 | - copy /y build\dec265\%CONFIGURATION%\dec265.exe build 33 | - copy /y build\enc265\%CONFIGURATION%\enc265.exe build 34 | - copy /y build\libde265\%CONFIGURATION%\libde265.dll build 35 | 36 | test_script: 37 | - build\dec265.exe -q -c -f 100 libde265-data\IDR-only\paris-352x288-intra.bin 38 | - build\dec265.exe -t 4 -q -c -f 100 libde265-data\IDR-only\paris-352x288-intra.bin 39 | - build\dec265.exe -q -c -f 100 libde265-data\RandomAccess\paris-ra-wpp.bin 40 | - build\dec265.exe -t 4 -q -c -f 100 libde265-data\RandomAccess\paris-ra-wpp.bin 41 | 42 | artifacts: 43 | - path: build 44 | -------------------------------------------------------------------------------- /sherlock265/README: -------------------------------------------------------------------------------- 1 | 2 | description of graphical overlays 3 | --------------------------------- 4 | 5 | CB - Show Coding Block quadtree structure. Prediction modes are 6 | signalled at this level. CBs can be further subdivided into 7 | PBs for prediction and TBs for residual transforms. 8 | 9 | PB - Show Prediction Block structure. CB blocks may be further 10 | subdivided, possibly using asymetric partitionings. This is 11 | the level on which motion-compensation and intra-prediction is 12 | performed. 13 | 14 | TB - Show Transformation Block structure. DCT/DSTs are carried out 15 | on this level. 16 | 17 | QP - Quantization Parameter shown as greyscale value. 18 | Brighter blocks for larger QP values (lower quality). 19 | 20 | IntraPred - Show intra prediction mode. 21 | * Directional prediction is depicted with a line in the prediction direction 22 | (out of 32 possible directions) 23 | * Planar prediction is depicted by a square. 24 | * DC prediction is depicted by a circle. 25 | 26 | PredMode - Show prediction mode. 27 | * red: intra 28 | * blue: inter 29 | * green: skip = inter mode with no PB subdivision and candidate from merge list 30 | 31 | MV - Show motion vectors. Vectors from list L0 are drawn in red, 32 | motion vectors from L1 are green. Vectors are magnified by a factor of 4. 33 | -------------------------------------------------------------------------------- /scripts/ci-before-script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eu 3 | # 4 | # H.265 video codec. 5 | # Copyright (c) 2018 struktur AG, Joachim Bauch 6 | # 7 | # This file is part of libde265. 8 | # 9 | # libde265 is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # libde265 is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with libde265. If not, see . 21 | # 22 | 23 | if [ ! -z "$HOST" ] && [ "$HOST" != "cmake" ]; then 24 | # Make sure the correct compiler will be used. 25 | unset CC 26 | unset CXX 27 | fi 28 | 29 | if [ "$TRAVIS_OS_NAME" = "osx" ]; then 30 | export PATH="/usr/local/opt/qt/bin:$PATH" 31 | export PKG_CONFIG_PATH=/usr/local/opt/qt/lib/pkgconfig 32 | fi 33 | 34 | if [ "$HOST" != "cmake" ]; then 35 | ./autogen.sh 36 | ./configure --host=$HOST 37 | fi 38 | 39 | if [ "$HOST" = "cmake" ]; then 40 | cmake . 41 | fi 42 | -------------------------------------------------------------------------------- /libde265/scan.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #ifndef DE265_SCAN_H 22 | #define DE265_SCAN_H 23 | 24 | #include 25 | 26 | typedef struct { 27 | uint8_t x,y; 28 | } position; 29 | 30 | typedef struct { 31 | uint8_t subBlock; 32 | uint8_t scanPos; 33 | } scan_position; 34 | 35 | void init_scan_orders(); 36 | 37 | /* scanIdx: 0 - diag, 1 - horiz, 2 - verti 38 | */ 39 | const position* get_scan_order(int log2BlockSize, int scanIdx); 40 | 41 | scan_position get_scan_position(int x,int y, int scanIdx, int log2BlkSize); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /sherlock265/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | bin_PROGRAMS = sherlock265 3 | 4 | AM_CPPFLAGS = -I../libde265 5 | 6 | sherlock265_DEPENDENCIES = ../libde265/libde265.la 7 | sherlock265_CXXFLAGS = $(QT_CFLAGS) -std=c++0x -fPIC 8 | sherlock265_LDFLAGS = $(QT_LIBS) 9 | sherlock265_LDADD = ../libde265/libde265.la -lstdc++ -lpthread 10 | sherlock265_SOURCES = \ 11 | sherlock265.cc \ 12 | VideoPlayer.cc \ 13 | VideoDecoder.cc \ 14 | VideoWidget.cc \ 15 | VideoPlayer.hh \ 16 | VideoDecoder.hh \ 17 | VideoWidget.hh 18 | 19 | nodist_sherlock265_SOURCES = \ 20 | moc_VideoPlayer.cpp \ 21 | moc_VideoDecoder.cpp \ 22 | moc_VideoWidget.cpp 23 | 24 | CLEANFILES = \ 25 | moc_VideoPlayer.cpp \ 26 | moc_VideoDecoder.cpp \ 27 | moc_VideoWidget.cpp 28 | 29 | if HAVE_VIDEOGFX 30 | sherlock265_CXXFLAGS += $(VIDEOGFX_CFLAGS) 31 | sherlock265_LDFLAGS += $(VIDEOGFX_LIBS) 32 | endif 33 | 34 | if HAVE_SWSCALE 35 | sherlock265_CXXFLAGS += $(SWSCALE_CFLAGS) 36 | sherlock265_LDFLAGS += $(SWSCALE_LIBS) 37 | endif 38 | 39 | moc_VideoWidget.cpp: VideoWidget.hh 40 | $(QTMOC) $(DEFINES) $(INCPATH) VideoWidget.hh -o moc_VideoWidget.cpp 41 | 42 | moc_VideoPlayer.cpp: VideoPlayer.hh 43 | $(QTMOC) $(DEFINES) $(INCPATH) VideoPlayer.hh -o moc_VideoPlayer.cpp 44 | 45 | moc_VideoDecoder.cpp: VideoDecoder.hh 46 | $(QTMOC) $(DEFINES) $(INCPATH) VideoDecoder.hh -o moc_VideoDecoder.cpp 47 | 48 | EXTRA_DIST = \ 49 | README 50 | -------------------------------------------------------------------------------- /libde265/sao.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #ifndef DE265_SAO_H 22 | #define DE265_SAO_H 23 | 24 | #include "libde265/decctx.h" 25 | 26 | void apply_sample_adaptive_offset(de265_image* img); 27 | 28 | /* requires less memory than the function above */ 29 | void apply_sample_adaptive_offset_sequential(de265_image* img); 30 | 31 | /* saoInputProgress - the CTB progress that SAO will wait for before beginning processing. 32 | Returns 'true' if any tasks have been added. 33 | */ 34 | bool add_sao_tasks(image_unit* imgunit, int saoInputProgress); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /libde265/encoder/encoder-motion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #ifndef DE265_ENCODER_MOTION_H 22 | #define DE265_ENCODER_MOTION_H 23 | 24 | #include "libde265/motion.h" 25 | 26 | void get_merge_candidate_list_from_tree(class encoder_context* ectx, 27 | const slice_segment_header* shdr, 28 | int xC,int yC, int xP,int yP, 29 | int nCS, int nPbW,int nPbH, int partIdx, 30 | PBMotion* mergeCandList); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /scripts/ci-before-install-osx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eu 3 | # 4 | # H.265 video codec. 5 | # Copyright (c) 2018 struktur AG, Joachim Bauch 6 | # 7 | # This file is part of libde265. 8 | # 9 | # libde265 is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # libde265 is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with libde265. If not, see . 21 | # 22 | 23 | INSTALL_PACKAGES= 24 | 25 | # Output something once per minute to avoid being killed for inactivity. 26 | while true; do echo "Still alive at $(date) ..."; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & 27 | 28 | if [ -z "$HOST" ]; then 29 | INSTALL_PACKAGES="$INSTALL_PACKAGES \ 30 | ffmpeg \ 31 | qt5 \ 32 | sdl \ 33 | " 34 | fi 35 | 36 | if [ ! -z "$INSTALL_PACKAGES" ]; then 37 | echo "Remove python@2 ..." 38 | brew unlink python@2 || true 39 | 40 | echo "Installing packages $INSTALL_PACKAGES ..." 41 | for package in $INSTALL_PACKAGES; do 42 | brew list $package &>/dev/null || brew install $package 43 | done 44 | fi 45 | -------------------------------------------------------------------------------- /libde265/md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc. 3 | * MD5 Message-Digest Algorithm (RFC 1321). 4 | * 5 | * Homepage: 6 | * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5 7 | * 8 | * Author: 9 | * Alexander Peslyak, better known as Solar Designer 10 | * 11 | * This software was written by Alexander Peslyak in 2001. No copyright is 12 | * claimed, and the software is hereby placed in the public domain. 13 | * In case this attempt to disclaim copyright and place the software in the 14 | * public domain is deemed null and void, then the software is 15 | * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the 16 | * general public under the following terms: 17 | * 18 | * Redistribution and use in source and binary forms, with or without 19 | * modification, are permitted. 20 | * 21 | * There's ABSOLUTELY NO WARRANTY, express or implied. 22 | * 23 | * See md5.c for more information. 24 | */ 25 | 26 | #ifdef HAVE_OPENSSL 27 | #include 28 | #elif !defined(_MD5_H) 29 | #define _MD5_H 30 | 31 | /* Any 32-bit or wider unsigned integer data type will do */ 32 | typedef unsigned int MD5_u32plus; 33 | 34 | typedef struct { 35 | MD5_u32plus lo, hi; 36 | MD5_u32plus a, b, c, d; 37 | unsigned char buffer[64]; 38 | MD5_u32plus block[16]; 39 | } MD5_CTX; 40 | 41 | extern void MD5_Init(MD5_CTX *ctx); 42 | extern void MD5_Update(MD5_CTX *ctx, void *data, unsigned long size); 43 | extern void MD5_Final(unsigned char *result, MD5_CTX *ctx); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /tools/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | bin_PROGRAMS = gen-enc-table yuv-distortion rd-curves block-rate-estim tests bjoentegaard 3 | 4 | AM_CPPFLAGS = -I$(top_srcdir)/libde265 -I$(top_srcdir) 5 | 6 | gen_enc_table_DEPENDENCIES = ../libde265/libde265.la 7 | gen_enc_table_CXXFLAGS = 8 | gen_enc_table_LDFLAGS = 9 | gen_enc_table_LDADD = ../libde265/libde265.la -lstdc++ 10 | gen_enc_table_SOURCES = gen-entropy-table.cc 11 | 12 | yuv_distortion_DEPENDENCIES = ../libde265/libde265.la 13 | yuv_distortion_CXXFLAGS = 14 | yuv_distortion_LDFLAGS = 15 | yuv_distortion_LDADD = ../libde265/libde265.la -lstdc++ 16 | yuv_distortion_SOURCES = yuv-distortion.cc 17 | 18 | if HAVE_VIDEOGFX 19 | yuv_distortion_CXXFLAGS += $(VIDEOGFX_CFLAGS) 20 | yuv_distortion_LDFLAGS += $(VIDEOGFX_LIBS) 21 | endif 22 | 23 | rd_curves_DEPENDENCIES = ../libde265/libde265.la 24 | rd_curves_CXXFLAGS = 25 | rd_curves_LDFLAGS = 26 | rd_curves_LDADD = ../libde265/libde265.la -lstdc++ 27 | rd_curves_SOURCES = rd-curves.cc 28 | 29 | block_rate_estim_DEPENDENCIES = ../libde265/libde265.la 30 | block_rate_estim_CXXFLAGS = 31 | block_rate_estim_LDFLAGS = 32 | block_rate_estim_LDADD = ../libde265/libde265.la -lstdc++ 33 | block_rate_estim_SOURCES = block-rate-estim.cc 34 | 35 | tests_DEPENDENCIES = ../libde265/libde265.la 36 | tests_CXXFLAGS = 37 | tests_LDFLAGS = 38 | tests_LDADD = ../libde265/libde265.la -lstdc++ 39 | tests_SOURCES = tests.cc 40 | 41 | bjoentegaard_DEPENDENCIES = ../libde265/libde265.la 42 | bjoentegaard_CXXFLAGS = 43 | bjoentegaard_LDFLAGS = 44 | bjoentegaard_LDADD = ../libde265/libde265.la -lstdc++ 45 | bjoentegaard_SOURCES = bjoentegaard.cc 46 | -------------------------------------------------------------------------------- /libde265/wasm/simd-dct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013 openHEVC contributors 4 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 5 | * 6 | * This file is part of libde265. 7 | * 8 | * libde265 is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as 10 | * published by the Free Software Foundation, either version 3 of 11 | * the License, or (at your option) any later version. 12 | * 13 | * libde265 is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with libde265. If not, see . 20 | */ 21 | 22 | #ifndef SSE_DCT_H 23 | #define SSE_DCT_H 24 | 25 | #include 26 | #include 27 | 28 | void ff_hevc_transform_skip_8_wasm(uint8_t *_dst, const int16_t *coeffs, ptrdiff_t _stride); 29 | void ff_hevc_transform_4x4_luma_add_8_wasm(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride); 30 | void ff_hevc_transform_4x4_add_8_wasm(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride); 31 | void ff_hevc_transform_8x8_add_8_wasm(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride); 32 | void ff_hevc_transform_16x16_add_8_wasm(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride); 33 | void ff_hevc_transform_32x32_add_8_wasm(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /libde265/x86/sse-dct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013 openHEVC contributors 4 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 5 | * 6 | * This file is part of libde265. 7 | * 8 | * libde265 is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as 10 | * published by the Free Software Foundation, either version 3 of 11 | * the License, or (at your option) any later version. 12 | * 13 | * libde265 is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with libde265. If not, see . 20 | */ 21 | 22 | #ifndef SSE_DCT_H 23 | #define SSE_DCT_H 24 | 25 | #include 26 | #include 27 | 28 | void ff_hevc_transform_skip_8_sse(uint8_t *_dst, const int16_t *coeffs, ptrdiff_t _stride); 29 | void ff_hevc_transform_4x4_luma_add_8_sse4(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride); 30 | void ff_hevc_transform_4x4_add_8_sse4(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride); 31 | void ff_hevc_transform_8x8_add_8_sse4(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride); 32 | void ff_hevc_transform_16x16_add_8_sse4(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride); 33 | void ff_hevc_transform_32x32_add_8_sse4(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /libde265/alloc_pool.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2014 struktur AG, Dirk Farin 4 | * 5 | * Authors: Dirk Farin 6 | * 7 | * This file is part of libde265. 8 | * 9 | * libde265 is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of 12 | * the License, or (at your option) any later version. 13 | * 14 | * libde265 is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with libde265. If not, see . 21 | */ 22 | 23 | #ifndef ALLOC_POOL_H 24 | #define ALLOC_POOL_H 25 | 26 | #ifdef HAVE_CONFIG_H 27 | #include "config.h" 28 | #endif 29 | 30 | #include 31 | #include 32 | #ifdef HAVE_STDINT_H 33 | #include 34 | #endif 35 | #ifdef HAVE_CSTDINT 36 | #include 37 | #endif 38 | 39 | 40 | class alloc_pool 41 | { 42 | public: 43 | alloc_pool(size_t objSize, int poolSize=1000, bool grow=true); 44 | ~alloc_pool(); 45 | 46 | void* new_obj(const size_t size); 47 | void delete_obj(void*); 48 | void purge(); 49 | 50 | private: 51 | size_t mObjSize; 52 | int mPoolSize; 53 | bool mGrow; 54 | 55 | std::vector m_memBlocks; 56 | std::vector m_freeList; 57 | 58 | void add_memory_block(); 59 | }; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /sherlock265/sherlock265.cc: -------------------------------------------------------------------------------- 1 | /* 2 | libde265 example application "sherlock265". 3 | 4 | MIT License 5 | 6 | Copyright (c) 2013-2014 struktur AG, Dirk Farin 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | */ 26 | 27 | #include "VideoPlayer.hh" 28 | 29 | 30 | int main(int argc, char **argv) 31 | { 32 | if (argc != 2) { 33 | fprintf(stderr,"usage: sherlock265 videofile.bin\n"); 34 | fprintf(stderr,"The video file must be a raw h.265 bitstream (e.g. HM-10.0 output)\n"); 35 | exit(5); 36 | } 37 | 38 | 39 | QApplication app(argc, argv); 40 | 41 | VideoPlayer videoPlayer(argv[1]); 42 | videoPlayer.show(); 43 | 44 | return app.exec(); 45 | } 46 | -------------------------------------------------------------------------------- /sherlock265/VideoPlayer.hh: -------------------------------------------------------------------------------- 1 | /* 2 | libde265 example application "sherlock265". 3 | 4 | MIT License 5 | 6 | Copyright (c) 2013-2014 struktur AG, Dirk Farin 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | */ 26 | 27 | #ifndef VIDEOPLAYER_HH 28 | #define VIDEOPLAYER_HH 29 | 30 | #include 31 | 32 | #include "VideoWidget.hh" 33 | #include "VideoDecoder.hh" 34 | 35 | 36 | class VideoPlayer : public QWidget 37 | { 38 | Q_OBJECT 39 | 40 | public: 41 | VideoPlayer(const char* filename); 42 | 43 | private: 44 | VideoWidget* videoWidget; 45 | QPushButton *startButton; 46 | QPushButton *stopButton; 47 | 48 | VideoDecoder* mDecoder; 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /libde265/encoder/encoder-intrapred.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #ifndef DE265_ENCODER_INTRAPRED_H 22 | #define DE265_ENCODER_INTRAPRED_H 23 | 24 | #include "libde265/decctx.h" 25 | 26 | 27 | void fillIntraPredModeCandidates(enum IntraPredMode candModeList[3], 28 | int x,int y, 29 | bool availableA, // left 30 | bool availableB, // top 31 | const class CTBTreeMatrix& ctbs, 32 | const seq_parameter_set* sps); 33 | 34 | void decode_intra_prediction_from_tree(const de265_image* img, 35 | const class enc_tb* tb, 36 | const class CTBTreeMatrix& ctbs, 37 | const class seq_parameter_set& sps, 38 | int cIdx); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /libde265/quality.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #ifndef DE265_QUALITY_H 22 | #define DE265_QUALITY_H 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | LIBDE265_API uint32_t SSD(const uint8_t* img, int imgStride, 30 | const uint8_t* ref, int refStride, 31 | int width, int height); 32 | 33 | LIBDE265_API uint32_t SAD(const uint8_t* img, int imgStride, 34 | const uint8_t* ref, int refStride, 35 | int width, int height); 36 | 37 | LIBDE265_API double MSE(const uint8_t* img, int imgStride, 38 | const uint8_t* ref, int refStride, 39 | int width, int height); 40 | 41 | LIBDE265_API double PSNR(double mse); 42 | 43 | 44 | LIBDE265_API uint32_t compute_distortion_ssd(const de265_image* img1, const de265_image* img2, 45 | int x0, int y0, int log2size, int cIdx); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /extra/stdbool.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1998-2013 Free Software Foundation, Inc. 2 | 3 | This file is part of GCC, modify by Min Chen. 4 | 5 | GCC is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3, or (at your option) 8 | any later version. 9 | 10 | GCC is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | Under Section 7 of GPL version 3, you are granted additional 16 | permissions described in the GCC Runtime Library Exception, version 17 | 3.1, as published by the Free Software Foundation. 18 | 19 | You should have received a copy of the GNU General Public License and 20 | a copy of the GCC Runtime Library Exception along with this program; 21 | see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 22 | . */ 23 | 24 | /* 25 | * ISO C Standard: 7.16 Boolean type and values 26 | */ 27 | 28 | #ifndef _STDBOOL_H 29 | #define _STDBOOL_H 30 | 31 | #ifndef __cplusplus 32 | 33 | #if defined __STDC__ && defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L 34 | #define bool _Bool 35 | #define true 1 36 | #define false 0 37 | 38 | #else /* not C99 */ 39 | 40 | typedef enum { 41 | false = 0, 42 | true = 1 43 | } bool; 44 | 45 | #endif /* not C99 */ 46 | 47 | #else /* __cplusplus */ 48 | 49 | #if !defined(_MSC_VER) 50 | 51 | /* Supporting in C++ is a GCC extension. */ 52 | #define _Bool bool 53 | #define bool bool 54 | #define false false 55 | #define true true 56 | 57 | #endif /* _MSC_VER */ 58 | 59 | #endif /* __cplusplus */ 60 | 61 | /* Signal that all the definitions are present. */ 62 | #define __bool_true_false_are_defined 1 63 | 64 | #endif /* stdbool.h */ 65 | -------------------------------------------------------------------------------- /libde265/encoder/algo/tb-rateestim.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * Authors: struktur AG, Dirk Farin 6 | * 7 | * This file is part of libde265. 8 | * 9 | * libde265 is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of 12 | * the License, or (at your option) any later version. 13 | * 14 | * libde265 is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with libde265. If not, see . 21 | */ 22 | 23 | 24 | #include "libde265/encoder/algo/tb-rateestim.h" 25 | #include "libde265/encoder/encoder-syntax.h" 26 | #include 27 | #include 28 | 29 | 30 | float Algo_TB_RateEstimation_Exact::encode_transform_unit(encoder_context* ectx, 31 | context_model_table& ctxModel, 32 | const enc_tb* tb, const enc_cb* cb, 33 | int x0,int y0, int xBase,int yBase, 34 | int log2TrafoSize, int trafoDepth, 35 | int blkIdx) 36 | { 37 | CABAC_encoder_estim estim; 38 | estim.set_context_models(&ctxModel); 39 | 40 | leaf(cb, NULL); 41 | 42 | ::encode_transform_unit(ectx, &estim, tb,cb, x0,y0, xBase,yBase, 43 | log2TrafoSize, trafoDepth, blkIdx); 44 | 45 | return estim.getRDBits(); 46 | } 47 | -------------------------------------------------------------------------------- /acceleration-speed/acceleration-speed.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2015 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #ifndef ACCELERATION_SPEED_H 22 | #define ACCELERATION_SPEED_H 23 | 24 | #ifdef HAVE_CONFIG_H 25 | #include "config.h" 26 | #endif 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | #include "libde265/image.h" 38 | #include "libde265/image-io.h" 39 | 40 | 41 | class DSPFunc 42 | { 43 | public: 44 | DSPFunc() { next = first; first = this; } 45 | virtual ~DSPFunc() { } 46 | 47 | virtual const char* name() const = 0; 48 | 49 | virtual int getBlkWidth() const = 0; 50 | virtual int getBlkHeight() const = 0; 51 | 52 | virtual void runOnBlock(int x,int y) = 0; 53 | virtual DSPFunc* referenceImplementation() const { return NULL; } 54 | 55 | virtual bool prepareNextImage(std::shared_ptr) = 0; 56 | 57 | bool runOnImage(std::shared_ptr img, bool compareToReference); 58 | virtual bool compareToReferenceImplementation() { return false; } 59 | 60 | static DSPFunc* first; 61 | DSPFunc* next; 62 | }; 63 | 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /sherlock265/VideoWidget.hh: -------------------------------------------------------------------------------- 1 | /* 2 | libde265 example application "sherlock265". 3 | 4 | MIT License 5 | 6 | Copyright (c) 2013-2014 struktur AG, Dirk Farin 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | */ 26 | 27 | #ifndef VIDEOWIDGET_HH 28 | #define VIDEOWIDGET_HH 29 | 30 | #include 31 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) 32 | #include 33 | #else 34 | #include 35 | #endif 36 | 37 | 38 | class VideoWidget : public QWidget 39 | { 40 | Q_OBJECT 41 | public: 42 | VideoWidget(QWidget *parent = 0); 43 | ~VideoWidget(); 44 | 45 | QSize sizeHint() const; 46 | 47 | public slots: 48 | void setImage(QImage* img) 49 | { 50 | mImg=img; repaint(); 51 | } 52 | 53 | protected: 54 | void paintEvent(QPaintEvent *event); 55 | void resizeEvent(QResizeEvent *event); 56 | 57 | private: 58 | 59 | QImage* mImg; 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /libde265/encoder/algo/ctb-qscale.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * Authors: struktur AG, Dirk Farin 6 | * 7 | * This file is part of libde265. 8 | * 9 | * libde265 is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of 12 | * the License, or (at your option) any later version. 13 | * 14 | * libde265 is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with libde265. If not, see . 21 | */ 22 | 23 | 24 | #include "libde265/encoder/algo/ctb-qscale.h" 25 | #include "libde265/encoder/encoder-context.h" 26 | #include 27 | #include 28 | #include 29 | 30 | 31 | #define ENCODER_DEVELOPMENT 1 32 | 33 | 34 | enc_cb* Algo_CTB_QScale_Constant::analyze(encoder_context* ectx, 35 | context_model_table& ctxModel, 36 | int x,int y) 37 | { 38 | enc_cb* cb = new enc_cb(); 39 | 40 | cb->log2Size = ectx->get_sps().Log2CtbSizeY; 41 | cb->ctDepth = 0; 42 | cb->x = x; 43 | cb->y = y; 44 | cb->downPtr = ectx->ctbs.getCTBRootPointer(x,y); 45 | *cb->downPtr = cb; 46 | 47 | cb->qp = ectx->active_qp; 48 | 49 | // write currently unused coding options 50 | cb->cu_transquant_bypass_flag = false; 51 | cb->pcm_flag = false; 52 | 53 | assert(mChildAlgo); 54 | descend(cb, "Q=%d",ectx->active_qp); 55 | enc_cb* result_cb = mChildAlgo->analyze(ectx,ctxModel,cb); 56 | ascend(); 57 | 58 | *cb->downPtr = result_cb; 59 | 60 | return result_cb; 61 | } 62 | -------------------------------------------------------------------------------- /scripts/check_licenses.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eu 3 | # 4 | # H.265 video codec. 5 | # Copyright (c) 2015 struktur AG, Joachim Bauch 6 | # 7 | # This file is part of libde265. 8 | # 9 | # libde265 is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # libde265 is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with libde265. If not, see . 21 | # 22 | 23 | echo "Checking licenses..." 24 | CHECK_RESULT=`/usr/bin/licensecheck --recursive --ignore 'nacl_sdk' .` 25 | 26 | # Files that are public domain or have other known-good license headers which licensecheck doesn't detect. 27 | KNOWN_GOOD_FILES=( 28 | './extra/stdint.h', 29 | './extra/win32cond.c', 30 | './extra/win32cond.h', 31 | './libde265/md5.cc', 32 | './libde265/md5.h', 33 | ) 34 | 35 | FOUND= 36 | while read -r line; do 37 | if ( echo $line | grep -q "GENERATED FILE" ); then 38 | # We don't care about generated files 39 | echo "OK: $line" 40 | continue 41 | fi 42 | 43 | if ( echo "$line" | grep -q "No copyright" ) || ( echo "$line" | grep -q "UNKNOWN" ); then 44 | FILENAME=`echo "$line" | awk '{split($0,a,":");print a[1]}'` 45 | if echo "${KNOWN_GOOD_FILES[@]}" | fgrep -q --word-regexp "${FILENAME}"; then 46 | echo "OK: $line (known-good)" 47 | else 48 | echo "ERROR: $line" >& 2 49 | FOUND=1 50 | fi 51 | continue 52 | fi 53 | 54 | echo "OK: $line" 55 | done <<< "${CHECK_RESULT}" 56 | 57 | if [ ! -z ${FOUND} ]; then 58 | echo "ERROR: Found files without licenses" >& 2 59 | exit 1 60 | fi 61 | -------------------------------------------------------------------------------- /libde265/bitstream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #ifndef DE265_BITSTREAM_H 22 | #define DE265_BITSTREAM_H 23 | 24 | #ifdef HAVE_CONFIG_H 25 | #include 26 | #endif 27 | 28 | #include 29 | #ifdef HAVE_STDBOOL_H 30 | #include 31 | #endif 32 | #include 33 | 34 | 35 | #define MAX_UVLC_LEADING_ZEROS 20 36 | #define UVLC_ERROR -99999 37 | 38 | 39 | typedef struct { 40 | uint8_t* data; 41 | int bytes_remaining; 42 | 43 | uint64_t nextbits; // left-aligned bits 44 | int nextbits_cnt; 45 | } bitreader; 46 | 47 | void bitreader_init(bitreader*, unsigned char* buffer, int len); 48 | void bitreader_refill(bitreader*); // refill to at least 56+1 bits 49 | int next_bit(bitreader*); 50 | int next_bit_norefill(bitreader*); 51 | int get_bits(bitreader*, int n); 52 | int get_bits_fast(bitreader*, int n); 53 | int peek_bits(bitreader*, int n); 54 | void skip_bits(bitreader*, int n); 55 | void skip_bits_fast(bitreader*, int n); 56 | void skip_to_byte_boundary(bitreader*); 57 | void prepare_for_CABAC(bitreader*); 58 | int get_uvlc(bitreader*); // may return UVLC_ERROR 59 | int get_svlc(bitreader*); // may return UVLC_ERROR 60 | 61 | bool check_rbsp_trailing_bits(bitreader*); // return true if remaining filler bits are all zero 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /enc265/image-io-png.h: -------------------------------------------------------------------------------- 1 | /* 2 | libde265 example application "enc265". 3 | 4 | MIT License 5 | 6 | Copyright (c) 2013-2014 struktur AG, Dirk Farin 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | */ 26 | 27 | #ifndef IMAGE_IO_PNG_H 28 | #define IMAGE_IO_PNG_H 29 | 30 | #include "libde265/image-io.h" 31 | #include 32 | 33 | 34 | #if HAVE_VIDEOGFX 35 | class ImageSource_PNG : public ImageSource 36 | { 37 | public: 38 | LIBDE265_API ImageSource_PNG(); 39 | virtual LIBDE265_API ~ImageSource_PNG(); 40 | 41 | bool LIBDE265_API set_input_file(const char* filename); 42 | 43 | //virtual ImageStatus get_status(); 44 | virtual LIBDE265_API de265_image* get_image(bool block=true); 45 | virtual LIBDE265_API void skip_frames(int n); 46 | 47 | virtual LIBDE265_API int get_width() const { return mWidth; } 48 | virtual LIBDE265_API int get_height() const { return mHeight; } 49 | 50 | private: 51 | const char* mFilenameTemplate; 52 | int mNextImageNumber; 53 | 54 | bool mReachedEndOfStream; 55 | 56 | int mWidth,mHeight; 57 | }; 58 | #endif 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /libde265/arm/neon.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Mans Rullgard 3 | * 4 | * This file is part of FFmpeg. 5 | * 6 | * FFmpeg is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * FFmpeg is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with FFmpeg; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | .macro transpose_8x8 r0, r1, r2, r3, r4, r5, r6, r7 22 | vtrn.32 \r0, \r4 23 | vtrn.32 \r1, \r5 24 | vtrn.32 \r2, \r6 25 | vtrn.32 \r3, \r7 26 | vtrn.16 \r0, \r2 27 | vtrn.16 \r1, \r3 28 | vtrn.16 \r4, \r6 29 | vtrn.16 \r5, \r7 30 | vtrn.8 \r0, \r1 31 | vtrn.8 \r2, \r3 32 | vtrn.8 \r4, \r5 33 | vtrn.8 \r6, \r7 34 | .endm 35 | 36 | .macro transpose_4x4 r0, r1, r2, r3 37 | vtrn.16 \r0, \r2 38 | vtrn.16 \r1, \r3 39 | vtrn.8 \r0, \r1 40 | vtrn.8 \r2, \r3 41 | .endm 42 | 43 | .macro swap4 r0, r1, r2, r3, r4, r5, r6, r7 44 | vswp \r0, \r4 45 | vswp \r1, \r5 46 | vswp \r2, \r6 47 | vswp \r3, \r7 48 | .endm 49 | 50 | .macro transpose16_4x4 r0, r1, r2, r3, r4, r5, r6, r7 51 | vtrn.32 \r0, \r2 52 | vtrn.32 \r1, \r3 53 | vtrn.32 \r4, \r6 54 | vtrn.32 \r5, \r7 55 | vtrn.16 \r0, \r1 56 | vtrn.16 \r2, \r3 57 | vtrn.16 \r4, \r5 58 | vtrn.16 \r6, \r7 59 | .endm 60 | -------------------------------------------------------------------------------- /extra/win32cond.h: -------------------------------------------------------------------------------- 1 | #ifndef WIN32COND_H 2 | #define WIN32COND_H 3 | 4 | /** 5 | * pthread_cond API for Win32 6 | * 7 | * ACE(TM), TAO(TM), CIAO(TM), DAnCE>(TM), and CoSMIC(TM) (henceforth 8 | * referred to as "DOC software") are copyrighted by Douglas C. Schmidt 9 | * and his research group at Washington University, University of California, 10 | * Irvine, and Vanderbilt University, Copyright (c) 1993-2009, all rights 11 | * reserved. 12 | * 13 | * Since DOC software is open-source, freely available software, you are free 14 | * to use, modify, copy, and distribute--perpetually and irrevocably--the DOC 15 | * software source code and object code produced from the source, as well as 16 | * copy and distribute modified versions of this software. You must, however, 17 | * include this copyright statement along with any code built using DOC 18 | * software that you release. 19 | * 20 | * No copyright statement needs to be provided if you just ship binary 21 | * executables of your software products. 22 | * 23 | * See "Strategies for Implementing POSIX Condition Variables on Win32" at 24 | * http://www.cs.wustl.edu/~schmidt/win32-cv-1.html 25 | */ 26 | 27 | #include 28 | 29 | typedef struct 30 | { 31 | long waiters_count_; 32 | // Number of waiting threads. 33 | 34 | CRITICAL_SECTION waiters_count_lock_; 35 | // Serialize access to . 36 | 37 | HANDLE sema_; 38 | // Semaphore used to queue up threads waiting for the condition to 39 | // become signaled. 40 | 41 | HANDLE waiters_done_; 42 | // An auto-reset event used by the broadcast/signal thread to wait 43 | // for all the waiting thread(s) to wake up and be released from the 44 | // semaphore. 45 | 46 | size_t was_broadcast_; 47 | // Keeps track of whether we were broadcasting or signaling. This 48 | // allows us to optimize the code if we're just signaling. 49 | } win32_cond_t; 50 | 51 | #ifdef __cplusplus 52 | extern "C" { 53 | #endif 54 | 55 | int win32_cond_init(win32_cond_t *cv); 56 | int win32_cond_destroy(win32_cond_t *cv); 57 | int win32_cond_wait(win32_cond_t *cv, HANDLE *external_mutex); 58 | int win32_cond_signal(win32_cond_t *cv); 59 | int win32_cond_broadcast(win32_cond_t *cv); 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /libde265/visualize.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #ifndef DE265_VISUALIZE_H 22 | #define DE265_VISUALIZE_H 23 | 24 | #include "libde265/de265.h" 25 | #include "libde265/image.h" 26 | 27 | 28 | void write_picture_to_file(const de265_image* img, const char* filename); 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | // TODO: these should either move to "sherlock265", or be part of the 35 | // "official" public API 36 | LIBDE265_API void draw_CB_grid(const de265_image* img, uint8_t* dst, int stride, uint32_t value, int pixelSize); 37 | LIBDE265_API void draw_TB_grid(const de265_image* img, uint8_t* dst, int stride, uint32_t value, int pixelSize); 38 | LIBDE265_API void draw_PB_grid(const de265_image* img, uint8_t* dst, int stride, uint32_t value, int pixelSize); 39 | LIBDE265_API void draw_PB_pred_modes(const de265_image* img, uint8_t* dst, int stride, int pixelSize); 40 | LIBDE265_API void draw_intra_pred_modes(const de265_image* img, uint8_t* dst, int stride, uint32_t value, int pixelSize); 41 | LIBDE265_API void draw_QuantPY(const de265_image* img, uint8_t* dst, int stride, int pixelSize); 42 | LIBDE265_API void draw_Motion(const de265_image* img, uint8_t* dst, int stride, int pixelSize); 43 | LIBDE265_API void draw_Slices(const de265_image* img, uint8_t* dst, int stride, int pixelSize); 44 | LIBDE265_API void draw_Tiles(const de265_image* img, uint8_t* dst, int stride, int pixelSize); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /libde265/encoder/algo/cb-skip.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * Authors: Dirk Farin 6 | * 7 | * This file is part of libde265. 8 | * 9 | * libde265 is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of 12 | * the License, or (at your option) any later version. 13 | * 14 | * libde265 is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with libde265. If not, see . 21 | */ 22 | 23 | #ifndef CB_SKIP_H 24 | #define CB_SKIP_H 25 | 26 | #include "libde265/nal-parser.h" 27 | #include "libde265/decctx.h" 28 | #include "libde265/slice.h" 29 | #include "libde265/scan.h" 30 | #include "libde265/intrapred.h" 31 | #include "libde265/transform.h" 32 | #include "libde265/fallback-dct.h" 33 | #include "libde265/quality.h" 34 | #include "libde265/fallback.h" 35 | #include "libde265/configparam.h" 36 | 37 | #include "libde265/encoder/algo/algo.h" 38 | #include "libde265/encoder/algo/cb-mergeindex.h" 39 | 40 | 41 | // ========== CB Skip/Inter decision ========== 42 | 43 | class Algo_CB_Skip : public Algo_CB 44 | { 45 | public: 46 | virtual ~Algo_CB_Skip() { } 47 | 48 | void setSkipAlgo(Algo_CB_MergeIndex* algo) { 49 | mSkipAlgo = algo; 50 | mSkipAlgo->set_code_residual(false); 51 | } 52 | 53 | void setNonSkipAlgo(Algo_CB* algo) { mNonSkipAlgo = algo; } 54 | 55 | const char* name() const { return "cb-skip"; } 56 | 57 | protected: 58 | Algo_CB_MergeIndex* mSkipAlgo; 59 | Algo_CB* mNonSkipAlgo; 60 | }; 61 | 62 | class Algo_CB_Skip_BruteForce : public Algo_CB_Skip 63 | { 64 | public: 65 | virtual enc_cb* analyze(encoder_context*, 66 | context_model_table&, 67 | enc_cb* cb); 68 | 69 | const char* name() const { return "cb-skip-bruteforce"; } 70 | }; 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /libde265/encoder/algo/cb-intra-inter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * Authors: Dirk Farin 6 | * 7 | * This file is part of libde265. 8 | * 9 | * libde265 is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of 12 | * the License, or (at your option) any later version. 13 | * 14 | * libde265 is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with libde265. If not, see . 21 | */ 22 | 23 | #ifndef CB_INTRA_INTER_H 24 | #define CB_INTRA_INTER_H 25 | 26 | #include "libde265/nal-parser.h" 27 | #include "libde265/decctx.h" 28 | #include "libde265/slice.h" 29 | #include "libde265/scan.h" 30 | #include "libde265/intrapred.h" 31 | #include "libde265/transform.h" 32 | #include "libde265/fallback-dct.h" 33 | #include "libde265/quality.h" 34 | #include "libde265/fallback.h" 35 | #include "libde265/configparam.h" 36 | 37 | #include "libde265/encoder/algo/algo.h" 38 | #include "libde265/encoder/algo/tb-intrapredmode.h" 39 | #include "libde265/encoder/algo/tb-split.h" 40 | #include "libde265/encoder/algo/cb-intrapartmode.h" 41 | 42 | 43 | // ========== CB Intra/Inter decision ========== 44 | 45 | class Algo_CB_IntraInter : public Algo_CB 46 | { 47 | public: 48 | virtual ~Algo_CB_IntraInter() { } 49 | 50 | void setIntraChildAlgo(Algo_CB* algo) { mIntraAlgo = algo; } 51 | void setInterChildAlgo(Algo_CB* algo) { mInterAlgo = algo; } 52 | 53 | virtual const char* name() const { return "cb-intra-inter"; } 54 | 55 | protected: 56 | Algo_CB* mIntraAlgo; 57 | Algo_CB* mInterAlgo; 58 | }; 59 | 60 | class Algo_CB_IntraInter_BruteForce : public Algo_CB_IntraInter 61 | { 62 | public: 63 | virtual enc_cb* analyze(encoder_context*, 64 | context_model_table&, 65 | enc_cb* cb); 66 | }; 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /m4/visibility.m4: -------------------------------------------------------------------------------- 1 | # visibility.m4 serial 1 (gettext-0.15) 2 | dnl Copyright (C) 2005 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Bruno Haible. 8 | 9 | dnl Tests whether the compiler supports the command-line option 10 | dnl -fvisibility=hidden and the function and variable attributes 11 | dnl __attribute__((__visibility__("hidden"))) and 12 | dnl __attribute__((__visibility__("default"))). 13 | dnl Does *not* test for __visibility__("protected") - which has tricky 14 | dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on 15 | dnl MacOS X. 16 | dnl Does *not* test for __visibility__("internal") - which has processor 17 | dnl dependent semantics. 18 | dnl Does *not* test for #pragma GCC visibility push(hidden) - which is 19 | dnl "really only recommended for legacy code". 20 | dnl Set the variable CFLAG_VISIBILITY. 21 | dnl Defines and sets the variable HAVE_VISIBILITY. 22 | 23 | AC_DEFUN([gl_VISIBILITY], 24 | [ 25 | AC_REQUIRE([AC_PROG_CC]) 26 | CFLAG_VISIBILITY= 27 | HAVE_VISIBILITY=0 28 | if test -n "$GCC"; then 29 | AC_MSG_CHECKING([for simple visibility declarations]) 30 | AC_CACHE_VAL(gl_cv_cc_visibility, [ 31 | gl_save_CFLAGS="$CFLAGS" 32 | CFLAGS="$CFLAGS -fvisibility=hidden" 33 | AC_TRY_COMPILE( 34 | [extern __attribute__((__visibility__("hidden"))) int hiddenvar; 35 | extern __attribute__((__visibility__("default"))) int exportedvar; 36 | extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); 37 | extern __attribute__((__visibility__("default"))) int exportedfunc (void);], 38 | [], 39 | gl_cv_cc_visibility=yes, 40 | gl_cv_cc_visibility=no) 41 | CFLAGS="$gl_save_CFLAGS"]) 42 | AC_MSG_RESULT([$gl_cv_cc_visibility]) 43 | if test $gl_cv_cc_visibility = yes; then 44 | CFLAG_VISIBILITY="-fvisibility=hidden" 45 | HAVE_VISIBILITY=1 46 | fi 47 | fi 48 | AC_SUBST([CFLAG_VISIBILITY]) 49 | AC_SUBST([HAVE_VISIBILITY]) 50 | AC_DEFINE_UNQUOTED([HAVE_VISIBILITY], [$HAVE_VISIBILITY], 51 | [Define to 1 or 0, depending whether the compiler supports simple visibility declarations.]) 52 | ]) 53 | -------------------------------------------------------------------------------- /libde265/encoder/algo/cb-mergeindex.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * Authors: Dirk Farin 6 | * 7 | * This file is part of libde265. 8 | * 9 | * libde265 is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of 12 | * the License, or (at your option) any later version. 13 | * 14 | * libde265 is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with libde265. If not, see . 21 | */ 22 | 23 | #ifndef CB_MERGEINDEX_H 24 | #define CB_MERGEINDEX_H 25 | 26 | #include "libde265/nal-parser.h" 27 | #include "libde265/decctx.h" 28 | #include "libde265/slice.h" 29 | #include "libde265/scan.h" 30 | #include "libde265/intrapred.h" 31 | #include "libde265/transform.h" 32 | #include "libde265/fallback-dct.h" 33 | #include "libde265/quality.h" 34 | #include "libde265/fallback.h" 35 | #include "libde265/configparam.h" 36 | 37 | #include "libde265/encoder/algo/algo.h" 38 | #include "libde265/encoder/algo/tb-split.h" 39 | 40 | 41 | // ========== CB Skip/Inter decision ========== 42 | 43 | class Algo_CB_MergeIndex : public Algo_CB 44 | { 45 | public: 46 | Algo_CB_MergeIndex() : mCodeResidual(false) { } 47 | virtual ~Algo_CB_MergeIndex() { } 48 | 49 | void set_code_residual(bool flag=true) { mCodeResidual=flag; } 50 | 51 | void setChildAlgo(Algo_TB_Split* algo) { mTBSplit = algo; } 52 | // TODO void setInterChildAlgo(Algo_CB_IntraPartMode* algo) { mInterPartModeAlgo = algo; } 53 | 54 | virtual const char* name() const { return "cb-mergeindex"; } 55 | 56 | protected: 57 | Algo_TB_Split* mTBSplit; 58 | 59 | bool mCodeResidual; 60 | }; 61 | 62 | class Algo_CB_MergeIndex_Fixed : public Algo_CB_MergeIndex 63 | { 64 | public: 65 | virtual enc_cb* analyze(encoder_context*, 66 | context_model_table&, 67 | enc_cb* cb); 68 | }; 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /libde265/refpic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #ifndef DE265_REFPIC_H 22 | #define DE265_REFPIC_H 23 | 24 | #include "libde265/bitstream.h" 25 | 26 | #define MAX_NUM_REF_PICS 16 // maximum defined by standard, may be lower for some Levels 27 | 28 | 29 | class ref_pic_set 30 | { 31 | public: 32 | // Lists of pictures that have to be kept in the decoded picture buffer for future 33 | // reference and that may optionally be used for prediction in the current frame. 34 | // Lists contain the relative POC positions. 35 | int16_t DeltaPocS0[MAX_NUM_REF_PICS]; // sorted in decreasing order (e.g. -1, -2, -4, -7, ...) 36 | int16_t DeltaPocS1[MAX_NUM_REF_PICS]; // sorted in ascending order (e.g. 1, 2, 4, 7) 37 | 38 | // flag for each reference whether this is actually used for prediction in the current frame 39 | uint8_t UsedByCurrPicS0[MAX_NUM_REF_PICS]; 40 | uint8_t UsedByCurrPicS1[MAX_NUM_REF_PICS]; 41 | 42 | uint8_t NumNegativePics; // number of past reference pictures 43 | uint8_t NumPositivePics; // number of future reference pictures 44 | 45 | // --- derived values --- 46 | 47 | void compute_derived_values(); 48 | 49 | uint8_t NumDeltaPocs; // total number of reference pictures (past + future) 50 | 51 | uint8_t NumPocTotalCurr_shortterm_only; /* Total number of reference pictures that may actually 52 | be used for prediction in the current frame. */ 53 | 54 | void reset(); 55 | }; 56 | 57 | 58 | void dump_short_term_ref_pic_set(const ref_pic_set*, FILE* fh); 59 | void dump_compact_short_term_ref_pic_set(const ref_pic_set* set, int range, FILE* fh); 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /libde265/transform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #ifndef DE265_TRANSFORM_H 22 | #define DE265_TRANSFORM_H 23 | 24 | #include "libde265/de265.h" 25 | #include "libde265/decctx.h" 26 | 27 | extern const int tab8_22[]; 28 | 29 | LIBDE265_INLINE static int table8_22(int qPi) 30 | { 31 | if (qPi<30) return qPi; 32 | if (qPi>=43) return qPi-6; 33 | return tab8_22[qPi-30]; 34 | } 35 | 36 | // (8.6.1) 37 | void decode_quantization_parameters(thread_context* tctx, int xC,int yC, 38 | int xCUBase, int yCUBase); 39 | 40 | // (8.6.2) 41 | void scale_coefficients(thread_context* tctx, 42 | int xT,int yT, // position of TU in frame (chroma adapted) 43 | int x0,int y0, // position of CU in frame (chroma adapted) 44 | int nT, int cIdx, 45 | bool transform_skip_flag, bool intra, int rdpcmMode); 46 | 47 | 48 | void inv_transform(acceleration_functions* acceleration, 49 | uint8_t* dst, int dstStride, int16_t* coeff, 50 | int log2TbSize, int trType); 51 | 52 | void fwd_transform(acceleration_functions* acceleration, 53 | int16_t* coeff, int coeffStride, int log2TbSize, int trType, 54 | const int16_t* src, int srcStride); 55 | 56 | void quant_coefficients(int16_t* out_coeff, 57 | const int16_t* in_coeff, 58 | int log2TrSize, int qp, 59 | bool intra); 60 | 61 | void dequant_coefficients(int16_t* out_coeff, 62 | const int16_t* in_coeff, 63 | int log2TrSize, int qP); 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.15) 2 | 3 | project (libde265 4 | LANGUAGES C CXX 5 | VERSION 1.0.8 6 | ) 7 | 8 | set(CMAKE_CXX_STANDARD 11) 9 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 10 | set(CMAKE_CXX_EXTENSIONS OFF) 11 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) 12 | 13 | if(NOT CMAKE_BUILD_TYPE) 14 | set(CMAKE_BUILD_TYPE Release) 15 | endif() 16 | 17 | set(CMAKE_CXX_FLAGS_DEBUG "-g") 18 | set(CMAKE_CXX_FLAGS_RELEASE "-O3 -flto -fno-exceptions") 19 | 20 | # The version number. 21 | set (NUMERIC_VERSION 0x01000800) 22 | set (PACKAGE_VERSION ${PROJECT_VERSION}) 23 | 24 | include (${CMAKE_ROOT}/Modules/CheckCCompilerFlag.cmake) 25 | include (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake) 26 | 27 | include(GNUInstallDirs) 28 | include(CheckFunctionExists) 29 | 30 | option(ENABLE_SDL "Enable SDL" ON) 31 | 32 | if (ENABLE_SDL) 33 | find_package(SDL) 34 | endif() 35 | 36 | find_package(Threads REQUIRED) 37 | 38 | CHECK_INCLUDE_FILE(malloc.h HAVE_MALLOC_H) 39 | CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H) 40 | CHECK_INCLUDE_FILE(stdbool.h HAVE_STDBOOL_H) 41 | CHECK_FUNCTION_EXISTS(posix_memalign HAVE_POSIX_MEMALIGN) 42 | 43 | if (HAVE_MALLOC_H) 44 | add_definitions(-DHAVE_MALLOC_H) 45 | endif() 46 | if (HAVE_STDINT_H) 47 | add_definitions(-DHAVE_STDINT_H) 48 | endif() 49 | if (HAVE_STDBOOL_H) 50 | add_definitions(-DHAVE_STDBOOL_H) 51 | endif() 52 | if (HAVE_POSIX_MEMALIGN) 53 | add_definitions(-DHAVE_POSIX_MEMALIGN) 54 | endif() 55 | 56 | configure_file (libde265/de265-version.h.in libde265/de265-version.h) 57 | 58 | if(CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} MATCHES Clang) 59 | add_definitions(-Wall) 60 | endif() 61 | 62 | option(DISABLE_SIMD "Disable SIMD intructions" OFF) 63 | if(EMSCRIPTEN) 64 | option(ENABLE_THREADS "Enable WebAssembly thread support" OFF) 65 | if (ENABLE_THREADS) 66 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s USE_PTHREADS=1") 67 | endif() 68 | 69 | if (NOT DISABLE_SIMD) 70 | add_definitions(-DWASM_SIMD) 71 | endif() 72 | endif() 73 | 74 | option(BUILD_SHARED_LIBS "Build shared library" ON) 75 | if(NOT BUILD_SHARED_LIBS) 76 | add_definitions(-DLIBDE265_STATIC_BUILD) 77 | endif() 78 | 79 | include_directories ("${PROJECT_SOURCE_DIR}") 80 | include_directories ("${PROJECT_BINARY_DIR}") 81 | include_directories ("${PROJECT_SOURCE_DIR}/libde265") 82 | if(MSVC) 83 | include_directories ("${PROJECT_SOURCE_DIR}/extra") 84 | add_definitions(-DHAVE_STDINT_H) 85 | add_definitions(-DHAVE_STDBOOL_H) 86 | endif() 87 | 88 | add_subdirectory (libde265) 89 | 90 | option(DISABLE_TOOLS "Don't build dec265 and enc265" ON) 91 | if (NOT DISABLE_TOOLS) 92 | add_subdirectory (dec265) 93 | add_subdirectory (enc265) 94 | endif() 95 | -------------------------------------------------------------------------------- /libde265/alloc_pool.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2014 struktur AG, Dirk Farin 4 | * 5 | * Authors: Dirk Farin 6 | * 7 | * This file is part of libde265. 8 | * 9 | * libde265 is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of 12 | * the License, or (at your option) any later version. 13 | * 14 | * libde265 is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with libde265. If not, see . 21 | */ 22 | 23 | #include "libde265/alloc_pool.h" 24 | #include "libde265/util.h" 25 | #include 26 | #include 27 | 28 | #define DEBUG_MEMORY 1 29 | 30 | 31 | alloc_pool::alloc_pool(size_t objSize, int poolSize, bool grow) 32 | : mObjSize(objSize), 33 | mPoolSize(poolSize), 34 | mGrow(grow) 35 | { 36 | m_freeList.reserve(poolSize); 37 | m_memBlocks.reserve(8); 38 | 39 | add_memory_block(); 40 | } 41 | 42 | 43 | void alloc_pool::add_memory_block() 44 | { 45 | uint8_t* p = new uint8_t[mObjSize * mPoolSize]; 46 | m_memBlocks.push_back(p); 47 | 48 | for (int i=0;i 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | 26 | class Test 27 | { 28 | public: 29 | Test() { next=s_firstTest; s_firstTest=this; } 30 | virtual ~Test() { } 31 | 32 | virtual const char* getName() const { return "noname"; } 33 | virtual const char* getDescription() const { return "no description"; } 34 | virtual bool work(bool quiet=false) = 0; 35 | 36 | static void runTest(const char* name) { 37 | Test* t = s_firstTest; 38 | while (t) { 39 | if (strcmp(t->getName(), name)==0) { 40 | t->work(); 41 | break; 42 | } 43 | t=t->next; 44 | } 45 | } 46 | 47 | static void runAllTests() { 48 | Test* t = s_firstTest; 49 | while (t) { 50 | printf("%s ... ",t->getName()); 51 | fflush(stdout); 52 | if (t->work(true) == false) { 53 | printf("*** FAILED ***\n"); 54 | } 55 | else { 56 | printf("passed\n"); 57 | } 58 | 59 | t=t->next; 60 | } 61 | } 62 | 63 | public: 64 | Test* next; 65 | static Test* s_firstTest; 66 | }; 67 | 68 | Test* Test::s_firstTest = NULL; 69 | 70 | 71 | class ListTests : public Test 72 | { 73 | public: 74 | const char* getName() const { return "list"; } 75 | const char* getDescription() const { return "list all available tests"; } 76 | bool work(bool quiet) { 77 | if (!quiet) { 78 | Test* t = s_firstTest; 79 | while (t) { 80 | printf("- %s: %s\n",t->getName(), t->getDescription()); 81 | t=t->next; 82 | } 83 | } 84 | return true; 85 | } 86 | } listtest; 87 | 88 | 89 | 90 | int main(int argc,char** argv) 91 | { 92 | if (argc>=2) { 93 | Test::runTest(argv[1]); 94 | } 95 | else { 96 | Test::runAllTests(); 97 | } 98 | 99 | return 0; 100 | } 101 | -------------------------------------------------------------------------------- /extra/getopt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1987, 1993, 1994, 1996 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the University of 16 | * California, Berkeley and its contributors. 17 | * 4. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | */ 33 | #ifndef __GETOPT_H__ 34 | #define __GETOPT_H__ 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | extern int opterr; /* if error message should be printed */ 41 | extern int optind; /* index into parent argv vector */ 42 | extern int optopt; /* character checked for validity */ 43 | extern int optreset; /* reset getopt */ 44 | extern char *optarg; /* argument associated with option */ 45 | 46 | struct option 47 | { 48 | const char *name; 49 | int has_arg; 50 | int *flag; 51 | int val; 52 | }; 53 | 54 | #define no_argument 0 55 | #define required_argument 1 56 | #define optional_argument 2 57 | 58 | int getopt(int, char**, char*); 59 | int getopt_long(int, char**, char*, struct option*, int*); 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif /* __GETOPT_H__ */ 66 | -------------------------------------------------------------------------------- /libde265/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = subdir-objects 2 | 3 | lib_LTLIBRARIES = libde265.la 4 | 5 | libde265_ladir = \ 6 | $(includedir)/libde265 7 | 8 | libde265_la_CPPFLAGS = 9 | libde265_la_CFLAGS = \ 10 | $(CFLAG_VISIBILITY) \ 11 | -DLIBDE265_EXPORTS 12 | libde265_la_CXXFLAGS = \ 13 | $(CFLAG_VISIBILITY) \ 14 | -DLIBDE265_EXPORTS \ 15 | -I$(top_srcdir) 16 | 17 | if HAVE_VISIBILITY 18 | libde265_la_CFLAGS += -DHAVE_VISIBILITY 19 | libde265_la_CXXFLAGS += -DHAVE_VISIBILITY 20 | endif 21 | 22 | libde265_la_LDFLAGS = -version-info $(LIBDE265_CURRENT):$(LIBDE265_REVISION):$(LIBDE265_AGE) 23 | 24 | libde265_la_SOURCES = \ 25 | acceleration.h \ 26 | alloc_pool.h \ 27 | alloc_pool.cc \ 28 | bitstream.cc \ 29 | bitstream.h \ 30 | cabac.cc \ 31 | cabac.h \ 32 | configparam.cc \ 33 | configparam.h \ 34 | contextmodel.cc \ 35 | contextmodel.h \ 36 | de265.cc \ 37 | deblock.cc \ 38 | deblock.h \ 39 | decctx.cc \ 40 | decctx.h \ 41 | fallback.cc \ 42 | fallback.h \ 43 | fallback-dct.h \ 44 | fallback-dct.cc \ 45 | fallback-motion.cc \ 46 | fallback-motion.h \ 47 | dpb.cc \ 48 | dpb.h \ 49 | image.cc \ 50 | image.h \ 51 | image-io.h \ 52 | image-io.cc \ 53 | intrapred.cc \ 54 | intrapred.h \ 55 | md5.cc \ 56 | md5.h \ 57 | motion.cc \ 58 | motion.h \ 59 | nal.cc \ 60 | nal.h \ 61 | nal-parser.cc \ 62 | nal-parser.h \ 63 | pps.cc \ 64 | pps.h \ 65 | quality.cc \ 66 | quality.h \ 67 | refpic.cc \ 68 | refpic.h \ 69 | sao.cc \ 70 | sao.h \ 71 | scan.cc \ 72 | scan.h \ 73 | sei.cc \ 74 | sei.h \ 75 | slice.cc \ 76 | slice.h \ 77 | sps.cc \ 78 | sps.h \ 79 | threads.cc \ 80 | threads.h \ 81 | transform.cc \ 82 | transform.h \ 83 | util.cc \ 84 | util.h \ 85 | visualize.cc \ 86 | visualize.h \ 87 | vps.cc \ 88 | vps.h \ 89 | vui.cc \ 90 | vui.h 91 | 92 | SUBDIRS = 93 | libde265_la_LIBADD = 94 | 95 | if ENABLE_ENCODER 96 | libde265_la_SOURCES += en265.h en265.cc 97 | SUBDIRS += encoder 98 | libde265_la_LIBADD += encoder/libde265_encoder.la 99 | endif 100 | 101 | if ENABLE_SSE_OPT 102 | SUBDIRS += x86 103 | libde265_la_LIBADD += x86/libde265_x86.la 104 | endif 105 | 106 | if ENABLE_ARM_OPT 107 | SUBDIRS += arm 108 | libde265_la_LIBADD += arm/libde265_arm.la 109 | endif 110 | 111 | if MINGW 112 | libde265_la_SOURCES += ../extra/win32cond.c ../extra/win32cond.h 113 | libde265_la_LDFLAGS += -no-undefined -static-libgcc -static-libstdc++ 114 | endif 115 | 116 | EXTRA_DIST = Makefile.vc7 \ 117 | CMakeLists.txt \ 118 | ../extra/stdbool.h \ 119 | ../extra/stdint.h 120 | 121 | libde265_la_HEADERS = \ 122 | de265.h \ 123 | de265-version.h 124 | -------------------------------------------------------------------------------- /sherlock265/VideoWidget.cc: -------------------------------------------------------------------------------- 1 | /* 2 | libde265 example application "sherlock265". 3 | 4 | MIT License 5 | 6 | Copyright (c) 2013-2014 struktur AG, Dirk Farin 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | */ 26 | 27 | #include "VideoWidget.hh" 28 | #include 29 | 30 | 31 | VideoWidget::VideoWidget(QWidget *parent) 32 | : QWidget(parent), mImg(NULL) 33 | { 34 | setAutoFillBackground(false); 35 | setAttribute(Qt::WA_NoSystemBackground, true); 36 | 37 | QPalette palette = this->palette(); 38 | palette.setColor(QPalette::Background, Qt::black); 39 | setPalette(palette); 40 | 41 | setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); 42 | 43 | setUpdatesEnabled(true); 44 | } 45 | 46 | VideoWidget::~VideoWidget() 47 | { 48 | } 49 | 50 | 51 | QSize VideoWidget::sizeHint() const 52 | { 53 | return QSize(352,288); 54 | } 55 | 56 | 57 | void VideoWidget::paintEvent(QPaintEvent *event) 58 | { 59 | QPainter painter(this); 60 | 61 | if (mImg) { 62 | QRect videoRect = mImg->rect(); 63 | videoRect.moveCenter(this->rect().center()); 64 | 65 | QRect erect = event->rect(); 66 | 67 | if (!videoRect.contains(event->rect())) { 68 | QRegion region = event->region(); 69 | region = region.subtracted(videoRect); 70 | 71 | QBrush brush = palette().background(); 72 | 73 | foreach (const QRect &rect, region.rects()) { 74 | painter.fillRect(rect, brush); 75 | } 76 | } 77 | 78 | painter.drawImage(videoRect, *mImg); 79 | } else { 80 | painter.fillRect(event->rect(), palette().background()); 81 | } 82 | } 83 | 84 | void VideoWidget::resizeEvent(QResizeEvent *event) 85 | { 86 | QWidget::resizeEvent(event); 87 | } 88 | -------------------------------------------------------------------------------- /libde265/encoder/algo/cb-split.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * Authors: Dirk Farin 6 | * 7 | * This file is part of libde265. 8 | * 9 | * libde265 is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of 12 | * the License, or (at your option) any later version. 13 | * 14 | * libde265 is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with libde265. If not, see . 21 | */ 22 | 23 | #ifndef CB_SPLIT_H 24 | #define CB_SPLIT_H 25 | 26 | #include "libde265/nal-parser.h" 27 | #include "libde265/decctx.h" 28 | #include "libde265/slice.h" 29 | #include "libde265/scan.h" 30 | #include "libde265/intrapred.h" 31 | #include "libde265/transform.h" 32 | #include "libde265/fallback-dct.h" 33 | #include "libde265/quality.h" 34 | #include "libde265/fallback.h" 35 | #include "libde265/configparam.h" 36 | 37 | #include "libde265/encoder/algo/algo.h" 38 | #include "libde265/encoder/algo/tb-intrapredmode.h" 39 | #include "libde265/encoder/algo/tb-split.h" 40 | 41 | 42 | /* Encoder search tree, bottom up: 43 | 44 | - Algo_TB_Split - whether TB is split or not 45 | 46 | - Algo_TB_IntraPredMode - choose the intra prediction mode (or NOP, if at the wrong tree level) 47 | 48 | - Algo_CB_IntraPartMode - choose between NxN and 2Nx2N intra parts 49 | 50 | - Algo_CB_Split - whether CB is split or not 51 | 52 | - Algo_CTB_QScale - select QScale on CTB granularity 53 | */ 54 | 55 | 56 | // ========== CB split decision ========== 57 | 58 | class Algo_CB_Split : public Algo_CB 59 | { 60 | public: 61 | virtual ~Algo_CB_Split() { } 62 | 63 | // TODO: probably, this will later be a intra/inter decision which again 64 | // has two child algorithms, depending on the coding mode. 65 | void setChildAlgo(Algo_CB* algo) { mChildAlgo = algo; } 66 | 67 | const char* name() const { return "cb-split"; } 68 | 69 | protected: 70 | Algo_CB* mChildAlgo; 71 | 72 | enc_cb* encode_cb_split(encoder_context* ectx, 73 | context_model_table& ctxModel, 74 | enc_cb* cb); 75 | }; 76 | 77 | 78 | class Algo_CB_Split_BruteForce : public Algo_CB_Split 79 | { 80 | public: 81 | virtual enc_cb* analyze(encoder_context*, 82 | context_model_table&, 83 | enc_cb* cb); 84 | 85 | const char* name() const { return "cb-split-bruteforce"; } 86 | }; 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /libde265/encoder/algo/algo.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * Authors: Dirk Farin 6 | * 7 | * This file is part of libde265. 8 | * 9 | * libde265 is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of 12 | * the License, or (at your option) any later version. 13 | * 14 | * libde265 is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with libde265. If not, see . 21 | */ 22 | 23 | #include "libde265/encoder/algo/algo.h" 24 | #include "libde265/encoder/encoder-context.h" 25 | 26 | #include 27 | 28 | 29 | 30 | #ifdef DE265_LOG_DEBUG 31 | static int descendLevel = 0; 32 | 33 | void Algo::enter() 34 | { 35 | if (logdebug_enabled(LogEncoder)) { 36 | printf("%d",descendLevel+1); 37 | for (int i=0;i%s(", name()); 54 | vfprintf(stdout, option, va); 55 | fprintf(stdout, ") %d;%d %dx%d %p\n",node->x,node->y,1<log2Size,1<log2Size,node); 56 | } 57 | } 58 | 59 | void Algo::ascend(const enc_node* resultNode, const char* fmt, ...) 60 | { 61 | if (logdebug_enabled(LogEncoder)) { 62 | if (fmt != NULL) { 63 | printf("%d ",descendLevel); 64 | for (int i=0;ix,node->y,1<log2Size,1<log2Size); 92 | } 93 | } 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /libde265/encoder/encoder-motion.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #include "encoder/encoder-motion.h" 22 | #include "encoder/encoder-context.h" 23 | #include "decctx.h" 24 | #include "util.h" 25 | #include "dpb.h" 26 | #include "motion.h" 27 | 28 | #include 29 | 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | #if defined(_MSC_VER) || defined(__MINGW32__) 36 | # include 37 | #elif defined(HAVE_ALLOCA_H) 38 | # include 39 | #endif 40 | 41 | 42 | class MotionVectorAccess_encoder_context : public MotionVectorAccess 43 | { 44 | public: 45 | MotionVectorAccess_encoder_context(const encoder_context* e) : ectx(e) { } 46 | 47 | enum PartMode get_PartMode(int x,int y) const override { return ectx->ctbs.getCB(x,y)->PartMode; } 48 | const PBMotion& get_mv_info(int x,int y) const override { return ectx->ctbs.getPB(x,y)->motion; } 49 | 50 | private: 51 | const encoder_context* ectx; 52 | }; 53 | 54 | 55 | 56 | void get_merge_candidate_list_from_tree(encoder_context* ectx, 57 | const slice_segment_header* shdr, 58 | int xC,int yC, int xP,int yP, 59 | int nCS, int nPbW,int nPbH, int partIdx, 60 | PBMotion* mergeCandList) 61 | { 62 | int max_merge_idx = 5-shdr->five_minus_max_num_merge_cand -1; 63 | 64 | get_merge_candidate_list_without_step_9(ectx, shdr, 65 | MotionVectorAccess_encoder_context(ectx), ectx->img, 66 | xC,yC,xP,yP,nCS,nPbW,nPbH, partIdx, 67 | max_merge_idx, mergeCandList); 68 | 69 | // 9. for encoder: modify all merge candidates 70 | 71 | for (int i=0;i<=max_merge_idx;i++) { 72 | if (mergeCandList[i].predFlag[0] && 73 | mergeCandList[i].predFlag[1] && 74 | nPbW+nPbH==12) 75 | { 76 | mergeCandList[i].refIdx[1] = -1; 77 | mergeCandList[i].predFlag[1] = 0; 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /scripts/ci-before-install-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eu 3 | # 4 | # H.265 video codec. 5 | # Copyright (c) 2018 struktur AG, Joachim Bauch 6 | # 7 | # This file is part of libde265. 8 | # 9 | # libde265 is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # libde265 is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with libde265. If not, see . 21 | # 22 | 23 | INSTALL_PACKAGES= 24 | UPDATE_APT= 25 | 26 | # Output something once per minute to avoid being killed for inactivity. 27 | while true; do echo "Still alive at $(date) ..."; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & 28 | 29 | if [ -z "$HOST" ]; then 30 | INSTALL_PACKAGES="$INSTALL_PACKAGES \ 31 | valgrind \ 32 | libsdl-dev \ 33 | libqt4-dev \ 34 | libswscale-dev \ 35 | " 36 | fi 37 | 38 | if [ -z "$HOST" ] && [ -z "$DECODESTREAMS" ]; then 39 | INSTALL_PACKAGES="$INSTALL_PACKAGES \ 40 | devscripts \ 41 | " 42 | fi 43 | 44 | if [ ! -z "$WINE" ]; then 45 | INSTALL_PACKAGES="$INSTALL_PACKAGES \ 46 | wine \ 47 | " 48 | fi 49 | if [ "$WINE" = "wine" ]; then 50 | INSTALL_PACKAGES="$INSTALL_PACKAGES \ 51 | gcc-mingw-w64-i686 \ 52 | g++-mingw-w64-i686 \ 53 | binutils-mingw-w64-i686 \ 54 | mingw-w64-i686-dev \ 55 | " 56 | elif [ "$WINE" = "wine64" ]; then 57 | INSTALL_PACKAGES="$INSTALL_PACKAGES \ 58 | gcc-mingw-w64-x86-64 \ 59 | g++-mingw-w64-x86-64 \ 60 | binutils-mingw-w64-x86-64 \ 61 | mingw-w64-x86-64-dev \ 62 | " 63 | fi 64 | 65 | if ( echo "$HOST" | grep -q "^arm" ); then 66 | INSTALL_PACKAGES="$INSTALL_PACKAGES \ 67 | g++-arm-linux-gnueabihf \ 68 | gcc-arm-linux-gnueabihf \ 69 | qemu-user \ 70 | " 71 | fi 72 | 73 | if [ ! -z "$DECODESTREAMS" ]; then 74 | sudo add-apt-repository -y ppa:strukturag/libde265 75 | UPDATE_APT=1 76 | INSTALL_PACKAGES="$INSTALL_PACKAGES \ 77 | $DECODESTREAMS \ 78 | " 79 | fi 80 | 81 | if [ "$HOST" = "cmake" ]; then 82 | INSTALL_PACKAGES="$INSTALL_PACKAGES \ 83 | cmake \ 84 | " 85 | fi 86 | 87 | if [ ! -z "$UPDATE_APT" ]; then 88 | echo "Updating package lists ..." 89 | sudo apt-get update -qq 90 | fi 91 | 92 | if [ ! -z "$INSTALL_PACKAGES" ]; then 93 | echo "Installing packages $INSTALL_PACKAGES ..." 94 | sudo apt-get install -qq $INSTALL_PACKAGES 95 | fi 96 | -------------------------------------------------------------------------------- /dec265/sdl.hh: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of dec265, an example application using libde265. 3 | 4 | MIT License 5 | 6 | Copyright (c) 2013-2014 struktur AG, Dirk Farin 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | */ 26 | 27 | #include 28 | 29 | 30 | class SDL_YUV_Display 31 | { 32 | public: 33 | 34 | enum SDL_Chroma { 35 | SDL_CHROMA_MONO=400, 36 | SDL_CHROMA_420 =420, 37 | SDL_CHROMA_422 =422, 38 | SDL_CHROMA_444 =444 39 | }; 40 | 41 | bool init(int frame_width, int frame_height, enum SDL_Chroma chroma = SDL_CHROMA_420); 42 | void display(const unsigned char *Y, const unsigned char *U, const unsigned char *V, 43 | int stride, int chroma_stride); 44 | void close(); 45 | 46 | bool doQuit() const; 47 | 48 | bool isOpen() const { return mWindowOpen; } 49 | 50 | private: 51 | SDL_Surface *mScreen; 52 | SDL_Overlay *mYUVOverlay; 53 | SDL_Rect rect; 54 | bool mWindowOpen; 55 | 56 | SDL_Chroma mChroma; 57 | 58 | void display400(const unsigned char *Y, 59 | int stride); 60 | void display420(const unsigned char *Y, 61 | const unsigned char *U, 62 | const unsigned char *V, 63 | int stride, int chroma_stride); 64 | void display422(const unsigned char *Y, 65 | const unsigned char *U, 66 | const unsigned char *V, 67 | int stride, int chroma_stride); 68 | void display444as422(const unsigned char *Y, 69 | const unsigned char *U, 70 | const unsigned char *V, 71 | int stride, int chroma_stride); 72 | void display444as420(const unsigned char *Y, 73 | const unsigned char *U, 74 | const unsigned char *V, 75 | int stride, int chroma_stride); 76 | }; 77 | -------------------------------------------------------------------------------- /libde265/Makefile.vc7: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Microsoft Visual Studio 2003 3 | # 4 | CFLAGS=/I..\extra /I.. /I. 5 | CC=cl /nologo 6 | LINK=link /nologo /subsystem:console 7 | DEFINES=/DWIN32 /D_WIN32_WINNT=0x0400 /DNDEBUG /DLIBDE265_EXPORTS /D_CRT_SECURE_NO_WARNINGS /DHAVE_SSE4_1 /DHAVE_STDINT_H 8 | 9 | CFLAGS=$(CFLAGS) /MT /Ox /Ob2 /Oi /TP /W4 /GL /EHsc 10 | 11 | # type conversion, possible loss of data 12 | CFLAGS=$(CFLAGS) /wd4244 13 | # unreferenced formal parameter 14 | CFLAGS=$(CFLAGS) /wd4100 15 | # local variable is initialized but not referenced 16 | CFLAGS=$(CFLAGS) /wd4189 17 | # unreferenced local function has been removed 18 | CFLAGS=$(CFLAGS) /wd4505 19 | # padded structures 20 | CFLAGS=$(CFLAGS) /wd4324 21 | # conversion signed/unsigned 22 | CFLAGS=$(CFLAGS) /wd4245 23 | # comparison signed/unsigned 24 | CFLAGS=$(CFLAGS) /wd4018 /wd4389 25 | # possible loss of data with return 26 | CFLAGS=$(CFLAGS) /wd4267 27 | # forcing value to bool (performance warning) 28 | CFLAGS=$(CFLAGS) /wd4800 29 | 30 | CFLAGS=$(CFLAGS) $(DEFINES) 31 | 32 | OBJS=\ 33 | alloc_pool.obj \ 34 | bitstream.obj \ 35 | cabac.obj \ 36 | configparam.obj \ 37 | contextmodel.obj \ 38 | de265.obj \ 39 | deblock.obj \ 40 | decctx.obj \ 41 | dpb.obj \ 42 | en265.obj \ 43 | fallback-dct.obj \ 44 | fallback-motion.obj \ 45 | fallback.obj \ 46 | image.obj \ 47 | image-io.obj \ 48 | intrapred.obj \ 49 | md5.obj \ 50 | motion.obj \ 51 | nal.obj \ 52 | nal-parser.obj \ 53 | pps.obj \ 54 | quality.obj \ 55 | refpic.obj \ 56 | sao.obj \ 57 | scan.obj \ 58 | sei.obj \ 59 | slice.obj \ 60 | sps.obj \ 61 | threads.obj \ 62 | transform.obj \ 63 | util.obj \ 64 | visualize.obj \ 65 | vps.obj \ 66 | vui.obj \ 67 | encoder\encoder-core.obj \ 68 | encoder\encoder-types.obj \ 69 | encoder\encoder-context.obj \ 70 | encoder\encoder-params.obj \ 71 | encoder\encoder-syntax.obj \ 72 | encoder\encoder-intrapred.obj \ 73 | encoder\encoder-motion.obj \ 74 | encoder\encpicbuf.obj \ 75 | encoder\sop.obj \ 76 | encoder\algo\algo.obj \ 77 | encoder\algo\cb-interpartmode.obj \ 78 | encoder\algo\cb-intra-inter.obj \ 79 | encoder\algo\cb-intrapartmode.obj \ 80 | encoder\algo\cb-mergeindex.obj \ 81 | encoder\algo\cb-skip.obj \ 82 | encoder\algo\cb-split.obj \ 83 | encoder\algo\coding-options.obj \ 84 | encoder\algo\ctb-qscale.obj \ 85 | encoder\algo\pb-mv.obj \ 86 | encoder\algo\tb-intrapredmode.obj \ 87 | encoder\algo\tb-rateestim.obj \ 88 | encoder\algo\tb-split.obj \ 89 | encoder\algo\tb-transform.obj \ 90 | x86\sse.obj \ 91 | x86\sse-dct.obj \ 92 | x86\sse-motion.obj \ 93 | ..\extra\win32cond.obj 94 | 95 | all: libde265.dll 96 | 97 | .c.obj: 98 | $(CC) /c $*.c /Fo$*.obj $(CFLAGS) 99 | 100 | .cc.obj: 101 | $(CC) /c $*.cc /Fo$*.obj $(CFLAGS) 102 | 103 | libde265.dll: $(OBJS) 104 | $(LINK) /dll /out:libde265.dll $** 105 | 106 | clean: 107 | del libde265.dll 108 | del $(OBJS) 109 | -------------------------------------------------------------------------------- /libde265/encoder/algo/tb-transform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * Authors: Dirk Farin 6 | * 7 | * This file is part of libde265. 8 | * 9 | * libde265 is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of 12 | * the License, or (at your option) any later version. 13 | * 14 | * libde265 is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with libde265. If not, see . 21 | */ 22 | 23 | #ifndef TB_TRANSFORM_H 24 | #define TB_TRANSFORM_H 25 | 26 | #include "libde265/nal-parser.h" 27 | #include "libde265/decctx.h" 28 | #include "libde265/encoder/encoder-types.h" 29 | #include "libde265/encoder/algo/algo.h" 30 | #include "libde265/slice.h" 31 | #include "libde265/scan.h" 32 | #include "libde265/intrapred.h" 33 | #include "libde265/transform.h" 34 | #include "libde265/fallback-dct.h" 35 | #include "libde265/quality.h" 36 | #include "libde265/fallback.h" 37 | #include "libde265/configparam.h" 38 | 39 | #include "libde265/encoder/algo/tb-intrapredmode.h" 40 | #include "libde265/encoder/algo/tb-rateestim.h" 41 | 42 | 43 | void diff_blk(int16_t* out,int out_stride, 44 | const uint8_t* a_ptr, int a_stride, 45 | const uint8_t* b_ptr, int b_stride, 46 | int blkSize); 47 | 48 | 49 | // ========== TB split decision ========== 50 | 51 | class Algo_TB_Residual : public Algo 52 | { 53 | public: 54 | Algo_TB_Residual() { } 55 | 56 | virtual enc_tb* analyze(encoder_context*, 57 | context_model_table&, 58 | const de265_image* input, 59 | enc_tb* tb, 60 | int TrafoDepth, int MaxTrafoDepth, int IntraSplitFlag) = 0; 61 | 62 | const char* name() const { return "residual-unknown"; } 63 | }; 64 | 65 | 66 | class Algo_TB_Transform : public Algo_TB_Residual 67 | { 68 | public: 69 | Algo_TB_Transform() : mAlgo_TB_RateEstimation(NULL) { } 70 | 71 | virtual enc_tb* analyze(encoder_context*, 72 | context_model_table&, 73 | const de265_image* input, 74 | enc_tb* parent, 75 | int TrafoDepth, int MaxTrafoDepth, int IntraSplitFlag); 76 | 77 | void setAlgo_TB_RateEstimation(Algo_TB_RateEstimation* algo) { mAlgo_TB_RateEstimation=algo; } 78 | 79 | const char* name() const { return "residual-FDCT"; } 80 | 81 | protected: 82 | Algo_TB_RateEstimation* mAlgo_TB_RateEstimation; 83 | }; 84 | 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /libde265/quality.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #include "quality.h" 22 | #include 23 | 24 | 25 | uint32_t SSD(const uint8_t* img, int imgStride, 26 | const uint8_t* ref, int refStride, 27 | int width, int height) 28 | { 29 | uint32_t sum=0; 30 | 31 | const uint8_t* iPtr = img; 32 | const uint8_t* rPtr = ref; 33 | 34 | for (int y=0;yget_image_plane_at_pos(cIdx,x0,y0), img1->get_image_stride(cIdx), 109 | img2->get_image_plane_at_pos(cIdx,x0,y0), img2->get_image_stride(cIdx), 110 | 1< 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #ifndef DE265_SEI_H 22 | #define DE265_SEI_H 23 | 24 | #include "libde265/bitstream.h" 25 | #include "libde265/de265.h" 26 | 27 | 28 | enum sei_payload_type { 29 | sei_payload_type_buffering_period = 0, 30 | sei_payload_type_pic_timing = 1, 31 | sei_payload_type_pan_scan_rect = 2, 32 | sei_payload_type_filler_payload = 3, 33 | sei_payload_type_user_data_registered_itu_t_t35 = 4, 34 | sei_payload_type_user_data_unregistered = 5, 35 | sei_payload_type_recovery_point = 6, 36 | sei_payload_type_scene_info = 9, 37 | sei_payload_type_picture_snapshot = 15, 38 | sei_payload_type_progressive_refinement_segment_start = 16, 39 | sei_payload_type_progressive_refinement_segment_end = 17, 40 | sei_payload_type_film_grain_characteristics = 19, 41 | sei_payload_type_post_filter_hint = 22, 42 | sei_payload_type_tone_mapping_info = 23, 43 | sei_payload_type_frame_packing_arrangement = 45, 44 | sei_payload_type_display_orientation = 47, 45 | sei_payload_type_structure_of_pictures_info = 128, 46 | sei_payload_type_active_parameter_sets = 129, 47 | sei_payload_type_decoding_unit_info = 130, 48 | sei_payload_type_temporal_sub_layer_zero_index = 131, 49 | sei_payload_type_decoded_picture_hash = 132, 50 | sei_payload_type_scalable_nesting = 133, 51 | sei_payload_type_region_refresh_info = 134, 52 | sei_payload_type_no_display = 135, 53 | sei_payload_type_motion_constrained_tile_sets = 136 54 | }; 55 | 56 | 57 | enum sei_decoded_picture_hash_type { 58 | sei_decoded_picture_hash_type_MD5 = 0, 59 | sei_decoded_picture_hash_type_CRC = 1, 60 | sei_decoded_picture_hash_type_checksum = 2 61 | }; 62 | 63 | 64 | typedef struct { 65 | enum sei_decoded_picture_hash_type hash_type; 66 | uint8_t md5[3][16]; 67 | uint16_t crc[3]; 68 | uint32_t checksum[3]; 69 | } sei_decoded_picture_hash; 70 | 71 | 72 | typedef struct { 73 | enum sei_payload_type payload_type; 74 | int payload_size; 75 | 76 | union { 77 | sei_decoded_picture_hash decoded_picture_hash; 78 | } data; 79 | } sei_message; 80 | 81 | class seq_parameter_set; 82 | 83 | const char* sei_type_name(enum sei_payload_type type); 84 | 85 | de265_error read_sei(bitreader* reader, sei_message*, bool suffix, const seq_parameter_set* sps); 86 | void dump_sei(const sei_message*, const seq_parameter_set* sps); 87 | de265_error process_sei(const sei_message*, struct de265_image* img); 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /libde265/encoder/encoder-params.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * Authors: struktur AG, Dirk Farin 6 | * 7 | * This file is part of libde265. 8 | * 9 | * libde265 is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of 12 | * the License, or (at your option) any later version. 13 | * 14 | * libde265 is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with libde265. If not, see . 21 | */ 22 | 23 | #include "encoder-params.h" 24 | 25 | 26 | 27 | static std::vector power2range(int low,int high) 28 | { 29 | std::vector vals; 30 | for (int i=low; i<=high; i*=2) 31 | vals.push_back(i); 32 | return vals; 33 | } 34 | 35 | encoder_params::encoder_params() 36 | { 37 | //rateControlMethod = RateControlMethod_ConstantQP; 38 | 39 | min_cb_size.set_ID("min-cb-size"); min_cb_size.set_valid_values(power2range(8,64)); min_cb_size.set_default(8); 40 | max_cb_size.set_ID("max-cb-size"); max_cb_size.set_valid_values(power2range(8,64)); max_cb_size.set_default(32); 41 | min_tb_size.set_ID("min-tb-size"); min_tb_size.set_valid_values(power2range(4,32)); min_tb_size.set_default(4); 42 | max_tb_size.set_ID("max-tb-size"); max_tb_size.set_valid_values(power2range(8,32)); max_tb_size.set_default(32); 43 | 44 | max_transform_hierarchy_depth_intra.set_ID("max-transform-hierarchy-depth-intra"); 45 | max_transform_hierarchy_depth_intra.set_range(0,4); 46 | max_transform_hierarchy_depth_intra.set_default(3); 47 | 48 | max_transform_hierarchy_depth_inter.set_ID("max-transform-hierarchy-depth-inter"); 49 | max_transform_hierarchy_depth_inter.set_range(0,4); 50 | max_transform_hierarchy_depth_inter.set_default(3); 51 | 52 | sop_structure.set_ID("sop-structure"); 53 | 54 | mAlgo_TB_IntraPredMode.set_ID("TB-IntraPredMode"); 55 | mAlgo_TB_IntraPredMode_Subset.set_ID("TB-IntraPredMode-subset"); 56 | mAlgo_CB_IntraPartMode.set_ID("CB-IntraPartMode"); 57 | 58 | mAlgo_TB_RateEstimation.set_ID("TB-RateEstimation"); 59 | 60 | mAlgo_MEMode.set_ID("MEMode"); 61 | } 62 | 63 | 64 | void encoder_params::registerParams(config_parameters& config) 65 | { 66 | config.add_option(&min_cb_size); 67 | config.add_option(&max_cb_size); 68 | config.add_option(&min_tb_size); 69 | config.add_option(&max_tb_size); 70 | config.add_option(&max_transform_hierarchy_depth_intra); 71 | config.add_option(&max_transform_hierarchy_depth_inter); 72 | 73 | config.add_option(&sop_structure); 74 | 75 | config.add_option(&mAlgo_TB_IntraPredMode); 76 | config.add_option(&mAlgo_TB_IntraPredMode_Subset); 77 | config.add_option(&mAlgo_CB_IntraPartMode); 78 | 79 | config.add_option(&mAlgo_MEMode); 80 | config.add_option(&mAlgo_TB_RateEstimation); 81 | 82 | mSOP_LowDelay.registerParams(config); 83 | } 84 | -------------------------------------------------------------------------------- /libde265/wasm/simd.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2020, Dmitry Ilyin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #include "wasm/simd.h" 22 | #include "wasm/simd-dct.h" 23 | #include "wasm/simd-motion.h" 24 | 25 | void init_acceleration_functions_wasm(struct acceleration_functions *accel) { 26 | accel->put_unweighted_pred_8 = ff_hevc_put_unweighted_pred_8_wasm; 27 | 28 | accel->put_weighted_pred_avg_8 = ff_hevc_put_weighted_pred_avg_8_wasm; 29 | 30 | accel->put_hevc_epel_8 = ff_hevc_put_hevc_epel_pixels_8_wasm; 31 | accel->put_hevc_epel_h_8 = ff_hevc_put_hevc_epel_h_8_wasm; 32 | accel->put_hevc_epel_v_8 = ff_hevc_put_hevc_epel_v_8_wasm; 33 | accel->put_hevc_epel_hv_8 = ff_hevc_put_hevc_epel_hv_8_wasm; 34 | 35 | accel->put_hevc_qpel_8[0][0] = ff_hevc_put_hevc_qpel_pixels_8_wasm; 36 | accel->put_hevc_qpel_8[0][1] = ff_hevc_put_hevc_qpel_v_1_8_wasm; 37 | accel->put_hevc_qpel_8[0][2] = ff_hevc_put_hevc_qpel_v_2_8_wasm; 38 | accel->put_hevc_qpel_8[0][3] = ff_hevc_put_hevc_qpel_v_3_8_wasm; 39 | accel->put_hevc_qpel_8[1][0] = ff_hevc_put_hevc_qpel_h_1_8_wasm; 40 | accel->put_hevc_qpel_8[1][1] = ff_hevc_put_hevc_qpel_h_1_v_1_wasm; 41 | accel->put_hevc_qpel_8[1][2] = ff_hevc_put_hevc_qpel_h_1_v_2_wasm; 42 | accel->put_hevc_qpel_8[1][3] = ff_hevc_put_hevc_qpel_h_1_v_3_wasm; 43 | accel->put_hevc_qpel_8[2][0] = ff_hevc_put_hevc_qpel_h_2_8_wasm; 44 | accel->put_hevc_qpel_8[2][1] = ff_hevc_put_hevc_qpel_h_2_v_1_wasm; 45 | accel->put_hevc_qpel_8[2][2] = ff_hevc_put_hevc_qpel_h_2_v_2_wasm; 46 | accel->put_hevc_qpel_8[2][3] = ff_hevc_put_hevc_qpel_h_2_v_3_wasm; 47 | accel->put_hevc_qpel_8[3][0] = ff_hevc_put_hevc_qpel_h_3_8_wasm; 48 | accel->put_hevc_qpel_8[3][1] = ff_hevc_put_hevc_qpel_h_3_v_1_wasm; 49 | accel->put_hevc_qpel_8[3][2] = ff_hevc_put_hevc_qpel_h_3_v_2_wasm; 50 | accel->put_hevc_qpel_8[3][3] = ff_hevc_put_hevc_qpel_h_3_v_3_wasm; 51 | 52 | accel->transform_skip_8 = ff_hevc_transform_skip_8_wasm; 53 | 54 | // actually, for these two functions, the scalar fallback seems to be faster 55 | // than the SSE code 56 | //accel->transform_4x4_luma_add_8 = ff_hevc_transform_4x4_luma_add_8_wasm; 57 | // SSE-4 only TODO 58 | //accel->transform_4x4_add_8 = ff_hevc_transform_4x4_add_8_wasm; 59 | 60 | accel->transform_add_8[1] = ff_hevc_transform_8x8_add_8_wasm; 61 | accel->transform_add_8[2] = ff_hevc_transform_16x16_add_8_wasm; 62 | accel->transform_add_8[3] = ff_hevc_transform_32x32_add_8_wasm; 63 | accel->put_unweighted_pred_8 = ff_hevc_put_unweighted_pred_8_wasm; 64 | accel->put_weighted_pred_avg_8 = ff_hevc_put_weighted_pred_avg_8_wasm; 65 | } 66 | -------------------------------------------------------------------------------- /tools/yuv-distortion.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include "config.h" 23 | #endif 24 | 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | #if HAVE_VIDEOGFX 31 | #include 32 | using namespace videogfx; 33 | #endif 34 | 35 | 36 | float ssim(const uint8_t* img1, 37 | const uint8_t* img2, 38 | int width, int height) 39 | { 40 | #if HAVE_VIDEOGFX 41 | Bitmap ref, coded; 42 | ref .Create(width, height); // reference image 43 | coded.Create(width, height); // coded image 44 | 45 | for (int y=0;y 4 | * 5 | * Authors: Dirk Farin 6 | * 7 | * This file is part of libde265. 8 | * 9 | * libde265 is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of 12 | * the License, or (at your option) any later version. 13 | * 14 | * libde265 is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with libde265. If not, see . 21 | */ 22 | 23 | #ifndef CTB_QSCALE_H 24 | #define CTB_QSCALE_H 25 | 26 | #include "libde265/nal-parser.h" 27 | #include "libde265/decctx.h" 28 | #include "libde265/encoder/algo/algo.h" 29 | #include "libde265/slice.h" 30 | #include "libde265/scan.h" 31 | #include "libde265/intrapred.h" 32 | #include "libde265/transform.h" 33 | #include "libde265/fallback-dct.h" 34 | #include "libde265/quality.h" 35 | #include "libde265/fallback.h" 36 | #include "libde265/configparam.h" 37 | 38 | #include "libde265/encoder/algo/cb-split.h" 39 | 40 | 41 | /* Encoder search tree, bottom up: 42 | 43 | - Algo_TB_Split - whether TB is split or not 44 | 45 | - Algo_TB_IntraPredMode - choose the intra prediction mode (or NOP, if at the wrong tree level) 46 | 47 | - Algo_CB_IntraPartMode - choose between NxN and 2Nx2N intra parts 48 | 49 | - Algo_CB_Split - whether CB is split or not 50 | 51 | - Algo_CTB_QScale - select QScale on CTB granularity 52 | */ 53 | 54 | 55 | // ========== choose a qscale at CTB level ========== 56 | 57 | class Algo_CTB_QScale : public Algo 58 | { 59 | public: 60 | Algo_CTB_QScale() : mChildAlgo(NULL) { } 61 | virtual ~Algo_CTB_QScale() { } 62 | 63 | virtual enc_cb* analyze(encoder_context*, 64 | context_model_table&, 65 | int ctb_x,int ctb_y) = 0; 66 | 67 | void setChildAlgo(Algo_CB_Split* algo) { mChildAlgo = algo; } 68 | 69 | protected: 70 | Algo_CB_Split* mChildAlgo; 71 | }; 72 | 73 | 74 | 75 | class Algo_CTB_QScale_Constant : public Algo_CTB_QScale 76 | { 77 | public: 78 | struct params 79 | { 80 | params() { 81 | mQP.set_range(1,51); 82 | mQP.set_default(27); 83 | mQP.set_ID("CTB-QScale-Constant"); 84 | mQP.set_cmd_line_options("qp",'q'); 85 | } 86 | 87 | option_int mQP; 88 | }; 89 | 90 | void setParams(const params& p) { mParams=p; } 91 | 92 | void registerParams(config_parameters& config) { 93 | config.add_option(&mParams.mQP); 94 | } 95 | 96 | virtual enc_cb* analyze(encoder_context*, 97 | context_model_table&, 98 | int ctb_x,int ctb_y); 99 | 100 | int getQP() const { return mParams.mQP; } 101 | 102 | const char* name() const { return "ctb-qscale-constant"; } 103 | 104 | private: 105 | params mParams; 106 | }; 107 | 108 | 109 | #endif 110 | -------------------------------------------------------------------------------- /tools/block-rate-estim.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | 27 | struct datapoint { 28 | int log2blksize; 29 | float rate; 30 | float estim; 31 | }; 32 | 33 | std::vector pts; 34 | 35 | #define NBINS 100 36 | 37 | /* 38 | #define ESTIMDIV 100 39 | #define MAXESTIM 80000 40 | std::vector bitestim2[MAXESTIM/ESTIMDIV]; 41 | */ 42 | 43 | 44 | 45 | void print_bitestim_results(int log2blksize) 46 | { 47 | float max_estim=0; 48 | 49 | for (int i=0;i0) { 80 | double mean = sum/cnt; 81 | 82 | double var = 0; 83 | 84 | for (int i=0;i> t >> pt.log2blksize >> pt.rate >> pt.estim; 116 | 117 | if (istr.eof()) break; 118 | 119 | if (t == tag) { 120 | pts.push_back(pt); 121 | } 122 | } 123 | 124 | print_bitestim_results(0); 125 | 126 | return 0; 127 | } 128 | -------------------------------------------------------------------------------- /enc265/image-io-png.cc: -------------------------------------------------------------------------------- 1 | /* 2 | libde265 example application "enc265". 3 | 4 | MIT License 5 | 6 | Copyright (c) 2013-2014 struktur AG, Dirk Farin 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | */ 26 | 27 | #include "image-io-png.h" 28 | #include 29 | 30 | #if HAVE_VIDEOGFX 31 | #include 32 | using namespace videogfx; 33 | 34 | 35 | ImageSource_PNG::ImageSource_PNG() 36 | { 37 | mFilenameTemplate = NULL; 38 | mNextImageNumber = 1; 39 | 40 | mReachedEndOfStream = false; 41 | 42 | mWidth=mHeight=0; 43 | } 44 | 45 | ImageSource_PNG::~ImageSource_PNG() 46 | { 47 | } 48 | 49 | bool ImageSource_PNG::set_input_file(const char* filename) 50 | { 51 | mFilenameTemplate = filename; 52 | return true; 53 | } 54 | 55 | de265_image* ImageSource_PNG::get_image(bool block) 56 | { 57 | if (mReachedEndOfStream) return NULL; 58 | 59 | 60 | // --- construct image filename --- 61 | 62 | char filename[1000]; 63 | sprintf(filename,mFilenameTemplate,mNextImageNumber); 64 | mNextImageNumber++; 65 | 66 | 67 | // --- load image --- 68 | 69 | Image input; 70 | bool success = videogfx::ReadImage_PNG(input, filename); 71 | if (!success) { 72 | mReachedEndOfStream = true; 73 | return NULL; 74 | } 75 | 76 | 77 | mWidth = input.AskWidth(); 78 | mHeight= input.AskHeight(); 79 | 80 | de265_image* img = new de265_image; 81 | img->alloc_image(mWidth,mHeight,de265_chroma_444, NULL, false, 82 | NULL, /*NULL,*/ 0, NULL, false); 83 | assert(img); // TODO: error handling 84 | 85 | 86 | uint8_t* p; 87 | int stride; 88 | 89 | for (int c=0;c<3;c++) { 90 | int h265channel; 91 | switch (c) { 92 | case 0: h265channel=2; break; // R 93 | case 1: h265channel=0; break; // G 94 | case 2: h265channel=1; break; // B 95 | } 96 | 97 | p = img->get_image_plane(h265channel); 98 | stride = img->get_image_stride(h265channel); 99 | 100 | for (int y=0;y 4 | * 5 | * Authors: Dirk Farin 6 | * 7 | * This file is part of libde265. 8 | * 9 | * libde265 is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of 12 | * the License, or (at your option) any later version. 13 | * 14 | * libde265 is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with libde265. If not, see . 21 | */ 22 | 23 | #ifndef CB_INTERPARTMODE_H 24 | #define CB_INTERPARTMODE_H 25 | 26 | #include "libde265/nal-parser.h" 27 | #include "libde265/decctx.h" 28 | #include "libde265/slice.h" 29 | #include "libde265/scan.h" 30 | #include "libde265/intrapred.h" 31 | #include "libde265/transform.h" 32 | #include "libde265/fallback-dct.h" 33 | #include "libde265/quality.h" 34 | #include "libde265/fallback.h" 35 | #include "libde265/configparam.h" 36 | 37 | #include "libde265/encoder/algo/algo.h" 38 | #include "libde265/encoder/algo/tb-intrapredmode.h" 39 | #include "libde265/encoder/algo/tb-split.h" 40 | #include "libde265/encoder/algo/cb-intrapartmode.h" 41 | 42 | 43 | // ========== CB Intra/Inter decision ========== 44 | 45 | class Algo_CB_InterPartMode : public Algo_CB 46 | { 47 | public: 48 | virtual ~Algo_CB_InterPartMode() { } 49 | 50 | void setChildAlgo(Algo_PB* algo) { mChildAlgo = algo; } 51 | 52 | virtual const char* name() const { return "cb-interpartmode"; } 53 | 54 | protected: 55 | Algo_PB* mChildAlgo; 56 | 57 | enc_cb* codeAllPBs(encoder_context*, 58 | context_model_table&, 59 | enc_cb* cb); 60 | }; 61 | 62 | 63 | 64 | 65 | class option_InterPartMode : public choice_option // choice_option 66 | { 67 | public: 68 | option_InterPartMode() { 69 | add_choice("2Nx2N", PART_2Nx2N, true); 70 | add_choice("NxN", PART_NxN); 71 | add_choice("Nx2N", PART_Nx2N); 72 | add_choice("2NxN", PART_2NxN); 73 | add_choice("2NxnU", PART_2NxnU); 74 | add_choice("2NxnD", PART_2NxnD); 75 | add_choice("nLx2N", PART_nLx2N); 76 | add_choice("nRx2N", PART_nRx2N); 77 | } 78 | }; 79 | 80 | class Algo_CB_InterPartMode_Fixed : public Algo_CB_InterPartMode 81 | { 82 | public: 83 | struct params 84 | { 85 | params() { 86 | partMode.set_ID("CB-InterPartMode-Fixed-partMode"); 87 | } 88 | 89 | option_InterPartMode partMode; 90 | }; 91 | 92 | void registerParams(config_parameters& config) { 93 | config.add_option(&mParams.partMode); 94 | } 95 | 96 | void setParams(const params& p) { mParams=p; } 97 | 98 | virtual enc_cb* analyze(encoder_context*, 99 | context_model_table&, 100 | enc_cb* cb); 101 | 102 | virtual const char* name() const { return "cb-interpartmode-fixed"; } 103 | 104 | private: 105 | params mParams; 106 | }; 107 | 108 | #endif 109 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # stats available at 2 | # https://travis-ci.org/strukturag/libde265/ 3 | language: cpp 4 | compiler: 5 | - gcc 6 | dist: trusty 7 | cache: ccache 8 | addons: 9 | apt: 10 | update: true 11 | env: 12 | - HOST= WINE= DECODESTREAMS= 13 | - HOST=i686-w64-mingw32 WINE=wine DECODESTREAMS= 14 | - HOST=x86_64-w64-mingw32 WINE=wine64 DECODESTREAMS= 15 | - HOST=arm-linux-gnueabihf WINE= DECODESTREAMS= 16 | - HOST=cmake WINE= DECODESTREAMS= 17 | - HOST= WINE= DECODESTREAMS=libde265-teststreams-fuzzing THREADING= 18 | - HOST= WINE= DECODESTREAMS=libde265-teststreams-fuzzing THREADING=--single-threaded 19 | - HOST= WINE= DECODESTREAMS=libde265-teststreams-nolf THREADING= 20 | - HOST= WINE= DECODESTREAMS=libde265-teststreams-nolf THREADING=--single-threaded 21 | - HOST= WINE= DECODESTREAMS=libde265-teststreams-sao THREADING= 22 | - HOST= WINE= DECODESTREAMS=libde265-teststreams-sao THREADING=--single-threaded 23 | - HOST= WINE= DECODESTREAMS=libde265-teststreams-tiles THREADING= 24 | - HOST= WINE= DECODESTREAMS=libde265-teststreams-tiles THREADING=--single-threaded 25 | - HOST= WINE= DECODESTREAMS=libde265-teststreams-tiles-nolf THREADING= 26 | - HOST= WINE= DECODESTREAMS=libde265-teststreams-tiles-nolf THREADING=--single-threaded 27 | - HOST= WINE= DECODESTREAMS=libde265-teststreams-weighted THREADING= 28 | - HOST= WINE= DECODESTREAMS=libde265-teststreams-weighted THREADING=--single-threaded 29 | - HOST= WINE= DECODESTREAMS=libde265-teststreams-wpp-nolf THREADING= 30 | - HOST= WINE= DECODESTREAMS=libde265-teststreams-wpp-nolf THREADING=--single-threaded 31 | 32 | matrix: 33 | include: 34 | - compiler: clang 35 | env: HOST= WINE= DECODESTREAMS= 36 | - os: osx 37 | compiler: clang 38 | env: HOST= WINE= DECODESTREAMS= 39 | - os: osx 40 | compiler: gcc 41 | env: HOST= WINE= DECODESTREAMS= 42 | - os: osx 43 | compiler: gcc 44 | env: HOST=cmake WINE= DECODESTREAMS= 45 | allow_failures: 46 | - env: HOST= WINE= DECODESTREAMS=libde265-teststreams-fuzzing THREADING= 47 | - env: HOST= WINE= DECODESTREAMS=libde265-teststreams-fuzzing THREADING=--single-threaded 48 | - env: HOST= WINE= DECODESTREAMS=libde265-teststreams-nolf THREADING= 49 | - env: HOST= WINE= DECODESTREAMS=libde265-teststreams-nolf THREADING=--single-threaded 50 | - env: HOST= WINE= DECODESTREAMS=libde265-teststreams-sao THREADING= 51 | - env: HOST= WINE= DECODESTREAMS=libde265-teststreams-sao THREADING=--single-threaded 52 | - env: HOST= WINE= DECODESTREAMS=libde265-teststreams-tiles THREADING= 53 | - env: HOST= WINE= DECODESTREAMS=libde265-teststreams-tiles THREADING=--single-threaded 54 | - env: HOST= WINE= DECODESTREAMS=libde265-teststreams-tiles-nolf THREADING= 55 | - env: HOST= WINE= DECODESTREAMS=libde265-teststreams-tiles-nolf THREADING=--single-threaded 56 | - env: HOST= WINE= DECODESTREAMS=libde265-teststreams-weighted THREADING= 57 | - env: HOST= WINE= DECODESTREAMS=libde265-teststreams-weighted THREADING=--single-threaded 58 | - env: HOST= WINE= DECODESTREAMS=libde265-teststreams-wpp-nolf THREADING= 59 | - env: HOST= WINE= DECODESTREAMS=libde265-teststreams-wpp-nolf THREADING=--single-threaded 60 | 61 | before_install: 62 | - ./scripts/ci-before-install-$TRAVIS_OS_NAME.sh 63 | 64 | install: 65 | - git clone https://github.com/strukturag/libde265-data.git 66 | 67 | before_script: 68 | - ./scripts/ci-before-script.sh 69 | 70 | script: 71 | - ./scripts/ci-run.sh 72 | -------------------------------------------------------------------------------- /libde265/image-io.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * Authors: struktur AG, Dirk Farin 6 | * 7 | * This file is part of libde265. 8 | * 9 | * libde265 is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of 12 | * the License, or (at your option) any later version. 13 | * 14 | * libde265 is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with libde265. If not, see . 21 | */ 22 | 23 | #ifndef IMAGE_IO_H 24 | #define IMAGE_IO_H 25 | 26 | #include "libde265/image.h" 27 | #include 28 | 29 | 30 | class ImageSource 31 | { 32 | public: 33 | LIBDE265_API ImageSource(); 34 | virtual LIBDE265_API ~ImageSource() { } 35 | 36 | //enum ImageStatus { Available, Waiting, EndOfVideo }; 37 | 38 | //virtual ImageStatus get_status() = 0; 39 | virtual LIBDE265_API de265_image* get_image(bool block=true) = 0; 40 | virtual LIBDE265_API void skip_frames(int n) = 0; 41 | 42 | virtual LIBDE265_API int get_width() const = 0; 43 | virtual LIBDE265_API int get_height() const = 0; 44 | }; 45 | 46 | 47 | 48 | class ImageSource_YUV : public ImageSource 49 | { 50 | public: 51 | LIBDE265_API ImageSource_YUV(); 52 | virtual LIBDE265_API ~ImageSource_YUV(); 53 | 54 | bool LIBDE265_API set_input_file(const char* filename, int w,int h); 55 | 56 | //virtual ImageStatus get_status(); 57 | virtual LIBDE265_API de265_image* get_image(bool block=true); 58 | virtual LIBDE265_API void skip_frames(int n); 59 | 60 | virtual LIBDE265_API int get_width() const { return width; } 61 | virtual LIBDE265_API int get_height() const { return height; } 62 | 63 | private: 64 | FILE* mFH; 65 | bool mReachedEndOfFile; 66 | 67 | int width,height; 68 | 69 | de265_image* read_next_image(); 70 | }; 71 | 72 | 73 | 74 | class ImageSink 75 | { 76 | public: 77 | virtual LIBDE265_API ~ImageSink() { } 78 | 79 | virtual LIBDE265_API void send_image(const de265_image* img) = 0; 80 | }; 81 | 82 | class ImageSink_YUV : public ImageSink 83 | { 84 | public: 85 | LIBDE265_API ImageSink_YUV() : mFH(NULL) { } 86 | LIBDE265_API ~ImageSink_YUV(); 87 | 88 | bool LIBDE265_API set_filename(const char* filename); 89 | 90 | virtual LIBDE265_API void send_image(const de265_image* img); 91 | 92 | private: 93 | FILE* mFH; 94 | }; 95 | 96 | 97 | 98 | class PacketSink 99 | { 100 | public: 101 | virtual LIBDE265_API ~PacketSink() { } 102 | 103 | virtual LIBDE265_API void send_packet(const uint8_t* data, int n) = 0; 104 | }; 105 | 106 | 107 | class PacketSink_File : public PacketSink 108 | { 109 | public: 110 | LIBDE265_API PacketSink_File(); 111 | virtual LIBDE265_API ~PacketSink_File(); 112 | 113 | LIBDE265_API void set_filename(const char* filename); 114 | 115 | virtual LIBDE265_API void send_packet(const uint8_t* data, int n); 116 | 117 | private: 118 | FILE* mFH; 119 | }; 120 | 121 | #endif 122 | -------------------------------------------------------------------------------- /libde265/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(CMakePackageConfigHelpers) 2 | 3 | set (libde265_sources 4 | alloc_pool.cc 5 | bitstream.cc 6 | cabac.cc 7 | configparam.cc 8 | contextmodel.cc 9 | de265.cc 10 | deblock.cc 11 | decctx.cc 12 | dpb.cc 13 | en265.cc 14 | fallback-dct.cc 15 | fallback-motion.cc 16 | fallback.cc 17 | image-io.cc 18 | image.cc 19 | intrapred.cc 20 | md5.cc 21 | motion.cc 22 | nal-parser.cc 23 | nal.cc 24 | pps.cc 25 | quality.cc 26 | refpic.cc 27 | sao.cc 28 | scan.cc 29 | sei.cc 30 | slice.cc 31 | sps.cc 32 | threads.cc 33 | transform.cc 34 | util.cc 35 | visualize.cc 36 | vps.cc 37 | vui.cc 38 | ) 39 | 40 | set (libde265_headers 41 | acceleration.h 42 | alloc_pool.h 43 | bitstream.h 44 | cabac.h 45 | configparam.h 46 | de265-version.h 47 | contextmodel.h 48 | de265.h 49 | deblock.h 50 | decctx.h 51 | dpb.h 52 | en265.h 53 | fallback-dct.h 54 | fallback-motion.h 55 | fallback.h 56 | image-io.h 57 | image.h 58 | intrapred.h 59 | md5.h 60 | motion.h 61 | nal-parser.h 62 | nal.h 63 | pps.h 64 | quality.h 65 | refpic.h 66 | sao.h 67 | scan.h 68 | sei.h 69 | slice.h 70 | sps.h 71 | threads.h 72 | transform.h 73 | util.h 74 | visualize.h 75 | vps.h 76 | vui.h 77 | ) 78 | 79 | if(MSVC OR MINGW) 80 | set (libde265_sources 81 | ${libde265_sources} 82 | ../extra/win32cond.c 83 | ../extra/win32cond.h 84 | ) 85 | endif() 86 | 87 | add_definitions(-DLIBDE265_EXPORTS) 88 | 89 | add_subdirectory (encoder) 90 | 91 | if(NOT DISABLE_SIMD) 92 | if (EMSCRIPTEN) 93 | # https://emscripten.org/docs/porting/simd.html 94 | add_subdirectory(wasm) 95 | else() 96 | if (MSVC) 97 | set(SUPPORTS_SSE2 1) 98 | set(SUPPORTS_SSSE3 1) 99 | set(SUPPORTS_SSE4_1 1) 100 | else() 101 | check_c_compiler_flag(-msse2 SUPPORTS_SSE2) 102 | check_c_compiler_flag(-mssse3 SUPPORTS_SSSE3) 103 | check_c_compiler_flag(-msse4.1 SUPPORTS_SSE4_1) 104 | check_c_compiler_flag(-mavx SUPPORTS_AVX) 105 | check_c_compiler_flag(-mavx2 SUPPORTS_AVX2) 106 | endif() 107 | 108 | if(SUPPORTS_SSE4_1) 109 | add_definitions(-DHAVE_SSE4_1) 110 | endif() 111 | if(SUPPORTS_SSE4_1 OR (SUPPORTS_SSE2 AND SUPPORTS_SSSE3)) 112 | add_subdirectory (x86) 113 | endif() 114 | endif() 115 | endif() 116 | 117 | add_library(${PROJECT_NAME} ${libde265_sources} ${ENCODER_OBJECTS} 118 | ${X86_OBJECTS} ${WASM_OBJECTS}) 119 | target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads) 120 | 121 | write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake COMPATIBILITY ExactVersion) 122 | 123 | install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Config 124 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 125 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 126 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} 127 | ) 128 | 129 | install(FILES ${libde265_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}) 130 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/de265-version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}) 131 | 132 | install(EXPORT ${PROJECT_NAME}Config DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") 133 | 134 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake DESTINATION 135 | "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") 136 | -------------------------------------------------------------------------------- /acceleration-speed/dct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2015 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #ifndef ACCELERATION_SPEED_DCT_H 22 | #define ACCELERATION_SPEED_DCT_H 23 | 24 | #include "acceleration-speed.h" 25 | #include "libde265/fallback-dct.h" 26 | 27 | 28 | class DSPFunc_FDCT_Base : public DSPFunc 29 | { 30 | public: 31 | DSPFunc_FDCT_Base(int size) { 32 | residuals=NULL; 33 | blkSize=size; 34 | coeffs = new int16_t[size*size]; 35 | } 36 | 37 | virtual const char* name() const { return "FDCT-Base"; } 38 | 39 | virtual int getBlkWidth() const { return blkSize; } 40 | virtual int getBlkHeight() const { return blkSize; } 41 | 42 | virtual void runOnBlock(int x,int y) = 0; 43 | 44 | void dump(int x,int y); 45 | 46 | virtual DSPFunc* referenceImplementation() const { return NULL; } 47 | 48 | bool compareToReferenceImplementation(); 49 | virtual bool prepareNextImage(std::shared_ptr img); 50 | 51 | private: 52 | std::shared_ptr prev_image; 53 | std::shared_ptr curr_image; 54 | 55 | protected: 56 | int blkSize; 57 | 58 | int16_t* residuals; 59 | int stride; 60 | int16_t* coeffs; 61 | }; 62 | 63 | 64 | 65 | 66 | 67 | class DSPFunc_IDCT_Base : public DSPFunc 68 | { 69 | public: 70 | DSPFunc_IDCT_Base(int size) { 71 | prev_image=NULL; curr_image=NULL; coeffs=NULL; blkSize=size; 72 | out = new uint8_t[size*size]; // allocate it to ensure alignment 73 | } 74 | 75 | virtual const char* name() const { return "IDCT-Base"; } 76 | 77 | virtual int getBlkWidth() const { return blkSize; } 78 | virtual int getBlkHeight() const { return blkSize; } 79 | 80 | virtual void runOnBlock(int x,int y) = 0; 81 | 82 | virtual DSPFunc* referenceImplementation() const { return NULL; } 83 | 84 | virtual bool compareToReferenceImplementation(); 85 | virtual bool prepareNextImage(std::shared_ptr img); 86 | 87 | inline int16_t* xy2coeff(int x,int y) const { 88 | // note: x+y*width does not make any sense, but gives us some random data 89 | 90 | //int xb = x/blkSize; 91 | //int yb = y/blkSize; 92 | int offset = (x+y*blksPerRow)*blkSize; //(xb+yb*blksPerRow)*blkSize*blkSize; 93 | //printf("%d %d -> %d %p\n", x,y, offset, coeffs+offset); 94 | return coeffs + offset; 95 | } 96 | 97 | private: 98 | std::shared_ptr prev_image; 99 | std::shared_ptr curr_image; 100 | 101 | protected: 102 | int blkSize; 103 | 104 | int16_t* coeffs; 105 | int width; 106 | int blksPerRow; 107 | uint8_t* out; // [32*32]; 108 | }; 109 | 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /libde265/encoder/sop.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #include "libde265/encoder/sop.h" 22 | #include "libde265/encoder/encoder-context.h" 23 | 24 | 25 | sop_creator_intra_only::sop_creator_intra_only() 26 | { 27 | } 28 | 29 | 30 | void sop_creator_intra_only::set_SPS_header_values() 31 | { 32 | mEncCtx->get_sps().log2_max_pic_order_cnt_lsb = get_num_poc_lsb_bits(); 33 | } 34 | 35 | 36 | void sop_creator_intra_only::insert_new_input_image(de265_image* img) 37 | { 38 | img->PicOrderCntVal = get_pic_order_count(); 39 | 40 | reset_poc(); 41 | int poc = get_pic_order_count(); 42 | 43 | assert(mEncPicBuf); 44 | image_data* imgdata = mEncPicBuf->insert_next_image_in_encoding_order(img, get_frame_number()); 45 | 46 | imgdata->set_intra(); 47 | imgdata->set_NAL_type(NAL_UNIT_IDR_N_LP); 48 | imgdata->shdr.slice_type = SLICE_TYPE_I; 49 | imgdata->shdr.slice_pic_order_cnt_lsb = get_pic_order_count_lsb(); 50 | 51 | mEncPicBuf->sop_metadata_commit(get_frame_number()); 52 | 53 | advance_frame(); 54 | } 55 | 56 | 57 | // --------------------------------------------------------------------------- 58 | 59 | 60 | sop_creator_trivial_low_delay::sop_creator_trivial_low_delay() 61 | { 62 | } 63 | 64 | 65 | void sop_creator_trivial_low_delay::set_SPS_header_values() 66 | { 67 | ref_pic_set rps; 68 | rps.DeltaPocS0[0] = -1; 69 | rps.UsedByCurrPicS0[0] = true; 70 | rps.NumNegativePics = 1; 71 | rps.NumPositivePics = 0; 72 | rps.compute_derived_values(); 73 | mEncCtx->get_sps().ref_pic_sets.push_back(rps); 74 | mEncCtx->get_sps().log2_max_pic_order_cnt_lsb = get_num_poc_lsb_bits(); 75 | } 76 | 77 | 78 | void sop_creator_trivial_low_delay::insert_new_input_image(de265_image* img) 79 | { 80 | img->PicOrderCntVal = get_pic_order_count(); 81 | 82 | int frame = get_frame_number(); 83 | 84 | std::vector l0, l1, empty; 85 | if (!isIntra(frame)) { 86 | l0.push_back(frame-1); 87 | } 88 | 89 | assert(mEncPicBuf); 90 | image_data* imgdata = mEncPicBuf->insert_next_image_in_encoding_order(img, get_frame_number()); 91 | 92 | if (isIntra(frame)) { 93 | reset_poc(); 94 | imgdata->set_intra(); 95 | imgdata->set_NAL_type(NAL_UNIT_IDR_N_LP); 96 | imgdata->shdr.slice_type = SLICE_TYPE_I; 97 | } else { 98 | imgdata->set_references(0, l0,l1, empty,empty); 99 | imgdata->set_NAL_type(NAL_UNIT_TRAIL_R); 100 | imgdata->shdr.slice_type = SLICE_TYPE_P; 101 | } 102 | imgdata->shdr.slice_pic_order_cnt_lsb = get_pic_order_count_lsb(); 103 | mEncPicBuf->sop_metadata_commit(get_frame_number()); 104 | 105 | advance_frame(); 106 | } 107 | -------------------------------------------------------------------------------- /m4/m4_ax_check_compile_flag.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS]) 8 | # 9 | # DESCRIPTION 10 | # 11 | # Check whether the given FLAG works with the current language's compiler 12 | # or gives an error. (Warnings, however, are ignored) 13 | # 14 | # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on 15 | # success/failure. 16 | # 17 | # If EXTRA-FLAGS is defined, it is added to the current language's default 18 | # flags (e.g. CFLAGS) when the check is done. The check is thus made with 19 | # the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to 20 | # force the compiler to issue an error when a bad flag is given. 21 | # 22 | # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this 23 | # macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. 24 | # 25 | # LICENSE 26 | # 27 | # Copyright (c) 2008 Guido U. Draheim 28 | # Copyright (c) 2011 Maarten Bosmans 29 | # 30 | # This program is free software: you can redistribute it and/or modify it 31 | # under the terms of the GNU General Public License as published by the 32 | # Free Software Foundation, either version 3 of the License, or (at your 33 | # option) any later version. 34 | # 35 | # This program is distributed in the hope that it will be useful, but 36 | # WITHOUT ANY WARRANTY; without even the implied warranty of 37 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 38 | # Public License for more details. 39 | # 40 | # You should have received a copy of the GNU General Public License along 41 | # with this program. If not, see . 42 | # 43 | # As a special exception, the respective Autoconf Macro's copyright owner 44 | # gives unlimited permission to copy, distribute and modify the configure 45 | # scripts that are the output of Autoconf when processing the Macro. You 46 | # need not follow the terms of the GNU General Public License when using 47 | # or distributing such scripts, even though portions of the text of the 48 | # Macro appear in them. The GNU General Public License (GPL) does govern 49 | # all other use of the material that constitutes the Autoconf Macro. 50 | # 51 | # This special exception to the GPL applies to versions of the Autoconf 52 | # Macro released by the Autoconf Archive. When you make and distribute a 53 | # modified version of the Autoconf Macro, you may extend this special 54 | # exception to the GPL to apply to your modified version as well. 55 | 56 | #serial 2 57 | 58 | AC_DEFUN([AX_CHECK_COMPILE_FLAG], 59 | [AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX 60 | AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl 61 | AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ 62 | ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS 63 | _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" 64 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], 65 | [AS_VAR_SET(CACHEVAR,[yes])], 66 | [AS_VAR_SET(CACHEVAR,[no])]) 67 | _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) 68 | AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes], 69 | [m4_default([$2], :)], 70 | [m4_default([$3], :)]) 71 | AS_VAR_POPDEF([CACHEVAR])dnl 72 | ])dnl AX_CHECK_COMPILE_FLAGS 73 | -------------------------------------------------------------------------------- /libde265/encoder/algo/algo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * Authors: Dirk Farin 6 | * 7 | * This file is part of libde265. 8 | * 9 | * libde265 is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of 12 | * the License, or (at your option) any later version. 13 | * 14 | * libde265 is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with libde265. If not, see . 21 | */ 22 | 23 | #ifndef ALGO_H 24 | #define ALGO_H 25 | 26 | #include "libde265/encoder/encoder-types.h" 27 | 28 | 29 | /* When entering the next recursion level, it is assumed that 30 | a valid CB structure is passed down. Ownership is transferred to 31 | the new algorithm. That algorithm passes back a (possibly different) 32 | CB structure that the first algorithm should use. The receiving 33 | algorithm will be the owner of the passed back algorithm. 34 | The original CB structure might have been deleted in the called algorithm. 35 | 36 | When using CodingOptions, it is important to set the passed back 37 | enc_node in the CodingOption (set_node()), so that the CodingOption 38 | can correctly handle ownership and delete nodes as needed. 39 | 40 | The context_model_table passed down is at the current state. 41 | When the algorithm returns, the state should represent the state 42 | after running this algorithm. 43 | */ 44 | 45 | class Algo 46 | { 47 | public: 48 | virtual ~Algo() { } 49 | 50 | virtual const char* name() const { return "noname"; } 51 | 52 | #ifdef DE265_LOG_DEBUG 53 | void enter(); 54 | void descend(const enc_node* node,const char* option_description, ...); 55 | void ascend(const enc_node* resultNode=NULL, const char* fmt=NULL, ...); 56 | void leaf(const enc_node* node,const char* option_description, ...); 57 | #else 58 | inline void enter() { } 59 | inline void descend(const enc_node*,const char*, ...) { } 60 | inline void ascend(const enc_node* resultNode=NULL,const char* fmt=NULL, ...) { } 61 | inline void leaf(const enc_node*,const char*, ...) { } 62 | #endif 63 | }; 64 | 65 | 66 | class Algo_CB : public Algo 67 | { 68 | public: 69 | virtual ~Algo_CB() { } 70 | 71 | /* The context_model_table that is provided can be modified and 72 | even released in the function. On exit, it should be filled with 73 | a (optionally new) context_model_table that represents the state 74 | after encoding the syntax element. However, to speed up computation, 75 | it is also allowed to not modify the context_model_table at all. 76 | */ 77 | virtual enc_cb* analyze(encoder_context*, 78 | context_model_table&, 79 | enc_cb* cb) = 0; 80 | }; 81 | 82 | 83 | class Algo_PB : public Algo 84 | { 85 | public: 86 | virtual ~Algo_PB() { } 87 | 88 | virtual enc_cb* analyze(encoder_context*, 89 | context_model_table&, 90 | enc_cb* cb, 91 | int PBidx, int x,int y,int w,int h) = 0; 92 | }; 93 | 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /scripts/ci-run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eu 3 | # 4 | # H.265 video codec. 5 | # Copyright (c) 2018 struktur AG, Joachim Bauch 6 | # 7 | # This file is part of libde265. 8 | # 9 | # libde265 is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # libde265 is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with libde265. If not, see . 21 | # 22 | BUILD_ROOT=$TRAVIS_BUILD_DIR 23 | 24 | if [ -z "$HOST" ] && [ -z "$DECODESTREAMS" ] && [ "$TRAVIS_OS_NAME" != "osx" ]; then 25 | ./scripts/check_licenses.sh 26 | fi 27 | 28 | if [ ! -z "$HOST" ] && [ "$HOST" != "cmake" ]; then 29 | # Make sure the correct compiler will be used. 30 | unset CC 31 | unset CXX 32 | fi 33 | 34 | make 35 | 36 | if [ -z "$HOST" ] && [ -z "$DECODESTREAMS" ]; then 37 | if [ "$TRAVIS_OS_NAME" != "osx" ]; then 38 | make dist 39 | 40 | mkdir dist-test 41 | (cd dist-test && tar xzf ../libde265-*.tar.gz && cd libde265-* && ./configure && make) 42 | 43 | mkdir dist-cmake-test 44 | (cd dist-cmake-test && tar xzf ../libde265-*.tar.gz && cd libde265-* && cmake . && make) 45 | 46 | VALGRIND="valgrind --tool=memcheck --quiet --error-exitcode=1 --gen-suppressions=all --suppressions=$BUILD_ROOT/valgrind.supp" 47 | DEC265="$BUILD_ROOT/dec265/.libs/dec265" 48 | else 49 | VALGRIND= 50 | DEC265="$BUILD_ROOT/dec265/dec265" 51 | fi 52 | export LD_LIBRARY_PATH=$BUILD_ROOT/libde265/.libs/ 53 | # inter-streams are valgrinded without SSE, because it gives too many false positives in put_hevc_qpel() 54 | # intra-streams use SSE, because they run fine in valgrind 55 | $VALGRIND $DEC265 -q -c -f 100 ./libde265-data/IDR-only/paris-352x288-intra.bin 56 | $VALGRIND $DEC265 -t 4 -q -c -f 100 ./libde265-data/IDR-only/paris-352x288-intra.bin 57 | $VALGRIND $DEC265 -0 -q -c -f 100 ./libde265-data/RandomAccess/paris-ra-wpp.bin 58 | $VALGRIND $DEC265 -0 -t 4 -q -c -f 100 ./libde265-data/RandomAccess/paris-ra-wpp.bin 59 | fi 60 | 61 | if [ ! -z "$WINE" ]; then 62 | export WINEPREFIX=$BUILD_ROOT/$WINE 63 | export WINEPATH="/usr/lib/gcc/$HOST/4.8/;/usr/$HOST/lib" 64 | $WINE ./dec265/dec265.exe -q -c ./libde265-data/IDR-only/paris-352x288-intra.bin 65 | $WINE ./dec265/dec265.exe -t 4 -q -c ./libde265-data/IDR-only/paris-352x288-intra.bin 66 | $WINE ./dec265/dec265.exe -q -c ./libde265-data/RandomAccess/paris-ra-wpp.bin 67 | $WINE ./dec265/dec265.exe -t 4 -q -c ./libde265-data/RandomAccess/paris-ra-wpp.bin 68 | fi 69 | 70 | if ( echo "$HOST" | grep -q "^arm" ); then 71 | export LD_LIBRARY_PATH=$BUILD_ROOT/libde265/.libs/ 72 | qemu-arm -L /usr/$HOST ./dec265/.libs/dec265 -q -c ./libde265-data/IDR-only/paris-352x288-intra.bin 73 | #qemu-arm -L /usr/$HOST ./dec265/.libs/dec265 -t 4 -q -c ./libde265-data/IDR-only/paris-352x288-intra.bin 74 | qemu-arm -L /usr/$HOST ./dec265/.libs/dec265 -q -c ./libde265-data/RandomAccess/paris-ra-wpp.bin 75 | #qemu-arm -L /usr/$HOST ./dec265/.libs/dec265 -t 4 -q -c ./libde265-data/RandomAccess/paris-ra-wpp.bin 76 | fi 77 | 78 | if [ ! -z "$DECODESTREAMS" ]; then 79 | python scripts/decodestreams.py $THREADING /var/lib/libde265-teststreams 80 | fi 81 | -------------------------------------------------------------------------------- /libde265/encoder/algo/cb-skip.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * Authors: struktur AG, Dirk Farin 6 | * 7 | * This file is part of libde265. 8 | * 9 | * libde265 is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of 12 | * the License, or (at your option) any later version. 13 | * 14 | * libde265 is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with libde265. If not, see . 21 | */ 22 | 23 | 24 | #include "libde265/encoder/algo/cb-skip.h" 25 | #include "libde265/encoder/algo/coding-options.h" 26 | #include "libde265/encoder/encoder-syntax.h" 27 | #include "libde265/encoder/encoder-context.h" 28 | #include 29 | #include 30 | #include 31 | 32 | 33 | 34 | 35 | enc_cb* Algo_CB_Skip_BruteForce::analyze(encoder_context* ectx, 36 | context_model_table& ctxModel, 37 | enc_cb* cb) 38 | { 39 | bool try_skip = (ectx->shdr->slice_type != SLICE_TYPE_I); 40 | bool try_nonskip = true; 41 | 42 | //try_nonskip = !try_skip; 43 | 44 | CodingOptions options(ectx,cb,ctxModel); 45 | CodingOption option_skip = options.new_option(try_skip); 46 | CodingOption option_nonskip = options.new_option(try_nonskip); 47 | options.start(); 48 | 49 | for (int i=0;i& opt = option_skip; 55 | opt.begin(); 56 | 57 | enc_cb* cb = opt.get_node(); 58 | 59 | // calc rate for skip flag (=true) 60 | 61 | CABAC_encoder_estim* cabac = opt.get_cabac(); 62 | encode_cu_skip_flag(ectx, cabac, cb, true); 63 | float rate_pred_mode = cabac->getRDBits(); 64 | cabac->reset(); 65 | 66 | // set skip flag 67 | 68 | cb->PredMode = MODE_SKIP; 69 | ectx->img->set_pred_mode(cb->x,cb->y, cb->log2Size, cb->PredMode); 70 | 71 | // encode CB 72 | 73 | descend(cb,"yes"); 74 | cb = mSkipAlgo->analyze(ectx, opt.get_context(), cb); 75 | ascend(); 76 | 77 | // add rate for PredMode 78 | 79 | cb->rate += rate_pred_mode; 80 | opt.set_node(cb); 81 | opt.end(); 82 | } 83 | 84 | if (option_nonskip) { 85 | CodingOption& opt = option_nonskip; 86 | enc_cb* cb = opt.get_node(); 87 | 88 | opt.begin(); 89 | 90 | // calc rate for skip flag (=true) 91 | 92 | float rate_pred_mode = 0; 93 | 94 | if (try_skip) { 95 | CABAC_encoder_estim* cabac = opt.get_cabac(); 96 | encode_cu_skip_flag(ectx, cabac, cb, false); 97 | rate_pred_mode = cabac->getRDBits(); 98 | cabac->reset(); 99 | } 100 | 101 | descend(cb,"no"); 102 | cb = mNonSkipAlgo->analyze(ectx, opt.get_context(), cb); 103 | ascend(); 104 | 105 | // add rate for PredMode 106 | 107 | cb->rate += rate_pred_mode; 108 | opt.set_node(cb); 109 | opt.end(); 110 | } 111 | 112 | options.compute_rdo_costs(); 113 | return options.return_best_rdo_node(); 114 | } 115 | -------------------------------------------------------------------------------- /sherlock265/VideoDecoder.hh: -------------------------------------------------------------------------------- 1 | /* 2 | libde265 example application "sherlock265". 3 | 4 | MIT License 5 | 6 | Copyright (c) 2013-2014 struktur AG, Dirk Farin 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | */ 26 | 27 | #ifndef VIDEODECODER_HH 28 | #define VIDEODECODER_HH 29 | 30 | #ifdef HAVE_CONFIG_H 31 | #include 32 | #endif 33 | 34 | #include 35 | #ifdef HAVE_SWSCALE 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | #include 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | #endif 44 | 45 | #include "VideoWidget.hh" 46 | #include "de265.h" 47 | 48 | 49 | class VideoDecoder : public QThread 50 | { 51 | Q_OBJECT 52 | 53 | public: 54 | VideoDecoder(); 55 | ~VideoDecoder(); 56 | 57 | void init(const char* filename); 58 | 59 | protected: 60 | void run(); // thread entry point 61 | 62 | public slots: 63 | void startDecoder(); 64 | void stopDecoder(); 65 | void singleStepDecoder(); 66 | 67 | void showCBPartitioning(bool flag); 68 | void showTBPartitioning(bool flag); 69 | void showPBPartitioning(bool flag); 70 | void showIntraPredMode(bool flag); 71 | void showPBPredMode(bool flag); 72 | void showQuantPY(bool flag); 73 | void showMotionVec(bool flag); 74 | void showTiles(bool flag); 75 | void showSlices(bool flag); 76 | void showDecodedImage(bool flag); 77 | 78 | signals: 79 | void displayImage(QImage*); 80 | 81 | private: 82 | // de265 decoder 83 | 84 | FILE* mFH; 85 | //input_context_FILE inputctx; 86 | //rbsp_buffer buf; 87 | de265_decoder_context* ctx; 88 | const de265_image* img; 89 | 90 | QMutex mutex; 91 | 92 | QImage mImgBuffers[2]; 93 | int mNextBuffer; 94 | int mFrameCount; 95 | 96 | bool mPlayingVideo; 97 | bool mVideoEnded; 98 | bool mSingleStep; 99 | 100 | 101 | bool mShowDecodedImage; 102 | bool mShowQuantPY; 103 | bool mCBShowPartitioning; 104 | bool mTBShowPartitioning; 105 | bool mPBShowPartitioning; 106 | bool mShowIntraPredMode; 107 | bool mShowPBPredMode; 108 | bool mShowMotionVec; 109 | bool mShowTiles; 110 | bool mShowSlices; 111 | 112 | void decoder_loop(); 113 | 114 | void init_decoder(const char* filename); 115 | void free_decoder(); 116 | 117 | void show_frame(const de265_image* img); 118 | #ifdef HAVE_VIDEOGFX 119 | void convert_frame_libvideogfx(const de265_image* img, QImage & qimg); 120 | #endif 121 | #ifdef HAVE_SWSCALE 122 | SwsContext* sws; 123 | int width; 124 | int height; 125 | void convert_frame_swscale(const de265_image* img, QImage & qimg); 126 | #endif 127 | }; 128 | 129 | #endif 130 | -------------------------------------------------------------------------------- /libde265/encoder/algo/tb-rateestim.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * Authors: Dirk Farin 6 | * 7 | * This file is part of libde265. 8 | * 9 | * libde265 is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of 12 | * the License, or (at your option) any later version. 13 | * 14 | * libde265 is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with libde265. If not, see . 21 | */ 22 | 23 | #ifndef TB_RATEESTIM_H 24 | #define TB_RATEESTIM_H 25 | 26 | #include "libde265/nal-parser.h" 27 | #include "libde265/decctx.h" 28 | #include "libde265/encoder/encoder-types.h" 29 | #include "libde265/encoder/algo/algo.h" 30 | #include "libde265/slice.h" 31 | #include "libde265/scan.h" 32 | #include "libde265/intrapred.h" 33 | #include "libde265/transform.h" 34 | #include "libde265/fallback-dct.h" 35 | #include "libde265/quality.h" 36 | #include "libde265/fallback.h" 37 | #include "libde265/configparam.h" 38 | 39 | 40 | enum ALGO_TB_RateEstimation { 41 | ALGO_TB_RateEstimation_None, 42 | ALGO_TB_RateEstimation_Exact 43 | }; 44 | 45 | class option_ALGO_TB_RateEstimation : public choice_option 46 | { 47 | public: 48 | option_ALGO_TB_RateEstimation() { 49 | add_choice("none" ,ALGO_TB_RateEstimation_None); 50 | add_choice("exact",ALGO_TB_RateEstimation_Exact, true); 51 | } 52 | }; 53 | 54 | 55 | 56 | class Algo_TB_RateEstimation : public Algo 57 | { 58 | public: 59 | virtual ~Algo_TB_RateEstimation() { } 60 | 61 | virtual float encode_transform_unit(encoder_context* ectx, 62 | context_model_table& ctxModel, 63 | const enc_tb* tb, const enc_cb* cb, 64 | int x0,int y0, int xBase,int yBase, 65 | int log2TrafoSize, int trafoDepth, int blkIdx) = 0; 66 | 67 | virtual const char* name() const { return "tb-rateestimation"; } 68 | }; 69 | 70 | 71 | class Algo_TB_RateEstimation_None : public Algo_TB_RateEstimation 72 | { 73 | public: 74 | virtual float encode_transform_unit(encoder_context* ectx, 75 | context_model_table& ctxModel, 76 | const enc_tb* tb, const enc_cb* cb, 77 | int x0,int y0, int xBase,int yBase, 78 | int log2TrafoSize, int trafoDepth, int blkIdx) 79 | { 80 | leaf(cb, NULL); 81 | return 0.0f; 82 | } 83 | 84 | virtual const char* name() const { return "tb-rateestimation-none"; } 85 | }; 86 | 87 | 88 | class Algo_TB_RateEstimation_Exact : public Algo_TB_RateEstimation 89 | { 90 | public: 91 | virtual float encode_transform_unit(encoder_context* ectx, 92 | context_model_table& ctxModel, 93 | const enc_tb* tb, const enc_cb* cb, 94 | int x0,int y0, int xBase,int yBase, 95 | int log2TrafoSize, int trafoDepth, int blkIdx); 96 | 97 | virtual const char* name() const { return "tb-rateestimation-exact"; } 98 | }; 99 | 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /libde265/encoder/encoder-params.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * Authors: Dirk Farin 6 | * 7 | * This file is part of libde265. 8 | * 9 | * libde265 is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of 12 | * the License, or (at your option) any later version. 13 | * 14 | * libde265 is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with libde265. If not, see . 21 | */ 22 | 23 | #ifndef ENCODER_PARAMS_H 24 | #define ENCODER_PARAMS_H 25 | 26 | #include "libde265/encoder/encoder-types.h" 27 | #include "libde265/encoder/encoder-core.h" 28 | #include "libde265/encoder/sop.h" 29 | 30 | 31 | enum RateControlMethod 32 | { 33 | RateControlMethod_ConstantQP, 34 | RateControlMethod_ConstantLambda 35 | }; 36 | 37 | enum IntraPredSearch 38 | { 39 | IntraPredSearch_Complete 40 | }; 41 | 42 | 43 | enum SOP_Structure 44 | { 45 | SOP_Intra, 46 | SOP_LowDelay 47 | }; 48 | 49 | class option_SOP_Structure : public choice_option 50 | { 51 | public: 52 | option_SOP_Structure() { 53 | add_choice("intra", SOP_Intra); 54 | add_choice("low-delay", SOP_LowDelay, true); 55 | } 56 | }; 57 | 58 | 59 | enum MEMode 60 | { 61 | MEMode_Test, 62 | MEMode_Search 63 | }; 64 | 65 | class option_MEMode : public choice_option 66 | { 67 | public: 68 | option_MEMode() { 69 | add_choice("test", MEMode_Test, true); 70 | add_choice("search", MEMode_Search); 71 | } 72 | }; 73 | 74 | 75 | struct encoder_params 76 | { 77 | encoder_params(); 78 | 79 | void registerParams(config_parameters& config); 80 | 81 | 82 | // CB quad-tree 83 | 84 | option_int min_cb_size; 85 | option_int max_cb_size; 86 | 87 | option_int min_tb_size; 88 | option_int max_tb_size; 89 | 90 | option_int max_transform_hierarchy_depth_intra; 91 | option_int max_transform_hierarchy_depth_inter; 92 | 93 | 94 | option_SOP_Structure sop_structure; 95 | 96 | sop_creator_trivial_low_delay::params mSOP_LowDelay; 97 | 98 | 99 | // --- Algo_TB_IntraPredMode 100 | 101 | option_ALGO_TB_IntraPredMode mAlgo_TB_IntraPredMode; 102 | option_ALGO_TB_IntraPredMode_Subset mAlgo_TB_IntraPredMode_Subset; 103 | 104 | //Algo_TB_IntraPredMode_FastBrute::params TB_IntraPredMode_FastBrute; 105 | //Algo_TB_IntraPredMode_MinResidual::params TB_IntraPredMode_MinResidual; 106 | 107 | 108 | // --- Algo_TB_Split_BruteForce 109 | 110 | //Algo_TB_Split_BruteForce::params TB_Split_BruteForce; 111 | 112 | 113 | // --- Algo_CB_IntraPartMode 114 | 115 | option_ALGO_CB_IntraPartMode mAlgo_CB_IntraPartMode; 116 | 117 | //Algo_CB_IntraPartMode_Fixed::params CB_IntraPartMode_Fixed; 118 | 119 | // --- Algo_CB_Split 120 | 121 | // --- Algo_CTB_QScale 122 | 123 | //Algo_CTB_QScale_Constant::params CTB_QScale_Constant; 124 | 125 | option_MEMode mAlgo_MEMode; 126 | 127 | 128 | // intra-prediction 129 | 130 | enum IntraPredSearch intraPredSearch; 131 | 132 | 133 | // rate-control 134 | 135 | enum RateControlMethod rateControlMethod; 136 | option_ALGO_TB_RateEstimation mAlgo_TB_RateEstimation; 137 | 138 | //int constant_QP; 139 | //int lambda; 140 | }; 141 | 142 | 143 | #endif 144 | -------------------------------------------------------------------------------- /dec265/hdrcopy.cc: -------------------------------------------------------------------------------- 1 | /* 2 | libde265 example application. 3 | 4 | MIT License 5 | 6 | Copyright (c) 2013-2014 struktur AG, Dirk Farin 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | */ 26 | 27 | 28 | #include "libde265/nal-parser.h" 29 | #include "libde265/decctx.h" 30 | #include 31 | 32 | error_queue errqueue; 33 | 34 | video_parameter_set vps; 35 | seq_parameter_set sps; 36 | pic_parameter_set pps; 37 | 38 | CABAC_encoder_bitstream writer; 39 | 40 | 41 | void process_nal(NAL_unit* nal) 42 | { 43 | de265_error err = DE265_OK; 44 | 45 | bitreader reader; 46 | bitreader_init(&reader, nal->data(), nal->size()); 47 | 48 | nal_header nal_hdr; 49 | nal_hdr.read(&reader); 50 | writer.write_startcode(); 51 | nal_hdr.write(writer); 52 | 53 | printf("NAL: 0x%x 0x%x - unit type:%s temporal id:%d\n", 54 | nal->data()[0], nal->data()[1], 55 | get_NAL_name(nal_hdr.nal_unit_type), 56 | nal_hdr.nuh_temporal_id); 57 | 58 | 59 | if (nal_hdr.nal_unit_type<32) { 60 | //err = read_slice_NAL(reader, nal, nal_hdr); 61 | } 62 | else switch (nal_hdr.nal_unit_type) { 63 | case NAL_UNIT_VPS_NUT: 64 | vps.read(&errqueue, &reader); 65 | vps.dump(1); 66 | vps.write(&errqueue, writer); 67 | writer.flush_VLC(); 68 | break; 69 | 70 | case NAL_UNIT_SPS_NUT: 71 | sps.read(&errqueue, &reader); 72 | sps.dump(1); 73 | sps.write(&errqueue, writer); 74 | writer.flush_VLC(); 75 | break; 76 | 77 | case NAL_UNIT_PPS_NUT: 78 | //err = read_pps_NAL(reader); 79 | break; 80 | 81 | case NAL_UNIT_PREFIX_SEI_NUT: 82 | case NAL_UNIT_SUFFIX_SEI_NUT: 83 | //err = read_sei_NAL(reader, nal_hdr.nal_unit_type==NAL_UNIT_SUFFIX_SEI_NUT); 84 | break; 85 | 86 | case NAL_UNIT_EOS_NUT: 87 | //ctx->FirstAfterEndOfSequenceNAL = true; 88 | break; 89 | } 90 | } 91 | 92 | 93 | int main(int argc, char** argv) 94 | { 95 | NAL_Parser nal_parser; 96 | 97 | FILE* fh = fopen(argv[1],"rb"); 98 | unsigned char buf[1024]; 99 | 100 | writer.write_bits(0,8); // because HM has an extra byte at the beginning 101 | 102 | while(!feof(fh)) 103 | { 104 | int n = fread(buf,1,1024,fh); 105 | if (n>0) { 106 | nal_parser.push_data(buf,n, 0); 107 | } 108 | 109 | if (nal_parser.get_NAL_queue_length()>0) { 110 | NAL_unit* nal = nal_parser.pop_from_NAL_queue(); 111 | assert(nal); 112 | process_nal(nal); 113 | nal_parser.free_NAL_unit(nal); 114 | } 115 | } 116 | 117 | fclose(fh); 118 | 119 | fh = fopen("out.bin","wb"); 120 | fwrite(writer.data(), 1,writer.size(), fh); 121 | fclose(fh); 122 | 123 | return 0; 124 | } 125 | -------------------------------------------------------------------------------- /libde265/encoder/encoder-syntax.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * Authors: Dirk Farin 6 | * 7 | * This file is part of libde265. 8 | * 9 | * libde265 is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of 12 | * the License, or (at your option) any later version. 13 | * 14 | * libde265 is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with libde265. If not, see . 21 | */ 22 | 23 | #ifndef ENCODER_SYNTAX_H 24 | #define ENCODER_SYNTAX_H 25 | 26 | #include "libde265/image.h" 27 | #include "libde265/encoder/encoder-types.h" 28 | 29 | 30 | void encode_split_cu_flag(encoder_context* ectx, 31 | CABAC_encoder* cabac, 32 | int x0, int y0, int ctDepth, int split_flag); 33 | 34 | void encode_transform_tree(encoder_context* ectx, 35 | CABAC_encoder* cabac, 36 | const enc_tb* tb, const enc_cb* cb, 37 | int x0,int y0, int xBase,int yBase, 38 | int log2TrafoSize, int trafoDepth, int blkIdx, 39 | int MaxTrafoDepth, int IntraSplitFlag, bool recurse); 40 | 41 | void encode_coding_unit(encoder_context* ectx, 42 | CABAC_encoder* cabac, 43 | const enc_cb* cb, int x0,int y0, int log2CbSize, bool recurse); 44 | 45 | /* returns 46 | 1 - forced split 47 | 0 - forced non-split 48 | -1 - optional split 49 | */ 50 | enum SplitType { 51 | ForcedNonSplit = 0, 52 | ForcedSplit = 1, 53 | OptionalSplit = 2 54 | }; 55 | 56 | SplitType get_split_type(const seq_parameter_set* sps, 57 | int x0,int y0, int log2CbSize); 58 | 59 | 60 | /* Compute how much rate is required for sending the chroma CBF flags 61 | in the whole TB tree. 62 | */ 63 | float recursive_cbfChroma_rate(CABAC_encoder_estim* cabac, 64 | enc_tb* tb, int log2TrafoSize, int trafoDepth); 65 | 66 | 67 | void encode_split_transform_flag(encoder_context* ectx, 68 | CABAC_encoder* cabac, 69 | int log2TrafoSize, int split_flag); 70 | 71 | void encode_merge_idx(encoder_context* ectx, 72 | CABAC_encoder* cabac, 73 | int mergeIdx); 74 | 75 | void encode_cu_skip_flag(encoder_context* ectx, 76 | CABAC_encoder* cabac, 77 | const enc_cb* cb, 78 | bool skip); 79 | 80 | void encode_cbf_luma(CABAC_encoder* cabac, 81 | bool zeroTrafoDepth, int cbf_luma); 82 | 83 | void encode_cbf_chroma(CABAC_encoder* cabac, 84 | int trafoDepth, int cbf_chroma); 85 | 86 | void encode_transform_unit(encoder_context* ectx, 87 | CABAC_encoder* cabac, 88 | const enc_tb* tb, const enc_cb* cb, 89 | int x0,int y0, int xBase,int yBase, 90 | int log2TrafoSize, int trafoDepth, int blkIdx); 91 | 92 | 93 | void encode_quadtree(encoder_context* ectx, 94 | CABAC_encoder* cabac, 95 | const enc_cb* cb, int x0,int y0, int log2CbSize, int ctDepth, 96 | bool recurse); 97 | 98 | void encode_ctb(encoder_context* ectx, 99 | CABAC_encoder* cabac, 100 | enc_cb* cb, int ctbX,int ctbY); 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /acceleration-speed/dct.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2015 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #include "dct.h" 22 | 23 | 24 | // --- FDCT --- 25 | 26 | void DSPFunc_FDCT_Base::dump(int x,int y) 27 | { 28 | printf("-> "); 29 | for (int yy=0;yy(referenceImplementation()); 52 | 53 | for (int i=0;icoeffs[i]) 55 | return false; 56 | 57 | return true; 58 | } 59 | 60 | 61 | bool DSPFunc_FDCT_Base::prepareNextImage(std::shared_ptr img) 62 | { 63 | if (!curr_image) { 64 | curr_image = img; 65 | return false; 66 | } 67 | 68 | prev_image = curr_image; 69 | curr_image = img; 70 | 71 | int w = curr_image->get_width(0); 72 | int h = curr_image->get_height(0); 73 | 74 | if (residuals==NULL) { 75 | int align=16; 76 | stride = (w+align-1)/align*align; 77 | residuals = new int16_t[stride*h]; 78 | } 79 | 80 | int cstride = curr_image->get_luma_stride(); 81 | int pstride = prev_image->get_luma_stride(); 82 | const uint8_t* curr = curr_image->get_image_plane_at_pos(0,0,0); 83 | const uint8_t* prev = prev_image->get_image_plane_at_pos(0,0,0); 84 | 85 | for (int y=0;y(referenceImplementation()); 99 | 100 | for (int i=0;iout[i]) 102 | return false; 103 | 104 | return true; 105 | } 106 | 107 | 108 | bool DSPFunc_IDCT_Base::prepareNextImage(std::shared_ptr img) 109 | { 110 | // --- generate fake coefficients --- 111 | // difference between two frames 112 | 113 | if (!curr_image) { 114 | curr_image = img; 115 | return false; 116 | } 117 | 118 | prev_image = curr_image; 119 | curr_image = img; 120 | 121 | int w = curr_image->get_width(0); 122 | int h = curr_image->get_height(0); 123 | 124 | int align = blkSize; 125 | width = (w+align-1) / align * align; 126 | 127 | blksPerRow = w/blkSize; 128 | 129 | if (coeffs==NULL) { 130 | coeffs = new int16_t[width*h]; 131 | } 132 | 133 | int cstride = curr_image->get_luma_stride(); 134 | int pstride = prev_image->get_luma_stride(); 135 | const uint8_t* curr = curr_image->get_image_plane_at_pos(0,0,0); 136 | const uint8_t* prev = prev_image->get_image_plane_at_pos(0,0,0); 137 | 138 | for (int y=0;y 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libde265 is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libde265. If not, see . 19 | */ 20 | 21 | #include "bitstream.h" 22 | #include "de265.h" 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | 30 | void bitreader_init(bitreader* br, unsigned char* buffer, int len) 31 | { 32 | br->data = buffer; 33 | br->bytes_remaining = len; 34 | 35 | br->nextbits=0; 36 | br->nextbits_cnt=0; 37 | 38 | bitreader_refill(br); 39 | } 40 | 41 | void bitreader_refill(bitreader* br) 42 | { 43 | int shift = 64-br->nextbits_cnt; 44 | 45 | while (shift >= 8 && br->bytes_remaining) { 46 | uint64_t newval = *br->data++; 47 | br->bytes_remaining--; 48 | 49 | shift -= 8; 50 | newval <<= shift; 51 | br->nextbits |= newval; 52 | } 53 | 54 | br->nextbits_cnt = 64-shift; 55 | } 56 | 57 | int get_bits(bitreader* br, int n) 58 | { 59 | if (br->nextbits_cnt < n) { 60 | bitreader_refill(br); 61 | } 62 | 63 | uint64_t val = br->nextbits; 64 | val >>= 64-n; 65 | 66 | br->nextbits <<= n; 67 | br->nextbits_cnt -= n; 68 | 69 | return val; 70 | } 71 | 72 | int get_bits_fast(bitreader* br, int n) 73 | { 74 | assert(br->nextbits_cnt >= n); 75 | 76 | uint64_t val = br->nextbits; 77 | val >>= 64-n; 78 | 79 | br->nextbits <<= n; 80 | br->nextbits_cnt -= n; 81 | 82 | return val; 83 | } 84 | 85 | int peek_bits(bitreader* br, int n) 86 | { 87 | if (br->nextbits_cnt < n) { 88 | bitreader_refill(br); 89 | } 90 | 91 | uint64_t val = br->nextbits; 92 | val >>= 64-n; 93 | 94 | return val; 95 | } 96 | 97 | void skip_bits(bitreader* br, int n) 98 | { 99 | if (br->nextbits_cnt < n) { 100 | bitreader_refill(br); 101 | } 102 | 103 | br->nextbits <<= n; 104 | br->nextbits_cnt -= n; 105 | } 106 | 107 | void skip_bits_fast(bitreader* br, int n) 108 | { 109 | br->nextbits <<= n; 110 | br->nextbits_cnt -= n; 111 | } 112 | 113 | void skip_to_byte_boundary(bitreader* br) 114 | { 115 | int nskip = (br->nextbits_cnt & 7); 116 | 117 | br->nextbits <<= nskip; 118 | br->nextbits_cnt -= nskip; 119 | } 120 | 121 | void prepare_for_CABAC(bitreader* br) 122 | { 123 | skip_to_byte_boundary(br); 124 | 125 | int rewind = br->nextbits_cnt/8; 126 | br->data -= rewind; 127 | br->bytes_remaining += rewind; 128 | br->nextbits = 0; 129 | br->nextbits_cnt = 0; 130 | } 131 | 132 | int get_uvlc(bitreader* br) 133 | { 134 | int num_zeros=0; 135 | 136 | while (get_bits(br,1)==0) { 137 | num_zeros++; 138 | 139 | if (num_zeros > MAX_UVLC_LEADING_ZEROS) { return UVLC_ERROR; } 140 | } 141 | 142 | int offset = 0; 143 | if (num_zeros != 0) { 144 | offset = get_bits(br, num_zeros); 145 | int value = offset + (1<0); 147 | return value; 148 | } else { 149 | return 0; 150 | } 151 | } 152 | 153 | int get_svlc(bitreader* br) 154 | { 155 | int v = get_uvlc(br); 156 | if (v==0) return v; 157 | if (v==UVLC_ERROR) return UVLC_ERROR; 158 | 159 | bool negative = ((v&1)==0); 160 | return negative ? -v/2 : (v+1)/2; 161 | } 162 | 163 | bool check_rbsp_trailing_bits(bitreader* br) 164 | { 165 | int stop_bit = get_bits(br,1); 166 | assert(stop_bit==1); 167 | 168 | while (br->nextbits_cnt>0 || br->bytes_remaining>0) { 169 | int filler = get_bits(br,1); 170 | if (filler!=0) { 171 | return false; 172 | } 173 | } 174 | 175 | return true; 176 | } 177 | --------------------------------------------------------------------------------