Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Raptor Engineering Public Development
dsview
Commits
8a261384
Commit
8a261384
authored
8 years ago
by
DreamSourceLab
Browse files
Options
Download
Email Patches
Plain Diff
Improve performance of protocol decoder
parent
9bc3bf7e
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
172 additions
and
91 deletions
+172
-91
DSView/main.cpp
DSView/main.cpp
+2
-1
DSView/pv/data/decode/row.cpp
DSView/pv/data/decode/row.cpp
+2
-2
DSView/pv/data/decoderstack.cpp
DSView/pv/data/decoderstack.cpp
+54
-9
DSView/pv/data/decoderstack.h
DSView/pv/data/decoderstack.h
+4
-10
DSView/pv/data/logicsnapshot.cpp
DSView/pv/data/logicsnapshot.cpp
+11
-9
DSView/pv/data/snapshot.cpp
DSView/pv/data/snapshot.cpp
+2
-0
DSView/pv/dock/dsotriggerdock.cpp
DSView/pv/dock/dsotriggerdock.cpp
+4
-4
DSView/pv/dock/measuredock.cpp
DSView/pv/dock/measuredock.cpp
+4
-4
DSView/pv/dock/searchdock.cpp
DSView/pv/dock/searchdock.cpp
+4
-4
DSView/pv/dock/triggerdock.cpp
DSView/pv/dock/triggerdock.cpp
+4
-4
DSView/pv/mainwindow.cpp
DSView/pv/mainwindow.cpp
+1
-1
DSView/pv/view/decodetrace.cpp
DSView/pv/view/decodetrace.cpp
+75
-40
DSView/pv/view/header.cpp
DSView/pv/view/header.cpp
+1
-1
DSView/pv/view/logicsignal.cpp
DSView/pv/view/logicsignal.cpp
+2
-0
DSView/pv/view/ruler.cpp
DSView/pv/view/ruler.cpp
+1
-1
DSView/pv/view/viewport.cpp
DSView/pv/view/viewport.cpp
+1
-1
No files found.
DSView/main.cpp
View file @
8a261384
...
...
@@ -35,6 +35,7 @@
#include <QFile>
#include <QDir>
#include "dsapplication.h"
#include "pv/devicemanager.h"
#include "pv/mainwindow.h"
...
...
@@ -59,7 +60,7 @@ int main(int argc, char *argv[])
struct
sr_context
*
sr_ctx
=
NULL
;
const
char
*
open_file
=
NULL
;
Q
Application
a
(
argc
,
argv
);
DS
Application
a
(
argc
,
argv
);
// Language
#ifdef LANGUAGE_ZH_CN
...
...
This diff is collapsed.
Click to expand it.
DSView/pv/data/decode/row.cpp
View file @
8a261384
...
...
@@ -68,8 +68,8 @@ const QString Row::title() const
bool
Row
::
operator
<
(
const
Row
&
other
)
const
{
return
(
_decoder
->
name
<
other
.
_decoder
->
name
)
||
(
_decoder
->
name
==
other
.
_decoder
->
name
&&
_row
->
desc
<
other
.
_row
->
desc
);
return
(
_decoder
<
other
.
_decoder
)
||
(
_decoder
==
other
.
_decoder
&&
_row
<
other
.
_row
);
}
}
// decode
...
...
This diff is collapsed.
Click to expand it.
DSView/pv/data/decoderstack.cpp
View file @
8a261384
...
...
@@ -17,12 +17,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <libsigrokdecode/libsigrokdecode.h>
#include <boost/foreach.hpp>
#include <boost/thread/thread.hpp>
#include <stdexcept>
#include <algorithm>
#include <QDebug>
...
...
@@ -57,6 +56,7 @@ namespace data {
const
double
DecoderStack
::
DecodeMargin
=
1.0
;
const
double
DecoderStack
::
DecodeThreshold
=
0.2
;
const
int64_t
DecoderStack
::
DecodeChunkLength
=
4
*
1024
;
//const int64_t DecoderStack::DecodeChunkLength = 1024 * 1024;
const
unsigned
int
DecoderStack
::
DecodeNotifyPeriod
=
1024
;
mutex
DecoderStack
::
_global_decode_mutex
;
...
...
@@ -443,11 +443,22 @@ void DecoderStack::decode_data(
uint64_t
notify_cnt
=
(
decode_end
-
decode_start
+
1
)
/
100
;
const
uint64_t
chunk_sample_count
=
DecodeChunkLength
/
_snapshot
->
unit_size
();
srd_decoder_inst
*
logic_di
=
NULL
;
// find the first level decoder instant
for
(
GSList
*
d
=
session
->
di_list
;
d
;
d
=
d
->
next
)
{
srd_decoder_inst
*
di
=
(
srd_decoder_inst
*
)
d
->
data
;
srd_decoder
*
decoder
=
di
->
decoder
;
const
bool
have_probes
=
(
decoder
->
channels
||
decoder
->
opt_channels
)
!=
0
;
if
(
have_probes
)
{
logic_di
=
di
;
break
;
}
}
for
(
uint
64
_t
i
=
decode_start
;
!
boost
::
this_thread
::
interruption_requested
()
&&
i
<
decode_end
&&
!
_no_memory
;
i
+=
chunk_sample_count
)
uint
8
_t
chunk_type
=
0
;
uint64_t
i
=
decode_start
;
while
(
!
boost
::
this_thread
::
interruption_requested
()
&&
i
<
decode_end
&&
!
_no_memory
)
{
//lock_guard<mutex> decode_lock(_global_decode_mutex);
...
...
@@ -455,22 +466,56 @@ void DecoderStack::decode_data(
i
+
chunk_sample_count
,
decode_end
);
chunk
=
_snapshot
->
get_samples
(
i
,
chunk_end
);
if
(
srd_session_send
(
session
,
i
,
chunk_end
,
chunk
,
if
(
srd_session_send
(
session
,
chunk_type
,
i
,
chunk_end
,
chunk
,
(
chunk_end
-
i
)
*
unit_size
,
unit_size
)
!=
SRD_OK
)
{
_error_message
=
tr
(
"Decoder reported an error"
);
break
;
}
if
(
logic_di
&&
logic_di
->
logic_mask
!=
0
)
{
uint64_t
cur_pos
=
logic_di
->
cur_pos
;
uint64_t
sample
=
_snapshot
->
get_sample
(
cur_pos
)
&
logic_di
->
logic_mask
;
if
(
logic_di
->
edge_index
==
-
1
)
{
std
::
vector
<
uint64_t
>
pos_vector
;
cur_pos
++
;
for
(
int
j
=
0
;
j
<
logic_di
->
dec_num_channels
;
j
++
)
{
int
index
=
logic_di
->
dec_channelmap
[
j
];
if
(
index
!=
-
1
&&
(
logic_di
->
logic_mask
&
(
1
<<
index
)))
{
bool
last_sample
=
(
sample
&
(
1
<<
index
))
?
1
:
0
;
pos_vector
.
push_back
(
cur_pos
);
_snapshot
->
get_nxt_edge
(
pos_vector
.
back
(),
last_sample
,
decode_end
,
1
,
index
);
}
}
cur_pos
=
*
std
::
min_element
(
pos_vector
.
begin
(),
pos_vector
.
end
());
}
else
{
bool
last_sample
=
(
sample
&
(
1
<<
logic_di
->
edge_index
))
?
1
:
0
;
do
{
cur_pos
++
;
if
(
!
_snapshot
->
get_nxt_edge
(
cur_pos
,
last_sample
,
decode_end
,
1
,
logic_di
->
edge_index
))
break
;
sample
=
_snapshot
->
get_sample
(
cur_pos
)
&
logic_di
->
logic_mask
;
last_sample
=
(
sample
&
(
1
<<
logic_di
->
edge_index
))
?
1
:
0
;
}
while
(
sample
!=
logic_di
->
exp_logic
);
}
i
=
cur_pos
;
if
(
i
>=
decode_end
)
i
=
decode_end
;
chunk_type
=
0
;
}
else
{
i
+=
chunk_sample_count
;
chunk_type
=
1
;
}
{
lock_guard
<
mutex
>
lock
(
_output_mutex
);
_samples_decoded
=
chunk_end
-
decode_start
+
1
;
_samples_decoded
=
i
-
decode_start
+
1
;
}
if
((
i
-
last_cnt
)
>
notify_cnt
)
{
last_cnt
=
i
;
new_decode_data
();
}
}
_options_changed
=
false
;
decode_done
();
...
...
This diff is collapsed.
Click to expand it.
DSView/pv/data/decoderstack.h
View file @
8a261384
...
...
@@ -20,8 +20,7 @@
#ifndef DSVIEW_PV_DATA_DECODERSTACK_H
#define DSVIEW_PV_DATA_DECODERSTACK_H
#include "signaldata.h"
#include <libsigrokdecode/libsigrokdecode.h>
#include <list>
...
...
@@ -32,14 +31,9 @@
#include <QObject>
#include <QString>
#include <pv/data/decode/row.h>
#include <pv/data/decode/rowdata.h>
struct
srd_decoder
;
struct
srd_decoder_annotation_row
;
struct
srd_channel
;
struct
srd_proto_data
;
struct
srd_session
;
#include <../data/decode/row.h>
#include <../data/decode/rowdata.h>
#include <../data/signaldata.h>
namespace
DecoderStackTest
{
class
TwoDecoderStack
;
...
...
This diff is collapsed.
Click to expand it.
DSView/pv/data/logicsnapshot.cpp
View file @
8a261384
...
...
@@ -23,6 +23,8 @@
#include <extdef.h>
#include <QDebug>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
...
...
@@ -208,25 +210,25 @@ void LogicSnapshot::get_subsampled_edges(
uint64_t
start
,
uint64_t
end
,
float
min_length
,
int
sig_index
)
{
uint64_t
index
=
start
;
bool
last_sample
;
if
(
!
edges
.
empty
())
edges
.
clear
()
;
assert
(
end
<=
get_sample_count
());
if
(
_sample_count
==
0
)
return
;
assert
(
end
<
_sample_count
);
assert
(
start
<=
end
);
assert
(
min_length
>
0
);
assert
(
sig_index
>=
0
);
assert
(
sig_index
<
64
);
if
(
_data
.
size
()
==
0
)
return
;
boost
::
lock_guard
<
boost
::
recursive_mutex
>
lock
(
_mutex
);
uint64_t
index
=
start
;
bool
last_sample
;
const
uint64_t
block_length
=
(
uint64_t
)
max
(
min_length
,
1.0
f
);
const
uint64_t
sig_mask
=
1ULL
<<
sig_index
;
if
(
!
edges
.
empty
())
edges
.
clear
();
// Store the initial state
last_sample
=
(
get_sample
(
start
)
&
sig_mask
)
!=
0
;
edges
.
push_back
(
pair
<
int64_t
,
bool
>
(
index
++
,
last_sample
));
...
...
This diff is collapsed.
Click to expand it.
DSView/pv/data/snapshot.cpp
View file @
8a261384
...
...
@@ -23,6 +23,8 @@
#include "snapshot.h"
#include <QDebug>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
...
...
This diff is collapsed.
Click to expand it.
DSView/pv/dock/dsotriggerdock.cpp
View file @
8a261384
...
...
@@ -155,10 +155,10 @@ DsoTriggerDock::~DsoTriggerDock()
void
DsoTriggerDock
::
paintEvent
(
QPaintEvent
*
)
{
QStyleOption
opt
;
opt
.
init
(
this
);
QPainter
p
(
this
);
style
()
->
drawPrimitive
(
QStyle
::
PE_Widget
,
&
opt
,
&
p
,
this
);
//
QStyleOption opt;
//
opt.init(this);
//
QPainter p(this);
//
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
void
DsoTriggerDock
::
pos_changed
(
int
pos
)
...
...
This diff is collapsed.
Click to expand it.
DSView/pv/dock/measuredock.cpp
View file @
8a261384
...
...
@@ -147,10 +147,10 @@ MeasureDock::~MeasureDock()
void
MeasureDock
::
paintEvent
(
QPaintEvent
*
)
{
QStyleOption
opt
;
opt
.
init
(
this
);
QPainter
p
(
this
);
style
()
->
drawPrimitive
(
QStyle
::
PE_Widget
,
&
opt
,
&
p
,
this
);
//
QStyleOption opt;
//
opt.init(this);
//
QPainter p(this);
//
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
void
MeasureDock
::
cursor_update
()
...
...
This diff is collapsed.
Click to expand it.
DSView/pv/dock/searchdock.cpp
View file @
8a261384
...
...
@@ -102,10 +102,10 @@ SearchDock::~SearchDock()
void
SearchDock
::
paintEvent
(
QPaintEvent
*
)
{
QStyleOption
opt
;
opt
.
init
(
this
);
QPainter
p
(
this
);
style
()
->
drawPrimitive
(
QStyle
::
PE_Widget
,
&
opt
,
&
p
,
this
);
//
QStyleOption opt;
//
opt.init(this);
//
QPainter p(this);
//
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
void
SearchDock
::
on_previous
()
...
...
This diff is collapsed.
Click to expand it.
DSView/pv/dock/triggerdock.cpp
View file @
8a261384
...
...
@@ -271,10 +271,10 @@ TriggerDock::~TriggerDock()
void
TriggerDock
::
paintEvent
(
QPaintEvent
*
)
{
QStyleOption
opt
;
opt
.
init
(
this
);
QPainter
p
(
this
);
style
()
->
drawPrimitive
(
QStyle
::
PE_Widget
,
&
opt
,
&
p
,
this
);
//
QStyleOption opt;
//
opt.init(this);
//
QPainter p(this);
//
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
void
TriggerDock
::
simple_trigger
()
...
...
This diff is collapsed.
Click to expand it.
DSView/pv/mainwindow.cpp
View file @
8a261384
...
...
@@ -112,7 +112,7 @@ void MainWindow::setup_ui()
{
setObjectName
(
QString
::
fromUtf8
(
"MainWindow"
));
setMinimumHeight
(
680
);
setMinimumWidth
(
5
00
);
setMinimumWidth
(
8
00
);
resize
(
1024
,
768
);
// Set the window icon
...
...
This diff is collapsed.
Click to expand it.
DSView/pv/view/decodetrace.cpp
View file @
8a261384
...
...
@@ -197,6 +197,41 @@ void DecodeTrace::paint_back(QPainter &p, int left, int right)
p
.
drawPolygon
(
start_points
,
countof
(
start_points
));
p
.
drawPolygon
(
end_points
,
countof
(
end_points
));
// --draw headings
const
int
row_height
=
_view
->
get_signalHeight
();
for
(
size_t
i
=
0
;
i
<
_cur_row_headings
.
size
();
i
++
)
{
const
int
y
=
i
*
row_height
+
get_y
()
-
_totalHeight
*
0.5
;
p
.
setPen
(
QPen
(
Qt
::
NoPen
));
p
.
setBrush
(
QApplication
::
palette
().
brush
(
QPalette
::
WindowText
));
const
QRect
r
(
left
+
ArrowSize
*
2
,
y
,
right
-
left
,
row_height
/
2
);
const
QString
h
(
_cur_row_headings
[
i
]);
const
int
f
=
Qt
::
AlignLeft
|
Qt
::
AlignVCenter
|
Qt
::
TextDontClip
;
const
QPointF
points
[]
=
{
QPointF
(
left
,
r
.
center
().
y
()
-
ArrowSize
),
QPointF
(
left
+
ArrowSize
,
r
.
center
().
y
()),
QPointF
(
left
,
r
.
center
().
y
()
+
ArrowSize
)
};
p
.
drawPolygon
(
points
,
countof
(
points
));
// Draw the outline
QFont
font
=
p
.
font
();
font
.
setPointSize
(
DefaultFontSize
);
p
.
setFont
(
font
);
// p.setPen(QApplication::palette().color(QPalette::Base));
// for (int dx = -1; dx <= 1; dx++)
// for (int dy = -1; dy <= 1; dy++)
// if (dx != 0 && dy != 0)
// p.drawText(r.translated(dx, dy), f, h);
// Draw the text
p
.
setPen
(
DARK_FORE
);
p
.
drawText
(
r
,
f
,
h
);
}
}
void
DecodeTrace
::
paint_mid
(
QPainter
&
p
,
int
left
,
int
right
)
...
...
@@ -300,45 +335,45 @@ void DecodeTrace::paint_fore(QPainter &p, int left, int right)
(
void
)
right
;
const
int
row_height
=
_view
->
get_signalHeight
();
for
(
size_t
i
=
0
;
i
<
_cur_row_headings
.
size
();
i
++
)
{
const
int
y
=
(
i
+
0.5
)
*
row_height
+
get_y
()
-
_totalHeight
*
0.5
;
p
.
setPen
(
QPen
(
Qt
::
NoPen
));
p
.
setBrush
(
QApplication
::
palette
().
brush
(
QPalette
::
WindowText
));
if
(
i
!=
0
)
{
const
QPointF
points
[]
=
{
QPointF
(
left
,
y
-
ArrowSize
),
QPointF
(
left
+
ArrowSize
,
y
),
QPointF
(
left
,
y
+
ArrowSize
)
};
p
.
drawPolygon
(
points
,
countof
(
points
));
}
const
QRect
r
(
left
+
ArrowSize
*
2
,
y
-
row_height
/
2
,
right
-
left
,
row_height
);
const
QString
h
(
_cur_row_headings
[
i
]);
const
int
f
=
Qt
::
AlignLeft
|
Qt
::
AlignBottom
|
Qt
::
TextDontClip
;
// Draw the outline
QFont
font
=
p
.
font
();
font
.
setPointSize
(
DefaultFontSize
);
p
.
setFont
(
font
);
p
.
setPen
(
QApplication
::
palette
().
color
(
QPalette
::
Base
));
for
(
int
dx
=
-
1
;
dx
<=
1
;
dx
++
)
for
(
int
dy
=
-
1
;
dy
<=
1
;
dy
++
)
if
(
dx
!=
0
&&
dy
!=
0
)
p
.
drawText
(
r
.
translated
(
dx
,
dy
),
f
,
h
);
// Draw the text
p
.
setPen
(
QApplication
::
palette
().
color
(
QPalette
::
WindowText
)
);
p
.
drawText
(
r
,
f
,
h
);
}
//
const int row_height = _view->get_signalHeight();
//
for (size_t i = 0; i < _cur_row_headings.size(); i++)
//
{
//
const int y = (i + 0.5) * row_height + get_y() - _totalHeight * 0.5;
//
p.setPen(QPen(Qt::NoPen));
//
p.setBrush(QApplication::palette().brush(QPalette::WindowText));
//
if (i != 0)
//
{
//
const QPointF points[] = {
//
QPointF(left, y - ArrowSize),
//
QPointF(left + ArrowSize, y),
//
QPointF(left, y + ArrowSize)
//
};
//
p.drawPolygon(points, countof(points));
//
}
//
const QRect r(left + ArrowSize * 2, y - row_height / 2,
//
right - left, row_height);
//
const QString h(_cur_row_headings[i]);
//
const int f = Qt::AlignLeft | Qt::AlignBottom |
//
Qt::TextDontClip;
//
// Draw the outline
//
QFont font=p.font();
//
font.setPointSize(DefaultFontSize);
//
p.setFont(font);
////
p.setPen(QApplication::palette().color(QPalette::Base));
////
for (int dx = -1; dx <= 1; dx++)
////
for (int dy = -1; dy <= 1; dy++)
////
if (dx != 0 && dy != 0)
////
p.drawText(r.translated(dx, dy), f, h);
//
// Draw the text
// p.setPen(DARK_FORE
);
//
p.drawText(r, f, h);
//
}
}
bool
DecodeTrace
::
create_popup
()
...
...
@@ -506,7 +541,7 @@ void DecodeTrace::draw_nodetail(QPainter &p,
size_t
base_colour
)
const
{
const
QRectF
nodetail_rect
(
left
,
y
-
h
/
2
+
0.5
,
right
-
left
,
h
);
QString
info
=
tr
(
"Zoom in For Detial"
);
QString
info
=
tr
(
"Zoom in For Detial
s
"
);
int
info_left
=
nodetail_rect
.
center
().
x
()
-
p
.
boundingRect
(
QRectF
(),
0
,
info
).
width
();
int
info_right
=
nodetail_rect
.
center
().
x
()
+
p
.
boundingRect
(
QRectF
(),
0
,
info
).
width
();
int
height
=
p
.
boundingRect
(
QRectF
(),
0
,
info
).
height
();
...
...
This diff is collapsed.
Click to expand it.
DSView/pv/view/header.cpp
View file @
8a261384
...
...
@@ -119,7 +119,7 @@ void Header::paintEvent(QPaintEvent*)
//painter.setRenderHint(QPainter::Antialiasing);
style
()
->
drawPrimitive
(
QStyle
::
PE_Widget
,
&
o
,
&
painter
,
this
);
painter
.
begin
(
this
);
//
painter.begin(this);
const
int
w
=
width
();
const
vector
<
boost
::
shared_ptr
<
Trace
>
>
traces
(
...
...
This diff is collapsed.
Click to expand it.
DSView/pv/view/logicsignal.cpp
View file @
8a261384
...
...
@@ -23,6 +23,8 @@
#include <extdef.h>
#include <QDebug>
#include <math.h>
#include "logicsignal.h"
...
...
This diff is collapsed.
Click to expand it.
DSView/pv/view/ruler.cpp
View file @
8a261384
...
...
@@ -182,7 +182,7 @@ void Ruler::paintEvent(QPaintEvent*)
QPainter
p
(
this
);
style
()
->
drawPrimitive
(
QStyle
::
PE_Widget
,
&
o
,
&
p
,
this
);
p
.
begin
(
this
);
//
p.begin(this);
//QPainter p(this);
//p.setRenderHint(QPainter::Antialiasing);
...
...
This diff is collapsed.
Click to expand it.
DSView/pv/view/viewport.cpp
View file @
8a261384
...
...
@@ -128,7 +128,7 @@ void Viewport::paintEvent(QPaintEvent *event)
QPainter
p
(
this
);
style
()
->
drawPrimitive
(
QStyle
::
PE_Widget
,
&
o
,
&
p
,
this
);
p
.
begin
(
this
);
//
p.begin(this);
const
vector
<
boost
::
shared_ptr
<
Trace
>
>
traces
(
_view
.
get_traces
(
_type
));
BOOST_FOREACH
(
const
boost
::
shared_ptr
<
Trace
>
t
,
traces
)
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment