forked from unity3d-jp/FrameCapturer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConvertTest.cpp
63 lines (51 loc) · 1.88 KB
/
ConvertTest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "TestCommon.h"
const void* fcConvertPixelFormat(void *dst, fcPixelFormat dstfmt, const void *src, fcPixelFormat srcfmt, size_t size);
const int Width = 320;
const int Height = 240;
template<class Src, class Dst>
void ConvertTestImpl(fcIPngContext *ctx, TBuffer<Src>& src)
{
char filename[128];
sprintf(filename, "%s_to_%s.png", GetPixelFormat<Src>::getName(), GetPixelFormat<Dst>::getName());
TBuffer<Dst> dst;
dst.resize(Width * Height);
auto data = fcConvertPixelFormat(&dst[0], GetPixelFormat<Dst>::value, &src[0], GetPixelFormat<Src>::value, src.size());
fcPngExportPixels(ctx, filename, data, Width, Height, GetPixelFormat<Dst>::value);
}
void ConvertTest()
{
printf("ConvertTest begin\n");
fcPngConfig conf;
fcIPngContext *ctx = fcPngCreateContext(&conf);
#define TestCases(SrcT)\
{\
TBuffer<SrcT> video_frame(Width * Height);\
CreateVideoData(&video_frame[0], Width, Height, 0);\
ConvertTestImpl<SrcT, RGBAu8>(ctx, video_frame);\
ConvertTestImpl<SrcT, RGBu8>(ctx, video_frame);\
ConvertTestImpl<SrcT, RGu8>(ctx, video_frame);\
ConvertTestImpl<SrcT, Ru8>(ctx, video_frame);\
ConvertTestImpl<SrcT, RGBAf16>(ctx, video_frame);\
ConvertTestImpl<SrcT, RGBf16>(ctx, video_frame);\
ConvertTestImpl<SrcT, RGf16>(ctx, video_frame);\
ConvertTestImpl<SrcT, Rf16>(ctx, video_frame);\
ConvertTestImpl<SrcT, RGBAf32>(ctx, video_frame);\
ConvertTestImpl<SrcT, RGBf32>(ctx, video_frame);\
ConvertTestImpl<SrcT, RGf32>(ctx, video_frame);\
ConvertTestImpl<SrcT, Rf32>(ctx, video_frame);\
}
TestCases(RGBAu8);
TestCases(RGBu8);
TestCases(RGu8);
TestCases(Ru8);
TestCases(RGBAf16);
TestCases(RGBf16);
TestCases(RGf16);
TestCases(Rf16);
TestCases(RGBAf32);
TestCases(RGBf32);
TestCases(RGf32);
TestCases(Rf32);
fcPngDestroyContext(ctx);
printf("ConvertTest end\n");
}