Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: erazortt/DoViBaker
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.4.5.1
Choose a base ref
...
head repository: erazortt/DoViBaker
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref

Commits on Mar 21, 2024

  1. Update README.md

    erazortt authored Mar 21, 2024
    Copy the full SHA
    9e1a342 View commit details

Commits on Mar 28, 2024

  1. DoViLutGen: cleanup

    erazortt committed Mar 28, 2024
    Copy the full SHA
    cff864c View commit details
  2. Copy the full SHA
    5b81817 View commit details

Commits on Mar 29, 2024

  1. Update README.md

    erazortt authored Mar 29, 2024
    Copy the full SHA
    8fbf10b View commit details
  2. Update README.md

    erazortt authored Mar 29, 2024
    Copy the full SHA
    a88e20d View commit details
  3. Update README.md

    erazortt authored Mar 29, 2024
    Copy the full SHA
    01d79ae View commit details
  4. Update README.md

    erazortt authored Mar 29, 2024
    Copy the full SHA
    e3044e4 View commit details
  5. Update README.md

    erazortt authored Mar 29, 2024
    Copy the full SHA
    8b1dd56 View commit details
  6. Update README.md

    erazortt authored Mar 29, 2024
    Copy the full SHA
    a9fbb80 View commit details
  7. Update README.md

    erazortt authored Mar 29, 2024
    Copy the full SHA
    481bdc7 View commit details
  8. Update README.md

    erazortt authored Mar 29, 2024
    Copy the full SHA
    86e4093 View commit details

Commits on Apr 8, 2024

  1. Copy the full SHA
    afe65a2 View commit details
  2. Copy the full SHA
    4792fda View commit details

Commits on May 1, 2024

  1. Copy the full SHA
    944933b View commit details
  2. CMake: add support for Windows

    Asd-g authored and erazortt committed May 1, 2024
    Copy the full SHA
    e3e9dc4 View commit details
  3. Copy the full SHA
    dd0c844 View commit details
  4. Merge pull request #33 from erazortt/linux

    Try to add Linux support
    erazortt authored May 1, 2024
    Copy the full SHA
    f3beeb6 View commit details

Commits on May 5, 2024

  1. Fix Linux building

    Asd-g authored and erazortt committed May 5, 2024
    Copy the full SHA
    e337ccc View commit details
  2. Copy the full SHA
    c41023b View commit details
  3. Merge pull request #34 from erazortt/linux2

    Next try for linux compatibility
    erazortt authored May 5, 2024
    Copy the full SHA
    d844c5b View commit details
  4. Fix overflow

    erazortt committed May 5, 2024
    Copy the full SHA
    53ee186 View commit details

Commits on May 12, 2024

  1. Copy the full SHA
    9667c5f View commit details
162 changes: 117 additions & 45 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,65 +1,137 @@
cmake_minimum_required(VERSION 3.16)
cmake_minimum_required(VERSION 3.28)

if (NOT CMAKE_GENERATOR MATCHES "Visual Studio")
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
endif()
endif()

project(DoViBaker LANGUAGES CXX)

