Merge remote-tracking branch 'upstream/devel' into devel
This commit is contained in:
69 files changed
+14671
-15581
No files matched your search
@@ -8,6 +8,8 @@ EXPORT(PACKAGE MyLib)
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/..)
|
||||
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
|
||||
|
||||
SET(Calyp_Lib_Frame_SRCS CalypPixel.cpp PixelFormats.h PixelFormats.cpp CalypFrame.h CalypFrame.cpp)
|
||||
|
||||
SET(Calyp_Lib_Stream_SRCS
|
||||
|
||||
+7
-10
@@ -27,6 +27,7 @@
|
||||
#define __CALYPDEFS_H__
|
||||
|
||||
#include <algorithm>
|
||||
#include <format>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -58,20 +59,16 @@ inline std::string clpUppercase( const std::string& in )
|
||||
|
||||
struct CalypFailure : public std::exception
|
||||
{
|
||||
std::string m_class_name;
|
||||
std::string m_error_msg;
|
||||
CalypFailure( std::string error_msg ) throw()
|
||||
: m_error_msg( error_msg ) {}
|
||||
CalypFailure( std::string error_msg ) throw() : m_error_msg{ std::move( error_msg ) } {}
|
||||
CalypFailure( std::string class_name, std::string error_msg ) throw()
|
||||
: m_class_name( class_name ), m_error_msg( error_msg )
|
||||
: m_error_msg{ std::format( "[%s] %s", class_name, error_msg ) }
|
||||
{
|
||||
}
|
||||
~CalypFailure() throw() {}
|
||||
const char* what() const throw()
|
||||
{
|
||||
std::string* msg = new std::string( "[" + m_class_name + "] " + m_error_msg );
|
||||
return msg->c_str();
|
||||
}
|
||||
auto what() const throw() -> const char* { return m_error_msg.c_str(); }
|
||||
|
||||
private:
|
||||
std::string m_error_msg;
|
||||
};
|
||||
|
||||
#endif // __CALYPDEFS_H__
|
||||
+362
-413
File diff suppressed because it is too large.
Load diff
+75
-69
@@ -27,6 +27,7 @@
|
||||
#define __CALYPFRAME_H__
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
@@ -37,7 +38,7 @@
|
||||
namespace cv
|
||||
{
|
||||
class Mat;
|
||||
}
|
||||
} // namespace cv
|
||||
|
||||
using ClpPel = std::uint16_t;
|
||||
using ClpByte = std::uint8_t;
|
||||
@@ -99,7 +100,10 @@ enum CLP_Endianness
|
||||
CLP_LITTLE_ENDIAN = 1,
|
||||
};
|
||||
|
||||
#define CHROMASHIFT( SIZE, SHIFT ) (unsigned int)( -( ( -( (int)( SIZE ) ) ) >> ( SHIFT ) ) )
|
||||
constexpr auto CHROMASHIFT( unsigned int size, unsigned int shift ) -> unsigned int
|
||||
{
|
||||
return -( ( -( static_cast<int>( size ) ) ) >> ( shift ) ); // NOLINT
|
||||
}
|
||||
|
||||
/**
|
||||
* \class CalypPixel
|
||||
@@ -117,9 +121,9 @@ public:
|
||||
static constexpr std::size_t getMaxNumberOfComponents() { return kMaxNumberOfComponents; }
|
||||
|
||||
CalypPixel() = default;
|
||||
CalypPixel( const int CalypColorSpace, const ClpPel c0 = 0 );
|
||||
CalypPixel( const int CalypColorSpace, const ClpPel c0, const ClpPel c1, const ClpPel c2 );
|
||||
CalypPixel( const int CalypColorSpace, const ClpPel c0, const ClpPel c1, const ClpPel c2, const ClpPel c3 );
|
||||
explicit CalypPixel( int calypColorSpace, ClpPel c0 = 0 );
|
||||
CalypPixel( int calypColorSpace, ClpPel c0, ClpPel c1, ClpPel c2 );
|
||||
CalypPixel( int calypColorSpace, ClpPel c0, ClpPel c1, ClpPel c2, ClpPel c3 );
|
||||
CalypPixel( const CalypPixel& other ) noexcept = default;
|
||||
CalypPixel( CalypPixel&& other ) noexcept = default;
|
||||
auto operator=( const CalypPixel& other ) -> CalypPixel& = default;
|
||||
@@ -131,20 +135,20 @@ public:
|
||||
auto components() const -> const std::array<ClpPel, kMaxNumberOfComponents>& { return m_pelComp; };
|
||||
auto components() -> std::array<ClpPel, kMaxNumberOfComponents>& { return m_pelComp; };
|
||||
|
||||
ClpPel operator[]( const std::size_t channel ) const { return m_pelComp[channel]; }
|
||||
ClpPel& operator[]( const std::size_t channel ) { return m_pelComp[channel]; }
|
||||
auto operator[]( const std::size_t channel ) const -> ClpPel { return m_pelComp[channel]; }
|
||||
auto operator[]( const std::size_t channel ) -> ClpPel& { return m_pelComp[channel]; }
|
||||
|
||||
CalypPixel& operator+=( const CalypPixel& );
|
||||
CalypPixel& operator-=( const CalypPixel& );
|
||||
CalypPixel& operator*=( const double );
|
||||
auto operator+=( const CalypPixel& ) -> CalypPixel&;
|
||||
auto operator-=( const CalypPixel& ) -> CalypPixel&;
|
||||
auto operator*=( double ) -> CalypPixel&;
|
||||
|
||||
CalypPixel operator+( const CalypPixel& ) const;
|
||||
CalypPixel operator-( const CalypPixel& ) const;
|
||||
CalypPixel operator*( const double ) const;
|
||||
auto operator+( const CalypPixel& ) const -> CalypPixel;
|
||||
auto operator-( const CalypPixel& ) const -> CalypPixel;
|
||||
auto operator*( double ) const -> CalypPixel;
|
||||
|
||||
auto operator==( const CalypPixel& other ) const -> bool;
|
||||
|
||||
friend std::ostream& operator<<( std::ostream& os, const CalypPixel& p );
|
||||
friend auto operator<<( std::ostream& os, const CalypPixel& p ) -> std::ostream&;
|
||||
|
||||
/**
|
||||
* Convert a Pixel to a new color space
|
||||
@@ -152,10 +156,10 @@ public:
|
||||
* @param eOutputSpace output color space
|
||||
* @return converted pixel
|
||||
*/
|
||||
CalypPixel convertPixel( CalypColorSpace eOutputSpace ) const;
|
||||
auto convertPixel( CalypColorSpace eOutputSpace ) const -> CalypPixel;
|
||||
};
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, const CalypPixel& p );
|
||||
auto operator<<( std::ostream& stream, const CalypPixel& pixel ) -> std::ostream&;
|
||||
|
||||
/**
|
||||
* \class CalypPlane
|
||||
@@ -221,11 +225,11 @@ public:
|
||||
*/
|
||||
static constexpr auto numberOfFormats() -> std::size_t;
|
||||
static auto findPixelFormat( const std::string& name ) -> std::optional<ClpPixelFormats>;
|
||||
static auto findPixelFormat( const std::string_view name ) -> std::optional<ClpPixelFormats>;
|
||||
static auto findPixelFormat( std::string_view name ) -> std::optional<ClpPixelFormats>;
|
||||
static auto pelFormatColorSpace( ClpPixelFormats idx ) -> int;
|
||||
static auto supportedPixelFormatListNames() -> std::map<ClpPixelFormats, std::string_view>;
|
||||
static auto supportedPixelFormatListNames( int colorSpace ) -> std::map<ClpPixelFormats, std::string_view>;
|
||||
static auto pixelFormatName( ClpPixelFormats idx ) -> const std::string_view;
|
||||
static auto pixelFormatName( ClpPixelFormats idx ) -> std::string_view;
|
||||
|
||||
/**
|
||||
* Creates a new frame using the following configuration
|
||||
@@ -247,21 +251,22 @@ public:
|
||||
*
|
||||
* @note this function might misbehave if the pixel format enum is not correct
|
||||
*/
|
||||
CalypFrame( unsigned int width, unsigned int height, ClpPixelFormats pelFormat, unsigned bitsPixel, bool has_negative_values );
|
||||
CalypFrame( unsigned int width, unsigned int height, ClpPixelFormats pelFormat, unsigned bitsPixel,
|
||||
bool hasNegativeValues );
|
||||
|
||||
/**
|
||||
* Move contructor
|
||||
*
|
||||
* @param other existing frame to copy from
|
||||
*/
|
||||
CalypFrame( CalypFrame&& other ) noexcept;
|
||||
CalypFrame( CalypFrame&& other ) noexcept = default;
|
||||
|
||||
/**
|
||||
* Move assignement contructor
|
||||
*
|
||||
* @param other existing frame to copy from
|
||||
*/
|
||||
CalypFrame& operator=( CalypFrame&& other ) noexcept;
|
||||
auto operator=( CalypFrame&& other ) noexcept -> CalypFrame& = default;
|
||||
|
||||
/**
|
||||
* Copy contructor
|
||||
@@ -275,7 +280,7 @@ public:
|
||||
*
|
||||
* @param other existing frame to copy from
|
||||
*/
|
||||
CalypFrame& operator=( const CalypFrame& other );
|
||||
auto operator=( const CalypFrame& other ) -> CalypFrame&;
|
||||
|
||||
/**
|
||||
* Creates and new frame with the configuration of an existing one and copy
|
||||
@@ -312,14 +317,14 @@ public:
|
||||
* @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;
|
||||
auto haveSameFmt( const CalypFrame& other, unsigned int match = MATCH_ALL ) const -> bool;
|
||||
auto haveSameFmt( const CalypFrame* other, unsigned int match = MATCH_ALL ) const -> bool;
|
||||
|
||||
/**
|
||||
* Get pixel format information
|
||||
* @return pixel format index
|
||||
*/
|
||||
ClpPixelFormats getPelFormat() const;
|
||||
auto getPelFormat() const -> ClpPixelFormats;
|
||||
|
||||
/**
|
||||
* Get pixel format information
|
||||
@@ -331,90 +336,91 @@ public:
|
||||
* Get color space information
|
||||
* @return get color space index
|
||||
*/
|
||||
int getColorSpace() const;
|
||||
auto getColorSpace() const -> int;
|
||||
|
||||
/**
|
||||
* Get the number of channels
|
||||
* @return number of channels
|
||||
*/
|
||||
unsigned getNumberChannels() const;
|
||||
auto getNumberChannels() const -> unsigned;
|
||||
|
||||
/**
|
||||
* Get width of the frame
|
||||
* @param channel/component
|
||||
* @return number of pixels
|
||||
*/
|
||||
unsigned int getWidth( unsigned channel = 0 ) const;
|
||||
auto getWidth( unsigned channel = 0 ) const -> unsigned int;
|
||||
|
||||
/**
|
||||
* Get height of the frame
|
||||
* @param channel/component
|
||||
* @return number of pixels
|
||||
*/
|
||||
unsigned int getHeight( unsigned channel = 0 ) const;
|
||||
auto getHeight( unsigned channel = 0 ) const -> unsigned int;
|
||||
|
||||
/**
|
||||
* Check if frame has negative values
|
||||
* @return Boolean with the flag value
|
||||
*/
|
||||
bool getHasNegativeValues() const;
|
||||
auto getHasNegativeValues() const -> bool;
|
||||
|
||||
/**
|
||||
* Get number of pixels of the frame
|
||||
* @param channel/component
|
||||
* @return number of pixels
|
||||
*/
|
||||
std::uint64_t getPixels( unsigned channel = 0 ) const;
|
||||
auto getPixels( unsigned channel = 0 ) const -> std::uint64_t;
|
||||
|
||||
/**
|
||||
* Get the total number of pixels of the frame
|
||||
* @return number of pixels
|
||||
*/
|
||||
std::uint64_t getTotalNumberOfPixels() const;
|
||||
auto getTotalNumberOfPixels() const -> std::uint64_t;
|
||||
|
||||
/**
|
||||
* Get chroma width ratio
|
||||
* @return ratio multiple of 2
|
||||
*/
|
||||
unsigned getChromaWidthRatio() const;
|
||||
auto getChromaWidthRatio() const -> unsigned;
|
||||
|
||||
/**
|
||||
* Get chroma height ratio
|
||||
* @return ratio multiple of 2
|
||||
*/
|
||||
unsigned getChromaHeightRatio() const;
|
||||
auto getChromaHeightRatio() const -> unsigned;
|
||||
|
||||
/**
|
||||
* Get number of pixels in each chroma channel
|
||||
* @return number of pixels
|
||||
*/
|
||||
std::uint64_t getChromaLength() const;
|
||||
auto getChromaLength() const -> std::uint64_t;
|
||||
|
||||
/**
|
||||
* Get number of bits per pixel
|
||||
* @return number of bits
|
||||
*/
|
||||
unsigned int getBitsPel() const;
|
||||
auto getBitsPel() const -> unsigned int;
|
||||
|
||||
/**
|
||||
* Get number of bytes per frame of an existing frame
|
||||
* @return number of bytes per frame
|
||||
*/
|
||||
std::uint64_t getBytesPerFrame() const;
|
||||
auto getBytesPerFrame() const -> std::uint64_t;
|
||||
|
||||
/**
|
||||
* 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, ClpPixelFormats pelFormat, unsigned int bitsPixel );
|
||||
static auto getBytesPerFrame( unsigned int uiWidth, unsigned int uiHeight, ClpPixelFormats pelFormat,
|
||||
unsigned int bitsPixel ) -> std::uint64_t;
|
||||
|
||||
/**
|
||||
* Reset frame pixels to zero
|
||||
*/
|
||||
void reset();
|
||||
|
||||
ClpPel*** getPelBufferYUV() const;
|
||||
ClpPel*** getPelBufferYUV();
|
||||
auto getPelBufferYUV() const -> ClpPel***;
|
||||
auto getPelBufferYUV() -> ClpPel***;
|
||||
|
||||
auto getRGBBuffer() const -> std::optional<std::span<const std::uint8_t>>;
|
||||
|
||||
@@ -426,7 +432,7 @@ public:
|
||||
* @param absolute whether it should return positive/negative values
|
||||
* @return pixel value
|
||||
*/
|
||||
ClpPel operator()( unsigned int ch, unsigned int xPos, unsigned int yPos, bool absolute = true ) const;
|
||||
auto operator()( unsigned int ch, unsigned int xPos, unsigned int yPos, bool absolute = true ) const -> ClpPel;
|
||||
|
||||
/**
|
||||
* Get pixel value at coordinates
|
||||
@@ -434,7 +440,7 @@ public:
|
||||
* @param yPos position in Y axis
|
||||
* @return pixel value
|
||||
*/
|
||||
CalypPixel operator()( unsigned int xPos, unsigned int yPos ) const;
|
||||
auto operator()( unsigned int xPos, unsigned int yPos ) const -> CalypPixel;
|
||||
|
||||
/**
|
||||
* Get pixel value at coordinates
|
||||
@@ -442,7 +448,7 @@ public:
|
||||
* @param yPos position in Y axis
|
||||
* @return pixel value
|
||||
*/
|
||||
CalypPixel getPixel( unsigned int xPos, unsigned int yPos ) const;
|
||||
auto getPixel( unsigned int xPos, unsigned int yPos ) const -> CalypPixel;
|
||||
|
||||
/**
|
||||
* Get pixel value at coordinates
|
||||
@@ -452,7 +458,7 @@ public:
|
||||
* @param eColorSpace desired color space
|
||||
* @return pixel value
|
||||
*/
|
||||
CalypPixel getPixel( unsigned int xPos, unsigned int yPos, CalypColorSpace eColorSpace ) const;
|
||||
auto getPixel( unsigned int xPos, unsigned int yPos, CalypColorSpace eColorSpace ) const -> CalypPixel;
|
||||
|
||||
/**
|
||||
* Set pixel value at coordinates to a given value
|
||||
@@ -488,9 +494,9 @@ public:
|
||||
void copyTo( const CalypFrame& other, unsigned x, unsigned y ) const;
|
||||
void copyTo( const CalypFrame* other, unsigned x, unsigned y ) const;
|
||||
|
||||
void frameFromBuffer( const std::vector<ClpByte>&, int, unsigned long );
|
||||
void frameFromBuffer( const std::vector<ClpByte>&, int );
|
||||
void frameToBuffer( std::vector<ClpByte>&, int ) const;
|
||||
void frameFromBuffer( std::span<const ClpByte>, int iEndianness, std::uint64_t uiBuffSize );
|
||||
void frameFromBuffer( std::span<const ClpByte>, int iEndianness );
|
||||
void frameToBuffer( std::span<ClpByte>, int iEndianness ) const;
|
||||
|
||||
void fillRGBBuffer( std::optional<std::size_t> channel ) const;
|
||||
void fillRGBBuffer() const;
|
||||
@@ -516,24 +522,24 @@ public:
|
||||
};
|
||||
void calcHistogram();
|
||||
|
||||
unsigned int getMinimumPelValue( unsigned channel ) const;
|
||||
unsigned int getMaximumPelValue( unsigned channel ) const;
|
||||
auto getMinimumPelValue( unsigned channel ) const -> unsigned int;
|
||||
auto getMaximumPelValue( unsigned channel ) const -> unsigned int;
|
||||
|
||||
unsigned int getMaximum( unsigned channel ) const;
|
||||
unsigned int getNumPixelsRange( unsigned channel, unsigned int start, unsigned int end ) const;
|
||||
double getMean( unsigned channel, unsigned int start, unsigned int end ) const;
|
||||
int getMedian( unsigned channel, unsigned int start, unsigned int end ) const;
|
||||
double getStdDev( unsigned channel, unsigned int start, unsigned int end ) const;
|
||||
double getHistogramValue( unsigned channel, unsigned int bin ) const;
|
||||
unsigned int getNEBins( unsigned channel ) const;
|
||||
int getNumHistogramSegment() const;
|
||||
double getEntropy( unsigned channel, unsigned int start, unsigned int end ) const;
|
||||
auto getMaximum( unsigned channel ) const -> unsigned int;
|
||||
auto getNumPixelsRange( unsigned channel, unsigned int start, unsigned int end ) const -> unsigned int;
|
||||
auto getMean( unsigned channel, unsigned int start, unsigned int end ) const -> double;
|
||||
auto getMedian( unsigned channel, unsigned int start, unsigned int end ) const -> int;
|
||||
auto getStdDev( unsigned channel, unsigned int start, unsigned int end ) const -> double;
|
||||
auto getHistogramValue( unsigned channel, unsigned int bin ) const -> double;
|
||||
auto getNEBins( unsigned channel ) const -> unsigned int;
|
||||
auto getNumHistogramSegment() const -> int;
|
||||
auto getEntropy( unsigned channel, unsigned int start, unsigned int end ) const -> double;
|
||||
|
||||
/**
|
||||
* 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 );
|
||||
auto toMat( cv::Mat& cvMat, bool convertToGray = false, bool scale = true, unsigned channel = 0 ) const -> bool;
|
||||
auto fromMat( cv::Mat& cvMat, int iChannel = -1 ) -> bool;
|
||||
|
||||
/**
|
||||
* \ingroup CalypFrameGrp
|
||||
@@ -553,18 +559,18 @@ public:
|
||||
NUMBER_METRICS,
|
||||
};
|
||||
|
||||
static std::vector<std::string> supportedQualityMetricsList();
|
||||
static std::vector<std::string> supportedQualityMetricsUnitsList();
|
||||
double getQuality( int Metric, CalypFrame* Org, unsigned int component );
|
||||
double getMSE( CalypFrame* Org, unsigned int component );
|
||||
double getPSNR( CalypFrame* Org, unsigned int component );
|
||||
double getSSIM( CalypFrame* Org, unsigned int component );
|
||||
double getWSPNR( CalypFrame* Org, unsigned int component );
|
||||
static auto supportedQualityMetricsList() -> std::vector<std::string>;
|
||||
static auto supportedQualityMetricsUnitsList() -> std::vector<std::string>;
|
||||
auto getQuality( int metric, CalypFrame* org, unsigned int component ) -> double;
|
||||
auto getMSE( CalypFrame* org, unsigned int component ) -> double;
|
||||
auto getPSNR( CalypFrame* org, unsigned int component ) -> double;
|
||||
auto getSSIM( CalypFrame* org, unsigned int component ) -> double;
|
||||
auto getWSPNR( CalypFrame* org, unsigned int component ) -> double;
|
||||
/** @} */
|
||||
|
||||
private:
|
||||
class CalypFramePrivate;
|
||||
std::unique_ptr<CalypFramePrivate> d;
|
||||
struct CalypFramePrivate;
|
||||
std::unique_ptr<CalypFramePrivate> m_d;
|
||||
};
|
||||
|
||||
#endif // __CALYPFRAME_H__
|
||||
+2
-17
@@ -40,18 +40,6 @@
|
||||
#include "CalypFrame.h"
|
||||
#include "CalypOptions.h"
|
||||
|
||||
#define REGISTER_CLASS_MAKER( X ) \
|
||||
extern "C" CalypModulePtr Maker() { return std::make_unique<X>(); }
|
||||
#define REGISTER_CLASS_FACTORY( X ) \
|
||||
public: \
|
||||
X( const X& buffer ) \
|
||||
noexcept = delete; \
|
||||
X( X&& buffer ) \
|
||||
noexcept = delete; \
|
||||
auto operator=( const X& buffer )->X& = delete; \
|
||||
auto operator=( X&& buffer ) noexcept->X& = delete; \
|
||||
static CalypModulePtr Create() { return std::make_unique<X>(); }
|
||||
|
||||
#define _BASIC_MODULE_API_2_CHECK_ \
|
||||
if( apcFrameList.size() != m_uiNumberOfFrames ) \
|
||||
return false; \
|
||||
@@ -204,10 +192,7 @@ public:
|
||||
void destroy();
|
||||
|
||||
// API using OpenCV
|
||||
virtual cv::Mat* create_using_opencv( const std::vector<Mat>& apcFrameList )
|
||||
{
|
||||
return nullptr;
|
||||
};
|
||||
virtual cv::Mat* create_using_opencv( const std::vector<Mat>& apcFrameList ) { return nullptr; };
|
||||
virtual Mat* process_using_opencv( const std::vector<Mat>& apcFrameList ) = 0;
|
||||
virtual void destroy_using_opencv(){};
|
||||
|
||||
@@ -220,7 +205,7 @@ protected:
|
||||
using CalypModulePtr = std::unique_ptr<CalypModuleIf>;
|
||||
|
||||
template <typename T>
|
||||
class CalypModuleInstace
|
||||
class CalypModuleInstance
|
||||
{
|
||||
public:
|
||||
static CalypModulePtr Create() { return std::make_unique<T>(); }
|
||||
|
||||
+37
-42
@@ -24,17 +24,15 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
#include <numeric>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "PixelFormats.h"
|
||||
#include "config.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr auto kMinPixelValue{ 0 };
|
||||
constexpr auto kMaxPixelValue{ 255 };
|
||||
|
||||
static inline void yuvToRgb( const int& iY, const int& iU, const int& iV, int& iR, int& iG, int& iB )
|
||||
constexpr void yuvToRgb( int iY, int iU, int iV, int& iR, int& iG, int& iB )
|
||||
{
|
||||
iR = std::clamp( iY + ( ( 1436 * ( iV - 128 ) ) >> 10 ), kMinPixelValue, kMaxPixelValue ); // NOLINT
|
||||
iG = std::clamp( iY - ( ( 352 * ( iU - 128 ) + 731 * ( iV - 128 ) ) >> 10 ), kMinPixelValue,
|
||||
@@ -42,95 +40,91 @@ static inline void yuvToRgb( const int& iY, const int& iU, const int& iV, int& i
|
||||
iB = std::clamp( iY + ( ( 1812 * ( iU - 128 ) ) >> 10 ), kMinPixelValue, kMaxPixelValue ); // NOLINT
|
||||
}
|
||||
|
||||
static inline void rgbToYuv( const int& iR, const int& iG, const int& iB, int& iY, int& iU, int& iV )
|
||||
constexpr void rgbToYuv( int iR, int iG, int iB, int& iY, int& iU, int& iV )
|
||||
{
|
||||
iY = ( 299 * iR + 587 * iG + 114 * iB + 500 ) / 1000; // NOLINT
|
||||
iU = ( 1000 * ( iB - iY ) + 226816 ) / 1772; // NOLINT
|
||||
iV = ( 1000 * ( iR - iY ) + 179456 ) / 1402; // NOLINT
|
||||
}
|
||||
} // namespace
|
||||
|
||||
CalypPixel::CalypPixel( const int ColorSpace, const ClpPel c0 )
|
||||
CalypPixel::CalypPixel( int colorSpace, const ClpPel c0 ) : m_colorSpace( colorSpace )
|
||||
{
|
||||
m_colorSpace = ColorSpace;
|
||||
m_pelComp[0] = c0;
|
||||
}
|
||||
|
||||
CalypPixel::CalypPixel( const int ColorSpace, const ClpPel c0, const ClpPel c1, const ClpPel c2 )
|
||||
CalypPixel::CalypPixel( int colorSpace, const ClpPel c0, const ClpPel c1, const ClpPel c2 ) : m_colorSpace( colorSpace )
|
||||
{
|
||||
m_colorSpace = ColorSpace;
|
||||
m_pelComp[0] = c0;
|
||||
m_pelComp[1] = c1;
|
||||
m_pelComp[2] = c2;
|
||||
}
|
||||
|
||||
CalypPixel::CalypPixel( const int ColorSpace, const ClpPel c0, const ClpPel c1, const ClpPel c2, const ClpPel c3 )
|
||||
CalypPixel::CalypPixel( int colorSpace, const ClpPel c0, const ClpPel c1, const ClpPel c2, const ClpPel c3 )
|
||||
: m_colorSpace( colorSpace )
|
||||
{
|
||||
m_colorSpace = ColorSpace;
|
||||
m_pelComp[0] = c0;
|
||||
m_pelComp[1] = c1;
|
||||
m_pelComp[2] = c2;
|
||||
m_pelComp[3] = c3;
|
||||
}
|
||||
|
||||
CalypPixel& CalypPixel::operator+=( const CalypPixel& in )
|
||||
auto CalypPixel::operator+=( const CalypPixel& in ) -> CalypPixel&
|
||||
{
|
||||
assert( in.colorSpace() == m_colorSpace );
|
||||
const auto& other_comp = in.components();
|
||||
std::transform( other_comp.begin(), other_comp.end(), m_pelComp.begin(), m_pelComp.begin(),
|
||||
[]( auto& p1, auto& p2 ) { return p1 + p2; } );
|
||||
std::ranges::transform( other_comp, m_pelComp, m_pelComp.begin(), []( auto& lhs, auto& rhs ) { return lhs + rhs; } );
|
||||
return *this;
|
||||
}
|
||||
|
||||
CalypPixel& CalypPixel::operator-=( const CalypPixel& in )
|
||||
auto CalypPixel::operator-=( const CalypPixel& in ) -> CalypPixel&
|
||||
{
|
||||
assert( in.colorSpace() == m_colorSpace );
|
||||
const auto& other_comp = in.components();
|
||||
std::transform( other_comp.begin(), other_comp.end(), m_pelComp.begin(), m_pelComp.begin(),
|
||||
[]( auto& p1, auto& p2 ) { return p1 - p2; } );
|
||||
std::ranges::transform( other_comp, m_pelComp, m_pelComp.begin(), []( auto& lhs, auto& rhs ) { return lhs - rhs; } );
|
||||
return *this;
|
||||
}
|
||||
|
||||
CalypPixel& CalypPixel::operator*=( const double op )
|
||||
auto CalypPixel::operator*=( double op ) -> CalypPixel&
|
||||
{
|
||||
std::transform( m_pelComp.begin(), m_pelComp.end(), m_pelComp.begin(), [&op]( auto& p1 ) { return p1 * op; } );
|
||||
std::ranges::transform( m_pelComp, m_pelComp.begin(), [&op]( auto& p1 ) { return p1 * op; } );
|
||||
return *this;
|
||||
}
|
||||
|
||||
CalypPixel CalypPixel::operator+( const CalypPixel& in ) const
|
||||
auto CalypPixel::operator+( const CalypPixel& in ) const -> CalypPixel
|
||||
{
|
||||
assert( in.colorSpace() == m_colorSpace );
|
||||
const auto& other_comp = in.components();
|
||||
CalypPixel result{ m_colorSpace };
|
||||
std::transform( other_comp.begin(), other_comp.end(), m_pelComp.begin(), result.components().begin(),
|
||||
[]( auto& p1, auto& p2 ) { return p1 + p2; } );
|
||||
std::ranges::transform( other_comp, m_pelComp, result.components().begin(),
|
||||
[]( auto& lhs, auto& rhs ) { return lhs + rhs; } );
|
||||
return result;
|
||||
}
|
||||
|
||||
CalypPixel CalypPixel::operator-( const CalypPixel& in ) const
|
||||
auto CalypPixel::operator-( const CalypPixel& input ) const -> CalypPixel
|
||||
{
|
||||
assert( in.colorSpace() == m_colorSpace );
|
||||
const auto& other_comp = in.components();
|
||||
assert( input.colorSpace() == m_colorSpace );
|
||||
const auto& other_comp = input.components();
|
||||
CalypPixel result{ m_colorSpace };
|
||||
std::transform( other_comp.begin(), other_comp.end(), m_pelComp.begin(), result.components().begin(),
|
||||
[]( auto& p1, auto& p2 ) { return p1 - p2; } );
|
||||
std::ranges::transform( other_comp, m_pelComp, result.components().begin(),
|
||||
[]( auto& lhs, auto& rhs ) { return lhs - rhs; } );
|
||||
return result;
|
||||
}
|
||||
|
||||
CalypPixel CalypPixel::operator*( const double op ) const
|
||||
auto CalypPixel::operator*( double op ) const -> CalypPixel
|
||||
{
|
||||
CalypPixel result{ m_colorSpace };
|
||||
auto& comp = result.components();
|
||||
std::transform( comp.begin(), comp.end(), comp.begin(), [&op]( auto& p1 ) { return p1 * op; } );
|
||||
std::ranges::transform( comp, comp.begin(), [&op]( auto& p1 ) { return p1 * op; } );
|
||||
return result;
|
||||
}
|
||||
|
||||
auto CalypPixel::operator==( const CalypPixel& other ) const -> bool
|
||||
{
|
||||
return colorSpace() == other.colorSpace() &&
|
||||
std::equal( m_pelComp.begin(), m_pelComp.end(), other.components().begin() );
|
||||
return colorSpace() == other.colorSpace() && std::ranges::equal( m_pelComp, other.components() );
|
||||
}
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, const CalypPixel& p )
|
||||
auto operator<<( std::ostream& stream, const CalypPixel& pixel ) -> std::ostream&
|
||||
{
|
||||
// #ifdef CLP_DEBUG
|
||||
// if( p.colorSpace() == CLP_COLOR_RGB || p.colorSpace() == CLP_COLOR_YUV )
|
||||
@@ -142,18 +136,18 @@ std::ostream& operator<<( std::ostream& os, const CalypPixel& p )
|
||||
// os << "(" << p[0] << ", " << p[1] << ", " << p[2] << ", " << p[3] << ")";
|
||||
// }
|
||||
// #endif
|
||||
return os;
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
CalypPixel CalypPixel::convertPixel( CalypColorSpace eOutputSpace ) const
|
||||
auto CalypPixel::convertPixel( CalypColorSpace eOutputSpace ) const -> CalypPixel
|
||||
{
|
||||
if( m_colorSpace == eOutputSpace )
|
||||
return *this;
|
||||
if( m_colorSpace == eOutputSpace ) return *this;
|
||||
|
||||
int outA = 0;
|
||||
int outB = 0;
|
||||
int outC = 0;
|
||||
int outD = 0;
|
||||
int outA{ 0 };
|
||||
int outB{ 0 };
|
||||
int outC{ 0 };
|
||||
int outD{ 0 };
|
||||
if( m_colorSpace == CLP_COLOR_YUV )
|
||||
{
|
||||
switch( eOutputSpace )
|
||||
@@ -186,5 +180,6 @@ CalypPixel CalypPixel::convertPixel( CalypColorSpace eOutputSpace ) const
|
||||
break;
|
||||
}
|
||||
}
|
||||
return CalypPixel( eOutputSpace, outA, outB, outC, outD );
|
||||
return { eOutputSpace, static_cast<ClpPel>( outA ), static_cast<ClpPel>( outB ), static_cast<ClpPel>( outC ),
|
||||
static_cast<ClpPel>( outD ) };
|
||||
}
|
||||
+29
-26
@@ -35,6 +35,10 @@
|
||||
#define FF_USER_CODEC_PARAM
|
||||
#endif
|
||||
|
||||
#if( LIBAVCODEC_VERSION_MAJOR >= 59 && LIBAVFORMAT_VERSION_MAJOR >= 59 )
|
||||
#define FF_API_LAVF_AVCTX
|
||||
#endif
|
||||
|
||||
std::vector<CalypStreamFormat> StreamHandlerLibav::supportedReadFormats()
|
||||
{
|
||||
INI_REGIST_CALYP_SUPPORTED_FMT;
|
||||
@@ -123,7 +127,7 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
|
||||
#else
|
||||
int codecId = m_cStream->codec->codec_id;
|
||||
#endif
|
||||
AVCodec* dec = avcodec_find_decoder( AVCodecID( codecId ) );
|
||||
auto* dec = avcodec_find_decoder( AVCodecID( codecId ) );
|
||||
if( !dec )
|
||||
{
|
||||
std::cout << "Failed to find video coded" << std::endl;
|
||||
@@ -150,7 +154,7 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
|
||||
|
||||
if( avcodec_open2( m_cCodedCtx, dec, NULL ) < 0 )
|
||||
{
|
||||
std::cout << "Failed to open video coded" << std::endl;
|
||||
std::cout << "Failed to open video codec" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -200,9 +204,7 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
|
||||
m_iPixelFormat = ClpPixelFormats::Invalid;
|
||||
m_bNative = false;
|
||||
auto found_fmt = std::find_if( g_CalypPixFmtDescriptorsMap.begin(), g_CalypPixFmtDescriptorsMap.end(),
|
||||
[auxPixFmt]( const auto& fmt ) {
|
||||
return fmt.second.ffmpegPelFormat == auxPixFmt;
|
||||
} );
|
||||
[auxPixFmt]( const auto& fmt ) { return fmt.second.ffmpegPelFormat == auxPixFmt; } );
|
||||
if( found_fmt != g_CalypPixFmtDescriptorsMap.end() )
|
||||
{
|
||||
m_bNative = true;
|
||||
@@ -272,8 +274,7 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
|
||||
AVPixelFormat newAvFmt = AVPixelFormat( g_CalypPixFmtDescriptorsMap.at( m_iPixelFormat ).ffmpegPelFormat );
|
||||
|
||||
/* create scaling context */
|
||||
m_ScalerCtx = sws_getContext( m_uiWidth, m_uiHeight, AVPixelFormat( m_ffPixFmt ),
|
||||
m_uiWidth, m_uiHeight, newAvFmt,
|
||||
m_ScalerCtx = sws_getContext( m_uiWidth, m_uiHeight, AVPixelFormat( m_ffPixFmt ), m_uiWidth, m_uiHeight, newAvFmt,
|
||||
SWS_BILINEAR, NULL, NULL, NULL );
|
||||
|
||||
m_cConvertedFrame = av_frame_alloc();
|
||||
@@ -283,8 +284,9 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
|
||||
return false;
|
||||
}
|
||||
|
||||
if( av_image_alloc( m_cConvertedFrame->data, m_cConvertedFrame->linesize,
|
||||
m_uiWidth, m_uiHeight, newAvFmt, 16 ) < 0 )
|
||||
auto alloc_error =
|
||||
av_image_alloc( m_cConvertedFrame->data, m_cConvertedFrame->linesize, m_uiWidth, m_uiHeight, newAvFmt, 16 );
|
||||
if( alloc_error < 0 )
|
||||
{
|
||||
closeHandler();
|
||||
return false;
|
||||
@@ -296,10 +298,10 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
|
||||
m_uiFrameBufferSize = av_image_get_buffer_size( AVPixelFormat( m_ffPixFmt ), m_uiWidth, m_uiHeight, 1 );
|
||||
|
||||
/* initialize packet, set data to NULL, let the demuxer fill it */
|
||||
av_init_packet( &m_cPacket );
|
||||
m_cPacket.data = NULL;
|
||||
m_cPacket.size = 0;
|
||||
m_cOrgPacket = m_cPacket;
|
||||
m_cPacket = av_packet_alloc();
|
||||
m_cPacket->data = NULL;
|
||||
m_cPacket->size = 0;
|
||||
m_cOrgPacket = *m_cPacket;
|
||||
|
||||
m_bHasStream = true;
|
||||
return true;
|
||||
@@ -316,6 +318,7 @@ void StreamHandlerLibav::closeHandler()
|
||||
avformat_close_input( &m_cFmtCtx );
|
||||
|
||||
av_free( m_cFrame );
|
||||
av_packet_free( &m_cPacket );
|
||||
}
|
||||
m_bHasStream = false;
|
||||
}
|
||||
@@ -373,13 +376,13 @@ bool StreamHandlerLibav::read( CalypFrame& pcFrame )
|
||||
bGotFrame = 1;
|
||||
}
|
||||
#else
|
||||
if( m_cPacket.stream_index == m_iStreamIdx )
|
||||
if( m_cPacket->stream_index == m_iStreamIdx )
|
||||
{
|
||||
if( ( iRet = avcodec_decode_video2( m_cCodedCtx, m_cFrame, &bGotFrame, &m_cPacket ) ) < 0 )
|
||||
if( ( iRet = avcodec_decode_video2( m_cCodedCtx, m_cFrame, &bGotFrame, m_cPacket ) ) < 0 )
|
||||
return false;
|
||||
m_cPacket.data += iRet;
|
||||
m_cPacket.size -= iRet;
|
||||
if( m_cPacket.size <= 0 )
|
||||
m_cPacket->data += iRet;
|
||||
m_cPacket->size -= iRet;
|
||||
if( m_cPacket->size <= 0 )
|
||||
{
|
||||
bReadPkt = true;
|
||||
av_packet_unref( &m_cOrgPacket );
|
||||
@@ -392,7 +395,7 @@ bool StreamHandlerLibav::read( CalypFrame& pcFrame )
|
||||
{
|
||||
bReadPkt = false;
|
||||
av_packet_unref( &m_cOrgPacket );
|
||||
if( ( iRet = av_read_frame( m_cFmtCtx, &m_cPacket ) ) < 0 )
|
||||
if( ( iRet = av_read_frame( m_cFmtCtx, m_cPacket ) ) < 0 )
|
||||
{
|
||||
if( iRet == AVERROR_EOF )
|
||||
{
|
||||
@@ -401,10 +404,10 @@ bool StreamHandlerLibav::read( CalypFrame& pcFrame )
|
||||
}
|
||||
return false;
|
||||
}
|
||||
m_cOrgPacket = m_cPacket;
|
||||
m_cOrgPacket = *m_cPacket;
|
||||
#ifdef FF_SEND_RECEIVE_API
|
||||
if( m_cPacket.stream_index == m_iStreamIdx )
|
||||
if( ( iRet = avcodec_send_packet( m_cCodedCtx, &m_cPacket ) ) < 0 )
|
||||
if( m_cPacket->stream_index == m_iStreamIdx )
|
||||
if( ( iRet = avcodec_send_packet( m_cCodedCtx, m_cPacket ) ) < 0 )
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
@@ -415,13 +418,13 @@ bool StreamHandlerLibav::read( CalypFrame& pcFrame )
|
||||
AVFrame* decFrame = m_cFrame;
|
||||
if( !m_bNative )
|
||||
{
|
||||
sws_scale( m_ScalerCtx, (const uint8_t* const*)decFrame->data, decFrame->linesize, 0,
|
||||
decFrame->height, (uint8_t* const*)m_cConvertedFrame->data, m_cConvertedFrame->linesize );
|
||||
sws_scale( m_ScalerCtx, (const uint8_t* const*)decFrame->data, decFrame->linesize, 0, decFrame->height,
|
||||
(uint8_t* const*)m_cConvertedFrame->data, m_cConvertedFrame->linesize );
|
||||
|
||||
decFrame = m_cConvertedFrame;
|
||||
}
|
||||
av_image_copy_to_buffer( m_pStreamBuffer.data(), m_uiFrameBufferSize, decFrame->data,
|
||||
decFrame->linesize, AVPixelFormat( m_ffPixFmt ), m_uiWidth, m_uiHeight, 1 );
|
||||
av_image_copy_to_buffer( m_pStreamBuffer.data(), m_uiFrameBufferSize, decFrame->data, decFrame->linesize,
|
||||
AVPixelFormat( m_ffPixFmt ), m_uiWidth, m_uiHeight, 1 );
|
||||
|
||||
pcFrame.frameFromBuffer( m_pStreamBuffer, m_iEndianness );
|
||||
m_uiCurrFrameFileIdx++;
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavutil/avutil.h>
|
||||
#include <libavutil/imgutils.h>
|
||||
@@ -87,7 +88,7 @@ private:
|
||||
int m_ffPixFmt;
|
||||
AVFrame* m_cFrame;
|
||||
AVPacket m_cOrgPacket;
|
||||
AVPacket m_cPacket;
|
||||
AVPacket* m_cPacket;
|
||||
|
||||
bool m_bHasStream;
|
||||
|
||||
|
||||
@@ -14,5 +14,5 @@ SET(Calyp_Lib_Catch2_Tests_SRCS
|
||||
ADD_DEFINITIONS(-DCALYP_TEST_DATA_DIR=\"${CALYP_TEST_DATA_DIR}\")
|
||||
|
||||
ADD_EXECUTABLE(CalypLibCatch2Tests ${Calyp_Lib_Catch2_Tests_SRCS})
|
||||
TARGET_LINK_LIBRARIES(CalypLibCatch2Tests ${PROJECT_LIBRARY} Catch2::Catch2)
|
||||
TARGET_LINK_LIBRARIES(CalypLibCatch2Tests ${PROJECT_LIBRARY} Catch2::Catch2WithMain)
|
||||
CATCH_DISCOVER_TESTS(CalypLibCatch2Tests)
|
||||
@@ -22,7 +22,7 @@
|
||||
* \brief CalypFrame general tests
|
||||
*/
|
||||
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_all.hpp>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
|
||||
|
||||
@@ -23,4 +23,4 @@
|
||||
*/
|
||||
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
@@ -22,7 +22,7 @@
|
||||
* \brief CalypStream general tests
|
||||
*/
|
||||
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_all.hpp>
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
#include <variant>
|
||||
@@ -51,7 +51,8 @@ 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, kStreamType );
|
||||
auto result =
|
||||
test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
|
||||
|
||||
REQUIRE( result );
|
||||
|
||||
@@ -76,11 +77,8 @@ TEST_CASE( "Can open a YUV file", "CalypStream" )
|
||||
constexpr auto KEndianness{ CLP_INVALID_ENDIANESS };
|
||||
|
||||
auto common_checks = []( auto& stream ) {
|
||||
return stream.getWidth() == kWidth &&
|
||||
stream.getHeight() == kHeight &&
|
||||
stream.getBitsPerPixel() == kBitsPel &&
|
||||
stream.getFormatName() == "YUV" &&
|
||||
stream.getCodecName() == "Raw Video" &&
|
||||
return stream.getWidth() == kWidth && stream.getHeight() == kHeight && stream.getBitsPerPixel() == kBitsPel &&
|
||||
stream.getFormatName() == "YUV" && stream.getCodecName() == "Raw Video" &&
|
||||
stream.getEndianess() == CLP_BIG_ENDIAN;
|
||||
};
|
||||
SECTION( "YUV420p" )
|
||||
@@ -90,7 +88,8 @@ 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, kStreamType );
|
||||
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 +105,8 @@ 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, kStreamType );
|
||||
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,8 @@ 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, kStreamType );
|
||||
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 +139,8 @@ 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, kStreamType );
|
||||
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();
|
||||
@@ -157,11 +159,8 @@ TEST_CASE( "Can open a RGB file", "CalypStream" )
|
||||
constexpr auto KEndianness{ CLP_INVALID_ENDIANESS };
|
||||
|
||||
auto common_checks = []( auto& stream ) {
|
||||
return stream.getWidth() == kWidth &&
|
||||
stream.getHeight() == kHeight &&
|
||||
stream.getBitsPerPixel() == kBitsPel &&
|
||||
stream.getFormatName() == "YUV" &&
|
||||
stream.getCodecName() == "Raw Video" &&
|
||||
return stream.getWidth() == kWidth && stream.getHeight() == kHeight && stream.getBitsPerPixel() == kBitsPel &&
|
||||
stream.getFormatName() == "YUV" && stream.getCodecName() == "Raw Video" &&
|
||||
stream.getEndianess() == CLP_BIG_ENDIAN;
|
||||
};
|
||||
SECTION( "RGB24" )
|
||||
@@ -170,7 +169,8 @@ 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, kStreamType );
|
||||
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,8 @@ 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, kStreamType );
|
||||
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();
|
||||
@@ -205,18 +206,16 @@ TEST_CASE( "Can open a GRAY file", "CalypStream" )
|
||||
constexpr auto KEndianness{ CLP_INVALID_ENDIANESS };
|
||||
|
||||
auto common_checks = []( auto& stream ) {
|
||||
return stream.getWidth() == kWidth &&
|
||||
stream.getHeight() == kHeight &&
|
||||
stream.getBitsPerPixel() == kBitsPel &&
|
||||
stream.getFormatName() == "YUV" &&
|
||||
stream.getCodecName() == "Raw Video" &&
|
||||
return stream.getWidth() == kWidth && stream.getHeight() == kHeight && stream.getBitsPerPixel() == kBitsPel &&
|
||||
stream.getFormatName() == "YUV" && stream.getCodecName() == "Raw Video" &&
|
||||
stream.getEndianess() == CLP_BIG_ENDIAN;
|
||||
};
|
||||
constexpr auto kInputFormat{ ClpPixelFormats::Gray };
|
||||
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, kStreamType );
|
||||
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 +244,8 @@ 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, force_raw, kStreamType );
|
||||
result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, force_raw,
|
||||
kStreamType );
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
@@ -260,7 +260,8 @@ 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, force_raw, kStreamType );
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate,
|
||||
force_raw, kStreamType );
|
||||
|
||||
REQUIRE( result );
|
||||
|
||||
|
||||
Reference in new issue
Block a user