~ubuntu-branches/ubuntu/natty/kipi-plugins/natty

« back to all changes in this revision

Viewing changes to dngconverter/dngwriter/extra/dng_sdk/dng_shared.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-06-13 01:07:38 UTC
  • mfrom: (1.1.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20100613010738-y8ped08n4vibopv3
Tags: 1.3.0-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
// accordance with the terms of the Adobe license agreement accompanying it.
7
7
/*****************************************************************************/
8
8
 
9
 
/* $Id: //mondo/dng_sdk_1_2/dng_sdk/source/dng_shared.cpp#2 $ */ 
10
 
/* $DateTime: 2008/04/02 14:06:57 $ */
11
 
/* $Change: 440485 $ */
 
9
/* $Id: //mondo/dng_sdk_1_3/dng_sdk/source/dng_shared.cpp#1 $ */ 
 
10
/* $DateTime: 2009/06/22 05:04:49 $ */
 
11
/* $Change: 578634 $ */
12
12
/* $Author: tknoll $ */
13
13
 
14
14
/*****************************************************************************/
15
15
 
16
16
#include "dng_shared.h"
 
17
 
17
18
#include "dng_camera_profile.h"
18
19
#include "dng_exceptions.h"
19
20
#include "dng_globals.h"
1027
1028
 
1028
1029
        ,       fAsShotProfileName ()
1029
1030
 
 
1031
        ,       fNoiseProfile ()
 
1032
 
1030
1033
        {
1031
1034
        
1032
1035
        }
1163
1166
                                        DumpHexAscii (stream, fIPTC_NAA_Count);
1164
1167
                                        
1165
1168
                                        }
1166
 
                                                
 
1169
                                        
 
1170
                                // Compute and output the digest.
 
1171
                                
 
1172
                                dng_memory_data buffer (fIPTC_NAA_Count);
 
1173
                                
 
1174
                                stream.SetReadPosition (fIPTC_NAA_Offset);
 
1175
                                
 
1176
                                stream.Get (buffer.Buffer (), fIPTC_NAA_Count);
 
1177
                                
 
1178
                                const uint8 *data = buffer.Buffer_uint8 ();
 
1179
                                
 
1180
                                uint32 count = fIPTC_NAA_Count;
 
1181
                                
 
1182
                                // Method 1: Counting all bytes (this is correct).
 
1183
                                
 
1184
                                        {
 
1185
                                        
 
1186
                                        dng_md5_printer printer;
 
1187
                
 
1188
                                        printer.Process (data, count);
 
1189
                                        
 
1190
                                        printf ("IPTCDigest: ");
 
1191
                                        
 
1192
                                        DumpFingerprint (printer.Result ());
 
1193
                                        
 
1194
                                        printf ("\n");
 
1195
                                        
 
1196
                                        }
 
1197
                                        
 
1198
                                // Method 2: Ignoring zero padding.
 
1199
                                        
 
1200
                                        {
 
1201
                                        
 
1202
                                        uint32 removed = 0;
 
1203
                        
 
1204
                                        while ((removed < 3) && (count > 0) && (data [count - 1] == 0))
 
1205
                                                {
 
1206
                                                removed++;
 
1207
                                                count--;
 
1208
                                                }
 
1209
                                                
 
1210
                                        if (removed != 0)
 
1211
                                                {
 
1212
                                        
 
1213
                                                dng_md5_printer printer;
 
1214
                        
 
1215
                                                printer.Process (data, count);
 
1216
                                                
 
1217
                                                printf ("IPTCDigest (ignoring zero padding): ");
 
1218
                                                
 
1219
                                                DumpFingerprint (printer.Result ());
 
1220
                                                
 
1221
                                                printf ("\n");
 
1222
                                                
 
1223
                                                }
 
1224
                                        
 
1225
                                        }
 
1226
                                        
1167
1227
                                }
1168
1228
                                
1169
1229
                        #endif
1689
1749
                        break;
1690
1750
                        
1691
1751
                        }
 
1752
 
 
1753
                case tcNoiseProfile:
 
