#475 and some clip pointer changes

This commit is contained in:
itsmattkc
2019-02-28 01:54:04 -08:00
parent edea300cbc
commit 1685fa3a5d
70 changed files with 726 additions and 516 deletions
+4 -4
View File
@@ -42,7 +42,7 @@ double bytes_to_seconds(int nb_bytes, int nb_channels, int sample_rate) {
return (double(nb_bytes >> 1) / nb_channels / sample_rate);
}
void apply_audio_effects(ClipPtr clip, double timecode_start, AVFrame* frame, int nb_bytes, QVector<ClipPtr> nests) {
void apply_audio_effects(Clip* clip, double timecode_start, AVFrame* frame, int nb_bytes, QVector<Clip*> nests) {
// perform all audio effects
double timecode_end;
timecode_end = timecode_start + bytes_to_seconds(nb_bytes, frame->channels, frame->sample_rate);
@@ -78,7 +78,7 @@ void apply_audio_effects(ClipPtr clip, double timecode_start, AVFrame* frame, in
}
if (!nests.isEmpty()) {
ClipPtr next_nest = nests.last();
Clip* next_nest = nests.last();
nests.removeLast();
apply_audio_effects(next_nest,
timecode_start + (double(clip->timeline_in(true)-clip->clip_in(true))/clip->sequence->frame_rate),
@@ -735,7 +735,7 @@ void Cacher::WakeMainThread()
main_thread_lock_.unlock();
}
Cacher::Cacher(ClipPtr c) : clip(c) {}
Cacher::Cacher(Clip* c) : clip(c) {}
void Cacher::OpenWorker() {
qint64 time_start = QDateTime::currentMSecsSinceEpoch();
@@ -1048,7 +1048,7 @@ void Cacher::Open()
start((clip->track() < 0) ? QThread::HighPriority : QThread::TimeCriticalPriority);
}
void Cacher::Cache(long playhead, bool scrubbing, QVector<ClipPtr>& nests, int playback_speed)
void Cacher::Cache(long playhead, bool scrubbing, QVector<Clip*>& nests, int playback_speed)
{
if (clip->media_stream()->infinite_length && queue.size() > 0) {
retrieved_frame = queue.at(0);
+4 -5
View File
@@ -42,7 +42,6 @@ extern "C" {
#include "rendering/clipqueue.h"
class Clip;
using ClipPtr = std::shared_ptr<Clip>;
/**
* @brief The Cacher class
@@ -106,7 +105,7 @@ public:
*
* @param c
*/
Cacher(ClipPtr c);
Cacher(Clip* c);
/**
* @brief The main QThread loop
@@ -158,7 +157,7 @@ public:
*
* The current playback speed (controlled by Shuttle Left/Stop/Right)
*/
void Cache(long playhead, bool scrubbing, QVector<ClipPtr>& nests, int playback_speed);
void Cache(long playhead, bool scrubbing, QVector<Clip*>& nests, int playback_speed);
/**
* @brief Retrieve frame requested by Cache()
@@ -257,7 +256,7 @@ private:
/**
* @brief Reference to the parent clip. Set in the constructor and never changed during this object's lifetime.
*/
ClipPtr clip;
Clip* clip;
/**
* @brief Frame queue
@@ -327,7 +326,7 @@ private:
/**
* @brief Current nested Sequence hierarchy set by Cache()
*/
QVector<ClipPtr> nests_;
QVector<Clip*> nests_;
/**
* @brief Signal cache to continue operation after one cycle rather than wait for another signal
+10 -10
View File
@@ -106,7 +106,7 @@ GLuint draw_clip(QOpenGLFramebufferObject* fbo, GLuint texture, bool clear) {
return fbo->texture();
}
void process_effect(ClipPtr c,
void process_effect(Clip* c,
EffectPtr e,
double timecode,
GLTextureCoords& coords,
@@ -178,12 +178,12 @@ GLuint compose_sequence(ComposeSequenceParams &params) {
int audio_track_count = 0;
QVector<ClipPtr> current_clips;
QVector<Clip*> current_clips;
// loop through clips, find currently active, and sort by track
for (int i=0;i<s->clips.size();i++) {
ClipPtr c = s->clips.at(i);
Clip* c = s->clips.at(i).get();
if (c != nullptr) {
@@ -284,7 +284,7 @@ GLuint compose_sequence(ComposeSequenceParams &params) {
// loop through current clips
for (int i=0;i<current_clips.size();i++) {
ClipPtr c = current_clips.at(i);
Clip* c = current_clips.at(i);
bool got_mutex = true;
@@ -683,15 +683,15 @@ long rescale_frame_number(long framenumber, double source_frame_rate, double tar
return qRound((double(framenumber)/source_frame_rate)*target_frame_rate);
}
double get_timecode(ClipPtr c, long playhead) {
double get_timecode(Clip* c, long playhead) {
return double(playhead_to_clip_frame(c, playhead))/c->sequence->frame_rate;
}
long playhead_to_clip_frame(ClipPtr c, long playhead) {
long playhead_to_clip_frame(Clip* c, long playhead) {
return (qMax(0L, playhead - c->timeline_in(true)) + c->clip_in(true));
}
double playhead_to_clip_seconds(ClipPtr c, long playhead) {
double playhead_to_clip_seconds(Clip* c, long playhead) {
// returns time in seconds
long clip_frame = playhead_to_clip_frame(c, playhead);
@@ -707,18 +707,18 @@ double playhead_to_clip_seconds(ClipPtr c, long playhead) {
return secs;
}
int64_t seconds_to_timestamp(ClipPtr c, double seconds) {
int64_t seconds_to_timestamp(Clip *c, double seconds) {
return qRound64(seconds * av_q2d(av_inv_q(c->time_base())));
}
int64_t playhead_to_timestamp(ClipPtr c, long playhead) {
int64_t playhead_to_timestamp(Clip* c, long playhead) {
return seconds_to_timestamp(c, playhead_to_clip_seconds(c, playhead));
}
void close_active_clips(SequencePtr s) {
if (s != nullptr) {
for (int i=0;i<s->clips.size();i++) {
ClipPtr c = s->clips.at(i);
Clip* c = s->clips.at(i).get();
if (c != nullptr) {
c->Close(true);
}
+6 -6
View File
@@ -67,7 +67,7 @@ struct ComposeSequenceParams {
* Should be left empty. This array gets passed around compose_sequence() as it calls itself recursively to
* handle nested sequences.
*/
QVector<ClipPtr> nests;
QVector<Clip*> nests;
/**
* @brief Set compose mode to video or audio
@@ -307,7 +307,7 @@ long rescale_frame_number(long framenumber, double source_frame_rate, double tar
*
* Timecode in seconds
*/
double get_timecode(ClipPtr c, long playhead);
double get_timecode(Clip *c, long playhead);
/**
* @brief Convert playhead frame number to a clip frame number
@@ -327,7 +327,7 @@ double get_timecode(ClipPtr c, long playhead);
*
* The curren frame number of the clip at `playhead`
*/
long playhead_to_clip_frame(ClipPtr c, long playhead);
long playhead_to_clip_frame(Clip* c, long playhead);
/**
* @brief Converts the playhead to clip seconds
@@ -348,7 +348,7 @@ long playhead_to_clip_frame(ClipPtr c, long playhead);
*
* Clip time in seconds
*/
double playhead_to_clip_seconds(ClipPtr c, long playhead);
double playhead_to_clip_seconds(Clip *c, long playhead);
/**
* @brief Convert seconds to FFmpeg timestamp
@@ -368,7 +368,7 @@ double playhead_to_clip_seconds(ClipPtr c, long playhead);
*
* An FFmpeg-compatible timestamp in AVStream->time_base units.
*/
int64_t seconds_to_timestamp(ClipPtr c, double seconds);
int64_t seconds_to_timestamp(Clip* c, double seconds);
/**
* @brief Convert Timeline playhead to FFmpeg timestamp
@@ -388,7 +388,7 @@ int64_t seconds_to_timestamp(ClipPtr c, double seconds);
*
* An FFmpeg-compatible timestamp in AVStream->time_base units.
*/
int64_t playhead_to_timestamp(ClipPtr c, long playhead);
int64_t playhead_to_timestamp(Clip *c, long playhead);
/**
* @brief Close all open clips in a Sequence