File indexing completed on 2025-01-05 03:56:58
0001 /* -*- C++ -*- 0002 * Copyright 2019-2021 LibRaw LLC (info@libraw.org) 0003 * 0004 LibRaw is free software; you can redistribute it and/or modify 0005 it under the terms of the one of two licenses as you choose: 0006 0007 1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1 0008 (See file LICENSE.LGPL provided in LibRaw distribution archive for details). 0009 0010 2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 0011 (See file LICENSE.CDDL provided in LibRaw distribution archive for details). 0012 0013 */ 0014 0015 #include "../../internal/dcraw_defs.h" 0016 0017 void LibRaw::parseEpsonMakernote(int base, int uptag, unsigned dng_writer) 0018 { 0019 0020 #define isRIC imgdata.sizes.raw_inset_crops[0] 0021 0022 unsigned entries, tag, type, len, save; 0023 short morder, sorder = order; 0024 ushort c; 0025 INT64 fsize = ifp->size(); 0026 0027 fseek(ifp, -2, SEEK_CUR); 0028 0029 entries = get2(); 0030 if (entries > 1000) 0031 return; 0032 morder = order; 0033 0034 while (entries--) 0035 { 0036 order = morder; 0037 tiff_get(base, &tag, &type, &len, &save); 0038 INT64 pos = ifp->tell(); 0039 if (len > 8 && pos + len > 2 * fsize) 0040 { 0041 fseek(ifp, save, SEEK_SET); // Recover tiff-read position!! 0042 continue; 0043 } 0044 0045 tag |= uptag << 16; 0046 if (len > 100 * 1024 * 1024) 0047 goto next; // 100Mb tag? No! 0048 0049 if (tag == 0x020b) 0050 { 0051 if (tagtypeIs(LIBRAW_EXIFTAG_TYPE_LONG)) 0052 isRIC.cwidth = get4(); 0053 else if (tagtypeIs(LIBRAW_EXIFTAG_TYPE_SHORT)) 0054 isRIC.cwidth = get2(); 0055 } 0056 else if (tag == 0x020c) 0057 { 0058 if (tagtypeIs(LIBRAW_EXIFTAG_TYPE_LONG)) 0059 isRIC.cheight = get4(); 0060 else if (tagtypeIs(LIBRAW_EXIFTAG_TYPE_SHORT)) 0061 isRIC.cheight = get2(); 0062 } 0063 else if (tag == 0x0400) 0064 { // sensor area 0065 ushort sdims[4] = {0, 0, 0, 0}; // left margin, top margin, width, height 0066 FORC4 sdims[c] = get2(); 0067 isRIC.cleft = (sdims[2] - sdims[0] - isRIC.cwidth) / 2; 0068 isRIC.ctop = (sdims[3] - sdims[1] - isRIC.cheight) / 2; 0069 } 0070 0071 if (dng_writer == nonDNG) 0072 { 0073 0074 if (tag == 0x0280) 0075 { 0076 thumb_offset = ftell(ifp); 0077 thumb_length = len; 0078 } 0079 else if (tag == 0x0401) 0080 { 0081 FORC4 cblack[RGGB_2_RGBG(c)] = get4(); 0082 } 0083 else if (tag == 0x0e80) 0084 { 0085 fseek(ifp, 48, SEEK_CUR); 0086 cam_mul[0] = get2() * 567.0 / 0x10000; 0087 cam_mul[2] = get2() * 431.0 / 0x10000; 0088 } 0089 } 0090 0091 next: 0092 fseek(ifp, save, SEEK_SET); 0093 } 0094 order = sorder; 0095 #undef isRIC 0096 }