~ubuntu-branches/ubuntu/trusty/gnuradio/trusty

« back to all changes in this revision

Viewing changes to .pc/update-codec2/gr-vocoder/lib/codec2_encode_sp_impl.cc

  • Committer: Package Import Robot
  • Author(s): A. Maitland Bottoms
  • Date: 2014-01-05 12:14:43 UTC
  • mfrom: (2.1.23 sid)
  • Revision ID: package-import@ubuntu.com-20140105121443-je18dkof6uhox808
Tags: 3.7.2.1-5
use correct compiler for unstable build

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- c++ -*- */
2
 
/*
3
 
 * Copyright 2005,2011 Free Software Foundation, Inc.
4
 
 *
5
 
 * This file is part of GNU Radio
6
 
 *
7
 
 * GNU Radio is free software; you can redistribute it and/or modify
8
 
 * it under the terms of the GNU General Public License as published by
9
 
 * the Free Software Foundation; either version 3, or (at your option)
10
 
 * any later version.
11
 
 *
12
 
 * GNU Radio is distributed in the hope that it will be useful,
13
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
 * GNU General Public License for more details.
16
 
 *
17
 
 * You should have received a copy of the GNU General Public License
18
 
 * along with GNU Radio; see the file COPYING.  If not, write to
19
 
 * the Free Software Foundation, Inc., 51 Franklin Street,
20
 
 * Boston, MA 02110-1301, USA.
21
 
 */
22
 
 
23
 
#ifdef HAVE_CONFIG_H
24
 
#include "config.h"
25
 
#endif
26
 
 
27
 
#include "codec2_encode_sp_impl.h"
28
 
 
29
 
extern "C" {
30
 
#include "codec2/codec2.h"
31
 
}
32
 
 
33
 
#include <gnuradio/io_signature.h>
34
 
#include <stdexcept>
35
 
 
36
 
namespace gr {
37
 
  namespace vocoder {
38
 
 
39
 
    codec2_encode_sp::sptr
40
 
    codec2_encode_sp::make()
41
 
    {
42
 
      return gnuradio::get_initial_sptr
43
 
        (new codec2_encode_sp_impl());
44
 
    }
45
 
 
46
 
    codec2_encode_sp_impl::codec2_encode_sp_impl()
47
 
      : sync_decimator("vocoder_codec2_encode_sp",
48
 
                          io_signature::make(1, 1, sizeof(short)),
49
 
                          io_signature::make(1, 1, CODEC2_BITS_PER_FRAME * sizeof(char)),
50
 
                          CODEC2_SAMPLES_PER_FRAME)
51
 
    {
52
 
      if((d_codec2 = codec2_create()) == 0)
53
 
        throw std::runtime_error("codec2_encode_sp_impl: codec2_create failed");
54
 
    }
55
 
 
56
 
    codec2_encode_sp_impl::~codec2_encode_sp_impl()
57
 
    {
58
 
      codec2_destroy(d_codec2);
59
 
    }
60
 
 
61
 
    int
62
 
    codec2_encode_sp_impl::work(int noutput_items,
63
 
                                gr_vector_const_void_star &input_items,
64
 
                                gr_vector_void_star &output_items)
65
 
    {
66
 
      const short *in = (const short*)input_items[0];
67
 
      unsigned char *out = (unsigned char*)output_items[0];
68
 
 
69
 
      for(int i = 0; i < noutput_items; i++) {
70
 
        codec2_encode(d_codec2, out, const_cast<short*>(in));
71
 
        in += CODEC2_SAMPLES_PER_FRAME;
72
 
        out += CODEC2_BITS_PER_FRAME * sizeof(char);
73
 
      }
74
 
 
75
 
      return noutput_items;
76
 
    }
77
 
 
78
 
  } /* namespace vocoder */
79
 
} /* namespace gr */