?? 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. */#define CJPEG_GLOBALS#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications *///#include "jpeglib.h"#include "jversion.h" /* for version message */#include "cjpeg.h"#include "local_mem.h"#include "vpe_m.h"//#include "20_input420_192128.h"//#include "20_input333_192128.h"//#include "20_420q90rst7qt1ht1_192128.h"//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 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 pool//unsigned int rst_interval = 7; //default value is 0//unsigned 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 tableunsigned int BASE_ADDRESS;/* Create the add-on message string table. */#define JMESSAGE(code,string) string ,static const char * const cdjpeg_message_table[] = {#include "cderror.h" NULL};//--------- Output bitstream pointer -----------//unsigned int *outbitstr;//unsigned int *outbitstr = (unsigned int *) 0x500000;//unsigned int *outbitstr = (unsigned int *) 0x1000000;//----------------------------------------------//unsigned int *DMA_COMMAND_system;unsigned int *DMA_COMMAND_system_phy;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];/* * The main program. */void JpegEnc (FJPEG_ENC_PARAM * ptParam, uint32_t * pu32BS_len){ struct jpeg_compress_struct cinfo; struct jpeg_error_mgr jerr; //pwhsu: 20031008 error report// int status;// unsigned char *pucrtlout;// static volatile int i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, i23, i24, i25, i26, i27, i28, i29, i30; volatile MDMA *pmdma; BASE_ADDRESS = (unsigned int)ptParam->pu32BaseAddr; YUVsampling = (unsigned int)ptParam->eYUVsampling; *pu32BS_len = 0; pmdma = MDMA1; mVpe_Indicator(0x91111111); outbitstr = ptParam->u32BSAddr_phy; // stop autobuffering first to prevent closed abnormally last time SET_VLDCTL(32); //ABF stop SET_PYDCR(0); SET_PUVDCR(0);// SET_QAR(qcoef_b0) SET_QAR(QCOEF_B0); SET_VADR(VLCOUT_OFF); SET_BADR(0); SET_BALR(0); SET_ABADR((int)outbitstr | 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, ptParam->u32img_qual, ptParam->u32rst_interval); //pwhsu:20031013 for default setting of jpeg files outfsize = 0; //pwhsu++:20040127 /* Scan command line to find file names. * It is convenient to use just one switch-parsing routine, but the switch * values read here are ignored; we will rescan the switches after opening * the input file. */ cinfo.image_width = ptParam->u32img_width; cinfo.image_height = ptParam->u32img_height; cinfo.num_components = ptParam->u32comp_num; cinfo.input_components = ptParam->u32comp_num; //local command buffer 1 DMA_COMMAND_local[3] = 0x4A10010; //chain enable DMA_COMMAND_local[7] = 0x4A10010; DMA_COMMAND_local[11] = 0x4A10010; DMA_COMMAND_local[15] = 0x4A10010; DMA_COMMAND_local[19] = 0x4A10010; DMA_COMMAND_local[23] = 0x4A10010; DMA_COMMAND_local[27] = 0x4A10010; DMA_COMMAND_local[31] = 0x4A10010; DMA_COMMAND_local[35] = 0x4A10010; DMA_COMMAND_local[39] = 0x4A10010; //local command buffer 2 DMA_COMMAND_local[43] = 0x4A10010; //chain enable DMA_COMMAND_local[47] = 0x4A10010; DMA_COMMAND_local[51] = 0x4A10010; DMA_COMMAND_local[55] = 0x4A10010; DMA_COMMAND_local[59] = 0x4A10010; DMA_COMMAND_local[63] = 0x4A10010; DMA_COMMAND_local[67] = 0x4A10010; DMA_COMMAND_local[71] = 0x4A10010; DMA_COMMAND_local[75] = 0x4A10010; DMA_COMMAND_local[39] = 0x4A10010; //local mem base address //local command buffer1 DMA_COMMAND_local[1] = (unsigned int) (cur_b0 ); DMA_COMMAND_local[5] = (unsigned int) (cur_b1 ); DMA_COMMAND_local[9] = (unsigned int) (cur_b2 ); DMA_COMMAND_local[13] = (unsigned int) (cur_b3 ); DMA_COMMAND_local[17] = (unsigned int) (cur_b4 ); DMA_COMMAND_local[21] = (unsigned int) (cur_b5 ); DMA_COMMAND_local[25] = (unsigned int) (cur_b6 ); DMA_COMMAND_local[29] = (unsigned int) (cur_b7 ); DMA_COMMAND_local[33] = (unsigned int) (cur_b8 ); DMA_COMMAND_local[37] = (unsigned int) (cur_b9 ); //local command buffer2 DMA_COMMAND_local[41] = (unsigned int) (cur_b0 + stride_MCU); DMA_COMMAND_local[45] = (unsigned int) (cur_b1 + stride_MCU); DMA_COMMAND_local[49] = (unsigned int) (cur_b2 + stride_MCU); DMA_COMMAND_local[53] = (unsigned int) (cur_b3 + stride_MCU); DMA_COMMAND_local[57] = (unsigned int) (cur_b4 + stride_MCU); DMA_COMMAND_local[61] = (unsigned int) (cur_b5 + stride_MCU); DMA_COMMAND_local[65] = (unsigned int) (cur_b6 + stride_MCU); DMA_COMMAND_local[69] = (unsigned int) (cur_b7 + stride_MCU); DMA_COMMAND_local[73] = (unsigned int) (cur_b8 + stride_MCU); DMA_COMMAND_local[77] = (unsigned int) (cur_b9 + stride_MCU); /* Now that we know input colorspace, fix colorspace-dependent defaults */// jpeg_default_colorspace(&cinfo); /* Specify data destination for compression */// jpeg_stdio_dest(&cinfo); /* Start compressor */ jpeg_start_compress(&cinfo, TRUE); // <--- KEY STEP pwhsu:20031014 //cinfo->global_state = CSTATE_SCANNING //cinfo.next_scanline = 0 //huffman table
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -