hacked footage viewer playing at wrong frequency

This commit is contained in:
itsmattkc
2018-11-12 15:38:34 +11:00
parent 967a91b8f0
commit 398e1aef43
7 changed files with 34 additions and 16 deletions
+8 -1
View File
@@ -33,6 +33,7 @@
#include "effects/internal/linearfadetransition.h" #include "effects/internal/linearfadetransition.h"
#include "effects/internal/exponentialfadetransition.h" #include "effects/internal/exponentialfadetransition.h"
#include "effects/internal/logarithmicfadetransition.h" #include "effects/internal/logarithmicfadetransition.h"
#include "effects/internal/cornerpineffect.h"
#include <QCheckBox> #include <QCheckBox>
#include <QGridLayout> #include <QGridLayout>
@@ -68,6 +69,7 @@ Effect* create_effect(Clip* c, const EffectMeta* em) {
case EFFECT_INTERNAL_LINEARFADE: return new LinearFadeTransition(c, em); case EFFECT_INTERNAL_LINEARFADE: return new LinearFadeTransition(c, em);
case EFFECT_INTERNAL_EXPONENTIALFADE: return new ExponentialFadeTransition(c, em); case EFFECT_INTERNAL_EXPONENTIALFADE: return new ExponentialFadeTransition(c, em);
case EFFECT_INTERNAL_LOGARITHMICFADE: return new LogarithmicFadeTransition(c, em); case EFFECT_INTERNAL_LOGARITHMICFADE: return new LogarithmicFadeTransition(c, em);
case EFFECT_INTERNAL_CORNERPIN: return new CornerPinEffect(c, em);
} }
} else { } else {
dout << "[ERROR] Invalid effect data"; dout << "[ERROR] Invalid effect data";
@@ -117,6 +119,11 @@ void load_internal_effects() {
em.internal = EFFECT_INTERNAL_TRANSFORM; em.internal = EFFECT_INTERNAL_TRANSFORM;
video_effects.append(em); video_effects.append(em);
em.name = "Corner Pin";
em.category = "Distort";
em.internal = EFFECT_INTERNAL_CORNERPIN;
video_effects.append(em);
em.name = "Text"; em.name = "Text";
em.category = "Render"; em.category = "Render";
em.internal = EFFECT_INTERNAL_TEXT; em.internal = EFFECT_INTERNAL_TEXT;
@@ -132,7 +139,6 @@ void load_internal_effects() {
em.internal = EFFECT_INTERNAL_SHAKE; em.internal = EFFECT_INTERNAL_SHAKE;
video_effects.append(em); video_effects.append(em);
// internal transitions // internal transitions
em.type = EFFECT_TYPE_TRANSITION; em.type = EFFECT_TYPE_TRANSITION;
em.category = ""; em.category = "";
@@ -766,6 +772,7 @@ Effect* Effect::copy(Clip* c) {
void Effect::process_shader(double timecode) { void Effect::process_shader(double timecode) {
glslProgram->setUniformValue("resolution", parent_clip->getWidth(), parent_clip->getHeight()); glslProgram->setUniformValue("resolution", parent_clip->getWidth(), parent_clip->getHeight());
glslProgram->setUniformValue("time", (GLfloat) timecode);
for (int i=0;i<rows.size();i++) { for (int i=0;i<rows.size();i++) {
EffectRow* row = rows.at(i); EffectRow* row = rows.at(i);
+2 -1
View File
@@ -71,7 +71,8 @@ extern QMutex effects_loaded;
#define EFFECT_INTERNAL_LINEARFADE 9 #define EFFECT_INTERNAL_LINEARFADE 9
#define EFFECT_INTERNAL_EXPONENTIALFADE 10 #define EFFECT_INTERNAL_EXPONENTIALFADE 10
#define EFFECT_INTERNAL_LOGARITHMICFADE 11 #define EFFECT_INTERNAL_LOGARITHMICFADE 11
#define EFFECT_INTERNAL_COUNT 12 #define EFFECT_INTERNAL_CORNERPIN 12
#define EFFECT_INTERNAL_COUNT 13
#define KEYFRAME_TYPE_LINEAR 0 #define KEYFRAME_TYPE_LINEAR 0
#define KEYFRAME_TYPE_SMOOTH 1 #define KEYFRAME_TYPE_SMOOTH 1
+8 -3
View File
@@ -19,9 +19,14 @@ CornerPinEffect::CornerPinEffect(Clip *c, const EffectMeta *em) : Effect(c, em)
bottom_right_x = bottom_right->add_field(EFFECT_FIELD_DOUBLE); bottom_right_x = bottom_right->add_field(EFFECT_FIELD_DOUBLE);
bottom_right_y = bottom_right->add_field(EFFECT_FIELD_DOUBLE); bottom_right_y = bottom_right->add_field(EFFECT_FIELD_DOUBLE);
connect(intensity_val, SIGNAL(changed()), this, SLOT(field_changed())); connect(top_left_x, SIGNAL(changed()), this, SLOT(field_changed()));
connect(rotation_val, SIGNAL(changed()), this, SLOT(field_changed())); connect(top_left_y, SIGNAL(changed()), this, SLOT(field_changed()));
connect(frequency_val, SIGNAL(changed()), this, SLOT(field_changed())); connect(top_right_x, SIGNAL(changed()), this, SLOT(field_changed()));
connect(top_right_y, SIGNAL(changed()), this, SLOT(field_changed()));
connect(bottom_left_x, SIGNAL(changed()), this, SLOT(field_changed()));
connect(bottom_left_y, SIGNAL(changed()), this, SLOT(field_changed()));
connect(bottom_right_x, SIGNAL(changed()), this, SLOT(field_changed()));
connect(bottom_right_y, SIGNAL(changed()), this, SLOT(field_changed()));
} }
void CornerPinEffect::process_coords(double timecode, GLTextureCoords &coords) { void CornerPinEffect::process_coords(double timecode, GLTextureCoords &coords) {
+2 -2
View File
@@ -144,13 +144,13 @@ void TransformEffect::process_coords(double timecode, GLTextureCoords& coords) {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
break; break;
case BLEND_MODE_OVERLAY: case BLEND_MODE_OVERLAY:
glBlendFunc(GL_DST_COLOR, GL_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE);
break; break;
case BLEND_MODE_SCREEN: case BLEND_MODE_SCREEN:
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
break; break;
case BLEND_MODE_MULTIPLY: case BLEND_MODE_MULTIPLY:
glBlendFunc(GL_DST_COLOR, GL_ZERO); glBlendFunc(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA);
break; break;
default: default:
dout << "[ERROR] Invalid blend mode. This is a bug - please contact developers"; dout << "[ERROR] Invalid blend mode. This is a bug - please contact developers";
+6 -4
View File
@@ -11,6 +11,7 @@
#include "project/undo.h" #include "project/undo.h"
#include "ui/audiomonitor.h" #include "ui/audiomonitor.h"
#include "ui_timeline.h" #include "ui_timeline.h"
#include "playback/playback.h"
#include "debug.h" #include "debug.h"
#define FRAMES_IN_ONE_MINUTE 1798 // 1800 - 2 #define FRAMES_IN_ONE_MINUTE 1798 // 1800 - 2
@@ -99,7 +100,8 @@ void Viewer::reset_all_audio() {
void Viewer::assert_audio_device() { void Viewer::assert_audio_device() {
if (audio_output->format().sampleRate() != seq->audio_frequency if (audio_output->format().sampleRate() != seq->audio_frequency
|| audio_output->format().channelCount() != av_get_channel_layout_nb_channels(seq->audio_layout)) { || audio_output->format().channelCount() != av_get_channel_layout_nb_channels(seq->audio_layout)) {
init_audio(seq); closeActiveClips(seq, true);
init_audio(seq);
} }
} }
@@ -529,6 +531,8 @@ void Viewer::set_sequence(bool main, Sequence *s) {
bool null_sequence = (seq == NULL); bool null_sequence = (seq == NULL);
init_audio(seq);
ui->headers->setEnabled(!null_sequence); ui->headers->setEnabled(!null_sequence);
ui->currentTimecode->setEnabled(!null_sequence); ui->currentTimecode->setEnabled(!null_sequence);
ui->openGLWidget->setEnabled(!null_sequence); ui->openGLWidget->setEnabled(!null_sequence);
@@ -539,8 +543,6 @@ void Viewer::set_sequence(bool main, Sequence *s) {
ui->pushButton_4->setEnabled(!null_sequence); ui->pushButton_4->setEnabled(!null_sequence);
ui->pushButton_5->setEnabled(!null_sequence); ui->pushButton_5->setEnabled(!null_sequence);
init_audio(seq);
if (!null_sequence) { if (!null_sequence) {
ui->currentTimecode->set_frame_rate(seq->frame_rate); ui->currentTimecode->set_frame_rate(seq->frame_rate);
@@ -562,7 +564,7 @@ void Viewer::set_sequence(bool main, Sequence *s) {
update_header_zoom(); update_header_zoom();
viewer_widget->update(); viewer_widget->update();
update(); update();
} }
+3
View File
@@ -55,6 +55,7 @@ void init_audio(Sequence* s) {
} }
audio_output = new QAudioOutput(audio_format); audio_output = new QAudioOutput(audio_format);
dout << "made output;";
audio_output->setNotifyInterval(5); audio_output->setNotifyInterval(5);
// connect // connect
@@ -68,6 +69,8 @@ void init_audio(Sequence* s) {
clear_audio_ibuffer(); clear_audio_ibuffer();
} }
dout << "h";
} }
void stop_audio() { void stop_audio() {
+5 -5
View File
@@ -297,10 +297,10 @@ void cache_audio_worker(Clip* c, bool scrubbing, QVector<Clip*>& nests) {
dout << "fsi-post-post:" << c->frame_sample_index; dout << "fsi-post-post:" << c->frame_sample_index;
#endif #endif
if (c->audio_buffer_write == 0) { if (c->audio_buffer_write == 0) {
c->audio_buffer_write = get_buffer_offset_from_frame(sequence, qMax(timeline_in, c->audio_target_frame)); c->audio_buffer_write = get_buffer_offset_from_frame((sequence == NULL) ? c->sequence : sequence, qMax(timeline_in, c->audio_target_frame));
if (frame_skip > 0) { if (frame_skip > 0) {
int target = get_buffer_offset_from_frame(sequence, qMax(timeline_in + frame_skip, c->audio_target_frame)); int target = get_buffer_offset_from_frame((sequence == NULL) ? c->sequence : sequence, qMax(timeline_in + frame_skip, c->audio_target_frame));
c->frame_sample_index += (target - c->audio_buffer_write); c->frame_sample_index += (target - c->audio_buffer_write);
c->audio_buffer_write = target; c->audio_buffer_write = target;
} }
@@ -328,7 +328,7 @@ void cache_audio_worker(Clip* c, bool scrubbing, QVector<Clip*>& nests) {
// apply any audio effects to the data // apply any audio effects to the data
if (nb_bytes == INT_MAX) nb_bytes = frame->nb_samples * av_get_bytes_per_sample(static_cast<AVSampleFormat>(frame->format)) * frame->channels; if (nb_bytes == INT_MAX) nb_bytes = frame->nb_samples * av_get_bytes_per_sample(static_cast<AVSampleFormat>(frame->format)) * frame->channels;
if (new_frame) { if (new_frame) {
apply_audio_effects(c, bytes_to_seconds(c->audio_buffer_write, 2, c->sequence->audio_frequency) + audio_ibuffer_timecode + ((double)c->clip_in/c->sequence->frame_rate) - ((double)timeline_in/sequence->frame_rate), frame, nb_bytes, nests); apply_audio_effects(c, bytes_to_seconds(c->audio_buffer_write, 2, c->sequence->audio_frequency) + audio_ibuffer_timecode + ((double)c->clip_in/c->sequence->frame_rate) - ((double)timeline_in/((sequence == NULL) ? c->sequence->frame_rate : sequence->frame_rate)), frame, nb_bytes, nests);
} }
} }
break; break;
@@ -360,7 +360,7 @@ void cache_audio_worker(Clip* c, bool scrubbing, QVector<Clip*>& nests) {
if (frame->nb_samples == 0) { if (frame->nb_samples == 0) {
break; break;
} else { } else {
long buffer_timeline_out = get_buffer_offset_from_frame(sequence, timeline_out); long buffer_timeline_out = get_buffer_offset_from_frame((sequence == NULL) ? c->sequence : sequence, timeline_out);
audio_write_lock.lock(); audio_write_lock.lock();
while (c->frame_sample_index < nb_bytes while (c->frame_sample_index < nb_bytes
@@ -786,7 +786,7 @@ void open_clip_worker(Clip* clip) {
dout << "[ERROR] Could not set output sample format"; dout << "[ERROR] Could not set output sample format";
} }
int target_sample_rate = sequence->audio_frequency; int target_sample_rate = audio_output->format().sampleRate();
if (qFuzzyCompare(clip->speed, 1.0)) { if (qFuzzyCompare(clip->speed, 1.0)) {
avfilter_link(clip->buffersrc_ctx, 0, clip->buffersink_ctx, 0); avfilter_link(clip->buffersrc_ctx, 0, clip->buffersink_ctx, 0);