You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Merge branch 'develop' into ffmpeg-targets
This commit is contained in:
@@ -92,14 +92,18 @@ ENDIF(WIN32)
|
||||
set(QT_HEADER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include/Qt)
|
||||
FILE(GLOB QT_HEADER_FILES "${QT_HEADER_DIR}/*.h")
|
||||
|
||||
############## PROCESS SUB-DIRECTORIES ##############
|
||||
############## PROCESS src/ DIRECTORIES ##############
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(tests)
|
||||
|
||||
################### DOCUMENTATION ###################
|
||||
# Find Doxygen (used for documentation)
|
||||
include(cmake/Modules/UseDoxygen.cmake)
|
||||
|
||||
# Doxygen was found
|
||||
if (TARGET doc)
|
||||
message(STATUS "Doxygen found, documentation target enabled")
|
||||
message("\nTo compile documentation in doc/html, run: 'make doc'")
|
||||
|
||||
# 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)\")")
|
||||
@@ -108,3 +112,8 @@ 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
|
||||
endif()
|
||||
|
||||
############# PROCESS tests/ DIRECTORY ##############
|
||||
add_subdirectory(tests)
|
||||
|
||||
|
||||
@@ -1,294 +0,0 @@
|
||||
#.rst:
|
||||
# FindPythonLibs
|
||||
# --------------
|
||||
#
|
||||
# Find python libraries
|
||||
#
|
||||
# This module finds if Python is installed and determines where the
|
||||
# include files and libraries are. It also determines what the name of
|
||||
# the library is. This code sets the following variables:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# PYTHONLIBS_FOUND - have the Python libs been found
|
||||
# PYTHON_LIBRARIES - path to the python library
|
||||
# PYTHON_INCLUDE_PATH - path to where Python.h is found (deprecated)
|
||||
# PYTHON_INCLUDE_DIRS - path to where Python.h is found
|
||||
# PYTHON_DEBUG_LIBRARIES - path to the debug library (deprecated)
|
||||
# PYTHONLIBS_VERSION_STRING - version of the Python libs found (since CMake 2.8.8)
|
||||
#
|
||||
#
|
||||
#
|
||||
# The Python_ADDITIONAL_VERSIONS variable can be used to specify a list
|
||||
# of version numbers that should be taken into account when searching
|
||||
# for Python. You need to set this variable before calling
|
||||
# find_package(PythonLibs).
|
||||
#
|
||||
# If you'd like to specify the installation of Python to use, you should
|
||||
# modify the following cache variables:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# PYTHON_LIBRARY - path to the python library
|
||||
# PYTHON_INCLUDE_DIR - path to where Python.h is found
|
||||
#
|
||||
# If also calling find_package(PythonInterp), call find_package(PythonInterp)
|
||||
# first to get the currently active Python version by default with a consistent
|
||||
# version of PYTHON_LIBRARIES.
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2001-2009 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
include(CMakeFindFrameworks)
|
||||
# Search for the python framework on Apple.
|
||||
CMAKE_FIND_FRAMEWORKS(Python)
|
||||
|
||||
set(_PYTHON1_VERSIONS 1.6 1.5)
|
||||
set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0)
|
||||
set(_PYTHON3_VERSIONS 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0)
|
||||
|
||||
if(PythonLibs_FIND_VERSION)
|
||||
if(PythonLibs_FIND_VERSION_COUNT GREATER 1)
|
||||
set(_PYTHON_FIND_MAJ_MIN "${PythonLibs_FIND_VERSION_MAJOR}.${PythonLibs_FIND_VERSION_MINOR}")
|
||||
unset(_PYTHON_FIND_OTHER_VERSIONS)
|
||||
if(PythonLibs_FIND_VERSION_EXACT)
|
||||
if(_PYTHON_FIND_MAJ_MIN STREQUAL PythonLibs_FIND_VERSION)
|
||||
set(_PYTHON_FIND_OTHER_VERSIONS "${PythonLibs_FIND_VERSION}")
|
||||
else()
|
||||
set(_PYTHON_FIND_OTHER_VERSIONS "${PythonLibs_FIND_VERSION}" "${_PYTHON_FIND_MAJ_MIN}")
|
||||
endif()
|
||||
else()
|
||||
foreach(_PYTHON_V ${_PYTHON${PythonLibs_FIND_VERSION_MAJOR}_VERSIONS})
|
||||
if(NOT _PYTHON_V VERSION_LESS _PYTHON_FIND_MAJ_MIN)
|
||||
list(APPEND _PYTHON_FIND_OTHER_VERSIONS ${_PYTHON_V})
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
unset(_PYTHON_FIND_MAJ_MIN)
|
||||
else()
|
||||
set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON${PythonLibs_FIND_VERSION_MAJOR}_VERSIONS})
|
||||
endif()
|
||||
else()
|
||||
set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS})
|
||||
endif()
|
||||
|
||||
# Set up the versions we know about, in the order we will search. Always add
|
||||
# the user supplied additional versions to the front.
|
||||
# If FindPythonInterp has already found the major and minor version,
|
||||
# insert that version between the user supplied versions and the stock
|
||||
# version list.
|
||||
set(_Python_VERSIONS ${Python_ADDITIONAL_VERSIONS})
|
||||
if(DEFINED PYTHON_VERSION_MAJOR AND DEFINED PYTHON_VERSION_MINOR)
|
||||
list(APPEND _Python_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
|
||||
endif()
|
||||
list(APPEND _Python_VERSIONS ${_PYTHON_FIND_OTHER_VERSIONS})
|
||||
|
||||
unset(_PYTHON_FIND_OTHER_VERSIONS)
|
||||
unset(_PYTHON1_VERSIONS)
|
||||
unset(_PYTHON2_VERSIONS)
|
||||
unset(_PYTHON3_VERSIONS)
|
||||
|
||||
foreach(_CURRENT_VERSION ${_Python_VERSIONS})
|
||||
string(REPLACE "." "" _CURRENT_VERSION_NO_DOTS ${_CURRENT_VERSION})
|
||||
if(WIN32)
|
||||
find_library(PYTHON_DEBUG_LIBRARY
|
||||
NAMES python${_CURRENT_VERSION_NO_DOTS}_d python
|
||||
PATHS
|
||||
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug
|
||||
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug
|
||||
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs
|
||||
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs
|
||||
)
|
||||
endif()
|
||||
|
||||
find_library(PYTHON_LIBRARY
|
||||
NAMES
|
||||
python${_CURRENT_VERSION_NO_DOTS}
|
||||
python${_CURRENT_VERSION}mu
|
||||
python${_CURRENT_VERSION}m
|
||||
python${_CURRENT_VERSION}u
|
||||
python${_CURRENT_VERSION}
|
||||
PATHS
|
||||
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs
|
||||
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs
|
||||
# Avoid finding the .dll in the PATH. We want the .lib.
|
||||
NO_SYSTEM_ENVIRONMENT_PATH
|
||||
)
|
||||
# Look for the static library in the Python config directory
|
||||
find_library(PYTHON_LIBRARY
|
||||
NAMES python${_CURRENT_VERSION_NO_DOTS} python${_CURRENT_VERSION}
|
||||
# Avoid finding the .dll in the PATH. We want the .lib.
|
||||
NO_SYSTEM_ENVIRONMENT_PATH
|
||||
# This is where the static library is usually located
|
||||
PATH_SUFFIXES python${_CURRENT_VERSION}/config
|
||||
)
|
||||
|
||||
# For backward compatibility, honour value of PYTHON_INCLUDE_PATH, if
|
||||
# PYTHON_INCLUDE_DIR is not set.
|
||||
if(DEFINED PYTHON_INCLUDE_PATH AND NOT DEFINED PYTHON_INCLUDE_DIR)
|
||||
set(PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_PATH}" CACHE PATH
|
||||
"Path to where Python.h is found" FORCE)
|
||||
endif()
|
||||
|
||||
set(PYTHON_FRAMEWORK_INCLUDES)
|
||||
if(Python_FRAMEWORKS AND NOT PYTHON_INCLUDE_DIR)
|
||||
foreach(dir ${Python_FRAMEWORKS})
|
||||
set(PYTHON_FRAMEWORK_INCLUDES ${PYTHON_FRAMEWORK_INCLUDES}
|
||||
${dir}/Versions/${_CURRENT_VERSION}/include/python${_CURRENT_VERSION})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
find_path(PYTHON_INCLUDE_DIR
|
||||
NAMES Python.h
|
||||
PATHS
|
||||
${PYTHON_FRAMEWORK_INCLUDES}
|
||||
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include
|
||||
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include
|
||||
PATH_SUFFIXES
|
||||
python${_CURRENT_VERSION}mu
|
||||
python${_CURRENT_VERSION}m
|
||||
python${_CURRENT_VERSION}u
|
||||
python${_CURRENT_VERSION}
|
||||
)
|
||||
|
||||
# For backward compatibility, set PYTHON_INCLUDE_PATH.
|
||||
set(PYTHON_INCLUDE_PATH "${PYTHON_INCLUDE_DIR}")
|
||||
|
||||
if(PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}/patchlevel.h")
|
||||
file(STRINGS "${PYTHON_INCLUDE_DIR}/patchlevel.h" python_version_str
|
||||
REGEX "^#define[ \t]+PY_VERSION[ \t]+\"[^\"]+\"")
|
||||
string(REGEX REPLACE "^#define[ \t]+PY_VERSION[ \t]+\"([^\"]+)\".*" "\\1"
|
||||
PYTHONLIBS_VERSION_STRING "${python_version_str}")
|
||||
unset(python_version_str)
|
||||
endif()
|
||||
|
||||
if(PYTHON_LIBRARY AND PYTHON_INCLUDE_DIR)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
mark_as_advanced(
|
||||
PYTHON_DEBUG_LIBRARY
|
||||
PYTHON_LIBRARY
|
||||
PYTHON_INCLUDE_DIR
|
||||
)
|
||||
|
||||
# We use PYTHON_INCLUDE_DIR, PYTHON_LIBRARY and PYTHON_DEBUG_LIBRARY for the
|
||||
# cache entries because they are meant to specify the location of a single
|
||||
# library. We now set the variables listed by the documentation for this
|
||||
# module.
|
||||
set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
|
||||
set(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}")
|
||||
|
||||
# These variables have been historically named in this module different from
|
||||
# what SELECT_LIBRARY_CONFIGURATIONS() expects.
|
||||
set(PYTHON_LIBRARY_DEBUG "${PYTHON_DEBUG_LIBRARY}")
|
||||
set(PYTHON_LIBRARY_RELEASE "${PYTHON_LIBRARY}")
|
||||
include(SelectLibraryConfigurations)
|
||||
SELECT_LIBRARY_CONFIGURATIONS(PYTHON)
|
||||
# SELECT_LIBRARY_CONFIGURATIONS() sets ${PREFIX}_FOUND if it has a library.
|
||||
# Unset this, this prefix doesn't match the module prefix, they are different
|
||||
# for historical reasons.
|
||||
unset(PYTHON_FOUND)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonLibs
|
||||
REQUIRED_VARS PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS
|
||||
VERSION_VAR PYTHONLIBS_VERSION_STRING)
|
||||
|
||||
# PYTHON_ADD_MODULE(<name> src1 src2 ... srcN) is used to build modules for python.
|
||||
# PYTHON_WRITE_MODULES_HEADER(<filename>) writes a header file you can include
|
||||
# in your sources to initialize the static python modules
|
||||
function(PYTHON_ADD_MODULE _NAME )
|
||||
get_property(_TARGET_SUPPORTS_SHARED_LIBS
|
||||
GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
|
||||
option(PYTHON_ENABLE_MODULE_${_NAME} "Add module ${_NAME}" TRUE)
|
||||
option(PYTHON_MODULE_${_NAME}_BUILD_SHARED
|
||||
"Add module ${_NAME} shared" ${_TARGET_SUPPORTS_SHARED_LIBS})
|
||||
|
||||
# Mark these options as advanced
|
||||
mark_as_advanced(PYTHON_ENABLE_MODULE_${_NAME}
|
||||
PYTHON_MODULE_${_NAME}_BUILD_SHARED)
|
||||
|
||||
if(PYTHON_ENABLE_MODULE_${_NAME})
|
||||
if(PYTHON_MODULE_${_NAME}_BUILD_SHARED)
|
||||
set(PY_MODULE_TYPE MODULE)
|
||||
else()
|
||||
set(PY_MODULE_TYPE STATIC)
|
||||
set_property(GLOBAL APPEND PROPERTY PY_STATIC_MODULES_LIST ${_NAME})
|
||||
endif()
|
||||
|
||||
set_property(GLOBAL APPEND PROPERTY PY_MODULES_LIST ${_NAME})
|
||||
add_library(${_NAME} ${PY_MODULE_TYPE} ${ARGN})
|
||||
# target_link_libraries(${_NAME} ${PYTHON_LIBRARIES})
|
||||
|
||||
if(PYTHON_MODULE_${_NAME}_BUILD_SHARED)
|
||||
set_target_properties(${_NAME} PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}")
|
||||
if(WIN32 AND NOT CYGWIN)
|
||||
set_target_properties(${_NAME} PROPERTIES SUFFIX ".pyd")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(PYTHON_WRITE_MODULES_HEADER _filename)
|
||||
|
||||
get_property(PY_STATIC_MODULES_LIST GLOBAL PROPERTY PY_STATIC_MODULES_LIST)
|
||||
|
||||
get_filename_component(_name "${_filename}" NAME)
|
||||
string(REPLACE "." "_" _name "${_name}")
|
||||
string(TOUPPER ${_name} _nameUpper)
|
||||
set(_filename ${CMAKE_CURRENT_BINARY_DIR}/${_filename})
|
||||
|
||||
set(_filenameTmp "${_filename}.in")
|
||||
file(WRITE ${_filenameTmp} "/*Created by cmake, do not edit, changes will be lost*/\n")
|
||||
file(APPEND ${_filenameTmp}
|
||||
"#ifndef ${_nameUpper}
|
||||
#define ${_nameUpper}
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern \"C\" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
")
|
||||
|
||||
foreach(_currentModule ${PY_STATIC_MODULES_LIST})
|
||||
file(APPEND ${_filenameTmp} "extern void init${PYTHON_MODULE_PREFIX}${_currentModule}(void);\n\n")
|
||||
endforeach()
|
||||
|
||||
file(APPEND ${_filenameTmp}
|
||||
"#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
")
|
||||
|
||||
|
||||
foreach(_currentModule ${PY_STATIC_MODULES_LIST})
|
||||
file(APPEND ${_filenameTmp} "int ${_name}_${_currentModule}(void) \n{\n static char name[]=\"${PYTHON_MODULE_PREFIX}${_currentModule}\"; return PyImport_AppendInittab(name, init${PYTHON_MODULE_PREFIX}${_currentModule});\n}\n\n")
|
||||
endforeach()
|
||||
|
||||
file(APPEND ${_filenameTmp} "void ${_name}_LoadAllPythonModules(void)\n{\n")
|
||||
foreach(_currentModule ${PY_STATIC_MODULES_LIST})
|
||||
file(APPEND ${_filenameTmp} " ${_name}_${_currentModule}();\n")
|
||||
endforeach()
|
||||
file(APPEND ${_filenameTmp} "}\n\n")
|
||||
file(APPEND ${_filenameTmp} "#ifndef EXCLUDE_LOAD_ALL_FUNCTION\nvoid CMakeLoadAllPythonModules(void)\n{\n ${_name}_LoadAllPythonModules();\n}\n#endif\n\n#endif\n")
|
||||
|
||||
# with configure_file() cmake complains that you may not use a file created using file(WRITE) as input file for configure_file()
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_filenameTmp}" "${_filename}" OUTPUT_QUIET ERROR_QUIET)
|
||||
|
||||
endfunction()
|
||||
@@ -61,6 +61,14 @@ namespace openshot {
|
||||
int64_t frame_number;
|
||||
int64_t chunk_number;
|
||||
int64_t chunk_frame;
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param message A message to accompany the exception
|
||||
* @param frame_number The frame number being processed
|
||||
* @param chunk_number The chunk requested
|
||||
* @param chunk_frame The 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() noexcept {}
|
||||
@@ -71,6 +79,11 @@ namespace openshot {
|
||||
class DecklinkError : public BaseException
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param message A message to accompany the exception
|
||||
*/
|
||||
DecklinkError(std::string message)
|
||||
: BaseException(message) { }
|
||||
virtual ~DecklinkError() noexcept {}
|
||||
@@ -81,6 +94,12 @@ namespace openshot {
|
||||
{
|
||||
public:
|
||||
int64_t frame_number;
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param message A message to accompany the exception
|
||||
* @param frame_number The frame number being processed
|
||||
*/
|
||||
ErrorDecodingAudio(std::string message, int64_t frame_number)
|
||||
: BaseException(message), frame_number(frame_number) { }
|
||||
virtual ~ErrorDecodingAudio() noexcept {}
|
||||
@@ -91,6 +110,12 @@ namespace openshot {
|
||||
{
|
||||
public:
|
||||
int64_t frame_number;
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param message A message to accompany the exception
|
||||
* @param frame_number The frame number being processed
|
||||
*/
|
||||
ErrorEncodingAudio(std::string message, int64_t frame_number)
|
||||
: BaseException(message), frame_number(frame_number) { }
|
||||
virtual ~ErrorEncodingAudio() noexcept {}
|
||||
@@ -101,6 +126,12 @@ namespace openshot {
|
||||
{
|
||||
public:
|
||||
int64_t frame_number;
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param message A message to accompany the exception
|
||||
* @param frame_number The frame number being processed
|
||||
*/
|
||||
ErrorEncodingVideo(std::string message, int64_t frame_number)
|
||||
: BaseException(message), frame_number(frame_number) { }
|
||||
virtual ~ErrorEncodingVideo() noexcept {}
|
||||
@@ -111,7 +142,13 @@ namespace openshot {
|
||||
{
|
||||
public:
|
||||
std::string file_path;
|
||||
InvalidChannels(std::string message, std::string file_path)
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param message A message to accompany the exception
|
||||
* @param file_path (optional) The input file being processed
|
||||
*/
|
||||
InvalidChannels(std::string message, std::string file_path="")
|
||||
: BaseException(message), file_path(file_path) { }
|
||||
virtual ~InvalidChannels() noexcept {}
|
||||
};
|
||||
@@ -121,7 +158,13 @@ namespace openshot {
|
||||
{
|
||||
public:
|
||||
std::string file_path;
|
||||
InvalidCodec(std::string message, std::string file_path)
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param message A message to accompany the exception
|
||||
* @param file_path (optional) The input file being processed
|
||||
*/
|
||||
InvalidCodec(std::string message, std::string file_path="")
|
||||
: BaseException(message), file_path(file_path) { }
|
||||
virtual ~InvalidCodec() noexcept {}
|
||||
};
|
||||
@@ -131,6 +174,12 @@ namespace openshot {
|
||||
{
|
||||
public:
|
||||
std::string file_path;
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param message A message to accompany the exception
|
||||
* @param file_path The input file being processed
|
||||
*/
|
||||
InvalidFile(std::string message, std::string file_path)
|
||||
: BaseException(message), file_path(file_path) { }
|
||||
virtual ~InvalidFile() noexcept {}
|
||||
@@ -141,7 +190,13 @@ namespace openshot {
|
||||
{
|
||||
public:
|
||||
std::string file_path;
|
||||
InvalidFormat(std::string message, std::string file_path)
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param message A message to accompany the exception
|
||||
* @param file_path (optional) The input file being processed
|
||||
*/
|
||||
InvalidFormat(std::string message, std::string file_path="")
|
||||
: BaseException(message), file_path(file_path) { }
|
||||
virtual ~InvalidFormat() noexcept {}
|
||||
};
|
||||
@@ -151,7 +206,13 @@ namespace openshot {
|
||||
{
|
||||
public:
|
||||
std::string file_path;
|
||||
InvalidJSON(std::string message, std::string file_path)
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param message A message to accompany the exception
|
||||
* @param file_path (optional) The input file being processed
|
||||
*/
|
||||
InvalidJSON(std::string message, std::string file_path="")
|
||||
: BaseException(message), file_path(file_path) { }
|
||||
virtual ~InvalidJSON() noexcept {}
|
||||
};
|
||||
@@ -161,7 +222,13 @@ namespace openshot {
|
||||
{
|
||||
public:
|
||||
std::string file_path;
|
||||
InvalidOptions(std::string message, std::string file_path)
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param message A message to accompany the exception
|
||||
* @param file_path (optional) The input file being processed
|
||||
*/
|
||||
InvalidOptions(std::string message, std::string file_path="")
|
||||
: BaseException(message), file_path(file_path) { }
|
||||
virtual ~InvalidOptions() noexcept {}
|
||||
};
|
||||
@@ -171,7 +238,13 @@ namespace openshot {
|
||||
{
|
||||
public:
|
||||
std::string file_path;
|
||||
InvalidSampleRate(std::string message, std::string file_path)
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param message A message to accompany the exception
|
||||
* @param file_path (optional) The input file being processed
|
||||
*/
|
||||
InvalidSampleRate(std::string message, std::string file_path="")
|
||||
: BaseException(message), file_path(file_path) { }
|
||||
virtual ~InvalidSampleRate() noexcept {}
|
||||
};
|
||||
@@ -181,6 +254,12 @@ namespace openshot {
|
||||
{
|
||||
public:
|
||||
std::string json;
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param message A message to accompany the exception
|
||||
* @param json The json data being processed
|
||||
*/
|
||||
InvalidJSONKey(std::string message, std::string json)
|
||||
: BaseException(message), json(json) { }
|
||||
virtual ~InvalidJSONKey() noexcept {}
|
||||
@@ -191,7 +270,13 @@ namespace openshot {
|
||||
{
|
||||
public:
|
||||
std::string file_path;
|
||||
NoStreamsFound(std::string message, std::string file_path)
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param message A message to accompany the exception
|
||||
* @param file_path (optional) The input file being processed
|
||||
*/
|
||||
NoStreamsFound(std::string message, std::string file_path="")
|
||||
: BaseException(message), file_path(file_path) { }
|
||||
virtual ~NoStreamsFound() noexcept {}
|
||||
};
|
||||
@@ -202,6 +287,13 @@ namespace openshot {
|
||||
public:
|
||||
int64_t FrameRequested;
|
||||
int64_t MaxFrames;
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param message A message to accompany the exception
|
||||
* @param frame_requested The out-of-bounds frame number requested
|
||||
* @param max_frames The maximum available frame number
|
||||
*/
|
||||
OutOfBoundsFrame(std::string message, int64_t frame_requested, int64_t max_frames)
|
||||
: BaseException(message), FrameRequested(frame_requested), MaxFrames(max_frames) { }
|
||||
virtual ~OutOfBoundsFrame() noexcept {}
|
||||
@@ -213,6 +305,13 @@ namespace openshot {
|
||||
public:
|
||||
int PointRequested;
|
||||
int MaxPoints;
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param message A message to accompany the exception
|
||||
* @param point_requested The out-of-bounds point requested
|
||||
* @param max_points The maximum available point value
|
||||
*/
|
||||
OutOfBoundsPoint(std::string message, int point_requested, int max_points)
|
||||
: BaseException(message), PointRequested(point_requested), MaxPoints(max_points) { }
|
||||
virtual ~OutOfBoundsPoint() noexcept {}
|
||||
@@ -223,7 +322,13 @@ namespace openshot {
|
||||
{
|
||||
public:
|
||||
std::string file_path;
|
||||
OutOfMemory(std::string message, std::string file_path)
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param message A message to accompany the exception
|
||||
* @param file_path (optional) The input file being processed
|
||||
*/
|
||||
OutOfMemory(std::string message, std::string file_path="")
|
||||
: BaseException(message), file_path(file_path) { }
|
||||
virtual ~OutOfMemory() noexcept {}
|
||||
};
|
||||
@@ -233,7 +338,13 @@ namespace openshot {
|
||||
{
|
||||
public:
|
||||
std::string file_path;
|
||||
ReaderClosed(std::string message, std::string file_path)
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param message A message to accompany the exception
|
||||
* @param file_path (optional) The input file being processed
|
||||
*/
|
||||
ReaderClosed(std::string message, std::string file_path="")
|
||||
: BaseException(message), file_path(file_path) { }
|
||||
virtual ~ReaderClosed() noexcept {}
|
||||
};
|
||||
@@ -243,7 +354,13 @@ namespace openshot {
|
||||
{
|
||||
public:
|
||||
std::string file_path;
|
||||
ResampleError(std::string message, std::string file_path)
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param message A message to accompany the exception
|
||||
* @param file_path (optional) The input file being processed
|
||||
*/
|
||||
ResampleError(std::string message, std::string file_path="")
|
||||
: BaseException(message), file_path(file_path) { }
|
||||
virtual ~ResampleError() noexcept {}
|
||||
};
|
||||
@@ -253,7 +370,13 @@ namespace openshot {
|
||||
{
|
||||
public:
|
||||
std::string file_path;
|
||||
TooManySeeks(std::string message, std::string file_path)
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param message A message to accompany the exception
|
||||
* @param file_path (optional) The input file being processed
|
||||
*/
|
||||
TooManySeeks(std::string message, std::string file_path="")
|
||||
: BaseException(message), file_path(file_path) { }
|
||||
virtual ~TooManySeeks() noexcept {}
|
||||
};
|
||||
@@ -263,7 +386,13 @@ namespace openshot {
|
||||
{
|
||||
public:
|
||||
std::string file_path;
|
||||
WriterClosed(std::string message, std::string file_path)
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param message A message to accompany the exception
|
||||
* @param file_path (optional) The output file being written
|
||||
*/
|
||||
WriterClosed(std::string message, std::string file_path="")
|
||||
: BaseException(message), file_path(file_path) { }
|
||||
virtual ~WriterClosed() noexcept {}
|
||||
};
|
||||
|
||||
@@ -43,36 +43,28 @@
|
||||
#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 <sstream>
|
||||
using namespace std;
|
||||
|
||||
namespace openshot
|
||||
{
|
||||
/// This struct holds version number information. Use the GetVersion() method to access the current version of libopenshot.
|
||||
struct OpenShotVersion {
|
||||
int major; /// Major version number
|
||||
int minor; /// Minor version number
|
||||
int build; /// Build number
|
||||
int so; /// Shared Object Number (incremented when API or ABI changes)
|
||||
static const int Major = OPENSHOT_VERSION_MAJOR; /// Major version number
|
||||
static const int Minor = OPENSHOT_VERSION_MINOR; /// Minor version number
|
||||
static const int Build = OPENSHOT_VERSION_BUILD; /// Build number
|
||||
static const int So = OPENSHOT_VERSION_SO; /// Shared Object Number (incremented when API or ABI changes)
|
||||
|
||||
/// Get a string version of the version (i.e. "Major.Minor.Build")
|
||||
string ToString() {
|
||||
stringstream version_string;
|
||||
version_string << major << "." << minor << "." << build;
|
||||
inline static const std::string ToString() {
|
||||
std::stringstream version_string;
|
||||
version_string << Major << "." << Minor << "." << Build;
|
||||
return version_string.str();
|
||||
}
|
||||
};
|
||||
|
||||
static const openshot::OpenShotVersion Version;
|
||||
|
||||
/// Get the current version number of libopenshot (major, minor, and build number)
|
||||
static OpenShotVersion GetVersion() {
|
||||
OpenShotVersion version;
|
||||
|
||||
// Set version info
|
||||
version.major = OPENSHOT_VERSION_MAJOR;
|
||||
version.minor = OPENSHOT_VERSION_MINOR;
|
||||
version.build = OPENSHOT_VERSION_BUILD;
|
||||
version.so = OPENSHOT_VERSION_SO;
|
||||
|
||||
return version;
|
||||
}
|
||||
openshot::OpenShotVersion GetVersion();
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // OPENSHOT_VERSION_H
|
||||
@@ -67,7 +67,7 @@ namespace openshot
|
||||
class QtImageReader : public ReaderBase
|
||||
{
|
||||
private:
|
||||
string path;
|
||||
QString path;
|
||||
std::shared_ptr<QImage> image; ///> Original image (full quality)
|
||||
std::shared_ptr<QImage> cached_image; ///> Scaled for performance
|
||||
bool is_open; ///> Is Reader opened
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#
|
||||
# Copyright (c) 2008-2019 OpenShot Studios, LLC
|
||||
# <http://www.openshotstudios.com/>. This file is part of
|
||||
# OpenShot Library (libopenshot), an open-source project dedicated to
|
||||
# delivering high quality video editing and animation solutions to the
|
||||
# OpenShot Library (libopenshot), an open-source project dedicated to
|
||||
# delivering high quality video editing and animation solutions to the
|
||||
# world. For more information visit <http://www.openshot.org/>.
|
||||
#
|
||||
# OpenShot Library (libopenshot) is free software: you can redistribute it
|
||||
@@ -128,7 +128,7 @@ IF (ENABLE_BLACKMAGIC)
|
||||
FIND_PACKAGE(BlackMagic)
|
||||
|
||||
IF (BLACKMAGIC_FOUND)
|
||||
# Include headers (needed for compile)
|
||||
# Include Blackmagic headers (needed for compile)
|
||||
include_directories(${BLACKMAGIC_INCLUDE_DIR})
|
||||
|
||||
# define a global var (used in the C++)
|
||||
@@ -138,20 +138,19 @@ IF (ENABLE_BLACKMAGIC)
|
||||
ENDIF (BLACKMAGIC_FOUND)
|
||||
ENDIF (ENABLE_BLACKMAGIC)
|
||||
|
||||
################### OPENMP #####################
|
||||
# Check for OpenMP (used for multi-core processing)
|
||||
FIND_PACKAGE(OpenMP)
|
||||
|
||||
if (OPENMP_FOUND)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} ")
|
||||
endif(OPENMP_FOUND)
|
||||
|
||||
################### ZEROMQ #####################
|
||||
# Find ZeroMQ library (used for socket communication & logging)
|
||||
FIND_PACKAGE(ZMQ REQUIRED)
|
||||
|
||||
# Some platforms package the header-only cppzmq C++ bindings separately,
|
||||
# others (Ubuntu) bundle them in with libzmq itself
|
||||
find_package(cppzmq QUIET)
|
||||
find_package(ZMQ REQUIRED)
|
||||
|
||||
# Include ZeroMQ headers (needed for compile)
|
||||
include_directories(${ZMQ_INCLUDE_DIRS})
|
||||
if (cppzmq_FOUND)
|
||||
include_directories(${cppzmq_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
################### RESVG #####################
|
||||
# Find resvg library (used for rendering svg files)
|
||||
@@ -216,6 +215,7 @@ SET ( OPENSHOT_SOURCE_FILES
|
||||
Frame.cpp
|
||||
FrameMapper.cpp
|
||||
KeyFrame.cpp
|
||||
OpenShotVersion.cpp
|
||||
ZmqLogger.cpp
|
||||
PlayerBase.cpp
|
||||
Point.cpp
|
||||
@@ -273,6 +273,7 @@ set_target_properties(openshot
|
||||
INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib"
|
||||
)
|
||||
|
||||
|
||||
################### FFMPEG #####################
|
||||
# Find FFmpeg libraries (used for video encoding / decoding)
|
||||
FIND_PACKAGE(FFmpeg REQUIRED COMPONENTS avcodec avdevice avformat avutil swscale)
|
||||
@@ -283,6 +284,25 @@ foreach(ff_comp avcodec avdevice avformat avfilter avutil postproc swscale swres
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
################### OPENMP #####################
|
||||
# Check for OpenMP (used for multi-core processing)
|
||||
|
||||
# OpenMP is required by FFmpegReader/Writer
|
||||
find_package(OpenMP REQUIRED)
|
||||
|
||||
if(NOT TARGET OpenMP::OpenMP_CXX)
|
||||
# Older CMake versions (< 3.9) don't create find targets.
|
||||
add_library(OpenMP_TARGET INTERFACE)
|
||||
add_library(OpenMP::OpenMP_CXX ALIAS OpenMP_TARGET)
|
||||
target_compile_options(OpenMP_TARGET INTERFACE ${OpenMP_CXX_FLAGS})
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(OpenMP_TARGET INTERFACE Threads::Threads)
|
||||
target_link_libraries(OpenMP_TARGET INTERFACE ${OpenMP_CXX_FLAGS})
|
||||
endif()
|
||||
|
||||
target_link_libraries(openshot PUBLIC OpenMP::OpenMP_CXX)
|
||||
|
||||
|
||||
############### LINK LIBRARY #################
|
||||
SET ( REQUIRED_LIBRARIES
|
||||
${LIBOPENSHOT_AUDIO_LIBRARIES}
|
||||
@@ -296,9 +316,6 @@ IF (RESVG_FOUND)
|
||||
list(APPEND REQUIRED_LIBRARIES ${RESVG_LIBRARIES})
|
||||
ENDIF(RESVG_FOUND)
|
||||
|
||||
IF (OPENMP_FOUND)
|
||||
list(APPEND REQUIRED_LIBRARIES ${OpenMP_CXX_FLAGS})
|
||||
ENDIF (OPENMP_FOUND)
|
||||
|
||||
IF (ImageMagick_FOUND)
|
||||
list(APPEND REQUIRED_LIBRARIES ${ImageMagick_LIBRARIES})
|
||||
@@ -316,11 +333,21 @@ ENDIF(WIN32)
|
||||
# Link all referenced libraries
|
||||
target_link_libraries(openshot PUBLIC ${REQUIRED_LIBRARIES})
|
||||
|
||||
# Pick up parameters from OpenMP target and propagate
|
||||
target_link_libraries(openshot PUBLIC OpenMP::OpenMP_CXX)
|
||||
|
||||
############### CLI EXECUTABLE ################
|
||||
# Create test executable
|
||||
add_executable(openshot-example examples/Example.cpp)
|
||||
|
||||
# Define path to test input files
|
||||
SET(TEST_MEDIA_PATH "${PROJECT_SOURCE_DIR}/src/examples/")
|
||||
IF (WIN32)
|
||||
STRING(REPLACE "/" "\\\\" TEST_MEDIA_PATH TEST_MEDIA_PATH)
|
||||
ENDIF(WIN32)
|
||||
target_compile_definitions(openshot-example PRIVATE
|
||||
-DTEST_MEDIA_PATH="${TEST_MEDIA_PATH}" )
|
||||
|
||||
# Link test executable to the new library
|
||||
target_link_libraries(openshot-example openshot)
|
||||
|
||||
|
||||
@@ -519,7 +519,7 @@ void CacheDisk::SetJson(string value) {
|
||||
|
||||
if (!success)
|
||||
// Raise exception
|
||||
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
|
||||
throw InvalidJSON("JSON could not be parsed (or is invalid)");
|
||||
|
||||
try
|
||||
{
|
||||
@@ -529,7 +529,7 @@ void CacheDisk::SetJson(string value) {
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
// Error parsing JSON (or missing keys)
|
||||
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", "");
|
||||
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -372,7 +372,7 @@ void CacheMemory::SetJson(string value) {
|
||||
delete reader;
|
||||
if (!success)
|
||||
// Raise exception
|
||||
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
|
||||
throw InvalidJSON("JSON could not be parsed (or is invalid)");
|
||||
|
||||
try
|
||||
{
|
||||
@@ -382,7 +382,7 @@ void CacheMemory::SetJson(string value) {
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
// Error parsing JSON (or missing keys)
|
||||
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", "");
|
||||
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -292,7 +292,7 @@ void ChunkReader::SetJson(string value) {
|
||||
delete reader;
|
||||
if (!success)
|
||||
// Raise exception
|
||||
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
|
||||
throw InvalidJSON("JSON could not be parsed (or is invalid)");
|
||||
|
||||
try
|
||||
{
|
||||
@@ -302,7 +302,7 @@ void ChunkReader::SetJson(string value) {
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
// Error parsing JSON (or missing keys)
|
||||
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", "");
|
||||
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
16
src/Clip.cpp
16
src/Clip.cpp
@@ -235,7 +235,7 @@ ReaderBase* Clip::Reader()
|
||||
return reader;
|
||||
else
|
||||
// Throw error if reader not initialized
|
||||
throw ReaderClosed("No Reader has been initialized for this Clip. Call Reader(*reader) before calling this method.", "");
|
||||
throw ReaderClosed("No Reader has been initialized for this Clip. Call Reader(*reader) before calling this method.");
|
||||
}
|
||||
|
||||
// Open the internal reader
|
||||
@@ -252,7 +252,7 @@ void Clip::Open()
|
||||
}
|
||||
else
|
||||
// Throw error if reader not initialized
|
||||
throw ReaderClosed("No Reader has been initialized for this Clip. Call Reader(*reader) before calling this method.", "");
|
||||
throw ReaderClosed("No Reader has been initialized for this Clip. Call Reader(*reader) before calling this method.");
|
||||
}
|
||||
|
||||
// Close the internal reader
|
||||
@@ -266,7 +266,7 @@ void Clip::Close()
|
||||
}
|
||||
else
|
||||
// Throw error if reader not initialized
|
||||
throw ReaderClosed("No Reader has been initialized for this Clip. Call Reader(*reader) before calling this method.", "");
|
||||
throw ReaderClosed("No Reader has been initialized for this Clip. Call Reader(*reader) before calling this method.");
|
||||
}
|
||||
|
||||
// Get end position of clip (trim end of video), which can be affected by the time curve.
|
||||
@@ -282,7 +282,7 @@ float Clip::End()
|
||||
fps = reader->info.fps.ToFloat();
|
||||
else
|
||||
// Throw error if reader not initialized
|
||||
throw ReaderClosed("No Reader has been initialized for this Clip. Call Reader(*reader) before calling this method.", "");
|
||||
throw ReaderClosed("No Reader has been initialized for this Clip. Call Reader(*reader) before calling this method.");
|
||||
|
||||
return float(time.GetLength()) / fps;
|
||||
}
|
||||
@@ -350,7 +350,7 @@ std::shared_ptr<Frame> Clip::GetFrame(int64_t requested_frame)
|
||||
}
|
||||
else
|
||||
// Throw error if reader not initialized
|
||||
throw ReaderClosed("No Reader has been initialized for this Clip. Call Reader(*reader) before calling this method.", "");
|
||||
throw ReaderClosed("No Reader has been initialized for this Clip. Call Reader(*reader) before calling this method.");
|
||||
}
|
||||
|
||||
// Get file extension
|
||||
@@ -394,7 +394,7 @@ void Clip::get_time_mapped_frame(std::shared_ptr<Frame> frame, int64_t frame_num
|
||||
// Check for valid reader
|
||||
if (!reader)
|
||||
// Throw error if reader not initialized
|
||||
throw ReaderClosed("No Reader has been initialized for this Clip. Call Reader(*reader) before calling this method.", "");
|
||||
throw ReaderClosed("No Reader has been initialized for this Clip. Call Reader(*reader) before calling this method.");
|
||||
|
||||
// Check for a valid time map curve
|
||||
if (time.Values.size() > 1)
|
||||
@@ -812,7 +812,7 @@ void Clip::SetJson(string value) {
|
||||
|
||||
if (!success)
|
||||
// Raise exception
|
||||
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
|
||||
throw InvalidJSON("JSON could not be parsed (or is invalid)");
|
||||
|
||||
try
|
||||
{
|
||||
@@ -822,7 +822,7 @@ void Clip::SetJson(string value) {
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
// Error parsing JSON (or missing keys)
|
||||
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", "");
|
||||
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ void Color::SetJson(string value) {
|
||||
|
||||
if (!success)
|
||||
// Raise exception
|
||||
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
|
||||
throw InvalidJSON("JSON could not be parsed (or is invalid)");
|
||||
|
||||
try
|
||||
{
|
||||
@@ -130,7 +130,7 @@ void Color::SetJson(string value) {
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
// Error parsing JSON (or missing keys)
|
||||
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", "");
|
||||
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ void Coordinate::SetJson(string value) {
|
||||
|
||||
if (!success)
|
||||
// Raise exception
|
||||
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
|
||||
throw InvalidJSON("JSON could not be parsed (or is invalid)");
|
||||
|
||||
try
|
||||
{
|
||||
@@ -93,7 +93,7 @@ void Coordinate::SetJson(string value) {
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
// Error parsing JSON (or missing keys)
|
||||
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", "");
|
||||
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -278,7 +278,7 @@ void DecklinkReader::SetJson(string value) {
|
||||
|
||||
if (!success)
|
||||
// Raise exception
|
||||
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
|
||||
throw InvalidJSON("JSON could not be parsed (or is invalid)");
|
||||
|
||||
try
|
||||
{
|
||||
@@ -288,7 +288,7 @@ void DecklinkReader::SetJson(string value) {
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
// Error parsing JSON (or missing keys)
|
||||
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", "");
|
||||
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -234,7 +234,7 @@ void DecklinkWriter::WriteFrame(std::shared_ptr<Frame> frame)
|
||||
{
|
||||
// Check for open reader (or throw exception)
|
||||
if (!is_open)
|
||||
throw WriterClosed("The DecklinkWriter is closed. Call Open() before calling this method.", "");
|
||||
throw WriterClosed("The DecklinkWriter is closed. Call Open() before calling this method.");
|
||||
|
||||
delegate->WriteFrame(frame);
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ void DummyReader::SetJson(string value) {
|
||||
|
||||
if (!success)
|
||||
// Raise exception
|
||||
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
|
||||
throw InvalidJSON("JSON could not be parsed (or is invalid)");
|
||||
|
||||
try
|
||||
{
|
||||
@@ -166,7 +166,7 @@ void DummyReader::SetJson(string value) {
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
// Error parsing JSON (or missing keys)
|
||||
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", "");
|
||||
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ void EffectBase::SetJson(string value) {
|
||||
|
||||
if (!success)
|
||||
// Raise exception
|
||||
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
|
||||
throw InvalidJSON("JSON could not be parsed (or is invalid)");
|
||||
|
||||
try
|
||||
{
|
||||
@@ -122,7 +122,7 @@ void EffectBase::SetJson(string value) {
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
// Error parsing JSON (or missing keys)
|
||||
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", "");
|
||||
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -309,7 +309,7 @@ void FFmpegReader::Open() {
|
||||
char *adapter_ptr = NULL;
|
||||
int adapter_num;
|
||||
adapter_num = openshot::Settings::Instance()->HW_DE_DEVICE_SET;
|
||||
fprintf(stderr, "\n\nDecodiing Device Nr: %d\n", adapter_num);
|
||||
fprintf(stderr, "Hardware decoding device number: %d\n", adapter_num);
|
||||
|
||||
// Set hardware pix format (callback)
|
||||
pCodecCtx->get_format = get_hw_dec_format;
|
||||
@@ -729,6 +729,33 @@ void FFmpegReader::UpdateVideoInfo() {
|
||||
info.display_ratio.num = size.num;
|
||||
info.display_ratio.den = size.den;
|
||||
|
||||
// Get scan type and order from codec context/params
|
||||
if (!check_interlace) {
|
||||
check_interlace = true;
|
||||
AVFieldOrder field_order = AV_GET_CODEC_ATTRIBUTES(pStream, pCodecCtx)->field_order;
|
||||
switch(field_order) {
|
||||
case AV_FIELD_PROGRESSIVE:
|
||||
info.interlaced_frame = false;
|
||||
break;
|
||||
case AV_FIELD_TT:
|
||||
case AV_FIELD_TB:
|
||||
info.interlaced_frame = true;
|
||||
info.top_field_first = true;
|
||||
break;
|
||||
case AV_FIELD_BT:
|
||||
case AV_FIELD_BB:
|
||||
info.interlaced_frame = true;
|
||||
info.top_field_first = false;
|
||||
break;
|
||||
case AV_FIELD_UNKNOWN:
|
||||
// Check again later?
|
||||
check_interlace = false;
|
||||
break;
|
||||
}
|
||||
// check_interlace will prevent these checks being repeated,
|
||||
// unless it was cleared because we got an AV_FIELD_UNKNOWN response.
|
||||
}
|
||||
|
||||
// Set the video timebase
|
||||
info.video_timebase.num = pStream->time_base.num;
|
||||
info.video_timebase.den = pStream->time_base.den;
|
||||
@@ -1078,14 +1105,14 @@ bool FFmpegReader::GetAVFrame() {
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::GetAVFrame (Packet not sent)");
|
||||
}
|
||||
else {
|
||||
AVFrame *next_frame2;
|
||||
if (hw_de_on && hw_de_supported) {
|
||||
next_frame2 = AV_ALLOCATE_FRAME();
|
||||
}
|
||||
else
|
||||
{
|
||||
next_frame2 = next_frame;
|
||||
}
|
||||
AVFrame *next_frame2;
|
||||
if (hw_de_on && hw_de_supported) {
|
||||
next_frame2 = AV_ALLOCATE_FRAME();
|
||||
}
|
||||
else
|
||||
{
|
||||
next_frame2 = next_frame;
|
||||
}
|
||||
pFrame = AV_ALLOCATE_FRAME();
|
||||
while (ret >= 0) {
|
||||
ret = avcodec_receive_frame(pCodecCtx, next_frame2);
|
||||
@@ -1119,11 +1146,6 @@ bool FFmpegReader::GetAVFrame() {
|
||||
av_image_alloc(pFrame->data, pFrame->linesize, info.width, info.height, (AVPixelFormat)(pStream->codecpar->format), 1);
|
||||
av_image_copy(pFrame->data, pFrame->linesize, (const uint8_t**)next_frame->data, next_frame->linesize,
|
||||
(AVPixelFormat)(pStream->codecpar->format), info.width, info.height);
|
||||
if (!check_interlace) {
|
||||
check_interlace = true;
|
||||
info.interlaced_frame = next_frame->interlaced_frame;
|
||||
info.top_field_first = next_frame->top_field_first;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hw_de_on && hw_de_supported) {
|
||||
@@ -1143,13 +1165,6 @@ bool FFmpegReader::GetAVFrame() {
|
||||
avpicture_alloc((AVPicture *) pFrame, pCodecCtx->pix_fmt, info.width, info.height);
|
||||
av_picture_copy((AVPicture *) pFrame, (AVPicture *) next_frame, pCodecCtx->pix_fmt, info.width,
|
||||
info.height);
|
||||
|
||||
// Detect interlaced frame (only once)
|
||||
if (!check_interlace) {
|
||||
check_interlace = true;
|
||||
info.interlaced_frame = next_frame->interlaced_frame;
|
||||
info.top_field_first = next_frame->top_field_first;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -2049,18 +2064,11 @@ bool FFmpegReader::CheckMissingFrame(int64_t requested_frame) {
|
||||
// Lock
|
||||
const GenericScopedLock <CriticalSection> lock(processingCriticalSection);
|
||||
|
||||
// Init # of times this frame has been checked so far
|
||||
int checked_count = 0;
|
||||
|
||||
// Increment check count for this frame (or init to 1)
|
||||
if (checked_frames.count(requested_frame) == 0)
|
||||
checked_frames[requested_frame] = 1;
|
||||
else
|
||||
checked_frames[requested_frame]++;
|
||||
checked_count = checked_frames[requested_frame];
|
||||
++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);
|
||||
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_frames[requested_frame]);
|
||||
|
||||
// Missing frames (sometimes frame #'s are skipped due to invalid or missing timestamps)
|
||||
map<int64_t, int64_t>::iterator itr;
|
||||
@@ -2073,7 +2081,7 @@ bool FFmpegReader::CheckMissingFrame(int64_t requested_frame) {
|
||||
// If MP3 with single video frame, handle this special case by copying the previously
|
||||
// decoded image to the new frame. Otherwise, it will spend a huge amount of
|
||||
// CPU time looking for missing images for all the audio-only frames.
|
||||
if (checked_count > 8 && !missing_video_frames.count(requested_frame) &&
|
||||
if (checked_frames[requested_frame] > 8 && !missing_video_frames.count(requested_frame) &&
|
||||
!processing_audio_frames.count(requested_frame) && processed_audio_frames.count(requested_frame) &&
|
||||
last_frame && last_video_frame->has_image_data && aCodecId == AV_CODEC_ID_MP3 && (vCodecId == AV_CODEC_ID_MJPEGB || vCodecId == AV_CODEC_ID_MJPEG)) {
|
||||
missing_video_frames.insert(pair<int64_t, int64_t>(requested_frame, last_video_frame->number));
|
||||
@@ -2087,10 +2095,7 @@ bool FFmpegReader::CheckMissingFrame(int64_t requested_frame) {
|
||||
int64_t missing_source_frame = missing_video_frames.find(requested_frame)->second;
|
||||
|
||||
// Increment missing source frame check count (or init to 1)
|
||||
if (checked_frames.count(missing_source_frame) == 0)
|
||||
checked_frames[missing_source_frame] = 1;
|
||||
else
|
||||
checked_frames[missing_source_frame]++;
|
||||
++checked_frames[missing_source_frame];
|
||||
|
||||
// Get the previous frame of this missing frame (if it's available in missing cache)
|
||||
std::shared_ptr<Frame> parent_frame = missing_frames.GetFrame(missing_source_frame);
|
||||
@@ -2452,7 +2457,7 @@ void FFmpegReader::SetJson(string value) {
|
||||
|
||||
if (!success)
|
||||
// Raise exception
|
||||
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
|
||||
throw InvalidJSON("JSON could not be parsed (or is invalid)");
|
||||
|
||||
try {
|
||||
// Set all values that match
|
||||
@@ -2460,7 +2465,7 @@ void FFmpegReader::SetJson(string value) {
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
// Error parsing JSON (or missing keys)
|
||||
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", "");
|
||||
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ void FFmpegWriter::SetVideoOptions(bool has_video, string codec, Fraction fps, i
|
||||
AVCodec *new_codec;
|
||||
// Check if the codec selected is a hardware accelerated codec
|
||||
#if IS_FFMPEG_3_2
|
||||
#if defined(__linux__)
|
||||
#if defined(__linux__)
|
||||
if ( (strcmp(codec.c_str(),"h264_vaapi") == 0)) {
|
||||
new_codec = avcodec_find_encoder_by_name(codec.c_str());
|
||||
hw_en_on = 1;
|
||||
@@ -194,7 +194,7 @@ void FFmpegWriter::SetVideoOptions(bool has_video, string codec, Fraction fps, i
|
||||
hw_en_supported = 0;
|
||||
}
|
||||
}
|
||||
#elif defined(_WIN32)
|
||||
#elif defined(_WIN32)
|
||||
if ( (strcmp(codec.c_str(),"h264_dxva2") == 0)) {
|
||||
new_codec = avcodec_find_encoder_by_name(codec.c_str());
|
||||
hw_en_on = 1;
|
||||
@@ -216,7 +216,7 @@ void FFmpegWriter::SetVideoOptions(bool has_video, string codec, Fraction fps, i
|
||||
hw_en_supported = 0;
|
||||
}
|
||||
}
|
||||
#elif defined(__APPLE__)
|
||||
#elif defined(__APPLE__)
|
||||
if ( (strcmp(codec.c_str(),"h264_videotoolbox") == 0)) {
|
||||
new_codec = avcodec_find_encoder_by_name(codec.c_str());
|
||||
hw_en_on = 1;
|
||||
@@ -229,9 +229,9 @@ void FFmpegWriter::SetVideoOptions(bool has_video, string codec, Fraction fps, i
|
||||
hw_en_on = 0;
|
||||
hw_en_supported = 0;
|
||||
}
|
||||
#else // is FFmpeg 3 but not linux
|
||||
#else // is FFmpeg 3 but not linux
|
||||
new_codec = avcodec_find_encoder_by_name(codec.c_str());
|
||||
#endif //__linux__
|
||||
#endif //__linux__
|
||||
#else // not ffmpeg 3
|
||||
new_codec = avcodec_find_encoder_by_name(codec.c_str());
|
||||
#endif //IS_FFMPEG_3_2
|
||||
|
||||
@@ -75,7 +75,7 @@ ReaderBase* FrameMapper::Reader()
|
||||
return reader;
|
||||
else
|
||||
// Throw error if reader not initialized
|
||||
throw ReaderClosed("No Reader has been initialized for FrameMapper. Call Reader(*reader) before calling this method.", "");
|
||||
throw ReaderClosed("No Reader has been initialized for FrameMapper. Call Reader(*reader) before calling this method.");
|
||||
}
|
||||
|
||||
void FrameMapper::AddField(int64_t frame)
|
||||
@@ -707,7 +707,7 @@ void FrameMapper::SetJson(string value) {
|
||||
|
||||
if (!success)
|
||||
// Raise exception
|
||||
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
|
||||
throw InvalidJSON("JSON could not be parsed (or is invalid)");
|
||||
|
||||
try
|
||||
{
|
||||
@@ -717,7 +717,7 @@ void FrameMapper::SetJson(string value) {
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
// Error parsing JSON (or missing keys)
|
||||
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", "");
|
||||
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ void ImageReader::SetJson(string value) {
|
||||
|
||||
if (!success)
|
||||
// Raise exception
|
||||
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
|
||||
throw InvalidJSON("JSON could not be parsed (or is invalid)");
|
||||
|
||||
try
|
||||
{
|
||||
@@ -179,7 +179,7 @@ void ImageReader::SetJson(string value) {
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
// Error parsing JSON (or missing keys)
|
||||
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", "");
|
||||
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user