implemented audio decoder and some of the audio node functionality
This commit is contained in:
+1
-19
@@ -58,25 +58,7 @@ public:
|
||||
// Necessary for subclassing, it's empty
|
||||
virtual ~Decoder();
|
||||
|
||||
/**
|
||||
* @brief Deleted copy constructor
|
||||
*/
|
||||
Decoder(const Decoder& other) = delete;
|
||||
|
||||
/**
|
||||
* @brief Deleted move constructor
|
||||
*/
|
||||
Decoder(Decoder&& other) = delete;
|
||||
|
||||
/**
|
||||
* @brief Deleted copy assignment
|
||||
*/
|
||||
Decoder& operator=(const Decoder& other) = delete;
|
||||
|
||||
/**
|
||||
* @brief Deleted move assignment
|
||||
*/
|
||||
Decoder& operator=(Decoder&& other) = delete;
|
||||
Q_DISABLE_COPY_MOVE(Decoder)
|
||||
|
||||
virtual QString id() = 0;
|
||||
|
||||
|
||||
@@ -249,7 +249,7 @@ FramePtr FFmpegDecoder::Retrieve(const rational &timecode, const rational &lengt
|
||||
FramePtr frame_container = Frame::Create();
|
||||
frame_container->set_width(frame_->width);
|
||||
frame_container->set_height(frame_->height);
|
||||
frame_container->set_format(output_fmt_);
|
||||
frame_container->set_format(static_cast<olive::PixelFormat>(output_fmt_));
|
||||
frame_container->set_timestamp(rational(frame_->pts * avstream_->time_base.num, avstream_->time_base.den));
|
||||
frame_container->set_native_timestamp(frame_->pts);
|
||||
frame_container->allocate();
|
||||
|
||||
+26
-5
@@ -28,7 +28,8 @@
|
||||
Frame::Frame() :
|
||||
width_(0),
|
||||
height_(0),
|
||||
format_(-1),
|
||||
format_(olive::PIX_FMT_INVALID),
|
||||
sample_count_(0),
|
||||
timestamp_(0),
|
||||
native_timestamp_(0)
|
||||
{
|
||||
@@ -59,6 +60,16 @@ void Frame::set_height(const int &height)
|
||||
height_ = height;
|
||||
}
|
||||
|
||||
const AudioRenderingParams &Frame::audio_params()
|
||||
{
|
||||
return audio_params_;
|
||||
}
|
||||
|
||||
void Frame::set_audio_params(const AudioRenderingParams ¶ms)
|
||||
{
|
||||
audio_params_ = params;
|
||||
}
|
||||
|
||||
const rational &Frame::timestamp()
|
||||
{
|
||||
return timestamp_;
|
||||
@@ -79,16 +90,26 @@ void Frame::set_native_timestamp(const int64_t ×tamp)
|
||||
native_timestamp_ = timestamp;
|
||||
}
|
||||
|
||||
const int &Frame::format()
|
||||
const olive::PixelFormat &Frame::format()
|
||||
{
|
||||
return format_;
|
||||
}
|
||||
|
||||
void Frame::set_format(const int &format)
|
||||
void Frame::set_format(const olive::PixelFormat &format)
|
||||
{
|
||||
format_ = format;
|
||||
}
|
||||
|
||||
const int &Frame::sample_count()
|
||||
{
|
||||
return sample_count_;
|
||||
}
|
||||
|
||||
void Frame::set_sample_count(const int &audio_sample_count)
|
||||
{
|
||||
sample_count_ = audio_sample_count;
|
||||
}
|
||||
|
||||
uint8_t *Frame::data()
|
||||
{
|
||||
return data_.data();
|
||||
@@ -104,9 +125,9 @@ void Frame::allocate()
|
||||
// Assume this frame is intended to be a video frame
|
||||
if (width_ > 0 && height_ > 0) {
|
||||
data_.resize(PixelService::GetBufferSize(static_cast<olive::PixelFormat>(format_), width_, height_));
|
||||
} else if (sample_count_ > 0) {
|
||||
data_.resize(audio_params_.samples_to_bytes(sample_count_));
|
||||
}
|
||||
|
||||
// FIXME: Audio sample allocation
|
||||
}
|
||||
|
||||
void Frame::destroy()
|
||||
|
||||
+14
-3
@@ -25,6 +25,7 @@
|
||||
#include <QVector>
|
||||
|
||||
#include "common/rational.h"
|
||||
#include "render/audio/audioparams.h"
|
||||
#include "render/pixelformat.h"
|
||||
|
||||
class Frame;
|
||||
@@ -57,6 +58,12 @@ public:
|
||||
const int& height();
|
||||
void set_height(const int& height);
|
||||
|
||||
const AudioRenderingParams& audio_params();
|
||||
void set_audio_params(const AudioRenderingParams& params);
|
||||
|
||||
const int &sample_count();
|
||||
void set_sample_count(const int &sample_count);
|
||||
|
||||
/**
|
||||
* @brief Get frame's timestamp.
|
||||
*
|
||||
@@ -75,8 +82,8 @@ public:
|
||||
*
|
||||
* Currently this will either be an olive::PixelFormat (video) or an olive::SampleFormat (audio).
|
||||
*/
|
||||
const int& format();
|
||||
void set_format(const int& format);
|
||||
const olive::PixelFormat& format();
|
||||
void set_format(const olive::PixelFormat& format);
|
||||
|
||||
/**
|
||||
* @brief Get the data buffer of this frame
|
||||
@@ -107,7 +114,11 @@ private:
|
||||
|
||||
int height_;
|
||||
|
||||
int format_;
|
||||
olive::PixelFormat format_;
|
||||
|
||||
AudioRenderingParams audio_params_;
|
||||
|
||||
int sample_count_;
|
||||
|
||||
QVector<uint8_t> data_;
|
||||
|
||||
|
||||
@@ -61,12 +61,12 @@ bool WaveOutput::open()
|
||||
write_int<int32_t>(&file_, params_.sample_rate());
|
||||
|
||||
// Bytes per second
|
||||
write_int<int32_t>(&file_, (params_.sample_rate() * params_.bits_per_sample() * params_.channel_count())/8);
|
||||
write_int<int32_t>(&file_, params_.samples_to_bytes(params_.sample_rate()));
|
||||
|
||||
// Bytes per sample
|
||||
write_int<int16_t>(&file_, static_cast<int16_t>((params_.bits_per_sample() * params_.channel_count())/8));
|
||||
write_int<int16_t>(&file_, static_cast<int16_t>(params_.samples_to_bytes(1)));
|
||||
|
||||
// Bits per sample
|
||||
// Bits per sample per channel
|
||||
write_int<int16_t>(&file_, static_cast<int16_t>(params_.bits_per_sample()));
|
||||
|
||||
// Data chunk header
|
||||
|
||||
Reference in New Issue
Block a user