finished merging earlier decoder code

This commit is contained in:
itsmattkc
2019-06-26 22:52:44 -07:00
parent f47de0be0d
commit d133ee9832
11 changed files with 570 additions and 1 deletions
+94
View File
@@ -0,0 +1,94 @@
#include "frame.h"
#include <QtGlobal>
Frame::Frame() :
frame_(nullptr)
{
}
Frame::Frame(AVFrame *f) :
frame_(f)
{
}
Frame::Frame(const Frame &f) :
frame_(nullptr)
{
Q_UNUSED(f)
}
Frame::Frame(Frame &&f) :
frame_(f.frame_)
{
f.frame_ = nullptr;
}
Frame &Frame::operator=(const Frame &f)
{
Q_UNUSED(f)
frame_ = nullptr;
return *this;
}
Frame &Frame::operator=(Frame &&f)
{
if (&f != this) {
frame_ = f.frame_;
f.frame_ = nullptr;
}
return *this;
}
Frame::~Frame()
{
FreeChild();
}
void Frame::SetAVFrame(AVFrame *f, AVRational timebase)
{
FreeChild();
f = frame_;
timestamp_ = rational(timebase.num*f->pts, timebase.den);
}
const int &Frame::width()
{
return frame_->width;
}
const int &Frame::height()
{
return frame_->height;
}
const rational &Frame::timestamp()
{
return timestamp_;
}
const int &Frame::format()
{
return frame_->format;
}
uint8_t **Frame::data()
{
return frame_->data;
}
int *Frame::linesize()
{
return frame_->linesize;
}
void Frame::FreeChild()
{
if (frame_ != nullptr) {
av_frame_free(&frame_);
frame_ = nullptr;
}
}