void djvColorProfileTest::run(int &, char **) { DJV_DEBUG("djvColorProfileTest::run"); ctors(); operators(); }
void djvSpeedTest::ctors() { DJV_DEBUG("djvSpeedTest::ctors"); { const djvSpeed speed; const djvSpeed speedDefault(djvSpeed::speed()); DJV_ASSERT(speedDefault.scale() == speed.scale()); DJV_ASSERT(speedDefault.duration() == speed.duration()); } { const djvSpeed speed(24000, 1001); DJV_ASSERT(24000 == speed.scale()); DJV_ASSERT(1001 == speed.duration()); } { const djvSpeed speed(djvSpeed::FPS_23_976); DJV_ASSERT(24000 == speed.scale()); DJV_ASSERT(1001 == speed.duration()); } }
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 djvColorProfileTest::ctors() { DJV_DEBUG("djvColorProfileTest::ctors"); { const djvColorProfile::Exposure exposure; DJV_ASSERT(djvMath::fuzzyCompare(0.0, exposure.value)); DJV_ASSERT(djvMath::fuzzyCompare(0.0, exposure.defog)); DJV_ASSERT(djvMath::fuzzyCompare(0.0, exposure.kneeLow)); DJV_ASSERT(djvMath::fuzzyCompare(5.0, exposure.kneeHigh)); } { const djvColorProfile::Exposure exposure(1.0, 2.0, 3.0, 4.0); 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)); } { const djvColorProfile colorProfile; DJV_ASSERT(djvColorProfile::RAW == colorProfile.type); DJV_ASSERT(djvMath::fuzzyCompare(2.2, colorProfile.gamma)); DJV_ASSERT(! colorProfile.lut.isValid()); } }
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 djvColorUtilTest::qt() { DJV_DEBUG("djvColorUtilTest::qt"); { djvColor color(djvPixel::RGBA_U8); color.setU8(255, 0); color.setU8(127, 1); color.setU8( 0, 2); color.setU8(255, 3); const QColor qColor = djvColorUtil::toQt(color); DJV_ASSERT(qColor.red() == color.u8(0)); DJV_ASSERT(qColor.green() == color.u8(1)); DJV_ASSERT(qColor.blue() == color.u8(2)); DJV_ASSERT(qColor.alpha() == color.u8(3)); } { QColor qColor(255, 127, 0, 255); const djvColor color = djvColorUtil::fromQt(qColor); DJV_ASSERT(color.u8(0) == qColor.red()); DJV_ASSERT(color.u8(1) == qColor.green()); DJV_ASSERT(color.u8(2) == qColor.blue()); DJV_ASSERT(color.u8(3) == qColor.alpha()); } }
void djvSpeedTest::members() { DJV_DEBUG("djvSpeedTest::members"); { djvSpeed::setSpeed(djvSpeed::FPS_24); const djvSpeed speed = djvSpeed::speed(); djvSpeed::setSpeed(djvSpeed::FPS_23_976); djvSpeed::setSpeed(djvSpeed::speedDefault()); DJV_ASSERT(djvSpeed::speed() == speed); } { djvSpeed speed; speed.set(djvSpeed::FPS_23_976); DJV_ASSERT(24000 == speed.scale()); DJV_ASSERT(1001 == speed.duration()); } { DJV_ASSERT(djvSpeed().isValid()); DJV_ASSERT(! djvSpeed(0, 0).isValid()); } }
void djvColorTest::run(int &, char **) { DJV_DEBUG("djvColorTest::run"); ctors(); members(); operators(); }
void djvOpenGlImageTest::run(int &, char **) { DJV_DEBUG("djvOpenGlImageTest::run"); ctors(); members(); operators(); }
void djvVectorUtilTest::isSizeValid() { DJV_DEBUG("djvVectorUtilTest::isSizeValid"); DJV_ASSERT( djvVectorUtil::isSizeValid(djvVector2i(1, 2)) && !djvVectorUtil::isSizeValid(djvVector2i(-1, -2))); }
void Window::play(bool in) { DJV_DEBUG("Window::play"); DJV_DEBUG_PRINT("in = " << in); _play = in; play_update(); }
void djvSpeedTest::run(int &, char **) { DJV_DEBUG("djvSpeedTest::run"); ctors(); members(); convert(); operators(); }
void djvSequenceUtilTest::run(int &, char **) { DJV_DEBUG("djvSequenceUtilTest::run"); frameToString(); stringToFrame(); sequenceToString(); stringToSequence(); }
void djvColorUtilTest::run(int &, char **) { DJV_DEBUG("djvColorUtilTest::run"); scale(); lerp(); convert(); qt(); }
void djvSystemTest::run(int & argc, char ** argv) { DJV_DEBUG("djvSystemTest::run"); QCoreApplication app(argc, argv); searchPath(); drives(); }
void djvVectorUtilTest::range() { DJV_DEBUG("djvVectorUtilTest::range"); DJV_ASSERT( djvVectorUtil::min(djvVector2i(1, 2), djvVector2i(3, 4)) == djvVector2i(1, 2)); DJV_ASSERT( djvVectorUtil::max(djvVector2i(1, 2), djvVector2i(3, 4)) == djvVector2i(3, 4)); DJV_ASSERT( djvVectorUtil::clamp(djvVector2i(-10, 10), djvVector2i(1, 2), djvVector2i(3, 4)) == djvVector2i(1, 4)); }
void djvBoxTest::members() { DJV_DEBUG("djvBoxTest::members"); { djvBox2i box(1, 2, 3, 4); box.zero(); DJV_ASSERT(0 == box.x); DJV_ASSERT(0 == box.y); DJV_ASSERT(0 == box.w); DJV_ASSERT(0 == box.h); } { djvBox3i box(1, 2, 3, 4, 5, 6); box.zero(); DJV_ASSERT(0 == box.x); DJV_ASSERT(0 == box.y); DJV_ASSERT(0 == box.z); DJV_ASSERT(0 == box.w); DJV_ASSERT(0 == box.h); DJV_ASSERT(0 == box.d); } { djvBox2i box(1, 2, 3, 4); DJV_ASSERT(3 == box.lowerRight().x); DJV_ASSERT(5 == box.lowerRight().y); box.setLowerRight(djvVector2i(4, 6)); DJV_ASSERT(4 == box.w); DJV_ASSERT(5 == box.h); } { djvBox3i box(1, 2, 3, 4, 5, 6); DJV_ASSERT(4 == box.lowerRight().x); DJV_ASSERT(6 == box.lowerRight().y); DJV_ASSERT(8 == box.lowerRight().z); box.setLowerRight(djvVector3i(5, 7, 9)); DJV_ASSERT(5 == box.w); DJV_ASSERT(6 == box.h); DJV_ASSERT(7 == box.d); } }
void djvColorUtilTest::convert() { DJV_DEBUG("djvColorUtilTest::convert"); const struct Data { QStringList in; djvPixel::PIXEL pixel; QStringList out; } data [] = { { QStringList() << "L U8" << "0", djvPixel::L_U8, QStringList() << "L U8" << "0" }, { QStringList() << "L U8" << "255", djvPixel::L_U8, QStringList() << "L U8" << "255" }, { QStringList() << "L U8" << "0", djvPixel::RGB_U10, QStringList() << "RGB U10" << "0" << "0" << "0" }, { QStringList() << "L U8" << "255", djvPixel::RGB_U10, QStringList() << "RGB U10" << "1023" << "1023" << "1023" }, { QStringList() << "L U8" << "0", djvPixel::L_U16, QStringList() << "L U16" << "0" }, { QStringList() << "L U8" << "255", djvPixel::L_U16, QStringList() << "L U16" << "65535" }, { QStringList() << "L U16" << "0", djvPixel::L_U8, QStringList() << "L U8" << "0" }, { QStringList() << "L U16" << "65535", djvPixel::L_U8, QStringList() << "L U8" << "255" }, { QStringList() << "L U16" << "0", djvPixel::RGB_U10, QStringList() << "RGB U10" << "0" << "0" << "0" }, { QStringList() << "L U16" << "65535", djvPixel::RGB_U10, QStringList() << "RGB U10" << "1023" << "1023" << "1023" }, { QStringList() << "L U16" << "0", djvPixel::L_U16, QStringList() << "L U16" << "0" }, { QStringList() << "L U16" << "65535", djvPixel::L_U16, QStringList() << "L U16" << "65535" }, { QStringList() << "L F32" << "-1.0", djvPixel::L_U8, QStringList() << "L U8" << "0" }, { QStringList() << "L F32" << "0.0", djvPixel::L_U8, QStringList() << "L U8" << "0" }, { QStringList() << "L F32" << "0.5", djvPixel::L_U8, QStringList() << "L U8" << "128" }, { QStringList() << "L F32" << "1.0", djvPixel::L_U8, QStringList() << "L U8" << "255" }, { QStringList() << "L F32" << "2.0", djvPixel::L_U8, QStringList() << "L U8" << "255" }, { QStringList() << "L F32" << "-1.0", djvPixel::L_U16, QStringList() << "L U16" << "0" }, { QStringList() << "L F32" << "0.0", djvPixel::L_U16, QStringList() << "L U16" << "0" }, { QStringList() << "L F32" << "0.5", djvPixel::L_U16, QStringList() << "L U16" << "32768" }, { QStringList() << "L F32" << "1.0", djvPixel::L_U16, QStringList() << "L U16" << "65535" }, { QStringList() << "L F32" << "2.0", djvPixel::L_U16, QStringList() << "L U16" << "65535" }, { QStringList() << "L F32" << "1.0", djvPixel::L_F16, QStringList() << "L F16" << "1" } }; const int dataCount = sizeof(data) / sizeof(Data); for (int i = 0; i < dataCount; ++i) { djvColor in; QStringList tmp = data[i].in; tmp >> in; djvColor out(data[i].pixel); djvColorUtil::convert(in, out); DJV_ASSERT(djvStringUtil::label(out) == data[i].out); } }
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 djvVectorUtilTest::run(int &, char **) { DJV_DEBUG("djvVectorUtilTest::run"); abs(); swap(); range(); isSizeValid(); length(); normalize(); dot(); aspect(); convert(); }
void djvVectorUtilTest::convert() { DJV_DEBUG("djvVectorUtilTest::convert"); djvVector2i v2i = djvVectorUtil::convert<double, int, 2>(djvVector2f(1.0, 2.0)); DJV_ASSERT(v2i == djvVector2i(1, 2)); v2i = djvVectorUtil::ceil<double, int, 2>(djvVector2f(0.5, 0.5)); DJV_ASSERT(v2i == djvVector2i(1, 1)); v2i = djvVectorUtil::floor<double, int, 2>(djvVector2f(0.5, 0.5)); DJV_ASSERT(v2i == djvVector2i(0, 0)); DJV_ASSERT((QStringList() << "1" << "2") == djvStringUtil::label(djvVector2i(1, 2))); }
Window::Window(const String & in) : _play(false), _frame(0), _idle_init(false), _idle_frame(0) { DJV_DEBUG(String_Format("Window::Window(%%)").arg(int64_t(this))); // Initialize. try { _movie.init(in); } catch (Error in) { DJV_AUDIO_APP->error(in); } _widget = new Image_View; _play_widget = new Tool_Button("playback_forward"); _play_widget->type(Tool_Button::TOGGLE); _slider = new Int_Slider; Layout_V * layout = new Layout_V(this); layout->margin(0); layout->spacing(0); layout->add(_widget); layout->stretch(_widget); Layout_H * layout_h = new Layout_H(layout); layout_h->margin(0); layout_h->add(_play_widget); layout_h->add(_slider); layout_h->stretch(_slider); _slider->range(0, static_cast<int>(_movie.info_time().list.size()) - 1); dirty(); size(_movie.info().size + V2i(0, size_min().y)); frame_update(); play_update(); _play_widget->signal.set(this, play_callback); _slider->signal.set(this, frame_callback); close_signal.set(this, close_callback); show(); }
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 djvColorUtilTest::lerp() { DJV_DEBUG("djvColorUtilTest::lerp"); { djvColor color(djvPixel::L_F32); djvColorUtil::lerp(0.5, djvColor(0.0f), djvColor(1.0f), color); DJV_ASSERT(djvMath::fuzzyCompare(0.5f, color.f32(0))); } { const djvColor color = djvColorUtil::lerp(0.5, djvColor(0.0f), djvColor(1.0f)); DJV_ASSERT(djvMath::fuzzyCompare(0.5f, color.f32(0))); } }
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); }