Changeset 8329

Show
Ignore:
Timestamp:
05/08/08 19:44:41
Author:
jcorgan
Message:

Applied relevant portion of changeset r8244 on trunk to release branch. Refactors FFT blocks, no user visible changes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gnuradio/branches/releases/3.1/gnuradio-core/src/lib/general/Makefile.am

    r8267 r8329  
    7171        gr_feval.cc                     \ 
    7272        gr_fft_vcc.cc                   \ 
     73        gr_fft_vcc_fftw.cc              \ 
    7374        gr_fft_vfc.cc                   \ 
    7475        gr_firdes.cc                    \ 
     
    202203        gr_feval.h                      \ 
    203204        gr_fft_vcc.h                    \ 
     205        gr_fft_vcc_fftw.h               \ 
    204206        gr_fft_vfc.h                    \ 
    205207        gr_firdes.h                     \ 
  • gnuradio/branches/releases/3.1/gnuradio-core/src/lib/general/gr_fft_vcc.cc

    r6044 r8329  
    11/* -*- c++ -*- */ 
    22/* 
    3  * Copyright 2004,2007 Free Software Foundation, Inc. 
     3 * Copyright 2004,2007,2008 Free Software Foundation, Inc. 
    44 *  
    55 * This file is part of GNU Radio 
     
    2525#endif 
    2626 
    27 #include <gr_fft_vcc.h> 
     27#include <gr_fft_vcc.h>         // abstract class 
     28#include <gr_fft_vcc_fftw.h>    // concrete class 
    2829#include <gr_io_signature.h> 
    2930#include <gri_fft.h> 
     
    3132 
    3233gr_fft_vcc_sptr 
    33 gr_make_fft_vcc (int fft_size, bool forward,const std::vector<float> window, bool shift) 
     34gr_make_fft_vcc (int fft_size, bool forward,const std::vector<float> &window, bool shift) 
    3435{ 
    35   return gr_fft_vcc_sptr (new gr_fft_vcc (fft_size, forward, window, shift)); 
     36  return gr_make_fft_vcc_fftw(fft_size, forward, window, shift); 
    3637} 
    3738 
    38 gr_fft_vcc::gr_fft_vcc (int fft_size, bool forward, const std::vector<float> window, bool shift) 
    39   : gr_sync_block ("fft_vcc", 
     39gr_fft_vcc::gr_fft_vcc (const std::string &name, 
     40                        int fft_size, bool forward, const std::vector<float> &window, 
     41                        bool shift) 
     42  : gr_sync_block (name, 
    4043                   gr_make_io_signature (1, 1, fft_size * sizeof (gr_complex)), 
    4144                   gr_make_io_signature (1, 1, fft_size * sizeof (gr_complex))), 
    4245    d_fft_size(fft_size), d_forward(forward), d_shift(shift) 
    4346{ 
    44   d_fft = new gri_fft_complex (d_fft_size, forward); 
    45  
    4647  set_window(window); 
    47  
    4848} 
    4949 
    5050gr_fft_vcc::~gr_fft_vcc () 
    5151{ 
    52   delete d_fft; 
    53 } 
    54  
    55 int 
    56 gr_fft_vcc::work (int noutput_items, 
    57                   gr_vector_const_void_star &input_items, 
    58                   gr_vector_void_star &output_items) 
    59 { 
    60   const gr_complex *in = (const gr_complex *) input_items[0]; 
    61   gr_complex *out = (gr_complex *) output_items[0]; 
    62  
    63   unsigned int input_data_size = input_signature()->sizeof_stream_item (0); 
    64   unsigned int output_data_size = output_signature()->sizeof_stream_item (0); 
    65  
    66   int count = 0; 
    67  
    68   while (count++ < noutput_items){ 
    69      
    70     // copy input into optimally aligned buffer 
    71      
    72     if (d_window.size()){ 
    73       gr_complex *dst = d_fft->get_inbuf(); 
    74       for (unsigned int i = 0; i < d_fft_size; i++)             // apply window 
    75         dst[i] = in[i] * d_window[i]; 
    76     } 
    77     else { 
    78       if(!d_forward && d_shift) {  // apply an ifft shift on the data 
    79         gr_complex *dst = d_fft->get_inbuf(); 
    80         unsigned int len = (unsigned int)(floor(d_fft_size/2.0)); // half length of complex array 
    81         memcpy(&dst[0], &in[len], sizeof(gr_complex)*(d_fft_size - len)); 
    82         memcpy(&dst[d_fft_size - len], &in[0], sizeof(gr_complex)*len); 
    83       } 
    84       else { 
    85         memcpy (d_fft->get_inbuf(), in, input_data_size); 
    86       } 
    87     } 
    88      
    89     // compute the fft 
    90     d_fft->execute (); 
    91      
    92     // copy result to our output 
    93     if(d_forward && d_shift) {  // apply a fft shift on the data 
    94       unsigned int len = (unsigned int)(ceil(d_fft_size/2.0)); 
    95       memcpy(&out[0], &d_fft->get_outbuf()[len], sizeof(gr_complex)*(d_fft_size - len)); 
    96       memcpy(&out[d_fft_size - len], &d_fft->get_outbuf()[0], sizeof(gr_complex)*len); 
    97     } 
    98     else { 
    99       memcpy (out, d_fft->get_outbuf (), output_data_size); 
    100     } 
    101      
    102     in  += d_fft_size; 
    103     out += d_fft_size; 
    104   } 
    105    
    106   return noutput_items; 
    10752} 
    10853 
    10954bool  
    110 gr_fft_vcc::set_window(const std::vector<float> window) 
     55gr_fft_vcc::set_window(const std::vector<float> &window) 
    11156{ 
    11257  if(window.size()==0 || window.size()==d_fft_size) { 
     
    11762    return false; 
    11863} 
    119  
    120 /* 
    121 fftshift 
    122  
    123   for(i=0; i < ceil(d_occupied_carriers/2.0); i++) { 
    124     unsigned int k=ceil(d_occupied_carriers/2.0); 
    125     out[i] = gr_complex(-1+2*in[i+k],0); 
    126   } 
    127   for(; i < d_vlen - ceil(d_occupied_carriers/2.0); i++) { 
    128     out[i]=gr_complex(0,0); 
    129   } 
    130   for(unsigned int j=0;i<d_vlen;i++,j++) { 
    131     out[i]= gr_complex((-1+2*in[j]),0); 
    132   } 
    133 */ 
  • gnuradio/branches/releases/3.1/gnuradio-core/src/lib/general/gr_fft_vcc.h

    r7517 r8329  
    11/* -*- c++ -*- */ 
    22/* 
    3  * Copyright 2004,2007 Free Software Foundation, Inc. 
     3 * Copyright 2004,2007,2008 Free Software Foundation, Inc. 
    44 *  
    55 * This file is part of GNU Radio 
     
    2626#include <gr_sync_block.h> 
    2727 
    28 class gri_fft_complex; 
    29  
    3028class gr_fft_vcc; 
    3129typedef boost::shared_ptr<gr_fft_vcc> gr_fft_vcc_sptr; 
    3230 
    3331gr_fft_vcc_sptr 
    34 gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> window, bool shift=false); 
     32gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> &window, bool shift=false); 
    3533 
    3634/*! 
    3735 * \brief Compute forward or reverse FFT.  complex vector in / complex vector out. 
    3836 * \ingroup dft 
     37 * 
     38 * Abstract base class 
    3939 */ 
    40  
    4140class gr_fft_vcc : public gr_sync_block 
    4241{ 
     42protected: 
    4343  friend gr_fft_vcc_sptr 
    44   gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> window, bool shift); 
     44  gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> &window, bool shift); 
    4545 
    46   unsigned int     d_fft_size; 
     46  unsigned int         d_fft_size; 
    4747  std::vector<float>   d_window; 
    48   gri_fft_complex *d_fft; 
    4948  bool d_forward; 
    5049  bool d_shift; 
    5150 
    52   gr_fft_vcc (int fft_size, bool forward, const std::vector<float> window, bool shift); 
     51  gr_fft_vcc (const std::string &name, int fft_size, bool forward, 
     52              const std::vector<float> &window, bool shift); 
    5353 
    5454 public: 
    5555  ~gr_fft_vcc (); 
    5656 
    57   int work (int noutput_items, 
    58             gr_vector_const_void_star &input_items, 
    59             gr_vector_void_star &output_items); 
    60   bool set_window(const std::vector<float> window); 
     57  bool set_window(const std::vector<float> &window); 
    6158}; 
    6259 
    63  
    6460#endif /* INCLUDED_GR_FFT_VCC_H */ 
  • gnuradio/branches/releases/3.1/gnuradio-core/src/lib/general/gr_fft_vcc.i

    r6044 r8329  
    11/* -*- c++ -*- */ 
    22/* 
    3  * Copyright 2004,2007 Free Software Foundation, Inc. 
     3 * Copyright 2004,2007,2008 Free Software Foundation, Inc. 
    44 *  
    55 * This file is part of GNU Radio 
     
    2929{ 
    3030 protected: 
    31   gr_fft_vcc (int fft_size, bool forward, const std::vector<float> window, bool shift); 
     31  gr_fft_vcc (int fft_size, bool forward, const std::vector<float> &window, bool shift); 
    3232 
    3333 public: 
    34   bool set_window(const std::vector<float> window); 
     34  bool set_window(const std::vector<float> &window); 
    3535}; 
  • gnuradio/branches/releases/3.1/gnuradio-core/src/lib/general/gr_math.h

    r7654 r8329  
    2929 
    3030#include <gr_complex.h> 
     31 
     32static inline bool 
     33gr_is_power_of_2(long x) 
     34{ 
     35  return x != 0 && (x & (x-1)) == 0; 
     36} 
    3137 
    3238long gr_gcd (long m, long n); 
  • gnuradio/branches/releases/3.1/gnuradio-core/src/python/gnuradio/gr/Makefile.am

    r7808 r8329  
    6262        qa_diff_phasor_cc.py            \ 
    6363        qa_feval.py                     \ 
     64        qa_fft.py                       \ 
    6465        qa_fft_filter.py                \ 
    6566        qa_filter_delay_fc.py           \