~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to source/blender/imbuf/intern/cineon/logImageLib.c

  • Committer: Bazaar Package Importer
  • Author(s): Lukas Fittl
  • Date: 2006-09-20 01:57:27 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060920015727-gmoqlxwstx9wwqs3
Tags: 2.42a-1ubuntu1
* Merge from Debian unstable (Closes: Malone #55903). Remaining changes:
  - debian/genpot: Add python scripts from Lee June <blender@eyou.com> to
    generate a reasonable PO template from the sources. Since gettext is used
    in a highly nonstandard way, xgettext does not work for this job.
  - debian/rules: Call the scripts, generate po/blender.pot, and clean it up
    in the clean target.
  - Add a proper header to the generated PO template.
* debian/control: Build depend on libavformat-dev >= 3:0.cvs20060823-3.1,
  otherwise this package will FTBFS

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *       Cineon and DPX image file format library routines.
 
3
 *
 
4
 *       Copyright 1999 - 2002 David Hodson <hodsond@acm.org>
 
5
 *
 
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)
 
9
 *       any later version.
 
10
 *
 
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
 
14
 *       for more details.
 
15
 *
 
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.
 
19
 *
 
20
 */
 
21
 
 
22
#include "cineonlib.h"
 
23
#include "dpxlib.h"
 
24
 
 
25
#include <stdio.h>
 
26
#include <math.h>
 
27
#include <stdlib.h>
 
28
#include <time.h>                                /* strftime() */
 
29
#include <sys/types.h>
 
30
#ifdef WIN32
 
31
#include <winsock.h>
 
32
#else
 
33
#include <netinet/in.h>  /* htonl() */
 
34
#endif
 
35
#include <string.h>                      /* memset */
 
36
 
 
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
 
42
 
 
43
void
 
44
logImageSetVerbose(int verbosity) {
 
45
        cineonSetVerbose(verbosity);
 
46
        dpxSetVerbose(verbosity);
 
47
}
 
48
 
 
49
LogImageFile*
 
50
logImageOpen(const char* filename, int cineon) {
 
51
        if (cineon) {
 
52
                return cineonOpen(filename);
 
53
        } else {
 
54
                return dpxOpen(filename);
 
55
        }
 
56
        return 0;
 
57
}
 
58
 
 
59
LogImageFile*
 
60
logImageOpenFromMem(unsigned char *buffer, unsigned int size, int cineon) {
 
61
        if (cineon) {
 
62
                return cineonOpenFromMem(buffer, size);
 
63
        } else {
 
64
                return dpxOpenFromMem(buffer, size);
 
65
        }
 
66
        return 0;
 
67
}
 
68
 
 
69
LogImageFile*
 
70
logImageCreate(const char* filename, int cineon, int width, int height, int depth) {
 
71
        if (cineon) {
 
72
                return cineonCreate(filename, width, height, depth);
 
73
        } else {
 
74
                return dpxCreate(filename, width, height, depth);
 
75
        }
 
76
        return 0;
 
77
}
 
78
 
 
79
int
 
80
logImageGetSize(const LogImageFile* logImage, int* width, int* height, int* depth) {
 
81
        *width = logImage->width;
 
82
        *height = logImage->height;
 
83
        *depth = logImage->depth;
 
84
        return 0;
 
85
}
 
86
 
 
87
int
 
88
logImageGetByteConversionDefaults(LogImageByteConversionParameters* params) {
 
89
        params->gamma = DEFAULT_GAMMA;
 
90
        params->blackPoint = DEFAULT_BLACK_POINT;
 
91
        params->whitePoint = DEFAULT_WHITE_POINT;
 
92
        return 0;
 
93
}
 
94
 
 
95
int
 
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;
 
100
        return 0;
 
101
}
 
102
 
 
103
int
 
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;
 
113
                setupLut(logImage);
 
114
                return 0;
 
115
        }
 
116
        return 1;
 
117
}
 
118
 
 
119
int
 
120
logImageGetRowBytes(LogImageFile* logImage, unsigned short* row, int y) {
 
121
        return logImage->getRow(logImage, row, y);
 
122
}
 
123
 
 
124
int
 
125
logImageSetRowBytes(LogImageFile* logImage, const unsigned short* row, int y) {
 
126
        return logImage->setRow(logImage, row, y);
 
127
}
 
128
 
 
129
void
 
130
logImageClose(LogImageFile* logImage) {
 
131
        logImage->close(logImage);
 
132
}
 
133
 
 
134
void
 
135
logImageDump(const char* filename) {
 
136
 
 
137
        U32 magic;
 
138
 
 
139
        FILE* foo = fopen(filename, "rb");
 
140
        if (foo == 0) {
 
141
                return;
 
142
        }
 
143
 
 
144
        if (fread(&magic, sizeof(magic), 1, foo) == 0) {
 
145
                fclose(foo);
 
146
                return;
 
147
        }
 
148
 
 
149
        fclose(foo);
 
150
 
 
151
        if (magic == ntohl(CINEON_FILE_MAGIC)) {
 
152
#if 0
 
153
                cineonDump(filename);
 
154
#endif
 
155
        } else if (magic == ntohl(DPX_FILE_MAGIC)) {
 
156
                dpxDump(filename);
 
157
        }
 
158
}