Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: third_party/libtiff/tif_pixarlog.c

Issue 1563103002: XFA: Upgrade to libtiff 4.0.6. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: rename to libtiff Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/libtiff/tif_packbits.c ('k') | third_party/libtiff/tif_predict.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* $Id: tif_pixarlog.c,v 1.38 2012-06-21 01:01:53 fwarmerdam Exp $ */ 1 /* $Id: tif_pixarlog.c,v 1.39 2012-12-10 17:27:13 tgl Exp $ */
2 2
3 /* 3 /*
4 * Copyright (c) 1996-1997 Sam Leffler 4 * Copyright (c) 1996-1997 Sam Leffler
5 * Copyright (c) 1996 Pixar 5 * Copyright (c) 1996 Pixar
6 * 6 *
7 * Permission to use, copy, modify, distribute, and sell this software and 7 * Permission to use, copy, modify, distribute, and sell this software and
8 * its documentation for any purpose is hereby granted without fee, provided 8 * its documentation for any purpose is hereby granted without fee, provided
9 * that (i) the above copyright notices and this permission notice appear in 9 * that (i) the above copyright notices and this permission notice appear in
10 * all copies of the software and related documentation, and (ii) the names of 10 * all copies of the software and related documentation, and (ii) the names of
11 * Pixar, Sam Leffler and Silicon Graphics may not be used in any advertising or 11 * Pixar, Sam Leffler and Silicon Graphics may not be used in any advertising or
12 * publicity relating to the software without the specific, prior written 12 * publicity relating to the software without the specific, prior written
13 * permission of Pixar, Sam Leffler and Silicon Graphics. 13 * permission of Pixar, Sam Leffler and Silicon Graphics.
14 * 14 *
15 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 15 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 16 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
17 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 17 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
18 * 18 *
19 * IN NO EVENT SHALL PIXAR, SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR 19 * IN NO EVENT SHALL PIXAR, SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
20 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, 20 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
21 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 21 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
22 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 22 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
23 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 23 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24 * OF THIS SOFTWARE. 24 * OF THIS SOFTWARE.
25 */ 25 */
26
26 #include "tiffiop.h" 27 #include "tiffiop.h"
27 #ifdef PIXARLOG_SUPPORT 28 #ifdef PIXARLOG_SUPPORT
28 29
29 /* 30 /*
30 * TIFF Library. 31 * TIFF Library.
31 * PixarLog Compression Support 32 * PixarLog Compression Support
32 * 33 *
33 * Contributed by Dan McCoy. 34 * Contributed by Dan McCoy.
34 * 35 *
35 * PixarLog film support uses the TIFF library to store companded 36 * PixarLog film support uses the TIFF library to store companded
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 multiply_ms(tmsize_t m1, tmsize_t m2) 637 multiply_ms(tmsize_t m1, tmsize_t m2)
637 { 638 {
638 tmsize_t bytes = m1 * m2; 639 tmsize_t bytes = m1 * m2;
639 640
640 if (m1 && bytes / m1 != m2) 641 if (m1 && bytes / m1 != m2)
641 bytes = 0; 642 bytes = 0;
642 643
643 return bytes; 644 return bytes;
644 } 645 }
645 646
647 static tmsize_t
648 add_ms(tmsize_t m1, tmsize_t m2)
649 {
650 tmsize_t bytes = m1 + m2;
651
652 /* if either input is zero, assume overflow already occurred */
653 if (m1 == 0 || m2 == 0)
654 bytes = 0;
655 else if (bytes <= m1 || bytes <= m2)
656 bytes = 0;
657
658 return bytes;
659 }
660
646 static int 661 static int
647 PixarLogFixupTags(TIFF* tif) 662 PixarLogFixupTags(TIFF* tif)
648 { 663 {
649 (void) tif; 664 (void) tif;
650 return (1); 665 return (1);
651 } 666 }
652 667
653 static int 668 static int
654 PixarLogSetupDecode(TIFF* tif) 669 PixarLogSetupDecode(TIFF* tif)
655 { 670 {
656 static const char module[] = "PixarLogSetupDecode"; 671 static const char module[] = "PixarLogSetupDecode";
657 TIFFDirectory *td = &tif->tif_dir; 672 TIFFDirectory *td = &tif->tif_dir;
658 PixarLogState* sp = DecoderState(tif); 673 PixarLogState* sp = DecoderState(tif);
659 tmsize_t tbuf_size; 674 tmsize_t tbuf_size;
660 675
661 assert(sp != NULL); 676 assert(sp != NULL);
662 677
663 /* Make sure no byte swapping happens on the data 678 /* Make sure no byte swapping happens on the data
664 * after decompression. */ 679 * after decompression. */
665 tif->tif_postdecode = _TIFFNoPostDecode; 680 tif->tif_postdecode = _TIFFNoPostDecode;
666 681
667 /* for some reason, we can't do this in TIFFInitPixarLog */ 682 /* for some reason, we can't do this in TIFFInitPixarLog */
668 683
669 sp->stride = (td->td_planarconfig == PLANARCONFIG_CONTIG ? 684 sp->stride = (td->td_planarconfig == PLANARCONFIG_CONTIG ?
670 td->td_samplesperpixel : 1); 685 td->td_samplesperpixel : 1);
671 tbuf_size = multiply_ms(multiply_ms(multiply_ms(sp->stride, td->td_image width), 686 tbuf_size = multiply_ms(multiply_ms(multiply_ms(sp->stride, td->td_image width),
672 td->td_rowsperstrip), sizeof(uint16)); 687 td->td_rowsperstrip), sizeof(uint16));
688 /* add one more stride in case input ends mid-stride */
689 tbuf_size = add_ms(tbuf_size, sizeof(uint16) * sp->stride);
673 if (tbuf_size == 0) 690 if (tbuf_size == 0)
674 return (0); /* TODO: this is an error return without error rep ort through TIFFErrorExt */ 691 return (0); /* TODO: this is an error return without error rep ort through TIFFErrorExt */
675 » sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size+sizeof(uint16)*sp->stride); 692 » sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size);
676 if (sp->tbuf == NULL) 693 if (sp->tbuf == NULL)
677 return (0); 694 return (0);
678 if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) 695 if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN)
679 sp->user_datafmt = PixarLogGuessDataFmt(td); 696 sp->user_datafmt = PixarLogGuessDataFmt(td);
680 if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) { 697 if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) {
681 TIFFErrorExt(tif->tif_clientdata, module, 698 TIFFErrorExt(tif->tif_clientdata, module,
682 "PixarLog compression can't handle bits depth/data forma t combination (depth: %d)", 699 "PixarLog compression can't handle bits depth/data forma t combination (depth: %d)",
683 td->td_bitspersample); 700 td->td_bitspersample);
684 return (0); 701 return (0);
685 } 702 }
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 static const char module[] = "PixarLogPreEncode"; 915 static const char module[] = "PixarLogPreEncode";
899 PixarLogState *sp = EncoderState(tif); 916 PixarLogState *sp = EncoderState(tif);
900 917
901 (void) s; 918 (void) s;
902 assert(sp != NULL); 919 assert(sp != NULL);
903 sp->stream.next_out = tif->tif_rawdata; 920 sp->stream.next_out = tif->tif_rawdata;
904 assert(sizeof(sp->stream.avail_out)==4); /* if this assert gets raised, 921 assert(sizeof(sp->stream.avail_out)==4); /* if this assert gets raised,
905 we need to simplify this code to reflect a ZLib that is likely updat ed 922 we need to simplify this code to reflect a ZLib that is likely updat ed
906 to deal with 8byte memory sizes, though this code will respond 923 to deal with 8byte memory sizes, though this code will respond
907 apropriately even before we simplify it */ 924 apropriately even before we simplify it */
908 » sp->stream.avail_out = (uInt)tif->tif_rawdatasize; 925 » sp->stream.avail_out = tif->tif_rawdatasize;
909 if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize) 926 if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize)
910 { 927 {
911 TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size"); 928 TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size");
912 return (0); 929 return (0);
913 } 930 }
914 return (deflateReset(&sp->stream) == Z_OK); 931 return (deflateReset(&sp->stream) == Z_OK);
915 } 932 }
916 933
917 static void 934 static void
918 horizontalDifferenceF(float *ip, int n, int stride, uint16 *wp, uint16 *FromLT2) 935 horizontalDifferenceF(float *ip, int n, int stride, uint16 *wp, uint16 *FromLT2)
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 #endif /* PIXARLOG_SUPPORT */ 1433 #endif /* PIXARLOG_SUPPORT */
1417 1434
1418 /* vim: set ts=8 sts=8 sw=8 noet: */ 1435 /* vim: set ts=8 sts=8 sw=8 noet: */
1419 /* 1436 /*
1420 * Local Variables: 1437 * Local Variables:
1421 * mode: c 1438 * mode: c
1422 * c-basic-offset: 8 1439 * c-basic-offset: 8
1423 * fill-column: 78 1440 * fill-column: 78
1424 * End: 1441 * End:
1425 */ 1442 */
1426
OLDNEW
« no previous file with comments | « third_party/libtiff/tif_packbits.c ('k') | third_party/libtiff/tif_predict.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698