diff -Nru libde265-1.0.12/CMakeLists.txt libde265-1.0.15/CMakeLists.txt --- libde265-1.0.12/CMakeLists.txt 2023-06-13 14:01:31.000000000 +0000 +++ libde265-1.0.15/CMakeLists.txt 2023-12-20 10:41:58.000000000 +0000 @@ -2,7 +2,7 @@ project (libde265 LANGUAGES C CXX - VERSION 1.0.12 + VERSION 1.0.15 ) set(CMAKE_CXX_STANDARD 11) @@ -11,7 +11,7 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) # The version number. -set (NUMERIC_VERSION 0x01001200) +set (NUMERIC_VERSION 0x01001500) set (PACKAGE_VERSION ${PROJECT_VERSION}) include (${CMAKE_ROOT}/Modules/CheckCCompilerFlag.cmake) @@ -23,7 +23,7 @@ option(ENABLE_SDL "Enable SDL" ON) if (ENABLE_SDL) - find_package(SDL) + find_package(SDL2) endif() find_package(Threads REQUIRED) @@ -44,7 +44,13 @@ add_definitions(-Wall) endif() -option(DISABLE_SSE "Disable SSE optimizations" OFF) +include(CheckCXXSymbolExists) +check_cxx_symbol_exists(_LIBCPP_VERSION cstdlib HAVE_LIBCPP) +if(HAVE_LIBCPP) + set(LIBS_PRIVATE "-lc++") +else() + set(LIBS_PRIVATE "-lstdc++") +endif() option(BUILD_SHARED_LIBS "Build shared library" ON) if(NOT BUILD_SHARED_LIBS) diff -Nru libde265-1.0.12/README.md libde265-1.0.15/README.md --- libde265-1.0.12/README.md 2023-01-27 13:21:53.000000000 +0000 +++ libde265-1.0.15/README.md 2023-11-21 08:44:01.000000000 +0000 @@ -60,7 +60,7 @@ libde265 has no dependencies on other libraries, but both optional example programs have dependencies on: -- SDL (optional for dec265's YUV overlay output), +- SDL2 (optional for dec265's YUV overlay output), - Qt (required for sherlock265), @@ -146,6 +146,11 @@ - libde265.js JavaScript decoder [source](https://github.com/strukturag/libde265.js), [demo](https://strukturag.github.io/libde265.js/). +## Packaging status + +[![libde265 packaging status](https://repology.org/badge/vertical-allrepos/libde265.svg?exclude_unsupported=1&columns=3&exclude_sources=modules,site&header=libde265%20packaging%20status)](https://repology.org/project/libheif/versions) + + License ======= @@ -155,5 +160,8 @@ See `COPYING` for more details. +The short video clip in the 'testdata' directory is from the movie 'Girl Shy', which is in the public domain. + Copyright (c) 2013-2014 Struktur AG -Contact: Dirk Farin +Copyright (c) 2013-2023 Dirk Farin +Contact: Dirk Farin diff -Nru libde265-1.0.12/config.h.in libde265-1.0.15/config.h.in --- libde265-1.0.12/config.h.in 2023-06-13 14:04:03.000000000 +0000 +++ libde265-1.0.15/config.h.in 2023-12-20 10:44:13.000000000 +0000 @@ -57,7 +57,7 @@ /* Define to 1 if the system has the type `ptrdiff_t'. */ #undef HAVE_PTRDIFF_T -/* Whether libsdl was found. */ +/* Whether libsdl2 was found. */ #undef HAVE_SDL /* Define to 1 if you have the header file. */ diff -Nru libde265-1.0.12/configure libde265-1.0.15/configure --- libde265-1.0.12/configure 2023-06-13 14:03:59.000000000 +0000 +++ libde265-1.0.15/configure 2023-12-20 10:44:08.000000000 +0000 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.71 for libde265 1.0.12. +# Generated by GNU Autoconf 2.71 for libde265 1.0.15. # # Report bugs to . # @@ -621,8 +621,8 @@ # Identity of this package. PACKAGE_NAME='libde265' PACKAGE_TARNAME='libde265' -PACKAGE_VERSION='1.0.12' -PACKAGE_STRING='libde265 1.0.12' +PACKAGE_VERSION='1.0.15' +PACKAGE_STRING='libde265 1.0.15' PACKAGE_BUGREPORT='dirk.farin@gmail.com' PACKAGE_URL='' @@ -1437,7 +1437,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures libde265 1.0.12 to adapt to many kinds of systems. +\`configure' configures libde265 1.0.15 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1509,7 +1509,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libde265 1.0.12:";; + short | recursive ) echo "Configuration of libde265 1.0.15:";; esac cat <<\_ACEOF @@ -1651,7 +1651,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libde265 configure 1.0.12 +libde265 configure 1.0.15 generated by GNU Autoconf 2.71 Copyright (C) 2021 Free Software Foundation, Inc. @@ -2263,7 +2263,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libde265 $as_me 1.0.12, which was +It was created by libde265 $as_me 1.0.15, which was generated by GNU Autoconf 2.71. Invocation command line was $ $0$ac_configure_args_raw @@ -3240,7 +3240,7 @@ ac_config_headers="$ac_config_headers config.h" -NUMERIC_VERSION=0x01001200 # Numeric representation of the version (A.B.C[.D] = 0xAABBCCDD) +NUMERIC_VERSION=0x01001500 # Numeric representation of the version (A.B.C[.D] = 0xAABBCCDD) # From https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html: @@ -3250,7 +3250,7 @@ # If any interfaces have been removed or changed since the last public release, then set age to 0. LIBDE265_CURRENT=1 -LIBDE265_REVISION=5 +LIBDE265_REVISION=8 LIBDE265_AGE=1 # --------------------------------------------------------------------------- @@ -17714,7 +17714,7 @@ # Define the identity of the package. PACKAGE='libde265' - VERSION='1.0.12' + VERSION='1.0.15' printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h @@ -20050,19 +20050,19 @@ if eval "test x$enable_dec265 = xyes" ; then pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sdl" >&5 -printf %s "checking for sdl... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sdl2" >&5 +printf %s "checking for sdl2... " >&6; } if test -n "$SDL_CFLAGS"; then pkg_cv_SDL_CFLAGS="$SDL_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sdl\""; } >&5 - ($PKG_CONFIG --exists --print-errors "sdl") 2>&5 + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sdl2\""; } >&5 + ($PKG_CONFIG --exists --print-errors "sdl2") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_SDL_CFLAGS=`$PKG_CONFIG --cflags "sdl" 2>/dev/null` + pkg_cv_SDL_CFLAGS=`$PKG_CONFIG --cflags "sdl2" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -20074,12 +20074,12 @@ pkg_cv_SDL_LIBS="$SDL_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sdl\""; } >&5 - ($PKG_CONFIG --exists --print-errors "sdl") 2>&5 + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sdl2\""; } >&5 + ($PKG_CONFIG --exists --print-errors "sdl2") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_SDL_LIBS=`$PKG_CONFIG --libs "sdl" 2>/dev/null` + pkg_cv_SDL_LIBS=`$PKG_CONFIG --libs "sdl2" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -20100,9 +20100,9 @@ _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - SDL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "sdl" 2>&1` + SDL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "sdl2" 2>&1` else - SDL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "sdl" 2>&1` + SDL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "sdl2" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$SDL_PKG_ERRORS" >&5 @@ -20235,8 +20235,8 @@ if eval "test $enable_dec265 = yes" && eval "test $have_videogfx != yes" && eval "test $have_sdl != yes" ; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Did not find libvideogfx or libsdl, video output of dec265 will be disabled." >&5 -printf "%s\n" "$as_me: WARNING: Did not find libvideogfx or libsdl, video output of dec265 will be disabled." >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Did not find libvideogfx or libsdl2, video output of dec265 will be disabled." >&5 +printf "%s\n" "$as_me: WARNING: Did not find libvideogfx or libsdl2, video output of dec265 will be disabled." >&2;} fi if eval "test $enable_sherlock265 = yes" && eval "test $have_videogfx != yes" && eval "test $have_swscale != yes" ; then @@ -21196,7 +21196,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by libde265 $as_me 1.0.12, which was +This file was extended by libde265 $as_me 1.0.15, which was generated by GNU Autoconf 2.71. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -21264,7 +21264,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ -libde265 config.status 1.0.12 +libde265 config.status 1.0.15 configured by $0, generated by GNU Autoconf 2.71, with options \\"\$ac_cs_config\\" diff -Nru libde265-1.0.12/configure.ac libde265-1.0.15/configure.ac --- libde265-1.0.12/configure.ac 2023-06-13 14:00:53.000000000 +0000 +++ libde265-1.0.15/configure.ac 2023-12-20 10:42:57.000000000 +0000 @@ -2,11 +2,11 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.68]) -AC_INIT([libde265], [1.0.12], [dirk.farin@gmail.com]) +AC_INIT([libde265], [1.0.15], [dirk.farin@gmail.com]) AC_CONFIG_SRCDIR([libde265/de265.cc]) AC_CONFIG_HEADERS([config.h]) -NUMERIC_VERSION=0x01001200 # Numeric representation of the version (A.B.C[.D] = 0xAABBCCDD) +NUMERIC_VERSION=0x01001500 # Numeric representation of the version (A.B.C[.D] = 0xAABBCCDD) AC_SUBST(NUMERIC_VERSION) # From https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html: @@ -16,7 +16,7 @@ # If any interfaces have been removed or changed since the last public release, then set age to 0. LIBDE265_CURRENT=1 -LIBDE265_REVISION=5 +LIBDE265_REVISION=8 LIBDE265_AGE=1 # --------------------------------------------------------------------------- @@ -308,8 +308,8 @@ fi if eval "test x$enable_dec265 = xyes" ; then - PKG_CHECK_MODULES([SDL], [sdl], - [AC_DEFINE([HAVE_SDL], [1], [Whether libsdl was found.]) + PKG_CHECK_MODULES([SDL], [sdl2], + [AC_DEFINE([HAVE_SDL], [1], [Whether libsdl2 was found.]) AC_SUBST(SDL_CFLAGS) AC_SUBST(SDL_LIBS) have_sdl="yes"], @@ -332,7 +332,7 @@ AM_CONDITIONAL([HAVE_SDL], [test "x$have_sdl" = "xyes"]) if eval "test $enable_dec265 = yes" && eval "test $have_videogfx != yes" && eval "test $have_sdl != yes" ; then - AC_MSG_WARN([Did not find libvideogfx or libsdl, video output of dec265 will be disabled.]) + AC_MSG_WARN([Did not find libvideogfx or libsdl2, video output of dec265 will be disabled.]) fi if eval "test $enable_sherlock265 = yes" && eval "test $have_videogfx != yes" && eval "test $have_swscale != yes" ; then diff -Nru libde265-1.0.12/debian/changelog libde265-1.0.15/debian/changelog --- libde265-1.0.12/debian/changelog 2023-10-24 22:47:00.000000000 +0000 +++ libde265-1.0.15/debian/changelog 2024-01-01 23:12:03.000000000 +0000 @@ -1,9 +1,26 @@ -libde265 (1.0.12-2~22.04.sav0) jammy; urgency=medium +libde265 (1.0.15-1~22.04.sav0) jammy; urgency=medium * Backport to Jammy - * debian/control: Set debhelper-compat (= 12) BD - -- Rob Savoury Tue, 24 Oct 2023 15:47:00 -0700 + -- Rob Savoury Mon, 01 Jan 2024 15:12:03 -0800 + +libde265 (1.0.15-1) unstable; urgency=medium + + * New upstream version 1.0.15 + * Fixes CVE-2023-49465, CVE-2023-49467, CVE-2023-49468. + * Add patch to fix "Libs.private" in libde265.pc. + + -- Joachim Bauch Thu, 21 Dec 2023 09:29:24 +0100 + +libde265 (1.0.13-1) unstable; urgency=medium + + * New upstream version 1.0.13 + * Fixes CVE-2023-47471 (Closes: #1056187), CVE-2023-43887. + * Update patches for new upstream version. + * d/control: Upstream switched examples to SDL2 (Closes: #1038097). + * Update symbols for new upstream version. + + -- Joachim Bauch Tue, 21 Nov 2023 08:59:09 +0100 libde265 (1.0.12-2) unstable; urgency=medium diff -Nru libde265-1.0.12/debian/control libde265-1.0.15/debian/control --- libde265-1.0.12/debian/control 2023-09-19 08:20:11.000000000 +0000 +++ libde265-1.0.15/debian/control 2023-11-21 07:45:01.000000000 +0000 @@ -8,7 +8,7 @@ Build-Depends: debhelper-compat (= 13), qtbase5-dev | libqt4-dev, - libsdl-dev, + libsdl2-dev, libswscale-dev, libx11-dev, libxext-dev, diff -Nru libde265-1.0.12/debian/libde265-0.symbols libde265-1.0.15/debian/libde265-0.symbols --- libde265-1.0.12/debian/libde265-0.symbols 2023-09-19 08:20:11.000000000 +0000 +++ libde265-1.0.15/debian/libde265-0.symbols 2023-11-21 07:54:03.000000000 +0000 @@ -3,8 +3,6 @@ (optional|c++|regex)"^std::_Sp_counted_base<.*@Base$" 1.0.2 (optional|c++|regex)"^std::_Sp_counted_ptr<.*@Base$" 1.0.3 (optional|c++|regex)"^std::_Sp_make_shared_tag.*@Base$" 1.0.4 - (optional|c++|regex)"^std::_Vector_base<.*@Base$" 1.0.7 - (optional|c++|regex)"^std::__cxx11::basic_string<.*@Base$" 1.0.9 (optional|c++|regex)"^std::__cxx11::basic_stringbuf<.*@Base$" 1.0.2 (optional|c++|regex)"^std::vector<.*@Base$" 1.0.2 (optional|c++|regex)"^typeinfo for std::.*@Base$" 1.0.2 diff -Nru libde265-1.0.12/debian/patches/disable_tools.patch libde265-1.0.15/debian/patches/disable_tools.patch --- libde265-1.0.12/debian/patches/disable_tools.patch 2023-09-19 08:20:11.000000000 +0000 +++ libde265-1.0.15/debian/patches/disable_tools.patch 2023-11-21 07:44:14.000000000 +0000 @@ -1,28 +1,6 @@ Description: Disable building of some internal tools that no longer link because internal symbols are no longer exported. Author: Joachim Bauch ---- a/dec265/Makefile.am -+++ b/dec265/Makefile.am -@@ -1,5 +1,5 @@ - --bin_PROGRAMS = dec265 hdrcopy -+bin_PROGRAMS = dec265 - - AM_CPPFLAGS = -I$(top_srcdir)/libde265 -I$(top_srcdir) - -@@ -9,12 +9,6 @@ - dec265_LDADD = ../libde265/libde265.la -lstdc++ - dec265_SOURCES = dec265.cc - --hdrcopy_DEPENDENCIES = ../libde265/libde265.la --hdrcopy_CXXFLAGS = --hdrcopy_LDFLAGS = --hdrcopy_LDADD = ../libde265/libde265.la -lstdc++ --hdrcopy_SOURCES = hdrcopy.cc -- - if HAVE_VIDEOGFX - dec265_CXXFLAGS += $(VIDEOGFX_CFLAGS) - dec265_LDFLAGS += $(VIDEOGFX_LIBS) --- a/Makefile.am +++ b/Makefile.am @@ -8,13 +8,6 @@ diff -Nru libde265-1.0.12/debian/patches/fix-private-libs-pc.patch libde265-1.0.15/debian/patches/fix-private-libs-pc.patch --- libde265-1.0.12/debian/patches/fix-private-libs-pc.patch 1970-01-01 00:00:00.000000000 +0000 +++ libde265-1.0.15/debian/patches/fix-private-libs-pc.patch 2023-12-21 08:26:14.000000000 +0000 @@ -0,0 +1,26 @@ +Description: Fix missing "LIBS_PRIVATE" variable for libde265.pc in + autoconf builds. +From 56d1cf52e43d734692721c99b72815c0fee1f184 Mon Sep 17 00:00:00 2001 +From: Joachim Bauch +Date: Thu, 21 Dec 2023 09:22:58 +0100 +Subject: [PATCH] Fix missing "LIBS_PRIVATE" for libde265.pc in autoconf + builds. +Forwarded: https://github.com/strukturag/libde265/pull/439 +--- + configure.ac | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/configure.ac b/configure.ac +index 770f5025..798e9a2c 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -104,6 +104,9 @@ AC_FUNC_ERROR_AT_LINE + # AC_FUNC_REALLOC + AC_FUNC_MKTIME + ++LIBS_PRIVATE="$LIBS -lstdc++" ++AC_SUBST(LIBS_PRIVATE) ++ + AM_CONDITIONAL(MINGW, expr $host : '.*-mingw' >/dev/null 2>&1) + + # Check if "__STRICT_ANSI__" is required. diff -Nru libde265-1.0.12/debian/patches/recycle_sps_if_possible.patch libde265-1.0.15/debian/patches/recycle_sps_if_possible.patch --- libde265-1.0.12/debian/patches/recycle_sps_if_possible.patch 2023-09-19 08:20:11.000000000 +0000 +++ libde265-1.0.15/debian/patches/recycle_sps_if_possible.patch 2023-11-21 07:44:22.000000000 +0000 @@ -23,11 +23,11 @@ libde265/sps.cc | 6 + 2 files changed, 279 insertions(+) -diff --git a/libde265/decctx.cc b/libde265/decctx.cc -index 6701725f..0000b25d 100644 ---- a/libde265/decctx.cc -+++ b/libde265/decctx.cc -@@ -545,6 +545,263 @@ de265_error decoder_context::read_vps_NAL(bitreader& reader) +Index: libde265/libde265/decctx.cc +=================================================================== +--- libde265.orig/libde265/decctx.cc ++++ libde265/libde265/decctx.cc +@@ -546,6 +546,263 @@ de265_error decoder_context::read_vps_NA return DE265_OK; } @@ -291,7 +291,7 @@ de265_error decoder_context::read_sps_NAL(bitreader& reader) { logdebug(LogHeaders,"----> read SPS\n"); -@@ -560,6 +817,22 @@ de265_error decoder_context::read_sps_NAL(bitreader& reader) +@@ -561,6 +818,22 @@ de265_error decoder_context::read_sps_NA new_sps->dump(param_sps_headers_fd); } @@ -314,11 +314,11 @@ sps[ new_sps->seq_parameter_set_id ] = new_sps; // Remove the all PPS that referenced the old SPS because parameters may have changed and we do not want to -diff --git a/libde265/sps.cc b/libde265/sps.cc -index f1c28255..31ce9470 100644 ---- a/libde265/sps.cc -+++ b/libde265/sps.cc -@@ -287,6 +287,11 @@ de265_error seq_parameter_set::read(error_queue* errqueue, bitreader* br) +Index: libde265/libde265/sps.cc +=================================================================== +--- libde265.orig/libde265/sps.cc ++++ libde265/libde265/sps.cc +@@ -287,6 +287,11 @@ de265_error seq_parameter_set::read(erro int firstLayer = (sps_sub_layer_ordering_info_present_flag ? 0 : sps_max_sub_layers-1 ); @@ -330,7 +330,7 @@ for (int i=firstLayer ; i <= sps_max_sub_layers-1; i++ ) { // sps_max_dec_pic_buffering[i] -@@ -347,6 +352,7 @@ de265_error seq_parameter_set::read(error_queue* errqueue, bitreader* br) +@@ -347,6 +352,7 @@ de265_error seq_parameter_set::read(erro if (sps_scaling_list_data_present_flag) { de265_error err; diff -Nru libde265-1.0.12/debian/patches/series libde265-1.0.15/debian/patches/series --- libde265-1.0.12/debian/patches/series 2023-09-19 08:20:11.000000000 +0000 +++ libde265-1.0.15/debian/patches/series 2023-12-21 08:04:40.000000000 +0000 @@ -3,3 +3,4 @@ reject_reference_pics_from_different_sps.patch use_sps_from_the_image.patch recycle_sps_if_possible.patch +fix-private-libs-pc.patch diff -Nru libde265-1.0.12/dec265/CMakeLists.txt libde265-1.0.15/dec265/CMakeLists.txt --- libde265-1.0.12/dec265/CMakeLists.txt 2023-06-13 13:54:12.000000000 +0000 +++ libde265-1.0.15/dec265/CMakeLists.txt 2023-11-20 16:30:00.000000000 +0000 @@ -2,15 +2,15 @@ target_link_libraries (dec265 PRIVATE de265) -if(SDL_FOUND) +if(SDL2_FOUND) target_sources(dec265 PRIVATE sdl.cc) target_compile_definitions(dec265 PRIVATE HAVE_SDL) - target_include_directories (dec265 PRIVATE "${SDL_INCLUDE_DIR}") - target_link_libraries (dec265 PRIVATE ${SDL_LIBRARY}) + target_include_directories (dec265 PRIVATE "${SDL2_INCLUDE_DIRS}") + target_link_libraries (dec265 PRIVATE ${SDL2_LIBRARIES}) endif() if(MSVC) - target_sources(dec265 PRIVATE + target_sources(dec265 PRIVATE ../extra/getopt.c ../extra/getopt_long.c ) @@ -18,11 +18,11 @@ install (TARGETS dec265 DESTINATION ${CMAKE_INSTALL_BINDIR}) -if(NOT MSVC) - # hdrcopy uses internal APIs that are not available when compiled for Windows - add_executable (hdrcopy hdrcopy.cc) - - target_link_libraries (hdrcopy PRIVATE de265) - - install (TARGETS hdrcopy DESTINATION ${CMAKE_INSTALL_BINDIR}) -endif() +#if(NOT MSVC) +# # hdrcopy uses internal APIs that are not available when compiled for Windows +# add_executable (hdrcopy hdrcopy.cc) +# +# target_link_libraries (hdrcopy PRIVATE de265) +# +# install (TARGETS hdrcopy DESTINATION ${CMAKE_INSTALL_BINDIR}) +#endif() diff -Nru libde265-1.0.12/dec265/Makefile.am libde265-1.0.15/dec265/Makefile.am --- libde265-1.0.12/dec265/Makefile.am 2023-06-13 13:54:12.000000000 +0000 +++ libde265-1.0.15/dec265/Makefile.am 2023-11-20 16:37:23.000000000 +0000 @@ -1,5 +1,5 @@ -bin_PROGRAMS = dec265 hdrcopy +bin_PROGRAMS = dec265 # hdrcopy AM_CPPFLAGS = -I$(top_srcdir)/libde265 -I$(top_srcdir) @@ -9,11 +9,11 @@ dec265_LDADD = ../libde265/libde265.la -lstdc++ dec265_SOURCES = dec265.cc -hdrcopy_DEPENDENCIES = ../libde265/libde265.la -hdrcopy_CXXFLAGS = -hdrcopy_LDFLAGS = -hdrcopy_LDADD = ../libde265/libde265.la -lstdc++ -hdrcopy_SOURCES = hdrcopy.cc +# hdrcopy_DEPENDENCIES = ../libde265/libde265.la +# hdrcopy_CXXFLAGS = +# hdrcopy_LDFLAGS = +# hdrcopy_LDADD = ../libde265/libde265.la -lstdc++ +# hdrcopy_SOURCES = hdrcopy.cc if HAVE_VIDEOGFX dec265_CXXFLAGS += $(VIDEOGFX_CFLAGS) diff -Nru libde265-1.0.12/dec265/Makefile.in libde265-1.0.15/dec265/Makefile.in --- libde265-1.0.12/dec265/Makefile.in 2023-06-13 14:03:59.000000000 +0000 +++ libde265-1.0.15/dec265/Makefile.in 2023-12-20 10:44:08.000000000 +0000 @@ -89,7 +89,13 @@ build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ -bin_PROGRAMS = dec265$(EXEEXT) hdrcopy$(EXEEXT) +bin_PROGRAMS = dec265$(EXEEXT) + +# hdrcopy_DEPENDENCIES = ../libde265/libde265.la +# hdrcopy_CXXFLAGS = +# hdrcopy_LDFLAGS = +# hdrcopy_LDADD = ../libde265/libde265.la -lstdc++ +# hdrcopy_SOURCES = hdrcopy.cc @HAVE_VIDEOGFX_TRUE@am__append_1 = $(VIDEOGFX_CFLAGS) @HAVE_VIDEOGFX_TRUE@am__append_2 = $(VIDEOGFX_LIBS) @HAVE_SDL_TRUE@am__append_3 = $(SDL_CFLAGS) @@ -125,11 +131,6 @@ dec265_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(dec265_CXXFLAGS) \ $(CXXFLAGS) $(dec265_LDFLAGS) $(LDFLAGS) -o $@ -am_hdrcopy_OBJECTS = hdrcopy-hdrcopy.$(OBJEXT) -hdrcopy_OBJECTS = $(am_hdrcopy_OBJECTS) -hdrcopy_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(hdrcopy_CXXFLAGS) \ - $(CXXFLAGS) $(hdrcopy_LDFLAGS) $(LDFLAGS) -o $@ AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -146,7 +147,7 @@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/dec265-dec265.Po \ - ./$(DEPDIR)/dec265-sdl.Po ./$(DEPDIR)/hdrcopy-hdrcopy.Po + ./$(DEPDIR)/dec265-sdl.Po am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) @@ -184,8 +185,8 @@ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = -SOURCES = $(dec265_SOURCES) $(hdrcopy_SOURCES) -DIST_SOURCES = $(am__dec265_SOURCES_DIST) $(hdrcopy_SOURCES) +SOURCES = $(dec265_SOURCES) +DIST_SOURCES = $(am__dec265_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -365,11 +366,6 @@ dec265_LDFLAGS = $(am__append_2) $(am__append_4) $(am__append_6) dec265_LDADD = ../libde265/libde265.la -lstdc++ dec265_SOURCES = dec265.cc $(am__append_5) -hdrcopy_DEPENDENCIES = ../libde265/libde265.la -hdrcopy_CXXFLAGS = -hdrcopy_LDFLAGS = -hdrcopy_LDADD = ../libde265/libde265.la -lstdc++ -hdrcopy_SOURCES = hdrcopy.cc EXTRA_DIST = Makefile.vc7 \ CMakeLists.txt \ ../extra/getopt.c \ @@ -463,10 +459,6 @@ @rm -f dec265$(EXEEXT) $(AM_V_CXXLD)$(dec265_LINK) $(dec265_OBJECTS) $(dec265_LDADD) $(LIBS) -hdrcopy$(EXEEXT): $(hdrcopy_OBJECTS) $(hdrcopy_DEPENDENCIES) $(EXTRA_hdrcopy_DEPENDENCIES) - @rm -f hdrcopy$(EXEEXT) - $(AM_V_CXXLD)$(hdrcopy_LINK) $(hdrcopy_OBJECTS) $(hdrcopy_LDADD) $(LIBS) - mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -475,7 +467,6 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dec265-dec265.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dec265-sdl.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hdrcopy-hdrcopy.Po@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @@ -532,20 +523,6 @@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @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` -hdrcopy-hdrcopy.o: hdrcopy.cc -@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 -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hdrcopy-hdrcopy.Tpo $(DEPDIR)/hdrcopy-hdrcopy.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='hdrcopy.cc' object='hdrcopy-hdrcopy.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@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 - -hdrcopy-hdrcopy.obj: hdrcopy.cc -@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` -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hdrcopy-hdrcopy.Tpo $(DEPDIR)/hdrcopy-hdrcopy.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='hdrcopy.cc' object='hdrcopy-hdrcopy.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@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` - mostlyclean-libtool: -rm -f *.lo @@ -680,7 +657,6 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/dec265-dec265.Po -rm -f ./$(DEPDIR)/dec265-sdl.Po - -rm -f ./$(DEPDIR)/hdrcopy-hdrcopy.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags @@ -728,7 +704,6 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/dec265-dec265.Po -rm -f ./$(DEPDIR)/dec265-sdl.Po - -rm -f ./$(DEPDIR)/hdrcopy-hdrcopy.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic diff -Nru libde265-1.0.12/dec265/dec265.cc libde265-1.0.15/dec265/dec265.cc --- libde265-1.0.12/dec265/dec265.cc 2023-06-13 13:54:12.000000000 +0000 +++ libde265-1.0.15/dec265/dec265.cc 2023-11-23 18:03:10.000000000 +0000 @@ -55,10 +55,15 @@ #include "sdl.hh" #endif +#ifndef PRIu32 +#define PRIu32 "u" +#endif #define BUFFER_SIZE 40960 #define NUM_THREADS 4 +const uint32_t kSecurityLimit_MaxNALSize = 100 * 1024 * 1024; // 100 MB + int nThreads=0; bool nal_input=false; int quiet=0; @@ -666,6 +671,10 @@ if (measure_quality) { reference_file = fopen(reference_filename, "rb"); + if (reference_file == nullptr) { + fprintf(stderr, "Error: cannot create measurement output file '%s'\n", reference_filename); + exit(5); + } } @@ -703,20 +712,31 @@ if (nal_input) { uint8_t len[4]; int n = fread(len,1,4,fh); - int length = (len[0]<<24) + (len[1]<<16) + (len[2]<<8) + len[3]; - - uint8_t* buf = (uint8_t*)malloc(length); - n = fread(buf,1,length,fh); - err = de265_push_NAL(ctx, buf,n, pos, (void*)1); - - if (write_bytestream) { - uint8_t sc[3] = { 0,0,1 }; - fwrite(sc ,1,3,bytestream_fh); - fwrite(buf,1,n,bytestream_fh); - } + uint32_t length = (len[0]<<24) + (len[1]<<16) + (len[2]<<8) + len[3]; - free(buf); - pos+=n; + if (length > kSecurityLimit_MaxNALSize) { + fprintf(stderr, "NAL packet with size %" PRIu32 " exceeds security limit %" PRIu32 ", skipping this NAL.\n", + length, + kSecurityLimit_MaxNALSize); + + fseek(fh, length, SEEK_CUR); + + pos += length; + } + else { + uint8_t* buf = (uint8_t*)malloc(length); + n = fread(buf,1,length,fh); + err = de265_push_NAL(ctx, buf,n, pos, (void*)1); + + if (write_bytestream) { + uint8_t sc[3] = { 0,0,1 }; + fwrite(sc ,1,3,bytestream_fh); + fwrite(buf,1,n,bytestream_fh); + } + + free(buf); + pos+=n; + } } else { // read a chunk of input data diff -Nru libde265-1.0.12/dec265/hdrcopy.cc libde265-1.0.15/dec265/hdrcopy.cc --- libde265-1.0.12/dec265/hdrcopy.cc 2022-10-19 14:34:13.000000000 +0000 +++ libde265-1.0.15/dec265/hdrcopy.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,124 +0,0 @@ -/* - libde265 example application. - - MIT License - - Copyright (c) 2013-2014 struktur AG, Dirk Farin - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ - - -#include "libde265/nal-parser.h" -#include "libde265/decctx.h" -#include - -error_queue errqueue; - -video_parameter_set vps; -seq_parameter_set sps; -pic_parameter_set pps; - -CABAC_encoder_bitstream writer; - - -void process_nal(NAL_unit* nal) -{ - de265_error err = DE265_OK; - - bitreader reader; - bitreader_init(&reader, nal->data(), nal->size()); - - nal_header nal_hdr; - nal_hdr.read(&reader); - writer.write_startcode(); - nal_hdr.write(writer); - - printf("NAL: 0x%x 0x%x - unit type:%s temporal id:%d\n", - nal->data()[0], nal->data()[1], - get_NAL_name(nal_hdr.nal_unit_type), - nal_hdr.nuh_temporal_id); - - - if (nal_hdr.nal_unit_type<32) { - //err = read_slice_NAL(reader, nal, nal_hdr); - } - else switch (nal_hdr.nal_unit_type) { - case NAL_UNIT_VPS_NUT: - vps.read(&errqueue, &reader); - vps.dump(1); - vps.write(&errqueue, writer); - writer.flush_VLC(); - break; - - case NAL_UNIT_SPS_NUT: - sps.read(&errqueue, &reader); - sps.dump(1); - sps.write(&errqueue, writer); - writer.flush_VLC(); - break; - - case NAL_UNIT_PPS_NUT: - //err = read_pps_NAL(reader); - break; - - case NAL_UNIT_PREFIX_SEI_NUT: - case NAL_UNIT_SUFFIX_SEI_NUT: - //err = read_sei_NAL(reader, nal_hdr.nal_unit_type==NAL_UNIT_SUFFIX_SEI_NUT); - break; - - case NAL_UNIT_EOS_NUT: - //ctx->FirstAfterEndOfSequenceNAL = true; - break; - } -} - - -int main(int argc, char** argv) -{ - NAL_Parser nal_parser; - - FILE* fh = fopen(argv[1],"rb"); - unsigned char buf[1024]; - - writer.write_bits(0,8); // because HM has an extra byte at the beginning - - while(!feof(fh)) - { - int n = fread(buf,1,1024,fh); - if (n>0) { - nal_parser.push_data(buf,n, 0); - } - - if (nal_parser.get_NAL_queue_length()>0) { - NAL_unit* nal = nal_parser.pop_from_NAL_queue(); - assert(nal); - process_nal(nal); - nal_parser.free_NAL_unit(nal); - } - } - - fclose(fh); - - fh = fopen("out.bin","wb"); - fwrite(writer.data(), 1,writer.size(), fh); - fclose(fh); - - return 0; -} diff -Nru libde265-1.0.12/dec265/sdl.cc libde265-1.0.15/dec265/sdl.cc --- libde265-1.0.12/dec265/sdl.cc 2022-10-19 14:34:13.000000000 +0000 +++ libde265-1.0.15/dec265/sdl.cc 2023-11-23 18:43:05.000000000 +0000 @@ -37,51 +37,49 @@ mChroma = chroma; - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0 ) { + if (SDL_Init(SDL_INIT_VIDEO) < 0 ) { printf("SDL_Init() failed: %s\n", SDL_GetError( ) ); SDL_Quit(); return false; } - const SDL_VideoInfo* info = SDL_GetVideoInfo(); - if( !info ) { - printf("SDL_GetVideoInfo() failed: %s\n", SDL_GetError() ); + // set window title + const char *window_title = "SDL YUV display"; + mWindow = SDL_CreateWindow(window_title, + SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, + frame_width, frame_height, 0); + if (!mWindow) { + printf("SDL: Couldn't set video mode to %dx%d: %s\n", + frame_width, frame_height, SDL_GetError()); SDL_Quit(); return false; } - Uint8 bpp = info->vfmt->BitsPerPixel; - - Uint32 vflags; - if (info->hw_available) - vflags = SDL_HWSURFACE; - else - vflags = SDL_SWSURFACE; - - // set window title - const char *window_title = "SDL YUV display"; - SDL_WM_SetCaption(window_title, NULL); - - mScreen = SDL_SetVideoMode(frame_width, frame_height, bpp, vflags); - if (mScreen == NULL) { - printf("SDL: Couldn't set video mode to %dx%d,%d bpp: %s", - frame_width, frame_height, bpp, SDL_GetError()); + Uint32 flags = 0; // Empty flags prioritize SDL_RENDERER_ACCELERATED. + mRenderer = SDL_CreateRenderer(mWindow, -1, flags); + if (!mRenderer) { + printf("SDL: Couldn't create renderer: %s\n", SDL_GetError()); SDL_Quit(); return false; } - uint32_t pixelFormat; + Uint32 pixelFormat = 0; switch (mChroma) { - case SDL_CHROMA_MONO: pixelFormat = SDL_YV12_OVERLAY; break; - case SDL_CHROMA_420: pixelFormat = SDL_YV12_OVERLAY; break; - case SDL_CHROMA_422: pixelFormat = SDL_YUY2_OVERLAY; break; - case SDL_CHROMA_444: pixelFormat = SDL_YV12_OVERLAY; break; - //case SDL_CHROMA_444: pixelFormat = SDL_YUY2_OVERLAY; break; + case SDL_CHROMA_MONO: pixelFormat = SDL_PIXELFORMAT_YV12; break; + case SDL_CHROMA_420: pixelFormat = SDL_PIXELFORMAT_YV12; break; + case SDL_CHROMA_422: pixelFormat = SDL_PIXELFORMAT_YV12; break; + case SDL_CHROMA_444: pixelFormat = SDL_PIXELFORMAT_YV12; break; + //case SDL_CHROMA_444: pixelFormat = SDL_PIXELFORMAT_YV12; break; + default: + printf("Unsupported chroma: %d\n", mChroma); + SDL_Quit(); + return false; } - mYUVOverlay = SDL_CreateYUVOverlay(frame_width, frame_height, pixelFormat, mScreen); - if (mYUVOverlay == NULL ) { - printf("SDL: Couldn't create SDL YUV overlay: %s",SDL_GetError()); + mTexture = SDL_CreateTexture(mRenderer, pixelFormat, + SDL_TEXTUREACCESS_STREAMING, frame_width, frame_height); + if (!mTexture ) { + printf("SDL: Couldn't create SDL texture: %s\n", SDL_GetError()); SDL_Quit(); return false; } @@ -102,7 +100,8 @@ int stride, int chroma_stride) { if (!mWindowOpen) return; - if (SDL_LockYUVOverlay(mYUVOverlay) < 0) return; + if (SDL_LockTexture(mTexture, nullptr, + reinterpret_cast(&mPixels), &mStride) < 0) return; if (mChroma == SDL_CHROMA_420) { display420(Y,U,V,stride,chroma_stride); @@ -118,9 +117,10 @@ display400(Y,stride); } - SDL_UnlockYUVOverlay(mYUVOverlay); + SDL_UnlockTexture(mTexture); - SDL_DisplayYUVOverlay(mYUVOverlay, &rect); + SDL_RenderCopy(mRenderer, mTexture, nullptr, nullptr); + SDL_RenderPresent(mRenderer); } @@ -129,26 +129,31 @@ const unsigned char *V, int stride, int chroma_stride) { - if (stride == rect.w && chroma_stride == rect.w/2) { + if (stride == mStride && chroma_stride == mStride/2) { // fast copy - memcpy(mYUVOverlay->pixels[0], Y, rect.w * rect.h); - memcpy(mYUVOverlay->pixels[1], V, rect.w * rect.h / 4); - memcpy(mYUVOverlay->pixels[2], U, rect.w * rect.h / 4); + memcpy(mPixels, Y, rect.w * rect.h); + memcpy(&mPixels[rect.w * rect.h], V, rect.w * rect.h / 4); + memcpy(&mPixels[(rect.w * rect.h) + (rect.w * rect.h / 4)], U, rect.w * rect.h / 4); } else { // copy line by line, because sizes are different + uint8_t *dest = mPixels; + + for (int y=0;ypixels[0]+y*rect.w, Y+stride*y, rect.w); + memcpy(dest, V+chroma_stride*y, rect.w/2); } - for (int y=0;ypixels[2]+y*rect.w/2, U+chroma_stride*y, rect.w/2); - memcpy(mYUVOverlay->pixels[1]+y*rect.w/2, V+chroma_stride*y, rect.w/2); + memcpy(dest, U+chroma_stride*y, rect.w/2); } } } @@ -156,48 +161,51 @@ void SDL_YUV_Display::display400(const unsigned char *Y, int stride) { - if (stride == rect.w) { + uint8_t *dest = mPixels; + if (stride == mStride) { // fast copy - memcpy(mYUVOverlay->pixels[0], Y, rect.w * rect.h); + memcpy(mPixels, Y, rect.w * rect.h); + dest += mStride * rect.h; } else { // copy line by line, because sizes are different - for (int y=0;ypixels[0]+y*rect.w, Y+stride*y, rect.w); + memcpy(dest, Y+stride*y, rect.w); } } // clear chroma planes - memset(mYUVOverlay->pixels[1], 0x80, rect.w * rect.h / 4); - memset(mYUVOverlay->pixels[2], 0x80, rect.w * rect.h / 4); + memset(dest, 0x80, mStride * rect.h / 2); } -void SDL_YUV_Display::display422(const unsigned char *Y, - const unsigned char *U, - const unsigned char *V, +void SDL_YUV_Display::display422(const unsigned char* Y, + const unsigned char* U, + const unsigned char* V, int stride, int chroma_stride) { - for (int y=0;ypixels[0] + y*rect.w *2; + for (int y = 0; y < rect.h; y++) { + unsigned char* dstY = mPixels + y * mStride; + const unsigned char* Yp = Y + y * stride; - const unsigned char* Yp = Y + y*stride; - const unsigned char* Up = U + y*chroma_stride; - const unsigned char* Vp = V + y*chroma_stride; + memcpy(dstY, Yp, rect.w); + } - for (int x=0;xpixels[0] + y*rect.w *2; + unsigned char* p = mPixels + y*mStride *2; const unsigned char* Yp = Y + y*stride; const unsigned char* Up = U + y*chroma_stride; @@ -234,14 +242,16 @@ { for (int y=0;ypixels[0] + y*rect.w; + unsigned char* p = mPixels + y*mStride; memcpy(p, Y+y*stride, rect.w); } + uint8_t *startV = mPixels + (rect.h*mStride); + uint8_t *startU = startV + (rect.h*mStride/2); for (int y=0;ypixels[2] + y/2*rect.w/2; - unsigned char* v = mYUVOverlay->pixels[1] + y/2*rect.w/2; + unsigned char* u = startU + y/2*mStride/2; + unsigned char* v = startV + y/2*mStride/2; for (int x=0;x=8) { append_byte((vlc_buffer >> (vlc_buffer_len-8)) & 0xFF); vlc_buffer_len -= 8; @@ -524,6 +526,8 @@ void CABAC_encoder_bitstream::flush_VLC() { + // TODO: errors returned by append_byte() are ignored, resulting in a broken output. + while (vlc_buffer_len>=8) { append_byte((vlc_buffer >> (vlc_buffer_len-8)) & 0xFF); vlc_buffer_len -= 8; @@ -557,7 +561,7 @@ } -void CABAC_encoder_bitstream::check_size_and_resize(int nBytes) +bool CABAC_encoder_bitstream::check_size_and_resize(int nBytes) { if (data_size+nBytes > data_capacity) { // 1 extra byte for stuffing if (data_capacity==0) { @@ -566,14 +570,24 @@ data_capacity *= 2; } - data_mem = (uint8_t*)realloc(data_mem,data_capacity); + uint8_t* new_data_mem = (uint8_t*)realloc(data_mem,data_capacity); + if (new_data_mem) { + data_mem = new_data_mem; + } + else { + return false; + } } + + return true; } -void CABAC_encoder_bitstream::append_byte(int byte) +bool CABAC_encoder_bitstream::append_byte(int byte) { - check_size_and_resize(2); + if (!check_size_and_resize(2)) { + return false; + } // --- emulation prevention --- @@ -603,17 +617,23 @@ // write actual data byte data_mem[ data_size++ ] = byte; + + return true; } -void CABAC_encoder_bitstream::write_startcode() +bool CABAC_encoder_bitstream::write_startcode() { - check_size_and_resize(3); + if (!check_size_and_resize(3)) { + return false; + } data_mem[ data_size+0 ] = 0; data_mem[ data_size+1 ] = 0; data_mem[ data_size+2 ] = 1; data_size+=3; + + return true; } void CABAC_encoder_bitstream::init_CABAC() @@ -628,6 +648,8 @@ void CABAC_encoder_bitstream::flush_CABAC() { + // TODO: errors returned by append_byte() are ignored, resulting in a broken output. + if (low >> (32 - bits_left)) { append_byte(buffered_byte + 1); @@ -661,6 +683,8 @@ void CABAC_encoder_bitstream::write_out() { + // TODO: errors returned by append_byte() are ignored, resulting in a broken output. + //logtrace(LogCABAC,"low = %08x (bits_left=%d)\n",low,bits_left); int leadByte = low >> (24 - bits_left); bits_left += 8; diff -Nru libde265-1.0.12/libde265/cabac.h libde265-1.0.15/libde265/cabac.h --- libde265-1.0.12/libde265/cabac.h 2023-02-20 12:02:19.000000000 +0000 +++ libde265-1.0.15/libde265/cabac.h 2023-11-04 14:31:00.000000000 +0000 @@ -66,7 +66,7 @@ virtual void write_bit(int bit) { write_bits(bit,1); } virtual void write_uvlc(int value); virtual void write_svlc(int value); - virtual void write_startcode() = 0; + virtual bool write_startcode() = 0; virtual void skip_bits(int nBits) = 0; virtual void add_trailing_bits(); @@ -113,7 +113,7 @@ // --- VLC --- virtual void write_bits(uint32_t bits,int n); - virtual void write_startcode(); + virtual bool write_startcode(); virtual void skip_bits(int nBits); virtual int number_free_bits_in_byte() const; @@ -155,10 +155,10 @@ uint16_t num_buffered_bytes; - void check_size_and_resize(int nBytes); + bool check_size_and_resize(int nBytes); void testAndWriteOut(); void write_out(); - void append_byte(int byte); + bool append_byte(int byte); }; @@ -178,7 +178,7 @@ virtual void write_bits(uint32_t bits,int n) { mFracBits += n<<15; } virtual void write_bit(int bit) { mFracBits+=1<<15; } - virtual void write_startcode() { mFracBits += (1<<15)*8*3; } + virtual bool write_startcode() { mFracBits += (1<<15)*8*3; return true; } virtual void skip_bits(int nBits) { mFracBits += nBits<<15; } virtual int number_free_bits_in_byte() const { return 0; } // TODO, good enough for now diff -Nru libde265-1.0.12/libde265/configparam.cc libde265-1.0.15/libde265/configparam.cc --- libde265-1.0.12/libde265/configparam.cc 2021-01-24 19:57:56.000000000 +0000 +++ libde265-1.0.15/libde265/configparam.cc 2023-11-04 14:31:00.000000000 +0000 @@ -236,7 +236,7 @@ bool option_found=false; - for (int o=0;ohasLongOption() && strcmp(mOptions[o]->getLongOption().c_str(), argv[i]+2)==0) { option_found=true; @@ -271,7 +271,7 @@ bool option_found=false; - for (int o=0;ogetShortOption() == option) { option_found=true; @@ -318,7 +318,7 @@ void config_parameters::print_params() const { - for (int i=0;i new_pps = std::make_shared(); bool success = new_pps->read(&reader,this); + if (!success) { + return DE265_WARNING_PPS_HEADER_INVALID; + } if (param_pps_headers_fd>=0) { new_pps->dump(param_pps_headers_fd); } - if (success) { - pps[ (int)new_pps->pic_parameter_set_id ] = new_pps; - } + pps[ (int)new_pps->pic_parameter_set_id ] = new_pps; - return success ? DE265_OK : DE265_WARNING_PPS_HEADER_INVALID; + return DE265_OK; } de265_error decoder_context::read_sei_NAL(bitreader& reader, bool suffix) @@ -703,7 +704,7 @@ template void pop_front(std::vector& vec) { - for (int i=1;isuffix_SEIs.size();i++) { + for (size_t i=0;isuffix_SEIs.size();i++) { const sei_message& sei = imgunit->suffix_SEIs[i]; err = process_sei(&sei, imgunit->img); @@ -1093,7 +1094,7 @@ img->wait_for_completion(); - for (int i=0;itasks.size();i++) + for (size_t i=0;itasks.size();i++) delete imgunit->tasks[i]; imgunit->tasks.clear(); @@ -1183,7 +1184,7 @@ img->wait_for_completion(); - for (int i=0;itasks.size();i++) + for (size_t i=0;itasks.size();i++) delete imgunit->tasks[i]; imgunit->tasks.clear(); @@ -1474,7 +1475,7 @@ lower POCs seems to be compliant to the reference decoder. */ - for (int i=0;iPicState != UnusedForReference && @@ -2144,7 +2145,7 @@ void decoder_context::remove_images_from_dpb(const std::vector& removeImageList) { - for (int i=0;i=0) { //printf("remove ID %d\n", removeImageList[i]); diff -Nru libde265-1.0.12/libde265/decctx.h libde265-1.0.15/libde265/decctx.h --- libde265-1.0.12/libde265/decctx.h 2023-06-13 13:54:12.000000000 +0000 +++ libde265-1.0.15/libde265/decctx.h 2023-11-04 14:31:00.000000000 +0000 @@ -203,7 +203,7 @@ std::vector suffix_SEIs; slice_unit* get_next_unprocessed_slice_segment() const { - for (int i=0;istate == slice_unit::Unprocessed) { return slice_units[i]; } @@ -213,7 +213,7 @@ } slice_unit* get_prev_slice_segment(slice_unit* s) const { - for (int i=1; iPicOrderCntVal, dpb[i]->get_ID(), @@ -63,7 +63,7 @@ if (dpb.size() < max_images_in_DPB) return true; // scan for empty slots - for (int i=0;iPicOutputFlag==false && dpb[i]->PicState == UnusedForReference) { return true; } @@ -81,7 +81,7 @@ //loginfo(LogDPB,"searching for short-term reference POC=%d\n",poc); if (preferLongTerm) { - for (int k=0;kPicOrderCntVal == poc && dpb[k]->removed_at_picture_id > currentID && dpb[k]->PicState == UsedForLongTermReference) { @@ -90,7 +90,7 @@ } } - for (int k=0;kPicOrderCntVal == poc && dpb[k]->removed_at_picture_id > currentID && dpb[k]->PicState != UnusedForReference) { @@ -107,7 +107,7 @@ logdebug(LogHeaders,"get access to picture with LSB %d from DPB\n",lsb); if (preferLongTerm) { - for (int k=0;kpicture_order_cnt_lsb == lsb && dpb[k]->removed_at_picture_id > currentID && dpb[k]->PicState == UsedForLongTermReference) { @@ -116,7 +116,7 @@ } } - for (int k=0;kpicture_order_cnt_lsb == lsb && dpb[k]->removed_at_picture_id > currentID && dpb[k]->PicState != UnusedForReference) { @@ -132,7 +132,7 @@ { logdebug(LogHeaders,"get access to picture with ID %d from DPB\n",id); - for (int k=0;kget_ID() == id) { return k; } @@ -150,7 +150,7 @@ int minPOC = reorder_output_queue[0]->PicOrderCntVal; int minIdx = 0; - for (int i=1;iPicOrderCntVal < minPOC) { minPOC = reorder_output_queue[i]->PicOrderCntVal; @@ -186,7 +186,7 @@ void decoded_picture_buffer::clear() { - for (int i=0;iPicOutputFlag || dpb[i]->PicState != UnusedForReference) { @@ -211,7 +211,7 @@ // --- search for a free slot in the DPB --- int free_image_buffer_idx = -DE265_ERROR_IMAGE_BUFFER_FULL; - for (int i=0;ican_be_released()) { dpb[i]->release(); /* TODO: this is surely not the best place to free the image, but we have to do it here because releasing it in de265_release_image() diff -Nru libde265-1.0.12/libde265/encoder/algo/coding-options.cc libde265-1.0.15/libde265/encoder/algo/coding-options.cc --- libde265-1.0.12/libde265/encoder/algo/coding-options.cc 2021-01-24 19:57:57.000000000 +0000 +++ libde265-1.0.15/libde265/encoder/algo/coding-options.cc 2023-11-04 14:31:00.000000000 +0000 @@ -110,7 +110,7 @@ template void CodingOptions::compute_rdo_costs() { - for (int i=0;irate); mOptions[i].rdoCost = mOptions[i].mNode->distortion + mECtx->lambda * mOptions[i].mNode->rate; @@ -129,7 +129,7 @@ bool first=true; int bestRDO=-1; - for (int i=0;i options(ectx, tb, ctxModel); std::vector > option; - for (int i=0;iwriteReconstructionToImage(img, sps); } diff -Nru libde265-1.0.12/libde265/encoder/encpicbuf.cc libde265-1.0.15/libde265/encoder/encpicbuf.cc --- libde265-1.0.12/libde265/encoder/encpicbuf.cc 2021-01-24 19:57:57.000000000 +0000 +++ libde265-1.0.15/libde265/encoder/encpicbuf.cc 2023-11-04 14:31:00.000000000 +0000 @@ -134,7 +134,7 @@ //shdr.num_ref_idx_l1_active = l1.size(); assert(l0.size() < MAX_NUM_REF_PICS); - for (int i=0;istate < image_data::state_encoding) { return true; } @@ -257,7 +257,7 @@ image_data* encoder_picture_buffer::get_next_picture_to_encode() { - for (int i=0;istate < image_data::state_encoding) { return mImages[i]; } @@ -269,7 +269,7 @@ const image_data* encoder_picture_buffer::get_picture(int frame_number) const { - for (int i=0;iframe_number == frame_number) return mImages[i]; } @@ -281,7 +281,7 @@ image_data* encoder_picture_buffer::get_picture(int frame_number) { - for (int i=0;iframe_number == frame_number) return mImages[i]; } @@ -293,7 +293,7 @@ bool encoder_picture_buffer::has_picture(int frame_number) const { - for (int i=0;iframe_number == frame_number) return true; } diff -Nru libde265-1.0.12/libde265/image.cc libde265-1.0.15/libde265/image.cc --- libde265-1.0.12/libde265/image.cc 2023-02-20 12:02:19.000000000 +0000 +++ libde265-1.0.15/libde265/image.cc 2023-11-30 10:55:41.000000000 +0000 @@ -330,6 +330,14 @@ int top = sps ? sps->conf_win_top_offset : 0; int bottom = sps ? sps->conf_win_bottom_offset : 0; + if ((left+right)*WinUnitX >= width) { + return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE; + } + + if ((top+bottom)*WinUnitY >= height) { + return DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE; + } + width_confwin = width - (left+right)*WinUnitX; height_confwin= height- (top+bottom)*WinUnitY; chroma_width_confwin = chroma_width -left-right; @@ -511,7 +519,7 @@ // free slices - for (int i=0;i 34) { + ipm = 0; + } + + return static_cast(ipm); } enum IntraPredMode get_IntraPredMode_atIndex(int idx) const diff -Nru libde265-1.0.12/libde265/motion.cc libde265-1.0.15/libde265/motion.cc --- libde265-1.0.12/libde265/motion.cc 2023-06-13 13:54:12.000000000 +0000 +++ libde265-1.0.15/libde265/motion.cc 2023-11-23 18:43:32.000000000 +0000 @@ -1716,9 +1716,24 @@ logmvcand(vi); const de265_image* imgX = NULL; - if (vi.predFlag[X]) imgX = ctx->get_image(shdr->RefPicList[X][ vi.refIdx[X] ]); + if (vi.predFlag[X]) { + // check for input data validity + if (vi.refIdx[X]<0 || vi.refIdx[X] >= MAX_NUM_REF_PICS) { + return; + } + + imgX = ctx->get_image(shdr->RefPicList[X][ vi.refIdx[X] ]); + } + const de265_image* imgY = NULL; - if (vi.predFlag[Y]) imgY = ctx->get_image(shdr->RefPicList[Y][ vi.refIdx[Y] ]); + if (vi.predFlag[Y]) { + // check for input data validity + if (vi.refIdx[Y]<0 || vi.refIdx[Y] >= MAX_NUM_REF_PICS) { + return; + } + + imgY = ctx->get_image(shdr->RefPicList[Y][ vi.refIdx[Y] ]); + } // check whether the predictor X is available and references the same POC if (vi.predFlag[X] && imgX && imgX->PicOrderCntVal == referenced_POC) { @@ -1849,9 +1864,22 @@ logmvcand(vi); const de265_image* imgX = NULL; - if (vi.predFlag[X]) imgX = ctx->get_image(shdr->RefPicList[X][ vi.refIdx[X] ]); + if (vi.predFlag[X]) { + if (vi.refIdx[X] < 0 || vi.refIdx[X] >= MAX_NUM_REF_PICS) { + return; + } + + imgX = ctx->get_image(shdr->RefPicList[X][ vi.refIdx[X] ]); + } + const de265_image* imgY = NULL; - if (vi.predFlag[Y]) imgY = ctx->get_image(shdr->RefPicList[Y][ vi.refIdx[Y] ]); + if (vi.predFlag[Y]) { + if (vi.refIdx[Y] < 0 || vi.refIdx[Y] >= MAX_NUM_REF_PICS) { + return; + } + + imgY = ctx->get_image(shdr->RefPicList[Y][ vi.refIdx[Y] ]); + } if (vi.predFlag[X] && imgX && imgX->PicOrderCntVal == referenced_POC) { logtrace(LogMotion,"a) take B%d/L%d as B candidate with same POC\n",k,X); diff -Nru libde265-1.0.12/libde265/nal-parser.cc libde265-1.0.15/libde265/nal-parser.cc --- libde265-1.0.12/libde265/nal-parser.cc 2021-01-24 19:57:57.000000000 +0000 +++ libde265-1.0.15/libde265/nal-parser.cc 2023-11-04 14:31:00.000000000 +0000 @@ -181,7 +181,7 @@ // free all NALs in free-list - for (int i=0;iNumNegativePics-1;i>=0;i--) { int n = set->DeltaPocS0[i]; - if (n>=-range) { + if (n>=-range && n<=range) { if (set->UsedByCurrPicS0[i]) log[n+range] = 'X'; else log[n+range] = 'o'; } else { log2fh(fh,"*%d%c ",n, set->UsedByCurrPicS0[i] ? 'X':'o'); } @@ -424,7 +424,7 @@ for (int i=set->NumPositivePics-1;i>=0;i--) { int n = set->DeltaPocS1[i]; - if (n<=range) { + if (n>=-range && n<=range) { if (set->UsedByCurrPicS1[i]) log[n+range] = 'X'; else log[n+range] = 'o'; } else { log2fh(fh,"*%d%c ",n, set->UsedByCurrPicS1[i] ? 'X':'o'); } diff -Nru libde265-1.0.12/libde265/slice.cc libde265-1.0.15/libde265/slice.cc --- libde265-1.0.12/libde265/slice.cc 2023-01-27 17:44:09.000000000 +0000 +++ libde265-1.0.15/libde265/slice.cc 2023-11-23 18:43:05.000000000 +0000 @@ -1277,14 +1277,23 @@ #define LOG3(t,d1,d2,d3) log2fh(fh, t,d1,d2,d3) #define LOG4(t,d1,d2,d3,d4) log2fh(fh, t,d1,d2,d3,d4) + LOG0("----------------- SLICE -----------------\n"); + const pic_parameter_set* pps = ctx->get_pps(slice_pic_parameter_set_id); + if (!pps) { + LOG0("invalid PPS referenced\n"); + return; + } assert(pps->pps_read); // TODO: error handling const seq_parameter_set* sps = ctx->get_sps((int)pps->seq_parameter_set_id); + if (!sps) { + LOG0("invalid SPS referenced\n"); + return; + } assert(sps->sps_read); // TODO: error handling - LOG0("----------------- SLICE -----------------\n"); LOG1("first_slice_segment_in_pic_flag : %d\n", first_slice_segment_in_pic_flag); if (ctx->get_nal_unit_type() >= NAL_UNIT_BLA_W_LP && ctx->get_nal_unit_type() <= NAL_UNIT_RESERVED_IRAP_VCL23) { @@ -2573,6 +2582,11 @@ static int decode_ref_idx_lX(thread_context* tctx, int numRefIdxLXActive) { + // prevent endless loop when 'numRefIdxLXActive' is invalid + if (numRefIdxLXActive <= 1) { + return 0; + } + logtrace(LogSlice,"# ref_idx_lX\n"); int cMax = numRefIdxLXActive-1; diff -Nru libde265-1.0.12/libde265/sps.cc libde265-1.0.15/libde265/sps.cc --- libde265-1.0.12/libde265/sps.cc 2023-06-13 13:54:12.000000000 +0000 +++ libde265-1.0.15/libde265/sps.cc 2023-11-04 14:31:00.000000000 +0000 @@ -722,7 +722,7 @@ LOG1("num_short_term_ref_pic_sets : %d\n", ref_pic_sets.size()); - for (int i = 0; i < ref_pic_sets.size(); i++) { + for (size_t i = 0; i < ref_pic_sets.size(); i++) { LOG1("ref_pic_set[ %2d ]: ",i); dump_compact_short_term_ref_pic_set(&ref_pic_sets[i], 16, fh); } diff -Nru libde265-1.0.12/libde265.pc.in libde265-1.0.15/libde265.pc.in --- libde265-1.0.12/libde265.pc.in 2023-02-20 12:02:19.000000000 +0000 +++ libde265-1.0.15/libde265.pc.in 2023-11-23 18:43:05.000000000 +0000 @@ -7,7 +7,7 @@ Description: H.265/HEVC video decoder. URL: https://github.com/strukturag/libde265 Version: @VERSION@ -Requires: +Requires: Libs: -lde265 -L${libdir} -Libs.private: @LIBS@ -lstdc++ +Libs.private: @LIBS_PRIVATE@ Cflags: -I${includedir}