Fix compilation errors and add new tests

This commit is contained in:
jfmcarreira committed 2021-10-15 23:40:41 +01:00
1 parent 26f3dc7612
commit 09ec5213c3
4 files changed
+187 -26

No files matched your search

+159 -1
View File
@@ -24,6 +24,7 @@
#include <catch2/catch.hpp>
#include <filesystem>
#include <iostream>
#include <variant>
#include "CalypFrame.h"
@@ -67,6 +68,163 @@ TEST_CASE( "Can open a YUV 420p file", "CalypStream" )
CHECK( frame->getPixel( 336, 278 ) == CalypPixel{ CLP_COLOR_YUV, 99, 111, 142 } );
}
TEST_CASE( "Can open a YUV file", "CalypStream" )
{
constexpr int kWidth{ 352 };
constexpr int kHeight{ 288 };
constexpr int kBitsPel{ 8 };
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" &&
stream.getEndianess() == CLP_BIG_ENDIAN;
};
SECTION( "YUV420p" )
{
constexpr auto kInputFormat{ CalypPixelFormats::CLP_YUV420P };
const auto kFilename = getFileTestFilename( "Foreman.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 );
REQUIRE( result );
CHECK( common_checks( test_stream ) );
const auto* frame = test_stream.getCurrFrame();
CHECK( frame->getColorSpace() == CLP_COLOR_YUV );
CHECK( frame->getPelFmtName() == "YUV420p" );
CHECK( frame->getPelFormat() == kInputFormat );
}
SECTION( "YUV422p" )
{
constexpr auto kInputFormat{ CalypPixelFormats::CLP_YUV422P };
const auto kFilename = getFileTestFilename( "Foreman_352x288_yuv422p.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 );
REQUIRE( result );
CHECK( common_checks( test_stream ) );
const auto* frame = test_stream.getCurrFrame();
CHECK( frame->getColorSpace() == CLP_COLOR_YUV );
CHECK( frame->getPelFmtName() == "YUV422p" );
CHECK( frame->getPelFormat() == kInputFormat );
}
SECTION( "YUV444p" )
{
constexpr auto kInputFormat{ CalypPixelFormats::CLP_YUV444P };
const auto kFilename = getFileTestFilename( "Foreman_352x288_yuv444p.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 );
REQUIRE( result );
CHECK( common_checks( test_stream ) );
const auto* frame = test_stream.getCurrFrame();
CHECK( frame->getColorSpace() == CLP_COLOR_YUV );
CHECK( frame->getPelFmtName() == "YUV444p" );
CHECK( frame->getPelFormat() == kInputFormat );
}
SECTION( "YUYV422" )
{
constexpr auto kInputFormat{ CalypPixelFormats::CLP_YUYV422 };
const auto kFilename = getFileTestFilename( "Foreman_352x288_yuyv422.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 );
REQUIRE( result );
CHECK( common_checks( test_stream ) );
const auto* frame = test_stream.getCurrFrame();
CHECK( frame->getColorSpace() == CLP_COLOR_YUV );
CHECK( frame->getPelFmtName() == "YUYV422" );
CHECK( frame->getPelFormat() == kInputFormat );
}
}
TEST_CASE( "Can open a RGB file", "CalypStream" )
{
constexpr int kWidth{ 352 };
constexpr int kHeight{ 288 };
constexpr int kBitsPel{ 8 };
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" &&
stream.getEndianess() == CLP_BIG_ENDIAN;
};
SECTION( "RGB24" )
{
constexpr auto kInputFormat{ CalypPixelFormats::CLP_RGB24 };
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 );
REQUIRE( result );
CHECK( common_checks( test_stream ) );
const auto* frame = test_stream.getCurrFrame();
CHECK( frame->getColorSpace() == CLP_COLOR_RGB );
CHECK( frame->getPelFmtName() == "RGB" );
CHECK( frame->getPelFormat() == kInputFormat );
std::cout << test_stream.getFormatName();
}
SECTION( "BGR24" )
{
constexpr auto kInputFormat{ CalypPixelFormats::CLP_BGR24 };
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 );
REQUIRE( result );
CHECK( common_checks( test_stream ) );
const auto* frame = test_stream.getCurrFrame();
CHECK( frame->getColorSpace() == CLP_COLOR_RGB );
CHECK( frame->getPelFmtName() == "BGR" );
CHECK( frame->getPelFormat() == kInputFormat );
}
}
TEST_CASE( "Can open a GRAY file", "CalypStream" )
{
constexpr int kWidth{ 352 };
constexpr int kHeight{ 288 };
constexpr int kBitsPel{ 8 };
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" &&
stream.getEndianess() == CLP_BIG_ENDIAN;
};
constexpr auto kInputFormat{ CalypPixelFormats::CLP_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, true );
REQUIRE( result );
CHECK( common_checks( test_stream ) );
const auto* frame = test_stream.getCurrFrame();
CHECK( frame->getColorSpace() == CLP_COLOR_GRAY );
CHECK( frame->getPelFmtName() == "GRAY" );
CHECK( frame->getPelFormat() == kInputFormat );
}
TEST_CASE( "Can open .batatas file as RAW video", "CalypStream" )
{
constexpr int kWidth{ 352 };
@@ -109,7 +267,7 @@ TEST_CASE( "Can open .batatas file as RAW video", "CalypStream" )
CHECK( test_stream.getWidth() == kWidth );
CHECK( test_stream.getHeight() == kHeight );
CHECK( test_stream.getBitsPerPixel() == kBitsPel );
CHECK( test_stream.getFormatName() == "YUV" );
CHECK( test_stream.getFormatName() == "BATATAS" );
CHECK( test_stream.getCodecName() == "Raw Video" );
CHECK( test_stream.getEndianess() == CLP_BIG_ENDIAN );