-
Notifications
You must be signed in to change notification settings - Fork 0
/
dump_dpx.cpp
614 lines (553 loc) · 21.4 KB
/
dump_dpx.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
/***************************************************************************
* Copyright (c) 2019-2021, Broadcom Inc.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***************************************************************************/
/** @file dump_dpx.cpp
@brief Defines the entry point for the dump_dpx application.
This file provides a sample application that dumps the header and image data for an ST 268-2 compliant DPX file.
*/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "hdr_dpx.h"
#include <iostream>
#include <sstream>
#include <iomanip>
using namespace std;
/**
Prints to cerr a specified message along with the error log from the DPX file
@param logmessage Message to include with the error log
@param f HdrDpxFile associated with DPX file
*/
static void dump_error_log(const std::string logmessage, const Dpx::HdrDpxFile &f)
{
Dpx::ErrorCode code;
Dpx::ErrorSeverity severity;
std::string msg;
std::cerr << logmessage;
for (int i = 0; i < f.GetNumErrors(); ++i)
{
f.GetError(i, code, severity, msg);
std::cerr << msg << std::endl;
}
}
/**
Converts a byte to a 2-character zero padded hex string
@param v Byte to convert
@return String representing the value of the byte
*/
inline string tohex(uint8_t v)
{
stringstream ss;
ss << setfill('0');
ss << hex << setw(2) << v;
return ss.str();
}
/**
Maps a datum label to a file extension (string)
@param dl Datum label
@param chroma_idx 0 = even line (Cb), other values = odd line (Cr) for 4:2:0
@return String containing the extension
*/
std::string datum_label_to_ext(Dpx::DatumLabel dl, uint8_t chroma_idx)
{
switch (dl)
{
case Dpx::DATUM_A:
return "a";
case Dpx::DATUM_B:
return "b";
case Dpx::DATUM_C:
if (chroma_idx == 0)
return "u";
else
return "v";
case Dpx::DATUM_CB:
return "u";
case Dpx::DATUM_COMPOSITE:
return "comp";
case Dpx::DATUM_CR:
return "v";
case Dpx::DATUM_G:
return "g";
case Dpx::DATUM_R:
return "r";
case Dpx::DATUM_Y:
return "y";
case Dpx::DATUM_Z:
return "z";
case Dpx::DATUM_UNSPEC:
return "g1";
case Dpx::DATUM_UNSPEC2:
return "g2";
case Dpx::DATUM_UNSPEC3:
return "g3";
case Dpx::DATUM_UNSPEC4:
return "g4";
case Dpx::DATUM_UNSPEC5:
return "g5";
case Dpx::DATUM_UNSPEC6:
return "g6";
case Dpx::DATUM_UNSPEC7:
return "g7";
case Dpx::DATUM_UNSPEC8:
return "g8";
// The following aren't needed but included for completeness:
case Dpx::DATUM_A2:
return "a2";
case Dpx::DATUM_Y2:
return "y2";
default:
return "unk";
}
}
/**
Converts an integer sample to a normalized [0, 1.0] double-precision value
@param i Integer sample to convert
@param is_chroma Flag indicating whether the sample is chroma
@param lowcode Low code value
@param is_signed Flag indicating whether the sample is signed
@param bit_depth_in The bit depth of the input sample
@return Normalized floating point sample
*/
inline double int_to_norm_double(int32_t i, bool is_chroma, float lowcode, bool is_signed, uint8_t bit_depth_in)
{
// Output is normalized [0..1.0]
if (is_signed) // Signed assumes full range
{
return static_cast<double>(i) / ((1 << bit_depth_in) - 1);
}
if (is_chroma && lowcode > 1) // Any low code value > 1 assumes limited range. Output floats are normalized [0..1.0]
return (static_cast<double>(i) - (1 << (bit_depth_in - 1))) / (240 << (bit_depth_in - 8)) + 0.5;
else if (!is_chroma && lowcode > 1)
return (static_cast<double>(i) - (16 << (bit_depth_in - 8))) / (219 << (bit_depth_in - 8));
else // Full range
return static_cast<double>(i) / ((1 << bit_depth_in) - 1);
}
/**
Converts a normalized [0, 1.0] double-precision value to an integer sample
@param f Double sample to convert
@param bits The desired bit depth of the integer sample
@param full_range Flag indicating whether the output sample is full range
@param is_chroma Flag indicating whether the sample is chroma
@return Integer sample
*/
inline uint16_t norm_double_to_uint(double f, uint8_t bits, bool full_range, bool is_chroma)
{
if (full_range)
{
return static_cast<uint16_t>(f * ((1 << bits) - 1) + 0.5);
}
else
{
if (is_chroma)
return static_cast<uint16_t>((f - 0.5) * (240 << (bits - 8)) + (1 << (bits - 1)) + 0.5);
else
return static_cast<uint16_t>(f * (219 << (bits - 8)) + (16 << (bits - 8)) + 0.5);
}
}
/**
Write a single 32-bit floating point sample to a file
@param rowdata vector containing FP32 sample array. There are num_components samples for each pixel.
@param bit_depth_conv If different from 32, samples are converted to a bit depth of bit_depth_conv before writing
@param hicode High code value. Note that samples beyond high & low code value could be clipped/clamped. This is not a requirement of the DPX spec but rather just an implementation choice for this example.
@param lowcode Low code value.
@param write_full_range Flag indicating the samples should be written as full range
@param is_chroma Flag indicating that the samples being written are chroma samples
@param raw_fp ofstream object to write to (assumed to be open & valid)
*/
void write_raw_datum(float rowdata, uint8_t bit_depth_conv, float hicode, float lowcode, bool write_full_range, bool is_chroma, std::shared_ptr<std::ofstream> raw_fp)
{
// Just passes through to float / double formats
if (bit_depth_conv == 32 || bit_depth_conv == 0)
{
float out = rowdata;
raw_fp->write((char *)&out, sizeof(float));
}
else if (bit_depth_conv == 64)
{
double out;
out = rowdata;
raw_fp->write((char *)&out, sizeof(double));
}
// Converts to integer (unsigned) format
else if (bit_depth_conv > 8)
{
uint16_t out;
out = norm_double_to_uint((rowdata - lowcode) / (hicode - lowcode), bit_depth_conv, write_full_range, is_chroma);
raw_fp->write((char *)&out, sizeof(uint16_t));
}
else
{
uint8_t out;
out = static_cast<uint8_t>(norm_double_to_uint((rowdata - lowcode) / (hicode - lowcode), bit_depth_conv, write_full_range, is_chroma));
raw_fp->write((char *)&out, sizeof(uint8_t));
}
}
/**
Write a single 64-bit floating point sample to a file
@param rowdata vector containing FP64 sample array. There are num_components samples for each pixel.
@param bit_depth_conv If different from 64, samples are converted to a bit depth of bit_depth_conv before writing
@param hicode High code value. Note that samples beyond high & low code value could be clipped/clamped. This is not a requirement of the DPX spec but rather just an implementation choice for this example.
@param lowcode Low code value.
@param write_full_range Flag indicating the samples should be written as full range
@param is_chroma Flag indicating that the samples being written are chroma samples
@param raw_fp ofstream object to write to (assumed to be open & valid)
*/
void write_raw_datum(double rowdata, uint8_t bit_depth_conv, float hicode, float lowcode, bool write_full_range, bool is_chroma, std::shared_ptr<std::ofstream> raw_fp)
{
// Just passes through to float / double formats
if (bit_depth_conv == 32)
{
float out = static_cast<float>(rowdata);
raw_fp->write((char *)&out, sizeof(float));
}
else if (bit_depth_conv == 64 || bit_depth_conv == 0)
{
double out;
out = rowdata;
raw_fp->write((char *)&out, sizeof(double));
}
// Converts to integer (unsigned) format
else if (bit_depth_conv > 8)
{
uint16_t out;
out = norm_double_to_uint((rowdata - lowcode) / (hicode - lowcode), bit_depth_conv, write_full_range, is_chroma);
raw_fp->write((char *)&out, sizeof(uint16_t));
}
else
{
uint8_t out;
out = static_cast<uint8_t>(norm_double_to_uint((rowdata - lowcode) / (hicode - lowcode), bit_depth_conv, write_full_range, is_chroma));
raw_fp->write((char *)&out, sizeof(uint8_t));
}
}
/**
Write a single integer sample to a file
@param rowdata vector containing FP32 sample array. There are num_components samples for each pixel.
@param bit_depth_in Bit depth of integer sample
@param bit_depth_conv If different from bit_depth_in, samples are converted to a bit depth of bit_depth_conv before writing
@param hicode High code value. Note that samples beyond high & low code value could be clipped/clamped. This is not a requirement of the DPX spec but rather just an implementation choice for this example.
@param lowcode Low code value.
@param is_signed Flag indicating sample is signed
@param write_full_range Flag indicating the samples should be written as full range
@param is_chroma Flag indicating that the samples being written are chroma samples
@param raw_fp ofstream object to write to (assumed to be open & valid)
*/
void write_raw_datum(int32_t rowdata, uint8_t bit_depth_in, uint8_t bit_depth_conv, float hicode, float lowcode, bool is_signed, bool write_full_range, bool is_chroma, std::shared_ptr<ofstream> raw_fp)
{
if (bit_depth_conv == 0)
bit_depth_conv = bit_depth_in;
if (bit_depth_conv == 32)
{
float outrow;
outrow = static_cast<float>(int_to_norm_double(rowdata, is_chroma, lowcode, is_signed, bit_depth_in));
raw_fp->write((char *)&outrow, sizeof(float));
}
else if (bit_depth_conv == 64)
{
double outrow;
outrow = (int_to_norm_double(rowdata, is_chroma, lowcode, is_signed, bit_depth_in));
raw_fp->write((char *)&outrow, sizeof(double));
}
// Converts to integer (unsigned) format
else if (bit_depth_conv > 8)
{
uint16_t outrow;
outrow = norm_double_to_uint(int_to_norm_double(rowdata, is_chroma, lowcode, is_signed, bit_depth_in), bit_depth_conv, write_full_range, is_chroma);
raw_fp->write((char *)&outrow, sizeof(uint16_t));
}
else
{
uint8_t outrow;
outrow = static_cast<uint8_t>(norm_double_to_uint(int_to_norm_double(rowdata, is_chroma, lowcode, is_signed, bit_depth_in), bit_depth_conv, write_full_range, is_chroma));
raw_fp->write((char *)&outrow, sizeof(uint8_t));
}
}
/**
Function to open all raw bitplane files for output at once for a specific image element
@param[out] fp_list vector containing the open ofstream objects
@param[in] ie_idx Current image element index (included in output file name)
@param[in] dl_list Vector (list) containing datum labels
@param[in] raw_base_name String containing the base file name for the raw files.
@param[out] alt_chroma Returns the index within fp_list of the file object that will contain the C2 samples for alternating chroma lines (4:2:0 only)
@param[out] is_chroma vector that indicates whether each returned open file contains chroma samples or not
*/
void open_raw_files(std::vector<std::shared_ptr<std::ofstream>> &fp_list, uint8_t ie_idx, std::vector<Dpx::DatumLabel> dl_list, std::string raw_base_name, uint8_t &alt_chroma, std::vector<bool> &is_chroma)
{
std::shared_ptr<std::ofstream> first_y_fp = NULL;
std::shared_ptr<std::ofstream> first_a_fp = NULL;
std::shared_ptr<std::ofstream> new_fp = NULL;
alt_chroma = UNDEFINED_U8;
for (auto c : dl_list)
{
is_chroma.push_back((c == Dpx::DATUM_C) || (c == Dpx::DATUM_CB) || (c == Dpx::DATUM_CR));
if (c == Dpx::DATUM_Y2)
fp_list.push_back(first_y_fp);
else if (c == Dpx::DATUM_A2)
fp_list.push_back(first_a_fp);
else
{
if (c == Dpx::DATUM_C)
alt_chroma = static_cast<uint8_t>(fp_list.size());
new_fp = static_cast<std::shared_ptr<std::ofstream>>(new std::ofstream);
std::string rawfilename(raw_base_name + "." + std::to_string(ie_idx) + "." + datum_label_to_ext(c, 0));
new_fp->open(rawfilename, ios::out | ios::binary);
fp_list.push_back(new_fp);
if (c == Dpx::DATUM_Y)
first_y_fp = new_fp;
if (c == Dpx::DATUM_A)
first_a_fp = new_fp;
}
}
if (alt_chroma != UNDEFINED_U8)
{
new_fp = static_cast<std::shared_ptr<std::ofstream>>(new std::ofstream);
std::string rawfilename(raw_base_name + "." + std::to_string(ie_idx) + "." + datum_label_to_ext(Dpx::DATUM_C, 1));
new_fp->open(rawfilename, ios::out | ios::binary);
fp_list.push_back(new_fp);
}
}
/**
Main entry point for the app
@param argc Number of command line arguments.
@param argv Array of char strings, each containing one command-line argument
@return Error code
*/
int main(int argc, char *argv[])
{
// Configuration variables:
uint8_t bit_depth_conv = 0;
std::string plane_order;
bool output_raw = false;
std::string raw_base_name;
bool write_full_range = false;;
if (argc < 2)
{
std::cerr << "Usage: dump_dpx <dpxfile> (-rawout <out_rawfile_base> (-plane_order <plane_order>) (-bit_depth_conv <bit_depth_conv>) (-dump_full_range))\n";
std::cerr << " <dpxfile> - DPX file to dump\n";
std::cerr << " <out_rawfile_base> - Output filename base name. The output extension will be .#.<plane_type>, where # is the first image element number and <plane_type> is y,u,v,r,g,b,a, or g0-7\n\n";
std::cerr << " <bit_depth_conv> - Convert DPX file to specified bit depth. If unspecified, uses bit depth from DPX.\n";
std::cerr << " -dump_full_range - If present, the output raw files will be full range; if absent, the output raw files will be limited range (float/double output always scaled to 0-1.0)\n";
std::cerr << " A sample in a file is stored within the smallest of (1, 2, 4, or 8) bytes that fits a <bit_depth_conv>-bit sample.\n";
std::cerr << " For example, if we have an 8-bit DPX image element and bit_depth_conv = 12, then the IE is converted from 8 to 12 bits (<<4) and\n";
std::cerr << " each 12-bit sample is placed in a 2-byte (16-bit) field in the raw file output (right-justified).\n\n";
std::cerr << " Byte order for raw file is always the native ordering of the machine\n\n";
std::cerr << " A suggested means of sanity checking an image would be to specify -rawout out -bit_depth_conv = 8; the resulting file can then be converted to a desired\n";
std::cerr << " viewing format using ffmpeg with the option -pix_fmt set to yuv420p, yuv422p, yuv444p, yuva420p, yuva422p, yuva444p rgb, or rgba based on the file type\n";
return 0;
}
// Parse arguments
std::string filename(argv[1]);
for (int i = 2; i < argc; ++i)
{
std::string arg = std::string(argv[i]);
if (!arg.compare("-rawout"))
{
output_raw = true;
raw_base_name = std::string(argv[++i]);
}
else if (!arg.compare("-plane_order"))
{
plane_order = std::string(argv[++i]);
}
else if (!arg.compare("-bit_depth_conv"))
{
bit_depth_conv = static_cast<uint8_t>(atoi(argv[++i]));
}
else if (!arg.compare("-dump_full_range"))
{
write_full_range = true;
}
else
{
std::cerr << "Unrecognized argument " << arg << "\n";
return -1;
}
}
// Shorthand to open a DPX file for reading
Dpx::HdrDpxFile f(filename);
if (!f.IsOk()) // can't open, unrecognized format
{
dump_error_log("Read failed:\n", f);
return 1;// Code to handle failure to open
}
if (!f.IsHdr())
{
// Code to handle V1.0/V2.0 DPX files
std::cout << "DPX header:\n" << f.DumpHeader();
return 0;
}
if (f.Validate()) // fields have to be valid, at least 1 image element, image data is interpretable, not out of bounds for offsets
{
dump_error_log("Validation errors:\n", f);
}
f.DumpUserDataOptions(true); // Dump user data with header
f.DumpStandardsBasedMetedataOptions(true); // Dump standards-based metadata with header
std::cout << f; // Dump header
// Output pixel data
if (output_raw) // Raw planes to files
{
// Make a list of all planes with corresponding IEs
for (auto src_ie_idx : f.GetIEIndexList())
{
std::vector<std::shared_ptr<std::ofstream>> raw_fp_list;
Dpx::HdrDpxImageElement *ie = f.GetImageElement(src_ie_idx);
uint8_t num_components = ie->GetNumberOfComponents();
uint8_t alt_chroma;
std::vector<bool> is_chroma;
open_raw_files(raw_fp_list, src_ie_idx, ie->GetDatumLabels(), raw_base_name, alt_chroma, is_chroma);
float hicode = ie->GetHeader(Dpx::eReferenceHighDataCode);
float lowcode = ie->GetHeader(Dpx::eReferenceLowDataCode);
bool is_signed = (ie->GetHeader(Dpx::eDataSign) == Dpx::eDataSignSigned);
uint8_t bit_depth_in = static_cast<uint8_t>(ie->GetHeader(Dpx::eBitDepth));
for (uint32_t row = 0; row < ie->GetHeight(); ++row)
{
if (ie->GetHeader(Dpx::eBitDepth) == Dpx::eBitDepthR32) // 32-bit float
{
std::vector<float> rowdata;
rowdata.resize(ie->GetRowSizeInDatums());
ie->Dpx2AppPixels(row, static_cast<float *>(rowdata.data()));
for (uint32_t column = 0; column < ie->GetWidth(); column++)
{
for (uint8_t c = 0; c < num_components; ++c)
{
if ((row & 1) && c == alt_chroma)
write_raw_datum(rowdata[column * num_components + c], bit_depth_conv, hicode, lowcode, write_full_range, true, raw_fp_list[num_components]);
else
write_raw_datum(rowdata[column * num_components + c], bit_depth_conv, hicode, lowcode, write_full_range, is_chroma[c], raw_fp_list[c]);
}
}
}
else if (ie->GetHeader(Dpx::eBitDepth) == Dpx::eBitDepthR64) // 64-bit float
{
std::vector<double> rowdata;
rowdata.resize(ie->GetRowSizeInDatums());
ie->Dpx2AppPixels(row, static_cast<double *>(rowdata.data()));
for (uint32_t column = 0; column < ie->GetWidth(); ++column)
{
for (uint8_t c = 0; c < num_components; ++c)
{
if ((row & 1) && c == alt_chroma)
write_raw_datum(rowdata[column * num_components + c], bit_depth_conv, hicode, lowcode, write_full_range, true, raw_fp_list[num_components]);
else
write_raw_datum(rowdata[column * num_components + c], bit_depth_conv, hicode, lowcode, write_full_range, is_chroma[c], raw_fp_list[c]);
}
}
}
else
{
std::vector<int32_t> rowdata;
rowdata.resize(ie->GetRowSizeInDatums());
ie->Dpx2AppPixels(row, static_cast<int32_t *>(rowdata.data()));
for (uint32_t column = 0; column < ie->GetWidth(); ++column)
{
for (uint8_t c = 0; c < num_components; ++c)
{
if ((row & 1) && c == alt_chroma)
write_raw_datum(rowdata[column * num_components + c], bit_depth_in, bit_depth_conv, hicode, lowcode, is_signed, write_full_range, true, raw_fp_list[num_components]);
else
write_raw_datum(rowdata[column * num_components + c], bit_depth_in, bit_depth_conv, hicode, lowcode, is_signed, write_full_range, is_chroma[c], raw_fp_list[c]);
}
}
}
}
for (auto fp : raw_fp_list)
{
fp->close();
}
}
}
else // Dump pixel data as text
{
for (auto src_ie_idx : f.GetIEIndexList())
{
Dpx::HdrDpxImageElement *ie = f.GetImageElement(src_ie_idx);
std::cout << "Component types for image element " << src_ie_idx << ": ";
for (auto c : ie->GetDatumLabels())
std::cout << ie->DatumLabelToName(c) << " ";
std::cout << "\n";
for (uint32_t row = 0; row < ie->GetHeight(); ++row)
{
std::cout << "\n" << row << ": ";
if (ie->GetHeader(Dpx::eBitDepth) == Dpx::eBitDepthR32) // 32-bit float
{
std::vector<float> rowdata;
uint32_t datum_idx = 0;
rowdata.resize(ie->GetRowSizeInDatums());
ie->Dpx2AppPixels(row, static_cast<float *>(rowdata.data()));
while (datum_idx < ie->GetWidth() * ie->GetNumberOfComponents())
{
std::cout << "(";
for (uint8_t c = 0; c < ie->GetNumberOfComponents() - 1; ++c)
{
std::cout << rowdata[datum_idx++] << ",";
}
std::cout << rowdata[datum_idx++] << ") ";
}
}
else if (ie->GetHeader(Dpx::eBitDepth) == Dpx::eBitDepthR64) // 64-bit float
{
std::vector<double> rowdata;
uint32_t datum_idx = 0;
rowdata.resize(ie->GetRowSizeInDatums());
ie->Dpx2AppPixels(row, static_cast<double *>(rowdata.data()));
for (uint32_t x = 0; x < ie->GetWidth(); ++x)
{
std::cout << "(";
for (uint8_t c = 0; c < ie->GetNumberOfComponents() - 1; ++c)
{
std::cout << rowdata[datum_idx++] << ",";
}
std::cout << rowdata[datum_idx++] << ") ";
}
}
else
{
std::vector<int32_t> rowdata;
int32_t datum_idx = 0;
rowdata.resize(ie->GetRowSizeInDatums());
ie->Dpx2AppPixels(row, static_cast<int32_t *>(rowdata.data()));
for (uint32_t x = 0; x < ie->GetWidth(); ++x)
{
std::cout << "(";
for (uint8_t c = 0; c < ie->GetNumberOfComponents() - 1; ++c)
{
std::cout << rowdata[datum_idx++] << ",";
}
std::cout << rowdata[datum_idx++] << ") ";
}
}
}
}
}
f.Close();
return 0;
}