📄 dct_main.c
字号:
/* ======================================================================== */
/* TEXAS INSTRUMENTS, INC. */
/* */
/* IMGLIB Application Note Examples */
/* */
/* Release: Version 1.0 */
/* */
/* This file contains proprietary intellectual property of Texas */
/* Instruments, Inc. Its source and binary codes are protected by */
/* various copyrights, and portions may also be protected by patents or */
/* other legal protections. */
/* */
/* ------------------------------------------------------------------------ */
/* Copyright (C) 2003 Texas Instruments, Incorporated. */
/* All Rights Reserved. */
/* ======================================================================== */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <csl.h>
#include <csl_timer.h>
#include <csl_cache.h>
#include <csl_dat.h>
/* ======================================================================== */
/* Include the IMGLIB header file */
/* ======================================================================== */
#include "IMG_fdct_8x8.h"
#include "IMG_idct_8x8.h"
//////////////////////////////////////////////////////////////////////////////
#include ".\lena.h"
/* ======================================================================== */
/* Number of data. Do not change NN. */
/* ======================================================================== */
//#define NN (65536)
/* ======================================================================== */
/* Output and temporary storage */
/* ======================================================================== */
//short hist[256];
//short t_hist[256*4];
/* ======================================================================== */
/* DMA buffers */
/* ======================================================================== */
//#define BUFSIZE (8192)
//const unsigned char PingIn [BUFSIZE]; /* DMA buffer 1 */
//const unsigned char PongIn [BUFSIZE]; /* DMA buffer 2 */
/* ======================================================================== */
/* NAME */
/* memclear */
/* */
/* RIVISION HISTORY */
/* 31-Dec-2002 Initial revision */
/* */
/* USAGE */
/* void memclear( void *ptr, int count ); */
/* */
/* The ptr points to the memory location to be cleared. */
/* The count is the number of data to be cleared in bytes. */
/* */
/* DESCRIPTION */
/* This function clears the specified memory with zeros. */
/* It is supposed to be faster than memset(). */
/* */
/* ASSUMPTIONS */
/* The count must be a multiple of 8 and greater than or equal to 32 */
/* */
/* ------------------------------------------------------------------------ */
/* Copyright (c) 2003 Texas Instruments, Incorporated. */
/* All Rights Reserved. */
/* ======================================================================== */
/* ======================================================================== */
/* NAME */
/* main */
/* */
/* RIVISION HISTORY */
/* 30-Jun-2002 Initial revision */
/* 31-Dec-2002 Improved benchmarking */
/* */
/* USAGE */
/* void main(); */
/* */
/* This program is to show the performance of IMG_histogram() */
/* when all data are in external memory and DMA is used to access the */
/* data. */
/* */
/* DESCRIPTION */
/* First, function call overhead for timer functions is measured. */
/* Then, the execution cycles for the target function is measured. */
/* Finally, the timer function call overhead is excluded from the */
/* execution cycles measured. */
/* Input data are in in_image[] and the histogram is stored in hist[]. */
/* */
/* ASSUMPTIONS */
/* The cycle count measured will include L1P miss overhead as well as */
/* function call overhead. */
/* The benchmarking code assumes C64x, e.g., 1 count = 8 CPU cycles. */
/* */
/* ------------------------------------------------------------------------ */
/* Copyright (c) 2003 Texas Instruments, Incorporated. */
/* All Rights Reserved. */
/* ======================================================================== */
void main()
{
TIMER_Handle hTimer;
unsigned int start, diff,stop,overhead;
int numBlocks;
char filename[]="penguins.bmp";
numBlocks = readbmp(filename);
printf("bmp read!\n");
/* ==================================================================== */
/* Initialize Chip Support Library */
/* ==================================================================== */
CSL_init();
DAT_open(DAT_CHAANY, DAT_PRI_HIGH, 0);
/* ==================================================================== */
/* Configure a timer. */
/* ==================================================================== */
hTimer = TIMER_open(TIMER_DEVANY,0);
TIMER_configArgs(hTimer, 0x000002C0, 0xFFFFFFFF, 0x00000000);
/* ==================================================================== */
/* Compute the overhead of calling the timer. */
/* ==================================================================== */
start = TIMER_getCount(hTimer); /* called twice to avoid L1D miss. */
start = TIMER_getCount(hTimer);
stop = TIMER_getCount(hTimer);
overhead = stop - start;
/* ==================================================================== */
/* Measure the time */
/* ==================================================================== */
start = TIMER_getCount(hTimer);
IMG_fdct_8x8(Bmatrix, numBlocks);
IMG_fdct_8x8(Gmatrix, numBlocks);
IMG_fdct_8x8(Rmatrix, numBlocks);
printf("foward dct completed.\n");
IMG_idct_8x8(Bmatrix, numBlocks);
IMG_idct_8x8(Gmatrix, numBlocks);
IMG_idct_8x8(Rmatrix, numBlocks);
printf("inverse dct completed.\n");
diff = (TIMER_getCount(hTimer) - start) - overhead;
TIMER_close(hTimer);
printf("Total cycles for forward and inverse dct = %d\n", diff*8);
/* ======================================================================== */
bmpform(Bmatrix,Gmatrix,Rmatrix);
printf("work completed.\n");
/* ==================================================================== */
/* Move code to L1. Use it for benchmarking only. */
/* ==================================================================== */
//IMG_histogram((const unsigned char *)hist, 8, 1, t_hist, hist);
/* ==================================================================== */
/* Clear histogram arrays */
/* ==================================================================== */
// memclear( hist, sizeof(hist) );
// id_PingIn = DAT_copy(in_image, (void*)PingIn, BUFSIZE);
// id_PongIn = DAT_copy(in_image+BUFSIZE, (void*)PongIn, BUFSIZE);
// for (i=0; i< (rows-2); i+=2)
// {
// memclear( t_hist, sizeof(t_hist) );
// DAT_wait(id_PingIn);
// IMG_histogram(PingIn, BUFSIZE, 1, t_hist, hist);
// id_PingIn = DAT_copy(in_image + ((i+2)*BUFSIZE),
// (void*)PingIn, BUFSIZE);
// memclear( t_hist, sizeof(t_hist) );
// DAT_wait(id_PongIn);
// IMG_histogram(PongIn, BUFSIZE, 1, t_hist, hist);
// id_PongIn = DAT_copy(in_image+((i+3)*BUFSIZE),
// (void*)PongIn, BUFSIZE);
// }
// memclear( t_hist, sizeof(t_hist) );
// DAT_wait(id_PingIn);
// IMG_histogram(PingIn, BUFSIZE, 1, t_hist, hist);
// memclear( t_hist, sizeof(t_hist) );
// DAT_wait(id_PongIn);
// IMG_histogram(PongIn, BUFSIZE, 1, t_hist, hist);
/* ==================================================================== */
/* Print the result */
/* ==================================================================== */
// printf("Number of data = %d\n", NN);
}
/* ======================================================================== */
/* End of file: hist_dma_main.c */
/* ------------------------------------------------------------------------ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -