Skip to content

Commit a836494

Browse files
committed
AviToExrSequence supports v210 AVI
1 parent 05ad94c commit a836494

File tree

3 files changed

+35
-16
lines changed

3 files changed

+35
-16
lines changed

AviToExrSequence/Main.cpp

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ Process(const wchar_t* inAviPath, const char* outExrPrefix, const bool PQ) {
3232
gamma = MLImage::MLG_ST2084;
3333
}
3434

35-
uint8_t* buf = nullptr;
35+
uint8_t* buf1 = nullptr;
36+
uint8_t* buf2 = nullptr;
3637

3738
do {
3839
if (aviR.NumFrames() == 0) {
@@ -42,18 +43,23 @@ Process(const wchar_t* inAviPath, const char* outExrPrefix, const bool PQ) {
4243
}
4344

4445
const MLBitmapInfoHeader& imgFmt = aviR.ImageFormat();
45-
if (imgFmt.biCompression != MLStringToFourCC("r210")) {
46-
printf("Error: Unsupported AVI image format %s. Only r210 is supported. %S\n",
46+
if (imgFmt.biCompression != MLStringToFourCC("r210") &&
47+
imgFmt.biCompression != MLStringToFourCC("v210")) {
48+
printf("Error: Unsupported AVI image format %s. Only r210 and v210 is supported. %S\n",
4749
MLFourCCtoString(imgFmt.biCompression).c_str(),
4850
inAviPath);
4951
b = false;
5052
break;
5153
}
5254

53-
buf = new uint8_t[imgFmt.biSizeImage];
55+
// AVIの画像読み出しバッファー。
56+
buf1 = new uint8_t[imgFmt.biSizeImage];
57+
58+
// R10G10B10A2の画像置き場。1ピクセル4バイト。
59+
buf2 = new uint8_t[imgFmt.biWidth * imgFmt.biHeight * 4];
5460

5561
for (int i = 0; i < aviR.NumFrames(); ++i) {
56-
int rv = aviR.GetImage(i, imgFmt.biSizeImage, buf);
62+
int rv = aviR.GetImage(i, imgFmt.biSizeImage, buf1);
5763
if (rv != imgFmt.biSizeImage) {
5864
printf("Error: Read image #%d failed. %S\n",
5965
i,
@@ -62,17 +68,27 @@ Process(const wchar_t* inAviPath, const char* outExrPrefix, const bool PQ) {
6268
break;
6369
}
6470

65-
conv.Rgb10bitToR10G10B10A2(
66-
(const uint32_t*)buf,
67-
(uint32_t*)buf,
68-
imgFmt.biWidth, imgFmt.biHeight, 0xff);
71+
if (imgFmt.biCompression == MLStringToFourCC("v210")) {
72+
conv.Yuv422_10bitToR10G10B10A2(
73+
(const uint32_t*)buf1,
74+
(uint32_t*)buf2,
75+
imgFmt.biWidth, imgFmt.biHeight, 0xff);
76+
} else if (imgFmt.biCompression == MLStringToFourCC("r210")) {
77+
conv.Rgb10bitToR10G10B10A2(
78+
(const uint32_t*)buf1,
79+
(uint32_t*)buf2,
80+
imgFmt.biWidth, imgFmt.biHeight, 0xff);
81+
} else {
82+
// ここには来ない。
83+
assert(0);
84+
}
6985

7086
MLImage mi;
7187
mi.Init(imgFmt.biWidth, imgFmt.biHeight,
7288
MLImage::IFFT_CapturedImg,
7389
MLImage::BFT_UIntR10G10B10A2,
7490
gamut, gamma,
75-
10, 3, imgFmt.biSizeImage, buf);
91+
10, 3, imgFmt.biSizeImage, buf2);
7692

7793
char outExrPath[MAX_PATH] = {};
7894
sprintf_s(outExrPath, "%s%06d.exr", outExrPrefix, i + 1);
@@ -91,9 +107,12 @@ Process(const wchar_t* inAviPath, const char* outExrPrefix, const bool PQ) {
91107

92108
} while (false);
93109

94-
delete[] buf;
95-
buf = nullptr;
96-
110+
delete[] buf2;
111+
buf2 = nullptr;
112+
113+
delete[] buf1;
114+
buf1 = nullptr;
115+
97116
aviR.Close();
98117
return b;
99118
}

HDR10Capture2019/MLConverter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ MLConverter::Uyvy8bitToR8G8B8A8(const uint32_t* pFrom, uint32_t* pTo, const int
194194
/// bmdFormat10BitYUV v210 → DXGI_FORMAT_R10G10B10A2_UNORM
195195
/// </summary>
196196
void
197-
MLConverter::Yuv422_10bitToR10G10B10A2(const uint32_t* pFrom, uint32_t* pTo, const int width, const int height)
197+
MLConverter::Yuv422_10bitToR10G10B10A2(const uint32_t* pFrom, uint32_t* pTo, const int width, const int height, const uint8_t alpha)
198198
{
199-
const uint32_t a = 0x3;
199+
const uint32_t a = (alpha >> 6) & 0x3;
200200

201201
assert((width % 48) == 0);
202202

HDR10Capture2019/MLConverter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class MLConverter {
1616
/// <summary>
1717
/// bmdFormat10BitYUV v210 ¨ DXGI_FORMAT_R10G10B10A2_UNORM
1818
/// </summary>
19-
static void Yuv422_10bitToR10G10B10A2(const uint32_t* pFrom, uint32_t* pTo, const int width, const int height);
19+
static void Yuv422_10bitToR10G10B10A2(const uint32_t* pFrom, uint32_t* pTo, const int width, const int height, const uint8_t alpha = 0xff);
2020

2121
/// <summary>
2222
/// bmdFormat8BitARGB ¨ DXGI_FORMAT_R8G8B8A8_UNORM

0 commit comments

Comments
 (0)