diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-10-22 16:49:00 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-10-22 16:49:00 +0400 |
commit | 4e11fe6c5aec1d609e3ecc2218138b838d253ebf (patch) | |
tree | d57b4f18280c04e50ecb562135fed058cf11b82d /source/blender/imbuf/intern/cineon/dpxlib.h | |
parent | 655e24979bb37c97a34b328238233591cfd5c924 (diff) |
Patch #27397: Improved DPX/Cineon code
Patch by Julien Enche, thanks!
From the patch comment:
It allows Blender to load:
- 1, 8, 10, 12 and 16 bits files. For 10 and 12 bits files, packed or
filled type A/B are supported.
- RGB, Log, Luma and YCbCr colorspaces.
- Big and little endian storage.
- Multi-elements (planar) storage.
It allows Blender to save :
- 8, 10, 12 and 16 bits file. For 10 and 12 bits files, the most used
type A padding is used.
- RGB and Log colorspaces (Cineon can only be saved in Log colorspace).
For Log colorspace, the common default values are used for gamma,
reference black and reference white (respectively 1.7, 95 and 685 for
10 bits files).
- Saved DPX/Cineon files now match the viewer.
Some files won't load (mostly because I haven't seen any of them):
- Compressed files
- 32 and 64 bits files
- Image orientation information are not taken in account. Here too,
I haven't seen any file that was not top-bottom/left-right oriented.
Diffstat (limited to 'source/blender/imbuf/intern/cineon/dpxlib.h')
-rw-r--r-- | source/blender/imbuf/intern/cineon/dpxlib.h | 162 |
1 files changed, 131 insertions, 31 deletions
diff --git a/source/blender/imbuf/intern/cineon/dpxlib.h b/source/blender/imbuf/intern/cineon/dpxlib.h index eb3937f2bf7..bd608b13057 100644 --- a/source/blender/imbuf/intern/cineon/dpxlib.h +++ b/source/blender/imbuf/intern/cineon/dpxlib.h @@ -1,60 +1,160 @@ /* - * DPX image file format library definitions. + * DPX image file format library definitions. * - * Copyright 1999 - 2002 David Hodson <hodsond@acm.org> + * Copyright 1999 - 2002 David Hodson <hodsond@acm.org> * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Julien Enche. * */ -#ifndef __DPXLIB_H__ -#define __DPXLIB_H__ - /** \file blender/imbuf/intern/cineon/dpxlib.h * \ingroup imbcineon */ + +#ifndef __DPX_LIB_H__ +#define __DPX_LIB_H__ + #ifdef __cplusplus extern "C" { #endif #include "logImageCore.h" -typedef struct _Log_Image_File_t_ DpxFile; +#define DPX_FILE_MAGIC 0x53445058 +#define DPX_UNDEFINED_U8 0xFF +#define DPX_UNDEFINED_U16 0xFFFF +#define DPX_UNDEFINED_U32 0xFFFFFFFF +#define DPX_UNDEFINED_R32 0xFFFFFFFF +#define DPX_UNDEFINED_CHAR 0 -/* int functions return 0 for OK */ +typedef struct { + unsigned int magic_num; + unsigned int offset; + char version[8]; + unsigned int file_size; + unsigned int ditto_key; + unsigned int gen_hdr_size; + unsigned int ind_hdr_size; + unsigned int user_data_size; + char file_name[100]; + char creation_date[24]; + char creator[100]; + char project[200]; + char copyright[200]; + unsigned int key; + char reserved[104]; +} DpxFileHeader; -void dpxSetVerbose(int); +typedef struct { + unsigned int data_sign; + unsigned int ref_low_data; + float ref_low_quantity; + unsigned int ref_high_data; + float ref_high_quantity; + unsigned char descriptor; + unsigned char transfer; + unsigned char colorimetric; + unsigned char bits_per_sample; + unsigned short packing; + unsigned short encoding; + unsigned int data_offset; + unsigned int line_padding; + unsigned int element_padding; + char description[32]; +} DpxElementHeader; -DpxFile* dpxOpen(const char* filename); -DpxFile* dpxCreate(const char* filename, int xsize, int ysize, int channels); -DpxFile* dpxOpenFromMem(unsigned char *buffer, unsigned int size); -int dpxIsMemFileCineon(void *buffer); +typedef struct { + unsigned short orientation; + unsigned short elements_per_image; + unsigned int pixels_per_line; + unsigned int lines_per_element; + DpxElementHeader element[8]; + char reserved[52]; +} DpxImageHeader; -/* get/set scanline of converted bytes */ -int dpxGetRowBytes(DpxFile* dpx, unsigned short* row, int y); -int dpxSetRowBytes(DpxFile* dpx, const unsigned short* row, int y); +typedef struct { + unsigned int x_offset; + unsigned int y_offset; + float x_center; + float y_center; + unsigned int x_original_size; + unsigned int y_original_size; + char file_name[100]; + char creation_time[24]; + char input_device[32]; + char input_serial_number[32]; + unsigned short border_validity[4]; + unsigned int pixel_aspect_ratio[2]; + char reserved[28]; +} DpxOrientationHeader; -/* closes file and deletes data */ -void dpxClose(DpxFile* dpx); +typedef struct { + char film_manufacturer_id[2]; + char film_type[2]; + char edge_code_perforation_offset[2]; + char edge_code_prefix[6]; + char edge_code_count[4]; + char film_format[32]; + unsigned int frame_position; + unsigned int sequence_length; + unsigned int held_count; + float frame_rate; + float shutter_angle; + char frame_identification[32]; + char slate_info[100]; + char reserved[56]; +} DpxFilmHeader; -/* dumps file to stdout */ -void dpxDump(const char* filename); +typedef struct { + unsigned int time_code; + unsigned int user_bits; + unsigned char interlace; + unsigned char field_number; + unsigned char video_signal; + unsigned char padding; + float horizontal_sample_rate; + float vertical_sample_rate; + float frame_rate; + float time_offset; + float gamma; + float black_level; + float black_gain; + float breakpoint; + float white_level; + float integration_times; + unsigned char reserved[76]; +} DpxTelevisionHeader; + + +typedef struct { + DpxFileHeader fileHeader; + DpxImageHeader imageHeader; + DpxOrientationHeader orientationHeader; + DpxFilmHeader filmHeader; + DpxTelevisionHeader televisionHeader; +} DpxMainHeader; + +void dpxSetVerbose(int verbosity); +LogImageFile* dpxOpen(const unsigned char* byteStuff, int fromMemory, size_t bufferSize); +LogImageFile* dpxCreate(const char* filename, int width, int height, int bitsPerSample, int hasAlpha, int isLogarithmic, int referenceWhite, int referenceBlack, float gamma, const char* creator); #ifdef __cplusplus } #endif -#endif /* __DPXLIB_H__ */ +#endif |