|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r85337 - sandbox/gil/boost/gil/extension/io2/backends/libtiff
From: dsaritz_at_[hidden]
Date: 2013-08-13 18:09:11
Author: psiha
Date: 2013-08-13 18:09:10 EDT (Tue, 13 Aug 2013)
New Revision: 85337
URL: http://svn.boost.org/trac/boost/changeset/85337
Log:
Minor refactoring and stylistic changes.
Text files modified:
sandbox/gil/boost/gil/extension/io2/backends/libtiff/backend.hpp | 30 +++++++++++--------
sandbox/gil/boost/gil/extension/io2/backends/libtiff/reader.hpp | 61 +++++++++++++++++++++------------------
2 files changed, 50 insertions(+), 41 deletions(-)
Modified: sandbox/gil/boost/gil/extension/io2/backends/libtiff/backend.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/backends/libtiff/backend.hpp Tue Aug 13 18:08:26 2013 (r85336)
+++ sandbox/gil/boost/gil/extension/io2/backends/libtiff/backend.hpp 2013-08-13 18:09:10 EDT (Tue, 13 Aug 2013) (r85337)
@@ -276,12 +276,11 @@
template <class View>
void set_buffers( View const & view, mpl::true_ /*is planar*/ )
{
+ number_of_planes_ = num_channels<View>::value;
for ( unsigned int plane( 0 ); plane < num_channels<View>::value; ++plane )
{
plane_buffers_[ plane ] = gil_reinterpret_cast<unsigned char *>( planar_view_get_raw_data( view, plane ) );
}
- BOOST_ASSERT( plane == num_channels<View>::value );
- number_of_planes_ = num_channels<View>::value;
}
template <class View>
@@ -292,7 +291,7 @@
}
void operator=( tiff_view_data_t const & );
-};
+}; // struct tiff_view_data_t
struct tiff_writer_view_data_t;
@@ -338,7 +337,7 @@
BOOST_STATIC_CONSTANT( unsigned int, desired_alignment = sizeof( void * ) );
BOOST_STATIC_CONSTANT( bool , builtin_conversion = false );
-};
+}; // struct backend_traits<libtiff_image>
////////////////////////////////////////////////////////////////////////////////
@@ -424,12 +423,12 @@
// them when possible.
// (20.07.2011.) (Domagoj Saric)
T value;
- #ifdef _MSC_VER
- T * p_value( &value );
- BOOST_VERIFY( ::TIFFVGetFieldDefaulted( &lib_object(), tag, reinterpret_cast<va_list>( &p_value ) ) );
- #else
- BOOST_VERIFY( ::TIFFGetFieldDefaulted ( &lib_object(), tag, &value ) );
- #endif // _MSC_VER
+ #ifdef _MSC_VER
+ T * p_value( &value );
+ BOOST_VERIFY( ::TIFFVGetFieldDefaulted( &lib_object(), tag, reinterpret_cast<va_list>( &p_value ) ) );
+ #else
+ BOOST_VERIFY( ::TIFFGetFieldDefaulted ( &lib_object(), tag, &value ) );
+ #endif // _MSC_VER
return value;
}
@@ -437,7 +436,12 @@
std::pair<T1, T2> get_field( ttag_t const tag, int & cumulative_result ) const
{
T1 first; T2 second; // avoid the std::pair default constructor
- cumulative_result &= ::TIFFGetFieldDefaulted( &lib_object(), tag, &first, &second );
+ #ifdef _MSC_VER
+ void * values[ 2 ] = { &first, &second };
+ cumulative_result &= ::TIFFVGetFieldDefaulted( &lib_object(), tag, reinterpret_cast<va_list>( &values ) );
+ #else
+ cumulative_result &= ::TIFFGetFieldDefaulted ( &lib_object(), tag, &first, &second );
+ #endif // _MSC_VER
return std::pair<T1, T2>( first, second );
}
@@ -462,9 +466,9 @@
private:
TIFF * const p_tiff_;
-};
+}; // class libtiff_image
-#if defined(BOOST_MSVC)
+#if defined( BOOST_MSVC )
# pragma warning( pop )
#endif
Modified: sandbox/gil/boost/gil/extension/io2/backends/libtiff/reader.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/backends/libtiff/reader.hpp Tue Aug 13 18:08:26 2013 (r85336)
+++ sandbox/gil/boost/gil/extension/io2/backends/libtiff/reader.hpp 2013-08-13 18:09:10 EDT (Tue, 13 Aug 2013) (r85337)
@@ -7,7 +7,8 @@
///
/// Copyright (c) Domagoj Saric 2010.-2013.
///
-/// Use, modification and distribution is subject to the Boost Software License, Version 1.0.
+/// Use, modification and distribution is subject to the
+/// Boost Software License, Version 1.0.
/// (See accompanying file LICENSE_1_0.txt or copy at
/// http://www.boost.org/LICENSE_1_0.txt)
///
@@ -89,15 +90,8 @@
template <typename DeviceHandle>
explicit native_reader( DeviceHandle const handle )
:
- libtiff_image
- (
- handle,
- &input_device<DeviceHandle>::read,
- NULL,
- NULL,
- NULL
- ),
- format_( get_format() )
+ libtiff_image( handle, &input_device<DeviceHandle>::read, NULL, NULL, NULL ),
+ format_ ( get_format() )
{}
public:
@@ -135,16 +129,16 @@
sequential_row_read_state() : position_( 0 ) {}
unsigned int position_;
- };
+ }; // class sequential_row_read_state
static sequential_row_read_state begin_sequential_row_read() { return sequential_row_read_state(); }
- void read_row( sequential_row_read_state & state, unsigned char * const p_row_storage, unsigned int const plane = 0 ) const
+ void read_row( sequential_row_read_state & state, void * const p_row_storage, tsample_t const plane = 0 ) const
{
state.accumulate_greater
(
- ::TIFFReadScanline( &lib_object(), p_row_storage, state.position_++, static_cast<tsample_t>( plane ) ),
+ ::TIFFReadScanline( &lib_object(), p_row_storage, state.position_++, plane ),
0
);
}
@@ -154,7 +148,7 @@
static sequential_tile_read_state begin_sequential_tile_access() { return begin_sequential_row_read(); }
- void read_tile( sequential_row_read_state & state, unsigned char * const p_tile_storage ) const
+ void read_tile( sequential_row_read_state & state, void * const p_tile_storage ) const
{
state.accumulate_greater
(
@@ -244,20 +238,20 @@
tile_width ( source.get_field<uint32>( TIFFTAG_TILEWIDTH ) ),
row_tiles ( source.get_field<uint32>( TIFFTAG_IMAGEWIDTH ) / tile_width ),
size_of_pixel ( ( source.format_bits().planar_configuration == PLANARCONFIG_CONTIG ? source.format_bits().samples_per_pixel : 1 ) * source.format_bits().bits_per_sample / 8 ),
- tile_width_bytes ( tile_width * size_of_pixel ),
- tile_size_bytes ( tile_width_bytes * tile_height ),
+ tile_width_bytes ( tile_width * size_of_pixel ),
+ tile_size_bytes ( tile_width_bytes * tile_height ),
p_tile_buffer ( new unsigned char[ tile_size_bytes * ( nptcc ? source.format_bits().samples_per_pixel : 1 ) ] ),
last_row_tile_width ( modulo_unless_zero( dimensions.x, tile_width ) /*dimensions.x % tile_width*/ ),
tiles_per_row ( ( dimensions.x / tile_width ) + /*( last_row_tile_width != 0 )*/ ( ( dimensions.x % tile_width ) != 0 ) ),
- last_row_tile_width_bytes ( last_row_tile_width * size_of_pixel ),
- last_row_tile_size_bytes ( last_row_tile_width_bytes * tile_height ),
- current_row_tiles_remaining( tiles_per_row ),
- starting_tile ( offset / tile_height * tiles_per_row ),
- rows_to_skip ( offset % tile_height ),
+ last_row_tile_width_bytes ( last_row_tile_width * size_of_pixel ),
+ last_row_tile_size_bytes ( last_row_tile_width_bytes * tile_height ),
+ current_row_tiles_remaining( tiles_per_row ),
+ starting_tile ( offset / tile_height * tiles_per_row ),
+ rows_to_skip ( offset % tile_height ),
number_of_tiles ( round_up_divide( dimensions.y, tile_height ) * tiles_per_row * ( source.format_bits().planar_configuration == PLANARCONFIG_SEPARATE ? source.format_bits().samples_per_pixel : 1 ) )
{
- BOOST_ASSERT( static_cast<tsize_t>( tile_width_bytes ) == ::TIFFTileRowSize( &source.lib_object() ) );
- BOOST_ASSERT( static_cast<tsize_t>( tile_size_bytes ) == ::TIFFTileSize ( &source.lib_object() ) );
+ BOOST_ASSERT( tile_width_bytes == unsigned( ::TIFFTileRowSize( &source.lib_object() ) ) );
+ BOOST_ASSERT( tile_size_bytes == unsigned( ::TIFFTileSize ( &source.lib_object() ) ) );
BOOST_ASSERT( starting_tile + number_of_tiles <= ::TIFFNumberOfTiles( &source.lib_object() ) );
if ( tile_height > static_cast<uint32>( dimensions.y ) )
{
@@ -276,8 +270,8 @@
uint32 const row_tiles ;
unsigned int const size_of_pixel ;
- size_t const tile_width_bytes;
- tsize_t const tile_size_bytes ;
+ unsigned int const tile_width_bytes;
+ unsigned int const tile_size_bytes ;
scoped_array<unsigned char> p_tile_buffer;
@@ -311,7 +305,7 @@
{
cumulative_result result;
- if ( can_do_tile_access() )
+ if ( can_do_tile_access() ) /* tiled decoding */
{
tile_setup_t setup( *this, view_data.dimensions_, view_data.offset_, false );
@@ -325,7 +319,18 @@
bool const last_row_tile ( !--setup.current_row_tiles_remaining );
unsigned int const this_tile_width_bytes( last_row_tile ? setup.last_row_tile_width_bytes : setup.tile_width_bytes );
- result.accumulate_equal( ::TIFFReadEncodedTile( &lib_object(), current_tile, setup.p_tile_buffer.get(), setup.tile_size_bytes ), setup.tile_size_bytes );
+ result.accumulate_equal
+ (
+ ::TIFFReadEncodedTile
+ (
+ &lib_object(),
+ current_tile,
+ setup.p_tile_buffer.get(),
+ setup.tile_size_bytes
+ ),
+ setup.tile_size_bytes
+ );
+
unsigned char const * p_tile_buffer_location( setup.p_tile_buffer.get() + ( setup.rows_to_skip * this_tile_width_bytes ) );
unsigned char * p_target_local ( p_target );
for ( unsigned int row( setup.rows_to_skip ); row < setup.rows_to_read_per_tile; ++row )
@@ -350,7 +355,7 @@
BOOST_ASSERT( p_target == view_data.plane_buffers_[ plane ] + ( view_data.stride_ * view_data.dimensions_.y ) );
}
}
- else
+ else /* row per row decoding */
{
BOOST_ASSERT( ::TIFFScanlineSize( &lib_object() ) <= static_cast<tsize_t>( view_data.stride_ ) );
for ( unsigned int plane( 0 ); plane < view_data.number_of_planes_; ++plane )
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk