Skip to content

Commit

Permalink
Merge pull request #190 from adamjw24/develop_various_stuff
Browse files Browse the repository at this point in the history
Various fixes, moved upscaling from lib to app
  • Loading branch information
K-os authored Aug 6, 2024
2 parents ad8f4bb + 5b0aa01 commit c53b6b0
Show file tree
Hide file tree
Showing 28 changed files with 812 additions and 746 deletions.
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,13 @@ unset( vvdec_target_arch_list )

if( VVDEC_TARGET_ARCH STREQUAL "ARM" )
set( VVDEC_ARM_SIMD_DEFAULT TRUE )
if( MSVC )
message( STATUS "ARM SIMD intinsics disabling default on MSVC" )
set( VVDEC_ARM_SIMD_DEFAULT FALSE )
endif()
endif()

# we enable x86 intrinsics for all target architectures, because they are implemented through simd-everywhere on non-x86
set( VVDEC_ENABLE_X86_SIMD TRUE CACHE BOOL "enable x86 intrinsics" )
set( VVDEC_ENABLE_ARM_SIMD ${VVDEC_ARM_SIMD_DEFAULT} CACHE BOOL "enable ARM intrinsics" )

set( VVDEC_ENABLE_TRACING FALSE CACHE BOOL "Compile in tracing functionality" )
set( VVDEC_ENABLE_FILM_GRAIN TRUE CACHE BOOL "Build with film grain synthesis support" )

include( vvdecCompilerSupport )

