~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** \file blender/imbuf/intern/cineon/cineonlib.c
 
2
 *  \ingroup imbcineon
 
3
 */
1
4
/*
2
5
 *       Cineon image file format library routines.
3
6
 *
33
36
#include <netinet/in.h>  /* htonl() */
34
37
#endif
35
38
#include <string.h>                      /* memset */
 
39
 
 
40
#include "BLI_utildefines.h"
 
41
#include "BLI_fileops.h"
 
42
 
36
43
#include "cin_debug_stuff.h"
37
44
#include "logmemfile.h"
38
45
 
129
136
        if (cineon->depth == 1) {
130
137
                fillCineonChannelInfo(cineon, &imageInfo->channel[0], 0);
131
138
 
132
 
        } else if (cineon->depth == 3) {
 
139
        }
 
140
        else if (cineon->depth == 3) {
133
141
                fillCineonChannelInfo(cineon, &imageInfo->channel[0], 1);
134
142
                fillCineonChannelInfo(cineon, &imageInfo->channel[1], 2);
135
143
                fillCineonChannelInfo(cineon, &imageInfo->channel[2], 3);
185
193
static void
186
194
fillCineonFormatInfo(CineonFile* cineon, CineonFormatInformation* formatInfo) {
187
195
 
 
196
        (void)cineon; /* unused */
 
197
        
188
198
        formatInfo->interleave = 0;
189
199
        formatInfo->packing = 5;
190
200
        formatInfo->signage = 0;
206
216
        d_printf("Packing %d,", formatInfo->packing);
207
217
        if (formatInfo->packing & 0x80) { 
208
218
                d_printf(" multi pixel,");
209
 
        } else {
 
219
        }
 
220
        else {
210
221
                d_printf(" single pixel,");
211
222
        }
212
223
        switch (formatInfo->packing & 0x7F) {
222
233
        d_printf("Sign %d,", formatInfo->signage);
223
234
        if (formatInfo->signage) { 
224
235
                d_printf(" signed\n");
225
 
        } else {
 
236
        }
 
237
        else {
226
238
                d_printf(" unsigned\n");
227
239
        }
228
240
        d_printf("Sense %d,", formatInfo->signage);
229
241
        if (formatInfo->signage) { 
230
242
                d_printf(" negative\n");
231
 
        } else {
 
243
        }
 
244
        else {
232
245
                d_printf(" positive\n");
233
246
        }
234
247
        d_printf("End of line padding %ld\n", (intptr_t)ntohl(formatInfo->line_padding));
238
251
static void
239
252
fillCineonOriginationInfo(CineonFile* cineon,
240
253
        CineonOriginationInformation* originInfo, CineonFileInformation* fileInfo) {
 
254
        
 
255
        (void)cineon; /* unused */
241
256
 
242
257
        originInfo->x_offset = htonl(0);
243
258
        originInfo->y_offset = htonl(0);
269
284
        d_printf("Input device gamma %f\n", ntohf(originInfo->input_device_gamma));
270
285
}
271
286
 
272
 
int
 
287
static int
273
288
initCineonGenericHeader(CineonFile* cineon, CineonGenericHeader* header, const char* imagename) {
274
289
 
275
290
        fillCineonFileInfo(cineon, &header->fileInfo, imagename);
280
295
        return 0;
281
296
}
282
297
 
283
 
void
284
 
dumpCineonGenericHeader(CineonGenericHeader* header) {
 
298
static void
 
299
UNUSED_FUNCTION(dumpCineonGenericHeader)(CineonGenericHeader* header) {
285
300
        dumpCineonFileInfo(&header->fileInfo);
286
301
        dumpCineonImageInfo(&header->imageInfo);
287
302
        dumpCineonFormatInfo(&header->formatInfo);
325
340
 
326
341
        longsRead = logimage_fread(cineon->lineBuffer, 4, cineon->lineBufferLength, cineon);
327
342
        if (longsRead != cineon->lineBufferLength) {
328
 
                if (verbose) 
329
 
        {       d_printf("Couldn't read line %d length %d\n", y, cineon->lineBufferLength * 4);
330
 
                perror("cineonGetRowBytes");
331
 
        }
 
343
                if (verbose) {
 
344
                        d_printf("Couldn't read line %d length %d\n", y, cineon->lineBufferLength * 4);
 
345
                        perror("cineonGetRowBytes");
 
346
                }
 
347
 
332
348
                return 1;
333
349
        }
334
350
 
350
366
 
351
367
        /* extract required pixels */
352
368
        for (pixelIndex = 0; pixelIndex < numPixels; ++pixelIndex) {
353
 
                if(cineon->params.doLogarithm)
 
369
                if (cineon->params.doLogarithm)
354
370
                        row[pixelIndex] = cineon->lut10_16[cineon->pixelBuffer[pixelIndex]];
355
371
                else
356
372
                        row[pixelIndex] = cineon->pixelBuffer[pixelIndex] << 6;
369
385
 
370
386
        /* put new pixels into pixelBuffer */
371
387
        for (pixelIndex = 0; pixelIndex < numPixels; ++pixelIndex) {
372
 
                if(cineon->params.doLogarithm)
 
388
                if (cineon->params.doLogarithm)
373
389
                        cineon->pixelBuffer[pixelIndex] = cineon->lut16_16[row[pixelIndex]];
374
390
                else
375
391
                        cineon->pixelBuffer[pixelIndex] = row[pixelIndex] >> 6;
512
528
        cineon->memcursor = 0;
513
529
        cineon->membuffersize = 0;
514
530
        
515
 
        cineon->file = fopen(filename, "rb");
 
531
        cineon->file = BLI_fopen(filename, "rb");
516
532
        if (cineon->file == 0) {
517
533
                if (verbose) d_printf("Failed to open file \"%s\".\n", filename);
518
534
                cineonClose(cineon);
592
608
        
593
609
        if (num != ntohl(CINEON_FILE_MAGIC)) {
594
610
                return 0;
595
 
        } else return 1;
 
611
        }
 
612
        else return 1;
596
613
}
597
614
 
598
615
CineonFile* 
599
616
cineonOpenFromMem(unsigned char *mem, unsigned int size) {
600
617
 
601
618
        CineonGenericHeader header;
602
 
        int i;
603
619
        
604
620
        CineonFile* cineon = (CineonFile* )malloc(sizeof(CineonFile));
605
621
        if (cineon == 0) {
663
679
                return 0;
664
680
        }
665
681
        cineon->pixelBufferUsed = 0;
666
 
 
667
 
        i = cineon->imageOffset;
668
682
        
669
683
        if (logimage_fseek(cineon, cineon->imageOffset, SEEK_SET) != 0) {
670
684
                if (verbose) d_printf("Couldn't seek to image data at %d\n", cineon->imageOffset);
719
733
        cineon->lineBuffer = 0;
720
734
        cineon->pixelBuffer = 0;
721
735
 
722
 
        cineon->file = fopen(filename, "wb");
 
736
        cineon->file = BLI_fopen(filename, "wb");
723
737
        if (cineon->file == 0) {
724
738
                if (verbose) d_printf("Couldn't open file %s\n", filename);
725
739
                cineonClose(cineon);
754
768
        shortFilename = strrchr(filename, '/');
755
769
        if (shortFilename == 0) {
756
770
                shortFilename = filename;
757
 
        } else {
 
771
        }
 
772
        else {
758
773
                ++shortFilename;
759
774
        }
760
775