sequence: made divider a sequence parameter rather than a viewer parameter
Doing this makes the preview resolution an explicit project setting rather than a temporary UI setting. This will allow more consistency when caching.
This commit is contained in:
+15
-66
@@ -26,125 +26,74 @@ extern "C" {
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
AudioParams::AudioParams() :
|
||||
sample_rate_(0),
|
||||
channel_layout_(0)
|
||||
{
|
||||
}
|
||||
|
||||
AudioParams::AudioParams(const int &sample_rate, const uint64_t &channel_layout) :
|
||||
sample_rate_(sample_rate),
|
||||
channel_layout_(channel_layout)
|
||||
{
|
||||
}
|
||||
|
||||
const int &AudioParams::sample_rate() const
|
||||
{
|
||||
return sample_rate_;
|
||||
}
|
||||
|
||||
const uint64_t &AudioParams::channel_layout() const
|
||||
{
|
||||
return channel_layout_;
|
||||
}
|
||||
|
||||
rational AudioParams::time_base() const
|
||||
{
|
||||
return rational(1, sample_rate());
|
||||
}
|
||||
|
||||
AudioRenderingParams::AudioRenderingParams() :
|
||||
format_(SampleFormat::SAMPLE_FMT_INVALID)
|
||||
{
|
||||
}
|
||||
|
||||
AudioRenderingParams::AudioRenderingParams(const int &sample_rate, const uint64_t &channel_layout, const SampleFormat::Format &format) :
|
||||
AudioParams(sample_rate, channel_layout),
|
||||
format_(format)
|
||||
{
|
||||
}
|
||||
|
||||
AudioRenderingParams::AudioRenderingParams(const AudioParams ¶ms, const SampleFormat::Format &format) :
|
||||
AudioParams(params),
|
||||
format_(format)
|
||||
{
|
||||
}
|
||||
|
||||
int AudioRenderingParams::time_to_bytes(const double &time) const
|
||||
int AudioParams::time_to_bytes(const double &time) const
|
||||
{
|
||||
Q_ASSERT(is_valid());
|
||||
|
||||
return time_to_samples(time) * channel_count() * bytes_per_sample_per_channel();
|
||||
}
|
||||
|
||||
const SampleFormat::Format &AudioRenderingParams::format() const
|
||||
{
|
||||
return format_;
|
||||
}
|
||||
|
||||
bool AudioRenderingParams::operator==(const AudioRenderingParams &other) const
|
||||
bool AudioParams::operator==(const AudioParams &other) const
|
||||
{
|
||||
return (format() == other.format()
|
||||
&& sample_rate() == other.sample_rate()
|
||||
&& channel_layout() == other.channel_layout());
|
||||
}
|
||||
|
||||
bool AudioRenderingParams::operator!=(const AudioRenderingParams &other) const
|
||||
bool AudioParams::operator!=(const AudioParams &other) const
|
||||
{
|
||||
return (format() != other.format()
|
||||
|| sample_rate() != other.sample_rate()
|
||||
|| channel_layout() != other.channel_layout());
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
int AudioRenderingParams::time_to_bytes(const rational &time) const
|
||||
int AudioParams::time_to_bytes(const rational &time) const
|
||||
{
|
||||
return time_to_bytes(time.toDouble());
|
||||
}
|
||||
|
||||
int AudioRenderingParams::time_to_samples(const double &time) const
|
||||
int AudioParams::time_to_samples(const double &time) const
|
||||
{
|
||||
Q_ASSERT(is_valid());
|
||||
|
||||
return qFloor(time * sample_rate());
|
||||
}
|
||||
|
||||
int AudioRenderingParams::time_to_samples(const rational &time) const
|
||||
int AudioParams::time_to_samples(const rational &time) const
|
||||
{
|
||||
return time_to_samples(time.toDouble());
|
||||
}
|
||||
|
||||
int AudioRenderingParams::samples_to_bytes(const int &samples) const
|
||||
int AudioParams::samples_to_bytes(const int &samples) const
|
||||
{
|
||||
Q_ASSERT(is_valid());
|
||||
|
||||
return samples * channel_count() * bytes_per_sample_per_channel();
|
||||
}
|
||||
|
||||
rational AudioRenderingParams::samples_to_time(const int &samples) const
|
||||
rational AudioParams::samples_to_time(const int &samples) const
|
||||
{
|
||||
return rational(samples, sample_rate());
|
||||
}
|
||||
|
||||
int AudioRenderingParams::bytes_to_samples(const int &bytes) const
|
||||
int AudioParams::bytes_to_samples(const int &bytes) const
|
||||
{
|
||||
Q_ASSERT(is_valid());
|
||||
|
||||
return bytes / (channel_count() * bytes_per_sample_per_channel());
|
||||
}
|
||||
|
||||
rational AudioRenderingParams::bytes_to_time(const int &bytes) const
|
||||
rational AudioParams::bytes_to_time(const int &bytes) const
|
||||
{
|
||||
Q_ASSERT(is_valid());
|
||||
|
||||
return samples_to_time(bytes_to_samples(bytes));
|
||||
}
|
||||
|
||||
int AudioRenderingParams::channel_count() const
|
||||
int AudioParams::channel_count() const
|
||||
{
|
||||
return av_get_channel_layout_nb_channels(channel_layout());
|
||||
}
|
||||
|
||||
int AudioRenderingParams::bytes_per_sample_per_channel() const
|
||||
int AudioParams::bytes_per_sample_per_channel() const
|
||||
{
|
||||
switch (format_) {
|
||||
case SampleFormat::SAMPLE_FMT_U8:
|
||||
@@ -165,12 +114,12 @@ int AudioRenderingParams::bytes_per_sample_per_channel() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AudioRenderingParams::bits_per_sample() const
|
||||
int AudioParams::bits_per_sample() const
|
||||
{
|
||||
return bytes_per_sample_per_channel() * 8;
|
||||
}
|
||||
|
||||
bool AudioRenderingParams::is_valid() const
|
||||
bool AudioParams::is_valid() const
|
||||
{
|
||||
bool valid = (sample_rate() > 0
|
||||
&& channel_layout() > 0
|
||||
|
||||
+37
-21
@@ -28,28 +28,41 @@
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
class AudioParams
|
||||
{
|
||||
class AudioParams {
|
||||
public:
|
||||
AudioParams();
|
||||
AudioParams(const int& sample_rate, const uint64_t& channel_layout);
|
||||
AudioParams() :
|
||||
sample_rate_(0),
|
||||
channel_layout_(0),
|
||||
format_(SampleFormat::SAMPLE_FMT_INVALID)
|
||||
{
|
||||
}
|
||||
|
||||
const int& sample_rate() const;
|
||||
const uint64_t& channel_layout() const;
|
||||
rational time_base() const;
|
||||
AudioParams(const int& sample_rate, const uint64_t& channel_layout, const SampleFormat::Format& format) :
|
||||
sample_rate_(sample_rate),
|
||||
channel_layout_(channel_layout),
|
||||
format_(format)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
int sample_rate_;
|
||||
const int& sample_rate() const
|
||||
{
|
||||
return sample_rate_;
|
||||
}
|
||||
|
||||
uint64_t channel_layout_;
|
||||
const uint64_t& channel_layout() const
|
||||
{
|
||||
return channel_layout_;
|
||||
}
|
||||
|
||||
};
|
||||
rational time_base() const
|
||||
{
|
||||
return rational(1, sample_rate());
|
||||
}
|
||||
|
||||
class AudioRenderingParams : public AudioParams {
|
||||
public:
|
||||
AudioRenderingParams();
|
||||
AudioRenderingParams(const int& sample_rate, const uint64_t& channel_layout, const SampleFormat::Format& format);
|
||||
AudioRenderingParams(const AudioParams& params, const SampleFormat::Format& format);
|
||||
const SampleFormat::Format &format() const
|
||||
{
|
||||
return format_;
|
||||
}
|
||||
|
||||
int time_to_bytes(const double& time) const;
|
||||
int time_to_bytes(const rational& time) const;
|
||||
@@ -64,17 +77,20 @@ public:
|
||||
int bits_per_sample() const;
|
||||
bool is_valid() const;
|
||||
|
||||
const SampleFormat::Format &format() const;
|
||||
|
||||
bool operator==(const AudioRenderingParams& other) const;
|
||||
bool operator!=(const AudioRenderingParams& other) const;
|
||||
bool operator==(const AudioParams& other) const;
|
||||
bool operator!=(const AudioParams& other) const;
|
||||
|
||||
private:
|
||||
int sample_rate_;
|
||||
|
||||
uint64_t channel_layout_;
|
||||
|
||||
SampleFormat::Format format_;
|
||||
|
||||
};
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
Q_DECLARE_METATYPE(OLIVE_NAMESPACE::AudioRenderingParams)
|
||||
Q_DECLARE_METATYPE(OLIVE_NAMESPACE::AudioParams)
|
||||
|
||||
#endif // AUDIOPARAMS_H
|
||||
|
||||
@@ -34,7 +34,7 @@ AudioPlaybackCache::AudioPlaybackCache()
|
||||
UpdateFilename(QString::number(r));
|
||||
}
|
||||
|
||||
void AudioPlaybackCache::SetParameters(const AudioRenderingParams ¶ms)
|
||||
void AudioPlaybackCache::SetParameters(const AudioParams ¶ms)
|
||||
{
|
||||
QMutexLocker locker(lock());
|
||||
|
||||
|
||||
@@ -33,12 +33,12 @@ class AudioPlaybackCache : public PlaybackCache
|
||||
public:
|
||||
AudioPlaybackCache();
|
||||
|
||||
AudioRenderingParams GetParameters() {
|
||||
AudioParams GetParameters() {
|
||||
QMutexLocker locker(lock());
|
||||
return params_;
|
||||
}
|
||||
|
||||
void SetParameters(const AudioRenderingParams& params);
|
||||
void SetParameters(const AudioParams& params);
|
||||
|
||||
void WritePCM(const TimeRange &range, SampleBufferPtr samples, const qint64& job_time);
|
||||
|
||||
@@ -70,7 +70,7 @@ private:
|
||||
|
||||
QString filename_;
|
||||
|
||||
AudioRenderingParams params_;
|
||||
AudioParams params_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ bool OpenGLProxy::Init()
|
||||
return true;
|
||||
}
|
||||
|
||||
NodeValue OpenGLProxy::FrameToValue(FramePtr frame, StreamPtr stream, const VideoRenderingParams& params)
|
||||
NodeValue OpenGLProxy::FrameToValue(FramePtr frame, StreamPtr stream, const VideoParams& params, const RenderMode::Mode& mode)
|
||||
{
|
||||
ImageStreamPtr video_stream = std::static_pointer_cast<ImageStream>(stream);
|
||||
|
||||
@@ -83,7 +83,7 @@ NodeValue OpenGLProxy::FrameToValue(FramePtr frame, StreamPtr stream, const Vide
|
||||
color_cache_.insert(colorspace_match, color_processor);
|
||||
}
|
||||
|
||||
ColorManager::OCIOMethod ocio_method = ColorManager::GetOCIOMethodForMode(params.mode());
|
||||
ColorManager::OCIOMethod ocio_method = ColorManager::GetOCIOMethodForMode(mode);
|
||||
|
||||
// OCIO's CPU conversion is more accurate, so for online we render on CPU but offline we render GPU
|
||||
if (ocio_method == ColorManager::kOCIOAccurate) {
|
||||
@@ -120,7 +120,7 @@ NodeValue OpenGLProxy::FrameToValue(FramePtr frame, StreamPtr stream, const Vide
|
||||
color_processor->Enable(ctx_, video_stream->premultiplied_alpha());
|
||||
}
|
||||
|
||||
VideoRenderingParams frame_params = frame->video_params();
|
||||
VideoParams frame_params = frame->video_params();
|
||||
|
||||
// Check frame aspect ratio
|
||||
if (frame->sample_aspect_ratio() != 1 && frame->sample_aspect_ratio() != 0) {
|
||||
@@ -136,16 +136,16 @@ NodeValue OpenGLProxy::FrameToValue(FramePtr frame, StreamPtr stream, const Vide
|
||||
new_height = qRound(static_cast<double>(new_height) / frame->sample_aspect_ratio().toDouble());
|
||||
}
|
||||
|
||||
frame_params = VideoRenderingParams(new_width,
|
||||
new_height,
|
||||
frame_params.format(),
|
||||
frame_params.divider());
|
||||
frame_params = VideoParams(new_width,
|
||||
new_height,
|
||||
frame_params.format(),
|
||||
frame_params.divider());
|
||||
}
|
||||
|
||||
VideoRenderingParams dest_params(frame_params.width(),
|
||||
frame_params.height(),
|
||||
params.format(),
|
||||
frame_params.divider());
|
||||
VideoParams dest_params(frame_params.width(),
|
||||
frame_params.height(),
|
||||
params.format(),
|
||||
frame_params.divider());
|
||||
|
||||
// Create destination texture
|
||||
OpenGLTextureCache::ReferencePtr associated_tex_ref = texture_cache_.Get(ctx_, dest_params);
|
||||
@@ -184,7 +184,7 @@ void OpenGLProxy::RunNodeAccelerated(const Node *node,
|
||||
const TimeRange &range,
|
||||
NodeValueDatabase &input_params,
|
||||
NodeValueTable &output_params,
|
||||
const VideoRenderingParams& params)
|
||||
const VideoParams& params)
|
||||
{
|
||||
OpenGLShaderPtr shader = shader_cache_.value(node->ShaderID(input_params));
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public slots:
|
||||
const OLIVE_NAMESPACE::TimeRange &range,
|
||||
OLIVE_NAMESPACE::NodeValueDatabase &input_params,
|
||||
OLIVE_NAMESPACE::NodeValueTable& output_params,
|
||||
const OLIVE_NAMESPACE::VideoRenderingParams ¶ms);
|
||||
const OLIVE_NAMESPACE::VideoParams ¶ms);
|
||||
|
||||
void TextureToBuffer(const QVariant& texture,
|
||||
OLIVE_NAMESPACE::FramePtr frame,
|
||||
@@ -79,7 +79,8 @@ public slots:
|
||||
|
||||
OLIVE_NAMESPACE::NodeValue FrameToValue(OLIVE_NAMESPACE::FramePtr frame,
|
||||
OLIVE_NAMESPACE::StreamPtr stream,
|
||||
const OLIVE_NAMESPACE::VideoRenderingParams ¶ms);
|
||||
const OLIVE_NAMESPACE::VideoParams ¶ms,
|
||||
const OLIVE_NAMESPACE::RenderMode::Mode &mode);
|
||||
|
||||
private:
|
||||
QOpenGLContext* ctx_;
|
||||
|
||||
@@ -45,7 +45,7 @@ bool OpenGLTexture::IsCreated() const
|
||||
return (texture_);
|
||||
}
|
||||
|
||||
void OpenGLTexture::Create(QOpenGLContext *ctx, const VideoRenderingParams ¶ms, const void* data, int linesize)
|
||||
void OpenGLTexture::Create(QOpenGLContext *ctx, const VideoParams ¶ms, const void* data, int linesize)
|
||||
{
|
||||
if (!ctx) {
|
||||
qWarning() << "OpenGLTexture::Create was passed an invalid context";
|
||||
@@ -63,7 +63,7 @@ void OpenGLTexture::Create(QOpenGLContext *ctx, const VideoRenderingParams ¶
|
||||
CreateInternal(created_ctx_, &texture_, data, linesize);
|
||||
}
|
||||
|
||||
void OpenGLTexture::Create(QOpenGLContext *ctx, const VideoRenderingParams ¶ms)
|
||||
void OpenGLTexture::Create(QOpenGLContext *ctx, const VideoParams ¶ms)
|
||||
{
|
||||
Create(ctx, params, nullptr, 0);
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ public:
|
||||
|
||||
DISABLE_COPY_MOVE(OpenGLTexture)
|
||||
|
||||
void Create(QOpenGLContext* ctx, const VideoRenderingParams& params, const void *data, int linesize);
|
||||
void Create(QOpenGLContext* ctx, const VideoRenderingParams& params);
|
||||
void Create(QOpenGLContext* ctx, const VideoParams& params, const void *data, int linesize);
|
||||
void Create(QOpenGLContext* ctx, const VideoParams& params);
|
||||
void Create(QOpenGLContext* ctx, FramePtr frame);
|
||||
void Create(QOpenGLContext* ctx, Frame* frame);
|
||||
|
||||
@@ -76,7 +76,7 @@ private:
|
||||
|
||||
GLuint texture_;
|
||||
|
||||
VideoRenderingParams params_;
|
||||
VideoParams params_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ OpenGLTextureCache::ReferencePtr OpenGLTextureCache::Get(QOpenGLContext *ctx, Fr
|
||||
return Get(ctx, frame->video_params(), frame->data(), frame->linesize_pixels());
|
||||
}
|
||||
|
||||
OpenGLTextureCache::ReferencePtr OpenGLTextureCache::Get(QOpenGLContext* ctx, const VideoRenderingParams ¶ms, const void *data, int linesize)
|
||||
OpenGLTextureCache::ReferencePtr OpenGLTextureCache::Get(QOpenGLContext* ctx, const VideoParams ¶ms, const void *data, int linesize)
|
||||
{
|
||||
OpenGLTexturePtr texture = nullptr;
|
||||
|
||||
@@ -76,7 +76,7 @@ OpenGLTextureCache::ReferencePtr OpenGLTextureCache::Get(QOpenGLContext* ctx, co
|
||||
return ref;
|
||||
}
|
||||
|
||||
OpenGLTextureCache::ReferencePtr OpenGLTextureCache::Get(QOpenGLContext *ctx, const VideoRenderingParams ¶ms)
|
||||
OpenGLTextureCache::ReferencePtr OpenGLTextureCache::Get(QOpenGLContext *ctx, const VideoParams ¶ms)
|
||||
{
|
||||
return Get(ctx, params, nullptr, 0);
|
||||
}
|
||||
|
||||
@@ -59,8 +59,8 @@ public:
|
||||
|
||||
ReferencePtr Get(QOpenGLContext *ctx, FramePtr frame);
|
||||
ReferencePtr Get(QOpenGLContext *ctx, Frame* frame);
|
||||
ReferencePtr Get(QOpenGLContext *ctx, const VideoRenderingParams& params, const void *data, int linesize);
|
||||
ReferencePtr Get(QOpenGLContext *ctx, const VideoRenderingParams& params);
|
||||
ReferencePtr Get(QOpenGLContext *ctx, const VideoParams& params, const void *data, int linesize);
|
||||
ReferencePtr Get(QOpenGLContext *ctx, const VideoParams& params);
|
||||
|
||||
private:
|
||||
void Relinquish(Reference* ref);
|
||||
|
||||
@@ -42,7 +42,7 @@ NodeValue OpenGLWorker::FrameToTexture(DecoderPtr decoder, StreamPtr stream, con
|
||||
{
|
||||
FramePtr frame = decoder->RetrieveVideo(range.in(),
|
||||
video_params().divider(),
|
||||
video_params().mode() == RenderMode::kOffline);
|
||||
render_mode() == RenderMode::kOffline);
|
||||
|
||||
NodeValue value;
|
||||
|
||||
@@ -53,7 +53,8 @@ NodeValue OpenGLWorker::FrameToTexture(DecoderPtr decoder, StreamPtr stream, con
|
||||
OLIVE_NS_RETURN_ARG(NodeValue, value),
|
||||
OLIVE_NS_ARG(FramePtr, frame),
|
||||
OLIVE_NS_ARG(StreamPtr, stream),
|
||||
OLIVE_NS_CONST_ARG(VideoRenderingParams&, video_params()));
|
||||
OLIVE_NS_CONST_ARG(VideoParams&, video_params()),
|
||||
OLIVE_NS_CONST_ARG(RenderMode::Mode&, render_mode()));
|
||||
}
|
||||
|
||||
return value;
|
||||
@@ -71,7 +72,7 @@ void OpenGLWorker::ProcessNodeEvent(const Node *node, const TimeRange &range, No
|
||||
OLIVE_NS_CONST_ARG(TimeRange&, range),
|
||||
OLIVE_NS_ARG(NodeValueDatabase&, input_params),
|
||||
OLIVE_NS_ARG(NodeValueTable&, output_params),
|
||||
OLIVE_NS_CONST_ARG(VideoRenderingParams&, video_params()));
|
||||
OLIVE_NS_CONST_ARG(VideoParams&, video_params()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,8 @@ RenderBackend::RenderBackend(QObject *parent) :
|
||||
QObject(parent),
|
||||
viewer_node_(nullptr),
|
||||
update_with_graph_(false),
|
||||
preview_job_time_(0)
|
||||
preview_job_time_(0),
|
||||
render_mode_(RenderMode::kOnline)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -124,7 +125,7 @@ QFuture<QList<QByteArray> > RenderBackend::Hash(const QList<rational> ×)
|
||||
hasher.addData(reinterpret_cast<const char*>(&video_params_.effective_width()), sizeof(int));
|
||||
hasher.addData(reinterpret_cast<const char*>(&video_params_.effective_height()), sizeof(int));
|
||||
hasher.addData(reinterpret_cast<const char*>(&video_params_.format()), sizeof(PixelFormat::Format));
|
||||
hasher.addData(reinterpret_cast<const char*>(&video_params_.mode()), sizeof(RenderMode::Mode));
|
||||
hasher.addData(reinterpret_cast<const char*>(&render_mode_), sizeof(RenderMode::Mode));
|
||||
|
||||
copied_viewer_node_->Hash(hasher, t);
|
||||
|
||||
@@ -167,12 +168,12 @@ RenderTicketPtr RenderBackend::RenderAudio(const TimeRange &r)
|
||||
return ticket;
|
||||
}
|
||||
|
||||
void RenderBackend::SetVideoParams(const VideoRenderingParams ¶ms)
|
||||
void RenderBackend::SetVideoParams(const VideoParams ¶ms)
|
||||
{
|
||||
video_params_ = params;
|
||||
}
|
||||
|
||||
void RenderBackend::SetAudioParams(const AudioRenderingParams ¶ms)
|
||||
void RenderBackend::SetAudioParams(const AudioParams ¶ms)
|
||||
{
|
||||
audio_params_ = params;
|
||||
}
|
||||
@@ -297,6 +298,7 @@ void RenderBackend::RunNextJob()
|
||||
worker->SetVideoParams(video_params_);
|
||||
worker->SetAudioParams(audio_params_);
|
||||
worker->SetVideoDownloadMatrix(video_download_matrix_);
|
||||
worker->SetRenderMode(render_mode_);
|
||||
if (preview_job_time_) {
|
||||
worker->EnablePreviewGeneration(viewer_node_->audio_playback_cache(), preview_job_time_);
|
||||
}
|
||||
|
||||
@@ -50,6 +50,11 @@ public:
|
||||
update_with_graph_ = e;
|
||||
}
|
||||
|
||||
void SetRenderMode(RenderMode::Mode e)
|
||||
{
|
||||
render_mode_ = e;
|
||||
}
|
||||
|
||||
void EnablePreviewGeneration(qint64 job_time)
|
||||
{
|
||||
preview_job_time_ = job_time;
|
||||
@@ -72,9 +77,9 @@ public:
|
||||
*/
|
||||
RenderTicketPtr RenderAudio(const TimeRange& r);
|
||||
|
||||
void SetVideoParams(const VideoRenderingParams& params);
|
||||
void SetVideoParams(const VideoParams& params);
|
||||
|
||||
void SetAudioParams(const AudioRenderingParams& params);
|
||||
void SetAudioParams(const AudioParams& params);
|
||||
|
||||
void SetVideoDownloadMatrix(const QMatrix4x4& mat);
|
||||
|
||||
@@ -98,11 +103,11 @@ private:
|
||||
ViewerOutput* viewer_node_;
|
||||
|
||||
// VIDEO MEMBERS
|
||||
VideoRenderingParams video_params_;
|
||||
VideoParams video_params_;
|
||||
QMatrix4x4 video_download_matrix_;
|
||||
|
||||
// AUDIO MEMBERS
|
||||
AudioRenderingParams audio_params_;
|
||||
AudioParams audio_params_;
|
||||
|
||||
QList<NodeInput*> graph_update_queue_;
|
||||
QHash<Node*, Node*> copy_map_;
|
||||
@@ -123,6 +128,8 @@ private:
|
||||
|
||||
qint64 preview_job_time_;
|
||||
|
||||
RenderMode::Mode render_mode_;
|
||||
|
||||
private slots:
|
||||
void WorkerFinished();
|
||||
|
||||
|
||||
@@ -35,7 +35,8 @@ RenderWorker::RenderWorker(RenderBackend* parent) :
|
||||
parent_(parent),
|
||||
available_(true),
|
||||
audio_mode_is_preview_(false),
|
||||
preview_cache_(nullptr)
|
||||
preview_cache_(nullptr),
|
||||
render_mode_(RenderMode::kOnline)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -48,12 +48,12 @@ public:
|
||||
available_ = a;
|
||||
}
|
||||
|
||||
void SetVideoParams(const VideoRenderingParams& params)
|
||||
void SetVideoParams(const VideoParams& params)
|
||||
{
|
||||
video_params_ = params;
|
||||
}
|
||||
|
||||
void SetAudioParams(const AudioRenderingParams& params)
|
||||
void SetAudioParams(const AudioParams& params)
|
||||
{
|
||||
audio_params_ = params;
|
||||
}
|
||||
@@ -73,6 +73,11 @@ public:
|
||||
copy_map_ = copy_map;
|
||||
}
|
||||
|
||||
void SetRenderMode(const RenderMode::Mode& mode)
|
||||
{
|
||||
render_mode_ = mode;
|
||||
}
|
||||
|
||||
void EnablePreviewGeneration(AudioPlaybackCache* cache, qint64 job_time)
|
||||
{
|
||||
preview_cache_ = cache;
|
||||
@@ -117,19 +122,24 @@ protected:
|
||||
|
||||
virtual void ProcessNodeEvent(const Node *node, const TimeRange &range, NodeValueDatabase &input_params_in, NodeValueTable &output_params) override;
|
||||
|
||||
const VideoRenderingParams& video_params() const
|
||||
const VideoParams& video_params() const
|
||||
{
|
||||
return video_params_;
|
||||
}
|
||||
|
||||
const AudioRenderingParams& audio_params() const
|
||||
const AudioParams& audio_params() const
|
||||
{
|
||||
return audio_params_;
|
||||
}
|
||||
|
||||
const RenderMode::Mode& render_mode() const
|
||||
{
|
||||
return render_mode_;
|
||||
}
|
||||
|
||||
signals:
|
||||
void AudioConformUnavailable(StreamPtr stream, TimeRange range,
|
||||
rational stream_time, AudioRenderingParams params);
|
||||
rational stream_time, AudioParams params);
|
||||
|
||||
void FinishedJob();
|
||||
|
||||
@@ -142,9 +152,9 @@ private:
|
||||
|
||||
RenderBackend* parent_;
|
||||
|
||||
VideoRenderingParams video_params_;
|
||||
VideoParams video_params_;
|
||||
|
||||
AudioRenderingParams audio_params_;
|
||||
AudioParams audio_params_;
|
||||
|
||||
struct CachedStill {
|
||||
NodeValue texture;
|
||||
@@ -170,6 +180,8 @@ private:
|
||||
|
||||
QHash<Node*, Node*>* copy_map_;
|
||||
|
||||
RenderMode::Mode render_mode_;
|
||||
|
||||
};
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
@@ -190,7 +190,7 @@ QList<rational> FrameHashCache::GetInvalidatedFrames()
|
||||
|
||||
void FrameHashCache::SaveCacheFrame(const QByteArray& hash,
|
||||
char* data,
|
||||
const VideoRenderingParams& vparam)
|
||||
const VideoParams& vparam)
|
||||
{
|
||||
QString fn = CachePathName(hash, vparam.format());
|
||||
|
||||
@@ -286,7 +286,7 @@ QString FrameHashCache::CachePathName(const QByteArray& hash, const PixelFormat:
|
||||
return cache_dir.filePath(filename);
|
||||
}
|
||||
|
||||
bool FrameHashCache::SaveCacheFrame(const QString &filename, char *data, const VideoRenderingParams &vparam)
|
||||
bool FrameHashCache::SaveCacheFrame(const QString &filename, char *data, const VideoParams &vparam)
|
||||
{
|
||||
switch (vparam.format()) {
|
||||
case PixelFormat::PIX_FMT_RGB8:
|
||||
|
||||
@@ -60,8 +60,8 @@ public:
|
||||
*/
|
||||
static QString CachePathName(const QByteArray &hash, const PixelFormat::Format& pix_fmt);
|
||||
|
||||
static bool SaveCacheFrame(const QString& filename, char *data, const VideoRenderingParams &vparam);
|
||||
static void SaveCacheFrame(const QByteArray& hash, char *data, const VideoRenderingParams &vparam);
|
||||
static bool SaveCacheFrame(const QString& filename, char *data, const VideoParams &vparam);
|
||||
static void SaveCacheFrame(const QByteArray& hash, char *data, const VideoParams &vparam);
|
||||
static void SaveCacheFrame(const QByteArray& hash, FramePtr frame);
|
||||
|
||||
static QString GetFormatExtension(const PixelFormat::Format& f);
|
||||
|
||||
@@ -216,7 +216,7 @@ FramePtr PixelFormat::ConvertPixelFormat(FramePtr frame, const PixelFormat::Form
|
||||
|
||||
// Create a destination frame with the same parameters
|
||||
FramePtr converted = Frame::Create();
|
||||
converted->set_video_params(VideoRenderingParams(frame->video_params().width(),
|
||||
converted->set_video_params(VideoParams(frame->video_params().width(),
|
||||
frame->video_params().height(),
|
||||
dest_format));
|
||||
converted->set_timestamp(frame->timestamp());
|
||||
|
||||
+17
-81
@@ -20,120 +20,56 @@
|
||||
|
||||
#include "videoparams.h"
|
||||
|
||||
#include <QtMath>
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
VideoParams::VideoParams() :
|
||||
width_(0),
|
||||
height_(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
VideoParams::VideoParams(const int &width, const int &height, const rational &time_base) :
|
||||
width_(width),
|
||||
height_(height),
|
||||
time_base_(time_base)
|
||||
{
|
||||
}
|
||||
|
||||
const int &VideoParams::width() const
|
||||
{
|
||||
return width_;
|
||||
}
|
||||
|
||||
const int &VideoParams::height() const
|
||||
{
|
||||
return height_;
|
||||
}
|
||||
|
||||
const rational &VideoParams::time_base() const
|
||||
{
|
||||
return time_base_;
|
||||
}
|
||||
|
||||
VideoRenderingParams::VideoRenderingParams() :
|
||||
format_(PixelFormat::PIX_FMT_INVALID)
|
||||
{
|
||||
}
|
||||
|
||||
VideoRenderingParams::VideoRenderingParams(const int &width, const int &height, const PixelFormat::Format &format, const int& divider) :
|
||||
VideoParams(width, height, rational()),
|
||||
VideoParams::VideoParams(const int &width, const int &height, const PixelFormat::Format &format, const int& divider) :
|
||||
width_(width),
|
||||
height_(height),
|
||||
format_(format),
|
||||
divider_(divider)
|
||||
{
|
||||
calculate_effective_size();
|
||||
}
|
||||
|
||||
VideoRenderingParams::VideoRenderingParams(const int &width, const int &height, const rational &time_base, const PixelFormat::Format &format, const RenderMode::Mode& mode, const int ÷r) :
|
||||
VideoParams(width, height, time_base),
|
||||
VideoParams::VideoParams(const int &width, const int &height, const rational &time_base, const PixelFormat::Format &format, const int ÷r) :
|
||||
width_(width),
|
||||
height_(height),
|
||||
time_base_(time_base),
|
||||
format_(format),
|
||||
mode_(mode),
|
||||
divider_(divider)
|
||||
{
|
||||
calculate_effective_size();
|
||||
}
|
||||
|
||||
VideoRenderingParams::VideoRenderingParams(const VideoParams ¶ms, const PixelFormat::Format &format, const RenderMode::Mode& mode, const int& divider) :
|
||||
VideoParams(params),
|
||||
format_(format),
|
||||
mode_(mode),
|
||||
divider_(divider)
|
||||
{
|
||||
calculate_effective_size();
|
||||
}
|
||||
|
||||
const int &VideoRenderingParams::divider() const
|
||||
{
|
||||
return divider_;
|
||||
}
|
||||
|
||||
const int& VideoRenderingParams::effective_width() const
|
||||
{
|
||||
return effective_width_;
|
||||
}
|
||||
|
||||
const int& VideoRenderingParams::effective_height() const
|
||||
{
|
||||
return effective_height_;
|
||||
}
|
||||
|
||||
const PixelFormat::Format &VideoRenderingParams::format() const
|
||||
{
|
||||
return format_;
|
||||
}
|
||||
|
||||
const RenderMode::Mode &VideoRenderingParams::mode() const
|
||||
{
|
||||
return mode_;
|
||||
}
|
||||
|
||||
bool VideoRenderingParams::operator==(const VideoRenderingParams &rhs) const
|
||||
bool VideoParams::operator==(const VideoParams &rhs) const
|
||||
{
|
||||
return width() == rhs.width()
|
||||
&& height() == rhs.height()
|
||||
&& time_base() == rhs.time_base()
|
||||
&& format() == rhs.format()
|
||||
&& mode() == rhs.mode()
|
||||
&& divider() == rhs.divider();
|
||||
}
|
||||
|
||||
bool VideoRenderingParams::operator!=(const VideoRenderingParams &rhs) const
|
||||
bool VideoParams::operator!=(const VideoParams &rhs) const
|
||||
{
|
||||
return width() != rhs.width()
|
||||
|| height() != rhs.height()
|
||||
|| time_base() != rhs.time_base()
|
||||
|| format() != rhs.format()
|
||||
|| mode() != rhs.mode()
|
||||
|| divider() != rhs.divider();
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
void VideoRenderingParams::calculate_effective_size()
|
||||
void VideoParams::calculate_effective_size()
|
||||
{
|
||||
effective_width_ = width() / divider_;
|
||||
effective_height_ = height() / divider_;
|
||||
// Fast rounding up to an even number
|
||||
effective_width_ = qCeil(width() / divider_ * 0.5) * 2;
|
||||
effective_height_ = qCeil(height() / divider_ * 0.5) * 2;
|
||||
}
|
||||
|
||||
bool VideoRenderingParams::is_valid() const
|
||||
bool VideoParams::is_valid() const
|
||||
{
|
||||
return (width() > 0
|
||||
&& height() > 0
|
||||
|
||||
+39
-25
@@ -27,46 +27,60 @@
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
class VideoParams
|
||||
{
|
||||
class VideoParams {
|
||||
public:
|
||||
VideoParams();
|
||||
VideoParams(const int& width, const int& height, const rational& time_base);
|
||||
VideoParams(const int& width, const int& height, const PixelFormat::Format& format, const int& divider = 1);
|
||||
VideoParams(const int& width, const int& height, const rational& time_base, const PixelFormat::Format& format, const int& divider = 1);
|
||||
|
||||
const int& width() const;
|
||||
const int& height() const;
|
||||
const rational& time_base() const;
|
||||
const int& width() const
|
||||
{
|
||||
return width_;
|
||||
}
|
||||
|
||||
private:
|
||||
int width_;
|
||||
int height_;
|
||||
rational time_base_;
|
||||
const int& height() const
|
||||
{
|
||||
return height_;
|
||||
}
|
||||
|
||||
};
|
||||
const rational& time_base() const
|
||||
{
|
||||
return time_base_;
|
||||
}
|
||||
|
||||
class VideoRenderingParams : public VideoParams {
|
||||
public:
|
||||
VideoRenderingParams();
|
||||
VideoRenderingParams(const int& width, const int& height, const PixelFormat::Format& format, const int& divider = 1);
|
||||
VideoRenderingParams(const int& width, const int& height, const rational& time_base, const PixelFormat::Format& format, const RenderMode::Mode& mode, const int& divider = 1);
|
||||
VideoRenderingParams(const VideoParams& params, const PixelFormat::Format& format, const RenderMode::Mode& mode, const int& divider = 1);
|
||||
const int& divider() const
|
||||
{
|
||||
return divider_;
|
||||
}
|
||||
|
||||
const int& divider() const;
|
||||
const int& effective_width() const;
|
||||
const int& effective_height() const;
|
||||
const int& effective_width() const
|
||||
{
|
||||
return effective_width_;
|
||||
}
|
||||
|
||||
const int& effective_height() const
|
||||
{
|
||||
return effective_height_;
|
||||
}
|
||||
|
||||
const PixelFormat::Format& format() const
|
||||
{
|
||||
return format_;
|
||||
}
|
||||
|
||||
bool is_valid() const;
|
||||
const PixelFormat::Format& format() const;
|
||||
const RenderMode::Mode& mode() const;
|
||||
|
||||
bool operator==(const VideoRenderingParams& rhs) const;
|
||||
bool operator!=(const VideoRenderingParams& rhs) const;
|
||||
bool operator==(const VideoParams& rhs) const;
|
||||
bool operator!=(const VideoParams& rhs) const;
|
||||
|
||||
private:
|
||||
void calculate_effective_size();
|
||||
|
||||
int width_;
|
||||
int height_;
|
||||
rational time_base_;
|
||||
|
||||
PixelFormat::Format format_;
|
||||
RenderMode::Mode mode_;
|
||||
|
||||
int divider_;
|
||||
int effective_width_;
|
||||
|
||||
Reference in New Issue
Block a user