add_library(libdovibaker SHARED
DoViBaker/AvisynthEntry.cpp
DoViBaker/cube.cpp
DoViBaker/DoViBaker.cpp
DoViBaker/DoViProcessor.cpp
DoViBaker/lut.cpp
DoViBaker/lut_avx2.cpp
DoViBaker/lut_avx512.cpp
DoViBaker/lut_sse41.cpp
DoViBaker/lut_x86.cpp
add_library(DoViBaker SHARED
${CMAKE_CURRENT_SOURCE_DIR}/DoViBaker/AvisynthEntry.cpp
${CMAKE_CURRENT_SOURCE_DIR}/DoViBaker/DoViBaker.cpp
${CMAKE_CURRENT_SOURCE_DIR}/DoViBaker/DoViCubes.cpp
${CMAKE_CURRENT_SOURCE_DIR}/DoViBaker/DoViEetf.cpp
${CMAKE_CURRENT_SOURCE_DIR}/DoViBaker/DoViProcessor.cpp
${CMAKE_CURRENT_SOURCE_DIR}/DoViBaker/DoViStatsFileLoader.cpp
${CMAKE_CURRENT_SOURCE_DIR}/DoViBaker/DoViTonemap.cpp
)

target_include_directories(DoViBaker PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)

if (UNIX)
target_include_directories(DoViBaker PRIVATE
/usr/local/include/avisynth
/usr/local/include
)
endif()

if (NOT CMAKE_GENERATOR MATCHES "Visual Studio")
string(TOLOWER ${CMAKE_BUILD_TYPE} build_type)
if (build_type STREQUAL debug)
target_compile_definitions(DoViBaker PRIVATE DEBUG_BUILD)
else (build_type STREQUAL release)
target_compile_definitions(DoViBaker PRIVATE RELEASE_BUILD)
endif()

message(STATUS "Build type - ${CMAKE_BUILD_TYPE}")
endif()

target_compile_features(DoViBaker PRIVATE cxx_std_20)

# graphengine
add_library(graphengine STATIC
${CMAKE_CURRENT_SOURCE_DIR}/timecube/graphengine/graphengine/cpuinfo.cpp
${CMAKE_CURRENT_SOURCE_DIR}/timecube/graphengine/graphengine/graph.cpp
${CMAKE_CURRENT_SOURCE_DIR}/timecube/graphengine/graphengine/node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/timecube/graphengine/graphengine/x86/cpuinfo_x86.cpp
)

target_include_directories(libdovibaker PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories(graphengine PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/timecube/graphengine/graphengine
${CMAKE_CURRENT_SOURCE_DIR}/timecube/graphengine/graphengine/x86
${CMAKE_CURRENT_SOURCE_DIR}/timecube/graphengine/include
)

if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
if (UNIX)
target_compile_options(graphengine PRIVATE "-fPIC")
endif()
# end graphengine

string(TOLOWER ${CMAKE_BUILD_TYPE} build_type)
if (build_type STREQUAL debug)
target_compile_definitions(libdovibaker PRIVATE DEBUG_BUILD)
else (build_type STREQUAL release)
target_compile_definitions(libdovibaker PRIVATE RELEASE_BUILD)
endif ()
# timecube
add_library(timecube STATIC
${CMAKE_CURRENT_SOURCE_DIR}/timecube/timecube/cube.cpp
${CMAKE_CURRENT_SOURCE_DIR}/timecube/timecube/lut.cpp
${CMAKE_CURRENT_SOURCE_DIR}/timecube/timecube/timecube.cpp
${CMAKE_CURRENT_SOURCE_DIR}/timecube/timecube/x86/lut_x86.cpp
${CMAKE_CURRENT_SOURCE_DIR}/timecube/timecube/x86/lut_sse41.cpp
${CMAKE_CURRENT_SOURCE_DIR}/timecube/timecube/x86/lut_avx2.cpp
${CMAKE_CURRENT_SOURCE_DIR}/timecube/timecube/x86/lut_avx512.cpp
)

message(STATUS "Build type - ${CMAKE_BUILD_TYPE}")
target_include_directories(timecube PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/timecube/timecube
${CMAKE_CURRENT_SOURCE_DIR}/timecube/timecube/x86
${CMAKE_CURRENT_SOURCE_DIR}/timecube/graphengine/include
)

target_compile_features(libdovibaker PRIVATE cxx_std_17)
if (MSVC)
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/timecube/timecube/x86/lut_avx2.cpp PROPERTIES COMPILE_OPTIONS "/arch:AVX2")
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/timecube/timecube/x86/lut_avx512.cpp PROPERTIES COMPILE_OPTIONS "/arch:AVX512")
else()
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/timecube/timecube/x86/lut_sse41.cpp PROPERTIES COMPILE_OPTIONS "-mfpmath=sse;-msse4.1")
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/timecube/timecube/x86/lut_avx2.cpp PROPERTIES COMPILE_OPTIONS "-mavx2;-mfma")
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/timecube/timecube/x86/lut_avx512.cpp PROPERTIES COMPILE_OPTIONS "-mavx512f;-mavx512bw;-mavx512dq;-mavx512vl;-mfma")

target_compile_options(timecube PRIVATE "-fPIC")
endif()

set_source_files_properties(DoViBaker/lut_sse41.cpp PROPERTIES COMPILE_OPTIONS "-mfpmath=sse;-msse4.1")
set_source_files_properties(DoViBaker/lut_avx2.cpp.cpp PROPERTIES COMPILE_OPTIONS "-mavx2;-mfma")
set_source_files_properties(DoViBaker/lut_avx512.cpp PROPERTIES COMPILE_OPTIONS "-mavx512f;-mavx512bw;-mavx512dq;-mavx512vl;-mfma")
target_link_libraries(timecube PRIVATE graphengine)
#end timecube

