Skip to content

Commit 76040a0

Browse files
committed
openmp parallelize pixel format conversion
1 parent 34a7a68 commit 76040a0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

HDR10Capture2019/MLConverter.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ MLConverter::MLConverter(void)
7171
void
7272
MLConverter::Argb8bitToR8G8B8A8(const uint32_t* pFrom, uint32_t* pTo, const int width, const int height)
7373
{
74+
#pragma omp parallel for
7475
for (int y = 0; y < height; ++y) {
7576
for (int x = 0; x < width; ++x) {
7677
const int pos = x + y * width;
@@ -96,6 +97,8 @@ void
9697
MLConverter::Rgb10bitToRGBA8bit(const uint32_t *pFrom, uint32_t *pTo, const int width, const int height, const uint8_t alpha)
9798
{
9899
const uint32_t a = alpha;
100+
101+
#pragma omp parallel for
99102
for (int y = 0; y < height; ++y) {
100103
for (int x = 0; x < width; ++x) {
101104
const int pos = x + y * width;
@@ -123,6 +126,8 @@ void
123126
MLConverter::Rgb10bitToR10G10B10A2(const uint32_t* pFrom, uint32_t* pTo, const int width, const int height, const uint8_t alpha)
124127
{
125128
const uint32_t a = (alpha >> 6) & 0x3;
129+
130+
#pragma omp parallel for
126131
for (int y = 0; y < height; ++y) {
127132
for (int x = 0; x < width; ++x) {
128133
const int pos = x + y * width;
@@ -153,6 +158,7 @@ MLConverter::R10G10B10A2ToExrHalfFloat(const uint32_t* pFrom, uint16_t* pTo, con
153158
// 0.0~1.0の範囲の値。
154159
half aF = (float)(alpha /255.0f);
155160

161+
#pragma omp parallel for
156162
for (int y = 0; y < height; ++y) {
157163
for (int x = 0; x < width; ++x) {
158164
const int readPos = x + y * width;
@@ -209,6 +215,7 @@ MLConverter::R10G10B10A2ToR210(const uint32_t* pFrom, uint32_t* pTo, const int w
209215
{
210216
const uint32_t a = (alpha >> 6) & 0x3;
211217

218+
#pragma omp parallel for
212219
for (int y = 0; y < height; ++y) {
213220
for (int x = 0; x < width; ++x) {
214221
const int pos = x + y * width;
@@ -243,6 +250,7 @@ MLConverter::Rgb12bitToR8G8B8A8(const uint32_t* pFrom, uint32_t* pTo, const int
243250
const uint8_t a = alpha;
244251
const int pixelCount = width * height;
245252

253+
#pragma omp parallel for
246254
for (int i=0; i<pixelCount/8; ++i) {
247255
const int fromPos = i * 9;
248256
const int toPos = i * 8;
@@ -363,6 +371,7 @@ MLConverter::Rgb12bitToR10G10B10A2(const uint32_t* pFrom, uint32_t* pTo, const i
363371
const uint8_t a = (alpha>>6) & 0x3;
364372
const int pixelCount = width * height;
365373

374+
#pragma omp parallel for
366375
for (int i=0; i<pixelCount/8; ++i) {
367376
const int fromPos = i * 9;
368377
const int toPos = i * 8;
@@ -484,6 +493,7 @@ MLConverter::Rgb12bitToR210(const uint32_t* pFrom, uint32_t* pTo, const int widt
484493
const uint8_t a = 0x3;
485494
const int pixelCount = width * height;
486495

496+
#pragma omp parallel for
487497
for (int i=0; i<pixelCount/8; ++i) {
488498
const int fromPos = i * 9;
489499
const int toPos = i * 8;
@@ -619,6 +629,7 @@ MLConverter::Rgb12bitToR16G16B16A16(const uint32_t* pFrom, uint64_t* pTo, const
619629
const uint16_t a = alpha * 257; //< 255 * 257 = 65535
620630
const int pixelCount = width * height;
621631

632+
#pragma omp parallel for
622633
for (int i = 0; i < pixelCount / 8; ++i) {
623634
const int fromPos = i * 9;
624635
const int toPos = i * 8;
@@ -725,5 +736,4 @@ MLConverter::Rgb12bitToR16G16B16A16(const uint32_t* pFrom, uint64_t* pTo, const
725736
pTo[toPos + 6] = ((uint64_t)a << 48) + ((uint64_t)b6 << 32) + ((uint32_t)g6 << 16) + r6;
726737
pTo[toPos + 7] = ((uint64_t)a << 48) + ((uint64_t)b7 << 32) + ((uint32_t)g7 << 16) + r7;
727738
}
728-
729739
}

0 commit comments

Comments
 (0)