Change format ext api and re-format code

This commit is contained in:
jfmcarreira committed 2017-11-27 20:13:05 +00:00
1 parent 327f5921f5
commit 6fe8a0f69e
62 files changed
+1422 -2579

No files matched your search

+1
View File
@@ -12,6 +12,7 @@ set(PlaYUVer_Lib_SRCS
PlaYUVerFrame.cpp
PlaYUVerFramePixelFormats.cpp
# Stream
PlaYUVerStreamHandlerIf.h
PlaYUVerStream.cpp
StreamHandlerRaw.cpp
StreamHandlerPortableMap.cpp
+1 -4
View File
@@ -143,10 +143,7 @@ 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 class_name, String error_msg ) throw() : m_class_name( class_name ), m_error_msg( error_msg ) {}
~PlaYUVerFailure() throw() {}
const Char* what() const throw()
{
+30 -76
View File
@@ -77,17 +77,12 @@ Int PlaYUVerFrame::findPixelFormat( const String& name )
return -1;
}
static Int getImgMemory( Pel**** array3D,
Int dim1,
Int dim2,
Int log2ChromaHeight,
Int log2ChromaWidth )
static Int getImgMemory( Pel**** array3D, Int dim1, Int dim2, Int log2ChromaHeight, Int log2ChromaWidth )
{
Int dim0 = 3;
Int i;
UInt64 total_mem_size = 0;
UInt64 mem_size = ( dim1 * dim2 + CHROMASHIFT( dim1, log2ChromaHeight ) *
CHROMASHIFT( dim2, log2ChromaWidth ) * 2 );
UInt64 mem_size = ( dim1 * dim2 + CHROMASHIFT( dim1, log2ChromaHeight ) * CHROMASHIFT( dim2, log2ChromaWidth ) * 2 );
total_mem_size += getMem2D<Pel*>( array3D, dim0, dim1 );
@@ -194,8 +189,7 @@ 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 );
@@ -204,8 +198,7 @@ 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;
@@ -238,8 +231,7 @@ 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 );
}
@@ -259,11 +251,9 @@ 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()] );
const PlaYUVerPixFmtDescriptor* pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[other.getPelFormat()] );
if( pcPelFormat->log2ChromaWidth )
{
if( x % ( 1 << pcPelFormat->log2ChromaWidth ) )
@@ -285,18 +275,12 @@ 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;
const PlaYUVerPixFmtDescriptor* pcPelFormat =
&( g_PlaYUVerPixFmtDescriptorsList[other->getPelFormat()] );
const PlaYUVerPixFmtDescriptor* pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[other->getPelFormat()] );
if( pcPelFormat->log2ChromaWidth )
{
if( posX % ( 1 << pcPelFormat->log2ChromaWidth ) )
@@ -335,8 +319,7 @@ Bool PlaYUVerFrame::haveSameFmt( const PlaYUVerFrame& other, UInt match ) const
if( match & MATCH_BITS )
bRet &= ( getBitsPel() == other.getBitsPel() );
if( match & MATCH_COLOR_SPACE_IGNORE_GRAY )
bRet &= ( getColorSpace() == PlaYUVerPixel::COLOR_GRAY ||
getColorSpace() == other.getColorSpace() );
bRet &= ( getColorSpace() == PlaYUVerPixel::COLOR_GRAY || getColorSpace() == other.getColorSpace() );
return bRet;
}
@@ -423,18 +406,14 @@ UInt64 PlaYUVerFrame::getBytesPerFrame()
return getBytesPerFrame( d->m_uiWidth, d->m_uiHeight, d->m_iPixelFormat, d->m_uiBitsPel );
}
UInt64 PlaYUVerFrame::getBytesPerFrame( UInt uiWidth,
UInt uiHeight,
Int iPixelFormat,
UInt bitsPixel )
UInt64 PlaYUVerFrame::getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat, UInt bitsPixel )
{
const PlaYUVerPixFmtDescriptor* pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[iPixelFormat] );
UInt bytesPerPixel = ( bitsPixel - 1 ) / 8 + 1;
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;
@@ -451,8 +430,7 @@ Void PlaYUVerFrame::clear()
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;
}
@@ -489,8 +467,7 @@ 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 );
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;
@@ -500,9 +477,7 @@ PlaYUVerPixel PlaYUVerFrame::getPixelValue( Int xPos, Int yPos )
return PixelValue;
}
PlaYUVerPixel PlaYUVerFrame::getPixelValue( Int xPos,
Int yPos,
PlaYUVerPixel::ColorSpace eColorSpace )
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++ )
@@ -533,8 +508,7 @@ Void PlaYUVerFrame::copyFrom( const PlaYUVerFrame& other )
return;
d->m_bHasRGBPel = false;
d->m_bHasHistogram = false;
memcpy( *d->m_pppcInputPel[LUMA], other.getPelBufferYUV()[LUMA][0],
getBytesPerFrame() * sizeof( Pel ) );
memcpy( *d->m_pppcInputPel[LUMA], other.getPelBufferYUV()[LUMA][0], getBytesPerFrame() * sizeof( Pel ) );
}
Void PlaYUVerFrame::copyFrom( const PlaYUVerFrame* other )
@@ -554,8 +528,7 @@ Void PlaYUVerFrame::copyFrom( const PlaYUVerFrame& other, UInt xPos, UInt yPos )
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 ) );
memcpy( d->m_pppcInputPel[ch][i], &( pInput[ch][( yPos >> ratioH ) + i][( xPos >> ratioW )] ), ( d->m_uiWidth >> ratioW ) * sizeof( Pel ) );
}
}
d->m_bHasRGBPel = false;
@@ -602,8 +575,7 @@ Void PlaYUVerFrame::frameFromBuffer( Byte* Buff, Int iEndianness )
{
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;
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++ )
@@ -613,11 +585,9 @@ Void PlaYUVerFrame::frameFromBuffer( Byte* Buff, Int iEndianness )
step = d->m_pcPelFormat->comp[ch].step_minus1;
pPel = d->m_pppcInputPel[ch][0];
pTmpBuff =
ppBuff[d->m_pcPelFormat->comp[ch].plane] + ( d->m_pcPelFormat->comp[ch].offset_plus1 - 1 );
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 )
@@ -663,8 +633,7 @@ Void PlaYUVerFrame::frameToBuffer( Byte* output_buffer, Int iEndianness )
{
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;
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++ )
@@ -676,8 +645,7 @@ 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( i = 0; i < CHROMASHIFT( d->m_uiHeight, ratioH ) * CHROMASHIFT( d->m_uiWidth, ratioW ); i++ )
{
for( b = startByte; b != endByte; b += incByte )
{
@@ -838,8 +806,7 @@ Void PlaYUVerFrame::calcHistogram()
}
if( ( colorSpace == PlaYUVerPixel::COLOR_RGB || colorSpace == PlaYUVerPixel::COLOR_ARGB ) )
{
PlaYUVerPixel currPixel( colorSpace, *( data[COLOR_R] ), *( data[COLOR_G] ),
*( data[COLOR_B] ) );
PlaYUVerPixel currPixel( colorSpace, *( data[COLOR_R] ), *( data[COLOR_G] ), *( data[COLOR_B] ) );
luma = currPixel.ConvertPixel( PlaYUVerPixel::COLOR_YUV ).Y();
d->m_puiHistogram[luma + j * d->m_uiHistoSegments]++;
}
@@ -886,8 +853,7 @@ Int getRealHistoChannel( Int colorSpace, Int channel )
}
break;
case PlaYUVerPixel::COLOR_ARGB:
if( channel != COLOR_R && channel != COLOR_G && channel != COLOR_B && channel != COLOR_A &&
channel != LUMA )
if( channel != COLOR_R && channel != COLOR_G && channel != COLOR_B && channel != COLOR_A && channel != LUMA )
{
return -1;
}
@@ -1185,16 +1151,14 @@ 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;
@@ -1355,14 +1319,7 @@ 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;
@@ -1422,8 +1379,7 @@ float compute_ssim( Pel** refImg,
cur_distortion /= (float)win_cnt;
if( cur_distortion >= 1.0 &&
cur_distortion < 1.01 ) // avoid float accuracy problem at very low QP(e.g.2)
if( cur_distortion >= 1.0 && cur_distortion < 1.01 ) // avoid float accuracy problem at very low QP(e.g.2)
cur_distortion = 1.0;
return cur_distortion;
@@ -1434,13 +1390,11 @@ 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;
}
+108 -109
View File
@@ -199,112 +199,111 @@ Void fillARGB32bufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height, UI
}
#endif
const PlaYUVerPixFmtDescriptor g_PlaYUVerPixFmtDescriptorsList[PlaYUVerFrame::NUMBER_PEL_FORMATS] =
{{
"YUV420p",
PlaYUVerPixel::COLOR_YUV,
3,
3,
1,
1,
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUV420P ),
{
{0, 0, 1}, /* Y */
{1, 0, 1}, /* U */
{2, 0, 1}, /* V */
},
},
{
"YUV422p",
PlaYUVerPixel::COLOR_YUV,
3,
3,
1,
0,
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUV422P ),
{
{0, 0, 1}, /* Y */
{1, 0, 1}, /* U */
{2, 0, 1}, /* V */
},
},
{
"YUV444p",
PlaYUVerPixel::COLOR_YUV,
3,
3,
0,
0,
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUV444P ),
{
{0, 0, 1}, /* Y */
{1, 0, 1}, /* U */
{2, 0, 1}, /* V */
},
},
{
"YUYV422",
PlaYUVerPixel::COLOR_YUV,
3,
1,
1,
0,
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUYV422 ),
{
{0, 1, 1}, /* Y */
{0, 3, 2}, /* U */
{0, 3, 4}, /* V */
},
},
{
"GRAY",
PlaYUVerPixel::COLOR_GRAY,
1,
1,
0,
0,
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_GRAY8 ),
{{0, 0, 1}}, /* Y */
},
{
"RGBp",
PlaYUVerPixel::COLOR_RGB,
3,
3,
0,
0,
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_RGB24 ),
{
{0, 0, 1}, /* R */
{1, 0, 1}, /* G */
{2, 0, 1}, /* B */
},
},
{
"RGB",
PlaYUVerPixel::COLOR_RGB,
3,
1,
0,
0,
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_RGB24 ),
{
{0, 2, 1}, /* R */
{0, 2, 2}, /* G */
{0, 2, 3}, /* B */
},
},
{
"BGR",
PlaYUVerPixel::COLOR_RGB,
3,
1,
0,
0,
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_BGR24 ),
{
{0, 2, 3}, /* B */
{0, 2, 2}, /* R */
{0, 2, 1}, /* G */
},
}};
const PlaYUVerPixFmtDescriptor g_PlaYUVerPixFmtDescriptorsList[PlaYUVerFrame::NUMBER_PEL_FORMATS] = {{
"YUV420p",
PlaYUVerPixel::COLOR_YUV,
3,
3,
1,
1,
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUV420P ),
{
{0, 0, 1}, /* Y */
{1, 0, 1}, /* U */
{2, 0, 1}, /* V */
},
},
{
"YUV422p",
PlaYUVerPixel::COLOR_YUV,
3,
3,
1,
0,
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUV422P ),
{
{0, 0, 1}, /* Y */
{1, 0, 1}, /* U */
{2, 0, 1}, /* V */
},
},
{
"YUV444p",
PlaYUVerPixel::COLOR_YUV,
3,
3,
0,
0,
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUV444P ),
{
{0, 0, 1}, /* Y */
{1, 0, 1}, /* U */
{2, 0, 1}, /* V */
},
},
{
"YUYV422",
PlaYUVerPixel::COLOR_YUV,
3,
1,
1,
0,
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUYV422 ),
{
{0, 1, 1}, /* Y */
{0, 3, 2}, /* U */
{0, 3, 4}, /* V */
},
},
{
"GRAY",
PlaYUVerPixel::COLOR_GRAY,
1,
1,
0,
0,
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_GRAY8 ),
{{0, 0, 1}}, /* Y */
},
{
"RGBp",
PlaYUVerPixel::COLOR_RGB,
3,
3,
0,
0,
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_RGB24 ),
{
{0, 0, 1}, /* R */
{1, 0, 1}, /* G */
{2, 0, 1}, /* B */
},
},
{
"RGB",
PlaYUVerPixel::COLOR_RGB,
3,
1,
0,
0,
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_RGB24 ),
{
{0, 2, 1}, /* R */
{0, 2, 2}, /* G */
{0, 2, 3}, /* B */
},
},
{
"BGR",
PlaYUVerPixel::COLOR_RGB,
3,
1,
0,
0,
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_BGR24 ),
{
{0, 2, 3}, /* B */
{0, 2, 2}, /* R */
{0, 2, 1}, /* G */
},
}};
+1 -2
View File
@@ -33,8 +33,7 @@
#define CHROMARATIO( SIZE, RATIO ) ( RATIO > 1 ? ( ( SIZE + 1 ) / RATIO ) : SIZE )
#define PEL_RGB( r, g, b ) \
( 0xffu << 24 ) | ( ( r & 0xff ) << 16 ) | ( ( g & 0xff ) << 8 ) | ( b & 0xff )
#define PEL_RGB( r, g, b ) ( 0xffu << 24 ) | ( ( r & 0xff ) << 16 ) | ( ( g & 0xff ) << 8 ) | ( b & 0xff )
typedef struct PlaYUVerComponentDescriptor
{
+11 -37
View File
@@ -60,10 +60,7 @@ 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++; }
};
@@ -72,11 +69,7 @@ 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;
@@ -204,30 +197,14 @@ PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, T& storage, co
return *this;
}
template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name,
Bool& storage,
const String& desc );
template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name,
UInt& storage,
const String& desc );
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, Bool& storage, const String& desc );
template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, UInt& storage, const String& desc );
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 );
/**
* Add option described by name to the parent Options list,
@@ -349,10 +326,7 @@ static void setOptions( PlaYUVerOptions::OptionsList& opt_list, const string& va
}
}
Bool PlaYUVerOptions::storePair( Bool allow_long,
Bool allow_short,
const string& name,
const string& value )
Bool PlaYUVerOptions::storePair( Bool allow_long, Bool allow_short, const string& name, const string& value )
{
bool found = false;
PlaYUVerOptions::OptionMap::iterator opt_it;
+1 -4
View File
@@ -51,10 +51,7 @@
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;
+2 -12
View File
@@ -31,12 +31,7 @@
#include <iostream>
#include <vector>
static inline Void YuvToRgb( const Int& iY,
const Int& iU,
const Int& iV,
Int& iR,
Int& iG,
Int& iB )
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 );
@@ -46,12 +41,7 @@ static inline Void YuvToRgb( const Int& iY,
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 )
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;
+37 -47
View File
@@ -91,12 +91,8 @@ private:
std::vector<PlaYUVerSupportedFormat> PlaYUVerStream::supportedReadFormats()
{
INI_REGIST_PLAYUVER_SUPPORTED_FMT;
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerRaw::Create, "Raw YUV Video", "yuv" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerRaw::Create, "Raw Gray Video", "gray" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerRaw::Create, "Raw RGB Video", "rgb" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerPortableMap::Create, "Portable BitMap ", "pbm" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerPortableMap::Create, "Portable GrayMap ", "pgm" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerPortableMap::Create, "Portable PixMap ", "ppm" );
APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerRaw, Read );
APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerPortableMap, Read );
#ifdef USE_FFMPEG
APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerLibav, Read );
#endif
@@ -109,9 +105,8 @@ std::vector<PlaYUVerSupportedFormat> PlaYUVerStream::supportedReadFormats()
std::vector<PlaYUVerSupportedFormat> PlaYUVerStream::supportedWriteFormats()
{
INI_REGIST_PLAYUVER_SUPPORTED_FMT;
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerRaw::Create, "Raw Video", "yuv" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerPortableMap::Create, "Portable BitMap ", "pbm" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerPortableMap::Create, "Portable GrayMap ", "pgm" );
APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerRaw, Write );
APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerPortableMap, Write );
#ifdef USE_FFMPEG
APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerLibav, Write );
#endif
@@ -121,6 +116,20 @@ std::vector<PlaYUVerSupportedFormat> PlaYUVerStream::supportedWriteFormats()
END_REGIST_PLAYUVER_SUPPORTED_FMT;
}
std::vector<String> PlaYUVerSupportedFormat::getExts()
{
std::vector<String> arrayExt;
String::size_type prev_pos = 0, pos = 0;
while( ( pos = formatExt.find( ',', pos ) ) != String::npos )
{
String substring( formatExt.substr( prev_pos, pos - prev_pos ) );
arrayExt.push_back( substring );
prev_pos = ++pos;
}
arrayExt.push_back( formatExt.substr( prev_pos, pos - prev_pos ) ); // Last word
return arrayExt;
}
std::vector<PlaYUVerStdResolution> PlaYUVerStream::stdResolutionSizes()
{
#define REGIST_PLAYUVER_STANDARD_RESOLUTION( name, width, height ) \
@@ -162,13 +171,17 @@ CreateStreamHandlerFn PlaYUVerStream::findStreamHandler( String strFilename, boo
}
for( UInt i = 0; i < supportedFmts.size(); i++ )
{
if( currExt != "" && supportedFmts[i].formatExt == currExt )
std::vector<String> arrayExt = supportedFmts[i].getExts();
for( std::vector<String>::iterator e = arrayExt.begin(); e != arrayExt.end(); ++e )
{
return supportedFmts[i].formatFct;
}
else if( strFilename.find( supportedFmts[i].formatExt ) != String::npos )
{
return supportedFmts[i].formatFct;
if( currExt != "" && currExt == *e )
{
return supportedFmts[i].formatFct;
}
else if( strFilename.find( *e ) != String::npos )
{
return supportedFmts[i].formatFct;
}
}
}
return &StreamHandlerRaw::Create;
@@ -200,13 +213,7 @@ 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;
@@ -222,8 +229,7 @@ Bool PlaYUVerStream::open( String filename,
}
for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames().size(); i++ )
{
if( lowercase( PlaYUVerFrame::supportedPixelFormatListNames()[i] ) ==
lowercase( input_format_name ) )
if( lowercase( PlaYUVerFrame::supportedPixelFormatListNames()[i] ) == lowercase( input_format_name ) )
{
input_format = i;
break;
@@ -232,14 +238,7 @@ Bool PlaYUVerStream::open( String filename,
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 +277,7 @@ Bool PlaYUVerStream::open( String filename,
return m_bInit;
}
if( m_pcHandler->m_uiWidth <= 0 || m_pcHandler->m_uiHeight <= 0 ||
m_pcHandler->m_iPixelFormat < 0 )
if( m_pcHandler->m_uiWidth <= 0 || m_pcHandler->m_uiHeight <= 0 || m_pcHandler->m_iPixelFormat < 0 )
{
close();
throw PlaYUVerFailure( "PlaYUVerStream", "Incorrect configuration" );
@@ -289,9 +287,8 @@ Bool PlaYUVerStream::open( String filename,
// 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 )
{
@@ -340,8 +337,7 @@ Bool PlaYUVerStream::reload()
m_pcHandler->setBytesPerFrame( m_frameBuffer->current()->getBytesPerFrame() );
m_uiTotalFrameNum = m_pcHandler->calculateFrameNumber();
if( m_pcHandler->m_uiWidth <= 0 || m_pcHandler->m_uiHeight <= 0 ||
m_pcHandler->m_iPixelFormat < 0 || m_pcHandler->m_uiBitsPerPixel == 0 ||
if( m_pcHandler->m_uiWidth <= 0 || m_pcHandler->m_uiHeight <= 0 || m_pcHandler->m_iPixelFormat < 0 || m_pcHandler->m_uiBitsPerPixel == 0 ||
m_uiTotalFrameNum < 1 )
{
return false;
@@ -401,12 +397,7 @@ 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 )
{
@@ -513,8 +504,7 @@ 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(),
if( !auxSaveStream.open( filename, saveFrame->getWidth(), saveFrame->getHeight(), saveFrame->getPelFormat(), saveFrame->getBitsPel(),
PLAYUVER_LITTLE_ENDIAN, 1, false ) )
{
return false;
+5 -43
View File
@@ -44,32 +44,12 @@ typedef struct
{
String formatName;
String formatExt;
std::vector<String> getExts();
String formatPattern;
CreateStreamHandlerFn formatFct;
} PlaYUVerSupportedFormat;
#define INI_REGIST_PLAYUVER_SUPPORTED_FMT \
std::vector<PlaYUVerSupportedFormat> formatsList; \
PlaYUVerSupportedFormat formatElem;
#define END_REGIST_PLAYUVER_SUPPORTED_FMT return formatsList;
#define REGIST_PLAYUVER_SUPPORTED_FMT( handler, name, ext ) \
formatElem.formatName = name; \
formatElem.formatExt = lowercase( ext ); \
formatElem.formatFct = handler; \
formatsList.push_back( formatElem );
#define REGIST_PLAYUVER_SUPPORTED_ABSTRACT_FMT( handler, name, pattern ) \
formatElem.formatPattern = pattern; \
REGIST_PLAYUVER_SUPPORTED_FMT( handler, name, "" )
#define APPEND_PLAYUVER_SUPPORTED_FMT( class_name, fct ) \
{ \
std::vector<PlaYUVerSupportedFormat> new_fmts = class_name::supported##fct##Formats(); \
formatsList.insert( formatsList.end(), new_fmts.begin(), new_fmts.end() ); \
}
/**
* \class PlaYUVerStream
* \ingroup PlaYUVerLib PlaYUVerLib_Stream
@@ -100,21 +80,8 @@ 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();
@@ -125,12 +92,7 @@ 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();
+30 -4
View File
@@ -30,10 +30,36 @@
class PlaYUVerFrame;
#define REGISTER_STREAM_HANDLER( X ) \
public: \
static PlaYUVerStreamHandlerIf* Create() { return new X(); } \
void Delete() { delete this; }
#define INI_REGIST_PLAYUVER_SUPPORTED_FMT \
std::vector<PlaYUVerSupportedFormat> formatsList; \
PlaYUVerSupportedFormat formatElem;
#define END_REGIST_PLAYUVER_SUPPORTED_FMT return formatsList;
#define REGIST_PLAYUVER_SUPPORTED_FMT( handler, name, ext ) \
formatElem.formatName = name; \
formatElem.formatExt = lowercase( ext ); \
formatElem.formatFct = handler; \
formatsList.push_back( formatElem );
#define REGIST_PLAYUVER_SUPPORTED_ABSTRACT_FMT( handler, name, pattern ) \
formatElem.formatPattern = pattern; \
REGIST_PLAYUVER_SUPPORTED_FMT( handler, name, "" )
#define APPEND_PLAYUVER_SUPPORTED_FMT( class_name, fct ) \
{ \
std::vector<PlaYUVerSupportedFormat> new_fmts = class_name::supported##fct##Formats(); \
formatsList.insert( formatsList.end(), new_fmts.begin(), new_fmts.end() ); \
}
#define REGISTER_STREAM_HANDLER( X ) \
public: \
static PlaYUVerStreamHandlerIf* Create() { return new X(); } \
void Delete() { delete this; } \
static std::vector<PlaYUVerSupportedFormat> supportedReadFormats(); \
static std::vector<PlaYUVerSupportedFormat> supportedWriteFormats(); \
// static Int checkforSupportedFile( String, Bool );
/**
* \class PlaYUVerStreamHandlerIf
* \ingroup PlaYUVerLib_Stream
+40 -17
View File
@@ -40,17 +40,15 @@ std::vector<PlaYUVerSupportedFormat> StreamHandlerLibav::supportedReadFormats()
{
INI_REGIST_PLAYUVER_SUPPORTED_FMT;
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Portable Network Graphics", "png" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Joint Photographic Experts Group",
"jpg" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Joint Photographic Experts Group", "jpg,jpeg" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Windows Bitmap", "bmp" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Tagged Image File Format", "tiff" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Audio video interleaved", "avi" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Windows media video", "wmv" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "MPEG4", "mp4" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Matroska Multimedia Container",
"mkv" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "H.264 streams", "h264" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "HEVC streams", "hevc" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Matroska Multimedia Container", "mkv" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "H.264 streams", "264,h264" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "HEVC streams", "265,hevc" );
END_REGIST_PLAYUVER_SUPPORTED_FMT;
}
@@ -60,6 +58,38 @@ std::vector<PlaYUVerSupportedFormat> StreamHandlerLibav::supportedWriteFormats()
END_REGIST_PLAYUVER_SUPPORTED_FMT;
}
StreamHandlerLibav::StreamHandlerLibav()
{
/* register all formats and codecs */
av_register_all();
}
// Int StreamHandlerLibav::checkforSupportedFile( String strFilename, Bool bRead )
//{
// Int iRet;
// /* register all formats and codecs */
// av_register_all();
// AVDictionary* fmtOpts = NULL;
// AVFormatContext* fmtCtx;
// /* register all formats and codecs */
// av_register_all();
// /* open input file, and allocate format context */
// if( ( iRet = avformat_open_input( &fmtCtx, strFilename.c_str(), NULL, &fmtOpts ) ) < 0 )
// {
// return iRet;
// }
// /* retrieve stream information */
// iRet = avformat_find_stream_info( fmtCtx, NULL );
// /* close format context */
// avformat_close_input( &fmtCtx );
// return iRet < 0 ? 0 : 1;
//}
Bool StreamHandlerLibav::openHandler( String strFilename, Bool bInput )
{
const char* filename = strFilename.c_str();
@@ -77,9 +107,6 @@ Bool StreamHandlerLibav::openHandler( String strFilename, Bool bInput )
AVDictionary* format_opts = NULL;
/* register all formats and codecs */
av_register_all();
// if( width > 0 && height > 0 )
// {
// Char aux_string[10];
@@ -143,15 +170,13 @@ Bool StreamHandlerLibav::openHandler( String strFilename, Bool bInput )
}
#ifdef FF_USER_CODEC_PARAM
m_uiFrameBufferSize = av_image_get_buffer_size( AVPixelFormat( codec_param->format ),
codec_param->width, codec_param->height, 1 );
m_uiFrameBufferSize = av_image_get_buffer_size( AVPixelFormat( codec_param->format ), codec_param->width, codec_param->height, 1 );
Int pix_fmt = codec_param->format;
m_uiWidth = codec_param->width;
m_uiHeight = codec_param->height;
#else
m_uiFrameBufferSize = av_image_get_buffer_size(
m_cStream->codec->pix_fmt, m_cStream->codec->width, m_cStream->codec->height, 1 );
m_uiFrameBufferSize = av_image_get_buffer_size( m_cStream->codec->pix_fmt, m_cStream->codec->width, m_cStream->codec->height, 1 );
Int pix_fmt = m_cStream->codec->pix_fmt;
m_uiWidth = m_cStream->codec->width;
@@ -373,12 +398,10 @@ Bool StreamHandlerLibav::read( PlaYUVerFrame* pcFrame )
{
#ifdef FF_USER_CODEC_PARAM
AVCodecParameters* codec_param = m_cStream->codecpar;
av_image_copy_to_buffer( m_pStreamBuffer, m_uiFrameBufferSize, m_cFrame->data,
m_cFrame->linesize, AVPixelFormat( codec_param->format ),
av_image_copy_to_buffer( m_pStreamBuffer, m_uiFrameBufferSize, m_cFrame->data, m_cFrame->linesize, AVPixelFormat( codec_param->format ),
codec_param->width, codec_param->height, 1 );
#else
av_image_copy_to_buffer( m_pStreamBuffer, m_uiFrameBufferSize, m_cFrame->data,
m_cFrame->linesize, m_cCodedCtx->pix_fmt, m_cCodedCtx->width,
av_image_copy_to_buffer( m_pStreamBuffer, m_uiFrameBufferSize, m_cFrame->data, m_cFrame->linesize, m_cCodedCtx->pix_fmt, m_cCodedCtx->width,
m_cCodedCtx->height, 1 );
#endif
+1 -4
View File
@@ -59,10 +59,7 @@ class StreamHandlerLibav : public PlaYUVerStreamHandlerIf
REGISTER_STREAM_HANDLER( StreamHandlerLibav )
public:
static std::vector<PlaYUVerSupportedFormat> supportedReadFormats();
static std::vector<PlaYUVerSupportedFormat> supportedWriteFormats();
StreamHandlerLibav() {}
StreamHandlerLibav();
~StreamHandlerLibav() {}
Bool openHandler( String strFilename, Bool bInput );
Void closeHandler();
+2 -4
View File
@@ -51,8 +51,7 @@ std::vector<PlaYUVerSupportedFormat> StreamHandlerOpenCV::supportedWriteFormats(
INI_REGIST_PLAYUVER_SUPPORTED_FMT;
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerOpenCV::Create, "Portable PixMap ", "ppm" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerOpenCV::Create, "Portable Network Graphics", "png" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerOpenCV::Create, "Joint Photographic Experts Group",
"jpg" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerOpenCV::Create, "Joint Photographic Experts Group", "jpg" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerOpenCV::Create, "Windows Bitmap", "bmp" );
END_REGIST_PLAYUVER_SUPPORTED_FMT;
}
@@ -89,8 +88,7 @@ Bool StreamHandlerOpenCV::openHandler( String strFilename, Bool bInput )
else
#endif
{
m_strCodecName = m_strFormatName =
uppercase( strFilename.substr( strFilename.find_last_of( "." ) + 1 ) );
m_strCodecName = m_strFormatName = uppercase( strFilename.substr( strFilename.find_last_of( "." ) + 1 ) );
Mat cvMat = cv::imread( m_cFilename );
m_uiWidth = cvMat.cols;
m_uiHeight = cvMat.rows;
-3
View File
@@ -40,9 +40,6 @@ class StreamHandlerOpenCV : public PlaYUVerStreamHandlerIf
REGISTER_STREAM_HANDLER( StreamHandlerOpenCV )
public:
static std::vector<PlaYUVerSupportedFormat> supportedReadFormats();
static std::vector<PlaYUVerSupportedFormat> supportedWriteFormats();
StreamHandlerOpenCV();
~StreamHandlerOpenCV() {}
Bool openHandler( String strFilename, Bool bInput );
+18 -2
View File
@@ -29,6 +29,23 @@
#include <cmath>
#include <cstdio>
std::vector<PlaYUVerSupportedFormat> StreamHandlerPortableMap::supportedReadFormats()
{
INI_REGIST_PLAYUVER_SUPPORTED_FMT;
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerPortableMap::Create, "Portable BitMap ", "pbm" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerPortableMap::Create, "Portable GrayMap ", "pgm" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerPortableMap::Create, "Portable PixMap ", "ppm" );
END_REGIST_PLAYUVER_SUPPORTED_FMT;
}
std::vector<PlaYUVerSupportedFormat> StreamHandlerPortableMap::supportedWriteFormats()
{
INI_REGIST_PLAYUVER_SUPPORTED_FMT;
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerPortableMap::Create, "Portable BitMap ", "pbm" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerPortableMap::Create, "Portable GrayMap ", "pgm" );
END_REGIST_PLAYUVER_SUPPORTED_FMT;
}
Bool StreamHandlerPortableMap::openHandler( String strFilename, Bool bInput )
{
m_bIsInput = bInput;
@@ -62,8 +79,7 @@ Bool StreamHandlerPortableMap::openHandler( String strFilename, Bool bInput )
;
sscanf( line, "%d", &m_iMaxValue );
m_uiBitsPerPixel = log( m_iMaxValue + 1 ) / log( 2 );
m_iPixelFormat =
m_iMagicNumber == 2 || m_iMagicNumber == 5 ? PlaYUVerFrame::GRAY : PlaYUVerFrame::RGB24;
m_iPixelFormat = m_iMagicNumber == 2 || m_iMagicNumber == 5 ? PlaYUVerFrame::GRAY : PlaYUVerFrame::RGB24;
}
}
else
+16
View File
@@ -30,6 +30,22 @@
#include "PlaYUVerFrame.h"
#include "PlaYUVerFramePixelFormats.h"
std::vector<PlaYUVerSupportedFormat> StreamHandlerRaw::supportedReadFormats()
{
INI_REGIST_PLAYUVER_SUPPORTED_FMT;
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerRaw::Create, "Raw YUV Video", "yuv" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerRaw::Create, "Raw Gray Video", "gray" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerRaw::Create, "Raw RGB Video", "rgb" );
END_REGIST_PLAYUVER_SUPPORTED_FMT;
}
std::vector<PlaYUVerSupportedFormat> StreamHandlerRaw::supportedWriteFormats()
{
INI_REGIST_PLAYUVER_SUPPORTED_FMT;
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerRaw::Create, "Raw Video", "yuv" );
END_REGIST_PLAYUVER_SUPPORTED_FMT;
}
Bool StreamHandlerRaw::openHandler( String strFilename, Bool bInput )
{
m_bIsInput = bInput;