Automated with clang-tidy readability-identifier-naming (config added to .clang-tidy) plus scripted passes, per the updated rules now documented in CONTRIBUTING.md: - types (class/struct/enum/alias/template params): PascalCase - functions, variables, members: snake_case (incl. rational -> Rational) - private/protected members: trailing underscore; static member variables likewise (instance_, available_themes_) - constants and enum values: snake_case (kLinear -> k_linear, F32P -> f32p); ALL_CAPS reserved for macros - macros: OAK_ prefix (OLIVE_ADD_TEST/OLIVE_ASSERT/OLIVE_CONFIG -> OAK_ADD_TEST/OAK_ASSERT/OAK_CONFIG, GL_PREAMBLE -> OAK_GL_PREAMBLE, include guards -> OAK_*) - file names: all lowercase (Current/Plugin/OliveHost/OliveClip/ OlivePluginInstance -> current/plugin/olivehost/oliveclip/ oliveplugininstance) - getters share the member name sans underscore, setters set_foo() - Qt and third-party (OpenFX) virtual overrides and framework callbacks keep their original names (exempt in .clang-tidy) Manual follow-ups required where automation could not reach: - string-based QMetaObject/SIGNAL/SLOT references updated to renamed methods (AddTask, CreatedFile, DeleteSpecificFile, moveSelectionUp, ...) - macro bodies referencing renamed methods (OLIVE_CONFIG, NODE_DEFAULT_DESTRUCTOR, MANAGEDDISPLAYWIDGET_*) - self-shadowing locals renamed where signals/methods became same-named (size_changed, worker_count, selected_items, import param, filters) - third_party OFX member/namespace usages restored (OFX::Host::*, _created, _clipPrefsDirty, createInstance, clearPersistentMessage) - STL protocol aliases restored (const_iterator) with .clang-tidy ignore rules; qHash overloads restored Full build and test suite pass: ctest 4/4, ~1960 gtest cases green.
132 lines
5.3 KiB
C++
132 lines
5.3 KiB
C++
#include <gtest/gtest.h>
|
|
|
|
#include "common/ffmpegutils.h"
|
|
|
|
using namespace olive;
|
|
|
|
TEST(CommonFFmpegUtils, GetNativeSampleFormatMapsCorrectly)
|
|
{
|
|
EXPECT_EQ(FFmpegUtils::get_native_sample_format(fb_sample_fmt_u8),
|
|
SampleFormat::u8);
|
|
EXPECT_EQ(FFmpegUtils::get_native_sample_format(fb_sample_fmt_s16),
|
|
SampleFormat::s16);
|
|
EXPECT_EQ(FFmpegUtils::get_native_sample_format(fb_sample_fmt_s32),
|
|
SampleFormat::s32);
|
|
EXPECT_EQ(FFmpegUtils::get_native_sample_format(fb_sample_fmt_s64),
|
|
SampleFormat::s64);
|
|
EXPECT_EQ(FFmpegUtils::get_native_sample_format(fb_sample_fmt_flt),
|
|
SampleFormat::f32);
|
|
EXPECT_EQ(FFmpegUtils::get_native_sample_format(fb_sample_fmt_dbl),
|
|
SampleFormat::f64);
|
|
EXPECT_EQ(FFmpegUtils::get_native_sample_format(fb_sample_fmt_u8_p),
|
|
SampleFormat::u8_p);
|
|
EXPECT_EQ(FFmpegUtils::get_native_sample_format(fb_sample_fmt_s16_p),
|
|
SampleFormat::s16_p);
|
|
EXPECT_EQ(FFmpegUtils::get_native_sample_format(fb_sample_fmt_s32_p),
|
|
SampleFormat::s32_p);
|
|
EXPECT_EQ(FFmpegUtils::get_native_sample_format(fb_sample_fmt_s64_p),
|
|
SampleFormat::s64_p);
|
|
EXPECT_EQ(FFmpegUtils::get_native_sample_format(fb_sample_fmt_fltp),
|
|
SampleFormat::f32_p);
|
|
EXPECT_EQ(FFmpegUtils::get_native_sample_format(fb_sample_fmt_dblp),
|
|
SampleFormat::f64_p);
|
|
EXPECT_EQ(FFmpegUtils::get_native_sample_format(fb_sample_fmt_none),
|
|
SampleFormat::invalid);
|
|
}
|
|
|
|
TEST(CommonFFmpegUtils, GetFFmpegSampleFormatMapsCorrectly)
|
|
{
|
|
EXPECT_EQ(FFmpegUtils::get_f_fmpeg_sample_format(SampleFormat::u8),
|
|
fb_sample_fmt_u8);
|
|
EXPECT_EQ(FFmpegUtils::get_f_fmpeg_sample_format(SampleFormat::s16),
|
|
fb_sample_fmt_s16);
|
|
EXPECT_EQ(FFmpegUtils::get_f_fmpeg_sample_format(SampleFormat::s32),
|
|
fb_sample_fmt_s32);
|
|
EXPECT_EQ(FFmpegUtils::get_f_fmpeg_sample_format(SampleFormat::s64),
|
|
fb_sample_fmt_s64);
|
|
EXPECT_EQ(FFmpegUtils::get_f_fmpeg_sample_format(SampleFormat::f32),
|
|
fb_sample_fmt_flt);
|
|
EXPECT_EQ(FFmpegUtils::get_f_fmpeg_sample_format(SampleFormat::f64),
|
|
fb_sample_fmt_dbl);
|
|
EXPECT_EQ(FFmpegUtils::get_f_fmpeg_sample_format(SampleFormat::u8_p),
|
|
fb_sample_fmt_u8_p);
|
|
EXPECT_EQ(FFmpegUtils::get_f_fmpeg_sample_format(SampleFormat::s16_p),
|
|
fb_sample_fmt_s16_p);
|
|
EXPECT_EQ(FFmpegUtils::get_f_fmpeg_sample_format(SampleFormat::s32_p),
|
|
fb_sample_fmt_s32_p);
|
|
EXPECT_EQ(FFmpegUtils::get_f_fmpeg_sample_format(SampleFormat::s64_p),
|
|
fb_sample_fmt_s64_p);
|
|
EXPECT_EQ(FFmpegUtils::get_f_fmpeg_sample_format(SampleFormat::f32_p),
|
|
fb_sample_fmt_fltp);
|
|
EXPECT_EQ(FFmpegUtils::get_f_fmpeg_sample_format(SampleFormat::f64_p),
|
|
fb_sample_fmt_dblp);
|
|
EXPECT_EQ(FFmpegUtils::get_f_fmpeg_sample_format(SampleFormat::invalid),
|
|
fb_sample_fmt_none);
|
|
}
|
|
|
|
TEST(CommonFFmpegUtils, ConvertJPEGSpaceToRegularSpace)
|
|
{
|
|
EXPECT_EQ(FFmpegUtils::convert_jpeg_space_to_regular_space(fb_pix_fmt_yuv_j420_p),
|
|
fb_pix_fmt_yu_v420_p);
|
|
EXPECT_EQ(FFmpegUtils::convert_jpeg_space_to_regular_space(fb_pix_fmt_yuv_j422_p),
|
|
fb_pix_fmt_yu_v422_p);
|
|
EXPECT_EQ(FFmpegUtils::convert_jpeg_space_to_regular_space(fb_pix_fmt_yuv_j444_p),
|
|
fb_pix_fmt_yu_v444_p);
|
|
EXPECT_EQ(FFmpegUtils::convert_jpeg_space_to_regular_space(fb_pix_fmt_yuv_j440_p),
|
|
fb_pix_fmt_yu_v440_p);
|
|
EXPECT_EQ(FFmpegUtils::convert_jpeg_space_to_regular_space(fb_pix_fmt_yuv_j411_p),
|
|
fb_pix_fmt_yu_v411_p);
|
|
EXPECT_EQ(FFmpegUtils::convert_jpeg_space_to_regular_space(fb_pix_fmt_yu_v420_p),
|
|
fb_pix_fmt_yu_v420_p);
|
|
}
|
|
|
|
TEST(CommonFFmpegUtils, GetCompatiblePixelFormatNative)
|
|
{
|
|
EXPECT_EQ(FFmpegUtils::get_compatible_pixel_format(PixelFormat::u8),
|
|
PixelFormat::u8);
|
|
EXPECT_EQ(FFmpegUtils::get_compatible_pixel_format(PixelFormat::u10),
|
|
PixelFormat::u8);
|
|
EXPECT_EQ(FFmpegUtils::get_compatible_pixel_format(PixelFormat::u16),
|
|
PixelFormat::u16);
|
|
EXPECT_EQ(FFmpegUtils::get_compatible_pixel_format(PixelFormat::f16),
|
|
PixelFormat::u16);
|
|
EXPECT_EQ(FFmpegUtils::get_compatible_pixel_format(PixelFormat::f32),
|
|
PixelFormat::u16);
|
|
EXPECT_EQ(FFmpegUtils::get_compatible_pixel_format(PixelFormat::invalid),
|
|
PixelFormat::invalid);
|
|
}
|
|
|
|
TEST(CommonFFmpegUtils, GetFFmpegPixelFormat)
|
|
{
|
|
EXPECT_EQ(FFmpegUtils::get_f_fmpeg_pixel_format(PixelFormat::u8,
|
|
VideoParams::k_rgb_channel_count),
|
|
fb_pix_fmt_rg_b24);
|
|
EXPECT_EQ(FFmpegUtils::get_f_fmpeg_pixel_format(PixelFormat::u16,
|
|
VideoParams::k_rgb_channel_count),
|
|
fb_pix_fmt_rg_b48_le);
|
|
EXPECT_EQ(FFmpegUtils::get_f_fmpeg_pixel_format(PixelFormat::f32,
|
|
VideoParams::k_rgb_channel_count),
|
|
fb_pix_fmt_rgb_f32_le);
|
|
EXPECT_EQ(FFmpegUtils::get_f_fmpeg_pixel_format(PixelFormat::u8,
|
|
VideoParams::k_rgba_channel_count),
|
|
fb_pix_fmt_rgba);
|
|
EXPECT_EQ(FFmpegUtils::get_f_fmpeg_pixel_format(PixelFormat::u16,
|
|
VideoParams::k_rgba_channel_count),
|
|
fb_pix_fmt_rgb_a64_le);
|
|
EXPECT_EQ(FFmpegUtils::get_f_fmpeg_pixel_format(PixelFormat::f32,
|
|
VideoParams::k_rgba_channel_count),
|
|
fb_pix_fmt_rgba_f32_le);
|
|
EXPECT_EQ(FFmpegUtils::get_f_fmpeg_pixel_format(PixelFormat::invalid, 0),
|
|
fb_pix_fmt_none);
|
|
}
|
|
|
|
TEST(CommonFFmpegUtils, GetCompatiblePixelFormatAV)
|
|
{
|
|
int fmt = FFmpegUtils::get_compatible_bridge_pixel_format(fb_pix_fmt_yu_v420_p);
|
|
EXPECT_NE(fmt, fb_pix_fmt_none);
|
|
|
|
fmt = FFmpegUtils::get_compatible_bridge_pixel_format(fb_pix_fmt_yu_v420_p,
|
|
PixelFormat::u8);
|
|
EXPECT_EQ(fmt, fb_pix_fmt_rgba);
|
|
}
|