コード例 #1
0
void OptionBase::toString(RSString & result) const
{
	C_ostrstream tempstream;
	(void) writevalue(tempstream);
	tempstream << ends;
#ifdef  USE_NEWSTRSTREAM
	const string str = tempstream.str();
	// no freeze / delete needed since ostringstream::str returns a string and not char*
	result = str.data();
#else
	result = tempstream.str();
	tempstream.rdbuf()->freeze(0);
#endif
}
コード例 #2
0
ファイル: lglib.c プロジェクト: Eiyeron/LuaFX
static int letter (lua_State *L)
{
 int x,y;

 if(!NetB){

x = lua_toint(L, 1)-1;
y = lua_toint(L, 2)-1;

switch(lua_type(L,3)){
case LUA_TSTRING:
writeg(x,y,(char*)lua_tostring ( L , 3  ) ) ;
break;
case LUA_TNUMBER:
writevalue(x,y,(long)(lua_tonumber(L, 3)));
break;
default: break;
}

 return 0;
 }
}
コード例 #3
0
ファイル: YUV2DCTZIGZAG16BITBE.c プロジェクト: PeterLemon/N64
// Convert Planar YUV 4:2:2 To 16-Bit DCT Quantization Block File (Y Channel)
static void convert_dct_Y(FILE *source_file, FILE *target_file, long ofs, long ofs_end) {
  unsigned int i = 0;
  unsigned int u = 0;
  unsigned int v = 0;
  unsigned int x = 0;
  unsigned int y = 0;

  // Fill JPEG Standard Quantization 8x8 Matrix Set By Quality Level
  for(i=0; i < 64; i++) {
    if(quality > 50) q[i] = q50[i] * (100-quality)/50;
    if(quality < 50) q[i] = q50[i] * 50/quality;
    if(quality == 50) q[i] = q50[i];
    if(q[i] > 255) q[i] = 255;
    if(q[i] < 1) q[i] = 1;
  }

  // Fill COS Look Up Table
  for(u=0; u < 8; u++) {
    for(x=0; x < 8; x++) coslut[u*8 + x] = cos((2*x + 1) * u * M_PI / 16);
  }

  // Loop Blocks
  ofs = 0;
  long wofs = 0;
  unsigned int block_row = 0; // Block Row Counter
  while(wofs < (width * height * 4) - 2048) {

    // Load Image Block (Y Channel)
    for(y=0; y < 8; y++) {
      for(x=0; x < 8; x++) {
        fseek(source_file, ofs, SEEK_SET);
        SourceCHR = readvalue(source_file);
        image[y*8 + x] = SourceCHR;
        ofs ++;
      }
      ofs += (width - 8); // Next Scanline In Block
    }

    block_row++;
    if(block_row == (width / 8)) {
      block_row = 0; // Next Block Row
      ofs -= (width - 8);
    }
    else ofs -= ((width * 8) - 8) ; // Next Block Column

    // Clear DCT Block
    for(i=0; i < 64; i++) dct[i] = 0.0;

    // Write DCT Block
    for(u=0; u < 8; u++) {
      for(v=0; v < 8; v++) {
        for(x=0; x < 8; x++) {
          for(y=0; y < 8; y++) {
            dct[v*8 + u] += (
              image[y*8 + x]
              * clut[u]
              * clut[v]
              * coslut[u*8 + x] // cos((2*x + 1) * u * pi / 16)
              * coslut[v*8 + y] // cos((2*y + 1) * v * pi / 16)
            );
          }
        }
      }
    }

    // Write DCTQ Block (Quantization)
    for(i=0; i < 64; i++) dctq[i] = dct[i] / q[i];

    // Write Zig-Zag DCTQ Block
    dctqz[0] = dctq[0];
    dctqz[1] = dctq[1];
    dctqz[2] = dctq[8];
    dctqz[3] = dctq[16];
    dctqz[4] = dctq[9];
    dctqz[5] = dctq[2];
    dctqz[6] = dctq[3];
    dctqz[7] = dctq[10];

    dctqz[8] = dctq[17];
    dctqz[9] = dctq[24];
    dctqz[10] = dctq[32];
    dctqz[11] = dctq[25];
    dctqz[12] = dctq[18];
    dctqz[13] = dctq[11];
    dctqz[14] = dctq[4];
    dctqz[15] = dctq[5];

    dctqz[16] = dctq[12];
    dctqz[17] = dctq[19];
    dctqz[18] = dctq[26];
    dctqz[19] = dctq[33];
    dctqz[20] = dctq[40];
    dctqz[21] = dctq[48];
    dctqz[22] = dctq[41];
    dctqz[23] = dctq[34];

    dctqz[24] = dctq[27];
    dctqz[25] = dctq[20];
    dctqz[26] = dctq[13];
    dctqz[27] = dctq[6];
    dctqz[28] = dctq[7];
    dctqz[29] = dctq[14];
    dctqz[30] = dctq[21];
    dctqz[31] = dctq[28];

    dctqz[32] = dctq[35];
    dctqz[33] = dctq[42];
    dctqz[34] = dctq[49];
    dctqz[35] = dctq[56];
    dctqz[36] = dctq[57];
    dctqz[37] = dctq[50];
    dctqz[38] = dctq[43];
    dctqz[39] = dctq[36];

    dctqz[40] = dctq[29];
    dctqz[41] = dctq[22];
    dctqz[42] = dctq[15];
    dctqz[43] = dctq[23];
    dctqz[44] = dctq[30];
    dctqz[45] = dctq[37];
    dctqz[46] = dctq[44];
    dctqz[47] = dctq[51];

    dctqz[48] = dctq[58];
    dctqz[49] = dctq[59];
    dctqz[50] = dctq[52];
    dctqz[51] = dctq[45];
    dctqz[52] = dctq[38];
    dctqz[53] = dctq[31];
    dctqz[54] = dctq[39];
    dctqz[55] = dctq[46];

    dctqz[56] = dctq[53];
    dctqz[57] = dctq[60];
    dctqz[58] = dctq[61];
    dctqz[59] = dctq[54];
    dctqz[60] = dctq[47];
    dctqz[61] = dctq[55];
    dctqz[62] = dctq[62];
    dctqz[63] = dctq[63];


    // Write DCTQZ To Output File
    for(i=0; i < 64; i++) {
      SourceCHR = dctqz[i] >> 8;
      fseek(target_file, wofs, SEEK_SET);
      writevalue(SourceCHR, target_file);
      wofs++;

      SourceCHR = dctqz[i] & 0xFF;
      fseek(target_file, wofs, SEEK_SET);
      writevalue(SourceCHR, target_file);
      wofs++;
    }

    if((wofs & 0x7FF) == 0) wofs += 2048;
  }

}
コード例 #4
0
ファイル: BMP2DCT8BIT.c プロジェクト: PeterLemon/N64
// Convert 32-Bit/24-Bit BMP To 8-Bit DCT Quantization Block File
static void convert_dct(FILE *source_file, FILE *target_file, long ofs, long ofs_end) {
  ofs = 0x12;
  fseek(source_file, ofs, SEEK_SET);
  width = readvalue(source_file);
  width += (readvalue(source_file))<<8;
  width += (readvalue(source_file))<<16;
  width += (readvalue(source_file))<<24;

  height = readvalue(source_file);
  height += (readvalue(source_file))<<8;
  height += (readvalue(source_file))<<16;
  height += (readvalue(source_file))<<24;

  ofs = 0x1C;
  fseek(source_file, ofs, SEEK_SET);
  depth = readvalue(source_file);
  depth += (readvalue(source_file))<<8;

  unsigned int i = 0;
  unsigned int u = 0;
  unsigned int v = 0;
  unsigned int x = 0;
  unsigned int y = 0;

  // Fill JPEG Standard Quantization 8x8 Matrix Set By Quality Level
  for(i=0; i < 64; i++) {
    if(quality > 50) q[i] = q50[i] * (100-quality)/50;
    if(quality < 50) q[i] = q50[i] * 50/quality;
    if(quality == 50) q[i] = q50[i];
    if(q[i] > 255) q[i] = 255;
    if(q[i] < 1) q[i] = 1;
  }

  // Fill COS Look Up Table
  for(u=0; u < 8; u++) {
    for(x=0; x < 8; x++) coslut[u*8 + x] = cos((2*x + 1) * u * M_PI / 16);
  }

  // Loop Blocks
  ofs = ofs_end - ((depth / 8) * width);
  long wofs = 0;
  unsigned int block_row = 0; // Block Row Counter
  while(wofs < width * height) {

    // Load Image Block (Red Channel)
    for(y=0; y < 8; y++) {
      for(x=0; x < 8; x++) {
        fseek(source_file, ofs, SEEK_SET);
        SourceCHR = readvalue(source_file);
        image[y*8 + x] = SourceCHR;
        ofs += (depth / 8);
      }
      ofs -= ((depth / 8) * width) + ((depth / 8) * 8); // Next Scanline In Block
    }

    block_row++;
    if(block_row == (width / 8)) {
      block_row = 0; // Next Column Block
      ofs += (depth / 8) * 8;
      ofs -= ((depth / 8) * width);
    }
    else ofs += ((depth / 8) * (width * 8)) + ((depth / 8) * 8); // Next Block Row

    // Clear DCT Block
    for(i=0; i < 64; i++) dct[i] = 0.0;

    // Write DCT Block
    for(u=0; u < 8; u++) {
      for(v=0; v < 8; v++) {
        for(x=0; x < 8; x++) {
          for(y=0; y < 8; y++) {
            dct[v*8 + u] += (
              image[y*8 + x]
              * clut[u]
              * clut[v]
              * coslut[u*8 + x] // cos((2*x + 1) * u * pi / 16)
              * coslut[v*8 + y] // cos((2*y + 1) * v * pi / 16)
            );
          }
        }
      }
    }

    // Write DCTQ Block (Quantization)
    for(i=0; i < 64; i++) dctq[i] = dct[i] / q[i];

    // Write DCTQ To Output File
    for(i=0; i < 64; i++) {
      SourceCHR = dctq[i];
      fseek(target_file, wofs, SEEK_SET);
      writevalue(SourceCHR, target_file);
      wofs++;
    }
  }

}