From: dev Date: Sun, 25 Nov 2012 09:07:23 +0000 (+0900) Subject: uint*_tをuint_fast*_tに変更 X-Git-Url: http://www.fmaj7b5.info/git?p=cuda.git;a=commitdiff_plain;h=9c4ea7a2596620dcb156a00d12bc55c07ba03339 uint*_tをuint_fast*_tに変更 --- diff --git a/binarize/binarize.cpp b/binarize/binarize.cpp index 792b290..f25bacd 100644 --- a/binarize/binarize.cpp +++ b/binarize/binarize.cpp @@ -27,12 +27,12 @@ using namespace FM7b5; -static void binarize_cpu(ImageGray& out, const ImageGray& in, const uint8_t thres = 128); +static void binarize_cpu(ImageGray& out, const ImageGray& in, const uint_fast8_t thres = 128); int _tmain(int argc, _TCHAR* argv[]) { try { - const uint8_t thres(128); + const uint_fast8_t thres(128); ImageGray image; image = loadPGM("..\\img\\sine.pgm"); @@ -55,7 +55,7 @@ int _tmain(int argc, _TCHAR* argv[]) } void -binarize_cpu(ImageGray& out, const ImageGray& in, const uint8_t thres) +binarize_cpu(ImageGray& out, const ImageGray& in, const uint_fast8_t thres) { if (in.width() != out.width() || in.height() != out.height()) { throw std::runtime_error("sizes of input and output images are diferent."); diff --git a/binarize/binarize.cu b/binarize/binarize.cu index 3d8a8bd..90c056f 100644 --- a/binarize/binarize.cu +++ b/binarize/binarize.cu @@ -24,7 +24,7 @@ using namespace FM7b5; void -FM7b5::binarize_gpu(ImageGray& out, const ImageGray& in, const uint8_t thres) +FM7b5::binarize_gpu(ImageGray& out, const ImageGray& in, const uint_fast8_t thres) { if (in.width() != out.width() || in.height() != out.height()) { throw std::runtime_error("sizes of input and output images are diferent."); @@ -38,7 +38,7 @@ FM7b5::binarize_gpu(ImageGray& out, const ImageGray& in, const uint8_t thres) (height + threads_per_block.y - 1)/ threads_per_block.y); // allocate input/output memories - memory::LinearPitch d_in(width, height), d_out(width, height); + memory::LinearPitch d_in(width, height), d_out(width, height); // copy an input image to device memory d_in.copy_from(in.data(), bpp * width, height, in.stride()); diff --git a/binarize/binarize.cuh b/binarize/binarize.cuh index e8b690e..52d8ddb 100644 --- a/binarize/binarize.cuh +++ b/binarize/binarize.cuh @@ -25,7 +25,7 @@ namespace FM7b5 { template __global__ void - binarize(const MDView out, const MDView in, const size_t width, const size_t height, const uint8_t thres) + binarize(const MDView out, const MDView in, const size_t width, const size_t height, const uint_fast8_t thres) { const size_t w(blockDim.x * blockIdx.x + threadIdx.x); const size_t h(blockDim.y * blockIdx.y + threadIdx.y); diff --git a/binarize/binarize.h b/binarize/binarize.h index 738dc05..2de2835 100644 --- a/binarize/binarize.h +++ b/binarize/binarize.h @@ -22,7 +22,7 @@ namespace FM7b5 { - void binarize_gpu(ImageGray& out, const ImageGray& in, const uint8_t thres = 128); + void binarize_gpu(ImageGray& out, const ImageGray& in, const uint_fast8_t thres = 128); } #endif /* FM7b5_BINARIZE_H */ diff --git a/libutils/Image.h b/libutils/Image.h index 4e60da0..2bbc5c0 100644 --- a/libutils/Image.h +++ b/libutils/Image.h @@ -31,7 +31,7 @@ namespace FM7b5 public: typedef T pixel_type; typedef Image image_type; - typedef std::uint8_t raw_type; + typedef std::uint_fast8_t raw_type; Image(); Image(const size_t width, const size_t height, const size_t stride = 0); @@ -153,7 +153,7 @@ namespace FM7b5 } /* typedefs for convinience */ - typedef Image ImageGray; + typedef Image ImageGray; } -#endif /* FM7b5_IMAGE_H */ \ No newline at end of file +#endif /* FM7b5_IMAGE_H */ diff --git a/libutils/ImageIO.cpp b/libutils/ImageIO.cpp index 309e8ea..de43f35 100644 --- a/libutils/ImageIO.cpp +++ b/libutils/ImageIO.cpp @@ -43,7 +43,7 @@ static bool skip_comment(FILE* fp); static bool read_end_of_line(FILE* fp); -Image +Image FM7b5::loadPGM(const std::string& filename) { FILE* fp(nullptr); @@ -69,7 +69,7 @@ FM7b5::loadPGM(const std::string& filename) throw std::runtime_error(__FUNCTION__ ": supported depth is 255 only."); } - Image img(header.width, header.height); + Image img(header.width, header.height); switch (header.magic[1]) { case '2': // Gray ASCII format @@ -82,7 +82,7 @@ FM7b5::loadPGM(const std::string& filename) throw std::runtime_error(__FUNCTION__ ": invalid data."); } - img(w, h) = static_cast(val); + img(w, h) = static_cast(val); } } break; @@ -90,7 +90,7 @@ FM7b5::loadPGM(const std::string& filename) case '5': // Gray binary format { const size_t size(header.width * header.height); - size_t ret = fread(img.data(), sizeof(std::uint8_t), size, fp); + size_t ret = fread(img.data(), sizeof(std::uint_fast8_t), size, fp); if (ret != size) { throw std::runtime_error(__FUNCTION__ ": insufficient data."); } diff --git a/libutils/ImageIO.h b/libutils/ImageIO.h index c859b3d..65e50d4 100644 --- a/libutils/ImageIO.h +++ b/libutils/ImageIO.h @@ -26,7 +26,7 @@ namespace FM7b5 { - Image loadPGM(const std::string& filename); + Image loadPGM(const std::string& filename); template void savePGM(const Image& image, const std::string& filename); @@ -74,4 +74,4 @@ namespace FM7b5 } } -#endif /* FM7b5_IMAGE_IO_H */ \ No newline at end of file +#endif /* FM7b5_IMAGE_IO_H */ diff --git a/libutils/MDView.cuh b/libutils/MDView.cuh index 4035de4..3f28603 100644 --- a/libutils/MDView.cuh +++ b/libutils/MDView.cuh @@ -34,7 +34,7 @@ namespace FM7b5 { public: typedef T value_type; - typedef typename copy_const::type* byte_pointer_type; + typedef typename copy_const::type* byte_pointer_type; typedef typename copy_const::type* void_pointer_type; protected: