aboutsummaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
Diffstat (limited to 'host/include')
-rw-r--r--host/include/uhd/convert.hpp50
-rw-r--r--host/include/uhd/stream.hpp16
2 files changed, 40 insertions, 26 deletions
diff --git a/host/include/uhd/convert.hpp b/host/include/uhd/convert.hpp
index c42edfdec..f906ff0e9 100644
--- a/host/include/uhd/convert.hpp
+++ b/host/include/uhd/convert.hpp
@@ -20,33 +20,39 @@
#include <uhd/config.hpp>
#include <uhd/types/ref_vector.hpp>
+#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#include <boost/operators.hpp>
#include <string>
namespace uhd{ namespace convert{
- typedef uhd::ref_vector<void *> output_type;
- typedef uhd::ref_vector<const void *> input_type;
+ //! A conversion class that implements a conversion from inputs -> outputs.
+ class converter{
+ public:
+ typedef boost::shared_ptr<converter> sptr;
+ typedef uhd::ref_vector<void *> output_type;
+ typedef uhd::ref_vector<const void *> input_type;
- //! input vectors, output vectors, num samples, scale factor
- typedef boost::function<void(const input_type&, const output_type&, const size_t, const double)> function_type;
+ //! Set the scale factor (used in floating point conversions)
+ virtual void set_scalar(const double) = 0;
- /*!
- * Describe the priority of a converter function.
- * A higher priority function takes precedence.
- * The general case function are the lowest.
- * Next comes the liborc implementations.
- * Custom intrinsics implementations are highest.
- */
- enum priority_type{
- PRIORITY_GENERAL = 0,
- PRIORITY_LIBORC = 1,
- PRIORITY_SIMD = 2,
- PRIORITY_CUSTOM = 3,
- PRIORITY_EMPTY = -1,
+ //! The public conversion method to convert inputs -> outputs
+ UHD_INLINE void conv(const input_type &in, const output_type &out, const size_t num){
+ if (num != 0) (*this)(in, out, num);
+ }
+
+ private:
+ //! Callable method: input vectors, output vectors, num samples
+ virtual void operator()(const input_type&, const output_type&, const size_t) = 0;
};
+ //! Conversion factory function typedef
+ typedef boost::function<converter::sptr(void)> function_type;
+
+ //! Priority of conversion routines
+ typedef int priority_type;
+
//! Identify a conversion routine in the registry
struct id_type : boost::equality_comparable<id_type>{
std::string input_format;
@@ -62,19 +68,19 @@ namespace uhd{ namespace convert{
/*!
* Register a converter function.
* \param id identify the conversion
- * \param fcn a pointer to the converter
+ * \param fcn makes a new converter
* \param prio the function priority
*/
UHD_API void register_converter(
const id_type &id,
- function_type fcn,
- priority_type prio
+ const function_type &fcn,
+ const priority_type prio
);
/*!
- * Get a converter function.
+ * Get a converter factory function.
* \param id identify the conversion
- * \return the converter function
+ * \return the converter factory function
*/
UHD_API function_type get_converter(const id_type &id);
diff --git a/host/include/uhd/stream.hpp b/host/include/uhd/stream.hpp
index 1f0332088..8f3219dbd 100644
--- a/host/include/uhd/stream.hpp
+++ b/host/include/uhd/stream.hpp
@@ -49,10 +49,12 @@ struct UHD_API stream_args_t{
/*!
* The CPU format is a string that describes the format of host memory.
- * Common CPU formats are:
- * - fc32 - complex<float>
+ * Conversions for the following CPU formats have been implemented:
* - fc64 - complex<double>
+ * - fc32 - complex<float>
* - sc16 - complex<int16_t>
+ *
+ * The following are not implemented, but are listed to demonstrate naming convention:
* - sc8 - complex<int8_t>
* - f32 - float
* - f64 - double
@@ -63,9 +65,11 @@ struct UHD_API stream_args_t{
/*!
* The OTW format is a string that describes the format over-the-wire.
- * Common OTW format are:
+ * The following over-the-wire formats have been implemented:
* - sc16 - Q16 I16
* - sc8 - Q8_1 I8_1 Q8_0 I8_0
+ *
+ * The following are not implemented, but are listed to demonstrate naming convention:
* - s16 - R16_1 R16_0
* - s8 - R8_3 R8_2 R8_1 R8_0
*/
@@ -74,7 +78,11 @@ struct UHD_API stream_args_t{
/*!
* The args parameter is used to pass arbitrary key/value pairs.
* Possible keys used by args (depends on implementation):
- * - scaler: 8sc converter scaling factor
+ * - scalar: an integer scaling factor used with the sc8 wire format.
+ * The key/value pair scalar=1024 means that the sample in the DSP
+ * was multiplied by 1024 before its upper 8 bits were harvested.
+ *
+ * The following are not implemented, but are listed for conceptual purposes:
* - function: magnitude or phase/magnitude
* - units: numeric units like counts or dBm
*/