implemented audio decoder and some of the audio node functionality
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
|
||||
AudioInput::AudioInput()
|
||||
{
|
||||
|
||||
samples_output_ = new NodeOutput("samples_out");
|
||||
samples_output_->set_data_type(NodeInput::kSamples);
|
||||
AddParameter(samples_output_);
|
||||
}
|
||||
|
||||
QString AudioInput::Name()
|
||||
@@ -24,3 +26,23 @@ QString AudioInput::Description()
|
||||
{
|
||||
return tr("Import an audio footage stream.");
|
||||
}
|
||||
|
||||
QVariant AudioInput::Value(NodeOutput *output, const rational &in, const rational &out)
|
||||
{
|
||||
if (output == samples_output_) {
|
||||
// Make sure decoder is set up
|
||||
if (!SetupDecoder()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Retrieve audio samples from decoder
|
||||
frame_ = decoder_->Retrieve(in, out - in);
|
||||
|
||||
QByteArray samples;
|
||||
samples.resize(frame_->audio_params().samples_to_bytes(frame_->sample_count()));
|
||||
memcpy(samples.data(), frame_->data(), static_cast<size_t>(samples.size()));
|
||||
return samples;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,12 @@ public:
|
||||
virtual QString id() override;
|
||||
virtual QString Category() override;
|
||||
virtual QString Description() override;
|
||||
|
||||
protected:
|
||||
virtual QVariant Value(NodeOutput* output, const rational& in, const rational& out) override;
|
||||
|
||||
private:
|
||||
NodeOutput* samples_output_;
|
||||
};
|
||||
|
||||
#endif // AUDIOINPUT_H
|
||||
|
||||
@@ -35,7 +35,7 @@ void MediaInput::Release()
|
||||
decoder_ = nullptr;
|
||||
}
|
||||
|
||||
StreamPtr MediaInput::Footage()
|
||||
StreamPtr MediaInput::footage()
|
||||
{
|
||||
return footage_input_->get_value(0).value<StreamPtr>();
|
||||
}
|
||||
@@ -52,7 +52,7 @@ bool MediaInput::SetupDecoder()
|
||||
}
|
||||
|
||||
// Get currently selected Footage
|
||||
StreamPtr stream = Footage();
|
||||
StreamPtr stream = footage();
|
||||
|
||||
// If no footage is selected, return nothing
|
||||
if (stream == nullptr) {
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
|
||||
virtual void Release() override;
|
||||
|
||||
StreamPtr Footage();
|
||||
StreamPtr footage();
|
||||
void SetFootage(StreamPtr f);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -96,10 +96,15 @@ QVariant VideoInput::Value(NodeOutput *output, const rational &in, const rationa
|
||||
{
|
||||
Q_UNUSED(out)
|
||||
|
||||
// FIXME: Hardcoded value
|
||||
bool alpha_is_associated = false;
|
||||
|
||||
if (output == texture_output_) {
|
||||
if (footage() == nullptr
|
||||
|| (footage()->type() != Stream::kVideo && footage()->type() != Stream::kImage)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// FIXME: Hardcoded value
|
||||
bool alpha_is_associated = false;
|
||||
|
||||
// Find the current Renderer instance
|
||||
RenderInstance* renderer = VideoRendererProcessor::CurrentInstance();
|
||||
|
||||
@@ -124,7 +129,7 @@ QVariant VideoInput::Value(NodeOutput *output, const rational &in, const rationa
|
||||
}
|
||||
|
||||
if (color_processor_ == nullptr) {
|
||||
QString colorspace = std::static_pointer_cast<VideoStream>(Footage())->colorspace();
|
||||
QString colorspace = std::static_pointer_cast<VideoStream>(footage())->colorspace();
|
||||
if (colorspace.isEmpty()) {
|
||||
// FIXME: Should use Footage() to find the Project* it belongs to instead of this
|
||||
colorspace = olive::core.GetActiveProject()->default_input_colorspace();
|
||||
|
||||
Reference in New Issue
Block a user