target_link_libraries(libdovibaker libdovi.a)
find_library(dovi dovi)

find_package (Git)
target_link_libraries(DoViBaker PRIVATE
${dovi}
timecube
)

if (GIT_FOUND)
execute_process (COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0
OUTPUT_VARIABLE ver
OUTPUT_STRIP_TRAILING_WHITESPACE
if (WIN32)
target_link_libraries(DoViBaker PRIVATE
ws2_32
bcrypt
userenv
shlwapi
ntdll
)
set_target_properties(libdovibaker PROPERTIES OUTPUT_NAME "dovibaker.${ver}")
else ()
message (STATUS "GIT not found")
endif ()
endif()

if (UNIX)
find_package (Git)

if (GIT_FOUND)
execute_process (COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0
OUTPUT_VARIABLE ver
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set_target_properties(DoViBaker PROPERTIES OUTPUT_NAME "dovibaker.${ver}")
else ()
message (STATUS "GIT not found")
endif ()

include(GNUInstallDirs)
include(GNUInstallDirs)

INSTALL(TARGETS libdovibaker LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/avisynth")
INSTALL(TARGETS DoViBaker LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/avisynth")

# uninstall target
if(NOT TARGET uninstall)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
# uninstall target
if(NOT TARGET uninstall)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)

add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()
endif()
8 changes: 4 additions & 4 deletions DoViBaker/AvisynthEntry.cpp
Original file line number Diff line number Diff line change
@@ -230,10 +230,10 @@ extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit3(IScri

void ypp2ycc(uint16_t* ycc, float y, float u, float v) {
//YPrPb to YCrCb
static const uint16_t scale = 1 << DoViProcessor::outContainerBitDepth;
static const uint16_t bias = 16 << (DoViProcessor::outContainerBitDepth - 8);
static const uint16_t ltop = scale - (21 << (DoViProcessor::outContainerBitDepth - 8));
static const uint16_t ctop = scale - (16 << (DoViProcessor::outContainerBitDepth - 8));
static const uint32_t scale = 1 << DoViProcessor::outContainerBitDepth;
static const uint32_t bias = 16 << (DoViProcessor::outContainerBitDepth - 8);
static const uint32_t ltop = scale - (21 << (DoViProcessor::outContainerBitDepth - 8));
static const uint32_t ctop = scale - (16 << (DoViProcessor::outContainerBitDepth - 8));

ycc[0] = y * (ltop - bias) + bias;
ycc[1] = (u + 0.5) * (ctop - bias) + bias;
19 changes: 9 additions & 10 deletions DoViBaker/DoViBaker.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
#include <array>

#include "DoViBaker.h"

//////////////////////////////
// Code
//////////////////////////////

// explicitly instantiate the template for the linker
template class DoViBaker<true>;
template class DoViBaker<false>;

template<int quarterResolutionEl>
DoViBaker<quarterResolutionEl>::DoViBaker(
PClip _blChild,
@@ -62,6 +56,10 @@ DoViBaker<quarterResolutionEl>::DoViBaker(
vi.pixel_type = VideoInfo::CS_RGBP16;
}

// explicitly instantiate the template for the linker
template class DoViBaker<true>;
template class DoViBaker<false>;

template<int quarterResolutionEl>
DoViBaker<quarterResolutionEl>::~DoViBaker()
{
@@ -588,10 +586,11 @@ PVideoFrame DoViBaker<quarterResolutionEl>::GetFrame(int n, IScriptEnvironment*
env->propSetInt(env->getFramePropsRW(dst), "_dovi_dynamic_min_pq", doviProc->getDynamicMinPq(), 0);
env->propSetInt(env->getFramePropsRW(dst), "_dovi_dynamic_max_pq", doviProc->getDynamicMaxPq(), 0);
env->propSetInt(env->getFramePropsRW(dst), "_dovi_dynamic_max_content_light_level", doviProc->getDynamicMaxContentLightLevel(), 0);
if (doviProc->getStaticMaxPq() > 0) {
env->propSetInt(env->getFramePropsRW(dst), "_dovi_static_max_pq", doviProc->getStaticMaxPq(), 0);
env->propSetInt(env->getFramePropsRW(dst), "_dovi_static_max_content_light_level", doviProc->getStaticMaxContentLightLevel(), 0);
}
env->propSetInt(env->getFramePropsRW(dst), "_dovi_static_max_pq", doviProc->getStaticMaxPq(), 0);
env->propSetInt(env->getFramePropsRW(dst), "_dovi_static_max_content_light_level", doviProc->getStaticMaxContentLightLevel(), 0);
env->propSetInt(env->getFramePropsRW(dst), "_dovi_static_max_avg_content_light_level", doviProc->getStaticMaxAvgContentLightLevel(), 0);
env->propSetInt(env->getFramePropsRW(dst), "_dovi_static_master_display_max_luminance", doviProc->getStaticMasterDisplayMaxLuminance(), 0);
env->propSetInt(env->getFramePropsRW(dst), "_dovi_static_master_display_min_luminance", doviProc->getStaticMasterDisplayMinLuminance(), 0);

if (qnd) {
if (blClipChromaSubSampled && elClipChromaSubSampled)
1 change: 1 addition & 0 deletions DoViBaker/DoViCubes.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "DoViCubes.h"
#include <climits>
#include <filesystem>

AVS_FORCEINLINE void* aligned_malloc(size_t size, size_t align)
16 changes: 11 additions & 5 deletions DoViBaker/DoViEetf.cpp
Original file line number Diff line number Diff line change
@@ -2,18 +2,18 @@
#include "DoViProcessor.h"
#include <algorithm>

template<int signalBitDepth>
DoViEetf<signalBitDepth>::DoViEetf(float kneeOffset_, bool normalizeOutput_)
: kneeOffset(kneeOffset_),
normalizeOutput(normalizeOutput_) {}

// explicitly instantiate the template for the linker
template class DoViEetf<8>;
template class DoViEetf<10>;
template class DoViEetf<12>;
template class DoViEetf<14>;
template class DoViEetf<16>;

template<int signalBitDepth>
DoViEetf<signalBitDepth>::DoViEetf(float kneeOffset_, bool normalizeOutput_)
: kneeOffset(kneeOffset_),
normalizeOutput(normalizeOutput_) {}

template<int signalBitDepth>
void DoViEetf<signalBitDepth>::generateEETF(
uint16_t targetMaxPq,
@@ -107,3 +107,9 @@ void DoViEetf<signalBitDepth>::generateEETF(
lut[inSignal] = outWhite;
}
}

template void DoViEetf<8>::generateEETF(uint16_t targetMaxPq, uint16_t targetMinPq, uint16_t masterMaxPq, uint16_t masterMinPq, float lumScale, bool limitedInput);
template void DoViEetf<10>::generateEETF(uint16_t targetMaxPq, uint16_t targetMinPq, uint16_t masterMaxPq, uint16_t masterMinPq, float lumScale, bool limitedInput);
template void DoViEetf<12>::generateEETF(uint16_t targetMaxPq, uint16_t targetMinPq, uint16_t masterMaxPq, uint16_t masterMinPq, float lumScale, bool limitedInput);
template void DoViEetf<14>::generateEETF(uint16_t targetMaxPq, uint16_t targetMinPq, uint16_t masterMaxPq, uint16_t masterMinPq, float lumScale, bool limitedInput);
template void DoViEetf<16>::generateEETF(uint16_t targetMaxPq, uint16_t targetMinPq, uint16_t masterMaxPq, uint16_t masterMinPq, float lumScale, bool limitedInput);
21 changes: 15 additions & 6 deletions DoViBaker/DoViLutGen.cpp
Original file line number Diff line number Diff line change
@@ -205,7 +205,7 @@ void XYZfromLms(double& X, double& Y, double& Z, double l, double m, double s) {
}

void labFromLms(double& L, double& a, double& b, double l, double m, double s) {
// the original exponent of 3.0 produces a blue color line which curls into iself
// the original exponent of 3.0 produces a blue color line which curls into itself
constexpr double exponent = 2.3605929376;
l = std::pow(l, 1/exponent);
m = std::pow(m, 1/exponent);
@@ -218,7 +218,7 @@ void lmsFromLab(double& l, double& m, double& s, double L, double a, double b) {
l = 0.9999999985 * L + 0.3963377922 * a + 0.2158037581 * b;
m = 1.000000009 * L - 0.1055613423 * a - 0.06385417477 * b;
s = 1.000000055 * L - 0.08948418209 * a - 1.291485538 * b;
// the original exponent of 3.0 produces a blue color line which curls into iself
// the original exponent of 3.0 produces a blue color line which curls into itself
constexpr double exponent = 2.3605929376;
l = std::pow(l, exponent);
m = std::pow(m, exponent);
@@ -364,10 +364,6 @@ double hybridColorMapping(double& ri, double& gi, double& bi) {
// this should only be numerical flukes
fracSrc = 1;
}
if (fracDst > 1) {
// for the weightning below we need an upper bound of 1
fracDst = 1;
}

double aLinScaled = aHullDst * fracSrc; //same as A/reduction;
double bLinScaled = bHullDst * fracSrc; //same as B/reduction;
@@ -378,10 +374,12 @@ double hybridColorMapping(double& ri, double& gi, double& bi) {
weight1 = fracSrc;
weight2 = (1 - fracSrc);
if (reductionFactor < 2) {
// the weight can be increased so that we remain nearer to the original color
weight2 = ((fracSrc - 1) * ((reductionFactor - 2) * (reductionFactor - 1) * fracSrc - reductionFactor)) / reductionFactor;
}
}
if (reductionFactor > 2) {
// the weight must be decreased such that we don't overshoot
double weight2sup = (1 + (reductionFactor / 2 - 1) * fracSrc);
weight2 /= weight2sup;
}
@@ -546,6 +544,7 @@ int main(int argc, char* argv[])
double chromaReduction = 1.0;

if (!hasArgument(args, "-s", "--size")) {
printf("LUT size not given!\n\n");
showUsage(execname);
return 1;
}
@@ -565,7 +564,17 @@ int main(int argc, char* argv[])
if (hasArgument(args, "-r", "--reduction")) {
chromaReduction = std::stof(getArgumentValue(args, "-r", "--reduction"));
}
if (args.begin() == args.end()) {
printf("No output filename given!\n\n");
showUsage(execname);
return 2;
}
lutFileName = getPositionalArgument(args);
if (args.size() > 0) {
printf("Unknown arguments given!\n\n");
showUsage(execname);
return 2;
}

if (lutSize < 1 || lutSize > 200) {
printf("LUT size not supported");
13 changes: 8 additions & 5 deletions DoViBaker/DoViProcessor.cpp
Original file line number Diff line number Diff line change
@@ -10,10 +10,14 @@ DoViProcessor::DoViProcessor(const char* rpuPath, IScriptEnvironment* env, uint8
, rgbProof(false)
, nlqProof(false)
, desiredTrimPq(0)
, dynamic_max_content_light_level(1000)
, rpus(0x0)
, blContainerBitDepth(blContainerBits)
, elContainerBitDepth(elContainerBits)
, static_max_pq(0)
, static_max_content_light_level(0)
, static_max_avg_content_light_level(0)
, static_master_display_max_luminance(0)
, static_master_display_min_luminance(0)
{
ycc_to_rgb_coef[0] = 8192;
ycc_to_rgb_coef[1] = 0;
@@ -193,16 +197,15 @@ bool DoViProcessor::intializeFrame(int frame, IScriptEnvironment* env, const uin

scene_refresh_flag = vdr_dm_data->scene_refresh_flag;
signal_full_range_flag = vdr_dm_data->signal_full_range_flag;
/*if (!signal_full_range_flag) {
showMessage("DoViBaker: Limited range output signals have not been tested, no idea if that works.", env);
return false;
}*/

dynamic_min_pq = vdr_dm_data->dm_data.level1->min_pq;
dynamic_max_pq = vdr_dm_data->dm_data.level1->max_pq;
dynamic_max_content_light_level = pq2nits(dynamic_max_pq) + 0.5f;
if (vdr_dm_data->dm_data.level6) {
static_max_content_light_level = vdr_dm_data->dm_data.level6->max_content_light_level;
static_max_avg_content_light_level = vdr_dm_data->dm_data.level6->max_frame_average_light_level;
static_master_display_max_luminance = vdr_dm_data->dm_data.level6->max_display_mastering_luminance;
static_master_display_min_luminance = vdr_dm_data->dm_data.level6->min_display_mastering_luminance;
static_max_pq = nits2pq(vdr_dm_data->dm_data.level6->max_content_light_level);
}

Loading