ljpegtest.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <string>
00022
00023 #include <boost/test/minimal.hpp>
00024 #include <boost/crc.hpp>
00025
00026 #include <libopenraw++/rawdata.h>
00027
00028 #include "io/file.h"
00029 #include "rawcontainer.h"
00030 #include "jfifcontainer.h"
00031 #include "ljpegdecompressor.h"
00032 #include "ljpegdecompressor_priv.h"
00033
00034 using OpenRaw::RawData;
00035 using OpenRaw::IO::File;
00036
00037 std::string g_testfile;
00038
00039 using namespace OpenRaw::Internals;
00040
00041 int test_main(int argc, char *argv[])
00042 {
00043 if (argc == 1) {
00044
00045 const char * srcdir = getenv("srcdir");
00046
00047 BOOST_ASSERT(srcdir != NULL);
00048 g_testfile = std::string(srcdir);
00049 g_testfile += "/ljpegtest1.jpg";
00050 }
00051 else {
00052 g_testfile = argv[1];
00053 }
00054
00055
00056 RawData *decompData;
00057 File *s = new File(g_testfile.c_str());
00058 RawContainer *container = new JFIFContainer(s, 0);
00059
00060 LJpegDecompressor decompressor(s, container);
00061
00062 decompData = decompressor.decompress();
00063
00064 boost::crc_optimal<8, 0x1021, 0xFFFF, 0, false, false> crc_ccitt2;
00065 const uint8_t * data = static_cast<uint8_t *>(decompData->data());
00066 size_t data_len = decompData->size();
00067 crc_ccitt2 = std::for_each( data, data + data_len, crc_ccitt2 );
00068 BOOST_CHECK(crc_ccitt2() == 0x49);
00069
00070 delete decompData;
00071 delete container;
00072 delete s;
00073
00074 return 0;
00075 }
00076