
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena Index: ChangeLog from Nicolas Ballas <ballas@lrde.epita.fr> Use memcpy_ in level::paste. * mln/core/image/image1d.hh: Replace array by buffer in element method. * mln/level/memcpy_.hh: Replace operator[] by element(). * mln/level/paste.spe.hh: Add paste_fastest and update dispatch. * mln/level/fill_with_value.spe.hh: Update doc. core/image/image1d.hh | 4 ++-- level/fill_with_value.spe.hh | 1 - level/memcpy_.hh | 19 ++++++++++++------- level/paste.spe.hh | 42 +++++++++++++++++++++++++++++------------- 4 files changed, 43 insertions(+), 23 deletions(-) Index: mln/core/image/image1d.hh --- mln/core/image/image1d.hh (revision 2784) +++ mln/core/image/image1d.hh (working copy) @@ -448,7 +448,7 @@ image1d<T>::element(unsigned ind) const { mln_precondition(this->has(point1d(ind))); - return this->data_->array_[ind]; + return this->data_->buffer_[ind]; } template <typename T> @@ -457,7 +457,7 @@ image1d<T>::element(unsigned ind) { mln_precondition(this->has(point1d(ind))); - return this->data_->array_[ind]; + return this->data_->buffer_[ind]; } template <typename T> Index: mln/level/memcpy_.hh --- mln/level/memcpy_.hh (revision 2784) +++ mln/level/memcpy_.hh (working copy) @@ -125,13 +125,18 @@ mln_precondition(dest.ima().has_data()); mln_precondition(src.ima().has_data()); - mln_precondition(&dest.val() >= &dest.ima()[0]); - mln_precondition(&dest.val() < &dest.ima()[0] + dest.ima().nelements()); - mln_precondition(&dest.val() + n <= &dest.ima()[0] + dest.ima().nelements()); - - mln_precondition(&src.val() >= &src.ima()[0]); - mln_precondition(&src.val() < &src.ima()[0] + src.ima().nelements()); - mln_precondition(&src.val() + n <= &src.ima()[0] + src.ima().nelements()); + mln_precondition(&dest.val() >= &dest.ima().element(0)); + mln_precondition(&dest.val() < &dest.ima().element(0) + + dest.ima().nelements()); + + mln_precondition(&dest.val() + n <= &dest.ima().element(0) + + dest.ima().nelements()); + + mln_precondition(&src.val() >= &src.ima().element(0)); + mln_precondition(&src.val() < &src.ima().element(0) + + src.ima().nelements()); + mln_precondition(&src.val() + n <= &src.ima().element(0) + + src.ima().nelements()); impl::memcpy__(dest, src, n); Index: mln/level/paste.spe.hh --- mln/level/paste.spe.hh (revision 2784) +++ mln/level/paste.spe.hh (working copy) @@ -39,6 +39,8 @@ # error "Forbidden inclusion of *.spe.hh" # endif // ! MLN_LEVEL_PASTE_HH +# include <mln/core/pixel.hh> +# include <mln/level/fill_with_value.hh> # include <mln/level/memcpy_.hh> @@ -114,21 +116,34 @@ trace::entering("level::impl::paste_fast"); } - template <typename I, typename J> - void paste_fast_singleton(const Image<I>& input_, Image<J>& output_) + void paste_fastest(const Image<I>& input_, Image<J>& output_) { - trace::entering("level::impl::paste_fast_singleton"); + trace::entering("level::impl::paste_fastest"); const I& input = exact(input_); J& output = exact(output_); level::internal::paste_tests(input, output); - mln_pixter(J) po(output); + pixel<const I> src (input); + pixel<J> dst(output); + *(src.address_()) = input.buffer(); + *(dst.address_()) = output.buffer(); + + memcpy_(dst, src, input.nelements()); + + trace::entering("level::impl::paste_fastest"); + } + + template <typename I, typename J> + void paste_singleton(const Image<I>& input_, Image<J>& output_) + { + trace::entering("level::impl::paste_fast_singleton"); + + const I& input = exact(input_); - for_all(po) - po.val() = input.val(); + level::fill_with_value(output_, input.val()); trace::entering("level::impl::paste_fast_singleton"); } @@ -152,10 +167,10 @@ const I& input = exact(input_); J& output = exact(output_); - if (input.domain() == output.domain()) - impl::paste_fast(input, output); + if (input.border() == output.border()) + impl::paste_fastest(input, output); else - impl::generic::paste(input, output); + impl::paste_fast(input, output); } template <typename I, typename J> @@ -167,7 +182,7 @@ const Image<I>& input, Image<J>& output) { - impl::paste_fast(input, output); + impl::paste_fastest(input, output); } @@ -196,11 +211,11 @@ template <typename I, typename J> inline void paste_(trait::image::value_storage::singleton, - trait::image::value_storage::one_block, + trait::image::value_storage::any, const Image<I>& input, Image<J>& output) { - impl::paste_fast_singleton(input, output); + impl::paste_singleton(input, output); } @@ -219,7 +234,8 @@ if (mlc_is(mln_trait_image_value_alignement(I), trait::image::value_alignement::with_grid)::value && mlc_is(mln_trait_image_value_alignement(J), - trait::image::value_alignement::with_grid)::value) + trait::image::value_alignement::with_grid)::value && + input.domain() == output.domain()) { paste_(mln_trait_image_value_access(I)(), mln_trait_image_value_access(J)(), Index: mln/level/fill_with_value.spe.hh --- mln/level/fill_with_value.spe.hh (revision 2784) +++ mln/level/fill_with_value.spe.hh (working copy) @@ -210,7 +210,6 @@ } - /// FIXME: // This specialization is only here to deal with image which have // non-updated properties (vw_io). template <typename I, typename V>