Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration of resvg SVG library (optional during build) #185

Merged
merged 7 commits into from
Jan 19, 2019
Merged
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,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: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
Expand Down
34 changes: 34 additions & 0 deletions cmake/Modules/FindRESVG.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# - Try to find RESVG
# Once done this will define
# RESVG_FOUND - System has RESVG
# RESVG_INCLUDE_DIRS - The RESVG include directories
# RESVG_LIBRARIES - The libraries needed to use RESVG
# RESVG_DEFINITIONS - Compiler switches required for using RESVG
find_path ( RESVG_INCLUDE_DIR ResvgQt.h
PATHS ${RESVGDIR}/include/resvg
$ENV{RESVGDIR}/include/resvg
$ENV{RESVGDIR}/include
/usr/include/resvg
/usr/include
/usr/local/include/resvg
/usr/local/include )

find_library ( RESVG_LIBRARY NAMES resvg
PATHS /usr/lib
/usr/local/lib
$ENV{RESVGDIR}/lib )

set ( RESVG_LIBRARIES ${RESVG_LIBRARY} )
set ( RESVG_INCLUDE_DIRS ${RESVG_INCLUDE_DIR} )

SET( RESVG_FOUND FALSE )

IF ( RESVG_INCLUDE_DIR AND RESVG_LIBRARY )
SET ( RESVG_FOUND TRUE )

include ( FindPackageHandleStandardArgs )
# handle the QUIETLY and REQUIRED arguments and set RESVG_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args ( RESVG DEFAULT_MSG RESVG_LIBRARY RESVG_INCLUDE_DIR )
ENDIF ( RESVG_INCLUDE_DIR AND RESVG_LIBRARY )

4 changes: 1 addition & 3 deletions include/ChunkReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
#define OPENSHOT_CHUNK_READER_H

#include "ReaderBase.h"
#include "FFmpegReader.h"

#include <cmath>
#include <ctime>
#include <iostream>
Expand Down Expand Up @@ -107,7 +105,7 @@ namespace openshot
string path;
bool is_open;
int64_t chunk_size;
FFmpegReader *local_reader;
ReaderBase *local_reader;
ChunkLocation previous_location;
ChunkVersion version;
std::shared_ptr<Frame> last_frame;
Expand Down
9 changes: 0 additions & 9 deletions include/Clip.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,9 @@
#include "EffectBase.h"
#include "Effects.h"
#include "EffectInfo.h"
#include "FFmpegReader.h"
#include "Fraction.h"
#include "FrameMapper.h"
#ifdef USE_IMAGEMAGICK
#include "ImageReader.h"
#include "TextReader.h"
#endif
#include "QtImageReader.h"
#include "ChunkReader.h"
#include "KeyFrame.h"
#include "ReaderBase.h"
#include "DummyReader.h"

