libopenraw
|
00001 /* 00002 * Copyright (C) 2007, 2009 Hubert Figuiere 00003 * 00004 * This library is free software: you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public License 00006 * as published by the Free Software Foundation, either version 3 of 00007 * the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library. If not, see 00016 * <http://www.gnu.org/licenses/>. 00017 */ 00018 00019 00020 00021 #include <string> 00022 00023 #include <boost/test/minimal.hpp> 00024 #include <boost/crc.hpp> // for boost::crc_basic, boost::crc_optimal 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 // no argument, lets run like we are in "check" 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