Change formating and copyrights

This commit is contained in:
jfmcarreira committed 2018-01-15 23:47:58 +00:00
1 parent bc5258a94d
commit 06cdda6d8a
122 files changed
+14058 -12613

No files matched your search

+7 -5
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
/* 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
@@ -95,7 +95,8 @@ Int getMem2D( T*** array2D, Int dim0, Int dim1 )
if( ( *( *array2D ) = (T*)xCallocMem( dim0 * dim1, sizeof( T ) ) ) == NULL )
printf( "get_mem2Dint: array2D" );
for( i = 1; i < dim0; i++ ) ( *array2D )[i] = ( *array2D )[i - 1] + dim1;
for( i = 1; i < dim0; i++ )
( *array2D )[i] = ( *array2D )[i - 1] + dim1;
return dim0 * ( sizeof( T* ) + dim1 * sizeof( T ) );
}
@@ -110,7 +111,8 @@ Int getMem3D( T**** array3D, Int dim0, Int dim1, Int dim2 )
mem_size += getMem2D( *array3D, dim0 * dim1, dim2 );
for( i = 1; i < dim0; i++ ) ( *array3D )[i] = ( *array3D )[i - 1] + dim1;
for( i = 1; i < dim0; i++ )
( *array3D )[i] = ( *array3D )[i - 1] + dim1;
return mem_size;
}
+9 -5
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
/* 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
@@ -142,8 +142,12 @@ struct PlaYUVerFailure : public std::exception
{
String m_class_name;
String m_error_msg;
PlaYUVerFailure( String error_msg ) throw() : m_error_msg( error_msg ) {}
PlaYUVerFailure( String class_name, String error_msg ) throw() : m_class_name( class_name ), m_error_msg( error_msg ) {}
PlaYUVerFailure( String error_msg ) throw()
: m_error_msg( error_msg ) {}
PlaYUVerFailure( String class_name, String error_msg ) throw()
: m_class_name( class_name ), m_error_msg( error_msg )
{
}
~PlaYUVerFailure() throw() {}
const Char* what() const throw()
{
+136 -71
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
/* 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
@@ -23,6 +23,9 @@
*/
#include "PlaYUVerFrame.h"
#include "LibMemory.h"
#include "PlaYUVerFramePixelFormats.h"
#include "config.h"
#include <cmath>
@@ -30,9 +33,6 @@
#include <opencv2/core/core.hpp>
#endif
#include "LibMemory.h"
#include "PlaYUVerFramePixelFormats.h"
/*! \brief Supported formats
*
* List of supported pixels formats
@@ -49,7 +49,8 @@ std::vector<String> PlaYUVerFrame::supportedColorSpacesListNames()
std::vector<String> PlaYUVerFrame::supportedPixelFormatListNames()
{
std::vector<String> formatsList;
for( Int i = 0; i < NUMBER_PEL_FORMATS; i++ ) {
for( Int i = 0; i < NUMBER_PEL_FORMATS; i++ )
{
formatsList.push_back( g_PlaYUVerPixFmtDescriptorsList[i].name );
}
return formatsList;
@@ -58,7 +59,8 @@ std::vector<String> PlaYUVerFrame::supportedPixelFormatListNames()
std::vector<String> PlaYUVerFrame::supportedPixelFormatListNames( Int colorSpace )
{
std::vector<String> formatsList;
for( Int i = 0; i < NUMBER_PEL_FORMATS; i++ ) {
for( Int i = 0; i < NUMBER_PEL_FORMATS; i++ )
{
if( g_PlaYUVerPixFmtDescriptorsList[i].colorSpace == colorSpace )
formatsList.push_back( g_PlaYUVerPixFmtDescriptorsList[i].name );
}
@@ -67,7 +69,8 @@ std::vector<String> PlaYUVerFrame::supportedPixelFormatListNames( Int colorSpace
Int PlaYUVerFrame::findPixelFormat( const String& name )
{
for( Int i = 0; i < NUMBER_PEL_FORMATS; i++ ) {
for( Int i = 0; i < NUMBER_PEL_FORMATS; i++ )
{
if( g_PlaYUVerPixFmtDescriptorsList[i].name == name )
return i;
}
@@ -89,7 +92,8 @@ static Int getImgMemory( Pel**** array3D, Int dim1, Int dim2, Int log2ChromaHeig
total_mem_size += mem_size * sizeof( Pel );
// Luma
for( i = 1; i < dim1; i++ ) ( *array3D )[0][i] = ( *array3D )[0][i - 1] + dim2;
for( i = 1; i < dim1; i++ )
( *array3D )[0][i] = ( *array3D )[0][i - 1] + dim2;
// Chroma
( *array3D )[1][0] = ( *array3D )[0][0] + dim2 * dim1;
@@ -97,10 +101,12 @@ static Int getImgMemory( Pel**** array3D, Int dim1, Int dim2, Int log2ChromaHeig
dim1 = CHROMASHIFT( dim1, log2ChromaHeight );
dim2 = CHROMASHIFT( dim2, log2ChromaWidth );
for( i = 1; i < dim1; i++ ) ( *array3D )[1][i] = ( *array3D )[1][i - 1] + dim2;
for( i = 1; i < dim1; i++ )
( *array3D )[1][i] = ( *array3D )[1][i - 1] + dim2;
( *array3D )[2][0] = ( *array3D )[1][0] + dim2 * dim1;
for( i = 1; i < dim1; i++ ) ( *array3D )[2][i] = ( *array3D )[2][i - 1] + dim2;
for( i = 1; i < dim1; i++ )
( *array3D )[2][i] = ( *array3D )[2][i - 1] + dim2;
return total_mem_size;
}
@@ -126,7 +132,8 @@ struct PlaYUVerFramePrivate
UInt m_uiWidth; //!< Width of the frame
UInt m_uiHeight; //!< Height of the frame
Int m_iPixelFormat; //!< Pixel format number (it follows the list of supported
Int m_iPixelFormat; //!< Pixel format number (it follows the list of
//!< supported
//! pixel formats)
Int m_iNumberChannels; //!< Number of channels
UInt m_uiBitsPel; //!< Bits per pixel/channel
@@ -182,7 +189,8 @@ struct PlaYUVerFramePrivate
}
else
{
getImgMemory( &m_pppcInputPel, m_uiHeight, m_uiWidth, m_pcPelFormat->log2ChromaHeight, m_pcPelFormat->log2ChromaWidth );
getImgMemory( &m_pppcInputPel, m_uiHeight, m_uiWidth, m_pcPelFormat->log2ChromaHeight,
m_pcPelFormat->log2ChromaWidth );
}
getMem1D( &m_pcARGB32, m_uiHeight * m_uiWidth * 4 );
@@ -192,7 +200,8 @@ struct PlaYUVerFramePrivate
m_uiHistoSegments = 1 << m_uiBitsPel;
if( m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_RGB || m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_ARGB )
if( m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_RGB ||
m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_ARGB )
m_uiHistoChannels = m_pcPelFormat->numberChannels + 1;
else
m_uiHistoChannels = m_pcPelFormat->numberChannels;
@@ -224,18 +233,21 @@ struct PlaYUVerFramePrivate
* \brief Constructors
*/
PlaYUVerFrame::PlaYUVerFrame( UInt width, UInt height, Int pelFormat, Int bitsPixel ) : d( new PlaYUVerFramePrivate )
PlaYUVerFrame::PlaYUVerFrame( UInt width, UInt height, Int pelFormat, Int bitsPixel )
: d( new PlaYUVerFramePrivate )
{
d->init( width, height, pelFormat, bitsPixel );
}
PlaYUVerFrame::PlaYUVerFrame( const PlaYUVerFrame& other ) : d( new PlaYUVerFramePrivate )
PlaYUVerFrame::PlaYUVerFrame( const PlaYUVerFrame& other )
: d( new PlaYUVerFramePrivate )
{
d->init( other.getWidth(), other.getHeight(), other.getPelFormat(), other.getBitsPel() );
copyFrom( &other );
}
PlaYUVerFrame::PlaYUVerFrame( const PlaYUVerFrame* other ) : d( new PlaYUVerFramePrivate )
PlaYUVerFrame::PlaYUVerFrame( const PlaYUVerFrame* other )
: d( new PlaYUVerFramePrivate )
{
if( other )
{
@@ -244,7 +256,8 @@ PlaYUVerFrame::PlaYUVerFrame( const PlaYUVerFrame* other ) : d( new PlaYUVerFram
}
}
PlaYUVerFrame::PlaYUVerFrame( const PlaYUVerFrame& other, UInt x, UInt y, UInt width, UInt height ) : d( new PlaYUVerFramePrivate )
PlaYUVerFrame::PlaYUVerFrame( const PlaYUVerFrame& other, UInt x, UInt y, UInt width, UInt height )
: d( new PlaYUVerFramePrivate )
{
const PlaYUVerPixFmtDescriptor* pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[other.getPelFormat()] );
if( pcPelFormat->log2ChromaWidth )
@@ -268,7 +281,8 @@ PlaYUVerFrame::PlaYUVerFrame( const PlaYUVerFrame& other, UInt x, UInt y, UInt w
copyFrom( other, x, y );
}
PlaYUVerFrame::PlaYUVerFrame( const PlaYUVerFrame* other, UInt posX, UInt posY, UInt areaWidth, UInt areaHeight ) : d( new PlaYUVerFramePrivate )
PlaYUVerFrame::PlaYUVerFrame( const PlaYUVerFrame* other, UInt posX, UInt posY, UInt areaWidth, UInt areaHeight )
: d( new PlaYUVerFramePrivate )
{
if( !other )
return;
@@ -406,7 +420,8 @@ UInt64 PlaYUVerFrame::getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelF
UInt64 numberBytes = uiWidth * uiHeight;
if( pcPelFormat->numberChannels > 1 )
{
UInt64 numberBytesChroma = CHROMASHIFT( uiWidth, pcPelFormat->log2ChromaWidth ) * CHROMASHIFT( uiHeight, pcPelFormat->log2ChromaHeight );
UInt64 numberBytesChroma =
CHROMASHIFT( uiWidth, pcPelFormat->log2ChromaWidth ) * CHROMASHIFT( uiHeight, pcPelFormat->log2ChromaHeight );
numberBytes += ( pcPelFormat->numberChannels - 1 ) * numberBytesChroma;
}
return numberBytes * bytesPerPixel;
@@ -418,11 +433,13 @@ Void PlaYUVerFrame::clear()
Pel uiValue = 128;
Int ratioH, ratioW;
UInt i;
for( UInt ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ ) {
for( UInt ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ )
{
ratioW = ch > 0 ? d->m_pcPelFormat->log2ChromaWidth : 0;
ratioH = ch > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0;
pPel = d->m_pppcInputPel[ch][0];
for( i = 0; i < CHROMASHIFT( d->m_uiHeight, ratioH ) * CHROMASHIFT( d->m_uiWidth, ratioW ); i++ ) {
for( i = 0; i < CHROMASHIFT( d->m_uiHeight, ratioH ) * CHROMASHIFT( d->m_uiWidth, ratioW ); i++ )
{
*pPel++ = uiValue;
}
}
@@ -458,8 +475,10 @@ UChar* PlaYUVerFrame::getRGBBuffer()
PlaYUVerPixel PlaYUVerFrame::getPixelValue( Int xPos, Int yPos )
{
PlaYUVerPixel PixelValue( d->m_pcPelFormat->colorSpace, d->m_uiHalfPelValue, d->m_uiHalfPelValue, d->m_uiHalfPelValue );
for( UInt ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ ) {
PlaYUVerPixel PixelValue( d->m_pcPelFormat->colorSpace, d->m_uiHalfPelValue, d->m_uiHalfPelValue,
d->m_uiHalfPelValue );
for( UInt ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ )
{
Int ratioH = ch > 0 ? d->m_pcPelFormat->log2ChromaWidth : 0;
Int ratioW = ch > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0;
PixelValue[ch] = d->m_pppcInputPel[ch][( yPos >> ratioH )][( xPos >> ratioW )];
@@ -470,7 +489,8 @@ PlaYUVerPixel PlaYUVerFrame::getPixelValue( Int xPos, Int yPos )
PlaYUVerPixel PlaYUVerFrame::getPixelValue( Int xPos, Int yPos, PlaYUVerPixel::ColorSpace eColorSpace )
{
PlaYUVerPixel PixelValue( d->m_pcPelFormat->colorSpace );
for( UInt ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ ) {
for( UInt ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ )
{
Int ratioH = ch > 0 ? d->m_pcPelFormat->log2ChromaWidth : 0;
Int ratioW = ch > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0;
PixelValue[ch] = d->m_pppcInputPel[ch][( yPos >> ratioH )][( xPos >> ratioW )];
@@ -481,7 +501,8 @@ PlaYUVerPixel PlaYUVerFrame::getPixelValue( Int xPos, Int yPos, PlaYUVerPixel::C
Void PlaYUVerFrame::setPixelValue( Int xPos, Int yPos, PlaYUVerPixel pixel )
{
for( UInt ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ ) {
for( UInt ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ )
{
Int ratioH = ch > 0 ? d->m_pcPelFormat->log2ChromaWidth : 0;
Int ratioW = ch > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0;
d->m_pppcInputPel[ch][( yPos >> ratioH )][( xPos >> ratioW )] = pixel.Components()[ch];
@@ -510,11 +531,14 @@ Void PlaYUVerFrame::copyFrom( const PlaYUVerFrame& other, UInt xPos, UInt yPos )
if( haveSameFmt( other, MATCH_ALL ) )
return;
Pel*** pInput = other.getPelBufferYUV();
for( UInt ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ ) {
for( UInt ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ )
{
Int ratioH = ch > 0 ? d->m_pcPelFormat->log2ChromaWidth : 0;
Int ratioW = ch > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0;
for( UInt i = 0; i < CHROMASHIFT( d->m_uiHeight, ratioH ); i++ ) {
memcpy( d->m_pppcInputPel[ch][i], &( pInput[ch][( yPos >> ratioH ) + i][( xPos >> ratioW )] ), ( d->m_uiWidth >> ratioW ) * sizeof( Pel ) );
for( UInt i = 0; i < CHROMASHIFT( d->m_uiHeight, ratioH ); i++ )
{
memcpy( d->m_pppcInputPel[ch][i], &( pInput[ch][( yPos >> ratioH ) + i][( xPos >> ratioW )] ),
( d->m_uiWidth >> ratioW ) * sizeof( Pel ) );
}
}
d->m_bHasRGBPel = false;
@@ -557,13 +581,15 @@ Void PlaYUVerFrame::frameFromBuffer( Byte* Buff, Int iEndianness )
}
ppBuff[0] = Buff;
for( i = 1; i < MAX_NUMBER_PLANES; i++ ) {
for( i = 1; i < MAX_NUMBER_PLANES; i++ )
{
ratioW = i > 1 ? d->m_pcPelFormat->log2ChromaWidth : 0;
ratioH = i > 1 ? d->m_pcPelFormat->log2ChromaHeight : 0;
ppBuff[i] = ppBuff[i - 1] + CHROMASHIFT( d->m_uiHeight, ratioH ) * CHROMASHIFT( d->m_uiWidth, ratioW ) * bytesPixel;
}
for( ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ ) {
for( ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ )
{
ratioW = ch > 0 ? d->m_pcPelFormat->log2ChromaWidth : 0;
ratioH = ch > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0;
step = d->m_pcPelFormat->comp[ch].step_minus1;
@@ -571,9 +597,11 @@ Void PlaYUVerFrame::frameFromBuffer( Byte* Buff, Int iEndianness )
pPel = d->m_pppcInputPel[ch][0];
pTmpBuff = ppBuff[d->m_pcPelFormat->comp[ch].plane] + ( d->m_pcPelFormat->comp[ch].offset_plus1 - 1 );
for( i = 0; i < CHROMASHIFT( d->m_uiHeight, ratioH ) * CHROMASHIFT( d->m_uiWidth, ratioW ); i++ ) {
for( i = 0; i < CHROMASHIFT( d->m_uiHeight, ratioH ) * CHROMASHIFT( d->m_uiWidth, ratioW ); i++ )
{
*pPel = 0;
for( b = startByte; b != endByte; b += incByte ) {
for( b = startByte; b != endByte; b += incByte )
{
*pPel += *pTmpBuff << ( b * 8 );
pTmpBuff++;
// Check max value and bound it to "maxval" to prevent segfault when
@@ -611,13 +639,15 @@ Void PlaYUVerFrame::frameToBuffer( Byte* output_buffer, Int iEndianness )
}
ppBuff[0] = output_buffer;
for( Int i = 1; i < MAX_NUMBER_PLANES; i++ ) {
for( Int i = 1; i < MAX_NUMBER_PLANES; i++ )
{
ratioW = i > 1 ? d->m_pcPelFormat->log2ChromaWidth : 0;
ratioH = i > 1 ? d->m_pcPelFormat->log2ChromaHeight : 0;
ppBuff[i] = ppBuff[i - 1] + CHROMASHIFT( d->m_uiHeight, ratioH ) * CHROMASHIFT( d->m_uiWidth, ratioW ) * bytesPixel;
}
for( ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ ) {
for( ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ )
{
ratioW = ch > 0 ? d->m_pcPelFormat->log2ChromaWidth : 0;
ratioH = ch > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0;
step = d->m_pcPelFormat->comp[ch].step_minus1;
@@ -625,8 +655,10 @@ Void PlaYUVerFrame::frameToBuffer( Byte* output_buffer, Int iEndianness )
pTmpPel = d->m_pppcInputPel[ch][0];
pTmpBuff = ppBuff[d->m_pcPelFormat->comp[ch].plane];
for( i = 0; i < CHROMASHIFT( d->m_uiHeight, ratioH ) * CHROMASHIFT( d->m_uiWidth, ratioW ); i++ ) {
for( b = startByte; b != endByte; b += incByte ) {
for( i = 0; i < CHROMASHIFT( d->m_uiHeight, ratioH ) * CHROMASHIFT( d->m_uiWidth, ratioW ); i++ )
{
for( b = startByte; b != endByte; b += incByte )
{
*pTmpBuff = *pTmpPel >> ( 8 * b );
pTmpBuff++;
}
@@ -656,7 +688,8 @@ Void PlaYUVerFrame::fillRGBBuffer()
{
Pel* pY = d->m_pppcInputPel[LUMA][0];
Int iY;
for( UInt i = 0; i < d->m_uiHeight * d->m_uiWidth; i++ ) {
for( UInt i = 0; i < d->m_uiHeight * d->m_uiWidth; i++ )
{
iY = *pY++;
iY >>= shiftBits;
iR = iY;
@@ -671,7 +704,8 @@ Void PlaYUVerFrame::fillRGBBuffer()
Pel* pG = d->m_pppcInputPel[COLOR_G][0];
Pel* pB = d->m_pppcInputPel[COLOR_B][0];
for( UInt i = 0; i < d->m_uiHeight * d->m_uiWidth; i++ ) {
for( UInt i = 0; i < d->m_uiHeight * d->m_uiWidth; i++ )
{
iR = *pR++;
iG = *pG++;
iB = *pB++;
@@ -693,18 +727,22 @@ Void PlaYUVerFrame::fillRGBBuffer()
UInt y, x;
Int i, j;
for( y = 0; y<d->m_uiHeight>> d->m_pcPelFormat->log2ChromaHeight; y++ ) {
for( i = 0; i < 1 << d->m_pcPelFormat->log2ChromaHeight; i++ ) {
for( y = 0; y<d->m_uiHeight>> d->m_pcPelFormat->log2ChromaHeight; y++ )
{
for( i = 0; i < 1 << d->m_pcPelFormat->log2ChromaHeight; i++ )
{
pY = pLineY;
pU = pLineU;
pV = pLineV;
pARGB = pARGBLine;
for( x = 0; x<d->m_uiWidth>> d->m_pcPelFormat->log2ChromaWidth; x++ ) {
for( x = 0; x<d->m_uiWidth>> d->m_pcPelFormat->log2ChromaWidth; x++ )
{
iU = *pU++;
iU >>= shiftBits;
iV = *pV++;
iV >>= shiftBits;
for( j = 0; j < ( 1 << d->m_pcPelFormat->log2ChromaWidth ); j++ ) {
for( j = 0; j < ( 1 << d->m_pcPelFormat->log2ChromaWidth ); j++ )
{
iY = *pY++;
iY >>= shiftBits;
YUV2RGB( iY, iU, iV, iR, iG, iB );
@@ -743,12 +781,15 @@ Void PlaYUVerFrame::calcHistogram()
data[LUMA] = d->m_pppcInputPel[LUMA][0];
data[CHROMA_U] = d->m_pppcInputPel[CHROMA_U][0];
data[CHROMA_V] = d->m_pppcInputPel[CHROMA_V][0];
for( i = 0; i < d->m_uiHeight * d->m_uiWidth; i++ ) {
for( i = 0; i < d->m_uiHeight * d->m_uiWidth; i++ )
{
d->m_puiHistogram[*( data[LUMA] ) + LUMA * d->m_uiHistoSegments]++;
data[LUMA] += 1;
}
for( i = 0; ( i < getChromaLength() ); i++ ) {
for( j = 1; j < numberChannels; j++ ) {
for( i = 0; ( i < getChromaLength() ); i++ )
{
for( j = 1; j < numberChannels; j++ )
{
d->m_puiHistogram[*( data[j] ) + j * d->m_uiHistoSegments]++;
data[j] += 1;
}
@@ -762,8 +803,10 @@ Void PlaYUVerFrame::calcHistogram()
data[COLOR_G] = d->m_pppcInputPel[COLOR_G][0];
data[COLOR_B] = d->m_pppcInputPel[COLOR_B][0];
for( i = 0; ( i < d->m_uiHeight * d->m_uiWidth ); i++ ) {
for( j = 0; j < numberChannels; j++ ) {
for( i = 0; ( i < d->m_uiHeight * d->m_uiWidth ); i++ )
{
for( j = 0; j < numberChannels; j++ )
{
d->m_puiHistogram[*( data[j] ) + j * d->m_uiHistoSegments]++;
}
if( ( colorSpace == PlaYUVerPixel::COLOR_RGB || colorSpace == PlaYUVerPixel::COLOR_ARGB ) )
@@ -772,7 +815,8 @@ Void PlaYUVerFrame::calcHistogram()
luma = currPixel.ConvertPixel( PlaYUVerPixel::COLOR_YUV ).Y();
d->m_puiHistogram[luma + j * d->m_uiHistoSegments]++;
}
for( j = 0; j < numberChannels; j++ ) data[j] += 1;
for( j = 0; j < numberChannels; j++ )
data[j] += 1;
}
}
d->m_bHasHistogram = true;
@@ -867,7 +911,8 @@ UInt PlaYUVerFrame::getMin( Int channel )
indexStart = histoChannel * d->m_uiHistoSegments;
for( value = 0; value <= d->m_uiHistoSegments; value++ ) {
for( value = 0; value <= d->m_uiHistoSegments; value++ )
{
if( d->m_puiHistogram[indexStart + value] > 0 )
{
break;
@@ -896,7 +941,8 @@ UInt PlaYUVerFrame::getMax( Int channel )
indexStart = histoChannel * d->m_uiHistoSegments;
for( value = d->m_uiHistoSegments - 1; value >= 0; value-- ) {
for( value = d->m_uiHistoSegments - 1; value >= 0; value-- )
{
if( d->m_puiHistogram[indexStart + value] > 0 )
{
break;
@@ -926,7 +972,8 @@ UInt PlaYUVerFrame::getCount( Int channel, UInt start, UInt end )
indexStart = histoChannel * d->m_uiHistoSegments;
for( i = start; i <= end; i++ ) {
for( i = start; i <= end; i++ )
{
count += d->m_puiHistogram[indexStart + i];
}
return count;
@@ -953,7 +1000,8 @@ Double PlaYUVerFrame::getMean( Int channel, UInt start, UInt end )
indexStart = histoChannel * d->m_uiHistoSegments;
for( UInt i = start; i <= end; i++ ) {
for( UInt i = start; i <= end; i++ )
{
mean += i * d->m_puiHistogram[indexStart + i];
}
@@ -990,7 +1038,8 @@ Int PlaYUVerFrame::getMedian( Int channel, UInt start, UInt end )
count = getCount( channel, start, end );
for( UInt i = start; i <= end; i++ ) {
for( UInt i = start; i <= end; i++ )
{
sum += d->m_puiHistogram[indexStart + i];
if( sum * 2 > count )
return i;
@@ -1037,7 +1086,8 @@ Double PlaYUVerFrame::getStdDev( Int channel, UInt start, UInt end )
-----------------------*/
for( UInt i = start; i <= end; i++ ) {
for( UInt i = start; i <= end; i++ )
{
dev += ( i * i ) * d->m_puiHistogram[indexStart + i];
}
@@ -1086,7 +1136,8 @@ Double PlaYUVerFrame::getMaximum( Int channel )
indexStart = histoChannel * d->m_uiHistoSegments;
for( UInt x = 0; x < d->m_uiHistoSegments; x++ ) {
for( UInt x = 0; x < d->m_uiHistoSegments; x++ )
{
if( d->m_puiHistogram[indexStart + x] > max )
{
max = d->m_puiHistogram[indexStart + x];
@@ -1106,18 +1157,21 @@ Bool PlaYUVerFrame::toMat( cv::Mat& cvMat, Bool convertToGray )
{
Bool bRet = false;
#ifdef USE_OPENCV
if( convertToGray && !( d->m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_YUV || d->m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_GRAY ) )
if( convertToGray && !( d->m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_YUV ||
d->m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_GRAY ) )
{
return bRet;
}
Int cvType = CV_MAKETYPE( CV_8U, convertToGray ? 1 : d->m_pcPelFormat->numberChannels );
cvMat.create( d->m_uiHeight, d->m_uiWidth, cvType );
UChar* pCvPel = cvMat.data;
if( !convertToGray && ( d->m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_YUV || d->m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_RGB ) )
if( !convertToGray && ( d->m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_YUV ||
d->m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_RGB ) )
{
fillRGBBuffer();
UChar* pARGB = d->m_pcARGB32;
for( UInt i = 0; i < d->m_uiWidth * d->m_uiHeight; i++ ) {
for( UInt i = 0; i < d->m_uiWidth * d->m_uiHeight; i++ )
{
*pCvPel++ = *pARGB++;
*pCvPel++ = *pARGB++;
*pCvPel++ = *pARGB++;
@@ -1128,7 +1182,8 @@ Bool PlaYUVerFrame::toMat( cv::Mat& cvMat, Bool convertToGray )
else if( convertToGray || d->m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_GRAY )
{
Pel* pPel = d->m_pppcInputPel[LUMA][0];
for( UInt i = 0; i < d->m_uiWidth * d->m_uiHeight; i++ ) {
for( UInt i = 0; i < d->m_uiWidth * d->m_uiHeight; i++ )
{
*pCvPel++ = *pPel++;
}
bRet = true;
@@ -1173,7 +1228,8 @@ Bool PlaYUVerFrame::fromMat( cv::Mat& cvMat )
Pel* pInputPelR = d->m_pppcInputPel[COLOR_R][0];
Pel* pInputPelG = d->m_pppcInputPel[COLOR_G][0];
Pel* pInputPelB = d->m_pppcInputPel[COLOR_B][0];
for( UInt i = 0; i < d->m_uiHeight * d->m_uiWidth; i++ ) {
for( UInt i = 0; i < d->m_uiHeight * d->m_uiWidth; i++ )
{
*pInputPelB++ = *pCvPel++;
*pInputPelG++ = *pCvPel++;
*pInputPelR++ = *pCvPel++;
@@ -1183,7 +1239,8 @@ Bool PlaYUVerFrame::fromMat( cv::Mat& cvMat )
else
{
Pel* pPel = d->m_pppcInputPel[LUMA][0];
for( UInt i = 0; i < d->m_uiWidth * d->m_uiHeight; i++ ) {
for( UInt i = 0; i < d->m_uiWidth * d->m_uiHeight; i++ )
{
*pPel++ = *pCvPel++;
}
bRet = true;
@@ -1245,7 +1302,8 @@ Double PlaYUVerFrame::getMSE( PlaYUVerFrame* Org, Int component )
numberOfPixels = getChromaLength();
}
for( UInt i = 0; i < numberOfPixels; i++ ) {
for( UInt i = 0; i < numberOfPixels; i++ )
{
aux_pel_1 = *pPelYUV++;
aux_pel_2 = *pOrgPelYUV++;
diff = aux_pel_1 - aux_pel_2;
@@ -1269,7 +1327,8 @@ Double PlaYUVerFrame::getPSNR( PlaYUVerFrame* Org, Int component )
return dPSNR;
}
float compute_ssim( Pel** refImg, Pel** encImg, Int width, Int height, Int win_width, Int win_height, Int max_pel_value_comp, Int overlapSize )
float compute_ssim( Pel** refImg, Pel** encImg, Int width, Int height, Int win_width, Int win_height,
Int max_pel_value_comp, Int overlapSize )
{
static const float K1 = 0.01f, K2 = 0.03f;
float max_pix_value_sqd;
@@ -1290,16 +1349,20 @@ float compute_ssim( Pel** refImg, Pel** encImg, Int width, Int height, Int win_w
C1 = K1 * K1 * max_pix_value_sqd;
C2 = K2 * K2 * max_pix_value_sqd;
for( j = 0; j <= height - win_height; j += overlapSize ) {
for( i = 0; i <= width - win_width; i += overlapSize ) {
for( j = 0; j <= height - win_height; j += overlapSize )
{
for( i = 0; i <= width - win_width; i += overlapSize )
{
imeanOrg = 0;
imeanEnc = 0;
ivarOrg = 0;
ivarEnc = 0;
icovOrgEnc = 0;
for( n = j; n < j + win_height; n++ ) {
for( m = i; m < i + win_width; m++ ) {
for( n = j; n < j + win_height; n++ )
{
for( m = i; m < i + win_width; m++ )
{
imeanOrg += refImg[n][m];
imeanEnc += encImg[n][m];
ivarOrg += refImg[n][m] * refImg[n][m];
@@ -1336,11 +1399,13 @@ Double PlaYUVerFrame::getSSIM( PlaYUVerFrame* Org, Int component )
Double dSSIM = 1;
if( component == LUMA )
{
dSSIM = compute_ssim( d->m_pppcInputPel[component], Org->getPelBufferYUV()[component], d->m_uiWidth, d->m_uiHeight, 8, 8, 255, 8 );
dSSIM = compute_ssim( d->m_pppcInputPel[component], Org->getPelBufferYUV()[component], d->m_uiWidth, d->m_uiHeight,
8, 8, 255, 8 );
}
else
{
dSSIM = compute_ssim( d->m_pppcInputPel[component], Org->getPelBufferYUV()[component], getChromaWidth(), getChromaHeight(), 4, 4, 255, 4 );
dSSIM = compute_ssim( d->m_pppcInputPel[component], Org->getPelBufferYUV()[component], getChromaWidth(),
getChromaHeight(), 4, 4, 255, 4 );
}
return dSSIM;
}
+6 -5
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
/* 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
@@ -99,8 +99,9 @@ public:
PlaYUVerFrame( const PlaYUVerFrame* other );
/**
* Creates and new frame with the configuration of an existing one and copy its contents.
* This function only copies a specific region from the existing frame
* Creates and new frame with the configuration of an existing one and copy
* its contents. This function only copies a specific region from the existing
* frame
*
* @param other existing frame to copy from
* @param posX position X to crop from
+9 -10
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
/* 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
@@ -23,20 +23,19 @@
*/
#include "PlaYUVerFramePixelFormats.h"
#include "config.h"
#include "LibMemory.h"
#include "PlaYUVerFrame.h"
#include "config.h"
#ifdef USE_FFMPEG
#include "StreamHandlerLibav.h"
#endif
#ifdef USE_SSE
#include <emmintrin.h>
#include <limits.h>
#include <smmintrin.h>
#endif
#include "LibMemory.h"
#include "PlaYUVerFrame.h"
#ifdef USE_FFMPEG
#include "StreamHandlerLibav.h"
#endif
/*
**************************************************************
* Handle different pel formats
+3 -3
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
/* 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
+3 -3
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
/* 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
+3 -3
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
/* 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
+46 -23
View File
@@ -37,21 +37,22 @@
*/
#include "PlaYUVerOptions.h"
#include "config.h"
#include "lib/PlaYUVerModuleIf.h"
#include "modules/PlaYUVerModuleFactory.h"
#include <cstring>
#include <sstream>
#include "lib/PlaYUVerModuleIf.h"
#include "modules/PlaYUVerModuleFactory.h"
using namespace std;
struct ParseFailure : public std::exception
{
String arg;
String val;
ParseFailure( String arg0, String val0 ) throw() : arg( arg0 ), val( val0 ) {}
ParseFailure( String arg0, String val0 ) throw()
: arg( arg0 ), val( val0 ) {}
~ParseFailure() throw() {}
const Char* what() const throw() { return "Option Parse Failure"; }
};
@@ -60,7 +61,8 @@ struct ParseFailure : public std::exception
class BoolOption : public OptionBase
{
public:
BoolOption( const String& name, const String& desc ) : OptionBase( name, desc ) { is_binary = true; }
BoolOption( const String& name, const String& desc )
: OptionBase( name, desc ) { is_binary = true; }
void parse( const String& arg ) { arg_count++; }
};
@@ -69,7 +71,11 @@ template <typename T>
class StandardOption : public OptionBase
{
public:
StandardOption( const String& name, T& storage, const String& desc ) : OptionBase( name, desc ), opt_storage( storage ) { is_binary = false; }
StandardOption( const String& name, T& storage, const String& desc )
: OptionBase( name, desc ), opt_storage( storage )
{
is_binary = false;
}
void parse( const String& arg );
T& opt_storage;
@@ -202,9 +208,12 @@ template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, UInt&
template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, Int& storage, const String& desc );
template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, Int64& storage, const String& desc );
template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, String& storage, const String& desc );
template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, std::vector<UInt>& storage, const String& desc );
template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, std::vector<Int>& storage, const String& desc );
template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, std::vector<String>& storage, const String& desc );
template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, std::vector<UInt>& storage,
const String& desc );
template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, std::vector<Int>& storage,
const String& desc );
template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, std::vector<String>& storage,
const String& desc );
/**
* Add option described by name to the parent Options list,
@@ -227,7 +236,8 @@ PlaYUVerOptions::PlaYUVerOptions( const String& name )
PlaYUVerOptions::~PlaYUVerOptions()
{
for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ ) {
for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ )
{
delete *it;
}
}
@@ -244,7 +254,8 @@ OptionBase* PlaYUVerOptions::getOption( const String& optName )
if( opt_it != opt_short_map.end() )
{
OptionsList opt_list = ( *opt_it ).second;
for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it ) {
for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it )
{
return ( *it )->opt;
}
}
@@ -252,7 +263,8 @@ OptionBase* PlaYUVerOptions::getOption( const String& optName )
if( opt_it != opt_long_map.end() )
{
OptionsList opt_list = ( *opt_it ).second;
for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it ) {
for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it )
{
return ( *it )->opt;
}
}
@@ -288,7 +300,8 @@ void PlaYUVerOptions::addOption( OptionBase* opt )
string& opt_string = opt->opt_string;
size_t opt_start = 0;
for( size_t opt_end = 0; opt_end != string::npos; ) {
for( size_t opt_end = 0; opt_end != string::npos; )
{
opt_end = opt_string.find_first_of( ',', opt_start );
bool force_short = 0;
if( opt_string[opt_start] == '-' )
@@ -316,7 +329,8 @@ static void setOptions( PlaYUVerOptions::OptionsList& opt_list, const string& va
{
/* multiple options may be registered for the same name:
* allow each to parse value */
for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it ) {
for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it )
{
( *it )->opt->parse( value );
}
}
@@ -487,7 +501,8 @@ list<const Char*> PlaYUVerOptions::scanArgv( UInt argc, Char* argv[] )
/* a list for anything that didn't get handled as an option */
list<const Char*> non_option_arguments;
for( UInt i = 1; i < argc; i++ ) {
for( UInt i = 1; i < argc; i++ )
{
if( argv[i][0] != '-' )
{
non_option_arguments.push_back( argv[i] );
@@ -515,7 +530,8 @@ list<const Char*> PlaYUVerOptions::scanArgv( UInt argc, Char* argv[] )
if( argv[i][2] == 0 )
{
/* a lone double dash ends option processing */
while( ++i < argc ) non_option_arguments.push_back( argv[i] );
while( ++i < argc )
non_option_arguments.push_back( argv[i] );
break;
}
@@ -528,7 +544,8 @@ list<const Char*> PlaYUVerOptions::scanArgv( UInt argc, Char* argv[] )
Void PlaYUVerOptions::parse( std::vector<String> args_array )
{
for( UInt i = 0; i < args_array.size(); i++ ) {
for( UInt i = 0; i < args_array.size(); i++ )
{
i += parseLONG( args_array[i] );
}
return;
@@ -572,7 +589,8 @@ Void PlaYUVerOptions::doHelp( ostream& out, UInt columns )
const UInt pad_short = 3;
/* first pass: work out the longest option name */
UInt max_width = 0;
for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ ) {
for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ )
{
ostringstream line( ios_base::out );
doHelpOpt( line, **it, pad_short );
max_width = max( max_width, (UInt)line.tellp() );
@@ -586,7 +604,8 @@ Void PlaYUVerOptions::doHelp( ostream& out, UInt columns )
* - if the option text is longer than opt_width, place the help
* text at opt_width on the next line.
*/
for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ ) {
for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ )
{
ostringstream line( ios_base::out );
line << " ";
doHelpOpt( line, **it, pad_short );
@@ -608,7 +627,8 @@ Void PlaYUVerOptions::doHelp( ostream& out, UInt columns )
}
/* split up the help text, taking into account new lines,
* (add opt_width of padding to each new line) */
for( size_t newline_pos = 0, cur_pos = 0; cur_pos != string::npos; currlength = 0 ) {
for( size_t newline_pos = 0, cur_pos = 0; cur_pos != string::npos; currlength = 0 )
{
/* print any required padding space for vertical alignment */
line << &( spaces[40 - opt_width + currlength] );
newline_pos = opt_desc.find_first_of( '\n', newline_pos );
@@ -673,7 +693,8 @@ Bool PlaYUVerOptions::checkListingOpts()
if( hasOpt( "pel_fmts" ) )
{
printf( "PlaYUVer supported pixel formats: \n" );
for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames().size(); i++ ) {
for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames().size(); i++ )
{
printf( " %s\n", PlaYUVerFrame::supportedPixelFormatListNames()[i].c_str() );
}
bRet |= true;
@@ -681,7 +702,8 @@ Bool PlaYUVerOptions::checkListingOpts()
if( hasOpt( "quality_metrics" ) )
{
printf( "PlaYUVer supported quality metrics: \n" );
for( UInt i = 0; i < PlaYUVerFrame::supportedQualityMetricsList().size(); i++ ) {
for( UInt i = 0; i < PlaYUVerFrame::supportedQualityMetricsList().size(); i++ )
{
printf( " %s\n", PlaYUVerFrame::supportedQualityMetricsList()[i].c_str() );
}
bRet |= true;
@@ -717,7 +739,8 @@ Void PlaYUVerOptions::listModules()
Char ModuleNameString[40];
for( UInt i = 0; it != PlaYUVerModuleFactoryMap.end(); ++it, i++ ) {
for( UInt i = 0; it != PlaYUVerModuleFactoryMap.end(); ++it, i++ )
{
printf( " " );
printf( "%-30s", it->first );
if( bDetailed )
+6 -4
View File
@@ -39,11 +39,11 @@
#ifndef __PROGRAMOPTIONS_H__
#define __PROGRAMOPTIONS_H__
#include "PlaYUVerDefs.h"
#include <list>
#include <map>
#include "PlaYUVerDefs.h"
/** OptionBase: Virtual base class for storing information relating to a
* specific option This base class describes common elements.
* Type specific information should be stored in a derived class.
@@ -51,7 +51,8 @@
class OptionBase
{
public:
OptionBase( const String& name, const String& desc ) : arg_count( 0 ), opt_string( name ), opt_desc( desc ) {}
OptionBase( const String& name, const String& desc )
: arg_count( 0 ), opt_string( name ), opt_desc( desc ) {}
virtual ~OptionBase() {}
/* parse argument arg, to obtain a value for the option */
virtual void parse( const String& arg ) = 0;
@@ -68,7 +69,8 @@ class PlaYUVerOptions
public:
struct Option
{
Option() : opt( 0 ) {}
Option()
: opt( 0 ) {}
~Option()
{
if( opt )
+7 -4
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
/* 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
@@ -23,11 +23,14 @@
*/
#include "PlaYUVerPixel.h"
#include "PlaYUVerFrame.h"
#include <cmath>
#include <cstdio>
PlaYUVerPixel::PlaYUVerPixel() : m_iColorSpace( COLOR_INVALID )
PlaYUVerPixel::PlaYUVerPixel()
: m_iColorSpace( COLOR_INVALID )
{
m_iColorSpace = COLOR_INVALID;
PixelComponents[0] = 0;
+4 -4
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
/* 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
@@ -25,11 +25,11 @@
#ifndef __PLAYUVERPIXEL_H__
#define __PLAYUVERPIXEL_H__
#include "PlaYUVerDefs.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 )
{
+37 -27
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
/* 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
@@ -24,17 +24,13 @@
// Self
#include "PlaYUVerStream.h"
#include "config.h"
// System
#include <cstdio>
// Own
#include "LibMemory.h"
#include "PlaYUVerFrame.h"
#include "PlaYUVerStreamHandlerIf.h"
#include "StreamHandlerPortableMap.h"
#include "StreamHandlerRaw.h"
#include "config.h"
#ifdef USE_FFMPEG
#include "StreamHandlerLibav.h"
#endif
@@ -42,6 +38,8 @@
#include "StreamHandlerOpenCV.h"
#endif
#include <cstdio>
class PlaYUVerStreamBufferPrivate
{
private:
@@ -51,7 +49,8 @@ private:
public:
PlaYUVerStreamBufferPrivate( UInt size, UInt width, UInt height, Int pelFormat, Int bitsPixel )
{
for( UInt i = 0; i < size; i++ ) {
for( UInt i = 0; i < size; i++ )
{
PlaYUVerFrame* pFrame = new PlaYUVerFrame( width, height, pelFormat, bitsPixel );
m_apcFrameBuffer.push_back( pFrame );
}
@@ -60,14 +59,16 @@ public:
~PlaYUVerStreamBufferPrivate()
{
while( m_apcFrameBuffer.size() > 0 ) {
while( m_apcFrameBuffer.size() > 0 )
{
delete m_apcFrameBuffer.back();
m_apcFrameBuffer.pop_back();
}
}
Void increase( UInt newSize )
{
for( UInt i = m_apcFrameBuffer.size(); i < newSize; i++ ) {
for( UInt i = m_apcFrameBuffer.size(); i < newSize; i++ )
{
PlaYUVerFrame* pFrame = new PlaYUVerFrame( m_apcFrameBuffer.at( 0 ) );
m_apcFrameBuffer.push_back( pFrame );
}
@@ -117,7 +118,8 @@ std::vector<String> PlaYUVerSupportedFormat::getExts()
{
std::vector<String> arrayExt;
String::size_type prev_pos = 0, pos = 0;
while( ( pos = formatExt.find( ',', pos ) ) != String::npos ) {
while( ( pos = formatExt.find( ',', pos ) ) != String::npos )
{
String substring( formatExt.substr( prev_pos, pos - prev_pos ) );
arrayExt.push_back( substring );
prev_pos = ++pos;
@@ -165,9 +167,11 @@ CreateStreamHandlerFn PlaYUVerStream::findStreamHandler( String strFilename, boo
{
supportedFmts = PlaYUVerStream::supportedWriteFormats();
}
for( UInt i = 0; i < supportedFmts.size(); i++ ) {
for( UInt i = 0; i < supportedFmts.size(); i++ )
{
std::vector<String> arrayExt = supportedFmts[i].getExts();
for( std::vector<String>::iterator e = arrayExt.begin(); e != arrayExt.end(); ++e ) {
for( std::vector<String>::iterator e = arrayExt.begin(); e != arrayExt.end(); ++e )
{
if( currExt != "" && currExt == *e )
{
return supportedFmts[i].formatFct;
@@ -206,7 +210,8 @@ String PlaYUVerStream::getCodecName()
return !m_pcHandler ? "" : m_pcHandler->getCodecName();
}
Bool PlaYUVerStream::open( String filename, String resolution, String input_format_name, UInt bitsPel, Int endianness, UInt frame_rate, Bool bInput )
Bool PlaYUVerStream::open( String filename, String resolution, String input_format_name, UInt bitsPel, Int endianness,
UInt frame_rate, Bool bInput )
{
UInt width = 0;
UInt height = 0;
@@ -220,7 +225,8 @@ Bool PlaYUVerStream::open( String filename, String resolution, String input_form
return false;
}
}
for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames().size(); i++ ) {
for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames().size(); i++ )
{
if( lowercase( PlaYUVerFrame::supportedPixelFormatListNames()[i] ) == lowercase( input_format_name ) )
{
input_format = i;
@@ -230,7 +236,8 @@ Bool PlaYUVerStream::open( String filename, String resolution, String input_form
return open( filename, width, height, input_format, bitsPel, endianness, frame_rate, bInput );
}
Bool PlaYUVerStream::open( String filename, UInt width, UInt height, Int input_format, UInt bitsPel, Int endianness, UInt frame_rate, Bool bInput )
Bool PlaYUVerStream::open( String filename, UInt width, UInt height, Int input_format, UInt bitsPel, Int endianness,
UInt frame_rate, Bool bInput )
{
if( m_bInit )
{
@@ -278,8 +285,9 @@ Bool PlaYUVerStream::open( String filename, UInt width, UInt height, Int input_f
// Keep past, current and future frames
try
{
m_frameBuffer = new PlaYUVerStreamBufferPrivate( m_bIsInput ? 3 : 1, m_pcHandler->m_uiWidth, m_pcHandler->m_uiHeight, m_pcHandler->m_iPixelFormat,
m_pcHandler->m_uiBitsPerPixel );
m_frameBuffer =
new PlaYUVerStreamBufferPrivate( m_bIsInput ? 3 : 1, m_pcHandler->m_uiWidth, m_pcHandler->m_uiHeight,
m_pcHandler->m_iPixelFormat, m_pcHandler->m_uiBitsPerPixel );
}
catch( PlaYUVerFailure& e )
{
@@ -321,15 +329,15 @@ Bool PlaYUVerStream::reload()
m_pcHandler->closeHandler();
if( !m_pcHandler->openHandler( m_cFilename, m_bIsInput ) )
{
throw PlaYUVerFailure( "PlaYUVerStream",
"Cannot open stream " + m_cFilename + " with the " + String( m_pcHandler->m_pchHandlerName ) + " handler" );
throw PlaYUVerFailure( "PlaYUVerStream", "Cannot open stream " + m_cFilename + " with the " +
String( m_pcHandler->m_pchHandlerName ) + " handler" );
}
m_pcHandler->m_uiNBytesPerFrame = m_frameBuffer->current()->getBytesPerFrame();
m_pcHandler->calculateFrameNumber();
m_pcHandler->configureBuffer( m_frameBuffer->current() );
if( m_pcHandler->m_uiWidth <= 0 || m_pcHandler->m_uiHeight <= 0 || m_pcHandler->m_iPixelFormat < 0 || m_pcHandler->m_uiBitsPerPixel == 0 ||
m_pcHandler->m_uiTotalNumberFrames == 0 )
if( m_pcHandler->m_uiWidth <= 0 || m_pcHandler->m_uiHeight <= 0 || m_pcHandler->m_iPixelFormat < 0 ||
m_pcHandler->m_uiBitsPerPixel == 0 || m_pcHandler->m_uiTotalNumberFrames == 0 )
{
return false;
}
@@ -388,7 +396,8 @@ Int PlaYUVerStream::getCurrFrameNum()
return m_iCurrFrameNum;
}
Void PlaYUVerStream::getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBitsPerPel, Int& rEndianness, UInt& rFrameRate )
Void PlaYUVerStream::getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBitsPerPel, Int& rEndianness,
UInt& rFrameRate )
{
if( m_bInit )
{
@@ -426,7 +435,8 @@ Void PlaYUVerStream::loadAll()
}
seekInput( 0 );
for( UInt i = 2; i < m_frameBuffer->size(); i++ ) {
for( UInt i = 2; i < m_frameBuffer->size(); i++ )
{
readFrame( m_frameBuffer->frame( i ) );
}
m_bLoadAll = true;
@@ -494,8 +504,8 @@ Bool PlaYUVerStream::saveFrame( const String& filename )
Bool PlaYUVerStream::saveFrame( const String& filename, PlaYUVerFrame* saveFrame )
{
PlaYUVerStream auxSaveStream;
if( !auxSaveStream.open( filename, saveFrame->getWidth(), saveFrame->getHeight(), saveFrame->getPelFormat(), saveFrame->getBitsPel(),
PLAYUVER_LITTLE_ENDIAN, 1, false ) )
if( !auxSaveStream.open( filename, saveFrame->getWidth(), saveFrame->getHeight(), saveFrame->getPelFormat(),
saveFrame->getBitsPel(), PLAYUVER_LITTLE_ENDIAN, 1, false ) )
{
return false;
}
+9 -6
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
/* 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
@@ -80,8 +80,10 @@ public:
String getFormatName();
String getCodecName();
Bool open( String filename, String resolution, String input_format, UInt bitsPel, Int endianness, UInt frame_rate, Bool bInput );
Bool open( String filename, UInt width, UInt height, Int input_format, UInt bitsPel, Int endianness, UInt frame_rate, Bool bInput );
Bool open( String filename, String resolution, String input_format, UInt bitsPel, Int endianness, UInt frame_rate,
Bool bInput );
Bool open( String filename, UInt width, UInt height, Int input_format, UInt bitsPel, Int endianness, UInt frame_rate,
Bool bInput );
Bool reload();
Void close();
@@ -92,7 +94,8 @@ public:
Int getEndianess() const;
Int getCurrFrameNum();
Double getFrameRate();
Void getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBitsPerPel, Int& rEndianness, UInt& rFrameRate );
Void getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBitsPerPel, Int& rEndianness,
UInt& rFrameRate );
Void loadAll();
+3 -3
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
/* 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
+15 -10
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
/* 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
@@ -23,6 +23,7 @@
*/
#include "StreamHandlerLibav.h"
#include "LibMemory.h"
#include "PlaYUVerFrame.h"
#include "PlaYUVerFramePixelFormats.h"
@@ -80,10 +81,12 @@ Bool StreamHandlerLibav::openHandler( String strFilename, Bool bInput )
// sprintf( aux_string, "%dx%d", m_uiWidth, m_uiHeight );
// av_dict_set( &format_opts, "video_size", aux_string, 0 );
// }
// Int ffmpeg_pel_format = g_PlaYUVerPixFmtDescriptorsList[m_iPixelFormat].ffmpegPelFormat;
// if( ffmpeg_pel_format >= 0 )
// Int ffmpeg_pel_format =
// g_PlaYUVerPixFmtDescriptorsList[m_iPixelFormat].ffmpegPelFormat; if(
// ffmpeg_pel_format >= 0 )
// {
// av_dict_set( &format_opts, "pix_fmt", av_get_pix_fmt_name( AVPixelFormat( ffmpeg_pel_format ) ), 0 );
// av_dict_set( &format_opts, "pix_fmt", av_get_pix_fmt_name(
// AVPixelFormat( ffmpeg_pel_format ) ), 0 );
// }
// Register all components of FFmpeg
@@ -197,7 +200,8 @@ Bool StreamHandlerLibav::openHandler( String strFilename, Bool bInput )
}
m_iPixelFormat = PlaYUVerFrame::NO_FMT;
for( Int i = 0; i < PlaYUVerFrame::NUMBER_PEL_FORMATS; i++ ) {
for( Int i = 0; i < PlaYUVerFrame::NUMBER_PEL_FORMATS; i++ )
{
if( g_PlaYUVerPixFmtDescriptorsList[i].ffmpegPelFormat == auxPixFmt )
{
m_iPixelFormat = i;
@@ -306,7 +310,8 @@ Bool StreamHandlerLibav::read( PlaYUVerFrame* pcFrame )
Bool bReadPkt = false;
Int iRet = 0;
while( !bGotFrame && !bErrors ) {
while( !bGotFrame && !bErrors )
{
#ifdef FF_SEND_RECEIVE_API
if( ( iRet = avcodec_receive_frame( m_cCodedCtx, m_cFrame ) ) < 0 )
{
@@ -352,8 +357,8 @@ Bool StreamHandlerLibav::read( PlaYUVerFrame* pcFrame )
if( bGotFrame )
{
av_image_copy_to_buffer( m_pStreamBuffer, m_uiFrameBufferSize, m_cFrame->data, m_cFrame->linesize, AVPixelFormat( m_ffPixFmt ), m_uiWidth,
m_uiHeight, 1 );
av_image_copy_to_buffer( m_pStreamBuffer, m_uiFrameBufferSize, m_cFrame->data, m_cFrame->linesize,
AVPixelFormat( m_ffPixFmt ), m_uiWidth, m_uiHeight, 1 );
pcFrame->frameFromBuffer( m_pStreamBuffer, m_iEndianness );
m_uiCurrFrameFileIdx++;
+3 -3
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
/* 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
+6 -9
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
/* 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
@@ -22,18 +22,15 @@
* \brief Interface with opencv lib
*/
// Self
#include "StreamHandlerOpenCV.h"
// System
#include <cstdio>
#include <opencv2/opencv.hpp>
// Own
#include "LibMemory.h"
#include "PlaYUVerFrame.h"
#include "PlaYUVerFramePixelFormats.h"
#include <cstdio>
#include <opencv2/opencv.hpp>
using cv::Mat;
using cv::VideoCapture;
+3 -3
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
/* 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
+5 -3
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
/* 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
@@ -23,9 +23,11 @@
*/
#include "StreamHandlerPortableMap.h"
#include "LibMemory.h"
#include "PlaYUVerFrame.h"
#include "PlaYUVerFramePixelFormats.h"
#include <cmath>
#include <cstdio>
+3 -3
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
/* 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
+5 -5
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
/* 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
@@ -24,12 +24,12 @@
#include "StreamHandlerRaw.h"
#include <cstdio>
#include "LibMemory.h"
#include "PlaYUVerFrame.h"
#include "PlaYUVerFramePixelFormats.h"
#include <cstdio>
std::vector<PlaYUVerSupportedFormat> StreamHandlerRaw::supportedReadFormats()
{
INI_REGIST_PLAYUVER_SUPPORTED_FMT;
+3 -3
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
/* 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