Expand Down
33 changes: 32 additions & 1 deletion cmake/modules/vvdecInstall.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ if( VVDEC_INSTALL_VVDECAPP OR (${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten") )
set( INSTALL_TARGETS "vvdec;vvdecapp" )
else()
set( INSTALL_TARGETS "vvdec" )
install( CODE "message( WARNING \"\nThe vvdecapp binary is not installed by default anymore. To also install vvdecapp set '-DVVDEC_INSTALL_VVDECAPP=ON' (with make: 'install-vvdecapp=1')\" )" )

if ( NOT VVDEC_INSTALL_VVDECAPP )
install( CODE "message( WARNING \"\nThe vvdecapp binary is not installed by default anymore. To also install vvdecapp set '-DVVDEC_INSTALL_VVDECAPP=ON' (with make: 'install-vvdecapp=1')\" )" )
endif()
endif()


Expand Down Expand Up @@ -103,6 +106,34 @@ install( EXPORT vvdecTargets-release NAMESPACE vvdec:: FILE vvdecTargets-
install( EXPORT vvdecTargets-debug NAMESPACE vvdec:: FILE vvdecTargets-${CONFIG_POSTFIX}.cmake CONFIGURATIONS Debug DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/vvdec )
install( EXPORT vvdecTargets-relwithdebinfo NAMESPACE vvdec:: FILE vvdecTargets-${CONFIG_POSTFIX}.cmake CONFIGURATIONS RelWithDebInfo DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/vvdec )

function( resolve_target_interface_libs TGT OUT_VAR )
get_target_property( interface_libs ${TGT} INTERFACE_LINK_LIBRARIES )

foreach( lib ${interface_libs} )
if( TARGET ${lib} )
# if it is a target and not a -llibrary, we need to further resolve it
resolve_target_interface_libs( ${lib} lib )
endif()

list( APPEND ret ${lib} )
endforeach()

set( ${OUT_VAR} ${ret} PARENT_SCOPE )
endfunction()

# create pkg-config file
set( VVDEC_PKG_EXTRA_LIBS ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES} )
if( VVDEC_PKG_EXTRA_LIBS )
list( TRANSFORM VVDEC_PKG_EXTRA_LIBS REPLACE "^([^-].*)" "-l\\1" ) # only add a -l, when not already there
list( REMOVE_ITEM VVDEC_PKG_EXTRA_LIBS "-lc" )
endif()

resolve_target_interface_libs( vvdec VVDEC_PKG_INTERFACE_LIBS )
if( VVDEC_PKG_INTERFACE_LIBS )
list( APPEND VVDEC_PKG_EXTRA_LIBS ${VVDEC_PKG_INTERFACE_LIBS} )
endif()

list( JOIN VVDEC_PKG_EXTRA_LIBS " " VVDEC_PKG_EXTRA_LIBS )
configure_file( pkgconfig/libvvdec.pc.in ${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/libvvdec.pc @ONLY )
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/libvvdec.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig )

33 changes: 21 additions & 12 deletions include/vvdec/vvdec.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ POSSIBILITY OF SUCH DAMAGE.

#include "vvdec/vvdecDecl.h"

#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>

Expand Down Expand Up @@ -123,16 +122,16 @@ typedef enum
{
VVDEC_SIMD_DEFAULT = 0,
VVDEC_SIMD_SCALAR = 1,
#if VVDEC_ARCH_X86
#if defined( VVDEC_ARCH_X86 )
VVDEC_SIMD_SSE41 = 2,
VVDEC_SIMD_SSE42 = 3,
VVDEC_SIMD_AVX = 4,
VVDEC_SIMD_AVX2 = 5,
VVDEC_SIMD_MAX = VVDEC_SIMD_AVX2
#elif VVDEC_ARCH_ARM
#elif defined( VVDEC_ARCH_ARM )
VVDEC_SIMD_NEON = 3,
VVDEC_SIMD_MAX = VVDEC_SIMD_NEON
#elif VVDEC_ARCH_WASM
#elif defined( VVDEC_ARCH_WASM )
VVDEC_SIMD_WASM = 3,
VVDEC_SIMD_MAX = VVDEC_SIMD_WASM
#else
Expand All @@ -142,15 +141,15 @@ typedef enum
}vvdecSIMD_Extension;

/*
\enum vvdecRPRUpscaling
The enum vvdecRPRUpscaling enumerates supported RPR upscaling handling
\enum vvdecObsoleteEnum
Placeholder for an obsolete field, that will be removed later. Don't use.
*/
typedef enum
{
VVDEC_UPSCALING_OFF = 0, // no RPR scaling
VVDEC_UPSCALING_COPY_ONLY = 1, // copy picture into target resolution only
VVDEC_UPSCALING_RESCALE = 2 // auto rescale RPR pictures into target resolution
}vvdecRPRUpscaling;
VVDEC_OBSOLETE_ENUM_0 = 0,
VVDEC_OBSOLETE_ENUM_1 = 1,
VVDEC_OBSOLETE_ENUM_2 = 2
} vvdecObsoleteEnum;

/*
\enum vvdecErrHandlingFlags
Expand Down Expand Up @@ -382,6 +381,15 @@ typedef struct vvdecOlsHrd
bool cbrFlag [32][VVDEC_NUM_GENEREAL_HRD_PARAM];
}vvdecOlsHrd;

/*
The struct vvdecSeqInfo contains some selected fields extracted from the Sequence Parameter Set (SPS)
*/
typedef struct vvdecSeqInfo
{
uint32_t maxWidth; // the maxium picture width contained in the current sequence (sps_pic_width_max_in_luma_samples)
uint32_t maxHeight; // the maxium picture height contained in the current sequence (sps_pic_height_max_in_luma_samples)
} vvdecSeqInfo;

/*
The struct vvdecPicAttributes contains additional picture side information
*/
Expand All @@ -396,6 +404,7 @@ typedef struct vvdecPicAttributes
vvdecVui *vui; // if available, pointer to VUI (Video Usability Information)
vvdecHrd *hrd; // if available, pointer to HRD (Hypothetical Reference Decoder)
vvdecOlsHrd *olsHrd; // if available, pointer to OLS HRD (Output Layer Set Hypothetical Reference Decoder)
vvdecSeqInfo *seqInfo; // if available, pointer to some data extracted from the SPS (Sequence Parameter Set)
} vvdecPicAttributes;

/*
Expand Down Expand Up @@ -439,10 +448,10 @@ typedef struct vvdecParams
{
int threads; // thread count ( default: -1 )
int parseDelay; // number of frames to parse in parallel ( default: -1 )
vvdecRPRUpscaling upscaleOutput; // do internal upscaling of rpl pictures to dest. resolution ( default: 0 )
vvdecObsoleteEnum obsolete_1; // removed feature, must be 0
vvdecLogLevel logLevel; // verbosity level
bool verifyPictureHash; // verify picture, if digest is available, true: check hash in SEI messages if available, false: ignore SEI message
bool removePadding; // copy output pictures to new buffer to remove padding (stride==width) ( default: false )
bool obsolete_2; // removed feature, muste be 0
vvdecSIMD_Extension simd; // set specific simd optimization (default: max. availalbe)
void *opaque; // opaque pointer for private user data ( can be used to carry application specific data or contexts )
vvdecErrHandlingFlags errHandlingFlags; // set of flags defining how to handle bitstream errors
Expand Down
3 changes: 2 additions & 1 deletion pkgconfig/libvvdec.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ includedir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@
Name: libvvdec
Description: Fraunhofer Versatile Video Decoder (VVdeC)
Version: @PROJECT_VERSION@
Libs: -L${libdir} -lvvdec -lstdc++ -lm
Libs: -L${libdir} -lvvdec
Libs.private: @VVDEC_PKG_EXTRA_LIBS@
Cflags: -I${includedir}
69 changes: 41 additions & 28 deletions source/App/vvdecapp/CmdLineParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@ POSSIBILITY OF SUCH DAMAGE.
namespace vvdecoderapp
{

enum RPRUpscaling
{
UPSCALING_OFF = 0, // no RPR scaling
UPSCALING_COPY_ONLY = 1, // copy picture into target resolution only
UPSCALING_RESCALE = 2 // auto rescale RPR pictures into target resolution
};

struct AppOutputParams
{
RPRUpscaling upscaleOutput = UPSCALING_OFF;
bool y4mOutput = false;
};

class CmdLineParser
{
int32_t m_iArg = 0;
Expand Down Expand Up @@ -178,11 +191,11 @@ class CmdLineParser
if( fullHelp )
{
std::cout << "\t\t [--parsedelay,-p <int> ] : maximal number of frames to read before decoding (default: <= 0 auto detection )" << std::endl;
#if VVDEC_ARCH_X86
#if defined( VVDEC_ARCH_X86 )
std::cout << "\t\t [--simd <int> ] : used simd extension (-1: auto, 0: scalar, 1: sse41, 2: sse42, 3: avx, 4: avx2) (default: -1)" << std::endl;
#elif VVDEC_ARCH_ARM
#elif defined( VVDEC_ARCH_ARM)
std::cout << "\t\t [--simd <int> ] : used simd extension (-1: auto, 0: scalar, 1: neon) (default: -1)" << std::endl;
#elif VVDEC_ARCH_WASM
#elif defined(VVDEC_ARCH_WASM)
std::cout << "\t\t [--simd <int> ] : used simd extension (-1: auto, 0: scalar, 1: wasm-simd) (default: -1)" << std::endl;
#endif
std::cout << "\t\t [--errHandling,-eh <int> ] : error handling flags ( 0: off, 1: try continue ) (default: " << rcParams.errHandlingFlags << ")" << std::endl;
Expand Down Expand Up @@ -217,19 +230,19 @@ class CmdLineParser
// clang-format on
}

int parse_command_line( int argc,
char* argv[],
vvdecParams& rcParams,
std::string& rcBitstreamFile,
std::string& rcOutputFile,
int& riFrames,
int& riLoops,
std::string& rcExpectYuvMD5,
bool& useY4mFormat,
bool& useExternAllocator,
std::string& sTracingFile,
std::string& sTracingRule,
int& riPrintPicHash )
int parse_command_line( int argc,
char* argv[],
vvdecParams& rcParams,
std::string& rcBitstreamFile,
std::string& rcOutputFile,
int& riFrames,
int& riLoops,
std::string& rcExpectYuvMD5,
AppOutputParams& appParams,
bool& useExternAllocator,
std::string& sTracingFile,
std::string& sTracingRule,
int& riPrintPicHash )
{
#ifndef ENABLE_TRACING
// ignore unused variables
Expand Down Expand Up @@ -308,24 +321,24 @@ class CmdLineParser
}
else if( parse_param( { "-uo", "--upscale" }, upscale_output ) ) /* In: upscale */
{
rcParams.upscaleOutput = vvdecRPRUpscaling( upscale_output );
appParams.upscaleOutput = RPRUpscaling( upscale_output );
if( rcParams.logLevel > VVDEC_VERBOSE )
{
std::string scale;
switch( rcParams.upscaleOutput )
const char* scale;
switch( appParams.upscaleOutput )
{
// clang-format off
case VVDEC_UPSCALING_OFF : scale = "OFF"; break;
case VVDEC_UPSCALING_COPY_ONLY: scale = "COPY_ONLY"; break;
case VVDEC_UPSCALING_RESCALE : scale = "RESCALE"; break;
default : scale = "UNKNOWN"; break;
case UPSCALING_OFF : scale = "OFF"; break;
case UPSCALING_COPY_ONLY: scale = "COPY_ONLY"; break;
case UPSCALING_RESCALE : scale = "RESCALE"; break;
default : scale = "UNKNOWN"; break;
// clang-format on
};
fprintf( stdout, "[upscale] : %s\n", scale.c_str() );
fprintf( stdout, "[upscale] : %s\n", scale );
}
}
else if( parse_param( { "-fg", "--filmGrain" }, rcParams.filmGrainSynthesis ) ) {}
else if( parse_param( { "--y4m" }, useY4mFormat ) ) {}
else if( parse_param( { "--y4m" }, appParams.y4mOutput ) ) {}
else if( parse_param( { "--extern" }, useExternAllocator ) ) {}
else if( parse_param( { "-f", "--frames" }, riFrames ) )
{
Expand Down Expand Up @@ -378,14 +391,14 @@ class CmdLineParser
// clang-format off
case VVDEC_SIMD_DEFAULT: cll = "DEFAULT"; break;
case VVDEC_SIMD_SCALAR: cll = "SCALAR"; break;
#if VVDEC_ARCH_X86
#if defined (VVDEC_ARCH_X86)
case VVDEC_SIMD_SSE41: cll = "SSE41"; break;
case VVDEC_SIMD_SSE42: cll = "SSE42"; break;
case VVDEC_SIMD_AVX: cll = "AVX"; break;
case VVDEC_SIMD_AVX2: cll = "AVX2"; break;
#elif VVDEC_ARCH_ARM
#elif defined (VVDEC_ARCH_ARM)
case VVDEC_SIMD_NEON: cll = "NEON"; break;
#elif VVDEC_ARCH_WASM
#elif defined (VVDEC_ARCH_WASM)
case VVDEC_SIMD_WASM: cll = "WASM-SIMD"; break;
#else
case VVDEC_SIMD_SIMDE_ANY: cll = "SIMDE-ANY"; break;
Expand Down
Loading

0 comments on commit c53b6b0

Please sign in to comment.