
BaseJpegDeocde exampe program
Dependencies: BaseJpegDecode Terminal BaseUsbHost mbed mbed-rtos
Fork of BaseJpegDecode by
Diff: benchmark_BaseJpegDecode.cpp
- Revision:
- 4:7d88de31c55a
- Parent:
- 3:2709bbf8baae
- Child:
- 5:033432f9baf3
--- a/benchmark_BaseJpegDecode.cpp Thu Oct 25 11:02:17 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -#if 0 -#include "mbed.h" -#include "BaseJpegDecode.h" -#include "Benchmark_data.h" - -#define DBG(...) do{fprintf(stderr,"[%s@%d] ",__PRETTY_FUNCTION__,__LINE__);fprintf(stderr,__VA_ARGS__);} while(0); -#define ASSERT(A) while(!(A)){fprintf(stderr,"\n\n%s@%d %s ASSERT!\n\n",__PRETTY_FUNCTION__,__LINE__,#A);exit(1);}; - -Serial pc(USBTX, USBRX); - -class JpegDecode : public BaseJpegDecode { -public: - JpegDecode(); - virtual void outputDC(int mcu, int block, int value); - virtual void outputAC(int mcu, int block, int scan, int value); - virtual void outputMARK(uint8_t c); - int DC_count; - int AC_count; -}; - -JpegDecode::JpegDecode() -{ - DC_count = 0; - AC_count = 0; -} - -void JpegDecode::outputDC(int mcu, int block, int value) -{ - DC_count++; -} - -void JpegDecode::outputAC(int mcu, int block, int scan, int value) -{ - AC_count++; -} - -void JpegDecode::outputMARK(uint8_t c) -{ -} - -JpegDecode* decode; - -void benchmark(uint8_t* image, int size) -{ - decode->DC_count = 0; - decode->AC_count = 0; -#ifdef JPEG_USE_REPORT_CODE - decode->report_scan_count = 0; - decode->report_scan_dc_count = 0; - decode->report_scan_ac_count = 0; -#endif - Timer t; - t.reset(); - t.start(); - decode->clear(); - for(int i = 0; i < size; i++) { - decode->input(image[i]); - } - t.stop(); - - printf("%p %d bytes\n", image, size); - for(int tq = 0; tq < 2; tq++) { - printf("DQT(%d):", tq); - for(int i = 0; i < 64; i++) { - printf(" %d", decode->qt[tq][i]); - } - printf("\n"); - } - printf("SOF0: width: %d height: %d yblocks: %d\n", decode->width, decode->height, decode->m_yblocks); - printf("Scan: DC: %d AC: %d\n", decode->DC_count, decode->AC_count); -#ifdef JPEG_USE_REPORT_CODE - printf("report: scan_count: %d\n", decode->report_scan_count); - printf("report: scan_dc_count: %d\n", decode->report_scan_dc_count); - printf("report: scan_ac_count: %d\n", decode->report_scan_ac_count); -#endif - printf("benchmark: %d ms\n", t.read_ms()); -} - -int main() { - pc.baud(921600); - printf("%s\n", __FILE__); - - decode = new JpegDecode; - ASSERT(decode); - - benchmark(c270_cam0001_jpg, sizeof(c270_cam0001_jpg)); - benchmark(vx700_cam0001_jpg, sizeof(vx700_cam0001_jpg)); - - printf("----\n"); - exit(1); -} - -#endif