Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
qa_jpegbm.cpp
1 
2 /***************************************************************************
3  * qa_jpegbm.h - QA for benchmarking jpeg compression
4  *
5  * Created: Fri Jul 20 13:22:51 2007
6  * Copyright 2005-2007 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 /// @cond QA
25 
26 #include <fvutils/color/colorspaces.h>
27 #include <fvutils/compression/jpeg_compressor.h>
28 
29 #include <utils/time/tracker.h>
30 #include <iostream>
31 #include <cstdlib>
32 
33 using namespace std;
34 using namespace fawkes;
35 using namespace firevision;
36 
37 #define IMAGE_WIDTH 500
38 #define IMAGE_HEIGHT 500
39 
40 #define NUM_CYCLES 100
41 
42 // ~ 500 KB should be enough
43 #define DEST_BUF_SIZE 500000
44 
45 int
46 main(int argc, char **argv)
47 {
48 
49  unsigned char *yuv422planar = malloc_buffer(YUV422_PLANAR, IMAGE_WIDTH, IMAGE_HEIGHT);
50  unsigned char *compressed = (unsigned char *)malloc(DEST_BUF_SIZE);
51 
52  JpegImageCompressor *jpeg = new JpegImageCompressor(JpegImageCompressor::JPEG_CS_RGB);
53  jpeg->set_image_dimensions(IMAGE_WIDTH, IMAGE_HEIGHT);
54  jpeg->set_image_buffer(YUV422_PLANAR, yuv422planar);
55  jpeg->set_destination_buffer(compressed, DEST_BUF_SIZE);
56  jpeg->set_compression_destination(ImageCompressor::COMP_DEST_MEM);
57 
58  TimeTracker *tracker = new TimeTracker();
59 
60  for ( unsigned int i = 0; i < NUM_CYCLES; ++i) {
61  jpeg->compress();
62  tracker->ping(0);
63  }
64 
65  tracker->print_to_stdout();
66 
67  delete tracker;
68  delete jpeg;
69  free(compressed);
70  free(yuv422planar);
71 
72  return 0;
73 }
74 
75 
76 
77 /// @endcond