2
* Cineon and DPX image file format library routines.
4
* Copyright 1999 - 2002 David Hodson <hodsond@acm.org>
6
* This program is free software; you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License as published by the Free
8
* Software Foundation; either version 2 of the License, or (at your option)
11
* This program is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
#include "cineonlib.h"
28
#include <time.h> /* strftime() */
29
#include <sys/types.h>
33
#include <netinet/in.h> /* htonl() */
35
#include <string.h> /* memset */
37
#define MIN_GAMMA 0.01
38
#define MAX_GAMMA 99.9
39
#define DEFAULT_GAMMA 1.0
40
#define DEFAULT_BLACK_POINT 95
41
#define DEFAULT_WHITE_POINT 685
44
logImageSetVerbose(int verbosity) {
45
cineonSetVerbose(verbosity);
46
dpxSetVerbose(verbosity);
50
logImageOpen(const char* filename, int cineon) {
52
return cineonOpen(filename);
54
return dpxOpen(filename);
60
logImageOpenFromMem(unsigned char *buffer, unsigned int size, int cineon) {
62
return cineonOpenFromMem(buffer, size);
64
return dpxOpenFromMem(buffer, size);
70
logImageCreate(const char* filename, int cineon, int width, int height, int depth) {
72
return cineonCreate(filename, width, height, depth);
74
return dpxCreate(filename, width, height, depth);
80
logImageGetSize(const LogImageFile* logImage, int* width, int* height, int* depth) {
81
*width = logImage->width;
82
*height = logImage->height;
83
*depth = logImage->depth;
88
logImageGetByteConversionDefaults(LogImageByteConversionParameters* params) {
89
params->gamma = DEFAULT_GAMMA;
90
params->blackPoint = DEFAULT_BLACK_POINT;
91
params->whitePoint = DEFAULT_WHITE_POINT;
96
logImageGetByteConversion(const LogImageFile* logImage, LogImageByteConversionParameters* params) {
97
params->gamma = logImage->params.gamma;
98
params->blackPoint = logImage->params.blackPoint;
99
params->whitePoint = logImage->params.whitePoint;
104
logImageSetByteConversion(LogImageFile* logImage, const LogImageByteConversionParameters* params) {
105
if ((params->gamma >= MIN_GAMMA) &&
106
(params->gamma <= MAX_GAMMA) &&
107
(params->blackPoint >= 0) &&
108
(params->blackPoint < params->whitePoint) &&
109
(params->whitePoint <= 1023)) {
110
logImage->params.gamma = params->gamma;
111
logImage->params.blackPoint = params->blackPoint;
112
logImage->params.whitePoint = params->whitePoint;
120
logImageGetRowBytes(LogImageFile* logImage, unsigned short* row, int y) {
121
return logImage->getRow(logImage, row, y);
125
logImageSetRowBytes(LogImageFile* logImage, const unsigned short* row, int y) {
126
return logImage->setRow(logImage, row, y);
130
logImageClose(LogImageFile* logImage) {
131
logImage->close(logImage);
135
logImageDump(const char* filename) {
139
FILE* foo = fopen(filename, "rb");
144
if (fread(&magic, sizeof(magic), 1, foo) == 0) {
151
if (magic == ntohl(CINEON_FILE_MAGIC)) {
153
cineonDump(filename);
155
} else if (magic == ntohl(DPX_FILE_MAGIC)) {