Forgot to attach the patch, now it is there. (If everybody is ok with it I can just do a commit)
2005-08-08 Martin Dudok van Heel <nldudok1 at olifantasia.com> Addded a new block to convert from float to unsigned char. Needed for new tv-reception example. * src/lib/general/gr_float_to_uchar.{cc,h,i}: new * src/lib/general/gri_float_to_uchar.{cc,h}: new * src/lib/general/Makefile.am: changed. Added gr_float_to_uchar and gri_float_to_uchar. (Also added gr_float_to_char.h which was forgotten in previous patch to add gr_float_to_char) * src/lib/general/general.i: changed. Added gr_float_to_uchar and gri_float_to_uchar. greetings, Martin Dudok van Heel (Martin Dvh)
? bootstrap-mdvh-debian ? src/python/gnuradio/gr/mdvh_benchmark_filters.py Index: src/lib/general/Makefile.am =================================================================== RCS file: /cvsroot/gnuradio/gnuradio-core/src/lib/general/Makefile.am,v retrieving revision 1.54 diff -u -b -B -r1.54 Makefile.am --- src/lib/general/Makefile.am 30 Jul 2005 21:29:25 -0000 1.54 +++ src/lib/general/Makefile.am 8 Aug 2005 14:53:41 -0000 @@ -111,6 +111,7 @@ gr_fft_vcc.cc \ gr_fft_vfc.cc \ gr_float_to_char.cc \ + gr_float_to_uchar.cc \ gr_float_to_complex.cc \ gr_float_to_short.cc \ gr_firdes.cc \ @@ -151,6 +152,7 @@ gri_debugger_hook.cc \ gri_fft.cc \ gri_float_to_char.cc \ + gri_float_to_uchar.cc \ gri_float_to_short.cc \ gri_short_to_float.cc \ gri_interleaved_short_to_complex.cc \ @@ -178,6 +180,8 @@ gr_deinterleave.h \ gr_fake_channel_coder_pp.h \ gr_float_to_short.h \ + gr_float_to_char.h \ + gr_float_to_uchar.h \ gr_fft_vcc.h \ gr_fft_vfc.h \ gr_firdes.h \ @@ -224,6 +228,7 @@ gri_debugger_hook.h \ gri_fft.h \ gri_float_to_char.h \ + gri_float_to_uchar.h \ gri_float_to_short.h \ gri_interleaved_short_to_complex.h \ gri_lfsr_15_1_0.h \ @@ -253,6 +258,7 @@ gr_fft_vcc.i \ gr_fft_vfc.i \ gr_float_to_char.i \ + gr_float_to_uchar.i \ gr_float_to_complex.i \ gr_float_to_short.i \ gr_frequency_modulator_fc.i \ Index: src/lib/general/general.i =================================================================== RCS file: /cvsroot/gnuradio/gnuradio-core/src/lib/general/general.i,v retrieving revision 1.30 diff -u -b -B -r1.30 general.i --- src/lib/general/general.i 30 Jul 2005 21:29:25 -0000 1.30 +++ src/lib/general/general.i 8 Aug 2005 14:53:41 -0000 @@ -43,6 +43,7 @@ #include <gr_fft_vfc.h> #include <gr_float_to_short.h> #include <gr_float_to_char.h> +#include <gr_float_to_uchar.h> #include <gr_short_to_float.h> #include <gr_frequency_modulator_fc.h> #include <gr_bytes_to_syms.h> @@ -89,6 +90,7 @@ %include "gr_fft_vfc.i" %include "gr_float_to_short.i" %include "gr_float_to_char.i" +%include "gr_float_to_uchar.i" %include "gr_short_to_float.i" %include "gr_frequency_modulator_fc.i" %include "gr_bytes_to_syms.i" Index: src/lib/general/gr_float_to_uchar.cc =================================================================== RCS file: src/lib/general/gr_float_to_uchar.cc diff -N src/lib/general/gr_float_to_uchar.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/lib/general/gr_float_to_uchar.cc 8 Aug 2005 14:53:42 -0000 @@ -0,0 +1,58 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gr_float_to_uchar.h> +#include <gr_io_signature.h> +#include <gri_float_to_uchar.h> + +gr_float_to_uchar_sptr +gr_make_float_to_uchar () +{ + return gr_float_to_uchar_sptr (new gr_float_to_uchar ()); +} + +gr_float_to_uchar::gr_float_to_uchar () + : gr_sync_block ("gr_float_to_uchar", + gr_make_io_signature (1, 1, sizeof (float)), + gr_make_io_signature (1, 1, sizeof (unsigned char))) +{ +} + +int +gr_float_to_uchar::work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const float *in = (const float *) input_items[0]; + unsigned char *out = (unsigned char *) output_items[0]; + + gri_float_to_uchar (in, out, noutput_items); + + return noutput_items; +} + + + Index: src/lib/general/gr_float_to_uchar.h =================================================================== RCS file: src/lib/general/gr_float_to_uchar.h diff -N src/lib/general/gr_float_to_uchar.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/lib/general/gr_float_to_uchar.h 8 Aug 2005 14:53:42 -0000 @@ -0,0 +1,51 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef INCLUDED_GR_FLOAT_TO_UCHAR_H +#define INCLUDED_GR_FLOAT_TO_UCHAR_H + +#include <gr_sync_block.h> + +class gr_float_to_uchar; +typedef boost::shared_ptr<gr_float_to_uchar> gr_float_to_uchar_sptr; + +gr_float_to_uchar_sptr +gr_make_float_to_uchar (); + +/*! + * \brief Convert stream of float to a stream of unsigned char + * \ingroup converter + */ + +class gr_float_to_uchar : public gr_sync_block +{ + friend gr_float_to_uchar_sptr gr_make_float_to_uchar (); + gr_float_to_uchar (); + + public: + virtual int work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + + +#endif /* INCLUDED_GR_FLOAT_TO_UCHAR_H */ Index: src/lib/general/gr_float_to_uchar.i =================================================================== RCS file: src/lib/general/gr_float_to_uchar.i diff -N src/lib/general/gr_float_to_uchar.i --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/lib/general/gr_float_to_uchar.i 8 Aug 2005 14:53:42 -0000 @@ -0,0 +1,30 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +GR_SWIG_BLOCK_MAGIC(gr,float_to_uchar) + +gr_float_to_uchar_sptr gr_make_float_to_uchar (); + +class gr_float_to_uchar : public gr_sync_block +{ + gr_float_to_uchar (); +}; Index: src/lib/general/gri_float_to_uchar.cc =================================================================== RCS file: src/lib/general/gri_float_to_uchar.cc diff -N src/lib/general/gri_float_to_uchar.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/lib/general/gri_float_to_uchar.cc 8 Aug 2005 14:53:42 -0000 @@ -0,0 +1,42 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#define _ISOC9X_SOURCE +#include <gri_float_to_uchar.h> +#include <math.h> + +static const int MIN_UCHAR = 0; +static const int MAX_UCHAR = 255; + + +void +gri_float_to_uchar (const float *in, unsigned char *out, int nsamples) +{ + for (int i = 0; i < nsamples; i++){ + long int r = (long int) rint (in[i]); + if (r < MIN_UCHAR) + r = MIN_UCHAR; + else if (r > MAX_UCHAR) + r = MAX_UCHAR; + out[i] = r; + } +} Index: src/lib/general/gri_float_to_uchar.h =================================================================== RCS file: src/lib/general/gri_float_to_uchar.h diff -N src/lib/general/gri_float_to_uchar.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/lib/general/gri_float_to_uchar.h 8 Aug 2005 14:53:42 -0000 @@ -0,0 +1,32 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef INCLUDED_GRI_FLOAT_TO_UCHAR_H +#define INCLUDED_GRI_FLOAT_TO_UCHAR_H + +/*! + * convert array of floats to unsigned chars with rounding and saturation. + */ +void gri_float_to_uchar (const float *in, unsigned char *out, int nsamples); + +#endif /* INCLUDED_GRI_FLOAT_TO_UCHAR_H */ +
_______________________________________________ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org http://lists.gnu.org/mailman/listinfo/discuss-gnuradio