Fix compiler warnings (prefix correct_errors/decode_audio with 'do_'.
Pass imbe_decoder to voice_du_handler and have the op25_decoder_ff own the object. git-svn-id: http://op25.osmocom.org/svn/trunk@170 65a5c917-d112-43f1-993d-58c26a4786be
This commit is contained in:
parent
4d32ec6a7b
commit
09d298bde4
|
@ -75,6 +75,7 @@ _op25_la_SOURCES = \
|
||||||
dummy_imbe_decoder.cc \
|
dummy_imbe_decoder.cc \
|
||||||
offline_imbe_decoder.cc \
|
offline_imbe_decoder.cc \
|
||||||
voice_data_unit.cc \
|
voice_data_unit.cc \
|
||||||
|
voice_du_handler.cc \
|
||||||
op25.cc \
|
op25.cc \
|
||||||
op25_decoder_ff.cc \
|
op25_decoder_ff.cc \
|
||||||
vc55_imbe_decoder.cc \
|
vc55_imbe_decoder.cc \
|
||||||
|
|
|
@ -42,7 +42,7 @@ void
|
||||||
abstract_data_unit::correct_errors()
|
abstract_data_unit::correct_errors()
|
||||||
{
|
{
|
||||||
if(is_complete()) {
|
if(is_complete()) {
|
||||||
correct_errors(d_frame_body);
|
do_correct_errors(d_frame_body);
|
||||||
} else {
|
} else {
|
||||||
ostringstream msg;
|
ostringstream msg;
|
||||||
msg << "cannot correct errors - frame is not complete" << endl;
|
msg << "cannot correct errors - frame is not complete" << endl;
|
||||||
|
@ -55,28 +55,10 @@ abstract_data_unit::correct_errors()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
abstract_data_unit::extend(dibit d)
|
abstract_data_unit::decode_audio(imbe_decoder& imbe)
|
||||||
{
|
{
|
||||||
if(frame_size() < frame_size_max()) {
|
|
||||||
d_frame_body.push_back(d & 0x2);
|
|
||||||
d_frame_body.push_back(d & 0x1);
|
|
||||||
} else {
|
|
||||||
ostringstream msg;
|
|
||||||
msg << "cannot extend frame " << endl;
|
|
||||||
msg << "(size now: " << frame_size() << ", expected size: " << frame_size_max() << ")" << endl;
|
|
||||||
msg << "func: " << __PRETTY_FUNCTION__ << endl;
|
|
||||||
msg << "file: " << __FILE__ << endl;
|
|
||||||
msg << "line: " << __LINE__ << endl;
|
|
||||||
throw length_error(msg.str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
abstract_data_unit::decode_audio(imbe_decoder& imbe, float_queue& audio)
|
|
||||||
{
|
|
||||||
size_t n = 0;
|
|
||||||
if(is_complete()) {
|
if(is_complete()) {
|
||||||
n = decode_audio(d_frame_body, imbe, audio);
|
do_decode_audio(d_frame_body, imbe);
|
||||||
} else {
|
} else {
|
||||||
ostringstream msg;
|
ostringstream msg;
|
||||||
msg << "cannot decode audio - frame is not complete" << endl;
|
msg << "cannot decode audio - frame is not complete" << endl;
|
||||||
|
@ -86,7 +68,6 @@ abstract_data_unit::decode_audio(imbe_decoder& imbe, float_queue& audio)
|
||||||
msg << "line: " << __LINE__ << endl;
|
msg << "line: " << __LINE__ << endl;
|
||||||
throw logic_error(msg.str());
|
throw logic_error(msg.str());
|
||||||
}
|
}
|
||||||
return n;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
|
@ -124,6 +105,23 @@ abstract_data_unit::decode_frame(const_bit_vector& frame_body, size_t msg_sz, ui
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
abstract_data_unit::extend(dibit d)
|
||||||
|
{
|
||||||
|
if(frame_size() < frame_size_max()) {
|
||||||
|
d_frame_body.push_back(d & 0x2);
|
||||||
|
d_frame_body.push_back(d & 0x1);
|
||||||
|
} else {
|
||||||
|
ostringstream msg;
|
||||||
|
msg << "cannot extend frame " << endl;
|
||||||
|
msg << "(size now: " << frame_size() << ", expected size: " << frame_size_max() << ")" << endl;
|
||||||
|
msg << "func: " << __PRETTY_FUNCTION__ << endl;
|
||||||
|
msg << "file: " << __FILE__ << endl;
|
||||||
|
msg << "line: " << __LINE__ << endl;
|
||||||
|
throw length_error(msg.str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
abstract_data_unit::is_complete() const
|
abstract_data_unit::is_complete() const
|
||||||
{
|
{
|
||||||
|
@ -161,14 +159,13 @@ abstract_data_unit::abstract_data_unit(const_bit_queue& frame_body) :
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
abstract_data_unit::correct_errors(bit_vector& frame_body)
|
abstract_data_unit::do_correct_errors(bit_vector& frame_body)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
void
|
||||||
abstract_data_unit::decode_audio(const_bit_vector& frame_body, imbe_decoder& imbe, float_queue& audio)
|
abstract_data_unit::do_decode_audio(const_bit_vector& frame_body, imbe_decoder& imbe)
|
||||||
{
|
{
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const_bit_vector&
|
const_bit_vector&
|
||||||
|
|
|
@ -56,15 +56,12 @@ public:
|
||||||
virtual void correct_errors();
|
virtual void correct_errors();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decode compressed audio using the supplied imbe_decoder and
|
* Decode compressed audio using the supplied imbe_decoder.
|
||||||
* writes output to audio.
|
|
||||||
*
|
*
|
||||||
* \precondition is_complete() == true.
|
* \precondition is_complete() == true.
|
||||||
* \param imbe The imbe_decoder to use to generate the audio.
|
* \param imbe The imbe_decoder to use to generate the audio.
|
||||||
* \param audio A deque<float> to which the audio (if any) is appended.
|
|
||||||
* \return The number of samples written to audio.
|
|
||||||
*/
|
*/
|
||||||
virtual size_t decode_audio(imbe_decoder& imbe, float_queue& audio);
|
virtual void decode_audio(imbe_decoder& imbe);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decode the frame into an octet vector.
|
* Decode the frame into an octet vector.
|
||||||
|
@ -133,19 +130,16 @@ protected:
|
||||||
*
|
*
|
||||||
* \param frame_body The bit vector to decode.
|
* \param frame_body The bit vector to decode.
|
||||||
*/
|
*/
|
||||||
virtual void correct_errors(bit_vector& frame_body);
|
virtual void do_correct_errors(bit_vector& frame_body);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decode compressed audio using the supplied imbe_decoder and
|
* Decode compressed audio using the supplied imbe_decoder.
|
||||||
* writes output to audio.
|
|
||||||
*
|
*
|
||||||
* \precondition is_complete() == true.
|
* \precondition is_complete() == true.
|
||||||
* \param frame_body The const_bit_vector to decode.
|
* \param frame_body The const_bit_vector to decode.
|
||||||
* \param imbe The imbe_decoder to use to generate the audio.
|
* \param imbe The imbe_decoder to use.
|
||||||
* \param audio A deque<float> to which the audio (if any) is appended.
|
|
||||||
* \return The number of samples written to audio.
|
|
||||||
*/
|
*/
|
||||||
virtual size_t decode_audio(const_bit_vector& frame_body, imbe_decoder& imbe, float_queue& audio);
|
virtual void do_decode_audio(const_bit_vector& frame_body, imbe_decoder& imbe);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decode frame_body and write the decoded frame contents to msg.
|
* Decode frame_body and write the decoded frame contents to msg.
|
||||||
|
|
|
@ -74,10 +74,8 @@ public:
|
||||||
*
|
*
|
||||||
* \precondition is_complete() == true.
|
* \precondition is_complete() == true.
|
||||||
* \param imbe The imbe_decoder to use to generate the audio.
|
* \param imbe The imbe_decoder to use to generate the audio.
|
||||||
* \param audio A deque<float> to which the audio (if any) is appended.
|
|
||||||
* \return The number of samples written to audio.
|
|
||||||
*/
|
*/
|
||||||
virtual size_t decode_audio(imbe_decoder& imbe, float_queue& audio) = 0;
|
virtual void decode_audio(imbe_decoder& imbe) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decode the frame into an octet vector.
|
* Decode the frame into an octet vector.
|
||||||
|
|
|
@ -31,10 +31,8 @@ dummy_imbe_decoder::~dummy_imbe_decoder()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
void
|
||||||
dummy_imbe_decoder::decode(voice_codeword& in_out, audio_output& out)
|
dummy_imbe_decoder::decode(voice_codeword& in_out)
|
||||||
{
|
{
|
||||||
// ToDo: implement me!
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,8 @@
|
||||||
#include <imbe_decoder.h>
|
#include <imbe_decoder.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dummy_imbe_decoder produces white noise in response to voice
|
* dummy_imbe_decoder is the imbe_decoder of last resort. It consumes
|
||||||
* frames. It is the imbe_decoder of last resort.
|
* the voice_codeeword and does nothing.
|
||||||
*/
|
*/
|
||||||
class dummy_imbe_decoder : public imbe_decoder {
|
class dummy_imbe_decoder : public imbe_decoder {
|
||||||
public:
|
public:
|
||||||
|
@ -44,14 +44,11 @@ public:
|
||||||
virtual ~dummy_imbe_decoder();
|
virtual ~dummy_imbe_decoder();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ignores in_out and generates white noise in response to all
|
* Ignores in_out and generates no audio.
|
||||||
* compressed voice samples.
|
|
||||||
*
|
*
|
||||||
* \param in_out IMBE codewords and parity.
|
* \param in_out IMBE codewords and parity.
|
||||||
* \param in Queue of audio samples to which output is written.
|
|
||||||
* \return The number of samples written to out.
|
|
||||||
*/
|
*/
|
||||||
virtual size_t decode(voice_codeword& in_out, audio_output& out);
|
virtual void decode(voice_codeword& in_out);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ hdu::snapshot() const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
hdu::correct_errors(bit_vector& frame)
|
hdu::do_correct_errors(bit_vector& frame)
|
||||||
{
|
{
|
||||||
apply_golay_correction(frame);
|
apply_golay_correction(frame);
|
||||||
apply_rs_correction(frame);
|
apply_rs_correction(frame);
|
||||||
|
|
|
@ -68,7 +68,7 @@ protected:
|
||||||
* \param frame_body The bit vector to decode.
|
* \param frame_body The bit vector to decode.
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
virtual void correct_errors(bit_vector& frame_body);
|
virtual void do_correct_errors(bit_vector& frame_body);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply Golay error correction code to the specified bit_vector.
|
* Apply Golay error correction code to the specified bit_vector.
|
||||||
|
|
|
@ -1,20 +1,26 @@
|
||||||
#include <dummy_imbe_decoder.h>
|
// #include <dummy_imbe_decoder.h>
|
||||||
#include <imbe_decoder.h>
|
#include <imbe_decoder.h>
|
||||||
// #include <offline_imbe_decoder.h>
|
#include <offline_imbe_decoder.h>
|
||||||
|
// #include <software_imbe_decoder.h>
|
||||||
// #include <vc55_imbe_decoder.h>
|
// #include <vc55_imbe_decoder.h>
|
||||||
|
|
||||||
imbe_decoder_sptr
|
imbe_decoder_sptr
|
||||||
imbe_decoder::make_imbe_decoder()
|
imbe_decoder::make_imbe_decoder()
|
||||||
{
|
{
|
||||||
return imbe_decoder_sptr(new dummy_imbe_decoder());
|
return imbe_decoder_sptr(new offline_imbe_decoder());
|
||||||
// return imbe_decoder_sptr(new offline_imbe_decoder());
|
|
||||||
// return imbe_decoder_sptr(new vc55_imbe_decoder());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
imbe_decoder::~imbe_decoder()
|
imbe_decoder::~imbe_decoder()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
imbe_decoder::imbe_decoder()
|
imbe_decoder::imbe_decoder() :
|
||||||
|
d_audio()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
audio_samples*
|
||||||
|
imbe_decoder::audio()
|
||||||
|
{
|
||||||
|
return &d_audio;
|
||||||
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
typedef std::deque<float> audio_output;
|
typedef std::deque<float> audio_samples;
|
||||||
typedef std::vector<bool> voice_codeword;
|
typedef std::vector<bool> voice_codeword;
|
||||||
|
|
||||||
typedef boost::shared_ptr<class imbe_decoder> imbe_decoder_sptr;
|
typedef boost::shared_ptr<class imbe_decoder> imbe_decoder_sptr;
|
||||||
|
@ -56,13 +56,19 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply error correction to the voice_codeword in_out,
|
* Apply error correction to the voice_codeword in_out,
|
||||||
* decode the audio and write it to the audio_output.
|
* decode the audio and write it to the audio_samples.
|
||||||
*
|
*
|
||||||
* \param in_out IMBE codewords and parity.
|
* \param in_out IMBE codeword (including parity check bits).
|
||||||
* \param in Queue of audio samples to which output is written.
|
|
||||||
* \return The number of samples written to out.
|
|
||||||
*/
|
*/
|
||||||
virtual size_t decode(voice_codeword& in_out, audio_output& out) = 0;
|
virtual void decode(voice_codeword& in_out) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the audio_samples samples. These are mono samples at
|
||||||
|
* 8KS/s represented as a float in the range -1.0 .. +1.0.
|
||||||
|
*
|
||||||
|
* \return A non-null pointer to a deque<float> of audio samples.
|
||||||
|
*/
|
||||||
|
audio_samples *audio();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -72,6 +78,13 @@ protected:
|
||||||
* make_imbe_decoder to construct concrete instances.
|
* make_imbe_decoder to construct concrete instances.
|
||||||
*/
|
*/
|
||||||
imbe_decoder();
|
imbe_decoder();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The audio samples produced by the IMBE decoder.
|
||||||
|
*/
|
||||||
|
audio_samples d_audio;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ public:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The msg_queue to which decoded frames are written.
|
* The file to which decoded frames are written.
|
||||||
*/
|
*/
|
||||||
std::ofstream d_log;
|
std::ofstream d_log;
|
||||||
|
|
||||||
|
|
|
@ -48,8 +48,8 @@ offline_imbe_decoder::~offline_imbe_decoder()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
void
|
||||||
offline_imbe_decoder::decode(voice_codeword& in_out, audio_output& out)
|
offline_imbe_decoder::decode(voice_codeword& in_out)
|
||||||
{
|
{
|
||||||
if(d_fp) {
|
if(d_fp) {
|
||||||
uint8_t codewords[18];
|
uint8_t codewords[18];
|
||||||
|
@ -60,5 +60,4 @@ offline_imbe_decoder::decode(voice_codeword& in_out, audio_output& out)
|
||||||
d_fp = NULL;
|
d_fp = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,10 +49,8 @@ public:
|
||||||
* Dump voice_codeword in_out to file.
|
* Dump voice_codeword in_out to file.
|
||||||
*
|
*
|
||||||
* \param in_out IMBE codewords and parity.
|
* \param in_out IMBE codewords and parity.
|
||||||
* \param in Queue of audio samples to which output is written.
|
|
||||||
* \return The number of samples written to out.
|
|
||||||
*/
|
*/
|
||||||
virtual size_t decode(voice_codeword& in_out, audio_output& out);
|
virtual void decode(voice_codeword& in_out);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* -*- C++ -*- */
|
/* -*- C++ -*- */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2008 Steve Glass
|
* Copyright 2008, 2009 Steve Glass
|
||||||
*
|
*
|
||||||
* This file is part of OP25.
|
* This file is part of OP25.
|
||||||
*
|
*
|
||||||
|
@ -30,8 +30,10 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <itpp/comm/bch.h>
|
#include <itpp/comm/bch.h>
|
||||||
#include <logfile_du_handler.h>
|
#include <logfile_du_handler.h>
|
||||||
|
#include <offline_imbe_decoder.h>
|
||||||
#include <op25_decoder_ff.h>
|
#include <op25_decoder_ff.h>
|
||||||
#include <snapshot_du_handler.h>
|
#include <snapshot_du_handler.h>
|
||||||
|
#include <voice_du_handler.h>
|
||||||
#include <yank.h>
|
#include <yank.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -58,6 +60,7 @@ op25_decoder_ff::general_work(int nof_output_items, gr_vector_int& nof_input_ite
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
// process symbol
|
||||||
const float *in = reinterpret_cast<const float*>(input_items[0]);
|
const float *in = reinterpret_cast<const float*>(input_items[0]);
|
||||||
for(int i = 0; i < nof_input_items[0]; ++i) {
|
for(int i = 0; i < nof_input_items[0]; ++i) {
|
||||||
dibit d;
|
dibit d;
|
||||||
|
@ -72,9 +75,11 @@ op25_decoder_ff::general_work(int nof_output_items, gr_vector_int& nof_input_ite
|
||||||
}
|
}
|
||||||
receive_symbol(d);
|
receive_symbol(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// produce audio (even if silence)
|
||||||
consume(0, nof_input_items[0]);
|
consume(0, nof_input_items[0]);
|
||||||
float *out = reinterpret_cast<float*>(output_items[0]);
|
float *out = reinterpret_cast<float*>(output_items[0]);
|
||||||
fill(out, out + nof_output_items, 0.0); // audio silence - for now
|
fill(out, out + nof_output_items, 0.0);
|
||||||
return nof_output_items;
|
return nof_output_items;
|
||||||
|
|
||||||
} catch(const std::exception& x) {
|
} catch(const std::exception& x) {
|
||||||
|
@ -96,12 +101,14 @@ op25_decoder_ff::op25_decoder_ff(gr_msg_queue_sptr msgq) :
|
||||||
d_data_unit(),
|
d_data_unit(),
|
||||||
d_data_unit_handler(),
|
d_data_unit_handler(),
|
||||||
d_frame_hdr(),
|
d_frame_hdr(),
|
||||||
|
d_imbe(new offline_imbe_decoder()),
|
||||||
d_state(SYNCHRONIZING),
|
d_state(SYNCHRONIZING),
|
||||||
d_sniffer_du_handler(NULL)
|
d_sniffer_du_handler(NULL)
|
||||||
{
|
{
|
||||||
d_sniffer_du_handler = new sniffer_du_handler(d_data_unit_handler);
|
d_sniffer_du_handler = new sniffer_du_handler(d_data_unit_handler);
|
||||||
d_data_unit_handler = data_unit_handler_sptr(d_sniffer_du_handler);
|
d_data_unit_handler = data_unit_handler_sptr(d_sniffer_du_handler);
|
||||||
d_data_unit_handler = data_unit_handler_sptr(new snapshot_du_handler(d_data_unit_handler, msgq));
|
d_data_unit_handler = data_unit_handler_sptr(new snapshot_du_handler(d_data_unit_handler, msgq));
|
||||||
|
d_data_unit_handler = data_unit_handler_sptr(new voice_du_handler(d_data_unit_handler, d_imbe));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -142,7 +149,7 @@ op25_decoder_ff::identified()
|
||||||
size_t NID_SZ = sizeof(NID) / sizeof(NID[0]);
|
size_t NID_SZ = sizeof(NID) / sizeof(NID[0]);
|
||||||
|
|
||||||
itpp::bvec b(63), zeroes(16);
|
itpp::bvec b(63), zeroes(16);
|
||||||
itpp::BCH bch(63, 16, 11,"6 3 3 1 1 4 1 3 6 7 2 3 5 4 5 3", true);
|
itpp::BCH bch(63, 16, 11, "6 3 3 1 1 4 1 3 6 7 2 3 5 4 5 3", true);
|
||||||
yank(d_frame_hdr, NID, NID_SZ, b, 0);
|
yank(d_frame_hdr, NID, NID_SZ, b, 0);
|
||||||
b = bch.decode(b);
|
b = bch.decode(b);
|
||||||
if(b != zeroes) {
|
if(b != zeroes) {
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <data_unit_handler.h>
|
#include <data_unit_handler.h>
|
||||||
#include <gr_block.h>
|
#include <gr_block.h>
|
||||||
#include <gr_msg_queue.h>
|
#include <gr_msg_queue.h>
|
||||||
|
#include <imbe_decoder.h>
|
||||||
#include <sniffer_du_handler.h>
|
#include <sniffer_du_handler.h>
|
||||||
|
|
||||||
typedef boost::shared_ptr<class op25_decoder_ff> op25_decoder_ff_sptr;
|
typedef boost::shared_ptr<class op25_decoder_ff> op25_decoder_ff_sptr;
|
||||||
|
@ -128,6 +129,11 @@ private:
|
||||||
*/
|
*/
|
||||||
bit_queue d_frame_hdr;
|
bit_queue d_frame_hdr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The IMBE decoder to use.
|
||||||
|
*/
|
||||||
|
imbe_decoder_sptr d_imbe;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The message queue used to send snapshots to the UI.
|
* The message queue used to send snapshots to the UI.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -40,7 +40,7 @@ pdu::duid_str() const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pdu::correct_errors(bit_vector& frame_body)
|
pdu::do_correct_errors(bit_vector& frame_body)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ protected:
|
||||||
* \param frame_body The bit vector to decode.
|
* \param frame_body The bit vector to decode.
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
virtual void correct_errors(bit_vector& frame_body);
|
virtual void do_correct_errors(bit_vector& frame_body);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the expected size (in bits) of this data unit in
|
* Returns the expected size (in bits) of this data unit in
|
||||||
|
|
|
@ -46,7 +46,7 @@ tdu::duid_str() const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tdu::correct_errors(bit_vector& frame)
|
tdu::do_correct_errors(bit_vector& frame)
|
||||||
{
|
{
|
||||||
if(d_has_link_control) {
|
if(d_has_link_control) {
|
||||||
apply_golay_correction(frame);
|
apply_golay_correction(frame);
|
||||||
|
|
|
@ -59,7 +59,7 @@ protected:
|
||||||
* \param frame_body The bit vector to decode.
|
* \param frame_body The bit vector to decode.
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
virtual void correct_errors(bit_vector& frame_body);
|
virtual void do_correct_errors(bit_vector& frame_body);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply Golay error correction code to the specified bit_vector.
|
* Apply Golay error correction code to the specified bit_vector.
|
||||||
|
|
|
@ -68,19 +68,18 @@ vc55_imbe_decoder::~vc55_imbe_decoder()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
void
|
||||||
vc55_imbe_decoder::decode(voice_codeword& in_out, audio_output& out)
|
vc55_imbe_decoder::decode(voice_codeword& in_out)
|
||||||
{
|
{
|
||||||
if(-1 != d_fd) {
|
if(-1 != d_fd) {
|
||||||
uint8_t packet[20];
|
uint8_t packet[20];
|
||||||
packet[0] = 0x56;
|
packet[0] = 0x56;
|
||||||
packet[1] = 0xf0;
|
packet[1] = 0xf0;
|
||||||
/* ToDo: extract(in_out, 0, 144, &packet[2]); */
|
// ToDo extract(in_out, 0, 144, &packet[2]);
|
||||||
if(-1 == write(d_fd, packet, sizeof(packet))) {
|
if(-1 == write(d_fd, packet, sizeof(packet))) {
|
||||||
perror("write(d_fd, packet, sizeof(packet))");
|
perror("write(d_fd, packet, sizeof(packet))");
|
||||||
close(d_fd);
|
close(d_fd);
|
||||||
d_fd = -1;
|
d_fd = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,9 @@
|
||||||
#include <imbe_decoder.h>
|
#include <imbe_decoder.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* vc55_imbe_decoder uses the VC55PR vocoder to decode voice.
|
* vc55_imbe_decoder uses the VC55PR vocoder to decode voice. Note
|
||||||
|
* that the VC55 produces audio but this is not fed back to the flow
|
||||||
|
* graph.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class vc55_imbe_decoder : public imbe_decoder {
|
class vc55_imbe_decoder : public imbe_decoder {
|
||||||
|
@ -44,13 +46,11 @@ public:
|
||||||
virtual ~vc55_imbe_decoder();
|
virtual ~vc55_imbe_decoder();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Passess the voice_codeword in_out to the VC55PR device
|
* Passess the voice_codeword in_out to the VC55PR device.
|
||||||
*
|
*
|
||||||
* \param in_out IMBE codewords and parity.
|
* \param in_out IMBE codewords and parity.
|
||||||
* \param in Queue of audio samples to which output is written.
|
|
||||||
* \return The number of samples written to out.
|
|
||||||
*/
|
*/
|
||||||
virtual size_t decode(voice_codeword& in_out, audio_output& out);
|
virtual void decode(voice_codeword& in_out);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -36,12 +36,12 @@ voice_data_unit::voice_data_unit(const_bit_queue& frame_body) :
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
voice_data_unit::correct_errors(bit_vector& frame_body)
|
voice_data_unit::do_correct_errors(bit_vector& frame_body)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
void
|
||||||
voice_data_unit::decode_audio(const_bit_vector& frame_body, imbe_decoder& imbe, float_queue& audio)
|
voice_data_unit::do_decode_audio(const_bit_vector& frame_body, imbe_decoder& imbe)
|
||||||
{
|
{
|
||||||
static const size_t nof_voice_codewords = 9, voice_codeword_sz = 144;
|
static const size_t nof_voice_codewords = 9, voice_codeword_sz = 144;
|
||||||
static const size_t voice_codeword_bits[nof_voice_codewords][voice_codeword_sz] = {
|
static const size_t voice_codeword_bits[nof_voice_codewords][voice_codeword_sz] = {
|
||||||
|
@ -165,15 +165,13 @@ voice_data_unit::decode_audio(const_bit_vector& frame_body, imbe_decoder& imbe,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
size_t nof_samples = 0;
|
|
||||||
for(size_t i = 0; i < nof_voice_codewords; ++i) {
|
for(size_t i = 0; i < nof_voice_codewords; ++i) {
|
||||||
voice_codeword cw(voice_codeword_sz);
|
voice_codeword cw(voice_codeword_sz);
|
||||||
for(size_t j = 0; j < voice_codeword_sz; ++j) {
|
for(size_t j = 0; j < voice_codeword_sz; ++j) {
|
||||||
cw[j] = frame_body[voice_codeword_bits[i][j]];
|
cw[j] = frame_body[voice_codeword_bits[i][j]];
|
||||||
}
|
}
|
||||||
nof_samples += imbe.decode(cw, audio);
|
imbe.decode(cw);
|
||||||
}
|
}
|
||||||
return nof_samples;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t
|
uint16_t
|
||||||
|
|
|
@ -55,18 +55,15 @@ protected:
|
||||||
* \param frame_body The bit vector to decode.
|
* \param frame_body The bit vector to decode.
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
virtual void correct_errors(bit_vector& frame_body);
|
virtual void do_correct_errors(bit_vector& frame_body);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decode compressed audio using the supplied imbe_decoder and
|
* Decode compressed audio using the supplied imbe_decoder.
|
||||||
* writes output to audio.
|
|
||||||
*
|
*
|
||||||
* \param frame_body The const_bit_vector to decode.
|
* \param frame_body The const_bit_vector to decode.
|
||||||
* \param imbe The imbe_decoder to use to generate the audio.
|
* \param imbe The imbe_decoder to use to generate the audio.
|
||||||
* \param audio A deque<float> to which the audio (if any) is appended.
|
|
||||||
* \return The number of samples written to audio.
|
|
||||||
*/
|
*/
|
||||||
virtual size_t decode_audio(const_bit_vector& frame_body, imbe_decoder& imbe, float_queue& audio);
|
virtual void do_decode_audio(const_bit_vector& frame_body, imbe_decoder& imbe);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the expected size (in bits) of this data_unit. For
|
* Returns the expected size (in bits) of this data_unit. For
|
||||||
|
|
|
@ -50,7 +50,7 @@ size_t extract(const X& in, int begin, int end, uint8_t *out)
|
||||||
const size_t out_sz = (7 + end - begin) / 8;
|
const size_t out_sz = (7 + end - begin) / 8;
|
||||||
std::fill(out, out + out_sz, 0);
|
std::fill(out, out + out_sz, 0);
|
||||||
for(int i = begin, j = 0; i < end; ++i, ++j) {
|
for(int i = begin, j = 0; i < end; ++i, ++j) {
|
||||||
out[j / 8] ^= in[i] << (7 - (j % 8));
|
out[j / 8] |= (in[i] ? 1 << (7 - (j % 8)) : 0);
|
||||||
}
|
}
|
||||||
return out_sz;
|
return out_sz;
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue