summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorn4hy2006-12-14 05:20:15 +0000
committern4hy2006-12-14 05:20:15 +0000
commit0bcd3eef3ddd18fd190a459923920a59287b7485 (patch)
tree7b23c1cf39fdddf9c4af1171bd36aad63dcf6147
parent732324bb5569286f035eec8ad0d6923b3ad843ce (diff)
downloadgnuradio-0bcd3eef3ddd18fd190a459923920a59287b7485.tar.gz
gnuradio-0bcd3eef3ddd18fd190a459923920a59287b7485.tar.bz2
gnuradio-0bcd3eef3ddd18fd190a459923920a59287b7485.zip
Two loop gr_costas_loop removing one if statement per sample
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@4080 221aa14e-8319-0410-a670-987f0aec2ac5
-rw-r--r--gnuradio-core/src/lib/general/gr_costas_loop_cc.cc77
1 files changed, 51 insertions, 26 deletions
diff --git a/gnuradio-core/src/lib/general/gr_costas_loop_cc.cc b/gnuradio-core/src/lib/general/gr_costas_loop_cc.cc
index f06be47eb..61d58ebe5 100644
--- a/gnuradio-core/src/lib/general/gr_costas_loop_cc.cc
+++ b/gnuradio-core/src/lib/general/gr_costas_loop_cc.cc
@@ -98,33 +98,58 @@ gr_costas_loop_cc::work (int noutput_items,
float error;
gr_complex nco_out;
-
- for (int i = 0; i < noutput_items; i++){
- nco_out = gr_expj(-d_phase);
- optr[i] = iptr[i] * nco_out;
-
- error = (*this.*d_phase_detector)(optr[i]);
- if (error > 1)
- error = 1;
- else if (error < -1)
- error = -1;
-
- d_freq = d_freq + d_beta * error;
- d_phase = d_phase + d_freq + d_alpha * error;
-
- while(d_phase>M_TWOPI)
- d_phase -= M_TWOPI;
- while(d_phase<-M_TWOPI)
- d_phase += M_TWOPI;
-
- if (d_freq > d_max_freq)
- d_freq = d_max_freq;
- else if (d_freq < d_min_freq)
- d_freq = d_min_freq;
-
- if (write_foptr){
+
+ if (write_foptr) {
+
+ for (int i = 0; i < noutput_items; i++){
+ nco_out = gr_expj(-d_phase);
+ optr[i] = iptr[i] * nco_out;
+
+ error = (*this.*d_phase_detector)(optr[i]);
+ if (error > 1)
+ error = 1;
+ else if (error < -1)
+ error = -1;
+
+ d_freq = d_freq + d_beta * error;
+ d_phase = d_phase + d_freq + d_alpha * error;
+
+ while(d_phase>M_TWOPI)
+ d_phase -= M_TWOPI;
+ while(d_phase<-M_TWOPI)
+ d_phase += M_TWOPI;
+
+ if (d_freq > d_max_freq)
+ d_freq = d_max_freq;
+ else if (d_freq < d_min_freq)
+ d_freq = d_min_freq;
+
foptr[i] = gr_complex(d_freq,0);
- //foptr[i] = gr_complex(error, 0);
+ }
+ } else {
+ for (int i = 0; i < noutput_items; i++){
+ nco_out = gr_expj(-d_phase);
+ optr[i] = iptr[i] * nco_out;
+
+ error = (*this.*d_phase_detector)(optr[i]);
+ if (error > 1)
+ error = 1;
+ else if (error < -1)
+ error = -1;
+
+ d_freq = d_freq + d_beta * error;
+ d_phase = d_phase + d_freq + d_alpha * error;
+
+ while(d_phase>M_TWOPI)
+ d_phase -= M_TWOPI;
+ while(d_phase<-M_TWOPI)
+ d_phase += M_TWOPI;
+
+ if (d_freq > d_max_freq)
+ d_freq = d_max_freq;
+ else if (d_freq < d_min_freq)
+ d_freq = d_min_freq;
+
}
}
return noutput_items;