?? cjpeg.c
字號:
/* * cjpeg.c * * Copyright (C) 1991-1998, Thomas G. Lane. * This file is part of the Independent JPEG Group's software. * For conditions of distribution and use, see the accompanying README file. * * This file contains a command-line user interface for the JPEG compressor. * It should work on any system with Unix- or MS-DOS-style command lines. * * Two different command line styles are permitted, depending on the * compile-time switch TWO_FILE_COMMANDLINE: * cjpeg [options] inputfile outputfile * cjpeg [options] [inputfile] * In the second style, output is always to standard output, which you'd * normally redirect to a file or pipe to some other program. Input is * either from a named file or from standard input (typically redirected). * The second style is convenient on Unix but is unhelpful on systems that * don't support pipes. Also, you MUST use the first style if your system * doesn't do binary I/O to stdin/stdout. * To simplify script writing, the "-outfile" switch is provided. The syntax * cjpeg [options] -outfile outputfile inputfile * works regardless of which command line style is used. */#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications *///#include "jpeglib.h"#include "jversion.h" /* for version message */#ifdef USE_INTERNAL_CPU #ifdef FPGA_demo #include "intercpucode_fpga.h" #else #include "intercpucode_rtl.h" #endif#else #ifndef FPGA_demo // means RTL simulation #include "20_input420_192128.h" #include "20_420q90rst7qt1ht1_192128.h" #endif#endif#ifndef FPGA_demo // means RTL simulation #define COMP_RST#endif//coverage test//#include "100_input420_192128.h"//#include "101_input211_192128.h"//#include "20_input111_192128.h"//#include "g15_input111_192128.h"//#include "09_input333_192128.h"//#include "14_input422_192128.h"#define CKR_RATIO 0////#define COMP_RSTstruct Compress_recon rinfo; //yuv420 =0//yuv422 =1//yuv211 =2//yuv333 =3//yuv222 =4//yuv111 =5unsigned int YUVsampling = 0;unsigned int img_qual = 90; //usually set 75 < qual <100, if qual<50 the quality of image is very poorunsigned int rst_interval = 7; //default value is 0unsigned int img_width = 192;unsigned int img_height = 128;unsigned int comp_num = 3;unsigned int qtbl_no = 1; //If the value is one, it will be the default table //If the value is zero, it will be the another one tableunsigned int hufftbl_no = 1; //If the value is one, it will be the default table //If the value is zero, it will be the another one table/* Create the add-on message string table. */#define JMESSAGE(code,string) string ,static const char * const cdjpeg_message_table[] = {#include "cderror.h" NULL};//--------------- Bank0 ---------------------//// storing the qcoeff and vlc output in MCUunsigned short *qcoef_b0 = (unsigned short *) (0x0+BASE_ADDRESS); //0000 -- 0500 (10 bolcks)//unsigned short *qcoef_b0 = (unsigned short *) (0x0); //0000 -- 0500 (10 bolcks)// DMA_commandunsigned int *DMA_COMMAND_local = (unsigned int *) (0x500+BASE_ADDRESS); //0500 -- 0700#ifdef USE_INTERNAL_CPU unsigned int *DMA_COMMAND_cpu = (unsigned int *) (0x800+BASE_ADDRESS); //0500 -- 0700#endif// vlc outputunsigned int *Vlcout = (unsigned int *) (0xc00+BASE_ADDRESS);//--------------- Bank1 ---------------------//// storing the pointer of each block in MCU (double buffer)/*unsigned char *cur_b0 = (unsigned char *) (0x4000+BASE_ADDRESS); //4000 -- 4280unsigned char *cur_b1 = (unsigned char *) (0x4040+BASE_ADDRESS); //4000 -- 4280unsigned char *cur_b2 = (unsigned char *) (0x4080+BASE_ADDRESS); //4000 -- 4280unsigned char *cur_b3 = (unsigned char *) (0x40c0+BASE_ADDRESS); //4000 -- 4280unsigned char *cur_b4 = (unsigned char *) (0x4100+BASE_ADDRESS); //4000 -- 4280unsigned char *cur_b5 = (unsigned char *) (0x4140+BASE_ADDRESS); //4000 -- 4280unsigned char *cur_b6 = (unsigned char *) (0x4180+BASE_ADDRESS); //4000 -- 4280unsigned char *cur_b7 = (unsigned char *) (0x41c0+BASE_ADDRESS); //4000 -- 4280unsigned char *cur_b8 = (unsigned char *) (0x4200+BASE_ADDRESS); //4000 -- 4280unsigned char *cur_b9 = (unsigned char *) (0x4240+BASE_ADDRESS); //4000 -- 4280*/#ifdef Internal_CPU//------For internal CPU------// //20041227unsigned char *cur_b0 = (unsigned char *) (0x14000); //4000 -- 4280unsigned char *cur_b1 = (unsigned char *) (0x14040); //4000 -- 4280unsigned char *cur_b2 = (unsigned char *) (0x14080); //4000 -- 4280unsigned char *cur_b3 = (unsigned char *) (0x140c0); //4000 -- 4280unsigned char *cur_b4 = (unsigned char *) (0x14100); //4000 -- 4280unsigned char *cur_b5 = (unsigned char *) (0x14140); //4000 -- 4280unsigned char *cur_b6 = (unsigned char *) (0x14180); //4000 -- 4280unsigned char *cur_b7 = (unsigned char *) (0x141c0); //4000 -- 4280unsigned char *cur_b8 = (unsigned char *) (0x14200); //4000 -- 4280unsigned char *cur_b9 = (unsigned char *) (0x14240); //4000 -- 4280const int stride_MCU = 0x280;const int stride_blk = 0x40;//For DMA LM_addrunsigned char *cur_b0_div2 = (unsigned char *) (0xa000); //4000 -- 4280unsigned char *cur_b1_div2 = (unsigned char *) (0xa020); //4000 -- 4280unsigned char *cur_b2_div2 = (unsigned char *) (0xa040); //4000 -- 4280unsigned char *cur_b3_div2 = (unsigned char *) (0xa060); //4000 -- 4280unsigned char *cur_b4_div2 = (unsigned char *) (0xa080); //4000 -- 4280unsigned char *cur_b5_div2 = (unsigned char *) (0xa0a0); //4000 -- 4280unsigned char *cur_b6_div2 = (unsigned char *) (0xa0c0); //4000 -- 4280unsigned char *cur_b7_div2 = (unsigned char *) (0xa0e0); //4000 -- 4280unsigned char *cur_b8_div2 = (unsigned char *) (0xa100); //4000 -- 4280unsigned char *cur_b9_div2 = (unsigned char *) (0xa120); //4000 -- 4280const int stride_MCU_div2 = 0x140;//------For internal CPU------// //20041227#elseunsigned char *cur_b0 = (unsigned char *) (0x4000); //4000 -- 4280unsigned char *cur_b1 = (unsigned char *) (0x4040); //4000 -- 4280unsigned char *cur_b2 = (unsigned char *) (0x4080); //4000 -- 4280unsigned char *cur_b3 = (unsigned char *) (0x40c0); //4000 -- 4280unsigned char *cur_b4 = (unsigned char *) (0x4100); //4000 -- 4280unsigned char *cur_b5 = (unsigned char *) (0x4140); //4000 -- 4280unsigned char *cur_b6 = (unsigned char *) (0x4180); //4000 -- 4280unsigned char *cur_b7 = (unsigned char *) (0x41c0); //4000 -- 4280unsigned char *cur_b8 = (unsigned char *) (0x4200); //4000 -- 4280unsigned char *cur_b9 = (unsigned char *) (0x4240); //4000 -- 4280const int stride_MCU = 0x280;const int stride_blk = 0x40;#endif//--------------- Qtable ---------------------//// storing the qval and invqval in local mem (31k~32k)unsigned int *qtbl0 = (unsigned int *) (0x7c00+BASE_ADDRESS); //7c00 -- 7cffunsigned int *qtbl1 = (unsigned int *) (0x7d00+BASE_ADDRESS); //7d00 -- 7dff unsigned int *qtbl2 = (unsigned int *) (0x7e00+BASE_ADDRESS); //7e00 -- 7effunsigned int *qtbl3 = (unsigned int *) (0x7f00+BASE_ADDRESS); //7f00 -- 7fff//--------------- Bank2,3 ---------------------//// storing the huffman table in local mem (32k~36k)unsigned int *huftbl0_ac = (unsigned int *) (0x8000+BASE_ADDRESS); //8000 -- 8400unsigned int *huftbl1_ac = (unsigned int *) (0x8400+BASE_ADDRESS); //8400 -- 8800unsigned int *huftbl0_dc = (unsigned int *) (0x8800+BASE_ADDRESS); //8800 -- 8c00unsigned int *huftbl1_dc = (unsigned int *) (0x8c00+BASE_ADDRESS); //8c00 -- 9000//--------- Output bitstream pointer -----------//unsigned int *outbitstr = (unsigned int *) 0x500000;//unsigned int *outbitstr = (unsigned int *) 0x1000000;//----------------------------------------------////unsigned int *DMA_COMMAND_system;unsigned int mcctrl; //pwhsu++:20040109unsigned int *pbufaddr; //pwhsu++:20040109//int imgbwidth;//pwhsu++:20040119int h_sampf[3];int v_sampf[3];int cMCUrow;unsigned int outfsize; //pwhsu++:20040128//unsigned char* cury ;//unsigned char* curu ;//unsigned char* curv ;unsigned char* curdata[3];//unsigned char* outbits;unsigned int sreg; //pwhsu++:20040115unsigned int vldreg; //pwhsu++:20040218unsigned int lmadr; //pwhsu++:20040219unsigned int smadr; //pwhsu++:20040219unsigned int bitslen; //pwhsu++:20040219unsigned int dmactrl;unsigned int comp_width[3];unsigned int mcu_height[3];unsigned int CCATmp0;unsigned int CCATmp1;#ifdef USE_INTERNAL_CPU volatile JPG_ENC_VAR *pjevar = JPG_ENC_VAR1;#endif// ftmcp100_exitvoid ftmcp100_exit(void){ for(;;) ;}/* * The main program. */void main (void){ struct jpeg_compress_struct cinfo; struct jpeg_error_mgr jerr; //pwhsu: 20031008 error report unsigned int tmpbits; int status, i, j; unsigned char *pucrtlout; unsigned int *vpe_stop = (unsigned int *) (VPE); volatile MDMA *pmdma = MDMA1; unsigned int qarval; #ifdef USE_INTERNAL_CPU unsigned int start_inter_cpu; #endif /***************************************************************************** * Command line parsing ****************************************************************************/ //__rt_lib_init(0x50000, 0x200000); __rt_lib_init(0x50000, 0x800000); _fp_init(); tmpbits = (unsigned int)outbitstr; qarval = ((unsigned int)qcoef_b0 & 0xffff)<<16 | ((unsigned int)qcoef_b0 & 0xffff); //__asm{ SET_PYDCR(0) SET_PUVDCR(0) SET_CKR(CKR_RATIO) //SET_QAR(qcoef_b0) SET_QAR(qarval) SET_VADR(Vlcout) SET_BADR(0) SET_BALR(0) SET_ABADR(tmpbits | 1) //SET_VLDCTL(16) //ABF start SET_VLDCTL(80) //ABF start & change endian //} /* Initialize the JPEG compression object with default error handling. */ cinfo.err = jpeg_std_error(&jerr); jpeg_create_compress(&cinfo); //pwhsu:20031008 starting compression //pwhsu++:20031013 cinfo->global_state = CSTATE_START //pwhsu:20031013 error message /* Add some application-specific error messages (from cderror.h) */ jerr.addon_message_table = cdjpeg_message_table; jerr.first_addon_message = JMSG_FIRSTADDONCODE; jerr.last_addon_message = JMSG_LASTADDONCODE; /* Initialize JPEG parameters. * Much of this may be overridden later. * In particular, we don't yet know the input file's color space, * but we need to provide some value for jpeg_set_defaults() to work. */ cinfo.in_color_space = JCS_RGB; /* arbitrary guess */ jpeg_set_defaults(&cinfo); //pwhsu:20031013 for default setting of jpeg files #ifdef USE_INTERNAL_CPU pmdma->Status = 1; DMA_COMMAND_cpu[0]=InterCPUcode; //DMA_COMMAND_cpu[1]=CPU_BASE_ADDRESS; DMA_COMMAND_cpu[1]=BASE_ADDRESS; DMA_COMMAND_cpu[2]=0x0; //DMA_COMMAND_cpu[3]=0x0<<26 | 0x8<<20 | 0x6c1; DMA_COMMAND_cpu[3]=0x0<<26 | 0x8<<20 | (sizeof(InterCPUcode) / sizeof(unsigned int));/* DMA_COMMAND_cpu[4]=(InterCPUcode+4095); DMA_COMMAND_cpu[5]=0x3FFFC+CPU_BASE_ADDRESS; DMA_COMMAND_cpu[6]=0x0; DMA_COMMAND_cpu[7]=0x0<<26 | 0xa<<20 | 0xb29;*/ while((pmdma->Status & 0x1) == 0) //DMA process run {} pmdma->CCA = (((unsigned int) DMA_COMMAND_cpu)&0xfffffff0) | 0x2;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -