moved sequence params into node graph too
Reduces code by reusing more of the existing node infrastructure to synchronize sequence parameters the render backend.
This commit is contained in:
@@ -235,11 +235,6 @@ int64_t Decoder::GetTimeInTimebaseUnits(const rational &time, const rational &ti
|
||||
return Timecode::time_to_timestamp(time, timebase) + start_time;
|
||||
}
|
||||
|
||||
Decoder::CodecStream Decoder::GetCodecStreamFromStreamReference(const Footage::StreamReference &ref)
|
||||
{
|
||||
return CodecStream(ref.footage()->filename(), ref.footage()->GetRealStreamIndex(ref));
|
||||
}
|
||||
|
||||
void Decoder::SignalProcessingProgress(int64_t ts, int64_t duration)
|
||||
{
|
||||
if (duration != AV_NOPTS_VALUE && duration != 0) {
|
||||
|
||||
+3
-4
@@ -36,6 +36,7 @@ extern "C" {
|
||||
#include "codec/waveoutput.h"
|
||||
#include "common/rational.h"
|
||||
#include "project/item/footage/footage.h"
|
||||
#include "project/item/footage/footagedescription.h"
|
||||
#include "project/item/footage/stream.h"
|
||||
|
||||
namespace olive {
|
||||
@@ -74,7 +75,7 @@ public:
|
||||
/**
|
||||
* @brief Unique decoder ID
|
||||
*/
|
||||
virtual QString id() = 0;
|
||||
virtual QString id() const = 0;
|
||||
|
||||
virtual bool SupportsVideo(){return false;}
|
||||
virtual bool SupportsAudio(){return false;}
|
||||
@@ -176,7 +177,7 @@ public:
|
||||
*
|
||||
* This function is re-entrant.
|
||||
*/
|
||||
virtual Streams Probe(const QString& filename, const QAtomicInt* cancelled) const = 0;
|
||||
virtual FootageDescription Probe(const QString& filename, const QAtomicInt* cancelled) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Closes media/deallocates memory
|
||||
@@ -202,8 +203,6 @@ public:
|
||||
|
||||
static QVector<DecoderPtr> ReceiveListOfAllDecoders();
|
||||
|
||||
static CodecStream GetCodecStreamFromStreamReference(const Footage::StreamReference& ref);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Internal open function
|
||||
|
||||
@@ -202,15 +202,15 @@ void FFmpegDecoder::CloseInternal()
|
||||
FreeScaler();
|
||||
}
|
||||
|
||||
QString FFmpegDecoder::id()
|
||||
QString FFmpegDecoder::id() const
|
||||
{
|
||||
return QStringLiteral("ffmpeg");
|
||||
}
|
||||
|
||||
Streams FFmpegDecoder::Probe(const QString &filename, const QAtomicInt *cancelled) const
|
||||
FootageDescription FFmpegDecoder::Probe(const QString &filename, const QAtomicInt *cancelled) const
|
||||
{
|
||||
// Return value
|
||||
Streams streams;
|
||||
FootageDescription desc(id());
|
||||
|
||||
// Variable for receiving errors from FFmpeg
|
||||
int error_code;
|
||||
@@ -236,9 +236,6 @@ Streams FFmpegDecoder::Probe(const QString &filename, const QAtomicInt *cancelle
|
||||
// FFmpeg AVStream
|
||||
AVStream* avstream = fmt_ctx->streams[i];
|
||||
|
||||
// Our native stream class
|
||||
Stream stream;
|
||||
|
||||
// Find decoder for this stream, if it exists we can proceed
|
||||
AVCodec* decoder = avcodec_find_decoder(avstream->codecpar->codec_id);
|
||||
|
||||
@@ -320,20 +317,25 @@ Streams FFmpegDecoder::Probe(const QString &filename, const QAtomicInt *cancelle
|
||||
|
||||
AVPixelFormat compatible_pix_fmt = FFmpegUtils::GetCompatiblePixelFormat(static_cast<AVPixelFormat>(avstream->codecpar->format));
|
||||
|
||||
stream = Stream(Stream::kVideo);
|
||||
VideoParams stream;
|
||||
stream.set_stream_index(i);
|
||||
stream.set_width(avstream->codecpar->width);
|
||||
stream.set_height(avstream->codecpar->height);
|
||||
stream.set_video_type((image_is_still) ? Stream::kVideoTypeStill : Stream::kVideoTypeVideo);
|
||||
stream.set_pixel_format(GetNativePixelFormat(compatible_pix_fmt));
|
||||
stream.set_video_type((image_is_still) ? VideoParams::kVideoTypeStill : VideoParams::kVideoTypeVideo);
|
||||
stream.set_format(GetNativePixelFormat(compatible_pix_fmt));
|
||||
stream.set_channel_count(GetNativeChannelCount(compatible_pix_fmt));
|
||||
stream.set_interlacing(interlacing);
|
||||
stream.set_pixel_aspect_ratio(pixel_aspect_ratio);
|
||||
stream.set_frame_rate(frame_rate);
|
||||
stream.set_start_time(avstream->start_time);
|
||||
stream.set_time_base(avstream->time_base);
|
||||
stream.set_duration(avstream->duration);
|
||||
|
||||
// Defaults to false, requires user intervention if incorrect
|
||||
stream.set_premultiplied_alpha(false);
|
||||
|
||||
desc.AddVideoStream(stream);
|
||||
|
||||
} else {
|
||||
|
||||
// Create an audio stream object
|
||||
@@ -370,45 +372,19 @@ Streams FFmpegDecoder::Probe(const QString &filename, const QAtomicInt *cancelle
|
||||
}
|
||||
}
|
||||
|
||||
stream = Stream(Stream::kAudio);
|
||||
AudioParams stream;
|
||||
stream.set_stream_index(i);
|
||||
stream.set_channel_layout(channel_layout);
|
||||
stream.set_channel_count(avstream->codecpar->channels);
|
||||
stream.set_sample_rate(avstream->codecpar->sample_rate);
|
||||
stream.set_format(AudioParams::kInternalFormat);
|
||||
stream.set_time_base(avstream->time_base);
|
||||
stream.set_duration(avstream->duration);
|
||||
desc.AddAudioStream(stream);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// This is data we can't utilize at the moment, but we make a Stream object anyway to keep parity with the file
|
||||
Stream::Type type;
|
||||
|
||||
// Set the correct codec type based on FFmpeg's result
|
||||
switch (avstream->codecpar->codec_type) {
|
||||
case AVMEDIA_TYPE_DATA:
|
||||
type = Stream::kData;
|
||||
break;
|
||||
case AVMEDIA_TYPE_SUBTITLE:
|
||||
type = Stream::kSubtitle;
|
||||
break;
|
||||
case AVMEDIA_TYPE_ATTACHMENT:
|
||||
type = Stream::kAttachment;
|
||||
break;
|
||||
case AVMEDIA_TYPE_UNKNOWN:
|
||||
default:
|
||||
// Fallback to an unknown stream
|
||||
type = Stream::kUnknown;
|
||||
break;
|
||||
}
|
||||
|
||||
stream = Stream(type);
|
||||
|
||||
}
|
||||
|
||||
stream.set_timebase(avstream->time_base);
|
||||
stream.set_duration(avstream->duration);
|
||||
|
||||
streams.append(stream);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -416,7 +392,7 @@ Streams FFmpegDecoder::Probe(const QString &filename, const QAtomicInt *cancelle
|
||||
// Free all memory
|
||||
avformat_close_input(&fmt_ctx);
|
||||
|
||||
return streams;
|
||||
return desc;
|
||||
}
|
||||
|
||||
QString FFmpegDecoder::FFmpegError(int error_code)
|
||||
|
||||
@@ -51,12 +51,12 @@ public:
|
||||
// Destructor
|
||||
virtual ~FFmpegDecoder() override;
|
||||
|
||||
virtual QString id() override;
|
||||
virtual QString id() const override;
|
||||
|
||||
virtual bool SupportsVideo() override{return true;}
|
||||
virtual bool SupportsAudio() override{return true;}
|
||||
|
||||
virtual Streams Probe(const QString &filename, const QAtomicInt *cancelled) const override;
|
||||
virtual FootageDescription Probe(const QString &filename, const QAtomicInt *cancelled) const override;
|
||||
|
||||
protected:
|
||||
virtual bool OpenInternal() override;
|
||||
|
||||
@@ -46,21 +46,21 @@ OIIODecoder::~OIIODecoder()
|
||||
CloseInternal();
|
||||
}
|
||||
|
||||
QString OIIODecoder::id()
|
||||
QString OIIODecoder::id() const
|
||||
{
|
||||
return QStringLiteral("oiio");
|
||||
}
|
||||
|
||||
Streams OIIODecoder::Probe(const QString &filename, const QAtomicInt* cancelled) const
|
||||
FootageDescription OIIODecoder::Probe(const QString &filename, const QAtomicInt* cancelled) const
|
||||
{
|
||||
Q_UNUSED(cancelled)
|
||||
|
||||
Streams streams;
|
||||
FootageDescription desc(id());
|
||||
|
||||
// Filter out any file extensions that aren't expected to work - sometimes OIIO will crash trying
|
||||
// to open a file that it can't if it's given one
|
||||
if (!FileTypeIsSupported(filename)) {
|
||||
return streams;
|
||||
return desc;
|
||||
}
|
||||
|
||||
std::string std_filename = filename.toStdString();
|
||||
@@ -68,35 +68,36 @@ Streams OIIODecoder::Probe(const QString &filename, const QAtomicInt* cancelled)
|
||||
auto in = OIIO::ImageInput::open(std_filename);
|
||||
|
||||
if (!in) {
|
||||
return streams;
|
||||
return desc;
|
||||
}
|
||||
|
||||
// Filter out OIIO detecting an "FFmpeg movie", we have a native FFmpeg decoder that can handle
|
||||
// it better
|
||||
if (!strcmp(in->format_name(), "FFmpeg movie")) {
|
||||
return streams;
|
||||
return desc;
|
||||
}
|
||||
|
||||
Stream stream(Stream::kVideo);
|
||||
VideoParams video_params;
|
||||
|
||||
stream.set_width(in->spec().width);
|
||||
stream.set_height(in->spec().height);
|
||||
stream.set_pixel_format(OIIOUtils::GetFormatFromOIIOBasetype(static_cast<OIIO::TypeDesc::BASETYPE>(in->spec().format.basetype)));
|
||||
stream.set_channel_count(in->spec().nchannels);
|
||||
stream.set_pixel_aspect_ratio(OIIOUtils::GetPixelAspectRatioFromOIIO(in->spec()));
|
||||
stream.set_video_type(Stream::kVideoTypeStill);
|
||||
video_params.set_stream_index(0);
|
||||
video_params.set_width(in->spec().width);
|
||||
video_params.set_height(in->spec().height);
|
||||
video_params.set_format(OIIOUtils::GetFormatFromOIIOBasetype(static_cast<OIIO::TypeDesc::BASETYPE>(in->spec().format.basetype)));
|
||||
video_params.set_channel_count(in->spec().nchannels);
|
||||
video_params.set_pixel_aspect_ratio(OIIOUtils::GetPixelAspectRatioFromOIIO(in->spec()));
|
||||
video_params.set_video_type(VideoParams::kVideoTypeStill);
|
||||
|
||||
// OIIO automatically premultiplies alpha
|
||||
// FIXME: We usually disassociate the alpha for the color management later, for 8-bit images this
|
||||
// likely reduces the fidelity?
|
||||
stream.set_premultiplied_alpha(true);
|
||||
video_params.set_premultiplied_alpha(true);
|
||||
|
||||
streams.append(stream);
|
||||
desc.AddVideoStream(video_params);
|
||||
|
||||
// If we're here, we have a successful image open
|
||||
in->close();
|
||||
|
||||
return streams;
|
||||
return desc;
|
||||
}
|
||||
|
||||
bool OIIODecoder::OpenInternal()
|
||||
|
||||
@@ -36,11 +36,11 @@ public:
|
||||
|
||||
virtual ~OIIODecoder() override;
|
||||
|
||||
virtual QString id() override;
|
||||
virtual QString id() const override;
|
||||
|
||||
virtual bool SupportsVideo() override{return true;}
|
||||
|
||||
virtual Streams Probe(const QString& filename, const QAtomicInt* cancelled) const override;
|
||||
virtual FootageDescription Probe(const QString& filename, const QAtomicInt* cancelled) const override;
|
||||
|
||||
protected:
|
||||
virtual bool OpenInternal() override;
|
||||
|
||||
Reference in New Issue
Block a user