more work towards loading media into the node graph

This commit is contained in:
itsmattkc
2019-08-06 08:26:25 +10:00
parent cee2b617a1
commit 360328ccbb
7 changed files with 26 additions and 15 deletions
+2 -2
View File
@@ -30,7 +30,7 @@ QString olive::timestamp_to_timecode(const int64_t &timestamp,
const rational& timebase,
const TimecodeDisplay& display)
{
double timestamp_dbl = (rational(timestamp) * timebase).ToDouble();
double timestamp_dbl = (rational(timestamp) * timebase).toDouble();
switch (display) {
case kTimecodeFrames:
@@ -52,7 +52,7 @@ QString olive::timestamp_to_timecode(const int64_t &timestamp,
} else {
rational frame_rate = timebase.flipped();
int frames = qRound((timestamp_dbl - total_seconds) * frame_rate.ToDouble());
int frames = qRound((timestamp_dbl - total_seconds) * frame_rate.toDouble());
return QString("%1:%2:%3;%4").arg(padded(hours, 2),
padded(mins, 2),
+2 -2
View File
@@ -278,11 +278,11 @@ void Core::CreateNewSequence()
new_sequence->AddNode(ii);
ClipBlock* cb1 = new ClipBlock();
cb1->set_length(1);
cb1->set_length(2);
new_sequence->AddNode(cb1);
ClipBlock* cb2 = new ClipBlock();
cb2->set_length(1);
cb2->set_length(4);
new_sequence->AddNode(cb2);
TimelineOutput* tb = new TimelineOutput();
+4 -2
View File
@@ -167,8 +167,8 @@ FramePtr FFmpegDecoder::Retrieve(const rational &timecode, const rational &lengt
return nullptr;
}
// avcodec_flush_buffers(codec_ctx_);
// av_seek_frame(fmt_ctx_, avstream_->index, 0, AVSEEK_FLAG_BACKWARD);
//avcodec_flush_buffers(codec_ctx_);
//av_seek_frame(fmt_ctx_, avstream_->index, 0, AVSEEK_FLAG_BACKWARD);
// Allocate and init a packet for reading encoded data
AVPacket pkt;
@@ -219,6 +219,8 @@ FramePtr FFmpegDecoder::Retrieve(const rational &timecode, const rational &lengt
}
}
// qDebug() << dec_frame->pts << ",";
// Handle any errors received during the frame retrieve process
if (ret < 0) {
qWarning() << tr("Failed to retrieve frame from FFmpeg decoder: %1").arg(ret);
+2 -2
View File
@@ -205,14 +205,14 @@ void SequenceDialog::AddFrameRate(const rational &r)
{
frame_rate_list_.append(r);
video_frame_rate_field_->addItem(tr("%1 FPS").arg(r.ToDouble()));
video_frame_rate_field_->addItem(tr("%1 FPS").arg(r.toDouble()));
}
void SequenceDialog::AddSampleRate(const rational &rate)
{
sample_rate_list_.append(rate);
audio_sample_rate_field_->addItem(tr("%1 Hz").arg(rate.ToDouble()));
audio_sample_rate_field_->addItem(tr("%1 Hz").arg(rate.toDouble()));
}
void SequenceDialog::AddChannelLayout(int layout)
+10 -1
View File
@@ -20,6 +20,8 @@
#include "clip.h"
#include <QDebug>
ClipBlock::ClipBlock()
{
texture_input_ = new NodeInput();
@@ -59,11 +61,18 @@ NodeInput *ClipBlock::texture_input()
void ClipBlock::Process(const rational &time)
{
qDebug() << "Clip received time" << time.numerator() << "/" << time.denominator();
// Run default node processing
Block::Process(time);
// We convert the time given (timeline time) to media time
rational media_time = time - in() + media_in_;
// rational media_time = time - in() + media_in_;
rational media_time = time - in();
qDebug() << "In time" << in().numerator() << "/" << in().denominator();
qDebug() << "Media In time" << media_in_.numerator() << "/" << media_in_.denominator();
qDebug() << "Media sent time" << media_time.numerator() << "/" << media_time.denominator();
// Retrieve texture
texture_output()->set_value(texture_input_->get_value(media_time));
+2 -2
View File
@@ -10,7 +10,7 @@ TimelineViewRect::TimelineViewRect(QGraphicsItem* parent) :
void TimelineViewRect::SetTimebase(const rational &timebase)
{
timebase_ = timebase;
timebase_dbl_ = timebase_.ToDouble();
timebase_dbl_ = timebase_.toDouble();
UpdateRect();
}
@@ -28,5 +28,5 @@ bool TimelineViewRect::TimebaseIsValid()
double TimelineViewRect::TimeToScreenCoord(const rational &time)
{
return time.ToDouble() / timebase_dbl_ * scale_;
return time.toDouble() / timebase_dbl_ * scale_;
}
+4 -4
View File
@@ -113,7 +113,7 @@ void TimeRuler::paintEvent(QPaintEvent *e)
// Depending on the scale, we don't need all the lines drawn or else they'll start to become unhelpful
// Determine an even number to divide the frame count by
int rough_frames_in_second = qRound(time_base_.flipped().ToDouble());
int rough_frames_in_second = qRound(time_base_.flipped().toDouble());
int test_divider = 1;
while (!((rough_frames_in_second%test_divider == 0 || test_divider > rough_frames_in_second)
&& scale_ * test_divider >= minimum_gap_between_lines_)) {
@@ -124,7 +124,7 @@ void TimeRuler::paintEvent(QPaintEvent *e)
}
}
double reverse_divider = double(rough_frames_in_second) / double(test_divider);
qreal real_divider = qMax(1.0, time_base_.flipped().ToDouble() / reverse_divider);
qreal real_divider = qMax(1.0, time_base_.flipped().toDouble() / reverse_divider);
// Set where the loop ends (affected by text)
int loop_start = - playhead_width_;
@@ -136,7 +136,7 @@ void TimeRuler::paintEvent(QPaintEvent *e)
int text_y = 0;
if (text_visible_) {
QFontMetrics fm = p.fontMetrics();
double width_of_second = time_base_.flipped().ToDouble() * scale_;
double width_of_second = time_base_.flipped().toDouble() * scale_;
int average_text_width = QFontMetricsWidth(&fm, olive::timestamp_to_timecode(0, time_base_, kTimecodeDisplay));
half_average_text_width = average_text_width/2;
while (width_of_second * text_skip < average_text_width) {
@@ -180,7 +180,7 @@ void TimeRuler::paintEvent(QPaintEvent *e)
if (qFloor(double(unit)/real_divider) > qFloor(double(last_unit)/real_divider)) {
// Determine if this unit is a whole second or not
int sec = qFloor(double(unit) * time_base_.ToDouble());
int sec = qFloor(double(unit) * time_base_.toDouble());
if (sec > last_sec) {
// This line marks a second so we make it long