Fix CalypStream and CalypFrame methods
This commit is contained in:
6 files changed
+203
-200
No files matched your search
+25
-29
@@ -217,43 +217,39 @@ public:
|
||||
|
||||
int getRealHistogramChannel( int channel )
|
||||
{
|
||||
int realChannel = -1;
|
||||
if( channel == CalypFrame::HIST_ALL_CHANNELS )
|
||||
if( channel < 0 )
|
||||
{
|
||||
realChannel = channel;
|
||||
assert( false );
|
||||
return 0;
|
||||
}
|
||||
else if( channel >= 0 && channel < 4 )
|
||||
if( channel < HistogramChannels::HIST_LUMA || channel == HistogramChannels::HIST_ALL_CHANNELS )
|
||||
{
|
||||
realChannel = channel;
|
||||
return channel;
|
||||
}
|
||||
else if( m_pcPelFormat->colorSpace == CLP_COLOR_GRAY )
|
||||
|
||||
if( m_pcPelFormat->colorSpace == CLP_COLOR_GRAY && channel == HistogramChannels::HIST_LUMA )
|
||||
{
|
||||
if( channel >= 10 && channel < 11 )
|
||||
return channel - HistogramChannels::HIST_LUMA;
|
||||
}
|
||||
|
||||
if( m_pcPelFormat->colorSpace == CLP_COLOR_YUV && channel >= HistogramChannels::HIST_LUMA && channel < HistogramChannels::HIST_CHROMA_V )
|
||||
{
|
||||
return channel - HistogramChannels::HIST_LUMA;
|
||||
}
|
||||
|
||||
if( m_pcPelFormat->colorSpace == CLP_COLOR_RGB || m_pcPelFormat->colorSpace == CLP_COLOR_RGBA )
|
||||
{
|
||||
if( channel == HistogramChannels::HIST_LUMA )
|
||||
{
|
||||
realChannel = channel - 10;
|
||||
return m_uiHistoChannels - 1;
|
||||
}
|
||||
if( channel >= HistogramChannels::HIST_COLOR_R && channel <= HistogramChannels::HIST_COLOR_A )
|
||||
{
|
||||
return channel - CLP_COLOR_R;
|
||||
}
|
||||
}
|
||||
else if( m_pcPelFormat->colorSpace == CLP_COLOR_YUV )
|
||||
{
|
||||
if( channel >= 10 && channel < 13 )
|
||||
{
|
||||
realChannel = channel - 10;
|
||||
}
|
||||
}
|
||||
else if( m_pcPelFormat->colorSpace == CLP_COLOR_RGB || m_pcPelFormat->colorSpace == CLP_COLOR_RGBA )
|
||||
{
|
||||
if( channel == CalypFrame::HIST_LUMA )
|
||||
{
|
||||
realChannel = m_uiHistoChannels - 1;
|
||||
}
|
||||
if( channel >= 20 && channel < 24 )
|
||||
{
|
||||
realChannel = channel - 20;
|
||||
}
|
||||
}
|
||||
if( realChannel > (int)m_uiHistoChannels )
|
||||
realChannel = -1;
|
||||
return realChannel;
|
||||
assert( false );
|
||||
return 0;
|
||||
}
|
||||
|
||||
~CalypFramePrivate()
|
||||
|
||||
+136
-136
@@ -146,11 +146,11 @@ public:
|
||||
friend std::ostream& operator<<( std::ostream& os, const CalypPixel& p );
|
||||
|
||||
/**
|
||||
* Convert a Pixel to a new color space
|
||||
* @param inputPixel input pixel (CalypPixel)
|
||||
* @param eOutputSpace output color space
|
||||
* @return converted pixel
|
||||
*/
|
||||
* Convert a Pixel to a new color space
|
||||
* @param inputPixel input pixel (CalypPixel)
|
||||
* @param eOutputSpace output color space
|
||||
* @return converted pixel
|
||||
*/
|
||||
CalypPixel convertPixel( CalypColorSpace eOutputSpace ) const;
|
||||
};
|
||||
|
||||
@@ -207,17 +207,17 @@ class CalypFrame
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Function that handles the supported color space
|
||||
* of CalypFrame
|
||||
* @return vector of strings with pixel formats names
|
||||
*/
|
||||
* Function that handles the supported color space
|
||||
* of CalypFrame
|
||||
* @return vector of strings with pixel formats names
|
||||
*/
|
||||
static std::vector<std::string> supportedColorSpacesListNames();
|
||||
|
||||
/**
|
||||
* Function that handles the supported pixel formats
|
||||
* of CalypFrame
|
||||
* @return vector of strings with pixel formats names
|
||||
*/
|
||||
* Function that handles the supported pixel formats
|
||||
* of CalypFrame
|
||||
* @return vector of strings with pixel formats names
|
||||
*/
|
||||
static std::vector<std::string> supportedPixelFormatListNames();
|
||||
static std::vector<std::string> supportedPixelFormatListNames( int colorSpace );
|
||||
static int numberOfFormats();
|
||||
@@ -225,14 +225,14 @@ public:
|
||||
static int pelformatColorSpace( const int idx );
|
||||
|
||||
/**
|
||||
* Creates a new frame using the following configuration
|
||||
*
|
||||
* @param width width of the frame
|
||||
* @param height height of the frame
|
||||
* @param pel_format pixel format index (always use PixelFormats enum)
|
||||
*
|
||||
* @note this function might misbehave if the pixel format enum is not correct
|
||||
*/
|
||||
* Creates a new frame using the following configuration
|
||||
*
|
||||
* @param width width of the frame
|
||||
* @param height height of the frame
|
||||
* @param pel_format pixel format index (always use PixelFormats enum)
|
||||
*
|
||||
* @note this function might misbehave if the pixel format enum is not correct
|
||||
*/
|
||||
CalypFrame( unsigned int width, unsigned int height, int pelFormat, unsigned bitsPixel = 8 );
|
||||
|
||||
/**
|
||||
@@ -261,10 +261,10 @@ public:
|
||||
CalypFrame& operator=( CalypFrame&& other ) noexcept;
|
||||
|
||||
/**
|
||||
* Copy contructor
|
||||
*
|
||||
* @param other existing frame to copy from
|
||||
*/
|
||||
* Copy contructor
|
||||
*
|
||||
* @param other existing frame to copy from
|
||||
*/
|
||||
CalypFrame( const CalypFrame& other );
|
||||
|
||||
/**
|
||||
@@ -275,23 +275,23 @@ public:
|
||||
CalypFrame& operator=( const CalypFrame& 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
|
||||
*
|
||||
* @param other existing frame to copy from
|
||||
* @param posX position X to crop from
|
||||
* @param posY position Y to crop from
|
||||
* @param areaWidth crop width
|
||||
* @param areaHeight crop height
|
||||
*/
|
||||
* 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
|
||||
* @param posY position Y to crop from
|
||||
* @param areaWidth crop width
|
||||
* @param areaHeight crop height
|
||||
*/
|
||||
CalypFrame( const CalypFrame& other, unsigned int x, unsigned int y, unsigned int width, unsigned int height );
|
||||
CalypFrame( const CalypFrame* other, unsigned int x, unsigned int y, unsigned int width, unsigned int height );
|
||||
|
||||
~CalypFrame();
|
||||
|
||||
/** Format match opts
|
||||
*/
|
||||
*/
|
||||
enum FormatMatching
|
||||
{
|
||||
MATCH_COLOR_SPACE = 1,
|
||||
@@ -304,50 +304,50 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if two CalypFrames have the same fmt
|
||||
* @param other frame to compare with
|
||||
* @param match matching conditions (use enum FormatMatching)
|
||||
* @return true if format matches
|
||||
*/
|
||||
* Check if two CalypFrames have the same fmt
|
||||
* @param other frame to compare with
|
||||
* @param match matching conditions (use enum FormatMatching)
|
||||
* @return true if format matches
|
||||
*/
|
||||
bool haveSameFmt( const CalypFrame& other, unsigned int match = MATCH_ALL ) const;
|
||||
bool haveSameFmt( const CalypFrame* other, unsigned int match = MATCH_ALL ) const;
|
||||
|
||||
/**
|
||||
* Get pixel format information
|
||||
* @return pixel format index
|
||||
*/
|
||||
* Get pixel format information
|
||||
* @return pixel format index
|
||||
*/
|
||||
int getPelFormat() const;
|
||||
|
||||
/**
|
||||
* Get pixel format information
|
||||
* @return pixel format name
|
||||
*/
|
||||
* Get pixel format information
|
||||
* @return pixel format name
|
||||
*/
|
||||
std::string getPelFmtName() const;
|
||||
|
||||
/**
|
||||
* Get color space information
|
||||
* @return get color space index
|
||||
*/
|
||||
* Get color space information
|
||||
* @return get color space index
|
||||
*/
|
||||
int getColorSpace() const;
|
||||
|
||||
/**
|
||||
* Get the number of channels
|
||||
* @return number of channels
|
||||
*/
|
||||
* Get the number of channels
|
||||
* @return number of channels
|
||||
*/
|
||||
unsigned getNumberChannels() const;
|
||||
|
||||
/**
|
||||
* Get width of the frame
|
||||
* @param channel/component
|
||||
* @return number of pixels
|
||||
*/
|
||||
* Get width of the frame
|
||||
* @param channel/component
|
||||
* @return number of pixels
|
||||
*/
|
||||
unsigned int getWidth( unsigned channel = 0 ) const;
|
||||
|
||||
/**
|
||||
* Get height of the frame
|
||||
* @param channel/component
|
||||
* @return number of pixels
|
||||
*/
|
||||
* Get height of the frame
|
||||
* @param channel/component
|
||||
* @return number of pixels
|
||||
*/
|
||||
unsigned int getHeight( unsigned channel = 0 ) const;
|
||||
|
||||
/**
|
||||
@@ -357,10 +357,10 @@ public:
|
||||
bool getHasNegativeValues() const;
|
||||
|
||||
/**
|
||||
* Get number of pixels of the frame
|
||||
* @param channel/component
|
||||
* @return number of pixels
|
||||
*/
|
||||
* Get number of pixels of the frame
|
||||
* @param channel/component
|
||||
* @return number of pixels
|
||||
*/
|
||||
std::uint64_t getPixels( unsigned channel = 0 ) const;
|
||||
|
||||
/**
|
||||
@@ -370,44 +370,44 @@ public:
|
||||
std::uint64_t getTotalNumberOfPixels() const;
|
||||
|
||||
/**
|
||||
* Get chroma width ratio
|
||||
* @return ratio multiple of 2
|
||||
*/
|
||||
* Get chroma width ratio
|
||||
* @return ratio multiple of 2
|
||||
*/
|
||||
unsigned getChromaWidthRatio() const;
|
||||
|
||||
/**
|
||||
* Get chroma height ratio
|
||||
* @return ratio multiple of 2
|
||||
*/
|
||||
* Get chroma height ratio
|
||||
* @return ratio multiple of 2
|
||||
*/
|
||||
unsigned getChromaHeightRatio() const;
|
||||
|
||||
/**
|
||||
* Get number of pixels in each chroma channel
|
||||
* @return number of pixels
|
||||
*/
|
||||
* Get number of pixels in each chroma channel
|
||||
* @return number of pixels
|
||||
*/
|
||||
std::uint64_t getChromaLength() const;
|
||||
|
||||
/**
|
||||
* Get number of bits per pixel
|
||||
* @return number of bits
|
||||
*/
|
||||
* Get number of bits per pixel
|
||||
* @return number of bits
|
||||
*/
|
||||
unsigned int getBitsPel() const;
|
||||
|
||||
/**
|
||||
* Get number of bytes per frame of an existing frame
|
||||
* @return number of bytes per frame
|
||||
*/
|
||||
* Get number of bytes per frame of an existing frame
|
||||
* @return number of bytes per frame
|
||||
*/
|
||||
std::uint64_t getBytesPerFrame() const;
|
||||
|
||||
/**
|
||||
* Get number of bytes per frame of a specific pixel format
|
||||
* @return number of bytes per frame
|
||||
*/
|
||||
* Get number of bytes per frame of a specific pixel format
|
||||
* @return number of bytes per frame
|
||||
*/
|
||||
static std::uint64_t getBytesPerFrame( unsigned int uiWidth, unsigned int uiHeight, int iPixelFormat, unsigned int bitsPixel );
|
||||
|
||||
/**
|
||||
* Reset frame pixels to zero
|
||||
*/
|
||||
* Reset frame pixels to zero
|
||||
*/
|
||||
void reset();
|
||||
|
||||
ClpPel*** getPelBufferYUV() const;
|
||||
@@ -417,71 +417,71 @@ public:
|
||||
|
||||
/**
|
||||
* Get pixel value at coordinates
|
||||
* @param ch frame channel
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
* @param ch frame channel
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
* @param absolute whether it should return positive/negative values
|
||||
* @return pixel value
|
||||
*/
|
||||
* @return pixel value
|
||||
*/
|
||||
ClpPel operator()( unsigned int ch, unsigned int xPos, unsigned int yPos, bool absolute = true ) const;
|
||||
|
||||
/**
|
||||
* Get pixel value at coordinates
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
* @return pixel value
|
||||
*/
|
||||
* Get pixel value at coordinates
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
* @return pixel value
|
||||
*/
|
||||
CalypPixel operator()( unsigned int xPos, unsigned int yPos ) const;
|
||||
|
||||
/**
|
||||
* Get pixel value at coordinates
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
* @return pixel value
|
||||
*/
|
||||
* Get pixel value at coordinates
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
* @return pixel value
|
||||
*/
|
||||
CalypPixel getPixel( unsigned int xPos, unsigned int yPos ) const;
|
||||
|
||||
/**
|
||||
* Get pixel value at coordinates
|
||||
* in the desired color space
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
* @param eColorSpace desired color space
|
||||
* @return pixel value
|
||||
*/
|
||||
* Get pixel value at coordinates
|
||||
* in the desired color space
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
* @param eColorSpace desired color space
|
||||
* @return pixel value
|
||||
*/
|
||||
CalypPixel getPixel( unsigned int xPos, unsigned int yPos, CalypColorSpace eColorSpace ) const;
|
||||
|
||||
/**
|
||||
* Set pixel value at coordinates to a given value
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
*/
|
||||
* Set pixel value at coordinates to a given value
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
*/
|
||||
void setPixel( unsigned int xPos, unsigned int yPos, CalypPixel pixel );
|
||||
|
||||
/**
|
||||
* Copy a frame into the current buffer
|
||||
* @param other frame to be copied
|
||||
*/
|
||||
* Copy a frame into the current buffer
|
||||
* @param other frame to be copied
|
||||
*/
|
||||
void copyFrom( const CalypFrame& other );
|
||||
void copyFrom( const CalypFrame* other );
|
||||
|
||||
/**
|
||||
* Copy a region from a reference corresponding to the size
|
||||
* of the size of the current frame
|
||||
* @param other frame to be copied
|
||||
* @param x x position on the reference frame
|
||||
* @param y y position on the reference frame
|
||||
*/
|
||||
* Copy a region from a reference corresponding to the size
|
||||
* of the size of the current frame
|
||||
* @param other frame to be copied
|
||||
* @param x x position on the reference frame
|
||||
* @param y y position on the reference frame
|
||||
*/
|
||||
void copyFrom( const CalypFrame& other, unsigned x, unsigned y );
|
||||
void copyFrom( const CalypFrame* other, unsigned x, unsigned y );
|
||||
|
||||
/**
|
||||
* Copy a reference frame to a specific location on the current frame
|
||||
* The whole reference frame is copied
|
||||
* @param other frame to be copied
|
||||
* @param x x position on the current frame
|
||||
* @param y y position on the current frame
|
||||
*/
|
||||
* Copy a reference frame to a specific location on the current frame
|
||||
* The whole reference frame is copied
|
||||
* @param other frame to be copied
|
||||
* @param x x position on the current frame
|
||||
* @param y y position on the current frame
|
||||
*/
|
||||
void copyTo( const CalypFrame& other, unsigned x, unsigned y ) const;
|
||||
void copyTo( const CalypFrame* other, unsigned x, unsigned y ) const;
|
||||
|
||||
@@ -492,8 +492,8 @@ public:
|
||||
void fillRGBBuffer() const;
|
||||
|
||||
/**
|
||||
* Histogram
|
||||
*/
|
||||
* Histogram
|
||||
*/
|
||||
enum HistogramChannels
|
||||
{
|
||||
HIST_CHAN_ONE = 0,
|
||||
@@ -526,18 +526,18 @@ public:
|
||||
double getEntropy( unsigned channel, unsigned int start, unsigned int end ) const;
|
||||
|
||||
/**
|
||||
* interface with OpenCV lib
|
||||
*/
|
||||
* interface with OpenCV lib
|
||||
*/
|
||||
bool toMat( cv::Mat& cvMat, bool convertToGray = false, bool scale = true, unsigned channel = 0 ) const;
|
||||
bool fromMat( cv::Mat& cvMat, int iChannel = -1 );
|
||||
|
||||
/**
|
||||
* \ingroup CalypFrameGrp
|
||||
* @defgroup CalypFrameQualityMetricsGrp Calyp Frame Quality Metrics interface
|
||||
* @{
|
||||
* Quality metrics interface
|
||||
*
|
||||
*/
|
||||
* \ingroup CalypFrameGrp
|
||||
* @defgroup CalypFrameQualityMetricsGrp Calyp Frame Quality Metrics interface
|
||||
* @{
|
||||
* Quality metrics interface
|
||||
*
|
||||
*/
|
||||
|
||||
enum QualityMetrics
|
||||
{
|
||||
|
||||
+18
-17
@@ -165,8 +165,8 @@ class CalypStream::CalypStreamPrivate
|
||||
{
|
||||
public:
|
||||
std::recursive_mutex stream_mutex;
|
||||
CalypStream::Type streamType;
|
||||
bool isInit;
|
||||
bool isInput;
|
||||
|
||||
std::unique_ptr<CalypStreamHandlerIf> handler;
|
||||
|
||||
@@ -188,7 +188,7 @@ public:
|
||||
CalypStreamPrivate()
|
||||
{
|
||||
handler = nullptr;
|
||||
isInput = true;
|
||||
streamType = CalypStream::Type::Input;
|
||||
isInit = false;
|
||||
bLoadAll = false;
|
||||
iCurrFrameNum = -1;
|
||||
@@ -200,14 +200,15 @@ public:
|
||||
}
|
||||
|
||||
bool open( std::string filename, unsigned int width, unsigned int height, int input_format, unsigned int bitsPel, int endianness, bool hasNegative,
|
||||
unsigned int frame_rate, bool bInput, bool forceRaw )
|
||||
unsigned int frame_rate, bool forceRaw, CalypStream::Type type )
|
||||
{
|
||||
if( isInit )
|
||||
{
|
||||
close();
|
||||
}
|
||||
isInit = false;
|
||||
isInput = bInput;
|
||||
streamType = type;
|
||||
bool isInput = streamType == CalypStream::Type::Input;
|
||||
|
||||
if( forceRaw )
|
||||
{
|
||||
@@ -341,7 +342,7 @@ public:
|
||||
{
|
||||
const std::lock_guard<std::recursive_mutex> lock( stream_mutex );
|
||||
|
||||
if( !isInit || !isInput || handler->m_uiCurrFrameFileIdx >= handler->m_uiTotalNumberFrames )
|
||||
if( !isInit || streamType != CalypStream::Type::Input || handler->m_uiCurrFrameFileIdx >= handler->m_uiTotalNumberFrames )
|
||||
return false;
|
||||
|
||||
if( bLoadAll )
|
||||
@@ -395,7 +396,7 @@ std::string CalypStream::getCodecName() const
|
||||
}
|
||||
|
||||
bool CalypStream::open( std::string filename, std::string resolution, std::string input_format_name, unsigned int bitsPel, int endianness, bool hasNegative,
|
||||
unsigned int frame_rate, bool bInput )
|
||||
unsigned int frame_rate, CalypStream::Type type )
|
||||
{
|
||||
unsigned int width = 0;
|
||||
unsigned int height = 0;
|
||||
@@ -417,25 +418,25 @@ bool CalypStream::open( std::string filename, std::string resolution, std::strin
|
||||
break;
|
||||
}
|
||||
}
|
||||
return d->open( std::move( filename ), width, height, input_format, bitsPel, endianness, hasNegative, frame_rate, bInput, false );
|
||||
return d->open( std::move( filename ), width, height, input_format, bitsPel, endianness, hasNegative, frame_rate, false, type );
|
||||
}
|
||||
|
||||
bool CalypStream::open( std::string filename, unsigned int width, unsigned int height, int input_format, unsigned int bitsPel, int endianness,
|
||||
unsigned int frame_rate, bool bInput )
|
||||
unsigned int frame_rate, CalypStream::Type type )
|
||||
{
|
||||
return d->open( std::move( filename ), width, height, input_format, bitsPel, endianness, false, frame_rate, bInput, false );
|
||||
return d->open( std::move( filename ), width, height, input_format, bitsPel, endianness, false, frame_rate, false, type );
|
||||
}
|
||||
|
||||
bool CalypStream::open( std::string filename, unsigned int width, unsigned int height, int input_format, unsigned int bitsPel, int endianness, bool hasNegative,
|
||||
unsigned int frame_rate, bool bInput )
|
||||
unsigned int frame_rate, CalypStream::Type type )
|
||||
{
|
||||
return d->open( std::move( filename ), width, height, input_format, bitsPel, endianness, hasNegative, frame_rate, bInput, false );
|
||||
return d->open( std::move( filename ), width, height, input_format, bitsPel, endianness, hasNegative, frame_rate, false, type );
|
||||
}
|
||||
|
||||
bool CalypStream::open( std::string filename, unsigned int width, unsigned int height, int input_format, unsigned int bitsPel, int endianness,
|
||||
unsigned int frame_rate, bool bInput, bool forceRaw )
|
||||
unsigned int frame_rate, bool forceRaw, CalypStream::Type type )
|
||||
{
|
||||
return d->open( std::move( filename ), width, height, input_format, bitsPel, endianness, false, frame_rate, bInput, forceRaw );
|
||||
return d->open( std::move( filename ), width, height, input_format, bitsPel, endianness, false, frame_rate, forceRaw, type );
|
||||
}
|
||||
|
||||
bool CalypStream::supportsFormatConfiguration()
|
||||
@@ -449,7 +450,7 @@ bool CalypStream::reload()
|
||||
{
|
||||
d->frameFifo.clear();
|
||||
d->handler->closeHandler();
|
||||
if( !d->handler->openHandler( d->cFilename, d->isInput ) )
|
||||
if( !d->handler->openHandler( d->cFilename, d->streamType == CalypStream::Type::Input ) )
|
||||
{
|
||||
throw CalypFailure( "CalypStream", "Cannot open stream " + d->cFilename + " with the " +
|
||||
std::string( d->handler->m_pchHandlerName ) + " handler" );
|
||||
@@ -554,7 +555,7 @@ auto CalypStream::hasWritingSlot() -> bool
|
||||
void CalypStream::loadAll()
|
||||
{
|
||||
const std::lock_guard<std::recursive_mutex> lock( d->stream_mutex );
|
||||
if( d->bLoadAll || !d->isInput )
|
||||
if( d->bLoadAll || d->streamType != CalypStream::Type::Input )
|
||||
return;
|
||||
|
||||
try
|
||||
@@ -653,7 +654,7 @@ bool CalypStream::saveFrame( const std::string& filename, const CalypFrame& save
|
||||
{
|
||||
CalypStream auxSaveStream;
|
||||
if( !auxSaveStream.open( filename, saveFrame.getWidth(), saveFrame.getHeight(), saveFrame.getPelFormat(),
|
||||
saveFrame.getBitsPel(), CLP_LITTLE_ENDIAN, 1, false ) )
|
||||
saveFrame.getBitsPel(), CLP_LITTLE_ENDIAN, 1, Type::Output ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -666,7 +667,7 @@ bool CalypStream::saveFrame( const std::string& filename, const CalypFrame& save
|
||||
*/
|
||||
bool CalypStream::seekInputRelative( bool bIsFoward )
|
||||
{
|
||||
if( !d->isInit || !d->isInput )
|
||||
if( !d->isInit || d->streamType != Type::Input )
|
||||
return false;
|
||||
|
||||
bool bRet = false;
|
||||
|
||||
+11
-5
@@ -68,6 +68,12 @@ public:
|
||||
class CalypStream
|
||||
{
|
||||
public:
|
||||
enum class Type
|
||||
{
|
||||
Input,
|
||||
Output
|
||||
};
|
||||
|
||||
static std::vector<CalypStreamFormat> supportedReadFormats();
|
||||
static std::vector<CalypStreamFormat> supportedWriteFormats();
|
||||
static std::vector<CalypStandardResolution> stdResolutionSizes();
|
||||
@@ -89,7 +95,7 @@ public:
|
||||
int endianness,
|
||||
bool hasNegative,
|
||||
unsigned int frame_rate,
|
||||
bool bInput );
|
||||
Type type );
|
||||
bool open( std::string filename,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
@@ -97,7 +103,7 @@ public:
|
||||
unsigned int bitsPel,
|
||||
int endianness,
|
||||
unsigned int frame_rate,
|
||||
bool bInput );
|
||||
Type type );
|
||||
bool open( std::string filename,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
@@ -106,7 +112,7 @@ public:
|
||||
int endianness,
|
||||
bool hasNegative,
|
||||
unsigned int frame_rate,
|
||||
bool bInput );
|
||||
Type type );
|
||||
bool open( std::string filename,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
@@ -114,8 +120,8 @@ public:
|
||||
unsigned int bitsPel,
|
||||
int endianness,
|
||||
unsigned int frame_rate,
|
||||
bool bInput,
|
||||
bool forceRaw );
|
||||
bool forceRaw,
|
||||
Type type );
|
||||
|
||||
bool supportsFormatConfiguration();
|
||||
bool reload();
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "CalypStream.h"
|
||||
|
||||
constexpr int kFrameRate{ 30 };
|
||||
constexpr bool kIsInput{ true };
|
||||
constexpr auto kStreamType = CalypStream::Type::Input;
|
||||
|
||||
auto getFileTestFilename( const char* test_sequence ) -> std::string
|
||||
{
|
||||
@@ -51,7 +51,7 @@ TEST_CASE( "Can open a YUV 420p file", "CalypStream" )
|
||||
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
|
||||
|
||||
CalypStream test_stream;
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, true );
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
|
||||
|
||||
REQUIRE( result );
|
||||
|
||||
@@ -90,7 +90,7 @@ TEST_CASE( "Can open a YUV file", "CalypStream" )
|
||||
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
|
||||
|
||||
CalypStream test_stream;
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, true );
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
|
||||
REQUIRE( result );
|
||||
CHECK( common_checks( test_stream ) );
|
||||
const auto* frame = test_stream.getCurrFrame();
|
||||
@@ -106,7 +106,7 @@ TEST_CASE( "Can open a YUV file", "CalypStream" )
|
||||
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
|
||||
|
||||
CalypStream test_stream;
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, true );
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
|
||||
REQUIRE( result );
|
||||
CHECK( common_checks( test_stream ) );
|
||||
const auto* frame = test_stream.getCurrFrame();
|
||||
@@ -122,7 +122,7 @@ TEST_CASE( "Can open a YUV file", "CalypStream" )
|
||||
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
|
||||
|
||||
CalypStream test_stream;
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, true );
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
|
||||
REQUIRE( result );
|
||||
CHECK( common_checks( test_stream ) );
|
||||
const auto* frame = test_stream.getCurrFrame();
|
||||
@@ -138,7 +138,7 @@ TEST_CASE( "Can open a YUV file", "CalypStream" )
|
||||
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
|
||||
|
||||
CalypStream test_stream;
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, true );
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
|
||||
REQUIRE( result );
|
||||
CHECK( common_checks( test_stream ) );
|
||||
const auto* frame = test_stream.getCurrFrame();
|
||||
@@ -170,7 +170,7 @@ TEST_CASE( "Can open a RGB file", "CalypStream" )
|
||||
const auto kFilename = getFileTestFilename( "Foreman_352x288_rgb24.yuv" );
|
||||
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
|
||||
CalypStream test_stream;
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, true );
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
|
||||
REQUIRE( result );
|
||||
CHECK( common_checks( test_stream ) );
|
||||
const auto* frame = test_stream.getCurrFrame();
|
||||
@@ -187,7 +187,7 @@ TEST_CASE( "Can open a RGB file", "CalypStream" )
|
||||
const auto kFilename = getFileTestFilename( "Foreman_352x288_bgr24.yuv" );
|
||||
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
|
||||
CalypStream test_stream;
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, true );
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
|
||||
REQUIRE( result );
|
||||
CHECK( common_checks( test_stream ) );
|
||||
const auto* frame = test_stream.getCurrFrame();
|
||||
@@ -216,7 +216,7 @@ TEST_CASE( "Can open a GRAY file", "CalypStream" )
|
||||
const auto kFilename = getFileTestFilename( "Foreman_352x288_gray.yuv" );
|
||||
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
|
||||
CalypStream test_stream;
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, true );
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
|
||||
REQUIRE( result );
|
||||
CHECK( common_checks( test_stream ) );
|
||||
const auto* frame = test_stream.getCurrFrame();
|
||||
@@ -245,7 +245,7 @@ TEST_CASE( "Can open .batatas file as RAW video", "CalypStream" )
|
||||
bool result{ false };
|
||||
try
|
||||
{
|
||||
result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kIsInput, force_raw );
|
||||
result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, force_raw, kStreamType );
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
@@ -260,7 +260,7 @@ TEST_CASE( "Can open .batatas file as RAW video", "CalypStream" )
|
||||
force_raw = true;
|
||||
|
||||
CalypStream test_stream;
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kIsInput, force_raw );
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, force_raw, kStreamType );
|
||||
|
||||
REQUIRE( result );
|
||||
|
||||
|
||||
@@ -36,12 +36,12 @@ protected:
|
||||
{
|
||||
pcStreamPast = std::make_unique<CalypStream>();
|
||||
pcStreamPast->open( std::string( CALYP_TEST_DATA_DIR ) + std::string( "/BasketballDrill_F10_832x480_yuv420p.yuv" ), 832, 480, 0, 8,
|
||||
CLP_BIG_ENDIAN, 1, true );
|
||||
CLP_BIG_ENDIAN, 1, CalypStream::Type::Input );
|
||||
pcFramePast = pcStreamPast->getCurrFrame();
|
||||
|
||||
pcStreamFuture = std::make_unique<CalypStream>();
|
||||
pcStreamFuture->open( std::string( CALYP_TEST_DATA_DIR ) + std::string( "/BasketballDrill_F15_832x480_yuv420p.yuv" ), 832, 480, 0, 8,
|
||||
CLP_BIG_ENDIAN, 1, true );
|
||||
CLP_BIG_ENDIAN, 1, CalypStream::Type::Input );
|
||||
pcFrameFuture = pcStreamFuture->getCurrFrame();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user