From 4556ce644c43c1f4b2798aa669e986a86473131e Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Mon, 31 Dec 2018 10:07:26 +1100 Subject: [PATCH 01/10] override_dh_auto_configure for debian --- debian/rules | 3 +++ 1 file changed, 3 insertions(+) diff --git a/debian/rules b/debian/rules index 18d67d9ac..c06731733 100644 --- a/debian/rules +++ b/debian/rules @@ -1,5 +1,8 @@ #!/usr/bin/make -f export QT_SELECT := qt5 +override_dh_auto_configure: + qmake olive.pro + %: dh $@ From 8a5bc58f9f27f5826957d8b106df0b8e898cbedd Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Mon, 31 Dec 2018 10:11:00 +1100 Subject: [PATCH 02/10] Revert "override_dh_auto_configure for debian" This reverts commit 4556ce644c43c1f4b2798aa669e986a86473131e. --- debian/rules | 3 --- 1 file changed, 3 deletions(-) diff --git a/debian/rules b/debian/rules index c06731733..18d67d9ac 100644 --- a/debian/rules +++ b/debian/rules @@ -1,8 +1,5 @@ #!/usr/bin/make -f export QT_SELECT := qt5 -override_dh_auto_configure: - qmake olive.pro - %: dh $@ From 3d8c5f2fed4570d55538c971235fafe7604006e3 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Mon, 31 Dec 2018 10:47:07 +1100 Subject: [PATCH 03/10] removed redundant link --- olive-editor.pro | 1 - 1 file changed, 1 deletion(-) delete mode 120000 olive-editor.pro diff --git a/olive-editor.pro b/olive-editor.pro deleted file mode 120000 index eb1b3bf56..000000000 --- a/olive-editor.pro +++ /dev/null @@ -1 +0,0 @@ -olive.pro \ No newline at end of file From 19765088d9b537ae6f78eea1554c495e4297396b Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Wed, 2 Jan 2019 12:07:15 +1100 Subject: [PATCH 04/10] corrected sample rate issue when exporting --- playback/audio.cpp | 7 +- playback/audio.h | 2 + playback/cacher.cpp | 1024 +++++++++++++++++++++---------------------- 3 files changed, 520 insertions(+), 513 deletions(-) diff --git a/playback/audio.cpp b/playback/audio.cpp index e5e90601e..aa0c38b2b 100644 --- a/playback/audio.cpp +++ b/playback/audio.cpp @@ -8,6 +8,7 @@ #include "panels/timeline.h" #include "panels/viewer.h" #include "ui/audiomonitor.h" +#include "playback/playback.h" #include "debug.h" #include @@ -104,9 +105,13 @@ void clear_audio_ibuffer() { audio_ibuffer_read = 0; } +int current_audio_freq() { + return rendering ? sequence->audio_frequency : audio_output->format().sampleRate(); +} + int get_buffer_offset_from_frame(double framerate, long frame) { if (frame >= audio_ibuffer_frame) { - return qFloor(((double) (frame - audio_ibuffer_frame)/framerate)*audio_output->format().sampleRate())*av_get_bytes_per_sample(AV_SAMPLE_FMT_S16)*av_get_channel_layout_nb_channels(AV_CH_LAYOUT_STEREO); + return qFloor(((double) (frame - audio_ibuffer_frame)/framerate)*current_audio_freq())*av_get_bytes_per_sample(AV_SAMPLE_FMT_S16)*av_get_channel_layout_nb_channels(AV_CH_LAYOUT_STEREO); } else { dout << "[WARNING] Invalid values passed to get_buffer_offset_from_frame"; return 0; diff --git a/playback/audio.h b/playback/audio.h index 795c6ba01..081a92e78 100644 --- a/playback/audio.h +++ b/playback/audio.h @@ -43,6 +43,8 @@ extern double audio_ibuffer_timecode; extern bool audio_scrub; void clear_audio_ibuffer(); +int current_audio_freq(); + bool is_audio_device_set(); void init_audio(); diff --git a/playback/cacher.cpp b/playback/cacher.cpp index ae3ecc683..d9a7056ce 100644 --- a/playback/cacher.cpp +++ b/playback/cacher.cpp @@ -42,36 +42,36 @@ double bytes_to_seconds(int nb_bytes, int nb_channels, int sample_rate) { } void apply_audio_effects(Clip* c, double timecode_start, AVFrame* frame, int nb_bytes, QVector nests) { - // perform all audio effects + // perform all audio effects double timecode_end; timecode_end = timecode_start + bytes_to_seconds(nb_bytes, frame->channels, frame->sample_rate); - for (int j=0;jeffects.size();j++) { + for (int j=0;jeffects.size();j++) { Effect* e = c->effects.at(j); if (e->is_enabled()) e->process_audio(timecode_start, timecode_end, frame->data[0], nb_bytes, 2); - } - if (c->get_opening_transition() != NULL) { - if (c->media != NULL && c->media->get_type() == MEDIA_TYPE_FOOTAGE) { - double transition_start = (c->get_clip_in_with_transition() / c->sequence->frame_rate); - double transition_end = (c->get_clip_in_with_transition() + c->get_opening_transition()->get_length()) / c->sequence->frame_rate; + } + if (c->get_opening_transition() != NULL) { + if (c->media != NULL && c->media->get_type() == MEDIA_TYPE_FOOTAGE) { + double transition_start = (c->get_clip_in_with_transition() / c->sequence->frame_rate); + double transition_end = (c->get_clip_in_with_transition() + c->get_opening_transition()->get_length()) / c->sequence->frame_rate; if (timecode_end < transition_end) { double adjustment = transition_end - transition_start; double adjusted_range_start = (timecode_start - transition_start) / adjustment; double adjusted_range_end = (timecode_end - transition_start) / adjustment; - c->get_opening_transition()->process_audio(adjusted_range_start, adjusted_range_end, frame->data[0], nb_bytes, TA_OPENING_TRANSITION); + c->get_opening_transition()->process_audio(adjusted_range_start, adjusted_range_end, frame->data[0], nb_bytes, TA_OPENING_TRANSITION); } } } - if (c->get_closing_transition() != NULL) { - if (c->media != NULL && c->media->get_type() == MEDIA_TYPE_FOOTAGE) { - long length_with_transitions = c->get_timeline_out_with_transition() - c->get_timeline_in_with_transition(); - double transition_start = (c->get_clip_in_with_transition() + length_with_transitions - c->get_closing_transition()->get_length()) / c->sequence->frame_rate; - double transition_end = (c->get_clip_in_with_transition() + length_with_transitions) / c->sequence->frame_rate; - if (timecode_start > transition_start) { + if (c->get_closing_transition() != NULL) { + if (c->media != NULL && c->media->get_type() == MEDIA_TYPE_FOOTAGE) { + long length_with_transitions = c->get_timeline_out_with_transition() - c->get_timeline_in_with_transition(); + double transition_start = (c->get_clip_in_with_transition() + length_with_transitions - c->get_closing_transition()->get_length()) / c->sequence->frame_rate; + double transition_end = (c->get_clip_in_with_transition() + length_with_transitions) / c->sequence->frame_rate; + if (timecode_start > transition_start) { double adjustment = transition_end - transition_start; double adjusted_range_start = (timecode_start - transition_start) / adjustment; double adjusted_range_end = (timecode_end - transition_start) / adjustment; - c->get_closing_transition()->process_audio(adjusted_range_start, adjusted_range_end, frame->data[0], nb_bytes, TA_CLOSING_TRANSITION); + c->get_closing_transition()->process_audio(adjusted_range_start, adjusted_range_end, frame->data[0], nb_bytes, TA_CLOSING_TRANSITION); } } } @@ -79,290 +79,290 @@ void apply_audio_effects(Clip* c, double timecode_start, AVFrame* frame, int nb_ if (!nests.isEmpty()) { Clip* next_nest = nests.last(); nests.removeLast(); - apply_audio_effects(next_nest, timecode_start + (((double)c->get_timeline_in_with_transition()-c->get_clip_in_with_transition())/c->sequence->frame_rate), frame, nb_bytes, nests); + apply_audio_effects(next_nest, timecode_start + (((double)c->get_timeline_in_with_transition()-c->get_clip_in_with_transition())/c->sequence->frame_rate), frame, nb_bytes, nests); } } #define AUDIO_BUFFER_PADDING 2048 void cache_audio_worker(Clip* c, bool scrubbing, QVector& nests) { - long timeline_in = c->get_timeline_in_with_transition(); - long timeline_out = c->get_timeline_out_with_transition(); + long timeline_in = c->get_timeline_in_with_transition(); + long timeline_out = c->get_timeline_out_with_transition(); long target_frame = c->audio_target_frame; long frame_skip = 0; - double last_fr = c->sequence->frame_rate; + double last_fr = c->sequence->frame_rate; if (!nests.isEmpty()) { for (int i=nests.size()-1;i>=0;i--) { - timeline_in = refactor_frame_number(timeline_in, last_fr, nests.at(i)->sequence->frame_rate) + nests.at(i)->get_timeline_in_with_transition() - nests.at(i)->get_clip_in_with_transition(); - timeline_out = refactor_frame_number(timeline_out, last_fr, nests.at(i)->sequence->frame_rate) + nests.at(i)->get_timeline_in_with_transition() - nests.at(i)->get_clip_in_with_transition(); - target_frame = refactor_frame_number(target_frame, last_fr, nests.at(i)->sequence->frame_rate) + nests.at(i)->get_timeline_in_with_transition() - nests.at(i)->get_clip_in_with_transition(); + timeline_in = refactor_frame_number(timeline_in, last_fr, nests.at(i)->sequence->frame_rate) + nests.at(i)->get_timeline_in_with_transition() - nests.at(i)->get_clip_in_with_transition(); + timeline_out = refactor_frame_number(timeline_out, last_fr, nests.at(i)->sequence->frame_rate) + nests.at(i)->get_timeline_in_with_transition() - nests.at(i)->get_clip_in_with_transition(); + target_frame = refactor_frame_number(target_frame, last_fr, nests.at(i)->sequence->frame_rate) + nests.at(i)->get_timeline_in_with_transition() - nests.at(i)->get_clip_in_with_transition(); - timeline_out = qMin(timeline_out, nests.at(i)->get_timeline_out_with_transition()); + timeline_out = qMin(timeline_out, nests.at(i)->get_timeline_out_with_transition()); frame_skip = refactor_frame_number(frame_skip, last_fr, nests.at(i)->sequence->frame_rate); - long validator = nests.at(i)->get_timeline_in_with_transition() - timeline_in; + long validator = nests.at(i)->get_timeline_in_with_transition() - timeline_in; if (validator > 0) { frame_skip += validator; - //timeline_in = nests.at(i)->get_timeline_in_with_transition(); + //timeline_in = nests.at(i)->get_timeline_in_with_transition(); } last_fr = nests.at(i)->sequence->frame_rate; } } - while (true) { + while (true) { AVFrame* frame; int nb_bytes = INT_MAX; - if (c->media == NULL) { - frame = c->frame; - nb_bytes = frame->nb_samples * av_get_bytes_per_sample(static_cast(frame->format)) * frame->channels; - while ((c->frame_sample_index == -1 || c->frame_sample_index >= nb_bytes) && nb_bytes > 0) { - // create "new frame" - memset(c->frame->data[0], 0, nb_bytes); - apply_audio_effects(c, bytes_to_seconds(frame->pts, frame->channels, frame->sample_rate), frame, nb_bytes, nests); - c->frame->pts += nb_bytes; - c->frame_sample_index = 0; - if (c->audio_buffer_write == 0) { - c->audio_buffer_write = get_buffer_offset_from_frame(last_fr, qMax(timeline_in, target_frame)); - } - int offset = audio_ibuffer_read - c->audio_buffer_write; - if (offset > 0) { - c->audio_buffer_write += offset; - c->frame_sample_index += offset; - } - } - } else if (c->media->get_type() == MEDIA_TYPE_FOOTAGE) { - double timebase = av_q2d(c->stream->time_base); + if (c->media == NULL) { + frame = c->frame; + nb_bytes = frame->nb_samples * av_get_bytes_per_sample(static_cast(frame->format)) * frame->channels; + while ((c->frame_sample_index == -1 || c->frame_sample_index >= nb_bytes) && nb_bytes > 0) { + // create "new frame" + memset(c->frame->data[0], 0, nb_bytes); + apply_audio_effects(c, bytes_to_seconds(frame->pts, frame->channels, frame->sample_rate), frame, nb_bytes, nests); + c->frame->pts += nb_bytes; + c->frame_sample_index = 0; + if (c->audio_buffer_write == 0) { + c->audio_buffer_write = get_buffer_offset_from_frame(last_fr, qMax(timeline_in, target_frame)); + } + int offset = audio_ibuffer_read - c->audio_buffer_write; + if (offset > 0) { + c->audio_buffer_write += offset; + c->frame_sample_index += offset; + } + } + } else if (c->media->get_type() == MEDIA_TYPE_FOOTAGE) { + double timebase = av_q2d(c->stream->time_base); - frame = c->queue.at(0); + frame = c->queue.at(0); - // retrieve frame - bool new_frame = false; - while ((c->frame_sample_index == -1 || c->frame_sample_index >= nb_bytes) && nb_bytes > 0) { - // no more audio left in frame, get a new one - if (!c->reached_end) { - int loop = 0; + // retrieve frame + bool new_frame = false; + while ((c->frame_sample_index == -1 || c->frame_sample_index >= nb_bytes) && nb_bytes > 0) { + // no more audio left in frame, get a new one + if (!c->reached_end) { + int loop = 0; - if (c->reverse && !c->audio_just_reset) { - avcodec_flush_buffers(c->codecCtx); - c->reached_end = false; - int64_t backtrack_seek = qMax(c->reverse_target - static_cast(av_q2d(av_inv_q(c->stream->time_base))), static_cast(0)); - av_seek_frame(c->formatCtx, c->stream->index, backtrack_seek, AVSEEK_FLAG_BACKWARD); + if (c->reverse && !c->audio_just_reset) { + avcodec_flush_buffers(c->codecCtx); + c->reached_end = false; + int64_t backtrack_seek = qMax(c->reverse_target - static_cast(av_q2d(av_inv_q(c->stream->time_base))), static_cast(0)); + av_seek_frame(c->formatCtx, c->stream->index, backtrack_seek, AVSEEK_FLAG_BACKWARD); #ifdef AUDIOWARNINGS - if (backtrack_seek == 0) { - dout << "backtracked to 0"; - } + if (backtrack_seek == 0) { + dout << "backtracked to 0"; + } #endif - } + } - do { - av_frame_unref(frame); + do { + av_frame_unref(frame); - int ret; + int ret; - while ((ret = av_buffersink_get_frame(c->buffersink_ctx, frame)) == AVERROR(EAGAIN)) { - ret = retrieve_next_frame(c, c->frame); - if (ret >= 0) { - if ((ret = av_buffersrc_add_frame_flags(c->buffersrc_ctx, c->frame, AV_BUFFERSRC_FLAG_KEEP_REF)) < 0) { - dout << "[ERROR] Could not feed filtergraph -" << ret; - break; - } - } else { - if (ret == AVERROR_EOF) { + while ((ret = av_buffersink_get_frame(c->buffersink_ctx, frame)) == AVERROR(EAGAIN)) { + ret = retrieve_next_frame(c, c->frame); + if (ret >= 0) { + if ((ret = av_buffersrc_add_frame_flags(c->buffersrc_ctx, c->frame, AV_BUFFERSRC_FLAG_KEEP_REF)) < 0) { + dout << "[ERROR] Could not feed filtergraph -" << ret; + break; + } + } else { + if (ret == AVERROR_EOF) { #ifdef AUDIOWARNINGS - dout << "reached EOF while reading"; + dout << "reached EOF while reading"; #endif - // TODO revise usage of reached_end in audio - if (!c->reverse) { - c->reached_end = true; - } else { - } - } else { - dout << "[WARNING] Raw audio frame data could not be retrieved." << ret; - c->reached_end = true; - } - break; - } - } + // TODO revise usage of reached_end in audio + if (!c->reverse) { + c->reached_end = true; + } else { + } + } else { + dout << "[WARNING] Raw audio frame data could not be retrieved." << ret; + c->reached_end = true; + } + break; + } + } - if (ret < 0) { - if (ret != AVERROR_EOF) { - dout << "[ERROR] Could not pull from filtergraph"; - c->reached_end = true; - break; - } else { + if (ret < 0) { + if (ret != AVERROR_EOF) { + dout << "[ERROR] Could not pull from filtergraph"; + c->reached_end = true; + break; + } else { #ifdef AUDIOWARNINGS - dout << "reached EOF while pulling from filtergraph"; + dout << "reached EOF while pulling from filtergraph"; #endif - if (!c->reverse) break; - } - } + if (!c->reverse) break; + } + } - if (c->reverse) { - if (loop > 1) { - AVFrame* rev_frame = c->queue.at(1); - if (ret != AVERROR_EOF) { - if (loop == 2) { + if (c->reverse) { + if (loop > 1) { + AVFrame* rev_frame = c->queue.at(1); + if (ret != AVERROR_EOF) { + if (loop == 2) { #ifdef AUDIOWARNINGS - dout << "starting rev_frame"; + dout << "starting rev_frame"; #endif - rev_frame->nb_samples = 0; - rev_frame->pts = c->frame->pkt_pts; - } - int offset = rev_frame->nb_samples * av_get_bytes_per_sample(static_cast(rev_frame->format)) * rev_frame->channels; + rev_frame->nb_samples = 0; + rev_frame->pts = c->frame->pkt_pts; + } + int offset = rev_frame->nb_samples * av_get_bytes_per_sample(static_cast(rev_frame->format)) * rev_frame->channels; #ifdef AUDIOWARNINGS - dout << "offset 1:" << offset; - dout << "retrieved samples:" << frame->nb_samples << "size:" << (frame->nb_samples * av_get_bytes_per_sample(static_cast(frame->format)) * frame->channels); + dout << "offset 1:" << offset; + dout << "retrieved samples:" << frame->nb_samples << "size:" << (frame->nb_samples * av_get_bytes_per_sample(static_cast(frame->format)) * frame->channels); #endif - memcpy( - rev_frame->data[0]+offset, - frame->data[0], - (frame->nb_samples * av_get_bytes_per_sample(static_cast(frame->format)) * frame->channels) - ); + memcpy( + rev_frame->data[0]+offset, + frame->data[0], + (frame->nb_samples * av_get_bytes_per_sample(static_cast(frame->format)) * frame->channels) + ); #ifdef AUDIOWARNINGS - dout << "pts:" << c->frame->pts << "dur:" << c->frame->pkt_duration << "rev_target:" << c->reverse_target << "offset:" << offset << "limit:" << rev_frame->linesize[0]; + dout << "pts:" << c->frame->pts << "dur:" << c->frame->pkt_duration << "rev_target:" << c->reverse_target << "offset:" << offset << "limit:" << rev_frame->linesize[0]; #endif - } + } - rev_frame->nb_samples += frame->nb_samples; + rev_frame->nb_samples += frame->nb_samples; - if ((c->frame->pts >= c->reverse_target) || (ret == AVERROR_EOF)) { + if ((c->frame->pts >= c->reverse_target) || (ret == AVERROR_EOF)) { /* #ifdef AUDIOWARNINGS - dout << "time for the end of rev cache" << rev_frame->nb_samples << c->rev_target << c->frame->pts << c->frame->pkt_duration << c->frame->nb_samples; - dout << "diff:" << (c->frame->pkt_pts + c->frame->pkt_duration) - c->rev_target; + dout << "time for the end of rev cache" << rev_frame->nb_samples << c->rev_target << c->frame->pts << c->frame->pkt_duration << c->frame->nb_samples; + dout << "diff:" << (c->frame->pkt_pts + c->frame->pkt_duration) - c->rev_target; #endif - int cutoff = qRound64((((c->frame->pkt_pts + c->frame->pkt_duration) - c->reverse_target) * timebase) * audio_output->format().sampleRate()); - if (cutoff > 0) { + int cutoff = qRound64((((c->frame->pkt_pts + c->frame->pkt_duration) - c->reverse_target) * timebase) * audio_output->format().sampleRate()); + if (cutoff > 0) { #ifdef AUDIOWARNINGS - dout << "cut off" << cutoff << "samples (rate:" << audio_output->format().sampleRate() << ")"; + dout << "cut off" << cutoff << "samples (rate:" << audio_output->format().sampleRate() << ")"; #endif - rev_frame->nb_samples -= cutoff; - } + rev_frame->nb_samples -= cutoff; + } */ #ifdef AUDIOWARNINGS - dout << "pre cutoff deets::: rev_frame.pts:" << rev_frame->pts << "rev_frame.nb_samples" << rev_frame->nb_samples << "rev_target:" << c->reverse_target; + dout << "pre cutoff deets::: rev_frame.pts:" << rev_frame->pts << "rev_frame.nb_samples" << rev_frame->nb_samples << "rev_target:" << c->reverse_target; #endif - rev_frame->nb_samples = qRound64(static_cast(c->reverse_target - rev_frame->pts) / c->stream->codecpar->sample_rate * (audio_output->format().sampleRate() / c->speed)); + rev_frame->nb_samples = qRound64(static_cast(c->reverse_target - rev_frame->pts) / c->stream->codecpar->sample_rate * (current_audio_freq() / c->speed)); #ifdef AUDIOWARNINGS - dout << "post cutoff deets::" << rev_frame->nb_samples; + dout << "post cutoff deets::" << rev_frame->nb_samples; #endif - int frame_size = rev_frame->nb_samples * rev_frame->channels * av_get_bytes_per_sample(static_cast(rev_frame->format)); - int half_frame_size = frame_size >> 1; + int frame_size = rev_frame->nb_samples * rev_frame->channels * av_get_bytes_per_sample(static_cast(rev_frame->format)); + int half_frame_size = frame_size >> 1; - int sample_size = rev_frame->channels*av_get_bytes_per_sample(static_cast(rev_frame->format)); - char* temp_chars = new char[sample_size]; - for (int i=0;idata[0][i+j]; - } - for (int j=0;jdata[0][i+j] = rev_frame->data[0][frame_size-i-sample_size+j]; - } - for (int j=0;jdata[0][frame_size-i-sample_size+j] = temp_chars[j]; - } - } - delete [] temp_chars; + int sample_size = rev_frame->channels*av_get_bytes_per_sample(static_cast(rev_frame->format)); + char* temp_chars = new char[sample_size]; + for (int i=0;idata[0][i+j]; + } + for (int j=0;jdata[0][i+j] = rev_frame->data[0][frame_size-i-sample_size+j]; + } + for (int j=0;jdata[0][frame_size-i-sample_size+j] = temp_chars[j]; + } + } + delete [] temp_chars; - c->reverse_target = rev_frame->pts; - frame = rev_frame; - break; - } - } + c->reverse_target = rev_frame->pts; + frame = rev_frame; + break; + } + } - loop++; + loop++; #ifdef AUDIOWARNINGS - dout << "loop" << loop; + dout << "loop" << loop; #endif - } else { - frame->pts = c->frame->pts; - break; - } - } while (true); - } else { - // if there is no more data in the file, we flush the remainder out of swresample - break; - } + } else { + frame->pts = c->frame->pts; + break; + } + } while (true); + } else { + // if there is no more data in the file, we flush the remainder out of swresample + break; + } - new_frame = true; + new_frame = true; - if (c->frame_sample_index < 0) { - c->frame_sample_index = 0; - } else { - c->frame_sample_index -= nb_bytes; - } + if (c->frame_sample_index < 0) { + c->frame_sample_index = 0; + } else { + c->frame_sample_index -= nb_bytes; + } - nb_bytes = frame->nb_samples * av_get_bytes_per_sample(static_cast(frame->format)) * frame->channels; + nb_bytes = frame->nb_samples * av_get_bytes_per_sample(static_cast(frame->format)) * frame->channels; - if (c->audio_just_reset) { - // get precise sample offset for the elected clip_in from this audio frame - double target_sts = playhead_to_clip_seconds(c, c->audio_target_frame); - double frame_sts = ((frame->pts - c->stream->start_time) * timebase); - int nb_samples = qRound64((target_sts - frame_sts)*audio_output->format().sampleRate()); - c->frame_sample_index = nb_samples * 4; + if (c->audio_just_reset) { + // get precise sample offset for the elected clip_in from this audio frame + double target_sts = playhead_to_clip_seconds(c, c->audio_target_frame); + double frame_sts = ((frame->pts - c->stream->start_time) * timebase); + int nb_samples = qRound64((target_sts - frame_sts)*current_audio_freq()); + c->frame_sample_index = nb_samples * 4; #ifdef AUDIOWARNINGS - dout << "fsts:" << frame_sts << "tsts:" << target_sts << "nbs:" << nb_samples << "nbb:" << nb_bytes << "rev_targetToSec:" << (c->reverse_target * timebase); - dout << "fsi-calc:" << c->frame_sample_index; + dout << "fsts:" << frame_sts << "tsts:" << target_sts << "nbs:" << nb_samples << "nbb:" << nb_bytes << "rev_targetToSec:" << (c->reverse_target * timebase); + dout << "fsi-calc:" << c->frame_sample_index; #endif - if (c->reverse) c->frame_sample_index = nb_bytes - c->frame_sample_index; - c->audio_just_reset = false; - } + if (c->reverse) c->frame_sample_index = nb_bytes - c->frame_sample_index; + c->audio_just_reset = false; + } #ifdef AUDIOWARNINGS - dout << "fsi-post-post:" << c->frame_sample_index; + dout << "fsi-post-post:" << c->frame_sample_index; #endif - if (c->audio_buffer_write == 0) { - c->audio_buffer_write = get_buffer_offset_from_frame(last_fr, qMax(timeline_in, target_frame)); + if (c->audio_buffer_write == 0) { + c->audio_buffer_write = get_buffer_offset_from_frame(last_fr, qMax(timeline_in, target_frame)); - if (frame_skip > 0) { - int target = get_buffer_offset_from_frame(last_fr, qMax(timeline_in + frame_skip, target_frame)); - c->frame_sample_index += (target - c->audio_buffer_write); - c->audio_buffer_write = target; - } - } + if (frame_skip > 0) { + int target = get_buffer_offset_from_frame(last_fr, qMax(timeline_in + frame_skip, target_frame)); + c->frame_sample_index += (target - c->audio_buffer_write); + c->audio_buffer_write = target; + } + } - int offset = audio_ibuffer_read - c->audio_buffer_write; - if (offset > 0) { - c->audio_buffer_write += offset; - c->frame_sample_index += offset; - } + int offset = audio_ibuffer_read - c->audio_buffer_write; + if (offset > 0) { + c->audio_buffer_write += offset; + c->frame_sample_index += offset; + } - // try to correct negative fsi - if (c->frame_sample_index < 0) { - c->audio_buffer_write -= c->frame_sample_index; - c->frame_sample_index = 0; - } - } + // try to correct negative fsi + if (c->frame_sample_index < 0) { + c->audio_buffer_write -= c->frame_sample_index; + c->frame_sample_index = 0; + } + } - if (c->reverse) frame = c->queue.at(1); + if (c->reverse) frame = c->queue.at(1); #ifdef AUDIOWARNINGS - dout << "j" << c->frame_sample_index << nb_bytes; + dout << "j" << c->frame_sample_index << nb_bytes; #endif - // apply any audio effects to the data - if (nb_bytes == INT_MAX) nb_bytes = frame->nb_samples * av_get_bytes_per_sample(static_cast(frame->format)) * frame->channels; - if (new_frame) { - apply_audio_effects(c, bytes_to_seconds(c->audio_buffer_write, 2, audio_output->format().sampleRate()) + audio_ibuffer_timecode + ((double)c->get_clip_in_with_transition()/c->sequence->frame_rate) - ((double)timeline_in/last_fr), frame, nb_bytes, nests); - } - } else { - // shouldn't ever get here - dout << "[ERROR] Tried to cache a non-footage/tone clip"; - return; - } + // apply any audio effects to the data + if (nb_bytes == INT_MAX) nb_bytes = frame->nb_samples * av_get_bytes_per_sample(static_cast(frame->format)) * frame->channels; + if (new_frame) { + apply_audio_effects(c, bytes_to_seconds(c->audio_buffer_write, 2, current_audio_freq()) + audio_ibuffer_timecode + ((double)c->get_clip_in_with_transition()/c->sequence->frame_rate) - ((double)timeline_in/last_fr), frame, nb_bytes, nests); + } + } else { + // shouldn't ever get here + dout << "[ERROR] Tried to cache a non-footage/tone clip"; + return; + } // mix audio into internal buffer if (frame->nb_samples == 0) { break; } else { - long buffer_timeline_out = get_buffer_offset_from_frame(c->sequence->frame_rate, timeline_out); + long buffer_timeline_out = get_buffer_offset_from_frame(c->sequence->frame_rate, timeline_out); audio_write_lock.lock(); while (c->frame_sample_index < nb_bytes @@ -387,9 +387,9 @@ void cache_audio_worker(Clip* c, bool scrubbing, QVector& nests) { audio_write_lock.unlock(); - if (scrubbing) { - if (audio_thread != NULL) audio_thread->notifyReceiver(); - } + if (scrubbing) { + if (audio_thread != NULL) audio_thread->notifyReceiver(); + } if (c->frame_sample_index == nb_bytes) { c->frame_sample_index = -1; @@ -403,9 +403,9 @@ void cache_audio_worker(Clip* c, bool scrubbing, QVector& nests) { if (c->reached_end) { frame->nb_samples = 0; } - if (scrubbing) { - break; - } + if (scrubbing) { + break; + } } QMetaObject::invokeMethod(panel_footage_viewer, "play_wake", Qt::QueuedConnection); @@ -425,7 +425,7 @@ void cache_video_worker(Clip* c, long playhead) { limit *= 2; } - if (c->queue.size() < limit) { + if (c->queue.size() < limit) { bool reverse = (c->reverse && !c->ignore_reverse); c->ignore_reverse = false; @@ -443,40 +443,40 @@ void cache_video_worker(Clip* c, long playhead) { smallest_pts = target_pts; } - if (c->multithreaded && c->cacher->interrupt) { // ignore interrupts for now - c->cacher->interrupt = false; - } + if (c->multithreaded && c->cacher->interrupt) { // ignore interrupts for now + c->cacher->interrupt = false; + } while (true) { AVFrame* frame = av_frame_alloc(); - Footage* media = c->media->to_footage(); + Footage* media = c->media->to_footage(); FootageStream* ms = media->get_stream_from_file_index(true, c->media_stream); while ((retr_ret = av_buffersink_get_frame(c->buffersink_ctx, frame)) == AVERROR(EAGAIN)) { - if (c->multithreaded && c->cacher->interrupt) return; // abort + if (c->multithreaded && c->cacher->interrupt) return; // abort AVFrame* send_frame = c->frame; read_ret = (c->use_existing_frame) ? 0 : retrieve_next_frame(c, send_frame); c->use_existing_frame = false; if (read_ret >= 0) { - bool send_it = true; + bool send_it = true; - /*if (reverse) { + /*if (reverse) { send_it = true; } else if (send_frame->pts > target_pts - eighth_second) { send_it = true; } else if (media->get_stream_from_file_index(true, c->media_stream)->infinite_length) { send_it = true; - } else { + } else { dout << "skipped adding a frame to the queue - fpts:" << send_frame->pts << "target:" << target_pts; - }*/ + }*/ - if (send_it) { + if (send_it) { if ((send_ret = av_buffersrc_add_frame_flags(c->buffersrc_ctx, send_frame, AV_BUFFERSRC_FLAG_KEEP_REF)) < 0) { dout << "[ERROR] Failed to add frame to buffer source." << send_ret; break; - } + } } av_frame_unref(c->frame); @@ -510,7 +510,7 @@ void cache_video_worker(Clip* c, long playhead) { if (!ms->infinite_length && !reverse && c->queue.size() == limit) { // see if we got the frame we needed (used for speed ups primarily) bool found = false; - for (int i=0;iqueue.size();i++) { + for (int i=0;iqueue.size();i++) { if (c->queue.at(i)->pts >= target_pts) { found = true; break; @@ -528,92 +528,92 @@ void cache_video_worker(Clip* c, long playhead) { } } - if (c->multithreaded && c->cacher->interrupt) { // abort - return; - } + if (c->multithreaded && c->cacher->interrupt) { // abort + return; + } } } } void reset_cache(Clip* c, long target_frame) { - // if we seek to a whole other place in the timeline, we'll need to reset the cache with new values - if (c->media == NULL) { - if (c->track >= 0) { - // tone clip - c->reached_end = false; - c->audio_target_frame = target_frame; - c->frame_sample_index = -1; - c->frame->pts = 0; - } - } else { - FootageStream* ms = c->media->to_footage()->get_stream_from_file_index(c->track < 0, c->media_stream); - if (ms->infinite_length) { - /*avcodec_flush_buffers(c->codecCtx); - av_seek_frame(c->formatCtx, ms->file_index, 0, AVSEEK_FLAG_BACKWARD);*/ - c->use_existing_frame = false; - } else { - if (c->stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { - // clear current queue - c->queue_clear(); + // if we seek to a whole other place in the timeline, we'll need to reset the cache with new values + if (c->media == NULL) { + if (c->track >= 0) { + // tone clip + c->reached_end = false; + c->audio_target_frame = target_frame; + c->frame_sample_index = -1; + c->frame->pts = 0; + } + } else { + FootageStream* ms = c->media->to_footage()->get_stream_from_file_index(c->track < 0, c->media_stream); + if (ms->infinite_length) { + /*avcodec_flush_buffers(c->codecCtx); + av_seek_frame(c->formatCtx, ms->file_index, 0, AVSEEK_FLAG_BACKWARD);*/ + c->use_existing_frame = false; + } else { + if (c->stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { + // clear current queue + c->queue_clear(); - // seeks to nearest keyframe (target_frame represents internal clip frame) - int64_t target_ts = seconds_to_timestamp(c, playhead_to_clip_seconds(c, target_frame)); - int64_t seek_ts = target_ts; - int64_t timebase_half_second = qRound64(av_q2d(av_inv_q(c->stream->time_base))); - if (c->reverse) seek_ts -= timebase_half_second; + // seeks to nearest keyframe (target_frame represents internal clip frame) + int64_t target_ts = seconds_to_timestamp(c, playhead_to_clip_seconds(c, target_frame)); + int64_t seek_ts = target_ts; + int64_t timebase_half_second = qRound64(av_q2d(av_inv_q(c->stream->time_base))); + if (c->reverse) seek_ts -= timebase_half_second; - while (true) { - // flush ffmpeg codecs - avcodec_flush_buffers(c->codecCtx); - c->reached_end = false; + while (true) { + // flush ffmpeg codecs + avcodec_flush_buffers(c->codecCtx); + c->reached_end = false; - if (seek_ts > 0) { - av_seek_frame(c->formatCtx, ms->file_index, seek_ts, AVSEEK_FLAG_BACKWARD); + if (seek_ts > 0) { + av_seek_frame(c->formatCtx, ms->file_index, seek_ts, AVSEEK_FLAG_BACKWARD); - av_frame_unref(c->frame); - int ret = retrieve_next_frame(c, c->frame); - if (ret < 0) { - dout << "[WARNING] Seeking terminated prematurely"; - break; - } - if (c->frame->pts <= target_ts) { - c->use_existing_frame = true; - break; - } else { - seek_ts -= timebase_half_second; - } - } else { - av_frame_unref(c->frame); - av_seek_frame(c->formatCtx, ms->file_index, 0, AVSEEK_FLAG_BACKWARD); - c->use_existing_frame = false; - break; - } - } - } else if (c->stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { - // flush ffmpeg codecs - avcodec_flush_buffers(c->codecCtx); - c->reached_end = false; + av_frame_unref(c->frame); + int ret = retrieve_next_frame(c, c->frame); + if (ret < 0) { + dout << "[WARNING] Seeking terminated prematurely"; + break; + } + if (c->frame->pts <= target_ts) { + c->use_existing_frame = true; + break; + } else { + seek_ts -= timebase_half_second; + } + } else { + av_frame_unref(c->frame); + av_seek_frame(c->formatCtx, ms->file_index, 0, AVSEEK_FLAG_BACKWARD); + c->use_existing_frame = false; + break; + } + } + } else if (c->stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { + // flush ffmpeg codecs + avcodec_flush_buffers(c->codecCtx); + c->reached_end = false; - // seek (target_frame represents timeline timecode in frames, not clip timecode) + // seek (target_frame represents timeline timecode in frames, not clip timecode) - int64_t timestamp = seconds_to_timestamp(c, playhead_to_clip_seconds(c, target_frame)); + int64_t timestamp = seconds_to_timestamp(c, playhead_to_clip_seconds(c, target_frame)); - if (c->reverse) { - c->reverse_target = timestamp; - timestamp -= av_q2d(av_inv_q(c->stream->time_base)); + if (c->reverse) { + c->reverse_target = timestamp; + timestamp -= av_q2d(av_inv_q(c->stream->time_base)); #ifdef AUDIOWARNINGS - dout << "seeking to" << timestamp << "(originally" << c->reverse_target << ")"; - } else { - dout << "reset called; seeking to" << timestamp; + dout << "seeking to" << timestamp << "(originally" << c->reverse_target << ")"; + } else { + dout << "reset called; seeking to" << timestamp; #endif - } - av_seek_frame(c->formatCtx, ms->file_index, timestamp, AVSEEK_FLAG_BACKWARD); - c->audio_target_frame = target_frame; - c->frame_sample_index = -1; - c->audio_just_reset = true; - } - } - } + } + av_seek_frame(c->formatCtx, ms->file_index, timestamp, AVSEEK_FLAG_BACKWARD); + c->audio_target_frame = target_frame; + c->frame_sample_index = -1; + c->audio_just_reset = true; + } + } + } } Cacher::Cacher(Clip* c) : clip(c) {} @@ -621,122 +621,122 @@ Cacher::Cacher(Clip* c) : clip(c) {} AVSampleFormat sample_format = AV_SAMPLE_FMT_S16; void open_clip_worker(Clip* clip) { - if (clip->media == NULL) { - if (clip->track >= 0) { - clip->frame = av_frame_alloc(); - clip->frame->format = sample_format; - clip->frame->channel_layout = clip->sequence->audio_layout; - clip->frame->channels = av_get_channel_layout_nb_channels(clip->frame->channel_layout); - clip->frame->sample_rate = audio_output->format().sampleRate(); - clip->frame->nb_samples = 2048; - av_frame_make_writable(clip->frame); - if (av_frame_get_buffer(clip->frame, 0)) { - dout << "[ERROR] Could not allocate buffer for tone clip"; - } - clip->audio_reset = true; - } - } else if (clip->media->get_type() == MEDIA_TYPE_FOOTAGE) { - // opens file resource for FFmpeg and prepares Clip struct for playback - Footage* m = clip->media->to_footage(); - QByteArray ba = m->url.toUtf8(); - const char* filename = ba.constData(); - FootageStream* ms = m->get_stream_from_file_index(clip->track < 0, clip->media_stream); + if (clip->media == NULL) { + if (clip->track >= 0) { + clip->frame = av_frame_alloc(); + clip->frame->format = sample_format; + clip->frame->channel_layout = clip->sequence->audio_layout; + clip->frame->channels = av_get_channel_layout_nb_channels(clip->frame->channel_layout); + clip->frame->sample_rate = current_audio_freq(); + clip->frame->nb_samples = 2048; + av_frame_make_writable(clip->frame); + if (av_frame_get_buffer(clip->frame, 0)) { + dout << "[ERROR] Could not allocate buffer for tone clip"; + } + clip->audio_reset = true; + } + } else if (clip->media->get_type() == MEDIA_TYPE_FOOTAGE) { + // opens file resource for FFmpeg and prepares Clip struct for playback + Footage* m = clip->media->to_footage(); + QByteArray ba = m->url.toUtf8(); + const char* filename = ba.constData(); + FootageStream* ms = m->get_stream_from_file_index(clip->track < 0, clip->media_stream); - int errCode = avformat_open_input( - &clip->formatCtx, - filename, - NULL, - NULL - ); - if (errCode != 0) { - char err[1024]; - av_strerror(errCode, err, 1024); - dout << "[ERROR] Could not open" << filename << "-" << err; - return; - } + int errCode = avformat_open_input( + &clip->formatCtx, + filename, + NULL, + NULL + ); + if (errCode != 0) { + char err[1024]; + av_strerror(errCode, err, 1024); + dout << "[ERROR] Could not open" << filename << "-" << err; + return; + } - errCode = avformat_find_stream_info(clip->formatCtx, NULL); - if (errCode < 0) { - char err[1024]; - av_strerror(errCode, err, 1024); - dout << "[ERROR] Could not open" << filename << "-" << err; - return; - } + errCode = avformat_find_stream_info(clip->formatCtx, NULL); + if (errCode < 0) { + char err[1024]; + av_strerror(errCode, err, 1024); + dout << "[ERROR] Could not open" << filename << "-" << err; + return; + } - av_dump_format(clip->formatCtx, 0, filename, 0); + av_dump_format(clip->formatCtx, 0, filename, 0); - clip->stream = clip->formatCtx->streams[ms->file_index]; - clip->codec = avcodec_find_decoder(clip->stream->codecpar->codec_id); - clip->codecCtx = avcodec_alloc_context3(clip->codec); - avcodec_parameters_to_context(clip->codecCtx, clip->stream->codecpar); + clip->stream = clip->formatCtx->streams[ms->file_index]; + clip->codec = avcodec_find_decoder(clip->stream->codecpar->codec_id); + clip->codecCtx = avcodec_alloc_context3(clip->codec); + avcodec_parameters_to_context(clip->codecCtx, clip->stream->codecpar); - clip->max_queue_size = (ms->infinite_length) ? 1 : qCeil(ms->video_frame_rate*0.5); - if (ms->video_interlacing != VIDEO_PROGRESSIVE) clip->max_queue_size *= 2; + clip->max_queue_size = (ms->infinite_length) ? 1 : qCeil(ms->video_frame_rate*0.5); + if (ms->video_interlacing != VIDEO_PROGRESSIVE) clip->max_queue_size *= 2; - clip->opts = NULL; + clip->opts = NULL; - // optimized decoding settings - if (clip->stream->codecpar->codec_id != AV_CODEC_ID_PNG && - clip->stream->codecpar->codec_id != AV_CODEC_ID_APNG && - clip->stream->codecpar->codec_id != AV_CODEC_ID_TIFF && - clip->stream->codecpar->codec_id != AV_CODEC_ID_PSD) { - av_dict_set(&clip->opts, "threads", "auto", 0); - } - if (clip->stream->codecpar->codec_id == AV_CODEC_ID_H264) { - av_dict_set(&clip->opts, "tune", "fastdecode", 0); - av_dict_set(&clip->opts, "tune", "zerolatency", 0); - } + // optimized decoding settings + if (clip->stream->codecpar->codec_id != AV_CODEC_ID_PNG && + clip->stream->codecpar->codec_id != AV_CODEC_ID_APNG && + clip->stream->codecpar->codec_id != AV_CODEC_ID_TIFF && + clip->stream->codecpar->codec_id != AV_CODEC_ID_PSD) { + av_dict_set(&clip->opts, "threads", "auto", 0); + } + if (clip->stream->codecpar->codec_id == AV_CODEC_ID_H264) { + av_dict_set(&clip->opts, "tune", "fastdecode", 0); + av_dict_set(&clip->opts, "tune", "zerolatency", 0); + } - // Open codec - if (avcodec_open2(clip->codecCtx, clip->codec, &clip->opts) < 0) { - dout << "[ERROR] Could not open codec"; - } + // Open codec + if (avcodec_open2(clip->codecCtx, clip->codec, &clip->opts) < 0) { + dout << "[ERROR] Could not open codec"; + } - // allocate filtergraph - clip->filter_graph = avfilter_graph_alloc(); - if (clip->filter_graph == NULL) { - dout << "[ERROR] Could not create filtergraph"; - } - char filter_args[512]; + // allocate filtergraph + clip->filter_graph = avfilter_graph_alloc(); + if (clip->filter_graph == NULL) { + dout << "[ERROR] Could not create filtergraph"; + } + char filter_args[512]; - if (clip->stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { - snprintf(filter_args, sizeof(filter_args), "video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d", - clip->stream->codecpar->width, - clip->stream->codecpar->height, - clip->stream->codecpar->format, - clip->stream->time_base.num, - clip->stream->time_base.den, - clip->stream->codecpar->sample_aspect_ratio.num, - clip->stream->codecpar->sample_aspect_ratio.den - ); + if (clip->stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { + snprintf(filter_args, sizeof(filter_args), "video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d", + clip->stream->codecpar->width, + clip->stream->codecpar->height, + clip->stream->codecpar->format, + clip->stream->time_base.num, + clip->stream->time_base.den, + clip->stream->codecpar->sample_aspect_ratio.num, + clip->stream->codecpar->sample_aspect_ratio.den + ); - avfilter_graph_create_filter(&clip->buffersrc_ctx, avfilter_get_by_name("buffer"), "in", filter_args, NULL, clip->filter_graph); - avfilter_graph_create_filter(&clip->buffersink_ctx, avfilter_get_by_name("buffersink"), "out", NULL, NULL, clip->filter_graph); + avfilter_graph_create_filter(&clip->buffersrc_ctx, avfilter_get_by_name("buffer"), "in", filter_args, NULL, clip->filter_graph); + avfilter_graph_create_filter(&clip->buffersink_ctx, avfilter_get_by_name("buffersink"), "out", NULL, NULL, clip->filter_graph); - AVFilterContext* last_filter = clip->buffersrc_ctx; + AVFilterContext* last_filter = clip->buffersrc_ctx; - if (ms->video_interlacing != VIDEO_PROGRESSIVE) { - AVFilterContext* yadif_filter; - char yadif_args[100]; - snprintf(yadif_args, sizeof(yadif_args), "mode=3:parity=%d", ((ms->video_interlacing == VIDEO_TOP_FIELD_FIRST) ? 0 : 1)); // there's a CUDA version if we start using nvdec/nvenc - avfilter_graph_create_filter(&yadif_filter, avfilter_get_by_name("yadif"), "yadif", yadif_args, NULL, clip->filter_graph); + if (ms->video_interlacing != VIDEO_PROGRESSIVE) { + AVFilterContext* yadif_filter; + char yadif_args[100]; + snprintf(yadif_args, sizeof(yadif_args), "mode=3:parity=%d", ((ms->video_interlacing == VIDEO_TOP_FIELD_FIRST) ? 0 : 1)); // there's a CUDA version if we start using nvdec/nvenc + avfilter_graph_create_filter(&yadif_filter, avfilter_get_by_name("yadif"), "yadif", yadif_args, NULL, clip->filter_graph); - avfilter_link(last_filter, 0, yadif_filter, 0); - last_filter = yadif_filter; - } + avfilter_link(last_filter, 0, yadif_filter, 0); + last_filter = yadif_filter; + } /* stabilization code */ - bool stabilize = false; - if (stabilize) { - AVFilterContext* stab_filter; - int stab_ret = avfilter_graph_create_filter(&stab_filter, avfilter_get_by_name("vidstabtransform"), "vidstab", "input=/media/matt/Home/samples/transforms.trf", NULL, clip->filter_graph); - if (stab_ret < 0) { - char err[100]; - av_strerror(stab_ret, err, sizeof(err)); - } else { - avfilter_link(last_filter, 0, stab_filter, 0); - last_filter = stab_filter; - } + bool stabilize = false; + if (stabilize) { + AVFilterContext* stab_filter; + int stab_ret = avfilter_graph_create_filter(&stab_filter, avfilter_get_by_name("vidstabtransform"), "vidstab", "input=/media/matt/Home/samples/transforms.trf", NULL, clip->filter_graph); + if (stab_ret < 0) { + char err[100]; + av_strerror(stab_ret, err, sizeof(err)); + } else { + avfilter_link(last_filter, 0, stab_filter, 0); + last_filter = stab_filter; + } } enum AVPixelFormat valid_pix_fmts[] = { @@ -750,102 +750,102 @@ void open_clip_worker(Clip* clip) { char format_args[100]; snprintf(format_args, sizeof(format_args), "pix_fmts=%s", chosen_format); - AVFilterContext* format_conv; + AVFilterContext* format_conv; avfilter_graph_create_filter(&format_conv, avfilter_get_by_name("format"), "fmt", format_args, NULL, clip->filter_graph); - avfilter_link(last_filter, 0, format_conv, 0); + avfilter_link(last_filter, 0, format_conv, 0); - avfilter_link(format_conv, 0, clip->buffersink_ctx, 0); + avfilter_link(format_conv, 0, clip->buffersink_ctx, 0); - avfilter_graph_config(clip->filter_graph, NULL); - } else if (clip->stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { - if (clip->codecCtx->channel_layout == 0) clip->codecCtx->channel_layout = av_get_default_channel_layout(clip->stream->codecpar->channels); + avfilter_graph_config(clip->filter_graph, NULL); + } else if (clip->stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { + if (clip->codecCtx->channel_layout == 0) clip->codecCtx->channel_layout = av_get_default_channel_layout(clip->stream->codecpar->channels); - // set up cache - clip->queue.append(av_frame_alloc()); - if (clip->reverse) { - AVFrame* reverse_frame = av_frame_alloc(); + // set up cache + clip->queue.append(av_frame_alloc()); + if (clip->reverse) { + AVFrame* reverse_frame = av_frame_alloc(); - reverse_frame->format = sample_format; - reverse_frame->nb_samples = audio_output->format().sampleRate()*2; - reverse_frame->channel_layout = clip->sequence->audio_layout; - reverse_frame->channels = av_get_channel_layout_nb_channels(clip->sequence->audio_layout); - av_frame_get_buffer(reverse_frame, 0); + reverse_frame->format = sample_format; + reverse_frame->nb_samples = current_audio_freq()*2; + reverse_frame->channel_layout = clip->sequence->audio_layout; + reverse_frame->channels = av_get_channel_layout_nb_channels(clip->sequence->audio_layout); + av_frame_get_buffer(reverse_frame, 0); - clip->queue.append(reverse_frame); - } + clip->queue.append(reverse_frame); + } - snprintf(filter_args, sizeof(filter_args), "time_base=%d/%d:sample_rate=%d:sample_fmt=%s:channel_layout=0x%" PRIx64, - clip->stream->time_base.num, - clip->stream->time_base.den, - clip->stream->codecpar->sample_rate, - av_get_sample_fmt_name(clip->codecCtx->sample_fmt), - clip->codecCtx->channel_layout - ); + snprintf(filter_args, sizeof(filter_args), "time_base=%d/%d:sample_rate=%d:sample_fmt=%s:channel_layout=0x%" PRIx64, + clip->stream->time_base.num, + clip->stream->time_base.den, + clip->stream->codecpar->sample_rate, + av_get_sample_fmt_name(clip->codecCtx->sample_fmt), + clip->codecCtx->channel_layout + ); - avfilter_graph_create_filter(&clip->buffersrc_ctx, avfilter_get_by_name("abuffer"), "in", filter_args, NULL, clip->filter_graph); - avfilter_graph_create_filter(&clip->buffersink_ctx, avfilter_get_by_name("abuffersink"), "out", NULL, NULL, clip->filter_graph); + avfilter_graph_create_filter(&clip->buffersrc_ctx, avfilter_get_by_name("abuffer"), "in", filter_args, NULL, clip->filter_graph); + avfilter_graph_create_filter(&clip->buffersink_ctx, avfilter_get_by_name("abuffersink"), "out", NULL, NULL, clip->filter_graph); - enum AVSampleFormat sample_fmts[] = { sample_format, static_cast(-1) }; - if (av_opt_set_int_list(clip->buffersink_ctx, "sample_fmts", sample_fmts, -1, AV_OPT_SEARCH_CHILDREN) < 0) { - dout << "[ERROR] Could not set output sample format"; - } + enum AVSampleFormat sample_fmts[] = { sample_format, static_cast(-1) }; + if (av_opt_set_int_list(clip->buffersink_ctx, "sample_fmts", sample_fmts, -1, AV_OPT_SEARCH_CHILDREN) < 0) { + dout << "[ERROR] Could not set output sample format"; + } - int64_t channel_layouts[] = { AV_CH_LAYOUT_STEREO, static_cast(-1) }; - if (av_opt_set_int_list(clip->buffersink_ctx, "channel_layouts", channel_layouts, -1, AV_OPT_SEARCH_CHILDREN) < 0) { - dout << "[ERROR] Could not set output sample format"; - } + int64_t channel_layouts[] = { AV_CH_LAYOUT_STEREO, static_cast(-1) }; + if (av_opt_set_int_list(clip->buffersink_ctx, "channel_layouts", channel_layouts, -1, AV_OPT_SEARCH_CHILDREN) < 0) { + dout << "[ERROR] Could not set output sample format"; + } - int target_sample_rate = audio_output->format().sampleRate(); + int target_sample_rate = current_audio_freq(); - if (qFuzzyCompare(clip->speed, 1.0)) { - avfilter_link(clip->buffersrc_ctx, 0, clip->buffersink_ctx, 0); - } else if (clip->maintain_audio_pitch) { - AVFilterContext* previous_filter = clip->buffersrc_ctx; - AVFilterContext* last_filter = clip->buffersrc_ctx; + if (qFuzzyCompare(clip->speed, 1.0)) { + avfilter_link(clip->buffersrc_ctx, 0, clip->buffersink_ctx, 0); + } else if (clip->maintain_audio_pitch) { + AVFilterContext* previous_filter = clip->buffersrc_ctx; + AVFilterContext* last_filter = clip->buffersrc_ctx; - char speed_param[10]; + char speed_param[10]; - if (clip->speed != 1.0) { - double base = (clip->speed > 1.0) ? 2.0 : 0.5; + if (clip->speed != 1.0) { + double base = (clip->speed > 1.0) ? 2.0 : 0.5; - double speedlog = log(clip->speed) / log(base); - int whole2 = qFloor(speedlog); - speedlog -= whole2; + double speedlog = log(clip->speed) / log(base); + int whole2 = qFloor(speedlog); + speedlog -= whole2; - if (whole2 > 0) { - snprintf(speed_param, sizeof(speed_param), "%f", base); - for (int i=0;ifilter_graph); - avfilter_link(previous_filter, 0, tempo_filter, 0); - previous_filter = tempo_filter; - } - } + if (whole2 > 0) { + snprintf(speed_param, sizeof(speed_param), "%f", base); + for (int i=0;ifilter_graph); + avfilter_link(previous_filter, 0, tempo_filter, 0); + previous_filter = tempo_filter; + } + } - snprintf(speed_param, sizeof(speed_param), "%f", qPow(base, speedlog)); - last_filter = NULL; - avfilter_graph_create_filter(&last_filter, avfilter_get_by_name("atempo"), "atempo", speed_param, NULL, clip->filter_graph); - avfilter_link(previous_filter, 0, last_filter, 0); - } + snprintf(speed_param, sizeof(speed_param), "%f", qPow(base, speedlog)); + last_filter = NULL; + avfilter_graph_create_filter(&last_filter, avfilter_get_by_name("atempo"), "atempo", speed_param, NULL, clip->filter_graph); + avfilter_link(previous_filter, 0, last_filter, 0); + } - avfilter_link(last_filter, 0, clip->buffersink_ctx, 0); - } else { - target_sample_rate = qRound64(target_sample_rate / clip->speed); - avfilter_link(clip->buffersrc_ctx, 0, clip->buffersink_ctx, 0); - } + avfilter_link(last_filter, 0, clip->buffersink_ctx, 0); + } else { + target_sample_rate = qRound64(target_sample_rate / clip->speed); + avfilter_link(clip->buffersrc_ctx, 0, clip->buffersink_ctx, 0); + } - int sample_rates[] = { target_sample_rate, 0 }; - if (av_opt_set_int_list(clip->buffersink_ctx, "sample_rates", sample_rates, 0, AV_OPT_SEARCH_CHILDREN) < 0) { - dout << "[ERROR] Could not set output sample rates"; - } + int sample_rates[] = { target_sample_rate, 0 }; + if (av_opt_set_int_list(clip->buffersink_ctx, "sample_rates", sample_rates, 0, AV_OPT_SEARCH_CHILDREN) < 0) { + dout << "[ERROR] Could not set output sample rates"; + } - avfilter_graph_config(clip->filter_graph, NULL); + avfilter_graph_config(clip->filter_graph, NULL); - clip->audio_reset = true; - } + clip->audio_reset = true; + } - clip->frame = av_frame_alloc(); - } + clip->frame = av_frame_alloc(); + } for (int i=0;ieffects.size();i++) { clip->effects.at(i)->open(); @@ -856,30 +856,30 @@ void open_clip_worker(Clip* clip) { dout << "[INFO] Clip opened on track" << clip->track; } -void cache_clip_worker(Clip* clip, long playhead, bool reset, bool scrubbing, QVector nests) { - if (reset) { - // note: for video, playhead is in "internal clip" frames - for audio, it's the timeline playhead - reset_cache(clip, playhead); - clip->audio_reset = false; - } +void cache_clip_worker(Clip* clip, long playhead, bool reset, bool scrubbing, QVector nests) { + if (reset) { + // note: for video, playhead is in "internal clip" frames - for audio, it's the timeline playhead + reset_cache(clip, playhead); + clip->audio_reset = false; + } - if (clip->media == NULL) { - if (clip->track >= 0) { - cache_audio_worker(clip, scrubbing, nests); - } - } else if (clip->media->get_type() == MEDIA_TYPE_FOOTAGE) { - if (clip->stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { - cache_video_worker(clip, playhead); - } else if (clip->stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { - cache_audio_worker(clip, scrubbing, nests); - } - } + if (clip->media == NULL) { + if (clip->track >= 0) { + cache_audio_worker(clip, scrubbing, nests); + } + } else if (clip->media->get_type() == MEDIA_TYPE_FOOTAGE) { + if (clip->stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { + cache_video_worker(clip, playhead); + } else if (clip->stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { + cache_audio_worker(clip, scrubbing, nests); + } + } } void close_clip_worker(Clip* clip) { clip->finished_opening = false; - if (clip->media != NULL && clip->media->get_type() == MEDIA_TYPE_FOOTAGE) { + if (clip->media != NULL && clip->media->get_type() == MEDIA_TYPE_FOOTAGE) { clip->queue_clear(); avfilter_graph_free(&clip->filter_graph); @@ -887,46 +887,46 @@ void close_clip_worker(Clip* clip) { avcodec_close(clip->codecCtx); avcodec_free_context(&clip->codecCtx); - av_dict_free(&clip->opts); + av_dict_free(&clip->opts); avformat_close_input(&clip->formatCtx); } av_frame_free(&clip->frame); - clip->reset(); + clip->reset(); dout << "[INFO] Clip closed on track" << clip->track; } void Cacher::run() { // open_lock is used to prevent the clip from being destroyed before the cacher has closed it properly - clip->lock.lock(); - clip->finished_opening = false; - clip->open = true; - caching = true; - interrupt = false; + clip->lock.lock(); + clip->finished_opening = false; + clip->open = true; + caching = true; + interrupt = false; open_clip_worker(clip); while (caching) { clip->can_cache.wait(&clip->lock); - if (!caching) { + if (!caching) { break; } else { - while (true) { - cache_clip_worker(clip, playhead, reset, scrubbing, nests); - if (clip->multithreaded && clip->cacher->interrupt && clip->track < 0) { - clip->cacher->interrupt = false; - } else { - break; - } - } + while (true) { + cache_clip_worker(clip, playhead, reset, scrubbing, nests); + if (clip->multithreaded && clip->cacher->interrupt && clip->track < 0) { + clip->cacher->interrupt = false; + } else { + break; + } + } } } - close_clip_worker(clip); + close_clip_worker(clip); - clip->lock.unlock(); + clip->lock.unlock(); clip->open_lock.unlock(); } From f4715fdf99971747ba303281b64f5c84d16cb68c Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Wed, 2 Jan 2019 23:09:00 +1100 Subject: [PATCH 05/10] corrected tab order for export and new sequence dialog --- dialogs/exportdialog.cpp | 115 +++++++++++++----------------- dialogs/newsequencedialog.cpp | 128 ++++++++++++++++------------------ dialogs/newsequencedialog.h | 2 +- 3 files changed, 107 insertions(+), 138 deletions(-) diff --git a/dialogs/exportdialog.cpp b/dialogs/exportdialog.cpp index 44835dacd..39e788e12 100644 --- a/dialogs/exportdialog.cpp +++ b/dialogs/exportdialog.cpp @@ -57,6 +57,7 @@ enum ExportFormats { ExportDialog::ExportDialog(QWidget *parent) : QDialog(parent) { + setWindowTitle("Export \"" + sequence->name + "\""); setup_ui(); rangeCombobox->setCurrentIndex(0); @@ -601,54 +602,41 @@ void ExportDialog::setup_ui() { videoGroupbox->setTitle("Video"); videoGroupbox->setFlat(false); videoGroupbox->setCheckable(true); - QGridLayout* gridLayout = new QGridLayout(videoGroupbox); - gridLayout->addWidget(new QLabel("Compression Type:"), 4, 0, 1, 1); + QGridLayout* videoGridLayout = new QGridLayout(videoGroupbox); + videoGridLayout->addWidget(new QLabel("Codec:"), 0, 0, 1, 1); + vcodecCombobox = new QComboBox(videoGroupbox); + videoGridLayout->addWidget(vcodecCombobox, 0, 1, 1, 1); + + videoGridLayout->addWidget(new QLabel("Width:"), 1, 0, 1, 1); + widthSpinbox = new QSpinBox(videoGroupbox); + widthSpinbox->setMaximum(16777216); + videoGridLayout->addWidget(widthSpinbox, 1, 1, 1, 1); + + videoGridLayout->addWidget(new QLabel("Height:"), 2, 0, 1, 1); + heightSpinbox = new QSpinBox(videoGroupbox); + heightSpinbox->setMaximum(16777216); + videoGridLayout->addWidget(heightSpinbox, 2, 1, 1, 1); + + videoGridLayout->addWidget(new QLabel("Frame Rate:"), 3, 0, 1, 1); + framerateSpinbox = new QDoubleSpinBox(videoGroupbox); + framerateSpinbox->setMaximum(60); + framerateSpinbox->setValue(0); + videoGridLayout->addWidget(framerateSpinbox, 3, 1, 1, 1); + + videoGridLayout->addWidget(new QLabel("Compression Type:"), 4, 0, 1, 1); compressionTypeCombobox = new QComboBox(videoGroupbox); compressionTypeCombobox->addItem("Quality-based (Constant Rate Factor)"); compressionTypeCombobox->addItem("File size-based (Two-Pass)"); + videoGridLayout->addWidget(compressionTypeCombobox, 4, 1, 1, 1); - gridLayout->addWidget(compressionTypeCombobox, 4, 1, 1, 1); - - gridLayout->addWidget(new QLabel("Codec:"), 0, 0, 1, 1); - - vcodecCombobox = new QComboBox(videoGroupbox); - - gridLayout->addWidget(vcodecCombobox, 0, 1, 1, 1); - - gridLayout->addWidget(new QLabel("Height:"), 2, 0, 1, 1); - - gridLayout->addWidget(new QLabel("Width:"), 1, 0, 1, 1); - - heightSpinbox = new QSpinBox(videoGroupbox); - heightSpinbox->setMaximum(16777216); - - gridLayout->addWidget(heightSpinbox, 2, 1, 1, 1); - - widthSpinbox = new QSpinBox(videoGroupbox); - widthSpinbox->setMaximum(16777216); - - gridLayout->addWidget(widthSpinbox, 1, 1, 1, 1); - - videobitrateSpinbox = new QDoubleSpinBox(videoGroupbox); - videobitrateSpinbox->setMaximum(100); - videobitrateSpinbox->setValue(2); - - gridLayout->addWidget(videobitrateSpinbox, 5, 1, 1, 1); - - videoBitrateLabel = new QLabel(videoGroupbox); - - gridLayout->addWidget(videoBitrateLabel, 5, 0, 1, 1); - - gridLayout->addWidget(new QLabel("Frame Rate:"), 3, 0, 1, 1); - - framerateSpinbox = new QDoubleSpinBox(videoGroupbox); - framerateSpinbox->setMaximum(60); - framerateSpinbox->setValue(0); - - gridLayout->addWidget(framerateSpinbox, 3, 1, 1, 1); - + videoBitrateLabel = new QLabel(videoGroupbox); + videoGridLayout->addWidget(videoBitrateLabel, 5, 0, 1, 1); + videobitrateSpinbox = new QDoubleSpinBox(videoGroupbox); + videobitrateSpinbox->setMaximum(100); + videobitrateSpinbox->setValue(2); + videoGridLayout->addWidget(videobitrateSpinbox, 5, 1, 1, 1); verticalLayout->addWidget(videoGroupbox); @@ -656,69 +644,60 @@ void ExportDialog::setup_ui() { audioGroupbox->setTitle("Audio"); audioGroupbox->setCheckable(true); - QGridLayout* gridLayout_2 = new QGridLayout(audioGroupbox); - gridLayout_2->addWidget(new QLabel("Codec:"), 0, 0, 1, 1); + QGridLayout* audioGridLayout = new QGridLayout(audioGroupbox); + audioGridLayout->addWidget(new QLabel("Codec:"), 0, 0, 1, 1); acodecCombobox = new QComboBox(audioGroupbox); + audioGridLayout->addWidget(acodecCombobox, 0, 1, 1, 1); - gridLayout_2->addWidget(acodecCombobox, 0, 1, 1, 1); - + audioGridLayout->addWidget(new QLabel("Sampling Rate:"), 1, 0, 1, 1); samplingRateSpinbox = new QSpinBox(audioGroupbox); samplingRateSpinbox->setMaximum(96000); samplingRateSpinbox->setValue(0); + audioGridLayout->addWidget(samplingRateSpinbox, 1, 1, 1, 1); - gridLayout_2->addWidget(samplingRateSpinbox, 1, 1, 1, 1); - - gridLayout_2->addWidget(new QLabel("Sampling Rate:"), 1, 0, 1, 1); - - gridLayout_2->addWidget(new QLabel("Bitrate (Kbps/CBR):"), 3, 0, 1, 1); - + audioGridLayout->addWidget(new QLabel("Bitrate (Kbps/CBR):"), 3, 0, 1, 1); audiobitrateSpinbox = new QSpinBox(audioGroupbox); audiobitrateSpinbox->setMaximum(320); audiobitrateSpinbox->setValue(256); - - gridLayout_2->addWidget(audiobitrateSpinbox, 3, 1, 1, 1); - + audioGridLayout->addWidget(audiobitrateSpinbox, 3, 1, 1, 1); verticalLayout->addWidget(audioGroupbox); - QHBoxLayout* horizontalLayout_3 = new QHBoxLayout(); + QHBoxLayout* progressLayout = new QHBoxLayout(); progressBar = new QProgressBar(this); progressBar->setFormat("%p% (ETA: 0:00:00)"); progressBar->setEnabled(false); progressBar->setValue(0); - - horizontalLayout_3->addWidget(progressBar); + progressLayout->addWidget(progressBar); renderCancel = new QPushButton(this); renderCancel->setText("x"); renderCancel->setEnabled(false); renderCancel->setMaximumSize(QSize(20, 16777215)); connect(renderCancel, SIGNAL(clicked(bool)), this, SLOT(cancel_render())); + progressLayout->addWidget(renderCancel); - horizontalLayout_3->addWidget(renderCancel); + verticalLayout->addLayout(progressLayout); - - verticalLayout->addLayout(horizontalLayout_3); - - QHBoxLayout* horizontalLayout_2 = new QHBoxLayout(); - horizontalLayout_2->addStretch(); + QHBoxLayout* buttonLayout = new QHBoxLayout(); + buttonLayout->addStretch(); export_button = new QPushButton(this); export_button->setText("Export"); connect(export_button, SIGNAL(clicked(bool)), this, SLOT(export_action())); - horizontalLayout_2->addWidget(export_button); + buttonLayout->addWidget(export_button); cancel_button = new QPushButton(this); cancel_button->setText("Cancel"); connect(cancel_button, SIGNAL(clicked(bool)), this, SLOT(reject())); - horizontalLayout_2->addWidget(cancel_button); + buttonLayout->addWidget(cancel_button); - horizontalLayout_2->addStretch(); + buttonLayout->addStretch(); - verticalLayout->addLayout(horizontalLayout_2); + verticalLayout->addLayout(buttonLayout); connect(formatCombobox, SIGNAL(currentIndexChanged(int)), this, SLOT(format_changed(int))); connect(compressionTypeCombobox, SIGNAL(currentIndexChanged(int)), this, SLOT(comp_type_changed(int))); diff --git a/dialogs/newsequencedialog.cpp b/dialogs/newsequencedialog.cpp index cfcd0678e..0451aa886 100644 --- a/dialogs/newsequencedialog.cpp +++ b/dialogs/newsequencedialog.cpp @@ -42,7 +42,7 @@ NewSequenceDialog::NewSequenceDialog(QWidget *parent, Media *existing) : break; } } - lineEdit->setText(existing_sequence->name); + sequence_name_edit->setText(existing_sequence->name); for (int i=0;icount();i++) { if (audio_frequency_combobox->itemData(i) == existing_sequence->audio_frequency) { audio_frequency_combobox->setCurrentIndex(i); @@ -59,14 +59,14 @@ NewSequenceDialog::~NewSequenceDialog() {} void NewSequenceDialog::set_sequence_name(const QString& s) { - lineEdit->setText(s); + sequence_name_edit->setText(s); } void NewSequenceDialog::create() { if (existing_sequence == NULL) { Sequence* s = new Sequence(); - s->name = lineEdit->text(); + s->name = sequence_name_edit->text(); s->width = width_numeric->value(); s->height = height_numeric->value(); s->frame_rate = frame_rate_combobox->currentData().toDouble(); @@ -82,7 +82,7 @@ void NewSequenceDialog::create() { double multiplier = frame_rate_combobox->currentData().toDouble() / existing_sequence->frame_rate; EditSequenceCommand* esc = new EditSequenceCommand(existing_item, existing_sequence); - esc->name = lineEdit->text(); + esc->name = sequence_name_edit->text(); esc->width = width_numeric->value(); esc->height = height_numeric->value(); esc->frame_rate = frame_rate_combobox->currentData().toDouble(); @@ -154,10 +154,10 @@ void NewSequenceDialog::setup_ui() { QWidget* widget = new QWidget(this); - QHBoxLayout* horizontalLayout_2 = new QHBoxLayout(widget); - horizontalLayout_2->setContentsMargins(0, 0, 0, 0); + QHBoxLayout* preset_layout = new QHBoxLayout(widget); + preset_layout->setContentsMargins(0, 0, 0, 0); - horizontalLayout_2->addWidget(new QLabel("Preset:")); + preset_layout->addWidget(new QLabel("Preset:")); preset_combobox = new QComboBox(widget); @@ -174,75 +174,65 @@ void NewSequenceDialog::setup_ui() { preset_combobox->addItem("Custom"); preset_combobox->setCurrentIndex(2); - horizontalLayout_2->addWidget(preset_combobox); + preset_layout->addWidget(preset_combobox); verticalLayout->addWidget(widget); - QGroupBox* groupBox = new QGroupBox(this); - groupBox->setTitle("Video"); + QGroupBox* videoGroupBox = new QGroupBox(this); + videoGroupBox->setTitle("Video"); - QGridLayout* gridLayout = new QGridLayout(groupBox); + QGridLayout* videoLayout = new QGridLayout(videoGroupBox); - height_numeric = new QSpinBox(groupBox); + videoLayout->addWidget(new QLabel("Width:"), 0, 0, 1, 1); + width_numeric = new QSpinBox(videoGroupBox); + width_numeric->setMaximum(9999); + width_numeric->setValue(1920); + videoLayout->addWidget(width_numeric, 0, 2, 1, 2); + + videoLayout->addWidget(new QLabel("Height:"), 1, 0, 1, 2); + height_numeric = new QSpinBox(videoGroupBox); height_numeric->setMaximum(9999); height_numeric->setValue(1080); + videoLayout->addWidget(height_numeric, 1, 2, 1, 2); - gridLayout->addWidget(height_numeric, 1, 2, 1, 2); + videoLayout->addWidget(new QLabel("Frame Rate:"), 2, 0, 1, 1); + frame_rate_combobox = new QComboBox(videoGroupBox); + frame_rate_combobox->addItem("10 FPS", 10.0); + frame_rate_combobox->addItem("12.5 FPS", 12.5); + frame_rate_combobox->addItem("15 FPS", 15.0); + frame_rate_combobox->addItem("23.976 FPS", 23.976); + frame_rate_combobox->addItem("24 FPS", 24.0); + frame_rate_combobox->addItem("25 FPS", 25.0); + frame_rate_combobox->addItem("29.97 FPS", 29.97); + frame_rate_combobox->addItem("30 FPS", 30.0); + frame_rate_combobox->addItem("50 FPS", 50.0); + frame_rate_combobox->addItem("59.94 FPS", 59.94); + frame_rate_combobox->addItem("60 FPS", 60.0); + frame_rate_combobox->setCurrentIndex(6); + videoLayout->addWidget(frame_rate_combobox, 2, 2, 1, 2); - width_numeric = new QSpinBox(groupBox); - width_numeric->setMaximum(9999); - width_numeric->setValue(1920); + videoLayout->addWidget(new QLabel("Pixel Aspect Ratio:"), 4, 0, 1, 1); + par_combobox = new QComboBox(videoGroupBox); + par_combobox->addItem("Square Pixels (1.0)"); + videoLayout->addWidget(par_combobox, 4, 2, 1, 2); - gridLayout->addWidget(width_numeric, 0, 2, 1, 2); - - gridLayout->addWidget(new QLabel("Width:"), 0, 0, 1, 1); - - gridLayout->addWidget(new QLabel("Pixel Aspect Ratio:"), 4, 0, 1, 1); - - gridLayout->addWidget(new QLabel("Interlacing:"), 6, 0, 1, 1); - - gridLayout->addWidget(new QLabel("Height:"), 1, 0, 1, 2); - - par_combobox = new QComboBox(groupBox); - par_combobox->addItem("Square Pixels (1.0)"); - - gridLayout->addWidget(par_combobox, 4, 2, 1, 2); - - interlacing_combobox = new QComboBox(groupBox); + videoLayout->addWidget(new QLabel("Interlacing:"), 6, 0, 1, 1); + interlacing_combobox = new QComboBox(videoGroupBox); interlacing_combobox->addItem("None (Progressive)"); - interlacing_combobox->addItem("Upper Field First"); - interlacing_combobox->addItem("Lower Field First"); +// interlacing_combobox->addItem("Upper Field First"); +// interlacing_combobox->addItem("Lower Field First"); + videoLayout->addWidget(interlacing_combobox, 6, 2, 1, 2); - gridLayout->addWidget(interlacing_combobox, 6, 2, 1, 2); + verticalLayout->addWidget(videoGroupBox); - frame_rate_combobox = new QComboBox(groupBox); - frame_rate_combobox->addItem("10 FPS", 10.0); - frame_rate_combobox->addItem("12.5 FPS", 12.5); - frame_rate_combobox->addItem("15 FPS", 15.0); - frame_rate_combobox->addItem("23.976 FPS", 23.976); - frame_rate_combobox->addItem("24 FPS", 24.0); - frame_rate_combobox->addItem("25 FPS", 25.0); - frame_rate_combobox->addItem("29.97 FPS", 29.97); - frame_rate_combobox->addItem("30 FPS", 30.0); - frame_rate_combobox->addItem("50 FPS", 50.0); - frame_rate_combobox->addItem("59.94 FPS", 59.94); - frame_rate_combobox->addItem("60 FPS", 60.0); - frame_rate_combobox->setCurrentIndex(6); + QGroupBox* audioGroupBox = new QGroupBox(this); + audioGroupBox->setTitle("Audio"); - gridLayout->addWidget(frame_rate_combobox, 2, 2, 1, 2); + QGridLayout* audioLayout = new QGridLayout(audioGroupBox); - gridLayout->addWidget(new QLabel("Frame Rate:"), 2, 0, 1, 1); + audioLayout->addWidget(new QLabel("Sample Rate: "), 0, 0, 1, 1); - verticalLayout->addWidget(groupBox); - - QGroupBox* groupBox_2 = new QGroupBox(this); - groupBox_2->setTitle("Audio"); - - QGridLayout* gridLayout_2 = new QGridLayout(groupBox_2); - - gridLayout_2->addWidget(new QLabel("Sample Rate: "), 0, 0, 1, 1); - - audio_frequency_combobox = new QComboBox(groupBox_2); + audio_frequency_combobox = new QComboBox(audioGroupBox); audio_frequency_combobox->addItem("22050 Hz", 22050); audio_frequency_combobox->addItem("24000 Hz", 24000); audio_frequency_combobox->addItem("32000 Hz", 32000); @@ -252,21 +242,21 @@ void NewSequenceDialog::setup_ui() { audio_frequency_combobox->addItem("96000 Hz", 96000); audio_frequency_combobox->setCurrentIndex(4); - gridLayout_2->addWidget(audio_frequency_combobox, 0, 1, 1, 1); + audioLayout->addWidget(audio_frequency_combobox, 0, 1, 1, 1); - verticalLayout->addWidget(groupBox_2); + verticalLayout->addWidget(audioGroupBox); - QWidget* widget_2 = new QWidget(this); - QHBoxLayout* horizontalLayout = new QHBoxLayout(widget_2); - horizontalLayout->setContentsMargins(0, 0, 0, 0); + QWidget* nameWidget = new QWidget(this); + QHBoxLayout* nameLayout = new QHBoxLayout(nameWidget); + nameLayout->setContentsMargins(0, 0, 0, 0); - horizontalLayout->addWidget(new QLabel("Name:")); + nameLayout->addWidget(new QLabel("Name:")); - lineEdit = new QLineEdit(widget_2); + sequence_name_edit = new QLineEdit(nameWidget); - horizontalLayout->addWidget(lineEdit); + nameLayout->addWidget(sequence_name_edit); - verticalLayout->addWidget(widget_2); + verticalLayout->addWidget(nameWidget); QDialogButtonBox* buttonBox = new QDialogButtonBox(this); buttonBox->setOrientation(Qt::Horizontal); diff --git a/dialogs/newsequencedialog.h b/dialogs/newsequencedialog.h index 1a5cf2042..56502d817 100644 --- a/dialogs/newsequencedialog.h +++ b/dialogs/newsequencedialog.h @@ -37,7 +37,7 @@ private: QComboBox* interlacing_combobox; QComboBox* frame_rate_combobox; QComboBox* audio_frequency_combobox; - QLineEdit* lineEdit; + QLineEdit* sequence_name_edit; }; #endif // NEWSEQUENCEDIALOG_H From 2b7103e286561ea8ae44336d15139d249316a3d1 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Thu, 3 Jan 2019 00:09:39 +1100 Subject: [PATCH 06/10] added #225 --- dialogs/mediapropertiesdialog.cpp | 90 ++++++++++++++++++++----- dialogs/mediapropertiesdialog.h | 2 + io/previewgenerator.cpp | 105 ++++++++++++++++-------------- io/previewgenerator.h | 4 +- panels/project.cpp | 38 +++++------ panels/timeline.cpp | 24 ++++--- panels/viewer.cpp | 18 ++--- playback/cacher.cpp | 6 +- playback/playback.cpp | 6 +- project/clip.cpp | 12 ++-- project/footage.cpp | 14 ++-- project/footage.h | 7 +- project/media.cpp | 33 +++++----- ui/timelinewidget.cpp | 6 +- ui/timelinewidget.h | 2 +- ui/viewerwidget.cpp | 2 +- ui/viewerwidget.h | 2 +- 17 files changed, 221 insertions(+), 150 deletions(-) diff --git a/dialogs/mediapropertiesdialog.cpp b/dialogs/mediapropertiesdialog.cpp index 6f4fae51e..a94215f0f 100644 --- a/dialogs/mediapropertiesdialog.cpp +++ b/dialogs/mediapropertiesdialog.cpp @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include "project/footage.h" #include "project/media.h" @@ -16,49 +18,107 @@ MediaPropertiesDialog::MediaPropertiesDialog(QWidget *parent, Media *i) : QDialog(parent), item(i) { + setWindowTitle("\"" + i->data(0, Qt::DisplayRole).toString() + "\" Properties"); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QGridLayout* grid = new QGridLayout(); setLayout(grid); + int row = 0; + Footage* f = item->to_footage(); + + grid->addWidget(new QLabel("Tracks:"), row, 0, 1, 2); + row++; + + track_list = new QListWidget(); + for (int i=0;ivideo_tracks.size();i++) { + const FootageStream& fs = f->video_tracks.at(i); + QListWidgetItem* item = new QListWidgetItem("Video " + QString::number(fs.file_index) + ": " + QString::number(fs.video_width) + "x" + QString::number(fs.video_height) + " " + QString::number(fs.video_frame_rate) + "FPS"); + item->setFlags(item->flags() | Qt::ItemIsUserCheckable); + item->setCheckState(fs.enabled ? Qt::Checked : Qt::Unchecked); + item->setData(Qt::UserRole+1, fs.file_index); + track_list->addItem(item); + } + for (int i=0;iaudio_tracks.size();i++) { + const FootageStream& fs = f->audio_tracks.at(i); + QListWidgetItem* item = new QListWidgetItem("Audio " + QString::number(fs.file_index) + ": " + QString::number(fs.audio_frequency) + "Hz " + QString::number(fs.audio_channels) + " channels"); + item->setFlags(item->flags() | Qt::ItemIsUserCheckable); + item->setCheckState(fs.enabled ? Qt::Checked : Qt::Unchecked); + item->setData(Qt::UserRole+1, fs.file_index); + track_list->addItem(item); + } + grid->addWidget(track_list, row, 0, 1, 2); + row++; + if (f->video_tracks.size() > 0) { interlacing_box = new QComboBox(); - interlacing_box->addItem("Auto (" + get_interlacing_name(f->video_tracks.at(0)->video_auto_interlacing) + ")"); + interlacing_box->addItem("Auto (" + get_interlacing_name(f->video_tracks.at(0).video_auto_interlacing) + ")"); interlacing_box->addItem(get_interlacing_name(VIDEO_PROGRESSIVE)); interlacing_box->addItem(get_interlacing_name(VIDEO_TOP_FIELD_FIRST)); interlacing_box->addItem(get_interlacing_name(VIDEO_BOTTOM_FIELD_FIRST)); - interlacing_box->setCurrentIndex((f->video_tracks.at(0)->video_auto_interlacing == f->video_tracks.at(0)->video_interlacing) ? 0 : f->video_tracks.at(0)->video_interlacing + 1); + interlacing_box->setCurrentIndex((f->video_tracks.at(0).video_auto_interlacing == f->video_tracks.at(0).video_interlacing) ? 0 : f->video_tracks.at(0).video_interlacing + 1); - grid->addWidget(new QLabel("Interlacing:"), 0, 0); - grid->addWidget(interlacing_box, 0, 1); + grid->addWidget(new QLabel("Interlacing:"), row, 0); + grid->addWidget(interlacing_box, row, 1); + + row++; } name_box = new QLineEdit(item->get_name()); - grid->addWidget(new QLabel("Name:"), 1, 0); - grid->addWidget(name_box, 1, 1); + grid->addWidget(new QLabel("Name:"), row, 0); + grid->addWidget(name_box, row, 1); + row++; QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); buttons->setCenterButtons(true); - grid->addWidget(buttons, 2, 0, 1, 2); + grid->addWidget(buttons, row, 0, 1, 2); connect(buttons, SIGNAL(accepted()), this, SLOT(accept())); connect(buttons, SIGNAL(rejected()), this, SLOT(reject())); } void MediaPropertiesDialog::accept() { + Footage* f = item->to_footage(); + ComboAction* ca = new ComboAction(); - //set interlacing - Footage* f = item->to_footage(); - if (interlacing_box->currentIndex() > 0) { - ca->append(new SetInt(&f->video_tracks.at(0)->video_interlacing, interlacing_box->currentIndex() - 1)); - } else { - ca->append(new SetInt(&f->video_tracks.at(0)->video_interlacing, f->video_tracks.at(0)->video_auto_interlacing)); - } + // set track enable + for (int i=0;icount();i++) { + QListWidgetItem* item = track_list->item(i); + const QVariant& data = item->data(Qt::UserRole+1); + if (!data.isNull()) { + int index = data.toInt(); + bool found = false; + for (int j=0;jvideo_tracks.size();j++) { + if (f->video_tracks.at(j).file_index == index) { + f->video_tracks[j].enabled = (item->checkState() == Qt::Checked); + found = true; + break; + } + } + if (!found) { + for (int j=0;jaudio_tracks.size();j++) { + if (f->audio_tracks.at(j).file_index == index) { + f->audio_tracks[j].enabled = (item->checkState() == Qt::Checked); + break; + } + } + } + } + } - //set name + // set interlacing + if (f->video_tracks.size() > 0) { + if (interlacing_box->currentIndex() > 0) { + ca->append(new SetInt(&f->video_tracks[0].video_interlacing, interlacing_box->currentIndex() - 1)); + } else { + ca->append(new SetInt(&f->video_tracks[0].video_interlacing, f->video_tracks.at(0).video_auto_interlacing)); + } + } + + // set name MediaRename* mr = new MediaRename(item, name_box->text()); ca->append(mr); diff --git a/dialogs/mediapropertiesdialog.h b/dialogs/mediapropertiesdialog.h index 13f96c3d1..db173408d 100644 --- a/dialogs/mediapropertiesdialog.h +++ b/dialogs/mediapropertiesdialog.h @@ -7,6 +7,7 @@ struct Footage; class QComboBox; class QLineEdit; class Media; +class QListWidget; class MediaPropertiesDialog : public QDialog { Q_OBJECT @@ -16,6 +17,7 @@ private: QComboBox* interlacing_box; QLineEdit* name_box; Media* item; + QListWidget* track_list; private slots: void accept(); }; diff --git a/io/previewgenerator.cpp b/io/previewgenerator.cpp index bb24f3cbd..afb753ef4 100644 --- a/io/previewgenerator.cpp +++ b/io/previewgenerator.cpp @@ -55,14 +55,13 @@ void PreviewGenerator::parse_media() { if (avcodec_find_decoder(fmt_ctx->streams[i]->codecpar->codec_id) == NULL) { dout << "[ERROR] Unsupported codec in stream" << i << "of file" << footage->name; } else { - FootageStream* ms = footage->get_stream_from_file_index(fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO, i); + FootageStream ms; + ms.preview_done = false; + ms.file_index = i; + ms.enabled = true; + bool append = false; - if (ms == NULL) { - ms = new FootageStream(); - ms->preview_done = false; - ms->file_index = i; - append = true; - } + if (fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && fmt_ctx->streams[i]->codecpar->width > 0 && fmt_ctx->streams[i]->codecpar->height > 0) { @@ -76,33 +75,43 @@ void PreviewGenerator::parse_media() { // heuristic to determine if video is a still image if (fmt_ctx->streams[i]->avg_frame_rate.den == 0 && fmt_ctx->streams[i]->codecpar->codec_id != AV_CODEC_ID_DNXHD) { // silly hack but this is the only scenario i've seen this - ms->infinite_length = true; + ms.infinite_length = true; contains_still_image = true; - ms->video_frame_rate = 0; + ms.video_frame_rate = 0; } else { - ms->infinite_length = false; + ms.infinite_length = false; if (fmt_ctx->streams[i]->r_frame_rate.den == 0) { - ms->video_frame_rate = av_q2d(fmt_ctx->streams[i]->avg_frame_rate); + ms.video_frame_rate = av_q2d(fmt_ctx->streams[i]->avg_frame_rate); } else { - ms->video_frame_rate = av_q2d(fmt_ctx->streams[i]->r_frame_rate); + ms.video_frame_rate = av_q2d(fmt_ctx->streams[i]->r_frame_rate); } } - ms->video_width = fmt_ctx->streams[i]->codecpar->width; - ms->video_height = fmt_ctx->streams[i]->codecpar->height; + ms.video_width = fmt_ctx->streams[i]->codecpar->width; + ms.video_height = fmt_ctx->streams[i]->codecpar->height; // default value, we get the true value later in generate_waveform() - ms->video_auto_interlacing = VIDEO_PROGRESSIVE; - ms->video_interlacing = VIDEO_PROGRESSIVE; + ms.video_auto_interlacing = VIDEO_PROGRESSIVE; + ms.video_interlacing = VIDEO_PROGRESSIVE; - if (append) footage->video_tracks.append(ms); + append = true; } else if (fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { - ms->audio_channels = fmt_ctx->streams[i]->codecpar->channels; - ms->audio_layout = fmt_ctx->streams[i]->codecpar->channel_layout; - ms->audio_frequency = fmt_ctx->streams[i]->codecpar->sample_rate; - if (append) footage->audio_tracks.append(ms); - } else if (append) { - delete ms; - } + ms.audio_channels = fmt_ctx->streams[i]->codecpar->channels; + ms.audio_layout = fmt_ctx->streams[i]->codecpar->channel_layout; + ms.audio_frequency = fmt_ctx->streams[i]->codecpar->sample_rate; + + append = true; + } + + if (append) { + QVector& stream_list = (fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) ? footage->audio_tracks : footage->video_tracks; + for (int j=0;jlength = fmt_ctx->duration; @@ -123,32 +132,32 @@ bool PreviewGenerator::retrieve_preview(const QString& hash) { bool found = true; for (int i=0;ivideo_tracks.size();i++) { - FootageStream* ms = footage->video_tracks.at(i); + FootageStream& ms = footage->video_tracks[i]; QString thumb_path = get_thumbnail_path(hash, ms); QFile f(thumb_path); - if (f.exists() && ms->video_preview.load(thumb_path)) { + if (f.exists() && ms.video_preview.load(thumb_path)) { //dout << "loaded thumb" << ms->file_index << "from" << thumb_path; - ms->make_square_thumb(); - ms->preview_done = true; + ms.make_square_thumb(); + ms.preview_done = true; } else { found = false; break; } } for (int i=0;iaudio_tracks.size();i++) { - FootageStream* ms = footage->audio_tracks.at(i); + FootageStream& ms = footage->audio_tracks[i]; QString waveform_path = get_waveform_path(hash, ms); QFile f(waveform_path); if (f.exists()) { //dout << "loaded wave" << ms->file_index << "from" << waveform_path; f.open(QFile::ReadOnly); QByteArray data = f.readAll(); - ms->audio_preview.resize(data.size()); + ms.audio_preview.resize(data.size()); for (int j=0;jaudio_preview[j] = data.at(j); + ms.audio_preview[j] = data.at(j); } - ms->preview_done = true; + ms.preview_done = true; f.close(); } else { found = false; @@ -157,13 +166,13 @@ bool PreviewGenerator::retrieve_preview(const QString& hash) { } if (!found) { for (int i=0;ivideo_tracks.size();i++) { - FootageStream* ms = footage->video_tracks.at(i); - ms->preview_done = false; + FootageStream& ms = footage->video_tracks[i]; + ms.preview_done = false; } for (int i=0;iaudio_tracks.size();i++) { - FootageStream* ms = footage->audio_tracks.at(i); - ms->audio_preview.clear(); - ms->preview_done = false; + FootageStream& ms = footage->audio_tracks[i]; + ms.audio_preview.clear(); + ms.preview_done = false; } } return !found; @@ -336,7 +345,7 @@ void PreviewGenerator::generate_waveform() { break; } } - s->audio_preview.append(min >> 8); + s->audio_preview.append(min >> 8); s->audio_preview.append(max >> 8); if (cancelled) break; } @@ -359,7 +368,7 @@ void PreviewGenerator::generate_waveform() { } else if (footage->audio_tracks.size() == 0) { done = true; for (int i=0;ivideo_tracks.size();i++) { - if (!footage->video_tracks.at(i)->preview_done) { + if (!footage->video_tracks.at(i).preview_done) { done = false; break; } @@ -373,7 +382,7 @@ void PreviewGenerator::generate_waveform() { } } for (int i=0;iaudio_tracks.size();i++) { - footage->audio_tracks.at(i)->preview_done = true; + footage->audio_tracks[i].preview_done = true; } av_frame_free(&temp_frame); av_packet_free(&packet); @@ -397,12 +406,12 @@ void PreviewGenerator::generate_waveform() { delete [] codec_ctx; } -QString PreviewGenerator::get_thumbnail_path(const QString& hash, FootageStream* ms) { - return data_path + "/" + hash + "t" + QString::number(ms->file_index); +QString PreviewGenerator::get_thumbnail_path(const QString& hash, const FootageStream& ms) { + return data_path + "/" + hash + "t" + QString::number(ms.file_index); } -QString PreviewGenerator::get_waveform_path(const QString& hash, FootageStream* ms) { - return data_path + "/" + hash + "w" + QString::number(ms->file_index); +QString PreviewGenerator::get_waveform_path(const QString& hash, const FootageStream& ms) { + return data_path + "/" + hash + "w" + QString::number(ms.file_index); } void PreviewGenerator::run() { @@ -445,15 +454,15 @@ void PreviewGenerator::run() { // save preview to file for (int i=0;ivideo_tracks.size();i++) { - FootageStream* ms = footage->video_tracks.at(i); - ms->video_preview.save(get_thumbnail_path(hash, ms), "PNG"); + FootageStream& ms = footage->video_tracks[i]; + ms.video_preview.save(get_thumbnail_path(hash, ms), "PNG"); //dout << "saved" << ms->file_index << "thumbnail to" << get_thumbnail_path(hash, ms); } for (int i=0;iaudio_tracks.size();i++) { - FootageStream* ms = footage->audio_tracks.at(i); + FootageStream& ms = footage->audio_tracks[i]; QFile f(get_waveform_path(hash, ms)); f.open(QFile::WriteOnly); - f.write(ms->audio_preview.constData(), ms->audio_preview.size()); + f.write(ms.audio_preview.constData(), ms.audio_preview.size()); f.close(); //dout << "saved" << ms->file_index << "waveform to" << get_waveform_path(hash, ms); } diff --git a/io/previewgenerator.h b/io/previewgenerator.h index 2f1f86c7d..3065bb072 100644 --- a/io/previewgenerator.h +++ b/io/previewgenerator.h @@ -36,8 +36,8 @@ private: bool replace; bool cancelled; QString data_path; - QString get_thumbnail_path(const QString &hash, FootageStream* ms); - QString get_waveform_path(const QString& hash, FootageStream* ms); + QString get_thumbnail_path(const QString &hash, const FootageStream &ms); + QString get_waveform_path(const QString& hash, const FootageStream &ms); }; #endif // PREVIEWGENERATOR_H diff --git a/panels/project.cpp b/panels/project.cpp index 96640180b..4b31f4676 100644 --- a/panels/project.cpp +++ b/panels/project.cpp @@ -181,13 +181,13 @@ Sequence* create_sequence_from_media(QVector& media_list) { if (m->ready) { if (!got_video_values) { for (int j=0;jvideo_tracks.size();j++) { - FootageStream* ms = m->video_tracks.at(j); - s->width = ms->video_width; - s->height = ms->video_height; - if (ms->video_frame_rate != 0) { - s->frame_rate = ms->video_frame_rate; + const FootageStream& ms = m->video_tracks.at(j); + s->width = ms.video_width; + s->height = ms.video_height; + if (ms.video_frame_rate != 0) { + s->frame_rate = ms.video_frame_rate; - if (ms->video_interlacing != VIDEO_PROGRESSIVE) s->frame_rate *= 2; + if (ms.video_interlacing != VIDEO_PROGRESSIVE) s->frame_rate *= 2; // only break with a decent frame rate, otherwise there may be a better candidate got_video_values = true; @@ -197,8 +197,8 @@ Sequence* create_sequence_from_media(QVector& media_list) { } if (!got_audio_values) { for (int j=0;jaudio_tracks.size();j++) { - FootageStream* ms = m->audio_tracks.at(j); - s->audio_frequency = ms->audio_frequency; + const FootageStream& ms = m->audio_tracks.at(j); + s->audio_frequency = ms.audio_frequency; got_audio_values = true; break; } @@ -851,22 +851,22 @@ void Project::save_folder(QXmlStreamWriter& stream, int type, bool set_ids_only, stream.writeAttribute("in", QString::number(f->in)); stream.writeAttribute("out", QString::number(f->out)); for (int j=0;jvideo_tracks.size();j++) { - FootageStream* ms = f->video_tracks.at(j); + const FootageStream& ms = f->video_tracks.at(j); stream.writeStartElement("video"); - stream.writeAttribute("id", QString::number(ms->file_index)); - stream.writeAttribute("width", QString::number(ms->video_width)); - stream.writeAttribute("height", QString::number(ms->video_height)); - stream.writeAttribute("framerate", QString::number(ms->video_frame_rate, 'f', 10)); - stream.writeAttribute("infinite", QString::number(ms->infinite_length)); + stream.writeAttribute("id", QString::number(ms.file_index)); + stream.writeAttribute("width", QString::number(ms.video_width)); + stream.writeAttribute("height", QString::number(ms.video_height)); + stream.writeAttribute("framerate", QString::number(ms.video_frame_rate, 'f', 10)); + stream.writeAttribute("infinite", QString::number(ms.infinite_length)); stream.writeEndElement(); } for (int j=0;jaudio_tracks.size();j++) { - FootageStream* ms = f->audio_tracks.at(j); + const FootageStream& ms = f->audio_tracks.at(j); stream.writeStartElement("audio"); - stream.writeAttribute("id", QString::number(ms->file_index)); - stream.writeAttribute("channels", QString::number(ms->audio_channels)); - stream.writeAttribute("layout", QString::number(ms->audio_layout)); - stream.writeAttribute("frequency", QString::number(ms->audio_frequency)); + stream.writeAttribute("id", QString::number(ms.file_index)); + stream.writeAttribute("channels", QString::number(ms.audio_channels)); + stream.writeAttribute("layout", QString::number(ms.audio_layout)); + stream.writeAttribute("frequency", QString::number(ms.audio_frequency)); stream.writeEndElement(); } stream.writeEndElement(); diff --git a/panels/timeline.cpp b/panels/timeline.cpp index 432fb6996..2f450ae56 100644 --- a/panels/timeline.cpp +++ b/panels/timeline.cpp @@ -182,7 +182,7 @@ void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector can_import = m->ready; if (m->using_inout) { double source_fr = 30; - if (m->video_tracks.size() > 0 && !qIsNull(m->video_tracks.at(0)->video_frame_rate)) source_fr = m->video_tracks.at(0)->video_frame_rate; + if (m->video_tracks.size() > 0 && !qIsNull(m->video_tracks.at(0).video_frame_rate)) source_fr = m->video_tracks.at(0).video_frame_rate; default_clip_in = refactor_frame_number(m->in, source_fr, seq->frame_rate); default_clip_out = refactor_frame_number(m->out, source_fr, seq->frame_rate); } @@ -214,7 +214,7 @@ void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector switch (medium->get_type()) { case MEDIA_TYPE_FOOTAGE: // is video source a still image? - if (m->video_tracks.size() > 0 && m->video_tracks[0]->infinite_length && m->audio_tracks.size() == 0) { + if (m->video_tracks.size() > 0 && m->video_tracks.at(0).infinite_length && m->audio_tracks.size() == 0) { g.out = g.in + 100; } else { long length = m->get_length_in_frames(seq->frame_rate); @@ -225,16 +225,20 @@ void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector } for (int j=0;jaudio_tracks.size();j++) { - g.track = j; - g.media_stream = m->audio_tracks.at(j)->file_index; - ghosts.append(g); - audio_ghosts = true; + if (m->audio_tracks.at(j).enabled) { + g.track = j; + g.media_stream = m->audio_tracks.at(j).file_index; + ghosts.append(g); + audio_ghosts = true; + } } for (int j=0;jvideo_tracks.size();j++) { - g.track = -1-j; - g.media_stream = m->video_tracks.at(j)->file_index; - ghosts.append(g); - video_ghosts = true; + if (m->video_tracks.at(j).enabled) { + g.track = -1-j; + g.media_stream = m->video_tracks.at(j).file_index; + ghosts.append(g); + video_ghosts = true; + } } break; case MEDIA_TYPE_SEQUENCE: diff --git a/panels/viewer.cpp b/panels/viewer.cpp index 01e488079..5563a5943 100644 --- a/panels/viewer.cpp +++ b/panels/viewer.cpp @@ -573,14 +573,14 @@ void Viewer::set_media(Media* m) { seq->frame_rate = 30; if (footage->video_tracks.size() > 0) { - FootageStream* video_stream = footage->video_tracks.at(0); - seq->width = video_stream->video_width; - seq->height = video_stream->video_height; - if (video_stream->video_frame_rate > 0 && !video_stream->infinite_length) seq->frame_rate = video_stream->video_frame_rate; + const FootageStream& video_stream = footage->video_tracks.at(0); + seq->width = video_stream.video_width; + seq->height = video_stream.video_height; + if (video_stream.video_frame_rate > 0 && !video_stream.infinite_length) seq->frame_rate = video_stream.video_frame_rate; Clip* c = new Clip(seq); c->media = media; - c->media_stream = video_stream->file_index; + c->media_stream = video_stream.file_index; c->timeline_in = 0; c->timeline_out = footage->get_length_in_frames(seq->frame_rate); if (c->timeline_out <= 0) c->timeline_out = 150; @@ -594,12 +594,12 @@ void Viewer::set_media(Media* m) { } if (footage->audio_tracks.size() > 0) { - FootageStream* audio_stream = footage->audio_tracks.at(0); - seq->audio_frequency = audio_stream->audio_frequency; + const FootageStream& audio_stream = footage->audio_tracks.at(0); + seq->audio_frequency = audio_stream.audio_frequency; Clip* c = new Clip(seq); c->media = media; - c->media_stream = audio_stream->file_index; + c->media_stream = audio_stream.file_index; c->timeline_in = 0; c->timeline_out = footage->get_length_in_frames(seq->frame_rate); c->track = 0; @@ -610,7 +610,7 @@ void Viewer::set_media(Media* m) { if (footage->video_tracks.size() == 0) { viewer_widget->waveform = true; viewer_widget->waveform_clip = c; - viewer_widget->waveform_ms = audio_stream; + viewer_widget->waveform_ms = &audio_stream; viewer_widget->update(); } } else { diff --git a/playback/cacher.cpp b/playback/cacher.cpp index d9a7056ce..ef6687c9e 100644 --- a/playback/cacher.cpp +++ b/playback/cacher.cpp @@ -451,7 +451,7 @@ void cache_video_worker(Clip* c, long playhead) { AVFrame* frame = av_frame_alloc(); Footage* media = c->media->to_footage(); - FootageStream* ms = media->get_stream_from_file_index(true, c->media_stream); + const FootageStream* ms = media->get_stream_from_file_index(true, c->media_stream); while ((retr_ret = av_buffersink_get_frame(c->buffersink_ctx, frame)) == AVERROR(EAGAIN)) { if (c->multithreaded && c->cacher->interrupt) return; // abort @@ -546,7 +546,7 @@ void reset_cache(Clip* c, long target_frame) { c->frame->pts = 0; } } else { - FootageStream* ms = c->media->to_footage()->get_stream_from_file_index(c->track < 0, c->media_stream); + const FootageStream* ms = c->media->to_footage()->get_stream_from_file_index(c->track < 0, c->media_stream); if (ms->infinite_length) { /*avcodec_flush_buffers(c->codecCtx); av_seek_frame(c->formatCtx, ms->file_index, 0, AVSEEK_FLAG_BACKWARD);*/ @@ -640,7 +640,7 @@ void open_clip_worker(Clip* clip) { Footage* m = clip->media->to_footage(); QByteArray ba = m->url.toUtf8(); const char* filename = ba.constData(); - FootageStream* ms = m->get_stream_from_file_index(clip->track < 0, clip->media_stream); + const FootageStream* ms = m->get_stream_from_file_index(clip->track < 0, clip->media_stream); int errCode = avformat_open_input( &clip->formatCtx, diff --git a/playback/playback.cpp b/playback/playback.cpp index 1448e312a..9dd4a399d 100644 --- a/playback/playback.cpp +++ b/playback/playback.cpp @@ -116,11 +116,11 @@ double get_timecode(Clip* c, long playhead) { void get_clip_frame(Clip* c, long playhead) { if (c->finished_opening) { - FootageStream* ms = c->media->to_footage()->get_stream_from_file_index(c->track < 0, c->media_stream); + const FootageStream* ms = c->media->to_footage()->get_stream_from_file_index(c->track < 0, c->media_stream); int64_t target_pts = qMax(static_cast(0), playhead_to_timestamp(c, playhead)); int64_t second_pts = qRound64(av_q2d(av_inv_q(c->stream->time_base))); - if (ms->video_interlacing != VIDEO_PROGRESSIVE) { + if (ms->video_interlacing != VIDEO_PROGRESSIVE) { target_pts *= 2; second_pts *= 2; } @@ -132,7 +132,7 @@ void get_clip_frame(Clip* c, long playhead) { c->queue_lock.lock(); if (c->queue.size() > 0) { - if (ms->infinite_length) { + if (ms->infinite_length) { target_frame = c->queue.at(0); #ifdef GCF_DEBUG dout << "GCF ==> USE PRECISE (INFINITE)"; diff --git a/project/clip.cpp b/project/clip.cpp index 213a53858..a2f4eafb6 100644 --- a/project/clip.cpp +++ b/project/clip.cpp @@ -113,9 +113,9 @@ void Clip::refresh() { Footage* m = media->to_footage(); if (track < 0 && m->video_tracks.size() > 0) { - media_stream = m->video_tracks.at(0)->file_index; + media_stream = m->video_tracks.at(0).file_index; } else if (track >= 0 && m->audio_tracks.size() > 0) { - media_stream = m->audio_tracks.at(0)->file_index; + media_stream = m->audio_tracks.at(0).file_index; } } replaced = false; @@ -241,8 +241,8 @@ void Clip::recalculateMaxLength() { case MEDIA_TYPE_FOOTAGE: { Footage* m = media->to_footage(); - FootageStream* ms = m->get_stream_from_file_index(track < 0, media_stream); - if (ms != NULL && ms->infinite_length) { + const FootageStream* ms = m->get_stream_from_file_index(track < 0, media_stream); + if (ms != NULL && ms->infinite_length) { calculated_length = LONG_MAX; } else { calculated_length = m->get_length_in_frames(fr); @@ -269,7 +269,7 @@ int Clip::getWidth() { switch (media->get_type()) { case MEDIA_TYPE_FOOTAGE: { - FootageStream* ms = media->to_footage()->get_stream_from_file_index(track < 0, media_stream); + const FootageStream* ms = media->to_footage()->get_stream_from_file_index(track < 0, media_stream); if (ms != NULL) return ms->video_width; if (sequence != NULL) return sequence->width; } @@ -287,7 +287,7 @@ int Clip::getHeight() { switch (media->get_type()) { case MEDIA_TYPE_FOOTAGE: { - FootageStream* ms = media->to_footage()->get_stream_from_file_index(track < 0, media_stream); + const FootageStream* ms = media->to_footage()->get_stream_from_file_index(track < 0, media_stream); if (ms != NULL) return ms->video_height; if (sequence != NULL) return sequence->height; } diff --git a/project/footage.cpp b/project/footage.cpp index b54f5a4a3..ec3a8baa1 100644 --- a/project/footage.cpp +++ b/project/footage.cpp @@ -24,12 +24,6 @@ void Footage::reset() { preview_gen->cancel(); preview_gen->wait(); } - for (int i=0;ifile_index == index) { - return video_tracks.at(i); + if (video_tracks.at(i).file_index == index) { + return &video_tracks[i]; } } } else { for (int i=0;ifile_index == index) { - return audio_tracks.at(i); + if (audio_tracks.at(i).file_index == index) { + return &audio_tracks[i]; } } } diff --git a/project/footage.h b/project/footage.h index 015253173..effbced64 100644 --- a/project/footage.h +++ b/project/footage.h @@ -29,6 +29,7 @@ struct FootageStream { int audio_channels; int audio_layout; int audio_frequency; + bool enabled; // preview thumbnail/waveform bool preview_done; @@ -45,8 +46,8 @@ struct Footage { QString url; QString name; int64_t length; - QVector video_tracks; - QVector audio_tracks; + QVector video_tracks; + QVector audio_tracks; int save_id; bool ready; bool invalid; @@ -59,7 +60,7 @@ struct Footage { long out; long get_length_in_frames(double frame_rate); - FootageStream* get_stream_from_file_index(bool video, int index); + FootageStream *get_stream_from_file_index(bool video, int index); void reset(); }; diff --git a/project/media.cpp b/project/media.cpp index cec9c7f8f..bf72646cb 100644 --- a/project/media.cpp +++ b/project/media.cpp @@ -104,21 +104,21 @@ void Media::update_tooltip(const QString& error) { if (i > 0) { tooltip += ", "; } - tooltip += QString::number(f->video_tracks.at(i)->video_width) + "x" + QString::number(f->video_tracks.at(i)->video_height); + tooltip += QString::number(f->video_tracks.at(i).video_width) + "x" + QString::number(f->video_tracks.at(i).video_height); } tooltip += "\n"; - if (!f->video_tracks.at(0)->infinite_length) { + if (!f->video_tracks.at(0).infinite_length) { tooltip += "Frame Rate: "; for (int i=0;ivideo_tracks.size();i++) { if (i > 0) { tooltip += ", "; } - if (f->video_tracks.at(i)->video_interlacing == VIDEO_PROGRESSIVE) { - tooltip += QString::number(f->video_tracks.at(i)->video_frame_rate); + if (f->video_tracks.at(i).video_interlacing == VIDEO_PROGRESSIVE) { + tooltip += QString::number(f->video_tracks.at(i).video_frame_rate); } else { - tooltip += QString::number(f->video_tracks.at(i)->video_frame_rate * 2); - tooltip += " fields (" + QString::number(f->video_tracks.at(i)->video_frame_rate) + " frames)"; + tooltip += QString::number(f->video_tracks.at(i).video_frame_rate * 2); + tooltip += " fields (" + QString::number(f->video_tracks.at(i).video_frame_rate) + " frames)"; } } tooltip += "\n"; @@ -129,7 +129,7 @@ void Media::update_tooltip(const QString& error) { if (i > 0) { tooltip += ", "; } - tooltip += get_interlacing_name(f->video_tracks.at(i)->video_interlacing); + tooltip += get_interlacing_name(f->video_tracks.at(i).video_interlacing); } } @@ -141,7 +141,7 @@ void Media::update_tooltip(const QString& error) { if (i > 0) { tooltip += ", "; } - tooltip += QString::number(f->audio_tracks.at(i)->audio_frequency); + tooltip += QString::number(f->audio_tracks.at(i).audio_frequency); } tooltip += "\n"; @@ -150,7 +150,7 @@ void Media::update_tooltip(const QString& error) { if (i > 0) { tooltip += ", "; } - tooltip += get_channel_layout_name(f->audio_tracks.at(i)->audio_channels, f->audio_tracks.at(i)->audio_layout); + tooltip += get_channel_layout_name(f->audio_tracks.at(i).audio_channels, f->audio_tracks.at(i).audio_layout); } // tooltip += "\n"; } @@ -202,8 +202,8 @@ double Media::get_frame_rate(int stream) { case MEDIA_TYPE_FOOTAGE: { Footage* f = to_footage(); - if (stream < 0) return f->video_tracks.at(0)->video_frame_rate; - return f->get_stream_from_file_index(true, stream)->video_frame_rate; + if (stream < 0) return f->video_tracks.at(0).video_frame_rate; + return f->get_stream_from_file_index(true, stream)->video_frame_rate; } case MEDIA_TYPE_SEQUENCE: return to_sequence()->frame_rate; } @@ -215,8 +215,8 @@ int Media::get_sampling_rate(int stream) { case MEDIA_TYPE_FOOTAGE: { Footage* f = to_footage(); - if (stream < 0) return f->audio_tracks.at(0)->audio_frequency; - return to_footage()->get_stream_from_file_index(false, stream)->audio_frequency; + if (stream < 0) return f->audio_tracks.at(0).audio_frequency; + return to_footage()->get_stream_from_file_index(false, stream)->audio_frequency; } case MEDIA_TYPE_SEQUENCE: return to_sequence()->audio_frequency; } @@ -258,8 +258,8 @@ QVariant Media::data(int column, int role) { if (get_type() == MEDIA_TYPE_FOOTAGE) { Footage* f = to_footage(); if (f->video_tracks.size() > 0 - && f->video_tracks.at(0)->preview_done) { - return f->video_tracks.at(0)->video_preview_square; + && f->video_tracks.at(0).preview_done) { + return f->video_tracks.at(0).video_preview_square; } } @@ -279,7 +279,8 @@ QVariant Media::data(int column, int role) { Footage* f = to_footage(); double r = 30; - if (f->video_tracks.size() > 0 && !qIsNull(f->video_tracks.at(0)->video_frame_rate)) r = f->video_tracks.at(0)->video_frame_rate; + if (f->video_tracks.size() > 0 && !qIsNull(f->video_tracks.at(0).video_frame_rate)) + r = f->video_tracks.at(0).video_frame_rate; long len = f->get_length_in_frames(r); if (len > 0) return frame_to_timecode(len, config.timecode_view, r); diff --git a/ui/timelinewidget.cpp b/ui/timelinewidget.cpp index da2d3b738..2e11b423e 100644 --- a/ui/timelinewidget.cpp +++ b/ui/timelinewidget.cpp @@ -1272,9 +1272,9 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { Clip* c = NULL; if (g.clip != -1) c = sequence->clips.at(g.clip); - FootageStream* ms = NULL; + const FootageStream* ms = NULL; if (g.clip != -1 && c->media != NULL && c->media->get_type() == MEDIA_TYPE_FOOTAGE) { - ms = c->media->to_footage()->get_stream_from_file_index(c->track < 0, c->media_stream); + ms = c->media->to_footage()->get_stream_from_file_index(c->track < 0, c->media_stream); } // validate ghosts for trimming @@ -2145,7 +2145,7 @@ int color_brightness(int r, int g, int b) { return (0.2126*r + 0.7152*g + 0.0722*b); } -void draw_waveform(Clip* clip, FootageStream* ms, long media_length, QPainter *p, const QRect& clip_rect, int waveform_start, int waveform_limit, double zoom) { +void draw_waveform(Clip* clip, const FootageStream* ms, long media_length, QPainter *p, const QRect& clip_rect, int waveform_start, int waveform_limit, double zoom) { int divider = ms->audio_channels*2; int channel_height = clip_rect.height()/ms->audio_channels; diff --git a/ui/timelinewidget.h b/ui/timelinewidget.h index bf03b1595..b8339a1b6 100644 --- a/ui/timelinewidget.h +++ b/ui/timelinewidget.h @@ -22,7 +22,7 @@ class QPainter; class Media; bool same_sign(int a, int b); -void draw_waveform(Clip* clip, FootageStream* ms, long media_length, QPainter* p, const QRect& clip_rect, int waveform_start, int waveform_limit, double zoom); +void draw_waveform(Clip* clip, const FootageStream *ms, long media_length, QPainter* p, const QRect& clip_rect, int waveform_start, int waveform_limit, double zoom); class TimelineWidget : public QWidget { Q_OBJECT diff --git a/ui/viewerwidget.cpp b/ui/viewerwidget.cpp index a501fbfec..9a1681dc7 100644 --- a/ui/viewerwidget.cpp +++ b/ui/viewerwidget.cpp @@ -485,7 +485,7 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) Footage* m = c->media->to_footage(); if (!m->invalid && !(c->track >= 0 && !is_audio_device_set())) { if (m->ready) { - FootageStream* ms = m->get_stream_from_file_index(c->track < 0, c->media_stream); + const FootageStream* ms = m->get_stream_from_file_index(c->track < 0, c->media_stream); if (ms != NULL && is_clip_active(c, playhead)) { // if thread is already working, we don't want to touch this, // but we also don't want to hang the UI thread diff --git a/ui/viewerwidget.h b/ui/viewerwidget.h index fa51aa383..0450efd52 100644 --- a/ui/viewerwidget.h +++ b/ui/viewerwidget.h @@ -34,7 +34,7 @@ public: bool waveform; Clip* waveform_clip; - FootageStream* waveform_ms; + const FootageStream* waveform_ms; double waveform_zoom; int waveform_scroll; From d4c115ef54bc6baf999fea4fde5df6d243fc5d3b Mon Sep 17 00:00:00 2001 From: eszlari Date: Wed, 2 Jan 2019 22:46:49 +0100 Subject: [PATCH 07/10] Linux mime: add icon --- packaging/linux/org.olivevideoeditor.Olive.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/packaging/linux/org.olivevideoeditor.Olive.xml b/packaging/linux/org.olivevideoeditor.Olive.xml index df8e8e517..418f4a795 100644 --- a/packaging/linux/org.olivevideoeditor.Olive.xml +++ b/packaging/linux/org.olivevideoeditor.Olive.xml @@ -3,5 +3,6 @@ Olive project + From 820be3b8b518835a134fac6276e8876a568cf758 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Thu, 3 Jan 2019 10:12:55 +1100 Subject: [PATCH 08/10] fixed crash caused by editing a sequence after deleting a clip --- project/undo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/undo.cpp b/project/undo.cpp index e67c38941..2fa50573a 100644 --- a/project/undo.cpp +++ b/project/undo.cpp @@ -1127,7 +1127,7 @@ void EditSequenceCommand::update() { // See if one exists or if you have to make one, make it // re-usable - seq->clips.at(i)->refresh(); + if (seq->clips.at(i) != NULL) seq->clips.at(i)->refresh(); } if (sequence == seq) { From 0f4664093190010ce860f73fbeaa47d7e3fab228 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Thu, 3 Jan 2019 11:25:47 +1100 Subject: [PATCH 09/10] fixed replace clip media regression --- dialogs/mediapropertiesdialog.cpp | 160 ++++++++++++++--------------- dialogs/replaceclipmediadialog.cpp | 6 +- project/undo.cpp | 5 - 3 files changed, 83 insertions(+), 88 deletions(-) diff --git a/dialogs/mediapropertiesdialog.cpp b/dialogs/mediapropertiesdialog.cpp index a94215f0f..ada35aa76 100644 --- a/dialogs/mediapropertiesdialog.cpp +++ b/dialogs/mediapropertiesdialog.cpp @@ -15,117 +15,117 @@ #include "project/undo.h" MediaPropertiesDialog::MediaPropertiesDialog(QWidget *parent, Media *i) : - QDialog(parent), - item(i) + QDialog(parent), + item(i) { - setWindowTitle("\"" + i->data(0, Qt::DisplayRole).toString() + "\" Properties"); + setWindowTitle("\"" + i->get_name() + "\" Properties"); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QGridLayout* grid = new QGridLayout(); setLayout(grid); - int row = 0; + int row = 0; - Footage* f = item->to_footage(); + Footage* f = item->to_footage(); - grid->addWidget(new QLabel("Tracks:"), row, 0, 1, 2); - row++; + grid->addWidget(new QLabel("Tracks:"), row, 0, 1, 2); + row++; - track_list = new QListWidget(); - for (int i=0;ivideo_tracks.size();i++) { - const FootageStream& fs = f->video_tracks.at(i); - QListWidgetItem* item = new QListWidgetItem("Video " + QString::number(fs.file_index) + ": " + QString::number(fs.video_width) + "x" + QString::number(fs.video_height) + " " + QString::number(fs.video_frame_rate) + "FPS"); - item->setFlags(item->flags() | Qt::ItemIsUserCheckable); - item->setCheckState(fs.enabled ? Qt::Checked : Qt::Unchecked); - item->setData(Qt::UserRole+1, fs.file_index); - track_list->addItem(item); - } - for (int i=0;iaudio_tracks.size();i++) { - const FootageStream& fs = f->audio_tracks.at(i); - QListWidgetItem* item = new QListWidgetItem("Audio " + QString::number(fs.file_index) + ": " + QString::number(fs.audio_frequency) + "Hz " + QString::number(fs.audio_channels) + " channels"); - item->setFlags(item->flags() | Qt::ItemIsUserCheckable); - item->setCheckState(fs.enabled ? Qt::Checked : Qt::Unchecked); - item->setData(Qt::UserRole+1, fs.file_index); - track_list->addItem(item); - } - grid->addWidget(track_list, row, 0, 1, 2); - row++; + track_list = new QListWidget(); + for (int i=0;ivideo_tracks.size();i++) { + const FootageStream& fs = f->video_tracks.at(i); + QListWidgetItem* item = new QListWidgetItem("Video " + QString::number(fs.file_index) + ": " + QString::number(fs.video_width) + "x" + QString::number(fs.video_height) + " " + QString::number(fs.video_frame_rate) + "FPS"); + item->setFlags(item->flags() | Qt::ItemIsUserCheckable); + item->setCheckState(fs.enabled ? Qt::Checked : Qt::Unchecked); + item->setData(Qt::UserRole+1, fs.file_index); + track_list->addItem(item); + } + for (int i=0;iaudio_tracks.size();i++) { + const FootageStream& fs = f->audio_tracks.at(i); + QListWidgetItem* item = new QListWidgetItem("Audio " + QString::number(fs.file_index) + ": " + QString::number(fs.audio_frequency) + "Hz " + QString::number(fs.audio_channels) + " channels"); + item->setFlags(item->flags() | Qt::ItemIsUserCheckable); + item->setCheckState(fs.enabled ? Qt::Checked : Qt::Unchecked); + item->setData(Qt::UserRole+1, fs.file_index); + track_list->addItem(item); + } + grid->addWidget(track_list, row, 0, 1, 2); + row++; - if (f->video_tracks.size() > 0) { - interlacing_box = new QComboBox(); - interlacing_box->addItem("Auto (" + get_interlacing_name(f->video_tracks.at(0).video_auto_interlacing) + ")"); - interlacing_box->addItem(get_interlacing_name(VIDEO_PROGRESSIVE)); - interlacing_box->addItem(get_interlacing_name(VIDEO_TOP_FIELD_FIRST)); - interlacing_box->addItem(get_interlacing_name(VIDEO_BOTTOM_FIELD_FIRST)); + if (f->video_tracks.size() > 0) { + interlacing_box = new QComboBox(); + interlacing_box->addItem("Auto (" + get_interlacing_name(f->video_tracks.at(0).video_auto_interlacing) + ")"); + interlacing_box->addItem(get_interlacing_name(VIDEO_PROGRESSIVE)); + interlacing_box->addItem(get_interlacing_name(VIDEO_TOP_FIELD_FIRST)); + interlacing_box->addItem(get_interlacing_name(VIDEO_BOTTOM_FIELD_FIRST)); - interlacing_box->setCurrentIndex((f->video_tracks.at(0).video_auto_interlacing == f->video_tracks.at(0).video_interlacing) ? 0 : f->video_tracks.at(0).video_interlacing + 1); + interlacing_box->setCurrentIndex((f->video_tracks.at(0).video_auto_interlacing == f->video_tracks.at(0).video_interlacing) ? 0 : f->video_tracks.at(0).video_interlacing + 1); - grid->addWidget(new QLabel("Interlacing:"), row, 0); - grid->addWidget(interlacing_box, row, 1); + grid->addWidget(new QLabel("Interlacing:"), row, 0); + grid->addWidget(interlacing_box, row, 1); - row++; - } + row++; + } - name_box = new QLineEdit(item->get_name()); - grid->addWidget(new QLabel("Name:"), row, 0); - grid->addWidget(name_box, row, 1); - row++; + name_box = new QLineEdit(item->get_name()); + grid->addWidget(new QLabel("Name:"), row, 0); + grid->addWidget(name_box, row, 1); + row++; QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); buttons->setCenterButtons(true); - grid->addWidget(buttons, row, 0, 1, 2); + grid->addWidget(buttons, row, 0, 1, 2); connect(buttons, SIGNAL(accepted()), this, SLOT(accept())); - connect(buttons, SIGNAL(rejected()), this, SLOT(reject())); + connect(buttons, SIGNAL(rejected()), this, SLOT(reject())); } void MediaPropertiesDialog::accept() { - Footage* f = item->to_footage(); + Footage* f = item->to_footage(); ComboAction* ca = new ComboAction(); - // set track enable - for (int i=0;icount();i++) { - QListWidgetItem* item = track_list->item(i); - const QVariant& data = item->data(Qt::UserRole+1); - if (!data.isNull()) { - int index = data.toInt(); - bool found = false; - for (int j=0;jvideo_tracks.size();j++) { - if (f->video_tracks.at(j).file_index == index) { - f->video_tracks[j].enabled = (item->checkState() == Qt::Checked); - found = true; - break; - } - } - if (!found) { - for (int j=0;jaudio_tracks.size();j++) { - if (f->audio_tracks.at(j).file_index == index) { - f->audio_tracks[j].enabled = (item->checkState() == Qt::Checked); - break; - } - } - } - } - } + // set track enable + for (int i=0;icount();i++) { + QListWidgetItem* item = track_list->item(i); + const QVariant& data = item->data(Qt::UserRole+1); + if (!data.isNull()) { + int index = data.toInt(); + bool found = false; + for (int j=0;jvideo_tracks.size();j++) { + if (f->video_tracks.at(j).file_index == index) { + f->video_tracks[j].enabled = (item->checkState() == Qt::Checked); + found = true; + break; + } + } + if (!found) { + for (int j=0;jaudio_tracks.size();j++) { + if (f->audio_tracks.at(j).file_index == index) { + f->audio_tracks[j].enabled = (item->checkState() == Qt::Checked); + break; + } + } + } + } + } - // set interlacing - if (f->video_tracks.size() > 0) { - if (interlacing_box->currentIndex() > 0) { - ca->append(new SetInt(&f->video_tracks[0].video_interlacing, interlacing_box->currentIndex() - 1)); - } else { - ca->append(new SetInt(&f->video_tracks[0].video_interlacing, f->video_tracks.at(0).video_auto_interlacing)); - } - } + // set interlacing + if (f->video_tracks.size() > 0) { + if (interlacing_box->currentIndex() > 0) { + ca->append(new SetInt(&f->video_tracks[0].video_interlacing, interlacing_box->currentIndex() - 1)); + } else { + ca->append(new SetInt(&f->video_tracks[0].video_interlacing, f->video_tracks.at(0).video_auto_interlacing)); + } + } - // set name - MediaRename* mr = new MediaRename(item, name_box->text()); + // set name + MediaRename* mr = new MediaRename(item, name_box->text()); ca->append(mr); ca->appendPost(new CloseAllClipsCommand()); - ca->appendPost(new UpdateFootageTooltip(item)); + ca->appendPost(new UpdateFootageTooltip(item)); undo_stack.push(ca); - QDialog::accept(); + QDialog::accept(); } diff --git a/dialogs/replaceclipmediadialog.cpp b/dialogs/replaceclipmediadialog.cpp index c1f042f22..5243cc71c 100644 --- a/dialogs/replaceclipmediadialog.cpp +++ b/dialogs/replaceclipmediadialog.cpp @@ -23,6 +23,8 @@ ReplaceClipMediaDialog::ReplaceClipMediaDialog(QWidget *parent, Media *old_media QDialog(parent), media(old_media) { + setWindowTitle("Replace clips using \"" + old_media->get_name() + "\""); + resize(300, 400); QVBoxLayout* layout = new QVBoxLayout(); @@ -56,12 +58,10 @@ ReplaceClipMediaDialog::ReplaceClipMediaDialog(QWidget *parent, Media *old_media setLayout(layout); tree->setModel(&project_model); - - //copy_tree(NULL, NULL); } void ReplaceClipMediaDialog::replace() { - QModelIndexList selected_items = panel_project->get_current_selected(); + QModelIndexList selected_items = tree->selectionModel()->selectedRows(); if (selected_items.size() != 1) { QMessageBox::critical(this, "No media selected", "Please select a media to replace with or click 'Cancel'.", QMessageBox::Ok); } else { diff --git a/project/undo.cpp b/project/undo.cpp index 2fa50573a..c77a30e67 100644 --- a/project/undo.cpp +++ b/project/undo.cpp @@ -1122,11 +1122,6 @@ void EditSequenceCommand::update() { item->set_sequence(seq); for (int i=0;iclips.size();i++) { - // TODO shift in/out/clipin points to match new frame rate - // BUT ALSO copy/paste must need a similar routine, no? - // See if one exists or if you have to make one, make it - // re-usable - if (seq->clips.at(i) != NULL) seq->clips.at(i)->refresh(); } From a98fb0bbc000c889cc7a000b6aa229f29b0decee Mon Sep 17 00:00:00 2001 From: eszlari Date: Thu, 3 Jan 2019 01:35:35 +0100 Subject: [PATCH 10/10] appdata: screenshot, license, bugtracker --- packaging/linux/org.olivevideoeditor.Olive.appdata.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packaging/linux/org.olivevideoeditor.Olive.appdata.xml b/packaging/linux/org.olivevideoeditor.Olive.appdata.xml index fb3a2c6f5..703ce1de1 100644 --- a/packaging/linux/org.olivevideoeditor.Olive.appdata.xml +++ b/packaging/linux/org.olivevideoeditor.Olive.appdata.xml @@ -3,7 +3,7 @@ org.olivevideoeditor.Olive Olive CC0-1.0 - GPLv3 + GPL-3.0 Olive Team Non-linear video editor Editor de vídeo não-linear @@ -15,9 +15,9 @@

Olive — свободный нелинейный видеоредактор, задуманный как полноценная замена закрытым коммерческим продуктам.

https://www.olivevideoeditor.org https://www.patreon.com/olivevideoeditor - https://github.com/olive-editor/olive/issues + https://github.com/olive-editor/olive/issues - http://images.libregraphicsworld.org/video/2018/12/introducing-olive/olive-alpha-main-window.jpg + https://olivevideoeditor.org/img/screenshot.jpg