Skip to content

Commit

Permalink
Merge branch 'develop' into store-qt-version
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdnyc committed Jun 11, 2020
2 parents 0e79844 + c29174f commit 07fef5b
Show file tree
Hide file tree
Showing 14 changed files with 414 additions and 87 deletions.
15 changes: 7 additions & 8 deletions .travis.yml
Expand Up @@ -32,8 +32,12 @@ addons:
- curl

jobs:
include:

# The FFmpeg 3.2 backport PPA has gone missing
allow_failures:
- name: "FFmpeg 3.2 GCC (Ubuntu 16.04 Xenial)"

include:
- name: "Coverage + FFmpeg 3.4 GCC (Ubuntu 18.04 Bionic)"
env:
- BUILD_VERSION=coverage_ffmpeg34
Expand All @@ -45,7 +49,6 @@ jobs:
apt:
sources:
- sourceline: 'ppa:openshot.developers/libopenshot-daily'
- sourceline: 'ppa:beineri/opt-qt-5.12.3-bionic'
packages:
- *p_common
- qt5-default
Expand All @@ -54,19 +57,17 @@ jobs:
- lcov
- binutils-common # For c++filt

- name: "FFmpeg 4 GCC (Ubuntu 18.04 Bionic)"
- name: "FFmpeg 4 GCC (Ubuntu 20.04 Focal)"
env:
- BUILD_VERSION=ffmpeg4
- CMAKE_EXTRA_ARGS=""
- TEST_TARGET=test
os: linux
dist: bionic
dist: focal
addons:
apt:
sources:
- sourceline: 'ppa:openshot.developers/libopenshot-daily'
- sourceline: 'ppa:beineri/opt-qt-5.12.3-bionic'
- sourceline: 'ppa:jonathonf/ffmpeg-4'
packages:
- *p_common
- qt5-default
Expand All @@ -92,7 +93,6 @@ jobs:
apt:
sources:
- sourceline: 'ppa:openshot.developers/libopenshot-daily'
- sourceline: 'ppa:beineri/opt-qt-5.12.3-bionic'
packages:
- *p_common
- qt5-default
Expand All @@ -110,7 +110,6 @@ jobs:
apt:
sources:
- sourceline: 'ppa:openshot.developers/libopenshot-daily'
- sourceline: 'ppa:beineri/opt-qt-5.10.0-xenial'
- sourceline: 'ppa:jon-hedgerows/ffmpeg-backports'
packages:
- *p_common
Expand Down
24 changes: 13 additions & 11 deletions include/Clip.h
Expand Up @@ -139,11 +139,11 @@ namespace openshot {
void reverse_buffer(juce::AudioSampleBuffer* buffer);

public:
openshot::GravityType gravity; ///< The gravity of a clip determines where it snaps to its parent
openshot::ScaleType scale; ///< The scale determines how a clip should be resized to fit its parent
openshot::AnchorType anchor; ///< The anchor determines what parent a clip should snap to
openshot::FrameDisplayType display; ///< The format to display the frame number (if any)
openshot::VolumeMixType mixing; ///< What strategy should be followed when mixing audio with other clips
openshot::GravityType gravity; ///< The gravity of a clip determines where it snaps to its parent
openshot::ScaleType scale; ///< The scale determines how a clip should be resized to fit its parent
openshot::AnchorType anchor; ///< The anchor determines what parent a clip should snap to
openshot::FrameDisplayType display; ///< The format to display the frame number (if any)
openshot::VolumeMixType mixing; ///< What strategy should be followed when mixing audio with other clips

/// Default Constructor
Clip();
Expand Down Expand Up @@ -207,15 +207,19 @@ namespace openshot {
bool Waveform() { return waveform; } ///< Get the waveform property of this clip
void Waveform(bool value) { waveform = value; } ///< Set the waveform property of this clip

// Scale and Location curves
// Scale, Location, and Alpha curves
openshot::Keyframe scale_x; ///< Curve representing the horizontal scaling in percent (0 to 1)
openshot::Keyframe scale_y; ///< Curve representing the vertical scaling in percent (0 to 1)
openshot::Keyframe location_x; ///< Curve representing the relative X position in percent based on the gravity (-1 to 1)
openshot::Keyframe location_y; ///< Curve representing the relative Y position in percent based on the gravity (-1 to 1)

// Alpha and Rotation curves
openshot::Keyframe alpha; ///< Curve representing the alpha (1 to 0)

// Rotation and Shear curves (origin point (x,y) is adjustable for both rotation and shear)
openshot::Keyframe rotation; ///< Curve representing the rotation (0 to 360)
openshot::Keyframe shear_x; ///< Curve representing X shear angle in degrees (-45.0=left, 45.0=right)
openshot::Keyframe shear_y; ///< Curve representing Y shear angle in degrees (-45.0=down, 45.0=up)
openshot::Keyframe origin_x; ///< Curve representing X origin point (0.0=0% (left), 1.0=100% (right))
openshot::Keyframe origin_y; ///< Curve representing Y origin point (0.0=0% (top), 1.0=100% (bottom))

// Time and Volume curves
openshot::Keyframe time; ///< Curve representing the frames over time to play (used for speed and direction of video)
Expand All @@ -231,9 +235,7 @@ namespace openshot {
openshot::Keyframe crop_x; ///< Curve representing X offset in percent (-1.0=-100%, 0.0=0%, 1.0=100%)
openshot::Keyframe crop_y; ///< Curve representing Y offset in percent (-1.0=-100%, 0.0=0%, 1.0=100%)

// Shear and perspective curves
openshot::Keyframe shear_x; ///< Curve representing X shear angle in degrees (-45.0=left, 45.0=right)
openshot::Keyframe shear_y; ///< Curve representing Y shear angle in degrees (-45.0=down, 45.0=up)
// Perspective curves
openshot::Keyframe perspective_c1_x; ///< Curves representing X for coordinate 1
openshot::Keyframe perspective_c1_y; ///< Curves representing Y for coordinate 1
openshot::Keyframe perspective_c2_x; ///< Curves representing X for coordinate 2
Expand Down
53 changes: 52 additions & 1 deletion include/DummyReader.h
Expand Up @@ -46,17 +46,65 @@
namespace openshot
{
/**
* @brief This class is used as a simple, dummy reader, which always returns a blank frame.
* @brief This class is used as a simple, dummy reader, which can be very useful when writing
* unit tests. It can return a single blank frame or it can return custom frame objects
* which were passed into the constructor with a Cache object.
*
* A dummy reader can be created with any framerate or samplerate. This is useful in unit
* tests that need to test different framerates or samplerates.
*
* @code
* // Create cache object to store fake Frame objects
* CacheMemory cache;
*
* // Now let's create some test frames
* for (int64_t frame_number = 1; frame_number <= 30; frame_number++)
* {
* // Create blank frame (with specific frame #, samples, and channels)
* // Sample count should be 44100 / 30 fps = 1470 samples per frame
* int sample_count = 1470;
* std::shared_ptr<openshot::Frame> f(new openshot::Frame(frame_number, sample_count, 2));
*
* // Create test samples with incrementing value
* float *audio_buffer = new float[sample_count];
* for (int64_t sample_number = 0; sample_number < sample_count; sample_number++)
* {
* // Generate an incrementing audio sample value (just as an example)
* audio_buffer[sample_number] = float(frame_number) + (float(sample_number) / float(sample_count));
* }
*
* // Add custom audio samples to Frame (bool replaceSamples, int destChannel, int destStartSample, const float* source,
* // int numSamples, float gainToApplyToSource = 1.0f)
* f->AddAudio(true, 0, 0, audio_buffer, sample_count, 1.0); // add channel 1
* f->AddAudio(true, 1, 0, audio_buffer, sample_count, 1.0); // add channel 2
*
* // Add test frame to cache
* cache.Add(f);
* }
*
* // Create a reader (Fraction fps, int width, int height, int sample_rate, int channels, float duration, CacheBase* cache)
* openshot::DummyReader r(openshot::Fraction(30, 1), 1920, 1080, 44100, 2, 30.0, &cache);
* r.Open(); // Open the reader
*
* // Now let's verify our DummyReader works
* std::shared_ptr<openshot::Frame> f = r.GetFrame(1);
* // r.GetFrame(1)->GetAudioSamples(0)[1] should equal 1.00068033 based on our above calculations
*
* // Clean up
* r.Close();
* cache.Clear()
* @endcode
*/
class DummyReader : public ReaderBase
{
private:
CacheBase* dummy_cache;
std::shared_ptr<openshot::Frame> image_frame;
bool is_open;

/// Initialize variables used by constructor
void init(Fraction fps, int width, int height, int sample_rate, int channels, float duration);

public:

/// Blank constructor for DummyReader, with default settings.
Expand All @@ -65,6 +113,9 @@ namespace openshot
/// Constructor for DummyReader.
DummyReader(openshot::Fraction fps, int width, int height, int sample_rate, int channels, float duration);

/// Constructor for DummyReader which takes a frame cache object.
DummyReader(openshot::Fraction fps, int width, int height, int sample_rate, int channels, float duration, CacheBase* cache);

virtual ~DummyReader();

/// Close File
Expand Down
18 changes: 8 additions & 10 deletions include/FFmpegUtilities.h
Expand Up @@ -163,11 +163,10 @@
#define AV_FREE_CONTEXT(av_context) avcodec_free_context(&av_context)
#define AV_GET_CODEC_TYPE(av_stream) av_stream->codecpar->codec_type
#define AV_FIND_DECODER_CODEC_ID(av_stream) av_stream->codecpar->codec_id
auto AV_GET_CODEC_CONTEXT = [](AVStream* av_stream, AVCodec* av_codec) { \
AVCodecContext *context = avcodec_alloc_context3(av_codec); \
avcodec_parameters_to_context(context, av_stream->codecpar); \
return context; \
};
#define AV_GET_CODEC_CONTEXT(av_stream, av_codec) \
({ AVCodecContext *context = avcodec_alloc_context3(av_codec); \
avcodec_parameters_to_context(context, av_stream->codecpar); \
context; })
#define AV_GET_CODEC_PAR_CONTEXT(av_stream, av_codec) av_codec;
#define AV_GET_CODEC_FROM_STREAM(av_stream,codec_in)
#define AV_GET_CODEC_ATTRIBUTES(av_stream, av_context) av_stream->codecpar
Expand Down Expand Up @@ -199,11 +198,10 @@
#define AV_FREE_CONTEXT(av_context) avcodec_free_context(&av_context)
#define AV_GET_CODEC_TYPE(av_stream) av_stream->codecpar->codec_type
#define AV_FIND_DECODER_CODEC_ID(av_stream) av_stream->codecpar->codec_id
auto AV_GET_CODEC_CONTEXT = [](AVStream* av_stream, AVCodec* av_codec) { \
AVCodecContext *context = avcodec_alloc_context3(av_codec); \
avcodec_parameters_to_context(context, av_stream->codecpar); \
return context; \
};
#define AV_GET_CODEC_CONTEXT(av_stream, av_codec) \
({ AVCodecContext *context = avcodec_alloc_context3(av_codec); \
avcodec_parameters_to_context(context, av_stream->codecpar); \
context; })
#define AV_GET_CODEC_PAR_CONTEXT(av_stream, av_codec) av_codec;
#define AV_GET_CODEC_FROM_STREAM(av_stream,codec_in)
#define AV_GET_CODEC_ATTRIBUTES(av_stream, av_context) av_stream->codecpar
Expand Down
8 changes: 4 additions & 4 deletions include/Qt/AudioPlaybackThread.h
Expand Up @@ -75,7 +75,7 @@ namespace openshot
static AudioDeviceManagerSingleton * Instance();

/// Public device manager property
AudioDeviceManager audioDeviceManager;
juce::AudioDeviceManager audioDeviceManager;

/// Close audio device
void CloseAudioDevice();
Expand All @@ -86,9 +86,9 @@ namespace openshot
*/
class AudioPlaybackThread : juce::Thread
{
AudioSourcePlayer player;
AudioTransportSource transport;
MixerAudioSource mixer;
juce::AudioSourcePlayer player;
juce::AudioTransportSource transport;
juce::MixerAudioSource mixer;
AudioReaderSource *source;
double sampleRate;
int numChannels;
Expand Down
20 changes: 17 additions & 3 deletions src/Clip.cpp
Expand Up @@ -89,6 +89,8 @@ void Clip::init_settings()
// Init shear and perspective curves
shear_x = Keyframe(0.0);
shear_y = Keyframe(0.0);
origin_x = Keyframe(0.5);
origin_y = Keyframe(0.5);
perspective_c1_x = Keyframe(-1.0);
perspective_c1_y = Keyframe(-1.0);
perspective_c2_x = Keyframe(-1.0);
Expand Down Expand Up @@ -148,8 +150,11 @@ Clip::Clip(ReaderBase* new_reader) : resampler(NULL), reader(new_reader), alloca
Open();
Close();

// Update duration
End(reader->info.duration);
// Update duration and set parent
if (reader) {
End(reader->info.duration);
reader->SetClip(this);
}
}

// Constructor with filepath
Expand Down Expand Up @@ -202,9 +207,10 @@ Clip::Clip(std::string path) : resampler(NULL), reader(NULL), allocated_reader(N
}
}

// Update duration
// Update duration and set parent
if (reader) {
End(reader->info.duration);
reader->SetClip(this);
allocated_reader = reader;
init_reader_rotation();
}
Expand Down Expand Up @@ -712,6 +718,8 @@ std::string Clip::PropertiesJSON(int64_t requested_frame) const {
root["shear_x"] = add_property_json("Shear X", shear_x.GetValue(requested_frame), "float", "", &shear_x, -1.0, 1.0, false, requested_frame);
root["shear_y"] = add_property_json("Shear Y", shear_y.GetValue(requested_frame), "float", "", &shear_y, -1.0, 1.0, false, requested_frame);
root["rotation"] = add_property_json("Rotation", rotation.GetValue(requested_frame), "float", "", &rotation, -360, 360, false, requested_frame);
root["origin_x"] = add_property_json("Origin X", origin_x.GetValue(requested_frame), "float", "", &origin_x, 0.0, 1.0, false, requested_frame);
root["origin_y"] = add_property_json("Origin Y", origin_y.GetValue(requested_frame), "float", "", &origin_y, 0.0, 1.0, false, requested_frame);
root["volume"] = add_property_json("Volume", volume.GetValue(requested_frame), "float", "", &volume, 0.0, 1.0, false, requested_frame);
root["time"] = add_property_json("Time", time.GetValue(requested_frame), "float", "", &time, 0.0, 30 * 60 * 60 * 48, false, requested_frame);
root["channel_filter"] = add_property_json("Channel Filter", channel_filter.GetValue(requested_frame), "int", "", &channel_filter, -1, 10, false, requested_frame);
Expand Down Expand Up @@ -768,6 +776,8 @@ Json::Value Clip::JsonValue() const {
root["crop_y"] = crop_y.JsonValue();
root["shear_x"] = shear_x.JsonValue();
root["shear_y"] = shear_y.JsonValue();
root["origin_x"] = origin_x.JsonValue();
root["origin_y"] = origin_y.JsonValue();
root["channel_filter"] = channel_filter.JsonValue();
root["channel_mapping"] = channel_mapping.JsonValue();
root["has_audio"] = has_audio.JsonValue();
Expand Down Expand Up @@ -865,6 +875,10 @@ void Clip::SetJsonValue(const Json::Value root) {
shear_x.SetJsonValue(root["shear_x"]);
if (!root["shear_y"].isNull())
shear_y.SetJsonValue(root["shear_y"]);
if (!root["origin_x"].isNull())
origin_x.SetJsonValue(root["origin_x"]);
if (!root["origin_y"].isNull())
origin_y.SetJsonValue(root["origin_y"]);
if (!root["channel_filter"].isNull())
channel_filter.SetJsonValue(root["channel_filter"]);
if (!root["channel_mapping"].isNull())
Expand Down

0 comments on commit 07fef5b

Please sign in to comment.