Imported Upstream version 3.2.2
[debian/gnuradio] / gnuradio-core / src / lib / general / gr_encode_ccsds_27_bb.cc
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2004,2008 Free Software Foundation, Inc.
4  * 
5  * GNU Radio is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3, or (at your option)
8  * any later version.
9  * 
10  * GNU Radio is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  * 
15  * You should have received a copy of the GNU General Public License
16  * along with GNU Radio; see the file COPYING.  If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street,
18  * Boston, MA 02110-1301, USA.
19  */
20
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24
25 #include <gr_encode_ccsds_27_bb.h>
26 #include <gr_io_signature.h>
27
28 extern "C" {
29 #include <../viterbi/viterbi.h>
30 }
31
32 gr_encode_ccsds_27_bb_sptr 
33 gr_make_encode_ccsds_27_bb()
34 {
35   return gr_encode_ccsds_27_bb_sptr(new gr_encode_ccsds_27_bb());
36 }
37
38 gr_encode_ccsds_27_bb::gr_encode_ccsds_27_bb()
39   : gr_sync_interpolator("encode_ccsds_27_bb",
40                          gr_make_io_signature(1, 1, sizeof(char)),
41                          gr_make_io_signature(1, 1, sizeof(char)),
42                          16)  // Rate 1/2 code, packed to unpacked conversion
43 {
44   d_encstate = 0;
45 }
46
47 gr_encode_ccsds_27_bb::~gr_encode_ccsds_27_bb()
48 {
49 }
50
51 int 
52 gr_encode_ccsds_27_bb::work(int noutput_items,
53                             gr_vector_const_void_star &input_items,
54                             gr_vector_void_star &output_items)
55 {
56   unsigned char *in = (unsigned char *)input_items[0];
57   unsigned char *out = (unsigned char *)output_items[0];
58
59   d_encstate = encode(out, in, noutput_items/16, d_encstate);
60
61   return noutput_items;
62 }