~ubuntu-branches/ubuntu/intrepid/blender/intrepid-updates

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2008-08-08 02:45:40 UTC
  • mfrom: (12.1.14 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080808024540-kkjp7ekfivzhuw3l
Tags: 2.46+dfsg-4
* Fix python syntax warning in import_dxf.py, which led to nasty output
  in installation/upgrade logs during byte-compilation, using a patch
  provided by the script author (Closes: #492280):
   - debian/patches/45_fix_python_syntax_warning

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 * cineon.c
28
28
 * contributors: joeedh
29
29
 * I hearby donate this code and all rights to the Blender Foundation.
30
 
 * $Id: cineon_dpx.c,v 1.3 2006/04/02 18:11:02 zuster Exp $
 
30
 * $Id: cineon_dpx.c 14316 2008-04-02 12:56:23Z campbellbarton $
31
31
 */
32
32
 
33
33
#include <stdio.h>
42
42
 
43
43
#include "MEM_guardedalloc.h"
44
44
 
 
45
/* ugly bad level, should be fixed */
 
46
#include "DNA_scene_types.h"
 
47
#include "BKE_global.h"
 
48
 
 
49
static void cineon_conversion_parameters(LogImageByteConversionParameters *params)
 
50
{
 
51
        params->blackPoint = G.scene->r.cineonblack;
 
52
        params->whitePoint = G.scene->r.cineonwhite;
 
53
        params->gamma = G.scene->r.cineongamma;
 
54
        params->doLogarithm = G.scene->r.subimtype & R_CINEON_LOG;
 
55
}
 
56
 
45
57
static struct ImBuf *imb_load_dpx_cineon(unsigned char *mem, int use_cineon, int size, int flags)
46
58
{
 
59
        LogImageByteConversionParameters conversion;
47
60
        ImBuf *ibuf;
48
61
        LogImageFile *image;
49
62
        int x, y;
50
 
        unsigned short *row;
 
63
        unsigned short *row, *upix;
51
64
        int width, height, depth;
52
65
        float *frow;
 
66
 
 
67
        cineon_conversion_parameters(&conversion);
53
68
        
54
69
        image = logImageOpenFromMem(mem, size, use_cineon);
55
70
        
64
79
                logImageClose(image);
65
80
                return NULL;
66
81
        }
 
82
        
67
83
        if (width == 0 && height == 0) {
68
84
                logImageClose(image);
69
85
                return NULL;
70
86
        }
71
87
        
 
88
        logImageSetByteConversion(image, &conversion);
 
89
 
72
90
        ibuf = IMB_allocImBuf(width, height, 32, IB_rectfloat | flags, 0);
73
91
 
74
92
        row = MEM_mallocN(sizeof(unsigned short)*width*depth, "row in cineon_dpx.c");
 
93
        frow = ibuf->rect_float+width*height*4;
75
94
        
76
95
        for (y = 0; y < height; y++) {
77
 
                unsigned int index = (width) * (height-y-1);
78
 
                index = index * 4;
79
 
                
80
 
                frow = &ibuf->rect_float[index];
81
 
                
82
96
                logImageGetRowBytes(image, row, y);
 
97
                upix = row;
 
98
                frow -= width*4;
83
99
                
84
100
                for (x=0; x<width; x++) {
85
 
                        unsigned short *upix = &row[x*depth];
86
 
                        float *fpix = &frow[x*4];
87
 
                        fpix[0] = ((float)upix[0]) / 65535.0f;
88
 
                        fpix[1] = ((float)upix[1]) / 65535.0f;
89
 
                        fpix[2] = ((float)upix[2]) / 65535.0f;
90
 
                        fpix[3] = 1.0f;
 
101
                        *(frow++) = ((float)*(upix++)) / 65535.0f;
 
102
                        *(frow++) = ((float)*(upix++)) / 65535.0f;
 
103
                        *(frow++) = ((float)*(upix++)) / 65535.0f;
 
104
                        *(frow++) = 1.0f;
91
105
                }
 
106
                frow -= width*4;
92
107
        }
93
108
 
94
109
        MEM_freeN(row);
109
124
        int i, j;
110
125
        int index;
111
126
        float *fline;
112
 
        
113
 
        conversion.blackPoint = 95;
114
 
        conversion.whitePoint = 685;
115
 
        conversion.gamma = 1;
 
127
 
 
128
        cineon_conversion_parameters(&conversion);
 
129
 
116
130
        /*
117
131
         * Get the drawable for the current image...
118
132
         */
121
135
        height = buf->y;
122
136
        depth = 3;
123
137
        
124
 
        if (!buf->rect_float) return 0;
 
138
        
 
139
        if (!buf->rect_float) {
 
140
                IMB_float_from_rect(buf);
 
141
                if (!buf->rect_float) { /* in the unlikely event that converting to a float buffer fails */
 
142
                        return 0;
 
143
                }
 
144
        }
125
145
        
126
146
        logImageSetVerbose(0);
127
147
        logImage = logImageCreate(filename, use_cineon, width, height, depth);