⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 step3.c

📁 改进的基于6个mips核的NOC网络
💻 C
字号:
/**************************************************************** * *       >>>> See header file for more information. <<<< ****************************************************************/#include "stdcomm.h"#include "mtools.h" /* For mt_halt() as replacement for exit(int) */#include "jpeg.h"#include "step3.h"#include "color.h"#ifdef CC_I386 /* gcc */#include "sunraster.h"#endif/* real declaration of global variables here *//* see jpeg.h for more info			*/cd_t   comp[3];         /* descriptors all components. No. components*/                        /* is 1 for grayscale and 3 for color images. */PBlock MCU_buff[10];    /* decoded DCT blocks buffer */int    MCU_valid[10];   /* components of above MCU blocks */int   x_size,y_size;    /* Video frame size */int   rx_size,ry_size;  /* down-rounded Video frame size (integer MCU) */int   MCU_sx, MCU_sy;   /* MCU size in pixels	 */int   mx_size, my_size; /* picture size in units of MCUs */int   n_comp;           /* number of components: 1 for grayscale, 3 for color*/int image_number;           /* Variables used in order to handle more than one image*/int number_of_images;#ifndef CC_I386 /* lcc */typedef struct {  unsigned long	MAGIC;  unsigned long	Width;  unsigned long	Heigth;  unsigned long	Depth;  unsigned long	Length;  unsigned long	Type;  unsigned long	CMapType;  unsigned long	CMapLength;} sunraster_header;sunraster_header *Frame1Header = (sunraster_header *)0xa000;unsigned char *Frame1Buffer = (unsigned char *)0xa020;   /* Complete final RGB image */sunraster_header *Frame2Header = (sunraster_header *)0xb000;unsigned char *Frame2Buffer = (unsigned char *)0xb020;   /* Complete final RGB image */#else /* i386 */unsigned char final_image[BMP_IMAGE_BUFFER_SIZE];unsigned char *FrameBuffer = final_image;   /* Complete final RGB image */#endifunsigned char ColorBuffer[2*8 /*= MCU_sx max*/ *2*8 /*= MCU_sy max*/ *3 /*= n_comp max*/];        /* Temporary for the MCU after color conversion */int	MCU_row, MCU_column; /* current position in MCU unit */#ifndef CC_I386 /* lcc *//* Returns ceil(N/D). */int ceil_div(int N, int D){  int i = N/D;  if (N > D*i) i++;  return i;}#endifint process_MCU(void){  int  i,j;  long offset;  int  goodrows, goodcolumns;  if (MCU_column == mx_size) {    MCU_column = 0;    MCU_row++;    if (MCU_row == my_size) {      return 0;    }  }  /* YCrCb to RGB color space transform here */  if (n_comp > 1)    color_conversion(ColorBuffer);  else {    for(i=0;i<64;i++)      ColorBuffer[i] = MCU_buff[0].linear[i];  };  /* cut last row/column as needed */  if ((y_size != ry_size) && (MCU_row == (my_size - 1)))    goodrows = y_size - ry_size;  else    goodrows = MCU_sy;  if ((x_size != rx_size) && (MCU_column == (mx_size - 1)))    goodcolumns = x_size - rx_size;  else    goodcolumns = MCU_sx;  offset = n_comp * (MCU_row * MCU_sy * x_size + MCU_column * MCU_sx);  for (i = 0; i < goodrows; i++)    for (j = 0; j < n_comp * goodcolumns; j++)        {        if (image_number == 1)          {	  Frame1Buffer[offset + n_comp * i * x_size+j] = ColorBuffer[n_comp * i * MCU_sx+j];	  }	else	  {	  Frame2Buffer[offset + n_comp * i * x_size+j] = ColorBuffer[n_comp * i * MCU_sx+j];	  }	}  MCU_column++;  return 1;}/*-----------------------------------------------------------------*//*		MAIN		MAIN		MAIN		   *//*-----------------------------------------------------------------*/void main(void){    int i;        image_number = 1;    number_of_images = 2;        while(image_number <= number_of_images)    {           sc_my_address = 3; /* Set node number. */      mprintf("Processor Step%d up and running!\n", sc_my_address);            mprintf("Start with image: %d\n", image_number);       /* Get the MCU, (color)component and picture properties: */      sc_receive(comp, sizeof(cd_t)*4);	      /*sc_receive((int *)MCU_buff, sizeof(PBlock)*11); */      sc_receive(MCU_valid, sizeof(int)*11);      sc_receive(&x_size, sizeof(int));      sc_receive(&y_size, sizeof(int));      sc_receive(&rx_size, sizeof(int));      sc_receive(&ry_size, sizeof(int));      sc_receive(&MCU_sx, sizeof(int));      sc_receive(&MCU_sy, sizeof(int));      sc_receive(&mx_size, sizeof(int));      sc_receive(&my_size, sizeof(int));      sc_receive(&n_comp, sizeof(int));      #ifndef CC_I386 /* lcc */            if (image_number == 1)        {	/* Save sunraster header (32 bytes) at start of memory. */        Frame1Header->MAGIC      = 0x59a66a95L;        Frame1Header->Width      = 2 * ceil_div(x_size, 2); /* round to 2 more */        Frame1Header->Heigth     = y_size;        Frame1Header->Depth      = (n_comp>1) ? 24 : 8;        Frame1Header->Length     = 0;	/* not required in v1.0 */        Frame1Header->Type       = 0;	/* old one */        Frame1Header->CMapType   = 0;	/* truecolor */        Frame1Header->CMapLength = 0;	/* none */ 		mprintf("Write properties image: %d\n", image_number);	     	}      else        {	/* Save sunraster header (32 bytes) at start of memory. */        Frame2Header->MAGIC      = 0x59a66a95L;        Frame2Header->Width      = 2 * ceil_div(x_size, 2); /* round to 2 more */        Frame2Header->Heigth     = y_size;        Frame2Header->Depth      = (n_comp>1) ? 24 : 8;        Frame2Header->Length     = 0;	/* not required in v1.0 */        Frame2Header->Type       = 0;	/* old one */        Frame2Header->CMapType   = 0;	/* truecolor */        Frame2Header->CMapLength = 0;	/* none */      		mprintf("Write properties image: %d\n", image_number);		}	      #endif          if (verbose) {          mprintf("x_size=%d, y_size=%d\nrx_size=%d, ry_size=%d\nMCU_sx=%d, MCU_sy=%d\nmx_size=%d, my_size=%d, n_comp=%d\n", \              x_size, y_size, rx_size, ry_size, MCU_sx, MCU_sy, mx_size, my_size, n_comp);          mprintf("All image properties have been received.\n");      };        /* Process all MCU's.*/      MCU_column = 0;      MCU_row = 0;      for (i = 0; i < mx_size * my_size; i++)      {          /* Receive a complete MCU in MCU_buff and process it.*/          int curcomp;          for (curcomp = 0; MCU_valid[curcomp] != -1; curcomp++) {              /* Receive a block from the previous node:*/              if (verbose) {                  mprintf("Receiving block %d...", curcomp);              };              sc_receive(&MCU_buff[curcomp], sizeof(PBlock));              if (verbose) {                  mprintf(" done.\n");              };          };          if (verbose) {              mprintf("Received MCU %d (x,y=%d,%d), processing...", i, MCU_row, MCU_column);          };          process_MCU();	            if (verbose) {              mprintf(" done.\n");          };      };            mprintf("Finish with image: %d\n", image_number);      image_number++; // It has finished with one picture, now it will star with the next one      mprintf("Next image: %d\n", image_number);          };            if (verbose) {        mprintf("All done!\n");    };    #ifdef CC_I386 /* i386 */    RGB_save("output.ras", FrameBuffer, x_size, y_size, n_comp);    #endif}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -