From 23c8d8a92f1c1a19f5c1ce29df91c27f53e51359 Mon Sep 17 00:00:00 2001 From: Roman Khassraf Date: Tue, 11 Aug 2015 11:52:15 +0200 Subject: Implemented boundary check for voice decoding. Issue 107 --- grc/decoding/gsm_tch_f_decoder.xml | 26 ++++++++++++++++++++-- include/grgsm/decoding/tch_f_decoder.h | 2 +- lib/decoding/tch_f_decoder_impl.cc | 40 +++++++++++++++++++++++++++++++--- lib/decoding/tch_f_decoder_impl.h | 4 +++- 4 files changed, 65 insertions(+), 7 deletions(-) diff --git a/grc/decoding/gsm_tch_f_decoder.xml b/grc/decoding/gsm_tch_f_decoder.xml index 59ac97d..632162f 100644 --- a/grc/decoding/gsm_tch_f_decoder.xml +++ b/grc/decoding/gsm_tch_f_decoder.xml @@ -3,7 +3,7 @@ TCH/F decoder gsm_tch_f_decoder import grgsm - grgsm.tch_f_decoder($mode, $file) + grgsm.tch_f_decoder($mode, $file, $boundary_check) TCH coding mode @@ -56,7 +56,21 @@ /tmp/speech.gsm file_open - + + Voice boundary detection + boundary_check + True + bool + + + + bursts message @@ -66,4 +80,12 @@ message 1 + + +If "Voice boundary detection" is enabled, then only bursts are decoded as voice where + +- the framenumber is greater then the framenumber of a received "Connect" or "Connect Acknowlegde" message, and +- the framenumber is less then the framenumber of a "Release" message + + diff --git a/include/grgsm/decoding/tch_f_decoder.h b/include/grgsm/decoding/tch_f_decoder.h index efe082c..8dbf68b 100644 --- a/include/grgsm/decoding/tch_f_decoder.h +++ b/include/grgsm/decoding/tch_f_decoder.h @@ -62,7 +62,7 @@ namespace gr { * class. gsm::tch_f_decoder::make is the public interface for * creating new instances. */ - static sptr make(tch_mode mode, const std::string &file); + static sptr make(tch_mode mode, const std::string &file, bool boundary_check=true); }; diff --git a/lib/decoding/tch_f_decoder_impl.cc b/lib/decoding/tch_f_decoder_impl.cc index a3b09fb..f3099fd 100644 --- a/lib/decoding/tch_f_decoder_impl.cc +++ b/lib/decoding/tch_f_decoder_impl.cc @@ -35,21 +35,23 @@ namespace gr { namespace gsm { tch_f_decoder::sptr - tch_f_decoder::make(tch_mode mode, const std::string &file) + tch_f_decoder::make(tch_mode mode, const std::string &file, bool boundary_check) { return gnuradio::get_initial_sptr - (new tch_f_decoder_impl(mode, file)); + (new tch_f_decoder_impl(mode, file, boundary_check)); } /* * Constructor */ - tch_f_decoder_impl::tch_f_decoder_impl(tch_mode mode, const std::string &file) + tch_f_decoder_impl::tch_f_decoder_impl(tch_mode mode, const std::string &file, bool boundary_check) : gr::block("tch_f_decoder", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), d_tch_mode(mode), d_collected_bursts_num(0), + d_boundary_check(boundary_check), + d_boundary_decode(!boundary_check), mBlockCoder(0x10004820009ULL, 40, 224), mU(228), mP(mU.segment(184,40)), @@ -163,6 +165,32 @@ namespace gr { pmt::pmt_t msg_out = pmt::cons(pmt::PMT_NIL, msg_binary_blob); message_port_pub(pmt::mp("msgs"), msg_out); + + // if d_boundary_check is enabled, we set d_boundary_decode to true, when a + // "Connect" or "Connect Acknowledge" message is received, and + // we set d_boundary_decode back to false, when "Release" message is received + if (d_boundary_check) + { + // check if this is a call control message + if ((outmsg[3] & 0x0f) == 0x03) + { + // Connect specified in GSM 04.08, 9.3.5 + if ((outmsg[4] & 0x3f) == 0x07) + { + d_boundary_decode = true; + } + // Connect Acknowledge specified in GSM 04.08, 9.3.6 + else if ((outmsg[4] & 0x3f) == 0x0f) + { + d_boundary_decode = true; + } + // Release specified in GSM 04.08, 9.3.18 + else if ((outmsg[4] & 0x3f) == 0x2d) + { + d_boundary_decode = false; + } + } + } // if we are in an AMR-mode and we receive a channel mode modify message, // we set the mode according to the multirate configuration from the message @@ -215,6 +243,12 @@ namespace gr { } } } + + // if boundary_check is enabled and d_boundary_decode is false, we are done + if (d_boundary_check && !d_boundary_decode) + { + return; + } // Decode voice frames and write to file if (d_tch_mode == TCH_FS || d_tch_mode == TCH_EFR) diff --git a/lib/decoding/tch_f_decoder_impl.h b/lib/decoding/tch_f_decoder_impl.h index f6d054b..3e8c79a 100644 --- a/lib/decoding/tch_f_decoder_impl.h +++ b/lib/decoding/tch_f_decoder_impl.h @@ -54,6 +54,8 @@ namespace gr { pmt::pmt_t d_bursts[8]; FILE * d_speech_file; enum tch_mode d_tch_mode; + bool d_boundary_check; + bool d_boundary_decode; BitVector mU; BitVector mP; @@ -87,7 +89,7 @@ namespace gr { void decode(pmt::pmt_t msg); void setCodingMode(tch_mode mode); public: - tch_f_decoder_impl(tch_mode mode, const std::string &file); + tch_f_decoder_impl(tch_mode mode, const std::string &file, bool boundary_check=true); ~tch_f_decoder_impl(); }; -- cgit v1.2.3