[boinc-app-seti] 02/04: Imported Upstream version 8.00~svn3363

Gianfranco Costamagna locutusofborg-guest at moszumanska.debian.org
Mon Feb 1 14:18:12 UTC 2016


This is an automated email from the git hooks/post-receive script.

locutusofborg-guest pushed a commit to branch master
in repository boinc-app-seti.

commit 706cf00a2068b14f3130d44fd4c9aadf7eaa287b
Author: Gianfranco Costamagna <costamagnagianfranco at yahoo.it>
Date:   Mon Feb 1 15:15:59 2016 +0100

    Imported Upstream version 8.00~svn3363
---
 db/schema_master.cpp            | 34 +++++++++++++++---
 db/schema_master.h              |  1 +
 db/schema_master.sql            |  3 +-
 db/xml_util.h                   | 12 ++++---
 splitter_pfb/mb_dotransform.cpp | 76 ++++++++++++++++++++++++++++++++++-------
 splitter_pfb/mb_dotransform.h   |  3 +-
 splitter_pfb/mb_wufiles.cpp     |  2 +-
 7 files changed, 106 insertions(+), 25 deletions(-)

diff --git a/db/schema_master.cpp b/db/schema_master.cpp
index ac66d8c..3279e4a 100644
--- a/db/schema_master.cpp
+++ b/db/schema_master.cpp
@@ -788,8 +788,8 @@ std::string data_description_t::print_xml(int full_subtables, int show_ids, int
 
 template <> const char * const db_table<receiver_config>::table_name="receiver_config";
 template <> const char * db_table<receiver_config>::_search_tag=table_name;
-template <> const int db_table<receiver_config>::_nfields=16;
-template <> const char * const db_table<receiver_config>::column_names[16]={"id","s4_id","name","beam_width","center_freq","latitude","longitude","elevation","diameter","az_orientation","az_corr_coeff","zen_corr_coeff","array_az_ellipse","array_za_ellipse","array_angle","min_vgc"};
+template <> const int db_table<receiver_config>::_nfields=17;
+template <> const char * const db_table<receiver_config>::column_names[17]={"id","s4_id","name","beam_width","center_freq","latitude","longitude","elevation","diameter","az_orientation","az_corr_coeff","zen_corr_coeff","array_az_ellipse","array_za_ellipse","array_angle","min_vgc""polarization"};
 
 receiver_config::receiver_config() : 
 	db_table<receiver_config>(*this,-1),
@@ -811,6 +811,7 @@ receiver_config::receiver_config() :
 {
 	db_open();
 	name[0]=0;
+	polarization[0]=0;
 }
 
 
@@ -834,6 +835,7 @@ receiver_config::receiver_config(const receiver_config &a) :
 {
 	db_open();
 	strcpy(name,a.name);
+	strcpy(polarization,a.polarization);
 }
 
 
@@ -887,6 +889,7 @@ receiver_config &receiver_config::operator =(const receiver_config &a) {
 		array_angle=a.array_angle;
 		min_vgc=a.min_vgc;
 	strcpy(name,a.name);
+	strcpy(polarization,a.polarization);
 	}
 	return (*this);
 }
@@ -895,7 +898,7 @@ receiver_config &receiver_config::operator =(const receiver_config &a) {
 std::string receiver_config::update_format() const
 {	std::ostringstream rv("");
 
-	for (int i=2;i<16;i++) rv << "?,";
+	for (int i=2;i<17;i++) rv << "?,";
 	rv << "?";
 	return rv.str();
 }
@@ -908,7 +911,7 @@ std::string receiver_config::insert_format() const
 std::string receiver_config::select_format() const
 {
 std::string rv("");
-for (int i=0; i<15;i++) rv+="?,";
+for (int i=0; i<16;i++) rv+="?,";
 rv+="?";
 return rv;
 }
@@ -970,6 +973,8 @@ std::string receiver_config::print(int full_subtables, int show_ids, int no_refs
 	rv << array_angle;
 	rv << ',';
 	rv << min_vgc;
+	rv << ',';
+	rv << "'" << polarization << "'";
 	return rv.str();
 }
 
@@ -1017,6 +1022,11 @@ std::string receiver_config::print_xml(int full_subtables, int show_ids, int no_
 	rv << xml_indent() << "<array_za_ellipse>" << array_za_ellipse << "</array_za_ellipse>\n";
 	rv << xml_indent() << "<array_angle>" << array_angle << "</array_angle>\n";
 	rv << xml_indent() << "<min_vgc>" << min_vgc << "</min_vgc>\n";
+	{
+	  std::string enc_field=xml_encode_string(polarization,std::min(strlen(polarization),sizeof(polarization)));
+	  rv << xml_indent() << "<polarization>";
+	  rv << enc_field << "</polarization>\n";
+	}
 	xml_indent(-2);
 	rv << xml_indent() << "</" << tag << ">\n";
 	return rv.str();
@@ -1141,6 +1151,16 @@ std::string receiver_config::print_xml(int full_subtables, int show_ids, int no_
 	        std::istringstream in(sub.c_str()+pos);
 	        in >> min_vgc;
 	      }
+	    if (extract_xml_record(field,"polarization",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::string::size_type epos=sub.find("<",pos);
+	        if (epos==std::string::npos) epos=sub.find('\n',pos);
+	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
+	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
+	        strncpy(polarization,(const char *)&(in.front()),std::min(in.size(),(size_t)32));
+	        polarization[std::min(in.size(),(size_t)31)]=0;
+	      }
 	      }
 	      }
 
@@ -1225,10 +1245,14 @@ std::string receiver_config::print_xml(int full_subtables, int show_ids, int no_
 	        std::istringstream row(*(s[15]));
 	        row >> min_vgc;
 	    }
+	  {  
+	        strncpy(polarization,s[16]->c_str(),32);
+	        polarization[31]=0;
+	    }
 	      }
 
 	void receiver_config::parse(const std::string &s) {
-	      SQL_ROW row(&s,16);
+	      SQL_ROW row(&s,17);
 	      parse(row);
 	      }
 
