1 // -*- mode: C++; tab-width: 4 -*- 2 // vi: ts=4 3 4 /*! \file DPXHeader.h */ 5 6 /* 7 * Copyright (c) 2009, Patrick A. Palmer. 8 * All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions are met: 12 * 13 * - Redistributions of source code must retain the above copyright notice, 14 * this list of conditions and the following disclaimer. 15 * 16 * - Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 20 * - Neither the name of Patrick A. Palmer nor the names of its 21 * contributors may be used to endorse or promote products derived from 22 * this software without specific prior written permission. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 * POSSIBILITY OF SUCH DAMAGE. 35 */ 36 37 38 // SMPTE DPX graphic file format v2.0 39 40 41 #ifndef _DPX_DPXHEADER_H 42 #define _DPX_DPXHEADER_H 1 43 44 #include <cstring> 45 #include <OpenImageIO/strutil.h> 46 #include "DPXStream.h" 47 48 49 50 /*! 51 * \def SMPTE_VERSION 52 * \brief SMPTE 268M-2003 DPX Version 53 */ 54 #define SMPTE_VERSION "V2.0" 55 56 /*! 57 * \def MAX_ELEMENTS 58 * \brief Maximum number of image elements 59 */ 60 #define MAX_ELEMENTS 8 61 62 /*! 63 * \def MAX_COMPONENTS 64 * \brief Maximum number of components per image element 65 */ 66 #define MAX_COMPONENTS 8 67 68 69 /*! 70 * \def MAGIC_COOKIE 71 * \brief HEX value of "SDPX" 72 */ 73 #define MAGIC_COOKIE 0x53445058 74 75 76 77 78 namespace dpx 79 { 80 81 82 // DPX data types 83 84 /*! 85 * \typedef unsigned char U8 86 * \brief Unsigned 8 bit integer 87 */ 88 typedef unsigned char U8; 89 90 /*! 91 * \typedef unsigned char U16 92 * \brief Unsigned 16 bit integer 93 */ 94 typedef unsigned short U16; 95 96 /*! 97 * \typedef unsigned char U32 98 * \brief Unsigned 32 bit integer 99 */ 100 typedef unsigned int U32; 101 102 /*! 103 * \typedef float R32 104 * \brief 32 bit floating point number 105 */ 106 typedef float R32; 107 108 /*! 109 * \typedef float R64 110 * \brief 64 bit floating point number 111 */ 112 typedef double R64; 113 114 /*! 115 * \typedef char ASCII 116 * \brief ASCII character 117 */ 118 typedef char ASCII; 119 120 121 /*! 122 * \enum DataSize 123 * \brief Component Data Storage Data Type 124 */ 125 enum DataSize 126 { 127 kByte, //!< 8-bit size component 128 kWord, //!< 129 kInt, //!< 130 kFloat, //!< 131 kDouble //!< 132 }; 133 134 135 /*! 136 * \enum Orientation 137 * \brief Image Orientation Code 138 */ 139 enum Orientation 140 { 141 kLeftToRightTopToBottom = 0, //!< Oriented left to right, top to bottom 142 kRightToLeftTopToBottom = 1, //!< Oriented right to left, top to bottom 143 kLeftToRightBottomToTop = 2, //!< Oriented left to right, bottom to top 144 kRightToLeftBottomToTop = 3, //!< Oriented right to left, bottom to top 145 kTopToBottomLeftToRight = 4, //!< Oriented top to bottom, left to right 146 kTopToBottomRightToLeft = 5, //!< Oriented top to bottom, right to left 147 kBottomToTopLeftToRight = 6, //!< Oriented bottom to top, left to right 148 kBottomToTopRightToLeft = 7, //!< Oriented bottom to top, right to left 149 kUndefinedOrientation = 0xffff //!< Undefined orientation 150 }; 151 152 153 /*! 154 * \enum Descriptor 155 * \brief Image element Descriptor 156 */ 157 enum Descriptor 158 { 159 kUserDefinedDescriptor = 0, //!< User defined descriptor 160 kRed = 1, //!< Red 161 kGreen = 2, //!< Green 162 kBlue = 3, //!< Blue 163 kAlpha = 4, //!< Alpha 164 kLuma = 6, //!< Luma (Y) 165 kColorDifference = 7, //!< Color difference 166 kDepth = 8, //!< Depth 167 kCompositeVideo = 9, //!< Composite video 168 kRGB = 50, //!< R,G,B 169 kRGBA = 51, //!< R,G,B,A 170 kABGR = 52, //!< A,B,G,R 171 kCbYCrY = 100, //!< Cb,Y,Cr,Y (4:2:2) 172 kCbYACrYA = 101, //!< Cb,Y,A,Cr,Y,A (4:2:2:4) 173 kCbYCr = 102, //!< Cb,Y,Cr (4:4:4) 174 kCbYCrA = 103, //!< Cb,Y,Cr,A (4:4:4:4) 175 kUserDefined2Comp = 150, //!< User defined 2 component element 176 kUserDefined3Comp = 151, //!< User defined 3 component element 177 kUserDefined4Comp = 152, //!< User defined 4 component element 178 kUserDefined5Comp = 153, //!< User defined 5 component element 179 kUserDefined6Comp = 154, //!< User defined 6 component element 180 kUserDefined7Comp = 155, //!< User defined 7 component element 181 kUserDefined8Comp = 156, //!< User defined 8 component element 182 kUndefinedDescriptor = 0xff //!< Undefined descriptor 183 }; 184 185 186 /*! 187 * \enum Characteristic 188 * \brief Transfer Characteristic and Colorimetric Specification 189 */ 190 enum Characteristic 191 { 192 kUserDefined = 0, //!< User defined 193 kPrintingDensity = 1, //!< Printing density 194 kLinear = 2, //!< Linear, transfer only 195 kLogarithmic = 3, //!< Logarithmic, transfer only 196 kUnspecifiedVideo = 4, //!< Unspecified video 197 kSMPTE274M = 5, //!< SMPTE 274M 198 kITUR709 = 6, //!< ITU-R 709-4 199 kITUR601 = 7, //!< ITU-R 601-5 system B or G 200 kITUR602 = 8, //!< ITU-R 601-5 system M 201 kNTSCCompositeVideo = 9, //!< NTSC composite video 202 kPALCompositeVideo = 10, //!< PAL composite video 203 kZLinear = 11, //!< Z depth linear, transfer only 204 kZHomogeneous = 12, //!< Z depth homogeneous, transfer only 205 kADX = 13, //!< SMPTE ST 2065-3 Academy Density Exchange Encoding (ADX) 206 kUndefinedCharacteristic = 0xff //!< Undefined 207 }; 208 209 210 /*! 211 * \enum VideoSignal 212 * \brief Video Signal Standard 213 */ 214 enum VideoSignal 215 { 216 kUndefined = 0, //!< Undefined 217 kNTSC = 1, //!< NTSC 218 kPAL = 2, //!< PAL 219 kPAL_M = 3, //!< PAL-M 220 kSECAM = 4, //!< SECAM 221 k525LineInterlace43AR = 50, //!< YCbCr ITU-R 601-5 525-line, 2:1 interlace, 4:3 aspect ratio 222 k625LineInterlace43AR = 51, //!< YCbCr ITU-R 601-5 625-line, 2:1 interlace, 4:3 aspect ratio 223 k525LineInterlace169AR = 100, //!< YCbCr ITU-R 601-5 525-line, 2:1 interlace, 16:9 aspect ratio 224 k625LineInterlace169AR = 101, //!< YCbCr ITU-R 601-5 625-line, 2:1 interlace, 16:9 aspect ratio 225 k1050LineInterlace169AR = 150, //!< YCbCr 1050-line, 2:1 interlace, 16:9 aspect ratio 226 k1125LineInterlace169AR_274 = 151, //!< YCbCr 1125-line, 2:1 interlace, 16:9 aspect ratio (SMPTE 274M) 227 k1250LineInterlace169AR = 152, //!< YCbCr 1250-line, 2:1 interlace, 16:9 aspect ratio 228 k1125LineInterlace169AR_240 = 153, //!< YCbCr 1125-line, 2:1 interlace, 16:9 aspect ratio (SMPTE 240M) 229 k525LineProgressive169AR = 200, //!< YCbCr 525-line, 1:1 progressive, 16:9 aspect ratio 230 k625LineProgressive169AR = 201, //!< YCbCr 625-line, 1:1 progressive, 16:9 aspect ratio 231 k750LineProgressive169AR = 202, //!< YCbCr 750-line, 1:1 progressive, 16:9 aspect ratio (SMPTE 296M) 232 k1125LineProgressive169AR = 203, //!< YCbCr 1125-line, 1:1 progressive, 16:9 aspect ratio (SMPTE 274M) 233 k255 = 255 234 }; 235 236 237 /*! 238 * \enum Packing 239 * \brief Component data packing method 240 */ 241 enum Packing 242 { 243 kPacked = 0, //!< Packed into 32-bit words 244 kFilledMethodA = 1, //!< Filled to 32-bit words, method A 245 kFilledMethodB = 2 //!< Filled to 32-bit words, method B 246 }; 247 248 249 /*! 250 * \enum Encoding 251 * \brief Component data encoding method 252 */ 253 enum Encoding 254 { 255 kNone = 0, //<! No encoding 256 kRLE = 1 //<! Run length encoding 257 }; 258 259 260 /*! 261 * \struct ImageElement 262 * \brief Data Structure for Image Element 263 */ 264 struct ImageElement 265 { 266 U32 dataSign; //!< Data sign (0 = unsigned, 1 = signed) 267 U32 lowData; //!< Reference low data code value 268 R32 lowQuantity; //!< Reference low quantity represented 269 U32 highData; //!< Reference high data code value 270 R32 highQuantity; //!< Reference high quantity represented 271 U8 descriptor; //!< Descriptor \see Descriptor 272 U8 transfer; //!< Transfer characteristic \see Characteristic 273 U8 colorimetric; //!< Colorimetric Specification \see Characteristic 274 U8 bitDepth; //!< Bit depth, valid values are 8,10,12,16,32,64 275 U16 packing; //!< Packing \see Packing 276 U16 encoding; //!< Encoding \see Encoding 277 U32 dataOffset; //!< Offset to data 278 U32 endOfLinePadding; //!< End-of-Line Padding 279 U32 endOfImagePadding; //!< End-of-Image Padding 280 ASCII description[32]; //!< Description of Image Element 281 282 /*! 283 * \brief Constructor 284 */ 285 ImageElement(); 286 }; 287 288 289 290 291 /*! 292 * \struct GenericHeader 293 * \brief Generic File and Image Header Information 294 */ 295 struct GenericHeader 296 { 297 /*! 298 * \name File Information Members 299 */ 300 //@{ 301 U32 magicNumber; //!< Indicates start of DPX image file and is used to determine byte order. 302 U32 imageOffset; //!< Offset to image data (in bytes) 303 ASCII version[8]; //!< Version number of header format 304 U32 fileSize; //!< Total file size (in bytes) 305 U32 dittoKey; //!< Ditto Key (0 = same as previous frame, 1 = new) 306 U32 genericSize; //!< Generic Header length (in bytes) 307 U32 industrySize; //!< Industry Header length (in bytes) 308 U32 userSize; //!< User defined header length (in bytes) 309 ASCII fileName[100]; //!< File name 310 ASCII creationTimeDate[24]; //!< Create date time /see DateTimeFormat 311 ASCII creator[100]; //!< Creator 312 ASCII project[200]; //!< Project name 313 ASCII copyright[200]; //!< Copyright statement 314 U32 encryptKey; //!< Encryption Key (0xffffffff if unencrypted) 315 ASCII reserved1[104]; //!< Reserved 316 /* end of group */ 317 //@} 318 319 320 /*! 321 * \name Image Information Members 322 */ 323 //@{ 324 U16 imageOrientation; //!< Image orientation \see Orientation 325 U16 numberOfElements; //!< Number of elements (1-8) 326 U32 pixelsPerLine; //!< Pixels per line 327 U32 linesPerElement; //!< Lines per element 328 ImageElement chan[MAX_ELEMENTS]; //!< Image element data structures 329 ASCII reserved2[52]; //!< Reserved 330 /* end of group */ 331 //@} 332 333 334 /*! 335 * \name Image Origination Members 336 */ 337 //@{ 338 U32 xOffset; //!< X offset 339 U32 yOffset; //!< Y offset 340 R32 xCenter; //!< X center 341 R32 yCenter; //!< Y center 342 U32 xOriginalSize; //!< X original size 343 U32 yOriginalSize; //!< Y original size 344 ASCII sourceImageFileName[100]; //!< Source image file name 345 ASCII sourceTimeDate[24]; //!< Source date and time /see DateTimeFormat 346 ASCII inputDevice[32]; //!< Input device name 347 ASCII inputDeviceSerialNumber[32]; //!< Input device serial number 348 U16 border[4]; //!< Border validity 349 U32 aspectRatio[2]; //!< Pixel aspect ratio (horizontal:vertical) 350 R32 xScannedSize; //!< X scanned size 351 R32 yScannedSize; //!< Y scanned size 352 ASCII reserved3[20]; //!< Reserved 353 /* end of group */ 354 //@} 355 356 /*! 357 * \brief Constructor 358 */ 359 GenericHeader(); 360 361 /*! 362 * \brief Reset class to initial state 363 */ 364 void Reset(); 365 366 367 368 /*! 369 * \name File Information Methods 370 */ 371 //@{ 372 373 /*! 374 * \brief Get magic number, used for byte ordering identification 375 * \return magic number 376 */ 377 inline U32 MagicNumber() const; 378 379 /*! 380 * \brief Get the offset in bytes to the start of the first image element 381 * \return offset 382 */ 383 inline U32 ImageOffset() const; 384 385 /*! 386 * \brief Set the offset in bytes to the start of the first image element 387 * \param offset offset in bytes 388 */ 389 inline void SetImageOffset(const U32 offset); 390 391 /*! 392 * \brief Get current version string of header 393 * \param v buffer to place string, needs to be at least 8+1 bytes long 394 */ 395 inline void Version(char *v) const; 396 397 /*! 398 * \brief Set the version string 399 * \param v version string 400 */ 401 inline void SetVersion(const char *v); 402 403 /*! 404 * \brief Get the size of the entire file 405 * \return file size in bytes 406 */ 407 inline U32 FileSize() const; 408 409 /*! 410 * \brief Set the size of the entire file 411 * \param fs file size in bytes 412 */ 413 inline void SetFileSize(const U32 fs); 414 415 /*! 416 * \brief Get the ditto key 417 * \return ditto key 418 */ 419 inline U32 DittoKey() const; 420 421 /*! 422 * \brief Set the ditto key 423 * \param key ditto key 424 */ 425 inline void SetDittoKey(const U32 key); 426 427 /*! 428 * \brief Get the size of the generic section within the header 429 * \return generic header size in bytes 430 */ 431 inline U32 GenericSize() const; 432 433 /*! 434 * \brief Get the size of the industry section within the header 435 * \return industry header size in bytes 436 */ 437 inline U32 IndustrySize() const; 438 439 /*! 440 * \brief Get the size of the user data 441 * \return user data size in bytes 442 */ 443 inline U32 UserSize() const; 444 445 /*! 446 * \brief Set the size of the user data 447 * \param size user data size in bytes 448 */ 449 inline void SetUserSize(const U32 size); 450 451 /*! 452 * \brief Get the file name 453 * \param fn buffer to store filename (100+1 chars) 454 */ 455 inline void FileName(char *fn) const; 456 457 /*! 458 * \brief Set the file name 459 * \param fn buffer with filename 460 */ 461 inline void SetFileName(const char *fn); 462 463 /*! 464 * \brief Get the creation time/date 465 * \param ct buffer to store creation time/date (24+1 chars) 466 */ 467 inline void CreationTimeDate(char *ct) const; 468 469 /*! 470 * \brief Set the creation time/date 471 * \param ct buffer with creation time/date 472 */ 473 inline void SetCreationTimeDate(const char *ct); 474 475 476 /*! 477 * \brief Set the creation time/date 478 * \param secs number of seconds since January 1, 1970 00:00 479 */ 480 void SetCreationTimeDate(const long secs); 481 482 /*! 483 * \brief Get the creator 484 * \param creat buffer to store creator (100+1 chars) 485 */ 486 inline void Creator(char *creat) const; 487 488 /*! 489 * \brief Set the creator 490 * \param creat buffer with creator 491 */ 492 inline void SetCreator(const char *creat); 493 494 /*! 495 * \brief Get the project 496 * \param prj buffer to store project (200+1 chars) 497 */ 498 inline void Project(char *prj) const; 499 500 /*! 501 * \brief Set the project 502 * \param prj buffer with project 503 */ 504 inline void SetProject(const char *prj); 505 506 /*! 507 * \brief Get the copyright information 508 * \param copy buffer to store copyright string (200+1 chars) 509 */ 510 inline void Copyright(char *copy) const; 511 512 /*! 513 * \brief Set the copyright information 514 * \param copy buffer with copyright string 515 */ 516 inline void SetCopyright(const char *copy); 517 518 /*! 519 * \brief Get the encryption key (no encryption is 0xffffffff) 520 * \return encryption key 521 */ 522 inline U32 EncryptKey() const; 523 524 /*! 525 * \brief Set the encryption key (no encryption is 0xffffffff) 526 * \param key encryption key 527 */ 528 inline void SetEncryptKey(const U32 key); 529 /* end of group */ 530 //@} 531 532 533 /*! 534 * \name Image Information Methods 535 */ 536 //@{ 537 538 /*! 539 * \brief Get the image orientation 540 * \return orientation enum 541 */ 542 inline Orientation ImageOrientation() const; 543 544 /*! 545 * \brief Set the image orientation 546 * \param orient orientation 547 */ 548 inline void SetImageOrientation(const Orientation orient); 549 550 /*! 551 * \brief Get the number of elements 552 * \return element count 553 */ 554 inline U16 NumberOfElements() const; 555 556 /*! 557 * \brief Set the number of elements 558 * \param num element count 559 */ 560 inline void SetNumberOfElements(const U16 num); 561 562 /*! 563 * \brief Get the pixels per line 564 * \return pixel count 565 */ 566 inline U32 PixelsPerLine() const; 567 568 /*! 569 * \brief Set the pixels per line 570 * \param ppl pixel count 571 */ 572 inline void SetPixelsPerLine(const U32 ppl); 573 574 /*! 575 * \brief Get the lines per element 576 * \return lines count 577 */ 578 inline U32 LinesPerElement() const; 579 580 /*! 581 * \brief Set the lines per element 582 * \param lpe lines count 583 */ 584 inline void SetLinesPerElement(const U32 lpe); 585 586 /*! 587 * \brief Get the data sign (0 = unsigned, 1 = signed) 588 * \param i element index (0-7) 589 * \return data sign 590 */ 591 inline U32 DataSign(const int i) const; 592 593 /*! 594 * \brief Set the data sign (0 = unsigned, 1 = signed) 595 * \param i element index (0-7) 596 * \param sign data sign 597 */ 598 inline void SetDataSign(const int i, const U32 sign); 599 600 /*! 601 * \brief Get the minimum data value 602 * \param i element index (0-7) 603 * \return minimum value 604 */ 605 inline U32 LowData(const int i) const; 606 607 /*! 608 * \brief Set the minimum data value 609 * \param i element index (0-7) 610 * \param data minimum value 611 */ 612 inline void SetLowData(const int i, const U32 data); 613 614 /*! 615 * \brief Get the quantity of minimum data value 616 * \param i element index (0-7) 617 * \return quantity 618 */ 619 inline R32 LowQuantity(const int i) const; 620 621 /*! 622 * \brief Set the quantity of minimum data value 623 * \param i element index (0-7) 624 * \param quant quantity 625 */ 626 inline void SetLowQuantity(const int i, const R32 quant); 627 628 /*! 629 * \brief Get the maximum data value 630 * \param i element index (0-7) 631 * \return maximum value 632 */ 633 inline U32 HighData(const int i) const; 634 635 /*! 636 * \brief Set the maximum data value 637 * \param i element index (0-7) 638 * \param data maximum value 639 */ 640 inline void SetHighData(const int i, const U32 data); 641 642 /*! 643 * \brief Get the quantity of maximum data value 644 * \param i element index (0-7) 645 * \return quantity 646 */ 647 inline R32 HighQuantity(const int i) const; 648 649 /*! 650 * \brief Set the quantity of maximum data value 651 * \param i element index (0-7) 652 * \param quant quantity 653 */ 654 inline void SetHighQuantity(const int i, const R32 quant); 655 656 /*! 657 * \brief Get the component defintion 658 * \param i element index (0-7) 659 * \return component descriptor 660 */ 661 inline Descriptor ImageDescriptor(const int i) const; 662 663 /*! 664 * \brief Set the component defintion 665 * \param i element index (0-7) 666 * \param desc component descriptor 667 */ 668 inline void SetImageDescriptor(const int i, const Descriptor desc); 669 670 /*! 671 * \brief Get the amplitude transfer function 672 * \param i element index (0-7) 673 * \return transfer characteristic 674 */ 675 inline Characteristic Transfer(const int i) const; 676 677 /*! 678 * \brief Set the amplitude transfer function 679 * \param i element index (0-7) 680 * \param ch transfer characteristic 681 */ 682 inline void SetTransfer(const int i, const Characteristic ch); 683 684 /*! 685 * \brief Get the color reference 686 * \param i element index (0-7) 687 * \return colorimetric specification 688 */ 689 inline Characteristic Colorimetric(const int i) const; 690 691 /*! 692 * \brief Set the color reference 693 * \param i element index (0-7) 694 * \param c colorimetric specification 695 */ 696 inline void SetColorimetric(const int i, const Characteristic c); 697 698 /*! 699 * \brief Get the bit size of each component 700 * \param i element index (0-7) 701 * \return bit size 702 */ 703 inline U8 BitDepth(const int i) const; 704 705 /*! 706 * \brief Set the bit size of each component 707 * \param i element index (0-7) 708 * \param depth bit size 709 */ 710 inline void SetBitDepth(const int i, const U8 depth); 711 712 /*! 713 * \brief Get the data packing mode 714 * \param i element index (0-7) 715 * \return packing method 716 */ 717 inline Packing ImagePacking(const int i) const; 718 719 /*! 720 * \brief Set the data packing mode 721 * \param i element index (0-7) 722 * \param pack packing method 723 */ 724 inline void SetImagePacking(const int i, const Packing pack); 725 726 /*! 727 * \brief Get the encoding method 728 * \param i element index (0-7) 729 * \return encoding method 730 */ 731 inline Encoding ImageEncoding(const int i) const; 732 733 /*! 734 * \brief Set the encoding method 735 * \param i element index (0-7) 736 * \param enc encoding method 737 */ 738 inline void SetImageEncoding(const int i, const Encoding enc); 739 740 /*! 741 * \brief Get the offset to element 742 * \param i element index (0-7) 743 * \return offset in bytes from the start of the file 744 */ 745 inline U32 DataOffset(const int i) const; 746 747 /*! 748 * \brief Set the offset to element 749 * \param i element index (0-7) 750 * \param offset offset in bytes from the start of the file 751 */ 752 inline void SetDataOffset(const int i, const U32 offset); 753 754 /*! 755 * \brief Get the number of bytes padding the end of each line 756 * \param i element index (0-7) 757 * \return count 758 */ 759 inline U32 EndOfLinePadding(const int i) const; 760 761 /*! 762 * \brief Set the number of bytes padding the end of each line 763 * \param i element index (0-7) 764 * \param eolp count 765 */ 766 inline void SetEndOfLinePadding(const int i, const U32 eolp); 767 768 /*! 769 * \brief Get the number of bytes padding the end of the image element 770 * \param i element index (0-7) 771 * \return count 772 */ 773 inline U32 EndOfImagePadding(const int i) const; 774 775 /*! 776 * \brief Set the number of bytes padding the end of the image element 777 * \param i element index (0-7) 778 * \param eoip count 779 */ 780 inline void SetEndOfImagePadding(const int i, const U32 eoip); 781 782 /*! 783 * \brief Get the element description 784 * \param i element index (0-7) 785 * \param desc buffer to write description string (32+1 chars) 786 */ 787 inline void Description(const int i, char *desc) const; 788 789 /*! 790 * \brief Set the element description 791 * \param i element index (0-7) 792 * \param desc buffer 793 */ 794 inline void SetDescription(const int i, const char *desc); 795 796 /* end of group */ 797 //@} 798 799 /*! 800 * \name Image Origination Methods 801 */ 802 //@{ 803 804 /*! 805 * \brief Get the line offset (in pixels) from the first pixel in original image 806 * \return offset count 807 */ 808 inline U32 XOffset() const; 809 810 /*! 811 * \brief Set the line offset (in pixels) from the first pixel in original image 812 * \param offset offset count 813 */ 814 inline void SetXOffset(const U32 offset); 815 816 /*! 817 * \brief Get the frame offset (in lines) from the first line in original image 818 * \return offset count 819 */ 820 inline U32 YOffset() const; 821 822 /*! 823 * \brief Set the frame offset (in lines) from the first line in original image 824 * \param offset offset count 825 */ 826 inline void SetYOffset(const U32 offset); 827 828 /*! 829 * \brief Get the X image center in pixels 830 * \return pixel position 831 */ 832 inline R32 XCenter() const; 833 834 /*! 835 * \brief Set the X image center in pixels 836 * \param center pixel position 837 */ 838 inline void SetXCenter(const R32 center); 839 840 /*! 841 * \brief Get the Y image center in pixels 842 * \return pixel position 843 */ 844 inline R32 YCenter() const; 845 846 /*! 847 * \brief Set the Y image center in pixels 848 * \param center pixel position 849 */ 850 inline void SetYCenter(const R32 center); 851 852 /*! 853 * \brief Get the number of pixels per line in the original image 854 * \return size 855 */ 856 inline U32 XOriginalSize() const; 857 858 /*! 859 * \brief GSt the number of pixels per line in the original image 860 * \param size size 861 */ 862 inline void SetXOriginalSize(const U32 size); 863 864 /*! 865 * \brief Get the number of lines per image in the original image 866 * \return size 867 */ 868 inline U32 YOriginalSize() const; 869 870 /*! 871 * \brief Set the number of lines per image in the original image 872 * \param size size 873 */ 874 inline void SetYOriginalSize(const U32 size); 875 876 /*! 877 * \brief Get the source image file name that this image was extracted 878 * \param fn buffer to write source file name (100+1) 879 */ 880 inline void SourceImageFileName(char *fn) const; 881 882 /*! 883 * \brief Set the source image file name that this image was extracted 884 * \param fn buffer with source file name 885 */ 886 inline void SetSourceImageFileName(const char *fn); 887 888 /*! 889 * \brief Get the source image time and date that this image was extracted 890 * \param td buffer to write time/date string (24+1) 891 */ 892 inline void SourceTimeDate(char *td) const; 893 894 /*! 895 * \brief Set the source image time and date that this image was extracted 896 * \param td buffer with time/date string 897 */ 898 inline void SetSourceTimeDate(const char *td); 899 900 /*! 901 * \brief Set the source image time and date that this image was extracted 902 * \param secs number of seconds since January 1, 1970 00:00 903 */ 904 void SetSourceTimeDate(const long secs); 905 906 /*! 907 * \brief Get the input device name 908 * \param dev buffer to write device (32+1) 909 */ 910 inline void InputDevice(char *dev) const; 911 912 /*! 913 * \brief Set the input device name 914 * \param dev buffer with device name 915 */ 916 inline void SetInputDevice(const char *dev); 917 918 /*! 919 * \brief Get the input device serial number 920 * \param sn buffer to write device serial number (32+1) 921 */ 922 inline void InputDeviceSerialNumber(char *sn) const; 923 924 /*! 925 * \brief Set the input device serial number 926 * \param sn buffer with device serial number 927 */ 928 inline void SetInputDeviceSerialNumber(const char *sn); 929 930 /*! 931 * \brief Get the pixel offset for the border region 932 * 933 * There are 4 border pixel offsets that define a region -- X-left, X-right, Y-top, Y-bottom 934 * 935 * \param i border index (0-3) 936 * \return offset in pixels 937 */ 938 inline U16 Border(const int i) const; 939 940 /*! 941 * \brief Set the pixel offset for the border region 942 * 943 * There are 4 border pixel offsets that define a region -- X-left, X-right, Y-top, Y-bottom 944 * 945 * \param i border index (0-3) 946 * \param bord offset in pixels 947 */ 948 inline void SetBorder(const int i, const U16 bord); 949 950 /*! 951 * \brief Get the pixel aspect ratio (horizontal:vertical) 952 * \param i aspect ratio index (0-1) 953 * \return ratio quantity 954 */ 955 inline U32 AspectRatio(const int i) const; 956 957 /*! 958 * \brief Set the pixel aspect ratio (horizontal:vertical) 959 * \param i aspect ratio index (0-1) 960 * \param ar ratio quantity 961 */ 962 inline void SetAspectRatio(const int i, const U32 ar); 963 964 /*! 965 * \brief Get the horizontal size of the original scanned optical image 966 * \return size in millimeters 967 */ 968 inline R32 XScannedSize() const; 969 970 /*! 971 * \brief Set the horizontal size of the original scanned optical image 972 * \param size size in millimeters 973 */ 974 inline void SetXScannedSize(const R32 size); 975 976 /*! 977 * \brief Get the vertical size of the original scanned optical image 978 * \return size in millimeters 979 */ 980 inline R32 YScannedSize() const; 981 982 /*! 983 * \brief Set the vertical size of the original scanned optical image 984 * \param size size in millimeters 985 */ 986 inline void SetYScannedSize(const R32 size); 987 988 /* end of group */ 989 //@} 990 991 /*! 992 * \brief Number of Active Elements in the Image 993 * \return element count 994 */ 995 int ImageElementCount() const; 996 997 /*! 998 * \brief Set member numberOfElements based on channel structure 999 */ 1000 void CalculateNumberOfElements(); 1001 1002 /*! 1003 * \brief Number of components for the element 1004 * \return number of components 1005 */ 1006 int ImageElementComponentCount(const int element) const; 1007 1008 /*! 1009 * \brief DataSize required for individual image element components 1010 * \return datasize of element 1011 */ 1012 DataSize ComponentDataSize(const int element) const; 1013 1014 /*! 1015 * \brief Byte count of data element components 1016 * \return byte count 1017 */ 1018 int ComponentByteCount(const int element) const; 1019 1020 /* 1021 * \brief Byte size for each DataSize 1022 * \return byte count 1023 */ 1024 static int DataSizeByteCount(const DataSize ds); 1025 1026 }; 1027 1028 1029 /*! 1030 * \struct IndustryHeader 1031 * \brief Motion Picture and Television Industry Specific Information 1032 */ 1033 struct IndustryHeader 1034 { 1035 1036 /*! 1037 * \name Motion Picture Industry Specific Members 1038 */ 1039 //@{ 1040 ASCII filmManufacturingIdCode[2]; //!< Film edge code manufacturing ID code 1041 ASCII filmType[2]; //!< Film edge code type 1042 ASCII perfsOffset[2]; //!< Film edge code offset in perfs 1043 ASCII prefix[6]; //!< Film edge code prefix 1044 ASCII count[4]; //!< Film edge code count 1045 ASCII format[32]; //!< Format string, e.g. Academy 1046 U32 framePosition; //!< Frame position in sequence 1047 U32 sequenceLength; //!< Sequence length 1048 U32 heldCount; //!< Held count (1 = default) 1049 R32 frameRate; //!< Frame rate of original (frame / sec) 1050 R32 shutterAngle; //!< Shutter angle of camera (degrees) 1051 ASCII frameId[32]; //!< Frame identification, e.g. keyframe 1052 ASCII slateInfo[100]; //!< Slate information 1053 ASCII reserved4[56]; //!< Reserved 1054 /* end of group */ 1055 //@} 1056 1057 1058 /*! 1059 * \name Television Industry Specific Members 1060 */ 1061 //@{ 1062 U32 timeCode; //!< Time code 1063 U32 userBits; //!< User bits 1064 U8 interlace; //!< Interlace (0 = noninterlace, 1 = 2:1 interlace) 1065 U8 fieldNumber; //!< Field number 1066 U8 videoSignal; //!< Video signal \see VideoSignal 1067 U8 zero; //!< Structure alignment padding 1068 R32 horizontalSampleRate; //!< Horizontal sample rate (in Hz) 1069 R32 verticalSampleRate; //!< Vertical sample rate (in Hz) 1070 R32 temporalFrameRate; //!< Temporal sample rate (in Hz) 1071 R32 timeOffset; //!< Time offset from sync to first pixel (in ms) 1072 R32 gamma; //!< Gamma 1073 R32 blackLevel; //!< Black level 1074 R32 blackGain; //!< Black gain 1075 R32 breakPoint; //!< Break point 1076 R32 whiteLevel; //!< White level 1077 R32 integrationTimes; //!< Integration time (in sec) 1078 ASCII reserved5[76]; //!< Reserved 1079 /* end of group */ 1080 //@} 1081 1082 /*! 1083 * \brief Constructor 1084 */ 1085 IndustryHeader(); 1086 1087 /*! 1088 * \brief Reset class to initial state 1089 */ 1090 void Reset(); 1091 1092 1093 // set/get functions for the data methods 1094 1095 /*! 1096 * \name Motion Picture Industry Specific Methods 1097 */ 1098 //@{ 1099 1100 /*! 1101 * \brief Get the film edge code information that is machine readable 1102 * \param edge buffer to write film edge code information (16+1 chars) 1103 */ 1104 void FilmEdgeCode(char *edge) const; 1105 1106 /*! 1107 * \brief Set the film edge code information that is machine readable 1108 * \param edge buffer with film edge code information 1109 */ 1110 void SetFileEdgeCode(const char *edge); 1111 1112 /*! 1113 * \brief Get the format (e.g., Academy) 1114 * \param fmt buffer to write format information (32+1 chars) 1115 */ 1116 inline void Format(char *fmt) const; 1117 1118 /*! 1119 * \brief Set the format (e.g., Academy) 1120 * \param fmt buffer with format information 1121 */ 1122 inline void SetFormat(const char *fmt); 1123 1124 /*! 1125 * \brief Get the frame position in sequence 1126 * \return position 1127 */ 1128 inline U32 FramePosition() const; 1129 1130 /*! 1131 * \brief Set the frame position in sequence 1132 * \param pos position 1133 */ 1134 inline void SetFramePosition(const U32 pos); 1135 1136 /*! 1137 * \brief Get the total number of frames in sequence 1138 * \return length 1139 */ 1140 inline U32 SequenceLength() const; 1141 1142 /*! 1143 * \brief Set the total number of frames in sequence 1144 * \param len length 1145 */ 1146 inline void SetSequenceLength(const U32 len); 1147 1148 /*! 1149 * \brief Get the how many sequential frames for which to hold current frame 1150 * \return count 1151 */ 1152 inline U32 HeldCount() const; 1153 1154 /*! 1155 * \brief Set the how many sequential frames for which to hold current frame 1156 * \param count count 1157 */ 1158 inline void SetHeldCount(const U32 count); 1159 1160 /*! 1161 * \brief Get the frame rate (frames / second) 1162 * \return rate 1163 */ 1164 inline R32 FrameRate() const; 1165 1166 /*! 1167 * \brief Set the frame rate (frames / second) 1168 * \param rate rate 1169 */ 1170 inline void SetFrameRate(const R32 rate); 1171 1172 /*! 1173 * \brief Get the shutter angle of the motion picture camera 1174 * \return degrees of the temporal sampling aperture 1175 */ 1176 inline R32 ShutterAngle() const; 1177 1178 /*! 1179 * \brief Set the shutter angle of the motion picture camera 1180 * \param angle degrees of the temporal sampling aperture 1181 */ 1182 inline void SetShutterAngle(const R32 angle); 1183 1184 /*! 1185 * \brief Get the user-defined frame identification 1186 * \param id buffer to write frame identification (32+1 chars) 1187 */ 1188 inline void FrameId(char *id) const; 1189 1190 /*! 1191 * \brief Set the user-defined frame identification 1192 * \param id buffer with frame identification 1193 */ 1194 inline void SetFrameId(const char *id); 1195 1196 /*! 1197 * \brief Get the production information from the camera slate 1198 * \param slate buffer to write slate information (100+1 chars) 1199 */ 1200 inline void SlateInfo(char *slate) const; 1201 1202 /*! 1203 * \brief Set the production information from the camera slate 1204 * \param slate buffer with slate information 1205 */ 1206 inline void SetSlateInfo(const char *slate); 1207 1208 /* end of group */ 1209 //@} 1210 1211 /*! 1212 * \name Television Industry Specific Methods 1213 */ 1214 //@{ 1215 1216 /*! 1217 * \brief Get the time code 1218 * \param str buffer to write time code (12 chars) 1219 */ 1220 void TimeCode(char *str) const; 1221 1222 /*! 1223 * \brief Set the time code 1224 * \param str buffer with time code 1225 */ 1226 void SetTimeCode(const char *str); 1227 1228 /*! 1229 * \brief Get the user bits 1230 * \param str buffer to write user bits (12 chars) 1231 */ 1232 void UserBits(char *str) const; 1233 1234 /*! 1235 * \brief Set the user bits 1236 * \param str buffer with user bits 1237 */ 1238 void SetUserBits(const char *str); 1239 1240 /*! 1241 * \brief Get the interlace (0 = noninterlace, 1 = 2:1 interlace) 1242 * \return interlace value 1243 */ 1244 inline U8 Interlace() const; 1245 1246 /*! 1247 * \brief Set the interlace (0 = noninterlace, 1 = 2:1 interlace) 1248 * \param lace interlace value 1249 */ 1250 inline void SetInterlace(const U8 lace); 1251 1252 /*! 1253 * \brief Get the field number of the video decoded 1254 * \return field number 1255 */ 1256 inline U8 FieldNumber() const; 1257 1258 /*! 1259 * \brief Set the field number of the video decoded 1260 * \param fn field number 1261 */ 1262 inline void SetFieldNumber(const U8 fn); 1263 1264 /*! 1265 * \brief Get the video source 1266 * \return signal 1267 */ 1268 inline VideoSignal Signal() const; 1269 1270 /*! 1271 * \brief Set the video source 1272 * \param vs signal 1273 */ 1274 inline void SetSignal(const VideoSignal vs); 1275 1276 /*! 1277 * \brief Get the clock rate at which samples were acquired 1278 * \return rate 1279 */ 1280 inline R32 HorizontalSampleRate() const; 1281 1282 /*! 1283 * \brief Set the clock rate at which samples were acquired 1284 * \param rate rate 1285 */ 1286 inline void SetHorizontalSampleRate(const R32 rate); 1287 1288 /*! 1289 * \brief Get the rate at which scanning the whole image is repeated 1290 * \return rate 1291 */ 1292 inline R32 VerticalSampleRate() const; 1293 1294 /*! 1295 * \brief Set the rate at which scanning the whole image is repeated 1296 * \param rate rate 1297 */ 1298 inline void SetVerticalSampleRate(const R32 rate); 1299 1300 /*! 1301 * \brief Get the applied gamma correction 1302 * \return rate 1303 */ 1304 inline R32 TemporalFrameRate() const; 1305 1306 /*! 1307 * \brief Set the applied gamma correction 1308 * \param rate gamma 1309 */ 1310 inline void SetTemporalFrameRate(const R32 rate); 1311 1312 /*! 1313 * \brief Get the time offset from sync to first pixel 1314 * \return time in microseconds 1315 */ 1316 inline R32 TimeOffset() const; 1317 1318 /*! 1319 * \brief Set the time offset from sync to first pixel 1320 * \param offset time in microseconds 1321 */ 1322 inline void SetTimeOffset(const R32 offset); 1323 1324 /*! 1325 * \brief Get the applied gamma correction 1326 * \return gamma 1327 */ 1328 inline R32 Gamma() const; 1329 1330 /*! 1331 * \brief Set the applied gamma correction 1332 * \param g gamma 1333 */ 1334 inline void SetGamma(const R32 g); 1335 1336 /*! 1337 * \brief Get the reference black level 1338 * \return value 1339 */ 1340 inline R32 BlackLevel() const; 1341 1342 /*! 1343 * \brief Set the reference black level 1344 * \param bl value 1345 */ 1346 inline void SetBlackLevel(const R32 bl); 1347 1348 /*! 1349 * \brief Get the gain applied to signals below the breakpoint 1350 * \return value 1351 */ 1352 inline R32 BlackGain() const; 1353 1354 /*! 1355 * \brief Set the gain applied to signals below the breakpoint 1356 * \param bg value 1357 */ 1358 inline void SetBlackGain(const R32 bg); 1359 1360 /*! 1361 * \brief Get the breakpoint which gamma is applied 1362 * \return value 1363 */ 1364 inline R32 BreakPoint() const; 1365 1366 /*! 1367 * \brief Set the breakpoint which gamma is applied 1368 * \param bp value 1369 */ 1370 inline void SetBreakPoint(const R32 bp); 1371 1372 /*! 1373 * \brief Get the reference white level 1374 * \return value 1375 */ 1376 inline R32 WhiteLevel() const; 1377 1378 /*! 1379 * \brief Set the reference white level 1380 * \param wl value 1381 */ 1382 inline void SetWhiteLevel(const R32 wl); 1383 1384 /*! 1385 * \brief Get the temporal sampling rate of television cameras 1386 * \return rate 1387 */ 1388 inline R32 IntegrationTimes() const; 1389 1390 /*! 1391 * \brief Set the temporal sampling rate of television cameras 1392 * \param times rate 1393 */ 1394 inline void SetIntegrationTimes(const R32 times); 1395 1396 /* end of group */ 1397 //@} 1398 1399 protected: 1400 U32 TCFromString(const char *str) const; 1401 }; 1402 1403 1404 1405 /*! 1406 * \brief Complete DPX Header 1407 */ 1408 struct Header : public GenericHeader, public IndustryHeader 1409 { 1410 Header(); 1411 1412 /*! 1413 * \brief Set the header data to a known start state 1414 */ 1415 void Reset(); 1416 1417 /*! 1418 * \brief Set the Input Stream object to read header from 1419 */ 1420 bool Read(InStream *); 1421 1422 /*! 1423 * \brief Set the Output Stream object to write header to 1424 */ 1425 bool Write(OutStream *); 1426 1427 // write the offset within the header 1428 bool WriteOffsetData(OutStream *); 1429 1430 /*! 1431 * \brief Validate the header 1432 */ 1433 bool Validate(); 1434 1435 /*! 1436 * \brief Does header require endian byte swap 1437 * \return swap required true/false 1438 */ 1439 inline bool RequiresByteSwap() const; 1440 1441 /*! 1442 * \brief Check magic cookie 1443 * \return valid true/false 1444 */ 1445 static bool ValidMagicCookie(const U32 magic); 1446 1447 /*! 1448 * \brief Returns the size of the header 1449 * \return 2048 as defined by the standard 1450 */ 1451 U32 Size() const; 1452 1453 /*! 1454 * \brief Calculate all of the offset members in the header 1455 */ 1456 void CalculateOffsets(); 1457 1458 /*! 1459 * \brief Determine whether the components of an element should be swapped \see ComponentOrdering 1460 * \param element image element 1461 * \return swap order of components 1462 */ 1463 bool DatumSwap(const int element) const; 1464 1465 /*! 1466 * \brief Set whether reader/writer should swap component ordering 1467 * \param swap allow swapping true/false 1468 */ 1469 void SetDatumSwap(const bool swap); 1470 1471 // system check, used only during platform port 1472 bool Check(); 1473 1474 /*! 1475 * \brief Height of the element adjusted for orientation 1476 * \return height 1477 */ 1478 U32 Height() const; 1479 1480 /*! 1481 * \brief Width of the element adjusted for orientation 1482 * \return width 1483 */ 1484 U32 Width() const; 1485 1486 1487 protected: 1488 bool DetermineByteSwap(const U32 magic) const; 1489 bool datumSwap; 1490 }; 1491 1492 1493 1494 1495 1496 /*! 1497 * \brief User Defined data 1498 */ 1499 struct UserDefinedData 1500 { 1501 ASCII userId[32]; //!< user data identification string 1502 U8 * data; //!< user data 1503 }; 1504 1505 1506 RequiresByteSwap()1507 inline bool Header::RequiresByteSwap() const 1508 { 1509 return this->DetermineByteSwap(this->magicNumber); 1510 } 1511 Size()1512 inline U32 Header::Size() const 1513 { 1514 return 2048; 1515 } 1516 1517 1518 MagicNumber()1519 inline U32 GenericHeader::MagicNumber() const 1520 { 1521 return this->magicNumber; 1522 } 1523 ImageOffset()1524 inline U32 GenericHeader::ImageOffset() const 1525 { 1526 return this->imageOffset; 1527 } 1528 SetImageOffset(const U32 offset)1529 inline void GenericHeader::SetImageOffset(const U32 offset) 1530 { 1531 this->imageOffset = offset; 1532 } 1533 Version(char * v)1534 inline void GenericHeader::Version(char *v) const 1535 { 1536 OIIO::Strutil::safe_strcpy(v, this->version, sizeof(this->version)); 1537 v[8] = '\0'; 1538 } 1539 SetVersion(const char * v)1540 inline void GenericHeader::SetVersion(const char * v) 1541 { 1542 OIIO::Strutil::safe_strcpy(this->version, v, sizeof(this->version)); 1543 } 1544 FileSize()1545 inline U32 GenericHeader::FileSize() const 1546 { 1547 return this->fileSize; 1548 } 1549 SetFileSize(const U32 fs)1550 inline void GenericHeader::SetFileSize(const U32 fs) 1551 { 1552 this->fileSize = fs; 1553 } 1554 DittoKey()1555 inline U32 GenericHeader::DittoKey() const 1556 { 1557 return this->dittoKey; 1558 } 1559 SetDittoKey(const U32 key)1560 inline void GenericHeader::SetDittoKey(const U32 key) 1561 { 1562 this->dittoKey = key; 1563 } 1564 GenericSize()1565 inline U32 GenericHeader::GenericSize() const 1566 { 1567 return this->genericSize; 1568 } 1569 IndustrySize()1570 inline U32 GenericHeader::IndustrySize() const 1571 { 1572 return this->industrySize; 1573 } 1574 UserSize()1575 inline U32 GenericHeader::UserSize() const 1576 { 1577 return this->userSize; 1578 } 1579 SetUserSize(const U32 size)1580 inline void GenericHeader::SetUserSize(const U32 size) 1581 { 1582 this->userSize = size; 1583 } 1584 FileName(char * fn)1585 inline void GenericHeader::FileName(char *fn) const 1586 { 1587 OIIO::Strutil::safe_strcpy(fn, this->fileName, sizeof(this->fileName)); 1588 } 1589 SetFileName(const char * fn)1590 inline void GenericHeader::SetFileName(const char *fn) 1591 { 1592 OIIO::Strutil::safe_strcpy(this->fileName, fn, sizeof(this->fileName)); 1593 } 1594 CreationTimeDate(char * ct)1595 inline void GenericHeader::CreationTimeDate(char *ct) const 1596 { 1597 OIIO::Strutil::safe_strcpy(ct, this->creationTimeDate, sizeof(this->creationTimeDate)); 1598 } 1599 SetCreationTimeDate(const char * ct)1600 inline void GenericHeader::SetCreationTimeDate(const char *ct) 1601 { 1602 OIIO::Strutil::safe_strcpy(this->creationTimeDate, ct, sizeof(this->creationTimeDate)); 1603 } 1604 Creator(char * creat)1605 inline void GenericHeader::Creator(char *creat) const 1606 { 1607 OIIO::Strutil::safe_strcpy(creat, this->creator, sizeof(this->creator)); 1608 } 1609 SetCreator(const char * creat)1610 inline void GenericHeader::SetCreator(const char *creat) 1611 { 1612 OIIO::Strutil::safe_strcpy(this->creator, creat, sizeof(this->creator)); 1613 } 1614 Project(char * prj)1615 inline void GenericHeader::Project(char *prj) const 1616 { 1617 OIIO::Strutil::safe_strcpy(prj, this->project, sizeof(this->project)); 1618 } 1619 SetProject(const char * prj)1620 inline void GenericHeader::SetProject(const char *prj) 1621 { 1622 OIIO::Strutil::safe_strcpy(this->project, prj, sizeof(this->project)); 1623 } 1624 Copyright(char * copy)1625 inline void GenericHeader::Copyright(char *copy) const 1626 { 1627 OIIO::Strutil::safe_strcpy(copy, this->copyright, sizeof(this->copyright)); 1628 } 1629 SetCopyright(const char * copy)1630 inline void GenericHeader::SetCopyright(const char *copy) 1631 { 1632 OIIO::Strutil::safe_strcpy(this->copyright, copy, sizeof(this->copyright)); 1633 } 1634 EncryptKey()1635 inline U32 GenericHeader::EncryptKey() const 1636 { 1637 return this->encryptKey; 1638 } 1639 SetEncryptKey(const U32 key)1640 inline void GenericHeader::SetEncryptKey(const U32 key) 1641 { 1642 this->encryptKey = key; 1643 } 1644 1645 ImageOrientation()1646 inline Orientation GenericHeader::ImageOrientation() const 1647 { 1648 return Orientation(this->imageOrientation); 1649 } 1650 SetImageOrientation(const Orientation orient)1651 inline void GenericHeader::SetImageOrientation(const Orientation orient) 1652 { 1653 this->imageOrientation = orient; 1654 } 1655 NumberOfElements()1656 inline U16 GenericHeader::NumberOfElements() const 1657 { 1658 return this->numberOfElements; 1659 } 1660 SetNumberOfElements(const U16 num)1661 inline void GenericHeader::SetNumberOfElements(const U16 num) 1662 { 1663 this->numberOfElements = num; 1664 } 1665 PixelsPerLine()1666 inline U32 GenericHeader::PixelsPerLine() const 1667 { 1668 return this->pixelsPerLine; 1669 } 1670 SetPixelsPerLine(const U32 ppl)1671 inline void GenericHeader::SetPixelsPerLine(const U32 ppl) 1672 { 1673 this->pixelsPerLine = ppl; 1674 } 1675 LinesPerElement()1676 inline U32 GenericHeader::LinesPerElement() const 1677 { 1678 return this->linesPerElement; 1679 } 1680 SetLinesPerElement(const U32 lpe)1681 inline void GenericHeader::SetLinesPerElement(const U32 lpe) 1682 { 1683 this->linesPerElement = lpe; 1684 } 1685 DataSign(const int i)1686 inline U32 GenericHeader::DataSign(const int i) const 1687 { 1688 if (i < 0 || i >= MAX_ELEMENTS) 1689 return 0xffffffff; 1690 return this->chan[i].dataSign; 1691 } 1692 SetDataSign(const int i,const U32 sign)1693 inline void GenericHeader::SetDataSign(const int i, const U32 sign) 1694 { 1695 if (i < 0 || i >= MAX_ELEMENTS) 1696 return; 1697 this->chan[i].dataSign = sign; 1698 } 1699 LowData(const int i)1700 inline U32 GenericHeader::LowData(const int i) const 1701 { 1702 if (i < 0 || i >= MAX_ELEMENTS) 1703 return 0xffffffff; 1704 return this->chan[i].lowData; 1705 } 1706 SetLowData(const int i,const U32 data)1707 inline void GenericHeader::SetLowData(const int i, const U32 data) 1708 { 1709 if (i < 0 || i >= MAX_ELEMENTS) 1710 return; 1711 this->chan[i].lowData = data; 1712 } 1713 LowQuantity(const int i)1714 inline R32 GenericHeader::LowQuantity(const int i) const 1715 { 1716 if (i < 0 || i >= MAX_ELEMENTS) 1717 return R32(0xffffffff); 1718 return this->chan[i].lowQuantity; 1719 } 1720 SetLowQuantity(const int i,const R32 quant)1721 inline void GenericHeader::SetLowQuantity(const int i, const R32 quant) 1722 { 1723 if (i < 0 || i >= MAX_ELEMENTS) 1724 return; 1725 this->chan[i].lowQuantity = quant; 1726 } 1727 HighData(const int i)1728 inline U32 GenericHeader::HighData(const int i) const 1729 { 1730 if (i < 0 || i >= MAX_ELEMENTS) 1731 return 0xffffffff; 1732 return this->chan[i].highData; 1733 } 1734 SetHighData(const int i,const U32 data)1735 inline void GenericHeader::SetHighData(const int i, const U32 data) 1736 { 1737 if (i < 0 || i >= MAX_ELEMENTS) 1738 return; 1739 this->chan[i].highData = data; 1740 } 1741 HighQuantity(const int i)1742 inline R32 GenericHeader::HighQuantity(const int i) const 1743 { 1744 if (i < 0 || i >= MAX_ELEMENTS) 1745 return R32(0xffffffff); 1746 return this->chan[i].highQuantity; 1747 } 1748 SetHighQuantity(const int i,const R32 quant)1749 inline void GenericHeader::SetHighQuantity(const int i, const R32 quant) 1750 { 1751 if (i < 0 || i >= MAX_ELEMENTS) 1752 return; 1753 this->chan[i].highQuantity = quant; 1754 } 1755 ImageDescriptor(const int i)1756 inline Descriptor GenericHeader::ImageDescriptor(const int i) const 1757 { 1758 if (i < 0 || i >= MAX_ELEMENTS) 1759 return Descriptor(0xff); 1760 return Descriptor(this->chan[i].descriptor); 1761 } 1762 SetImageDescriptor(const int i,const Descriptor desc)1763 inline void GenericHeader::SetImageDescriptor(const int i, const Descriptor desc) 1764 { 1765 if (i < 0 || i >= MAX_ELEMENTS) 1766 return; 1767 this->chan[i].descriptor = desc; 1768 } 1769 Transfer(const int i)1770 inline Characteristic GenericHeader::Transfer(const int i) const 1771 { 1772 if (i < 0 || i >= MAX_ELEMENTS) 1773 return Characteristic(0xff); 1774 return Characteristic(this->chan[i].transfer); 1775 } 1776 SetTransfer(const int i,const Characteristic ch)1777 inline void GenericHeader::SetTransfer(const int i, const Characteristic ch) 1778 { 1779 if (i < 0 || i >= MAX_ELEMENTS) 1780 return; 1781 this->chan[i].transfer = ch; 1782 } 1783 Colorimetric(const int i)1784 inline Characteristic GenericHeader::Colorimetric(const int i) const 1785 { 1786 if (i < 0 || i >= MAX_ELEMENTS) 1787 return Characteristic(0xff); 1788 return Characteristic(this->chan[i].colorimetric); 1789 } 1790 SetColorimetric(const int i,const Characteristic c)1791 inline void GenericHeader::SetColorimetric(const int i, const Characteristic c) 1792 { 1793 if (i < 0 || i >= MAX_ELEMENTS) 1794 return; 1795 this->chan[i].colorimetric = c; 1796 } 1797 BitDepth(const int i)1798 inline U8 GenericHeader::BitDepth(const int i) const 1799 { 1800 if (i < 0 || i >= MAX_ELEMENTS) 1801 return 0xff; 1802 return this->chan[i].bitDepth; 1803 } 1804 SetBitDepth(const int i,const U8 depth)1805 inline void GenericHeader::SetBitDepth(const int i, const U8 depth) 1806 { 1807 if (i < 0 || i >= MAX_ELEMENTS) 1808 return; 1809 this->chan[i].bitDepth = depth; 1810 } 1811 ImagePacking(const int i)1812 inline Packing GenericHeader::ImagePacking(const int i) const 1813 { 1814 if (i < 0 || i >= MAX_ELEMENTS) 1815 return Packing(0xff); 1816 return Packing(this->chan[i].packing); 1817 } 1818 SetImagePacking(const int i,const Packing pack)1819 inline void GenericHeader::SetImagePacking(const int i, const Packing pack) 1820 { 1821 if (i < 0 || i >= MAX_ELEMENTS) 1822 return; 1823 this->chan[i].packing = pack; 1824 } 1825 ImageEncoding(const int i)1826 inline Encoding GenericHeader::ImageEncoding(const int i) const 1827 { 1828 Encoding e = kNone; 1829 1830 if (i < 0 || i >= MAX_ELEMENTS) 1831 return kNone; 1832 1833 if (this->chan[i].encoding == 1) 1834 e = kRLE; 1835 1836 return e; 1837 } 1838 SetImageEncoding(const int i,const Encoding enc)1839 inline void GenericHeader::SetImageEncoding(const int i, const Encoding enc) 1840 { 1841 if (i < 0 || i >= MAX_ELEMENTS) 1842 return; 1843 1844 this->chan[i].encoding = (enc == kNone ? 0 : 1); 1845 } 1846 DataOffset(const int i)1847 inline U32 GenericHeader::DataOffset(const int i) const 1848 { 1849 if (i < 0 || i >= MAX_ELEMENTS) 1850 return 0xffffffff; 1851 return this->chan[i].dataOffset; 1852 } 1853 SetDataOffset(const int i,const U32 offset)1854 inline void GenericHeader::SetDataOffset(const int i, const U32 offset) 1855 { 1856 if (i < 0 || i >= MAX_ELEMENTS) 1857 return; 1858 this->chan[i].dataOffset = offset; 1859 } 1860 EndOfLinePadding(const int i)1861 inline U32 GenericHeader::EndOfLinePadding(const int i) const 1862 { 1863 if (i < 0 || i >= MAX_ELEMENTS) 1864 return 0xffffffff; 1865 if (this->chan[i].endOfLinePadding == 0xffffffff) 1866 return 0; 1867 return this->chan[i].endOfLinePadding; 1868 } 1869 SetEndOfLinePadding(const int i,const U32 eolp)1870 inline void GenericHeader::SetEndOfLinePadding(const int i, const U32 eolp) 1871 { 1872 if (i < 0 || i >= MAX_ELEMENTS) 1873 return; 1874 this->chan[i].endOfLinePadding = eolp; 1875 } 1876 EndOfImagePadding(const int i)1877 inline U32 GenericHeader::EndOfImagePadding(const int i) const 1878 { 1879 if (i < 0 || i >= MAX_ELEMENTS) 1880 return 0xffffffff; 1881 if (this->chan[i].endOfImagePadding == 0xffffffff) 1882 return 0; 1883 return this->chan[i].endOfImagePadding; 1884 } 1885 SetEndOfImagePadding(const int i,const U32 eoip)1886 inline void GenericHeader::SetEndOfImagePadding(const int i, const U32 eoip) 1887 { 1888 if (i < 0 || i >= MAX_ELEMENTS) 1889 return; 1890 this->chan[i].endOfImagePadding = eoip; 1891 } 1892 Description(const int i,char * desc)1893 inline void GenericHeader::Description(const int i, char *desc) const 1894 { 1895 if (i < 0 || i >= MAX_ELEMENTS) 1896 return; 1897 OIIO::Strutil::safe_strcpy(desc, this->chan[i].description, 32); 1898 } 1899 SetDescription(const int i,const char * desc)1900 inline void GenericHeader::SetDescription(const int i, const char *desc) 1901 { 1902 if (i < 0 || i >= MAX_ELEMENTS) 1903 return; 1904 OIIO::Strutil::safe_strcpy(this->chan[i].description, desc, 32); 1905 } 1906 1907 XOffset()1908 inline U32 GenericHeader::XOffset() const 1909 { 1910 return this->xOffset; 1911 } 1912 SetXOffset(const U32 offset)1913 inline void GenericHeader::SetXOffset(const U32 offset) 1914 { 1915 this->xOffset = offset; 1916 } 1917 YOffset()1918 inline U32 GenericHeader::YOffset() const 1919 { 1920 return this->yOffset; 1921 } 1922 SetYOffset(const U32 offset)1923 inline void GenericHeader::SetYOffset(const U32 offset) 1924 { 1925 this->yOffset = offset; 1926 } 1927 XCenter()1928 inline R32 GenericHeader::XCenter() const 1929 { 1930 return this->xCenter; 1931 } 1932 SetXCenter(const R32 center)1933 inline void GenericHeader::SetXCenter(const R32 center) 1934 { 1935 this->xCenter = center; 1936 } 1937 YCenter()1938 inline R32 GenericHeader::YCenter() const 1939 { 1940 return this->yCenter; 1941 } 1942 SetYCenter(const R32 center)1943 inline void GenericHeader::SetYCenter(const R32 center) 1944 { 1945 this->yCenter = center; 1946 } 1947 XOriginalSize()1948 inline U32 GenericHeader::XOriginalSize() const 1949 { 1950 return this->xOriginalSize; 1951 } 1952 SetXOriginalSize(const U32 size)1953 inline void GenericHeader::SetXOriginalSize(const U32 size) 1954 { 1955 this->xOriginalSize = size; 1956 } 1957 YOriginalSize()1958 inline U32 GenericHeader::YOriginalSize() const 1959 { 1960 return this->yOriginalSize; 1961 } 1962 SetYOriginalSize(const U32 size)1963 inline void GenericHeader::SetYOriginalSize(const U32 size) 1964 { 1965 this->yOriginalSize = size; 1966 } 1967 SourceImageFileName(char * fn)1968 inline void GenericHeader::SourceImageFileName(char *fn) const 1969 { 1970 OIIO::Strutil::safe_strcpy(fn, this->sourceImageFileName, sizeof(this->sourceImageFileName)); 1971 } 1972 SetSourceImageFileName(const char * fn)1973 inline void GenericHeader::SetSourceImageFileName(const char *fn) 1974 { 1975 OIIO::Strutil::safe_strcpy(this->sourceImageFileName, fn, sizeof(this->sourceImageFileName)); 1976 } 1977 SourceTimeDate(char * td)1978 inline void GenericHeader::SourceTimeDate(char *td) const 1979 { 1980 OIIO::Strutil::safe_strcpy(td, this->sourceTimeDate, sizeof(this->sourceTimeDate)); 1981 } 1982 SetSourceTimeDate(const char * td)1983 inline void GenericHeader::SetSourceTimeDate(const char *td) 1984 { 1985 OIIO::Strutil::safe_strcpy(this->sourceTimeDate, td, sizeof(this->sourceTimeDate)); 1986 } 1987 InputDevice(char * dev)1988 inline void GenericHeader::InputDevice(char *dev) const 1989 { 1990 OIIO::Strutil::safe_strcpy(dev, this->inputDevice, sizeof(this->inputDevice)); 1991 } 1992 SetInputDevice(const char * dev)1993 inline void GenericHeader::SetInputDevice(const char *dev) 1994 { 1995 OIIO::Strutil::safe_strcpy(this->inputDevice, dev, sizeof(this->inputDevice)); 1996 } 1997 InputDeviceSerialNumber(char * sn)1998 inline void GenericHeader::InputDeviceSerialNumber(char *sn) const 1999 { 2000 OIIO::Strutil::safe_strcpy(sn, this->inputDeviceSerialNumber, sizeof(this->inputDeviceSerialNumber)); 2001 } 2002 SetInputDeviceSerialNumber(const char * sn)2003 inline void GenericHeader::SetInputDeviceSerialNumber(const char *sn) 2004 { 2005 OIIO::Strutil::safe_strcpy(this->inputDeviceSerialNumber, sn, sizeof(this->inputDeviceSerialNumber)); 2006 } 2007 Border(const int i)2008 inline U16 GenericHeader::Border(const int i) const 2009 { 2010 if (i < 0 || i > 3) 2011 return 0xffff; 2012 2013 return this->border[i]; 2014 } 2015 SetBorder(const int i,const U16 bord)2016 inline void GenericHeader::SetBorder(const int i, const U16 bord) 2017 { 2018 if (i < 0 || i > 3) 2019 return; 2020 this->border[i] = bord; 2021 } 2022 AspectRatio(const int i)2023 inline U32 GenericHeader::AspectRatio(const int i) const 2024 { 2025 if (i != 0 && i != 1) 2026 return 0xffffffff; 2027 2028 return this->aspectRatio[i]; 2029 } 2030 SetAspectRatio(const int i,const U32 ar)2031 inline void GenericHeader::SetAspectRatio(const int i, const U32 ar) 2032 { 2033 if (i != 0 && i != 1) 2034 return; 2035 this->aspectRatio[i] = ar; 2036 } 2037 XScannedSize()2038 inline R32 GenericHeader::XScannedSize() const 2039 { 2040 return this->xScannedSize; 2041 } 2042 SetXScannedSize(const R32 size)2043 inline void GenericHeader::SetXScannedSize(const R32 size) 2044 { 2045 this->xScannedSize = size; 2046 } 2047 YScannedSize()2048 inline R32 GenericHeader::YScannedSize() const 2049 { 2050 return this->yScannedSize; 2051 } 2052 SetYScannedSize(const R32 size)2053 inline void GenericHeader::SetYScannedSize(const R32 size) 2054 { 2055 this->yScannedSize = size; 2056 } 2057 2058 Format(char * fmt)2059 inline void IndustryHeader::Format(char *fmt) const 2060 { 2061 OIIO::Strutil::safe_strcpy(fmt, this->format, sizeof(this->format)); 2062 } 2063 SetFormat(const char * fmt)2064 inline void IndustryHeader::SetFormat(const char *fmt) 2065 { 2066 OIIO::Strutil::safe_strcpy(this->format, fmt, sizeof(this->format)); 2067 } 2068 FramePosition()2069 inline U32 IndustryHeader::FramePosition() const 2070 { 2071 return this->framePosition; 2072 } 2073 SetFramePosition(const U32 pos)2074 inline void IndustryHeader::SetFramePosition(const U32 pos) 2075 { 2076 this->framePosition = pos; 2077 } 2078 SequenceLength()2079 inline U32 IndustryHeader::SequenceLength() const 2080 { 2081 return this->sequenceLength; 2082 } 2083 SetSequenceLength(const U32 len)2084 inline void IndustryHeader::SetSequenceLength(const U32 len) 2085 { 2086 this->sequenceLength = len; 2087 } 2088 HeldCount()2089 inline U32 IndustryHeader::HeldCount() const 2090 { 2091 return this->heldCount; 2092 } 2093 SetHeldCount(const U32 count)2094 inline void IndustryHeader::SetHeldCount(const U32 count) 2095 { 2096 this->heldCount = count; 2097 } 2098 FrameRate()2099 inline R32 IndustryHeader::FrameRate() const 2100 { 2101 return this->frameRate; 2102 } 2103 SetFrameRate(const R32 rate)2104 inline void IndustryHeader::SetFrameRate(const R32 rate) 2105 { 2106 this->frameRate = rate; 2107 } 2108 ShutterAngle()2109 inline R32 IndustryHeader::ShutterAngle() const 2110 { 2111 return this->shutterAngle; 2112 } 2113 SetShutterAngle(const R32 angle)2114 inline void IndustryHeader::SetShutterAngle(const R32 angle) 2115 { 2116 this->shutterAngle = angle; 2117 } 2118 FrameId(char * id)2119 inline void IndustryHeader::FrameId(char *id) const 2120 { 2121 OIIO::Strutil::safe_strcpy(id, this->frameId, sizeof(this->frameId)); 2122 } 2123 SetFrameId(const char * id)2124 inline void IndustryHeader::SetFrameId(const char *id) 2125 { 2126 OIIO::Strutil::safe_strcpy(this->frameId, id, sizeof(this->frameId)); 2127 } 2128 SlateInfo(char * slate)2129 inline void IndustryHeader::SlateInfo(char *slate) const 2130 { 2131 OIIO::Strutil::safe_strcpy(slate, this->slateInfo, sizeof(this->slateInfo)); 2132 } 2133 SetSlateInfo(const char * slate)2134 inline void IndustryHeader::SetSlateInfo(const char *slate) 2135 { 2136 OIIO::Strutil::safe_strcpy(this->slateInfo, slate, sizeof(this->slateInfo)); 2137 } 2138 2139 Interlace()2140 inline U8 IndustryHeader::Interlace() const 2141 { 2142 return this->interlace; 2143 } 2144 SetInterlace(const U8 lace)2145 inline void IndustryHeader::SetInterlace(const U8 lace) 2146 { 2147 this->interlace = lace; 2148 } 2149 FieldNumber()2150 inline U8 IndustryHeader::FieldNumber() const 2151 { 2152 return this->fieldNumber; 2153 } 2154 SetFieldNumber(const U8 fn)2155 inline void IndustryHeader::SetFieldNumber(const U8 fn) 2156 { 2157 this->fieldNumber = fn; 2158 } 2159 Signal()2160 inline VideoSignal IndustryHeader::Signal() const 2161 { 2162 return VideoSignal(this->videoSignal); 2163 } 2164 SetSignal(const VideoSignal vs)2165 inline void IndustryHeader::SetSignal(const VideoSignal vs) 2166 { 2167 this->videoSignal = vs; 2168 } 2169 HorizontalSampleRate()2170 inline R32 IndustryHeader::HorizontalSampleRate() const 2171 { 2172 return this->horizontalSampleRate; 2173 } 2174 SetHorizontalSampleRate(const R32 rate)2175 inline void IndustryHeader::SetHorizontalSampleRate(const R32 rate) 2176 { 2177 this->horizontalSampleRate = rate; 2178 } 2179 VerticalSampleRate()2180 inline R32 IndustryHeader::VerticalSampleRate() const 2181 { 2182 return this->verticalSampleRate; 2183 } 2184 SetVerticalSampleRate(const R32 rate)2185 inline void IndustryHeader::SetVerticalSampleRate(const R32 rate) 2186 { 2187 this->verticalSampleRate = rate; 2188 } 2189 TemporalFrameRate()2190 inline R32 IndustryHeader::TemporalFrameRate() const 2191 { 2192 return this->temporalFrameRate; 2193 } 2194 SetTemporalFrameRate(const R32 rate)2195 inline void IndustryHeader::SetTemporalFrameRate(const R32 rate) 2196 { 2197 this->temporalFrameRate = rate; 2198 } 2199 TimeOffset()2200 inline R32 IndustryHeader::TimeOffset() const 2201 { 2202 return this->timeOffset; 2203 } 2204 SetTimeOffset(const R32 offset)2205 inline void IndustryHeader::SetTimeOffset(const R32 offset) 2206 { 2207 this->timeOffset = offset; 2208 } 2209 Gamma()2210 inline R32 IndustryHeader::Gamma() const 2211 { 2212 return this->gamma; 2213 } 2214 SetGamma(const R32 g)2215 inline void IndustryHeader::SetGamma(const R32 g) 2216 { 2217 this->gamma = g; 2218 } 2219 BlackLevel()2220 inline R32 IndustryHeader::BlackLevel() const 2221 { 2222 return this->blackLevel; 2223 } 2224 SetBlackLevel(const R32 bl)2225 inline void IndustryHeader::SetBlackLevel(const R32 bl) 2226 { 2227 this->blackLevel = bl; 2228 } 2229 BlackGain()2230 inline R32 IndustryHeader::BlackGain() const 2231 { 2232 return this->blackGain; 2233 } 2234 SetBlackGain(const R32 bg)2235 inline void IndustryHeader::SetBlackGain(const R32 bg) 2236 { 2237 this->blackGain = bg; 2238 } 2239 BreakPoint()2240 inline R32 IndustryHeader::BreakPoint() const 2241 { 2242 return this->breakPoint; 2243 } 2244 SetBreakPoint(const R32 bp)2245 inline void IndustryHeader::SetBreakPoint(const R32 bp) 2246 { 2247 this->breakPoint = bp; 2248 } 2249 WhiteLevel()2250 inline R32 IndustryHeader::WhiteLevel() const 2251 { 2252 return this->whiteLevel; 2253 } 2254 SetWhiteLevel(const R32 wl)2255 inline void IndustryHeader::SetWhiteLevel(const R32 wl) 2256 { 2257 this->whiteLevel = wl; 2258 } 2259 IntegrationTimes()2260 inline R32 IndustryHeader::IntegrationTimes() const 2261 { 2262 return this->integrationTimes; 2263 } 2264 SetIntegrationTimes(const R32 times)2265 inline void IndustryHeader::SetIntegrationTimes(const R32 times) 2266 { 2267 this->integrationTimes = times; 2268 } 2269 2270 } 2271 2272 #endif 2273