@@ -32,7 +32,8 @@ Process(const wchar_t* inAviPath, const char* outExrPrefix, const bool PQ) {
32
32
gamma = MLImage::MLG_ST2084;
33
33
}
34
34
35
- uint8_t * buf = nullptr ;
35
+ uint8_t * buf1 = nullptr ;
36
+ uint8_t * buf2 = nullptr ;
36
37
37
38
do {
38
39
if (aviR.NumFrames () == 0 ) {
@@ -42,18 +43,23 @@ Process(const wchar_t* inAviPath, const char* outExrPrefix, const bool PQ) {
42
43
}
43
44
44
45
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 " ,
47
49
MLFourCCtoString (imgFmt.biCompression ).c_str (),
48
50
inAviPath);
49
51
b = false ;
50
52
break ;
51
53
}
52
54
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 ];
54
60
55
61
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 );
57
63
if (rv != imgFmt.biSizeImage ) {
58
64
printf (" Error: Read image #%d failed. %S\n " ,
59
65
i,
@@ -62,17 +68,27 @@ Process(const wchar_t* inAviPath, const char* outExrPrefix, const bool PQ) {
62
68
break ;
63
69
}
64
70
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
+ }
69
85
70
86
MLImage mi;
71
87
mi.Init (imgFmt.biWidth , imgFmt.biHeight ,
72
88
MLImage::IFFT_CapturedImg,
73
89
MLImage::BFT_UIntR10G10B10A2,
74
90
gamut, gamma,
75
- 10 , 3 , imgFmt.biSizeImage , buf );
91
+ 10 , 3 , imgFmt.biSizeImage , buf2 );
76
92
77
93
char outExrPath[MAX_PATH] = {};
78
94
sprintf_s (outExrPath, " %s%06d.exr" , outExrPrefix, i + 1 );
@@ -91,9 +107,12 @@ Process(const wchar_t* inAviPath, const char* outExrPrefix, const bool PQ) {
91
107
92
108
} while (false );
93
109
94
- delete[] buf;
95
- buf = nullptr ;
96
-
110
+ delete[] buf2;
111
+ buf2 = nullptr ;
112
+
113
+ delete[] buf1;
114
+ buf1 = nullptr ;
115
+
97
116
aviR.Close ();
98
117
return b;
99
118
}
0 commit comments