diff --git a/db/schema_master.h b/db/schema_master.h
index 252d4f2..34330c5 100644
--- a/db/schema_master.h
+++ b/db/schema_master.h
@@ -158,6 +158,7 @@ class  receiver_config  : public db_table<receiver_config> {
 	double  array_za_ellipse;
 	double  array_angle;
 	long  min_vgc;
+	char  polarization[32];
 	receiver_config();
 	receiver_config(const receiver_config &a);
 	receiver_config(const SQL_ROW &a);
diff --git a/db/schema_master.sql b/db/schema_master.sql
index 799ab92..6c54358 100644
--- a/db/schema_master.sql
+++ b/db/schema_master.sql
@@ -87,7 +87,8 @@ create table receiver_config
     array_az_ellipse float default 0 not null,
     array_za_ellipse float default 0 not null,
     array_angle float default 0 not null,
-    min_vgc integer default 0
+    min_vgc integer default 0,
+    polarization char(32)
   );
 
 
diff --git a/db/xml_util.h b/db/xml_util.h
index 7da2e94..44ce6de 100644
--- a/db/xml_util.h
+++ b/db/xml_util.h
@@ -882,13 +882,17 @@ std::vector<T> xml_decode_field(const std::string &input, const char *tag) {
   start_tag+=' ';
   end_tag+=tag;
   std::string::size_type start,endt,enc,len;
-  if (((start=input.find(start_tag))==std::string::npos) ||
-      ((endt=input.find(end_tag,start))==std::string::npos) ||
-      ((enc=input.find("encoding=\"",start))==std::string::npos)) {
+  if ((start=input.find(start_tag))==std::string::npos) {
+    throw ERR_XML_PARSE;
+  }
+  if ((endt=input.find(end_tag,start))==std::string::npos) { 
+    throw ERR_XML_PARSE;
+  }
+  if ((enc=input.find("encoding=\"",start))==std::string::npos) {
     throw ERR_XML_PARSE;
   }
   unsigned int length=0;
-  if ((len=input.find("length=",start)!=std::string::npos))
+  if ((len=input.find("length=",start))!=std::string::npos)
     length=atoi(&(input.c_str()[len+strlen("length=")]));
   const char *encoding=input.c_str()+enc+strlen("encoding=\"");
   start=input.find('>',start)+1;
diff --git a/splitter_pfb/mb_dotransform.cpp b/splitter_pfb/mb_dotransform.cpp
index 753f7dc..8a2f8bd 100644
--- a/splitter_pfb/mb_dotransform.cpp
+++ b/splitter_pfb/mb_dotransform.cpp
@@ -70,21 +70,73 @@ void gen_coeff(float * coeff, int num_coeff) {
   }
 }
 
-void output_samples(float *data, int i) {
+inline int quantize(float f,float stddev,int num_bits) {
+  switch (num_bits) {
+    case 1: 
+        return (f>0);
+    case 2:
+        if (f<-0.98159883*stddev) return 0;
+        if (f<0) return 1;
+        if (f<0.98159883*stddev) return 2;
+        return 3;
+#if 0
+// this won't work for encoding into an unsigned short.
+    case 3:
+        f*=(sqrt(2)/stddev);
+        f+=3.5;
+        if (f>7) return 7;
+        if (f<0) return 0;
+        return static_cast<int>(round(f));
+#endif
+    case 4:
+        f*=(2.0/stddev);
+        f+=7.5;
+        if (f>15) return 15;
+        if (f<0) return 0;
+        return static_cast<int>(round(f));
+    case 8:
+        f*=(64.0/stddev);
+        if (f>127) return 127;
+        if (f<-127) return -127;
+        return static_cast<int>(round(f));
+    default:
+        fprintf(stderr,"Unsupported bit depth (%d)\n",num_bits);
+        abort();
+  }
+}
+
+void output_samples(float *data, int i, int bits_per_sample) {
 // outputs 8 complex samples per call (8 cplx floats -> 8 cplx chars, or 16 floats -> 16 chars)
   int j,k;
-  unsigned short s=0;
+  unsigned short s;
   float *p=data;
-
-  for (k=0; k<8; k++) {
-      s >>= 2;
-      if (*p>0) s |= 0x8000;
-      if (*(p+1)>0) s |= 0x4000;
-      p+=2;
+  static float stddev[2]={1,1};  // use reasonable guesses to prevent really bad early values
+  static long n=8;
+
+  // this is our gain control.
+  // maintain a running stddev for the last 256K points from all subbands
+  n=std::min(n,256L*1024-8);
+  stddev[0]*=stddev[0]*n;
+  stddev[1]*=stddev[1]*n;
+  for (j=0;j<8;j++) {
+     stddev[0]+=(data[j*2]*data[j*2]);
+     stddev[1]+=(data[j*2+1]*data[j*2+1]);
   }
-  // bin_data is defined in mb_wufiles.cpp as a vector<unsigned char>
-  bin_data[i].push_back((s>>8) & 0xff);
-  bin_data[i].push_back(s & 0xff);
+  n+=8;
+  stddev[0]=sqrt(stddev[0]/n);
+  stddev[1]=sqrt(stddev[1]/n);
+
+  for (j=0; j<(8*bits_per_sample/(CHAR_BIT*sizeof(unsigned short))); j++) {
+      s=0;
+      for (k=0; k<CHAR_BIT*sizeof(unsigned short)/bits_per_sample; k++) {
+          s >>= bits_per_sample;
+          s |= (quantize(*p,stddev[0],bits_per_sample/2) << (CHAR_BIT*sizeof(unsigned short)-bits_per_sample/2));
+          s |= (quantize(*(p+1),stddev[1],bits_per_sample/2) << (CHAR_BIT*sizeof(unsigned short)-bits_per_sample));
+          p+=2;
+      }
+      bin_data[i].push_back((s>>8) & 0xff);
+      bin_data[i].push_back(s & 0xff);
+   }
 }
 
 void splitter_bits_to_float(unsigned short *raw, float *data, int nsamples) {
@@ -270,7 +322,7 @@ void process_seg() {
             
 
             for (i=0; i<NSTRIPS; i++) {                 // NSTRIPS = 256 WUs in 1 WUG
-                output_samples(fbuff, i);               // output_samples() outputs 8 complex samples per call
+                output_samples(fbuff, i, splitter_settings.splitter_cfg->wu_bits_per_sample);               // output_samples() outputs 8 complex samples per call
                 fbuff += PFB_OUTPUT_STACK_SIZE*2;       // ..so, we move fbuff ahead by PFB_OUTPUT_STACK_SIZE (8) complex (via *2) floats
             }
 
diff --git a/splitter_pfb/mb_dotransform.h b/splitter_pfb/mb_dotransform.h
index a531c89..ac17ee0 100644
--- a/splitter_pfb/mb_dotransform.h
+++ b/splitter_pfb/mb_dotransform.h
@@ -27,8 +27,7 @@
 
 //extern int obuf_pos; /* Tracks current postition in the output buffers */
 
-
-void output_samples(float *data, int i, int buf_pos);
+void output_samples(float *data, int i, int bits_per_sample=2);
 void splitter_bits_to_float(unsigned short *raw, float *data, int nsamples) ;
 void process_seg(void);
 void do_transform(std::vector<dr2_compact_block_t> &tapebuffer) ;
diff --git a/splitter_pfb/mb_wufiles.cpp b/splitter_pfb/mb_wufiles.cpp
index 816aa05..4d031d7 100644
--- a/splitter_pfb/mb_wufiles.cpp
+++ b/splitter_pfb/mb_wufiles.cpp
@@ -143,7 +143,7 @@ int make_wu_headers(std::vector<dr2_compact_block_t> &tapebuffer,
   double numtrip=std::min(3.25215e+12/std::min(wugrp.data_desc.true_angle_range,10.0),1.44774e+13);
 
   // check for VLAR workunits
-  if (wugrp.data_desc.true_angle_range < 0.12) {
+  if (wugrp.data_desc.true_angle_range < 1.2*wugrp.receiver_cfg->beam_width) {
     group_is_vlar=true;
   } else {
     group_is_vlar=false;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-boinc/boinc-app-seti.git



More information about the pkg-boinc-commits mailing list