diff options
author | Josh Blum <josh@joshknows.com> | 2011-01-12 15:41:32 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-01-12 15:41:32 -0800 |
commit | 6f814f04c4af020a627f6772f7f9b14083d312f4 (patch) | |
tree | 586e9d103371d3840cc19477c323e37bfa8da086 /host/lib/transport | |
parent | 4f28afe2479856f1e0696983a206f05939b2edbf (diff) | |
download | uhd-6f814f04c4af020a627f6772f7f9b14083d312f4.tar.gz uhd-6f814f04c4af020a627f6772f7f9b14083d312f4.tar.bz2 uhd-6f814f04c4af020a627f6772f7f9b14083d312f4.zip |
uhd: changed convert routines to return the function pointer
changed the vrt packet handler to get the function pointer (once), this may be a minor performance help
Diffstat (limited to 'host/lib/transport')
-rw-r--r-- | host/lib/transport/vrt_packet_handler.hpp | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/host/lib/transport/vrt_packet_handler.hpp b/host/lib/transport/vrt_packet_handler.hpp index ab58e3416..0507ae328 100644 --- a/host/lib/transport/vrt_packet_handler.hpp +++ b/host/lib/transport/vrt_packet_handler.hpp @@ -35,6 +35,9 @@ namespace vrt_packet_handler{ +//this may change in the future but its a constant for now +static const size_t OTW_BYTES_PER_SAMP = sizeof(boost::uint32_t); + template <typename T> UHD_INLINE T get_context_code( const boost::uint32_t *vrt_hdr, const uhd::transport::vrt::if_packet_info_t &if_packet_info @@ -145,8 +148,7 @@ template <typename T> UHD_INLINE T get_context_code( size_t offset_bytes, size_t total_samps, uhd::rx_metadata_t &metadata, - const uhd::io_type_t &io_type, - const uhd::otw_type_t &otw_type, + uhd::convert::function_type &converter, double tick_rate, const vrt_unpacker_t &vrt_unpacker, const get_recv_buffs_t &get_recv_buffs, @@ -184,7 +186,7 @@ template <typename T> UHD_INLINE T get_context_code( } //extract the number of samples available to copy - size_t bytes_per_item = otw_type.get_sample_size(); + size_t bytes_per_item = OTW_BYTES_PER_SAMP; size_t nsamps_available = state.size_of_copy_buffs/bytes_per_item; size_t nsamps_to_copy = std::min(total_samps*chans_per_otw_buff, nsamps_available); size_t bytes_to_copy = nsamps_to_copy*bytes_per_item; @@ -200,9 +202,7 @@ template <typename T> UHD_INLINE T get_context_code( //copy-convert the samples from the recv buffer uhd::convert::input_type otw_buffs(1, state.copy_buffs[i]); - uhd::convert::otw_type_to_io_type( - io_type, otw_type, otw_buffs, io_buffs, nsamps_to_copy_per_io_buff - ); + converter(otw_buffs, io_buffs, nsamps_to_copy_per_io_buff); //update the rx copy buffer to reflect the bytes copied state.copy_buffs[i] += bytes_to_copy; @@ -236,6 +236,11 @@ template <typename T> UHD_INLINE T get_context_code( size_t vrt_header_offset_words32 = 0, size_t chans_per_otw_buff = 1 ){ + uhd::convert::function_type converter( + uhd::convert::get_converter_otw_to_cpu( + io_type, otw_type, 1, buffs.size() + )); + switch(recv_mode){ //////////////////////////////////////////////////////////////// @@ -246,7 +251,7 @@ template <typename T> UHD_INLINE T get_context_code( buffs, 0, total_num_samps, metadata, - io_type, otw_type, + converter, tick_rate, vrt_unpacker, get_recv_buffs, @@ -267,7 +272,7 @@ template <typename T> UHD_INLINE T get_context_code( buffs, accum_num_samps*io_type.size, total_num_samps - accum_num_samps, (accum_num_samps == 0)? metadata : tmp_md, //only the first metadata gets kept - io_type, otw_type, + converter, tick_rate, vrt_unpacker, get_recv_buffs, @@ -311,15 +316,14 @@ template <typename T> UHD_INLINE T get_context_code( const size_t offset_bytes, const size_t num_samps, uhd::transport::vrt::if_packet_info_t &if_packet_info, - const uhd::io_type_t &io_type, - const uhd::otw_type_t &otw_type, + uhd::convert::function_type &converter, const vrt_packer_t &vrt_packer, const get_send_buffs_t &get_send_buffs, const size_t vrt_header_offset_words32, const size_t chans_per_otw_buff ){ //load the rest of the if_packet_info in here - if_packet_info.num_payload_words32 = (num_samps*chans_per_otw_buff*otw_type.get_sample_size())/sizeof(boost::uint32_t); + if_packet_info.num_payload_words32 = (num_samps*chans_per_otw_buff*OTW_BYTES_PER_SAMP)/sizeof(boost::uint32_t); if_packet_info.packet_count = state.next_packet_seq; //get send buffers for each channel @@ -340,9 +344,7 @@ template <typename T> UHD_INLINE T get_context_code( //copy-convert the samples into the send buffer uhd::convert::output_type otw_buffs(1, otw_mem); - uhd::convert::io_type_to_otw_type( - io_type, otw_type, io_buffs, otw_buffs, num_samps - ); + converter(io_buffs, otw_buffs, num_samps); //commit the samples to the zero-copy interface size_t num_bytes_total = (vrt_header_offset_words32+if_packet_info.num_packet_words32)*sizeof(boost::uint32_t); @@ -370,6 +372,11 @@ template <typename T> UHD_INLINE T get_context_code( size_t vrt_header_offset_words32 = 0, size_t chans_per_otw_buff = 1 ){ + uhd::convert::function_type converter( + uhd::convert::get_converter_cpu_to_otw( + io_type, otw_type, buffs.size(), 1 + )); + //translate the metadata to vrt if packet info uhd::transport::vrt::if_packet_info_t if_packet_info; if_packet_info.has_sid = false; @@ -405,7 +412,7 @@ template <typename T> UHD_INLINE T get_context_code( buffs_, 0, std::min(total_num_samps_, max_samples_per_packet), if_packet_info, - io_type, otw_type, + converter, vrt_packer, get_send_buffs, vrt_header_offset_words32, @@ -438,7 +445,7 @@ template <typename T> UHD_INLINE T get_context_code( buffs, total_num_samps_sent*io_type.size, std::min(total_num_samps_unsent, max_samples_per_packet), if_packet_info, - io_type, otw_type, + converter, vrt_packer, get_send_buffs, vrt_header_offset_words32, |