Commit f70dcc9a authored by Vincent Carrubba's avatar Vincent Carrubba
Browse files

Intermediate commit (another one...) to save my work on.Current state:...

Intermediate commit (another one...) to save my work on.Current state: integration of New LightVideoFrame in progress
parent efb06886
#include "LightVideoFrame.h"
VideoFrame::~VideoFrame()
{
if ( frame.octets != NULL )
delete [] frame.octets;
};
VideoFrame::VideoFrame()
{
frame.octets = NULL;
nboctets = 0;
nbpixels = 0;
}
VideoFrame::VideoFrame(VideoFrame const & tocopy) : QSharedData( tocopy )
{
if ( tocopy.frame.octets != NULL )
{
quint32 i;
nboctets = tocopy.nboctets;
nbpixels = tocopy.nboctets / Pixel::NbComposantes;
frame.octets = new quint8[tocopy.nboctets];
for ( i = 0; i < nboctets; ++i )
frame.octets[i] = tocopy.frame.octets[i];
}
else
{
nboctets = 0;
nbpixels = 0;
frame.octets = NULL;
}
}
//
//
//
//
//
LightVideoFrame::LightVideoFrame()
{
m_videoFrame = new VideoFrame;
};
LightVideoFrame::LightVideoFrame(LightVideoFrame const & tocopy) : m_videoFrame(tocopy.m_videoFrame)
{
};
LightVideoFrame& LightVideoFrame::operator=(LightVideoFrame const & tocopy)
{
if ( m_videoFrame->frame.octets == NULL )
{
if ( tocopy.m_videoFrame->frame.octets != NULL )
{
m_videoFrame->frame.octets = new quint8[tocopy.m_videoFrame->nboctets];
m_videoFrame->nboctets = tocopy.m_videoFrame->nboctets;
m_videoFrame->nbpixels = tocopy.m_videoFrame->nboctets / Pixel::NbComposantes;
quint32 i;
for ( i = 0; i < m_videoFrame->nboctets; ++i )
m_videoFrame->frame.octets[i] = tocopy.m_videoFrame->frame.octets[i];
}
}
else
{
if ( tocopy.m_videoFrame->frame.octets != NULL )
{
if ( m_videoFrame->nboctets != tocopy.m_videoFrame->nboctets )
{
qDebug() << __LINE__ << "\n"
<< "this pixels = " << m_videoFrame->nbpixels
<< "tocopy.m_videoFrame pixels = " << tocopy.m_videoFrame->nbpixels;
delete [] m_videoFrame->frame.octets;
m_videoFrame->frame.octets = new quint8[tocopy.m_videoFrame->nboctets];
m_videoFrame->nboctets = tocopy.m_videoFrame->nboctets;
m_videoFrame->nbpixels = tocopy.m_videoFrame->nboctets / Pixel::NbComposantes;
}
quint32 i;
for ( i = 0; i < m_videoFrame->nboctets; ++i )
m_videoFrame->frame.octets[i] = tocopy.m_videoFrame->frame.octets[i];
}
else
{
delete [] m_videoFrame->frame.octets;
m_videoFrame->frame.octets = NULL;
m_videoFrame->nboctets = 0;
m_videoFrame->nbpixels = 0;
}
}
return ( *this );
};
LightVideoFrame::LightVideoFrame(quint32 nboctets)
{
m_videoFrame = new VideoFrame;
m_videoFrame->nboctets = nboctets;
m_videoFrame->nbpixels = nboctets / Pixel::NbComposantes;
m_videoFrame->frame.octets = new quint8[nboctets];
};
LightVideoFrame::LightVideoFrame(quint8 const * tocopy, quint32 nboctets)
{
quint32 i;
m_videoFrame = new VideoFrame;
m_videoFrame->nboctets = nboctets;
m_videoFrame->nbpixels = nboctets / Pixel::NbComposantes;
m_videoFrame->frame.octets = new quint8[nboctets];
for ( i = 0; i < m_videoFrame->nboctets; ++i )
m_videoFrame->frame.octets[i] = tocopy[i];
};
LightVideoFrame::~LightVideoFrame()
{
};
VideoFrame const * LightVideoFrame::operator->(void) const
{
return ( m_videoFrame.data() );
};
VideoFrame const & LightVideoFrame::operator*(void) const
{
return ( *m_videoFrame );
};
VideoFrame* LightVideoFrame::operator->(void)
{
return ( m_videoFrame.data() );
};
VideoFrame& LightVideoFrame::operator*(void)
{
return ( *m_videoFrame );
};
#ifndef LIGHTVIDEOFRAME_H_
#define LIGHTVIDEOFRAME_H_
#include "CopyOnWrite.hpp"
#include "VideoFrame.h"
#include <QSharedDataPointer>
#include <QSharedData>
#include <QDebug>
//typedef CopyOnWrite<VideoFrame> LightVideoFrame;
typedef VideoFrame LightVideoFrame;
struct Pixel
{
enum
{
NbComposantes = 3
};
quint8 Red;
quint8 Green;
quint8 Blue;
};
#endif // LIGHTVIDEOFRAME_H_
union RawVideoFrame
{
Pixel* pixels;
quint8* octets;
};
struct VideoFrame : public QSharedData
{
~VideoFrame();
VideoFrame();
VideoFrame(VideoFrame const & tocopy);
RawVideoFrame frame;
quint32 nbpixels;
quint32 nboctets;
};
class LightVideoFrame
{
public:
LightVideoFrame();
LightVideoFrame(LightVideoFrame const & tocopy);
LightVideoFrame(quint32 nboctets);
LightVideoFrame(quint8 const * tocopy, quint32 nboctets);
~LightVideoFrame();
LightVideoFrame& operator=(LightVideoFrame const & tocopy);
VideoFrame const * operator->(void) const;
VideoFrame const & operator*(void) const;
VideoFrame* operator->(void);
VideoFrame& operator*(void);
private:
QSharedDataPointer<VideoFrame> m_videoFrame;
};
#endif // VIDEOFRAME_H_
#ifndef VIDEOFRAME_H_
#define VIDEOFRAME_H_
#include <QtGlobal>
// #include <QByteArray>
// typedef QByteArray VideoFrame;
#include <QSharedDataPointer>
#include <QSharedData>
#include <QDebug>
struct Pixel
{
......@@ -19,22 +18,41 @@ struct Pixel
union RawVideoFrame
{
Pixel* pixel;
quint8* raw;
Pixel* pixels;
quint8* octets;
};
struct VideoFrame
struct VideoFrame : public QSharedData
{
~VideoFrame();
VideoFrame();
VideoFrame(quint32 nboctets);
VideoFrame(quint8* tocopy, quint32 nboctets);
VideoFrame(VideoFrame const &);
VideoFrame & operator=(VideoFrame const & tocopy);
RawVideoFrame rvf;
VideoFrame(VideoFrame const & tocopy);
RawVideoFrame frame;
quint32 nbpixels;
quint32 nboctets;
};
class LightVideoFrame
{
public:
LightVideoFrame();
LightVideoFrame(LightVideoFrame const & tocopy);
LightVideoFrame(quint32 nboctets);
LightVideoFrame(quint8 const * tocopy, quint32 nboctets);
~LightVideoFrame();
LightVideoFrame& operator=(LightVideoFrame const & tocopy);
VideoFrame const * operator->(void) const;
VideoFrame const & operator*(void) const;
VideoFrame* operator->(void);
VideoFrame& operator*(void);
private:
QSharedDataPointer<VideoFrame> m_videoFrame;
};
#endif // VIDEOFRAME_H_
......@@ -2,94 +2,6 @@
// #include "GenericEffect.h"
// #include "PouetEffect.h"
#include <QSharedDataPointer>
#include <QSharedData>
#include <QDebug>
// class EmployeeData : public QSharedData
// {
// public:
// EmployeeData() : id(-1) { name.clear(); }
// EmployeeData(const EmployeeData &other)
// : QSharedData(other), id(other.id), name(other.name) { }
// ~EmployeeData() { }
// int id;
// QString name;
// };
// class Employee
// {
// public:
// Employee() { d = new EmployeeData; }
// Employee(int id, QString name) {
// d = new EmployeeData;
// setId(id);
// setName(name);
// }
// Employee(const Employee &other)
// : d (other.d)
// {
// }
// void setId(int id) { d->id = id; }
// void setName(QString name) { d->name = name; }
// int id() const { return d->id; }
// QString name() const { return d->name; }
// private:
// QSharedDataPointer<EmployeeData> d;
// };
//
//
//
//
//
// union PPixel
// {
// enum
// {
// NbComposantes = 3
// };
// struct
// {
// quint8 Red;
// quint8 Green;
// quint8 Blue;
// } composantes;
// quint32 raw : NbComposantes * 8;
// };
// struct PVideoFrame
// {
// // ~VideoFrame();
// // VideoFrame();
// // VideoFrame(quint32 nboctets);
// // VideoFrame(quint8* tocopy, quint32 nboctets);
// // VideoFrame(VideoFrame const &);
// // VideoFrame & operator=(VideoFrame const & tocopy);
// union
// {
// PPixel* pixels;
// quint8* octets;
// } frame;
// quint32 nbpixels;
// quint32 nboctets;
// };
//
//
//
//
//
struct Pixel
{
......@@ -216,7 +128,7 @@ public:
m_videoFrame->frame.octets = new quint8[nboctets];
};
LightVideoFrame(quint8* tocopy, quint32 nboctets)
LightVideoFrame(quint8 const * tocopy, quint32 nboctets)
{
quint32 i;
......@@ -261,8 +173,10 @@ private:
int main(void)
{
LightVideoFrame vf(100);
LightVideoFrame vf((const quint8*)("JAIMELESPONEYS"), 15);
std::cout << (const char*)vf->frame.octets << '\n'
<< vf->nbpixels << std::endl;
qDebug() << vf->nbpixels;
return (0);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment