Coverage Report

Created: 2021-08-22 09:07

/src/skia/third_party/externals/dng_sdk/source/dng_filter_task.cpp
Line
Count
Source (jump to first uncovered line)
1
/*****************************************************************************/
2
// Copyright 2006 Adobe Systems Incorporated
3
// All Rights Reserved.
4
//
5
// NOTICE:  Adobe permits you to use, modify, and distribute this file in
6
// accordance with the terms of the Adobe license agreement accompanying it.
7
/*****************************************************************************/
8
9
/* $Id: //mondo/dng_sdk_1_4/dng_sdk/source/dng_filter_task.cpp#1 $ */ 
10
/* $DateTime: 2012/05/30 13:28:51 $ */
11
/* $Change: 832332 $ */
12
/* $Author: tknoll $ */
13
14
/*****************************************************************************/
15
16
#include "dng_filter_task.h"
17
18
#include "dng_bottlenecks.h"
19
#include "dng_exceptions.h"
20
#include "dng_image.h"
21
#include "dng_memory.h"
22
#include "dng_tag_types.h"
23
#include "dng_tag_values.h"
24
#include "dng_utils.h"
25
26
/*****************************************************************************/
27
28
dng_filter_task::dng_filter_task (const dng_image &srcImage,
29
                  dng_image &dstImage)
30
  
31
  : fSrcImage     (srcImage)
32
  , fDstImage     (dstImage)
33
  
34
  , fSrcPlane     (0                    )
35
  , fSrcPlanes    (srcImage.Planes    ())
36
  , fSrcPixelType (srcImage.PixelType ())
37
  
38
  , fDstPlane     (0                    )
39
  , fDstPlanes    (dstImage.Planes    ())
40
  , fDstPixelType (dstImage.PixelType ())
41
  
42
  , fSrcRepeat    (1, 1)
43
  , fSrcTileSize  (0, 0)
44
  
45
0
  {
46
47
0
  }
48
                
49
/*****************************************************************************/
50
51
dng_filter_task::~dng_filter_task ()
52
0
  {
53
  
54
0
  }
55
    
56
/*****************************************************************************/
57
58
void dng_filter_task::Start (uint32 threadCount,
59
               const dng_point &tileSize,
60
               dng_memory_allocator *allocator,
61
               dng_abort_sniffer * /* sniffer */)
62
0
  {
63
  
64
0
  fSrcTileSize = SrcTileSize (tileSize);
65
    
66
0
    uint32 srcBufferSize = ComputeBufferSize(fSrcPixelType, fSrcTileSize,
67
0
                         fSrcPlanes, pad16Bytes);
68
0
    uint32 dstBufferSize = ComputeBufferSize(fDstPixelType, tileSize,
69
0
                         fDstPlanes, pad16Bytes);
70
    
71
0
    for (uint32 threadIndex = 0; threadIndex < threadCount; threadIndex++)
72
0
    {
73
    
74
0
    fSrcBuffer [threadIndex] . Reset (allocator->Allocate (srcBufferSize));
75
    
76
0
    fDstBuffer [threadIndex] . Reset (allocator->Allocate (dstBufferSize));
77
    
78
    // Zero buffers so any pad bytes have defined values.
79
    
80
0
    DoZeroBytes (fSrcBuffer [threadIndex]->Buffer      (),
81
0
           fSrcBuffer [threadIndex]->LogicalSize ());
82
    
83
0
    DoZeroBytes (fDstBuffer [threadIndex]->Buffer      (),
84
0
           fDstBuffer [threadIndex]->LogicalSize ());
85
    
86
0
    }
87
    
88
0
  }
89
90
/*****************************************************************************/
91
92
void dng_filter_task::Process (uint32 threadIndex,
93
                 const dng_rect &area,
94
                 dng_abort_sniffer * /* sniffer */)
95
0
  {
96
  
97
  // Find source area for this destination area.
98
  
99
0
  dng_rect srcArea = SrcArea (area);
100
  
101
0
  int32 src_area_w;
102
0
  int32 src_area_h;
103
0
  if (!ConvertUint32ToInt32 (srcArea.W (), &src_area_w) || !ConvertUint32ToInt32 (srcArea.H (), &src_area_h) || src_area_w > fSrcTileSize.h || src_area_h > fSrcTileSize.v)
104
0
    {
105
    
106
0
    ThrowMemoryFull("Area exceeds tile size.");
107
    
108
0
    }
109
            
110
  // Setup srcBuffer.
111
  
112
0
  dng_pixel_buffer srcBuffer(srcArea, fSrcPlane, fSrcPlanes, fSrcPixelType,
113
0
                 pcRowInterleavedAlign16,
114
0
                 fSrcBuffer [threadIndex]->Buffer ());
115
  
116
  // Setup dstBuffer.
117
  
118
0
  dng_pixel_buffer dstBuffer(area, fDstPlane, fDstPlanes, fDstPixelType,
119
0
                 pcRowInterleavedAlign16,
120
0
                 fDstBuffer [threadIndex]->Buffer ());
121
  
122
  // Get source pixels.
123
  
124
0
  fSrcImage.Get (srcBuffer,
125
0
           dng_image::edge_repeat,
126
0
           fSrcRepeat.v,
127
0
           fSrcRepeat.h);
128
           
129
  // Process area.
130
  
131
0
  ProcessArea (threadIndex,
132
0
         srcBuffer,
133
0
         dstBuffer);
134
135
  // Save result pixels.
136
  
137
0
  fDstImage.Put (dstBuffer);
138
  
139
0
  }
140
141
/*****************************************************************************/