[Hdrflow-svn] SF.net SVN: hdrflow: [83] lib/openlibraries
Status: Pre-Alpha
Brought to you by:
glslang
|
From: <gl...@us...> - 2007-04-18 22:05:55
|
Revision: 83
http://hdrflow.svn.sourceforge.net/hdrflow/?rev=83&view=rev
Author: glslang
Date: 2007-04-18 15:05:49 -0700 (Wed, 18 Apr 2007)
Log Message:
-----------
+ guard fixes
+ dpx storer
Modified Paths:
--------------
lib/openlibraries/src/openimagelib/il/utility.hpp
lib/openlibraries/src/openimagelib/plugins/dpx/dpx_plugin.cpp
lib/openlibraries/src/openmedialib/plugins/oil/oil_plugin.cpp
lib/openlibraries/test/openmedialib/store/store.cpp
Modified: lib/openlibraries/src/openimagelib/il/utility.hpp
===================================================================
--- lib/openlibraries/src/openimagelib/il/utility.hpp 2007-04-17 22:24:01 UTC (rev 82)
+++ lib/openlibraries/src/openimagelib/il/utility.hpp 2007-04-18 22:05:49 UTC (rev 83)
@@ -14,7 +14,7 @@
inline image_type_ptr conform( image_type_ptr image, int flags )
{
- if ( !image->matching( flags ) )
+ if ( image && !image->matching( flags ) )
image = image_type_ptr( static_cast<image_type*>( image->clone( flags ) ) );
return image;
}
Modified: lib/openlibraries/src/openimagelib/plugins/dpx/dpx_plugin.cpp
===================================================================
--- lib/openlibraries/src/openimagelib/plugins/dpx/dpx_plugin.cpp 2007-04-17 22:24:01 UTC (rev 82)
+++ lib/openlibraries/src/openimagelib/plugins/dpx/dpx_plugin.cpp 2007-04-18 22:05:49 UTC (rev 83)
@@ -101,6 +101,13 @@
image_element element[ 8 ];
char reserved[ 52 ];
};
+
+ struct additional_image_orientation_information_header
+ {
+ float x_scanned_size;
+ float y_scanned_size;
+ char reserved[ 20 ];
+ };
struct image_orientation_information_header
{
@@ -116,6 +123,7 @@
char input_device_serial_name[ 32 ];
unsigned short border_validity[ 4 ];
unsigned int sar[ 2 ];
+ additional_image_orientation_information_header additional;
};
struct motion_picture_film_information_header
@@ -610,8 +618,6 @@
if( !Read_s( file, ( char* ) &tv_info_header, sizeof( tv_info_header ), sizeof( tv_info_header ) ) )
return il::image_type_ptr( );
- file.rdbuf( )->pubseekoff( header.user_header_length, std::ios::cur );
-
bool swab = header.magic == 0x58504453 ? true : false;
if( swab )
@@ -688,18 +694,66 @@
return im;
}
-
- // Needs to move into IL traits.
- void element_info( const std::wstring& pf, unsigned char& bitdepth )
+
+ // IL enum support for colour spaces... and add swizzling support.
+ bool element_info( int i, const std::wstring& pf, unsigned char& bitdepth, unsigned char& descriptor, unsigned char& transfer, unsigned char& colorimetric )
{
- if( pf == L"r8g8b8" || pf == L"r8g8b8a8" )
- bitdepth = 8;
- else if( pf == L"r10g10b10" || pf == L"r10g10b10a10" )
- bitdepth = 10;
- else if( pf == L"r12g12b12" || pf == L"r12g12b12a12" )
- bitdepth = 12;
- else if( pf == L"r16g16b16" || pf == L"r16g16b16a16" )
- bitdepth = 16;
+ transfer = 2, colorimetric = 2;
+
+ if( pf == L"r8g8b8" || pf == L"r8g8b8a8" || pf == L"r10g10b10" || pf == L"r10g10b10a10"
+ || pf == L"r12g12b12" || pf == L"r12g12b12a12" || pf == L"r16g16b16" || pf == L"r16g16b16a16"
+ || pf == L"r8g8b8log" || pf == L"r8g8b8a8log" || pf == L"r10g10b10log" || pf == L"r10g10b10a10log"
+ || pf == L"r12g12b12log" || pf == L"r12g12b12a12log" || pf == L"r16g16b16log" || pf == L"r16g16b16a16log" )
+ {
+ if( pf == L"r8g8b8" || pf == L"r8g8b8a8" || pf == L"r8g8b8log" || pf == L"r8g8b8a8log" )
+ bitdepth = 8;
+ else if( pf == L"r10g10b10" || pf == L"r10g10b10a10" || pf == L"r10g10b10log" || pf == L"r10g10b10a10log" )
+ bitdepth = 10;
+ else if( pf == L"r12g12b12" || pf == L"r12g12b12a12" || pf == L"r12g12b12log" || pf == L"r12g12b12a12log" )
+ bitdepth = 12;
+ else if( pf == L"r16g16b16" || pf == L"r16g16b16a16" || pf == L"r16g16b16log" || pf == L"r16g16b16a16log" )
+ bitdepth = 16;
+
+ if( pf == L"r8g8b8" || pf == L"r10g10b10" || pf == L"r12g12b12" || pf == L"r16g16b16"
+ || pf == L"r8g8b8log" || pf == L"r10g10b10log" || pf == L"r12g12b12log" || pf == L"r16g16b16log" )
+ descriptor = IMAGE_ELEMENT_DESC_RGB;
+ else
+ descriptor = IMAGE_ELEMENT_DESC_RGBA;
+
+ if( pf == L"r8g8b8log" || pf == L"r8g8b8a8log" || pf == L"r10g10b10log" || pf == L"r10g10b10a10log"
+ || pf == L"r12g12b12log" || pf == L"r12g12b12a12log" || pf == L"r16g16b16log" || pf == L"r16g16b16a16log" )
+ transfer = 1, colorimetric = 1;
+
+ return true;
+ }
+ else if( pf == L"r8g8b8p" || pf == L"r8g8b8a8p" || pf == L"r10g10b10p" || pf == L"r10g10b10a10p"
+ || pf == L"r12g12b12p" || pf == L"r12g12b12a12p" || pf == L"r16g16b16p" || pf == L"r16g16b16a16p" )
+ {
+ if( pf == L"r8g8b8p" || pf == L"r8g8b8a8p" )
+ bitdepth = 8;
+ else if( pf == L"r10g10b10p" || pf == L"r10g10b10a10p" )
+ bitdepth = 10;
+ else if( pf == L"r12g12b12p" || pf == L"r12g12b12a12p" )
+ bitdepth = 12;
+ else if( pf == L"r16g16b16p" || pf == L"r16g16b16a16p" )
+ bitdepth = 16;
+
+ if( i == 0 )
+ descriptor = IMAGE_ELEMENT_DESC_RED;
+ else if( i == 1 )
+ descriptor = IMAGE_ELEMENT_DESC_GREEN;
+ else if( i == 2 )
+ descriptor = IMAGE_ELEMENT_DESC_BLUE;
+ else if( i == 3 )
+ descriptor = IMAGE_ELEMENT_DESC_ALPHA;
+
+ return true;
+ }
+ else if( pf == L"l12a12p" || pf == L"l16a16p" )
+ {
+ }
+
+ return false;
}
bool store_dpx( const fs::path& path, const il::image_type_ptr& im )
@@ -709,18 +763,13 @@
il::image_type::size_type width = im->width( );
il::image_type::size_type height = im->height( );
-
- unsigned char bitdepth;
- element_info( im->pf( ), bitdepth );
- int linesize = bytes_per_line( bitdepth, im->linesize( ), 0 );
-
file_information_header header;
memset( &header, 0, sizeof( header ) );
header.magic = 0x53445058;
- header.offset = 2048; // fixed value if no user defined data is present. check the specification.
- strcpy( header.version, "V2.0" ); // xxx
- header.filesize = 2048 + linesize * height;
+ header.offset = 2080; // fixed value if no user defined data is present. check the specification.
+ strcpy( header.version, "V2.0" );
+ header.filesize = 2080 + im->size( );
image_information_header image_info_header;
memset( &image_info_header, 0, sizeof( image_info_header ) );
@@ -729,20 +778,30 @@
image_info_header.pixels_per_line = width;
image_info_header.lines_per_element = height;
+ int offset = 2080;
for( int i = 0; i < image_info_header.image_elements; ++i )
- {
- image_info_header.element[ i ].sign = 0;
- image_info_header.element[ i ].descriptor = 50; // xxx
- image_info_header.element[ i ].transfer = 2; // xxx
- image_info_header.element[ i ].colorimetric = 2; // xxx
- image_info_header.element[ i ].bitdepth = bitdepth;
- image_info_header.element[ i ].packing = 0;
- image_info_header.element[ i ].encoding = 0;
-
- if( !i )
- image_info_header.element[ i ].offset = 2048;
- else
- image_info_header.element[ i ].offset = image_info_header.element[ i - 1 ].offset + im->pitch( i - 1 ) * im->height( i - 1 );
+ {
+ unsigned char bitdepth, descriptor, transfer, colorimetric;
+ if( element_info( i, im->pf( ), bitdepth, descriptor, transfer, colorimetric ) )
+ {
+ image_info_header.element[ i ].sign = 0;
+ image_info_header.element[ i ].descriptor = descriptor;
+ image_info_header.element[ i ].transfer = transfer;
+ image_info_header.element[ i ].colorimetric = colorimetric;
+ image_info_header.element[ i ].bitdepth = bitdepth == 10 || bitdepth == 12 ? 16 : bitdepth;
+ image_info_header.element[ i ].packing = 0;
+ image_info_header.element[ i ].encoding = 0;
+
+ if( i > 0 )
+ {
+ if( bitdepth == 8 )
+ offset = 2080 + im->offset( i );
+ else
+ offset += im->linesize( i - 1 ) * height * sizeof( unsigned short );
+ }
+
+ image_info_header.element[ i ].offset = offset;
+ }
}
image_orientation_information_header image_orientation_info_header;
@@ -764,20 +823,33 @@
Write_s( file, ( char* ) &tv_info_header, sizeof( tv_info_header ) ) &&
Write_s( file, ( char* ) &user_defined_header, sizeof( user_defined_header ) ) ) )
return false;
-
+
for( int i = 0; i < image_info_header.image_elements; ++i )
{
- unsigned char* data = im->data( i );
-
- for( int j = 0; j < im->height( i ); ++j )
+ if( image_info_header.element[ i ].bitdepth == 8 )
{
- if( !Write_s( file, ( char* ) data, im->pitch( i ) ) )
- return false;
-
- data += im->pitch( i );
+ il::image_type::const_pointer data = im->data( i );
+ for( int j = 0; j < height; ++j )
+ {
+ if( !Write_s( file, ( char* ) data, im->pitch( i ) ) )
+ return false;
+
+ data += im->pitch( i );
+ }
}
+ else
+ {
+ unsigned short* data = ( unsigned short* ) im->data( i );
+ for( int j = 0; j < height; ++j )
+ {
+ if( !Write_s( file, ( char* ) data, im->linesize( i ) * sizeof( unsigned short ) ) )
+ return false;
+
+ data += im->pitch( i );
+ }
+ }
}
-
+
return true;
}
}
Modified: lib/openlibraries/src/openmedialib/plugins/oil/oil_plugin.cpp
===================================================================
--- lib/openlibraries/src/openmedialib/plugins/oil/oil_plugin.cpp 2007-04-17 22:24:01 UTC (rev 82)
+++ lib/openlibraries/src/openmedialib/plugins/oil/oil_plugin.cpp 2007-04-18 22:05:49 UTC (rev 83)
@@ -460,7 +460,6 @@
typedef pl::discovery<il_query_traits> discovery;
il::image_type_ptr image = frame->get_image( );
if ( image == 0 ) return false;
- image = il::convert( image, L"r8g8b8" );
std::ostringstream out;
out << path_;
Modified: lib/openlibraries/test/openmedialib/store/store.cpp
===================================================================
--- lib/openlibraries/test/openmedialib/store/store.cpp 2007-04-17 22:24:01 UTC (rev 82)
+++ lib/openlibraries/test/openmedialib/store/store.cpp 2007-04-18 22:05:49 UTC (rev 83)
@@ -57,13 +57,13 @@
void run( )
{
- //while( !done_ && input_->get_position( ) != input_->get_frames( ) )
+ while( !done_ && input_->get_position( ) != input_->get_frames( ) )
{
ml::frame_type_ptr frame = input_->fetch( );
if ( speed_ != 1 )
frame->set_audio( ml::audio_type_ptr( ) );
if ( !store_->push( frame ) )
- //break;
+ break;
boost::mutex::scoped_lock scoped_lock( mutex_ );
input_->seek( speed_, true );
}
@@ -80,7 +80,6 @@
int main( int argc, char* argv[ ] )
{
- // Load both oil and oml plugins since oml uses oil
opl::init( "" );
if ( argc > 2 )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|