Codebase list libde265 / 9df9576
Imported Upstream version 1.0.2 Joachim Bauch 8 years ago
163 changed file(s) with 31933 addition(s) and 3559 deletion(s). Raw diff Collapse all Expand all
44 - gcc
55 env:
66 - HOST= WINE= DECODESTREAMS=
7 - HOST= WINE= DECODESTREAMS=libde265-teststreams-nolf
8 - HOST= WINE= DECODESTREAMS=libde265-teststreams-sao
9 - HOST= WINE= DECODESTREAMS=libde265-teststreams-tiles
10 - HOST= WINE= DECODESTREAMS=libde265-teststreams-tiles-nolf
11 - HOST= WINE= DECODESTREAMS=libde265-teststreams-weighted
12 - HOST= WINE= DECODESTREAMS=libde265-teststreams-wpp-nolf
7 - HOST= WINE= DECODESTREAMS=libde265-teststreams-fuzzing THREADING=
8 - HOST= WINE= DECODESTREAMS=libde265-teststreams-fuzzing THREADING=--single-threaded
9 - HOST= WINE= DECODESTREAMS=libde265-teststreams-nolf THREADING=
10 - HOST= WINE= DECODESTREAMS=libde265-teststreams-nolf THREADING=--single-threaded
11 - HOST= WINE= DECODESTREAMS=libde265-teststreams-sao THREADING=
12 - HOST= WINE= DECODESTREAMS=libde265-teststreams-sao THREADING=--single-threaded
13 - HOST= WINE= DECODESTREAMS=libde265-teststreams-tiles THREADING=
14 - HOST= WINE= DECODESTREAMS=libde265-teststreams-tiles THREADING=--single-threaded
15 - HOST= WINE= DECODESTREAMS=libde265-teststreams-tiles-nolf THREADING=
16 - HOST= WINE= DECODESTREAMS=libde265-teststreams-tiles-nolf THREADING=--single-threaded
17 - HOST= WINE= DECODESTREAMS=libde265-teststreams-weighted THREADING=
18 - HOST= WINE= DECODESTREAMS=libde265-teststreams-weighted THREADING=--single-threaded
19 - HOST= WINE= DECODESTREAMS=libde265-teststreams-wpp-nolf THREADING=
20 - HOST= WINE= DECODESTREAMS=libde265-teststreams-wpp-nolf THREADING=--single-threaded
1321 - HOST=i686-w64-mingw32 WINE=wine DECODESTREAMS=
1422 - HOST=x86_64-w64-mingw32 WINE=wine64 DECODESTREAMS=
23 - HOST=arm-linux-gnueabihf WINE= DECODESTREAMS=
24 - HOST=cmake WINE= DECODESTREAMS=
1525
1626 matrix:
1727 include:
2232 - sh -c "if [ ! -z '$DECODESTREAMS' ]; then sudo add-apt-repository -y ppa:strukturag/libde265; fi"
2333 - sudo apt-get update -qq
2434 - sh -c "if [ -z '$HOST' ]; then sudo apt-get install -qq valgrind libsdl-dev libqt4-dev libswscale-dev; fi"
25 - sh -c "if [ ! -z '$HOST' ]; then sudo apt-get install -qq wine; fi"
35 - sh -c "if [ -z '$HOST' ] && [ -z '$DECODESTREAMS' ]; then sudo apt-get install -qq devscripts; fi"
36 - sh -c "if [ ! -z '$WINE' ]; then sudo apt-get install -qq wine; fi"
2637 - sh -c "if [ '$WINE' = 'wine' ]; then sudo apt-get install -qq gcc-mingw-w64-i686 g++-mingw-w64-i686 binutils-mingw-w64-i686 mingw-w64-dev; fi"
2738 - sh -c "if [ '$WINE' = 'wine64' ]; then sudo apt-get install -qq gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 binutils-mingw-w64-x86-64 mingw-w64-dev; fi"
39 - sh -c "if ( echo '$HOST' | grep -q '^arm' ); then sudo apt-get install -qq g++-arm-linux-gnueabihf gcc-arm-linux-gnueabihf qemu-user; fi"
2840 - sh -c "if [ ! -z '$DECODESTREAMS' ]; then sudo apt-get install $DECODESTREAMS; fi"
2941
3042 install:
3143 - git clone https://github.com/strukturag/libde265-data.git
3244
3345 before_script:
34 - ./autogen.sh
35 - if [ ! -z "$HOST" ]; then unset CC; fi
36 - if [ ! -z "$HOST" ]; then unset CXX; fi
37 - ./configure --host=$HOST
46 - if [ "$HOST" != "cmake" ]; then ./autogen.sh; fi
47 - if [ ! -z "$HOST" ] && [ "$HOST" != "cmake" ]; then unset CC; fi
48 - if [ ! -z "$HOST" ] && [ "$HOST" != "cmake" ]; then unset CXX; fi
49 - if [ "$HOST" != "cmake" ]; then ./configure --host=$HOST; fi
50 - if [ "$HOST" = "cmake" ]; then cmake .; fi
3851
3952 script:
53 - sh -c "if [ -z "$HOST" ] && [ -z "$DECODESTREAMS" ]; then ./scripts/check_licenses.sh; fi"
4054 - make
55 - sh -c "if [ -z "$HOST" ] && [ -z "$DECODESTREAMS" ]; then make dist && mkdir dist-test && cd dist-test && tar xzf ../libde265-*.tar.gz && cd libde265-* && ./configure && make; fi"
56 - sh -c "if [ -z "$HOST" ] && [ -z "$DECODESTREAMS" ]; then make dist && mkdir dist-cmake-test && cd dist-cmake-test && tar xzf ../libde265-*.tar.gz && cd libde265-* && cmake . && make; fi"
4157 - sh -c "if [ -z "$HOST" ] && [ -z "$DECODESTREAMS" ]; then LD_LIBRARY_PATH=./libde265/.libs/ valgrind --tool=memcheck --quiet --error-exitcode=1 ./dec265/.libs/dec265 -q -c -f 100 ./libde265-data/IDR-only/paris-352x288-intra.bin; fi"
4258 - sh -c "if [ -z "$HOST" ] && [ -z "$DECODESTREAMS" ]; then LD_LIBRARY_PATH=./libde265/.libs/ valgrind --tool=memcheck --quiet --error-exitcode=1 ./dec265/.libs/dec265 -t 4 -q -c -f 100 ./libde265-data/IDR-only/paris-352x288-intra.bin; fi"
4359 - sh -c "if [ -z "$HOST" ] && [ -z "$DECODESTREAMS" ]; then LD_LIBRARY_PATH=./libde265/.libs/ valgrind --tool=memcheck --quiet --error-exitcode=1 ./dec265/.libs/dec265 -q -c -f 100 ./libde265-data/RandomAccess/paris-ra-wpp.bin; fi"
4460 - sh -c "if [ -z "$HOST" ] && [ -z "$DECODESTREAMS" ]; then LD_LIBRARY_PATH=./libde265/.libs/ valgrind --tool=memcheck --quiet --error-exitcode=1 ./dec265/.libs/dec265 -t 4 -q -c -f 100 ./libde265-data/RandomAccess/paris-ra-wpp.bin; fi"
45 - sh -c "if [ ! -z "$HOST" ]; then WINEPREFIX=`pwd`/$WINE WINEPATH=/usr/lib/gcc/$HOST/4.6/ $WINE ./dec265/dec265.exe -q -c ./libde265-data/IDR-only/paris-352x288-intra.bin; fi"
46 - sh -c "if [ ! -z "$HOST" ]; then WINEPREFIX=`pwd`/$WINE WINEPATH=/usr/lib/gcc/$HOST/4.6/ $WINE ./dec265/dec265.exe -t 4 -q -c ./libde265-data/IDR-only/paris-352x288-intra.bin; fi"
47 - sh -c "if [ ! -z "$HOST" ]; then WINEPREFIX=`pwd`/$WINE WINEPATH=/usr/lib/gcc/$HOST/4.6/ $WINE ./dec265/dec265.exe -q -c ./libde265-data/RandomAccess/paris-ra-wpp.bin; fi"
48 - sh -c "if [ ! -z "$HOST" ]; then WINEPREFIX=`pwd`/$WINE WINEPATH=/usr/lib/gcc/$HOST/4.6/ $WINE ./dec265/dec265.exe -t 4 -q -c ./libde265-data/RandomAccess/paris-ra-wpp.bin; fi"
49 - sh -c "if [ ! -z '$DECODESTREAMS' ]; then python scripts/decodestreams.py /var/lib/libde265-teststreams; fi"
61 - sh -c "if [ ! -z "$WINE" ]; then WINEPREFIX=`pwd`/$WINE WINEPATH=/usr/lib/gcc/$HOST/4.6/ $WINE ./dec265/dec265.exe -q -c ./libde265-data/IDR-only/paris-352x288-intra.bin; fi"
62 - sh -c "if [ ! -z "$WINE" ]; then WINEPREFIX=`pwd`/$WINE WINEPATH=/usr/lib/gcc/$HOST/4.6/ $WINE ./dec265/dec265.exe -t 4 -q -c ./libde265-data/IDR-only/paris-352x288-intra.bin; fi"
63 - sh -c "if [ ! -z "$WINE" ]; then WINEPREFIX=`pwd`/$WINE WINEPATH=/usr/lib/gcc/$HOST/4.6/ $WINE ./dec265/dec265.exe -q -c ./libde265-data/RandomAccess/paris-ra-wpp.bin; fi"
64 - sh -c "if [ ! -z "$WINE" ]; then WINEPREFIX=`pwd`/$WINE WINEPATH=/usr/lib/gcc/$HOST/4.6/ $WINE ./dec265/dec265.exe -t 4 -q -c ./libde265-data/RandomAccess/paris-ra-wpp.bin; fi"
65 - sh -c "if ( echo '$HOST' | grep -q '^arm' ); then LD_LIBRARY_PATH=`pwd`/libde265/.libs/ qemu-arm -L /usr/$HOST ./dec265/.libs/dec265 -q -c ./libde265-data/IDR-only/paris-352x288-intra.bin; fi"
66 #- sh -c "if ( echo '$HOST' | grep -q '^arm' ); then LD_LIBRARY_PATH=`pwd`/libde265/.libs/ qemu-arm -L /usr/$HOST ./dec265/.libs/dec265 -t 4 -q -c ./libde265-data/IDR-only/paris-352x288-intra.bin; fi"
67 - sh -c "if ( echo '$HOST' | grep -q '^arm' ); then LD_LIBRARY_PATH=`pwd`/libde265/.libs/ qemu-arm -L /usr/$HOST ./dec265/.libs/dec265 -q -c ./libde265-data/RandomAccess/paris-ra-wpp.bin; fi"
68 #- sh -c "if ( echo '$HOST' | grep -q '^arm' ); then LD_LIBRARY_PATH=`pwd`/libde265/.libs/ qemu-arm -L /usr/$HOST ./dec265/.libs/dec265 -t 4 -q -c ./libde265-data/RandomAccess/paris-ra-wpp.bin; fi"
69 - sh -c "if [ ! -z '$DECODESTREAMS' ]; then python scripts/decodestreams.py $THREADING /var/lib/libde265-teststreams; fi"
0 project (libde265)
1 cmake_minimum_required (VERSION 2.8)
2
3 # The version number.
4 set (NUMERIC_VERSION 0x01000000)
5 set (PACKAGE_VERSION 1.0.0)
6
7 include (${CMAKE_ROOT}/Modules/CheckCCompilerFlag.cmake)
8 include (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
9 include (${CMAKE_ROOT}/Modules/FindSDL.cmake)
10 include (${CMAKE_ROOT}/Modules/FindThreads.cmake)
11
12 CHECK_INCLUDE_FILE(malloc.h HAVE_MALLOC_H)
13 CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
14 CHECK_INCLUDE_FILE(stdbool.h HAVE_STDBOOL_H)
15
16 if (HAVE_MALLOC_H)
17 add_definitions(-DHAVE_MALLOC_H)
18 endif()
19 if (HAVE_STDINT_H)
20 add_definitions(-DHAVE_STDINT_H)
21 endif()
22 if (HAVE_STDBOOL_H)
23 add_definitions(-DHAVE_STDBOOL_H)
24 endif()
25
26 configure_file (
27 "${PROJECT_SOURCE_DIR}/libde265/de265-version.h.in"
28 "${PROJECT_BINARY_DIR}/libde265/de265-version.h"
29 )
30
31 if(CMAKE_COMPILER_IS_GNUCXX)
32 set(GCC 1)
33 add_definitions(-Wall)
34 set(CMAKE_CXX_FLAGS "-std=gnu++0x ${CMAKE_CXX_FLAGS}")
35 elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
36 add_definitions(-Wall)
37 set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
38 endif()
39
40 option(DISABLE_SSE "Disable SSE optimizations")
41 if(NOT ${DISABLE_SSE} EQUAL OFF)
42 if(MSVC)
43 set(SUPPORTS_SSE4_1 1)
44 else()
45 CHECK_C_COMPILER_FLAG(-msse4.1 SUPPORTS_SSE4_1)
46 endif()
47 endif()
48
49 include_directories ("${PROJECT_SOURCE_DIR}")
50 include_directories ("${PROJECT_BINARY_DIR}")
51 include_directories ("${PROJECT_SOURCE_DIR}/libde265")
52 if(MSVC)
53 include_directories ("${PROJECT_SOURCE_DIR}/extra")
54 add_definitions(-DHAVE_STDINT_H)
55 add_definitions(-DHAVE_STDBOOL_H)
56 add_definitions(-DNOMINMAX)
57 endif()
58
59 if(UNIX)
60 set(LIBDE265_LIBRARY_NAME de265)
61 else()
62 set(LIBDE265_LIBRARY_NAME libde265)
63 endif()
64
65 add_subdirectory (libde265)
66 add_subdirectory (dec265)
67 add_subdirectory (enc265)
77 SUBDIRS+=dec265
88 endif
99
10 SUBDIRS+=enc265
11
12 SUBDIRS+=tools
13
1014 if ENABLE_SHERLOCK265
1115 SUBDIRS+=sherlock265
1216 endif
1519 autogen.sh \
1620 build.bat \
1721 m4/m4_ax_check_compile_flag.m4 \
18 build \
1922 Makefile.vc7 \
23 CMakeLists.txt \
2024 README.md \
2125 libde265.png \
2226 */COPYING
8484 DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \
8585 $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
8686 $(top_srcdir)/configure $(am__configure_deps) \
87 $(srcdir)/config.h.in $(srcdir)/libde265.pc.in COPYING compile \
88 config.guess config.sub depcomp install-sh missing ltmain.sh
87 $(srcdir)/config.h.in $(srcdir)/libde265.pc.in COPYING TODO \
88 compile config.guess config.sub depcomp install-sh missing \
89 ltmain.sh
8990 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
9091 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
92 $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \
9193 $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
9294 $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
9395 $(top_srcdir)/m4/lt~obsolete.m4 \
9496 $(top_srcdir)/m4/m4_ax_check_compile_flag.m4 \
95 $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/configure.ac
97 $(top_srcdir)/configure.ac
9698 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
9799 $(ACLOCAL_M4)
98100 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
186188 ETAGS = etags
187189 CTAGS = ctags
188190 CSCOPE = cscope
189 DIST_SUBDIRS = libde265 dec265 sherlock265
191 DIST_SUBDIRS = libde265 dec265 enc265 tools sherlock265
190192 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
191193 distdir = $(PACKAGE)-$(VERSION)
192194 top_distdir = $(distdir)
230232 | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
231233 distcleancheck_listfiles = find . -type f -print
232234 ACLOCAL = @ACLOCAL@
235 ALLOCA = @ALLOCA@
233236 AMTAR = @AMTAR@
234237 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
235238 AR = @AR@
238241 AUTOMAKE = @AUTOMAKE@
239242 AWK = @AWK@
240243 CC = @CC@
244 CCAS = @CCAS@
245 CCASDEPMODE = @CCASDEPMODE@
246 CCASFLAGS = @CCASFLAGS@
241247 CCDEPMODE = @CCDEPMODE@
242248 CFLAGS = @CFLAGS@
243 CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
244249 CPP = @CPP@
245250 CPPFLAGS = @CPPFLAGS@
246251 CXX = @CXX@
260265 EXEEXT = @EXEEXT@
261266 FGREP = @FGREP@
262267 GREP = @GREP@
263 HAVE_VISIBILITY = @HAVE_VISIBILITY@
268 HAVE_CXX11 = @HAVE_CXX11@
264269 INSTALL = @INSTALL@
265270 INSTALL_DATA = @INSTALL_DATA@
266271 INSTALL_PROGRAM = @INSTALL_PROGRAM@
371376 top_build_prefix = @top_build_prefix@
372377 top_builddir = @top_builddir@
373378 top_srcdir = @top_srcdir@
374 SUBDIRS = libde265 $(am__append_1) $(am__append_2)
379 SUBDIRS = libde265 $(am__append_1) enc265 tools $(am__append_2)
375380 ACLOCAL_AMFLAGS = -I m4
376381 EXTRA_DIST = .travis.yml \
377382 autogen.sh \
378383 build.bat \
379384 m4/m4_ax_check_compile_flag.m4 \
380 build \
381385 Makefile.vc7 \
386 CMakeLists.txt \
382387 README.md \
383388 libde265.png \
384389 */COPYING
00 clean all:
11 cd libde265 && $(MAKE) -f Makefile.vc7 $*
22 cd dec265 && $(MAKE) -f Makefile.vc7 $*
3 cd enc265 && $(MAKE) -f Makefile.vc7 $*
7676
7777 You can disable building of the example programs by running `./configure` with
7878 <pre>
79 --disable-dec265 Do not dec265 decoder program.
80 --disable-sherlock265 Do not build sherlock265 visual inspection program.
79 --disable-dec265 Do not build the dec265 decoder program.
80 --disable-sherlock265 Do not build the sherlock265 visual inspection program.
8181 </pre>
8282
8383 Additional logging information can be turned on and off using these `./configure` flags:
8686 --enable-log-info turn on logging at info level (default=no)
8787 --enable-log-trace turn on logging at trace level (default=no)
8888 </pre>
89
90
91 Build using cmake
92 =================
93
94 cmake scripts to build libde265 and the sample scripts `dec265` and `enc265` are
95 included and can be compiled using these commands:
96
97 ```
98 mkdir build
99 cd build
100 cmake ..
101 make
102 ```
103
104 See the [cmake documentation](http://www.cmake.org) for further information on
105 using cmake on other platforms.
89106
90107
91108 Prebuilt binaries
0 /mnt/temp/dirk/yuv/flower_garden_422_720x486_30fps_simple_intra.bin
1
2 diff at byte 00196800
3 frame 3
4 channel: 0
5 pixel position: x=384;y=125
6 file A: 56
7 file B: 86
8
9
10 - API: request IDR-frame
11 - API: return SPS header infos
12 - rate-control: specify bit-rate
214214 m4_ifndef([AC_AUTOCONF_VERSION],
215215 [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
216216 _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
217
218 # Figure out how to run the assembler. -*- Autoconf -*-
219
220 # Copyright (C) 2001-2013 Free Software Foundation, Inc.
221 #
222 # This file is free software; the Free Software Foundation
223 # gives unlimited permission to copy and/or distribute it,
224 # with or without modifications, as long as this notice is preserved.
225
226 # AM_PROG_AS
227 # ----------
228 AC_DEFUN([AM_PROG_AS],
229 [# By default we simply use the C compiler to build assembly code.
230 AC_REQUIRE([AC_PROG_CC])
231 test "${CCAS+set}" = set || CCAS=$CC
232 test "${CCASFLAGS+set}" = set || CCASFLAGS=$CFLAGS
233 AC_ARG_VAR([CCAS], [assembler compiler command (defaults to CC)])
234 AC_ARG_VAR([CCASFLAGS], [assembler compiler flags (defaults to CFLAGS)])
235 _AM_IF_OPTION([no-dependencies],, [_AM_DEPENDENCIES([CCAS])])dnl
236 ])
217237
218238 # AM_AUX_DIR_EXPAND -*- Autoconf -*-
219239
13071327 ]) # _AM_PROG_TAR
13081328
13091329 m4_include([m4/ax_compare_version.m4])
1330 m4_include([m4/ax_cxx_compile_stdcxx_11.m4])
13101331 m4_include([m4/libtool.m4])
13111332 m4_include([m4/ltoptions.m4])
13121333 m4_include([m4/ltsugar.m4])
13131334 m4_include([m4/ltversion.m4])
13141335 m4_include([m4/lt~obsolete.m4])
13151336 m4_include([m4/m4_ax_check_compile_flag.m4])
1316 m4_include([m4/visibility.m4])
00 #!/bin/sh
1 set -eu
2 #
3 # H.265 video codec.
4 # Copyright (c) 2013 struktur AG, Joachim Bauch <bauch@struktur.de>
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 General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (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 General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with libde265. If not, see <http://www.gnu.org/licenses/>.
20 #
121 if [ -x "`which autoreconf 2>/dev/null`" ] ; then
222 exec autoreconf -ivf
323 fi
+0
-6
build/vc9-x86/make-solutions.bat less more
0 @echo off
1 ::
2 :: run this batch file to create a Visual Studion solution file for this project.
3 :: See the cmake documentation for other generator targets
4 ::
5 cmake -G "Visual Studio 9 2008" ..\..\dec265 && cmake-gui ..\..\dec265
1919 mkdir bin_x86\lib
2020 )
2121 copy /y dec265\dec265.exe bin_x86\
22 copy /y enc265\enc265.exe bin_x86\
2223 copy /y libde265\libde265.dll bin_x86\
2324 copy /y libde265\libde265.lib bin_x86\lib\
2425 copy /y libde265\libde265.exp bin_x86\lib\
3233 mkdir bin_x64\lib
3334 )
3435 copy /y dec265\dec265.exe bin_x64\
36 copy /y enc265\enc265.exe bin_x64\
3537 copy /y libde265\libde265.dll bin_x64\
3638 copy /y libde265\libde265.lib bin_x64\lib\
3739 copy /y libde265\libde265.exp bin_x64\lib\
00 /* config.h.in. Generated from configure.ac by autoheader. */
1
2 /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
3 systems. This function is required for `alloca.c' support on those systems.
4 */
5 #undef CRAY_STACKSEG_END
6
7 /* Define to 1 if using `alloca.c'. */
8 #undef C_ALLOCA
9
10 /* Define to 1 if you have the `alarm' function. */
11 #undef HAVE_ALARM
12
13 /* Define to 1 if you have `alloca', as a function or macro. */
14 #undef HAVE_ALLOCA
15
16 /* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
17 */
18 #undef HAVE_ALLOCA_H
19
20 /* Support ARM instructions */
21 #undef HAVE_ARM
22
23 /* define if the compiler supports basic C++11 syntax */
24 #undef HAVE_CXX11
125
226 /* Define to 1 if you have the <dlfcn.h> header file. */
327 #undef HAVE_DLFCN_H
428
29 /* Define to 1 if you have the `gettimeofday' function. */
30 #undef HAVE_GETTIMEOFDAY
31
532 /* Define to 1 if you have the <inttypes.h> header file. */
633 #undef HAVE_INTTYPES_H
734
2350 /* Define to 1 if you have the `memset' function. */
2451 #undef HAVE_MEMSET
2552
53 /* Support ARM NEON instructions */
54 #undef HAVE_NEON
55
2656 /* Define to 1 if you have the `posix_memalign' function. */
2757 #undef HAVE_POSIX_MEMALIGN
2858
59 /* Define to 1 if you have the `pow' function. */
60 #undef HAVE_POW
61
62 /* Define to 1 if the system has the type `ptrdiff_t'. */
63 #undef HAVE_PTRDIFF_T
64
2965 /* Whether libsdl was found. */
3066 #undef HAVE_SDL
3167
68 /* Define to 1 if you have the <setjmp.h> header file. */
69 #undef HAVE_SETJMP_H
70
71 /* Define to 1 if you have the <signal.h> header file. */
72 #undef HAVE_SIGNAL_H
73
74 /* Define to 1 if you have the `sqrt' function. */
75 #undef HAVE_SQRT
76
3277 /* Support SSSE4.1 (Streaming SIMD Extensions 4.1) instructions */
3378 #undef HAVE_SSE4_1
3479
3580 /* Define to 1 if stdbool.h conforms to C99. */
3681 #undef HAVE_STDBOOL_H
3782
83 /* Define to 1 if you have the <stddef.h> header file. */
84 #undef HAVE_STDDEF_H
85
3886 /* Define to 1 if you have the <stdint.h> header file. */
3987 #undef HAVE_STDINT_H
4088
4189 /* Define to 1 if you have the <stdlib.h> header file. */
4290 #undef HAVE_STDLIB_H
4391
92 /* Define to 1 if you have the `strchr' function. */
93 #undef HAVE_STRCHR
94
4495 /* Define to 1 if you have the <strings.h> header file. */
4596 #undef HAVE_STRINGS_H
4697
4798 /* Define to 1 if you have the <string.h> header file. */
4899 #undef HAVE_STRING_H
49100
101 /* Define to 1 if you have the `strrchr' function. */
102 #undef HAVE_STRRCHR
103
50104 /* Whether libswscale was found. */
51105 #undef HAVE_SWSCALE
52106
53107 /* Define to 1 if you have the <sys/stat.h> header file. */
54108 #undef HAVE_SYS_STAT_H
55109
110 /* Define to 1 if you have the <sys/time.h> header file. */
111 #undef HAVE_SYS_TIME_H
112
56113 /* Define to 1 if you have the <sys/types.h> header file. */
57114 #undef HAVE_SYS_TYPES_H
58115
61118
62119 /* Whether libvideogfx was found. */
63120 #undef HAVE_VIDEOGFX
64
65 /* Define to 1 or 0, depending whether the compiler supports simple visibility
66 declarations. */
67 #undef HAVE_VISIBILITY
68121
69122 /* Define to 1 if the system has the type `_Bool'. */
70123 #undef HAVE__BOOL
103156 /* Define to the version of this package. */
104157 #undef PACKAGE_VERSION
105158
159 /* If using the C implementation of alloca, define if you know the
160 direction of stack growth for your system; otherwise it will be
161 automatically deduced at runtime.
162 STACK_DIRECTION > 0 => grows toward higher addresses
163 STACK_DIRECTION < 0 => grows toward lower addresses
164 STACK_DIRECTION = 0 => direction of growth unknown */
165 #undef STACK_DIRECTION
166
106167 /* Define to 1 if you have the ANSI C header files. */
107168 #undef STDC_HEADERS
169
170 /* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
171 #undef TIME_WITH_SYS_TIME
108172
109173 /* Version number of package */
110174 #undef VERSION
124188 #define below would cause a syntax error. */
125189 #undef _UINT8_T
126190
191 /* Define to `__inline__' or `__inline' if that's what the C compiler
192 calls it, or to nothing if 'inline' is not supported under any name. */
193 #ifndef __cplusplus
194 #undef inline
195 #endif
196
127197 /* Define to the type of a signed integer type of width exactly 16 bits if
128198 such a type exists and the standard includes do not define it. */
129199 #undef int16_t
131201 /* Define to the type of a signed integer type of width exactly 32 bits if
132202 such a type exists and the standard includes do not define it. */
133203 #undef int32_t
204
205 /* Define to the type of a signed integer type of width exactly 64 bits if
206 such a type exists and the standard includes do not define it. */
207 #undef int64_t
134208
135209 /* Define to the type of a signed integer type of width exactly 8 bits if such
136210 a type exists and the standard includes do not define it. */
137211 #undef int8_t
138212
213 /* Define to `unsigned int' if <sys/types.h> does not define. */
214 #undef size_t
215
139216 /* Define to the type of an unsigned integer type of width exactly 16 bits if
140217 such a type exists and the standard includes do not define it. */
141218 #undef uint16_t
+1323
-165
configure less more
00 #! /bin/sh
11 # Guess values for system-dependent variables and create Makefiles.
2 # Generated by GNU Autoconf 2.69 for libde265 0.9.
2 # Generated by GNU Autoconf 2.69 for libde265 1.0.2.
33 #
44 # Report bugs to <farin@struktur.de>.
55 #
589589 # Identity of this package.
590590 PACKAGE_NAME='libde265'
591591 PACKAGE_TARNAME='libde265'
592 PACKAGE_VERSION='0.9'
593 PACKAGE_STRING='libde265 0.9'
592 PACKAGE_VERSION='1.0.2'
593 PACKAGE_STRING='libde265 1.0.2'
594594 PACKAGE_BUGREPORT='farin@struktur.de'
595595 PACKAGE_URL=''
596596
631631 # include <unistd.h>
632632 #endif"
633633
634 ac_header_list=
635 ac_func_list=
634636 ac_subst_vars='am__EXEEXT_FALSE
635637 am__EXEEXT_TRUE
636638 LTLIBOBJS
637 LIBOBJS
638639 ENABLE_SHERLOCK265_FALSE
639640 ENABLE_SHERLOCK265_TRUE
640641 ENABLE_DEC265_FALSE
658659 PKG_CONFIG_LIBDIR
659660 PKG_CONFIG_PATH
660661 PKG_CONFIG
662 ENABLE_ARM_THUMB_FALSE
663 ENABLE_ARM_THUMB_TRUE
664 ENABLE_NEON_OPT_FALSE
665 ENABLE_NEON_OPT_TRUE
666 ENABLE_ARM_OPT_FALSE
667 ENABLE_ARM_OPT_TRUE
661668 ENABLE_SSE_OPT_FALSE
662669 ENABLE_SSE_OPT_TRUE
663670 MINGW_FALSE
664671 MINGW_TRUE
672 LIBOBJS
673 ALLOCA
665674 HAVE_VISIBILITY_FALSE
666675 HAVE_VISIBILITY_TRUE
667 HAVE_VISIBILITY
668 CFLAG_VISIBILITY
676 HAVE_CXX11
669677 AM_BACKSLASH
670678 AM_DEFAULT_VERBOSITY
671679 AM_DEFAULT_V
676684 am__fastdepCC_FALSE
677685 am__fastdepCC_TRUE
678686 CCDEPMODE
679 am__nodep
680 AMDEPBACKSLASH
681 AMDEP_FALSE
682 AMDEP_TRUE
683 am__quote
684 am__include
685 DEPDIR
686687 am__untar
687688 am__tar
688689 AMTAR
689 am__leading_dot
690690 SET_MAKE
691691 mkdir_p
692692 MKDIR_P
708708 ac_ct_CXX
709709 CXXFLAGS
710710 CXX
711 am__fastdepCCAS_FALSE
712 am__fastdepCCAS_TRUE
713 CCASDEPMODE
714 am__nodep
715 AMDEPBACKSLASH
716 AMDEP_FALSE
717 AMDEP_TRUE
718 am__quote
719 am__include
720 DEPDIR
721 am__leading_dot
722 CCASFLAGS
723 CCAS
711724 CPP
712725 OTOOL64
713726 OTOOL
806819 enable_dependency_tracking
807820 enable_silent_rules
808821 enable_sse
822 enable_arm
823 enable_thumb
809824 enable_log_error
810825 enable_log_info
811826 enable_log_debug
822837 LIBS
823838 CPPFLAGS
824839 CPP
840 CCAS
841 CCASFLAGS
825842 CXX
826843 CXXFLAGS
827844 CCC
13771394 # Omit some internal or obsolete options to make the list less imposing.
13781395 # This message is too long to be a string in the A/UX 3.1 sh.
13791396 cat <<_ACEOF
1380 \`configure' configures libde265 0.9 to adapt to many kinds of systems.
1397 \`configure' configures libde265 1.0.2 to adapt to many kinds of systems.
13811398
13821399 Usage: $0 [OPTION]... [VAR=VALUE]...
13831400
14481465
14491466 if test -n "$ac_init_help"; then
14501467 case $ac_init_help in
1451 short | recursive ) echo "Configuration of libde265 0.9:";;
1468 short | recursive ) echo "Configuration of libde265 1.0.2:";;
14521469 esac
14531470 cat <<\_ACEOF
14541471
14681485 --enable-silent-rules less verbose build output (undo: "make V=1")
14691486 --disable-silent-rules verbose build output (undo: "make V=0")
14701487 --disable-sse disable SSE optimizations (default=no)
1488 --disable-arm disable ARM optimizations (default=no)
1489 --enable-thumb disable ARM THUMB instructions (default=no)
14711490 --enable-log-error turn on logging at error level (default=yes)
14721491 --enable-log-info turn on logging at info level (default=no)
14731492 --enable-log-debug turn on logging at debug level (default=no)
14931512 CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
14941513 you have headers in a nonstandard directory <include dir>
14951514 CPP C preprocessor
1515 CCAS assembler compiler command (defaults to CC)
1516 CCASFLAGS assembler compiler flags (defaults to CFLAGS)
14961517 CXX C++ compiler command
14971518 CXXFLAGS C++ compiler flags
14981519 CXXCPP C++ preprocessor
15801601 test -n "$ac_init_help" && exit $ac_status
15811602 if $ac_init_version; then
15821603 cat <<\_ACEOF
1583 libde265 configure 0.9
1604 libde265 configure 1.0.2
15841605 generated by GNU Autoconf 2.69
15851606
15861607 Copyright (C) 2012 Free Software Foundation, Inc.
22542275 This file contains any messages produced by compilers while
22552276 running configure, to aid debugging if configure makes a mistake.
22562277
2257 It was created by libde265 $as_me 0.9, which was
2278 It was created by libde265 $as_me 1.0.2, which was
22582279 generated by GNU Autoconf 2.69. Invocation command line was
22592280
22602281 $ $0 $@
25342555 >$cache_file
25352556 fi
25362557
2558 as_fn_append ac_header_list " sys/time.h"
2559 as_fn_append ac_header_list " unistd.h"
2560 as_fn_append ac_func_list " alarm"
25372561 # Check that the precious variables saved in the cache have kept the same
25382562 # value.
25392563 ac_cache_corrupted=false
26062630 ac_config_headers="$ac_config_headers config.h"
26072631
26082632
2609 NUMERIC_VERSION=0x00090000 # Numeric representation of the version
2633 NUMERIC_VERSION=0x01000200 # Numeric representation of the version (A.B.C[.D] = 0xAABBCCDD)
26102634
26112635
26122636 LIBDE265_CURRENT=0
2613 LIBDE265_REVISION=8
2637 LIBDE265_REVISION=10
26142638 LIBDE265_AGE=0
26152639
26162640 # ---------------------------------------------------------------------------
1118211206
1118311207
1118411208 # Checks for programs.
11209 rm -rf .tst 2>/dev/null
11210 mkdir .tst 2>/dev/null
11211 if test -d .tst; then
11212 am__leading_dot=.
11213 else
11214 am__leading_dot=_
11215 fi
11216 rmdir .tst 2>/dev/null
11217
11218 DEPDIR="${am__leading_dot}deps"
11219
11220 ac_config_commands="$ac_config_commands depfiles"
11221
11222
11223 am_make=${MAKE-make}
11224 cat > confinc << 'END'
11225 am__doit:
11226 @echo this is the am__doit target
11227 .PHONY: am__doit
11228 END
11229 # If we don't find an include directive, just comment out the code.
11230 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5
11231 $as_echo_n "checking for style of include used by $am_make... " >&6; }
11232 am__include="#"
11233 am__quote=
11234 _am_result=none
11235 # First try GNU make style include.
11236 echo "include confinc" > confmf
11237 # Ignore all kinds of additional output from 'make'.
11238 case `$am_make -s -f confmf 2> /dev/null` in #(
11239 *the\ am__doit\ target*)
11240 am__include=include
11241 am__quote=
11242 _am_result=GNU
11243 ;;
11244 esac
11245 # Now try BSD make style include.
11246 if test "$am__include" = "#"; then
11247 echo '.include "confinc"' > confmf
11248 case `$am_make -s -f confmf 2> /dev/null` in #(
11249 *the\ am__doit\ target*)
11250 am__include=.include
11251 am__quote="\""
11252 _am_result=BSD
11253 ;;
11254 esac
11255 fi
11256
11257
11258 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5
11259 $as_echo "$_am_result" >&6; }
11260 rm -f confinc confmf
11261
11262 # Check whether --enable-dependency-tracking was given.
11263 if test "${enable_dependency_tracking+set}" = set; then :
11264 enableval=$enable_dependency_tracking;
11265 fi
11266
11267 if test "x$enable_dependency_tracking" != xno; then
11268 am_depcomp="$ac_aux_dir/depcomp"
11269 AMDEPBACKSLASH='\'
11270 am__nodep='_no'
11271 fi
11272 if test "x$enable_dependency_tracking" != xno; then
11273 AMDEP_TRUE=
11274 AMDEP_FALSE='#'
11275 else
11276 AMDEP_TRUE='#'
11277 AMDEP_FALSE=
11278 fi
11279
11280
11281 # By default we simply use the C compiler to build assembly code.
11282
11283 test "${CCAS+set}" = set || CCAS=$CC
11284 test "${CCASFLAGS+set}" = set || CCASFLAGS=$CFLAGS
11285
11286
11287
11288 depcc="$CCAS" am_compiler_list=
11289
11290 { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
11291 $as_echo_n "checking dependency style of $depcc... " >&6; }
11292 if ${am_cv_CCAS_dependencies_compiler_type+:} false; then :
11293 $as_echo_n "(cached) " >&6
11294 else
11295 if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
11296 # We make a subdir and do the tests there. Otherwise we can end up
11297 # making bogus files that we don't know about and never remove. For
11298 # instance it was reported that on HP-UX the gcc test will end up
11299 # making a dummy file named 'D' -- because '-MD' means "put the output
11300 # in D".
11301 rm -rf conftest.dir
11302 mkdir conftest.dir
11303 # Copy depcomp to subdir because otherwise we won't find it if we're
11304 # using a relative directory.
11305 cp "$am_depcomp" conftest.dir
11306 cd conftest.dir
11307 # We will build objects and dependencies in a subdirectory because
11308 # it helps to detect inapplicable dependency modes. For instance
11309 # both Tru64's cc and ICC support -MD to output dependencies as a
11310 # side effect of compilation, but ICC will put the dependencies in
11311 # the current directory while Tru64 will put them in the object
11312 # directory.
11313 mkdir sub
11314
11315 am_cv_CCAS_dependencies_compiler_type=none
11316 if test "$am_compiler_list" = ""; then
11317 am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
11318 fi
11319 am__universal=false
11320
11321
11322 for depmode in $am_compiler_list; do
11323 # Setup a source with many dependencies, because some compilers
11324 # like to wrap large dependency lists on column 80 (with \), and
11325 # we should not choose a depcomp mode which is confused by this.
11326 #
11327 # We need to recreate these files for each test, as the compiler may
11328 # overwrite some of them when testing with obscure command lines.
11329 # This happens at least with the AIX C compiler.
11330 : > sub/conftest.c
11331 for i in 1 2 3 4 5 6; do
11332 echo '#include "conftst'$i'.h"' >> sub/conftest.c
11333 # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
11334 # Solaris 10 /bin/sh.
11335 echo '/* dummy */' > sub/conftst$i.h
11336 done
11337 echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
11338
11339 # We check with '-c' and '-o' for the sake of the "dashmstdout"
11340 # mode. It turns out that the SunPro C++ compiler does not properly
11341 # handle '-M -o', and we need to detect this. Also, some Intel
11342 # versions had trouble with output in subdirs.
11343 am__obj=sub/conftest.${OBJEXT-o}
11344 am__minus_obj="-o $am__obj"
11345 case $depmode in
11346 gcc)
11347 # This depmode causes a compiler race in universal mode.
11348 test "$am__universal" = false || continue
11349 ;;
11350 nosideeffect)
11351 # After this tag, mechanisms are not by side-effect, so they'll
11352 # only be used when explicitly requested.
11353 if test "x$enable_dependency_tracking" = xyes; then
11354 continue
11355 else
11356 break
11357 fi
11358 ;;
11359 msvc7 | msvc7msys | msvisualcpp | msvcmsys)
11360 # This compiler won't grok '-c -o', but also, the minuso test has
11361 # not run yet. These depmodes are late enough in the game, and
11362 # so weak that their functioning should not be impacted.
11363 am__obj=conftest.${OBJEXT-o}
11364 am__minus_obj=
11365 ;;
11366 none) break ;;
11367 esac
11368 if depmode=$depmode \
11369 source=sub/conftest.c object=$am__obj \
11370 depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
11371 $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
11372 >/dev/null 2>conftest.err &&
11373 grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
11374 grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
11375 grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
11376 ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
11377 # icc doesn't choke on unknown options, it will just issue warnings
11378 # or remarks (even with -Werror). So we grep stderr for any message
11379 # that says an option was ignored or not supported.
11380 # When given -MP, icc 7.0 and 7.1 complain thusly:
11381 # icc: Command line warning: ignoring option '-M'; no argument required
11382 # The diagnosis changed in icc 8.0:
11383 # icc: Command line remark: option '-MP' not supported
11384 if (grep 'ignoring option' conftest.err ||
11385 grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
11386 am_cv_CCAS_dependencies_compiler_type=$depmode
11387 break
11388 fi
11389 fi
11390 done
11391
11392 cd ..
11393 rm -rf conftest.dir
11394 else
11395 am_cv_CCAS_dependencies_compiler_type=none
11396 fi
11397
11398 fi
11399 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CCAS_dependencies_compiler_type" >&5
11400 $as_echo "$am_cv_CCAS_dependencies_compiler_type" >&6; }
11401 CCASDEPMODE=depmode=$am_cv_CCAS_dependencies_compiler_type
11402
11403 if
11404 test "x$enable_dependency_tracking" != xno \
11405 && test "$am_cv_CCAS_dependencies_compiler_type" = gcc3; then
11406 am__fastdepCCAS_TRUE=
11407 am__fastdepCCAS_FALSE='#'
11408 else
11409 am__fastdepCCAS_TRUE='#'
11410 am__fastdepCCAS_FALSE=
11411 fi
11412
11413
1118511414 ac_ext=cpp
1118611415 ac_cpp='$CXXCPP $CPPFLAGS'
1118711416 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
1568415913 SET_MAKE="MAKE=${MAKE-make}"
1568515914 fi
1568615915
15687 rm -rf .tst 2>/dev/null
15688 mkdir .tst 2>/dev/null
15689 if test -d .tst; then
15690 am__leading_dot=.
15691 else
15692 am__leading_dot=_
15693 fi
15694 rmdir .tst 2>/dev/null
15695
15696 DEPDIR="${am__leading_dot}deps"
15697
15698 ac_config_commands="$ac_config_commands depfiles"
15699
15700
15701 am_make=${MAKE-make}
15702 cat > confinc << 'END'
15703 am__doit:
15704 @echo this is the am__doit target
15705 .PHONY: am__doit
15706 END
15707 # If we don't find an include directive, just comment out the code.
15708 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5
15709 $as_echo_n "checking for style of include used by $am_make... " >&6; }
15710 am__include="#"
15711 am__quote=
15712 _am_result=none
15713 # First try GNU make style include.
15714 echo "include confinc" > confmf
15715 # Ignore all kinds of additional output from 'make'.
15716 case `$am_make -s -f confmf 2> /dev/null` in #(
15717 *the\ am__doit\ target*)
15718 am__include=include
15719 am__quote=
15720 _am_result=GNU
15721 ;;
15722 esac
15723 # Now try BSD make style include.
15724 if test "$am__include" = "#"; then
15725 echo '.include "confinc"' > confmf
15726 case `$am_make -s -f confmf 2> /dev/null` in #(
15727 *the\ am__doit\ target*)
15728 am__include=.include
15729 am__quote="\""
15730 _am_result=BSD
15731 ;;
15732 esac
15733 fi
15734
15735
15736 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5
15737 $as_echo "$_am_result" >&6; }
15738 rm -f confinc confmf
15739
15740 # Check whether --enable-dependency-tracking was given.
15741 if test "${enable_dependency_tracking+set}" = set; then :
15742 enableval=$enable_dependency_tracking;
15743 fi
15744
15745 if test "x$enable_dependency_tracking" != xno; then
15746 am_depcomp="$ac_aux_dir/depcomp"
15747 AMDEPBACKSLASH='\'
15748 am__nodep='_no'
15749 fi
15750 if test "x$enable_dependency_tracking" != xno; then
15751 AMDEP_TRUE=
15752 AMDEP_FALSE='#'
15753 else
15754 AMDEP_TRUE='#'
15755 AMDEP_FALSE=
15756 fi
15757
15758
1575915916 # Check whether --enable-silent-rules was given.
1576015917 if test "${enable_silent_rules+set}" = set; then :
1576115918 enableval=$enable_silent_rules;
1581715974
1581815975 # Define the identity of the package.
1581915976 PACKAGE='libde265'
15820 VERSION='0.9'
15977 VERSION='1.0.2'
1582115978
1582215979
1582315980 cat >>confdefs.h <<_ACEOF
1616716324 fi
1616816325
1616916326 CFLAGS+=" -std=c99"
16327 CXXFLAGS+=" -Werror=return-type -Werror=unused-result -Werror=reorder"
16328 ax_cxx_compile_cxx11_required=true
16329 ac_ext=cpp
16330 ac_cpp='$CXXCPP $CPPFLAGS'
16331 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
16332 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
16333 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
16334 ac_success=no
16335 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5
16336 $as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; }
16337 if ${ax_cv_cxx_compile_cxx11+:} false; then :
16338 $as_echo_n "(cached) " >&6
16339 else
16340 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
16341 /* end confdefs.h. */
16342
16343 template <typename T>
16344 struct check
16345 {
16346 static_assert(sizeof(int) <= sizeof(T), "not big enough");
16347 };
16348
16349 struct Base {
16350 virtual void f() {}
16351 };
16352 struct Child : public Base {
16353 virtual void f() {} // DiFa: override {} # override not supported in gcc 4.6
16354 };
16355
16356 typedef check<check<bool>> right_angle_brackets;
16357
16358 int a;
16359 decltype(a) b;
16360
16361 typedef check<int> check_type;
16362 check_type c;
16363 check_type&& cr = static_cast<check_type&&>(c);
16364
16365 auto d = a;
16366 auto l = [](){};
16367
16368 _ACEOF
16369 if ac_fn_cxx_try_compile "$LINENO"; then :
16370 ax_cv_cxx_compile_cxx11=yes
16371 else
16372 ax_cv_cxx_compile_cxx11=no
16373 fi
16374 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
16375 fi
16376 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11" >&5
16377 $as_echo "$ax_cv_cxx_compile_cxx11" >&6; }
16378 if test x$ax_cv_cxx_compile_cxx11 = xyes; then
16379 ac_success=yes
16380 fi
16381
16382 if test x$ac_success = xno; then
16383 for switch in -std=gnu++11 -std=gnu++0x; do
16384 cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh`
16385 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5
16386 $as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; }
16387 if eval \${$cachevar+:} false; then :
16388 $as_echo_n "(cached) " >&6
16389 else
16390 ac_save_CXXFLAGS="$CXXFLAGS"
16391 CXXFLAGS="$CXXFLAGS $switch"
16392 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
16393 /* end confdefs.h. */
16394
16395 template <typename T>
16396 struct check
16397 {
16398 static_assert(sizeof(int) <= sizeof(T), "not big enough");
16399 };
16400
16401 struct Base {
16402 virtual void f() {}
16403 };
16404 struct Child : public Base {
16405 virtual void f() {} // DiFa: override {} # override not supported in gcc 4.6
16406 };
16407
16408 typedef check<check<bool>> right_angle_brackets;
16409
16410 int a;
16411 decltype(a) b;
16412
16413 typedef check<int> check_type;
16414 check_type c;
16415 check_type&& cr = static_cast<check_type&&>(c);
16416
16417 auto d = a;
16418 auto l = [](){};
16419
16420 _ACEOF
16421 if ac_fn_cxx_try_compile "$LINENO"; then :
16422 eval $cachevar=yes
16423 else
16424 eval $cachevar=no
16425 fi
16426 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
16427 CXXFLAGS="$ac_save_CXXFLAGS"
16428 fi
16429 eval ac_res=\$$cachevar
16430 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
16431 $as_echo "$ac_res" >&6; }
16432 if eval test x\$$cachevar = xyes; then
16433 CXXFLAGS="$CXXFLAGS $switch"
16434 ac_success=yes
16435 break
16436 fi
16437 done
16438 fi
16439
16440 if test x$ac_success = xno; then
16441 for switch in -std=c++11 -std=c++0x; do
16442 cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh`
16443 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5
16444 $as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; }
16445 if eval \${$cachevar+:} false; then :
16446 $as_echo_n "(cached) " >&6
16447 else
16448 ac_save_CXXFLAGS="$CXXFLAGS"
16449 CXXFLAGS="$CXXFLAGS $switch"
16450 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
16451 /* end confdefs.h. */
16452
16453 template <typename T>
16454 struct check
16455 {
16456 static_assert(sizeof(int) <= sizeof(T), "not big enough");
16457 };
16458
16459 struct Base {
16460 virtual void f() {}
16461 };
16462 struct Child : public Base {
16463 virtual void f() {} // DiFa: override {} # override not supported in gcc 4.6
16464 };
16465
16466 typedef check<check<bool>> right_angle_brackets;
16467
16468 int a;
16469 decltype(a) b;
16470
16471 typedef check<int> check_type;
16472 check_type c;
16473 check_type&& cr = static_cast<check_type&&>(c);
16474
16475 auto d = a;
16476 auto l = [](){};
16477
16478 _ACEOF
16479 if ac_fn_cxx_try_compile "$LINENO"; then :
16480 eval $cachevar=yes
16481 else
16482 eval $cachevar=no
16483 fi
16484 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
16485 CXXFLAGS="$ac_save_CXXFLAGS"
16486 fi
16487 eval ac_res=\$$cachevar
16488 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
16489 $as_echo "$ac_res" >&6; }
16490 if eval test x\$$cachevar = xyes; then
16491 CXXFLAGS="$CXXFLAGS $switch"
16492 ac_success=yes
16493 break
16494 fi
16495 done
16496 fi
16497 ac_ext=c
16498 ac_cpp='$CPP $CPPFLAGS'
16499 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
16500 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
16501 ac_compiler_gnu=$ac_cv_c_compiler_gnu
16502
16503 if test x$ax_cxx_compile_cxx11_required = xtrue; then
16504 if test x$ac_success = xno; then
16505 as_fn_error $? "*** A compiler with support for C++11 language features is required." "$LINENO" 5
16506 fi
16507 else
16508 if test x$ac_success = xno; then
16509 HAVE_CXX11=0
16510 { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++11 support was found" >&5
16511 $as_echo "$as_me: No compiler with C++11 support was found" >&6;}
16512 else
16513 HAVE_CXX11=1
16514
16515 $as_echo "#define HAVE_CXX11 1" >>confdefs.h
16516
16517 fi
16518
16519
16520 fi
16521
1617016522
1617116523 if test "x$GCC" = "xyes"; then
1617216524 case " $CFLAGS " in
1617516527 esac
1617616528 fi
1617716529
16178
16179
16180 CFLAG_VISIBILITY=
16181 HAVE_VISIBILITY=0
16182 if test -n "$GCC"; then
16183 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for simple visibility declarations" >&5
16184 $as_echo_n "checking for simple visibility declarations... " >&6; }
16185 if ${gl_cv_cc_visibility+:} false; then :
16186 $as_echo_n "(cached) " >&6
16187 else
16188
16189 gl_save_CFLAGS="$CFLAGS"
16190 CFLAGS="$CFLAGS -fvisibility=hidden"
16191 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
16192 /* end confdefs.h. */
16193 extern __attribute__((__visibility__("hidden"))) int hiddenvar;
16194 extern __attribute__((__visibility__("default"))) int exportedvar;
16195 extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
16196 extern __attribute__((__visibility__("default"))) int exportedfunc (void);
16197 int
16198 main ()
16199 {
16200
16201 ;
16202 return 0;
16203 }
16204 _ACEOF
16205 if ac_fn_c_try_compile "$LINENO"; then :
16206 gl_cv_cc_visibility=yes
16207 else
16208 gl_cv_cc_visibility=no
16209 fi
16210 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
16211 CFLAGS="$gl_save_CFLAGS"
16212 fi
16213
16214 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_cc_visibility" >&5
16215 $as_echo "$gl_cv_cc_visibility" >&6; }
16216 if test $gl_cv_cc_visibility = yes; then
16217 CFLAG_VISIBILITY="-fvisibility=hidden"
16218 HAVE_VISIBILITY=1
16219 fi
16220 fi
16221
16222
16223
16224 cat >>confdefs.h <<_ACEOF
16225 #define HAVE_VISIBILITY $HAVE_VISIBILITY
16226 _ACEOF
16227
16228
16530 HAVE_VISIBILITY=0
1622916531 if test "x$HAVE_VISIBILITY" != "x0"; then
1623016532 HAVE_VISIBILITY_TRUE=
1623116533 HAVE_VISIBILITY_FALSE='#'
1623616538
1623716539
1623816540 # Checks for header files.
16239 for ac_header in stdint.h stdlib.h string.h malloc.h
16541 for ac_header in stdint.h stdlib.h string.h malloc.h signal.h setjmp.h stddef.h sys/time.h
1624016542 do :
1624116543 as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
1624216544 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
1634416646
1634516647 fi
1634616648
16649 ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default"
16650 if test "x$ac_cv_type_size_t" = xyes; then :
16651
16652 else
16653
16654 cat >>confdefs.h <<_ACEOF
16655 #define size_t unsigned int
16656 _ACEOF
16657
16658 fi
16659
16660 ac_fn_c_find_intX_t "$LINENO" "8" "ac_cv_c_int8_t"
16661 case $ac_cv_c_int8_t in #(
16662 no|yes) ;; #(
16663 *)
16664
16665 cat >>confdefs.h <<_ACEOF
16666 #define int8_t $ac_cv_c_int8_t
16667 _ACEOF
16668 ;;
16669 esac
16670
1634716671 ac_fn_c_find_intX_t "$LINENO" "16" "ac_cv_c_int16_t"
1634816672 case $ac_cv_c_int16_t in #(
1634916673 no|yes) ;; #(
1636616690 ;;
1636716691 esac
1636816692
16369 ac_fn_c_find_intX_t "$LINENO" "8" "ac_cv_c_int8_t"
16370 case $ac_cv_c_int8_t in #(
16693 ac_fn_c_find_intX_t "$LINENO" "64" "ac_cv_c_int64_t"
16694 case $ac_cv_c_int64_t in #(
1637116695 no|yes) ;; #(
1637216696 *)
1637316697
1637416698 cat >>confdefs.h <<_ACEOF
16375 #define int8_t $ac_cv_c_int8_t
16699 #define int64_t $ac_cv_c_int64_t
1637616700 _ACEOF
1637716701 ;;
1637816702 esac
16703
16704 ac_fn_c_find_uintX_t "$LINENO" "8" "ac_cv_c_uint8_t"
16705 case $ac_cv_c_uint8_t in #(
16706 no|yes) ;; #(
16707 *)
16708
16709 $as_echo "#define _UINT8_T 1" >>confdefs.h
16710
16711
16712 cat >>confdefs.h <<_ACEOF
16713 #define uint8_t $ac_cv_c_uint8_t
16714 _ACEOF
16715 ;;
16716 esac
1637916717
1638016718 ac_fn_c_find_uintX_t "$LINENO" "16" "ac_cv_c_uint16_t"
1638116719 case $ac_cv_c_uint16_t in #(
1641716755 ;;
1641816756 esac
1641916757
16420 ac_fn_c_find_uintX_t "$LINENO" "8" "ac_cv_c_uint8_t"
16421 case $ac_cv_c_uint8_t in #(
16422 no|yes) ;; #(
16758 ac_fn_c_check_type "$LINENO" "ptrdiff_t" "ac_cv_type_ptrdiff_t" "$ac_includes_default"
16759 if test "x$ac_cv_type_ptrdiff_t" = xyes; then :
16760
16761 cat >>confdefs.h <<_ACEOF
16762 #define HAVE_PTRDIFF_T 1
16763 _ACEOF
16764
16765
16766 fi
16767
16768 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5
16769 $as_echo_n "checking for inline... " >&6; }
16770 if ${ac_cv_c_inline+:} false; then :
16771 $as_echo_n "(cached) " >&6
16772 else
16773 ac_cv_c_inline=no
16774 for ac_kw in inline __inline__ __inline; do
16775 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
16776 /* end confdefs.h. */
16777 #ifndef __cplusplus
16778 typedef int foo_t;
16779 static $ac_kw foo_t static_foo () {return 0; }
16780 $ac_kw foo_t foo () {return 0; }
16781 #endif
16782
16783 _ACEOF
16784 if ac_fn_c_try_compile "$LINENO"; then :
16785 ac_cv_c_inline=$ac_kw
16786 fi
16787 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
16788 test "$ac_cv_c_inline" != no && break
16789 done
16790
16791 fi
16792 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5
16793 $as_echo "$ac_cv_c_inline" >&6; }
16794
16795 case $ac_cv_c_inline in
16796 inline | yes) ;;
1642316797 *)
16424
16425 $as_echo "#define _UINT8_T 1" >>confdefs.h
16426
16427
16428 cat >>confdefs.h <<_ACEOF
16429 #define uint8_t $ac_cv_c_uint8_t
16798 case $ac_cv_c_inline in
16799 no) ac_val=;;
16800 *) ac_val=$ac_cv_c_inline;;
16801 esac
16802 cat >>confdefs.h <<_ACEOF
16803 #ifndef __cplusplus
16804 #define inline $ac_val
16805 #endif
1643016806 _ACEOF
16431 ;;
16432 esac
16807 ;;
16808 esac
1643316809
1643416810
1643516811 # Checks for library functions.
1644516821 fi
1644616822 done
1644716823
16824
16825 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pow" >&5
16826 $as_echo_n "checking for library containing pow... " >&6; }
16827 if ${ac_cv_search_pow+:} false; then :
16828 $as_echo_n "(cached) " >&6
16829 else
16830 ac_func_search_save_LIBS=$LIBS
16831 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
16832 /* end confdefs.h. */
16833
16834 /* Override any GCC internal prototype to avoid an error.
16835 Use char because int might match the return type of a GCC
16836 builtin and then its argument prototype would still apply. */
16837 #ifdef __cplusplus
16838 extern "C"
16839 #endif
16840 char pow ();
16841 int
16842 main ()
16843 {
16844 return pow ();
16845 ;
16846 return 0;
16847 }
16848 _ACEOF
16849 for ac_lib in '' m; do
16850 if test -z "$ac_lib"; then
16851 ac_res="none required"
16852 else
16853 ac_res=-l$ac_lib
16854 LIBS="-l$ac_lib $ac_func_search_save_LIBS"
16855 fi
16856 if ac_fn_c_try_link "$LINENO"; then :
16857 ac_cv_search_pow=$ac_res
16858 fi
16859 rm -f core conftest.err conftest.$ac_objext \
16860 conftest$ac_exeext
16861 if ${ac_cv_search_pow+:} false; then :
16862 break
16863 fi
16864 done
16865 if ${ac_cv_search_pow+:} false; then :
16866
16867 else
16868 ac_cv_search_pow=no
16869 fi
16870 rm conftest.$ac_ext
16871 LIBS=$ac_func_search_save_LIBS
16872 fi
16873 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_pow" >&5
16874 $as_echo "$ac_cv_search_pow" >&6; }
16875 ac_res=$ac_cv_search_pow
16876 if test "$ac_res" != no; then :
16877 test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
16878
16879 fi
1644816880
1644916881 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing sqrt" >&5
1645016882 $as_echo_n "checking for library containing sqrt... " >&6; }
1655916991 fi
1656016992
1656116993
16994 for ac_func in gettimeofday
16995 do :
16996 ac_fn_c_check_func "$LINENO" "gettimeofday" "ac_cv_func_gettimeofday"
16997 if test "x$ac_cv_func_gettimeofday" = xyes; then :
16998 cat >>confdefs.h <<_ACEOF
16999 #define HAVE_GETTIMEOFDAY 1
17000 _ACEOF
17001
17002 fi
17003 done
17004
17005 for ac_func in pow sqrt
17006 do :
17007 as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
17008 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
17009 if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
17010 cat >>confdefs.h <<_ACEOF
17011 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
17012 _ACEOF
17013
17014 fi
17015 done
17016
17017 for ac_func in strchr strrchr
17018 do :
17019 as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
17020 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
17021 if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
17022 cat >>confdefs.h <<_ACEOF
17023 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
17024 _ACEOF
17025
17026 fi
17027 done
17028
17029
17030 # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
17031 # for constant arguments. Useless!
17032 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5
17033 $as_echo_n "checking for working alloca.h... " >&6; }
17034 if ${ac_cv_working_alloca_h+:} false; then :
17035 $as_echo_n "(cached) " >&6
17036 else
17037 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
17038 /* end confdefs.h. */
17039 #include <alloca.h>
17040 int
17041 main ()
17042 {
17043 char *p = (char *) alloca (2 * sizeof (int));
17044 if (p) return 0;
17045 ;
17046 return 0;
17047 }
17048 _ACEOF
17049 if ac_fn_c_try_link "$LINENO"; then :
17050 ac_cv_working_alloca_h=yes
17051 else
17052 ac_cv_working_alloca_h=no
17053 fi
17054 rm -f core conftest.err conftest.$ac_objext \
17055 conftest$ac_exeext conftest.$ac_ext
17056 fi
17057 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5
17058 $as_echo "$ac_cv_working_alloca_h" >&6; }
17059 if test $ac_cv_working_alloca_h = yes; then
17060
17061 $as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h
17062
17063 fi
17064
17065 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5
17066 $as_echo_n "checking for alloca... " >&6; }
17067 if ${ac_cv_func_alloca_works+:} false; then :
17068 $as_echo_n "(cached) " >&6
17069 else
17070 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
17071 /* end confdefs.h. */
17072 #ifdef __GNUC__
17073 # define alloca __builtin_alloca
17074 #else
17075 # ifdef _MSC_VER
17076 # include <malloc.h>
17077 # define alloca _alloca
17078 # else
17079 # ifdef HAVE_ALLOCA_H
17080 # include <alloca.h>
17081 # else
17082 # ifdef _AIX
17083 #pragma alloca
17084 # else
17085 # ifndef alloca /* predefined by HP cc +Olibcalls */
17086 void *alloca (size_t);
17087 # endif
17088 # endif
17089 # endif
17090 # endif
17091 #endif
17092
17093 int
17094 main ()
17095 {
17096 char *p = (char *) alloca (1);
17097 if (p) return 0;
17098 ;
17099 return 0;
17100 }
17101 _ACEOF
17102 if ac_fn_c_try_link "$LINENO"; then :
17103 ac_cv_func_alloca_works=yes
17104 else
17105 ac_cv_func_alloca_works=no
17106 fi
17107 rm -f core conftest.err conftest.$ac_objext \
17108 conftest$ac_exeext conftest.$ac_ext
17109 fi
17110 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5
17111 $as_echo "$ac_cv_func_alloca_works" >&6; }
17112
17113 if test $ac_cv_func_alloca_works = yes; then
17114
17115 $as_echo "#define HAVE_ALLOCA 1" >>confdefs.h
17116
17117 else
17118 # The SVR3 libPW and SVR4 libucb both contain incompatible functions
17119 # that cause trouble. Some versions do not even contain alloca or
17120 # contain a buggy version. If you still want to use their alloca,
17121 # use ar to extract alloca.o from them instead of compiling alloca.c.
17122
17123 ALLOCA=\${LIBOBJDIR}alloca.$ac_objext
17124
17125 $as_echo "#define C_ALLOCA 1" >>confdefs.h
17126
17127
17128 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5
17129 $as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; }
17130 if ${ac_cv_os_cray+:} false; then :
17131 $as_echo_n "(cached) " >&6
17132 else
17133 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
17134 /* end confdefs.h. */
17135 #if defined CRAY && ! defined CRAY2
17136 webecray
17137 #else
17138 wenotbecray
17139 #endif
17140
17141 _ACEOF
17142 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
17143 $EGREP "webecray" >/dev/null 2>&1; then :
17144 ac_cv_os_cray=yes
17145 else
17146 ac_cv_os_cray=no
17147 fi
17148 rm -f conftest*
17149
17150 fi
17151 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5
17152 $as_echo "$ac_cv_os_cray" >&6; }
17153 if test $ac_cv_os_cray = yes; then
17154 for ac_func in _getb67 GETB67 getb67; do
17155 as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
17156 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
17157 if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
17158
17159 cat >>confdefs.h <<_ACEOF
17160 #define CRAY_STACKSEG_END $ac_func
17161 _ACEOF
17162
17163 break
17164 fi
17165
17166 done
17167 fi
17168
17169 { $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5
17170 $as_echo_n "checking stack direction for C alloca... " >&6; }
17171 if ${ac_cv_c_stack_direction+:} false; then :
17172 $as_echo_n "(cached) " >&6
17173 else
17174 if test "$cross_compiling" = yes; then :
17175 ac_cv_c_stack_direction=0
17176 else
17177 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
17178 /* end confdefs.h. */
17179 $ac_includes_default
17180 int
17181 find_stack_direction (int *addr, int depth)
17182 {
17183 int dir, dummy = 0;
17184 if (! addr)
17185 addr = &dummy;
17186 *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1;
17187 dir = depth ? find_stack_direction (addr, depth - 1) : 0;
17188 return dir + dummy;
17189 }
17190
17191 int
17192 main (int argc, char **argv)
17193 {
17194 return find_stack_direction (0, argc + !argv + 20) < 0;
17195 }
17196 _ACEOF
17197 if ac_fn_c_try_run "$LINENO"; then :
17198 ac_cv_c_stack_direction=1
17199 else
17200 ac_cv_c_stack_direction=-1
17201 fi
17202 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
17203 conftest.$ac_objext conftest.beam conftest.$ac_ext
17204 fi
17205
17206 fi
17207 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5
17208 $as_echo "$ac_cv_c_stack_direction" >&6; }
17209 cat >>confdefs.h <<_ACEOF
17210 #define STACK_DIRECTION $ac_cv_c_stack_direction
17211 _ACEOF
17212
17213
17214 fi
17215
17216 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for error_at_line" >&5
17217 $as_echo_n "checking for error_at_line... " >&6; }
17218 if ${ac_cv_lib_error_at_line+:} false; then :
17219 $as_echo_n "(cached) " >&6
17220 else
17221 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
17222 /* end confdefs.h. */
17223 #include <error.h>
17224 int
17225 main ()
17226 {
17227 error_at_line (0, 0, "", 0, "an error occurred");
17228 ;
17229 return 0;
17230 }
17231 _ACEOF
17232 if ac_fn_c_try_link "$LINENO"; then :
17233 ac_cv_lib_error_at_line=yes
17234 else
17235 ac_cv_lib_error_at_line=no
17236 fi
17237 rm -f core conftest.err conftest.$ac_objext \
17238 conftest$ac_exeext conftest.$ac_ext
17239 fi
17240 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_error_at_line" >&5
17241 $as_echo "$ac_cv_lib_error_at_line" >&6; }
17242 if test $ac_cv_lib_error_at_line = no; then
17243 case " $LIBOBJS " in
17244 *" error.$ac_objext "* ) ;;
17245 *) LIBOBJS="$LIBOBJS error.$ac_objext"
17246 ;;
17247 esac
17248
17249 fi
17250
17251 # Checking for malloc breaks building on ARM for us. A similar issue is described
17252 # here: http://nerdland.net/unstumping-the-internet/malloc-has-not-been-declared/
17253 # AC_FUNC_MALLOC
17254 # AC_FUNC_REALLOC
17255 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5
17256 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; }
17257 if ${ac_cv_header_time+:} false; then :
17258 $as_echo_n "(cached) " >&6
17259 else
17260 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
17261 /* end confdefs.h. */
17262 #include <sys/types.h>
17263 #include <sys/time.h>
17264 #include <time.h>
17265
17266 int
17267 main ()
17268 {
17269 if ((struct tm *) 0)
17270 return 0;
17271 ;
17272 return 0;
17273 }
17274 _ACEOF
17275 if ac_fn_c_try_compile "$LINENO"; then :
17276 ac_cv_header_time=yes
17277 else
17278 ac_cv_header_time=no
17279 fi
17280 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
17281 fi
17282 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5
17283 $as_echo "$ac_cv_header_time" >&6; }
17284 if test $ac_cv_header_time = yes; then
17285
17286 $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h
17287
17288 fi
17289
17290
17291
17292
17293 for ac_header in $ac_header_list
17294 do :
17295 as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
17296 ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
17297 "
17298 if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
17299 cat >>confdefs.h <<_ACEOF
17300 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
17301 _ACEOF
17302
17303 fi
17304
17305 done
17306
17307
17308
17309
17310
17311
17312
17313
17314 for ac_func in $ac_func_list
17315 do :
17316 as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
17317 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
17318 if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
17319 cat >>confdefs.h <<_ACEOF
17320 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
17321 _ACEOF
17322
17323 fi
17324 done
17325
17326
17327
17328
17329
17330 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working mktime" >&5
17331 $as_echo_n "checking for working mktime... " >&6; }
17332 if ${ac_cv_func_working_mktime+:} false; then :
17333 $as_echo_n "(cached) " >&6
17334 else
17335 if test "$cross_compiling" = yes; then :
17336 ac_cv_func_working_mktime=no
17337 else
17338 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
17339 /* end confdefs.h. */
17340 /* Test program from Paul Eggert and Tony Leneis. */
17341 #ifdef TIME_WITH_SYS_TIME
17342 # include <sys/time.h>
17343 # include <time.h>
17344 #else
17345 # ifdef HAVE_SYS_TIME_H
17346 # include <sys/time.h>
17347 # else
17348 # include <time.h>
17349 # endif
17350 #endif
17351
17352 #include <limits.h>
17353 #include <stdlib.h>
17354
17355 #ifdef HAVE_UNISTD_H
17356 # include <unistd.h>
17357 #endif
17358
17359 #ifndef HAVE_ALARM
17360 # define alarm(X) /* empty */
17361 #endif
17362
17363 /* Work around redefinition to rpl_putenv by other config tests. */
17364 #undef putenv
17365
17366 static time_t time_t_max;
17367 static time_t time_t_min;
17368
17369 /* Values we'll use to set the TZ environment variable. */
17370 static const char *tz_strings[] = {
17371 (const char *) 0, "TZ=GMT0", "TZ=JST-9",
17372 "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
17373 };
17374 #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
17375
17376 /* Return 0 if mktime fails to convert a date in the spring-forward gap.
17377 Based on a problem report from Andreas Jaeger. */
17378 static int
17379 spring_forward_gap ()
17380 {
17381 /* glibc (up to about 1998-10-07) failed this test. */
17382 struct tm tm;
17383
17384 /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
17385 instead of "TZ=America/Vancouver" in order to detect the bug even
17386 on systems that don't support the Olson extension, or don't have the
17387 full zoneinfo tables installed. */
17388 putenv ((char*) "TZ=PST8PDT,M4.1.0,M10.5.0");
17389
17390 tm.tm_year = 98;
17391 tm.tm_mon = 3;
17392 tm.tm_mday = 5;
17393 tm.tm_hour = 2;
17394 tm.tm_min = 0;
17395 tm.tm_sec = 0;
17396 tm.tm_isdst = -1;
17397 return mktime (&tm) != (time_t) -1;
17398 }
17399
17400 static int
17401 mktime_test1 (time_t now)
17402 {
17403 struct tm *lt;
17404 return ! (lt = localtime (&now)) || mktime (lt) == now;
17405 }
17406
17407 static int
17408 mktime_test (time_t now)
17409 {
17410 return (mktime_test1 (now)
17411 && mktime_test1 ((time_t) (time_t_max - now))
17412 && mktime_test1 ((time_t) (time_t_min + now)));
17413 }
17414
17415 static int
17416 irix_6_4_bug ()
17417 {
17418 /* Based on code from Ariel Faigon. */
17419 struct tm tm;
17420 tm.tm_year = 96;
17421 tm.tm_mon = 3;
17422 tm.tm_mday = 0;
17423 tm.tm_hour = 0;
17424 tm.tm_min = 0;
17425 tm.tm_sec = 0;
17426 tm.tm_isdst = -1;
17427 mktime (&tm);
17428 return tm.tm_mon == 2 && tm.tm_mday == 31;
17429 }
17430
17431 static int
17432 bigtime_test (int j)
17433 {
17434 struct tm tm;
17435 time_t now;
17436 tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j;
17437 now = mktime (&tm);
17438 if (now != (time_t) -1)
17439 {
17440 struct tm *lt = localtime (&now);
17441 if (! (lt
17442 && lt->tm_year == tm.tm_year
17443 && lt->tm_mon == tm.tm_mon
17444 && lt->tm_mday == tm.tm_mday
17445 && lt->tm_hour == tm.tm_hour
17446 && lt->tm_min == tm.tm_min
17447 && lt->tm_sec == tm.tm_sec
17448 && lt->tm_yday == tm.tm_yday
17449 && lt->tm_wday == tm.tm_wday
17450 && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
17451 == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
17452 return 0;
17453 }
17454 return 1;
17455 }
17456
17457 static int
17458 year_2050_test ()
17459 {
17460 /* The correct answer for 2050-02-01 00:00:00 in Pacific time,
17461 ignoring leap seconds. */
17462 unsigned long int answer = 2527315200UL;
17463
17464 struct tm tm;
17465 time_t t;
17466 tm.tm_year = 2050 - 1900;
17467 tm.tm_mon = 2 - 1;
17468 tm.tm_mday = 1;
17469 tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
17470 tm.tm_isdst = -1;
17471
17472 /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
17473 instead of "TZ=America/Vancouver" in order to detect the bug even
17474 on systems that don't support the Olson extension, or don't have the
17475 full zoneinfo tables installed. */
17476 putenv ((char*) "TZ=PST8PDT,M4.1.0,M10.5.0");
17477
17478 t = mktime (&tm);
17479
17480 /* Check that the result is either a failure, or close enough
17481 to the correct answer that we can assume the discrepancy is
17482 due to leap seconds. */
17483 return (t == (time_t) -1
17484 || (0 < t && answer - 120 <= t && t <= answer + 120));
17485 }
17486
17487 int
17488 main ()
17489 {
17490 time_t t, delta;
17491 int i, j;
17492
17493 /* This test makes some buggy mktime implementations loop.
17494 Give up after 60 seconds; a mktime slower than that
17495 isn't worth using anyway. */
17496 alarm (60);
17497
17498 for (;;)
17499 {
17500 t = (time_t_max << 1) + 1;
17501 if (t <= time_t_max)
17502 break;
17503 time_t_max = t;
17504 }
17505 time_t_min = - ((time_t) ~ (time_t) 0 == (time_t) -1) - time_t_max;
17506
17507 delta = time_t_max / 997; /* a suitable prime number */
17508 for (i = 0; i < N_STRINGS; i++)
17509 {
17510 if (tz_strings[i])
17511 putenv ((char*) tz_strings[i]);
17512
17513 for (t = 0; t <= time_t_max - delta; t += delta)
17514 if (! mktime_test (t))
17515 return 1;
17516 if (! (mktime_test ((time_t) 1)
17517 && mktime_test ((time_t) (60 * 60))
17518 && mktime_test ((time_t) (60 * 60 * 24))))
17519 return 1;
17520
17521 for (j = 1; ; j <<= 1)
17522 if (! bigtime_test (j))
17523 return 1;
17524 else if (INT_MAX / 2 < j)
17525 break;
17526 if (! bigtime_test (INT_MAX))
17527 return 1;
17528 }
17529 return ! (irix_6_4_bug () && spring_forward_gap () && year_2050_test ());
17530 }
17531 _ACEOF
17532 if ac_fn_c_try_run "$LINENO"; then :
17533 ac_cv_func_working_mktime=yes
17534 else
17535 ac_cv_func_working_mktime=no
17536 fi
17537 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
17538 conftest.$ac_objext conftest.beam conftest.$ac_ext
17539 fi
17540
17541 fi
17542 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_working_mktime" >&5
17543 $as_echo "$ac_cv_func_working_mktime" >&6; }
17544 if test $ac_cv_func_working_mktime = no; then
17545 case " $LIBOBJS " in
17546 *" mktime.$ac_objext "* ) ;;
17547 *) LIBOBJS="$LIBOBJS mktime.$ac_objext"
17548 ;;
17549 esac
17550
17551 fi
17552
17553
1656217554 if expr $host : '.*-mingw' >/dev/null 2>&1; then
1656317555 MINGW_TRUE=
1656417556 MINGW_FALSE='#'
1656817560 fi
1656917561
1657017562
17563 # Check if "__STRICT_ANSI__" is required.
17564 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if __STRICT_ANSI__ is required" >&5
17565 $as_echo_n "checking if __STRICT_ANSI__ is required... " >&6; }
17566 ac_ext=cpp
17567 ac_cpp='$CXXCPP $CPPFLAGS'
17568 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
17569 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
17570 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
17571
17572 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
17573 /* end confdefs.h. */
17574
17575 #include <vector>
17576
17577 int
17578 main ()
17579 {
17580
17581 ;
17582 return 0;
17583 }
17584 _ACEOF
17585 if ac_fn_cxx_try_compile "$LINENO"; then :
17586 need_strict_ansi=no
17587 else
17588 need_strict_ansi=yes
17589 fi
17590 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext;
17591 ac_ext=c
17592 ac_cpp='$CPP $CPPFLAGS'
17593 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
17594 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
17595 ac_compiler_gnu=$ac_cv_c_compiler_gnu
17596
17597 if eval "test x$need_strict_ansi = xyes"; then
17598 CFLAGS+=" -D__STRICT_ANSI__"
17599 CXXFLAGS+=" -D__STRICT_ANSI__"
17600 fi
17601 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $need_strict_ansi" >&5
17602 $as_echo "$need_strict_ansi" >&6; }
1657117603
1657217604 # --- machine dependent optimizations ---
1657317605
1664717679
1664817680 # CFLAGS+=$SIMD_FLAGS
1664917681 # CFLAGS+=" -march=x86-64"
17682
17683 case $target_cpu in
17684 arm*)
17685 # Check whether --enable-arm was given.
17686 if test "${enable_arm+set}" = set; then :
17687 enableval=$enable_arm; disable_arm=yes
17688 else
17689 disable_arm=no
17690 fi
17691
17692
17693 if test x"$disable_arm" != x"yes"; then
17694
17695 $as_echo "#define HAVE_ARM 1" >>confdefs.h
17696
17697
17698 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -mfpu=neon" >&5
17699 $as_echo_n "checking whether C compiler accepts -mfpu=neon... " >&6; }
17700 if ${ax_cv_check_cflags___mfpu_neon+:} false; then :
17701 $as_echo_n "(cached) " >&6
17702 else
17703
17704 ax_check_save_flags=$CFLAGS
17705 CFLAGS="$CFLAGS -mfpu=neon"
17706 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
17707 /* end confdefs.h. */
17708
17709 int
17710 main ()
17711 {
17712
17713 ;
17714 return 0;
17715 }
17716 _ACEOF
17717 if ac_fn_c_try_compile "$LINENO"; then :
17718 ax_cv_check_cflags___mfpu_neon=yes
17719 else
17720 ax_cv_check_cflags___mfpu_neon=no
17721 fi
17722 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
17723 CFLAGS=$ax_check_save_flags
17724 fi
17725 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___mfpu_neon" >&5
17726 $as_echo "$ax_cv_check_cflags___mfpu_neon" >&6; }
17727 if test x"$ax_cv_check_cflags___mfpu_neon" = xyes; then :
17728
17729
17730 $as_echo "#define HAVE_NEON 1" >>confdefs.h
17731
17732 ax_cv_support_neon_ext=yes
17733 else
17734 :
17735 fi
17736
17737
17738 # Check whether --enable-thumb was given.
17739 if test "${enable_thumb+set}" = set; then :
17740 enableval=$enable_thumb; enable_thumb=yes
17741 else
17742 enable_thumb=no
17743 fi
17744
17745 fi
17746 ;;
17747
17748 *)
17749 disable_arm=yes
17750 ;;
17751
17752 esac
17753
17754 if test x"$disable_arm" != x"yes"; then
17755 ENABLE_ARM_OPT_TRUE=
17756 ENABLE_ARM_OPT_FALSE='#'
17757 else
17758 ENABLE_ARM_OPT_TRUE='#'
17759 ENABLE_ARM_OPT_FALSE=
17760 fi
17761
17762 if test x"$ax_cv_support_neon_ext" = x"yes"; then
17763 ENABLE_NEON_OPT_TRUE=
17764 ENABLE_NEON_OPT_FALSE='#'
17765 else
17766 ENABLE_NEON_OPT_TRUE='#'
17767 ENABLE_NEON_OPT_FALSE=
17768 fi
17769
17770 if test x"$enable_thumb" != x"no"; then
17771 ENABLE_ARM_THUMB_TRUE=
17772 ENABLE_ARM_THUMB_FALSE='#'
17773 else
17774 ENABLE_ARM_THUMB_TRUE='#'
17775 ENABLE_ARM_THUMB_FALSE=
17776 fi
1665017777
1665117778
1665217779 # --- additional logging ---
1744918576
1745018577 ac_config_files="$ac_config_files libde265/Makefile"
1745118578
18579 ac_config_files="$ac_config_files libde265/arm/Makefile"
18580
1745218581 ac_config_files="$ac_config_files libde265/x86/Makefile"
1745318582
18583 ac_config_files="$ac_config_files libde265/encoder/Makefile"
18584
18585 ac_config_files="$ac_config_files libde265/encoder/algo/Makefile"
18586
1745418587 ac_config_files="$ac_config_files libde265/de265-version.h"
1745518588
1745618589 ac_config_files="$ac_config_files dec265/Makefile"
1745718590
18591 ac_config_files="$ac_config_files enc265/Makefile"
18592
1745818593 ac_config_files="$ac_config_files sherlock265/Makefile"
18594
18595 ac_config_files="$ac_config_files tools/Makefile"
1745918596
1746018597 ac_config_files="$ac_config_files libde265.pc"
1746118598
1756818705 LTLIBOBJS=$ac_ltlibobjs
1756918706
1757018707
18708 if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
18709 as_fn_error $? "conditional \"AMDEP\" was never defined.
18710 Usually this means the macro was only invoked conditionally." "$LINENO" 5
18711 fi
18712 if test -z "${am__fastdepCCAS_TRUE}" && test -z "${am__fastdepCCAS_FALSE}"; then
18713 as_fn_error $? "conditional \"am__fastdepCCAS\" was never defined.
18714 Usually this means the macro was only invoked conditionally." "$LINENO" 5
18715 fi
1757118716 { $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5
1757218717 $as_echo_n "checking that generated files are newer than configure... " >&6; }
1757318718 if test -n "$am_sleep_pid"; then
1757618721 fi
1757718722 { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5
1757818723 $as_echo "done" >&6; }
17579 if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
17580 as_fn_error $? "conditional \"AMDEP\" was never defined.
17581 Usually this means the macro was only invoked conditionally." "$LINENO" 5
17582 fi
1758318724 if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
1758418725 as_fn_error $? "conditional \"am__fastdepCC\" was never defined.
1758518726 Usually this means the macro was only invoked conditionally." "$LINENO" 5
1760618747 fi
1760718748 if test -z "${ENABLE_SSE_OPT_TRUE}" && test -z "${ENABLE_SSE_OPT_FALSE}"; then
1760818749 as_fn_error $? "conditional \"ENABLE_SSE_OPT\" was never defined.
18750 Usually this means the macro was only invoked conditionally." "$LINENO" 5
18751 fi
18752 if test -z "${ENABLE_ARM_OPT_TRUE}" && test -z "${ENABLE_ARM_OPT_FALSE}"; then
18753 as_fn_error $? "conditional \"ENABLE_ARM_OPT\" was never defined.
18754 Usually this means the macro was only invoked conditionally." "$LINENO" 5
18755 fi
18756 if test -z "${ENABLE_NEON_OPT_TRUE}" && test -z "${ENABLE_NEON_OPT_FALSE}"; then
18757 as_fn_error $? "conditional \"ENABLE_NEON_OPT\" was never defined.
18758 Usually this means the macro was only invoked conditionally." "$LINENO" 5
18759 fi
18760 if test -z "${ENABLE_ARM_THUMB_TRUE}" && test -z "${ENABLE_ARM_THUMB_FALSE}"; then
18761 as_fn_error $? "conditional \"ENABLE_ARM_THUMB\" was never defined.
1760918762 Usually this means the macro was only invoked conditionally." "$LINENO" 5
1761018763 fi
1761118764 if test -z "${HAVE_VIDEOGFX_TRUE}" && test -z "${HAVE_VIDEOGFX_FALSE}"; then
1802519178 # report actual input values of CONFIG_FILES etc. instead of their
1802619179 # values after options handling.
1802719180 ac_log="
18028 This file was extended by libde265 $as_me 0.9, which was
19181 This file was extended by libde265 $as_me 1.0.2, which was
1802919182 generated by GNU Autoconf 2.69. Invocation command line was
1803019183
1803119184 CONFIG_FILES = $CONFIG_FILES
1809119244 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
1809219245 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
1809319246 ac_cs_version="\\
18094 libde265 config.status 0.9
19247 libde265 config.status 1.0.2
1809519248 configured by $0, generated by GNU Autoconf 2.69,
1809619249 with options \\"\$ac_cs_config\\"
1809719250
1860019753 "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
1860119754 "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
1860219755 "libde265/Makefile") CONFIG_FILES="$CONFIG_FILES libde265/Makefile" ;;
19756 "libde265/arm/Makefile") CONFIG_FILES="$CONFIG_FILES libde265/arm/Makefile" ;;
1860319757 "libde265/x86/Makefile") CONFIG_FILES="$CONFIG_FILES libde265/x86/Makefile" ;;
19758 "libde265/encoder/Makefile") CONFIG_FILES="$CONFIG_FILES libde265/encoder/Makefile" ;;
19759 "libde265/encoder/algo/Makefile") CONFIG_FILES="$CONFIG_FILES libde265/encoder/algo/Makefile" ;;
1860419760 "libde265/de265-version.h") CONFIG_FILES="$CONFIG_FILES libde265/de265-version.h" ;;
1860519761 "dec265/Makefile") CONFIG_FILES="$CONFIG_FILES dec265/Makefile" ;;
19762 "enc265/Makefile") CONFIG_FILES="$CONFIG_FILES enc265/Makefile" ;;
1860619763 "sherlock265/Makefile") CONFIG_FILES="$CONFIG_FILES sherlock265/Makefile" ;;
19764 "tools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/Makefile" ;;
1860719765 "libde265.pc") CONFIG_FILES="$CONFIG_FILES libde265.pc" ;;
1860819766
1860919767 *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
11 # Process this file with autoconf to produce a configure script.
22
33 AC_PREREQ([2.68])
4 AC_INIT([libde265], [0.9], [farin@struktur.de])
4 AC_INIT([libde265], [1.0.2], [farin@struktur.de])
55 AC_CONFIG_SRCDIR([libde265/de265.cc])
66 AC_CONFIG_HEADERS([config.h])
77
8 NUMERIC_VERSION=0x00090000 # Numeric representation of the version
8 NUMERIC_VERSION=0x01000200 # Numeric representation of the version (A.B.C[.D] = 0xAABBCCDD)
99 AC_SUBST(NUMERIC_VERSION)
1010
1111 LIBDE265_CURRENT=0
12 LIBDE265_REVISION=8
12 LIBDE265_REVISION=10
1313 LIBDE265_AGE=0
1414
1515 # ---------------------------------------------------------------------------
2525 AC_CONFIG_MACRO_DIR([m4])
2626
2727 # Checks for programs.
28 AM_PROG_AS
2829 AC_PROG_CXX
2930 AC_PROG_CC
3031 AC_PROG_INSTALL
3536 AM_INIT_AUTOMAKE
3637
3738 CFLAGS+=" -std=c99"
39 CXXFLAGS+=" -Werror=return-type -Werror=unused-result -Werror=reorder"
40 AX_CXX_COMPILE_STDCXX_11()
3841
3942 dnl Use -Wall if we have gcc.
4043 changequote(,)dnl
4649 fi
4750 changequote([,])dnl
4851
49 gl_VISIBILITY
52 dnl gl_VISIBILITY
53 dnl : In encoder branch, we still export all library symbols :
54 HAVE_VISIBILITY=0
5055 AM_CONDITIONAL([HAVE_VISIBILITY], [test "x$HAVE_VISIBILITY" != "x0"])
5156
5257 # Checks for header files.
53 AC_CHECK_HEADERS([stdint.h stdlib.h string.h malloc.h])
58 AC_CHECK_HEADERS([stdint.h stdlib.h string.h malloc.h signal.h setjmp.h stddef.h sys/time.h])
5459
5560 # Checks for typedefs, structures, and compiler characteristics.
5661 AC_HEADER_STDBOOL
62 AC_TYPE_SIZE_T
63 AC_TYPE_INT8_T
5764 AC_TYPE_INT16_T
5865 AC_TYPE_INT32_T
59 AC_TYPE_INT8_T
66 AC_TYPE_INT64_T
67 AC_TYPE_UINT8_T
6068 AC_TYPE_UINT16_T
6169 AC_TYPE_UINT32_T
6270 AC_TYPE_UINT64_T
63 AC_TYPE_UINT8_T
71 AC_CHECK_TYPES([ptrdiff_t])
72 AC_C_INLINE
6473
6574 # Checks for library functions.
6675 AC_CHECK_FUNCS([malloc memmove memset __malloc_hook memalign posix_memalign __mingw_aligned_malloc __mingw_aligned_free])
6776
77 AC_SEARCH_LIBS([pow], [m])
6878 AC_SEARCH_LIBS([sqrt], [m])
6979 AC_SEARCH_LIBS([pthread_create], [pthread])
7080
81 AC_CHECK_FUNCS([gettimeofday])
82 AC_CHECK_FUNCS([pow sqrt])
83 AC_CHECK_FUNCS([strchr strrchr])
84
85 AC_FUNC_ALLOCA
86 AC_FUNC_ERROR_AT_LINE
87 # Checking for malloc breaks building on ARM for us. A similar issue is described
88 # here: http://nerdland.net/unstumping-the-internet/malloc-has-not-been-declared/
89 # AC_FUNC_MALLOC
90 # AC_FUNC_REALLOC
91 AC_FUNC_MKTIME
92
7193 AM_CONDITIONAL(MINGW, expr $host : '.*-mingw' >/dev/null 2>&1)
7294
95 # Check if "__STRICT_ANSI__" is required.
96 AC_MSG_CHECKING([if __STRICT_ANSI__ is required])
97 AC_LANG_PUSH(C++)
98 AC_TRY_COMPILE([
99 #include <vector>
100 ],[],[need_strict_ansi=no],[need_strict_ansi=yes]);
101 AC_LANG_POP(C++)
102 if eval "test x$need_strict_ansi = xyes"; then
103 CFLAGS+=" -D__STRICT_ANSI__"
104 CXXFLAGS+=" -D__STRICT_ANSI__"
105 fi
106 AC_MSG_RESULT([$need_strict_ansi])
73107
74108 # --- machine dependent optimizations ---
75109
104138 # CFLAGS+=$SIMD_FLAGS
105139 # CFLAGS+=" -march=x86-64"
106140
141 case $target_cpu in
142 arm*)
143 AC_ARG_ENABLE(arm,
144 [AS_HELP_STRING([--disable-arm],
145 [disable ARM optimizations (default=no)])],
146 [disable_arm=yes],
147 [disable_arm=no])
148
149 if test x"$disable_arm" != x"yes"; then
150 AC_DEFINE(HAVE_ARM, 1, [Support ARM instructions])
151
152 AX_CHECK_COMPILE_FLAG(-mfpu=neon, [
153 AC_DEFINE(HAVE_NEON, 1, [Support ARM NEON instructions])
154 ax_cv_support_neon_ext=yes], [])
155
156 AC_ARG_ENABLE(thumb,
157 [AS_HELP_STRING([--enable-thumb],
158 [disable ARM THUMB instructions (default=no)])],
159 [enable_thumb=yes],
160 [enable_thumb=no])
161 fi
162 ;;
163
164 *)
165 disable_arm=yes
166 ;;
167
168 esac
169
170 AM_CONDITIONAL([ENABLE_ARM_OPT], [test x"$disable_arm" != x"yes"])
171 AM_CONDITIONAL([ENABLE_NEON_OPT], [test x"$ax_cv_support_neon_ext" = x"yes"])
172 AM_CONDITIONAL([ENABLE_ARM_THUMB], [test x"$enable_thumb" != x"no"])
107173
108174 # --- additional logging ---
109175
230296
231297 AC_CONFIG_FILES([Makefile])
232298 AC_CONFIG_FILES([libde265/Makefile])
299 AC_CONFIG_FILES([libde265/arm/Makefile])
233300 AC_CONFIG_FILES([libde265/x86/Makefile])
301 AC_CONFIG_FILES([libde265/encoder/Makefile])
302 AC_CONFIG_FILES([libde265/encoder/algo/Makefile])
234303 AC_CONFIG_FILES([libde265/de265-version.h])
235304 AC_CONFIG_FILES([dec265/Makefile])
305 AC_CONFIG_FILES([enc265/Makefile])
236306 AC_CONFIG_FILES([sherlock265/Makefile])
307 AC_CONFIG_FILES([tools/Makefile])
237308 AC_CONFIG_FILES([libde265.pc])
238309 AC_OUTPUT
0 set(CMAKE_CONFIGURATION_TYPES "Debug;Release;RelWithDebInfo" CACHE STRING "Configurations" FORCE)
0 set (dec265_sources
1 dec265.cc
2 )
13
2 if(NOT CMAKE_BUILD_TYPE)
3 # default to Release build for GCC builds
4 set(CMAKE_BUILD_TYPE Release CACHE STRING
5 "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release."
6 FORCE)
4 set (hdrcopy_sources
5 hdrcopy.cc
6 )
7
8 if(MSVC)
9 set (dec265_sources
10 ${dec265_sources}
11 ../extra/getopt.c
12 ../extra/getopt_long.c
13 )
14 set (hdrcopy_sources
15 ${hdrcopy_sources}
16 ../extra/getopt.c
17 ../extra/getopt_long.c
18 )
719 endif()
820
9 project (dec265)
10 cmake_minimum_required (VERSION 2.8)
11
12 SET(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/../cmake" "${CMAKE_MODULE_PATH}")
13
14 if ("${CMAKE_SIZEOF_VOID_P}" MATCHES 8)
15 set(X64 1)
16 add_definitions(-DX86_64)
21 if(SDL_FOUND)
22 add_definitions(-DHAVE_SDL)
23 include_directories ("${SDL_INCLUDE_DIR}")
24 set (dec265_sources
25 ${dec265_sources}
26 sdl.cc
27 )
1728 endif()
1829
19 # Enforce coding standards. Full warnings and warnings as errors
20 if(MSVC)
21 add_definitions(/W4 /D_CRT_SECURE_NO_WARNINGS)
22 add_definitions(/Ob2) # always inline
23 add_definitions(/Oi) # enable intrinsics
24 # add_definitions(/MP) # multithreaded build
25 # add_definitions(/TP) # all files as cpp
30 add_executable (dec265 ${dec265_sources})
2631
27 include_directories(../extra)
28 endif(MSVC)
32 target_link_libraries (dec265 ${LIBDE265_LIBRARY_NAME} ${SDL_LIBRARY})
2933
30 if("$ENV{CXX}" STREQUAL "icpc")
31 set(GCC 1)
32 add_definitions(-Wall -Wextra -Wunused-variable -Wunused-function -Wshadow -no-vec -msse4)
33 elseif(CMAKE_COMPILER_IS_GNUCXX)
34 set(GCC 1)
35 add_definitions(-Wall -Wextra -Wunused-variable -Wunused-function -Wshadow -msse4)
34
35 if(NOT MSVC)
36 # hdrcopy uses internal APIs that are not available when compiled for Windows
37 add_executable (hdrcopy ${hdrcopy_sources})
38
39 target_link_libraries (hdrcopy ${LIBDE265_LIBRARY_NAME})
3640 endif()
37
38 option(USE_ASM "Use SSE41 SIMD optimize" ON)
39 if(USE_ASM)
40 add_definitions(-DUSE_ASM=ASM_SSE4)
41 add_definitions(-DHAVE_SSE4_1)
42 else(USE_ASM)
43 add_definitions(-DUSE_ASM=ASM_NONE)
44 endif(USE_ASM)
45
46 option(USE_VIDEOGFX "Use of VIDEOGFX" OFF)
47 if(USE_VIDEOGFX)
48 add_definitions(-D HAVE_VIDEOGFX=1)
49 else(USE_VIDEOGFX)
50 add_definitions(-D HAVE_VIDEOGFX=0)
51 endif(USE_VIDEOGFX)
52
53 option(BUILD_STATIC "Static Lib" ON)
54 if(BUILD_STATIC)
55 add_definitions(-DLIBDE265_STATIC_BUILD)
56 endif(BUILD_STATIC)
57
58 option(DE265_LOG_ERROR "Enable DE265_LOG_ERROR" OFF)
59 if(DE265_LOG_ERROR)
60 add_definitions(-DDE265_LOG_ERROR)
61 endif(DE265_LOG_ERROR)
62
63 option(DE265_LOG_INFO "Enable DE265_LOG_INFO" OFF)
64 if(DE265_LOG_INFO)
65 add_definitions(-DDE265_LOG_INFO)
66 endif(DE265_LOG_INFO)
67
68 option(DE265_LOG_DEBUG "Enable DE265_LOG_DEBUG" OFF)
69 if(DE265_LOG_DEBUG)
70 add_definitions(-DDE265_LOG_DEBUG)
71 endif(DE265_LOG_DEBUG)
72
73 option(DE265_LOG_TRACE "Enable DE265_LOG_TRACE" OFF)
74 if(DE265_LOG_TRACE)
75 add_definitions(-DDE265_LOG_TRACE)
76 endif(DE265_LOG_TRACE)
77
78 include_directories(../ ../libde265)
79
80 file(GLOB LIBSRC ../libde265/*.cc ../extra/*.c)
81 file(GLOB LIBINC ../libde265/*.h ../extra/*.h)
82 file(GLOB APPSRC dec265.cc)
83 file(GLOB ASMSRC0 ../libde265/x86/sse.cc ../libde265/x86/sse-dct.cc)
84 file(GLOB ASMSRC1 ../libde265/x86/sse-motion.cc)
85 file(GLOB ASMINC ../libde265/x86/*.h)
86
87 source_group(INC FILES ${LIBINC})
88 source_group(SRC FILES ${LIBSRC})
89 source_group(APP FILES ${APPSRC})
90 source_group(ASM FILES ${ASMSRC0} ${ASMSRC1} ${ASMINC})
91
92 if(USE_ASM)
93 SET(LIBSRC ${LIBSRC} ${ASMSRC0} ${ASMSRC1})
94 SET(LIBINC ${LIBINC} ${ASMINC})
95
96 # disable uninitialize check on VC, because x1 is not assign, remove later
97 #if(MSVC)
98 # SET_SOURCE_FILES_PROPERTIES(${ASMSRC1} PROPERTIES COMPILE_FLAGS "/RTCs")
99 #endif(MSVC)
100 endif(USE_ASM)
101
102 if(UNIX)
103 SET(PLATFORM_LIBS pthread rt m)
104 SET_SOURCE_FILES_PROPERTIES(../extra/win32thread.c PROPERTIES HEADER_FILE_ONLY TRUE)
105 endif(UNIX)
106
107 # Main CLI application
108 if(MSVC)
109 add_definitions(/wd4244) # type conversion, possible loss of data
110 add_definitions(/wd4100) # unreferenced formal parameter
111 add_definitions(/wd4505) # unreferenced local function has been removed
112 add_definitions(/wd4701) # potentially uninitialized local variable
113 add_definitions(/wd4127) # conditional expression is constant
114 # add_definitions(/wd4018) # signed/unsigned mismatch
115 add_definitions(/wd4189) # local variable is initialized but not referenced
116 add_definitions(/wd4715) # not all control paths return a value
117 add_definitions(/wd4324) # structure was padded due to __declspec(align())
118
119 set_source_files_properties(${LIBSRC} PROPERTIES LANGUAGE CXX)
120 endif(MSVC)
121 if(GCC)
122 add_definitions(-Wno-sign-compare)
123 add_definitions(-Wno-unused-parameter)
124 endif(GCC)
125
126 add_executable(dec265
127 ${APPSRC} ${EXTRAS} ${LIBSRC} ${LIBINC}
128 )
129
130 target_link_libraries(dec265 ${PLATFORM_LIBS})
131
00
1 bin_PROGRAMS = dec265
1 bin_PROGRAMS = dec265 hdrcopy
22
33 AM_CPPFLAGS = -I../libde265
44
77 dec265_LDFLAGS =
88 dec265_LDADD = ../libde265/libde265.la -lstdc++
99 dec265_SOURCES = dec265.cc
10
11 hdrcopy_DEPENDENCIES = ../libde265/libde265.la
12 hdrcopy_CXXFLAGS =
13 hdrcopy_LDFLAGS =
14 hdrcopy_LDADD = ../libde265/libde265.la -lstdc++
15 hdrcopy_SOURCES = hdrcopy.cc
1016
1117 if HAVE_VIDEOGFX
1218 dec265_CXXFLAGS += $(VIDEOGFX_CFLAGS)
7878 build_triplet = @build@
7979 host_triplet = @host@
8080 target_triplet = @target@
81 bin_PROGRAMS = dec265$(EXEEXT)
81 bin_PROGRAMS = dec265$(EXEEXT) hdrcopy$(EXEEXT)
8282 @HAVE_VIDEOGFX_TRUE@am__append_1 = $(VIDEOGFX_CFLAGS)
8383 @HAVE_VIDEOGFX_TRUE@am__append_2 = $(VIDEOGFX_LIBS)
8484 @HAVE_SDL_TRUE@am__append_3 = $(SDL_CFLAGS)
9090 $(top_srcdir)/depcomp COPYING
9191 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
9292 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
93 $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \
9394 $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
9495 $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
9596 $(top_srcdir)/m4/lt~obsolete.m4 \
9697 $(top_srcdir)/m4/m4_ax_check_compile_flag.m4 \
97 $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/configure.ac
98 $(top_srcdir)/configure.ac
9899 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
99100 $(ACLOCAL_M4)
100101 mkinstalldirs = $(install_sh) -d
114115 dec265_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
115116 $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(dec265_CXXFLAGS) \
116117 $(CXXFLAGS) $(dec265_LDFLAGS) $(LDFLAGS) -o $@
118 am_hdrcopy_OBJECTS = hdrcopy-hdrcopy.$(OBJEXT)
119 hdrcopy_OBJECTS = $(am_hdrcopy_OBJECTS)
120 hdrcopy_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
121 $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(hdrcopy_CXXFLAGS) \
122 $(CXXFLAGS) $(hdrcopy_LDFLAGS) $(LDFLAGS) -o $@
117123 AM_V_P = $(am__v_P_@AM_V@)
118124 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
119125 am__v_P_0 = false
166172 am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
167173 am__v_CCLD_0 = @echo " CCLD " $@;
168174 am__v_CCLD_1 =
169 SOURCES = $(dec265_SOURCES)
170 DIST_SOURCES = $(am__dec265_SOURCES_DIST)
175 SOURCES = $(dec265_SOURCES) $(hdrcopy_SOURCES)
176 DIST_SOURCES = $(am__dec265_SOURCES_DIST) $(hdrcopy_SOURCES)
171177 am__can_run_installinfo = \
172178 case $$AM_UPDATE_INFO_DIR in \
173179 n|no|NO) false;; \
194200 CTAGS = ctags
195201 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
196202 ACLOCAL = @ACLOCAL@
203 ALLOCA = @ALLOCA@
197204 AMTAR = @AMTAR@
198205 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
199206 AR = @AR@
202209 AUTOMAKE = @AUTOMAKE@
203210 AWK = @AWK@
204211 CC = @CC@
212 CCAS = @CCAS@
213 CCASDEPMODE = @CCASDEPMODE@
214 CCASFLAGS = @CCASFLAGS@
205215 CCDEPMODE = @CCDEPMODE@
206216 CFLAGS = @CFLAGS@
207 CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
208217 CPP = @CPP@
209218 CPPFLAGS = @CPPFLAGS@
210219 CXX = @CXX@
224233 EXEEXT = @EXEEXT@
225234 FGREP = @FGREP@
226235 GREP = @GREP@
227 HAVE_VISIBILITY = @HAVE_VISIBILITY@
236 HAVE_CXX11 = @HAVE_CXX11@
228237 INSTALL = @INSTALL@
229238 INSTALL_DATA = @INSTALL_DATA@
230239 INSTALL_PROGRAM = @INSTALL_PROGRAM@
341350 dec265_LDFLAGS = $(am__append_2) $(am__append_4) $(am__append_6)
342351 dec265_LDADD = ../libde265/libde265.la -lstdc++
343352 dec265_SOURCES = dec265.cc $(am__append_5)
353 hdrcopy_DEPENDENCIES = ../libde265/libde265.la
354 hdrcopy_CXXFLAGS =
355 hdrcopy_LDFLAGS =
356 hdrcopy_LDADD = ../libde265/libde265.la -lstdc++
357 hdrcopy_SOURCES = hdrcopy.cc
344358 EXTRA_DIST = Makefile.vc7 \
345359 CMakeLists.txt \
346360 ../extra/getopt.c \
435449 @rm -f dec265$(EXEEXT)
436450 $(AM_V_CXXLD)$(dec265_LINK) $(dec265_OBJECTS) $(dec265_LDADD) $(LIBS)
437451
452 hdrcopy$(EXEEXT): $(hdrcopy_OBJECTS) $(hdrcopy_DEPENDENCIES) $(EXTRA_hdrcopy_DEPENDENCIES)
453 @rm -f hdrcopy$(EXEEXT)
454 $(AM_V_CXXLD)$(hdrcopy_LINK) $(hdrcopy_OBJECTS) $(hdrcopy_LDADD) $(LIBS)
455
438456 mostlyclean-compile:
439457 -rm -f *.$(OBJEXT)
440458
443461
444462 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dec265-dec265.Po@am__quote@
445463 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dec265-sdl.Po@am__quote@
464 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hdrcopy-hdrcopy.Po@am__quote@
446465
447466 .cc.o:
448467 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
492511 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='sdl.cc' object='dec265-sdl.obj' libtool=no @AMDEPBACKSLASH@
493512 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
494513 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(dec265_CXXFLAGS) $(CXXFLAGS) -c -o dec265-sdl.obj `if test -f 'sdl.cc'; then $(CYGPATH_W) 'sdl.cc'; else $(CYGPATH_W) '$(srcdir)/sdl.cc'; fi`
514
515 hdrcopy-hdrcopy.o: hdrcopy.cc
516 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hdrcopy_CXXFLAGS) $(CXXFLAGS) -MT hdrcopy-hdrcopy.o -MD -MP -MF $(DEPDIR)/hdrcopy-hdrcopy.Tpo -c -o hdrcopy-hdrcopy.o `test -f 'hdrcopy.cc' || echo '$(srcdir)/'`hdrcopy.cc
517 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hdrcopy-hdrcopy.Tpo $(DEPDIR)/hdrcopy-hdrcopy.Po
518 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='hdrcopy.cc' object='hdrcopy-hdrcopy.o' libtool=no @AMDEPBACKSLASH@
519 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
520 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hdrcopy_CXXFLAGS) $(CXXFLAGS) -c -o hdrcopy-hdrcopy.o `test -f 'hdrcopy.cc' || echo '$(srcdir)/'`hdrcopy.cc
521
522 hdrcopy-hdrcopy.obj: hdrcopy.cc
523 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hdrcopy_CXXFLAGS) $(CXXFLAGS) -MT hdrcopy-hdrcopy.obj -MD -MP -MF $(DEPDIR)/hdrcopy-hdrcopy.Tpo -c -o hdrcopy-hdrcopy.obj `if test -f 'hdrcopy.cc'; then $(CYGPATH_W) 'hdrcopy.cc'; else $(CYGPATH_W) '$(srcdir)/hdrcopy.cc'; fi`
524 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hdrcopy-hdrcopy.Tpo $(DEPDIR)/hdrcopy-hdrcopy.Po
525 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='hdrcopy.cc' object='hdrcopy-hdrcopy.obj' libtool=no @AMDEPBACKSLASH@
526 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
527 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hdrcopy_CXXFLAGS) $(CXXFLAGS) -c -o hdrcopy-hdrcopy.obj `if test -f 'hdrcopy.cc'; then $(CYGPATH_W) 'hdrcopy.cc'; else $(CYGPATH_W) '$(srcdir)/hdrcopy.cc'; fi`
495528
496529 mostlyclean-libtool:
497530 -rm -f *.lo
11 # Makefile for Microsoft Visual Studio 2003
22 #
33 CFLAGS=/I.. /I..\libde265 /I..\extra
4 CC=cl /nologo
4 CC=cl /nologo
55 LINK=link /nologo /subsystem:console
66 DEFINES=/DWIN32
77
88 CFLAGS=$(CFLAGS) /MT /Ob2 /Oi /W4 /EHsc
99 CFLAGS=$(CFLAGS) $(DEFINES)
10
11 # unreferenced formal parameter
12 CFLAGS=$(CFLAGS) /wd4100
1013
1114 OBJS=\
1215 ..\extra\getopt_long.obj \
3737 #include <unistd.h>
3838 #endif
3939
40 #include "libde265/quality.h"
41
4042 #if HAVE_VIDEOGFX
4143 #include <libvideogfx.hh>
4244 using namespace videogfx;
5254
5355 int nThreads=0;
5456 bool nal_input=false;
55 bool quiet=false;
57 int quiet=0;
5658 bool check_hash=false;
5759 bool show_help=false;
5860 bool dump_headers=false;
6466 uint32_t max_frames=UINT32_MAX;
6567 bool write_bytestream=false;
6668 const char *bytestream_filename;
69 bool measure_quality=false;
70 bool show_ssim_map=false;
71 bool show_psnr_map=false;
72 const char* reference_filename;
73 FILE* reference_file;
6774 int highestTID = 100;
6875 int verbosity=0;
6976 int disable_deblocking=0;
8390 {"help", no_argument, 0, 'h' },
8491 {"noaccel", no_argument, 0, '0' },
8592 {"write-bytestream", required_argument,0, 'B' },
93 {"measure", required_argument, 0, 'm' },
94 {"ssim", no_argument, 0, 's' },
95 {"errmap", no_argument, 0, 'e' },
8696 {"highest-TID", required_argument, 0, 'T' },
8797 {"verbose", no_argument, 0, 'v' },
8898 {"disable-deblocking", no_argument, &disable_deblocking, 1 },
97107 static FILE* fh = NULL;
98108 if (fh==NULL) { fh = fopen(output_filename, "wb"); }
99109
100
110
101111
102112 for (int c=0;c<3;c++) {
103113 int stride;
104114 const uint8_t* p = de265_get_image_plane(img, c, &stride);
105115 int width = de265_get_image_width(img,c);
106116
107 for (int y=0;y<de265_get_image_height(img,c);y++) {
108 fwrite(p + y*stride, width, 1, fh);
109 }
110 }
111
117 if (de265_get_bits_per_pixel(img,c)<=8) {
118 // --- save 8 bit YUV ---
119
120 for (int y=0;y<de265_get_image_height(img,c);y++) {
121 fwrite(p + y*stride, width, 1, fh);
122 }
123 }
124 else {
125 // --- save 16 bit YUV ---
126
127 uint8_t* buf = new uint8_t[width*2];
128 uint16_t* p16 = (uint16_t*)p;
129
130 for (int y=0;y<de265_get_image_height(img,c);y++) {
131 for (int x=0;x<width;x++) {
132 uint16_t pixel_value = (p16+y*stride)[x];
133 buf[2*x+0] = pixel_value & 0xFF;
134 buf[2*x+1] = pixel_value >> 8;
135 }
136
137 fwrite(buf, width*2, 1, fh);
138 }
139
140 delete[] buf;
141 }
142 }
143
112144 fflush(fh);
113145 }
114146
134166
135167 int width = de265_get_image_width(img,0);
136168 int height = de265_get_image_height(img,0);
169 de265_chroma chroma = de265_get_chroma_format(img);
170
171 ChromaFormat vgfx_chroma;
172 Colorspace vgfx_cs = Colorspace_YUV;
173
174 switch (chroma) {
175 case de265_chroma_420: vgfx_chroma = Chroma_420; break;
176 case de265_chroma_422: vgfx_chroma = Chroma_422; break;
177 case de265_chroma_444: vgfx_chroma = Chroma_444; break;
178 case de265_chroma_mono: vgfx_cs = Colorspace_Greyscale; break;
179 }
137180
138181 Image<Pixel> visu;
139 visu.Create(width, height, Colorspace_YUV, Chroma_420);
140
141 for (int ch=0;ch<3;ch++) {
182 visu.Create(width, height, vgfx_cs, vgfx_chroma);
183
184 int nChannels = 3;
185 if (chroma == de265_chroma_mono) {
186 nChannels = 1;
187 }
188
189 for (int ch=0;ch<nChannels;ch++) {
142190 const uint8_t* data;
143191 int stride;
144192
146194 width = de265_get_image_width(img,ch);
147195 height = de265_get_image_height(img,ch);
148196
149 for (int y=0;y<height;y++) {
150 memcpy(visu.AskFrame((BitmapChannel)ch)[y], data + y*stride, width);
197 int bit_depth = de265_get_bits_per_pixel(img,ch);
198
199 if (bit_depth==8) {
200 for (int y=0;y<height;y++) {
201 memcpy(visu.AskFrame((BitmapChannel)ch)[y], data + y*stride, width);
202 }
203 }
204 else {
205 const uint16_t* data16 = (const uint16_t*)data;
206 for (int y=0;y<height;y++) {
207 for (int x=0;x<width;x++) {
208 visu.AskFrame((BitmapChannel)ch)[y][x] = *(data16 + y*stride +x) >> (bit_depth-8);
209 }
210 }
151211 }
152212 }
153213
155215 win.WaitForKeypress();
156216 }
157217 #endif
218
219 static uint8_t* convert_to_8bit(const uint8_t* data, int width, int height, int stride, int bit_depth)
220 {
221 const uint16_t* data16 = (const uint16_t*)data;
222 uint8_t* out = new uint8_t[stride*height];
223
224 for (int y=0;y<height;y++) {
225 for (int x=0;x<width;x++) {
226 out[y*stride + x] = *(data16 + y*stride +x) >> (bit_depth-8);
227 }
228 }
229
230 return out;
231 }
232
158233
159234 #if HAVE_SDL
160235 SDL_YUV_Display sdlWin;
162237
163238 bool display_sdl(const struct de265_image* img)
164239 {
240 int width = de265_get_image_width(img,0);
241 int height = de265_get_image_height(img,0);
242
243 int chroma_width = de265_get_image_width(img,1);
244 int chroma_height = de265_get_image_height(img,1);
245
246 de265_chroma chroma = de265_get_chroma_format(img);
247
165248 if (!sdl_active) {
166 int width = de265_get_image_width(img,0);
167 int height = de265_get_image_height(img,0);
168
169249 sdl_active=true;
170 sdlWin.init(width,height);
250 enum SDL_YUV_Display::SDL_Chroma sdlChroma;
251 switch (chroma) {
252 case de265_chroma_420: sdlChroma = SDL_YUV_Display::SDL_CHROMA_420; break;
253 case de265_chroma_422: sdlChroma = SDL_YUV_Display::SDL_CHROMA_422; break;
254 case de265_chroma_444: sdlChroma = SDL_YUV_Display::SDL_CHROMA_444; break;
255 case de265_chroma_mono: sdlChroma = SDL_YUV_Display::SDL_CHROMA_MONO; break;
256 }
257
258 sdlWin.init(width,height, sdlChroma);
171259 }
172260
173261 int stride,chroma_stride;
175263 const uint8_t* cb =de265_get_image_plane(img,1,&chroma_stride);
176264 const uint8_t* cr =de265_get_image_plane(img,2,NULL);
177265
266 uint8_t* y16 = NULL;
267 uint8_t* cb16 = NULL;
268 uint8_t* cr16 = NULL;
269 int bd;
270
271 if ((bd=de265_get_bits_per_pixel(img, 0)) > 8) {
272 y16 = convert_to_8bit(y, width,height,stride,bd); y=y16;
273 }
274
275 if (chroma != de265_chroma_mono) {
276 if ((bd=de265_get_bits_per_pixel(img, 1)) > 8) {
277 cb16 = convert_to_8bit(cb, chroma_width,chroma_height,chroma_stride,bd); cb=cb16;
278 }
279 if ((bd=de265_get_bits_per_pixel(img, 2)) > 8) {
280 cr16 = convert_to_8bit(cr, chroma_width,chroma_height,chroma_stride,bd); cr=cr16;
281 }
282 }
283
178284 sdlWin.display(y,cb,cr, stride, chroma_stride);
285
286 delete[] y16;
287 delete[] cb16;
288 delete[] cr16;
179289
180290 return sdlWin.doQuit();
181291 }
232342 }
233343
234344 return stop;
345 }
346
347
348 static double mse_y=0.0, mse_cb=0.0, mse_cr=0.0;
349 static int mse_frames=0;
350
351 static double ssim_y=0.0;
352 static int ssim_frames=0;
353
354 void measure(const de265_image* img)
355 {
356 // --- compute PSNR ---
357
358 int width = de265_get_image_width(img,0);
359 int height = de265_get_image_height(img,0);
360
361 uint8_t* p = (uint8_t*)malloc(width*height*3/2);
362 if (p == NULL) {
363 return;
364 }
365
366 size_t toread = width*height*3/2;
367 if (fread(p,1,toread,reference_file) != toread) {
368 free(p);
369 return;
370 }
371
372 int stride, cstride;
373 const uint8_t* yptr = de265_get_image_plane(img,0, &stride);
374 const uint8_t* cbptr = de265_get_image_plane(img,1, &cstride);
375 const uint8_t* crptr = de265_get_image_plane(img,2, &cstride);
376
377 double img_mse_y = MSE( yptr, stride, p, width, width, height);
378 double img_mse_cb = MSE(cbptr, cstride, p+width*height, width/2, width/2,height/2);
379 double img_mse_cr = MSE(crptr, cstride, p+width*height*5/4, width/2, width/2,height/2);
380
381 mse_frames++;
382
383 mse_y += img_mse_y;
384 mse_cb += img_mse_cb;
385 mse_cr += img_mse_cr;
386
387
388
389 // --- compute SSIM ---
390
391 double ssimSum = 0.0;
392
393 #if HAVE_VIDEOGFX
394 Bitmap<Pixel> ref, coded;
395 ref .Create(width, height); // reference image
396 coded.Create(width, height); // coded image
397
398 const uint8_t* data;
399 data = de265_get_image_plane(img,0,&stride);
400
401 for (int y=0;y<height;y++) {
402 memcpy(coded[y], data + y*stride, width);
403 memcpy(ref[y], p + y*stride, width);
404 }
405
406 SSIM ssimAlgo;
407 Bitmap<float> ssim = ssimAlgo.calcSSIM(ref,coded);
408
409 Bitmap<Pixel> ssimMap;
410 ssimMap.Create(width,height);
411
412 for (int y=0;y<height;y++)
413 for (int x=0;x<width;x++)
414 {
415 float v = ssim[y][x];
416 ssimSum += v;
417 v = v*v;
418 v = 255*v; //pow(v, 20);
419
420 //assert(v<=255.0);
421 ssimMap[y][x] = v;
422 }
423
424 ssimSum /= width*height;
425
426
427 Bitmap<Pixel> error_map = CalcErrorMap(ref, coded, TransferCurve_Sqrt);
428
429
430 // display PSNR error map
431
432 if (show_psnr_map) {
433 static X11Win win;
434 static bool first=true;
435
436 if (first) {
437 first=false;
438 win.Create(de265_get_image_width(img,0),
439 de265_get_image_height(img,0),
440 "psnr output");
441 }
442
443 win.Display(MakeImage(error_map));
444 }
445
446
447 // display SSIM error map
448
449 if (show_ssim_map) {
450 static X11Win win;
451 static bool first=true;
452
453 if (first) {
454 first=false;
455 win.Create(de265_get_image_width(img,0),
456 de265_get_image_height(img,0),
457 "ssim output");
458 }
459
460 win.Display(MakeImage(ssimMap));
461 }
462 #endif
463
464 ssim_frames++;
465 ssim_y += ssimSum;
466
467 printf("%5d %6f %6f %6f %6f\n",
468 framecnt,
469 PSNR(img_mse_y), PSNR(img_mse_cb), PSNR(img_mse_cr),
470 ssimSum);
471
472 free(p);
235473 }
236474
237475
298536 #endif
299537 #endif
300538
539
301540 int main(int argc, char** argv)
302541 {
303542 while (1) {
304543 int option_index = 0;
305544
306 int c = getopt_long(argc, argv, "qt:chf:o:dLB:n0vT:"
545 int c = getopt_long(argc, argv, "qt:chf:o:dLB:n0vT:m:se"
307546 #if HAVE_VIDEOGFX && HAVE_SDL
308547 "V"
309548 #endif
312551 break;
313552
314553 switch (c) {
315 case 'q': quiet=true; break;
554 case 'q': quiet++; break;
316555 case 't': nThreads=atoi(optarg); break;
317556 case 'c': check_hash=true; break;
318557 case 'f': max_frames=atoi(optarg); break;
324563 case 'L': logging=false; break;
325564 case '0': no_acceleration=true; break;
326565 case 'B': write_bytestream=true; bytestream_filename=optarg; break;
566 case 'm': measure_quality=true; reference_filename=optarg; break;
567 case 's': show_ssim_map=true; break;
568 case 'e': show_psnr_map=true; break;
327569 case 'T': highestTID=atoi(optarg); break;
328570 case 'v': verbosity++; break;
329571 }
347589 fprintf(stderr," -V, --videogfx output with videogfx instead of SDL\n");
348590 #endif
349591 fprintf(stderr," -0, --noaccel do not use any accelerated code (SSE)\n");
592 fprintf(stderr," -v, --verbose increase verbosity level (up to 3 times)\n");
350593 fprintf(stderr," -L, --no-logging disable logging\n");
351594 fprintf(stderr," -B, --write-bytestream FILENAME write raw bytestream (from NAL input)\n");
595 fprintf(stderr," -m, --measure YUV compute PSNRs relative to reference YUV\n");
596 #if HAVE_VIDEOGFX
597 fprintf(stderr," -s, --ssim show SSIM-map (only when -m active)\n");
598 fprintf(stderr," -e, --errmap show error-map (only when -m active)\n");
599 #endif
352600 fprintf(stderr," -T, --highest-TID select highest temporal sublayer to decode\n");
353601 fprintf(stderr," --disable-deblocking disable deblocking filter\n");
354602 fprintf(stderr," --disable-sao disable sample-adaptive offset filter\n");
394642
395643 de265_set_limit_TID(ctx, highestTID);
396644
645
646 if (measure_quality) {
647 reference_file = fopen(reference_filename, "rb");
648 }
397649
398650
399651 FILE* fh = fopen(argv[optind], "rb");
483735
484736 err = de265_decode(ctx, &more);
485737 if (err != DE265_OK) {
738 // if (quiet<=1) fprintf(stderr,"ERROR: %s\n", de265_get_error_text(err));
739
486740 if (check_hash && err == DE265_ERROR_CHECKSUM_MISMATCH)
487741 stop = 1;
488742 more = 0;
493747
494748 const de265_image* img = de265_get_next_picture(ctx);
495749 if (img) {
750 if (measure_quality) {
751 measure(img);
752 }
753
496754 stop = output_image(img);
497755 if (stop) more=0;
498756 else more=1;
506764 break;
507765 }
508766
509 fprintf(stderr,"WARNING: %s\n", de265_get_error_text(warning));
767 if (quiet<=1) fprintf(stderr,"WARNING: %s\n", de265_get_error_text(warning));
510768 }
511769 }
512770 }
517775 fclose(bytestream_fh);
518776 }
519777
778 if (measure_quality) {
779 printf("#total %6f %6f %6f %6f\n",
780 PSNR(mse_y /mse_frames),
781 PSNR(mse_cb/mse_frames),
782 PSNR(mse_cr/mse_frames),
783 ssim_y/ssim_frames);
784
785 fclose(reference_file);
786 }
787
520788 de265_free_decoder(ctx);
521789
522790 struct timeval tv_end;
523791 gettimeofday(&tv_end, NULL);
524792
525793 if (err != DE265_OK) {
526 fprintf(stderr,"decoding error: %s (code=%d)\n", de265_get_error_text(err), err);
794 if (quiet<=1) fprintf(stderr,"decoding error: %s (code=%d)\n", de265_get_error_text(err), err);
527795 }
528796
529797 double secs = tv_end.tv_sec-tv_start.tv_sec;
530798 secs += (tv_end.tv_usec - tv_start.tv_usec)*0.001*0.001;
531799
532 fprintf(stderr,"nFrames decoded: %d (%dx%d @ %5.2f fps)\n",framecnt,
533 width,height,framecnt/secs);
800 if (quiet<=1) fprintf(stderr,"nFrames decoded: %d (%dx%d @ %5.2f fps)\n",framecnt,
801 width,height,framecnt/secs);
534802
535803
536804 return err==DE265_OK ? 0 : 10;
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * This file is part of libde265.
5 *
6 * libde265 is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * libde265 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
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with libde265. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20
21 #include "libde265/nal-parser.h"
22 #include "libde265/decctx.h"
23 #include <assert.h>
24
25 error_queue errqueue;
26
27 video_parameter_set vps;
28 seq_parameter_set sps;
29 pic_parameter_set pps;
30
31 CABAC_encoder_bitstream writer;
32
33
34 void process_nal(NAL_unit* nal)
35 {
36 de265_error err = DE265_OK;
37
38 bitreader reader;
39 bitreader_init(&reader, nal->data(), nal->size());
40
41 nal_header nal_hdr;
42 nal_hdr.read(&reader);
43 writer.write_startcode();
44 nal_hdr.write(writer);
45
46 printf("NAL: 0x%x 0x%x - unit type:%s temporal id:%d\n",
47 nal->data()[0], nal->data()[1],
48 get_NAL_name(nal_hdr.nal_unit_type),
49 nal_hdr.nuh_temporal_id);
50
51
52 if (nal_hdr.nal_unit_type<32) {
53 //err = read_slice_NAL(reader, nal, nal_hdr);
54 }
55 else switch (nal_hdr.nal_unit_type) {
56 case NAL_UNIT_VPS_NUT:
57 vps.read(&errqueue, &reader);
58 vps.dump(1);
59 vps.write(&errqueue, writer);
60 writer.flush_VLC();
61 break;
62
63 case NAL_UNIT_SPS_NUT:
64 sps.read(&errqueue, &reader);
65 sps.dump(1);
66 sps.write(&errqueue, writer);
67 writer.flush_VLC();
68 break;
69
70 case NAL_UNIT_PPS_NUT:
71 //err = read_pps_NAL(reader);
72 break;
73
74 case NAL_UNIT_PREFIX_SEI_NUT:
75 case NAL_UNIT_SUFFIX_SEI_NUT:
76 //err = read_sei_NAL(reader, nal_hdr.nal_unit_type==NAL_UNIT_SUFFIX_SEI_NUT);
77 break;
78
79 case NAL_UNIT_EOS_NUT:
80 //ctx->FirstAfterEndOfSequenceNAL = true;
81 break;
82 }
83 }
84
85
86 int main(int argc, char** argv)
87 {
88 NAL_Parser nal_parser;
89
90 FILE* fh = fopen(argv[1],"rb");
91 unsigned char buf[1024];
92
93 writer.write_bits(0,8); // because HM has an extra byte at the beginning
94
95 while(!feof(fh))
96 {
97 int n = fread(buf,1,1024,fh);
98 if (n>0) {
99 nal_parser.push_data(buf,n, 0);
100 }
101
102 if (nal_parser.get_NAL_queue_length()>0) {
103 NAL_unit* nal = nal_parser.pop_from_NAL_queue();
104 assert(nal);
105 process_nal(nal);
106 nal_parser.free_NAL_unit(nal);
107 }
108 }
109
110 fclose(fh);
111
112 fh = fopen("out.bin","wb");
113 fwrite(writer.data(), 1,writer.size(), fh);
114 fclose(fh);
115
116 return 0;
117 }
1818 */
1919
2020 #include "sdl.hh"
21
22
23 bool SDL_YUV_Display::init(int frame_width, int frame_height)
21 #include <assert.h>
22
23
24 bool SDL_YUV_Display::init(int frame_width, int frame_height, enum SDL_Chroma chroma)
2425 {
2526 // reduce image size to a multiple of 8 (apparently required by YUV overlay)
2627
2728 frame_width &= ~7;
2829 frame_height &= ~7;
2930
31 mChroma = chroma;
3032
3133 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0 ) {
3234 printf("SDL_Init() failed: %s\n", SDL_GetError( ) );
6163 return false;
6264 }
6365
64 mYUVOverlay = SDL_CreateYUVOverlay(frame_width, frame_height, SDL_YV12_OVERLAY, mScreen);
66 uint32_t pixelFormat;
67 switch (mChroma) {
68 case SDL_CHROMA_MONO: pixelFormat = SDL_YV12_OVERLAY; break;
69 case SDL_CHROMA_420: pixelFormat = SDL_YV12_OVERLAY; break;
70 case SDL_CHROMA_422: pixelFormat = SDL_YUY2_OVERLAY; break;
71 case SDL_CHROMA_444: pixelFormat = SDL_YV12_OVERLAY; break;
72 //case SDL_CHROMA_444: pixelFormat = SDL_YUY2_OVERLAY; break;
73 }
74
75 mYUVOverlay = SDL_CreateYUVOverlay(frame_width, frame_height, pixelFormat, mScreen);
6576 if (mYUVOverlay == NULL ) {
6677 printf("SDL: Couldn't create SDL YUV overlay: %s",SDL_GetError());
6778 SDL_Quit();
8697 if (!mWindowOpen) return;
8798 if (SDL_LockYUVOverlay(mYUVOverlay) < 0) return;
8899
100 if (mChroma == SDL_CHROMA_420) {
101 display420(Y,U,V,stride,chroma_stride);
102 }
103 else if (mChroma == SDL_CHROMA_422) {
104 display422(Y,U,V,stride,chroma_stride);
105 }
106 else if (mChroma == SDL_CHROMA_444) {
107 display444as420(Y,U,V,stride,chroma_stride);
108 //display444as422(Y,U,V,stride,chroma_stride);
109 }
110 else if (mChroma == SDL_CHROMA_MONO) {
111 display400(Y,stride);
112 }
113
114 SDL_UnlockYUVOverlay(mYUVOverlay);
115
116 SDL_DisplayYUVOverlay(mYUVOverlay, &rect);
117 }
118
119
120 void SDL_YUV_Display::display420(const unsigned char *Y,
121 const unsigned char *U,
122 const unsigned char *V,
123 int stride, int chroma_stride)
124 {
89125 if (stride == rect.w && chroma_stride == rect.w/2) {
90126
91127 // fast copy
108144 memcpy(mYUVOverlay->pixels[1]+y*rect.w/2, V+chroma_stride*y, rect.w/2);
109145 }
110146 }
111
112 SDL_UnlockYUVOverlay(mYUVOverlay);
113
114 SDL_DisplayYUVOverlay(mYUVOverlay, &rect);
115 }
147 }
148
149
150 void SDL_YUV_Display::display400(const unsigned char *Y, int stride)
151 {
152 if (stride == rect.w) {
153
154 // fast copy
155
156 memcpy(mYUVOverlay->pixels[0], Y, rect.w * rect.h);
157 }
158 else {
159 // copy line by line, because sizes are different
160
161 for (int y=0;y<rect.h;y++)
162 {
163 memcpy(mYUVOverlay->pixels[0]+y*rect.w, Y+stride*y, rect.w);
164 }
165 }
166
167 // clear chroma planes
168
169 memset(mYUVOverlay->pixels[1], 0x80, rect.w * rect.h / 4);
170 memset(mYUVOverlay->pixels[2], 0x80, rect.w * rect.h / 4);
171 }
172
173
174 void SDL_YUV_Display::display422(const unsigned char *Y,
175 const unsigned char *U,
176 const unsigned char *V,
177 int stride, int chroma_stride)
178 {
179 for (int y=0;y<rect.h;y++)
180 {
181 unsigned char* p = mYUVOverlay->pixels[0] + y*rect.w *2;
182
183 const unsigned char* Yp = Y + y*stride;
184 const unsigned char* Up = U + y*chroma_stride;
185 const unsigned char* Vp = V + y*chroma_stride;
186
187 for (int x=0;x<rect.w;x+=2) {
188 *p++ = Yp[x];
189 *p++ = Up[x/2];
190 *p++ = Yp[x+1];
191 *p++ = Vp[x/2];
192 }
193 }
194 }
195
196
197 /* This converts down 4:4:4 input to 4:2:2 for display, as SDL does not support
198 any 4:4:4 pixel format.
199 */
200 void SDL_YUV_Display::display444as422(const unsigned char *Y,
201 const unsigned char *U,
202 const unsigned char *V,
203 int stride, int chroma_stride)
204 {
205 for (int y=0;y<rect.h;y++)
206 {
207 unsigned char* p = mYUVOverlay->pixels[0] + y*rect.w *2;
208
209 const unsigned char* Yp = Y + y*stride;
210 const unsigned char* Up = U + y*chroma_stride;
211 const unsigned char* Vp = V + y*chroma_stride;
212
213 for (int x=0;x<rect.w;x+=2) {
214 *p++ = Yp[x];
215 *p++ = Up[x];
216 *p++ = Yp[x+1];
217 *p++ = Vp[x];
218 }
219 }
220 }
221
222
223 void SDL_YUV_Display::display444as420(const unsigned char *Y,
224 const unsigned char *U,
225 const unsigned char *V,
226 int stride, int chroma_stride)
227 {
228 for (int y=0;y<rect.h;y++)
229 {
230 unsigned char* p = mYUVOverlay->pixels[0] + y*rect.w;
231 memcpy(p, Y+y*stride, rect.w);
232 }
233
234 for (int y=0;y<rect.h;y+=2)
235 {
236 unsigned char* u = mYUVOverlay->pixels[2] + y/2*rect.w/2;
237 unsigned char* v = mYUVOverlay->pixels[1] + y/2*rect.w/2;
238
239 for (int x=0;x<rect.w;x+=2) {
240 u[x/2] = (U[ y *chroma_stride + x] + U[ y *chroma_stride + x +1] +
241 U[(y+1)*chroma_stride + x] + U[(y+1)*chroma_stride + x +1])/4;
242 v[x/2] = (V[ y *chroma_stride + x] + V[ y *chroma_stride + x +1] +
243 V[(y+1)*chroma_stride + x] + V[(y+1)*chroma_stride + x +1])/4;
244
245 //u[x/2] = U[y*chroma_stride + x];
246 //v[x/2] = V[y*chroma_stride + x];
247 }
248 }
249 }
250
116251
117252 bool SDL_YUV_Display::doQuit() const
118253 {
2424 {
2525 public:
2626
27 bool init(int frame_width, int frame_height);
27 enum SDL_Chroma {
28 SDL_CHROMA_MONO=400,
29 SDL_CHROMA_420 =420,
30 SDL_CHROMA_422 =422,
31 SDL_CHROMA_444 =444
32 };
33
34 bool init(int frame_width, int frame_height, enum SDL_Chroma chroma = SDL_CHROMA_420);
2835 void display(const unsigned char *Y, const unsigned char *U, const unsigned char *V,
2936 int stride, int chroma_stride);
3037 void close();
3845 SDL_Overlay *mYUVOverlay;
3946 SDL_Rect rect;
4047 bool mWindowOpen;
48
49 SDL_Chroma mChroma;
50
51 void display400(const unsigned char *Y,
52 int stride);
53 void display420(const unsigned char *Y,
54 const unsigned char *U,
55 const unsigned char *V,
56 int stride, int chroma_stride);
57 void display422(const unsigned char *Y,
58 const unsigned char *U,
59 const unsigned char *V,
60 int stride, int chroma_stride);
61 void display444as422(const unsigned char *Y,
62 const unsigned char *U,
63 const unsigned char *V,
64 int stride, int chroma_stride);
65 void display444as420(const unsigned char *Y,
66 const unsigned char *U,
67 const unsigned char *V,
68 int stride, int chroma_stride);
4169 };
0 set (enc265_sources
1 enc265.cc
2 )
3
4 if(MSVC)
5 set (enc265_sources
6 ${enc265_sources}
7 ../extra/getopt.c
8 ../extra/getopt_long.c
9 )
10 endif()
11
12 add_executable (enc265 ${enc265_sources})
13
14 target_link_libraries (enc265 ${LIBDE265_LIBRARY_NAME})
0
1 bin_PROGRAMS = enc265
2
3 AM_CPPFLAGS = -I../libde265
4
5 enc265_DEPENDENCIES = ../libde265/libde265.la
6 enc265_CXXFLAGS =
7 enc265_LDFLAGS =
8 enc265_LDADD = ../libde265/libde265.la -lstdc++
9 enc265_SOURCES = enc265.cc
10
11 if HAVE_VIDEOGFX
12 enc265_CXXFLAGS += $(VIDEOGFX_CFLAGS)
13 enc265_LDFLAGS += $(VIDEOGFX_LIBS)
14 endif
15
16 EXTRA_DIST = \
17 CMakeLists.txt \
18 Makefile.vc7
0 # Makefile.in generated by automake 1.14.1 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15
16 VPATH = @srcdir@
17 am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
18 am__make_running_with_option = \
19 case $${target_option-} in \
20 ?) ;; \
21 *) echo "am__make_running_with_option: internal error: invalid" \
22 "target option '$${target_option-}' specified" >&2; \
23 exit 1;; \
24 esac; \
25 has_opt=no; \
26 sane_makeflags=$$MAKEFLAGS; \
27 if $(am__is_gnu_make); then \
28 sane_makeflags=$$MFLAGS; \
29 else \
30 case $$MAKEFLAGS in \
31 *\\[\ \ ]*) \
32 bs=\\; \
33 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
34 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
35 esac; \
36 fi; \
37 skip_next=no; \
38 strip_trailopt () \
39 { \
40 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
41 }; \
42 for flg in $$sane_makeflags; do \
43 test $$skip_next = yes && { skip_next=no; continue; }; \
44 case $$flg in \
45 *=*|--*) continue;; \
46 -*I) strip_trailopt 'I'; skip_next=yes;; \
47 -*I?*) strip_trailopt 'I';; \
48 -*O) strip_trailopt 'O'; skip_next=yes;; \
49 -*O?*) strip_trailopt 'O';; \
50 -*l) strip_trailopt 'l'; skip_next=yes;; \
51 -*l?*) strip_trailopt 'l';; \
52 -[dEDm]) skip_next=yes;; \
53 -[JT]) skip_next=yes;; \
54 esac; \
55 case $$flg in \
56 *$$target_option*) has_opt=yes; break;; \
57 esac; \
58 done; \
59 test $$has_opt = yes
60 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
61 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
62 pkgdatadir = $(datadir)/@PACKAGE@
63 pkgincludedir = $(includedir)/@PACKAGE@
64 pkglibdir = $(libdir)/@PACKAGE@
65 pkglibexecdir = $(libexecdir)/@PACKAGE@
66 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
67 install_sh_DATA = $(install_sh) -c -m 644
68 install_sh_PROGRAM = $(install_sh) -c
69 install_sh_SCRIPT = $(install_sh) -c
70 INSTALL_HEADER = $(INSTALL_DATA)
71 transform = $(program_transform_name)
72 NORMAL_INSTALL = :
73 PRE_INSTALL = :
74 POST_INSTALL = :
75 NORMAL_UNINSTALL = :
76 PRE_UNINSTALL = :
77 POST_UNINSTALL = :
78 build_triplet = @build@
79 host_triplet = @host@
80 target_triplet = @target@
81 bin_PROGRAMS = enc265$(EXEEXT)
82 @HAVE_VIDEOGFX_TRUE@am__append_1 = $(VIDEOGFX_CFLAGS)
83 @HAVE_VIDEOGFX_TRUE@am__append_2 = $(VIDEOGFX_LIBS)
84 subdir = enc265
85 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
86 $(top_srcdir)/depcomp
87 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
88 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
89 $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \
90 $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
91 $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
92 $(top_srcdir)/m4/lt~obsolete.m4 \
93 $(top_srcdir)/m4/m4_ax_check_compile_flag.m4 \
94 $(top_srcdir)/configure.ac
95 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
96 $(ACLOCAL_M4)
97 mkinstalldirs = $(install_sh) -d
98 CONFIG_HEADER = $(top_builddir)/config.h
99 CONFIG_CLEAN_FILES =
100 CONFIG_CLEAN_VPATH_FILES =
101 am__installdirs = "$(DESTDIR)$(bindir)"
102 PROGRAMS = $(bin_PROGRAMS)
103 am_enc265_OBJECTS = enc265-enc265.$(OBJEXT)
104 enc265_OBJECTS = $(am_enc265_OBJECTS)
105 AM_V_lt = $(am__v_lt_@AM_V@)
106 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
107 am__v_lt_0 = --silent
108 am__v_lt_1 =
109 enc265_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
110 $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(enc265_CXXFLAGS) \
111 $(CXXFLAGS) $(enc265_LDFLAGS) $(LDFLAGS) -o $@
112 AM_V_P = $(am__v_P_@AM_V@)
113 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
114 am__v_P_0 = false
115 am__v_P_1 = :
116 AM_V_GEN = $(am__v_GEN_@AM_V@)
117 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
118 am__v_GEN_0 = @echo " GEN " $@;
119 am__v_GEN_1 =
120 AM_V_at = $(am__v_at_@AM_V@)
121 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
122 am__v_at_0 = @
123 am__v_at_1 =
124 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
125 depcomp = $(SHELL) $(top_srcdir)/depcomp
126 am__depfiles_maybe = depfiles
127 am__mv = mv -f
128 CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
129 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
130 LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
131 $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
132 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
133 $(AM_CXXFLAGS) $(CXXFLAGS)
134 AM_V_CXX = $(am__v_CXX_@AM_V@)
135 am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
136 am__v_CXX_0 = @echo " CXX " $@;
137 am__v_CXX_1 =
138 CXXLD = $(CXX)
139 CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
140 $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
141 $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
142 AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
143 am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
144 am__v_CXXLD_0 = @echo " CXXLD " $@;
145 am__v_CXXLD_1 =
146 SOURCES = $(enc265_SOURCES)
147 DIST_SOURCES = $(enc265_SOURCES)
148 am__can_run_installinfo = \
149 case $$AM_UPDATE_INFO_DIR in \
150 n|no|NO) false;; \
151 *) (install-info --version) >/dev/null 2>&1;; \
152 esac
153 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
154 # Read a list of newline-separated strings from the standard input,
155 # and print each of them once, without duplicates. Input order is
156 # *not* preserved.
157 am__uniquify_input = $(AWK) '\
158 BEGIN { nonempty = 0; } \
159 { items[$$0] = 1; nonempty = 1; } \
160 END { if (nonempty) { for (i in items) print i; }; } \
161 '
162 # Make sure the list of sources is unique. This is necessary because,
163 # e.g., the same source file might be shared among _SOURCES variables
164 # for different programs/libraries.
165 am__define_uniq_tagged_files = \
166 list='$(am__tagged_files)'; \
167 unique=`for i in $$list; do \
168 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
169 done | $(am__uniquify_input)`
170 ETAGS = etags
171 CTAGS = ctags
172 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
173 ACLOCAL = @ACLOCAL@
174 ALLOCA = @ALLOCA@
175 AMTAR = @AMTAR@
176 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
177 AR = @AR@
178 AUTOCONF = @AUTOCONF@
179 AUTOHEADER = @AUTOHEADER@
180 AUTOMAKE = @AUTOMAKE@
181 AWK = @AWK@
182 CC = @CC@
183 CCAS = @CCAS@
184 CCASDEPMODE = @CCASDEPMODE@
185 CCASFLAGS = @CCASFLAGS@
186 CCDEPMODE = @CCDEPMODE@
187 CFLAGS = @CFLAGS@
188 CPP = @CPP@
189 CPPFLAGS = @CPPFLAGS@
190 CXX = @CXX@
191 CXXCPP = @CXXCPP@
192 CXXDEPMODE = @CXXDEPMODE@
193 CXXFLAGS = @CXXFLAGS@
194 CYGPATH_W = @CYGPATH_W@
195 DEFS = @DEFS@
196 DEPDIR = @DEPDIR@
197 DLLTOOL = @DLLTOOL@
198 DSYMUTIL = @DSYMUTIL@
199 DUMPBIN = @DUMPBIN@
200 ECHO_C = @ECHO_C@
201 ECHO_N = @ECHO_N@
202 ECHO_T = @ECHO_T@
203 EGREP = @EGREP@
204 EXEEXT = @EXEEXT@
205 FGREP = @FGREP@
206 GREP = @GREP@
207 HAVE_CXX11 = @HAVE_CXX11@
208 INSTALL = @INSTALL@
209 INSTALL_DATA = @INSTALL_DATA@
210 INSTALL_PROGRAM = @INSTALL_PROGRAM@
211 INSTALL_SCRIPT = @INSTALL_SCRIPT@
212 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
213 LD = @LD@
214 LDFLAGS = @LDFLAGS@
215 LIBDE265_AGE = @LIBDE265_AGE@
216 LIBDE265_CURRENT = @LIBDE265_CURRENT@
217 LIBDE265_REVISION = @LIBDE265_REVISION@
218 LIBOBJS = @LIBOBJS@
219 LIBS = @LIBS@
220 LIBTOOL = @LIBTOOL@
221 LIPO = @LIPO@
222 LN_S = @LN_S@
223 LTLIBOBJS = @LTLIBOBJS@
224 MAKEINFO = @MAKEINFO@
225 MANIFEST_TOOL = @MANIFEST_TOOL@
226 MKDIR_P = @MKDIR_P@
227 NM = @NM@
228 NMEDIT = @NMEDIT@
229 NUMERIC_VERSION = @NUMERIC_VERSION@
230 OBJDUMP = @OBJDUMP@
231 OBJEXT = @OBJEXT@
232 OTOOL = @OTOOL@
233 OTOOL64 = @OTOOL64@
234 PACKAGE = @PACKAGE@
235 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
236 PACKAGE_NAME = @PACKAGE_NAME@
237 PACKAGE_STRING = @PACKAGE_STRING@
238 PACKAGE_TARNAME = @PACKAGE_TARNAME@
239 PACKAGE_URL = @PACKAGE_URL@
240 PACKAGE_VERSION = @PACKAGE_VERSION@
241 PATH_SEPARATOR = @PATH_SEPARATOR@
242 PKG_CONFIG = @PKG_CONFIG@
243 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
244 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
245 QTCHOOSER = @QTCHOOSER@
246 QTMOC = @QTMOC@
247 QT_CFLAGS = @QT_CFLAGS@
248 QT_LIBS = @QT_LIBS@
249 RANLIB = @RANLIB@
250 SDL_CFLAGS = @SDL_CFLAGS@
251 SDL_LIBS = @SDL_LIBS@
252 SED = @SED@
253 SET_MAKE = @SET_MAKE@
254 SHELL = @SHELL@
255 STRIP = @STRIP@
256 SWSCALE_CFLAGS = @SWSCALE_CFLAGS@
257 SWSCALE_LIBS = @SWSCALE_LIBS@
258 VERSION = @VERSION@
259 VIDEOGFX_CFLAGS = @VIDEOGFX_CFLAGS@
260 VIDEOGFX_LIBS = @VIDEOGFX_LIBS@
261 abs_builddir = @abs_builddir@
262 abs_srcdir = @abs_srcdir@
263 abs_top_builddir = @abs_top_builddir@
264 abs_top_srcdir = @abs_top_srcdir@
265 ac_ct_AR = @ac_ct_AR@
266 ac_ct_CC = @ac_ct_CC@
267 ac_ct_CXX = @ac_ct_CXX@
268 ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
269 am__include = @am__include@
270 am__leading_dot = @am__leading_dot@
271 am__quote = @am__quote@
272 am__tar = @am__tar@
273 am__untar = @am__untar@
274 bindir = @bindir@
275 build = @build@
276 build_alias = @build_alias@
277 build_cpu = @build_cpu@
278 build_os = @build_os@
279 build_vendor = @build_vendor@
280 builddir = @builddir@
281 datadir = @datadir@
282 datarootdir = @datarootdir@
283 docdir = @docdir@
284 dvidir = @dvidir@
285 exec_prefix = @exec_prefix@
286 host = @host@
287 host_alias = @host_alias@
288 host_cpu = @host_cpu@
289 host_os = @host_os@
290 host_vendor = @host_vendor@
291 htmldir = @htmldir@
292 includedir = @includedir@
293 infodir = @infodir@
294 install_sh = @install_sh@
295 libdir = @libdir@
296 libexecdir = @libexecdir@
297 localedir = @localedir@
298 localstatedir = @localstatedir@
299 mandir = @mandir@
300 mkdir_p = @mkdir_p@
301 oldincludedir = @oldincludedir@
302 pdfdir = @pdfdir@
303 prefix = @prefix@
304 program_transform_name = @program_transform_name@
305 psdir = @psdir@
306 sbindir = @sbindir@
307 sharedstatedir = @sharedstatedir@
308 srcdir = @srcdir@
309 sysconfdir = @sysconfdir@
310 target = @target@
311 target_alias = @target_alias@
312 target_cpu = @target_cpu@
313 target_os = @target_os@
314 target_vendor = @target_vendor@
315 top_build_prefix = @top_build_prefix@
316 top_builddir = @top_builddir@
317 top_srcdir = @top_srcdir@
318 AM_CPPFLAGS = -I../libde265
319 enc265_DEPENDENCIES = ../libde265/libde265.la
320 enc265_CXXFLAGS = $(am__append_1)
321 enc265_LDFLAGS = $(am__append_2)
322 enc265_LDADD = ../libde265/libde265.la -lstdc++
323 enc265_SOURCES = enc265.cc
324 EXTRA_DIST = \
325 CMakeLists.txt \
326 Makefile.vc7
327
328 all: all-am
329
330 .SUFFIXES:
331 .SUFFIXES: .cc .lo .o .obj
332 $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
333 @for dep in $?; do \
334 case '$(am__configure_deps)' in \
335 *$$dep*) \
336 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
337 && { if test -f $@; then exit 0; else break; fi; }; \
338 exit 1;; \
339 esac; \
340 done; \
341 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu enc265/Makefile'; \
342 $(am__cd) $(top_srcdir) && \
343 $(AUTOMAKE) --gnu enc265/Makefile
344 .PRECIOUS: Makefile
345 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
346 @case '$?' in \
347 *config.status*) \
348 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
349 *) \
350 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
351 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
352 esac;
353
354 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
355 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
356
357 $(top_srcdir)/configure: $(am__configure_deps)
358 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
359 $(ACLOCAL_M4): $(am__aclocal_m4_deps)
360 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
361 $(am__aclocal_m4_deps):
362 install-binPROGRAMS: $(bin_PROGRAMS)
363 @$(NORMAL_INSTALL)
364 @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
365 if test -n "$$list"; then \
366 echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
367 $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
368 fi; \
369 for p in $$list; do echo "$$p $$p"; done | \
370 sed 's/$(EXEEXT)$$//' | \
371 while read p p1; do if test -f $$p \
372 || test -f $$p1 \
373 ; then echo "$$p"; echo "$$p"; else :; fi; \
374 done | \
375 sed -e 'p;s,.*/,,;n;h' \
376 -e 's|.*|.|' \
377 -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
378 sed 'N;N;N;s,\n, ,g' | \
379 $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
380 { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
381 if ($$2 == $$4) files[d] = files[d] " " $$1; \
382 else { print "f", $$3 "/" $$4, $$1; } } \
383 END { for (d in files) print "f", d, files[d] }' | \
384 while read type dir files; do \
385 if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
386 test -z "$$files" || { \
387 echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
388 $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
389 } \
390 ; done
391
392 uninstall-binPROGRAMS:
393 @$(NORMAL_UNINSTALL)
394 @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
395 files=`for p in $$list; do echo "$$p"; done | \
396 sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
397 -e 's/$$/$(EXEEXT)/' \
398 `; \
399 test -n "$$list" || exit 0; \
400 echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
401 cd "$(DESTDIR)$(bindir)" && rm -f $$files
402
403 clean-binPROGRAMS:
404 @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
405 echo " rm -f" $$list; \
406 rm -f $$list || exit $$?; \
407 test -n "$(EXEEXT)" || exit 0; \
408 list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
409 echo " rm -f" $$list; \
410 rm -f $$list
411
412 enc265$(EXEEXT): $(enc265_OBJECTS) $(enc265_DEPENDENCIES) $(EXTRA_enc265_DEPENDENCIES)
413 @rm -f enc265$(EXEEXT)
414 $(AM_V_CXXLD)$(enc265_LINK) $(enc265_OBJECTS) $(enc265_LDADD) $(LIBS)
415
416 mostlyclean-compile:
417 -rm -f *.$(OBJEXT)
418
419 distclean-compile:
420 -rm -f *.tab.c
421
422 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/enc265-enc265.Po@am__quote@
423
424 .cc.o:
425 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
426 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
427 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
428 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
429 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<
430
431 .cc.obj:
432 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
433 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
434 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
435 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
436 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
437
438 .cc.lo:
439 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
440 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
441 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
442 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
443 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
444
445 enc265-enc265.o: enc265.cc
446 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(enc265_CXXFLAGS) $(CXXFLAGS) -MT enc265-enc265.o -MD -MP -MF $(DEPDIR)/enc265-enc265.Tpo -c -o enc265-enc265.o `test -f 'enc265.cc' || echo '$(srcdir)/'`enc265.cc
447 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/enc265-enc265.Tpo $(DEPDIR)/enc265-enc265.Po
448 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='enc265.cc' object='enc265-enc265.o' libtool=no @AMDEPBACKSLASH@
449 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
450 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(enc265_CXXFLAGS) $(CXXFLAGS) -c -o enc265-enc265.o `test -f 'enc265.cc' || echo '$(srcdir)/'`enc265.cc
451
452 enc265-enc265.obj: enc265.cc
453 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(enc265_CXXFLAGS) $(CXXFLAGS) -MT enc265-enc265.obj -MD -MP -MF $(DEPDIR)/enc265-enc265.Tpo -c -o enc265-enc265.obj `if test -f 'enc265.cc'; then $(CYGPATH_W) 'enc265.cc'; else $(CYGPATH_W) '$(srcdir)/enc265.cc'; fi`
454 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/enc265-enc265.Tpo $(DEPDIR)/enc265-enc265.Po
455 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='enc265.cc' object='enc265-enc265.obj' libtool=no @AMDEPBACKSLASH@
456 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
457 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(enc265_CXXFLAGS) $(CXXFLAGS) -c -o enc265-enc265.obj `if test -f 'enc265.cc'; then $(CYGPATH_W) 'enc265.cc'; else $(CYGPATH_W) '$(srcdir)/enc265.cc'; fi`
458
459 mostlyclean-libtool:
460 -rm -f *.lo
461
462 clean-libtool:
463 -rm -rf .libs _libs
464
465 ID: $(am__tagged_files)
466 $(am__define_uniq_tagged_files); mkid -fID $$unique
467 tags: tags-am
468 TAGS: tags
469
470 tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
471 set x; \
472 here=`pwd`; \
473 $(am__define_uniq_tagged_files); \
474 shift; \
475 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
476 test -n "$$unique" || unique=$$empty_fix; \
477 if test $$# -gt 0; then \
478 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
479 "$$@" $$unique; \
480 else \
481 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
482 $$unique; \
483 fi; \
484 fi
485 ctags: ctags-am
486
487 CTAGS: ctags
488 ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
489 $(am__define_uniq_tagged_files); \
490 test -z "$(CTAGS_ARGS)$$unique" \
491 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
492 $$unique
493
494 GTAGS:
495 here=`$(am__cd) $(top_builddir) && pwd` \
496 && $(am__cd) $(top_srcdir) \
497 && gtags -i $(GTAGS_ARGS) "$$here"
498 cscopelist: cscopelist-am
499
500 cscopelist-am: $(am__tagged_files)
501 list='$(am__tagged_files)'; \
502 case "$(srcdir)" in \
503 [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
504 *) sdir=$(subdir)/$(srcdir) ;; \
505 esac; \
506 for i in $$list; do \
507 if test -f "$$i"; then \
508 echo "$(subdir)/$$i"; \
509 else \
510 echo "$$sdir/$$i"; \
511 fi; \
512 done >> $(top_builddir)/cscope.files
513
514 distclean-tags:
515 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
516
517 distdir: $(DISTFILES)
518 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
519 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
520 list='$(DISTFILES)'; \
521 dist_files=`for file in $$list; do echo $$file; done | \
522 sed -e "s|^$$srcdirstrip/||;t" \
523 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
524 case $$dist_files in \
525 */*) $(MKDIR_P) `echo "$$dist_files" | \
526 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
527 sort -u` ;; \
528 esac; \
529 for file in $$dist_files; do \
530 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
531 if test -d $$d/$$file; then \
532 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
533 if test -d "$(distdir)/$$file"; then \
534 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
535 fi; \
536 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
537 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
538 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
539 fi; \
540 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
541 else \
542 test -f "$(distdir)/$$file" \
543 || cp -p $$d/$$file "$(distdir)/$$file" \
544 || exit 1; \
545 fi; \
546 done
547 check-am: all-am
548 check: check-am
549 all-am: Makefile $(PROGRAMS)
550 installdirs:
551 for dir in "$(DESTDIR)$(bindir)"; do \
552 test -z "$$dir" || $(MKDIR_P) "$$dir"; \
553 done
554 install: install-am
555 install-exec: install-exec-am
556 install-data: install-data-am
557 uninstall: uninstall-am
558
559 install-am: all-am
560 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
561
562 installcheck: installcheck-am
563 install-strip:
564 if test -z '$(STRIP)'; then \
565 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
566 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
567 install; \
568 else \
569 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
570 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
571 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
572 fi
573 mostlyclean-generic:
574
575 clean-generic:
576
577 distclean-generic:
578 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
579 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
580
581 maintainer-clean-generic:
582 @echo "This command is intended for maintainers to use"
583 @echo "it deletes files that may require special tools to rebuild."
584 clean: clean-am
585
586 clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
587
588 distclean: distclean-am
589 -rm -rf ./$(DEPDIR)
590 -rm -f Makefile
591 distclean-am: clean-am distclean-compile distclean-generic \
592 distclean-tags
593
594 dvi: dvi-am
595
596 dvi-am:
597
598 html: html-am
599
600 html-am:
601
602 info: info-am
603
604 info-am:
605
606 install-data-am:
607
608 install-dvi: install-dvi-am
609
610 install-dvi-am:
611
612 install-exec-am: install-binPROGRAMS
613
614 install-html: install-html-am
615
616 install-html-am:
617
618 install-info: install-info-am
619
620 install-info-am:
621
622 install-man:
623
624 install-pdf: install-pdf-am
625
626 install-pdf-am:
627
628 install-ps: install-ps-am
629
630 install-ps-am:
631
632 installcheck-am:
633
634 maintainer-clean: maintainer-clean-am
635 -rm -rf ./$(DEPDIR)
636 -rm -f Makefile
637 maintainer-clean-am: distclean-am maintainer-clean-generic
638
639 mostlyclean: mostlyclean-am
640
641 mostlyclean-am: mostlyclean-compile mostlyclean-generic \
642 mostlyclean-libtool
643
644 pdf: pdf-am
645
646 pdf-am:
647
648 ps: ps-am
649
650 ps-am:
651
652 uninstall-am: uninstall-binPROGRAMS
653
654 .MAKE: install-am install-strip
655
656 .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \
657 clean-binPROGRAMS clean-generic clean-libtool cscopelist-am \
658 ctags ctags-am distclean distclean-compile distclean-generic \
659 distclean-libtool distclean-tags distdir dvi dvi-am html \
660 html-am info info-am install install-am install-binPROGRAMS \
661 install-data install-data-am install-dvi install-dvi-am \
662 install-exec install-exec-am install-html install-html-am \
663 install-info install-info-am install-man install-pdf \
664 install-pdf-am install-ps install-ps-am install-strip \
665 installcheck installcheck-am installdirs maintainer-clean \
666 maintainer-clean-generic mostlyclean mostlyclean-compile \
667 mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
668 tags tags-am uninstall uninstall-am uninstall-binPROGRAMS
669
670
671 # Tell versions [3.59,3.63) of GNU make to not export all variables.
672 # Otherwise a system limit (for SysV at least) may be exceeded.
673 .NOEXPORT:
0 #
1 # Makefile for Microsoft Visual Studio 2003
2 #
3 CFLAGS=/I.. /I..\libde265 /I..\extra
4 CC=cl /nologo
5 LINK=link /nologo /subsystem:console
6 DEFINES=/DWIN32
7
8 CFLAGS=$(CFLAGS) /MT /Ob2 /Oi /W4 /EHsc
9 CFLAGS=$(CFLAGS) $(DEFINES)
10
11 # unreferenced formal parameter
12 CFLAGS=$(CFLAGS) /wd4100
13
14
15 OBJS=\
16 ..\extra\getopt_long.obj \
17 ..\extra\getopt.obj \
18 enc265.obj
19
20 all: enc265.exe
21
22 enc265.obj: enc265.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 enc265.exe: $(OBJS) ..\libde265\libde265.lib
32 $(LINK) /out:enc265.exe $** ..\libde265\libde265.lib
33
34 clean:
35 del enc265.exe
36 del $(OBJS)
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * This file is part of libde265.
5 *
6 * libde265 is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * libde265 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
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with libde265. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "libde265/en265.h" //coder-context.h"
21
22 #include "libde265/configparam.h"
23 #include "libde265/image-io.h"
24 #include "libde265/encoder/analyze.h"
25 #include "libde265/util.h"
26
27 #include <getopt.h>
28
29
30
31 #if HAVE_VIDEOGFX
32 #include <libvideogfx.hh>
33 using namespace videogfx;
34
35 void debug_show_image_libvideogfx(const de265_image* input, int slot)
36 {
37 static X11Win debugwin;
38 static bool opened=false;
39 int w = input->get_width();
40 int h = input->get_height();
41 if (!opened) {
42 opened=true;
43 debugwin.Create(w,h, "debug");
44 }
45
46 Image<Pixel> img;
47 img.Create(w,h,Colorspace_YUV, Chroma_420);
48
49 for (int y=0;y<h;y++)
50 memcpy(img.AskFrameY()[y], input->get_image_plane_at_pos(0,0,y), w);
51
52 for (int y=0;y<h/2;y++) {
53 memcpy(img.AskFrameU()[y], input->get_image_plane_at_pos(1,0,y), w/2);
54 memcpy(img.AskFrameV()[y], input->get_image_plane_at_pos(2,0,y), w/2);
55 }
56
57 debugwin.Display(img);
58 //debugwin.WaitForKeypress();
59 }
60 #endif
61
62
63
64 int show_help=false;
65 int verbosity=0;
66
67 static struct option long_options[] = {
68 {"help", no_argument, &show_help, 1 },
69 {"verbose", no_argument, 0, 'v' },
70 {0, 0, 0, 0 }
71 };
72
73
74 struct inout_params
75 {
76 inout_params();
77
78 // input
79
80 option_int first_frame;
81 option_int max_number_of_frames;
82
83 option_string input_yuv;
84 option_int input_width;
85 option_int input_height;
86
87 // output
88
89 option_string output_filename;
90
91 // debug
92
93 option_string reconstruction_yuv;
94
95
96 void register_params(config_parameters& config);
97 };
98
99
100 inout_params::inout_params()
101 {
102 input_yuv.set_ID("input"); input_yuv.set_short_option('i');
103 input_yuv.set_default("paris_cif.yuv");
104
105 output_filename.set_ID("output"); output_filename.set_short_option('o');
106 output_filename.set_default("out.bin");
107
108 reconstruction_yuv.set_ID("input");
109 reconstruction_yuv.set_default("recon.yuv");
110
111 first_frame.set_ID("first-frame");
112 first_frame.set_default(0);
113 first_frame.set_minimum(0);
114
115 max_number_of_frames.set_ID("frames");
116 max_number_of_frames.set_short_option('f');
117 max_number_of_frames.set_minimum(1);
118 //max_number_of_frames.set_default(INT_MAX);
119
120 input_width.set_ID("width"); input_width.set_short_option('w');
121 input_width.set_minimum(1); input_width.set_default(352);
122
123 input_height.set_ID("height"); input_height.set_short_option('h');
124 input_height.set_minimum(1); input_height.set_default(288);
125 }
126
127
128 void inout_params::register_params(config_parameters& config)
129 {
130 config.add_option(&input_yuv);
131 config.add_option(&output_filename);
132 config.add_option(&first_frame);
133 config.add_option(&max_number_of_frames);
134 config.add_option(&input_width);
135 config.add_option(&input_height);
136 }
137
138
139 void test_parameters_API(en265_encoder_context* ectx)
140 {
141 const char** param = en265_list_parameters(ectx);
142 if (param) {
143 for (int i=0; param[i]; i++) {
144 printf("|%s| ",param[i]);
145
146 enum en265_parameter_type type = en265_get_parameter_type(ectx, param[i]);
147 const char* type_name="unknown";
148 switch (type) {
149 case en265_parameter_int: type_name="int"; break;
150 case en265_parameter_bool: type_name="bool"; break;
151 case en265_parameter_string: type_name="string"; break;
152 case en265_parameter_choice: type_name="choice"; break;
153 }
154
155 printf("(%s)",type_name);
156
157 if (type==en265_parameter_choice) {
158 const char** choices = en265_list_parameter_choices(ectx, param[i]);
159 if (choices) {
160 for (int k=0; choices[k]; k++) {
161 printf(" %s",choices[k]);
162 }
163 }
164 }
165
166 printf("\n");
167 }
168 }
169
170 // en265_set_parameter_int(ectx, "min-tb-size", 8);
171 }
172
173
174 extern int skipTBSplit, noskipTBSplit;
175 extern int zeroBlockCorrelation[6][2][5];
176
177 int main(int argc, char** argv)
178 {
179 de265_init();
180
181 en265_encoder_context* ectx = en265_new_encoder();
182
183
184 bool cmdline_errors = false;
185
186 // --- in/out parameters ---
187
188 struct inout_params inout_params;
189 config_parameters inout_param_config;
190 inout_params.register_params(inout_param_config);
191
192 int first_idx=1;
193 if (!inout_param_config.parse_command_line_params(&argc,argv, &first_idx, true)) {
194 cmdline_errors = true;
195 }
196
197
198 // --- read encoder parameters ---
199
200 if (en265_parse_command_line_parameters(ectx, &argc, argv) != DE265_OK) {
201 cmdline_errors = true;
202 }
203
204
205
206 while (1) {
207 int option_index = 0;
208
209 int c = getopt_long(argc, argv, "v"
210 , long_options, &option_index);
211 if (c == -1)
212 break;
213
214 switch (c) {
215 case 'v': verbosity++; break;
216 }
217 }
218
219
220 // --- show usage information ---
221
222 if (optind != argc || cmdline_errors || show_help) {
223 fprintf(stderr," enc265 v%s\n", de265_get_version());
224 fprintf(stderr,"--------------\n");
225 fprintf(stderr,"usage: enc265 [options]\n");
226 fprintf(stderr,"The video file must be a raw YUV file\n");
227 fprintf(stderr,"\n");
228 fprintf(stderr,"options:\n");
229 fprintf(stderr," --help show help\n");
230 fprintf(stderr," -v, --verbose increase verbosity level (up to 3 times)\n");
231
232 inout_param_config.print_params();
233 fprintf(stderr,"\n");
234 en265_show_parameters(ectx);
235
236 exit(show_help ? 0 : 5);
237 }
238
239
240
241 de265_set_verbosity(verbosity);
242 #if HAVE_VIDEOGFX
243 //debug_set_image_output(debug_show_image_libvideogfx);
244 #endif
245
246 //test_parameters_API(ectx);
247
248
249 ImageSink_YUV reconstruction_sink;
250 if (strlen(inout_params.reconstruction_yuv.get().c_str()) != 0) {
251 reconstruction_sink.set_filename(inout_params.reconstruction_yuv.get().c_str());
252 //ectx.reconstruction_sink = &reconstruction_sink;
253 }
254
255 ImageSource_YUV image_source;
256 image_source.set_input_file(inout_params.input_yuv.get().c_str(),
257 inout_params.input_width,
258 inout_params.input_height);
259
260 PacketSink_File packet_sink;
261 packet_sink.set_filename(inout_params.output_filename.get().c_str());
262
263
264 // --- run encoder ---
265
266 image_source.skip_frames( inout_params.first_frame );
267
268 en265_start_encoder(ectx, 0);
269
270 int maxPoc = INT_MAX;
271 if (inout_params.max_number_of_frames.is_defined()) {
272 maxPoc = inout_params.max_number_of_frames;
273 }
274
275 bool eof = false;
276 for (int poc=0; poc<maxPoc && !eof ;poc++)
277 {
278 // push one image into the encoder
279
280 de265_image* input_image = image_source.get_image();
281 if (input_image==NULL) {
282 en265_push_eof(ectx);
283 eof=true;
284 }
285 else {
286 en265_push_image(ectx, input_image);
287 }
288
289
290
291 // encode images while more are available
292
293 en265_encode(ectx);
294
295
296 // write all pending packets
297
298 for (;;) {
299 en265_packet* pck = en265_get_packet(ectx,0);
300 if (pck==NULL)
301 break;
302
303 packet_sink.send_packet(pck->data, pck->length);
304
305 en265_free_packet(ectx,pck);
306 }
307 }
308
309
310
311 // --- print statistics ---
312
313 en265_print_logging((encoder_context*)ectx, "tb-split", NULL);
314
315
316 en265_free_encoder(ectx);
317
318 de265_free();
319
320 return 0;
321 }
5050
5151 int win32_cond_wait(win32_cond_t *cv, HANDLE *external_mutex)
5252 {
53 int last_waiter;
54
5355 // Avoid race conditions.
5456 EnterCriticalSection (&cv->waiters_count_lock_);
5557 cv->waiters_count_++;
6769 cv->waiters_count_--;
6870
6971 // Check to see if we're the last waiter after <pthread_cond_broadcast>.
70 int last_waiter = cv->was_broadcast_ && cv->waiters_count_ == 0;
72 last_waiter = cv->was_broadcast_ && cv->waiters_count_ == 0;
7173
7274 LeaveCriticalSection (&cv->waiters_count_lock_);
7375
8688
8789 int win32_cond_signal(win32_cond_t *cv)
8890 {
91 int have_waiters;
92
8993 EnterCriticalSection (&cv->waiters_count_lock_);
90 int have_waiters = cv->waiters_count_ > 0;
94 have_waiters = cv->waiters_count_ > 0;
9195 LeaveCriticalSection (&cv->waiters_count_lock_);
9296
9397 // If there aren't any waiters, then this is a no-op.
98102
99103 int win32_cond_broadcast(win32_cond_t *cv)
100104 {
105 int have_waiters = 0;
106
101107 // This is needed to ensure that <waiters_count_> and <was_broadcast_> are
102108 // consistent relative to each other.
103109 EnterCriticalSection (&cv->waiters_count_lock_);
104 int have_waiters = 0;
105110
106111 if (cv->waiters_count_ > 0) {
107112 // We are broadcasting, even if there is just one waiter...
0 set (libde265_sources
1 bitstream.cc
2 cabac.cc
3 de265.cc
4 deblock.cc
5 decctx.cc
6 nal-parser.cc
7 nal-parser.h
8 dpb.cc
9 dpb.h
10 image.cc
11 intrapred.cc
12 md5.cc
13 nal.cc
14 pps.cc
15 transform.cc
16 refpic.cc
17 sao.cc
18 scan.cc
19 sei.cc
20 slice.cc
21 sps.cc
22 util.cc
23 vps.cc
24 bitstream.h
25 cabac.h
26 deblock.h
27 decctx.h
28 image.h
29 intrapred.h
30 md5.h
31 nal.h
32 pps.h
33 transform.h
34 refpic.h
35 sao.h
36 scan.h
37 sei.h
38 slice.h
39 sps.h
40 util.h
41 vps.h
42 vui.h vui.cc
43 motion.cc motion.h
44 threads.cc threads.h
45 visualize.cc visualize.h
46 acceleration.h
47 fallback.cc fallback.h fallback-motion.cc fallback-motion.h
48 fallback-dct.h fallback-dct.cc
49 quality.cc quality.h
50 configparam.cc configparam.h
51 image-io.h image-io.cc
52 alloc_pool.h alloc_pool.cc
53 en265.h en265.cc
54 contextmodel.cc
55 )
56
57 if(MSVC)
58 set (libde265_sources
59 ${libde265_sources}
60 ../extra/win32cond.c
61 ../extra/win32cond.h
62 )
63 endif()
64
65 add_definitions(-DLIBDE265_EXPORTS)
66
67 add_library(${LIBDE265_LIBRARY_NAME} SHARED ${libde265_sources})
68
69 target_link_libraries(${LIBDE265_LIBRARY_NAME} ${CMAKE_THREAD_LIBS_INIT})
70
71 if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
72 SET_TARGET_PROPERTIES(${LIBDE265_LIBRARY_NAME} PROPERTIES COMPILE_FLAGS "-fPIC")
73 endif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
74
75 add_subdirectory (encoder)
76
77 target_link_libraries(${LIBDE265_LIBRARY_NAME} encoder)
78
79 if(SUPPORTS_SSE4_1)
80 add_definitions(-DHAVE_SSE4_1)
81 add_subdirectory (x86)
82 target_link_libraries(${LIBDE265_LIBRARY_NAME} x86)
83 endif()
2121 libde265_la_LIBADD = -lstdc++
2222
2323 libde265_la_SOURCES = \
24 acceleration.h \
25 alloc_pool.h \
26 alloc_pool.cc \
2427 bitstream.cc \
28 bitstream.h \
2529 cabac.cc \
30 cabac.h \
31 configparam.cc \
32 configparam.h \
33 contextmodel.cc \
34 contextmodel.h \
2635 de265.cc \
2736 deblock.cc \
37 deblock.h \
2838 decctx.cc \
29 nal-parser.cc \
30 nal-parser.h \
39 decctx.h \
40 en265.h \
41 en265.cc \
42 fallback.cc \
43 fallback.h \
44 fallback-dct.h \
45 fallback-dct.cc \
46 fallback-motion.cc \
47 fallback-motion.h \
3148 dpb.cc \
3249 dpb.h \
3350 image.cc \
51 image.h \
52 image-io.h \
53 image-io.cc \
3454 intrapred.cc \
55 intrapred.h \
3556 md5.cc \
57 md5.h \
58 motion.cc \
59 motion.h \
3660 nal.cc \
61 nal.h \
62 nal-parser.cc \
63 nal-parser.h \
3764 pps.cc \
65 pps.h \
66 quality.cc \
67 quality.h \
68 refpic.cc \
69 refpic.h \
70 sao.cc \
71 sao.h \
72 scan.cc \
73 scan.h \
74 sei.cc \
75 sei.h \
76 slice.cc \
77 slice.h \
78 sps.cc \
79 sps.h \
80 threads.cc \
81 threads.h \
3882 transform.cc \
39 refpic.cc \
40 sao.cc \
41 scan.cc \
42 sei.cc \
43 slice.cc \
44 sps.cc \
83 transform.h \
4584 util.cc \
85 util.h \
86 visualize.cc \
87 visualize.h \
4688 vps.cc \
47 bitstream.h \
48 cabac.h \
49 deblock.h \
50 decctx.h \
51 image.h \
52 intrapred.h \
53 md5.h \
54 nal.h \
55 pps.h \
56 transform.h \
57 refpic.h \
58 sao.h \
59 scan.h \
60 sei.h \
61 slice.h \
62 sps.h \
63 util.h \
6489 vps.h \
65 motion.cc motion.h \
66 threads.cc threads.h \
67 visualize.cc visualize.h \
68 acceleration.h \
69 fallback.cc fallback.h fallback-motion.cc fallback-motion.h \
70 fallback-dct.h fallback-dct.cc
90 vui.cc \
91 vui.h
92
93 SUBDIRS = encoder
94 libde265_la_LIBADD += encoder/libde265_encoder.la
7195
7296 if ENABLE_SSE_OPT
73 SUBDIRS = x86
97 SUBDIRS += x86
7498 libde265_la_LIBADD += x86/libde265_x86.la
99 endif
100
101 if ENABLE_ARM_OPT
102 SUBDIRS += arm
103 libde265_la_LIBADD += arm/libde265_arm.la
75104 endif
76105
77106 if MINGW
80109 endif
81110
82111 EXTRA_DIST = Makefile.vc7 \
112 CMakeLists.txt \
83113 ../extra/stdbool.h \
84114 ../extra/stdint.h
85115
8181 target_triplet = @target@
8282 @HAVE_VISIBILITY_TRUE@am__append_1 = -DHAVE_VISIBILITY
8383 @HAVE_VISIBILITY_TRUE@am__append_2 = -DHAVE_VISIBILITY
84 @ENABLE_SSE_OPT_TRUE@am__append_3 = x86/libde265_x86.la
85 @MINGW_TRUE@am__append_4 = ../extra/win32cond.c ../extra/win32cond.h
86 @MINGW_TRUE@am__append_5 = -no-undefined -static-libgcc -static-libstdc++
84 @ENABLE_SSE_OPT_TRUE@am__append_3 = x86
85 @ENABLE_SSE_OPT_TRUE@am__append_4 = x86/libde265_x86.la
86 @ENABLE_ARM_OPT_TRUE@am__append_5 = arm
87 @ENABLE_ARM_OPT_TRUE@am__append_6 = arm/libde265_arm.la
88 @MINGW_TRUE@am__append_7 = ../extra/win32cond.c ../extra/win32cond.h
89 @MINGW_TRUE@am__append_8 = -no-undefined -static-libgcc -static-libstdc++
8790 subdir = libde265
8891 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
8992 $(srcdir)/de265-version.h.in $(top_srcdir)/depcomp \
9093 $(libde265_la_HEADERS) COPYING
9194 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
9295 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
96 $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \
9397 $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
9498 $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
9599 $(top_srcdir)/m4/lt~obsolete.m4 \
96100 $(top_srcdir)/m4/m4_ax_check_compile_flag.m4 \
97 $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/configure.ac
101 $(top_srcdir)/configure.ac
98102 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
99103 $(ACLOCAL_M4)
100104 mkinstalldirs = $(install_sh) -d
130134 }
131135 am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libde265_ladir)"
132136 LTLIBRARIES = $(lib_LTLIBRARIES)
133 libde265_la_DEPENDENCIES = $(am__append_3)
134 am__libde265_la_SOURCES_DIST = bitstream.cc cabac.cc de265.cc \
135 deblock.cc decctx.cc nal-parser.cc nal-parser.h dpb.cc dpb.h \
136 image.cc intrapred.cc md5.cc nal.cc pps.cc transform.cc \
137 refpic.cc sao.cc scan.cc sei.cc slice.cc sps.cc util.cc vps.cc \
138 bitstream.h cabac.h deblock.h decctx.h image.h intrapred.h \
139 md5.h nal.h pps.h transform.h refpic.h sao.h scan.h sei.h \
140 slice.h sps.h util.h vps.h motion.cc motion.h threads.cc \
141 threads.h visualize.cc visualize.h acceleration.h fallback.cc \
142 fallback.h fallback-motion.cc fallback-motion.h fallback-dct.h \
143 fallback-dct.cc ../extra/win32cond.c ../extra/win32cond.h
137 libde265_la_DEPENDENCIES = encoder/libde265_encoder.la $(am__append_4) \
138 $(am__append_6)
139 am__libde265_la_SOURCES_DIST = acceleration.h alloc_pool.h \
140 alloc_pool.cc bitstream.cc bitstream.h cabac.cc cabac.h \
141 configparam.cc configparam.h contextmodel.cc contextmodel.h \
142 de265.cc deblock.cc deblock.h decctx.cc decctx.h en265.h \
143 en265.cc fallback.cc fallback.h fallback-dct.h fallback-dct.cc \
144 fallback-motion.cc fallback-motion.h dpb.cc dpb.h image.cc \
145 image.h image-io.h image-io.cc intrapred.cc intrapred.h md5.cc \
146 md5.h motion.cc motion.h nal.cc nal.h nal-parser.cc \
147 nal-parser.h pps.cc pps.h quality.cc quality.h refpic.cc \
148 refpic.h sao.cc sao.h scan.cc scan.h sei.cc sei.h slice.cc \
149 slice.h sps.cc sps.h threads.cc threads.h transform.cc \
150 transform.h util.cc util.h visualize.cc visualize.h vps.cc \
151 vps.h vui.cc vui.h ../extra/win32cond.c ../extra/win32cond.h
144152 am__dirstamp = $(am__leading_dot)dirstamp
145153 @MINGW_TRUE@am__objects_1 = ../extra/libde265_la-win32cond.lo
146 am_libde265_la_OBJECTS = libde265_la-bitstream.lo libde265_la-cabac.lo \
154 am_libde265_la_OBJECTS = libde265_la-alloc_pool.lo \
155 libde265_la-bitstream.lo libde265_la-cabac.lo \
156 libde265_la-configparam.lo libde265_la-contextmodel.lo \
147157 libde265_la-de265.lo libde265_la-deblock.lo \
148 libde265_la-decctx.lo libde265_la-nal-parser.lo \
149 libde265_la-dpb.lo libde265_la-image.lo \
150 libde265_la-intrapred.lo libde265_la-md5.lo libde265_la-nal.lo \
151 libde265_la-pps.lo libde265_la-transform.lo \
152 libde265_la-refpic.lo libde265_la-sao.lo libde265_la-scan.lo \
153 libde265_la-sei.lo libde265_la-slice.lo libde265_la-sps.lo \
154 libde265_la-util.lo libde265_la-vps.lo libde265_la-motion.lo \
155 libde265_la-threads.lo libde265_la-visualize.lo \
156 libde265_la-fallback.lo libde265_la-fallback-motion.lo \
157 libde265_la-fallback-dct.lo $(am__objects_1)
158 libde265_la-decctx.lo libde265_la-en265.lo \
159 libde265_la-fallback.lo libde265_la-fallback-dct.lo \
160 libde265_la-fallback-motion.lo libde265_la-dpb.lo \
161 libde265_la-image.lo libde265_la-image-io.lo \
162 libde265_la-intrapred.lo libde265_la-md5.lo \
163 libde265_la-motion.lo libde265_la-nal.lo \
164 libde265_la-nal-parser.lo libde265_la-pps.lo \
165 libde265_la-quality.lo libde265_la-refpic.lo \
166 libde265_la-sao.lo libde265_la-scan.lo libde265_la-sei.lo \
167 libde265_la-slice.lo libde265_la-sps.lo libde265_la-threads.lo \
168 libde265_la-transform.lo libde265_la-util.lo \
169 libde265_la-visualize.lo libde265_la-vps.lo libde265_la-vui.lo \
170 $(am__objects_1)
158171 libde265_la_OBJECTS = $(am_libde265_la_OBJECTS)
159172 AM_V_lt = $(am__v_lt_@AM_V@)
160173 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
258271 done | $(am__uniquify_input)`
259272 ETAGS = etags
260273 CTAGS = ctags
261 DIST_SUBDIRS = x86
274 DIST_SUBDIRS = encoder x86 arm
262275 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
263276 am__relativize = \
264277 dir0=`pwd`; \
286299 done; \
287300 reldir="$$dir2"
288301 ACLOCAL = @ACLOCAL@
302 ALLOCA = @ALLOCA@
289303 AMTAR = @AMTAR@
290304 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
291305 AR = @AR@
294308 AUTOMAKE = @AUTOMAKE@
295309 AWK = @AWK@
296310 CC = @CC@
311 CCAS = @CCAS@
312 CCASDEPMODE = @CCASDEPMODE@
313 CCASFLAGS = @CCASFLAGS@
297314 CCDEPMODE = @CCDEPMODE@
298315 CFLAGS = @CFLAGS@
299 CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
300316 CPP = @CPP@
301317 CPPFLAGS = @CPPFLAGS@
302318 CXX = @CXX@
316332 EXEEXT = @EXEEXT@
317333 FGREP = @FGREP@
318334 GREP = @GREP@
319 HAVE_VISIBILITY = @HAVE_VISIBILITY@
335 HAVE_CXX11 = @HAVE_CXX11@
320336 INSTALL = @INSTALL@
321337 INSTALL_DATA = @INSTALL_DATA@
322338 INSTALL_PROGRAM = @INSTALL_PROGRAM@
439455 $(am__append_2)
440456 libde265_la_LDFLAGS = -version-info \
441457 $(LIBDE265_CURRENT):$(LIBDE265_REVISION):$(LIBDE265_AGE) \
442 $(am__append_5)
443 libde265_la_LIBADD = -lstdc++ $(am__append_3)
444 libde265_la_SOURCES = bitstream.cc cabac.cc de265.cc deblock.cc \
445 decctx.cc nal-parser.cc nal-parser.h dpb.cc dpb.h image.cc \
446 intrapred.cc md5.cc nal.cc pps.cc transform.cc refpic.cc \
447 sao.cc scan.cc sei.cc slice.cc sps.cc util.cc vps.cc \
448 bitstream.h cabac.h deblock.h decctx.h image.h intrapred.h \
449 md5.h nal.h pps.h transform.h refpic.h sao.h scan.h sei.h \
450 slice.h sps.h util.h vps.h motion.cc motion.h threads.cc \
451 threads.h visualize.cc visualize.h acceleration.h fallback.cc \
452 fallback.h fallback-motion.cc fallback-motion.h fallback-dct.h \
453 fallback-dct.cc $(am__append_4)
454 @ENABLE_SSE_OPT_TRUE@SUBDIRS = x86
458 $(am__append_8)
459 libde265_la_LIBADD = -lstdc++ encoder/libde265_encoder.la \
460 $(am__append_4) $(am__append_6)
461 libde265_la_SOURCES = acceleration.h alloc_pool.h alloc_pool.cc \
462 bitstream.cc bitstream.h cabac.cc cabac.h configparam.cc \
463 configparam.h contextmodel.cc contextmodel.h de265.cc \
464 deblock.cc deblock.h decctx.cc decctx.h en265.h en265.cc \
465 fallback.cc fallback.h fallback-dct.h fallback-dct.cc \
466 fallback-motion.cc fallback-motion.h dpb.cc dpb.h image.cc \
467 image.h image-io.h image-io.cc intrapred.cc intrapred.h md5.cc \
468 md5.h motion.cc motion.h nal.cc nal.h nal-parser.cc \
469 nal-parser.h pps.cc pps.h quality.cc quality.h refpic.cc \
470 refpic.h sao.cc sao.h scan.cc scan.h sei.cc sei.h slice.cc \
471 slice.h sps.cc sps.h threads.cc threads.h transform.cc \
472 transform.h util.cc util.h visualize.cc visualize.h vps.cc \
473 vps.h vui.cc vui.h $(am__append_7)
474 SUBDIRS = encoder $(am__append_3) $(am__append_5)
455475 EXTRA_DIST = Makefile.vc7 \
476 CMakeLists.txt \
456477 ../extra/stdbool.h \
457478 ../extra/stdint.h
458479
552573 -rm -f *.tab.c
553574
554575 @AMDEP_TRUE@@am__include@ @am__quote@../extra/$(DEPDIR)/libde265_la-win32cond.Plo@am__quote@
576 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-alloc_pool.Plo@am__quote@
555577 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-bitstream.Plo@am__quote@
556578 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-cabac.Plo@am__quote@
579 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-configparam.Plo@am__quote@
580 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-contextmodel.Plo@am__quote@
557581 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-de265.Plo@am__quote@
558582 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-deblock.Plo@am__quote@
559583 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-decctx.Plo@am__quote@
560584 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-dpb.Plo@am__quote@
585 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-en265.Plo@am__quote@
561586 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-fallback-dct.Plo@am__quote@
562587 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-fallback-motion.Plo@am__quote@
563588 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-fallback.Plo@am__quote@
589 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-image-io.Plo@am__quote@
564590 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-image.Plo@am__quote@
565591 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-intrapred.Plo@am__quote@
566592 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-md5.Plo@am__quote@
568594 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-nal-parser.Plo@am__quote@
569595 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-nal.Plo@am__quote@
570596 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-pps.Plo@am__quote@
597 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-quality.Plo@am__quote@
571598 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-refpic.Plo@am__quote@
572599 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-sao.Plo@am__quote@
573600 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-scan.Plo@am__quote@
579606 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-util.Plo@am__quote@
580607 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-visualize.Plo@am__quote@
581608 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-vps.Plo@am__quote@
609 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_la-vui.Plo@am__quote@
582610
583611 .c.o:
584612 @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
635663 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
636664 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
637665
666 libde265_la-alloc_pool.lo: alloc_pool.cc
667 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-alloc_pool.lo -MD -MP -MF $(DEPDIR)/libde265_la-alloc_pool.Tpo -c -o libde265_la-alloc_pool.lo `test -f 'alloc_pool.cc' || echo '$(srcdir)/'`alloc_pool.cc
668 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-alloc_pool.Tpo $(DEPDIR)/libde265_la-alloc_pool.Plo
669 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='alloc_pool.cc' object='libde265_la-alloc_pool.lo' libtool=yes @AMDEPBACKSLASH@
670 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
671 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-alloc_pool.lo `test -f 'alloc_pool.cc' || echo '$(srcdir)/'`alloc_pool.cc
672
638673 libde265_la-bitstream.lo: bitstream.cc
639674 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-bitstream.lo -MD -MP -MF $(DEPDIR)/libde265_la-bitstream.Tpo -c -o libde265_la-bitstream.lo `test -f 'bitstream.cc' || echo '$(srcdir)/'`bitstream.cc
640675 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-bitstream.Tpo $(DEPDIR)/libde265_la-bitstream.Plo
649684 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
650685 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-cabac.lo `test -f 'cabac.cc' || echo '$(srcdir)/'`cabac.cc
651686
687 libde265_la-configparam.lo: configparam.cc
688 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-configparam.lo -MD -MP -MF $(DEPDIR)/libde265_la-configparam.Tpo -c -o libde265_la-configparam.lo `test -f 'configparam.cc' || echo '$(srcdir)/'`configparam.cc
689 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-configparam.Tpo $(DEPDIR)/libde265_la-configparam.Plo
690 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='configparam.cc' object='libde265_la-configparam.lo' libtool=yes @AMDEPBACKSLASH@
691 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
692 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-configparam.lo `test -f 'configparam.cc' || echo '$(srcdir)/'`configparam.cc
693
694 libde265_la-contextmodel.lo: contextmodel.cc
695 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-contextmodel.lo -MD -MP -MF $(DEPDIR)/libde265_la-contextmodel.Tpo -c -o libde265_la-contextmodel.lo `test -f 'contextmodel.cc' || echo '$(srcdir)/'`contextmodel.cc
696 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-contextmodel.Tpo $(DEPDIR)/libde265_la-contextmodel.Plo
697 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='contextmodel.cc' object='libde265_la-contextmodel.lo' libtool=yes @AMDEPBACKSLASH@
698 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
699 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-contextmodel.lo `test -f 'contextmodel.cc' || echo '$(srcdir)/'`contextmodel.cc
700
652701 libde265_la-de265.lo: de265.cc
653702 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-de265.lo -MD -MP -MF $(DEPDIR)/libde265_la-de265.Tpo -c -o libde265_la-de265.lo `test -f 'de265.cc' || echo '$(srcdir)/'`de265.cc
654703 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-de265.Tpo $(DEPDIR)/libde265_la-de265.Plo
670719 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
671720 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-decctx.lo `test -f 'decctx.cc' || echo '$(srcdir)/'`decctx.cc
672721
722 libde265_la-en265.lo: en265.cc
723 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-en265.lo -MD -MP -MF $(DEPDIR)/libde265_la-en265.Tpo -c -o libde265_la-en265.lo `test -f 'en265.cc' || echo '$(srcdir)/'`en265.cc
724 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-en265.Tpo $(DEPDIR)/libde265_la-en265.Plo
725 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='en265.cc' object='libde265_la-en265.lo' libtool=yes @AMDEPBACKSLASH@
726 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
727 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-en265.lo `test -f 'en265.cc' || echo '$(srcdir)/'`en265.cc
728
729 libde265_la-fallback.lo: fallback.cc
730 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-fallback.lo -MD -MP -MF $(DEPDIR)/libde265_la-fallback.Tpo -c -o libde265_la-fallback.lo `test -f 'fallback.cc' || echo '$(srcdir)/'`fallback.cc
731 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-fallback.Tpo $(DEPDIR)/libde265_la-fallback.Plo
732 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='fallback.cc' object='libde265_la-fallback.lo' libtool=yes @AMDEPBACKSLASH@
733 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
734 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-fallback.lo `test -f 'fallback.cc' || echo '$(srcdir)/'`fallback.cc
735
736 libde265_la-fallback-dct.lo: fallback-dct.cc
737 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-fallback-dct.lo -MD -MP -MF $(DEPDIR)/libde265_la-fallback-dct.Tpo -c -o libde265_la-fallback-dct.lo `test -f 'fallback-dct.cc' || echo '$(srcdir)/'`fallback-dct.cc
738 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-fallback-dct.Tpo $(DEPDIR)/libde265_la-fallback-dct.Plo
739 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='fallback-dct.cc' object='libde265_la-fallback-dct.lo' libtool=yes @AMDEPBACKSLASH@
740 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
741 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-fallback-dct.lo `test -f 'fallback-dct.cc' || echo '$(srcdir)/'`fallback-dct.cc
742
743 libde265_la-fallback-motion.lo: fallback-motion.cc
744 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-fallback-motion.lo -MD -MP -MF $(DEPDIR)/libde265_la-fallback-motion.Tpo -c -o libde265_la-fallback-motion.lo `test -f 'fallback-motion.cc' || echo '$(srcdir)/'`fallback-motion.cc
745 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-fallback-motion.Tpo $(DEPDIR)/libde265_la-fallback-motion.Plo
746 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='fallback-motion.cc' object='libde265_la-fallback-motion.lo' libtool=yes @AMDEPBACKSLASH@
747 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
748 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-fallback-motion.lo `test -f 'fallback-motion.cc' || echo '$(srcdir)/'`fallback-motion.cc
749
750 libde265_la-dpb.lo: dpb.cc
751 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-dpb.lo -MD -MP -MF $(DEPDIR)/libde265_la-dpb.Tpo -c -o libde265_la-dpb.lo `test -f 'dpb.cc' || echo '$(srcdir)/'`dpb.cc
752 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-dpb.Tpo $(DEPDIR)/libde265_la-dpb.Plo
753 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='dpb.cc' object='libde265_la-dpb.lo' libtool=yes @AMDEPBACKSLASH@
754 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
755 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-dpb.lo `test -f 'dpb.cc' || echo '$(srcdir)/'`dpb.cc
756
757 libde265_la-image.lo: image.cc
758 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-image.lo -MD -MP -MF $(DEPDIR)/libde265_la-image.Tpo -c -o libde265_la-image.lo `test -f 'image.cc' || echo '$(srcdir)/'`image.cc
759 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-image.Tpo $(DEPDIR)/libde265_la-image.Plo
760 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='image.cc' object='libde265_la-image.lo' libtool=yes @AMDEPBACKSLASH@
761 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
762 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-image.lo `test -f 'image.cc' || echo '$(srcdir)/'`image.cc
763
764 libde265_la-image-io.lo: image-io.cc
765 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-image-io.lo -MD -MP -MF $(DEPDIR)/libde265_la-image-io.Tpo -c -o libde265_la-image-io.lo `test -f 'image-io.cc' || echo '$(srcdir)/'`image-io.cc
766 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-image-io.Tpo $(DEPDIR)/libde265_la-image-io.Plo
767 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='image-io.cc' object='libde265_la-image-io.lo' libtool=yes @AMDEPBACKSLASH@
768 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
769 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-image-io.lo `test -f 'image-io.cc' || echo '$(srcdir)/'`image-io.cc
770
771 libde265_la-intrapred.lo: intrapred.cc
772 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-intrapred.lo -MD -MP -MF $(DEPDIR)/libde265_la-intrapred.Tpo -c -o libde265_la-intrapred.lo `test -f 'intrapred.cc' || echo '$(srcdir)/'`intrapred.cc
773 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-intrapred.Tpo $(DEPDIR)/libde265_la-intrapred.Plo
774 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='intrapred.cc' object='libde265_la-intrapred.lo' libtool=yes @AMDEPBACKSLASH@
775 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
776 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-intrapred.lo `test -f 'intrapred.cc' || echo '$(srcdir)/'`intrapred.cc
777
778 libde265_la-md5.lo: md5.cc
779 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-md5.lo -MD -MP -MF $(DEPDIR)/libde265_la-md5.Tpo -c -o libde265_la-md5.lo `test -f 'md5.cc' || echo '$(srcdir)/'`md5.cc
780 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-md5.Tpo $(DEPDIR)/libde265_la-md5.Plo
781 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='md5.cc' object='libde265_la-md5.lo' libtool=yes @AMDEPBACKSLASH@
782 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
783 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-md5.lo `test -f 'md5.cc' || echo '$(srcdir)/'`md5.cc
784
785 libde265_la-motion.lo: motion.cc
786 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-motion.lo -MD -MP -MF $(DEPDIR)/libde265_la-motion.Tpo -c -o libde265_la-motion.lo `test -f 'motion.cc' || echo '$(srcdir)/'`motion.cc
787 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-motion.Tpo $(DEPDIR)/libde265_la-motion.Plo
788 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='motion.cc' object='libde265_la-motion.lo' libtool=yes @AMDEPBACKSLASH@
789 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
790 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-motion.lo `test -f 'motion.cc' || echo '$(srcdir)/'`motion.cc
791
792 libde265_la-nal.lo: nal.cc
793 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-nal.lo -MD -MP -MF $(DEPDIR)/libde265_la-nal.Tpo -c -o libde265_la-nal.lo `test -f 'nal.cc' || echo '$(srcdir)/'`nal.cc
794 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-nal.Tpo $(DEPDIR)/libde265_la-nal.Plo
795 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='nal.cc' object='libde265_la-nal.lo' libtool=yes @AMDEPBACKSLASH@
796 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
797 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-nal.lo `test -f 'nal.cc' || echo '$(srcdir)/'`nal.cc
798
673799 libde265_la-nal-parser.lo: nal-parser.cc
674800 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-nal-parser.lo -MD -MP -MF $(DEPDIR)/libde265_la-nal-parser.Tpo -c -o libde265_la-nal-parser.lo `test -f 'nal-parser.cc' || echo '$(srcdir)/'`nal-parser.cc
675801 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-nal-parser.Tpo $(DEPDIR)/libde265_la-nal-parser.Plo
677803 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
678804 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-nal-parser.lo `test -f 'nal-parser.cc' || echo '$(srcdir)/'`nal-parser.cc
679805
680 libde265_la-dpb.lo: dpb.cc
681 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-dpb.lo -MD -MP -MF $(DEPDIR)/libde265_la-dpb.Tpo -c -o libde265_la-dpb.lo `test -f 'dpb.cc' || echo '$(srcdir)/'`dpb.cc
682 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-dpb.Tpo $(DEPDIR)/libde265_la-dpb.Plo
683 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='dpb.cc' object='libde265_la-dpb.lo' libtool=yes @AMDEPBACKSLASH@
684 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
685 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-dpb.lo `test -f 'dpb.cc' || echo '$(srcdir)/'`dpb.cc
686
687 libde265_la-image.lo: image.cc
688 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-image.lo -MD -MP -MF $(DEPDIR)/libde265_la-image.Tpo -c -o libde265_la-image.lo `test -f 'image.cc' || echo '$(srcdir)/'`image.cc
689 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-image.Tpo $(DEPDIR)/libde265_la-image.Plo
690 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='image.cc' object='libde265_la-image.lo' libtool=yes @AMDEPBACKSLASH@
691 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
692 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-image.lo `test -f 'image.cc' || echo '$(srcdir)/'`image.cc
693
694 libde265_la-intrapred.lo: intrapred.cc
695 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-intrapred.lo -MD -MP -MF $(DEPDIR)/libde265_la-intrapred.Tpo -c -o libde265_la-intrapred.lo `test -f 'intrapred.cc' || echo '$(srcdir)/'`intrapred.cc
696 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-intrapred.Tpo $(DEPDIR)/libde265_la-intrapred.Plo
697 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='intrapred.cc' object='libde265_la-intrapred.lo' libtool=yes @AMDEPBACKSLASH@
698 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
699 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-intrapred.lo `test -f 'intrapred.cc' || echo '$(srcdir)/'`intrapred.cc
700
701 libde265_la-md5.lo: md5.cc
702 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-md5.lo -MD -MP -MF $(DEPDIR)/libde265_la-md5.Tpo -c -o libde265_la-md5.lo `test -f 'md5.cc' || echo '$(srcdir)/'`md5.cc
703 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-md5.Tpo $(DEPDIR)/libde265_la-md5.Plo
704 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='md5.cc' object='libde265_la-md5.lo' libtool=yes @AMDEPBACKSLASH@
705 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
706 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-md5.lo `test -f 'md5.cc' || echo '$(srcdir)/'`md5.cc
707
708 libde265_la-nal.lo: nal.cc
709 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-nal.lo -MD -MP -MF $(DEPDIR)/libde265_la-nal.Tpo -c -o libde265_la-nal.lo `test -f 'nal.cc' || echo '$(srcdir)/'`nal.cc
710 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-nal.Tpo $(DEPDIR)/libde265_la-nal.Plo
711 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='nal.cc' object='libde265_la-nal.lo' libtool=yes @AMDEPBACKSLASH@
712 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
713 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-nal.lo `test -f 'nal.cc' || echo '$(srcdir)/'`nal.cc
714
715806 libde265_la-pps.lo: pps.cc
716807 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-pps.lo -MD -MP -MF $(DEPDIR)/libde265_la-pps.Tpo -c -o libde265_la-pps.lo `test -f 'pps.cc' || echo '$(srcdir)/'`pps.cc
717808 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-pps.Tpo $(DEPDIR)/libde265_la-pps.Plo
719810 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
720811 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-pps.lo `test -f 'pps.cc' || echo '$(srcdir)/'`pps.cc
721812
813 libde265_la-quality.lo: quality.cc
814 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-quality.lo -MD -MP -MF $(DEPDIR)/libde265_la-quality.Tpo -c -o libde265_la-quality.lo `test -f 'quality.cc' || echo '$(srcdir)/'`quality.cc
815 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-quality.Tpo $(DEPDIR)/libde265_la-quality.Plo
816 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='quality.cc' object='libde265_la-quality.lo' libtool=yes @AMDEPBACKSLASH@
817 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
818 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-quality.lo `test -f 'quality.cc' || echo '$(srcdir)/'`quality.cc
819
820 libde265_la-refpic.lo: refpic.cc
821 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-refpic.lo -MD -MP -MF $(DEPDIR)/libde265_la-refpic.Tpo -c -o libde265_la-refpic.lo `test -f 'refpic.cc' || echo '$(srcdir)/'`refpic.cc
822 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-refpic.Tpo $(DEPDIR)/libde265_la-refpic.Plo
823 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='refpic.cc' object='libde265_la-refpic.lo' libtool=yes @AMDEPBACKSLASH@
824 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
825 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-refpic.lo `test -f 'refpic.cc' || echo '$(srcdir)/'`refpic.cc
826
827 libde265_la-sao.lo: sao.cc
828 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-sao.lo -MD -MP -MF $(DEPDIR)/libde265_la-sao.Tpo -c -o libde265_la-sao.lo `test -f 'sao.cc' || echo '$(srcdir)/'`sao.cc
829 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-sao.Tpo $(DEPDIR)/libde265_la-sao.Plo
830 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='sao.cc' object='libde265_la-sao.lo' libtool=yes @AMDEPBACKSLASH@
831 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
832 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-sao.lo `test -f 'sao.cc' || echo '$(srcdir)/'`sao.cc
833
834 libde265_la-scan.lo: scan.cc
835 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-scan.lo -MD -MP -MF $(DEPDIR)/libde265_la-scan.Tpo -c -o libde265_la-scan.lo `test -f 'scan.cc' || echo '$(srcdir)/'`scan.cc
836 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-scan.Tpo $(DEPDIR)/libde265_la-scan.Plo
837 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='scan.cc' object='libde265_la-scan.lo' libtool=yes @AMDEPBACKSLASH@
838 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
839 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-scan.lo `test -f 'scan.cc' || echo '$(srcdir)/'`scan.cc
840
841 libde265_la-sei.lo: sei.cc
842 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-sei.lo -MD -MP -MF $(DEPDIR)/libde265_la-sei.Tpo -c -o libde265_la-sei.lo `test -f 'sei.cc' || echo '$(srcdir)/'`sei.cc
843 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-sei.Tpo $(DEPDIR)/libde265_la-sei.Plo
844 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='sei.cc' object='libde265_la-sei.lo' libtool=yes @AMDEPBACKSLASH@
845 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
846 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-sei.lo `test -f 'sei.cc' || echo '$(srcdir)/'`sei.cc
847
848 libde265_la-slice.lo: slice.cc
849 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-slice.lo -MD -MP -MF $(DEPDIR)/libde265_la-slice.Tpo -c -o libde265_la-slice.lo `test -f 'slice.cc' || echo '$(srcdir)/'`slice.cc
850 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-slice.Tpo $(DEPDIR)/libde265_la-slice.Plo
851 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='slice.cc' object='libde265_la-slice.lo' libtool=yes @AMDEPBACKSLASH@
852 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
853 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-slice.lo `test -f 'slice.cc' || echo '$(srcdir)/'`slice.cc
854
855 libde265_la-sps.lo: sps.cc
856 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-sps.lo -MD -MP -MF $(DEPDIR)/libde265_la-sps.Tpo -c -o libde265_la-sps.lo `test -f 'sps.cc' || echo '$(srcdir)/'`sps.cc
857 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-sps.Tpo $(DEPDIR)/libde265_la-sps.Plo
858 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='sps.cc' object='libde265_la-sps.lo' libtool=yes @AMDEPBACKSLASH@
859 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
860 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-sps.lo `test -f 'sps.cc' || echo '$(srcdir)/'`sps.cc
861
862 libde265_la-threads.lo: threads.cc
863 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-threads.lo -MD -MP -MF $(DEPDIR)/libde265_la-threads.Tpo -c -o libde265_la-threads.lo `test -f 'threads.cc' || echo '$(srcdir)/'`threads.cc
864 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-threads.Tpo $(DEPDIR)/libde265_la-threads.Plo
865 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='threads.cc' object='libde265_la-threads.lo' libtool=yes @AMDEPBACKSLASH@
866 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
867 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-threads.lo `test -f 'threads.cc' || echo '$(srcdir)/'`threads.cc
868
722869 libde265_la-transform.lo: transform.cc
723870 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-transform.lo -MD -MP -MF $(DEPDIR)/libde265_la-transform.Tpo -c -o libde265_la-transform.lo `test -f 'transform.cc' || echo '$(srcdir)/'`transform.cc
724871 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-transform.Tpo $(DEPDIR)/libde265_la-transform.Plo
726873 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
727874 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-transform.lo `test -f 'transform.cc' || echo '$(srcdir)/'`transform.cc
728875
729 libde265_la-refpic.lo: refpic.cc
730 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-refpic.lo -MD -MP -MF $(DEPDIR)/libde265_la-refpic.Tpo -c -o libde265_la-refpic.lo `test -f 'refpic.cc' || echo '$(srcdir)/'`refpic.cc
731 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-refpic.Tpo $(DEPDIR)/libde265_la-refpic.Plo
732 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='refpic.cc' object='libde265_la-refpic.lo' libtool=yes @AMDEPBACKSLASH@
733 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
734 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-refpic.lo `test -f 'refpic.cc' || echo '$(srcdir)/'`refpic.cc
735
736 libde265_la-sao.lo: sao.cc
737 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-sao.lo -MD -MP -MF $(DEPDIR)/libde265_la-sao.Tpo -c -o libde265_la-sao.lo `test -f 'sao.cc' || echo '$(srcdir)/'`sao.cc
738 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-sao.Tpo $(DEPDIR)/libde265_la-sao.Plo
739 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='sao.cc' object='libde265_la-sao.lo' libtool=yes @AMDEPBACKSLASH@
740 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
741 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-sao.lo `test -f 'sao.cc' || echo '$(srcdir)/'`sao.cc
742
743 libde265_la-scan.lo: scan.cc
744 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-scan.lo -MD -MP -MF $(DEPDIR)/libde265_la-scan.Tpo -c -o libde265_la-scan.lo `test -f 'scan.cc' || echo '$(srcdir)/'`scan.cc
745 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-scan.Tpo $(DEPDIR)/libde265_la-scan.Plo
746 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='scan.cc' object='libde265_la-scan.lo' libtool=yes @AMDEPBACKSLASH@
747 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
748 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-scan.lo `test -f 'scan.cc' || echo '$(srcdir)/'`scan.cc
749
750 libde265_la-sei.lo: sei.cc
751 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-sei.lo -MD -MP -MF $(DEPDIR)/libde265_la-sei.Tpo -c -o libde265_la-sei.lo `test -f 'sei.cc' || echo '$(srcdir)/'`sei.cc
752 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-sei.Tpo $(DEPDIR)/libde265_la-sei.Plo
753 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='sei.cc' object='libde265_la-sei.lo' libtool=yes @AMDEPBACKSLASH@
754 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
755 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-sei.lo `test -f 'sei.cc' || echo '$(srcdir)/'`sei.cc
756
757 libde265_la-slice.lo: slice.cc
758 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-slice.lo -MD -MP -MF $(DEPDIR)/libde265_la-slice.Tpo -c -o libde265_la-slice.lo `test -f 'slice.cc' || echo '$(srcdir)/'`slice.cc
759 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-slice.Tpo $(DEPDIR)/libde265_la-slice.Plo
760 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='slice.cc' object='libde265_la-slice.lo' libtool=yes @AMDEPBACKSLASH@
761 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
762 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-slice.lo `test -f 'slice.cc' || echo '$(srcdir)/'`slice.cc
763
764 libde265_la-sps.lo: sps.cc
765 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-sps.lo -MD -MP -MF $(DEPDIR)/libde265_la-sps.Tpo -c -o libde265_la-sps.lo `test -f 'sps.cc' || echo '$(srcdir)/'`sps.cc
766 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-sps.Tpo $(DEPDIR)/libde265_la-sps.Plo
767 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='sps.cc' object='libde265_la-sps.lo' libtool=yes @AMDEPBACKSLASH@
768 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
769 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-sps.lo `test -f 'sps.cc' || echo '$(srcdir)/'`sps.cc
770
771876 libde265_la-util.lo: util.cc
772877 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-util.lo -MD -MP -MF $(DEPDIR)/libde265_la-util.Tpo -c -o libde265_la-util.lo `test -f 'util.cc' || echo '$(srcdir)/'`util.cc
773878 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-util.Tpo $(DEPDIR)/libde265_la-util.Plo
775880 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
776881 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-util.lo `test -f 'util.cc' || echo '$(srcdir)/'`util.cc
777882
883 libde265_la-visualize.lo: visualize.cc
884 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-visualize.lo -MD -MP -MF $(DEPDIR)/libde265_la-visualize.Tpo -c -o libde265_la-visualize.lo `test -f 'visualize.cc' || echo '$(srcdir)/'`visualize.cc
885 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-visualize.Tpo $(DEPDIR)/libde265_la-visualize.Plo
886 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='visualize.cc' object='libde265_la-visualize.lo' libtool=yes @AMDEPBACKSLASH@
887 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
888 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-visualize.lo `test -f 'visualize.cc' || echo '$(srcdir)/'`visualize.cc
889
778890 libde265_la-vps.lo: vps.cc
779891 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-vps.lo -MD -MP -MF $(DEPDIR)/libde265_la-vps.Tpo -c -o libde265_la-vps.lo `test -f 'vps.cc' || echo '$(srcdir)/'`vps.cc
780892 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-vps.Tpo $(DEPDIR)/libde265_la-vps.Plo
782894 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
783895 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-vps.lo `test -f 'vps.cc' || echo '$(srcdir)/'`vps.cc
784896
785 libde265_la-motion.lo: motion.cc
786 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-motion.lo -MD -MP -MF $(DEPDIR)/libde265_la-motion.Tpo -c -o libde265_la-motion.lo `test -f 'motion.cc' || echo '$(srcdir)/'`motion.cc
787 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-motion.Tpo $(DEPDIR)/libde265_la-motion.Plo
788 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='motion.cc' object='libde265_la-motion.lo' libtool=yes @AMDEPBACKSLASH@
789 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
790 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-motion.lo `test -f 'motion.cc' || echo '$(srcdir)/'`motion.cc
791
792 libde265_la-threads.lo: threads.cc
793 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-threads.lo -MD -MP -MF $(DEPDIR)/libde265_la-threads.Tpo -c -o libde265_la-threads.lo `test -f 'threads.cc' || echo '$(srcdir)/'`threads.cc
794 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-threads.Tpo $(DEPDIR)/libde265_la-threads.Plo
795 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='threads.cc' object='libde265_la-threads.lo' libtool=yes @AMDEPBACKSLASH@
796 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
797 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-threads.lo `test -f 'threads.cc' || echo '$(srcdir)/'`threads.cc
798
799 libde265_la-visualize.lo: visualize.cc
800 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-visualize.lo -MD -MP -MF $(DEPDIR)/libde265_la-visualize.Tpo -c -o libde265_la-visualize.lo `test -f 'visualize.cc' || echo '$(srcdir)/'`visualize.cc
801 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-visualize.Tpo $(DEPDIR)/libde265_la-visualize.Plo
802 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='visualize.cc' object='libde265_la-visualize.lo' libtool=yes @AMDEPBACKSLASH@
803 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
804 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-visualize.lo `test -f 'visualize.cc' || echo '$(srcdir)/'`visualize.cc
805
806 libde265_la-fallback.lo: fallback.cc
807 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-fallback.lo -MD -MP -MF $(DEPDIR)/libde265_la-fallback.Tpo -c -o libde265_la-fallback.lo `test -f 'fallback.cc' || echo '$(srcdir)/'`fallback.cc
808 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-fallback.Tpo $(DEPDIR)/libde265_la-fallback.Plo
809 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='fallback.cc' object='libde265_la-fallback.lo' libtool=yes @AMDEPBACKSLASH@
810 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
811 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-fallback.lo `test -f 'fallback.cc' || echo '$(srcdir)/'`fallback.cc
812
813 libde265_la-fallback-motion.lo: fallback-motion.cc
814 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-fallback-motion.lo -MD -MP -MF $(DEPDIR)/libde265_la-fallback-motion.Tpo -c -o libde265_la-fallback-motion.lo `test -f 'fallback-motion.cc' || echo '$(srcdir)/'`fallback-motion.cc
815 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-fallback-motion.Tpo $(DEPDIR)/libde265_la-fallback-motion.Plo
816 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='fallback-motion.cc' object='libde265_la-fallback-motion.lo' libtool=yes @AMDEPBACKSLASH@
817 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
818 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-fallback-motion.lo `test -f 'fallback-motion.cc' || echo '$(srcdir)/'`fallback-motion.cc
819
820 libde265_la-fallback-dct.lo: fallback-dct.cc
821 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-fallback-dct.lo -MD -MP -MF $(DEPDIR)/libde265_la-fallback-dct.Tpo -c -o libde265_la-fallback-dct.lo `test -f 'fallback-dct.cc' || echo '$(srcdir)/'`fallback-dct.cc
822 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-fallback-dct.Tpo $(DEPDIR)/libde265_la-fallback-dct.Plo
823 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='fallback-dct.cc' object='libde265_la-fallback-dct.lo' libtool=yes @AMDEPBACKSLASH@
824 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
825 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-fallback-dct.lo `test -f 'fallback-dct.cc' || echo '$(srcdir)/'`fallback-dct.cc
897 libde265_la-vui.lo: vui.cc
898 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_la-vui.lo -MD -MP -MF $(DEPDIR)/libde265_la-vui.Tpo -c -o libde265_la-vui.lo `test -f 'vui.cc' || echo '$(srcdir)/'`vui.cc
899 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_la-vui.Tpo $(DEPDIR)/libde265_la-vui.Plo
900 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='vui.cc' object='libde265_la-vui.lo' libtool=yes @AMDEPBACKSLASH@
901 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
902 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libde265_la_CPPFLAGS) $(CPPFLAGS) $(libde265_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_la-vui.lo `test -f 'vui.cc' || echo '$(srcdir)/'`vui.cc
826903
827904 mostlyclean-libtool:
828905 -rm -f *.lo
11 # Makefile for Microsoft Visual Studio 2003
22 #
33 CFLAGS=/I..\extra /I.. /I.
4 CC=cl /nologo
4 CC=cl /nologo
55 LINK=link /nologo /subsystem:console
66 DEFINES=/DWIN32 /D_WIN32_WINNT=0x0400 /DNDEBUG /DLIBDE265_EXPORTS /D_CRT_SECURE_NO_WARNINGS /DHAVE_SSE4_1 /DNOMINMAX
77
2929 CFLAGS=$(CFLAGS) $(DEFINES)
3030
3131 OBJS=\
32 alloc_pool.obj \
3233 bitstream.obj \
3334 cabac.obj \
35 configparam.obj \
36 contextmodel.obj \
3437 de265.obj \
3538 deblock.obj \
3639 decctx.obj \
3740 dpb.obj \
41 en265.obj \
3842 fallback-dct.obj \
3943 fallback-motion.obj \
4044 fallback.obj \
4145 image.obj \
46 image-io.obj \
4247 intrapred.obj \
4348 md5.obj \
4449 motion.obj \
4550 nal.obj \
4651 nal-parser.obj \
4752 pps.obj \
53 quality.obj \
4854 refpic.obj \
4955 sao.obj \
5056 scan.obj \
5662 util.obj \
5763 visualize.obj \
5864 vps.obj \
65 vui.obj \
66 encoder\analyze.obj \
67 encoder\encode.obj \
68 encoder\encoder-context.obj \
69 encoder\encoder-params.obj \
70 encoder\encpicbuf.obj \
71 encoder\sop.obj \
72 encoder\algo\algo.obj \
73 encoder\algo\cb-interpartmode.obj \
74 encoder\algo\cb-intra-inter.obj \
75 encoder\algo\cb-intrapartmode.obj \
76 encoder\algo\cb-mergeindex.obj \
77 encoder\algo\cb-skip.obj \
78 encoder\algo\cb-split.obj \
79 encoder\algo\coding-options.obj \
80 encoder\algo\ctb-qscale.obj \
81 encoder\algo\pb-mv.obj \
82 encoder\algo\tb-intrapredmode.obj \
83 encoder\algo\tb-split.obj \
5984 x86\sse.obj \
6085 x86\sse-dct.obj \
6186 x86\sse-motion.obj \
2222
2323 #include <stddef.h>
2424 #include <stdint.h>
25 #include <assert.h>
26
2527
2628 struct acceleration_functions
2729 {
2830 void (*put_weighted_pred_avg_8)(uint8_t *_dst, ptrdiff_t dststride,
29 int16_t *src1, int16_t *src2, ptrdiff_t srcstride,
31 const int16_t *src1, const int16_t *src2, ptrdiff_t srcstride,
3032 int width, int height);
3133
3234 void (*put_unweighted_pred_8)(uint8_t *_dst, ptrdiff_t dststride,
33 int16_t *src, ptrdiff_t srcstride,
35 const int16_t *src, ptrdiff_t srcstride,
3436 int width, int height);
3537
3638 void (*put_weighted_pred_8)(uint8_t *_dst, ptrdiff_t dststride,
37 int16_t *src, ptrdiff_t srcstride,
39 const int16_t *src, ptrdiff_t srcstride,
3840 int width, int height,
3941 int w,int o,int log2WD);
4042 void (*put_weighted_bipred_8)(uint8_t *_dst, ptrdiff_t dststride,
41 int16_t *src1, int16_t *src2, ptrdiff_t srcstride,
43 const int16_t *src1, const int16_t *src2, ptrdiff_t srcstride,
4244 int width, int height,
4345 int w1,int o1, int w2,int o2, int log2WD);
4446
47
48 void (*put_weighted_pred_avg_16)(uint16_t *_dst, ptrdiff_t dststride,
49 const int16_t *src1, const int16_t *src2, ptrdiff_t srcstride,
50 int width, int height, int bit_depth);
51
52 void (*put_unweighted_pred_16)(uint16_t *_dst, ptrdiff_t dststride,
53 const int16_t *src, ptrdiff_t srcstride,
54 int width, int height, int bit_depth);
55
56 void (*put_weighted_pred_16)(uint16_t *_dst, ptrdiff_t dststride,
57 const int16_t *src, ptrdiff_t srcstride,
58 int width, int height,
59 int w,int o,int log2WD, int bit_depth);
60 void (*put_weighted_bipred_16)(uint16_t *_dst, ptrdiff_t dststride,
61 const int16_t *src1, const int16_t *src2, ptrdiff_t srcstride,
62 int width, int height,
63 int w1,int o1, int w2,int o2, int log2WD, int bit_depth);
64
65
66 void put_weighted_pred_avg(void *_dst, ptrdiff_t dststride,
67 const int16_t *src1, const int16_t *src2, ptrdiff_t srcstride,
68 int width, int height, int bit_depth) const;
69
70 void put_unweighted_pred(void *_dst, ptrdiff_t dststride,
71 const int16_t *src, ptrdiff_t srcstride,
72 int width, int height, int bit_depth) const;
73
74 void put_weighted_pred(void *_dst, ptrdiff_t dststride,
75 const int16_t *src, ptrdiff_t srcstride,
76 int width, int height,
77 int w,int o,int log2WD, int bit_depth) const;
78 void put_weighted_bipred(void *_dst, ptrdiff_t dststride,
79 const int16_t *src1, const int16_t *src2, ptrdiff_t srcstride,
80 int width, int height,
81 int w1,int o1, int w2,int o2, int log2WD, int bit_depth) const;
82
83
84
85
4586 void (*put_hevc_epel_8)(int16_t *dst, ptrdiff_t dststride,
46 uint8_t *src, ptrdiff_t srcstride, int width, int height,
87 const uint8_t *src, ptrdiff_t srcstride, int width, int height,
4788 int mx, int my, int16_t* mcbuffer);
4889 void (*put_hevc_epel_h_8)(int16_t *dst, ptrdiff_t dststride,
49 uint8_t *src, ptrdiff_t srcstride, int width, int height,
50 int mx, int my, int16_t* mcbuffer);
90 const uint8_t *src, ptrdiff_t srcstride, int width, int height,
91 int mx, int my, int16_t* mcbuffer, int bit_depth);
5192 void (*put_hevc_epel_v_8)(int16_t *dst, ptrdiff_t dststride,
52 uint8_t *src, ptrdiff_t srcstride, int width, int height,
53 int mx, int my, int16_t* mcbuffer);
93 const uint8_t *src, ptrdiff_t srcstride, int width, int height,
94 int mx, int my, int16_t* mcbuffer, int bit_depth);
5495 void (*put_hevc_epel_hv_8)(int16_t *dst, ptrdiff_t dststride,
55 uint8_t *src, ptrdiff_t srcstride, int width, int height,
56 int mx, int my, int16_t* mcbuffer);
96 const uint8_t *src, ptrdiff_t srcstride, int width, int height,
97 int mx, int my, int16_t* mcbuffer, int bit_depth);
5798
5899 void (*put_hevc_qpel_8[4][4])(int16_t *dst, ptrdiff_t dststride,
59 uint8_t *src, ptrdiff_t srcstride, int width, int height,
100 const uint8_t *src, ptrdiff_t srcstride, int width, int height,
60101 int16_t* mcbuffer);
61102
62 void (*transform_skip_8)(uint8_t *_dst, int16_t *coeffs, ptrdiff_t _stride); // no transform
63 void (*transform_bypass_8)(uint8_t *dst, int16_t *coeffs, int nT, ptrdiff_t stride);
64 void (*transform_4x4_luma_add_8)(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride); // iDST
65
66 void (*transform_4x4_add_8)(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride); // iDCT
67 void (*transform_8x8_add_8)(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride); // iDCT
68 void (*transform_16x16_add_8)(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride); // iDCT
69 void (*transform_32x32_add_8)(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride); // iDCT
103
104 void (*put_hevc_epel_16)(int16_t *dst, ptrdiff_t dststride,
105 const uint16_t *src, ptrdiff_t srcstride, int width, int height,
106 int mx, int my, int16_t* mcbuffer, int bit_depth);
107 void (*put_hevc_epel_h_16)(int16_t *dst, ptrdiff_t dststride,
108 const uint16_t *src, ptrdiff_t srcstride, int width, int height,
109 int mx, int my, int16_t* mcbuffer, int bit_depth);
110 void (*put_hevc_epel_v_16)(int16_t *dst, ptrdiff_t dststride,
111 const uint16_t *src, ptrdiff_t srcstride, int width, int height,
112 int mx, int my, int16_t* mcbuffer, int bit_depth);
113 void (*put_hevc_epel_hv_16)(int16_t *dst, ptrdiff_t dststride,
114 const uint16_t *src, ptrdiff_t srcstride, int width, int height,
115 int mx, int my, int16_t* mcbuffer, int bit_depth);
116
117 void (*put_hevc_qpel_16[4][4])(int16_t *dst, ptrdiff_t dststride,
118 const uint16_t *src, ptrdiff_t srcstride, int width, int height,
119 int16_t* mcbuffer, int bit_depth);
120
121
122 void put_hevc_epel(int16_t *dst, ptrdiff_t dststride,
123 const void *src, ptrdiff_t srcstride, int width, int height,
124 int mx, int my, int16_t* mcbuffer, int bit_depth) const;
125 void put_hevc_epel_h(int16_t *dst, ptrdiff_t dststride,
126 const void *src, ptrdiff_t srcstride, int width, int height,
127 int mx, int my, int16_t* mcbuffer, int bit_depth) const;
128 void put_hevc_epel_v(int16_t *dst, ptrdiff_t dststride,
129 const void *src, ptrdiff_t srcstride, int width, int height,
130 int mx, int my, int16_t* mcbuffer, int bit_depth) const;
131 void put_hevc_epel_hv(int16_t *dst, ptrdiff_t dststride,
132 const void *src, ptrdiff_t srcstride, int width, int height,
133 int mx, int my, int16_t* mcbuffer, int bit_depth) const;
134
135 void put_hevc_qpel(int16_t *dst, ptrdiff_t dststride,
136 const void *src, ptrdiff_t srcstride, int width, int height,
137 int16_t* mcbuffer, int dX,int dY, int bit_depth) const;
138
139
140 // --- inverse transforms ---
141
142 void (*transform_bypass)(int32_t *residual, const int16_t *coeffs, int nT);
143 void (*transform_bypass_rdpcm_v)(int32_t *r, const int16_t *coeffs, int nT);
144 void (*transform_bypass_rdpcm_h)(int32_t *r, const int16_t *coeffs, int nT);
145
146 // 8 bit
147
148 void (*transform_skip_8)(uint8_t *_dst, const int16_t *coeffs, ptrdiff_t _stride); // no transform
149 void (*transform_skip_rdpcm_v_8)(uint8_t *_dst, const int16_t *coeffs, int nT, ptrdiff_t _stride);
150 void (*transform_skip_rdpcm_h_8)(uint8_t *_dst, const int16_t *coeffs, int nT, ptrdiff_t _stride);
151 void (*transform_4x4_dst_add_8)(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride); // iDST
152 void (*transform_add_8[4])(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride); // iDCT
153
154 // 9-16 bit
155
156 void (*transform_skip_16)(uint16_t *_dst, const int16_t *coeffs, ptrdiff_t _stride, int bit_depth); // no transform
157 void (*transform_4x4_dst_add_16)(uint16_t *dst, const int16_t *coeffs, ptrdiff_t stride, int bit_depth); // iDST
158 void (*transform_add_16[4])(uint16_t *dst, const int16_t *coeffs, ptrdiff_t stride, int bit_depth); // iDCT
159
160
161 void (*rotate_coefficients)(int16_t *coeff, int nT);
162
163 void (*transform_idst_4x4)(int32_t *dst, const int16_t *coeffs, int bdShift, int max_coeff_bits);
164 void (*transform_idct_4x4)(int32_t *dst, const int16_t *coeffs, int bdShift, int max_coeff_bits);
165 void (*transform_idct_8x8)(int32_t *dst, const int16_t *coeffs, int bdShift, int max_coeff_bits);
166 void (*transform_idct_16x16)(int32_t *dst,const int16_t *coeffs,int bdShift, int max_coeff_bits);
167 void (*transform_idct_32x32)(int32_t *dst,const int16_t *coeffs,int bdShift, int max_coeff_bits);
168 void (*add_residual_8)(uint8_t *dst, ptrdiff_t stride, const int32_t* r, int nT, int bit_depth);
169 void (*add_residual_16)(uint16_t *dst,ptrdiff_t stride,const int32_t* r, int nT, int bit_depth);
170
171 template <class pixel_t>
172 void add_residual(pixel_t *dst, ptrdiff_t stride, const int32_t* r, int nT, int bit_depth) const;
173
174 void (*rdpcm_v)(int32_t* residual, const int16_t* coeffs, int nT,int tsShift,int bdShift);
175 void (*rdpcm_h)(int32_t* residual, const int16_t* coeffs, int nT,int tsShift,int bdShift);
176
177 void (*transform_skip_residual)(int32_t *residual, const int16_t *coeffs, int nT,
178 int tsShift,int bdShift);
179
180
181 template <class pixel_t> void transform_skip(pixel_t *dst, const int16_t *coeffs, ptrdiff_t stride, int bit_depth) const;
182 template <class pixel_t> void transform_skip_rdpcm_v(pixel_t *dst, const int16_t *coeffs, int nT, ptrdiff_t stride, int bit_depth) const;
183 template <class pixel_t> void transform_skip_rdpcm_h(pixel_t *dst, const int16_t *coeffs, int nT, ptrdiff_t stride, int bit_depth) const;
184 template <class pixel_t> void transform_4x4_dst_add(pixel_t *dst, const int16_t *coeffs, ptrdiff_t stride, int bit_depth) const;
185 template <class pixel_t> void transform_add(int sizeIdx, pixel_t *dst, const int16_t *coeffs, ptrdiff_t stride, int bit_depth) const;
186
187
188
189 // --- forward transforms ---
190
191 void (*fwd_transform_4x4_dst_8)(int16_t *coeffs, const int16_t* src, ptrdiff_t stride); // fDST
192
193 // indexed with (log2TbSize-2)
194 void (*fwd_transform_8[4]) (int16_t *coeffs, const int16_t *src, ptrdiff_t stride); // fDCT
195
196
197 // forward Hadamard transform (without scaling factor)
198 // (4x4,8x8,16x16,32x32) indexed with (log2TbSize-2)
199 void (*hadamard_transform_8[4]) (int16_t *coeffs, const int16_t *src, ptrdiff_t stride);
70200 };
71201
202
203 /*
204 template <> inline void acceleration_functions::put_weighted_pred_avg<uint8_t>(uint8_t *_dst, ptrdiff_t dststride,
205 const int16_t *src1, const int16_t *src2, ptrdiff_t srcstride,
206 int width, int height, int bit_depth) { put_weighted_pred_avg_8(_dst,dststride,src1,src2,srcstride,width,height); }
207 template <> inline void acceleration_functions::put_weighted_pred_avg<uint16_t>(uint16_t *_dst, ptrdiff_t dststride,
208 const int16_t *src1, const int16_t *src2, ptrdiff_t srcstride,
209 int width, int height, int bit_depth) { put_weighted_pred_avg_16(_dst,dststride,src1,src2,
210 srcstride,width,height,bit_depth); }
211
212 template <> inline void acceleration_functions::put_unweighted_pred<uint8_t>(uint8_t *_dst, ptrdiff_t dststride,
213 const int16_t *src, ptrdiff_t srcstride,
214 int width, int height, int bit_depth) { put_unweighted_pred_8(_dst,dststride,src,srcstride,width,height); }
215 template <> inline void acceleration_functions::put_unweighted_pred<uint16_t>(uint16_t *_dst, ptrdiff_t dststride,
216 const int16_t *src, ptrdiff_t srcstride,
217 int width, int height, int bit_depth) { put_unweighted_pred_16(_dst,dststride,src,srcstride,width,height,bit_depth); }
218
219 template <> inline void acceleration_functions::put_weighted_pred<uint8_t>(uint8_t *_dst, ptrdiff_t dststride,
220 const int16_t *src, ptrdiff_t srcstride,
221 int width, int height,
222 int w,int o,int log2WD, int bit_depth) { put_weighted_pred_8(_dst,dststride,src,srcstride,width,height,w,o,log2WD); }
223 template <> inline void acceleration_functions::put_weighted_pred<uint16_t>(uint16_t *_dst, ptrdiff_t dststride,
224 const int16_t *src, ptrdiff_t srcstride,
225 int width, int height,
226 int w,int o,int log2WD, int bit_depth) { put_weighted_pred_16(_dst,dststride,src,srcstride,width,height,w,o,log2WD,bit_depth); }
227
228 template <> inline void acceleration_functions::put_weighted_bipred<uint8_t>(uint8_t *_dst, ptrdiff_t dststride,
229 const int16_t *src1, const int16_t *src2, ptrdiff_t srcstride,
230 int width, int height,
231 int w1,int o1, int w2,int o2, int log2WD, int bit_depth) { put_weighted_bipred_8(_dst,dststride,src1,src2,srcstride,
232 width,height,
233 w1,o1,w2,o2,log2WD); }
234 template <> inline void acceleration_functions::put_weighted_bipred<uint16_t>(uint16_t *_dst, ptrdiff_t dststride,
235 const int16_t *src1, const int16_t *src2, ptrdiff_t srcstride,
236 int width, int height,
237 int w1,int o1, int w2,int o2, int log2WD, int bit_depth) { put_weighted_bipred_16(_dst,dststride,src1,src2,srcstride,
238 width,height,
239 w1,o1,w2,o2,log2WD,bit_depth); }
240 */
241
242
243 inline void acceleration_functions::put_weighted_pred_avg(void* _dst, ptrdiff_t dststride,
244 const int16_t *src1, const int16_t *src2, ptrdiff_t srcstride,
245 int width, int height, int bit_depth) const
246 {
247 if (bit_depth <= 8)
248 put_weighted_pred_avg_8((uint8_t*)_dst,dststride,src1,src2,srcstride,width,height);
249 else
250 put_weighted_pred_avg_16((uint16_t*)_dst,dststride,src1,src2,srcstride,width,height,bit_depth);
251 }
252
253
254 inline void acceleration_functions::put_unweighted_pred(void* _dst, ptrdiff_t dststride,
255 const int16_t *src, ptrdiff_t srcstride,
256 int width, int height, int bit_depth) const
257 {
258 if (bit_depth <= 8)
259 put_unweighted_pred_8((uint8_t*)_dst,dststride,src,srcstride,width,height);
260 else
261 put_unweighted_pred_16((uint16_t*)_dst,dststride,src,srcstride,width,height,bit_depth);
262 }
263
264
265 inline void acceleration_functions::put_weighted_pred(void* _dst, ptrdiff_t dststride,
266 const int16_t *src, ptrdiff_t srcstride,
267 int width, int height,
268 int w,int o,int log2WD, int bit_depth) const
269 {
270 if (bit_depth <= 8)
271 put_weighted_pred_8((uint8_t*)_dst,dststride,src,srcstride,width,height,w,o,log2WD);
272 else
273 put_weighted_pred_16((uint16_t*)_dst,dststride,src,srcstride,width,height,w,o,log2WD,bit_depth);
274 }
275
276
277 inline void acceleration_functions::put_weighted_bipred(void* _dst, ptrdiff_t dststride,
278 const int16_t *src1, const int16_t *src2, ptrdiff_t srcstride,
279 int width, int height,
280 int w1,int o1, int w2,int o2, int log2WD, int bit_depth) const
281 {
282 if (bit_depth <= 8)
283 put_weighted_bipred_8((uint8_t*)_dst,dststride,src1,src2,srcstride, width,height, w1,o1,w2,o2,log2WD);
284 else
285 put_weighted_bipred_16((uint16_t*)_dst,dststride,src1,src2,srcstride, width,height, w1,o1,w2,o2,log2WD,bit_depth);
286 }
287
288
289
290 inline void acceleration_functions::put_hevc_epel(int16_t *dst, ptrdiff_t dststride,
291 const void *src, ptrdiff_t srcstride, int width, int height,
292 int mx, int my, int16_t* mcbuffer, int bit_depth) const
293 {
294 if (bit_depth <= 8)
295 put_hevc_epel_8(dst,dststride,(const uint8_t*)src,srcstride,width,height,mx,my,mcbuffer);
296 else
297 put_hevc_epel_16(dst,dststride,(const uint16_t*)src,srcstride,width,height,mx,my,mcbuffer, bit_depth);
298 }
299
300 inline void acceleration_functions::put_hevc_epel_h(int16_t *dst, ptrdiff_t dststride,
301 const void *src, ptrdiff_t srcstride, int width, int height,
302 int mx, int my, int16_t* mcbuffer, int bit_depth) const
303 {
304 if (bit_depth <= 8)
305 put_hevc_epel_h_8(dst,dststride,(const uint8_t*)src,srcstride,width,height,mx,my,mcbuffer,bit_depth);
306 else
307 put_hevc_epel_h_16(dst,dststride,(const uint16_t*)src,srcstride,width,height,mx,my,mcbuffer,bit_depth);
308 }
309
310 inline void acceleration_functions::put_hevc_epel_v(int16_t *dst, ptrdiff_t dststride,
311 const void *src, ptrdiff_t srcstride, int width, int height,
312 int mx, int my, int16_t* mcbuffer, int bit_depth) const
313 {
314 if (bit_depth <= 8)
315 put_hevc_epel_v_8(dst,dststride,(const uint8_t*)src,srcstride,width,height,mx,my,mcbuffer,bit_depth);
316 else
317 put_hevc_epel_v_16(dst,dststride,(const uint16_t*)src,srcstride,width,height,mx,my,mcbuffer, bit_depth);
318 }
319
320 inline void acceleration_functions::put_hevc_epel_hv(int16_t *dst, ptrdiff_t dststride,
321 const void *src, ptrdiff_t srcstride, int width, int height,
322 int mx, int my, int16_t* mcbuffer, int bit_depth) const
323 {
324 if (bit_depth <= 8)
325 put_hevc_epel_hv_8(dst,dststride,(const uint8_t*)src,srcstride,width,height,mx,my,mcbuffer,bit_depth);
326 else
327 put_hevc_epel_hv_16(dst,dststride,(const uint16_t*)src,srcstride,width,height,mx,my,mcbuffer, bit_depth);
328 }
329
330 inline void acceleration_functions::put_hevc_qpel(int16_t *dst, ptrdiff_t dststride,
331 const void *src, ptrdiff_t srcstride, int width, int height,
332 int16_t* mcbuffer, int dX,int dY, int bit_depth) const
333 {
334 if (bit_depth <= 8)
335 put_hevc_qpel_8[dX][dY](dst,dststride,(const uint8_t*)src,srcstride,width,height,mcbuffer);
336 else
337 put_hevc_qpel_16[dX][dY](dst,dststride,(const uint16_t*)src,srcstride,width,height,mcbuffer, bit_depth);
338 }
339
340 template <> inline void acceleration_functions::transform_skip<uint8_t>(uint8_t *dst, const int16_t *coeffs,ptrdiff_t stride, int bit_depth) const { transform_skip_8(dst,coeffs,stride); }
341 template <> inline void acceleration_functions::transform_skip<uint16_t>(uint16_t *dst, const int16_t *coeffs, ptrdiff_t stride, int bit_depth) const { transform_skip_16(dst,coeffs,stride, bit_depth); }
342
343 template <> inline void acceleration_functions::transform_skip_rdpcm_v<uint8_t>(uint8_t *dst, const int16_t *coeffs, int nT, ptrdiff_t stride, int bit_depth) const { assert(bit_depth==8); transform_skip_rdpcm_v_8(dst,coeffs,nT,stride); }
344 template <> inline void acceleration_functions::transform_skip_rdpcm_h<uint8_t>(uint8_t *dst, const int16_t *coeffs, int nT, ptrdiff_t stride, int bit_depth) const { assert(bit_depth==8); transform_skip_rdpcm_h_8(dst,coeffs,nT,stride); }
345 template <> inline void acceleration_functions::transform_skip_rdpcm_v<uint16_t>(uint16_t *dst, const int16_t *coeffs, int nT, ptrdiff_t stride, int bit_depth) const { assert(false); /*transform_skip_rdpcm_v_8(dst,coeffs,nT,stride);*/ }
346 template <> inline void acceleration_functions::transform_skip_rdpcm_h<uint16_t>(uint16_t *dst, const int16_t *coeffs, int nT, ptrdiff_t stride, int bit_depth) const { assert(false); /*transform_skip_rdpcm_h_8(dst,coeffs,nT,stride);*/ }
347
348
349 template <> inline void acceleration_functions::transform_4x4_dst_add<uint8_t>(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride,int bit_depth) const { transform_4x4_dst_add_8(dst,coeffs,stride); }
350 template <> inline void acceleration_functions::transform_4x4_dst_add<uint16_t>(uint16_t *dst, const int16_t *coeffs, ptrdiff_t stride,int bit_depth) const { transform_4x4_dst_add_16(dst,coeffs,stride,bit_depth); }
351
352 template <> inline void acceleration_functions::transform_add<uint8_t>(int sizeIdx, uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride, int bit_depth) const { transform_add_8[sizeIdx](dst,coeffs,stride); }
353 template <> inline void acceleration_functions::transform_add<uint16_t>(int sizeIdx, uint16_t *dst, const int16_t *coeffs, ptrdiff_t stride, int bit_depth) const { transform_add_16[sizeIdx](dst,coeffs,stride,bit_depth); }
354
355 template <> inline void acceleration_functions::add_residual(uint8_t *dst, ptrdiff_t stride, const int32_t* r, int nT, int bit_depth) const { add_residual_8(dst,stride,r,nT,bit_depth); }
356 template <> inline void acceleration_functions::add_residual(uint16_t *dst, ptrdiff_t stride, const int32_t* r, int nT, int bit_depth) const { add_residual_16(dst,stride,r,nT,bit_depth); }
357
72358 #endif
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #include "libde265/alloc_pool.h"
23 #include "libde265/util.h"
24 #include <assert.h>
25 #include <stdio.h>
26
27 #define DEBUG_MEMORY 1
28
29
30 alloc_pool::alloc_pool(size_t objSize, int poolSize, bool grow)
31 : mObjSize(objSize),
32 mPoolSize(poolSize),
33 mGrow(grow)
34 {
35 m_freeList.reserve(poolSize);
36 m_memBlocks.reserve(8);
37
38 add_memory_block();
39 }
40
41
42 void alloc_pool::add_memory_block()
43 {
44 uint8_t* p = new uint8_t[mObjSize * mPoolSize];
45 m_memBlocks.push_back(p);
46
47 for (int i=0;i<mPoolSize;i++)
48 {
49 m_freeList.push_back(p + (mPoolSize-1-i) * mObjSize);
50 }
51 }
52
53 alloc_pool::~alloc_pool()
54 {
55 FOR_LOOP(uint8_t*, p, m_memBlocks) {
56 delete[] p;
57 }
58 }
59
60
61 void* alloc_pool::new_obj(const size_t size)
62 {
63 if (size != mObjSize) {
64 return ::operator new(size);
65 }
66
67 if (m_freeList.size()==0) {
68 if (mGrow) {
69 add_memory_block();
70 if (DEBUG_MEMORY) { fprintf(stderr,"additional block allocated in memory pool\n"); }
71 }
72 else {
73 return NULL;
74 }
75 }
76
77 assert(!m_freeList.empty());
78
79 void* p = m_freeList.back();
80 m_freeList.pop_back();
81
82 return p;
83 }
84
85
86 void alloc_pool::delete_obj(void* obj)
87 {
88 int memBlockSize = mObjSize * mPoolSize;
89
90 FOR_LOOP(uint8_t*, memBlk, m_memBlocks) {
91 if (memBlk <= obj && obj < memBlk + memBlockSize) {
92 m_freeList.push_back(obj);
93 return;
94 }
95 }
96
97 ::operator delete(obj);
98 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef ALLOC_POOL_H
23 #define ALLOC_POOL_H
24
25 #include <vector>
26 #include <cstddef>
27 #ifdef HAVE_STDINT_H
28 #include <stdint.h>
29 #else
30 #include <cstdint>
31 #endif
32
33
34 class alloc_pool
35 {
36 public:
37 alloc_pool(size_t objSize, int poolSize=1000, bool grow=true);
38 ~alloc_pool();
39
40 void* new_obj(const size_t size);
41 void delete_obj(void*);
42 void purge();
43
44 private:
45 size_t mObjSize;
46 int mPoolSize;
47 bool mGrow;
48
49 std::vector<uint8_t*> m_memBlocks;
50 std::vector<void*> m_freeList;
51
52 void add_memory_block();
53 };
54
55 #endif
0 noinst_LTLIBRARIES = libde265_arm.la
1
2 libde265_arm_la_CXXFLAGS = -I.. $(CFLAG_VISIBILITY)
3 libde265_arm_la_SOURCES = arm.cc arm.h
4 libde265_arm_la_LIBADD =
5
6 if HAVE_VISIBILITY
7 libde265_arm_la_CXXFLAGS += -DHAVE_VISIBILITY
8 endif
9
10
11 if ENABLE_NEON_OPT
12 # NEON specific functions
13
14 noinst_LTLIBRARIES += libde265_arm_neon.la
15 libde265_arm_la_LIBADD += libde265_arm_neon.la
16 libde265_arm_neon_la_CXXFLAGS = -mfpu=neon -I.. $(CFLAG_VISIBILITY)
17 libde265_arm_neon_la_CCASFLAGS = -mfpu=neon -I.. \
18 -DHAVE_NEON \
19 -DEXTERN_ASM= \
20 -DHAVE_AS_FUNC \
21 -DHAVE_SECTION_DATA_REL_RO
22
23 if ENABLE_ARM_THUMB
24 libde265_arm_neon_la_CCASFLAGS += -DCONFIG_THUMB
25 endif
26
27 libde265_arm_neon_la_SOURCES = \
28 asm.S \
29 cpudetect.S \
30 hevcdsp_qpel_neon.S \
31 neon.S
32
33 if HAVE_VISIBILITY
34 libde265_arm_neon_la_CXXFLAGS += -DHAVE_VISIBILITY
35 endif
36
37 endif
0 # Makefile.in generated by automake 1.14.1 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15
16 VPATH = @srcdir@
17 am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
18 am__make_running_with_option = \
19 case $${target_option-} in \
20 ?) ;; \
21 *) echo "am__make_running_with_option: internal error: invalid" \
22 "target option '$${target_option-}' specified" >&2; \
23 exit 1;; \
24 esac; \
25 has_opt=no; \
26 sane_makeflags=$$MAKEFLAGS; \
27 if $(am__is_gnu_make); then \
28 sane_makeflags=$$MFLAGS; \
29 else \
30 case $$MAKEFLAGS in \
31 *\\[\ \ ]*) \
32 bs=\\; \
33 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
34 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
35 esac; \
36 fi; \
37 skip_next=no; \
38 strip_trailopt () \
39 { \
40 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
41 }; \
42 for flg in $$sane_makeflags; do \
43 test $$skip_next = yes && { skip_next=no; continue; }; \
44 case $$flg in \
45 *=*|--*) continue;; \
46 -*I) strip_trailopt 'I'; skip_next=yes;; \
47 -*I?*) strip_trailopt 'I';; \
48 -*O) strip_trailopt 'O'; skip_next=yes;; \
49 -*O?*) strip_trailopt 'O';; \
50 -*l) strip_trailopt 'l'; skip_next=yes;; \
51 -*l?*) strip_trailopt 'l';; \
52 -[dEDm]) skip_next=yes;; \
53 -[JT]) skip_next=yes;; \
54 esac; \
55 case $$flg in \
56 *$$target_option*) has_opt=yes; break;; \
57 esac; \
58 done; \
59 test $$has_opt = yes
60 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
61 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
62 pkgdatadir = $(datadir)/@PACKAGE@
63 pkgincludedir = $(includedir)/@PACKAGE@
64 pkglibdir = $(libdir)/@PACKAGE@
65 pkglibexecdir = $(libexecdir)/@PACKAGE@
66 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
67 install_sh_DATA = $(install_sh) -c -m 644
68 install_sh_PROGRAM = $(install_sh) -c
69 install_sh_SCRIPT = $(install_sh) -c
70 INSTALL_HEADER = $(INSTALL_DATA)
71 transform = $(program_transform_name)
72 NORMAL_INSTALL = :
73 PRE_INSTALL = :
74 POST_INSTALL = :
75 NORMAL_UNINSTALL = :
76 PRE_UNINSTALL = :
77 POST_UNINSTALL = :
78 build_triplet = @build@
79 host_triplet = @host@
80 target_triplet = @target@
81
82 # NEON specific functions
83 @ENABLE_NEON_OPT_TRUE@am__append_1 = libde265_arm_neon.la
84 @ENABLE_NEON_OPT_TRUE@am__append_2 = libde265_arm_neon.la
85 subdir = libde265/arm
86 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
87 $(top_srcdir)/depcomp
88 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
89 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
90 $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \
91 $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
92 $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
93 $(top_srcdir)/m4/lt~obsolete.m4 \
94 $(top_srcdir)/m4/m4_ax_check_compile_flag.m4 \
95 $(top_srcdir)/configure.ac
96 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
97 $(ACLOCAL_M4)
98 mkinstalldirs = $(install_sh) -d
99 CONFIG_HEADER = $(top_builddir)/config.h
100 CONFIG_CLEAN_FILES =
101 CONFIG_CLEAN_VPATH_FILES =
102 LTLIBRARIES = $(noinst_LTLIBRARIES)
103 libde265_arm_la_DEPENDENCIES = $(am__append_2)
104 am_libde265_arm_la_OBJECTS = libde265_arm_la-arm.lo
105 libde265_arm_la_OBJECTS = $(am_libde265_arm_la_OBJECTS)
106 AM_V_lt = $(am__v_lt_@AM_V@)
107 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
108 am__v_lt_0 = --silent
109 am__v_lt_1 =
110 libde265_arm_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
111 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
112 $(libde265_arm_la_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
113 $(LDFLAGS) -o $@
114 libde265_arm_neon_la_LIBADD =
115 am__libde265_arm_neon_la_SOURCES_DIST = asm.S cpudetect.S \
116 hevcdsp_qpel_neon.S neon.S
117 @ENABLE_NEON_OPT_TRUE@am_libde265_arm_neon_la_OBJECTS = \
118 @ENABLE_NEON_OPT_TRUE@ libde265_arm_neon_la-asm.lo \
119 @ENABLE_NEON_OPT_TRUE@ libde265_arm_neon_la-cpudetect.lo \
120 @ENABLE_NEON_OPT_TRUE@ libde265_arm_neon_la-hevcdsp_qpel_neon.lo \
121 @ENABLE_NEON_OPT_TRUE@ libde265_arm_neon_la-neon.lo
122 libde265_arm_neon_la_OBJECTS = $(am_libde265_arm_neon_la_OBJECTS)
123 @ENABLE_NEON_OPT_TRUE@am_libde265_arm_neon_la_rpath =
124 AM_V_P = $(am__v_P_@AM_V@)
125 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
126 am__v_P_0 = false
127 am__v_P_1 = :
128 AM_V_GEN = $(am__v_GEN_@AM_V@)
129 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
130 am__v_GEN_0 = @echo " GEN " $@;
131 am__v_GEN_1 =
132 AM_V_at = $(am__v_at_@AM_V@)
133 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
134 am__v_at_0 = @
135 am__v_at_1 =
136 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
137 depcomp = $(SHELL) $(top_srcdir)/depcomp
138 am__depfiles_maybe = depfiles
139 am__mv = mv -f
140 CPPASCOMPILE = $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
141 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS)
142 LTCPPASCOMPILE = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) \
143 $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) \
144 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
145 $(AM_CCASFLAGS) $(CCASFLAGS)
146 AM_V_CPPAS = $(am__v_CPPAS_@AM_V@)
147 am__v_CPPAS_ = $(am__v_CPPAS_@AM_DEFAULT_V@)
148 am__v_CPPAS_0 = @echo " CPPAS " $@;
149 am__v_CPPAS_1 =
150 CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
151 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
152 LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
153 $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
154 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
155 $(AM_CXXFLAGS) $(CXXFLAGS)
156 AM_V_CXX = $(am__v_CXX_@AM_V@)
157 am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
158 am__v_CXX_0 = @echo " CXX " $@;
159 am__v_CXX_1 =
160 CXXLD = $(CXX)
161 CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
162 $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
163 $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
164 AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
165 am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
166 am__v_CXXLD_0 = @echo " CXXLD " $@;
167 am__v_CXXLD_1 =
168 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
169 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
170 LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
171 $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
172 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
173 $(AM_CFLAGS) $(CFLAGS)
174 AM_V_CC = $(am__v_CC_@AM_V@)
175 am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
176 am__v_CC_0 = @echo " CC " $@;
177 am__v_CC_1 =
178 CCLD = $(CC)
179 LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
180 $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
181 $(AM_LDFLAGS) $(LDFLAGS) -o $@
182 AM_V_CCLD = $(am__v_CCLD_@AM_V@)
183 am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
184 am__v_CCLD_0 = @echo " CCLD " $@;
185 am__v_CCLD_1 =
186 SOURCES = $(libde265_arm_la_SOURCES) $(libde265_arm_neon_la_SOURCES)
187 DIST_SOURCES = $(libde265_arm_la_SOURCES) \
188 $(am__libde265_arm_neon_la_SOURCES_DIST)
189 am__can_run_installinfo = \
190 case $$AM_UPDATE_INFO_DIR in \
191 n|no|NO) false;; \
192 *) (install-info --version) >/dev/null 2>&1;; \
193 esac
194 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
195 # Read a list of newline-separated strings from the standard input,
196 # and print each of them once, without duplicates. Input order is
197 # *not* preserved.
198 am__uniquify_input = $(AWK) '\
199 BEGIN { nonempty = 0; } \
200 { items[$$0] = 1; nonempty = 1; } \
201 END { if (nonempty) { for (i in items) print i; }; } \
202 '
203 # Make sure the list of sources is unique. This is necessary because,
204 # e.g., the same source file might be shared among _SOURCES variables
205 # for different programs/libraries.
206 am__define_uniq_tagged_files = \
207 list='$(am__tagged_files)'; \
208 unique=`for i in $$list; do \
209 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
210 done | $(am__uniquify_input)`
211 ETAGS = etags
212 CTAGS = ctags
213 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
214 ACLOCAL = @ACLOCAL@
215 ALLOCA = @ALLOCA@
216 AMTAR = @AMTAR@
217 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
218 AR = @AR@
219 AUTOCONF = @AUTOCONF@
220 AUTOHEADER = @AUTOHEADER@
221 AUTOMAKE = @AUTOMAKE@
222 AWK = @AWK@
223 CC = @CC@
224 CCAS = @CCAS@
225 CCASDEPMODE = @CCASDEPMODE@
226 CCASFLAGS = @CCASFLAGS@
227 CCDEPMODE = @CCDEPMODE@
228 CFLAGS = @CFLAGS@
229 CPP = @CPP@
230 CPPFLAGS = @CPPFLAGS@
231 CXX = @CXX@
232 CXXCPP = @CXXCPP@
233 CXXDEPMODE = @CXXDEPMODE@
234 CXXFLAGS = @CXXFLAGS@
235 CYGPATH_W = @CYGPATH_W@
236 DEFS = @DEFS@
237 DEPDIR = @DEPDIR@
238 DLLTOOL = @DLLTOOL@
239 DSYMUTIL = @DSYMUTIL@
240 DUMPBIN = @DUMPBIN@
241 ECHO_C = @ECHO_C@
242 ECHO_N = @ECHO_N@
243 ECHO_T = @ECHO_T@
244 EGREP = @EGREP@
245 EXEEXT = @EXEEXT@
246 FGREP = @FGREP@
247 GREP = @GREP@
248 HAVE_CXX11 = @HAVE_CXX11@
249 INSTALL = @INSTALL@
250 INSTALL_DATA = @INSTALL_DATA@
251 INSTALL_PROGRAM = @INSTALL_PROGRAM@
252 INSTALL_SCRIPT = @INSTALL_SCRIPT@
253 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
254 LD = @LD@
255 LDFLAGS = @LDFLAGS@
256 LIBDE265_AGE = @LIBDE265_AGE@
257 LIBDE265_CURRENT = @LIBDE265_CURRENT@
258 LIBDE265_REVISION = @LIBDE265_REVISION@
259 LIBOBJS = @LIBOBJS@
260 LIBS = @LIBS@
261 LIBTOOL = @LIBTOOL@
262 LIPO = @LIPO@
263 LN_S = @LN_S@
264 LTLIBOBJS = @LTLIBOBJS@
265 MAKEINFO = @MAKEINFO@
266 MANIFEST_TOOL = @MANIFEST_TOOL@
267 MKDIR_P = @MKDIR_P@
268 NM = @NM@
269 NMEDIT = @NMEDIT@
270 NUMERIC_VERSION = @NUMERIC_VERSION@
271 OBJDUMP = @OBJDUMP@
272 OBJEXT = @OBJEXT@
273 OTOOL = @OTOOL@
274 OTOOL64 = @OTOOL64@
275 PACKAGE = @PACKAGE@
276 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
277 PACKAGE_NAME = @PACKAGE_NAME@
278 PACKAGE_STRING = @PACKAGE_STRING@
279 PACKAGE_TARNAME = @PACKAGE_TARNAME@
280 PACKAGE_URL = @PACKAGE_URL@
281 PACKAGE_VERSION = @PACKAGE_VERSION@
282 PATH_SEPARATOR = @PATH_SEPARATOR@
283 PKG_CONFIG = @PKG_CONFIG@
284 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
285 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
286 QTCHOOSER = @QTCHOOSER@
287 QTMOC = @QTMOC@
288 QT_CFLAGS = @QT_CFLAGS@
289 QT_LIBS = @QT_LIBS@
290 RANLIB = @RANLIB@
291 SDL_CFLAGS = @SDL_CFLAGS@
292 SDL_LIBS = @SDL_LIBS@
293 SED = @SED@
294 SET_MAKE = @SET_MAKE@
295 SHELL = @SHELL@
296 STRIP = @STRIP@
297 SWSCALE_CFLAGS = @SWSCALE_CFLAGS@
298 SWSCALE_LIBS = @SWSCALE_LIBS@
299 VERSION = @VERSION@
300 VIDEOGFX_CFLAGS = @VIDEOGFX_CFLAGS@
301 VIDEOGFX_LIBS = @VIDEOGFX_LIBS@
302 abs_builddir = @abs_builddir@
303 abs_srcdir = @abs_srcdir@
304 abs_top_builddir = @abs_top_builddir@
305 abs_top_srcdir = @abs_top_srcdir@
306 ac_ct_AR = @ac_ct_AR@
307 ac_ct_CC = @ac_ct_CC@
308 ac_ct_CXX = @ac_ct_CXX@
309 ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
310 am__include = @am__include@
311 am__leading_dot = @am__leading_dot@
312 am__quote = @am__quote@
313 am__tar = @am__tar@
314 am__untar = @am__untar@
315 bindir = @bindir@
316 build = @build@
317 build_alias = @build_alias@
318 build_cpu = @build_cpu@
319 build_os = @build_os@
320 build_vendor = @build_vendor@
321 builddir = @builddir@
322 datadir = @datadir@
323 datarootdir = @datarootdir@
324 docdir = @docdir@
325 dvidir = @dvidir@
326 exec_prefix = @exec_prefix@
327 host = @host@
328 host_alias = @host_alias@
329 host_cpu = @host_cpu@
330 host_os = @host_os@
331 host_vendor = @host_vendor@
332 htmldir = @htmldir@
333 includedir = @includedir@
334 infodir = @infodir@
335 install_sh = @install_sh@
336 libdir = @libdir@
337 libexecdir = @libexecdir@
338 localedir = @localedir@
339 localstatedir = @localstatedir@
340 mandir = @mandir@
341 mkdir_p = @mkdir_p@
342 oldincludedir = @oldincludedir@
343 pdfdir = @pdfdir@
344 prefix = @prefix@
345 program_transform_name = @program_transform_name@
346 psdir = @psdir@
347 sbindir = @sbindir@
348 sharedstatedir = @sharedstatedir@
349 srcdir = @srcdir@
350 sysconfdir = @sysconfdir@
351 target = @target@
352 target_alias = @target_alias@
353 target_cpu = @target_cpu@
354 target_os = @target_os@
355 target_vendor = @target_vendor@
356 top_build_prefix = @top_build_prefix@
357 top_builddir = @top_builddir@
358 top_srcdir = @top_srcdir@
359 noinst_LTLIBRARIES = libde265_arm.la $(am__append_1)
360 libde265_arm_la_CXXFLAGS = -I.. $(CFLAG_VISIBILITY)
361 libde265_arm_la_SOURCES = arm.cc arm.h
362 libde265_arm_la_LIBADD = $(am__append_2)
363 @ENABLE_NEON_OPT_TRUE@libde265_arm_neon_la_CXXFLAGS = -mfpu=neon -I.. $(CFLAG_VISIBILITY)
364 @ENABLE_NEON_OPT_TRUE@libde265_arm_neon_la_CCASFLAGS = -mfpu=neon -I.. \
365 @ENABLE_NEON_OPT_TRUE@ -DHAVE_NEON \
366 @ENABLE_NEON_OPT_TRUE@ -DEXTERN_ASM= \
367 @ENABLE_NEON_OPT_TRUE@ -DHAVE_AS_FUNC \
368 @ENABLE_NEON_OPT_TRUE@ -DHAVE_SECTION_DATA_REL_RO
369
370 @ENABLE_NEON_OPT_TRUE@libde265_arm_neon_la_SOURCES = \
371 @ENABLE_NEON_OPT_TRUE@ asm.S \
372 @ENABLE_NEON_OPT_TRUE@ cpudetect.S \
373 @ENABLE_NEON_OPT_TRUE@ hevcdsp_qpel_neon.S \
374 @ENABLE_NEON_OPT_TRUE@ neon.S
375
376 all: all-am
377
378 .SUFFIXES:
379 .SUFFIXES: .S .cc .lo .o .obj
380 $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
381 @for dep in $?; do \
382 case '$(am__configure_deps)' in \
383 *$$dep*) \
384 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
385 && { if test -f $@; then exit 0; else break; fi; }; \
386 exit 1;; \
387 esac; \
388 done; \
389 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libde265/arm/Makefile'; \
390 $(am__cd) $(top_srcdir) && \
391 $(AUTOMAKE) --gnu libde265/arm/Makefile
392 .PRECIOUS: Makefile
393 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
394 @case '$?' in \
395 *config.status*) \
396 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
397 *) \
398 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
399 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
400 esac;
401
402 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
403 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
404
405 $(top_srcdir)/configure: $(am__configure_deps)
406 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
407 $(ACLOCAL_M4): $(am__aclocal_m4_deps)
408 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
409 $(am__aclocal_m4_deps):
410
411 clean-noinstLTLIBRARIES:
412 -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
413 @list='$(noinst_LTLIBRARIES)'; \
414 locs=`for p in $$list; do echo $$p; done | \
415 sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
416 sort -u`; \
417 test -z "$$locs" || { \
418 echo rm -f $${locs}; \
419 rm -f $${locs}; \
420 }
421
422 libde265_arm.la: $(libde265_arm_la_OBJECTS) $(libde265_arm_la_DEPENDENCIES) $(EXTRA_libde265_arm_la_DEPENDENCIES)
423 $(AM_V_CXXLD)$(libde265_arm_la_LINK) $(libde265_arm_la_OBJECTS) $(libde265_arm_la_LIBADD) $(LIBS)
424
425 libde265_arm_neon.la: $(libde265_arm_neon_la_OBJECTS) $(libde265_arm_neon_la_DEPENDENCIES) $(EXTRA_libde265_arm_neon_la_DEPENDENCIES)
426 $(AM_V_CCLD)$(LINK) $(am_libde265_arm_neon_la_rpath) $(libde265_arm_neon_la_OBJECTS) $(libde265_arm_neon_la_LIBADD) $(LIBS)
427
428 mostlyclean-compile:
429 -rm -f *.$(OBJEXT)
430
431 distclean-compile:
432 -rm -f *.tab.c
433
434 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_arm_la-arm.Plo@am__quote@
435 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_arm_neon_la-asm.Plo@am__quote@
436 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_arm_neon_la-cpudetect.Plo@am__quote@
437 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_arm_neon_la-hevcdsp_qpel_neon.Plo@am__quote@
438 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_arm_neon_la-neon.Plo@am__quote@
439
440 .S.o:
441 @am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CPPASCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
442 @am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
443 @AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
444 @AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
445 @am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CPPASCOMPILE) -c -o $@ $<
446
447 .S.obj:
448 @am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CPPASCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
449 @am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
450 @AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
451 @AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
452 @am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CPPASCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
453
454 .S.lo:
455 @am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(LTCPPASCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
456 @am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
457 @AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
458 @AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
459 @am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LTCPPASCOMPILE) -c -o $@ $<
460
461 libde265_arm_neon_la-asm.lo: asm.S
462 @am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_arm_neon_la_CCASFLAGS) $(CCASFLAGS) -MT libde265_arm_neon_la-asm.lo -MD -MP -MF $(DEPDIR)/libde265_arm_neon_la-asm.Tpo -c -o libde265_arm_neon_la-asm.lo `test -f 'asm.S' || echo '$(srcdir)/'`asm.S
463 @am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_arm_neon_la-asm.Tpo $(DEPDIR)/libde265_arm_neon_la-asm.Plo
464 @AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='asm.S' object='libde265_arm_neon_la-asm.lo' libtool=yes @AMDEPBACKSLASH@
465 @AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
466 @am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_arm_neon_la_CCASFLAGS) $(CCASFLAGS) -c -o libde265_arm_neon_la-asm.lo `test -f 'asm.S' || echo '$(srcdir)/'`asm.S
467
468 libde265_arm_neon_la-cpudetect.lo: cpudetect.S
469 @am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_arm_neon_la_CCASFLAGS) $(CCASFLAGS) -MT libde265_arm_neon_la-cpudetect.lo -MD -MP -MF $(DEPDIR)/libde265_arm_neon_la-cpudetect.Tpo -c -o libde265_arm_neon_la-cpudetect.lo `test -f 'cpudetect.S' || echo '$(srcdir)/'`cpudetect.S
470 @am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_arm_neon_la-cpudetect.Tpo $(DEPDIR)/libde265_arm_neon_la-cpudetect.Plo
471 @AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='cpudetect.S' object='libde265_arm_neon_la-cpudetect.lo' libtool=yes @AMDEPBACKSLASH@
472 @AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
473 @am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_arm_neon_la_CCASFLAGS) $(CCASFLAGS) -c -o libde265_arm_neon_la-cpudetect.lo `test -f 'cpudetect.S' || echo '$(srcdir)/'`cpudetect.S
474
475 libde265_arm_neon_la-hevcdsp_qpel_neon.lo: hevcdsp_qpel_neon.S
476 @am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_arm_neon_la_CCASFLAGS) $(CCASFLAGS) -MT libde265_arm_neon_la-hevcdsp_qpel_neon.lo -MD -MP -MF $(DEPDIR)/libde265_arm_neon_la-hevcdsp_qpel_neon.Tpo -c -o libde265_arm_neon_la-hevcdsp_qpel_neon.lo `test -f 'hevcdsp_qpel_neon.S' || echo '$(srcdir)/'`hevcdsp_qpel_neon.S
477 @am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_arm_neon_la-hevcdsp_qpel_neon.Tpo $(DEPDIR)/libde265_arm_neon_la-hevcdsp_qpel_neon.Plo
478 @AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='hevcdsp_qpel_neon.S' object='libde265_arm_neon_la-hevcdsp_qpel_neon.lo' libtool=yes @AMDEPBACKSLASH@
479 @AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
480 @am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_arm_neon_la_CCASFLAGS) $(CCASFLAGS) -c -o libde265_arm_neon_la-hevcdsp_qpel_neon.lo `test -f 'hevcdsp_qpel_neon.S' || echo '$(srcdir)/'`hevcdsp_qpel_neon.S
481
482 libde265_arm_neon_la-neon.lo: neon.S
483 @am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_arm_neon_la_CCASFLAGS) $(CCASFLAGS) -MT libde265_arm_neon_la-neon.lo -MD -MP -MF $(DEPDIR)/libde265_arm_neon_la-neon.Tpo -c -o libde265_arm_neon_la-neon.lo `test -f 'neon.S' || echo '$(srcdir)/'`neon.S
484 @am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_arm_neon_la-neon.Tpo $(DEPDIR)/libde265_arm_neon_la-neon.Plo
485 @AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='neon.S' object='libde265_arm_neon_la-neon.lo' libtool=yes @AMDEPBACKSLASH@
486 @AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
487 @am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_arm_neon_la_CCASFLAGS) $(CCASFLAGS) -c -o libde265_arm_neon_la-neon.lo `test -f 'neon.S' || echo '$(srcdir)/'`neon.S
488
489 .cc.o:
490 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
491 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
492 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
493 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
494 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<
495
496 .cc.obj:
497 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
498 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
499 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
500 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
501 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
502
503 .cc.lo:
504 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
505 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
506 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
507 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
508 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
509
510 libde265_arm_la-arm.lo: arm.cc
511 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_arm_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_arm_la-arm.lo -MD -MP -MF $(DEPDIR)/libde265_arm_la-arm.Tpo -c -o libde265_arm_la-arm.lo `test -f 'arm.cc' || echo '$(srcdir)/'`arm.cc
512 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_arm_la-arm.Tpo $(DEPDIR)/libde265_arm_la-arm.Plo
513 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='arm.cc' object='libde265_arm_la-arm.lo' libtool=yes @AMDEPBACKSLASH@
514 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
515 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_arm_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_arm_la-arm.lo `test -f 'arm.cc' || echo '$(srcdir)/'`arm.cc
516
517 mostlyclean-libtool:
518 -rm -f *.lo
519
520 clean-libtool:
521 -rm -rf .libs _libs
522
523 ID: $(am__tagged_files)
524 $(am__define_uniq_tagged_files); mkid -fID $$unique
525 tags: tags-am
526 TAGS: tags
527
528 tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
529 set x; \
530 here=`pwd`; \
531 $(am__define_uniq_tagged_files); \
532 shift; \
533 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
534 test -n "$$unique" || unique=$$empty_fix; \
535 if test $$# -gt 0; then \
536 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
537 "$$@" $$unique; \
538 else \
539 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
540 $$unique; \
541 fi; \
542 fi
543 ctags: ctags-am
544
545 CTAGS: ctags
546 ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
547 $(am__define_uniq_tagged_files); \
548 test -z "$(CTAGS_ARGS)$$unique" \
549 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
550 $$unique
551
552 GTAGS:
553 here=`$(am__cd) $(top_builddir) && pwd` \
554 && $(am__cd) $(top_srcdir) \
555 && gtags -i $(GTAGS_ARGS) "$$here"
556 cscopelist: cscopelist-am
557
558 cscopelist-am: $(am__tagged_files)
559 list='$(am__tagged_files)'; \
560 case "$(srcdir)" in \
561 [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
562 *) sdir=$(subdir)/$(srcdir) ;; \
563 esac; \
564 for i in $$list; do \
565 if test -f "$$i"; then \
566 echo "$(subdir)/$$i"; \
567 else \
568 echo "$$sdir/$$i"; \
569 fi; \
570 done >> $(top_builddir)/cscope.files
571
572 distclean-tags:
573 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
574
575 distdir: $(DISTFILES)
576 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
577 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
578 list='$(DISTFILES)'; \
579 dist_files=`for file in $$list; do echo $$file; done | \
580 sed -e "s|^$$srcdirstrip/||;t" \
581 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
582 case $$dist_files in \
583 */*) $(MKDIR_P) `echo "$$dist_files" | \
584 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
585 sort -u` ;; \
586 esac; \
587 for file in $$dist_files; do \
588 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
589 if test -d $$d/$$file; then \
590 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
591 if test -d "$(distdir)/$$file"; then \
592 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
593 fi; \
594 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
595 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
596 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
597 fi; \
598 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
599 else \
600 test -f "$(distdir)/$$file" \
601 || cp -p $$d/$$file "$(distdir)/$$file" \
602 || exit 1; \
603 fi; \
604 done
605 check-am: all-am
606 check: check-am
607 all-am: Makefile $(LTLIBRARIES)
608 installdirs:
609 install: install-am
610 install-exec: install-exec-am
611 install-data: install-data-am
612 uninstall: uninstall-am
613
614 install-am: all-am
615 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
616
617 installcheck: installcheck-am
618 install-strip:
619 if test -z '$(STRIP)'; then \
620 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
621 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
622 install; \
623 else \
624 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
625 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
626 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
627 fi
628 mostlyclean-generic:
629
630 clean-generic:
631
632 distclean-generic:
633 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
634 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
635
636 maintainer-clean-generic:
637 @echo "This command is intended for maintainers to use"
638 @echo "it deletes files that may require special tools to rebuild."
639 clean: clean-am
640
641 clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
642 mostlyclean-am
643
644 distclean: distclean-am
645 -rm -rf ./$(DEPDIR)
646 -rm -f Makefile
647 distclean-am: clean-am distclean-compile distclean-generic \
648 distclean-tags
649
650 dvi: dvi-am
651
652 dvi-am:
653
654 html: html-am
655
656 html-am:
657
658 info: info-am
659
660 info-am:
661
662 install-data-am:
663
664 install-dvi: install-dvi-am
665
666 install-dvi-am:
667
668 install-exec-am:
669
670 install-html: install-html-am
671
672 install-html-am:
673
674 install-info: install-info-am
675
676 install-info-am:
677
678 install-man:
679
680 install-pdf: install-pdf-am
681
682 install-pdf-am:
683
684 install-ps: install-ps-am
685
686 install-ps-am:
687
688 installcheck-am:
689
690 maintainer-clean: maintainer-clean-am
691 -rm -rf ./$(DEPDIR)
692 -rm -f Makefile
693 maintainer-clean-am: distclean-am maintainer-clean-generic
694
695 mostlyclean: mostlyclean-am
696
697 mostlyclean-am: mostlyclean-compile mostlyclean-generic \
698 mostlyclean-libtool
699
700 pdf: pdf-am
701
702 pdf-am:
703
704 ps: ps-am
705
706 ps-am:
707
708 uninstall-am:
709
710 .MAKE: install-am install-strip
711
712 .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
713 clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \
714 ctags-am distclean distclean-compile distclean-generic \
715 distclean-libtool distclean-tags distdir dvi dvi-am html \
716 html-am info info-am install install-am install-data \
717 install-data-am install-dvi install-dvi-am install-exec \
718 install-exec-am install-html install-html-am install-info \
719 install-info-am install-man install-pdf install-pdf-am \
720 install-ps install-ps-am install-strip installcheck \
721 installcheck-am installdirs maintainer-clean \
722 maintainer-clean-generic mostlyclean mostlyclean-compile \
723 mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
724 tags tags-am uninstall uninstall-am
725
726
727 @HAVE_VISIBILITY_TRUE@ libde265_arm_la_CXXFLAGS += -DHAVE_VISIBILITY
728
729 @ENABLE_ARM_THUMB_TRUE@@ENABLE_NEON_OPT_TRUE@ libde265_arm_neon_la_CCASFLAGS += -DCONFIG_THUMB
730
731 @ENABLE_NEON_OPT_TRUE@@HAVE_VISIBILITY_TRUE@ libde265_arm_neon_la_CXXFLAGS += -DHAVE_VISIBILITY
732
733 # Tell versions [3.59,3.63) of GNU make to not export all variables.
734 # Otherwise a system limit (for SysV at least) may be exceeded.
735 .NOEXPORT:
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2015 struktur AG, Joachim Bauch <bauch@struktur.de>
3 *
4 * This file is part of libde265.
5 *
6 * libde265 is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation, either version 3 of
9 * the License, or (at your option) any later version.
10 *
11 * libde265 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
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with libde265. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23
24 #include "arm.h"
25
26 #ifdef HAVE_NEON
27
28 #define QPEL_FUNC(name) \
29 extern "C" void ff_##name(int16_t *dst, ptrdiff_t dststride, const uint8_t *src, ptrdiff_t srcstride, \
30 int height, int width); \
31 void libde265_##name(int16_t *dst, ptrdiff_t dststride, const uint8_t *src, ptrdiff_t srcstride, \
32 int width, int height, int16_t* mcbuffer) { \
33 ff_##name(dst, dststride, src, srcstride, height, width); \
34 }
35
36 QPEL_FUNC(hevc_put_qpel_v1_neon_8);
37 QPEL_FUNC(hevc_put_qpel_v2_neon_8);
38 QPEL_FUNC(hevc_put_qpel_v3_neon_8);
39 QPEL_FUNC(hevc_put_qpel_h1_neon_8);
40 QPEL_FUNC(hevc_put_qpel_h2_neon_8);
41 QPEL_FUNC(hevc_put_qpel_h3_neon_8);
42 QPEL_FUNC(hevc_put_qpel_h1v1_neon_8);
43 QPEL_FUNC(hevc_put_qpel_h1v2_neon_8);
44 QPEL_FUNC(hevc_put_qpel_h1v3_neon_8);
45 QPEL_FUNC(hevc_put_qpel_h2v1_neon_8);
46 QPEL_FUNC(hevc_put_qpel_h2v2_neon_8);
47 QPEL_FUNC(hevc_put_qpel_h2v3_neon_8);
48 QPEL_FUNC(hevc_put_qpel_h3v1_neon_8);
49 QPEL_FUNC(hevc_put_qpel_h3v2_neon_8);
50 QPEL_FUNC(hevc_put_qpel_h3v3_neon_8);
51 #undef QPEL_FUNC
52
53 #if defined(HAVE_SIGNAL_H) && defined(HAVE_SETJMP_H)
54
55 #include <signal.h>
56 #include <setjmp.h>
57
58 extern "C" void libde265_detect_neon(void);
59
60 static jmp_buf jump_env;
61
62 static void sighandler(int sig) {
63 (void)sig;
64 longjmp(jump_env, 1);
65 }
66
67 static bool has_NEON() {
68 static bool checked_NEON = false;
69 static bool have_NEON = false;
70
71 if (!checked_NEON) {
72 void (*oldsignal)(int);
73
74 checked_NEON = true;
75 oldsignal = signal(SIGILL, sighandler);
76 if (setjmp(jump_env)) {
77 signal(SIGILL, oldsignal);
78 have_NEON = false;
79 return false;
80 }
81 libde265_detect_neon();
82 signal(SIGILL, oldsignal);
83 have_NEON = true;
84 }
85
86 return have_NEON;
87 }
88
89 #else // #if defined(HAVE_SIGNAL_H) && defined(HAVE_SETJMP_H)
90
91 #warning "Don't know how to detect NEON support at runtime- will be disabled"
92
93 static bool has_NEON() {
94 return false;
95 }
96
97 #endif
98
99 #endif // #ifdef HAVE_NEON
100
101 void init_acceleration_functions_arm(struct acceleration_functions* accel)
102 {
103 #ifdef HAVE_NEON
104 if (has_NEON()) {
105 accel->put_hevc_qpel_8[0][1] = libde265_hevc_put_qpel_v1_neon_8;
106 accel->put_hevc_qpel_8[0][2] = libde265_hevc_put_qpel_v2_neon_8;
107 accel->put_hevc_qpel_8[0][3] = libde265_hevc_put_qpel_v3_neon_8;
108 accel->put_hevc_qpel_8[1][0] = libde265_hevc_put_qpel_h1_neon_8;
109 accel->put_hevc_qpel_8[1][1] = libde265_hevc_put_qpel_h1v1_neon_8;
110 accel->put_hevc_qpel_8[1][2] = libde265_hevc_put_qpel_h1v2_neon_8;
111 accel->put_hevc_qpel_8[1][3] = libde265_hevc_put_qpel_h1v3_neon_8;
112 accel->put_hevc_qpel_8[2][0] = libde265_hevc_put_qpel_h2_neon_8;
113 accel->put_hevc_qpel_8[2][1] = libde265_hevc_put_qpel_h2v1_neon_8;
114 accel->put_hevc_qpel_8[2][2] = libde265_hevc_put_qpel_h2v2_neon_8;
115 accel->put_hevc_qpel_8[2][3] = libde265_hevc_put_qpel_h2v3_neon_8;
116 accel->put_hevc_qpel_8[3][0] = libde265_hevc_put_qpel_h3_neon_8;
117 accel->put_hevc_qpel_8[3][1] = libde265_hevc_put_qpel_h3v1_neon_8;
118 accel->put_hevc_qpel_8[3][2] = libde265_hevc_put_qpel_h3v2_neon_8;
119 accel->put_hevc_qpel_8[3][3] = libde265_hevc_put_qpel_h3v3_neon_8;
120 }
121 #endif // #ifdef HAVE_NEON
122 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2015 struktur AG, Joachim Bauch <bauch@struktur.de>
3 *
4 * This file is part of libde265.
5 *
6 * libde265 is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation, either version 3 of
9 * the License, or (at your option) any later version.
10 *
11 * libde265 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
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with libde265. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef LIBDE265_ARM_H
21 #define LIBDE265_ARM_H
22
23 #include "acceleration.h"
24
25 void init_acceleration_functions_arm(struct acceleration_functions* accel);
26
27 #endif // LIBDE265_ARM_H
0 /*
1 * Copyright (c) 2008 Mans Rullgard <mans@mansr.com>
2 *
3 * This file is part of FFmpeg.
4 *
5 * FFmpeg is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * FFmpeg 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 GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with FFmpeg; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #include "config.h"
21
22 #ifdef __ELF__
23 # define ELF
24 #else
25 # define ELF @
26 #endif
27
28 #if CONFIG_THUMB
29 # define A @
30 # define T
31 #else
32 # define A
33 # define T @
34 #endif
35
36 #if HAVE_AS_FUNC
37 # define FUNC
38 #else
39 # define FUNC @
40 #endif
41
42 #if HAVE_NEON
43 .arch armv7-a
44 #elif HAVE_ARMV6T2
45 .arch armv6t2
46 #elif HAVE_ARMV6
47 .arch armv6
48 #elif HAVE_ARMV5TE
49 .arch armv5te
50 #endif
51
52 #if HAVE_NEON
53 .fpu neon
54 #elif HAVE_VFP
55 .fpu vfp
56 #endif
57
58 .syntax unified
59 T .thumb
60 ELF .eabi_attribute 25, 1 @ Tag_ABI_align_preserved
61 ELF .section .note.GNU-stack,"",%progbits @ Mark stack as non-executable
62
63 .macro function name, export=0, align=2
64 .set .Lpic_idx, 0
65 .set .Lpic_gp, 0
66 .macro endfunc
67 .if .Lpic_idx
68 .align 2
69 .altmacro
70 put_pic %(.Lpic_idx - 1)
71 .noaltmacro
72 .endif
73 ELF .size \name, . - \name
74 FUNC .endfunc
75 .purgem endfunc
76 .endm
77 .text
78 .align \align
79 .if \export
80 .global EXTERN_ASM\name
81 ELF .type EXTERN_ASM\name, %function
82 FUNC .func EXTERN_ASM\name
83 EXTERN_ASM\name:
84 .else
85 ELF .type \name, %function
86 FUNC .func \name
87 \name:
88 .endif
89 .endm
90
91 .macro const name, align=2, relocate=0
92 .macro endconst
93 ELF .size \name, . - \name
94 .purgem endconst
95 .endm
96 .if HAVE_SECTION_DATA_REL_RO && \relocate
97 .section .data.rel.ro
98 .else
99 .section .rodata
100 .endif
101 .align \align
102 \name:
103 .endm
104
105 #if !HAVE_ARMV6T2_EXTERNAL
106 .macro movw rd, val
107 mov \rd, \val & 255
108 orr \rd, \val & ~255
109 .endm
110 #endif
111
112 .macro mov32 rd, val
113 #if HAVE_ARMV6T2_EXTERNAL
114 movw \rd, #(\val) & 0xffff
115 .if (\val) >> 16
116 movt \rd, #(\val) >> 16
117 .endif
118 #else
119 ldr \rd, =\val
120 #endif
121 .endm
122
123 .macro put_pic num
124 put_pic_\num
125 .endm
126
127 .macro do_def_pic num, val, label
128 .macro put_pic_\num
129 .if \num
130 .altmacro
131 put_pic %(\num - 1)
132 .noaltmacro
133 .endif
134 \label: .word \val
135 .purgem put_pic_\num
136 .endm
137 .endm
138
139 .macro def_pic val, label
140 .altmacro
141 do_def_pic %.Lpic_idx, \val, \label
142 .noaltmacro
143 .set .Lpic_idx, .Lpic_idx + 1
144 .endm
145
146 .macro ldpic rd, val, indir=0
147 ldr \rd, .Lpicoff\@
148 .Lpic\@:
149 .if \indir
150 A ldr \rd, [pc, \rd]
151 T add \rd, pc
152 T ldr \rd, [\rd]
153 .else
154 add \rd, pc
155 .endif
156 def_pic \val - (.Lpic\@ + (8 >> CONFIG_THUMB)), .Lpicoff\@
157 .endm
158
159 .macro movrel rd, val
160 #if CONFIG_PIC
161 ldpic \rd, \val
162 #elif HAVE_ARMV6T2_EXTERNAL && !defined(__APPLE__)
163 movw \rd, #:lower16:\val
164 movt \rd, #:upper16:\val
165 #else
166 ldr \rd, =\val
167 #endif
168 .endm
169
170 .macro movrelx rd, val, gp
171 #if CONFIG_PIC && defined(__ELF__)
172 .ifnb \gp
173 .if .Lpic_gp
174 .unreq gp
175 .endif
176 gp .req \gp
177 ldpic gp, _GLOBAL_OFFSET_TABLE_
178 .elseif !.Lpic_gp
179 gp .req r12
180 ldpic gp, _GLOBAL_OFFSET_TABLE_
181 .endif
182 .set .Lpic_gp, 1
183 ldr \rd, .Lpicoff\@
184 ldr \rd, [gp, \rd]
185 def_pic \val(GOT), .Lpicoff\@
186 #elif CONFIG_PIC && defined(__APPLE__)
187 ldpic \rd, .Lpic\@, indir=1
188 .non_lazy_symbol_pointer
189 .Lpic\@:
190 .indirect_symbol \val
191 .word 0
192 .text
193 #else
194 movrel \rd, \val
195 #endif
196 .endm
197
198 .macro add_sh rd, rn, rm, sh:vararg
199 A add \rd, \rn, \rm, \sh
200 T mov \rm, \rm, \sh
201 T add \rd, \rn, \rm
202 .endm
203
204 .macro ldr_pre rt, rn, rm:vararg
205 A ldr \rt, [\rn, \rm]!
206 T add \rn, \rn, \rm
207 T ldr \rt, [\rn]
208 .endm
209
210 .macro ldr_dpre rt, rn, rm:vararg
211 A ldr \rt, [\rn, -\rm]!
212 T sub \rn, \rn, \rm
213 T ldr \rt, [\rn]
214 .endm
215
216 .macro ldr_nreg rt, rn, rm:vararg
217 A ldr \rt, [\rn, -\rm]
218 T sub \rt, \rn, \rm
219 T ldr \rt, [\rt]
220 .endm
221
222 .macro ldr_post rt, rn, rm:vararg
223 A ldr \rt, [\rn], \rm
224 T ldr \rt, [\rn]
225 T add \rn, \rn, \rm
226 .endm
227
228 .macro ldrc_pre cc, rt, rn, rm:vararg
229 A ldr\cc \rt, [\rn, \rm]!
230 T itt \cc
231 T add\cc \rn, \rn, \rm
232 T ldr\cc \rt, [\rn]
233 .endm
234
235 .macro ldrd_reg rt, rt2, rn, rm
236 A ldrd \rt, \rt2, [\rn, \rm]
237 T add \rt, \rn, \rm
238 T ldrd \rt, \rt2, [\rt]
239 .endm
240
241 .macro ldrd_post rt, rt2, rn, rm
242 A ldrd \rt, \rt2, [\rn], \rm
243 T ldrd \rt, \rt2, [\rn]
244 T add \rn, \rn, \rm
245 .endm
246
247 .macro ldrh_pre rt, rn, rm
248 A ldrh \rt, [\rn, \rm]!
249 T add \rn, \rn, \rm
250 T ldrh \rt, [\rn]
251 .endm
252
253 .macro ldrh_dpre rt, rn, rm
254 A ldrh \rt, [\rn, -\rm]!
255 T sub \rn, \rn, \rm
256 T ldrh \rt, [\rn]
257 .endm
258
259 .macro ldrh_post rt, rn, rm
260 A ldrh \rt, [\rn], \rm
261 T ldrh \rt, [\rn]
262 T add \rn, \rn, \rm
263 .endm
264
265 .macro ldrb_post rt, rn, rm
266 A ldrb \rt, [\rn], \rm
267 T ldrb \rt, [\rn]
268 T add \rn, \rn, \rm
269 .endm
270
271 .macro str_post rt, rn, rm:vararg
272 A str \rt, [\rn], \rm
273 T str \rt, [\rn]
274 T add \rn, \rn, \rm
275 .endm
276
277 .macro strb_post rt, rn, rm:vararg
278 A strb \rt, [\rn], \rm
279 T strb \rt, [\rn]
280 T add \rn, \rn, \rm
281 .endm
282
283 .macro strd_post rt, rt2, rn, rm
284 A strd \rt, \rt2, [\rn], \rm
285 T strd \rt, \rt2, [\rn]
286 T add \rn, \rn, \rm
287 .endm
288
289 .macro strh_pre rt, rn, rm
290 A strh \rt, [\rn, \rm]!
291 T add \rn, \rn, \rm
292 T strh \rt, [\rn]
293 .endm
294
295 .macro strh_dpre rt, rn, rm
296 A strh \rt, [\rn, -\rm]!
297 T sub \rn, \rn, \rm
298 T strh \rt, [\rn]
299 .endm
300
301 .macro strh_post rt, rn, rm
302 A strh \rt, [\rn], \rm
303 T strh \rt, [\rn]
304 T add \rn, \rn, \rm
305 .endm
306
307 .macro strh_dpost rt, rn, rm
308 A strh \rt, [\rn], -\rm
309 T strh \rt, [\rn]
310 T sub \rn, \rn, \rm
311 .endm
312
313 #if HAVE_VFP_ARGS
314 ELF .eabi_attribute 28, 1
315 # define VFP
316 # define NOVFP @
317 #else
318 # define VFP @
319 # define NOVFP
320 #endif
321
322 #define GLUE(a, b) a ## b
323 #define JOIN(a, b) GLUE(a, b)
324 #define X(s) JOIN(EXTERN_ASM, s)
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2015 struktur AG, Joachim Bauch <bauch@struktur.de>
3 *
4 * This file is part of libde265.
5 *
6 * libde265 is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation, either version 3 of
9 * the License, or (at your option) any later version.
10 *
11 * libde265 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
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with libde265. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "asm.S"
21 #include "neon.S"
22
23 // we execute a simple NEON instruction and check if SIGILL is triggered to
24 // detect if the CPU support NEON code
25 function libde265_detect_neon, export=1
26 vand q0, q0, q0
27 bx lr
28 endfunc
0 /*
1 * Copyright (c) 2014 - 2015 Seppo Tomperi <seppo.tomperi@vtt.fi>
2 *
3 * This file is part of FFmpeg.
4 *
5 * FFmpeg is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * FFmpeg 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 GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with FFmpeg; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 /*
21 * This is commit 63ca0fe8288dbd300c9bb814cb671e5d889f691c from
22 * https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/arm/hevcdsp_qpel_neon.S
23 */
24
25 #include "asm.S"
26 #include "neon.S"
27
28 #define MAX_PB_SIZE #64
29
30 .macro regshuffle_d8
31 vmov d16, d17
32 vmov d17, d18
33 vmov d18, d19
34 vmov d19, d20
35 vmov d20, d21
36 vmov d21, d22
37 vmov d22, d23
38 .endm
39
40 .macro regshuffle_q8
41 vmov q0, q1
42 vmov q1, q2
43 vmov q2, q3
44 vmov q3, q4
45 vmov q4, q5
46 vmov q5, q6
47 vmov q6, q7
48 .endm
49
50 .macro vextin8
51 pld [r2]
52 vld1.8 {q11}, [r2], r3
53 vext.8 d16, d22, d23, #1
54 vext.8 d17, d22, d23, #2
55 vext.8 d18, d22, d23, #3
56 vext.8 d19, d22, d23, #4
57 vext.8 d20, d22, d23, #5
58 vext.8 d21, d22, d23, #6
59 vext.8 d22, d22, d23, #7
60 .endm
61
62 .macro loadin8
63 pld [r2]
64 vld1.8 {d16}, [r2], r3
65 pld [r2]
66 vld1.8 {d17}, [r2], r3
67 pld [r2]
68 vld1.8 {d18}, [r2], r3
69 pld [r2]
70 vld1.8 {d19}, [r2], r3
71 pld [r2]
72 vld1.8 {d20}, [r2], r3
73 pld [r2]
74 vld1.8 {d21}, [r2], r3
75 pld [r2]
76 vld1.8 {d22}, [r2], r3
77 pld [r2]
78 vld1.8 {d23}, [r2], r3
79 .endm
80
81 .macro qpel_filter_1_32b
82 vmov.i16 d16, #58
83 vmov.i16 d17, #10
84 vmull.s16 q9, d6, d16 // 58 * d0
85 vmull.s16 q10, d7, d16 // 58 * d1
86 vmov.i16 d16, #17
87 vmull.s16 q11, d4, d17 // 10 * c0
88 vmull.s16 q12, d5, d17 // 10 * c1
89 vmov.i16 d17, #5
90 vmull.s16 q13, d8, d16 // 17 * e0
91 vmull.s16 q14, d9, d16 // 17 * e1
92 vmull.s16 q15, d10, d17 // 5 * f0
93 vmull.s16 q8, d11, d17 // 5 * f1
94 vsub.s32 q9, q11 // 58 * d0 - 10 * c0
95 vsub.s32 q10, q12 // 58 * d1 - 10 * c1
96 vshll.s16 q11, d2, #2 // 4 * b0
97 vshll.s16 q12, d3, #2 // 4 * b1
98 vadd.s32 q9, q13 // 58 * d0 - 10 * c0 + 17 * e0
99 vadd.s32 q10, q14 // 58 * d1 - 10 * c1 + 17 * e1
100 vsubl.s16 q13, d12, d0 // g0 - a0
101 vsubl.s16 q14, d13, d1 // g1 - a1
102 vadd.s32 q9, q11 // 58 * d0 - 10 * c0 + 17 * e0 + 4 * b0
103 vadd.s32 q10, q12 // 58 * d1 - 10 * c1 + 17 * e1 + 4 * b1
104 vsub.s32 q13, q15 // g0 - a0 - 5 * f0
105 vsub.s32 q14, q8 // g1 - a1 - 5 * f1
106 vadd.s32 q9, q13 // 58 * d0 - 10 * c0 + 17 * e0 + 4 * b0 + g0 - a0 - 5 * f0
107 vadd.s32 q10, q14 // 58 * d1 - 10 * c1 + 17 * e1 + 4 * b1 + g1 - a1 - 5 * f1
108 vqshrn.s32 d16, q9, #6
109 vqshrn.s32 d17, q10, #6
110 .endm
111
112 // input q0 - q7
113 // output q8
114 .macro qpel_filter_2_32b
115 vmov.i32 q8, #11
116 vaddl.s16 q9, d6, d8 // d0 + e0
117 vaddl.s16 q10, d7, d9 // d1 + e1
118 vaddl.s16 q11, d4, d10 // c0 + f0
119 vaddl.s16 q12, d5, d11 // c1 + f1
120 vmul.s32 q11, q8 // 11 * (c0 + f0)
121 vmul.s32 q12, q8 // 11 * (c1 + f1)
122 vmov.i32 q8, #40
123 vaddl.s16 q15, d2, d12 // b0 + g0
124 vmul.s32 q9, q8 // 40 * (d0 + e0)
125 vmul.s32 q10, q8 // 40 * (d1 + e1)
126 vaddl.s16 q8, d3, d13 // b1 + g1
127 vaddl.s16 q13, d0, d14 // a0 + h0
128 vaddl.s16 q14, d1, d15 // a1 + h1
129 vshl.s32 q15, #2 // 4*(b0+g0)
130 vshl.s32 q8, #2 // 4*(b1+g1)
131 vadd.s32 q11, q13 // 11 * (c0 + f0) + a0 + h0
132 vadd.s32 q12, q14 // 11 * (c1 + f1) + a1 + h1
133 vadd.s32 q9, q15 // 40 * (d0 + e0) + 4*(b0+g0)
134 vadd.s32 q10, q8 // 40 * (d1 + e1) + 4*(b1+g1)
135 vsub.s32 q9, q11 // 40 * (d0 + e0) + 4*(b0+g0) - (11 * (c0 + f0) + a0 + h0)
136 vsub.s32 q10, q12 // 40 * (d1 + e1) + 4*(b1+g1) - (11 * (c1 + f1) + a1 + h1)
137 vqshrn.s32 d16, q9, #6
138 vqshrn.s32 d17, q10, #6
139 .endm
140
141 .macro qpel_filter_3_32b
142 vmov.i16 d16, #58
143 vmov.i16 d17, #10
144 vmull.s16 q9, d8, d16 // 58 * d0
145 vmull.s16 q10, d9, d16 // 58 * d1
146 vmov.i16 d16, #17
147 vmull.s16 q11, d10, d17 // 10 * c0
148 vmull.s16 q12, d11, d17 // 10 * c1
149 vmov.i16 d17, #5
150 vmull.s16 q13, d6, d16 // 17 * e0
151 vmull.s16 q14, d7, d16 // 17 * e1
152 vmull.s16 q15, d4, d17 // 5 * f0
153 vmull.s16 q8, d5, d17 // 5 * f1
154 vsub.s32 q9, q11 // 58 * d0 - 10 * c0
155 vsub.s32 q10, q12 // 58 * d1 - 10 * c1
156 vshll.s16 q11, d12, #2 // 4 * b0
157 vshll.s16 q12, d13, #2 // 4 * b1
158 vadd.s32 q9, q13 // 58 * d0 - 10 * c0 + 17 * e0
159 vadd.s32 q10, q14 // 58 * d1 - 10 * c1 + 17 * e1
160 vsubl.s16 q13, d2, d14 // g0 - a0
161 vsubl.s16 q14, d3, d15 // g1 - a1
162 vadd.s32 q9, q11 // 58 * d0 - 10 * c0 + 17 * e0 + 4 * b0
163 vadd.s32 q10, q12 // 58 * d1 - 10 * c1 + 17 * e1 + 4 * b1
164 vsub.s32 q13, q15 // g0 - a0 - 5 * f0
165 vsub.s32 q14, q8 // g1 - a1 - 5 * f1
166 vadd.s32 q9, q13 // 58 * d0 - 10 * c0 + 17 * e0 + 4 * b0 + g0 - a0 - 5 * f0
167 vadd.s32 q10, q14 // 58 * d1 - 10 * c1 + 17 * e1 + 4 * b1 + g1 - a1 - 5 * f1
168 vqshrn.s32 d16, q9, #6
169 vqshrn.s32 d17, q10, #6
170 .endm
171
172 .macro qpel_filter_1 out=q7
173 vmov.u8 d24, #58
174 vmov.u8 d25, #10
175 vshll.u8 q13, d20, #4 // 16*e
176 vshll.u8 q14, d21, #2 // 4*f
177 vmull.u8 \out, d19, d24 // 58*d
178 vaddw.u8 q13, q13, d20 // 17*e
179 vmull.u8 q15, d18, d25 // 10*c
180 vaddw.u8 q14, q14, d21 // 5*f
181 vsubl.u8 q12, d22, d16 // g - a
182 vadd.u16 \out, q13 // 58d + 17e
183 vshll.u8 q13, d17, #2 // 4*b
184 vadd.u16 q15, q14 // 10*c + 5*f
185 vadd.s16 q13, q12 // - a + 4*b + g
186 vsub.s16 \out, q15 // -10*c + 58*d + 17*e -5*f
187 vadd.s16 \out, q13 // -a + 4*b -10*c + 58*d + 17*e -5*f
188 .endm
189
190 .macro qpel_filter_2 out=q7
191 vmov.i16 q12, #10
192 vmov.i16 q14, #11
193 vaddl.u8 q13, d19, d20 // d + e
194 vaddl.u8 q15, d18, d21 // c + f
195 vmul.u16 q13, q12 // 10 * (d+e)
196 vmul.u16 q15, q14 // 11 * ( c + f)
197 vaddl.u8 \out, d17, d22 // b + g
198 vaddl.u8 q12, d16, d23 // a + h
199 vadd.u16 \out, q13 // b + 10 * (d + e) + g
200 vadd.s16 q12, q15
201 vshl.u16 \out, #2 // 4 * (b + 10 * (d + e) + g)
202 vsub.s16 \out, q12
203 .endm
204
205 .macro qpel_filter_3 out=q7
206 vmov.u8 d24, #58
207 vmov.u8 d25, #10
208 vshll.u8 q13, d19, #4 // 16*e
209 vshll.u8 q14, d18, #2 // 4*f
210 vmull.u8 \out, d20, d24 // 58*d
211 vaddw.u8 q13, q13, d19 // 17*e
212 vmull.u8 q15, d21, d25 // 10*c
213 vaddw.u8 q14, q14, d18 // 5*f
214 vsubl.u8 q12, d17, d23 // g - a
215 vadd.u16 \out, q13 // 58d + 17e
216 vshll.u8 q13, d22, #2 // 4*b
217 vadd.u16 q15, q14 // 10*c + 5*f
218 vadd.s16 q13, q12 // - a + 4*b + g
219 vsub.s16 \out, q15 // -10*c + 58*d + 17*e -5*f
220 vadd.s16 \out, q13 // -a + 4*b -10*c + 58*d + 17*e -5*f
221 .endm
222
223 .macro hevc_put_qpel_vX_neon_8 filter
224 push {r4, r5, r6, r7}
225 ldr r4, [sp, #16] // height
226 ldr r5, [sp, #20] // width
227 vpush {d8-d15}
228 sub r2, r2, r3, lsl #1
229 sub r2, r3
230 mov r12, r4
231 mov r6, r0
232 mov r7, r2
233 lsl r1, #1
234 0: loadin8
235 cmp r5, #4
236 beq 4f
237 8: subs r4, #1
238 \filter
239 vst1.16 {q7}, [r0], r1
240 regshuffle_d8
241 vld1.8 {d23}, [r2], r3
242 bne 8b
243 subs r5, #8
244 beq 99f
245 mov r4, r12
246 add r6, #16
247 mov r0, r6
248 add r7, #8
249 mov r2, r7
250 b 0b
251 4: subs r4, #1
252 \filter
253 vst1.16 d14, [r0], r1
254 regshuffle_d8
255 vld1.32 {d23[0]}, [r2], r3
256 bne 4b
257 99: vpop {d8-d15}
258 pop {r4, r5, r6, r7}
259 bx lr
260 .endm
261
262 .macro hevc_put_qpel_uw_vX_neon_8 filter
263 push {r4-r10}
264 ldr r5, [sp, #28] // width
265 ldr r4, [sp, #32] // height
266 ldr r8, [sp, #36] // src2
267 ldr r9, [sp, #40] // src2stride
268 vpush {d8-d15}
269 sub r2, r2, r3, lsl #1
270 sub r2, r3
271 mov r12, r4
272 mov r6, r0
273 mov r7, r2
274 cmp r8, #0
275 bne .Lbi\@
276 0: loadin8
277 cmp r5, #4
278 beq 4f
279 8: subs r4, #1
280 \filter
281 vqrshrun.s16 d0, q7, #6
282 vst1.8 d0, [r0], r1
283 regshuffle_d8
284 vld1.8 {d23}, [r2], r3
285 bne 8b
286 subs r5, #8
287 beq 99f
288 mov r4, r12
289 add r6, #8
290 mov r0, r6
291 add r7, #8
292 mov r2, r7
293 b 0b
294 4: subs r4, #1
295 \filter
296 vqrshrun.s16 d0, q7, #6
297 vst1.32 d0[0], [r0], r1
298 regshuffle_d8
299 vld1.32 {d23[0]}, [r2], r3
300 bne 4b
301 b 99f
302 .Lbi\@: lsl r9, #1
303 mov r10, r8
304 0: loadin8
305 cmp r5, #4
306 beq 4f
307 8: subs r4, #1
308 \filter
309 vld1.16 {q0}, [r8], r9
310 vqadd.s16 q0, q7
311 vqrshrun.s16 d0, q0, #7
312 vst1.8 d0, [r0], r1
313 regshuffle_d8
314 vld1.8 {d23}, [r2], r3
315 bne 8b
316 subs r5, #8
317 beq 99f
318 mov r4, r12
319 add r6, #8
320 mov r0, r6
321 add r10, #16
322 mov r8, r10
323 add r7, #8
324 mov r2, r7
325 b 0b
326 4: subs r4, #1
327 \filter
328 vld1.16 d0, [r8], r9
329 vqadd.s16 d0, d14
330 vqrshrun.s16 d0, q0, #7
331 vst1.32 d0[0], [r0], r1
332 regshuffle_d8
333 vld1.32 {d23[0]}, [r2], r3
334 bne 4b
335 99: vpop {d8-d15}
336 pop {r4-r10}
337 bx lr
338 .endm
339
340 function ff_hevc_put_qpel_v1_neon_8, export=1
341 hevc_put_qpel_vX_neon_8 qpel_filter_1
342 endfunc
343
344 function ff_hevc_put_qpel_v2_neon_8, export=1
345 hevc_put_qpel_vX_neon_8 qpel_filter_2
346 endfunc
347
348 function ff_hevc_put_qpel_v3_neon_8, export=1
349 hevc_put_qpel_vX_neon_8 qpel_filter_3
350 endfunc
351
352
353 function ff_hevc_put_qpel_uw_v1_neon_8, export=1
354 hevc_put_qpel_uw_vX_neon_8 qpel_filter_1
355 endfunc
356
357 function ff_hevc_put_qpel_uw_v2_neon_8, export=1
358 hevc_put_qpel_uw_vX_neon_8 qpel_filter_2
359 endfunc
360
361 function ff_hevc_put_qpel_uw_v3_neon_8, export=1
362 hevc_put_qpel_uw_vX_neon_8 qpel_filter_3
363 endfunc
364
365 .macro hevc_put_qpel_hX_neon_8 filter
366 push {r4, r5, r6, r7}
367 ldr r4, [sp, #16] // height
368 ldr r5, [sp, #20] // width
369
370 vpush {d8-d15}
371 sub r2, #4
372 lsl r1, #1
373 mov r12, r4
374 mov r6, r0
375 mov r7, r2
376 cmp r5, #4
377 beq 4f
378 8: subs r4, #1
379 vextin8
380 \filter
381 vst1.16 {q7}, [r0], r1
382 bne 8b
383 subs r5, #8
384 beq 99f
385 mov r4, r12
386 add r6, #16
387 mov r0, r6
388 add r7, #8
389 mov r2, r7
390 cmp r5, #4
391 bne 8b
392 4: subs r4, #1
393 vextin8
394 \filter
395 vst1.16 d14, [r0], r1
396 bne 4b
397 99: vpop {d8-d15}
398 pop {r4, r5, r6, r7}
399 bx lr
400 .endm
401
402 .macro hevc_put_qpel_uw_hX_neon_8 filter
403 push {r4-r10}
404 ldr r5, [sp, #28] // width
405 ldr r4, [sp, #32] // height
406 ldr r8, [sp, #36] // src2
407 ldr r9, [sp, #40] // src2stride
408 vpush {d8-d15}
409 sub r2, #4
410 mov r12, r4
411 mov r6, r0
412 mov r7, r2
413 cmp r8, #0
414 bne .Lbi\@
415 cmp r5, #4
416 beq 4f
417 8: subs r4, #1
418 vextin8
419 \filter
420 vqrshrun.s16 d0, q7, #6
421 vst1.8 d0, [r0], r1
422 bne 8b
423 subs r5, #8
424 beq 99f
425 mov r4, r12
426 add r6, #8
427 mov r0, r6
428 add r7, #8
429 mov r2, r7
430 cmp r5, #4
431 bne 8b
432 4: subs r4, #1
433 vextin8
434 \filter
435 vqrshrun.s16 d0, q7, #6
436 vst1.32 d0[0], [r0], r1
437 bne 4b
438 b 99f
439 .Lbi\@:
440 lsl r9, #1
441 cmp r5, #4
442 beq 4f
443 mov r10, r8
444 8: subs r4, #1
445 vextin8
446 \filter
447 vld1.16 {q0}, [r8], r9
448 vqadd.s16 q0, q7
449 vqrshrun.s16 d0, q0, #7
450 vst1.8 d0, [r0], r1
451 bne 8b
452 subs r5, #8
453 beq 99f
454 mov r4, r12
455 add r6, #8
456 add r10, #16
457 mov r8, r10
458 mov r0, r6
459 add r7, #8
460 mov r2, r7
461 cmp r5, #4
462 bne 8b
463 4: subs r4, #1
464 vextin8
465 \filter
466 vld1.16 d0, [r8], r9
467 vqadd.s16 d0, d14
468 vqrshrun.s16 d0, q0, #7
469 vst1.32 d0[0], [r0], r1
470 bne 4b
471 99: vpop {d8-d15}
472 pop {r4-r10}
473 bx lr
474 .endm
475
476 function ff_hevc_put_qpel_h1_neon_8, export=1
477 hevc_put_qpel_hX_neon_8 qpel_filter_1
478 endfunc
479
480 function ff_hevc_put_qpel_h2_neon_8, export=1
481 hevc_put_qpel_hX_neon_8 qpel_filter_2
482 endfunc
483
484 function ff_hevc_put_qpel_h3_neon_8, export=1
485 hevc_put_qpel_hX_neon_8 qpel_filter_3
486 endfunc
487
488
489 function ff_hevc_put_qpel_uw_h1_neon_8, export=1
490 hevc_put_qpel_uw_hX_neon_8 qpel_filter_1
491 endfunc
492
493 function ff_hevc_put_qpel_uw_h2_neon_8, export=1
494 hevc_put_qpel_uw_hX_neon_8 qpel_filter_2
495 endfunc
496
497 function ff_hevc_put_qpel_uw_h3_neon_8, export=1
498 hevc_put_qpel_uw_hX_neon_8 qpel_filter_3
499 endfunc
500
501 .macro hevc_put_qpel_hXvY_neon_8 filterh filterv
502 push {r4, r5, r6, r7}
503 ldr r4, [sp, #16] // height
504 ldr r5, [sp, #20] // width
505
506 vpush {d8-d15}
507 sub r2, #4
508 sub r2, r2, r3, lsl #1
509 sub r2, r3 // extra_before 3
510 lsl r1, #1
511 mov r12, r4
512 mov r6, r0
513 mov r7, r2
514 0: vextin8
515 \filterh q0
516 vextin8
517 \filterh q1
518 vextin8
519 \filterh q2
520 vextin8
521 \filterh q3
522 vextin8
523 \filterh q4
524 vextin8
525 \filterh q5
526 vextin8
527 \filterh q6
528 vextin8
529 \filterh q7
530 cmp r5, #4
531 beq 4f
532 8: subs r4, #1
533 \filterv
534 vst1.16 {q8}, [r0], r1
535 regshuffle_q8
536 vextin8
537 \filterh q7
538 bne 8b
539 subs r5, #8
540 beq 99f
541 mov r4, r12
542 add r6, #16
543 mov r0, r6
544 add r7, #8
545 mov r2, r7
546 b 0b
547 4: subs r4, #1
548 \filterv
549 vst1.16 d16, [r0], r1
550 regshuffle_q8
551 vextin8
552 \filterh q7
553 bne 4b
554 99: vpop {d8-d15}
555 pop {r4, r5, r6, r7}
556 bx lr
557 .endm
558
559 .macro hevc_put_qpel_uw_hXvY_neon_8 filterh filterv
560 push {r4-r10}
561 ldr r5, [sp, #28] // width
562 ldr r4, [sp, #32] // height
563 ldr r8, [sp, #36] // src2
564 ldr r9, [sp, #40] // src2stride
565 vpush {d8-d15}
566 sub r2, #4
567 sub r2, r2, r3, lsl #1
568 sub r2, r3 // extra_before 3
569 mov r12, r4
570 mov r6, r0
571 mov r7, r2
572 cmp r8, #0
573 bne .Lbi\@
574 0: vextin8
575 \filterh q0
576 vextin8
577 \filterh q1
578 vextin8
579 \filterh q2
580 vextin8
581 \filterh q3
582 vextin8
583 \filterh q4
584 vextin8
585 \filterh q5
586 vextin8
587 \filterh q6
588 vextin8
589 \filterh q7
590 cmp r5, #4
591 beq 4f
592 8: subs r4, #1
593 \filterv
594 vqrshrun.s16 d0, q8, #6
595 vst1.8 d0, [r0], r1
596 regshuffle_q8
597 vextin8
598 \filterh q7
599 bne 8b
600 subs r5, #8
601 beq 99f
602 mov r4, r12
603 add r6, #8
604 mov r0, r6
605 add r7, #8
606 mov r2, r7
607 b 0b
608 4: subs r4, #1
609 \filterv
610 vqrshrun.s16 d0, q8, #6
611 vst1.32 d0[0], [r0], r1
612 regshuffle_q8
613 vextin8
614 \filterh q7
615 bne 4b
616 b 99f
617 .Lbi\@: lsl r9, #1
618 mov r10, r8
619 0: vextin8
620 \filterh q0
621 vextin8
622 \filterh q1
623 vextin8
624 \filterh q2
625 vextin8
626 \filterh q3
627 vextin8
628 \filterh q4
629 vextin8
630 \filterh q5
631 vextin8
632 \filterh q6
633 vextin8
634 \filterh q7
635 cmp r5, #4
636 beq 4f
637 8: subs r4, #1
638 \filterv
639 vld1.16 {q0}, [r8], r9
640 vqadd.s16 q0, q8
641 vqrshrun.s16 d0, q0, #7
642 vst1.8 d0, [r0], r1
643 regshuffle_q8
644 vextin8
645 \filterh q7
646 bne 8b
647 subs r5, #8
648 beq 99f
649 mov r4, r12
650 add r6, #8
651 mov r0, r6
652 add r10, #16
653 mov r8, r10
654 add r7, #8
655 mov r2, r7
656 b 0b
657 4: subs r4, #1
658 \filterv
659 vld1.16 d0, [r8], r9
660 vqadd.s16 d0, d16
661 vqrshrun.s16 d0, q0, #7
662 vst1.32 d0[0], [r0], r1
663 regshuffle_q8
664 vextin8
665 \filterh q7
666 bne 4b
667 99: vpop {d8-d15}
668 pop {r4-r10}
669 bx lr
670 .endm
671
672
673 function ff_hevc_put_qpel_h1v1_neon_8, export=1
674 hevc_put_qpel_hXvY_neon_8 qpel_filter_1 qpel_filter_1_32b
675 endfunc
676
677 function ff_hevc_put_qpel_h2v1_neon_8, export=1
678 hevc_put_qpel_hXvY_neon_8 qpel_filter_2 qpel_filter_1_32b
679 endfunc
680
681 function ff_hevc_put_qpel_h3v1_neon_8, export=1
682 hevc_put_qpel_hXvY_neon_8 qpel_filter_3 qpel_filter_1_32b
683 endfunc
684
685 function ff_hevc_put_qpel_h1v2_neon_8, export=1
686 hevc_put_qpel_hXvY_neon_8 qpel_filter_1 qpel_filter_2_32b
687 endfunc
688
689 function ff_hevc_put_qpel_h2v2_neon_8, export=1
690 hevc_put_qpel_hXvY_neon_8 qpel_filter_2 qpel_filter_2_32b
691 endfunc
692
693 function ff_hevc_put_qpel_h3v2_neon_8, export=1
694 hevc_put_qpel_hXvY_neon_8 qpel_filter_3 qpel_filter_2_32b
695 endfunc
696
697 function ff_hevc_put_qpel_h1v3_neon_8, export=1
698 hevc_put_qpel_hXvY_neon_8 qpel_filter_1 qpel_filter_3_32b
699 endfunc
700
701 function ff_hevc_put_qpel_h2v3_neon_8, export=1
702 hevc_put_qpel_hXvY_neon_8 qpel_filter_2 qpel_filter_3_32b
703 endfunc
704
705 function ff_hevc_put_qpel_h3v3_neon_8, export=1
706 hevc_put_qpel_hXvY_neon_8 qpel_filter_3 qpel_filter_3_32b
707 endfunc
708
709
710 function ff_hevc_put_qpel_uw_h1v1_neon_8, export=1
711 hevc_put_qpel_uw_hXvY_neon_8 qpel_filter_1 qpel_filter_1_32b
712 endfunc
713
714 function ff_hevc_put_qpel_uw_h2v1_neon_8, export=1
715 hevc_put_qpel_uw_hXvY_neon_8 qpel_filter_2 qpel_filter_1_32b
716 endfunc
717
718 function ff_hevc_put_qpel_uw_h3v1_neon_8, export=1
719 hevc_put_qpel_uw_hXvY_neon_8 qpel_filter_3 qpel_filter_1_32b
720 endfunc
721
722 function ff_hevc_put_qpel_uw_h1v2_neon_8, export=1
723 hevc_put_qpel_uw_hXvY_neon_8 qpel_filter_1 qpel_filter_2_32b
724 endfunc
725
726 function ff_hevc_put_qpel_uw_h2v2_neon_8, export=1
727 hevc_put_qpel_uw_hXvY_neon_8 qpel_filter_2 qpel_filter_2_32b
728 endfunc
729
730 function ff_hevc_put_qpel_uw_h3v2_neon_8, export=1
731 hevc_put_qpel_uw_hXvY_neon_8 qpel_filter_3 qpel_filter_2_32b
732 endfunc
733
734 function ff_hevc_put_qpel_uw_h1v3_neon_8, export=1
735 hevc_put_qpel_uw_hXvY_neon_8 qpel_filter_1 qpel_filter_3_32b
736 endfunc
737
738 function ff_hevc_put_qpel_uw_h2v3_neon_8, export=1
739 hevc_put_qpel_uw_hXvY_neon_8 qpel_filter_2 qpel_filter_3_32b
740 endfunc
741
742 function ff_hevc_put_qpel_uw_h3v3_neon_8, export=1
743 hevc_put_qpel_uw_hXvY_neon_8 qpel_filter_3 qpel_filter_3_32b
744 endfunc
745
746 .macro init_put_pixels
747 pld [r1]
748 pld [r1, r2]
749 mov r12, MAX_PB_SIZE
750 lsl r12, #1
751 .endm
752
753 function ff_hevc_put_pixels_w2_neon_8, export=1
754 init_put_pixels
755 vmov.u8 d5, #255
756 vshr.u64 d5, #32
757 0: subs r3, #1
758 vld1.32 {d0[0]}, [r1], r2
759 pld [r1]
760 vld1.32 d6, [r0]
761 vshll.u8 q0, d0, #6
762 vbit d6, d0, d5
763 vst1.32 d6, [r0], r12
764 bne 0b
765 bx lr
766 endfunc
767
768 function ff_hevc_put_pixels_w4_neon_8, export=1
769 init_put_pixels
770 0: subs r3, #2
771 vld1.32 {d0[0]}, [r1], r2
772 vld1.32 {d0[1]}, [r1], r2
773 pld [r1]
774 pld [r1, r2]
775 vshll.u8 q0, d0, #6
776 vst1.64 {d0}, [r0], r12
777 vst1.64 {d1}, [r0], r12
778 bne 0b
779 bx lr
780 endfunc
781
782 function ff_hevc_put_pixels_w6_neon_8, export=1
783 init_put_pixels
784 vmov.u8 q10, #255
785 vshr.u64 d21, #32
786 0: subs r3, #1
787 vld1.16 {d0}, [r1], r2
788 pld [r1]
789 vshll.u8 q0, d0, #6
790 vld1.8 {q12}, [r0]
791 vbit q12, q0, q10
792 vst1.8 {q12}, [r0], r12
793 bne 0b
794 bx lr
795 endfunc
796
797 function ff_hevc_put_pixels_w8_neon_8, export=1
798 init_put_pixels
799 0: subs r3, #2
800 vld1.8 {d0}, [r1], r2
801 vld1.8 {d2}, [r1], r2
802 pld [r1]
803 pld [r1, r2]
804 vshll.u8 q0, d0, #6
805 vshll.u8 q1, d2, #6
806 vst1.16 {q0}, [r0], r12
807 vst1.16 {q1}, [r0], r12
808 bne 0b
809 bx lr
810 endfunc
811
812 function ff_hevc_put_pixels_w12_neon_8, export=1
813 init_put_pixels
814 0: subs r3, #2
815 vld1.64 {d0}, [r1]
816 add r1, #8
817 vld1.32 {d1[0]}, [r1], r2
818 sub r1, #8
819 vld1.64 {d2}, [r1]
820 add r1, #8
821 vld1.32 {d1[1]}, [r1], r2
822 sub r1, #8
823 pld [r1]
824 pld [r1, r2]
825 vshll.u8 q8, d0, #6
826 vshll.u8 q9, d1, #6
827 vshll.u8 q10, d2, #6
828 vmov d22, d19
829 vst1.64 {d16, d17, d18}, [r0], r12
830 vst1.64 {d20, d21, d22}, [r0], r12
831 bne 0b
832 bx lr
833 endfunc
834
835 function ff_hevc_put_pixels_w16_neon_8, export=1
836 init_put_pixels
837 0: subs r3, #2
838 vld1.8 {q0}, [r1], r2
839 vld1.8 {q1}, [r1], r2
840 pld [r1]
841 pld [r1, r2]
842 vshll.u8 q8, d0, #6
843 vshll.u8 q9, d1, #6
844 vshll.u8 q10, d2, #6
845 vshll.u8 q11, d3, #6
846 vst1.8 {q8, q9}, [r0], r12
847 vst1.8 {q10, q11}, [r0], r12
848 bne 0b
849 bx lr
850 endfunc
851
852 function ff_hevc_put_pixels_w24_neon_8, export=1
853 init_put_pixels
854 0: subs r3, #1
855 vld1.8 {d0, d1, d2}, [r1], r2
856 pld [r1]
857 vshll.u8 q10, d0, #6
858 vshll.u8 q11, d1, #6
859 vshll.u8 q12, d2, #6
860 vstm r0, {q10, q11, q12}
861 add r0, r12
862 bne 0b
863 bx lr
864 endfunc
865
866 function ff_hevc_put_pixels_w32_neon_8, export=1
867 init_put_pixels
868 0: subs r3, #1
869 vld1.8 {q0, q1}, [r1], r2
870 pld [r1]
871 vshll.u8 q8, d0, #6
872 vshll.u8 q9, d1, #6
873 vshll.u8 q10, d2, #6
874 vshll.u8 q11, d3, #6
875 vstm r0, {q8, q9, q10, q11}
876 add r0, r12
877 bne 0b
878 bx lr
879 endfunc
880
881 function ff_hevc_put_pixels_w48_neon_8, export=1
882 init_put_pixels
883 0: subs r3, #1
884 vld1.8 {q0, q1}, [r1]
885 add r1, #32
886 vld1.8 {q2}, [r1], r2
887 sub r1, #32
888 pld [r1]
889 vshll.u8 q8, d0, #6
890 vshll.u8 q9, d1, #6
891 vshll.u8 q10, d2, #6
892 vshll.u8 q11, d3, #6
893 vshll.u8 q12, d4, #6
894 vshll.u8 q13, d5, #6
895 vstm r0, {q8, q9, q10, q11, q12, q13}
896 add r0, r12
897 bne 0b
898 bx lr
899 endfunc
900
901 function ff_hevc_put_pixels_w64_neon_8, export=1
902 init_put_pixels
903 0: subs r3, #1
904 vld1.8 {q0, q1}, [r1]
905 add r1, #32
906 vld1.8 {q2, q3}, [r1], r2
907 sub r1, #32
908 pld [r1]
909 vshll.u8 q8, d0, #6
910 vshll.u8 q9, d1, #6
911 vshll.u8 q10, d2, #6
912 vshll.u8 q11, d3, #6
913 vshll.u8 q12, d4, #6
914 vshll.u8 q13, d5, #6
915 vshll.u8 q14, d6, #6
916 vshll.u8 q15, d7, #6
917 vstm r0, {q8, q9, q10, q11, q12, q13, q14, q15}
918 add r0, r12
919 bne 0b
920 bx lr
921 endfunc
922
923 function ff_hevc_put_qpel_uw_pixels_neon_8, export=1
924 push {r4-r9}
925 ldr r5, [sp, #24] // width
926 ldr r4, [sp, #28] // height
927 ldr r8, [sp, #32] // src2
928 ldr r9, [sp, #36] // src2stride
929 vpush {d8-d15}
930 cmp r8, #0
931 bne 2f
932 1: subs r4, #1
933 vld1.8 {d0}, [r2], r3
934 vst1.8 d0, [r0], r1
935 bne 1b
936 vpop {d8-d15}
937 pop {r4-r9}
938 bx lr
939 2: subs r4, #1
940 vld1.8 {d0}, [r2], r3
941 vld1.16 {q1}, [r8], r9
942 vshll.u8 q0, d0, #6
943 vqadd.s16 q0, q1
944 vqrshrun.s16 d0, q0, #7
945 vst1.8 d0, [r0], r1
946 bne 2b
947 vpop {d8-d15}
948 pop {r4-r9}
949 bx lr
950 endfunc
951
952 .macro put_qpel_uw_pixels width, regs, regs2, regs3, regs4
953 function ff_hevc_put_qpel_uw_pixels_w\width\()_neon_8, export=1
954 ldr r12, [sp] // height
955 1: subs r12, #4
956 vld1.32 {\regs} , [r2], r3
957 vld1.32 {\regs2} , [r2], r3
958 vld1.32 {\regs3} , [r2], r3
959 vld1.32 {\regs4} , [r2], r3
960 vst1.32 {\regs} , [r0], r1
961 vst1.32 {\regs2} , [r0], r1
962 vst1.32 {\regs3} , [r0], r1
963 vst1.32 {\regs4} , [r0], r1
964 bne 1b
965 bx lr
966 endfunc
967 .endm
968
969 .macro put_qpel_uw_pixels_m width, regs, regs2, regs3, regs4
970 function ff_hevc_put_qpel_uw_pixels_w\width\()_neon_8, export=1
971 push {r4-r5}
972 ldr r12, [sp, #8] // height
973 1: subs r12, #2
974 mov r4, r2
975 vld1.32 {\regs} , [r2]!
976 vld1.32 {\regs2} , [r2]
977 add r2, r4, r3
978 mov r4, r2
979 vld1.32 {\regs3} , [r2]!
980 vld1.32 {\regs4} , [r2]
981 add r2, r4, r3
982 mov r5, r0
983 vst1.32 {\regs} , [r0]!
984 vst1.32 {\regs2} , [r0]
985 add r0, r5, r1
986 mov r5, r0
987 vst1.32 {\regs3} , [r0]!
988 vst1.32 {\regs4} , [r0]
989 add r0, r5, r1
990 bne 1b
991 pop {r4-r5}
992 bx lr
993 endfunc
994 .endm
995
996 put_qpel_uw_pixels 4, d0[0], d0[1], d1[0], d1[1]
997 put_qpel_uw_pixels 8, d0, d1, d2, d3
998 put_qpel_uw_pixels_m 12, d0, d1[0], d2, d3[0]
999 put_qpel_uw_pixels 16, q0, q1, q2, q3
1000 put_qpel_uw_pixels 24, d0-d2, d3-d5, d16-d18, d19-d21
1001 put_qpel_uw_pixels 32, q0-q1, q2-q3, q8-q9, q10-q11
1002 put_qpel_uw_pixels_m 48, q0-q1, q2, q8-q9, q10
1003 put_qpel_uw_pixels_m 64, q0-q1, q2-q3, q8-q9, q10-q11
0 /*
1 * Copyright (c) 2008 Mans Rullgard <mans@mansr.com>
2 *
3 * This file is part of FFmpeg.
4 *
5 * FFmpeg is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * FFmpeg 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 GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with FFmpeg; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 .macro transpose_8x8 r0, r1, r2, r3, r4, r5, r6, r7
21 vtrn.32 \r0, \r4
22 vtrn.32 \r1, \r5
23 vtrn.32 \r2, \r6
24 vtrn.32 \r3, \r7
25 vtrn.16 \r0, \r2
26 vtrn.16 \r1, \r3
27 vtrn.16 \r4, \r6
28 vtrn.16 \r5, \r7
29 vtrn.8 \r0, \r1
30 vtrn.8 \r2, \r3
31 vtrn.8 \r4, \r5
32 vtrn.8 \r6, \r7
33 .endm
34
35 .macro transpose_4x4 r0, r1, r2, r3
36 vtrn.16 \r0, \r2
37 vtrn.16 \r1, \r3
38 vtrn.8 \r0, \r1
39 vtrn.8 \r2, \r3
40 .endm
41
42 .macro swap4 r0, r1, r2, r3, r4, r5, r6, r7
43 vswp \r0, \r4
44 vswp \r1, \r5
45 vswp \r2, \r6
46 vswp \r3, \r7
47 .endm
48
49 .macro transpose16_4x4 r0, r1, r2, r3, r4, r5, r6, r7
50 vtrn.32 \r0, \r2
51 vtrn.32 \r1, \r3
52 vtrn.32 \r4, \r6
53 vtrn.32 \r5, \r7
54 vtrn.16 \r0, \r1
55 vtrn.16 \r2, \r3
56 vtrn.16 \r4, \r5
57 vtrn.16 \r6, \r7
58 .endm
141141 int offset = 0;
142142 if (num_zeros != 0) {
143143 offset = get_bits(br, num_zeros);
144 return offset + (1<<num_zeros)-1;
144 int value = offset + (1<<num_zeros)-1;
145 assert(value>0);
146 return value;
145147 } else {
146148 return 0;
147149 }
2222
2323 #include <stdint.h>
2424 #include <stdio.h>
25 #include <stdlib.h>
2526 #include <assert.h>
27
28 #define INITIAL_CABAC_BUFFER_CAPACITY 4096
2629
2730
2831 static const uint8_t LPS_table[64][4] =
131134
132135 void init_CABAC_decoder(CABAC_decoder* decoder, uint8_t* bitstream, int length)
133136 {
137 assert(length >= 0);
138
134139 decoder->bitstream_start = bitstream;
135140 decoder->bitstream_curr = bitstream;
136141 decoder->bitstream_end = bitstream+length;
152157 }
153158
154159
155 //#include <sys/types.h>
156 //#include <signal.h>
157
158160 int decode_CABAC_bit(CABAC_decoder* decoder, context_model* model)
159161 {
160 //if (logcnt >= 1100000) { enablelog(); }
161
162 // if (logcnt==400068770) { raise(SIGINT); }
163
164162 logtrace(LogCABAC,"[%3d] decodeBin r:%x v:%x state:%d\n",logcnt,decoder->range, decoder->value, model->state);
165
166 //assert(decoder->range>=0x100);
167163
168164 int decoded_bit;
169165 int LPS = LPS_table[model->state][ ( decoder->range >> 6 ) - 4 ];
177173 {
178174 logtrace(LogCABAC,"[%3d] MPS\n",logcnt);
179175
180 // MPS path
176 // MPS path
181177
182178 decoded_bit = model->MPSbit;
183179 model->state = next_state_MPS[model->state];
193189 if (decoder->bits_needed == 0)
194190 {
195191 decoder->bits_needed = -8;
196 if (decoder->bitstream_curr != decoder->bitstream_end)
192 if (decoder->bitstream_curr < decoder->bitstream_end)
197193 { decoder->value |= *decoder->bitstream_curr++; }
198194 }
199195 }
201197 else
202198 {
203199 logtrace(LogCABAC,"[%3d] LPS\n",logcnt);
204
205 // LPS path
200 //printf("%d %d\n", model->state, 0);
201
202 // LPS path
203
204 decoder->value = (decoder->value - scaled_range);
206205
207206 int num_bits = renorm_table[ LPS >> 3 ];
208 decoder->value = (decoder->value - scaled_range);
209
210207 decoder->value <<= num_bits;
211208 decoder->range = LPS << num_bits; /* this is always >= 0x100 except for state 63,
212209 but state 63 is never used */
210
211 int num_bitsTab = renorm_table[ LPS >> 3 ];
212
213 assert(num_bits == num_bitsTab);
214
213215 decoded_bit = 1 - model->MPSbit;
214216
215217 if (model->state==0) { model->MPSbit = 1-model->MPSbit; }
220222 if (decoder->bits_needed >= 0)
221223 {
222224 logtrace(LogCABAC,"bits_needed: %d\n", decoder->bits_needed);
223 if (decoder->bitstream_curr != decoder->bitstream_end)
225 if (decoder->bitstream_curr < decoder->bitstream_end)
224226 { decoder->value |= (*decoder->bitstream_curr++) << decoder->bits_needed; }
225227
226228 decoder->bits_needed -= 8;
232234 logcnt++;
233235 #endif
234236
235 //assert(decoder->range>=0x100);
236
237237 return decoded_bit;
238238 }
239239
240240 int decode_CABAC_term_bit(CABAC_decoder* decoder)
241241 {
242 logtrace(LogCABAC,"CABAC term: range=%x\n", decoder->range);
243
242244 decoder->range -= 2;
243245 uint32_t scaledRange = decoder->range << 7;
244246
260262 {
261263 decoder->bits_needed = -8;
262264
263 if (decoder->bitstream_curr != decoder->bitstream_end) {
265 if (decoder->bitstream_curr < decoder->bitstream_end) {
264266 decoder->value += (*decoder->bitstream_curr++);
265267 }
266268 }
276278 {
277279 logtrace(LogCABAC,"[%3d] bypass r:%x v:%x\n",logcnt,decoder->range, decoder->value);
278280
279 //assert(decoder->range>=0x100);
280
281281 decoder->value <<= 1;
282282 decoder->bits_needed++;
283283
284284 if (decoder->bits_needed >= 0)
285285 {
286 //assert(decoder->bits_needed==0);
287
288 decoder->bits_needed = -8;
289 decoder->value |= *decoder->bitstream_curr++;
286 if (decoder->bitstream_end > decoder->bitstream_curr) {
287 decoder->bits_needed = -8;
288 decoder->value |= *decoder->bitstream_curr++;
289 }
290290 }
291291
292292 int bit;
306306 logcnt++;
307307 #endif
308308
309 //assert(decoder->range>=0x100);
310
311309 return bit;
312310 }
313311
339337
340338 int decode_CABAC_FL_bypass_parallel(CABAC_decoder* decoder, int nBits)
341339 {
342 logtrace(LogCABAC,"[%3d] bypass group r:%x v:%x\n",logcnt,decoder->range, decoder->value);
340 logtrace(LogCABAC,"[%3d] bypass group r:%x v:%x (nBits=%d)\n",logcnt,
341 decoder->range, decoder->value, nBits);
343342
344343 decoder->value <<= nBits;
345344 decoder->bits_needed+=nBits;
346345
347346 if (decoder->bits_needed >= 0)
348347 {
349 int input = *decoder->bitstream_curr++;
350 input <<= decoder->bits_needed;
351
352 decoder->bits_needed -= 8;
353 decoder->value |= input;
348 if (decoder->bitstream_end > decoder->bitstream_curr) {
349 int input = *decoder->bitstream_curr++;
350 input <<= decoder->bits_needed;
351
352 decoder->bits_needed -= 8;
353 decoder->value |= input;
354 }
354355 }
355356
356357 uint32_t scaled_range = decoder->range << 7;
360361
361362 logtrace(LogCABAC,"[%3d] -> value %d r:%x v:%x\n", logcnt+nBits-1,
362363 value, decoder->range, decoder->value);
364
363365 #ifdef DE265_LOG_TRACE
364366 logcnt+=nBits;
365367 #endif
366368
367 //assert(decoder->range>=0x100);
368
369369 return value;
370370 }
371371
373373 int decode_CABAC_FL_bypass(CABAC_decoder* decoder, int nBits)
374374 {
375375 int value=0;
376
377376
378377 if (likely(nBits<=8)) {
379378 if (nBits==0) {
398397 value |= decode_CABAC_bypass(decoder);
399398 }
400399 }
401
402400 logtrace(LogCABAC," -> FL: %d\n", value);
403401
404402 return value;
415413
416414 return (prefix << cRiceParam) | suffix;
417415 }
416
417
418 #define MAX_PREFIX 32
418419
419420 int decode_CABAC_EGk_bypass(CABAC_decoder* decoder, int k)
420421 {
430431 base += 1<<n;
431432 n++;
432433 }
434
435 if (n == k+MAX_PREFIX) {
436 return 0; // TODO: error
437 }
433438 }
434439
435440 int suffix = decode_CABAC_FL_bypass(decoder, n);
436441 return base + suffix;
437442 }
438443
444
445 // ---------------------------------------------------------------------------
446
447 void CABAC_encoder::add_trailing_bits()
448 {
449 write_bit(1);
450 int nZeros = number_free_bits_in_byte();
451 write_bits(0, nZeros);
452 }
453
454
455
456 CABAC_encoder_bitstream::CABAC_encoder_bitstream()
457 {
458 data_mem = NULL;
459 data_capacity = 0;
460 data_size = 0;
461 state = 0;
462
463 vlc_buffer_len = 0;
464
465 init_CABAC();
466 }
467
468 CABAC_encoder_bitstream::~CABAC_encoder_bitstream()
469 {
470 free(data_mem);
471 }
472
473 void CABAC_encoder_bitstream::reset()
474 {
475 data_size = 0;
476 state = 0;
477
478 vlc_buffer_len = 0;
479
480 init_CABAC();
481 }
482
483 void CABAC_encoder_bitstream::write_bits(uint32_t bits,int n)
484 {
485 vlc_buffer <<= n;
486 vlc_buffer |= bits;
487 vlc_buffer_len += n;
488
489 while (vlc_buffer_len>=8) {
490 append_byte((vlc_buffer >> (vlc_buffer_len-8)) & 0xFF);
491 vlc_buffer_len -= 8;
492 }
493 }
494
495 void CABAC_encoder::write_uvlc(int value)
496 {
497 assert(value>=0);
498
499 int nLeadingZeros=0;
500 int base=0;
501 int range=1;
502
503 while (value>=base+range) {
504 base += range;
505 range <<= 1;
506 nLeadingZeros++;
507 }
508
509 write_bits((1<<nLeadingZeros) | (value-base),2*nLeadingZeros+1);
510 }
511
512 void CABAC_encoder::write_svlc(int value)
513 {
514 if (value==0) write_bits(1,1);
515 else if (value>0) write_uvlc(2*value-1);
516 else write_uvlc(-2*value);
517 }
518
519 void CABAC_encoder_bitstream::flush_VLC()
520 {
521 while (vlc_buffer_len>=8) {
522 append_byte((vlc_buffer >> (vlc_buffer_len-8)) & 0xFF);
523 vlc_buffer_len -= 8;
524 }
525
526 if (vlc_buffer_len>0) {
527 append_byte(vlc_buffer << (8-vlc_buffer_len));
528 vlc_buffer_len = 0;
529 }
530
531 vlc_buffer = 0;
532 }
533
534 void CABAC_encoder_bitstream::skip_bits(int nBits)
535 {
536 while (nBits>=8) {
537 write_bits(0,8);
538 nBits-=8;
539 }
540
541 if (nBits>0) {
542 write_bits(0,nBits);
543 }
544 }
545
546
547 int CABAC_encoder_bitstream::number_free_bits_in_byte() const
548 {
549 if ((vlc_buffer_len % 8)==0) return 0;
550 return 8- (vlc_buffer_len % 8);
551 }
552
553
554 void CABAC_encoder_bitstream::check_size_and_resize(int nBytes)
555 {
556 if (data_size+nBytes > data_capacity) { // 1 extra byte for stuffing
557 if (data_capacity==0) {
558 data_capacity = INITIAL_CABAC_BUFFER_CAPACITY;
559 } else {
560 data_capacity *= 2;
561 }
562
563 data_mem = (uint8_t*)realloc(data_mem,data_capacity);
564 }
565 }
566
567
568 void CABAC_encoder_bitstream::append_byte(int byte)
569 {
570 check_size_and_resize(2);
571
572 // --- emulation prevention ---
573
574 /* These byte sequences may never occur in the bitstream:
575 0x000000 / 0x000001 / 0x000002
576
577 Hence, we have to add a 0x03 before the third byte.
578 We also have to add a 0x03 for this sequence: 0x000003, because
579 the escape byte itself also has to be escaped.
580 */
581
582 // S0 --(0)--> S1 --(0)--> S2 --(0,1,2,3)--> add stuffing
583
584 if (byte<=3) {
585 /**/ if (state< 2 && byte==0) { state++; }
586 else if (state==2 && byte<=3) {
587 data_mem[ data_size++ ] = 3;
588
589 if (byte==0) state=1;
590 else state=0;
591 }
592 else { state=0; }
593 }
594 else { state=0; }
595
596
597 // write actual data byte
598
599 data_mem[ data_size++ ] = byte;
600 }
601
602
603 void CABAC_encoder_bitstream::write_startcode()
604 {
605 check_size_and_resize(3);
606
607 data_mem[ data_size+0 ] = 0;
608 data_mem[ data_size+1 ] = 0;
609 data_mem[ data_size+2 ] = 1;
610 data_size+=3;
611 }
612
613 void CABAC_encoder_bitstream::init_CABAC()
614 {
615 range = 510;
616 low = 0;
617
618 bits_left = 23;
619 buffered_byte = 0xFF;
620 num_buffered_bytes = 0;
621 }
622
623 void CABAC_encoder_bitstream::flush_CABAC()
624 {
625 if (low >> (32 - bits_left))
626 {
627 append_byte(buffered_byte + 1);
628 while (num_buffered_bytes > 1)
629 {
630 append_byte(0x00);
631 num_buffered_bytes--;
632 }
633
634 low -= 1 << (32 - bits_left);
635 }
636 else
637 {
638 if (num_buffered_bytes > 0)
639 {
640 append_byte(buffered_byte);
641 }
642
643 while (num_buffered_bytes > 1)
644 {
645 append_byte(0xff);
646 num_buffered_bytes--;
647 }
648 }
649
650 // printf("low: %08x nbits left:%d filled:%d\n",low,bits_left,32-bits_left);
651
652 write_bits(low >> 8, 24-bits_left);
653 }
654
655
656 void CABAC_encoder_bitstream::write_out()
657 {
658 //logtrace(LogCABAC,"low = %08x (bits_left=%d)\n",low,bits_left);
659 int leadByte = low >> (24 - bits_left);
660 bits_left += 8;
661 low &= 0xffffffffu >> bits_left;
662
663 //logtrace(LogCABAC,"write byte %02x\n",leadByte);
664 //logtrace(LogCABAC,"-> low = %08x\n",low);
665
666 if (leadByte == 0xff)
667 {
668 num_buffered_bytes++;
669 }
670 else
671 {
672 if (num_buffered_bytes > 0)
673 {
674 int carry = leadByte >> 8;
675 int byte = buffered_byte + carry;
676 buffered_byte = leadByte & 0xff;
677 append_byte(byte);
678
679 byte = ( 0xff + carry ) & 0xff;
680 while ( num_buffered_bytes > 1 )
681 {
682 append_byte(byte);
683 num_buffered_bytes--;
684 }
685 }
686 else
687 {
688 num_buffered_bytes = 1;
689 buffered_byte = leadByte;
690 }
691 }
692 }
693
694 void CABAC_encoder_bitstream::testAndWriteOut()
695 {
696 // logtrace(LogCABAC,"bits_left = %d\n",bits_left);
697
698 if (bits_left < 12)
699 {
700 write_out();
701 }
702 }
703
704
705 #ifdef DE265_LOG_TRACE
706 int encBinCnt=1;
707 #endif
708
709 void CABAC_encoder_bitstream::write_CABAC_bit(int modelIdx, int bin)
710 {
711 context_model* model = &(*mCtxModels)[modelIdx];
712 //m_uiBinsCoded += m_binCountIncrement;
713 //rcCtxModel.setBinsCoded( 1 );
714
715 logtrace(LogCABAC,"[%d] range=%x low=%x state=%d, bin=%d\n",
716 encBinCnt, range,low, model->state,bin);
717
718 /*
719 printf("[%d] range=%x low=%x state=%d, bin=%d\n",
720 encBinCnt, range,low, model->state,bin);
721
722 printf("%d %d X\n",model->state,bin != model->MPSbit);
723 */
724
725 #ifdef DE265_LOG_TRACE
726 encBinCnt++;
727 #endif
728
729 uint32_t LPS = LPS_table[model->state][ ( range >> 6 ) - 4 ];
730 range -= LPS;
731
732 if (bin != model->MPSbit)
733 {
734 //logtrace(LogCABAC,"LPS\n");
735
736 int num_bits = renorm_table[ LPS >> 3 ];
737 low = (low + range) << num_bits;
738 range = LPS << num_bits;
739
740 if (model->state==0) { model->MPSbit = 1-model->MPSbit; }
741
742 model->state = next_state_LPS[model->state];
743
744 bits_left -= num_bits;
745 }
746 else
747 {
748 //logtrace(LogCABAC,"MPS\n");
749
750 model->state = next_state_MPS[model->state];
751
752
753 // renorm
754
755 if (range >= 256) { return; }
756
757 low <<= 1;
758 range <<= 1;
759 bits_left--;
760 }
761
762 testAndWriteOut();
763 }
764
765 void CABAC_encoder_bitstream::write_CABAC_bypass(int bin)
766 {
767 logtrace(LogCABAC,"[%d] bypass = %d, range=%x\n",encBinCnt,bin,range);
768 /*
769 printf("[%d] bypass = %d, range=%x\n",encBinCnt,bin,range);
770 printf("%d %d X\n",64, -1);
771 */
772
773 #ifdef DE265_LOG_TRACE
774 encBinCnt++;
775 #endif
776
777 // BinsCoded += m_binCountIncrement;
778 low <<= 1;
779
780 if (bin)
781 {
782 low += range;
783 }
784 bits_left--;
785
786 testAndWriteOut();
787 }
788
789 void CABAC_encoder::write_CABAC_TU_bypass(int value, int cMax)
790 {
791 for (int i=0;i<value;i++) {
792 write_CABAC_bypass(1);
793 }
794
795 if (value<cMax) {
796 write_CABAC_bypass(0);
797 }
798 }
799
800 void CABAC_encoder::write_CABAC_FL_bypass(int value, int n)
801 {
802 while (n>0) {
803 n--;
804 write_CABAC_bypass(value & (1<<n));
805 }
806 }
807
808 void CABAC_encoder_bitstream::write_CABAC_term_bit(int bit)
809 {
810 logtrace(LogCABAC,"CABAC term: range=%x\n", range);
811
812 range -= 2;
813
814 if (bit) {
815 low += range;
816
817 low <<= 7;
818 range = 2 << 7;
819 bits_left -= 7;
820 }
821 else if (range >= 256)
822 {
823 return;
824 }
825 else
826 {
827 low <<= 1;
828 range <<= 1;
829 bits_left--;
830 }
831
832 testAndWriteOut();
833 }
834
835
836
837
838 static const uint32_t entropy_table[128] = {
839 // -------------------- 200 --------------------
840 /* state= 0 */ 0x07d13 /* 0.977164 */, 0x08255 /* 1.018237 */,
841 /* state= 1 */ 0x07738 /* 0.931417 */, 0x086ef /* 1.054179 */,
842 /* state= 2 */ 0x0702b /* 0.876323 */, 0x0935a /* 1.151195 */,
843 /* state= 3 */ 0x069e6 /* 0.827333 */, 0x09c7f /* 1.222650 */,
844 /* state= 4 */ 0x062e8 /* 0.772716 */, 0x0a2c7 /* 1.271708 */,
845 /* state= 5 */ 0x05c18 /* 0.719488 */, 0x0ae25 /* 1.360532 */,
846 /* state= 6 */ 0x05632 /* 0.673414 */, 0x0b724 /* 1.430793 */,
847 /* state= 7 */ 0x05144 /* 0.634904 */, 0x0c05d /* 1.502850 */,
848 /* state= 8 */ 0x04bdf /* 0.592754 */, 0x0ccf2 /* 1.601145 */,
849 /* state= 9 */ 0x0478d /* 0.559012 */, 0x0d57b /* 1.667843 */,
850 /* state=10 */ 0x042ad /* 0.520924 */, 0x0de81 /* 1.738336 */,
851 /* state=11 */ 0x03f4d /* 0.494564 */, 0x0e4b8 /* 1.786871 */,
852 /* state=12 */ 0x03a9d /* 0.457945 */, 0x0f471 /* 1.909721 */,
853 /* state=13 */ 0x037d5 /* 0.436201 */, 0x0fc56 /* 1.971385 */,
854 /* state=14 */ 0x034c2 /* 0.412177 */, 0x10236 /* 2.017284 */,
855 /* state=15 */ 0x031a6 /* 0.387895 */, 0x10d5c /* 2.104394 */,
856 /* state=16 */ 0x02e62 /* 0.362383 */, 0x11b34 /* 2.212552 */,
857 /* state=17 */ 0x02c20 /* 0.344752 */, 0x120b4 /* 2.255512 */,
858 /* state=18 */ 0x029b8 /* 0.325943 */, 0x1294d /* 2.322672 */,
859 /* state=19 */ 0x02791 /* 0.309143 */, 0x135e1 /* 2.420959 */,
860 /* state=20 */ 0x02562 /* 0.292057 */, 0x13e37 /* 2.486077 */,
861 /* state=21 */ 0x0230d /* 0.273846 */, 0x144fd /* 2.539000 */,
862 /* state=22 */ 0x02193 /* 0.262308 */, 0x150c9 /* 2.631150 */,
863 /* state=23 */ 0x01f5d /* 0.245026 */, 0x15ca0 /* 2.723641 */,
864 /* state=24 */ 0x01de7 /* 0.233617 */, 0x162f9 /* 2.773246 */,
865 /* state=25 */ 0x01c2f /* 0.220208 */, 0x16d99 /* 2.856259 */,
866 /* state=26 */ 0x01a8e /* 0.207459 */, 0x17a93 /* 2.957634 */,
867 /* state=27 */ 0x0195a /* 0.198065 */, 0x18051 /* 3.002477 */,
868 /* state=28 */ 0x01809 /* 0.187778 */, 0x18764 /* 3.057759 */,
869 /* state=29 */ 0x0164a /* 0.174144 */, 0x19460 /* 3.159206 */,
870 /* state=30 */ 0x01539 /* 0.165824 */, 0x19f20 /* 3.243181 */,
871 /* state=31 */ 0x01452 /* 0.158756 */, 0x1a465 /* 3.284334 */,
872 /* state=32 */ 0x0133b /* 0.150261 */, 0x1b422 /* 3.407303 */,
873 /* state=33 */ 0x0120c /* 0.140995 */, 0x1bce5 /* 3.475767 */,
874 /* state=34 */ 0x01110 /* 0.133315 */, 0x1c394 /* 3.527962 */,
875 /* state=35 */ 0x0104d /* 0.127371 */, 0x1d059 /* 3.627736 */,
876 /* state=36 */ 0x00f8b /* 0.121451 */, 0x1d74b /* 3.681983 */,
877 /* state=37 */ 0x00ef4 /* 0.116829 */, 0x1dfd0 /* 3.748540 */,
878 /* state=38 */ 0x00e10 /* 0.109864 */, 0x1e6d3 /* 3.803335 */,
879 /* state=39 */ 0x00d3f /* 0.103507 */, 0x1f925 /* 3.946462 */,
880 /* state=40 */ 0x00cc4 /* 0.099758 */, 0x1fda7 /* 3.981667 */,
881 /* state=41 */ 0x00c42 /* 0.095792 */, 0x203f8 /* 4.031012 */,
882 /* state=42 */ 0x00b78 /* 0.089610 */, 0x20f7d /* 4.121014 */,
883 /* state=43 */ 0x00afc /* 0.085830 */, 0x21dd6 /* 4.233102 */,
884 /* state=44 */ 0x00a5e /* 0.081009 */, 0x22419 /* 4.282016 */,
885 /* state=45 */ 0x00a1b /* 0.078950 */, 0x22a5e /* 4.331015 */,
886 /* state=46 */ 0x00989 /* 0.074514 */, 0x23756 /* 4.432323 */,
887 /* state=47 */ 0x0091b /* 0.071166 */, 0x24225 /* 4.516775 */,
888 /* state=48 */ 0x008cf /* 0.068837 */, 0x2471a /* 4.555487 */,
889 /* state=49 */ 0x00859 /* 0.065234 */, 0x25313 /* 4.649048 */,
890 /* state=50 */ 0x00814 /* 0.063140 */, 0x25d67 /* 4.729721 */,
891 /* state=51 */ 0x007b6 /* 0.060272 */, 0x2651f /* 4.790028 */,
892 /* state=52 */ 0x0076e /* 0.058057 */, 0x2687c /* 4.816294 */,
893 /* state=53 */ 0x00707 /* 0.054924 */, 0x27da7 /* 4.981661 */,
894 /* state=54 */ 0x006d5 /* 0.053378 */, 0x28172 /* 5.011294 */,
895 /* state=55 */ 0x00659 /* 0.049617 */, 0x28948 /* 5.072512 */,
896 /* state=56 */ 0x00617 /* 0.047598 */, 0x297c5 /* 5.185722 */,
897 /* state=57 */ 0x005dd /* 0.045814 */, 0x2a2df /* 5.272434 */,
898 /* state=58 */ 0x005c1 /* 0.044965 */, 0x2a581 /* 5.293019 */,
899 /* state=59 */ 0x00574 /* 0.042619 */, 0x2ad59 /* 5.354304 */,
900 /* state=60 */ 0x0053b /* 0.040882 */, 0x2bba5 /* 5.465973 */,
901 /* state=61 */ 0x0050c /* 0.039448 */, 0x2c596 /* 5.543651 */,
902 /* state=62 */ 0x004e9 /* 0.038377 */, 0x2cd88 /* 5.605741 */,
903 0x00400 , 0x2d000 /* dummy, should never be used */
904 };
905
906
907 static const uint32_t entropy_table_orig[128] = {
908 0x07b23, 0x085f9, 0x074a0, 0x08cbc, 0x06ee4, 0x09354, 0x067f4, 0x09c1b,
909 0x060b0, 0x0a62a, 0x05a9c, 0x0af5b, 0x0548d, 0x0b955, 0x04f56, 0x0c2a9,
910 0x04a87, 0x0cbf7, 0x045d6, 0x0d5c3, 0x04144, 0x0e01b, 0x03d88, 0x0e937,
911 0x039e0, 0x0f2cd, 0x03663, 0x0fc9e, 0x03347, 0x10600, 0x03050, 0x10f95,
912 0x02d4d, 0x11a02, 0x02ad3, 0x12333, 0x0286e, 0x12cad, 0x02604, 0x136df,
913 0x02425, 0x13f48, 0x021f4, 0x149c4, 0x0203e, 0x1527b, 0x01e4d, 0x15d00,
914 0x01c99, 0x166de, 0x01b18, 0x17017, 0x019a5, 0x17988, 0x01841, 0x18327,
915 0x016df, 0x18d50, 0x015d9, 0x19547, 0x0147c, 0x1a083, 0x0138e, 0x1a8a3,
916 0x01251, 0x1b418, 0x01166, 0x1bd27, 0x01068, 0x1c77b, 0x00f7f, 0x1d18e,
917 0x00eda, 0x1d91a, 0x00e19, 0x1e254, 0x00d4f, 0x1ec9a, 0x00c90, 0x1f6e0,
918 0x00c01, 0x1fef8, 0x00b5f, 0x208b1, 0x00ab6, 0x21362, 0x00a15, 0x21e46,
919 0x00988, 0x2285d, 0x00934, 0x22ea8, 0x008a8, 0x239b2, 0x0081d, 0x24577,
920 0x007c9, 0x24ce6, 0x00763, 0x25663, 0x00710, 0x25e8f, 0x006a0, 0x26a26,
921 0x00672, 0x26f23, 0x005e8, 0x27ef8, 0x005ba, 0x284b5, 0x0055e, 0x29057,
922 0x0050c, 0x29bab, 0x004c1, 0x2a674, 0x004a7, 0x2aa5e, 0x0046f, 0x2b32f,
923 0x0041f, 0x2c0ad, 0x003e7, 0x2ca8d, 0x003ba, 0x2d323, 0x0010c, 0x3bfbb
924 };
925
926
927 const uint32_t entropy_table_theory[128] =
928 {
929 0x08000, 0x08000, 0x076da, 0x089a0, 0x06e92, 0x09340, 0x0670a, 0x09cdf, 0x06029, 0x0a67f, 0x059dd, 0x0b01f, 0x05413, 0x0b9bf, 0x04ebf, 0x0c35f,
930 0x049d3, 0x0ccff, 0x04546, 0x0d69e, 0x0410d, 0x0e03e, 0x03d22, 0x0e9de, 0x0397d, 0x0f37e, 0x03619, 0x0fd1e, 0x032ee, 0x106be, 0x02ffa, 0x1105d,
931 0x02d37, 0x119fd, 0x02aa2, 0x1239d, 0x02836, 0x12d3d, 0x025f2, 0x136dd, 0x023d1, 0x1407c, 0x021d2, 0x14a1c, 0x01ff2, 0x153bc, 0x01e2f, 0x15d5c,
932 0x01c87, 0x166fc, 0x01af7, 0x1709b, 0x0197f, 0x17a3b, 0x0181d, 0x183db, 0x016d0, 0x18d7b, 0x01595, 0x1971b, 0x0146c, 0x1a0bb, 0x01354, 0x1aa5a,
933 0x0124c, 0x1b3fa, 0x01153, 0x1bd9a, 0x01067, 0x1c73a, 0x00f89, 0x1d0da, 0x00eb7, 0x1da79, 0x00df0, 0x1e419, 0x00d34, 0x1edb9, 0x00c82, 0x1f759,
934 0x00bda, 0x200f9, 0x00b3c, 0x20a99, 0x00aa5, 0x21438, 0x00a17, 0x21dd8, 0x00990, 0x22778, 0x00911, 0x23118, 0x00898, 0x23ab8, 0x00826, 0x24458,
935 0x007ba, 0x24df7, 0x00753, 0x25797, 0x006f2, 0x26137, 0x00696, 0x26ad7, 0x0063f, 0x27477, 0x005ed, 0x27e17, 0x0059f, 0x287b6, 0x00554, 0x29156,
936 0x0050e, 0x29af6, 0x004cc, 0x2a497, 0x0048d, 0x2ae35, 0x00451, 0x2b7d6, 0x00418, 0x2c176, 0x003e2, 0x2cb15, 0x003af, 0x2d4b5, 0x0037f, 0x2de55
937 };
938
939
940 void CABAC_encoder_estim::write_CABAC_bit(int modelIdx, int bit)
941 {
942 context_model* model = &(*mCtxModels)[modelIdx];
943 //printf("[%d] state=%d, bin=%d\n", encBinCnt, model->state,bit);
944 //encBinCnt++;
945
946 int idx = model->state<<1;
947
948 if (bit==model->MPSbit) {
949 model->state = next_state_MPS[model->state];
950 }
951 else {
952 idx++;
953 if (model->state==0) { model->MPSbit = 1-model->MPSbit; }
954 model->state = next_state_LPS[model->state];
955 }
956
957 mFracBits += entropy_table[idx];
958
959 //printf("-> %08lx %f\n",entropy_table[idx], entropy_table[idx] / float(1<<15));
960 }
961
962
963 float CABAC_encoder::RDBits_for_CABAC_bin(int modelIdx, int bit)
964 {
965 context_model* model = &(*mCtxModels)[modelIdx];
966 int idx = model->state<<1;
967
968 if (bit!=model->MPSbit) {
969 idx++;
970 }
971
972 return entropy_table[idx] / float(1<<15);
973 }
974
975
976 void CABAC_encoder::write_CABAC_EGk(int val, int k)
977 {
978 while (val >= ( 1 << k ) ) {
979 write_CABAC_bypass(1);
980 val = val - ( 1 << k );
981 k++;
982 }
983
984 write_CABAC_bypass(0);
985
986 while (k) {
987 k--;
988 write_CABAC_bypass((val >> k) & 1);
989 }
990 }
991
992
993
994 void CABAC_encoder_estim_constant::write_CABAC_bit(int modelIdx, int bit)
995 {
996 context_model* model = &(*mCtxModels)[modelIdx];
997 int idx = model->state<<1;
998
999 if (bit!=model->MPSbit) {
1000 idx++;
1001 }
1002
1003 mFracBits += entropy_table[idx];
1004 }
1005
1006
1007
1008 #if 0
1009 void printtab(int idx,int s)
1010 {
1011 printf("%d %f %f %f\n", s,
1012 double(entropy_table[idx])/0x8000,
1013 double(entropy_table_orig[idx])/0x8000,
1014 double(entropy_table_f265[idx])/0x8000);
1015 }
1016
1017
1018 void plot_tables()
1019 {
1020 for (int i=-62;i<=0;i++) {
1021 int idx = -i *2;
1022 int s = i;
1023 printtab(idx,s);
1024 }
1025
1026 for (int i=0;i<=62;i++) {
1027 int idx = 2*i +1;
1028 int s = i;
1029 printtab(idx,s);
1030 }
1031 }
1032 #endif
2121 #define DE265_CABAC_H
2222
2323 #include <stdint.h>
24 #include "contextmodel.h"
2425
2526
2627 typedef struct {
3233 uint32_t value;
3334 int16_t bits_needed;
3435 } CABAC_decoder;
35
36
37 typedef struct {
38 uint8_t MPSbit : 1;
39 uint8_t state : 7;
40 } context_model;
4136
4237
4338 void init_CABAC_decoder(CABAC_decoder* decoder, uint8_t* bitstream, int length);
5247 int decode_CABAC_TR_bypass(CABAC_decoder* decoder, int cRiceParam, int cTRMax);
5348 int decode_CABAC_EGk_bypass(CABAC_decoder* decoder, int k);
5449
50
51 // ---------------------------------------------------------------------------
52
53 class CABAC_encoder
54 {
55 public:
56 CABAC_encoder() : mCtxModels(NULL) { }
57 virtual ~CABAC_encoder() { }
58
59 virtual int size() const = 0;
60 virtual void reset() = 0;
61
62 // --- VLC ---
63
64 virtual void write_bits(uint32_t bits,int n) = 0;
65 virtual void write_bit(int bit) { write_bits(bit,1); }
66 virtual void write_uvlc(int value);
67 virtual void write_svlc(int value);
68 virtual void write_startcode() = 0;
69 virtual void skip_bits(int nBits) = 0;
70
71 virtual void add_trailing_bits();
72 virtual int number_free_bits_in_byte() const = 0;
73
74 // output all remaining bits and fill with zeros to next byte boundary
75 virtual void flush_VLC() { }
76
77
78 // --- CABAC ---
79
80 void set_context_models(context_model_table* models) { mCtxModels=models; }
81
82 virtual void init_CABAC() { }
83 virtual void write_CABAC_bit(int modelIdx, int bit) = 0;
84 virtual void write_CABAC_bypass(int bit) = 0;
85 virtual void write_CABAC_TU_bypass(int value, int cMax);
86 virtual void write_CABAC_FL_bypass(int value, int nBits);
87 virtual void write_CABAC_term_bit(int bit) = 0;
88 virtual void flush_CABAC() { }
89
90 void write_CABAC_EGk(int absolute_symbol, int k); // absolute_symbol >= 0
91
92 virtual bool modifies_context() const = 0;
93
94 float RDBits_for_CABAC_bin(int modelIdx, int bit);
95
96 protected:
97 context_model_table* mCtxModels;
98 };
99
100
101 class CABAC_encoder_bitstream : public CABAC_encoder
102 {
103 public:
104 CABAC_encoder_bitstream();
105 ~CABAC_encoder_bitstream();
106
107 virtual void reset();
108
109 virtual int size() const { return data_size; }
110 uint8_t* data() const { return data_mem; }
111
112 // --- VLC ---
113
114 virtual void write_bits(uint32_t bits,int n);
115 virtual void write_startcode();
116 virtual void skip_bits(int nBits);
117
118 virtual int number_free_bits_in_byte() const;
119
120 // output all remaining bits and fill with zeros to next byte boundary
121 virtual void flush_VLC();
122
123
124 // --- CABAC ---
125
126 virtual void init_CABAC();
127 virtual void write_CABAC_bit(int modelIdx, int bit);
128 virtual void write_CABAC_bypass(int bit);
129 virtual void write_CABAC_term_bit(int bit);
130 virtual void flush_CABAC();
131
132 virtual bool modifies_context() const { return true; }
133
134 private:
135 // data buffer
136
137 uint8_t* data_mem;
138 uint32_t data_capacity;
139 uint32_t data_size;
140 char state; // for inserting emulation-prevention bytes
141
142 // VLC
143
144 uint32_t vlc_buffer;
145 uint32_t vlc_buffer_len;
146
147
148 // CABAC
149
150 uint32_t range;
151 uint32_t low;
152 int8_t bits_left;
153 uint8_t buffered_byte;
154 uint16_t num_buffered_bytes;
155
156
157 void check_size_and_resize(int nBytes);
158 void testAndWriteOut();
159 void write_out();
160 void append_byte(int byte);
161 };
162
163
164 class CABAC_encoder_estim : public CABAC_encoder
165 {
166 public:
167 CABAC_encoder_estim() : mFracBits(0) { }
168
169 virtual void reset() { mFracBits=0; }
170
171 virtual int size() const { return mFracBits>>(15+3); }
172
173 uint64_t getFracBits() const { return mFracBits; }
174 float getRDBits() const { return mFracBits / float(1<<15); }
175
176 // --- VLC ---
177
178 virtual void write_bits(uint32_t bits,int n) { mFracBits += n<<15; }
179 virtual void write_bit(int bit) { mFracBits+=1<<15; }
180 virtual void write_startcode() { mFracBits += (1<<15)*8*3; }
181 virtual void skip_bits(int nBits) { mFracBits += nBits<<15; }
182 virtual int number_free_bits_in_byte() const { return 0; } // TODO, good enough for now
183
184 // --- CABAC ---
185
186 virtual void write_CABAC_bit(int modelIdx, int bit);
187 virtual void write_CABAC_bypass(int bit) {
188 mFracBits += 0x8000;
189 }
190 virtual void write_CABAC_FL_bypass(int value, int nBits) {
191 mFracBits += nBits<<15;
192 }
193 virtual void write_CABAC_term_bit(int bit) { /* not implemented (not needed) */ }
194
195 virtual bool modifies_context() const { return true; }
196
197 protected:
198 uint64_t mFracBits;
199 };
200
201
202 class CABAC_encoder_estim_constant : public CABAC_encoder_estim
203 {
204 public:
205 void write_CABAC_bit(int modelIdx, int bit);
206
207 virtual bool modifies_context() const { return false; }
208 };
209
55210 #endif
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: struktur AG, Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #include "configparam.h"
23
24 #include <string.h>
25 #include <ctype.h>
26 #include <sstream>
27 #include <iomanip>
28 #include <iostream>
29 #include <algorithm>
30 #include <typeinfo>
31
32 #ifndef RTTI_ENABLED
33 #error "Need to compile with RTTI enabled."
34 #endif
35
36 static void remove_option(int* argc,char** argv,int idx, int n=1)
37 {
38 for (int i=idx+n;i<*argc;i++) {
39 argv[i-n] = argv[i];
40 }
41
42 *argc-=n;
43 }
44
45
46 bool option_string::processCmdLineArguments(char** argv, int* argc, int idx)
47 {
48 if (argv==NULL) { return false; }
49 if (idx >= *argc) { return false; }
50
51 value = argv[idx];
52 value_set = true;
53
54 remove_option(argc,argv,idx,1);
55
56 return true;
57 }
58
59
60 void option_int::set_range(int mini,int maxi)
61 {
62 have_low_limit =true;
63 have_high_limit=true;
64 low_limit =mini;
65 high_limit=maxi;
66 }
67
68 std::string option_int::getTypeDescr() const
69 {
70 std::stringstream sstr;
71 sstr << "(int)";
72
73 if (have_low_limit || have_high_limit) { sstr << " "; }
74 if (have_low_limit) { sstr << low_limit << " <= "; }
75 if (have_low_limit || have_high_limit) { sstr << "x"; }
76 if (have_high_limit) { sstr << " <= " << high_limit; }
77
78 if (!valid_values_set.empty()) {
79 sstr << " {";
80 bool first=true;
81 FOR_LOOP(int, v, valid_values_set) {
82 if (!first) sstr << ","; else first=false;
83 sstr << v;
84 }
85 sstr << "}";
86 }
87
88 return sstr.str();
89 }
90
91 bool option_int::processCmdLineArguments(char** argv, int* argc, int idx)
92 {
93 if (argv==NULL) { return false; }
94 if (idx >= *argc) { return false; }
95
96 int v = atoi(argv[idx]);
97 if (!is_valid(v)) { return false; }
98
99 value = v;
100 value_set = true;
101
102 remove_option(argc,argv,idx,1);
103
104 return true;
105 }
106
107 bool option_int::is_valid(int v) const
108 {
109 if (have_low_limit && v<low_limit) { return false; }
110 if (have_high_limit && v>high_limit) { return false; }
111
112 if (!valid_values_set.empty()) {
113 auto iter = std::find(valid_values_set.begin(), valid_values_set.end(), v);
114 if (iter==valid_values_set.end()) { return false; }
115 }
116
117 return true;
118 }
119
120 std::string option_int::get_default_string() const
121 {
122 std::stringstream sstr;
123 sstr << default_value;
124 return sstr.str();
125 }
126
127
128 std::string choice_option_base::getTypeDescr() const
129 {
130 std::vector<std::string> choices = get_choice_names();
131
132 std::stringstream sstr;
133 sstr << "{";
134
135 bool first=true;
136 #ifdef FOR_LOOP_AUTO_SUPPORT
137 FOR_LOOP(auto, c, choices) {
138 #else
139 FOR_LOOP(std::string, c, choices) {
140 #endif
141 if (first) { first=false; }
142 else { sstr << ","; }
143
144 sstr << c;
145 }
146
147 sstr << "}";
148 return sstr.str();
149 }
150
151
152 bool choice_option_base::processCmdLineArguments(char** argv, int* argc, int idx)
153 {
154 if (argv==NULL) { return false; }
155 if (idx >= *argc) { return false; }
156
157 std::string value = argv[idx];
158
159 std::cout << "set " << value << "\n";
160 bool success = set_value(value);
161 std::cout << "success " << success << "\n";
162
163 remove_option(argc,argv,idx,1);
164
165 return success;
166 }
167
168
169 static char* fill_strings_into_memory(const std::vector<std::string>& strings_list)
170 {
171 // calculate memory requirement
172
173 int totalStringLengths = 0;
174 #ifdef FOR_LOOP_AUTO_SUPPORT
175 FOR_LOOP(auto, str, strings_list) {
176 #else
177 FOR_LOOP(std::string, str, strings_list) {
178 #endif
179 totalStringLengths += str.length() +1; // +1 for null termination
180 }
181
182 int numStrings = strings_list.size();
183
184 int pointersSize = (numStrings+1) * sizeof(const char*);
185
186 char* memory = new char[pointersSize + totalStringLengths];
187
188
189 // copy strings to memory area
190
191 char* stringPtr = memory + (numStrings+1) * sizeof(const char*);
192 const char** tablePtr = (const char**)memory;
193
194 #ifdef FOR_LOOP_AUTO_SUPPORT
195 FOR_LOOP(auto, str, strings_list) {
196 #else
197 FOR_LOOP(std::string, str, strings_list) {
198 #endif
199 *tablePtr++ = stringPtr;
200
201 strcpy(stringPtr, str.c_str());
202 stringPtr += str.length()+1;
203 }
204
205 *tablePtr = NULL;
206
207 return memory;
208 }
209
210
211 const char** choice_option_base::get_choices_string_table() const
212 {
213 if (choice_string_table==NULL) {
214 choice_string_table = fill_strings_into_memory(get_choice_names());
215 }
216
217 return (const char**)choice_string_table;
218 }
219
220
221
222 bool config_parameters::parse_command_line_params(int* argc, char** argv, int* first_idx_ptr,
223 bool ignore_unknown_options)
224 {
225 int first_idx=1;
226 if (first_idx_ptr) { first_idx = *first_idx_ptr; }
227
228 for (int i=first_idx;i < *argc;i++) {
229
230 if (argv[i][0]=='-') {
231 // option
232
233 if (argv[i][1]=='-') {
234 // long option
235
236 bool option_found=false;
237
238 for (int o=0;o<mOptions.size();o++) {
239 if (mOptions[o]->hasLongOption() && strcmp(mOptions[o]->getLongOption().c_str(),
240 argv[i]+2)==0) {
241 option_found=true;
242
243 bool success = mOptions[o]->processCmdLineArguments(argv,argc, i+1);
244 if (!success) {
245 if (first_idx_ptr) { *first_idx_ptr = i; }
246 return false;
247 }
248
249 remove_option(argc,argv,i);
250 i--;
251
252 break;
253 }
254 }
255
256 if (option_found == false && !ignore_unknown_options) {
257 return false;
258 }
259 }
260 else {
261 // short option
262
263 bool is_single_option = (argv[i][1] != 0 && argv[i][2]==0);
264 bool do_remove_option = true;
265
266 for (int n=1; argv[i][n]; n++) {
267 char option = argv[i][n];
268
269 bool option_found=false;
270
271 for (int o=0;o<mOptions.size();o++) {
272 if (mOptions[o]->getShortOption() == option) {
273 option_found=true;
274
275 bool success;
276 if (is_single_option) {
277 success = mOptions[o]->processCmdLineArguments(argv,argc, i+1);
278 }
279 else {
280 success = mOptions[o]->processCmdLineArguments(NULL,NULL, 0);
281 }
282
283 if (!success) {
284 if (first_idx_ptr) { *first_idx_ptr = i; }
285 return false;
286 }
287
288 break;
289 }
290 }
291
292 if (!option_found) {
293 if (!ignore_unknown_options) {
294 fprintf(stderr, "unknown option -%c\n",option);
295 return false;
296 }
297 else {
298 do_remove_option=false;
299 }
300 }
301
302 } // all short options
303
304 if (do_remove_option) {
305 remove_option(argc,argv,i);
306 i--;
307 }
308 } // is short option
309 } // is option
310 } // all command line arguments
311
312 return true;
313 }
314
315
316 void config_parameters::print_params() const
317 {
318 for (int i=0;i<mOptions.size();i++) {
319 const option_base* o = mOptions[i];
320
321 std::stringstream sstr;
322 sstr << " ";
323 if (o->hasShortOption()) {
324 sstr << '-' << o->getShortOption();
325 } else {
326 sstr << " ";
327 }
328
329 if (o->hasShortOption() && o->hasLongOption()) {
330 sstr << ", ";
331 } else {
332 sstr << " ";
333 }
334
335 if (o->hasLongOption()) {
336 sstr << "--" << std::setw(12) << std::left << o->getLongOption();
337 } else {
338 sstr << " ";
339 }
340
341 sstr << " ";
342 sstr << o->getTypeDescr();
343
344 if (o->has_default()) {
345 sstr << ", default=" << o->get_default_string();
346 }
347
348 sstr << "\n";
349
350 std::cerr << sstr.str();
351 }
352 }
353
354
355 void config_parameters::add_option(option_base* o)
356 {
357 mOptions.push_back(o);
358 delete[] param_string_table; // delete old table, since we got a new parameter
359 param_string_table = NULL;
360 }
361
362
363 std::vector<std::string> config_parameters::get_parameter_IDs() const
364 {
365 std::vector<std::string> ids;
366
367 #ifdef FOR_LOOP_AUTO_SUPPORT
368 FOR_LOOP(auto, option, mOptions) {
369 #else
370 FOR_LOOP(option_base*, option, mOptions) {
371 #endif
372 ids.push_back(option->get_name());
373 }
374
375 return ids;
376 }
377
378
379 enum en265_parameter_type config_parameters::get_parameter_type(const char* param) const
380 {
381 option_base* option = find_option(param);
382 assert(option);
383
384 if (dynamic_cast<option_int*> (option)) { return en265_parameter_int; }
385 if (dynamic_cast<option_bool*> (option)) { return en265_parameter_bool; }
386 if (dynamic_cast<option_string*>(option)) { return en265_parameter_string; }
387 if (dynamic_cast<choice_option_base*>(option)) { return en265_parameter_choice; }
388
389 assert(false);
390 return en265_parameter_bool;
391 }
392
393
394 std::vector<std::string> config_parameters::get_parameter_choices(const char* param) const
395 {
396 option_base* option = find_option(param);
397 assert(option);
398
399 choice_option_base* o = dynamic_cast<choice_option_base*>(option);
400 assert(o);
401
402 return o->get_choice_names();
403 }
404
405
406 option_base* config_parameters::find_option(const char* param) const
407 {
408 #ifdef FOR_LOOP_AUTO_SUPPORT
409 FOR_LOOP(auto, o, mOptions) {
410 #else
411 FOR_LOOP(option_base*, o, mOptions) {
412 #endif
413 if (strcmp(o->get_name().c_str(), param)==0) { return o; }
414 }
415
416 return NULL;
417 }
418
419
420 bool config_parameters::set_bool(const char* param, bool value)
421 {
422 option_base* option = find_option(param);
423 assert(option);
424
425 option_bool* o = dynamic_cast<option_bool*>(option);
426 assert(o);
427
428 return o->set(value);
429 }
430
431 bool config_parameters::set_int(const char* param, int value)
432 {
433 option_base* option = find_option(param);
434 assert(option);
435
436 option_int* o = dynamic_cast<option_int*>(option);
437 assert(o);
438
439 return o->set(value);
440 }
441
442 bool config_parameters::set_string(const char* param, const char* value)
443 {
444 option_base* option = find_option(param);
445 assert(option);
446
447 option_string* o = dynamic_cast<option_string*>(option);
448 assert(o);
449
450 return o->set(value);
451 }
452
453 bool config_parameters::set_choice(const char* param, const char* value)
454 {
455 option_base* option = find_option(param);
456 assert(option);
457
458 choice_option_base* o = dynamic_cast<choice_option_base*>(option);
459 assert(o);
460
461 return o->set(value);
462 }
463
464
465
466 const char** config_parameters::get_parameter_choices_table(const char* param) const
467 {
468 option_base* option = find_option(param);
469 assert(option);
470
471 choice_option_base* o = dynamic_cast<choice_option_base*>(option);
472 assert(o);
473
474 return o->get_choices_string_table();
475 }
476
477 const char** config_parameters::get_parameter_string_table() const
478 {
479 if (param_string_table==NULL) {
480 param_string_table = fill_strings_into_memory(get_parameter_IDs());
481 }
482
483 return (const char**)param_string_table;
484 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: struktur AG, Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef CONFIG_PARAM_H
23 #define CONFIG_PARAM_H
24
25 #include "en265.h"
26 #include "util.h"
27
28 #include <climits>
29 #include <vector>
30 #include <string>
31 #include <stddef.h>
32 #include <assert.h>
33
34
35 /* Notes: probably best to keep cmd-line-options here. So it will be:
36 - automatically consistent even when having different combinations of algorithms
37 - no other place to edit
38 - if needed, one can still override it at another place
39 */
40
41 // TODO: set a stack of default prefixes in config_parameters, such that all options added
42 // will receive this namespace prefix.
43
44 // TODO: add the possibility to remove long options again, i.e., not use the default id name
45 class option_base
46 {
47 public:
48 option_base() : mShortOption(0), mLongOption(NULL) { }
49 option_base(const char* name) : mIDName(name), mShortOption(0), mLongOption(NULL) { }
50 virtual ~option_base() { }
51
52
53 // --- option identifier ---
54
55 void set_ID(const char* name) { mIDName=name; }
56 void add_namespace_prefix(std::string prefix) { mPrefix = prefix + ":" + mPrefix; }
57
58 std::string get_name() const { return mPrefix + mIDName; }
59
60
61 // --- description ---
62
63 void set_description(std::string descr) { mDescription = descr; }
64 std::string get_description() const { return mDescription; }
65
66
67 // --- value ---
68
69 virtual bool is_defined() const = 0;
70 bool is_undefined() const { return !is_defined(); }
71
72 virtual bool has_default() const = 0;
73
74
75 // --- command line options ----
76
77 void set_cmd_line_options(const char* long_option, char short_option = 0)
78 {
79 mShortOption = short_option;
80 mLongOption = long_option;
81 }
82
83 void set_short_option(char short_option) { mShortOption=short_option; }
84
85 void unsetCmdLineOption()
86 {
87 mShortOption = 0;
88 mLongOption = NULL;
89 }
90
91 bool hasShortOption() const { return mShortOption!=0; }
92 char getShortOption() const { return mShortOption; }
93 bool hasLongOption() const { return true; } //mLongOption!=NULL; }
94 std::string getLongOption() const { return mLongOption ? std::string(mLongOption) : get_name(); }
95
96 virtual LIBDE265_API bool processCmdLineArguments(char** argv, int* argc, int idx) { return false; }
97
98
99
100 virtual std::string getTypeDescr() const = 0;
101
102 virtual std::string get_default_string() const { return "N/A"; }
103
104 private:
105 std::string mPrefix;
106 std::string mIDName;
107
108 std::string mDescription;
109
110 char mShortOption;
111 const char* mLongOption;
112 };
113
114
115
116 class option_bool : public option_base
117 {
118 public:
119 option_bool() : value_set(false), default_set(false) { }
120
121 operator bool() const {
122 assert(value_set || default_set);
123 return value_set ? value : default_value;
124 }
125
126 virtual bool is_defined() const { return value_set || default_set; }
127 virtual bool has_default() const { return default_set; }
128
129 void set_default(bool v) { default_value=v; default_set=true; }
130 virtual std::string get_default_string() const { return default_value ? "true":"false"; }
131
132 virtual std::string getTypeDescr() const { return "boolean"; }
133 virtual LIBDE265_API bool processCmdLineArguments(char** argv, int* argc, int idx) { value=true; return true; }
134
135 bool set(bool v) { value_set=true; value=v; return true; }
136
137 private:
138 bool value_set;
139 bool value;
140
141 bool default_set;
142 bool default_value;
143 };
144
145
146 class option_string : public option_base
147 {
148 public:
149 option_string() : value_set(false), default_set(false) { }
150
151 const option_string& operator=(std::string v) { value=v; value_set=true; return *this; }
152
153 operator std::string() const { return get(); }
154 std::string get() const {
155 assert(value_set || default_set);
156 return value_set ? value : default_value;
157 }
158
159 virtual bool is_defined() const { return value_set || default_set; }
160 virtual bool has_default() const { return default_set; }
161
162 void set_default(std::string v) { default_value=v; default_set=true; }
163 virtual LIBDE265_API std::string get_default_string() const { return default_value; }
164
165 virtual LIBDE265_API std::string getTypeDescr() const { return "(string)"; }
166 virtual LIBDE265_API bool processCmdLineArguments(char** argv, int* argc, int idx);
167
168 bool set(std::string v) { value_set=true; value=v; return true; }
169
170 private:
171 bool value_set;
172 std::string value;
173
174 bool default_set;
175 std::string default_value;
176 };
177
178
179 class option_int : public option_base
180 {
181 public:
182 option_int() : value_set(false), default_set(false),
183 have_low_limit(false), have_high_limit(false) { }
184
185 void set_minimum(int mini) { have_low_limit =true; low_limit =mini; }
186 void set_maximum(int maxi) { have_high_limit=true; high_limit=maxi; }
187 void set_range(int mini,int maxi);
188 void set_valid_values(const std::vector<int>& v) { valid_values_set = v; }
189
190 const option_int& operator=(int v) { value=v; value_set=true; return *this; }
191
192 int operator() () const {
193 assert(value_set || default_set);
194 return value_set ? value : default_value;
195 }
196 operator int() const { return operator()(); }
197
198 virtual bool is_defined() const { return value_set || default_set; }
199 virtual bool has_default() const { return default_set; }
200
201 void set_default(int v) { default_value=v; default_set=true; }
202 virtual LIBDE265_API std::string get_default_string() const;
203
204 virtual LIBDE265_API std::string getTypeDescr() const;
205 virtual LIBDE265_API bool processCmdLineArguments(char** argv, int* argc, int idx);
206
207 bool set(int v) {
208 if (is_valid(v)) { value_set=true; value=v; return true; }
209 else { return false; }
210 }
211
212 private:
213 bool value_set;
214 int value;
215
216 bool default_set;
217 int default_value;
218
219 bool have_low_limit, have_high_limit;
220 int low_limit, high_limit;
221
222 std::vector<int> valid_values_set;
223
224 bool is_valid(int v) const;
225 };
226
227
228
229 class choice_option_base : public option_base
230 {
231 public:
232 choice_option_base() : choice_string_table(NULL) { }
233 ~choice_option_base() { delete[] choice_string_table; }
234
235 bool set(std::string v) { return set_value(v); }
236 virtual bool set_value(const std::string& val) = 0;
237 virtual std::vector<std::string> get_choice_names() const = 0;
238
239 virtual std::string getTypeDescr() const;
240 virtual LIBDE265_API bool processCmdLineArguments(char** argv, int* argc, int idx);
241
242 const char** get_choices_string_table() const;
243
244 protected:
245 void invalidate_choices_string_table() {
246 delete[] choice_string_table;
247 choice_string_table = NULL;
248 }
249
250 private:
251 mutable char* choice_string_table;
252 };
253
254
255 template <class T> class choice_option : public choice_option_base
256 {
257 public:
258 choice_option() : default_set(false), value_set(false) { }
259
260 // --- initialization ---
261
262 void add_choice(const std::string& s, T id, bool default_value=false) {
263 choices.push_back( std::make_pair(s,id) );
264 if (default_value) {
265 defaultID = id;
266 defaultValue = s;
267 default_set = true;
268 }
269
270 invalidate_choices_string_table();
271 }
272
273 void set_default(T val) {
274 #ifdef FOR_LOOP_AUTO_SUPPORT
275 FOR_LOOP(auto, c, choices) {
276 #else
277 for (typename std::vector< std::pair<std::string,T> >::const_iterator it=choices.begin(); it!=choices.end(); ++it) {
278 const std::pair<std::string,T> & c = *it;
279 #endif
280 if (c.second == val) {
281 defaultID = val;
282 defaultValue = c.first;
283 default_set = true;
284 return;
285 }
286 }
287
288 assert(false); // value does not exist
289 }
290
291
292 // --- usage ---
293
294 bool set_value(const std::string& val) // returns false if it is not a valid option
295 {
296 value_set = true;
297 selectedValue=val;
298
299 validValue = false;
300
301 #ifdef FOR_LOOP_AUTO_SUPPORT
302 FOR_LOOP(auto, c, choices) {
303 #else
304 for (typename std::vector< std::pair<std::string,T> >::const_iterator it=choices.begin(); it!=choices.end(); ++it) {
305 const std::pair<std::string,T> & c = *it;
306 #endif
307 if (val == c.first) {
308 selectedID = c.second;
309 validValue = true;
310 }
311 }
312
313 return validValue;
314 }
315
316 bool isValidValue() const { return validValue; }
317
318 const std::string& getValue() const {
319 assert(value_set || default_set);
320 return value_set ? selectedValue : defaultValue;
321 }
322 void setID(T id) { selectedID=id; validValue=true; }
323 const T getID() const { return value_set ? selectedID : defaultID; }
324
325 virtual bool is_defined() const { return value_set || default_set; }
326 virtual bool has_default() const { return default_set; }
327
328 std::vector<std::string> get_choice_names() const
329 {
330 std::vector<std::string> names;
331 #ifdef FOR_LOOP_AUTO_SUPPORT
332 FOR_LOOP(auto, p, choices) {
333 #else
334 for (typename std::vector< std::pair<std::string,T> >::const_iterator it=choices.begin(); it!=choices.end(); ++it) {
335 const std::pair<std::string,T> & p = *it;
336 #endif
337 names.push_back(p.first);
338 }
339 return names;
340 }
341
342 std::string get_default_string() const { return defaultValue; }
343
344 T operator() () const { return (T)getID(); }
345
346 private:
347 std::vector< std::pair<std::string,T> > choices;
348
349 bool default_set;
350 std::string defaultValue;
351 T defaultID;
352
353 bool value_set;
354 std::string selectedValue;
355 T selectedID;
356
357 bool validValue;
358 };
359
360
361
362
363 class config_parameters
364 {
365 public:
366 config_parameters() : param_string_table(NULL) { }
367 ~config_parameters() { delete[] param_string_table; }
368
369 void LIBDE265_API add_option(option_base* o);
370
371 void LIBDE265_API print_params() const;
372 bool LIBDE265_API parse_command_line_params(int* argc, char** argv, int* first_idx=NULL,
373 bool ignore_unknown_options=false);
374
375
376 // --- connection to C API ---
377
378 std::vector<std::string> get_parameter_IDs() const;
379 enum en265_parameter_type get_parameter_type(const char* param) const;
380
381 std::vector<std::string> get_parameter_choices(const char* param) const;
382
383 bool set_bool(const char* param, bool value);
384 bool set_int(const char* param, int value);
385 bool set_string(const char* param, const char* value);
386 bool set_choice(const char* param, const char* value);
387
388 const char** get_parameter_string_table() const;
389 const char** get_parameter_choices_table(const char* param) const;
390
391 private:
392 std::vector<option_base*> mOptions;
393
394 option_base* find_option(const char* param) const;
395
396 mutable char* param_string_table;
397 };
398
399 #endif
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * This file is part of libde265.
5 *
6 * libde265 is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation, either version 3 of
9 * the License, or (at your option) any later version.
10 *
11 * libde265 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
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with libde265. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "slice.h"
21 #include <assert.h>
22 #include <iomanip>
23 #include <sstream>
24
25 bool D = false;
26
27 context_model_table::context_model_table()
28 : model(NULL), refcnt(NULL)
29 {
30 }
31
32
33 context_model_table::context_model_table(const context_model_table& src)
34 {
35 if (D) printf("%p c'tor = %p\n",this,&src);
36
37 if (src.refcnt) {
38 (*(src.refcnt))++;
39 }
40
41 refcnt = src.refcnt;
42 model = src.model;
43 }
44
45
46 context_model_table::~context_model_table()
47 {
48 if (D) printf("%p destructor\n",this);
49
50 if (refcnt) {
51 (*refcnt)--;
52 if (*refcnt==0) {
53 if (D) printf("mfree %p\n",model);
54 delete[] model;
55 delete refcnt;
56 }
57 }
58 }
59
60
61 void context_model_table::init(int initType, int QPY)
62 {
63 if (D) printf("%p init\n",this);
64
65 decouple_or_alloc_with_empty_data();
66
67 initialize_CABAC_models(model, initType, QPY);
68 }
69
70
71 void context_model_table::release()
72 {
73 if (D) printf("%p release %p\n",this,refcnt);
74
75 if (!refcnt) { return; }
76
77 // if (*refcnt == 1) { return; } <- keep memory for later, but does not work when we believe that we freed the memory and nulled all references
78
79 (*refcnt)--;
80 if (refcnt==0) {
81 delete[] model;
82 delete refcnt;
83 }
84
85 model = nullptr;
86 refcnt= nullptr;
87 }
88
89
90 void context_model_table::decouple()
91 {
92 if (D) printf("%p decouple (%p)\n",this,refcnt);
93
94 assert(refcnt); // not necessarily so, but we never use it on an unitialized object
95
96 if (*refcnt > 1) {
97 (*refcnt)--;
98
99 context_model* oldModel = model;
100
101 model = new context_model[CONTEXT_MODEL_TABLE_LENGTH];
102 refcnt= new int;
103 *refcnt=1;
104
105 memcpy(model,oldModel,sizeof(context_model)*CONTEXT_MODEL_TABLE_LENGTH);
106 }
107 }
108
109
110 context_model_table context_model_table::transfer()
111 {
112 context_model_table newtable;
113 newtable.model = model;
114 newtable.refcnt= refcnt;
115
116 model =nullptr;
117 refcnt=nullptr;
118
119 return newtable;
120 }
121
122
123 context_model_table& context_model_table::operator=(const context_model_table& src)
124 {
125 if (D) printf("%p assign = %p\n",this,&src);
126
127 // assert(src.refcnt); // not necessarily so, but we never use it on an unitialized object
128
129 if (!src.refcnt) {
130 release();
131 return *this;
132 }
133
134 (*(src.refcnt))++;
135
136 release();
137
138 model = src.model;
139 refcnt= src.refcnt;
140
141 return *this;
142 }
143
144
145 bool context_model_table::operator==(const context_model_table& b) const
146 {
147 if (b.model == model) return true;
148 if (b.model == nullptr || model == nullptr) return false;
149
150 for (int i=0;i<CONTEXT_MODEL_TABLE_LENGTH;i++) {
151 if (!(b.model[i] == model[i])) return false;
152 }
153
154 return true;
155 }
156
157
158 std::string context_model_table::debug_dump() const
159 {
160 int hash = 0;
161 for (int i=0;i<CONTEXT_MODEL_TABLE_LENGTH;i++) {
162 hash ^= ((i+7)*model[i].state) & 0xFFFF;
163 }
164
165 std::stringstream sstr;
166 sstr << std::hex << hash;
167 return sstr.str();
168 }
169
170
171 void context_model_table::decouple_or_alloc_with_empty_data()
172 {
173 if (refcnt && *refcnt==1) { return; }
174
175 if (refcnt) {
176 assert(*refcnt>1);
177 (*refcnt)--;
178 }
179
180 if (D) printf("%p (alloc)\n",this);
181
182 model = new context_model[CONTEXT_MODEL_TABLE_LENGTH];
183 refcnt= new int;
184 *refcnt=1;
185 }
186
187
188
189
190
191
192 static void set_initValue(int SliceQPY,
193 context_model* model, int initValue, int nContexts)
194 {
195 int slopeIdx = initValue >> 4;
196 int intersecIdx = initValue & 0xF;
197 int m = slopeIdx*5 - 45;
198 int n = (intersecIdx<<3) - 16;
199 int preCtxState = Clip3(1,126, ((m*Clip3(0,51, SliceQPY))>>4)+n);
200
201 // logtrace(LogSlice,"QP=%d slopeIdx=%d intersecIdx=%d m=%d n=%d\n",SliceQPY,slopeIdx,intersecIdx,m,n);
202
203 for (int i=0;i<nContexts;i++) {
204 model[i].MPSbit=(preCtxState<=63) ? 0 : 1;
205 model[i].state = model[i].MPSbit ? (preCtxState-64) : (63-preCtxState);
206
207 // model state will always be between [0;62]
208
209 assert(model[i].state <= 62);
210 }
211 }
212
213
214 static const int initValue_split_cu_flag[3][3] = {
215 { 139,141,157 },
216 { 107,139,126 },
217 { 107,139,126 },
218 };
219 static const int initValue_cu_skip_flag[2][3] = {
220 { 197,185,201 },
221 { 197,185,201 },
222 };
223 static const int initValue_part_mode[9] = { 184,154,139, 154,154,154, 139,154,154 };
224 static const int initValue_prev_intra_luma_pred_flag[3] = { 184,154,183 };
225 static const int initValue_intra_chroma_pred_mode[3] = { 63,152,152 };
226 static const int initValue_cbf_luma[4] = { 111,141,153,111 };
227 static const int initValue_cbf_chroma[12] = { 94,138,182,154,149,107,167,154,149,92,167,154 };
228 static const int initValue_split_transform_flag[9] = { 153,138,138, 124,138,94, 224,167,122 }; // FIX712
229 static const int initValue_last_significant_coefficient_prefix[54] = {
230 110,110,124,125,140,153,125,127,140,109,111,143,127,111, 79,108,123, 63,
231 125,110, 94,110, 95, 79,125,111,110, 78,110,111,111, 95, 94,108,123,108,
232 125,110,124,110, 95, 94,125,111,111, 79,125,126,111,111, 79,108,123, 93
233 };
234 static const int initValue_coded_sub_block_flag[12] = { 91,171,134,141,121,140,61,154,121,140,61,154 };
235 static const int initValue_significant_coeff_flag[3][42] = {
236 {
237 111, 111, 125, 110, 110, 94, 124, 108, 124, 107, 125, 141, 179, 153, 125, 107,
238 125, 141, 179, 153, 125, 107, 125, 141, 179, 153, 125, 140, 139, 182, 182, 152,
239 136, 152, 136, 153, 136, 139, 111, 136, 139, 111
240 },
241 {
242 155, 154, 139, 153, 139, 123, 123, 63, 153, 166, 183, 140, 136, 153, 154, 166,
243 183, 140, 136, 153, 154, 166, 183, 140, 136, 153, 154, 170, 153, 123, 123, 107,
244 121, 107, 121, 167, 151, 183, 140, 151, 183, 140,
245 },
246 {
247 170, 154, 139, 153, 139, 123, 123, 63, 124, 166, 183, 140, 136, 153, 154, 166,
248 183, 140, 136, 153, 154, 166, 183, 140, 136, 153, 154, 170, 153, 138, 138, 122,
249 121, 122, 121, 167, 151, 183, 140, 151, 183, 140
250 },
251 };
252 static const int initValue_significant_coeff_flag_skipmode[3][2] = {
253 { 141,111 }, { 140,140 }, { 140,140 }
254 };
255
256 static const int initValue_coeff_abs_level_greater1_flag[72] = {
257 140, 92,137,138,140,152,138,139,153, 74,149, 92,139,107,122,152,
258 140,179,166,182,140,227,122,197,154,196,196,167,154,152,167,182,
259 182,134,149,136,153,121,136,137,169,194,166,167,154,167,137,182,
260 154,196,167,167,154,152,167,182,182,134,149,136,153,121,136,122,
261 169,208,166,167,154,152,167,182
262 };
263 static const int initValue_coeff_abs_level_greater2_flag[18] = {
264 138,153,136,167,152,152,107,167, 91,122,107,167,
265 107,167, 91,107,107,167
266 };
267 static const int initValue_sao_merge_leftUp_flag[3] = { 153,153,153 };
268 static const int initValue_sao_type_idx_lumaChroma_flag[3] = { 200,185,160 };
269 static const int initValue_cu_qp_delta_abs[2] = { 154,154 };
270 static const int initValue_transform_skip_flag[2] = { 139,139 };
271 static const int initValue_merge_flag[2] = { 110,154 };
272 static const int initValue_merge_idx[2] = { 122,137 };
273 static const int initValue_pred_mode_flag[2] = { 149,134 };
274 static const int initValue_abs_mvd_greater01_flag[4] = { 140,198,169,198 };
275 static const int initValue_mvp_lx_flag[1] = { 168 };
276 static const int initValue_rqt_root_cbf[1] = { 79 };
277 static const int initValue_ref_idx_lX[2] = { 153,153 };
278 static const int initValue_inter_pred_idc[5] = { 95,79,63,31,31 };
279 static const int initValue_cu_transquant_bypass_flag[3] = { 154,154,154 };
280
281
282 static void init_context(int SliceQPY,
283 context_model* model,
284 const int* initValues, int len)
285 {
286 for (int i=0;i<len;i++)
287 {
288 set_initValue(SliceQPY, &model[i], initValues[i], 1);
289 }
290 }
291
292
293 static void init_context_const(int SliceQPY,
294 context_model* model,
295 int initValue, int len)
296 {
297 set_initValue(SliceQPY, model, initValue, len);
298 }
299
300 void initialize_CABAC_models(context_model context_model_table[CONTEXT_MODEL_TABLE_LENGTH],
301 int initType,
302 int QPY)
303 {
304 context_model* cm = context_model_table; // just an abbreviation
305
306 if (initType > 0) {
307 init_context(QPY, cm+CONTEXT_MODEL_CU_SKIP_FLAG, initValue_cu_skip_flag[initType-1], 3);
308 init_context(QPY, cm+CONTEXT_MODEL_PRED_MODE_FLAG, &initValue_pred_mode_flag[initType-1], 1);
309 init_context(QPY, cm+CONTEXT_MODEL_MERGE_FLAG, &initValue_merge_flag[initType-1],1);
310 init_context(QPY, cm+CONTEXT_MODEL_MERGE_IDX, &initValue_merge_idx[initType-1], 1);
311 init_context(QPY, cm+CONTEXT_MODEL_INTER_PRED_IDC, initValue_inter_pred_idc, 5);
312 init_context(QPY, cm+CONTEXT_MODEL_REF_IDX_LX, initValue_ref_idx_lX, 2);
313 init_context(QPY, cm+CONTEXT_MODEL_ABS_MVD_GREATER01_FLAG, &initValue_abs_mvd_greater01_flag[initType == 1 ? 0 : 2], 2);
314 init_context(QPY, cm+CONTEXT_MODEL_MVP_LX_FLAG, initValue_mvp_lx_flag, 1);
315 init_context(QPY, cm+CONTEXT_MODEL_RQT_ROOT_CBF, initValue_rqt_root_cbf, 1);
316
317 init_context_const(QPY, cm+CONTEXT_MODEL_RDPCM_FLAG, 139, 2);
318 init_context_const(QPY, cm+CONTEXT_MODEL_RDPCM_DIR, 139, 2);
319 }
320
321 init_context(QPY, cm+CONTEXT_MODEL_SPLIT_CU_FLAG, initValue_split_cu_flag[initType], 3);
322 init_context(QPY, cm+CONTEXT_MODEL_PART_MODE, &initValue_part_mode[(initType!=2 ? initType : 5)], 4);
323 init_context(QPY, cm+CONTEXT_MODEL_PREV_INTRA_LUMA_PRED_FLAG, &initValue_prev_intra_luma_pred_flag[initType], 1);
324 init_context(QPY, cm+CONTEXT_MODEL_INTRA_CHROMA_PRED_MODE, &initValue_intra_chroma_pred_mode[initType], 1);
325 init_context(QPY, cm+CONTEXT_MODEL_CBF_LUMA, &initValue_cbf_luma[initType == 0 ? 0 : 2], 2);
326 init_context(QPY, cm+CONTEXT_MODEL_CBF_CHROMA, &initValue_cbf_chroma[initType * 4], 4);
327 init_context(QPY, cm+CONTEXT_MODEL_SPLIT_TRANSFORM_FLAG, &initValue_split_transform_flag[initType * 3], 3);
328 init_context(QPY, cm+CONTEXT_MODEL_LAST_SIGNIFICANT_COEFFICIENT_X_PREFIX, &initValue_last_significant_coefficient_prefix[initType * 18], 18);
329 init_context(QPY, cm+CONTEXT_MODEL_LAST_SIGNIFICANT_COEFFICIENT_Y_PREFIX, &initValue_last_significant_coefficient_prefix[initType * 18], 18);
330 init_context(QPY, cm+CONTEXT_MODEL_CODED_SUB_BLOCK_FLAG, &initValue_coded_sub_block_flag[initType * 4], 4);
331 init_context(QPY, cm+CONTEXT_MODEL_SIGNIFICANT_COEFF_FLAG, initValue_significant_coeff_flag[initType], 42);
332 init_context(QPY, cm+CONTEXT_MODEL_SIGNIFICANT_COEFF_FLAG+42, initValue_significant_coeff_flag_skipmode[initType], 2);
333
334 init_context(QPY, cm+CONTEXT_MODEL_COEFF_ABS_LEVEL_GREATER1_FLAG, &initValue_coeff_abs_level_greater1_flag[initType * 24], 24);
335 init_context(QPY, cm+CONTEXT_MODEL_COEFF_ABS_LEVEL_GREATER2_FLAG, &initValue_coeff_abs_level_greater2_flag[initType * 6], 6);
336 init_context(QPY, cm+CONTEXT_MODEL_SAO_MERGE_FLAG, &initValue_sao_merge_leftUp_flag[initType], 1);
337 init_context(QPY, cm+CONTEXT_MODEL_SAO_TYPE_IDX, &initValue_sao_type_idx_lumaChroma_flag[initType], 1);
338 init_context(QPY, cm+CONTEXT_MODEL_CU_QP_DELTA_ABS, initValue_cu_qp_delta_abs, 2);
339 init_context(QPY, cm+CONTEXT_MODEL_TRANSFORM_SKIP_FLAG, initValue_transform_skip_flag, 2);
340 init_context(QPY, cm+CONTEXT_MODEL_CU_TRANSQUANT_BYPASS_FLAG, &initValue_cu_transquant_bypass_flag[initType], 1);
341
342 init_context_const(QPY, cm+CONTEXT_MODEL_LOG2_RES_SCALE_ABS_PLUS1, 154, 8);
343 init_context_const(QPY, cm+CONTEXT_MODEL_RES_SCALE_SIGN_FLAG, 154, 2);
344 init_context_const(QPY, cm+CONTEXT_MODEL_CU_CHROMA_QP_OFFSET_FLAG, 154, 1);
345 init_context_const(QPY, cm+CONTEXT_MODEL_CU_CHROMA_QP_OFFSET_IDX, 154, 1);
346 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: struktur AG, Dirk Farin <farin@struktur.de>
5 * Min Chen <chenm003@163.com>
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 <http://www.gnu.org/licenses/>.
21 */
22
23 #ifndef DE265_CONTEXTMODEL_H
24 #define DE265_CONTEXTMODEL_H
25
26 #include "libde265/cabac.h"
27 #include "libde265/de265.h"
28
29 #include <string.h>
30 #include <string>
31
32
33 struct context_model {
34 uint8_t MPSbit : 1;
35 uint8_t state : 7;
36
37 bool operator==(context_model b) const { return state==b.state && MPSbit==b.MPSbit; }
38 bool operator!=(context_model b) const { return state!=b.state || MPSbit!=b.MPSbit; }
39 };
40
41
42 enum context_model_index {
43 // SAO
44 CONTEXT_MODEL_SAO_MERGE_FLAG = 0,
45 CONTEXT_MODEL_SAO_TYPE_IDX = CONTEXT_MODEL_SAO_MERGE_FLAG +1,
46
47 // CB-tree
48 CONTEXT_MODEL_SPLIT_CU_FLAG = CONTEXT_MODEL_SAO_TYPE_IDX + 1,
49 CONTEXT_MODEL_CU_SKIP_FLAG = CONTEXT_MODEL_SPLIT_CU_FLAG + 3,
50
51 // intra-prediction
52 CONTEXT_MODEL_PART_MODE = CONTEXT_MODEL_CU_SKIP_FLAG + 3,
53 CONTEXT_MODEL_PREV_INTRA_LUMA_PRED_FLAG = CONTEXT_MODEL_PART_MODE + 4,
54 CONTEXT_MODEL_INTRA_CHROMA_PRED_MODE = CONTEXT_MODEL_PREV_INTRA_LUMA_PRED_FLAG + 1,
55
56 // transform-tree
57 CONTEXT_MODEL_CBF_LUMA = CONTEXT_MODEL_INTRA_CHROMA_PRED_MODE + 1,
58 CONTEXT_MODEL_CBF_CHROMA = CONTEXT_MODEL_CBF_LUMA + 2,
59 CONTEXT_MODEL_SPLIT_TRANSFORM_FLAG = CONTEXT_MODEL_CBF_CHROMA + 4,
60 CONTEXT_MODEL_CU_CHROMA_QP_OFFSET_FLAG = CONTEXT_MODEL_SPLIT_TRANSFORM_FLAG + 3,
61 CONTEXT_MODEL_CU_CHROMA_QP_OFFSET_IDX = CONTEXT_MODEL_CU_CHROMA_QP_OFFSET_FLAG + 1,
62
63 // residual
64 CONTEXT_MODEL_LAST_SIGNIFICANT_COEFFICIENT_X_PREFIX = CONTEXT_MODEL_CU_CHROMA_QP_OFFSET_IDX + 1,
65 CONTEXT_MODEL_LAST_SIGNIFICANT_COEFFICIENT_Y_PREFIX = CONTEXT_MODEL_LAST_SIGNIFICANT_COEFFICIENT_X_PREFIX + 18,
66 CONTEXT_MODEL_CODED_SUB_BLOCK_FLAG = CONTEXT_MODEL_LAST_SIGNIFICANT_COEFFICIENT_Y_PREFIX + 18,
67 CONTEXT_MODEL_SIGNIFICANT_COEFF_FLAG = CONTEXT_MODEL_CODED_SUB_BLOCK_FLAG + 4,
68 CONTEXT_MODEL_COEFF_ABS_LEVEL_GREATER1_FLAG = CONTEXT_MODEL_SIGNIFICANT_COEFF_FLAG + 42+2,
69 CONTEXT_MODEL_COEFF_ABS_LEVEL_GREATER2_FLAG = CONTEXT_MODEL_COEFF_ABS_LEVEL_GREATER1_FLAG + 24,
70
71 CONTEXT_MODEL_CU_QP_DELTA_ABS = CONTEXT_MODEL_COEFF_ABS_LEVEL_GREATER2_FLAG + 6,
72 CONTEXT_MODEL_TRANSFORM_SKIP_FLAG = CONTEXT_MODEL_CU_QP_DELTA_ABS + 2,
73 CONTEXT_MODEL_RDPCM_FLAG = CONTEXT_MODEL_TRANSFORM_SKIP_FLAG + 2,
74 CONTEXT_MODEL_RDPCM_DIR = CONTEXT_MODEL_RDPCM_FLAG + 2,
75
76 // motion
77 CONTEXT_MODEL_MERGE_FLAG = CONTEXT_MODEL_RDPCM_DIR + 2,
78 CONTEXT_MODEL_MERGE_IDX = CONTEXT_MODEL_MERGE_FLAG + 1,
79 CONTEXT_MODEL_PRED_MODE_FLAG = CONTEXT_MODEL_MERGE_IDX + 1,
80 CONTEXT_MODEL_ABS_MVD_GREATER01_FLAG = CONTEXT_MODEL_PRED_MODE_FLAG + 1,
81 CONTEXT_MODEL_MVP_LX_FLAG = CONTEXT_MODEL_ABS_MVD_GREATER01_FLAG + 2,
82 CONTEXT_MODEL_RQT_ROOT_CBF = CONTEXT_MODEL_MVP_LX_FLAG + 1,
83 CONTEXT_MODEL_REF_IDX_LX = CONTEXT_MODEL_RQT_ROOT_CBF + 1,
84 CONTEXT_MODEL_INTER_PRED_IDC = CONTEXT_MODEL_REF_IDX_LX + 2,
85 CONTEXT_MODEL_CU_TRANSQUANT_BYPASS_FLAG = CONTEXT_MODEL_INTER_PRED_IDC + 5,
86 CONTEXT_MODEL_LOG2_RES_SCALE_ABS_PLUS1 = CONTEXT_MODEL_CU_TRANSQUANT_BYPASS_FLAG + 1,
87 CONTEXT_MODEL_RES_SCALE_SIGN_FLAG = CONTEXT_MODEL_LOG2_RES_SCALE_ABS_PLUS1 + 8,
88 CONTEXT_MODEL_TABLE_LENGTH = CONTEXT_MODEL_RES_SCALE_SIGN_FLAG + 2
89 };
90
91
92
93 void initialize_CABAC_models(context_model context_model_table[CONTEXT_MODEL_TABLE_LENGTH],
94 int initType,
95 int QPY);
96
97
98 class context_model_table
99 {
100 public:
101 context_model_table();
102 context_model_table(const context_model_table&);
103 ~context_model_table();
104
105 void init(int initType, int QPY);
106 void release();
107 void decouple();
108 context_model_table transfer();
109 context_model_table copy() const { context_model_table t=*this; t.decouple(); return t; }
110
111 bool empty() const { return refcnt != NULL; }
112
113 context_model& operator[](int i) { return model[i]; }
114
115 context_model_table& operator=(const context_model_table&);
116
117 bool operator==(const context_model_table&) const;
118
119 std::string debug_dump() const;
120
121 private:
122 void decouple_or_alloc_with_empty_data();
123
124 context_model* model; // [CONTEXT_MODEL_TABLE_LENGTH]
125 int* refcnt;
126 };
127
128
129 #endif
2727 #define LIBDE265_VERSION_H
2828
2929 /* Numeric representation of the version */
30 #define LIBDE265_NUMERIC_VERSION 0x00090000
30 #define LIBDE265_NUMERIC_VERSION 0x01000200
3131
3232 /* Version string */
33 #define LIBDE265_VERSION "0.9"
33 #define LIBDE265_VERSION "1.0.2"
3434
3535 #endif
4646 return (LIBDE265_NUMERIC_VERSION);
4747 }
4848
49 LIBDE265_API int de265_get_version_number_major(void)
50 {
51 return ((LIBDE265_NUMERIC_VERSION)>>24) & 0xFF;
52 }
53
54 LIBDE265_API int de265_get_version_number_minor(void)
55 {
56 return ((LIBDE265_NUMERIC_VERSION)>>16) & 0xFF;
57 }
58
59 LIBDE265_API int de265_get_version_number_maintenance(void)
60 {
61 return ((LIBDE265_NUMERIC_VERSION)>>8) & 0xFF;
62 }
63
64
4965 LIBDE265_API const char* de265_get_error_text(de265_error err)
5066 {
5167 switch (err) {
5268 case DE265_OK: return "no error";
5369 case DE265_ERROR_NO_SUCH_FILE: return "no such file";
5470 //case DE265_ERROR_NO_STARTCODE: return "no startcode found";
55 case DE265_ERROR_EOF: return "end of file";
71 //case DE265_ERROR_EOF: return "end of file";
5672 case DE265_ERROR_COEFFICIENT_OUT_OF_IMAGE_BOUNDS: return "coefficient out of image bounds";
5773 case DE265_ERROR_CHECKSUM_MISMATCH: return "image checksum mismatch";
5874 case DE265_ERROR_CTB_OUTSIDE_IMAGE_AREA: return "CTB outside of image area";
6379 case DE265_ERROR_LIBRARY_INITIALIZATION_FAILED: return "global library initialization failed";
6480 case DE265_ERROR_LIBRARY_NOT_INITIALIZED: return "cannot free library data (not initialized";
6581
66 case DE265_ERROR_MAX_THREAD_CONTEXTS_EXCEEDED:
67 return "internal error: maximum number of thread contexts exceeded";
68 case DE265_ERROR_MAX_NUMBER_OF_SLICES_EXCEEDED:
69 return "internal error: maximum number of slices exceeded";
82 //case DE265_ERROR_MAX_THREAD_CONTEXTS_EXCEEDED:
83 // return "internal error: maximum number of thread contexts exceeded";
84 //case DE265_ERROR_MAX_NUMBER_OF_SLICES_EXCEEDED:
85 // return "internal error: maximum number of slices exceeded";
86 case DE265_ERROR_NOT_IMPLEMENTED_YET:
87 return "unimplemented decoder feature";
7088 //case DE265_ERROR_SCALING_LIST_NOT_IMPLEMENTED:
7189 //return "scaling list not implemented";
90
7291 case DE265_ERROR_WAITING_FOR_INPUT_DATA:
7392 return "no more input data, decoder stalled";
7493 case DE265_ERROR_CANNOT_PROCESS_SEI:
7594 return "SEI data cannot be processed";
95 case DE265_ERROR_PARAMETER_PARSING:
96 return "command-line parameter error";
97 case DE265_ERROR_NO_INITIAL_SLICE_HEADER:
98 return "first slice missing, cannot decode dependent slice";
99 case DE265_ERROR_PREMATURE_END_OF_SLICE:
100 return "premature end of slice data";
101 case DE265_ERROR_UNSPECIFIED_DECODING_ERROR:
102 return "unspecified decoding error";
76103
77104 case DE265_WARNING_NO_WPP_CANNOT_USE_MULTITHREADING:
78105 return "Cannot run decoder multi-threaded because stream does not support WPP";
126153 return "cannot apply SAO because we ran out of memory";
127154 case DE265_WARNING_SPS_MISSING_CANNOT_DECODE_SEI:
128155 return "SPS header missing, cannot decode SEI";
156 case DE265_WARNING_COLLOCATED_MOTION_VECTOR_OUTSIDE_IMAGE_AREA:
157 return "collocated motion-vector is outside image area";
129158
130159 default: return "unknown error";
131160 }
586615 }
587616 }
588617
618 LIBDE265_API int de265_get_bits_per_pixel(const struct de265_image* img,int channel)
619 {
620 switch (channel) {
621 case 0:
622 return img->sps.BitDepth_Y;
623 case 1:
624 case 2:
625 return img->sps.BitDepth_C;
626 default:
627 return 0;
628 }
629 }
630
589631 LIBDE265_API enum de265_chroma de265_get_chroma_format(const struct de265_image* img)
590632 {
591633 return img->get_chroma_format();
597639
598640 uint8_t* data = img->pixels_confwin[channel];
599641
600 if (stride) *stride = img->get_image_stride(channel);
642 if (stride) *stride = img->get_image_stride(channel) * ((de265_get_bits_per_pixel(img, channel)+7) / 8);
601643
602644 return data;
603645 }
611653
612654 LIBDE265_API void de265_set_image_plane(de265_image* img, int cIdx, void* mem, int stride, void *userdata)
613655 {
656 // The internal "stride" is the number of pixels per line.
657 stride = stride / ((de265_get_bits_per_pixel(img, cIdx)+7) / 8);
614658 img->set_image_plane(cIdx, (uint8_t*)mem, stride, userdata);
615659 }
616660
655699 if (nuh_temporal_id) *nuh_temporal_id = img->nal_hdr.nuh_temporal_id;
656700 }
657701 }
658
7171 LIBDE265_API const char *de265_get_version(void);
7272 LIBDE265_API uint32_t de265_get_version_number(void);
7373
74 LIBDE265_API int de265_get_version_number_major(void);
75 LIBDE265_API int de265_get_version_number_minor(void);
76 LIBDE265_API int de265_get_version_number_maintenance(void);
77
7478
7579 /* === error codes === */
7680
7882 DE265_OK = 0,
7983 DE265_ERROR_NO_SUCH_FILE=1,
8084 //DE265_ERROR_NO_STARTCODE=2, obsolet
81 DE265_ERROR_EOF=3,
85 //DE265_ERROR_EOF=3,
8286 DE265_ERROR_COEFFICIENT_OUT_OF_IMAGE_BOUNDS=4,
8387 DE265_ERROR_CHECKSUM_MISMATCH=5,
8488 DE265_ERROR_CTB_OUTSIDE_IMAGE_AREA=6,
9094 DE265_ERROR_LIBRARY_NOT_INITIALIZED=12,
9195 DE265_ERROR_WAITING_FOR_INPUT_DATA=13,
9296 DE265_ERROR_CANNOT_PROCESS_SEI=14,
97 DE265_ERROR_PARAMETER_PARSING=15,
98 DE265_ERROR_NO_INITIAL_SLICE_HEADER=16,
99 DE265_ERROR_PREMATURE_END_OF_SLICE=17,
100 DE265_ERROR_UNSPECIFIED_DECODING_ERROR=18,
93101
94102 // --- errors that should become obsolete in later libde265 versions ---
95103
96 DE265_ERROR_MAX_THREAD_CONTEXTS_EXCEEDED = 500,
97 DE265_ERROR_MAX_NUMBER_OF_SLICES_EXCEEDED = 501,
104 //DE265_ERROR_MAX_THREAD_CONTEXTS_EXCEEDED = 500, obsolet
105 //DE265_ERROR_MAX_NUMBER_OF_SLICES_EXCEEDED = 501, obsolet
106 DE265_ERROR_NOT_IMPLEMENTED_YET = 502,
98107 //DE265_ERROR_SCALING_LIST_NOT_IMPLEMENTED = 502, obsolet
99108
100109 // --- warnings ---
124133 DE265_WARNING_NUMBER_OF_THREADS_LIMITED_TO_MAXIMUM=1022,
125134 DE265_NON_EXISTING_LT_REFERENCE_CANDIDATE_IN_SLICE_HEADER=1023,
126135 DE265_WARNING_CANNOT_APPLY_SAO_OUT_OF_MEMORY=1024,
127 DE265_WARNING_SPS_MISSING_CANNOT_DECODE_SEI=1025
136 DE265_WARNING_SPS_MISSING_CANNOT_DECODE_SEI=1025,
137 DE265_WARNING_COLLOCATED_MOTION_VECTOR_OUTSIDE_IMAGE_AREA=1026
128138 } de265_error;
129139
130140 LIBDE265_API const char* de265_get_error_text(de265_error err);
147157
148158 enum de265_chroma {
149159 de265_chroma_mono=0,
150 de265_chroma_420=1, // currently the only used format
160 de265_chroma_420=1,
151161 de265_chroma_422=2,
152162 de265_chroma_444=3
153163 };
158168 LIBDE265_API int de265_get_image_width(const struct de265_image*,int channel);
159169 LIBDE265_API int de265_get_image_height(const struct de265_image*,int channel);
160170 LIBDE265_API enum de265_chroma de265_get_chroma_format(const struct de265_image*);
171 LIBDE265_API int de265_get_bits_per_pixel(const struct de265_image*,int channel);
172 /* The |out_stride| is returned as "bytes per line" if a non-NULL parameter is given. */
161173 LIBDE265_API const uint8_t* de265_get_image_plane(const struct de265_image*, int channel, int* out_stride);
162174 LIBDE265_API void* de265_get_image_plane_user_data(const struct de265_image*, int channel);
163175 LIBDE265_API de265_PTS de265_get_image_PTS(const struct de265_image*);
311323
312324 struct de265_image_allocation
313325 {
314 int (*get_buffer)(de265_decoder_context* ctx,
326 int (*get_buffer)(de265_decoder_context* ctx, // first parameter deprecated
315327 struct de265_image_spec* spec,
316328 struct de265_image* img,
317329 void* userdata);
318 void (*release_buffer)(de265_decoder_context* ctx,
330 void (*release_buffer)(de265_decoder_context* ctx, // first parameter deprecated
319331 struct de265_image* img,
320332 void* userdata);
321333 };
383395 de265_acceleration_SSE4 = 40,
384396 de265_acceleration_AVX = 50, // not implemented yet
385397 de265_acceleration_AVX2 = 60, // not implemented yet
398 de265_acceleration_ARM = 70,
399 de265_acceleration_NEON = 80,
386400 de265_acceleration_AUTO = 10000
387401 };
388402
159159 int x0ctb = x0 >> ctbshift;
160160 int y0ctb = y0 >> ctbshift;
161161
162 // check for corrupted streams
163 if (img->is_SliceHeader_available(x0,y0)==false) {
164 return false;
165 }
166
162167 // check whether we should filter this slice
163168
164169 slice_segment_header* shdr = img->get_SliceHeader(x0,y0);
174179
175180 if (x0 && ((x0 & ctb_mask) == 0)) { // left edge at CTB boundary
176181 if (shdr->slice_loop_filter_across_slices_enabled_flag == 0 &&
182 img->is_SliceHeader_available(x0-1,y0) && // for corrupted streams
177183 shdr->SliceAddrRS != img->get_SliceHeader(x0-1,y0)->SliceAddrRS)
178184 {
179185 filterLeftCbEdge = 0;
187193
188194 if (y0 && ((y0 & ctb_mask) == 0)) { // top edge at CTB boundary
189195 if (shdr->slice_loop_filter_across_slices_enabled_flag == 0 &&
196 img->is_SliceHeader_available(x0,y0-1) && // for corrupted streams
190197 shdr->SliceAddrRS != img->get_SliceHeader(x0,y0-1)->SliceAddrRS)
191198 {
192199 filterTopCbEdge = 0;
280287
281288 bS = 0;
282289
283 const PredVectorInfo* mviP = img->get_mv_info(xDiOpp,yDiOpp);
284 const PredVectorInfo* mviQ = img->get_mv_info(xDi ,yDi);
290 const MotionVectorSpec* mviP = img->get_mv_info(xDiOpp,yDiOpp);
291 const MotionVectorSpec* mviQ = img->get_mv_info(xDi ,yDi);
285292
286293 slice_segment_header* shdrP = img->get_SliceHeader(xDiOpp,yDiOpp);
287294 slice_segment_header* shdrQ = img->get_SliceHeader(xDi ,yDi);
392399
393400
394401 // 8.7.2.4
395 void edge_filtering_luma(de265_image* img, bool vertical,
396 int yStart,int yEnd, int xStart,int xEnd)
397 {
402 template <class pixel_t>
403 void edge_filtering_luma_internal(de265_image* img, bool vertical,
404 int yStart,int yEnd, int xStart,int xEnd)
405 {
406 //printf("luma %d-%d %d-%d\n",xStart,xEnd,yStart,yEnd);
407
398408 int xIncr = vertical ? 2 : 1;
399409 int yIncr = vertical ? 1 : 2;
400410
407417
408418 for (int y=yStart;y<yEnd;y+=yIncr)
409419 for (int x=xStart;x<xEnd;x+=xIncr) {
410 int xDi = x<<2;
411 int yDi = y<<2;
420 // x;y in deblocking units (4x4 pixels)
421
422 int xDi = x<<2; // *4 -> pixel resolution
423 int yDi = y<<2; // *4 -> pixel resolution
412424 int bS = img->get_deblk_bS(xDi,yDi);
425
426 //printf("x,y:%d,%d xDi,yDi:%d,%d\n",x,y,xDi,yDi);
413427
414428 logtrace(LogDeblock,"deblock POC=%d %c --- x:%d y:%d bS:%d---\n",
415429 img->PicOrderCntVal,vertical ? 'V':'H',xDi,yDi,bS);
449463
450464 // 8.7.2.4.3
451465
452 uint8_t* ptr = img->get_image_plane_at_pos(0, xDi,yDi);
453
454 uint8_t q[4][4], p[4][4];
466 pixel_t* ptr = img->get_image_plane_at_pos_NEW<pixel_t>(0, xDi,yDi);
467
468 pixel_t q[4][4], p[4][4];
455469 for (int k=0;k<4;k++)
456470 for (int i=0;i<4;i++)
457471 {
576590
577591 logtrace(LogDeblock,"line:%d\n",k);
578592
579 const uint8_t p0 = p[k][0];
580 const uint8_t p1 = p[k][1];
581 const uint8_t p2 = p[k][2];
582 const uint8_t p3 = p[k][3];
583 const uint8_t q0 = q[k][0];
584 const uint8_t q1 = q[k][1];
585 const uint8_t q2 = q[k][2];
586 const uint8_t q3 = q[k][3];
593 const pixel_t p0 = p[k][0];
594 const pixel_t p1 = p[k][1];
595 const pixel_t p2 = p[k][2];
596 const pixel_t p3 = p[k][3];
597 const pixel_t q0 = q[k][0];
598 const pixel_t q1 = q[k][1];
599 const pixel_t q2 = q[k][2];
600 const pixel_t q3 = q[k][3];
587601
588602 if (dE==2) {
589603 // strong filtering
590604
591605 //nDp=nDq=3;
592606
593 uint8_t pnew[3],qnew[3];
607 pixel_t pnew[3],qnew[3];
594608 pnew[0] = Clip3(p0-2*tc,p0+2*tc, (p2 + 2*p1 + 2*p0 + 2*q0 + q1 +4)>>3);
595609 pnew[1] = Clip3(p1-2*tc,p1+2*tc, (p2 + p1 + p0 + q0+2)>>2);
596610 pnew[2] = Clip3(p2-2*tc,p2+2*tc, (2*p3 + 3*p2 + p1 + p0 + q0 + 4)>>3);
628642 delta = Clip3(-tc,tc,delta);
629643 logtrace(LogDeblock," deblk + %d;%d [%02x->%02x] - %d;%d [%02x->%02x] delta:%d\n",
630644 vertical ? xDi-1 : xDi+k,
631 vertical ? yDi+k : yDi-1, p0,Clip1_8bit(p0+delta),
645 vertical ? yDi+k : yDi-1, p0,Clip_BitDepth(p0+delta, bitDepth_Y),
632646 vertical ? xDi : xDi+k,
633 vertical ? yDi+k : yDi, q0,Clip1_8bit(q0-delta),
647 vertical ? yDi+k : yDi, q0,Clip_BitDepth(q0-delta, bitDepth_Y),
634648 delta);
635649
636650 if (vertical) {
637 if (filterP) { ptr[-0-1+k*stride] = Clip1_8bit(p0+delta); }
638 if (filterQ) { ptr[ 0 +k*stride] = Clip1_8bit(q0-delta); }
651 if (filterP) { ptr[-0-1+k*stride] = Clip_BitDepth(p0+delta, bitDepth_Y); }
652 if (filterQ) { ptr[ 0 +k*stride] = Clip_BitDepth(q0-delta, bitDepth_Y); }
639653 }
640654 else {
641 if (filterP) { ptr[ k -1*stride] = Clip1_8bit(p0+delta); }
642 if (filterQ) { ptr[ k +0*stride] = Clip1_8bit(q0-delta); }
655 if (filterP) { ptr[ k -1*stride] = Clip_BitDepth(p0+delta, bitDepth_Y); }
656 if (filterQ) { ptr[ k +0*stride] = Clip_BitDepth(q0-delta, bitDepth_Y); }
643657 }
644658
645659 //ptr[ 0+k*stride] = 200;
652666 vertical ? yDi+k : yDi-2,
653667 delta_p);
654668
655 if (vertical) { ptr[-1-1+k*stride] = Clip1_8bit(p1+delta_p); }
656 else { ptr[ k -2*stride] = Clip1_8bit(p1+delta_p); }
669 if (vertical) { ptr[-1-1+k*stride] = Clip_BitDepth(p1+delta_p, bitDepth_Y); }
670 else { ptr[ k -2*stride] = Clip_BitDepth(p1+delta_p, bitDepth_Y); }
657671 }
658672
659673 if (dEq==1 && filterQ) {
664678 vertical ? yDi+k : yDi+1,
665679 delta_q);
666680
667 if (vertical) { ptr[ 1 +k*stride] = Clip1_8bit(q1+delta_q); }
668 else { ptr[ k +1*stride] = Clip1_8bit(q1+delta_q); }
681 if (vertical) { ptr[ 1 +k*stride] = Clip_BitDepth(q1+delta_q, bitDepth_Y); }
682 else { ptr[ k +1*stride] = Clip_BitDepth(q1+delta_q, bitDepth_Y); }
669683 }
670684
671685 //nDp = dEp+1;
680694 }
681695 }
682696
697
698 void edge_filtering_luma(de265_image* img, bool vertical,
699 int yStart,int yEnd, int xStart,int xEnd)
700 {
701 if (img->high_bit_depth(0)) {
702 edge_filtering_luma_internal<uint16_t>(img,vertical,yStart,yEnd,xStart,xEnd);
703 }
704 else {
705 edge_filtering_luma_internal<uint8_t>(img,vertical,yStart,yEnd,xStart,xEnd);
706 }
707 }
683708
684709 void edge_filtering_luma_CTB(de265_image* img, bool vertical, int xCtb,int yCtb)
685710 {
695720
696721
697722 // 8.7.2.4
698 void edge_filtering_chroma(de265_image* img, bool vertical, int yStart,int yEnd,
699 int xStart,int xEnd)
700 {
701 int xIncr = vertical ? 4 : 2;
702 int yIncr = vertical ? 2 : 4;
723 /** ?Start and ?End values in 4-luma pixels resolution.
724 */
725 template <class pixel_t>
726 void edge_filtering_chroma_internal(de265_image* img, bool vertical,
727 int yStart,int yEnd,
728 int xStart,int xEnd)
729 {
730 //printf("chroma %d-%d %d-%d\n",xStart,xEnd,yStart,yEnd);
731
732 const int SubWidthC = img->sps.SubWidthC;
733 const int SubHeightC = img->sps.SubHeightC;
734
735 int xIncr = vertical ? 2 : 1;
736 int yIncr = vertical ? 1 : 2;
737
738 xIncr *= SubWidthC;
739 yIncr *= SubHeightC;
703740
704741 const int stride = img->get_image_stride(1);
705742
706743 xEnd = libde265_min(xEnd,img->get_deblk_width());
707744 yEnd = libde265_min(yEnd,img->get_deblk_height());
708745
746 int bitDepth_C = img->sps.BitDepth_C;
747
709748 for (int y=yStart;y<yEnd;y+=yIncr)
710749 for (int x=xStart;x<xEnd;x+=xIncr) {
711 int xDi = x*2;
712 int yDi = y*2;
713 int bS = img->get_deblk_bS(2*xDi,2*yDi);
750 int xDi = x << (3-SubWidthC);
751 int yDi = y << (3-SubHeightC);
752
753 //printf("x,y:%d,%d xDi,yDi:%d,%d\n",x,y,xDi,yDi);
754
755 int bS = img->get_deblk_bS(xDi*SubWidthC,yDi*SubHeightC);
714756
715757 if (bS>1) {
716758 // 8.7.2.4.5
720762 img->pps.pic_cb_qp_offset :
721763 img->pps.pic_cr_qp_offset);
722764
723 uint8_t* ptr = img->get_image_plane_at_pos(cplane+1, xDi,yDi);
724
725 uint8_t p[2][4];
726 uint8_t q[2][4];
765 pixel_t* ptr = img->get_image_plane_at_pos_NEW<pixel_t>(cplane+1, xDi,yDi);
766
767 pixel_t p[2][4];
768 pixel_t q[2][4];
727769
728770 logtrace(LogDeblock,"-%s- %d %d\n",cplane==0 ? "Cb" : "Cr",xDi,yDi);
729771
758800 }
759801 #endif
760802
761 int QP_Q = img->get_QPY(2*xDi,2*yDi);
803 int QP_Q = img->get_QPY(SubWidthC*xDi,SubHeightC*yDi);
762804 int QP_P = (vertical ?
763 img->get_QPY(2*xDi-1,2*yDi) :
764 img->get_QPY(2*xDi,2*yDi-1));
805 img->get_QPY(SubWidthC*xDi-1,SubHeightC*yDi) :
806 img->get_QPY(SubWidthC*xDi,SubHeightC*yDi-1));
765807 int qP_i = ((QP_Q+QP_P+1)>>1) + cQpPicOffset;
766 int QP_C = table8_22(qP_i);
808 int QP_C;
809 if (img->sps.ChromaArrayType == CHROMA_420) {
810 QP_C = table8_22(qP_i);
811 } else {
812 QP_C = libde265_min(qP_i, 51);
813 }
814
767815
768816 //printf("POC=%d\n",ctx->img->PicOrderCntVal);
769817 logtrace(LogDeblock,"%d %d: ((%d+%d+1)>>1) + %d = qP_i=%d (QP_C=%d)\n",
770 2*xDi,2*yDi, QP_Q,QP_P,cQpPicOffset,qP_i,QP_C);
771
772 int sliceIndexQ00 = img->get_SliceHeaderIndex(2*xDi,2*yDi);
818 SubWidthC*xDi,SubHeightC*yDi, QP_Q,QP_P,cQpPicOffset,qP_i,QP_C);
819
820 int sliceIndexQ00 = img->get_SliceHeaderIndex(SubWidthC*xDi,SubHeightC*yDi);
773821 int tc_offset = img->slices[sliceIndexQ00]->slice_tc_offset;
774822
775823 int Q = Clip3(0,53, QP_C + 2*(bS-1) + tc_offset);
781829
782830 if (vertical) {
783831 bool filterP = true;
784 if (img->sps.pcm_loop_filter_disable_flag && img->get_pcm_flag(2*xDi-1,2*yDi)) filterP=false;
785 if (img->get_cu_transquant_bypass(2*xDi-1,2*yDi)) filterP=false;
832 if (img->sps.pcm_loop_filter_disable_flag && img->get_pcm_flag(SubWidthC*xDi-1,SubHeightC*yDi)) filterP=false;
833 if (img->get_cu_transquant_bypass(SubWidthC*xDi-1,SubHeightC*yDi)) filterP=false;
786834
787835 bool filterQ = true;
788 if (img->sps.pcm_loop_filter_disable_flag && img->get_pcm_flag(2*xDi,2*yDi)) filterQ=false;
789 if (img->get_cu_transquant_bypass(2*xDi,2*yDi)) filterQ=false;
836 if (img->sps.pcm_loop_filter_disable_flag && img->get_pcm_flag(SubWidthC*xDi,SubHeightC*yDi)) filterQ=false;
837 if (img->get_cu_transquant_bypass(SubWidthC*xDi,SubHeightC*yDi)) filterQ=false;
790838
791839
792840 for (int k=0;k<4;k++) {
793841 int delta = Clip3(-tc,tc, ((((q[0][k]-p[0][k])<<2)+p[1][k]-q[1][k]+4)>>3));
794842 logtrace(LogDeblock,"delta=%d\n",delta);
795 if (filterP) { ptr[-1+k*stride] = Clip1_8bit(p[0][k]+delta); }
796 if (filterQ) { ptr[ 0+k*stride] = Clip1_8bit(q[0][k]-delta); }
843 if (filterP) { ptr[-1+k*stride] = Clip_BitDepth(p[0][k]+delta, bitDepth_C); }
844 if (filterQ) { ptr[ 0+k*stride] = Clip_BitDepth(q[0][k]-delta, bitDepth_C); }
797845 }
798846 }
799847 else {
800848 bool filterP = true;
801 if (img->sps.pcm_loop_filter_disable_flag && img->get_pcm_flag(2*xDi,2*yDi-1)) filterP=false;
802 if (img->get_cu_transquant_bypass(2*xDi,2*yDi-1)) filterP=false;
849 if (img->sps.pcm_loop_filter_disable_flag && img->get_pcm_flag(SubWidthC*xDi,SubHeightC*yDi-1)) filterP=false;
850 if (img->get_cu_transquant_bypass(SubWidthC*xDi,SubHeightC*yDi-1)) filterP=false;
803851
804852 bool filterQ = true;
805 if (img->sps.pcm_loop_filter_disable_flag && img->get_pcm_flag(2*xDi,2*yDi)) filterQ=false;
806 if (img->get_cu_transquant_bypass(2*xDi,2*yDi)) filterQ=false;
853 if (img->sps.pcm_loop_filter_disable_flag && img->get_pcm_flag(SubWidthC*xDi,SubHeightC*yDi)) filterQ=false;
854 if (img->get_cu_transquant_bypass(SubWidthC*xDi,SubHeightC*yDi)) filterQ=false;
807855
808856 for (int k=0;k<4;k++) {
809857 int delta = Clip3(-tc,tc, ((((q[0][k]-p[0][k])<<2)+p[1][k]-q[1][k]+4)>>3));
810 if (filterP) { ptr[ k-1*stride] = Clip1_8bit(p[0][k]+delta); }
811 if (filterQ) { ptr[ k+0*stride] = Clip1_8bit(q[0][k]-delta); }
858 if (filterP) { ptr[ k-1*stride] = Clip_BitDepth(p[0][k]+delta, bitDepth_C); }
859 if (filterQ) { ptr[ k+0*stride] = Clip_BitDepth(q[0][k]-delta, bitDepth_C); }
812860 }
813861 }
814862 }
815863 }
816864 }
817865 }
866
867
868 void edge_filtering_chroma(de265_image* img, bool vertical, int yStart,int yEnd,
869 int xStart,int xEnd)
870 {
871 if (img->high_bit_depth(1)) {
872 edge_filtering_chroma_internal<uint16_t>(img,vertical,yStart,yEnd,xStart,xEnd);
873 }
874 else {
875 edge_filtering_chroma_internal<uint8_t>(img,vertical,yStart,yEnd,xStart,xEnd);
876 }
877 }
878
818879
819880 void edge_filtering_chroma_CTB(de265_image* img, bool vertical, int xCtb,int yCtb)
820881 {
836897 bool vertical;
837898
838899 virtual void work();
900 virtual std::string name() const {
901 char buf[100];
902 sprintf(buf,"deblock-%d",ctb_y);
903 return buf;
904 }
839905 };
840906
841907
842908 void thread_task_deblock_CTBRow::work()
843909 {
844910 state = Running;
845 img->thread_run();
911 img->thread_run(this);
846912
847913 int xStart=0;
848914 int xEnd = img->get_deblk_width();
899965
900966 if (deblocking_enabled) {
901967 derive_boundaryStrength(img, vertical, first,last, xStart,xEnd);
902 edge_filtering_luma (img, vertical, first,last, xStart,xEnd);
903 edge_filtering_chroma (img, vertical, first,last, xStart,xEnd);
968
969 edge_filtering_luma(img, vertical, first,last, xStart,xEnd);
970
971 if (img->sps.ChromaArrayType != CHROMA_MONO) {
972 edge_filtering_chroma(img, vertical, first,last, xStart,xEnd);
973 }
904974 }
905975
906976 for (int x=0;x<=rightCtb;x++) {
909979 }
910980
911981 state = Finished;
912 img->thread_finishes();
982 img->thread_finishes(this);
913983 }
914984
915985
9341004 task->vertical = (pass==0);
9351005
9361006 imgunit->tasks.push_back(task);
937 add_task(&ctx->thread_pool, task);
1007 add_task(&ctx->thread_pool_, task);
9381008 n++;
9391009 }
9401010 }
9541024 logtrace(LogDeblock,"VERTICAL\n");
9551025 derive_boundaryStrength(img, true ,0,img->get_deblk_height(),0,img->get_deblk_width());
9561026 edge_filtering_luma (img, true ,0,img->get_deblk_height(),0,img->get_deblk_width());
957 edge_filtering_chroma (img, true ,0,img->get_deblk_height(),0,img->get_deblk_width());
958
1027
1028 if (img->sps.ChromaArrayType != CHROMA_MONO) {
1029 edge_filtering_chroma (img, true ,0,img->get_deblk_height(),0,img->get_deblk_width());
1030 }
9591031 #if 0
9601032 char buf[1000];
9611033 sprintf(buf,"lf-after-V-%05d.yuv", ctx->img->PicOrderCntVal);
9671039 logtrace(LogDeblock,"HORIZONTAL\n");
9681040 derive_boundaryStrength(img, false ,0,img->get_deblk_height(),0,img->get_deblk_width());
9691041 edge_filtering_luma (img, false ,0,img->get_deblk_height(),0,img->get_deblk_width());
970 edge_filtering_chroma (img, false ,0,img->get_deblk_height(),0,img->get_deblk_width());
1042
1043 if (img->sps.ChromaArrayType != CHROMA_MONO) {
1044 edge_filtering_chroma (img, false ,0,img->get_deblk_height(),0,img->get_deblk_width());
1045 }
9711046
9721047 #if 0
9731048 sprintf(buf,"lf-after-H-%05d.yuv", ctx->img->PicOrderCntVal);
3939 #include "x86/sse.h"
4040 #endif
4141
42 #ifdef HAVE_ARM
43 #include "arm/arm.h"
44 #endif
45
4246 #define SAVE_INTERMEDIATE_IMAGES 0
4347
4448 #if SAVE_INTERMEDIATE_IMAGES
8791 IsCuQpDeltaCoded = false;
8892 CuQpDelta = 0;
8993
94 IsCuChromaQpOffsetCoded = false;
95 CuQpOffsetCb = 0;
96 CuQpOffsetCr = 0;
97
9098 /*
9199 currentQPY = 0;
92100 currentQG_x = 0;
109117 img = NULL;
110118 shdr = NULL;
111119
120 imgunit = NULL;
121 sliceunit = NULL;
122
112123
113124 //memset(this,0,sizeof(thread_context));
114125
117128 int offset = (uintptr_t)_coeffBuf & 0x0f;
118129
119130 if (offset == 0) {
120 coeffBuf = (int16_t *) &_coeffBuf; // correctly aligned already
131 coeffBuf = _coeffBuf; // correctly aligned already
121132 }
122133 else {
123134 coeffBuf = (int16_t *) (((uint8_t *)_coeffBuf) + (16-offset));
128139
129140
130141 slice_unit::slice_unit(decoder_context* decctx)
131 : ctx(decctx),
132 nal(NULL),
142 : nal(NULL),
133143 shdr(NULL),
144 imgunit(NULL),
134145 flush_reorder_buffer(false),
146 nThreads(0),
147 first_decoded_CTB_RS(-1),
148 last_decoded_CTB_RS(-1),
135149 thread_contexts(NULL),
136 imgunit(NULL)
150 ctx(decctx)
137151 {
138152 state = Unprocessed;
153 nThreadContexts = 0;
139154 }
140155
141156 slice_unit::~slice_unit()
153168 assert(thread_contexts==NULL);
154169
155170 thread_contexts = new thread_context[n];
171 nThreadContexts = n;
156172 }
157173
158174
173189 for (int i=0;i<tasks.size();i++) {
174190 delete tasks[i];
175191 }
192 }
193
194
195 base_context::base_context()
196 {
197 set_acceleration_functions(de265_acceleration_AUTO);
176198 }
177199
178200
197219 param_vps_headers_fd = -1;
198220 param_pps_headers_fd = -1;
199221 param_slice_headers_fd = -1;
200
201 set_acceleration_functions(de265_acceleration_AUTO);
202222
203223 param_image_allocation_functions = de265_image::default_image_allocation;
204224 param_image_allocation_userdata = NULL;
319339
320340 de265_error decoder_context::start_thread_pool(int nThreads)
321341 {
322 ::start_thread_pool(&thread_pool, nThreads);
342 ::start_thread_pool(&thread_pool_, nThreads);
323343
324344 num_worker_threads = nThreads;
325345
331351 {
332352 if (get_num_worker_threads()>0) {
333353 //flush_thread_pool(&ctx->thread_pool);
334 ::stop_thread_pool(&thread_pool);
354 ::stop_thread_pool(&thread_pool_);
335355 }
336356 }
337357
340360 {
341361 if (num_worker_threads>0) {
342362 //flush_thread_pool(&ctx->thread_pool);
343 ::stop_thread_pool(&thread_pool);
363 ::stop_thread_pool(&thread_pool_);
344364 }
345365
346366 // --------------------------------------------------
406426 }
407427 }
408428
409 void decoder_context::set_acceleration_functions(enum de265_acceleration l)
429 void base_context::set_acceleration_functions(enum de265_acceleration l)
410430 {
411431 // fill scalar functions first (so that function table is completely filled)
412432
420440 init_acceleration_functions_sse(&acceleration);
421441 }
422442 #endif
443 #ifdef HAVE_ARM
444 if (l>=de265_acceleration_ARM) {
445 init_acceleration_functions_arm(&acceleration);
446 }
447 #endif
423448 }
424449
425450
465490 }
466491
467492
468 void decoder_context::add_task_decode_CTB_row(thread_context* tctx, bool firstSliceSubstream)
493 void decoder_context::add_task_decode_CTB_row(thread_context* tctx,
494 bool firstSliceSubstream,
495 int ctbRow)
469496 {
470497 thread_task_ctb_row* task = new thread_task_ctb_row;
471498 task->firstSliceSubstream = firstSliceSubstream;
472499 task->tctx = tctx;
500 task->debug_startCtbRow = ctbRow;
473501 tctx->task = task;
474502
475 add_task(&thread_pool, task);
503 add_task(&thread_pool_, task);
476504
477505 tctx->imgunit->tasks.push_back(task);
478506 }
479507
480508
481 void decoder_context::add_task_decode_slice_segment(thread_context* tctx, bool firstSliceSubstream)
509 void decoder_context::add_task_decode_slice_segment(thread_context* tctx, bool firstSliceSubstream,
510 int ctbx,int ctby)
482511 {
483512 thread_task_slice_segment* task = new thread_task_slice_segment;
484513 task->firstSliceSubstream = firstSliceSubstream;
485514 task->tctx = tctx;
515 task->debug_startCtbX = ctbx;
516 task->debug_startCtbY = ctby;
486517 tctx->task = task;
487518
488 add_task(&thread_pool, task);
519 add_task(&thread_pool_, task);
489520
490521 tctx->imgunit->tasks.push_back(task);
491522 }
495526 {
496527 logdebug(LogHeaders,"---> read VPS\n");
497528
498 video_parameter_set vps = { 0 };
499 de265_error err = ::read_vps(this,&reader,&vps);
529 video_parameter_set vps;
530 de265_error err = vps.read(this,&reader);
500531 if (err != DE265_OK) {
501532 return err;
502533 }
503534
504535 if (param_vps_headers_fd>=0) {
505 dump_vps(&vps, param_vps_headers_fd);
536 vps.dump(param_vps_headers_fd);
506537 }
507538
508539 process_vps(&vps);
522553 }
523554
524555 if (param_sps_headers_fd>=0) {
525 sps.dump_sps(param_sps_headers_fd);
556 sps.dump(param_sps_headers_fd);
526557 }
527558
528559 process_sps(&sps);
539570 bool success = pps.read(&reader,this);
540571
541572 if (param_pps_headers_fd>=0) {
542 pps.dump_pps(param_pps_headers_fd);
573 pps.dump(param_pps_headers_fd);
543574 }
544575
545576 if (success) {
603634
604635 if (process_slice_segment_header(this, shdr, &err, nal->pts, &nal_hdr, nal->user_data) == false)
605636 {
606 img->integrity = INTEGRITY_NOT_DECODED;
637 if (img!=NULL) img->integrity = INTEGRITY_NOT_DECODED;
607638 nal_parser.free_NAL_unit(nal);
608639 delete shdr;
609640 return err;
649680 image_units.back()->slice_units.push_back(sliceunit);
650681 }
651682
652 decode_some();
683 bool did_work;
684 err = decode_some(&did_work);
653685
654686 return DE265_OK;
655687 }
664696 }
665697
666698
667 de265_error decoder_context::decode_some()
699 de265_error decoder_context::decode_some(bool* did_work)
668700 {
669701 de265_error err = DE265_OK;
670702
671 if (0) {
672 static int cnt=0;
673 cnt++;
674 if (cnt<5) return DE265_OK;
675 }
703 *did_work = false;
676704
677705 if (image_units.empty()) { return DE265_OK; } // nothing to do
678706
679707
680708 // decode something if there is work to do
681709
682 if ( ! image_units.empty() && ! image_units[0]->slice_units.empty() ) {
710 if ( ! image_units.empty() ) { // && ! image_units[0]->slice_units.empty() ) {
683711
684712 image_unit* imgunit = image_units[0];
685 slice_unit* sliceunit = imgunit->slice_units[0];
686
687 pop_front(imgunit->slice_units);
688
689 if (sliceunit->flush_reorder_buffer) {
690 dpb.flush_reorder_buffer();
691 }
692
693 //err = decode_slice_unit_sequential(imgunit, sliceunit);
694 err = decode_slice_unit_parallel(imgunit, sliceunit);
695 if (err) {
696 return err;
697 }
698
699 delete sliceunit;
713 slice_unit* sliceunit = imgunit->get_next_unprocessed_slice_segment();
714
715 if (sliceunit != NULL) {
716
717 //pop_front(imgunit->slice_units);
718
719 if (sliceunit->flush_reorder_buffer) {
720 dpb.flush_reorder_buffer();
721 }
722
723 *did_work = true;
724
725 //err = decode_slice_unit_sequential(imgunit, sliceunit);
726 err = decode_slice_unit_parallel(imgunit, sliceunit);
727 if (err) {
728 return err;
729 }
730
731 //delete sliceunit;
732 }
700733 }
701734
702735
704737 // if we decoded all slices of the current image and there will not
705738 // be added any more slices to the image, output the image
706739
707 if ( ( image_units.size()>=2 && image_units[0]->slice_units.empty() ) ||
708 ( image_units.size()>=1 && image_units[0]->slice_units.empty() &&
740 if ( ( image_units.size()>=2 && image_units[0]->all_slice_segments_processed()) ||
741 ( image_units.size()>=1 && image_units[0]->all_slice_segments_processed() &&
709742 nal_parser.number_of_NAL_units_pending()==0 &&
710743 (nal_parser.is_end_of_stream() || nal_parser.is_end_of_frame()) )) {
711744
712745 image_unit* imgunit = image_units[0];
746
747 *did_work=true;
713748
714749
715750 // mark all CTBs as decoded even if they are not, because faulty input
767802
768803 remove_images_from_dpb(sliceunit->shdr->RemoveReferencesList);
769804
805 if (sliceunit->shdr->slice_segment_address >= imgunit->img->pps.CtbAddrRStoTS.size()) {
806 return DE265_ERROR_CTB_OUTSIDE_IMAGE_AREA;
807 }
808
770809
771810 struct thread_context tctx;
772811
774813 tctx.img = imgunit->img;
775814 tctx.decctx = this;
776815 tctx.imgunit = imgunit;
816 tctx.sliceunit= sliceunit;
777817 tctx.CtbAddrInTS = imgunit->img->pps.CtbAddrRStoTS[tctx.shdr->slice_segment_address];
778818 tctx.task = NULL;
779819
780820 init_thread_context(&tctx);
821
822 if (sliceunit->reader.bytes_remaining <= 0) {
823 return DE265_ERROR_PREMATURE_END_OF_SLICE;
824 }
781825
782826 init_CABAC_decoder(&tctx.cabac_decoder,
783827 sliceunit->reader.data,
787831
788832 if (pps->entropy_coding_sync_enabled_flag &&
789833 sliceunit->shdr->first_slice_segment_in_pic_flag) {
790 imgunit->ctx_models.resize( (img->sps.PicHeightInCtbsY-1) * CONTEXT_MODEL_TABLE_LENGTH );
791 }
792
793 if ((err=read_slice_segment_data(&tctx)) != DE265_OK)
794 { return err; }
834 imgunit->ctx_models.resize( (img->sps.PicHeightInCtbsY-1) ); //* CONTEXT_MODEL_TABLE_LENGTH );
835 }
836
837 sliceunit->nThreads=1;
838
839 err=read_slice_segment_data(&tctx);
840
841 sliceunit->finished_threads.set_progress(1);
795842
796843 return err;
844 }
845
846
847 void decoder_context::mark_whole_slice_as_processed(image_unit* imgunit,
848 slice_unit* sliceunit,
849 int progress)
850 {
851 //printf("mark whole slice\n");
852
853
854 // mark all CTBs upto the next slice segment as processed
855
856 slice_unit* nextSegment = imgunit->get_next_slice_segment(sliceunit);
857 if (nextSegment) {
858 /*
859 printf("mark whole slice between %d and %d\n",
860 sliceunit->shdr->slice_segment_address,
861 nextSegment->shdr->slice_segment_address);
862 */
863
864 for (int ctb=sliceunit->shdr->slice_segment_address;
865 ctb < nextSegment->shdr->slice_segment_address;
866 ctb++)
867 {
868 if (ctb >= imgunit->img->number_of_ctbs())
869 break;
870
871 imgunit->img->ctb_progress[ctb].set_progress(progress);
872 }
873 }
797874 }
798875
799876
804881
805882 remove_images_from_dpb(sliceunit->shdr->RemoveReferencesList);
806883
807
884 /*
885 printf("-------- decode --------\n");
886 printf("IMAGE UNIT %p\n",imgunit);
887 sliceunit->shdr->dump_slice_segment_header(sliceunit->ctx, 1);
888 imgunit->dump_slices();
889 */
808890
809891 de265_image* img = imgunit->img;
810892 const pic_parameter_set* pps = &img->pps;
893
894 sliceunit->state = slice_unit::InProgress;
811895
812896 bool use_WPP = (img->decctx->num_worker_threads > 0 &&
813897 pps->entropy_coding_sync_enabled_flag);
825909 }
826910
827911
912 // If this is the first slice segment, mark all CTBs before this as processed
913 // (the real first slice segment could be missing).
914
915 if (imgunit->is_first_slice_segment(sliceunit)) {
916 slice_segment_header* shdr = sliceunit->shdr;
917 int firstCTB = shdr->slice_segment_address;
918
919 for (int ctb=0;ctb<firstCTB;ctb++) {
920 //printf("mark pre progress %d\n",ctb);
921 img->ctb_progress[ctb].set_progress(CTB_PROGRESS_PREFILTER);
922 }
923 }
924
925
926 // if there is a previous slice that has been completely decoded,
927 // mark all CTBs until the start of this slice as completed
928
929 //printf("this slice: %p\n",sliceunit);
930 slice_unit* prevSlice = imgunit->get_prev_slice_segment(sliceunit);
931 //if (prevSlice) printf("prev slice state: %d\n",prevSlice->state);
932 if (prevSlice && prevSlice->state == slice_unit::Decoded) {
933 mark_whole_slice_as_processed(imgunit,prevSlice,CTB_PROGRESS_PREFILTER);
934 }
935
936
828937 // TODO: even though we cannot split this into several tasks, we should run it
829938 // as a background thread
830939 if (!use_WPP && !use_tiles) {
831 return decode_slice_unit_sequential(imgunit, sliceunit);
940 //printf("SEQ\n");
941 err = decode_slice_unit_sequential(imgunit, sliceunit);
942 sliceunit->state = slice_unit::Decoded;
943 mark_whole_slice_as_processed(imgunit,sliceunit,CTB_PROGRESS_PREFILTER);
944 return err;
832945 }
833946
834947
835948 if (use_WPP && use_tiles) {
836949 // TODO: this is not allowed ... output some warning or error
950
951 return DE265_WARNING_PPS_HEADER_INVALID;
837952 }
838953
839954
840955 if (use_WPP) {
841 return decode_slice_unit_WPP(imgunit, sliceunit);
956 //printf("WPP\n");
957 err = decode_slice_unit_WPP(imgunit, sliceunit);
958 sliceunit->state = slice_unit::Decoded;
959 mark_whole_slice_as_processed(imgunit,sliceunit,CTB_PROGRESS_PREFILTER);
960 return err;
842961 }
843962 else if (use_tiles) {
844 return decode_slice_unit_tiles(imgunit, sliceunit);
963 //printf("TILE\n");
964 err = decode_slice_unit_tiles(imgunit, sliceunit);
965 sliceunit->state = slice_unit::Decoded;
966 mark_whole_slice_as_processed(imgunit,sliceunit,CTB_PROGRESS_PREFILTER);
967 return err;
845968 }
846969
847970 assert(false);
848 return DE265_OK;
971 return err;
849972 }
850973
851974
863986
864987
865988 assert(img->num_threads_active() == 0);
866 img->thread_start(nRows);
867
868 //printf("-------- decode --------\n");
869989
870990
871991 // reserve space to store entropy coding context models for each CTB row
872992
873993 if (shdr->first_slice_segment_in_pic_flag) {
874994 // reserve space for nRows-1 because we don't need to save the CABAC model in the last CTB row
875 imgunit->ctx_models.resize( (img->sps.PicHeightInCtbsY-1) * CONTEXT_MODEL_TABLE_LENGTH );
995 imgunit->ctx_models.resize( (img->sps.PicHeightInCtbsY-1) ); //* CONTEXT_MODEL_TABLE_LENGTH );
876996 }
877997
878998
8891009 ctbRow++;
8901010 ctbAddrRS = ctbRow * ctbsWidth;
8911011 }
1012 else if (nRows>1 && (ctbAddrRS % ctbsWidth) != 0) {
1013 // If slice segment consists of several WPP rows, each of them
1014 // has to start at a row.
1015
1016 //printf("does not start at start\n");
1017
1018 err = DE265_WARNING_SLICEHEADER_INVALID;
1019 break;
1020 }
8921021
8931022
8941023 // prepare thread context
8991028 tctx->decctx = img->decctx;
9001029 tctx->img = img;
9011030 tctx->imgunit = imgunit;
1031 tctx->sliceunit= sliceunit;
9021032 tctx->CtbAddrInTS = pps->CtbAddrRStoTS[ctbAddrRS];
9031033
9041034 init_thread_context(tctx);
9141044 if (entryPt==nRows-1) dataEnd = sliceunit->reader.bytes_remaining;
9151045 else dataEnd = shdr->entry_point_offset[entryPt];
9161046
1047 if (dataStartIndex<0 || dataEnd>sliceunit->reader.bytes_remaining ||
1048 dataEnd <= dataStartIndex) {
1049 //printf("WPP premature end\n");
1050 err = DE265_ERROR_PREMATURE_END_OF_SLICE;
1051 break;
1052 }
1053
9171054 init_CABAC_decoder(&tctx->cabac_decoder,
9181055 &sliceunit->reader.data[dataStartIndex],
9191056 dataEnd-dataStartIndex);
9201057
9211058 // add task
9221059
923 add_task_decode_CTB_row(tctx, entryPt==0);
1060 //printf("start task for ctb-row: %d\n",ctbRow);
1061 img->thread_start(1);
1062 sliceunit->nThreads++;
1063 add_task_decode_CTB_row(tctx, entryPt==0, ctbRow);
9241064 }
9251065
9261066 #if 0
9601100
9611101
9621102 assert(img->num_threads_active() == 0);
963 img->thread_start(nTiles);
9641103
9651104 sliceunit->allocate_thread_contexts(nTiles);
9661105
9731112 // entry points other than the first start at tile beginnings
9741113 if (entryPt>0) {
9751114 tileID++;
1115
1116 if (tileID >= pps->num_tile_columns * pps->num_tile_rows) {
1117 err = DE265_WARNING_SLICEHEADER_INVALID;
1118 break;
1119 }
1120
9761121 int ctbX = pps->colBd[tileID % pps->num_tile_columns];
9771122 int ctbY = pps->rowBd[tileID / pps->num_tile_columns];
9781123 ctbAddrRS = ctbY * ctbsWidth + ctbX;
9861131 tctx->decctx = img->decctx;
9871132 tctx->img = img;
9881133 tctx->imgunit = imgunit;
1134 tctx->sliceunit= sliceunit;
9891135 tctx->CtbAddrInTS = pps->CtbAddrRStoTS[ctbAddrRS];
9901136
9911137 init_thread_context(tctx);
10011147 if (entryPt==nTiles-1) dataEnd = sliceunit->reader.bytes_remaining;
10021148 else dataEnd = shdr->entry_point_offset[entryPt];
10031149
1150 if (dataStartIndex<0 || dataEnd>sliceunit->reader.bytes_remaining ||
1151 dataEnd <= dataStartIndex) {
1152 err = DE265_ERROR_PREMATURE_END_OF_SLICE;
1153 break;
1154 }
1155
10041156 init_CABAC_decoder(&tctx->cabac_decoder,
10051157 &sliceunit->reader.data[dataStartIndex],
10061158 dataEnd-dataStartIndex);
10071159
10081160 // add task
10091161
1010 add_task_decode_slice_segment(tctx, entryPt==0);
1162 //printf("add tiles thread\n");
1163 img->thread_start(1);
1164 sliceunit->nThreads++;
1165 add_task_decode_slice_segment(tctx, entryPt==0,
1166 ctbAddrRS % ctbsWidth,
1167 ctbAddrRS / ctbsWidth);
10111168 }
10121169
10131170 img->wait_for_completion();
10161173 delete imgunit->tasks[i];
10171174 imgunit->tasks.clear();
10181175
1019 return DE265_OK;
1176 return err;
10201177 }
10211178
10221179
10321189 bitreader_init(&reader, nal->data(), nal->size());
10331190
10341191 nal_header nal_hdr;
1035 nal_read_header(&reader, &nal_hdr);
1192 nal_hdr.read(&reader);
10361193 ctx->process_nal_hdr(&nal_hdr);
1194
1195 if (nal_hdr.nuh_layer_id > 0) {
1196 // Discard all NAL units with nuh_layer_id > 0
1197 // These will have to be handeled by an SHVC decoder.
1198 nal_parser.free_NAL_unit(nal);
1199 return DE265_OK;
1200 }
10371201
10381202 loginfo(LogHighlevel,"NAL: 0x%x 0x%x - unit type:%s temporal id:%d\n",
10391203 nal->data()[0], nal->data()[1],
11041268 // if the stream has ended, and no more NALs are to be decoded, flush all pictures
11051269
11061270 if (ctx->nal_parser.get_NAL_queue_length() == 0 &&
1107 ctx->nal_parser.is_end_of_stream() &&
1271 (ctx->nal_parser.is_end_of_stream() || ctx->nal_parser.is_end_of_frame()) &&
11081272 ctx->image_units.empty()) {
11091273
11101274 // flush all pending pictures into output queue
11421306 // decode one NAL from the queue
11431307
11441308 de265_error err = DE265_OK;
1145
1146 if (ctx->nal_parser.number_of_NAL_units_pending()) {
1309 bool did_work = false;
1310
1311 if (ctx->nal_parser.get_NAL_queue_length()) { // number_of_NAL_units_pending()) {
11471312 NAL_unit* nal = ctx->nal_parser.pop_from_NAL_queue();
11481313 assert(nal);
11491314 err = ctx->decode_NAL(nal);
11501315 // ctx->nal_parser.free_NAL_unit(nal); TODO: do not free NAL with new loop
1316 did_work=true;
11511317 }
11521318 else if (ctx->nal_parser.is_end_of_frame() == true &&
11531319 ctx->image_units.empty()) {
11561322 return DE265_ERROR_WAITING_FOR_INPUT_DATA;
11571323 }
11581324 else {
1159 err = decode_some();
1325 err = decode_some(&did_work);
11601326 }
11611327
11621328 if (more) {
11631329 // decoding error is assumed to be unrecoverable
1164 *more = (err==DE265_OK);
1330 *more = (err==DE265_OK && did_work);
11651331 }
11661332
11671333 return err;
11721338 {
11731339 nal_unit_type = nal->nal_unit_type;
11741340
1175 IdrPicFlag = (nal->nal_unit_type == NAL_UNIT_IDR_W_RADL ||
1176 nal->nal_unit_type == NAL_UNIT_IDR_N_LP);
1177
1178 RapPicFlag = (nal->nal_unit_type >= 16 &&
1179 nal->nal_unit_type <= 23);
1341 IdrPicFlag = isIdrPic(nal->nal_unit_type);
1342 RapPicFlag = isRapPic(nal->nal_unit_type);
11801343 }
11811344
11821345
12471410 ctx->img->PicOrderCntVal);
12481411
12491412 if (ctx->img->nal_hdr.nuh_temporal_id==0 &&
1250 (isReferenceNALU(ctx->nal_unit_type) &&
1251 (!isRASL(ctx->nal_unit_type) && !isRADL(ctx->nal_unit_type))) &&
1252 1 /* sub-layer non-reference picture */) // TODO
1413 !isSublayerNonReference(ctx->nal_unit_type) &&
1414 !isRASL(ctx->nal_unit_type) &&
1415 !isRADL(ctx->nal_unit_type))
12531416 {
12541417 loginfo(LogHeaders,"set prevPicOrderCntLsb/Msb\n");
12551418
16071770 }
16081771 }
16091772
1610 if (hdr->num_ref_idx_l0_active > 15) {
1773 /*
1774 if (hdr->num_ref_idx_l0_active > 16) {
16111775 ctx->add_warning(DE265_WARNING_NONEXISTING_REFERENCE_PICTURE_ACCESSED, false);
16121776 return false;
16131777 }
1614
1778 */
1779
1780 assert(hdr->num_ref_idx_l0_active <= 16);
16151781 for (rIdx=0; rIdx<hdr->num_ref_idx_l0_active; rIdx++) {
16161782 int idx = hdr->ref_pic_list_modification_flag_l0 ? hdr->list_entry_l0[rIdx] : rIdx;
16171783
16191785 hdr->LongTermRefPic[0][rIdx] = isLongTerm[0][idx];
16201786
16211787 // remember POC of referenced image (needed in motion.c, derive_collocated_motion_vector)
1622 hdr->RefPicList_POC[0][rIdx] = ctx->dpb.get_image(hdr->RefPicList[0][rIdx])->PicOrderCntVal;
1623 hdr->RefPicList_PicState[0][rIdx] = ctx->dpb.get_image(hdr->RefPicList[0][rIdx])->PicState;
1788 de265_image* img_0_rIdx = ctx->dpb.get_image(hdr->RefPicList[0][rIdx]);
1789 if (img_0_rIdx==NULL) {
1790 return false;
1791 }
1792 hdr->RefPicList_POC[0][rIdx] = img_0_rIdx->PicOrderCntVal;
1793 hdr->RefPicList_PicState[0][rIdx] = img_0_rIdx->PicState;
16241794 }
16251795
16261796
16351805
16361806 int rIdx=0;
16371807 while (rIdx < NumRpsCurrTempList1) {
1638 for (int i=0;i<ctx->NumPocStCurrAfter && rIdx<NumRpsCurrTempList1; rIdx++,i++)
1808 for (int i=0;i<ctx->NumPocStCurrAfter && rIdx<NumRpsCurrTempList1; rIdx++,i++) {
16391809 RefPicListTemp1[rIdx] = ctx->RefPicSetStCurrAfter[i];
1640
1641 for (int i=0;i<ctx->NumPocStCurrBefore && rIdx<NumRpsCurrTempList1; rIdx++,i++)
1810 }
1811
1812 for (int i=0;i<ctx->NumPocStCurrBefore && rIdx<NumRpsCurrTempList1; rIdx++,i++) {
16421813 RefPicListTemp1[rIdx] = ctx->RefPicSetStCurrBefore[i];
1814 }
16431815
16441816 for (int i=0;i<ctx->NumPocLtCurr && rIdx<NumRpsCurrTempList1; rIdx++,i++) {
16451817 RefPicListTemp1[rIdx] = ctx->RefPicSetLtCurr[i];
16461818 isLongTerm[1][rIdx] = true;
16471819 }
1648 }
1649
1650 assert(hdr->num_ref_idx_l1_active <= 15);
1820
1821 // This check is to prevent an endless loop when no images are added above.
1822 if (rIdx==0) {
1823 ctx->add_warning(DE265_WARNING_FAULTY_REFERENCE_PICTURE_LIST, false);
1824 return false;
1825 }
1826 }
1827
1828 if (hdr->num_ref_idx_l0_active > 16) {
1829 ctx->add_warning(DE265_WARNING_NONEXISTING_REFERENCE_PICTURE_ACCESSED, false);
1830 return false;
1831 }
1832
1833 assert(hdr->num_ref_idx_l1_active <= 16);
16511834 for (rIdx=0; rIdx<hdr->num_ref_idx_l1_active; rIdx++) {
16521835 int idx = hdr->ref_pic_list_modification_flag_l1 ? hdr->list_entry_l1[rIdx] : rIdx;
16531836
16551838 hdr->LongTermRefPic[1][rIdx] = isLongTerm[1][idx];
16561839
16571840 // remember POC of referenced imaged (needed in motion.c, derive_collocated_motion_vector)
1658 hdr->RefPicList_POC[1][rIdx] = ctx->dpb.get_image(hdr->RefPicList[1][rIdx])->PicOrderCntVal;
1659 hdr->RefPicList_PicState[1][rIdx] = ctx->dpb.get_image(hdr->RefPicList[1][rIdx])->PicState;
1841 de265_image* img_1_rIdx = ctx->dpb.get_image(hdr->RefPicList[1][rIdx]);
1842 if (img_1_rIdx == NULL) { return false; }
1843 hdr->RefPicList_POC[1][rIdx] = img_1_rIdx->PicOrderCntVal;
1844 hdr->RefPicList_PicState[1][rIdx] = img_1_rIdx->PicState;
16601845 }
16611846 }
16621847
18372022 ctx->img = img;
18382023
18392024 img->vps = *ctx->current_vps;
1840 img->sps = *ctx->current_sps;
2025 //img->sps = *ctx->current_sps; // already set in new_image()
18412026 img->pps = *ctx->current_pps;
18422027 img->decctx = ctx;
18432028
18922077
18932078 first_decoded_picture = false;
18942079 }
2080 else {
2081 // claims to be not the first slice, but there is no active image available
2082
2083 if (ctx->img == NULL) {
2084 return false;
2085 }
2086 }
18952087
18962088 if (hdr->slice_type == SLICE_TYPE_B ||
18972089 hdr->slice_type == SLICE_TYPE_P)
3737 #define DE265_MAX_VPS_SETS 16 // this is the maximum as defined in the standard
3838 #define DE265_MAX_SPS_SETS 16 // this is the maximum as defined in the standard
3939 #define DE265_MAX_PPS_SETS 64 // this is the maximum as defined in the standard
40 #define MAX_THREAD_CONTEXTS 68 // enough for 4K @ 32 pixel CTBs, but TODO: make this dynamic
4140
4241 #define MAX_WARNINGS 20
4342
4443
45 struct slice_segment_header;
46 struct image_unit;
47
48
49 struct thread_context
44 class slice_segment_header;
45 class image_unit;
46 class slice_unit;
47 class decoder_context;
48
49
50 class thread_context
5051 {
52 public:
5153 thread_context();
5254
5355 int CtbAddrInRS;
5860
5961 // motion vectors
6062
61 int8_t refIdx[2];
62 int16_t mvd[2][2]; // only in top left position
63 uint8_t merge_flag;
64 uint8_t merge_idx;
65 uint8_t mvp_lX_flag[2];
66 uint8_t inter_pred_idc; // enum InterPredIdc
63 motion_spec motion;
6764
6865
6966 // prediction
7067
71 enum IntraPredMode IntraPredModeC; // chroma intra-prediction mode for current CB
68 // enum IntraPredMode IntraPredModeC[4]; // chroma intra-prediction mode for current CB
69 int ResScaleVal;
7270
7371
7472 // residual data
7573
7674 uint8_t cu_transquant_bypass_flag;
7775 uint8_t transform_skip_flag[3];
76 uint8_t explicit_rdpcm_flag;
77 uint8_t explicit_rdpcm_dir;
7878
7979 ALIGNED_16(int16_t) _coeffBuf[(32*32)+8]; // alignment required for SSE code !
8080 int16_t *coeffBuf;
8383 int16_t coeffPos[3][32*32];
8484 int16_t nCoeff[3];
8585
86 int32_t residual_luma[32*32]; // only used when cross-comp-prediction is enabled
87
8688
8789 // quantization
8890
8991 int IsCuQpDeltaCoded;
9092 int CuQpDelta;
93 int IsCuChromaQpOffsetCoded;
94 int CuQpOffsetCb, CuQpOffsetCr;
9195
9296 int currentQPY;
9397 int currentQG_x, currentQG_y;
97101
98102 CABAC_decoder cabac_decoder;
99103
100 context_model ctx_model[CONTEXT_MODEL_TABLE_LENGTH];
101
102 struct decoder_context* decctx;
104 context_model_table ctx_model;
105 uint8_t StatCoeff[4];
106
107 decoder_context* decctx;
103108 struct de265_image *img;
104 struct slice_segment_header* shdr;
105
106 struct image_unit* imgunit;
107 struct thread_task* task; // executing thread_task or NULL if not multi-threaded
109 slice_segment_header* shdr;
110
111 image_unit* imgunit;
112 slice_unit* sliceunit;
113 thread_task* task; // executing thread_task or NULL if not multi-threaded
108114
109115 private:
110116 thread_context(const thread_context&); // not allowed
130136
131137
132138
133 struct slice_unit
139 class slice_unit
134140 {
141 public:
135142 slice_unit(decoder_context* decctx);
136143 ~slice_unit();
137144
139146 slice_segment_header* shdr; // not the owner (de265_image is owner)
140147 bitreader reader;
141148
142 struct image_unit* imgunit;
149 image_unit* imgunit;
143150
144151 bool flush_reorder_buffer;
145152
146 enum { Unprocessed,
147 Inprogress,
148 Decoded
153
154 // decoding status
155
156 enum SliceDecodingProgress { Unprocessed,
157 InProgress,
158 Decoded
149159 } state;
150160
161 de265_progress_lock finished_threads;
162 int nThreads;
163
164 int first_decoded_CTB_RS; // TODO
165 int last_decoded_CTB_RS; // TODO
166
151167 void allocate_thread_contexts(int n);
152 thread_context* get_thread_context(int n) { return &thread_contexts[n]; }
168 thread_context* get_thread_context(int n) {
169 assert(n < nThreadContexts);
170 return &thread_contexts[n];
171 }
172 int num_thread_contexts() const { return nThreadContexts; }
153173
154174 private:
155175 thread_context* thread_contexts; /* NOTE: cannot use std::vector, because thread_context has
156176 no copy constructor. */
157
177 int nThreadContexts;
178
179 public:
158180 decoder_context* ctx;
159181
160
182 private:
161183 slice_unit(const slice_unit&); // not allowed
162184 const slice_unit& operator=(const slice_unit&); // not allowed
163185 };
164186
165187
166 struct image_unit
188 class image_unit
167189 {
190 public:
168191 image_unit();
169192 ~image_unit();
170193
173196
174197 std::vector<slice_unit*> slice_units;
175198 std::vector<sei_message> suffix_SEIs;
199
200 slice_unit* get_next_unprocessed_slice_segment() const {
201 for (int i=0;i<slice_units.size();i++) {
202 if (slice_units[i]->state == slice_unit::Unprocessed) {
203 return slice_units[i];
204 }
205 }
206
207 return NULL;
208 }
209
210 slice_unit* get_prev_slice_segment(slice_unit* s) const {
211 for (int i=1; i<slice_units.size(); i++) {
212 if (slice_units[i]==s) {
213 return slice_units[i-1];
214 }
215 }
216
217 return NULL;
218 }
219
220 slice_unit* get_next_slice_segment(slice_unit* s) const {
221 for (int i=0; i<slice_units.size()-1; i++) {
222 if (slice_units[i]==s) {
223 return slice_units[i+1];
224 }
225 }
226
227 return NULL;
228 }
229
230 void dump_slices() const {
231 for (int i=0; i<slice_units.size(); i++) {
232 printf("[%d] = %p\n",i,slice_units[i]);
233 }
234 }
235
236 bool all_slice_segments_processed() const {
237 if (slice_units.size()==0) return true;
238 if (slice_units.back()->state != slice_unit::Unprocessed) return true;
239 return false;
240 }
241
242 bool is_first_slice_segment(const slice_unit* s) const {
243 if (slice_units.size()==0) return false;
244 return (slice_units[0] == s);
245 }
176246
177247 enum { Invalid, // headers not read yet
178248 Unknown, // SPS/PPS available
191261 /* Saved context models for WPP.
192262 There is one saved model for the initialization of each CTB row.
193263 The array is unused for non-WPP streams. */
194 std::vector<context_model> ctx_models; // TODO: move this into image ?
264 std::vector<context_model_table> ctx_models; // TODO: move this into image ?
195265 };
196266
197267
198
199 class decoder_context : public error_queue {
268 class base_context : public error_queue
269 {
270 public:
271 base_context();
272 virtual ~base_context() { }
273
274 // --- accelerated DSP functions ---
275
276 void set_acceleration_functions(enum de265_acceleration);
277
278 struct acceleration_functions acceleration; // CPU optimized functions
279
280 //virtual /* */ de265_image* get_image(int dpb_index) { return dpb.get_image(dpb_index); }
281 virtual const de265_image* get_image(int frame_id) const = 0;
282 virtual bool has_image(int frame_id) const = 0;
283 };
284
285
286 class decoder_context : public base_context {
200287 public:
201288 decoder_context();
202289 ~decoder_context();
223310 de265_error decode_NAL(NAL_unit* nal);
224311
225312 de265_error decode(int* more);
226 de265_error decode_some();
313 de265_error decode_some(bool* did_work);
227314
228315 de265_error decode_slice_unit_sequential(image_unit* imgunit, slice_unit* sliceunit);
229316 de265_error decode_slice_unit_parallel(image_unit* imgunit, slice_unit* sliceunit);
230317 de265_error decode_slice_unit_WPP(image_unit* imgunit, slice_unit* sliceunit);
231318 de265_error decode_slice_unit_tiles(image_unit* imgunit, slice_unit* sliceunit);
232319
320
233321 void process_nal_hdr(nal_header*);
234322 void process_vps(video_parameter_set*);
235323 void process_sps(seq_parameter_set*);
263351
264352 de265_image_allocation param_image_allocation_functions;
265353 void* param_image_allocation_userdata;
266
267
268 // --- accelerated DSP functions ---
269
270 void set_acceleration_functions(enum de265_acceleration);
271
272 struct acceleration_functions acceleration; // CPU optimized functions
273354
274355
275356 // --- input stream data ---
308389 pic_parameter_set* current_pps;
309390
310391 public:
311 struct thread_pool thread_pool;
392 thread_pool thread_pool_;
312393
313394 private:
314395 int num_worker_threads;
414495 bool flush_reorder_buffer_at_this_frame;
415496
416497 private:
417 void init_thread_context(class thread_context* tctx);
418 void add_task_decode_CTB_row(thread_context* tctx, bool firstSliceSubstream);
419 void add_task_decode_slice_segment(thread_context* tctx, bool firstSliceSubstream);
420
498 void init_thread_context(thread_context* tctx);
499 void add_task_decode_CTB_row(thread_context* tctx, bool firstSliceSubstream, int ctbRow);
500 void add_task_decode_slice_segment(thread_context* tctx, bool firstSliceSubstream,
501 int ctbX,int ctbY);
502
503 void mark_whole_slice_as_processed(image_unit* imgunit,
504 slice_unit* sliceunit,
505 int progress);
421506
422507 void process_picture_order_count(decoder_context* ctx, slice_segment_header* hdr);
423508 int generate_unavailable_reference_picture(decoder_context* ctx, const seq_parameter_set* sps,
427512
428513
429514 void remove_images_from_dpb(const std::vector<int>& removeImageList);
430 void run_postprocessing_filters_sequential(de265_image* img);
515 void run_postprocessing_filters_sequential(struct de265_image* img);
431516 void run_postprocessing_filters_parallel(image_unit* img);
432517 };
433518
258258 default: chroma = de265_chroma_420; assert(0); break; // should never happen
259259 }
260260
261 img->alloc_image(w,h, chroma, sps, true, decctx, pts, user_data, isOutputImage);
261 img->alloc_image(w,h, chroma, sps, true, decctx, NULL, pts, user_data, isOutputImage);
262262
263263 img->integrity = INTEGRITY_CORRECT;
264264
2626 #include <deque>
2727 #include <vector>
2828
29 class decoder_context;
2930
30
31 struct decoded_picture_buffer {
31 class decoded_picture_buffer {
32 public:
3233 decoded_picture_buffer();
3334 ~decoded_picture_buffer();
3435
3940 If there is no space for a new image, return -1. */
4041 int new_image(const seq_parameter_set* sps, decoder_context* decctx,
4142 de265_PTS pts, void* user_data, bool isOutputImage);
42
43
4344 /* Check for a free slot in the DPB. There are some slots reserved for
4445 unavailable reference frames. If high_priority==true, these reserved slots
4546 are included in the check. */
5152 int size() const { return dpb.size(); }
5253
5354 /* Raw access to the images. */
54 /* */ de265_image* get_image(int index) { return dpb[index]; }
55 const de265_image* get_image(int index) const { return dpb[index]; }
55
56 /* */ de265_image* get_image(int index) {
57 if (index>=dpb.size()) return NULL;
58 return dpb[index];
59 }
60
61 const de265_image* get_image(int index) const {
62 if (index>=dpb.size()) return NULL;
63 return dpb[index];
64 }
5665
5766 /* Search DPB for the slot index of a specific picture. */
5867 int DPB_index_of_picture_with_POC(int poc, int currentID, bool preferLongTerm=false) const;
5968 int DPB_index_of_picture_with_LSB(int lsb, int currentID, bool preferLongTerm=false) const;
6069 int DPB_index_of_picture_with_ID (int id) const;
61
70
6271
6372 // --- reorder buffer ---
6473
65 void insert_image_into_reorder_buffer(de265_image* img) {
74 void insert_image_into_reorder_buffer(struct de265_image* img) {
6675 reorder_output_queue.push_back(img);
6776 }
6877
7079
7180 // move next picture in reorder buffer to output queue
7281 void output_next_picture_in_reorder_buffer();
73
82
7483 // Move all pictures in reorder buffer to output buffer. Return true if there were any pictures.
7584 bool flush_reorder_buffer();
76
85
7786
7887 // --- output buffer ---
7988
8089 int num_pictures_in_output_queue() const { return image_output_queue.size(); }
8190
8291 /* Get the next picture in the output queue, but do not remove it from the queue. */
83 de265_image* get_next_picture_in_output_queue() const { return image_output_queue.front(); }
92 struct de265_image* get_next_picture_in_output_queue() const { return image_output_queue.front(); }
8493
8594 /* Remove the next picture in the output queue. */
8695 void pop_next_picture_in_output_queue();
9099
91100 void log_dpb_content() const;
92101 void log_dpb_queues() const;
93
102
94103 private:
95104 int max_images_in_DPB;
96105 int norm_images_in_DPB;
97106
98 std::vector<de265_image*> dpb; // decoded picture buffer
107 std::vector<struct de265_image*> dpb; // decoded picture buffer
99108
100 std::vector<de265_image*> reorder_output_queue;
101 std::deque<de265_image*> image_output_queue;
109 std::vector<struct de265_image*> reorder_output_queue;
110 std::deque<struct de265_image*> image_output_queue;
102111
103112 private:
104113 decoded_picture_buffer(const decoded_picture_buffer&); // no copy
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #include "libde265/en265.h"
23 #include "libde265/encoder/encoder-context.h"
24
25
26 LIBDE265_API en265_encoder_context* en265_new_encoder(void)
27 {
28 de265_error init_err = de265_init();
29 if (init_err != DE265_OK) {
30 return NULL;
31 }
32
33 encoder_context* ectx = new encoder_context();
34 return (en265_encoder_context*)ectx;
35 }
36
37
38 LIBDE265_API de265_error en265_free_encoder(en265_encoder_context* e)
39 {
40 assert(e);
41 encoder_context* ectx = (encoder_context*)e;
42 delete ectx;
43
44 return de265_free();
45 }
46
47
48 LIBDE265_API void en265_set_image_release_function(en265_encoder_context* e,
49 void (*release_func)(en265_encoder_context*,
50 de265_image*,
51 void* userdata),
52 void* alloc_userdata)
53 {
54 assert(e);
55 encoder_context* ectx = (encoder_context*)e;
56
57 ectx->param_image_allocation_userdata = alloc_userdata;
58 ectx->release_func = release_func;
59 }
60
61
62 // ========== encoder parameters ==========
63
64 LIBDE265_API de265_error en265_parse_command_line_parameters(en265_encoder_context* e,
65 int* argc, char** argv)
66 {
67 assert(e);
68 encoder_context* ectx = (encoder_context*)e;
69
70 //if (!ectx->params_config.parse_command_line_params(argc,argv, &ectx->params, true)) {
71 int first_idx=1;
72 if (!ectx->params_config.parse_command_line_params(argc,argv, &first_idx, true)) {
73 return DE265_ERROR_PARAMETER_PARSING;
74 }
75 else {
76 return DE265_OK;
77 }
78 }
79
80 LIBDE265_API void en265_show_parameters(en265_encoder_context* e)
81 {
82 assert(e);
83 encoder_context* ectx = (encoder_context*)e;
84
85 //ectx->params_config.show_params(&ectx->params);
86
87 ectx->params_config.print_params();
88 }
89
90
91 LIBDE265_API const char** en265_list_parameters(en265_encoder_context* e)
92 {
93 assert(e);
94 encoder_context* ectx = (encoder_context*)e;
95
96 return ectx->params_config.get_parameter_string_table();
97 }
98
99
100 LIBDE265_API enum en265_parameter_type en265_get_parameter_type(en265_encoder_context* e,
101 const char* parametername)
102 {
103 assert(e);
104 encoder_context* ectx = (encoder_context*)e;
105
106 return ectx->params_config.get_parameter_type(parametername);
107 }
108
109
110 LIBDE265_API de265_error en265_set_parameter_bool(en265_encoder_context* e,
111 const char* param,int value)
112 {
113 assert(e);
114 encoder_context* ectx = (encoder_context*)e;
115
116 return ectx->params_config.set_bool(param,value) ? DE265_OK : DE265_ERROR_PARAMETER_PARSING;
117 }
118
119
120 LIBDE265_API de265_error en265_set_parameter_int(en265_encoder_context* e,
121 const char* param,int value)
122 {
123 assert(e);
124 encoder_context* ectx = (encoder_context*)e;
125
126 return ectx->params_config.set_int(param,value) ? DE265_OK : DE265_ERROR_PARAMETER_PARSING;
127 }
128
129 LIBDE265_API de265_error en265_set_parameter_string(en265_encoder_context* e,
130 const char* param,const char* value)
131 {
132 assert(e);
133 encoder_context* ectx = (encoder_context*)e;
134
135 return ectx->params_config.set_string(param,value) ? DE265_OK : DE265_ERROR_PARAMETER_PARSING;
136 }
137
138 LIBDE265_API de265_error en265_set_parameter_choice(en265_encoder_context* e,
139 const char* param,const char* value)
140 {
141 assert(e);
142 encoder_context* ectx = (encoder_context*)e;
143
144 return ectx->params_config.set_choice(param,value) ? DE265_OK : DE265_ERROR_PARAMETER_PARSING;
145 }
146
147
148 LIBDE265_API const char** en265_list_parameter_choices(en265_encoder_context* e,
149 const char* parametername)
150 {
151 assert(e);
152 encoder_context* ectx = (encoder_context*)e;
153
154 return ectx->params_config.get_parameter_choices_table(parametername);
155 }
156
157
158
159 // ========== encoding loop ==========
160
161
162 LIBDE265_API de265_error en265_start_encoder(en265_encoder_context* e, int number_of_threads)
163 {
164 assert(e);
165 encoder_context* ectx = (encoder_context*)e;
166
167 ectx->start_encoder();
168
169 return DE265_OK;
170 }
171
172
173 LIBDE265_API struct de265_image* en265_allocate_image(en265_encoder_context* e,
174 int width, int height, de265_chroma chroma,
175 de265_PTS pts, void* image_userdata)
176 {
177 assert(e);
178 encoder_context* ectx = (encoder_context*)e;
179
180 de265_image* img = new de265_image;
181 if (img->alloc_image(width,height,de265_chroma_420, NULL, false,
182 NULL,ectx, pts, image_userdata, true) != DE265_OK) {
183 delete img;
184 return NULL;
185 }
186
187 return img;
188 }
189
190 // Request a specification of the image memory layout for an image of the specified dimensions.
191 LIBDE265_API void en265_get_image_spec(en265_encoder_context* e,
192 int width, int height, de265_chroma chroma,
193 struct de265_image_spec* out_spec)
194 {
195 out_spec->format = de265_image_format_YUV420P8;
196 out_spec->width = width;
197 out_spec->height= height;
198 out_spec->alignment = 1;
199
200 out_spec->crop_left =0;
201 out_spec->crop_right =0;
202 out_spec->crop_top =0;
203 out_spec->crop_bottom=0;
204
205 out_spec->visible_width = out_spec->width - out_spec->crop_left - out_spec->crop_right;
206 out_spec->visible_height = out_spec->height - out_spec->crop_top - out_spec->crop_bottom;
207 }
208
209 // Image memory layout specification for an image returned by en265_allocate_image().
210 //LIBDE265_API void de265_get_image_spec_from_image(de265_image* img, struct de265_image_spec* spec);
211
212
213
214 LIBDE265_API de265_error en265_push_image(en265_encoder_context* e,
215 struct de265_image* img)
216 {
217 assert(e);
218 encoder_context* ectx = (encoder_context*)e;
219
220 ectx->sop->insert_new_input_image(img);
221 return DE265_OK;
222 }
223
224
225 LIBDE265_API de265_error en265_push_eof(en265_encoder_context* e)
226 {
227 assert(e);
228 encoder_context* ectx = (encoder_context*)e;
229
230 ectx->sop->insert_end_of_stream();
231 return DE265_OK;
232 }
233
234
235 LIBDE265_API de265_error en265_block_on_input_queue_length(en265_encoder_context*,
236 int max_pending_images,
237 int timeout_ms)
238 {
239 // TODO
240 return DE265_OK;
241 }
242
243 LIBDE265_API de265_error en265_trim_input_queue(en265_encoder_context*, int max_pending_images)
244 {
245 // TODO
246 return DE265_OK;
247 }
248
249 LIBDE265_API int en265_current_input_queue_length(en265_encoder_context*)
250 {
251 // TODO
252 return DE265_OK;
253 }
254
255 LIBDE265_API de265_error en265_encode(en265_encoder_context* e)
256 {
257 assert(e);
258 encoder_context* ectx = (encoder_context*)e;
259
260 while (ectx->picbuf.have_more_frames_to_encode())
261 {
262 de265_error result = ectx->encode_picture_from_input_buffer();
263 if (result != DE265_OK) return result;
264 }
265
266 return DE265_OK;
267 }
268
269 LIBDE265_API enum en265_encoder_state en265_get_encoder_state(en265_encoder_context* e)
270 {
271 // TODO
272 return EN265_STATE_IDLE;
273 }
274
275 LIBDE265_API struct en265_packet* en265_get_packet(en265_encoder_context* e, int timeout_ms)
276 {
277 assert(e);
278 encoder_context* ectx = (encoder_context*)e;
279
280 assert(timeout_ms==0); // TODO: blocking not implemented yet
281
282 if (ectx->output_packets.size()>0) {
283 en265_packet* pck = ectx->output_packets.front();
284 ectx->output_packets.pop_front();
285
286 return pck;
287 }
288 else {
289 return NULL;
290 }
291 }
292
293 LIBDE265_API void en265_free_packet(en265_encoder_context* e, struct en265_packet* pck)
294 {
295 assert(e);
296 encoder_context* ectx = (encoder_context*)e;
297
298 // Do not delete images here. They are owned by the EncPicBuf.
299 //delete pck->input_image;
300 //delete pck->reconstruction;
301
302 if (pck->frame_number >= 0) {
303 ectx->mark_image_is_outputted(pck->frame_number);
304
305 ectx->release_input_image(pck->frame_number);
306 }
307
308 delete[] pck->data;
309 delete pck;
310 }
311
312 LIBDE265_API int en265_number_of_queued_packets(en265_encoder_context* e)
313 {
314 assert(e);
315 encoder_context* ectx = (encoder_context*)e;
316
317 return ectx->output_packets.size();
318 }
319
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef EN265_H
23 #define EN265_H
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 #include <libde265/de265.h>
30
31
32 // ========== encoder context ==========
33
34 typedef void en265_encoder_context; // private structure
35
36 /* Get a new encoder context. Must be freed with en265_free_encoder(). */
37 LIBDE265_API en265_encoder_context* en265_new_encoder(void);
38
39 /* Free encoder context. May only be called once on a context. */
40 LIBDE265_API de265_error en265_free_encoder(en265_encoder_context*);
41
42 /* The alloc_userdata pointer will be given to the release_func(). */
43 LIBDE265_API void en265_set_image_release_function(en265_encoder_context*,
44 void (*release_func)(en265_encoder_context*,
45 struct de265_image*,
46 void* userdata),
47 void* alloc_userdata);
48
49 // ========== encoder parameters ==========
50
51 LIBDE265_API de265_error en265_set_parameter_bool(en265_encoder_context*,
52 const char* parametername,int value);
53 LIBDE265_API de265_error en265_set_parameter_int(en265_encoder_context*,
54 const char* parametername,int value);
55 LIBDE265_API de265_error en265_set_parameter_string(en265_encoder_context*,
56 const char* parametername,const char* value);
57 LIBDE265_API de265_error en265_set_parameter_choice(en265_encoder_context*,
58 const char* parametername,const char* value);
59
60
61 LIBDE265_API const char** en265_list_parameters(en265_encoder_context*);
62
63 enum en265_parameter_type {
64 en265_parameter_bool,
65 en265_parameter_int,
66 en265_parameter_string,
67 en265_parameter_choice
68 };
69
70 LIBDE265_API enum en265_parameter_type en265_get_parameter_type(en265_encoder_context*,
71 const char* parametername);
72
73 LIBDE265_API const char** en265_list_parameter_choices(en265_encoder_context*,
74 const char* parametername);
75
76
77 // --- convenience functions for command-line parameters ---
78
79 LIBDE265_API de265_error en265_parse_command_line_parameters(en265_encoder_context*,
80 int* argc, char** argv);
81 LIBDE265_API void en265_show_parameters(en265_encoder_context*);
82
83
84
85 // ========== encoding loop ==========
86
87 LIBDE265_API de265_error en265_start_encoder(en265_encoder_context*, int number_of_threads);
88
89 // If we have provided our own memory release function, no image memory will be allocated.
90 LIBDE265_API struct de265_image* en265_allocate_image(en265_encoder_context*,
91 int width, int height,
92 enum de265_chroma chroma,
93 de265_PTS pts, void* image_userdata);
94
95 LIBDE265_API void* de265_alloc_image_plane(struct de265_image* img, int cIdx,
96 void* inputdata, int inputstride, void *userdata);
97 LIBDE265_API void de265_free_image_plane(struct de265_image* img, int cIdx);
98
99
100 // Request a specification of the image memory layout for an image of the specified dimensions.
101 LIBDE265_API void en265_get_image_spec(en265_encoder_context*,
102 int width, int height, enum de265_chroma chroma,
103 struct de265_image_spec* out_spec);
104
105 // Image memory layout specification for an image returned by en265_allocate_image().
106 /* TODO: do we need this?
107 LIBDE265_API void de265_get_image_spec_from_image(de265_image* img, struct de265_image_spec* spec);
108 */
109
110
111 LIBDE265_API de265_error en265_push_image(en265_encoder_context*,
112 struct de265_image*); // non-blocking
113
114 LIBDE265_API de265_error en265_push_eof(en265_encoder_context*);
115
116 // block when there are more than max_input_images in the input queue
117 LIBDE265_API de265_error en265_block_on_input_queue_length(en265_encoder_context*,
118 int max_pending_images,
119 int timeout_ms);
120
121 LIBDE265_API de265_error en265_trim_input_queue(en265_encoder_context*, int max_pending_images);
122
123 LIBDE265_API int en265_current_input_queue_length(en265_encoder_context*);
124
125 // Run encoder in main thread. Only use this when not using background threads.
126 LIBDE265_API de265_error en265_encode(en265_encoder_context*);
127
128 enum en265_encoder_state
129 {
130 EN265_STATE_IDLE,
131 EN265_STATE_WAITING_FOR_INPUT,
132 EN265_STATE_WORKING,
133 EN265_STATE_OUTPUT_QUEUE_FULL,
134 EN265_STATE_EOS
135 };
136
137
138 LIBDE265_API enum en265_encoder_state en265_get_encoder_state(en265_encoder_context*);
139
140
141 enum en265_packet_content_type {
142 EN265_PACKET_VPS,
143 EN265_PACKET_SPS,
144 EN265_PACKET_PPS,
145 EN265_PACKET_SEI,
146 EN265_PACKET_SLICE,
147 EN265_PACKET_SKIPPED_IMAGE
148 };
149
150
151 enum en265_nal_unit_type {
152 EN265_NUT_TRAIL_N = 0,
153 EN265_NUT_TRAIL_R = 1,
154 EN265_NUT_TSA_N = 2,
155 EN265_NUT_TSA_R = 3,
156 EN265_NUT_STSA_N = 4,
157 EN265_NUT_STSA_R = 5,
158 EN265_NUT_RADL_N = 6,
159 EN265_NUT_RADL_R = 7,
160 EN265_NUT_RASL_N = 8,
161 EN265_NUT_RASL_R = 9,
162 EN265_NUT_BLA_W_LP = 16,
163 EN265_NUT_BLA_W_RADL= 17,
164 EN265_NUT_BLA_N_LP = 18,
165 EN265_NUT_IDR_W_RADL= 19,
166 EN265_NUT_IDR_N_LP = 20,
167 EN265_NUT_CRA = 21,
168 EN265_NUT_VPS = 32,
169 EN265_NUT_SPS = 33,
170 EN265_NUT_PPS = 34,
171 EN265_NUT_AUD = 35,
172 EN265_NUT_EOS = 36,
173 EN265_NUT_EOB = 37,
174 EN265_NUT_FD = 38,
175 EN265_NUT_PREFIX_SEI = 39,
176 EN265_NUT_SUFFIX_SEI = 40
177 };
178
179
180 struct en265_packet
181 {
182 int version; // currently: 1
183
184 const uint8_t* data;
185 int length;
186
187 int frame_number;
188
189 enum en265_packet_content_type content_type;
190 char complete_picture : 1;
191 char final_slice : 1;
192 char dependent_slice : 1;
193
194 enum en265_nal_unit_type nal_unit_type;
195 unsigned char nuh_layer_id;
196 unsigned char nuh_temporal_id;
197
198 en265_encoder_context* encoder_context;
199
200 const struct de265_image* input_image;
201 const struct de265_image* reconstruction;
202 };
203
204 // timeout_ms - timeout in milliseconds. 0 - no timeout, -1 - block forever
205 LIBDE265_API struct en265_packet* en265_get_packet(en265_encoder_context*, int timeout_ms);
206 LIBDE265_API void en265_free_packet(en265_encoder_context*, struct en265_packet*);
207
208 LIBDE265_API int en265_number_of_queued_packets(en265_encoder_context*);
209
210 #ifdef __cplusplus
211 }
212 #endif
213
214
215 #endif
0 set (encoder_sources
1 analyze.cc analyze.h
2 encode.h encode.cc
3 encoder-params.h encoder-params.cc
4 encoder-context.h encoder-context.cc
5 encpicbuf.h encpicbuf.cc
6 sop.h sop.cc
7 )
8
9 add_library(encoder STATIC ${encoder_sources})
10
11 if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
12 SET_TARGET_PROPERTIES(encoder PROPERTIES COMPILE_FLAGS "-fPIC")
13 endif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
14
15 add_subdirectory (algo)
16
17 target_link_libraries(encoder algo)
0 noinst_LTLIBRARIES = libde265_encoder.la
1
2 libde265_encoder_la_CXXFLAGS = -I..
3 libde265_encoder_la_SOURCES = \
4 analyze.cc analyze.h \
5 encode.h encode.cc \
6 encoder-params.h encoder-params.cc \
7 encoder-context.h encoder-context.cc \
8 encpicbuf.h encpicbuf.cc \
9 sop.h sop.cc
10
11 SUBDIRS=algo
12 libde265_encoder_la_LIBADD = algo/libde265_encoder_algo.la
13
14 EXTRA_DIST = \
15 CMakeLists.txt
0 # Makefile.in generated by automake 1.14.1 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15
16 VPATH = @srcdir@
17 am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
18 am__make_running_with_option = \
19 case $${target_option-} in \
20 ?) ;; \
21 *) echo "am__make_running_with_option: internal error: invalid" \
22 "target option '$${target_option-}' specified" >&2; \
23 exit 1;; \
24 esac; \
25 has_opt=no; \
26 sane_makeflags=$$MAKEFLAGS; \
27 if $(am__is_gnu_make); then \
28 sane_makeflags=$$MFLAGS; \
29 else \
30 case $$MAKEFLAGS in \
31 *\\[\ \ ]*) \
32 bs=\\; \
33 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
34 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
35 esac; \
36 fi; \
37 skip_next=no; \
38 strip_trailopt () \
39 { \
40 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
41 }; \
42 for flg in $$sane_makeflags; do \
43 test $$skip_next = yes && { skip_next=no; continue; }; \
44 case $$flg in \
45 *=*|--*) continue;; \
46 -*I) strip_trailopt 'I'; skip_next=yes;; \
47 -*I?*) strip_trailopt 'I';; \
48 -*O) strip_trailopt 'O'; skip_next=yes;; \
49 -*O?*) strip_trailopt 'O';; \
50 -*l) strip_trailopt 'l'; skip_next=yes;; \
51 -*l?*) strip_trailopt 'l';; \
52 -[dEDm]) skip_next=yes;; \
53 -[JT]) skip_next=yes;; \
54 esac; \
55 case $$flg in \
56 *$$target_option*) has_opt=yes; break;; \
57 esac; \
58 done; \
59 test $$has_opt = yes
60 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
61 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
62 pkgdatadir = $(datadir)/@PACKAGE@
63 pkgincludedir = $(includedir)/@PACKAGE@
64 pkglibdir = $(libdir)/@PACKAGE@
65 pkglibexecdir = $(libexecdir)/@PACKAGE@
66 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
67 install_sh_DATA = $(install_sh) -c -m 644
68 install_sh_PROGRAM = $(install_sh) -c
69 install_sh_SCRIPT = $(install_sh) -c
70 INSTALL_HEADER = $(INSTALL_DATA)
71 transform = $(program_transform_name)
72 NORMAL_INSTALL = :
73 PRE_INSTALL = :
74 POST_INSTALL = :
75 NORMAL_UNINSTALL = :
76 PRE_UNINSTALL = :
77 POST_UNINSTALL = :
78 build_triplet = @build@
79 host_triplet = @host@
80 target_triplet = @target@
81 subdir = libde265/encoder
82 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
83 $(top_srcdir)/depcomp
84 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
85 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
86 $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \
87 $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
88 $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
89 $(top_srcdir)/m4/lt~obsolete.m4 \
90 $(top_srcdir)/m4/m4_ax_check_compile_flag.m4 \
91 $(top_srcdir)/configure.ac
92 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
93 $(ACLOCAL_M4)
94 mkinstalldirs = $(install_sh) -d
95 CONFIG_HEADER = $(top_builddir)/config.h
96 CONFIG_CLEAN_FILES =
97 CONFIG_CLEAN_VPATH_FILES =
98 LTLIBRARIES = $(noinst_LTLIBRARIES)
99 libde265_encoder_la_DEPENDENCIES = algo/libde265_encoder_algo.la
100 am_libde265_encoder_la_OBJECTS = libde265_encoder_la-analyze.lo \
101 libde265_encoder_la-encode.lo \
102 libde265_encoder_la-encoder-params.lo \
103 libde265_encoder_la-encoder-context.lo \
104 libde265_encoder_la-encpicbuf.lo libde265_encoder_la-sop.lo
105 libde265_encoder_la_OBJECTS = $(am_libde265_encoder_la_OBJECTS)
106 AM_V_lt = $(am__v_lt_@AM_V@)
107 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
108 am__v_lt_0 = --silent
109 am__v_lt_1 =
110 libde265_encoder_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
111 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
112 $(libde265_encoder_la_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
113 $(LDFLAGS) -o $@
114 AM_V_P = $(am__v_P_@AM_V@)
115 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
116 am__v_P_0 = false
117 am__v_P_1 = :
118 AM_V_GEN = $(am__v_GEN_@AM_V@)
119 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
120 am__v_GEN_0 = @echo " GEN " $@;
121 am__v_GEN_1 =
122 AM_V_at = $(am__v_at_@AM_V@)
123 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
124 am__v_at_0 = @
125 am__v_at_1 =
126 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
127 depcomp = $(SHELL) $(top_srcdir)/depcomp
128 am__depfiles_maybe = depfiles
129 am__mv = mv -f
130 CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
131 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
132 LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
133 $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
134 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
135 $(AM_CXXFLAGS) $(CXXFLAGS)
136 AM_V_CXX = $(am__v_CXX_@AM_V@)
137 am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
138 am__v_CXX_0 = @echo " CXX " $@;
139 am__v_CXX_1 =
140 CXXLD = $(CXX)
141 CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
142 $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
143 $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
144 AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
145 am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
146 am__v_CXXLD_0 = @echo " CXXLD " $@;
147 am__v_CXXLD_1 =
148 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
149 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
150 LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
151 $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
152 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
153 $(AM_CFLAGS) $(CFLAGS)
154 AM_V_CC = $(am__v_CC_@AM_V@)
155 am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
156 am__v_CC_0 = @echo " CC " $@;
157 am__v_CC_1 =
158 CCLD = $(CC)
159 LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
160 $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
161 $(AM_LDFLAGS) $(LDFLAGS) -o $@
162 AM_V_CCLD = $(am__v_CCLD_@AM_V@)
163 am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
164 am__v_CCLD_0 = @echo " CCLD " $@;
165 am__v_CCLD_1 =
166 SOURCES = $(libde265_encoder_la_SOURCES)
167 DIST_SOURCES = $(libde265_encoder_la_SOURCES)
168 RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
169 ctags-recursive dvi-recursive html-recursive info-recursive \
170 install-data-recursive install-dvi-recursive \
171 install-exec-recursive install-html-recursive \
172 install-info-recursive install-pdf-recursive \
173 install-ps-recursive install-recursive installcheck-recursive \
174 installdirs-recursive pdf-recursive ps-recursive \
175 tags-recursive uninstall-recursive
176 am__can_run_installinfo = \
177 case $$AM_UPDATE_INFO_DIR in \
178 n|no|NO) false;; \
179 *) (install-info --version) >/dev/null 2>&1;; \
180 esac
181 RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
182 distclean-recursive maintainer-clean-recursive
183 am__recursive_targets = \
184 $(RECURSIVE_TARGETS) \
185 $(RECURSIVE_CLEAN_TARGETS) \
186 $(am__extra_recursive_targets)
187 AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
188 distdir
189 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
190 # Read a list of newline-separated strings from the standard input,
191 # and print each of them once, without duplicates. Input order is
192 # *not* preserved.
193 am__uniquify_input = $(AWK) '\
194 BEGIN { nonempty = 0; } \
195 { items[$$0] = 1; nonempty = 1; } \
196 END { if (nonempty) { for (i in items) print i; }; } \
197 '
198 # Make sure the list of sources is unique. This is necessary because,
199 # e.g., the same source file might be shared among _SOURCES variables
200 # for different programs/libraries.
201 am__define_uniq_tagged_files = \
202 list='$(am__tagged_files)'; \
203 unique=`for i in $$list; do \
204 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
205 done | $(am__uniquify_input)`
206 ETAGS = etags
207 CTAGS = ctags
208 DIST_SUBDIRS = $(SUBDIRS)
209 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
210 am__relativize = \
211 dir0=`pwd`; \
212 sed_first='s,^\([^/]*\)/.*$$,\1,'; \
213 sed_rest='s,^[^/]*/*,,'; \
214 sed_last='s,^.*/\([^/]*\)$$,\1,'; \
215 sed_butlast='s,/*[^/]*$$,,'; \
216 while test -n "$$dir1"; do \
217 first=`echo "$$dir1" | sed -e "$$sed_first"`; \
218 if test "$$first" != "."; then \
219 if test "$$first" = ".."; then \
220 dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
221 dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
222 else \
223 first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
224 if test "$$first2" = "$$first"; then \
225 dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
226 else \
227 dir2="../$$dir2"; \
228 fi; \
229 dir0="$$dir0"/"$$first"; \
230 fi; \
231 fi; \
232 dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
233 done; \
234 reldir="$$dir2"
235 ACLOCAL = @ACLOCAL@
236 ALLOCA = @ALLOCA@
237 AMTAR = @AMTAR@
238 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
239 AR = @AR@
240 AUTOCONF = @AUTOCONF@
241 AUTOHEADER = @AUTOHEADER@
242 AUTOMAKE = @AUTOMAKE@
243 AWK = @AWK@
244 CC = @CC@
245 CCAS = @CCAS@
246 CCASDEPMODE = @CCASDEPMODE@
247 CCASFLAGS = @CCASFLAGS@
248 CCDEPMODE = @CCDEPMODE@
249 CFLAGS = @CFLAGS@
250 CPP = @CPP@
251 CPPFLAGS = @CPPFLAGS@
252 CXX = @CXX@
253 CXXCPP = @CXXCPP@
254 CXXDEPMODE = @CXXDEPMODE@
255 CXXFLAGS = @CXXFLAGS@
256 CYGPATH_W = @CYGPATH_W@
257 DEFS = @DEFS@
258 DEPDIR = @DEPDIR@
259 DLLTOOL = @DLLTOOL@
260 DSYMUTIL = @DSYMUTIL@
261 DUMPBIN = @DUMPBIN@
262 ECHO_C = @ECHO_C@
263 ECHO_N = @ECHO_N@
264 ECHO_T = @ECHO_T@
265 EGREP = @EGREP@
266 EXEEXT = @EXEEXT@
267 FGREP = @FGREP@
268 GREP = @GREP@
269 HAVE_CXX11 = @HAVE_CXX11@
270 INSTALL = @INSTALL@
271 INSTALL_DATA = @INSTALL_DATA@
272 INSTALL_PROGRAM = @INSTALL_PROGRAM@
273 INSTALL_SCRIPT = @INSTALL_SCRIPT@
274 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
275 LD = @LD@
276 LDFLAGS = @LDFLAGS@
277 LIBDE265_AGE = @LIBDE265_AGE@
278 LIBDE265_CURRENT = @LIBDE265_CURRENT@
279 LIBDE265_REVISION = @LIBDE265_REVISION@
280 LIBOBJS = @LIBOBJS@
281 LIBS = @LIBS@
282 LIBTOOL = @LIBTOOL@
283 LIPO = @LIPO@
284 LN_S = @LN_S@
285 LTLIBOBJS = @LTLIBOBJS@
286 MAKEINFO = @MAKEINFO@
287 MANIFEST_TOOL = @MANIFEST_TOOL@
288 MKDIR_P = @MKDIR_P@
289 NM = @NM@
290 NMEDIT = @NMEDIT@
291 NUMERIC_VERSION = @NUMERIC_VERSION@
292 OBJDUMP = @OBJDUMP@
293 OBJEXT = @OBJEXT@
294 OTOOL = @OTOOL@
295 OTOOL64 = @OTOOL64@
296 PACKAGE = @PACKAGE@
297 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
298 PACKAGE_NAME = @PACKAGE_NAME@
299 PACKAGE_STRING = @PACKAGE_STRING@
300 PACKAGE_TARNAME = @PACKAGE_TARNAME@
301 PACKAGE_URL = @PACKAGE_URL@
302 PACKAGE_VERSION = @PACKAGE_VERSION@
303 PATH_SEPARATOR = @PATH_SEPARATOR@
304 PKG_CONFIG = @PKG_CONFIG@
305 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
306 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
307 QTCHOOSER = @QTCHOOSER@
308 QTMOC = @QTMOC@
309 QT_CFLAGS = @QT_CFLAGS@
310 QT_LIBS = @QT_LIBS@
311 RANLIB = @RANLIB@
312 SDL_CFLAGS = @SDL_CFLAGS@
313 SDL_LIBS = @SDL_LIBS@
314 SED = @SED@
315 SET_MAKE = @SET_MAKE@
316 SHELL = @SHELL@
317 STRIP = @STRIP@
318 SWSCALE_CFLAGS = @SWSCALE_CFLAGS@
319 SWSCALE_LIBS = @SWSCALE_LIBS@
320 VERSION = @VERSION@
321 VIDEOGFX_CFLAGS = @VIDEOGFX_CFLAGS@
322 VIDEOGFX_LIBS = @VIDEOGFX_LIBS@
323 abs_builddir = @abs_builddir@
324 abs_srcdir = @abs_srcdir@
325 abs_top_builddir = @abs_top_builddir@
326 abs_top_srcdir = @abs_top_srcdir@
327 ac_ct_AR = @ac_ct_AR@
328 ac_ct_CC = @ac_ct_CC@
329 ac_ct_CXX = @ac_ct_CXX@
330 ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
331 am__include = @am__include@
332 am__leading_dot = @am__leading_dot@
333 am__quote = @am__quote@
334 am__tar = @am__tar@
335 am__untar = @am__untar@
336 bindir = @bindir@
337 build = @build@
338 build_alias = @build_alias@
339 build_cpu = @build_cpu@
340 build_os = @build_os@
341 build_vendor = @build_vendor@
342 builddir = @builddir@
343 datadir = @datadir@
344 datarootdir = @datarootdir@
345 docdir = @docdir@
346 dvidir = @dvidir@
347 exec_prefix = @exec_prefix@
348 host = @host@
349 host_alias = @host_alias@
350 host_cpu = @host_cpu@
351 host_os = @host_os@
352 host_vendor = @host_vendor@
353 htmldir = @htmldir@
354 includedir = @includedir@
355 infodir = @infodir@
356 install_sh = @install_sh@
357 libdir = @libdir@
358 libexecdir = @libexecdir@
359 localedir = @localedir@
360 localstatedir = @localstatedir@
361 mandir = @mandir@
362 mkdir_p = @mkdir_p@
363 oldincludedir = @oldincludedir@
364 pdfdir = @pdfdir@
365 prefix = @prefix@
366 program_transform_name = @program_transform_name@
367 psdir = @psdir@
368 sbindir = @sbindir@
369 sharedstatedir = @sharedstatedir@
370 srcdir = @srcdir@
371 sysconfdir = @sysconfdir@
372 target = @target@
373 target_alias = @target_alias@
374 target_cpu = @target_cpu@
375 target_os = @target_os@
376 target_vendor = @target_vendor@
377 top_build_prefix = @top_build_prefix@
378 top_builddir = @top_builddir@
379 top_srcdir = @top_srcdir@
380 noinst_LTLIBRARIES = libde265_encoder.la
381 libde265_encoder_la_CXXFLAGS = -I..
382 libde265_encoder_la_SOURCES = \
383 analyze.cc analyze.h \
384 encode.h encode.cc \
385 encoder-params.h encoder-params.cc \
386 encoder-context.h encoder-context.cc \
387 encpicbuf.h encpicbuf.cc \
388 sop.h sop.cc
389
390 SUBDIRS = algo
391 libde265_encoder_la_LIBADD = algo/libde265_encoder_algo.la
392 EXTRA_DIST = \
393 CMakeLists.txt
394
395 all: all-recursive
396
397 .SUFFIXES:
398 .SUFFIXES: .cc .lo .o .obj
399 $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
400 @for dep in $?; do \
401 case '$(am__configure_deps)' in \
402 *$$dep*) \
403 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
404 && { if test -f $@; then exit 0; else break; fi; }; \
405 exit 1;; \
406 esac; \
407 done; \
408 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libde265/encoder/Makefile'; \
409 $(am__cd) $(top_srcdir) && \
410 $(AUTOMAKE) --gnu libde265/encoder/Makefile
411 .PRECIOUS: Makefile
412 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
413 @case '$?' in \
414 *config.status*) \
415 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
416 *) \
417 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
418 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
419 esac;
420
421 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
422 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
423
424 $(top_srcdir)/configure: $(am__configure_deps)
425 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
426 $(ACLOCAL_M4): $(am__aclocal_m4_deps)
427 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
428 $(am__aclocal_m4_deps):
429
430 clean-noinstLTLIBRARIES:
431 -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
432 @list='$(noinst_LTLIBRARIES)'; \
433 locs=`for p in $$list; do echo $$p; done | \
434 sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
435 sort -u`; \
436 test -z "$$locs" || { \
437 echo rm -f $${locs}; \
438 rm -f $${locs}; \
439 }
440
441 libde265_encoder.la: $(libde265_encoder_la_OBJECTS) $(libde265_encoder_la_DEPENDENCIES) $(EXTRA_libde265_encoder_la_DEPENDENCIES)
442 $(AM_V_CXXLD)$(libde265_encoder_la_LINK) $(libde265_encoder_la_OBJECTS) $(libde265_encoder_la_LIBADD) $(LIBS)
443
444 mostlyclean-compile:
445 -rm -f *.$(OBJEXT)
446
447 distclean-compile:
448 -rm -f *.tab.c
449
450 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_encoder_la-analyze.Plo@am__quote@
451 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_encoder_la-encode.Plo@am__quote@
452 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_encoder_la-encoder-context.Plo@am__quote@
453 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_encoder_la-encoder-params.Plo@am__quote@
454 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_encoder_la-encpicbuf.Plo@am__quote@
455 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_encoder_la-sop.Plo@am__quote@
456
457 .cc.o:
458 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
459 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
460 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
461 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
462 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<
463
464 .cc.obj:
465 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
466 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
467 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
468 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
469 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
470
471 .cc.lo:
472 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
473 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
474 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
475 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
476 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
477
478 libde265_encoder_la-analyze.lo: analyze.cc
479 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_encoder_la-analyze.lo -MD -MP -MF $(DEPDIR)/libde265_encoder_la-analyze.Tpo -c -o libde265_encoder_la-analyze.lo `test -f 'analyze.cc' || echo '$(srcdir)/'`analyze.cc
480 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_encoder_la-analyze.Tpo $(DEPDIR)/libde265_encoder_la-analyze.Plo
481 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='analyze.cc' object='libde265_encoder_la-analyze.lo' libtool=yes @AMDEPBACKSLASH@
482 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
483 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_encoder_la-analyze.lo `test -f 'analyze.cc' || echo '$(srcdir)/'`analyze.cc
484
485 libde265_encoder_la-encode.lo: encode.cc
486 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_encoder_la-encode.lo -MD -MP -MF $(DEPDIR)/libde265_encoder_la-encode.Tpo -c -o libde265_encoder_la-encode.lo `test -f 'encode.cc' || echo '$(srcdir)/'`encode.cc
487 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_encoder_la-encode.Tpo $(DEPDIR)/libde265_encoder_la-encode.Plo
488 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='encode.cc' object='libde265_encoder_la-encode.lo' libtool=yes @AMDEPBACKSLASH@
489 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
490 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_encoder_la-encode.lo `test -f 'encode.cc' || echo '$(srcdir)/'`encode.cc
491
492 libde265_encoder_la-encoder-params.lo: encoder-params.cc
493 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_encoder_la-encoder-params.lo -MD -MP -MF $(DEPDIR)/libde265_encoder_la-encoder-params.Tpo -c -o libde265_encoder_la-encoder-params.lo `test -f 'encoder-params.cc' || echo '$(srcdir)/'`encoder-params.cc
494 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_encoder_la-encoder-params.Tpo $(DEPDIR)/libde265_encoder_la-encoder-params.Plo
495 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='encoder-params.cc' object='libde265_encoder_la-encoder-params.lo' libtool=yes @AMDEPBACKSLASH@
496 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
497 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_encoder_la-encoder-params.lo `test -f 'encoder-params.cc' || echo '$(srcdir)/'`encoder-params.cc
498
499 libde265_encoder_la-encoder-context.lo: encoder-context.cc
500 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_encoder_la-encoder-context.lo -MD -MP -MF $(DEPDIR)/libde265_encoder_la-encoder-context.Tpo -c -o libde265_encoder_la-encoder-context.lo `test -f 'encoder-context.cc' || echo '$(srcdir)/'`encoder-context.cc
501 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_encoder_la-encoder-context.Tpo $(DEPDIR)/libde265_encoder_la-encoder-context.Plo
502 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='encoder-context.cc' object='libde265_encoder_la-encoder-context.lo' libtool=yes @AMDEPBACKSLASH@
503 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
504 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_encoder_la-encoder-context.lo `test -f 'encoder-context.cc' || echo '$(srcdir)/'`encoder-context.cc
505
506 libde265_encoder_la-encpicbuf.lo: encpicbuf.cc
507 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_encoder_la-encpicbuf.lo -MD -MP -MF $(DEPDIR)/libde265_encoder_la-encpicbuf.Tpo -c -o libde265_encoder_la-encpicbuf.lo `test -f 'encpicbuf.cc' || echo '$(srcdir)/'`encpicbuf.cc
508 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_encoder_la-encpicbuf.Tpo $(DEPDIR)/libde265_encoder_la-encpicbuf.Plo
509 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='encpicbuf.cc' object='libde265_encoder_la-encpicbuf.lo' libtool=yes @AMDEPBACKSLASH@
510 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
511 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_encoder_la-encpicbuf.lo `test -f 'encpicbuf.cc' || echo '$(srcdir)/'`encpicbuf.cc
512
513 libde265_encoder_la-sop.lo: sop.cc
514 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_encoder_la-sop.lo -MD -MP -MF $(DEPDIR)/libde265_encoder_la-sop.Tpo -c -o libde265_encoder_la-sop.lo `test -f 'sop.cc' || echo '$(srcdir)/'`sop.cc
515 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_encoder_la-sop.Tpo $(DEPDIR)/libde265_encoder_la-sop.Plo
516 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='sop.cc' object='libde265_encoder_la-sop.lo' libtool=yes @AMDEPBACKSLASH@
517 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
518 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_encoder_la-sop.lo `test -f 'sop.cc' || echo '$(srcdir)/'`sop.cc
519
520 mostlyclean-libtool:
521 -rm -f *.lo
522
523 clean-libtool:
524 -rm -rf .libs _libs
525
526 # This directory's subdirectories are mostly independent; you can cd
527 # into them and run 'make' without going through this Makefile.
528 # To change the values of 'make' variables: instead of editing Makefiles,
529 # (1) if the variable is set in 'config.status', edit 'config.status'
530 # (which will cause the Makefiles to be regenerated when you run 'make');
531 # (2) otherwise, pass the desired values on the 'make' command line.
532 $(am__recursive_targets):
533 @fail=; \
534 if $(am__make_keepgoing); then \
535 failcom='fail=yes'; \
536 else \
537 failcom='exit 1'; \
538 fi; \
539 dot_seen=no; \
540 target=`echo $@ | sed s/-recursive//`; \
541 case "$@" in \
542 distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
543 *) list='$(SUBDIRS)' ;; \
544 esac; \
545 for subdir in $$list; do \
546 echo "Making $$target in $$subdir"; \
547 if test "$$subdir" = "."; then \
548 dot_seen=yes; \
549 local_target="$$target-am"; \
550 else \
551 local_target="$$target"; \
552 fi; \
553 ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
554 || eval $$failcom; \
555 done; \
556 if test "$$dot_seen" = "no"; then \
557 $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
558 fi; test -z "$$fail"
559
560 ID: $(am__tagged_files)
561 $(am__define_uniq_tagged_files); mkid -fID $$unique
562 tags: tags-recursive
563 TAGS: tags
564
565 tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
566 set x; \
567 here=`pwd`; \
568 if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
569 include_option=--etags-include; \
570 empty_fix=.; \
571 else \
572 include_option=--include; \
573 empty_fix=; \
574 fi; \
575 list='$(SUBDIRS)'; for subdir in $$list; do \
576 if test "$$subdir" = .; then :; else \
577 test ! -f $$subdir/TAGS || \
578 set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
579 fi; \
580 done; \
581 $(am__define_uniq_tagged_files); \
582 shift; \
583 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
584 test -n "$$unique" || unique=$$empty_fix; \
585 if test $$# -gt 0; then \
586 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
587 "$$@" $$unique; \
588 else \
589 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
590 $$unique; \
591 fi; \
592 fi
593 ctags: ctags-recursive
594
595 CTAGS: ctags
596 ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
597 $(am__define_uniq_tagged_files); \
598 test -z "$(CTAGS_ARGS)$$unique" \
599 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
600 $$unique
601
602 GTAGS:
603 here=`$(am__cd) $(top_builddir) && pwd` \
604 && $(am__cd) $(top_srcdir) \
605 && gtags -i $(GTAGS_ARGS) "$$here"
606 cscopelist: cscopelist-recursive
607
608 cscopelist-am: $(am__tagged_files)
609 list='$(am__tagged_files)'; \
610 case "$(srcdir)" in \
611 [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
612 *) sdir=$(subdir)/$(srcdir) ;; \
613 esac; \
614 for i in $$list; do \
615 if test -f "$$i"; then \
616 echo "$(subdir)/$$i"; \
617 else \
618 echo "$$sdir/$$i"; \
619 fi; \
620 done >> $(top_builddir)/cscope.files
621
622 distclean-tags:
623 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
624
625 distdir: $(DISTFILES)
626 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
627 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
628 list='$(DISTFILES)'; \
629 dist_files=`for file in $$list; do echo $$file; done | \
630 sed -e "s|^$$srcdirstrip/||;t" \
631 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
632 case $$dist_files in \
633 */*) $(MKDIR_P) `echo "$$dist_files" | \
634 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
635 sort -u` ;; \
636 esac; \
637 for file in $$dist_files; do \
638 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
639 if test -d $$d/$$file; then \
640 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
641 if test -d "$(distdir)/$$file"; then \
642 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
643 fi; \
644 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
645 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
646 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
647 fi; \
648 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
649 else \
650 test -f "$(distdir)/$$file" \
651 || cp -p $$d/$$file "$(distdir)/$$file" \
652 || exit 1; \
653 fi; \
654 done
655 @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
656 if test "$$subdir" = .; then :; else \
657 $(am__make_dryrun) \
658 || test -d "$(distdir)/$$subdir" \
659 || $(MKDIR_P) "$(distdir)/$$subdir" \
660 || exit 1; \
661 dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
662 $(am__relativize); \
663 new_distdir=$$reldir; \
664 dir1=$$subdir; dir2="$(top_distdir)"; \
665 $(am__relativize); \
666 new_top_distdir=$$reldir; \
667 echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
668 echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
669 ($(am__cd) $$subdir && \
670 $(MAKE) $(AM_MAKEFLAGS) \
671 top_distdir="$$new_top_distdir" \
672 distdir="$$new_distdir" \
673 am__remove_distdir=: \
674 am__skip_length_check=: \
675 am__skip_mode_fix=: \
676 distdir) \
677 || exit 1; \
678 fi; \
679 done
680 check-am: all-am
681 check: check-recursive
682 all-am: Makefile $(LTLIBRARIES)
683 installdirs: installdirs-recursive
684 installdirs-am:
685 install: install-recursive
686 install-exec: install-exec-recursive
687 install-data: install-data-recursive
688 uninstall: uninstall-recursive
689
690 install-am: all-am
691 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
692
693 installcheck: installcheck-recursive
694 install-strip:
695 if test -z '$(STRIP)'; then \
696 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
697 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
698 install; \
699 else \
700 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
701 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
702 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
703 fi
704 mostlyclean-generic:
705
706 clean-generic:
707
708 distclean-generic:
709 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
710 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
711
712 maintainer-clean-generic:
713 @echo "This command is intended for maintainers to use"
714 @echo "it deletes files that may require special tools to rebuild."
715 clean: clean-recursive
716
717 clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
718 mostlyclean-am
719
720 distclean: distclean-recursive
721 -rm -rf ./$(DEPDIR)
722 -rm -f Makefile
723 distclean-am: clean-am distclean-compile distclean-generic \
724 distclean-tags
725
726 dvi: dvi-recursive
727
728 dvi-am:
729
730 html: html-recursive
731
732 html-am:
733
734 info: info-recursive
735
736 info-am:
737
738 install-data-am:
739
740 install-dvi: install-dvi-recursive
741
742 install-dvi-am:
743
744 install-exec-am:
745
746 install-html: install-html-recursive
747
748 install-html-am:
749
750 install-info: install-info-recursive
751
752 install-info-am:
753
754 install-man:
755
756 install-pdf: install-pdf-recursive
757
758 install-pdf-am:
759
760 install-ps: install-ps-recursive
761
762 install-ps-am:
763
764 installcheck-am:
765
766 maintainer-clean: maintainer-clean-recursive
767 -rm -rf ./$(DEPDIR)
768 -rm -f Makefile
769 maintainer-clean-am: distclean-am maintainer-clean-generic
770
771 mostlyclean: mostlyclean-recursive
772
773 mostlyclean-am: mostlyclean-compile mostlyclean-generic \
774 mostlyclean-libtool
775
776 pdf: pdf-recursive
777
778 pdf-am:
779
780 ps: ps-recursive
781
782 ps-am:
783
784 uninstall-am:
785
786 .MAKE: $(am__recursive_targets) install-am install-strip
787
788 .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \
789 check-am clean clean-generic clean-libtool \
790 clean-noinstLTLIBRARIES cscopelist-am ctags ctags-am distclean \
791 distclean-compile distclean-generic distclean-libtool \
792 distclean-tags distdir dvi dvi-am html html-am info info-am \
793 install install-am install-data install-data-am install-dvi \
794 install-dvi-am install-exec install-exec-am install-html \
795 install-html-am install-info install-info-am install-man \
796 install-pdf install-pdf-am install-ps install-ps-am \
797 install-strip installcheck installcheck-am installdirs \
798 installdirs-am maintainer-clean maintainer-clean-generic \
799 mostlyclean mostlyclean-compile mostlyclean-generic \
800 mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
801 uninstall-am
802
803
804 # Tell versions [3.59,3.63) of GNU make to not export all variables.
805 # Otherwise a system limit (for SysV at least) may be exceeded.
806 .NOEXPORT:
0 set (algo_sources
1 algo.h algo.cc
2 coding-options.h coding-options.cc
3 ctb-qscale.h ctb-qscale.cc
4 cb-split.h cb-split.cc
5 cb-intrapartmode.h cb-intrapartmode.cc
6 cb-interpartmode.h cb-interpartmode.cc
7 cb-skip.h cb-skip.cc
8 cb-intra-inter.h cb-intra-inter.cc
9 cb-mergeindex.h cb-mergeindex.cc
10 tb-split.h tb-split.cc
11 tb-intrapredmode.h tb-intrapredmode.cc
12 pb-mv.h pb-mv.cc
13 )
14
15 add_library(algo STATIC ${algo_sources})
16
17 if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
18 SET_TARGET_PROPERTIES(algo PROPERTIES COMPILE_FLAGS "-fPIC")
19 endif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
0 noinst_LTLIBRARIES = libde265_encoder_algo.la
1
2 libde265_encoder_algo_la_CXXFLAGS = -I../..
3 libde265_encoder_algo_la_SOURCES = \
4 algo.h algo.cc \
5 coding-options.h coding-options.cc \
6 ctb-qscale.h ctb-qscale.cc \
7 cb-split.h cb-split.cc \
8 cb-intrapartmode.h cb-intrapartmode.cc \
9 cb-interpartmode.h cb-interpartmode.cc \
10 cb-skip.h cb-skip.cc \
11 cb-intra-inter.h cb-intra-inter.cc \
12 cb-mergeindex.h cb-mergeindex.cc \
13 tb-split.h tb-split.cc \
14 tb-intrapredmode.h tb-intrapredmode.cc \
15 pb-mv.h pb-mv.cc
16
17 EXTRA_DIST = \
18 CMakeLists.txt
0 # Makefile.in generated by automake 1.14.1 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15
16 VPATH = @srcdir@
17 am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
18 am__make_running_with_option = \
19 case $${target_option-} in \
20 ?) ;; \
21 *) echo "am__make_running_with_option: internal error: invalid" \
22 "target option '$${target_option-}' specified" >&2; \
23 exit 1;; \
24 esac; \
25 has_opt=no; \
26 sane_makeflags=$$MAKEFLAGS; \
27 if $(am__is_gnu_make); then \
28 sane_makeflags=$$MFLAGS; \
29 else \
30 case $$MAKEFLAGS in \
31 *\\[\ \ ]*) \
32 bs=\\; \
33 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
34 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
35 esac; \
36 fi; \
37 skip_next=no; \
38 strip_trailopt () \
39 { \
40 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
41 }; \
42 for flg in $$sane_makeflags; do \
43 test $$skip_next = yes && { skip_next=no; continue; }; \
44 case $$flg in \
45 *=*|--*) continue;; \
46 -*I) strip_trailopt 'I'; skip_next=yes;; \
47 -*I?*) strip_trailopt 'I';; \
48 -*O) strip_trailopt 'O'; skip_next=yes;; \
49 -*O?*) strip_trailopt 'O';; \
50 -*l) strip_trailopt 'l'; skip_next=yes;; \
51 -*l?*) strip_trailopt 'l';; \
52 -[dEDm]) skip_next=yes;; \
53 -[JT]) skip_next=yes;; \
54 esac; \
55 case $$flg in \
56 *$$target_option*) has_opt=yes; break;; \
57 esac; \
58 done; \
59 test $$has_opt = yes
60 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
61 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
62 pkgdatadir = $(datadir)/@PACKAGE@
63 pkgincludedir = $(includedir)/@PACKAGE@
64 pkglibdir = $(libdir)/@PACKAGE@
65 pkglibexecdir = $(libexecdir)/@PACKAGE@
66 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
67 install_sh_DATA = $(install_sh) -c -m 644
68 install_sh_PROGRAM = $(install_sh) -c
69 install_sh_SCRIPT = $(install_sh) -c
70 INSTALL_HEADER = $(INSTALL_DATA)
71 transform = $(program_transform_name)
72 NORMAL_INSTALL = :
73 PRE_INSTALL = :
74 POST_INSTALL = :
75 NORMAL_UNINSTALL = :
76 PRE_UNINSTALL = :
77 POST_UNINSTALL = :
78 build_triplet = @build@
79 host_triplet = @host@
80 target_triplet = @target@
81 subdir = libde265/encoder/algo
82 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
83 $(top_srcdir)/depcomp
84 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
85 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
86 $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \
87 $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
88 $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
89 $(top_srcdir)/m4/lt~obsolete.m4 \
90 $(top_srcdir)/m4/m4_ax_check_compile_flag.m4 \
91 $(top_srcdir)/configure.ac
92 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
93 $(ACLOCAL_M4)
94 mkinstalldirs = $(install_sh) -d
95 CONFIG_HEADER = $(top_builddir)/config.h
96 CONFIG_CLEAN_FILES =
97 CONFIG_CLEAN_VPATH_FILES =
98 LTLIBRARIES = $(noinst_LTLIBRARIES)
99 libde265_encoder_algo_la_LIBADD =
100 am_libde265_encoder_algo_la_OBJECTS = \
101 libde265_encoder_algo_la-algo.lo \
102 libde265_encoder_algo_la-coding-options.lo \
103 libde265_encoder_algo_la-ctb-qscale.lo \
104 libde265_encoder_algo_la-cb-split.lo \
105 libde265_encoder_algo_la-cb-intrapartmode.lo \
106 libde265_encoder_algo_la-cb-interpartmode.lo \
107 libde265_encoder_algo_la-cb-skip.lo \
108 libde265_encoder_algo_la-cb-intra-inter.lo \
109 libde265_encoder_algo_la-cb-mergeindex.lo \
110 libde265_encoder_algo_la-tb-split.lo \
111 libde265_encoder_algo_la-tb-intrapredmode.lo \
112 libde265_encoder_algo_la-pb-mv.lo
113 libde265_encoder_algo_la_OBJECTS = \
114 $(am_libde265_encoder_algo_la_OBJECTS)
115 AM_V_lt = $(am__v_lt_@AM_V@)
116 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
117 am__v_lt_0 = --silent
118 am__v_lt_1 =
119 libde265_encoder_algo_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
120 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
121 $(libde265_encoder_algo_la_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
122 $(LDFLAGS) -o $@
123 AM_V_P = $(am__v_P_@AM_V@)
124 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
125 am__v_P_0 = false
126 am__v_P_1 = :
127 AM_V_GEN = $(am__v_GEN_@AM_V@)
128 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
129 am__v_GEN_0 = @echo " GEN " $@;
130 am__v_GEN_1 =
131 AM_V_at = $(am__v_at_@AM_V@)
132 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
133 am__v_at_0 = @
134 am__v_at_1 =
135 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
136 depcomp = $(SHELL) $(top_srcdir)/depcomp
137 am__depfiles_maybe = depfiles
138 am__mv = mv -f
139 CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
140 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
141 LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
142 $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
143 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
144 $(AM_CXXFLAGS) $(CXXFLAGS)
145 AM_V_CXX = $(am__v_CXX_@AM_V@)
146 am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
147 am__v_CXX_0 = @echo " CXX " $@;
148 am__v_CXX_1 =
149 CXXLD = $(CXX)
150 CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
151 $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
152 $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
153 AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
154 am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
155 am__v_CXXLD_0 = @echo " CXXLD " $@;
156 am__v_CXXLD_1 =
157 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
158 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
159 LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
160 $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
161 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
162 $(AM_CFLAGS) $(CFLAGS)
163 AM_V_CC = $(am__v_CC_@AM_V@)
164 am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
165 am__v_CC_0 = @echo " CC " $@;
166 am__v_CC_1 =
167 CCLD = $(CC)
168 LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
169 $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
170 $(AM_LDFLAGS) $(LDFLAGS) -o $@
171 AM_V_CCLD = $(am__v_CCLD_@AM_V@)
172 am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
173 am__v_CCLD_0 = @echo " CCLD " $@;
174 am__v_CCLD_1 =
175 SOURCES = $(libde265_encoder_algo_la_SOURCES)
176 DIST_SOURCES = $(libde265_encoder_algo_la_SOURCES)
177 am__can_run_installinfo = \
178 case $$AM_UPDATE_INFO_DIR in \
179 n|no|NO) false;; \
180 *) (install-info --version) >/dev/null 2>&1;; \
181 esac
182 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
183 # Read a list of newline-separated strings from the standard input,
184 # and print each of them once, without duplicates. Input order is
185 # *not* preserved.
186 am__uniquify_input = $(AWK) '\
187 BEGIN { nonempty = 0; } \
188 { items[$$0] = 1; nonempty = 1; } \
189 END { if (nonempty) { for (i in items) print i; }; } \
190 '
191 # Make sure the list of sources is unique. This is necessary because,
192 # e.g., the same source file might be shared among _SOURCES variables
193 # for different programs/libraries.
194 am__define_uniq_tagged_files = \
195 list='$(am__tagged_files)'; \
196 unique=`for i in $$list; do \
197 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
198 done | $(am__uniquify_input)`
199 ETAGS = etags
200 CTAGS = ctags
201 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
202 ACLOCAL = @ACLOCAL@
203 ALLOCA = @ALLOCA@
204 AMTAR = @AMTAR@
205 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
206 AR = @AR@
207 AUTOCONF = @AUTOCONF@
208 AUTOHEADER = @AUTOHEADER@
209 AUTOMAKE = @AUTOMAKE@
210 AWK = @AWK@
211 CC = @CC@
212 CCAS = @CCAS@
213 CCASDEPMODE = @CCASDEPMODE@
214 CCASFLAGS = @CCASFLAGS@
215 CCDEPMODE = @CCDEPMODE@
216 CFLAGS = @CFLAGS@
217 CPP = @CPP@
218 CPPFLAGS = @CPPFLAGS@
219 CXX = @CXX@
220 CXXCPP = @CXXCPP@
221 CXXDEPMODE = @CXXDEPMODE@
222 CXXFLAGS = @CXXFLAGS@
223 CYGPATH_W = @CYGPATH_W@
224 DEFS = @DEFS@
225 DEPDIR = @DEPDIR@
226 DLLTOOL = @DLLTOOL@
227 DSYMUTIL = @DSYMUTIL@
228 DUMPBIN = @DUMPBIN@
229 ECHO_C = @ECHO_C@
230 ECHO_N = @ECHO_N@
231 ECHO_T = @ECHO_T@
232 EGREP = @EGREP@
233 EXEEXT = @EXEEXT@
234 FGREP = @FGREP@
235 GREP = @GREP@
236 HAVE_CXX11 = @HAVE_CXX11@
237 INSTALL = @INSTALL@
238 INSTALL_DATA = @INSTALL_DATA@
239 INSTALL_PROGRAM = @INSTALL_PROGRAM@
240 INSTALL_SCRIPT = @INSTALL_SCRIPT@
241 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
242 LD = @LD@
243 LDFLAGS = @LDFLAGS@
244 LIBDE265_AGE = @LIBDE265_AGE@
245 LIBDE265_CURRENT = @LIBDE265_CURRENT@
246 LIBDE265_REVISION = @LIBDE265_REVISION@
247 LIBOBJS = @LIBOBJS@
248 LIBS = @LIBS@
249 LIBTOOL = @LIBTOOL@
250 LIPO = @LIPO@
251 LN_S = @LN_S@
252 LTLIBOBJS = @LTLIBOBJS@
253 MAKEINFO = @MAKEINFO@
254 MANIFEST_TOOL = @MANIFEST_TOOL@
255 MKDIR_P = @MKDIR_P@
256 NM = @NM@
257 NMEDIT = @NMEDIT@
258 NUMERIC_VERSION = @NUMERIC_VERSION@
259 OBJDUMP = @OBJDUMP@
260 OBJEXT = @OBJEXT@
261 OTOOL = @OTOOL@
262 OTOOL64 = @OTOOL64@
263 PACKAGE = @PACKAGE@
264 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
265 PACKAGE_NAME = @PACKAGE_NAME@
266 PACKAGE_STRING = @PACKAGE_STRING@
267 PACKAGE_TARNAME = @PACKAGE_TARNAME@
268 PACKAGE_URL = @PACKAGE_URL@
269 PACKAGE_VERSION = @PACKAGE_VERSION@
270 PATH_SEPARATOR = @PATH_SEPARATOR@
271 PKG_CONFIG = @PKG_CONFIG@
272 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
273 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
274 QTCHOOSER = @QTCHOOSER@
275 QTMOC = @QTMOC@
276 QT_CFLAGS = @QT_CFLAGS@
277 QT_LIBS = @QT_LIBS@
278 RANLIB = @RANLIB@
279 SDL_CFLAGS = @SDL_CFLAGS@
280 SDL_LIBS = @SDL_LIBS@
281 SED = @SED@
282 SET_MAKE = @SET_MAKE@
283 SHELL = @SHELL@
284 STRIP = @STRIP@
285 SWSCALE_CFLAGS = @SWSCALE_CFLAGS@
286 SWSCALE_LIBS = @SWSCALE_LIBS@
287 VERSION = @VERSION@
288 VIDEOGFX_CFLAGS = @VIDEOGFX_CFLAGS@
289 VIDEOGFX_LIBS = @VIDEOGFX_LIBS@
290 abs_builddir = @abs_builddir@
291 abs_srcdir = @abs_srcdir@
292 abs_top_builddir = @abs_top_builddir@
293 abs_top_srcdir = @abs_top_srcdir@
294 ac_ct_AR = @ac_ct_AR@
295 ac_ct_CC = @ac_ct_CC@
296 ac_ct_CXX = @ac_ct_CXX@
297 ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
298 am__include = @am__include@
299 am__leading_dot = @am__leading_dot@
300 am__quote = @am__quote@
301 am__tar = @am__tar@
302 am__untar = @am__untar@
303 bindir = @bindir@
304 build = @build@
305 build_alias = @build_alias@
306 build_cpu = @build_cpu@
307 build_os = @build_os@
308 build_vendor = @build_vendor@
309 builddir = @builddir@
310 datadir = @datadir@
311 datarootdir = @datarootdir@
312 docdir = @docdir@
313 dvidir = @dvidir@
314 exec_prefix = @exec_prefix@
315 host = @host@
316 host_alias = @host_alias@
317 host_cpu = @host_cpu@
318 host_os = @host_os@
319 host_vendor = @host_vendor@
320 htmldir = @htmldir@
321 includedir = @includedir@
322 infodir = @infodir@
323 install_sh = @install_sh@
324 libdir = @libdir@
325 libexecdir = @libexecdir@
326 localedir = @localedir@
327 localstatedir = @localstatedir@
328 mandir = @mandir@
329 mkdir_p = @mkdir_p@
330 oldincludedir = @oldincludedir@
331 pdfdir = @pdfdir@
332 prefix = @prefix@
333 program_transform_name = @program_transform_name@
334 psdir = @psdir@
335 sbindir = @sbindir@
336 sharedstatedir = @sharedstatedir@
337 srcdir = @srcdir@
338 sysconfdir = @sysconfdir@
339 target = @target@
340 target_alias = @target_alias@
341 target_cpu = @target_cpu@
342 target_os = @target_os@
343 target_vendor = @target_vendor@
344 top_build_prefix = @top_build_prefix@
345 top_builddir = @top_builddir@
346 top_srcdir = @top_srcdir@
347 noinst_LTLIBRARIES = libde265_encoder_algo.la
348 libde265_encoder_algo_la_CXXFLAGS = -I../..
349 libde265_encoder_algo_la_SOURCES = \
350 algo.h algo.cc \
351 coding-options.h coding-options.cc \
352 ctb-qscale.h ctb-qscale.cc \
353 cb-split.h cb-split.cc \
354 cb-intrapartmode.h cb-intrapartmode.cc \
355 cb-interpartmode.h cb-interpartmode.cc \
356 cb-skip.h cb-skip.cc \
357 cb-intra-inter.h cb-intra-inter.cc \
358 cb-mergeindex.h cb-mergeindex.cc \
359 tb-split.h tb-split.cc \
360 tb-intrapredmode.h tb-intrapredmode.cc \
361 pb-mv.h pb-mv.cc
362
363 EXTRA_DIST = \
364 CMakeLists.txt
365
366 all: all-am
367
368 .SUFFIXES:
369 .SUFFIXES: .cc .lo .o .obj
370 $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
371 @for dep in $?; do \
372 case '$(am__configure_deps)' in \
373 *$$dep*) \
374 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
375 && { if test -f $@; then exit 0; else break; fi; }; \
376 exit 1;; \
377 esac; \
378 done; \
379 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libde265/encoder/algo/Makefile'; \
380 $(am__cd) $(top_srcdir) && \
381 $(AUTOMAKE) --gnu libde265/encoder/algo/Makefile
382 .PRECIOUS: Makefile
383 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
384 @case '$?' in \
385 *config.status*) \
386 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
387 *) \
388 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
389 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
390 esac;
391
392 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
393 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
394
395 $(top_srcdir)/configure: $(am__configure_deps)
396 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
397 $(ACLOCAL_M4): $(am__aclocal_m4_deps)
398 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
399 $(am__aclocal_m4_deps):
400
401 clean-noinstLTLIBRARIES:
402 -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
403 @list='$(noinst_LTLIBRARIES)'; \
404 locs=`for p in $$list; do echo $$p; done | \
405 sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
406 sort -u`; \
407 test -z "$$locs" || { \
408 echo rm -f $${locs}; \
409 rm -f $${locs}; \
410 }
411
412 libde265_encoder_algo.la: $(libde265_encoder_algo_la_OBJECTS) $(libde265_encoder_algo_la_DEPENDENCIES) $(EXTRA_libde265_encoder_algo_la_DEPENDENCIES)
413 $(AM_V_CXXLD)$(libde265_encoder_algo_la_LINK) $(libde265_encoder_algo_la_OBJECTS) $(libde265_encoder_algo_la_LIBADD) $(LIBS)
414
415 mostlyclean-compile:
416 -rm -f *.$(OBJEXT)
417
418 distclean-compile:
419 -rm -f *.tab.c
420
421 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_encoder_algo_la-algo.Plo@am__quote@
422 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_encoder_algo_la-cb-interpartmode.Plo@am__quote@
423 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_encoder_algo_la-cb-intra-inter.Plo@am__quote@
424 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_encoder_algo_la-cb-intrapartmode.Plo@am__quote@
425 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_encoder_algo_la-cb-mergeindex.Plo@am__quote@
426 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_encoder_algo_la-cb-skip.Plo@am__quote@
427 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_encoder_algo_la-cb-split.Plo@am__quote@
428 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_encoder_algo_la-coding-options.Plo@am__quote@
429 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_encoder_algo_la-ctb-qscale.Plo@am__quote@
430 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_encoder_algo_la-pb-mv.Plo@am__quote@
431 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_encoder_algo_la-tb-intrapredmode.Plo@am__quote@
432 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libde265_encoder_algo_la-tb-split.Plo@am__quote@
433
434 .cc.o:
435 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
436 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
437 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
438 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
439 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<
440
441 .cc.obj:
442 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
443 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
444 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
445 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
446 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
447
448 .cc.lo:
449 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
450 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
451 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
452 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
453 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
454
455 libde265_encoder_algo_la-algo.lo: algo.cc
456 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_algo_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_encoder_algo_la-algo.lo -MD -MP -MF $(DEPDIR)/libde265_encoder_algo_la-algo.Tpo -c -o libde265_encoder_algo_la-algo.lo `test -f 'algo.cc' || echo '$(srcdir)/'`algo.cc
457 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_encoder_algo_la-algo.Tpo $(DEPDIR)/libde265_encoder_algo_la-algo.Plo
458 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='algo.cc' object='libde265_encoder_algo_la-algo.lo' libtool=yes @AMDEPBACKSLASH@
459 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
460 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_algo_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_encoder_algo_la-algo.lo `test -f 'algo.cc' || echo '$(srcdir)/'`algo.cc
461
462 libde265_encoder_algo_la-coding-options.lo: coding-options.cc
463 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_algo_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_encoder_algo_la-coding-options.lo -MD -MP -MF $(DEPDIR)/libde265_encoder_algo_la-coding-options.Tpo -c -o libde265_encoder_algo_la-coding-options.lo `test -f 'coding-options.cc' || echo '$(srcdir)/'`coding-options.cc
464 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_encoder_algo_la-coding-options.Tpo $(DEPDIR)/libde265_encoder_algo_la-coding-options.Plo
465 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='coding-options.cc' object='libde265_encoder_algo_la-coding-options.lo' libtool=yes @AMDEPBACKSLASH@
466 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
467 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_algo_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_encoder_algo_la-coding-options.lo `test -f 'coding-options.cc' || echo '$(srcdir)/'`coding-options.cc
468
469 libde265_encoder_algo_la-ctb-qscale.lo: ctb-qscale.cc
470 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_algo_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_encoder_algo_la-ctb-qscale.lo -MD -MP -MF $(DEPDIR)/libde265_encoder_algo_la-ctb-qscale.Tpo -c -o libde265_encoder_algo_la-ctb-qscale.lo `test -f 'ctb-qscale.cc' || echo '$(srcdir)/'`ctb-qscale.cc
471 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_encoder_algo_la-ctb-qscale.Tpo $(DEPDIR)/libde265_encoder_algo_la-ctb-qscale.Plo
472 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='ctb-qscale.cc' object='libde265_encoder_algo_la-ctb-qscale.lo' libtool=yes @AMDEPBACKSLASH@
473 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
474 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_algo_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_encoder_algo_la-ctb-qscale.lo `test -f 'ctb-qscale.cc' || echo '$(srcdir)/'`ctb-qscale.cc
475
476 libde265_encoder_algo_la-cb-split.lo: cb-split.cc
477 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_algo_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_encoder_algo_la-cb-split.lo -MD -MP -MF $(DEPDIR)/libde265_encoder_algo_la-cb-split.Tpo -c -o libde265_encoder_algo_la-cb-split.lo `test -f 'cb-split.cc' || echo '$(srcdir)/'`cb-split.cc
478 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_encoder_algo_la-cb-split.Tpo $(DEPDIR)/libde265_encoder_algo_la-cb-split.Plo
479 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='cb-split.cc' object='libde265_encoder_algo_la-cb-split.lo' libtool=yes @AMDEPBACKSLASH@
480 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
481 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_algo_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_encoder_algo_la-cb-split.lo `test -f 'cb-split.cc' || echo '$(srcdir)/'`cb-split.cc
482
483 libde265_encoder_algo_la-cb-intrapartmode.lo: cb-intrapartmode.cc
484 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_algo_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_encoder_algo_la-cb-intrapartmode.lo -MD -MP -MF $(DEPDIR)/libde265_encoder_algo_la-cb-intrapartmode.Tpo -c -o libde265_encoder_algo_la-cb-intrapartmode.lo `test -f 'cb-intrapartmode.cc' || echo '$(srcdir)/'`cb-intrapartmode.cc
485 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_encoder_algo_la-cb-intrapartmode.Tpo $(DEPDIR)/libde265_encoder_algo_la-cb-intrapartmode.Plo
486 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='cb-intrapartmode.cc' object='libde265_encoder_algo_la-cb-intrapartmode.lo' libtool=yes @AMDEPBACKSLASH@
487 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
488 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_algo_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_encoder_algo_la-cb-intrapartmode.lo `test -f 'cb-intrapartmode.cc' || echo '$(srcdir)/'`cb-intrapartmode.cc
489
490 libde265_encoder_algo_la-cb-interpartmode.lo: cb-interpartmode.cc
491 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_algo_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_encoder_algo_la-cb-interpartmode.lo -MD -MP -MF $(DEPDIR)/libde265_encoder_algo_la-cb-interpartmode.Tpo -c -o libde265_encoder_algo_la-cb-interpartmode.lo `test -f 'cb-interpartmode.cc' || echo '$(srcdir)/'`cb-interpartmode.cc
492 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_encoder_algo_la-cb-interpartmode.Tpo $(DEPDIR)/libde265_encoder_algo_la-cb-interpartmode.Plo
493 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='cb-interpartmode.cc' object='libde265_encoder_algo_la-cb-interpartmode.lo' libtool=yes @AMDEPBACKSLASH@
494 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
495 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_algo_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_encoder_algo_la-cb-interpartmode.lo `test -f 'cb-interpartmode.cc' || echo '$(srcdir)/'`cb-interpartmode.cc
496
497 libde265_encoder_algo_la-cb-skip.lo: cb-skip.cc
498 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_algo_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_encoder_algo_la-cb-skip.lo -MD -MP -MF $(DEPDIR)/libde265_encoder_algo_la-cb-skip.Tpo -c -o libde265_encoder_algo_la-cb-skip.lo `test -f 'cb-skip.cc' || echo '$(srcdir)/'`cb-skip.cc
499 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_encoder_algo_la-cb-skip.Tpo $(DEPDIR)/libde265_encoder_algo_la-cb-skip.Plo
500 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='cb-skip.cc' object='libde265_encoder_algo_la-cb-skip.lo' libtool=yes @AMDEPBACKSLASH@
501 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
502 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_algo_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_encoder_algo_la-cb-skip.lo `test -f 'cb-skip.cc' || echo '$(srcdir)/'`cb-skip.cc
503
504 libde265_encoder_algo_la-cb-intra-inter.lo: cb-intra-inter.cc
505 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_algo_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_encoder_algo_la-cb-intra-inter.lo -MD -MP -MF $(DEPDIR)/libde265_encoder_algo_la-cb-intra-inter.Tpo -c -o libde265_encoder_algo_la-cb-intra-inter.lo `test -f 'cb-intra-inter.cc' || echo '$(srcdir)/'`cb-intra-inter.cc
506 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_encoder_algo_la-cb-intra-inter.Tpo $(DEPDIR)/libde265_encoder_algo_la-cb-intra-inter.Plo
507 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='cb-intra-inter.cc' object='libde265_encoder_algo_la-cb-intra-inter.lo' libtool=yes @AMDEPBACKSLASH@
508 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
509 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_algo_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_encoder_algo_la-cb-intra-inter.lo `test -f 'cb-intra-inter.cc' || echo '$(srcdir)/'`cb-intra-inter.cc
510
511 libde265_encoder_algo_la-cb-mergeindex.lo: cb-mergeindex.cc
512 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_algo_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_encoder_algo_la-cb-mergeindex.lo -MD -MP -MF $(DEPDIR)/libde265_encoder_algo_la-cb-mergeindex.Tpo -c -o libde265_encoder_algo_la-cb-mergeindex.lo `test -f 'cb-mergeindex.cc' || echo '$(srcdir)/'`cb-mergeindex.cc
513 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_encoder_algo_la-cb-mergeindex.Tpo $(DEPDIR)/libde265_encoder_algo_la-cb-mergeindex.Plo
514 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='cb-mergeindex.cc' object='libde265_encoder_algo_la-cb-mergeindex.lo' libtool=yes @AMDEPBACKSLASH@
515 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
516 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_algo_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_encoder_algo_la-cb-mergeindex.lo `test -f 'cb-mergeindex.cc' || echo '$(srcdir)/'`cb-mergeindex.cc
517
518 libde265_encoder_algo_la-tb-split.lo: tb-split.cc
519 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_algo_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_encoder_algo_la-tb-split.lo -MD -MP -MF $(DEPDIR)/libde265_encoder_algo_la-tb-split.Tpo -c -o libde265_encoder_algo_la-tb-split.lo `test -f 'tb-split.cc' || echo '$(srcdir)/'`tb-split.cc
520 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_encoder_algo_la-tb-split.Tpo $(DEPDIR)/libde265_encoder_algo_la-tb-split.Plo
521 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='tb-split.cc' object='libde265_encoder_algo_la-tb-split.lo' libtool=yes @AMDEPBACKSLASH@
522 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
523 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_algo_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_encoder_algo_la-tb-split.lo `test -f 'tb-split.cc' || echo '$(srcdir)/'`tb-split.cc
524
525 libde265_encoder_algo_la-tb-intrapredmode.lo: tb-intrapredmode.cc
526 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_algo_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_encoder_algo_la-tb-intrapredmode.lo -MD -MP -MF $(DEPDIR)/libde265_encoder_algo_la-tb-intrapredmode.Tpo -c -o libde265_encoder_algo_la-tb-intrapredmode.lo `test -f 'tb-intrapredmode.cc' || echo '$(srcdir)/'`tb-intrapredmode.cc
527 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_encoder_algo_la-tb-intrapredmode.Tpo $(DEPDIR)/libde265_encoder_algo_la-tb-intrapredmode.Plo
528 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='tb-intrapredmode.cc' object='libde265_encoder_algo_la-tb-intrapredmode.lo' libtool=yes @AMDEPBACKSLASH@
529 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
530 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_algo_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_encoder_algo_la-tb-intrapredmode.lo `test -f 'tb-intrapredmode.cc' || echo '$(srcdir)/'`tb-intrapredmode.cc
531
532 libde265_encoder_algo_la-pb-mv.lo: pb-mv.cc
533 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_algo_la_CXXFLAGS) $(CXXFLAGS) -MT libde265_encoder_algo_la-pb-mv.lo -MD -MP -MF $(DEPDIR)/libde265_encoder_algo_la-pb-mv.Tpo -c -o libde265_encoder_algo_la-pb-mv.lo `test -f 'pb-mv.cc' || echo '$(srcdir)/'`pb-mv.cc
534 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libde265_encoder_algo_la-pb-mv.Tpo $(DEPDIR)/libde265_encoder_algo_la-pb-mv.Plo
535 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='pb-mv.cc' object='libde265_encoder_algo_la-pb-mv.lo' libtool=yes @AMDEPBACKSLASH@
536 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
537 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libde265_encoder_algo_la_CXXFLAGS) $(CXXFLAGS) -c -o libde265_encoder_algo_la-pb-mv.lo `test -f 'pb-mv.cc' || echo '$(srcdir)/'`pb-mv.cc
538
539 mostlyclean-libtool:
540 -rm -f *.lo
541
542 clean-libtool:
543 -rm -rf .libs _libs
544
545 ID: $(am__tagged_files)
546 $(am__define_uniq_tagged_files); mkid -fID $$unique
547 tags: tags-am
548 TAGS: tags
549
550 tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
551 set x; \
552 here=`pwd`; \
553 $(am__define_uniq_tagged_files); \
554 shift; \
555 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
556 test -n "$$unique" || unique=$$empty_fix; \
557 if test $$# -gt 0; then \
558 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
559 "$$@" $$unique; \
560 else \
561 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
562 $$unique; \
563 fi; \
564 fi
565 ctags: ctags-am
566
567 CTAGS: ctags
568 ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
569 $(am__define_uniq_tagged_files); \
570 test -z "$(CTAGS_ARGS)$$unique" \
571 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
572 $$unique
573
574 GTAGS:
575 here=`$(am__cd) $(top_builddir) && pwd` \
576 && $(am__cd) $(top_srcdir) \
577 && gtags -i $(GTAGS_ARGS) "$$here"
578 cscopelist: cscopelist-am
579
580 cscopelist-am: $(am__tagged_files)
581 list='$(am__tagged_files)'; \
582 case "$(srcdir)" in \
583 [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
584 *) sdir=$(subdir)/$(srcdir) ;; \
585 esac; \
586 for i in $$list; do \
587 if test -f "$$i"; then \
588 echo "$(subdir)/$$i"; \
589 else \
590 echo "$$sdir/$$i"; \
591 fi; \
592 done >> $(top_builddir)/cscope.files
593
594 distclean-tags:
595 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
596
597 distdir: $(DISTFILES)
598 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
599 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
600 list='$(DISTFILES)'; \
601 dist_files=`for file in $$list; do echo $$file; done | \
602 sed -e "s|^$$srcdirstrip/||;t" \
603 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
604 case $$dist_files in \
605 */*) $(MKDIR_P) `echo "$$dist_files" | \
606 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
607 sort -u` ;; \
608 esac; \
609 for file in $$dist_files; do \
610 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
611 if test -d $$d/$$file; then \
612 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
613 if test -d "$(distdir)/$$file"; then \
614 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
615 fi; \
616 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
617 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
618 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
619 fi; \
620 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
621 else \
622 test -f "$(distdir)/$$file" \
623 || cp -p $$d/$$file "$(distdir)/$$file" \
624 || exit 1; \
625 fi; \
626 done
627 check-am: all-am
628 check: check-am
629 all-am: Makefile $(LTLIBRARIES)
630 installdirs:
631 install: install-am
632 install-exec: install-exec-am
633 install-data: install-data-am
634 uninstall: uninstall-am
635
636 install-am: all-am
637 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
638
639 installcheck: installcheck-am
640 install-strip:
641 if test -z '$(STRIP)'; then \
642 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
643 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
644 install; \
645 else \
646 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
647 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
648 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
649 fi
650 mostlyclean-generic:
651
652 clean-generic:
653
654 distclean-generic:
655 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
656 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
657
658 maintainer-clean-generic:
659 @echo "This command is intended for maintainers to use"
660 @echo "it deletes files that may require special tools to rebuild."
661 clean: clean-am
662
663 clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
664 mostlyclean-am
665
666 distclean: distclean-am
667 -rm -rf ./$(DEPDIR)
668 -rm -f Makefile
669 distclean-am: clean-am distclean-compile distclean-generic \
670 distclean-tags
671
672 dvi: dvi-am
673
674 dvi-am:
675
676 html: html-am
677
678 html-am:
679
680 info: info-am
681
682 info-am:
683
684 install-data-am:
685
686 install-dvi: install-dvi-am
687
688 install-dvi-am:
689
690 install-exec-am:
691
692 install-html: install-html-am
693
694 install-html-am:
695
696 install-info: install-info-am
697
698 install-info-am:
699
700 install-man:
701
702 install-pdf: install-pdf-am
703
704 install-pdf-am:
705
706 install-ps: install-ps-am
707
708 install-ps-am:
709
710 installcheck-am:
711
712 maintainer-clean: maintainer-clean-am
713 -rm -rf ./$(DEPDIR)
714 -rm -f Makefile
715 maintainer-clean-am: distclean-am maintainer-clean-generic
716
717 mostlyclean: mostlyclean-am
718
719 mostlyclean-am: mostlyclean-compile mostlyclean-generic \
720 mostlyclean-libtool
721
722 pdf: pdf-am
723
724 pdf-am:
725
726 ps: ps-am
727
728 ps-am:
729
730 uninstall-am:
731
732 .MAKE: install-am install-strip
733
734 .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
735 clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \
736 ctags-am distclean distclean-compile distclean-generic \
737 distclean-libtool distclean-tags distdir dvi dvi-am html \
738 html-am info info-am install install-am install-data \
739 install-data-am install-dvi install-dvi-am install-exec \
740 install-exec-am install-html install-html-am install-info \
741 install-info-am install-man install-pdf install-pdf-am \
742 install-ps install-ps-am install-strip installcheck \
743 installcheck-am installdirs maintainer-clean \
744 maintainer-clean-generic mostlyclean mostlyclean-compile \
745 mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
746 tags tags-am uninstall uninstall-am
747
748
749 # Tell versions [3.59,3.63) of GNU make to not export all variables.
750 # Otherwise a system limit (for SysV at least) may be exceeded.
751 .NOEXPORT:
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #include "libde265/encoder/algo/algo.h"
23 #include "libde265/encoder/encoder-context.h"
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef ALGO_H
23 #define ALGO_H
24
25 #include "libde265/encoder/encode.h"
26
27
28 /* When entering the next recursion level, it is assumed that
29 a valid CB structure is passed down. Ownership is transferred to
30 the new algorithm. That algorithm passes back a (possibly different)
31 CB structure that the first algorithm should use. The original CB
32 structure might have been deleted in the called algorithm.
33
34 The context_model_table passed down is at the current state.
35 When the algorithm returns, the state should represent the state
36 after running this algorithm.
37
38 When returning from the algorithm, it is also assumed that the
39 ectx->img content (reconstruction and metadata) represent the
40 current state. When the algorithm tries several variants, it
41 has to restore the state to the selected variant.
42 */
43
44 class Algo_CB
45 {
46 public:
47 virtual ~Algo_CB() { }
48
49 /* The context_model_table that is provided can be modified and
50 even released in the function. On exit, it should be filled with
51 a (optionally new) context_model_table that represents the state
52 after encoding the syntax element. However, to speed up computation,
53 it is also allowed to not modify the context_model_table at all.
54 */
55 virtual enc_cb* analyze(encoder_context*,
56 context_model_table&,
57 enc_cb* cb) = 0;
58 };
59
60
61 class Algo_PB
62 {
63 public:
64 virtual ~Algo_PB() { }
65
66 virtual enc_cb* analyze(encoder_context*,
67 context_model_table&,
68 enc_cb* cb,
69 int PBidx, int x,int y,int w,int h) = 0;
70 };
71
72
73 #endif
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: struktur AG, Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22
23 #include "libde265/encoder/algo/cb-interpartmode.h"
24 #include "libde265/encoder/algo/coding-options.h"
25 #include "libde265/encoder/encoder-context.h"
26 #include <assert.h>
27 #include <limits>
28 #include <math.h>
29
30
31
32 enc_cb* Algo_CB_InterPartMode::codeAllPBs(encoder_context* ectx,
33 context_model_table& ctxModel,
34 enc_cb* cb)
35 {
36 int x = cb->x;
37 int y = cb->y;
38 int log2Size = cb->log2Size;
39 int w = 1<<log2Size;
40 int s; // splitSize;
41
42 int nPB;
43 switch (cb->PartMode) {
44 case PART_2Nx2N:
45 cb = mChildAlgo->analyze(ectx, ctxModel, cb, 0, x,y,1<<log2Size,1<<log2Size);
46 break;
47
48 case PART_NxN:
49 s = 1<<(log2Size-1);
50 cb = mChildAlgo->analyze(ectx, ctxModel, cb, 0, x ,y ,s,s);
51 cb = mChildAlgo->analyze(ectx, ctxModel, cb, 1, x+s,y ,s,s);
52 cb = mChildAlgo->analyze(ectx, ctxModel, cb, 2, x ,y+s,s,s);
53 cb = mChildAlgo->analyze(ectx, ctxModel, cb, 3, x+s,y+s,s,s);
54 break;
55
56 case PART_2NxN:
57 s = 1<<(log2Size-1);
58 cb = mChildAlgo->analyze(ectx, ctxModel, cb, 0, x,y ,w,s);
59 cb = mChildAlgo->analyze(ectx, ctxModel, cb, 1, x,y+s,w,s);
60 break;
61
62 case PART_Nx2N:
63 s = 1<<(log2Size-1);
64 cb = mChildAlgo->analyze(ectx, ctxModel, cb, 0, x ,y,s,w);
65 cb = mChildAlgo->analyze(ectx, ctxModel, cb, 1, x+s,y,s,w);
66 break;
67
68 case PART_2NxnU:
69 s = 1<<(log2Size-2);
70 cb = mChildAlgo->analyze(ectx, ctxModel, cb, 0, x,y ,w,s);
71 cb = mChildAlgo->analyze(ectx, ctxModel, cb, 1, x,y+s,w,w-s);
72 break;
73
74 case PART_2NxnD:
75 s = 1<<(log2Size-2);
76 cb = mChildAlgo->analyze(ectx, ctxModel, cb, 0, x,y ,w,w-s);
77 cb = mChildAlgo->analyze(ectx, ctxModel, cb, 1, x,y+w-s,w,s);
78 break;
79
80 case PART_nLx2N:
81 s = 1<<(log2Size-2);
82 cb = mChildAlgo->analyze(ectx, ctxModel, cb, 0, x ,y,s ,w);
83 cb = mChildAlgo->analyze(ectx, ctxModel, cb, 1, x+s,y,w-s,w);
84 break;
85
86 case PART_nRx2N:
87 s = 1<<(log2Size-2);
88 cb = mChildAlgo->analyze(ectx, ctxModel, cb, 0, x ,y,w-s,w);
89 cb = mChildAlgo->analyze(ectx, ctxModel, cb, 1, x+w-s,y,s ,w);
90 break;
91 }
92
93 return cb;
94 }
95
96
97 enc_cb* Algo_CB_InterPartMode_Fixed::analyze(encoder_context* ectx,
98 context_model_table& ctxModel,
99 enc_cb* cb)
100 {
101 const int x = cb->x;
102 const int y = cb->y;
103
104 enum PartMode partMode = mParams.partMode();
105
106 cb->PartMode = partMode;
107 ectx->img->set_PartMode(x,y, partMode);
108
109 cb = codeAllPBs(ectx,ctxModel,cb);
110
111 return cb;
112 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef CB_INTERPARTMODE_H
23 #define CB_INTERPARTMODE_H
24
25 #include "libde265/nal-parser.h"
26 #include "libde265/decctx.h"
27 #include "libde265/encoder/encode.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 protected:
53 Algo_PB* mChildAlgo;
54
55 enc_cb* codeAllPBs(encoder_context*,
56 context_model_table&,
57 enc_cb* cb);
58 };
59
60
61
62
63 class option_InterPartMode : public choice_option<enum PartMode> // choice_option
64 {
65 public:
66 option_InterPartMode() {
67 add_choice("2Nx2N", PART_2Nx2N, true);
68 add_choice("NxN", PART_NxN);
69 add_choice("Nx2N", PART_Nx2N);
70 add_choice("2NxN", PART_2NxN);
71 add_choice("2NxnU", PART_2NxnU);
72 add_choice("2NxnD", PART_2NxnD);
73 add_choice("nLx2N", PART_nLx2N);
74 add_choice("nRx2N", PART_nRx2N);
75 }
76 };
77
78 class Algo_CB_InterPartMode_Fixed : public Algo_CB_InterPartMode
79 {
80 public:
81 struct params
82 {
83 params() {
84 partMode.set_ID("CB-InterPartMode-Fixed-partMode");
85 }
86
87 option_InterPartMode partMode;
88 };
89
90 void registerParams(config_parameters& config) {
91 config.add_option(&mParams.partMode);
92 }
93
94 void setParams(const params& p) { mParams=p; }
95
96 virtual enc_cb* analyze(encoder_context*,
97 context_model_table&,
98 enc_cb* cb);
99
100 private:
101 params mParams;
102 };
103
104 #endif
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: struktur AG, Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22
23 #include "libde265/encoder/algo/cb-intra-inter.h"
24 #include "libde265/encoder/algo/coding-options.h"
25 #include "libde265/encoder/encoder-context.h"
26 #include <assert.h>
27 #include <limits>
28 #include <math.h>
29
30
31
32 enc_cb* Algo_CB_IntraInter_BruteForce::analyze(encoder_context* ectx,
33 context_model_table& ctxModel,
34 enc_cb* cb)
35 {
36 assert(cb->pcm_flag==0);
37
38 bool try_intra = true;
39 bool try_inter = (ectx->shdr->slice_type != SLICE_TYPE_I);
40
41 bool debug_halt = try_inter;
42 //try_inter = false;
43 //try_intra = !try_inter; // TODO HACK: no intra in inter frames
44
45 if (ectx->imgdata->frame_number > 0) {
46 //printf("%d\n",ectx->imgdata->frame_number);
47 }
48
49 // 0: intra
50 // 1: inter
51
52 CodingOptions options(ectx,cb,ctxModel);
53
54 CodingOption option_intra = options.new_option(try_intra);
55 CodingOption option_inter = options.new_option(try_inter);
56
57 options.start();
58
59 enc_cb* cb_inter = NULL;
60 enc_cb* cb_intra = NULL;
61
62 const int log2CbSize = cb->log2Size;
63 const int x = cb->x;
64 const int y = cb->y;
65
66
67 // try encoding with inter
68
69 if (option_inter) {
70 option_inter.begin();
71 cb_inter = option_inter.get_cb();
72
73 cb_inter->PredMode = MODE_INTER;
74 ectx->img->set_pred_mode(x,y, log2CbSize, MODE_INTER);
75
76 enc_cb* cb_result;
77 cb_result=mInterAlgo->analyze(ectx, option_inter.get_context(), cb_inter);
78
79 if (cb_result->PredMode != MODE_SKIP) {
80 CABAC_encoder_estim* cabac = option_inter.get_cabac();
81 cabac->reset();
82
83 cabac->write_CABAC_bit(CONTEXT_MODEL_PRED_MODE_FLAG, 0); // 0 - inter
84 float rate_pred_mode_flag = cabac->getRDBits();
85 //printf("inter bits: %f\n", rate_pred_mode_flag);
86
87 cb_result->rate += rate_pred_mode_flag;
88 }
89
90 option_inter.set_cb(cb_result);
91
92 option_inter.end();
93 }
94
95
96 // try intra
97
98 if (option_intra) {
99 option_intra.begin();
100 cb_intra = option_intra.get_cb();
101
102 cb_intra->PredMode = MODE_INTRA;
103 ectx->img->set_pred_mode(x,y, log2CbSize, MODE_INTRA);
104
105 enc_cb* cb_result;
106 cb_result=mIntraAlgo->analyze(ectx, option_intra.get_context(), cb_intra);
107
108 if (ectx->shdr->slice_type != SLICE_TYPE_I) {
109 CABAC_encoder_estim* cabac = option_intra.get_cabac();
110 cabac->reset();
111
112 cabac->write_CABAC_bit(CONTEXT_MODEL_PRED_MODE_FLAG, 1); // 1 - intra
113 float rate_pred_mode_flag = cabac->getRDBits();
114 //printf("intra bits: %f\n", rate_pred_mode_flag);
115
116 cb_result->rate += rate_pred_mode_flag;
117 }
118
119 option_intra.set_cb(cb_result);
120
121 option_intra.end();
122 }
123
124
125 options.compute_rdo_costs();
126 return options.return_best_rdo();
127 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef CB_INTRA_INTER_H
23 #define CB_INTRA_INTER_H
24
25 #include "libde265/nal-parser.h"
26 #include "libde265/decctx.h"
27 #include "libde265/encoder/encode.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 protected:
54 Algo_CB* mIntraAlgo;
55 Algo_CB* mInterAlgo;
56 };
57
58 class Algo_CB_IntraInter_BruteForce : public Algo_CB_IntraInter
59 {
60 public:
61 virtual enc_cb* analyze(encoder_context*,
62 context_model_table&,
63 enc_cb* cb);
64 };
65
66 #endif
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: struktur AG, Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22
23 #include "libde265/encoder/algo/cb-intrapartmode.h"
24 #include "libde265/encoder/algo/coding-options.h"
25 #include "libde265/encoder/encoder-context.h"
26 #include <assert.h>
27 #include <limits>
28 #include <math.h>
29 #include <iostream>
30
31
32 #define ENCODER_DEVELOPMENT 1
33
34
35
36 enc_cb* Algo_CB_IntraPartMode_BruteForce::analyze(encoder_context* ectx,
37 context_model_table& ctxModel,
38 enc_cb* cb_in)
39 {
40 const int log2CbSize = cb_in->log2Size;
41 const int x = cb_in->x;
42 const int y = cb_in->y;
43
44 const bool can_use_NxN = ((log2CbSize == ectx->sps.Log2MinCbSizeY) &&
45 (log2CbSize > ectx->sps.Log2MinTrafoSize));
46
47
48 // test all modes
49
50 assert(cb_in->pcm_flag==0);
51
52
53 // 0: 2Nx2N (always checked)
54 // 1: NxN (only checked at MinCbSize)
55
56 CodingOptions options(ectx,cb_in,ctxModel);
57 CodingOption option[2];
58 option[0] = options.new_option(true);
59 option[1] = options.new_option(can_use_NxN);
60
61 options.start();
62
63 for (int p=0;p<2;p++)
64 if (option[p]) {
65 option[p].begin();
66
67 enc_cb* cb = option[p].get_cb();
68
69 // --- set intra prediction mode ---
70
71 cb->PartMode = (p==0 ? PART_2Nx2N : PART_NxN);
72
73 ectx->img->set_pred_mode(x,y, log2CbSize, cb->PredMode); // TODO: probably unnecessary
74 ectx->img->set_PartMode (x,y, cb->PartMode);
75
76 // encode transform tree
77
78 int IntraSplitFlag= (cb->PredMode == MODE_INTRA && cb->PartMode == PART_NxN);
79 int MaxTrafoDepth = ectx->sps.max_transform_hierarchy_depth_intra + IntraSplitFlag;
80
81 cb->transform_tree = mTBIntraPredModeAlgo->analyze(ectx, option[p].get_context(),
82 ectx->imgdata->input, NULL, cb,
83 x,y, x,y, log2CbSize,
84 0,
85 0, MaxTrafoDepth, IntraSplitFlag);
86
87 cb->distortion = cb->transform_tree->distortion;
88 cb->rate = cb->transform_tree->rate;
89
90
91 // rate for cu syntax
92
93 logtrace(LogSymbols,"$1 part_mode=%d\n",cb->PartMode);
94 if (log2CbSize == ectx->sps.Log2MinCbSizeY) {
95 int bin = (cb->PartMode==PART_2Nx2N);
96 option[p].get_cabac()->reset();
97 option[p].get_cabac()->write_CABAC_bit(CONTEXT_MODEL_PART_MODE+0, bin);
98 cb->rate += option[p].get_cabac()->getRDBits();
99 }
100
101 option[p].end();
102 }
103
104 options.compute_rdo_costs();
105 return options.return_best_rdo();
106 }
107
108
109 enc_cb* Algo_CB_IntraPartMode_Fixed::analyze(encoder_context* ectx,
110 context_model_table& ctxModel,
111 enc_cb* cb)
112 {
113 std::cout << "CB-IntraPartMode in size=" << (1<<cb->log2Size)
114 << " hash=" << ctxModel.debug_dump() << "\n";
115
116 enum PartMode PartMode = mParams.partMode();
117
118
119 const int log2CbSize = cb->log2Size;
120 const int x = cb->x;
121 const int y = cb->y;
122
123
124 // NxN can only be applied at minimum CB size.
125 // If we are not at the minimum size, we have to use 2Nx2N.
126
127 if (PartMode==PART_NxN && log2CbSize != ectx->sps.Log2MinCbSizeY) {
128 PartMode = PART_2Nx2N;
129 }
130
131
132 // --- set intra prediction mode ---
133
134 cb->PartMode = PartMode;
135 ectx->img->set_PartMode(x,y, PartMode);
136
137
138 // encode transform tree
139
140 int IntraSplitFlag= (cb->PredMode == MODE_INTRA && cb->PartMode == PART_NxN);
141 int MaxTrafoDepth = ectx->sps.max_transform_hierarchy_depth_intra + IntraSplitFlag;
142
143 cb->transform_tree = mTBIntraPredModeAlgo->analyze(ectx, ctxModel,
144 ectx->imgdata->input, NULL, cb,
145 cb->x,cb->y, cb->x,cb->y, log2CbSize,
146 0,
147 0, MaxTrafoDepth, IntraSplitFlag);
148
149
150 // rate and distortion for this CB
151
152 cb->distortion = cb->transform_tree->distortion;
153 cb->rate = cb->transform_tree->rate;
154
155 std::cout << "SUM TB-tree hinter PartMode " << cb->rate << "\n";
156
157
158 // rate for cu syntax
159
160 CABAC_encoder_estim estim;
161 estim.set_context_models(&ctxModel);
162
163 //encode_coding_unit(ectx,&estim,cb,x,y,log2CbSize, false);
164
165 //encode_part_mode(ectx,&estim, MODE_INTRA, PartMode, 0);
166
167 logtrace(LogSymbols,"$1 part_mode=%d\n",PartMode);
168 if (log2CbSize == ectx->sps.Log2MinCbSizeY) {
169 int bin = (PartMode==PART_2Nx2N);
170 estim.write_CABAC_bit(CONTEXT_MODEL_PART_MODE+0, bin);
171 }
172
173 cb->rate += estim.getRDBits();
174
175 std::cout << "CB-IntraPartMode out size=" << (1<<cb->log2Size)
176 << " hash=" << ctxModel.debug_dump() << "\n";
177
178 return cb;
179 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef CB_INTRAPARTMODE_H
23 #define CB_INTRAPARTMODE_H
24
25 #include "libde265/nal-parser.h"
26 #include "libde265/decctx.h"
27 #include "libde265/encoder/encode.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 intra NxN vs. 2Nx2N decision ==========
57
58 enum ALGO_CB_IntraPartMode {
59 ALGO_CB_IntraPartMode_BruteForce,
60 ALGO_CB_IntraPartMode_Fixed
61 };
62
63 class option_ALGO_CB_IntraPartMode : public choice_option<enum ALGO_CB_IntraPartMode>
64 {
65 public:
66 option_ALGO_CB_IntraPartMode() {
67 add_choice("fixed", ALGO_CB_IntraPartMode_Fixed);
68 add_choice("brute-force",ALGO_CB_IntraPartMode_BruteForce, true);
69 }
70 };
71
72
73 class Algo_CB_IntraPartMode : public Algo_CB
74 {
75 public:
76 Algo_CB_IntraPartMode() : mTBIntraPredModeAlgo(NULL) { }
77 virtual ~Algo_CB_IntraPartMode() { }
78
79 virtual enc_cb* analyze(encoder_context*,
80 context_model_table&,
81 enc_cb* cb) = 0;
82
83 void setChildAlgo(Algo_TB_IntraPredMode* algo) { mTBIntraPredModeAlgo = algo; }
84
85 protected:
86 Algo_TB_IntraPredMode* mTBIntraPredModeAlgo;
87 };
88
89 /* Try both NxN, 2Nx2N and choose better one.
90 */
91 class Algo_CB_IntraPartMode_BruteForce : public Algo_CB_IntraPartMode
92 {
93 public:
94 virtual enc_cb* analyze(encoder_context*,
95 context_model_table&,
96 enc_cb* cb);
97 };
98
99
100 class option_PartMode : public choice_option<enum PartMode> // choice_option
101 {
102 public:
103 option_PartMode() {
104 add_choice("NxN", PART_NxN);
105 add_choice("2Nx2N", PART_2Nx2N, true);
106 }
107 };
108
109
110 /* Always use choose selected part mode.
111 If NxN is chosen but cannot be applied (CB tree not at maximum depth), 2Nx2N is used instead.
112 */
113 class Algo_CB_IntraPartMode_Fixed : public Algo_CB_IntraPartMode
114 {
115 public:
116 Algo_CB_IntraPartMode_Fixed() { }
117
118 struct params
119 {
120 params() {
121 partMode.set_ID("CB-IntraPartMode-Fixed-partMode");
122 }
123
124 option_PartMode partMode;
125 };
126
127 void registerParams(config_parameters& config) {
128 config.add_option(&mParams.partMode);
129 }
130
131 void setParams(const params& p) { mParams=p; }
132
133 virtual enc_cb* analyze(encoder_context* ectx,
134 context_model_table& ctxModel,
135 enc_cb* cb);
136
137 private:
138 params mParams;
139 };
140
141
142 #endif
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: struktur AG, Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22
23 #include "libde265/encoder/algo/cb-mergeindex.h"
24 #include "libde265/encoder/encoder-context.h"
25 #include <assert.h>
26 #include <limits>
27 #include <math.h>
28
29
30
31
32 enc_cb* Algo_CB_MergeIndex_Fixed::analyze(encoder_context* ectx,
33 context_model_table& ctxModel,
34 enc_cb* cb)
35 {
36 assert(cb->split_cu_flag==false);
37 assert(cb->PredMode==MODE_SKIP); // TODO: || (cb->PredMode==MODE_INTER && cb->inter.skip_flag));
38
39
40 MotionVectorSpec mergeCandList[5];
41
42 int partIdx = 0;
43
44 int cbSize = 1 << cb->log2Size;
45
46 get_merge_candidate_list(ectx, ectx->shdr, ectx->img,
47 cb->x, cb->y, // xC/yC
48 cb->x, cb->y, // xP/yP
49 cbSize, // nCS
50 cbSize,cbSize, // nPbW/nPbH
51 partIdx, // partIdx
52 mergeCandList);
53
54 motion_spec& spec = cb->inter.pb[partIdx].spec;
55
56 spec.merge_flag = 1; // we use merge mode
57 spec.merge_idx = 0;
58
59
60 // build prediction
61
62 // previous frame (TODO)
63 const de265_image* refimg = ectx->get_image(ectx->imgdata->frame_number -1);
64
65 //printf("prev frame: %p %d\n",refimg,ectx->imgdata->frame_number);
66
67 /*
68 printf("#l0: %d\n",ectx->imgdata->shdr.num_ref_idx_l0_active);
69 printf("#l1: %d\n",ectx->imgdata->shdr.num_ref_idx_l1_active);
70
71 for (int i=0;i<ectx->imgdata->shdr.num_ref_idx_l0_active;i++)
72 printf("RefPixList[0][%d] = %d\n", i, ectx->imgdata->shdr.RefPicList[0][i]);
73 */
74
75 // TODO: fake motion data
76
77 const MotionVectorSpec& vec = mergeCandList[spec.merge_idx];
78 cb->inter.pb[partIdx].motion = vec;
79
80 ectx->img->set_mv_info(cb->x,cb->y, 1<<cb->log2Size,1<<cb->log2Size, vec);
81
82 generate_inter_prediction_samples(ectx, ectx->shdr, ectx->prediction,
83 cb->x,cb->y, // int xC,int yC,
84 0,0, // int xB,int yB,
85 1<<cb->log2Size, // int nCS,
86 1<<cb->log2Size,
87 1<<cb->log2Size, // int nPbW,int nPbH,
88 &vec);
89
90 generate_inter_prediction_samples(ectx, ectx->shdr, ectx->img,
91 cb->x,cb->y, // int xC,int yC,
92 0,0, // int xB,int yB,
93 1<<cb->log2Size, // int nCS,
94 1<<cb->log2Size,
95 1<<cb->log2Size, // int nPbW,int nPbH,
96 &vec);
97
98 // estimate rate for sending merge index
99
100 //CABAC_encoder_estim cabac;
101 //cabac.write_bits();
102
103 int IntraSplitFlag = 0;
104 int MaxTrafoDepth = ectx->sps.max_transform_hierarchy_depth_inter;
105
106 if (mCodeResidual) {
107 assert(false);
108 cb->transform_tree = mTBSplit->analyze(ectx,ctxModel, ectx->imgdata->input, NULL, cb,
109 cb->x,cb->y,cb->x,cb->y, cb->log2Size,0,
110 0, MaxTrafoDepth, IntraSplitFlag);
111
112 cb->inter.rqt_root_cbf = ! cb->transform_tree->isZeroBlock();
113
114 cb->distortion = cb->transform_tree->distortion;
115 cb->rate = cb->transform_tree->rate;
116 }
117 else {
118 const de265_image* input = ectx->imgdata->input;
119 de265_image* img = ectx->prediction;
120 int x0 = cb->x;
121 int y0 = cb->y;
122 int tbSize = 1<<cb->log2Size;
123
124 CABAC_encoder_estim cabac;
125 cabac.set_context_models(&ctxModel);
126 encode_merge_idx(ectx, &cabac, spec.merge_idx);
127
128 cb->distortion = compute_distortion_ssd(input, img, x0,y0, cb->log2Size, 0);
129 cb->rate = cabac.getRDBits();
130
131 cb->inter.rqt_root_cbf = 0;
132 }
133
134 //printf("%d;%d rqt_root_cbf=%d\n",cb->x,cb->y,cb->inter.rqt_root_cbf);
135
136 return cb;
137 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef CB_MERGEINDEX_H
23 #define CB_MERGEINDEX_H
24
25 #include "libde265/nal-parser.h"
26 #include "libde265/decctx.h"
27 #include "libde265/encoder/encode.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 protected:
55 Algo_TB_Split* mTBSplit;
56
57 bool mCodeResidual;
58 };
59
60 class Algo_CB_MergeIndex_Fixed : public Algo_CB_MergeIndex
61 {
62 public:
63 virtual enc_cb* analyze(encoder_context*,
64 context_model_table&,
65 enc_cb* cb);
66 };
67
68 #endif
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: struktur AG, Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22
23 #include "libde265/encoder/algo/cb-skip.h"
24 #include "libde265/encoder/algo/coding-options.h"
25 #include "libde265/encoder/encoder-context.h"
26 #include <assert.h>
27 #include <limits>
28 #include <math.h>
29
30
31
32
33 enc_cb* Algo_CB_Skip_BruteForce::analyze(encoder_context* ectx,
34 context_model_table& ctxModel,
35 enc_cb* cb)
36 {
37 bool try_skip = (ectx->shdr->slice_type != SLICE_TYPE_I);
38 bool try_nonskip = true;
39
40 CodingOptions options(ectx,cb,ctxModel);
41 CodingOption option_skip = options.new_option(try_skip);
42 CodingOption option_nonskip = options.new_option(try_nonskip);
43 options.start();
44
45 for (int i=0;i<CONTEXT_MODEL_TABLE_LENGTH;i++) {
46 //printf("%i: %d/%d\n",i, ctxModel[i].state, ctxModel[i].MPSbit);
47 }
48
49 if (option_skip) {
50 CodingOption& opt = option_skip;
51 opt.begin();
52
53 enc_cb* cb = opt.get_cb();
54
55 // calc rate for skip flag (=true)
56
57 CABAC_encoder_estim* cabac = opt.get_cabac();
58 encode_cu_skip_flag(ectx, cabac, cb, true);
59 float rate_pred_mode = cabac->getRDBits();
60 cabac->reset();
61
62 // set skip flag
63
64 cb->PredMode = MODE_SKIP;
65 ectx->img->set_pred_mode(cb->x,cb->y, cb->log2Size, cb->PredMode);
66
67 // encode CB
68
69 cb = mSkipAlgo->analyze(ectx, opt.get_context(), cb);
70
71 // add rate for PredMode
72
73 cb->rate += rate_pred_mode;
74 opt.set_cb(cb);
75 opt.end();
76 }
77
78 if (option_nonskip) {
79 CodingOption& opt = option_nonskip;
80 enc_cb* cb = opt.get_cb();
81
82 opt.begin();
83
84 // calc rate for skip flag (=true)
85
86 float rate_pred_mode = 0;
87
88 if (try_skip) {
89 CABAC_encoder_estim* cabac = opt.get_cabac();
90 encode_cu_skip_flag(ectx, cabac, cb, false);
91 rate_pred_mode = cabac->getRDBits();
92 cabac->reset();
93 }
94
95 cb = mNonSkipAlgo->analyze(ectx, opt.get_context(), cb);
96 // add rate for PredMode
97
98 cb->rate += rate_pred_mode;
99 opt.set_cb(cb);
100 opt.end();
101 }
102
103 options.compute_rdo_costs();
104 return options.return_best_rdo();
105 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef CB_SKIP_H
23 #define CB_SKIP_H
24
25 #include "libde265/nal-parser.h"
26 #include "libde265/decctx.h"
27 #include "libde265/encoder/encode.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 protected:
56 Algo_CB_MergeIndex* mSkipAlgo;
57 Algo_CB* mNonSkipAlgo;
58 };
59
60 class Algo_CB_Skip_BruteForce : public Algo_CB_Skip
61 {
62 public:
63 virtual enc_cb* analyze(encoder_context*,
64 context_model_table&,
65 enc_cb* cb);
66 };
67
68 #endif
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: struktur AG, Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22
23 #include "libde265/encoder/algo/cb-split.h"
24 #include "libde265/encoder/algo/coding-options.h"
25 #include "libde265/encoder/encoder-context.h"
26 #include <assert.h>
27 #include <limits>
28 #include <math.h>
29 #include <iostream>
30
31
32 // Utility function to encode all four children in a splitted CB.
33 // Children are coded with the specified algo_cb_split.
34 enc_cb* Algo_CB_Split::encode_cb_split(encoder_context* ectx,
35 context_model_table& ctxModel,
36 enc_cb* cb)
37 {
38 int w = ectx->imgdata->input->get_width();
39 int h = ectx->imgdata->input->get_height();
40
41
42 cb->split_cu_flag = true;
43
44
45 // encode all 4 children and sum their distortions and rates
46
47 for (int i=0;i<4;i++) {
48 int child_x = cb->x + ((i&1) << (cb->log2Size-1));
49 int child_y = cb->y + ((i>>1) << (cb->log2Size-1));
50
51 if (child_x>=w || child_y>=h) {
52 cb->children[i] = NULL;
53 }
54 else {
55 enc_cb* childCB = new enc_cb;
56 childCB->log2Size = cb->log2Size-1;
57 childCB->ctDepth = cb->ctDepth+1;
58
59 childCB->x = child_x;
60 childCB->y = child_y;
61
62 cb->children[i] = analyze(ectx, ctxModel, childCB);
63
64 cb->distortion += cb->children[i]->distortion;
65 cb->rate += cb->children[i]->rate;
66 }
67 }
68
69 return cb;
70 }
71
72
73
74
75 enc_cb* Algo_CB_Split_BruteForce::analyze(encoder_context* ectx,
76 context_model_table& ctxModel,
77 enc_cb* cb_input)
78 {
79 assert(cb_input->pcm_flag==0);
80
81 // --- prepare coding options ---
82
83 const SplitType split_type = get_split_type(&ectx->sps,
84 cb_input->x, cb_input->y,
85 cb_input->log2Size);
86
87
88 bool can_split_CB = (split_type != ForcedNonSplit);
89 bool can_nosplit_CB = (split_type != ForcedSplit);
90
91 //if (can_split_CB) { can_nosplit_CB=false; } // TODO TMP
92 //if (can_nosplit_CB) { can_split_CB=false; } // TODO TMP
93
94 CodingOptions options(ectx, cb_input, ctxModel);
95
96 CodingOption option_split = options.new_option(can_split_CB);
97 CodingOption option_no_split = options.new_option(can_nosplit_CB);
98
99 options.start();
100
101 // --- encode without splitting ---
102
103 if (option_no_split) {
104 CodingOption& opt = option_no_split; // abbrev.
105
106 opt.begin();
107
108 enc_cb* cb = opt.get_cb();
109
110 // set CB size in image data-structure
111 ectx->img->set_ctDepth(cb->x,cb->y,cb->log2Size, cb->ctDepth);
112 ectx->img->set_log2CbSize(cb->x,cb->y,cb->log2Size, true);
113
114 /* We set QP here, because this is required at in non-split CBs only.
115 */
116 cb->qp = ectx->active_qp;
117
118 // analyze subtree
119 assert(mChildAlgo);
120 cb = mChildAlgo->analyze(ectx, opt.get_context(), cb);
121
122 // add rate for split flag
123 if (split_type == OptionalSplit) {
124 encode_split_cu_flag(ectx,opt.get_cabac(), cb->x,cb->y, cb->ctDepth, 0);
125 cb->rate += opt.get_cabac_rate();
126 }
127
128 opt.set_cb(cb);
129 opt.end();
130 }
131
132 // --- encode with splitting ---
133
134 if (option_split) {
135 option_split.begin();
136
137 enc_cb* cb = option_split.get_cb();
138 cb = encode_cb_split(ectx, option_split.get_context(), cb);
139
140 // add rate for split flag
141 if (split_type == OptionalSplit) {
142 encode_split_cu_flag(ectx,option_split.get_cabac(), cb->x,cb->y, cb->ctDepth, 1);
143 cb->rate += option_split.get_cabac_rate();
144 }
145
146 option_split.set_cb(cb);
147 option_split.end();
148 }
149
150 options.compute_rdo_costs();
151 enc_cb* bestCB = options.return_best_rdo();
152
153 return bestCB;
154 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef CB_SPLIT_H
23 #define CB_SPLIT_H
24
25 #include "libde265/nal-parser.h"
26 #include "libde265/decctx.h"
27 #include "libde265/encoder/encode.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 protected:
68 Algo_CB* mChildAlgo;
69
70 enc_cb* encode_cb_split(encoder_context* ectx,
71 context_model_table& ctxModel,
72 enc_cb* cb);
73 };
74
75
76 class Algo_CB_Split_BruteForce : public Algo_CB_Split
77 {
78 public:
79 virtual enc_cb* analyze(encoder_context*,
80 context_model_table&,
81 enc_cb* cb);
82 };
83
84 #endif
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #include "libde265/encoder/algo/coding-options.h"
23 #include "libde265/encoder/encoder-context.h"
24
25
26 CodingOptions::CodingOptions(encoder_context* ectx, enc_cb* cb, context_model_table& tab)
27 {
28 mCBInput = cb;
29 mContextModelInput = &tab;
30
31 mCurrentlyReconstructedOption=-1;
32 mBestRDO=-1;
33
34 mECtx = ectx;
35 }
36
37 CodingOptions::~CodingOptions()
38 {
39 }
40
41 CodingOption CodingOptions::new_option(bool active)
42 {
43 if (!active) {
44 return CodingOption();
45 }
46
47
48 CodingOptionData opt;
49
50 bool firstOption = mOptions.empty();
51 if (firstOption) {
52 opt.cb = mCBInput;
53 }
54 else {
55 opt.cb = new enc_cb(*mCBInput);
56 }
57
58 opt.context = *mContextModelInput;
59
60 CodingOption option(this, mOptions.size());
61
62 mOptions.push_back( std::move(opt) );
63
64 return option;
65 }
66
67
68 void CodingOptions::start(enum RateEstimationMethod rateMethod)
69 {
70 /* We don't need the input context model anymore.
71 Releasing it now may save a copy during a later decouple().
72 */
73 mContextModelInput->release();
74
75 bool adaptiveContext;
76 switch (rateMethod) {
77 case Rate_Default:
78 adaptiveContext = mECtx->use_adaptive_context;
79 break;
80 case Rate_FixedContext:
81 adaptiveContext = false;
82 break;
83 case Rate_AdaptiveContext:
84 adaptiveContext = true;
85 break;
86 }
87
88 if (adaptiveContext) {
89 /* If we modify the context models in this algorithm,
90 we need separate models for each option.
91 */
92 for (auto& option : mOptions) {
93 option.context.decouple();
94 }
95
96 cabac = &cabac_adaptive;
97 }
98 else {
99 cabac = &cabac_constant;
100 }
101 }
102
103
104 void CodingOption::begin()
105 {
106 mParent->cabac->reset();
107 mParent->cabac->set_context_models( &get_context() );
108
109 if (mParent->mCurrentlyReconstructedOption >= 0) {
110 mParent->mOptions[mParent->mCurrentlyReconstructedOption].cb->save(mParent->mECtx->img);
111 }
112
113 mParent->mCurrentlyReconstructedOption = mOptionIdx;
114 }
115
116 void CodingOption::end()
117 {
118 assert(mParent->mCurrentlyReconstructedOption == mOptionIdx);
119 }
120
121
122 void CodingOptions::compute_rdo_costs()
123 {
124 for (int i=0;i<mOptions.size();i++) {
125 mOptions[i].rdoCost = mOptions[i].cb->distortion + mECtx->lambda * mOptions[i].cb->rate;
126 }
127 }
128
129
130 enc_cb* CodingOptions::return_best_rdo()
131 {
132 assert(mOptions.size()>0);
133
134
135 float bestRDOCost = 0;
136 bool first=true;
137 int bestRDO=-1;
138
139 for (int i=0;i<mOptions.size();i++) {
140 float cost = mOptions[i].rdoCost;
141 if (first || cost < bestRDOCost) {
142 bestRDOCost = cost;
143 first = false;
144 bestRDO = i;
145 }
146 }
147
148
149 assert(bestRDO>=0);
150
151 if (bestRDO != mCurrentlyReconstructedOption) {
152 mOptions[bestRDO].cb->restore(mECtx->img);
153 }
154
155 *mContextModelInput = mOptions[bestRDO].context;
156
157
158 // delete all CBs except the best one
159
160 for (int i=0;i<mOptions.size();i++) {
161 if (i != bestRDO)
162 {
163 delete mOptions[i].cb;
164 mOptions[i].cb = NULL;
165 }
166 }
167
168 return mOptions[bestRDO].cb;
169 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef CODING_OPTIONS_H
23 #define CODING_OPTIONS_H
24
25 #include "libde265/encoder/encode.h"
26
27
28 class CodingOption;
29
30
31 class CodingOptions
32 {
33 public:
34 CodingOptions(encoder_context*, enc_cb*, context_model_table& tab);
35 ~CodingOptions();
36
37 // --- init --- call before object use
38
39 CodingOption new_option(bool active=true);
40
41 enum RateEstimationMethod
42 {
43 Rate_Default,
44 Rate_AdaptiveContext,
45 Rate_FixedContext
46 };
47
48 void start(enum RateEstimationMethod = Rate_Default);
49
50
51 // --- processing ---
52
53 // compute RDO cost (D + lambda*R) for all options
54 void compute_rdo_costs();
55
56
57 // --- end processing --- do not call any function after this one
58
59 /* Return the CB with the lowest RDO cost. All other CBs are destroyed.
60 If the current reconstruction and metadata are not from the returned CB,
61 the data from the returned CB is reconstructed.
62 */
63 enc_cb* return_best_rdo();
64
65 private:
66 struct CodingOptionData
67 {
68 enc_cb* cb;
69 context_model_table context;
70 bool mOptionActive;
71 float rdoCost;
72 };
73
74
75 encoder_context* mECtx;
76
77 enc_cb* mCBInput;
78 context_model_table* mContextModelInput;
79
80 int mCurrentlyReconstructedOption;
81 int mBestRDO;
82
83 std::vector<CodingOptionData> mOptions;
84
85 CABAC_encoder_estim cabac_adaptive;
86 CABAC_encoder_estim_constant cabac_constant;
87 CABAC_encoder_estim* cabac;
88
89 friend class CodingOption;
90 };
91
92
93 class CodingOption
94 {
95 public:
96 CodingOption() {
97 mParent = nullptr;
98 mOptionIdx = 0;
99 }
100
101 enc_cb* get_cb() { return mParent->mOptions[mOptionIdx].cb; }
102 void set_cb(enc_cb* cb) { mParent->mOptions[mOptionIdx].cb = cb; }
103
104 context_model_table& get_context() { return mParent->mOptions[mOptionIdx].context; }
105
106 operator bool() const { return mParent; }
107
108 /* When modifying the reconstruction image or metadata, you have to
109 encapsulate the modification between these two functions to ensure
110 that the correct reconstruction will be active after return_best_rdo().
111 */
112 void begin();
113 void end();
114
115 // Manually set RDO costs instead of computing them with compute_rdo_costs.
116 // Only required when using custom costs.
117 void set_rdo_cost(float rdo) { mParent->mOptions[mOptionIdx].rdoCost=rdo; }
118
119 CABAC_encoder_estim* get_cabac() { return mParent->cabac; }
120 float get_cabac_rate() const { return mParent->cabac->getRDBits(); }
121
122 private:
123 CodingOption(class CodingOptions* parent, int idx)
124 : mParent(parent), mOptionIdx(idx) { }
125
126 class CodingOptions* mParent;
127 int mOptionIdx;
128
129 friend class CodingOptions;
130 };
131
132
133 #endif
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: struktur AG, Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22
23 #include "libde265/encoder/algo/ctb-qscale.h"
24 #include "libde265/encoder/encoder-context.h"
25 #include <assert.h>
26 #include <limits>
27 #include <math.h>
28
29
30 #define ENCODER_DEVELOPMENT 1
31
32
33 enc_cb* Algo_CTB_QScale_Constant::analyze(encoder_context* ectx,
34 context_model_table& ctxModel,
35 int ctb_x,int ctb_y)
36 {
37 enc_cb* cb = new enc_cb();
38
39 cb->log2Size = ectx->sps.Log2CtbSizeY;
40 cb->ctDepth = 0;
41 cb->x = ctb_x;
42 cb->y = ctb_y;
43
44 ectx->img->set_QPY(ctb_x,ctb_y, cb->log2Size, ectx->active_qp);
45
46 // write currently unused coding options to image
47 ectx->img->set_cu_transquant_bypass(ctb_x,ctb_y,cb->log2Size, cb->cu_transquant_bypass_flag);
48 ectx->img->set_pcm_flag(ctb_x,ctb_y,cb->log2Size, cb->pcm_flag);
49
50 assert(mChildAlgo);
51 return mChildAlgo->analyze(ectx,ctxModel,cb);
52 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef CTB_QSCALE_H
23 #define CTB_QSCALE_H
24
25 #include "libde265/nal-parser.h"
26 #include "libde265/decctx.h"
27 #include "libde265/encoder/encode.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/cb-split.h"
38
39
40 /* Encoder search tree, bottom up:
41
42 - Algo_TB_Split - whether TB is split or not
43
44 - Algo_TB_IntraPredMode - choose the intra prediction mode (or NOP, if at the wrong tree level)
45
46 - Algo_CB_IntraPartMode - choose between NxN and 2Nx2N intra parts
47
48 - Algo_CB_Split - whether CB is split or not
49
50 - Algo_CTB_QScale - select QScale on CTB granularity
51 */
52
53
54 // ========== choose a qscale at CTB level ==========
55
56 class Algo_CTB_QScale
57 {
58 public:
59 Algo_CTB_QScale() : mChildAlgo(NULL) { }
60 virtual ~Algo_CTB_QScale() { }
61
62 virtual enc_cb* analyze(encoder_context*,
63 context_model_table&,
64 int ctb_x,int ctb_y) = 0;
65
66 void setChildAlgo(Algo_CB_Split* algo) { mChildAlgo = algo; }
67
68 protected:
69 Algo_CB_Split* mChildAlgo;
70 };
71
72
73
74 class Algo_CTB_QScale_Constant : public Algo_CTB_QScale
75 {
76 public:
77 struct params
78 {
79 params() {
80 mQP.set_range(1,51);
81 mQP.set_default(27);
82 mQP.set_ID("CTB-QScale-Constant");
83 mQP.set_cmd_line_options("qp",'q');
84 }
85
86 option_int mQP;
87 };
88
89 void setParams(const params& p) { mParams=p; }
90
91 void registerParams(config_parameters& config) {
92 config.add_option(&mParams.mQP);
93 }
94
95 virtual enc_cb* analyze(encoder_context*,
96 context_model_table&,
97 int ctb_x,int ctb_y);
98
99 int getQP() const { return mParams.mQP; }
100
101 private:
102 params mParams;
103 };
104
105
106 #endif
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: struktur AG, Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22
23 #include "libde265/encoder/algo/pb-mv.h"
24 #include "libde265/encoder/algo/coding-options.h"
25 #include "libde265/encoder/encoder-context.h"
26 #include <assert.h>
27 #include <limits>
28 #include <math.h>
29
30
31
32 enc_cb* Algo_PB_MV_Test::analyze(encoder_context* ectx,
33 context_model_table& ctxModel,
34 enc_cb* cb,
35 int PBidx, int x,int y,int w,int h)
36 {
37 enum MVTestMode testMode = mParams.testMode();
38
39
40 MotionVector mvp[2];
41
42 fill_luma_motion_vector_predictors(ectx, ectx->shdr, ectx->img,
43 cb->x,cb->y,1<<cb->log2Size, x,y,w,h,
44 0, // l
45 0, 0, // int refIdx, int partIdx,
46 mvp);
47
48 //printf("%d/%d: [%d;%d] [%d;%d]\n",cb->x,cb->y, mvp[0].x,mvp[0].y, mvp[1].x,mvp[1].y);
49
50
51 motion_spec& spec = cb->inter.pb[PBidx].spec;
52 MotionVectorSpec& vec = cb->inter.pb[PBidx].motion;
53
54 spec.merge_flag = 0;
55 spec.merge_idx = 0;
56
57 spec.inter_pred_idc = PRED_L0;
58 spec.refIdx[0] = vec.refIdx[0] = 0;
59 spec.mvp_l0_flag = 0;
60
61 int value = mParams.range();
62
63 switch (testMode) {
64 case MVTestMode_Zero:
65 spec.mvd[0][0]=0;
66 spec.mvd[0][1]=0;
67 break;
68
69 case MVTestMode_Random:
70 spec.mvd[0][0] = (rand() % (2*value+1)) - value;
71 spec.mvd[0][1] = (rand() % (2*value+1)) - value;
72 break;
73
74 case MVTestMode_Horizontal:
75 spec.mvd[0][0]=value;
76 spec.mvd[0][1]=0;
77 break;
78
79 case MVTestMode_Vertical:
80 spec.mvd[0][0]=0;
81 spec.mvd[0][1]=value;
82 break;
83 }
84
85 spec.mvd[0][0] -= mvp[0].x;
86 spec.mvd[0][1] -= mvp[0].y;
87
88 vec.mv[0].x = mvp[0].x + spec.mvd[0][0];
89 vec.mv[0].y = mvp[0].y + spec.mvd[0][1];
90 vec.predFlag[0] = 1;
91 vec.predFlag[1] = 0;
92
93 ectx->img->set_mv_info(x,y,w,h, vec);
94
95 generate_inter_prediction_samples(ectx, ectx->shdr, ectx->prediction,
96 cb->x,cb->y, // int xC,int yC,
97 0,0, // int xB,int yB,
98 1<<cb->log2Size, // int nCS,
99 1<<cb->log2Size,
100 1<<cb->log2Size, // int nPbW,int nPbH,
101 &vec);
102
103 // TODO estimate rate for sending MV
104
105 int IntraSplitFlag = 0;
106 int MaxTrafoDepth = ectx->sps.max_transform_hierarchy_depth_inter;
107
108 mCodeResidual=true;
109 if (mCodeResidual) {
110 assert(mTBSplitAlgo);
111 cb->transform_tree = mTBSplitAlgo->analyze(ectx,ctxModel, ectx->imgdata->input, NULL, cb,
112 cb->x,cb->y,cb->x,cb->y, cb->log2Size,0,
113 0, MaxTrafoDepth, IntraSplitFlag);
114
115 cb->inter.rqt_root_cbf = ! cb->transform_tree->isZeroBlock();
116
117 cb->distortion = cb->transform_tree->distortion;
118 cb->rate = cb->transform_tree->rate;
119 }
120 else {
121 const de265_image* input = ectx->imgdata->input;
122 de265_image* img = ectx->prediction;
123 int x0 = cb->x;
124 int y0 = cb->y;
125 int tbSize = 1<<cb->log2Size;
126
127 cb->distortion = compute_distortion_ssd(input, img, x0,y0, cb->log2Size, 0);
128 cb->rate = 5; // fake (MV)
129
130 cb->inter.rqt_root_cbf = 0;
131 }
132
133 return cb;
134 }
135
136
137
138
139 int sad(const uint8_t* p1,int stride1,
140 const uint8_t* p2,int stride2,
141 int w,int h)
142 {
143 int cost=0;
144
145 for (int y=0;y<h;y++) {
146 for (int x=0;x<w;x++) {
147 cost += abs_value(*p1 - *p2);
148 p1++;
149 p2++;
150 }
151
152 p1 += stride1-w;
153 p2 += stride2-w;
154 }
155
156 return cost;
157 }
158
159
160 enc_cb* Algo_PB_MV_Search::analyze(encoder_context* ectx,
161 context_model_table& ctxModel,
162 enc_cb* cb,
163 int PBidx, int x,int y,int pbW,int pbH)
164 {
165 enum MVSearchAlgo searchAlgo = mParams.mvSearchAlgo();
166
167
168 MotionVector mvp[2];
169
170 fill_luma_motion_vector_predictors(ectx, ectx->shdr, ectx->img,
171 cb->x,cb->y,1<<cb->log2Size, x,y,pbW,pbH,
172 0, // l
173 0, 0, // int refIdx, int partIdx,
174 mvp);
175
176 motion_spec& spec = cb->inter.pb[PBidx].spec;
177 MotionVectorSpec& vec = cb->inter.pb[PBidx].motion;
178
179 spec.merge_flag = 0;
180 spec.merge_idx = 0;
181
182 spec.inter_pred_idc = PRED_L0;
183 spec.refIdx[0] = vec.refIdx[0] = 0;
184 spec.mvp_l0_flag = 0;
185
186 int hrange = mParams.hrange();
187 int vrange = mParams.vrange();
188
189 // previous frame (TODO)
190 const de265_image* refimg = ectx->get_image(ectx->imgdata->frame_number -1);
191 const de265_image* inputimg = ectx->imgdata->input;
192
193 int w = refimg->get_width();
194 int h = refimg->get_height();
195
196 int mincost = 0x7fffffff;
197
198 double lambda = 10.0;
199
200 double *bits_h = new double[2*hrange+1];
201 double *bits_v = new double[2*vrange+1];
202
203 for (int i=-hrange;i<=hrange;i++) {
204 int diff = (i - mvp[0].x);
205 int b;
206
207 if (diff==0) { b=0; }
208 else if (diff==1 || diff==-1) { b=2; }
209 else { b=abs_value(b+2); }
210
211 bits_h[i+hrange]=b;
212 }
213
214 for (int i=-vrange;i<=vrange;i++) {
215 int diff = (i - mvp[0].y);
216 int b;
217
218 if (diff==0) { b=0; }
219 else if (diff==1 || diff==-1) { b=2; }
220 else { b=abs_value(b+2); }
221
222 bits_v[i+vrange]=b;
223 }
224
225 for (int my = y-vrange; my<=y+vrange; my++)
226 for (int mx = x-hrange; mx<=x+hrange; mx++)
227 {
228 if (mx<0 || mx+pbW>w || my<0 || my+pbH>h) continue;
229
230 int cost = sad(refimg->get_image_plane_at_pos(0,mx,my),
231 refimg->get_image_stride(0),
232 inputimg->get_image_plane_at_pos(0,x,y),
233 inputimg->get_image_stride(0),
234 pbW,pbH);
235
236 int bits = bits_h[mx-x+hrange] + bits_v[my-y+vrange];
237
238 cost += lambda * bits;
239
240 //printf("%d %d : %d\n",mx,my,cost);
241
242 if (cost<mincost) {
243 mincost=cost;
244
245 spec.mvd[0][0]=(mx-x)<<2;
246 spec.mvd[0][1]=(my-y)<<2;
247 }
248 }
249
250 spec.mvd[0][0] -= mvp[0].x;
251 spec.mvd[0][1] -= mvp[0].y;
252
253 vec.mv[0].x = mvp[0].x + spec.mvd[0][0];
254 vec.mv[0].y = mvp[0].y + spec.mvd[0][1];
255 vec.predFlag[0] = 1;
256 vec.predFlag[1] = 0;
257
258 ectx->img->set_mv_info(x,y,pbW,pbH, vec);
259
260 generate_inter_prediction_samples(ectx, ectx->shdr, ectx->prediction,
261 cb->x,cb->y, // int xC,int yC,
262 0,0, // int xB,int yB,
263 1<<cb->log2Size, // int nCS,
264 1<<cb->log2Size,
265 1<<cb->log2Size, // int nPbW,int nPbH,
266 &vec);
267
268 // --- create residual ---
269
270
271
272 // TODO estimate rate for sending MV
273
274 int IntraSplitFlag = 0;
275 int MaxTrafoDepth = ectx->sps.max_transform_hierarchy_depth_inter;
276
277 mCodeResidual=true;
278 if (mCodeResidual) {
279 cb->transform_tree = mTBSplitAlgo->analyze(ectx,ctxModel, ectx->imgdata->input, NULL, cb,
280 cb->x,cb->y,cb->x,cb->y, cb->log2Size,0,
281 0, MaxTrafoDepth, IntraSplitFlag);
282
283 cb->inter.rqt_root_cbf = ! cb->transform_tree->isZeroBlock();
284
285 cb->distortion = cb->transform_tree->distortion;
286 cb->rate = cb->transform_tree->rate;
287 }
288 else {
289 const de265_image* input = ectx->imgdata->input;
290 de265_image* img = ectx->img;
291 int x0 = cb->x;
292 int y0 = cb->y;
293 int tbSize = 1<<cb->log2Size;
294
295 cb->distortion = compute_distortion_ssd(input, img, x0,y0, cb->log2Size, 0);
296 cb->rate = 5; // fake (MV)
297
298 cb->inter.rqt_root_cbf = 0;
299 }
300
301 delete[] bits_h;
302 delete[] bits_v;
303
304 return cb;
305 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef PB_MV_H
23 #define PB_MV_H
24
25 #include "libde265/nal-parser.h"
26 #include "libde265/decctx.h"
27 #include "libde265/encoder/encode.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
39
40 // ========== CB Intra/Inter decision ==========
41
42 class Algo_TB_Split;
43
44
45 class Algo_PB_MV : public Algo_PB
46 {
47 public:
48 Algo_PB_MV() : mTBSplitAlgo(NULL) { }
49 virtual ~Algo_PB_MV() { }
50
51 void setChildAlgo(Algo_TB_Split* algo) { mTBSplitAlgo = algo; }
52
53 protected:
54 Algo_TB_Split* mTBSplitAlgo;
55 };
56
57
58
59
60 enum MVTestMode
61 {
62 MVTestMode_Zero,
63 MVTestMode_Random,
64 MVTestMode_Horizontal,
65 MVTestMode_Vertical
66 };
67
68 class option_MVTestMode : public choice_option<enum MVTestMode>
69 {
70 public:
71 option_MVTestMode() {
72 add_choice("zero", MVTestMode_Zero);
73 add_choice("random", MVTestMode_Random);
74 add_choice("horiz", MVTestMode_Horizontal, true);
75 add_choice("verti", MVTestMode_Vertical);
76 }
77 };
78
79
80 class Algo_PB_MV_Test : public Algo_PB_MV
81 {
82 public:
83 Algo_PB_MV_Test() : mCodeResidual(false) { }
84
85 struct params
86 {
87 params() {
88 testMode.set_ID("PB-MV-TestMode");
89 range.set_ID ("PB-MV-Range");
90 range.set_default(4);
91 }
92
93 option_MVTestMode testMode;
94 option_int range;
95 };
96
97 void registerParams(config_parameters& config) {
98 config.add_option(&mParams.testMode);
99 config.add_option(&mParams.range);
100 }
101
102 void setParams(const params& p) { mParams=p; }
103
104 virtual enc_cb* analyze(encoder_context*,
105 context_model_table&,
106 enc_cb* cb,
107 int PBidx, int x,int y,int w,int h);
108
109 private:
110 params mParams;
111
112 bool mCodeResidual;
113 };
114
115
116
117
118 enum MVSearchAlgo
119 {
120 MVSearchAlgo_Zero,
121 MVSearchAlgo_Full,
122 MVSearchAlgo_Diamond,
123 MVSearchAlgo_PMVFast
124 };
125
126 class option_MVSearchAlgo : public choice_option<enum MVSearchAlgo>
127 {
128 public:
129 option_MVSearchAlgo() {
130 add_choice("zero", MVSearchAlgo_Zero);
131 add_choice("full", MVSearchAlgo_Full, true);
132 add_choice("diamond",MVSearchAlgo_Diamond);
133 add_choice("pmvfast",MVSearchAlgo_PMVFast);
134 }
135 };
136
137
138 class Algo_PB_MV_Search : public Algo_PB_MV
139 {
140 public:
141 Algo_PB_MV_Search() : mCodeResidual(false) { }
142
143 struct params
144 {
145 params() {
146 mvSearchAlgo.set_ID("PB-MV-Search-Algo");
147 hrange.set_ID ("PB-MV-Search-HRange");
148 vrange.set_ID ("PB-MV-Search-VRange");
149 hrange.set_default(8);
150 vrange.set_default(8);
151 }
152
153 option_MVSearchAlgo mvSearchAlgo;
154 option_int hrange;
155 option_int vrange;
156 };
157
158 void registerParams(config_parameters& config) {
159 config.add_option(&mParams.mvSearchAlgo);
160 config.add_option(&mParams.hrange);
161 config.add_option(&mParams.vrange);
162 }
163
164 void setParams(const params& p) { mParams=p; }
165
166 virtual enc_cb* analyze(encoder_context*,
167 context_model_table&,
168 enc_cb* cb,
169 int PBidx, int x,int y,int w,int h);
170
171 private:
172 params mParams;
173
174 bool mCodeResidual;
175 };
176
177 #endif
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: struktur AG, Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22
23 #include "libde265/encoder/analyze.h"
24 #include "libde265/encoder/encoder-context.h"
25 #include "libde265/encoder/algo/tb-split.h"
26 #include <assert.h>
27 #include <limits>
28 #include <math.h>
29 #include <algorithm>
30 #include <iostream>
31
32
33 enum IntraPredMode find_best_intra_mode(de265_image& img,int x0,int y0, int log2BlkSize, int cIdx,
34 const uint8_t* ref, int stride)
35 {
36 //return INTRA_ANGULAR_20;
37
38 enum IntraPredMode best_mode;
39 int min_sad=-1;
40
41 int candidates[3];
42
43 const seq_parameter_set* sps = &img.sps;
44
45
46 fillIntraPredModeCandidates(candidates, x0,y0,
47 sps->getPUIndexRS(x0,y0),
48 x0>0, y0>0, &img);
49
50 // --- test candidates first ---
51
52 for (int idx=0;idx<3;idx++) {
53 enum IntraPredMode mode = (enum IntraPredMode)candidates[idx];
54 decode_intra_prediction(&img, x0,y0, (enum IntraPredMode)mode, 1<<log2BlkSize, cIdx);
55
56 uint32_t distortion = SSD(ref,stride,
57 img.get_image_plane_at_pos(cIdx, x0,y0), img.get_image_stride(cIdx),
58 1<<log2BlkSize, 1<<log2BlkSize);
59
60 int sad=distortion;
61
62 sad *= 0.5;
63 //sad *= 0.9;
64
65 if (mode==0 || sad<min_sad) {
66 min_sad = sad;
67 best_mode = (enum IntraPredMode)mode;
68 }
69 }
70
71
72 // --- test all modes ---
73
74 for (int idx=0;idx<35;idx++) {
75 enum IntraPredMode mode = (enum IntraPredMode)idx; //candidates[idx];
76 decode_intra_prediction(&img, x0,y0, (enum IntraPredMode)mode, 1<<log2BlkSize, cIdx);
77
78
79 uint32_t distortion = SSD(ref,stride,
80 img.get_image_plane_at_pos(cIdx, x0,y0), img.get_image_stride(cIdx),
81 1<<log2BlkSize, 1<<log2BlkSize);
82
83 int sad=distortion;
84
85 if (min_sad<0 || sad<min_sad) {
86 min_sad = sad;
87 best_mode = (enum IntraPredMode)mode;
88 }
89 }
90
91 return best_mode;
92 }
93
94
95
96
97 float estim_TB_bitrate(const encoder_context* ectx,
98 const de265_image* input,
99 int x0,int y0, int log2BlkSize,
100 enum TBBitrateEstimMethod method)
101 {
102 int blkSize = 1<<log2BlkSize;
103
104 float distortion;
105
106 switch (method)
107 {
108 case TBBitrateEstim_SSD:
109 return SSD(input->get_image_plane_at_pos(0, x0,y0),
110 input->get_image_stride(0),
111 ectx->img->get_image_plane_at_pos(0, x0,y0),
112 ectx->img->get_image_stride(0),
113 1<<log2BlkSize, 1<<log2BlkSize);
114 break;
115
116 case TBBitrateEstim_SAD:
117 return SAD(input->get_image_plane_at_pos(0, x0,y0),
118 input->get_image_stride(0),
119 ectx->img->get_image_plane_at_pos(0, x0,y0),
120 ectx->img->get_image_stride(0),
121 1<<log2BlkSize, 1<<log2BlkSize);
122 break;
123
124 case TBBitrateEstim_SATD_DCT:
125 case TBBitrateEstim_SATD_Hadamard:
126 {
127 int16_t coeffs[32*32];
128 int16_t diff[32*32];
129
130 diff_blk(diff,blkSize,
131 input->get_image_plane_at_pos(0, x0,y0), input->get_image_stride(0),
132 ectx->img->get_image_plane_at_pos(0, x0,y0), ectx->img->get_image_stride(0),
133 blkSize);
134
135 if (method == TBBitrateEstim_SATD_Hadamard) {
136 ectx->acceleration.hadamard_transform_8[log2BlkSize-2](coeffs, diff, &diff[blkSize] - &diff[0]);
137 }
138 else {
139 ectx->acceleration.fwd_transform_8[log2BlkSize-2](coeffs, diff, &diff[blkSize] - &diff[0]);
140 }
141
142 float distortion=0;
143 for (int i=0;i<blkSize*blkSize;i++) {
144 distortion += abs_value((int)coeffs[i]);
145 }
146
147 return distortion;
148 }
149 break;
150
151 /*
152 case TBBitrateEstim_AccurateBits:
153 assert(false);
154 return 0;
155 */
156 }
157
158 assert(false);
159 return 0;
160 }
161
162
163
164 enc_tb*
165 Algo_TB_IntraPredMode_BruteForce::analyze(encoder_context* ectx,
166 context_model_table& ctxModel,
167 const de265_image* input,
168 const enc_tb* parent,
169 enc_cb* cb,
170 int x0,int y0, int xBase,int yBase,
171 int log2TbSize, int blkIdx,
172 int TrafoDepth, int MaxTrafoDepth,
173 int IntraSplitFlag)
174 {
175 //printf("encode_transform_tree_may_split %d %d (%d %d) size %d\n",x0,y0,xBase,yBase,1<<log2TbSize);
176
177 /*
178 enum IntraPredMode pre_intraMode = find_best_intra_mode(ectx->img,x0,y0, log2TbSize, 0,
179 input->get_image_plane_at_pos(0,x0,y0),
180 input->get_image_stride(0));
181 */
182
183 bool selectIntraPredMode = false;
184 selectIntraPredMode |= (cb->PredMode==MODE_INTRA && cb->PartMode==PART_2Nx2N && TrafoDepth==0);
185 selectIntraPredMode |= (cb->PredMode==MODE_INTRA && cb->PartMode==PART_NxN && TrafoDepth==1);
186
187 if (selectIntraPredMode) {
188 enc_tb* tb[35];
189
190 float minCost = std::numeric_limits<float>::max();
191 int minCostIdx=0;
192 float minCandCost;
193
194 const de265_image* img = ectx->img;
195 const seq_parameter_set* sps = &img->sps;
196 int candidates[3];
197 fillIntraPredModeCandidates(candidates, x0,y0,
198 sps->getPUIndexRS(x0,y0),
199 x0>0, y0>0, img);
200
201
202 for (int i = 0; i<35; i++) {
203 if (!mPredMode_enabled[i]) {
204 tb[i]=NULL;
205 continue;
206 }
207
208
209 context_model_table ctxIntra = ctxModel.copy();
210 //copy_context_model_table(ctxIntra, ctxModel);
211
212 enum IntraPredMode intraMode = (IntraPredMode)i;
213
214 cb->intra.pred_mode[blkIdx] = intraMode;
215 if (blkIdx==0) { cb->intra.chroma_mode = intraMode; }
216
217 ectx->img->set_IntraPredMode(x0,y0,log2TbSize, intraMode);
218
219 tb[intraMode] = mTBSplitAlgo->analyze(ectx,ctxIntra,input,parent,
220 cb, x0,y0, xBase,yBase, log2TbSize, blkIdx,
221 TrafoDepth, MaxTrafoDepth, IntraSplitFlag);
222
223
224 float sad;
225 if ((1<<log2TbSize)==8) {
226 decode_intra_prediction(ectx->img, x0,y0, intraMode, 1<<log2TbSize, 0);
227 sad = estim_TB_bitrate(ectx,input, x0,y0, log2TbSize, TBBitrateEstim_SAD);
228 }
229
230
231 float rate = tb[intraMode]->rate;
232 int enc_bin;
233
234 if (log2TbSize==3) {
235 // printf("RATE2 %d %f %f\n",log2TbSize,tb[intraMode]->rate,sad);
236 }
237
238 /**/ if (candidates[0]==intraMode) { rate += 1; enc_bin=1; }
239 else if (candidates[1]==intraMode) { rate += 2; enc_bin=1; }
240 else if (candidates[2]==intraMode) { rate += 2; enc_bin=1; }
241 else { rate += 5; enc_bin=0; }
242
243 CABAC_encoder_estim estim;
244 estim.set_context_models(&ctxIntra);
245 rate += estim.RDBits_for_CABAC_bin(CONTEXT_MODEL_PREV_INTRA_LUMA_PRED_FLAG, enc_bin);
246
247 float cost = tb[intraMode]->distortion + ectx->lambda * rate;
248 if (cost<minCost) {
249 minCost=cost;
250 minCostIdx=intraMode;
251 //minCandCost=c;
252 }
253 }
254
255
256 enum IntraPredMode intraMode = (IntraPredMode)minCostIdx;
257
258 cb->intra.pred_mode[blkIdx] = intraMode;
259 if (blkIdx==0) { cb->intra.chroma_mode = intraMode; } //INTRA_CHROMA_LIKE_LUMA;
260 ectx->img->set_IntraPredMode(x0,y0,log2TbSize, intraMode);
261
262 tb[minCostIdx]->reconstruct(ectx, ectx->img,
263 cb, blkIdx);
264
265
266 //printf("INTRA %d %d %d\n",pre_intraMode,intraMode,minCandCost);
267
268 for (int i = 0; i<35; i++) {
269 if (i != minCostIdx) {
270 delete tb[i];
271 }
272 }
273
274 return tb[minCostIdx];
275 }
276 else {
277 return mTBSplitAlgo->analyze(ectx, ctxModel, input, parent, cb,
278 x0,y0,xBase,yBase, log2TbSize,
279 blkIdx, TrafoDepth, MaxTrafoDepth,
280 IntraSplitFlag);
281 }
282
283 assert(false);
284 return nullptr;
285 }
286
287
288
289 enc_tb*
290 Algo_TB_IntraPredMode_MinResidual::analyze(encoder_context* ectx,
291 context_model_table& ctxModel,
292 const de265_image* input,
293 const enc_tb* parent,
294 enc_cb* cb,
295 int x0,int y0, int xBase,int yBase,
296 int log2TbSize, int blkIdx,
297 int TrafoDepth, int MaxTrafoDepth,
298 int IntraSplitFlag)
299 {
300
301 bool selectIntraPredMode = false;
302 selectIntraPredMode |= (cb->PredMode==MODE_INTRA && cb->PartMode==PART_2Nx2N && TrafoDepth==0);
303 selectIntraPredMode |= (cb->PredMode==MODE_INTRA && cb->PartMode==PART_NxN && TrafoDepth==1);
304
305 if (selectIntraPredMode) {
306
307 enum IntraPredMode intraMode;
308 float minDistortion;
309
310 for (int idx=0;idx<35;idx++) {
311 enum IntraPredMode mode = (enum IntraPredMode)idx;
312 decode_intra_prediction(ectx->img, x0,y0, (enum IntraPredMode)mode, 1<<log2TbSize, 0);
313
314 float distortion;
315 distortion = estim_TB_bitrate(ectx, input, x0,y0, log2TbSize,
316 mParams.bitrateEstimMethod());
317
318 if (idx==0 || distortion<minDistortion) {
319 minDistortion = distortion;
320 intraMode = mode;
321 }
322 }
323
324
325 cb->intra.pred_mode[blkIdx] = intraMode;
326 if (blkIdx==0) { cb->intra.chroma_mode = intraMode; }
327
328 ectx->img->set_IntraPredMode(x0,y0,log2TbSize, intraMode);
329
330 /*
331 decode_intra_prediction(ectx->img, x0,y0, intraMode, 1<< log2TbSize, 0);
332 decode_intra_prediction(ectx->img, x0>>1,y0>>1, intraMode, 1<<(log2TbSize-1), 1);
333 decode_intra_prediction(ectx->img, x0>>1,y0>>1, intraMode, 1<<(log2TbSize-1), 2);
334 */
335
336 // Note: cannot prepare intra prediction pixels here, because this has to
337 // be done at the lowest TB split level.
338
339 enc_tb* tb = mTBSplitAlgo->analyze(ectx,ctxModel,input,parent,
340 cb, x0,y0, xBase,yBase, log2TbSize, blkIdx,
341 TrafoDepth, MaxTrafoDepth, IntraSplitFlag);
342
343 debug_show_image(ectx->img, 0);
344
345 return tb;
346 }
347 else {
348 return mTBSplitAlgo->analyze(ectx, ctxModel, input, parent, cb,
349 x0,y0,xBase,yBase, log2TbSize,
350 blkIdx, TrafoDepth, MaxTrafoDepth,
351 IntraSplitFlag);
352 }
353
354 assert(false);
355 return nullptr;
356 }
357
358 static bool sortDistortions(std::pair<enum IntraPredMode,float> i,
359 std::pair<enum IntraPredMode,float> j)
360 {
361 return i.second < j.second;
362 }
363
364 enc_tb*
365 Algo_TB_IntraPredMode_FastBrute::analyze(encoder_context* ectx,
366 context_model_table& ctxModel,
367 const de265_image* input,
368 const enc_tb* parent,
369 enc_cb* cb,
370 int x0,int y0, int xBase,int yBase,
371 int log2TbSize, int blkIdx,
372 int TrafoDepth, int MaxTrafoDepth,
373 int IntraSplitFlag)
374 {
375 //printf("encode_transform_tree_may_split %d %d (%d %d) size %d\n",x0,y0,xBase,yBase,1<<log2TbSize);
376
377 /*
378 enum IntraPredMode pre_intraMode = find_best_intra_mode(ectx->img,x0,y0, log2TbSize, 0,
379 input->get_image_plane_at_pos(0,x0,y0),
380 input->get_image_stride(0));
381 */
382
383 bool selectIntraPredMode = false;
384 selectIntraPredMode |= (cb->PredMode==MODE_INTRA && cb->PartMode==PART_2Nx2N && TrafoDepth==0);
385 selectIntraPredMode |= (cb->PredMode==MODE_INTRA && cb->PartMode==PART_NxN && TrafoDepth==1);
386
387 if (selectIntraPredMode) {
388 float minCost = std::numeric_limits<float>::max();
389 int minCostIdx=0;
390 float minCandCost;
391
392 const de265_image* img = ectx->img;
393 const seq_parameter_set* sps = &img->sps;
394 int candidates[3];
395 fillIntraPredModeCandidates(candidates, x0,y0,
396 sps->getPUIndexRS(x0,y0),
397 x0>0, y0>0, img);
398
399
400
401 std::vector< std::pair<enum IntraPredMode,float> > distortions;
402
403 for (int idx=0;idx<35;idx++)
404 if (idx!=candidates[0] && idx!=candidates[1] && idx!=candidates[2] && mPredMode_enabled[idx])
405 {
406 enum IntraPredMode mode = (enum IntraPredMode)idx;
407 decode_intra_prediction(ectx->img, x0,y0, (enum IntraPredMode)mode, 1<<log2TbSize, 0);
408
409 float distortion;
410 distortion = estim_TB_bitrate(ectx, input, x0,y0, log2TbSize,
411 mParams.bitrateEstimMethod());
412
413 distortions.push_back( std::make_pair((enum IntraPredMode)idx, distortion) );
414 }
415
416 std::sort( distortions.begin(), distortions.end(), sortDistortions );
417
418
419 for (int i=0;i<distortions.size();i++)
420 {
421 //printf("%d -> %f\n",i,distortions[i].second);
422 }
423
424 int keepNBest=std::min((int)mParams.keepNBest, (int)distortions.size());
425 distortions.resize(keepNBest);
426 distortions.push_back(std::make_pair((enum IntraPredMode)candidates[0],0));
427 distortions.push_back(std::make_pair((enum IntraPredMode)candidates[1],0));
428 distortions.push_back(std::make_pair((enum IntraPredMode)candidates[2],0));
429
430
431 enc_tb* tb[35];
432 context_model_table contexts[35];
433
434 for (int i=0;i<35;i++) tb[i]=NULL;
435
436 for (int i=0;i<distortions.size();i++) {
437
438 //copy_context_model_table(ctxIntra, ctxModel);
439
440 enum IntraPredMode intraMode = (IntraPredMode)distortions[i].first;
441
442 if (!mPredMode_enabled[intraMode]) { continue; }
443
444 cb->intra.pred_mode[blkIdx] = intraMode;
445 if (blkIdx==0) { cb->intra.chroma_mode = intraMode; }
446
447 ectx->img->set_IntraPredMode(x0,y0,log2TbSize, intraMode);
448
449 contexts[intraMode] = ctxModel.copy();
450 tb[intraMode] = mTBSplitAlgo->analyze(ectx,contexts[intraMode],input,parent,
451 cb, x0,y0, xBase,yBase, log2TbSize, blkIdx,
452 TrafoDepth, MaxTrafoDepth, IntraSplitFlag);
453
454 float rate = tb[intraMode]->rate_withoutCbfChroma;
455 int enc_bin;
456
457 /**/ if (candidates[0]==intraMode) { rate += 1; enc_bin=1; }
458 else if (candidates[1]==intraMode) { rate += 2; enc_bin=1; }
459 else if (candidates[2]==intraMode) { rate += 2; enc_bin=1; }
460 else { rate += 5; enc_bin=0; }
461
462 CABAC_encoder_estim estim;
463 estim.set_context_models(&contexts[intraMode]);
464 //rate += estim.RDBits_for_CABAC_bin(CONTEXT_MODEL_PREV_INTRA_LUMA_PRED_FLAG, enc_bin);
465 logtrace(LogSymbols,"$1 prev_intra_luma_pred_flag=%d\n",enc_bin);
466 estim.write_CABAC_bit(CONTEXT_MODEL_PREV_INTRA_LUMA_PRED_FLAG, enc_bin);
467
468 // TODO: currently we make the chroma-pred-mode decision for each part even
469 // in NxN part mode. Since we always set this to the same value, it does not
470 // matter. However, we should only add the rate for it once (for blkIdx=0).
471
472 if (blkIdx==0) {
473 logtrace(LogSymbols,"$1 intra_chroma_pred_mode=%d\n",0);
474 estim.write_CABAC_bit(CONTEXT_MODEL_INTRA_CHROMA_PRED_MODE,0);
475 }
476 rate += estim.getRDBits();
477
478 float cbfRate = tb[intraMode]->rate - tb[intraMode]->rate_withoutCbfChroma;
479 tb[intraMode]->rate_withoutCbfChroma = rate;
480 tb[intraMode]->rate = tb[intraMode]->rate_withoutCbfChroma + cbfRate;
481
482 //printf("QQQ %f %f\n", b, estim.getRDBits());
483
484 float cost = tb[intraMode]->distortion + ectx->lambda * rate;
485
486 //printf("idx:%d mode:%d cost:%f\n",i,intraMode,cost);
487
488 if (cost<minCost) {
489 minCost=cost;
490 minCostIdx=intraMode;
491 //minCandCost=c;
492 }
493 }
494
495
496 enum IntraPredMode intraMode = (IntraPredMode)minCostIdx;
497
498 cb->intra.pred_mode[blkIdx] = intraMode;
499 if (blkIdx==0) { cb->intra.chroma_mode = intraMode; } //INTRA_CHROMA_LIKE_LUMA;
500 ectx->img->set_IntraPredMode(x0,y0,log2TbSize, intraMode);
501
502 tb[minCostIdx]->reconstruct(ectx, ectx->img, cb, blkIdx);
503 ctxModel = contexts[minCostIdx];
504
505 for (int i = 0; i<35; i++) {
506 if (i != minCostIdx) {
507 delete tb[i];
508 }
509 }
510
511 return tb[minCostIdx];
512 }
513 else {
514 return mTBSplitAlgo->analyze(ectx, ctxModel, input, parent, cb,
515 x0,y0,xBase,yBase, log2TbSize,
516 blkIdx, TrafoDepth, MaxTrafoDepth,
517 IntraSplitFlag);
518
519 }
520
521 assert(false);
522 return nullptr;
523 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef TB_INTRAPREDMODE_H
23 #define TB_INTRAPREDMODE_H
24
25 #include "libde265/nal-parser.h"
26 #include "libde265/decctx.h"
27 #include "libde265/encoder/encode.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
38 /* Encoder search tree, bottom up:
39
40 - Algo_TB_Split - whether TB is split or not
41
42 - Algo_TB_IntraPredMode - choose the intra prediction mode (or NOP, if at the wrong tree level)
43
44 - Algo_CB_IntraPartMode - choose between NxN and 2Nx2N intra parts
45
46 - Algo_CB_Split - whether CB is split or not
47
48 - Algo_CTB_QScale - select QScale on CTB granularity
49 */
50
51
52 // ========== TB intra prediction mode ==========
53
54 enum ALGO_TB_IntraPredMode {
55 ALGO_TB_IntraPredMode_BruteForce,
56 ALGO_TB_IntraPredMode_FastBrute,
57 ALGO_TB_IntraPredMode_MinResidual
58 };
59
60 class option_ALGO_TB_IntraPredMode : public choice_option<enum ALGO_TB_IntraPredMode>
61 {
62 public:
63 option_ALGO_TB_IntraPredMode() {
64 add_choice("min-residual",ALGO_TB_IntraPredMode_MinResidual);
65 add_choice("brute-force" ,ALGO_TB_IntraPredMode_BruteForce);
66 add_choice("fast-brute" ,ALGO_TB_IntraPredMode_FastBrute, true);
67 }
68 };
69
70
71 enum TBBitrateEstimMethod {
72 //TBBitrateEstim_AccurateBits,
73 TBBitrateEstim_SSD,
74 TBBitrateEstim_SAD,
75 TBBitrateEstim_SATD_DCT,
76 TBBitrateEstim_SATD_Hadamard
77 };
78
79 class option_TBBitrateEstimMethod : public choice_option<enum TBBitrateEstimMethod>
80 {
81 public:
82 option_TBBitrateEstimMethod() {
83 add_choice("ssd",TBBitrateEstim_SSD);
84 add_choice("sad",TBBitrateEstim_SAD);
85 add_choice("satd-dct",TBBitrateEstim_SATD_DCT);
86 add_choice("satd",TBBitrateEstim_SATD_Hadamard, true);
87 }
88 };
89
90 class Algo_TB_Split;
91
92
93 /** Base class for intra prediction-mode algorithms.
94 Selects one of the 35 prediction modes.
95 */
96 class Algo_TB_IntraPredMode
97 {
98 public:
99 Algo_TB_IntraPredMode() : mTBSplitAlgo(NULL) { }
100 virtual ~Algo_TB_IntraPredMode() { }
101
102 virtual enc_tb* analyze(encoder_context*,
103 context_model_table&,
104 const de265_image* input,
105 const enc_tb* parent,
106 enc_cb* cb,
107 int x0,int y0, int xBase,int yBase, int log2TbSize,
108 int blkIdx,
109 int TrafoDepth, int MaxTrafoDepth, int IntraSplitFlag) = 0;
110
111 void setChildAlgo(Algo_TB_Split* algo) { mTBSplitAlgo = algo; }
112
113 protected:
114 Algo_TB_Split* mTBSplitAlgo;
115 };
116
117
118 enum ALGO_TB_IntraPredMode_Subset {
119 ALGO_TB_IntraPredMode_Subset_All,
120 ALGO_TB_IntraPredMode_Subset_HVPlus,
121 ALGO_TB_IntraPredMode_Subset_DC,
122 ALGO_TB_IntraPredMode_Subset_Planar
123 };
124
125 class option_ALGO_TB_IntraPredMode_Subset : public choice_option<enum ALGO_TB_IntraPredMode_Subset>
126 {
127 public:
128 option_ALGO_TB_IntraPredMode_Subset() {
129 add_choice("all" ,ALGO_TB_IntraPredMode_Subset_All, true);
130 add_choice("HV+" ,ALGO_TB_IntraPredMode_Subset_HVPlus);
131 add_choice("DC" ,ALGO_TB_IntraPredMode_Subset_DC);
132 add_choice("planar",ALGO_TB_IntraPredMode_Subset_Planar);
133 }
134 };
135
136
137 /** Utility class for intra prediction-mode algorithm that uses a subset of modes.
138 */
139 class Algo_TB_IntraPredMode_ModeSubset : public Algo_TB_IntraPredMode
140 {
141 public:
142 Algo_TB_IntraPredMode_ModeSubset() {
143 for (int i=0;i<35;i++) {
144 mPredMode_enabled[i] = true;
145 }
146 }
147
148 void disableAllIntraPredModes() {
149 for (int i=0;i<35;i++) {
150 mPredMode_enabled[i] = false;
151 }
152 }
153
154 void enableIntraPredMode(int mode, bool flag=true) {
155 mPredMode_enabled[mode] = flag;
156 }
157
158 void enableIntraPredModeSubset(enum ALGO_TB_IntraPredMode_Subset subset) {
159 switch (subset)
160 {
161 case ALGO_TB_IntraPredMode_Subset_All: // activate all is the default
162 for (int i=0;i<35;i++) { enableIntraPredMode(i); }
163 break;
164 case ALGO_TB_IntraPredMode_Subset_DC:
165 disableAllIntraPredModes();
166 enableIntraPredMode(INTRA_DC);
167 break;
168 case ALGO_TB_IntraPredMode_Subset_Planar:
169 disableAllIntraPredModes();
170 enableIntraPredMode(INTRA_PLANAR);
171 break;
172 case ALGO_TB_IntraPredMode_Subset_HVPlus:
173 disableAllIntraPredModes();
174 enableIntraPredMode(INTRA_DC);
175 enableIntraPredMode(INTRA_PLANAR);
176 enableIntraPredMode(INTRA_ANGULAR_10);
177 enableIntraPredMode(INTRA_ANGULAR_26);
178 break;
179 }
180 }
181
182 protected:
183 bool mPredMode_enabled[35];
184 };
185
186
187 /** Algorithm that brute-forces through all intra prediction mode.
188 */
189 class Algo_TB_IntraPredMode_BruteForce : public Algo_TB_IntraPredMode_ModeSubset
190 {
191 public:
192
193 virtual enc_tb* analyze(encoder_context*,
194 context_model_table&,
195 const de265_image* input,
196 const enc_tb* parent,
197 enc_cb* cb,
198 int x0,int y0, int xBase,int yBase, int log2TbSize,
199 int blkIdx,
200 int TrafoDepth, int MaxTrafoDepth, int IntraSplitFlag);
201 };
202
203
204 /** Algorithm that makes a quick pre-selection of modes and then brute-forces through them.
205 */
206 class Algo_TB_IntraPredMode_FastBrute : public Algo_TB_IntraPredMode_ModeSubset
207 {
208 public:
209
210 struct params
211 {
212 params() {
213 keepNBest.set_ID("IntraPredMode-FastBrute-keepNBest");
214 keepNBest.set_range(0,32);
215 keepNBest.set_default(5);
216
217 bitrateEstimMethod.set_ID("IntraPredMode-FastBrute-estimator");
218 }
219
220 option_TBBitrateEstimMethod bitrateEstimMethod;
221 option_int keepNBest;
222 };
223
224 void registerParams(config_parameters& config) {
225 config.add_option(&mParams.keepNBest);
226 config.add_option(&mParams.bitrateEstimMethod);
227 }
228
229 void setParams(const params& p) { mParams=p; }
230
231
232 virtual enc_tb* analyze(encoder_context*,
233 context_model_table&,
234 const de265_image* input,
235 const enc_tb* parent,
236 enc_cb* cb,
237 int x0,int y0, int xBase,int yBase, int log2TbSize,
238 int blkIdx,
239 int TrafoDepth, int MaxTrafoDepth, int IntraSplitFlag);
240
241 private:
242 params mParams;
243 };
244
245
246 /** Algorithm that selects the intra prediction mode on minimum residual only.
247 */
248 class Algo_TB_IntraPredMode_MinResidual : public Algo_TB_IntraPredMode_ModeSubset
249 {
250 public:
251
252 struct params
253 {
254 params() {
255 bitrateEstimMethod.set_ID("IntraPredMode-MinResidual-estimator");
256 }
257
258 option_TBBitrateEstimMethod bitrateEstimMethod;
259 };
260
261 void setParams(const params& p) { mParams=p; }
262
263 void registerParams(config_parameters& config) {
264 config.add_option(&mParams.bitrateEstimMethod);
265 }
266
267 virtual enc_tb* analyze(encoder_context*,
268 context_model_table&,
269 const de265_image* input,
270 const enc_tb* parent,
271 enc_cb* cb,
272 int x0,int y0, int xBase,int yBase, int log2TbSize,
273 int blkIdx,
274 int TrafoDepth, int MaxTrafoDepth, int IntraSplitFlag);
275
276 private:
277 params mParams;
278 };
279
280 #endif
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: struktur AG, Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22
23 #include "libde265/encoder/analyze.h"
24 #include "libde265/encoder/encoder-context.h"
25 #include <assert.h>
26 #include <limits>
27 #include <math.h>
28 #include <iostream>
29
30
31 #define ENCODER_DEVELOPMENT 1
32
33
34 void diff_blk(int16_t* out,int out_stride,
35 const uint8_t* a_ptr, int a_stride,
36 const uint8_t* b_ptr, int b_stride,
37 int blkSize)
38 {
39 for (int by=0;by<blkSize;by++)
40 for (int bx=0;bx<blkSize;bx++)
41 {
42 out[by*out_stride+bx] = a_ptr[by*a_stride+bx] - b_ptr[by*b_stride+bx];
43 }
44 }
45
46
47 static bool has_nonzero_value(const int16_t* data, int n)
48 {
49 for (int i=0;i<n;i++)
50 if (data[i]) return true;
51
52 return false;
53 }
54
55
56 void show_debug_image(const de265_image* input, int slot);
57
58 /*
59 void encode_transform_unit(encoder_context* ectx,
60 enc_tb* tb,
61 const de265_image* input,
62 //int16_t* residual, int stride,
63 int x0,int y0, // luma position
64 int log2TbSize, // chroma adapted
65 const enc_cb* cb,
66 int cIdx)
67 {
68 }
69 */
70
71 void analyze_transform_unit(encoder_context* ectx,
72 enc_tb* tb,
73 const de265_image* input, // TODO: probably pass pixels/stride directly
74 //int16_t* residual, int stride,
75 int x0,int y0, // luma position
76 int log2TbSize, // chroma adapted
77 const enc_cb* cb,
78 int cIdx)
79 {
80 int xC = x0;
81 int yC = y0;
82 int tbSize = 1<<log2TbSize;
83 if (cIdx>0) { xC>>=1; yC>>=1; }
84
85 enum PredMode predMode = cb->PredMode;
86
87 int16_t blk[32*32]; // residual
88
89 // --- do intra prediction ---
90
91 if (predMode==MODE_INTRA) {
92 enum IntraPredMode intraPredMode;
93
94 if (cIdx==0) {
95 intraPredMode = ectx->img->get_IntraPredMode(x0,y0);
96 }
97 else {
98 intraPredMode = cb->intra.chroma_mode;
99 }
100
101 decode_intra_prediction(ectx->img, xC, yC, intraPredMode, tbSize , cIdx);
102
103
104 // --- subtract prediction from prediction ---
105
106 uint8_t* pred = ectx->img->get_image_plane(cIdx);
107 int stride = ectx->img->get_image_stride(cIdx);
108
109 diff_blk(blk,tbSize,
110 input->get_image_plane_at_pos(cIdx,xC,yC), input->get_image_stride(cIdx),
111 &pred[yC*stride+xC],stride, tbSize);
112 }
113 else {
114 // --- subtract prediction from prediction ---
115
116 uint8_t* pred = ectx->prediction->get_image_plane(cIdx);
117 int stride = ectx->prediction->get_image_stride(cIdx);
118
119 //printBlk("input",input->get_image_plane_at_pos(cIdx,xC,yC), tbSize, input->get_image_stride(cIdx));
120 //printBlk("prediction", pred,tbSize, stride);
121
122 diff_blk(blk,tbSize,
123 input->get_image_plane_at_pos(cIdx,xC,yC), input->get_image_stride(cIdx),
124 &pred[yC*stride+xC],stride, tbSize);
125
126 //printBlk("residual", blk,tbSize,tbSize);
127 }
128
129
130 //show_debug_image(ectx->img, 0);
131
132
133
134
135 // --- forward transform ---
136
137 tb->alloc_coeff_memory(cIdx, tbSize);
138
139 int trType;
140 if (cIdx==0 && log2TbSize==2 && predMode==MODE_INTRA) trType=1; // TODO: inter mode
141 else trType=0;
142
143 fwd_transform(&ectx->acceleration, tb->coeff[cIdx], tbSize, log2TbSize, trType, blk, tbSize);
144
145
146 // --- quantization ---
147
148 quant_coefficients(tb->coeff[cIdx], tb->coeff[cIdx], log2TbSize, cb->qp, true);
149
150 tb->cbf[cIdx] = has_nonzero_value(tb->coeff[cIdx], 1<<(log2TbSize<<1));
151 }
152
153
154 static void recursive_cbfChroma(CABAC_encoder_estim* cabac,
155 enc_tb* tb, int log2TrafoSize, int trafoDepth)
156 {
157 float bits_pre = cabac->getRDBits();
158
159 // --- CBF CB/CR ---
160
161 // For 4x4 luma, there is no signaling of chroma CBF, because only the
162 // chroma CBF for 8x8 is relevant.
163 if (log2TrafoSize>2) {
164 if (trafoDepth==0 || tb->parent->cbf[1]) {
165 encode_cbf_chroma(cabac, trafoDepth, tb->cbf[1]);
166 }
167 if (trafoDepth==0 || tb->parent->cbf[2]) {
168 encode_cbf_chroma(cabac, trafoDepth, tb->cbf[2]);
169 }
170 }
171
172 if (tb->split_transform_flag) {
173 for (int i=0;i<4;i++) {
174 recursive_cbfChroma(cabac, tb->children[i], log2TrafoSize-1, trafoDepth+1);
175 }
176 }
177
178 float bits_post = cabac->getRDBits();
179
180 tb->rate = tb->rate_withoutCbfChroma + (bits_post - bits_pre);
181 }
182
183
184 enc_tb* encode_transform_tree_no_split(encoder_context* ectx,
185 context_model_table& ctxModel,
186 const de265_image* input,
187 const enc_tb* parent,
188 enc_cb* cb,
189 int x0,int y0, int xBase,int yBase, int log2TbSize,
190 int blkIdx,
191 int trafoDepth, int MaxTrafoDepth, int IntraSplitFlag)
192 {
193 de265_image* img = ectx->img;
194
195 int stride = ectx->img->get_image_stride(0);
196
197 uint8_t* luma_plane = ectx->img->get_image_plane(0);
198 uint8_t* cb_plane = ectx->img->get_image_plane(1);
199 uint8_t* cr_plane = ectx->img->get_image_plane(2);
200
201 // --- compute transform coefficients ---
202
203 enc_tb* tb = new enc_tb();
204
205 tb->parent = parent;
206 tb->split_transform_flag = false;
207 tb->log2Size = log2TbSize;
208 tb->x = x0;
209 tb->y = y0;
210 tb->cbf[0] = tb->cbf[1] = tb->cbf[2] = 0;
211
212
213 // luma block
214
215 analyze_transform_unit(ectx, tb, input, x0,y0, log2TbSize, cb, 0 /* Y */);
216
217
218 // chroma blocks
219
220 if (log2TbSize > 2) {
221 // if TB is > 4x4, do chroma transform of half size
222 analyze_transform_unit(ectx, tb, input, x0,y0, log2TbSize-1, cb, 1 /* Cb */);
223 analyze_transform_unit(ectx, tb, input, x0,y0, log2TbSize-1, cb, 2 /* Cr */);
224 }
225 else if (blkIdx==3) {
226 // if TB size is 4x4, do chroma transform for last sub-block
227 analyze_transform_unit(ectx, tb, input, xBase,yBase, log2TbSize, cb, 1 /* Cb */);
228 analyze_transform_unit(ectx, tb, input, xBase,yBase, log2TbSize, cb, 2 /* Cr */);
229 }
230
231
232 // reconstruction
233
234 tb->reconstruct(ectx, ectx->img, cb, blkIdx);
235
236
237
238 // measure rate
239
240 CABAC_encoder_estim estim;
241 estim.set_context_models(&ctxModel);
242
243
244 tb->rate_withoutCbfChroma = 0;
245
246 const seq_parameter_set* sps = &ectx->img->sps;
247
248
249 if (log2TbSize <= sps->Log2MaxTrafoSize &&
250 log2TbSize > sps->Log2MinTrafoSize &&
251 trafoDepth < MaxTrafoDepth &&
252 !(IntraSplitFlag && trafoDepth==0))
253 {
254 encode_split_transform_flag(ectx, &estim, log2TbSize, 0);
255 tb->rate_withoutCbfChroma += estim.getRDBits();
256 estim.reset();
257 }
258
259 // --- CBF CB/CR ---
260
261 if (cb->PredMode == MODE_INTRA || trafoDepth != 0 ||
262 tb->cbf[1] || tb->cbf[2]) {
263 encode_cbf_luma(&estim, trafoDepth==0, tb->cbf[0]);
264 }
265
266 encode_transform_unit(ectx,&estim, tb,cb, x0,y0, xBase,yBase, log2TbSize, trafoDepth, blkIdx);
267
268 tb->rate_withoutCbfChroma += estim.getRDBits();
269
270 estim.reset(); // TODO: not needed ?
271
272 recursive_cbfChroma(&estim,tb,log2TbSize,trafoDepth);
273
274 //float rate_cbfChroma = estim.getRDBits();
275 //tb->rate = tb->rate_withoutCbfChroma + rate_cbfChroma;
276
277
278 // measure distortion
279
280 int tbSize = 1<<log2TbSize;
281 tb->distortion = SSD(input->get_image_plane_at_pos(0, x0,y0), input->get_image_stride(0),
282 img ->get_image_plane_at_pos(0, x0,y0), img ->get_image_stride(0),
283 tbSize, tbSize);
284
285 return tb;
286 }
287
288
289 enc_tb* Algo_TB_Split::encode_transform_tree_split(encoder_context* ectx,
290 context_model_table& ctxModel,
291 const de265_image* input,
292 const enc_tb* parent,
293 enc_cb* cb,
294 int x0,int y0, int log2TbSize,
295 int TrafoDepth, int MaxTrafoDepth,
296 int IntraSplitFlag)
297 {
298 const de265_image* img = ectx->img;
299
300 enc_tb* tb = new enc_tb();
301
302 tb->parent = parent;
303 tb->split_transform_flag = true;
304 tb->log2Size = log2TbSize;
305 tb->x = x0;
306 tb->y = y0;
307
308 tb->distortion = 0;
309 tb->rate = 0;
310 tb->rate_withoutCbfChroma = 0;
311
312
313 // Since we try to code all sub-blocks, we enable all CBF flags.
314 // Should we see later that the child TBs are zero, we clear those flags later.
315
316 tb->cbf[0]=1;
317 tb->cbf[1]=1;
318 tb->cbf[2]=1;
319
320
321 context_model ctxModelCbfChroma[4];
322 for (int i=0;i<4;i++) {
323 ctxModelCbfChroma[i] = ctxModel[CONTEXT_MODEL_CBF_CHROMA+i];
324 }
325
326
327 // --- encode all child nodes ---
328
329 for (int i=0;i<4;i++) {
330 int dx = (i&1) << (log2TbSize-1);
331 int dy = (i>>1) << (log2TbSize-1);
332
333 if (cb->PredMode == MODE_INTRA) {
334 tb->children[i] = mAlgo_TB_IntraPredMode->analyze(ectx, ctxModel, input, tb, cb,
335 x0+dx, y0+dy, x0,y0,
336 log2TbSize-1, i,
337 TrafoDepth+1, MaxTrafoDepth, IntraSplitFlag);
338 }
339 else {
340 tb->children[i] = this->analyze(ectx, ctxModel, input, tb, cb,
341 x0+dx, y0+dy, x0,y0,
342 log2TbSize-1, i,
343 TrafoDepth+1, MaxTrafoDepth, IntraSplitFlag);
344 }
345
346 tb->distortion += tb->children[i]->distortion;
347 tb->rate_withoutCbfChroma += tb->children[i]->rate_withoutCbfChroma;
348 }
349
350 tb->set_cbf_flags_from_children();
351
352
353 // --- add rate for this TB level ---
354
355 CABAC_encoder_estim estim;
356 estim.set_context_models(&ctxModel);
357
358
359
360
361 const seq_parameter_set* sps = &ectx->img->sps;
362
363 if (log2TbSize <= sps->Log2MaxTrafoSize &&
364 log2TbSize > sps->Log2MinTrafoSize &&
365 TrafoDepth < MaxTrafoDepth &&
366 !(IntraSplitFlag && TrafoDepth==0))
367 {
368 encode_split_transform_flag(ectx, &estim, log2TbSize, 1);
369 tb->rate_withoutCbfChroma += estim.getRDBits();
370 estim.reset();
371 }
372
373 // restore chroma CBF context models
374
375 for (int i=0;i<4;i++) {
376 ctxModel[CONTEXT_MODEL_CBF_CHROMA+i] = ctxModelCbfChroma[i];
377 }
378
379 recursive_cbfChroma(&estim,tb, log2TbSize, TrafoDepth);
380 //tb->rate = tb->rate_withoutCbfChroma + estim.getRDBits();
381
382 return tb;
383 }
384
385
386
387 struct Logging_TB_Split : public Logging
388 {
389 int skipTBSplit, noskipTBSplit;
390 int zeroBlockCorrelation[6][2][5];
391
392 const char* name() const { return "tb-split"; }
393
394 void print(const encoder_context* ectx, const char* filename)
395 {
396 printf("%d %d\n\n",skipTBSplit, noskipTBSplit);
397
398 for (int tb=3;tb<=5;tb++) {
399 for (int z=0;z<=1;z++) {
400 float total = 0;
401
402 for (int c=0;c<5;c++)
403 total += zeroBlockCorrelation[tb][z][c];
404
405 for (int c=0;c<5;c++) {
406 printf("%d %d %d : %d %5.2f\n", tb,z,c,
407 zeroBlockCorrelation[tb][z][c],
408 total==0 ? 0 : zeroBlockCorrelation[tb][z][c]/total*100);
409 }
410 }
411 }
412
413
414 for (int z=0;z<2;z++) {
415 printf("\n");
416 for (int tb=3;tb<=5;tb++) {
417 float total = 0;
418
419 for (int c=0;c<5;c++)
420 total += zeroBlockCorrelation[tb][z][c];
421
422 printf("%dx%d ",1<<tb,1<<tb);
423
424 for (int c=0;c<5;c++) {
425 printf("%5.2f ", total==0 ? 0 : zeroBlockCorrelation[tb][z][c]/total*100);
426 }
427 printf("\n");
428 }
429 }
430 }
431 } logging_tb_split;
432
433
434
435 enc_tb*
436 Algo_TB_Split_BruteForce::analyze(encoder_context* ectx,
437 context_model_table& ctxModel,
438 const de265_image* input,
439 const enc_tb* parent,
440 enc_cb* cb,
441 int x0,int y0, int xBase,int yBase, int log2TbSize,
442 int blkIdx,
443 int TrafoDepth, int MaxTrafoDepth,
444 int IntraSplitFlag)
445 {
446 bool test_split = (log2TbSize > 2 &&
447 TrafoDepth < MaxTrafoDepth &&
448 log2TbSize > ectx->sps.Log2MinTrafoSize);
449
450 bool test_no_split = true;
451 if (IntraSplitFlag && TrafoDepth==0) test_no_split=false; // we have to split
452 if (log2TbSize > ectx->sps.Log2MaxTrafoSize) test_no_split=false;
453
454 context_model_table ctxSplit;
455 if (test_split) {
456 ctxSplit = ctxModel.copy();
457 }
458
459
460 enc_tb* tb_no_split = NULL;
461 enc_tb* tb_split = NULL;
462 float rd_cost_no_split = std::numeric_limits<float>::max();
463 float rd_cost_split = std::numeric_limits<float>::max();
464
465 if (test_no_split) {
466 tb_no_split = encode_transform_tree_no_split(ectx, ctxModel, input, parent,
467 cb, x0,y0, xBase,yBase, log2TbSize,
468 blkIdx,
469 TrafoDepth,MaxTrafoDepth,IntraSplitFlag);
470
471 rd_cost_no_split = tb_no_split->distortion + ectx->lambda * tb_no_split->rate;
472
473 if (log2TbSize <= mParams.zeroBlockPrune()) {
474 bool zeroBlock = tb_no_split->isZeroBlock();
475
476 if (zeroBlock) {
477 test_split = false;
478 logging_tb_split.skipTBSplit++;
479 }
480 else
481 logging_tb_split.noskipTBSplit++;
482 }
483 }
484
485
486 if (test_split) {
487 tb_split = encode_transform_tree_split(ectx, ctxSplit, input, parent, cb,
488 x0,y0, log2TbSize,
489 TrafoDepth, MaxTrafoDepth, IntraSplitFlag);
490
491 rd_cost_split = tb_split->distortion + ectx->lambda * tb_split->rate;
492 }
493
494
495 if (test_split && test_no_split) {
496 bool zero_block = tb_no_split->isZeroBlock();
497
498 int nChildZero = 0;
499 for (int i=0;i<4;i++) {
500 if (tb_split->children[i]->isZeroBlock()) nChildZero++;
501 }
502
503 logging_tb_split.zeroBlockCorrelation[log2TbSize][zero_block ? 0 : 1][nChildZero]++;
504 }
505
506
507 bool split = (rd_cost_split < rd_cost_no_split);
508
509 if (split) {
510 ctxModel = ctxSplit;
511
512 delete tb_no_split;
513 assert(tb_split);
514 return tb_split;
515 }
516 else {
517 delete tb_split;
518 assert(tb_no_split);
519 tb_no_split->reconstruct(ectx, ectx->img,
520 cb, blkIdx);
521
522 return tb_no_split;
523 }
524 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef TB_SPLIT_H
23 #define TB_SPLIT_H
24
25 #include "libde265/nal-parser.h"
26 #include "libde265/decctx.h"
27 #include "libde265/encoder/encode.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/tb-intrapredmode.h"
38
39
40 /* Encoder search tree, bottom up:
41
42 - Algo_TB_Split - whether TB is split or not
43
44 - Algo_TB_IntraPredMode - choose the intra prediction mode (or NOP, if at the wrong tree level)
45
46 - Algo_CB_IntraPartMode - choose between NxN and 2Nx2N intra parts
47
48 - Algo_CB_Split - whether CB is split or not
49
50 - Algo_CTB_QScale - select QScale on CTB granularity
51 */
52
53 /*
54 struct ResidualBlock
55 {
56 const int16_t* data[4];
57 int stride[4];
58 };
59 */
60
61 void diff_blk(int16_t* out,int out_stride,
62 const uint8_t* a_ptr, int a_stride,
63 const uint8_t* b_ptr, int b_stride,
64 int blkSize);
65
66
67 // ========== TB split decision ==========
68
69 class Algo_TB_Split
70 {
71 public:
72 Algo_TB_Split() : mAlgo_TB_IntraPredMode(NULL) { }
73 virtual ~Algo_TB_Split() { }
74
75 virtual enc_tb* analyze(encoder_context*,
76 context_model_table&,
77 const de265_image* input,
78 const enc_tb* parent,
79 enc_cb* cb,
80 int x0,int y0, int xBase,int yBase, int log2TbSize,
81 int blkIdx,
82 int TrafoDepth, int MaxTrafoDepth, int IntraSplitFlag) = 0;
83
84 void setAlgo_TB_IntraPredMode(Algo_TB_IntraPredMode* algo) { mAlgo_TB_IntraPredMode=algo; }
85
86 protected:
87 enc_tb* encode_transform_tree_split(encoder_context* ectx,
88 context_model_table& ctxModel,
89 const de265_image* input,
90 const enc_tb* parent,
91 enc_cb* cb,
92 int x0,int y0, int log2TbSize,
93 int TrafoDepth, int MaxTrafoDepth, int IntraSplitFlag);
94
95 Algo_TB_IntraPredMode* mAlgo_TB_IntraPredMode;
96 };
97
98
99
100 enum ALGO_TB_Split_BruteForce_ZeroBlockPrune {
101 // numeric value specifies the maximum size for log2Tb for which the pruning is applied
102 ALGO_TB_BruteForce_ZeroBlockPrune_off = 0,
103 ALGO_TB_BruteForce_ZeroBlockPrune_8x8 = 3,
104 ALGO_TB_BruteForce_ZeroBlockPrune_8x8_16x16 = 4,
105 ALGO_TB_BruteForce_ZeroBlockPrune_all = 5
106 };
107
108 class option_ALGO_TB_Split_BruteForce_ZeroBlockPrune
109 : public choice_option<enum ALGO_TB_Split_BruteForce_ZeroBlockPrune>
110 {
111 public:
112 option_ALGO_TB_Split_BruteForce_ZeroBlockPrune() {
113 add_choice("off" ,ALGO_TB_BruteForce_ZeroBlockPrune_off);
114 add_choice("8x8" ,ALGO_TB_BruteForce_ZeroBlockPrune_8x8);
115 add_choice("8-16" ,ALGO_TB_BruteForce_ZeroBlockPrune_8x8_16x16);
116 add_choice("all" ,ALGO_TB_BruteForce_ZeroBlockPrune_all, true);
117 }
118 };
119
120 class Algo_TB_Split_BruteForce : public Algo_TB_Split
121 {
122 public:
123 struct params
124 {
125 params() {
126 zeroBlockPrune.set_ID("TB-Split-BruteForce-ZeroBlockPrune");
127 }
128
129 option_ALGO_TB_Split_BruteForce_ZeroBlockPrune zeroBlockPrune;
130 };
131
132 void setParams(const params& p) { mParams=p; }
133
134 void registerParams(config_parameters& config) {
135 config.add_option(&mParams.zeroBlockPrune);
136 }
137
138 virtual enc_tb* analyze(encoder_context*,
139 context_model_table&,
140 const de265_image* input,
141 const enc_tb* parent,
142 enc_cb* cb,
143 int x0,int y0, int xBase,int yBase, int log2TbSize,
144 int blkIdx,
145 int TrafoDepth, int MaxTrafoDepth, int IntraSplitFlag);
146
147 private:
148 params mParams;
149 };
150
151 #endif
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: struktur AG, Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22
23 #include "libde265/encoder/analyze.h"
24 #include "libde265/encoder/encoder-context.h"
25 #include <assert.h>
26 #include <limits>
27 #include <math.h>
28 #include <iostream>
29
30
31 #define ENCODER_DEVELOPMENT 0
32 #define COMPARE_ESTIMATED_RATE_TO_REAL_RATE 0
33
34
35 static int IntraPredModeCnt[7][35];
36 static int MPM_used[7][35];
37
38 static int IntraPredModeCnt_total[35];
39 static int MPM_used_total[35];
40
41 void statistics_IntraPredMode(const encoder_context* ectx, int x,int y, const enc_cb* cb)
42 {
43 if (cb->split_cu_flag) {
44 for (int i=0;i<4;i++)
45 if (cb->children[i]) {
46 statistics_IntraPredMode(ectx, childX(x,i,cb->log2Size), childY(y,i,cb->log2Size), cb->children[i]);
47 }
48 }
49 else {
50 int cnt;
51 int size = cb->log2Size;
52
53 if (cb->PartMode == PART_NxN) { cnt=4; size--; } else cnt=1;
54
55 for (int i=0;i<cnt;i++) {
56 IntraPredModeCnt[size][ cb->intra.pred_mode[i] ]++;
57 IntraPredModeCnt_total[ cb->intra.pred_mode[i] ]++;
58
59 int xi = childX(x,i,cb->log2Size);
60 int yi = childY(y,i,cb->log2Size);
61
62 int candModeList[3];
63 fillIntraPredModeCandidates(candModeList,xi,yi, xi>0, yi>0, ectx->img);
64
65 int predmode = cb->intra.pred_mode[i];
66 if (candModeList[0]==predmode ||
67 candModeList[1]==predmode ||
68 candModeList[2]==predmode) {
69 MPM_used[size][predmode]++;
70 MPM_used_total[predmode]++;
71 }
72 }
73 }
74 }
75
76 void statistics_print()
77 {
78 for (int i=0;i<35;i++) {
79 printf("%d",i);
80 printf(" %d %d",IntraPredModeCnt_total[i], MPM_used_total[i]);
81
82 for (int k=2;k<=6;k++) {
83 printf(" %d %d",IntraPredModeCnt[k][i], MPM_used[k][i]);
84 }
85
86 printf("\n");
87 }
88 }
89
90
91 void print_tb_tree_rates(const enc_tb* tb, int level)
92 {
93 for (int i=0;i<level;i++)
94 std::cout << " ";
95
96 std::cout << "TB rate=" << tb->rate << " (" << tb->rate_withoutCbfChroma << ")\n";
97 if (tb->split_transform_flag) {
98 for (int i=0;i<4;i++)
99 print_tb_tree_rates(tb->children[i], level+1);
100 }
101 }
102
103
104 void print_cb_tree_rates(const enc_cb* cb, int level)
105 {
106 for (int i=0;i<level;i++)
107 std::cout << " ";
108
109 std::cout << "CB rate=" << cb->rate << "\n";
110 if (cb->split_cu_flag) {
111 for (int i=0;i<4;i++)
112 print_cb_tree_rates(cb->children[i], level+1);
113 }
114 else {
115 print_tb_tree_rates(cb->transform_tree, level+1);
116 }
117 }
118
119
120 double encode_image(encoder_context* ectx,
121 const de265_image* input,
122 EncodingAlgorithm& algo)
123 {
124 int stride=input->get_image_stride(0);
125
126 int w = ectx->sps.pic_width_in_luma_samples;
127 int h = ectx->sps.pic_height_in_luma_samples;
128
129 // --- create reconstruction image ---
130 ectx->img = new de265_image;
131 ectx->img->vps = ectx->vps;
132 ectx->img->sps = ectx->sps;
133 ectx->img->pps = ectx->pps;
134 ectx->img->PicOrderCntVal = input->PicOrderCntVal;
135
136 ectx->img->alloc_image(w,h, de265_chroma_420, &ectx->sps, true,
137 NULL /* no decctx */, ectx, 0,NULL,false);
138 //ectx->img->alloc_encoder_data(&ectx->sps);
139 ectx->img->clear_metadata();
140
141 #if 1
142 if (1) {
143 ectx->prediction = new de265_image;
144 ectx->prediction->alloc_image(w,h, de265_chroma_420, &ectx->sps, false /* no metadata */,
145 NULL /* no decctx */, NULL /* no encctx */, 0,NULL,false);
146 ectx->prediction->vps = ectx->vps;
147 ectx->prediction->sps = ectx->sps;
148 ectx->prediction->pps = ectx->pps;
149 }
150 #endif
151
152 ectx->active_qp = ectx->pps.pic_init_qp; // TODO take current qp from slice
153
154
155 ectx->cabac_ctx_models.init(ectx->shdr->initType, ectx->shdr->SliceQPY);
156 ectx->cabac_encoder.set_context_models(&ectx->cabac_ctx_models);
157
158
159 context_model_table modelEstim;
160 CABAC_encoder_estim cabacEstim;
161
162 modelEstim.init(ectx->shdr->initType, ectx->shdr->SliceQPY);
163 cabacEstim.set_context_models(&modelEstim);
164
165
166 int Log2CtbSize = ectx->sps.Log2CtbSizeY;
167
168 uint8_t* luma_plane = ectx->img->get_image_plane(0);
169 uint8_t* cb_plane = ectx->img->get_image_plane(1);
170 uint8_t* cr_plane = ectx->img->get_image_plane(2);
171
172
173 // encode CTB by CTB
174
175 for (int y=0;y<ectx->sps.PicHeightInCtbsY;y++)
176 for (int x=0;x<ectx->sps.PicWidthInCtbsY;x++)
177 {
178 ectx->img->set_SliceAddrRS(x, y, ectx->shdr->SliceAddrRS);
179
180 int x0 = x<<Log2CtbSize;
181 int y0 = y<<Log2CtbSize;
182
183 logtrace(LogSlice,"encode CTB at %d %d\n",x0,y0);
184
185 // make a copy of the context model that we can modify for testing alternatives
186
187 context_model_table ctxModel;
188 //copy_context_model_table(ctxModel, ectx->ctx_model_bitstream);
189 ctxModel = ectx->cabac_ctx_models.copy();
190 ctxModel = modelEstim.copy(); // TODO TMP
191
192 disable_logging(LogSymbols);
193 enable_logging(LogSymbols); // TODO TMP
194
195 //printf("================================================== ANALYZE\n");
196
197 #if 1
198 /*
199 enc_cb* cb = encode_cb_may_split(ectx, ctxModel,
200 input, x0,y0, Log2CtbSize, 0, qp);
201 */
202
203 enc_cb* cb = algo.getAlgoCTBQScale()->analyze(ectx,ctxModel, x0,y0);
204 #else
205 float minCost = std::numeric_limits<float>::max();
206 int bestQ = 0;
207 int qp = ectx->params.constant_QP;
208
209 enc_cb* cb;
210 for (int q=1;q<51;q++) {
211 copy_context_model_table(ctxModel, ectx->ctx_model_bitstream);
212
213 enc_cb* cbq = encode_cb_may_split(ectx, ctxModel,
214 input, x0,y0, Log2CtbSize, 0, q);
215
216 float cost = cbq->distortion + ectx->lambda * cbq->rate;
217 if (cost<minCost) { minCost=cost; bestQ=q; }
218
219 if (q==qp) { cb=cbq; }
220 }
221
222 printf("Q %d\n",bestQ);
223 fflush(stdout);
224 #endif
225
226 //print_cb_tree_rates(cb,0);
227
228 //statistics_IntraPredMode(ectx, x0,y0, cb);
229
230
231 // --- write bitstream ---
232
233 //ectx->switch_CABAC_to_bitstream();
234
235 enable_logging(LogSymbols);
236
237 encode_ctb(ectx, &ectx->cabac_encoder, cb, x,y);
238
239 //printf("================================================== WRITE\n");
240
241
242 if (COMPARE_ESTIMATED_RATE_TO_REAL_RATE) {
243 float realPre = cabacEstim.getRDBits();
244 encode_ctb(ectx, &cabacEstim, cb, x,y);
245 float realPost = cabacEstim.getRDBits();
246
247 printf("estim: %f real: %f diff: %f\n",
248 cb->rate,
249 realPost-realPre,
250 cb->rate - (realPost-realPre));
251 }
252
253
254 int last = (y==ectx->sps.PicHeightInCtbsY-1 &&
255 x==ectx->sps.PicWidthInCtbsY-1);
256 ectx->cabac_encoder.write_CABAC_term_bit(last);
257
258
259 delete cb;
260
261 //ectx->free_all_pools();
262 }
263
264
265 //statistics_print();
266
267
268 delete ectx->prediction;
269
270
271 // frame PSNR
272
273 double psnr = PSNR(MSE(input->get_image_plane(0), input->get_image_stride(0),
274 luma_plane, ectx->img->get_image_stride(0),
275 input->get_width(), input->get_height()));
276 return psnr;
277 }
278
279
280
281 void EncodingAlgorithm_Custom::setParams(encoder_params& params)
282 {
283 // build algorithm tree
284
285 mAlgo_CTB_QScale_Constant.setChildAlgo(&mAlgo_CB_Split_BruteForce);
286 mAlgo_CB_Split_BruteForce.setChildAlgo(&mAlgo_CB_Skip_BruteForce);
287
288 mAlgo_CB_Skip_BruteForce.setSkipAlgo(&mAlgo_CB_MergeIndex_Fixed);
289 mAlgo_CB_Skip_BruteForce.setNonSkipAlgo(&mAlgo_CB_IntraInter_BruteForce);
290 //&mAlgo_CB_InterPartMode_Fixed);
291
292 Algo_CB_IntraPartMode* algo_CB_IntraPartMode = NULL;
293 switch (params.mAlgo_CB_IntraPartMode()) {
294 case ALGO_CB_IntraPartMode_BruteForce:
295 algo_CB_IntraPartMode = &mAlgo_CB_IntraPartMode_BruteForce;
296 break;
297 case ALGO_CB_IntraPartMode_Fixed:
298 algo_CB_IntraPartMode = &mAlgo_CB_IntraPartMode_Fixed;
299 break;
300 }
301
302 mAlgo_CB_IntraInter_BruteForce.setIntraChildAlgo(algo_CB_IntraPartMode);
303 mAlgo_CB_IntraInter_BruteForce.setInterChildAlgo(&mAlgo_CB_InterPartMode_Fixed);
304
305 mAlgo_CB_MergeIndex_Fixed.setChildAlgo(&mAlgo_TB_Split_BruteForce);
306
307 Algo_PB_MV* pbAlgo = NULL;
308 switch (params.mAlgo_MEMode()) {
309 case MEMode_Test:
310 pbAlgo = &mAlgo_PB_MV_Test;
311 break;
312 case MEMode_Search:
313 pbAlgo = &mAlgo_PB_MV_Search;
314 break;
315 }
316
317 mAlgo_CB_InterPartMode_Fixed.setChildAlgo(pbAlgo);
318 pbAlgo->setChildAlgo(&mAlgo_TB_Split_BruteForce);
319
320
321 Algo_TB_IntraPredMode_ModeSubset* algo_TB_IntraPredMode = NULL;
322 switch (params.mAlgo_TB_IntraPredMode()) {
323 case ALGO_TB_IntraPredMode_BruteForce:
324 algo_TB_IntraPredMode = &mAlgo_TB_IntraPredMode_BruteForce;
325 break;
326 case ALGO_TB_IntraPredMode_FastBrute:
327 algo_TB_IntraPredMode = &mAlgo_TB_IntraPredMode_FastBrute;
328 break;
329 case ALGO_TB_IntraPredMode_MinResidual:
330 algo_TB_IntraPredMode = &mAlgo_TB_IntraPredMode_MinResidual;
331 break;
332 }
333
334 algo_CB_IntraPartMode->setChildAlgo(algo_TB_IntraPredMode);
335
336 mAlgo_TB_Split_BruteForce.setAlgo_TB_IntraPredMode(algo_TB_IntraPredMode);
337 //mAlgo_TB_Split_BruteForce.setParams(params.TB_Split_BruteForce);
338
339 algo_TB_IntraPredMode->setChildAlgo(&mAlgo_TB_Split_BruteForce);
340
341
342 // ===== set algorithm parameters ======
343
344 //mAlgo_CB_IntraPartMode_Fixed.setParams(params.CB_IntraPartMode_Fixed);
345
346 //mAlgo_TB_IntraPredMode_FastBrute.setParams(params.TB_IntraPredMode_FastBrute);
347 //mAlgo_TB_IntraPredMode_MinResidual.setParams(params.TB_IntraPredMode_MinResidual);
348
349
350 //mAlgo_CTB_QScale_Constant.setParams(params.CTB_QScale_Constant);
351
352
353 algo_TB_IntraPredMode->enableIntraPredModeSubset( params.mAlgo_TB_IntraPredMode_Subset() );
354 }
355
356
357 void Logging::print_logging(const encoder_context* ectx, const char* id, const char* filename)
358 {
359 #if 000
360 if (strcmp(id,logging_tb_split.name())==0) {
361 logging_tb_split.print(ectx,filename);
362 }
363 #endif
364 }
365
366
367 void en265_print_logging(const encoder_context* ectx, const char* id, const char* filename)
368 {
369 Logging::print_logging(ectx,id,filename);
370 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef ANALYZE_H
23 #define ANALYZE_H
24
25 #include "libde265/nal-parser.h"
26 #include "libde265/decctx.h"
27 #include "libde265/encoder/encode.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/tb-intrapredmode.h"
38 #include "libde265/encoder/algo/tb-split.h"
39 #include "libde265/encoder/algo/cb-intrapartmode.h"
40 #include "libde265/encoder/algo/cb-interpartmode.h"
41 #include "libde265/encoder/algo/cb-split.h"
42 #include "libde265/encoder/algo/ctb-qscale.h"
43 #include "libde265/encoder/algo/cb-mergeindex.h"
44 //#include "libde265/encoder/algo/cb-skip-or-inter.h"
45 #include "libde265/encoder/algo/pb-mv.h"
46 #include "libde265/encoder/algo/cb-skip.h"
47 #include "libde265/encoder/algo/cb-intra-inter.h"
48
49
50 /* Encoder search tree, bottom up:
51
52 - Algo_TB_Split - whether TB is split or not
53
54 - Algo_TB_IntraPredMode - choose the intra prediction mode (or NOP, if at the wrong tree level)
55
56 - Algo_CB_IntraPartMode - choose between NxN and 2Nx2N intra parts
57
58 - Algo_CB_PredMode - intra / inter
59
60 - Algo_CB_Split - whether CB is split or not
61
62 - Algo_CTB_QScale - select QScale on CTB granularity
63 */
64
65
66 // ========== an encoding algorithm combines a set of algorithm modules ==========
67
68 class EncodingAlgorithm
69 {
70 public:
71 virtual ~EncodingAlgorithm() { }
72
73 virtual Algo_CTB_QScale* getAlgoCTBQScale() = 0;
74
75 virtual int getPPS_QP() const = 0;
76 virtual int getSlice_QPDelta() const { return 0; }
77 };
78
79
80 class EncodingAlgorithm_Custom : public EncodingAlgorithm
81 {
82 public:
83
84 void setParams(struct encoder_params& params);
85
86 void registerParams(config_parameters& config) {
87 mAlgo_CTB_QScale_Constant.registerParams(config);
88 mAlgo_CB_IntraPartMode_Fixed.registerParams(config);
89 mAlgo_CB_InterPartMode_Fixed.registerParams(config);
90 mAlgo_PB_MV_Test.registerParams(config);
91 mAlgo_PB_MV_Search.registerParams(config);
92 mAlgo_TB_IntraPredMode_FastBrute.registerParams(config);
93 mAlgo_TB_IntraPredMode_MinResidual.registerParams(config);
94 mAlgo_TB_Split_BruteForce.registerParams(config);
95 }
96
97 virtual Algo_CTB_QScale* getAlgoCTBQScale() { return &mAlgo_CTB_QScale_Constant; }
98
99 virtual int getPPS_QP() const { return mAlgo_CTB_QScale_Constant.getQP(); }
100
101 private:
102 Algo_CTB_QScale_Constant mAlgo_CTB_QScale_Constant;
103
104 Algo_CB_Split_BruteForce mAlgo_CB_Split_BruteForce;
105 Algo_CB_Skip_BruteForce mAlgo_CB_Skip_BruteForce;
106 Algo_CB_IntraInter_BruteForce mAlgo_CB_IntraInter_BruteForce;
107
108 Algo_CB_IntraPartMode_BruteForce mAlgo_CB_IntraPartMode_BruteForce;
109 Algo_CB_IntraPartMode_Fixed mAlgo_CB_IntraPartMode_Fixed;
110
111 Algo_CB_InterPartMode_Fixed mAlgo_CB_InterPartMode_Fixed;
112 Algo_CB_MergeIndex_Fixed mAlgo_CB_MergeIndex_Fixed;
113
114 Algo_PB_MV_Test mAlgo_PB_MV_Test;
115 Algo_PB_MV_Search mAlgo_PB_MV_Search;
116
117 Algo_TB_Split_BruteForce mAlgo_TB_Split_BruteForce;
118
119 Algo_TB_IntraPredMode_BruteForce mAlgo_TB_IntraPredMode_BruteForce;
120 Algo_TB_IntraPredMode_FastBrute mAlgo_TB_IntraPredMode_FastBrute;
121 Algo_TB_IntraPredMode_MinResidual mAlgo_TB_IntraPredMode_MinResidual;
122 };
123
124
125
126 double encode_image(encoder_context*, const de265_image* input, EncodingAlgorithm&);
127
128 void encode_sequence(encoder_context*);
129
130
131 class Logging
132 {
133 public:
134 virtual ~Logging() { }
135
136 static void print_logging(const encoder_context* ectx, const char* id, const char* filename);
137
138 virtual const char* name() const = 0;
139 virtual void print(const encoder_context* ectx, const char* filename) = 0;
140 };
141
142
143 LIBDE265_API void en265_print_logging(const encoder_context* ectx, const char* id, const char* filename);
144
145 #endif
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: struktur AG, Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #include "encode.h"
23 #include "encoder-context.h"
24 #include "slice.h"
25 #include "scan.h"
26 #include "intrapred.h"
27 #include "libde265/transform.h"
28 #include "libde265/fallback-dct.h"
29 #include <iostream>
30
31
32 int allocTB = 0;
33 int allocCB = 0;
34
35 #define DEBUG_ALLOCS 0
36
37
38
39 void enc_node::save(const de265_image* img)
40 {
41 delete[] mReconstruction;
42
43 int blkSize = Log2SizeToArea(log2Size);
44 mReconstruction = new uint8_t[blkSize * 3/2];
45
46 int w = 1<<log2Size;
47
48 copy_subimage(mReconstruction, w,
49 img->get_image_plane_at_pos(0, x,y),
50 img->get_image_stride(0),
51 w,w);
52
53 copy_subimage(mReconstruction + blkSize, w>>1,
54 img->get_image_plane_at_pos(1, x>>1,y>>1),
55 img->get_image_stride(1),
56 w>>1,w>>1);
57
58 copy_subimage(mReconstruction + blkSize*5/4, w>>1,
59 img->get_image_plane_at_pos(2, x>>1,y>>1),
60 img->get_image_stride(2),
61 w>>1,w>>1);
62 }
63
64
65 void enc_node::restore(de265_image* img)
66 {
67 assert(mReconstruction);
68
69 int blkSize = Log2SizeToArea(log2Size);
70 int w = 1<<log2Size;
71
72 copy_subimage(img->get_image_plane_at_pos(0, x,y),
73 img->get_image_stride(0),
74 mReconstruction, w,
75 w,w);
76
77 copy_subimage(img->get_image_plane_at_pos(1, x>>1,y>>1),
78 img->get_image_stride(1),
79 mReconstruction + blkSize, w>>1,
80 w>>1,w>>1);
81
82 copy_subimage(img->get_image_plane_at_pos(2, x>>1,y>>1),
83 img->get_image_stride(2),
84 mReconstruction + blkSize*5/4, w>>1,
85 w>>1,w>>1);
86 }
87
88
89 void enc_cb::save(const de265_image* img)
90 {
91 enc_node::save(img);
92
93 // TODO: save metadata in node buffer memory
94 }
95
96
97 void enc_cb::restore(de265_image* img)
98 {
99 enc_node::restore(img);
100
101 // write back all the metadata
102
103 write_to_image(img);
104 }
105
106
107 void enc_cb::set_rqt_root_bf_from_children_cbf()
108 {
109 assert(transform_tree);
110 inter.rqt_root_cbf = (transform_tree->cbf[0] |
111 transform_tree->cbf[1] |
112 transform_tree->cbf[2]);
113 }
114
115
116
117
118 alloc_pool enc_tb::mMemPool(sizeof(enc_tb));
119
120 enc_tb::enc_tb()
121 : split_transform_flag(false)
122 {
123 coeff[0]=coeff[1]=coeff[2]=NULL;
124
125 if (DEBUG_ALLOCS) { allocTB++; printf("TB : %d\n",allocTB); }
126 }
127
128
129 enc_tb::~enc_tb()
130 {
131 if (split_transform_flag) {
132 for (int i=0;i<4;i++) {
133 delete children[i];
134 }
135 }
136 else {
137 for (int i=0;i<3;i++) {
138 delete[] coeff[i];
139 }
140 }
141
142 if (DEBUG_ALLOCS) { allocTB--; printf("TB ~: %d\n",allocTB); }
143 }
144
145
146 void enc_tb::alloc_coeff_memory(int cIdx, int tbSize)
147 {
148 assert(coeff[cIdx]==NULL);
149 coeff[cIdx] = new int16_t[tbSize*tbSize];
150 }
151
152
153 void enc_tb::reconstruct_tb(encoder_context* ectx,
154 de265_image* img,
155 int x0,int y0, // luma
156 int log2TbSize, // chroma adapted
157 const enc_cb* cb, int cIdx) const
158 {
159 // chroma adapted position
160 int xC=x0;
161 int yC=y0;
162
163 if (cIdx>0) {
164 xC>>=1;
165 yC>>=1;
166 }
167
168 if (cb->PredMode == MODE_INTRA) {
169
170 enum IntraPredMode intraPredMode = img->get_IntraPredMode(x0,y0);
171
172 if (cIdx>0) {
173 intraPredMode = cb->intra.chroma_mode;
174 //intraPredMode = lumaPredMode_to_chromaPredMode(intraPredMode, cb->intra.chroma_mode);
175 }
176
177 decode_intra_prediction(img, xC,yC, intraPredMode, 1<< log2TbSize , cIdx);
178 }
179 else {
180 int size = 1<<log2TbSize;
181
182 uint8_t* dst_ptr = img->get_image_plane_at_pos(cIdx, xC, yC );
183 int dst_stride = img->get_image_stride(cIdx);
184
185 uint8_t* src_ptr = ectx->prediction->get_image_plane_at_pos(cIdx, xC, yC );
186 int src_stride = ectx->prediction->get_image_stride(cIdx);
187
188 for (int y=0;y<size;y++) {
189 for (int x=0;x<size;x++) {
190 dst_ptr[y*dst_stride+x] = src_ptr[y*src_stride+x];
191 }
192 }
193 }
194
195 ALIGNED_16(int16_t) dequant_coeff[32*32];
196
197 if (cbf[cIdx]) dequant_coefficients(dequant_coeff, coeff[cIdx], log2TbSize, cb->qp);
198
199 //printf("--- quantized coeffs ---\n");
200 //printBlk(coeff[0],1<<log2BlkSize,1<<log2BlkSize);
201
202 //printf("--- dequantized coeffs ---\n");
203 //printBlk(dequant_coeff[0],1<<log2BlkSize,1<<log2BlkSize);
204
205 //printf("--- plane at %d %d / %d ---\n",x0,y0,cIdx);
206
207 uint8_t* ptr = img->get_image_plane_at_pos(cIdx, xC, yC );
208 int stride = img->get_image_stride(cIdx);
209
210 int trType = (cIdx==0 && log2TbSize==2); // TODO: inter
211
212 //printf("--- prediction %d %d / %d ---\n",x0,y0,cIdx);
213 //printBlk("prediction",ptr,1<<log2TbSize,stride);
214
215 if (cbf[cIdx]) inv_transform(&ectx->acceleration,
216 ptr,stride, dequant_coeff, log2TbSize, trType);
217
218
219 //printf("--- RECO intra prediction %d %d ---\n",x0,y0);
220 //printBlk("prediction",ptr,1<<log2TbSize,stride);
221
222 //dequant_and_add_transform(accel, img, x0,y0, qp);
223
224 //printf("--- RECO add residual %d %d ---\n",x0,y0);
225 //img->printBlk(x0,y0,0,log2CbSize);
226 }
227
228
229 void enc_tb::reconstruct(encoder_context* ectx,
230 de265_image* img,
231 const enc_cb* cb,
232 int blkIdx) const
233 {
234 if (split_transform_flag) {
235 for (int i=0;i<4;i++) {
236 children[i]->reconstruct(ectx,img,
237 cb, i);
238 }
239 }
240 else {
241 reconstruct_tb(ectx, img, x,y, log2Size, cb, 0);
242
243 if (log2Size>2) {
244 reconstruct_tb(ectx, img, x,y, log2Size-1, cb, 1);
245 reconstruct_tb(ectx, img, x,y, log2Size-1, cb, 2);
246 }
247 else if (blkIdx==3) {
248 int xBase = x - (1<<log2Size);
249 int yBase = y - (1<<log2Size);
250
251 reconstruct_tb(ectx, img, xBase,yBase, log2Size, cb, 1);
252 reconstruct_tb(ectx, img, xBase,yBase, log2Size, cb, 2);
253 }
254 }
255 }
256
257
258 void enc_tb::set_cbf_flags_from_children()
259 {
260 assert(split_transform_flag);
261
262 cbf[0] = 0;
263 cbf[1] = 0;
264 cbf[2] = 0;
265
266 for (int i=0;i<4;i++) {
267 cbf[0] |= children[i]->cbf[0];
268 cbf[1] |= children[i]->cbf[1];
269 cbf[2] |= children[i]->cbf[2];
270 }
271 }
272
273
274
275
276 alloc_pool enc_cb::mMemPool(sizeof(enc_cb), 200);
277
278
279 enc_cb::enc_cb()
280 : split_cu_flag(false),
281 cu_transquant_bypass_flag(false),
282 pcm_flag(false),
283 transform_tree(NULL),
284 distortion(0),
285 rate(0)
286 {
287 if (DEBUG_ALLOCS) { allocCB++; printf("CB : %d\n",allocCB); }
288 }
289
290 enc_cb::~enc_cb()
291 {
292 if (split_cu_flag) {
293 for (int i=0;i<4;i++) {
294 delete children[i];
295 }
296 }
297 else {
298 delete transform_tree;
299 }
300
301 if (DEBUG_ALLOCS) { allocCB--; printf("CB ~: %d\n",allocCB); }
302 }
303
304
305 void enc_cb::write_to_image(de265_image* img) const
306 {
307 //printf("write_to_image %d %d size:%d\n",x,y,1<<log2Size);
308
309
310 if (!split_cu_flag) {
311 img->set_log2CbSize(x,y,log2Size, true);
312 img->set_ctDepth(x,y,log2Size, ctDepth);
313 assert(pcm_flag==0);
314 img->set_pcm_flag(x,y,log2Size, pcm_flag);
315 img->set_cu_transquant_bypass(x,y,log2Size, cu_transquant_bypass_flag);
316 img->set_QPY(x,y,log2Size, qp);
317 img->set_pred_mode(x,y, log2Size, PredMode);
318 img->set_PartMode(x,y, PartMode);
319
320 if (PredMode == MODE_INTRA) {
321 //img->set_ChromaIntraPredMode(x,y,log2Size, intra.chroma_mode);
322
323 if (PartMode == PART_NxN) {
324 int h = 1<<(log2Size-1);
325 img->set_IntraPredMode(x ,y ,log2Size-1, intra.pred_mode[0]);
326 img->set_IntraPredMode(x+h,y ,log2Size-1, intra.pred_mode[1]);
327 img->set_IntraPredMode(x ,y+h,log2Size-1, intra.pred_mode[2]);
328 img->set_IntraPredMode(x+h,y+h,log2Size-1, intra.pred_mode[3]);
329 }
330 else {
331 img->set_IntraPredMode(x,y,log2Size, intra.pred_mode[0]);
332 }
333 }
334 else {
335 int nC = 1<<log2Size;
336 int nC2 = nC>>1;
337 int nC4 = nC>>2;
338 int nC3 = nC-nC4;
339 switch (PartMode) {
340 case PART_2Nx2N:
341 img->set_mv_info(x,y,nC,nC, inter.pb[0].motion);
342 break;
343 case PART_NxN:
344 img->set_mv_info(x ,y ,nC2,nC2, inter.pb[0].motion);
345 img->set_mv_info(x+nC2,y ,nC2,nC2, inter.pb[1].motion);
346 img->set_mv_info(x ,y+nC2,nC2,nC2, inter.pb[2].motion);
347 img->set_mv_info(x+nC2,y+nC2,nC2,nC2, inter.pb[3].motion);
348 break;
349 case PART_2NxN:
350 img->set_mv_info(x,y ,nC,nC2, inter.pb[0].motion);
351 img->set_mv_info(x,y+nC2,nC,nC2, inter.pb[1].motion);
352 break;
353 case PART_Nx2N:
354 img->set_mv_info(x ,y,nC2,nC, inter.pb[0].motion);
355 img->set_mv_info(x+nC2,y,nC2,nC, inter.pb[1].motion);
356 break;
357 case PART_2NxnU:
358 img->set_mv_info(x,y ,nC,nC4, inter.pb[0].motion);
359 img->set_mv_info(x,y+nC4,nC,nC3, inter.pb[1].motion);
360 break;
361 case PART_2NxnD:
362 img->set_mv_info(x,y ,nC,nC3, inter.pb[0].motion);
363 img->set_mv_info(x,y+nC3,nC,nC4, inter.pb[1].motion);
364 break;
365 case PART_nLx2N:
366 img->set_mv_info(x ,y,nC4,nC, inter.pb[0].motion);
367 img->set_mv_info(x+nC4,y,nC3,nC, inter.pb[1].motion);
368 break;
369 case PART_nRx2N:
370 img->set_mv_info(x ,y,nC3,nC, inter.pb[0].motion);
371 img->set_mv_info(x+nC3,y,nC4,nC, inter.pb[1].motion);
372 break;
373 }
374 }
375 }
376 else {
377 for (int i=0;i<4;i++) {
378 if (children[i]) {
379 children[i]->write_to_image(img);
380 }
381 }
382 }
383 }
384
385
386 void enc_cb::reconstruct(encoder_context* ectx, de265_image* img) const
387 {
388 if (split_cu_flag) {
389 for (int i=0;i<4;i++) {
390 children[i]->reconstruct(ectx, img);
391 }
392 }
393 else {
394 write_to_image(img);
395 transform_tree->reconstruct(ectx,img,this,0);
396 }
397 }
398
399
400
401 void encode_split_cu_flag(encoder_context* ectx,
402 CABAC_encoder* cabac,
403 int x0, int y0, int ctDepth, int split_flag)
404 {
405 logtrace(LogSymbols,"$1 split_cu_flag=%d\n",split_flag);
406
407 // check if neighbors are available
408
409 int availableL = check_CTB_available(ectx->img, x0,y0, x0-1,y0);
410 int availableA = check_CTB_available(ectx->img, x0,y0, x0,y0-1);
411
412 int condL = 0;
413 int condA = 0;
414
415 if (availableL && ectx->img->get_ctDepth(x0-1,y0) > ctDepth) condL=1;
416 if (availableA && ectx->img->get_ctDepth(x0,y0-1) > ctDepth) condA=1;
417
418 int contextOffset = condL + condA;
419 int context = contextOffset;
420
421 // decode bit
422
423 logtrace(LogSlice,"> split_cu_flag = %d (context=%d)\n",split_flag,context);
424
425 cabac->write_CABAC_bit(CONTEXT_MODEL_SPLIT_CU_FLAG + context, split_flag);
426 }
427
428
429 void encode_part_mode(encoder_context* ectx,
430 CABAC_encoder* cabac,
431 enum PredMode PredMode, enum PartMode PartMode, int cLog2CbSize)
432 {
433 logtrace(LogSymbols,"$1 part_mode=%d\n",PartMode);
434 logtrace(LogSlice,"> part_mode = %d\n",PartMode);
435
436 if (PredMode == MODE_INTRA) {
437 int bin = (PartMode==PART_2Nx2N);
438 cabac->write_CABAC_bit(CONTEXT_MODEL_PART_MODE+0, bin);
439 }
440 else {
441 if (PartMode==PART_2Nx2N) {
442 cabac->write_CABAC_bit(CONTEXT_MODEL_PART_MODE+0, 1);
443 return;
444 }
445 else {
446 cabac->write_CABAC_bit(CONTEXT_MODEL_PART_MODE+0, 0);
447 }
448
449 if (cLog2CbSize > ectx->sps.Log2MinCbSizeY) {
450 if (ectx->sps.amp_enabled_flag) {
451 switch (PartMode) {
452 case PART_2NxN:
453 cabac->write_CABAC_bit(CONTEXT_MODEL_PART_MODE+1, 1);
454 cabac->write_CABAC_bit(CONTEXT_MODEL_PART_MODE+3, 1);
455 break;
456 case PART_Nx2N:
457 cabac->write_CABAC_bit(CONTEXT_MODEL_PART_MODE+1, 0);
458 cabac->write_CABAC_bit(CONTEXT_MODEL_PART_MODE+3, 1);
459 break;
460 case PART_2NxnU:
461 cabac->write_CABAC_bit(CONTEXT_MODEL_PART_MODE+1, 1);
462 cabac->write_CABAC_bit(CONTEXT_MODEL_PART_MODE+3, 0);
463 cabac->write_CABAC_bypass(0);
464 break;
465 case PART_2NxnD:
466 cabac->write_CABAC_bit(CONTEXT_MODEL_PART_MODE+1, 1);
467 cabac->write_CABAC_bit(CONTEXT_MODEL_PART_MODE+3, 0);
468 cabac->write_CABAC_bypass(1);
469 break;
470 case PART_nLx2N:
471 cabac->write_CABAC_bit(CONTEXT_MODEL_PART_MODE+1, 0);
472 cabac->write_CABAC_bit(CONTEXT_MODEL_PART_MODE+3, 0);
473 cabac->write_CABAC_bypass(0);
474 break;
475 case PART_nRx2N:
476 cabac->write_CABAC_bit(CONTEXT_MODEL_PART_MODE+1, 0);
477 cabac->write_CABAC_bit(CONTEXT_MODEL_PART_MODE+3, 0);
478 cabac->write_CABAC_bypass(1);
479 break;
480 case PART_NxN:
481 case PART_2Nx2N:
482 assert(false);
483 break;
484 }
485 }
486 else {
487 if (PartMode==PART_2NxN) {
488 cabac->write_CABAC_bit(CONTEXT_MODEL_PART_MODE+1, 1);
489 }
490 else {
491 assert(PartMode==PART_Nx2N);
492 cabac->write_CABAC_bit(CONTEXT_MODEL_PART_MODE+1, 0);
493 }
494 }
495 }
496 else {
497 if (PartMode==PART_2NxN) {
498 cabac->write_CABAC_bit(CONTEXT_MODEL_PART_MODE+1, 1);
499 }
500 else {
501 cabac->write_CABAC_bit(CONTEXT_MODEL_PART_MODE+1, 0);
502
503 if (cLog2CbSize==3) {
504 assert(PartMode==PART_Nx2N);
505 }
506 else {
507 if (PartMode==PART_Nx2N) {
508 cabac->write_CABAC_bit(CONTEXT_MODEL_PART_MODE+3, 1);
509 }
510 else {
511 assert(PartMode==PART_NxN);
512 cabac->write_CABAC_bit(CONTEXT_MODEL_PART_MODE+3, 0);
513 }
514 }
515 }
516 }
517 }
518 }
519
520
521 static void encode_pred_mode_flag(encoder_context* ectx,
522 CABAC_encoder* cabac,
523 enum PredMode PredMode)
524 {
525 logtrace(LogSlice,"> pred_mode = %d\n",PredMode);
526
527 int flag = (PredMode == MODE_INTRA) ? 1 : 0;
528
529 logtrace(LogSymbols,"$1 pred_mode=%d\n",flag);
530
531 cabac->write_CABAC_bit(CONTEXT_MODEL_PRED_MODE_FLAG, flag);
532 }
533
534
535 static void encode_prev_intra_luma_pred_flag(encoder_context* ectx,
536 CABAC_encoder* cabac,
537 int intraPred)
538 {
539 logtrace(LogSymbols,"$1 prev_intra_luma_pred_flag=%d\n",intraPred>=0);
540 int bin = (intraPred>=0);
541
542 logtrace(LogSlice,"> prev_intra_luma_pred_flag = %d\n",bin);
543
544 cabac->write_CABAC_bit(CONTEXT_MODEL_PREV_INTRA_LUMA_PRED_FLAG, bin);
545 }
546
547 static void encode_intra_mpm_or_rem(encoder_context* ectx,
548 CABAC_encoder* cabac,
549 int intraPred)
550 {
551 if (intraPred>=0) {
552 logtrace(LogSymbols,"$1 mpm_idx=%d\n",intraPred);
553 logtrace(LogSlice,"> mpm_idx = %d\n",intraPred);
554 assert(intraPred<=2);
555 cabac->write_CABAC_TU_bypass(intraPred, 2);
556 }
557 else {
558 logtrace(LogSymbols,"$1 rem_intra_luma_pred_mode=%d\n",-intraPred-1);
559 logtrace(LogSlice,"> rem_intra_luma_pred_mode = %d\n",-intraPred-1);
560 cabac->write_CABAC_FL_bypass(-intraPred-1, 5);
561 }
562 }
563
564
565 static void encode_intra_chroma_pred_mode(encoder_context* ectx,
566 CABAC_encoder* cabac,
567 int mode)
568 {
569 logtrace(LogSymbols,"$1 intra_chroma_pred_mode=%d\n",mode);
570 logtrace(LogSlice,"> intra_chroma_pred_mode = %d\n",mode);
571
572 if (mode==4) {
573 cabac->write_CABAC_bit(CONTEXT_MODEL_INTRA_CHROMA_PRED_MODE,0);
574 }
575 else {
576 assert(mode<4);
577
578 cabac->write_CABAC_bit(CONTEXT_MODEL_INTRA_CHROMA_PRED_MODE,1);
579 cabac->write_CABAC_FL_bypass(mode, 2);
580 }
581 }
582
583
584 /* Optimized variant that tests most likely branch first.
585 */
586 enum IntraChromaPredMode find_chroma_pred_mode(enum IntraPredMode chroma_mode,
587 enum IntraPredMode luma_mode)
588 {
589 // most likely mode: chroma mode = luma mode
590
591 if (luma_mode==chroma_mode) {
592 return INTRA_CHROMA_LIKE_LUMA;
593 }
594
595
596 // check remaining candidates
597
598 IntraPredMode mode = chroma_mode;
599
600 // angular-34 is coded by setting the coded mode equal to the luma_mode
601 if (chroma_mode == INTRA_ANGULAR_34) {
602 mode = luma_mode;
603 }
604
605 switch (mode) {
606 case INTRA_PLANAR: return INTRA_CHROMA_PLANAR_OR_34;
607 case INTRA_ANGULAR_26: return INTRA_CHROMA_ANGULAR_26_OR_34;
608 case INTRA_ANGULAR_10: return INTRA_CHROMA_ANGULAR_10_OR_34;
609 case INTRA_DC: return INTRA_CHROMA_DC_OR_34;
610 default:
611 assert(false);
612 return INTRA_CHROMA_DC_OR_34;
613 }
614 }
615
616
617
618 void encode_split_transform_flag(encoder_context* ectx,
619 CABAC_encoder* cabac,
620 int log2TrafoSize, int split_flag)
621 {
622 logtrace(LogSymbols,"$1 split_transform_flag=%d\n",split_flag);
623 logtrace(LogSlice,"> split_transform_flag = %d\n",split_flag);
624
625 int context = 5-log2TrafoSize;
626 assert(context >= 0 && context <= 2);
627
628 cabac->write_CABAC_bit(CONTEXT_MODEL_SPLIT_TRANSFORM_FLAG + context, split_flag);
629 }
630
631
632 void encode_cbf_luma(CABAC_encoder* cabac,
633 bool zeroTrafoDepth, int cbf_luma)
634 {
635 logtrace(LogSymbols,"$1 cbf_luma=%d\n",cbf_luma);
636 logtrace(LogSlice,"> cbf_luma = %d\n",cbf_luma);
637
638 int context = (zeroTrafoDepth ? 1 : 0);
639
640 cabac->write_CABAC_bit(CONTEXT_MODEL_CBF_LUMA + context, cbf_luma);
641 }
642
643
644 void encode_cbf_chroma(CABAC_encoder* cabac,
645 int trafoDepth, int cbf_chroma)
646 {
647 logtrace(LogSymbols,"$1 cbf_chroma=%d\n",cbf_chroma);
648 logtrace(LogSlice,"> cbf_chroma = %d\n",cbf_chroma);
649
650 int context = trafoDepth;
651 assert(context >= 0 && context <= 3);
652
653 cabac->write_CABAC_bit(CONTEXT_MODEL_CBF_CHROMA + context, cbf_chroma);
654 }
655
656 static inline void encode_coded_sub_block_flag(encoder_context* ectx,
657 CABAC_encoder* cabac,
658 int cIdx,
659 uint8_t coded_sub_block_neighbors,
660 int flag)
661 {
662 logtrace(LogSymbols,"$1 coded_sub_block_flag=%d\n",flag);
663 logtrace(LogSlice,"# coded_sub_block_flag = %d\n",flag);
664
665 // tricky computation of csbfCtx
666 int csbfCtx = ((coded_sub_block_neighbors & 1) | // right neighbor set or
667 (coded_sub_block_neighbors >> 1)); // bottom neighbor set -> csbfCtx=1
668
669 int ctxIdxInc = csbfCtx;
670 if (cIdx!=0) {
671 ctxIdxInc += 2;
672 }
673
674 cabac->write_CABAC_bit(CONTEXT_MODEL_CODED_SUB_BLOCK_FLAG + ctxIdxInc, flag);
675 }
676
677 static inline void encode_significant_coeff_flag_lookup(encoder_context* ectx,
678 CABAC_encoder* cabac,
679 uint8_t ctxIdxInc,
680 int significantFlag)
681 {
682 logtrace(LogSymbols,"$1 significant_coeff_flag=%d\n",significantFlag);
683 logtrace(LogSlice,"# significant_coeff_flag = significantFlag\n");
684 logtrace(LogSlice,"context: %d\n",ctxIdxInc);
685
686 cabac->write_CABAC_bit(CONTEXT_MODEL_SIGNIFICANT_COEFF_FLAG + ctxIdxInc, significantFlag);
687 }
688
689 static inline void encode_coeff_abs_level_greater1(encoder_context* ectx,
690 CABAC_encoder* cabac,
691 int cIdx, int i,
692 bool firstCoeffInSubblock,
693 bool firstSubblock,
694 int lastSubblock_greater1Ctx,
695 int* lastInvocation_greater1Ctx,
696 int* lastInvocation_coeff_abs_level_greater1_flag,
697 int* lastInvocation_ctxSet, int c1,
698 int value)
699 {
700 logtrace(LogSymbols,"$1 coeff_abs_level_greater1=%d\n",value);
701 logtrace(LogSlice,"# coeff_abs_level_greater1 = %d\n",value);
702
703 logtrace(LogSlice," cIdx:%d i:%d firstCoeffInSB:%d firstSB:%d lastSB>1:%d last>1Ctx:%d lastLev>1:%d lastCtxSet:%d\n", cIdx,i,firstCoeffInSubblock,firstSubblock,lastSubblock_greater1Ctx,
704 *lastInvocation_greater1Ctx,
705 *lastInvocation_coeff_abs_level_greater1_flag,
706 *lastInvocation_ctxSet);
707
708 int lastGreater1Ctx;
709 int greater1Ctx;
710 int ctxSet;
711
712 logtrace(LogSlice,"c1: %d\n",c1);
713
714 if (firstCoeffInSubblock) {
715 // block with real DC -> ctx 0
716 if (i==0 || cIdx>0) { ctxSet=0; }
717 else { ctxSet=2; }
718
719 if (firstSubblock) { lastGreater1Ctx=1; }
720 else { lastGreater1Ctx = lastSubblock_greater1Ctx; }
721
722 if (lastGreater1Ctx==0) { ctxSet++; }
723
724 logtrace(LogSlice,"ctxSet: %d\n",ctxSet);
725
726 greater1Ctx=1;
727 }
728 else { // !firstCoeffInSubblock
729 ctxSet = *lastInvocation_ctxSet;
730 logtrace(LogSlice,"ctxSet (old): %d\n",ctxSet);
731
732 greater1Ctx = *lastInvocation_greater1Ctx;
733 if (greater1Ctx>0) {
734 int lastGreater1Flag=*lastInvocation_coeff_abs_level_greater1_flag;
735 if (lastGreater1Flag==1) greater1Ctx=0;
736 else { /*if (greater1Ctx>0)*/ greater1Ctx++; }
737 }
738 }
739
740 ctxSet = c1; // use HM algo
741
742 int ctxIdxInc = (ctxSet*4) + (greater1Ctx>=3 ? 3 : greater1Ctx);
743
744 if (cIdx>0) { ctxIdxInc+=16; }
745
746 cabac->write_CABAC_bit(CONTEXT_MODEL_COEFF_ABS_LEVEL_GREATER1_FLAG + ctxIdxInc, value);
747
748 *lastInvocation_greater1Ctx = greater1Ctx;
749 *lastInvocation_coeff_abs_level_greater1_flag = value;
750 *lastInvocation_ctxSet = ctxSet;
751 }
752
753 static void encode_coeff_abs_level_greater2(encoder_context* ectx,
754 CABAC_encoder* cabac,
755 int cIdx, // int i,int n,
756 int ctxSet,
757 int value)
758 {
759 logtrace(LogSymbols,"$1 coeff_abs_level_greater2=%d\n",value);
760 logtrace(LogSlice,"# coeff_abs_level_greater2 = %d\n",value);
761
762 int ctxIdxInc = ctxSet;
763
764 if (cIdx>0) ctxIdxInc+=4;
765
766 cabac->write_CABAC_bit(CONTEXT_MODEL_COEFF_ABS_LEVEL_GREATER2_FLAG + ctxIdxInc, value);
767 }
768
769
770 bool TU(int val, int maxi)
771 {
772 for (int i=0;i<val;i++) {
773 printf("1");
774 }
775 if (val<maxi) { printf("0"); return false; }
776 else return true;
777 }
778
779 void bin(int val, int bits)
780 {
781 for (int i=0;i<bits;i++) {
782 int bit = (1<<(bits-1-i));
783 if (val&bit) printf("1"); else printf("0");
784 }
785 }
786
787 void ExpG(int level, int riceParam)
788 {
789 int prefix = level >> riceParam;
790 int suffix = level - (prefix<<riceParam);
791
792 //printf("%d %d ",prefix,suffix);
793
794 int base=0;
795 int range=1;
796 int nBits=0;
797 while (prefix >= base+range) {
798 printf("1");
799 base+=range;
800 range*=2;
801 nBits++;
802 }
803
804 printf("0.");
805 bin(prefix-base, nBits);
806 printf(":");
807 bin(suffix,riceParam);
808 }
809
810 int blamain()
811 {
812 int riceParam=2;
813 int TRMax = 4<<riceParam;
814
815 for (int level=0;level<128;level++)
816 {
817 printf("%d: ",level);
818
819 int prefixPart = std::min(TRMax, level);
820
821 // code TR prefix
822
823 bool isMaxi = TU(prefixPart>>riceParam, TRMax>>riceParam);
824 printf(":");
825 if (TRMax>prefixPart) {
826 int remain = prefixPart & ((1<<riceParam)-1);
827 bin(remain, riceParam);
828 }
829 printf("|");
830
831 if (isMaxi) {
832 ExpG(level-TRMax, riceParam+1);
833 }
834
835 printf("\n");
836 }
837
838 return 0;
839 }
840
841
842 static void encode_coeff_abs_level_remaining(encoder_context* ectx,
843 CABAC_encoder* cabac,
844 int cRiceParam,
845 int level)
846 {
847 logtrace(LogSymbols,"$1 coeff_abs_level_remaining=%d\n",level);
848 logtrace(LogSlice,"# encode_coeff_abs_level_remaining = %d\n",level);
849
850 int cTRMax = 4<<cRiceParam;
851 int prefixPart = std::min(level, cTRMax);
852
853 // --- code prefix with TR ---
854
855 // TU part, length 4 (cTRMax>>riceParam)
856
857 int nOnes = (prefixPart>>cRiceParam);
858 cabac->write_CABAC_TU_bypass(nOnes, 4);
859
860 // TR suffix
861
862 if (cTRMax > prefixPart) {
863 int remain = prefixPart & ((1<<cRiceParam)-1);
864 cabac->write_CABAC_FL_bypass(remain, cRiceParam);
865 }
866
867
868 // --- remainder suffix ---
869
870 if (nOnes==4) {
871 int remain = level-cTRMax;
872 int ExpGRiceParam = cRiceParam+1;
873
874 int prefix = remain >> ExpGRiceParam;
875 int suffix = remain - (prefix<<ExpGRiceParam);
876
877 int base=0;
878 int range=1;
879 int nBits=0;
880 while (prefix >= base+range) {
881 cabac->write_CABAC_bypass(1);
882 base+=range;
883 range*=2;
884 nBits++;
885 }
886
887 cabac->write_CABAC_bypass(0);
888 cabac->write_CABAC_FL_bypass(prefix-base, nBits);
889 cabac->write_CABAC_FL_bypass(suffix, ExpGRiceParam);
890 }
891 }
892
893 // ---------------------------------------------------------------------------
894
895 void findLastSignificantCoeff(const position* sbScan, const position* cScan,
896 const int16_t* coeff, int log2TrafoSize,
897 int* lastSignificantX, int* lastSignificantY,
898 int* lastSb, int* lastPos)
899 {
900 int nSb = 1<<((log2TrafoSize-2)<<1); // number of sub-blocks
901
902 // find last significant coefficient
903
904 for (int i=nSb ; i-->0 ;) {
905 int x0 = sbScan[i].x << 2;
906 int y0 = sbScan[i].y << 2;
907 for (int c=16 ; c-->0 ;) {
908 int x = x0 + cScan[c].x;
909 int y = y0 + cScan[c].y;
910
911 if (coeff[x+(y<<log2TrafoSize)]) {
912 *lastSignificantX = x;
913 *lastSignificantY = y;
914 *lastSb = i;
915 *lastPos= c;
916
917 logtrace(LogSlice,"last significant coeff at: %d;%d, Sb:%d Pos:%d\n", x,y,i,c);
918
919 return;
920 }
921 }
922 }
923
924 // all coefficients == 0 ? cannot be since cbf should be false in this case
925 assert(false);
926 }
927
928
929 bool subblock_has_nonzero_coefficient(const int16_t* coeff, int coeffStride,
930 const position& sbPos)
931 {
932 int x0 = sbPos.x << 2;
933 int y0 = sbPos.y << 2;
934
935 coeff += x0 + y0*coeffStride;
936
937 for (int y=0;y<4;y++) {
938 if (coeff[0] || coeff[1] || coeff[2] || coeff[3]) { return true; }
939 coeff += coeffStride;
940 }
941
942 return false;
943 }
944
945 /*
946 Example 16x16: prefix in [0;7]
947
948 prefix | last pos
949 =============|=============
950 0 | 0
951 1 | 1
952 2 | 2
953 3 | 3
954 -------------+-------------
955 lsb nBits |
956 4 0 1 | 4, 5
957 5 1 1 | 6, 7
958 6 0 2 | 8, 9,10,11
959 7 1 2 | 12,13,14,15
960 */
961 void encode_last_signficiant_coeff_prefix(encoder_context* ectx,
962 CABAC_encoder* cabac,
963 int log2TrafoSize,
964 int cIdx, int lastSignificant,
965 int context_model_index)
966 {
967 logtrace(LogSlice,"> last_significant_coeff_prefix=%d log2TrafoSize:%d cIdx:%d\n",
968 lastSignificant,log2TrafoSize,cIdx);
969
970 int cMax = (log2TrafoSize<<1)-1;
971
972 int ctxOffset, ctxShift;
973 if (cIdx==0) {
974 ctxOffset = 3*(log2TrafoSize-2) + ((log2TrafoSize-1)>>2);
975 ctxShift = (log2TrafoSize+1)>>2;
976 }
977 else {
978 ctxOffset = 15;
979 ctxShift = log2TrafoSize-2;
980 }
981
982 for (int binIdx=0;binIdx<lastSignificant;binIdx++)
983 {
984 int ctxIdxInc = (binIdx >> ctxShift);
985 cabac->write_CABAC_bit(context_model_index + ctxOffset + ctxIdxInc, 1);
986 }
987
988 if (lastSignificant != cMax) {
989 int binIdx = lastSignificant;
990 int ctxIdxInc = (binIdx >> ctxShift);
991 cabac->write_CABAC_bit(context_model_index + ctxOffset + ctxIdxInc, 0);
992 }
993 }
994
995
996 void split_last_significant_position(int pos, int* prefix, int* suffix, int* nSuffixBits)
997 {
998 logtrace(LogSlice,"split position %d : ",pos);
999
1000 // most frequent case
1001
1002 if (pos<=3) {
1003 *prefix=pos;
1004 *suffix=-1; // just to have some defined value
1005 *nSuffixBits=0;
1006 logtrace(LogSlice,"prefix=%d suffix=%d (%d bits)\n",*prefix,*suffix,*nSuffixBits);
1007 return;
1008 }
1009
1010 pos -= 4;
1011 int nBits=1;
1012 int range=4;
1013 while (pos>=range) {
1014 nBits++;
1015 pos-=range;
1016 range<<=1;
1017 }
1018
1019 *prefix = (1+nBits)<<1;
1020 if (pos >= (range>>1)) {
1021 *prefix |= 1;
1022 pos -= (range>>1);
1023 }
1024 *suffix = pos;
1025 *nSuffixBits = nBits;
1026
1027 logtrace(LogSlice,"prefix=%d suffix=%d (%d bits)\n",*prefix,*suffix,*nSuffixBits);
1028 }
1029
1030
1031 extern uint8_t* ctxIdxLookup[4 /* 4-log2-32 */][2 /* !!cIdx */][2 /* !!scanIdx */][4 /* prevCsbf */];
1032
1033 /* These values are read from the image metadata:
1034 - intra prediction mode (x0;y0)
1035 */
1036 void encode_residual(encoder_context* ectx,
1037 CABAC_encoder* cabac,
1038 const enc_tb* tb, const enc_cb* cb,
1039 int x0,int y0,int log2TrafoSize,int cIdx)
1040 {
1041 const de265_image* img = ectx->img;
1042 const seq_parameter_set& sps = img->sps;
1043 const pic_parameter_set& pps = img->pps;
1044
1045 int16_t* coeff = tb->coeff[cIdx];
1046
1047 if (pps.transform_skip_enabled_flag && true /* TODO */) {
1048 }
1049
1050
1051 #if 0
1052 printf("write coefficients\n");
1053 for (int y=0;y<(1<<log2TrafoSize);y++)
1054 {
1055 for (int x=0;x<(1<<log2TrafoSize);x++)
1056 {
1057 printf("%4d ",coeff[x+y*(1<<log2TrafoSize)]);
1058 }
1059 printf("\n");
1060 }
1061 #endif
1062
1063
1064 // --- get scan orders ---
1065
1066 enum PredMode PredMode = cb->PredMode;
1067 int scanIdx;
1068
1069 if (PredMode == MODE_INTRA) {
1070 if (cIdx==0) {
1071 scanIdx = get_intra_scan_idx_luma(log2TrafoSize, img->get_IntraPredMode(x0,y0));
1072 }
1073 else {
1074 enum IntraPredMode chromaMode = cb->intra.chroma_mode;
1075 /*
1076 enum IntraPredMode chromaMode = lumaPredMode_to_chromaPredMode(img->get_IntraPredMode(x0,y0),
1077 cb->intra.chroma_mode);
1078 */
1079 scanIdx = get_intra_scan_idx_chroma(log2TrafoSize, chromaMode);
1080 }
1081 }
1082 else {
1083 scanIdx=0;
1084 }
1085
1086
1087 const position* ScanOrderSub = get_scan_order(log2TrafoSize-2, scanIdx);
1088 const position* ScanOrderPos = get_scan_order(2, scanIdx);
1089
1090 int lastSignificantX, lastSignificantY;
1091 int lastScanPos;
1092 int lastSubBlock;
1093 findLastSignificantCoeff(ScanOrderSub, ScanOrderPos,
1094 coeff, log2TrafoSize,
1095 &lastSignificantX, &lastSignificantY,
1096 &lastSubBlock, &lastScanPos);
1097
1098 int codedSignificantX = lastSignificantX;
1099 int codedSignificantY = lastSignificantY;
1100
1101 if (scanIdx==2) {
1102 std::swap(codedSignificantX, codedSignificantY);
1103 }
1104
1105
1106
1107 int prefixX, suffixX, suffixBitsX;
1108 int prefixY, suffixY, suffixBitsY;
1109
1110 split_last_significant_position(codedSignificantX, &prefixX,&suffixX,&suffixBitsX);
1111 split_last_significant_position(codedSignificantY, &prefixY,&suffixY,&suffixBitsY);
1112
1113 encode_last_signficiant_coeff_prefix(ectx, cabac, log2TrafoSize, cIdx, prefixX,
1114 CONTEXT_MODEL_LAST_SIGNIFICANT_COEFFICIENT_X_PREFIX);
1115
1116 encode_last_signficiant_coeff_prefix(ectx, cabac, log2TrafoSize, cIdx, prefixY,
1117 CONTEXT_MODEL_LAST_SIGNIFICANT_COEFFICIENT_Y_PREFIX);
1118
1119
1120 if (codedSignificantX > 3) {
1121 cabac->write_CABAC_FL_bypass(suffixX, suffixBitsX);
1122 }
1123 if (codedSignificantY > 3) {
1124 cabac->write_CABAC_FL_bypass(suffixY, suffixBitsY);
1125 }
1126
1127
1128
1129 int sbWidth = 1<<(log2TrafoSize-2);
1130 int CoeffStride = 1<<log2TrafoSize;
1131
1132 uint8_t coded_sub_block_neighbors[32/4*32/4]; // 64*2 flags
1133 memset(coded_sub_block_neighbors,0,sbWidth*sbWidth);
1134
1135 int c1 = 1;
1136 bool firstSubblock = true; // for coeff_abs_level_greater1_flag context model
1137 int lastSubblock_greater1Ctx=false; /* for coeff_abs_level_greater1_flag context model
1138 (initialization not strictly needed)
1139 */
1140
1141 int lastInvocation_greater1Ctx=0;
1142 int lastInvocation_coeff_abs_level_greater1_flag=0;
1143 int lastInvocation_ctxSet=0;
1144
1145
1146
1147 // ----- encode coefficients -----
1148
1149 //tctx->nCoeff[cIdx] = 0;
1150
1151
1152 // i - subblock index
1153 // n - coefficient index in subblock
1154
1155 for (int i=lastSubBlock;i>=0;i--) {
1156 position S = ScanOrderSub[i];
1157 int inferSbDcSigCoeffFlag=0;
1158
1159 logtrace(LogSlice,"sub block scan idx: %d\n",i);
1160
1161
1162 // --- check whether this sub-block has to be coded ---
1163
1164 int sub_block_is_coded = 0;
1165
1166 if ((i<lastSubBlock) && (i>0)) {
1167 sub_block_is_coded = subblock_has_nonzero_coefficient(coeff, CoeffStride, S);
1168 encode_coded_sub_block_flag(ectx, cabac, cIdx,
1169 coded_sub_block_neighbors[S.x+S.y*sbWidth],
1170 sub_block_is_coded);
1171 inferSbDcSigCoeffFlag=1;
1172 }
1173 else if (i==0 || i==lastSubBlock) {
1174 // first (DC) and last sub-block are always coded
1175 // - the first will most probably contain coefficients
1176 // - the last obviously contains the last coded coefficient
1177
1178 sub_block_is_coded = 1;
1179 }
1180
1181 if (sub_block_is_coded) {
1182 if (S.x > 0) coded_sub_block_neighbors[S.x-1 + S.y *sbWidth] |= 1;
1183 if (S.y > 0) coded_sub_block_neighbors[S.x + (S.y-1)*sbWidth] |= 2;
1184 }
1185
1186 logtrace(LogSlice,"subblock is coded: %s\n", sub_block_is_coded ? "yes":"no");
1187
1188
1189 // --- write significant coefficient flags ---
1190
1191 int16_t coeff_value[16];
1192 int16_t coeff_baseLevel[16];
1193 int8_t coeff_scan_pos[16];
1194 int8_t coeff_sign[16];
1195 int8_t coeff_has_max_base_level[16];
1196 int nCoefficients=0;
1197
1198
1199 if (sub_block_is_coded) {
1200 int x0 = S.x<<2;
1201 int y0 = S.y<<2;
1202
1203 int log2w = log2TrafoSize-2;
1204 int prevCsbf = coded_sub_block_neighbors[S.x+S.y*sbWidth];
1205 uint8_t* ctxIdxMap = ctxIdxLookup[log2w][!!cIdx][!!scanIdx][prevCsbf];
1206
1207
1208
1209
1210 // set the last coded coefficient in the last subblock
1211
1212 if (i==lastSubBlock) {
1213 coeff_value[nCoefficients] = coeff[lastSignificantX+(lastSignificantY<<log2TrafoSize)];
1214 coeff_has_max_base_level[nCoefficients] = 1; // TODO
1215 coeff_scan_pos[nCoefficients] = lastScanPos;
1216 nCoefficients++;
1217 }
1218
1219
1220 // --- encode all coefficients' significant_coeff flags except for the DC coefficient ---
1221
1222 int last_coeff = (i==lastSubBlock) ? lastScanPos-1 : 15;
1223
1224 for (int n= last_coeff ; n>0 ; n--) {
1225 int subX = ScanOrderPos[n].x;
1226 int subY = ScanOrderPos[n].y;
1227 int xC = x0 + subX;
1228 int yC = y0 + subY;
1229
1230
1231 // for all AC coefficients in sub-block, a significant_coeff flag is coded
1232
1233 int isSignificant = !!tb->coeff[cIdx][xC + (yC<<log2TrafoSize)];
1234
1235 logtrace(LogSlice,"coeff %d is significant: %d\n", n, isSignificant);
1236
1237 logtrace(LogSlice,"context idx: %d;%d\n",xC,yC);
1238
1239 encode_significant_coeff_flag_lookup(ectx, cabac,
1240 ctxIdxMap[xC+(yC<<log2TrafoSize)],
1241 isSignificant);
1242 //ctxIdxMap[(i<<4)+n]);
1243
1244 if (isSignificant) {
1245 coeff_value[nCoefficients] = coeff[xC+(yC<<log2TrafoSize)];
1246 coeff_has_max_base_level[nCoefficients] = 1;
1247 coeff_scan_pos[nCoefficients] = n;
1248 nCoefficients++;
1249
1250 // since we have a coefficient in the sub-block,
1251 // we cannot infer the DC coefficient anymore
1252 inferSbDcSigCoeffFlag = 0;
1253 }
1254 }
1255
1256
1257 // --- decode DC coefficient significance ---
1258
1259 if (last_coeff>=0) // last coded coefficient (always set to 1) is not the DC coefficient
1260 {
1261 if (inferSbDcSigCoeffFlag==0) {
1262 // if we cannot infert the DC coefficient, it is coded
1263 int isSignificant = !!tb->coeff[cIdx][x0 + (y0<<log2TrafoSize)];
1264
1265 logtrace(LogSlice,"DC coeff is significant: %d\n", isSignificant);
1266
1267 encode_significant_coeff_flag_lookup(ectx, cabac,
1268 ctxIdxMap[x0+(y0<<log2TrafoSize)],
1269 isSignificant);
1270
1271 if (isSignificant) {
1272 coeff_value[nCoefficients] = coeff[x0+(y0<<log2TrafoSize)];
1273 coeff_has_max_base_level[nCoefficients] = 1;
1274 coeff_scan_pos[nCoefficients] = 0;
1275 nCoefficients++;
1276 }
1277 }
1278 else {
1279 // we can infer that the DC coefficient must be present
1280 coeff_value[nCoefficients] = coeff[x0+(y0<<log2TrafoSize)];
1281 coeff_has_max_base_level[nCoefficients] = 1;
1282 coeff_scan_pos[nCoefficients] = 0;
1283 nCoefficients++;
1284 }
1285 }
1286 }
1287
1288
1289
1290 // --- encode coefficient values ---
1291
1292 if (nCoefficients) {
1293
1294 // separate absolute coefficient value and sign
1295
1296 logtrace(LogSlice,"coefficients to code: ");
1297
1298 for (int l=0;l<nCoefficients;l++) {
1299 logtrace(LogSlice,"%d ",coeff_value[l]);
1300
1301 if (coeff_value[l]<0) {
1302 coeff_value[l] = -coeff_value[l];
1303 coeff_sign[l] = 1;
1304 }
1305 else {
1306 coeff_sign[l] = 0;
1307 }
1308
1309 coeff_baseLevel[l] = 1;
1310
1311 logtrace(LogSlice,"(%d) ",coeff_scan_pos[l]);
1312 }
1313
1314 logtrace(LogSlice,"\n");
1315
1316
1317 int ctxSet;
1318 if (i==0 || cIdx>0) { ctxSet=0; }
1319 else { ctxSet=2; }
1320
1321 if (c1==0) { ctxSet++; }
1322 c1=1;
1323
1324
1325 // --- encode greater-1 flags ---
1326
1327 int newLastGreater1ScanPos=-1;
1328
1329 int lastGreater1Coefficient = libde265_min(8,nCoefficients);
1330 for (int c=0;c<lastGreater1Coefficient;c++) {
1331 int greater1_flag = (coeff_value[c]>1);
1332
1333 encode_coeff_abs_level_greater1(ectx, cabac, cIdx,i,
1334 c==0,
1335 firstSubblock,
1336 lastSubblock_greater1Ctx,
1337 &lastInvocation_greater1Ctx,
1338 &lastInvocation_coeff_abs_level_greater1_flag,
1339 &lastInvocation_ctxSet, ctxSet,
1340 greater1_flag);
1341
1342 if (greater1_flag) {
1343 coeff_baseLevel[c]++;
1344
1345 c1=0;
1346
1347 if (newLastGreater1ScanPos == -1) {
1348 newLastGreater1ScanPos=c;
1349 }
1350 }
1351 else {
1352 coeff_has_max_base_level[c] = 0;
1353
1354 if (c1<3 && c1>0) {
1355 c1++;
1356 }
1357 }
1358 }
1359
1360 firstSubblock = false;
1361 lastSubblock_greater1Ctx = lastInvocation_greater1Ctx;
1362
1363
1364 // --- decode greater-2 flag ---
1365
1366 if (newLastGreater1ScanPos != -1) {
1367 int greater2_flag = (coeff_value[newLastGreater1ScanPos]>2);
1368 encode_coeff_abs_level_greater2(ectx,cabac, cIdx, lastInvocation_ctxSet, greater2_flag);
1369 coeff_baseLevel[newLastGreater1ScanPos] += greater2_flag;
1370 coeff_has_max_base_level[newLastGreater1ScanPos] = greater2_flag;
1371 }
1372
1373
1374 // --- encode coefficient signs ---
1375
1376 int signHidden = (coeff_scan_pos[0]-coeff_scan_pos[nCoefficients-1] > 3 &&
1377 !cb->cu_transquant_bypass_flag);
1378
1379 for (int n=0;n<nCoefficients-1;n++) {
1380 cabac->write_CABAC_bypass(coeff_sign[n]);
1381 //logtrace(LogSlice,"a) sign[%d] = %d\n", n, coeff_sign[n]);
1382 }
1383
1384 // n==nCoefficients-1
1385 if (!pps.sign_data_hiding_flag || !signHidden) {
1386 cabac->write_CABAC_bypass(coeff_sign[nCoefficients-1]);
1387 //logtrace(LogSlice,"b) sign[%d] = %d\n", nCoefficients-1, coeff_sign[nCoefficients-1]);
1388 }
1389 else {
1390 assert(coeff_sign[nCoefficients-1] == 0);
1391 }
1392
1393 // --- decode coefficient value ---
1394
1395 int sumAbsLevel=0;
1396 int uiGoRiceParam=0;
1397
1398 for (int n=0;n<nCoefficients;n++) {
1399 int baseLevel = coeff_baseLevel[n];
1400
1401 int coeff_abs_level_remaining;
1402
1403 if (coeff_has_max_base_level[n]) {
1404 logtrace(LogSlice,"value[%d]=%d, base level: %d\n",n,coeff_value[n],coeff_baseLevel[n]);
1405
1406 coeff_abs_level_remaining = coeff_value[n] - coeff_baseLevel[n];
1407
1408 encode_coeff_abs_level_remaining(ectx, cabac, uiGoRiceParam,
1409 coeff_abs_level_remaining);
1410
1411 // (9-462)
1412 if (baseLevel + coeff_abs_level_remaining > 3*(1<<uiGoRiceParam)) {
1413 uiGoRiceParam++;
1414 if (uiGoRiceParam>4) uiGoRiceParam=4;
1415 }
1416 }
1417 else {
1418 coeff_abs_level_remaining = 0;
1419 }
1420
1421
1422 // --- DEBUG: check coefficient ---
1423
1424 #if 0
1425 int16_t currCoeff = baseLevel + coeff_abs_level_remaining;
1426 if (coeff_sign[n]) {
1427 currCoeff = -currCoeff;
1428 }
1429
1430 if (pps.sign_data_hiding_flag && signHidden) {
1431 sumAbsLevel += baseLevel + coeff_abs_level_remaining;
1432
1433 if (n==nCoefficients-1 && (sumAbsLevel & 1)) {
1434 currCoeff = -currCoeff;
1435 }
1436 }
1437
1438 assert(currCoeff == coeff_value[n]);
1439 #endif
1440 } // iterate through coefficients in sub-block
1441 } // if nonZero
1442
1443 }
1444 }
1445
1446
1447 void encode_transform_unit(encoder_context* ectx,
1448 CABAC_encoder* cabac,
1449 const enc_tb* tb, const enc_cb* cb,
1450 int x0,int y0, int xBase,int yBase,
1451 int log2TrafoSize, int trafoDepth, int blkIdx)
1452 {
1453 if (tb->cbf[0] || tb->cbf[1] || tb->cbf[2]) {
1454 if (ectx->img->pps.cu_qp_delta_enabled_flag &&
1455 true /*!ectx->IsCuQpDeltaCoded*/) {
1456 assert(0);
1457 }
1458
1459 if (tb->cbf[0]) {
1460 encode_residual(ectx,cabac, tb,cb,x0,y0,log2TrafoSize,0);
1461 }
1462
1463 // larger than 4x4
1464 if (log2TrafoSize>2) {
1465 if (tb->cbf[1]) {
1466 encode_residual(ectx,cabac,tb,cb,x0,y0,log2TrafoSize-1,1);
1467 }
1468 if (tb->cbf[2]) {
1469 encode_residual(ectx,cabac,tb,cb,x0,y0,log2TrafoSize-1,2);
1470 }
1471 }
1472 else if (blkIdx==3) {
1473 // cannot check for tb->parent->cbf[], because this may not yet be set
1474 if (tb->cbf[1]) {
1475 encode_residual(ectx,cabac,tb,cb,xBase,yBase,log2TrafoSize,1);
1476 }
1477 if (tb->cbf[2]) {
1478 encode_residual(ectx,cabac,tb,cb,xBase,yBase,log2TrafoSize,2);
1479 }
1480 }
1481 }
1482 }
1483
1484
1485 void encode_transform_tree(encoder_context* ectx,
1486 CABAC_encoder* cabac,
1487 const enc_tb* tb, const enc_cb* cb,
1488 int x0,int y0, int xBase,int yBase,
1489 int log2TrafoSize, int trafoDepth, int blkIdx,
1490 int MaxTrafoDepth, int IntraSplitFlag, bool recurse)
1491 {
1492 //de265_image* img = ectx->img;
1493 const seq_parameter_set* sps = &ectx->img->sps;
1494
1495 if (log2TrafoSize <= sps->Log2MaxTrafoSize &&
1496 log2TrafoSize > sps->Log2MinTrafoSize &&
1497 trafoDepth < MaxTrafoDepth &&
1498 !(IntraSplitFlag && trafoDepth==0))
1499 {
1500 int split_transform_flag = tb->split_transform_flag;
1501 encode_split_transform_flag(ectx, cabac, log2TrafoSize, split_transform_flag);
1502 }
1503 else
1504 {
1505 int interSplitFlag=0; // TODO
1506
1507 bool split_transform_flag = (log2TrafoSize > sps->Log2MaxTrafoSize ||
1508 (IntraSplitFlag==1 && trafoDepth==0) ||
1509 interSplitFlag==1) ? 1:0;
1510
1511 /*
1512 printf("split_transform_flag log2TrafoSize:%d Log2MaxTrafoSize:%d "
1513 "IntraSplitFlag:%d trafoDepth:%d -> %d\n",
1514 log2TrafoSize,sps->Log2MaxTrafoSize,
1515 IntraSplitFlag, trafoDepth,
1516 split_transform_flag);
1517 */
1518
1519 assert(tb->split_transform_flag == split_transform_flag);
1520 }
1521
1522 // --- CBF CB/CR ---
1523
1524 // For 4x4 luma, there is no signaling of chroma CBF, because only the
1525 // chroma CBF for 8x8 is relevant.
1526 if (log2TrafoSize>2) {
1527 if (trafoDepth==0 || tb->parent->cbf[1]) {
1528 encode_cbf_chroma(cabac, trafoDepth, tb->cbf[1]);
1529 }
1530 if (trafoDepth==0 || tb->parent->cbf[2]) {
1531 encode_cbf_chroma(cabac, trafoDepth, tb->cbf[2]);
1532 }
1533 }
1534
1535 if (tb->split_transform_flag) {
1536 if (recurse) {
1537 int x1 = x0 + (1<<(log2TrafoSize-1));
1538 int y1 = y0 + (1<<(log2TrafoSize-1));
1539
1540 encode_transform_tree(ectx, cabac, tb->children[0], cb, x0,y0,x0,y0,log2TrafoSize-1,
1541 trafoDepth+1, 0, MaxTrafoDepth, IntraSplitFlag, true);
1542 encode_transform_tree(ectx, cabac, tb->children[1], cb, x1,y0,x0,y0,log2TrafoSize-1,
1543 trafoDepth+1, 1, MaxTrafoDepth, IntraSplitFlag, true);
1544 encode_transform_tree(ectx, cabac, tb->children[2], cb, x0,y1,x0,y0,log2TrafoSize-1,
1545 trafoDepth+1, 2, MaxTrafoDepth, IntraSplitFlag, true);
1546 encode_transform_tree(ectx, cabac, tb->children[3], cb, x1,y1,x0,y0,log2TrafoSize-1,
1547 trafoDepth+1, 3, MaxTrafoDepth, IntraSplitFlag, true);
1548 }
1549 }
1550 else {
1551 if (cb->PredMode == MODE_INTRA || trafoDepth != 0 ||
1552 tb->cbf[1] || tb->cbf[2]) {
1553 encode_cbf_luma(cabac, trafoDepth==0, tb->cbf[0]);
1554 }
1555 else {
1556 /* Note: usually, cbf[0] should be TRUE, but while estimating the bitrate, this
1557 function can also be called with all CBFs FALSE. Usually, this is handled by
1558 the rqt_root_cbf flag, but during analysis, this is set after the bitrate is estimated.
1559 */
1560 // assert(tb->cbf[0]==true);
1561 }
1562
1563 encode_transform_unit(ectx,cabac, tb,cb, x0,y0, xBase,yBase, log2TrafoSize, trafoDepth, blkIdx);
1564 }
1565 }
1566
1567
1568 void encode_cu_skip_flag(encoder_context* ectx,
1569 CABAC_encoder* cabac,
1570 const enc_cb* cb,
1571 bool skip)
1572 {
1573 logtrace(LogSymbols,"$1 cu_skip_flag=%d\n",skip);
1574
1575 const de265_image* img = ectx->img;
1576
1577 int x0 = cb->x;
1578 int y0 = cb->y;
1579
1580 // check if neighbors are available
1581
1582 int availableL = check_CTB_available(img, x0,y0, x0-1,y0);
1583 int availableA = check_CTB_available(img, x0,y0, x0,y0-1);
1584
1585 int condL = 0;
1586 int condA = 0;
1587
1588 if (availableL && img->get_cu_skip_flag(x0-1,y0)) condL=1;
1589 if (availableA && img->get_cu_skip_flag(x0,y0-1)) condA=1;
1590
1591 int contextOffset = condL + condA;
1592 int context = contextOffset;
1593
1594 // decode bit
1595
1596 int bit = skip;
1597
1598 logtrace(LogSlice,"> cu_skip_flag ctx=%d, bit=%d\n", context,bit);
1599
1600 cabac->write_CABAC_bit(CONTEXT_MODEL_CU_SKIP_FLAG + context, bit);
1601 }
1602
1603
1604 void encode_merge_idx(encoder_context* ectx,
1605 CABAC_encoder* cabac,
1606 int mergeIdx)
1607 {
1608 logtrace(LogSymbols,"$1 merge_idx=%d\n",mergeIdx);
1609 logtrace(LogSlice,"# merge_idx %d\n", mergeIdx);
1610
1611 if (ectx->shdr->MaxNumMergeCand <= 1) {
1612 return; // code nothing, we use only a single merge candidate
1613 }
1614
1615 // TU coding, first bin is CABAC, remaining are bypass.
1616 // cMax = MaxNumMergeCand-1
1617
1618 cabac->write_CABAC_bit(CONTEXT_MODEL_MERGE_IDX, mergeIdx ? 1 : 0);
1619
1620 if (mergeIdx>0) {
1621 int idx=1;
1622
1623 while (idx<ectx->shdr->MaxNumMergeCand-1) {
1624 int increase = (idx < mergeIdx);
1625
1626 cabac->write_CABAC_bypass(increase);
1627 if (increase) {
1628 idx++;
1629 }
1630 else {
1631 break;
1632 }
1633 }
1634 }
1635 }
1636
1637
1638 static inline void encode_rqt_root_cbf(encoder_context* ectx,
1639 CABAC_encoder* cabac,
1640 int rqt_root_cbf)
1641 {
1642 logtrace(LogSymbols,"$1 rqt_root_cbf=%d\n",rqt_root_cbf);
1643 cabac->write_CABAC_bit(CONTEXT_MODEL_RQT_ROOT_CBF, rqt_root_cbf);
1644 }
1645
1646
1647 void encode_mvd(encoder_context* ectx,
1648 CABAC_encoder* cabac,
1649 const int16_t mvd[2])
1650 {
1651 int mvd0abs = abs_value(mvd[0]);
1652 int mvd1abs = abs_value(mvd[1]);
1653
1654 int mvd0_greater_0 = !!(mvd0abs);
1655 int mvd1_greater_0 = !!(mvd1abs);
1656
1657 cabac->write_CABAC_bit(CONTEXT_MODEL_ABS_MVD_GREATER01_FLAG+0, mvd0_greater_0);
1658 cabac->write_CABAC_bit(CONTEXT_MODEL_ABS_MVD_GREATER01_FLAG+0, mvd1_greater_0);
1659
1660 if (mvd0_greater_0) {
1661 cabac->write_CABAC_bit(CONTEXT_MODEL_ABS_MVD_GREATER01_FLAG+1, mvd0abs>1);
1662 }
1663 if (mvd1_greater_0) {
1664 cabac->write_CABAC_bit(CONTEXT_MODEL_ABS_MVD_GREATER01_FLAG+1, mvd1abs>1);
1665 }
1666
1667 if (mvd0abs) {
1668 if (mvd0abs>1) {
1669 cabac->write_CABAC_EGk(mvd0abs-2,1);
1670 }
1671 cabac->write_CABAC_bypass(mvd[0]<0);
1672 }
1673
1674 if (mvd1abs) {
1675 if (mvd1abs>1) {
1676 cabac->write_CABAC_EGk(mvd1abs-2,1);
1677 }
1678 cabac->write_CABAC_bypass(mvd[1]<0);
1679 }
1680 }
1681
1682
1683 void encode_prediction_unit(encoder_context* ectx,
1684 CABAC_encoder* cabac,
1685 const enc_cb* cb, int pbIdx,
1686 int x0,int y0, int w, int h)
1687 {
1688 const enc_pb_inter& pb = cb->inter.pb[pbIdx];
1689
1690 logtrace(LogSymbols,"$1 merge_flag=%d\n",pb.spec.merge_flag);
1691 cabac->write_CABAC_bit(CONTEXT_MODEL_MERGE_FLAG, pb.spec.merge_flag);
1692
1693 if (pb.spec.merge_flag) {
1694 assert(false); // TODO
1695 }
1696 else {
1697 if (ectx->shdr->slice_type == SLICE_TYPE_B) {
1698 assert(false); // TODO
1699 }
1700
1701 if (pb.spec.inter_pred_idc != PRED_L1) {
1702 if (ectx->shdr->num_ref_idx_l0_active > 1) {
1703 assert(false); // TODO
1704 //cabac->write_CABAC_bit(CONTEXT_MODEL_REF_IDX_LX, pb.spec.mvp_l0_flag);
1705 }
1706
1707 encode_mvd(ectx,cabac, pb.spec.mvd[0]);
1708
1709 logtrace(LogSymbols,"$1 mvp_lx_flag=%d\n",pb.spec.mvp_l0_flag);
1710 cabac->write_CABAC_bit(CONTEXT_MODEL_MVP_LX_FLAG, pb.spec.mvp_l0_flag);
1711 }
1712
1713 if (pb.spec.inter_pred_idc != PRED_L0) {
1714 assert(false); // TODO
1715 }
1716
1717 /*
1718 enum InterPredIdc
1719 PRED_L0=0,
1720 PRED_L1=1,
1721 PRED_BI=2
1722 */
1723 }
1724 }
1725
1726
1727 void encode_coding_unit(encoder_context* ectx,
1728 CABAC_encoder* cabac,
1729 const enc_cb* cb, int x0,int y0, int log2CbSize, bool recurse)
1730 {
1731 logtrace(LogSlice,"--- encode CU (%d;%d) ---\n",x0,y0);
1732
1733 de265_image* img = ectx->img;
1734 const slice_segment_header* shdr = &ectx->imgdata->shdr;
1735 const seq_parameter_set* sps = &ectx->img->sps;
1736
1737
1738 int nCbS = 1<<log2CbSize;
1739
1740
1741 // write skip_flag
1742
1743 if (shdr->slice_type != SLICE_TYPE_I) {
1744 encode_cu_skip_flag(ectx,cabac, cb, cb->PredMode==MODE_SKIP);
1745 }
1746
1747 if (cb->PredMode==MODE_SKIP) {
1748 assert(cb->inter.pb[0].spec.merge_flag);
1749 encode_merge_idx(ectx,cabac, cb->inter.pb[0].spec.merge_idx);
1750 }
1751 else {
1752
1753 enum PredMode PredMode = cb->PredMode;
1754 enum PartMode PartMode = PART_2Nx2N;
1755 int IntraSplitFlag=0;
1756
1757 if (shdr->slice_type != SLICE_TYPE_I) {
1758 encode_pred_mode_flag(ectx,cabac, PredMode);
1759 }
1760
1761 if (PredMode != MODE_INTRA ||
1762 log2CbSize == sps->Log2MinCbSizeY) {
1763 PartMode = cb->PartMode;
1764 encode_part_mode(ectx,cabac, PredMode, PartMode, log2CbSize);
1765 }
1766
1767 if (PredMode == MODE_INTRA) {
1768
1769 int availableA0 = check_CTB_available(img, x0,y0, x0-1,y0);
1770 int availableB0 = check_CTB_available(img, x0,y0, x0,y0-1);
1771
1772 if (PartMode==PART_2Nx2N) {
1773 logtrace(LogSlice,"x0,y0: %d,%d\n",x0,y0);
1774 int PUidx = (x0>>sps->Log2MinPUSize) + (y0>>sps->Log2MinPUSize)*sps->PicWidthInMinPUs;
1775
1776 int candModeList[3];
1777 fillIntraPredModeCandidates(candModeList,x0,y0,PUidx,
1778 availableA0,availableB0, img);
1779
1780 for (int i=0;i<3;i++)
1781 logtrace(LogSlice,"candModeList[%d] = %d\n", i, candModeList[i]);
1782
1783 enum IntraPredMode mode = cb->intra.pred_mode[0];
1784 int intraPred = find_intra_pred_mode(mode, candModeList);
1785 encode_prev_intra_luma_pred_flag(ectx,cabac, intraPred);
1786 encode_intra_mpm_or_rem(ectx,cabac, intraPred);
1787
1788 logtrace(LogSlice,"IntraPredMode: %d (candidates: %d %d %d)\n", mode,
1789 candModeList[0], candModeList[1], candModeList[2]);
1790 logtrace(LogSlice," MPM/REM = %d\n",intraPred);
1791 }
1792 else {
1793 IntraSplitFlag=1;
1794
1795 int pbOffset = nCbS/2;
1796 int PUidx;
1797
1798 int intraPred[4];
1799 int childIdx=0;
1800
1801 for (int j=0;j<nCbS;j+=pbOffset)
1802 for (int i=0;i<nCbS;i+=pbOffset, childIdx++)
1803 {
1804 int x=x0+i, y=y0+j;
1805
1806 int availableA = availableA0 || (i>0); // left candidate always available for right blk
1807 int availableB = availableB0 || (j>0); // top candidate always available for bottom blk
1808
1809 PUidx = (x>>sps->Log2MinPUSize) + (y>>sps->Log2MinPUSize)*sps->PicWidthInMinPUs;
1810
1811 int candModeList[3];
1812 fillIntraPredModeCandidates(candModeList,x,y,PUidx,
1813 availableA,availableB, img);
1814
1815 enum IntraPredMode mode = cb->intra.pred_mode[childIdx];
1816
1817 assert(ectx->img->get_IntraPredMode(x,y) == mode);
1818
1819 intraPred[childIdx] = find_intra_pred_mode(mode, candModeList);
1820 }
1821
1822 for (int i=0;i<4;i++)
1823 encode_prev_intra_luma_pred_flag(ectx,cabac, intraPred[i]);
1824
1825 for (int i=0;i<4;i++)
1826 encode_intra_mpm_or_rem(ectx,cabac, intraPred[i]);
1827 }
1828
1829 IntraChromaPredMode chromaPredMode = find_chroma_pred_mode(cb->intra.chroma_mode,
1830 cb->intra.pred_mode[0]);
1831 encode_intra_chroma_pred_mode(ectx,cabac, chromaPredMode);
1832 }
1833 else {
1834 switch (cb->PartMode) {
1835 case PART_2Nx2N:
1836 encode_prediction_unit(ectx,cabac,cb, 0, cb->x,cb->y,1<<cb->log2Size,1<<cb->log2Size);
1837 break;
1838 case PART_2NxN:
1839 case PART_Nx2N:
1840 case PART_NxN:
1841 case PART_2NxnU:
1842 case PART_2NxnD:
1843 case PART_nLx2N:
1844 case PART_nRx2N:
1845 assert(false); // TODO
1846 }
1847 }
1848
1849
1850 if (true) { // !pcm
1851
1852 if (cb->PredMode != MODE_INTRA &&
1853 !(cb->PartMode == PART_2Nx2N && cb->inter.pb[0].spec.merge_flag)) {
1854
1855 //printf("%d %d %d\n",cb->PredMode,cb->PartMode,cb->inter.pb[0].merge_flag);
1856
1857 encode_rqt_root_cbf(ectx,cabac, cb->inter.rqt_root_cbf);
1858 }
1859
1860 //printf("%d;%d encode rqt_root_cbf=%d\n",x0,y0,cb->inter.rqt_root_cbf);
1861
1862 if (cb->PredMode == MODE_INTRA || cb->inter.rqt_root_cbf) {
1863 int MaxTrafoDepth;
1864 if (PredMode == MODE_INTRA)
1865 { MaxTrafoDepth = sps->max_transform_hierarchy_depth_intra + IntraSplitFlag; }
1866 else
1867 { MaxTrafoDepth = sps->max_transform_hierarchy_depth_inter; }
1868
1869
1870 if (recurse) {
1871 //printf("%d;%d store transform tree\n",x0,y0);
1872
1873 encode_transform_tree(ectx,cabac, cb->transform_tree, cb,
1874 x0,y0, x0,y0, log2CbSize, 0, 0, MaxTrafoDepth, IntraSplitFlag, true);
1875 }
1876 }
1877 }
1878 }
1879 }
1880
1881
1882 SplitType get_split_type(const seq_parameter_set* sps,
1883 int x0,int y0, int log2CbSize)
1884 {
1885 /*
1886 CU split flag:
1887
1888 | overlaps | minimum ||
1889 case | border | size || split
1890 -----+----------+---------++----------
1891 A | 0 | 0 || optional
1892 B | 0 | 1 || 0
1893 C | 1 | 0 || 1
1894 D | 1 | 1 || 0
1895 */
1896 if (x0+(1<<log2CbSize) <= sps->pic_width_in_luma_samples &&
1897 y0+(1<<log2CbSize) <= sps->pic_height_in_luma_samples &&
1898 log2CbSize > sps->Log2MinCbSizeY) {
1899
1900 // case A
1901
1902 return OptionalSplit;
1903 } else {
1904 // case B/C/D
1905
1906 if (log2CbSize > sps->Log2MinCbSizeY) { return ForcedSplit; }
1907 else { return ForcedNonSplit; }
1908 }
1909 }
1910
1911
1912 void encode_quadtree(encoder_context* ectx,
1913 CABAC_encoder* cabac,
1914 const enc_cb* cb, int x0,int y0, int log2CbSize, int ctDepth,
1915 bool recurse)
1916 {
1917 //de265_image* img = ectx->img;
1918 const seq_parameter_set* sps = &ectx->img->sps;
1919
1920 int split_flag = get_split_type(sps,x0,y0,log2CbSize);
1921
1922 // if it is an optional split, take the decision from the CU flag
1923 if (split_flag == OptionalSplit) {
1924 split_flag = cb->split_cu_flag;
1925
1926 encode_split_cu_flag(ectx,cabac, x0,y0, ctDepth, split_flag);
1927 }
1928
1929
1930 if (split_flag) {
1931 if (recurse) {
1932 int x1 = x0 + (1<<(log2CbSize-1));
1933 int y1 = y0 + (1<<(log2CbSize-1));
1934
1935 encode_quadtree(ectx,cabac, cb->children[0], x0,y0, log2CbSize-1, ctDepth+1, true);
1936
1937 if (x1<sps->pic_width_in_luma_samples)
1938 encode_quadtree(ectx,cabac, cb->children[1], x1,y0, log2CbSize-1, ctDepth+1, true);
1939
1940 if (y1<sps->pic_height_in_luma_samples)
1941 encode_quadtree(ectx,cabac, cb->children[2], x0,y1, log2CbSize-1, ctDepth+1, true);
1942
1943 if (x1<sps->pic_width_in_luma_samples &&
1944 y1<sps->pic_height_in_luma_samples)
1945 encode_quadtree(ectx,cabac, cb->children[3], x1,y1, log2CbSize-1, ctDepth+1, true);
1946 }
1947 }
1948 else {
1949 encode_coding_unit(ectx,cabac, cb,x0,y0, log2CbSize, true);
1950 }
1951 }
1952
1953
1954 void encode_ctb(encoder_context* ectx,
1955 CABAC_encoder* cabac,
1956 enc_cb* cb, int ctbX,int ctbY)
1957 {
1958 logtrace(LogSlice,"----- encode CTB (%d;%d) -----\n",ctbX,ctbY);
1959
1960 #if 0
1961 printf("MODEL:\n");
1962 for (int i=0;i<CONTEXT_MODEL_TABLE_LENGTH;i++)
1963 {
1964 printf("%d;%d ",
1965 ectx->ctx_model[i].state,
1966 ectx->ctx_model[i].MPSbit);
1967
1968 if ((i%16)==15) printf("\n");
1969 }
1970 printf("\n");
1971 #endif
1972
1973 de265_image* img = ectx->img;
1974 int log2ctbSize = img->sps.Log2CtbSizeY;
1975
1976 encode_quadtree(ectx,cabac, cb, ctbX<<log2ctbSize, ctbY<<log2ctbSize, log2ctbSize, 0, true);
1977 }
1978
1979
1980 // ---------------------------------------------------------------------------
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef ENCODE_H
23 #define ENCODE_H
24
25 #include "libde265/image.h"
26 #include "libde265/decctx.h"
27 #include "libde265/image-io.h"
28 #include "libde265/alloc_pool.h"
29
30 class encoder_context;
31 class enc_cb;
32
33
34 class enc_node
35 {
36 public:
37 enc_node() { mReconstruction=NULL; }
38 virtual ~enc_node() { delete[] mReconstruction; }
39
40 uint16_t x,y;
41 uint8_t log2Size : 3;
42
43 virtual void save(const de265_image*);
44 virtual void restore(de265_image*);
45
46 private:
47 uint8_t* mReconstruction;
48 };
49
50
51 class enc_tb : public enc_node
52 {
53 public:
54 enc_tb();
55 ~enc_tb();
56
57 const enc_tb* parent;
58
59 uint8_t split_transform_flag : 1;
60 uint8_t TrafoDepth : 2; // 2 bits enough ? (TODO)
61
62 uint8_t cbf[3];
63
64 union {
65 // split
66 struct {
67 enc_tb* children[4];
68 };
69
70 // non-split
71 struct {
72 int16_t* coeff[3];
73 };
74 };
75
76 float distortion; // total distortion for this level of the TB tree (including all children)
77 float rate; // total rate for coding this TB level and all children
78 float rate_withoutCbfChroma;
79
80 void set_cbf_flags_from_children();
81
82 void reconstruct(encoder_context* ectx,
83 de265_image* img,
84 const enc_cb* cb, int blkIdx=0) const;
85
86 bool isZeroBlock() const { return cbf[0]==false && cbf[1]==false && cbf[2]==false; }
87
88 void alloc_coeff_memory(int cIdx, int tbSize);
89
90 static void* operator new(const size_t size) { return mMemPool.new_obj(size); }
91 static void operator delete(void* obj) { mMemPool.delete_obj(obj); }
92
93 private:
94 static alloc_pool mMemPool;
95
96 void reconstruct_tb(encoder_context* ectx,
97 de265_image* img, int x0,int y0, int log2TbSize,
98 const enc_cb* cb, int cIdx) const;
99 };
100
101
102 struct enc_pb_inter
103 {
104 /* absolute motion information (for MV-prediction candidates)
105 */
106 MotionVectorSpec motion;
107
108 /* specification how to code the motion vector in the bitstream
109 */
110 motion_spec spec;
111
112
113 // NOT TRUE: refIdx in 'spec' is not used. It is taken from 'motion'
114 // Currently, information is duplicated. Same as with inter_pred_idc/predFlag[].
115
116 /* SPEC:
117 int8_t refIdx[2]; // not used
118 int16_t mvd[2][2];
119
120 uint8_t inter_pred_idc : 2; // enum InterPredIdc
121 uint8_t mvp_l0_flag : 1;
122 uint8_t mvp_l1_flag : 1;
123 uint8_t merge_flag : 1;
124 uint8_t merge_idx : 3;
125 */
126 };
127
128
129 class enc_cb : public enc_node
130 {
131 public:
132 enc_cb();
133 ~enc_cb();
134
135 const enc_cb* parent;
136
137 uint8_t split_cu_flag : 1;
138 uint8_t ctDepth : 2;
139
140 union {
141 // split
142 struct {
143 enc_cb* children[4]; // undefined when split_cu_flag==false
144 };
145
146 // non-split
147 struct {
148 uint8_t qp : 6;
149 uint8_t cu_transquant_bypass_flag : 1; // currently unused
150 uint8_t pcm_flag : 1;
151
152 enum PredMode PredMode; // : 6;
153 enum PartMode PartMode; // : 3;
154
155 union {
156 struct {
157 enum IntraPredMode pred_mode[4];
158 enum IntraPredMode chroma_mode;
159 } intra;
160
161 struct {
162 enc_pb_inter pb[4];
163
164 uint8_t rqt_root_cbf : 1;
165 } inter;
166 };
167
168 const enc_tb* transform_tree;
169 };
170 };
171
172
173 float distortion;
174 float rate;
175
176
177 void set_rqt_root_bf_from_children_cbf();
178
179 /* Save CB reconstruction in the node and restore it again to the image.
180 Pixel data and metadata.
181 */
182 virtual void save(const de265_image*);
183 virtual void restore(de265_image*);
184
185
186 /* Decode this CB: pixel data and write metadata to image.
187 */
188 void reconstruct(encoder_context* ectx,de265_image* img) const;
189
190
191 // memory management
192
193 static void* operator new(const size_t size) { return mMemPool.new_obj(size); }
194 static void operator delete(void* obj) { mMemPool.delete_obj(obj); }
195
196 private:
197 void write_to_image(de265_image*) const;
198
199 static alloc_pool mMemPool;
200 };
201
202
203
204 inline int childX(int x0, int idx, int log2CbSize)
205 {
206 return x0 + ((idx&1) << (log2CbSize-1));
207 }
208
209 inline int childY(int y0, int idx, int log2CbSize)
210 {
211 return y0 + ((idx>>1) << (log2CbSize-1));
212 }
213
214
215
216 void encode_split_cu_flag(encoder_context* ectx,
217 CABAC_encoder* cabac,
218 int x0, int y0, int ctDepth, int split_flag);
219
220 void encode_transform_tree(encoder_context* ectx,
221 CABAC_encoder* cabac,
222 const enc_tb* tb, const enc_cb* cb,
223 int x0,int y0, int xBase,int yBase,
224 int log2TrafoSize, int trafoDepth, int blkIdx,
225 int MaxTrafoDepth, int IntraSplitFlag, bool recurse);
226
227 void encode_coding_unit(encoder_context* ectx,
228 CABAC_encoder* cabac,
229 const enc_cb* cb, int x0,int y0, int log2CbSize, bool recurse);
230
231 /* returns
232 1 - forced split
233 0 - forced non-split
234 -1 - optional split
235 */
236 enum SplitType {
237 ForcedNonSplit = 0,
238 ForcedSplit = 1,
239 OptionalSplit = 2
240 };
241
242 SplitType get_split_type(const seq_parameter_set* sps,
243 int x0,int y0, int log2CbSize);
244
245
246 void encode_split_transform_flag(encoder_context* ectx,
247 CABAC_encoder* cabac,
248 int log2TrafoSize, int split_flag);
249
250 void encode_merge_idx(encoder_context* ectx,
251 CABAC_encoder* cabac,
252 int mergeIdx);
253
254 void encode_cu_skip_flag(encoder_context* ectx,
255 CABAC_encoder* cabac,
256 const enc_cb* cb,
257 bool skip);
258
259 void encode_cbf_luma(CABAC_encoder* cabac,
260 bool zeroTrafoDepth, int cbf_luma);
261
262 void encode_cbf_chroma(CABAC_encoder* cabac,
263 int trafoDepth, int cbf_chroma);
264
265 void encode_transform_unit(encoder_context* ectx,
266 CABAC_encoder* cabac,
267 const enc_tb* tb, const enc_cb* cb,
268 int x0,int y0, int xBase,int yBase,
269 int log2TrafoSize, int trafoDepth, int blkIdx);
270
271
272 void encode_quadtree(encoder_context* ectx,
273 CABAC_encoder* cabac,
274 const enc_cb* cb, int x0,int y0, int log2CbSize, int ctDepth,
275 bool recurse);
276
277 void encode_ctb(encoder_context* ectx,
278 CABAC_encoder* cabac,
279 enc_cb* cb, int ctbX,int ctbY);
280
281
282 class de265_encoder
283 {
284 public:
285 virtual ~de265_encoder() { }
286 };
287
288 #endif
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #include "encoder/encoder-context.h"
23 #include "encoder/analyze.h"
24 #include "libde265/util.h"
25
26 #include <math.h>
27
28
29 encoder_context::encoder_context()
30 {
31 encoder_started=false;
32
33 //img_source = NULL;
34 //reconstruction_sink = NULL;
35 //packet_sink = NULL;
36
37 image_spec_is_defined = false;
38 parameters_have_been_set = false;
39 headers_have_been_sent = false;
40
41 param_image_allocation_userdata = NULL;
42 release_func = NULL;
43
44 use_adaptive_context = true; //false;
45
46 //enc_coeff_pool.set_blk_size(64*64*20); // TODO: this a guess
47
48 //switch_CABAC_to_bitstream();
49
50
51 params.registerParams(params_config);
52 algo.registerParams(params_config);
53 }
54
55
56 encoder_context::~encoder_context()
57 {
58 while (!output_packets.empty()) {
59 en265_free_packet(this, output_packets.front());
60 output_packets.pop_front();
61 }
62 }
63
64
65 void encoder_context::start_encoder()
66 {
67 if (encoder_started) {
68 return;
69 }
70
71
72 if (params.sop_structure() == SOP_Intra) {
73 sop = std::shared_ptr<sop_creator_intra_only>(new sop_creator_intra_only());
74 }
75 else {
76 auto s = std::shared_ptr<sop_creator_trivial_low_delay>(new sop_creator_trivial_low_delay());
77 s->setParams(params.mSOP_LowDelay);
78 sop = s;
79 }
80
81 sop->set_encoder_context(this);
82 sop->set_encoder_picture_buffer(&picbuf);
83
84
85 encoder_started=true;
86 }
87
88
89 en265_packet* encoder_context::create_packet(en265_packet_content_type t)
90 {
91 en265_packet* pck = new en265_packet;
92
93 uint8_t* data = new uint8_t[cabac_encoder.size()];
94 memcpy(data, cabac_encoder.data(), cabac_encoder.size());
95
96 pck->version = 1;
97
98 pck->data = data;
99 pck->length = cabac_encoder.size();
100
101 pck->frame_number = -1;
102 pck->content_type = t;
103 pck->complete_picture = 0;
104 pck->final_slice = 0;
105 pck->dependent_slice = 0;
106 //pck->pts = 0;
107 //pck->user_data = NULL;
108 pck->nuh_layer_id = 0;
109 pck->nuh_temporal_id = 0;
110
111 pck->encoder_context = this;
112
113 pck->input_image = NULL;
114 pck->reconstruction = NULL;
115
116 cabac_encoder.reset();
117
118 return pck;
119 }
120
121
122 de265_error encoder_context::encode_headers()
123 {
124 nal_header nal;
125
126 // VPS
127
128 vps.set_defaults(Profile_Main, 6,2);
129
130
131 // SPS
132
133 sps.set_defaults();
134 sps.set_CB_log2size_range( Log2(params.min_cb_size), Log2(params.max_cb_size));
135 sps.set_TB_log2size_range( Log2(params.min_tb_size), Log2(params.max_tb_size));
136 sps.max_transform_hierarchy_depth_intra = params.max_transform_hierarchy_depth_intra;
137
138 sps.set_resolution(image_width, image_height);
139 sop->set_SPS_header_values();
140 sps.compute_derived_values();
141
142
143 // PPS
144
145 pps.set_defaults();
146 pps.pic_init_qp = algo.getPPS_QP();
147
148 // turn off deblocking filter
149 pps.deblocking_filter_control_present_flag = true;
150 pps.deblocking_filter_override_enabled_flag = false;
151 pps.pic_disable_deblocking_filter_flag = true;
152 pps.pps_loop_filter_across_slices_enabled_flag = false;
153
154 pps.set_derived_values(&sps);
155
156
157
158 // write headers
159
160 en265_packet* pck;
161
162 nal.set(NAL_UNIT_VPS_NUT);
163 nal.write(cabac_encoder);
164 vps.write(this, cabac_encoder);
165 cabac_encoder.add_trailing_bits();
166 cabac_encoder.flush_VLC();
167 pck = create_packet(EN265_PACKET_VPS);
168 pck->nal_unit_type = EN265_NUT_VPS;
169 output_packets.push_back(pck);
170
171 nal.set(NAL_UNIT_SPS_NUT);
172 nal.write(cabac_encoder);
173 sps.write(this, cabac_encoder);
174 cabac_encoder.add_trailing_bits();
175 cabac_encoder.flush_VLC();
176 pck = create_packet(EN265_PACKET_SPS);
177 pck->nal_unit_type = EN265_NUT_SPS;
178 output_packets.push_back(pck);
179
180 nal.set(NAL_UNIT_PPS_NUT);
181 nal.write(cabac_encoder);
182 pps.write(this, cabac_encoder, &sps);
183 cabac_encoder.add_trailing_bits();
184 cabac_encoder.flush_VLC();
185 pck = create_packet(EN265_PACKET_PPS);
186 pck->nal_unit_type = EN265_NUT_PPS;
187 output_packets.push_back(pck);
188
189
190
191 headers_have_been_sent = true;
192
193 return DE265_OK;
194 }
195
196
197 de265_error encoder_context::encode_picture_from_input_buffer()
198 {
199 if (!picbuf.have_more_frames_to_encode()) {
200 return DE265_OK;
201 }
202
203
204 if (!image_spec_is_defined) {
205 const image_data* id = picbuf.peek_next_picture_to_encode();
206 image_width = id->input->get_width();
207 image_height = id->input->get_height();
208 image_spec_is_defined = true;
209 }
210
211
212 if (!parameters_have_been_set) {
213 algo.setParams(params);
214
215
216 // TODO: must be <30, because Y->C mapping (tab8_22) is not implemented yet
217 int qp = algo.getPPS_QP();
218
219 //lambda = ectx->params.lambda;
220 lambda = 0.0242 * pow(1.27245, qp);
221
222 parameters_have_been_set = true;
223 }
224
225
226 if (!headers_have_been_sent) {
227 encode_headers();
228 }
229
230
231
232
233
234 image_data* imgdata;
235 imgdata = picbuf.get_next_picture_to_encode();
236 assert(imgdata);
237 picbuf.mark_encoding_started(imgdata->frame_number);
238
239 this->imgdata = imgdata;
240 this->shdr = &imgdata->shdr;
241 loginfo(LogEncoder,"encoding frame %d\n",imgdata->frame_number);
242
243
244 // write slice header
245
246 // slice
247
248 imgdata->shdr.slice_deblocking_filter_disabled_flag = true;
249 imgdata->shdr.slice_loop_filter_across_slices_enabled_flag = false;
250 imgdata->shdr.compute_derived_values(&pps);
251
252 //shdr.slice_pic_order_cnt_lsb = poc & 0xFF;
253
254 imgdata->nal.write(cabac_encoder);
255 imgdata->shdr.write(this, cabac_encoder, &sps, &pps, imgdata->nal.nal_unit_type);
256 cabac_encoder.add_trailing_bits();
257 cabac_encoder.flush_VLC();
258
259
260 // encode image
261
262 cabac_encoder.init_CABAC();
263 double psnr = encode_image(this,imgdata->input, algo);
264 loginfo(LogEncoder," PSNR-Y: %f\n", psnr);
265 cabac_encoder.flush_CABAC();
266 cabac_encoder.add_trailing_bits();
267 cabac_encoder.flush_VLC();
268
269
270 // set reconstruction image
271
272 picbuf.set_reconstruction_image(imgdata->frame_number, img);
273 //picbuf.set_prediction_image(imgdata->frame_number, prediction);
274 img=NULL;
275 this->imgdata = NULL;
276 this->shdr = NULL;
277
278 // build output packet
279
280 en265_packet* pck = create_packet(EN265_PACKET_SLICE);
281 pck->input_image = imgdata->input;
282 pck->reconstruction = imgdata->reconstruction;
283 pck->frame_number = imgdata->frame_number;
284 pck->nal_unit_type = (enum en265_nal_unit_type)imgdata->nal.nal_unit_type;
285 pck->nuh_layer_id = imgdata->nal.nuh_layer_id;
286 pck->nuh_temporal_id= imgdata->nal.nuh_temporal_id;
287 output_packets.push_back(pck);
288
289
290 picbuf.mark_encoding_finished(imgdata->frame_number);
291
292 return DE265_OK;
293 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef ENCODER_CONTEXT_H
23 #define ENCODER_CONTEXT_H
24
25 #include "libde265/image.h"
26 #include "libde265/decctx.h"
27 #include "libde265/image-io.h"
28 #include "libde265/encoder/encoder-params.h"
29 #include "libde265/encoder/encpicbuf.h"
30 #include "libde265/encoder/sop.h"
31 #include "libde265/en265.h"
32 #include "libde265/util.h"
33
34 #include <memory>
35
36
37 class encoder_context : public base_context
38 {
39 public:
40 encoder_context();
41 ~encoder_context();
42
43 virtual const de265_image* get_image(int frame_id) const {
44 return picbuf.get_picture(frame_id)->reconstruction;
45 }
46
47 virtual bool has_image(int frame_id) const {
48 return picbuf.has_picture(frame_id);
49 }
50
51 bool encoder_started;
52
53 encoder_params params;
54 config_parameters params_config;
55
56 EncodingAlgorithm_Custom algo;
57
58 int image_width, image_height;
59 bool image_spec_is_defined; // whether we know the input image size
60
61 void* param_image_allocation_userdata;
62 void (*release_func)(en265_encoder_context*,
63 de265_image*,
64 void* userdata);
65
66 //error_queue errqueue;
67 //acceleration_functions accel;
68
69 // quick links
70 de265_image* img; // reconstruction
71 de265_image* prediction;
72 image_data* imgdata; // input image
73 slice_segment_header* shdr;
74
75 // temporary memory for motion compensated pixels (when CB-algo passes this down to TB-algo)
76 //uint8_t prediction[3][64*64]; // stride: 1<<(cb->log2Size)
77 //int prediction_x0,prediction_y0;
78
79
80 int active_qp; // currently active QP
81 /*int target_qp;*/ /* QP we want to code at.
82 (Not actually the real QP. Check image.get_QPY() for that.) */
83
84 video_parameter_set vps;
85 seq_parameter_set sps;
86 pic_parameter_set pps;
87 //slice_segment_header shdr;
88
89 bool parameters_have_been_set;
90 bool headers_have_been_sent;
91
92 encoder_picture_buffer picbuf;
93 std::shared_ptr<sop_creator> sop;
94
95 std::deque<en265_packet*> output_packets;
96
97
98 // --- rate-control ---
99
100 float lambda;
101
102
103 // --- CABAC output and rate estimation ---
104
105 //CABAC_encoder* cabac; // currently active CABAC output (estim or bitstream)
106 //context_model_table2* ctx_model; // currently active ctx models (estim or bitstream)
107
108 // CABAC bitstream writer
109 CABAC_encoder_bitstream cabac_encoder;
110 context_model_table cabac_ctx_models;
111
112 //std::shared_ptr<CABAC_encoder> cabac_estim;
113
114 bool use_adaptive_context;
115
116
117 /*** TODO: CABAC_encoder direkt an encode-Funktion übergeben, anstatt hier
118 aussenrum zwischenzuspeichern (mit undefinierter Lifetime).
119 Das Context-Model kann dann gleich mit in den Encoder rein cabac_encoder(ctxtable).
120 write_bits() wird dann mit dem context-index aufgerufen, nicht mit dem model direkt.
121 ***/
122
123
124 /*
125 void switch_CABAC(context_model_table2* model) {
126 cabac = cabac_estim.get();
127 ctx_model = model;
128 }
129
130 void switch_CABAC_to_bitstream() {
131 cabac = &cabac_bitstream;
132 ctx_model = &ctx_model_bitstream;
133 }
134 */
135
136 en265_packet* create_packet(en265_packet_content_type t);
137
138
139 // --- encoding control ---
140
141 void start_encoder();
142 de265_error encode_headers();
143 de265_error encode_picture_from_input_buffer();
144
145
146 // Input images can be released after encoding and when the output packet is released.
147 // This is important to do as soon as possible, as the image might actually wrap
148 // scarce resources like camera picture buffers.
149 // This function does release (only) the raw input data.
150 void release_input_image(int frame_number) { picbuf.release_input_image(frame_number); }
151
152 void mark_image_is_outputted(int frame_number) { picbuf.mark_image_is_outputted(frame_number); }
153 };
154
155
156 #endif
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: struktur AG, Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #include "encoder-params.h"
23
24
25
26 static std::vector<int> power2range(int low,int high)
27 {
28 std::vector<int> vals;
29 for (int i=low; i<=high; i*=2)
30 vals.push_back(i);
31 return vals;
32 }
33
34 encoder_params::encoder_params()
35 {
36 //rateControlMethod = RateControlMethod_ConstantQP;
37
38 min_cb_size.set_ID("min-cb-size"); min_cb_size.set_valid_values(power2range(8,64)); min_cb_size.set_default(8);
39 max_cb_size.set_ID("max-cb-size"); max_cb_size.set_valid_values(power2range(8,64)); max_cb_size.set_default(32);
40 min_tb_size.set_ID("min-tb-size"); min_tb_size.set_valid_values(power2range(4,32)); min_tb_size.set_default(4);
41 max_tb_size.set_ID("max-tb-size"); max_tb_size.set_valid_values(power2range(8,32)); max_tb_size.set_default(32);
42
43 max_transform_hierarchy_depth_intra.set_ID("max-transform-hierarchy-depth-intra");
44 max_transform_hierarchy_depth_intra.set_range(0,4);
45 max_transform_hierarchy_depth_intra.set_default(3);
46
47 sop_structure.set_ID("sop-structure");
48
49 mAlgo_TB_IntraPredMode.set_ID("TB-IntraPredMode");
50 mAlgo_TB_IntraPredMode_Subset.set_ID("TB-IntraPredMode-subset");
51 mAlgo_CB_IntraPartMode.set_ID("CB-IntraPartMode");
52
53 mAlgo_MEMode.set_ID("MEMode");
54 }
55
56
57 void encoder_params::registerParams(config_parameters& config)
58 {
59 config.add_option(&min_cb_size);
60 config.add_option(&max_cb_size);
61 config.add_option(&min_tb_size);
62 config.add_option(&max_tb_size);
63 config.add_option(&max_transform_hierarchy_depth_intra);
64
65 config.add_option(&sop_structure);
66
67 config.add_option(&mAlgo_TB_IntraPredMode);
68 config.add_option(&mAlgo_TB_IntraPredMode_Subset);
69 config.add_option(&mAlgo_CB_IntraPartMode);
70
71 config.add_option(&mAlgo_MEMode);
72
73 mSOP_LowDelay.registerParams(config);
74 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef ENCODER_PARAMS_H
23 #define ENCODER_PARAMS_H
24
25 #include "libde265/encoder/encode.h"
26 #include "libde265/encoder/analyze.h"
27 #include "libde265/encoder/sop.h"
28
29
30 enum RateControlMethod
31 {
32 RateControlMethod_ConstantQP,
33 RateControlMethod_ConstantLambda
34 };
35
36 enum IntraPredSearch
37 {
38 IntraPredSearch_Complete
39 };
40
41
42 enum SOP_Structure
43 {
44 SOP_Intra,
45 SOP_LowDelay
46 };
47
48 class option_SOP_Structure : public choice_option<enum SOP_Structure>
49 {
50 public:
51 option_SOP_Structure() {
52 add_choice("intra", SOP_Intra);
53 add_choice("low-delay", SOP_LowDelay, true);
54 }
55 };
56
57
58 enum MEMode
59 {
60 MEMode_Test,
61 MEMode_Search
62 };
63
64 class option_MEMode : public choice_option<enum MEMode>
65 {
66 public:
67 option_MEMode() {
68 add_choice("test", MEMode_Test, true);
69 add_choice("search", MEMode_Search);
70 }
71 };
72
73
74 struct encoder_params
75 {
76 encoder_params();
77
78 void registerParams(config_parameters& config);
79
80
81 // CB quad-tree
82
83 option_int min_cb_size;
84 option_int max_cb_size;
85
86 option_int min_tb_size;
87 option_int max_tb_size;
88
89 option_int max_transform_hierarchy_depth_intra;
90
91
92 option_SOP_Structure sop_structure;
93
94 sop_creator_trivial_low_delay::params mSOP_LowDelay;
95
96
97 // --- Algo_TB_IntraPredMode
98
99 option_ALGO_TB_IntraPredMode mAlgo_TB_IntraPredMode;
100 option_ALGO_TB_IntraPredMode_Subset mAlgo_TB_IntraPredMode_Subset;
101
102 //Algo_TB_IntraPredMode_FastBrute::params TB_IntraPredMode_FastBrute;
103 //Algo_TB_IntraPredMode_MinResidual::params TB_IntraPredMode_MinResidual;
104
105
106 // --- Algo_TB_Split_BruteForce
107
108 //Algo_TB_Split_BruteForce::params TB_Split_BruteForce;
109
110
111 // --- Algo_CB_IntraPartMode
112
113 option_ALGO_CB_IntraPartMode mAlgo_CB_IntraPartMode;
114
115 //Algo_CB_IntraPartMode_Fixed::params CB_IntraPartMode_Fixed;
116
117 // --- Algo_CB_Split
118
119 // --- Algo_CTB_QScale
120
121 //Algo_CTB_QScale_Constant::params CTB_QScale_Constant;
122
123 option_MEMode mAlgo_MEMode;
124
125
126 // intra-prediction
127
128 enum IntraPredSearch intraPredSearch;
129
130
131 // rate-control
132
133 enum RateControlMethod rateControlMethod;
134
135 //int constant_QP;
136 //int lambda;
137 };
138
139
140 #endif
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * This file is part of libde265.
5 *
6 * libde265 is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation, either version 3 of
9 * the License, or (at your option) any later version.
10 *
11 * libde265 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
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with libde265. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "libde265/encoder/encpicbuf.h"
21 #include "libde265/util.h"
22
23
24 encoder_picture_buffer::encoder_picture_buffer()
25 {
26 }
27
28 encoder_picture_buffer::~encoder_picture_buffer()
29 {
30 flush_images();
31 }
32
33
34 image_data::image_data()
35 {
36 //printf("new %p\n",this);
37
38 frame_number = 0;
39
40 input = NULL;
41 prediction = NULL;
42 reconstruction = NULL;
43
44 // SOP metadata
45
46 sps_index = -1;
47 skip_priority = 0;
48 is_intra = true;
49
50 state = state_unprocessed;
51
52 is_in_output_queue = true;
53 }
54
55 image_data::~image_data()
56 {
57 //printf("delete %p\n",this);
58
59 delete input;
60 // TODO: this could still be referenced in the packet output queue, so the
61 // images should really be refcounted. release for now to prevent leaks
62 delete reconstruction;
63 delete prediction;
64 }
65
66
67 // --- input pushed by the input process ---
68
69 void encoder_picture_buffer::reset()
70 {
71 flush_images();
72
73 mEndOfStream = false;
74 }
75
76
77 void encoder_picture_buffer::flush_images()
78 {
79 while (!mImages.empty()) {
80 delete mImages.front();
81 mImages.pop_front();
82 }
83 }
84
85
86 image_data* encoder_picture_buffer::insert_next_image_in_encoding_order(const de265_image* img,
87 int frame_number)
88 {
89 image_data* data = new image_data();
90 data->frame_number = frame_number;
91 data->input = img;
92 data->shdr.set_defaults();
93
94 mImages.push_back(data);
95
96 return data;
97 }
98
99 void encoder_picture_buffer::insert_end_of_stream()
100 {
101 mEndOfStream = true;
102 }
103
104
105 // --- SOP structure ---
106
107 void image_data::set_intra()
108 {
109 is_intra = true;
110 }
111
112 void image_data::set_NAL_type(uint8_t nalType)
113 {
114 nal.nal_unit_type = nalType;
115 }
116
117 void image_data::set_references(int sps_index, // -1 -> custom
118 const std::vector<int>& l0,
119 const std::vector<int>& l1,
120 const std::vector<int>& lt,
121 const std::vector<int>& keepMoreReferences)
122 {
123 this->sps_index = sps_index;
124 ref0 = l0;
125 ref1 = l1;
126 longterm = lt;
127 keep = keepMoreReferences;
128
129
130 // TODO: pps.num_ref_idx_l0_default_active
131
132 shdr.num_ref_idx_l0_active = l0.size();
133 //shdr.num_ref_idx_l1_active = l1.size();
134
135 assert(l0.size() < MAX_NUM_REF_PICS);
136 for (int i=0;i<l0.size();i++) {
137 shdr.RefPicList[0][i] = l0[i];
138 }
139
140 /*
141 assert(l1.size() < MAX_NUM_REF_PICS);
142 for (int i=0;i<l1.size();i++) {
143 shdr.RefPicList[1][i] = l1[i];
144 }
145 */
146 }
147
148 void image_data::set_NAL_temporal_id(int temporal_id)
149 {
150 this->nal.nuh_temporal_id = temporal_id;
151 }
152
153 void image_data::set_skip_priority(int skip_priority)
154 {
155 this->skip_priority = skip_priority;
156 }
157
158 void encoder_picture_buffer::sop_metadata_commit(int frame_number)
159 {
160 image_data* data = mImages.back();
161 assert(data->frame_number == frame_number);
162
163 data->state = image_data::state_sop_metadata_available;
164 }
165
166
167
168 // --- infos pushed by encoder ---
169
170 void encoder_picture_buffer::mark_encoding_started(int frame_number)
171 {
172 image_data* data = get_picture(frame_number);
173
174 data->state = image_data::state_encoding;
175 }
176
177 void encoder_picture_buffer::set_prediction_image(int frame_number, de265_image* pred)
178 {
179 image_data* data = get_picture(frame_number);
180
181 data->prediction = pred;
182 }
183
184 void encoder_picture_buffer::set_reconstruction_image(int frame_number, de265_image* reco)
185 {
186 image_data* data = get_picture(frame_number);
187
188 data->reconstruction = reco;
189 }
190
191 void encoder_picture_buffer::mark_encoding_finished(int frame_number)
192 {
193 image_data* data = get_picture(frame_number);
194
195 data->state = image_data::state_keep_for_reference;
196
197
198 // --- delete images that are not required anymore ---
199
200 // first, mark all images unused
201
202 #ifdef FOR_LOOP_AUTO_SUPPORT
203 FOR_LOOP(auto, imgdata, mImages) {
204 #else
205 FOR_LOOP(image_data *, imgdata, mImages) {
206 #endif
207 imgdata->mark_used = false;
208 }
209
210 // mark all images that will be used later
211
212 FOR_LOOP(int, f, data->ref0) { get_picture(f)->mark_used=true; }
213 FOR_LOOP(int, f, data->ref1) { get_picture(f)->mark_used=true; }
214 FOR_LOOP(int, f, data->longterm) { get_picture(f)->mark_used=true; }
215 FOR_LOOP(int, f, data->keep) { get_picture(f)->mark_used=true; }
216 data->mark_used=true;
217
218 // copy over all images that we still keep
219
220 std::deque<image_data*> newImageSet;
221 #ifdef FOR_LOOP_AUTO_SUPPORT
222 FOR_LOOP(auto, imgdata, mImages) {
223 #else
224 FOR_LOOP(image_data *, imgdata, mImages) {
225 #endif
226 if (imgdata->mark_used || imgdata->is_in_output_queue) {
227 imgdata->reconstruction->PicState = UsedForShortTermReference; // TODO: this is only a hack
228
229 newImageSet.push_back(imgdata);
230 }
231 else {
232 // image is not needed anymore for reference, remove it from EncPicBuf
233
234 delete imgdata;
235 }
236 }
237
238 mImages = newImageSet;
239 }
240
241
242
243 // --- data access ---
244
245 bool encoder_picture_buffer::have_more_frames_to_encode() const
246 {
247 for (int i=0;i<mImages.size();i++) {
248 if (mImages[i]->state < image_data::state_encoding) {
249 return true;
250 }
251 }
252
253 return false;
254 }
255
256
257 image_data* encoder_picture_buffer::get_next_picture_to_encode()
258 {
259 for (int i=0;i<mImages.size();i++) {
260 if (mImages[i]->state < image_data::state_encoding) {
261 return mImages[i];
262 }
263 }
264
265 return NULL;
266 }
267
268
269 const image_data* encoder_picture_buffer::get_picture(int frame_number) const
270 {
271 for (int i=0;i<mImages.size();i++) {
272 if (mImages[i]->frame_number == frame_number)
273 return mImages[i];
274 }
275
276 assert(false);
277 return NULL;
278 }
279
280
281 image_data* encoder_picture_buffer::get_picture(int frame_number)
282 {
283 for (int i=0;i<mImages.size();i++) {
284 if (mImages[i]->frame_number == frame_number)
285 return mImages[i];
286 }
287
288 assert(false);
289 return NULL;
290 }
291
292
293 bool encoder_picture_buffer::has_picture(int frame_number) const
294 {
295 for (int i=0;i<mImages.size();i++) {
296 if (mImages[i]->frame_number == frame_number)
297 return true;
298 }
299
300 return false;
301 }
302
303
304 void encoder_picture_buffer::mark_image_is_outputted(int frame_number)
305 {
306 image_data* idata = get_picture(frame_number);
307 assert(idata);
308
309 idata->is_in_output_queue = false;
310 }
311
312
313 void encoder_picture_buffer::release_input_image(int frame_number)
314 {
315 image_data* idata = get_picture(frame_number);
316 assert(idata);
317
318 delete idata->input;
319 idata->input = NULL;
320 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * This file is part of libde265.
5 *
6 * libde265 is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation, either version 3 of
9 * the License, or (at your option) any later version.
10 *
11 * libde265 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
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with libde265. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef DE265_ENCPICBUF_H
21 #define DE265_ENCPICBUF_H
22
23 #include "libde265/image.h"
24 #include "libde265/sps.h"
25
26 #include <deque>
27 #include <vector>
28
29
30 /* TODO: we need a way to quickly access pictures with a stable ID, like in the DPB.
31 */
32
33 struct image_data
34 {
35 image_data();
36 ~image_data();
37
38 int frame_number;
39
40 const de265_image* input; // owner
41 de265_image* prediction; // owner
42 de265_image* reconstruction; // owner
43
44 // SOP metadata
45
46 nal_header nal; // TODO: image split into several NALs (always same NAL header?)
47
48 slice_segment_header shdr; // TODO: multi-slice pictures
49
50 std::vector<int> ref0;
51 std::vector<int> ref1;
52 std::vector<int> longterm;
53 std::vector<int> keep;
54 int sps_index;
55 int skip_priority;
56 bool is_intra; // TODO: remove, use shdr.slice_type instead
57
58 /* unprocessed only input image has been inserted, no metadata
59 sop_metadata_available sop-creator has filled in references and skipping metadata
60 a) encoding encoding started for this frame, reconstruction image was created
61 . keep_for_reference encoding finished, picture is kept in the buffer for reference
62 b) skipped image was skipped, no encoding was done, no reconstruction image
63 */
64 enum state {
65 state_unprocessed,
66 state_sop_metadata_available,
67 state_encoding,
68 state_keep_for_reference,
69 state_skipped
70 } state;
71
72 bool is_in_output_queue;
73
74 bool mark_used;
75
76
77 // --- SOP structure ---
78
79 void set_intra();
80 void set_NAL_type(uint8_t nalType);
81 void set_NAL_temporal_id(int temporal_id);
82 void set_references(int sps_index, // -1 -> custom
83 const std::vector<int>& l0, const std::vector<int>& l1,
84 const std::vector<int>& lt,
85 const std::vector<int>& keepMoreReferences);
86 void set_skip_priority(int skip_priority);
87 };
88
89
90 class encoder_picture_buffer
91 {
92 public:
93 encoder_picture_buffer();
94 ~encoder_picture_buffer();
95
96
97 // --- input pushed by the input process ---
98
99 void reset();
100
101 image_data* insert_next_image_in_encoding_order(const de265_image*, int frame_number);
102 void insert_end_of_stream();
103
104
105 // --- SOP structure ---
106
107 void sop_metadata_commit(int frame_number); // note: frame_number is only for consistency checking
108
109
110 // --- infos pushed by encoder ---
111
112 void mark_encoding_started(int frame_number);
113 void set_prediction_image(int frame_number, de265_image*); // store it just for debugging fun
114 void set_reconstruction_image(int frame_number, de265_image*);
115 void mark_encoding_finished(int frame_number);
116
117
118
119 // --- data access ---
120
121 bool have_more_frames_to_encode() const;
122 image_data* get_next_picture_to_encode(); // or return NULL if no picture is available
123 const image_data* get_picture(int frame_number) const;
124 bool has_picture(int frame_number) const;
125
126 const image_data* peek_next_picture_to_encode() const {
127 assert(!mImages.empty());
128 return mImages.front();
129 }
130
131 void mark_image_is_outputted(int frame_number);
132 void release_input_image(int frame_number);
133
134 private:
135 bool mEndOfStream;
136 std::deque<image_data*> mImages;
137
138 void flush_images();
139 image_data* get_picture(int frame_number);
140 };
141
142
143 #endif
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * This file is part of libde265.
5 *
6 * libde265 is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation, either version 3 of
9 * the License, or (at your option) any later version.
10 *
11 * libde265 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
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with libde265. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "libde265/encoder/sop.h"
21 #include "libde265/encoder/encoder-context.h"
22
23
24 sop_creator_intra_only::sop_creator_intra_only()
25 {
26 }
27
28
29 void sop_creator_intra_only::set_SPS_header_values()
30 {
31 mEncCtx->sps.log2_max_pic_order_cnt_lsb = get_num_poc_lsb_bits();
32 }
33
34
35 void sop_creator_intra_only::insert_new_input_image(de265_image* img)
36 {
37 img->PicOrderCntVal = get_pic_order_count();
38
39 reset_poc();
40 int poc = get_pic_order_count();
41
42 assert(mEncPicBuf);
43 image_data* imgdata = mEncPicBuf->insert_next_image_in_encoding_order(img, get_frame_number());
44
45 imgdata->set_intra();
46 imgdata->set_NAL_type(NAL_UNIT_IDR_N_LP);
47 imgdata->shdr.slice_type = SLICE_TYPE_I;
48 imgdata->shdr.slice_pic_order_cnt_lsb = get_pic_order_count_lsb();
49
50 mEncPicBuf->sop_metadata_commit(get_frame_number());
51
52 advance_frame();
53 }
54
55
56 // ---------------------------------------------------------------------------
57
58
59 sop_creator_trivial_low_delay::sop_creator_trivial_low_delay()
60 {
61 }
62
63
64 void sop_creator_trivial_low_delay::set_SPS_header_values()
65 {
66 ref_pic_set rps;
67 rps.DeltaPocS0[0] = -1;
68 rps.UsedByCurrPicS0[0] = true;
69 rps.NumNegativePics = 1;
70 rps.NumPositivePics = 0;
71 rps.compute_derived_values();
72 mEncCtx->sps.ref_pic_sets.push_back(rps);
73 mEncCtx->sps.log2_max_pic_order_cnt_lsb = get_num_poc_lsb_bits();
74 }
75
76
77 void sop_creator_trivial_low_delay::insert_new_input_image(de265_image* img)
78 {
79 img->PicOrderCntVal = get_pic_order_count();
80
81 int frame = get_frame_number();
82
83 std::vector<int> l0, l1, empty;
84 if (!isIntra(frame)) {
85 l0.push_back(frame-1);
86 }
87
88 assert(mEncPicBuf);
89 image_data* imgdata = mEncPicBuf->insert_next_image_in_encoding_order(img, get_frame_number());
90
91 if (isIntra(frame)) {
92 reset_poc();
93 imgdata->set_intra();
94 imgdata->set_NAL_type(NAL_UNIT_IDR_N_LP);
95 imgdata->shdr.slice_type = SLICE_TYPE_I;
96 } else {
97 imgdata->set_references(0, l0,l1, empty,empty);
98 imgdata->set_NAL_type(NAL_UNIT_TRAIL_R);
99 imgdata->shdr.slice_type = SLICE_TYPE_P;
100 }
101 imgdata->shdr.slice_pic_order_cnt_lsb = get_pic_order_count_lsb();
102 mEncPicBuf->sop_metadata_commit(get_frame_number());
103
104 advance_frame();
105 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * This file is part of libde265.
5 *
6 * libde265 is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation, either version 3 of
9 * the License, or (at your option) any later version.
10 *
11 * libde265 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
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with libde265. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef DE265_SOP_H
21 #define DE265_SOP_H
22
23 #include "libde265/image.h"
24 #include "libde265/sps.h"
25 #include "libde265/encoder/encpicbuf.h"
26 #include "libde265/configparam.h"
27
28 #include <deque>
29 #include <vector>
30
31 /*
32 struct refpic_set
33 {
34 std::vector<int> l0;
35 std::vector<int> l1;
36 };
37 */
38
39 class pic_order_counter
40 {
41 public:
42 pic_order_counter() { mFrameNumber=0; mPOC=0; mNumLsbBits=6; }
43
44 void reset_poc() { mPOC=0; }
45
46 int get_frame_number() const { return mFrameNumber; }
47
48 int get_pic_order_count() const { return mPOC; }
49 int get_pic_order_count_lsb() const {
50 return mPOC & ((1<<mNumLsbBits)-1);
51 }
52
53 void advance_frame(int n=1) { mFrameNumber+=n; mPOC+=n; }
54
55 void set_num_poc_lsb_bits(int n) { mNumLsbBits=n; }
56 int get_num_poc_lsb_bits() const { return mNumLsbBits; }
57
58 private:
59 int mFrameNumber;
60 int mPOC;
61 int mNumLsbBits;
62 };
63
64
65 class sop_creator : public pic_order_counter
66 {
67 public:
68 sop_creator() { mEncCtx=NULL; mEncPicBuf=NULL; }
69 virtual ~sop_creator() { }
70
71 void set_encoder_context(encoder_context* encctx) { mEncCtx=encctx; }
72 void set_encoder_picture_buffer(encoder_picture_buffer* encbuf) { mEncPicBuf=encbuf; }
73
74 /* Fills in the following fields:
75 - SPS.ref_pic_sets
76 - SPS.log2_max_pic_order_cnt_lsb
77 */
78 virtual void set_SPS_header_values() = 0;
79
80 /* Fills in the following fields:
81 - NAL.nal_type
82 - SHDR.slice_type
83 - SHDR.slice_pic_order_cnt_lsb
84 - IMGDATA.references
85 */
86 virtual void insert_new_input_image(de265_image*) = 0;
87 virtual void insert_end_of_stream() { mEncPicBuf->insert_end_of_stream(); }
88
89 virtual int get_number_of_temporal_layers() const { return 1; }
90
91 //virtual std::vector<refpic_set> get_sps_refpic_sets() const = 0;
92
93 protected:
94 encoder_context* mEncCtx;
95 encoder_picture_buffer* mEncPicBuf;
96 };
97
98
99
100 class sop_creator_intra_only : public sop_creator
101 {
102 public:
103 sop_creator_intra_only();
104
105 virtual void set_SPS_header_values();
106 virtual void insert_new_input_image(de265_image* img);
107 };
108
109
110
111 class sop_creator_trivial_low_delay : public sop_creator
112 {
113 public:
114 struct params {
115 params() {
116 intraPeriod.set_ID("sop-lowDelay-intraPeriod");
117 intraPeriod.set_minimum(1);
118 intraPeriod.set_default(250);
119 }
120
121 void registerParams(config_parameters& config) {
122 config.add_option(&intraPeriod);
123 }
124
125 option_int intraPeriod;
126 };
127
128 sop_creator_trivial_low_delay();
129
130 void setParams(const params& p) { mParams=p; }
131
132 virtual void set_SPS_header_values();
133 virtual void insert_new_input_image(de265_image* img);
134
135 private:
136 params mParams;
137
138 bool isIntra(int frame) const { return (frame % mParams.intraPeriod)==0; }
139 };
140
141
142 #endif
1717 * along with libde265. If not, see <http://www.gnu.org/licenses/>.
1818 */
1919
20 #include "fallback-motion.h"
21 #include "util.h"
20 #include "fallback-dct.h"
2221
2322 #if defined(_MSC_VER) || defined(__MINGW32__)
2423 # include <malloc.h>
2726 #endif
2827
2928 #include <assert.h>
30
31
32 void transform_skip_8_fallback(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride)
29 #include <algorithm>
30
31
32 static void printMatrix(const char* name, const int16_t* v, int n)
33 {
34 printf("--- %s ---\n",name);
35 for (int r=0;r<n;r++) {
36 for (int c=0;c<n;c++) {
37 printf("%4d ",v[c+r*n]);
38 }
39 printf("\n");
40 }
41 }
42
43
44
45 void transform_skip_8_fallback(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride)
3346 {
3447 int nT = 4;
3548 int bdShift2 = 20-8;
49
50 assert(0); // DEPRECATED, should not be used anymore because of fixed 4x4 size
3651
3752 for (int y=0;y<nT;y++)
3853 for (int x=0;x<nT;x++) {
4459 }
4560
4661
47 void transform_bypass_8_fallback(uint8_t *dst, int16_t *coeffs, int nT, ptrdiff_t stride)
48 {
49 int bdShift2 = 20-8;
50
62 void transform_skip_16_fallback(uint16_t *dst, const int16_t *coeffs, ptrdiff_t stride, int bit_depth)
63 {
64 int nT = 4;
65 int bdShift2 = 20-bit_depth;
66
67 assert(0); // DEPRECATED, should not be used anymore because of fixed 4x4 size
68
69 for (int y=0;y<nT;y++)
70 for (int x=0;x<nT;x++) {
71 int32_t c = coeffs[x+y*nT] << 7;
72 c = (c+(1<<(bdShift2-1)))>>bdShift2;
73
74 dst[y*stride+x] = Clip_BitDepth(dst[y*stride+x] + c, bit_depth);
75 }
76 }
77
78
79 void transform_skip_residual_fallback(int32_t *residual, const int16_t *coeffs, int nT,
80 int tsShift,int bdShift)
81 {
82 const int rnd = 1<<(bdShift-1);
83
84 for (int y=0;y<nT;y++)
85 for (int x=0;x<nT;x++) {
86 int32_t c = coeffs[x+y*nT] << tsShift;
87 residual[x+y*nT] = (c + rnd) >> bdShift;
88 }
89 }
90
91
92 void transform_skip_rdpcm_v_8_fallback(uint8_t *dst, const int16_t *coeffs, int log2nT, ptrdiff_t stride)
93 {
94 int bitDepth = 8;
95 int bdShift2 = 20-bitDepth;
96 int offset = (1<<(bdShift2-1));
97 int tsShift = 5 + log2nT; // TODO: extended_precision
98 int nT = 1<<log2nT;
99
100 for (int x=0;x<nT;x++) {
101 int32_t sum = 0;
102
103 for (int y=0;y<nT;y++) {
104 int c = coeffs[x+y*nT] << tsShift;
105 sum += (c+offset)>>bdShift2;
106
107 dst[y*stride+x] = Clip1_8bit(dst[y*stride+x] + sum);
108 }
109 }
110 }
111
112 void transform_skip_rdpcm_h_8_fallback(uint8_t *dst, const int16_t *coeffs, int log2nT, ptrdiff_t stride)
113 {
114 int bitDepth = 8;
115 int bdShift2 = 20-bitDepth;
116 int offset = (1<<(bdShift2-1));
117 int tsShift = 5 + log2nT; // TODO: extended_precision
118 int nT = 1<<log2nT;
119
120 for (int y=0;y<nT;y++) {
121 int32_t sum = 0;
122
123 for (int x=0;x<nT;x++) {
124 int c = coeffs[x+y*nT] << tsShift;
125 sum += (c+offset)>>bdShift2;
126
127 dst[y*stride+x] = Clip1_8bit(dst[y*stride+x] + sum);
128 }
129 }
130 }
131
132
133 void transform_bypass_rdpcm_v_8_fallback(uint8_t *dst, const int16_t *coeffs,int nT,ptrdiff_t stride)
134 {
135 for (int x=0;x<nT;x++) {
136 int32_t sum=0;
137 for (int y=0;y<nT;y++) {
138 sum += coeffs[x+y*nT];
139
140 dst[y*stride+x] = Clip1_8bit(dst[y*stride+x] + sum);
141 }
142 }
143 }
144
145
146 void transform_bypass_rdpcm_h_8_fallback(uint8_t *dst, const int16_t *coeffs,int nT,ptrdiff_t stride)
147 {
148 for (int y=0;y<nT;y++) {
149 int32_t sum=0;
150 for (int x=0;x<nT;x++) {
151 sum += coeffs[x+y*nT];
152
153 dst[y*stride+x] = Clip1_8bit(dst[y*stride+x] + sum);
154 }
155 }
156 }
157
158
159 void transform_bypass_rdpcm_v_fallback(int32_t *dst, const int16_t *coeffs,int nT)
160 {
161 for (int x=0;x<nT;x++) {
162 int32_t sum=0;
163 for (int y=0;y<nT;y++) {
164 sum += coeffs[x+y*nT];
165
166 dst[y*nT+x] = sum;
167 }
168 }
169 }
170
171
172 void transform_bypass_rdpcm_h_fallback(int32_t *dst, const int16_t *coeffs,int nT)
173 {
174 for (int y=0;y<nT;y++) {
175 int32_t sum=0;
176 for (int x=0;x<nT;x++) {
177 sum += coeffs[x+y*nT];
178
179 dst[y*nT+x] = sum;
180 }
181 }
182 }
183
184
185 void rdpcm_v_fallback(int32_t* residual, const int16_t* coeffs, int nT,int tsShift,int bdShift)
186 {
187 int rnd = (1<<(bdShift-1));
188
189 for (int x=0;x<nT;x++) {
190 int sum=0;
191 for (int y=0;y<nT;y++) {
192 int c = coeffs[x+y*nT] << tsShift;
193 sum += (c+rnd)>>bdShift;
194 residual[y*nT+x] = sum;
195 }
196 }
197 }
198
199
200 void rdpcm_h_fallback(int32_t* residual, const int16_t* coeffs, int nT,int tsShift,int bdShift)
201 {
202 int rnd = (1<<(bdShift-1));
203
204 for (int y=0;y<nT;y++) {
205 int sum=0;
206 for (int x=0;x<nT;x++) {
207 int c = coeffs[x+y*nT] << tsShift;
208 sum += (c+rnd)>>bdShift;
209 residual[y*nT+x] = sum;
210 }
211 }
212 }
213
214
215 void transform_bypass_fallback(int32_t *dst, const int16_t *coeffs, int nT)
216 {
51217 for (int y=0;y<nT;y++)
52218 for (int x=0;x<nT;x++) {
53219 int32_t c = coeffs[x+y*nT];
54220
221 dst[y*nT+x] = c;
222 }
223 }
224
225
226 void transform_bypass_8_fallback(uint8_t *dst, const int16_t *coeffs, int nT, ptrdiff_t stride)
227 {
228 for (int y=0;y<nT;y++)
229 for (int x=0;x<nT;x++) {
230 int32_t c = coeffs[x+y*nT];
231
55232 dst[y*stride+x] = Clip1_8bit(dst[y*stride+x] + c);
56233 }
57234 }
58
235
236
237 void transform_bypass_16_fallback(uint16_t *dst, const int16_t *coeffs, int nT, ptrdiff_t stride, int bit_depth)
238 {
239 int bdShift2 = 20-bit_depth;
240
241 for (int y=0;y<nT;y++)
242 for (int x=0;x<nT;x++) {
243 int32_t c = coeffs[x+y*nT];
244
245 dst[y*stride+x] = Clip_BitDepth(dst[y*stride+x] + c, bit_depth);
246 }
247 }
248
249
250 void rotate_coefficients_fallback(int16_t *coeff, int nT)
251 {
252 for (int y=0;y<nT/2;y++)
253 for (int x=0;x<nT;x++) {
254 std::swap(coeff[y*nT+x], coeff[(nT-1-y)*nT + nT-1-x]);
255 }
256 }
257
258
59259
60260 static int8_t mat_8_357[4][4] = {
61261 { 29, 55, 74, 84 },
66266
67267
68268
69 void transform_4x4_luma_add_8_fallback(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride)
269 void transform_4x4_luma_add_8_fallback(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride)
70270 {
71271 int16_t g[4][4];
72272
78278 // --- V ---
79279
80280 for (int c=0;c<4;c++) {
81
281 /*
82282 logtrace(LogTransform,"DST-V: ");
83283 for (int r=0;r<4;r++) {
84284 logtrace(LogTransform,"%d ",coeffs[c+r*4]);
85285 }
86286 logtrace(LogTransform,"* -> ");
87
287 */
88288
89289 for (int i=0;i<4;i++) {
90290 int sum=0;
96296 g[i][c] = Clip3(-32768,32767, (sum+rndV)>>7);
97297 }
98298
99
299 /*
100300 for (int y=0;y<4;y++) {
101301 logtrace(LogTransform,"*%d ",g[y][c]);
102302 }
103303 logtrace(LogTransform,"*\n");
304 */
104305 }
105306
106307
108309
109310 for (int y=0;y<4;y++) {
110311
312 /*
111313 logtrace(LogTransform,"DST-H: ");
112314 for (int c=0;c<4;c++) {
113315 logtrace(LogTransform,"%d ",g[y][c]);
114316 }
115317 logtrace(LogTransform,"* -> ");
116
318 */
117319
118320 for (int i=0;i<4;i++) {
119321 int sum=0;
130332 }
131333
132334 logtrace(LogTransform,"*\n");
335 }
336 }
337
338
339 void transform_4x4_luma_add_16_fallback(uint16_t *dst, const int16_t *coeffs, ptrdiff_t stride,
340 int bit_depth)
341 {
342 int16_t g[4][4];
343
344 int postShift = 20-bit_depth;
345 int rndV = 1<<(7-1);
346 int rndH = 1<<(postShift-1);
347
348
349 // --- V ---
350
351 for (int c=0;c<4;c++) {
352 /*
353 logtrace(LogTransform,"DST-V: ");
354 for (int r=0;r<4;r++) {
355 logtrace(LogTransform,"%d ",coeffs[c+r*4]);
356 }
357 logtrace(LogTransform,"* -> ");
358 */
359
360 for (int i=0;i<4;i++) {
361 int sum=0;
362
363 for (int j=0;j<4;j++) {
364 sum += mat_8_357[j][i] * coeffs[c+j*4];
365 }
366
367 g[i][c] = Clip3(-32768,32767, (sum+rndV)>>7);
368 }
369
370 /*
371 for (int y=0;y<4;y++) {
372 logtrace(LogTransform,"*%d ",g[y][c]);
373 }
374 logtrace(LogTransform,"*\n");
375 */
376 }
377
378
379 // --- H ---
380
381 for (int y=0;y<4;y++) {
382
383 /*
384 logtrace(LogTransform,"DST-H: ");
385 for (int c=0;c<4;c++) {
386 logtrace(LogTransform,"%d ",g[y][c]);
387 }
388 logtrace(LogTransform,"* -> ");
389 */
390
391 for (int i=0;i<4;i++) {
392 int sum=0;
393
394 for (int j=0;j<4;j++) {
395 sum += mat_8_357[j][i] * g[y][j];
396 }
397
398 int out = Clip3(-32768,32767, (sum+rndH)>>postShift);
399
400 dst[y*stride+i] = Clip_BitDepth(dst[y*stride+i] + out, bit_depth);
401
402 logtrace(LogTransform,"*%d ",out);
403 }
404
405 logtrace(LogTransform,"*\n");
406 }
407 }
408
409
410 void fdst_4x4_8_fallback(int16_t *coeffs, const int16_t *input, ptrdiff_t stride)
411 {
412 int16_t g[4*4];
413
414 int BD = 8;
415 int shift1 = Log2(4) + BD -9;
416 int shift2 = Log2(4) + 6;
417
418 int rnd1 = 1<<(shift1-1);
419 int rnd2 = 1<<(shift2-1);
420
421
422 // --- V ---
423
424 for (int c=0;c<4;c++) {
425
426 /*
427 logtrace(LogTransform,"DST-V: ");
428 for (int r=0;r<4;r++) {
429 logtrace(LogTransform,"%d ",coeffs[c+r*4]);
430 }
431 logtrace(LogTransform,"* -> ");
432 */
433
434 for (int i=0;i<4;i++) {
435 int sum=0;
436
437 for (int j=0;j<4;j++) {
438 sum += mat_8_357[i][j] * input[c+j*stride];
439 }
440
441 g[c+4*i] = Clip3(-32768,32767, (sum+rnd1)>>shift1);
442 }
443 }
444
445
446 // --- H ---
447
448 for (int y=0;y<4;y++) {
449 for (int i=0;i<4;i++) {
450 int sum=0;
451
452 for (int j=0;j<4;j++) {
453 sum += mat_8_357[i][j] * g[y*4+j];
454 }
455
456 // TODO: do we need clipping ?
457 int out = (sum+rnd2)>>shift2; // Clip3(-32768,32767, (sum+rndH)>>postShift);
458
459 coeffs[y*4+i] = out;
460
461 logtrace(LogTransform,"*%d ",out);
462 }
463
464 logtrace(LogTransform,"*\n");
465 }
466 }
467
468
469 void transform_idst_4x4_fallback(int32_t *dst, const int16_t *coeffs, int bdShift, int max_coeff_bits)
470 {
471 int16_t g[4][4];
472
473 int rndV = 1<<(7-1);
474 int rndH = 1<<(bdShift-1);
475
476 int CoeffMax = (1<<max_coeff_bits)-1;
477 int CoeffMin = -(1<<max_coeff_bits);
478
479
480 // --- V ---
481
482 for (int c=0;c<4;c++) {
483 for (int i=0;i<4;i++) {
484 int sum=0;
485
486 for (int j=0;j<4;j++) {
487 sum += mat_8_357[j][i] * coeffs[c+j*4];
488 }
489
490 g[i][c] = Clip3(CoeffMin,CoeffMax, (sum+rndV)>>7);
491 }
492 }
493
494
495 // --- H ---
496
497 for (int y=0;y<4;y++) {
498 for (int i=0;i<4;i++) {
499 int sum=0;
500
501 for (int j=0;j<4;j++) {
502 sum += mat_8_357[j][i] * g[y][j];
503 }
504
505 dst[y*4+i] = (sum + rndH)>>bdShift;
506 }
133507 }
134508 }
135509
173547
174548
175549
176 static void transform_dct_add_8(uint8_t *dst, ptrdiff_t stride,
177 int nT, int16_t *coeffs)
178 {
179 int postShift = 20-8; // 8 bit
550 template <class pixel_t>
551 void transform_idct_add(pixel_t *dst, ptrdiff_t stride,
552 int nT, const int16_t *coeffs, int bit_depth)
553 {
554 /*
555 The effective shift is
556 7 bits right for bit-depth 8,
557 6 bits right for bit-depth 9,
558 5 bits right for bit-depth 10.
559
560 Computation is independent of the block size.
561 Each multiplication with the table includes a left shift of 6 bits.
562 Hence, we have 2* 6 bits = 12 bits left shift.
563 V-pass has fixed 7 bit right shift.
564 H-pass has 20-BitDepth bit right shift;
565
566 Effective shift 's' means: residual value 1 gives DC-coeff (1<<s).
567 */
568
569
570 int postShift = 20-bit_depth;
180571 int rnd1 = 1<<(7-1);
181572 int rnd2 = 1<<(postShift-1);
182573 int fact = (1<<(5-Log2(nT)));
199590 printf("\n");
200591 */
201592
593 /*
594 printf("--- input\n");
595 for (int r=0;r<nT;r++, printf("\n"))
596 for (int c=0;c<nT;c++) {
597 printf("%3d ",coeffs[c+r*nT]);
598 }
599 */
600
202601 for (int c=0;c<nT;c++) {
203602
603 /*
204604 logtrace(LogTransform,"DCT-V: ");
205605 for (int i=0;i<nT;i++) {
206606 logtrace(LogTransform,"*%d ",coeffs[c+i*nT]);
207607 }
208608 logtrace(LogTransform,"* -> ");
609 */
209610
210611
211612 // find last non-zero coefficient to reduce computations carried out in DCT
217618
218619 for (int i=0;i<nT;i++) {
219620 int sum=0;
220
621
622 /*
623 printf("input: ");
624 for (int j=0;j<nT;j++) {
625 printf("%3d ",coeffs[c+j*nT]);
626 }
627 printf("\n");
628
629 printf("mat: ");
630 for (int j=0;j<nT;j++) {
631 printf("%3d ",mat_dct[fact*j][i]);
632 }
633 printf("\n");
634 */
635
221636 for (int j=0;j<=lastCol /*nT*/;j++) {
222637 sum += mat_dct[fact*j][i] * coeffs[c+j*nT];
223638 }
224
639
225640 g[c+i*nT] = Clip3(-32768,32767, (sum+rnd1)>>7);
226641
227642 logtrace(LogTransform,"*%d ",g[c+i*nT]);
229644 logtrace(LogTransform,"*\n");
230645 }
231646
647 /*
648 printf("--- temp\n");
649 for (int r=0;r<nT;r++, printf("\n"))
650 for (int c=0;c<nT;c++) {
651 printf("%3d ",g[c+r*nT]);
652 }
653 */
232654
233655 for (int y=0;y<nT;y++) {
234
656 /*
235657 logtrace(LogTransform,"DCT-H: ");
236658 for (int i=0;i<nT;i++) {
237659 logtrace(LogTransform,"*%d ",g[i+y*nT]);
238660 }
239661 logtrace(LogTransform,"* -> ");
662 */
240663
241664
242665 // find last non-zero coefficient to reduce computations carried out in DCT
249672
250673 for (int i=0;i<nT;i++) {
251674 int sum=0;
252
675
253676 for (int j=0;j<=lastCol /*nT*/;j++) {
254677 sum += mat_dct[fact*j][i] * g[y*nT+j];
255678 }
256
679
257680 //int out = Clip3(-32768,32767, (sum+rnd2)>>postShift);
258681 int out = (sum+rnd2)>>postShift;
259682
260683 //fprintf(stderr,"%d*%d+%d = %d\n",y,stride,i,y*stride+i);
261684 //fprintf(stderr,"[%p]=%d\n",&dst[y*stride+i], Clip1_8bit(dst[y*stride+i]));
262 dst[y*stride+i] = Clip1_8bit(dst[y*stride+i] + out);
685 dst[y*stride+i] = Clip_BitDepth(dst[y*stride+i] + out, bit_depth);
263686
264687 logtrace(LogTransform,"*%d ",out);
265688 }
268691 }
269692
270693
271 void transform_4x4_add_8_fallback(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride)
272 {
273 transform_dct_add_8(dst,stride, 4, coeffs);
274 }
275
276 void transform_8x8_add_8_fallback(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride)
277 {
278 transform_dct_add_8(dst,stride, 8, coeffs);
279 }
280
281 void transform_16x16_add_8_fallback(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride)
282 {
283 transform_dct_add_8(dst,stride, 16, coeffs);
284 }
285
286 void transform_32x32_add_8_fallback(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride)
287 {
288 transform_dct_add_8(dst,stride, 32, coeffs);
289 }
694
695 void transform_idct_fallback(int32_t *dst, int nT, const int16_t *coeffs, int bdShift, int max_coeff_bits)
696 {
697 /*
698 The effective shift is
699 7 bits right for bit-depth 8,
700 6 bits right for bit-depth 9,
701 5 bits right for bit-depth 10.
702
703 One transformation with raw transform filter values increases range be 2048 (=32*64).
704 This equals 11 bits.
705
706 Computation is independent of the block size.
707 Each multiplication with the table includes a left shift of 6 bits.
708 Hence, we have 2* 6 bits = 12 bits left shift.
709 V-pass has fixed 7 bit right shift.
710 H-pass has 20-BitDepth bit right shift;
711
712 Effective shift 's' means: residual value 1 gives DC-coeff (1<<s).
713 */
714
715
716 int rnd1 = 1<<(7-1);
717 int fact = (1<<(5-Log2(nT)));
718
719 //int bdShift = 20-bit_depth;
720 int rnd2 = 1<<(bdShift-1);
721
722 int16_t g[32*32]; // actually, only [nT*nT] used
723
724 int CoeffMax = (1<<max_coeff_bits)-1;
725 int CoeffMin = -(1<<max_coeff_bits);
726
727 // TODO: valgrind reports that dst[] contains uninitialized data.
728 // Probably from intra-prediction.
729
730 /*
731 for (int i=0;i<nT*nT;i++) {
732 printf("%d\n",coeffs[i]);
733 }
734
735 for (int y=0;y<nT;y++) {
736 for (int i=0;i<nT;i++) {
737 printf("%d ",dst[y*stride+i]);
738 }
739 }
740 printf("\n");
741 */
742
743 /*
744 printf("--- input\n");
745 for (int r=0;r<nT;r++, printf("\n"))
746 for (int c=0;c<nT;c++) {
747 printf("%3d ",coeffs[c+r*nT]);
748 }
749 */
750
751 for (int c=0;c<nT;c++) {
752
753 /*
754 logtrace(LogTransform,"DCT-V: ");
755 for (int i=0;i<nT;i++) {
756 logtrace(LogTransform,"*%d ",coeffs[c+i*nT]);
757 }
758 logtrace(LogTransform,"* -> ");
759 */
760
761
762 // find last non-zero coefficient to reduce computations carried out in DCT
763
764 int lastCol = nT-1;
765 for (;lastCol>=0;lastCol--) {
766 if (coeffs[c+lastCol*nT]) { break; }
767 }
768
769 for (int i=0;i<nT;i++) {
770 int sum=0;
771
772 /*
773 printf("input: ");
774 for (int j=0;j<nT;j++) {
775 printf("%3d ",coeffs[c+j*nT]);
776 }
777 printf("\n");
778
779 printf("mat: ");
780 for (int j=0;j<nT;j++) {
781 printf("%3d ",mat_dct[fact*j][i]);
782 }
783 printf("\n");
784 */
785
786 for (int j=0;j<=lastCol /*nT*/;j++) {
787 sum += mat_dct[fact*j][i] * coeffs[c+j*nT];
788 }
789
790 g[c+i*nT] = Clip3(CoeffMin,CoeffMax, (sum+rnd1)>>7);
791
792 logtrace(LogTransform,"*%d ",g[c+i*nT]);
793 }
794 logtrace(LogTransform,"*\n");
795 }
796
797 /*
798 printf("--- temp\n");
799 for (int r=0;r<nT;r++, printf("\n"))
800 for (int c=0;c<nT;c++) {
801 printf("%3d ",g[c+r*nT]);
802 }
803 */
804
805 for (int y=0;y<nT;y++) {
806 /*
807 logtrace(LogTransform,"DCT-H: ");
808 for (int i=0;i<nT;i++) {
809 logtrace(LogTransform,"*%d ",g[i+y*nT]);
810 }
811 logtrace(LogTransform,"* -> ");
812 */
813
814
815 // find last non-zero coefficient to reduce computations carried out in DCT
816
817 int lastCol = nT-1;
818 for (;lastCol>=0;lastCol--) {
819 if (g[y*nT+lastCol]) { break; }
820 }
821
822
823 for (int i=0;i<nT;i++) {
824 int sum=0;
825
826 for (int j=0;j<=lastCol /*nT*/;j++) {
827 sum += mat_dct[fact*j][i] * g[y*nT+j];
828 }
829
830 dst[y*nT+i] = (sum + rnd2)>>bdShift;
831
832 logtrace(LogTransform,"*%d ",sum);
833 }
834 logtrace(LogTransform,"*\n");
835 }
836 }
837
838
839 void transform_idct_4x4_fallback(int32_t *dst, const int16_t *coeffs, int bdShift, int max_coeff_bits)
840 {
841 transform_idct_fallback(dst,4,coeffs,bdShift,max_coeff_bits);
842 }
843
844 void transform_idct_8x8_fallback(int32_t *dst, const int16_t *coeffs, int bdShift, int max_coeff_bits)
845 {
846 transform_idct_fallback(dst,8,coeffs,bdShift,max_coeff_bits);
847 }
848
849 void transform_idct_16x16_fallback(int32_t *dst, const int16_t *coeffs,
850 int bdShift, int max_coeff_bits)
851 {
852 transform_idct_fallback(dst,16,coeffs,bdShift,max_coeff_bits);
853 }
854
855 void transform_idct_32x32_fallback(int32_t *dst, const int16_t *coeffs,
856 int bdShift, int max_coeff_bits)
857 {
858 transform_idct_fallback(dst,32,coeffs,bdShift,max_coeff_bits);
859 }
860
861
862
863
864 void transform_4x4_add_8_fallback(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride)
865 {
866 transform_idct_add<uint8_t>(dst,stride, 4, coeffs, 8);
867 }
868
869 void transform_8x8_add_8_fallback(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride)
870 {
871 transform_idct_add<uint8_t>(dst,stride, 8, coeffs, 8);
872 }
873
874 void transform_16x16_add_8_fallback(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride)
875 {
876 transform_idct_add<uint8_t>(dst,stride, 16, coeffs, 8);
877 }
878
879 void transform_32x32_add_8_fallback(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride)
880 {
881 transform_idct_add<uint8_t>(dst,stride, 32, coeffs, 8);
882 }
883
884
885 void transform_4x4_add_16_fallback(uint16_t *dst, const int16_t *coeffs, ptrdiff_t stride, int bit_depth)
886 {
887 transform_idct_add<uint16_t>(dst,stride, 4, coeffs, bit_depth);
888 }
889
890 void transform_8x8_add_16_fallback(uint16_t *dst, const int16_t *coeffs, ptrdiff_t stride, int bit_depth)
891 {
892 transform_idct_add<uint16_t>(dst,stride, 8, coeffs, bit_depth);
893 }
894
895 void transform_16x16_add_16_fallback(uint16_t *dst, const int16_t *coeffs, ptrdiff_t stride, int bit_depth)
896 {
897 transform_idct_add<uint16_t>(dst,stride, 16, coeffs, bit_depth);
898 }
899
900 void transform_32x32_add_16_fallback(uint16_t *dst, const int16_t *coeffs, ptrdiff_t stride, int bit_depth)
901 {
902 transform_idct_add<uint16_t>(dst,stride, 32, coeffs, bit_depth);
903 }
904
905
906 static void transform_fdct_8(int16_t* coeffs, int nT,
907 const int16_t *input, ptrdiff_t stride)
908 {
909 /*
910 Each sum over a basis vector sums nT elements, which is compensated by
911 shifting right by Log2(nT), effectively dividing by 2^Log2(nT) = nT.
912 Do this in each of the H/V passes.
913
914 Each multiplication with the table includes a left shift of 6 bits.
915 Hence, we have in total 2* 6 bits = 12 bits left shift because of the
916 multiplications.
917
918 We carry out shifts after each pass:
919 First (V) pass has BitDepth-9 bit right shift,
920 Second (H) pass has fixed 6 bit right shift.
921
922 For bit-depth 8, the total shift is 7 bits left.
923 For bit-depth 9, the total shift is 6 bits left.
924 For bit-depth 10, the total shift is 5 bits left.
925
926 I.e.: a constant residual value 1 gives DC-coeff (1<<s).
927
928 For 8-bit images in a 32x32 block, the input are 8 bits + 1 sign bit.
929 After the first pass, we need 9+5+6=20 bits for the intermediate sum
930 (9 bit input, 5 bit because we sum 2^5 elements, 6 bit because of multiplication with 64).
931 The first pass shift is Log2(32) - 1 -> 4 bits and we are down to 16 bits again.
932 After the second pass, we need 16+5+6=27 bits for the intermediate sum
933 (16 bit input, 5 bit because we sum 2^5 elements, 6 bit because of coefficient multiplication).
934 The second pass shift is Log2(32)+6 = 11 and we are down again to 16 bits.
935
936 For larger input bit-depths, the intermediate result after the first pass
937 will be wider accordingly, but the widths after the shifts are the same.
938 */
939
940 int BitDepth = 8;
941
942 // / compensate everything | / effective word length |
943 int shift1 = Log2(nT) + 6 + BitDepth - 15;
944 int shift2 = Log2(nT) + 6;
945
946 int rnd1 = 1<<(shift1-1);
947 int rnd2 = 1<<(shift2-1);
948 int fact = (1<<(5-Log2(nT)));
949
950 int16_t g[32*32]; // actually, only [nT*nT] used
951
952 for (int c=0;c<nT;c++) {
953
954 for (int i=0;i<nT;i++) {
955 int sum=0;
956
957 for (int j=0;j<nT;j++) {
958 sum += mat_dct[fact*i][j] * input[c+j*stride];
959 }
960
961 //assert((sum+rnd1)>>shift1 <= 32767);
962 //assert((sum+rnd1)>>shift1 >= -32768);
963 g[c+i*nT] = (sum+rnd1)>>shift1; // clipping to -32768;32767 unnecessary
964 }
965 }
966
967
968 for (int y=0;y<nT;y++) {
969 for (int i=0;i<nT;i++) {
970 int sum=0;
971
972 for (int j=0;j<nT;j++) {
973 sum += mat_dct[fact*i][j] * g[y*nT+j];
974 }
975
976 // no clipping to -32768;32767 required
977 int out = (sum+rnd2)>>shift2;
978
979 coeffs[y*nT+i] = out;
980 }
981 }
982 }
983
984
985 void fdct_4x4_8_fallback(int16_t *coeffs, const int16_t *input, ptrdiff_t stride)
986 {
987 transform_fdct_8(coeffs, 4, input,stride);
988 }
989
990 void fdct_8x8_8_fallback(int16_t *coeffs, const int16_t *input, ptrdiff_t stride)
991 {
992 transform_fdct_8(coeffs, 8, input,stride);
993 }
994
995 void fdct_16x16_8_fallback(int16_t *coeffs, const int16_t *input, ptrdiff_t stride)
996 {
997 transform_fdct_8(coeffs, 16, input,stride);
998 }
999
1000 void fdct_32x32_8_fallback(int16_t *coeffs, const int16_t *input, ptrdiff_t stride)
1001 {
1002 transform_fdct_8(coeffs, 32, input,stride);
1003 }
1004
1005
1006
1007
1008 void hadamard_transform_8(int16_t *coeffs, int n, const int16_t *input, ptrdiff_t stride)
1009 {
1010 int16_t tmp[32*32];
1011
1012 // row transforms
1013
1014 //printMatrix("input",input,n);
1015
1016 int16_t am[32],bm[32];
1017 int16_t *a = am, *b = bm;
1018 for (int row=0;row<n;row++) {
1019 int rs = row*stride;
1020 for (int i=0;i<(n>>1);i++) {
1021 a[ i] = input[i+rs] + input[i+(n>>1)+rs];
1022 a[(n>>1)+i] = input[i+rs] - input[i+(n>>1)+rs];
1023 }
1024
1025 int iOuter=(n>>1);
1026 int nInner=(n>>2);
1027
1028 while (nInner>=2) {
1029 std::swap(a,b);
1030
1031 for (int k=0;k<n;k+=iOuter) {
1032 for (int i=0;i<nInner;i++) {
1033 a[k+i ] = b[k+i] + b[k+i+nInner];
1034 a[k+i+nInner] = b[k+i] - b[k+i+nInner];
1035 }
1036 }
1037
1038 iOuter>>=1;
1039 nInner>>=1;
1040 }
1041
1042 for (int k=0;k<n;k+=2) {
1043 tmp[k +n*row] = a[k] + a[k+1];
1044 tmp[k+1+n*row] = a[k] - a[k+1];
1045 }
1046 }
1047
1048 //printMatrix("tmp",tmp,n);
1049
1050 // column transforms
1051
1052 for (int col=0;col<n;col++) {
1053 for (int i=0;i<(n>>1);i++) {
1054 a[ i] = tmp[i*n+col] + tmp[(i+(n>>1))*n+col];
1055 a[(n>>1)+i] = tmp[i*n+col] - tmp[(i+(n>>1))*n+col];
1056 }
1057
1058 int iOuter=(n>>1);
1059 int nInner=(n>>2);
1060
1061 while (nInner>=2) {
1062 std::swap(a,b);
1063
1064 for (int k=0;k<n;k+=iOuter) {
1065 for (int i=0;i<nInner;i++) {
1066 a[k+i ] = b[k+i] + b[k+i+nInner];
1067 a[k+i+nInner] = b[k+i] - b[k+i+nInner];
1068 }
1069 }
1070
1071 iOuter>>=1;
1072 nInner>>=1;
1073 }
1074
1075 for (int k=0;k<n;k+=2) {
1076 coeffs[col+(k )*n] = a[k] + a[k+1];
1077 coeffs[col+(k+1)*n] = a[k] - a[k+1];
1078 }
1079 }
1080
1081 //printMatrix("coeffs",coeffs,n);
1082 }
1083
1084
1085 void hadamard_4x4_8_fallback(int16_t *coeffs, const int16_t *input, ptrdiff_t stride)
1086 {
1087 int16_t tmp[4*4];
1088
1089 // row transforms
1090
1091 //printMatrix("input",input,4);
1092
1093 int16_t a[4];
1094 for (int row=0;row<4;row++) {
1095 int rs = row*stride;
1096 a[0] = input[0+rs] + input[2+rs];
1097 a[1] = input[1+rs] + input[3+rs];
1098 a[2] = input[0+rs] - input[2+rs];
1099 a[3] = input[1+rs] - input[3+rs];
1100
1101 tmp[0+4*row] = a[0]+a[1];
1102 tmp[1+4*row] = a[0]-a[1];
1103 tmp[2+4*row] = a[2]+a[3];
1104 tmp[3+4*row] = a[2]-a[3];
1105 }
1106
1107 //printMatrix("tmp",tmp,4);
1108
1109 // column transforms
1110
1111 for (int col=0;col<4;col++) {
1112 a[0] = tmp[col+0*4] + tmp[col+2*4];
1113 a[1] = tmp[col+1*4] + tmp[col+3*4];
1114 a[2] = tmp[col+0*4] - tmp[col+2*4];
1115 a[3] = tmp[col+1*4] - tmp[col+3*4];
1116
1117 coeffs[col+0*4] = a[0]+a[1];
1118 coeffs[col+1*4] = a[0]-a[1];
1119 coeffs[col+2*4] = a[2]+a[3];
1120 coeffs[col+3*4] = a[2]-a[3];
1121 }
1122
1123 //printMatrix("coeffs",coeffs,4);
1124 }
1125
1126
1127 void hadamard_8x8_8_fallback(int16_t *coeffs, const int16_t *input, ptrdiff_t stride)
1128 {
1129 int16_t tmp[8*8];
1130
1131 // row transforms
1132
1133 //printMatrix("input",input,8);
1134
1135 int16_t a[8],b[8];
1136 for (int row=0;row<8;row++) {
1137 int rs = row*stride;
1138 a[0] = input[0+rs] + input[4+rs];
1139 a[1] = input[1+rs] + input[5+rs];
1140 a[2] = input[2+rs] + input[6+rs];
1141 a[3] = input[3+rs] + input[7+rs];
1142 a[4] = input[0+rs] - input[4+rs];
1143 a[5] = input[1+rs] - input[5+rs];
1144 a[6] = input[2+rs] - input[6+rs];
1145 a[7] = input[3+rs] - input[7+rs];
1146
1147 b[0] = a[0]+a[2];
1148 b[1] = a[1]+a[3];
1149 b[2] = a[0]-a[2];
1150 b[3] = a[1]-a[3];
1151 b[4] = a[4]+a[6];
1152 b[5] = a[5]+a[7];
1153 b[6] = a[4]-a[6];
1154 b[7] = a[5]-a[7];
1155
1156 tmp[0+8*row] = b[0]+b[1];
1157 tmp[1+8*row] = b[0]-b[1];
1158 tmp[2+8*row] = b[2]+b[3];
1159 tmp[3+8*row] = b[2]-b[3];
1160 tmp[4+8*row] = b[4]+b[5];
1161 tmp[5+8*row] = b[4]-b[5];
1162 tmp[6+8*row] = b[6]+b[7];
1163 tmp[7+8*row] = b[6]-b[7];
1164 }
1165
1166 //printMatrix("tmp",tmp,8);
1167
1168 // column transforms
1169
1170 for (int col=0;col<8;col++) {
1171 a[0] = tmp[col+0*8] + tmp[col+4*8];
1172 a[1] = tmp[col+1*8] + tmp[col+5*8];
1173 a[2] = tmp[col+2*8] + tmp[col+6*8];
1174 a[3] = tmp[col+3*8] + tmp[col+7*8];
1175 a[4] = tmp[col+0*8] - tmp[col+4*8];
1176 a[5] = tmp[col+1*8] - tmp[col+5*8];
1177 a[6] = tmp[col+2*8] - tmp[col+6*8];
1178 a[7] = tmp[col+3*8] - tmp[col+7*8];
1179
1180 b[0] = a[0]+a[2];
1181 b[1] = a[1]+a[3];
1182 b[2] = a[0]-a[2];
1183 b[3] = a[1]-a[3];
1184 b[4] = a[4]+a[6];
1185 b[5] = a[5]+a[7];
1186 b[6] = a[4]-a[6];
1187 b[7] = a[5]-a[7];
1188
1189 coeffs[col+0*8] = b[0]+b[1];
1190 coeffs[col+1*8] = b[0]-b[1];
1191 coeffs[col+2*8] = b[2]+b[3];
1192 coeffs[col+3*8] = b[2]-b[3];
1193 coeffs[col+4*8] = b[4]+b[5];
1194 coeffs[col+5*8] = b[4]-b[5];
1195 coeffs[col+6*8] = b[6]+b[7];
1196 coeffs[col+7*8] = b[6]-b[7];
1197 }
1198
1199 //printMatrix("coeffs",coeffs,8);
1200 }
1201
1202
1203 void hadamard_16x16_8_fallback(int16_t *coeffs, const int16_t *input, ptrdiff_t stride)
1204 {
1205 hadamard_transform_8(coeffs,16, input,stride);
1206 }
1207
1208 void hadamard_32x32_8_fallback(int16_t *coeffs, const int16_t *input, ptrdiff_t stride)
1209 {
1210 hadamard_transform_8(coeffs,32, input,stride);
1211 }
2323 #include <stddef.h>
2424 #include <stdint.h>
2525
26 #include "util.h"
2627
27 void transform_skip_8_fallback(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
28 void transform_bypass_8_fallback(uint8_t *dst, int16_t *coeffs, int nT, ptrdiff_t stride);
2928
30 void transform_4x4_luma_add_8_fallback(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
31 void transform_4x4_add_8_fallback(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
32 void transform_8x8_add_8_fallback(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
33 void transform_16x16_add_8_fallback(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
34 void transform_32x32_add_8_fallback(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
29 // --- decoding ---
30
31 void transform_skip_8_fallback(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride);
32 void transform_bypass_fallback(int32_t *r, const int16_t *coeffs, int nT);
33
34 void transform_skip_rdpcm_v_8_fallback(uint8_t *dst, const int16_t *coeffs, int nT, ptrdiff_t stride);
35 void transform_skip_rdpcm_h_8_fallback(uint8_t *dst, const int16_t *coeffs, int nT, ptrdiff_t stride);
36 void transform_bypass_rdpcm_v_fallback(int32_t *r, const int16_t *coeffs,int nT);
37 void transform_bypass_rdpcm_h_fallback(int32_t *r, const int16_t *coeffs,int nT);
38
39 void transform_4x4_luma_add_8_fallback(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride);
40 void transform_4x4_add_8_fallback(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride);
41 void transform_8x8_add_8_fallback(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride);
42 void transform_16x16_add_8_fallback(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride);
43 void transform_32x32_add_8_fallback(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride);
44
45
46 void transform_skip_16_fallback(uint16_t *dst, const int16_t *coeffs, ptrdiff_t stride, int bit_depth);
47 void transform_bypass_16_fallback(uint16_t *dst, const int16_t *coeffs, int nT, ptrdiff_t stride, int bit_depth);
48
49 void transform_4x4_luma_add_16_fallback(uint16_t *dst, const int16_t *coeffs, ptrdiff_t stride, int bit_depth);
50 void transform_4x4_add_16_fallback(uint16_t *dst, const int16_t *coeffs, ptrdiff_t stride, int bit_depth);
51 void transform_8x8_add_16_fallback(uint16_t *dst, const int16_t *coeffs, ptrdiff_t stride, int bit_depth);
52 void transform_16x16_add_16_fallback(uint16_t *dst, const int16_t *coeffs, ptrdiff_t stride, int bit_depth);
53 void transform_32x32_add_16_fallback(uint16_t *dst, const int16_t *coeffs, ptrdiff_t stride, int bit_depth);
54
55 void rotate_coefficients_fallback(int16_t *coeff, int nT);
56
57
58 void transform_idst_4x4_fallback(int32_t *dst, const int16_t *coeffs, int bdShift, int max_coeff_bits);
59 void transform_idct_4x4_fallback(int32_t *dst, const int16_t *coeffs, int bdShift, int max_coeff_bits);
60 void transform_idct_8x8_fallback(int32_t *dst, const int16_t *coeffs, int bdShift, int max_coeff_bits);
61 void transform_idct_16x16_fallback(int32_t *dst, const int16_t *coeffs, int bdShift, int max_coeff_bits);
62 void transform_idct_32x32_fallback(int32_t *dst, const int16_t *coeffs, int bdShift, int max_coeff_bits);
63
64 template <class pixel_t>
65 void add_residual_fallback(pixel_t *dst, ptrdiff_t stride,
66 const int32_t* r, int nT, int bit_depth)
67 {
68 for (int y=0;y<nT;y++)
69 for (int x=0;x<nT;x++) {
70 dst[y*stride+x] = Clip_BitDepth(dst[y*stride+x] + r[y*nT+x], bit_depth);
71 }
72 }
73
74
75 void rdpcm_v_fallback(int32_t* residual, const int16_t* coeffs, int nT, int tsShift,int bdShift);
76 void rdpcm_h_fallback(int32_t* residual, const int16_t* coeffs, int nT, int tsShift,int bdShift);
77
78 void transform_skip_residual_fallback(int32_t *residual, const int16_t *coeffs, int nT,
79 int tsShift,int bdShift);
80
81
82 // --- encoding ---
83
84 void fdst_4x4_8_fallback(int16_t *coeffs, const int16_t *input, ptrdiff_t stride);
85 void fdct_4x4_8_fallback(int16_t *coeffs, const int16_t *input, ptrdiff_t stride);
86 void fdct_8x8_8_fallback(int16_t *coeffs, const int16_t *input, ptrdiff_t stride);
87 void fdct_16x16_8_fallback(int16_t *coeffs, const int16_t *input, ptrdiff_t stride);
88 void fdct_32x32_8_fallback(int16_t *coeffs, const int16_t *input, ptrdiff_t stride);
89
90 void hadamard_4x4_8_fallback(int16_t *coeffs, const int16_t *input, ptrdiff_t stride);
91 void hadamard_8x8_8_fallback(int16_t *coeffs, const int16_t *input, ptrdiff_t stride);
92 void hadamard_16x16_8_fallback(int16_t *coeffs, const int16_t *input, ptrdiff_t stride);
93 void hadamard_32x32_8_fallback(int16_t *coeffs, const int16_t *input, ptrdiff_t stride);
3594
3695 #endif
3030
3131
3232 void put_unweighted_pred_8_fallback(uint8_t *dst, ptrdiff_t dststride,
33 int16_t *src, ptrdiff_t srcstride,
33 const int16_t *src, ptrdiff_t srcstride,
3434 int width, int height)
3535 {
3636 int offset8bit = 32;
3939 assert((width&1)==0);
4040
4141 for (int y=0;y<height;y++) {
42 int16_t* in = &src[y*srcstride];
42 const int16_t* in = &src[y*srcstride];
4343 uint8_t* out = &dst[y*dststride];
4444
4545 for (int x=0;x<width;x+=2) {
5252
5353
5454 void put_weighted_pred_8_fallback(uint8_t *dst, ptrdiff_t dststride,
55 int16_t *src, ptrdiff_t srcstride,
55 const int16_t *src, ptrdiff_t srcstride,
5656 int width, int height,
5757 int w,int o,int log2WD)
5858 {
6161 const int rnd = (1<<(log2WD-1));
6262
6363 for (int y=0;y<height;y++) {
64 int16_t* in = &src[y*srcstride];
64 const int16_t* in = &src[y*srcstride];
6565 uint8_t* out = &dst[y*dststride];
6666
6767 for (int x=0;x<width;x++) {
7272 }
7373
7474 void put_weighted_bipred_8_fallback(uint8_t *dst, ptrdiff_t dststride,
75 int16_t *src1, int16_t *src2, ptrdiff_t srcstride,
75 const int16_t *src1, const int16_t *src2, ptrdiff_t srcstride,
7676 int width, int height,
7777 int w1,int o1, int w2,int o2, int log2WD)
7878 {
8181 const int rnd = ((o1+o2+1) << log2WD);
8282
8383 for (int y=0;y<height;y++) {
84 int16_t* in1 = &src1[y*srcstride];
85 int16_t* in2 = &src2[y*srcstride];
84 const int16_t* in1 = &src1[y*srcstride];
85 const int16_t* in2 = &src2[y*srcstride];
8686 uint8_t* out = &dst[y*dststride];
8787
8888 for (int x=0;x<width;x++) {
9494
9595
9696 void put_weighted_pred_avg_8_fallback(uint8_t *dst, ptrdiff_t dststride,
97 int16_t *src1, int16_t *src2,
97 const int16_t *src1, const int16_t *src2,
9898 ptrdiff_t srcstride, int width,
9999 int height)
100100 {
143143 #endif
144144 {
145145 for (int y=0;y<height;y++) {
146 int16_t* in1 = &src1[y*srcstride];
147 int16_t* in2 = &src2[y*srcstride];
146 const int16_t* in1 = &src1[y*srcstride];
147 const int16_t* in2 = &src2[y*srcstride];
148148 uint8_t* out = &dst[y*dststride];
149149
150150 for (int x=0;x<width;x+=2) {
158158
159159
160160
161
162
163 void put_unweighted_pred_16_fallback(uint16_t *dst, ptrdiff_t dststride,
164 const int16_t *src, ptrdiff_t srcstride,
165 int width, int height, int bit_depth)
166 {
167 int shift1 = 14-bit_depth;
168 int offset1 = 0;
169 if (shift1>0) { offset1 = 1<<(shift1-1); }
170
171 assert((width&1)==0);
172
173 for (int y=0;y<height;y++) {
174 const int16_t* in = &src[y*srcstride];
175 uint16_t* out = &dst[y*dststride];
176
177 for (int x=0;x<width;x+=2) {
178 out[0] = Clip_BitDepth((in[0] + offset1)>>shift1, bit_depth);
179 out[1] = Clip_BitDepth((in[1] + offset1)>>shift1, bit_depth);
180 out+=2; in+=2;
181 }
182 }
183 }
184
185 #include <stdlib.h>
186
187 void put_weighted_pred_16_fallback(uint16_t *dst, ptrdiff_t dststride,
188 const int16_t *src, ptrdiff_t srcstride,
189 int width, int height,
190 int w,int o,int log2WD, int bit_depth)
191 {
192 assert(log2WD>=1); // TODO
193
194 const int rnd = (1<<(log2WD-1));
195
196 for (int y=0;y<height;y++) {
197 const int16_t* in = &src[y*srcstride];
198 uint16_t* out = &dst[y*dststride];
199
200 for (int x=0;x<width;x++) {
201 out[0] = Clip_BitDepth(((in[0]*w + rnd)>>log2WD) + o, bit_depth);
202 out++; in++;
203 }
204 }
205 }
206
207 void put_weighted_bipred_16_fallback(uint16_t *dst, ptrdiff_t dststride,
208 const int16_t *src1, const int16_t *src2, ptrdiff_t srcstride,
209 int width, int height,
210 int w1,int o1, int w2,int o2, int log2WD, int bit_depth)
211 {
212 assert(log2WD>=1); // TODO
213
214 const int rnd = ((o1+o2+1) << log2WD);
215
216 for (int y=0;y<height;y++) {
217 const int16_t* in1 = &src1[y*srcstride];
218 const int16_t* in2 = &src2[y*srcstride];
219 uint16_t* out = &dst[y*dststride];
220
221 for (int x=0;x<width;x++) {
222 out[0] = Clip_BitDepth((in1[0]*w1 + in2[0]*w2 + rnd)>>(log2WD+1), bit_depth);
223 out++; in1++; in2++;
224 }
225 }
226 }
227
228
229 void put_weighted_pred_avg_16_fallback(uint16_t *dst, ptrdiff_t dststride,
230 const int16_t *src1, const int16_t *src2,
231 ptrdiff_t srcstride, int width,
232 int height, int bit_depth)
233 {
234 int shift2 = 15-bit_depth;
235 int offset2 = 1<<(shift2-1);
236
237 assert((width&1)==0);
238
239 for (int y=0;y<height;y++) {
240 const int16_t* in1 = &src1[y*srcstride];
241 const int16_t* in2 = &src2[y*srcstride];
242 uint16_t* out = &dst[y*dststride];
243
244 for (int x=0;x<width;x+=2) {
245 out[0] = Clip_BitDepth((in1[0] + in2[0] + offset2)>>shift2, bit_depth);
246 out[1] = Clip_BitDepth((in1[1] + in2[1] + offset2)>>shift2, bit_depth);
247 out+=2; in1+=2; in2+=2;
248 }
249 }
250 }
251
252
253
254
255
161256 void put_epel_8_fallback(int16_t *out, ptrdiff_t out_stride,
162 uint8_t *src, ptrdiff_t src_stride,
257 const uint8_t *src, ptrdiff_t src_stride,
163258 int width, int height,
164259 int mx, int my, int16_t* mcbuffer)
165260 {
167262
168263 for (int y=0;y<height;y++) {
169264 int16_t* o = &out[y*out_stride];
170 uint8_t* i = &src[y*src_stride];
265 const uint8_t* i = &src[y*src_stride];
171266
172267 for (int x=0;x<width;x++) {
173268 *o = *i << shift3;
178273 }
179274
180275
181 void put_epel_hv_8_fallback(int16_t *dst, ptrdiff_t dst_stride,
182 uint8_t *src, ptrdiff_t src_stride,
183 int nPbWC, int nPbHC,
184 int xFracC, int yFracC, int16_t* mcbuffer)
185 {
186 const int shift1 = 0;
276 void put_epel_16_fallback(int16_t *out, ptrdiff_t out_stride,
277 const uint16_t *src, ptrdiff_t src_stride,
278 int width, int height,
279 int mx, int my, int16_t* mcbuffer, int bit_depth)
280 {
281 int shift3 = 14 - bit_depth;
282
283 for (int y=0;y<height;y++) {
284 int16_t* o = &out[y*out_stride];
285 const uint16_t* i = &src[y*src_stride];
286
287 for (int x=0;x<width;x++) {
288 *o = *i << shift3;
289 o++;
290 i++;
291 }
292 }
293 }
294
295
296 template <class pixel_t>
297 void put_epel_hv_fallback(int16_t *dst, ptrdiff_t dst_stride,
298 const pixel_t *src, ptrdiff_t src_stride,
299 int nPbWC, int nPbHC,
300 int xFracC, int yFracC, int16_t* mcbuffer, int bit_depth)
301 {
302 const int shift1 = bit_depth-8;
187303 const int shift2 = 6;
188304 //const int shift3 = 6;
189305
223339 //printf("---H---(%d)\n",xFracC);
224340
225341 for (int y=-extra_top;y<nPbHC+extra_bottom;y++) {
226 uint8_t* p = &src[y*src_stride - extra_left];
342 const pixel_t* p = &src[y*src_stride - extra_left];
227343
228344 for (int x=0;x<nPbWC;x++) {
229345 int16_t v;
240356 }
241357
242358 //printf("%d %d %d %d -> %d\n",p[0],p[1],p[2],p[3],v);
243
359
244360 tmp2buf[y+extra_top + x*nPbH_extra] = v;
245361 p++;
246362
271387 default:
272388 case 7: v = (-2*p[0]+10*p[1]+58*p[2]-2*p[3])>>vshift; break;
273389 }
274
390
275391 dst[x + y*dst_stride] = v;
276392 p++;
277393 }
290406 }
291407
292408
409 template
410 void put_epel_hv_fallback<uint8_t>(int16_t *dst, ptrdiff_t dst_stride,
411 const uint8_t *src, ptrdiff_t src_stride,
412 int nPbWC, int nPbHC,
413 int xFracC, int yFracC, int16_t* mcbuffer, int bit_depth);
414 template
415 void put_epel_hv_fallback<uint16_t>(int16_t *dst, ptrdiff_t dst_stride,
416 const uint16_t *src, ptrdiff_t src_stride,
417 int nPbWC, int nPbHC,
418 int xFracC, int yFracC, int16_t* mcbuffer, int bit_depth);
419
293420
294421
295422 void put_qpel_0_0_fallback(int16_t *out, ptrdiff_t out_stride,
296 uint8_t *src, ptrdiff_t srcstride,
423 const uint8_t *src, ptrdiff_t srcstride,
297424 int nPbW, int nPbH, int16_t* mcbuffer)
298425 {
299426 //const int shift1 = 0; // sps->BitDepth_Y-8;
302429 // straight copy
303430
304431 for (int y=0;y<nPbH;y++) {
305 uint8_t* p = src + srcstride*y;
432 const uint8_t* p = src + srcstride*y;
306433 int16_t* o = out + out_stride*y;
307434
308435 for (int x=0;x<nPbW;x+=4) {
309 #if 0
310 *o = *p << shift2;
311 o++; p++;
312 #else
436
313437 // does not seem to be faster...
314438 int16_t o0,o1,o2,o3;
315439 o0 = p[0] << shift2;
323447
324448 o+=4;
325449 p+=4;
326 #endif
327 }
450 }
451 }
452 }
453
454
455 void put_qpel_0_0_fallback_16(int16_t *out, ptrdiff_t out_stride,
456 const uint16_t *src, ptrdiff_t srcstride,
457 int nPbW, int nPbH, int16_t* mcbuffer, int bit_depth)
458 {
459 //const int shift1 = bit_depth-8;
460 //const int shift2 = 6;
461 const int shift3 = 14-bit_depth;
462
463 // straight copy
464
465 for (int y=0;y<nPbH;y++) {
466 const uint16_t* p = src + srcstride*y;
467 int16_t* o = out + out_stride*y;
468
469 for (int x=0;x<nPbW;x++) {
470 *o++ = *p++ << shift3;
471 }
328472 }
329473 }
330474
333477 static int extra_before[4] = { 0,3,3,2 };
334478 static int extra_after [4] = { 0,3,4,4 };
335479
480 template <class pixel_t>
336481 void put_qpel_fallback(int16_t *out, ptrdiff_t out_stride,
337 uint8_t *src, ptrdiff_t srcstride,
482 const pixel_t *src, ptrdiff_t srcstride,
338483 int nPbW, int nPbH, int16_t* mcbuffer,
339 int xFracL, int yFracL)
484 int xFracL, int yFracL, int bit_depth)
340485 {
341486 int extra_left = extra_before[xFracL];
342487 //int extra_right = extra_after [xFracL];
346491 //int nPbW_extra = extra_left + nPbW + extra_right;
347492 int nPbH_extra = extra_top + nPbH + extra_bottom;
348493
349 const int shift1 = 0; // sps->BitDepth_Y-8;
494 const int shift1 = bit_depth-8;
350495 const int shift2 = 6;
351496
352497
355500 switch (xFracL) {
356501 case 0:
357502 for (int y=-extra_top;y<nPbH+extra_bottom;y++) {
358 uint8_t* p = src + srcstride*y - extra_left;
503 const pixel_t* p = src + srcstride*y - extra_left;
359504 int16_t* o = &mcbuffer[y+extra_top];
360505
361506 for (int x=0;x<nPbW;x++) {
367512 break;
368513 case 1:
369514 for (int y=-extra_top;y<nPbH+extra_bottom;y++) {
370 uint8_t* p = src + srcstride*y - extra_left;
515 const pixel_t* p = src + srcstride*y - extra_left;
371516 int16_t* o = &mcbuffer[y+extra_top];
372517
373518 for (int x=0;x<nPbW;x++) {
379524 break;
380525 case 2:
381526 for (int y=-extra_top;y<nPbH+extra_bottom;y++) {
382 uint8_t* p = src + srcstride*y - extra_left;
527 const pixel_t* p = src + srcstride*y - extra_left;
383528 int16_t* o = &mcbuffer[y+extra_top];
384529
385530 for (int x=0;x<nPbW;x++) {
391536 break;
392537 case 3:
393538 for (int y=-extra_top;y<nPbH+extra_bottom;y++) {
394 uint8_t* p = src + srcstride*y - extra_left;
539 const pixel_t* p = src + srcstride*y - extra_left;
395540 int16_t* o = &mcbuffer[y+extra_top];
396541
397542 for (int x=0;x<nPbW;x++) {
420565 switch (yFracL) {
421566 case 0:
422567 for (int x=0;x<nPbW;x++) {
423 int16_t* p = &mcbuffer[x*nPbH_extra];
568 const int16_t* p = &mcbuffer[x*nPbH_extra];
424569 int16_t* o = &out[x];
425
570
426571 for (int y=0;y<nPbH;y++) {
427572 *o = *p;
428573 o+=out_stride;
432577 break;
433578 case 1:
434579 for (int x=0;x<nPbW;x++) {
435 int16_t* p = &mcbuffer[x*nPbH_extra];
580 const int16_t* p = &mcbuffer[x*nPbH_extra];
436581 int16_t* o = &out[x];
437
582
438583 for (int y=0;y<nPbH;y++) {
439584 *o = (-p[0]+4*p[1]-10*p[2]+58*p[3]+17*p[4] -5*p[5] +p[6])>>vshift;
440585 o+=out_stride;
444589 break;
445590 case 2:
446591 for (int x=0;x<nPbW;x++) {
447 int16_t* p = &mcbuffer[x*nPbH_extra];
592 const int16_t* p = &mcbuffer[x*nPbH_extra];
448593 int16_t* o = &out[x];
449
594
450595 for (int y=0;y<nPbH;y++) {
451596 *o = (-p[0]+4*p[1]-11*p[2]+40*p[3]+40*p[4]-11*p[5]+4*p[6]-p[7])>>vshift;
452597 o+=out_stride;
456601 break;
457602 case 3:
458603 for (int x=0;x<nPbW;x++) {
459 int16_t* p = &mcbuffer[x*nPbH_extra];
604 const int16_t* p = &mcbuffer[x*nPbH_extra];
460605 int16_t* o = &out[x];
461
606
462607 for (int y=0;y<nPbH;y++) {
463608 *o = ( p[0]-5*p[1]+17*p[2]+58*p[3]-10*p[4] +4*p[5] -p[6])>>vshift;
464609 o+=out_stride;
479624 }
480625
481626
627
482628 #define QPEL(x,y) void put_qpel_ ## x ## _ ## y ## _fallback(int16_t *out, ptrdiff_t out_stride, \
483 uint8_t *src, ptrdiff_t srcstride, \
484 int nPbW, int nPbH, int16_t* mcbuffer) \
485 { put_qpel_fallback(out,out_stride, src,srcstride, nPbW,nPbH,mcbuffer,x,y ); }
629 const uint8_t *src, ptrdiff_t srcstride, \
630 int nPbW, int nPbH, int16_t* mcbuffer) \
631 { put_qpel_fallback(out,out_stride, src,srcstride, nPbW,nPbH,mcbuffer,x,y, 8 ); }
632
633
634 #define QPEL16(x,y) void put_qpel_ ## x ## _ ## y ## _fallback_16(int16_t *out, ptrdiff_t out_stride, \
635 const uint16_t *src, ptrdiff_t srcstride, \
636 int nPbW, int nPbH, int16_t* mcbuffer, int bit_depth) \
637 { put_qpel_fallback(out,out_stride, src,srcstride, nPbW,nPbH,mcbuffer,x,y, bit_depth ); }
486638
487639 /* */ QPEL(0,1) QPEL(0,2) QPEL(0,3)
488640 QPEL(1,0) QPEL(1,1) QPEL(1,2) QPEL(1,3)
489641 QPEL(2,0) QPEL(2,1) QPEL(2,2) QPEL(2,3)
490642 QPEL(3,0) QPEL(3,1) QPEL(3,2) QPEL(3,3)
643
644 /* */ QPEL16(0,1) QPEL16(0,2) QPEL16(0,3)
645 QPEL16(1,0) QPEL16(1,1) QPEL16(1,2) QPEL16(1,3)
646 QPEL16(2,0) QPEL16(2,1) QPEL16(2,2) QPEL16(2,3)
647 QPEL16(3,0) QPEL16(3,1) QPEL16(3,2) QPEL16(3,3)
2525
2626
2727 void put_weighted_pred_avg_8_fallback(uint8_t *dst, ptrdiff_t dststride,
28 int16_t *src1, int16_t *src2,
28 const int16_t *src1, const int16_t *src2,
2929 ptrdiff_t srcstride, int width,
3030 int height);
3131
3232 void put_unweighted_pred_8_fallback(uint8_t *_dst, ptrdiff_t dststride,
33 int16_t *src, ptrdiff_t srcstride,
33 const int16_t *src, ptrdiff_t srcstride,
3434 int width, int height);
3535
3636 void put_weighted_pred_8_fallback(uint8_t *_dst, ptrdiff_t dststride,
37 int16_t *src, ptrdiff_t srcstride,
37 const int16_t *src, ptrdiff_t srcstride,
3838 int width, int height,
3939 int w,int o,int log2WD);
4040 void put_weighted_bipred_8_fallback(uint8_t *_dst, ptrdiff_t dststride,
41 int16_t *src1, int16_t *src2, ptrdiff_t srcstride,
41 const int16_t *src1, const int16_t *src2, ptrdiff_t srcstride,
4242 int width, int height,
4343 int w1,int o1, int w2,int o2, int log2WD);
4444
45 void put_weighted_pred_avg_16_fallback(uint16_t *dst, ptrdiff_t dststride,
46 const int16_t *src1, const int16_t *src2,
47 ptrdiff_t srcstride, int width,
48 int height, int bit_depth);
49
50 void put_unweighted_pred_16_fallback(uint16_t *_dst, ptrdiff_t dststride,
51 const int16_t *src, ptrdiff_t srcstride,
52 int width, int height, int bit_depth);
53
54 void put_weighted_pred_16_fallback(uint16_t *_dst, ptrdiff_t dststride,
55 const int16_t *src, ptrdiff_t srcstride,
56 int width, int height,
57 int w,int o,int log2WD, int bit_depth);
58 void put_weighted_bipred_16_fallback(uint16_t *_dst, ptrdiff_t dststride,
59 const int16_t *src1, const int16_t *src2, ptrdiff_t srcstride,
60 int width, int height,
61 int w1,int o1, int w2,int o2, int log2WD, int bit_depth);
62
63
64
4565 void put_epel_8_fallback(int16_t *dst, ptrdiff_t dststride,
46 uint8_t *_src, ptrdiff_t srcstride,
47 int width, int height,
48 int mx, int my, int16_t* mcbuffer);
49 void put_epel_hv_8_fallback(int16_t *dst, ptrdiff_t dststride,
50 uint8_t *_src, ptrdiff_t srcstride,
51 int width, int height,
52 int mx, int my, int16_t* mcbuffer);
66 const uint8_t *_src, ptrdiff_t srcstride,
67 int width, int height,
68 int mx, int my, int16_t* mcbuffer);
5369
54 void put_qpel_0_0_fallback(int16_t *out, ptrdiff_t out_stride,
55 uint8_t *src, ptrdiff_t srcstride,
56 int nPbW, int nPbH, int16_t* mcbuffer);
57 void put_qpel_0_1_fallback(int16_t *out, ptrdiff_t out_stride,
58 uint8_t *src, ptrdiff_t srcstride,
59 int nPbW, int nPbH, int16_t* mcbuffer);
60 void put_qpel_0_2_fallback(int16_t *out, ptrdiff_t out_stride,
61 uint8_t *src, ptrdiff_t srcstride,
62 int nPbW, int nPbH, int16_t* mcbuffer);
63 void put_qpel_0_3_fallback(int16_t *out, ptrdiff_t out_stride,
64 uint8_t *src, ptrdiff_t srcstride,
65 int nPbW, int nPbH, int16_t* mcbuffer);
66 void put_qpel_1_0_fallback(int16_t *out, ptrdiff_t out_stride,
67 uint8_t *src, ptrdiff_t srcstride,
68 int nPbW, int nPbH, int16_t* mcbuffer);
69 void put_qpel_1_1_fallback(int16_t *out, ptrdiff_t out_stride,
70 uint8_t *src, ptrdiff_t srcstride,
71 int nPbW, int nPbH, int16_t* mcbuffer);
72 void put_qpel_1_2_fallback(int16_t *out, ptrdiff_t out_stride,
73 uint8_t *src, ptrdiff_t srcstride,
74 int nPbW, int nPbH, int16_t* mcbuffer);
75 void put_qpel_1_3_fallback(int16_t *out, ptrdiff_t out_stride,
76 uint8_t *src, ptrdiff_t srcstride,
77 int nPbW, int nPbH, int16_t* mcbuffer);
78 void put_qpel_2_0_fallback(int16_t *out, ptrdiff_t out_stride,
79 uint8_t *src, ptrdiff_t srcstride,
80 int nPbW, int nPbH, int16_t* mcbuffer);
81 void put_qpel_2_1_fallback(int16_t *out, ptrdiff_t out_stride,
82 uint8_t *src, ptrdiff_t srcstride,
83 int nPbW, int nPbH, int16_t* mcbuffer);
84 void put_qpel_2_2_fallback(int16_t *out, ptrdiff_t out_stride,
85 uint8_t *src, ptrdiff_t srcstride,
86 int nPbW, int nPbH, int16_t* mcbuffer);
87 void put_qpel_2_3_fallback(int16_t *out, ptrdiff_t out_stride,
88 uint8_t *src, ptrdiff_t srcstride,
89 int nPbW, int nPbH, int16_t* mcbuffer);
90 void put_qpel_3_0_fallback(int16_t *out, ptrdiff_t out_stride,
91 uint8_t *src, ptrdiff_t srcstride,
92 int nPbW, int nPbH, int16_t* mcbuffer);
93 void put_qpel_3_1_fallback(int16_t *out, ptrdiff_t out_stride,
94 uint8_t *src, ptrdiff_t srcstride,
95 int nPbW, int nPbH, int16_t* mcbuffer);
96 void put_qpel_3_2_fallback(int16_t *out, ptrdiff_t out_stride,
97 uint8_t *src, ptrdiff_t srcstride,
98 int nPbW, int nPbH, int16_t* mcbuffer);
99 void put_qpel_3_3_fallback(int16_t *out, ptrdiff_t out_stride,
100 uint8_t *src, ptrdiff_t srcstride,
101 int nPbW, int nPbH, int16_t* mcbuffer);
70 void put_epel_16_fallback(int16_t *out, ptrdiff_t out_stride,
71 const uint16_t *src, ptrdiff_t src_stride,
72 int width, int height,
73 int mx, int my, int16_t* mcbuffer, int bit_depth);
74
75 template <class pixel_t>
76 void put_epel_hv_fallback(int16_t *dst, ptrdiff_t dststride,
77 const pixel_t *_src, ptrdiff_t srcstride,
78 int width, int height,
79 int mx, int my, int16_t* mcbuffer, int bit_depth);
80
81
82 #define QPEL(x,y) void put_qpel_ ## x ## _ ## y ## _fallback(int16_t *out, ptrdiff_t out_stride, \
83 const uint8_t *src, ptrdiff_t srcstride, \
84 int nPbW, int nPbH, int16_t* mcbuffer)
85 QPEL(0,0); QPEL(0,1); QPEL(0,2); QPEL(0,3);
86 QPEL(1,0); QPEL(1,1); QPEL(1,2); QPEL(1,3);
87 QPEL(2,0); QPEL(2,1); QPEL(2,2); QPEL(2,3);
88 QPEL(3,0); QPEL(3,1); QPEL(3,2); QPEL(3,3);
89
90 #undef QPEL
91
92
93 #define QPEL(x,y) void put_qpel_ ## x ## _ ## y ## _fallback_16(int16_t *out, ptrdiff_t out_stride, \
94 const uint16_t *src, ptrdiff_t srcstride, \
95 int nPbW, int nPbH, int16_t* mcbuffer, int bit_depth)
96 QPEL(0,0); QPEL(0,1); QPEL(0,2); QPEL(0,3);
97 QPEL(1,0); QPEL(1,1); QPEL(1,2); QPEL(1,3);
98 QPEL(2,0); QPEL(2,1); QPEL(2,2); QPEL(2,3);
99 QPEL(3,0); QPEL(3,1); QPEL(3,2); QPEL(3,3);
100
101 #undef QPEL
102102
103103 #endif
2626 {
2727 accel->put_weighted_pred_avg_8 = put_weighted_pred_avg_8_fallback;
2828 accel->put_unweighted_pred_8 = put_unweighted_pred_8_fallback;
29
3029 accel->put_weighted_pred_8 = put_weighted_pred_8_fallback;
3130 accel->put_weighted_bipred_8 = put_weighted_bipred_8_fallback;
3231
32 accel->put_weighted_pred_avg_16 = put_weighted_pred_avg_16_fallback;
33 accel->put_unweighted_pred_16 = put_unweighted_pred_16_fallback;
34 accel->put_weighted_pred_16 = put_weighted_pred_16_fallback;
35 accel->put_weighted_bipred_16 = put_weighted_bipred_16_fallback;
36
37
3338 accel->put_hevc_epel_8 = put_epel_8_fallback;
34 accel->put_hevc_epel_h_8 = put_epel_hv_8_fallback;
35 accel->put_hevc_epel_v_8 = put_epel_hv_8_fallback;
36 accel->put_hevc_epel_hv_8 = put_epel_hv_8_fallback;
39 accel->put_hevc_epel_h_8 = put_epel_hv_fallback<uint8_t>;
40 accel->put_hevc_epel_v_8 = put_epel_hv_fallback<uint8_t>;
41 accel->put_hevc_epel_hv_8 = put_epel_hv_fallback<uint8_t>;
3742
3843 accel->put_hevc_qpel_8[0][0] = put_qpel_0_0_fallback;
3944 accel->put_hevc_qpel_8[0][1] = put_qpel_0_1_fallback;
5257 accel->put_hevc_qpel_8[3][2] = put_qpel_3_2_fallback;
5358 accel->put_hevc_qpel_8[3][3] = put_qpel_3_3_fallback;
5459
60 accel->put_hevc_epel_16 = put_epel_16_fallback;
61 accel->put_hevc_epel_h_16 = put_epel_hv_fallback<uint16_t>;
62 accel->put_hevc_epel_v_16 = put_epel_hv_fallback<uint16_t>;
63 accel->put_hevc_epel_hv_16 = put_epel_hv_fallback<uint16_t>;
64
65 accel->put_hevc_qpel_16[0][0] = put_qpel_0_0_fallback_16;
66 accel->put_hevc_qpel_16[0][1] = put_qpel_0_1_fallback_16;
67 accel->put_hevc_qpel_16[0][2] = put_qpel_0_2_fallback_16;
68 accel->put_hevc_qpel_16[0][3] = put_qpel_0_3_fallback_16;
69 accel->put_hevc_qpel_16[1][0] = put_qpel_1_0_fallback_16;
70 accel->put_hevc_qpel_16[1][1] = put_qpel_1_1_fallback_16;
71 accel->put_hevc_qpel_16[1][2] = put_qpel_1_2_fallback_16;
72 accel->put_hevc_qpel_16[1][3] = put_qpel_1_3_fallback_16;
73 accel->put_hevc_qpel_16[2][0] = put_qpel_2_0_fallback_16;
74 accel->put_hevc_qpel_16[2][1] = put_qpel_2_1_fallback_16;
75 accel->put_hevc_qpel_16[2][2] = put_qpel_2_2_fallback_16;
76 accel->put_hevc_qpel_16[2][3] = put_qpel_2_3_fallback_16;
77 accel->put_hevc_qpel_16[3][0] = put_qpel_3_0_fallback_16;
78 accel->put_hevc_qpel_16[3][1] = put_qpel_3_1_fallback_16;
79 accel->put_hevc_qpel_16[3][2] = put_qpel_3_2_fallback_16;
80 accel->put_hevc_qpel_16[3][3] = put_qpel_3_3_fallback_16;
81
82
83
5584 accel->transform_skip_8 = transform_skip_8_fallback;
56 accel->transform_bypass_8 = transform_bypass_8_fallback;
57 accel->transform_4x4_luma_add_8 = transform_4x4_luma_add_8_fallback;
58 accel->transform_4x4_add_8 = transform_4x4_add_8_fallback;
59 accel->transform_8x8_add_8 = transform_8x8_add_8_fallback;
60 accel->transform_16x16_add_8 = transform_16x16_add_8_fallback;
61 accel->transform_32x32_add_8 = transform_32x32_add_8_fallback;
85 accel->transform_skip_rdpcm_h_8 = transform_skip_rdpcm_h_8_fallback;
86 accel->transform_skip_rdpcm_v_8 = transform_skip_rdpcm_v_8_fallback;
87 accel->transform_bypass = transform_bypass_fallback;
88 accel->transform_bypass_rdpcm_h = transform_bypass_rdpcm_h_fallback;
89 accel->transform_bypass_rdpcm_v = transform_bypass_rdpcm_v_fallback;
90 accel->transform_4x4_dst_add_8 = transform_4x4_luma_add_8_fallback;
91 accel->transform_add_8[0] = transform_4x4_add_8_fallback;
92 accel->transform_add_8[1] = transform_8x8_add_8_fallback;
93 accel->transform_add_8[2] = transform_16x16_add_8_fallback;
94 accel->transform_add_8[3] = transform_32x32_add_8_fallback;
95
96 accel->transform_skip_16 = transform_skip_16_fallback;
97 accel->transform_4x4_dst_add_16 = transform_4x4_luma_add_16_fallback;
98 accel->transform_add_16[0] = transform_4x4_add_16_fallback;
99 accel->transform_add_16[1] = transform_8x8_add_16_fallback;
100 accel->transform_add_16[2] = transform_16x16_add_16_fallback;
101 accel->transform_add_16[3] = transform_32x32_add_16_fallback;
102
103 accel->rotate_coefficients = rotate_coefficients_fallback;
104 accel->add_residual_8 = add_residual_fallback<uint8_t>;
105 accel->add_residual_16 = add_residual_fallback<uint16_t>;
106 accel->rdpcm_h = rdpcm_h_fallback;
107 accel->rdpcm_v = rdpcm_v_fallback;
108 accel->transform_skip_residual = transform_skip_residual_fallback;
109
110 accel->transform_idst_4x4 = transform_idst_4x4_fallback;
111 accel->transform_idct_4x4 = transform_idct_4x4_fallback;
112 accel->transform_idct_8x8 = transform_idct_8x8_fallback;
113 accel->transform_idct_16x16 = transform_idct_16x16_fallback;
114 accel->transform_idct_32x32 = transform_idct_32x32_fallback;
115
116 accel->fwd_transform_4x4_dst_8 = fdst_4x4_8_fallback;
117 accel->fwd_transform_8[0] = fdct_4x4_8_fallback;
118 accel->fwd_transform_8[1] = fdct_8x8_8_fallback;
119 accel->fwd_transform_8[2] = fdct_16x16_8_fallback;
120 accel->fwd_transform_8[3] = fdct_32x32_8_fallback;
121
122 accel->hadamard_transform_8[0] = hadamard_4x4_8_fallback;
123 accel->hadamard_transform_8[1] = hadamard_8x8_8_fallback;
124 accel->hadamard_transform_8[2] = hadamard_16x16_8_fallback;
125 accel->hadamard_transform_8[3] = hadamard_32x32_8_fallback;
62126 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: struktur AG, Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #include "libde265/image-io.h"
23 #include <assert.h>
24
25
26 ImageSource_YUV::~ImageSource_YUV()
27 {
28 if (mFH) {
29 fclose(mFH);
30 }
31 }
32
33
34 bool ImageSource_YUV::set_input_file(const char* filename, int w,int h)
35 {
36 assert(mFH==NULL);
37
38 mFH = fopen(filename,"rb");
39 if (mFH==NULL) {
40 return false;
41 }
42
43 width =w;
44 height=h;
45 mReachedEndOfFile = false;
46
47 return true;
48 }
49
50
51 de265_image* ImageSource_YUV::read_next_image()
52 {
53 if (mReachedEndOfFile) return NULL;
54
55 de265_image* img = new de265_image;
56 img->alloc_image(width,height,de265_chroma_420, NULL, false,
57 NULL, NULL, 0, NULL, false);
58 assert(img); // TODO: error handling
59
60 // --- load image ---
61
62 uint8_t* p;
63 int stride;
64
65 p = img->get_image_plane(0); stride = img->get_image_stride(0);
66 for (int y=0;y<height;y++) {
67 if (fread(p+y*stride,1,width,mFH) != width) {
68 goto check_eof;
69 }
70 }
71
72 p = img->get_image_plane(1); stride = img->get_image_stride(1);
73 for (int y=0;y<height/2;y++) {
74 if (fread(p+y*stride,1,width/2,mFH) != width/2) {
75 goto check_eof;
76 }
77 }
78
79 p = img->get_image_plane(2); stride = img->get_image_stride(2);
80 for (int y=0;y<height/2;y++) {
81 if (fread(p+y*stride,1,width/2,mFH) != width/2) {
82 goto check_eof;
83 }
84 }
85
86 // --- check for EOF ---
87
88 check_eof:
89 if (feof(mFH)) {
90 mReachedEndOfFile = true;
91 delete img;
92 return NULL;
93 }
94 else {
95 return img;
96 }
97 }
98
99
100 /*
101 ImageSource::ImageStatus ImageSource_YUV::get_status()
102 {
103 return Available;
104 }
105 */
106
107 de265_image* ImageSource_YUV::get_image(bool block)
108 {
109 de265_image* img = read_next_image();
110 return img;
111 }
112
113
114 void ImageSource_YUV::skip_frames(int n)
115 {
116 int imageSize = width*height*3/2;
117 fseek(mFH,n * imageSize, SEEK_CUR);
118 }
119
120
121
122
123 ImageSink_YUV::~ImageSink_YUV()
124 {
125 if (mFH) {
126 fclose(mFH);
127 }
128 }
129
130 bool ImageSink_YUV::set_filename(const char* filename)
131 {
132 assert(mFH==NULL);
133
134 mFH = fopen(filename,"wb");
135
136 return true;
137 }
138
139 void ImageSink_YUV::send_image(const de265_image* img)
140 {
141 // --- write image ---
142
143 const uint8_t* p;
144 int stride;
145
146 int width = img->get_width();
147 int height= img->get_height();
148
149 p = img->get_image_plane(0); stride = img->get_image_stride(0);
150 for (int y=0;y<height;y++) {
151 fwrite(p+y*stride,1,width,mFH);
152 }
153
154 p = img->get_image_plane(1); stride = img->get_image_stride(1);
155 for (int y=0;y<height/2;y++) {
156 fwrite(p+y*stride,1,width/2,mFH);
157 }
158
159 p = img->get_image_plane(2); stride = img->get_image_stride(2);
160 for (int y=0;y<height/2;y++) {
161 fwrite(p+y*stride,1,width/2,mFH);
162 }
163 }
164
165
166
167 LIBDE265_API PacketSink_File::~PacketSink_File()
168 {
169 if (mFH) {
170 fclose(mFH);
171 }
172 }
173
174
175 LIBDE265_API void PacketSink_File::set_filename(const char* filename)
176 {
177 assert(mFH==NULL);
178
179 mFH = fopen(filename,"wb");
180 }
181
182
183 LIBDE265_API void PacketSink_File::send_packet(const uint8_t* data, int n)
184 {
185 uint8_t startCode[3];
186 startCode[0] = 0;
187 startCode[1] = 0;
188 startCode[2] = 1;
189
190 fwrite(startCode,1,3,mFH);
191 fwrite(data,1,n,mFH);
192 fflush(mFH);
193 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * Authors: struktur AG, Dirk Farin <farin@struktur.de>
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 <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef IMAGE_IO_H
23 #define IMAGE_IO_H
24
25 #include "libde265/image.h"
26 #include <deque>
27
28
29 class ImageSource
30 {
31 public:
32 LIBDE265_API ImageSource() { }
33 virtual LIBDE265_API ~ImageSource() { }
34
35 //enum ImageStatus { Available, Waiting, EndOfVideo };
36
37 //virtual ImageStatus get_status() = 0;
38 virtual LIBDE265_API de265_image* get_image(bool block=true) = 0;
39 virtual LIBDE265_API void skip_frames(int n) = 0;
40
41 virtual LIBDE265_API int get_width() const = 0;
42 virtual LIBDE265_API int get_height() const = 0;
43 };
44
45
46
47 class ImageSource_YUV : public ImageSource
48 {
49 public:
50 LIBDE265_API ImageSource_YUV() : mFH(NULL) { }
51 virtual LIBDE265_API ~ImageSource_YUV();
52
53 bool LIBDE265_API set_input_file(const char* filename, int w,int h);
54
55 //virtual ImageStatus get_status();
56 virtual LIBDE265_API de265_image* get_image(bool block=true);
57 virtual LIBDE265_API void skip_frames(int n);
58
59 virtual LIBDE265_API int get_width() const { return width; }
60 virtual LIBDE265_API int get_height() const { return height; }
61
62 private:
63 FILE* mFH;
64 bool mReachedEndOfFile;
65
66 int width,height;
67
68 de265_image* read_next_image();
69 };
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() : mFH(NULL) { }
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
1919
2020 #include "image.h"
2121 #include "decctx.h"
22 #include "encoder/encoder-context.h"
2223
2324 #include <stdlib.h>
2425 #include <string.h>
3637 #else
3738 #define MEMORY_PADDING 0
3839 #endif
40
41 #define STANDARD_ALIGNMENT 16
3942
4043 #ifdef HAVE___MINGW_ALIGNED_MALLOC
4144 #define ALLOC_ALIGNED(alignment, size) __mingw_aligned_malloc((size), (alignment))
6164
6265 static const int alignment = 16;
6366
67 LIBDE265_API void* de265_alloc_image_plane(struct de265_image* img, int cIdx,
68 void* inputdata, int inputstride, void *userdata)
69 {
70 int alignment = STANDARD_ALIGNMENT;
71 int stride = (img->get_width(cIdx) + alignment-1) / alignment * alignment;
72 int height = img->get_height(cIdx);
73
74 uint8_t* p = (uint8_t *)ALLOC_ALIGNED_16(stride * height + MEMORY_PADDING);
75
76 if (p==NULL) { return NULL; }
77
78 img->set_image_plane(cIdx, p, stride, userdata);
79
80 // copy input data if provided
81
82 if (inputdata != NULL) {
83 if (inputstride == stride) {
84 memcpy(p, inputdata, stride*height);
85 }
86 else {
87 for (int y=0;y<height;y++) {
88 memcpy(p+y*stride, ((char*)inputdata) + inputstride*y, inputstride);
89 }
90 }
91 }
92
93 return p;
94 }
95
96
97 LIBDE265_API void de265_free_image_plane(struct de265_image* img, int cIdx)
98 {
99 uint8_t* p = (uint8_t*)img->get_image_plane(cIdx);
100 assert(p);
101 FREE_ALIGNED(p);
102 }
103
64104
65105 static int de265_image_get_buffer(de265_decoder_context* ctx,
66106 de265_image_spec* spec, de265_image* img, void* userdata)
67107 {
68 int luma_stride = (spec->width + spec->alignment-1) / spec->alignment * spec->alignment;
69 int chroma_stride = (spec->width/2 + spec->alignment-1) / spec->alignment * spec->alignment;
108 const int rawChromaWidth = spec->width / img->sps.SubWidthC;
109 const int rawChromaHeight = spec->height / img->sps.SubHeightC;
110
111 int luma_stride = (spec->width + spec->alignment-1) / spec->alignment * spec->alignment;
112 int chroma_stride = (rawChromaWidth + spec->alignment-1) / spec->alignment * spec->alignment;
113
114 assert(img->sps.BitDepth_Y >= 8 && img->sps.BitDepth_Y <= 16);
115 assert(img->sps.BitDepth_C >= 8 && img->sps.BitDepth_C <= 16);
116
117 int luma_bpl = luma_stride * ((img->sps.BitDepth_Y+7)/8);
118 int chroma_bpl = chroma_stride * ((img->sps.BitDepth_C+7)/8);
70119
71120 int luma_height = spec->height;
72 int chroma_height = (spec->height+1)/2;
121 int chroma_height = rawChromaHeight;
122
123 bool alloc_failed = false;
73124
74125 uint8_t* p[3] = { 0,0,0 };
75 p[0] = (uint8_t *)ALLOC_ALIGNED_16(luma_stride * luma_height + MEMORY_PADDING);
76 p[1] = (uint8_t *)ALLOC_ALIGNED_16(chroma_stride * chroma_height + MEMORY_PADDING);
77 p[2] = (uint8_t *)ALLOC_ALIGNED_16(chroma_stride * chroma_height + MEMORY_PADDING);
78
79 if (p[0]==NULL || p[1]==NULL || p[2]==NULL) {
126 p[0] = (uint8_t *)ALLOC_ALIGNED_16(luma_height * luma_bpl + MEMORY_PADDING);
127 if (p[0]==NULL) { alloc_failed=true; }
128
129 if (img->get_chroma_format() != de265_chroma_mono) {
130 p[1] = (uint8_t *)ALLOC_ALIGNED_16(chroma_height * chroma_bpl + MEMORY_PADDING);
131 p[2] = (uint8_t *)ALLOC_ALIGNED_16(chroma_height * chroma_bpl + MEMORY_PADDING);
132
133 if (p[1]==NULL || p[2]==NULL) { alloc_failed=true; }
134 }
135 else {
136 p[1] = NULL;
137 p[2] = NULL;
138 chroma_stride = 0;
139 }
140
141 if (alloc_failed) {
80142 for (int i=0;i<3;i++)
81143 if (p[i]) {
82144 FREE_ALIGNED(p[i]);
97159 {
98160 for (int i=0;i<3;i++) {
99161 uint8_t* p = (uint8_t*)img->get_image_plane(i);
100 assert(p);
101 FREE_ALIGNED(p);
162 if (p) {
163 FREE_ALIGNED(p);
164 }
102165 }
103166 }
104167
127190 removed_at_picture_id = 0; // picture not used, so we can assume it has been removed
128191
129192 decctx = NULL;
193 encctx = NULL;
194
195 encoder_image_release_func = NULL;
130196
131197 //alloc_functions.get_buffer = NULL;
132198 //alloc_functions.release_buffer = NULL;
164230
165231 de265_error de265_image::alloc_image(int w,int h, enum de265_chroma c,
166232 const seq_parameter_set* sps, bool allocMetadata,
167 decoder_context* ctx, de265_PTS pts, void* user_data,
168 bool isOutputImage)
169 {
170 if (allocMetadata) { assert(sps); }
233 decoder_context* dctx,
234 encoder_context* ectx,
235 de265_PTS pts, void* user_data,
236 bool useCustomAllocFunc)
237 {
238 //if (allocMetadata) { assert(sps); }
239 assert(sps);
240
241 this->sps = *sps;
242
243 release(); /* TODO: review code for efficient allocation when arrays are already
244 allocated to the requested size. Without the release, the old image-data
245 will not be freed. */
171246
172247 ID = s_next_image_ID++;
173248 removed_at_picture_id = std::numeric_limits<int32_t>::max();
174249
175 decctx = ctx;
250 decctx = dctx;
251 encctx = ectx;
176252
177253 // --- allocate image buffer ---
178254
208284
209285 case de265_chroma_422:
210286 spec.format = de265_image_format_YUV422P8;
211 chroma_height = (chroma_height+1)/2;
287 chroma_width = (chroma_width+1)/2;
212288 break;
213289
290 case de265_chroma_444:
291 spec.format = de265_image_format_YUV444P8;
292 break;
293
294 case de265_chroma_mono:
295 spec.format = de265_image_format_mono8;
296 chroma_width = 0;
297 chroma_height= 0;
298 break;
299
214300 default:
215 assert(false); // TODO: not implemented yet
301 assert(false);
216302 break;
217303 }
218304
219305 spec.width = w;
220306 spec.height = h;
221 spec.alignment = 16;
307 spec.alignment = STANDARD_ALIGNMENT;
222308
223309
224310 // conformance window cropping
242328 spec.visible_height= height_confwin;
243329
244330
331 bpp_shift[0] = (sps->BitDepth_Y > 8) ? 1 : 0;
332 bpp_shift[1] = (sps->BitDepth_C > 8) ? 1 : 0;
333 bpp_shift[2] = bpp_shift[1];
334
335
245336 // allocate memory and set conformance window pointers
246337
247 void* alloc_userdata = decctx->param_image_allocation_userdata;
248 if (isOutputImage) {
338 void* alloc_userdata = NULL;
339 if (decctx) alloc_userdata = decctx->param_image_allocation_userdata;
340 if (encctx) alloc_userdata = encctx->param_image_allocation_userdata; // actually not needed
341
342 if (encctx && useCustomAllocFunc) {
343 encoder_image_release_func = encctx->release_func;
344
345 // if we do not provide a release function, use our own
346
347 if (encoder_image_release_func == NULL) {
348 image_allocation_functions = de265_image::default_image_allocation;
349 }
350 else {
351 image_allocation_functions.get_buffer = NULL;
352 image_allocation_functions.release_buffer = NULL;
353 }
354 }
355 else if (decctx && useCustomAllocFunc) {
249356 image_allocation_functions = decctx->param_image_allocation_functions;
250357 }
251358 else {
252359 image_allocation_functions = de265_image::default_image_allocation;
253360 }
254 bool mem_alloc_success = image_allocation_functions.get_buffer(decctx, &spec, this,
255 alloc_userdata);
256
257 pixels_confwin[0] = pixels[0] + left*WinUnitX + top*WinUnitY*stride;
258 pixels_confwin[1] = pixels[1] + left + top*chroma_stride;
259 pixels_confwin[2] = pixels[2] + left + top*chroma_stride;
260
261
262 // check for memory shortage
263
264 if (!mem_alloc_success)
265 {
266 return DE265_ERROR_OUT_OF_MEMORY;
267 }
361
362 bool mem_alloc_success = true;
363
364 if (image_allocation_functions.get_buffer != NULL) {
365 mem_alloc_success = image_allocation_functions.get_buffer(decctx, &spec, this,
366 alloc_userdata);
367
368 pixels_confwin[0] = pixels[0] + left*WinUnitX + top*WinUnitY*stride;
369 pixels_confwin[1] = pixels[1] + left + top*chroma_stride;
370 pixels_confwin[2] = pixels[2] + left + top*chroma_stride;
371
372
373 // check for memory shortage
374
375 if (!mem_alloc_success)
376 {
377 return DE265_ERROR_OUT_OF_MEMORY;
378 }
379 }
268380
269381 //alloc_functions = *allocfunc;
270382 //alloc_userdata = userdata;
276388
277389 mem_alloc_success &= intraPredMode.alloc(sps->PicWidthInMinPUs, sps->PicHeightInMinPUs,
278390 sps->Log2MinPUSize);
391
392 mem_alloc_success &= intraPredModeC.alloc(sps->PicWidthInMinPUs, sps->PicHeightInMinPUs,
393 sps->Log2MinPUSize);
279394
280395 // cb info
281396
348463
349464 if (pixels[0])
350465 {
351 image_allocation_functions.release_buffer(decctx, this,
352 decctx ? decctx->param_image_allocation_userdata : NULL);
353
466 if (encoder_image_release_func != NULL) {
467 encoder_image_release_func(encctx, this,
468 encctx->param_image_allocation_userdata);
469 }
470 else {
471 image_allocation_functions.release_buffer(decctx, this,
472 decctx ?
473 decctx->param_image_allocation_userdata :
474 NULL);
475 }
476
354477 for (int i=0;i<3;i++)
355478 {
356479 pixels[i] = NULL;
392515 */
393516
394517 de265_error err = alloc_image(src->width, src->height, src->chroma_format, &src->sps, false,
395 src->decctx, src->pts, src->user_data, false);
518 src->decctx, src->encctx, src->pts, src->user_data, false);
396519 if (err != DE265_OK) {
397520 return err;
398521 }
411534 assert(first % 2 == 0);
412535 assert(end % 2 == 0);
413536
537 int luma_bpp = (sps.BitDepth_Y+7)/8;
538 int chroma_bpp = (sps.BitDepth_C+7)/8;
539
414540 if (src->stride == stride) {
415 memcpy(pixels[0] + first*stride,
416 src->pixels[0] + first*src->stride,
417 (end-first)*stride);
541 memcpy(pixels[0] + first*stride * luma_bpp,
542 src->pixels[0] + first*src->stride * luma_bpp,
543 (end-first)*stride * luma_bpp);
418544 }
419545 else {
420546 for (int yp=first;yp<end;yp++) {
421 memcpy(pixels[0]+yp*stride, src->pixels[0]+yp*src->stride, src->width);
422 }
423 }
424
425 int first_chroma = first>>1;
426 int end_chroma = end>>1;
547 memcpy(pixels[0]+yp*stride * luma_bpp,
548 src->pixels[0]+yp*src->stride * luma_bpp,
549 src->width * luma_bpp);
550 }
551 }
552
553 int first_chroma = first / src->sps.SubHeightC;
554 int end_chroma = end / src->sps.SubHeightC;
427555
428556 if (src->chroma_format != de265_chroma_mono) {
429557 if (src->chroma_stride == chroma_stride) {
430 memcpy(pixels[1] + first_chroma*chroma_stride,
431 src->pixels[1] + first_chroma*chroma_stride,
432 (end_chroma-first_chroma) * chroma_stride);
433 memcpy(pixels[2] + first_chroma*chroma_stride,
434 src->pixels[2] + first_chroma*chroma_stride,
435 (end_chroma-first_chroma) * chroma_stride);
558 memcpy(pixels[1] + first_chroma*chroma_stride * chroma_bpp,
559 src->pixels[1] + first_chroma*chroma_stride * chroma_bpp,
560 (end_chroma-first_chroma) * chroma_stride * chroma_bpp);
561 memcpy(pixels[2] + first_chroma*chroma_stride * chroma_bpp,
562 src->pixels[2] + first_chroma*chroma_stride * chroma_bpp,
563 (end_chroma-first_chroma) * chroma_stride * chroma_bpp);
436564 }
437565 else {
438566 for (int y=first_chroma;y<end_chroma;y++) {
439 memcpy(pixels[1]+y*chroma_stride, src->pixels[1]+y*src->chroma_stride, src->chroma_width);
440 memcpy(pixels[2]+y*chroma_stride, src->pixels[2]+y*src->chroma_stride, src->chroma_width);
567 memcpy(pixels[1]+y*chroma_stride * chroma_bpp,
568 src->pixels[1]+y*src->chroma_stride * chroma_bpp,
569 src->chroma_width * chroma_bpp);
570 memcpy(pixels[2]+y*chroma_stride * chroma_bpp,
571 src->pixels[2]+y*src->chroma_stride * chroma_bpp,
572 src->chroma_width * chroma_bpp);
441573 }
442574 }
443575 }
462594 {
463595 de265_mutex_lock(&mutex);
464596
597 //printf("nThreads before: %d %d\n",nThreadsQueued, nThreadsTotal);
598
465599 nThreadsQueued += nThreads;
466600 nThreadsTotal += nThreads;
467601
602 //printf("nThreads after: %d %d\n",nThreadsQueued, nThreadsTotal);
603
468604 de265_mutex_unlock(&mutex);
469605 }
470606
471 void de265_image::thread_run()
472 {
607 void de265_image::thread_run(const thread_task* task)
608 {
609 //printf("run thread %s\n", task->name().c_str());
610
473611 de265_mutex_lock(&mutex);
474612 nThreadsQueued--;
475613 nThreadsRunning++;
492630 de265_mutex_unlock(&mutex);
493631 }
494632
495 void de265_image::thread_finishes()
496 {
633 void de265_image::thread_finishes(const thread_task* task)
634 {
635 //printf("finish thread %s\n", task->name().c_str());
636
497637 de265_mutex_lock(&mutex);
498638
499639 nThreadsRunning--;
516656
517657 void de265_image::wait_for_progress(thread_task* task, int ctbAddrRS, int progress)
518658 {
659 if (task==NULL) { return; }
660
519661 de265_progress_lock* progresslock = &ctb_progress[ctbAddrRS];
520662 if (progresslock->get_progress() < progress) {
521663 thread_blocks();
557699 // during decoding (especially log2CbSize), but it is unlikely to be faster than the memset.
558700
559701 cb_info.clear();
560 tu_info.clear();
702 //tu_info.clear(); // done on the fly
561703 ctb_info.clear();
562704 deblk_info.clear();
563705
569711 }
570712
571713
572 void de265_image::set_mv_info(int x,int y, int nPbW,int nPbH, const PredVectorInfo* mv)
714 void de265_image::set_mv_info(int x,int y, int nPbW,int nPbH, const MotionVectorSpec& mv)
573715 {
574716 int log2PuSize = 2;
575717
583725 for (int pby=0;pby<hPu;pby++)
584726 for (int pbx=0;pbx<wPu;pbx++)
585727 {
586 pb_info[ xPu+pbx + (yPu+pby)*stride ].mvi = *mv;
728 pb_info[ xPu+pbx + (yPu+pby)*stride ].mv = mv;
587729 }
588730 }
589731
634776 availableN = available_zscan(xP,yP,xN,yN);
635777 }
636778 else {
637 availableN = !(nPbW<<1 == nCbS && nPbH<<1 == nCbS &&
779 availableN = !(nPbW<<1 == nCbS && nPbH<<1 == nCbS && // NxN
638780 partIdx==1 &&
639 yN >= yC+nPbH && xN < xC+nPbW);
781 yN >= yC+nPbH && xN < xC+nPbW); // xN/yN inside partIdx 2
640782 }
641783
642784 if (availableN && get_pred_mode(xN,yN) == MODE_INTRA) {
645787
646788 return availableN;
647789 }
648
3232 #include <stdbool.h>
3333 #endif
3434 #include "libde265/de265.h"
35 #include "libde265/en265.h"
3536 #include "libde265/sps.h"
3637 #include "libde265/pps.h"
3738 #include "libde265/motion.h"
3839 #include "libde265/threads.h"
3940 #include "libde265/slice.h"
4041 #include "libde265/nal.h"
41
4242
4343 enum PictureState {
4444 UnusedForReference,
7777 #define CTB_PROGRESS_DEBLK_H 3
7878 #define CTB_PROGRESS_SAO 4
7979
80 class decoder_context;
81
8082 template <class DataUnit> class MetaDataArray
8183 {
8284 public:
8385 MetaDataArray() { data=NULL; data_size=0; log2unitSize=0; width_in_units=0; height_in_units=0; }
8486 ~MetaDataArray() { free(data); }
8587
86 bool alloc(int w,int h, int _log2unitSize) {
88 LIBDE265_CHECK_RESULT bool alloc(int w,int h, int _log2unitSize) {
8789 int size = w*h;
8890
8991 if (size != data_size) {
9092 free(data);
9193 data = (DataUnit*)malloc(size * sizeof(DataUnit));
94 if (data == NULL) {
95 data_size = 0;
96 return false;
97 }
9298 data_size = size;
93 width_in_units = w;
94 height_in_units = h;
9599 }
100
101 width_in_units = w;
102 height_in_units = h;
96103
97104 log2unitSize = _log2unitSize;
98105
107114 int unitX = x>>log2unitSize;
108115 int unitY = y>>log2unitSize;
109116
117 assert(unitX >= 0 && unitX < width_in_units);
118 assert(unitY >= 0 && unitY < height_in_units);
119
110120 return data[ unitX + unitY*width_in_units ];
111121 }
112122
114124 int unitX = x>>log2unitSize;
115125 int unitY = y>>log2unitSize;
116126
127 assert(unitX >= 0 && unitX < width_in_units);
128 assert(unitY >= 0 && unitY < height_in_units);
129
117130 return data[ unitX + unitY*width_in_units ];
118131 }
119132
121134 int unitX = x>>log2unitSize;
122135 int unitY = y>>log2unitSize;
123136
137 assert(unitX >= 0 && unitX < width_in_units);
138 assert(unitY >= 0 && unitY < height_in_units);
139
124140 data[ unitX + unitY*width_in_units ] = d;
125141 }
126142
127143 DataUnit& operator[](int idx) { return data[idx]; }
128144 const DataUnit& operator[](int idx) const { return data[idx]; }
145
146 int size() const { return data_size; }
129147
130148 // private:
131149 DataUnit* data;
145163 cb_info[ cbx + cby*cb_info.width_in_units ].Field = value; \
146164 }
147165
166 #define CLEAR_TB_BLK(x,y,log2BlkWidth) \
167 int tuX = x >> tu_info.log2unitSize; \
168 int tuY = y >> tu_info.log2unitSize; \
169 int width = 1 << (log2BlkWidth - tu_info.log2unitSize); \
170 for (int tuy=tuY;tuy<tuY+width;tuy++) \
171 for (int tux=tuX;tux<tuX+width;tux++) \
172 { \
173 tu_info[ tux + tuy*tu_info.width_in_units ] = 0; \
174 }
175
148176
149177 typedef struct {
150178 uint16_t SliceAddrRS;
152180
153181 sao_info saoInfo;
154182 bool deblock; // this CTB has to be deblocked
155 bool has_pcm; // pcm is used in this CTB
156 bool has_cu_transquant_bypass; // transquant_bypass is used in this CTB
183
184 // The following flag helps to quickly check whether we have to
185 // check all conditions in the SAO filter or whether we can skip them.
186 bool has_pcm_or_cu_transquant_bypass; // pcm or transquant_bypass is used in this CTB
157187 } CTB_info;
158188
159189
160190 typedef struct {
161 uint8_t log2CbSize : 3; // [0;6] (1<<log2CbSize) = 64
191 uint8_t log2CbSize : 3; /* [0;6] (1<<log2CbSize) = 64
192 This is only set in the top-left corner of the CB.
193 The other values should be zero.
194 TODO: in the encoder, we have to clear to zero.
195 Used in deblocking and QP-scale decoding */
162196 uint8_t PartMode : 3; // (enum PartMode) [0;7] set only in top-left of CB
163 // TODO: could be removed if prediction-block-boundaries would be
164 // set during decoding
165 uint8_t ctDepth : 2; // [0:3]? (0:64, 1:32, 2:16, 3:8)
197 // Used for spatial merging candidates in current frame
198 // and for deriving interSplitFlag in decoding.
199
200 uint8_t ctDepth : 2; // [0:3]? (for CTB size 64: 0:64, 1:32, 2:16, 3:8)
201 // Used for decoding/encoding split_cu flag.
202
203 // --- byte boundary ---
166204 uint8_t PredMode : 2; // (enum PredMode) [0;2] must be saved for past images
167 uint8_t pcm_flag : 1; //
168 uint8_t cu_transquant_bypass : 1;
169
170 int8_t QP_Y;
171
172 // uint8_t pcm_flag; // TODO
205 // Used in motion decoding.
206 uint8_t pcm_flag : 1; // Stored for intra-prediction / SAO
207 uint8_t cu_transquant_bypass : 1; // Stored for SAO
208 // note: 4 bits left
209
210 // --- byte boundary ---
211 int8_t QP_Y; // Stored for QP prediction
212
173213 } CB_ref_info;
174214
175215
176216 typedef struct {
177 PredVectorInfo mvi; // TODO: this can be done in 16x16 grid
217 MotionVectorSpec mv; // TODO: this can be done in 16x16 grid
178218 } PB_ref_info;
219
220 // intraPredMode: Used for determining scanIdx when decoding/encoding coefficients.
179221
180222
181223
184226 ~de265_image();
185227
186228
187 de265_error alloc_image(int w,int h, enum de265_chroma c, const seq_parameter_set* sps,
188 bool allocMetadata, decoder_context* ctx, de265_PTS pts, void* user_data,
189 bool isOutputImage);
229 de265_error alloc_image(int w,int h, enum de265_chroma c,
230 const seq_parameter_set* sps,
231 bool allocMetadata,
232 decoder_context* dctx,
233 class encoder_context* ectx,
234 de265_PTS pts, void* user_data,
235 bool useCustomAllocFunctions);
236
237 //de265_error alloc_encoder_data(const seq_parameter_set* sps);
190238
191239 bool is_allocated() const { return pixels[0] != NULL; }
192240
211259 return pixels[cIdx] + xpos + ypos*stride;
212260 }
213261
262
263 /// xpos;ypos in actual plane resolution
264 template <class pixel_t>
265 pixel_t* get_image_plane_at_pos_NEW(int cIdx, int xpos,int ypos)
266 {
267 int stride = get_image_stride(cIdx);
268 return (pixel_t*)(pixels[cIdx] + (xpos + ypos*stride)*sizeof(pixel_t));
269 }
270
214271 const uint8_t* get_image_plane_at_pos(int cIdx, int xpos,int ypos) const
215272 {
216273 int stride = get_image_stride(cIdx);
217274 return pixels[cIdx] + xpos + ypos*stride;
218275 }
219276
277 void* get_image_plane_at_pos_any_depth(int cIdx, int xpos,int ypos)
278 {
279 int stride = get_image_stride(cIdx);
280 return pixels[cIdx] + ((xpos + ypos*stride) << bpp_shift[cIdx]);
281 }
282
283 const void* get_image_plane_at_pos_any_depth(int cIdx, int xpos,int ypos) const
284 {
285 int stride = get_image_stride(cIdx);
286 return pixels[cIdx] + ((xpos + ypos*stride) << bpp_shift[cIdx]);
287 }
288
289 /* Number of pixels in one row (not number of bytes).
290 */
220291 int get_image_stride(int cIdx) const
221292 {
222293 if (cIdx==0) return stride;
231302
232303 enum de265_chroma get_chroma_format() const { return chroma_format; }
233304
305 int get_bit_depth(int cIdx) const {
306 if (cIdx==0) return sps.BitDepth_Y;
307 else return sps.BitDepth_C;
308 }
309
310 int get_bytes_per_pixel(int cIdx) const {
311 return (get_bit_depth(cIdx)+7)/8;
312 }
313
314 bool high_bit_depth(int cIdx) const {
315 return get_bit_depth(cIdx)>8;
316 }
234317
235318 bool can_be_released() const { return PicOutputFlag==false && PicState==UnusedForReference; }
236319
250333
251334 static de265_image_allocation default_image_allocation;
252335
336 void printBlk(const char* title, int x0,int y0,int blkSize,int cIdx) const {
337 ::printBlk(title, get_image_plane_at_pos(cIdx,x0,y0),
338 blkSize, get_image_stride(cIdx));
339 }
340
253341 private:
254342 uint32_t ID;
255343 static uint32_t s_next_image_ID;
256344
257345 uint8_t* pixels[3];
346 uint8_t bpp_shift[3]; // 0 for 8 bit, 1 for 16 bit
258347
259348 enum de265_chroma chroma_format;
260349
290379 seq_parameter_set sps; // the SPS used for decoding this image
291380 pic_parameter_set pps; // the PPS used for decoding this image
292381 decoder_context* decctx;
382 class encoder_context* encctx;
383
384 int number_of_ctbs() const { return ctb_info.size(); }
293385
294386 private:
295387 MetaDataArray<CTB_info> ctb_info;
296388 MetaDataArray<CB_ref_info> cb_info;
297389 MetaDataArray<PB_ref_info> pb_info;
298390 MetaDataArray<uint8_t> intraPredMode;
391 MetaDataArray<uint8_t> intraPredModeC;
299392 MetaDataArray<uint8_t> tu_info;
300393 MetaDataArray<uint8_t> deblk_info;
301394
306399 void* user_data;
307400 void* plane_user_data[3]; // this is logically attached to the pixel data pointers
308401 de265_image_allocation image_allocation_functions; // the functions used for memory allocation
402 void (*encoder_image_release_func)(en265_encoder_context*,
403 de265_image*,
404 void* userdata);
309405
310406 uint8_t integrity; /* Whether an error occured while the image was decoded.
311407 When generated, this is initialized to INTEGRITY_CORRECT,
327423
328424
329425 void thread_start(int nThreads);
330 void thread_run();
426 void thread_run(const thread_task*);
331427 void thread_blocks();
332428 void thread_unblocks();
333 void thread_finishes(); /* NOTE: you should not access any data in the thread_task after
334 calling this, as this function may unlock other threads that
335 will push this image to the output queue and free all decoder data. */
429 /* NOTE: you should not access any data in the thread_task after
430 calling this, as this function may unlock other threads that
431 will push this image to the output queue and free all decoder data. */
432 void thread_finishes(const thread_task*);
336433
337434 void wait_for_progress(thread_task* task, int ctbx,int ctby, int progress);
338435 void wait_for_progress(thread_task* task, int ctbAddrRS, int progress);
383480 return get_pred_mode(x,y)==MODE_SKIP;
384481 }
385482
386 void set_pcm_flag(int x,int y, int log2BlkWidth)
387 {
388 SET_CB_BLK(x,y,log2BlkWidth, pcm_flag, 1);
389 ctb_info.get(x,y).has_pcm = true;
483 void set_pcm_flag(int x,int y, int log2BlkWidth, uint8_t value=1)
484 {
485 SET_CB_BLK(x,y,log2BlkWidth, pcm_flag, value);
486
487 // TODO: in the encoder, we somewhere have to clear this
488 ctb_info.get(x,y).has_pcm_or_cu_transquant_bypass = true;
390489 }
391490
392491 int get_pcm_flag(int x,int y) const
394493 return cb_info.get(x,y).pcm_flag;
395494 }
396495
397 void set_cu_transquant_bypass(int x,int y, int log2BlkWidth)
398 {
399 SET_CB_BLK(x,y,log2BlkWidth, cu_transquant_bypass, 1);
400 ctb_info.get(x,y).has_cu_transquant_bypass = true;
496 void set_cu_transquant_bypass(int x,int y, int log2BlkWidth, uint8_t value=1)
497 {
498 SET_CB_BLK(x,y,log2BlkWidth, cu_transquant_bypass, value);
499
500 // TODO: in the encoder, we somewhere have to clear this
501 ctb_info.get(x,y).has_pcm_or_cu_transquant_bypass = true;
401502 }
402503
403504 int get_cu_transquant_bypass(int x,int y) const
405506 return cb_info.get(x,y).cu_transquant_bypass;
406507 }
407508
408 void set_log2CbSize(int x0, int y0, int log2CbSize)
409 {
509 void set_log2CbSize(int x0, int y0, int log2CbSize, bool fill)
510 {
511 // In theory, we could assume that remaining cb_info blocks are initialized to zero.
512 // But in corrupted streams, slices may overlap and set contradicting log2CbSizes.
513 // We also need this for encoding.
514 if (fill) {
515 SET_CB_BLK(x0,y0,log2CbSize, log2CbSize, 0);
516 }
517
410518 cb_info.get(x0,y0).log2CbSize = log2CbSize;
411
412 // assume that remaining cb_info blocks are initialized to zero
413519 }
414520
415521 int get_log2CbSize(int x0, int y0) const
458564 void set_split_transform_flag(int x0,int y0,int trafoDepth)
459565 {
460566 tu_info.get(x0,y0) |= (1<<trafoDepth);
567 }
568
569 void clear_split_transform_flags(int x0,int y0,int log2CbSize)
570 {
571 CLEAR_TB_BLK (x0,y0, log2CbSize);
461572 }
462573
463574 int get_split_transform_flag(int x0,int y0,int trafoDepth) const
499610 void set_IntraPredMode(int PUidx,int log2blkSize, enum IntraPredMode mode)
500611 {
501612 int pbSize = 1<<(log2blkSize - intraPredMode.log2unitSize);
502
613
503614 for (int y=0;y<pbSize;y++)
504615 for (int x=0;x<pbSize;x++)
505616 intraPredMode[PUidx + x + y*intraPredMode.width_in_units] = mode;
506617 }
507618
619 void set_IntraPredMode(int x0,int y0,int log2blkSize,
620 enum IntraPredMode mode)
621 {
622 int pbSize = 1<<(log2blkSize - intraPredMode.log2unitSize);
623 int PUidx = (x0>>sps.Log2MinPUSize) + (y0>>sps.Log2MinPUSize)*sps.PicWidthInMinPUs;
624
625 for (int y=0;y<pbSize;y++)
626 for (int x=0;x<pbSize;x++) {
627 assert(x<sps.PicWidthInMinPUs);
628 assert(y<sps.PicHeightInMinPUs);
629
630 int idx = PUidx + x + y*intraPredMode.width_in_units;
631 assert(idx<intraPredMode.data_size);
632 intraPredMode[idx] = mode;
633 }
634 }
635
636
637 enum IntraPredMode get_IntraPredModeC(int x,int y) const
638 {
639 return (enum IntraPredMode)(intraPredModeC.get(x,y) & 0x3f);
640 }
641
642 bool is_IntraPredModeC_Mode4(int x,int y) const
643 {
644 return intraPredModeC.get(x,y) & 0x80;
645 }
646
647 void set_IntraPredModeC(int x0,int y0,int log2blkSize, enum IntraPredMode mode,
648 bool is_mode4)
649 {
650 uint8_t combinedValue = mode;
651 if (is_mode4) combinedValue |= 0x80;
652
653 int pbSize = 1<<(log2blkSize - intraPredMode.log2unitSize);
654 int PUidx = (x0>>sps.Log2MinPUSize) + (y0>>sps.Log2MinPUSize)*sps.PicWidthInMinPUs;
655
656 for (int y=0;y<pbSize;y++)
657 for (int x=0;x<pbSize;x++) {
658 assert(x<sps.PicWidthInMinPUs);
659 assert(y<sps.PicHeightInMinPUs);
660
661 int idx = PUidx + x + y*intraPredModeC.width_in_units;
662 assert(idx<intraPredModeC.data_size);
663 intraPredModeC[idx] = combinedValue;
664 }
665 }
666
667
668 /*
669 // NOTE: encoder only
670 void set_ChromaIntraPredMode(int x,int y,int log2BlkWidth, enum IntraChromaPredMode mode)
671 {
672 SET_CB_BLK (x, y, log2BlkWidth, intra_chroma_pred_mode, mode);
673 }
674
675 // NOTE: encoder only
676 enum IntraChromaPredMode get_ChromaIntraPredMode(int x,int y) const
677 {
678 return (enum IntraChromaPredMode)(cb_info.get(x,y).intra_chroma_pred_mode);
679 }
680 */
508681
509682 // --- CTB metadata access ---
510683
546719 return ctb_info[ctb].SliceHeaderIndex;
547720 }
548721
722 bool is_SliceHeader_available(int x,int y) const
723 {
724 int idx = ctb_info.get(x,y).SliceHeaderIndex;
725 return idx >= 0 && idx < slices.size();
726 }
727
549728 slice_segment_header* get_SliceHeader(int x, int y)
550729 {
551 return slices[ get_SliceHeaderIndex(x,y) ];
730 int idx = get_SliceHeaderIndex(x,y);
731 if (idx >= slices.size()) { return NULL; }
732 return slices[idx];
552733 }
553734
554735 slice_segment_header* get_SliceHeaderCtb(int ctbX, int ctbY)
555736 {
556 return slices[ get_SliceHeaderIndexCtb(ctbX,ctbY) ];
737 int idx = get_SliceHeaderIndexCtb(ctbX,ctbY);
738 if (idx >= slices.size()) { return NULL; }
739 return slices[idx];
557740 }
558741
559742 const slice_segment_header* get_SliceHeaderCtb(int ctbX, int ctbY) const
560743 {
561 return slices[ get_SliceHeaderIndexCtb(ctbX,ctbY) ];
562 }
563
744 int idx = get_SliceHeaderIndexCtb(ctbX,ctbY);
745 if (idx >= slices.size()) { return NULL; }
746 return slices[idx];
747 }
748
564749 void set_sao_info(int ctbX,int ctbY,const sao_info* saoinfo)
565750 {
566751 sao_info* sao = &ctb_info[ctbX + ctbY*ctb_info.width_in_units].saoInfo;
567
752
568753 memcpy(sao,
569754 saoinfo,
570755 sizeof(sao_info));
571756 }
572
757
573758 const sao_info* get_sao_info(int ctbX,int ctbY) const
574759 {
575760 return &ctb_info[ctbX + ctbY*ctb_info.width_in_units].saoInfo;
588773 }
589774
590775
591 bool get_CTB_has_pcm(int ctbX,int ctbY) const
776 bool get_CTB_has_pcm_or_cu_transquant_bypass(int ctbX,int ctbY) const
592777 {
593778 int idx = ctbX + ctbY*ctb_info.width_in_units;
594 return ctb_info[idx].has_pcm;
595 }
596
597 bool get_CTB_has_cu_transquant_bypass(int ctbX,int ctbY) const
598 {
599 int idx = ctbX + ctbY*ctb_info.width_in_units;
600 return ctb_info[idx].has_cu_transquant_bypass;
779 return ctb_info[idx].has_pcm_or_cu_transquant_bypass;
601780 }
602781
603782
611790 {
612791 const int xd = x0/4;
613792 const int yd = y0/4;
614
793
615794 if (xd<deblk_info.width_in_units &&
616795 yd<deblk_info.height_in_units) {
617796 deblk_info[xd + yd*deblk_info.width_in_units] |= flags;
641820
642821 // --- PB metadata access ---
643822
644 const PredVectorInfo* get_mv_info(int x,int y) const
645 {
646 return &pb_info.get(x,y).mvi;
647 }
648
649 void set_mv_info(int x,int y, int nPbW,int nPbH, const PredVectorInfo* mv);
650
651 // --- value logging ---
652
823 const MotionVectorSpec* get_mv_info(int x,int y) const
824 {
825 return &pb_info.get(x,y).mv;
826 }
827
828 void set_mv_info(int x,int y, int nPbW,int nPbH, const MotionVectorSpec& mv);
829
830 // --- value logging ---
831
832 void printBlk(int x0,int y0, int cIdx, int log2BlkSize);
653833 };
654834
655835
2828
2929
3030 #ifdef DE265_LOG_TRACE
31 void print_border(uint8_t* data, uint8_t* available, int nT)
31 template <class pixel_t>
32 void print_border(pixel_t* data, uint8_t* available, int nT)
3233 {
3334 for (int i=-2*nT ; i<=2*nT ; i++) {
3435 if (i==0 || i==1 || i==-nT || i==nT+1) {
5051 #endif
5152
5253
54 void fillIntraPredModeCandidates(int candModeList[3], int x,int y, int PUidx,
55 bool availableA, // left
56 bool availableB, // top
57 const de265_image* img)
58 {
59 const seq_parameter_set* sps = &img->sps;
60
61 // block on left side
62
63 enum IntraPredMode candIntraPredModeA, candIntraPredModeB;
64 if (availableA==false) {
65 candIntraPredModeA=INTRA_DC;
66 }
67 else if (img->get_pred_mode(x-1,y) != MODE_INTRA ||
68 img->get_pcm_flag (x-1,y)) {
69 candIntraPredModeA=INTRA_DC;
70 }
71 else {
72 candIntraPredModeA = img->get_IntraPredMode_atIndex(PUidx-1);
73 }
74
75 // block above
76
77 if (availableB==false) {
78 candIntraPredModeB=INTRA_DC;
79 }
80 else if (img->get_pred_mode(x,y-1) != MODE_INTRA ||
81 img->get_pcm_flag (x,y-1)) {
82 candIntraPredModeB=INTRA_DC;
83 }
84 else if (y-1 < ((y >> sps->Log2CtbSizeY) << sps->Log2CtbSizeY)) {
85 candIntraPredModeB=INTRA_DC;
86 }
87 else {
88 candIntraPredModeB = img->get_IntraPredMode_atIndex(PUidx-sps->PicWidthInMinPUs);
89 }
90
91
92 // build candidate list
93
94 logtrace(LogSlice,"%d;%d availableA:%d candA:%d & availableB:%d candB:%d\n", x,y,
95 availableA, candIntraPredModeA,
96 availableB, candIntraPredModeB);
97
98 if (candIntraPredModeA == candIntraPredModeB) {
99 if (candIntraPredModeA < 2) {
100 candModeList[0] = INTRA_PLANAR;
101 candModeList[1] = INTRA_DC;
102 candModeList[2] = INTRA_ANGULAR_26;
103 }
104 else {
105 candModeList[0] = candIntraPredModeA;
106 candModeList[1] = 2 + ((candIntraPredModeA-2 -1 +32) % 32);
107 candModeList[2] = 2 + ((candIntraPredModeA-2 +1 ) % 32);
108 }
109 }
110 else {
111 candModeList[0] = candIntraPredModeA;
112 candModeList[1] = candIntraPredModeB;
113
114 if (candIntraPredModeA != INTRA_PLANAR &&
115 candIntraPredModeB != INTRA_PLANAR) {
116 candModeList[2] = INTRA_PLANAR;
117 }
118 else if (candIntraPredModeA != INTRA_DC &&
119 candIntraPredModeB != INTRA_DC) {
120 candModeList[2] = INTRA_DC;
121 }
122 else {
123 candModeList[2] = INTRA_ANGULAR_26;
124 }
125 }
126
127 /*
128 printf("candModeList: %d %d %d\n",
129 candModeList[0],
130 candModeList[1],
131 candModeList[2]
132 );
133 */
134 }
135
136
137 int find_intra_pred_mode(enum IntraPredMode mode,
138 int candModeList[3])
139 {
140 // check whether the mode is in the candidate list
141
142 for (int i=0;i<3;i++) {
143 if (candModeList[i] == mode) {
144 return i;
145 }
146 }
147
148 // sort candModeList
149
150 if (candModeList[0] > candModeList[1]) {
151 std::swap(candModeList[0],candModeList[1]);
152 }
153 if (candModeList[0] > candModeList[2]) {
154 std::swap(candModeList[0],candModeList[2]);
155 }
156 if (candModeList[1] > candModeList[2]) {
157 std::swap(candModeList[1],candModeList[2]);
158 }
159
160 // skip modes already in the candidate list
161
162 int intraMode = mode;
163
164 for (int i=2;i>=0;i--) {
165 if (intraMode >= candModeList[i]) { intraMode--; }
166 }
167
168 return -intraMode-1;
169 }
170
171
172 void list_chroma_pred_candidates(enum IntraPredMode chroma_mode[5],
173 enum IntraPredMode luma_mode)
174 {
175 enum IntraPredMode chroma_cand[5];
176 chroma_cand[0] = INTRA_PLANAR;
177 chroma_cand[1] = INTRA_ANGULAR_26;
178 chroma_cand[2] = INTRA_ANGULAR_10;
179 chroma_cand[3] = INTRA_DC;
180 chroma_cand[4] = luma_mode;
181
182 switch (luma_mode) {
183 case INTRA_PLANAR: chroma_cand[0] = INTRA_ANGULAR_34; break;
184 case INTRA_ANGULAR_26: chroma_cand[1] = INTRA_ANGULAR_34; break;
185 case INTRA_ANGULAR_10: chroma_cand[2] = INTRA_ANGULAR_34; break;
186 case INTRA_DC: chroma_cand[3] = INTRA_ANGULAR_34; break;
187 default:
188 // use defaults from above
189 break;
190 }
191 }
192
193
194 int get_intra_scan_idx(int log2TrafoSize, enum IntraPredMode intraPredMode, int cIdx,
195 const seq_parameter_set* sps)
196 {
197 if (log2TrafoSize==2 ||
198 (log2TrafoSize==3 && (cIdx==0 ||
199 sps->ChromaArrayType==CHROMA_444))) {
200 /**/ if (intraPredMode >= 6 && intraPredMode <= 14) return 2;
201 else if (intraPredMode >= 22 && intraPredMode <= 30) return 1;
202 else return 0;
203 }
204 else { return 0; }
205 }
206
207
208 int get_intra_scan_idx_luma(int log2TrafoSize, enum IntraPredMode intraPredMode)
209 {
210 if (log2TrafoSize==2 || log2TrafoSize==3) {
211 /**/ if (intraPredMode >= 6 && intraPredMode <= 14) return 2;
212 else if (intraPredMode >= 22 && intraPredMode <= 30) return 1;
213 else return 0;
214 }
215 else { return 0; }
216 }
217
218 int get_intra_scan_idx_chroma(int log2TrafoSize, enum IntraPredMode intraPredMode)
219 {
220 if (log2TrafoSize==1 || log2TrafoSize==2) {
221 /**/ if (intraPredMode >= 6 && intraPredMode <= 14) return 2;
222 else if (intraPredMode >= 22 && intraPredMode <= 30) return 1;
223 else return 0;
224 }
225 else { return 0; }
226 }
227
228
229 enum IntraPredMode lumaPredMode_to_chromaPredMode(enum IntraPredMode luma,
230 enum IntraChromaPredMode chroma)
231 {
232 switch (chroma) {
233 case INTRA_CHROMA_LIKE_LUMA:
234 return luma;
235
236 case INTRA_CHROMA_PLANAR_OR_34:
237 if (luma==INTRA_PLANAR) return INTRA_ANGULAR_34;
238 else return INTRA_PLANAR;
239
240 case INTRA_CHROMA_ANGULAR_26_OR_34:
241 if (luma==INTRA_ANGULAR_26) return INTRA_ANGULAR_34;
242 else return INTRA_ANGULAR_26;
243
244 case INTRA_CHROMA_ANGULAR_10_OR_34:
245 if (luma==INTRA_ANGULAR_10) return INTRA_ANGULAR_34;
246 else return INTRA_ANGULAR_10;
247
248 case INTRA_CHROMA_DC_OR_34:
249 if (luma==INTRA_DC) return INTRA_ANGULAR_34;
250 else return INTRA_DC;
251 }
252
253
254 assert(false);
255 return INTRA_DC;
256 }
257
258
53259 // (8.4.4.2.2)
54 void fill_border_samples(de265_image* img, int xB,int yB,
260 template <class pixel_t>
261 void fill_border_samples(de265_image* img,
262 int xB,int yB, // in component specific resolution
55263 int nT, int cIdx,
56 uint8_t* out_border)
264 pixel_t* out_border)
57265 {
58266 const seq_parameter_set* sps = &img->sps;
59267 const pic_parameter_set* pps = &img->pps;
61269 uint8_t available_data[2*64 + 1];
62270 uint8_t* available = &available_data[64];
63271
64 uint8_t* image;
272 pixel_t* image;
65273 int stride;
66 image = img->get_image_plane(cIdx);
274 image = (pixel_t*)img->get_image_plane(cIdx);
67275 stride = img->get_image_stride(cIdx);
68276
69 const int chromaShift = (cIdx==0) ? 0 : 1;
70 const int TUShift = (cIdx==0) ? sps->Log2MinTrafoSize : sps->Log2MinTrafoSize-1;
71
277 const int SubWidth = (cIdx==0) ? 1 : sps->SubWidthC;
278 const int SubHeight = (cIdx==0) ? 1 : sps->SubHeightC;
279
280 const int bit_depth = img->get_bit_depth(cIdx);
72281
73282 // --- check for CTB boundaries ---
74283
75 int xBLuma = (cIdx==0) ? xB : 2*xB;
76 int yBLuma = (cIdx==0) ? yB : 2*yB;
77 int nTLuma = (cIdx==0) ? nT : 2*nT;
284 int xBLuma = xB * SubWidth;
285 int yBLuma = yB * SubHeight;
78286
79287 int log2CtbSize = sps->Log2CtbSizeY;
80288 int picWidthInCtbs = sps->PicWidthInCtbsY;
84292 bool availableTopRight=true; // is CTB at top-right side available?
85293 bool availableTopLeft=true; // if CTB at top-left pixel available?
86294
295
296 //printf("xB/yB: %d %d\n",xB,yB);
87297
88298 // are we at left image border
89299
103313 yBLuma = 0; // fake value, available flags are already set to false
104314 }
105315
106 if (xBLuma+nTLuma >= sps->pic_width_in_luma_samples) {
316 if (xBLuma+nT*SubWidth >= sps->pic_width_in_luma_samples) {
107317 availableTopRight=false;
108318 }
109
319
110320 // check for tile and slice boundaries
111321
112322 int xCurrCtb = xBLuma >> log2CtbSize;
113323 int yCurrCtb = yBLuma >> log2CtbSize;
114324 int xLeftCtb = (xBLuma-1) >> log2CtbSize;
115 int xRightCtb = (xBLuma+nTLuma) >> log2CtbSize;
325 int xRightCtb = (xBLuma+nT*SubWidth) >> log2CtbSize;
116326 int yTopCtb = (yBLuma-1) >> log2CtbSize;
117327
118328 int currCTBSlice = img->get_SliceAddrRS(xCurrCtb,yCurrCtb);
121331 int toprightCTBSlice = availableTopRight ? img->get_SliceAddrRS(xRightCtb, yTopCtb) : -1;
122332 int topleftCTBSlice = availableTopLeft ? img->get_SliceAddrRS(xLeftCtb, yTopCtb) : -1;
123333
334 /*
335 printf("size: %d\n",pps->TileIdRS.size());
336 printf("curr: %d left: %d top: %d\n",
337 xCurrCtb+yCurrCtb*picWidthInCtbs,
338 availableLeft ? xLeftCtb+yCurrCtb*picWidthInCtbs : 9999,
339 availableTop ? xCurrCtb+yTopCtb*picWidthInCtbs : 9999);
340 */
124341 int currCTBTileID = pps->TileIdRS[xCurrCtb+yCurrCtb*picWidthInCtbs];
125342 int leftCTBTileID = availableLeft ? pps->TileIdRS[xLeftCtb+yCurrCtb*picWidthInCtbs] : -1;
126343 int topCTBTileID = availableTop ? pps->TileIdRS[xCurrCtb+yTopCtb*picWidthInCtbs] : -1;
138355
139356 // number of pixels that are in the valid image area to the right and to the bottom
140357
141 int nBottom = sps->pic_height_in_luma_samples - (cIdx==0 ? yB : 2*yB);
142 if (cIdx) nBottom=(nBottom+1)/2;
358 int nBottom = sps->pic_height_in_luma_samples - yB*SubHeight;
359 nBottom=(nBottom+SubHeight-1)/SubHeight;
143360 if (nBottom>2*nT) nBottom=2*nT;
144 int nRight = sps->pic_width_in_luma_samples - (cIdx==0 ? xB : 2*xB);
145 if (cIdx) nRight =(nRight +1)/2;
361
362 int nRight = sps->pic_width_in_luma_samples - xB*SubWidth;
363 nRight =(nRight +SubWidth-1)/SubWidth;
146364 if (nRight >2*nT) nRight=2*nT;
147365
148366 int nAvail=0;
149367
150 uint8_t firstValue;
368 pixel_t firstValue;
151369
152370 memset(available-2*nT, 0, 4*nT+1);
153371
157375 for (int y=nBottom-1 ; y>=0 ; y-=4)
158376 if (availableLeft)
159377 {
160 int NBlockAddr = pps->MinTbAddrZS[ ((xB-1)>>TUShift) +
161 ((yB+y)>>TUShift) * sps->PicWidthInTbsY ];
162
163 bool availableN = NBlockAddr < currBlockAddr;
378 int NBlockAddr = pps->MinTbAddrZS[ (((xB-1)*SubWidth )>>sps->Log2MinTrafoSize) +
379 (((yB+y)*SubHeight)>>sps->Log2MinTrafoSize)
380 * sps->PicWidthInTbsY ];
381
382 bool availableN = NBlockAddr <= currBlockAddr;
164383
165384 if (pps->constrained_intra_pred_flag) {
166 if (img->get_pred_mode((xB-1)<<chromaShift,(yB+y)<<chromaShift)!=MODE_INTRA)
385 if (img->get_pred_mode((xB-1)*SubWidth,(yB+y)*SubHeight)!=MODE_INTRA)
167386 availableN = false;
168387 }
169388
183402
184403 if (availableTopLeft)
185404 {
186 int NBlockAddr = pps->MinTbAddrZS[ ((xB-1)>>TUShift) +
187 ((yB-1)>>TUShift) * sps->PicWidthInTbsY ];
188
189 bool availableN = NBlockAddr < currBlockAddr;
405 int NBlockAddr = pps->MinTbAddrZS[ (((xB-1)*SubWidth )>>sps->Log2MinTrafoSize) +
406 (((yB-1)*SubHeight)>>sps->Log2MinTrafoSize)
407 * sps->PicWidthInTbsY ];
408
409 bool availableN = NBlockAddr <= currBlockAddr;
190410
191411 if (pps->constrained_intra_pred_flag) {
192 if (img->get_pred_mode((xB-1)<<chromaShift,(yB-1)<<chromaShift)!=MODE_INTRA) {
412 if (img->get_pred_mode((xB-1)*SubWidth,(yB-1)*SubHeight)!=MODE_INTRA) {
193413 availableN = false;
194414 }
195415 }
212432
213433 if (borderAvailable)
214434 {
215 int NBlockAddr = pps->MinTbAddrZS[ ((xB+x)>>TUShift) +
216 ((yB-1)>>TUShift) * sps->PicWidthInTbsY ];
217
218 bool availableN = NBlockAddr < currBlockAddr;
435 int NBlockAddr = pps->MinTbAddrZS[ (((xB+x)*SubWidth )>>sps->Log2MinTrafoSize) +
436 (((yB-1)*SubHeight)>>sps->Log2MinTrafoSize)
437 * sps->PicWidthInTbsY ];
438
439 bool availableN = NBlockAddr <= currBlockAddr;
219440
220441 if (pps->constrained_intra_pred_flag) {
221 if (img->get_pred_mode((xB+x)<<chromaShift,(yB-1)<<chromaShift)!=MODE_INTRA) {
442 if (img->get_pred_mode((xB+x)*SubWidth,(yB-1)*SubHeight)!=MODE_INTRA) {
222443 availableN = false;
223444 }
224445 }
242463
243464 if (nAvail!=4*nT+1) {
244465 if (nAvail==0) {
245 memset(out_border-2*nT, 1<<(sps->bit_depth_luma-1), 4*nT+1);
466 if (sizeof(pixel_t)==1) {
467 memset(out_border-2*nT, 1<<(bit_depth-1), 4*nT+1);
468 }
469 else {
470 for (int i = -2*nT; i <= 2*nT ; i++) {
471 out_border[i] = 1<<(bit_depth-1);
472 }
473 }
246474 }
247475 else {
248476 if (!available[-2*nT]) {
268496
269497
270498 // (8.4.4.2.3)
499 template <class pixel_t>
271500 void intra_prediction_sample_filtering(de265_image* img,
272 uint8_t* p,
273 int nT,
501 pixel_t* p,
502 int nT, int cIdx,
274503 enum IntraPredMode intraPredMode)
275504 {
276505 int filterFlag;
292521
293522 if (filterFlag) {
294523 int biIntFlag = (img->sps.strong_intra_smoothing_enable_flag &&
524 cIdx==0 &&
295525 nT==32 &&
296526 abs_value(p[0]+p[ 64]-2*p[ 32]) < (1<<(img->sps.bit_depth_luma-5)) &&
297527 abs_value(p[0]+p[-64]-2*p[-32]) < (1<<(img->sps.bit_depth_luma-5)))
298528 ? 1 : 0;
299529
300 uint8_t pF_mem[2*64+1];
301 uint8_t* pF = &pF_mem[64];
530 pixel_t pF_mem[2*64+1];
531 pixel_t* pF = &pF_mem[64];
302532
303533 if (biIntFlag) {
304534 pF[-2*nT] = p[-2*nT];
322552
323553 // copy back to original array
324554
325 memcpy(p-2*nT, pF-2*nT, 4*nT+1);
555 memcpy(p-2*nT, pF-2*nT, (4*nT+1) * sizeof(pixel_t));
326556 }
327557 else {
328558 // do nothing ?
344574 -315,-390,-482,-630,-910,-1638,-4096 };
345575
346576
347 // TODO: clip to read BitDepthY
348 LIBDE265_INLINE static int Clip1Y(int x) { if (x<0) return 0; else if (x>255) return 255; else return x; }
349
350
351577 // (8.4.4.2.6)
578 template <class pixel_t>
352579 void intra_prediction_angular(de265_image* img,
353580 int xB0,int yB0,
354581 enum IntraPredMode intraPredMode,
355582 int nT,int cIdx,
356 uint8_t* border)
357 {
358 uint8_t ref_mem[2*64+1];
359 uint8_t* ref=&ref_mem[64];
360
361 uint8_t* pred;
583 pixel_t* border)
584 {
585 pixel_t ref_mem[2*64+1];
586 pixel_t* ref=&ref_mem[64];
587
588 pixel_t* pred;
362589 int stride;
363 pred = img->get_image_plane_at_pos(cIdx,xB0,yB0);
590 pred = img->get_image_plane_at_pos_NEW<pixel_t>(cIdx,xB0,yB0);
364591 stride = img->get_image_stride(cIdx);
365592
593 int bit_depth = img->get_bit_depth(cIdx);
594
595 assert(intraPredMode<35);
596 assert(intraPredMode>=2);
597
366598 int intraPredAngle = intraPredAngle_table[intraPredMode];
599
600 bool disableIntraBoundaryFilter =
601 (img->sps.range_extension.implicit_rdpcm_enabled_flag &&
602 img->get_cu_transquant_bypass(xB0,yB0));
367603
368604 if (intraPredMode >= 18) {
369605
397633 }
398634 }
399635
400 if (intraPredMode==26 && cIdx==0 && nT<32) {
636 if (intraPredMode==26 && cIdx==0 && nT<32 && !disableIntraBoundaryFilter) {
401637 for (int y=0;y<nT;y++) {
402 pred[0+y*stride] = Clip1Y(border[1] + ((border[-1-y] - border[0])>>1));
638 pred[0+y*stride] = Clip_BitDepth(border[1] + ((border[-1-y] - border[0])>>1), bit_depth);
403639 }
404640 }
405641 }
435671 }
436672 }
437673
438 if (intraPredMode==10 && cIdx==0 && nT<32) { // DIFF 26->10
674 if (intraPredMode==10 && cIdx==0 && nT<32 && !disableIntraBoundaryFilter) { // DIFF 26->10
439675 for (int x=0;x<nT;x++) { // DIFF (x<->y)
440 pred[x] = Clip1Y(border[-1] + ((border[1+x] - border[0])>>1)); // DIFF (x<->y && neg)
676 pred[x] = Clip_BitDepth(border[-1] + ((border[1+x] - border[0])>>1), bit_depth); // DIFF (x<->y && neg)
441677 }
442678 }
443679 }
455691 }
456692
457693
694 template <class pixel_t>
458695 void intra_prediction_planar(de265_image* img,int xB0,int yB0,int nT,int cIdx,
459 uint8_t* border)
460 {
461 uint8_t* pred;
696 pixel_t* border)
697 {
698 pixel_t* pred;
462699 int stride;
463 pred = img->get_image_plane_at_pos(cIdx,xB0,yB0);
700 pred = img->get_image_plane_at_pos_NEW<pixel_t>(cIdx,xB0,yB0);
464701 stride = img->get_image_stride(cIdx);
465702
466703 int Log2_nT = Log2(nT);
485722 }
486723
487724
725 template <class pixel_t>
488726 void intra_prediction_DC(de265_image* img,int xB0,int yB0,int nT,int cIdx,
489 uint8_t* border)
490 {
491 uint8_t* pred;
727 pixel_t* border)
728 {
729 pixel_t* pred;
492730 int stride;
493 pred = img->get_image_plane_at_pos(cIdx,xB0,yB0);
731 pred = img->get_image_plane_at_pos_NEW<pixel_t>(cIdx,xB0,yB0);
494732 stride = img->get_image_stride(cIdx);
495733
496734 int Log2_nT = Log2(nT);
524762 }
525763
526764
527 /*
528 printf("INTRAPRED DC\n");
529 for (int y=0;y<nT;y++) {
530 for (int x=0;x<nT;x++)
531 {
532 printf("%d ",pred[x+y*stride]);
533 }
534 printf("\n");
535 }
536 */
537 }
538
539
540
541 // (8.4.4.2.1)
542 void decode_intra_prediction(de265_image* img,
543 int xB0,int yB0,
544 enum IntraPredMode intraPredMode,
545 int nT, int cIdx)
546 {
547 logtrace(LogIntraPred,"decode_intra_prediction xy0:%d/%d mode=%d nT=%d, cIdx=%d\n",
548 xB0,yB0, intraPredMode, nT,cIdx);
549 /*
550 printf("decode_intra_prediction xy0:%d/%d mode=%d nT=%d, cIdx=%d\n",
551 xB0,yB0, intraPredMode, nT,cIdx);
552 */
553
554 uint8_t border_pixels_mem[2*64+1];
555 uint8_t* border_pixels = &border_pixels_mem[64];
765 logtrace(LogIntraPred,"INTRAPRED DC\n");
766 for (int y=0;y<nT;y++)
767 {
768 for (int x=0;x<nT;x++)
769 logtrace(LogIntraPred,"%02x ", pred[x+y*stride]);
770
771 logtrace(LogIntraPred,"\n");
772 }
773 }
774
775
776
777 template <class pixel_t>
778 void decode_intra_prediction_internal(de265_image* img,
779 int xB0,int yB0,
780 enum IntraPredMode intraPredMode,
781 int nT, int cIdx)
782 {
783 pixel_t border_pixels_mem[2*64+1];
784 pixel_t* border_pixels = &border_pixels_mem[64];
556785
557786 fill_border_samples(img, xB0,yB0, nT, cIdx, border_pixels);
558787
559 if (cIdx==0) {
560 intra_prediction_sample_filtering(img, border_pixels, nT, intraPredMode);
561 }
788 if (img->sps.range_extension.intra_smoothing_disabled_flag == 0 &&
789 (cIdx==0 || img->sps.ChromaArrayType==CHROMA_444))
790 {
791 intra_prediction_sample_filtering(img, border_pixels, nT, cIdx, intraPredMode);
792 }
562793
563794
564795 switch (intraPredMode) {
575806 }
576807
577808
809 // (8.4.4.2.1)
810 void decode_intra_prediction(de265_image* img,
811 int xB0,int yB0,
812 enum IntraPredMode intraPredMode,
813 int nT, int cIdx)
814 {
815 logtrace(LogIntraPred,"decode_intra_prediction xy0:%d/%d mode=%d nT=%d, cIdx=%d\n",
816 xB0,yB0, intraPredMode, nT,cIdx);
817 /*
818 printf("decode_intra_prediction xy0:%d/%d mode=%d nT=%d, cIdx=%d\n",
819 xB0,yB0, intraPredMode, nT,cIdx);
820 */
821
822 if (img->high_bit_depth(cIdx)) {
823 decode_intra_prediction_internal<uint16_t>(img,xB0,yB0, intraPredMode,nT,cIdx);
824 }
825 else {
826 decode_intra_prediction_internal<uint8_t>(img,xB0,yB0, intraPredMode,nT,cIdx);
827 }
828 }
2424
2525 extern const int intraPredAngle_table[1+34];
2626
27
28 /* Fill the three intra-pred-mode candidates into candModeList.
29 Block position is (x,y) and you also have to give the PUidx for this
30 block (which is (x>>Log2MinPUSize) + (y>>Log2MinPUSize)*PicWidthInMinPUs).
31 availableA/B is the output of check_CTB_available().
32 */
33 void fillIntraPredModeCandidates(int candModeList[3],
34 int x,int y, int PUidx,
35 bool availableA, // left
36 bool availableB, // top
37 const de265_image* img);
38
39
40 inline void fillIntraPredModeCandidates(int candModeList[3], int x,int y,
41 bool availableA, // left
42 bool availableB, // top
43 const de265_image* img)
44 {
45 int PUidx = img->sps.getPUIndexRS(x,y);
46 fillIntraPredModeCandidates(candModeList, x,y, PUidx, availableA,availableB, img);
47 }
48
49
50
51 /* Return value >= 0 -> use mpm_idx(return value)
52 else -> use rem_intra(-return value-1)
53
54 This function may modify the candModeList !
55 */
56 int find_intra_pred_mode(enum IntraPredMode mode,
57 int candModeList[3]);
58
59 void list_chroma_pred_candidates(enum IntraPredMode chroma_mode[5],
60 enum IntraPredMode luma_mode);
61
62 int get_intra_scan_idx(int log2TrafoSize, enum IntraPredMode intraPredMode, int cIdx,
63 const seq_parameter_set* sps);
64
65 int get_intra_scan_idx_luma (int log2TrafoSize, enum IntraPredMode intraPredMode); // DEPRECATED
66 int get_intra_scan_idx_chroma(int log2TrafoSize, enum IntraPredMode intraPredMode); // DEPRECATED
67
68 enum IntraPredMode lumaPredMode_to_chromaPredMode(enum IntraPredMode luma,
69 enum IntraChromaPredMode chroma);
70
2771 void decode_intra_block(decoder_context* ctx,
2872 thread_context* tctx,
2973 int cIdx,
3377 enum IntraPredMode intraPredMode,
3478 bool transform_skip_flag);
3579
36 void fill_border_samples(decoder_context* ctx, int xB,int yB,
37 int nT, int cIdx, uint8_t* out_border);
80 //void fill_border_samples(decoder_context* ctx, int xB,int yB,
81 // int nT, int cIdx, uint8_t* out_border);
3882
3983 void decode_intra_prediction(de265_image* img,
4084 int xB0,int yB0,
3838 #define MAX_CU_SIZE 64
3939
4040
41 enum {
42 // important! order like shown in 8.5.3.1.1
43 PRED_A1 = 0,
44 PRED_B1 = 1,
45 PRED_B0 = 2,
46 PRED_A0 = 3,
47 PRED_B2 = 4,
48 PRED_COL = 5,
49 PRED_ZERO= 6
50 };
51
52
53 typedef struct
54 {
55 uint8_t available[7];
56 PredVectorInfo pred_vector[7];
57 } MergingCandidates;
58
59
60 void reset_pred_vector(PredVectorInfo* pvec)
61 {
62 for (int X=0;X<2;X++) {
63 pvec->mv[X].x = 0;
64 pvec->mv[X].y = 0;
65 pvec->refIdx[X] = -1;
66 pvec->predFlag[X] = 0;
67 }
68 }
69
70
7141 static int extra_before[4] = { 0,3,3,2 };
7242 static int extra_after [4] = { 0,3,4,4 };
7343
7444
7545
76 void mc_luma(const decoder_context* ctx,
77 const de265_image* img, int mv_x, int mv_y,
46 template <class pixel_t>
47 void mc_luma(const base_context* ctx,
48 const seq_parameter_set* sps, int mv_x, int mv_y,
7849 int xP,int yP,
7950 int16_t* out, int out_stride,
80 uint8_t* ref, int ref_stride,
81 int nPbW, int nPbH)
51 const pixel_t* ref, int ref_stride,
52 int nPbW, int nPbH, int bitDepth_L)
8253 {
83 const seq_parameter_set* sps = &img->sps;
84
8554 int xFracL = mv_x & 3;
8655 int yFracL = mv_y & 3;
8756
10069 ALIGNED_16(int16_t) mcbuffer[MAX_CU_SIZE * (MAX_CU_SIZE+7)];
10170
10271 if (xFracL==0 && yFracL==0) {
72
10373 if (xIntOffsL >= 0 && yIntOffsL >= 0 &&
10474 nPbW+xIntOffsL <= w && nPbH+yIntOffsL <= h) {
105 }
106
107 if (xIntOffsL >= 0 && yIntOffsL >= 0 &&
108 nPbW+xIntOffsL <= w && nPbH+yIntOffsL <= h) {
109
110 ctx->acceleration.put_hevc_qpel_8[0][0](out, out_stride,
111 &ref[yIntOffsL*ref_stride + xIntOffsL],
112 ref_stride,
113 nPbW,nPbH, mcbuffer);
75
76 ctx->acceleration.put_hevc_qpel(out, out_stride,
77 &ref[yIntOffsL*ref_stride + xIntOffsL],
78 ref_stride /* sizeof(pixel_t)*/,
79 nPbW,nPbH, mcbuffer, 0,0, bitDepth_L);
11480 }
11581 else {
11682 for (int y=0;y<nPbH;y++)
11783 for (int x=0;x<nPbW;x++) {
118
84
11985 int xA = Clip3(0,w-1,x + xIntOffsL);
12086 int yA = Clip3(0,h-1,y + yIntOffsL);
121
87
12288 out[y*out_stride+x] = ref[ xA + yA*ref_stride ] << shift3;
12389 }
12490 }
12894
12995 for (int y=0;y<nPbH;y++) {
13096 for (int x=0;x<nPbW;x++) {
131
97
13298 int xA = Clip3(0,w-1,x + xIntOffsL);
13399 int yA = Clip3(0,h-1,y + yIntOffsL);
134
100
135101 logtrace(LogMotion,"%02x ", ref[ xA + yA*ref_stride ]);
136102 }
137103 logtrace(LogMotion,"\n");
141107
142108 for (int y=0;y<nPbH;y++) {
143109 for (int x=0;x<nPbW;x++) {
144
110
145111 logtrace(LogMotion,"%02x ",out[y*out_stride+x] >> 6); // 6 will be used when summing predictions
146112 }
147113 logtrace(LogMotion,"\n");
158124 //int nPbH_extra = extra_top + nPbH + extra_bottom;
159125
160126
161 uint8_t padbuf[(MAX_CU_SIZE+16)*(MAX_CU_SIZE+7)];
162
163 uint8_t* src_ptr;
127 pixel_t padbuf[(MAX_CU_SIZE+16)*(MAX_CU_SIZE+7)];
128
129 const pixel_t* src_ptr;
164130 int src_stride;
165131
166132 if (-extra_left + xIntOffsL >= 0 &&
173139 else {
174140 for (int y=-extra_top;y<nPbH+extra_bottom;y++) {
175141 for (int x=-extra_left;x<nPbW+extra_right;x++) {
176
142
177143 int xA = Clip3(0,w-1,x + xIntOffsL);
178144 int yA = Clip3(0,h-1,y + yIntOffsL);
179
145
180146 padbuf[x+extra_left + (y+extra_top)*(MAX_CU_SIZE+16)] = ref[ xA + yA*ref_stride ];
181147 }
182148 }
185151 src_stride = MAX_CU_SIZE+16;
186152 }
187153
188 ctx->acceleration.put_hevc_qpel_8[xFracL][yFracL](out, out_stride,
189 src_ptr, src_stride,
190 nPbW,nPbH, mcbuffer);
154 ctx->acceleration.put_hevc_qpel(out, out_stride,
155 src_ptr, src_stride /* sizeof(pixel_t) */,
156 nPbW,nPbH, mcbuffer, xFracL,yFracL, bitDepth_L);
191157
192158
193159 logtrace(LogMotion,"---V---\n");
202168
203169
204170
205 void mc_chroma(const decoder_context* ctx,
206 const de265_image* img,
171 template <class pixel_t>
172 void mc_chroma(const base_context* ctx,
173 const seq_parameter_set* sps,
207174 int mv_x, int mv_y,
208175 int xP,int yP,
209176 int16_t* out, int out_stride,
210 uint8_t* ref, int ref_stride,
211 int nPbWC, int nPbHC)
177 const pixel_t* ref, int ref_stride,
178 int nPbWC, int nPbHC, int bit_depth_C)
212179 {
213 const seq_parameter_set* sps = &img->sps;
214
215180 // chroma sample interpolation process (8.5.3.2.2.2)
216181
217182 //const int shift1 = sps->BitDepth_C-8;
221186 int wC = sps->pic_width_in_luma_samples /sps->SubWidthC;
222187 int hC = sps->pic_height_in_luma_samples/sps->SubHeightC;
223188
189 mv_x *= 2 / sps->SubWidthC;
190 mv_y *= 2 / sps->SubHeightC;
191
224192 int xFracC = mv_x & 7;
225193 int yFracC = mv_y & 7;
226194
227 int xIntOffsC = xP/2 + (mv_x>>3);
228 int yIntOffsC = yP/2 + (mv_y>>3);
195 int xIntOffsC = xP/sps->SubWidthC + (mv_x>>3);
196 int yIntOffsC = yP/sps->SubHeightC + (mv_y>>3);
229197
230198 ALIGNED_32(int16_t mcbuffer[MAX_CU_SIZE*(MAX_CU_SIZE+7)]);
231199
232200 if (xFracC == 0 && yFracC == 0) {
233201 if (xIntOffsC>=0 && nPbWC+xIntOffsC<=wC &&
234202 yIntOffsC>=0 && nPbHC+yIntOffsC<=hC) {
235 ctx->acceleration.put_hevc_epel_8(out, out_stride,
236 &ref[xIntOffsC + yIntOffsC*ref_stride], ref_stride,
237 nPbWC,nPbHC, 0,0, NULL);
203 ctx->acceleration.put_hevc_epel(out, out_stride,
204 &ref[xIntOffsC + yIntOffsC*ref_stride], ref_stride,
205 nPbWC,nPbHC, 0,0, NULL, bit_depth_C);
238206 }
239207 else
240208 {
249217 }
250218 }
251219 else {
252 uint8_t padbuf[(MAX_CU_SIZE+16)*(MAX_CU_SIZE+3)];
253
254 uint8_t* src_ptr;
220 pixel_t padbuf[(MAX_CU_SIZE+16)*(MAX_CU_SIZE+3)];
221
222 const pixel_t* src_ptr;
255223 int src_stride;
256224
257225 int extra_top = 1;
267235 else {
268236 for (int y=-extra_top;y<nPbHC+extra_bottom;y++) {
269237 for (int x=-extra_left;x<nPbWC+extra_right;x++) {
270
238
271239 int xA = Clip3(0,wC-1,x + xIntOffsC);
272240 int yA = Clip3(0,hC-1,y + yIntOffsC);
273
241
274242 padbuf[x+extra_left + (y+extra_top)*(MAX_CU_SIZE+16)] = ref[ xA + yA*ref_stride ];
275243 }
276244 }
281249
282250
283251 if (xFracC && yFracC) {
284 ctx->acceleration.put_hevc_epel_hv_8(out, out_stride,
285 src_ptr, src_stride,
286 nPbWC,nPbHC, xFracC,yFracC, mcbuffer);
252 ctx->acceleration.put_hevc_epel_hv(out, out_stride,
253 src_ptr, src_stride,
254 nPbWC,nPbHC, xFracC,yFracC, mcbuffer, bit_depth_C);
287255 }
288256 else if (xFracC) {
289 ctx->acceleration.put_hevc_epel_h_8(out, out_stride,
290 src_ptr, src_stride,
291 nPbWC,nPbHC, xFracC,yFracC, mcbuffer);
257 ctx->acceleration.put_hevc_epel_h(out, out_stride,
258 src_ptr, src_stride,
259 nPbWC,nPbHC, xFracC,yFracC, mcbuffer, bit_depth_C);
292260 }
293261 else if (yFracC) {
294 ctx->acceleration.put_hevc_epel_v_8(out, out_stride,
295 src_ptr, src_stride,
296 nPbWC,nPbHC, xFracC,yFracC, mcbuffer);
262 ctx->acceleration.put_hevc_epel_v(out, out_stride,
263 src_ptr, src_stride,
264 nPbWC,nPbHC, xFracC,yFracC, mcbuffer, bit_depth_C);
297265 }
298266 else {
299267 assert(false); // full-pel shifts are handled above
305273
306274 // 8.5.3.2
307275 // NOTE: for full-pel shifts, we can introduce a fast path, simply copying without shifts
308 void generate_inter_prediction_samples(decoder_context* ctx,
276 void generate_inter_prediction_samples(base_context* ctx,
277 const slice_segment_header* shdr,
309278 de265_image* img,
310 slice_segment_header* shdr,
311279 int xC,int yC,
312280 int xB,int yB,
313281 int nCS, int nPbW,int nPbH,
314 const VectorInfo* vi)
282 const MotionVectorSpec* vi)
315283 {
284 int xP = xC+xB;
285 int yP = yC+yB;
286
287 void* pixels[3];
288 int stride[3];
289
290 const int SubWidthC = img->sps.SubWidthC;
291 const int SubHeightC = img->sps.SubHeightC;
292
293 pixels[0] = img->get_image_plane_at_pos_any_depth(0,xP,yP);
294 stride[0] = img->get_image_stride(0);
295
296 pixels[1] = img->get_image_plane_at_pos_any_depth(1,xP/SubWidthC,yP/SubHeightC);
297 stride[1] = img->get_image_stride(1);
298
299 pixels[2] = img->get_image_plane_at_pos_any_depth(2,xP/SubWidthC,yP/SubHeightC);
300 stride[2] = img->get_image_stride(2);
301
302
316303 ALIGNED_16(int16_t) predSamplesL [2 /* LX */][MAX_CU_SIZE* MAX_CU_SIZE];
317304 ALIGNED_16(int16_t) predSamplesC[2 /* chroma */ ][2 /* LX */][MAX_CU_SIZE* MAX_CU_SIZE];
318305
319 int xP = xC+xB;
320 int yP = yC+yB;
306 //int xP = xC+xB;
307 //int yP = yC+yB;
321308
322309 int predFlag[2];
323 predFlag[0] = vi->lum.predFlag[0];
324 predFlag[1] = vi->lum.predFlag[1];
325
310 predFlag[0] = vi->predFlag[0];
311 predFlag[1] = vi->predFlag[1];
312
313 const int bit_depth_L = img->sps.BitDepth_Y;
314 const int bit_depth_C = img->sps.BitDepth_C;
326315
327316 // Some encoders use bi-prediction with two similar MVs.
328317 // Identify this case and use only one MV.
330319 // do this only without weighted prediction, because the weights/offsets may be different
331320 if (img->pps.weighted_pred_flag==0) {
332321 if (predFlag[0] && predFlag[1]) {
333 if (vi->lum.mv[0].x == vi->lum.mv[1].x &&
334 vi->lum.mv[0].y == vi->lum.mv[1].y &&
335 shdr->RefPicList[0][vi->lum.refIdx[0]] ==
336 shdr->RefPicList[1][vi->lum.refIdx[1]]) {
322 if (vi->mv[0].x == vi->mv[1].x &&
323 vi->mv[0].y == vi->mv[1].y &&
324 shdr->RefPicList[0][vi->refIdx[0]] ==
325 shdr->RefPicList[1][vi->refIdx[1]]) {
337326 predFlag[1] = 0;
338327 }
339328 }
344333 if (predFlag[l]) {
345334 // 8.5.3.2.1
346335
347 if (vi->lum.refIdx[l] >= MAX_NUM_REF_PICS) {
336 if (vi->refIdx[l] >= MAX_NUM_REF_PICS) {
348337 img->integrity = INTEGRITY_DECODING_ERRORS;
349338 ctx->add_warning(DE265_WARNING_NONEXISTING_REFERENCE_PICTURE_ACCESSED, false);
350339 return;
351340 }
352341
353 de265_image* refPic;
354 refPic = ctx->get_image(shdr->RefPicList[l][vi->lum.refIdx[l]]);
355
356 logtrace(LogMotion, "refIdx: %d -> dpb[%d]\n", vi->lum.refIdx[l], shdr->RefPicList[l][vi->lum.refIdx[l]]);
342 const de265_image* refPic = ctx->get_image(shdr->RefPicList[l][vi->refIdx[l]]);
343
344 logtrace(LogMotion, "refIdx: %d -> dpb[%d]\n", vi->refIdx[l], shdr->RefPicList[l][vi->refIdx[l]]);
357345
358346 if (refPic->PicState == UnusedForReference) {
359347 img->integrity = INTEGRITY_DECODING_ERRORS;
360348 ctx->add_warning(DE265_WARNING_NONEXISTING_REFERENCE_PICTURE_ACCESSED, false);
349
350 // TODO: fill predSamplesC with black or grey
361351 }
362352 else {
363353 // 8.5.3.2.2
364354
365355 logtrace(LogMotion,"do MC: L%d,MV=%d;%d RefPOC=%d\n",
366 l,vi->lum.mv[l].x,vi->lum.mv[l].y,refPic->PicOrderCntVal);
356 l,vi->mv[l].x,vi->mv[l].y,refPic->PicOrderCntVal);
367357
368358
369359 // TODO: must predSamples stride really be nCS or can it be somthing smaller like nPbW?
370 mc_luma(ctx, img, vi->lum.mv[l].x, vi->lum.mv[l].y, xP,yP,
371 predSamplesL[l],nCS,
372 refPic->get_image_plane(0),refPic->get_luma_stride(), nPbW,nPbH);
373
374
375 mc_chroma(ctx, img, vi->lum.mv[l].x, vi->lum.mv[l].y, xP,yP,
376 predSamplesC[0][l],nCS, refPic->get_image_plane(1),
377 refPic->get_chroma_stride(), nPbW/2,nPbH/2);
378 mc_chroma(ctx, img, vi->lum.mv[l].x, vi->lum.mv[l].y, xP,yP,
379 predSamplesC[1][l],nCS, refPic->get_image_plane(2),
380 refPic->get_chroma_stride(), nPbW/2,nPbH/2);
360
361 if (img->high_bit_depth(0)) {
362 mc_luma(ctx, &img->sps, vi->mv[l].x, vi->mv[l].y, xP,yP,
363 predSamplesL[l],nCS,
364 (const uint16_t*)refPic->get_image_plane(0),
365 refPic->get_luma_stride(), nPbW,nPbH, bit_depth_L);
366 }
367 else {
368 mc_luma(ctx, &img->sps, vi->mv[l].x, vi->mv[l].y, xP,yP,
369 predSamplesL[l],nCS,
370 (const uint8_t*)refPic->get_image_plane(0),
371 refPic->get_luma_stride(), nPbW,nPbH, bit_depth_L);
372 }
373
374 if (img->high_bit_depth(0)) {
375 mc_chroma(ctx, &img->sps, vi->mv[l].x, vi->mv[l].y, xP,yP,
376 predSamplesC[0][l],nCS, (const uint16_t*)refPic->get_image_plane(1),
377 refPic->get_chroma_stride(), nPbW/SubWidthC,nPbH/SubHeightC, bit_depth_C);
378 mc_chroma(ctx, &img->sps, vi->mv[l].x, vi->mv[l].y, xP,yP,
379 predSamplesC[1][l],nCS, (const uint16_t*)refPic->get_image_plane(2),
380 refPic->get_chroma_stride(), nPbW/SubWidthC,nPbH/SubHeightC, bit_depth_C);
381 }
382 else {
383 mc_chroma(ctx, &img->sps, vi->mv[l].x, vi->mv[l].y, xP,yP,
384 predSamplesC[0][l],nCS, (const uint8_t*)refPic->get_image_plane(1),
385 refPic->get_chroma_stride(), nPbW/SubWidthC,nPbH/SubHeightC, bit_depth_C);
386 mc_chroma(ctx, &img->sps, vi->mv[l].x, vi->mv[l].y, xP,yP,
387 predSamplesC[1][l],nCS, (const uint8_t*)refPic->get_image_plane(2),
388 refPic->get_chroma_stride(), nPbW/SubWidthC,nPbH/SubHeightC, bit_depth_C);
389 }
381390 }
382391 }
383392 }
385394
386395 // weighted sample prediction (8.5.3.2.3)
387396
388 //const int shift1 = 6; // TODO
389 //const int offset1= 1<<(shift1-1);
397 const int shift1_L = libde265_max(2,14-img->sps.BitDepth_Y);
398 const int offset_shift1_L = img->sps.WpOffsetBdShiftY;
399 const int shift1_C = libde265_max(2,14-img->sps.BitDepth_C);
400 const int offset_shift1_C = img->sps.WpOffsetBdShiftC;
401
402 /*
403 const int shift1_L = 14-img->sps.BitDepth_Y;
404 const int offset_shift1_L = img->sps.BitDepth_Y-8;
405 const int shift1_C = 14-img->sps.BitDepth_C;
406 const int offset_shift1_C = img->sps.BitDepth_C-8;
407 */
408
409 /*
410 if (0)
411 printf("%d/%d %d/%d %d/%d %d/%d\n",
412 shift1_L,
413 Nshift1_L,
414 offset_shift1_L,
415 Noffset_shift1_L,
416 shift1_C,
417 Nshift1_C,
418 offset_shift1_C,
419 Noffset_shift1_C);
420
421 assert(shift1_L==
422 Nshift1_L);
423 assert(offset_shift1_L==
424 Noffset_shift1_L);
425 assert(shift1_C==
426 Nshift1_C);
427 assert(offset_shift1_C==
428 Noffset_shift1_C);
429 */
430
390431
391432 logtrace(LogMotion,"predFlags (modified): %d %d\n", predFlag[0], predFlag[1]);
392433
393434 if (shdr->slice_type == SLICE_TYPE_P) {
394435 if (img->pps.weighted_pred_flag==0) {
395436 if (predFlag[0]==1 && predFlag[1]==0) {
396 ctx->acceleration.put_unweighted_pred_8(img->get_image_plane_at_pos(0,xP,yP),
397 img->get_image_stride(0),
398 predSamplesL[0],nCS, nPbW,nPbH);
399 ctx->acceleration.put_unweighted_pred_8(img->get_image_plane_at_pos(1,xP/2,yP/2),
400 img->get_image_stride(1),
401 predSamplesC[0][0],nCS, nPbW/2,nPbH/2);
402 ctx->acceleration.put_unweighted_pred_8(img->get_image_plane_at_pos(2,xP/2,yP/2),
403 img->get_image_stride(2),
404 predSamplesC[1][0],nCS, nPbW/2,nPbH/2);
437 ctx->acceleration.put_unweighted_pred(pixels[0], stride[0],
438 predSamplesL[0],nCS, nPbW,nPbH, bit_depth_L);
439 ctx->acceleration.put_unweighted_pred(pixels[1], stride[1],
440 predSamplesC[0][0],nCS,
441 nPbW/SubWidthC,nPbH/SubHeightC, bit_depth_C);
442 ctx->acceleration.put_unweighted_pred(pixels[2], stride[2],
443 predSamplesC[1][0],nCS,
444 nPbW/SubWidthC,nPbH/SubHeightC, bit_depth_C);
405445 }
406446 else {
407447 ctx->add_warning(DE265_WARNING_BOTH_PREDFLAGS_ZERO, false);
413453
414454 if (predFlag[0]==1 && predFlag[1]==0) {
415455
416 int refIdx0 = vi->lum.refIdx[0];
417
418 int luma_log2WD = shdr->luma_log2_weight_denom + (14-8); // TODO: bitDepth
419 int chroma_log2WD = shdr->ChromaLog2WeightDenom + (14-8); // TODO: bitDepth
456 int refIdx0 = vi->refIdx[0];
457
458 int luma_log2WD = shdr->luma_log2_weight_denom + shift1_L;
459 int chroma_log2WD = shdr->ChromaLog2WeightDenom + shift1_C;
420460
421461 int luma_w0 = shdr->LumaWeight[0][refIdx0];
422 int luma_o0 = shdr->luma_offset[0][refIdx0] * (1<<(8-8)); // TODO: bitDepth
462 int luma_o0 = shdr->luma_offset[0][refIdx0] * (1<<(offset_shift1_L));
423463
424464 int chroma0_w0 = shdr->ChromaWeight[0][refIdx0][0];
425 int chroma0_o0 = shdr->ChromaOffset[0][refIdx0][0] * (1<<(8-8)); // TODO: bitDepth
465 int chroma0_o0 = shdr->ChromaOffset[0][refIdx0][0] * (1<<(offset_shift1_C));
426466 int chroma1_w0 = shdr->ChromaWeight[0][refIdx0][1];
427 int chroma1_o0 = shdr->ChromaOffset[0][refIdx0][1] * (1<<(8-8)); // TODO: bitDepth
467 int chroma1_o0 = shdr->ChromaOffset[0][refIdx0][1] * (1<<(offset_shift1_C));
428468
429469 logtrace(LogMotion,"weighted-0 [%d] %d %d %d %dx%d\n", refIdx0, luma_log2WD-6,luma_w0,luma_o0,nPbW,nPbH);
430470
431 ctx->acceleration.put_weighted_pred_8(img->get_image_plane_at_pos(0,xP,yP),
432 img->get_image_stride(0),
433 predSamplesL[0],nCS, nPbW,nPbH,
434 luma_w0, luma_o0, luma_log2WD);
435 ctx->acceleration.put_weighted_pred_8(img->get_image_plane_at_pos(1,xP/2,yP/2),
436 img->get_image_stride(1),
437 predSamplesC[0][0],nCS, nPbW/2,nPbH/2,
438 chroma0_w0, chroma0_o0, chroma_log2WD);
439 ctx->acceleration.put_weighted_pred_8(img->get_image_plane_at_pos(2,xP/2,yP/2),
440 img->get_image_stride(2),
441 predSamplesC[1][0],nCS, nPbW/2,nPbH/2,
442 chroma1_w0, chroma1_o0, chroma_log2WD);
471 ctx->acceleration.put_weighted_pred(pixels[0], stride[0],
472 predSamplesL[0],nCS, nPbW,nPbH,
473 luma_w0, luma_o0, luma_log2WD, bit_depth_L);
474 ctx->acceleration.put_weighted_pred(pixels[1], stride[1],
475 predSamplesC[0][0],nCS, nPbW/SubWidthC,nPbH/SubHeightC,
476 chroma0_w0, chroma0_o0, chroma_log2WD, bit_depth_C);
477 ctx->acceleration.put_weighted_pred(pixels[2], stride[2],
478 predSamplesC[1][0],nCS, nPbW/SubWidthC,nPbH/SubHeightC,
479 chroma1_w0, chroma1_o0, chroma_log2WD, bit_depth_C);
443480 }
444481 else {
445482 ctx->add_warning(DE265_WARNING_BOTH_PREDFLAGS_ZERO, false);
457494
458495 int16_t* in0 = predSamplesL[0];
459496 int16_t* in1 = predSamplesL[1];
460 uint8_t* out = img->get_image_plane_at_pos(0, xP,yP);
461
462 ctx->acceleration.put_weighted_pred_avg_8(out, img->get_luma_stride(),
463 in0,in1, nCS, nPbW, nPbH);
497
498 ctx->acceleration.put_weighted_pred_avg(pixels[0], stride[0],
499 in0,in1, nCS, nPbW, nPbH, bit_depth_L);
464500
465501 int16_t* in00 = predSamplesC[0][0];
466502 int16_t* in01 = predSamplesC[0][1];
467503 int16_t* in10 = predSamplesC[1][0];
468504 int16_t* in11 = predSamplesC[1][1];
469 uint8_t* out0 = img->get_image_plane_at_pos(1,xP/2,yP/2);
470 uint8_t* out1 = img->get_image_plane_at_pos(2,xP/2,yP/2);
471
472 ctx->acceleration.put_weighted_pred_avg_8(out0, img->get_chroma_stride(),
473 in00,in01, nCS, nPbW/2, nPbH/2);
474 ctx->acceleration.put_weighted_pred_avg_8(out1, img->get_chroma_stride(),
475 in10,in11, nCS, nPbW/2, nPbH/2);
505
506 ctx->acceleration.put_weighted_pred_avg(pixels[1], stride[1],
507 in00,in01, nCS,
508 nPbW/SubWidthC, nPbH/SubHeightC, bit_depth_C);
509 ctx->acceleration.put_weighted_pred_avg(pixels[2], stride[2],
510 in10,in11, nCS,
511 nPbW/SubWidthC, nPbH/SubHeightC, bit_depth_C);
476512 }
477513 else {
478514 // weighted prediction
479515
480 int refIdx0 = vi->lum.refIdx[0];
481 int refIdx1 = vi->lum.refIdx[1];
482
483 int luma_log2WD = shdr->luma_log2_weight_denom + (14-8); // TODO: bitDepth
484 int chroma_log2WD = shdr->ChromaLog2WeightDenom + (14-8); // TODO: bitDepth
516 int refIdx0 = vi->refIdx[0];
517 int refIdx1 = vi->refIdx[1];
518
519 int luma_log2WD = shdr->luma_log2_weight_denom + shift1_L;
520 int chroma_log2WD = shdr->ChromaLog2WeightDenom + shift1_C;
485521
486522 int luma_w0 = shdr->LumaWeight[0][refIdx0];
487 int luma_o0 = shdr->luma_offset[0][refIdx0] * (1<<(8-8)); // TODO: bitDepth
523 int luma_o0 = shdr->luma_offset[0][refIdx0] * (1<<(offset_shift1_L));
488524 int luma_w1 = shdr->LumaWeight[1][refIdx1];
489 int luma_o1 = shdr->luma_offset[1][refIdx1] * (1<<(8-8)); // TODO: bitDepth
525 int luma_o1 = shdr->luma_offset[1][refIdx1] * (1<<(offset_shift1_L));
490526
491527 int chroma0_w0 = shdr->ChromaWeight[0][refIdx0][0];
492 int chroma0_o0 = shdr->ChromaOffset[0][refIdx0][0] * (1<<(8-8)); // TODO: bitDepth
528 int chroma0_o0 = shdr->ChromaOffset[0][refIdx0][0] * (1<<(offset_shift1_C));
493529 int chroma1_w0 = shdr->ChromaWeight[0][refIdx0][1];
494 int chroma1_o0 = shdr->ChromaOffset[0][refIdx0][1] * (1<<(8-8)); // TODO: bitDepth
530 int chroma1_o0 = shdr->ChromaOffset[0][refIdx0][1] * (1<<(offset_shift1_C));
495531 int chroma0_w1 = shdr->ChromaWeight[1][refIdx1][0];
496 int chroma0_o1 = shdr->ChromaOffset[1][refIdx1][0] * (1<<(8-8)); // TODO: bitDepth
532 int chroma0_o1 = shdr->ChromaOffset[1][refIdx1][0] * (1<<(offset_shift1_C));
497533 int chroma1_w1 = shdr->ChromaWeight[1][refIdx1][1];
498 int chroma1_o1 = shdr->ChromaOffset[1][refIdx1][1] * (1<<(8-8)); // TODO: bitDepth
534 int chroma1_o1 = shdr->ChromaOffset[1][refIdx1][1] * (1<<(offset_shift1_C));
499535
500536 logtrace(LogMotion,"weighted-BI-0 [%d] %d %d %d %dx%d\n", refIdx0, luma_log2WD-6,luma_w0,luma_o0,nPbW,nPbH);
501537 logtrace(LogMotion,"weighted-BI-1 [%d] %d %d %d %dx%d\n", refIdx1, luma_log2WD-6,luma_w1,luma_o1,nPbW,nPbH);
502538
503539 int16_t* in0 = predSamplesL[0];
504540 int16_t* in1 = predSamplesL[1];
505 uint8_t* out = img->get_image_plane_at_pos(0, xP,yP);
506
507 ctx->acceleration.put_weighted_bipred_8(out, img->get_luma_stride(),
508 in0,in1, nCS, nPbW, nPbH,
509 luma_w0,luma_o0,
510 luma_w1,luma_o1,
511 luma_log2WD);
541
542 ctx->acceleration.put_weighted_bipred(pixels[0], stride[0],
543 in0,in1, nCS, nPbW, nPbH,
544 luma_w0,luma_o0,
545 luma_w1,luma_o1,
546 luma_log2WD, bit_depth_L);
512547
513548 int16_t* in00 = predSamplesC[0][0];
514549 int16_t* in01 = predSamplesC[0][1];
515550 int16_t* in10 = predSamplesC[1][0];
516551 int16_t* in11 = predSamplesC[1][1];
517 uint8_t* out0 = img->get_image_plane_at_pos(1,xP/2,yP/2);
518 uint8_t* out1 = img->get_image_plane_at_pos(2,xP/2,yP/2);
519
520 ctx->acceleration.put_weighted_bipred_8(out0, img->get_chroma_stride(),
521 in00,in01, nCS, nPbW/2, nPbH/2,
522 chroma0_w0,chroma0_o0,
523 chroma0_w1,chroma0_o1,
524 chroma_log2WD);
525 ctx->acceleration.put_weighted_bipred_8(out1, img->get_chroma_stride(),
526 in10,in11, nCS, nPbW/2, nPbH/2,
527 chroma1_w0,chroma1_o0,
528 chroma1_w1,chroma1_o1,
529 chroma_log2WD);
552
553 ctx->acceleration.put_weighted_bipred(pixels[1], stride[1],
554 in00,in01, nCS, nPbW/SubWidthC, nPbH/SubHeightC,
555 chroma0_w0,chroma0_o0,
556 chroma0_w1,chroma0_o1,
557 chroma_log2WD, bit_depth_C);
558 ctx->acceleration.put_weighted_bipred(pixels[2], stride[2],
559 in10,in11, nCS, nPbW/SubWidthC, nPbH/SubHeightC,
560 chroma1_w0,chroma1_o0,
561 chroma1_w1,chroma1_o1,
562 chroma_log2WD, bit_depth_C);
530563 }
531564 }
532565 else if (predFlag[0]==1 || predFlag[1]==1) {
533566 int l = predFlag[0] ? 0 : 1;
534567
535568 if (img->pps.weighted_bipred_flag==0) {
536 ctx->acceleration.put_unweighted_pred_8(img->get_image_plane_at_pos(0,xP,yP),
537 img->get_image_stride(0),
538 predSamplesL[l],nCS, nPbW,nPbH);
539 ctx->acceleration.put_unweighted_pred_8(img->get_image_plane_at_pos(1,xP/2,yP/2),
540 img->get_image_stride(1),
541 predSamplesC[0][l],nCS, nPbW/2,nPbH/2);
542 ctx->acceleration.put_unweighted_pred_8(img->get_image_plane_at_pos(2,xP/2,yP/2),
543 img->get_image_stride(2),
544 predSamplesC[1][l],nCS, nPbW/2,nPbH/2);
569 ctx->acceleration.put_unweighted_pred(pixels[0], stride[0],
570 predSamplesL[l],nCS, nPbW,nPbH, bit_depth_L);
571 ctx->acceleration.put_unweighted_pred(pixels[1], stride[1],
572 predSamplesC[0][l],nCS,
573 nPbW/SubWidthC,nPbH/SubHeightC, bit_depth_C);
574 ctx->acceleration.put_unweighted_pred(pixels[2], stride[2],
575 predSamplesC[1][l],nCS,
576 nPbW/SubWidthC,nPbH/SubHeightC, bit_depth_C);
545577 }
546578 else {
547 int refIdx = vi->lum.refIdx[l];
548
549 int luma_log2WD = shdr->luma_log2_weight_denom + (14-8); // TODO: bitDepth
550 int chroma_log2WD = shdr->ChromaLog2WeightDenom + (14-8); // TODO: bitDepth
579 int refIdx = vi->refIdx[l];
580
581 int luma_log2WD = shdr->luma_log2_weight_denom + shift1_L;
582 int chroma_log2WD = shdr->ChromaLog2WeightDenom + shift1_C;
551583
552584 int luma_w = shdr->LumaWeight[l][refIdx];
553 int luma_o = shdr->luma_offset[l][refIdx] * (1<<(8-8)); // TODO: bitDepth
585 int luma_o = shdr->luma_offset[l][refIdx] * (1<<(offset_shift1_L));
554586
555587 int chroma0_w = shdr->ChromaWeight[l][refIdx][0];
556 int chroma0_o = shdr->ChromaOffset[l][refIdx][0] * (1<<(8-8)); // TODO: bitDepth
588 int chroma0_o = shdr->ChromaOffset[l][refIdx][0] * (1<<(offset_shift1_C));
557589 int chroma1_w = shdr->ChromaWeight[l][refIdx][1];
558 int chroma1_o = shdr->ChromaOffset[l][refIdx][1] * (1<<(8-8)); // TODO: bitDepth
590 int chroma1_o = shdr->ChromaOffset[l][refIdx][1] * (1<<(offset_shift1_C));
559591
560592 logtrace(LogMotion,"weighted-B-L%d [%d] %d %d %d %dx%d\n", l, refIdx, luma_log2WD-6,luma_w,luma_o,nPbW,nPbH);
561593
562 ctx->acceleration.put_weighted_pred_8(img->get_image_plane_at_pos(0,xP,yP),
563 img->get_image_stride(0),
564 predSamplesL[l],nCS, nPbW,nPbH,
565 luma_w, luma_o, luma_log2WD);
566 ctx->acceleration.put_weighted_pred_8(img->get_image_plane_at_pos(1,xP/2,yP/2),
567 img->get_image_stride(1),
568 predSamplesC[0][l],nCS, nPbW/2,nPbH/2,
569 chroma0_w, chroma0_o, chroma_log2WD);
570 ctx->acceleration.put_weighted_pred_8(img->get_image_plane_at_pos(2,xP/2,yP/2),
571 img->get_image_stride(2),
572 predSamplesC[1][l],nCS, nPbW/2,nPbH/2,
573 chroma1_w, chroma1_o, chroma_log2WD);
594 ctx->acceleration.put_weighted_pred(pixels[0], stride[0],
595 predSamplesL[l],nCS, nPbW,nPbH,
596 luma_w, luma_o, luma_log2WD, bit_depth_L);
597 ctx->acceleration.put_weighted_pred(pixels[1], stride[1],
598 predSamplesC[0][l],nCS,
599 nPbW/SubWidthC,nPbH/SubHeightC,
600 chroma0_w, chroma0_o, chroma_log2WD, bit_depth_C);
601 ctx->acceleration.put_weighted_pred(pixels[2], stride[2],
602 predSamplesC[1][l],nCS,
603 nPbW/SubWidthC,nPbH/SubHeightC,
604 chroma1_w, chroma1_o, chroma_log2WD, bit_depth_C);
574605 }
575606 }
576607 else {
589620 logtrace(LogTransform,"MC-y-%d-%d ",xP,yP+y);
590621
591622 for (int x=0;x<nPbW;x++) {
592 logtrace(LogTransform,"*%02x ", img->y[xP+x+(yP+y)*img->stride]);
623 logtrace(LogTransform,"*%02x ", pixels[0][x+y*stride[0]]);
593624 }
594625
595626 logtrace(LogTransform,"*\n");
596 }
627 }
597628
598629
599630 logtrace(LogTransform,"MC pixels (chroma cb), position %d %d:\n", xP/2,yP/2);
602633 logtrace(LogTransform,"MC-cb-%d-%d ",xP/2,yP/2+y);
603634
604635 for (int x=0;x<nPbW/2;x++) {
605 logtrace(LogTransform,"*%02x ", img->cb[xP/2+x+(yP/2+y)*img->chroma_stride]);
636 logtrace(LogTransform,"*%02x ", pixels[1][x+y*stride[1]]);
606637 }
607638
608639 logtrace(LogTransform,"*\n");
609 }
640 }
610641
611642
612643 logtrace(LogTransform,"MC pixels (chroma cr), position %d %d:\n", xP/2,yP/2);
615646 logtrace(LogTransform,"MC-cr-%d-%d ",xP/2,yP/2+y);
616647
617648 for (int x=0;x<nPbW/2;x++) {
618 logtrace(LogTransform,"*%02x ", img->cr[xP/2+x+(yP/2+y)*img->chroma_stride]);
649 logtrace(LogTransform,"*%02x ", pixels[2][x+y*stride[2]]);
619650 }
620651
621652 logtrace(LogTransform,"*\n");
622 }
653 }
623654 #endif
624655 }
625656
626657
627658 #ifdef DE265_LOG_TRACE
628 void logmvcand(PredVectorInfo p)
659 void logmvcand(const MotionVectorSpec& p)
629660 {
630661 for (int v=0;v<2;v++) {
631662 if (p.predFlag[v]) {
641672 #endif
642673
643674
644 LIBDE265_INLINE static bool equal_cand_MV(const PredVectorInfo* a, const PredVectorInfo* b)
675 LIBDE265_INLINE static bool equal_cand_MV(const MotionVectorSpec* a, const MotionVectorSpec* b)
645676 {
646677 // TODO: is this really correct? no check for predFlag? Standard says so... (p.127)
647678
667698 | |
668699 | |
669700 | |
670 | |
701 | PB |
671702 | |
672703 | |
673704 +--+ |
680711
681712 // 8.5.3.1.2
682713 // TODO: check: can we fill the candidate list directly in this function and omit to copy later
683 void derive_spatial_merging_candidates(const de265_image* img,
684 int xC, int yC, int nCS, int xP, int yP,
685 uint8_t singleMCLFlag,
686 int nPbW, int nPbH,
687 int partIdx,
688 MergingCandidates* out_cand)
714 /*
715 xC/yC: CB position
716 nCS: CB size (probably modified because of singleMCLFlag)
717 xP/yP: PB position (absolute) (probably modified because of singleMCLFlag)
718 singleMCLFlag
719 nPbW/nPbH: PB size
720 partIdx
721 out_cand: merging candidate vectors
722
723 Add these candidates:
724 - A1
725 - B1 (if != A1)
726 - B0 (if != B1)
727 - A0 (if != A1)
728 - B2 (if != A1 and != B1)
729
730 A maximum of 4 candidates are generated.
731
732 Note 1: For a CB splitted into two PBs, it does not make sense to merge the
733 second part to the parameters of the first part, since then, we could use 2Nx2N
734 right away. -> Exclude this candidate.
735 */
736 int derive_spatial_merging_candidates(const de265_image* img,
737 int xC, int yC, int nCS, int xP, int yP,
738 uint8_t singleMCLFlag,
739 int nPbW, int nPbH,
740 int partIdx,
741 MotionVectorSpec* out_cand,
742 int maxCandidates)
689743 {
690744 const pic_parameter_set* pps = &img->pps;
691 int log2_parallel_merge_level = pps->log2_parallel_merge_level;
745 const int log2_parallel_merge_level = pps->log2_parallel_merge_level;
692746
693747 enum PartMode PartMode = img->get_PartMode(xC,yC);
694748
749 /*
750 const int A0 = SpatialMergingCandidates::PRED_A0;
751 const int A1 = SpatialMergingCandidates::PRED_A1;
752 const int B0 = SpatialMergingCandidates::PRED_B0;
753 const int B1 = SpatialMergingCandidates::PRED_B1;
754 const int B2 = SpatialMergingCandidates::PRED_B2;
755 */
756
695757 // --- A1 ---
696758
697 // a pixel within A1
759 // a pixel within A1 (bottom right of A1)
698760 int xA1 = xP-1;
699761 int yA1 = yP+nPbH-1;
700762
701763 bool availableA1;
702
764 int idxA1;
765
766 int computed_candidates = 0;
767
768 // check if candidate is in same motion-estimation region (MER) -> discard
703769 if ((xP>>log2_parallel_merge_level) == (xA1>>log2_parallel_merge_level) &&
704770 (yP>>log2_parallel_merge_level) == (yA1>>log2_parallel_merge_level)) {
705771 availableA1 = false;
706772 logtrace(LogMotion,"spatial merging candidate A1: below parallel merge level\n");
707773 }
708 else if (!singleMCLFlag &&
774 // redundant candidate? (Note 1) -> discard
775 else if (// !singleMCLFlag && automatically true when partIdx==1
709776 partIdx==1 &&
710777 (PartMode==PART_Nx2N ||
711778 PartMode==PART_nLx2N ||
713780 availableA1 = false;
714781 logtrace(LogMotion,"spatial merging candidate A1: second part ignore\n");
715782 }
783 // MV available in A1
716784 else {
717785 availableA1 = img->available_pred_blk(xC,yC, nCS, xP,yP, nPbW,nPbH,partIdx, xA1,yA1);
718786 if (!availableA1) logtrace(LogMotion,"spatial merging candidate A1: unavailable\n");
719787 }
720788
721 if (!availableA1) {
722 out_cand->available[PRED_A1] = 0;
723 reset_pred_vector(&out_cand->pred_vector[PRED_A1]);
724 }
725 else {
726 out_cand->available[PRED_A1] = 1;
727 out_cand->pred_vector[PRED_A1] = *img->get_mv_info(xA1,yA1);
789 if (availableA1) {
790 idxA1 = computed_candidates++;
791 out_cand[idxA1] = *img->get_mv_info(xA1,yA1);
728792
729793 logtrace(LogMotion,"spatial merging candidate A1:\n");
730 logmvcand(out_cand->pred_vector[PRED_A1]);
731 }
794 logmvcand(out_cand[idxA1]);
795 }
796
797 if (computed_candidates>=maxCandidates) return computed_candidates;
732798
733799
734800 // --- B1 ---
737803 int yB1 = yP-1;
738804
739805 bool availableB1;
740
806 int idxB1;
807
808 // same MER -> discard
741809 if ((xP>>log2_parallel_merge_level) == (xB1>>log2_parallel_merge_level) &&
742810 (yP>>log2_parallel_merge_level) == (yB1>>log2_parallel_merge_level)) {
743811 availableB1 = false;
744812 logtrace(LogMotion,"spatial merging candidate B1: below parallel merge level\n");
745813 }
746 else if (!singleMCLFlag &&
814 // redundant candidate (Note 1) -> discard
815 else if (// !singleMCLFlag && automatically true when partIdx==1
747816 partIdx==1 &&
748817 (PartMode==PART_2NxN ||
749818 PartMode==PART_2NxnU ||
751820 availableB1 = false;
752821 logtrace(LogMotion,"spatial merging candidate B1: second part ignore\n");
753822 }
823 // MV available in B1
754824 else {
755825 availableB1 = img->available_pred_blk(xC,yC, nCS, xP,yP, nPbW,nPbH,partIdx, xB1,yB1);
756826 if (!availableB1) logtrace(LogMotion,"spatial merging candidate B1: unavailable\n");
757827 }
758828
759 if (!availableB1) {
760 out_cand->available[PRED_B1] = 0;
761 reset_pred_vector(&out_cand->pred_vector[PRED_B1]);
762 }
763 else {
764 out_cand->available[PRED_B1] = 1;
765 out_cand->pred_vector[PRED_B1] = *img->get_mv_info(xB1,yB1);
766
829 if (availableB1) {
830 const MotionVectorSpec* b1 = img->get_mv_info(xB1,yB1);
831
832 // B1 == A1 -> discard B1
767833 if (availableA1 &&
768 equal_cand_MV(&out_cand->pred_vector[PRED_A1],
769 &out_cand->pred_vector[PRED_B1])) {
770 out_cand->available[PRED_B1] = 0;
834 equal_cand_MV(&out_cand[idxA1], b1)) {
835 idxB1 = idxA1;
771836 logtrace(LogMotion,"spatial merging candidate B1: redundant to A1\n");
772837 }
773838 else {
839 idxB1 = computed_candidates++;
840 out_cand[idxB1] = *b1;
841
774842 logtrace(LogMotion,"spatial merging candidate B1:\n");
775 logmvcand(out_cand->pred_vector[PRED_B1]);
776 }
777 }
843 logmvcand(out_cand[idxB1]);
844 }
845 }
846
847 if (computed_candidates>=maxCandidates) return computed_candidates;
778848
779849
780850 // --- B0 ---
783853 int yB0 = yP-1;
784854
785855 bool availableB0;
856 int idxB0;
786857
787858 if ((xP>>log2_parallel_merge_level) == (xB0>>log2_parallel_merge_level) &&
788859 (yP>>log2_parallel_merge_level) == (yB0>>log2_parallel_merge_level)) {
794865 if (!availableB0) logtrace(LogMotion,"spatial merging candidate B0: unavailable\n");
795866 }
796867
797 if (!availableB0) {
798 out_cand->available[PRED_B0] = 0;
799 reset_pred_vector(&out_cand->pred_vector[PRED_B0]);
800 }
801 else {
802 out_cand->available[PRED_B0] = 1;
803 out_cand->pred_vector[PRED_B0] = *img->get_mv_info(xB0,yB0);
804
868 if (availableB0) {
869 const MotionVectorSpec* b0 = img->get_mv_info(xB0,yB0);
870
871 // B0 == B1 -> discard B0
805872 if (availableB1 &&
806 equal_cand_MV(&out_cand->pred_vector[PRED_B1],
807 &out_cand->pred_vector[PRED_B0])) {
808 out_cand->available[PRED_B0] = 0;
873 equal_cand_MV(&out_cand[idxB1], b0)) {
874 idxB0 = idxB1;
809875 logtrace(LogMotion,"spatial merging candidate B0: redundant to B1\n");
810876 }
811877 else {
878 idxB0 = computed_candidates++;
879 out_cand[idxB0] = *b0;
812880 logtrace(LogMotion,"spatial merging candidate B0:\n");
813 logmvcand(out_cand->pred_vector[PRED_B0]);
814 }
815 }
881 logmvcand(out_cand[idxB0]);
882 }
883 }
884
885 if (computed_candidates>=maxCandidates) return computed_candidates;
816886
817887
818888 // --- A0 ---
821891 int yA0 = yP+nPbH;
822892
823893 bool availableA0;
894 int idxA0;
824895
825896 if ((xP>>log2_parallel_merge_level) == (xA0>>log2_parallel_merge_level) &&
826897 (yP>>log2_parallel_merge_level) == (yA0>>log2_parallel_merge_level)) {
832903 if (!availableA0) logtrace(LogMotion,"spatial merging candidate A0: unavailable\n");
833904 }
834905
835 if (!availableA0) {
836 out_cand->available[PRED_A0] = 0;
837 reset_pred_vector(&out_cand->pred_vector[PRED_A0]);
838 }
839 else {
840 out_cand->available[PRED_A0] = 1;
841 out_cand->pred_vector[PRED_A0] = *img->get_mv_info(xA0,yA0);
842
906 if (availableA0) {
907 const MotionVectorSpec* a0 = img->get_mv_info(xA0,yA0);
908
909 // A0 == A1 -> discard A0
843910 if (availableA1 &&
844 equal_cand_MV(&out_cand->pred_vector[PRED_A1],
845 &out_cand->pred_vector[PRED_A0])) {
846 out_cand->available[PRED_A0] = 0;
911 equal_cand_MV(&out_cand[idxA1], a0)) {
912 idxA0 = idxA1;
847913 logtrace(LogMotion,"spatial merging candidate A0: redundant to A1\n");
848914 }
849915 else {
916 idxA0 = computed_candidates++;
917 out_cand[idxA0] = *a0;
850918 logtrace(LogMotion,"spatial merging candidate A0:\n");
851 logmvcand(out_cand->pred_vector[PRED_A0]);
852 }
853 }
919 logmvcand(out_cand[idxA0]);
920 }
921 }
922
923 if (computed_candidates>=maxCandidates) return computed_candidates;
854924
855925
856926 // --- B2 ---
859929 int yB2 = yP-1;
860930
861931 bool availableB2;
862
863 if (out_cand->available[PRED_A0] && out_cand->available[PRED_A1] &&
864 out_cand->available[PRED_B0] && out_cand->available[PRED_B1]) {
932 int idxB2;
933
934 // if we already have four candidates, do not consider B2 anymore
935 if (computed_candidates==4) {
865936 availableB2 = false;
866937 logtrace(LogMotion,"spatial merging candidate B2: ignore\n");
867938 }
875946 if (!availableB2) logtrace(LogMotion,"spatial merging candidate B2: unavailable\n");
876947 }
877948
878 if (!availableB2) {
879 out_cand->available[PRED_B2] = 0;
880 reset_pred_vector(&out_cand->pred_vector[PRED_B2]);
881 }
882 else {
883 out_cand->available[PRED_B2] = 1;
884 out_cand->pred_vector[PRED_B2] = *img->get_mv_info(xB2,yB2);
885
949 if (availableB2) {
950 const MotionVectorSpec* b2 = img->get_mv_info(xB2,yB2);
951
952 // B2 == B1 -> discard B2
886953 if (availableB1 &&
887 equal_cand_MV(&out_cand->pred_vector[PRED_B1],
888 &out_cand->pred_vector[PRED_B2])) {
889 out_cand->available[PRED_B2] = 0;
954 equal_cand_MV(&out_cand[idxB1], b2)) {
955 idxB2 = idxB1;
890956 logtrace(LogMotion,"spatial merging candidate B2: redundant to B1\n");
891957 }
958 // B2 == A1 -> discard B2
892959 else if (availableA1 &&
893 equal_cand_MV(&out_cand->pred_vector[PRED_A1],
894 &out_cand->pred_vector[PRED_B2])) {
895 out_cand->available[PRED_B2] = 0;
960 equal_cand_MV(&out_cand[idxA1], b2)) {
961 idxB2 = idxA1;
896962 logtrace(LogMotion,"spatial merging candidate B2: redundant to A1\n");
897963 }
898964 else {
899 logtrace(LogMotion,"spatial merging candidate B0:\n");
900 logmvcand(out_cand->pred_vector[PRED_B0]);
901 }
902 }
965 idxB2 = computed_candidates++;
966 out_cand[idxB2] = *b2;
967 logtrace(LogMotion,"spatial merging candidate B2:\n");
968 logmvcand(out_cand[idxB2]);
969 }
970 }
971
972 return computed_candidates;
903973 }
904974
905975
906976 // 8.5.3.1.4
907 void derive_zero_motion_vector_candidates(slice_segment_header* shdr,
908 PredVectorInfo* inout_mergeCandList,
909 int* inout_numCurrMergeCand)
977 void derive_zero_motion_vector_candidates(const slice_segment_header* shdr,
978 MotionVectorSpec* out_mergeCandList,
979 int* inout_numCurrMergeCand,
980 int maxCandidates)
910981 {
911982 logtrace(LogMotion,"derive_zero_motion_vector_candidates\n");
912983
924995 //int numInputMergeCand = *inout_numMergeCand;
925996 int zeroIdx = 0;
926997
927 while (*inout_numCurrMergeCand < shdr->MaxNumMergeCand) {
998 while (*inout_numCurrMergeCand < maxCandidates) {
928999 // 1.
9291000
9301001 logtrace(LogMotion,"zeroIdx:%d numRefIdx:%d\n", zeroIdx, numRefIdx);
9311002
932 PredVectorInfo* newCand = &inout_mergeCandList[*inout_numCurrMergeCand];
1003 MotionVectorSpec* newCand = &out_mergeCandList[*inout_numCurrMergeCand];
1004
1005 const int refIdx = (zeroIdx < numRefIdx) ? zeroIdx : 0;
9331006
9341007 if (shdr->slice_type==SLICE_TYPE_P) {
935 newCand->refIdx[0] = (zeroIdx < numRefIdx) ? zeroIdx : 0;
1008 newCand->refIdx[0] = refIdx;
9361009 newCand->refIdx[1] = -1;
9371010 newCand->predFlag[0] = 1;
9381011 newCand->predFlag[1] = 0;
9391012 }
9401013 else {
941 newCand->refIdx[0] = (zeroIdx < numRefIdx) ? zeroIdx : 0;
942 newCand->refIdx[1] = (zeroIdx < numRefIdx) ? zeroIdx : 0;
1014 newCand->refIdx[0] = refIdx;
1015 newCand->refIdx[1] = refIdx;
9431016 newCand->predFlag[0] = 1;
9441017 newCand->predFlag[1] = 1;
9451018 }
9501023 newCand->mv[1].y = 0;
9511024
9521025 (*inout_numCurrMergeCand)++;
953
1026
9541027 // 2.
9551028
9561029 zeroIdx++;
9811054
9821055 // (L1003) 8.5.3.2.8
9831056
984 void derive_collocated_motion_vectors(decoder_context* ctx,
1057 void derive_collocated_motion_vectors(base_context* ctx,
9851058 de265_image* img,
9861059 const slice_segment_header* shdr,
9871060 int xP,int yP,
9881061 int colPic,
9891062 int xColPb,int yColPb,
990 int refIdxLX, int X,
1063 int refIdxLX, // (always 0 for merge mode)
1064 int X,
9911065 MotionVector* out_mvLXCol,
9921066 uint8_t* out_availableFlagLXCol)
9931067 {
9941068 logtrace(LogMotion,"derive_collocated_motion_vectors %d;%d\n",xP,yP);
9951069
1070
1071 // get collocated image and the prediction mode at the collocated position
1072
9961073 assert(ctx->has_image(colPic));
9971074 const de265_image* colImg = ctx->get_image(colPic);
1075
1076 // check for access outside image area
1077
1078 if (xColPb >= colImg->get_width() ||
1079 yColPb >= colImg->get_height()) {
1080 ctx->add_warning(DE265_WARNING_COLLOCATED_MOTION_VECTOR_OUTSIDE_IMAGE_AREA, false);
1081 *out_availableFlagLXCol = 0;
1082 return;
1083 }
1084
9981085 enum PredMode predMode = colImg->get_pred_mode(xColPb,yColPb);
1086
1087
1088 // collocated block is Intra -> no collocated MV
9991089
10001090 if (predMode == MODE_INTRA) {
10011091 out_mvLXCol->x = 0;
10031093 *out_availableFlagLXCol = 0;
10041094 return;
10051095 }
1096
1097
1098 logtrace(LogMotion,"colPic:%d (POC=%d) X:%d refIdxLX:%d refpiclist:%d\n",
1099 colPic,
1100 colImg->PicOrderCntVal,
1101 X,refIdxLX,shdr->RefPicList[X][refIdxLX]);
1102
1103
1104 // collocated reference image is unavailable -> no collocated MV
1105
1106 if (colImg->integrity == INTEGRITY_UNAVAILABLE_REFERENCE) {
1107 out_mvLXCol->x = 0;
1108 out_mvLXCol->y = 0;
1109 *out_availableFlagLXCol = 0;
1110 return;
1111 }
1112
1113
1114 // get the collocated MV
1115
1116 const MotionVectorSpec* mvi = colImg->get_mv_info(xColPb,yColPb);
1117 int listCol;
1118 int refIdxCol;
1119 MotionVector mvCol;
1120
1121 logtrace(LogMotion,"read MVI %d;%d:\n",xColPb,yColPb);
1122 logmvcand(*mvi);
1123
1124
1125 // collocated MV uses only L1 -> use L1
1126 if (mvi->predFlag[0]==0) {
1127 mvCol = mvi->mv[1];
1128 refIdxCol = mvi->refIdx[1];
1129 listCol = 1;
1130 }
1131 // collocated MV uses only L0 -> use L0
1132 else if (mvi->predFlag[1]==0) {
1133 mvCol = mvi->mv[0];
1134 refIdxCol = mvi->refIdx[0];
1135 listCol = 0;
1136 }
1137 // collocated MV uses L0 and L1
10061138 else {
1007 logtrace(LogMotion,"colPic:%d (POC=%d) X:%d refIdxLX:%d refpiclist:%d\n",
1008 colPic,
1009 colImg->PicOrderCntVal,
1010 X,refIdxLX,shdr->RefPicList[X][refIdxLX]);
1011
1012 if (colImg->integrity == INTEGRITY_UNAVAILABLE_REFERENCE) {
1013 out_mvLXCol->x = 0;
1014 out_mvLXCol->y = 0;
1015 *out_availableFlagLXCol = 0;
1016 return;
1017 }
1018
1019 const PredVectorInfo* mvi = colImg->get_mv_info(xColPb,yColPb);
1020 int listCol;
1021 int refIdxCol;
1022 MotionVector mvCol;
1023
1024 logtrace(LogMotion,"read MVI %d;%d:\n",xColPb,yColPb);
1025 logmvcand(*mvi);
1026
1027 if (mvi->predFlag[0]==0) {
1028 mvCol = mvi->mv[1];
1029 refIdxCol = mvi->refIdx[1];
1030 listCol = 1;
1139 bool allRefFramesBeforeCurrentFrame = true;
1140
1141 const int currentPOC = img->PicOrderCntVal;
1142
1143 // all reference POCs earlier than current POC (list 1)
1144 // Test L1 first, because there is a higher change to find a future reference frame.
1145
1146 for (int rIdx=0; rIdx<shdr->num_ref_idx_l1_active && allRefFramesBeforeCurrentFrame; rIdx++)
1147 {
1148 const de265_image* refimg = ctx->get_image(shdr->RefPicList[1][rIdx]);
1149 int refPOC = refimg->PicOrderCntVal;
1150
1151 if (refPOC > currentPOC) {
1152 allRefFramesBeforeCurrentFrame = false;
1153 }
1154 }
1155
1156 // all reference POCs earlier than current POC (list 0)
1157
1158 for (int rIdx=0; rIdx<shdr->num_ref_idx_l0_active && allRefFramesBeforeCurrentFrame; rIdx++)
1159 {
1160 const de265_image* refimg = ctx->get_image(shdr->RefPicList[0][rIdx]);
1161 int refPOC = refimg->PicOrderCntVal;
1162
1163 if (refPOC > currentPOC) {
1164 allRefFramesBeforeCurrentFrame = false;
1165 }
1166 }
1167
1168
1169 /* TODO: What is the rationale behind this ???
1170
1171 My guess:
1172 when there are images before the current frame (most probably in L0) and images after
1173 the current frame (most probably in L1), we take the reference in the opposite
1174 direction than where the collocated frame is positioned in the hope that the distance
1175 to the current frame will be smaller and thus give a better prediction.
1176
1177 If all references point into the past, we cannot say much about the temporal order or
1178 L0,L1 and thus take over both parts.
1179 */
1180
1181 if (allRefFramesBeforeCurrentFrame) {
1182 mvCol = mvi->mv[X];
1183 refIdxCol = mvi->refIdx[X];
1184 listCol = X;
10311185 }
10321186 else {
1033 if (mvi->predFlag[1]==0) {
1034 mvCol = mvi->mv[0];
1035 refIdxCol = mvi->refIdx[0];
1036 listCol = 0;
1037 }
1038 else {
1039 int AllDiffPicOrderCntLEZero = true;
1040
1041 const int PicOrderCntVal = img->PicOrderCntVal;
1042
1043 for (int rIdx=0; rIdx<shdr->num_ref_idx_l0_active && AllDiffPicOrderCntLEZero; rIdx++)
1044 {
1045 const de265_image* imgA = ctx->get_image(shdr->RefPicList[0][rIdx]);
1046 int aPOC = imgA->PicOrderCntVal;
1047
1048 if (aPOC > PicOrderCntVal) {
1049 AllDiffPicOrderCntLEZero = false;
1050 }
1051 }
1052
1053 for (int rIdx=0; rIdx<shdr->num_ref_idx_l1_active && AllDiffPicOrderCntLEZero; rIdx++)
1054 {
1055 const de265_image* imgA = ctx->get_image(shdr->RefPicList[1][rIdx]);
1056 int aPOC = imgA->PicOrderCntVal;
1057
1058 if (aPOC > PicOrderCntVal) {
1059 AllDiffPicOrderCntLEZero = false;
1060 }
1061 }
1062
1063 if (AllDiffPicOrderCntLEZero) {
1064 mvCol = mvi->mv[X];
1065 refIdxCol = mvi->refIdx[X];
1066 listCol = X;
1067 }
1068 else {
1069 int N = shdr->collocated_from_l0_flag;
1070 mvCol = mvi->mv[N];
1071 refIdxCol = mvi->refIdx[N];
1072 listCol = N;
1073 }
1074 }
1075 }
1076
1077
1078
1079 const slice_segment_header* colShdr = colImg->slices[ colImg->get_SliceHeaderIndex(xColPb,yColPb) ];
1080
1081 if (shdr->LongTermRefPic[X][refIdxLX] !=
1082 colShdr->LongTermRefPic[listCol][refIdxCol]) {
1083 *out_availableFlagLXCol = 0;
1084 out_mvLXCol->x = 0;
1085 out_mvLXCol->y = 0;
1187 int N = shdr->collocated_from_l0_flag;
1188 mvCol = mvi->mv[N];
1189 refIdxCol = mvi->refIdx[N];
1190 listCol = N;
1191 }
1192 }
1193
1194
1195
1196 const slice_segment_header* colShdr = colImg->slices[ colImg->get_SliceHeaderIndex(xColPb,yColPb) ];
1197
1198 if (shdr->LongTermRefPic[X][refIdxLX] !=
1199 colShdr->LongTermRefPic[listCol][refIdxCol]) {
1200 *out_availableFlagLXCol = 0;
1201 out_mvLXCol->x = 0;
1202 out_mvLXCol->y = 0;
1203 }
1204 else {
1205 *out_availableFlagLXCol = 1;
1206
1207 const bool isLongTerm = shdr->LongTermRefPic[X][refIdxLX];
1208
1209 int colDist = colImg->PicOrderCntVal - colShdr->RefPicList_POC[listCol][refIdxCol];
1210 int currDist = img->PicOrderCntVal - shdr->RefPicList_POC[X][refIdxLX];
1211
1212 logtrace(LogMotion,"COLPOCDIFF %d %d [%d %d / %d %d]\n",colDist, currDist,
1213 colImg->PicOrderCntVal, colShdr->RefPicList_POC[listCol][refIdxCol],
1214 img->PicOrderCntVal, shdr->RefPicList_POC[X][refIdxLX]
1215 );
1216
1217 if (isLongTerm || colDist == currDist) {
1218 *out_mvLXCol = mvCol;
10861219 }
10871220 else {
1088 *out_availableFlagLXCol = 1;
1089
1090 const bool isLongTerm = shdr->LongTermRefPic[X][refIdxLX];
1091
1092 int colDist = colImg->PicOrderCntVal - colShdr->RefPicList_POC[listCol][refIdxCol];
1093 int currDist = img->PicOrderCntVal - shdr->RefPicList_POC[X][refIdxLX];
1094
1095 logtrace(LogMotion,"COLPOCDIFF %d %d [%d %d / %d %d]\n",colDist, currDist,
1096 colImg->PicOrderCntVal, colShdr->RefPicList_POC[listCol][refIdxCol],
1097 img->PicOrderCntVal, shdr->RefPicList_POC[X][refIdxLX]
1098 );
1099
1100 if (isLongTerm || colDist == currDist) {
1101 *out_mvLXCol = mvCol;
1102 }
1103 else {
1104 if (!scale_mv(out_mvLXCol, mvCol, colDist, currDist)) {
1105 ctx->add_warning(DE265_WARNING_INCORRECT_MOTION_VECTOR_SCALING, false);
1106 img->integrity = INTEGRITY_DECODING_ERRORS;
1107 }
1108
1109 logtrace(LogMotion,"scale: %d;%d to %d;%d\n",
1110 mvCol.x,mvCol.y, out_mvLXCol->x,out_mvLXCol->y);
1111 }
1221 if (!scale_mv(out_mvLXCol, mvCol, colDist, currDist)) {
1222 ctx->add_warning(DE265_WARNING_INCORRECT_MOTION_VECTOR_SCALING, false);
1223 img->integrity = INTEGRITY_DECODING_ERRORS;
1224 }
1225
1226 logtrace(LogMotion,"scale: %d;%d to %d;%d\n",
1227 mvCol.x,mvCol.y, out_mvLXCol->x,out_mvLXCol->y);
11121228 }
11131229 }
11141230 }
11151231
11161232
11171233 // 8.5.3.1.7
1118 void derive_temporal_luma_vector_prediction(decoder_context* ctx,
1234 void derive_temporal_luma_vector_prediction(base_context* ctx,
11191235 de265_image* img,
11201236 const slice_segment_header* shdr,
11211237 int xP,int yP,
11221238 int nPbW,int nPbH,
1123 int refIdxL, int X,
1239 int refIdxL,
1240 int X, // which MV (L0/L1) to get
11241241 MotionVector* out_mvLXCol,
11251242 uint8_t* out_availableFlagLXCol)
11261243 {
1244 // --- no temporal MVP -> exit ---
11271245
11281246 if (shdr->slice_temporal_mvp_enabled_flag == 0) {
11291247 out_mvLXCol->x = 0;
11321250 return;
11331251 }
11341252
1253
1254 // --- find collocated reference image ---
1255
11351256 int Log2CtbSizeY = img->sps.Log2CtbSizeY;
11361257
11371258 int colPic; // TODO: this is the same for the whole slice. We can precompute it.
11411262 {
11421263 logtrace(LogMotion,"collocated L1 ref_idx=%d\n",shdr->collocated_ref_idx);
11431264
1144 // TODO: make sure that shdr->collocated_ref_idx is a valid index
11451265 colPic = shdr->RefPicList[1][ shdr->collocated_ref_idx ];
11461266 }
11471267 else
11481268 {
11491269 logtrace(LogMotion,"collocated L0 ref_idx=%d\n",shdr->collocated_ref_idx);
11501270
1151 // TODO: make sure that shdr->collocated_ref_idx is a valid index
11521271 colPic = shdr->RefPicList[0][ shdr->collocated_ref_idx ];
11531272 }
11541273
1155 //logtrace(LogMotion,"collocated reference POC=%d\n",ctx->dpb[colPic].PicOrderCntVal);
1156
1274
1275 // check whether collocated reference picture exists
11571276
11581277 if (!ctx->has_image(colPic)) {
11591278 out_mvLXCol->x = 0;
11651284 }
11661285
11671286
1287 // --- get collocated MV either at bottom-right corner or from center of PB ---
1288
11681289 int xColPb,yColPb;
11691290 int yColBr = yP + nPbH; // bottom right collocated motion vector position
11701291 int xColBr = xP + nPbW;
11711292
1293 /* If neighboring pixel at bottom-right corner is in the same CTB-row and inside the image,
1294 use this (reduced down to 16 pixels resolution) as collocated MV position.
1295
1296 Note: see 2014, Sze, Sect. 5.2.1.2 why candidate C0 is excluded when on another CTB-row.
1297 This is to reduce the memory bandwidth requirements.
1298 */
11721299 if ((yP>>Log2CtbSizeY) == (yColBr>>Log2CtbSizeY) &&
11731300 xColBr < img->sps.pic_width_in_luma_samples &&
11741301 yColBr < img->sps.pic_height_in_luma_samples)
12071334 };
12081335
12091336 // 8.5.3.1.3
1210 void derive_combined_bipredictive_merging_candidates(const decoder_context* ctx,
1211 slice_segment_header* shdr,
1212 PredVectorInfo* inout_mergeCandList,
1337 /* Note (TODO): during decoding, we know which of the candidates we will select.
1338 + Hence, we do not really have to generate the other ones...
1339 + */
1340 void derive_combined_bipredictive_merging_candidates(const base_context* ctx,
1341 const slice_segment_header* shdr,
1342 MotionVectorSpec* inout_mergeCandList,
12131343 int* inout_numMergeCand,
1214 int numOrigMergeCand)
1344 int maxCandidates)
12151345 {
1216 if (*inout_numMergeCand>1 && *inout_numMergeCand < shdr->MaxNumMergeCand) {
1346 if (*inout_numMergeCand>1 && *inout_numMergeCand < maxCandidates) {
1347 int numOrigMergeCand = *inout_numMergeCand;
1348
12171349 int numInputMergeCand = *inout_numMergeCand;
12181350 int combIdx = 0;
12191351 uint8_t combStop = false;
12271359 assert(false); // bitstream error -> TODO: conceal error
12281360 }
12291361
1230 PredVectorInfo* l0Cand = &inout_mergeCandList[l0CandIdx];
1231 PredVectorInfo* l1Cand = &inout_mergeCandList[l1CandIdx];
1362 MotionVectorSpec* l0Cand = &inout_mergeCandList[l0CandIdx];
1363 MotionVectorSpec* l1Cand = &inout_mergeCandList[l1CandIdx];
12321364
12331365 logtrace(LogMotion,"add bipredictive merging candidate (combIdx:%d)\n",combIdx);
12341366 logtrace(LogMotion,"l0Cand:\n"); logmvcand(*l0Cand);
12361368
12371369 const de265_image* img0 = l0Cand->predFlag[0] ? ctx->get_image(shdr->RefPicList[0][l0Cand->refIdx[0]]) : NULL;
12381370 const de265_image* img1 = l1Cand->predFlag[1] ? ctx->get_image(shdr->RefPicList[1][l1Cand->refIdx[1]]) : NULL;
1371
1372 if (l0Cand->predFlag[0] && !img0) {
1373 return; // TODO error
1374 }
1375
1376 if (l1Cand->predFlag[1] && !img1) {
1377 return; // TODO error
1378 }
12391379
12401380 if (l0Cand->predFlag[0] && l1Cand->predFlag[1] &&
12411381 (img0->PicOrderCntVal != img1->PicOrderCntVal ||
12421382 l0Cand->mv[0].x != l1Cand->mv[1].x ||
12431383 l0Cand->mv[0].y != l1Cand->mv[1].y)) {
1244 PredVectorInfo* p = &inout_mergeCandList[ *inout_numMergeCand ];
1384 MotionVectorSpec* p = &inout_mergeCandList[ *inout_numMergeCand ];
12451385 p->refIdx[0] = l0Cand->refIdx[0];
12461386 p->refIdx[1] = l1Cand->refIdx[1];
12471387 p->predFlag[0] = l0Cand->predFlag[0];
12561396
12571397 combIdx++;
12581398 if (combIdx == numOrigMergeCand*(numOrigMergeCand-1) ||
1259 *inout_numMergeCand == shdr->MaxNumMergeCand) {
1399 *inout_numMergeCand == maxCandidates) {
12601400 combStop = true;
12611401 }
12621402 }
12651405
12661406
12671407 // 8.5.3.1.1
1268 void derive_luma_motion_merge_mode(decoder_context* ctx,
1269 thread_context* tctx,
1270 int xC,int yC, int xP,int yP,
1271 int nCS, int nPbW,int nPbH, int partIdx,
1272 VectorInfo* out_vi)
1408 static void get_merge_candidate_list_without_step_9(base_context* ctx,
1409 const slice_segment_header* shdr,
1410 de265_image* img,
1411 int xC,int yC, int xP,int yP,
1412 int nCS, int nPbW,int nPbH, int partIdx,
1413 int max_merge_idx,
1414 MotionVectorSpec* mergeCandList)
12731415 {
1274 slice_segment_header* shdr = tctx->shdr;
12751416
12761417 //int xOrigP = xP;
12771418 //int yOrigP = yP;
12781419 int nOrigPbW = nPbW;
12791420 int nOrigPbH = nPbH;
12801421
1281 int singleMCLFlag;
1282 singleMCLFlag = (tctx->img->pps.log2_parallel_merge_level > 2 && nCS==8);
1422 int singleMCLFlag; // single merge-candidate-list (MCL) flag
1423
1424 /* Use single MCL for CBs of size 8x8, except when parallel-merge-level is at 4x4.
1425 Without this flag, PBs smaller than 8x8 would not receive as much merging candidates.
1426 Having additional candidates might have these advantages:
1427 - coding MVs for these small PBs is expensive, and
1428 - since the PBs are not far away from a proper (neighboring) merging candidate,
1429 the quality of the candidates will still be good.
1430 */
1431 singleMCLFlag = (img->pps.log2_parallel_merge_level > 2 && nCS==8);
12831432
12841433 if (singleMCLFlag) {
12851434 xP=xC;
12891438 partIdx=0;
12901439 }
12911440
1292 MergingCandidates mergeCand;
1293 derive_spatial_merging_candidates(tctx->img, xC,yC, nCS, xP,yP, singleMCLFlag,
1294 nPbW,nPbH,partIdx, &mergeCand);
1295
1296 int refIdxCol[2] = { 0,0 };
1297
1298 MotionVector mvCol[2];
1299 uint8_t predFlagLCol[2];
1300 derive_temporal_luma_vector_prediction(ctx,tctx->img,shdr, xP,yP,nPbW,nPbH,
1301 refIdxCol[0],0, &mvCol[0],
1302 &predFlagLCol[0]);
1303
1304 uint8_t availableFlagCol = predFlagLCol[0];
1305 predFlagLCol[1] = 0;
1306
1307 if (shdr->slice_type == SLICE_TYPE_B) {
1308 derive_temporal_luma_vector_prediction(ctx,tctx->img,shdr,
1309 xP,yP,nPbW,nPbH, refIdxCol[1],1, &mvCol[1],
1310 &predFlagLCol[1]);
1311 availableFlagCol |= predFlagLCol[1];
1312 }
1313
1314
1315 // 4.
1316
1317 PredVectorInfo mergeCandList[5];
1441 int maxCandidates = max_merge_idx+1;
1442 //MotionVectorSpec mergeCandList[5];
13181443 int numMergeCand=0;
13191444
1320 for (int i=0;i<5;i++) {
1321 if (mergeCand.available[i]) {
1322 mergeCandList[numMergeCand++] = mergeCand.pred_vector[i];
1323 }
1324 }
1325
1326 if (availableFlagCol) {
1327 // TODO: save in mergeCand directly...
1328 mergeCand.available[PRED_COL] = availableFlagCol;
1329 mergeCand.pred_vector[PRED_COL].mv[0] = mvCol[0];
1330 mergeCand.pred_vector[PRED_COL].mv[1] = mvCol[1];
1331 mergeCand.pred_vector[PRED_COL].predFlag[0] = predFlagLCol[0];
1332 mergeCand.pred_vector[PRED_COL].predFlag[1] = predFlagLCol[1];
1333 mergeCand.pred_vector[PRED_COL].refIdx[0] = refIdxCol[0];
1334 mergeCand.pred_vector[PRED_COL].refIdx[1] = refIdxCol[1];
1335
1336 mergeCandList[numMergeCand++] = mergeCand.pred_vector[PRED_COL];
1337 }
1338
1339 // 5.
1340
1341 //int numOrigMergeCand = numMergeCand;
1342
1343 // 6.
1344
1345 //int numCombMergeCand = 0;
1445 // --- spatial merge candidates
1446
1447 numMergeCand = derive_spatial_merging_candidates(img, xC,yC, nCS, xP,yP, singleMCLFlag,
1448 nPbW,nPbH,partIdx, mergeCandList,
1449 maxCandidates);
1450
1451 // --- collocated merge candidate
1452 if (numMergeCand < maxCandidates) {
1453 int refIdxCol[2] = { 0,0 };
1454
1455 MotionVector mvCol[2];
1456 uint8_t predFlagLCol[2];
1457 derive_temporal_luma_vector_prediction(ctx,img,shdr, xP,yP,nPbW,nPbH,
1458 refIdxCol[0],0, &mvCol[0],
1459 &predFlagLCol[0]);
1460
1461 uint8_t availableFlagCol = predFlagLCol[0];
1462 predFlagLCol[1] = 0;
1463
1464 if (shdr->slice_type == SLICE_TYPE_B) {
1465 derive_temporal_luma_vector_prediction(ctx,img,shdr,
1466 xP,yP,nPbW,nPbH, refIdxCol[1],1, &mvCol[1],
1467 &predFlagLCol[1]);
1468 availableFlagCol |= predFlagLCol[1];
1469 }
1470
1471
1472 if (availableFlagCol) {
1473 MotionVectorSpec* colVec = &mergeCandList[numMergeCand++];
1474
1475 colVec->mv[0] = mvCol[0];
1476 colVec->mv[1] = mvCol[1];
1477 colVec->predFlag[0] = predFlagLCol[0];
1478 colVec->predFlag[1] = predFlagLCol[1];
1479 colVec->refIdx[0] = refIdxCol[0];
1480 colVec->refIdx[1] = refIdxCol[1];
1481 }
1482 }
1483
1484
1485 // --- bipredictive merge candidates ---
13461486
13471487 if (shdr->slice_type == SLICE_TYPE_B) {
13481488 derive_combined_bipredictive_merging_candidates(ctx, shdr,
1349 mergeCandList, &numMergeCand, numMergeCand);
1350
1351 //numCombMergeCand = numMergeCand - numOrigMergeCand;
1352 }
1353
1354
1355 // 7.
1356
1357 derive_zero_motion_vector_candidates(shdr, mergeCandList, &numMergeCand);
1358
1359 // 8.
1360
1361 int merge_idx = tctx->merge_idx; // get_merge_idx(ctx,xP,yP);
1362 out_vi->lum = mergeCandList[merge_idx];
1489 mergeCandList, &numMergeCand, maxCandidates);
1490 }
1491
1492
1493 // --- zero-vector merge candidates ---
1494
1495 derive_zero_motion_vector_candidates(shdr, mergeCandList, &numMergeCand, maxCandidates);
13631496
13641497
13651498 logtrace(LogMotion,"mergeCandList:\n");
13661499 for (int i=0;i<shdr->MaxNumMergeCand;i++)
13671500 {
1368 logtrace(LogMotion, " %d:%s\n", i, i==merge_idx ? " SELECTED":"");
1501 //logtrace(LogMotion, " %d:%s\n", i, i==merge_idx ? " SELECTED":"");
13691502 logmvcand(mergeCandList[i]);
13701503 }
1371
1372 // 9.
1373
1374 if (out_vi->lum.predFlag[0] && out_vi->lum.predFlag[1] && nOrigPbW+nOrigPbH==12) {
1375 out_vi->lum.refIdx[1] = -1;
1376 out_vi->lum.predFlag[1] = 0;
1377 }
13781504 }
13791505
13801506
1507
1508 void get_merge_candidate_list(base_context* ctx,
1509 const slice_segment_header* shdr,
1510 de265_image* img,
1511 int xC,int yC, int xP,int yP,
1512 int nCS, int nPbW,int nPbH, int partIdx,
1513 MotionVectorSpec* mergeCandList)
1514 {
1515 int max_merge_idx = 5-shdr->five_minus_max_num_merge_cand -1;
1516
1517 get_merge_candidate_list_without_step_9(ctx, shdr, img,
1518 xC,yC,xP,yP,nCS,nPbW,nPbH, partIdx,
1519 max_merge_idx, mergeCandList);
1520
1521 // 9. for encoder: modify all merge candidates
1522
1523 for (int i=0;i<=max_merge_idx;i++) {
1524 if (mergeCandList[i].predFlag[0] &&
1525 mergeCandList[i].predFlag[1] &&
1526 nPbW+nPbH==12)
1527 {
1528 mergeCandList[i].refIdx[1] = -1;
1529 mergeCandList[i].predFlag[1] = 0;
1530 }
1531 }
1532 }
1533
1534
1535
1536 void derive_luma_motion_merge_mode(base_context* ctx,
1537 const slice_segment_header* shdr,
1538 de265_image* img,
1539 int xC,int yC, int xP,int yP,
1540 int nCS, int nPbW,int nPbH, int partIdx,
1541 int merge_idx,
1542 MotionVectorSpec* out_vi)
1543 {
1544 MotionVectorSpec mergeCandList[5];
1545
1546 get_merge_candidate_list_without_step_9(ctx, shdr, img,
1547 xC,yC,xP,yP,nCS,nPbW,nPbH, partIdx,
1548 merge_idx, mergeCandList);
1549
1550
1551 *out_vi = mergeCandList[merge_idx];
1552
1553 // 8.5.3.1.1 / 9.
1554
1555 if (out_vi->predFlag[0] && out_vi->predFlag[1] && nPbW+nPbH==12) {
1556 out_vi->refIdx[1] = -1;
1557 out_vi->predFlag[1] = 0;
1558 }
1559 }
1560
1561
13811562 // 8.5.3.1.6
1382 void derive_spatial_luma_vector_prediction(de265_image* img,
1563 void derive_spatial_luma_vector_prediction(base_context* ctx,
1564 de265_image* img,
13831565 const slice_segment_header* shdr,
13841566 int xC,int yC,int nCS,int xP,int yP,
13851567 int nPbW,int nPbH, int X,
13871569 uint8_t out_availableFlagLXN[2],
13881570 MotionVector out_mvLXN[2])
13891571 {
1390 const decoder_context* ctx = img->decctx;
1391
13921572 int isScaledFlagLX = 0;
13931573
13941574 const int A=0;
13951575 const int B=1;
1576
1577 out_availableFlagLXN[A] = 0;
1578 out_availableFlagLXN[B] = 0;
1579
13961580
13971581 // --- A ---
13981582
14271611 int refIdxA=-1;
14281612
14291613 // the POC we want to reference in this PB
1430 const int referenced_POC = ctx->get_image(shdr->RefPicList[X][ refIdxLX ])->PicOrderCntVal;
1431
1432 const int referenced_refIdx = refIdxLX;
1614 const de265_image* tmpimg = ctx->get_image(shdr->RefPicList[X][ refIdxLX ]);
1615 if (tmpimg==NULL) { return; }
1616 const int referenced_POC = tmpimg->PicOrderCntVal;
14331617
14341618 for (int k=0;k<=1;k++) {
14351619 if (availableA[k] &&
14371621 img->get_pred_mode(xA[k],yA[k]) != MODE_INTRA) {
14381622
14391623 int Y=1-X;
1440
1441 const PredVectorInfo* vi = img->get_mv_info(xA[k],yA[k]);
1624
1625 const MotionVectorSpec* vi = img->get_mv_info(xA[k],yA[k]);
14421626 logtrace(LogMotion,"MVP A%d=\n",k);
14431627 logmvcand(*vi);
14441628
1629 const de265_image* imgX = NULL;
1630 if (vi->predFlag[X]) imgX = ctx->get_image(shdr->RefPicList[X][ vi->refIdx[X] ]);
1631 const de265_image* imgY = NULL;
1632 if (vi->predFlag[Y]) imgY = ctx->get_image(shdr->RefPicList[Y][ vi->refIdx[Y] ]);
1633
14451634 // check whether the predictor X is available and references the same POC
1446 if (vi->predFlag[X] &&
1447 ctx->get_image(shdr->RefPicList[X][ vi->refIdx[X] ])->PicOrderCntVal == referenced_POC) {
1448 //vi->refIdx[X] == referenced_refIdx) {
1635 if (vi->predFlag[X] && imgX && imgX->PicOrderCntVal == referenced_POC) {
14491636
14501637 logtrace(LogMotion,"take A%d/L%d as A candidate with same POC\n",k,X);
14511638
14541641 refIdxA = vi->refIdx[X];
14551642 }
14561643 // check whether the other predictor (Y) is available and references the same POC
1457 else if (vi->predFlag[Y] &&
1458 ctx->get_image(shdr->RefPicList[Y][ vi->refIdx[Y] ])->PicOrderCntVal == referenced_POC) {
1459 //vi->refIdx[Y] == referenced_refIdx) {
1644 else if (vi->predFlag[Y] && imgY && imgY->PicOrderCntVal == referenced_POC) {
14601645
14611646 logtrace(LogMotion,"take A%d/L%d as A candidate with same POC\n",k,Y);
14621647
14781663 img->get_pred_mode(xA[k],yA[k]) != MODE_INTRA) {
14791664
14801665 int Y=1-X;
1481
1482 const PredVectorInfo* vi = img->get_mv_info(xA[k],yA[k]);
1666
1667 const MotionVectorSpec* vi = img->get_mv_info(xA[k],yA[k]);
14831668 if (vi->predFlag[X]==1 &&
14841669 shdr->LongTermRefPic[X][refIdxLX] == shdr->LongTermRefPic[X][ vi->refIdx[X] ]) {
14851670
15031688 }
15041689
15051690 if (out_availableFlagLXN[A]==1) {
1691 if (refIdxA<0) {
1692 out_availableFlagLXN[0] = out_availableFlagLXN[1] = false;
1693 return; // error
1694 }
1695
15061696 assert(refIdxA>=0);
15071697 assert(refPicList>=0);
15081698
15091699 const de265_image* refPicA = ctx->get_image(shdr->RefPicList[refPicList][refIdxA ]);
15101700 const de265_image* refPicX = ctx->get_image(shdr->RefPicList[X ][refIdxLX]);
15111701
1512 int picStateA = shdr->RefPicList_PicState[refPicList][refIdxA ];
1513 int picStateX = shdr->RefPicList_PicState[X ][refIdxLX];
1702 //int picStateA = shdr->RefPicList_PicState[refPicList][refIdxA ];
1703 //int picStateX = shdr->RefPicList_PicState[X ][refIdxLX];
15141704
15151705 int isLongTermA = shdr->LongTermRefPic[refPicList][refIdxA ];
15161706 int isLongTermX = shdr->LongTermRefPic[X ][refIdxLX];
15261716 {
15271717 int distA = img->PicOrderCntVal - refPicA->PicOrderCntVal;
15281718 int distX = img->PicOrderCntVal - referenced_POC;
1529
1719
15301720 if (!scale_mv(&out_mvLXN[A], out_mvLXN[A], distA, distX)) {
1531 img->decctx->add_warning(DE265_WARNING_INCORRECT_MOTION_VECTOR_SCALING, false);
1721 ctx->add_warning(DE265_WARNING_INCORRECT_MOTION_VECTOR_SCALING, false);
15321722 img->integrity = INTEGRITY_DECODING_ERRORS;
15331723 }
15341724 }
15631753 availableB[k] = img->available_pred_blk(xC,yC, nCS, xP,yP, nPbW,nPbH,partIdx, xB[k],yB[k]);
15641754
15651755 if (availableB[k] && out_availableFlagLXN[B]==0) {
1566
1756
15671757 int Y=1-X;
1568
1569 const PredVectorInfo* vi = img->get_mv_info(xB[k],yB[k]);
1758
1759 const MotionVectorSpec* vi = img->get_mv_info(xB[k],yB[k]);
15701760 logtrace(LogMotion,"MVP B%d=\n",k);
15711761 logmvcand(*vi);
15721762
15731763
1574 if (vi->predFlag[X] &&
1575 ctx->get_image(shdr->RefPicList[X][ vi->refIdx[X] ])->PicOrderCntVal == referenced_POC) {
1764 const de265_image* imgX = NULL;
1765 if (vi->predFlag[X]) imgX = ctx->get_image(shdr->RefPicList[X][ vi->refIdx[X] ]);
1766 const de265_image* imgY = NULL;
1767 if (vi->predFlag[Y]) imgY = ctx->get_image(shdr->RefPicList[Y][ vi->refIdx[Y] ]);
1768
1769 if (vi->predFlag[X] && imgX && imgX->PicOrderCntVal == referenced_POC) {
15761770 logtrace(LogMotion,"a) take B%d/L%d as B candidate with same POC\n",k,X);
15771771
15781772 out_availableFlagLXN[B]=1;
15791773 out_mvLXN[B] = vi->mv[X];
15801774 refIdxB = vi->refIdx[X];
15811775 }
1582 else if (vi->predFlag[Y] &&
1583 ctx->get_image(shdr->RefPicList[Y][ vi->refIdx[Y] ])->PicOrderCntVal == referenced_POC) {
1776 else if (vi->predFlag[Y] && imgY && imgY->PicOrderCntVal == referenced_POC) {
15841777 logtrace(LogMotion,"b) take B%d/L%d as B candidate with same POC\n",k,Y);
15851778
15861779 out_availableFlagLXN[B]=1;
16171810
16181811 if (availableB[k]) {
16191812 int Y=1-X;
1620
1621 const PredVectorInfo* vi = img->get_mv_info(xB[k],yB[k]);
1813
1814 const MotionVectorSpec* vi = img->get_mv_info(xB[k],yB[k]);
16221815
16231816 if (vi->predFlag[X]==1 &&
16241817 shdr->LongTermRefPic[X][refIdxLX] == shdr->LongTermRefPic[X][ vi->refIdx[X] ]) {
16371830 }
16381831
16391832 if (out_availableFlagLXN[B]==1) {
1833 if (refIdxB<0) {
1834 out_availableFlagLXN[0] = out_availableFlagLXN[1] = false;
1835 return; // error
1836 }
1837
16401838 assert(refPicList>=0);
16411839 assert(refIdxB>=0);
16421840
1643 const de265_image* refPicB=img->decctx->get_image(shdr->RefPicList[refPicList][refIdxB ]);
1644 const de265_image* refPicX=img->decctx->get_image(shdr->RefPicList[X ][refIdxLX]);
1841 const de265_image* refPicB=ctx->get_image(shdr->RefPicList[refPicList][refIdxB ]);
1842 const de265_image* refPicX=ctx->get_image(shdr->RefPicList[X ][refIdxLX]);
16451843
16461844 int isLongTermB = shdr->LongTermRefPic[refPicList][refIdxB ];
16471845 int isLongTermX = shdr->LongTermRefPic[X ][refIdxLX];
16481846
1649 if (refPicB->PicOrderCntVal != refPicX->PicOrderCntVal &&
1650 !isLongTermB && !isLongTermX) {
1847 if (refPicB==NULL || refPicX==NULL) {
1848 img->decctx->add_warning(DE265_WARNING_NONEXISTING_REFERENCE_PICTURE_ACCESSED,false);
1849 img->integrity = INTEGRITY_DECODING_ERRORS;
1850 }
1851 else if (refPicB->PicOrderCntVal != refPicX->PicOrderCntVal &&
1852 !isLongTermB && !isLongTermX) {
16511853 int distB = img->PicOrderCntVal - refPicB->PicOrderCntVal;
16521854 int distX = img->PicOrderCntVal - referenced_POC;
16531855
16541856 logtrace(LogMotion,"scale MVP B: B-POC:%d X-POC:%d\n",refPicB->PicOrderCntVal,refPicX->PicOrderCntVal);
16551857
16561858 if (!scale_mv(&out_mvLXN[B], out_mvLXN[B], distB, distX)) {
1657 img->decctx->add_warning(DE265_WARNING_INCORRECT_MOTION_VECTOR_SCALING, false);
1859 ctx->add_warning(DE265_WARNING_INCORRECT_MOTION_VECTOR_SCALING, false);
16581860 img->integrity = INTEGRITY_DECODING_ERRORS;
16591861 }
16601862 }
16631865 }
16641866 }
16651867
1868
16661869 // 8.5.3.1.5
1667 MotionVector luma_motion_vector_prediction(decoder_context* ctx,
1668 thread_context* tctx,
1870 void fill_luma_motion_vector_predictors(base_context* ctx,
1871 const slice_segment_header* shdr,
1872 de265_image* img,
1873 int xC,int yC,int nCS,int xP,int yP,
1874 int nPbW,int nPbH, int l,
1875 int refIdx, int partIdx,
1876 MotionVector out_mvpList[2])
1877 {
1878 // 8.5.3.1.6: derive two spatial vector predictors A (0) and B (1)
1879
1880 uint8_t availableFlagLXN[2];
1881 MotionVector mvLXN[2];
1882
1883 derive_spatial_luma_vector_prediction(ctx, img, shdr, xC,yC, nCS, xP,yP,
1884 nPbW,nPbH, l, refIdx, partIdx,
1885 availableFlagLXN, mvLXN);
1886
1887 // 8.5.3.1.7: if we only have one spatial vector or both spatial vectors are the same,
1888 // derive a temporal predictor
1889
1890 uint8_t availableFlagLXCol;
1891 MotionVector mvLXCol;
1892
1893
1894 if (availableFlagLXN[0] &&
1895 availableFlagLXN[1] &&
1896 (mvLXN[0].x != mvLXN[1].x || mvLXN[0].y != mvLXN[1].y)) {
1897 availableFlagLXCol = 0;
1898 }
1899 else {
1900 derive_temporal_luma_vector_prediction(ctx, img, shdr,
1901 xP,yP, nPbW,nPbH, refIdx,l,
1902 &mvLXCol, &availableFlagLXCol);
1903 }
1904
1905
1906 // --- build candidate vector list with exactly two entries ---
1907
1908 int numMVPCandLX=0;
1909
1910 // spatial predictor A
1911
1912 if (availableFlagLXN[0])
1913 {
1914 out_mvpList[numMVPCandLX++] = mvLXN[0];
1915 }
1916
1917 // spatial predictor B (if not same as A)
1918
1919 if (availableFlagLXN[1] &&
1920 (!availableFlagLXN[0] || // in case A in not available, but mvLXA initialized to same as mvLXB
1921 (mvLXN[0].x != mvLXN[1].x || mvLXN[0].y != mvLXN[1].y)))
1922 {
1923 out_mvpList[numMVPCandLX++] = mvLXN[1];
1924 }
1925
1926 // temporal predictor
1927
1928 if (availableFlagLXCol)
1929 {
1930 out_mvpList[numMVPCandLX++] = mvLXCol;
1931 }
1932
1933 // fill with zero predictors
1934
1935 while (numMVPCandLX<2) {
1936 out_mvpList[numMVPCandLX].x = 0;
1937 out_mvpList[numMVPCandLX].y = 0;
1938 numMVPCandLX++;
1939 }
1940
1941
1942 assert(numMVPCandLX==2);
1943 }
1944
1945
1946 MotionVector luma_motion_vector_prediction(base_context* ctx,
1947 const slice_segment_header* shdr,
1948 de265_image* img,
1949 const motion_spec& motion,
16691950 int xC,int yC,int nCS,int xP,int yP,
16701951 int nPbW,int nPbH, int l,
16711952 int refIdx, int partIdx)
16721953 {
1673 const slice_segment_header* shdr = tctx->shdr;
1674
1675
1676 // 8.5.3.1.6: derive two spatial vector predictors A (0) and B (1)
1677
1678 uint8_t availableFlagLXN[2];
1679 MotionVector mvLXN[2];
1680
1681 derive_spatial_luma_vector_prediction(tctx->img, shdr, xC,yC, nCS, xP,yP, nPbW,nPbH, l, refIdx, partIdx,
1682 availableFlagLXN, mvLXN);
1683
1684 // 8.5.3.1.7: if we only have one spatial vector or both spatial vectors are the same,
1685 // derive a temporal predictor
1686
1687 uint8_t availableFlagLXCol;
1688 MotionVector mvLXCol;
1689
1690
1691 if (availableFlagLXN[0] &&
1692 availableFlagLXN[1] &&
1693 (mvLXN[0].x != mvLXN[1].x || mvLXN[0].y != mvLXN[1].y)) {
1694 availableFlagLXCol = 0;
1695 }
1696 else {
1697 derive_temporal_luma_vector_prediction(ctx, tctx->img, shdr, xP,yP, nPbW,nPbH, refIdx,l,
1698 &mvLXCol, &availableFlagLXCol);
1699 }
1700
1701
1702 // --- build candidate vector list with exactly two entries ---
1703
1704 int numMVPCandLX=0;
1705
1706 // spatial predictor A
1707
1708 MotionVector mvpList[3];
1709 if (availableFlagLXN[0])
1710 {
1711 mvpList[numMVPCandLX++] = mvLXN[0];
1712 }
1713
1714 // spatial predictor B (if not same as A)
1715
1716 if (availableFlagLXN[1] &&
1717 (!availableFlagLXN[0] || // in case A in not available, but mvLXA initialized to same as mvLXB
1718 (mvLXN[0].x != mvLXN[1].x || mvLXN[0].y != mvLXN[1].y)))
1719 {
1720 mvpList[numMVPCandLX++] = mvLXN[1];
1721 }
1722
1723 // temporal predictor
1724
1725 if (availableFlagLXCol)
1726 {
1727 mvpList[numMVPCandLX++] = mvLXCol;
1728 }
1729
1730 // fill with zero predictors
1731
1732 while (numMVPCandLX<2) {
1733 mvpList[numMVPCandLX].x = 0;
1734 mvpList[numMVPCandLX].y = 0;
1735 numMVPCandLX++;
1736 }
1737
1954 MotionVector mvpList[2];
1955
1956 fill_luma_motion_vector_predictors(ctx, shdr, img,
1957 xC,yC,nCS,xP,yP,
1958 nPbW, nPbH, l, refIdx, partIdx,
1959 mvpList);
17381960
17391961 // select predictor according to mvp_lX_flag
17401962
1741 return mvpList[ tctx->mvp_lX_flag[l] ];
1963 return mvpList[ l ? motion.mvp_l1_flag : motion.mvp_l0_flag ];
17421964 }
17431965
1966
17441967 #if DE265_LOG_TRACE
1745 void logMV(int x0,int y0,int nPbW,int nPbH, const char* mode,const VectorInfo* mv)
1968 void logMV(int x0,int y0,int nPbW,int nPbH, const char* mode,const MotionVectorSpec* mv)
17461969 {
1747 int pred0 = mv->lum.predFlag[0];
1748 int pred1 = mv->lum.predFlag[1];
1970 int pred0 = mv->predFlag[0];
1971 int pred1 = mv->predFlag[1];
17491972
17501973 logtrace(LogMotion,
17511974 "*MV %d;%d [%d;%d] %s: (%d) %d;%d @%d (%d) %d;%d @%d\n", x0,y0,nPbW,nPbH,mode,
17521975 pred0,
1753 pred0 ? mv->lum.mv[0].x : 0,pred0 ? mv->lum.mv[0].y : 0, pred0 ? mv->lum.refIdx[0] : 0,
1976 pred0 ? mv->mv[0].x : 0,pred0 ? mv->mv[0].y : 0, pred0 ? mv->refIdx[0] : 0,
17541977 pred1,
1755 pred1 ? mv->lum.mv[1].x : 0,pred1 ? mv->lum.mv[1].y : 0, pred1 ? mv->lum.refIdx[1] : 0);
1978 pred1 ? mv->mv[1].x : 0,pred1 ? mv->mv[1].y : 0, pred1 ? mv->refIdx[1] : 0);
17561979 }
17571980 #else
17581981 #define logMV(x0,y0,nPbW,nPbH,mode,mv)
17611984
17621985
17631986 // 8.5.3.1
1764 void motion_vectors_and_ref_indices(decoder_context* ctx,
1765 thread_context* tctx,
1766 int xC,int yC, int xB,int yB, int nCS, int nPbW,int nPbH, int partIdx,
1767 VectorInfo* out_vi)
1987 void motion_vectors_and_ref_indices(base_context* ctx,
1988 const slice_segment_header* shdr,
1989 de265_image* img,
1990 const motion_spec& motion,
1991 int xC,int yC, int xB,int yB, int nCS, int nPbW,int nPbH,
1992 int partIdx,
1993 MotionVectorSpec* out_vi)
17681994 {
17691995 //slice_segment_header* shdr = tctx->shdr;
17701996
17711997 int xP = xC+xB;
17721998 int yP = yC+yB;
17731999
1774 enum PredMode predMode = tctx->img->get_pred_mode(xC,yC);
2000 enum PredMode predMode = img->get_pred_mode(xC,yC);
17752001
17762002 if (predMode == MODE_SKIP ||
1777 (predMode == MODE_INTER && tctx->merge_flag))
2003 (predMode == MODE_INTER && motion.merge_flag))
17782004 {
1779 derive_luma_motion_merge_mode(ctx,tctx, xC,yC, xP,yP, nCS,nPbW,nPbH, partIdx, out_vi);
2005 derive_luma_motion_merge_mode(ctx,shdr,img,
2006 xC,yC, xP,yP, nCS,nPbW,nPbH, partIdx,
2007 motion.merge_idx, out_vi);
17802008
17812009 logMV(xP,yP,nPbW,nPbH, "merge_mode", out_vi);
17822010 }
17872015 for (int l=0;l<2;l++) {
17882016 // 1.
17892017
1790 enum InterPredIdc inter_pred_idc = (enum InterPredIdc)tctx->inter_pred_idc;
2018 enum InterPredIdc inter_pred_idc = (enum InterPredIdc)motion.inter_pred_idc;
17912019
17922020 if (inter_pred_idc == PRED_BI ||
17932021 (inter_pred_idc == PRED_L0 && l==0) ||
17942022 (inter_pred_idc == PRED_L1 && l==1)) {
1795 out_vi->lum.refIdx[l] = tctx->refIdx[l];
1796 out_vi->lum.predFlag[l] = 1;
2023 out_vi->refIdx[l] = motion.refIdx[l];
2024 out_vi->predFlag[l] = 1;
17972025 }
17982026 else {
1799 out_vi->lum.refIdx[l] = -1;
1800 out_vi->lum.predFlag[l] = 0;
2027 out_vi->refIdx[l] = -1;
2028 out_vi->predFlag[l] = 0;
18012029 }
18022030
18032031 // 2.
18042032
1805 mvdL[l][0] = tctx->mvd[l][0];
1806 mvdL[l][1] = tctx->mvd[l][1];
1807
1808
1809 if (out_vi->lum.predFlag[l]) {
2033 mvdL[l][0] = motion.mvd[l][0];
2034 mvdL[l][1] = motion.mvd[l][1];
2035
2036
2037 if (out_vi->predFlag[l]) {
18102038 // 3.
18112039
1812 mvpL[l] = luma_motion_vector_prediction(ctx,tctx,xC,yC,nCS,xP,yP, nPbW,nPbH, l,
1813 out_vi->lum.refIdx[l], partIdx);
2040 mvpL[l] = luma_motion_vector_prediction(ctx,shdr,img,motion,
2041 xC,yC,nCS,xP,yP, nPbW,nPbH, l,
2042 out_vi->refIdx[l], partIdx);
18142043
18152044 // 4.
18162045
18172046 int32_t x = (mvpL[l].x + mvdL[l][0] + 0x10000) & 0xFFFF;
18182047 int32_t y = (mvpL[l].y + mvdL[l][1] + 0x10000) & 0xFFFF;
18192048
1820 out_vi->lum.mv[l].x = (x>=0x8000) ? x-0x10000 : x;
1821 out_vi->lum.mv[l].y = (y>=0x8000) ? y-0x10000 : y;
2049 out_vi->mv[l].x = (x>=0x8000) ? x-0x10000 : x;
2050 out_vi->mv[l].y = (y>=0x8000) ? y-0x10000 : y;
18222051 }
18232052 }
18242053
18282057
18292058
18302059 // 8.5.3
1831 void decode_prediction_unit(thread_context* tctx,
2060 void decode_prediction_unit(base_context* ctx,
2061 const slice_segment_header* shdr,
2062 de265_image* img,
2063 const motion_spec& motion,
18322064 int xC,int yC, int xB,int yB, int nCS, int nPbW,int nPbH, int partIdx)
18332065 {
18342066 logtrace(LogMotion,"decode_prediction_unit POC=%d %d;%d %dx%d\n",
1835 tctx->img->PicOrderCntVal, xC+xB,yC+yB, nPbW,nPbH);
1836
1837 slice_segment_header* shdr = tctx->shdr;
2067 img->PicOrderCntVal, xC+xB,yC+yB, nPbW,nPbH);
2068
2069 //slice_segment_header* shdr = tctx->shdr;
18382070
18392071 // 1.
18402072
1841 VectorInfo vi;
1842 motion_vectors_and_ref_indices(tctx->decctx,tctx, xC,yC, xB,yB, nCS, nPbW,nPbH, partIdx, &vi);
2073 MotionVectorSpec vi;
2074 motion_vectors_and_ref_indices(ctx, shdr, img, motion,
2075 xC,yC, xB,yB, nCS, nPbW,nPbH, partIdx, &vi);
18432076
18442077 // 2.
18452078
1846 generate_inter_prediction_samples(tctx->decctx,tctx->img, shdr, xC,yC, xB,yB, nCS, nPbW,nPbH, &vi);
1847
1848
1849 tctx->img->set_mv_info(xC+xB,yC+yB,nPbW,nPbH, &vi.lum);
2079 generate_inter_prediction_samples(ctx,shdr, img, xC,yC, xB,yB, nCS, nPbW,nPbH, &vi);
2080
2081
2082 img->set_mv_info(xC+xB,yC+yB,nPbW,nPbH, vi);
18502083 }
1851
2222
2323 #include <stdint.h>
2424
25 class base_context;
26 class slice_segment_header;
2527
2628 typedef struct
2729 {
3133
3234 typedef struct
3335 {
34 int8_t refIdx[2];
35 uint8_t predFlag[2];
36 MotionVector mv[2];
37 } PredVectorInfo;
36 uint8_t predFlag[2]; // which of the two vectors is actually used
37 int8_t refIdx[2];
38 MotionVector mv[2];
39 } MotionVectorSpec;
3840
3941
40 typedef struct
41 {
42 PredVectorInfo lum;
43 MotionVector mvC[2];
44 } VectorInfo;
42 typedef struct {
43 int8_t refIdx[2];
44 int16_t mvd[2][2]; // [L0/L1][x/y] (only in top left position - ???)
45
46 uint8_t inter_pred_idc : 2; // enum InterPredIdc
47 uint8_t mvp_l0_flag : 1;
48 uint8_t mvp_l1_flag : 1;
49 uint8_t merge_flag : 1;
50 uint8_t merge_idx : 3;
51 } motion_spec;
4552
4653
47 void decode_prediction_unit(struct thread_context* shdr,
54 void get_merge_candidate_list(base_context* ctx,
55 const slice_segment_header* shdr,
56 struct de265_image* img,
57 int xC,int yC, int xP,int yP,
58 int nCS, int nPbW,int nPbH, int partIdx,
59 MotionVectorSpec* mergeCandList);
60
61 /*
62 int derive_spatial_merging_candidates(const struct de265_image* img,
63 int xC, int yC, int nCS, int xP, int yP,
64 uint8_t singleMCLFlag,
65 int nPbW, int nPbH,
66 int partIdx,
67 MotionVectorSpec* out_cand,
68 int maxCandidates);
69 */
70
71 void generate_inter_prediction_samples(base_context* ctx,
72 const slice_segment_header* shdr,
73 struct de265_image* img,
74 int xC,int yC,
75 int xB,int yB,
76 int nCS, int nPbW,int nPbH,
77 const MotionVectorSpec* vi);
78
79
80 /* Fill list (two entries) of motion-vector predictors for MVD coding.
81 */
82 void fill_luma_motion_vector_predictors(base_context* ctx,
83 const slice_segment_header* shdr,
84 de265_image* img,
85 int xC,int yC,int nCS,int xP,int yP,
86 int nPbW,int nPbH, int l,
87 int refIdx, int partIdx,
88 MotionVector out_mvpList[2]);
89
90
91 void decode_prediction_unit(base_context* ctx,const slice_segment_header* shdr,
92 de265_image* img, const motion_spec& motion,
4893 int xC,int yC, int xB,int yB, int nCS, int nPbW,int nPbH, int partIdx);
4994
50 void inter_prediction(struct decoder_context* ctx,struct slice_segment_header* shdr,
51 int xC,int yC, int log2CbSize);
52
5395 #endif
5757 skipped_bytes.clear();
5858 }
5959
60 void NAL_unit::resize(int new_size)
60 LIBDE265_CHECK_RESULT bool NAL_unit::resize(int new_size)
6161 {
6262 if (capacity < new_size) {
6363 unsigned char* newbuffer = (unsigned char*)malloc(new_size);
64 if (newbuffer == NULL) {
65 return false;
66 }
6467
6568 if (nal_data != NULL) {
6669 memcpy(newbuffer, nal_data, data_size);
7073 nal_data = newbuffer;
7174 capacity = new_size;
7275 }
73 }
74
75 void NAL_unit::append(const unsigned char* in_data, int n)
76 {
77 resize(data_size + n);
76 return true;
77 }
78
79 LIBDE265_CHECK_RESULT bool NAL_unit::append(const unsigned char* in_data, int n)
80 {
81 if (!resize(data_size + n)) {
82 return false;
83 }
7884 memcpy(nal_data + data_size, in_data, n);
7985 data_size += n;
80 }
81
82 void NAL_unit::set_data(const unsigned char* in_data, int n)
83 {
84 resize(n);
86 return true;
87 }
88
89 bool LIBDE265_CHECK_RESULT NAL_unit::set_data(const unsigned char* in_data, int n)
90 {
91 if (!resize(n)) {
92 return false;
93 }
8594 memcpy(nal_data, in_data, n);
8695 data_size = n;
96 return true;
8797 }
8898
8999 void NAL_unit::insert_skipped_byte(int pos)
176186 }
177187
178188
179 NAL_unit* NAL_Parser::alloc_NAL_unit(int size)
189 LIBDE265_CHECK_RESULT NAL_unit* NAL_Parser::alloc_NAL_unit(int size)
180190 {
181191 NAL_unit* nal;
182192
191201 }
192202
193203 nal->clear();
194 nal->resize(size);
204 if (!nal->resize(size)) {
205 free_NAL_unit(nal);
206 return NULL;
207 }
195208
196209 return nal;
197210 }
198211
199212 void NAL_Parser::free_NAL_unit(NAL_unit* nal)
200213 {
214 if (nal == NULL) {
215 // Allow calling with NULL just like regular "free()"
216 return;
217 }
201218 if (NAL_free_list.size() < DE265_NAL_FREE_LIST_SIZE) {
202219 NAL_free_list.push_back(nal);
203220 }
234251
235252 if (pending_input_NAL == NULL) {
236253 pending_input_NAL = alloc_NAL_unit(len+3);
254 if (pending_input_NAL == NULL) {
255 return DE265_ERROR_OUT_OF_MEMORY;
256 }
237257 pending_input_NAL->pts = pts;
238258 pending_input_NAL->user_data = user_data;
239259 }
242262
243263 // Resize output buffer so that complete input would fit.
244264 // We add 3, because in the worst case 3 extra bytes are created for an input byte.
245 nal->resize(nal->size() + len + 3);
265 if (!nal->resize(nal->size() + len + 3)) {
266 return DE265_ERROR_OUT_OF_MEMORY;
267 }
246268
247269 unsigned char* out = nal->data() + nal->size();
248270
315337 // initialize new, empty NAL unit
316338
317339 pending_input_NAL = alloc_NAL_unit(len+3);
340 if (pending_input_NAL == NULL) {
341 return DE265_ERROR_OUT_OF_MEMORY;
342 }
318343 pending_input_NAL->pts = pts;
319344 pending_input_NAL->user_data = user_data;
320345 nal = pending_input_NAL;
351376 end_of_frame = false;
352377
353378 NAL_unit* nal = alloc_NAL_unit(len);
354 nal->set_data(data, len);
379 if (nal == NULL || !nal->set_data(data, len)) {
380 free_NAL_unit(nal);
381 return DE265_ERROR_OUT_OF_MEMORY;
382 }
355383 nal->pts = pts;
356384 nal->user_data = user_data;
357385
371399
372400 // append bytes that are implied by the push state
373401
374 if (input_push_state==6) { nal->append(null,1); }
375 if (input_push_state==7) { nal->append(null,2); }
402 if (input_push_state==6) {
403 if (!nal->append(null,1)) {
404 return DE265_ERROR_OUT_OF_MEMORY;
405 }
406 }
407 if (input_push_state==7) {
408 if (!nal->append(null,2)) {
409 return DE265_ERROR_OUT_OF_MEMORY;
410 }
411 }
376412
377413
378414 // only push the NAL if it contains at least the NAL header
2323 #include "libde265/sps.h"
2424 #include "libde265/pps.h"
2525 #include "libde265/nal.h"
26 #include "libde265/util.h"
2627
2728 #include <vector>
2829 #include <queue>
4647
4748 // --- rbsp data ---
4849
49 void resize(int new_size);
50 void append(const unsigned char* data, int n);
51 void set_data(const unsigned char* data, int n);
50 LIBDE265_CHECK_RESULT bool resize(int new_size);
51 LIBDE265_CHECK_RESULT bool append(const unsigned char* data, int n);
52 LIBDE265_CHECK_RESULT bool set_data(const unsigned char* data, int n);
5253
5354 int size() const { return data_size; }
5455 void set_size(int s) { data_size=s; }
8990 ~NAL_Parser();
9091
9192 de265_error push_data(const unsigned char* data, int len,
92 de265_PTS pts, void* user_data);
93 de265_PTS pts, void* user_data = NULL);
9394
9495 de265_error push_NAL(const unsigned char* data, int len,
95 de265_PTS pts, void* user_data);
96 de265_PTS pts, void* user_data = NULL);
9697
9798 NAL_unit* pop_from_NAL_queue();
98 void push_to_NAL_queue(NAL_unit*);
9999 de265_error flush_data();
100100 void mark_end_of_stream() { end_of_stream=true; }
101101 void mark_end_of_frame() { end_of_frame=true; }
111111 int size = NAL_queue.size();
112112 if (pending_input_NAL) { size++; }
113113 return size;
114 }
115
116 int number_of_complete_NAL_units_pending() const {
117 return NAL_queue.size();
114118 }
115119
116120 void free_NAL_unit(NAL_unit*);
135139 std::queue<NAL_unit*> NAL_queue; // enqueued NALs have suffing bytes removed
136140 int nBytes_in_NAL_queue; // data bytes currently in NAL_queue
137141
142 void push_to_NAL_queue(NAL_unit*);
143
138144
139145 // pool of unused NAL memory
140146
141147 std::vector<NAL_unit*> NAL_free_list; // maximum size: DE265_NAL_FREE_LIST_SIZE
142148
143 NAL_unit* alloc_NAL_unit(int size);
149 LIBDE265_CHECK_RESULT NAL_unit* alloc_NAL_unit(int size);
144150 };
145151
146152
1818 */
1919
2020 #include "nal.h"
21 #include "cabac.h"
2122 #include <assert.h>
2223
2324
24 void nal_read_header(bitreader* reader, nal_header* hdr)
25 void nal_header::read(bitreader* reader)
2526 {
2627 skip_bits(reader,1);
27 hdr->nal_unit_type = get_bits(reader,6);
28 hdr->nuh_layer_id = get_bits(reader,6);
29 hdr->nuh_temporal_id = get_bits(reader,3) -1;
28 nal_unit_type = get_bits(reader,6);
29 nuh_layer_id = get_bits(reader,6);
30 nuh_temporal_id = get_bits(reader,3) -1;
31 }
32
33
34 void nal_header::write(CABAC_encoder& out) const
35 {
36 out.skip_bits(1);
37 out.write_bits(nal_unit_type,6);
38 out.write_bits(nuh_layer_id ,6);
39 out.write_bits(nuh_temporal_id+1,3);
3040 }
3141
3242
7989 (unit_type <= NAL_UNIT_RESERVED_IRAP_VCL23)) );
8090 }
8191
92 bool isSublayerNonReference(uint8_t unit_type)
93 {
94 switch (unit_type) {
95 case NAL_UNIT_TRAIL_N:
96 case NAL_UNIT_TSA_N:
97 case NAL_UNIT_STSA_N:
98 case NAL_UNIT_RADL_N:
99 case NAL_UNIT_RASL_N:
100 case NAL_UNIT_RESERVED_VCL_N10:
101 case NAL_UNIT_RESERVED_VCL_N12:
102 case NAL_UNIT_RESERVED_VCL_N14:
103 return true;
104
105 default:
106 return false;
107 }
108 }
82109
83110 static const char* NAL_unit_name[] = {
84111 "TRAIL_N", // 0
133160
134161 const char* get_NAL_name(uint8_t unit_type)
135162 {
136 assert(unit_type <= 47);
163 if (unit_type >= 48) { return "INVALID NAL >= 48"; }
137164 return NAL_unit_name[unit_type];
138165 }
139
3030 #endif
3131
3232 #include "libde265/bitstream.h"
33 #include "libde265/cabac.h"
3334
3435 struct nal_header {
3536 nal_header() {
3839 nuh_temporal_id = 0;
3940 }
4041
41 int nal_unit_type;
42 int nuh_layer_id;
43 int nuh_temporal_id;
42 void read(bitreader* reader);
43 void write(CABAC_encoder& writer) const;
44
45 void set(int unit_type, int layer_id=0, int temporal_id=0) {
46 nal_unit_type =unit_type;
47 nuh_layer_id =layer_id;
48 nuh_temporal_id=temporal_id;
49 }
50
51 uint8_t nal_unit_type;
52 uint8_t nuh_layer_id;
53 uint8_t nuh_temporal_id;
4454 };
4555
4656 #define NAL_UNIT_TRAIL_N 0
94104
95105 #define NAL_UNIT_UNDEFINED 255
96106
97 void nal_read_header(bitreader* reader, nal_header*);
98
99107 bool isIDR(uint8_t unit_type);
100108 bool isBLA(uint8_t unit_type);
101109 bool isCRA(uint8_t unit_type);
104112 bool isIRAP(uint8_t unit_type);
105113 bool isRADL(uint8_t unit_type);
106114 bool isReferenceNALU(uint8_t unit_type);
115 bool isSublayerNonReference(uint8_t unit_type);
107116
108117 const char* get_NAL_name(uint8_t unit_type);
109118
119 inline bool isIdrPic(uint8_t nal_unit_type) {
120 return (nal_unit_type == NAL_UNIT_IDR_W_RADL ||
121 nal_unit_type == NAL_UNIT_IDR_N_LP);
122 }
123
124 inline bool isRapPic(uint8_t nal_unit_type) {
125 return nal_unit_type >= 16 && nal_unit_type <= 23;
126 }
127
110128 #endif
3131 #endif
3232
3333
34 void pps_range_extension::reset()
35 {
36 log2_max_transform_skip_block_size = 2;
37 cross_component_prediction_enabled_flag = false;
38 chroma_qp_offset_list_enabled_flag = false;
39 diff_cu_chroma_qp_offset_depth = 0;
40 chroma_qp_offset_list_len = 0;
41 log2_sao_offset_scale_luma = 0;
42 log2_sao_offset_scale_chroma = 0;
43 }
44
45
46 bool pps_range_extension::read(bitreader* br, decoder_context* ctx, const pic_parameter_set* pps)
47 {
48 const seq_parameter_set* sps = ctx->get_sps(pps->seq_parameter_set_id);
49
50 int uvlc;
51
52 if (pps->transform_skip_enabled_flag) {
53 uvlc = get_uvlc(br);
54 if (uvlc == UVLC_ERROR ||
55 uvlc+2 > sps->Log2MaxTrafoSize) {
56
57 // Note: this is out of spec, but the conformance stream
58 // PERSIST_RPARAM_A_RExt_Sony_2 codes a too large value.
59
60 //ctx->add_warning(DE265_WARNING_PPS_HEADER_INVALID, false);
61 //return false;
62 }
63
64 log2_max_transform_skip_block_size = uvlc+2;
65 }
66
67 cross_component_prediction_enabled_flag = get_bits(br,1);
68 if (sps->ChromaArrayType != CHROMA_444 &&
69 cross_component_prediction_enabled_flag) {
70 ctx->add_warning(DE265_WARNING_PPS_HEADER_INVALID, false);
71 }
72
73 chroma_qp_offset_list_enabled_flag = get_bits(br,1);
74 if (sps->ChromaArrayType == CHROMA_MONO &&
75 chroma_qp_offset_list_enabled_flag) {
76 ctx->add_warning(DE265_WARNING_PPS_HEADER_INVALID, false);
77 }
78
79 if (chroma_qp_offset_list_enabled_flag) {
80 uvlc = get_uvlc(br);
81 if (uvlc == UVLC_ERROR ||
82 uvlc > sps->log2_diff_max_min_luma_coding_block_size) {
83 ctx->add_warning(DE265_WARNING_PPS_HEADER_INVALID, false);
84 return false;
85 }
86
87 diff_cu_chroma_qp_offset_depth = uvlc;
88
89
90 uvlc = get_uvlc(br);
91 if (uvlc == UVLC_ERROR ||
92 uvlc > 5) {
93 ctx->add_warning(DE265_WARNING_PPS_HEADER_INVALID, false);
94 return false;
95 }
96
97 chroma_qp_offset_list_len = uvlc+1;
98
99 for (int i=0;i<chroma_qp_offset_list_len;i++) {
100 int svlc;
101 svlc = get_svlc(br);
102 if (svlc == UVLC_ERROR ||
103 svlc < -12 || svlc > 12) {
104 ctx->add_warning(DE265_WARNING_PPS_HEADER_INVALID, false);
105 return false;
106 }
107
108 cb_qp_offset_list[i] = svlc;
109
110 svlc = get_svlc(br);
111 if (svlc == UVLC_ERROR ||
112 svlc < -12 || svlc > 12) {
113 ctx->add_warning(DE265_WARNING_PPS_HEADER_INVALID, false);
114 return false;
115 }
116
117 cr_qp_offset_list[i] = svlc;
118 }
119 }
120
121
122 uvlc = get_uvlc(br);
123 if (uvlc == UVLC_ERROR ||
124 uvlc > libde265_max(0, sps->BitDepth_Y-10)) {
125 ctx->add_warning(DE265_WARNING_PPS_HEADER_INVALID, false);
126 return false;
127 }
128
129 log2_sao_offset_scale_luma = uvlc;
130
131 uvlc = get_uvlc(br);
132 if (uvlc == UVLC_ERROR ||
133 uvlc > libde265_max(0, sps->BitDepth_C-10)) {
134 ctx->add_warning(DE265_WARNING_PPS_HEADER_INVALID, false);
135 return false;
136 }
137
138 log2_sao_offset_scale_chroma = uvlc;
139
140 return true;
141 }
142
143
144 void pps_range_extension::dump(int fd) const
145 {
146 FILE* fh;
147 if (fd==1) fh=stdout;
148 else if (fd==2) fh=stderr;
149 else { return; }
150
151 #define LOG0(t) log2fh(fh, t)
152 #define LOG1(t,d) log2fh(fh, t,d)
153 #define LOG2(t,d,e) log2fh(fh, t,d,e)
154
155 LOG0("---------- PPS range-extension ----------\n");
156 LOG1("log2_max_transform_skip_block_size : %d\n", log2_max_transform_skip_block_size);
157 LOG1("cross_component_prediction_enabled_flag : %d\n", cross_component_prediction_enabled_flag);
158 LOG1("chroma_qp_offset_list_enabled_flag : %d\n", chroma_qp_offset_list_enabled_flag);
159 if (chroma_qp_offset_list_enabled_flag) {
160 LOG1("diff_cu_chroma_qp_offset_depth : %d\n", diff_cu_chroma_qp_offset_depth);
161 LOG1("chroma_qp_offset_list_len : %d\n", chroma_qp_offset_list_len);
162 for (int i=0;i<chroma_qp_offset_list_len;i++) {
163 LOG2("cb_qp_offset_list[%d] : %d\n", i,cb_qp_offset_list[i]);
164 LOG2("cr_qp_offset_list[%d] : %d\n", i,cr_qp_offset_list[i]);
165 }
166 }
167
168 LOG1("log2_sao_offset_scale_luma : %d\n", log2_sao_offset_scale_luma);
169 LOG1("log2_sao_offset_scale_chroma : %d\n", log2_sao_offset_scale_chroma);
170 #undef LOG2
171 #undef LOG1
172 #undef LOG0
173 }
174
175
176
177
178
34179 pic_parameter_set::pic_parameter_set()
35180 {
181 reset();
182 }
183
184
185 pic_parameter_set::~pic_parameter_set()
186 {
187 }
188
189
190 void pic_parameter_set::set_defaults(enum PresetSet)
191 {
36192 pps_read = false;
37 }
38
39
40 pic_parameter_set::~pic_parameter_set()
41 {
193
194 pic_parameter_set_id = 0;
195 seq_parameter_set_id = 0;
196 dependent_slice_segments_enabled_flag = 0;
197 sign_data_hiding_flag = 0;
198 cabac_init_present_flag = 0;
199 num_ref_idx_l0_default_active = 1;
200 num_ref_idx_l1_default_active = 1;
201
202 pic_init_qp = 27;
203 constrained_intra_pred_flag = 0;
204 transform_skip_enabled_flag = 0;
205
206 cu_qp_delta_enabled_flag = 0;
207 diff_cu_qp_delta_depth = 0;
208
209 pic_cb_qp_offset = 0;
210 pic_cr_qp_offset = 0;
211 pps_slice_chroma_qp_offsets_present_flag = 0;
212 weighted_pred_flag = 0;
213 weighted_bipred_flag= 0;
214 output_flag_present_flag = 0;
215 transquant_bypass_enable_flag = 0;
216 entropy_coding_sync_enabled_flag = 0;
217
218 // --- tiles ---
219
220 tiles_enabled_flag = 0;
221 num_tile_columns = 1;
222 num_tile_rows = 1;
223 uniform_spacing_flag = 1;
224
225
226 // --- ---
227
228 loop_filter_across_tiles_enabled_flag = 1;
229 pps_loop_filter_across_slices_enabled_flag = 1;
230
231 for (int i=0;i<DE265_MAX_TILE_COLUMNS;i++) { colWidth[i]=0; }
232 for (int i=0;i<DE265_MAX_TILE_ROWS;i++) { rowHeight[i]=0; }
233 for (int i=0;i<=DE265_MAX_TILE_COLUMNS;i++) { colBd[i]=0; }
234 for (int i=0;i<=DE265_MAX_TILE_ROWS;i++) { rowBd[i]=0; }
235
236 CtbAddrRStoTS.clear();
237 CtbAddrTStoRS.clear();
238 TileId.clear();
239 TileIdRS.clear();
240 MinTbAddrZS.clear();
241
242
243 Log2MinCuQpDeltaSize = 0;
244
245 deblocking_filter_control_present_flag = 0;
246 deblocking_filter_override_enabled_flag = 0;
247 pic_disable_deblocking_filter_flag = 0;
248
249 beta_offset = 0;
250 tc_offset = 0;
251
252 pic_scaling_list_data_present_flag = 0;
253 // TODO struct scaling_list_data scaling_list;
254
255 lists_modification_present_flag = 0;
256 log2_parallel_merge_level = 2;
257
258 num_extra_slice_header_bits = 0;
259 slice_segment_header_extension_present_flag = 0;
260 pps_extension_flag = 0;
261
262 pps_range_extension_flag = 0;
263 pps_multilayer_extension_flag = 0;
264 pps_extension_6bits = 0;
42265 }
43266
44267
45268 bool pic_parameter_set::read(bitreader* br, decoder_context* ctx)
46269 {
47 pps_read = false; // incomplete pps
270 reset();
271
48272
49273 int uvlc;
50274 pic_parameter_set_id = uvlc = get_uvlc(br);
160384
161385 lastColumnWidth -= colWidth[i];
162386 }
387
388 if (lastColumnWidth <= 0) {
389 return false;
390 }
163391
164392 colWidth[num_tile_columns-1] = lastColumnWidth;
165393
174402 lastRowHeight -= rowHeight[i];
175403 }
176404
405 if (lastRowHeight <= 0) {
406 return false;
407 }
408
409
177410 rowHeight[num_tile_rows-1] = lastRowHeight;
178411 }
179412
188421
189422
190423
191 if (uniform_spacing_flag) {
192
193 // set columns widths
194
195 int *const colPos = (int *)alloca((num_tile_columns+1) * sizeof(int));
196
197 for (int i=0;i<=num_tile_columns;i++) {
198 colPos[i] = i*sps->PicWidthInCtbsY / num_tile_columns;
199 }
200 for (int i=0;i<num_tile_columns;i++) {
201 colWidth[i] = colPos[i+1] - colPos[i];
202 }
203
204 // set row heights
205
206 int *const rowPos = (int *)alloca((num_tile_rows+1) * sizeof(int));
207
208 for (int i=0;i<=num_tile_rows;i++) {
209 rowPos[i] = i*sps->PicHeightInCtbsY / num_tile_rows;
210 }
211 for (int i=0;i<num_tile_rows;i++) {
212 rowHeight[i] = rowPos[i+1] - rowPos[i];
213 }
214 }
215
216
217 // set tile boundaries
218
219 colBd[0]=0;
220 for (int i=0;i<num_tile_columns;i++) {
221 colBd[i+1] = colBd[i] + colWidth[i];
222 }
223
224 rowBd[0]=0;
225 for (int i=0;i<num_tile_rows;i++) {
226 rowBd[i+1] = rowBd[i] + rowHeight[i];
227 }
228
229
230
231 // alloc raster scan arrays
232
233 CtbAddrRStoTS.resize(sps->PicSizeInCtbsY);
234 CtbAddrTStoRS.resize(sps->PicSizeInCtbsY);
235 TileId .resize(sps->PicSizeInCtbsY);
236 TileIdRS .resize(sps->PicSizeInCtbsY);
237 MinTbAddrZS .resize(sps->PicSizeInTbsY );
238
239
240 // raster scan (RS) <-> tile scan (TS) conversion
241
242 for (int ctbAddrRS=0 ; ctbAddrRS < sps->PicSizeInCtbsY ; ctbAddrRS++)
243 {
244 int tbX = ctbAddrRS % sps->PicWidthInCtbsY;
245 int tbY = ctbAddrRS / sps->PicWidthInCtbsY;
246 int tileX=-1,tileY=-1;
247
248 for (int i=0;i<num_tile_columns;i++)
249 if (tbX >= colBd[i])
250 tileX=i;
251
252 for (int j=0;j<num_tile_rows;j++)
253 if (tbY >= rowBd[j])
254 tileY=j;
255
256 CtbAddrRStoTS[ctbAddrRS] = 0;
257 for (int i=0;i<tileX;i++)
258 CtbAddrRStoTS[ctbAddrRS] += rowHeight[tileY]*colWidth[i];
259
260 for (int j=0;j<tileY;j++)
261 {
262 //pps->CtbAddrRStoTS[ctbAddrRS] += (tbY - pps->rowBd[tileY])*pps->colWidth[tileX];
263 //pps->CtbAddrRStoTS[ctbAddrRS] += tbX - pps->colBd[tileX];
264
265 CtbAddrRStoTS[ctbAddrRS] += sps->PicWidthInCtbsY * rowHeight[j];
266 }
267
268 assert(tileX>=0 && tileY>=0);
269
270 CtbAddrRStoTS[ctbAddrRS] += (tbY-rowBd[tileY])*colWidth[tileX];
271 CtbAddrRStoTS[ctbAddrRS] += tbX - colBd[tileX];
272
273
274 // inverse mapping
275
276 CtbAddrTStoRS[ CtbAddrRStoTS[ctbAddrRS] ] = ctbAddrRS;
277 }
278
279
280 logtrace(LogHeaders,"6.5.1 CtbAddrRSToTS\n");
281 for (int y=0;y<sps->PicHeightInCtbsY;y++)
282 {
283 for (int x=0;x<sps->PicWidthInCtbsY;x++)
284 {
285 logtrace(LogHeaders,"%3d ", CtbAddrRStoTS[x + y*sps->PicWidthInCtbsY]);
286 }
287
288 logtrace(LogHeaders,"\n");
289 }
290
291
292 // tile id
293
294 for (int j=0, tIdx=0 ; j<num_tile_rows ; j++)
295 for (int i=0 ; i<num_tile_columns;i++)
296 {
297 for (int y=rowBd[j] ; y<rowBd[j+1] ; y++)
298 for (int x=colBd[i] ; x<colBd[i+1] ; x++) {
299 TileId [ CtbAddrRStoTS[y*sps->PicWidthInCtbsY + x] ] = tIdx;
300 TileIdRS[ y*sps->PicWidthInCtbsY + x ] = tIdx;
301
302 //logtrace(LogHeaders,"tileID[%d,%d] = %d\n",x,y,pps->TileIdRS[ y*sps->PicWidthInCtbsY + x ]);
303 }
304
305 tIdx++;
306 }
307
308 logtrace(LogHeaders,"Tile IDs RS:\n");
309 for (int y=0;y<sps->PicHeightInCtbsY;y++) {
310 for (int x=0;x<sps->PicWidthInCtbsY;x++) {
311 logtrace(LogHeaders,"%2d ",TileIdRS[y*sps->PicWidthInCtbsY+x]);
312 }
313 logtrace(LogHeaders,"\n");
314 }
315
316 // 6.5.2 Z-scan order array initialization process
317
318 for (int y=0;y<sps->PicHeightInTbsY;y++)
319 for (int x=0;x<sps->PicWidthInTbsY;x++)
320 {
321 int tbX = (x<<sps->Log2MinTrafoSize)>>sps->Log2CtbSizeY;
322 int tbY = (y<<sps->Log2MinTrafoSize)>>sps->Log2CtbSizeY;
323 int ctbAddrRS = sps->PicWidthInCtbsY*tbY + tbX;
324
325 MinTbAddrZS[x + y*sps->PicWidthInTbsY] = CtbAddrRStoTS[ctbAddrRS]
326 << ((sps->Log2CtbSizeY-sps->Log2MinTrafoSize)*2);
327
328 int p=0;
329 for (int i=0 ; i<(sps->Log2CtbSizeY - sps->Log2MinTrafoSize) ; i++) {
330 int m=1<<i;
331 p += (m & x ? m*m : 0) + (m & y ? 2*m*m : 0);
332 }
333
334 MinTbAddrZS[x + y*sps->PicWidthInTbsY] += p;
335 }
336
337
338 // --- debug logging ---
339
340 /*
341 logtrace(LogHeaders,"6.5.2 Z-scan order array\n");
342 for (int y=0;y<sps->PicHeightInTbsY;y++)
343 {
344 for (int x=0;x<sps->PicWidthInTbsY;x++)
345 {
346 logtrace(LogHeaders,"%4d ", pps->MinTbAddrZS[x + y*sps->PicWidthInTbsY]);
347 }
348
349 logtrace(LogHeaders,"\n");
350 }
351
352 for (int i=0;i<sps->PicSizeInTbsY;i++)
353 {
354 for (int y=0;y<sps->PicHeightInTbsY;y++)
355 {
356 for (int x=0;x<sps->PicWidthInTbsY;x++)
357 {
358 if (pps->MinTbAddrZS[x + y*sps->PicWidthInTbsY] == i) {
359 logtrace(LogHeaders,"%d %d\n",x,y);
360 }
361 }
362 }
363 }
364 */
365
366424 // END tiles
367425
368
369 Log2MinCuQpDeltaSize = sps->Log2CtbSizeY - diff_cu_qp_delta_depth;
370426
371427
372428 beta_offset = 0; // default value
433489 }
434490 log2_parallel_merge_level += 2;
435491
492 if (log2_parallel_merge_level-2 > sps->log2_min_luma_coding_block_size-3 +1 +
493 sps->log2_diff_max_min_luma_coding_block_size) {
494 return false;
495 }
496
436497 slice_segment_header_extension_present_flag = get_bits(br,1);
437498 pps_extension_flag = get_bits(br,1);
499
500 if (pps_extension_flag) {
501 pps_range_extension_flag = get_bits(br,1);
502 pps_multilayer_extension_flag = get_bits(br,1);
503 pps_extension_6bits = get_bits(br,6);
504
505 if (pps_range_extension_flag) {
506 bool success = range_extension.read(br, ctx, this);
507 if (!success) {
508 return false;
509 }
510 }
511
512 //assert(false);
513 /*
514 while( more_rbsp_data() )
515
516 pps_extension_data_flag
517 u(1)
518 rbsp_trailing_bits()
519
520 }
521 */
522 }
523
524
525 set_derived_values(sps);
526
527 pps_read = true;
528
529 return true;
530 }
531
532
533 void pic_parameter_set::set_derived_values(const seq_parameter_set* sps)
534 {
535 Log2MinCuQpDeltaSize = sps->Log2CtbSizeY - diff_cu_qp_delta_depth;
536
537 Log2MinCuChromaQpOffsetSize = sps->Log2CtbSizeY - range_extension.diff_cu_chroma_qp_offset_depth;
538 Log2MaxTransformSkipSize = range_extension.log2_max_transform_skip_block_size;
539
540 if (uniform_spacing_flag) {
541
542 // set columns widths
543
544 int *const colPos = (int *)alloca((num_tile_columns+1) * sizeof(int));
545
546 for (int i=0;i<=num_tile_columns;i++) {
547 colPos[i] = i*sps->PicWidthInCtbsY / num_tile_columns;
548 }
549 for (int i=0;i<num_tile_columns;i++) {
550 colWidth[i] = colPos[i+1] - colPos[i];
551 }
552
553 // set row heights
554
555 int *const rowPos = (int *)alloca((num_tile_rows+1) * sizeof(int));
556
557 for (int i=0;i<=num_tile_rows;i++) {
558 rowPos[i] = i*sps->PicHeightInCtbsY / num_tile_rows;
559 }
560 for (int i=0;i<num_tile_rows;i++) {
561 rowHeight[i] = rowPos[i+1] - rowPos[i];
562 }
563 }
564
565
566 // set tile boundaries
567
568 colBd[0]=0;
569 for (int i=0;i<num_tile_columns;i++) {
570 colBd[i+1] = colBd[i] + colWidth[i];
571 }
572
573 rowBd[0]=0;
574 for (int i=0;i<num_tile_rows;i++) {
575 rowBd[i+1] = rowBd[i] + rowHeight[i];
576 }
577
578
579
580 // alloc raster scan arrays
581
582 CtbAddrRStoTS.resize(sps->PicSizeInCtbsY);
583 CtbAddrTStoRS.resize(sps->PicSizeInCtbsY);
584 TileId .resize(sps->PicSizeInCtbsY);
585 TileIdRS .resize(sps->PicSizeInCtbsY);
586 MinTbAddrZS .resize(sps->PicSizeInTbsY );
587
588
589 // raster scan (RS) <-> tile scan (TS) conversion
590
591 for (int ctbAddrRS=0 ; ctbAddrRS < sps->PicSizeInCtbsY ; ctbAddrRS++)
592 {
593 int tbX = ctbAddrRS % sps->PicWidthInCtbsY;
594 int tbY = ctbAddrRS / sps->PicWidthInCtbsY;
595 int tileX=-1,tileY=-1;
596
597 for (int i=0;i<num_tile_columns;i++)
598 if (tbX >= colBd[i])
599 tileX=i;
600
601 for (int j=0;j<num_tile_rows;j++)
602 if (tbY >= rowBd[j])
603 tileY=j;
604
605 CtbAddrRStoTS[ctbAddrRS] = 0;
606 for (int i=0;i<tileX;i++)
607 CtbAddrRStoTS[ctbAddrRS] += rowHeight[tileY]*colWidth[i];
608
609 for (int j=0;j<tileY;j++)
610 {
611 //pps->CtbAddrRStoTS[ctbAddrRS] += (tbY - pps->rowBd[tileY])*pps->colWidth[tileX];
612 //pps->CtbAddrRStoTS[ctbAddrRS] += tbX - pps->colBd[tileX];
613
614 CtbAddrRStoTS[ctbAddrRS] += sps->PicWidthInCtbsY * rowHeight[j];
615 }
616
617 assert(tileX>=0 && tileY>=0);
618
619 CtbAddrRStoTS[ctbAddrRS] += (tbY-rowBd[tileY])*colWidth[tileX];
620 CtbAddrRStoTS[ctbAddrRS] += tbX - colBd[tileX];
621
622
623 // inverse mapping
624
625 CtbAddrTStoRS[ CtbAddrRStoTS[ctbAddrRS] ] = ctbAddrRS;
626 }
627
628
629 #if 0
630 logtrace(LogHeaders,"6.5.1 CtbAddrRSToTS\n");
631 for (int y=0;y<sps->PicHeightInCtbsY;y++)
632 {
633 for (int x=0;x<sps->PicWidthInCtbsY;x++)
634 {
635 logtrace(LogHeaders,"%3d ", CtbAddrRStoTS[x + y*sps->PicWidthInCtbsY]);
636 }
637
638 logtrace(LogHeaders,"\n");
639 }
640 #endif
641
642 // tile id
643
644 for (int j=0, tIdx=0 ; j<num_tile_rows ; j++)
645 for (int i=0 ; i<num_tile_columns;i++)
646 {
647 for (int y=rowBd[j] ; y<rowBd[j+1] ; y++)
648 for (int x=colBd[i] ; x<colBd[i+1] ; x++) {
649 TileId [ CtbAddrRStoTS[y*sps->PicWidthInCtbsY + x] ] = tIdx;
650 TileIdRS[ y*sps->PicWidthInCtbsY + x ] = tIdx;
651
652 //logtrace(LogHeaders,"tileID[%d,%d] = %d\n",x,y,pps->TileIdRS[ y*sps->PicWidthInCtbsY + x ]);
653 }
654
655 tIdx++;
656 }
657
658 #if 0
659 logtrace(LogHeaders,"Tile IDs RS:\n");
660 for (int y=0;y<sps->PicHeightInCtbsY;y++) {
661 for (int x=0;x<sps->PicWidthInCtbsY;x++) {
662 logtrace(LogHeaders,"%2d ",TileIdRS[y*sps->PicWidthInCtbsY+x]);
663 }
664 logtrace(LogHeaders,"\n");
665 }
666 #endif
667
668 // 6.5.2 Z-scan order array initialization process
669
670 for (int y=0;y<sps->PicHeightInTbsY;y++)
671 for (int x=0;x<sps->PicWidthInTbsY;x++)
672 {
673 int tbX = (x<<sps->Log2MinTrafoSize)>>sps->Log2CtbSizeY;
674 int tbY = (y<<sps->Log2MinTrafoSize)>>sps->Log2CtbSizeY;
675 int ctbAddrRS = sps->PicWidthInCtbsY*tbY + tbX;
676
677 MinTbAddrZS[x + y*sps->PicWidthInTbsY] = CtbAddrRStoTS[ctbAddrRS]
678 << ((sps->Log2CtbSizeY-sps->Log2MinTrafoSize)*2);
679
680 int p=0;
681 for (int i=0 ; i<(sps->Log2CtbSizeY - sps->Log2MinTrafoSize) ; i++) {
682 int m=1<<i;
683 p += (m & x ? m*m : 0) + (m & y ? 2*m*m : 0);
684 }
685
686 MinTbAddrZS[x + y*sps->PicWidthInTbsY] += p;
687 }
688
689
690 // --- debug logging ---
691
692 /*
693 logtrace(LogHeaders,"6.5.2 Z-scan order array\n");
694 for (int y=0;y<sps->PicHeightInTbsY;y++)
695 {
696 for (int x=0;x<sps->PicWidthInTbsY;x++)
697 {
698 logtrace(LogHeaders,"%4d ", pps->MinTbAddrZS[x + y*sps->PicWidthInTbsY]);
699 }
700
701 logtrace(LogHeaders,"\n");
702 }
703
704 for (int i=0;i<sps->PicSizeInTbsY;i++)
705 {
706 for (int y=0;y<sps->PicHeightInTbsY;y++)
707 {
708 for (int x=0;x<sps->PicWidthInTbsY;x++)
709 {
710 if (pps->MinTbAddrZS[x + y*sps->PicWidthInTbsY] == i) {
711 logtrace(LogHeaders,"%d %d\n",x,y);
712 }
713 }
714 }
715 }
716 */
717 }
718
719
720 bool pic_parameter_set::write(error_queue* errqueue, CABAC_encoder& out,
721 const seq_parameter_set* sps)
722 {
723 if (pic_parameter_set_id >= DE265_MAX_PPS_SETS) {
724 errqueue->add_warning(DE265_WARNING_NONEXISTING_PPS_REFERENCED, false);
725 return false;
726 }
727 out.write_uvlc(pic_parameter_set_id);
728
729 if (seq_parameter_set_id >= DE265_MAX_PPS_SETS) {
730 errqueue->add_warning(DE265_WARNING_NONEXISTING_SPS_REFERENCED, false);
731 return false;
732 }
733 out.write_uvlc(seq_parameter_set_id);
734
735 out.write_bit(dependent_slice_segments_enabled_flag);
736 out.write_bit(output_flag_present_flag);
737 out.write_bits(num_extra_slice_header_bits,3);
738 out.write_bit(sign_data_hiding_flag);
739 out.write_bit(cabac_init_present_flag);
740 out.write_uvlc(num_ref_idx_l0_default_active-1);
741 out.write_uvlc(num_ref_idx_l1_default_active-1);
742
743 out.write_svlc(pic_init_qp-26);
744
745 out.write_bit(constrained_intra_pred_flag);
746 out.write_bit(transform_skip_enabled_flag);
747 out.write_bit(cu_qp_delta_enabled_flag);
748
749 if (cu_qp_delta_enabled_flag) {
750 out.write_uvlc(diff_cu_qp_delta_depth);
751 }
752
753 out.write_svlc(pic_cb_qp_offset);
754 out.write_svlc(pic_cr_qp_offset);
755
756 out.write_bit(pps_slice_chroma_qp_offsets_present_flag);
757 out.write_bit(weighted_pred_flag);
758 out.write_bit(weighted_bipred_flag);
759 out.write_bit(transquant_bypass_enable_flag);
760 out.write_bit(tiles_enabled_flag);
761 out.write_bit(entropy_coding_sync_enabled_flag);
762
763
764 // --- tiles ---
765
766 if (tiles_enabled_flag) {
767 if (num_tile_columns > DE265_MAX_TILE_COLUMNS) {
768 errqueue->add_warning(DE265_WARNING_PPS_HEADER_INVALID, false);
769 return false;
770 }
771 out.write_uvlc(num_tile_columns-1);
772
773 if (num_tile_rows > DE265_MAX_TILE_ROWS) {
774 errqueue->add_warning(DE265_WARNING_PPS_HEADER_INVALID, false);
775 return false;
776 }
777 out.write_uvlc(num_tile_rows-1);
778
779 out.write_bit(uniform_spacing_flag);
780
781 if (uniform_spacing_flag==false) {
782 for (int i=0; i<num_tile_columns-1; i++)
783 {
784 out.write_uvlc(colWidth[i]-1);
785 }
786
787 for (int i=0; i<num_tile_rows-1; i++)
788 {
789 out.write_uvlc(rowHeight[i]-1);
790 }
791 }
792
793 out.write_bit(loop_filter_across_tiles_enabled_flag);
794 }
795
796
797 out.write_bit(pps_loop_filter_across_slices_enabled_flag);
798 out.write_bit(deblocking_filter_control_present_flag);
799
800 if (deblocking_filter_control_present_flag) {
801 out.write_bit(deblocking_filter_override_enabled_flag);
802 out.write_bit(pic_disable_deblocking_filter_flag);
803
804 if (!pic_disable_deblocking_filter_flag) {
805 out.write_svlc(beta_offset/2);
806 out.write_svlc(tc_offset /2);
807 }
808 }
809
810
811 // --- scaling list ---
812
813 out.write_bit(pic_scaling_list_data_present_flag);
814
815 // check consistency: if scaling-lists are not enabled, pic_scalign_list_data_present_flag
816 // must be FALSE
817 if (sps->scaling_list_enable_flag==0 &&
818 pic_scaling_list_data_present_flag != 0) {
819 errqueue->add_warning(DE265_WARNING_PPS_HEADER_INVALID, false);
820 return false;
821 }
822
823 if (pic_scaling_list_data_present_flag) {
824 de265_error err = write_scaling_list(out, sps, &scaling_list, true);
825 if (err != DE265_OK) {
826 errqueue->add_warning(err, false);
827 return false;
828 }
829 }
830
831
832
833 out.write_bit(lists_modification_present_flag);
834 out.write_uvlc(log2_parallel_merge_level-2);
835
836 out.write_bit(slice_segment_header_extension_present_flag);
837 out.write_bit(pps_extension_flag);
438838
439839 if (pps_extension_flag) {
440840 //assert(false);
456856 }
457857
458858
459 void pic_parameter_set::dump_pps(int fd) const
859 void pic_parameter_set::dump(int fd) const
460860 {
461861 FILE* fh;
462862 if (fd==1) fh=stdout;
535935 LOG1("pic_disable_deblocking_filter_flag: %d\n", pic_disable_deblocking_filter_flag);
536936
537937 LOG1("beta_offset: %d\n", beta_offset);
538 LOG1("tc_offset: %d\n", tc_offset);
938 LOG1("tc_offset: %d\n", tc_offset);
539939 }
540940
541941 LOG1("pic_scaling_list_data_present_flag: %d\n", pic_scaling_list_data_present_flag);
547947 LOG1("log2_parallel_merge_level : %d\n", log2_parallel_merge_level);
548948 LOG1("num_extra_slice_header_bits : %d\n", num_extra_slice_header_bits);
549949 LOG1("slice_segment_header_extension_present_flag : %d\n", slice_segment_header_extension_present_flag);
550 LOG1("pps_extension_flag : %d\n", pps_extension_flag);
551
552 LOG1("Log2MinCuQpDeltaSize : %d\n", Log2MinCuQpDeltaSize);
950 LOG1("pps_extension_flag : %d\n", pps_extension_flag);
951 LOG1("pps_range_extension_flag : %d\n", pps_range_extension_flag);
952 LOG1("pps_multilayer_extension_flag : %d\n", pps_multilayer_extension_flag);
953 LOG1("pps_extension_6bits : %d\n", pps_extension_6bits);
954
955 LOG1("Log2MinCuQpDeltaSize : %d\n", Log2MinCuQpDeltaSize);
956 LOG1("Log2MinCuChromaQpOffsetSize (RExt) : %d\n", Log2MinCuChromaQpOffsetSize);
957 LOG1("Log2MaxTransformSkipSize (RExt) : %d\n", Log2MaxTransformSkipSize);
553958
554959 #undef LOG0
555960 #undef LOG1
961
962
963 if (pps_range_extension_flag) {
964 range_extension.dump(fd);
965 }
556966 }
557967
558968
2828 #define DE265_MAX_TILE_COLUMNS 10
2929 #define DE265_MAX_TILE_ROWS 10
3030
31 class decoder_context;
32 class pic_parameter_set;
3133
32 struct pic_parameter_set {
34
35 class pps_range_extension
36 {
37 public:
38 pps_range_extension() { reset(); }
39
40 void reset();
41
42 bool read(bitreader*, decoder_context*, const pic_parameter_set*);
43 void dump(int fd) const;
44
45 uint8_t log2_max_transform_skip_block_size;
46 bool cross_component_prediction_enabled_flag;
47 bool chroma_qp_offset_list_enabled_flag;
48 uint8_t diff_cu_chroma_qp_offset_depth;
49 uint8_t chroma_qp_offset_list_len;
50 int8_t cb_qp_offset_list[6];
51 int8_t cr_qp_offset_list[6];
52 uint8_t log2_sao_offset_scale_luma;
53 uint8_t log2_sao_offset_scale_chroma;
54 };
55
56
57 class pic_parameter_set {
58 public:
3359 pic_parameter_set();
3460 ~pic_parameter_set();
3561
36 bool read(bitreader*, struct decoder_context*);
62 void reset() { set_defaults(); }
63 bool read(bitreader*, decoder_context*);
64 bool write(error_queue*, CABAC_encoder&,
65 const seq_parameter_set* sps);
3766
3867 bool is_tile_start_CTB(int ctbX,int ctbY) const;
39 void dump_pps(int fd) const;
68 void dump(int fd) const;
4069
70
71 void set_defaults(enum PresetSet = Preset_Default);
4172
4273 bool pps_read; // whether this pps has been read from bitstream
4374
4677 char dependent_slice_segments_enabled_flag;
4778 char sign_data_hiding_flag;
4879 char cabac_init_present_flag;
49 char num_ref_idx_l0_default_active;
50 char num_ref_idx_l1_default_active;
80 char num_ref_idx_l0_default_active; // [1;16]
81 char num_ref_idx_l1_default_active; // [1;16]
5182
5283 int pic_init_qp;
5384 char constrained_intra_pred_flag;
5485 char transform_skip_enabled_flag;
5586
56 // if ( cu_qp_delta_enabled_flag )
87 // --- QP ---
88
5789 char cu_qp_delta_enabled_flag;
58 int diff_cu_qp_delta_depth;
90 int diff_cu_qp_delta_depth; // [ 0 ; log2_diff_max_min_luma_coding_block_size ]
5991
6092 int pic_cb_qp_offset;
6193 int pic_cr_qp_offset;
6294 char pps_slice_chroma_qp_offsets_present_flag;
95
96
6397 char weighted_pred_flag;
6498 char weighted_bipred_flag;
6599 char output_flag_present_flag;
69103
70104 // --- tiles ---
71105
72 //if( tiles_enabled_flag ) {
73106 char tiles_enabled_flag;
74 int num_tile_columns;
75 int num_tile_rows;
107 int num_tile_columns; // [1;PicWidthInCtbsY]
108 int num_tile_rows; // [1;PicHeightInCtbsY]
76109 char uniform_spacing_flag;
77110
78 // derived values
79 int colWidth [ DE265_MAX_TILE_COLUMNS ];
80 int rowHeight[ DE265_MAX_TILE_ROWS ];
81 int colBd [ DE265_MAX_TILE_COLUMNS+1 ];
82 int rowBd [ DE265_MAX_TILE_ROWS+1 ];
83
84 std::vector<int> CtbAddrRStoTS; // #CTBs
85 std::vector<int> CtbAddrTStoRS; // #CTBs
86 std::vector<int> TileId; // #CTBs // index in tile-scan order
87 std::vector<int> TileIdRS; // #CTBs // index in raster-scan order
88 std::vector<int> MinTbAddrZS; // #TBs [x + y*PicWidthInTbsY]
89
90
91 // --- QP ---
92
93 int Log2MinCuQpDeltaSize;
94111
95112 // --- ---
96113
97114 char loop_filter_across_tiles_enabled_flag;
98
99115 char pps_loop_filter_across_slices_enabled_flag;
100116 char deblocking_filter_control_present_flag;
101117
109125 struct scaling_list_data scaling_list; // contains valid data if sps->scaling_list_enabled_flag set
110126
111127 char lists_modification_present_flag;
112 int log2_parallel_merge_level;
128 int log2_parallel_merge_level; // [2 ; log2(max CB size)]
113129 char num_extra_slice_header_bits;
114130 char slice_segment_header_extension_present_flag;
115131 char pps_extension_flag;
132 char pps_range_extension_flag;
133 char pps_multilayer_extension_flag;
134 char pps_extension_6bits;
116135
136 pps_range_extension range_extension;
137
138
139 // --- derived values ---
140
141 int Log2MinCuQpDeltaSize;
142 int Log2MinCuChromaQpOffsetSize;
143 int Log2MaxTransformSkipSize;
144
145 int colWidth [ DE265_MAX_TILE_COLUMNS ];
146 int rowHeight[ DE265_MAX_TILE_ROWS ];
147 int colBd [ DE265_MAX_TILE_COLUMNS+1 ];
148 int rowBd [ DE265_MAX_TILE_ROWS+1 ];
149
150 std::vector<int> CtbAddrRStoTS; // #CTBs
151 std::vector<int> CtbAddrTStoRS; // #CTBs
152 std::vector<int> TileId; // #CTBs // index in tile-scan order
153 std::vector<int> TileIdRS; // #CTBs // index in raster-scan order
154 std::vector<int> MinTbAddrZS; // #TBs [x + y*PicWidthInTbsY]
155
156 void set_derived_values(const seq_parameter_set* sps);
117157 };
118158
119159 #endif
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * This file is part of libde265.
5 *
6 * libde265 is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation, either version 3 of
9 * the License, or (at your option) any later version.
10 *
11 * libde265 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
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with libde265. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "quality.h"
21 #include <math.h>
22
23
24 uint32_t SSD(const uint8_t* img, int imgStride,
25 const uint8_t* ref, int refStride,
26 int width, int height)
27 {
28 uint32_t sum=0;
29
30 const uint8_t* iPtr = img;
31 const uint8_t* rPtr = ref;
32
33 for (int y=0;y<height;y++) {
34 for (int x=0;x<width;x++) {
35 int diff = iPtr[x] - rPtr[x];
36 sum += diff*diff;
37 }
38
39 iPtr += imgStride;
40 rPtr += refStride;
41 }
42
43 return sum;
44 }
45
46
47 uint32_t SAD(const uint8_t* img, int imgStride,
48 const uint8_t* ref, int refStride,
49 int width, int height)
50 {
51 uint32_t sum=0;
52
53 const uint8_t* iPtr = img;
54 const uint8_t* rPtr = ref;
55
56 for (int y=0;y<height;y++) {
57 for (int x=0;x<width;x++) {
58 int diff = iPtr[x] - rPtr[x];
59 sum += abs_value(diff);
60 }
61
62 iPtr += imgStride;
63 rPtr += refStride;
64 }
65
66 return sum;
67 }
68
69
70 double MSE(const uint8_t* img, int imgStride,
71 const uint8_t* ref, int refStride,
72 int width, int height)
73 {
74 double sum=0.0;
75
76 const uint8_t* iPtr = img;
77 const uint8_t* rPtr = ref;
78
79 for (int y=0;y<height;y++) {
80 uint32_t lineSum=0;
81
82 for (int x=0;x<width;x++) {
83 int diff = iPtr[x] - rPtr[x];
84 lineSum += diff*diff;
85 }
86
87 sum += ((double)lineSum)/width;
88
89 iPtr += imgStride;
90 rPtr += refStride;
91 }
92
93 return sum/height;
94 }
95
96
97 double PSNR(double mse)
98 {
99 if (mse==0) { return 99.99999; }
100
101 return 10*log10(255.0*255.0/mse);
102 }
103
104 uint32_t compute_distortion_ssd(const de265_image* img1, const de265_image* img2,
105 int x0, int y0, int log2size, int cIdx)
106 {
107 return SSD(img1->get_image_plane_at_pos(cIdx,x0,y0), img1->get_image_stride(cIdx),
108 img2->get_image_plane_at_pos(cIdx,x0,y0), img2->get_image_stride(cIdx),
109 1<<log2size, 1<<log2size);
110 }
111
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * This file is part of libde265.
5 *
6 * libde265 is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation, either version 3 of
9 * the License, or (at your option) any later version.
10 *
11 * libde265 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
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with libde265. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef DE265_QUALITY_H
21 #define DE265_QUALITY_H
22
23 #include <stdint.h>
24 #include <libde265/de265.h>
25 #include <libde265/image.h>
26
27
28 LIBDE265_API uint32_t SSD(const uint8_t* img, int imgStride,
29 const uint8_t* ref, int refStride,
30 int width, int height);
31
32 LIBDE265_API uint32_t SAD(const uint8_t* img, int imgStride,
33 const uint8_t* ref, int refStride,
34 int width, int height);
35
36 LIBDE265_API double MSE(const uint8_t* img, int imgStride,
37 const uint8_t* ref, int refStride,
38 int width, int height);
39
40 LIBDE265_API double PSNR(double mse);
41
42
43 LIBDE265_API uint32_t compute_distortion_ssd(const de265_image* img1, const de265_image* img2,
44 int x0, int y0, int log2size, int cIdx);
45
46 #endif
3030 #endif
3131
3232
33 static void compute_NumPoc(ref_pic_set* rpset)
34 {
35 rpset->NumPocTotalCurr_shortterm_only = 0;
36
37 for (int i=0; i<rpset->NumNegativePics; i++)
38 if (rpset->UsedByCurrPicS0[i])
39 rpset->NumPocTotalCurr_shortterm_only++;
40
41 for (int i=0; i<rpset->NumPositivePics; i++)
42 if (rpset->UsedByCurrPicS1[i])
43 rpset->NumPocTotalCurr_shortterm_only++;
33 void ref_pic_set::reset()
34 {
35 NumNegativePics = 0;
36 NumPositivePics = 0;
37 NumDeltaPocs = 0;
38 NumPocTotalCurr_shortterm_only = 0;
39
40 for (int i=0;i<MAX_NUM_REF_PICS;i++) {
41 DeltaPocS0[i] = 0;
42 DeltaPocS1[i] = 0;
43
44 UsedByCurrPicS0[i] = 0;
45 UsedByCurrPicS1[i] = 0;
46 }
47 }
48
49
50 void ref_pic_set::compute_derived_values()
51 {
52 NumPocTotalCurr_shortterm_only = 0;
53
54 for (int i=0; i<NumNegativePics; i++)
55 if (UsedByCurrPicS0[i])
56 NumPocTotalCurr_shortterm_only++;
57
58 for (int i=0; i<NumPositivePics; i++)
59 if (UsedByCurrPicS1[i])
60 NumPocTotalCurr_shortterm_only++;
61
62 NumDeltaPocs = NumNegativePics + NumPositivePics;
63
4464
4565 /*
4666 NOTE: this is done when reading the slice header.
6181 When coding the ref-pic-sets in the SPS, predicition is always from the previous set.
6282 In the slice header, the ref-pic-set can use any previous set as reference.
6383 */
64 bool read_short_term_ref_pic_set(decoder_context* ctx,
84 bool read_short_term_ref_pic_set(error_queue* errqueue,
6585 const seq_parameter_set* sps,
6686 bitreader* br,
6787 ref_pic_set* out_set, // where to store the read set
91111 int delta_idx;
92112 if (sliceRefPicSet) { // idxRps == num_short_term_ref_pic_sets) {
93113 delta_idx = vlc = get_uvlc(br);
114 if (delta_idx==UVLC_ERROR) {
115 return false;
116 }
117
118 if (delta_idx>=idxRps) {
119 return false;
120 }
121
94122 delta_idx++;
95123 } else {
96124 delta_idx = 1;
101129
102130 int delta_rps_sign = get_bits(br,1);
103131 int abs_delta_rps = vlc = get_uvlc(br);
132 if (vlc==UVLC_ERROR) { return false; }
104133 abs_delta_rps++;
105134 int DeltaRPS = (delta_rps_sign ? -abs_delta_rps : abs_delta_rps);
106135
141170
142171 // positive list
143172 for (int j=nPositiveRIdx-1;j>=0;j--) {
173 assert(RIdx >= 0 && RIdx < sets.size());
174 assert(j>=0 && j < MAX_NUM_REF_PICS);
175
144176 int dPoc = sets[RIdx].DeltaPocS1[j] + DeltaRPS; // new delta
145177 if (dPoc<0 && use_delta_flag[nNegativeRIdx+j]) {
178 if (i>= MAX_NUM_REF_PICS) { return false; }
179
146180 out_set->DeltaPocS0[i] = dPoc;
147181 out_set->UsedByCurrPicS0[i] = used_by_curr_pic_flag[nNegativeRIdx+j];
148182 i++;
151185
152186 // frame 0
153187 if (DeltaRPS<0 && use_delta_flag[nDeltaPocsRIdx]) {
188 if (i>= MAX_NUM_REF_PICS) { return false; }
189
154190 out_set->DeltaPocS0[i] = DeltaRPS;
155191 out_set->UsedByCurrPicS0[i] = used_by_curr_pic_flag[nDeltaPocsRIdx];
156192 i++;
160196 for (int j=0;j<nNegativeRIdx;j++) {
161197 int dPoc = sets[RIdx].DeltaPocS0[j] + DeltaRPS;
162198 if (dPoc<0 && use_delta_flag[j]) {
199 if (i>= MAX_NUM_REF_PICS) { return false; }
200
163201 out_set->DeltaPocS0[i] = dPoc;
164202 out_set->UsedByCurrPicS0[i] = used_by_curr_pic_flag[j];
165203 i++;
178216 for (int j=nNegativeRIdx-1;j>=0;j--) {
179217 int dPoc = sets[RIdx].DeltaPocS0[j] + DeltaRPS;
180218 if (dPoc>0 && use_delta_flag[j]) {
219 if (i>= MAX_NUM_REF_PICS) { return false; }
220
181221 out_set->DeltaPocS1[i] = dPoc;
182222 out_set->UsedByCurrPicS1[i] = used_by_curr_pic_flag[j];
183223 i++;
186226
187227 // frame 0
188228 if (DeltaRPS>0 && use_delta_flag[nDeltaPocsRIdx]) {
229 if (i>= MAX_NUM_REF_PICS) { return false; }
230
189231 out_set->DeltaPocS1[i] = DeltaRPS;
190232 out_set->UsedByCurrPicS1[i] = used_by_curr_pic_flag[nDeltaPocsRIdx];
191233 i++;
195237 for (int j=0;j<nPositiveRIdx;j++) {
196238 int dPoc = sets[RIdx].DeltaPocS1[j] + DeltaRPS;
197239 if (dPoc>0 && use_delta_flag[nNegativeRIdx+j]) {
240 if (i>= MAX_NUM_REF_PICS) { return false; }
241
198242 out_set->DeltaPocS1[i] = dPoc;
199243 out_set->UsedByCurrPicS1[i] = used_by_curr_pic_flag[nNegativeRIdx+j];
200244 i++;
202246 }
203247
204248 out_set->NumPositivePics = i;
205
206 out_set->NumDeltaPocs = out_set->NumNegativePics + out_set->NumPositivePics;
207249
208250 } else {
209251
221263 out_set->NumDeltaPocs = 0;
222264 out_set->NumPocTotalCurr_shortterm_only = 0;
223265
224 ctx->add_warning(DE265_WARNING_MAX_NUM_REF_PICS_EXCEEDED, false);
266 errqueue->add_warning(DE265_WARNING_MAX_NUM_REF_PICS_EXCEEDED, false);
225267 return false;
226268 }
227269
270 if (num_negative_pics > MAX_NUM_REF_PICS ||
271 num_positive_pics > MAX_NUM_REF_PICS) {
272 errqueue->add_warning(DE265_WARNING_MAX_NUM_REF_PICS_EXCEEDED, false);
273 return false;
274 }
228275
229276 out_set->NumNegativePics = num_negative_pics;
230277 out_set->NumPositivePics = num_positive_pics;
231 out_set->NumDeltaPocs = num_positive_pics + num_negative_pics;
232278
233279 // --- now, read the deltas between the reference frames to fill the lists ---
234280
236282
237283 int lastPocS=0;
238284 for (int i=0;i<num_negative_pics;i++) {
239 int delta_poc_s0 = get_uvlc(br)+1;
285 int delta_poc_s0 = get_uvlc(br);
286 if (delta_poc_s0==UVLC_ERROR) { return false; }
287 delta_poc_s0++;
240288 char used_by_curr_pic_s0_flag = get_bits(br,1);
241289
242290 out_set->DeltaPocS0[i] = lastPocS - delta_poc_s0;
248296
249297 lastPocS=0;
250298 for (int i=0;i<num_positive_pics;i++) {
251 int delta_poc_s1 = get_uvlc(br)+1;
299 int delta_poc_s1 = get_uvlc(br);
300 if (delta_poc_s1==UVLC_ERROR) { return false; }
301 delta_poc_s1++;
252302 char used_by_curr_pic_s1_flag = get_bits(br,1);
253303
254304 out_set->DeltaPocS1[i] = lastPocS + delta_poc_s1;
258308 }
259309
260310
261 compute_NumPoc(out_set);
311 out_set->compute_derived_values();
262312
263313 return true;
314 }
315
316
317 bool write_short_term_ref_pic_set_nopred(error_queue* errqueue,
318 const seq_parameter_set* sps,
319 CABAC_encoder& out,
320 const ref_pic_set* in_set, // which set to write
321 int idxRps, // index of the set to be written
322 const std::vector<ref_pic_set>& sets, // previously read sets
323 bool sliceRefPicSet) // is this in the slice header?
324 {
325 if (idxRps != 0) {
326 // inter_ref_pic_set_prediction_flag
327 out.write_bit(0);
328 }
329
330
331 // --- first, write the number of past and future frames in this set ---
332
333 out.write_uvlc(in_set->NumNegativePics);
334 out.write_uvlc(in_set->NumPositivePics);
335
336 // --- now, write the deltas between the reference frames to fill the lists ---
337
338 // past frames
339
340 int lastPocS=0;
341 for (int i=0;i<in_set->NumNegativePics;i++) {
342 int delta_poc_s0 = lastPocS - in_set->DeltaPocS0[i];
343 char used_by_curr_pic_s0_flag = in_set->UsedByCurrPicS0[i];
344
345 assert(delta_poc_s0 >= 1);
346 out.write_uvlc(delta_poc_s0-1);
347 out.write_bit(used_by_curr_pic_s0_flag);
348 lastPocS = in_set->DeltaPocS0[i];
349 }
350
351 // future frames
352
353 lastPocS=0;
354 for (int i=0;i<in_set->NumPositivePics;i++) {
355 int delta_poc_s1 = in_set->DeltaPocS1[i] - lastPocS;
356 char used_by_curr_pic_s1_flag = in_set->UsedByCurrPicS1[i];
357
358 assert(delta_poc_s1 >= 1);
359 out.write_uvlc(delta_poc_s1-1);
360 out.write_bit(used_by_curr_pic_s1_flag);
361 lastPocS = in_set->DeltaPocS1[i];
362 }
363
364 return true;
365 }
366
367
368 bool write_short_term_ref_pic_set(error_queue* errqueue,
369 const seq_parameter_set* sps,
370 CABAC_encoder& out,
371 const ref_pic_set* in_set, // which set to write
372 int idxRps, // index of the set to be read
373 const std::vector<ref_pic_set>& sets, // previously read sets
374 bool sliceRefPicSet) // is this in the slice header?
375 {
376 return write_short_term_ref_pic_set_nopred(errqueue, sps, out, in_set, idxRps, sets,
377 sliceRefPicSet);
264378 }
265379
266380
2525 #define MAX_NUM_REF_PICS 16 // maximum defined by standard, may be lower for some Levels
2626
2727
28 typedef struct {
29 uint8_t NumNegativePics; // number of past reference pictures
30 uint8_t NumPositivePics; // number of future reference pictures
31 uint8_t NumDeltaPocs; // total number of reference pictures (past + future)
32
33 uint8_t NumPocTotalCurr_shortterm_only; /* Total number of reference pictures that may actually
34 be used for prediction in the current frame. */
35
28 class ref_pic_set
29 {
30 public:
3631 // Lists of pictures that have to be kept in the decoded picture buffer for future
3732 // reference and that may optionally be used for prediction in the current frame.
3833 // Lists contain the relative POC positions.
4338 uint8_t UsedByCurrPicS0[MAX_NUM_REF_PICS];
4439 uint8_t UsedByCurrPicS1[MAX_NUM_REF_PICS];
4540
46 } ref_pic_set;
41 uint8_t NumNegativePics; // number of past reference pictures
42 uint8_t NumPositivePics; // number of future reference pictures
43
44 // --- derived values ---
45
46 void compute_derived_values();
47
48 uint8_t NumDeltaPocs; // total number of reference pictures (past + future)
49
50 uint8_t NumPocTotalCurr_shortterm_only; /* Total number of reference pictures that may actually
51 be used for prediction in the current frame. */
52
53 void reset();
54 };
4755
4856
4957 void dump_short_term_ref_pic_set(const ref_pic_set*, FILE* fh);
2424 #include <string.h>
2525
2626
27 void apply_sao(de265_image* img, int xCtb,int yCtb,
28 const slice_segment_header* shdr, int cIdx, int nS,
29 const uint8_t* in_img, int in_stride,
30 /* */ uint8_t* out_img, int out_stride)
27 template <class pixel_t>
28 void apply_sao_internal(de265_image* img, int xCtb,int yCtb,
29 const slice_segment_header* shdr, int cIdx, int nSW,int nSH,
30 const pixel_t* in_img, int in_stride,
31 /* */ pixel_t* out_img, int out_stride)
3132 {
3233 const sao_info* saoinfo = img->get_sao_info(xCtb,yCtb);
3334
3435 int SaoTypeIdx = (saoinfo->SaoTypeIdx >> (2*cIdx)) & 0x3;
3536
36 logtrace(LogSAO,"apply_sao CTB %d;%d cIdx:%d type=%d (%dx%d)\n",xCtb,yCtb,cIdx, SaoTypeIdx, nS,nS);
37 logtrace(LogSAO,"apply_sao CTB %d;%d cIdx:%d type=%d (%dx%d)\n",xCtb,yCtb,cIdx, SaoTypeIdx, nSW,nSH);
3738
3839 if (SaoTypeIdx==0) {
3940 return;
4546 const int maxPixelValue = (1<<bitDepth)-1;
4647
4748 // top left position of CTB in pixels
48 const int xC = xCtb*nS;
49 const int yC = yCtb*nS;
49 const int xC = xCtb*nSW;
50 const int yC = yCtb*nSH;
5051
5152 const int width = img->get_width(cIdx);
5253 const int height = img->get_height(cIdx);
5455 const int ctbSliceAddrRS = img->get_SliceHeader(xC,yC)->SliceAddrRS;
5556
5657 const int picWidthInCtbs = sps->PicWidthInCtbsY;
57 const int ctbshift = sps->Log2CtbSizeY - (cIdx>0 ? 1 : 0);
58 const int chromashift = (cIdx>0 ? 1 : 0);
58 const int chromashiftW = sps->get_chroma_shift_W(cIdx);
59 const int chromashiftH = sps->get_chroma_shift_H(cIdx);
60 const int ctbshiftW = sps->Log2CtbSizeY - chromashiftW;
61 const int ctbshiftH = sps->Log2CtbSizeY - chromashiftH;
5962
6063
6164 for (int i=0;i<5;i++)
6568
6669
6770 // actual size of CTB to be processed (can be smaller when partially outside of image)
68 const int ctbW = (xC+nS>width) ? width -xC : nS;
69 const int ctbH = (yC+nS>height) ? height-yC : nS;
70
71
72 const bool extendedTests = (img->get_CTB_has_pcm(xCtb,yCtb) ||
73 img->get_CTB_has_cu_transquant_bypass(xCtb,yCtb));
71 const int ctbW = (xC+nSW>width) ? width -xC : nSW;
72 const int ctbH = (yC+nSH>height) ? height-yC : nSH;
73
74
75 const bool extendedTests = img->get_CTB_has_pcm_or_cu_transquant_bypass(xCtb,yCtb);
7476
7577 if (SaoTypeIdx==2) {
7678 int hPos[2], vPos[2];
98100
99101
100102 for (int j=0;j<ctbH;j++) {
101 const uint8_t* in_ptr = &in_img [xC+(yC+j)*in_stride];
102 /* */ uint8_t* out_ptr = &out_img[xC+(yC+j)*out_stride];
103 const pixel_t* in_ptr = &in_img [xC+(yC+j)*in_stride];
104 /* */ pixel_t* out_ptr = &out_img[xC+(yC+j)*out_stride];
103105
104106 for (int i=0;i<ctbW;i++) {
105107 int edgeIdx = -1;
106108
107109 logtrace(LogSAO, "pos %d,%d\n",xC+i,yC+j);
108110
109 if (extendedTests &&
110 (sps->pcm_loop_filter_disable_flag &&
111 img->get_pcm_flag((xC+i)<<chromashift,(yC+j)<<chromashift)) ||
112 img->get_cu_transquant_bypass((xC+i)<<chromashift,(yC+j)<<chromashift)) {
111 if ((extendedTests &&
112 (sps->pcm_loop_filter_disable_flag &&
113 img->get_pcm_flag((xC+i)<<chromashiftW,(yC+j)<<chromashiftH))) ||
114 img->get_cu_transquant_bypass((xC+i)<<chromashiftW,(yC+j)<<chromashiftH)) {
113115 continue;
114116 }
115117
132134 // slice anyway) reduced computation time only by 1.3%.
133135 // TODO: however, this may still be a big part of SAO itself.
134136
135 int sliceAddrRS = img->get_SliceHeader(xS<<chromashift,yS<<chromashift)->SliceAddrRS;
137 slice_segment_header* sliceHeader = img->get_SliceHeader(xS<<chromashiftW,
138 yS<<chromashiftH);
139 if (sliceHeader==NULL) { return; }
140
141 int sliceAddrRS = sliceHeader->SliceAddrRS;
136142 if (sliceAddrRS < ctbSliceAddrRS &&
137 img->get_SliceHeader((xC+i)<<chromashift,(yC+j)<<chromashift)->slice_loop_filter_across_slices_enabled_flag==0) {
143 img->get_SliceHeader((xC+i)<<chromashiftW,
144 (yC+j)<<chromashiftH)->slice_loop_filter_across_slices_enabled_flag==0) {
138145 edgeIdx=0;
139146 break;
140147 }
141148
142149 if (sliceAddrRS > ctbSliceAddrRS &&
143 img->get_SliceHeader(xS<<chromashift,yS<<chromashift)->slice_loop_filter_across_slices_enabled_flag==0) {
150 img->get_SliceHeader(xS<<chromashiftW,
151 yS<<chromashiftH)->slice_loop_filter_across_slices_enabled_flag==0) {
144152 edgeIdx=0;
145153 break;
146154 }
147155
148156
149 if (pps->loop_filter_across_tiles_enabled_flag==0 &&
150 pps->TileIdRS[(xS>>ctbshift) + (yS>>ctbshift)*picWidthInCtbs] !=
151 pps->TileIdRS[(xC>>ctbshift) + (yC>>ctbshift)*picWidthInCtbs]) {
157 if (pps->loop_filter_across_tiles_enabled_flag==0 &&
158 pps->TileIdRS[(xS>>ctbshiftW) + (yS>>ctbshiftH)*picWidthInCtbs] !=
159 pps->TileIdRS[(xC>>ctbshiftW) + (yC>>ctbshiftH)*picWidthInCtbs]) {
152160 edgeIdx=0;
153161 break;
154162 }
197205 for (int i=0;i<ctbW;i++) {
198206
199207 if ((sps->pcm_loop_filter_disable_flag &&
200 img->get_pcm_flag((xC+i)<<chromashift,(yC+j)<<chromashift)) ||
201 img->get_cu_transquant_bypass((xC+i)<<chromashift,(yC+j)<<chromashift)) {
208 img->get_pcm_flag((xC+i)<<chromashiftW,(yC+j)<<chromashiftH)) ||
209 img->get_cu_transquant_bypass((xC+i)<<chromashiftW,(yC+j)<<chromashiftH)) {
202210 continue;
203211 }
204212
205213 int bandIdx = bandTable[ in_img[xC+i+(yC+j)*in_stride]>>bandShift ];
214
215 // Shifts are a strange thing. On x86, >>x actually computes >>(x%64).
216 // So we have to take care of large bandShifts.
217 if (bandShift>=8) { bandIdx=0; }
206218
207219 if (bandIdx>0) {
208220 int offset = saoinfo->saoOffsetVal[cIdx][bandIdx-1];
211223 offset,
212224 in_img[xC+i+(yC+j)*in_stride],
213225 in_img[xC+i+(yC+j)*in_stride]+offset);
214
226
215227 out_img[xC+i+(yC+j)*out_stride] = Clip3(0,maxPixelValue,
216228 in_img[xC+i+(yC+j)*in_stride] + offset);
217229 }
226238
227239 int bandIdx = bandTable[ in_img[xC+i+(yC+j)*in_stride]>>bandShift ];
228240
241 // see above
242 if (bandShift>=8) { bandIdx=0; }
243
229244 if (bandIdx>0) {
230245 int offset = saoinfo->saoOffsetVal[cIdx][bandIdx-1];
231246
234249 }
235250 }
236251 }
252 }
253 }
254
255
256 template <class pixel_t>
257 void apply_sao(de265_image* img, int xCtb,int yCtb,
258 const slice_segment_header* shdr, int cIdx, int nSW,int nSH,
259 const pixel_t* in_img, int in_stride,
260 /* */ pixel_t* out_img, int out_stride)
261 {
262 if (img->high_bit_depth(cIdx)) {
263 apply_sao_internal<uint16_t>(img,xCtb,yCtb, shdr,cIdx,nSW,nSH,
264 (uint16_t*)in_img, in_stride,
265 (uint16_t*)out_img,out_stride);
266 }
267 else {
268 apply_sao_internal<uint8_t>(img,xCtb,yCtb, shdr,cIdx,nSW,nSH,
269 in_img, in_stride,
270 out_img,out_stride);
237271 }
238272 }
239273
257291 const slice_segment_header* shdr = img->get_SliceHeaderCtb(xCtb,yCtb);
258292
259293 if (shdr->slice_sao_luma_flag) {
260 apply_sao(img, xCtb,yCtb, shdr, 0, 1<<img->sps.Log2CtbSizeY,
294 apply_sao(img, xCtb,yCtb, shdr, 0, 1<<img->sps.Log2CtbSizeY, 1<<img->sps.Log2CtbSizeY,
261295 inputCopy.get_image_plane(0), inputCopy.get_image_stride(0),
262296 img->get_image_plane(0), img->get_image_stride(0));
263297 }
264298
265299 if (shdr->slice_sao_chroma_flag) {
266 apply_sao(img, xCtb,yCtb, shdr, 1, 1<<(img->sps.Log2CtbSizeY-1),
300 int nSW = (1<<img->sps.Log2CtbSizeY) / img->sps.SubWidthC;
301 int nSH = (1<<img->sps.Log2CtbSizeY) / img->sps.SubHeightC;
302
303 apply_sao(img, xCtb,yCtb, shdr, 1, nSW,nSH,
267304 inputCopy.get_image_plane(1), inputCopy.get_image_stride(1),
268305 img->get_image_plane(1), img->get_image_stride(1));
269306
270 apply_sao(img, xCtb,yCtb, shdr, 2, 1<<(img->sps.Log2CtbSizeY-1),
307 apply_sao(img, xCtb,yCtb, shdr, 2, nSW,nSH,
271308 inputCopy.get_image_plane(2), inputCopy.get_image_stride(2),
272309 img->get_image_plane(2), img->get_image_stride(2));
273310 }
281318 return;
282319 }
283320
284
285 uint8_t* inputCopy = new uint8_t[ img->get_image_stride(0) * img->get_height(0) ];
321 int lumaImageSize = img->get_image_stride(0) * img->get_height(0) * img->get_bytes_per_pixel(0);
322 int chromaImageSize = img->get_image_stride(1) * img->get_height(1) * img->get_bytes_per_pixel(1);
323
324 uint8_t* inputCopy = new uint8_t[ libde265_max(lumaImageSize, chromaImageSize) ];
286325 if (inputCopy == NULL) {
287326 img->decctx->add_warning(DE265_WARNING_CANNOT_APPLY_SAO_OUT_OF_MEMORY,false);
288327 return;
289328 }
290329
291330
292 for (int cIdx=0;cIdx<3;cIdx++) {
331 int nChannels = 3;
332 if (img->sps.ChromaArrayType == CHROMA_MONO) { nChannels=1; }
333
334 for (int cIdx=0;cIdx<nChannels;cIdx++) {
293335
294336 int stride = img->get_image_stride(cIdx);
295337 int height = img->get_height(cIdx);
296338
297 memcpy(inputCopy, img->get_image_plane(cIdx), stride * height);
339 memcpy(inputCopy, img->get_image_plane(cIdx), stride * height * img->get_bytes_per_pixel(cIdx));
298340
299341 for (int yCtb=0; yCtb<img->sps.PicHeightInCtbsY; yCtb++)
300342 for (int xCtb=0; xCtb<img->sps.PicWidthInCtbsY; xCtb++)
301343 {
302344 const slice_segment_header* shdr = img->get_SliceHeaderCtb(xCtb,yCtb);
345 if (shdr==NULL) { return; }
303346
304347 if (cIdx==0 && shdr->slice_sao_luma_flag) {
305 apply_sao(img, xCtb,yCtb, shdr, 0, 1<<img->sps.Log2CtbSizeY,
348 apply_sao(img, xCtb,yCtb, shdr, 0, 1<<img->sps.Log2CtbSizeY, 1<<img->sps.Log2CtbSizeY,
306349 inputCopy, stride,
307350 img->get_image_plane(0), img->get_image_stride(0));
308351 }
309352
310353 if (cIdx!=0 && shdr->slice_sao_chroma_flag) {
311 apply_sao(img, xCtb,yCtb, shdr, cIdx, 1<<(img->sps.Log2CtbSizeY-1),
354 int nSW = (1<<img->sps.Log2CtbSizeY) / img->sps.SubWidthC;
355 int nSH = (1<<img->sps.Log2CtbSizeY) / img->sps.SubHeightC;
356
357 apply_sao(img, xCtb,yCtb, shdr, cIdx, nSW,nSH,
312358 inputCopy, stride,
313359 img->get_image_plane(cIdx), img->get_image_stride(cIdx));
314360 }
334380 int inputProgress;
335381
336382 virtual void work();
383 virtual std::string name() const {
384 char buf[100];
385 sprintf(buf,"sao-%d",ctb_y);
386 return buf;
387 }
337388 };
338389
339390
340391 void thread_task_sao::work()
341392 {
342393 state = Running;
343 img->thread_run();
394 img->thread_run(this);
344395
345396 const int rightCtb = img->sps.PicWidthInCtbsY-1;
346397 const int ctbSize = (1<<img->sps.Log2CtbSizeY);
353404 if (ctb_y>0) {
354405 img->wait_for_progress(this, rightCtb,ctb_y-1, inputProgress);
355406 }
356
407
357408 if (ctb_y+1<img->sps.PicHeightInCtbsY) {
358409 img->wait_for_progress(this, rightCtb,ctb_y+1, inputProgress);
359410 }
369420 for (int xCtb=0; xCtb<img->sps.PicWidthInCtbsY; xCtb++)
370421 {
371422 const slice_segment_header* shdr = img->get_SliceHeaderCtb(xCtb,ctb_y);
423 if (shdr==NULL) {
424 break;
425 }
372426
373427 if (shdr->slice_sao_luma_flag) {
374 apply_sao(img, xCtb,ctb_y, shdr, 0, ctbSize,
428 apply_sao(img, xCtb,ctb_y, shdr, 0, ctbSize, ctbSize,
375429 inputImg ->get_image_plane(0), inputImg ->get_image_stride(0),
376430 outputImg->get_image_plane(0), outputImg->get_image_stride(0));
377431 }
378432
379433 if (shdr->slice_sao_chroma_flag) {
380 apply_sao(img, xCtb,ctb_y, shdr, 1, ctbSize>>1,
434 int nSW = ctbSize / img->sps.SubWidthC;
435 int nSH = ctbSize / img->sps.SubHeightC;
436
437 apply_sao(img, xCtb,ctb_y, shdr, 1, nSW,nSH,
381438 inputImg ->get_image_plane(1), inputImg ->get_image_stride(1),
382439 outputImg->get_image_plane(1), outputImg->get_image_stride(1));
383440
384 apply_sao(img, xCtb,ctb_y, shdr, 2, ctbSize>>1,
441 apply_sao(img, xCtb,ctb_y, shdr, 2, nSW,nSH,
385442 inputImg ->get_image_plane(2), inputImg ->get_image_stride(2),
386443 outputImg->get_image_plane(2), outputImg->get_image_stride(2));
387444 }
397454
398455
399456 state = Finished;
400 img->thread_finishes();
457 img->thread_finishes(this);
401458 }
402459
403460
414471
415472 de265_error err = imgunit->sao_output.alloc_image(img->get_width(), img->get_height(),
416473 img->get_chroma_format(), &img->sps, false,
417 img->decctx, img->pts, img->user_data, true);
474 img->decctx, img->encctx,
475 img->pts, img->user_data, true);
418476 if (err != DE265_OK) {
419477 img->decctx->add_warning(DE265_WARNING_CANNOT_APPLY_SAO_OUT_OF_MEMORY,false);
420478 return false;
425483 int n=0;
426484 img->thread_start(nRows);
427485
428 for (int y=0;y<img->sps.PicHeightInCtbsY;y++)
486 for (int y=0;y<nRows;y++)
429487 {
430488 thread_task_sao* task = new thread_task_sao;
431489
436494 task->inputProgress = saoInputProgress;
437495
438496 imgunit->tasks.push_back(task);
439 add_task(&ctx->thread_pool, task);
497 add_task(&ctx->thread_pool_, task);
440498 n++;
441499 }
442500
9595 }
9696
9797
98 static uint32_t compute_checksum_8bit(uint8_t* data,int w,int h,int stride)
98 class raw_hash_data
99 {
100 public:
101 raw_hash_data(int w, int stride);
102 ~raw_hash_data();
103
104 struct data_chunk {
105 const uint8_t* data;
106 int len;
107 };
108
109 data_chunk prepare_8bit(const uint8_t* data,int y);
110 data_chunk prepare_16bit(const uint8_t* data,int y);
111
112 private:
113 int mWidth, mStride;
114
115 uint8_t* mMem;
116 };
117
118
119 raw_hash_data::raw_hash_data(int w, int stride)
120 {
121 mWidth=w;
122 mStride=stride;
123 mMem = NULL;
124 }
125
126 raw_hash_data::~raw_hash_data()
127 {
128 delete[] mMem;
129 }
130
131 raw_hash_data::data_chunk raw_hash_data::prepare_8bit(const uint8_t* data,int y)
132 {
133 data_chunk chunk;
134 chunk.data = data+y*mStride;
135 chunk.len = mWidth;
136 return chunk;
137 }
138
139 raw_hash_data::data_chunk raw_hash_data::prepare_16bit(const uint8_t* data,int y)
140 {
141 if (mMem == NULL) {
142 mMem = new uint8_t[2*mWidth];
143 }
144
145 const uint16_t* data16 = (uint16_t*)data;
146
147 for (int x=0; x<mWidth; x++) {
148 mMem[2*x+0] = data16[y*mStride+x] & 0xFF;
149 mMem[2*x+1] = data16[y*mStride+x] >> 8;
150 }
151
152 data_chunk chunk;
153 chunk.data = mMem;
154 chunk.len = 2*mWidth;
155 return chunk;
156 }
157
158
159 static uint32_t compute_checksum_8bit(uint8_t* data,int w,int h,int stride, int bit_depth)
99160 {
100161 uint32_t sum = 0;
101 for (int y=0; y<h; y++)
102 for(int x=0; x<w; x++) {
103 uint8_t xorMask = ( x & 0xFF ) ^ ( y & 0xFF ) ^ ( x >> 8 ) ^ ( y >> 8 );
104 sum += data[y*stride + x] ^ xorMask;
105
106 /*
107 if (compDepth[cIdx] > 8 )
108 sum = ( sum + ( ( component[cIdx][y * compWidth[cIdx] + x] >> 8 ) ^ xorMask ) ) &
109 0xFFFFFFFF
110 }
111 */
112 }
162
163 if (bit_depth<=8) {
164 for (int y=0; y<h; y++)
165 for(int x=0; x<w; x++) {
166 uint8_t xorMask = ( x & 0xFF ) ^ ( y & 0xFF ) ^ ( x >> 8 ) ^ ( y >> 8 );
167 sum += data[y*stride + x] ^ xorMask;
168 }
169 }
170 else {
171 for (int y=0; y<h; y++)
172 for(int x=0; x<w; x++) {
173 uint8_t xorMask = ( x & 0xFF ) ^ ( y & 0xFF ) ^ ( x >> 8 ) ^ ( y >> 8 );
174 sum += (data[y*stride + x] & 0xFF) ^ xorMask;
175 sum += (data[y*stride + x] >> 8) ^ xorMask;
176 }
177 }
113178
114179 return sum & 0xFFFFFFFF;
115180 }
156221 (t << 12)) & 0xFFFF;
157222 }
158223
159 static uint32_t compute_CRC_8bit_fast(const uint8_t* data,int w,int h,int stride)
160 {
224 static uint32_t compute_CRC_8bit_fast(const uint8_t* data,int w,int h,int stride, int bit_depth)
225 {
226 raw_hash_data raw_data(w,stride);
227
161228 uint16_t crc = 0xFFFF;
162229
163230 crc = crc_process_byte_parallel(crc, 0);
164231 crc = crc_process_byte_parallel(crc, 0);
165232
166233 for (int y=0; y<h; y++) {
167 const uint8_t* d = &data[y*stride];
168
169 for(int x=0; x<w; x++) {
170 crc = crc_process_byte_parallel(crc, *d++);
234 raw_hash_data::data_chunk chunk;
235
236 if (bit_depth>8)
237 chunk = raw_data.prepare_16bit(data, y);
238 else
239 chunk = raw_data.prepare_8bit(data, y);
240
241 for(int x=0; x<chunk.len; x++) {
242 crc = crc_process_byte_parallel(crc, chunk.data[x]);
171243 }
172244 }
173245
174246 return crc;
175247 }
176248
177 static void compute_MD5_8bit(uint8_t* data,int w,int h,int stride, uint8_t* result)
249
250 static void compute_MD5(uint8_t* data,int w,int h,int stride, uint8_t* result, int bit_depth)
178251 {
179252 MD5_CTX md5;
180253 MD5_Init(&md5);
181254
255 raw_hash_data raw_data(w,stride);
256
182257 for (int y=0; y<h; y++) {
183 MD5_Update(&md5, &data[y*stride], w);
258 raw_hash_data::data_chunk chunk;
259
260 if (bit_depth>8)
261 chunk = raw_data.prepare_16bit(data, y);
262 else
263 chunk = raw_data.prepare_8bit(data, y);
264
265 MD5_Update(&md5, (void*)chunk.data, chunk.len);
184266 }
185267
186268 MD5_Final(result, &md5);
216298 case sei_decoded_picture_hash_type_MD5:
217299 {
218300 uint8_t md5[16];
219 compute_MD5_8bit(data,w,h,stride,md5);
301 compute_MD5(data,w,h,stride,md5, img->get_bit_depth(i));
220302
221303 /*
222304 fprintf(stderr,"computed MD5: ");
237319
238320 case sei_decoded_picture_hash_type_CRC:
239321 {
240 uint16_t crc = compute_CRC_8bit_fast(data,w,h,stride);
322 uint16_t crc = compute_CRC_8bit_fast(data,w,h,stride, img->get_bit_depth(i));
241323
242324 logtrace(LogSEI,"SEI decoded picture hash: %04x <-[%d]-> decoded picture: %04x\n",
243325 seihash->crc[i], i, crc);
252334
253335 case sei_decoded_picture_hash_type_checksum:
254336 {
255 uint32_t chksum = compute_checksum_8bit(data,w,h,stride);
337 uint32_t chksum = compute_checksum_8bit(data,w,h,stride, img->get_bit_depth(i));
256338
257339 if (chksum != seihash->checksum[i]) {
258340 fprintf(stderr,"SEI decoded picture hash: %04x, decoded picture: %04x (POC=%d)\n",
281363 if (byte != 0xFF) { break; }
282364 }
283365
366 //printf("SEI payload: %d\n",payload_type);
367
284368 int payload_size = 0;
285369 for (;;)
286370 {
334418 case sei_payload_type_decoded_picture_hash:
335419 if (img->decctx->param_sei_check_hash) {
336420 err = process_sei_decoded_picture_hash(sei, img);
421 if (err==DE265_OK) {
422 //printf("SEI check ok\n");
423 }
337424 }
338425
339426 break;
405492 return "unknown SEI message";
406493 }
407494 }
408
6868 } sei_decoded_picture_hash;
6969
7070
71 struct sei_message {
71 typedef struct {
7272 enum sei_payload_type payload_type;
7373 int payload_size;
7474
7575 union {
7676 sei_decoded_picture_hash decoded_picture_hash;
7777 } data;
78 };
79
78 } sei_message;
8079
8180 class seq_parameter_set;
8281
8483
8584 de265_error read_sei(bitreader* reader, sei_message*, bool suffix, const seq_parameter_set* sps);
8685 void dump_sei(const sei_message*, const seq_parameter_set* sps);
87 de265_error process_sei(const sei_message*, class de265_image* img);
86 de265_error process_sei(const sei_message*, struct de265_image* img);
8887
8988 #endif
3737 #define LOCK de265_mutex_lock(&ctx->thread_pool.mutex)
3838 #define UNLOCK de265_mutex_unlock(&ctx->thread_pool.mutex)
3939
40 extern bool read_short_term_ref_pic_set(decoder_context* ctx,
40 extern bool read_short_term_ref_pic_set(error_queue* errqueue,
4141 const seq_parameter_set* sps,
4242 bitreader* br,
4343 ref_pic_set* out_set,
4848
4949 void read_coding_tree_unit(thread_context* tctx);
5050 void read_coding_quadtree(thread_context* tctx,
51 int xCtb, int yCtb,
51 int xCtb, int yCtb,
5252 int Log2CtbSizeY,
5353 int ctDepth);
54 int check_CTB_available(de265_image* img,
55 slice_segment_header* shdr,
56 int xC,int yC, int xN,int yN);
5754 /*
5855 void decode_inter_block(decoder_context* ctx,thread_context* tctx,
5956 int xC, int yC, int log2CbSize);
6057 */
58
59 void slice_segment_header::set_defaults()
60 {
61 slice_index = 0;
62
63 first_slice_segment_in_pic_flag = 1;
64 no_output_of_prior_pics_flag = 0;
65 slice_pic_parameter_set_id = 0;
66 dependent_slice_segment_flag = 0;
67 slice_segment_address = 0;
68
69 slice_type = SLICE_TYPE_I;
70 pic_output_flag = 1;
71 colour_plane_id = 0;
72 slice_pic_order_cnt_lsb = 0;
73 short_term_ref_pic_set_sps_flag = 1;
74 // ref_pic_set slice_ref_pic_set;
75
76 short_term_ref_pic_set_idx = 0;
77 num_long_term_sps = 0;
78 num_long_term_pics = 0;
79
80 //uint8_t lt_idx_sps[MAX_NUM_REF_PICS];
81 //int poc_lsb_lt[MAX_NUM_REF_PICS];
82 //char used_by_curr_pic_lt_flag[MAX_NUM_REF_PICS];
83
84 //char delta_poc_msb_present_flag[MAX_NUM_REF_PICS];
85 //int delta_poc_msb_cycle_lt[MAX_NUM_REF_PICS];
86
87 slice_temporal_mvp_enabled_flag = 0;
88 slice_sao_luma_flag = 0;
89 slice_sao_chroma_flag = 0;
90
91 num_ref_idx_active_override_flag = 0;
92 num_ref_idx_l0_active=1; // [1;16]
93 num_ref_idx_l1_active=1; // [1;16]
94
95 ref_pic_list_modification_flag_l0 = 0;
96 ref_pic_list_modification_flag_l1 = 0;
97 //uint8_t list_entry_l0[16];
98 //uint8_t list_entry_l1[16];
99
100 mvd_l1_zero_flag = 0;
101 cabac_init_flag = 0;
102 collocated_from_l0_flag = 0;
103 collocated_ref_idx = 0;
104
105 // --- pred_weight_table ---
106
107 luma_log2_weight_denom=0; // [0;7]
108 ChromaLog2WeightDenom=0; // [0;7]
109
110 // first index is L0/L1
111 /*
112 uint8_t luma_weight_flag[2][16]; // bool
113 uint8_t chroma_weight_flag[2][16]; // bool
114 int16_t LumaWeight[2][16];
115 int8_t luma_offset[2][16];
116 int16_t ChromaWeight[2][16][2];
117 int8_t ChromaOffset[2][16][2];
118 */
119
120
121 five_minus_max_num_merge_cand = 0;
122 slice_qp_delta = 0;
123
124 slice_cb_qp_offset = 0;
125 slice_cr_qp_offset = 0;
126
127 cu_chroma_qp_offset_enabled_flag = 0;
128
129 deblocking_filter_override_flag = 0;
130 slice_deblocking_filter_disabled_flag = 0;
131 slice_beta_offset=0; // = pps->beta_offset if undefined
132 slice_tc_offset=0; // = pps->tc_offset if undefined
133
134 slice_loop_filter_across_slices_enabled_flag = 0;
135
136 num_entry_point_offsets = 0;
137 //int offset_len;
138 //std::vector<int> entry_point_offset;
139
140 slice_segment_header_extension_length = 0;
141
142 SliceAddrRS = slice_segment_address;
143 }
144
61145
62146 bool read_pred_weight_table(bitreader* br, slice_segment_header* shdr, decoder_context* ctx)
63147 {
110194 // luma_offset
111195
112196 vlc = get_svlc(br);
113 if (vlc < -128 || vlc > 127) return false;
197 if (vlc < -sps->WpOffsetHalfRangeY || vlc > sps->WpOffsetHalfRangeY-1) return false;
114198 shdr->luma_offset[l][i] = vlc;
115199 }
116200 else {
123207 // delta_chroma_weight
124208
125209 vlc = get_svlc(br);
126 if (vlc < -128 || vlc > 127) return false;
210 if (vlc < -128 || vlc > 127) return false;
127211
128212 shdr->ChromaWeight[l][i][j] = (1<<shdr->ChromaLog2WeightDenom) + vlc;
129213
130214 // delta_chroma_offset
131215
132216 vlc = get_svlc(br);
133 if (vlc < -512 || vlc > 511) return false;
134
135 vlc = Clip3(-128,127, (vlc-((128*shdr->ChromaWeight[l][i][j])
136 >> shdr->ChromaLog2WeightDenom) + 128));
217 if (vlc < -4*sps->WpOffsetHalfRangeC ||
218 vlc > 4*sps->WpOffsetHalfRangeC-1) return false;
219
220 vlc = Clip3(-sps->WpOffsetHalfRangeC,
221 sps->WpOffsetHalfRangeC-1,
222 (sps->WpOffsetHalfRangeC
223 +vlc
224 -((sps->WpOffsetHalfRangeC*shdr->ChromaWeight[l][i][j])
225 >> shdr->ChromaLog2WeightDenom)));
137226
138227 shdr->ChromaOffset[l][i][j] = vlc;
139228 }
152241 }
153242
154243
244 void slice_segment_header::reset()
245 {
246 slice_index = 0;
247
248 first_slice_segment_in_pic_flag = 0;
249 no_output_of_prior_pics_flag = 0;
250 slice_pic_parameter_set_id = 0;
251 dependent_slice_segment_flag = 0;
252 slice_segment_address = 0;
253
254 slice_type = 0;
255 pic_output_flag = 0;
256 colour_plane_id = 0;
257 slice_pic_order_cnt_lsb = 0;
258 short_term_ref_pic_set_sps_flag = 0;
259 slice_ref_pic_set.reset();
260
261 short_term_ref_pic_set_idx = 0;
262 num_long_term_sps = 0;
263 num_long_term_pics= 0;
264
265 for (int i=0;i<MAX_NUM_REF_PICS;i++) {
266 lt_idx_sps[i] = 0;
267 poc_lsb_lt[i] = 0;
268 used_by_curr_pic_lt_flag[i] = 0;
269 delta_poc_msb_present_flag[i] = 0;
270 delta_poc_msb_cycle_lt[i] = 0;
271 }
272
273 slice_temporal_mvp_enabled_flag = 0;
274 slice_sao_luma_flag = 0;
275 slice_sao_chroma_flag = 0;
276
277 num_ref_idx_active_override_flag = 0;
278 num_ref_idx_l0_active = 0;
279 num_ref_idx_l1_active = 0;
280
281 ref_pic_list_modification_flag_l0 = 0;
282 ref_pic_list_modification_flag_l1 = 0;
283 for (int i=0;i<16;i++) {
284 list_entry_l0[i] = 0;
285 list_entry_l1[i] = 0;
286 }
287
288 mvd_l1_zero_flag = 0;
289 cabac_init_flag = 0;
290 collocated_from_l0_flag = 0;
291 collocated_ref_idx = 0;
292
293 luma_log2_weight_denom = 0;
294 ChromaLog2WeightDenom = 0;
295
296 for (int i=0;i<2;i++)
297 for (int j=0;j<16;j++) {
298 luma_weight_flag[i][j] = 0;
299 chroma_weight_flag[i][j] = 0;
300 LumaWeight[i][j] = 0;
301 luma_offset[i][j] = 0;
302 ChromaWeight[i][j][0] = ChromaWeight[i][j][1] = 0;
303 ChromaOffset[i][j][0] = ChromaOffset[i][j][1] = 0;
304 }
305
306 five_minus_max_num_merge_cand = 0;
307 slice_qp_delta = 0;
308
309 slice_cb_qp_offset = 0;
310 slice_cr_qp_offset = 0;
311
312 cu_chroma_qp_offset_enabled_flag = 0;
313
314 deblocking_filter_override_flag = 0;
315 slice_deblocking_filter_disabled_flag = 0;
316 slice_beta_offset = 0;
317 slice_tc_offset = 0;
318
319 slice_loop_filter_across_slices_enabled_flag = 0;
320
321 num_entry_point_offsets = 0;
322 offset_len = 0;
323 entry_point_offset.clear();
324
325 slice_segment_header_extension_length = 0;
326
327 SliceAddrRS = 0;
328 SliceQPY = 0;
329
330 initType = 0;
331
332 MaxNumMergeCand = 0;
333 CurrRpsIdx = 0;
334 CurrRps.reset();
335 NumPocTotalCurr = 0;
336
337 for (int i=0;i<2;i++)
338 for (int j=0;j<MAX_NUM_REF_PICS;j++) {
339 RefPicList[i][j] = 0;
340 RefPicList_POC[i][j] = 0;
341 RefPicList_PicState[i][j] = 0;
342 LongTermRefPic[i][j] = 0;
343 }
344
345 //context_model ctx_model_storage[CONTEXT_MODEL_TABLE_LENGTH];
346
347 RemoveReferencesList.clear();
348
349 ctx_model_storage_defined = false;
350 }
351
352
155353 de265_error slice_segment_header::read(bitreader* br, decoder_context* ctx,
156354 bool* continueDecoding)
157355 {
158356 *continueDecoding = false;
357 reset();
159358
160359 // set defaults
161360
206405 return DE265_OK;
207406 }
208407
408 if (ctx->previous_slice_header == NULL) {
409 return DE265_ERROR_NO_INITIAL_SLICE_HEADER;
410 }
411
209412 *this = *ctx->previous_slice_header;
210413
211414 first_slice_segment_in_pic_flag = 0;
219422 }
220423
221424 if (slice_segment_address < 0 ||
222 slice_segment_address > sps->PicSizeInCtbsY) {
425 slice_segment_address >= sps->PicSizeInCtbsY) {
223426 ctx->add_warning(DE265_WARNING_SLICE_SEGMENT_ADDRESS_INVALID, false);
224427 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
225428 }
226429
430 //printf("SLICE %d (%d)\n",slice_segment_address, sps->PicSizeInCtbsY);
227431
228432
229433 if (!dependent_slice_segment_flag) {
230434 for (int i=0; i<pps->num_extra_slice_header_bits; i++) {
231435 //slice_reserved_undetermined_flag[i]
232 skip_bits(br,1);
436 skip_bits(br,1);
233437 }
234438
235439 slice_type = get_uvlc(br);
248452 }
249453
250454 if (sps->separate_colour_plane_flag == 1) {
251 colour_plane_id = get_bits(br,1);
455 colour_plane_id = get_bits(br,2);
252456 }
253457
254458
265469 if (!short_term_ref_pic_set_sps_flag) {
266470 read_short_term_ref_pic_set(ctx, sps,
267471 br, &slice_ref_pic_set,
268 sps->num_short_term_ref_pic_sets,
472 sps->num_short_term_ref_pic_sets(),
269473 sps->ref_pic_sets,
270474 true);
271475
272 CurrRpsIdx = sps->num_short_term_ref_pic_sets;
476 CurrRpsIdx = sps->num_short_term_ref_pic_sets();
273477 CurrRps = slice_ref_pic_set;
274478 }
275479 else {
276 int nBits = ceil_log2(sps->num_short_term_ref_pic_sets);
480 int nBits = ceil_log2(sps->num_short_term_ref_pic_sets());
277481 if (nBits>0) short_term_ref_pic_set_idx = get_bits(br,nBits);
278482 else short_term_ref_pic_set_idx = 0;
279483
280 if (short_term_ref_pic_set_idx > sps->num_short_term_ref_pic_sets) {
484 if (short_term_ref_pic_set_idx >= sps->num_short_term_ref_pic_sets()) {
281485 ctx->add_warning(DE265_WARNING_SHORT_TERM_REF_PIC_SET_OUT_OF_RANGE, false);
282486 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
283487 }
292496 if (sps->long_term_ref_pics_present_flag) {
293497 if (sps->num_long_term_ref_pics_sps > 0) {
294498 num_long_term_sps = get_uvlc(br);
499 if (num_long_term_sps == UVLC_ERROR) {
500 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
501 }
295502 }
296503 else {
297504 num_long_term_sps = 0;
298505 }
299506
300507 num_long_term_pics= get_uvlc(br);
301
508 if (num_long_term_pics == UVLC_ERROR) {
509 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
510 }
302511
303512 // check maximum number of reference frames
304513
347556 delta_poc_msb_present_flag[i] = get_bits(br,1);
348557 if (delta_poc_msb_present_flag[i]) {
349558 delta_poc_msb_cycle_lt[i] = get_uvlc(br);
559 if (delta_poc_msb_cycle_lt[i]==UVLC_ERROR) {
560 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
561 }
350562 }
351563 else {
352564 delta_poc_msb_cycle_lt[i] = 0;
381593
382594
383595 // --- SAO ---
384
596
385597 if (sps->sample_adaptive_offset_enabled_flag) {
386598 slice_sao_luma_flag = get_bits(br,1);
387 slice_sao_chroma_flag = get_bits(br,1);
599
600 if (sps->ChromaArrayType != CHROMA_MONO) {
601 slice_sao_chroma_flag = get_bits(br,1);
602 }
603 else {
604 slice_sao_chroma_flag = 0;
605 }
388606 }
389607 else {
390608 slice_sao_luma_flag = 0;
391609 slice_sao_chroma_flag = 0;
392610 }
611
612 num_ref_idx_l0_active = 0;
613 num_ref_idx_l1_active = 0;
393614
394615 if (slice_type == SLICE_TYPE_P ||
395616 slice_type == SLICE_TYPE_B) {
416637 num_ref_idx_l1_active = pps->num_ref_idx_l1_default_active;
417638 }
418639
640 if (num_ref_idx_l0_active > 16) { return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE; }
641 if (num_ref_idx_l1_active > 16) { return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE; }
642
419643 NumPocTotalCurr = CurrRps.NumPocTotalCurr_shortterm_only + NumLtPics;
420644
421645 if (pps->lists_modification_present_flag && NumPocTotalCurr > 1) {
474698 else {
475699 collocated_ref_idx = 0;
476700 }
477 }
701
702 // check whether collocated_ref_idx points to a valid index
703
704 if (( collocated_from_l0_flag && collocated_ref_idx >= num_ref_idx_l0_active) ||
705 (!collocated_from_l0_flag && collocated_ref_idx >= num_ref_idx_l1_active)) {
706 ctx->add_warning(DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE, false);
707 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
708 }
709 }
710
478711
479712 if ((pps->weighted_pred_flag && slice_type == SLICE_TYPE_P) ||
480713 (pps->weighted_bipred_flag && slice_type == SLICE_TYPE_B)) {
493726 }
494727 MaxNumMergeCand = 5-five_minus_max_num_merge_cand;
495728 }
496
729
497730 slice_qp_delta = get_svlc(br);
498731 if (slice_qp_delta == UVLC_ERROR) {
499732 ctx->add_warning(DE265_WARNING_SLICEHEADER_INVALID, false);
517750 else {
518751 slice_cb_qp_offset = 0;
519752 slice_cr_qp_offset = 0;
753 }
754
755 if (pps->range_extension.chroma_qp_offset_list_enabled_flag) {
756 cu_chroma_qp_offset_enabled_flag = get_bits(br,1);
520757 }
521758
522759 if (pps->deblocking_filter_override_enabled_flag) {
569806 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
570807 }
571808
809 if (pps->entropy_coding_sync_enabled_flag) {
810 // check num_entry_points for valid range
811
812 int firstCTBRow = slice_segment_address / sps->PicWidthInCtbsY;
813 int lastCTBRow = firstCTBRow + num_entry_point_offsets;
814 if (lastCTBRow >= sps->PicHeightInCtbsY) {
815 ctx->add_warning(DE265_WARNING_SLICEHEADER_INVALID, false);
816 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
817 }
818 }
819
820 if (pps->tiles_enabled_flag) {
821 if (num_entry_point_offsets > pps->num_tile_columns * pps->num_tile_rows) {
822 ctx->add_warning(DE265_WARNING_SLICEHEADER_INVALID, false);
823 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
824 }
825 }
826
572827 entry_point_offset.resize( num_entry_point_offsets );
573828
574829 if (num_entry_point_offsets > 0) {
578833 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
579834 }
580835 offset_len++;
836
837 if (offset_len > 32) {
838 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
839 }
581840
582841 for (int i=0; i<num_entry_point_offsets; i++) {
583842 {
601860 ctx->add_warning(DE265_WARNING_SLICEHEADER_INVALID, false);
602861 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
603862 }
604
863
605864 for (int i=0; i<slice_segment_header_extension_length; i++) {
606865 //slice_segment_header_extension_data_byte[i]
607866 get_bits(br,8);
609868 }
610869
611870
871 compute_derived_values(pps);
872
873 *continueDecoding = true;
874 return DE265_OK;
875 }
876
877
878 de265_error slice_segment_header::write(error_queue* errqueue, CABAC_encoder& out,
879 const seq_parameter_set* sps,
880 const pic_parameter_set* pps,
881 uint8_t nal_unit_type)
882 {
883 out.write_bit(first_slice_segment_in_pic_flag);
884
885 if (isRapPic(nal_unit_type)) { // TODO: is this still correct ? Should we drop RapPicFlag ?
886 out.write_bit(no_output_of_prior_pics_flag);
887 }
888
889 if (slice_pic_parameter_set_id > DE265_MAX_PPS_SETS) {
890 errqueue->add_warning(DE265_WARNING_NONEXISTING_PPS_REFERENCED, false);
891 return DE265_OK;
892 }
893 out.write_uvlc(slice_pic_parameter_set_id);
894
895 if (!first_slice_segment_in_pic_flag) {
896 if (pps->dependent_slice_segments_enabled_flag) {
897 out.write_bit(dependent_slice_segment_flag);
898 }
899
900 out.write_bits(slice_segment_address, ceil_log2(sps->PicSizeInCtbsY));
901
902 if (dependent_slice_segment_flag) {
903 if (slice_segment_address == 0) {
904 errqueue->add_warning(DE265_WARNING_DEPENDENT_SLICE_WITH_ADDRESS_ZERO, false);
905 return DE265_OK;
906 }
907 }
908 }
909
910 if (slice_segment_address < 0 ||
911 slice_segment_address > sps->PicSizeInCtbsY) {
912 errqueue->add_warning(DE265_WARNING_SLICE_SEGMENT_ADDRESS_INVALID, false);
913 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
914 }
915
916
917
918 if (!dependent_slice_segment_flag) {
919 for (int i=0; i<pps->num_extra_slice_header_bits; i++) {
920 //slice_reserved_undetermined_flag[i]
921 out.skip_bits(1);
922 }
923
924 if (slice_type > 2) {
925 errqueue->add_warning(DE265_WARNING_SLICEHEADER_INVALID, false);
926 return DE265_OK;
927 }
928 out.write_uvlc(slice_type);
929
930 if (pps->output_flag_present_flag) {
931 out.write_bit(pic_output_flag);
932 }
933
934 if (sps->separate_colour_plane_flag == 1) {
935 out.write_bits(colour_plane_id,2);
936 }
937
938
939 int NumLtPics = 0;
940
941 if (nal_unit_type != NAL_UNIT_IDR_W_RADL &&
942 nal_unit_type != NAL_UNIT_IDR_N_LP) {
943 out.write_bits(slice_pic_order_cnt_lsb, sps->log2_max_pic_order_cnt_lsb);
944 out.write_bit(short_term_ref_pic_set_sps_flag);
945
946 if (!short_term_ref_pic_set_sps_flag) {
947 /* TODO
948 read_short_term_ref_pic_set(ctx, sps,
949 br, &slice_ref_pic_set,
950 sps->num_short_term_ref_pic_sets,
951 sps->ref_pic_sets,
952 true);
953 */
954 //CurrRpsIdx = sps->num_short_term_ref_pic_sets;
955 //CurrRps = slice_ref_pic_set;
956 }
957 else {
958 int nBits = ceil_log2(sps->num_short_term_ref_pic_sets());
959 if (nBits>0) out.write_bits(short_term_ref_pic_set_idx,nBits);
960 else { assert(short_term_ref_pic_set_idx==0); }
961
962 if (short_term_ref_pic_set_idx > sps->num_short_term_ref_pic_sets()) {
963 errqueue->add_warning(DE265_WARNING_SHORT_TERM_REF_PIC_SET_OUT_OF_RANGE, false);
964 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
965 }
966
967 //CurrRpsIdx = short_term_ref_pic_set_idx;
968 //CurrRps = sps->ref_pic_sets[CurrRpsIdx];
969 }
970
971
972 // --- long-term MC ---
973
974 if (sps->long_term_ref_pics_present_flag) {
975 if (sps->num_long_term_ref_pics_sps > 0) {
976 out.write_uvlc(num_long_term_sps);
977 }
978 else {
979 assert(num_long_term_sps == 0);
980 }
981
982 out.write_uvlc(num_long_term_pics);
983
984
985 // check maximum number of reference frames
986
987 if (num_long_term_sps +
988 num_long_term_pics +
989 CurrRps.NumNegativePics +
990 CurrRps.NumPositivePics
991 > sps->sps_max_dec_pic_buffering[sps->sps_max_sub_layers-1])
992 {
993 errqueue->add_warning(DE265_WARNING_MAX_NUM_REF_PICS_EXCEEDED, false);
994 return DE265_OK;
995 }
996
997 for (int i=0; i<num_long_term_sps + num_long_term_pics; i++) {
998 if (i < num_long_term_sps) {
999 int nBits = ceil_log2(sps->num_long_term_ref_pics_sps);
1000 out.write_bits(lt_idx_sps[i], nBits);
1001
1002 // check that the referenced lt-reference really exists
1003
1004 if (lt_idx_sps[i] >= sps->num_long_term_ref_pics_sps) {
1005 errqueue->add_warning(DE265_NON_EXISTING_LT_REFERENCE_CANDIDATE_IN_SLICE_HEADER, false);
1006 return DE265_OK;
1007 }
1008
1009 //ctx->PocLsbLt[i] = sps->lt_ref_pic_poc_lsb_sps[ lt_idx_sps[i] ];
1010 //ctx->UsedByCurrPicLt[i] = sps->used_by_curr_pic_lt_sps_flag[ lt_idx_sps[i] ];
1011 }
1012 else {
1013 int nBits = sps->log2_max_pic_order_cnt_lsb;
1014 out.write_bits(poc_lsb_lt[i], nBits);
1015 out.write_bit(used_by_curr_pic_lt_flag[i]);
1016
1017 //ctx->PocLsbLt[i] = poc_lsb_lt[i];
1018 //ctx->UsedByCurrPicLt[i] = used_by_curr_pic_lt_flag[i];
1019 }
1020
1021 //if (ctx->UsedByCurrPicLt[i]) {
1022 //NumLtPics++;
1023 //}
1024
1025 out.write_bit(delta_poc_msb_present_flag[i]);
1026 if (delta_poc_msb_present_flag[i]) {
1027 out.write_uvlc(delta_poc_msb_cycle_lt[i]);
1028 }
1029 else {
1030 assert(delta_poc_msb_cycle_lt[i] == 0);
1031 }
1032
1033 /*
1034 if (i==0 || i==num_long_term_sps) {
1035 ctx->DeltaPocMsbCycleLt[i] = delta_poc_msb_cycle_lt[i];
1036 }
1037 else {
1038 ctx->DeltaPocMsbCycleLt[i] = (delta_poc_msb_cycle_lt[i] +
1039 ctx->DeltaPocMsbCycleLt[i-1]);
1040 }
1041 */
1042 }
1043 }
1044 else {
1045 assert(num_long_term_sps == 0);
1046 assert(num_long_term_pics== 0);
1047 }
1048
1049 if (sps->sps_temporal_mvp_enabled_flag) {
1050 out.write_bit(slice_temporal_mvp_enabled_flag);
1051 }
1052 else {
1053 assert(slice_temporal_mvp_enabled_flag == 0);
1054 }
1055 }
1056 else {
1057 assert(slice_pic_order_cnt_lsb == 0);
1058 assert(num_long_term_sps == 0);
1059 assert(num_long_term_pics== 0);
1060 }
1061
1062
1063 // --- SAO ---
1064
1065 if (sps->sample_adaptive_offset_enabled_flag) {
1066 out.write_bit(slice_sao_luma_flag);
1067 out.write_bit(slice_sao_chroma_flag);
1068 }
1069 else {
1070 assert(slice_sao_luma_flag == 0);
1071 assert(slice_sao_chroma_flag== 0);
1072 }
1073
1074 if (slice_type == SLICE_TYPE_P ||
1075 slice_type == SLICE_TYPE_B) {
1076 out.write_bit(num_ref_idx_active_override_flag);
1077
1078 if (num_ref_idx_active_override_flag) {
1079 out.write_uvlc(num_ref_idx_l0_active);
1080 num_ref_idx_l0_active++;;
1081
1082 if (slice_type == SLICE_TYPE_B) {
1083 out.write_uvlc(num_ref_idx_l1_active);
1084 num_ref_idx_l1_active++;
1085 }
1086 }
1087 else {
1088 assert(num_ref_idx_l0_active == pps->num_ref_idx_l0_default_active);
1089 assert(num_ref_idx_l1_active == pps->num_ref_idx_l1_default_active);
1090 }
1091
1092 NumPocTotalCurr = CurrRps.NumPocTotalCurr_shortterm_only + NumLtPics;
1093
1094 if (pps->lists_modification_present_flag && NumPocTotalCurr > 1) {
1095
1096 int nBits = ceil_log2(NumPocTotalCurr);
1097
1098 out.write_bit(ref_pic_list_modification_flag_l0);
1099 if (ref_pic_list_modification_flag_l0) {
1100 for (int i=0;i<num_ref_idx_l0_active;i++) {
1101 out.write_bits(list_entry_l0[i], nBits);
1102 }
1103 }
1104
1105 if (slice_type == SLICE_TYPE_B) {
1106 out.write_bit(ref_pic_list_modification_flag_l1);
1107 if (ref_pic_list_modification_flag_l1) {
1108 for (int i=0;i<num_ref_idx_l1_active;i++) {
1109 out.write_bits(list_entry_l1[i], nBits);
1110 }
1111 }
1112 }
1113 else {
1114 assert(ref_pic_list_modification_flag_l1 == 0);
1115 }
1116 }
1117 else {
1118 assert(ref_pic_list_modification_flag_l0 == 0);
1119 assert(ref_pic_list_modification_flag_l1 == 0);
1120 }
1121
1122 if (slice_type == SLICE_TYPE_B) {
1123 out.write_bit(mvd_l1_zero_flag);
1124 }
1125
1126 if (pps->cabac_init_present_flag) {
1127 out.write_bit(cabac_init_flag);
1128 }
1129 else {
1130 assert(cabac_init_flag == 0);
1131 }
1132
1133 if (slice_temporal_mvp_enabled_flag) {
1134 if (slice_type == SLICE_TYPE_B)
1135 out.write_bit(collocated_from_l0_flag);
1136 else
1137 { assert(collocated_from_l0_flag == 1); }
1138
1139 if (( collocated_from_l0_flag && num_ref_idx_l0_active > 1) ||
1140 (!collocated_from_l0_flag && num_ref_idx_l1_active > 1)) {
1141 out.write_uvlc(collocated_ref_idx);
1142 }
1143 else {
1144 assert(collocated_ref_idx == 0);
1145 }
1146 }
1147
1148 if ((pps->weighted_pred_flag && slice_type == SLICE_TYPE_P) ||
1149 (pps->weighted_bipred_flag && slice_type == SLICE_TYPE_B)) {
1150
1151 assert(0);
1152 /* TODO
1153 if (!read_pred_weight_table(br,this,ctx))
1154 {
1155 ctx->add_warning(DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE, false);
1156 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
1157 }
1158 */
1159 }
1160
1161 out.write_uvlc(five_minus_max_num_merge_cand);
1162 //MaxNumMergeCand = 5-five_minus_max_num_merge_cand;
1163 }
1164
1165 out.write_svlc(slice_qp_delta);
1166
1167 if (pps->pps_slice_chroma_qp_offsets_present_flag) {
1168 out.write_svlc(slice_cb_qp_offset);
1169 out.write_svlc(slice_cr_qp_offset);
1170 }
1171 else {
1172 assert(slice_cb_qp_offset == 0);
1173 assert(slice_cr_qp_offset == 0);
1174 }
1175
1176 if (pps->deblocking_filter_override_enabled_flag) {
1177 out.write_bit(deblocking_filter_override_flag);
1178 }
1179 else {
1180 assert(deblocking_filter_override_flag == 0);
1181 }
1182
1183 //slice_beta_offset = pps->beta_offset;
1184 //slice_tc_offset = pps->tc_offset;
1185
1186 if (deblocking_filter_override_flag) {
1187 out.write_bit(slice_deblocking_filter_disabled_flag);
1188 if (!slice_deblocking_filter_disabled_flag) {
1189 out.write_svlc(slice_beta_offset/2);
1190 out.write_svlc(slice_tc_offset /2);
1191 }
1192 }
1193 else {
1194 assert(slice_deblocking_filter_disabled_flag == pps->pic_disable_deblocking_filter_flag);
1195 }
1196
1197 if (pps->pps_loop_filter_across_slices_enabled_flag &&
1198 (slice_sao_luma_flag || slice_sao_chroma_flag ||
1199 !slice_deblocking_filter_disabled_flag )) {
1200 out.write_bit(slice_loop_filter_across_slices_enabled_flag);
1201 }
1202 else {
1203 assert(slice_loop_filter_across_slices_enabled_flag ==
1204 pps->pps_loop_filter_across_slices_enabled_flag);
1205 }
1206 }
1207
1208 if (pps->tiles_enabled_flag || pps->entropy_coding_sync_enabled_flag ) {
1209 out.write_uvlc(num_entry_point_offsets);
1210
1211 if (num_entry_point_offsets > 0) {
1212 out.write_uvlc(offset_len-1);
1213
1214 for (int i=0; i<num_entry_point_offsets; i++) {
1215 {
1216 int prev=0;
1217 if (i>0) prev = entry_point_offset[i-1];
1218 out.write_bits(entry_point_offset[i]-prev-1, offset_len);
1219 }
1220 }
1221 }
1222 }
1223 else {
1224 assert(num_entry_point_offsets == 0);
1225 }
1226
1227 if (pps->slice_segment_header_extension_present_flag) {
1228 out.write_uvlc(slice_segment_header_extension_length);
1229 if (slice_segment_header_extension_length > 1000) { // TODO: safety check against too large values
1230 errqueue->add_warning(DE265_WARNING_SLICEHEADER_INVALID, false);
1231 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
1232 }
1233
1234 for (int i=0; i<slice_segment_header_extension_length; i++) {
1235 //slice_segment_header_extension_data_byte[i]
1236 out.skip_bits(8);
1237 }
1238 }
1239
1240 return DE265_OK;
1241 }
1242
1243 void slice_segment_header::compute_derived_values(const pic_parameter_set* pps)
1244 {
6121245 // --- init variables ---
6131246
6141247 SliceQPY = pps->pic_init_qp + slice_qp_delta;
6201253 case SLICE_TYPE_B: initType = 2 - cabac_init_flag; break;
6211254 }
6221255
623 *continueDecoding = true;
624 return DE265_OK;
625 }
626
1256 MaxNumMergeCand = 5-five_minus_max_num_merge_cand;
1257 }
6271258
6281259
6291260 //-----------------------------------------------------------------------
6501281
6511282
6521283 LOG0("----------------- SLICE -----------------\n");
653 LOG1("first_slice_segment_in_pic_flag : %d\n", first_slice_segment_in_pic_flag);
1284 LOG1("first_slice_segment_in_pic_flag : %d\n", first_slice_segment_in_pic_flag);
6541285 if (ctx->get_nal_unit_type() >= NAL_UNIT_BLA_W_LP &&
6551286 ctx->get_nal_unit_type() <= NAL_UNIT_RESERVED_IRAP_VCL23) {
656 LOG1("no_output_of_prior_pics_flag : %d\n", no_output_of_prior_pics_flag);
657 }
658
659 LOG1("slice_pic_parameter_set_id : %d\n", slice_pic_parameter_set_id);
1287 LOG1("no_output_of_prior_pics_flag : %d\n", no_output_of_prior_pics_flag);
1288 }
1289
1290 LOG1("slice_pic_parameter_set_id : %d\n", slice_pic_parameter_set_id);
6601291
6611292 if (!first_slice_segment_in_pic_flag) {
662 if (pps->dependent_slice_segments_enabled_flag) {
1293 //if (pps->dependent_slice_segments_enabled_flag) {
6631294 LOG1("dependent_slice_segment_flag : %d\n", dependent_slice_segment_flag);
664 }
1295 //}
6651296 LOG1("slice_segment_address : %d\n", slice_segment_address);
6661297 }
6671298
6891320 LOG1("short_term_ref_pic_set_sps_flag : %d\n", short_term_ref_pic_set_sps_flag);
6901321
6911322 if (!short_term_ref_pic_set_sps_flag) {
692 LOG1("ref_pic_set[ %2d ]: ",sps->num_short_term_ref_pic_sets);
1323 LOG1("ref_pic_set[ %2d ]: ",sps->num_short_term_ref_pic_sets());
6931324 dump_compact_short_term_ref_pic_set(&slice_ref_pic_set, 16, fh);
6941325 }
695 else if (sps->num_short_term_ref_pic_sets > 1) {
1326 else if (sps->num_short_term_ref_pic_sets() > 1) {
6961327 LOG1("short_term_ref_pic_set_idx : %d\n", short_term_ref_pic_set_idx);
6971328 dump_compact_short_term_ref_pic_set(&sps->ref_pic_sets[short_term_ref_pic_set_idx], 16, fh);
6981329 }
7041335
7051336 LOG1("num_long_term_pics : %d\n", num_long_term_pics);
7061337
707 #if 0
1338 #if 0
7081339 for (int i=0; i<num_long_term_sps + num_long_term_pics; i++) {
7091340 LOG2("PocLsbLt[%d] : %d\n", i, ctx->PocLsbLt[i]);
7101341 LOG2("UsedByCurrPicLt[%d] : %d\n", i, ctx->UsedByCurrPicLt[i]);
7171348 LOG1("slice_temporal_mvp_enabled_flag : %d\n", slice_temporal_mvp_enabled_flag);
7181349 }
7191350 }
720
1351
7211352
7221353 if (sps->sample_adaptive_offset_enabled_flag) {
7231354 LOG1("slice_sao_luma_flag : %d\n", slice_sao_luma_flag);
7561387 if (slice_type == SLICE_TYPE_B) {
7571388 LOG1("mvd_l1_zero_flag : %d\n", mvd_l1_zero_flag);
7581389 }
759
1390
7601391 LOG1("cabac_init_flag : %d\n", cabac_init_flag);
7611392
7621393 if (slice_temporal_mvp_enabled_flag) {
8521483 /*
8531484 if( slice_segment_header_extension_present_flag ) {
8541485 slice_segment_header_extension_length
855 for( i = 0; i < slice_segment_header_extension_length; i++)
1486 for( i = 0; i < slice_segment_header_extension_length; i++)
8561487 slice_segment_header_extension_data_byte[i]
8571488 }
8581489 byte_alignment()
8691500
8701501
8711502
872
873
874 static void set_initValue(slice_segment_header* shdr,
875 context_model* model, int initValue)
876 {
877 int slopeIdx = initValue >> 4;
878 int intersecIdx = initValue & 0xF;
879 int m = slopeIdx*5 - 45;
880 int n = (intersecIdx<<3) - 16;
881 int preCtxState = Clip3(1,126, ((m*Clip3(0,51, shdr->SliceQPY))>>4)+n);
882
883 logtrace(LogSlice,"QP=%d slopeIdx=%d intersecIdx=%d m=%d n=%d\n",shdr->SliceQPY,slopeIdx,intersecIdx,m,n);
884
885 model->MPSbit=(preCtxState<=63) ? 0 : 1;
886 model->state = model->MPSbit ? (preCtxState-64) : (63-preCtxState);
887
888 // model state will always be between [0;62]
889
890 assert(model->state <= 62);
891 }
892
893
894 static const int initValue_split_cu_flag[3][3] = {
895 { 139,141,157 },
896 { 107,139,126 },
897 { 107,139,126 },
898 };
899 static const int initValue_cu_skip_flag[2][3] = {
900 { 197,185,201 },
901 { 197,185,201 },
902 };
903 static const int initValue_part_mode[9] = { 184,154,139, 154,154,154, 139,154,154 };
904 static const int initValue_prev_intra_luma_pred_flag[3] = { 184,154,183 };
905 static const int initValue_intra_chroma_pred_mode[3] = { 63,152,152 };
906 static const int initValue_cbf_luma[4] = { 111,141,153,111 };
907 static const int initValue_cbf_chroma[12] = { 94,138,182,154,149,107,167,154,149,92,167,154 };
908 static const int initValue_split_transform_flag[9] = { 153,138,138, 124,138,94, 224,167,122 }; // FIX712
909 static const int initValue_last_significant_coefficient_prefix[54] = {
910 110,110,124,125,140,153,125,127,140,109,111,143,127,111, 79,108,123, 63,
911 125,110, 94,110, 95, 79,125,111,110, 78,110,111,111, 95, 94,108,123,108,
912 125,110,124,110, 95, 94,125,111,111, 79,125,126,111,111, 79,108,123, 93
913 };
914 static const int initValue_coded_sub_block_flag[12] = { 91,171,134,141,121,140,61,154,121,140,61,154 };
915 static const int initValue_significant_coeff_flag[3][42] = {
916 {
917 111, 111, 125, 110, 110, 94, 124, 108, 124, 107, 125, 141, 179, 153, 125, 107,
918 125, 141, 179, 153, 125, 107, 125, 141, 179, 153, 125, 140, 139, 182, 182, 152,
919 136, 152, 136, 153, 136, 139, 111, 136, 139, 111
920 },
921 {
922 155, 154, 139, 153, 139, 123, 123, 63, 153, 166, 183, 140, 136, 153, 154, 166,
923 183, 140, 136, 153, 154, 166, 183, 140, 136, 153, 154, 170, 153, 123, 123, 107,
924 121, 107, 121, 167, 151, 183, 140, 151, 183, 140,
925 },
926 {
927 170, 154, 139, 153, 139, 123, 123, 63, 124, 166, 183, 140, 136, 153, 154, 166,
928 183, 140, 136, 153, 154, 166, 183, 140, 136, 153, 154, 170, 153, 138, 138, 122,
929 121, 122, 121, 167, 151, 183, 140, 151, 183, 140
930 },
931 };
932 static const int initValue_coeff_abs_level_greater1_flag[72] = {
933 140, 92,137,138,140,152,138,139,153, 74,149, 92,139,107,122,152,
934 140,179,166,182,140,227,122,197,154,196,196,167,154,152,167,182,
935 182,134,149,136,153,121,136,137,169,194,166,167,154,167,137,182,
936 154,196,167,167,154,152,167,182,182,134,149,136,153,121,136,122,
937 169,208,166,167,154,152,167,182
938 };
939 static const int initValue_coeff_abs_level_greater2_flag[18] = {
940 138,153,136,167,152,152,107,167, 91,122,107,167,
941 107,167, 91,107,107,167
942 };
943 static const int initValue_sao_merge_leftUp_flag[3] = { 153,153,153 };
944 static const int initValue_sao_type_idx_lumaChroma_flag[3] = { 200,185,160 };
945 static const int initValue_cu_qp_delta_abs[2] = { 154,154 };
946 static const int initValue_transform_skip_flag[2] = { 139,139 };
947 static const int initValue_merge_flag[2] = { 110,154 };
948 static const int initValue_merge_idx[2] = { 122,137 };
949 static const int initValue_pred_mode_flag[2] = { 149,134 };
950 static const int initValue_abs_mvd_greater01_flag[4] = { 140,198,169,198 };
951 static const int initValue_mvp_lx_flag[1] = { 168 };
952 static const int initValue_rqt_root_cbf[1] = { 79 };
953 static const int initValue_ref_idx_lX[2] = { 153,153 };
954 static const int initValue_inter_pred_idc[5] = { 95,79,63,31,31 };
955 static const int initValue_cu_transquant_bypass_flag[3] = { 154,154,154 };
956
957
958 static void init_context(thread_context* tctx,
959 enum context_model_indices idx,
960 const int* initValues, int len)
961 {
962 for (int i=0;i<len;i++)
963 {
964 set_initValue(tctx->shdr,
965 &tctx->ctx_model[idx+i],
966 initValues[i]);
967 }
968 }
1503 void initialize_CABAC_models(thread_context* tctx)
1504 {
1505 const int QPY = tctx->shdr->SliceQPY;
1506 const int initType = tctx->shdr->initType;
1507 assert(initType >= 0 && initType <= 2);
1508
1509 tctx->ctx_model.init(initType, QPY);
1510
1511 for (int i=0;i<4;i++) {
1512 tctx->StatCoeff[i] = 0;
1513 }
1514 }
1515
9691516
9701517
9711518 static int decode_transform_skip_flag(thread_context* tctx, int cIdx)
9761523
9771524 int bit = decode_CABAC_bit(&tctx->cabac_decoder,
9781525 &tctx->ctx_model[CONTEXT_MODEL_TRANSFORM_SKIP_FLAG+context]);
1526
1527 logtrace(LogSymbols,"$1 transform_skip_flag=%d\n",bit);
1528
9791529 return bit;
9801530 }
9811531
9851535 logtrace(LogSlice,"# sao_merge_left/up_flag\n");
9861536 int bit = decode_CABAC_bit(&tctx->cabac_decoder,
9871537 &tctx->ctx_model[CONTEXT_MODEL_SAO_MERGE_FLAG]);
1538
1539 logtrace(LogSymbols,"$1 sao_merge_flag=%d\n",bit);
1540
9881541 return bit;
9891542 }
9901543
9981551 &tctx->ctx_model[CONTEXT_MODEL_SAO_TYPE_IDX]);
9991552
10001553 if (bit0==0) {
1554 logtrace(LogSymbols,"$1 sao_type_idx=%d\n",0);
10011555 return 0;
10021556 }
10031557 else {
10041558 int bit1 = decode_CABAC_bypass(&tctx->cabac_decoder);
10051559 if (bit1==0) {
1560 logtrace(LogSymbols,"$1 sao_type_idx=%d\n",1);
10061561 return 1;
10071562 }
10081563 else {
1564 logtrace(LogSymbols,"$1 sao_type_idx=%d\n",2);
10091565 return 2;
10101566 }
10111567 }
10121568 }
10131569
10141570
1015 static int decode_sao_offset_abs(thread_context* tctx)
1571 static int decode_sao_offset_abs(thread_context* tctx, int bitDepth)
10161572 {
10171573 logtrace(LogSlice,"# sao_offset_abs\n");
1018 int bitDepth = 8;
10191574 int cMax = (1<<(libde265_min(bitDepth,10)-5))-1;
10201575 int value = decode_CABAC_TU_bypass(&tctx->cabac_decoder, cMax);
1576 logtrace(LogSymbols,"$1 sao_offset_abs=%d\n",value);
10211577 return value;
10221578 }
10231579
10261582 {
10271583 logtrace(LogSlice,"# sao_class\n");
10281584 int value = decode_CABAC_FL_bypass(&tctx->cabac_decoder, 2);
1585 logtrace(LogSymbols,"$1 sao_class=%d\n",value);
10291586 return value;
10301587 }
10311588
10341591 {
10351592 logtrace(LogSlice,"# sao_offset_sign\n");
10361593 int value = decode_CABAC_bypass(&tctx->cabac_decoder);
1594 logtrace(LogSymbols,"$1 sao_offset_sign=%d\n",value);
10371595 return value;
10381596 }
10391597
10421600 {
10431601 logtrace(LogSlice,"# sao_band_position\n");
10441602 int value = decode_CABAC_FL_bypass(&tctx->cabac_decoder,5);
1603 logtrace(LogSymbols,"$1 sao_band_position=%d\n",value);
10451604 return value;
10461605 }
10471606
10511610 logtrace(LogSlice,"# cu_transquant_bypass_enable_flag\n");
10521611 int value = decode_CABAC_bit(&tctx->cabac_decoder,
10531612 &tctx->ctx_model[CONTEXT_MODEL_CU_TRANSQUANT_BYPASS_FLAG]);
1613 logtrace(LogSymbols,"$1 transquant_bypass_flag=%d\n",value);
10541614 return value;
10551615 }
10561616
10611621 static int decode_split_cu_flag(thread_context* tctx,
10621622 int x0, int y0, int ctDepth)
10631623 {
1064 //decoder_context* ctx = tctx->decctx;
1065
1066 if (x0==64 && y0==448) {
1067 //raise(SIGINT);
1068 }
1069
10701624 // check if neighbors are available
10711625
1072 int availableL = check_CTB_available(tctx->img,tctx->shdr, x0,y0, x0-1,y0);
1073 int availableA = check_CTB_available(tctx->img,tctx->shdr, x0,y0, x0,y0-1);
1626 int availableL = check_CTB_available(tctx->img, x0,y0, x0-1,y0);
1627 int availableA = check_CTB_available(tctx->img, x0,y0, x0,y0-1);
10741628
10751629 int condL = 0;
10761630 int condA = 0;
10891643
10901644 logtrace(LogSlice,"> split_cu_flag R=%x, ctx=%d, bit=%d\n", tctx->cabac_decoder.range,context,bit);
10911645
1646 logtrace(LogSymbols,"$1 split_cu_flag=%d\n",bit);
1647
10921648 return bit;
10931649 }
10941650
11001656
11011657 // check if neighbors are available
11021658
1103 int availableL = check_CTB_available(tctx->img,tctx->shdr, x0,y0, x0-1,y0);
1104 int availableA = check_CTB_available(tctx->img,tctx->shdr, x0,y0, x0,y0-1);
1659 int availableL = check_CTB_available(tctx->img, x0,y0, x0-1,y0);
1660 int availableA = check_CTB_available(tctx->img, x0,y0, x0,y0-1);
11051661
11061662 int condL = 0;
11071663 int condA = 0;
11201676
11211677 logtrace(LogSlice,"> cu_skip_flag R=%x, ctx=%d, bit=%d\n", tctx->cabac_decoder.range,context,bit);
11221678
1679 logtrace(LogSymbols,"$1 cu_skip_flag=%d\n",bit);
1680
11231681 return bit;
11241682 }
11251683
11361694
11371695 logtrace(LogSlice,"> %s\n",bit ? "2Nx2N" : "NxN");
11381696
1697 logtrace(LogSymbols,"$1 part_mode=%d\n",bit ? PART_2Nx2N : PART_NxN);
1698
11391699 return bit ? PART_2Nx2N : PART_NxN;
11401700 }
11411701 else {
11421702 int bit0 = decode_CABAC_bit(&tctx->cabac_decoder, &tctx->ctx_model[CONTEXT_MODEL_PART_MODE+0]);
1143 if (bit0) { return PART_2Nx2N; }
1703 if (bit0) { logtrace(LogSymbols,"$1 part_mode=%d\n",PART_2Nx2N); return PART_2Nx2N; }
11441704
11451705 // CHECK_ME: I optimize code and fix bug here, need more VERIFY!
11461706 int bit1 = decode_CABAC_bit(&tctx->cabac_decoder, &tctx->ctx_model[CONTEXT_MODEL_PART_MODE+1]);
11471707 if (cLog2CbSize > img->sps.Log2MinCbSizeY) {
11481708 if (!img->sps.amp_enabled_flag) {
1709 logtrace(LogSymbols,"$1 part_mode=%d\n",bit1 ? PART_2NxN : PART_Nx2N);
11491710 return bit1 ? PART_2NxN : PART_Nx2N;
11501711 }
11511712 else {
11521713 int bit3 = decode_CABAC_bit(&tctx->cabac_decoder, &tctx->ctx_model[CONTEXT_MODEL_PART_MODE+3]);
11531714 if (bit3) {
1715 logtrace(LogSymbols,"$1 part_mode=%d\n",bit1 ? PART_2NxN : PART_Nx2N);
11541716 return bit1 ? PART_2NxN : PART_Nx2N;
11551717 }
11561718
11571719 int bit4 = decode_CABAC_bypass(&tctx->cabac_decoder);
1158 if ( bit1 && bit4) return PART_2NxnD;
1159 if ( bit1 && !bit4) return PART_2NxnU;
1160 if (!bit1 && !bit4) return PART_nLx2N;
1161 if (!bit1 && bit4) return PART_nRx2N;
1720 if ( bit1 && bit4) {
1721 logtrace(LogSymbols,"$1 part_mode=%d\n",PART_2NxnD);
1722 return PART_2NxnD;
1723 }
1724 if ( bit1 && !bit4) {
1725 logtrace(LogSymbols,"$1 part_mode=%d\n",PART_2NxnU);
1726 return PART_2NxnU;
1727 }
1728 if (!bit1 && !bit4) {
1729 logtrace(LogSymbols,"$1 part_mode=%d\n",PART_nLx2N);
1730 return PART_nLx2N;
1731 }
1732 if (!bit1 && bit4) {
1733 logtrace(LogSymbols,"$1 part_mode=%d\n",PART_nRx2N);
1734 return PART_nRx2N;
1735 }
11621736 }
11631737 }
11641738 else {
11651739 // TODO, we could save one if here when first decoding the next bin and then
11661740 // checkcLog2CbSize==3 when it is '0'
11671741
1168 if (bit1) return PART_2NxN;
1742 if (bit1) {
1743 logtrace(LogSymbols,"$1 part_mode=%d\n",PART_2NxN);
1744 return PART_2NxN;
1745 }
11691746
11701747 if (cLog2CbSize==3) {
1748 logtrace(LogSymbols,"$1 part_mode=%d\n",PART_Nx2N);
11711749 return PART_Nx2N;
11721750 }
11731751 else {
11741752 int bit2 = decode_CABAC_bit(&tctx->cabac_decoder, &tctx->ctx_model[CONTEXT_MODEL_PART_MODE+2]);
1753 logtrace(LogSymbols,"$1 part_mode=%d\n",PART_NxN-bit2);
11751754 return (enum PartMode)((int)PART_NxN - bit2)/*bit2 ? PART_Nx2N : PART_NxN*/;
11761755 }
11771756 }
11821761 }
11831762
11841763
1185 static int decode_prev_intra_luma_pred_flag(thread_context* tctx)
1764 static inline int decode_prev_intra_luma_pred_flag(thread_context* tctx)
11861765 {
11871766 logtrace(LogSlice,"# prev_intra_luma_pred_flag\n");
11881767 int bit = decode_CABAC_bit(&tctx->cabac_decoder, &tctx->ctx_model[CONTEXT_MODEL_PREV_INTRA_LUMA_PRED_FLAG]);
1768 logtrace(LogSymbols,"$1 prev_intra_luma_pred_flag=%d\n",bit);
11891769 return bit;
11901770 }
11911771
11921772
1193 static int decode_mpm_idx(thread_context* tctx)
1773 static inline int decode_mpm_idx(thread_context* tctx)
11941774 {
11951775 logtrace(LogSlice,"# mpm_idx (TU:2)\n");
11961776 int mpm = decode_CABAC_TU_bypass(&tctx->cabac_decoder, 2);
11971777 logtrace(LogSlice,"> mpm_idx = %d\n",mpm);
1778 logtrace(LogSymbols,"$1 mpm_idx=%d\n",mpm);
11981779 return mpm;
11991780 }
12001781
12011782
1202 static int decode_rem_intra_luma_pred_mode(thread_context* tctx)
1783 static inline int decode_rem_intra_luma_pred_mode(thread_context* tctx)
12031784 {
12041785 logtrace(LogSlice,"# rem_intra_luma_pred_mode (5 bits)\n");
1205 return decode_CABAC_FL_bypass(&tctx->cabac_decoder, 5);
1786 int value = decode_CABAC_FL_bypass(&tctx->cabac_decoder, 5);
1787 logtrace(LogSymbols,"$1 rem_intra_luma_pred_mode=%d\n",value);
1788 return value;
12061789 }
12071790
12081791
12211804 }
12221805
12231806 logtrace(LogSlice,"> intra_chroma_pred_mode = %d\n",mode);
1807 logtrace(LogSymbols,"$1 intra_chroma_pred_mode=%d\n",mode);
12241808
12251809 return mode;
12261810 }
12371821 logtrace(LogSlice,"# context: %d\n",context);
12381822
12391823 int bit = decode_CABAC_bit(&tctx->cabac_decoder, &tctx->ctx_model[CONTEXT_MODEL_SPLIT_TRANSFORM_FLAG + context]);
1824 logtrace(LogSymbols,"$1 split_transform_flag=%d\n",bit);
12401825 return bit;
12411826 }
12421827
12481833
12491834 int bit = decode_CABAC_bit(&tctx->cabac_decoder, &tctx->ctx_model[CONTEXT_MODEL_CBF_CHROMA + trafoDepth]);
12501835
1836 logtrace(LogSymbols,"$1 cbf_chroma=%d\n",bit);
12511837 return bit;
12521838 }
12531839
12611847
12621848 logtrace(LogSlice,"> cbf_luma = %d\n",bit);
12631849
1850 logtrace(LogSymbols,"$1 cbf_luma=%d\n",bit);
12641851 return bit;
12651852 }
12661853
12831870 int bit = decode_CABAC_bit(&tctx->cabac_decoder,
12841871 &tctx->ctx_model[CONTEXT_MODEL_CODED_SUB_BLOCK_FLAG + ctxIdxInc]);
12851872
1873 logtrace(LogSymbols,"$1 coded_sub_block_flag=%d\n",bit);
12861874 return bit;
12871875 }
12881876
12941882 int bit = decode_CABAC_bit(&tctx->cabac_decoder,
12951883 &tctx->ctx_model[CONTEXT_MODEL_CU_QP_DELTA_ABS + 0]);
12961884 if (bit==0) {
1885 logtrace(LogSymbols,"$1 cu_qp_delta_abs=%d\n",0);
12971886 return 0;
12981887 }
12991888
13071896
13081897 if (prefix==5) {
13091898 int value = decode_CABAC_EGk_bypass(&tctx->cabac_decoder, 0);
1899 logtrace(LogSymbols,"$1 cu_qp_delta_abs=%d\n",value+5);
13101900 return value + 5;
13111901 }
13121902 else {
1903 logtrace(LogSymbols,"$1 cu_qp_delta_abs=%d\n",prefix);
13131904 return prefix;
13141905 }
13151906 }
13161907
1317
1908
13181909 static int decode_last_significant_coeff_prefix(thread_context* tctx,
13191910 int log2TrafoSize,
13201911 int cIdx,
14041995 for (int scanIdx=0;scanIdx<2;scanIdx++) {
14051996 ctxIdxLookup[2][cIdx][scanIdx][prevCsbf] = p;
14061997 }
1407
1998
14081999 p += 16*16;
14092000 }
14102001
17512342
17522343 int bit = decode_CABAC_bit(&tctx->cabac_decoder,
17532344 &tctx->ctx_model[CONTEXT_MODEL_SIGNIFICANT_COEFF_FLAG + ctxIdxInc]);
2345
2346 logtrace(LogSymbols,"$1 significant_coeff_flag=%d\n",bit);
2347
17542348 return bit;
17552349 }
17562350
18192413 *lastInvocation_coeff_abs_level_greater1_flag = bit;
18202414 *lastInvocation_ctxSet = ctxSet;
18212415
2416 //logtrace(LogSymbols,"$1 coeff_abs_level_greater1=%d\n",bit);
2417
18222418 return bit;
18232419 }
18242420
18362432 int bit = decode_CABAC_bit(&tctx->cabac_decoder,
18372433 &tctx->ctx_model[CONTEXT_MODEL_COEFF_ABS_LEVEL_GREATER2_FLAG + ctxIdxInc]);
18382434
2435 logtrace(LogSymbols,"$1 coeff_abs_level_greater2=%d\n",bit);
2436
18392437 return bit;
18402438 }
18412439
2440
2441 #define MAX_PREFIX 64
18422442
18432443 static int decode_coeff_abs_level_remaining(thread_context* tctx,
18442444 int cRiceParam)
18502450 do {
18512451 prefix++;
18522452 codeword = decode_CABAC_bypass(&tctx->cabac_decoder);
2453
2454 if (prefix>MAX_PREFIX) {
2455 return 0; // TODO: error
2456 }
18532457 }
18542458 while (codeword);
18552459
18712475 value = (((1<<(prefix-3))+3-1)<<cRiceParam)+codeword;
18722476 }
18732477
2478 logtrace(LogSymbols,"$1 coeff_abs_level_remaining=%d\n",value);
2479
18742480 return value;
18752481 }
18762482
18822488 int bit = decode_CABAC_bit(&tctx->cabac_decoder,
18832489 &tctx->ctx_model[CONTEXT_MODEL_MERGE_FLAG]);
18842490
2491 logtrace(LogSymbols,"$1 merge_flag=%d\n",bit);
2492
18852493 return bit;
18862494 }
18872495
18892497 static int decode_merge_idx(thread_context* tctx)
18902498 {
18912499 logtrace(LogSlice,"# merge_idx\n");
2500
2501 if (tctx->shdr->MaxNumMergeCand <= 1) {
2502 logtrace(LogSymbols,"$1 merge_idx=%d\n",0);
2503 return 0;
2504 }
18922505
18932506 // TU coding, first bin is CABAC, remaining are bypass.
18942507 // cMax = MaxNumMergeCand-1
19132526 }
19142527
19152528 logtrace(LogSlice,"> merge_idx = %d\n",idx);
2529 logtrace(LogSymbols,"$1 merge_idx=%d\n",idx);
19162530
19172531 return idx;
19182532 }
19252539 int bit = decode_CABAC_bit(&tctx->cabac_decoder,
19262540 &tctx->ctx_model[CONTEXT_MODEL_PRED_MODE_FLAG]);
19272541
2542 logtrace(LogSymbols,"$1 pred_mode=%d\n",bit);
19282543 return bit;
19292544 }
19302545
19352550 int bit = decode_CABAC_bit(&tctx->cabac_decoder,
19362551 &tctx->ctx_model[CONTEXT_MODEL_MVP_LX_FLAG]);
19372552
2553 logtrace(LogSymbols,"$1 mvp_lx_flag=%d\n",bit);
19382554 return bit;
19392555 }
19402556
19452561 int bit = decode_CABAC_bit(&tctx->cabac_decoder,
19462562 &tctx->ctx_model[CONTEXT_MODEL_RQT_ROOT_CBF]);
19472563
2564 logtrace(LogSymbols,"$1 rqt_root_cbf=%d\n",bit);
19482565 return bit;
19492566 }
19502567
19792596
19802597 logtrace(LogSlice,"> ref_idx = %d\n",idx);
19812598
2599 logtrace(LogSymbols,"$1 ref_idx_lX=%d\n",idx);
19822600 return idx;
19832601 }
19842602
20132631 logtrace(LogSlice,"> inter_pred_idc = %d (%s)\n",value,
20142632 value==0 ? "L0" : (value==1 ? "L1" : "BI"));
20152633
2016 return (enum InterPredIdc) value;
2017 }
2018
2019
2020
2021 void initialize_CABAC(thread_context* tctx)
2022 {
2023 const int initType = tctx->shdr->initType;
2024 assert(initType >= 0 && initType <= 2);
2025
2026 init_context(tctx, CONTEXT_MODEL_SPLIT_CU_FLAG, initValue_split_cu_flag[initType], 3);
2027 if (initType > 0) {
2028 init_context(tctx, CONTEXT_MODEL_CU_SKIP_FLAG, initValue_cu_skip_flag[initType-1], 3);
2029 init_context(tctx, CONTEXT_MODEL_PRED_MODE_FLAG, &initValue_pred_mode_flag[initType-1], 1);
2030 init_context(tctx, CONTEXT_MODEL_MERGE_FLAG, &initValue_merge_flag[initType-1],1);
2031 init_context(tctx, CONTEXT_MODEL_MERGE_IDX, &initValue_merge_idx[initType-1], 1);
2032 init_context(tctx, CONTEXT_MODEL_INTER_PRED_IDC, initValue_inter_pred_idc, 5);
2033 init_context(tctx, CONTEXT_MODEL_REF_IDX_LX, initValue_ref_idx_lX, 2);
2034 init_context(tctx, CONTEXT_MODEL_ABS_MVD_GREATER01_FLAG, &initValue_abs_mvd_greater01_flag[initType == 1 ? 0 : 2], 2);
2035 init_context(tctx, CONTEXT_MODEL_MVP_LX_FLAG, initValue_mvp_lx_flag, 1);
2036 init_context(tctx, CONTEXT_MODEL_RQT_ROOT_CBF, initValue_rqt_root_cbf, 1);
2037 }
2038
2039 init_context(tctx, CONTEXT_MODEL_PART_MODE, &initValue_part_mode[(initType!=2 ? initType : 5)], 4);
2040 init_context(tctx, CONTEXT_MODEL_PREV_INTRA_LUMA_PRED_FLAG, &initValue_prev_intra_luma_pred_flag[initType], 1);
2041 init_context(tctx, CONTEXT_MODEL_INTRA_CHROMA_PRED_MODE, &initValue_intra_chroma_pred_mode[initType], 1);
2042 init_context(tctx, CONTEXT_MODEL_CBF_LUMA, &initValue_cbf_luma[initType == 0 ? 0 : 2], 2);
2043 init_context(tctx, CONTEXT_MODEL_CBF_CHROMA, &initValue_cbf_chroma[initType * 4], 4);
2044 init_context(tctx, CONTEXT_MODEL_SPLIT_TRANSFORM_FLAG, &initValue_split_transform_flag[initType * 3], 3);
2045 init_context(tctx, CONTEXT_MODEL_LAST_SIGNIFICANT_COEFFICIENT_X_PREFIX, &initValue_last_significant_coefficient_prefix[initType * 18], 18);
2046 init_context(tctx, CONTEXT_MODEL_LAST_SIGNIFICANT_COEFFICIENT_Y_PREFIX, &initValue_last_significant_coefficient_prefix[initType * 18], 18);
2047 init_context(tctx, CONTEXT_MODEL_CODED_SUB_BLOCK_FLAG, &initValue_coded_sub_block_flag[initType * 4], 4);
2048 init_context(tctx, CONTEXT_MODEL_SIGNIFICANT_COEFF_FLAG, initValue_significant_coeff_flag[initType], 42);
2049 init_context(tctx, CONTEXT_MODEL_COEFF_ABS_LEVEL_GREATER1_FLAG, &initValue_coeff_abs_level_greater1_flag[initType * 24], 24);
2050 init_context(tctx, CONTEXT_MODEL_COEFF_ABS_LEVEL_GREATER2_FLAG, &initValue_coeff_abs_level_greater2_flag[initType * 6], 6);
2051 init_context(tctx, CONTEXT_MODEL_SAO_MERGE_FLAG, &initValue_sao_merge_leftUp_flag[initType], 1);
2052 init_context(tctx, CONTEXT_MODEL_SAO_TYPE_IDX, &initValue_sao_type_idx_lumaChroma_flag[initType], 1);
2053 init_context(tctx, CONTEXT_MODEL_CU_QP_DELTA_ABS, initValue_cu_qp_delta_abs, 2);
2054 init_context(tctx, CONTEXT_MODEL_TRANSFORM_SKIP_FLAG, initValue_transform_skip_flag, 2);
2055 init_context(tctx, CONTEXT_MODEL_CU_TRANSQUANT_BYPASS_FLAG, &initValue_cu_transquant_bypass_flag[initType], 1);
2056 }
2634 logtrace(LogSymbols,"$1 decode_inter_pred_idx=%d\n",value+1);
2635
2636 return (enum InterPredIdc) (value+1);
2637 }
2638
2639
2640 static int decode_explicit_rdpcm_flag(thread_context* tctx,int cIdx)
2641 {
2642 context_model* model = &tctx->ctx_model[CONTEXT_MODEL_RDPCM_FLAG];
2643 int value = decode_CABAC_bit(&tctx->cabac_decoder, &model[cIdx ? 1 : 0]);
2644 return value;
2645 }
2646
2647
2648 static int decode_explicit_rdpcm_dir(thread_context* tctx,int cIdx)
2649 {
2650 context_model* model = &tctx->ctx_model[CONTEXT_MODEL_RDPCM_DIR];
2651 int value = decode_CABAC_bit(&tctx->cabac_decoder, &model[cIdx ? 1 : 0]);
2652 return value;
2653 }
2654
20572655
20582656
20592657 /* Take CtbAddrInTS and compute
21342732 }
21352733
21362734 if (!sao_merge_up_flag && !sao_merge_left_flag) {
2137 for (int cIdx=0; cIdx<3; cIdx++) {
2735 int nChroma = 3;
2736 if (sps->ChromaArrayType == CHROMA_MONO) nChroma=1;
2737
2738 for (int cIdx=0; cIdx<nChroma; cIdx++) {
21382739 if ((shdr->slice_sao_luma_flag && cIdx==0) ||
21392740 (shdr->slice_sao_chroma_flag && cIdx>0)) {
21402741
21602761
21612762 if (SaoTypeIdx != 0) {
21622763 for (int i=0;i<4;i++) {
2163 saoinfo.saoOffsetVal[cIdx][i] = decode_sao_offset_abs(tctx);
2764 saoinfo.saoOffsetVal[cIdx][i] = decode_sao_offset_abs(tctx, img->get_bit_depth(cIdx));
21642765 logtrace(LogSlice,"saoOffsetVal[%d][%d] = %d\n",cIdx,i, saoinfo.saoOffsetVal[cIdx][i]);
21652766 }
21662767
21952796 logtrace(LogSlice,"SaoEoClass[%d] = %d\n",cIdx,SaoEoClass);
21962797 }
21972798
2198 int bitDepth = (cIdx==0 ?
2199 sps->BitDepth_Y :
2200 sps->BitDepth_C);
2201 int shift = bitDepth-libde265_min(bitDepth,10);
2799 int log2OffsetScale;
2800
2801 if (cIdx==0) {
2802 log2OffsetScale = pps->range_extension.log2_sao_offset_scale_luma;
2803 }
2804 else {
2805 log2OffsetScale = pps->range_extension.log2_sao_offset_scale_chroma;
2806 }
22022807
22032808 for (int i=0;i<4;i++) {
2204 saoinfo.saoOffsetVal[cIdx][i] = sign[i]*(saoinfo.saoOffsetVal[cIdx][i] << shift);
2809 saoinfo.saoOffsetVal[cIdx][i] = sign[i]*(saoinfo.saoOffsetVal[cIdx][i] << log2OffsetScale);
22052810 }
22062811 }
22072812 }
22512856 }
22522857
22532858
2254 LIBDE265_INLINE static int luma_pos_to_ctbAddrRS(seq_parameter_set* sps, int x,int y)
2859 LIBDE265_INLINE static int luma_pos_to_ctbAddrRS(const seq_parameter_set* sps, int x,int y)
22552860 {
22562861 int ctbX = x >> sps->Log2CtbSizeY;
22572862 int ctbY = y >> sps->Log2CtbSizeY;
22602865 }
22612866
22622867
2263 int check_CTB_available(de265_image* img,
2264 slice_segment_header* shdr,
2868 int check_CTB_available(const de265_image* img,
22652869 int xC,int yC, int xN,int yN)
22662870 {
22672871 // check whether neighbor is outside of frame
22942898
22952899 int residual_coding(thread_context* tctx,
22962900 int x0, int y0, // position of TU in frame
2297 int xL, int yL, // position of TU in local CU
22982901 int log2TrafoSize,
22992902 int cIdx)
23002903 {
23062909 const seq_parameter_set* sps = &img->sps;
23072910 const pic_parameter_set* pps = &img->pps;
23082911
2912 enum PredMode PredMode = img->get_pred_mode(x0,y0);
23092913
23102914 if (cIdx==0) {
23112915 img->set_nonzero_coefficient(x0,y0,log2TrafoSize);
23142918
23152919 if (pps->transform_skip_enabled_flag &&
23162920 !tctx->cu_transquant_bypass_flag &&
2317 (log2TrafoSize==2))
2921 (log2TrafoSize <= pps->Log2MaxTransformSkipSize))
23182922 {
23192923 tctx->transform_skip_flag[cIdx] = decode_transform_skip_flag(tctx,cIdx);
23202924 }
23222926 {
23232927 tctx->transform_skip_flag[cIdx] = 0;
23242928 }
2929
2930
2931 tctx->explicit_rdpcm_flag = false;
2932
2933 if (PredMode == MODE_INTER && sps->range_extension.explicit_rdpcm_enabled_flag &&
2934 ( tctx->transform_skip_flag[cIdx] || tctx->cu_transquant_bypass_flag))
2935 {
2936 tctx->explicit_rdpcm_flag = decode_explicit_rdpcm_flag(tctx,cIdx);
2937 if (tctx->explicit_rdpcm_flag) {
2938 tctx->explicit_rdpcm_dir = decode_explicit_rdpcm_dir(tctx,cIdx);
2939 }
2940
2941 //printf("EXPLICIT RDPCM %d;%d\n",x0,y0);
2942 }
2943 else
2944 {
2945 tctx->explicit_rdpcm_flag = false;
2946 }
2947
2948
2949
2950 // sbType for persistent_rice_adaptation_enabled_flag
2951
2952 int sbType = (cIdx==0) ? 2 : 0;
2953 if (tctx->transform_skip_flag[cIdx] || tctx->cu_transquant_bypass_flag) {
2954 sbType++;
2955 }
23252956
23262957
23272958 // --- decode position of last coded coefficient ---
23672998
23682999 int scanIdx;
23693000
2370 enum PredMode PredMode = img->get_pred_mode(x0,y0);
2371
2372
23733001 if (PredMode == MODE_INTRA) {
23743002 if (cIdx==0) {
2375 if (log2TrafoSize==2 || log2TrafoSize==3) {
2376 enum IntraPredMode predMode = img->get_IntraPredMode(x0,y0);
2377 logtrace(LogSlice,"IntraPredMode[%d,%d] = %d\n",x0,y0,predMode);
2378
2379 if (predMode >= 6 && predMode <= 14) scanIdx=2;
2380 else if (predMode >= 22 && predMode <= 30) scanIdx=1;
2381 else scanIdx=0;
2382 }
2383 else { scanIdx=0; }
3003 scanIdx = get_intra_scan_idx(log2TrafoSize, img->get_IntraPredMode(x0,y0), cIdx, sps);
23843004 }
23853005 else {
2386 if (log2TrafoSize==1 || log2TrafoSize==2) {
2387 enum IntraPredMode predMode = tctx->IntraPredModeC;
2388
2389 if (predMode >= 6 && predMode <= 14) scanIdx=2;
2390 else if (predMode >= 22 && predMode <= 30) scanIdx=1;
2391 else scanIdx=0;
2392 }
2393 else { scanIdx=0; }
2394 }
2395
2396 logtrace(LogSlice,"pred: %d -> scan: %d\n",PredMode,scanIdx);
3006 scanIdx = get_intra_scan_idx(log2TrafoSize, img->get_IntraPredModeC(x0,y0), cIdx, sps);
3007 }
23973008 }
23983009 else {
23993010 scanIdx=0;
24003011 }
24013012
2402
2403 // HM 9 only ?
24043013 if (scanIdx==2) {
2405 int t = LastSignificantCoeffX;
2406 LastSignificantCoeffX = LastSignificantCoeffY;
2407 LastSignificantCoeffY = t;
3014 std::swap(LastSignificantCoeffX, LastSignificantCoeffY);
24083015 }
24093016
24103017 logtrace(LogSlice,"LastSignificantCoeff: x=%d;y=%d\n",LastSignificantCoeffX,LastSignificantCoeffY);
25323139
25333140 // for all AC coefficients in sub-block, a significant_coeff flag is coded
25343141
2535 int significant_coeff = decode_significant_coeff_flag_lookup(tctx,
2536 ctxIdxMap[xC+(yC<<log2TrafoSize)]);
2537 //ctxIdxMap[(i<<4)+n]);
3142 int ctxInc;
3143 if (sps->range_extension.transform_skip_context_enabled_flag &&
3144 (tctx->cu_transquant_bypass_flag || tctx->transform_skip_flag[cIdx])) {
3145 ctxInc = ( cIdx == 0 ) ? 42 : (16+27);
3146 }
3147 else {
3148 ctxInc = ctxIdxMap[xC+(yC<<log2TrafoSize)];
3149 }
3150
3151 int significant_coeff = decode_significant_coeff_flag_lookup(tctx, ctxInc);
25383152
25393153 if (significant_coeff) {
25403154 coeff_value[nCoefficients] = 1;
25553169 {
25563170 if (inferSbDcSigCoeffFlag==0) {
25573171 // if we cannot infert the DC coefficient, it is coded
2558 int significant_coeff = decode_significant_coeff_flag_lookup(tctx,
2559 ctxIdxMap[x0+(y0<<log2TrafoSize)]);
2560 //ctxIdxMap[(i<<4)+0]);
3172
3173 int ctxInc;
3174 if (sps->range_extension.transform_skip_context_enabled_flag &&
3175 (tctx->cu_transquant_bypass_flag || tctx->transform_skip_flag[cIdx])) {
3176 ctxInc = ( cIdx == 0 ) ? 42 : (16+27);
3177 }
3178 else {
3179 ctxInc = ctxIdxMap[x0+(y0<<log2TrafoSize)];
3180 }
3181
3182 int significant_coeff = decode_significant_coeff_flag_lookup(tctx, ctxInc);
25613183
25623184
25633185 if (significant_coeff) {
25803202
25813203
25823204 /*
2583 logtrace(LogSlice,"significant_coeff_flags:\n");
2584 for (int y=0;y<4;y++) {
3205 logtrace(LogSlice,"significant_coeff_flags:\n");
3206 for (int y=0;y<4;y++) {
25853207 logtrace(LogSlice," ");
25863208 for (int x=0;x<4;x++) {
2587 logtrace(LogSlice,"*%d ",significant_coeff_flag[y][x]);
3209 logtrace(LogSlice,"*%d ",significant_coeff_flag[y][x]);
25883210 }
25893211 logtrace(LogSlice,"*\n");
2590 }
3212 }
25913213 */
25923214
25933215
26483270
26493271 // --- decode coefficient signs ---
26503272
2651 int signHidden = (coeff_scan_pos[0]-coeff_scan_pos[nCoefficients-1] > 3 &&
2652 !tctx->cu_transquant_bypass_flag);
3273 int signHidden;
3274
3275
3276 IntraPredMode predModeIntra;
3277 if (cIdx==0) predModeIntra = img->get_IntraPredMode(x0,y0);
3278 else predModeIntra = img->get_IntraPredModeC(x0,y0);
3279
3280
3281 if (tctx->cu_transquant_bypass_flag ||
3282 (PredMode == MODE_INTRA &&
3283 sps->range_extension.implicit_rdpcm_enabled_flag &&
3284 tctx->transform_skip_flag[cIdx] &&
3285 ( predModeIntra == 10 || predModeIntra == 26 )) ||
3286 tctx->explicit_rdpcm_flag)
3287 {
3288 signHidden = 0;
3289 }
3290 else
3291 {
3292 signHidden = (coeff_scan_pos[0]-coeff_scan_pos[nCoefficients-1] > 3);
3293 }
3294
26533295
26543296 for (int n=0;n<nCoefficients-1;n++) {
26553297 coeff_sign[n] = decode_CABAC_bypass(&tctx->cabac_decoder);
26693311 // --- decode coefficient value ---
26703312
26713313 int sumAbsLevel=0;
2672 int uiGoRiceParam=0;
3314 int uiGoRiceParam;
3315
3316 if (sps->range_extension.persistent_rice_adaptation_enabled_flag==0) {
3317 uiGoRiceParam = 0;
3318 }
3319 else {
3320 uiGoRiceParam = tctx->StatCoeff[sbType]/4;
3321 }
3322
3323 // printf("initial uiGoRiceParam=%d\n",uiGoRiceParam);
3324 bool firstCoeffWithAbsLevelRemaining = true;
26733325
26743326 for (int n=0;n<nCoefficients;n++) {
26753327 int baseLevel = coeff_value[n];
26763328
26773329 int coeff_abs_level_remaining;
3330
3331 // printf("coeff %d/%d, uiRiceParam: %d\n",n,nCoefficients,uiGoRiceParam);
26783332
26793333 if (coeff_has_max_base_level[n]) {
26803334 coeff_abs_level_remaining =
26813335 decode_coeff_abs_level_remaining(tctx, uiGoRiceParam);
26823336
2683 // (9-462)
2684 if (baseLevel + coeff_abs_level_remaining > 3*(1<<uiGoRiceParam)) {
2685 uiGoRiceParam++;
2686 if (uiGoRiceParam>4) uiGoRiceParam=4;
3337 if (sps->range_extension.persistent_rice_adaptation_enabled_flag == 0) {
3338 // (2014.10 / 9-20)
3339 if (baseLevel + coeff_abs_level_remaining > 3*(1<<uiGoRiceParam)) {
3340 uiGoRiceParam++;
3341 if (uiGoRiceParam>4) uiGoRiceParam=4;
3342 }
26873343 }
3344 else {
3345 if (baseLevel + coeff_abs_level_remaining > 3*(1<<uiGoRiceParam))
3346 uiGoRiceParam++;
3347 }
3348
3349 // persistent_rice_adaptation_enabled_flag
3350 if (sps->range_extension.persistent_rice_adaptation_enabled_flag &&
3351 firstCoeffWithAbsLevelRemaining) {
3352 if (coeff_abs_level_remaining >= (3 << (tctx->StatCoeff[sbType]/4 ))) {
3353 tctx->StatCoeff[sbType]++;
3354 }
3355 else if (2*coeff_abs_level_remaining < (1 << (tctx->StatCoeff[sbType]/4 )) &&
3356 tctx->StatCoeff[sbType] > 0) {
3357 tctx->StatCoeff[sbType]--;
3358 }
3359 }
3360
3361 firstCoeffWithAbsLevelRemaining=false;
26883362 }
26893363 else {
26903364 coeff_abs_level_remaining = 0;
26913365 }
3366
3367 logtrace(LogSlice, "coeff_abs_level_remaining=%d\n",coeff_abs_level_remaining);
26923368
26933369
26943370 int16_t currCoeff = baseLevel + coeff_abs_level_remaining;
27033379 currCoeff = -currCoeff;
27043380 }
27053381 }
3382
3383 logtrace(LogSlice, "quantized coefficient=%d\n",currCoeff);
27063384
27073385 #ifdef DE265_LOG_TRACE
27083386 //TransCoeffLevel[yC*CoeffStride + xC] = currCoeff;
27163394 tctx->coeffList[cIdx][ tctx->nCoeff[cIdx] ] = currCoeff;
27173395 tctx->coeffPos [cIdx][ tctx->nCoeff[cIdx] ] = xC + yC*CoeffStride;
27183396 tctx->nCoeff[cIdx]++;
3397
3398 //printf("%d ",currCoeff);
27193399 } // iterate through coefficients in sub-block
3400
3401 //printf(" (%d;%d)\n",x0,y0);
3402
27203403 } // if nonZero
27213404 } // next sub-block
27223405
27233406 return DE265_OK;
3407 }
3408
3409
3410 static void decode_TU(thread_context* tctx,
3411 int x0,int y0,
3412 int xCUBase,int yCUBase,
3413 int nT, int cIdx, enum PredMode cuPredMode, bool cbf)
3414 {
3415 de265_image* img = tctx->img;
3416
3417 int residualDpcm = 0;
3418
3419 if (cuPredMode == MODE_INTRA) // if intra mode
3420 {
3421 enum IntraPredMode intraPredMode;
3422
3423 if (cIdx==0) {
3424 intraPredMode = img->get_IntraPredMode(x0,y0);
3425 }
3426 else {
3427 const int SubWidthC = tctx->img->sps.SubWidthC;
3428 const int SubHeightC = tctx->img->sps.SubHeightC;
3429
3430 intraPredMode = img->get_IntraPredModeC(x0*SubWidthC,y0*SubHeightC);
3431 }
3432
3433 if (intraPredMode<0 || intraPredMode>=35) {
3434 // TODO: ERROR
3435 intraPredMode = INTRA_DC;
3436 }
3437
3438 decode_intra_prediction(img, x0,y0, intraPredMode, nT, cIdx);
3439
3440
3441 residualDpcm = tctx->img->sps.range_extension.implicit_rdpcm_enabled_flag &&
3442 (tctx->cu_transquant_bypass_flag || tctx->transform_skip_flag[cIdx]) &&
3443 (intraPredMode == 10 || intraPredMode == 26);
3444
3445 if (residualDpcm && intraPredMode == 26)
3446 residualDpcm = 2;
3447 }
3448 else // INTER
3449 {
3450 if (tctx->explicit_rdpcm_flag) {
3451 residualDpcm = (tctx->explicit_rdpcm_dir ? 2 : 1);
3452 }
3453 }
3454
3455 if (cbf) {
3456 scale_coefficients(tctx, x0,y0, xCUBase,yCUBase, nT, cIdx,
3457 tctx->transform_skip_flag[cIdx], cuPredMode==MODE_INTRA, residualDpcm);
3458 }
3459 /*
3460 else if (!cbf && cIdx==0) {
3461 memset(tctx->residual_luma,0,32*32*sizeof(int32_t));
3462 }
3463 */
3464 else if (!cbf && cIdx!=0 && tctx->ResScaleVal) {
3465 // --- cross-component-prediction when CBF==0 ---
3466
3467 tctx->nCoeff[cIdx] = 0;
3468 residualDpcm=0;
3469
3470 scale_coefficients(tctx, x0,y0, xCUBase,yCUBase, nT, cIdx,
3471 tctx->transform_skip_flag[cIdx], cuPredMode==MODE_INTRA, residualDpcm);
3472 }
3473 }
3474
3475
3476 static int decode_log2_res_scale_abs_plus1(thread_context* tctx, int cIdxMinus1)
3477 {
3478 //const int context = (cIdx==0) ? 0 : 1;
3479
3480 logtrace(LogSlice,"# log2_res_scale_abs_plus1 (c=%d)\n",cIdxMinus1);
3481
3482 int value = 0;
3483 int cMax = 4;
3484 for (int binIdx=0;binIdx<cMax;binIdx++)
3485 {
3486 int ctxIdxInc = 4*cIdxMinus1 + binIdx;
3487
3488 int bit = decode_CABAC_bit(&tctx->cabac_decoder,
3489 &tctx->ctx_model[CONTEXT_MODEL_LOG2_RES_SCALE_ABS_PLUS1+ctxIdxInc]);
3490 if (!bit) break;
3491 value++;
3492 }
3493
3494 logtrace(LogSymbols,"$1 log2_res_scale_abs_plus1=%d\n",value);
3495
3496 return value;
3497 }
3498
3499
3500 static int decode_res_scale_sign_flag(thread_context* tctx, int cIdxMinus1)
3501 {
3502 //const int context = (cIdx==0) ? 0 : 1;
3503
3504 logtrace(LogSlice,"# res_scale_sign_flag (c=%d)\n",cIdxMinus1);
3505
3506 int bit = decode_CABAC_bit(&tctx->cabac_decoder,
3507 &tctx->ctx_model[CONTEXT_MODEL_RES_SCALE_SIGN_FLAG+cIdxMinus1]);
3508
3509 logtrace(LogSymbols,"$1 res_scale_sign_flag=%d\n",bit);
3510
3511 return bit;
3512 }
3513
3514
3515 static void read_cross_comp_pred(thread_context* tctx, int cIdxMinus1)
3516 {
3517 int log2_res_scale_abs_plus1 = decode_log2_res_scale_abs_plus1(tctx,cIdxMinus1);
3518 int ResScaleVal;
3519
3520 if (log2_res_scale_abs_plus1 != 0) {
3521 int res_scale_sign_flag = decode_res_scale_sign_flag(tctx,cIdxMinus1);
3522
3523 ResScaleVal = 1 << (log2_res_scale_abs_plus1 - 1);
3524 ResScaleVal *= 1 - 2 * res_scale_sign_flag;
3525 }
3526 else {
3527 ResScaleVal = 0;
3528 }
3529
3530 tctx->ResScaleVal = ResScaleVal;
27243531 }
27253532
27263533
27403547 assert(cbf_cr != -1);
27413548 assert(cbf_luma != -1);
27423549
3550 const int ChromaArrayType = tctx->img->sps.ChromaArrayType;
3551
3552 int log2TrafoSizeC = (ChromaArrayType==CHROMA_444 ? log2TrafoSize : log2TrafoSize-1);
3553 log2TrafoSizeC = libde265_max(2, log2TrafoSizeC);
3554
3555 const int cbfLuma = cbf_luma;
3556 const int cbfChroma = cbf_cb | cbf_cr;
3557
27433558 tctx->transform_skip_flag[0]=0;
27443559 tctx->transform_skip_flag[1]=0;
27453560 tctx->transform_skip_flag[2]=0;
27463561
2747
2748 if (cbf_luma || cbf_cb || cbf_cr)
3562 tctx->explicit_rdpcm_flag = false;
3563
3564
3565 enum PredMode cuPredMode = tctx->img->get_pred_mode(x0,y0);
3566
3567 if (cbfLuma || cbfChroma)
27493568 {
3569 bool doDecodeQuantParameters = false;
3570
27503571 if (tctx->img->pps.cu_qp_delta_enabled_flag &&
27513572 !tctx->IsCuQpDeltaCoded) {
27523573
27653586 logtrace(LogSlice,"cu_qp_delta_sign = %d\n",cu_qp_delta_sign);
27663587 logtrace(LogSlice,"CuQpDelta = %d\n",tctx->CuQpDelta);
27673588
3589 doDecodeQuantParameters = true;
3590 //decode_quantization_parameters(tctx, x0,y0, xCUBase, yCUBase);
3591 }
3592
3593 if (tctx->shdr->cu_chroma_qp_offset_enabled_flag && cbfChroma &&
3594 !tctx->cu_transquant_bypass_flag && !tctx->IsCuChromaQpOffsetCoded ) {
3595 logtrace(LogSlice,"# cu_chroma_qp_offset_flag\n");
3596
3597 int cu_chroma_qp_offset_flag = decode_CABAC_bit(&tctx->cabac_decoder,
3598 &tctx->ctx_model[CONTEXT_MODEL_CU_CHROMA_QP_OFFSET_FLAG]);
3599
3600
3601 const pic_parameter_set* pps = &tctx->img->pps;
3602
3603 int cu_chroma_qp_offset_idx = 0;
3604 if (cu_chroma_qp_offset_flag && pps->range_extension.chroma_qp_offset_list_len > 1) {
3605 cu_chroma_qp_offset_idx = decode_CABAC_bit(&tctx->cabac_decoder,
3606 &tctx->ctx_model[CONTEXT_MODEL_CU_CHROMA_QP_OFFSET_IDX]);
3607 }
3608
3609 tctx->IsCuChromaQpOffsetCoded = 1;
3610
3611 if (cu_chroma_qp_offset_flag) {
3612 tctx->CuQpOffsetCb = pps->range_extension.cb_qp_offset_list[ cu_chroma_qp_offset_idx ];
3613 tctx->CuQpOffsetCr = pps->range_extension.cr_qp_offset_list[ cu_chroma_qp_offset_idx ];
3614 }
3615 else {
3616 tctx->CuQpOffsetCb = 0;
3617 tctx->CuQpOffsetCr = 0;
3618 }
3619
3620 doDecodeQuantParameters = true;
3621 //decode_quantization_parameters(tctx, x0,y0, xCUBase, yCUBase);
3622 }
3623
3624
3625 if (doDecodeQuantParameters) {
27683626 decode_quantization_parameters(tctx, x0,y0, xCUBase, yCUBase);
27693627 }
27703628 }
27713629
2772
2773 if (cbf_luma || cbf_cb || cbf_cr)
3630 // position of TU in local CU
3631 int xL = x0 - xCUBase;
3632 int yL = y0 - yCUBase;
3633 int nT = 1<<log2TrafoSize;
3634 int nTC = 1<<log2TrafoSizeC;
3635
3636 const int SubWidthC = tctx->img->sps.SubWidthC;
3637 const int SubHeightC = tctx->img->sps.SubHeightC;
3638
3639 // --- luma ---
3640
3641 tctx->ResScaleVal = 0;
3642
3643 int err;
3644 if (cbf_luma) {
3645 if ((err=residual_coding(tctx,x0,y0, log2TrafoSize,0)) != DE265_OK) return err;
3646 }
3647
3648 decode_TU(tctx, x0,y0, xCUBase,yCUBase, nT, 0, cuPredMode, cbf_luma);
3649
3650
3651 // --- chroma ---
3652
3653 const int yOffset422 = 1<<log2TrafoSizeC;
3654
3655 if (log2TrafoSize>2 || ChromaArrayType == CHROMA_444) {
3656 // TODO: cross-component prediction
3657
3658 const bool do_cross_component_prediction =
3659 (tctx->img->pps.range_extension.cross_component_prediction_enabled_flag &&
3660 cbf_luma &&
3661 (cuPredMode == MODE_INTER || tctx->img->is_IntraPredModeC_Mode4(x0,y0)));
3662
3663 if (do_cross_component_prediction) {
3664 read_cross_comp_pred(tctx, 0);
3665 }
3666 else {
3667 tctx->ResScaleVal = 0;
3668 }
3669
27743670 {
2775 // position of TU in local CU
2776 int xL = x0 - xCUBase;
2777 int yL = y0 - yCUBase;
2778
2779 int err;
2780 if (cbf_luma) {
2781 if ((err=residual_coding(tctx,x0,y0, xL,yL,log2TrafoSize,0)) != DE265_OK) return err;
2782 }
2783
2784 if (log2TrafoSize>2) {
2785 if (cbf_cb) {
2786 if ((err=residual_coding(tctx,x0,y0,xL,yL,log2TrafoSize-1,1)) != DE265_OK) return err;
2787 }
2788
2789 if (cbf_cr) {
2790 if ((err=residual_coding(tctx,x0,y0,xL,yL,log2TrafoSize-1,2)) != DE265_OK) return err;
2791 }
2792 }
2793 else if (blkIdx==3) {
2794 if (cbf_cb) {
2795 if ((err=residual_coding(tctx,xBase,yBase,xBase-xCUBase,yBase-yCUBase,
2796 log2TrafoSize,1)) != DE265_OK) return err;
2797 }
2798
2799 if (cbf_cr) {
2800 if ((err=residual_coding(tctx,xBase,yBase,xBase-xCUBase,yBase-yCUBase,
2801 log2TrafoSize,2)) != DE265_OK) return err;
2802 }
2803 }
2804 }
3671 if (cbf_cb & 1) {
3672 if ((err=residual_coding(tctx,x0,y0,log2TrafoSizeC,1)) != DE265_OK) return err;
3673 }
3674
3675 if (tctx->img->sps.ChromaArrayType != CHROMA_MONO) {
3676 decode_TU(tctx,
3677 x0/SubWidthC,y0/SubHeightC,
3678 xCUBase/SubWidthC,yCUBase/SubHeightC, nTC, 1, cuPredMode, cbf_cb & 1);
3679 }
3680 }
3681
3682 // 4:2:2
3683 if (ChromaArrayType == CHROMA_422) {
3684 const int yOffset = 1<<log2TrafoSizeC;
3685
3686 if (cbf_cb & 2) {
3687 if ((err=residual_coding(tctx,
3688 x0,y0+yOffset*SubHeightC,
3689 log2TrafoSizeC,1)) != DE265_OK) return err;
3690 }
3691
3692 decode_TU(tctx,
3693 x0/SubWidthC,y0/SubHeightC + yOffset,
3694 xCUBase/SubWidthC,yCUBase/SubHeightC +yOffset,
3695 nTC, 1, cuPredMode, cbf_cb & 2);
3696 }
3697
3698
3699 if (do_cross_component_prediction) {
3700 read_cross_comp_pred(tctx, 1);
3701 }
3702 else {
3703 tctx->ResScaleVal = 0;
3704 }
3705
3706 {
3707 if (cbf_cr & 1) {
3708 if ((err=residual_coding(tctx,x0,y0,log2TrafoSizeC,2)) != DE265_OK) return err;
3709 }
3710
3711 if (tctx->img->sps.ChromaArrayType != CHROMA_MONO) {
3712 decode_TU(tctx,
3713 x0/SubWidthC,y0/SubHeightC,
3714 xCUBase/SubWidthC,yCUBase/SubHeightC,
3715 nTC, 2, cuPredMode, cbf_cr & 1);
3716 }
3717 }
3718
3719 // 4:2:2
3720 if (ChromaArrayType == CHROMA_422) {
3721 const int yOffset = 1<<log2TrafoSizeC;
3722
3723 if (cbf_cr & 2) {
3724 if ((err=residual_coding(tctx,
3725 x0,y0+yOffset*SubHeightC,
3726 log2TrafoSizeC,2)) != DE265_OK) return err;
3727 }
3728
3729 decode_TU(tctx,
3730 x0/SubWidthC,y0/SubHeightC+yOffset,
3731 xCUBase/SubWidthC,yCUBase/SubHeightC+yOffset,
3732 nTC, 2, cuPredMode, cbf_cr & 2);
3733 }
3734 }
3735 else if (blkIdx==3) {
3736 if (cbf_cb & 1) {
3737 if ((err=residual_coding(tctx,xBase,yBase,
3738 log2TrafoSize,1)) != DE265_OK) return err;
3739 }
3740
3741 if (tctx->img->sps.ChromaArrayType != CHROMA_MONO) {
3742 decode_TU(tctx,
3743 xBase/SubWidthC, yBase/SubHeightC,
3744 xCUBase/SubWidthC,yCUBase/SubHeightC, nT, 1, cuPredMode, cbf_cb & 1);
3745 }
3746
3747 // 4:2:2
3748 if (cbf_cb & 2) {
3749 if ((err=residual_coding(tctx,
3750 xBase ,yBase +(1<<log2TrafoSize),
3751 log2TrafoSize,1)) != DE265_OK) return err;
3752 }
3753
3754 if (ChromaArrayType == CHROMA_422) {
3755 decode_TU(tctx,
3756 xBase/SubWidthC, yBase/SubHeightC + (1<<log2TrafoSize),
3757 xCUBase/SubWidthC,yCUBase/SubHeightC, nT, 1, cuPredMode, cbf_cb & 2);
3758 }
3759
3760 if (cbf_cr & 1) {
3761 if ((err=residual_coding(tctx,xBase,yBase,
3762 log2TrafoSize,2)) != DE265_OK) return err;
3763 }
3764
3765 if (tctx->img->sps.ChromaArrayType != CHROMA_MONO) {
3766 decode_TU(tctx,
3767 xBase/SubWidthC, yBase/SubHeightC,
3768 xCUBase/SubWidthC,yCUBase/SubHeightC, nT, 2, cuPredMode, cbf_cr & 1);
3769 }
3770
3771 // 4:2:2
3772 if (cbf_cr & 2) {
3773 if ((err=residual_coding(tctx,
3774 xBase ,yBase +(1<<log2TrafoSizeC),
3775 log2TrafoSize,2)) != DE265_OK) return err;
3776 }
3777
3778 if (ChromaArrayType == CHROMA_422) {
3779 decode_TU(tctx,
3780 xBase/SubWidthC, yBase/SubHeightC + (1<<log2TrafoSize),
3781 xCUBase/SubWidthC,yCUBase/SubHeightC, nT, 2, cuPredMode, cbf_cr & 2);
3782 }
3783 }
3784
28053785
28063786 return DE265_OK;
3787 }
3788
3789
3790 static void dump_cbsize(de265_image* img)
3791 {
3792 int w = img->get_width(0);
3793 int h = img->get_height(0);
3794
3795 for (int y=0;y<h;y+=8) {
3796 for (int x=0;x<w;x+=8) {
3797 printf("%d",img->get_log2CbSize(x,y));
3798 }
3799 printf("\n");
3800 }
28073801 }
28083802
28093803
28173811 int MaxTrafoDepth,
28183812 int IntraSplitFlag,
28193813 enum PredMode cuPredMode,
2820 bool parent_cbf_cb,bool parent_cbf_cr)
3814 uint8_t parent_cbf_cb,uint8_t parent_cbf_cr)
28213815 {
28223816 logtrace(LogSlice,"- read_transform_tree (interleaved) x0:%d y0:%d xBase:%d yBase:%d "
2823 "log2TrafoSize:%d trafoDepth:%d MaxTrafoDepth:%d\n",
2824 x0,y0,xBase,yBase,log2TrafoSize,trafoDepth,MaxTrafoDepth);
3817 "log2TrafoSize:%d trafoDepth:%d MaxTrafoDepth:%d parent-cbf-cb:%d parent-cbf-cr:%d\n",
3818 x0,y0,xBase,yBase,log2TrafoSize,trafoDepth,MaxTrafoDepth,parent_cbf_cb,parent_cbf_cr);
28253819
28263820 de265_image* img = tctx->img;
28273821 const seq_parameter_set* sps = &img->sps;
28283822
3823 int split_transform_flag;
3824
28293825 enum PredMode PredMode = img->get_pred_mode(x0,y0);
2830 enum PartMode PartMode = img->get_PartMode(x0,y0);
2831
2832 int split_transform_flag;
2833
2834 int interSplitFlag= (sps->max_transform_hierarchy_depth_inter==0 &&
2835 PredMode == MODE_INTER &&
2836 PartMode != PART_2Nx2N &&
2837 trafoDepth == 0);
2838
3826 assert(PredMode == cuPredMode);
28393827
28403828 /* If TrafoSize is larger than maximum size -> split automatically
28413829 If TrafoSize is at minimum size -> do not split
28523840 }
28533841 else
28543842 {
3843 enum PartMode PartMode = img->get_PartMode(x0,y0);
3844
3845 int interSplitFlag= (sps->max_transform_hierarchy_depth_inter==0 &&
3846 trafoDepth == 0 &&
3847 PredMode == MODE_INTER &&
3848 PartMode != PART_2Nx2N);
3849
28553850 split_transform_flag = (log2TrafoSize > sps->Log2MaxTrafoSize ||
28563851 (IntraSplitFlag==1 && trafoDepth==0) ||
28573852 interSplitFlag==1) ? 1:0;
28583853 }
28593854
2860
28613855 if (split_transform_flag) {
28623856 logtrace(LogSlice,"set_split_transform_flag(%d,%d, %d)\n",x0,y0,trafoDepth);
28633857 img->set_split_transform_flag(x0,y0,trafoDepth);
28643858 }
28653859
2866
28673860 int cbf_cb=-1;
28683861 int cbf_cr=-1;
28693862
2870 if (log2TrafoSize>2) {
3863 // CBF_CB/CR flags are encoded like this:
3864 // 4:2:0 and 4:4:4 modes: binary flag in bit 0
3865 // 4:2:2 mode: bit 0: top block, bit 1: bottom block
3866
3867 if ((log2TrafoSize>2 && sps->ChromaArrayType != CHROMA_MONO) ||
3868 sps->ChromaArrayType == CHROMA_444) {
28713869 // we do not have to test for trafoDepth==0, because parent_cbf_cb is 1 at depth 0
28723870 if (/*trafoDepth==0 ||*/ parent_cbf_cb) {
28733871 cbf_cb = decode_cbf_chroma(tctx,trafoDepth);
3872
3873 if (sps->ChromaArrayType == CHROMA_422 && (!split_transform_flag || log2TrafoSize==3)) {
3874 cbf_cb |= (decode_cbf_chroma(tctx,trafoDepth) << 1);
3875 }
28743876 }
28753877
28763878 // we do not have to test for trafoDepth==0, because parent_cbf_cb is 1 at depth 0
28773879 if (/*trafoDepth==0 ||*/ parent_cbf_cr) {
28783880 cbf_cr = decode_cbf_chroma(tctx,trafoDepth);
2879 }
2880 }
2881
3881
3882 if (sps->ChromaArrayType == CHROMA_422 && (!split_transform_flag || log2TrafoSize==3)) {
3883 cbf_cr |= (decode_cbf_chroma(tctx,trafoDepth) << 1);
3884 }
3885 }
3886 }
3887
3888 //printf("CBF: cb:%d cr:%d\n",cbf_cb,cbf_cr);
28823889
28833890 // cbf_cr/cbf_cb not present in bitstream -> induce values
28843891
28853892 if (cbf_cb<0) {
3893 assert(!(trafoDepth==0 && log2TrafoSize==2));
3894
3895 /* The standard specifies to check trafoDepth>0 AND log2TrafoSize==2.
3896 However, I think that trafoDepth>0 is redundant as a CB is always
3897 at least 8x8 and hence trafoDepth>0.
3898 */
3899
28863900 if (trafoDepth>0 && log2TrafoSize==2) {
28873901 cbf_cb = parent_cbf_cb;
28883902 } else {
29143928 MaxTrafoDepth,IntraSplitFlag, cuPredMode, cbf_cb,cbf_cr);
29153929 }
29163930 else {
2917 int cbf_luma=1;
3931 int cbf_luma;
29183932
29193933 if (PredMode==MODE_INTRA || trafoDepth!=0 || cbf_cb || cbf_cr) {
29203934 cbf_luma = decode_cbf_luma(tctx,trafoDepth);
29213935 }
3936 else {
3937 /* There cannot be INTER blocks with no residual data.
3938 That case is already handled with rqt_root_cbf.
3939 */
3940
3941 cbf_luma = 1;
3942 }
29223943
29233944 logtrace(LogSlice,"call read_transform_unit %d/%d\n",x0,y0);
29243945
29253946 read_transform_unit(tctx, x0,y0,xBase,yBase, xCUBase,yCUBase, log2TrafoSize,trafoDepth, blkIdx,
29263947 cbf_luma, cbf_cb, cbf_cr);
2927
2928
2929 int nT = 1<<log2TrafoSize;
2930
2931
2932 if (cuPredMode == MODE_INTRA) // if intra mode
2933 {
2934 enum IntraPredMode intraPredMode = img->get_IntraPredMode(x0,y0);
2935
2936 decode_intra_prediction(img, x0,y0, intraPredMode, nT, 0);
2937
2938 enum IntraPredMode chromaPredMode = tctx->IntraPredModeC;
2939
2940 if (nT>=8) {
2941 decode_intra_prediction(img, x0/2,y0/2, chromaPredMode, nT/2, 1);
2942 decode_intra_prediction(img, x0/2,y0/2, chromaPredMode, nT/2, 2);
2943 }
2944 else if (blkIdx==3) {
2945 decode_intra_prediction(img, xBase/2,yBase/2, chromaPredMode, nT, 1);
2946 decode_intra_prediction(img, xBase/2,yBase/2, chromaPredMode, nT, 2);
2947 }
2948 }
2949
2950 // NOTE: disable MC-mode residuals:
2951 { //if (cuPredMode == MODE_INTRA) {
2952 if (cbf_luma) {
2953 scale_coefficients(tctx, x0,y0, xCUBase,yCUBase, nT, 0,
2954 tctx->transform_skip_flag[0], PredMode==MODE_INTRA);
2955 }
2956
2957 if (nT>=8) {
2958 if (cbf_cb) {
2959 scale_coefficients(tctx, x0/2,y0/2, xCUBase/2,yCUBase/2, nT/2, 1,
2960 tctx->transform_skip_flag[1], PredMode==MODE_INTRA);
2961 }
2962 if (cbf_cr) {
2963 scale_coefficients(tctx, x0/2,y0/2, xCUBase/2,yCUBase/2, nT/2, 2,
2964 tctx->transform_skip_flag[2], PredMode==MODE_INTRA);
2965 }
2966 }
2967 else if (blkIdx==3) {
2968 if (cbf_cb) {
2969 scale_coefficients(tctx, xBase/2,yBase/2, xCUBase/2,yCUBase/2, nT, 1,
2970 tctx->transform_skip_flag[1], PredMode==MODE_INTRA);
2971 }
2972 if (cbf_cr) {
2973 scale_coefficients(tctx, xBase/2,yBase/2, xCUBase/2,yCUBase/2, nT, 2,
2974 tctx->transform_skip_flag[2], PredMode==MODE_INTRA);
2975 }
2976 }
2977 }
29783948 }
29793949 }
29803950
30494019 }
30504020
30514021 //set_mvd(tctx->decctx, x0,y0, refList, value[0],value[1]);
3052 tctx->mvd[refList][0] = value[0];
3053 tctx->mvd[refList][1] = value[1];
4022 tctx->motion.mvd[refList][0] = value[0];
4023 tctx->motion.mvd[refList][1] = value[1];
30544024
30554025 logtrace(LogSlice, "MVD[%d;%d|%d] = %d;%d\n",x0,y0,refList, value[0],value[1]);
30564026 }
30604030 int x0, int y0,
30614031 int nPbW, int nPbH)
30624032 {
3063 slice_segment_header* shdr = tctx->shdr;
3064
3065 int merge_idx;
3066 if (shdr->MaxNumMergeCand>1) {
3067 merge_idx = decode_merge_idx(tctx);
3068 }
3069 else {
3070 merge_idx = 0;
3071 }
3072
3073 tctx->merge_idx = merge_idx;
3074 tctx->merge_flag = true;
4033 int merge_idx = decode_merge_idx(tctx);
4034
4035 tctx->motion.merge_idx = merge_idx;
4036 tctx->motion.merge_flag = true;
30754037
30764038 logtrace(LogSlice,"prediction skip 2Nx2N, merge_idx: %d\n",merge_idx);
30774039 }
30784040
30794041
4042 /* xC/yC : CB position
4043 xB/yB : position offset of the PB
4044 nPbW/nPbH : size of PB
4045 nCS : CB size
4046 */
30804047 void read_prediction_unit(thread_context* tctx,
30814048 int xC,int yC, int xB,int yB,
30824049 int nPbW, int nPbH,
30904057 slice_segment_header* shdr = tctx->shdr;
30914058
30924059 int merge_flag = decode_merge_flag(tctx);
3093 tctx->merge_flag = merge_flag;
4060 tctx->motion.merge_flag = merge_flag;
30944061
30954062 if (merge_flag) {
3096 int merge_idx;
3097
3098 if (shdr->MaxNumMergeCand>1) {
3099 merge_idx = decode_merge_idx(tctx);
3100 }
3101 else {
3102 merge_idx = 0;
3103 }
4063 int merge_idx = decode_merge_idx(tctx);
31044064
31054065 logtrace(LogSlice,"prediction unit %d,%d, merge mode, index: %d\n",x0,y0,merge_idx);
31064066
3107 tctx->merge_idx = merge_idx;
4067 tctx->motion.merge_idx = merge_idx;
31084068 }
31094069 else { // no merge flag
31104070 enum InterPredIdc inter_pred_idc;
31164076 inter_pred_idc = PRED_L0;
31174077 }
31184078
3119 tctx->inter_pred_idc = inter_pred_idc; // set_inter_pred_idc(ctx,x0,y0, inter_pred_idc);
4079 tctx->motion.inter_pred_idc = inter_pred_idc; // set_inter_pred_idc(ctx,x0,y0, inter_pred_idc);
31204080
31214081 if (inter_pred_idc != PRED_L1) {
31224082 int ref_idx_l0 = decode_ref_idx_lX(tctx, shdr->num_ref_idx_l0_active);
31234083
31244084 // NOTE: case for only one reference frame is handles in decode_ref_idx_lX()
3125 tctx->refIdx[0] = ref_idx_l0;
4085 tctx->motion.refIdx[0] = ref_idx_l0;
31264086
31274087 read_mvd_coding(tctx,x0,y0, 0);
31284088
31294089 int mvp_l0_flag = decode_mvp_lx_flag(tctx); // l0
3130 tctx->mvp_lX_flag[0] = mvp_l0_flag;
4090 tctx->motion.mvp_l0_flag = mvp_l0_flag;
31314091
31324092 logtrace(LogSlice,"prediction unit %d,%d, L0, refIdx=%d mvp_l0_flag:%d\n",
3133 x0,y0, tctx->refIdx[0], mvp_l0_flag);
4093 x0,y0, tctx->motion.refIdx[0], mvp_l0_flag);
31344094 }
31354095
31364096 if (inter_pred_idc != PRED_L0) {
31374097 int ref_idx_l1 = decode_ref_idx_lX(tctx, shdr->num_ref_idx_l1_active);
31384098
31394099 // NOTE: case for only one reference frame is handles in decode_ref_idx_lX()
3140 tctx->refIdx[1] = ref_idx_l1;
4100 tctx->motion.refIdx[1] = ref_idx_l1;
31414101
31424102 if (shdr->mvd_l1_zero_flag &&
31434103 inter_pred_idc == PRED_BI) {
3144 tctx->mvd[1][0] = 0;
3145 tctx->mvd[1][1] = 0;
4104 tctx->motion.mvd[1][0] = 0;
4105 tctx->motion.mvd[1][1] = 0;
31464106 }
31474107 else {
31484108 read_mvd_coding(tctx,x0,y0, 1);
31494109 }
31504110
31514111 int mvp_l1_flag = decode_mvp_lx_flag(tctx); // l1
3152 tctx->mvp_lX_flag[1] = mvp_l1_flag;
4112 tctx->motion.mvp_l1_flag = mvp_l1_flag;
31534113
31544114 logtrace(LogSlice,"prediction unit %d,%d, L1, refIdx=%d mvp_l1_flag:%d\n",
3155 x0,y0, tctx->refIdx[1], mvp_l1_flag);
3156 }
3157 }
3158
3159
3160
3161 decode_prediction_unit(tctx, xC,yC,xB,yB, nCS, nPbW,nPbH, partIdx);
3162 }
3163
3164
3165
4115 x0,y0, tctx->motion.refIdx[1], mvp_l1_flag);
4116 }
4117 }
4118
4119
4120
4121 decode_prediction_unit(tctx->decctx, tctx->shdr, tctx->img, tctx->motion,
4122 xC,yC,xB,yB, nCS, nPbW,nPbH, partIdx);
4123 }
4124
4125
4126
4127
4128 template <class pixel_t>
4129 void read_pcm_samples_internal(thread_context* tctx, int x0, int y0, int log2CbSize,
4130 int cIdx, bitreader& br)
4131 {
4132 const seq_parameter_set* sps = &tctx->img->sps;
4133
4134 int nPcmBits;
4135 int bitDepth;
4136
4137 int w = 1<<log2CbSize;
4138 int h = 1<<log2CbSize;
4139
4140 if (cIdx>0) {
4141 w /= tctx->img->sps.SubWidthC;
4142 h /= tctx->img->sps.SubHeightC;
4143
4144 x0 /= tctx->img->sps.SubWidthC;
4145 y0 /= tctx->img->sps.SubHeightC;
4146
4147 nPcmBits = sps->pcm_sample_bit_depth_chroma;
4148 bitDepth = sps->BitDepth_C;
4149 }
4150 else {
4151 nPcmBits = sps->pcm_sample_bit_depth_luma;
4152 bitDepth = sps->BitDepth_Y;
4153 }
4154
4155 pixel_t* ptr;
4156 int stride;
4157 ptr = tctx->img->get_image_plane_at_pos_NEW<pixel_t>(cIdx,x0,y0);
4158 stride = tctx->img->get_image_stride(cIdx);
4159
4160 int shift = bitDepth - nPcmBits;
4161
4162 for (int y=0;y<h;y++)
4163 for (int x=0;x<w;x++)
4164 {
4165 int value = get_bits(&br, nPcmBits);
4166 ptr[y*stride+x] = value << shift;
4167 }
4168 }
31664169
31674170 static void read_pcm_samples(thread_context* tctx, int x0, int y0, int log2CbSize)
31684171 {
31724175 br.nextbits = 0;
31734176 br.nextbits_cnt = 0;
31744177
3175 const seq_parameter_set* sps = &tctx->img->sps;
3176 //fprintf(stderr,"PCM pos: %d %d (POC=%d)\n",x0,y0,tctx->decctx->img->PicOrderCntVal);
3177
3178 int nBitsY = sps->pcm_sample_bit_depth_luma;
3179 int nBitsC = sps->pcm_sample_bit_depth_chroma;
3180
3181 int wY = 1<<log2CbSize;
3182 int wC = 1<<(log2CbSize-1);
3183
3184 uint8_t* yPtr;
3185 uint8_t* cbPtr;
3186 uint8_t* crPtr;
3187 int stride;
3188 int chroma_stride;
3189 yPtr = tctx->img->get_image_plane(0);
3190 cbPtr = tctx->img->get_image_plane(1);
3191 crPtr = tctx->img->get_image_plane(2);
3192 stride = tctx->img->get_image_stride(0);
3193 chroma_stride = tctx->img->get_image_stride(1);
3194
3195 yPtr = &yPtr [y0*stride + x0];
3196 cbPtr = &cbPtr[y0/2*chroma_stride + x0/2];
3197 crPtr = &crPtr[y0/2*chroma_stride + x0/2];
3198
3199 int shiftY = sps->BitDepth_Y - nBitsY;
3200 int shiftC = sps->BitDepth_C - nBitsC;
3201
3202 for (int y=0;y<wY;y++)
3203 for (int x=0;x<wY;x++)
3204 {
3205 int value = get_bits(&br, nBitsY);
3206 yPtr[y*stride+x] = value << shiftY;
3207 }
3208
3209 for (int y=0;y<wC;y++)
3210 for (int x=0;x<wC;x++)
3211 {
3212 int value = get_bits(&br, nBitsC);
3213 cbPtr[y*chroma_stride+x] = value << shiftC;
3214 }
3215
3216 for (int y=0;y<wC;y++)
3217 for (int x=0;x<wC;x++)
3218 {
3219 int value = get_bits(&br, nBitsC);
3220 crPtr[y*chroma_stride+x] = value << shiftC;
3221 }
4178
4179 if (tctx->img->high_bit_depth(0)) {
4180 read_pcm_samples_internal<uint16_t>(tctx,x0,y0,log2CbSize,0,br);
4181 } else {
4182 read_pcm_samples_internal<uint8_t>(tctx,x0,y0,log2CbSize,0,br);
4183 }
4184
4185 if (tctx->img->sps.ChromaArrayType != CHROMA_MONO) {
4186 if (tctx->img->high_bit_depth(1)) {
4187 read_pcm_samples_internal<uint16_t>(tctx,x0,y0,log2CbSize,1,br);
4188 read_pcm_samples_internal<uint16_t>(tctx,x0,y0,log2CbSize,2,br);
4189 } else {
4190 read_pcm_samples_internal<uint8_t>(tctx,x0,y0,log2CbSize,1,br);
4191 read_pcm_samples_internal<uint8_t>(tctx,x0,y0,log2CbSize,2,br);
4192 }
4193 }
32224194
32234195 prepare_for_CABAC(&br);
32244196 tctx->cabac_decoder.bitstream_curr = br.data;
32254197 init_CABAC_decoder_2(&tctx->cabac_decoder);
32264198 }
32274199
4200
4201 int map_chroma_pred_mode(int intra_chroma_pred_mode, int IntraPredMode)
4202 {
4203 if (intra_chroma_pred_mode==4) {
4204 return IntraPredMode;
4205 }
4206 else {
4207 static const enum IntraPredMode IntraPredModeCCand[4] = {
4208 INTRA_PLANAR,
4209 INTRA_ANGULAR_26, // vertical
4210 INTRA_ANGULAR_10, // horizontal
4211 INTRA_DC
4212 };
4213
4214 int IntraPredModeC = IntraPredModeCCand[intra_chroma_pred_mode];
4215 if (IntraPredModeC == IntraPredMode) {
4216 return INTRA_ANGULAR_34;
4217 }
4218 else {
4219 return IntraPredModeC;
4220 }
4221 }
4222 }
4223
4224 // h.265-V2 Table 8-3
4225 static const uint8_t map_chroma_422[35] = {
4226 0,1,2, 2, 2, 2, 3, 5, 7, 8,10,12,13,15,17,18,19,20,
4227 21,22,23,23,24,24,25,25,26,27,27,28,28,29,29,30,31
4228 };
32284229
32294230 void read_coding_unit(thread_context* tctx,
32304231 int x0, int y0, // position of coding unit in frame
32394240 logtrace(LogSlice,"- read_coding_unit %d;%d cbsize:%d\n",x0,y0,1<<log2CbSize);
32404241
32414242
3242 img->set_log2CbSize(x0,y0, log2CbSize);
4243 //QQprintf("- read_coding_unit %d;%d cbsize:%d\n",x0,y0,1<<log2CbSize);
4244
4245 img->set_log2CbSize(x0,y0, log2CbSize, true);
4246
4247 /* This is only required on corrupted input streams.
4248 It may happen that there are several slices in the image that overlap.
4249 In this case, flags would accumulate from both slices.
4250 */
4251 img->clear_split_transform_flags(x0,y0, log2CbSize);
32434252
32444253 int nCbS = 1<<log2CbSize; // number of coding block samples
32454254
32824291 // DECODE
32834292
32844293 int nCS_L = 1<<log2CbSize;
3285 decode_prediction_unit(tctx,x0,y0, 0,0, nCS_L, nCS_L,nCS_L, 0);
4294 decode_prediction_unit(tctx->decctx,tctx->shdr,tctx->img,tctx->motion,
4295 x0,y0, 0,0, nCS_L, nCS_L,nCS_L, 0);
32864296 }
32874297 else /* not skipped */ {
32884298 if (shdr->slice_type != SLICE_TYPE_I) {
33474357
33484358 int mpm_idx[4], rem_intra_luma_pred_mode[4];
33494359 idx=0;
4360
4361 int availableA0 = check_CTB_available(img, x0,y0, x0-1,y0);
4362 int availableB0 = check_CTB_available(img, x0,y0, x0,y0-1);
33504363
33514364 for (int j=0;j<nCbS;j+=pbOffset)
33524365 for (int i=0;i<nCbS;i+=pbOffset)
33664379
33674380 int IntraPredMode;
33684381
3369 int availableA = check_CTB_available(img, shdr, x,y, x-1,y);
3370 int availableB = check_CTB_available(img, shdr, x,y, x,y-1);
4382 int availableA = availableA0 || (i>0); // left candidate always available for right blk
4383 int availableB = availableB0 || (j>0); // top candidate always available for bottom blk
4384
4385
33714386
33724387 int PUidx = (x>>sps->Log2MinPUSize) + (y>>sps->Log2MinPUSize)*sps->PicWidthInMinPUs;
33734388
3374 // block on left side
3375
3376 enum IntraPredMode candIntraPredModeA, candIntraPredModeB;
3377 if (availableA==false) {
3378 candIntraPredModeA=INTRA_DC;
3379 }
3380 else if (img->get_pred_mode(x-1,y) != MODE_INTRA ||
3381 img->get_pcm_flag (x-1,y)) {
3382 candIntraPredModeA=INTRA_DC;
3383 }
3384 else {
3385 candIntraPredModeA = img->get_IntraPredMode_atIndex(PUidx-1);
3386 }
3387
3388 // block above
3389
3390 if (availableB==false) {
3391 candIntraPredModeB=INTRA_DC;
3392 }
3393 else if (img->get_pred_mode(x,y-1) != MODE_INTRA ||
3394 img->get_pcm_flag (x,y-1)) {
3395 candIntraPredModeB=INTRA_DC;
3396 }
3397 else if (y-1 < ((y >> sps->Log2CtbSizeY) << sps->Log2CtbSizeY)) {
3398 candIntraPredModeB=INTRA_DC;
3399 }
3400 else {
3401 candIntraPredModeB = img->get_IntraPredMode_atIndex(PUidx-sps->PicWidthInMinPUs);
3402 }
3403
3404 // build candidate list
3405
34064389 int candModeList[3];
34074390
3408 logtrace(LogSlice,"availableA:%d candA:%d & availableB:%d candB:%d\n",
3409 availableA, candIntraPredModeA,
3410 availableB, candIntraPredModeB);
3411
3412 if (candIntraPredModeA == candIntraPredModeB) {
3413 if (candIntraPredModeA < 2) {
3414 candModeList[0] = INTRA_PLANAR;
3415 candModeList[1] = INTRA_DC;
3416 candModeList[2] = INTRA_ANGULAR_26;
3417 }
3418 else {
3419 candModeList[0] = candIntraPredModeA;
3420 candModeList[1] = 2 + ((candIntraPredModeA-2 -1 +32) % 32);
3421 candModeList[2] = 2 + ((candIntraPredModeA-2 +1 ) % 32);
3422 }
3423 }
3424 else {
3425 candModeList[0] = candIntraPredModeA;
3426 candModeList[1] = candIntraPredModeB;
3427
3428 if (candIntraPredModeA != INTRA_PLANAR &&
3429 candIntraPredModeB != INTRA_PLANAR) {
3430 candModeList[2] = INTRA_PLANAR;
3431 }
3432 else if (candIntraPredModeA != INTRA_DC &&
3433 candIntraPredModeB != INTRA_DC) {
3434 candModeList[2] = INTRA_DC;
3435 }
3436 else {
3437 candModeList[2] = INTRA_ANGULAR_26;
3438 }
3439 }
4391 fillIntraPredModeCandidates(candModeList,x,y,PUidx,
4392 availableA, availableB, img);
34404393
34414394 for (int i=0;i<3;i++)
34424395 logtrace(LogSlice,"candModeList[%d] = %d\n", i, candModeList[i]);
34484401 // sort candModeList
34494402
34504403 if (candModeList[0] > candModeList[1]) {
3451 int t = candModeList[0]; candModeList[0]=candModeList[1]; candModeList[1]=t;
4404 std::swap(candModeList[0],candModeList[1]);
34524405 }
34534406 if (candModeList[0] > candModeList[2]) {
3454 int t = candModeList[0]; candModeList[0]=candModeList[2]; candModeList[2]=t;
4407 std::swap(candModeList[0],candModeList[2]);
34554408 }
34564409 if (candModeList[1] > candModeList[2]) {
3457 int t = candModeList[1]; candModeList[1]=candModeList[2]; candModeList[2]=t;
4410 std::swap(candModeList[1],candModeList[2]);
34584411 }
34594412
34604413 // skip modes in the list
34764429
34774430 // set chroma intra prediction mode
34784431
3479 int intra_chroma_pred_mode = decode_intra_chroma_pred_mode(tctx);
3480
3481 int IntraPredMode = img->get_IntraPredMode(x0,y0);
3482 logtrace(LogSlice,"IntraPredMode: %d\n",IntraPredMode);
3483
3484 int IntraPredModeC;
3485 if (intra_chroma_pred_mode==4) {
3486 IntraPredModeC = IntraPredMode;
3487 }
3488 else {
3489 static enum IntraPredMode IntraPredModeCCand[4] = {
3490 INTRA_PLANAR,
3491 INTRA_ANGULAR_26, // vertical
3492 INTRA_ANGULAR_10, // horizontal
3493 INTRA_DC
3494 };
3495
3496 IntraPredModeC = IntraPredModeCCand[intra_chroma_pred_mode];
3497 if (IntraPredModeC == IntraPredMode) {
3498 IntraPredModeC = INTRA_ANGULAR_34;
4432 if (sps->ChromaArrayType == CHROMA_444) {
4433 // chroma 4:4:4
4434
4435 idx = 0;
4436 for (int j=0;j<nCbS;j+=pbOffset)
4437 for (int i=0;i<nCbS;i+=pbOffset) {
4438 int x = x0+i;
4439 int y = y0+j;
4440
4441 int intra_chroma_pred_mode = decode_intra_chroma_pred_mode(tctx);
4442 int IntraPredMode = img->get_IntraPredMode(x,y);
4443
4444 int IntraPredModeC = map_chroma_pred_mode(intra_chroma_pred_mode, IntraPredMode);
4445
4446 logtrace(LogSlice,"IntraPredModeC[%d][%d]: %d (blksize:%d)\n",x,y,IntraPredModeC,
4447 1<<log2IntraPredSize);
4448
4449 img->set_IntraPredModeC(x,y, log2IntraPredSize,
4450 (enum IntraPredMode)IntraPredModeC,
4451 intra_chroma_pred_mode == 4);
4452 idx++;
4453 }
4454 }
4455 else if (sps->ChromaArrayType != CHROMA_MONO) {
4456 // chroma 4:2:0 and 4:2:2
4457
4458 int intra_chroma_pred_mode = decode_intra_chroma_pred_mode(tctx);
4459 int IntraPredMode = img->get_IntraPredMode(x0,y0);
4460 logtrace(LogSlice,"IntraPredMode: %d\n",IntraPredMode);
4461 int IntraPredModeC = map_chroma_pred_mode(intra_chroma_pred_mode, IntraPredMode);
4462
4463 if (sps->ChromaArrayType == CHROMA_422) {
4464 IntraPredModeC = map_chroma_422[ IntraPredModeC ];
34994465 }
3500 }
3501
3502 logtrace(LogSlice,"IntraPredModeC[%d][%d]: %d\n",x0,y0,IntraPredModeC);
3503
3504 tctx->IntraPredModeC = (enum IntraPredMode) IntraPredModeC;
4466
4467 img->set_IntraPredModeC(x0,y0, log2CbSize,
4468 (enum IntraPredMode)IntraPredModeC,
4469 intra_chroma_pred_mode == 4);
4470 }
35054471 }
35064472 }
35074473 else { // INTER
35514517 if (!pcm_flag) { // !pcm
35524518 bool rqt_root_cbf;
35534519
3554 uint8_t merge_flag = tctx->merge_flag; // !!get_merge_flag(ctx,x0,y0);
4520 uint8_t merge_flag = tctx->motion.merge_flag; // !!get_merge_flag(ctx,x0,y0);
35554521
35564522 if (cuPredMode != MODE_INTRA &&
35574523 !(PartMode == PART_2Nx2N && merge_flag)) {
35594525 rqt_root_cbf = !!decode_rqt_root_cbf(tctx);
35604526 }
35614527 else {
4528 /* rqt_root_cbf=1 is inferred for Inter blocks with 2Nx2N, merge mode.
4529 These must be some residual data, because otherwise, the CB could
4530 also be coded in SKIP mode.
4531 */
4532
35624533 rqt_root_cbf = true;
35634534 }
35644535
35764547
35774548 logtrace(LogSlice,"MaxTrafoDepth: %d\n",MaxTrafoDepth);
35784549
4550 uint8_t initial_chroma_cbf = 1;
4551 if (sps->ChromaArrayType == CHROMA_MONO) {
4552 initial_chroma_cbf = 0;
4553 }
4554
35794555 read_transform_tree(tctx, x0,y0, x0,y0, x0,y0, log2CbSize, 0,0,
3580 MaxTrafoDepth, IntraSplitFlag, cuPredMode, 1,1);
4556 MaxTrafoDepth, IntraSplitFlag, cuPredMode,
4557 initial_chroma_cbf, initial_chroma_cbf);
35814558 }
35824559 } // !pcm
35834560 }
36244601 // shdr->CuQpDelta = 0; // TODO check: is this the right place to set to default value ?
36254602 }
36264603
4604
4605 if (tctx->shdr->cu_chroma_qp_offset_enabled_flag &&
4606 log2CbSize >= img->pps.Log2MinCuChromaQpOffsetSize) {
4607 tctx->IsCuChromaQpOffsetCoded = 0;
4608 }
4609
36274610 if (split_flag) {
36284611 int x1 = x0 + (1<<(log2CbSize-1));
36294612 int y1 = y0 + (1<<(log2CbSize-1));
36744657
36754658 const int startCtbY = tctx->CtbY;
36764659
4660 //printf("start decoding substream at %d;%d\n",tctx->CtbX,tctx->CtbY);
4661
36774662 // in WPP mode: initialize CABAC model with stored model from row above
36784663
36794664 if ((!first_independent_substream || tctx->CtbY != startCtbY) &&
36814666 tctx->CtbY>=1 && tctx->CtbX==0)
36824667 {
36834668 if (sps->PicWidthInCtbsY>1) {
4669 if ((tctx->CtbY-1) >= tctx->imgunit->ctx_models.size()) {
4670 return Decode_Error;
4671 }
4672
4673 //printf("CTX wait on %d/%d\n",1,tctx->CtbY-1);
4674
36844675 // we have to wait until the context model data is there
36854676 tctx->img->wait_for_progress(tctx->task, 1,tctx->CtbY-1,CTB_PROGRESS_PREFILTER);
36864677
36874678 // copy CABAC model from previous CTB row
3688 memcpy(tctx->ctx_model,
3689 &tctx->imgunit->ctx_models[(tctx->CtbY-1) * CONTEXT_MODEL_TABLE_LENGTH],
3690 CONTEXT_MODEL_TABLE_LENGTH * sizeof(context_model));
4679 tctx->ctx_model = tctx->imgunit->ctx_models[(tctx->CtbY-1)];
4680 tctx->imgunit->ctx_models[(tctx->CtbY-1)].release(); // not used anymore
36914681 }
36924682 else {
36934683 tctx->img->wait_for_progress(tctx->task, 0,tctx->CtbY-1,CTB_PROGRESS_PREFILTER);
3694 initialize_CABAC(tctx);
4684 initialize_CABAC_models(tctx);
36954685 }
36964686 }
36974687
37004690 const int ctbx = tctx->CtbX;
37014691 const int ctby = tctx->CtbY;
37024692
4693 if (ctbx+ctby*ctbW >= tctx->img->pps.CtbAddrRStoTS.size()) {
4694 return Decode_Error;
4695 }
4696
4697 if (ctbx >= tctx->img->sps.PicWidthInCtbsY ||
4698 ctby >= tctx->img->sps.PicHeightInCtbsY) {
4699 return Decode_Error;
4700 }
4701
37034702 if (block_wpp && ctby>0 && ctbx < ctbW-1) {
3704 //printf("wait on %d/%d\n",ctbx+1,ctby-1);
4703
4704 // TODO: if we are in tiles mode and at the right border, do not wait for x+1,y-1
4705
4706 //printf("wait on %d/%d (%d)\n",ctbx+1,ctby-1, ctbx+1+(ctby-1)*sps->PicWidthInCtbsY);
37054707
37064708 tctx->img->wait_for_progress(tctx->task, ctbx+1,ctby-1, CTB_PROGRESS_PREFILTER);
37074709 }
37084710
3709 //printf("%p: decode %d;%d\n", tctx, tctx->CtbY,tctx->CtbX);
4711 //printf("%p: decode %d;%d\n", tctx, tctx->CtbX,tctx->CtbY);
37104712
37114713
37124714 // read and decode CTB
4715
4716 if (tctx->ctx_model.empty() == false) {
4717 return Decode_Error;
4718 }
37134719
37144720 read_coding_tree_unit(tctx);
37154721
37204726 ctbx == 1 &&
37214727 ctby < sps->PicHeightInCtbsY-1)
37224728 {
3723 context_model* ctx_store = &tctx->imgunit->ctx_models[ctby * CONTEXT_MODEL_TABLE_LENGTH];
3724
3725 memcpy(ctx_store,
3726 &tctx->ctx_model,
3727 CONTEXT_MODEL_TABLE_LENGTH * sizeof(context_model));
4729 // no storage for context table has been allocated
4730 if (tctx->imgunit->ctx_models.size() <= ctby) {
4731 return Decode_Error;
4732 }
4733
4734 tctx->imgunit->ctx_models[ctby] = tctx->ctx_model;
4735 tctx->imgunit->ctx_models[ctby].decouple(); // store an independent copy
37284736 }
37294737
37304738
37314739 // end of slice segment ?
37324740
37334741 int end_of_slice_segment_flag = decode_CABAC_term_bit(&tctx->cabac_decoder);
4742 //printf("end-of-slice flag: %d\n", end_of_slice_segment_flag);
37344743
37354744 if (end_of_slice_segment_flag) {
37364745 // at the end of the slice segment, we store the CABAC model if we need it
37374746 // because a dependent slice may follow
37384747
37394748 if (pps->dependent_slice_segments_enabled_flag) {
3740 memcpy(tctx->shdr->ctx_model_storage,
3741 tctx->ctx_model,
3742 CONTEXT_MODEL_TABLE_LENGTH * sizeof(context_model));
4749 tctx->shdr->ctx_model_storage = tctx->ctx_model;
4750 tctx->shdr->ctx_model_storage.decouple(); // store an independent copy
4751
4752 tctx->shdr->ctx_model_storage_defined = true;
37434753 }
37444754 }
37454755
37654775
37664776
37674777 if (end_of_slice_segment_flag) {
4778 /* corrupted inputs may send the end_of_slice_segment_flag even if not all
4779 CTBs in a row have been coded. Hence, we mark all of them as finished.
4780 */
4781
4782 /*
4783 for (int x = ctbx+1 ; x<sps->PicWidthInCtbsY; x++) {
4784 printf("mark skipped %d;%d\n",ctbx,ctby);
4785 tctx->img->ctb_progress[ctbx+ctby*ctbW].set_progress(CTB_PROGRESS_PREFILTER);
4786 }
4787 */
4788
37684789 return Decode_EndOfSliceSegment;
37694790 }
37704791
37944815
37954816
37964817
3797 void initialize_CABAC_at_slice_segment_start(thread_context* tctx)
4818 bool initialize_CABAC_at_slice_segment_start(thread_context* tctx)
37984819 {
37994820 de265_image* img = tctx->img;
38004821 const pic_parameter_set* pps = &img->pps;
38044825 if (shdr->dependent_slice_segment_flag) {
38054826 int prevCtb = pps->CtbAddrTStoRS[ pps->CtbAddrRStoTS[shdr->slice_segment_address] -1 ];
38064827
3807 slice_segment_header* prevCtbHdr = img->slices[ img->get_SliceHeaderIndex_atIndex(prevCtb) ];
4828 int sliceIdx = img->get_SliceHeaderIndex_atIndex(prevCtb);
4829 if (sliceIdx >= img->slices.size()) {
4830 return false;
4831 }
4832 slice_segment_header* prevCtbHdr = img->slices[ sliceIdx ];
38084833
38094834 if (pps->is_tile_start_CTB(shdr->slice_segment_address % sps->PicWidthInCtbsY,
38104835 shdr->slice_segment_address / sps->PicWidthInCtbsY
38114836 )) {
3812 initialize_CABAC(tctx);
4837 initialize_CABAC_models(tctx);
38134838 }
38144839 else {
4840 // wait for previous slice to finish decoding
4841
4842 //printf("wait for previous slice to finish decoding\n");
4843
4844
4845 slice_unit* prevSliceSegment = tctx->imgunit->get_prev_slice_segment(tctx->sliceunit);
4846 //assert(prevSliceSegment);
4847 if (prevSliceSegment==NULL) {
4848 return false;
4849 }
4850
4851 prevSliceSegment->finished_threads.wait_for_progress(prevSliceSegment->nThreads);
4852
4853
4854 /*
4855 printf("wait for %d,%d (init)\n",
4856 prevCtb / sps->PicWidthInCtbsY,
4857 prevCtb % sps->PicWidthInCtbsY);
38154858 tctx->img->wait_for_progress(tctx->task, prevCtb, CTB_PROGRESS_PREFILTER);
3816
3817 memcpy(tctx->ctx_model,
3818 prevCtbHdr->ctx_model_storage,
3819 CONTEXT_MODEL_TABLE_LENGTH * sizeof(context_model));
4859 */
4860
4861 if (!prevCtbHdr->ctx_model_storage_defined) {
4862 return false;
4863 }
4864
4865 tctx->ctx_model = prevCtbHdr->ctx_model_storage;
4866 prevCtbHdr->ctx_model_storage.release();
38204867 }
38214868 }
38224869 else {
3823 initialize_CABAC(tctx);
3824 }
4870 initialize_CABAC_models(tctx);
4871 }
4872
4873 return true;
4874 }
4875
4876
4877 std::string thread_task_ctb_row::name() const {
4878 char buf[100];
4879 sprintf(buf,"ctb-row-%d",debug_startCtbRow);
4880 return buf;
4881 }
4882
4883
4884 std::string thread_task_slice_segment::name() const {
4885 char buf[100];
4886 sprintf(buf,"slice-segment-%d;%d",debug_startCtbX,debug_startCtbY);
4887 return buf;
38254888 }
38264889
38274890
38284891 void thread_task_slice_segment::work()
38294892 {
3830 struct thread_task_slice_segment* data = this;
4893 thread_task_slice_segment* data = this;
38314894 thread_context* tctx = data->tctx;
38324895 de265_image* img = tctx->img;
38334896
38344897 state = Running;
3835 img->thread_run();
4898 img->thread_run(this);
38364899
38374900 setCtbAddrFromTS(tctx);
38384901
38394902 //printf("%p: A start decoding at %d/%d\n", tctx, tctx->CtbX,tctx->CtbY);
38404903
38414904 if (data->firstSliceSubstream) {
3842 initialize_CABAC_at_slice_segment_start(tctx);
4905 bool success = initialize_CABAC_at_slice_segment_start(tctx);
4906 if (!success) {
4907 state = Finished;
4908 tctx->sliceunit->finished_threads.increase_progress(1);
4909 img->thread_finishes(this);
4910 return;
4911 }
38434912 }
38444913 else {
3845 initialize_CABAC(tctx);
4914 initialize_CABAC_models(tctx);
38464915 }
38474916
38484917 init_CABAC_decoder_2(&tctx->cabac_decoder);
38504919 /*enum DecodeResult result =*/ decode_substream(tctx, false, data->firstSliceSubstream);
38514920
38524921 state = Finished;
3853 img->thread_finishes();
4922 tctx->sliceunit->finished_threads.increase_progress(1);
4923 img->thread_finishes(this);
38544924
38554925 return; // DE265_OK;
38564926 }
38584928
38594929 void thread_task_ctb_row::work()
38604930 {
3861 struct thread_task_ctb_row* data = this;
4931 thread_task_ctb_row* data = this;
38624932 thread_context* tctx = data->tctx;
38634933 de265_image* img = tctx->img;
38644934
38664936 int ctbW = sps->PicWidthInCtbsY;
38674937
38684938 state = Running;
3869 img->thread_run();
4939 img->thread_run(this);
38704940
38714941 setCtbAddrFromTS(tctx);
38724942
38734943 int ctby = tctx->CtbAddrInRS / ctbW;
38744944 int myCtbRow = ctby;
38754945
3876 // printf("start decoding at %d/%d\n", ctbx,ctby);
4946 //printf("start CTB-row decoding at row %d\n", ctby);
38774947
38784948 if (data->firstSliceSubstream) {
3879 initialize_CABAC_at_slice_segment_start(tctx);
4949 bool success = initialize_CABAC_at_slice_segment_start(tctx);
4950 if (!success) {
4951 // could not decode this row, mark whole row as finished
4952 for (int x=0;x<ctbW;x++) {
4953 img->ctb_progress[myCtbRow*ctbW + x].set_progress(CTB_PROGRESS_PREFILTER);
4954 }
4955
4956 state = Finished;
4957 tctx->sliceunit->finished_threads.increase_progress(1);
4958 img->thread_finishes(this);
4959 return;
4960 }
38804961 //initialize_CABAC(tctx);
38814962 }
38824963
38924973
38934974 // TODO: what about slices that end properly in the middle of a CTB row?
38944975
3895 #if 1
38964976 if (tctx->CtbY == myCtbRow) {
38974977 int lastCtbX = sps->PicWidthInCtbsY; // assume no tiles when WPP is on
38984978 for (int x = tctx->CtbX; x<lastCtbX ; x++) {
3899 img->ctb_progress[myCtbRow*ctbW + x].set_progress(CTB_PROGRESS_PREFILTER);
3900 }
3901 }
3902 #endif
4979
4980 if (x < img->sps.PicWidthInCtbsY &&
4981 myCtbRow < img->sps.PicHeightInCtbsY) {
4982 img->ctb_progress[myCtbRow*ctbW + x].set_progress(CTB_PROGRESS_PREFILTER);
4983 }
4984 }
4985 }
39034986
39044987 state = Finished;
3905 img->thread_finishes();
4988 tctx->sliceunit->finished_threads.increase_progress(1);
4989 img->thread_finishes(this);
39064990 }
39074991
39084992
39154999 const seq_parameter_set* sps = &img->sps;
39165000 slice_segment_header* shdr = tctx->shdr;
39175001
3918 initialize_CABAC_at_slice_segment_start(tctx);
5002 bool success = initialize_CABAC_at_slice_segment_start(tctx);
5003 if (!success) {
5004 return DE265_ERROR_UNSPECIFIED_DECODING_ERROR;
5005 }
39195006
39205007 init_CABAC_decoder_2(&tctx->cabac_decoder);
39215008
3922 // printf("-----\n");
5009 //printf("-----\n");
39235010
39245011 bool first_slice_substream = !shdr->dependent_slice_segment_flag;
39255012
39415028 }
39425029
39435030 substream++;
3944
5031
39455032
39465033 result = decode_substream(tctx, false, first_slice_substream);
39475034
39545041 first_slice_substream = false;
39555042
39565043 if (pps->tiles_enabled_flag) {
3957 initialize_CABAC(tctx);
5044 initialize_CABAC_models(tctx);
39585045 }
39595046 } while (true);
39605047
2828 #include "libde265/util.h"
2929 #include "libde265/refpic.h"
3030 #include "libde265/threads.h"
31 #include "contextmodel.h"
3132
3233 #include <vector>
34 #include <string.h>
3335
3436 #define MAX_NUM_REF_PICS 16
3537
36 #define SLICE_TYPE_B 0
37 #define SLICE_TYPE_P 1
38 #define SLICE_TYPE_I 2
39
38 class decoder_context;
39 class thread_context;
40 class error_queue;
41 class seq_parameter_set;
42 class pic_parameter_set;
43
44 enum SliceType
45 {
46 SLICE_TYPE_B = 0,
47 SLICE_TYPE_P = 1,
48 SLICE_TYPE_I = 2
49 };
4050
4151 /*
42 2Nx2N 2NxN Nx2N NxN
52 2Nx2N 2NxN Nx2N NxN
4353 +-------+ +-------+ +---+---+ +---+---+
4454 | | | | | | | | | |
4555 | | |_______| | | | |___|___|
4757 | | | | | | | | | |
4858 +-------+ +-------+ +---+---+ +---+---+
4959
50 2NxnU 2NxnD nLx2N nRx2N
60 2NxnU 2NxnD nLx2N nRx2N
5161 +-------+ +-------+ +-+-----+ +-----+-+
5262 |_______| | | | | | | | |
5363 | | | | | | | | | |
8898 INTRA_ANGULAR_22 = 22, INTRA_ANGULAR_23 = 23, INTRA_ANGULAR_24 = 24, INTRA_ANGULAR_25 = 25,
8999 INTRA_ANGULAR_26 = 26, INTRA_ANGULAR_27 = 27, INTRA_ANGULAR_28 = 28, INTRA_ANGULAR_29 = 29,
90100 INTRA_ANGULAR_30 = 30, INTRA_ANGULAR_31 = 31, INTRA_ANGULAR_32 = 32, INTRA_ANGULAR_33 = 33,
91 INTRA_ANGULAR_34 = 34,
92 INTRA_CHROMA_EQ_LUMA = 100 // chroma := luma
93 };
101 INTRA_ANGULAR_34 = 34
102 };
103
104
105 enum IntraChromaPredMode
106 {
107 INTRA_CHROMA_PLANAR_OR_34 = 0,
108 INTRA_CHROMA_ANGULAR_26_OR_34 = 1,
109 INTRA_CHROMA_ANGULAR_10_OR_34 = 2,
110 INTRA_CHROMA_DC_OR_34 = 3,
111 INTRA_CHROMA_LIKE_LUMA = 4
112 };
113
94114
95115 enum InterPredIdc
96116 {
97 PRED_L0=0,
98 PRED_L1=1,
99 PRED_BI=2
100 };
101
102 enum context_model_indices {
103 CONTEXT_MODEL_SAO_MERGE_FLAG = 0,
104 CONTEXT_MODEL_SAO_TYPE_IDX = CONTEXT_MODEL_SAO_MERGE_FLAG +1,
105 CONTEXT_MODEL_SPLIT_CU_FLAG = CONTEXT_MODEL_SAO_TYPE_IDX + 1,
106 CONTEXT_MODEL_CU_SKIP_FLAG = CONTEXT_MODEL_SPLIT_CU_FLAG + 3,
107 CONTEXT_MODEL_PART_MODE = CONTEXT_MODEL_CU_SKIP_FLAG + 3,
108 CONTEXT_MODEL_PREV_INTRA_LUMA_PRED_FLAG = CONTEXT_MODEL_PART_MODE + 4,
109 CONTEXT_MODEL_INTRA_CHROMA_PRED_MODE = CONTEXT_MODEL_PREV_INTRA_LUMA_PRED_FLAG + 1,
110 CONTEXT_MODEL_CBF_LUMA = CONTEXT_MODEL_INTRA_CHROMA_PRED_MODE + 1,
111 CONTEXT_MODEL_CBF_CHROMA = CONTEXT_MODEL_CBF_LUMA + 2,
112 CONTEXT_MODEL_SPLIT_TRANSFORM_FLAG = CONTEXT_MODEL_CBF_CHROMA + 4,
113 CONTEXT_MODEL_LAST_SIGNIFICANT_COEFFICIENT_X_PREFIX = CONTEXT_MODEL_SPLIT_TRANSFORM_FLAG + 3,
114 CONTEXT_MODEL_LAST_SIGNIFICANT_COEFFICIENT_Y_PREFIX = CONTEXT_MODEL_LAST_SIGNIFICANT_COEFFICIENT_X_PREFIX + 18,
115 CONTEXT_MODEL_CODED_SUB_BLOCK_FLAG = CONTEXT_MODEL_LAST_SIGNIFICANT_COEFFICIENT_Y_PREFIX + 18,
116 CONTEXT_MODEL_SIGNIFICANT_COEFF_FLAG = CONTEXT_MODEL_CODED_SUB_BLOCK_FLAG + 4,
117 CONTEXT_MODEL_COEFF_ABS_LEVEL_GREATER1_FLAG = CONTEXT_MODEL_SIGNIFICANT_COEFF_FLAG + 42,
118 CONTEXT_MODEL_COEFF_ABS_LEVEL_GREATER2_FLAG = CONTEXT_MODEL_COEFF_ABS_LEVEL_GREATER1_FLAG + 24,
119 CONTEXT_MODEL_CU_QP_DELTA_ABS = CONTEXT_MODEL_COEFF_ABS_LEVEL_GREATER2_FLAG + 6,
120 CONTEXT_MODEL_TRANSFORM_SKIP_FLAG = CONTEXT_MODEL_CU_QP_DELTA_ABS + 2,
121 CONTEXT_MODEL_MERGE_FLAG = CONTEXT_MODEL_TRANSFORM_SKIP_FLAG + 2,
122 CONTEXT_MODEL_MERGE_IDX = CONTEXT_MODEL_MERGE_FLAG + 1,
123 CONTEXT_MODEL_PRED_MODE_FLAG = CONTEXT_MODEL_MERGE_IDX + 1,
124 CONTEXT_MODEL_ABS_MVD_GREATER01_FLAG = CONTEXT_MODEL_PRED_MODE_FLAG + 1,
125 CONTEXT_MODEL_MVP_LX_FLAG = CONTEXT_MODEL_ABS_MVD_GREATER01_FLAG + 2,
126 CONTEXT_MODEL_RQT_ROOT_CBF = CONTEXT_MODEL_MVP_LX_FLAG + 1,
127 CONTEXT_MODEL_REF_IDX_LX = CONTEXT_MODEL_RQT_ROOT_CBF + 1,
128 CONTEXT_MODEL_INTER_PRED_IDC = CONTEXT_MODEL_REF_IDX_LX + 2,
129 CONTEXT_MODEL_CU_TRANSQUANT_BYPASS_FLAG = CONTEXT_MODEL_INTER_PRED_IDC + 5,
130 CONTEXT_MODEL_TABLE_LENGTH = CONTEXT_MODEL_CU_TRANSQUANT_BYPASS_FLAG + 1
131 };
132
133
134 typedef struct slice_segment_header {
135 slice_segment_header() { }
136
137 de265_error read(bitreader* br, struct decoder_context*, bool* continueDecoding);
117 // note: values have to match the decoding function decode_inter_pred_idc()
118 PRED_L0=1,
119 PRED_L1=2,
120 PRED_BI=3
121 };
122
123
124
125 class slice_segment_header {
126 public:
127 slice_segment_header() {
128 reset();
129 }
130
131 de265_error read(bitreader* br, decoder_context*, bool* continueDecoding);
132 de265_error write(error_queue*, CABAC_encoder&,
133 const seq_parameter_set* sps,
134 const pic_parameter_set* pps,
135 uint8_t nal_unit_type);
136
138137 void dump_slice_segment_header(const decoder_context*, int fd) const;
139138
140
141 int slice_index; // index through all slices in a picture
139 void set_defaults();
140 void reset();
141
142
143 int slice_index; // index through all slices in a picture (internal only)
142144
143145 char first_slice_segment_in_pic_flag;
144146 char no_output_of_prior_pics_flag;
202204 int slice_cb_qp_offset;
203205 int slice_cr_qp_offset;
204206
207 char cu_chroma_qp_offset_enabled_flag;
208
205209 char deblocking_filter_override_flag;
206210 char slice_deblocking_filter_disabled_flag;
207211 int slice_beta_offset; // = pps->beta_offset if undefined
218222
219223 // --- derived data ---
220224
221 int SliceAddrRS; // start of last independent slice
222225 int SliceQPY;
223
224226 int initType;
225227
226 int MaxNumMergeCand;
228 void compute_derived_values(const pic_parameter_set* pps);
229
230
231 // --- data for external modules ---
232
233 int SliceAddrRS; // slice_segment_address of last independent slice
234
235 int MaxNumMergeCand; // directly derived from 'five_minus_max_num_merge_cand'
227236 int CurrRpsIdx;
228237 ref_pic_set CurrRps; // the active reference-picture set
229238 int NumPocTotalCurr;
230239
231 int RefPicList[2][MAX_NUM_REF_PICS]; // contains indices into DPB
240 // number of entries: num_ref_idx_l0_active / num_ref_idx_l1_active
241 int RefPicList[2][MAX_NUM_REF_PICS]; // contains buffer IDs (D:indices into DPB/E:frame number)
232242 int RefPicList_POC[2][MAX_NUM_REF_PICS];
233243 int RefPicList_PicState[2][MAX_NUM_REF_PICS]; /* We have to save the PicState because the decoding
234244 of an image may be delayed and the PicState can
239249 is a long-term picture. */
240250
241251 // context storage for dependent slices (stores CABAC model at end of slice segment)
242 context_model ctx_model_storage[CONTEXT_MODEL_TABLE_LENGTH];
252 context_model_table ctx_model_storage;
253 bool ctx_model_storage_defined; // whether there is valid data in ctx_model_storage
243254
244255 std::vector<int> RemoveReferencesList; // images that can be removed from the DPB before decoding this slice
245256
246 } slice_segment_header;
257 };
247258
248259
249260
254265 unsigned char SaoEoClass; // use with (SaoTypeIdx>>(2*cIdx)) & 0x3
255266
256267 uint8_t sao_band_position[3];
257 int8_t saoOffsetVal[3][4]; // index with [][idx-1] as saoOffsetVal[][0]==0 always
268 int8_t saoOffsetVal[3][4]; // index with [][idx-1] as saoOffsetVal[][0]==0 always
258269 } sao_info;
259270
260271
261272
262273
263 de265_error read_slice_segment_data(struct thread_context* tctx);
274 de265_error read_slice_segment_data(thread_context* tctx);
264275
265276 bool alloc_and_init_significant_coeff_ctxIdx_lookupTable();
266277 void free_significant_coeff_ctxIdx_lookupTable();
270281 {
271282 public:
272283 bool firstSliceSubstream;
273 struct thread_context* tctx;
284 int debug_startCtbRow;
285 thread_context* tctx;
274286
275287 virtual void work();
288 virtual std::string name() const;
276289 };
277290
278291 class thread_task_slice_segment : public thread_task
279292 {
280293 public:
281294 bool firstSliceSubstream;
282 struct thread_context* tctx;
295 int debug_startCtbX, debug_startCtbY;
296 thread_context* tctx;
283297
284298 virtual void work();
299 virtual std::string name() const;
285300 };
286301
302
303 int check_CTB_available(const de265_image* img,
304 int xC,int yC, int xN,int yN);
305
287306 #endif
2828
2929 #define READ_VLC_OFFSET(variable, vlctype, offset) \
3030 if ((vlc = get_ ## vlctype(br)) == UVLC_ERROR) { \
31 ctx->add_warning(DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE, false); \
31 errqueue->add_warning(DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE, false); \
3232 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE; \
3333 } \
3434 variable = vlc + offset;
4545
4646
4747 // TODO: should be in some header-file of refpic.c
48 extern bool read_short_term_ref_pic_set(decoder_context* ctx,
48 extern bool read_short_term_ref_pic_set(error_queue* errqueue,
4949 const seq_parameter_set* sps,
5050 bitreader* br,
5151 ref_pic_set* out_set,
5353 const std::vector<ref_pic_set>& sets,
5454 bool sliceRefPicSet);
5555
56 extern bool write_short_term_ref_pic_set(error_queue* errqueue,
57 const seq_parameter_set* sps,
58 CABAC_encoder& out,
59 const ref_pic_set* in_set, // which set to write
60 int idxRps, // index of the set to be read
61 const std::vector<ref_pic_set>& sets, // previously read sets
62 bool sliceRefPicSet); // is this in the slice header?
63
64
65 sps_range_extension::sps_range_extension()
66 {
67 transform_skip_rotation_enabled_flag = 0;
68 transform_skip_context_enabled_flag = 0;
69 implicit_rdpcm_enabled_flag = 0;
70 explicit_rdpcm_enabled_flag = 0;
71 extended_precision_processing_flag = 0;
72 intra_smoothing_disabled_flag = 0;
73 high_precision_offsets_enabled_flag = 0;
74 persistent_rice_adaptation_enabled_flag = 0;
75 cabac_bypass_alignment_enabled_flag = 0;
76 }
77
78
5679 seq_parameter_set::seq_parameter_set()
5780 {
5881 // TODO: this is dangerous
6992 }
7093
7194
72 de265_error seq_parameter_set::read(decoder_context* ctx, bitreader* br)
95 void seq_parameter_set::set_defaults(enum PresetSet)
96 {
97 video_parameter_set_id = 0;
98 sps_max_sub_layers = 1;
99 sps_temporal_id_nesting_flag = 1;
100
101 profile_tier_level_.general.set_defaults(Profile_Main, 6,2); // TODO
102
103 seq_parameter_set_id = 0;
104 chroma_format_idc = 1;
105 ChromaArrayType = chroma_format_idc;
106
107 separate_colour_plane_flag = 0;
108 pic_width_in_luma_samples = 0;
109 pic_height_in_luma_samples = 0;
110 conformance_window_flag = 0;
111
112 conf_win_left_offset = 0;
113 conf_win_right_offset = 0;
114 conf_win_top_offset = 0;
115 conf_win_bottom_offset = 0;
116
117 bit_depth_luma =8;
118 bit_depth_chroma=8;
119
120 log2_max_pic_order_cnt_lsb = 8;
121 sps_sub_layer_ordering_info_present_flag = 0;
122
123 sps_max_dec_pic_buffering[0] = 1;
124 sps_max_num_reorder_pics[0] = 0;
125 sps_max_latency_increase_plus1[0] = 0;
126
127 set_CB_log2size_range(4,4);
128 set_TB_log2size_range(3,4);
129 max_transform_hierarchy_depth_inter = 1;
130 max_transform_hierarchy_depth_intra = 1;
131
132 scaling_list_enable_flag = 0;
133 sps_scaling_list_data_present_flag = 0;
134
135 // TODO struct scaling_list_data scaling_list;
136
137 amp_enabled_flag = 0;
138 sample_adaptive_offset_enabled_flag = 0;
139 pcm_enabled_flag = 0;
140
141 pcm_sample_bit_depth_luma = 8;
142 pcm_sample_bit_depth_chroma = 8;
143 // TODO log2_min_pcm_luma_coding_block_size;
144 // TODO log2_diff_max_min_pcm_luma_coding_block_size;
145 pcm_loop_filter_disable_flag = 1;
146
147 // num_short_term_ref_pic_sets = 0;
148 // std::vector<ref_pic_set> ref_pic_sets; // [0 ; num_short_term_ref_pic_set (<=MAX_REF_PIC_SETS) )
149 ref_pic_sets.clear();
150
151 long_term_ref_pics_present_flag = 0;
152
153 num_long_term_ref_pics_sps = 0;
154
155 /* TODO
156 int lt_ref_pic_poc_lsb_sps[MAX_NUM_LT_REF_PICS_SPS];
157 char used_by_curr_pic_lt_sps_flag[MAX_NUM_LT_REF_PICS_SPS];
158 */
159
160 sps_temporal_mvp_enabled_flag = 0;
161 strong_intra_smoothing_enable_flag = 0;
162 vui_parameters_present_flag = 0;
163
164 /*
165 if( vui_parameters_present_flag )
166 vui_parameters()
167 */
168
169 sps_extension_present_flag = 0;
170 sps_range_extension_flag = 0;
171 sps_multilayer_extension_flag = 0;
172 sps_extension_6bits = 0;
173 }
174
175
176 void seq_parameter_set::set_CB_log2size_range(int mini,int maxi)
177 {
178 log2_min_luma_coding_block_size = mini;
179 log2_diff_max_min_luma_coding_block_size = maxi-mini;
180 }
181
182
183 void seq_parameter_set::set_TB_log2size_range(int mini,int maxi)
184 {
185 log2_min_transform_block_size = mini;
186 log2_diff_max_min_transform_block_size = maxi-mini;
187 }
188
189
190 void seq_parameter_set::set_resolution(int w,int h)
191 {
192 pic_width_in_luma_samples = w;
193 pic_height_in_luma_samples = h;
194 }
195
196
197 de265_error seq_parameter_set::read(error_queue* errqueue, bitreader* br)
73198 {
74199 int vlc;
75200
81206
82207 sps_temporal_id_nesting_flag = get_bits(br,1);
83208
84 read_profile_tier_level(br,&profile_tier_level, sps_max_sub_layers);
209 profile_tier_level_.read(br, sps_max_sub_layers);
85210
86211 READ_VLC(seq_parameter_set_id, uvlc);
212 if (seq_parameter_set_id >= DE265_MAX_SPS_SETS) {
213 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
214 }
87215
88216
89217 // --- decode chroma type ---
106234
107235 if (chroma_format_idc<0 ||
108236 chroma_format_idc>3) {
109 ctx->add_warning(DE265_WARNING_INVALID_CHROMA_FORMAT, false);
110 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
111 }
112
113 SubWidthC = SubWidthC_tab [chroma_format_idc];
114 SubHeightC = SubHeightC_tab[chroma_format_idc];
237 errqueue->add_warning(DE265_WARNING_INVALID_CHROMA_FORMAT, false);
238 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
239 }
115240
116241
117242 // --- picture size ---
118243
119244 READ_VLC(pic_width_in_luma_samples, uvlc);
120245 READ_VLC(pic_height_in_luma_samples, uvlc);
246
247 if (pic_width_in_luma_samples == 0 ||
248 pic_height_in_luma_samples == 0) {
249 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
250 }
251
252 if (pic_width_in_luma_samples > MAX_PICTURE_WIDTH ||
253 pic_height_in_luma_samples> MAX_PICTURE_HEIGHT) {
254 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
255 }
121256
122257 conformance_window_flag = get_bits(br,1);
123258
134269 conf_win_bottom_offset= 0;
135270 }
136271
137 if (ChromaArrayType==0) {
138 WinUnitX = 1;
139 WinUnitY = 1;
140 }
141 else {
142 WinUnitX = SubWidthC_tab [chroma_format_idc];
143 WinUnitY = SubHeightC_tab[chroma_format_idc];
144 }
145
146
147272 READ_VLC_OFFSET(bit_depth_luma, uvlc, 8);
148273 READ_VLC_OFFSET(bit_depth_chroma,uvlc, 8);
149274
165290 vlc=get_uvlc(br);
166291 if (vlc == UVLC_ERROR ||
167292 vlc+1 > MAX_NUM_REF_PICS) {
168 ctx->add_warning(DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE, false);
293 errqueue->add_warning(DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE, false);
169294 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
170295 }
171296
204329 READ_VLC(log2_diff_max_min_transform_block_size, uvlc);
205330 READ_VLC(max_transform_hierarchy_depth_inter, uvlc);
206331 READ_VLC(max_transform_hierarchy_depth_intra, uvlc);
332
333 if (log2_min_luma_coding_block_size > 6) { return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE; }
334 if (log2_min_luma_coding_block_size + log2_diff_max_min_luma_coding_block_size > 6) { return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE; }
335 if (log2_min_transform_block_size > 5) { return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE; }
336 if (log2_min_transform_block_size + log2_diff_max_min_transform_block_size > 5) { return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE; }
337
207338 scaling_list_enable_flag = get_bits(br,1);
208339
209340 if (scaling_list_enable_flag) {
239370 pcm_loop_filter_disable_flag = 0;
240371 }
241372
373 int num_short_term_ref_pic_sets;
242374 READ_VLC(num_short_term_ref_pic_sets, uvlc);
243375 if (num_short_term_ref_pic_sets < 0 ||
244376 num_short_term_ref_pic_sets > 64) {
245 ctx->add_warning(DE265_WARNING_NUMBER_OF_SHORT_TERM_REF_PIC_SETS_OUT_OF_RANGE, false);
377 errqueue->add_warning(DE265_WARNING_NUMBER_OF_SHORT_TERM_REF_PIC_SETS_OUT_OF_RANGE, false);
246378 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
247379 }
248380
254386
255387 for (int i = 0; i < num_short_term_ref_pic_sets; i++) {
256388
257 bool success = read_short_term_ref_pic_set(ctx,this,br,
389 bool success = read_short_term_ref_pic_set(errqueue,this,br,
258390 &ref_pic_sets[i], i,
259391 ref_pic_sets,
260392 false);
286418
287419 sps_temporal_mvp_enabled_flag = get_bits(br,1);
288420 strong_intra_smoothing_enable_flag = get_bits(br,1);
421
289422 vui_parameters_present_flag = get_bits(br,1);
290
291 #if 0
292423 if (vui_parameters_present_flag) {
293 assert(false);
294 /*
295 vui_parameters()
296
297 sps_extension_flag
298 u(1)
299 if( sps_extension_flag )
300
301 while( more_rbsp_data() )
302
303 sps_extension_data_flag
304 u(1)
305 rbsp_trailing_bits()
306 */
307 }
308
424 vui.read(errqueue, br, this);
425 }
426
427
428 sps_extension_present_flag = get_bits(br,1);
429 if (sps_extension_present_flag) {
430 sps_range_extension_flag = get_bits(br,1);
431 sps_multilayer_extension_flag = get_bits(br,1);
432 sps_extension_6bits = get_bits(br,6);
433 }
434 else {
435 sps_range_extension_flag = 0;
436 }
437
438 if (sps_range_extension_flag) {
439 de265_error err = range_extension.read(errqueue, br);
440 if (err != DE265_OK) { return err; }
441 }
442
443 /*
309444 sps_extension_flag = get_bits(br,1);
310445 if (sps_extension_flag) {
311446 assert(false);
312447 }
313
314 check_rbsp_trailing_bits(br);
315 #endif
316
448 */
449
450
451 de265_error err = compute_derived_values();
452 if (err != DE265_OK) { return err; }
453
454 sps_read = true;
455
456 return DE265_OK;
457 }
458
459
460 de265_error seq_parameter_set::compute_derived_values()
461 {
317462 // --- compute derived values ---
463
464 SubWidthC = SubWidthC_tab [chroma_format_idc];
465 SubHeightC = SubHeightC_tab[chroma_format_idc];
466
467 if (ChromaArrayType==0) {
468 WinUnitX = 1;
469 WinUnitY = 1;
470 }
471 else {
472 WinUnitX = SubWidthC_tab [chroma_format_idc];
473 WinUnitY = SubHeightC_tab[chroma_format_idc];
474 }
475
476
318477
319478 BitDepth_Y = bit_depth_luma;
320479 QpBdOffset_Y = 6*(bit_depth_luma-8);
325484 Log2CtbSizeY = Log2MinCbSizeY + log2_diff_max_min_luma_coding_block_size;
326485 MinCbSizeY = 1 << Log2MinCbSizeY;
327486 CtbSizeY = 1 << Log2CtbSizeY;
328 PicWidthInMinCbsY = pic_width_in_luma_samples / MinCbSizeY;
487
488 PicWidthInMinCbsY = ceil_div(pic_width_in_luma_samples, MinCbSizeY);
329489 PicWidthInCtbsY = ceil_div(pic_width_in_luma_samples, CtbSizeY);
330 PicHeightInMinCbsY = pic_height_in_luma_samples / MinCbSizeY;
490 PicHeightInMinCbsY = ceil_div(pic_height_in_luma_samples, MinCbSizeY);
331491 PicHeightInCtbsY = ceil_div(pic_height_in_luma_samples,CtbSizeY);
332492 PicSizeInMinCbsY = PicWidthInMinCbsY * PicHeightInMinCbsY;
333493 PicSizeInCtbsY = PicWidthInCtbsY * PicHeightInCtbsY;
345505 Log2MinTrafoSize = log2_min_transform_block_size;
346506 Log2MaxTrafoSize = log2_min_transform_block_size + log2_diff_max_min_transform_block_size;
347507
508 if (max_transform_hierarchy_depth_inter > Log2CtbSizeY - Log2MinTrafoSize) { return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE; }
509 if (max_transform_hierarchy_depth_intra > Log2CtbSizeY - Log2MinTrafoSize) { return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE; }
510
348511 Log2MinPUSize = Log2MinCbSizeY-1;
349512 PicWidthInMinPUs = PicWidthInCtbsY << (Log2CtbSizeY - Log2MinPUSize);
350513 PicHeightInMinPUs = PicHeightInCtbsY << (Log2CtbSizeY - Log2MinPUSize);
358521 PicHeightInTbsY = PicHeightInCtbsY << (Log2CtbSizeY - Log2MinTrafoSize);
359522 PicSizeInTbsY = PicWidthInTbsY * PicHeightInTbsY;
360523
524
525 if (range_extension.high_precision_offsets_enabled_flag) {
526 WpOffsetBdShiftY = 0;
527 WpOffsetBdShiftC = 0;
528 WpOffsetHalfRangeY = 1 << (BitDepth_Y - 1);
529 WpOffsetHalfRangeC = 1 << (BitDepth_C - 1);
530 }
531 else {
532 WpOffsetBdShiftY = ( BitDepth_Y - 8 );
533 WpOffsetBdShiftC = ( BitDepth_C - 8 );
534 WpOffsetHalfRangeY = 1 << 7;
535 WpOffsetHalfRangeC = 1 << 7;
536 }
537
538
539 // --- check SPS sanity ---
540
541 if (pic_width_in_luma_samples % MinCbSizeY != 0 ||
542 pic_height_in_luma_samples % MinCbSizeY != 0) {
543 // TODO: warn that image size is coded wrong in bitstream (must be multiple of MinCbSizeY)
544 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
545 }
546
547 if (Log2MinTrafoSize > Log2MinCbSizeY) {
548 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
549 }
550
551 if (Log2MaxTrafoSize > libde265_min(Log2CtbSizeY,5)) {
552 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
553 }
554
555
556 if (BitDepth_Y < 8 || BitDepth_Y > 16) {
557 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
558 }
559
560 if (BitDepth_C < 8 || BitDepth_C > 16) {
561 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
562 }
563
564
361565 sps_read = true;
362566
363567 return DE265_OK;
365569
366570
367571
368 void seq_parameter_set::dump_sps(int fd) const
572 void seq_parameter_set::dump(int fd) const
369573 {
370574 //#if (_MSC_VER >= 1500)
371575 //#define LOG0(t) loginfo(LogHeaders, t)
389593 LOG1("sps_max_sub_layers : %d\n", sps_max_sub_layers);
390594 LOG1("sps_temporal_id_nesting_flag : %d\n", sps_temporal_id_nesting_flag);
391595
392 dump_profile_tier_level(&profile_tier_level, sps_max_sub_layers, fh);
596 profile_tier_level_.dump(sps_max_sub_layers, fh);
393597
394598 LOG1("seq_parameter_set_id : %d\n", seq_parameter_set_id);
395599 LOG2("chroma_format_idc : %d (%s)\n", chroma_format_idc,
600 chroma_format_idc == 0 ? "monochrome" :
396601 chroma_format_idc == 1 ? "4:2:0" :
397602 chroma_format_idc == 2 ? "4:2:2" :
398603 chroma_format_idc == 3 ? "4:4:4" : "unknown");
459664 LOG1("pcm_loop_filter_disable_flag : %d\n", pcm_loop_filter_disable_flag);
460665 }
461666
462 LOG1("num_short_term_ref_pic_sets : %d\n", num_short_term_ref_pic_sets);
463
464 for (int i = 0; i < num_short_term_ref_pic_sets; i++) {
667 LOG1("num_short_term_ref_pic_sets : %d\n", ref_pic_sets.size());
668
669 for (int i = 0; i < ref_pic_sets.size(); i++) {
465670 LOG1("ref_pic_set[ %2d ]: ",i);
466671 dump_compact_short_term_ref_pic_set(&ref_pic_sets[i], 16, fh);
467672 }
481686 LOG1("sps_temporal_mvp_enabled_flag : %d\n", sps_temporal_mvp_enabled_flag);
482687 LOG1("strong_intra_smoothing_enable_flag : %d\n", strong_intra_smoothing_enable_flag);
483688 LOG1("vui_parameters_present_flag : %d\n", vui_parameters_present_flag);
689
690 LOG1("sps_extension_present_flag : %d\n", sps_extension_present_flag);
691 LOG1("sps_range_extension_flag : %d\n", sps_range_extension_flag);
692 LOG1("sps_multilayer_extension_flag : %d\n", sps_multilayer_extension_flag);
693 LOG1("sps_extension_6bits : %d\n", sps_extension_6bits);
484694
485695 LOG1("CtbSizeY : %d\n", CtbSizeY);
486696 LOG1("MinCbSizeY : %d\n", MinCbSizeY);
488698 LOG1("MinTBSizeY : %d\n", 1<<log2_min_transform_block_size);
489699 LOG1("MaxTBSizeY : %d\n", 1<<(log2_min_transform_block_size + log2_diff_max_min_transform_block_size));
490700
701 LOG1("PicWidthInCtbsY : %d\n", PicWidthInCtbsY);
702 LOG1("PicHeightInCtbsY : %d\n", PicHeightInCtbsY);
491703 LOG1("SubWidthC : %d\n", SubWidthC);
492704 LOG1("SubHeightC : %d\n", SubHeightC);
493705
494 return;
706 if (sps_range_extension_flag) {
707 range_extension.dump(fd);
708 }
495709
496710 if (vui_parameters_present_flag) {
497 assert(false);
498 /*
499 vui_parameters()
500
501 sps_extension_flag
502 u(1)
503 if( sps_extension_flag )
504
505 while( more_rbsp_data() )
506
507 sps_extension_data_flag
508 u(1)
509 rbsp_trailing_bits()
510 */
711 vui.dump(fd);
511712 }
512713 #undef LOG0
513714 #undef LOG1
645846 char scaling_list_pred_mode_flag = get_bits(br,1);
646847 if (!scaling_list_pred_mode_flag) {
647848 int scaling_list_pred_matrix_id_delta = get_uvlc(br);
648 if (scaling_list_pred_matrix_id_delta < 0 ||
849 if (scaling_list_pred_matrix_id_delta == UVLC_ERROR ||
649850 scaling_list_pred_matrix_id_delta > matrixId) {
650851 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
651852 }
742943 }
743944
744945
946 de265_error write_scaling_list(CABAC_encoder& out, const seq_parameter_set* sps,
947 scaling_list_data* sclist, bool inPPS)
948 {
949 assert(false);
950 // TODO
951
952 return DE265_OK;
953 }
954
955
745956 void set_default_scaling_lists(scaling_list_data* sclist)
746957 {
747958 // 4x4
777988 default_ScalingList_8x8_inter, 3);
778989 }
779990
991
992 de265_error seq_parameter_set::write(error_queue* errqueue, CABAC_encoder& out)
993 {
994 out.write_bits(video_parameter_set_id, 4);
995 if (sps_max_sub_layers>7) {
996 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
997 }
998 out.write_bits(sps_max_sub_layers-1, 3);
999
1000 out.write_bit(sps_temporal_id_nesting_flag);
1001
1002 profile_tier_level_.write(out, sps_max_sub_layers);
1003
1004 out.write_uvlc(seq_parameter_set_id);
1005
1006
1007 // --- encode chroma type ---
1008
1009 out.write_uvlc(chroma_format_idc);
1010
1011 if (chroma_format_idc<0 ||
1012 chroma_format_idc>3) {
1013 errqueue->add_warning(DE265_WARNING_INVALID_CHROMA_FORMAT, false);
1014 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
1015 }
1016
1017 if (chroma_format_idc == 3) {
1018 out.write_bit(separate_colour_plane_flag);
1019 }
1020
1021
1022 // --- picture size ---
1023
1024 out.write_uvlc(pic_width_in_luma_samples);
1025 out.write_uvlc(pic_height_in_luma_samples);
1026
1027 out.write_bit(conformance_window_flag);
1028
1029 if (conformance_window_flag) {
1030 out.write_uvlc(conf_win_left_offset);
1031 out.write_uvlc(conf_win_right_offset);
1032 out.write_uvlc(conf_win_top_offset);
1033 out.write_uvlc(conf_win_bottom_offset);
1034 }
1035
1036
1037 out.write_uvlc(bit_depth_luma-8);
1038 out.write_uvlc(bit_depth_chroma-8);
1039
1040 out.write_uvlc(log2_max_pic_order_cnt_lsb-4);
1041
1042
1043 // --- sub_layer_ordering_info ---
1044
1045 out.write_bit(sps_sub_layer_ordering_info_present_flag);
1046
1047 int firstLayer = (sps_sub_layer_ordering_info_present_flag ?
1048 0 : sps_max_sub_layers-1 );
1049
1050 for (int i=firstLayer ; i <= sps_max_sub_layers-1; i++ ) {
1051
1052 // sps_max_dec_pic_buffering[i]
1053
1054 if (sps_max_dec_pic_buffering[i] > MAX_NUM_REF_PICS) {
1055 errqueue->add_warning(DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE, false);
1056 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
1057 }
1058
1059 out.write_uvlc(sps_max_dec_pic_buffering[i]-1);
1060
1061 // sps_max_num_reorder_pics[i]
1062
1063 out.write_uvlc(sps_max_num_reorder_pics[i]);
1064
1065
1066 // sps_max_latency_increase[i]
1067
1068 out.write_uvlc(sps_max_latency_increase_plus1[i]);
1069 }
1070
1071
1072 out.write_uvlc(log2_min_luma_coding_block_size-3);
1073 out.write_uvlc(log2_diff_max_min_luma_coding_block_size);
1074 out.write_uvlc(log2_min_transform_block_size-2);
1075 out.write_uvlc(log2_diff_max_min_transform_block_size);
1076 out.write_uvlc(max_transform_hierarchy_depth_inter);
1077 out.write_uvlc(max_transform_hierarchy_depth_intra);
1078 out.write_bit(scaling_list_enable_flag);
1079
1080 if (scaling_list_enable_flag) {
1081
1082 out.write_bit(sps_scaling_list_data_present_flag);
1083 if (sps_scaling_list_data_present_flag) {
1084
1085 de265_error err;
1086 if ((err=write_scaling_list(out,this, &scaling_list, false)) != DE265_OK) {
1087 return err;
1088 }
1089 }
1090 }
1091
1092 out.write_bit(amp_enabled_flag);
1093 out.write_bit(sample_adaptive_offset_enabled_flag);
1094 out.write_bit(pcm_enabled_flag);
1095 if (pcm_enabled_flag) {
1096 out.write_bits(pcm_sample_bit_depth_luma -1,4);
1097 out.write_bits(pcm_sample_bit_depth_chroma-1,4);
1098 out.write_uvlc(log2_min_pcm_luma_coding_block_size-3);
1099 out.write_uvlc(log2_diff_max_min_pcm_luma_coding_block_size);
1100 out.write_bit(pcm_loop_filter_disable_flag);
1101 }
1102
1103 int num_short_term_ref_pic_sets = ref_pic_sets.size();
1104 if (num_short_term_ref_pic_sets < 0 ||
1105 num_short_term_ref_pic_sets > 64) {
1106 errqueue->add_warning(DE265_WARNING_NUMBER_OF_SHORT_TERM_REF_PIC_SETS_OUT_OF_RANGE, false);
1107 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
1108 }
1109 out.write_uvlc(num_short_term_ref_pic_sets);
1110
1111 // --- allocate reference pic set ---
1112
1113 // we do not allocate the ref-pic-set for the slice header here, but in the slice header itself
1114
1115 for (int i = 0; i < num_short_term_ref_pic_sets; i++) {
1116
1117 bool success = write_short_term_ref_pic_set(errqueue,this,out,
1118 &ref_pic_sets[i], i,
1119 ref_pic_sets,
1120 false);
1121
1122 if (!success) {
1123 return DE265_WARNING_SPS_HEADER_INVALID;
1124 }
1125
1126 // dump_short_term_ref_pic_set(&(*ref_pic_sets)[i], fh);
1127 }
1128
1129 out.write_bit(long_term_ref_pics_present_flag);
1130
1131 if (long_term_ref_pics_present_flag) {
1132
1133 if (num_long_term_ref_pics_sps > MAX_NUM_LT_REF_PICS_SPS) {
1134 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
1135 }
1136 out.write_uvlc(num_long_term_ref_pics_sps);
1137
1138 for (int i = 0; i < num_long_term_ref_pics_sps; i++ ) {
1139 out.write_bits(lt_ref_pic_poc_lsb_sps[i], log2_max_pic_order_cnt_lsb);
1140 out.write_bit (used_by_curr_pic_lt_sps_flag[i]);
1141 }
1142 }
1143
1144 out.write_bit(sps_temporal_mvp_enabled_flag);
1145 out.write_bit(strong_intra_smoothing_enable_flag);
1146 out.write_bit(vui_parameters_present_flag);
1147
1148 #if 0
1149 if (vui_parameters_present_flag) {
1150 assert(false);
1151 /*
1152 vui_parameters()
1153 sps_extension_flag
1154 u(1)
1155 if( sps_extension_flag )
1156 while( more_rbsp_data() )
1157 sps_extension_data_flag
1158 u(1)
1159 rbsp_trailing_bits()
1160 */
1161 }
1162 #endif
1163
1164 out.write_bit(sps_extension_present_flag);
1165
1166 #if 0
1167 if (sps_extension_flag) {
1168 assert(false);
1169 }
1170 check_rbsp_trailing_bits(br);
1171 #endif
1172
1173 // --- compute derived values ---
1174
1175 #if 0
1176 BitDepth_Y = bit_depth_luma;
1177 QpBdOffset_Y = 6*(bit_depth_luma-8);
1178 BitDepth_C = bit_depth_chroma;
1179 QpBdOffset_C = 6*(bit_depth_chroma-8);
1180 Log2MinCbSizeY = log2_min_luma_coding_block_size;
1181 Log2CtbSizeY = Log2MinCbSizeY + log2_diff_max_min_luma_coding_block_size;
1182 MinCbSizeY = 1 << Log2MinCbSizeY;
1183 CtbSizeY = 1 << Log2CtbSizeY;
1184 PicWidthInMinCbsY = pic_width_in_luma_samples / MinCbSizeY;
1185 PicWidthInCtbsY = ceil_div(pic_width_in_luma_samples, CtbSizeY);
1186 PicHeightInMinCbsY = pic_height_in_luma_samples / MinCbSizeY;
1187 PicHeightInCtbsY = ceil_div(pic_height_in_luma_samples,CtbSizeY);
1188 PicSizeInMinCbsY = PicWidthInMinCbsY * PicHeightInMinCbsY;
1189 PicSizeInCtbsY = PicWidthInCtbsY * PicHeightInCtbsY;
1190 PicSizeInSamplesY = pic_width_in_luma_samples * pic_height_in_luma_samples;
1191 if (chroma_format_idc==0 || separate_colour_plane_flag) {
1192 CtbWidthC = 0;
1193 CtbHeightC = 0;
1194 }
1195 else {
1196 CtbWidthC = CtbSizeY / SubWidthC;
1197 CtbHeightC = CtbSizeY / SubHeightC;
1198 }
1199 Log2MinTrafoSize = log2_min_transform_block_size;
1200 Log2MaxTrafoSize = log2_min_transform_block_size + log2_diff_max_min_transform_block_size;
1201 Log2MinPUSize = Log2MinCbSizeY-1;
1202 PicWidthInMinPUs = PicWidthInCtbsY << (Log2CtbSizeY - Log2MinPUSize);
1203 PicHeightInMinPUs = PicHeightInCtbsY << (Log2CtbSizeY - Log2MinPUSize);
1204 Log2MinIpcmCbSizeY = log2_min_pcm_luma_coding_block_size;
1205 Log2MaxIpcmCbSizeY = (log2_min_pcm_luma_coding_block_size +
1206 log2_diff_max_min_pcm_luma_coding_block_size);
1207 // the following are not in the standard
1208 PicWidthInTbsY = PicWidthInCtbsY << (Log2CtbSizeY - Log2MinTrafoSize);
1209 PicHeightInTbsY = PicHeightInCtbsY << (Log2CtbSizeY - Log2MinTrafoSize);
1210 PicSizeInTbsY = PicWidthInTbsY * PicHeightInTbsY;
1211 sps_read = true;
1212 #endif
1213
1214 return DE265_OK;
1215 }
1216
1217
1218 de265_error sps_range_extension::read(error_queue* errqueue, bitreader* br)
1219 {
1220 transform_skip_rotation_enabled_flag = get_bits(br,1);
1221 transform_skip_context_enabled_flag = get_bits(br,1);
1222 implicit_rdpcm_enabled_flag = get_bits(br,1);
1223 explicit_rdpcm_enabled_flag = get_bits(br,1);
1224 extended_precision_processing_flag = get_bits(br,1);
1225 intra_smoothing_disabled_flag = get_bits(br,1);
1226 high_precision_offsets_enabled_flag = get_bits(br,1);
1227 persistent_rice_adaptation_enabled_flag = get_bits(br,1);
1228 cabac_bypass_alignment_enabled_flag = get_bits(br,1);
1229
1230 return DE265_OK;
1231 }
1232
1233
1234 #define LOG0(t) log2fh(fh, t)
1235 #define LOG1(t,d) log2fh(fh, t,d)
1236 void sps_range_extension::dump(int fd) const
1237 {
1238 FILE* fh;
1239 if (fd==1) fh=stdout;
1240 else if (fd==2) fh=stderr;
1241 else { return; }
1242
1243 LOG0("----------------- SPS-range-extension -----------------\n");
1244 LOG1("transform_skip_rotation_enabled_flag : %d\n", transform_skip_rotation_enabled_flag);
1245 LOG1("transform_skip_context_enabled_flag : %d\n", transform_skip_context_enabled_flag);
1246 LOG1("implicit_rdpcm_enabled_flag : %d\n", implicit_rdpcm_enabled_flag);
1247 LOG1("explicit_rdpcm_enabled_flag : %d\n", explicit_rdpcm_enabled_flag);
1248 LOG1("extended_precision_processing_flag : %d\n", extended_precision_processing_flag);
1249 LOG1("intra_smoothing_disabled_flag : %d\n", intra_smoothing_disabled_flag);
1250 LOG1("high_precision_offsets_enabled_flag : %d\n", high_precision_offsets_enabled_flag);
1251 LOG1("persistent_rice_adaptation_enabled_flag : %d\n", persistent_rice_adaptation_enabled_flag);
1252 LOG1("cabac_bypass_alignment_enabled_flag : %d\n", cabac_bypass_alignment_enabled_flag);
1253 }
1254 #undef LOG1
1255 #undef LOG0
2121 #define DE265_SPS_H
2222
2323 #include "libde265/vps.h"
24 #include "libde265/vui.h"
2425 #include "libde265/bitstream.h"
2526 #include "libde265/refpic.h"
2627 #include "libde265/de265.h"
28 #include "libde265/cabac.h"
2729
2830 #include <vector>
2931
30 #define MAX_REF_PIC_SETS 64 // maximum according to standard
32 class error_queue;
33
34 // #define MAX_REF_PIC_SETS 64 // maximum according to standard
3135 #define MAX_NUM_LT_REF_PICS_SPS 32
3236
37 // this is just a safety range
38 #define MAX_PICTURE_WIDTH 70000
39 #define MAX_PICTURE_HEIGHT 70000
3340
3441 enum {
3542 CHROMA_MONO = 0,
5057 } scaling_list_data;
5158
5259
53 struct seq_parameter_set {
60 enum PresetSet {
61 Preset_Default
62 };
63
64
65 class sps_range_extension
66 {
67 public:
68 sps_range_extension();
69
70 uint8_t transform_skip_rotation_enabled_flag;
71 uint8_t transform_skip_context_enabled_flag;
72 uint8_t implicit_rdpcm_enabled_flag;
73 uint8_t explicit_rdpcm_enabled_flag;
74 uint8_t extended_precision_processing_flag;
75 uint8_t intra_smoothing_disabled_flag;
76 uint8_t high_precision_offsets_enabled_flag;
77 uint8_t persistent_rice_adaptation_enabled_flag;
78 uint8_t cabac_bypass_alignment_enabled_flag;
79
80 de265_error read(error_queue*, bitreader*);
81 void dump(int fd) const;
82 };
83
84
85 class seq_parameter_set {
86 public:
5487 seq_parameter_set();
5588 ~seq_parameter_set();
5689
57 de265_error read(struct decoder_context*, bitreader*);
58
59 void dump_sps(int fd) const;
90 de265_error read(error_queue*, bitreader*);
91 de265_error write(error_queue*, CABAC_encoder&);
92
93 void dump(int fd) const;
94
95 void set_defaults(enum PresetSet = Preset_Default);
96 void set_CB_log2size_range(int mini,int maxi);
97 void set_TB_log2size_range(int mini,int maxi);
98 void set_resolution(int w,int h);
6099
61100 bool sps_read; // whether the sps has been read from the bitstream
62101
63102
64103 char video_parameter_set_id;
65 char sps_max_sub_layers;
104 char sps_max_sub_layers; // [1;7]
66105 char sps_temporal_id_nesting_flag;
67106
68 struct profile_tier_level profile_tier_level;
107 profile_tier_level profile_tier_level_;
69108
70109 int seq_parameter_set_id;
71110 int chroma_format_idc;
90129 int sps_max_num_reorder_pics[7];
91130 int sps_max_latency_increase_plus1[7];
92131
93 int log2_min_luma_coding_block_size;
94 int log2_diff_max_min_luma_coding_block_size;
95 int log2_min_transform_block_size;
96 int log2_diff_max_min_transform_block_size;
132 int log2_min_luma_coding_block_size; // smallest CB size [3;6]
133 int log2_diff_max_min_luma_coding_block_size; // largest CB size
134 int log2_min_transform_block_size; // smallest TB size [2;5]
135 int log2_diff_max_min_transform_block_size; // largest TB size
97136 int max_transform_hierarchy_depth_inter;
98137 int max_transform_hierarchy_depth_intra;
99138
113152 int log2_diff_max_min_pcm_luma_coding_block_size;
114153 char pcm_loop_filter_disable_flag;
115154
116 int num_short_term_ref_pic_sets;
155 int num_short_term_ref_pic_sets() const { return ref_pic_sets.size(); }
117156 std::vector<ref_pic_set> ref_pic_sets; // [0 ; num_short_term_ref_pic_set (<=MAX_REF_PIC_SETS) )
118
119 /*
120 for( i = 0; i < num_short_term_ref_pic_sets; i++)
121 short_term_ref_pic_set(i)
122 */
123157
124158 char long_term_ref_pics_present_flag;
125159
130164
131165 char sps_temporal_mvp_enabled_flag;
132166 char strong_intra_smoothing_enable_flag;
167
133168 char vui_parameters_present_flag;
134
135 /*
136 if( vui_parameters_present_flag )
137 vui_parameters()
138 */
139
140 char sps_extension_flag;
169 video_usability_information vui;
170
171 char sps_extension_present_flag;
172 char sps_range_extension_flag;
173 char sps_multilayer_extension_flag;
174 char sps_extension_6bits;
175
176 sps_range_extension range_extension;
141177
142178 /*
143179 if( sps_extension_flag )
147183 rbsp_trailing_bits()
148184 */
149185
186
187 // --- derived values ---
188
189 de265_error compute_derived_values();
190
150191 int BitDepth_Y;
151192 int QpBdOffset_Y;
152193 int BitDepth_C;
157198 int WinUnitX, WinUnitY;
158199
159200 int MaxPicOrderCntLsb;
160
201
161202 int Log2MinCbSizeY;
162203 int Log2CtbSizeY;
163204 int MinCbSizeY;
187228 int Log2MaxIpcmCbSizeY;
188229
189230 int SpsMaxLatencyPictures[7]; // [temporal layer]
231
232 uint8_t WpOffsetBdShiftY;
233 uint8_t WpOffsetBdShiftC;
234 int32_t WpOffsetHalfRangeY;
235 int32_t WpOffsetHalfRangeC;
236
237
238 int getPUIndexRS(int pixelX,int pixelY) const {
239 return (pixelX>>Log2MinPUSize) + (pixelY>>Log2MinPUSize)*PicWidthInMinPUs;
240 }
241
242 int get_bit_depth(int cIdx) const {
243 if (cIdx==0) return BitDepth_Y;
244 else return BitDepth_C;
245 }
246
247 int get_chroma_shift_W(int cIdx) const { return cIdx ? SubWidthC -1 : 0; }
248 int get_chroma_shift_H(int cIdx) const { return cIdx ? SubHeightC-1 : 0; }
190249 };
191250
192251 de265_error read_scaling_list(bitreader*, const seq_parameter_set*, scaling_list_data*, bool inPPS);
252 de265_error write_scaling_list(CABAC_encoder& out, const seq_parameter_set* sps,
253 scaling_list_data* sclist, bool inPPS);
193254 void set_default_scaling_lists(scaling_list_data*);
194255
195256 #endif
3434 #define THREAD_RESULT void*
3535 #define THREAD_PARAM void*
3636
37 #include <stdio.h>
38
3739 int de265_thread_create(de265_thread* t, void *(*start_routine) (void *), void *arg) { return pthread_create(t,NULL,start_routine,arg); }
3840 void de265_thread_join(de265_thread t) { pthread_join(t,NULL); }
3941 void de265_thread_destroy(de265_thread* t) { }
120122 de265_mutex_unlock(&mutex);
121123 }
122124
125 void de265_progress_lock::increase_progress(int progress)
126 {
127 de265_mutex_lock(&mutex);
128
129 mProgress += progress;
130 de265_cond_broadcast(&cond, &mutex);
131
132 de265_mutex_unlock(&mutex);
133 }
134
123135 int de265_progress_lock::get_progress() const
124136 {
125137 return mProgress;
3131 #endif
3232
3333 #include <deque>
34 #include <string>
3435
3536 #ifndef _WIN32
3637 #include <pthread.h>
4243 #else // _WIN32
4344 #include <windows.h>
4445 #include "../extra/win32cond.h"
46 #if _MSC_VER > 1310
4547 #include <intrin.h>
48 #else
49 extern "C"
50 {
51 LONG __cdecl _InterlockedExchangeAdd(long volatile *Addend, LONG Value);
52 }
53 #pragma intrinsic (_InterlockedExchangeAdd)
54 #define InterlockedExchangeAdd _InterlockedExchangeAdd
55 #endif
4656
4757 typedef HANDLE de265_thread;
4858 typedef HANDLE de265_mutex;
99109
100110 void wait_for_progress(int progress);
101111 void set_progress(int progress);
112 void increase_progress(int progress);
102113 int get_progress() const;
103114 void reset(int value=0) { mProgress=value; }
104115
122133 enum { Queued, Running, Blocked, Finished } state;
123134
124135 virtual void work() = 0;
136
137 virtual std::string name() const { return "noname"; }
125138 };
126139
127140
6767 int qPY_PRED;
6868
6969 // first QG in CTB row ?
70
70
7171 int ctbLSBMask = ((1<<sps->Log2CtbSizeY)-1);
7272 bool firstInCTBRow = (xQG == 0 && ((yQG & ctbLSBMask)==0));
7373
147147
148148 tctx->qPYPrime = QPY + sps->QpBdOffset_Y;
149149
150 int qPiCb = Clip3(-sps->QpBdOffset_C,57, QPY+pps->pic_cb_qp_offset + shdr->slice_cb_qp_offset);
151 int qPiCr = Clip3(-sps->QpBdOffset_C,57, QPY+pps->pic_cr_qp_offset + shdr->slice_cr_qp_offset);
150 int qPiCb = Clip3(-sps->QpBdOffset_C,57, QPY+pps->pic_cb_qp_offset + shdr->slice_cb_qp_offset + tctx->CuQpOffsetCb);
151 int qPiCr = Clip3(-sps->QpBdOffset_C,57, QPY+pps->pic_cr_qp_offset + shdr->slice_cr_qp_offset + tctx->CuQpOffsetCr);
152152
153153 logtrace(LogTransform,"qPiCb:%d (%d %d), qPiCr:%d (%d %d)\n",
154154 qPiCb, pps->pic_cb_qp_offset, shdr->slice_cb_qp_offset,
155155 qPiCr, pps->pic_cr_qp_offset, shdr->slice_cr_qp_offset);
156156
157 int qPCb = table8_22(qPiCb);
158 int qPCr = table8_22(qPiCr);
157 int qPCb,qPCr;
158
159 if (sps->ChromaArrayType == CHROMA_420) {
160 qPCb = table8_22(qPiCb);
161 qPCr = table8_22(qPiCr);
162 }
163 else {
164 qPCb = qPiCb;
165 qPCr = qPiCr;
166 }
167
168 //printf("q: %d %d\n",qPiCb, qPCb);
159169
160170 tctx->qPCbPrime = qPCb + sps->QpBdOffset_C;
161171 tctx->qPCrPrime = qPCr + sps->QpBdOffset_C;
162172
173 /*
174 printf("Q: %d (%d %d %d / %d %d) %d %d %d\n",QPY,
175 sps->QpBdOffset_Y,
176 pps->pic_cb_qp_offset + shdr->slice_cb_qp_offset,
177 pps->pic_cr_qp_offset + shdr->slice_cr_qp_offset,
178 sps->QpBdOffset_C, sps->QpBdOffset_C,
179 tctx->qPYPrime, tctx->qPCbPrime, tctx->qPCrPrime);
180 */
181
163182 int log2CbSize = tctx->img->get_log2CbSize(xCUBase, yCUBase);
183
184 // TODO: On broken input, log2CbSize may be zero (multithreaded only). Not sure yet why.
185 // Maybe another decoding thread is overwriting the value set in slice.cc:read_coding_unit.
186 // id:000163,sig:06,src:002041,op:havoc,rep:16.bin
187 if (log2CbSize<3) { log2CbSize=3; }
188
164189 tctx->img->set_QPY(xCUBase, yCUBase, log2CbSize, QPY);
165190 tctx->currentQPY = QPY;
166191
175200
176201
177202
178 void transform_coefficients(decoder_context* ctx,
179 int16_t* coeff, int coeffStride, int nT, int trType, int postShift,
180 uint8_t* dst, int dstStride)
203 template <class pixel_t>
204 void transform_coefficients(acceleration_functions* acceleration,
205 int16_t* coeff, int coeffStride, int nT, int trType,
206 pixel_t* dst, int dstStride, int bit_depth)
181207 {
182208 logtrace(LogTransform,"transform --- trType: %d nT: %d\n",trType,nT);
183209
210
184211 if (trType==1) {
185212
186 ctx->acceleration.transform_4x4_luma_add_8(dst, coeff, dstStride);
213 acceleration->transform_4x4_dst_add<pixel_t>(dst, coeff, dstStride, bit_depth);
187214
188215 } else {
189216
190 /**/ if (nT==4) { ctx->acceleration.transform_4x4_add_8(dst,coeff,dstStride); }
191 else if (nT==8) { ctx->acceleration.transform_8x8_add_8(dst,coeff,dstStride); }
192 else if (nT==16) { ctx->acceleration.transform_16x16_add_8(dst,coeff,dstStride); }
193 else { ctx->acceleration.transform_32x32_add_8(dst,coeff,dstStride); }
194 }
195 }
217 /**/ if (nT==4) { acceleration->transform_add<pixel_t>(0,dst,coeff,dstStride, bit_depth); }
218 else if (nT==8) { acceleration->transform_add<pixel_t>(1,dst,coeff,dstStride, bit_depth); }
219 else if (nT==16) { acceleration->transform_add<pixel_t>(2,dst,coeff,dstStride, bit_depth); }
220 else { acceleration->transform_add<pixel_t>(3,dst,coeff,dstStride, bit_depth); }
221 }
222
223 #if 0
224 printf("decoded pixels:\n");
225 for (int y=0;y<nT;y++,printf("\n"))
226 for (int x=0;x<nT;x++) {
227 printf("%02x ",dst[y*dstStride+x]);
228 }
229 #endif
230 }
231
232
233 // TODO: make this an accelerated function
234 void cross_comp_pred(const thread_context* tctx, int32_t* residual, int nT)
235 {
236 const int BitDepthC = tctx->img->sps.BitDepth_C;
237 const int BitDepthY = tctx->img->sps.BitDepth_Y;
238
239 for (int y=0;y<nT;y++)
240 for (int x=0;x<nT;x++) {
241 /* TODO: the most usual case is definitely BitDepthY == BitDepthC, in which case
242 we could just omit two shifts. The second most common case is probably
243 BitDepthY>BitDepthC, for which we could also eliminate one shift. The remaining
244 case is also one shift only.
245 */
246
247 residual[y*nT+x] += (tctx->ResScaleVal *
248 ((tctx->residual_luma[y*nT+x] << BitDepthC ) >> BitDepthY ) ) >> 3;
249 }
250 }
251
252
253 template <class pixel_t>
254 void transform_coefficients_explicit(thread_context* tctx,
255 int16_t* coeff, int coeffStride, int nT, int trType,
256 pixel_t* dst, int dstStride, int bit_depth, int cIdx)
257 {
258 logtrace(LogTransform,"transform --- trType: %d nT: %d\n",trType,nT);
259
260 const acceleration_functions* acceleration = &tctx->decctx->acceleration;
261
262 int32_t residual_buffer[32*32];
263 int32_t* residual;
264 if (cIdx==0) {
265 residual = tctx->residual_luma;
266 }
267 else {
268 residual = residual_buffer;
269 }
270
271
272 // TODO
273 int bdShift = 20 - bit_depth;
274 int max_coeff_bits = 15;
275
276 if (trType==1) {
277
278 acceleration->transform_idst_4x4(residual, coeff, bdShift, max_coeff_bits);
279
280 } else {
281
282 /**/ if (nT==4) { acceleration->transform_idct_4x4(residual,coeff,bdShift,max_coeff_bits); }
283 else if (nT==8) { acceleration->transform_idct_8x8(residual,coeff,bdShift,max_coeff_bits); }
284 else if (nT==16) { acceleration->transform_idct_16x16(residual,coeff,bdShift,max_coeff_bits); }
285 else { acceleration->transform_idct_32x32(residual,coeff,bdShift,max_coeff_bits); }
286 }
287
288
289 //printBlk("prediction",(uint8_t*)dst,nT,dstStride);
290 //printBlk("residual",residual,nT,nT);
291
292 if (cIdx != 0) {
293 if (tctx->ResScaleVal != 0) {
294 cross_comp_pred(tctx, residual, nT);
295 }
296
297 //printBlk("cross-comp-pred modified residual",residual,nT,nT);
298 }
299
300 acceleration->add_residual(dst,dstStride, residual,nT, bit_depth);
301 }
302
303
304 void inv_transform(acceleration_functions* acceleration,
305 uint8_t* dst, int dstStride, int16_t* coeff,
306 int log2TbSize, int trType)
307 {
308 if (trType==1) {
309 assert(log2TbSize==2);
310
311 acceleration->transform_4x4_dst_add_8(dst, coeff, dstStride);
312
313 } else {
314 acceleration->transform_add_8[log2TbSize-2](dst,coeff,dstStride);
315 }
316
317
318 #if 0
319 int nT = 1<<log2TbSize;
320 printf("decoded pixels:\n");
321 for (int y=0;y<nT;y++,printf("\n"))
322 for (int x=0;x<nT;x++) {
323 printf("%02x ",dst[y*dstStride+x]);
324 }
325 #endif
326 }
327
328
329 void fwd_transform(acceleration_functions* acceleration,
330 int16_t* coeff, int coeffStride, int log2TbSize, int trType,
331 const int16_t* src, int srcStride)
332 {
333 logtrace(LogTransform,"transform --- trType: %d nT: %d\n",trType,1<<log2TbSize);
334
335 if (trType==1) {
336 // DST 4x4
337
338 acceleration->fwd_transform_4x4_dst_8(coeff, src, srcStride);
339 } else {
340 // DCT 4x4, 8x8, 16x16, 32x32
341
342 acceleration->fwd_transform_8[log2TbSize-2](coeff,src,srcStride);
343 }
344 }
345
196346
197347
198348 static const int levelScale[] = { 40,45,51,57,64,72 };
199349
200350 // (8.6.2) and (8.6.3)
201 void scale_coefficients(thread_context* tctx,
202 int xT,int yT, // position of TU in frame (chroma adapted)
203 int x0,int y0, // position of CU in frame (chroma adapted)
204 int nT, int cIdx,
205 bool transform_skip_flag, bool intra)
351 template <class pixel_t>
352 void scale_coefficients_internal(thread_context* tctx,
353 int xT,int yT, // position of TU in frame (chroma adapted)
354 int x0,int y0, // position of CU in frame (chroma adapted)
355 int nT, int cIdx,
356 bool transform_skip_flag, bool intra, int rdpcmMode)
206357 {
207358 seq_parameter_set* sps = &tctx->img->sps;
208359 pic_parameter_set* pps = &tctx->img->pps;
217368
218369 logtrace(LogTransform,"qP: %d\n",qP);
219370
220 //printf("residual %d;%d cIdx=%d qp=%d\n",xT * (cIdx?2:1),yT * (cIdx?2:1),cIdx,qP);
221
222371
223372 int16_t* coeff;
224373 int coeffStride;
230379
231380
232381
233 uint8_t* pred;
382 pixel_t* pred;
234383 int stride;
235 pred = tctx->img->get_image_plane_at_pos(cIdx, xT,yT);
384 pred = tctx->img->get_image_plane_at_pos_NEW<pixel_t>(cIdx, xT,yT);
236385 stride = tctx->img->get_image_stride(cIdx);
237386
238 //fprintf(stderr,"POC=%d pred: %p (%d;%d stride=%d)\n",ctx->img->PicOrderCntVal,pred,xT,yT,stride);
239
240 /*
241 int x,y;
242 for (y=0;y<nT;y++)
243 {
244 printf("P: ");
245
246 for (x=0;x<nT;x++)
247 {
248 printf("%02x ",pred[x+y*stride]);
249 }
250
251 printf("\n");
252 }
253 */
387 // We explicitly include the case for sizeof(pixel_t)==1 so that the compiler
388 // can optimize away a lot of code for 8-bit pixels.
389 const int bit_depth = ((sizeof(pixel_t)==1) ? 8 : sps->get_bit_depth(cIdx));
390
391 //assert(intra == (tctx->img->get_pred_mode(xT,yT)==MODE_INTRA));
392 int cuPredModeIntra = (tctx->img->get_pred_mode(xT,yT)==MODE_INTRA);
393
394 bool rotateCoeffs = (sps->range_extension.transform_skip_rotation_enabled_flag &&
395 nT == 4 &&
396 cuPredModeIntra);
254397
255398 if (tctx->cu_transquant_bypass_flag) {
256 //assert(false); // TODO
257
399
400 int32_t residual_buffer[32*32];
401
402 int32_t* residual;
403 if (cIdx==0) residual = tctx->residual_luma;
404 else residual = residual_buffer;
405
406
407 // TODO: we could fold the coefficient rotation into the coefficient expansion here:
258408 for (int i=0;i<tctx->nCoeff[cIdx];i++) {
259 int32_t currCoeff = tctx->coeffList[cIdx][i];
409 int32_t currCoeff = tctx->coeffList[cIdx][i];
260410 tctx->coeffBuf[ tctx->coeffPos[cIdx][i] ] = currCoeff;
261411 }
262412
263 tctx->decctx->acceleration.transform_bypass_8(pred, coeff, nT, stride);
413 if (rotateCoeffs) {
414 tctx->decctx->acceleration.rotate_coefficients(coeff, nT);
415 }
416
417 if (rdpcmMode) {
418 if (rdpcmMode==2)
419 tctx->decctx->acceleration.transform_bypass_rdpcm_v(residual, coeff, nT);
420 else
421 tctx->decctx->acceleration.transform_bypass_rdpcm_h(residual, coeff, nT);
422 }
423 else {
424 tctx->decctx->acceleration.transform_bypass(residual, coeff, nT);
425 }
426
427 if (cIdx != 0) {
428 if (tctx->ResScaleVal != 0) {
429 cross_comp_pred(tctx, residual, nT);
430 }
431 }
432
433 tctx->decctx->acceleration.add_residual(pred,stride, residual,nT, bit_depth);
434
435 if (rotateCoeffs) {
436 memset(coeff, 0, nT*nT*sizeof(int16_t)); // delete all, because we moved the coeffs around
437 }
264438 }
265439 else {
266440 // (8.6.3)
270444 logtrace(LogTransform,"bdShift=%d\n",bdShift);
271445
272446 logtrace(LogTransform,"dequant %d;%d cIdx=%d qp=%d\n",xT*(cIdx?2:1),yT*(cIdx?2:1),cIdx,qP);
447
448
449 // --- inverse quantization ---
273450
274451 if (sps->scaling_list_enable_flag==0) {
275452
285462 // usually, this needs to be 64bit, but because we modify the shift above, we can use 16 bit
286463 int32_t currCoeff = tctx->coeffList[cIdx][i];
287464
465 //logtrace(LogTransform,"coefficient[%d] = %d\n",tctx->coeffPos[cIdx][i],
466 //tctx->coeffList[cIdx][i]);
467
288468 currCoeff = Clip3(-32768,32767,
289469 ( (currCoeff * fact + offset ) >> bdShift));
470
471 //logtrace(LogTransform," -> %d\n",currCoeff);
290472
291473 tctx->coeffBuf[ tctx->coeffPos[cIdx][i] ] = currCoeff;
292474 }
326508 }
327509 }
328510
511
512 // --- do transform or skip ---
513
329514 logtrace(LogTransform,"coefficients OUT:\n");
330515 for (int y=0;y<nT;y++) {
331516 logtrace(LogTransform," ");
344529
345530 if (transform_skip_flag) {
346531
347 tctx->decctx->acceleration.transform_skip_8(pred, coeff, stride);
532 int extended_precision_processing_flag = 0;
533 int Log2nTbS = Log2(nT);
534 int bdShift = libde265_max( 20 - bit_depth, extended_precision_processing_flag ? 11 : 0 );
535 int tsShift = (extended_precision_processing_flag ? libde265_min( 5, bdShift - 2 ) : 5 )
536 + Log2nTbS;
537
538 if (rotateCoeffs) {
539 tctx->decctx->acceleration.rotate_coefficients(coeff, nT);
540 }
541
542 int32_t residual_buffer[32*32];
543
544 int32_t* residual;
545 if (cIdx==0) residual = tctx->residual_luma;
546 else residual = residual_buffer;
547
548 if (rdpcmMode) {
549 /*
550 if (rdpcmMode==2)
551 tctx->decctx->acceleration.transform_skip_rdpcm_v(pred,coeff, Log2(nT), stride, bit_depth);
552 else
553 tctx->decctx->acceleration.transform_skip_rdpcm_h(pred,coeff, Log2(nT), stride, bit_depth);
554 */
555
556 if (rdpcmMode==2)
557 tctx->decctx->acceleration.rdpcm_v(residual, coeff,nT, tsShift,bdShift);
558 else
559 tctx->decctx->acceleration.rdpcm_h(residual, coeff,nT, tsShift,bdShift);
560 }
561 else {
562 //tctx->decctx->acceleration.transform_skip(pred, coeff, stride, bit_depth);
563
564 tctx->decctx->acceleration.transform_skip_residual(residual, coeff, nT, tsShift, bdShift);
565 }
566
567 if (cIdx != 0) {
568 if (tctx->ResScaleVal != 0) {
569 cross_comp_pred(tctx, residual, nT);
570 }
571 }
572
573 tctx->decctx->acceleration.add_residual(pred,stride, residual,nT, bit_depth);
574
575 if (rotateCoeffs) {
576 memset(coeff, 0, nT*nT*sizeof(int16_t)); // delete all, because we moved the coeffs around
577 }
348578 }
349579 else {
350580 int trType;
351581
352 if (nT==4 && cIdx==0 && tctx->img->get_pred_mode(xT,yT)==MODE_INTRA) {
582 //if (nT==4 && cIdx==0 && tctx->img->get_pred_mode(xT,yT)==MODE_INTRA) {
583 if (nT==4 && cIdx==0 && cuPredModeIntra) {
353584 trType=1;
354585 }
355586 else {
356587 trType=0;
357588 }
358589
359 transform_coefficients(tctx->decctx, coeff, coeffStride, nT, trType, bdShift2,
360 pred, stride);
590 assert(rdpcmMode==0);
591
592
593 if (tctx->img->pps.range_extension.cross_component_prediction_enabled_flag) {
594 // cross-component-prediction: transform to residual buffer and add in a separate step
595
596 transform_coefficients_explicit(tctx, coeff, coeffStride, nT, trType,
597 pred, stride, bit_depth, cIdx);
598 }
599 else {
600 transform_coefficients(&tctx->decctx->acceleration, coeff, coeffStride, nT, trType,
601 pred, stride, bit_depth);
602 }
361603 }
362604 }
363605
365607 logtrace(LogTransform,"pixels (cIdx:%d), position %d %d:\n",cIdx, xT,yT);
366608
367609 for (int y=0;y<nT;y++) {
368 logtrace(LogTransform,"RECO-%d-%d-%d ",xT,yT+y,cIdx);
610 logtrace(LogTransform,"RECO-%3d-%3d-%d ",xT,yT+y,cIdx);
369611
370612 for (int x=0;x<nT;x++) {
371 logtrace(LogTransform,"*%02x ", pred[x+y*stride]);
613 logtrace(LogTransform,"*%03x ", pred[x+y*stride]);
372614 }
373615
374616 logtrace(LogTransform,"*\n");
375 }
376
377 /*
378 for (y=0;y<nT;y++)
379 {
380 printf("C: ");
381
382 for (x=0;x<nT;x++)
383 {
384 printf("%4d ",coeff[x+y*nT]);
385 }
386
387 printf("\n");
388 }
389
390 for (y=0;y<nT;y++)
391 {
392 for (x=0;x<nT;x++)
393 {
394 printf("%02x ",pred[x+y*stride]);
395 }
396
397 printf("\n");
398 }
399 */
617 }
400618
401619 // zero out scrap coefficient buffer again
402620
404622 tctx->coeffBuf[ tctx->coeffPos[cIdx][i] ] = 0;
405623 }
406624 }
625
626
627 void scale_coefficients(thread_context* tctx,
628 int xT,int yT, // position of TU in frame (chroma adapted)
629 int x0,int y0, // position of CU in frame (chroma adapted)
630 int nT, int cIdx,
631 bool transform_skip_flag, bool intra,
632 int rdpcmMode // 0 - off, 1 - Horizontal, 2 - Vertical
633 )
634 {
635 if (tctx->img->high_bit_depth(cIdx)) {
636 scale_coefficients_internal<uint16_t>(tctx, xT,yT, x0,y0, nT,cIdx, transform_skip_flag, intra,
637 rdpcmMode);
638 } else {
639 scale_coefficients_internal<uint8_t> (tctx, xT,yT, x0,y0, nT,cIdx, transform_skip_flag, intra,
640 rdpcmMode);
641 }
642 }
643
644
645 //#define QUANT_IQUANT_SHIFT 20 // Q(QP%6) * IQ(QP%6) = 2^20
646 #define QUANT_SHIFT 14 // Q(4) = 2^14
647 //#define SCALE_BITS 15 // Inherited from TMuC, pressumably for fractional bit estimates in RDOQ
648 #define MAX_TR_DYNAMIC_RANGE 15 // Maximum transform dynamic range (excluding sign bit)
649
650
651 const static uint16_t g_quantScales[6] = {
652 26214,23302,20560,18396,16384,14564
653 };
654
655 void quant_coefficients(//encoder_context* ectx,
656 int16_t* out_coeff,
657 const int16_t* in_coeff,
658 int log2TrSize, int qp,
659 bool intra)
660 {
661 const int qpDiv6 = qp / 6;
662 const int qpMod6 = qp % 6;
663
664 //int uiLog2TrSize = xLog2( iWidth - 1);
665
666 int uiQ = g_quantScales[qpMod6];
667 int bitDepth = 8;
668 int transformShift = MAX_TR_DYNAMIC_RANGE - bitDepth - log2TrSize; // Represents scaling through forward transform
669 int qBits = QUANT_SHIFT + qpDiv6 + transformShift;
670
671 /* TODO: originally, this was checking for intra slices, why not for intra mode ?
672 */
673 int rnd = (intra ? 171 : 85) << (qBits-9);
674
675 int x, y;
676 int uiAcSum = 0;
677
678 int nStride = (1<<log2TrSize);
679
680 for (y=0; y < (1<<log2TrSize) ; y++) {
681 for (x=0; x < (1<<log2TrSize) ; x++) {
682 int level;
683 int sign;
684 int blockPos = y * nStride + x;
685 level = in_coeff[blockPos];
686 //logtrace(LogTransform,"(%d,%d) %d -> ", x,y,level);
687 sign = (level < 0 ? -1: 1);
688
689 level = (abs_value(level) * uiQ + rnd ) >> qBits;
690 uiAcSum += level;
691 level *= sign;
692 out_coeff[blockPos] = Clip3(-32768, 32767, level);
693 //logtrace(LogTransform,"%d\n", out_coeff[blockPos]);
694 }
695 }
696 }
697
698
699 void dequant_coefficients(int16_t* out_coeff,
700 const int16_t* in_coeff,
701 int log2TrSize, int qP)
702 {
703 const int m_x_y = 1;
704 int bitDepth = 8;
705 int bdShift = bitDepth + log2TrSize - 5;
706 bdShift -= 4; // this is equivalent to having a m_x_y of 16 and we can use 32bit integers
707
708 const int offset = (1<<(bdShift-1));
709 const int fact = m_x_y * levelScale[qP%6] << (qP/6);
710
711 int blkSize = (1<<log2TrSize);
712 int nCoeff = (1<<(log2TrSize<<1));
713
714 for (int i=0;i<nCoeff;i++) {
715
716 // usually, this needs to be 64bit, but because we modify the shift above, we can use 16 bit
717 int32_t currCoeff = in_coeff[i];
718
719 //logtrace(LogTransform,"coefficient[%d] = %d\n",i,currCoeff);
720
721 currCoeff = Clip3(-32768,32767,
722 ( (currCoeff * fact + offset ) >> bdShift));
723
724 //logtrace(LogTransform," -> %d\n",currCoeff);
725
726 out_coeff[i] = currCoeff;
727 }
728 }
4141 int xT,int yT, // position of TU in frame (chroma adapted)
4242 int x0,int y0, // position of CU in frame (chroma adapted)
4343 int nT, int cIdx,
44 bool transform_skip_flag, bool intra);
44 bool transform_skip_flag, bool intra, int rdpcmMode);
45
46
47 void inv_transform(acceleration_functions* acceleration,
48 uint8_t* dst, int dstStride, int16_t* coeff,
49 int log2TbSize, int trType);
50
51 void fwd_transform(acceleration_functions* acceleration,
52 int16_t* coeff, int coeffStride, int log2TbSize, int trType,
53 const int16_t* src, int srcStride);
54
55 void quant_coefficients(int16_t* out_coeff,
56 const int16_t* in_coeff,
57 int log2TrSize, int qp,
58 bool intra);
59
60 void dequant_coefficients(int16_t* out_coeff,
61 const int16_t* in_coeff,
62 int log2TrSize, int qP);
4563
4664 #endif
2222
2323 #include <stdarg.h>
2424 #include <stdio.h>
25 #include <string.h>
26
27
28 void copy_subimage(uint8_t* dst,int dststride,
29 const uint8_t* src,int srcstride,
30 int w, int h)
31 {
32 for (int y=0;y<h;y++) {
33 memcpy(dst, src, w);
34 dst += dststride;
35 src += srcstride;
36 }
37 }
38
2539
2640
2741 #ifdef DE265_LOGGING
2842 static int current_poc=0;
2943 static int log_poc_start=-9999; // frame-numbers can be negative
30 static int enable_log = 1;
44 static bool disable_log[NUMBER_OF_LogModules];
3145 void log_set_current_POC(int poc) { current_poc=poc; }
3246 #endif
3347
3448
35 static int disable_logging=0;
49 static int disable_logging_OLD=0;
3650 static int verbosity = 0;
3751
52
3853 LIBDE265_API void de265_disable_logging() // DEPRECATED
3954 {
40 disable_logging=1;
41 }
55 disable_logging_OLD=1;
56 }
57
4258
4359 LIBDE265_API void de265_set_verbosity(int level)
4460 {
4662 }
4763
4864 #if defined(DE265_LOG_ERROR) || defined(DE265_LOG_INFO) || defined(DE265_LOG_DEBUG) || defined(DE265_LOG_INFO)
49 void enablelog() { enable_log=1; }
50 #endif
65 void enable_logging(enum LogModule module)
66 {
67 disable_log[module]=false;
68 }
69 void disable_logging(enum LogModule module)
70 {
71 disable_log[module]=true;
72 }
73 #endif
74
75 static long logcnt[10];
5176
5277 #ifdef DE265_LOG_ERROR
5378 void logerror(enum LogModule module, const char* string, ...)
5479 {
55 if (disable_logging) return;
56 if (current_poc < log_poc_start) { return; }
57 if (!enable_log) return;
80 if (current_poc < log_poc_start) { return; }
81 if (disable_log[module]) return;
5882
5983 va_list va;
6084
7195 void loginfo (enum LogModule module, const char* string, ...)
7296 {
7397 if (verbosity<1) return;
74 if (disable_logging) return;
75 if (current_poc < log_poc_start) { return; }
76 if (!enable_log) return;
98 if (current_poc < log_poc_start) { return; }
99 if (disable_log[module]) return;
77100
78101 va_list va;
79102
90113 void logdebug(enum LogModule module, const char* string, ...)
91114 {
92115 if (verbosity<2) return;
93 if (disable_logging) return;
94 if (current_poc < log_poc_start) { return; }
95 if (!enable_log) return;
116 if (current_poc < log_poc_start) { return; }
117 if (disable_log[module]) return;
96118
97119 va_list va;
98120
109131 void logtrace(enum LogModule module, const char* string, ...)
110132 {
111133 if (verbosity<3) return;
112 if (disable_logging) return;
113 if (current_poc < log_poc_start) { return; }
114 if (!enable_log) return;
134 if (current_poc < log_poc_start) { return; }
135 if (disable_log[module]) return;
136
137 //if (module != LogSymbols /*&& module != LogCABAC*/) { return; }
138 //if (logcnt<319500) return;
115139
116140 //if (module != LogCABAC) return;
117141
118142 va_list va;
119143
144 if (string[0]=='$') {
145 int id = string[1]-'0';
146 logcnt[id]++;
147 fprintf(stdout, "[%ld] ",logcnt[id]);
148
149 string += 3;
150 }
151
120152 int noPrefix = (string[0]=='*');
121153 if (!noPrefix) { } // fprintf(stdout, "ERR: ");
122154 va_start(va, string);
137169 va_end(va);
138170 fflush(stdout);
139171 }
172
173
174
175 void printBlk(const char* title, const int16_t* data, int blksize, int stride)
176 {
177 printf("%s:\n",title);
178
179 for (int y=0;y<blksize;y++) {
180 //logtrace(LogTransform," ");
181 printf(" ");
182 for (int x=0;x<blksize;x++) {
183 //logtrace(LogTransform,"*%3d ", data[x+y*stride]);
184 printf("%4d ", data[x+y*stride]);
185 }
186 //logtrace(LogTransform,"*\n");
187 printf("\n");
188 }
189 }
190
191
192 void printBlk(const char* title, const int32_t* data, int blksize, int stride)
193 {
194 printf("%s:\n",title);
195
196 for (int y=0;y<blksize;y++) {
197 //logtrace(LogTransform," ");
198 printf(" ");
199 for (int x=0;x<blksize;x++) {
200 //logtrace(LogTransform,"*%3d ", data[x+y*stride]);
201 printf("%4d ", data[x+y*stride]);
202 }
203 //logtrace(LogTransform,"*\n");
204 printf("\n");
205 }
206 }
207
208
209 void printBlk(const char* title, const uint8_t* data, int blksize, int stride)
210 {
211 printf("%s:\n",title);
212
213 for (int y=0;y<blksize;y++) {
214 //logtrace(LogTransform," ");
215 printf(" ");
216 for (int x=0;x<blksize;x++) {
217 //logtrace(LogTransform,"*%3d ", data[x+y*stride]);
218 printf("%02x ", data[x+y*stride]);
219 }
220 //logtrace(LogTransform,"*\n");
221 printf("\n");
222 }
223 }
224
225
226 static void (*debug_image_output_func)(const struct de265_image*, int slot) = NULL;
227
228 void debug_set_image_output(void (*func)(const struct de265_image*, int slot))
229 {
230 debug_image_output_func = func;
231 }
232
233 void debug_show_image(const struct de265_image* img, int slot)
234 {
235 if (debug_image_output_func) {
236 debug_image_output_func(img,slot);
237 }
238 }
2828
2929 #include "libde265/de265.h"
3030
31 #ifdef __GNUC__
32 #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
33 #endif
3134
3235 #ifdef _MSC_VER
3336 #define LIBDE265_DECLARE_ALIGNED( var, n ) __declspec(align(n)) var
3942 #define unlikely(x) __builtin_expect(!!(x), 0)
4043 #endif
4144
45 #if defined(__GNUC__) && (__GNUC__ >= 4)
46 #define LIBDE265_CHECK_RESULT __attribute__ ((warn_unused_result))
47 #elif defined(_MSC_VER) && (_MSC_VER >= 1700)
48 #define LIBDE265_CHECK_RESULT _Check_return_
49 #else
50 #define LIBDE265_CHECK_RESULT
51 #endif
52
4253 #define ALIGNED_32( var ) LIBDE265_DECLARE_ALIGNED( var, 32 )
4354 #define ALIGNED_16( var ) LIBDE265_DECLARE_ALIGNED( var, 16 )
4455 #define ALIGNED_8( var ) LIBDE265_DECLARE_ALIGNED( var, 8 )
4556 #define ALIGNED_4( var ) LIBDE265_DECLARE_ALIGNED( var, 4 )
4657
47
58 // C++11 specific features
59 #if defined(_MSC_VER) || (!__clang__ && __GNUC__ && GCC_VERSION < 40600)
60 #define FOR_LOOP(type, var, list) for each (type var in list)
61 #undef FOR_LOOP_AUTO_SUPPORT
62 #else
63 #define FOR_LOOP(type, var, list) for (type var : list)
64 #define FOR_LOOP_AUTO_SUPPORT 1
65 #endif
66
67 #ifdef USE_STD_TR1_NAMESPACE
68 #include <tr1/memory>
69 namespace std { using namespace std::tr1; }
70 #endif
71
72 #if __GNUC__ && GCC_VERSION < 40600
73 // nullptr was introduced in gcc 4.6, a simple alias should be fine for our use case
74 #define nullptr NULL
75 #endif
76
77 #ifdef _MSC_VER
78 #ifdef _CPPRTTI
79 #define RTTI_ENABLED
80 #endif
81 #else
82 #ifdef __GXX_RTTI
83 #define RTTI_ENABLED
84 #endif
85 #endif
4886
4987 //inline uint8_t Clip1_8bit(int16_t value) { if (value<=0) return 0; else if (value>=255) return 255; else return value; }
5088 #define Clip1_8bit(value) ((value)<0 ? 0 : (value)>255 ? 255 : (value))
89 #define Clip_BitDepth(value, bit_depth) ((value)<0 ? 0 : (value)>((1<<bit_depth)-1) ? ((1<<bit_depth)-1) : (value))
5190 #define Clip3(low,high,value) ((value)<(low) ? (low) : (value)>(high) ? (high) : (value))
5291 #define Sign(value) (((value)<0) ? -1 : ((value)>0) ? 1 : 0)
5392 #define abs_value(a) (((a)<0) ? -(a) : (a))
5998 num += denom-1;
6099 return num/denom;
61100 }
101
62102 LIBDE265_INLINE static int ceil_log2(int val)
63103 {
64104 int n=0;
68108
69109 return n;
70110 }
111
71112 LIBDE265_INLINE static int Log2(int v)
72113 {
73114 int n=0;
78119
79120 return n;
80121 }
122
123 LIBDE265_INLINE static int Log2SizeToArea(int v)
124 {
125 return (1<<(v<<1));
126 }
127
128 void copy_subimage(uint8_t* dst,int dststride,
129 const uint8_t* src,int srcstride,
130 int w, int h);
81131
82132
83133 // === logging ===
94144 LogSEI,
95145 LogIntraPred,
96146 LogPixels,
97 LogCABAC
147 LogSymbols,
148 LogCABAC,
149 LogEncoder,
150 NUMBER_OF_LogModules
98151 };
99152
100153
101154 #if defined(DE265_LOG_ERROR) || defined(DE265_LOG_INFO) || defined(DE265_LOG_DEBUG) || defined(DE265_LOG_TRACE)
102155 # define DE265_LOGGING 1
103 void enablelog();
104 #else
105 #define enablelog() { }
156 void enable_logging(enum LogModule);
157 void disable_logging(enum LogModule);
158 #else
159 #define enable_logging(x) { }
160 #define disable_logging(x) { }
106161 #endif
107162
108163 #ifdef DE265_LOGGING
137192
138193 void log2fh(FILE* fh, const char* string, ...);
139194
140 #endif
195
196 void printBlk(const char* title,const int32_t* data, int blksize, int stride);
197 void printBlk(const char* title,const int16_t* data, int blksize, int stride);
198 void printBlk(const char* title,const uint8_t* data, int blksize, int stride);
199
200 void debug_set_image_output(void (*)(const struct de265_image*, int slot));
201 void debug_show_image(const struct de265_image*, int slot);
202
203 #endif
291291 tint_rect(img,stride, x0,y0,w,h, cols[predMode], pixelSize);
292292 }
293293 else if (what == PBMotionVectors) {
294 const PredVectorInfo* mvi = srcimg->get_mv_info(x0,y0);
294 const MotionVectorSpec* mvi = srcimg->get_mv_info(x0,y0);
295295 int x = x0+w/2;
296296 int y = y0+h/2;
297297 if (mvi->predFlag[0]) {
553553 }
554554 }
555555 }
556
2424 #include <assert.h>
2525
2626
27 de265_error read_vps(decoder_context* ctx, bitreader* reader, video_parameter_set* vps)
27 void profile_data::set_defaults(enum profile_idc profile, int level_major, int level_minor)
28 {
29 profile_present_flag = 1;
30
31 profile_space = 0;
32 tier_flag = 0;
33 profile_idc = profile;
34
35 for (int i=0;i<32;i++) {
36 profile_compatibility_flag[i]=0;
37 }
38
39 switch (profile) {
40 case Profile_Main:
41 profile_compatibility_flag[Profile_Main]=1;
42 profile_compatibility_flag[Profile_Main10]=1;
43 break;
44 case Profile_Main10:
45 profile_compatibility_flag[Profile_Main10]=1;
46 break;
47 default:
48 assert(0);
49 }
50
51 progressive_source_flag = 0;
52 interlaced_source_flag = 0;
53 non_packed_constraint_flag = 0;
54 frame_only_constraint_flag = 0;
55
56
57 // --- level ---
58
59 level_present_flag = 1;
60 level_idc = level_major*30 + level_minor*3;
61 }
62
63
64 void video_parameter_set::set_defaults(enum profile_idc profile, int level_major, int level_minor)
65 {
66 video_parameter_set_id = 0;
67 vps_max_layers = 1; // always =1 in current version of standard
68 vps_max_sub_layers = 1; // temporal sub-layers
69 vps_temporal_id_nesting_flag = 1;
70
71 profile_tier_level_.general.set_defaults(profile,level_major,level_minor);
72
73 vps_sub_layer_ordering_info_present_flag = 0;
74 layer[0].vps_max_dec_pic_buffering = 1;
75 layer[0].vps_max_num_reorder_pics = 0;
76 layer[0].vps_max_latency_increase = 0;
77
78 vps_max_layer_id = 0;
79 vps_num_layer_sets = 1;
80
81 layer_id_included_flag.resize(vps_num_layer_sets);
82
83
84 // --- timing info ---
85
86 vps_timing_info_present_flag = 0;
87 vps_num_units_in_tick = 0;
88 vps_time_scale = 0;
89 vps_poc_proportional_to_timing_flag = 0;
90
91 vps_num_ticks_poc_diff_one = 0;
92 vps_num_hrd_parameters = 0;
93
94
95 // --- vps extension ---
96
97 vps_extension_flag = 0;
98 }
99
100
101 de265_error video_parameter_set::read(error_queue* errqueue, bitreader* reader)
28102 {
29103 int vlc;
30104
31 vps->video_parameter_set_id = vlc = get_bits(reader, 4);
105 video_parameter_set_id = vlc = get_bits(reader, 4);
32106 if (vlc >= DE265_MAX_VPS_SETS) return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
33107
34108 skip_bits(reader, 2);
35 vps->vps_max_layers = vlc = get_bits(reader,6) +1;
36 if (vlc != 1) return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE; // TODO: out of specification
37
38 vps->vps_max_sub_layers = vlc = get_bits(reader,3) +1;
109 vps_max_layers = vlc = get_bits(reader,6) +1;
110 if (vlc > 63) return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE; // vps_max_layers_minus1 (range 0...63)
111
112 vps_max_sub_layers = vlc = get_bits(reader,3) +1;
39113 if (vlc >= MAX_TEMPORAL_SUBLAYERS) return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
40114
41 vps->vps_temporal_id_nesting_flag = get_bits(reader,1);
115 vps_temporal_id_nesting_flag = get_bits(reader,1);
42116 skip_bits(reader, 16);
43117
44 read_profile_tier_level(reader, &vps->profile_tier_level,
45 vps->vps_max_sub_layers);
118 profile_tier_level_.read(reader, vps_max_sub_layers);
46119
47120 /*
48 read_bit_rate_pic_rate_info(reader, &vps->bit_rate_pic_rate_info,
49 0, vps->vps_max_sub_layers-1);
121 read_bit_rate_pic_rate_info(reader, &bit_rate_pic_rate_info,
122 0, vps_max_sub_layers-1);
50123 */
51124
52 vps->vps_sub_layer_ordering_info_present_flag = get_bits(reader,1);
53 //assert(vps->vps_max_sub_layers-1 < MAX_TEMPORAL_SUBLAYERS);
54
55 int firstLayerRead = vps->vps_sub_layer_ordering_info_present_flag ? 0 : (vps->vps_max_sub_layers-1);
56
57 for (int i=firstLayerRead;i<vps->vps_max_sub_layers;i++) {
58 vps->layer[i].vps_max_dec_pic_buffering = get_uvlc(reader);
59 vps->layer[i].vps_max_num_reorder_pics = get_uvlc(reader);
60 vps->layer[i].vps_max_latency_increase = get_uvlc(reader);
61 }
62
63 if (!vps->vps_sub_layer_ordering_info_present_flag) {
125 vps_sub_layer_ordering_info_present_flag = get_bits(reader,1);
126 //assert(vps_max_sub_layers-1 < MAX_TEMPORAL_SUBLAYERS);
127
128 int firstLayerRead = vps_sub_layer_ordering_info_present_flag ? 0 : (vps_max_sub_layers-1);
129
130 for (int i=firstLayerRead;i<vps_max_sub_layers;i++) {
131 layer[i].vps_max_dec_pic_buffering = get_uvlc(reader);
132 layer[i].vps_max_num_reorder_pics = get_uvlc(reader);
133 layer[i].vps_max_latency_increase = get_uvlc(reader);
134
135 if (layer[i].vps_max_dec_pic_buffering == UVLC_ERROR ||
136 layer[i].vps_max_num_reorder_pics == UVLC_ERROR ||
137 layer[i].vps_max_latency_increase == UVLC_ERROR) {
138 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
139 }
140 }
141
142 if (!vps_sub_layer_ordering_info_present_flag) {
64143 assert(firstLayerRead < MAX_TEMPORAL_SUBLAYERS);
65144
66145 for (int i=0;i<firstLayerRead;i++) {
67 vps->layer[i].vps_max_dec_pic_buffering = vps->layer[firstLayerRead].vps_max_dec_pic_buffering;
68 vps->layer[i].vps_max_num_reorder_pics = vps->layer[firstLayerRead].vps_max_num_reorder_pics;
69 vps->layer[i].vps_max_latency_increase = vps->layer[firstLayerRead].vps_max_latency_increase;
70 }
71 }
72
73
74 vps->vps_max_layer_id = get_bits(reader,6);
75 vps->vps_num_layer_sets = get_uvlc(reader)+1;
76
77 if (vps->vps_num_layer_sets<0 ||
78 vps->vps_num_layer_sets>=1024) {
79 ctx->add_warning(DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE, false);
146 layer[i].vps_max_dec_pic_buffering = layer[firstLayerRead].vps_max_dec_pic_buffering;
147 layer[i].vps_max_num_reorder_pics = layer[firstLayerRead].vps_max_num_reorder_pics;
148 layer[i].vps_max_latency_increase = layer[firstLayerRead].vps_max_latency_increase;
149 }
150 }
151
152
153 vps_max_layer_id = get_bits(reader,6);
154 vps_num_layer_sets = get_uvlc(reader);
155
156 if (vps_num_layer_sets+1<0 ||
157 vps_num_layer_sets+1>=1024 ||
158 vps_num_layer_sets == UVLC_ERROR) {
159 errqueue->add_warning(DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE, false);
80160 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
81161 }
82
83 for (int i=1; i <= vps->vps_num_layer_sets-1; i++)
84 for (int j=0; j <= vps->vps_max_layer_id; j++)
85 {
86 vps->layer_id_included_flag[i][j] = get_bits(reader,1);
87 }
88
89 vps->vps_timing_info_present_flag = get_bits(reader,1);
90
91 if (vps->vps_timing_info_present_flag) {
92 vps->vps_num_units_in_tick = get_bits(reader,32);
93 vps->vps_time_scale = get_bits(reader,32);
94 vps->vps_poc_proportional_to_timing_flag = get_bits(reader,1);
95
96 if (vps->vps_poc_proportional_to_timing_flag) {
97 vps->vps_num_ticks_poc_diff_one = get_uvlc(reader)+1;
98 vps->vps_num_hrd_parameters = get_uvlc(reader);
99
100 if (vps->vps_num_hrd_parameters >= 1024) {
162 vps_num_layer_sets += 1;
163
164 layer_id_included_flag.resize(vps_num_layer_sets);
165
166 for (int i=1; i <= vps_num_layer_sets-1; i++)
167 {
168 layer_id_included_flag[i].resize(vps_max_layer_id+1);
169
170 for (int j=0; j <= vps_max_layer_id; j++)
171 {
172 layer_id_included_flag[i][j] = get_bits(reader,1);
173 }
174 }
175
176 vps_timing_info_present_flag = get_bits(reader,1);
177
178 if (vps_timing_info_present_flag) {
179 vps_num_units_in_tick = get_bits(reader,32);
180 vps_time_scale = get_bits(reader,32);
181 vps_poc_proportional_to_timing_flag = get_bits(reader,1);
182
183 if (vps_poc_proportional_to_timing_flag) {
184 vps_num_ticks_poc_diff_one = get_uvlc(reader)+1;
185 vps_num_hrd_parameters = get_uvlc(reader);
186
187 if (vps_num_hrd_parameters >= 1024) {
101188 assert(false); // TODO: return bitstream error
102189 }
103190
104 for (int i=0; i<vps->vps_num_hrd_parameters; i++) {
105 vps->hrd_layer_set_idx[i] = get_uvlc(reader);
191 hrd_layer_set_idx .resize(vps_num_hrd_parameters);
192 cprms_present_flag.resize(vps_num_hrd_parameters);
193
194 for (int i=0; i<vps_num_hrd_parameters; i++) {
195 hrd_layer_set_idx[i] = get_uvlc(reader);
106196
107197 if (i > 0) {
108 vps->cprms_present_flag[i] = get_bits(reader,1);
198 cprms_present_flag[i] = get_bits(reader,1);
109199 }
110200
111201 //hrd_parameters(cprms_present_flag[i], vps_max_sub_layers_minus1)
114204 }
115205 }
116206 }
117
118 vps->vps_extension_flag = get_bits(reader,1);
119
120 if (vps->vps_extension_flag) {
207
208 vps_extension_flag = get_bits(reader,1);
209
210 if (vps_extension_flag) {
211 /*
212 while( more_rbsp_data() )
213 vps_extension_data_flag u(1)
214 rbsp_trailing_bits()
215 */
216 }
217
218 return DE265_OK;
219 }
220
221
222 de265_error video_parameter_set::write(error_queue* errqueue, CABAC_encoder& out) const
223 {
224 if (video_parameter_set_id >= DE265_MAX_VPS_SETS) return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
225 out.write_bits(video_parameter_set_id,4);
226
227 out.write_bits(0x3,2);
228 out.write_bits(vps_max_layers-1,6);
229
230 if (vps_max_sub_layers >= MAX_TEMPORAL_SUBLAYERS) return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
231 out.write_bits(vps_max_sub_layers-1,3);
232
233 out.write_bit(vps_temporal_id_nesting_flag);
234 out.write_bits(0xFFFF, 16);
235
236 profile_tier_level_.write(out, vps_max_sub_layers);
237
238 /*
239 read_bit_rate_pic_rate_info(reader, &bit_rate_pic_rate_info,
240 0, vps_max_sub_layers-1);
241 */
242
243 out.write_bit(vps_sub_layer_ordering_info_present_flag);
244 //assert(vps_max_sub_layers-1 < MAX_TEMPORAL_SUBLAYERS);
245
246 int firstLayerRead = vps_sub_layer_ordering_info_present_flag ? 0 : (vps_max_sub_layers-1);
247
248 for (int i=firstLayerRead;i<vps_max_sub_layers;i++) {
249 out.write_uvlc(layer[i].vps_max_dec_pic_buffering);
250 out.write_uvlc(layer[i].vps_max_num_reorder_pics);
251 out.write_uvlc(layer[i].vps_max_latency_increase);
252 }
253
254 if (vps_num_layer_sets<0 ||
255 vps_num_layer_sets>=1024) {
256 errqueue->add_warning(DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE, false);
257 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE;
258 }
259
260 out.write_bits(vps_max_layer_id,6);
261 out.write_uvlc(vps_num_layer_sets-1);
262
263 for (int i=1; i <= vps_num_layer_sets-1; i++)
264 for (int j=0; j <= vps_max_layer_id; j++)
265 {
266 out.write_bit(layer_id_included_flag[i][j]);
267 }
268
269 out.write_bit(vps_timing_info_present_flag);
270
271 if (vps_timing_info_present_flag) {
272 out.write_bits(vps_num_units_in_tick,32);
273 out.write_bits(vps_time_scale ,32);
274 out.write_bit (vps_poc_proportional_to_timing_flag);
275
276 if (vps_poc_proportional_to_timing_flag) {
277 out.write_uvlc(vps_num_ticks_poc_diff_one-1);
278 out.write_uvlc(vps_num_hrd_parameters);
279
280 for (int i=0; i<vps_num_hrd_parameters; i++) {
281 out.write_uvlc(hrd_layer_set_idx[i]);
282
283 if (i > 0) {
284 out.write_bit(cprms_present_flag[i]);
285 }
286
287 //hrd_parameters(cprms_present_flag[i], vps_max_sub_layers_minus1)
288
289 return DE265_OK; // TODO: decode hrd_parameters()
290 }
291 }
292 }
293
294 out.write_bit(vps_extension_flag);
295
296 if (vps_extension_flag) {
121297 /*
122298 while( more_rbsp_data() )
123299 vps_extension_data_flag u(1)
129305 }
130306
131307
132 void read_profile_tier_level(bitreader* reader,
133 struct profile_tier_level* hdr,
134 int max_sub_layers)
135 {
136 hdr->general_profile_space = get_bits(reader,2);
137 hdr->general_tier_flag = get_bits(reader,1);
138 hdr->general_profile_idc = get_bits(reader,5);
139
140 for (int i=0; i<32; i++) {
141 hdr->general_profile_compatibility_flag[i] = get_bits(reader,1);
142 }
143
144 hdr->general_progressive_source_flag = get_bits(reader,1);
145 hdr->general_interlaced_source_flag = get_bits(reader,1);
146 hdr->general_non_packed_constraint_flag = get_bits(reader,1);
147 hdr->general_frame_only_constraint_flag = get_bits(reader,1);
148 skip_bits(reader,44);
149
150 hdr->general_level_idc = get_bits(reader,8);
151
308 void profile_data::read(bitreader* reader)
309 {
310 if (profile_present_flag) {
311 profile_space = get_bits(reader,2);
312 tier_flag = get_bits(reader,1);
313 profile_idc = (enum profile_idc)get_bits(reader,5);
314
315 for (int i=0; i<32; i++) {
316 profile_compatibility_flag[i] = get_bits(reader,1);
317 }
318
319 progressive_source_flag = get_bits(reader,1);
320 interlaced_source_flag = get_bits(reader,1);
321 non_packed_constraint_flag = get_bits(reader,1);
322 frame_only_constraint_flag = get_bits(reader,1);
323 skip_bits(reader,44);
324 }
325
326 if (level_present_flag) {
327 level_idc = get_bits(reader,8);
328 }
329 }
330
331
332 void profile_tier_level::read(bitreader* reader,
333 int max_sub_layers)
334 {
335 // --- read the general profile ---
336
337 general.profile_present_flag = true;
338 general.level_present_flag = true;
339 general.read(reader);
340
341
342 // --- read the profile/levels of the sub-layers ---
152343
153344 for (int i=0; i<max_sub_layers-1; i++)
154345 {
155 hdr->profile[i].sub_layer_profile_present_flag = get_bits(reader,1);
156 hdr->profile[i].sub_layer_level_present_flag = get_bits(reader,1);
346 sub_layer[i].profile_present_flag = get_bits(reader,1);
347 sub_layer[i].level_present_flag = get_bits(reader,1);
157348 }
158349
159350 if (max_sub_layers > 1)
166357
167358 for (int i=0; i<max_sub_layers-1; i++)
168359 {
169 if (hdr->profile[i].sub_layer_profile_present_flag)
360 sub_layer[i].read(reader);
361 }
362 }
363
364
365 void profile_data::write(CABAC_encoder& out) const
366 {
367 if (profile_present_flag)
368 {
369 out.write_bits(profile_space,2);
370 out.write_bit (tier_flag);
371 out.write_bits(profile_idc,5);
372
373 for (int j=0; j<32; j++)
170374 {
171 hdr->profile[i].sub_layer_profile_space = get_bits(reader,2);
172 hdr->profile[i].sub_layer_tier_flag = get_bits(reader,1);
173 hdr->profile[i].sub_layer_profile_idc = get_bits(reader,5);
174
175 for (int j=0; j<32; j++)
176 {
177 hdr->profile[i].sub_layer_profile_compatibility_flag[j] = get_bits(reader,1);
178 }
179
180 hdr->profile[i].sub_layer_progressive_source_flag = get_bits(reader,1);
181 hdr->profile[i].sub_layer_interlaced_source_flag = get_bits(reader,1);
182 hdr->profile[i].sub_layer_non_packed_constraint_flag = get_bits(reader,1);
183 hdr->profile[i].sub_layer_frame_only_constraint_flag = get_bits(reader,1);
184 skip_bits(reader,44);
375 out.write_bit(profile_compatibility_flag[j]);
185376 }
186377
187 if (hdr->profile[i].sub_layer_level_present_flag)
378 out.write_bit(progressive_source_flag);
379 out.write_bit(interlaced_source_flag);
380 out.write_bit(non_packed_constraint_flag);
381 out.write_bit(frame_only_constraint_flag);
382 out.skip_bits(44);
383 }
384
385 if (level_present_flag)
386 {
387 out.write_bits(level_idc,8);
388 }
389 }
390
391 void profile_tier_level::write(CABAC_encoder& out, int max_sub_layers) const
392 {
393 assert(general.profile_present_flag==true);
394 assert(general.level_present_flag==true);
395
396 general.write(out);
397
398 for (int i=0; i<max_sub_layers-1; i++)
399 {
400 out.write_bit(sub_layer[i].profile_present_flag);
401 out.write_bit(sub_layer[i].level_present_flag);
402 }
403
404 if (max_sub_layers > 1)
405 {
406 for (int i=max_sub_layers-1; i<8; i++)
188407 {
189 hdr->profile[i].sub_layer_level_idc = get_bits(reader,8);
408 out.skip_bits(2);
190409 }
410 }
411
412 for (int i=0; i<max_sub_layers-1; i++)
413 {
414 sub_layer[i].write(out);
191415 }
192416 }
193417
223447 #define LOG2(t,d1,d2) log2fh(fh, t,d1,d2)
224448 #define LOG3(t,d1,d2,d3) log2fh(fh, t,d1,d2,d3)
225449
226 void dump_vps(video_parameter_set* vps, int fd)
450 void video_parameter_set::dump(int fd) const
227451 {
228452 FILE* fh;
229453 if (fd==1) fh=stdout;
231455 else { return; }
232456
233457 LOG0("----------------- VPS -----------------\n");
234 LOG1("video_parameter_set_id : %d\n", vps->video_parameter_set_id);
235 LOG1("vps_max_layers : %d\n", vps->vps_max_layers);
236 LOG1("vps_max_sub_layers : %d\n", vps->vps_max_sub_layers);
237 LOG1("vps_temporal_id_nesting_flag : %d\n", vps->vps_temporal_id_nesting_flag);
238
239 dump_profile_tier_level(&vps->profile_tier_level, vps->vps_max_sub_layers, fh);
240 //dump_bit_rate_pic_rate_info(&vps->bit_rate_pic_rate_info, 0, vps->vps_max_sub_layers-1);
458 LOG1("video_parameter_set_id : %d\n", video_parameter_set_id);
459 LOG1("vps_max_layers : %d\n", vps_max_layers);
460 LOG1("vps_max_sub_layers : %d\n", vps_max_sub_layers);
461 LOG1("vps_temporal_id_nesting_flag : %d\n", vps_temporal_id_nesting_flag);
462
463 profile_tier_level_.dump(vps_max_sub_layers, fh);
464 //dump_bit_rate_pic_rate_info(&bit_rate_pic_rate_info, 0, vps_max_sub_layers-1);
241465
242466 LOG1("vps_sub_layer_ordering_info_present_flag : %d\n",
243 vps->vps_sub_layer_ordering_info_present_flag);
244
245 if (vps->vps_sub_layer_ordering_info_present_flag) {
246 for (int i=0;i<vps->vps_max_sub_layers;i++) {
247 LOG2("layer %d: vps_max_dec_pic_buffering = %d\n",i,vps->layer[i].vps_max_dec_pic_buffering);
248 LOG1(" vps_max_num_reorder_pics = %d\n",vps->layer[i].vps_max_num_reorder_pics);
249 LOG1(" vps_max_latency_increase = %d\n",vps->layer[i].vps_max_latency_increase);
467 vps_sub_layer_ordering_info_present_flag);
468
469 if (vps_sub_layer_ordering_info_present_flag) {
470 for (int i=0;i<vps_max_sub_layers;i++) {
471 LOG2("layer %d: vps_max_dec_pic_buffering = %d\n",i,layer[i].vps_max_dec_pic_buffering);
472 LOG1(" vps_max_num_reorder_pics = %d\n",layer[i].vps_max_num_reorder_pics);
473 LOG1(" vps_max_latency_increase = %d\n",layer[i].vps_max_latency_increase);
250474 }
251475 }
252476 else {
253 LOG1("layer (all): vps_max_dec_pic_buffering = %d\n",vps->layer[0].vps_max_dec_pic_buffering);
254 LOG1(" vps_max_num_reorder_pics = %d\n",vps->layer[0].vps_max_num_reorder_pics);
255 LOG1(" vps_max_latency_increase = %d\n",vps->layer[0].vps_max_latency_increase);
256 }
257
258
259 LOG1("vps_max_layer_id = %d\n", vps->vps_max_layer_id);
260 LOG1("vps_num_layer_sets = %d\n", vps->vps_num_layer_sets);
261
262 for (int i=1; i <= vps->vps_num_layer_sets-1; i++)
263 for (int j=0; j <= vps->vps_max_layer_id; j++)
477 LOG1("layer (all): vps_max_dec_pic_buffering = %d\n",layer[0].vps_max_dec_pic_buffering);
478 LOG1(" vps_max_num_reorder_pics = %d\n",layer[0].vps_max_num_reorder_pics);
479 LOG1(" vps_max_latency_increase = %d\n",layer[0].vps_max_latency_increase);
480 }
481
482
483 LOG1("vps_max_layer_id = %d\n", vps_max_layer_id);
484 LOG1("vps_num_layer_sets = %d\n", vps_num_layer_sets);
485
486 for (int i=1; i <= vps_num_layer_sets-1; i++)
487 for (int j=0; j <= vps_max_layer_id; j++)
264488 {
265489 LOG3("layer_id_included_flag[%d][%d] = %d\n",i,j,
266 vps->layer_id_included_flag[i][j]);
490 layer_id_included_flag[i][j]);
267491 }
268492
269493 LOG1("vps_timing_info_present_flag = %d\n",
270 vps->vps_timing_info_present_flag);
271
272 if (vps->vps_timing_info_present_flag) {
273 LOG1("vps_num_units_in_tick = %d\n", vps->vps_num_units_in_tick);
274 LOG1("vps_time_scale = %d\n", vps->vps_time_scale);
275 LOG1("vps_poc_proportional_to_timing_flag = %d\n", vps->vps_poc_proportional_to_timing_flag);
276
277 if (vps->vps_poc_proportional_to_timing_flag) {
278 LOG1("vps_num_ticks_poc_diff_one = %d\n", vps->vps_num_ticks_poc_diff_one);
279 LOG1("vps_num_hrd_parameters = %d\n", vps->vps_num_hrd_parameters);
280
281 for (int i=0; i<vps->vps_num_hrd_parameters; i++) {
282 LOG2("hrd_layer_set_idx[%d] = %d\n", i, vps->hrd_layer_set_idx[i]);
494 vps_timing_info_present_flag);
495
496 if (vps_timing_info_present_flag) {
497 LOG1("vps_num_units_in_tick = %d\n", vps_num_units_in_tick);
498 LOG1("vps_time_scale = %d\n", vps_time_scale);
499 LOG1("vps_poc_proportional_to_timing_flag = %d\n", vps_poc_proportional_to_timing_flag);
500
501 if (vps_poc_proportional_to_timing_flag) {
502 LOG1("vps_num_ticks_poc_diff_one = %d\n", vps_num_ticks_poc_diff_one);
503 LOG1("vps_num_hrd_parameters = %d\n", vps_num_hrd_parameters);
504
505 for (int i=0; i<vps_num_hrd_parameters; i++) {
506 LOG2("hrd_layer_set_idx[%d] = %d\n", i, hrd_layer_set_idx[i]);
283507
284508 if (i > 0) {
285 LOG2("cprms_present_flag[%d] = %d\n", i, vps->cprms_present_flag[i]);
509 LOG2("cprms_present_flag[%d] = %d\n", i, cprms_present_flag[i]);
286510 }
287511
288512 //hrd_parameters(cprms_present_flag[i], vps_max_sub_layers_minus1)
291515 }
292516 }
293517 }
294
295 LOG1("vps_extension_flag = %d\n", vps->vps_extension_flag);
296 }
297
298
299 void dump_profile_tier_level(const struct profile_tier_level* hdr,
300 int max_sub_layers, FILE* fh)
301 {
302 LOG1(" general_profile_space : %d\n", hdr->general_profile_space);
303 LOG1(" general_tier_flag : %d\n", hdr->general_tier_flag);
304 LOG1(" general_profile_idc : %d\n", hdr->general_profile_idc);
305
306 LOG0(" general_profile_compatibility_flags: ");
307 for (int i=0; i<32; i++) {
308 if (i) LOG0("*,");
309 LOG1("*%d",hdr->general_profile_compatibility_flag[i]);
310 }
311 LOG0("*\n");
312
313 LOG1(" general_level_idc : %d\n", hdr->general_level_idc);
518
519 LOG1("vps_extension_flag = %d\n", vps_extension_flag);
520 }
521
522
523 static const char* profile_name(profile_idc p)
524 {
525 switch (p) {
526 case Profile_Main: return "Main";
527 case Profile_Main10: return "Main10";
528 case Profile_MainStillPicture: return "MainStillPicture";
529 case Profile_FormatRangeExtensions: return "FormatRangeExtensions";
530 default:
531 return "(unknown)";
532 }
533 }
534
535
536 void profile_data::dump(bool general, FILE* fh) const
537 {
538 const char* prefix = (general ? "general" : "sub_layer");
539
540 if (profile_present_flag) {
541 LOG2(" %s_profile_space : %d\n", prefix,profile_space);
542 LOG2(" %s_tier_flag : %d\n", prefix,tier_flag);
543 LOG2(" %s_profile_idc : %s\n", prefix, profile_name(profile_idc));
544
545 LOG1(" %s_profile_compatibility_flags: ", prefix);
546 for (int i=0; i<32; i++) {
547 if (i) LOG0("*,");
548 LOG1("*%d",profile_compatibility_flag[i]);
549 }
550 LOG0("*\n");
551 LOG2(" %s_progressive_source_flag : %d\n",prefix,progressive_source_flag);
552 LOG2(" %s_interlaced_source_flag : %d\n",prefix,interlaced_source_flag);
553 LOG2(" %s_non_packed_constraint_flag : %d\n",prefix,non_packed_constraint_flag);
554 LOG2(" %s_frame_only_constraint_flag : %d\n",prefix,frame_only_constraint_flag);
555 }
556
557 if (level_present_flag) {
558 LOG3(" %s_level_idc : %d (%4.2f)\n", prefix,level_idc, level_idc/30.0f);
559 }
560 }
561
562
563 void profile_tier_level::dump(int max_sub_layers, FILE* fh) const
564 {
565 general.dump(true, fh);
314566
315567 for (int i=0; i<max_sub_layers-1; i++)
316568 {
317569 LOG1(" Profile/Tier/Level [Layer %d]\n",i);
318
319 if (hdr->profile[i].sub_layer_profile_present_flag) {
320
321 LOG1(" sub_layer_profile_space : %d\n",hdr->profile[i].sub_layer_profile_space);
322 LOG1(" sub_layer_tier_flag : %d\n",hdr->profile[i].sub_layer_tier_flag);
323 LOG1(" sub_layer_profile_idc : %d\n",hdr->profile[i].sub_layer_profile_idc);
324
325 LOG0(" sub_layer_profile_compatibility_flags: ");
326 for (int j=0; j<32; j++) {
327 if (j) LOG0(",");
328 LOG1("%d",hdr->profile[i].sub_layer_profile_compatibility_flag[j]);
329 }
330 LOG0("\n");
331
332 LOG1(" sub_layer_progressive_source_flag : %d\n",hdr->profile[i].sub_layer_progressive_source_flag);
333 LOG1(" sub_layer_interlaced_source_flag : %d\n",hdr->profile[i].sub_layer_interlaced_source_flag);
334 LOG1(" sub_layer_non_packed_constraint_flag : %d\n",hdr->profile[i].sub_layer_non_packed_constraint_flag);
335 LOG1(" sub_layer_frame_only_constraint_flag : %d\n",hdr->profile[i].sub_layer_frame_only_constraint_flag);
336 }
337
338
339 if (hdr->profile[i].sub_layer_level_present_flag) {
340 LOG1(" sub_layer_level_idc : %d\n", hdr->profile[i].sub_layer_level_idc);
341 }
570 sub_layer[i].dump(false, fh);
342571 }
343572 }
344573
3030
3131 #include "libde265/bitstream.h"
3232 #include "libde265/de265.h"
33 #include "libde265/cabac.h"
34
35 #include <vector>
36
37 class error_queue;
3338
3439 #define MAX_TEMPORAL_SUBLAYERS 8
3540
3641
37 struct profile_data {
42 enum profile_idc {
43 Profile_Main = 1,
44 Profile_Main10 = 2,
45 Profile_MainStillPicture = 3,
46 Profile_FormatRangeExtensions = 4
47 };
48
49
50 class profile_data {
51 public:
52 void read(bitreader* reader);
53 void write(CABAC_encoder& writer) const;
54 void dump(bool general, FILE* fh) const;
55
56 void set_defaults(enum profile_idc, int level_major, int level_minor);
57
3858 // --- profile ---
3959
40 char sub_layer_profile_present_flag;
60 char profile_present_flag; // always true for general profile
4161
42 char sub_layer_profile_space;
43 char sub_layer_tier_flag;
44 char sub_layer_profile_idc;
62 char profile_space; // currently always 0
63 char tier_flag; // main tier or low tier (see Table A-66/A-67)
64 enum profile_idc profile_idc; // profile
4565
46 char sub_layer_profile_compatibility_flag[32];
66 char profile_compatibility_flag[32]; // to which profile we are compatible
4767
48 char sub_layer_progressive_source_flag;
49 char sub_layer_interlaced_source_flag;
50 char sub_layer_non_packed_constraint_flag;
51 char sub_layer_frame_only_constraint_flag;
68 char progressive_source_flag;
69 char interlaced_source_flag;
70 char non_packed_constraint_flag;
71 char frame_only_constraint_flag;
5272
5373
5474 // --- level ---
5575
56 char sub_layer_level_present_flag;
57 int sub_layer_level_idc;
76 char level_present_flag; // always true for general level
77 int level_idc; // level * 30
5878 };
5979
6080
61 struct profile_tier_level {
62 int general_profile_space;
63 int general_tier_flag;
64 int general_profile_idc;
81 class profile_tier_level
82 {
83 public:
84 void read(bitreader* reader, int max_sub_layers);
85 void write(CABAC_encoder& writer, int max_sub_layers) const;
86 void dump(int max_sub_layers, FILE* fh) const;
6587
66 char general_profile_compatibility_flag[32];
88 profile_data general;
6789
68 char general_progressive_source_flag;
69 char general_interlaced_source_flag;
70 char general_non_packed_constraint_flag;
71 char general_frame_only_constraint_flag;
90 //bool sub_layer_profile_present[MAX_TEMPORAL_SUBLAYERS];
91 //bool sub_layer_level_present[MAX_TEMPORAL_SUBLAYERS];
7292
73 int general_level_idc;
74
75 struct profile_data profile[MAX_TEMPORAL_SUBLAYERS];
93 profile_data sub_layer[MAX_TEMPORAL_SUBLAYERS];
7694 };
77
78
79 void read_profile_tier_level(bitreader* reader,
80 struct profile_tier_level* hdr,
81 int max_sub_layers);
82
83 void dump_profile_tier_level(const struct profile_tier_level* hdr,
84 int max_sub_layers, FILE* fh);
8595
8696
8797 /*
109119
110120
111121 typedef struct {
112 int vps_max_dec_pic_buffering;
113 int vps_max_num_reorder_pics;
114 int vps_max_latency_increase;
122 int vps_max_dec_pic_buffering; // [1 ; ]
123 int vps_max_num_reorder_pics; // [0 ; ]
124 int vps_max_latency_increase; // 0 -> no limit, otherwise value is (x-1)
115125 } layer_data;
116126
117 typedef struct {
127
128 class video_parameter_set
129 {
130 public:
131 de265_error read(error_queue* errqueue, bitreader* reader);
132 de265_error write(error_queue* errqueue, CABAC_encoder& out) const;
133 void dump(int fd) const;
134
135 void set_defaults(enum profile_idc profile, int level_major, int level_minor);
136
118137 int video_parameter_set_id;
119 int vps_max_layers;
120 int vps_max_sub_layers;
121 int vps_temporal_id_nesting_flag;
122 struct profile_tier_level profile_tier_level;
123 //struct bit_rate_pic_rate_info bit_rate_pic_rate_info;
138 int vps_max_layers; // [1;?] currently always 1
139 int vps_max_sub_layers; // [1;7] number of temporal sub-layers
140 int vps_temporal_id_nesting_flag; // indicate temporal up-switching always possible
141 profile_tier_level profile_tier_level_;
142
124143 int vps_sub_layer_ordering_info_present_flag;
125
126144 layer_data layer[MAX_TEMPORAL_SUBLAYERS];
127145
128 uint8_t vps_max_layer_id;
129 int vps_num_layer_sets;
146 uint8_t vps_max_layer_id; // max value for nuh_layer_id in NALs
147 int vps_num_layer_sets; // [1;1024], currently always 1
130148
131 char layer_id_included_flag[1024][64];
149 std::vector<std::vector<bool> > layer_id_included_flag; // max size = [1024][64]
150
151
152 // --- timing info ---
132153
133154 char vps_timing_info_present_flag;
134155 uint32_t vps_num_units_in_tick;
135156 uint32_t vps_time_scale;
136157 char vps_poc_proportional_to_timing_flag;
158 uint32_t vps_num_ticks_poc_diff_one;
137159
138 int vps_num_ticks_poc_diff_one;
139 int vps_num_hrd_parameters;
160 int vps_num_hrd_parameters; // currently [0;1]
140161
141 uint16_t hrd_layer_set_idx[1024];
142 char cprms_present_flag[1024];
162 std::vector<uint16_t> hrd_layer_set_idx; // max size = 1024
163 std::vector<char> cprms_present_flag; // max size = 1024
143164
144 // hrd_parameters(cprms_present_flag[i], vps_max_sub_layers-1)
165
166 // --- vps extension ---
145167
146168 char vps_extension_flag;
147
148 } video_parameter_set;
169 };
149170
150171
151 de265_error read_vps(struct decoder_context* ctx, bitreader* reader, video_parameter_set* vps);
152 void dump_vps(video_parameter_set*, int fd);
153
154172 #endif
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * This file is part of libde265.
5 *
6 * libde265 is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation, either version 3 of
9 * the License, or (at your option) any later version.
10 *
11 * libde265 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
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with libde265. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "vui.h"
21 #include "decctx.h"
22
23 #include <assert.h>
24 #include <stdlib.h>
25 #include <string.h>
26
27 #define READ_VLC_OFFSET(variable, vlctype, offset) \
28 if ((vlc = get_ ## vlctype(br)) == UVLC_ERROR) { \
29 errqueue->add_warning(DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE, false); \
30 return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE; \
31 } \
32 variable = vlc + offset;
33
34 #define READ_VLC(variable, vlctype) READ_VLC_OFFSET(variable,vlctype,0)
35
36
37 #define NUM_SAR_PRESETS 17
38
39 static uint16_t sar_presets[NUM_SAR_PRESETS+1][2] = {
40 { 0,0 },
41 { 1,1 },
42 { 12,11 },
43 { 10,11 },
44 { 16,11 },
45 { 40,33 },
46 { 24,11 },
47 { 20,11 },
48 { 32,11 },
49 { 80,33 },
50 { 18,11 },
51 { 15,11 },
52 { 64,33 },
53 { 160,99 },
54 { 4,3 },
55 { 3,2 },
56 { 2,1 }
57 };
58
59 #define EXTENDED_SAR 255
60
61
62 const char* get_video_format_name(enum VideoFormat format)
63 {
64 switch (format) {
65 case VideoFormat_Component: return "component";
66 case VideoFormat_PAL: return "PAL";
67 case VideoFormat_NTSC: return "NTSC";
68 case VideoFormat_SECAM: return "SECAM";
69 case VideoFormat_MAC: return "MAC";
70 default: return "unspecified";
71 }
72 }
73
74
75 video_usability_information::video_usability_information()
76 {
77 aspect_ratio_info_present_flag = false;
78 sar_width = 0;
79 sar_height = 0;
80
81
82 // --- overscan ---
83
84 overscan_info_present_flag = false;
85 overscan_appropriate_flag = false;
86
87
88 // --- video signal type ---
89
90 video_signal_type_present_flag = false;
91 video_format = VideoFormat_Unspecified;
92 video_full_range_flag = false;
93 colour_description_present_flag = false;
94 colour_primaries = 2;
95 transfer_characteristics = 2;
96 matrix_coeffs = 2;
97
98 // --- chroma / interlaced ---
99
100 chroma_loc_info_present_flag = false;
101 chroma_sample_loc_type_top_field = 0;
102 chroma_sample_loc_type_bottom_field = 0;
103
104 neutral_chroma_indication_flag = false;
105 field_seq_flag = false;
106 frame_field_info_present_flag = false;
107
108 // --- default display window ---
109
110 default_display_window_flag = false;
111 def_disp_win_left_offset = 0;
112 def_disp_win_right_offset = 0;
113 def_disp_win_top_offset = 0;
114 def_disp_win_bottom_offset = 0;
115
116
117 // --- timing ---
118
119 vui_timing_info_present_flag = false;
120 vui_num_units_in_tick = 0;
121 vui_time_scale = 0;
122
123 vui_poc_proportional_to_timing_flag = false;
124 vui_num_ticks_poc_diff_one = 1;
125
126
127 // --- hrd parameters ---
128
129 vui_hrd_parameters_present_flag = false;
130 //hrd_parameters vui_hrd_parameters;
131
132
133 // --- bitstream restriction ---
134
135 bitstream_restriction_flag = false;
136 tiles_fixed_structure_flag = false;
137 motion_vectors_over_pic_boundaries_flag = true;
138 restricted_ref_pic_lists_flag = false;
139 min_spatial_segmentation_idc = 0;
140 max_bytes_per_pic_denom = 2;
141 max_bits_per_min_cu_denom = 1;
142 log2_max_mv_length_horizontal = 15;
143 log2_max_mv_length_vertical = 15;
144 }
145
146
147 de265_error video_usability_information::read(error_queue* errqueue, bitreader* br,
148 const seq_parameter_set* sps)
149 {
150 int vlc;
151
152
153 // --- sample aspect ratio (SAR) ---
154
155 aspect_ratio_info_present_flag = get_bits(br,1);
156 if (aspect_ratio_info_present_flag) {
157 int aspect_ratio_idc = get_bits(br,8);
158 if (aspect_ratio_idc <= NUM_SAR_PRESETS) {
159 sar_width = sar_presets[aspect_ratio_idc][0];
160 sar_height = sar_presets[aspect_ratio_idc][1];
161 }
162 else if (aspect_ratio_idc == EXTENDED_SAR) {
163 sar_width = get_bits(br,16);
164 sar_height = get_bits(br,16);
165 }
166 else {
167 sar_width = 0;
168 sar_height = 0;
169 }
170 }
171 else {
172 sar_width = 0;
173 sar_height = 0;
174 }
175
176
177 // --- overscan ---
178
179 overscan_info_present_flag = get_bits(br,1);
180 if (overscan_info_present_flag) {
181 overscan_appropriate_flag = get_bits(br,1);
182 }
183
184
185 // --- video signal type ---
186
187 { // defaults
188 video_format = VideoFormat_Unspecified;
189 video_full_range_flag = false;
190 colour_primaries = 2;
191 transfer_characteristics = 2;
192 matrix_coeffs = 2;
193 }
194
195 video_signal_type_present_flag = get_bits(br,1);
196 if (video_signal_type_present_flag) {
197 int video_format_idc = get_bits(br,3);
198 if (video_format_idc > 5) {
199 video_format_idc = VideoFormat_Unspecified;
200 }
201 video_format = (VideoFormat)video_format_idc;
202
203 video_full_range_flag = get_bits(br,1);
204
205 colour_description_present_flag = get_bits(br,1);
206 if (colour_description_present_flag) {
207 colour_primaries = get_bits(br,8);
208 if (colour_primaries == 0 ||
209 colour_primaries == 3 ||
210 colour_primaries >= 11) {
211 colour_primaries = 2;
212 }
213
214 transfer_characteristics = get_bits(br,8);
215 if (transfer_characteristics == 0 ||
216 transfer_characteristics == 3 ||
217 transfer_characteristics >= 18) {
218 transfer_characteristics = 2;
219 }
220
221 matrix_coeffs = get_bits(br,8);
222 if (matrix_coeffs == 0 ||
223 matrix_coeffs >= 11) {
224 matrix_coeffs = 2;
225 }
226 }
227 }
228
229
230 // --- chroma / interlaced ---
231
232 chroma_loc_info_present_flag = get_bits(br,1);
233 if (chroma_loc_info_present_flag) {
234 READ_VLC(chroma_sample_loc_type_top_field, uvlc);
235 READ_VLC(chroma_sample_loc_type_bottom_field, uvlc);
236 }
237 else {
238 chroma_sample_loc_type_top_field = 0;
239 chroma_sample_loc_type_bottom_field = 0;
240 }
241
242 neutral_chroma_indication_flag = get_bits(br,1);
243 field_seq_flag = get_bits(br,1);
244 frame_field_info_present_flag = get_bits(br,1);
245
246
247 // --- default display window ---
248
249 default_display_window_flag = get_bits(br,1);
250 if (default_display_window_flag) {
251 READ_VLC(def_disp_win_left_offset ,uvlc);
252 READ_VLC(def_disp_win_right_offset ,uvlc);
253 READ_VLC(def_disp_win_top_offset ,uvlc);
254 READ_VLC(def_disp_win_bottom_offset,uvlc);
255 }
256 else {
257 def_disp_win_left_offset =0;
258 def_disp_win_right_offset =0;
259 def_disp_win_top_offset =0;
260 def_disp_win_bottom_offset=0;
261 }
262
263
264 // --- timing ---
265
266 vui_timing_info_present_flag = get_bits(br,1);
267 if (vui_timing_info_present_flag) {
268 vui_num_units_in_tick = get_bits(br,32);
269 vui_time_scale = get_bits(br,32);
270 }
271
272 vui_poc_proportional_to_timing_flag = get_bits(br,1);
273 READ_VLC_OFFSET(vui_num_ticks_poc_diff_one, uvlc, 1);
274
275
276 // --- hrd parameters ---
277
278 vui_hrd_parameters_present_flag = get_bits(br,1);
279 if (vui_hrd_parameters_present_flag) {
280 return DE265_ERROR_NOT_IMPLEMENTED_YET;
281 //hrd_parameters vui_hrd_parameters;
282 }
283
284
285 // --- bitstream restriction ---
286
287 bitstream_restriction_flag = get_bits(br,1);
288 if (bitstream_restriction_flag) {
289 tiles_fixed_structure_flag = get_bits(br,1);
290 motion_vectors_over_pic_boundaries_flag = get_bits(br,1);
291 restricted_ref_pic_lists_flag = get_bits(br,1);
292
293 READ_VLC(min_spatial_segmentation_idc, uvlc);
294 if (min_spatial_segmentation_idc > 4095) {
295 errqueue->add_warning(DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE, false);
296 min_spatial_segmentation_idc = 0;
297 }
298
299 READ_VLC(max_bytes_per_pic_denom, uvlc);
300 if (max_bytes_per_pic_denom > 16) {
301 errqueue->add_warning(DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE, false);
302 max_bytes_per_pic_denom = 2;
303 }
304
305 READ_VLC(max_bits_per_min_cu_denom, uvlc);
306 if (max_bits_per_min_cu_denom > 16) {
307 errqueue->add_warning(DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE, false);
308 max_bits_per_min_cu_denom = 1;
309 }
310
311 READ_VLC(log2_max_mv_length_horizontal, uvlc);
312 if (log2_max_mv_length_horizontal > 15) {
313 errqueue->add_warning(DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE, false);
314 log2_max_mv_length_horizontal = 15;
315 }
316
317 READ_VLC(log2_max_mv_length_vertical, uvlc);
318 if (log2_max_mv_length_vertical > 15) {
319 errqueue->add_warning(DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE, false);
320 log2_max_mv_length_vertical = 15;
321 }
322 }
323 else {
324 tiles_fixed_structure_flag = false;
325 motion_vectors_over_pic_boundaries_flag = true;
326 restricted_ref_pic_lists_flag = false; // NOTE: default not specified in standard 2014/10
327
328 min_spatial_segmentation_idc = 0;
329 max_bytes_per_pic_denom = 2;
330 max_bits_per_min_cu_denom = 1;
331 log2_max_mv_length_horizontal = 15;
332 log2_max_mv_length_vertical = 15;
333 }
334
335 //vui_read = true;
336
337 return DE265_OK;
338 }
339
340
341 void video_usability_information::dump(int fd) const
342 {
343 //#if (_MSC_VER >= 1500)
344 //#define LOG0(t) loginfo(LogHeaders, t)
345 //#define LOG1(t,d) loginfo(LogHeaders, t,d)
346 //#define LOG2(t,d1,d2) loginfo(LogHeaders, t,d1,d2)
347 //#define LOG3(t,d1,d2,d3) loginfo(LogHeaders, t,d1,d2,d3)
348
349 FILE* fh;
350 if (fd==1) fh=stdout;
351 else if (fd==2) fh=stderr;
352 else { return; }
353
354 #define LOG0(t) log2fh(fh, t)
355 #define LOG1(t,d) log2fh(fh, t,d)
356 #define LOG2(t,d1,d2) log2fh(fh, t,d1,d2)
357 #define LOG3(t,d1,d2,d3) log2fh(fh, t,d1,d2,d3)
358
359 LOG0("----------------- VUI -----------------\n");
360 LOG2("sample aspect ratio : %d:%d\n", sar_width,sar_height);
361 LOG1("overscan_info_present_flag : %d\n", overscan_info_present_flag);
362 LOG1("overscan_appropriate_flag : %d\n", overscan_appropriate_flag);
363
364 LOG1("video_signal_type_present_flag: %d\n", video_signal_type_present_flag);
365 if (video_signal_type_present_flag) {
366 LOG1(" video_format : %s\n", get_video_format_name(video_format));
367 LOG1(" video_full_range_flag : %d\n", video_full_range_flag);
368 LOG1(" colour_description_present_flag : %d\n", colour_description_present_flag);
369 LOG1(" colour_primaries : %d\n", colour_primaries);
370 LOG1(" transfer_characteristics : %d\n", transfer_characteristics);
371 LOG1(" matrix_coeffs : %d\n", matrix_coeffs);
372 }
373
374 LOG1("chroma_loc_info_present_flag: %d\n", chroma_loc_info_present_flag);
375 if (chroma_loc_info_present_flag) {
376 LOG1(" chroma_sample_loc_type_top_field : %d\n", chroma_sample_loc_type_top_field);
377 LOG1(" chroma_sample_loc_type_bottom_field: %d\n", chroma_sample_loc_type_bottom_field);
378 }
379
380 LOG1("neutral_chroma_indication_flag: %d\n", neutral_chroma_indication_flag);
381 LOG1("field_seq_flag : %d\n", field_seq_flag);
382 LOG1("frame_field_info_present_flag : %d\n", frame_field_info_present_flag);
383
384 LOG1("default_display_window_flag : %d\n", default_display_window_flag);
385 LOG1(" def_disp_win_left_offset : %d\n", def_disp_win_left_offset);
386 LOG1(" def_disp_win_right_offset : %d\n", def_disp_win_right_offset);
387 LOG1(" def_disp_win_top_offset : %d\n", def_disp_win_top_offset);
388 LOG1(" def_disp_win_bottom_offset : %d\n", def_disp_win_bottom_offset);
389
390 LOG1("vui_timing_info_present_flag : %d\n", vui_timing_info_present_flag);
391 if (vui_timing_info_present_flag) {
392 LOG1(" vui_num_units_in_tick : %d\n", vui_num_units_in_tick);
393 LOG1(" vui_time_scale : %d\n", vui_time_scale);
394 }
395
396 LOG1("vui_poc_proportional_to_timing_flag : %d\n", vui_poc_proportional_to_timing_flag);
397 LOG1("vui_num_ticks_poc_diff_one : %d\n", vui_num_ticks_poc_diff_one);
398
399 LOG1("vui_hrd_parameters_present_flag : %d\n", vui_hrd_parameters_present_flag);
400 if (vui_hrd_parameters_present_flag) {
401 //hrd_parameters vui_hrd_parameters;
402 }
403
404
405 // --- bitstream restriction ---
406
407 LOG1("bitstream_restriction_flag : %d\n", bitstream_restriction_flag);
408 if (bitstream_restriction_flag) {
409 LOG1(" tiles_fixed_structure_flag : %d\n", tiles_fixed_structure_flag);
410 LOG1(" motion_vectors_over_pic_boundaries_flag : %d\n", motion_vectors_over_pic_boundaries_flag);
411 LOG1(" restricted_ref_pic_lists_flag : %d\n", restricted_ref_pic_lists_flag);
412 LOG1(" min_spatial_segmentation_idc : %d\n", min_spatial_segmentation_idc);
413 LOG1(" max_bytes_per_pic_denom : %d\n", max_bytes_per_pic_denom);
414 LOG1(" max_bits_per_min_cu_denom : %d\n", max_bits_per_min_cu_denom);
415 LOG1(" log2_max_mv_length_horizontal : %d\n", log2_max_mv_length_horizontal);
416 LOG1(" log2_max_mv_length_vertical : %d\n", log2_max_mv_length_vertical);
417 }
418
419 #undef LOG0
420 #undef LOG1
421 #undef LOG2
422 #undef LOG3
423 //#endif
424 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * This file is part of libde265.
5 *
6 * libde265 is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation, either version 3 of
9 * the License, or (at your option) any later version.
10 *
11 * libde265 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
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with libde265. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef DE265_VUI_H
21 #define DE265_VUI_H
22
23 #include "libde265/de265.h"
24 #include "libde265/bitstream.h"
25
26 #include <vector>
27
28 class error_queue;
29 class seq_parameter_set;
30
31
32 enum VideoFormat {
33 VideoFormat_Component = 0,
34 VideoFormat_PAL = 1,
35 VideoFormat_NTSC = 2,
36 VideoFormat_SECAM = 3,
37 VideoFormat_MAC = 4,
38 VideoFormat_Unspecified = 5
39 };
40
41 const char* get_video_format_name(enum VideoFormat);
42
43
44 class video_usability_information
45 {
46 public:
47 video_usability_information();
48
49 de265_error read(error_queue*, bitreader*, const seq_parameter_set*);
50 void dump(int fd) const;
51
52
53 // --- sample aspect ratio (SAR) ---
54
55 bool aspect_ratio_info_present_flag;
56 uint16_t sar_width; // sar_width and sar_height are zero if unspecified
57 uint16_t sar_height;
58
59
60 // --- overscan ---
61
62 bool overscan_info_present_flag;
63 bool overscan_appropriate_flag;
64
65
66 // --- video signal type ---
67
68 bool video_signal_type_present_flag;
69 enum VideoFormat video_format;
70 bool video_full_range_flag;
71 bool colour_description_present_flag;
72 uint8_t colour_primaries;
73 uint8_t transfer_characteristics;
74 uint8_t matrix_coeffs;
75
76 // --- chroma / interlaced ---
77
78 bool chroma_loc_info_present_flag;
79 uint8_t chroma_sample_loc_type_top_field;
80 uint8_t chroma_sample_loc_type_bottom_field;
81
82 bool neutral_chroma_indication_flag;
83 bool field_seq_flag;
84 bool frame_field_info_present_flag;
85
86 // --- default display window ---
87
88 bool default_display_window_flag;
89 uint32_t def_disp_win_left_offset;
90 uint32_t def_disp_win_right_offset;
91 uint32_t def_disp_win_top_offset;
92 uint32_t def_disp_win_bottom_offset;
93
94
95 // --- timing ---
96
97 bool vui_timing_info_present_flag;
98 uint32_t vui_num_units_in_tick;
99 uint32_t vui_time_scale;
100
101 bool vui_poc_proportional_to_timing_flag;
102 uint32_t vui_num_ticks_poc_diff_one;
103
104
105 // --- hrd parameters ---
106
107 bool vui_hrd_parameters_present_flag;
108 //hrd_parameters vui_hrd_parameters;
109
110
111 // --- bitstream restriction ---
112
113 bool bitstream_restriction_flag;
114 bool tiles_fixed_structure_flag;
115 bool motion_vectors_over_pic_boundaries_flag;
116 bool restricted_ref_pic_lists_flag;
117 uint16_t min_spatial_segmentation_idc;
118 uint8_t max_bytes_per_pic_denom;
119 uint8_t max_bits_per_min_cu_denom;
120 uint8_t log2_max_mv_length_horizontal;
121 uint8_t log2_max_mv_length_vertical;
122 };
123
124
125 #endif
0 set (x86_sources
1 sse.cc sse.h
2 )
3
4 set (x86_sse_sources
5 sse-motion.cc sse-motion.h sse-dct.h sse-dct.cc
6 )
7
8 add_library(x86 STATIC ${x86_sources})
9
10 add_library(x86_sse STATIC ${x86_sse_sources})
11
12 set(sse_flags "")
13
14 if(NOT MSVC)
15 set(sse_flags "${sse_flags} -msse4.1")
16 endif()
17
18 target_link_libraries(x86 x86_sse)
19
20 if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
21 SET_TARGET_PROPERTIES(x86 PROPERTIES COMPILE_FLAGS "-fPIC")
22 SET_TARGET_PROPERTIES(x86_sse PROPERTIES COMPILE_FLAGS "-fPIC ${sse_flags}")
23 endif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
1717 libde265_x86_sse_la_CXXFLAGS += -DHAVE_VISIBILITY
1818 endif
1919
20 EXTRA_DIST = \
21 CMakeLists.txt
8585 $(top_srcdir)/depcomp
8686 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
8787 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
88 $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \
8889 $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
8990 $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
9091 $(top_srcdir)/m4/lt~obsolete.m4 \
9192 $(top_srcdir)/m4/m4_ax_check_compile_flag.m4 \
92 $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/configure.ac
93 $(top_srcdir)/configure.ac
9394 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
9495 $(ACLOCAL_M4)
9596 mkinstalldirs = $(install_sh) -d
197198 CTAGS = ctags
198199 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
199200 ACLOCAL = @ACLOCAL@
201 ALLOCA = @ALLOCA@
200202 AMTAR = @AMTAR@
201203 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
202204 AR = @AR@
205207 AUTOMAKE = @AUTOMAKE@
206208 AWK = @AWK@
207209 CC = @CC@
210 CCAS = @CCAS@
211 CCASDEPMODE = @CCASDEPMODE@
212 CCASFLAGS = @CCASFLAGS@
208213 CCDEPMODE = @CCDEPMODE@
209214 CFLAGS = @CFLAGS@
210 CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
211215 CPP = @CPP@
212216 CPPFLAGS = @CPPFLAGS@
213217 CXX = @CXX@
227231 EXEEXT = @EXEEXT@
228232 FGREP = @FGREP@
229233 GREP = @GREP@
230 HAVE_VISIBILITY = @HAVE_VISIBILITY@
234 HAVE_CXX11 = @HAVE_CXX11@
231235 INSTALL = @INSTALL@
232236 INSTALL_DATA = @INSTALL_DATA@
233237 INSTALL_PROGRAM = @INSTALL_PROGRAM@
347351 libde265_x86_sse_la_CXXFLAGS = -msse4.1 -I.. $(CFLAG_VISIBILITY) \
348352 $(am__append_2)
349353 libde265_x86_sse_la_SOURCES = sse-motion.cc sse-motion.h sse-dct.h sse-dct.cc
354 EXTRA_DIST = \
355 CMakeLists.txt
356
350357 all: all-am
351358
352359 .SUFFIXES:
281281 #define add_1st (1 << (shift_1st - 1))
282282
283283
284 void ff_hevc_transform_skip_8_sse(uint8_t *_dst, int16_t *coeffs, ptrdiff_t _stride)
284 void ff_hevc_transform_skip_8_sse(uint8_t *_dst, const int16_t *coeffs, ptrdiff_t _stride)
285285 {
286286 uint8_t *dst = (uint8_t*)_dst;
287287 ptrdiff_t stride = _stride;
341341
342342
343343 #if HAVE_SSE4_1
344 void ff_hevc_transform_4x4_luma_add_8_sse4(uint8_t *_dst, int16_t *coeffs,
344 void ff_hevc_transform_4x4_luma_add_8_sse4(uint8_t *_dst, const int16_t *coeffs,
345345 ptrdiff_t _stride) {
346346
347347 uint8_t shift_2nd = 12; // 20 - Bit depth
349349
350350 uint8_t *dst = (uint8_t*) _dst;
351351 ptrdiff_t stride = _stride;
352 int16_t *src = coeffs;
352 const int16_t *src = coeffs;
353353 __m128i m128iAdd, S0, S8, m128iTmp1, m128iTmp2, m128iAC, m128iBD, m128iA,
354354 m128iD;
355355 m128iAdd = _mm_set1_epi32(64);
495495 #endif // SSE4.1
496496
497497 #if 0
498 void ff_hevc_transform_4x4_luma_add_10_sse4(uint8_t *_dst, int16_t *coeffs,
498 void ff_hevc_transform_4x4_luma_add_10_sse4(uint8_t *_dst, const int16_t *coeffs,
499499 ptrdiff_t _stride) {
500500 int i,j;
501501 uint8_t shift_2nd = 10; // 20 - Bit depth
622622
623623
624624 #if HAVE_SSE4_1
625 void ff_hevc_transform_4x4_add_8_sse4(uint8_t *_dst, int16_t *coeffs,
625 void ff_hevc_transform_4x4_add_8_sse4(uint8_t *_dst, const int16_t *coeffs,
626626 ptrdiff_t _stride) {
627627 uint8_t shift_2nd = 12; // 20 - Bit depth
628628 uint16_t add_2nd = 1 << 11; //(1 << (shift_2nd - 1))
629629
630630 uint8_t *dst = (uint8_t*) _dst;
631631 ptrdiff_t stride = _stride;
632 int16_t *src = coeffs;
632 const int16_t *src = coeffs;
633633
634634 __m128i S0, S8, m128iAdd, m128Tmp, E1, E2, O1, O2, m128iA, m128iD, m128iTmp1,m128iTmp2;
635635 S0 = _mm_load_si128((__m128i *) (src));
743743 #endif
744744
745745 #if 0
746 void ff_hevc_transform_4x4_add_10_sse4(uint8_t *_dst, int16_t *coeffs,
746 void ff_hevc_transform_4x4_add_10_sse4(uint8_t *_dst, const int16_t *coeffs,
747747 ptrdiff_t _stride) {
748748 int i;
749749 uint8_t shift_2nd = 10; // 20 - Bit depth
838838 #endif
839839
840840 #if HAVE_SSE4_1
841 void ff_hevc_transform_8x8_add_8_sse4(uint8_t *_dst, int16_t *coeffs,
841 void ff_hevc_transform_8x8_add_8_sse4(uint8_t *_dst, const int16_t *coeffs,
842842 ptrdiff_t _stride) {
843843 uint8_t shift_2nd = 12; // 20 - Bit depth
844844 uint16_t add_2nd = 1 << 11; //(1 << (shift_2nd - 1))
845845
846846 uint8_t *dst = (uint8_t*) _dst;
847847 ptrdiff_t stride = _stride / sizeof(uint8_t);
848 int16_t *src = coeffs;
848 const int16_t *src = coeffs;
849849 __m128i m128iS0, m128iS1, m128iS2, m128iS3, m128iS4, m128iS5, m128iS6,
850850 m128iS7, m128iAdd, m128Tmp0, m128Tmp1, m128Tmp2, m128Tmp3, E0h, E1h,
851851 E2h, E3h, E0l, E1l, E2l, E3l, O0h, O1h, O2h, O3h, O0l, O1l, O2l,
11731173 #endif
11741174
11751175 #if 0
1176 void ff_hevc_transform_8x8_add_10_sse4(uint8_t *_dst, int16_t *coeffs,
1176 void ff_hevc_transform_8x8_add_10_sse4(uint8_t *_dst, const int16_t *coeffs,
11771177 ptrdiff_t _stride) {
11781178 int i;
11791179 uint16_t *dst = (uint16_t*) _dst;
14881488
14891489
14901490 #if HAVE_SSE4_1
1491 void ff_hevc_transform_16x16_add_8_sse4(uint8_t *_dst, int16_t *coeffs,
1491 void ff_hevc_transform_16x16_add_8_sse4(uint8_t *_dst, const int16_t *coeffs,
14921492 ptrdiff_t _stride) {
14931493 uint8_t shift_2nd = 12; // 20 - Bit depth
14941494 uint16_t add_2nd = 1 << 11; //(1 << (shift_2nd - 1))
14951495 int i;
14961496 uint8_t *dst = (uint8_t*) _dst;
14971497 ptrdiff_t stride = _stride / sizeof(uint8_t);
1498 int16_t *src = coeffs;
1498 const int16_t *src = coeffs;
14991499 int32_t shift;
15001500 __m128i m128iS0, m128iS1, m128iS2, m128iS3, m128iS4, m128iS5, m128iS6,
15011501 m128iS7, m128iS8, m128iS9, m128iS10, m128iS11, m128iS12, m128iS13,
22452245
22462246
22472247 #if 0
2248 void ff_hevc_transform_16x16_add_10_sse4(uint8_t *_dst, int16_t *coeffs,
2248 void ff_hevc_transform_16x16_add_10_sse4(uint8_t *_dst, const int16_t *coeffs,
22492249 ptrdiff_t _stride) {
22502250 int i;
22512251 uint16_t *dst = (uint16_t*) _dst;
29082908
29092909
29102910 #if HAVE_SSE4_1
2911 void ff_hevc_transform_32x32_add_8_sse4(uint8_t *_dst, int16_t *coeffs,
2911 void ff_hevc_transform_32x32_add_8_sse4(uint8_t *_dst, const int16_t *coeffs,
29122912 ptrdiff_t _stride) {
29132913 uint8_t shift_2nd = 12; // 20 - Bit depth
29142914 uint16_t add_2nd = 1 << 11; //(1 << (shift_2nd - 1))
29162916 uint8_t *dst = (uint8_t*) _dst;
29172917 ptrdiff_t stride = _stride / sizeof(uint8_t);
29182918 int shift;
2919 int16_t *src = coeffs;
2919 const int16_t *src = coeffs;
29202920
29212921 __m128i m128iS0, m128iS1, m128iS2, m128iS3, m128iS4, m128iS5, m128iS6,
29222922 m128iS7, m128iS8, m128iS9, m128iS10, m128iS11, m128iS12, m128iS13,
52005200
52015201
52025202 #if 0
5203 void ff_hevc_transform_32x32_add_10_sse4(uint8_t *_dst, int16_t *coeffs,
5203 void ff_hevc_transform_32x32_add_10_sse4(uint8_t *_dst, const int16_t *coeffs,
52045204 ptrdiff_t _stride) {
52055205 int i, j;
52065206 uint16_t *dst = (uint16_t*) _dst;
2424 #include <stddef.h>
2525 #include <stdint.h>
2626
27 void ff_hevc_transform_skip_8_sse(uint8_t *_dst, int16_t *coeffs, ptrdiff_t _stride);
28 void ff_hevc_transform_4x4_luma_add_8_sse4(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
29 void ff_hevc_transform_4x4_add_8_sse4(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
30 void ff_hevc_transform_8x8_add_8_sse4(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
31 void ff_hevc_transform_16x16_add_8_sse4(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
32 void ff_hevc_transform_32x32_add_8_sse4(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
27 void ff_hevc_transform_skip_8_sse(uint8_t *_dst, const int16_t *coeffs, ptrdiff_t _stride);
28 void ff_hevc_transform_4x4_luma_add_8_sse4(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride);
29 void ff_hevc_transform_4x4_add_8_sse4(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride);
30 void ff_hevc_transform_8x8_add_8_sse4(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride);
31 void ff_hevc_transform_16x16_add_8_sse4(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride);
32 void ff_hevc_transform_32x32_add_8_sse4(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride);
3333
3434 #endif
8585 #define BIT_DEPTH 8
8686
8787 void ff_hevc_put_unweighted_pred_8_sse(uint8_t *_dst, ptrdiff_t dststride,
88 int16_t *src, ptrdiff_t srcstride, int width, int height) {
88 const int16_t *src, ptrdiff_t srcstride,
89 int width, int height) {
8990 int x, y;
9091 uint8_t *dst = (uint8_t*) _dst;
9192 __m128i r0, r1, f0;
168169 }
169170
170171 void ff_hevc_put_unweighted_pred_sse(uint8_t *_dst, ptrdiff_t _dststride,
171 int16_t *src, ptrdiff_t srcstride, int width, int height) {
172 const int16_t *src, ptrdiff_t srcstride,
173 int width, int height) {
172174 int x, y;
173175 uint8_t *dst = (uint8_t*) _dst;
174176 ptrdiff_t dststride = _dststride / sizeof(uint8_t);
202204 }
203205
204206 void ff_hevc_put_weighted_pred_avg_8_sse(uint8_t *_dst, ptrdiff_t dststride,
205 int16_t *src1, int16_t *src2, ptrdiff_t srcstride, int width,
206 int height) {
207 const int16_t *src1, const int16_t *src2,
208 ptrdiff_t srcstride, int width,
209 int height) {
207210 int x, y;
208211 uint8_t *dst = (uint8_t*) _dst;
209212 __m128i r0, r1, f0, r2, r3;
306309 }
307310
308311 void ff_hevc_put_weighted_pred_avg_sse(uint8_t *_dst, ptrdiff_t _dststride,
309 int16_t *src1, int16_t *src2, ptrdiff_t srcstride, int width,
310 int height) {
312 const int16_t *src1, const int16_t *src2,
313 ptrdiff_t srcstride, int width,
314 int height) {
311315 int x, y;
312316 uint8_t *dst = (uint8_t*) _dst;
313317 ptrdiff_t dststride = _dststride / sizeof(uint8_t);
345349
346350 #if 0
347351 void ff_hevc_weighted_pred_8_sse4(uint8_t denom, int16_t wlxFlag, int16_t olxFlag,
348 uint8_t *_dst, ptrdiff_t _dststride, int16_t *src, ptrdiff_t srcstride,
349 int width, int height) {
352 uint8_t *_dst, ptrdiff_t _dststride,
353 const int16_t *src, ptrdiff_t srcstride,
354 int width, int height) {
350355
351356 int log2Wd;
352357 int x, y;
586591
587592 #if 0
588593 void ff_hevc_weighted_pred_sse(uint8_t denom, int16_t wlxFlag, int16_t olxFlag,
589 uint8_t *_dst, ptrdiff_t _dststride, int16_t *src, ptrdiff_t srcstride,
590 int width, int height) {
594 uint8_t *_dst, ptrdiff_t _dststride,
595 const int16_t *src, ptrdiff_t srcstride,
596 int width, int height) {
591597
592598 int log2Wd;
593599 int x, y;
671677
672678 #if HAVE_SSE4_1
673679 void ff_hevc_weighted_pred_avg_8_sse4(uint8_t denom, int16_t wl0Flag,
674 int16_t wl1Flag, int16_t ol0Flag, int16_t ol1Flag, uint8_t *_dst,
675 ptrdiff_t _dststride, int16_t *src1, int16_t *src2, ptrdiff_t srcstride,
676 int width, int height) {
680 int16_t wl1Flag, int16_t ol0Flag, int16_t ol1Flag,
681 uint8_t *_dst, ptrdiff_t _dststride,
682 const int16_t *src1, const int16_t *src2, ptrdiff_t srcstride,
683 int width, int height) {
677684 int shift, shift2;
678685 int log2Wd;
679686 int o0;
868875 #if 0
869876 void ff_hevc_weighted_pred_avg_sse(uint8_t denom, int16_t wl0Flag,
870877 int16_t wl1Flag, int16_t ol0Flag, int16_t ol1Flag, uint8_t *_dst,
871 ptrdiff_t _dststride, int16_t *src1, int16_t *src2, ptrdiff_t srcstride,
878 ptrdiff_t _dststride, const int16_t *src1, const int16_t *src2, ptrdiff_t srcstride,
872879 int width, int height) {
873880 int shift, shift2;
874881 int log2Wd;
942949
943950
944951 void ff_hevc_put_hevc_epel_pixels_8_sse(int16_t *dst, ptrdiff_t dststride,
945 uint8_t *_src, ptrdiff_t srcstride, int width, int height, int mx,
946 int my, int16_t* mcbuffer) {
952 const uint8_t *_src, ptrdiff_t srcstride,
953 int width, int height, int mx,
954 int my, int16_t* mcbuffer) {
947955 int x, y;
948956 __m128i x1, x2,x3;
949957 uint8_t *src = (uint8_t*) _src;
10191027
10201028 #ifndef __native_client__
10211029 void ff_hevc_put_hevc_epel_pixels_10_sse(int16_t *dst, ptrdiff_t dststride,
1022 uint8_t *_src, ptrdiff_t _srcstride, int width, int height, int mx,
1023 int my, int16_t* mcbuffer) {
1030 const uint8_t *_src, ptrdiff_t _srcstride,
1031 int width, int height, int mx,
1032 int my, int16_t* mcbuffer) {
10241033 int x, y;
10251034 __m128i x2;
10261035 uint16_t *src = (uint16_t*) _src;
10701079 #endif
10711080
10721081 void ff_hevc_put_hevc_epel_h_8_sse(int16_t *dst, ptrdiff_t dststride,
1073 uint8_t *_src, ptrdiff_t _srcstride, int width, int height, int mx,
1074 int my, int16_t* mcbuffer) {
1082 const uint8_t *_src, ptrdiff_t _srcstride,
1083 int width, int height, int mx,
1084 int my, int16_t* mcbuffer, int bit_depth) {
10751085 int x, y;
1076 uint8_t *src = (uint8_t*) _src;
1086 const uint8_t *src = (const uint8_t*) _src;
10771087 ptrdiff_t srcstride = _srcstride;
10781088 const int8_t *filter = epel_filters[mx - 1];
10791089 __m128i r0, bshuffle1, bshuffle2, x1, x2, x3;
11671177
11681178 #ifndef __native_client__
11691179 void ff_hevc_put_hevc_epel_h_10_sse(int16_t *dst, ptrdiff_t dststride,
1170 uint8_t *_src, ptrdiff_t _srcstride, int width, int height, int mx,
1171 int my, int16_t* mcbuffer) {
1180 const uint8_t *_src, ptrdiff_t _srcstride,
1181 int width, int height, int mx,
1182 int my, int16_t* mcbuffer) {
11721183 int x, y;
11731184 uint16_t *src = (uint16_t*) _src;
11741185 ptrdiff_t srcstride = _srcstride>>1;
12291240
12301241
12311242 void ff_hevc_put_hevc_epel_v_8_sse(int16_t *dst, ptrdiff_t dststride,
1232 uint8_t *_src, ptrdiff_t _srcstride, int width, int height, int mx,
1233 int my, int16_t* mcbuffer) {
1243 const uint8_t *_src, ptrdiff_t _srcstride, int width, int height, int mx,
1244 int my, int16_t* mcbuffer, int bit_depth) {
12341245 int x, y;
12351246 __m128i x0, x1, x2, x3, t0, t1, t2, t3, r0, f0, f1, f2, f3, r1;
12361247 uint8_t *src = (uint8_t*) _src;
13681379
13691380 #ifndef __native_client__
13701381 void ff_hevc_put_hevc_epel_v_10_sse(int16_t *dst, ptrdiff_t dststride,
1371 uint8_t *_src, ptrdiff_t _srcstride, int width, int height, int mx,
1382 const uint8_t *_src, ptrdiff_t _srcstride, int width, int height, int mx,
13721383 int my, int16_t* mcbuffer) {
13731384 int x, y;
13741385 __m128i x0, x1, x2, x3, t0, t1, t2, t3, r0, f0, f1, f2, f3, r1, r2, r3;
15351546 #endif
15361547
15371548 void ff_hevc_put_hevc_epel_hv_8_sse(int16_t *dst, ptrdiff_t dststride,
1538 uint8_t *_src, ptrdiff_t _srcstride, int width, int height, int mx,
1539 int my, int16_t* mcbuffer) {
1549 const uint8_t *_src, ptrdiff_t _srcstride, int width, int height, int mx,
1550 int my, int16_t* mcbuffer, int bit_depth) {
15401551 int x, y;
15411552 uint8_t *src = (uint8_t*) _src;
15421553 ptrdiff_t srcstride = _srcstride;
17621773
17631774 #ifndef __native_client__
17641775 void ff_hevc_put_hevc_epel_hv_10_sse(int16_t *dst, ptrdiff_t dststride,
1765 uint8_t *_src, ptrdiff_t _srcstride, int width, int height, int mx,
1776 const uint8_t *_src, ptrdiff_t _srcstride, int width, int height, int mx,
17661777 int my, int16_t* mcbuffer) {
17671778 int x, y;
17681779 uint16_t *src = (uint16_t*) _src;
19241935 #endif
19251936
19261937 void ff_hevc_put_hevc_qpel_pixels_8_sse(int16_t *dst, ptrdiff_t dststride,
1927 uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
1938 const uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
19281939 int16_t* mcbuffer) {
19291940 int x, y;
19301941 __m128i x1, x2, x3, x0;
19982009
19992010 #ifndef __native_client__
20002011 void ff_hevc_put_hevc_qpel_pixels_10_sse(int16_t *dst, ptrdiff_t dststride,
2001 uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
2012 const uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
20022013 int16_t* mcbuffer) {
20032014 int x, y;
20042015 __m128i x1, x2, x4;
20452056
20462057
20472058 void ff_hevc_put_hevc_qpel_h_1_8_sse(int16_t *dst, ptrdiff_t dststride,
2048 uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
2059 const uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
20492060 int16_t* mcbuffer) {
20502061 int x, y;
2051 uint8_t *src = _src;
2062 const uint8_t *src = _src;
20522063 ptrdiff_t srcstride = _srcstride / sizeof(uint8_t);
20532064 __m128i x1, r0, x2, x3, x4, x5;
20542065
21442155 * @TODO : Valgrind to see if it's useful to use SSE or wait for AVX2 implementation
21452156 */
21462157 void ff_hevc_put_hevc_qpel_h_1_10_sse(int16_t *dst, ptrdiff_t dststride,
2147 uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
2158 const uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
21482159 int16_t* mcbuffer) {
21492160 int x, y;
21502161 uint16_t *src = (uint16_t*)_src;
21782189
21792190
21802191 void ff_hevc_put_hevc_qpel_h_2_8_sse(int16_t *dst, ptrdiff_t dststride,
2181 uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
2192 const uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
21822193 int16_t* mcbuffer) {
21832194 int x, y;
2184 uint8_t *src = _src;
2195 const uint8_t *src = _src;
21852196 ptrdiff_t srcstride = _srcstride / sizeof(uint8_t);
21862197 __m128i x1, r0, x2, x3, x4, x5;
21872198
22482259
22492260 #if 0
22502261 static void ff_hevc_put_hevc_qpel_h_2_sse(int16_t *dst, ptrdiff_t dststride,
2251 uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
2262 const uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
22522263 int16_t* mcbuffer) {
22532264 int x, y;
22542265 uint8_t *src = _src;
23162327
23172328 }
23182329 static void ff_hevc_put_hevc_qpel_h_3_sse(int16_t *dst, ptrdiff_t dststride,
2319 uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
2330 const uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
23202331 int16_t* mcbuffer) {
23212332 int x, y;
23222333 uint8_t *src = _src;
23832394 #endif
23842395
23852396 void ff_hevc_put_hevc_qpel_h_3_8_sse(int16_t *dst, ptrdiff_t dststride,
2386 uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
2397 const uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
23872398 int16_t* mcbuffer) {
23882399 int x, y;
2389 uint8_t *src = _src;
2400 const uint8_t *src = _src;
23902401 ptrdiff_t srcstride = _srcstride / sizeof(uint8_t);
23912402 __m128i x1, r0, x2, x3, x4, x5;
23922403
24512462
24522463 */
24532464 void ff_hevc_put_hevc_qpel_v_1_8_sse(int16_t *dst, ptrdiff_t dststride,
2454 uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
2465 const uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
24552466 int16_t* mcbuffer) {
24562467 int x, y;
24572468 uint8_t *src = (uint8_t*) _src;
26102621
26112622 #if 0
26122623 void ff_hevc_put_hevc_qpel_v_1_10_sse4(int16_t *dst, ptrdiff_t dststride,
2613 uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
2624 const uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
26142625 int16_t* mcbuffer) {
26152626 int x, y;
26162627 uint16_t *src = (uint16_t*) _src;
26872698
26882699
26892700 void ff_hevc_put_hevc_qpel_v_2_8_sse(int16_t *dst, ptrdiff_t dststride,
2690 uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
2701 const uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
26912702 int16_t* mcbuffer) {
26922703 int x, y;
26932704 uint8_t *src = (uint8_t*) _src;
28622873
28632874 #if 0
28642875 void ff_hevc_put_hevc_qpel_v_2_10_sse(int16_t *dst, ptrdiff_t dststride,
2865 uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
2876 cosnt uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
28662877 int16_t* mcbuffer) {
28672878 int x, y;
28682879 uint16_t *src = (uint16_t*) _src;
29532964
29542965 #if 0
29552966 static void ff_hevc_put_hevc_qpel_v_3_sse(int16_t *dst, ptrdiff_t dststride,
2956 uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
2967 const uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
29572968 int16_t* mcbuffer) {
29582969 int x, y;
29592970 uint8_t *src = (uint8_t*) _src;
31203131 #endif
31213132
31223133 void ff_hevc_put_hevc_qpel_v_3_8_sse(int16_t *dst, ptrdiff_t dststride,
3123 uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
3134 const uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
31243135 int16_t* mcbuffer) {
31253136 int x, y;
31263137 uint8_t *src = (uint8_t*) _src;
32753286
32763287 #if 0
32773288 void ff_hevc_put_hevc_qpel_v_3_10_sse(int16_t *dst, ptrdiff_t dststride,
3278 uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
3289 const uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
32793290 int16_t* mcbuffer) {
32803291 int x, y;
32813292 uint16_t *src = (uint16_t*) _src;
33513362
33523363
33533364 void ff_hevc_put_hevc_qpel_h_1_v_1_sse(int16_t *dst, ptrdiff_t dststride,
3354 uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
3365 const uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
33553366 int16_t* mcbuffer) {
33563367 int x, y;
33573368 uint8_t* src = (uint8_t*) _src;
35233534 }
35243535 }
35253536 void ff_hevc_put_hevc_qpel_h_1_v_2_sse(int16_t *dst, ptrdiff_t dststride,
3526 uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
3537 const uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
35273538 int16_t* mcbuffer) {
35283539 int x, y;
35293540 uint8_t *src = (uint8_t*) _src;
37063717 }
37073718 }
37083719 void ff_hevc_put_hevc_qpel_h_1_v_3_sse(int16_t *dst, ptrdiff_t dststride,
3709 uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
3720 const uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
37103721 int16_t* mcbuffer) {
37113722 int x, y;
37123723 uint8_t *src = (uint8_t*) _src;
38833894 }
38843895 }
38853896 void ff_hevc_put_hevc_qpel_h_2_v_1_sse(int16_t *dst, ptrdiff_t dststride,
3886 uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
3897 const uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
38873898 int16_t* mcbuffer) {
38883899 int x, y;
38893900 uint8_t *src = (uint8_t*) _src;
40544065 }
40554066 }
40564067 void ff_hevc_put_hevc_qpel_h_2_v_2_sse(int16_t *dst, ptrdiff_t dststride,
4057 uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
4068 const uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
40584069 int16_t* mcbuffer) {
40594070 int x, y;
40604071 uint8_t *src = (uint8_t*) _src;
42374248 }
42384249 }
42394250 void ff_hevc_put_hevc_qpel_h_2_v_3_sse(int16_t *dst, ptrdiff_t dststride,
4240 uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
4251 const uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
42414252 int16_t* mcbuffer) {
42424253 int x, y;
42434254 uint8_t *src = (uint8_t*) _src;
44154426 }
44164427 }
44174428 void ff_hevc_put_hevc_qpel_h_3_v_1_sse(int16_t *dst, ptrdiff_t dststride,
4418 uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
4429 const uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
44194430 int16_t* mcbuffer) {
44204431 int x, y;
44214432 uint8_t *src = (uint8_t*) _src;
45884599 }
45894600 }
45904601 void ff_hevc_put_hevc_qpel_h_3_v_2_sse(int16_t *dst, ptrdiff_t dststride,
4591 uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
4602 const uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
45924603 int16_t* mcbuffer) {
45934604 int x, y;
45944605 uint8_t *src = (uint8_t*) _src;
47744785 }
47754786 }
47764787 void ff_hevc_put_hevc_qpel_h_3_v_3_sse(int16_t *dst, ptrdiff_t dststride,
4777 uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
4788 const uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
47784789 int16_t* mcbuffer) {
47794790 int x, y;
47804791 uint8_t *src = (uint8_t*) _src;
2626
2727
2828 void ff_hevc_put_unweighted_pred_8_sse(uint8_t *_dst, ptrdiff_t dststride,
29 int16_t *src, ptrdiff_t srcstride,
30 int width, int height);
29 const int16_t *src, ptrdiff_t srcstride,
30 int width, int height);
3131
3232 void ff_hevc_put_weighted_pred_avg_8_sse(uint8_t *_dst, ptrdiff_t dststride,
33 int16_t *src1, int16_t *src2,
34 ptrdiff_t srcstride, int width,
35 int height);
33 const int16_t *src1, const int16_t *src2,
34 ptrdiff_t srcstride, int width,
35 int height);
3636
3737 void ff_hevc_put_hevc_epel_pixels_8_sse(int16_t *dst, ptrdiff_t dststride,
38 uint8_t *_src, ptrdiff_t srcstride,
38 const uint8_t *_src, ptrdiff_t srcstride,
3939 int width, int height,
4040 int mx, int my, int16_t* mcbuffer);
4141 void ff_hevc_put_hevc_epel_h_8_sse(int16_t *dst, ptrdiff_t dststride,
42 uint8_t *_src, ptrdiff_t srcstride,
42 const uint8_t *_src, ptrdiff_t srcstride,
4343 int width, int height,
44 int mx, int my, int16_t* mcbuffer);
44 int mx, int my, int16_t* mcbuffer, int bit_depth);
4545 void ff_hevc_put_hevc_epel_v_8_sse(int16_t *dst, ptrdiff_t dststride,
46 uint8_t *_src, ptrdiff_t srcstride,
46 const uint8_t *_src, ptrdiff_t srcstride,
4747 int width, int height,
48 int mx, int my, int16_t* mcbuffer);
48 int mx, int my, int16_t* mcbuffer, int bit_depth);
4949 void ff_hevc_put_hevc_epel_hv_8_sse(int16_t *dst, ptrdiff_t dststride,
50 uint8_t *_src, ptrdiff_t srcstride,
50 const uint8_t *_src, ptrdiff_t srcstride,
5151 int width, int height,
52 int mx, int my, int16_t* mcbuffer);
52 int mx, int my, int16_t* mcbuffer, int bit_depth);
5353
5454 void ff_hevc_put_hevc_qpel_pixels_8_sse(int16_t *dst, ptrdiff_t dststride,
55 uint8_t *src, ptrdiff_t srcstride,
56 int width, int height, int16_t* mcbuffer);
55 const uint8_t *src, ptrdiff_t srcstride,
56 int width, int height, int16_t* mcbuffer);
5757 void ff_hevc_put_hevc_qpel_v_1_8_sse(int16_t *dst, ptrdiff_t dststride,
58 uint8_t *src, ptrdiff_t srcstride,
59 int width, int height, int16_t* mcbuffer);
58 const uint8_t *src, ptrdiff_t srcstride,
59 int width, int height, int16_t* mcbuffer);
6060 void ff_hevc_put_hevc_qpel_v_2_8_sse(int16_t *dst, ptrdiff_t dststride,
61 uint8_t *src, ptrdiff_t srcstride,
62 int width, int height, int16_t* mcbuffer);
61 const uint8_t *src, ptrdiff_t srcstride,
62 int width, int height, int16_t* mcbuffer);
6363 void ff_hevc_put_hevc_qpel_v_3_8_sse(int16_t *dst, ptrdiff_t dststride,
64 uint8_t *src, ptrdiff_t srcstride,
65 int width, int height, int16_t* mcbuffer);
64 const uint8_t *src, ptrdiff_t srcstride,
65 int width, int height, int16_t* mcbuffer);
6666 void ff_hevc_put_hevc_qpel_h_1_8_sse(int16_t *dst, ptrdiff_t dststride,
67 uint8_t *src, ptrdiff_t srcstride,
67 const uint8_t *src, ptrdiff_t srcstride,
6868 int width, int height, int16_t* mcbuffer);
6969 void ff_hevc_put_hevc_qpel_h_1_v_1_sse(int16_t *dst, ptrdiff_t dststride,
70 uint8_t *src, ptrdiff_t srcstride,
71 int width, int height, int16_t* mcbuffer);
70 const uint8_t *src, ptrdiff_t srcstride,
71 int width, int height, int16_t* mcbuffer);
7272 void ff_hevc_put_hevc_qpel_h_1_v_2_sse(int16_t *dst, ptrdiff_t dststride,
73 uint8_t *src, ptrdiff_t srcstride,
74 int width, int height, int16_t* mcbuffer);
73 const uint8_t *src, ptrdiff_t srcstride,
74 int width, int height, int16_t* mcbuffer);
7575 void ff_hevc_put_hevc_qpel_h_1_v_3_sse(int16_t *dst, ptrdiff_t dststride,
76 uint8_t *src, ptrdiff_t srcstride,
77 int width, int height, int16_t* mcbuffer);
76 const uint8_t *src, ptrdiff_t srcstride,
77 int width, int height, int16_t* mcbuffer);
7878 void ff_hevc_put_hevc_qpel_h_2_8_sse(int16_t *dst, ptrdiff_t dststride,
79 uint8_t *src, ptrdiff_t srcstride,
79 const uint8_t *src, ptrdiff_t srcstride,
8080 int width, int height, int16_t* mcbuffer);
8181 void ff_hevc_put_hevc_qpel_h_2_v_1_sse(int16_t *dst, ptrdiff_t dststride,
82 uint8_t *src, ptrdiff_t srcstride,
83 int width, int height, int16_t* mcbuffer);
82 const uint8_t *src, ptrdiff_t srcstride,
83 int width, int height, int16_t* mcbuffer);
8484 void ff_hevc_put_hevc_qpel_h_2_v_2_sse(int16_t *dst, ptrdiff_t dststride,
85 uint8_t *src, ptrdiff_t srcstride,
86 int width, int height, int16_t* mcbuffer);
85 const uint8_t *src, ptrdiff_t srcstride,
86 int width, int height, int16_t* mcbuffer);
8787 void ff_hevc_put_hevc_qpel_h_2_v_3_sse(int16_t *dst, ptrdiff_t dststride,
88 uint8_t *src, ptrdiff_t srcstride,
89 int width, int height, int16_t* mcbuffer);
88 const uint8_t *src, ptrdiff_t srcstride,
89 int width, int height, int16_t* mcbuffer);
9090 void ff_hevc_put_hevc_qpel_h_3_8_sse(int16_t *dst, ptrdiff_t dststride,
91 uint8_t *src, ptrdiff_t srcstride,
91 const uint8_t *src, ptrdiff_t srcstride,
9292 int width, int height, int16_t* mcbuffer);
9393 void ff_hevc_put_hevc_qpel_h_3_v_1_sse(int16_t *dst, ptrdiff_t dststride,
94 uint8_t *src, ptrdiff_t srcstride,
95 int width, int height, int16_t* mcbuffer);
94 const uint8_t *src, ptrdiff_t srcstride,
95 int width, int height, int16_t* mcbuffer);
9696 void ff_hevc_put_hevc_qpel_h_3_v_2_sse(int16_t *dst, ptrdiff_t dststride,
97 uint8_t *src, ptrdiff_t srcstride,
98 int width, int height, int16_t* mcbuffer);
97 const uint8_t *src, ptrdiff_t srcstride,
98 int width, int height, int16_t* mcbuffer);
9999 void ff_hevc_put_hevc_qpel_h_3_v_3_sse(int16_t *dst, ptrdiff_t dststride,
100 uint8_t *src, ptrdiff_t srcstride,
101 int width, int height, int16_t* mcbuffer);
100 const uint8_t *src, ptrdiff_t srcstride,
101 int width, int height, int16_t* mcbuffer);
102102
103103 #endif
9494 //accel->transform_4x4_luma_add_8 = ff_hevc_transform_4x4_luma_add_8_sse4; // SSE-4 only TODO
9595 //accel->transform_4x4_add_8 = ff_hevc_transform_4x4_add_8_sse4;
9696
97 accel->transform_8x8_add_8 = ff_hevc_transform_8x8_add_8_sse4;
98 accel->transform_16x16_add_8 = ff_hevc_transform_16x16_add_8_sse4;
99 accel->transform_32x32_add_8 = ff_hevc_transform_32x32_add_8_sse4;
97 accel->transform_add_8[1] = ff_hevc_transform_8x8_add_8_sse4;
98 accel->transform_add_8[2] = ff_hevc_transform_16x16_add_8_sse4;
99 accel->transform_add_8[3] = ff_hevc_transform_32x32_add_8_sse4;
100100 }
101101 #endif
102102 }
0 # ============================================================================
1 # http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
2 # ============================================================================
3 #
4 # SYNOPSIS
5 #
6 # AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional])
7 #
8 # DESCRIPTION
9 #
10 # Check for baseline language coverage in the compiler for the C++11
11 # standard; if necessary, add switches to CXXFLAGS to enable support.
12 #
13 # The first argument, if specified, indicates whether you insist on an
14 # extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
15 # -std=c++11). If neither is specified, you get whatever works, with
16 # preference for an extended mode.
17 #
18 # The second argument, if specified 'mandatory' or if left unspecified,
19 # indicates that baseline C++11 support is required and that the macro
20 # should error out if no mode with that support is found. If specified
21 # 'optional', then configuration proceeds regardless, after defining
22 # HAVE_CXX11 if and only if a supporting mode is found.
23 #
24 # LICENSE
25 #
26 # Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
27 # Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
28 # Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
29 # Copyright (c) 2014 Alexey Sokolov <sokolov@google.com>
30 #
31 # Copying and distribution of this file, with or without modification, are
32 # permitted in any medium without royalty provided the copyright notice
33 # and this notice are preserved. This file is offered as-is, without any
34 # warranty.
35
36 #serial 4
37
38 m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [[
39 template <typename T>
40 struct check
41 {
42 static_assert(sizeof(int) <= sizeof(T), "not big enough");
43 };
44
45 struct Base {
46 virtual void f() {}
47 };
48 struct Child : public Base {
49 virtual void f() {} // DiFa: override {} # override not supported in gcc 4.6
50 };
51
52 typedef check<check<bool>> right_angle_brackets;
53
54 int a;
55 decltype(a) b;
56
57 typedef check<int> check_type;
58 check_type c;
59 check_type&& cr = static_cast<check_type&&>(c);
60
61 auto d = a;
62 auto l = [](){};
63 ]])
64
65 AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
66 m4_if([$1], [], [],
67 [$1], [ext], [],
68 [$1], [noext], [],
69 [m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl
70 m4_if([$2], [], [ax_cxx_compile_cxx11_required=true],
71 [$2], [mandatory], [ax_cxx_compile_cxx11_required=true],
72 [$2], [optional], [ax_cxx_compile_cxx11_required=false],
73 [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_11])])
74 AC_LANG_PUSH([C++])dnl
75 ac_success=no
76 AC_CACHE_CHECK(whether $CXX supports C++11 features by default,
77 ax_cv_cxx_compile_cxx11,
78 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
79 [ax_cv_cxx_compile_cxx11=yes],
80 [ax_cv_cxx_compile_cxx11=no])])
81 if test x$ax_cv_cxx_compile_cxx11 = xyes; then
82 ac_success=yes
83 fi
84
85 m4_if([$1], [noext], [], [dnl
86 if test x$ac_success = xno; then
87 for switch in -std=gnu++11 -std=gnu++0x; do
88 cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
89 AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
90 $cachevar,
91 [ac_save_CXXFLAGS="$CXXFLAGS"
92 CXXFLAGS="$CXXFLAGS $switch"
93 AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
94 [eval $cachevar=yes],
95 [eval $cachevar=no])
96 CXXFLAGS="$ac_save_CXXFLAGS"])
97 if eval test x\$$cachevar = xyes; then
98 CXXFLAGS="$CXXFLAGS $switch"
99 ac_success=yes
100 break
101 fi
102 done
103 fi])
104
105 m4_if([$1], [ext], [], [dnl
106 if test x$ac_success = xno; then
107 for switch in -std=c++11 -std=c++0x; do
108 cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
109 AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
110 $cachevar,
111 [ac_save_CXXFLAGS="$CXXFLAGS"
112 CXXFLAGS="$CXXFLAGS $switch"
113 AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
114 [eval $cachevar=yes],
115 [eval $cachevar=no])
116 CXXFLAGS="$ac_save_CXXFLAGS"])
117 if eval test x\$$cachevar = xyes; then
118 CXXFLAGS="$CXXFLAGS $switch"
119 ac_success=yes
120 break
121 fi
122 done
123 fi])
124 AC_LANG_POP([C++])
125 if test x$ax_cxx_compile_cxx11_required = xtrue; then
126 if test x$ac_success = xno; then
127 AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.])
128 fi
129 else
130 if test x$ac_success = xno; then
131 HAVE_CXX11=0
132 AC_MSG_NOTICE([No compiler with C++11 support was found])
133 else
134 HAVE_CXX11=1
135 AC_DEFINE(HAVE_CXX11,1,
136 [define if the compiler supports basic C++11 syntax])
137 fi
138
139 AC_SUBST(HAVE_CXX11)
140 fi
141 ])
+0
-52
m4/visibility.m4 less more
0 # visibility.m4 serial 1 (gettext-0.15)
1 dnl Copyright (C) 2005 Free Software Foundation, Inc.
2 dnl This file is free software; the Free Software Foundation
3 dnl gives unlimited permission to copy and/or distribute it,
4 dnl with or without modifications, as long as this notice is preserved.
5
6 dnl From Bruno Haible.
7
8 dnl Tests whether the compiler supports the command-line option
9 dnl -fvisibility=hidden and the function and variable attributes
10 dnl __attribute__((__visibility__("hidden"))) and
11 dnl __attribute__((__visibility__("default"))).
12 dnl Does *not* test for __visibility__("protected") - which has tricky
13 dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on
14 dnl MacOS X.
15 dnl Does *not* test for __visibility__("internal") - which has processor
16 dnl dependent semantics.
17 dnl Does *not* test for #pragma GCC visibility push(hidden) - which is
18 dnl "really only recommended for legacy code".
19 dnl Set the variable CFLAG_VISIBILITY.
20 dnl Defines and sets the variable HAVE_VISIBILITY.
21
22 AC_DEFUN([gl_VISIBILITY],
23 [
24 AC_REQUIRE([AC_PROG_CC])
25 CFLAG_VISIBILITY=
26 HAVE_VISIBILITY=0
27 if test -n "$GCC"; then
28 AC_MSG_CHECKING([for simple visibility declarations])
29 AC_CACHE_VAL(gl_cv_cc_visibility, [
30 gl_save_CFLAGS="$CFLAGS"
31 CFLAGS="$CFLAGS -fvisibility=hidden"
32 AC_TRY_COMPILE(
33 [extern __attribute__((__visibility__("hidden"))) int hiddenvar;
34 extern __attribute__((__visibility__("default"))) int exportedvar;
35 extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
36 extern __attribute__((__visibility__("default"))) int exportedfunc (void);],
37 [],
38 gl_cv_cc_visibility=yes,
39 gl_cv_cc_visibility=no)
40 CFLAGS="$gl_save_CFLAGS"])
41 AC_MSG_RESULT([$gl_cv_cc_visibility])
42 if test $gl_cv_cc_visibility = yes; then
43 CFLAG_VISIBILITY="-fvisibility=hidden"
44 HAVE_VISIBILITY=1
45 fi
46 fi
47 AC_SUBST([CFLAG_VISIBILITY])
48 AC_SUBST([HAVE_VISIBILITY])
49 AC_DEFINE_UNQUOTED([HAVE_VISIBILITY], [$HAVE_VISIBILITY],
50 [Define to 1 or 0, depending whether the compiler supports simple visibility declarations.])
51 ])
8888 $(top_srcdir)/depcomp COPYING README
8989 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
9090 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
91 $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \
9192 $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
9293 $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
9394 $(top_srcdir)/m4/lt~obsolete.m4 \
9495 $(top_srcdir)/m4/m4_ax_check_compile_flag.m4 \
95 $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/configure.ac
96 $(top_srcdir)/configure.ac
9697 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
9798 $(ACLOCAL_M4)
9899 mkinstalldirs = $(install_sh) -d
197198 CTAGS = ctags
198199 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
199200 ACLOCAL = @ACLOCAL@
201 ALLOCA = @ALLOCA@
200202 AMTAR = @AMTAR@
201203 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
202204 AR = @AR@
205207 AUTOMAKE = @AUTOMAKE@
206208 AWK = @AWK@
207209 CC = @CC@
210 CCAS = @CCAS@
211 CCASDEPMODE = @CCASDEPMODE@
212 CCASFLAGS = @CCASFLAGS@
208213 CCDEPMODE = @CCDEPMODE@
209214 CFLAGS = @CFLAGS@
210 CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
211215 CPP = @CPP@
212216 CPPFLAGS = @CPPFLAGS@
213217 CXX = @CXX@
227231 EXEEXT = @EXEEXT@
228232 FGREP = @FGREP@
229233 GREP = @GREP@
230 HAVE_VISIBILITY = @HAVE_VISIBILITY@
234 HAVE_CXX11 = @HAVE_CXX11@
231235 INSTALL = @INSTALL@
232236 INSTALL_DATA = @INSTALL_DATA@
233237 INSTALL_PROGRAM = @INSTALL_PROGRAM@
3232
3333
3434 VideoDecoder::VideoDecoder()
35 : ctx(NULL),
35 : mFH(NULL),
36 ctx(NULL),
3637 img(NULL),
3738 mNextBuffer(0),
3839 mFrameCount(0),
4041 mVideoEnded(false),
4142 mSingleStep(false),
4243 mShowDecodedImage(true),
44 mShowQuantPY(false),
4345 mCBShowPartitioning(false),
4446 mTBShowPartitioning(false),
4547 mPBShowPartitioning(false),
48 mShowIntraPredMode(false),
4649 mShowPBPredMode(false),
47 mShowIntraPredMode(false),
48 mShowQuantPY(false),
4950 mShowMotionVec(false),
50 mShowSlices(false),
5151 mShowTiles(false),
52 mFH(NULL)
52 mShowSlices(false)
5353 #ifdef HAVE_SWSCALE
5454 , sws(NULL)
5555 , width(0)
0
1 bin_PROGRAMS = gen-enc-table yuv-distortion rd-curves block-rate-estim tests bjoentegaard
2
3 AM_CPPFLAGS = -I../libde265
4
5 gen_enc_table_DEPENDENCIES = ../libde265/libde265.la
6 gen_enc_table_CXXFLAGS =
7 gen_enc_table_LDFLAGS =
8 gen_enc_table_LDADD = ../libde265/libde265.la -lstdc++
9 gen_enc_table_SOURCES = gen-entropy-table.cc
10
11 yuv_distortion_DEPENDENCIES = ../libde265/libde265.la
12 yuv_distortion_CXXFLAGS =
13 yuv_distortion_LDFLAGS =
14 yuv_distortion_LDADD = ../libde265/libde265.la -lstdc++
15 yuv_distortion_SOURCES = yuv-distortion.cc
16
17 if HAVE_VIDEOGFX
18 yuv_distortion_CXXFLAGS += $(VIDEOGFX_CFLAGS)
19 yuv_distortion_LDFLAGS += $(VIDEOGFX_LIBS)
20 endif
21
22 rd_curves_DEPENDENCIES = ../libde265/libde265.la
23 rd_curves_CXXFLAGS =
24 rd_curves_LDFLAGS =
25 rd_curves_LDADD = ../libde265/libde265.la -lstdc++
26 rd_curves_SOURCES = rd-curves.cc
27
28 block_rate_estim_DEPENDENCIES = ../libde265/libde265.la
29 block_rate_estim_CXXFLAGS =
30 block_rate_estim_LDFLAGS =
31 block_rate_estim_LDADD = ../libde265/libde265.la -lstdc++
32 block_rate_estim_SOURCES = block-rate-estim.cc
33
34 tests_DEPENDENCIES = ../libde265/libde265.la
35 tests_CXXFLAGS =
36 tests_LDFLAGS =
37 tests_LDADD = ../libde265/libde265.la -lstdc++
38 tests_SOURCES = tests.cc
39
40 bjoentegaard_DEPENDENCIES = ../libde265/libde265.la
41 bjoentegaard_CXXFLAGS =
42 bjoentegaard_LDFLAGS =
43 bjoentegaard_LDADD = ../libde265/libde265.la -lstdc++
44 bjoentegaard_SOURCES = bjoentegaard.cc
45
0 # Makefile.in generated by automake 1.14.1 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15
16 VPATH = @srcdir@
17 am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
18 am__make_running_with_option = \
19 case $${target_option-} in \
20 ?) ;; \
21 *) echo "am__make_running_with_option: internal error: invalid" \
22 "target option '$${target_option-}' specified" >&2; \
23 exit 1;; \
24 esac; \
25 has_opt=no; \
26 sane_makeflags=$$MAKEFLAGS; \
27 if $(am__is_gnu_make); then \
28 sane_makeflags=$$MFLAGS; \
29 else \
30 case $$MAKEFLAGS in \
31 *\\[\ \ ]*) \
32 bs=\\; \
33 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
34 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
35 esac; \
36 fi; \
37 skip_next=no; \
38 strip_trailopt () \
39 { \
40 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
41 }; \
42 for flg in $$sane_makeflags; do \
43 test $$skip_next = yes && { skip_next=no; continue; }; \
44 case $$flg in \
45 *=*|--*) continue;; \
46 -*I) strip_trailopt 'I'; skip_next=yes;; \
47 -*I?*) strip_trailopt 'I';; \
48 -*O) strip_trailopt 'O'; skip_next=yes;; \
49 -*O?*) strip_trailopt 'O';; \
50 -*l) strip_trailopt 'l'; skip_next=yes;; \
51 -*l?*) strip_trailopt 'l';; \
52 -[dEDm]) skip_next=yes;; \
53 -[JT]) skip_next=yes;; \
54 esac; \
55 case $$flg in \
56 *$$target_option*) has_opt=yes; break;; \
57 esac; \
58 done; \
59 test $$has_opt = yes
60 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
61 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
62 pkgdatadir = $(datadir)/@PACKAGE@
63 pkgincludedir = $(includedir)/@PACKAGE@
64 pkglibdir = $(libdir)/@PACKAGE@
65 pkglibexecdir = $(libexecdir)/@PACKAGE@
66 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
67 install_sh_DATA = $(install_sh) -c -m 644
68 install_sh_PROGRAM = $(install_sh) -c
69 install_sh_SCRIPT = $(install_sh) -c
70 INSTALL_HEADER = $(INSTALL_DATA)
71 transform = $(program_transform_name)
72 NORMAL_INSTALL = :
73 PRE_INSTALL = :
74 POST_INSTALL = :
75 NORMAL_UNINSTALL = :
76 PRE_UNINSTALL = :
77 POST_UNINSTALL = :
78 build_triplet = @build@
79 host_triplet = @host@
80 target_triplet = @target@
81 bin_PROGRAMS = gen-enc-table$(EXEEXT) yuv-distortion$(EXEEXT) \
82 rd-curves$(EXEEXT) block-rate-estim$(EXEEXT) tests$(EXEEXT) \
83 bjoentegaard$(EXEEXT)
84 @HAVE_VIDEOGFX_TRUE@am__append_1 = $(VIDEOGFX_CFLAGS)
85 @HAVE_VIDEOGFX_TRUE@am__append_2 = $(VIDEOGFX_LIBS)
86 subdir = tools
87 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
88 $(top_srcdir)/depcomp
89 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
90 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
91 $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \
92 $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
93 $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
94 $(top_srcdir)/m4/lt~obsolete.m4 \
95 $(top_srcdir)/m4/m4_ax_check_compile_flag.m4 \
96 $(top_srcdir)/configure.ac
97 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
98 $(ACLOCAL_M4)
99 mkinstalldirs = $(install_sh) -d
100 CONFIG_HEADER = $(top_builddir)/config.h
101 CONFIG_CLEAN_FILES =
102 CONFIG_CLEAN_VPATH_FILES =
103 am__installdirs = "$(DESTDIR)$(bindir)"
104 PROGRAMS = $(bin_PROGRAMS)
105 am_bjoentegaard_OBJECTS = bjoentegaard-bjoentegaard.$(OBJEXT)
106 bjoentegaard_OBJECTS = $(am_bjoentegaard_OBJECTS)
107 AM_V_lt = $(am__v_lt_@AM_V@)
108 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
109 am__v_lt_0 = --silent
110 am__v_lt_1 =
111 bjoentegaard_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
112 $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(bjoentegaard_CXXFLAGS) \
113 $(CXXFLAGS) $(bjoentegaard_LDFLAGS) $(LDFLAGS) -o $@
114 am_block_rate_estim_OBJECTS = \
115 block_rate_estim-block-rate-estim.$(OBJEXT)
116 block_rate_estim_OBJECTS = $(am_block_rate_estim_OBJECTS)
117 block_rate_estim_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
118 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
119 $(block_rate_estim_CXXFLAGS) $(CXXFLAGS) \
120 $(block_rate_estim_LDFLAGS) $(LDFLAGS) -o $@
121 am_gen_enc_table_OBJECTS = gen_enc_table-gen-entropy-table.$(OBJEXT)
122 gen_enc_table_OBJECTS = $(am_gen_enc_table_OBJECTS)
123 gen_enc_table_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
124 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
125 $(gen_enc_table_CXXFLAGS) $(CXXFLAGS) $(gen_enc_table_LDFLAGS) \
126 $(LDFLAGS) -o $@
127 am_rd_curves_OBJECTS = rd_curves-rd-curves.$(OBJEXT)
128 rd_curves_OBJECTS = $(am_rd_curves_OBJECTS)
129 rd_curves_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
130 $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(rd_curves_CXXFLAGS) \
131 $(CXXFLAGS) $(rd_curves_LDFLAGS) $(LDFLAGS) -o $@
132 am_tests_OBJECTS = tests-tests.$(OBJEXT)
133 tests_OBJECTS = $(am_tests_OBJECTS)
134 tests_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
135 $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(tests_CXXFLAGS) \
136 $(CXXFLAGS) $(tests_LDFLAGS) $(LDFLAGS) -o $@
137 am_yuv_distortion_OBJECTS = yuv_distortion-yuv-distortion.$(OBJEXT)
138 yuv_distortion_OBJECTS = $(am_yuv_distortion_OBJECTS)
139 yuv_distortion_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
140 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
141 $(yuv_distortion_CXXFLAGS) $(CXXFLAGS) \
142 $(yuv_distortion_LDFLAGS) $(LDFLAGS) -o $@
143 AM_V_P = $(am__v_P_@AM_V@)
144 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
145 am__v_P_0 = false
146 am__v_P_1 = :
147 AM_V_GEN = $(am__v_GEN_@AM_V@)
148 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
149 am__v_GEN_0 = @echo " GEN " $@;
150 am__v_GEN_1 =
151 AM_V_at = $(am__v_at_@AM_V@)
152 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
153 am__v_at_0 = @
154 am__v_at_1 =
155 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
156 depcomp = $(SHELL) $(top_srcdir)/depcomp
157 am__depfiles_maybe = depfiles
158 am__mv = mv -f
159 CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
160 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
161 LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
162 $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
163 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
164 $(AM_CXXFLAGS) $(CXXFLAGS)
165 AM_V_CXX = $(am__v_CXX_@AM_V@)
166 am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
167 am__v_CXX_0 = @echo " CXX " $@;
168 am__v_CXX_1 =
169 CXXLD = $(CXX)
170 CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
171 $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
172 $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
173 AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
174 am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
175 am__v_CXXLD_0 = @echo " CXXLD " $@;
176 am__v_CXXLD_1 =
177 SOURCES = $(bjoentegaard_SOURCES) $(block_rate_estim_SOURCES) \
178 $(gen_enc_table_SOURCES) $(rd_curves_SOURCES) $(tests_SOURCES) \
179 $(yuv_distortion_SOURCES)
180 DIST_SOURCES = $(bjoentegaard_SOURCES) $(block_rate_estim_SOURCES) \
181 $(gen_enc_table_SOURCES) $(rd_curves_SOURCES) $(tests_SOURCES) \
182 $(yuv_distortion_SOURCES)
183 am__can_run_installinfo = \
184 case $$AM_UPDATE_INFO_DIR in \
185 n|no|NO) false;; \
186 *) (install-info --version) >/dev/null 2>&1;; \
187 esac
188 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
189 # Read a list of newline-separated strings from the standard input,
190 # and print each of them once, without duplicates. Input order is
191 # *not* preserved.
192 am__uniquify_input = $(AWK) '\
193 BEGIN { nonempty = 0; } \
194 { items[$$0] = 1; nonempty = 1; } \
195 END { if (nonempty) { for (i in items) print i; }; } \
196 '
197 # Make sure the list of sources is unique. This is necessary because,
198 # e.g., the same source file might be shared among _SOURCES variables
199 # for different programs/libraries.
200 am__define_uniq_tagged_files = \
201 list='$(am__tagged_files)'; \
202 unique=`for i in $$list; do \
203 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
204 done | $(am__uniquify_input)`
205 ETAGS = etags
206 CTAGS = ctags
207 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
208 ACLOCAL = @ACLOCAL@
209 ALLOCA = @ALLOCA@
210 AMTAR = @AMTAR@
211 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
212 AR = @AR@
213 AUTOCONF = @AUTOCONF@
214 AUTOHEADER = @AUTOHEADER@
215 AUTOMAKE = @AUTOMAKE@
216 AWK = @AWK@
217 CC = @CC@
218 CCAS = @CCAS@
219 CCASDEPMODE = @CCASDEPMODE@
220 CCASFLAGS = @CCASFLAGS@
221 CCDEPMODE = @CCDEPMODE@
222 CFLAGS = @CFLAGS@
223 CPP = @CPP@
224 CPPFLAGS = @CPPFLAGS@
225 CXX = @CXX@
226 CXXCPP = @CXXCPP@
227 CXXDEPMODE = @CXXDEPMODE@
228 CXXFLAGS = @CXXFLAGS@
229 CYGPATH_W = @CYGPATH_W@
230 DEFS = @DEFS@
231 DEPDIR = @DEPDIR@
232 DLLTOOL = @DLLTOOL@
233 DSYMUTIL = @DSYMUTIL@
234 DUMPBIN = @DUMPBIN@
235 ECHO_C = @ECHO_C@
236 ECHO_N = @ECHO_N@
237 ECHO_T = @ECHO_T@
238 EGREP = @EGREP@
239 EXEEXT = @EXEEXT@
240 FGREP = @FGREP@
241 GREP = @GREP@
242 HAVE_CXX11 = @HAVE_CXX11@
243 INSTALL = @INSTALL@
244 INSTALL_DATA = @INSTALL_DATA@
245 INSTALL_PROGRAM = @INSTALL_PROGRAM@
246 INSTALL_SCRIPT = @INSTALL_SCRIPT@
247 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
248 LD = @LD@
249 LDFLAGS = @LDFLAGS@
250 LIBDE265_AGE = @LIBDE265_AGE@
251 LIBDE265_CURRENT = @LIBDE265_CURRENT@
252 LIBDE265_REVISION = @LIBDE265_REVISION@
253 LIBOBJS = @LIBOBJS@
254 LIBS = @LIBS@
255 LIBTOOL = @LIBTOOL@
256 LIPO = @LIPO@
257 LN_S = @LN_S@
258 LTLIBOBJS = @LTLIBOBJS@
259 MAKEINFO = @MAKEINFO@
260 MANIFEST_TOOL = @MANIFEST_TOOL@
261 MKDIR_P = @MKDIR_P@
262 NM = @NM@
263 NMEDIT = @NMEDIT@
264 NUMERIC_VERSION = @NUMERIC_VERSION@
265 OBJDUMP = @OBJDUMP@
266 OBJEXT = @OBJEXT@
267 OTOOL = @OTOOL@
268 OTOOL64 = @OTOOL64@
269 PACKAGE = @PACKAGE@
270 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
271 PACKAGE_NAME = @PACKAGE_NAME@
272 PACKAGE_STRING = @PACKAGE_STRING@
273 PACKAGE_TARNAME = @PACKAGE_TARNAME@
274 PACKAGE_URL = @PACKAGE_URL@
275 PACKAGE_VERSION = @PACKAGE_VERSION@
276 PATH_SEPARATOR = @PATH_SEPARATOR@
277 PKG_CONFIG = @PKG_CONFIG@
278 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
279 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
280 QTCHOOSER = @QTCHOOSER@
281 QTMOC = @QTMOC@
282 QT_CFLAGS = @QT_CFLAGS@
283 QT_LIBS = @QT_LIBS@
284 RANLIB = @RANLIB@
285 SDL_CFLAGS = @SDL_CFLAGS@
286 SDL_LIBS = @SDL_LIBS@
287 SED = @SED@
288 SET_MAKE = @SET_MAKE@
289 SHELL = @SHELL@
290 STRIP = @STRIP@
291 SWSCALE_CFLAGS = @SWSCALE_CFLAGS@
292 SWSCALE_LIBS = @SWSCALE_LIBS@
293 VERSION = @VERSION@
294 VIDEOGFX_CFLAGS = @VIDEOGFX_CFLAGS@
295 VIDEOGFX_LIBS = @VIDEOGFX_LIBS@
296 abs_builddir = @abs_builddir@
297 abs_srcdir = @abs_srcdir@
298 abs_top_builddir = @abs_top_builddir@
299 abs_top_srcdir = @abs_top_srcdir@
300 ac_ct_AR = @ac_ct_AR@
301 ac_ct_CC = @ac_ct_CC@
302 ac_ct_CXX = @ac_ct_CXX@
303 ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
304 am__include = @am__include@
305 am__leading_dot = @am__leading_dot@
306 am__quote = @am__quote@
307 am__tar = @am__tar@
308 am__untar = @am__untar@
309 bindir = @bindir@
310 build = @build@
311 build_alias = @build_alias@
312 build_cpu = @build_cpu@
313 build_os = @build_os@
314 build_vendor = @build_vendor@
315 builddir = @builddir@
316 datadir = @datadir@
317 datarootdir = @datarootdir@
318 docdir = @docdir@
319 dvidir = @dvidir@
320 exec_prefix = @exec_prefix@
321 host = @host@
322 host_alias = @host_alias@
323 host_cpu = @host_cpu@
324 host_os = @host_os@
325 host_vendor = @host_vendor@
326 htmldir = @htmldir@
327 includedir = @includedir@
328 infodir = @infodir@
329 install_sh = @install_sh@
330 libdir = @libdir@
331 libexecdir = @libexecdir@
332 localedir = @localedir@
333 localstatedir = @localstatedir@
334 mandir = @mandir@
335 mkdir_p = @mkdir_p@
336 oldincludedir = @oldincludedir@
337 pdfdir = @pdfdir@
338 prefix = @prefix@
339 program_transform_name = @program_transform_name@
340 psdir = @psdir@
341 sbindir = @sbindir@
342 sharedstatedir = @sharedstatedir@
343 srcdir = @srcdir@
344 sysconfdir = @sysconfdir@
345 target = @target@
346 target_alias = @target_alias@
347 target_cpu = @target_cpu@
348 target_os = @target_os@
349 target_vendor = @target_vendor@
350 top_build_prefix = @top_build_prefix@
351 top_builddir = @top_builddir@
352 top_srcdir = @top_srcdir@
353 AM_CPPFLAGS = -I../libde265
354 gen_enc_table_DEPENDENCIES = ../libde265/libde265.la
355 gen_enc_table_CXXFLAGS =
356 gen_enc_table_LDFLAGS =
357 gen_enc_table_LDADD = ../libde265/libde265.la -lstdc++
358 gen_enc_table_SOURCES = gen-entropy-table.cc
359 yuv_distortion_DEPENDENCIES = ../libde265/libde265.la
360 yuv_distortion_CXXFLAGS = $(am__append_1)
361 yuv_distortion_LDFLAGS = $(am__append_2)
362 yuv_distortion_LDADD = ../libde265/libde265.la -lstdc++
363 yuv_distortion_SOURCES = yuv-distortion.cc
364 rd_curves_DEPENDENCIES = ../libde265/libde265.la
365 rd_curves_CXXFLAGS =
366 rd_curves_LDFLAGS =
367 rd_curves_LDADD = ../libde265/libde265.la -lstdc++
368 rd_curves_SOURCES = rd-curves.cc
369 block_rate_estim_DEPENDENCIES = ../libde265/libde265.la
370 block_rate_estim_CXXFLAGS =
371 block_rate_estim_LDFLAGS =
372 block_rate_estim_LDADD = ../libde265/libde265.la -lstdc++
373 block_rate_estim_SOURCES = block-rate-estim.cc
374 tests_DEPENDENCIES = ../libde265/libde265.la
375 tests_CXXFLAGS =
376 tests_LDFLAGS =
377 tests_LDADD = ../libde265/libde265.la -lstdc++
378 tests_SOURCES = tests.cc
379 bjoentegaard_DEPENDENCIES = ../libde265/libde265.la
380 bjoentegaard_CXXFLAGS =
381 bjoentegaard_LDFLAGS =
382 bjoentegaard_LDADD = ../libde265/libde265.la -lstdc++
383 bjoentegaard_SOURCES = bjoentegaard.cc
384 all: all-am
385
386 .SUFFIXES:
387 .SUFFIXES: .cc .lo .o .obj
388 $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
389 @for dep in $?; do \
390 case '$(am__configure_deps)' in \
391 *$$dep*) \
392 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
393 && { if test -f $@; then exit 0; else break; fi; }; \
394 exit 1;; \
395 esac; \
396 done; \
397 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tools/Makefile'; \
398 $(am__cd) $(top_srcdir) && \
399 $(AUTOMAKE) --gnu tools/Makefile
400 .PRECIOUS: Makefile
401 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
402 @case '$?' in \
403 *config.status*) \
404 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
405 *) \
406 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
407 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
408 esac;
409
410 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
411 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
412
413 $(top_srcdir)/configure: $(am__configure_deps)
414 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
415 $(ACLOCAL_M4): $(am__aclocal_m4_deps)
416 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
417 $(am__aclocal_m4_deps):
418 install-binPROGRAMS: $(bin_PROGRAMS)
419 @$(NORMAL_INSTALL)
420 @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
421 if test -n "$$list"; then \
422 echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
423 $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
424 fi; \
425 for p in $$list; do echo "$$p $$p"; done | \
426 sed 's/$(EXEEXT)$$//' | \
427 while read p p1; do if test -f $$p \
428 || test -f $$p1 \
429 ; then echo "$$p"; echo "$$p"; else :; fi; \
430 done | \
431 sed -e 'p;s,.*/,,;n;h' \
432 -e 's|.*|.|' \
433 -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
434 sed 'N;N;N;s,\n, ,g' | \
435 $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
436 { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
437 if ($$2 == $$4) files[d] = files[d] " " $$1; \
438 else { print "f", $$3 "/" $$4, $$1; } } \
439 END { for (d in files) print "f", d, files[d] }' | \
440 while read type dir files; do \
441 if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
442 test -z "$$files" || { \
443 echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
444 $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
445 } \
446 ; done
447
448 uninstall-binPROGRAMS:
449 @$(NORMAL_UNINSTALL)
450 @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
451 files=`for p in $$list; do echo "$$p"; done | \
452 sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
453 -e 's/$$/$(EXEEXT)/' \
454 `; \
455 test -n "$$list" || exit 0; \
456 echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
457 cd "$(DESTDIR)$(bindir)" && rm -f $$files
458
459 clean-binPROGRAMS:
460 @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
461 echo " rm -f" $$list; \
462 rm -f $$list || exit $$?; \
463 test -n "$(EXEEXT)" || exit 0; \
464 list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
465 echo " rm -f" $$list; \
466 rm -f $$list
467
468 bjoentegaard$(EXEEXT): $(bjoentegaard_OBJECTS) $(bjoentegaard_DEPENDENCIES) $(EXTRA_bjoentegaard_DEPENDENCIES)
469 @rm -f bjoentegaard$(EXEEXT)
470 $(AM_V_CXXLD)$(bjoentegaard_LINK) $(bjoentegaard_OBJECTS) $(bjoentegaard_LDADD) $(LIBS)
471
472 block-rate-estim$(EXEEXT): $(block_rate_estim_OBJECTS) $(block_rate_estim_DEPENDENCIES) $(EXTRA_block_rate_estim_DEPENDENCIES)
473 @rm -f block-rate-estim$(EXEEXT)
474 $(AM_V_CXXLD)$(block_rate_estim_LINK) $(block_rate_estim_OBJECTS) $(block_rate_estim_LDADD) $(LIBS)
475
476 gen-enc-table$(EXEEXT): $(gen_enc_table_OBJECTS) $(gen_enc_table_DEPENDENCIES) $(EXTRA_gen_enc_table_DEPENDENCIES)
477 @rm -f gen-enc-table$(EXEEXT)
478 $(AM_V_CXXLD)$(gen_enc_table_LINK) $(gen_enc_table_OBJECTS) $(gen_enc_table_LDADD) $(LIBS)
479
480 rd-curves$(EXEEXT): $(rd_curves_OBJECTS) $(rd_curves_DEPENDENCIES) $(EXTRA_rd_curves_DEPENDENCIES)
481 @rm -f rd-curves$(EXEEXT)
482 $(AM_V_CXXLD)$(rd_curves_LINK) $(rd_curves_OBJECTS) $(rd_curves_LDADD) $(LIBS)
483
484 tests$(EXEEXT): $(tests_OBJECTS) $(tests_DEPENDENCIES) $(EXTRA_tests_DEPENDENCIES)
485 @rm -f tests$(EXEEXT)
486 $(AM_V_CXXLD)$(tests_LINK) $(tests_OBJECTS) $(tests_LDADD) $(LIBS)
487
488 yuv-distortion$(EXEEXT): $(yuv_distortion_OBJECTS) $(yuv_distortion_DEPENDENCIES) $(EXTRA_yuv_distortion_DEPENDENCIES)
489 @rm -f yuv-distortion$(EXEEXT)
490 $(AM_V_CXXLD)$(yuv_distortion_LINK) $(yuv_distortion_OBJECTS) $(yuv_distortion_LDADD) $(LIBS)
491
492 mostlyclean-compile:
493 -rm -f *.$(OBJEXT)
494
495 distclean-compile:
496 -rm -f *.tab.c
497
498 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bjoentegaard-bjoentegaard.Po@am__quote@
499 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/block_rate_estim-block-rate-estim.Po@am__quote@
500 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_enc_table-gen-entropy-table.Po@am__quote@
501 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rd_curves-rd-curves.Po@am__quote@
502 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tests-tests.Po@am__quote@
503 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yuv_distortion-yuv-distortion.Po@am__quote@
504
505 .cc.o:
506 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
507 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
508 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
509 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
510 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<
511
512 .cc.obj:
513 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
514 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
515 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
516 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
517 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
518
519 .cc.lo:
520 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
521 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
522 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
523 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
524 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
525
526 bjoentegaard-bjoentegaard.o: bjoentegaard.cc
527 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bjoentegaard_CXXFLAGS) $(CXXFLAGS) -MT bjoentegaard-bjoentegaard.o -MD -MP -MF $(DEPDIR)/bjoentegaard-bjoentegaard.Tpo -c -o bjoentegaard-bjoentegaard.o `test -f 'bjoentegaard.cc' || echo '$(srcdir)/'`bjoentegaard.cc
528 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/bjoentegaard-bjoentegaard.Tpo $(DEPDIR)/bjoentegaard-bjoentegaard.Po
529 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='bjoentegaard.cc' object='bjoentegaard-bjoentegaard.o' libtool=no @AMDEPBACKSLASH@
530 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
531 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bjoentegaard_CXXFLAGS) $(CXXFLAGS) -c -o bjoentegaard-bjoentegaard.o `test -f 'bjoentegaard.cc' || echo '$(srcdir)/'`bjoentegaard.cc
532
533 bjoentegaard-bjoentegaard.obj: bjoentegaard.cc
534 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bjoentegaard_CXXFLAGS) $(CXXFLAGS) -MT bjoentegaard-bjoentegaard.obj -MD -MP -MF $(DEPDIR)/bjoentegaard-bjoentegaard.Tpo -c -o bjoentegaard-bjoentegaard.obj `if test -f 'bjoentegaard.cc'; then $(CYGPATH_W) 'bjoentegaard.cc'; else $(CYGPATH_W) '$(srcdir)/bjoentegaard.cc'; fi`
535 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/bjoentegaard-bjoentegaard.Tpo $(DEPDIR)/bjoentegaard-bjoentegaard.Po
536 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='bjoentegaard.cc' object='bjoentegaard-bjoentegaard.obj' libtool=no @AMDEPBACKSLASH@
537 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
538 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bjoentegaard_CXXFLAGS) $(CXXFLAGS) -c -o bjoentegaard-bjoentegaard.obj `if test -f 'bjoentegaard.cc'; then $(CYGPATH_W) 'bjoentegaard.cc'; else $(CYGPATH_W) '$(srcdir)/bjoentegaard.cc'; fi`
539
540 block_rate_estim-block-rate-estim.o: block-rate-estim.cc
541 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(block_rate_estim_CXXFLAGS) $(CXXFLAGS) -MT block_rate_estim-block-rate-estim.o -MD -MP -MF $(DEPDIR)/block_rate_estim-block-rate-estim.Tpo -c -o block_rate_estim-block-rate-estim.o `test -f 'block-rate-estim.cc' || echo '$(srcdir)/'`block-rate-estim.cc
542 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/block_rate_estim-block-rate-estim.Tpo $(DEPDIR)/block_rate_estim-block-rate-estim.Po
543 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='block-rate-estim.cc' object='block_rate_estim-block-rate-estim.o' libtool=no @AMDEPBACKSLASH@
544 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
545 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(block_rate_estim_CXXFLAGS) $(CXXFLAGS) -c -o block_rate_estim-block-rate-estim.o `test -f 'block-rate-estim.cc' || echo '$(srcdir)/'`block-rate-estim.cc
546
547 block_rate_estim-block-rate-estim.obj: block-rate-estim.cc
548 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(block_rate_estim_CXXFLAGS) $(CXXFLAGS) -MT block_rate_estim-block-rate-estim.obj -MD -MP -MF $(DEPDIR)/block_rate_estim-block-rate-estim.Tpo -c -o block_rate_estim-block-rate-estim.obj `if test -f 'block-rate-estim.cc'; then $(CYGPATH_W) 'block-rate-estim.cc'; else $(CYGPATH_W) '$(srcdir)/block-rate-estim.cc'; fi`
549 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/block_rate_estim-block-rate-estim.Tpo $(DEPDIR)/block_rate_estim-block-rate-estim.Po
550 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='block-rate-estim.cc' object='block_rate_estim-block-rate-estim.obj' libtool=no @AMDEPBACKSLASH@
551 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
552 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(block_rate_estim_CXXFLAGS) $(CXXFLAGS) -c -o block_rate_estim-block-rate-estim.obj `if test -f 'block-rate-estim.cc'; then $(CYGPATH_W) 'block-rate-estim.cc'; else $(CYGPATH_W) '$(srcdir)/block-rate-estim.cc'; fi`
553
554 gen_enc_table-gen-entropy-table.o: gen-entropy-table.cc
555 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gen_enc_table_CXXFLAGS) $(CXXFLAGS) -MT gen_enc_table-gen-entropy-table.o -MD -MP -MF $(DEPDIR)/gen_enc_table-gen-entropy-table.Tpo -c -o gen_enc_table-gen-entropy-table.o `test -f 'gen-entropy-table.cc' || echo '$(srcdir)/'`gen-entropy-table.cc
556 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/gen_enc_table-gen-entropy-table.Tpo $(DEPDIR)/gen_enc_table-gen-entropy-table.Po
557 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='gen-entropy-table.cc' object='gen_enc_table-gen-entropy-table.o' libtool=no @AMDEPBACKSLASH@
558 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
559 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gen_enc_table_CXXFLAGS) $(CXXFLAGS) -c -o gen_enc_table-gen-entropy-table.o `test -f 'gen-entropy-table.cc' || echo '$(srcdir)/'`gen-entropy-table.cc
560
561 gen_enc_table-gen-entropy-table.obj: gen-entropy-table.cc
562 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gen_enc_table_CXXFLAGS) $(CXXFLAGS) -MT gen_enc_table-gen-entropy-table.obj -MD -MP -MF $(DEPDIR)/gen_enc_table-gen-entropy-table.Tpo -c -o gen_enc_table-gen-entropy-table.obj `if test -f 'gen-entropy-table.cc'; then $(CYGPATH_W) 'gen-entropy-table.cc'; else $(CYGPATH_W) '$(srcdir)/gen-entropy-table.cc'; fi`
563 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/gen_enc_table-gen-entropy-table.Tpo $(DEPDIR)/gen_enc_table-gen-entropy-table.Po
564 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='gen-entropy-table.cc' object='gen_enc_table-gen-entropy-table.obj' libtool=no @AMDEPBACKSLASH@
565 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
566 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gen_enc_table_CXXFLAGS) $(CXXFLAGS) -c -o gen_enc_table-gen-entropy-table.obj `if test -f 'gen-entropy-table.cc'; then $(CYGPATH_W) 'gen-entropy-table.cc'; else $(CYGPATH_W) '$(srcdir)/gen-entropy-table.cc'; fi`
567
568 rd_curves-rd-curves.o: rd-curves.cc
569 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rd_curves_CXXFLAGS) $(CXXFLAGS) -MT rd_curves-rd-curves.o -MD -MP -MF $(DEPDIR)/rd_curves-rd-curves.Tpo -c -o rd_curves-rd-curves.o `test -f 'rd-curves.cc' || echo '$(srcdir)/'`rd-curves.cc
570 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/rd_curves-rd-curves.Tpo $(DEPDIR)/rd_curves-rd-curves.Po
571 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='rd-curves.cc' object='rd_curves-rd-curves.o' libtool=no @AMDEPBACKSLASH@
572 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
573 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rd_curves_CXXFLAGS) $(CXXFLAGS) -c -o rd_curves-rd-curves.o `test -f 'rd-curves.cc' || echo '$(srcdir)/'`rd-curves.cc
574
575 rd_curves-rd-curves.obj: rd-curves.cc
576 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rd_curves_CXXFLAGS) $(CXXFLAGS) -MT rd_curves-rd-curves.obj -MD -MP -MF $(DEPDIR)/rd_curves-rd-curves.Tpo -c -o rd_curves-rd-curves.obj `if test -f 'rd-curves.cc'; then $(CYGPATH_W) 'rd-curves.cc'; else $(CYGPATH_W) '$(srcdir)/rd-curves.cc'; fi`
577 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/rd_curves-rd-curves.Tpo $(DEPDIR)/rd_curves-rd-curves.Po
578 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='rd-curves.cc' object='rd_curves-rd-curves.obj' libtool=no @AMDEPBACKSLASH@
579 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
580 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rd_curves_CXXFLAGS) $(CXXFLAGS) -c -o rd_curves-rd-curves.obj `if test -f 'rd-curves.cc'; then $(CYGPATH_W) 'rd-curves.cc'; else $(CYGPATH_W) '$(srcdir)/rd-curves.cc'; fi`
581
582 tests-tests.o: tests.cc
583 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CXXFLAGS) $(CXXFLAGS) -MT tests-tests.o -MD -MP -MF $(DEPDIR)/tests-tests.Tpo -c -o tests-tests.o `test -f 'tests.cc' || echo '$(srcdir)/'`tests.cc
584 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tests-tests.Tpo $(DEPDIR)/tests-tests.Po
585 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='tests.cc' object='tests-tests.o' libtool=no @AMDEPBACKSLASH@
586 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
587 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CXXFLAGS) $(CXXFLAGS) -c -o tests-tests.o `test -f 'tests.cc' || echo '$(srcdir)/'`tests.cc
588
589 tests-tests.obj: tests.cc
590 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CXXFLAGS) $(CXXFLAGS) -MT tests-tests.obj -MD -MP -MF $(DEPDIR)/tests-tests.Tpo -c -o tests-tests.obj `if test -f 'tests.cc'; then $(CYGPATH_W) 'tests.cc'; else $(CYGPATH_W) '$(srcdir)/tests.cc'; fi`
591 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tests-tests.Tpo $(DEPDIR)/tests-tests.Po
592 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='tests.cc' object='tests-tests.obj' libtool=no @AMDEPBACKSLASH@
593 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
594 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CXXFLAGS) $(CXXFLAGS) -c -o tests-tests.obj `if test -f 'tests.cc'; then $(CYGPATH_W) 'tests.cc'; else $(CYGPATH_W) '$(srcdir)/tests.cc'; fi`
595
596 yuv_distortion-yuv-distortion.o: yuv-distortion.cc
597 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(yuv_distortion_CXXFLAGS) $(CXXFLAGS) -MT yuv_distortion-yuv-distortion.o -MD -MP -MF $(DEPDIR)/yuv_distortion-yuv-distortion.Tpo -c -o yuv_distortion-yuv-distortion.o `test -f 'yuv-distortion.cc' || echo '$(srcdir)/'`yuv-distortion.cc
598 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/yuv_distortion-yuv-distortion.Tpo $(DEPDIR)/yuv_distortion-yuv-distortion.Po
599 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='yuv-distortion.cc' object='yuv_distortion-yuv-distortion.o' libtool=no @AMDEPBACKSLASH@
600 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
601 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(yuv_distortion_CXXFLAGS) $(CXXFLAGS) -c -o yuv_distortion-yuv-distortion.o `test -f 'yuv-distortion.cc' || echo '$(srcdir)/'`yuv-distortion.cc
602
603 yuv_distortion-yuv-distortion.obj: yuv-distortion.cc
604 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(yuv_distortion_CXXFLAGS) $(CXXFLAGS) -MT yuv_distortion-yuv-distortion.obj -MD -MP -MF $(DEPDIR)/yuv_distortion-yuv-distortion.Tpo -c -o yuv_distortion-yuv-distortion.obj `if test -f 'yuv-distortion.cc'; then $(CYGPATH_W) 'yuv-distortion.cc'; else $(CYGPATH_W) '$(srcdir)/yuv-distortion.cc'; fi`
605 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/yuv_distortion-yuv-distortion.Tpo $(DEPDIR)/yuv_distortion-yuv-distortion.Po
606 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='yuv-distortion.cc' object='yuv_distortion-yuv-distortion.obj' libtool=no @AMDEPBACKSLASH@
607 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
608 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(yuv_distortion_CXXFLAGS) $(CXXFLAGS) -c -o yuv_distortion-yuv-distortion.obj `if test -f 'yuv-distortion.cc'; then $(CYGPATH_W) 'yuv-distortion.cc'; else $(CYGPATH_W) '$(srcdir)/yuv-distortion.cc'; fi`
609
610 mostlyclean-libtool:
611 -rm -f *.lo
612
613 clean-libtool:
614 -rm -rf .libs _libs
615
616 ID: $(am__tagged_files)
617 $(am__define_uniq_tagged_files); mkid -fID $$unique
618 tags: tags-am
619 TAGS: tags
620
621 tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
622 set x; \
623 here=`pwd`; \
624 $(am__define_uniq_tagged_files); \
625 shift; \
626 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
627 test -n "$$unique" || unique=$$empty_fix; \
628 if test $$# -gt 0; then \
629 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
630 "$$@" $$unique; \
631 else \
632 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
633 $$unique; \
634 fi; \
635 fi
636 ctags: ctags-am
637
638 CTAGS: ctags
639 ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
640 $(am__define_uniq_tagged_files); \
641 test -z "$(CTAGS_ARGS)$$unique" \
642 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
643 $$unique
644
645 GTAGS:
646 here=`$(am__cd) $(top_builddir) && pwd` \
647 && $(am__cd) $(top_srcdir) \
648 && gtags -i $(GTAGS_ARGS) "$$here"
649 cscopelist: cscopelist-am
650
651 cscopelist-am: $(am__tagged_files)
652 list='$(am__tagged_files)'; \
653 case "$(srcdir)" in \
654 [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
655 *) sdir=$(subdir)/$(srcdir) ;; \
656 esac; \
657 for i in $$list; do \
658 if test -f "$$i"; then \
659 echo "$(subdir)/$$i"; \
660 else \
661 echo "$$sdir/$$i"; \
662 fi; \
663 done >> $(top_builddir)/cscope.files
664
665 distclean-tags:
666 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
667
668 distdir: $(DISTFILES)
669 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
670 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
671 list='$(DISTFILES)'; \
672 dist_files=`for file in $$list; do echo $$file; done | \
673 sed -e "s|^$$srcdirstrip/||;t" \
674 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
675 case $$dist_files in \
676 */*) $(MKDIR_P) `echo "$$dist_files" | \
677 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
678 sort -u` ;; \
679 esac; \
680 for file in $$dist_files; do \
681 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
682 if test -d $$d/$$file; then \
683 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
684 if test -d "$(distdir)/$$file"; then \
685 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
686 fi; \
687 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
688 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
689 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
690 fi; \
691 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
692 else \
693 test -f "$(distdir)/$$file" \
694 || cp -p $$d/$$file "$(distdir)/$$file" \
695 || exit 1; \
696 fi; \
697 done
698 check-am: all-am
699 check: check-am
700 all-am: Makefile $(PROGRAMS)
701 installdirs:
702 for dir in "$(DESTDIR)$(bindir)"; do \
703 test -z "$$dir" || $(MKDIR_P) "$$dir"; \
704 done
705 install: install-am
706 install-exec: install-exec-am
707 install-data: install-data-am
708 uninstall: uninstall-am
709
710 install-am: all-am
711 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
712
713 installcheck: installcheck-am
714 install-strip:
715 if test -z '$(STRIP)'; then \
716 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
717 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
718 install; \
719 else \
720 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
721 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
722 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
723 fi
724 mostlyclean-generic:
725
726 clean-generic:
727
728 distclean-generic:
729 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
730 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
731
732 maintainer-clean-generic:
733 @echo "This command is intended for maintainers to use"
734 @echo "it deletes files that may require special tools to rebuild."
735 clean: clean-am
736
737 clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
738
739 distclean: distclean-am
740 -rm -rf ./$(DEPDIR)
741 -rm -f Makefile
742 distclean-am: clean-am distclean-compile distclean-generic \
743 distclean-tags
744
745 dvi: dvi-am
746
747 dvi-am:
748
749 html: html-am
750
751 html-am:
752
753 info: info-am
754
755 info-am:
756
757 install-data-am:
758
759 install-dvi: install-dvi-am
760
761 install-dvi-am:
762
763 install-exec-am: install-binPROGRAMS
764
765 install-html: install-html-am
766
767 install-html-am:
768
769 install-info: install-info-am
770
771 install-info-am:
772
773 install-man:
774
775 install-pdf: install-pdf-am
776
777 install-pdf-am:
778
779 install-ps: install-ps-am
780
781 install-ps-am:
782
783 installcheck-am:
784
785 maintainer-clean: maintainer-clean-am
786 -rm -rf ./$(DEPDIR)
787 -rm -f Makefile
788 maintainer-clean-am: distclean-am maintainer-clean-generic
789
790 mostlyclean: mostlyclean-am
791
792 mostlyclean-am: mostlyclean-compile mostlyclean-generic \
793 mostlyclean-libtool
794
795 pdf: pdf-am
796
797 pdf-am:
798
799 ps: ps-am
800
801 ps-am:
802
803 uninstall-am: uninstall-binPROGRAMS
804
805 .MAKE: install-am install-strip
806
807 .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \
808 clean-binPROGRAMS clean-generic clean-libtool cscopelist-am \
809 ctags ctags-am distclean distclean-compile distclean-generic \
810 distclean-libtool distclean-tags distdir dvi dvi-am html \
811 html-am info info-am install install-am install-binPROGRAMS \
812 install-data install-data-am install-dvi install-dvi-am \
813 install-exec install-exec-am install-html install-html-am \
814 install-info install-info-am install-man install-pdf \
815 install-pdf-am install-ps install-ps-am install-strip \
816 installcheck installcheck-am installdirs maintainer-clean \
817 maintainer-clean-generic mostlyclean mostlyclean-compile \
818 mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
819 tags tags-am uninstall uninstall-am uninstall-binPROGRAMS
820
821
822 # Tell versions [3.59,3.63) of GNU make to not export all variables.
823 # Otherwise a system limit (for SysV at least) may be exceeded.
824 .NOEXPORT:
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * This file is part of libde265.
5 *
6 * libde265 is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * libde265 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
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with libde265. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <fstream>
23 #include <sstream>
24 #include <string>
25 #include <vector>
26 #include <math.h>
27 #include <unistd.h>
28
29
30 const bool D = false;
31
32
33 /* There are numerical stability problems in the matrix inverse.
34 Switching to long double seems to provide enough accuracy.
35 TODO: in the long term, use a better regression algorithm.
36 */
37 typedef long double FP;
38
39
40 struct datapoint
41 {
42 double rate;
43 double distortion;
44 };
45
46 struct BjoentegaardParams
47 {
48 // a*log^3 R + b*log^2 R + c*log R + d
49 double a,b,c,d;
50
51 double minRate, maxRate;
52 };
53
54 std::vector<datapoint> curveA,curveB;
55 BjoentegaardParams paramsA,paramsB;
56
57 #define RATE_NORMALIZATION_FACTOR 1 //(1/1000.0)
58
59
60
61 FP invf(int i,int j,const FP* m)
62 {
63 int o = 2+(j-i);
64
65 i += 4+o;
66 j += 4-o;
67
68 #define e(a,b) m[ ((j+b)%4)*4 + ((i+a)%4) ]
69
70 FP inv =
71 + e(+1,-1)*e(+0,+0)*e(-1,+1)
72 + e(+1,+1)*e(+0,-1)*e(-1,+0)
73 + e(-1,-1)*e(+1,+0)*e(+0,+1)
74 - e(-1,-1)*e(+0,+0)*e(+1,+1)
75 - e(-1,+1)*e(+0,-1)*e(+1,+0)
76 - e(+1,-1)*e(-1,+0)*e(+0,+1);
77
78 return (o%2)?inv : -inv;
79
80 #undef e
81
82 }
83
84 bool inverseMatrix4x4(const FP *m, FP *out)
85 {
86 FP inv[16];
87
88 for(int i=0;i<4;i++)
89 for(int j=0;j<4;j++)
90 inv[j*4+i] = invf(i,j,m);
91
92 FP D = 0;
93
94 for(int k=0;k<4;k++) D += m[k] * inv[k*4];
95
96 if (D == 0) return false;
97
98 D = 1.0 / D;
99
100 for (int i = 0; i < 16; i++)
101 out[i] = inv[i] * D;
102
103 return true;
104
105 }
106
107
108
109 BjoentegaardParams fitParams(const std::vector<datapoint>& curve)
110 {
111 // build regression matrix
112
113 int n = curve.size();
114
115 FP X[4*n]; // regression matrix
116 FP XT[n*4]; // transpose of X
117
118 for (int i=0;i<n;i++) {
119 FP x = log(curve[i].rate) * RATE_NORMALIZATION_FACTOR;
120
121 X[4*i + 0] = 1;
122 X[4*i + 1] = x;
123 X[4*i + 2] = x*x;
124 X[4*i + 3] = x*x*x;
125
126 if (D) printf("%f %f %f %f ;\n",1.0,(double)x,(double)(x*x),(double)(x*x*x));
127
128 XT[i+0*n] = 1;
129 XT[i+1*n] = x;
130 XT[i+2*n] = x*x;
131 XT[i+3*n] = x*x*x;
132 }
133
134 if (D) {
135 printf("rate: ");
136 for (int i=0;i<n;i++) {
137 printf("%f ; ",curve[i].rate);
138 }
139 printf("\n");
140
141 printf("distortion: ");
142 for (int i=0;i<n;i++) {
143 printf("%f ; ",curve[i].distortion);
144 }
145 printf("\n");
146 }
147
148 // calc X^T * X
149
150 FP XTX[4*4];
151 for (int y=0;y<4;y++)
152 for (int x=0;x<4;x++) {
153 FP sum=0;
154
155 for (int i=0;i<n;i++)
156 {
157 sum += XT[y*n + i] * X[x + i*4];
158 }
159
160 XTX[y*4+x] = sum;
161 }
162
163 FP XTXinv[4*4];
164
165 inverseMatrix4x4(XTX, XTXinv);
166
167 if (D) {
168 for (int y=0;y<4;y++) {
169 for (int x=0;x<4;x++) {
170 printf("%f ",(double)XTXinv[y*4+x]);
171 }
172 printf("\n");
173 }
174 }
175
176 // calculate pseudo-inverse XP = (X^T * X)^-1 * X^T
177
178 FP XP[n*4];
179
180 for (int y=0;y<4;y++) {
181 for (int x=0;x<n;x++) {
182 FP sum=0;
183
184 for (int i=0;i<4;i++)
185 {
186 sum += XTXinv[y*4 + i] * XT[x + i*n];
187 }
188
189 XP[y*n+x] = sum;
190 }
191 }
192
193 // calculate regression parameters
194
195 FP p[4];
196
197 for (int k=0;k<4;k++)
198 {
199 FP sum=0;
200
201 for (int i=0;i<n;i++) {
202 sum += XP[k*n + i] * curve[i].distortion;
203 }
204
205 p[k]=sum;
206 }
207
208
209 BjoentegaardParams param;
210 param.d = p[0];
211 param.c = p[1];
212 param.b = p[2];
213 param.a = p[3];
214
215
216 // find min and max rate
217
218 param.minRate = curve[0].rate;
219 param.maxRate = curve[0].rate;
220
221 for (int i=1;i<n;i++) {
222 param.minRate = std::min(param.minRate, curve[i].rate);
223 param.maxRate = std::max(param.maxRate, curve[i].rate);
224 }
225
226 return param;
227 }
228
229 FP evalIntegralAt(const BjoentegaardParams& p, double x)
230 {
231 FP sum = 0;
232
233 // integral of: d
234
235 sum += p.d * x;
236
237 // integral of: c*log(x)
238
239 sum += p.c * x* (log(x)-1);
240
241 // integral of: b*log(x)^2
242
243 sum += p.b * x * ((log(x)-2)*log(x)+2);
244
245 // integral of: a*log(x)^3
246
247 sum += p.a * x * (log(x)*((log(x)-3)*log(x)+6)-6);
248
249 return sum;
250 }
251
252
253 double calcBjoentegaard(const BjoentegaardParams& paramsA,
254 const BjoentegaardParams& paramsB,
255 double min_rate, double max_rate)
256 {
257 double mini = std::max(paramsA.minRate, paramsB.minRate);
258 double maxi = std::min(paramsA.maxRate, paramsB.maxRate);
259
260 if (min_rate >= 0) mini = std::max(mini, min_rate);
261 if (max_rate >= 0) maxi = std::min(maxi, max_rate);
262
263 if (D) printf("range: %f %f\n",mini,maxi);
264
265 FP intA = evalIntegralAt(paramsA, maxi) - evalIntegralAt(paramsA, mini);
266 FP intB = evalIntegralAt(paramsB, maxi) - evalIntegralAt(paramsB, mini);
267
268 if (D) printf("int1:%f int2:%f\n",(double)intA,(double)intB);
269
270 return (intA-intB)/(maxi-mini);
271 }
272
273
274 std::vector<datapoint> readRDFile(const char* filename, float min_rate, float max_rate)
275 {
276 std::vector<datapoint> curve;
277 std::ifstream istr(filename);
278
279 for (;;)
280 {
281 std::string line;
282 getline(istr, line);
283 if (istr.eof())
284 break;
285
286 if (line[0]=='#') continue;
287
288 std::stringstream sstr(line);
289 datapoint p;
290 sstr >> p.rate >> p.distortion;
291
292 if (min_rate>=0 && p.rate < min_rate) continue;
293 if (max_rate>=0 && p.rate > max_rate) continue;
294
295 curve.push_back(p);
296 }
297
298 return curve;
299 }
300
301
302 int main(int argc, char** argv)
303 {
304 float min_rate = -1;
305 float max_rate = -1;
306
307 int c;
308 while ((c=getopt(argc,argv, "l:h:")) != -1) {
309 switch (c) {
310 case 'l': min_rate = atof(optarg); break;
311 case 'h': max_rate = atof(optarg); break;
312 }
313 }
314
315 curveA = readRDFile(argv[optind], min_rate, max_rate);
316 paramsA = fitParams(curveA);
317
318 printf("params A: %f %f %f %f\n",paramsA.a,paramsA.b,paramsA.c,paramsA.d);
319
320 printf("gnuplot: %f*log(x)**3+%f*log(x)**2+%f*log(x)+%f\n",paramsA.a,paramsA.b,paramsA.c,paramsA.d);
321
322 if (optind+1<argc) {
323 curveB = readRDFile(argv[optind+1], min_rate, max_rate);
324 paramsB = fitParams(curveB);
325
326 printf("params B: %f %f %f %f\n",paramsB.a,paramsB.b,paramsB.c,paramsB.d);
327
328 printf("gnuplot: %f*log(x)**3+%f*log(x)**2+%f*log(x)+%f\n",paramsB.a,paramsB.b,paramsB.c,paramsB.d);
329
330 double delta = calcBjoentegaard(paramsA,paramsB, min_rate,max_rate);
331
332 printf("Bjoentegaard delta: %f dB (A-B -> >0 -> first (A) is better)\n",delta);
333
334 if (delta>=0) {
335 printf("-> first is better by %f dB\n",delta);
336 }
337 else {
338 printf("-> second is better by %f dB\n",-delta);
339 }
340 }
341
342 return 0;
343 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * This file is part of libde265.
5 *
6 * libde265 is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * libde265 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
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with libde265. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include <vector>
21 #include <string>
22 #include <fstream>
23 #include <math.h>
24
25
26 struct datapoint {
27 int log2blksize;
28 float rate;
29 float estim;
30 };
31
32 std::vector<datapoint> pts;
33
34 #define NBINS 100
35
36 /*
37 #define ESTIMDIV 100
38 #define MAXESTIM 80000
39 std::vector<float> bitestim2[MAXESTIM/ESTIMDIV];
40 */
41
42
43
44 void print_bitestim_results(int log2blksize)
45 {
46 float max_estim=0;
47
48 for (int i=0;i<pts.size();i++) {
49 if (log2blksize==0 || pts[i].log2blksize==log2blksize) {
50 max_estim = std::max(max_estim, pts[i].estim);
51 }
52 }
53
54
55
56 float epsilon = 0.0001;
57 float interval = (max_estim+epsilon) / NBINS;
58
59 for (int b=0;b<NBINS;b++) {
60
61 int cnt=0;
62 double sum=0;
63 float mini=999999;
64 float maxi=0;
65
66 for (int i=0;i<pts.size();i++)
67 if (log2blksize==0 || pts[i].log2blksize==log2blksize) {
68 int bin = pts[i].estim/interval;
69 if (bin==b) {
70 sum += pts[i].rate;
71
72 mini = std::min(mini,pts[i].rate);
73 maxi = std::max(maxi,pts[i].rate);
74 cnt++;
75 }
76 }
77
78 if (cnt>0) {
79 double mean = sum/cnt;
80
81 double var = 0;
82
83 for (int i=0;i<pts.size();i++)
84 if (log2blksize==0 || pts[i].log2blksize==log2blksize) {
85 int bin = pts[i].estim/interval;
86 if (bin==b) {
87 var += (pts[i].rate-mean)*(pts[i].rate-mean);
88 }
89 }
90
91 var /= cnt;
92 double stddev = sqrt(var);
93
94 printf("%f %f %f %f %f %f %f %d\n",
95 (b+0.5)*interval,mean,var,
96 mean-stddev,mean+stddev, mini,maxi,
97 cnt);
98 }
99 }
100 }
101
102
103 int main(int argc,char** argv)
104 {
105 std::string tag = argv[1];
106
107 std::ifstream istr(argv[2]);
108 for (;;)
109 {
110 std::string t;
111 int log2blksize;
112 datapoint pt;
113
114 istr >> t >> pt.log2blksize >> pt.rate >> pt.estim;
115
116 if (istr.eof()) break;
117
118 if (t == tag) {
119 pts.push_back(pt);
120 }
121 }
122
123 print_bitestim_results(0);
124
125 return 0;
126 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * This file is part of libde265.
5 *
6 * libde265 is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * libde265 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
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with libde265. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20
21 #include "libde265/cabac.h"
22 #include <assert.h>
23 #include <time.h>
24 #include <stdlib.h>
25 #include <stdio.h>
26
27
28 void simple_getline(char** lineptr,size_t* linelen,FILE* fh)
29 {
30 const int LINESIZE=1000;
31
32 if (*lineptr==NULL) {
33 *linelen = LINESIZE;
34 *lineptr = (char*)malloc(LINESIZE);
35 }
36
37 char* p = *lineptr;
38
39 for (;;) {
40 assert(p - *lineptr < LINESIZE);
41
42 int c = fgetc(fh);
43 if (c == EOF || c == '\n') {
44 *p = 0;
45 break;
46 }
47
48 *p++ = c;
49 }
50 }
51
52
53 void generate_entropy_table()
54 {
55 #if 000
56 const int nSymbols=1000*1000*10;
57 const int oversample = 10;
58
59 double tab[64][2];
60
61 for (int i=0;i<64;i++)
62 for (int k=0;k<2;k++)
63 tab[i][k]=0;
64
65 srand(time(0));
66 //srand(123);
67
68 int cnt=1;
69 for (;;cnt++) {
70 printf("-------------------- %d --------------------\n",cnt);
71
72 for (int s=0;s<63;s++) {
73 CABAC_encoder_bitstream cabac_mix0;
74 CABAC_encoder_bitstream cabac_mix1;
75 CABAC_encoder_bitstream cabac_ref;
76
77 for (int i=0;i<nSymbols*oversample;i++) {
78 int r = rand();
79 int n = (r>>2) % 63;
80 int m = (r>>1) & 1;
81 int b = r & 1;
82
83 context_model model;
84 model.MPSbit = 1;
85 model.state = n;
86 cabac_ref.write_CABAC_bit(&model, b);
87
88 model.MPSbit = 1;
89 model.state = n;
90 cabac_mix0.write_CABAC_bit(&model, b);
91
92 model.MPSbit = 1;
93 model.state = n;
94 cabac_mix1.write_CABAC_bit(&model, b);
95
96 if (i%oversample == oversample/2) {
97 model.MPSbit = 1;
98 model.state = s;
99 cabac_mix0.write_CABAC_bit(&model, 0);
100
101 model.MPSbit = 1;
102 model.state = s;
103 cabac_mix1.write_CABAC_bit(&model, 1);
104
105 //b = rand() & 1;
106 //cabac_mix.write_CABAC_bypass(1);
107 }
108
109 }
110
111 cabac_ref.flush_CABAC();
112 cabac_mix0.flush_CABAC();
113 cabac_mix1.flush_CABAC();
114
115 int bits_ref = cabac_ref.size()*8;
116 int bits_mix0 = cabac_mix0.size()*8;
117 int bits_mix1 = cabac_mix1.size()*8;
118
119 //printf("bits: %d %d\n",bits_ref,bits_mix);
120 int bits_diff0 = bits_mix0-bits_ref;
121 int bits_diff1 = bits_mix1-bits_ref;
122 //printf("bits diff: %d\n",bits_diff);
123
124 double bits_per_symbol0 = bits_diff0 / double(nSymbols);
125 double bits_per_symbol1 = bits_diff1 / double(nSymbols);
126
127 tab[s][0] += bits_per_symbol0;
128 tab[s][1] += bits_per_symbol1;
129
130 double bps0 = tab[s][0]/cnt;
131 double bps1 = tab[s][1]/cnt;
132
133 printf("/* state=%2d */ 0x%05x /* %f */, 0x%05x /* %f */,\n", s,
134 (int)(bps1*0x8000), bps1,
135 (int)(bps0*0x8000), bps0);
136 }
137
138 printf(" 0x0010c, 0x3bfbb /* dummy, should never be used */\n");
139 }
140 #endif
141 }
142
143 int probTab[128+2] = {
144 1537234,1602970,
145 1608644,1815493,
146 1822246,2245961,
147 916773,1329391,
148 1337504,1930659,
149 1063692,1707588,
150 868294,1532108,
151 842934,1555538,
152 689043,1396941,
153 860184,1789964,
154 534165,1258482,
155 672508,1598821,
156 578782,1476240,
157 602247,1613140,
158 409393,1206638,
159 459294,1356779,
160 430124,1359893,
161 308326,1050647,
162 313100,1099956,
163 293887,1088978,
164 220901,869582,
165 214967,881695,
166 197226,856990,
167 166131,767761,
168 152514,737406,
169 128332,663998,
170 117638,632653,
171 106178,595539,
172 90898,539506,
173 83437,509231,
174 76511,492801,
175 64915,443096,
176 57847,409809,
177 52730,385395,
178 45707,354059,
179 42018,333028,
180 37086,308073,
181 33256,284497,
182 36130,299172,
183 28831,270716,
184 25365,244840,
185 22850,221896,
186 19732,201462,
187 17268,183729,
188 15252,168106,
189 13787,153979,
190 12187,141455,
191 10821,130337,
192 9896,120165,
193 8626,112273,
194 8162,103886,
195 7201,96441,
196 6413,89805,
197 5886,83733,
198 5447,78084,
199 4568,73356,
200 4388,68831,
201 3959,64688,
202 3750,60804,
203 3407,57271,
204 3109,54024,
205 2820,51099,
206 48569,1451987,
207 0, 0,
208 0*22686225, 0
209 };
210
211
212 void generate_entropy_table_probTableWeighted()
213 {
214 #if 000
215 int64_t probTabSum=0;
216 for (int i=0;i<130;i++)
217 probTabSum += probTab[i];
218
219
220 const int nSymbols=1000*1000*10;
221 const int oversample = 10;
222
223 double tab[64][2];
224
225 for (int i=0;i<64;i++)
226 for (int k=0;k<2;k++)
227 tab[i][k]=0;
228
229 srand(time(0));
230 //srand(123);
231
232 int cnt=1;
233 for (;;cnt++) {
234 printf("-------------------- %d --------------------\n",cnt);
235
236 for (int s=0;s<63;s++) {
237 CABAC_encoder_bitstream cabac_mix0;
238 CABAC_encoder_bitstream cabac_mix1;
239 CABAC_encoder_bitstream cabac_ref;
240
241 for (int i=0;i<nSymbols*oversample;i++) {
242 int r = rand();
243
244 r %= probTabSum;
245 int idx=0;
246 while (r>probTab[idx]) {
247 r-=probTab[idx];
248 idx++;
249 }
250
251 assert(idx<=128);
252
253 int n = idx/2;
254 int b = idx&1;
255 bool bypass = (idx==128);
256
257 printf("%d %d %d\n",n,b,bypass);
258
259 context_model model;
260 model.MPSbit = 1;
261 model.state = n;
262 if (bypass) cabac_ref.write_CABAC_bypass(1);
263 else cabac_ref.write_CABAC_bit(&model, b);
264
265 model.MPSbit = 1;
266 model.state = n;
267 if (bypass) cabac_mix0.write_CABAC_bypass(1);
268 else cabac_mix0.write_CABAC_bit(&model, b);
269
270 model.MPSbit = 1;
271 model.state = n;
272 if (bypass) cabac_mix1.write_CABAC_bypass(1);
273 else cabac_mix1.write_CABAC_bit(&model, b);
274
275 if (i%oversample == oversample/2) {
276 model.MPSbit = 1;
277 model.state = s;
278 cabac_mix0.write_CABAC_bit(&model, 0);
279
280 model.MPSbit = 1;
281 model.state = s;
282 cabac_mix1.write_CABAC_bit(&model, 1);
283
284 //b = rand() & 1;
285 //cabac_mix.write_CABAC_bypass(1);
286 }
287
288 }
289
290 cabac_ref.flush_CABAC();
291 cabac_mix0.flush_CABAC();
292 cabac_mix1.flush_CABAC();
293
294 int bits_ref = cabac_ref.size()*8;
295 int bits_mix0 = cabac_mix0.size()*8;
296 int bits_mix1 = cabac_mix1.size()*8;
297
298 //printf("bits: %d %d\n",bits_ref,bits_mix);
299 int bits_diff0 = bits_mix0-bits_ref;
300 int bits_diff1 = bits_mix1-bits_ref;
301 //printf("bits diff: %d\n",bits_diff);
302
303 double bits_per_symbol0 = bits_diff0 / double(nSymbols);
304 double bits_per_symbol1 = bits_diff1 / double(nSymbols);
305
306 tab[s][0] += bits_per_symbol0;
307 tab[s][1] += bits_per_symbol1;
308
309 double bps0 = tab[s][0]/cnt;
310 double bps1 = tab[s][1]/cnt;
311
312 printf("/* state=%2d */ 0x%05x /* %f */, 0x%05x /* %f */,\n", s,
313 (int)(bps1*0x8000), bps1,
314 (int)(bps0*0x8000), bps0);
315 }
316
317 printf(" 0x0010c, 0x3bfbb /* dummy, should never be used */\n");
318 }
319 #endif
320 }
321
322
323 void generate_entropy_table_replay()
324 {
325 #if 000
326 const int oversample = 10;
327
328 char* lineptr = NULL;
329 size_t linelen = 0;
330
331 for (int s=0;s<63;s++) {
332 CABAC_encoder_bitstream cabac_mix0;
333 CABAC_encoder_bitstream cabac_mix1;
334 CABAC_encoder_bitstream cabac_ref;
335
336 int nSymbols = 0;
337
338 FILE* fh = fopen("streamdump-paris-intra","r");
339
340 for (int i=0;i<80000000;i++) {
341 simple_getline(&lineptr,&linelen,fh);
342 if (feof(fh))
343 break;
344
345 int n,b;
346 sscanf(lineptr,"%d %d",&n,&b);
347
348 bool bypass = (n==64);
349
350 if ((i%10000)==0)
351 { printf("%d %d %d \r",i,n,b);
352 }
353
354 //printf("%d %d %d\n",n,b,bypass);
355
356 context_model model;
357 model.MPSbit = 1;
358 model.state = n;
359 if (bypass) cabac_ref.write_CABAC_bypass(1);
360 else cabac_ref.write_CABAC_bit(&model, b);
361
362 model.MPSbit = 1;
363 model.state = n;
364 if (bypass) cabac_mix0.write_CABAC_bypass(1);
365 else cabac_mix0.write_CABAC_bit(&model, b);
366
367 model.MPSbit = 1;
368 model.state = n;
369 if (bypass) cabac_mix1.write_CABAC_bypass(1);
370 else cabac_mix1.write_CABAC_bit(&model, b);
371
372 if (i%oversample == oversample/2) {
373 model.MPSbit = 1;
374 model.state = s;
375 cabac_mix0.write_CABAC_bit(&model, 0);
376
377 model.MPSbit = 1;
378 model.state = s;
379 cabac_mix1.write_CABAC_bit(&model, 1);
380
381 nSymbols++;
382
383 //b = rand() & 1;
384 //cabac_mix.write_CABAC_bypass(1);
385 }
386 }
387
388 fclose(fh);
389
390 cabac_ref.flush_CABAC();
391 cabac_mix0.flush_CABAC();
392 cabac_mix1.flush_CABAC();
393
394 int bits_ref = cabac_ref.size()*8;
395 int bits_mix0 = cabac_mix0.size()*8;
396 int bits_mix1 = cabac_mix1.size()*8;
397
398 //printf("bits: %d %d\n",bits_ref,bits_mix);
399 int bits_diff0 = bits_mix0-bits_ref;
400 int bits_diff1 = bits_mix1-bits_ref;
401 //printf("bits diff: %d\n",bits_diff);
402
403 double bits_per_symbol0 = bits_diff0 / double(nSymbols);
404 double bits_per_symbol1 = bits_diff1 / double(nSymbols);
405
406 double bps0 = bits_per_symbol0;
407 double bps1 = bits_per_symbol1;
408
409 printf("/* state=%2d */ 0x%05x /* %f */, 0x%05x /* %f */,\n", s,
410 (int)(bps1*0x8000), bps1,
411 (int)(bps0*0x8000), bps0);
412 }
413
414 printf(" 0x0010c, 0x3bfbb /* dummy, should never be used */\n");
415 #endif
416 }
417
418
419 void test_entropy_table_replay()
420 {
421 #if 000
422 char* lineptr = NULL;
423 size_t linelen = 0;
424
425
426 CABAC_encoder_bitstream cabac_bs;
427 CABAC_encoder_estim cabac_estim;
428
429 //FILE* fh = fopen("y","r");
430 //FILE* fh = fopen("own-dump","r");
431 //FILE* fh = fopen("rawstream-dump","r");
432 //FILE* fh = fopen("johnny-stream-dump","r");
433 FILE* fh = fopen("streamdump-paris-intra","r");
434
435 for (int i=0;i<80000000;i++) {
436 simple_getline(&lineptr,&linelen,fh);
437 if (feof(fh))
438 break;
439
440 int n,b;
441 sscanf(lineptr,"%d %d",&n,&b);
442 b=!b;
443 bool bypass = (n==64);
444
445 if ((i%10000)==0)
446 { printf("%d %d %d \n",i,n,b);
447 }
448
449 context_model model;
450 model.MPSbit = 1;
451 model.state = n;
452 if (bypass) cabac_bs.write_CABAC_bypass(1);
453 else cabac_bs.write_CABAC_bit(&model, b);
454
455 model.MPSbit = 1;
456 model.state = n;
457 if (bypass) cabac_estim.write_CABAC_bypass(1);
458 else cabac_estim.write_CABAC_bit(&model, b);
459 }
460
461 fclose(fh);
462
463 printf("bs:%d estim:%d\n",cabac_bs.size(),cabac_estim.size());
464 #endif
465 }
466
467
468 int main(int argc, char** argv)
469 {
470 //generate_entropy_table();
471 //generate_entropy_table_replay();
472
473 test_entropy_table_replay();
474
475 return 0;
476 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * This file is part of libde265.
5 *
6 * libde265 is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * libde265 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
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with libde265. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <sys/types.h>
27 #include <sys/stat.h>
28 #include <unistd.h>
29 #include <assert.h>
30 #include <stdint.h>
31 #include <string.h>
32 #include <getopt.h>
33
34 #include <sys/time.h>
35
36 #ifndef WIN32
37 #include <sys/times.h>
38 #endif
39
40 #include <string>
41 #include <sstream>
42 #include <iostream>
43 #include <iomanip>
44 #include <fstream>
45 #include <vector>
46
47
48
49 static struct {
50 const char* name;
51 const char* value;
52 } variables[] = {
53 { "$HOME" , "/home/domain/farindk" },
54 { "$ROOT" , "/home/domain/farindk/prog/h265" },
55 { "$ENC265" , "$ROOT/libde265/enc265/enc265" },
56 { "$DEC265" , "$ROOT/libde265/dec265/dec265" },
57 { "$YUVDIST" , "$ROOT/libde265/tools/yuv-distortion" },
58 { "$YUVTMP" , "/mnt/temp/dirk/yuv/ftp.tnt.uni-hannover.de/testsequences" },
59 { "$YUV" , "/storage/users/farindk/yuv" },
60 { "$HMENC" , "HM13enc" },
61 { "$HM13CFG" , "$ROOT/HM/HM-13.0-dev/cfg" },
62 { "$HMSCCENC", "HM-SCC-enc" },
63 { "$HMSCCCFG", "$ROOT/HM/HM-SCC-extensions/cfg" },
64 { "$X265ENC" , "$ROOT/x265/build/linux/x265" },
65 { "$X264" , "x264" },
66 { "$FFMPEG" , "ffmpeg" },
67 { "$F265" , "$ROOT/f265/build/f265cli" },
68 { 0,0 }
69 };
70
71
72 bool keepStreams = false;
73 int maxFrames = 0;
74 std::string encoderParameters;
75
76
77 std::string replace_variables(std::string str)
78 {
79 bool replaced = false;
80 for (int i=0;variables[i].name;i++) {
81 size_t pos = str.find(variables[i].name);
82 if (pos != std::string::npos) {
83 replaced = true;
84 str = str.replace(pos, strlen(variables[i].name), variables[i].value);
85 break;
86 }
87 }
88
89 if (!replaced) return str;
90 else return replace_variables(str);
91 }
92
93
94 // ---------------------------------------------------------------------------
95
96 struct Preset
97 {
98 const int ID;
99 const char* name;
100 const char* descr;
101
102 const char* options_de265;
103 const char* options_hm;
104 const char* options_hm_scc;
105 const char* options_x265;
106 const char* options_f265;
107 const char* options_x264;
108 const char* options_x264_ffmpeg;
109 const char* options_ffmpeg_mpeg2;
110
111 //int nFrames;
112 };
113
114
115 Preset preset[] = {
116 { 1, "pre01-intra-noLF", "intra, no LF, no SBH, CTB-size 32, min CB=8",
117 /* de265 */ "--sop-structure intra",
118 /* HM */ "-c $HM13CFG/encoder_intra_main.cfg -SBH 0 --SAO=0 --LoopFilterDisable --DeblockingFilterControlPresent --MaxCUSize=32 --MaxPartitionDepth=2",
119 /* HM SCC */ "-c $HMSCCCFG/encoder_intra_main_scc.cfg -SBH 0 --SAO=0 --LoopFilterDisable --DeblockingFilterControlPresent --MaxCUSize=32 --MaxPartitionDepth=2",
120 /* x265 */ "--no-lft -I 1 --no-signhide",
121 /* f265 */ "key-frame-spacing=1",
122 /* x264 */ "-I 1",
123 /* ffmpeg */ "-g 1",
124 /* mpeg-2 */ "-g 1"
125 // 0 // all frames
126 },
127
128 { 2, "pre02-fastIntra", "intra, no LF, no SBH, CTB-size 32, min CB=8",
129 /* de265 */ "--sop-structure intra --TB-IntraPredMode minSSD",
130 /* HM */ "-c $HM13CFG/encoder_intra_main.cfg -SBH 0 --SAO=0 --LoopFilterDisable --DeblockingFilterControlPresent --MaxCUSize=32 --MaxPartitionDepth=2",
131 /* HM SCC */ "-c $HMSCCCFG/encoder_intra_main_scc.cfg -SBH 0 --SAO=0 --LoopFilterDisable --DeblockingFilterControlPresent --MaxCUSize=32 --MaxPartitionDepth=2",
132 /* x265 */ "--no-lft -I 1 --no-signhide",
133 /* f265 */ "key-frame-spacing=1",
134 /* x264 */ "-I 1",
135 /* ffmpeg */ "-g 1",
136 /* mpeg-2 */ "-g 1"
137 // 0 // all frames
138 },
139
140 { 3, "pre03-fastIntra", "pre02, but fast-brute",
141 /* de265 */ "--sop-structure intra --TB-IntraPredMode fast-brute",
142 /* HM */ "-c $HM13CFG/encoder_intra_main.cfg -SBH 0 --SAO=0 --LoopFilterDisable --DeblockingFilterControlPresent --MaxCUSize=32 --MaxPartitionDepth=2",
143 /* HM SCC */ "-c $HMSCCCFG/encoder_intra_main_scc.cfg -SBH 0 --SAO=0 --LoopFilterDisable --DeblockingFilterControlPresent --MaxCUSize=32 --MaxPartitionDepth=2",
144 /* x265 */ "--no-lft -I 1 --no-signhide",
145 /* f265 */ "key-frame-spacing=1",
146 /* x264 */ "-I 1",
147 /* ffmpeg */ "-g 1",
148 /* mpeg-2 */ "-g 1"
149 // 0 // all frames
150 },
151
152 { 50, "cb-auto16", "(development test)",
153 /* de265 */ "--max-cb-size 16 --min-cb-size 8",
154 /* HM */ "-c $HM13CFG/encoder_intra_main.cfg -SBH 0 --SAO=0 --LoopFilterDisable --DeblockingFilterControlPresent --MaxCUSize=32 --MaxPartitionDepth=2",
155 /* HM SCC */ "-c $HMSCCCFG/encoder_intra_main_scc.cfg -SBH 0 --SAO=0 --LoopFilterDisable --DeblockingFilterControlPresent --MaxCUSize=32 --MaxPartitionDepth=2",
156 /* x265 */ "--no-lft -I 1 --no-signhide",
157 /* f265 */ "key-frame-spacing=1",
158 /* x264 */ "-I 1",
159 /* ffmpeg */ "-g 1",
160 /* mpeg-2 */ "-g 1"
161 // 0 // all frames
162 },
163
164 { 80, "lowdelay", "default (low-default) encoder parameters",
165 "--MEMode search --max-cb-size 32 --min-cb-size 8 --min-tb-size 4 --CB-IntraPartMode-Fixed-partMode 2Nx2N --CB-IntraPartMode fixed --TB-IntraPredMode min-residual --PB-MV-TestMode zero",
166 /* de265 */ //"--sop-structure low-delay --MEMode search --max-cb-size 32 --min-cb-size 8 --min-tb-size 4 --CB-IntraPartMode fixed --TB-IntraPredMode min-residual",
167 /* HM */ "-c $HM13CFG/encoder_lowdelay_main.cfg -ip 248",
168 /* HM SCC */ "-c $HMSCCCFG/encoder_lowdelay_main_scc.cfg -ip 248",
169 /* x265 */ "-I 248 --no-wpp --bframes 0", // GOP size: 248
170 /* f265 */ 0, //"key-frame-spacing=248",
171 /* x264 */ "",
172 /* ffmpeg */ "-g 248 -bf 0",
173 /* mpeg-2 */ "" // GOP size 248 does not make sense here
174 // 0 // all frames
175 },
176
177 { 98, "best", "default (random-access) encoder parameters",
178 /* de265 */ "--max-cb-size 16 --min-cb-size 8",
179 /* HM */ "-c $HM13CFG/encoder_randomaccess_main.cfg",
180 /* HM SCC */ "-c $HMSCCCFG/encoder_randomaccess_main_scc.cfg",
181 /* x265 */ "",
182 /* f265 */ "",
183 /* x264 */ "",
184 /* ffmpeg */ "",
185 /* mpeg-2 */ ""
186 // 0 // all frames
187 },
188
189 { 99, "besteq", "default (random-access) encoder parameters, I-frame distance = 248",
190 /* de265 */ "",
191 /* HM */ "-c $HM13CFG/encoder_randomaccess_main.cfg -ip 248",
192 /* HM SCC */ "-c $HMSCCCFG/encoder_randomaccess_main_scc.cfg -ip 248",
193 /* x265 */ "-I 248 --no-wpp", // GOP size: 248
194 /* f265 */ "key-frame-spacing=248",
195 /* x264 */ "",
196 /* ffmpeg */ "-g 248",
197 /* mpeg-2 */ "" // GOP size 248 does not make sense here
198 // 0 // all frames
199 },
200
201 { 0, NULL }
202 };
203
204 // ---------------------------------------------------------------------------
205
206 class Input
207 {
208 public:
209 Input() {
210 width=height=0;
211 maxFrames=0;
212 }
213
214 void setInput(const char* yuvfilename,int w,int h, float fps) {
215 mInputFilename = yuvfilename;
216 width = w;
217 height = h;
218 mFPS = fps;
219 }
220
221 void setMaxFrames(int n) { maxFrames=n; }
222
223 std::string options_de265() const {
224 std::stringstream sstr;
225 sstr << " -i " << mInputFilename << " --width " << width << " --height " << height;
226 if (maxFrames) sstr << " --frames " << maxFrames;
227
228 return sstr.str();
229 }
230
231 std::string options_HM() const {
232 std::stringstream sstr;
233 sstr << "-i " << mInputFilename << " -wdt " << width << " -hgt " << height
234 << " -fr " << mFPS;
235 if (maxFrames) sstr << " -f " << maxFrames;
236
237 return sstr.str();
238 }
239
240 std::string options_x265() const {
241 std::stringstream sstr;
242 sstr << mInputFilename << " --input-res " << width << "x" << height
243 << " --fps " << mFPS;
244 if (maxFrames) sstr << " -f " << maxFrames;
245
246 return sstr.str();
247 }
248
249 std::string options_x264() const {
250 std::stringstream sstr;
251 sstr << mInputFilename << " --input-res " << width << "x" << height;
252 sstr << " --fps 25"; // TODO: check why crf/qp rate-control freaks out when fps is != 25
253 if (maxFrames) sstr << " --frames " << maxFrames;
254
255 return sstr.str();
256 }
257
258 std::string options_ffmpeg() const {
259 std::stringstream sstr;
260 sstr << "-f rawvideo -vcodec rawvideo -s " << width << "x" << height; // << " -r " << mFPS
261 sstr << " -pix_fmt yuv420p -i " << mInputFilename;
262 if (maxFrames) sstr << " -vframes " << maxFrames;
263
264 return sstr.str();
265 }
266
267 std::string options_f265() const {
268 std::stringstream sstr;
269 sstr << mInputFilename << " -w " << width << ":" << height;
270 if (maxFrames) sstr << " -c " << maxFrames;
271
272 return sstr.str();
273 }
274
275 std::string getFilename() const { return mInputFilename; }
276 float getFPS() const { return mFPS; }
277 int getNFrames() const { return maxFrames; }
278 int getWidth() const { return width; }
279 int getHeight() const { return height; }
280
281 private:
282 std::string mInputFilename;
283 int width, height;
284 int maxFrames;
285 float mFPS;
286 };
287
288 Input input;
289
290 struct InputSpec
291 {
292 const char* name;
293 const char* filename;
294 int width,height, nFrames;
295 float fps;
296 } inputSpec[] = {
297 { "paris", "$YUV/paris_cif.yuv",352,288,1065, 30.0 },
298 { "paris10", "$YUV/paris_cif.yuv",352,288, 10, 30.0 },
299 { "paris100", "$YUV/paris_cif.yuv",352,288, 100, 30.0 },
300 { "johnny", "$YUV/Johnny_1280x720_60.yuv",1280,720,600,60.0 },
301 { "johnny10", "$YUV/Johnny_1280x720_60.yuv",1280,720, 10,60.0 },
302 { "johnny100", "$YUV/Johnny_1280x720_60.yuv",1280,720,100,60.0 },
303 { "cactus", "$YUV/Cactus_1920x1080_50.yuv",1920,1080,500,50.0 },
304 { "cactus10", "$YUV/Cactus_1920x1080_50.yuv",1920,1080, 10,50.0 },
305 { "4people", "$YUVTMP/FourPeople_1280x720_60.yuv",1280,720,600,60.0 },
306 { "4people100", "$YUVTMP/FourPeople_1280x720_60.yuv",1280,720,100,60.0 },
307 { "slideedit", "$YUVTMP/SlideEditing_1280x720_30.yuv",1280,720,300,30.0 },
308 { "slideedit100","$YUVTMP/SlideEditing_1280x720_30.yuv",1280,720,100,30.0 },
309 { "slideshow", "$YUVTMP/SlideShow_1280x720_20.yuv",1280,720,500,20.0 },
310 { "slideshow100","$YUVTMP/SlideShow_1280x720_20.yuv",1280,720,100,20.0 },
311 { "screensharing","$HOME/test-screensharing-encoding/Screensharing.yuv",1360,768,4715,60.0 },
312 { NULL }
313 };
314
315
316 void setInput(const char* input_preset)
317 {
318 bool presetFound=false;
319
320 for (int i=0;inputSpec[i].name;i++) {
321 if (strcmp(input_preset, inputSpec[i].name)==0) {
322 input.setInput(inputSpec[i].filename,
323 inputSpec[i].width,
324 inputSpec[i].height,
325 inputSpec[i].fps);
326 input.setMaxFrames(inputSpec[i].nFrames);
327 presetFound=true;
328 break;
329 }
330 }
331
332 if (!presetFound) {
333 fprintf(stderr,"no input preset '%s'\n",input_preset);
334 exit(5);
335 }
336 }
337
338
339 float bitrate(const char* filename)
340 {
341 struct stat s;
342 stat(filename,&s);
343
344 long size = s.st_size;
345
346 int frames = input.getNFrames();
347 assert(frames!=0);
348
349 float bitrate = size*8/(frames/input.getFPS());
350 return bitrate;
351 }
352
353
354 // ---------------------------------------------------------------------------
355
356 class Quality
357 {
358 public:
359 virtual ~Quality() { }
360
361 virtual void measure(const char* h265filename);
362 virtual void measure_yuv(const char* yuvfilename);
363
364 float psnr, ssim;
365 };
366
367
368 void Quality::measure(const char* h265filename)
369 {
370 std::stringstream sstr;
371 sstr << "$DEC265 " << h265filename << " -q -t6 -m " << input.getFilename() << " | grep total "
372 //"| awk '{print $2}' "
373 ">/tmp/xtmp";
374
375 //std::cout << sstr.str() << "\n";
376 int retval = system(replace_variables(sstr.str()).c_str());
377
378 std::ifstream istr;
379 istr.open("/tmp/xtmp");
380 std::string dummy;
381 istr >> dummy >> psnr >> dummy >> dummy >> ssim;
382
383 unlink("/tmp/xtmp");
384 }
385
386
387 void Quality::measure_yuv(const char* yuvfilename)
388 {
389 std::stringstream sstr;
390
391 sstr << "$YUVDIST " << input.getFilename() << " " << yuvfilename
392 << " " << input.getWidth() << " " << input.getHeight()
393 << "|grep total "
394 //"|awk '{print $2}' "
395 ">/tmp/ytmp";
396
397 //std::cout << sstr.str() << "\n";
398 int retval = system(replace_variables(sstr.str()).c_str());
399
400 std::ifstream istr;
401 istr.open("/tmp/ytmp");
402 std::string dummy;
403 istr >> dummy >> psnr >> ssim;
404
405 unlink("/tmp/ytmp");
406 }
407
408 Quality quality;
409
410 // ---------------------------------------------------------------------------
411
412 long ticks_per_second;
413
414 void init_clock()
415 {
416 #ifndef WIN32
417 ticks_per_second = sysconf(_SC_CLK_TCK);
418 #endif
419 }
420
421 double get_cpu_time()
422 {
423 #ifndef WIN32
424 struct tms t;
425 times(&t);
426 return double(t.tms_cutime)/ticks_per_second;
427 #else
428 return 0; // not supported on windows (TODO)
429 #endif
430 }
431
432 double get_wall_time()
433 {
434 struct timeval tv;
435 gettimeofday(&tv, NULL);
436 double t = tv.tv_sec;
437 double ut = tv.tv_usec/1000000.0f;
438 t += ut;
439 return t;
440 }
441
442
443 struct RDPoint
444 {
445 float rate;
446 float psnr;
447 float ssim;
448 double cpu_time; // computation time in seconds
449 double wall_time;
450
451
452 RDPoint() { }
453
454 void compute_from_h265(std::string stream_name) {
455 rate = bitrate(stream_name.c_str());
456 quality.measure(stream_name.c_str());
457 psnr = quality.psnr;
458 ssim = quality.ssim;
459 }
460
461 void compute_from_yuv(std::string stream_name, std::string yuv_name) {
462 rate = bitrate(stream_name.c_str());
463 quality.measure_yuv(yuv_name.c_str());
464 psnr = quality.psnr;
465 ssim = quality.ssim;
466 }
467
468 void start_timer() {
469 cpu_time = get_cpu_time();
470 wall_time= get_wall_time();
471 }
472
473 void end_timer() {
474 cpu_time = get_cpu_time() - cpu_time;
475 wall_time= get_wall_time()- wall_time;
476 }
477 };
478
479
480 FILE* output_fh;
481
482 void write_rd_line(RDPoint p)
483 {
484 fprintf(output_fh,"%9.2f %6.4f %5.3f %5.4f %5.4f\n",
485 p.rate/1024, p.psnr, p.ssim,
486 p.cpu_time/60, p.wall_time/60);
487 fflush(output_fh);
488 }
489
490
491
492
493 class Encoder
494 {
495 public:
496 virtual ~Encoder() { }
497
498 virtual std::vector<RDPoint> encode_curve(const Preset& preset) const = 0;
499
500 private:
501 };
502
503
504 class Encoder_de265 : public Encoder
505 {
506 public:
507 Encoder_de265();
508 void setQPRange(int low,int high,int step) { mQPLow=low; mQPHigh=high; mQPStep=step; }
509
510 virtual std::vector<RDPoint> encode_curve(const Preset& preset) const;
511
512 private:
513 RDPoint encode(const Preset& preset,int qp) const;
514
515 int mQPLow,mQPHigh,mQPStep;
516 };
517
518
519 Encoder_de265::Encoder_de265()
520 {
521 mQPLow = 14;
522 mQPHigh= 40;
523 mQPStep= 2;
524 }
525
526
527 std::vector<RDPoint> Encoder_de265::encode_curve(const Preset& preset) const
528 {
529 std::vector<RDPoint> curve;
530
531 for (int qp=mQPHigh ; qp>=mQPLow ; qp-=mQPStep) {
532 curve.push_back(encode(preset, qp));
533 }
534
535 return curve;
536 }
537
538
539 RDPoint Encoder_de265::encode(const Preset& preset,int qp) const
540 {
541 std::stringstream streamname;
542 streamname << "de265-" << preset.name << "-" << qp << ".265";
543
544 std::stringstream cmd1;
545 cmd1 << "$ENC265 " << input.options_de265()
546 << " " << preset.options_de265
547 << " -q " << qp << " -o " << streamname.str()
548 << " " << encoderParameters;
549
550 std::string cmd2 = replace_variables(cmd1.str());
551
552 printf("cmdline: %s\n",cmd2.c_str());
553
554 RDPoint rd;
555 rd.start_timer();
556 int retval = system(cmd2.c_str());
557 rd.end_timer();
558
559 rd.compute_from_h265(streamname.str());
560
561 if (!keepStreams) { unlink(streamname.str().c_str()); }
562
563 write_rd_line(rd);
564
565 return rd;
566 }
567
568
569
570
571 class Encoder_HM : public Encoder
572 {
573 public:
574 Encoder_HM();
575
576 void enableSCC(bool flag=true) { useSCC = flag; }
577 void setQPRange(int low,int high,int step) { mQPLow=low; mQPHigh=high; mQPStep=step; }
578
579 virtual std::vector<RDPoint> encode_curve(const Preset& preset) const;
580
581 private:
582 RDPoint encode(const Preset& preset,int qp) const;
583
584 bool useSCC;
585 int mQPLow,mQPHigh,mQPStep;
586 };
587
588
589 Encoder_HM::Encoder_HM()
590 {
591 mQPLow = 14;
592 mQPHigh= 40;
593 mQPStep= 2;
594
595 useSCC = false;
596 }
597
598
599 std::vector<RDPoint> Encoder_HM::encode_curve(const Preset& preset) const
600 {
601 std::vector<RDPoint> curve;
602
603 for (int qp=mQPHigh ; qp>=mQPLow ; qp-=mQPStep) {
604 curve.push_back(encode(preset, qp));
605 }
606
607 return curve;
608 }
609
610
611 RDPoint Encoder_HM::encode(const Preset& preset,int qp) const
612 {
613 std::stringstream streamname;
614 streamname << (useSCC ? "hmscc-" : "hm-") << preset.name << "-" << qp << ".265";
615
616 char recoyuv_prefix[] = "/tmp/reco-XXXXXX";
617 char *tempfile = mktemp(recoyuv_prefix);
618 assert(tempfile != NULL && tempfile[0] != 0);
619 std::string recoyuv = std::string(recoyuv_prefix) + ".yuv";
620
621 std::stringstream cmd1;
622 cmd1 << (useSCC ? "$HMSCCENC " : "$HMENC ")
623 << input.options_HM()
624 << " " << (useSCC ? preset.options_hm_scc : preset.options_hm)
625 << " -q " << qp << " -o " << recoyuv << " -b " << streamname.str()
626 << " " << encoderParameters << " >&2";
627
628 std::string cmd2 = replace_variables(cmd1.str());
629
630 std::cout << "CMD: '" << cmd2 << "'\n";
631 RDPoint rd;
632 rd.start_timer();
633 int retval = system(cmd2.c_str());
634 rd.end_timer();
635
636 rd.compute_from_yuv(streamname.str(), recoyuv);
637 if (!keepStreams) { unlink(streamname.str().c_str()); }
638 unlink(recoyuv.c_str());
639
640 write_rd_line(rd);
641
642 return rd;
643 }
644
645
646
647 class Encoder_x265 : public Encoder
648 {
649 public:
650 Encoder_x265();
651 void setQPRange(int low,int high,int step) { mQPLow=low; mQPHigh=high; mQPStep=step; }
652
653 virtual std::vector<RDPoint> encode_curve(const Preset& preset) const;
654
655 private:
656 RDPoint encode(const Preset& preset,int qp) const;
657
658 int mQPLow,mQPHigh,mQPStep;
659 };
660
661
662 Encoder_x265::Encoder_x265()
663 {
664 /* CRF
665 mQPLow = 4;
666 mQPHigh= 34;
667 mQPStep= 2;
668 */
669
670 mQPLow = 14;
671 mQPHigh= 40;
672 mQPStep= 2;
673 }
674
675
676 std::vector<RDPoint> Encoder_x265::encode_curve(const Preset& preset) const
677 {
678 std::vector<RDPoint> curve;
679
680 for (int qp=mQPHigh ; qp>=mQPLow ; qp-=mQPStep) {
681 curve.push_back(encode(preset, qp));
682 }
683
684 return curve;
685 }
686
687
688 RDPoint Encoder_x265::encode(const Preset& preset,int qp) const
689 {
690 std::stringstream streamname;
691 streamname << "x265-" << preset.name << "-" << qp << ".265";
692
693 std::stringstream cmd1;
694 cmd1 << "$X265ENC " << input.options_x265()
695 << " " << preset.options_x265
696 << " --qp " << qp << " " << streamname.str()
697 << " " << encoderParameters
698 << " >&2";
699
700 std::string cmd2 = replace_variables(cmd1.str());
701
702 //std::cout << "CMD: '" << cmd2 << "'\n";
703 RDPoint rd;
704 rd.start_timer();
705 int retval = system(cmd2.c_str());
706 rd.end_timer();
707
708 rd.compute_from_h265(streamname.str());
709 if (!keepStreams) { unlink(streamname.str().c_str()); }
710
711 write_rd_line(rd);
712
713 return rd;
714 }
715
716
717
718
719 class Encoder_f265 : public Encoder
720 {
721 public:
722 Encoder_f265();
723 void setQPRange(int low,int high,int step) { mQPLow=low; mQPHigh=high; mQPStep=step; }
724
725 virtual std::vector<RDPoint> encode_curve(const Preset& preset) const;
726
727 private:
728 RDPoint encode(const Preset& preset,int qp) const;
729
730 int mQPLow,mQPHigh,mQPStep;
731 };
732
733
734 Encoder_f265::Encoder_f265()
735 {
736 mQPLow = 14;
737 mQPHigh= 40;
738 mQPStep= 2;
739 }
740
741
742 std::vector<RDPoint> Encoder_f265::encode_curve(const Preset& preset) const
743 {
744 std::vector<RDPoint> curve;
745
746 for (int qp=mQPHigh ; qp>=mQPLow ; qp-=mQPStep) {
747 curve.push_back(encode(preset, qp));
748 }
749
750 return curve;
751 }
752
753
754 RDPoint Encoder_f265::encode(const Preset& preset,int qp) const
755 {
756 std::stringstream cmd1;
757 cmd1 << "$F265 " << input.options_f265()
758 << " f265.out -v -p\"" << preset.options_f265 << " qp=" << qp
759 << " " << encoderParameters
760 << "\" >&2";
761
762 std::string cmd2 = replace_variables(cmd1.str());
763
764 std::cout << "CMD: '" << cmd2 << "'\n";
765 RDPoint rd;
766 rd.start_timer();
767 int retval = system(cmd2.c_str());
768 rd.end_timer();
769
770 rd.compute_from_h265("f265.out");
771 if (!keepStreams) { unlink("f265.out"); }
772
773 write_rd_line(rd);
774
775 return rd;
776 }
777
778
779
780 class Encoder_x264 : public Encoder
781 {
782 public:
783 Encoder_x264();
784 //void setCRFRange(int low,int high,int step) { mCRFLow=low; mCRFHigh=high; mCRFStep=step; }
785
786 virtual std::vector<RDPoint> encode_curve(const Preset& preset) const;
787
788 private:
789 RDPoint encode(const Preset& preset,int crf) const;
790
791 int mCRFLow,mCRFMid,mCRFHigh;
792 int mCRFStepHigh, mCRFStepLow;
793 };
794
795
796 Encoder_x264::Encoder_x264()
797 {
798 // in the upper bit-rate range [mid;high], use larger CRF step-size 'StepHigh'
799 // in the lower bit-rate range [low;mid], use smaller CRF step-size 'StepLow'
800
801 mCRFLow = 10;
802 mCRFMid = 20;
803 mCRFHigh= 36;
804 mCRFStepHigh= 2;
805 mCRFStepLow = 1;
806 }
807
808
809 std::vector<RDPoint> Encoder_x264::encode_curve(const Preset& preset) const
810 {
811 std::vector<RDPoint> curve;
812
813 for (int crf=mCRFLow ; crf<mCRFMid ; crf+=mCRFStepHigh) {
814 curve.push_back(encode(preset, crf));
815 }
816
817 for (int crf=mCRFMid ; crf<=mCRFHigh ; crf+=mCRFStepLow) {
818 curve.push_back(encode(preset, crf));
819 }
820
821 return curve;
822 }
823
824
825 RDPoint Encoder_x264::encode(const Preset& preset,int qp_crf) const
826 {
827 std::stringstream streamname;
828 streamname << "x264-" << preset.name << "-" << qp_crf << ".264";
829
830 std::stringstream cmd1;
831 #if 0
832 cmd1 << "$X264 " << input.options_x264()
833 << " " << preset.options_x264
834 << " --crf " << qp_crf
835 << " -o " << streamname.str();
836 #else
837 cmd1 << "$FFMPEG " << input.options_ffmpeg()
838 << " " << preset.options_x264_ffmpeg
839 << " -crf " << qp_crf
840 << " -threads 6"
841 << " -f h264 " << streamname.str()
842 << " " << encoderParameters;
843 #endif
844
845 std::string cmd2 = replace_variables(cmd1.str());
846
847 std::cerr << "-----------------------------\n";
848
849 std::cerr << "CMD: '" << cmd2 << "'\n";
850
851 RDPoint rd;
852 rd.start_timer();
853 int retval = system(cmd2.c_str());
854 rd.end_timer();
855
856 char tmpyuv_prefix[] = "/tmp/rdout-XXXXXX";
857 char *tempfile = mktemp(tmpyuv_prefix);
858 assert(tempfile != NULL && tempfile[0] != 0);
859 std::string tmpyuv = std::string(tmpyuv_prefix) + ".yuv";
860
861 std::string cmd3 = "ffmpeg -i " + streamname.str() + " -threads 6 " + tmpyuv;
862
863 retval = system(cmd3.c_str());
864
865 rd.compute_from_yuv(streamname.str(), tmpyuv);
866
867 unlink(tmpyuv.c_str());
868 if (!keepStreams) { unlink(streamname.str().c_str()); }
869
870 write_rd_line(rd);
871
872 return rd;
873 }
874
875
876 class Encoder_mpeg2 : public Encoder
877 {
878 public:
879 Encoder_mpeg2();
880
881 virtual std::vector<RDPoint> encode_curve(const Preset& preset) const;
882
883 private:
884 RDPoint encode(const Preset& preset,int bitrate) const;
885 };
886
887
888 Encoder_mpeg2::Encoder_mpeg2()
889 {
890 }
891
892
893 std::vector<RDPoint> Encoder_mpeg2::encode_curve(const Preset& preset) const
894 {
895 std::vector<RDPoint> curve;
896
897 int bitrates[] = { 250,500,750,1000,1250,1500,1750,2000,2500,3000,3500,4000,4500,5000,
898 6000,7000,8000,9000,10000,12000,14000,16000,18000,20000,25000,30000,
899 -1 };
900
901 for (int i=0; bitrates[i]>0; i++) {
902 curve.push_back(encode(preset, bitrates[i]));
903 }
904
905 return curve;
906 }
907
908
909 RDPoint Encoder_mpeg2::encode(const Preset& preset,int br) const
910 {
911 std::stringstream streamname;
912 streamname << "mpeg2-" << preset.name << "-"
913 << std::setfill('0') << std::setw(5) << br << ".mp2";
914
915 std::stringstream cmd1;
916 cmd1 << "$FFMPEG " << input.options_ffmpeg()
917 << " " << preset.options_x264_ffmpeg
918 << " -b " << br << "k "
919 << " -threads 6"
920 << " -f mpeg2video " << streamname.str()
921 << " " << encoderParameters;
922
923 std::string cmd2 = replace_variables(cmd1.str());
924
925 std::cerr << "-----------------------------\n";
926
927 std::cerr << "CMD: '" << cmd2 << "'\n";
928
929 RDPoint rd;
930 rd.start_timer();
931 int retval = system(cmd2.c_str());
932 rd.end_timer();
933
934 char tmpyuv_prefix[] = "/tmp/rdout-XXXXXX";
935 char *tempfile = mktemp(tmpyuv_prefix);
936 assert(tempfile != NULL && tempfile[0] != 0);
937 std::string tmpyuv = std::string(tmpyuv_prefix) + ".yuv";
938
939 std::string cmd3 = "ffmpeg -i " + streamname.str() + " -threads 6 " + tmpyuv;
940
941 retval = system(cmd3.c_str());
942
943 rd.compute_from_yuv(streamname.str(), tmpyuv);
944
945 unlink(tmpyuv.c_str());
946 if (!keepStreams) { unlink(streamname.str().c_str()); }
947
948 write_rd_line(rd);
949
950 return rd;
951 }
952
953
954 Encoder_de265 enc_de265;
955 Encoder_HM enc_hm;
956 Encoder_x265 enc_x265;
957 Encoder_f265 enc_f265;
958 Encoder_x264 enc_x264;
959 Encoder_mpeg2 enc_mpeg2;
960
961 // ---------------------------------------------------------------------------
962
963 static struct option long_options[] = {
964 {"keep-streams", no_argument, 0, 'k' },
965 //{"write-bytestream", required_argument,0, 'B' },
966 {0, 0, 0, 0 }
967 };
968
969
970 void show_usage()
971 {
972 fprintf(stderr,
973 "usage: rd-curves 'preset_id' 'input_preset' 'encoder'\n"
974 "supported encoders: de265 / hm / hmscc / x265 / f265 / x264 / mpeg2\n");
975 fprintf(stderr,
976 "presets:\n");
977
978 for (int i=0;preset[i].name!=NULL;i++) {
979 fprintf(stderr,
980 " %2d %-20s %s\n",preset[i].ID,preset[i].name,preset[i].descr);
981 }
982
983 fprintf(stderr,
984 "\ninput presets:\n");
985 for (int i=0;inputSpec[i].name;i++) {
986 fprintf(stderr,
987 " %-12s %-30s %4dx%4d, %4d frames, %5.2f fps\n",
988 inputSpec[i].name,
989 inputSpec[i].filename,
990 inputSpec[i].width,
991 inputSpec[i].height,
992 inputSpec[i].nFrames,
993 inputSpec[i].fps);
994 }
995 }
996
997 int main(int argc, char** argv)
998 {
999 init_clock();
1000
1001 while (1) {
1002 int option_index = 0;
1003
1004 int c = getopt_long(argc, argv, "kf:p:",
1005 long_options, &option_index);
1006 if (c == -1)
1007 break;
1008
1009 switch (c) {
1010 case 'k': keepStreams=true; break;
1011 case 'f': maxFrames=atoi(optarg); break;
1012 case 'p': encoderParameters=optarg; break;
1013 }
1014 }
1015
1016 if (optind != argc-3) {
1017 show_usage();
1018 exit(5);
1019 }
1020
1021 int presetID = atoi( argv[optind] );
1022 const char* inputName = argv[optind+1];
1023 const char* encoderName = argv[optind+2];
1024
1025 int presetIdx = -1;
1026
1027 for (int i=0;preset[i].name != NULL;i++) {
1028 if (preset[i].ID == presetID) {
1029 presetIdx = i;
1030 break;
1031 }
1032 }
1033
1034 if (presetIdx == -1) {
1035 fprintf(stderr,"preset ID %d does not exist\n",presetID);
1036 exit(5);
1037 }
1038
1039 setInput(inputName);
1040 if (maxFrames) input.setMaxFrames(maxFrames);
1041
1042
1043 Encoder* enc = NULL;
1044 /**/ if (strcmp(encoderName,"de265")==0) { enc = &enc_de265; }
1045 else if (strcmp(encoderName,"hm" )==0) { enc = &enc_hm; }
1046 else if (strcmp(encoderName,"hmscc")==0) { enc = &enc_hm; enc_hm.enableSCC(); }
1047 else if (strcmp(encoderName,"x265" )==0) { enc = &enc_x265; }
1048 else if (strcmp(encoderName,"f265" )==0) { enc = &enc_f265; }
1049 else if (strcmp(encoderName,"x264" )==0) { enc = &enc_x264; }
1050 else if (strcmp(encoderName,"mpeg2")==0) { enc = &enc_mpeg2; }
1051
1052 if (enc==NULL) {
1053 fprintf(stderr, "unknown encoder");
1054 exit(5);
1055 }
1056
1057
1058 std::stringstream data_filename;
1059 data_filename << encoderName << "-" << inputName << "-" << preset[presetIdx].name << ".rd";
1060 output_fh = fopen(data_filename.str().c_str(), "wb");
1061
1062 fprintf(output_fh,"# %s\n", preset[presetIdx].descr);
1063 fprintf(output_fh,"# 1:rate 2:psnr 3:ssim 4:cputime(min) 5:walltime(min)\n");
1064
1065 std::vector<RDPoint> curve = enc->encode_curve(preset[presetIdx]);
1066
1067 for (int i=0;i<curve.size();i++) {
1068 //fprintf(out_fh,"%7.2f %6.4f\n", curve[i].rate/1024, curve[i].psnr);
1069 }
1070
1071 fclose(output_fh);
1072
1073 return 0;
1074 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * This file is part of libde265.
5 *
6 * libde265 is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * libde265 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
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with libde265. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include <stdio.h>
21 #include <iostream>
22 #include <string.h>
23
24
25 class Test
26 {
27 public:
28 Test() { next=s_firstTest; s_firstTest=this; }
29 virtual ~Test() { }
30
31 virtual const char* getName() const { return "noname"; }
32 virtual const char* getDescription() const { return "no description"; }
33 virtual bool work(bool quiet=false) = 0;
34
35 static void runTest(const char* name) {
36 Test* t = s_firstTest;
37 while (t) {
38 if (strcmp(t->getName(), name)==0) {
39 t->work();
40 break;
41 }
42 t=t->next;
43 }
44 }
45
46 static void runAllTests() {
47 Test* t = s_firstTest;
48 while (t) {
49 printf("%s ... ",t->getName());
50 fflush(stdout);
51 if (t->work(true) == false) {
52 printf("*** FAILED ***\n");
53 }
54 else {
55 printf("passed\n");
56 }
57
58 t=t->next;
59 }
60 }
61
62 public:
63 Test* next;
64 static Test* s_firstTest;
65 };
66
67 Test* Test::s_firstTest = NULL;
68
69
70 class ListTests : public Test
71 {
72 public:
73 const char* getName() const { return "list"; }
74 const char* getDescription() const { return "list all available tests"; }
75 bool work(bool quiet) {
76 if (!quiet) {
77 Test* t = s_firstTest;
78 while (t) {
79 printf("- %s: %s\n",t->getName(), t->getDescription());
80 t=t->next;
81 }
82 }
83 return true;
84 }
85 } listtest;
86
87
88
89 int main(int argc,char** argv)
90 {
91 if (argc>=2) {
92 Test::runTest(argv[1]);
93 }
94 else {
95 Test::runAllTests();
96 }
97
98 return 0;
99 }
0 /*
1 * H.265 video codec.
2 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
3 *
4 * This file is part of libde265.
5 *
6 * libde265 is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * libde265 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
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with libde265. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23
24 #include <stdio.h>
25 #include <stdlib.h>
26
27 #include <libde265/quality.h>
28
29 #if HAVE_VIDEOGFX
30 #include <libvideogfx.hh>
31 using namespace videogfx;
32 #endif
33
34
35 float ssim(const uint8_t* img1,
36 const uint8_t* img2,
37 int width, int height)
38 {
39 #if HAVE_VIDEOGFX
40 Bitmap<Pixel> ref, coded;
41 ref .Create(width, height); // reference image
42 coded.Create(width, height); // coded image
43
44 for (int y=0;y<height;y++) {
45 memcpy(coded[y], img1 + y*width, width);
46 memcpy(ref[y], img2 + y*width, width);
47 }
48
49 SSIM ssimAlgo;
50 return ssimAlgo.calcMSSIM(ref,coded);
51 #else
52 return 0;
53 #endif
54 }
55
56
57 int main(int argc, char** argv)
58 {
59 if (argc != 5) {
60 fprintf(stderr,"need two YUV files and image size as input: FILE1 FILE2 WIDTH HEIGHT\n");
61 exit(5);
62 }
63
64
65 FILE* fh_ref = fopen(argv[1],"rb");
66 FILE* fh_cmp = fopen(argv[2],"rb");
67
68 int width = atoi(argv[3]);
69 int height = atoi(argv[4]);
70
71 uint8_t* yp_ref = (uint8_t*)malloc(width*height);
72 uint8_t* yp_cmp = (uint8_t*)malloc(width*height);
73
74 double mse_y=0.0, ssim_y=0.0;
75 int nFrames=0;
76
77 for (;;)
78 {
79 if (fread(yp_ref,1,width*height,fh_ref) != width*height) {
80 break;
81 }
82 if (fread(yp_cmp,1,width*height,fh_cmp) != width*height) {
83 break;
84 }
85
86 if (feof(fh_ref)) break;
87 if (feof(fh_cmp)) break;
88
89 fprintf(stderr,"yuv-distortion processing frame %d\r",nFrames+1);
90
91 fseek(fh_ref,width*height/2,SEEK_CUR);
92 fseek(fh_cmp,width*height/2,SEEK_CUR);
93
94 double curr_mse_y = MSE(yp_ref, width, yp_cmp, width, width, height);
95 mse_y += curr_mse_y;
96
97 double curr_ssim_y = ssim(yp_ref, yp_cmp, width, height);
98 ssim_y += curr_ssim_y;
99
100 printf("%4d %f %f\n",nFrames,PSNR(curr_mse_y),curr_ssim_y);
101
102 nFrames++;
103 }
104
105 printf("total: %f %f\n",PSNR(mse_y/nFrames),ssim_y/nFrames);
106 fprintf(stderr,"\n");
107
108 fclose(fh_ref);
109 fclose(fh_cmp);
110
111 return 0;
112 }