File: ljpegtest.cpp

package info (click to toggle)
libopenraw 0.0.9-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 3,060 kB
  • sloc: sh: 11,089; cpp: 9,341; ansic: 1,535; makefile: 565; xml: 507; perl: 42
file content (76 lines) | stat: -rw-r--r-- 1,991 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
 * Copyright (C) 2007, 2009 Hubert Figuiere
 *
 * This library is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation, either version 3 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see
 * <http://www.gnu.org/licenses/>.
 */



#include <string>

#include <boost/test/minimal.hpp>
#include <boost/crc.hpp>      // for boost::crc_basic, boost::crc_optimal

#include <libopenraw++/rawdata.h>

#include "io/file.h"
#include "rawcontainer.h"
#include "jfifcontainer.h"
#include "ljpegdecompressor.h"
#include "ljpegdecompressor_priv.h"

using OpenRaw::RawData;
using OpenRaw::IO::File;

std::string g_testfile;

using namespace OpenRaw::Internals;

int test_main(int argc, char *argv[])
{
	if (argc == 1) {
		// no argument, lets run like we are in "check"
		const char * srcdir = getenv("srcdir");
		
		BOOST_ASSERT(srcdir != NULL);
		g_testfile = std::string(srcdir);
		g_testfile += "/ljpegtest1.jpg";
	}
	else {
		g_testfile = argv[1];
	}
	

	RawData *decompData;
	File *s = new File(g_testfile.c_str());
	RawContainer *container = new JFIFContainer(s, 0);

	LJpegDecompressor decompressor(s, container);

	decompData = decompressor.decompress();

	boost::crc_optimal<8, 0x1021, 0xFFFF, 0, false, false>  crc_ccitt2;
	const uint8_t * data = static_cast<uint8_t *>(decompData->data());
	size_t data_len = decompData->size();
	crc_ccitt2 = std::for_each( data, data + data_len, crc_ccitt2 );
	BOOST_CHECK(crc_ccitt2() == 0x49);

	delete decompData;
	delete container;
	delete s;

	return 0;
}