forked from Grouper-AOSP/platform_manifest
-
Notifications
You must be signed in to change notification settings - Fork 13
/
external_opencv.patch
105 lines (96 loc) · 3.75 KB
/
external_opencv.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
diff --git a/otherlibs/highgui/bitstrm.cpp b/otherlibs/highgui/bitstrm.cpp
index 3a3bb1aaa..17a599356 100644
--- a/otherlibs/highgui/bitstrm.cpp
+++ b/otherlibs/highgui/bitstrm.cpp
@@ -209,13 +209,18 @@ void RBaseStream::SetPos( int pos )
int RBaseStream::GetPos()
{
assert( IsOpened() );
- return m_block_pos - m_block_size + (int)(m_current - m_start);
+ int pos = validateToInt((m_current - m_start) + m_block_pos - m_block_size );
+ //assert(pos >= m_block_pos); // overflow check
+ assert(pos >= 0); // overflow check
+ return pos;
}
void RBaseStream::Skip( int bytes )
{
assert( bytes >= 0 );
+ uchar* old = m_current;
m_current += bytes;
+ assert(m_current >= old);
}
jmp_buf& RBaseStream::JmpBuf()
@@ -746,6 +751,9 @@ void WBaseStream::WriteBlock()
{
int size = (int)(m_current - m_start);
assert( m_file != 0 );
+ assert( IsOpened() );
+ if (size == 0 )
+ return;
//fseek( m_file, m_block_pos, SEEK_SET );
fwrite( m_start, 1, size, m_file );
diff --git a/otherlibs/highgui/grfmt_bmp.cpp b/otherlibs/highgui/grfmt_bmp.cpp
index c67ed4132..b39e23a53 100644
--- a/otherlibs/highgui/grfmt_bmp.cpp
+++ b/otherlibs/highgui/grfmt_bmp.cpp
@@ -102,6 +102,7 @@ bool GrFmtBmpReader::ReadHeader()
m_offset = m_strm.GetDWord();
int size = m_strm.GetDWord();
+ assert(size > 0);
if( size >= 36 )
{
diff --git a/otherlibs/highgui/grfmt_jpeg2000.cpp b/otherlibs/highgui/grfmt_jpeg2000.cpp
index 53067f278..529c9f6f7 100644
--- a/otherlibs/highgui/grfmt_jpeg2000.cpp
+++ b/otherlibs/highgui/grfmt_jpeg2000.cpp
@@ -49,7 +49,8 @@
GrFmtJpeg2000::GrFmtJpeg2000()
{
m_sign_len = 12;
- m_signature = "\x00\x00\x00\x0cjP \r\n\x87\n";
+ static const unsigned char signature_[12] = { 0, 0, 0, 0x0c, 'j', 'P', ' ', ' ', 13, 10, 0x87, 10};
+ m_signature = String((const char*)signature_, (const char*)signature_ + sizeof(signature_));
m_description = "JPEG-2000 files (*.jp2)";
jas_init();
}
@@ -115,6 +116,8 @@ bool GrFmtJpeg2000Reader::ReadHeader()
{
m_image = jas_image_decode( m_stream, -1, 0 );
if( m_image ) {
+ assert(0 == (jas_image_tlx(image));
+ assert(0 == (jas_image_tly(image));
m_width = jas_image_width( m_image );
m_height = jas_image_height( m_image );
@@ -123,6 +126,7 @@ bool GrFmtJpeg2000Reader::ReadHeader()
for( int i = 0; i < numcmpts; i++ )
{
int depth = jas_image_cmptprec( m_image, i );
+ assert(depth == 0 || depth == depth_i);
if( depth > m_bit_depth )
m_bit_depth = depth;
if( m_bit_depth > 8 )
@@ -130,11 +134,27 @@ bool GrFmtJpeg2000Reader::ReadHeader()
if( jas_image_cmpttype( m_image, i ) > 2 )
continue;
+ int sgnd = jas_image_cmptsgnd(image, i);
+ int xstart = jas_image_cmpttlx(image, i);
+ int xend = jas_image_cmptbrx(image, i);
+ int xstep = jas_image_cmpthstep(image, i);
+ int ystart = jas_image_cmpttly(image, i);
+ int yend = jas_image_cmptbry(image, i);
+ int ystep = jas_image_cmptvstep(image, i);
+ assert(sgnd == 0);
+ assert(xstart == 0);
+ assert(ystart == 0);
+ assert(xstep == 1);
+ assert(ystep == 1);
+ assert(xend == m_width);
+ assert(yend == m_height);
cntcmpts++;
}
if( cntcmpts )
{
+ assert(depth == 8 || depth == 16);
+ assert(cntcmpts == 1 || cntcmpts == 3);
m_iscolor = (cntcmpts > 1);
result = true;