VideoCodec/Data/PictureInfo.cpp
#include "PictureInfo.h"
namespace VideoCodec
{
PictureInfo::PictureInfo()
{
this->colourFormat = COLOUR_FORMAT_INVALID;
this->pixelLayout = PIXEL_LAYOUT_SCAN;
this->frameType = FRAME_TYPE_INVALID;
this->pixelsX = 0;
this->pixelsY = 0;
this->blockRows = 0;
this->blockColumns = 0;
this->unsignedByteData = NULL;
this->unsignedByteDataLength = 0;
this->signedShortData = NULL;
this->signedShortDataLength = 0;
this->displacementsX = NULL;
this->displacementsXLength = 0;
this->displacementsY = NULL;
this->displacementsYLength = 0;
}
PictureInfo::~PictureInfo()
{
if (this->unsignedByteData != NULL)
delete [] this->unsignedByteData;
if (this->signedShortData != NULL)
delete [] this->signedShortData;
if (this->displacementsX != NULL)
delete [] this->displacementsX;
if (this->displacementsY != NULL)
delete [] this->displacementsY;
}
PictureInfo* PictureInfo::Clone()
{
PictureInfo* clone = new PictureInfo();
// Copy meta-data.
clone->SetColourFormat(this->GetColourFormat());
clone->SetPixelLayout(this->GetPixelLayout());
clone->SetFrameType(this->GetFrameType());
clone->SetPixelsX(this->GetPixelsX());
clone->SetPixelsY(this->GetPixelsY());
clone->SetBlockRows(this->GetBlockRows());
clone->SetBlockColumns(this->GetBlockColumns());
// Copy pixel data.
if (this->unsignedByteData != NULL && this->unsignedByteDataLength > 0)
{
UnsignedByte* cloneUB = new UnsignedByte[this->unsignedByteDataLength];
memcpy((void*)cloneUB, (void*)this->unsignedByteData, this->unsignedByteDataLength * sizeof(UnsignedByte));
clone->SetUnsignedByteData(cloneUB, this->unsignedByteDataLength);
}
if (this->signedShortData != NULL && this->signedShortDataLength > 0)
{
SignedShort* cloneSS = new SignedShort[this->signedShortDataLength];
memcpy((void*)cloneSS, (void*)this->signedShortData, this->signedShortDataLength * sizeof(SignedShort));
clone->SetSignedShortData(cloneSS, this->signedShortDataLength);
}
// Copy vectors.
if (this->displacementsX != NULL && this->displacementsXLength > 0)
{
SignedByte* cloneDX = new SignedByte[this->displacementsXLength];
memcpy((void*)cloneDX, (void*)this->displacementsX, this->displacementsXLength * sizeof(SignedByte));
clone->SetMVDisplacementsX(cloneDX, this->displacementsXLength);
}
if (this->displacementsY != NULL && this->displacementsYLength > 0)
{
SignedByte* cloneDY = new SignedByte[this->displacementsYLength];
memcpy((void*)cloneDY, (void*)this->displacementsY, this->displacementsYLength * sizeof(SignedByte));
clone->SetMVDisplacementsY(cloneDY, this->displacementsYLength);
}
return clone;
}
void PictureInfo::SetColourFormat(ColourFormat colourFormat)
{
this->colourFormat = colourFormat;
}
ColourFormat PictureInfo::GetColourFormat()
{
return this->colourFormat;
}
void PictureInfo::SetPixelLayout(PixelLayout pixelLayout)
{
this->pixelLayout = pixelLayout;
}
PixelLayout PictureInfo::GetPixelLayout()
{
return this->pixelLayout;
}
void PictureInfo::SetPixelsX(PixelCount pixelsX)
{
this->pixelsX = pixelsX;
}
PixelCount PictureInfo::GetPixelsX()
{
return this->pixelsX;
}
void PictureInfo::SetPixelsY(PixelCount pixelsY)
{
this->pixelsY = pixelsY;
}
PixelCount PictureInfo::GetPixelsY()
{
return this->pixelsY;
}
void PictureInfo::SetBlockRows(BlockCount blockRows)
{
this->blockRows = blockRows;
}
BlockCount PictureInfo::GetBlockRows()
{
return this->blockRows;
}
void PictureInfo::SetBlockColumns(BlockCount blockColumns)
{
this->blockColumns = blockColumns;
}
BlockCount PictureInfo::GetBlockColumns()
{
return this->blockColumns;
}
void PictureInfo::SetFrameType(FrameType type)
{
this->frameType = type;
}
FrameType PictureInfo::GetFrameType()
{
return this->frameType;
}
void PictureInfo::SetUnsignedByteData(UnsignedByte* unsignedByteData, unsigned long int length)
{
if (this->unsignedByteData != NULL && this->unsignedByteData != unsignedByteData)
delete [] this->unsignedByteData;
this->unsignedByteData = unsignedByteData;
this->unsignedByteDataLength = length;
}
UnsignedByte* PictureInfo::GetUnsignedByteData()
{
if (this->unsignedByteData == NULL)
Logger::LogMessage("Warning: Retrieved NULL data from the picture info.");
return this->unsignedByteData;
}
UnsignedByte* PictureInfo::CopyUnsignedByteData()
{
if (this->unsignedByteData == NULL)
return NULL;
UnsignedByte* copy = new UnsignedByte[this->unsignedByteDataLength];
memcpy(copy, this->unsignedByteData, sizeof(UnsignedByte) * this->unsignedByteDataLength);
return copy;
}
unsigned long int PictureInfo::GetUnsignedByteDataLength()
{
return this->unsignedByteDataLength;
}
void PictureInfo::SetSignedShortData(SignedShort* signedShortData, unsigned long int length)
{
if (this->signedShortData != NULL && this->signedShortData != signedShortData)
delete [] this->signedShortData;
this->signedShortData = signedShortData;
this->signedShortDataLength = length;
}
SignedShort* PictureInfo::GetSignedShortData()
{
if (this->signedShortData == NULL)
Logger::LogMessage("Warning: Retrieved NULL data from the picture info.");
return this->signedShortData;
}
SignedShort* PictureInfo::CopySignedShortData()
{
if (this->signedShortData == NULL)
return NULL;
SignedShort* copy = new SignedShort[this->signedShortDataLength];
memcpy(copy, this->signedShortData, sizeof(SignedShort) * this->signedShortDataLength);
return copy;
}
unsigned long int PictureInfo::GetSignedShortDataLength()
{
return this->signedShortDataLength;
}
void PictureInfo::SetMVDisplacementsX(SignedByte* displacementsX, unsigned long int length)
{
this->displacementsYLength = length;
this->displacementsX = displacementsX;
}
SignedByte* PictureInfo::GetMVDisplacementsX()
{
return this->displacementsX;
}
void PictureInfo::SetMVDisplacementsY(SignedByte* displacementsY, unsigned long int length)
{
this->displacementsYLength = length;
this->displacementsY = displacementsY;
}
SignedByte* PictureInfo::GetMVDisplacementsY()
{
return this->displacementsY;
}
}