Statistics
| Branch: | Tag: | Revision:

root / gnuradio-core / src / lib / general / gr_repeat.cc @ c4763fb9

History | View | Annotate | Download (1.7 kB)

1 c989df77 jcorgan
/* -*- c++ -*- */
2 c989df77 jcorgan
/*
3 c989df77 jcorgan
 * Copyright 2008 Free Software Foundation, Inc.
4 c989df77 jcorgan
 * 
5 c989df77 jcorgan
 * This file is part of GNU Radio
6 c989df77 jcorgan
 * 
7 c989df77 jcorgan
 * GNU Radio is free software; you can redistribute it and/or modify
8 c989df77 jcorgan
 * it under the terms of the GNU General Public License as published by
9 c989df77 jcorgan
 * the Free Software Foundation; either version 3, or (at your option)
10 c989df77 jcorgan
 * any later version.
11 c989df77 jcorgan
 * 
12 c989df77 jcorgan
 * GNU Radio is distributed in the hope that it will be useful,
13 c989df77 jcorgan
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 c989df77 jcorgan
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 c989df77 jcorgan
 * GNU General Public License for more details.
16 c989df77 jcorgan
 * 
17 c989df77 jcorgan
 * You should have received a copy of the GNU General Public License
18 c989df77 jcorgan
 * along with GNU Radio; see the file COPYING.  If not, write to
19 c989df77 jcorgan
 * the Free Software Foundation, Inc., 51 Franklin Street,
20 c989df77 jcorgan
 * Boston, MA 02110-1301, USA.
21 c989df77 jcorgan
 */
22 c989df77 jcorgan
23 c989df77 jcorgan
#ifdef HAVE_CONFIG_H
24 c989df77 jcorgan
#include "config.h"
25 c989df77 jcorgan
#endif
26 c989df77 jcorgan
27 c989df77 jcorgan
#include <gr_repeat.h>
28 c989df77 jcorgan
#include <gr_io_signature.h>
29 38ea3a57 eb
#include <string.h>
30 c989df77 jcorgan
31 c989df77 jcorgan
gr_repeat_sptr 
32 c989df77 jcorgan
gr_make_repeat(size_t itemsize, int interp)
33 c989df77 jcorgan
{
34 c989df77 jcorgan
  return gr_repeat_sptr(new gr_repeat(itemsize, interp));
35 c989df77 jcorgan
}
36 c989df77 jcorgan
37 c989df77 jcorgan
gr_repeat::gr_repeat(size_t itemsize, int interp)  
38 c989df77 jcorgan
  : gr_sync_interpolator("extend",
39 c989df77 jcorgan
                         gr_make_io_signature(1, 1, itemsize),
40 c989df77 jcorgan
                         gr_make_io_signature(1, 1, itemsize),
41 c989df77 jcorgan
                         interp),
42 c989df77 jcorgan
    d_interp(interp),
43 c989df77 jcorgan
    d_itemsize(itemsize)
44 c989df77 jcorgan
{
45 c989df77 jcorgan
}
46 c989df77 jcorgan
47 c989df77 jcorgan
gr_repeat::~gr_repeat()
48 c989df77 jcorgan
{
49 c989df77 jcorgan
}
50 c989df77 jcorgan
51 c989df77 jcorgan
int 
52 c989df77 jcorgan
gr_repeat::work(int noutput_items,
53 c989df77 jcorgan
                  gr_vector_const_void_star &input_items,
54 c989df77 jcorgan
                  gr_vector_void_star &output_items)
55 c989df77 jcorgan
{
56 c989df77 jcorgan
  const char *in = (const char *) input_items[0];
57 c989df77 jcorgan
  char *out = (char *)output_items[0];
58 c989df77 jcorgan
59 c989df77 jcorgan
  for (int i = 0; i < noutput_items/d_interp; i++) {
60 c989df77 jcorgan
    for (int j = 0; j < d_interp; j++) {
61 c989df77 jcorgan
      memcpy(out, in, d_itemsize);
62 c989df77 jcorgan
      out += d_itemsize;
63 c989df77 jcorgan
    }
64 c989df77 jcorgan
65 b655e7dc eb
    in += d_itemsize;
66 c989df77 jcorgan
  }
67 c989df77 jcorgan
68 c989df77 jcorgan
  return noutput_items;
69 c989df77 jcorgan
}