Remove PlaYUVerPixel.* files

Merge PlaYUVerPixel class into PlaYUVerFrame.h as frame and
pixels are always related. This simplifies the lib files that
are installed
This commit is contained in:
jfmcarreira committed 2018-02-04 04:07:17 +00:00
1 parent ec1679a2e7
commit e9e8db92b5
14 files changed
+275 -295

No files matched your search

+2
View File
@@ -30,6 +30,8 @@
#include "QtConcurrent/qtconcurrentrun.h"
#include "SubWindowAbstract.h"
#include <cassert>
/**
* \brief Functions to control data stream from stream information
*/
-2
View File
@@ -10,7 +10,6 @@ set(PlaYUVer_Lib_SRCS
LibMemory.h
PlaYUVerLib.h
# Frame
PlaYUVerPixel.cpp
PlaYUVerFrame.cpp
PlaYUVerFramePixelFormats.cpp
# Stream
@@ -34,7 +33,6 @@ ENDIF()
set(PlaYUVer_Lib_HEADERS
PlaYUVerDefs.h
PlaYUVerPixel.h
PlaYUVerFrame.h
PlaYUVerStream.h
PlaYUVerOptions.h
+174
View File
@@ -33,6 +33,8 @@
#include <opencv2/core/core.hpp>
#endif
#define MAX_NUMBER_COMPONENTS 4
/*! \brief Supported formats
*
* List of supported pixels formats
@@ -77,6 +79,178 @@ Int PlaYUVerFrame::findPixelFormat( const String& name )
return -1;
}
static inline Void YuvToRgb( const Int& iY, const Int& iU, const Int& iV, Int& iR, Int& iG, Int& iB )
{
iR = iY + ( ( 1436 * ( iV - 128 ) ) >> 10 );
iG = iY - ( ( 352 * ( iU - 128 ) + 731 * ( iV - 128 ) ) >> 10 );
iB = iY + ( ( 1812 * ( iU - 128 ) ) >> 10 );
iR = iR < 0 ? 0 : iR > 255 ? 255 : iR;
iG = iG < 0 ? 0 : iG > 255 ? 255 : iG;
iB = iB < 0 ? 0 : iB > 255 ? 255 : iB;
}
static inline Void rgbToYuv( const Int& iR, const Int& iG, const Int& iB, Int& iY, Int& iU, Int& iV )
{
iY = ( 299 * iR + 587 * iG + 114 * iB + 500 ) / 1000;
iU = ( 1000 * ( iB - iY ) + 226816 ) / 1772;
iV = ( 1000 * ( iR - iY ) + 179456 ) / 1402;
}
struct PlaYUVerPixelPrivate
{
Int iColorSpace;
Pel PixelComponents[MAX_NUMBER_COMPONENTS];
};
Int PlaYUVerPixel::getMaxNumberOfComponents()
{
return MAX_NUMBER_COMPONENTS;
}
PlaYUVerPixel::PlaYUVerPixel()
: d( new PlaYUVerPixelPrivate )
{
d->iColorSpace = COLOR_INVALID;
d->PixelComponents[0] = 0;
d->PixelComponents[1] = 0;
d->PixelComponents[2] = 0;
d->PixelComponents[3] = 0;
}
PlaYUVerPixel::PlaYUVerPixel( const Int& ColorSpace )
{
d->iColorSpace = ColorSpace == COLOR_GRAY ? COLOR_YUV : ColorSpace;
d->PixelComponents[0] = 0;
d->PixelComponents[1] = 0;
d->PixelComponents[2] = 0;
d->PixelComponents[3] = 0;
}
PlaYUVerPixel::PlaYUVerPixel( const Int& ColorSpace, const Pel& c0, const Pel& c1, const Pel& c2 )
{
d->iColorSpace = ColorSpace == COLOR_GRAY ? COLOR_YUV : ColorSpace;
d->PixelComponents[0] = c0;
d->PixelComponents[1] = c1;
d->PixelComponents[2] = c2;
d->PixelComponents[3] = 0;
}
PlaYUVerPixel::PlaYUVerPixel( const Int& ColorSpace, const Pel& c0, const Pel& c1, const Pel& c2, const Pel& c3 )
{
d->iColorSpace = ColorSpace == COLOR_GRAY ? COLOR_YUV : ColorSpace;
d->PixelComponents[0] = c0;
d->PixelComponents[1] = c1;
d->PixelComponents[2] = c2;
d->PixelComponents[3] = c3;
}
PlaYUVerPixel::~PlaYUVerPixel() {}
Int PlaYUVerPixel::ColorSpaceType()
{
return d->iColorSpace;
}
Pel* PlaYUVerPixel::Components()
{
return d->PixelComponents;
}
Pel PlaYUVerPixel::Y() const
{
return d->PixelComponents[0];
}
Pel PlaYUVerPixel::Cb() const
{
return d->PixelComponents[1];
}
Pel PlaYUVerPixel::Cr() const
{
return d->PixelComponents[2];
}
Pel& PlaYUVerPixel::Y()
{
return d->PixelComponents[0];
}
Pel& PlaYUVerPixel::Cb()
{
return d->PixelComponents[1];
}
Pel& PlaYUVerPixel::Cr()
{
return d->PixelComponents[2];
}
Pel& PlaYUVerPixel::R()
{
return d->PixelComponents[0];
}
Pel& PlaYUVerPixel::G()
{
return d->PixelComponents[1];
}
Pel& PlaYUVerPixel::B()
{
return d->PixelComponents[2];
}
Pel PlaYUVerPixel::operator[]( const Int& channel ) const
{
return d->PixelComponents[channel];
}
Pel& PlaYUVerPixel::operator[]( const Int& channel )
{
return d->PixelComponents[channel];
}
PlaYUVerPixel PlaYUVerPixel::operator+( const PlaYUVerPixel& in )
{
PlaYUVerPixel result;
for( Int i = 0; i < MAX_NUMBER_COMPONENTS; i++ )
{
result[i] = d->PixelComponents[i] + in[i];
}
PlaYUVerPixel out( d->iColorSpace, Y() + in.Y(), Cb() + in.Cb(), Cr() + in.Cr() );
return out;
}
PlaYUVerPixel PlaYUVerPixel::operator-( const PlaYUVerPixel& in )
{
PlaYUVerPixel out( d->iColorSpace, Y() - in.Y(), Cb() - in.Cb(), Cr() - in.Cr() );
return out;
}
PlaYUVerPixel PlaYUVerPixel::operator*( const Double& op )
{
PlaYUVerPixel out( d->iColorSpace, Y() * op, Cb() * op, Cr() * op );
return out;
}
PlaYUVerPixel PlaYUVerPixel::ConvertPixel( ColorSpace eOutputSpace )
{
Int outA, outB, outC;
PlaYUVerPixel outPixel( COLOR_INVALID, 0, 0, 0 );
if( ColorSpace() == eOutputSpace || eOutputSpace == COLOR_ARGB || eOutputSpace == COLOR_GRAY )
return *this;
if( eOutputSpace == COLOR_RGB )
{
YuvToRgb( Y(), Cb(), Cr(), outA, outB, outC );
outPixel.R() = outA;
outPixel.G() = outB;
outPixel.B() = outC;
}
if( eOutputSpace == COLOR_YUV )
{
rgbToYuv( R(), G(), B(), outA, outB, outC );
outPixel.Y() = outA;
outPixel.Cb() = outB;
outPixel.Cr() = outC;
}
return outPixel;
}
static Int getImgMemory( Pel**** array3D, Int dim1, Int dim2, Int log2ChromaHeight, Int log2ChromaWidth )
{
Int dim0 = 3;
+70 -4
View File
@@ -19,6 +19,7 @@
/**
* \file PlaYUVerFrame.h
* \ingroup PlaYUVerLibFrame
* \brief Video Frame handling
*/
@@ -26,7 +27,6 @@
#define __PLAYUVERFRAME_H__
#include "PlaYUVerDefs.h"
#include "PlaYUVerPixel.h"
namespace cv
{
@@ -38,9 +38,75 @@ struct PlaYUVerFramePrivate;
#define CHROMASHIFT( SIZE, SHIFT ) UInt( -( ( -( Int( SIZE ) ) ) >> ( SHIFT ) ) )
/**
* \class PlaYUVerPixel
* \ingroup PlaYUVerLibFrame
* \brief Pixel handling class
*/
class PlaYUVerPixel
{
public:
/** ColorSpace list
* List of supported color spaces
*/
enum ColorSpace
{
COLOR_INVALID = -1, //!< Invalid
COLOR_YUV = 0, //!< YUV
COLOR_RGB = 1, //!< RGB
COLOR_GRAY = 2, //!< Grayscale
COLOR_ARGB = 3, //!< RGB + Alpha
COLOR_MAX = 255, //!< Accouunt for future formats
};
static Int getMaxNumberOfComponents();
PlaYUVerPixel();
PlaYUVerPixel( const Int& ColorSpace );
PlaYUVerPixel( const Int& ColorSpace, const Pel& c0, const Pel& c1, const Pel& c2 );
PlaYUVerPixel( const Int& ColorSpace, const Pel& c0, const Pel& c1, const Pel& c2, const Pel& c3 );
~PlaYUVerPixel();
Int ColorSpaceType();
Pel* Components();
Pel Y() const;
Pel Cb() const;
Pel Cr() const;
Pel R() const;
Pel G() const;
Pel B() const;
Pel& Y();
Pel& Cb();
Pel& Cr();
Pel& R();
Pel& G();
Pel& B();
Pel operator[]( const Int& channel ) const;
Pel& operator[]( const Int& channel );
PlaYUVerPixel operator+( const PlaYUVerPixel& );
PlaYUVerPixel operator-( const PlaYUVerPixel& );
PlaYUVerPixel operator*( const Double& );
/**
* Convert a Pixel to a new color space
* @param inputPixel input pixel (PlaYUVerPixel)
* @param eOutputSpace output color space
* @return converted pixel
*/
PlaYUVerPixel ConvertPixel( ColorSpace eOutputSpace );
private:
struct PlaYUVerPixelPrivate* d;
};
/**
* \class PlaYUVerFrame
* \ingroup PlaYUVerLib PlaYUVerLib_Frame
* \ingroup PlaYUVerLibFrame
* \brief Frame handling class
*/
class PlaYUVerFrame
@@ -253,8 +319,8 @@ public:
Bool fromMat( cv::Mat& cvMat );
/**
* \ingroup PlaYUVerLib_Frame
* @defgroup PlaYUVerLib_Frame_QualityMetrics Quality Metrics Interface
* \ingroup PlaYUVerLibFrame
* @defgroup PlaYUVerLibFrameQualityMetrics Quality Metrics Interface
* @{
* Quality metrics interface
*
-1
View File
@@ -27,7 +27,6 @@
#include "PlaYUVerDefs.h"
#include "PlaYUVerFrame.h"
#include "PlaYUVerPixel.h"
#include <map>
+2 -2
View File
@@ -39,12 +39,12 @@
* This guaratees that the top-level applications does not need to worry
* about dealig with different stream formats as well as different pixel formats
*
* @defgroup PlaYUVerLib_Frame PlaYUVer Frame
* @defgroup PlaYUVerLibFrame PlaYUVer Frame
* @{
* Describe PlaYUVerFrame
* @}
*
* @defgroup PlaYUVerLib_Stream PlaYUVer Stream
* @defgroup PlaYUVerLibStream PlaYUVer Stream
* @{
* Describe PlaYUVerStream
* @}
+1
View File
@@ -42,6 +42,7 @@
#include "lib/PlaYUVerModuleIf.h"
#include <cstring>
#include <iostream>
#include <sstream>
using namespace std;
-160
View File
@@ -1,160 +0,0 @@
/* This file is a part of PlaYUVer project
* Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com)
* Luis Lucas (luisfrlucas@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/**
* \file PlaYUVerPixel.cpp
* \brief Pixel handling
*/
#include "PlaYUVerPixel.h"
#include "PlaYUVerFrame.h"
#include <cmath>
#include <cstdio>
PlaYUVerPixel::PlaYUVerPixel()
: m_iColorSpace( COLOR_INVALID )
{
m_iColorSpace = COLOR_INVALID;
PixelComponents[0] = 0;
PixelComponents[1] = 0;
PixelComponents[2] = 0;
PixelComponents[3] = 0;
}
PlaYUVerPixel::PlaYUVerPixel( const Int& ColorSpace )
{
m_iColorSpace = ColorSpace == COLOR_GRAY ? COLOR_YUV : ColorSpace;
PixelComponents[0] = 0;
PixelComponents[1] = 0;
PixelComponents[2] = 0;
PixelComponents[3] = 0;
}
PlaYUVerPixel::PlaYUVerPixel( const Int& ColorSpace, const Pel& c0, const Pel& c1, const Pel& c2 )
{
m_iColorSpace = ColorSpace == COLOR_GRAY ? COLOR_YUV : ColorSpace;
PixelComponents[0] = c0;
PixelComponents[1] = c1;
PixelComponents[2] = c2;
PixelComponents[3] = 0;
}
PlaYUVerPixel::~PlaYUVerPixel() {}
Int PlaYUVerPixel::ColorSpaceType()
{
return m_iColorSpace;
}
Pel* PlaYUVerPixel::Components()
{
return PixelComponents;
}
Pel PlaYUVerPixel::Y() const
{
return PixelComponents[0];
}
Pel PlaYUVerPixel::Cb() const
{
return PixelComponents[1];
}
Pel PlaYUVerPixel::Cr() const
{
return PixelComponents[2];
}
Pel& PlaYUVerPixel::Y()
{
return PixelComponents[0];
}
Pel& PlaYUVerPixel::Cb()
{
return PixelComponents[1];
}
Pel& PlaYUVerPixel::Cr()
{
return PixelComponents[2];
}
Pel& PlaYUVerPixel::R()
{
return PixelComponents[0];
}
Pel& PlaYUVerPixel::G()
{
return PixelComponents[1];
}
Pel& PlaYUVerPixel::B()
{
return PixelComponents[2];
}
Pel PlaYUVerPixel::operator[]( const Int& channel ) const
{
return PixelComponents[channel];
}
Pel& PlaYUVerPixel::operator[]( const Int& channel )
{
return PixelComponents[channel];
}
PlaYUVerPixel PlaYUVerPixel::operator+( const PlaYUVerPixel& in )
{
PlaYUVerPixel out( m_iColorSpace, Y() + in.Y(), Cb() + in.Cb(), Cr() + in.Cr() );
return out;
}
PlaYUVerPixel PlaYUVerPixel::operator-( const PlaYUVerPixel& in )
{
PlaYUVerPixel out( m_iColorSpace, Y() - in.Y(), Cb() - in.Cb(), Cr() - in.Cr() );
return out;
}
PlaYUVerPixel PlaYUVerPixel::operator*( const Double& op )
{
PlaYUVerPixel out( m_iColorSpace, Y() * op, Cb() * op, Cr() * op );
return out;
}
PlaYUVerPixel PlaYUVerPixel::ConvertPixel( ColorSpace eOutputSpace )
{
Int outA, outB, outC;
PlaYUVerPixel outPixel( COLOR_INVALID, 0, 0, 0 );
if( ColorSpace() == eOutputSpace || eOutputSpace == COLOR_ARGB || eOutputSpace == COLOR_GRAY )
return *this;
if( eOutputSpace == COLOR_RGB )
{
YuvToRgb( Y(), Cb(), Cr(), outA, outB, outC );
outPixel.R() = outA;
outPixel.G() = outB;
outPixel.B() = outC;
}
if( eOutputSpace == COLOR_YUV )
{
rgbToYuv( R(), G(), B(), outA, outB, outC );
outPixel.Y() = outA;
outPixel.Cb() = outB;
outPixel.Cr() = outC;
}
return outPixel;
}
-117
View File
@@ -1,117 +0,0 @@
/* This file is a part of PlaYUVer project
* Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com)
* Luis Lucas (luisfrlucas@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/**
* \file PlaYUVerPixel.h
* \brief Pixel handling
*/
#ifndef __PLAYUVERPIXEL_H__
#define __PLAYUVERPIXEL_H__
#include <cassert>
#include <cstdio>
#include <iostream>
#include <vector>
#include "PlaYUVerDefs.h"
static inline Void YuvToRgb( const Int& iY, const Int& iU, const Int& iV, Int& iR, Int& iG, Int& iB )
{
iR = iY + ( ( 1436 * ( iV - 128 ) ) >> 10 );
iG = iY - ( ( 352 * ( iU - 128 ) + 731 * ( iV - 128 ) ) >> 10 );
iB = iY + ( ( 1812 * ( iU - 128 ) ) >> 10 );
iR = iR < 0 ? 0 : iR > 255 ? 255 : iR;
iG = iG < 0 ? 0 : iG > 255 ? 255 : iG;
iB = iB < 0 ? 0 : iB > 255 ? 255 : iB;
}
static inline Void rgbToYuv( const Int& iR, const Int& iG, const Int& iB, Int& iY, Int& iU, Int& iV )
{
iY = ( 299 * iR + 587 * iG + 114 * iB + 500 ) / 1000;
iU = ( 1000 * ( iB - iY ) + 226816 ) / 1772;
iV = ( 1000 * ( iR - iY ) + 179456 ) / 1402;
}
/**
* \class PlaYUVerPixel
* \ingroup PlaYUVerLib PlaYUVerLib_Frame
* \brief Pixel handling class
*/
class PlaYUVerPixel
{
public:
static const UInt MAX_NUMBER_COMPONENTS = 5;
/** ColorSpace list
* List of supported color spaces
*/
enum ColorSpace
{
COLOR_INVALID = -1, //!< Invalid
COLOR_YUV = 0, //!< YUV
COLOR_RGB = 1, //!< RGB
COLOR_GRAY = 2, //!< Grayscale
COLOR_ARGB = 3, //!< RGB + Alpha
COLOR_MAX = 255, //!< Accouunt for future formats
};
PlaYUVerPixel();
PlaYUVerPixel( const Int& ColorSpace );
PlaYUVerPixel( const Int& ColorSpace, const Pel& c0, const Pel& c1, const Pel& c2 );
~PlaYUVerPixel();
Int ColorSpaceType();
Pel* Components();
Pel Y() const;
Pel Cb() const;
Pel Cr() const;
Pel R() const;
Pel G() const;
Pel B() const;
Pel& Y();
Pel& Cb();
Pel& Cr();
Pel& R();
Pel& G();
Pel& B();
Pel operator[]( const Int& channel ) const;
Pel& operator[]( const Int& channel );
PlaYUVerPixel operator+( const PlaYUVerPixel& );
PlaYUVerPixel operator-( const PlaYUVerPixel& );
PlaYUVerPixel operator*( const Double& );
/**
* Convert a Pixel to a new color space
* @param inputPixel input pixel (PlaYUVerPixel)
* @param eOutputSpace output color space
* @return converted pixel
*/
PlaYUVerPixel ConvertPixel( ColorSpace eOutputSpace );
private:
Int m_iColorSpace;
Pel PixelComponents[MAX_NUMBER_COMPONENTS];
};
#endif // __PLAYUVERPIXEL_H__
+1 -2
View File
@@ -86,9 +86,8 @@ private:
inline Int prevIndex() { return m_uiIndex - 1 < 0 ? m_apcFrameBuffer.size() - 1 : m_uiIndex - 1; }
};
class PlaYUVerStreamPrivate
struct PlaYUVerStreamPrivate
{
public:
Bool isInit;
Bool isInput;
+1 -2
View File
@@ -28,7 +28,6 @@
#include "PlaYUVerDefs.h"
class PlaYUVerFrame;
class PlaYUVerStreamPrivate;
class PlaYUVerStreamHandlerIf;
typedef PlaYUVerStreamHandlerIf* ( *CreateStreamHandlerFn )( void );
@@ -122,7 +121,7 @@ private:
Bool readFrame( PlaYUVerFrame* frame );
private:
PlaYUVerStreamPrivate* d;
struct PlaYUVerStreamPrivate* d;
};
#endif // __PLAYUVERSTREAM_H__
+1 -2
View File
@@ -30,7 +30,6 @@
#include "lib/PlaYUVerFrame.h"
#include "lib/PlaYUVerModuleIf.h"
#include "lib/PlaYUVerPixel.h"
#include "lib/PlaYUVerStream.h"
#include "modules/PlaYUVerModuleFactory.h"
@@ -425,7 +424,7 @@ Int PlaYUVerTools::QualityOperation()
const char* pchQualityMetricName = PlaYUVerFrame::supportedQualityMetricsList()[m_uiQualityMetric].c_str();
PlaYUVerFrame* apcCurrFrame[MAX_NUMBER_INPUTS];
Bool abEOF[MAX_NUMBER_INPUTS];
Double adAverageQuality[MAX_NUMBER_INPUTS - 1][PlaYUVerPixel::MAX_NUMBER_COMPONENTS];
Double adAverageQuality[MAX_NUMBER_INPUTS - 1][PlaYUVerPixel::getMaxNumberOfComponents()];
Double dQuality;
String metric_fmt = " ";
+19
View File
@@ -20,11 +20,30 @@
/**
* \file PlaYUVerTools.h
* \brief Main definition of the PlaYUVerTools app
*
* @defgroup PlaYUVerTools PlaYUVer Tools
* @{
*
* PlaYUVerTools is a command line interface
* for the modules and quality metrics
* included in PlaYUVer
*
* @}
*/
#ifndef __PLAYUVERTOOLS_H__
#define __PLAYUVERTOOLS_H__
/**
* @defgroup PlaYUVerTools PlaYUVer Tools
* @{
* PlaYUVerTools is a command line interface
* for the modules and quality metrics
* included in PlaYUVer
* @}
*
*/
#include "lib/PlaYUVerDefs.h"
#include "lib/PlaYUVerFrame.h"
+4 -3
View File
@@ -24,14 +24,15 @@
#include "PlaYUVerToolsCmdParser.h"
#include <cstdarg>
#include <cstring>
#include "lib/PlaYUVerFrame.h"
#include "lib/PlaYUVerModuleIf.h"
#include "lib/PlaYUVerStream.h"
#include "modules/PlaYUVerModuleFactory.h"
#include <cstdarg>
#include <cstring>
#include <iostream>
PlaYUVerToolsCmdParser::PlaYUVerToolsCmdParser()
{
m_uiLogLevel = 0;