qa_jpegbm.cpp

00001
00002 /***************************************************************************
00003  *  qa_jpegbm.h - QA for benchmarking jpeg compression
00004  *
00005  *  Created: Fri Jul 20 13:22:51 2007
00006  *  Copyright  2005-2007  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023 
00024 /// @cond QA
00025 
00026 #include <fvutils/color/colorspaces.h>
00027 #include <fvutils/compression/jpeg_compressor.h>
00028
00029 #include <utils/time/tracker.h>
00030 #include <iostream>
00031 #include <cstdlib>
00032
00033 using namespace std;
00034 using namespace fawkes;
00035
00036 #define IMAGE_WIDTH   500
00037 #define IMAGE_HEIGHT  500
00038 
00039 #define NUM_CYCLES 100
00040 
00041 // ~ 500 KB should be enough
00042 #define DEST_BUF_SIZE 500000
00043 
00044 int
00045 main(int argc, char **argv)
00046 {
00047
00048   unsigned char *yuv422planar = malloc_buffer(YUV422_PLANAR, IMAGE_WIDTH, IMAGE_HEIGHT);
00049   unsigned char *compressed = (unsigned char *)malloc(DEST_BUF_SIZE);
00050
00051   JpegImageCompressor *jpeg = new JpegImageCompressor(JpegImageCompressor::JPEG_CS_RGB);
00052   jpeg->set_image_dimensions(IMAGE_WIDTH, IMAGE_HEIGHT);
00053   jpeg->set_image_buffer(YUV422_PLANAR, yuv422planar);
00054   jpeg->set_destination_buffer(compressed, DEST_BUF_SIZE);
00055   jpeg->set_compression_destination(ImageCompressor::COMP_DEST_MEM);
00056
00057   TimeTracker *tracker = new TimeTracker();
00058
00059   for ( unsigned int i = 0; i < NUM_CYCLES; ++i) {
00060     jpeg->compress();
00061     tracker->ping(0);
00062   }
00063
00064   tracker->print_to_stdout();
00065
00066   delete tracker;
00067   delete jpeg;
00068   free(compressed);
00069   free(yuv422planar);
00070
00071   return 0;
00072 }
00073
00074
00075 
00076 /// @endcond