void djvSpeedTest::convert() { DJV_DEBUG("djvSpeedTest::convert"); const struct Data { djvSpeed speed; double value; } data [] = { { djvSpeed(djvSpeed::FPS_23_976), 23.976 }, { djvSpeed(djvSpeed::FPS_24), 24.0 }, { djvSpeed(djvSpeed::FPS_29_97), 29.97 }, { djvSpeed(240, 1), 240.0 } }; const int dataCount = sizeof(data) / sizeof(data[0]); for (int i = 0; i < dataCount; ++i) { DJV_DEBUG_PRINT("speed = " << data[i].speed); const double value = djvSpeed::speedToFloat(data[i].speed); DJV_DEBUG_PRINT("value = " << value); DJV_ASSERT(djvMath::fuzzyCompare(value, data[i].value, 0.0001)); const djvSpeed speed = djvSpeed::floatToSpeed(value); DJV_ASSERT(data[i].speed == speed); } }
void djvSpeedTest::operators() { DJV_DEBUG("djvSpeedTest::operators"); { const djvSpeed a(djvSpeed::FPS_23_976), b(djvSpeed::FPS_23_976); DJV_ASSERT(a == b); DJV_ASSERT(a != djvSpeed()); } { djvSpeed speed; QStringList tmp; tmp << speed; tmp >> speed; DJV_ASSERT(speed == djvSpeed()); } { DJV_DEBUG_PRINT(djvSpeed()); } }
void djvOpenGlImageTest::ctors() { DJV_DEBUG("djvOpenGlImageTest::ctors"); { DJV_DEBUG_PRINT(djvOpenGlImageXform()); } { DJV_DEBUG_PRINT(djvOpenGlImageColor()); } { DJV_DEBUG_PRINT(djvOpenGlImageLevels()); } { DJV_DEBUG_PRINT(djvOpenGlImageDisplayProfile()); } { DJV_DEBUG_PRINT(djvOpenGlImageFilter()); DJV_DEBUG_PRINT(djvOpenGlImageFilter( djvOpenGlImageFilter::BOX, djvOpenGlImageFilter::TRIANGLE)); } { DJV_DEBUG_PRINT(djvOpenGlImageOptions()); } }
void Window::play(bool in) { DJV_DEBUG("Window::play"); DJV_DEBUG_PRINT("in = " << in); _play = in; play_update(); }
void djvSequenceUtilTest::stringToSequence() { DJV_DEBUG("djvSequenceUtilTest::stringToSequence"); const struct Data { QString a; djvSequence b; } data [] = { { "", djvSequence(djvFrameList()) }, { "1", djvSequence(djvFrameList() << 1) }, { "1-2", djvSequence(djvFrameList() << 1 << 2) }, { "1-3", djvSequence(djvFrameList() << 1 << 2 << 3) }, { "0001-0003", djvSequence(djvFrameList() << 1 << 2 << 3, 4) }, { "3-1", djvSequence(djvFrameList() << 3 << 2 << 1) }, { "1,2,3", djvSequence(djvFrameList() << 1 << 2 << 3) }, { "1-3,5", djvSequence(djvFrameList() << 1 << 2 << 3 << 5) }, { "1-3,5-6", djvSequence(djvFrameList() << 1 << 2 << 3 << 5 << 6) }, { "1-3,5-7", djvSequence(djvFrameList() << 1 << 2 << 3 << 5 << 6 << 7) }, { "1-3,3-1", djvSequence(djvFrameList() << 1 << 2 << 3 << 3 << 2 << 1) }, { "-1", djvSequence(djvFrameList() << -1) }, { "-1--2", djvSequence(djvFrameList() << -1 << -2) }, { "-1--3", djvSequence(djvFrameList() << -1 << -2 << -3) }, { "-0001--0003", djvSequence(djvFrameList() << -1 << -2 << -3, 4) }, { "-3--1", djvSequence(djvFrameList() << -3 << -2 << -1) }, { "-1,-2,-3", djvSequence(djvFrameList() << -1 << -2 << -3) }, { "-1--3,-5", djvSequence(djvFrameList() << -1 << -2 << -3 << -5) }, { "-1--3,-5--6", djvSequence(djvFrameList() << -1 << -2 << -3 << -5 << -6) }, { "-1--3,-5--7", djvSequence(djvFrameList() << -1 << -2 << -3 << -5 << -6 << -7) }, { "-1--3,-3--1", djvSequence(djvFrameList() << -1 << -2 << -3 << -3 << -2 << -1) }, { "-3-3", djvSequence(djvFrameList() << -3 << -2 << -1 << 0 << 1 << 2 << 3) }, { "3--3", djvSequence(djvFrameList() << 3 << 2 << 1 << 0 << -1 << -2 << -3) } }; const int dataCount = sizeof(data) / sizeof(Data); for (int i = 0; i < dataCount; ++i) { const djvSequence tmp = djvSequenceUtil::stringToSequence(data[i].a); DJV_DEBUG_PRINT(data[i].a << " = " << tmp); DJV_ASSERT(tmp == data[i].b); } }
void Window::frame_update() { DJV_DEBUG(String_Format("Window::frame_update(%%)").arg(int64_t(this))); DJV_DEBUG_PRINT("frame = " << _frame); callbacks(false); _slider->set(_frame); _widget->set(_movie.image(_frame)); _widget->redraw(); callbacks(true); }
void djvSequenceUtilTest::sequenceToString() { DJV_DEBUG("djvSequenceUtilTest::sequenceToString"); const struct Data { djvSequence a; QString b; } data [] = { { djvSequence(djvFrameList()), "" }, { djvSequence(djvFrameList() << 1), "1" }, { djvSequence(djvFrameList() << 1 << 2), "1-2" }, { djvSequence(djvFrameList() << 1 << 2 << 3), "1-3" }, { djvSequence(djvFrameList() << 1 << 2 << 3, 4), "0001-0003" }, { djvSequence(djvFrameList() << 3 << 2 << 1), "3-1" }, { djvSequence(djvFrameList() << 1 << 2 << 3 << 5), "1-3,5" }, { djvSequence(djvFrameList() << 1 << 2 << 3 << 5 << 6), "1-3,5-6" }, { djvSequence(djvFrameList() << 1 << 2 << 3 << 5 << 6 << 7), "1-3,5-7" }, { djvSequence(djvFrameList() << 1 << 2 << 3 << 3 << 2 << 1), "1-3,3-1" }, { djvSequence(djvFrameList() << -1), "-1" }, { djvSequence(djvFrameList() << -1 << -2), "-1--2" }, { djvSequence(djvFrameList() << -1 << -2 << -3), "-1--3" }, { djvSequence(djvFrameList() << -1 << -2 << -3, 4), "-0001--0003" }, { djvSequence(djvFrameList() << -3 << -2 << -1), "-3--1" }, { djvSequence(djvFrameList() << -1 << -2 << -3 << -5), "-1--3,-5" }, { djvSequence(djvFrameList() << -1 << -2 << -3 << -5 << -6), "-1--3,-5--6" }, { djvSequence(djvFrameList() << -1 << -2 << -3 << -5 << -6 << -7), "-1--3,-5--7" }, { djvSequence(djvFrameList() << -1 << -2 << -3 << -3 << -2 << -1), "-1--3,-3--1" }, { djvSequence(djvFrameList() << -3 << -2 << -1 << 0 << 1 << 2 << 3), "-3-3" }, { djvSequence(djvFrameList() << 3 << 2 << 1 << 0 << -1 << -2 << -3), "3--3" } }; const int dataCount = sizeof(data) / sizeof(Data); for (int i = 0; i < dataCount; ++i) { const QString tmp = djvSequenceUtil::sequenceToString(data[i].a); DJV_DEBUG_PRINT(data[i].a.frames << " = " << tmp); DJV_ASSERT(tmp == data[i].b); } }
void djvSequenceUtilTest::stringToFrame() { DJV_DEBUG("djvSequenceUtilTest::stringToFrame"); const struct Data { QString a; qint64 b; int pad; } data [] = { { "0", 0, 0 }, { "0000", 0, 4 }, { "0100", 100, 4 }, { "1000", 1000, 0 }, { "-1", -1, 0 }, { "-0001", -1, 4 }, { "-0100", -100, 4 }, { "-1000", -1000, 0 }, { "1370468628437", 1370468628437, 0 }, { "-1370468628437", -1370468628437, 0 }, { "#", -1, 0 } }; const int dataCount = sizeof(data) / sizeof(Data); for (int i = 0; i < dataCount; ++i) { int pad = 0; const qint64 tmp = djvSequenceUtil::stringToFrame(data[i].a, &pad); DJV_DEBUG_PRINT(data[i].a << " = " << tmp << "(" << pad << ")"); DJV_ASSERT(tmp == data[i].b); DJV_ASSERT(pad == data[i].pad); } }
void djvSequenceUtilTest::frameToString() { DJV_DEBUG("djvSequenceUtilTest::frameToString"); const struct Data { qint64 a; QString b; int pad; } data [] = { { 0, "0", 0 }, { 0, "0000", 4 }, { 100, "0100", 4 }, { 1000, "1000", 4 }, { 10000, "10000", 4 }, { -1, "-1", 0 }, { -1, "-0001", 4 }, { -100, "-0100", 4 }, { -1000, "-1000", 4 }, { -10000, "-10000", 4 }, { 1370468628437, "1370468628437", 0 }, { -1370468628437, "-1370468628437", 0 } }; const int dataCount = sizeof(data) / sizeof(Data); for (int i = 0; i < dataCount; ++i) { const QString tmp = djvSequenceUtil::frameToString(data[i].a, data[i].pad); DJV_DEBUG_PRINT(data[i].a << "(" << data[i].pad << ") = " << tmp); DJV_ASSERT(tmp == data[i].b); } }
void djvSystemTest::searchPath() { DJV_DEBUG("djvSystemTest::searchPath"); const QString djvPathValue = djvSystem::env(djvSystem::djvPathEnv()); if (! djvPathValue.length()) { djvSystem::setEnv(djvSystem::djvPathEnv(), "djvPath1:djvPath2"); } const QString ldLibPathValue = djvSystem::env(djvSystem::ldLibPathEnv()); if (! ldLibPathValue.length()) { djvSystem::setEnv(djvSystem::ldLibPathEnv(), "ldLibPath1:ldLibPath2"); } DJV_DEBUG_PRINT(djvSystem::searchPath()); djvSystem::setEnv(djvSystem::ldLibPathEnv(), ldLibPathValue); djvSystem::setEnv(djvSystem::ldLibPathEnv(), ldLibPathValue); }
void Window::play_update() { DJV_DEBUG(String_Format("Window::play_update(%%)").arg(int64_t(this))); DJV_DEBUG_PRINT("play = " << _play); callbacks(false); _play_widget->set(_play); if (_play) { _audio = std::auto_ptr<Audio>(new Audio); try { _audio->init(_movie.info_audio(), &_audio_buffer); } catch (Error in) { _audio.reset(); DJV_AUDIO_APP->error(in); } _idle_init = false; DJV_AUDIO_APP->idle_add(this); } else { _audio.reset(); _audio_buffer.clear(); DJV_AUDIO_APP->idle_del(this); } callbacks(true); }
void djvOpenGlImageTest::members() { DJV_DEBUG("djvOpenGlImageTest::members"); { DJV_DEBUG_PRINT(djvOpenGlImageXform::xformMatrix(djvOpenGlImageXform())); } { DJV_DEBUG_PRINT(djvOpenGlImageColor::brightnessMatrix(1.0, 0.0, 0.0)); DJV_DEBUG_PRINT(djvOpenGlImageColor::contrastMatrix(1.0, 0.0, 0.0)); DJV_DEBUG_PRINT(djvOpenGlImageColor::saturationMatrix(1.0, 0.0, 0.0)); DJV_DEBUG_PRINT(djvOpenGlImageColor::colorMatrix(djvOpenGlImageColor())); } { DJV_DEBUG_PRINT(djvOpenGlImageLevels::colorLut(djvOpenGlImageLevels(), 0.5)); } { DJV_ASSERT(djvOpenGlImageFilter::toGl(djvOpenGlImageFilter::NEAREST)); DJV_ASSERT(djvOpenGlImageFilter::toGl(djvOpenGlImageFilter::LINEAR)); DJV_ASSERT(!djvOpenGlImageFilter::toGl(djvOpenGlImageFilter::BOX)); } { djvImageContext context; QScopedPointer<djvOpenGlContext> openGlContext( context.openGlContextFactory()->create()); djvOpenGlContextScope contextScope(openGlContext.data()); for (int i = 0; i < djvPixel::PIXEL_COUNT; ++i) { const djvPixel::PIXEL pixel = static_cast<djvPixel::PIXEL>(i); DJV_DEBUG_PRINT("pixel = " << pixel); djvPixelData a(djvPixelDataInfo(1, 1, pixel)), b(djvPixelDataInfo(1, 1, pixel)); djvColor color(pixel); djvColorUtil::convert(djvColor(0.5), color); DJV_DEBUG_PRINT("color = " << color); djvMemory::copy(color.data(), a.data(), a.dataByteCount()); DJV_DEBUG_PRINT("pixel = " << djvOpenGlImage::pixel(a, 0, 0)); djvOpenGlImage::copy(a, b); DJV_DEBUG_PRINT("compare = " << (a == b)); djvOpenGlImage::average(a, color); DJV_DEBUG_PRINT("average = " << color); djvColor min, max; djvOpenGlImage::histogram(a, b, 1, min, max); DJV_DEBUG_PRINT("histogram = " << b); DJV_DEBUG_PRINT("min = " << min); DJV_DEBUG_PRINT("max = " << max); DJV_DEBUG_PRINT(""); } } }
void djvOpenGlTest::members() { DJV_DEBUG("djvOpenGlTest::members"); djvImageContext context; QScopedPointer<djvOpenGlContext> openGlContext( context.openGlContextFactory()->create()); djvOpenGlContextScope contextScope(openGlContext.data()); QScopedPointer<djvOpenGlOffscreenBuffer> buffer( new djvOpenGlOffscreenBuffer(djvPixelDataInfo(100, 100, djvPixel::RGBA_U8))); djvOpenGlOffscreenBufferScope bufferScope(buffer.data()); DJV_DEBUG_PRINT("buffer = " << buffer->info()); DJV_DEBUG_PRINT("buffer id = " << buffer->id()); DJV_DEBUG_PRINT("buffer texture = " << buffer->texture()); { djvOpenGlUtil::ortho(djvVector2i(100, 100)); DJV_ASSERT(GL_NO_ERROR == ::glGetError()); djvOpenGlUtil::color(djvColor(0.5)); DJV_ASSERT(GL_NO_ERROR == ::glGetError()); djvOpenGlUtil::drawBox(djvBox2i(25, 25, 50, 50)); DJV_ASSERT(GL_NO_ERROR == ::glGetError()); djvOpenGlUtil::drawBox(djvBox2f(50.0, 50.0, 50.0, 50.0)); DJV_ASSERT(GL_NO_ERROR == ::glGetError()); djvVector2f uv[4] = { djvVector2f(0.0, 0.0), djvVector2f(0.1, 0.0), djvVector2f(0.1, 1.0), djvVector2f(0.0, 1.0) }; djvOpenGlUtil::drawBox(djvBox2i(25, 25, 50, 50), uv); DJV_ASSERT(GL_NO_ERROR == ::glGetError()); djvOpenGlUtil::drawBox(djvBox2f(50.0, 50.0, 50.0, 50.0), uv); DJV_ASSERT(GL_NO_ERROR == ::glGetError()); } { for (int i = 0; i < djvPixel::PIXEL_COUNT; ++i) { DJV_ASSERT(djvOpenGlUtil::format(static_cast<djvPixel::PIXEL>(i))); DJV_ASSERT(djvOpenGlUtil::type(static_cast<djvPixel::PIXEL>(i))); } } }
void djvSystemTest::drives() { DJV_DEBUG("djvSystemTest::drives"); DJV_DEBUG_PRINT("drives = " << djvSystem::drives()); }
void Window::idle() { DJV_DEBUG(String_Format("Window::idle(%%)").arg(int64_t(this))); if (_audio.get()) { int size = _audio_buffer.size(); DJV_DEBUG_PRINT("audio size = " << size); if (! size) { // Reset audio. _audio->stop(); _audio_buffer.clear(); _movie.audio_seek(_frame); _idle_init = false; } // Fill audio buffer. const int min = _audio_buffer.min(); do { int16_t * p = _audio_buffer.push(); if (! p) { break; } _movie.audio( p, _audio_buffer.chunk() / _movie.info_audio().channel); } while (++size < min) ; } if (! _idle_init) { DJV_DEBUG_PRINT("init"); if (_audio.get()) { _audio->start(); } _idle_timer.start(); _idle_frame = 0; _idle_init = true; } else { _idle_timer.check(); } const double time = _audio.get() ? _audio->time() : _idle_timer.seconds(); DJV_DEBUG_PRINT("time = " << time); if (time > 0.0) { const int64_t absolute_frame = Math::floor(time * Image_Speed::speed_to_float(_movie.info_time().speed)); int inc = absolute_frame - _idle_frame; _idle_frame = absolute_frame; DJV_DEBUG_PRINT("absolute frame = " << absolute_frame); DJV_DEBUG_PRINT("inc = " << inc); if (inc) { _frame += inc; if (_frame >= static_cast<int>(_movie.info_time().list.size())) { _frame = 0; if (_audio.get()) { _audio->stop(); } _audio_buffer.clear(); _idle_init = false; } frame_update(); } } }
void djvBoxTest::operators() { DJV_DEBUG("djvBoxTest::operators"); { const djvBox2i tmp(1, 2, 3, 4); djvBox2i box; box = tmp; DJV_ASSERT(1 == box.x); DJV_ASSERT(2 == box.y); DJV_ASSERT(3 == box.w); DJV_ASSERT(4 == box.h); } { const djvBox3i tmp(1, 2, 3, 4, 5, 6); djvBox3i box; box = tmp; DJV_ASSERT(1 == box.x); DJV_ASSERT(2 == box.y); DJV_ASSERT(3 == box.z); DJV_ASSERT(4 == box.w); DJV_ASSERT(5 == box.h); DJV_ASSERT(6 == box.d); } { djvBox2i box(1, 2, 3, 4); box *= djvVector2i(2, 3); DJV_ASSERT( 2 == box.x); DJV_ASSERT( 6 == box.y); DJV_ASSERT( 6 == box.w); DJV_ASSERT(12 == box.h); } { djvBox3i box(1, 2, 3, 4, 5, 6); box *= djvVector3i(2, 3, 4); DJV_ASSERT( 2 == box.x); DJV_ASSERT( 6 == box.y); DJV_ASSERT(12 == box.z); DJV_ASSERT( 8 == box.w); DJV_ASSERT(15 == box.h); DJV_ASSERT(24 == box.d); } { djvBox2i box(4, 6, 8, 9); box /= djvVector2i(2, 3); DJV_ASSERT(2 == box.x); DJV_ASSERT(2 == box.y); DJV_ASSERT(4 == box.w); DJV_ASSERT(3 == box.h); } { djvBox3i box(4, 6, 8, 10, 12, 16); box /= djvVector3i(2, 3, 4); DJV_ASSERT(2 == box.x); DJV_ASSERT(2 == box.y); DJV_ASSERT(2 == box.z); DJV_ASSERT(5 == box.w); DJV_ASSERT(4 == box.h); DJV_ASSERT(4 == box.d); } { djvBox2i box(4, 6, 8, 10); box /= 2; DJV_ASSERT(2 == box.x); DJV_ASSERT(3 == box.y); DJV_ASSERT(4 == box.w); DJV_ASSERT(5 == box.h); } { djvBox3i box(4, 6, 8, 10, 12, 14); box /= 2; DJV_ASSERT(2 == box.x); DJV_ASSERT(3 == box.y); DJV_ASSERT(4 == box.z); DJV_ASSERT(5 == box.w); DJV_ASSERT(6 == box.h); DJV_ASSERT(7 == box.d); } { const djvBox2f box = djvBox2i(1, 2, 3, 4); DJV_ASSERT(djvMath::fuzzyCompare(1.0, box.x)); DJV_ASSERT(djvMath::fuzzyCompare(2.0, box.y)); DJV_ASSERT(djvMath::fuzzyCompare(3.0, box.w)); DJV_ASSERT(djvMath::fuzzyCompare(4.0, box.h)); } { const djvBox3f box = djvBox3i(1, 2, 3, 4, 5, 6); DJV_ASSERT(djvMath::fuzzyCompare(1.0, box.x)); DJV_ASSERT(djvMath::fuzzyCompare(2.0, box.y)); DJV_ASSERT(djvMath::fuzzyCompare(3.0, box.z)); DJV_ASSERT(djvMath::fuzzyCompare(4.0, box.w)); DJV_ASSERT(djvMath::fuzzyCompare(5.0, box.h)); DJV_ASSERT(djvMath::fuzzyCompare(6.0, box.d)); } { const djvBox2i box = djvBox2f(1.0, 2.0, 3.0, 4.0); DJV_ASSERT(1 == box.x); DJV_ASSERT(2 == box.y); DJV_ASSERT(3 == box.w); DJV_ASSERT(4 == box.h); } { const djvBox3i box = djvBox3f(1.0, 2.0, 3.0, 4.0, 5.0, 6.0); DJV_ASSERT(1 == box.x); DJV_ASSERT(2 == box.y); DJV_ASSERT(3 == box.z); DJV_ASSERT(4 == box.w); DJV_ASSERT(5 == box.h); DJV_ASSERT(6 == box.d); } { const djvBox2i box = djvBox2i(1, 2, 3, 4) + 1; DJV_ASSERT(2 == box.x); DJV_ASSERT(3 == box.y); DJV_ASSERT(4 == box.w); DJV_ASSERT(5 == box.h); } { const djvBox3i box = djvBox3i(1, 2, 3, 4, 5, 6) + 1; DJV_ASSERT(2 == box.x); DJV_ASSERT(3 == box.y); DJV_ASSERT(4 == box.z); DJV_ASSERT(5 == box.w); DJV_ASSERT(6 == box.h); DJV_ASSERT(7 == box.d); } { const djvBox2i box = djvBox2i(1, 2, 3, 4) - 1; DJV_ASSERT(0 == box.x); DJV_ASSERT(1 == box.y); DJV_ASSERT(2 == box.w); DJV_ASSERT(3 == box.h); } { const djvBox3i box = djvBox3i(1, 2, 3, 4, 5, 6) - 1; DJV_ASSERT(0 == box.x); DJV_ASSERT(1 == box.y); DJV_ASSERT(2 == box.z); DJV_ASSERT(3 == box.w); DJV_ASSERT(4 == box.h); DJV_ASSERT(5 == box.d); } { const djvBox2i box = djvBox2i(1, 2, 3, 4) * 2; DJV_ASSERT(2 == box.x); DJV_ASSERT(4 == box.y); DJV_ASSERT(6 == box.w); DJV_ASSERT(8 == box.h); } { const djvBox3i box = djvBox3i(1, 2, 3, 4, 5, 6) * 2; DJV_ASSERT( 2 == box.x); DJV_ASSERT( 4 == box.y); DJV_ASSERT( 6 == box.z); DJV_ASSERT( 8 == box.w); DJV_ASSERT(10 == box.h); DJV_ASSERT(12 == box.d); } { const djvBox2i box = djvBox2i(2, 4, 6, 8) / 2; DJV_ASSERT(1 == box.x); DJV_ASSERT(2 == box.y); DJV_ASSERT(3 == box.w); DJV_ASSERT(4 == box.h); } { const djvBox3i box = djvBox3i(2, 4, 6, 8, 10, 12) / 2; DJV_ASSERT(1 == box.x); DJV_ASSERT(2 == box.y); DJV_ASSERT(3 == box.z); DJV_ASSERT(4 == box.w); DJV_ASSERT(5 == box.h); DJV_ASSERT(6 == box.d); } { const djvBox2i box = djvBox2i(1, 2, 3, 4) + djvVector2i(1, 2); DJV_ASSERT(2 == box.x); DJV_ASSERT(4 == box.y); DJV_ASSERT(4 == box.w); DJV_ASSERT(6 == box.h); } { const djvBox3i box = djvBox3i(1, 2, 3, 4, 5, 6) + djvVector3i(1, 2, 3); DJV_ASSERT(2 == box.x); DJV_ASSERT(4 == box.y); DJV_ASSERT(6 == box.z); DJV_ASSERT(5 == box.w); DJV_ASSERT(7 == box.h); DJV_ASSERT(9 == box.d); } { const djvBox2i box = djvBox2i(1, 2, 3, 4) - djvVector2i(1, 2); DJV_ASSERT(0 == box.x); DJV_ASSERT(0 == box.y); DJV_ASSERT(2 == box.w); DJV_ASSERT(2 == box.h); } { const djvBox3i box = djvBox3i(1, 2, 3, 4, 5, 6) - djvVector3i(1, 2, 3); DJV_ASSERT(0 == box.x); DJV_ASSERT(0 == box.y); DJV_ASSERT(0 == box.z); DJV_ASSERT(3 == box.w); DJV_ASSERT(3 == box.h); DJV_ASSERT(3 == box.d); } { const djvBox2i box = djvBox2i(1, 2, 3, 4) * djvVector2i(2, 3); DJV_ASSERT( 2 == box.x); DJV_ASSERT( 6 == box.y); DJV_ASSERT( 6 == box.w); DJV_ASSERT(12 == box.h); } { const djvBox3i box = djvBox3i(1, 2, 3, 4, 5, 6) * djvVector3i(2, 3, 4); DJV_ASSERT( 2 == box.x); DJV_ASSERT( 6 == box.y); DJV_ASSERT(12 == box.z); DJV_ASSERT( 8 == box.w); DJV_ASSERT(15 == box.h); DJV_ASSERT(24 == box.d); } { const djvBox2i box = djvBox2i(2, 3, 4, 6) / djvVector2i(2, 3); DJV_ASSERT(1 == box.x); DJV_ASSERT(1 == box.y); DJV_ASSERT(2 == box.w); DJV_ASSERT(2 == box.h); } { const djvBox3i box = djvBox3i(2, 3, 4, 4, 6, 8) / djvVector3i(2, 3, 4); DJV_ASSERT(1 == box.x); DJV_ASSERT(1 == box.y); DJV_ASSERT(1 == box.z); DJV_ASSERT(2 == box.w); DJV_ASSERT(2 == box.h); DJV_ASSERT(2 == box.d); } { DJV_ASSERT(djvBox2i(1, 2, 3, 4) == djvBox2i(1, 2, 3, 4)); DJV_ASSERT(djvBox2i(1, 2, 3, 4) != djvBox2i()); } { djvBox2i box; QStringList s = QStringList() << "1" << "2" << "3" << "4"; s >> box; DJV_ASSERT(1 == box.x); DJV_ASSERT(2 == box.y); DJV_ASSERT(3 == box.w); DJV_ASSERT(4 == box.h); DJV_ASSERT(s.isEmpty()); } { djvBox3i box; QStringList s = QStringList() << "1" << "2" << "3" << "4" << "5" << "6"; s >> box; DJV_ASSERT(1 == box.x); DJV_ASSERT(2 == box.y); DJV_ASSERT(3 == box.z); DJV_ASSERT(4 == box.w); DJV_ASSERT(5 == box.h); DJV_ASSERT(6 == box.d); DJV_ASSERT(s.isEmpty()); } { djvBox2i box(1, 2, 3, 4); QStringList s; s << box; DJV_ASSERT((QStringList() << "1" << "2" << "3" << "4") == s); } { djvBox3i box(1, 2, 3, 4, 5, 6); QStringList s; s << box; DJV_ASSERT((QStringList() << "1" << "2" << "3" << "4" << "5" << "6") == s); } { DJV_DEBUG_PRINT(djvBox2i()); DJV_DEBUG_PRINT(djvBox2f()); DJV_DEBUG_PRINT(djvBox3i()); DJV_DEBUG_PRINT(djvBox3f()); } }
void djvColorTest::operators() { DJV_DEBUG("djvColorTest::operators"); { const djvColor color = djvColor(1.0f); DJV_ASSERT(djvMath::fuzzyCompare(1.0f, color.f32(0))); } { djvColor a, b; DJV_ASSERT(a == b); a.setPixel(djvPixel::L_U8); b.setPixel(djvPixel::RGB_U8); DJV_ASSERT(a != b); } { djvColor a(djvPixel::RGB_U8), b(djvPixel::RGB_U8); DJV_ASSERT(a == b); a.setU8(djvPixel::u8Max, 0); DJV_ASSERT(a != b); } { djvColor a(djvPixel::RGB_U10), b(djvPixel::RGB_U10); DJV_ASSERT(a == b); a.setU10(djvPixel::u10Max, 0); DJV_ASSERT(a != b); } { djvColor a(djvPixel::RGB_U16), b(djvPixel::RGB_U16); DJV_ASSERT(a == b); a.setU16(djvPixel::u16Max, 0); DJV_ASSERT(a != b); } { djvColor a(djvPixel::RGB_F16), b(djvPixel::RGB_F16); DJV_ASSERT(a == b); a.setF16(1.0, 0); DJV_ASSERT(a != b); } { DJV_ASSERT(djvColor(1.0f) == djvColor(1.0f)); DJV_ASSERT(djvColor(1.0f) != djvColor(0.0f)); } { djvColor color; QStringList s = QStringList() << "RGB U8" << "255" << "127" << "0"; s >> color; DJV_ASSERT(255 == color.u8(0)); DJV_ASSERT(127 == color.u8(1)); DJV_ASSERT( 0 == color.u8(2)); } { djvColor color; QStringList s = QStringList() << "RGB U10" << "1023" << "511" << "0"; s >> color; DJV_ASSERT(1023 == color.u10(0)); DJV_ASSERT( 511 == color.u10(1)); DJV_ASSERT( 0 == color.u10(2)); } { djvColor color; QStringList s = QStringList() << "RGB F16" << "1.0" << "0.5" << "0.0"; s >> color; DJV_ASSERT(djvMath::fuzzyCompare(1.0f, color.f16(0))); DJV_ASSERT(djvMath::fuzzyCompare(0.5f, color.f16(1))); DJV_ASSERT(djvMath::fuzzyCompare(0.0f, color.f16(2))); } { djvColor color; QStringList s = QStringList() << "RGB F32" << "1.0" << "0.5" << "0.0"; s >> color; DJV_ASSERT(djvMath::fuzzyCompare(1.0f, color.f32(0))); DJV_ASSERT(djvMath::fuzzyCompare(0.5f, color.f32(1))); DJV_ASSERT(djvMath::fuzzyCompare(0.0f, color.f32(2))); } { djvColor color(1.0f, 0.5f, 0.0f); QStringList s; s << color; DJV_ASSERT((QStringList() << "RGB F32" << "1" << "0.5" << "0") == s); } { DJV_DEBUG_PRINT(djvColor()); } }
void djvColorProfileTest::operators() { DJV_DEBUG("djvColorProfileTest::operators"); { djvColorProfile a, b; a.type = b.type = djvColorProfile::LUT; a.gamma = b.gamma = 1.0; a.lut = b.lut = djvPixelData(djvPixelDataInfo(16, 1, djvPixel::L_U8)); a.exposure = b.exposure = djvColorProfile::Exposure(1.0, 2.0, 3.0, 4.0); a.lut.zero(); b.lut.zero(); DJV_ASSERT(a.exposure == b.exposure); DJV_ASSERT(a.exposure != djvColorProfile::Exposure()); DJV_ASSERT(a == b); DJV_ASSERT(a != djvColorProfile()); } { djvColorProfile::Exposure exposure; QStringList s = QStringList() << "1.0" << "2.0" << "3.0" << "4.0"; s >> exposure; DJV_ASSERT(djvMath::fuzzyCompare(1.0, exposure.value)); DJV_ASSERT(djvMath::fuzzyCompare(2.0, exposure.defog)); DJV_ASSERT(djvMath::fuzzyCompare(3.0, exposure.kneeLow)); DJV_ASSERT(djvMath::fuzzyCompare(4.0, exposure.kneeHigh)); } { djvColorProfile::Exposure exposure(1.0, 2.0, 3.0, 4.0); QStringList s; s << exposure; DJV_ASSERT((QStringList() << "1" << "2" << "3" << "4") == s); } { const djvColorProfile::Exposure a(1.0, 2.0, 3.0, 4.0); QStringList tmp; tmp << a; djvColorProfile::Exposure b; tmp >> b; DJV_ASSERT(a == b); } { const djvColorProfile::PROFILE a = djvColorProfile::LUT; QStringList tmp; tmp << a; djvColorProfile::PROFILE b = static_cast<djvColorProfile::PROFILE>(0); tmp >> b; DJV_ASSERT(a == b); } { DJV_DEBUG_PRINT(djvColorProfile::Exposure()); DJV_DEBUG_PRINT(djvColorProfile::RAW); DJV_DEBUG_PRINT(djvColorProfile()); } }
void djvMathTest::members() { DJV_DEBUG("djvMathTest::members"); { DJV_ASSERT(10 == djvMath::abs<int>( 10)); DJV_ASSERT(10 == djvMath::abs<int>(-10)); } { DJV_ASSERT(4 == djvMath::pow(2, 2)); DJV_ASSERT(djvMath::fuzzyCompare(4.0, djvMath::pow(2.0, 2.0))); } { DJV_ASSERT(djvMath::fuzzyCompare(2.0, djvMath::sqrt(4.0))); } { DJV_ASSERT(0 == djvMath::mod<int>(2, 1)); } { DJV_ASSERT(1 == djvMath::wrap<int>(-1, 0, 1)); DJV_ASSERT(0 == djvMath::wrap<int>( 0, 0, 1)); DJV_ASSERT(1 == djvMath::wrap<int>( 1, 0, 1)); DJV_ASSERT(0 == djvMath::wrap<int>( 2, 0, 1)); } { DJV_ASSERT(-1 == djvMath::step<int>(-1, 1)); DJV_ASSERT( 0 == djvMath::step<int>( 0, 1)); DJV_ASSERT( 1 == djvMath::step<int>( 1, 1)); DJV_ASSERT( 1 == djvMath::step<int>( 2, 1)); } { DJV_ASSERT(0 == djvMath::pulse<int>(-1, 0, 1)); DJV_ASSERT(0 == djvMath::pulse<int>( 0, 0, 1)); DJV_ASSERT(1 == djvMath::pulse<int>( 1, 0, 1)); DJV_ASSERT(1 == djvMath::pulse<int>( 2, 0, 1)); } { DJV_ASSERT(0 == djvMath::min(0, 1)); DJV_ASSERT(1 == djvMath::max(0, 1)); } { DJV_ASSERT(0 == djvMath::clamp(-1, 0, 1)); DJV_ASSERT(0 == djvMath::clamp( 0, 0, 1)); DJV_ASSERT(1 == djvMath::clamp( 1, 0, 1)); DJV_ASSERT(1 == djvMath::clamp( 2, 0, 1)); } { DJV_ASSERT(-1 == djvMath::lerp(-1, 0, 1)); DJV_ASSERT( 0 == djvMath::lerp( 0, 0, 1)); DJV_ASSERT( 1 == djvMath::lerp( 1, 0, 1)); DJV_ASSERT( 2 == djvMath::lerp( 2, 0, 1)); } { DJV_ASSERT(1 == djvMath::floor(1.5)); DJV_ASSERT(2 == djvMath::ceil (1.5)); DJV_ASSERT(2 == djvMath::round(1.5)); } { DJV_ASSERT(djvMath::fuzzyCompare(0.5, djvMath::fraction(1.5))); } { DJV_ASSERT(4 == djvMath::toPow2(3)); } { DJV_DEBUG_PRINT(djvMath::degreesToRadians(180.0)); DJV_DEBUG_PRINT(djvMath::radiansToDegrees(djvMath::pi)); //DJV_ASSERT(djvMath::fuzzyCompare(djvMath::pi, djvMath::degreesToRadians(180.0))); //DJV_ASSERT(djvMath::fuzzyCompare(180.0, djvMath::radiansToDegrees(djvMath::pi))); } }
void djvOpenGlImageTest::operators() { DJV_DEBUG("djvOpenGlImageTest::operators"); { djvOpenGlImageXform a, b; a.mirror = b.mirror = djvPixelDataInfo::Mirror(true, true); DJV_ASSERT(a == b); DJV_ASSERT(a != djvOpenGlImageXform()); } { djvOpenGlImageColor a, b; a.brightness = b.brightness = 2.0; DJV_ASSERT(a == b); DJV_ASSERT(a != djvOpenGlImageColor()); } { djvOpenGlImageLevels a, b; a.gamma = b.gamma = 2.2; DJV_ASSERT(a == b); DJV_ASSERT(a != djvOpenGlImageLevels()); } { djvOpenGlImageDisplayProfile a, b; a.softClip = b.softClip = 0.5; DJV_ASSERT(a == b); DJV_ASSERT(a != djvOpenGlImageDisplayProfile()); } { djvOpenGlImageFilter a, b; a.min = b.min = djvOpenGlImageFilter::BOX; DJV_ASSERT(a == b); DJV_ASSERT(a != djvOpenGlImageFilter()); } { djvOpenGlImageOptions a, b; a.channel = b.channel = djvOpenGlImageOptions::CHANNEL_RED; DJV_ASSERT(a == b); DJV_ASSERT(a != djvOpenGlImageOptions()); } { djvOpenGlImageXform a; a.mirror = djvPixelDataInfo::Mirror(true, true); a.position = djvVector2f(1.0, 2.0); a.scale = djvVector2f(3.0, 4.0); a.rotate = 5.0; QStringList tmp; tmp << a; djvOpenGlImageXform b; tmp >> b; DJV_ASSERT(a == b); } { djvOpenGlImageColor a; a.brightness = 1.0; a.contrast = 2.0; a.saturation = 3.0; QStringList tmp; tmp << a; djvOpenGlImageColor b; tmp >> b; DJV_ASSERT(a == b); } { djvOpenGlImageLevels a; a.inLow = 1.0; a.inHigh = 2.0; a.gamma = 3.0; a.outLow = 4.0; a.outHigh = 5.0; QStringList tmp; tmp << a; djvOpenGlImageLevels b; tmp >> b; DJV_ASSERT(a == b); } { DJV_DEBUG_PRINT(djvOpenGlImageFilter::BELL); DJV_DEBUG_PRINT(djvOpenGlImageOptions::CHANNEL_RED); } }