From f82c01db2dc84eaff02808d3dcaec463c48a453c Mon Sep 17 00:00:00 2001 From: Chad Walker Date: Tue, 11 Jun 2019 17:04:07 -0500 Subject: [PATCH 01/43] make use of crop_x, crop_y, crop_with, crop_height keyframes --- src/Clip.cpp | 6 +++--- src/Timeline.cpp | 39 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/src/Clip.cpp b/src/Clip.cpp index 2099705d..48085655 100644 --- a/src/Clip.cpp +++ b/src/Clip.cpp @@ -76,9 +76,9 @@ void Clip::init_settings() wave_color = Color((unsigned char)0, (unsigned char)123, (unsigned char)255, (unsigned char)255); // Init crop settings - crop_gravity = GRAVITY_CENTER; - crop_width = Keyframe(-1.0); - crop_height = Keyframe(-1.0); + crop_gravity = GRAVITY_TOP_LEFT; + crop_width = Keyframe(1.0); + crop_height = Keyframe(1.0); crop_x = Keyframe(0.0); crop_y = Keyframe(0.0); diff --git a/src/Timeline.cpp b/src/Timeline.cpp index 37d3f71c..3d96c002 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -457,6 +457,43 @@ void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, in } } + float crop_x = source_clip->crop_x.GetValue(clip_frame_number); + float crop_y = source_clip->crop_y.GetValue(clip_frame_number); + float crop_w = source_clip->crop_width.GetValue(clip_frame_number); + float crop_h = source_clip->crop_height.GetValue(clip_frame_number); + switch(source_clip->crop_gravity) + { + case (GRAVITY_TOP): + crop_x += 0.5; + break; + case (GRAVITY_TOP_RIGHT): + crop_x += 1.0; + break; + case (GRAVITY_LEFT): + crop_y += 0.5; + break; + case (GRAVITY_CENTER): + crop_x += 0.5; + crop_y += 0.5; + break; + case (GRAVITY_RIGHT): + crop_x += 1.0; + crop_y += 0.5; + break; + case (GRAVITY_BOTTOM_LEFT): + crop_y += 1.0; + break; + case (GRAVITY_BOTTOM): + crop_x += 0.5; + crop_y += 1.0; + break; + case (GRAVITY_BOTTOM_RIGHT): + crop_x += 1.0; + crop_y += 1.0; + break; + } + + /* GRAVITY LOCATION - Initialize X & Y to the correct values (before applying location curves) */ float x = 0.0; // left float y = 0.0; // top @@ -564,7 +601,7 @@ void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, in // Composite a new layer onto the image painter.setCompositionMode(QPainter::CompositionMode_SourceOver); - painter.drawImage(0, 0, *source_image); + painter.drawImage(0, 0, *source_image, crop_x * scaled_source_width, crop_y * scaled_source_height, crop_w * scaled_source_width, crop_h * scaled_source_height); // Draw frame #'s on top of image (if needed) if (source_clip->display != FRAME_DISPLAY_NONE) { From 0fd335ab7bd6a50c85cbcc333fcdb79fdb56f409 Mon Sep 17 00:00:00 2001 From: Chad Walker Date: Tue, 11 Jun 2019 20:28:23 -0500 Subject: [PATCH 02/43] use source_image->width() and source_image->height() instead of scaled_source_width and scaled_source_height --- src/Timeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Timeline.cpp b/src/Timeline.cpp index 3d96c002..74aed9a4 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -601,7 +601,7 @@ void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, in // Composite a new layer onto the image painter.setCompositionMode(QPainter::CompositionMode_SourceOver); - painter.drawImage(0, 0, *source_image, crop_x * scaled_source_width, crop_y * scaled_source_height, crop_w * scaled_source_width, crop_h * scaled_source_height); + painter.drawImage(0, 0, *source_image, crop_x * source_image->width(), crop_y * source_image->height(), crop_w * source_image->width(), crop_h * source_image->height()); // Draw frame #'s on top of image (if needed) if (source_clip->display != FRAME_DISPLAY_NONE) { From 094c378e67f84b8064d32c3b441f27a66afb2772 Mon Sep 17 00:00:00 2001 From: Chad Walker Date: Fri, 21 Jun 2019 23:43:56 -0500 Subject: [PATCH 03/43] add crop properties to json --- src/Clip.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Clip.cpp b/src/Clip.cpp index 48085655..0a059828 100644 --- a/src/Clip.cpp +++ b/src/Clip.cpp @@ -713,6 +713,11 @@ string Clip::PropertiesJSON(int64_t requested_frame) { root["has_audio"] = add_property_json("Enable Audio", has_audio.GetValue(requested_frame), "int", "", &has_audio, -1, 1.0, false, requested_frame); root["has_video"] = add_property_json("Enable Video", has_video.GetValue(requested_frame), "int", "", &has_video, -1, 1.0, false, requested_frame); + root["crop_x"] = add_property_json("Crop X", crop_x.GetValue(requested_frame), "float", "", &crop_x, 0.0, 0.0, false, requested_frame); + root["crop_y"] = add_property_json("Crop Y", crop_y.GetValue(requested_frame), "float", "", &crop_y, 0.0, 0.0, false, requested_frame); + root["crop_width"] = add_property_json("Crop Width", crop_width.GetValue(requested_frame), "float", "", &crop_width, 0.0, 1.0, false, requested_frame); + root["crop_height"] = add_property_json("Crop Height", crop_height.GetValue(requested_frame), "float", "", &crop_height, 0.0, 1.0, false, requested_frame); + root["wave_color"] = add_property_json("Wave Color", 0.0, "color", "", &wave_color.red, 0, 255, false, requested_frame); root["wave_color"]["red"] = add_property_json("Red", wave_color.red.GetValue(requested_frame), "float", "", &wave_color.red, 0, 255, false, requested_frame); root["wave_color"]["blue"] = add_property_json("Blue", wave_color.blue.GetValue(requested_frame), "float", "", &wave_color.blue, 0, 255, false, requested_frame); From e2677e4512b4186813ddbff239bebfd98cd39993 Mon Sep 17 00:00:00 2001 From: Chad Walker Date: Sat, 22 Jun 2019 20:19:34 -0500 Subject: [PATCH 04/43] fix the crop_x and crop_y min and max --- src/Clip.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Clip.cpp b/src/Clip.cpp index 0a059828..cca9f193 100644 --- a/src/Clip.cpp +++ b/src/Clip.cpp @@ -713,8 +713,8 @@ string Clip::PropertiesJSON(int64_t requested_frame) { root["has_audio"] = add_property_json("Enable Audio", has_audio.GetValue(requested_frame), "int", "", &has_audio, -1, 1.0, false, requested_frame); root["has_video"] = add_property_json("Enable Video", has_video.GetValue(requested_frame), "int", "", &has_video, -1, 1.0, false, requested_frame); - root["crop_x"] = add_property_json("Crop X", crop_x.GetValue(requested_frame), "float", "", &crop_x, 0.0, 0.0, false, requested_frame); - root["crop_y"] = add_property_json("Crop Y", crop_y.GetValue(requested_frame), "float", "", &crop_y, 0.0, 0.0, false, requested_frame); + root["crop_x"] = add_property_json("Crop X", crop_x.GetValue(requested_frame), "float", "", &crop_x, -1.0, 1.0, false, requested_frame); + root["crop_y"] = add_property_json("Crop Y", crop_y.GetValue(requested_frame), "float", "", &crop_y, -1.0, 1.0, false, requested_frame); root["crop_width"] = add_property_json("Crop Width", crop_width.GetValue(requested_frame), "float", "", &crop_width, 0.0, 1.0, false, requested_frame); root["crop_height"] = add_property_json("Crop Height", crop_height.GetValue(requested_frame), "float", "", &crop_height, 0.0, 1.0, false, requested_frame); From cf9fbf4402e4a154c741c383b24b6df306e27cd7 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Wed, 26 Jun 2019 21:19:02 -0400 Subject: [PATCH 05/43] Properly install DLL on Win32 Adding a RUNTIME DESTINATION to the install for the library target will install the DLL on Windows systems, so it no longer has to be manually copied in the `.gitlab-ci.yml` script --- .gitlab-ci.yml | 2 -- src/CMakeLists.txt | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d74c1ef6..6c92665a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -78,7 +78,6 @@ windows-builder-x64: - cmake -D"CMAKE_INSTALL_PREFIX:PATH=$CI_PROJECT_DIR\build\install-x64" -G "MinGW Makefiles" -D"CMAKE_BUILD_TYPE:STRING=Release" ../ - mingw32-make install - Move-Item -Force -path "install-x64\lib\python3.6\site-packages\*openshot*" -destination "install-x64\python\" - - cp src\libopenshot.dll install-x64\lib - New-Item -path "install-x64/share/" -Name "$CI_PROJECT_NAME" -Value "CI_PROJECT_NAME:$CI_PROJECT_NAME`nCI_COMMIT_REF_NAME:$CI_COMMIT_REF_NAME`nCI_COMMIT_SHA:$CI_COMMIT_SHA`nCI_JOB_ID:$CI_JOB_ID" -ItemType file -force - $PREV_GIT_LABEL=(git describe --tags --abbrev=0) - git log "$PREV_GIT_LABEL..HEAD" --oneline --pretty=format:"%C(auto,yellow)%h%C(auto,magenta)% %C(auto,blue)%>(12,trunc)%ad %C(auto,green)%<(25,trunc)%aN%C(auto,reset)%s%C(auto,red)% gD% D" --date=short > "install-x64/share/$CI_PROJECT_NAME.log" @@ -109,7 +108,6 @@ windows-builder-x86: - cmake -D"CMAKE_INSTALL_PREFIX:PATH=$CI_PROJECT_DIR\build\install-x86" -G "MinGW Makefiles" -D"CMAKE_BUILD_TYPE:STRING=Release" -D"CMAKE_CXX_FLAGS=-m32" -D"CMAKE_EXE_LINKER_FLAGS=-Wl,--large-address-aware" -D"CMAKE_C_FLAGS=-m32" ../ - mingw32-make install - Move-Item -Force -path "install-x86\lib\python3.6\site-packages\*openshot*" -destination "install-x86\python\" - - cp src\libopenshot.dll install-x86\lib - New-Item -path "install-x86/share/" -Name "$CI_PROJECT_NAME" -Value "CI_PROJECT_NAME:$CI_PROJECT_NAME`nCI_COMMIT_REF_NAME:$CI_COMMIT_REF_NAME`nCI_COMMIT_SHA:$CI_COMMIT_SHA`nCI_JOB_ID:$CI_JOB_ID" -ItemType file -force - $PREV_GIT_LABEL=(git describe --tags --abbrev=0) - git log "$PREV_GIT_LABEL..HEAD" --oneline --pretty=format:"%C(auto,yellow)%h%C(auto,magenta)% %C(auto,blue)%>(12,trunc)%ad %C(auto,green)%<(25,trunc)%aN%C(auto,reset)%s%C(auto,red)% gD% D" --date=short > "install-x86/share/$CI_PROJECT_NAME.log" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3dd38a29..2848d6b5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -400,6 +400,7 @@ set(LIB_INSTALL_DIR lib${LIB_SUFFIX}) # determine correct lib folder INSTALL( TARGETS openshot ARCHIVE DESTINATION ${LIB_INSTALL_DIR} LIBRARY DESTINATION ${LIB_INSTALL_DIR} + RUNTIME DESTINATION ${LIB_INSTALL_DIR} COMPONENT library ) INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ From 376170d7dd4befd555682c6a127076ac3efc3ad7 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Mon, 1 Jul 2019 12:24:50 -0500 Subject: [PATCH 06/43] Merging work from @ferdnyc, to move version info to CMake, and other misc Cmake improvements. This was the easiest way to resolve the merge conflict for me (to apply it locally and commit it). --- CMakeLists.txt | 72 +++++++++++++-------- include/OpenShot.h | 2 +- include/{Version.h => OpenShotVersion.h.in} | 20 +++--- include/Tests.h | 38 ----------- src/CMakeLists.txt | 5 +- src/bindings/python/openshot.i | 4 +- src/bindings/ruby/CMakeLists.txt | 2 + src/bindings/ruby/openshot.i | 4 +- tests/CMakeLists.txt | 3 + tests/Clip_Tests.cpp | 1 - tests/FFmpegReader_Tests.cpp | 1 - tests/FFmpegWriter_Tests.cpp | 1 - tests/FrameMapper_Tests.cpp | 1 - tests/ImageWriter_Tests.cpp | 3 +- tests/Timeline_Tests.cpp | 1 - 15 files changed, 68 insertions(+), 90 deletions(-) rename include/{Version.h => OpenShotVersion.h.in} (68%) delete mode 100644 include/Tests.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 03c5a761..bd063371 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,41 +38,29 @@ For more information, please visit . ################ ADD CMAKE MODULES ################## set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules") +# Define install paths according to system conventions +include(GNUInstallDirs) -################ GET VERSION INFORMATION FROM VERSION.H ################## -message(STATUS "Determining Version Number (from Version.h file)") +################ PROJECT VERSION #################### +set(PROJECT_VERSION_FULL "0.2.3-dev1") +set(PROJECT_SO_VERSION 17) -#### Get the lines related to libopenshot version from the Version.h header -file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/include/Version.h - OPENSHOT_VERSION_LINES - REGEX "#define[ ]+OPENSHOT_VERSION_.*[0-9]+;.*") - -#### Set each line into it's own variable -list (GET OPENSHOT_VERSION_LINES 0 LINE_MAJOR) -list (GET OPENSHOT_VERSION_LINES 1 LINE_MINOR) -list (GET OPENSHOT_VERSION_LINES 2 LINE_BUILD) -list (GET OPENSHOT_VERSION_LINES 3 LINE_SO) - -#### Get the version number out of each line -STRING(REGEX REPLACE "#define[ ]+OPENSHOT_VERSION_MAJOR[ ]+([0-9]+);(.*)" "\\1" MAJOR_VERSION "${LINE_MAJOR}") -STRING(REGEX REPLACE "#define[ ]+OPENSHOT_VERSION_MINOR[ ]+([0-9]+);(.*)" "\\1" MINOR_VERSION "${LINE_MINOR}") -STRING(REGEX REPLACE "#define[ ]+OPENSHOT_VERSION_BUILD[ ]+([0-9]+);(.*)" "\\1" BUILD_VERSION "${LINE_BUILD}") -STRING(REGEX REPLACE "#define[ ]+OPENSHOT_VERSION_SO[ ]+([0-9]+);(.*)" "\\1" SO_VERSION "${LINE_SO}") - -message(STATUS "MAJOR Version: ${MAJOR_VERSION}") -message(STATUS "MINOR Version: ${MINOR_VERSION}") -message(STATUS "BUILD Version: ${BUILD_VERSION}") -message(STATUS "SO/API/ABI Version: ${SO_VERSION}") -message(STATUS "Determining Version Number - done") +# Remove the dash and anything following, to get the #.#.# version for project() +STRING(REGEX REPLACE "\-.*$" "" VERSION_NUM "${PROJECT_VERSION_FULL}") ################### SETUP PROJECT ################### -PROJECT(libopenshot LANGUAGES C CXX - VERSION ${MAJOR_VERSION}.${MINOR_VERSION}.${BUILD_VERSION}) +# This will define the following variables +# PROJECT_NAME +# PROJECT_VERSION, libopenshot_VERSION +# PROJECT_VERSION_MAJOR, libopenshot_VERSION_MAJOR +# PROJECT_VERSION_MINOR, libopenshot_VERSION_MINOR +# PROJECT_VERSION_PATCH, libopenshot_VERSION_PATCH +PROJECT(libopenshot LANGUAGES C CXX VERSION ${VERSION_NUM}) message(" Generating build files for OpenShot Building ${PROJECT_NAME} (version ${PROJECT_VERSION}) - SO/API/ABI Version: ${SO_VERSION} + SO/API/ABI Version: ${PROJECT_SO_VERSION} ") #### Work around a GCC < 9 bug with handling of _Pragma() in macros @@ -82,6 +70,34 @@ if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") AND set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no-integrated-cpp") endif() +########## Configure Version.h header ############## +configure_file(include/OpenShotVersion.h.in include/OpenShotVersion.h @ONLY) +# We'll want that installed later +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/OpenShotVersion.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libopenshot) + + +############### Set up include paths ################# +list(APPEND OPENSHOT_INCLUDE_DIRS + include + include/effects + include/Qt + ${CMAKE_CURRENT_BINARY_DIR}/include ) + +########## Configure Version.h header ############## +configure_file(include/OpenShotVersion.h.in include/OpenShotVersion.h @ONLY) +# We'll want that installed later +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/OpenShotVersion.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libopenshot) + + +############### Set up include paths ################# +list(APPEND OPENSHOT_INCLUDE_DIRS + include + include/effects + include/Qt + ${CMAKE_CURRENT_BINARY_DIR}/include ) + #### Enable C++11 (for std::shared_ptr support) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -104,4 +120,4 @@ add_subdirectory(tests) include(cmake/Modules/UseDoxygen.cmake) file(GLOB_RECURSE doc_files ${CMAKE_CURRENT_BINARY_DIR}/doc/html/*.*) -INSTALL(FILES ${doc_files} DESTINATION share/doc/libopenshot) +INSTALL(FILES ${doc_files} DESTINATION ${CMAKE_INSTALL_DOCDIR}) diff --git a/include/OpenShot.h b/include/OpenShot.h index fb53164c..c5778f99 100644 --- a/include/OpenShot.h +++ b/include/OpenShot.h @@ -96,7 +96,7 @@ */ // Include the version number of OpenShot Library -#include "Version.h" +#include "OpenShotVersion.h" // Include all other classes #include "AudioBufferSource.h" diff --git a/include/Version.h b/include/OpenShotVersion.h.in similarity index 68% rename from include/Version.h rename to include/OpenShotVersion.h.in index ec9e94a6..89f4ed52 100644 --- a/include/Version.h +++ b/include/OpenShotVersion.h.in @@ -31,18 +31,16 @@ #ifndef OPENSHOT_VERSION_H #define OPENSHOT_VERSION_H -// Crazy c++ macro to convert an integer into a string -#ifndef STRINGIZE - #define STRINGIZE_(x) #x - #define STRINGIZE(x) STRINGIZE_(x) -#endif +#define OPENSHOT_VERSION_ALL "@PROJECT_VERSION@" /// A string of the entire version "Major.Minor.Build" +#define OPENSHOT_VERSION_FULL "@PROJECT_VERSION_FULL@" /// A string of the full version identifier, including suffixes (e.g. "0.0.0-dev0") -#define OPENSHOT_VERSION_MAJOR 0; /// Major version number is incremented when huge features are added or improved. -#define OPENSHOT_VERSION_MINOR 2; /// Minor version is incremented when smaller (but still very important) improvements are added. -#define OPENSHOT_VERSION_BUILD 3; /// Build number is incremented when minor bug fixes and less important improvements are added. -#define OPENSHOT_VERSION_SO 17; /// Shared object version number. This increments any time the API and ABI changes (so old apps will no longer link) -#define OPENSHOT_VERSION_MAJOR_MINOR STRINGIZE(OPENSHOT_VERSION_MAJOR) "." STRINGIZE(OPENSHOT_VERSION_MINOR); /// A string of the "Major.Minor" version -#define OPENSHOT_VERSION_ALL STRINGIZE(OPENSHOT_VERSION_MAJOR) "." STRINGIZE(OPENSHOT_VERSION_MINOR) "." STRINGIZE(OPENSHOT_VERSION_BUILD); /// A string of the entire version "Major.Minor.Build" +#define OPENSHOT_VERSION_MAJOR_MINOR "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@" /// A string of the "Major.Minor" version + +#define OPENSHOT_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ /// Major version number is incremented when huge features are added or improved. +#define OPENSHOT_VERSION_MINOR @PROJECT_VERSION_MINOR@ /// Minor version is incremented when smaller (but still very important) improvements are added. +#define OPENSHOT_VERSION_BUILD @PROJECT_VERSION_PATCH@ /// Build number is incremented when minor bug fixes and less important improvements are added. + +#define OPENSHOT_VERSION_SO @PROJECT_SO_VERSION@ /// Shared object version number. This increments any time the API and ABI changes (so old apps will no longer link) #include using namespace std; diff --git a/include/Tests.h b/include/Tests.h deleted file mode 100644 index b647cb0e..00000000 --- a/include/Tests.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @file - * @brief Header file for UnitTests - * @author Jonathan Thomas - * - * @ref License - */ - -/* LICENSE - * - * Copyright (c) 2008-2019 OpenShot Studios, LLC - * . This file is part of - * OpenShot Library (libopenshot), an open-source project dedicated to - * delivering high quality video editing and animation solutions to the - * world. For more information visit . - * - * OpenShot Library (libopenshot) is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * OpenShot Library (libopenshot) is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with OpenShot Library. If not, see . - */ - -#ifndef OPENSHOT_UNITTESTS_H -#define OPENSHOT_UNITTESTS_H - - #ifndef TEST_MEDIA_PATH - #define TEST_MEDIA_PATH "../../src/examples/" - #endif - -#endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3dd38a29..9f5b3f5f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,6 +24,9 @@ # along with OpenShot Library. If not, see . ################################################################################ +# Pick up our include directories from the parent context +include_directories(${OPENSHOT_INCLUDE_DIRS}) + ################ OPTIONS ################## # Optional build settings for libopenshot OPTION(USE_SYSTEM_JSONCPP "Use system installed JsonCpp" OFF) @@ -299,7 +302,7 @@ add_library(openshot SHARED set_target_properties(openshot PROPERTIES VERSION ${PROJECT_VERSION} - SOVERSION ${SO_VERSION} + SOVERSION ${PROJECT_SO_VERSION} INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib" ) diff --git a/src/bindings/python/openshot.i b/src/bindings/python/openshot.i index 74d2705b..af1abb74 100644 --- a/src/bindings/python/openshot.i +++ b/src/bindings/python/openshot.i @@ -53,7 +53,7 @@ %shared_ptr(Frame) %{ -#include "../../../include/Version.h" +#include "OpenShotVersion.h" #include "../../../include/ReaderBase.h" #include "../../../include/WriterBase.h" #include "../../../include/CacheBase.h" @@ -117,7 +117,7 @@ } } -%include "../../../include/Version.h" +%include "OpenShotVersion.h" %include "../../../include/ReaderBase.h" %include "../../../include/WriterBase.h" %include "../../../include/CacheBase.h" diff --git a/src/bindings/ruby/CMakeLists.txt b/src/bindings/ruby/CMakeLists.txt index e0987ca4..db3655fb 100644 --- a/src/bindings/ruby/CMakeLists.txt +++ b/src/bindings/ruby/CMakeLists.txt @@ -24,6 +24,8 @@ # along with OpenShot Library. If not, see . ################################################################################ +# Pick up our include directories from the parent context +include_directories(${OPENSHOT_INCLUDE_DIRS}) ############### RUBY BINDINGS ################ FIND_PACKAGE(SWIG 2.0 REQUIRED) diff --git a/src/bindings/ruby/openshot.i b/src/bindings/ruby/openshot.i index 775421b6..ab11ae7f 100644 --- a/src/bindings/ruby/openshot.i +++ b/src/bindings/ruby/openshot.i @@ -65,7 +65,7 @@ namespace std { #define RB_RSHIFT(a, b) RSHIFT(a, b) #undef RSHIFT #endif -#include "../../../include/Version.h" +#include "OpenShotVersion.h" #include "../../../include/ReaderBase.h" #include "../../../include/WriterBase.h" #include "../../../include/CacheBase.h" @@ -127,7 +127,7 @@ namespace std { %} #endif -%include "../../../include/Version.h" +%include "OpenShotVersion.h" %include "../../../include/ReaderBase.h" %include "../../../include/WriterBase.h" %include "../../../include/CacheBase.h" diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b1782774..caefffb0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -24,6 +24,9 @@ # along with OpenShot Library. If not, see . ################################################################################ +# Pick up our include directories from the parent context +include_directories(${OPENSHOT_INCLUDE_DIRS}) + SET(TEST_MEDIA_PATH "${PROJECT_SOURCE_DIR}/src/examples/") ################ WINDOWS ################## diff --git a/tests/Clip_Tests.cpp b/tests/Clip_Tests.cpp index c77e44b6..6c60bedd 100644 --- a/tests/Clip_Tests.cpp +++ b/tests/Clip_Tests.cpp @@ -30,7 +30,6 @@ #include "UnitTest++.h" #include "../include/OpenShot.h" -#include "../include/Tests.h" using namespace std; using namespace openshot; diff --git a/tests/FFmpegReader_Tests.cpp b/tests/FFmpegReader_Tests.cpp index 4ef570ae..68aba4bb 100644 --- a/tests/FFmpegReader_Tests.cpp +++ b/tests/FFmpegReader_Tests.cpp @@ -30,7 +30,6 @@ #include "UnitTest++.h" #include "../include/OpenShot.h" -#include "../include/Tests.h" using namespace std; using namespace openshot; diff --git a/tests/FFmpegWriter_Tests.cpp b/tests/FFmpegWriter_Tests.cpp index 53a9cbf2..8cb10e15 100644 --- a/tests/FFmpegWriter_Tests.cpp +++ b/tests/FFmpegWriter_Tests.cpp @@ -30,7 +30,6 @@ #include "UnitTest++.h" #include "../include/OpenShot.h" -#include "../include/Tests.h" using namespace std; using namespace openshot; diff --git a/tests/FrameMapper_Tests.cpp b/tests/FrameMapper_Tests.cpp index ce43fc20..f400d830 100644 --- a/tests/FrameMapper_Tests.cpp +++ b/tests/FrameMapper_Tests.cpp @@ -30,7 +30,6 @@ #include "UnitTest++.h" #include "../include/OpenShot.h" -#include "../include/Tests.h" using namespace std; using namespace openshot; diff --git a/tests/ImageWriter_Tests.cpp b/tests/ImageWriter_Tests.cpp index d44bbd84..4236b462 100644 --- a/tests/ImageWriter_Tests.cpp +++ b/tests/ImageWriter_Tests.cpp @@ -30,7 +30,6 @@ #include "UnitTest++.h" #include "../include/OpenShot.h" -#include "../include/Tests.h" using namespace std; using namespace openshot; @@ -81,4 +80,4 @@ TEST(ImageWriter_Test_Gif) CHECK_EQUAL(11, (int)pixels[pixel_index + 2]); CHECK_EQUAL(255, (int)pixels[pixel_index + 3]); } -#endif \ No newline at end of file +#endif diff --git a/tests/Timeline_Tests.cpp b/tests/Timeline_Tests.cpp index 1290bee7..0bb42b89 100644 --- a/tests/Timeline_Tests.cpp +++ b/tests/Timeline_Tests.cpp @@ -30,7 +30,6 @@ #include "UnitTest++.h" #include "../include/OpenShot.h" -#include "../include/Tests.h" using namespace std; using namespace openshot; From 4e08ab32c1386366305212875925ab81ed1e257a Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Mon, 1 Jul 2019 12:43:31 -0500 Subject: [PATCH 07/43] Fixing a few more conflicts between this branch and develop --- CMakeLists.txt | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd063371..9c468ae0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,8 +38,6 @@ For more information, please visit . ################ ADD CMAKE MODULES ################## set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules") -# Define install paths according to system conventions -include(GNUInstallDirs) ################ PROJECT VERSION #################### set(PROJECT_VERSION_FULL "0.2.3-dev1") @@ -63,12 +61,10 @@ Generating build files for OpenShot SO/API/ABI Version: ${PROJECT_SO_VERSION} ") -#### Work around a GCC < 9 bug with handling of _Pragma() in macros -#### See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55578 -if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") AND - (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "9.0.0")) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no-integrated-cpp") -endif() +# Define install paths according to system conventions +# XXX: This must be AFTER THE PROJECT() COMMAND w/ languages enabled, +# in order to properly configure CMAKE_INSTALL_LIBDIR path +include(GNUInstallDirs) ########## Configure Version.h header ############## configure_file(include/OpenShotVersion.h.in include/OpenShotVersion.h @ONLY) @@ -76,21 +72,6 @@ configure_file(include/OpenShotVersion.h.in include/OpenShotVersion.h @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/OpenShotVersion.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libopenshot) - -############### Set up include paths ################# -list(APPEND OPENSHOT_INCLUDE_DIRS - include - include/effects - include/Qt - ${CMAKE_CURRENT_BINARY_DIR}/include ) - -########## Configure Version.h header ############## -configure_file(include/OpenShotVersion.h.in include/OpenShotVersion.h @ONLY) -# We'll want that installed later -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/OpenShotVersion.h - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libopenshot) - - ############### Set up include paths ################# list(APPEND OPENSHOT_INCLUDE_DIRS include @@ -117,7 +98,4 @@ add_subdirectory(tests) ################### DOCUMENTATION ################### # Find Doxygen (used for documentation) -include(cmake/Modules/UseDoxygen.cmake) - -file(GLOB_RECURSE doc_files ${CMAKE_CURRENT_BINARY_DIR}/doc/html/*.*) -INSTALL(FILES ${doc_files} DESTINATION ${CMAKE_INSTALL_DOCDIR}) +include(cmake/Modules/UseDoxygen.cmake) \ No newline at end of file From db51ea1ee091aaeef175c43b8fcef6a354bdf714 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Wed, 3 Jul 2019 03:33:52 -0400 Subject: [PATCH 08/43] FFmpegUtilities: inline av_make_error_string Avoids warnings about the function being unused, if compiling with `-Wall` Borrowed from: https://github.com/ZoneMinder/zoneminder/blob/222f14523085f996a8d0dd3dd8beea722ea957e1/src/zm_ffmpeg.h#L241 --- include/FFmpegUtilities.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/FFmpegUtilities.h b/include/FFmpegUtilities.h index e3df704b..8a0b7705 100644 --- a/include/FFmpegUtilities.h +++ b/include/FFmpegUtilities.h @@ -91,12 +91,11 @@ #endif // This wraps an unsafe C macro to be C++ compatible function - static const std::string av_make_error_string(int errnum) + inline static const std::string av_make_error_string(int errnum) { char errbuf[AV_ERROR_MAX_STRING_SIZE]; av_strerror(errnum, errbuf, AV_ERROR_MAX_STRING_SIZE); - std::string errstring(errbuf); - return errstring; + return (std::string)errbuf; } // Redefine the C macro to use our new C++ function From 8158a1f2fa5998fac89d89c58d00c9dda956cd73 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Wed, 3 Jul 2019 06:28:57 -0400 Subject: [PATCH 09/43] Catch-by-reference for tests/Clip_Tests --- tests/Clip_Tests.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Clip_Tests.cpp b/tests/Clip_Tests.cpp index 6c60bedd..1b520ef6 100644 --- a/tests/Clip_Tests.cpp +++ b/tests/Clip_Tests.cpp @@ -128,7 +128,7 @@ TEST(Clip_Properties) CHECK_EQUAL(true, root["alpha"]["keyframe"].asBool()); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); @@ -153,7 +153,7 @@ TEST(Clip_Properties) CHECK_EQUAL(false, root["alpha"]["keyframe"].asBool()); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); @@ -177,7 +177,7 @@ TEST(Clip_Properties) CHECK_EQUAL(false, root["alpha"]["keyframe"].asBool()); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); @@ -202,7 +202,7 @@ TEST(Clip_Properties) CHECK_EQUAL(true, root["alpha"]["keyframe"].asBool()); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); From cb6ac2121901e8d47c10a850ab7c7cb358b0a1d0 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Wed, 3 Jul 2019 06:29:32 -0400 Subject: [PATCH 10/43] src/effects: Catch-by-reference --- src/effects/Bars.cpp | 2 +- src/effects/Blur.cpp | 2 +- src/effects/Brightness.cpp | 2 +- src/effects/ChromaKey.cpp | 2 +- src/effects/ColorShift.cpp | 2 +- src/effects/Crop.cpp | 2 +- src/effects/Deinterlace.cpp | 2 +- src/effects/Hue.cpp | 2 +- src/effects/Mask.cpp | 2 +- src/effects/Negate.cpp | 2 +- src/effects/Pixelate.cpp | 2 +- src/effects/Saturation.cpp | 2 +- src/effects/Shift.cpp | 2 +- src/effects/Wave.cpp | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/effects/Bars.cpp b/src/effects/Bars.cpp index 4320e618..a05d9021 100644 --- a/src/effects/Bars.cpp +++ b/src/effects/Bars.cpp @@ -156,7 +156,7 @@ void Bars::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/effects/Blur.cpp b/src/effects/Blur.cpp index db036133..be07c386 100644 --- a/src/effects/Blur.cpp +++ b/src/effects/Blur.cpp @@ -293,7 +293,7 @@ void Blur::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/effects/Brightness.cpp b/src/effects/Brightness.cpp index 67d45824..eec4b7fe 100644 --- a/src/effects/Brightness.cpp +++ b/src/effects/Brightness.cpp @@ -147,7 +147,7 @@ void Brightness::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/effects/ChromaKey.cpp b/src/effects/ChromaKey.cpp index 397c7ab1..b99da9bb 100644 --- a/src/effects/ChromaKey.cpp +++ b/src/effects/ChromaKey.cpp @@ -140,7 +140,7 @@ void ChromaKey::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/effects/ColorShift.cpp b/src/effects/ColorShift.cpp index f4fab883..d3622634 100644 --- a/src/effects/ColorShift.cpp +++ b/src/effects/ColorShift.cpp @@ -239,7 +239,7 @@ void ColorShift::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/effects/Crop.cpp b/src/effects/Crop.cpp index 99f8f124..af372a00 100644 --- a/src/effects/Crop.cpp +++ b/src/effects/Crop.cpp @@ -155,7 +155,7 @@ void Crop::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/effects/Deinterlace.cpp b/src/effects/Deinterlace.cpp index c698dbd1..a09a07f0 100644 --- a/src/effects/Deinterlace.cpp +++ b/src/effects/Deinterlace.cpp @@ -134,7 +134,7 @@ void Deinterlace::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/effects/Hue.cpp b/src/effects/Hue.cpp index a75b4a1f..43e6c1c0 100644 --- a/src/effects/Hue.cpp +++ b/src/effects/Hue.cpp @@ -141,7 +141,7 @@ void Hue::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/effects/Mask.cpp b/src/effects/Mask.cpp index b952ba62..f0e28196 100644 --- a/src/effects/Mask.cpp +++ b/src/effects/Mask.cpp @@ -194,7 +194,7 @@ void Mask::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/effects/Negate.cpp b/src/effects/Negate.cpp index 1b9decdc..547bb88d 100644 --- a/src/effects/Negate.cpp +++ b/src/effects/Negate.cpp @@ -95,7 +95,7 @@ void Negate::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/effects/Pixelate.cpp b/src/effects/Pixelate.cpp index 95d88b71..b064ceeb 100644 --- a/src/effects/Pixelate.cpp +++ b/src/effects/Pixelate.cpp @@ -152,7 +152,7 @@ void Pixelate::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/effects/Saturation.cpp b/src/effects/Saturation.cpp index 4278b0b8..83792f65 100644 --- a/src/effects/Saturation.cpp +++ b/src/effects/Saturation.cpp @@ -152,7 +152,7 @@ void Saturation::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/effects/Shift.cpp b/src/effects/Shift.cpp index 0e802c99..666bd479 100644 --- a/src/effects/Shift.cpp +++ b/src/effects/Shift.cpp @@ -172,7 +172,7 @@ void Shift::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/effects/Wave.cpp b/src/effects/Wave.cpp index cfcb70c7..5ffb9300 100644 --- a/src/effects/Wave.cpp +++ b/src/effects/Wave.cpp @@ -155,7 +155,7 @@ void Wave::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); From 25b522589ddfd5e78d261d2c3fba12b06364682f Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Wed, 3 Jul 2019 12:58:02 -0400 Subject: [PATCH 11/43] Always catch-by-reference in C++11 --- src/CacheDisk.cpp | 2 +- src/CacheMemory.cpp | 2 +- src/ChunkReader.cpp | 6 +++--- src/Clip.cpp | 4 ++-- src/Color.cpp | 2 +- src/Coordinate.cpp | 2 +- src/DecklinkReader.cpp | 2 +- src/DummyReader.cpp | 2 +- src/EffectBase.cpp | 2 +- src/FFmpegReader.cpp | 2 +- src/FrameMapper.cpp | 2 +- src/ImageReader.cpp | 4 ++-- src/KeyFrame.cpp | 4 ++-- src/Point.cpp | 2 +- src/Profiles.cpp | 4 ++-- src/QtImageReader.cpp | 2 +- src/TextReader.cpp | 2 +- src/Timeline.cpp | 4 ++-- src/WriterBase.cpp | 2 +- 19 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/CacheDisk.cpp b/src/CacheDisk.cpp index 4d446746..7d71e100 100644 --- a/src/CacheDisk.cpp +++ b/src/CacheDisk.cpp @@ -522,7 +522,7 @@ void CacheDisk::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/CacheMemory.cpp b/src/CacheMemory.cpp index 4de6bb1f..790f3f98 100644 --- a/src/CacheMemory.cpp +++ b/src/CacheMemory.cpp @@ -377,7 +377,7 @@ void CacheMemory::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/ChunkReader.cpp b/src/ChunkReader.cpp index 8d5b466e..97ab0797 100644 --- a/src/ChunkReader.cpp +++ b/src/ChunkReader.cpp @@ -121,7 +121,7 @@ void ChunkReader::load_json() info.audio_timebase.den = root["audio_timebase"]["den"].asInt(); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON could not be parsed (or is invalid).", path); @@ -235,7 +235,7 @@ std::shared_ptr ChunkReader::GetFrame(int64_t requested_frame) local_reader = new FFmpegReader(chunk_video_path); local_reader->Open(); // open reader - } catch (InvalidFile) + } catch (const InvalidFile& e) { // Invalid Chunk (possibly it is not found) throw ChunkNotFound(path, requested_frame, location.number, location.frame); @@ -298,7 +298,7 @@ void ChunkReader::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/Clip.cpp b/src/Clip.cpp index bddcd0c9..93a246af 100644 --- a/src/Clip.cpp +++ b/src/Clip.cpp @@ -123,7 +123,7 @@ void Clip::init_reader_rotation() { try { float rotate_metadata = strtof(reader->info.metadata["rotate"].c_str(), 0); rotation = Keyframe(rotate_metadata); - } catch (exception e) {} + } catch (const std::exception& e) {} } else // Default no rotation @@ -809,7 +809,7 @@ void Clip::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/Color.cpp b/src/Color.cpp index 21c3f146..932d31f4 100644 --- a/src/Color.cpp +++ b/src/Color.cpp @@ -125,7 +125,7 @@ void Color::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/Coordinate.cpp b/src/Coordinate.cpp index 5baeb5bf..2f2dbaa6 100644 --- a/src/Coordinate.cpp +++ b/src/Coordinate.cpp @@ -88,7 +88,7 @@ void Coordinate::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/DecklinkReader.cpp b/src/DecklinkReader.cpp index 230a6689..b9464301 100644 --- a/src/DecklinkReader.cpp +++ b/src/DecklinkReader.cpp @@ -283,7 +283,7 @@ void DecklinkReader::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/DummyReader.cpp b/src/DummyReader.cpp index aa1e6a56..28b8f2b0 100644 --- a/src/DummyReader.cpp +++ b/src/DummyReader.cpp @@ -161,7 +161,7 @@ void DummyReader::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/EffectBase.cpp b/src/EffectBase.cpp index 9bf30986..d6cee206 100644 --- a/src/EffectBase.cpp +++ b/src/EffectBase.cpp @@ -117,7 +117,7 @@ void EffectBase::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/FFmpegReader.cpp b/src/FFmpegReader.cpp index 10d89051..044fb580 100644 --- a/src/FFmpegReader.cpp +++ b/src/FFmpegReader.cpp @@ -2439,7 +2439,7 @@ void FFmpegReader::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) { + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); } diff --git a/src/FrameMapper.cpp b/src/FrameMapper.cpp index 1f6b7629..3be9f812 100644 --- a/src/FrameMapper.cpp +++ b/src/FrameMapper.cpp @@ -712,7 +712,7 @@ void FrameMapper::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/ImageReader.cpp b/src/ImageReader.cpp index 62439d82..31afd179 100644 --- a/src/ImageReader.cpp +++ b/src/ImageReader.cpp @@ -67,7 +67,7 @@ void ImageReader::Open() image->backgroundColor(Magick::Color("none")); MAGICK_IMAGE_ALPHA(image, true); } - catch (Magick::Exception e) { + catch (const Magick::Exception& e) { // raise exception throw InvalidFile("File could not be opened.", path); } @@ -174,7 +174,7 @@ void ImageReader::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/KeyFrame.cpp b/src/KeyFrame.cpp index 31393d17..75b2c739 100644 --- a/src/KeyFrame.cpp +++ b/src/KeyFrame.cpp @@ -200,7 +200,7 @@ Point Keyframe::GetPreviousPoint(Point p) { else return Points[0]; - } catch (OutOfBoundsPoint) { + } catch (const OutOfBoundsPoint& e) { // No previous point return Point(-1, -1); } @@ -384,7 +384,7 @@ void Keyframe::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/Point.cpp b/src/Point.cpp index b0e85658..8d29b2ac 100644 --- a/src/Point.cpp +++ b/src/Point.cpp @@ -151,7 +151,7 @@ void Point::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/Profiles.cpp b/src/Profiles.cpp index 9c2b3014..7d3bbb45 100644 --- a/src/Profiles.cpp +++ b/src/Profiles.cpp @@ -120,7 +120,7 @@ Profile::Profile(string path) { } } - catch (exception e) + catch (const std::exception& e) { // Error parsing profile file throw InvalidFile("Profile could not be found or loaded (or is invalid).", path); @@ -182,7 +182,7 @@ void Profile::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/QtImageReader.cpp b/src/QtImageReader.cpp index bd1c4bc8..b8e17160 100644 --- a/src/QtImageReader.cpp +++ b/src/QtImageReader.cpp @@ -304,7 +304,7 @@ void QtImageReader::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/TextReader.cpp b/src/TextReader.cpp index 9c664535..b714fb97 100644 --- a/src/TextReader.cpp +++ b/src/TextReader.cpp @@ -235,7 +235,7 @@ void TextReader::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/Timeline.cpp b/src/Timeline.cpp index 7636de7d..359901ac 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -1045,7 +1045,7 @@ void Timeline::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); @@ -1160,7 +1160,7 @@ void Timeline::ApplyJsonDiff(string value) { } } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); diff --git a/src/WriterBase.cpp b/src/WriterBase.cpp index bc16e7e0..71705529 100644 --- a/src/WriterBase.cpp +++ b/src/WriterBase.cpp @@ -214,7 +214,7 @@ void WriterBase::SetJson(string value) { // Set all values that match SetJsonValue(root); } - catch (exception e) + catch (const std::exception& e) { // Error parsing JSON (or missing keys) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); From 80765147b9dffd5872d08387eade60c30edc0c9e Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Wed, 3 Jul 2019 13:12:02 -0400 Subject: [PATCH 12/43] Exceptions.h: fixes for noexcept, unused vars, std:: Some fixes for `-Wall`-readiness: * Removed `using namespace std;` from the header and added `std::` prefixes where needed (`std::string`) * Replaced `throw ()` in declarations with `noexcept`, as `throw ()` is [deprecated in c++11][1] * Several exception classes had a `file_path` member variable, despite never using it. Removed the unused class member. [1]: --- include/Exceptions.h | 125 +++++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 65 deletions(-) diff --git a/include/Exceptions.h b/include/Exceptions.h index 0fb2bb1e..c5228f13 100644 --- a/include/Exceptions.h +++ b/include/Exceptions.h @@ -32,7 +32,6 @@ #define OPENSHOT_EXCEPTIONS_H #include -using namespace std; namespace openshot { @@ -45,11 +44,11 @@ namespace openshot { class BaseException : public std::exception //: public exception { protected: - string m_message; + std::string m_message; public: - BaseException(string message) : m_message(message) { } - virtual ~BaseException() throw () {} - virtual const char* what() const throw () { + BaseException(std::string message) : m_message(message) { } + virtual ~BaseException() noexcept {} + virtual const char* what() const noexcept { // return custom message return m_message.c_str(); } @@ -59,13 +58,12 @@ namespace openshot { class ChunkNotFound : public BaseException { public: - string file_path; int64_t frame_number; int64_t chunk_number; int64_t chunk_frame; - ChunkNotFound(string message, int64_t frame_number, int64_t chunk_number, int64_t chunk_frame) + ChunkNotFound(std::string message, int64_t frame_number, int64_t chunk_number, int64_t chunk_frame) : BaseException(message), frame_number(frame_number), chunk_number(chunk_number), chunk_frame(chunk_frame) { } - virtual ~ChunkNotFound() throw () {} + virtual ~ChunkNotFound() noexcept {} }; @@ -73,132 +71,129 @@ namespace openshot { class DecklinkError : public BaseException { public: - DecklinkError(string message) + DecklinkError(std::string message) : BaseException(message) { } - virtual ~DecklinkError() throw () {} + virtual ~DecklinkError() noexcept {} }; /// Exception when decoding audio packet class ErrorDecodingAudio : public BaseException { public: - string file_path; int64_t frame_number; - ErrorDecodingAudio(string message, int64_t frame_number) + ErrorDecodingAudio(std::string message, int64_t frame_number) : BaseException(message), frame_number(frame_number) { } - virtual ~ErrorDecodingAudio() throw () {} + virtual ~ErrorDecodingAudio() noexcept {} }; /// Exception when encoding audio packet class ErrorEncodingAudio : public BaseException { public: - string file_path; int64_t frame_number; - ErrorEncodingAudio(string message, int64_t frame_number) + ErrorEncodingAudio(std::string message, int64_t frame_number) : BaseException(message), frame_number(frame_number) { } - virtual ~ErrorEncodingAudio() throw () {} + virtual ~ErrorEncodingAudio() noexcept {} }; /// Exception when encoding audio packet class ErrorEncodingVideo : public BaseException { public: - string file_path; int64_t frame_number; - ErrorEncodingVideo(string message, int64_t frame_number) + ErrorEncodingVideo(std::string message, int64_t frame_number) : BaseException(message), frame_number(frame_number) { } - virtual ~ErrorEncodingVideo() throw () {} + virtual ~ErrorEncodingVideo() noexcept {} }; /// Exception when an invalid # of audio channels are detected class InvalidChannels : public BaseException { public: - string file_path; - InvalidChannels(string message, string file_path) + std::string file_path; + InvalidChannels(std::string message, std::string file_path) : BaseException(message), file_path(file_path) { } - virtual ~InvalidChannels() throw () {} + virtual ~InvalidChannels() noexcept {} }; /// Exception when no valid codec is found for a file class InvalidCodec : public BaseException { public: - string file_path; - InvalidCodec(string message, string file_path) + std::string file_path; + InvalidCodec(std::string message, std::string file_path) : BaseException(message), file_path(file_path) { } - virtual ~InvalidCodec() throw () {} + virtual ~InvalidCodec() noexcept {} }; /// Exception for files that can not be found or opened class InvalidFile : public BaseException { public: - string file_path; - InvalidFile(string message, string file_path) + std::string file_path; + InvalidFile(std::string message, std::string file_path) : BaseException(message), file_path(file_path) { } - virtual ~InvalidFile() throw () {} + virtual ~InvalidFile() noexcept {} }; /// Exception when no valid format is found for a file class InvalidFormat : public BaseException { public: - string file_path; - InvalidFormat(string message, string file_path) + std::string file_path; + InvalidFormat(std::string message, std::string file_path) : BaseException(message), file_path(file_path) { } - virtual ~InvalidFormat() throw () {} + virtual ~InvalidFormat() noexcept {} }; /// Exception for invalid JSON class InvalidJSON : public BaseException { public: - string file_path; - InvalidJSON(string message, string file_path) + std::string file_path; + InvalidJSON(std::string message, std::string file_path) : BaseException(message), file_path(file_path) { } - virtual ~InvalidJSON() throw () {} + virtual ~InvalidJSON() noexcept {} }; /// Exception when invalid encoding options are used class InvalidOptions : public BaseException { public: - string file_path; - InvalidOptions(string message, string file_path) + std::string file_path; + InvalidOptions(std::string message, std::string file_path) : BaseException(message), file_path(file_path) { } - virtual ~InvalidOptions() throw () {} + virtual ~InvalidOptions() noexcept {} }; /// Exception when invalid sample rate is detected during encoding class InvalidSampleRate : public BaseException { public: - string file_path; - InvalidSampleRate(string message, string file_path) + std::string file_path; + InvalidSampleRate(std::string message, std::string file_path) : BaseException(message), file_path(file_path) { } - virtual ~InvalidSampleRate() throw () {} + virtual ~InvalidSampleRate() noexcept {} }; /// Exception for missing JSON Change key class InvalidJSONKey : public BaseException { public: - string json; - InvalidJSONKey(string message, string json) + std::string json; + InvalidJSONKey(std::string message, std::string json) : BaseException(message), json(json) { } - virtual ~InvalidJSONKey() throw () {} + virtual ~InvalidJSONKey() noexcept {} }; /// Exception when no streams are found in the file class NoStreamsFound : public BaseException { public: - string file_path; - NoStreamsFound(string message, string file_path) + std::string file_path; + NoStreamsFound(std::string message, std::string file_path) : BaseException(message), file_path(file_path) { } - virtual ~NoStreamsFound() throw () {} + virtual ~NoStreamsFound() noexcept {} }; /// Exception for frames that are out of bounds. @@ -207,9 +202,9 @@ namespace openshot { public: int64_t FrameRequested; int64_t MaxFrames; - OutOfBoundsFrame(string message, int64_t frame_requested, int64_t max_frames) + OutOfBoundsFrame(std::string message, int64_t frame_requested, int64_t max_frames) : BaseException(message), FrameRequested(frame_requested), MaxFrames(max_frames) { } - virtual ~OutOfBoundsFrame() throw () {} + virtual ~OutOfBoundsFrame() noexcept {} }; /// Exception for an out of bounds key-frame point. @@ -218,59 +213,59 @@ namespace openshot { public: int PointRequested; int MaxPoints; - OutOfBoundsPoint(string message, int point_requested, int max_points) + OutOfBoundsPoint(std::string message, int point_requested, int max_points) : BaseException(message), PointRequested(point_requested), MaxPoints(max_points) { } - virtual ~OutOfBoundsPoint() throw () {} + virtual ~OutOfBoundsPoint() noexcept {} }; /// Exception when memory could not be allocated class OutOfMemory : public BaseException { public: - string file_path; - OutOfMemory(string message, string file_path) + std::string file_path; + OutOfMemory(std::string message, std::string file_path) : BaseException(message), file_path(file_path) { } - virtual ~OutOfMemory() throw () {} + virtual ~OutOfMemory() noexcept {} }; /// Exception when a reader is closed, and a frame is requested class ReaderClosed : public BaseException { public: - string file_path; - ReaderClosed(string message, string file_path) + std::string file_path; + ReaderClosed(std::string message, std::string file_path) : BaseException(message), file_path(file_path) { } - virtual ~ReaderClosed() throw () {} + virtual ~ReaderClosed() noexcept {} }; /// Exception when resample fails class ResampleError : public BaseException { public: - string file_path; - ResampleError(string message, string file_path) + std::string file_path; + ResampleError(std::string message, std::string file_path) : BaseException(message), file_path(file_path) { } - virtual ~ResampleError() throw () {} + virtual ~ResampleError() noexcept {} }; /// Exception when too many seek attempts happen class TooManySeeks : public BaseException { public: - string file_path; - TooManySeeks(string message, string file_path) + std::string file_path; + TooManySeeks(std::string message, std::string file_path) : BaseException(message), file_path(file_path) { } - virtual ~TooManySeeks() throw () {} + virtual ~TooManySeeks() noexcept {} }; /// Exception when a writer is closed, and a frame is requested class WriterClosed : public BaseException { public: - string file_path; - WriterClosed(string message, string file_path) + std::string file_path; + WriterClosed(std::string message, std::string file_path) : BaseException(message), file_path(file_path) { } - virtual ~WriterClosed() throw () {} + virtual ~WriterClosed() noexcept {} }; } From 2dc2fffa454daf97f84de53261a7972c50553df0 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Wed, 3 Jul 2019 14:06:44 -0400 Subject: [PATCH 13/43] ZmqLogger: default AppendDebugMethod()'s extra params Give the AppendDebugMethod() declaration a set of default values for all parameters after the first. (It uses `""` and `-1.0`, which are what callers were passing in anyway.) This way, callers have the _option_ to eschew this kind of thing: ``` ZmqLogger::Instance()->AppendDebugMethod("Message", "start", start, "length", length, "", -1, "", -1, "", -1, "", -1); ``` instead, they can use the functionally equivalent: ``` ZmqLogger::Instance()->AppendDebugMethod("Message", "start", start, "length", length); ``` Passing meaningless args is the compiler's job, not the programmer's. --- include/ZmqLogger.h | 13 +++++++------ src/ZmqLogger.cpp | 15 ++++++++------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/include/ZmqLogger.h b/include/ZmqLogger.h index 96e16213..84729500 100644 --- a/include/ZmqLogger.h +++ b/include/ZmqLogger.h @@ -96,12 +96,13 @@ namespace openshot { static ZmqLogger * Instance(); /// Append debug information - void AppendDebugMethod(string method_name, string arg1_name, float arg1_value, - string arg2_name, float arg2_value, - string arg3_name, float arg3_value, - string arg4_name, float arg4_value, - string arg5_name, float arg5_value, - string arg6_name, float arg6_value); + void AppendDebugMethod(std::string method_name, + std::string arg1_name="", float arg1_value=-0.0, + std::string arg2_name="", float arg2_value=-0.0, + std::string arg3_name="", float arg3_value=-0.0, + std::string arg4_name="", float arg4_value=-0.0, + std::string arg5_name="", float arg5_value=-0.0, + std::string arg6_name="", float arg6_value=-0.0); /// Close logger (sockets and/or files) void Close(); diff --git a/src/ZmqLogger.cpp b/src/ZmqLogger.cpp index f9ecc875..7cf69228 100644 --- a/src/ZmqLogger.cpp +++ b/src/ZmqLogger.cpp @@ -162,12 +162,13 @@ void ZmqLogger::Close() } // Append debug information -void ZmqLogger::AppendDebugMethod(string method_name, string arg1_name, float arg1_value, - string arg2_name, float arg2_value, - string arg3_name, float arg3_value, - string arg4_name, float arg4_value, - string arg5_name, float arg5_value, - string arg6_name, float arg6_value) +void ZmqLogger::AppendDebugMethod(string method_name, + string arg1_name, float arg1_value, + string arg2_name, float arg2_value, + string arg3_name, float arg3_value, + string arg4_name, float arg4_value, + string arg5_name, float arg5_value, + string arg6_name, float arg6_value) { if (!enabled) // Don't do anything @@ -206,4 +207,4 @@ void ZmqLogger::AppendDebugMethod(string method_name, string arg1_name, float ar // Send message through ZMQ Log(message.str()); } -} \ No newline at end of file +} From 75c9565f318f4b7b72a7ec2f2bc278f804ef2820 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Wed, 3 Jul 2019 14:07:36 -0400 Subject: [PATCH 14/43] ZmqLogger.h: Remove using namespace std; add prefixes --- include/ZmqLogger.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/include/ZmqLogger.h b/include/ZmqLogger.h index 84729500..ba9a3370 100644 --- a/include/ZmqLogger.h +++ b/include/ZmqLogger.h @@ -45,8 +45,6 @@ #include "JuceHeader.h" -using namespace std; - namespace openshot { /** @@ -58,11 +56,11 @@ namespace openshot { class ZmqLogger { private: CriticalSection loggerCriticalSection; - string connection; + std::string connection; // Logfile related vars - string file_path; - ofstream log_file; + std::string file_path; + std::ofstream log_file; bool enabled; /// ZMQ Context @@ -108,19 +106,19 @@ namespace openshot { void Close(); /// Set or change connection info for logger (i.e. tcp://*:5556) - void Connection(string new_connection); + void Connection(std::string new_connection); /// Enable/Disable logging void Enable(bool is_enabled) { enabled = is_enabled;}; /// Set or change the file path (optional) - void Path(string new_path); + void Path(std::string new_path); /// Log message to all subscribers of this logger (if any) - void Log(string message); + void Log(std::string message); /// Log message to a file (if path set) - void LogToFile(string message); + void LogToFile(std::string message); }; } From f29a6bcb274526ec3a008f86c0f2ddce88792044 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Wed, 3 Jul 2019 14:14:02 -0400 Subject: [PATCH 15/43] Trim unnecessary args off logging calls --- src/Clip.cpp | 2 +- src/FFmpegReader.cpp | 74 ++++++++++++++++++++++---------------------- src/FFmpegWriter.cpp | 61 ++++++++++++++++++------------------ src/FrameMapper.cpp | 22 ++++++------- src/ImageWriter.cpp | 4 +-- src/Timeline.cpp | 66 +++++++++++++++++++-------------------- 6 files changed, 114 insertions(+), 115 deletions(-) diff --git a/src/Clip.cpp b/src/Clip.cpp index bddcd0c9..670f7a0f 100644 --- a/src/Clip.cpp +++ b/src/Clip.cpp @@ -259,7 +259,7 @@ void Clip::Open() void Clip::Close() { if (reader) { - ZmqLogger::Instance()->AppendDebugMethod("Clip::Close", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Clip::Close"); // Close the reader reader->Close(); diff --git a/src/FFmpegReader.cpp b/src/FFmpegReader.cpp index 10d89051..db018684 100644 --- a/src/FFmpegReader.cpp +++ b/src/FFmpegReader.cpp @@ -209,7 +209,7 @@ static enum AVPixelFormat get_hw_dec_format(AVCodecContext *ctx, const enum AVPi break; } } - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::get_hw_dec_format (Unable to decode this file using hardware decode)", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::get_hw_dec_format (Unable to decode this file using hardware decode)"); return AV_PIX_FMT_NONE; } @@ -385,11 +385,11 @@ void FFmpegReader::Open() { #elif defined(__APPLE__) if( adapter_ptr != NULL ) { #endif - ZmqLogger::Instance()->AppendDebugMethod("Decode Device present using device", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Decode Device present using device"); } else { adapter_ptr = NULL; // use default - ZmqLogger::Instance()->AppendDebugMethod("Decode Device not present using default", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Decode Device not present using default"); } hw_device_ctx = NULL; @@ -452,7 +452,7 @@ void FFmpegReader::Open() { pCodecCtx->coded_height < constraints->min_height || pCodecCtx->coded_width > constraints->max_width || pCodecCtx->coded_height > constraints->max_height) { - ZmqLogger::Instance()->AppendDebugMethod("DIMENSIONS ARE TOO LARGE for hardware acceleration\n", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("DIMENSIONS ARE TOO LARGE for hardware acceleration\n"); hw_de_supported = 0; retry_decode_open = 1; AV_FREE_CONTEXT(pCodecCtx); @@ -477,13 +477,13 @@ void FFmpegReader::Open() { max_h = openshot::Settings::Instance()->DE_LIMIT_HEIGHT_MAX; //max_w = ((getenv( "LIMIT_WIDTH_MAX" )==NULL) ? MAX_SUPPORTED_WIDTH : atoi(getenv( "LIMIT_WIDTH_MAX" ))); max_w = openshot::Settings::Instance()->DE_LIMIT_WIDTH_MAX; - ZmqLogger::Instance()->AppendDebugMethod("Constraints could not be found using default limit\n", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Constraints could not be found using default limit\n"); //cerr << "Constraints could not be found using default limit\n"; if (pCodecCtx->coded_width < 0 || pCodecCtx->coded_height < 0 || pCodecCtx->coded_width > max_w || pCodecCtx->coded_height > max_h ) { - ZmqLogger::Instance()->AppendDebugMethod("DIMENSIONS ARE TOO LARGE for hardware acceleration\n", "Max Width :", max_w, "Max Height :", max_h, "Frame width :", pCodecCtx->coded_width, "Frame height :", pCodecCtx->coded_height, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("DIMENSIONS ARE TOO LARGE for hardware acceleration\n", "Max Width :", max_w, "Max Height :", max_h, "Frame width :", pCodecCtx->coded_width, "Frame height :", pCodecCtx->coded_height); hw_de_supported = 0; retry_decode_open = 1; AV_FREE_CONTEXT(pCodecCtx); @@ -493,13 +493,13 @@ void FFmpegReader::Open() { } } else { - ZmqLogger::Instance()->AppendDebugMethod("\nDecode hardware acceleration is used\n", "Max Width :", max_w, "Max Height :", max_h, "Frame width :", pCodecCtx->coded_width, "Frame height :", pCodecCtx->coded_height, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("\nDecode hardware acceleration is used\n", "Max Width :", max_w, "Max Height :", max_h, "Frame width :", pCodecCtx->coded_width, "Frame height :", pCodecCtx->coded_height); retry_decode_open = 0; } } } // if hw_de_on && hw_de_supported else { - ZmqLogger::Instance()->AppendDebugMethod("\nDecode in software is used\n", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("\nDecode in software is used\n"); } #else retry_decode_open = 0; @@ -577,7 +577,7 @@ void FFmpegReader::Close() { // Mark as "closed" is_open = false; - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::Close", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::Close"); if (packet) { // Remove previous packet before getting next one @@ -792,13 +792,13 @@ std::shared_ptr FFmpegReader::GetFrame(int64_t requested_frame) { throw InvalidFile("Could not detect the duration of the video or audio stream.", path); // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::GetFrame", "requested_frame", requested_frame, "last_frame", last_frame, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::GetFrame", "requested_frame", requested_frame, "last_frame", last_frame); // Check the cache for this frame std::shared_ptr frame = final_cache.GetFrame(requested_frame); if (frame) { // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::GetFrame", "returned cached frame", requested_frame, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::GetFrame", "returned cached frame", requested_frame); // Return the cached frame return frame; @@ -809,7 +809,7 @@ std::shared_ptr FFmpegReader::GetFrame(int64_t requested_frame) { frame = final_cache.GetFrame(requested_frame); if (frame) { // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::GetFrame", "returned cached frame on 2nd look", requested_frame, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::GetFrame", "returned cached frame on 2nd look", requested_frame); // Return the cached frame } else { @@ -867,7 +867,7 @@ std::shared_ptr FFmpegReader::ReadStream(int64_t requested_frame) { omp_set_nested(true); // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ReadStream", "requested_frame", requested_frame, "OPEN_MP_NUM_PROCESSORS", OPEN_MP_NUM_PROCESSORS, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ReadStream", "requested_frame", requested_frame, "OPEN_MP_NUM_PROCESSORS", OPEN_MP_NUM_PROCESSORS); #pragma omp parallel { @@ -990,7 +990,7 @@ std::shared_ptr FFmpegReader::ReadStream(int64_t requested_frame) { } // end omp parallel // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ReadStream (Completed)", "packets_processed", packets_processed, "end_of_stream", end_of_stream, "largest_frame_processed", largest_frame_processed, "Working Cache Count", working_cache.Count(), "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ReadStream (Completed)", "packets_processed", packets_processed, "end_of_stream", end_of_stream, "largest_frame_processed", largest_frame_processed, "Working Cache Count", working_cache.Count()); // End of stream? if (end_of_stream) @@ -1065,7 +1065,7 @@ bool FFmpegReader::GetAVFrame() { hw_de_av_device_type = hw_de_av_device_type_global; if (ret < 0 || ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) { - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::GetAVFrame (Packet not sent)", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::GetAVFrame (Packet not sent)"); } else { AVFrame *next_frame2; @@ -1083,17 +1083,17 @@ bool FFmpegReader::GetAVFrame() { break; } if (ret != 0) { - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::GetAVFrame (invalid return frame received)", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::GetAVFrame (invalid return frame received)"); } if (hw_de_on && hw_de_supported) { int err; if (next_frame2->format == hw_de_av_pix_fmt) { next_frame->format = AV_PIX_FMT_YUV420P; if ((err = av_hwframe_transfer_data(next_frame,next_frame2,0)) < 0) { - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::GetAVFrame (Failed to transfer data to output frame)", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::GetAVFrame (Failed to transfer data to output frame)"); } if ((err = av_frame_copy_props(next_frame,next_frame2)) < 0) { - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::GetAVFrame (Failed to copy props to output frame)", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::GetAVFrame (Failed to copy props to output frame)"); } } } @@ -1206,14 +1206,14 @@ void FFmpegReader::ProcessVideoPacket(int64_t requested_frame) { RemoveAVFrame(pFrame); // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ProcessVideoPacket (Skipped)", "requested_frame", requested_frame, "current_frame", current_frame, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ProcessVideoPacket (Skipped)", "requested_frame", requested_frame, "current_frame", current_frame); // Skip to next frame without decoding or caching return; } // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ProcessVideoPacket (Before)", "requested_frame", requested_frame, "current_frame", current_frame, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ProcessVideoPacket (Before)", "requested_frame", requested_frame, "current_frame", current_frame); // Init some things local (for OpenMP) PixelFormat pix_fmt = AV_GET_CODEC_PIXEL_FORMAT(pStream, pCodecCtx); @@ -1352,7 +1352,7 @@ void FFmpegReader::ProcessVideoPacket(int64_t requested_frame) { } // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ProcessVideoPacket (After)", "requested_frame", requested_frame, "current_frame", current_frame, "f->number", f->number, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ProcessVideoPacket (After)", "requested_frame", requested_frame, "current_frame", current_frame, "f->number", f->number); } // end omp task @@ -1367,14 +1367,14 @@ void FFmpegReader::ProcessAudioPacket(int64_t requested_frame, int64_t target_fr // Are we close enough to decode the frame's audio? if (target_frame < (requested_frame - 20)) { // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ProcessAudioPacket (Skipped)", "requested_frame", requested_frame, "target_frame", target_frame, "starting_sample", starting_sample, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ProcessAudioPacket (Skipped)", "requested_frame", requested_frame, "target_frame", target_frame, "starting_sample", starting_sample); // Skip to next frame without decoding or caching return; } // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ProcessAudioPacket (Before)", "requested_frame", requested_frame, "target_frame", target_frame, "starting_sample", starting_sample, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ProcessAudioPacket (Before)", "requested_frame", requested_frame, "target_frame", target_frame, "starting_sample", starting_sample); // Init an AVFrame to hold the decoded audio samples int frame_finished = 0; @@ -1491,7 +1491,7 @@ void FFmpegReader::ProcessAudioPacket(int64_t requested_frame, int64_t target_fr // Allocate audio buffer int16_t *audio_buf = new int16_t[AVCODEC_MAX_AUDIO_FRAME_SIZE + MY_INPUT_BUFFER_PADDING_SIZE]; - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ProcessAudioPacket (ReSample)", "packet_samples", packet_samples, "info.channels", info.channels, "info.sample_rate", info.sample_rate, "aCodecCtx->sample_fmt", AV_GET_SAMPLE_FORMAT(aStream, aCodecCtx), "AV_SAMPLE_FMT_S16", AV_SAMPLE_FMT_S16, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ProcessAudioPacket (ReSample)", "packet_samples", packet_samples, "info.channels", info.channels, "info.sample_rate", info.sample_rate, "aCodecCtx->sample_fmt", AV_GET_SAMPLE_FORMAT(aStream, aCodecCtx), "AV_SAMPLE_FMT_S16", AV_SAMPLE_FMT_S16); // Create output frame AVFrame *audio_converted = AV_ALLOCATE_FRAME(); @@ -1652,7 +1652,7 @@ void FFmpegReader::ProcessAudioPacket(int64_t requested_frame, int64_t target_fr AV_FREE_FRAME(&audio_frame); // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ProcessAudioPacket (After)", "requested_frame", requested_frame, "starting_frame", target_frame, "end_frame", starting_frame_number - 1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ProcessAudioPacket (After)", "requested_frame", requested_frame, "starting_frame", target_frame, "end_frame", starting_frame_number - 1); } @@ -1831,7 +1831,7 @@ void FFmpegReader::UpdatePTSOffset(bool is_video) { video_pts_offset = 0 - max(GetVideoPTS(), (int64_t) info.video_timebase.ToInt() * 10); // debug output - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::UpdatePTSOffset (Video)", "video_pts_offset", video_pts_offset, "is_video", is_video, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::UpdatePTSOffset (Video)", "video_pts_offset", video_pts_offset, "is_video", is_video); } } else { // AUDIO PACKET @@ -1841,7 +1841,7 @@ void FFmpegReader::UpdatePTSOffset(bool is_video) { audio_pts_offset = 0 - max(packet->pts, (int64_t) info.audio_timebase.ToInt() * 10); // debug output - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::UpdatePTSOffset (Audio)", "audio_pts_offset", audio_pts_offset, "is_video", is_video, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::UpdatePTSOffset (Audio)", "audio_pts_offset", audio_pts_offset, "is_video", is_video); } } } @@ -1874,14 +1874,14 @@ int64_t FFmpegReader::ConvertVideoPTStoFrame(int64_t pts) { if (current_video_frame < frame) // has missing frames - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ConvertVideoPTStoFrame (detected missing frame)", "calculated frame", frame, "previous_video_frame", previous_video_frame, "current_video_frame", current_video_frame, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ConvertVideoPTStoFrame (detected missing frame)", "calculated frame", frame, "previous_video_frame", previous_video_frame, "current_video_frame", current_video_frame); // Sometimes frames are missing due to varying timestamps, or they were dropped. Determine // if we are missing a video frame. const GenericScopedLock lock(processingCriticalSection); while (current_video_frame < frame) { if (!missing_video_frames.count(current_video_frame)) { - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ConvertVideoPTStoFrame (tracking missing frame)", "current_video_frame", current_video_frame, "previous_video_frame", previous_video_frame, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ConvertVideoPTStoFrame (tracking missing frame)", "current_video_frame", current_video_frame, "previous_video_frame", previous_video_frame); missing_video_frames.insert(pair(current_video_frame, previous_video_frame)); missing_video_frames_source.insert(pair(previous_video_frame, current_video_frame)); } @@ -1965,16 +1965,16 @@ AudioLocation FFmpegReader::GetAudioPTSLocation(int64_t pts) { location.frame = previous_packet_location.frame; // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::GetAudioPTSLocation (Audio Gap Detected)", "Source Frame", orig_frame, "Source Audio Sample", orig_start, "Target Frame", location.frame, "Target Audio Sample", location.sample_start, "pts", pts, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::GetAudioPTSLocation (Audio Gap Detected)", "Source Frame", orig_frame, "Source Audio Sample", orig_start, "Target Frame", location.frame, "Target Audio Sample", location.sample_start, "pts", pts); } else { // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::GetAudioPTSLocation (Audio Gap Ignored - too big)", "Previous location frame", previous_packet_location.frame, "Target Frame", location.frame, "Target Audio Sample", location.sample_start, "pts", pts, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::GetAudioPTSLocation (Audio Gap Ignored - too big)", "Previous location frame", previous_packet_location.frame, "Target Frame", location.frame, "Target Audio Sample", location.sample_start, "pts", pts); const GenericScopedLock lock(processingCriticalSection); for (int64_t audio_frame = previous_packet_location.frame; audio_frame < location.frame; audio_frame++) { if (!missing_audio_frames.count(audio_frame)) { - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::GetAudioPTSLocation (tracking missing frame)", "missing_audio_frame", audio_frame, "previous_audio_frame", previous_packet_location.frame, "new location frame", location.frame, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::GetAudioPTSLocation (tracking missing frame)", "missing_audio_frame", audio_frame, "previous_audio_frame", previous_packet_location.frame, "new location frame", location.frame); missing_audio_frames.insert(pair(audio_frame, previous_packet_location.frame - 1)); } } @@ -2043,7 +2043,7 @@ bool FFmpegReader::CheckMissingFrame(int64_t requested_frame) { checked_count = checked_frames[requested_frame]; // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::CheckMissingFrame", "requested_frame", requested_frame, "has_missing_frames", has_missing_frames, "missing_video_frames.size()", missing_video_frames.size(), "checked_count", checked_count, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::CheckMissingFrame", "requested_frame", requested_frame, "has_missing_frames", has_missing_frames, "missing_video_frames.size()", missing_video_frames.size(), "checked_count", checked_count); // Missing frames (sometimes frame #'s are skipped due to invalid or missing timestamps) map::iterator itr; @@ -2089,12 +2089,12 @@ bool FFmpegReader::CheckMissingFrame(int64_t requested_frame) { std::shared_ptr missing_frame = CreateFrame(requested_frame); // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::CheckMissingFrame (Is Previous Video Frame Final)", "requested_frame", requested_frame, "missing_frame->number", missing_frame->number, "missing_source_frame", missing_source_frame, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::CheckMissingFrame (Is Previous Video Frame Final)", "requested_frame", requested_frame, "missing_frame->number", missing_frame->number, "missing_source_frame", missing_source_frame); // If previous frame found, copy image from previous to missing frame (else we'll just wait a bit and try again later) if (parent_frame != NULL) { // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::CheckMissingFrame (AddImage from Previous Video Frame)", "requested_frame", requested_frame, "missing_frame->number", missing_frame->number, "missing_source_frame", missing_source_frame, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::CheckMissingFrame (AddImage from Previous Video Frame)", "requested_frame", requested_frame, "missing_frame->number", missing_frame->number, "missing_source_frame", missing_source_frame); // Add this frame to the processed map (since it's already done) std::shared_ptr parent_image = parent_frame->GetImage(); @@ -2115,7 +2115,7 @@ bool FFmpegReader::CheckMissingFrame(int64_t requested_frame) { int samples_per_frame = Frame::GetSamplesPerFrame(missing_frame->number, info.fps, info.sample_rate, info.channels); // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::CheckMissingFrame (Add Silence for Missing Audio Frame)", "requested_frame", requested_frame, "missing_frame->number", missing_frame->number, "samples_per_frame", samples_per_frame, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::CheckMissingFrame (Add Silence for Missing Audio Frame)", "requested_frame", requested_frame, "missing_frame->number", missing_frame->number, "samples_per_frame", samples_per_frame); // Add this frame to the processed map (since it's already done) missing_frame->AddAudioSilence(samples_per_frame); @@ -2224,7 +2224,7 @@ void FFmpegReader::CheckWorkingFrames(bool end_of_stream, int64_t requested_fram const GenericScopedLock lock(processingCriticalSection); if (missing_video_frames_source.count(f->number)) { // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::CheckWorkingFrames (add frame to missing cache)", "f->number", f->number, "is_seek_trash", is_seek_trash, "Missing Cache Count", missing_frames.Count(), "Working Cache Count", working_cache.Count(), "Final Cache Count", final_cache.Count(), "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::CheckWorkingFrames (add frame to missing cache)", "f->number", f->number, "is_seek_trash", is_seek_trash, "Missing Cache Count", missing_frames.Count(), "Working Cache Count", working_cache.Count(), "Final Cache Count", final_cache.Count()); missing_frames.Add(f); } diff --git a/src/FFmpegWriter.cpp b/src/FFmpegWriter.cpp index 663e8ab0..37f3016a 100644 --- a/src/FFmpegWriter.cpp +++ b/src/FFmpegWriter.cpp @@ -151,7 +151,7 @@ void FFmpegWriter::auto_detect_format() { // initialize streams void FFmpegWriter::initialize_streams() { - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::initialize_streams", "fmt->video_codec", fmt->video_codec, "fmt->audio_codec", fmt->audio_codec, "AV_CODEC_ID_NONE", AV_CODEC_ID_NONE, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::initialize_streams", "fmt->video_codec", fmt->video_codec, "fmt->audio_codec", fmt->audio_codec, "AV_CODEC_ID_NONE", AV_CODEC_ID_NONE); // Add the audio and video streams using the default format codecs and initialize the codecs video_st = NULL; @@ -315,7 +315,7 @@ void FFmpegWriter::SetAudioOptions(bool has_audio, string codec, int sample_rate if (original_channels == 0) original_channels = info.channels; - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::SetAudioOptions (" + codec + ")", "sample_rate", sample_rate, "channels", channels, "bit_rate", bit_rate, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::SetAudioOptions (" + codec + ")", "sample_rate", sample_rate, "channels", channels, "bit_rate", bit_rate); // Enable / Disable audio info.has_audio = has_audio; @@ -468,7 +468,7 @@ void FFmpegWriter::SetOption(StreamType stream, string name, string value) { AV_OPTION_SET(st, c->priv_data, name.c_str(), value.c_str(), c); } - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::SetOption (" + (string)name + ")", "stream == VIDEO_STREAM", stream == VIDEO_STREAM, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::SetOption (" + (string)name + ")", "stream == VIDEO_STREAM", stream == VIDEO_STREAM); // Muxing dictionary is not part of the codec context. // Just reusing SetOption function to set popular multiplexing presets. @@ -504,7 +504,7 @@ void FFmpegWriter::PrepareStreams() { if (!info.has_audio && !info.has_video) throw InvalidOptions("No video or audio options have been set. You must set has_video or has_audio (or both).", path); - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::PrepareStreams [" + path + "]", "info.has_audio", info.has_audio, "info.has_video", info.has_video, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::PrepareStreams [" + path + "]", "info.has_audio", info.has_audio, "info.has_video", info.has_video); // Initialize the streams (i.e. add the streams) initialize_streams(); @@ -554,7 +554,7 @@ void FFmpegWriter::WriteHeader() { // Mark as 'written' write_header = true; - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::WriteHeader", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::WriteHeader"); } // Add a frame to the queue waiting to be encoded. @@ -571,7 +571,7 @@ void FFmpegWriter::WriteFrame(std::shared_ptr frame) { if (info.has_audio && audio_st) spooled_audio_frames.push_back(frame); - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::WriteFrame", "frame->number", frame->number, "spooled_video_frames.size()", spooled_video_frames.size(), "spooled_audio_frames.size()", spooled_audio_frames.size(), "cache_size", cache_size, "is_writing", is_writing, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::WriteFrame", "frame->number", frame->number, "spooled_video_frames.size()", spooled_video_frames.size(), "spooled_audio_frames.size()", spooled_audio_frames.size(), "cache_size", cache_size, "is_writing", is_writing); // Write the frames once it reaches the correct cache size if (spooled_video_frames.size() == cache_size || spooled_audio_frames.size() == cache_size) { @@ -592,7 +592,7 @@ void FFmpegWriter::WriteFrame(std::shared_ptr frame) { // Write all frames in the queue to the video file. void FFmpegWriter::write_queued_frames() { - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_queued_frames", "spooled_video_frames.size()", spooled_video_frames.size(), "spooled_audio_frames.size()", spooled_audio_frames.size(), "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_queued_frames", "spooled_video_frames.size()", spooled_video_frames.size(), "spooled_audio_frames.size()", spooled_audio_frames.size()); // Flip writing flag is_writing = true; @@ -700,7 +700,7 @@ void FFmpegWriter::write_queued_frames() { // Write a block of frames from a reader void FFmpegWriter::WriteFrame(ReaderBase *reader, int64_t start, int64_t length) { - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::WriteFrame (from Reader)", "start", start, "length", length, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::WriteFrame (from Reader)", "start", start, "length", length); // Loop through each frame (and encoded it) for (int64_t number = start; number <= length; number++) { @@ -733,7 +733,7 @@ void FFmpegWriter::WriteTrailer() { // Mark as 'written' write_trailer = true; - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::WriteTrailer", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::WriteTrailer"); } // Flush encoders @@ -818,8 +818,7 @@ void FFmpegWriter::flush_encoders() { #endif // IS_FFMPEG_3_2 if (error_code < 0) { - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::flush_encoders ERROR [" + (string) av_err2str(error_code) + "]", "error_code", error_code, "", -1, "", -1, - "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::flush_encoders ERROR [" + (string) av_err2str(error_code) + "]", "error_code", error_code); } if (!got_packet) { stop_encoding = 1; @@ -841,7 +840,7 @@ void FFmpegWriter::flush_encoders() { // Write packet error_code = av_interleaved_write_frame(oc, &pkt); if (error_code < 0) { - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::flush_encoders ERROR [" + (string)av_err2str(error_code) + "]", "error_code", error_code, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::flush_encoders ERROR [" + (string)av_err2str(error_code) + "]", "error_code", error_code); } // Deallocate memory (if needed) @@ -876,7 +875,7 @@ void FFmpegWriter::flush_encoders() { error_code = avcodec_encode_audio2(audio_codec, &pkt, NULL, &got_packet); #endif if (error_code < 0) { - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::flush_encoders ERROR [" + (string)av_err2str(error_code) + "]", "error_code", error_code, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::flush_encoders ERROR [" + (string)av_err2str(error_code) + "]", "error_code", error_code); } if (!got_packet) { stop_encoding = 1; @@ -902,7 +901,7 @@ void FFmpegWriter::flush_encoders() { // Write packet error_code = av_interleaved_write_frame(oc, &pkt); if (error_code < 0) { - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::flush_encoders ERROR [" + (string)av_err2str(error_code) + "]", "error_code", error_code, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::flush_encoders ERROR [" + (string)av_err2str(error_code) + "]", "error_code", error_code); } // deallocate memory for packet @@ -987,7 +986,7 @@ void FFmpegWriter::Close() { write_header = false; write_trailer = false; - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::Close", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::Close"); } // Add an AVFrame to the cache @@ -1214,9 +1213,9 @@ AVStream *FFmpegWriter::add_video_stream() { AV_COPY_PARAMS_FROM_CONTEXT(st, c); #if (LIBAVFORMAT_VERSION_MAJOR < 58) - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::add_video_stream (" + (string)fmt->name + " : " + (string)av_get_pix_fmt_name(c->pix_fmt) + ")", "c->codec_id", c->codec_id, "c->bit_rate", c->bit_rate, "c->pix_fmt", c->pix_fmt, "oc->oformat->flags", oc->oformat->flags, "AVFMT_RAWPICTURE", AVFMT_RAWPICTURE, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::add_video_stream (" + (string)fmt->name + " : " + (string)av_get_pix_fmt_name(c->pix_fmt) + ")", "c->codec_id", c->codec_id, "c->bit_rate", c->bit_rate, "c->pix_fmt", c->pix_fmt, "oc->oformat->flags", oc->oformat->flags, "AVFMT_RAWPICTURE", AVFMT_RAWPICTURE); #else - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::add_video_stream (" + (string)fmt->name + " : " + (string)av_get_pix_fmt_name(c->pix_fmt) + ")", "c->codec_id", c->codec_id, "c->bit_rate", c->bit_rate, "c->pix_fmt", c->pix_fmt, "oc->oformat->flags", oc->oformat->flags, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::add_video_stream (" + (string)fmt->name + " : " + (string)av_get_pix_fmt_name(c->pix_fmt) + ")", "c->codec_id", c->codec_id, "c->bit_rate", c->bit_rate, "c->pix_fmt", c->pix_fmt, "oc->oformat->flags", oc->oformat->flags); #endif return st; @@ -1290,7 +1289,7 @@ void FFmpegWriter::open_audio(AVFormatContext *oc, AVStream *st) { av_dict_set(&st->metadata, iter->first.c_str(), iter->second.c_str(), 0); } - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::open_audio", "audio_codec->thread_count", audio_codec->thread_count, "audio_input_frame_size", audio_input_frame_size, "buffer_size", AVCODEC_MAX_AUDIO_FRAME_SIZE + MY_INPUT_BUFFER_PADDING_SIZE, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::open_audio", "audio_codec->thread_count", audio_codec->thread_count, "audio_input_frame_size", audio_input_frame_size, "buffer_size", AVCODEC_MAX_AUDIO_FRAME_SIZE + MY_INPUT_BUFFER_PADDING_SIZE); } // open video codec @@ -1332,15 +1331,15 @@ void FFmpegWriter::open_video(AVFormatContext *oc, AVStream *st) { #elif defined(__APPLE__) if( adapter_ptr != NULL ) { #endif - ZmqLogger::Instance()->AppendDebugMethod("Encode Device present using device", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Encode Device present using device"); } else { adapter_ptr = NULL; // use default - ZmqLogger::Instance()->AppendDebugMethod("Encode Device not present using default", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Encode Device not present using default"); } if (av_hwdevice_ctx_create(&hw_device_ctx, hw_en_av_device_type, adapter_ptr, NULL, 0) < 0) { - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::open_video : Codec name: ", info.vcodec.c_str(), -1, " ERROR creating\n", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::open_video : Codec name: ", info.vcodec.c_str(), -1, " ERROR creating\n", -1); throw InvalidCodec("Could not create hwdevice", path); } } @@ -1543,7 +1542,7 @@ void FFmpegWriter::write_audio_packets(bool is_final) { AV_FREE_FRAME(&audio_converted); all_queued_samples = NULL; // this array cleared with above call - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_audio_packets (Successfully completed 1st resampling)", "nb_samples", nb_samples, "remaining_frame_samples", remaining_frame_samples, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_audio_packets (Successfully completed 1st resampling)", "nb_samples", nb_samples, "remaining_frame_samples", remaining_frame_samples); } // Loop until no more samples @@ -1633,7 +1632,7 @@ void FFmpegWriter::write_audio_packets(bool is_final) { AV_FREE_FRAME(&audio_frame); all_queued_samples = NULL; // this array cleared with above call - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_audio_packets (Successfully completed 2nd resampling for Planar formats)", "nb_samples", nb_samples, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_audio_packets (Successfully completed 2nd resampling for Planar formats)", "nb_samples", nb_samples); } else { // Create a new array @@ -1721,12 +1720,12 @@ void FFmpegWriter::write_audio_packets(bool is_final) { /* write the compressed frame in the media file */ int error_code = av_interleaved_write_frame(oc, &pkt); if (error_code < 0) { - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_audio_packets ERROR [" + (string) av_err2str(error_code) + "]", "error_code", error_code, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_audio_packets ERROR [" + (string) av_err2str(error_code) + "]", "error_code", error_code); } } if (error_code < 0) { - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_audio_packets ERROR [" + (string) av_err2str(error_code) + "]", "error_code", error_code, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_audio_packets ERROR [" + (string) av_err2str(error_code) + "]", "error_code", error_code); } // deallocate AVFrame @@ -1828,7 +1827,7 @@ void FFmpegWriter::process_video_packet(std::shared_ptr frame) { // Fill with data AV_COPY_PICTURE_DATA(frame_source, (uint8_t *) pixels, PIX_FMT_RGBA, source_image_width, source_image_height); - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::process_video_packet", "frame->number", frame->number, "bytes_source", bytes_source, "bytes_final", bytes_final, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::process_video_packet", "frame->number", frame->number, "bytes_source", bytes_source, "bytes_final", bytes_final); // Resize & convert pixel format sws_scale(scaler, frame_source->data, frame_source->linesize, 0, @@ -1848,9 +1847,9 @@ void FFmpegWriter::process_video_packet(std::shared_ptr frame) { // write video frame bool FFmpegWriter::write_video_packet(std::shared_ptr frame, AVFrame *frame_final) { #if (LIBAVFORMAT_VERSION_MAJOR >= 58) - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_video_packet", "frame->number", frame->number, "oc->oformat->flags", oc->oformat->flags, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_video_packet", "frame->number", frame->number, "oc->oformat->flags", oc->oformat->flags); #else - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_video_packet", "frame->number", frame->number, "oc->oformat->flags & AVFMT_RAWPICTURE", oc->oformat->flags & AVFMT_RAWPICTURE, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_video_packet", "frame->number", frame->number, "oc->oformat->flags & AVFMT_RAWPICTURE", oc->oformat->flags & AVFMT_RAWPICTURE); if (oc->oformat->flags & AVFMT_RAWPICTURE) { // Raw video case. @@ -1869,7 +1868,7 @@ bool FFmpegWriter::write_video_packet(std::shared_ptr frame, AVFrame *fra /* write the compressed frame in the media file */ int error_code = av_interleaved_write_frame(oc, &pkt); if (error_code < 0) { - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_video_packet ERROR [" + (string) av_err2str(error_code) + "]", "error_code", error_code, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_video_packet ERROR [" + (string) av_err2str(error_code) + "]", "error_code", error_code); return false; } @@ -1927,7 +1926,7 @@ bool FFmpegWriter::write_video_packet(std::shared_ptr frame, AVFrame *fra } error_code = ret; if (ret < 0 ) { - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_video_packet (Frame not sent)", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_video_packet (Frame not sent)"); if (ret == AVERROR(EAGAIN) ) { cerr << "Frame EAGAIN" << "\n"; } @@ -2001,7 +2000,7 @@ bool FFmpegWriter::write_video_packet(std::shared_ptr frame, AVFrame *fra /* write the compressed frame in the media file */ int error_code = av_interleaved_write_frame(oc, &pkt); if (error_code < 0) { - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_video_packet ERROR [" + (string) av_err2str(error_code) + "]", "error_code", error_code, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_video_packet ERROR [" + (string) av_err2str(error_code) + "]", "error_code", error_code); return false; } } diff --git a/src/FrameMapper.cpp b/src/FrameMapper.cpp index 1f6b7629..e249ca42 100644 --- a/src/FrameMapper.cpp +++ b/src/FrameMapper.cpp @@ -99,7 +99,7 @@ void FrameMapper::AddField(Field field) // whether the frame rate is increasing or decreasing. void FrameMapper::Init() { - ZmqLogger::Instance()->AppendDebugMethod("FrameMapper::Init (Calculate frame mappings)", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FrameMapper::Init (Calculate frame mappings)"); // Do not initialize anything if just a picture with no audio if (info.has_video and !info.has_audio and info.has_single_image) @@ -342,7 +342,7 @@ MappedFrame FrameMapper::GetMappedFrame(int64_t TargetFrameNumber) TargetFrameNumber = frames.size(); // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FrameMapper::GetMappedFrame", "TargetFrameNumber", TargetFrameNumber, "frames.size()", frames.size(), "frames[...].Odd", frames[TargetFrameNumber - 1].Odd.Frame, "frames[...].Even", frames[TargetFrameNumber - 1].Even.Frame, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FrameMapper::GetMappedFrame", "TargetFrameNumber", TargetFrameNumber, "frames.size()", frames.size(), "frames[...].Odd", frames[TargetFrameNumber - 1].Odd.Frame, "frames[...].Even", frames[TargetFrameNumber - 1].Even.Frame); // Return frame return frames[TargetFrameNumber - 1]; @@ -358,7 +358,7 @@ std::shared_ptr FrameMapper::GetOrCreateFrame(int64_t number) try { // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FrameMapper::GetOrCreateFrame (from reader)", "number", number, "samples_in_frame", samples_in_frame, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FrameMapper::GetOrCreateFrame (from reader)", "number", number, "samples_in_frame", samples_in_frame); // Attempt to get a frame (but this could fail if a reader has just been closed) new_frame = reader->GetFrame(number); @@ -375,7 +375,7 @@ std::shared_ptr FrameMapper::GetOrCreateFrame(int64_t number) } // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FrameMapper::GetOrCreateFrame (create blank)", "number", number, "samples_in_frame", samples_in_frame, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FrameMapper::GetOrCreateFrame (create blank)", "number", number, "samples_in_frame", samples_in_frame); // Create blank frame new_frame = std::make_shared(number, info.width, info.height, "#000000", samples_in_frame, reader->info.channels); @@ -409,14 +409,14 @@ std::shared_ptr FrameMapper::GetFrame(int64_t requested_frame) int minimum_frames = 1; // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FrameMapper::GetFrame (Loop through frames)", "requested_frame", requested_frame, "minimum_frames", minimum_frames, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FrameMapper::GetFrame (Loop through frames)", "requested_frame", requested_frame, "minimum_frames", minimum_frames); // Loop through all requested frames for (int64_t frame_number = requested_frame; frame_number < requested_frame + minimum_frames; frame_number++) { // Debug output - ZmqLogger::Instance()->AppendDebugMethod("FrameMapper::GetFrame (inside omp for loop)", "frame_number", frame_number, "minimum_frames", minimum_frames, "requested_frame", requested_frame, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FrameMapper::GetFrame (inside omp for loop)", "frame_number", frame_number, "minimum_frames", minimum_frames, "requested_frame", requested_frame); // Get the mapped frame MappedFrame mapped = GetMappedFrame(frame_number); @@ -634,7 +634,7 @@ void FrameMapper::Open() { if (reader) { - ZmqLogger::Instance()->AppendDebugMethod("FrameMapper::Open", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FrameMapper::Open"); // Open the reader reader->Open(); @@ -649,7 +649,7 @@ void FrameMapper::Close() // Create a scoped lock, allowing only a single thread to run the following code at one time const GenericScopedLock lock(getFrameCriticalSection); - ZmqLogger::Instance()->AppendDebugMethod("FrameMapper::Close", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FrameMapper::Close"); // Close internal reader reader->Close(); @@ -782,7 +782,7 @@ void FrameMapper::ResampleMappedAudio(std::shared_ptr frame, int64_t orig int samples_in_frame = frame->GetAudioSamplesCount(); ChannelLayout channel_layout_in_frame = frame->ChannelsLayout(); - ZmqLogger::Instance()->AppendDebugMethod("FrameMapper::ResampleMappedAudio", "frame->number", frame->number, "original_frame_number", original_frame_number, "channels_in_frame", channels_in_frame, "samples_in_frame", samples_in_frame, "sample_rate_in_frame", sample_rate_in_frame, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FrameMapper::ResampleMappedAudio", "frame->number", frame->number, "original_frame_number", original_frame_number, "channels_in_frame", channels_in_frame, "samples_in_frame", samples_in_frame, "sample_rate_in_frame", sample_rate_in_frame); // Get audio sample array float* frame_samples_float = NULL; @@ -818,7 +818,7 @@ void FrameMapper::ResampleMappedAudio(std::shared_ptr frame, int64_t orig if (error_code < 0) { - ZmqLogger::Instance()->AppendDebugMethod("FrameMapper::ResampleMappedAudio ERROR [" + (string)av_err2str(error_code) + "]", "error_code", error_code, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FrameMapper::ResampleMappedAudio ERROR [" + (string)av_err2str(error_code) + "]", "error_code", error_code); throw ErrorEncodingVideo("Error while resampling audio in frame mapper", frame->number); } @@ -917,7 +917,7 @@ void FrameMapper::ResampleMappedAudio(std::shared_ptr frame, int64_t orig // Add samples to frame for this channel frame->AddAudio(true, channel_filter, 0, channel_buffer, position, 1.0f); - ZmqLogger::Instance()->AppendDebugMethod("FrameMapper::ResampleMappedAudio (Add audio to channel)", "number of samples", position, "channel_filter", channel_filter, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FrameMapper::ResampleMappedAudio (Add audio to channel)", "number of samples", position, "channel_filter", channel_filter); } // Update frame's audio meta data diff --git a/src/ImageWriter.cpp b/src/ImageWriter.cpp index e0b7a5b6..2b1e3fc0 100644 --- a/src/ImageWriter.cpp +++ b/src/ImageWriter.cpp @@ -128,7 +128,7 @@ void ImageWriter::WriteFrame(std::shared_ptr frame) // Write a block of frames from a reader void ImageWriter::WriteFrame(ReaderBase* reader, int64_t start, int64_t length) { - ZmqLogger::Instance()->AppendDebugMethod("ImageWriter::WriteFrame (from Reader)", "start", start, "length", length, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("ImageWriter::WriteFrame (from Reader)", "start", start, "length", length); // Loop through each frame (and encoded it) for (int64_t number = start; number <= length; number++) @@ -156,7 +156,7 @@ void ImageWriter::Close() // Close writer is_open = false; - ZmqLogger::Instance()->AppendDebugMethod("ImageWriter::Close", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("ImageWriter::Close"); } #endif //USE_IMAGEMAGICK diff --git a/src/Timeline.cpp b/src/Timeline.cpp index 7636de7d..7967b86e 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -194,7 +194,7 @@ double Timeline::calculate_time(int64_t number, Fraction rate) std::shared_ptr Timeline::apply_effects(std::shared_ptr frame, int64_t timeline_frame_number, int layer) { // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::apply_effects", "frame->number", frame->number, "timeline_frame_number", timeline_frame_number, "layer", layer, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::apply_effects", "frame->number", frame->number, "timeline_frame_number", timeline_frame_number, "layer", layer); // Find Effects at this position and layer list::iterator effect_itr; @@ -210,7 +210,7 @@ std::shared_ptr Timeline::apply_effects(std::shared_ptr frame, int bool does_effect_intersect = (effect_start_position <= timeline_frame_number && effect_end_position >= timeline_frame_number && effect->Layer() == layer); // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::apply_effects (Does effect intersect)", "effect->Position()", effect->Position(), "does_effect_intersect", does_effect_intersect, "timeline_frame_number", timeline_frame_number, "layer", layer, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::apply_effects (Does effect intersect)", "effect->Position()", effect->Position(), "does_effect_intersect", does_effect_intersect, "timeline_frame_number", timeline_frame_number, "layer", layer); // Clip is visible if (does_effect_intersect) @@ -220,7 +220,7 @@ std::shared_ptr Timeline::apply_effects(std::shared_ptr frame, int long effect_frame_number = timeline_frame_number - effect_start_position + effect_start_frame; // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::apply_effects (Process Effect)", "effect_frame_number", effect_frame_number, "does_effect_intersect", does_effect_intersect, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::apply_effects (Process Effect)", "effect_frame_number", effect_frame_number, "does_effect_intersect", does_effect_intersect); // Apply the effect to this frame frame = effect->GetFrame(frame, effect_frame_number); @@ -242,7 +242,7 @@ std::shared_ptr Timeline::GetOrCreateFrame(Clip* clip, int64_t number) try { // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetOrCreateFrame (from reader)", "number", number, "samples_in_frame", samples_in_frame, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetOrCreateFrame (from reader)", "number", number, "samples_in_frame", samples_in_frame); // Attempt to get a frame (but this could fail if a reader has just been closed) #pragma omp critical (T_GetOtCreateFrame) @@ -260,7 +260,7 @@ std::shared_ptr Timeline::GetOrCreateFrame(Clip* clip, int64_t number) } // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetOrCreateFrame (create blank)", "number", number, "samples_in_frame", samples_in_frame, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetOrCreateFrame (create blank)", "number", number, "samples_in_frame", samples_in_frame); // Create blank frame new_frame = std::make_shared(number, Settings::Instance()->MAX_WIDTH, Settings::Instance()->MAX_HEIGHT, "#000000", samples_in_frame, info.channels); @@ -285,13 +285,13 @@ void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, in return; // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer", "new_frame->number", new_frame->number, "clip_frame_number", clip_frame_number, "timeline_frame_number", timeline_frame_number, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer", "new_frame->number", new_frame->number, "clip_frame_number", clip_frame_number, "timeline_frame_number", timeline_frame_number); /* REPLACE IMAGE WITH WAVEFORM IMAGE (IF NEEDED) */ if (source_clip->Waveform()) { // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Generate Waveform Image)", "source_frame->number", source_frame->number, "source_clip->Waveform()", source_clip->Waveform(), "clip_frame_number", clip_frame_number, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Generate Waveform Image)", "source_frame->number", source_frame->number, "source_clip->Waveform()", source_clip->Waveform(), "clip_frame_number", clip_frame_number); // Get the color of the waveform int red = source_clip->wave_color.red.GetInt(clip_frame_number); @@ -319,7 +319,7 @@ void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, in /* COPY AUDIO - with correct volume */ if (source_clip->Reader()->info.has_audio) { // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Copy Audio)", "source_clip->Reader()->info.has_audio", source_clip->Reader()->info.has_audio, "source_frame->GetAudioChannelsCount()", source_frame->GetAudioChannelsCount(), "info.channels", info.channels, "clip_frame_number", clip_frame_number, "timeline_frame_number", timeline_frame_number, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Copy Audio)", "source_clip->Reader()->info.has_audio", source_clip->Reader()->info.has_audio, "source_frame->GetAudioChannelsCount()", source_frame->GetAudioChannelsCount(), "info.channels", info.channels, "clip_frame_number", clip_frame_number, "timeline_frame_number", timeline_frame_number); if (source_frame->GetAudioChannelsCount() == info.channels && source_clip->has_audio.GetInt(clip_frame_number) != 0) for (int channel = 0; channel < source_frame->GetAudioChannelsCount(); channel++) @@ -375,7 +375,7 @@ void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, in } else // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (No Audio Copied - Wrong # of Channels)", "source_clip->Reader()->info.has_audio", source_clip->Reader()->info.has_audio, "source_frame->GetAudioChannelsCount()", source_frame->GetAudioChannelsCount(), "info.channels", info.channels, "clip_frame_number", clip_frame_number, "timeline_frame_number", timeline_frame_number, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (No Audio Copied - Wrong # of Channels)", "source_clip->Reader()->info.has_audio", source_clip->Reader()->info.has_audio, "source_frame->GetAudioChannelsCount()", source_frame->GetAudioChannelsCount(), "info.channels", info.channels, "clip_frame_number", clip_frame_number, "timeline_frame_number", timeline_frame_number); } @@ -385,7 +385,7 @@ void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, in return; // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Get Source Image)", "source_frame->number", source_frame->number, "source_clip->Waveform()", source_clip->Waveform(), "clip_frame_number", clip_frame_number, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Get Source Image)", "source_frame->number", source_frame->number, "source_clip->Waveform()", source_clip->Waveform(), "clip_frame_number", clip_frame_number); // Get actual frame image data source_image = source_frame->GetImage(); @@ -409,7 +409,7 @@ void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, in } // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Set Alpha & Opacity)", "alpha", alpha, "source_frame->number", source_frame->number, "clip_frame_number", clip_frame_number, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Set Alpha & Opacity)", "alpha", alpha, "source_frame->number", source_frame->number, "clip_frame_number", clip_frame_number); } /* RESIZE SOURCE IMAGE - based on scale type */ @@ -421,7 +421,7 @@ void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, in source_size.scale(Settings::Instance()->MAX_WIDTH, Settings::Instance()->MAX_HEIGHT, Qt::KeepAspectRatio); // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Scale: SCALE_FIT)", "source_frame->number", source_frame->number, "source_width", source_size.width(), "source_height", source_size.height(), "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Scale: SCALE_FIT)", "source_frame->number", source_frame->number, "source_width", source_size.width(), "source_height", source_size.height()); break; } case (SCALE_STRETCH): { @@ -429,7 +429,7 @@ void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, in source_size.scale(Settings::Instance()->MAX_WIDTH, Settings::Instance()->MAX_HEIGHT, Qt::IgnoreAspectRatio); // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Scale: SCALE_STRETCH)", "source_frame->number", source_frame->number, "source_width", source_size.width(), "source_height", source_size.height(), "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Scale: SCALE_STRETCH)", "source_frame->number", source_frame->number, "source_width", source_size.width(), "source_height", source_size.height()); break; } case (SCALE_CROP): { @@ -443,7 +443,7 @@ void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, in source_size.scale(height_size.width(), height_size.height(), Qt::KeepAspectRatio); // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Scale: SCALE_CROP)", "source_frame->number", source_frame->number, "source_width", source_size.width(), "source_height", source_size.height(), "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Scale: SCALE_CROP)", "source_frame->number", source_frame->number, "source_width", source_size.width(), "source_height", source_size.height()); break; } case (SCALE_NONE): { @@ -455,7 +455,7 @@ void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, in source_size.scale(Settings::Instance()->MAX_WIDTH * source_width_ratio, Settings::Instance()->MAX_HEIGHT * source_height_ratio, Qt::KeepAspectRatio); // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Scale: SCALE_NONE)", "source_frame->number", source_frame->number, "source_width", source_size.width(), "source_height", source_size.height(), "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Scale: SCALE_NONE)", "source_frame->number", source_frame->number, "source_width", source_size.width(), "source_height", source_size.height()); break; } } @@ -587,7 +587,7 @@ void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, in } // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Transform: Composite Image Layer: Prepare)", "source_frame->number", source_frame->number, "new_frame->GetImage()->width()", new_frame->GetImage()->width(), "transformed", transformed, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Transform: Composite Image Layer: Prepare)", "source_frame->number", source_frame->number, "new_frame->GetImage()->width()", new_frame->GetImage()->width(), "transformed", transformed); /* COMPOSITE SOURCE IMAGE (LAYER) ONTO FINAL IMAGE */ std::shared_ptr new_image; @@ -632,13 +632,13 @@ void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, in painter.end(); // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Transform: Composite Image Layer: Completed)", "source_frame->number", source_frame->number, "new_frame->GetImage()->width()", new_frame->GetImage()->width(), "transformed", transformed, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Transform: Composite Image Layer: Completed)", "source_frame->number", source_frame->number, "new_frame->GetImage()->width()", new_frame->GetImage()->width(), "transformed", transformed); } // Update the list of 'opened' clips void Timeline::update_open_clips(Clip *clip, bool does_clip_intersect) { - ZmqLogger::Instance()->AppendDebugMethod("Timeline::update_open_clips (before)", "does_clip_intersect", does_clip_intersect, "closing_clips.size()", closing_clips.size(), "open_clips.size()", open_clips.size(), "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::update_open_clips (before)", "does_clip_intersect", does_clip_intersect, "closing_clips.size()", closing_clips.size(), "open_clips.size()", open_clips.size()); // is clip already in list? bool clip_found = open_clips.count(clip); @@ -666,14 +666,14 @@ void Timeline::update_open_clips(Clip *clip, bool does_clip_intersect) } // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::update_open_clips (after)", "does_clip_intersect", does_clip_intersect, "clip_found", clip_found, "closing_clips.size()", closing_clips.size(), "open_clips.size()", open_clips.size(), "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::update_open_clips (after)", "does_clip_intersect", does_clip_intersect, "clip_found", clip_found, "closing_clips.size()", closing_clips.size(), "open_clips.size()", open_clips.size()); } // Sort clips by position on the timeline void Timeline::sort_clips() { // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::SortClips", "clips.size()", clips.size(), "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::SortClips", "clips.size()", clips.size()); // sort clips clips.sort(CompareClips()); @@ -689,7 +689,7 @@ void Timeline::sort_effects() // Close the reader (and any resources it was consuming) void Timeline::Close() { - ZmqLogger::Instance()->AppendDebugMethod("Timeline::Close", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::Close"); // Close all open clips list::iterator clip_itr; @@ -734,7 +734,7 @@ std::shared_ptr Timeline::GetFrame(int64_t requested_frame) frame = final_cache->GetFrame(requested_frame); if (frame) { // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetFrame (Cached frame found)", "requested_frame", requested_frame, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetFrame (Cached frame found)", "requested_frame", requested_frame); // Return cached frame return frame; @@ -753,7 +753,7 @@ std::shared_ptr Timeline::GetFrame(int64_t requested_frame) frame = final_cache->GetFrame(requested_frame); if (frame) { // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetFrame (Cached frame found on 2nd look)", "requested_frame", requested_frame, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetFrame (Cached frame found on 2nd look)", "requested_frame", requested_frame); // Return cached frame return frame; @@ -773,7 +773,7 @@ std::shared_ptr Timeline::GetFrame(int64_t requested_frame) omp_set_nested(true); // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetFrame", "requested_frame", requested_frame, "minimum_frames", minimum_frames, "OPEN_MP_NUM_PROCESSORS", OPEN_MP_NUM_PROCESSORS, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetFrame", "requested_frame", requested_frame, "minimum_frames", minimum_frames, "OPEN_MP_NUM_PROCESSORS", OPEN_MP_NUM_PROCESSORS); // GENERATE CACHE FOR CLIPS (IN FRAME # SEQUENCE) // Determine all clip frames, and request them in order (to keep resampled audio in sequence) @@ -806,7 +806,7 @@ std::shared_ptr Timeline::GetFrame(int64_t requested_frame) for (int64_t frame_number = requested_frame; frame_number < requested_frame + minimum_frames; frame_number++) { // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetFrame (processing frame)", "frame_number", frame_number, "omp_get_thread_num()", omp_get_thread_num(), "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetFrame (processing frame)", "frame_number", frame_number, "omp_get_thread_num()", omp_get_thread_num()); // Init some basic properties about this frame int samples_in_frame = Frame::GetSamplesPerFrame(frame_number, info.fps, info.sample_rate, info.channels); @@ -821,7 +821,7 @@ std::shared_ptr Timeline::GetFrame(int64_t requested_frame) } // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetFrame (Adding solid color)", "frame_number", frame_number, "info.width", info.width, "info.height", info.height, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetFrame (Adding solid color)", "frame_number", frame_number, "info.width", info.width, "info.height", info.height); // Add Background Color to 1st layer (if animated or not black) if ((color.red.Points.size() > 1 || color.green.Points.size() > 1 || color.blue.Points.size() > 1) || @@ -829,7 +829,7 @@ std::shared_ptr Timeline::GetFrame(int64_t requested_frame) new_frame->AddColor(Settings::Instance()->MAX_WIDTH, Settings::Instance()->MAX_HEIGHT, color.GetColorHex(frame_number)); // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetFrame (Loop through clips)", "frame_number", frame_number, "clips.size()", clips.size(), "nearby_clips.size()", nearby_clips.size(), "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetFrame (Loop through clips)", "frame_number", frame_number, "clips.size()", clips.size(), "nearby_clips.size()", nearby_clips.size()); // Find Clips near this time for (int clip_index = 0; clip_index < nearby_clips.size(); clip_index++) @@ -842,7 +842,7 @@ std::shared_ptr Timeline::GetFrame(int64_t requested_frame) bool does_clip_intersect = (clip_start_position <= frame_number && clip_end_position >= frame_number); // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetFrame (Does clip intersect)", "frame_number", frame_number, "clip->Position()", clip->Position(), "clip->Duration()", clip->Duration(), "does_clip_intersect", does_clip_intersect, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetFrame (Does clip intersect)", "frame_number", frame_number, "clip->Position()", clip->Position(), "clip->Duration()", clip->Duration(), "does_clip_intersect", does_clip_intersect); // Clip is visible if (does_clip_intersect) @@ -878,19 +878,19 @@ std::shared_ptr Timeline::GetFrame(int64_t requested_frame) long clip_frame_number = frame_number - clip_start_position + clip_start_frame; // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetFrame (Calculate clip's frame #)", "clip->Position()", clip->Position(), "clip->Start()", clip->Start(), "info.fps.ToFloat()", info.fps.ToFloat(), "clip_frame_number", clip_frame_number, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetFrame (Calculate clip's frame #)", "clip->Position()", clip->Position(), "clip->Start()", clip->Start(), "info.fps.ToFloat()", info.fps.ToFloat(), "clip_frame_number", clip_frame_number); // Add clip's frame as layer add_layer(new_frame, clip, clip_frame_number, frame_number, is_top_clip, max_volume); } else // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetFrame (clip does not intersect)", "frame_number", frame_number, "does_clip_intersect", does_clip_intersect, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetFrame (clip does not intersect)", "frame_number", frame_number, "does_clip_intersect", does_clip_intersect); } // end clip loop // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetFrame (Add frame to cache)", "frame_number", frame_number, "info.width", info.width, "info.height", info.height, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetFrame (Add frame to cache)", "frame_number", frame_number, "info.width", info.width, "info.height", info.height); // Set frame # on mapped frame #pragma omp ordered @@ -905,7 +905,7 @@ std::shared_ptr Timeline::GetFrame(int64_t requested_frame) } // end parallel // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetFrame (end parallel region)", "requested_frame", requested_frame, "omp_get_thread_num()", omp_get_thread_num(), "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetFrame (end parallel region)", "requested_frame", requested_frame, "omp_get_thread_num()", omp_get_thread_num()); // Return frame (or blank frame) return final_cache->GetFrame(requested_frame); @@ -942,7 +942,7 @@ vector Timeline::find_intersecting_clips(int64_t requested_frame, int num (clip_end_position >= min_requested_frame || clip_end_position >= max_requested_frame); // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Timeline::find_intersecting_clips (Is clip near or intersecting)", "requested_frame", requested_frame, "min_requested_frame", min_requested_frame, "max_requested_frame", max_requested_frame, "clip->Position()", clip->Position(), "does_clip_intersect", does_clip_intersect, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Timeline::find_intersecting_clips (Is clip near or intersecting)", "requested_frame", requested_frame, "min_requested_frame", min_requested_frame, "max_requested_frame", max_requested_frame, "clip->Position()", clip->Position(), "does_clip_intersect", does_clip_intersect); // Open (or schedule for closing) this clip, based on if it's intersecting or not #pragma omp critical (reader_lock) From e1ffe0762ff01090457284252c1d0078e96b99f4 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Wed, 3 Jul 2019 15:24:45 -0400 Subject: [PATCH 16/43] ZmqLogger.h: Correct default values for optional params --- include/ZmqLogger.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/ZmqLogger.h b/include/ZmqLogger.h index ba9a3370..2dc1a0cb 100644 --- a/include/ZmqLogger.h +++ b/include/ZmqLogger.h @@ -95,12 +95,12 @@ namespace openshot { /// Append debug information void AppendDebugMethod(std::string method_name, - std::string arg1_name="", float arg1_value=-0.0, - std::string arg2_name="", float arg2_value=-0.0, - std::string arg3_name="", float arg3_value=-0.0, - std::string arg4_name="", float arg4_value=-0.0, - std::string arg5_name="", float arg5_value=-0.0, - std::string arg6_name="", float arg6_value=-0.0); + std::string arg1_name="", float arg1_value=-1.0, + std::string arg2_name="", float arg2_value=-1.0, + std::string arg3_name="", float arg3_value=-1.0, + std::string arg4_name="", float arg4_value=-1.0, + std::string arg5_name="", float arg5_value=-1.0, + std::string arg6_name="", float arg6_value=-1.0); /// Close logger (sockets and/or files) void Close(); From 35772809c703468064a3ae2771d4dbbfc9b5d0ce Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sat, 6 Jul 2019 03:14:09 -0400 Subject: [PATCH 17/43] Exclude all build* files/directories @ root level I tend to create multiple build paths at the root of the project, for testing various configurations. So I'll have all of `build/`, `build-somebranch`, `build-otherbranch`, etc. sitting around. This PR updates the `.gitignore` for the repo to exclude `/build*`, meaning _anything_ with a name that starts with `build`, if it's located at the root of the repository tree. --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 022991be..c02a2fb9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ -build/ -build/* +/build* *.DS_Store .pydevproject .settings From fd79eba6fcc14adf4f7526f0de9bb83f6230c314 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sun, 7 Jul 2019 16:24:11 -0400 Subject: [PATCH 18/43] Install docs in DOCDIR/API, if built Running `make install` AFTER `make doc` will pick up the generated Doxygen output an install it into `${CMAKE_INSTALL_DOCDIR}/API`, which is `${CMAKE_INSTALL_PREFIX}/share/doc/libopenshot/API` on most systems. --- CMakeLists.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c468ae0..d4e658f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,4 +98,13 @@ add_subdirectory(tests) ################### DOCUMENTATION ################### # Find Doxygen (used for documentation) -include(cmake/Modules/UseDoxygen.cmake) \ No newline at end of file +include(cmake/Modules/UseDoxygen.cmake) + +# Install docs, if the user builds them with `make doc` +install(CODE "MESSAGE(\"Checking for documentation files to install...\")") +install(CODE "MESSAGE(\"(Compile with 'make doc' command, requires Doxygen)\")") + +install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/html/ + DESTINATION ${CMAKE_INSTALL_DOCDIR}/API + MESSAGE_NEVER # Don't spew about file copies + OPTIONAL ) # No error if the docs aren't found From a4cc1197170acd54bc6c789e81613c90f64ad729 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Tue, 9 Jul 2019 15:23:52 -0500 Subject: [PATCH 19/43] Fix SVG render size for Resvg (breaking common transitions) --- src/QtImageReader.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/QtImageReader.cpp b/src/QtImageReader.cpp index bd1c4bc8..3a385fec 100644 --- a/src/QtImageReader.cpp +++ b/src/QtImageReader.cpp @@ -229,10 +229,15 @@ std::shared_ptr QtImageReader::GetFrame(int64_t requested_frame) path.find(".svgz") != std::string::npos) { ResvgRenderer renderer(QString::fromStdString(path)); if (renderer.isValid()) { + // Scale SVG size to keep aspect ratio, and fill the max_size as best as possible + QSize svg_size(renderer.defaultSize().width(), renderer.defaultSize().height()); + svg_size.scale(max_width, max_height, Qt::KeepAspectRatio); - cached_image = std::shared_ptr(new QImage(QSize(max_width, max_height), QImage::Format_RGBA8888)); + // Create empty QImage + cached_image = std::shared_ptr(new QImage(QSize(svg_size.width(), svg_size.height()), QImage::Format_RGBA8888)); cached_image->fill(Qt::transparent); + // Render SVG into QImage QPainter p(cached_image.get()); renderer.render(&p); p.end(); From 9806694e1362d49eb08c525aee539f68ee4767e0 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Tue, 9 Jul 2019 15:48:46 -0500 Subject: [PATCH 20/43] Fix crash caused by resvg failing to parse SVG (when Qt can still parse things fine) --- src/QtImageReader.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/QtImageReader.cpp b/src/QtImageReader.cpp index 3a385fec..af12add4 100644 --- a/src/QtImageReader.cpp +++ b/src/QtImageReader.cpp @@ -77,12 +77,15 @@ void QtImageReader::Open() // If defined and found in CMake, utilize the libresvg for parsing // SVG files and rasterizing them to QImages. // Only use resvg for files ending in '.svg' or '.svgz' - if (path.find(".svg") != std::string::npos || - path.find(".svgz") != std::string::npos) { + if (path.find(".svg") != std::string::npos || path.find(".svgz") != std::string::npos) { ResvgRenderer renderer(QString::fromStdString(path)); if (!renderer.isValid()) { - success = false; + // Attempt to open file (old method using Qt5 limited SVG parsing) + success = image->load(QString::fromStdString(path)); + if (success) { + image = std::shared_ptr(new QImage(image->convertToFormat(QImage::Format_RGBA8888))); + } } else { image = std::shared_ptr(new QImage(renderer.defaultSize(), QImage::Format_RGBA8888)); @@ -225,8 +228,7 @@ std::shared_ptr QtImageReader::GetFrame(int64_t requested_frame) // If defined and found in CMake, utilize the libresvg for parsing // SVG files and rasterizing them to QImages. // Only use resvg for files ending in '.svg' or '.svgz' - if (path.find(".svg") != std::string::npos || - path.find(".svgz") != std::string::npos) { + if (path.find(".svg") != std::string::npos || path.find(".svgz") != std::string::npos) { ResvgRenderer renderer(QString::fromStdString(path)); if (renderer.isValid()) { // Scale SVG size to keep aspect ratio, and fill the max_size as best as possible @@ -241,6 +243,10 @@ std::shared_ptr QtImageReader::GetFrame(int64_t requested_frame) QPainter p(cached_image.get()); renderer.render(&p); p.end(); + } else { + // Resize current rasterized SVG (since we failed to parse original SVG file with resvg) + cached_image = std::shared_ptr(new QImage(image->scaled(max_width, max_height, Qt::KeepAspectRatio, Qt::SmoothTransformation))); + cached_image = std::shared_ptr(new QImage(cached_image->convertToFormat(QImage::Format_RGBA8888))); } } else { // We need to resize the original image to a smaller image (for performance reasons) From 86e610bfc8069b0c7634e03c73a126972c2f5a2a Mon Sep 17 00:00:00 2001 From: Frank Dana Date: Wed, 10 Jul 2019 04:48:31 -0400 Subject: [PATCH 21/43] Fix parameter documentation for brightness MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The range was listed as 0 – 100, but implemented as -1 – +1. Edited documentation to reflect reality. Reported by @jeffski like a year and a half ago. Fixes #71 --- include/effects/Brightness.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/effects/Brightness.h b/include/effects/Brightness.h index fd43f784..eb33d338 100644 --- a/include/effects/Brightness.h +++ b/include/effects/Brightness.h @@ -75,8 +75,8 @@ namespace openshot /// Default constructor, which takes 2 curves. The curves adjust the brightness and // contrast of a frame's image. /// - /// @param new_brightness The curve to adjust the brightness (between 100 and -100) - /// @param new_contrast The curve to adjust the contrast (3 is typical, 20 is a lot, 0 is invalid) + /// @param new_brightness The curve to adjust the brightness (from -1 to +1, 0 is default/"off") + /// @param new_contrast The curve to adjust the contrast (3 is typical, 20 is a lot, 100 is max. 0 is invalid) Brightness(Keyframe new_brightness, Keyframe new_contrast); /// @brief This method is required for all derived classes of EffectBase, and returns a From 35eb6adc555726e152903e5cc55dd88d3bd460c3 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Thu, 11 Jul 2019 05:00:47 -0400 Subject: [PATCH 22/43] Clean up allocated memory in JSON code --- src/CacheDisk.cpp | 6 +++++- src/CacheMemory.cpp | 4 +++- src/ChunkReader.cpp | 3 ++- src/Clip.cpp | 4 +++- src/Color.cpp | 2 ++ src/Coordinate.cpp | 4 +++- src/DecklinkReader.cpp | 4 +++- src/DummyReader.cpp | 4 +++- src/EffectBase.cpp | 4 +++- src/FFmpegReader.cpp | 2 ++ src/FrameMapper.cpp | 4 +++- src/ImageReader.cpp | 2 ++ src/KeyFrame.cpp | 4 +++- src/Point.cpp | 4 +++- src/Profiles.cpp | 4 +++- src/QtImageReader.cpp | 4 +++- src/TextReader.cpp | 4 +++- src/Timeline.cpp | 8 ++++++-- src/WriterBase.cpp | 4 +++- src/effects/Bars.cpp | 5 +++-- src/effects/Blur.cpp | 5 +++-- src/effects/Brightness.cpp | 5 +++-- src/effects/ChromaKey.cpp | 4 +++- src/effects/ColorShift.cpp | 5 +++-- src/effects/Crop.cpp | 2 ++ src/effects/Deinterlace.cpp | 4 +++- src/effects/Hue.cpp | 5 +++-- src/effects/Mask.cpp | 4 +++- src/effects/Negate.cpp | 4 +++- src/effects/Pixelate.cpp | 5 +++-- src/effects/Saturation.cpp | 5 +++-- src/effects/Shift.cpp | 5 +++-- src/effects/Wave.cpp | 5 +++-- tests/Clip_Tests.cpp | 4 ++++ 34 files changed, 103 insertions(+), 39 deletions(-) diff --git a/src/CacheDisk.cpp b/src/CacheDisk.cpp index 4d446746..ee80c21f 100644 --- a/src/CacheDisk.cpp +++ b/src/CacheDisk.cpp @@ -495,6 +495,8 @@ Json::Value CacheDisk::JsonValue() { string errors; bool success = reader->parse( json_ranges.c_str(), json_ranges.c_str() + json_ranges.size(), &ranges, &errors ); + delete reader; + if (success) root["ranges"] = ranges; @@ -512,7 +514,9 @@ void CacheDisk::SetJson(string value) { string errors; bool success = reader->parse( value.c_str(), - value.c_str() + value.size(), &root, &errors ); + value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); diff --git a/src/CacheMemory.cpp b/src/CacheMemory.cpp index 4de6bb1f..fd1af22f 100644 --- a/src/CacheMemory.cpp +++ b/src/CacheMemory.cpp @@ -345,10 +345,11 @@ Json::Value CacheMemory::JsonValue() { Json::Value ranges; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - + string errors; bool success = reader->parse( json_ranges.c_str(), json_ranges.c_str() + json_ranges.size(), &ranges, &errors ); + delete reader; if (success) root["ranges"] = ranges; @@ -368,6 +369,7 @@ void CacheMemory::SetJson(string value) { string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); diff --git a/src/ChunkReader.cpp b/src/ChunkReader.cpp index 8d5b466e..170808e2 100644 --- a/src/ChunkReader.cpp +++ b/src/ChunkReader.cpp @@ -285,10 +285,11 @@ void ChunkReader::SetJson(string value) { Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - + string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); diff --git a/src/Clip.cpp b/src/Clip.cpp index bddcd0c9..8f72ffb8 100644 --- a/src/Clip.cpp +++ b/src/Clip.cpp @@ -796,10 +796,12 @@ void Clip::SetJson(string value) { Json::Value root; Json::CharReaderBuilder rbuilder; Json::CharReader* reader(rbuilder.newCharReader()); - + string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); diff --git a/src/Color.cpp b/src/Color.cpp index 21c3f146..0736eb63 100644 --- a/src/Color.cpp +++ b/src/Color.cpp @@ -116,6 +116,8 @@ void Color::SetJson(string value) { string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); diff --git a/src/Coordinate.cpp b/src/Coordinate.cpp index 5baeb5bf..a2f40e46 100644 --- a/src/Coordinate.cpp +++ b/src/Coordinate.cpp @@ -77,8 +77,10 @@ void Coordinate::SetJson(string value) { Json::CharReader* reader(rbuilder.newCharReader()); string errors; - bool success = reader->parse( value.c_str(), + bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); diff --git a/src/DecklinkReader.cpp b/src/DecklinkReader.cpp index 230a6689..21e20b1f 100644 --- a/src/DecklinkReader.cpp +++ b/src/DecklinkReader.cpp @@ -272,8 +272,10 @@ void DecklinkReader::SetJson(string value) { Json::CharReader* reader(rbuilder.newCharReader()); string errors; - bool success = reader->parse( value.c_str(), + bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); diff --git a/src/DummyReader.cpp b/src/DummyReader.cpp index aa1e6a56..3c66e9e0 100644 --- a/src/DummyReader.cpp +++ b/src/DummyReader.cpp @@ -150,8 +150,10 @@ void DummyReader::SetJson(string value) { Json::CharReader* reader(rbuilder.newCharReader()); string errors; - bool success = reader->parse( value.c_str(), + bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); diff --git a/src/EffectBase.cpp b/src/EffectBase.cpp index 9bf30986..f9f8623b 100644 --- a/src/EffectBase.cpp +++ b/src/EffectBase.cpp @@ -106,8 +106,10 @@ void EffectBase::SetJson(string value) { Json::CharReader* reader(rbuilder.newCharReader()); string errors; - bool success = reader->parse( value.c_str(), + bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); diff --git a/src/FFmpegReader.cpp b/src/FFmpegReader.cpp index 10d89051..40e29e03 100644 --- a/src/FFmpegReader.cpp +++ b/src/FFmpegReader.cpp @@ -2431,6 +2431,8 @@ void FFmpegReader::SetJson(string value) { string errors; bool success = reader->parse(value.c_str(), value.c_str() + value.size(), &root, &errors); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); diff --git a/src/FrameMapper.cpp b/src/FrameMapper.cpp index 1f6b7629..8d362381 100644 --- a/src/FrameMapper.cpp +++ b/src/FrameMapper.cpp @@ -701,8 +701,10 @@ void FrameMapper::SetJson(string value) { Json::CharReader* reader(rbuilder.newCharReader()); string errors; - bool success = reader->parse( value.c_str(), + bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); diff --git a/src/ImageReader.cpp b/src/ImageReader.cpp index 62439d82..bafe76fe 100644 --- a/src/ImageReader.cpp +++ b/src/ImageReader.cpp @@ -165,6 +165,8 @@ void ImageReader::SetJson(string value) { string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); diff --git a/src/KeyFrame.cpp b/src/KeyFrame.cpp index 31393d17..5c79fe27 100644 --- a/src/KeyFrame.cpp +++ b/src/KeyFrame.cpp @@ -373,8 +373,10 @@ void Keyframe::SetJson(string value) { Json::CharReader* reader(rbuilder.newCharReader()); string errors; - bool success = reader->parse( value.c_str(), + bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); diff --git a/src/Point.cpp b/src/Point.cpp index b0e85658..23b0159a 100644 --- a/src/Point.cpp +++ b/src/Point.cpp @@ -140,8 +140,10 @@ void Point::SetJson(string value) { Json::CharReader* reader(rbuilder.newCharReader()); string errors; - bool success = reader->parse( value.c_str(), + bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); diff --git a/src/Profiles.cpp b/src/Profiles.cpp index 9c2b3014..fec06cfa 100644 --- a/src/Profiles.cpp +++ b/src/Profiles.cpp @@ -171,8 +171,10 @@ void Profile::SetJson(string value) { Json::CharReader* reader(rbuilder.newCharReader()); string errors; - bool success = reader->parse( value.c_str(), + bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); diff --git a/src/QtImageReader.cpp b/src/QtImageReader.cpp index af12add4..a291ac92 100644 --- a/src/QtImageReader.cpp +++ b/src/QtImageReader.cpp @@ -304,8 +304,10 @@ void QtImageReader::SetJson(string value) { Json::CharReader* reader(rbuilder.newCharReader()); string errors; - bool success = reader->parse( value.c_str(), + bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); diff --git a/src/TextReader.cpp b/src/TextReader.cpp index 9c664535..9cb75881 100644 --- a/src/TextReader.cpp +++ b/src/TextReader.cpp @@ -224,8 +224,10 @@ void TextReader::SetJson(string value) { Json::CharReader* reader(rbuilder.newCharReader()); string errors; - bool success = reader->parse( value.c_str(), + bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); diff --git a/src/Timeline.cpp b/src/Timeline.cpp index 7636de7d..16ae2f6c 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -1034,8 +1034,10 @@ void Timeline::SetJson(string value) { Json::CharReader* reader(rbuilder.newCharReader()); string errors; - bool success = reader->parse( value.c_str(), + bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); @@ -1131,8 +1133,10 @@ void Timeline::ApplyJsonDiff(string value) { Json::CharReader* reader(rbuilder.newCharReader()); string errors; - bool success = reader->parse( value.c_str(), + bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success || !root.isArray()) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid).", ""); diff --git a/src/WriterBase.cpp b/src/WriterBase.cpp index bc16e7e0..729f52e8 100644 --- a/src/WriterBase.cpp +++ b/src/WriterBase.cpp @@ -203,8 +203,10 @@ void WriterBase::SetJson(string value) { Json::CharReader* reader(rbuilder.newCharReader()); string errors; - bool success = reader->parse( value.c_str(), + bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); diff --git a/src/effects/Bars.cpp b/src/effects/Bars.cpp index 4320e618..b85cd454 100644 --- a/src/effects/Bars.cpp +++ b/src/effects/Bars.cpp @@ -145,8 +145,10 @@ void Bars::SetJson(string value) { Json::CharReader* reader(rbuilder.newCharReader()); string errors; - bool success = reader->parse( value.c_str(), + bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); @@ -207,4 +209,3 @@ string Bars::PropertiesJSON(int64_t requested_frame) { // Return formatted string return root.toStyledString(); } - diff --git a/src/effects/Blur.cpp b/src/effects/Blur.cpp index db036133..f5cad9d9 100644 --- a/src/effects/Blur.cpp +++ b/src/effects/Blur.cpp @@ -282,8 +282,10 @@ void Blur::SetJson(string value) { Json::CharReader* reader(rbuilder.newCharReader()); string errors; - bool success = reader->parse( value.c_str(), + bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); @@ -338,4 +340,3 @@ string Blur::PropertiesJSON(int64_t requested_frame) { // Return formatted string return root.toStyledString(); } - diff --git a/src/effects/Brightness.cpp b/src/effects/Brightness.cpp index 67d45824..c32475b6 100644 --- a/src/effects/Brightness.cpp +++ b/src/effects/Brightness.cpp @@ -136,8 +136,10 @@ void Brightness::SetJson(string value) { Json::CharReader* reader(rbuilder.newCharReader()); string errors; - bool success = reader->parse( value.c_str(), + bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); @@ -186,4 +188,3 @@ string Brightness::PropertiesJSON(int64_t requested_frame) { // Return formatted string return root.toStyledString(); } - diff --git a/src/effects/ChromaKey.cpp b/src/effects/ChromaKey.cpp index 397c7ab1..6825eb86 100644 --- a/src/effects/ChromaKey.cpp +++ b/src/effects/ChromaKey.cpp @@ -129,8 +129,10 @@ void ChromaKey::SetJson(string value) { Json::CharReader* reader(rbuilder.newCharReader()); string errors; - bool success = reader->parse( value.c_str(), + bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); diff --git a/src/effects/ColorShift.cpp b/src/effects/ColorShift.cpp index f4fab883..218d47cd 100644 --- a/src/effects/ColorShift.cpp +++ b/src/effects/ColorShift.cpp @@ -228,8 +228,10 @@ void ColorShift::SetJson(string value) { Json::CharReader* reader(rbuilder.newCharReader()); string errors; - bool success = reader->parse( value.c_str(), + bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); @@ -296,4 +298,3 @@ string ColorShift::PropertiesJSON(int64_t requested_frame) { // Return formatted string return root.toStyledString(); } - diff --git a/src/effects/Crop.cpp b/src/effects/Crop.cpp index 99f8f124..67c61f1e 100644 --- a/src/effects/Crop.cpp +++ b/src/effects/Crop.cpp @@ -146,6 +146,8 @@ void Crop::SetJson(string value) { string errors; bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); diff --git a/src/effects/Deinterlace.cpp b/src/effects/Deinterlace.cpp index c698dbd1..6e7f22f3 100644 --- a/src/effects/Deinterlace.cpp +++ b/src/effects/Deinterlace.cpp @@ -123,8 +123,10 @@ void Deinterlace::SetJson(string value) { Json::CharReader* reader(rbuilder.newCharReader()); string errors; - bool success = reader->parse( value.c_str(), + bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); diff --git a/src/effects/Hue.cpp b/src/effects/Hue.cpp index a75b4a1f..5739e3f4 100644 --- a/src/effects/Hue.cpp +++ b/src/effects/Hue.cpp @@ -130,8 +130,10 @@ void Hue::SetJson(string value) { Json::CharReader* reader(rbuilder.newCharReader()); string errors; - bool success = reader->parse( value.c_str(), + bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); @@ -177,4 +179,3 @@ string Hue::PropertiesJSON(int64_t requested_frame) { // Return formatted string return root.toStyledString(); } - diff --git a/src/effects/Mask.cpp b/src/effects/Mask.cpp index b952ba62..9e20b2cb 100644 --- a/src/effects/Mask.cpp +++ b/src/effects/Mask.cpp @@ -183,8 +183,10 @@ void Mask::SetJson(string value) { Json::CharReader* reader(rbuilder.newCharReader()); string errors; - bool success = reader->parse( value.c_str(), + bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); diff --git a/src/effects/Negate.cpp b/src/effects/Negate.cpp index 1b9decdc..8451888f 100644 --- a/src/effects/Negate.cpp +++ b/src/effects/Negate.cpp @@ -84,8 +84,10 @@ void Negate::SetJson(string value) { Json::CharReader* reader(rbuilder.newCharReader()); string errors; - bool success = reader->parse( value.c_str(), + bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); diff --git a/src/effects/Pixelate.cpp b/src/effects/Pixelate.cpp index 95d88b71..19324def 100644 --- a/src/effects/Pixelate.cpp +++ b/src/effects/Pixelate.cpp @@ -141,8 +141,10 @@ void Pixelate::SetJson(string value) { Json::CharReader* reader(rbuilder.newCharReader()); string errors; - bool success = reader->parse( value.c_str(), + bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); @@ -200,4 +202,3 @@ string Pixelate::PropertiesJSON(int64_t requested_frame) { // Return formatted string return root.toStyledString(); } - diff --git a/src/effects/Saturation.cpp b/src/effects/Saturation.cpp index 4278b0b8..b101d96a 100644 --- a/src/effects/Saturation.cpp +++ b/src/effects/Saturation.cpp @@ -141,8 +141,10 @@ void Saturation::SetJson(string value) { Json::CharReader* reader(rbuilder.newCharReader()); string errors; - bool success = reader->parse( value.c_str(), + bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); @@ -188,4 +190,3 @@ string Saturation::PropertiesJSON(int64_t requested_frame) { // Return formatted string return root.toStyledString(); } - diff --git a/src/effects/Shift.cpp b/src/effects/Shift.cpp index 0e802c99..d5445add 100644 --- a/src/effects/Shift.cpp +++ b/src/effects/Shift.cpp @@ -161,8 +161,10 @@ void Shift::SetJson(string value) { Json::CharReader* reader(rbuilder.newCharReader()); string errors; - bool success = reader->parse( value.c_str(), + bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); @@ -211,4 +213,3 @@ string Shift::PropertiesJSON(int64_t requested_frame) { // Return formatted string return root.toStyledString(); } - diff --git a/src/effects/Wave.cpp b/src/effects/Wave.cpp index cfcb70c7..6733b7dd 100644 --- a/src/effects/Wave.cpp +++ b/src/effects/Wave.cpp @@ -144,8 +144,10 @@ void Wave::SetJson(string value) { Json::CharReader* reader(rbuilder.newCharReader()); string errors; - bool success = reader->parse( value.c_str(), + bool success = reader->parse( value.c_str(), value.c_str() + value.size(), &root, &errors ); + delete reader; + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); @@ -203,4 +205,3 @@ string Wave::PropertiesJSON(int64_t requested_frame) { // Return formatted string return root.toStyledString(); } - diff --git a/tests/Clip_Tests.cpp b/tests/Clip_Tests.cpp index 6c60bedd..a43b8faa 100644 --- a/tests/Clip_Tests.cpp +++ b/tests/Clip_Tests.cpp @@ -117,6 +117,7 @@ TEST(Clip_Properties) string errors; bool success = reader->parse( properties.c_str(), properties.c_str() + properties.size(), &root, &errors ); + if (!success) // Raise exception throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); @@ -208,6 +209,9 @@ TEST(Clip_Properties) throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", ""); } + + // Free up the reader we allocated + delete reader; } TEST(Clip_Effects) From 0ac3720023f37f65403835b6b8e4a836a83ae2d9 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Fri, 12 Jul 2019 13:28:47 -0400 Subject: [PATCH 23/43] SWIG: Warnings cleanup * Remove a SWIG pragma from Frame.h (gcc warns on it) * Place the equivalent %warnfilter in the openshot.i files * Set openshot.i PROPERTY GENERATED_COMPILE_OPTIONS with flags to disable warning spew in generated SWIG code, if -Wall is used (Also, remove 'using namespace std' from Frame.h, and add std:: prefixes to necessary variables.) --- include/Frame.h | 17 +++++++---------- src/bindings/python/CMakeLists.txt | 8 +++++++- src/bindings/python/openshot.i | 3 +++ src/bindings/ruby/CMakeLists.txt | 5 +++++ src/bindings/ruby/openshot.i | 3 +++ 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/include/Frame.h b/include/Frame.h index cb855fe4..1048c9cf 100644 --- a/include/Frame.h +++ b/include/Frame.h @@ -65,9 +65,6 @@ #include "MagickUtilities.h" #endif -#pragma SWIG nowarn=362 -using namespace std; - namespace openshot { /** @@ -131,7 +128,7 @@ namespace openshot int width; int height; int sample_rate; - string color; + std::string color; int64_t max_audio_sample; ///< The max audio sample count added to this frame /// Constrain a color value from 0 to 255 @@ -147,13 +144,13 @@ namespace openshot Frame(); /// Constructor - image only (48kHz audio silence) - Frame(int64_t number, int width, int height, string color); + Frame(int64_t number, int width, int height, std::string color); /// Constructor - audio only (300x200 blank image) Frame(int64_t number, int samples, int channels); /// Constructor - image & audio - Frame(int64_t number, int width, int height, string color, int samples, int channels); + Frame(int64_t number, int width, int height, std::string color, int samples, int channels); /// Copy constructor Frame ( const Frame &other ); @@ -165,7 +162,7 @@ namespace openshot virtual ~Frame(); /// Add (or replace) pixel data to the frame (based on a solid color) - void AddColor(int new_width, int new_height, string new_color); + void AddColor(int new_width, int new_height, std::string new_color); /// Add (or replace) pixel data to the frame void AddImage(int new_width, int new_height, int bytes_per_pixel, QImage::Format type, const unsigned char *pixels_); @@ -283,7 +280,7 @@ namespace openshot void SampleRate(int orig_sample_rate) { sample_rate = orig_sample_rate; }; /// Save the frame image to the specified path. The image format can be BMP, JPG, JPEG, PNG, PPM, XBM, XPM - void Save(string path, float scale, string format="PNG", int quality=100); + void Save(std::string path, float scale, std::string format="PNG", int quality=100); /// Set frame number void SetFrameNumber(int64_t number); @@ -293,8 +290,8 @@ namespace openshot /// Thumbnail the frame image with tons of options to the specified path. The image format is determined from the extension (i.e. image.PNG, image.JPEG). /// This method allows for masks, overlays, background color, and much more accurate resizing (including padding and centering) - void Thumbnail(string path, int new_width, int new_height, string mask_path, string overlay_path, - string background_color, bool ignore_aspect, string format="png", int quality=100, float rotate=0.0); + void Thumbnail(std::string path, int new_width, int new_height, std::string mask_path, std::string overlay_path, + std::string background_color, bool ignore_aspect, std::string format="png", int quality=100, float rotate=0.0); /// Play audio samples for this frame void Play(); diff --git a/src/bindings/python/CMakeLists.txt b/src/bindings/python/CMakeLists.txt index eb7c989a..54f62df3 100644 --- a/src/bindings/python/CMakeLists.txt +++ b/src/bindings/python/CMakeLists.txt @@ -50,6 +50,12 @@ if (PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND) set_property(SOURCE openshot.i PROPERTY SWIG_MODULE_NAME openshot) SET(CMAKE_SWIG_FLAGS "") + ### Suppress a ton of warnings in the generated SWIG C++ code + set(SWIG_CXX_FLAGS "-Wno-unused-variable -Wno-unused-function -Wno-deprecated-copy -Wno-class-memaccess -Wno-cast-function-type \ +-Wno-unused-parameter -Wno-catch-value -Wno-sign-compare -Wno-ignored-qualifiers") + separate_arguments(sw_flags UNIX_COMMAND ${SWIG_CXX_FLAGS}) + set_property(SOURCE openshot.i PROPERTY GENERATED_COMPILE_OPTIONS ${sw_flags}) + ### Add the SWIG interface file (which defines all the SWIG methods) if (CMAKE_VERSION VERSION_LESS 3.8.0) swig_add_module(pyopenshot python openshot.i) @@ -65,7 +71,7 @@ if (PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND) target_link_libraries(${SWIG_MODULE_pyopenshot_REAL_NAME} ${PYTHON_LIBRARIES} openshot) - ### Check if the following Debian-friendly python module path exists + ### Check if the following Debian-friendly python module path exists SET(PYTHON_MODULE_PATH "${CMAKE_INSTALL_PREFIX}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages") if (NOT EXISTS ${PYTHON_MODULE_PATH}) diff --git a/src/bindings/python/openshot.i b/src/bindings/python/openshot.i index af1abb74..512224ef 100644 --- a/src/bindings/python/openshot.i +++ b/src/bindings/python/openshot.i @@ -27,6 +27,9 @@ %module openshot +/* Suppress warnings about ignored operator= */ +%warnfilter(362); + /* Enable inline documentation */ %feature("autodoc", "1"); diff --git a/src/bindings/ruby/CMakeLists.txt b/src/bindings/ruby/CMakeLists.txt index db3655fb..0ef70c3b 100644 --- a/src/bindings/ruby/CMakeLists.txt +++ b/src/bindings/ruby/CMakeLists.txt @@ -51,6 +51,11 @@ IF (RUBY_FOUND) set_property(SOURCE openshot.i PROPERTY SWIG_MODULE_NAME openshot) SET(CMAKE_SWIG_FLAGS "") + ### Suppress a ton of warnings in the generated SWIG C++ code + set(SWIG_CXX_FLAGS "-Wno-unused-variable -Wno-unused-function -Wno-deprecated-copy -Wno-class-memaccess -Wno-cast-function-type \ +-Wno-unused-parameter -Wno-catch-value -Wno-sign-compare -Wno-ignored-qualifiers") + separate_arguments(sw_flags UNIX_COMMAND ${SWIG_CXX_FLAGS}) + set_property(SOURCE openshot.i PROPERTY GENERATED_COMPILE_OPTIONS ${sw_flags}) ### Add the SWIG interface file (which defines all the SWIG methods) if (CMAKE_VERSION VERSION_LESS 3.8.0) diff --git a/src/bindings/ruby/openshot.i b/src/bindings/ruby/openshot.i index ab11ae7f..1f3e0d99 100644 --- a/src/bindings/ruby/openshot.i +++ b/src/bindings/ruby/openshot.i @@ -27,6 +27,9 @@ %module openshot +/* Suppress warnings about ignored operator= */ +%warnfilter(362); + /* Enable inline documentation */ %feature("autodoc", "1"); From 8dcefbd87cc1de25946bc77368f84ce154166d7f Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Fri, 12 Jul 2019 18:28:40 -0400 Subject: [PATCH 24/43] Overhaul FindOpenShotAudio.cmake * Version checking! - Supports EXACT (but only for M.N.B, e.g. 0.1.8-dev1 matches 0.1.8 EXACT) - REQUIRED will now cause CMake to abort if version is not sufficient (lower than requested) - Outputs the following: - Version requested, if set - Version found, if successfully parsed from header - Compatibility status, if version set on both ends * Accept `LIBOPENSHOT_AUDIO_DIR` cache variable, in addition to the environment variable (for `cmake -DLIBOPENSHOT_AUDIO_DIR=...`) * Do two-stage search for both headers and libs (Avoids this situation...) LIBOPENSHOT_AUDIO_INCLUDE_DIRS=/usr/include/libopenshot-audio LIBOPENSHOT_AUDIO_LIBRARY=/home/ferd/build/ (Largely inspired by CMake's `FindPythonLibs.cmake`) --- cmake/Modules/FindOpenShotAudio.cmake | 124 +++++++++++++++++++++----- 1 file changed, 102 insertions(+), 22 deletions(-) diff --git a/cmake/Modules/FindOpenShotAudio.cmake b/cmake/Modules/FindOpenShotAudio.cmake index 0aeb0e1f..c1916219 100644 --- a/cmake/Modules/FindOpenShotAudio.cmake +++ b/cmake/Modules/FindOpenShotAudio.cmake @@ -5,34 +5,114 @@ # LIBOPENSHOT_AUDIO_INCLUDE_DIRS - The juce.h include directories # LIBOPENSHOT_AUDIO_LIBRARIES - The libraries needed to use juce -message("$ENV{LIBOPENSHOT_AUDIO_DIR}") +include(GNUInstallDirs) -# Find the libopenshot-audio header files -find_path(LIBOPENSHOT_AUDIO_INCLUDE_DIR JuceHeader.h - PATHS $ENV{LIBOPENSHOT_AUDIO_DIR}/include/libopenshot-audio/ - /usr/include/libopenshot-audio/ - /usr/local/include/libopenshot-audio/ ) +if("$ENV{LIBOPENSHOT_AUDIO_DIR}" AND NOT "${OpenShotAudio_FIND_QUIETLY}") + message(STATUS "Looking for OpenShotAudio in: $ENV{LIBOPENSHOT_AUDIO_DIR}") +endif() -# Find the libopenshot-audio.so (check env var first) -find_library(LIBOPENSHOT_AUDIO_LIBRARY - NAMES libopenshot-audio openshot-audio - PATHS $ENV{LIBOPENSHOT_AUDIO_DIR}/lib/ NO_DEFAULT_PATH) +# Find the libopenshot-audio header files (check env/cache vars first) +find_path( + LIBOPENSHOT_AUDIO_INCLUDE_DIR + JuceHeader.h + HINTS + ENV LIBOPENSHOT_AUDIO_DIR + PATHS + ${LIBOPENSHOT_AUDIO_DIR} + PATH_SUFFIXES + include/libopenshot-audio + libopenshot-audio + include + NO_DEFAULT_PATH +) -# Find the libopenshot-audio.so / libopenshot-audio.dll library (fallback) -find_library(LIBOPENSHOT_AUDIO_LIBRARY - NAMES libopenshot-audio openshot-audio - HINTS $ENV{LIBOPENSHOT_AUDIO_DIR}/lib/ - /usr/lib/ - /usr/lib/libopenshot-audio/ - /usr/local/lib/ ) +# Find the libopenshot-audio header files (fallback to std. paths) +find_path( + LIBOPENSHOT_AUDIO_INCLUDE_DIR + JuceHeader.h + HINTS + ENV LIBOPENSHOT_AUDIO_DIR + PATHS + ${LIBOPENSHOT_AUDIO_DIR} + PATH_SUFFIXES + include/libopenshot-audio + libopenshot-audio + include +) -set(LIBOPENSHOT_AUDIO_LIBRARIES ${LIBOPENSHOT_AUDIO_LIBRARY}) -set(LIBOPENSHOT_AUDIO_LIBRARY ${LIBOPENSHOT_AUDIO_LIBRARIES}) +# Find libopenshot-audio.so / libopenshot-audio.dll (check env/cache vars first) +find_library( + LIBOPENSHOT_AUDIO_LIBRARY + NAMES + libopenshot-audio + openshot-audio + HINTS + ENV LIBOPENSHOT_AUDIO_DIR + PATHS + ${LIBOPENSHOT_AUDIO_DIR} + PATH_SUFFIXES + lib/libopenshot-audio + libopenshot-audio + lib + NO_DEFAULT_PATH +) -set(LIBOPENSHOT_AUDIO_INCLUDE_DIRS ${LIBOPENSHOT_AUDIO_INCLUDE_DIR} ) +# Find libopenshot-audio.so / libopenshot-audio.dll (fallback) +find_library( + LIBOPENSHOT_AUDIO_LIBRARY + NAMES + libopenshot-audio + openshot-audio + HINTS + ENV LIBOPENSHOT_AUDIO_DIR + PATHS + ${LIBOPENSHOT_AUDIO_DIR} + PATH_SUFFIXES + lib/libopenshot-audio + libopenshot-audio + lib +) + +set(LIBOPENSHOT_AUDIO_LIBRARIES "${LIBOPENSHOT_AUDIO_LIBRARY}") +set(LIBOPENSHOT_AUDIO_LIBRARY "${LIBOPENSHOT_AUDIO_LIBRARIES}") +set(LIBOPENSHOT_AUDIO_INCLUDE_DIRS "${LIBOPENSHOT_AUDIO_INCLUDE_DIR}") + +if(LIBOPENSHOT_AUDIO_INCLUDE_DIR AND EXISTS "${LIBOPENSHOT_AUDIO_INCLUDE_DIR}/JuceHeader.h") + file(STRINGS "${LIBOPENSHOT_AUDIO_INCLUDE_DIR}/JuceHeader.h" libosa_version_str + REGEX "versionString.*=.*\"[^\"]+\"") + if(libosa_version_str MATCHES "versionString.*=.*\"([^\"]+)\"") + set(LIBOPENSHOT_AUDIO_VERSION_STRING ${CMAKE_MATCH_1}) + endif() + unset(libosa_version_str) + string(REGEX REPLACE "^([0-9]+\.[0-9]+\.[0-9]+).*$" "\\1" + LIBOPENSHOT_AUDIO_VERSION "${LIBOPENSHOT_AUDIO_VERSION_STRING}") +endif() + +# If we couldn't parse M.N.B version, don't keep any of it +if(NOT LIBOPENSHOT_AUDIO_VERSION) + unset(LIBOPENSHOT_AUDIO_VERSION) + unset(LIBOPENSHOT_AUDIO_VERSION_STRING) +endif() + +# Determine compatibility with requested version in find_package() +if(OpenShotAudio_FIND_VERSION AND LIBOPENSHOT_AUDIO_VERSION) + if("${OpenShotAudio_FIND_VERSION}" STREQUAL "${LIBOPENSHOT_AUDIO_VERSION}") + set(OpenShotAudio_VERSION_EXACT TRUE) + endif() + if("${OpenShotAudio_FIND_VERSION}" VERSION_GREATER "${LIBOPENSHOT_AUDIO_VERSION}") + set(OpenShotAudio_VERSION_COMPATIBLE FALSE) + else() + set(OpenShotAudio_VERSION_COMPATIBLE TRUE) + endif() +endif() include(FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set LIBOPENSHOT_AUDIO_FOUND to TRUE # if all listed variables are TRUE -find_package_handle_standard_args(LIBOPENSHOT_AUDIO DEFAULT_MSG - LIBOPENSHOT_AUDIO_LIBRARY LIBOPENSHOT_AUDIO_INCLUDE_DIR) +find_package_handle_standard_args(OpenShotAudio + REQUIRED_VARS + LIBOPENSHOT_AUDIO_LIBRARY + LIBOPENSHOT_AUDIO_INCLUDE_DIRS + VERSION_VAR + LIBOPENSHOT_AUDIO_VERSION_STRING +) From c4c625ba8e8e9ff4025a0b0882dd9aed448b7ad2 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Fri, 12 Jul 2019 18:37:09 -0400 Subject: [PATCH 25/43] Add 0.1.8 minimum version for libopenshot-audio --- src/CMakeLists.txt | 2 +- tests/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 869dcfc6..6980dbae 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -112,7 +112,7 @@ ENDIF (AVRESAMPLE_FOUND) ################# LIBOPENSHOT-AUDIO ################### # Find JUCE-based openshot Audio libraries -FIND_PACKAGE(OpenShotAudio REQUIRED) +FIND_PACKAGE(OpenShotAudio 0.1.8 REQUIRED) # Include Juce headers (needed for compile) include_directories(${LIBOPENSHOT_AUDIO_INCLUDE_DIRS}) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index caefffb0..5e18fcf3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -112,7 +112,7 @@ ENDIF (AVRESAMPLE_FOUND) ################# LIBOPENSHOT-AUDIO ################### # Find JUCE-based openshot Audio libraries -FIND_PACKAGE(OpenShotAudio REQUIRED) +FIND_PACKAGE(OpenShotAudio 0.1.8 REQUIRED) # Include Juce headers (needed for compile) include_directories(${LIBOPENSHOT_AUDIO_INCLUDE_DIRS}) From 935a740cff648c72ab9e1f0be86c728d3db8acf8 Mon Sep 17 00:00:00 2001 From: Frank Dana Date: Fri, 12 Jul 2019 19:12:31 -0400 Subject: [PATCH 26/43] Remove spurious include That wasn't supposed to be in there. --- cmake/Modules/FindOpenShotAudio.cmake | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmake/Modules/FindOpenShotAudio.cmake b/cmake/Modules/FindOpenShotAudio.cmake index c1916219..a0cb9200 100644 --- a/cmake/Modules/FindOpenShotAudio.cmake +++ b/cmake/Modules/FindOpenShotAudio.cmake @@ -5,8 +5,6 @@ # LIBOPENSHOT_AUDIO_INCLUDE_DIRS - The juce.h include directories # LIBOPENSHOT_AUDIO_LIBRARIES - The libraries needed to use juce -include(GNUInstallDirs) - if("$ENV{LIBOPENSHOT_AUDIO_DIR}" AND NOT "${OpenShotAudio_FIND_QUIETLY}") message(STATUS "Looking for OpenShotAudio in: $ENV{LIBOPENSHOT_AUDIO_DIR}") endif() From 09a1715dea6f59d37a2415fe41647028132919f2 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Tue, 16 Jul 2019 01:57:43 -0500 Subject: [PATCH 27/43] Updating MSYS2 with new syntax --- .gitlab-ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6c92665a..e4fbb73d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -71,11 +71,12 @@ windows-builder-x64: - $env:LIBOPENSHOT_AUDIO_DIR = "$CI_PROJECT_DIR\build\install-x64" - $env:UNITTEST_DIR = "C:\msys64\usr" - $env:ZMQDIR = "C:\msys64\usr" + - $env:RESVGDIR = "C:\msys64\usr\local" - $env:Path = "C:\msys64\mingw64\bin;C:\msys64\mingw64\lib;C:\msys64\usr\lib\cmake\UnitTest++;C:\msys64\home\jonathan\depot_tools;C:\msys64\usr;C:\msys64\usr\lib;" + $env:Path; - New-Item -ItemType Directory -Force -Path build - New-Item -ItemType Directory -Force -Path build\install-x64\python - cd build - - cmake -D"CMAKE_INSTALL_PREFIX:PATH=$CI_PROJECT_DIR\build\install-x64" -G "MinGW Makefiles" -D"CMAKE_BUILD_TYPE:STRING=Release" ../ + - cmake -D"CMAKE_INSTALL_PREFIX:PATH=$CI_PROJECT_DIR\build\install-x64" -G "MSYS Makefiles" -DCMAKE_MAKE_PROGRAM=mingw32-make -D"CMAKE_BUILD_TYPE:STRING=Release" ../ - mingw32-make install - Move-Item -Force -path "install-x64\lib\python3.6\site-packages\*openshot*" -destination "install-x64\python\" - New-Item -path "install-x64/share/" -Name "$CI_PROJECT_NAME" -Value "CI_PROJECT_NAME:$CI_PROJECT_NAME`nCI_COMMIT_REF_NAME:$CI_COMMIT_REF_NAME`nCI_COMMIT_SHA:$CI_COMMIT_SHA`nCI_JOB_ID:$CI_JOB_ID" -ItemType file -force @@ -105,7 +106,7 @@ windows-builder-x86: - New-Item -ItemType Directory -Force -Path build - New-Item -ItemType Directory -Force -Path build\install-x86\python - cd build - - cmake -D"CMAKE_INSTALL_PREFIX:PATH=$CI_PROJECT_DIR\build\install-x86" -G "MinGW Makefiles" -D"CMAKE_BUILD_TYPE:STRING=Release" -D"CMAKE_CXX_FLAGS=-m32" -D"CMAKE_EXE_LINKER_FLAGS=-Wl,--large-address-aware" -D"CMAKE_C_FLAGS=-m32" ../ + - cmake -D"CMAKE_INSTALL_PREFIX:PATH=$CI_PROJECT_DIR\build\install-x86" -G "MSYS Makefiles" -DCMAKE_MAKE_PROGRAM=mingw32-make -D"CMAKE_BUILD_TYPE:STRING=Release" -D"CMAKE_CXX_FLAGS=-m32" -D"CMAKE_EXE_LINKER_FLAGS=-Wl,--large-address-aware" -D"CMAKE_C_FLAGS=-m32" ../ - mingw32-make install - Move-Item -Force -path "install-x86\lib\python3.6\site-packages\*openshot*" -destination "install-x86\python\" - New-Item -path "install-x86/share/" -Name "$CI_PROJECT_NAME" -Value "CI_PROJECT_NAME:$CI_PROJECT_NAME`nCI_COMMIT_REF_NAME:$CI_COMMIT_REF_NAME`nCI_COMMIT_SHA:$CI_COMMIT_SHA`nCI_JOB_ID:$CI_JOB_ID" -ItemType file -force From 4a1d133da85e529b158f9a34518c41feb150d71c Mon Sep 17 00:00:00 2001 From: nick black Date: Tue, 16 Jul 2019 10:37:45 -0400 Subject: [PATCH 28/43] PlayerDemo: declare keyPressEvent() override --- include/Qt/PlayerDemo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Qt/PlayerDemo.h b/include/Qt/PlayerDemo.h index e5d304a4..c5a49377 100644 --- a/include/Qt/PlayerDemo.h +++ b/include/Qt/PlayerDemo.h @@ -57,7 +57,7 @@ public: ~PlayerDemo(); protected: - void keyPressEvent(QKeyEvent *event); + override void keyPressEvent(QKeyEvent *event); void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; private slots: From 47d69779b60bf85da34485b0e33589f389fd44a4 Mon Sep 17 00:00:00 2001 From: Frank Dana Date: Tue, 16 Jul 2019 12:28:00 -0400 Subject: [PATCH 29/43] Fix override syntax Overrides go at the end of the declaration. Qt also has the `Q_DECL_OVERRIDE` preprocessor define, which expands to `override` only when building the code using C++11 or higher. --- include/Qt/PlayerDemo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Qt/PlayerDemo.h b/include/Qt/PlayerDemo.h index c5a49377..cfed78bd 100644 --- a/include/Qt/PlayerDemo.h +++ b/include/Qt/PlayerDemo.h @@ -57,7 +57,7 @@ public: ~PlayerDemo(); protected: - override void keyPressEvent(QKeyEvent *event); + void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE; void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; private slots: From bfd70795c3e595a40447559ba80999c9db6f81a0 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Tue, 16 Jul 2019 15:45:46 -0500 Subject: [PATCH 30/43] Fixing python3.6 to 3.7 Windows reference --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e4fbb73d..d64e463f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -78,7 +78,7 @@ windows-builder-x64: - cd build - cmake -D"CMAKE_INSTALL_PREFIX:PATH=$CI_PROJECT_DIR\build\install-x64" -G "MSYS Makefiles" -DCMAKE_MAKE_PROGRAM=mingw32-make -D"CMAKE_BUILD_TYPE:STRING=Release" ../ - mingw32-make install - - Move-Item -Force -path "install-x64\lib\python3.6\site-packages\*openshot*" -destination "install-x64\python\" + - Move-Item -Force -path "install-x64\lib\python3.7\site-packages\*openshot*" -destination "install-x64\python\" - New-Item -path "install-x64/share/" -Name "$CI_PROJECT_NAME" -Value "CI_PROJECT_NAME:$CI_PROJECT_NAME`nCI_COMMIT_REF_NAME:$CI_COMMIT_REF_NAME`nCI_COMMIT_SHA:$CI_COMMIT_SHA`nCI_JOB_ID:$CI_JOB_ID" -ItemType file -force - $PREV_GIT_LABEL=(git describe --tags --abbrev=0) - git log "$PREV_GIT_LABEL..HEAD" --oneline --pretty=format:"%C(auto,yellow)%h%C(auto,magenta)% %C(auto,blue)%>(12,trunc)%ad %C(auto,green)%<(25,trunc)%aN%C(auto,reset)%s%C(auto,red)% gD% D" --date=short > "install-x64/share/$CI_PROJECT_NAME.log" @@ -108,7 +108,7 @@ windows-builder-x86: - cd build - cmake -D"CMAKE_INSTALL_PREFIX:PATH=$CI_PROJECT_DIR\build\install-x86" -G "MSYS Makefiles" -DCMAKE_MAKE_PROGRAM=mingw32-make -D"CMAKE_BUILD_TYPE:STRING=Release" -D"CMAKE_CXX_FLAGS=-m32" -D"CMAKE_EXE_LINKER_FLAGS=-Wl,--large-address-aware" -D"CMAKE_C_FLAGS=-m32" ../ - mingw32-make install - - Move-Item -Force -path "install-x86\lib\python3.6\site-packages\*openshot*" -destination "install-x86\python\" + - Move-Item -Force -path "install-x86\lib\python3.7\site-packages\*openshot*" -destination "install-x86\python\" - New-Item -path "install-x86/share/" -Name "$CI_PROJECT_NAME" -Value "CI_PROJECT_NAME:$CI_PROJECT_NAME`nCI_COMMIT_REF_NAME:$CI_COMMIT_REF_NAME`nCI_COMMIT_SHA:$CI_COMMIT_SHA`nCI_JOB_ID:$CI_JOB_ID" -ItemType file -force - $PREV_GIT_LABEL=(git describe --tags --abbrev=0) - git log "$PREV_GIT_LABEL..HEAD" --oneline --pretty=format:"%C(auto,yellow)%h%C(auto,magenta)% %C(auto,blue)%>(12,trunc)%ad %C(auto,green)%<(25,trunc)%aN%C(auto,reset)%s%C(auto,red)% gD% D" --date=short > "install-x86/share/$CI_PROJECT_NAME.log" From efddb1b2b1babb405c1007ddc7fbb9919588a9e4 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Tue, 16 Jul 2019 15:50:51 -0500 Subject: [PATCH 31/43] Fixing python3.6 to 3.7 Windows reference --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d64e463f..68dd761c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -71,7 +71,7 @@ windows-builder-x64: - $env:LIBOPENSHOT_AUDIO_DIR = "$CI_PROJECT_DIR\build\install-x64" - $env:UNITTEST_DIR = "C:\msys64\usr" - $env:ZMQDIR = "C:\msys64\usr" - - $env:RESVGDIR = "C:\msys64\usr\local" + - $env:RESVGDIR = "C:\msys64\usr" - $env:Path = "C:\msys64\mingw64\bin;C:\msys64\mingw64\lib;C:\msys64\usr\lib\cmake\UnitTest++;C:\msys64\home\jonathan\depot_tools;C:\msys64\usr;C:\msys64\usr\lib;" + $env:Path; - New-Item -ItemType Directory -Force -Path build - New-Item -ItemType Directory -Force -Path build\install-x64\python @@ -100,7 +100,7 @@ windows-builder-x86: - Expand-Archive -Path artifacts.zip -DestinationPath . - $env:LIBOPENSHOT_AUDIO_DIR = "$CI_PROJECT_DIR\build\install-x86" - $env:UNITTEST_DIR = "C:\msys32\usr" - - $env:RESVGDIR = "C:\msys32\usr\local" + - $env:RESVGDIR = "C:\msys32\usr" - $env:ZMQDIR = "C:\msys32\usr" - $env:Path = "C:\msys32\mingw32\bin;C:\msys32\mingw32\lib;C:\msys32\usr\lib\cmake\UnitTest++;C:\msys32\home\jonathan\depot_tools;C:\msys32\usr;C:\msys32\usr\lib;" + $env:Path; - New-Item -ItemType Directory -Force -Path build From cf0e827a24781ed4f58177a69a8ffc03281c8852 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Tue, 23 Jul 2019 17:11:55 -0500 Subject: [PATCH 32/43] Adding logging support for resvg (which will output on stderr) --- src/ZmqLogger.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/ZmqLogger.cpp b/src/ZmqLogger.cpp index f9ecc875..325bf6c0 100644 --- a/src/ZmqLogger.cpp +++ b/src/ZmqLogger.cpp @@ -30,6 +30,10 @@ #include "../include/ZmqLogger.h" +#if USE_RESVG == 1 + #include "ResvgQt.h" +#endif + using namespace std; using namespace openshot; @@ -54,6 +58,13 @@ ZmqLogger *ZmqLogger::Instance() // Init enabled to False (force user to call Enable()) m_pInstance->enabled = false; + + #if USE_RESVG == 1 + // Init resvg logging (if needed) + // This can only happen 1 time or it will crash + ResvgRenderer::initLog(); + #endif + } return m_pInstance; From 50963c63507844b410c05f3206c398d8e2344811 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Thu, 25 Jul 2019 16:45:22 -0500 Subject: [PATCH 33/43] Enable verbose logging --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 68dd761c..0447a721 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -76,7 +76,7 @@ windows-builder-x64: - New-Item -ItemType Directory -Force -Path build - New-Item -ItemType Directory -Force -Path build\install-x64\python - cd build - - cmake -D"CMAKE_INSTALL_PREFIX:PATH=$CI_PROJECT_DIR\build\install-x64" -G "MSYS Makefiles" -DCMAKE_MAKE_PROGRAM=mingw32-make -D"CMAKE_BUILD_TYPE:STRING=Release" ../ + - cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -D"CMAKE_INSTALL_PREFIX:PATH=$CI_PROJECT_DIR\build\install-x64" -G "MSYS Makefiles" -DCMAKE_MAKE_PROGRAM=mingw32-make -D"CMAKE_BUILD_TYPE:STRING=Release" ../ - mingw32-make install - Move-Item -Force -path "install-x64\lib\python3.7\site-packages\*openshot*" -destination "install-x64\python\" - New-Item -path "install-x64/share/" -Name "$CI_PROJECT_NAME" -Value "CI_PROJECT_NAME:$CI_PROJECT_NAME`nCI_COMMIT_REF_NAME:$CI_COMMIT_REF_NAME`nCI_COMMIT_SHA:$CI_COMMIT_SHA`nCI_JOB_ID:$CI_JOB_ID" -ItemType file -force @@ -106,7 +106,7 @@ windows-builder-x86: - New-Item -ItemType Directory -Force -Path build - New-Item -ItemType Directory -Force -Path build\install-x86\python - cd build - - cmake -D"CMAKE_INSTALL_PREFIX:PATH=$CI_PROJECT_DIR\build\install-x86" -G "MSYS Makefiles" -DCMAKE_MAKE_PROGRAM=mingw32-make -D"CMAKE_BUILD_TYPE:STRING=Release" -D"CMAKE_CXX_FLAGS=-m32" -D"CMAKE_EXE_LINKER_FLAGS=-Wl,--large-address-aware" -D"CMAKE_C_FLAGS=-m32" ../ + - cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -D"CMAKE_INSTALL_PREFIX:PATH=$CI_PROJECT_DIR\build\install-x86" -G "MSYS Makefiles" -DCMAKE_MAKE_PROGRAM=mingw32-make -D"CMAKE_BUILD_TYPE:STRING=Release" -D"CMAKE_CXX_FLAGS=-m32" -D"CMAKE_EXE_LINKER_FLAGS=-Wl,--large-address-aware" -D"CMAKE_C_FLAGS=-m32" ../ - mingw32-make install - Move-Item -Force -path "install-x86\lib\python3.7\site-packages\*openshot*" -destination "install-x86\python\" - New-Item -path "install-x86/share/" -Name "$CI_PROJECT_NAME" -Value "CI_PROJECT_NAME:$CI_PROJECT_NAME`nCI_COMMIT_REF_NAME:$CI_COMMIT_REF_NAME`nCI_COMMIT_SHA:$CI_COMMIT_SHA`nCI_JOB_ID:$CI_JOB_ID" -ItemType file -force From 2ffce233f9bdb8f81bb47af33cffd7393321a9b5 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Thu, 25 Jul 2019 17:29:40 -0500 Subject: [PATCH 34/43] Enable verbose logging --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0447a721..131e0c81 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,7 +17,7 @@ linux-builder: - export LIBOPENSHOT_AUDIO_DIR=$CI_PROJECT_DIR/build/install-x64 - mkdir -p build; cd build; - mkdir -p install-x64/python; - - cmake -D"CMAKE_INSTALL_PREFIX:PATH=$CI_PROJECT_DIR/build/install-x64" -D"CMAKE_BUILD_TYPE:STRING=Release" ../ + - cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -D"CMAKE_INSTALL_PREFIX:PATH=$CI_PROJECT_DIR/build/install-x64" -D"CMAKE_BUILD_TYPE:STRING=Release" ../ - make - make install - make doc @@ -46,7 +46,7 @@ mac-builder: - export LIBOPENSHOT_AUDIO_DIR=$CI_PROJECT_DIR/build/install-x64 - mkdir -p build; cd build; - mkdir -p install-x64/python; - - cmake -D"CMAKE_INSTALL_PREFIX:PATH=$CI_PROJECT_DIR/build/install-x64" -DCMAKE_CXX_COMPILER=/usr/local/opt/gcc48/bin/g++-4.8 -DCMAKE_C_COMPILER=/usr/local/opt/gcc48/bin/gcc-4.8 -DCMAKE_PREFIX_PATH=/usr/local/qt5/5.5/clang_64 -DPYTHON_INCLUDE_DIR=/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m -DPYTHON_LIBRARY=/Library/Frameworks/Python.framework/Versions/3.6/lib/libpython3.6.dylib -DPython_FRAMEWORKS=/Library/Frameworks/Python.framework/ -D"CMAKE_BUILD_TYPE:STRING=Debug" -D"CMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" -D"CMAKE_OSX_DEPLOYMENT_TARGET=10.9" -D"CMAKE_INSTALL_RPATH_USE_LINK_PATH=1" -D"ENABLE_RUBY=0" ../ + - cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -D"CMAKE_INSTALL_PREFIX:PATH=$CI_PROJECT_DIR/build/install-x64" -DCMAKE_CXX_COMPILER=/usr/local/opt/gcc48/bin/g++-4.8 -DCMAKE_C_COMPILER=/usr/local/opt/gcc48/bin/gcc-4.8 -DCMAKE_PREFIX_PATH=/usr/local/qt5/5.5/clang_64 -DPYTHON_INCLUDE_DIR=/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m -DPYTHON_LIBRARY=/Library/Frameworks/Python.framework/Versions/3.6/lib/libpython3.6.dylib -DPython_FRAMEWORKS=/Library/Frameworks/Python.framework/ -D"CMAKE_BUILD_TYPE:STRING=Debug" -D"CMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" -D"CMAKE_OSX_DEPLOYMENT_TARGET=10.9" -D"CMAKE_INSTALL_RPATH_USE_LINK_PATH=1" -D"ENABLE_RUBY=0" ../ - make - make install - mv install-x64/lib/python3.6/site-packages/*openshot* install-x64/python From 7e5715627c1f9347f788e8c3a933c7a672d0a1b0 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Fri, 26 Jul 2019 19:27:15 -0400 Subject: [PATCH 35/43] Enable Audio/Video choices show as Auto/Off/On --- src/Clip.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Clip.cpp b/src/Clip.cpp index 8f72ffb8..c81fc187 100644 --- a/src/Clip.cpp +++ b/src/Clip.cpp @@ -716,6 +716,14 @@ string Clip::PropertiesJSON(int64_t requested_frame) { root["has_audio"] = add_property_json("Enable Audio", has_audio.GetValue(requested_frame), "int", "", &has_audio, -1, 1.0, false, requested_frame); root["has_video"] = add_property_json("Enable Video", has_video.GetValue(requested_frame), "int", "", &has_video, -1, 1.0, false, requested_frame); + // Add enable audio/video choices (dropdown style) + root["has_audio"]["choices"].append(add_property_choice_json("Auto", -1, has_audio.GetValue(requested_frame))); + root["has_audio"]["choices"].append(add_property_choice_json("Off", 0, has_audio.GetValue(requested_frame))); + root["has_audio"]["choices"].append(add_property_choice_json("On", 1, has_audio.GetValue(requested_frame))); + root["has_video"]["choices"].append(add_property_choice_json("Auto", -1, has_video.GetValue(requested_frame))); + root["has_video"]["choices"].append(add_property_choice_json("Off", 0, has_video.GetValue(requested_frame))); + root["has_video"]["choices"].append(add_property_choice_json("On", 1, has_video.GetValue(requested_frame))); + root["crop_x"] = add_property_json("Crop X", crop_x.GetValue(requested_frame), "float", "", &crop_x, -1.0, 1.0, false, requested_frame); root["crop_y"] = add_property_json("Crop Y", crop_y.GetValue(requested_frame), "float", "", &crop_y, -1.0, 1.0, false, requested_frame); root["crop_width"] = add_property_json("Crop Width", crop_width.GetValue(requested_frame), "float", "", &crop_width, 0.0, 1.0, false, requested_frame); From e94436b71d07962bb8add0b77ebd2ddd9c8f0670 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Tue, 30 Jul 2019 04:06:36 -0400 Subject: [PATCH 36/43] Raise SWIG version requirement to 3.0 --- src/bindings/python/CMakeLists.txt | 2 +- src/bindings/ruby/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bindings/python/CMakeLists.txt b/src/bindings/python/CMakeLists.txt index 54f62df3..9afabd41 100644 --- a/src/bindings/python/CMakeLists.txt +++ b/src/bindings/python/CMakeLists.txt @@ -26,7 +26,7 @@ ############### SWIG PYTHON BINDINGS ################ -FIND_PACKAGE(SWIG 2.0 REQUIRED) +FIND_PACKAGE(SWIG 3.0 REQUIRED) INCLUDE(${SWIG_USE_FILE}) ### Enable some legacy SWIG behaviors, in newer CMAKEs diff --git a/src/bindings/ruby/CMakeLists.txt b/src/bindings/ruby/CMakeLists.txt index 0ef70c3b..4b962e73 100644 --- a/src/bindings/ruby/CMakeLists.txt +++ b/src/bindings/ruby/CMakeLists.txt @@ -28,7 +28,7 @@ include_directories(${OPENSHOT_INCLUDE_DIRS}) ############### RUBY BINDINGS ################ -FIND_PACKAGE(SWIG 2.0 REQUIRED) +FIND_PACKAGE(SWIG 3.0 REQUIRED) INCLUDE(${SWIG_USE_FILE}) ### Enable some legacy SWIG behaviors, in newer CMAKEs From 4d7ecded14f6cbfec90951020eb00e8887b851b8 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Tue, 30 Jul 2019 13:15:31 -0400 Subject: [PATCH 37/43] Fix misleading indentation --- src/Frame.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Frame.cpp b/src/Frame.cpp index ccbb65d5..49fb7358 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -833,10 +833,11 @@ void Frame::AddImage(std::shared_ptr new_image, bool only_odd_lines) int start = 0; if (only_odd_lines) start = 1; - for (int row = start; row < image->height(); row += 2) { - memcpy((unsigned char *) pixels, new_pixels + (row * image->bytesPerLine()), image->bytesPerLine()); - new_pixels += image->bytesPerLine(); - } + + for (int row = start; row < image->height(); row += 2) { + memcpy((unsigned char *) pixels, new_pixels + (row * image->bytesPerLine()), image->bytesPerLine()); + new_pixels += image->bytesPerLine(); + } // Update height and width width = image->width(); From f434b063d920e29ba425354bcc9b8b0487d72d4a Mon Sep 17 00:00:00 2001 From: eisneinechse <42617957+eisneinechse@users.noreply.github.com> Date: Wed, 31 Jul 2019 20:56:11 -0700 Subject: [PATCH 38/43] Move #endif Move av_hwdevice_get_hwframe_constraints inside the part of the code only compiled when testing VAAPI constraint detection. --- src/FFmpegReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FFmpegReader.cpp b/src/FFmpegReader.cpp index d5d51d52..511a3183 100644 --- a/src/FFmpegReader.cpp +++ b/src/FFmpegReader.cpp @@ -445,8 +445,8 @@ void FFmpegReader::Open() { // TODO: needs va_config! #if ENABLE_VAAPI ((AVVAAPIHWConfig *)hwconfig)->config_id = ((VAAPIDecodeContext *)(pCodecCtx->priv_data))->va_config; -#endif constraints = av_hwdevice_get_hwframe_constraints(hw_device_ctx,hwconfig); +#endif if (constraints) { if (pCodecCtx->coded_width < constraints->min_width || pCodecCtx->coded_height < constraints->min_height || From c77f00903883ea0b0c39b1608f19da28ce7f7191 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sun, 4 Aug 2019 16:06:54 -0400 Subject: [PATCH 39/43] Remove "dummy" args from ZmqLogger stragglers I somehow missed a few calls, in #266. --- src/AudioReaderSource.cpp | 4 ++-- src/Clip.cpp | 4 ++-- src/FFmpegWriter.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/AudioReaderSource.cpp b/src/AudioReaderSource.cpp index 4c42d2ed..8195d03b 100644 --- a/src/AudioReaderSource.cpp +++ b/src/AudioReaderSource.cpp @@ -66,7 +66,7 @@ void AudioReaderSource::GetMoreSamplesFromReader() } // Debug - ZmqLogger::Instance()->AppendDebugMethod("AudioReaderSource::GetMoreSamplesFromReader", "amount_needed", amount_needed, "amount_remaining", amount_remaining, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("AudioReaderSource::GetMoreSamplesFromReader", "amount_needed", amount_needed, "amount_remaining", amount_remaining); // Init estimated buffer equal to the current frame position (before getting more samples) estimated_frame = frame_number; @@ -149,7 +149,7 @@ juce::AudioSampleBuffer* AudioReaderSource::reverse_buffer(juce::AudioSampleBuff int channels = buffer->getNumChannels(); // Debug - ZmqLogger::Instance()->AppendDebugMethod("AudioReaderSource::reverse_buffer", "number_of_samples", number_of_samples, "channels", channels, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("AudioReaderSource::reverse_buffer", "number_of_samples", number_of_samples, "channels", channels); // Reverse array (create new buffer to hold the reversed version) AudioSampleBuffer *reversed = new juce::AudioSampleBuffer(channels, number_of_samples); diff --git a/src/Clip.cpp b/src/Clip.cpp index 653cb667..3bf6030d 100644 --- a/src/Clip.cpp +++ b/src/Clip.cpp @@ -616,7 +616,7 @@ std::shared_ptr Clip::GetOrCreateFrame(int64_t number) try { // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Clip::GetOrCreateFrame (from reader)", "number", number, "samples_in_frame", samples_in_frame, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Clip::GetOrCreateFrame (from reader)", "number", number, "samples_in_frame", samples_in_frame); // Attempt to get a frame (but this could fail if a reader has just been closed) new_frame = reader->GetFrame(number); @@ -634,7 +634,7 @@ std::shared_ptr Clip::GetOrCreateFrame(int64_t number) } // Debug output - ZmqLogger::Instance()->AppendDebugMethod("Clip::GetOrCreateFrame (create blank)", "number", number, "samples_in_frame", samples_in_frame, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("Clip::GetOrCreateFrame (create blank)", "number", number, "samples_in_frame", samples_in_frame); // Create blank frame new_frame = std::make_shared(number, reader->info.width, reader->info.height, "#000000", samples_in_frame, reader->info.channels); diff --git a/src/FFmpegWriter.cpp b/src/FFmpegWriter.cpp index 37f3016a..20940455 100644 --- a/src/FFmpegWriter.cpp +++ b/src/FFmpegWriter.cpp @@ -1389,7 +1389,7 @@ void FFmpegWriter::open_video(AVFormatContext *oc, AVStream *st) { av_dict_set(&st->metadata, iter->first.c_str(), iter->second.c_str(), 0); } - ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::open_video", "video_codec->thread_count", video_codec->thread_count, "", -1, "", -1, "", -1, "", -1, "", -1); + ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::open_video", "video_codec->thread_count", video_codec->thread_count); } From fc764622926c3cdc223c9ef25888813f2e7fdb58 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Mon, 5 Aug 2019 20:19:50 -0400 Subject: [PATCH 40/43] Update table in HW-ACCEL.md for Doxygen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By using actual Unicode characters for the various ✔️ and ❌ marks in the table, Doxygen will format it properly. Also: - Changed to superscripted numerals, for the various callouts - Reformatted notes into a corresponding ordered list - Added invisible spaces after the marks without a callout, to balance centering - Added center-alignment markers to appropriate table columns --- doc/HW-ACCEL.md | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/doc/HW-ACCEL.md b/doc/HW-ACCEL.md index b8ee7b4e..cbcf5e63 100644 --- a/doc/HW-ACCEL.md +++ b/doc/HW-ACCEL.md @@ -7,20 +7,22 @@ our support for this in the future! The following table summarizes our current level of support: -| | Linux Decode | Linux Encode | Mac Decode | Mac Encode |Windows Decode| Windows Encode | Notes | -|--------------------|------------------------|----------------------|------------------|----------------|--------------|------------------|------------------| -| VA-API | :heavy_check_mark: | :heavy_check_mark: | - | - | - | - | *Linux Only* | -| VDPAU | :heavy_check_mark:(+) |:white_check_mark:(++)| - | - | - | - | *Linux Only* | -| CUDA (NVDEC/NVENC) | :x:(+++) | :heavy_check_mark: | - | - | - |:heavy_check_mark:| *Cross Platform* | -| VideoToolBox | - | - |:heavy_check_mark:| :x:(++++) | - | - | *Mac Only* | -| DXVA2 | - | - | - | - | :x:(+++) | - | *Windows Only* | -| D3D11VA | - | - | - | - | :x:(+++) | - | *Windows Only* | -| QSV | :x:(+++) | :x: | :x: | :x: | :x: | :x: | *Cross Platform* | +| | Linux Decode | Linux Encode | Mac Decode | Mac Encode | Windows Decode | Windows Encode | Notes | +|--------------------|:---------------:|:--------------:|:----------:|:--------------:|:--------------:|:--------------:|------------------| +| VA-API | ✔️   | ✔️   | - | - | - | - | *Linux Only* | +| VDPAU | ✔️ 1 | ✅ 2 | - | - | - | - | *Linux Only* | +| CUDA (NVDEC/NVENC) | ❌ 3 | ✔️   | - | - | - | ✔️   | *Cross Platform* | +| VideoToolBox | - | - | ✔️   | ❌ 4 | - | - | *Mac Only* | +| DXVA2 | - | - | - | - | ❌ 3 | - | *Windows Only* | +| D3D11VA | - | - | - | - | ❌ 3 | - | *Windows Only* | +| QSV | ❌ 3 | ❌   | ❌   | ❌   | ❌   | ❌   | *Cross Platform* | -* *(+) VDPAU for some reason needs a card number one higher than it really is* -* *(++) VDPAU is a decoder only.* -* *(+++) Green frames (pixel data not correctly tranferred back to system memory)* -* *(++++) Crashes and burns* +#### Notes + +1. VDPAU for some reason needs a card number one higher than it really is +2. VDPAU is a decoder only +3. Green frames (pixel data not correctly tranferred back to system memory) +4. Crashes and burns ## Supported FFmpeg Versions @@ -37,7 +39,7 @@ included. The following settings are use by libopenshot to enable, disable, and control the various hardware acceleration features. -``` +```{cpp} /// Use video codec for faster video decoding (if supported) int HARDWARE_DECODER = 0; @@ -76,9 +78,9 @@ in Ubuntu 18.04) for the AppImage to work with hardware acceleration. An AppImage that works on both systems (supporting libva and libva2), might be possible when no libva is included in the AppImage. -* vaapi is working for intel and AMD -* vaapi is working for decode only for nouveau -* nVidia driver is working for export only +* vaapi is working for intel and AMD +* vaapi is working for decode only for nouveau +* nVidia driver is working for export only ## AMD Graphics Cards (RadeonOpenCompute/ROCm) From 5fb9755353d2dc6fe5779c7fd4b22a2760d3b6e4 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Tue, 6 Aug 2019 11:59:55 -0400 Subject: [PATCH 41/43] Fix truncated output filenames in FFmpegWriter --- include/FFmpegUtilities.h | 4 ++++ src/FFmpegWriter.cpp | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/FFmpegUtilities.h b/include/FFmpegUtilities.h index 8a0b7705..0ccf1ca1 100644 --- a/include/FFmpegUtilities.h +++ b/include/FFmpegUtilities.h @@ -149,6 +149,7 @@ #define AV_REGISTER_ALL #define AVCODEC_REGISTER_ALL #define AV_FILENAME url + #define AV_SET_FILENAME(oc, f) oc->AV_FILENAME = av_strdup(f) #define MY_INPUT_BUFFER_PADDING_SIZE AV_INPUT_BUFFER_PADDING_SIZE #define AV_ALLOCATE_FRAME() av_frame_alloc() #define AV_ALLOCATE_IMAGE(av_frame, pix_fmt, width, height) av_image_alloc(av_frame->data, av_frame->linesize, width, height, pix_fmt, 1) @@ -184,6 +185,7 @@ #define AV_REGISTER_ALL av_register_all(); #define AVCODEC_REGISTER_ALL avcodec_register_all(); #define AV_FILENAME filename + #define AV_SET_FILENAME(oc, f) snprintf(oc->AV_FILENAME, sizeof(oc->AV_FILENAME), "%s", f) #define MY_INPUT_BUFFER_PADDING_SIZE FF_INPUT_BUFFER_PADDING_SIZE #define AV_ALLOCATE_FRAME() av_frame_alloc() #define AV_ALLOCATE_IMAGE(av_frame, pix_fmt, width, height) av_image_alloc(av_frame->data, av_frame->linesize, width, height, pix_fmt, 1) @@ -222,6 +224,7 @@ #define AV_REGISTER_ALL av_register_all(); #define AVCODEC_REGISTER_ALL avcodec_register_all(); #define AV_FILENAME filename + #define AV_SET_FILENAME(oc, f) snprintf(oc->AV_FILENAME, sizeof(oc->AV_FILENAME), "%s", f) #define MY_INPUT_BUFFER_PADDING_SIZE FF_INPUT_BUFFER_PADDING_SIZE #define AV_ALLOCATE_FRAME() av_frame_alloc() #define AV_ALLOCATE_IMAGE(av_frame, pix_fmt, width, height) avpicture_alloc((AVPicture *) av_frame, pix_fmt, width, height) @@ -252,6 +255,7 @@ #define AV_REGISTER_ALL av_register_all(); #define AVCODEC_REGISTER_ALL avcodec_register_all(); #define AV_FILENAME filename + #define AV_SET_FILENAME(oc, f) snprintf(oc->AV_FILENAME, sizeof(oc->AV_FILENAME), "%s", f) #define MY_INPUT_BUFFER_PADDING_SIZE FF_INPUT_BUFFER_PADDING_SIZE #define AV_ALLOCATE_FRAME() avcodec_alloc_frame() #define AV_ALLOCATE_IMAGE(av_frame, pix_fmt, width, height) avpicture_alloc((AVPicture *) av_frame, pix_fmt, width, height) diff --git a/src/FFmpegWriter.cpp b/src/FFmpegWriter.cpp index 37f3016a..9d77746d 100644 --- a/src/FFmpegWriter.cpp +++ b/src/FFmpegWriter.cpp @@ -525,9 +525,7 @@ void FFmpegWriter::WriteHeader() { } // Force the output filename (which doesn't always happen for some reason) - snprintf(oc->AV_FILENAME, sizeof(oc->AV_FILENAME), "%s", path.c_str()); - - // Write the stream header, if any + AV_SET_FILENAME(oc, path.c_str()); // Add general metadata (if any) for (std::map::iterator iter = info.metadata.begin(); iter != info.metadata.end(); ++iter) { @@ -543,6 +541,7 @@ void FFmpegWriter::WriteHeader() { if (is_mp4 || is_mov) av_dict_copy(&dict, mux_dict, 0); + // Write the stream header if (avformat_write_header(oc, &dict) != 0) { throw InvalidFile("Could not write header to file.", path); }; From 59fe41714100fac3058343b8dddbc67748b1d850 Mon Sep 17 00:00:00 2001 From: SuslikV Date: Thu, 8 Aug 2019 16:46:07 +0300 Subject: [PATCH 42/43] Unify indentation of the code strings --- include/FFmpegUtilities.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/FFmpegUtilities.h b/include/FFmpegUtilities.h index 0ccf1ca1..c673305e 100644 --- a/include/FFmpegUtilities.h +++ b/include/FFmpegUtilities.h @@ -105,13 +105,13 @@ // Define this for compatibility #ifndef PixelFormat #define PixelFormat AVPixelFormat - #endif + #endif #ifndef PIX_FMT_RGBA #define PIX_FMT_RGBA AV_PIX_FMT_RGBA - #endif + #endif #ifndef PIX_FMT_NONE #define PIX_FMT_NONE AV_PIX_FMT_NONE - #endif + #endif #ifndef PIX_FMT_RGB24 #define PIX_FMT_RGB24 AV_PIX_FMT_RGB24 #endif @@ -154,7 +154,7 @@ #define AV_ALLOCATE_FRAME() av_frame_alloc() #define AV_ALLOCATE_IMAGE(av_frame, pix_fmt, width, height) av_image_alloc(av_frame->data, av_frame->linesize, width, height, pix_fmt, 1) #define AV_RESET_FRAME(av_frame) av_frame_unref(av_frame) - #define AV_FREE_FRAME(av_frame) av_frame_free(av_frame) + #define AV_FREE_FRAME(av_frame) av_frame_free(av_frame) #define AV_FREE_PACKET(av_packet) av_packet_unref(av_packet) #define AV_FREE_CONTEXT(av_context) avcodec_free_context(&av_context) #define AV_GET_CODEC_TYPE(av_stream) av_stream->codecpar->codec_type @@ -190,7 +190,7 @@ #define AV_ALLOCATE_FRAME() av_frame_alloc() #define AV_ALLOCATE_IMAGE(av_frame, pix_fmt, width, height) av_image_alloc(av_frame->data, av_frame->linesize, width, height, pix_fmt, 1) #define AV_RESET_FRAME(av_frame) av_frame_unref(av_frame) - #define AV_FREE_FRAME(av_frame) av_frame_free(av_frame) + #define AV_FREE_FRAME(av_frame) av_frame_free(av_frame) #define AV_FREE_PACKET(av_packet) av_packet_unref(av_packet) #define AV_FREE_CONTEXT(av_context) avcodec_free_context(&av_context) #define AV_GET_CODEC_TYPE(av_stream) av_stream->codecpar->codec_type @@ -229,7 +229,7 @@ #define AV_ALLOCATE_FRAME() av_frame_alloc() #define AV_ALLOCATE_IMAGE(av_frame, pix_fmt, width, height) avpicture_alloc((AVPicture *) av_frame, pix_fmt, width, height) #define AV_RESET_FRAME(av_frame) av_frame_unref(av_frame) - #define AV_FREE_FRAME(av_frame) av_frame_free(av_frame) + #define AV_FREE_FRAME(av_frame) av_frame_free(av_frame) #define AV_FREE_PACKET(av_packet) av_packet_unref(av_packet) #define AV_FREE_CONTEXT(av_context) avcodec_close(av_context) #define AV_GET_CODEC_TYPE(av_stream) av_stream->codec->codec_type From dfbcb4730bbea7673e4099dcf8d18a2366b50e2a Mon Sep 17 00:00:00 2001 From: SuslikV Date: Mon, 12 Aug 2019 14:09:26 +0300 Subject: [PATCH 43/43] Disable debug logger on close The logger can be closed from the external thread (openshot-qt), while same logger instance is still in use in libopenshot. This change prevents crash on attempts to use debug logger if it was closed. Co-authored-by: Frank Dana --- src/ZmqLogger.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ZmqLogger.cpp b/src/ZmqLogger.cpp index 0aeeab22..89d2798a 100644 --- a/src/ZmqLogger.cpp +++ b/src/ZmqLogger.cpp @@ -160,6 +160,9 @@ void ZmqLogger::Path(string new_path) void ZmqLogger::Close() { + // Disable logger as it no longer needed + enabled = false; + // Close file (if already open) if (log_file.is_open()) log_file.close();