using namespace std;
using namespace openshot;
Expand Down
7 changes: 1 addition & 6 deletions include/ClipBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ namespace openshot {
float start; ///< The position in seconds to start playing (used to trim the beginning of a clip)
float end; ///< The position in seconds to end playing (used to trim the ending of a clip)
string previous_properties; ///< This string contains the previous JSON properties
int max_width; ///< The maximum image width needed by this clip (used for optimizations)
int max_height; ///< The maximium image height needed by this clip (used for optimizations)

/// Generate JSON for a property
Json::Value add_property_json(string name, float value, string type, string memo, Keyframe* keyframe, float min_value, float max_value, bool readonly, int64_t requested_frame);
Expand All @@ -70,7 +68,7 @@ namespace openshot {
public:

/// Constructor for the base clip
ClipBase() { max_width = 0; max_height = 0; };
ClipBase() { };

// Compare a clip using the Position() property
bool operator< ( ClipBase& a) { return (Position() < a.Position()); }
Expand All @@ -93,9 +91,6 @@ namespace openshot {
void Start(float value) { start = value; } ///< Set start position (in seconds) of clip (trim start of video)
void End(float value) { end = value; } ///< Set end position (in seconds) of clip (trim end of video)

/// Set Max Image Size (used for performance optimization)
void SetMaxSize(int width, int height) { max_width = width; max_height = height; };

/// Get and Set JSON methods
virtual string Json() = 0; ///< Generate JSON string of this object
virtual void SetJson(string value) = 0; ///< Load JSON string into this object
Expand Down
1 change: 1 addition & 0 deletions include/FFmpegReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <stdio.h>
#include <memory>
#include "CacheMemory.h"
#include "Clip.h"
#include "Exceptions.h"
#include "OpenMPUtilities.h"
#include "Settings.h"
Expand Down
8 changes: 4 additions & 4 deletions include/FFmpegUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,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) if (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
Expand Down Expand Up @@ -176,7 +176,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) if(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
Expand Down Expand Up @@ -211,7 +211,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) if (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
Expand Down Expand Up @@ -241,7 +241,7 @@
#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)
#define AV_RESET_FRAME(av_frame) avcodec_get_frame_defaults(av_frame)
#define AV_FREE_FRAME(av_frame) if(av_frame) avcodec_free_frame(av_frame)
#define AV_FREE_FRAME(av_frame) avcodec_free_frame(av_frame)
#define AV_FREE_PACKET(av_packet) av_free_packet(av_packet)
#define AV_FREE_CONTEXT(av_context) avcodec_close(av_context)
#define AV_GET_CODEC_TYPE(av_stream) av_stream->codec->codec_type
Expand Down
10 changes: 1 addition & 9 deletions include/QtImageReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,14 @@
#ifndef OPENSHOT_QIMAGE_READER_H
#define OPENSHOT_QIMAGE_READER_H

#include "ReaderBase.h"

#include <cmath>
#include <ctime>
#include <iostream>
#include <omp.h>
#include <stdio.h>
#include <memory>
#include <QtCore/QString>
#include <QtGui/QImage>
#include <QtGui/QPainter>
#include "CacheMemory.h"
#include "Exceptions.h"
#include "ReaderBase.h"

using namespace std;

Expand Down Expand Up @@ -110,9 +105,6 @@ namespace openshot
Json::Value JsonValue(); ///< Generate Json::JsonValue for this object
void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object

/// Set Max Image Size (used for performance optimization)
void SetMaxSize(int width, int height);

/// Open File - which is called by the constructor automatically
void Open();
};
Expand Down
14 changes: 8 additions & 6 deletions include/ReaderBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <sstream>
#include "CacheMemory.h"
#include "ChannelLayouts.h"
#include "ClipBase.h"
#include "Fraction.h"
#include "Frame.h"
#include "Json.h"
Expand Down Expand Up @@ -99,9 +100,7 @@ namespace openshot
/// Section lock for multiple threads
CriticalSection getFrameCriticalSection;
CriticalSection processingCriticalSection;

int max_width; ///< The maximum image width needed by this clip (used for optimizations)
int max_height; ///< The maximium image height needed by this clip (used for optimizations)
ClipBase* parent;

public:

Expand All @@ -111,6 +110,12 @@ namespace openshot
/// Information about the current media file
ReaderInfo info;

/// Parent clip object of this reader (which can be unparented and NULL)
ClipBase* GetClip();

/// Set parent clip object of this reader
void SetClip(ClipBase* clip);

/// Close the reader (and any resources it was consuming)
virtual void Close() = 0;

Expand Down Expand Up @@ -140,9 +145,6 @@ namespace openshot
virtual Json::Value JsonValue() = 0; ///< Generate Json::JsonValue for this object
virtual void SetJsonValue(Json::Value root) = 0; ///< Load Json::JsonValue into this object

/// Set Max Image Size (used for performance optimization)
void SetMaxSize(int width, int height) { max_width = width; max_height = height; };

/// Open the reader (and start consuming resources, such as images or video files)
virtual void Open() = 0;
};
Expand Down
6 changes: 6 additions & 0 deletions include/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ namespace openshot {
/// Scale mode used in FFmpeg decoding and encoding (used as an optimization for faster previews)
bool HIGH_QUALITY_SCALING = false;

/// Maximum width for image data (useful for optimzing for a smaller preview or render)
int MAX_WIDTH = 0;

/// Maximum height for image data (useful for optimzing for a smaller preview or render)
int MAX_HEIGHT = 0;

/// Wait for OpenMP task to finish before continuing (used to limit threads on slower systems)
bool WAIT_FOR_VIDEO_PROCESSING_TASK = false;

Expand Down
5 changes: 5 additions & 0 deletions include/Timeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "KeyFrame.h"
#include "OpenMPUtilities.h"
#include "ReaderBase.h"
#include "Settings.h"

using namespace std;
using namespace openshot;
Expand Down Expand Up @@ -265,6 +266,10 @@ namespace openshot {
Json::Value JsonValue(); ///< Generate Json::JsonValue for this object
void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object

/// Set Max Image Size (used for performance optimization). Convenience function for setting
/// Settings::Instance()->MAX_WIDTH and Settings::Instance()->MAX_HEIGHT.
void SetMaxSize(int width, int height);

/// @brief Apply a special formatted JSON object, which represents a change to the timeline (add, update, delete)
/// This is primarily designed to keep the timeline (and its child objects... such as clips and effects) in sync
/// with another application... such as OpenShot Video Editor (http://www.openshot.org).
Expand Down
28 changes: 20 additions & 8 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ ENDIF (ImageMagick_FOUND)
# Find FFmpeg libraries (used for video encoding / decoding)
FIND_PACKAGE(FFmpeg REQUIRED)

# Include FFmpeg headers (needed for compile)
message('AVCODEC_FOUND: ${AVCODEC_FOUND}')
message('AVCODEC_INCLUDE_DIRS: ${AVCODEC_INCLUDE_DIRS}')
message('AVCODEC_LIBRARIES: ${AVCODEC_LIBRARIES}')

IF (AVCODEC_FOUND)
include_directories(${AVCODEC_INCLUDE_DIRS})
ENDIF (AVCODEC_FOUND)
Expand Down Expand Up @@ -116,8 +111,6 @@ ENDIF (AVRESAMPLE_FOUND)
# Find JUCE-based openshot Audio libraries
FIND_PACKAGE(OpenShotAudio REQUIRED)

message('LIBOPENSHOT_AUDIO_INCLUDE_DIRS: ${LIBOPENSHOT_AUDIO_INCLUDE_DIRS}')

# Include Juce headers (needed for compile)
include_directories(${LIBOPENSHOT_AUDIO_INCLUDE_DIRS})

Expand Down Expand Up @@ -190,13 +183,28 @@ FIND_PACKAGE(ZMQ REQUIRED)
# Include ZeroMQ headers (needed for compile)
include_directories(${ZMQ_INCLUDE_DIRS})

################### RESVG #####################
# Find resvg library (used for rendering svg files)
FIND_PACKAGE(RESVG)

# Include resvg headers (optional SVG library)
if (RESVG_FOUND)
include_directories(${RESVG_INCLUDE_DIRS})

# define a global var (used in the C++)
add_definitions( -DUSE_RESVG=1 )
SET(CMAKE_SWIG_FLAGS "-DUSE_RESVG=1")
else(RESVG_FOUND)
message("-- Could NOT find libresvg (using Qt SVG parsing instead)")
endif(RESVG_FOUND)

################### JSONCPP #####################
# Include jsoncpp headers (needed for JSON parsing)
if (USE_SYSTEM_JSONCPP)
find_package(JsonCpp REQUIRED)
include_directories(${JSONCPP_INCLUDE_DIRS})
else()
message("Using embedded JsonCpp")
message("-- Could NOT find JsonCpp library (Using embedded JsonCpp instead)")
include_directories("../thirdparty/jsoncpp/include")
endif(USE_SYSTEM_JSONCPP)

Expand Down Expand Up @@ -334,6 +342,10 @@ IF (AVRESAMPLE_FOUND)
SET ( REQUIRED_LIBRARIES ${REQUIRED_LIBRARIES} ${AVRESAMPLE_LIBRARIES} )
ENDIF (AVRESAMPLE_FOUND)

IF (RESVG_FOUND)
SET ( REQUIRED_LIBRARIES ${REQUIRED_LIBRARIES} ${RESVG_LIBRARIES} )
ENDIF(RESVG_FOUND)

IF (OPENMP_FOUND)
SET ( REQUIRED_LIBRARIES ${REQUIRED_LIBRARIES} ${OpenMP_CXX_FLAGS} )
ENDIF (OPENMP_FOUND)
Expand Down
2 changes: 1 addition & 1 deletion src/ChunkReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/

#include "../include/ChunkReader.h"
#include "../include/FFmpegReader.h"

using namespace openshot;

Expand Down Expand Up @@ -227,7 +228,6 @@ std::shared_ptr<Frame> ChunkReader::GetFrame(int64_t requested_frame)
cout << "Load READER: " << chunk_video_path << endl;
// Load new FFmpegReader
local_reader = new FFmpegReader(chunk_video_path);
local_reader->enable_seek = false; // disable seeking
local_reader->Open(); // open reader

} catch (InvalidFile)
Expand Down
Loading