1754
                        {
 
1755
 
 
1756
                        if (!CheckTagType (parentCode, tagCode, tagType, ttDouble))
 
1757
                                return false;
 
1758
 
 
1759
                        // Must be an even, positive number of doubles in a noise profile.
 
1760
                        
 
1761
                        if (!tagCount || (tagCount & 1))
 
1762
                                return false;
 
1763
 
 
1764
                        // Determine number of planes (i.e., half the number of doubles).
 
1765
 
 
1766
                        const uint32 numPlanes = Pin_uint32 (0, 
 
1767
                                                                                                 tagCount >> 1, 
 
1768
                                                                                                 kMaxColorPlanes);
 
1769
 
 
1770
                        // Parse the noise function parameters.
 
1771
 
 
1772
                        std::vector<dng_noise_function> noiseFunctions;
 
1773
 
 
1774
                        for (uint32 i = 0; i < numPlanes; i++)
 
1775
                                {
 
1776
 
 
1777
                                const real64 scale      = stream.TagValue_real64 (tagType);
 
1778
                                const real64 offset = stream.TagValue_real64 (tagType);
 
1779
 
 
1780
                                noiseFunctions.push_back (dng_noise_function (scale, offset));
 
1781
 
 
1782
                                }
 
1783
 
 
1784
                        // Store the noise profile.
 
1785
 
 
1786
                        fNoiseProfile = dng_noise_profile (noiseFunctions);
 
1787
 
 
1788
                        // Debug.
 
1789
 
 
1790
                        #if qDNGValidate
 
1791
 
 
1792
                        if (gVerbose)
 
1793
                                {
 
1794
                                
 
1795
                                printf ("NoiseProfile:\n");
 
1796
                                
 
1797
                                printf ("  Planes: %u\n", numPlanes);
 
1798
                                        
 
1799
                                for (uint32 plane = 0; plane < numPlanes; plane++)
 
1800
                                        {
 
1801
 
 
1802
                                        printf ("  Noise function for plane %u: scale = %.8lf, offset = %.8lf\n",
 
1803
                                                        plane,
 
1804
                                                        noiseFunctions [plane].Scale  (),
 
1805
                                                        noiseFunctions [plane].Offset ());
 
1806
 
 
1807
                                        }
 
1808
                                
 
1809
                                }
 
1810
 
 
1811
                        #endif
 
1812
                        
 
1813
                        break;
 
1814
                        
 
1815
                        }
1692
1816
                        
1693
1817
                case tcBaselineSharpness:
1694
1818
                        {
2349
2473
                
2350
2474
                // Support for DNG versions before 1.0.0.0.
2351
2475
                
2352
 
                if (fDNGVersion < 0x01000000)
 
2476
                if (fDNGVersion < dngVersion_1_0_0_0)
2353
2477
                        {
2354
2478
                        
2355
2479
                        #if qDNGValidate
2364
2488
                        fCameraProfile.fCalibrationIlluminant1 = lsStandardLightA;
2365
2489
                        fCameraProfile.fCalibrationIlluminant2 = lsD65;
2366
2490
                        
2367
 
                        fDNGVersion = 0x01000000;
 
2491
                        fDNGVersion = dngVersion_1_0_0_0;
2368
2492
 
2369
2493
                        }
2370
2494
                
2379
2503
        
2380
2504
                // Check DNGBackwardVersion value.
2381
2505
                
2382
 
                if (fDNGBackwardVersion < 0x01000000)
 
2506
                if (fDNGBackwardVersion < dngVersion_1_0_0_0)
2383
2507
                        {
2384
2508
                        
2385
2509
                        #if qDNGValidate
2388
2512
                                                 
2389
2513
                        #endif
2390
2514
                        
2391
 
                        fDNGBackwardVersion = 0x01000000;
 
2515
                        fDNGBackwardVersion = dngVersion_1_0_0_0;
2392
2516
                                
2393
2517
                        }
2394
2518
 
2584
2708
                        fBaselineSharpness = dng_urational (1, 1);
2585
2709
                                                         
2586
2710
                        }
 
2711
 
 
2712
                // Check NoiseProfile.
 
2713
 
 
2714
                if (!fNoiseProfile.IsValid () && fNoiseProfile.NumFunctions () != 0)
 
2715
                        {
 
2716
                        
 
2717
                        #if qDNGValidate
 
2718
                        
 
2719
                        ReportWarning ("Invalid NoiseProfile");
 
2720
                                                 
 
2721
                        #endif
 
2722
                        
 
2723
                        fNoiseProfile = dng_noise_profile ();
 
2724
                                                         
 
2725
                        }
2587
2726
                        
2588
2727
                // Check LinearResponseLimit.
2589
2728
                
2627
2766
        
2628
2767
        // Check DNGVersion value.
2629
2768
        
2630
 
        if (fDNGVersion < 0x01000000)
 
2769
        if (fDNGVersion < dngVersion_1_0_0_0)
2631
2770
                {
2632
2771
                
2633
2772
                #if qDNGValidate
2642
2781
                
2643
2782
        // Check DNGBackwardVersion value.
2644
2783
        
2645
 
        if (fDNGBackwardVersion > 0x01020000)
 
2784
        if (fDNGBackwardVersion > dngVersion_Current)
2646
2785
                {
2647
2786
                
2648
2787
                #if qDNGValidate