コード例 #1
0
ファイル: getMLE.cpp プロジェクト: axrt/gbra
inline const NumericVector * E (const NumericMatrix& mtx){
  
  const NumericVector * rm=rowMeans(mtx);
  const NumericVector * jt=jitter(*rm);
  delete rm;
  
  return jt;
}
コード例 #2
0
ファイル: Movie.cpp プロジェクト: williamedwardhahn/OpenPV
/**
 * - Update the image buffers
 * - If the time is a multiple of biasChangetime then the position of the bias (biasX, biasY) changes.
 * - With probability persistenceProb the offset position (offsetX, offsetY) remains unchanged.
 * - Otherwise, with probability (1-persistenceProb) the offset position performs a random walk
 *   around the bias position (biasX, biasY).
 *
 * - If the time is a multiple of displayPeriod then load the next image.
 * - If nf=1 then the image is converted to grayscale during the call to read(filename, offsetX, offsetY).
 *   If nf>1 then the image is loaded with color information preserved.
 * - Return true if buffers have changed
 */
bool Movie::updateImage(double time, double dt)
{
   if( jitterFlag ) {
      jitter();
   } // jitterFlag

   InterColComm * icComm = getParent()->icCommunicator();

      //TODO: Fix movie layer to take with batches. This is commented out for compile
      //if(!flipOnTimescaleError && (parent->getTimeScale() > 0 && parent->getTimeScale() < parent->getTimeScaleMin())){
      //   if (parent->icCommunicator()->commRank()==0) {
      //      std::cout << "timeScale of " << parent->getTimeScale() << " is less than timeScaleMin of " << parent->getTimeScaleMin() << ", Movie is keeping the same frame\n";
      //   }
      //}
      //else{
         //Only do this if it's not the first update timestep
         //The timestep number is (time - startTime)/(width of timestep), with allowance for roundoff.
         //But if we're using adaptive timesteps, the dt passed as a function argument is not the correct (width of timestep).  
      if(fabs(time - (parent->getStartTime() + parent->getDeltaTime())) > (parent->getDeltaTime()/2)){
         int status = getFrame(time, dt);
         assert(status == PV_SUCCESS);
      }
      
      


      //nextDisplayTime removed, now using nextUpdateTime in HyPerLayer
      //while (time >= nextDisplayTime) {
      //   nextDisplayTime += displayPeriod;
      //}
      //Set frame number (member variable in Image)
      
      //Write to timestamp file here when updated
      if( icComm->commRank()==0 ) {
          //Only write if the parameter is set
          if(timestampFile){
             std::ostringstream outStrStream;
             outStrStream.precision(15);
             int kb0 = getLayerLoc()->kb0;
             for(int b = 0; b < parent->getNBatch(); b++){
                outStrStream << time << "," << b+kb0 << "," << frameNumbers[b] << "," << framePath[b] << "\n";
             }

             size_t len = outStrStream.str().length();
             int status = PV_fwrite(outStrStream.str().c_str(), sizeof(char), len, timestampFile)==len ? PV_SUCCESS : PV_FAILURE;
             if (status != PV_SUCCESS) {
                fprintf(stderr, "%s \"%s\" error: Movie::updateState failed to write to timestamp file.\n", getKeyword(), name);
                exit(EXIT_FAILURE);
             }
             //Flush buffer
             fflush(timestampFile->fp);
          }
      }
   //} // randomMovie

   return true;
}
コード例 #3
0
ファイル: Main.cpp プロジェクト: xiushudongfang/Play--CodeGen
int main(int argc, const char** argv)
{
	Jitter::CJitter jitter(Jitter::CreateCodeGen());
	for(const auto& factory : s_factories)
	{
		auto test = factory();
		test->Compile(jitter);
		test->Run();
		delete test;
	}
	return 0;
}
コード例 #4
0
ファイル: pyjit.cpp プロジェクト: acccounttest/Pyjion
extern "C" __declspec(dllexport) PyJittedCode* JitCompile(PyCodeObject* code) {
    if (strcmp(PyUnicode_AsUTF8(code->co_name), "<module>") == 0) {
        return nullptr;
    }
#ifdef DEBUG_TRACE
    static int compileCount = 0, failCount = 0;
    printf("Compiling %s from %s line %d #%d (%d failures so far)\r\n",
        PyUnicode_AsUTF8(code->co_name),
        PyUnicode_AsUTF8(code->co_filename),
        code->co_firstlineno,
        ++compileCount,
        failCount);
#endif

    PythonCompiler jitter(code);
    AbstractInterpreter interp(code, &jitter);
    auto res = interp.compile();

    if (res == nullptr) {
#ifdef DEBUG_TRACE
        printf("Compilation failure #%d\r\n", ++failCount);
#endif
        return nullptr;
    }

    auto jittedCode = (PyJittedCode*)PyJittedCode_New();
    if (jittedCode == nullptr) {
        // OOM
        delete res;
        return nullptr;
    }

    g_jittedCode[jittedCode] = res;
    jittedCode->j_evalfunc = &Jit_EvalHelper; //(Py_EvalFunc)res->get_code_addr();
    jittedCode->j_evalstate = res->get_code_addr();
    return jittedCode;
}
コード例 #5
0
ファイル: blender_light_direct.cpp プロジェクト: 2asoft/xray
//	TODO: DX10:	implement CBlender_accum_direct::Compile
void	CBlender_accum_direct_volumetric_sun_msaa::Compile(CBlender_Compile& C)
{
	IBlender::Compile		(C);

   if( Name )
      ::Render->m_MSAASample = atoi( Definition );
   else
      ::Render->m_MSAASample = -1;

	switch (C.iElement)
		{
		case 0:		// near pass - enable Z-test to perform depth-clipping
			C.r_Pass			("stub_notransform_2uv","accum_volumetric_sun_msaa",	false,	false,	false, true,D3DBLEND_ONE,D3DBLEND_ONE,false,0);
         C.r_dx10Texture		("s_smap",			r2_RT_smap_depth);
         C.r_dx10Texture		("s_position",		r2_RT_P);
         jitter				(C);

         C.r_dx10Sampler		("smp_nofilter");
         C.r_dx10Sampler		("smp_smap");
         C.r_End				();
			break;
		}
   ::Render->m_MSAASample = -1;
}
コード例 #6
0
ファイル: Knob.cpp プロジェクト: AlexLevkovich/Qigsaw
void Knob::initPath() {
    double data[DATA_LEN][DATA_LEN];
    for (int i=0;i<DATA_LEN;i++) {
        for (int j=0;j<DATA_LEN;j++) {
            data[i][j] = ctl[i][j];
        }
    }

    jitter (data, XVARY, YVARY, XDBVARY, XDFVARY);
    cPath.setFillRule(Qt::WindingFill);
    cPathReverse.setFillRule(Qt::WindingFill);
    cPath.moveTo(data[0][X],data[0][Y]);
    cPathReverse.moveTo(data[DATA_LEN-1][X],data[DATA_LEN-1][Y]);
    for (int i = 0; i < (DATA_LEN-1); i++) {
      curveTo (cPath,        data,               i, true);
      curveTo (cPathReverse, data,    DATA_LEN-1-i, false);
    }

    // Transform to coincide with line segment (x1,y1)-(x2,y2)

    QMatrix affine(x2-x1, y2-y1,  y1-y2, x2-x1,  x1, y1);
    cPath=affine.map(cPath);
    cPathReverse=affine.map(cPathReverse);
}
コード例 #7
0
ファイル: rtjitter.c プロジェクト: Sophiealex/jgt-code
void raytrace(int argc, char **argv)
{
  int x, y, *tmpsamp, i, sampleno=CELLX*CELLY;
  Pixel *tmppix;
  Float usertime, systime, lasttime, upos, vpos;
  Float samples[CELLX*CELLY*2];
  Pixel acc, tmp;

  /*
   * If this is the first frame,
   * allocate scanlines, etc.
   */
  if (Options.framenum == Options.startframe)
    RaytraceInit();
  /*
   * The top-level ray TopRay always has as its origin the
   * eye position and as its medium NULL, indicating that it
   * is passing through a medium with index of refraction
   * equal to DefIndex.
   */
  TopRay.pos = Camera.pos;
  TopRay.media = (Medium *)0;
  TopRay.depth = 0;

  lasttime = 0;
  for (y=0; y < Screen.ysize; y++) {

	for (x = 0; x < Screen.xsize; x++) {
		jitter(CELLX, CELLY, samples);
		acc.r = acc.g = acc.b = acc.alpha = 0;
		for (i=0 ; i<sampleno ; i++) {
	   		vpos = y + Screen.miny + samples[(i<<1)+1];
			upos = x + Screen.minx + samples[i<<1];
			TopRay.time = SampleTime(0);
			SampleScreen(upos, vpos, &TopRay, &tmp, 0);
			acc.r += tmp.r;
			acc.g += tmp.g;
			acc.b += tmp.b;
		}
		pix[x].r = acc.r/sampleno; /* box filter, or average */
		pix[x].g = acc.g/sampleno; 
		pix[x].b = acc.b/sampleno; 
		pix[x].alpha = 0;
	}
  
  	PictureWriteLine(pix); /* write the scanline */

	if ((y+Screen.miny-1) % Options.report_freq == 0) {
		fprintf(Stats.fstats,"Finished line %d (%lu rays",
					y+Screen.miny-1,
					Stats.EyeRays);
		if (Options.verbose) {
			/*
			* Report total CPU and split times.
			*/
			RSGetCpuTime(&usertime, &systime);
			fprintf(Stats.fstats,", %2.2f sec,", usertime+systime);
			fprintf(Stats.fstats," %2.2f split", usertime+systime-lasttime);
			lasttime = usertime+systime;
		}
	}
	fprintf(Stats.fstats,")\n");
	(void)fflush(Stats.fstats);
  }
}
コード例 #8
0
ファイル: blender_combine.cpp プロジェクト: 2asoft/xray-16
void	CBlender_combine::Compile(CBlender_Compile& C)
{
	IBlender::Compile		(C);

	switch (C.iElement)
	{
	case 0:	// combine
		C.r_Pass			("combine_1",		"combine_1_nomsaa",		FALSE,	FALSE,	FALSE, TRUE, D3DBLEND_INVSRCALPHA, D3DBLEND_SRCALPHA);	//. MRT-blend?
		C.r_Stencil			(TRUE,D3DCMP_LESSEQUAL,0xff,0x00);	// stencil should be >= 1
		C.r_StencilRef		(0x01);
		//C.r_Sampler_rtf		("s_position",		r2_RT_P				);
		//C.r_Sampler_rtf		("s_normal",		r2_RT_N				);
		//C.r_Sampler_rtf		("s_diffuse",		r2_RT_albedo		);
		//C.r_Sampler_rtf		("s_accumulator",	r2_RT_accum			);
		//C.r_Sampler_rtf		("s_depth",			r2_RT_depth			);
		//C.r_Sampler_rtf		("s_tonemap",		r2_RT_luminance_cur	);
		//C.r_Sampler_clw		("s_material",		r2_material			);
		//C.r_Sampler_clf		("env_s0",			r2_T_envs0			);
		//C.r_Sampler_clf		("env_s1",			r2_T_envs1			);
		//C.r_Sampler_clf		("sky_s0",			r2_T_sky0			);
		//C.r_Sampler_clf		("sky_s1",			r2_T_sky1			);

		C.r_dx10Texture		("s_position",		r2_RT_P				);
		C.r_dx10Texture		("s_normal",		r2_RT_N				);
		C.r_dx10Texture		("s_diffuse",		r2_RT_albedo		);
		C.r_dx10Texture		("s_accumulator",	r2_RT_accum			);
		C.r_dx10Texture		("s_depth",			r2_RT_depth			);
		C.r_dx10Texture		("s_tonemap",		r2_RT_luminance_cur	);
		C.r_dx10Texture		("s_material",		r2_material			);
		C.r_dx10Texture		("env_s0",			r2_T_envs0			);
		C.r_dx10Texture		("env_s1",			r2_T_envs1			);
		C.r_dx10Texture		("sky_s0",			r2_T_sky0			);
		C.r_dx10Texture		("sky_s1",			r2_T_sky1			);
		C.r_dx10Texture		("s_occ",			r2_RT_ssao_temp		);
		C.r_dx10Texture		("s_half_depth",	r2_RT_half_depth	);

		jitter(C);

		C.r_dx10Sampler		("smp_nofilter");
		C.r_dx10Sampler		("smp_material");
		C.r_dx10Sampler		("smp_rtlinear");
		C.r_End				();
		break;
	case 1:	// aa-edge-detection + AA :)
		C.r_Pass			("stub_notransform_aa_AA","combine_2_AA",		FALSE,	FALSE,	FALSE);
		//C.r_Sampler_rtf		("s_position",		r2_RT_P);
		//C.r_Sampler_rtf		("s_normal",		r2_RT_N);
		//C.r_Sampler_clf		("s_image",			r2_RT_generic0);
		//C.r_Sampler_clf		("s_bloom",			r2_RT_bloom1);
		//C.r_Sampler_clf		("s_distort",		r2_RT_generic1);

		C.r_dx10Texture		("s_position",		r2_RT_P);
		C.r_dx10Texture		("s_normal",		r2_RT_N);
		C.r_dx10Texture		("s_image",			r2_RT_generic0);
		C.r_dx10Texture		("s_bloom",			r2_RT_bloom1);
		C.r_dx10Texture		("s_distort",		r2_RT_generic1);

		C.r_dx10Sampler		("smp_nofilter");
		C.r_dx10Sampler		("smp_rtlinear");
		C.r_End				();
		break;
	case 2:	// non-AA
		//	Can use simpler VS (need only Tex0)
		C.r_Pass			("stub_notransform_aa_AA","combine_2_NAA",	FALSE,	FALSE,	FALSE);
		//C.r_Sampler_rtf		("s_position",		r2_RT_P);
		//C.r_Sampler_rtf		("s_normal",		r2_RT_N);
		//C.r_Sampler_clf		("s_image",			r2_RT_generic0);
		//C.r_Sampler_clf		("s_bloom",			r2_RT_bloom1);
		//C.r_Sampler_clf		("s_distort",		r2_RT_generic1);

		C.r_dx10Texture		("s_position",		r2_RT_P);
		C.r_dx10Texture		("s_normal",		r2_RT_N);
		C.r_dx10Texture		("s_image",			r2_RT_generic0);
		C.r_dx10Texture		("s_bloom",			r2_RT_bloom1);
		C.r_dx10Texture		("s_distort",		r2_RT_generic1);

		C.r_dx10Sampler		("smp_nofilter");
		C.r_dx10Sampler		("smp_rtlinear");
		C.r_End				();
		break;
	case 3:	// aa-edge-detection + AA :) + DISTORTION
		C.r_Pass			("stub_notransform_aa_AA","combine_2_AA_D",	FALSE,	FALSE,	FALSE);
		//C.r_Sampler_rtf		("s_position",		r2_RT_P);
		//C.r_Sampler_rtf		("s_normal",		r2_RT_N);
		//C.r_Sampler_clf		("s_image",			r2_RT_generic0);
		//C.r_Sampler_clf		("s_bloom",			r2_RT_bloom1);
		//C.r_Sampler_clf		("s_distort",		r2_RT_generic1);

		C.r_dx10Texture		("s_position",		r2_RT_P);
		C.r_dx10Texture		("s_normal",		r2_RT_N);
		C.r_dx10Texture		("s_image",			r2_RT_generic0);
		C.r_dx10Texture		("s_bloom",			r2_RT_bloom1);
		C.r_dx10Texture		("s_distort",		r2_RT_generic1);

		C.r_dx10Sampler		("smp_nofilter");
		C.r_dx10Sampler		("smp_rtlinear");
		C.r_End				();
		break;
	case 4:	// non-AA + DISTORTION
		//	Can use simpler VS (need only Tex0)
		C.r_Pass			("stub_notransform_aa_AA","combine_2_NAA_D",	FALSE,	FALSE,	FALSE);
		//C.r_Sampler_rtf		("s_position",		r2_RT_P);
		//C.r_Sampler_rtf		("s_normal",		r2_RT_N);
		//C.r_Sampler_clf		("s_image",			r2_RT_generic0);
		//C.r_Sampler_clf		("s_bloom",			r2_RT_bloom1);
		//C.r_Sampler_clf		("s_distort",		r2_RT_generic1);

		C.r_dx10Texture		("s_position",		r2_RT_P);
		C.r_dx10Texture		("s_normal",		r2_RT_N);
		C.r_dx10Texture		("s_image",			r2_RT_generic0);
		C.r_dx10Texture		("s_bloom",			r2_RT_bloom1);
		C.r_dx10Texture		("s_distort",		r2_RT_generic1);

		C.r_dx10Sampler		("smp_nofilter");
		C.r_dx10Sampler		("smp_rtlinear");
		C.r_End				();
		break;
	case 5:	// post-processing
		break;
	}
}
コード例 #9
0
ファイル: blender_combine.cpp プロジェクト: 2asoft/xray
void	CBlender_combine::Compile(CBlender_Compile& C)
{
	IBlender::Compile		(C);

	switch (C.iElement)
	{
	case 0:	// combine
		C.r_Pass			("combine_1",		"combine_1",		FALSE,	FALSE,	FALSE, TRUE, D3DBLEND_INVSRCALPHA, D3DBLEND_SRCALPHA);	//. MRT-blend?
		C.r_Sampler_rtf		("s_position",		r2_RT_P				);
		C.r_Sampler_rtf		("s_normal",		r2_RT_N				);
		C.r_Sampler_rtf		("s_diffuse",		r2_RT_albedo		);
		C.r_Sampler_rtf		("s_accumulator",	r2_RT_accum			);
		C.r_Sampler_rtf		("s_depth",			r2_RT_depth			);
		C.r_Sampler_rtf		("s_tonemap",		r2_RT_luminance_cur	);
		C.r_Sampler_clw		("s_material",		r2_material			);
		C.r_Sampler_clw		("s_occ",			r2_RT_ssao_temp		);
		C.r_Sampler_rtf		("s_half_depth",	r2_RT_half_depth);
		C.r_Sampler_clf		("env_s0",			r2_T_envs0			);
		C.r_Sampler_clf		("env_s1",			r2_T_envs1			);
		C.r_Sampler_clf		("sky_s0",			r2_T_sky0			);
		C.r_Sampler_clf		("sky_s1",			r2_T_sky1			);
		jitter(C);
		C.r_End				();
		break;
	case 1:	// aa-edge-detection + AA :)
		C.r_Pass			("null",			"combine_2_AA",		FALSE,	FALSE,	FALSE);
		C.r_Sampler_rtf		("s_position",		r2_RT_P);
		C.r_Sampler_rtf		("s_normal",		r2_RT_N);
		C.r_Sampler_clf		("s_image",			r2_RT_generic0);
		C.r_Sampler_clf		("s_bloom",			r2_RT_bloom1);
		C.r_Sampler_clf		("s_distort",		r2_RT_generic1);
		C.r_End				();
		break;
	case 2:	// non-AA
		C.r_Pass			("null",			"combine_2_NAA",	FALSE,	FALSE,	FALSE);
		C.r_Sampler_rtf		("s_position",		r2_RT_P);
		C.r_Sampler_rtf		("s_normal",		r2_RT_N);
		C.r_Sampler_clf		("s_image",			r2_RT_generic0);
		C.r_Sampler_clf		("s_bloom",			r2_RT_bloom1);
		C.r_Sampler_clf		("s_distort",		r2_RT_generic1);
		C.r_End				();
		break;
	case 3:	// aa-edge-detection + AA :) + DISTORTION
		C.r_Pass			("null",			"combine_2_AA_D",	FALSE,	FALSE,	FALSE);
		C.r_Sampler_rtf		("s_position",		r2_RT_P);
		C.r_Sampler_rtf		("s_normal",		r2_RT_N);
		C.r_Sampler_clf		("s_image",			r2_RT_generic0);
		C.r_Sampler_clf		("s_bloom",			r2_RT_bloom1);
		C.r_Sampler_clf		("s_distort",		r2_RT_generic1);
		C.r_End				();
		break;
	case 4:	// non-AA + DISTORTION
		C.r_Pass			("null",			"combine_2_NAA_D",	FALSE,	FALSE,	FALSE);
		C.r_Sampler_rtf		("s_position",		r2_RT_P);
		C.r_Sampler_rtf		("s_normal",		r2_RT_N);
		C.r_Sampler_clf		("s_image",			r2_RT_generic0);
		C.r_Sampler_clf		("s_bloom",			r2_RT_bloom1);
		C.r_Sampler_clf		("s_distort",		r2_RT_generic1);
		C.r_End				();
		break;
	case 5:	// post-processing
		break;
	}
}
コード例 #10
0
int main_0015_offsets_seek (int argc, char **argv) {
    const char *topic = test_mk_topic_name("0015", 1);
    rd_kafka_t *rk_p, *rk_c;
    rd_kafka_topic_t *rkt_p, *rkt_c;
    int msg_cnt = 1000;
    int msg_base = 0;
    int32_t partition = 0;
    int i;
    int64_t offset_last, offset_base;
    uint64_t testid;
    int dance_iterations = 10;
    int msgs_per_dance = 10;

    testid = test_id_generate();

    /* Produce messages */
    rk_p = test_create_producer();
    rkt_p = test_create_producer_topic(rk_p, topic, NULL);

    test_produce_msgs(rk_p, rkt_p, testid, partition, msg_base, msg_cnt,
                      NULL, 0);

    rd_kafka_topic_destroy(rkt_p);
    rd_kafka_destroy(rk_p);


    rk_c = test_create_consumer(NULL, NULL, NULL, NULL);
    rkt_c = test_create_consumer_topic(rk_c, topic);

    /* Start consumer tests */
    test_consumer_start("verify.all", rkt_c, partition,
                        RD_KAFKA_OFFSET_BEGINNING);
    /* Make sure all messages are available */
    offset_last = test_consume_msgs("verify.all", rkt_c,
                                    testid, partition, TEST_NO_SEEK,
                                    msg_base, msg_cnt, 1/* parse format*/);

    /* Rewind offset back to its base. */
    offset_base = offset_last - msg_cnt + 1;

    TEST_SAY("%s [%"PRId32"]: Do random seek&consume for msgs #%d+%d with "
             "offsets %"PRId64"..%"PRId64"\n",
             rd_kafka_topic_name(rkt_c), partition,
             msg_base, msg_cnt, offset_base, offset_last);

    /* Now go dancing over the entire range with offset seeks. */
    for (i = 0 ; i < dance_iterations ; i++) {
        int64_t offset = jitter((int)offset_base,
                                (int)offset_base+msg_cnt);

        test_consume_msgs("dance", rkt_c,
                          testid, partition, offset,
                          msg_base + (int)(offset - offset_base),
                          RD_MIN(msgs_per_dance,
                                 (int)(offset_last - offset)),
                          1 /* parse format */);
    }

    test_consumer_stop("1", rkt_c, partition);

    rd_kafka_topic_destroy(rkt_c);
    rd_kafka_destroy(rk_c);

    return 0;
}
コード例 #11
0
ファイル: BitmapText.cpp プロジェクト: Ancaro/stepmania
// draw text at x, y using colorTop blended down to colorBottom, with size multiplied by scale
void BitmapText::DrawPrimitives()
{
	Actor::SetGlobalRenderStates(); // set Actor-specified render states
	DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Modulate );

	// Draw if we're not fully transparent or the zbuffer is enabled
	if( m_pTempState->diffuse[0].a != 0 )
	{
		// render the shadow
		if( m_fShadowLengthX != 0  ||  m_fShadowLengthY != 0 )
		{
			DISPLAY->PushMatrix();
			DISPLAY->TranslateWorld( m_fShadowLengthX, m_fShadowLengthY, 0 );

			RageColor c = m_ShadowColor;
			c.a *= m_pTempState->diffuse[0].a;
			for( unsigned i=0; i<m_aVertices.size(); i++ )
				m_aVertices[i].c = c;
			DrawChars( false );

			DISPLAY->PopMatrix();
		}

		// render the stroke
		if( m_StrokeColor.a > 0 )
		{
			RageColor c = m_StrokeColor;
			c.a *= m_pTempState->diffuse[0].a;
			for( unsigned i=0; i<m_aVertices.size(); i++ )
				m_aVertices[i].c = c;
			DrawChars( true );
		}

		// render the diffuse pass
		if( m_bRainbowScroll )
		{
			int color_index = int(RageTimer::GetTimeSinceStartFast() / 0.200) % RAINBOW_COLORS.size();
			for( unsigned i=0; i<m_aVertices.size(); i+=4 )
			{
				const RageColor color = RAINBOW_COLORS[color_index];
				for( unsigned j=i; j<i+4; j++ )
					m_aVertices[j].c = color;

				color_index = (color_index+1) % RAINBOW_COLORS.size();
			}
		}
		else
		{
			size_t i = 0;
			map<size_t,Attribute>::const_iterator iter = m_mAttributes.begin();
			while( i < m_aVertices.size() )
			{
				// Set the colors up to the next attribute.
				size_t iEnd = iter == m_mAttributes.end()? m_aVertices.size():iter->first*4;
				iEnd = min( iEnd, m_aVertices.size() );
				for( ; i < iEnd; i += 4 )
				{
					m_aVertices[i+0].c = m_pTempState->diffuse[0];	// top left
					m_aVertices[i+1].c = m_pTempState->diffuse[2];	// bottom left
					m_aVertices[i+2].c = m_pTempState->diffuse[3];	// bottom right
					m_aVertices[i+3].c = m_pTempState->diffuse[1];	// top right
				}
				if( iter == m_mAttributes.end() )
					break;
				// Set the colors according to this attribute.
				const Attribute &attr = iter->second;
				++iter;
				if( attr.length < 0 )
					iEnd = iter == m_mAttributes.end()? m_aVertices.size():iter->first*4;
				else
					iEnd = i + attr.length*4;
				iEnd = min( iEnd, m_aVertices.size() );
				for( ; i < iEnd; i += 4 )
				{
					m_aVertices[i+0].c = attr.diffuse[0];	// top left
					m_aVertices[i+1].c = attr.diffuse[2];	// bottom left
					m_aVertices[i+2].c = attr.diffuse[3];	// bottom right
					m_aVertices[i+3].c = attr.diffuse[1];	// top right
				}
			}
		}

		// apply jitter to verts
		vector<RageVector3> vGlyphJitter;
		if( m_bJitter )
		{
			int iSeed = lrintf( RageTimer::GetTimeSinceStartFast()*8 );
			RandomGen rnd( iSeed );

			for( unsigned i=0; i<m_aVertices.size(); i+=4 )
			{
				RageVector3 jitter( rnd()%2, rnd()%3, 0 );
				vGlyphJitter.push_back( jitter );

				m_aVertices[i+0].p += jitter;	// top left
				m_aVertices[i+1].p += jitter;	// bottom left
				m_aVertices[i+2].p += jitter;	// bottom right
				m_aVertices[i+3].p += jitter;	// top right
			}
		}

		DrawChars( false );

		// undo jitter to verts
		if( m_bJitter )
		{
			ASSERT( vGlyphJitter.size() == m_aVertices.size()/4 );
			for( unsigned i=0; i<m_aVertices.size(); i+=4 )
			{
				const RageVector3 &jitter = vGlyphJitter[i/4];;

				m_aVertices[i+0].p -= jitter;	// top left
				m_aVertices[i+1].p -= jitter;	// bottom left
				m_aVertices[i+2].p -= jitter;	// bottom right
				m_aVertices[i+3].p -= jitter;	// top right
			}
		}
	}

	// render the glow pass
	if( m_pTempState->glow.a > 0.0001f || m_bHasGlowAttribute )
	{
		DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Glow );

		size_t i = 0;
		map<size_t,Attribute>::const_iterator iter = m_mAttributes.begin();
		while( i < m_aVertices.size() )
		{
			// Set the glow up to the next attribute.
			size_t iEnd = iter == m_mAttributes.end()? m_aVertices.size():iter->first*4;
			iEnd = min( iEnd, m_aVertices.size() );
			for( ; i < iEnd; ++i )
				m_aVertices[i].c = m_pTempState->glow;
			if( iter == m_mAttributes.end() )
				break;
			// Set the glow according to this attribute.
			const Attribute &attr = iter->second;
			++iter;
			if( attr.length < 0 )
				iEnd = iter == m_mAttributes.end()? m_aVertices.size():iter->first*4;
			else
				iEnd = i + attr.length*4;
			iEnd = min( iEnd, m_aVertices.size() );
			for( ; i < iEnd; ++i )
				m_aVertices[i].c = attr.glow;
		}
		/* Draw glow using the base texture and the glow texture. Otherwise,
		 * glow looks too tame on BitmapText that has a stroke. - Chris Danford */
		/* This doesn't work well if the font is using an invisible stroke, as
		 * the invisible stroke will glow as well. Time for TextGlowMode.
		 * Only draw the strokes if the glow mode is not inner only. -aj */
		DrawChars(m_TextGlowMode != TextGlowMode_Inner);
	}
}
コード例 #12
0
    void DifferentialEvolution::calculateNextGeneration(
                                     std::vector<Candidate>& population,
                                     const CostFunction& costFunction) const {

        std::vector<Candidate> mirrorPopulation;
        std::vector<Candidate> oldPopulation = population;

        switch (configuration().strategy) {

          case Rand1Standard: {
              std::random_shuffle(population.begin(), population.end());
              std::vector<Candidate> shuffledPop1 = population;
              std::random_shuffle(population.begin(), population.end());
              std::vector<Candidate> shuffledPop2 = population;
              std::random_shuffle(population.begin(), population.end());
              mirrorPopulation = shuffledPop1;

              for (Size popIter = 0; popIter < population.size(); popIter++) {
                  population[popIter].values = population[popIter].values
                      + configuration().stepsizeWeight
                      * (shuffledPop1[popIter].values - shuffledPop2[popIter].values);
              }
          }
            break;

          case BestMemberWithJitter: {
              std::random_shuffle(population.begin(), population.end());
              std::vector<Candidate> shuffledPop1 = population;
              std::random_shuffle(population.begin(), population.end());
              Array jitter(population[0].values.size(), 0.0);

              for (Size popIter = 0; popIter < population.size(); popIter++) {
                  for (Size jitterIter = 0; jitterIter < jitter.size(); jitterIter++) {
                      jitter[jitterIter] = rng_.nextReal();
                  }
                  population[popIter].values = bestMemberEver_.values
                      + (shuffledPop1[popIter].values - population[popIter].values)
                      * (0.0001 * jitter + configuration().stepsizeWeight);
              }
              mirrorPopulation = std::vector<Candidate>(population.size(),
                                                        bestMemberEver_);
          }
            break;

          case CurrentToBest2Diffs: {
              std::random_shuffle(population.begin(), population.end());
              std::vector<Candidate> shuffledPop1 = population;
              std::random_shuffle(population.begin(), population.end());

              for (Size popIter = 0; popIter < population.size(); popIter++) {
                  population[popIter].values = oldPopulation[popIter].values
                      + configuration().stepsizeWeight
                      * (bestMemberEver_.values - oldPopulation[popIter].values)
                      + configuration().stepsizeWeight
                      * (population[popIter].values - shuffledPop1[popIter].values);
              }
              mirrorPopulation = shuffledPop1;
          }
            break;

          case Rand1DiffWithPerVectorDither: {
              std::random_shuffle(population.begin(), population.end());
              std::vector<Candidate> shuffledPop1 = population;
              std::random_shuffle(population.begin(), population.end());
              std::vector<Candidate> shuffledPop2 = population;
              std::random_shuffle(population.begin(), population.end());
              mirrorPopulation = shuffledPop1;
              Array FWeight = Array(population.front().values.size(), 0.0);
              for (Size fwIter = 0; fwIter < FWeight.size(); fwIter++)
                  FWeight[fwIter] = (1.0 - configuration().stepsizeWeight)
                      * rng_.nextReal() + configuration().stepsizeWeight;
              for (Size popIter = 0; popIter < population.size(); popIter++) {
                  population[popIter].values = population[popIter].values
                      + FWeight * (shuffledPop1[popIter].values - shuffledPop2[popIter].values);
              }
          }
            break;

          case Rand1DiffWithDither: {
              std::random_shuffle(population.begin(), population.end());
              std::vector<Candidate> shuffledPop1 = population;
              std::random_shuffle(population.begin(), population.end());
              std::vector<Candidate> shuffledPop2 = population;
              std::random_shuffle(population.begin(), population.end());
              mirrorPopulation = shuffledPop1;
              Real FWeight = (1.0 - configuration().stepsizeWeight) * rng_.nextReal()
                  + configuration().stepsizeWeight;
              for (Size popIter = 0; popIter < population.size(); popIter++) {
                  population[popIter].values = population[popIter].values
                      + FWeight * (shuffledPop1[popIter].values - shuffledPop2[popIter].values);
              }
          }
            break;

          case EitherOrWithOptimalRecombination: {
              std::random_shuffle(population.begin(), population.end());
              std::vector<Candidate> shuffledPop1 = population;
              std::random_shuffle(population.begin(), population.end());
              std::vector<Candidate> shuffledPop2 = population;
              std::random_shuffle(population.begin(), population.end());
              mirrorPopulation = shuffledPop1;
              Real probFWeight = 0.5;
              if (rng_.nextReal() < probFWeight) {
                  for (Size popIter = 0; popIter < population.size(); popIter++) {
                      population[popIter].values = oldPopulation[popIter].values
                          + configuration().stepsizeWeight
                          * (shuffledPop1[popIter].values - shuffledPop2[popIter].values);
                  }
              } else {
                  Real K = 0.5 * (configuration().stepsizeWeight + 1); // invariant with respect to probFWeight used
                  for (Size popIter = 0; popIter < population.size(); popIter++) {
                      population[popIter].values = oldPopulation[popIter].values
                          + K
                          * (shuffledPop1[popIter].values - shuffledPop2[popIter].values
                             - 2.0 * population[popIter].values);
                  }
              }
          }
            break;

          case Rand1SelfadaptiveWithRotation: {
              std::random_shuffle(population.begin(), population.end());
              std::vector<Candidate> shuffledPop1 = population;
              std::random_shuffle(population.begin(), population.end());
              std::vector<Candidate> shuffledPop2 = population;
              std::random_shuffle(population.begin(), population.end());
              mirrorPopulation = shuffledPop1;

              adaptSizeWeights();

              for (Size popIter = 0; popIter < population.size(); popIter++) {
                  if (rng_.nextReal() < 0.1){
                      population[popIter].values = rotateArray(bestMemberEver_.values);
                  }else {
                      population[popIter].values = bestMemberEver_.values
                          + currGenSizeWeights_[popIter]
                          * (shuffledPop1[popIter].values - shuffledPop2[popIter].values);
                  }
              }
          }
            break;

          default:
            QL_FAIL("Unknown strategy ("
                    << Integer(configuration().strategy) << ")");
        }
        // in order to avoid unnecessary copying we use the same population object for mutants
        crossover(oldPopulation, population, population, mirrorPopulation,
                  costFunction);
    }
コード例 #13
0
ファイル: blender_light_direct.cpp プロジェクト: 2asoft/xray
void	CBlender_accum_direct::Compile(CBlender_Compile& C)
{
	IBlender::Compile		(C);

//	BOOL	b_HW_smap		= RImplementation.o.HW_smap;
//	BOOL	b_HW_PCF		= RImplementation.o.HW_smap_PCF;
	BOOL		blend		= FALSE;	//RImplementation.o.fp16_blend;
	D3DBLEND	dest		= blend?D3DBLEND_ONE:D3DBLEND_ZERO;
	if (RImplementation.o.sunfilter)	{ blend = FALSE; dest = D3DBLEND_ZERO; }

	switch (C.iElement)
	{
	case SE_SUN_NEAR:		// near pass - enable Z-test to perform depth-clipping
		//	FVF::TL2uv
		C.r_Pass			("stub_notransform_2uv","accum_sun_near_nomsaa_nominmax",	false,	TRUE,	FALSE,blend,D3DBLEND_ONE,dest);

		C.r_CullMode		(D3DCULL_NONE);
		C.PassSET_ZB		(TRUE,FALSE,TRUE	);	// force inverted Z-Buffer

		C.r_dx10Texture		("s_position",		r2_RT_P);
		C.r_dx10Texture		("s_normal",		r2_RT_N);
		C.r_dx10Texture		("s_material",		r2_material);
		C.r_dx10Texture		("s_accumulator",	r2_RT_accum);
		C.r_dx10Texture		("s_lmap",			r2_sunmask);
		C.r_dx10Texture		("s_smap",			r2_RT_smap_depth);
		C.r_dx10Texture		("s_smap_minmax",	r2_RT_smap_depth_minmax);

		C.r_dx10Sampler		("smp_nofilter");
		C.r_dx10Sampler		("smp_material");
		C.r_dx10Sampler		("smp_linear");
		jitter				(C);
		C.r_dx10Sampler		("smp_smap");

		C.r_End				();
		break;
	case SE_SUN_FAR:		// far pass, only stencil clipping performed
		//	FVF::TL2uv
		//C.r_Pass			("null",			"accum_sun_far",	false,	TRUE,	FALSE,blend,D3DBLEND_ONE,dest);
		C.r_Pass			("stub_notransform_2uv","accum_sun_far_nomsaa",	false,	TRUE,	FALSE,blend,D3DBLEND_ONE,dest);
		C.r_CullMode		(D3DCULL_NONE);
		//C.r_Sampler_rtf		("s_position",		r2_RT_P			);
		//C.r_Sampler_rtf		("s_normal",		r2_RT_N			);
		//C.r_Sampler_clw		("s_material",		r2_material		);
		//C.r_Sampler_rtf		("s_accumulator",	r2_RT_accum		);
		//C.r_Sampler			("s_lmap",			r2_sunmask		);
		//if (b_HW_smap)		{
		//	if (b_HW_PCF)	C.r_Sampler_clf		("s_smap",r2_RT_smap_depth	);
		//	else			{
		//		C.r_Sampler_rtf		("s_smap",r2_RT_smap_depth	);
		//	}
		//}
		//else				C.r_Sampler_rtf		("s_smap",r2_RT_smap_surf	);
		//jitter				(C);

		C.r_dx10Texture		("s_position",		r2_RT_P);
		C.r_dx10Texture		("s_normal",		r2_RT_N);
		C.r_dx10Texture		("s_material",		r2_material);
		C.r_dx10Texture		("s_accumulator",	r2_RT_accum);
		C.r_dx10Texture		("s_lmap",			r2_sunmask);
		C.r_dx10Texture		("s_smap",			r2_RT_smap_depth);

		C.r_dx10Sampler		("smp_nofilter");
		C.r_dx10Sampler		("smp_material");
		C.r_dx10Sampler		("smp_linear");
		jitter				(C);
		C.r_dx10Sampler		("smp_smap");

		C.r_End				();
		break;
	case SE_SUN_LUMINANCE:	// luminance pass
		//C.r_Pass			("null",			"accum_sun",		false,	FALSE,	FALSE);
		C.r_Pass			("stub_notransform_aa_AA","accum_sun_nomsaa",		false,	FALSE,	FALSE);
		C.r_CullMode		(D3DCULL_NONE);
		//C.r_Sampler_rtf		("s_position",		r2_RT_P			);
		//C.r_Sampler_rtf		("s_normal",		r2_RT_N			);
		//C.r_Sampler_clw		("s_material",		r2_material		);
		//C.r_Sampler_clf		("s_smap",			r2_RT_generic0	);
		//jitter				(C);

		C.r_dx10Texture		("s_position",		r2_RT_P);
		C.r_dx10Texture		("s_normal",		r2_RT_N);
		C.r_dx10Texture		("s_material",		r2_material);
		C.r_dx10Texture		("s_smap",			r2_RT_generic0);

		C.r_dx10Sampler		("smp_nofilter");
		C.r_dx10Sampler		("smp_material");
		jitter				(C);
		C.r_End				();
		break;

		//	SE_SUN_NEAR for min/max
	case SE_SUN_NEAR_MINMAX:		// near pass - enable Z-test to perform depth-clipping
		//	FVF::TL2uv
		C.r_Pass			("stub_notransform_2uv","accum_sun_near_nomsaa_minmax",	false,	TRUE,	FALSE,blend,D3DBLEND_ONE,dest);
		C.r_CullMode		(D3DCULL_NONE);
		C.PassSET_ZB		(TRUE,FALSE,TRUE	);	// force inverted Z-Buffer

		C.r_dx10Texture		("s_position",		r2_RT_P);
		C.r_dx10Texture		("s_normal",		r2_RT_N);
		C.r_dx10Texture		("s_material",		r2_material);
		C.r_dx10Texture		("s_accumulator",	r2_RT_accum);
		C.r_dx10Texture		("s_lmap",			r2_sunmask);
		C.r_dx10Texture		("s_smap",			r2_RT_smap_depth);
		C.r_dx10Texture		("s_smap_minmax",	r2_RT_smap_depth_minmax);

		C.r_dx10Sampler		("smp_nofilter");
		C.r_dx10Sampler		("smp_material");
		C.r_dx10Sampler		("smp_linear");
		jitter				(C);
		C.r_dx10Sampler		("smp_smap");

		C.r_End				();
		break;
		/*
	//	SE_SUN_FAR for min/max
	case 5:		// far pass, only stencil clipping performed
		//	FVF::TL2uv
		C.r_Pass			("stub_notransform_2uv","accum_sun_far_nomsaa",	false,	TRUE,	FALSE,blend,D3DBLEND_ONE,dest);
		C.r_CullMode		(D3DCULL_NONE);

		C.r_dx10Texture		("s_position",		r2_RT_P);
		C.r_dx10Texture		("s_normal",		r2_RT_N);
		C.r_dx10Texture		("s_material",		r2_material);
		C.r_dx10Texture		("s_accumulator",	r2_RT_accum);
		C.r_dx10Texture		("s_lmap",			r2_sunmask);
		C.r_dx10Texture		("s_smap",			r2_RT_smap_depth);

		C.r_dx10Sampler		("smp_nofilter");
		C.r_dx10Sampler		("smp_material");
		C.r_dx10Sampler		("smp_linear");
		jitter				(C);
		C.r_dx10Sampler		("smp_smap");

		C.r_End				();
		break;
		*/
	}
}
コード例 #14
0
//	TODO: DX10:	implement CBlender_accum_direct::Compile
void	CBlender_accum_direct_msaa::Compile(CBlender_Compile& C)
{
	IBlender::Compile		(C);

   if( Name )
      ::Render->m_MSAASample = atoi( Definition );
   else
      ::Render->m_MSAASample = -1;

//	BOOL	b_HW_smap		= RImplementation.o.HW_smap;
//	BOOL	b_HW_PCF		= RImplementation.o.HW_smap_PCF;
	BOOL		blend		= FALSE;	//RImplementation.o.fp16_blend;
	D3DBLEND	dest		= blend?D3DBLEND_ONE:D3DBLEND_ZERO;
	if (RImplementation.o.sunfilter)	{ blend = FALSE; dest = D3DBLEND_ZERO; }

	switch (C.iElement)
	{
	case SE_SUN_NEAR:		// near pass - enable Z-test to perform depth-clipping
	case SE_SUN_MIDDLE:		// middle pass - enable Z-test to perform depth-clipping
		//	FVF::TL2uv
		//C.r_Pass			("null",			"accum_sun_near",	false,	TRUE,	FALSE,blend,D3DBLEND_ONE,dest);
		C.r_Pass			("accum_sun","accum_sun_near_msaa_nominmax",	false,	TRUE,	FALSE,blend,D3DBLEND_ONE,dest);
		C.r_CullMode		(D3DCULL_NONE);
		C.PassSET_ZB		(TRUE,FALSE,TRUE	);	// force inverted Z-Buffer
		//C.r_Sampler_rtf		("s_position",		r2_RT_P			);
		//C.r_Sampler_rtf		("s_normal",		r2_RT_N			);
		//C.r_Sampler_clw		("s_material",		r2_material		);
		//C.r_Sampler_rtf		("s_accumulator",	r2_RT_accum		);
		//C.r_Sampler			("s_lmap",			r2_sunmask		);
		//if (b_HW_smap)		{
		//	if (b_HW_PCF)	C.r_Sampler_clf		("s_smap",r2_RT_smap_depth	);
		//	else			{
		//		C.r_Sampler_rtf		("s_smap",r2_RT_smap_depth	);
		//	}
		//}
		//else				C.r_Sampler_rtf		("s_smap",r2_RT_smap_surf	);
		//jitter				(C);

		C.r_dx10Texture		("s_position",		r2_RT_P);
		C.r_dx10Texture		("s_normal",		r2_RT_N);
		C.r_dx10Texture		("s_material",		r2_material);
		C.r_dx10Texture		("s_accumulator",	r2_RT_accum);
		C.r_dx10Texture		("s_lmap",			r2_sunmask);
		C.r_dx10Texture		("s_smap",			r2_RT_smap_depth);

		C.r_dx10Sampler		("smp_nofilter");
		C.r_dx10Sampler		("smp_material");
		C.r_dx10Sampler		("smp_linear");
		jitter				(C);
		C.r_dx10Sampler		("smp_smap");

		C.r_End				();
		break;
	case SE_SUN_FAR:		// far pass, only stencil clipping performed
		//	FVF::TL2uv
		//C.r_Pass			("null",			"accum_sun_far",	false,	TRUE,	FALSE,blend,D3DBLEND_ONE,dest);
		C.r_Pass			("accum_sun","accum_sun_far_msaa",	false,	TRUE,	FALSE,blend,D3DBLEND_ONE,dest);
		C.r_CullMode		(D3DCULL_NONE);
		//C.r_Sampler_rtf		("s_position",		r2_RT_P			);
		//C.r_Sampler_rtf		("s_normal",		r2_RT_N			);
		//C.r_Sampler_clw		("s_material",		r2_material		);
		//C.r_Sampler_rtf		("s_accumulator",	r2_RT_accum		);
		//C.r_Sampler			("s_lmap",			r2_sunmask		);
		//if (b_HW_smap)		{
		//	if (b_HW_PCF)	C.r_Sampler_clf		("s_smap",r2_RT_smap_depth	);
		//	else			{
		//		C.r_Sampler_rtf		("s_smap",r2_RT_smap_depth	);
		//	}
		//}
		//else				C.r_Sampler_rtf		("s_smap",r2_RT_smap_surf	);
		//jitter				(C);

		C.r_dx10Texture		("s_position",		r2_RT_P);
		C.r_dx10Texture		("s_normal",		r2_RT_N);
		C.r_dx10Texture		("s_material",		r2_material);
		C.r_dx10Texture		("s_accumulator",	r2_RT_accum);
		C.r_dx10Texture		("s_lmap",			r2_sunmask);
		C.r_dx10Texture		("s_smap",			r2_RT_smap_depth);

		C.r_dx10Sampler		("smp_nofilter");
		C.r_dx10Sampler		("smp_material");
		C.r_dx10Sampler		("smp_linear");
		jitter				(C);
		{
			u32 s = C.r_dx10Sampler("smp_smap");
			C.i_dx10Address		(s, D3DTADDRESS_BORDER);
			C.i_dx10BorderColor	(s, D3DCOLOR_ARGB(255, 255, 255, 255));
		}

		C.r_End				();
		break;
	case SE_SUN_LUMINANCE:	// luminance pass
		//C.r_Pass			("null",			"accum_sun",		false,	FALSE,	FALSE);
		C.r_Pass			("stub_notransform_aa_AA","accum_sun_msaa",		false,	FALSE,	FALSE);
		C.r_CullMode		(D3DCULL_NONE);
		//C.r_Sampler_rtf		("s_position",		r2_RT_P			);
		//C.r_Sampler_rtf		("s_normal",		r2_RT_N			);
		//C.r_Sampler_clw		("s_material",		r2_material		);
		//C.r_Sampler_clf		("s_smap",			r2_RT_generic0	);
		//jitter				(C);

		C.r_dx10Texture		("s_position",		r2_RT_P);
		C.r_dx10Texture		("s_normal",		r2_RT_N);
		C.r_dx10Texture		("s_material",		r2_material);
		C.r_dx10Texture		("s_smap",			r2_RT_generic0);

		C.r_dx10Sampler		("smp_nofilter");
		C.r_dx10Sampler		("smp_material");
		jitter				(C);
		C.r_End				();
		break;

		
		//	SE_SUN_NEAR for minmax
	case SE_SUN_NEAR_MINMAX:		// near pass - enable Z-test to perform depth-clipping
		//	FVF::TL2uv
		C.r_Pass			("accum_sun","accum_sun_near_msaa_minmax",	false,	TRUE,	FALSE,blend,D3DBLEND_ONE,dest);
		C.r_CullMode		(D3DCULL_NONE);
		C.PassSET_ZB		(TRUE,FALSE,TRUE	);	// force inverted Z-Buffer

		C.r_dx10Texture		("s_position",		r2_RT_P);
		C.r_dx10Texture		("s_normal",		r2_RT_N);
		C.r_dx10Texture		("s_material",		r2_material);
		C.r_dx10Texture		("s_accumulator",	r2_RT_accum);
		C.r_dx10Texture		("s_lmap",			r2_sunmask);
		C.r_dx10Texture		("s_smap",			r2_RT_smap_depth);
		C.r_dx10Texture		("s_smap_minmax",	r2_RT_smap_depth_minmax);

		C.r_dx10Sampler		("smp_nofilter");
		C.r_dx10Sampler		("smp_material");
		C.r_dx10Sampler		("smp_linear");
		jitter				(C);
		C.r_dx10Sampler		("smp_smap");

		C.r_End				();
		break;

	}
   ::Render->m_MSAASample = -1;
}
コード例 #15
0
ファイル: 0080-admin_ut.c プロジェクト: Whissi/librdkafka
/**
 * @brief CreateTopics tests
 *
 *
 *
 */
static void do_test_CreateTopics (const char *what,
                                  rd_kafka_t *rk, rd_kafka_queue_t *useq,
                                  int with_background_event_cb,
                                  int with_options) {
        rd_kafka_queue_t *q = useq ? useq : rd_kafka_queue_new(rk);
#define MY_NEW_TOPICS_CNT 6
        rd_kafka_NewTopic_t *new_topics[MY_NEW_TOPICS_CNT];
        rd_kafka_AdminOptions_t *options = NULL;
        int exp_timeout = MY_SOCKET_TIMEOUT_MS;
        int i;
        char errstr[512];
        const char *errstr2;
        rd_kafka_resp_err_t err;
        test_timing_t timing;
        rd_kafka_event_t *rkev;
        const rd_kafka_CreateTopics_result_t *res;
        const rd_kafka_topic_result_t **restopics;
        size_t restopic_cnt;
        void *my_opaque = NULL, *opaque;

        TEST_SAY(_C_MAG "[ %s CreateTopics with %s, timeout %dms ]\n",
                 rd_kafka_name(rk), what, exp_timeout);

        /**
         * Construct NewTopic array with different properties for
         * different partitions.
         */
        for (i = 0 ; i < MY_NEW_TOPICS_CNT ; i++) {
                const char *topic = test_mk_topic_name(__FUNCTION__, 1);
                int num_parts = i * 51 + 1;
                int num_replicas = jitter(1, MY_NEW_TOPICS_CNT-1);
                int set_config = (i & 2);
                int set_replicas = !(i % 1);

                new_topics[i] = rd_kafka_NewTopic_new(topic,
                                                      num_parts,
                                                      set_replicas ? -1 :
                                                      num_replicas,
                                                      NULL, 0);

                if (set_config) {
                        /*
                         * Add various (unverified) configuration properties
                         */
                        err = rd_kafka_NewTopic_set_config(new_topics[i],
                                                           "dummy.doesntexist",
                                                           "butThere'sNothing "
                                                           "to verify that");
                        TEST_ASSERT(!err, "%s", rd_kafka_err2str(err));

                        err = rd_kafka_NewTopic_set_config(new_topics[i],
                                                           "try.a.null.value",
                                                           NULL);
                        TEST_ASSERT(!err, "%s", rd_kafka_err2str(err));

                        err = rd_kafka_NewTopic_set_config(new_topics[i],
                                                           "or.empty", "");
                        TEST_ASSERT(!err, "%s", rd_kafka_err2str(err));
                }


                if (set_replicas) {
                        int32_t p;
                        int32_t replicas[MY_NEW_TOPICS_CNT];
                        int j;

                        for (j = 0 ; j < num_replicas ; j++)
                                replicas[j] = j;

                        /*
                         * Set valid replica assignments
                         */
                        for (p = 0 ; p < num_parts ; p++) {
                                /* Try adding an existing out of order,
                                 * should fail */
                                if (p == 1) {
                                        err = rd_kafka_NewTopic_set_replica_assignment(
                                                new_topics[i], p+1,
                                                replicas, num_replicas,
                                                errstr, sizeof(errstr));
                                        TEST_ASSERT(err == RD_KAFKA_RESP_ERR__INVALID_ARG,
                                                    "%s", rd_kafka_err2str(err));
                                }

                                err = rd_kafka_NewTopic_set_replica_assignment(
                                        new_topics[i], p,
                                        replicas, num_replicas,
                                        errstr, sizeof(errstr));
                                TEST_ASSERT(!err, "%s", errstr);
                        }

                        /* Try to add an existing partition, should fail */
                        err = rd_kafka_NewTopic_set_replica_assignment(
                                new_topics[i], 0,
                                replicas, num_replicas, NULL, 0);
                        TEST_ASSERT(err == RD_KAFKA_RESP_ERR__INVALID_ARG,
                                    "%s", rd_kafka_err2str(err));

                } else {
                        int32_t dummy_replicas[1] = {1};

                        /* Test invalid partition */
                        err = rd_kafka_NewTopic_set_replica_assignment(
                                new_topics[i], num_parts+1, dummy_replicas, 1,
                                errstr, sizeof(errstr));
                        TEST_ASSERT(err == RD_KAFKA_RESP_ERR__INVALID_ARG,
                                    "%s: %s", rd_kafka_err2str(err),
                                    err == RD_KAFKA_RESP_ERR_NO_ERROR ?
                                    "" : errstr);

                        /* Setting replicas with with default replicas != -1
                         * is an error. */
                        err = rd_kafka_NewTopic_set_replica_assignment(
                                new_topics[i], 0, dummy_replicas, 1,
                                errstr, sizeof(errstr));
                        TEST_ASSERT(err == RD_KAFKA_RESP_ERR__INVALID_ARG,
                                    "%s: %s", rd_kafka_err2str(err),
                                    err == RD_KAFKA_RESP_ERR_NO_ERROR ?
                                    "" : errstr);
                }
        }

        if (with_options) {
                options = rd_kafka_AdminOptions_new(rk, RD_KAFKA_ADMIN_OP_ANY);

                exp_timeout = MY_SOCKET_TIMEOUT_MS * 2;
                err = rd_kafka_AdminOptions_set_request_timeout(
                        options, exp_timeout, errstr, sizeof(errstr));
                TEST_ASSERT(!err, "%s", rd_kafka_err2str(err));

                my_opaque = (void *)123;
                rd_kafka_AdminOptions_set_opaque(options, my_opaque);
        }

        TIMING_START(&timing, "CreateTopics");
        TEST_SAY("Call CreateTopics, timeout is %dms\n", exp_timeout);
        rd_kafka_CreateTopics(rk, new_topics, MY_NEW_TOPICS_CNT,
                              options, q);
        TIMING_ASSERT_LATER(&timing, 0, 50);

        if (with_background_event_cb) {
                /* Result event will be triggered by callback from
                 * librdkafka background queue thread. */
                TIMING_START(&timing, "CreateTopics.wait_background_event_cb");
                rkev = wait_background_event_cb();
        } else {
                /* Poll result queue */
                TIMING_START(&timing, "CreateTopics.queue_poll");
                rkev = rd_kafka_queue_poll(q, exp_timeout + 1000);
        }

        TIMING_ASSERT_LATER(&timing, exp_timeout-100, exp_timeout+100);
        TEST_ASSERT(rkev != NULL, "expected result in %dms",
                    exp_timeout);
        TEST_SAY("CreateTopics: got %s in %.3fs\n",
                 rd_kafka_event_name(rkev),
                 TIMING_DURATION(&timing) / 1000.0f);

        /* Convert event to proper result */
        res = rd_kafka_event_CreateTopics_result(rkev);
        TEST_ASSERT(res, "expected CreateTopics_result, not %s",
                    rd_kafka_event_name(rkev));

        opaque = rd_kafka_event_opaque(rkev);
        TEST_ASSERT(opaque == my_opaque, "expected opaque to be %p, not %p",
                    my_opaque, opaque);

        /* Expecting error */
        err = rd_kafka_event_error(rkev);
        errstr2 = rd_kafka_event_error_string(rkev);
        TEST_ASSERT(err == RD_KAFKA_RESP_ERR__TIMED_OUT,
                    "expected CreateTopics to return error %s, not %s (%s)",
                    rd_kafka_err2str(RD_KAFKA_RESP_ERR__TIMED_OUT),
                    rd_kafka_err2str(err),
                    err ? errstr2 : "n/a");

        /* Attempt to extract topics anyway, should return NULL. */
        restopics = rd_kafka_CreateTopics_result_topics(res, &restopic_cnt);
        TEST_ASSERT(!restopics && restopic_cnt == 0,
                    "expected no result_topics, got %p cnt %"PRIusz,
                    restopics, restopic_cnt);

        rd_kafka_event_destroy(rkev);

        rd_kafka_NewTopic_destroy_array(new_topics, MY_NEW_TOPICS_CNT);

        if (options)
                rd_kafka_AdminOptions_destroy(options);

        if (!useq)
                rd_kafka_queue_destroy(q);
}
コード例 #16
0
void
img_copy_texture(uint16 *dest, uint8 *source, uint32 channels, uint32 stride,
                 const IMG_INFO *info, uint32 w, uint32 h)
{
  uint32 i,j;
  uint16 *destRow;
  uint8 *pRow;
  uint8 r,g,b;
  
  for(i = 0; i < h; i++)
  {
    pRow = &source[i*stride];
    destRow = &dest[i*w];
    
    if (channels == 3)
    {
      switch(info->alpha)
        {
        case IMG_ALPHA_NONE:
          for(j = 0; j < w; j++)
          {
            if (info->dither == IMG_DITHER_JITTER)
            {
              r = jitter(pRow[j*3],0,3,info->noise,
                         i%info->dither_height,j%info->dither_width);
              g = jitter(pRow[j*3+1],1,2,info->noise,
                         i%info->dither_height,j%info->dither_width);
              b = jitter(pRow[j*3+2],2,3,info->noise,
                         i%info->dither_height,j%info->dither_width);
            }
            else
            {
              r = pRow[j*3];
              g = pRow[j*3+1];
              b = pRow[j*3+2];
            }
            destRow[j] = LOAD565(r,g,b);
          }
          break;
        case IMG_ALPHA_MASK:
          for(j = 0; j < w; j++)
          {
            if (info->dither == IMG_DITHER_JITTER)
            {
              r = jitter(pRow[j*3],0,3,info->noise,
                         i%info->dither_height,j%info->dither_width);
              g = jitter(pRow[j*3+1],1,3,info->noise,
                         i%info->dither_height,j%info->dither_width);
              b = jitter(pRow[j*3+2],2,3,info->noise,
                         i%info->dither_height,j%info->dither_width);
            }
            else
            {
              r = pRow[j*3];
              g = pRow[j*3+1];
              b = pRow[j*3+2];
            }
            destRow[j] = LOAD1555(r,g,b,255);
          }
          break;
        case IMG_ALPHA_FULL:
          for(j = 0; j < w; j++)
          {
            if (info->dither == IMG_DITHER_JITTER)
            {
              r = jitter(pRow[j*3],0,4,info->noise,
                         i%info->dither_height,j%info->dither_width);
              g = jitter(pRow[j*3+1],1,4,info->noise,
                         i%info->dither_height,j%info->dither_width);
              b = jitter(pRow[j*3+2],2,4,info->noise,
                         i%info->dither_height,j%info->dither_width);
            }
            else
            {
              r = pRow[j*3];
              g = pRow[j*3+1];
              b = pRow[j*3+2];
            }
            destRow[j] = LOAD4444(r,g,b,255);
          }
          break;
        case IMG_ALPHA_KEYED:
          for(j = 0; j < w; j++)
          {
            if (info->dither == IMG_DITHER_JITTER)
            {
              r = jitter(pRow[j*3],0,3,info->noise,
                         i%info->dither_height,j%info->dither_width);
              g = jitter(pRow[j*3+1],1,3,info->noise,
                         i%info->dither_height,j%info->dither_width);
              b = jitter(pRow[j*3+2],2,3,info->noise,
                         i%info->dither_height,j%info->dither_width);
            }
            else
            {
              r = pRow[j*3];
              g = pRow[j*3+1];
              b = pRow[j*3+2];
            }
            if (info->key == LOAD8888(pRow[j*3],pRow[j*3+1],pRow[j*3+2],0))
              destRow[j] = LOAD1555(r,g,b,0);
            else
              destRow[j] = LOAD1555(r,g,b,255);
          }
      }
    }
    else if (channels == 4)
    {
      switch(info->alpha)
        {
        case IMG_ALPHA_NONE:
          for(j = 0; j < h; j++)
          {
            if (info->dither == IMG_DITHER_JITTER)
            {
              r = jitter(pRow[j*4],0,3,info->noise,
                         i%info->dither_height,j%info->dither_width);
              g = jitter(pRow[j*4+1],1,2,info->noise,
                         i%info->dither_height,j%info->dither_width);
              b = jitter(pRow[j*4+2],2,3,info->noise,
                         i%info->dither_height,j%info->dither_width);
            }
            else
            {
              r = pRow[j*4];
              g = pRow[j*4+1];
              b = pRow[j*4+2];
            }
            destRow[j] = LOAD565(r, g, b);
          }
          break;
        case IMG_ALPHA_MASK:
          for(j = 0; j < h; j++)
          {
            if (info->dither == IMG_DITHER_JITTER)
            {
              r = jitter(pRow[j*4],0,3,info->noise,
                         i%info->dither_height,j%info->dither_width);
              g = jitter(pRow[j*4+1],1,3,info->noise,
                         i%info->dither_height,j%info->dither_width);
              b = jitter(pRow[j*4+2],2,3,info->noise,
                         i%info->dither_height,j%info->dither_width);
            }
            else
            {
              r = pRow[j*4];
              g = pRow[j*4+1];
              b = pRow[j*4+2];
            }
            destRow[j] = LOAD1555(r,g,b,pRow[j*4+3]);
          }
          break;
        case IMG_ALPHA_FULL:
          for(j = 0; j < h; j++)
          {
            if (info->dither == IMG_DITHER_JITTER)
            {
              r = jitter(pRow[j*4],0,4,info->noise,
                         i%info->dither_height,j%info->dither_width);
              g = jitter(pRow[j*4+1],1,4,info->noise,
                         i%info->dither_height,j%info->dither_width);
              b = jitter(pRow[j*4+2],2,4,info->noise,
                         i%info->dither_height,j%info->dither_width);
            }
            else
            {
              r = pRow[j*4];
              g = pRow[j*4+1];
              b = pRow[j*4+2];
            }
            destRow[j] = LOAD4444(r,g,b,pRow[j*4+3]);
          }
          break;
        case IMG_ALPHA_KEYED:
          for(j = 0; j < h; j++)
          {
            if (info->dither == IMG_DITHER_JITTER)
            {
              r = jitter(pRow[j*4],0,3,info->noise,
                         i%info->dither_height,j%info->dither_width);
              g = jitter(pRow[j*4+1],1,3,info->noise,
                         i%info->dither_height,j%info->dither_width);
              b = jitter(pRow[j*4+2],2,3,info->noise,
                         i%info->dither_height,j%info->dither_width);
            }
            else
            {
              r = pRow[j*4];
              g = pRow[j*4+1];
              b = pRow[j*4+2];
            }
            if (info->key == LOAD8888(pRow[j*4],pRow[j*4+1],pRow[j*4+2],0))
              destRow[j] = LOAD1555(r,g,b,0);
            else
              destRow[j] = LOAD1555(r,g,b,pRow[j*4+3]);
          }
          break;
        }
    }
  }
}
コード例 #17
0
ファイル: blender_light_spot.cpp プロジェクト: 2asoft/xray-16
void	CBlender_accum_spot::Compile(CBlender_Compile& C)
{
	IBlender::Compile		(C);

	BOOL		b_HW_smap	= RImplementation.o.HW_smap;
	BOOL		b_HW_PCF	= RImplementation.o.HW_smap_PCF;
	BOOL		blend		= RImplementation.o.fp16_blend;
	D3DBLEND	dest		= blend?D3DBLEND_ONE:D3DBLEND_ZERO;

	switch (C.iElement)
	{
	case SE_L_FILL:			// masking
		C.r_Pass			("null", 			"copy",						false,	FALSE,	FALSE);
		C.r_Sampler			("s_base",			C.L_textures[0]);
		C.r_End				();
		break;
	case SE_L_UNSHADOWED:	// unshadowed
		C.r_Pass			("accum_volume",	"accum_spot_unshadowed",	false,	FALSE,FALSE,blend,D3DBLEND_ONE,dest);
		C.r_Sampler_rtf		("s_position",		r2_RT_P);
		C.r_Sampler_rtf		("s_normal",		r2_RT_N);
		C.r_Sampler_clw		("s_material",		r2_material);
		C.r_Sampler			("s_lmap",			C.L_textures[0],false,D3DTADDRESS_CLAMP);
		C.r_Sampler_rtf		("s_accumulator",	r2_RT_accum		);
		C.r_End				();
		break;
	case SE_L_NORMAL:		// normal
		C.r_Pass			("accum_volume",	"accum_spot_normal",		false,	FALSE,FALSE,blend,D3DBLEND_ONE,dest);
		C.r_Sampler_rtf		("s_position",		r2_RT_P);
		C.r_Sampler_rtf		("s_normal",		r2_RT_N);
		C.r_Sampler_clw		("s_material",		r2_material);
		C.r_Sampler			("s_lmap",			C.L_textures[0],false,D3DTADDRESS_CLAMP);
		if (b_HW_smap)		{
			if (b_HW_PCF)	C.r_Sampler_clf		("s_smap",r2_RT_smap_depth	);
			else			C.r_Sampler_rtf		("s_smap",r2_RT_smap_depth	);
		}
		else				C.r_Sampler_rtf		("s_smap",r2_RT_smap_surf	);
		jitter				(C);
		C.r_Sampler_rtf		("s_accumulator",	r2_RT_accum		);
		C.r_End				();
		break;
	case SE_L_FULLSIZE:		// normal-fullsize
		C.r_Pass			("accum_volume",	"accum_spot_fullsize",		false,	FALSE,FALSE,blend,D3DBLEND_ONE,dest);
		C.r_Sampler_rtf		("s_position",		r2_RT_P);
		C.r_Sampler_rtf		("s_normal",		r2_RT_N);
		C.r_Sampler_clw		("s_material",		r2_material);
		C.r_Sampler			("s_lmap",			C.L_textures[0],false,D3DTADDRESS_CLAMP);
		if (b_HW_smap)		{
			if (b_HW_PCF)	C.r_Sampler_clf		("s_smap",r2_RT_smap_depth	);
			else			C.r_Sampler_rtf		("s_smap",r2_RT_smap_depth	);
		}
		else				C.r_Sampler_rtf		("s_smap",r2_RT_smap_surf	);
		jitter				(C);
		C.r_Sampler_rtf		("s_accumulator",	r2_RT_accum		);
		C.r_End				();
		break;
	case SE_L_TRANSLUENT:	// shadowed + transluency
		C.r_Pass			("accum_volume",	"accum_spot_fullsize",		false,	FALSE,FALSE,blend,D3DBLEND_ONE,dest);
		C.r_Sampler_rtf		("s_position",		r2_RT_P);
		C.r_Sampler_rtf		("s_normal",		r2_RT_N);
		C.r_Sampler_clw		("s_material",		r2_material);
		C.r_Sampler_clf		("s_lmap",			r2_RT_smap_surf);			// diff here
		if (b_HW_smap)		{
			if (b_HW_PCF)	C.r_Sampler_clf		("s_smap",r2_RT_smap_depth	);
			else			C.r_Sampler_rtf		("s_smap",r2_RT_smap_depth	);
		}
		else				C.r_Sampler_rtf		("s_smap",r2_RT_smap_surf	);
		C.r_Sampler_rtf		("s_accumulator",	r2_RT_accum		);
		jitter				(C);
		C.r_End				();
		break;
	}
}
コード例 #18
0
ファイル: calcstuff.c プロジェクト: MattHung/sage-graphics
int
main (int argc, char **argv)
{
	char *endptr;
	int opt, packetsize, ip_int, coarse_ip, normal_ip, big_ip, ib;
	int il_normal, il_big;
	int bufsize, buffers;
	double bitrate, ip, ip_frac, ft_jitter, il_jitter;
	double testrate, tolerance;

	tolerance = 0;
	while ((opt = getopt (argc, argv, "ht:V")) != -1) {
		switch (opt) {
		case 'h':
			printf ("Usage: %s [OPTION]... BITRATE PACKETSIZE\n",
				argv[0]);
			printf ("Calculate DVB ASI stuffing parameters "
				"for a given BITRATE and PACKETSIZE.\n\n");
			printf ("  -h\t\tdisplay this help and exit\n");
			printf ("  -t TOLERANCE\tstop optimizing the bitrate "
				"at an error of\n"
				"\t\tTOLERANCE parts per million "
				"(default 0)\n");
			printf ("  -V\t\toutput version information "
				"and exit\n\n");
			printf ("Report bugs to <*****@*****.**>.\n");
			return 0;
		case 't':
			tolerance = strtod (optarg, &endptr);
			if (*endptr != '\0' || tolerance > 30) {
				fprintf (stderr,
					"%s: invalid bitrate tolerance: %s\n",
					argv[0], optarg);
				return -1;
			}
			break;
		case 'V':
			printf ("%s from master-%s (%s)\n", progname,
				MASTER_DRIVER_VERSION,
				MASTER_DRIVER_DATE);
			printf ("\nCopyright (C) 2000-2004 "
				"Linear Systems Ltd.\n"
				"This is free software; "
				"see the source for copying conditions.  "
				"There is NO\n"
				"warranty; not even for MERCHANTABILITY "
				"or FITNESS FOR A PARTICULAR PURPOSE.\n");
			return 0;
		case '?':
			goto USAGE;
		}
	}

	/* Check the number of arguments */
	if ((argc - optind) < 2) {
		fprintf (stderr, "%s: missing arguments\n", argv[0]);
		goto USAGE;
	} else if ((argc - optind) > 2) {
		fprintf (stderr, "%s: extra operand\n", argv[0]);
		goto USAGE;
	}

	/* Read the packet size */
	packetsize = strtol (argv[optind + 1], &endptr, 0);
	if ((*endptr != '\0') ||
		((packetsize != 188) && (packetsize != 204))) {
		fprintf (stderr, "%s: invalid packet size: %s\n",
			argv[0], argv[optind + 1]);
		return -1;
	}

	/* Read the bitrate */
	bitrate = strtod (argv[optind], &endptr);
	if ((*endptr != '\0') || (bitrate > br (packetsize, 0, 1, 0)) ||
		(bitrate < br (packetsize, 16777215, 1, 255))) {
		fprintf (stderr, "%s: invalid bitrate: %s\n",
			argv[0], argv[optind]);
		return -1;
	}

	/* Assume no interbyte stuffing.
	 * This will allow bitrates down to about 2400 bps,
	 * which is probably good enough! */
	ip = 270000000 * 0.8 * packetsize / bitrate - packetsize - 2;
	printf ("\n%f bytes of stuffing required per packet.\n", ip);
	ip_int = ip;
	ip_frac = ip - ip_int;
	if (ip_frac > 0.5) {
		coarse_ip = ip_int + 1;
	} else {
		coarse_ip = ip_int;
	}
	testrate = br (packetsize, coarse_ip, 1, 0);
	printf ("ib = 0, ip = %i  =>  bitrate = %f bps, err = %.0f ppm\n",
		coarse_ip, testrate, ppm (testrate, bitrate));
	normal_ip = 0;
	big_ip = 0;
	il_normal = 0;
	il_big = 0;
	if ((ip_frac > (double)1 / 256 / 2) &&
		(ip_frac < (1 - (double)1 / 256 / 2)) &&
		(fabs (ppm (testrate, bitrate)) > tolerance)) {
		int n = 1, b = 1, il0, il1, il_normal_max, il_big_max;
		double best_error = 1.0, error, jit = 0.1;

		/* Find the finetuning parameters which
		 * best approximate the desired bitrate.
		 * Break at 1 us p-p network jitter or
		 * the desired bitrate accuracy, whichever
		 * gives less network jitter */
		printf ("\nFinetuning ib = 0, ip = %i:\n", ip_int);
		while ((b < 256) && (n < 256) &&
			(((double)(n * b) / (n + b)) <= 27)) {
			error = (double)b / (n + b) - ip_frac;
			if (fabs (error) < fabs (best_error)) {
				best_error = error;
				normal_ip = n;
				big_ip = b;
				testrate = br (packetsize, ip_int, n, b);
				printf ("normal_ip = %i, big_ip = %i"
					"  =>  bitrate = %f bps, "
					"err = %.0f ppm\n",
					n, b,
					testrate, ppm (testrate, bitrate));
				if (fabs (ppm (testrate, bitrate)) < tolerance) {
					break;
				}
			}
			if (error < 0) {
				b++;
			} else {
				n++;
			}
		}

		/* Calculate the network jitter produced by finetuning */
		ft_jitter = jitter (normal_ip, big_ip,
			normal_ip, big_ip,
			(double)big_ip / (normal_ip + big_ip));

		/* Find the interleaving parameters which
		 * produce the least network jitter */
		if ((normal_ip == 1) || (big_ip == 1)) {
			il_jitter = jitter (normal_ip, big_ip,
				normal_ip, big_ip,
				(double)big_ip / (normal_ip + big_ip));
		} else {
			il_jitter = 0.1;
			il_normal_max = (normal_ip > 14) ? 14 : normal_ip;
			for (il0 = 1; il0 <= il_normal_max; il0++) {
				il_big_max = (big_ip > 14) ? 14 : big_ip;
				il1 = 1;
				while ((il1 <= il_big_max) &&
					(il0 + il1 <= 15)) {
					jit = jitter (normal_ip, big_ip,
						il0, il1,
						(double)big_ip / (normal_ip + big_ip));
					if (jit < il_jitter) {
						il_jitter = jit;
						il_normal = il0;
						il_big = il1;
					}
					il1++;
				}
			}
		}
	} else {
		ip_int = coarse_ip;
		ft_jitter = 0;
		il_jitter = 0;
	}

	/* Print the best stuffing parameters
	 * for transmitters with interleaved finetuning */
	printf ("\nRecommended stuffing parameters with "
		"interleaved finetuning:\n");
	printf ("ib = 0, ip = %i, normal_ip = %i, big_ip = %i,\n"
		"\til_normal = %i, il_big = %i (burst mode) OR\n",
		ip_int, normal_ip, big_ip, il_normal, il_big);
	ib = ip_int / (packetsize - 1);
	while ((ib - smooth_ip (ip_int, ib, packetsize)) >
		(packetsize + 2) / 2) {
		ib--;
	}
	if (ib > 255) {
		if (ib > 65535) {
			ib = 65535;
		}
		printf ("ib = %i, ip = %i, normal_ip = %i, big_ip = %i,\n"
			"\til_normal = %i, il_big = %i (large ib) OR\n",
			ib, smooth_ip (ip_int, ib, packetsize),
			normal_ip, big_ip, il_normal, il_big);
		ib = 255;
	}
	printf ("ib = %i, ip = %i, normal_ip = %i, big_ip = %i,\n"
		"\til_normal = %i, il_big = %i\n",
		ib, smooth_ip (ip_int, ib, packetsize),
		normal_ip, big_ip, il_normal, il_big);
	testrate = br (packetsize, ip_int, normal_ip, big_ip);
	printf ("Bitrate = %f bps; "
		"err = %.0f ppm, network jitter = %.0f ns p-p\n",
		testrate, ppm (testrate, bitrate), il_jitter * 1E+09);

	/* Print the best stuffing parameters
	 * for transmitters with ordinary finetuning */
	printf ("\nRecommended stuffing parameters with finetuning:\n");
	printf ("ib = 0, ip = %i, "
		"normal_ip = %i, big_ip = %i (burst mode) OR\n",
		ip_int, normal_ip, big_ip);
	ib = ip_int / (packetsize - 1);
	while ((ib - smooth_ip (ip_int, ib, packetsize)) >
		(packetsize + 2) / 2) {
		ib--;
	}
	if (ib > 255) {
		if (ib > 65535) {
			ib = 65535;
		}
		printf ("ib = %i, ip = %i, "
			"normal_ip = %i, big_ip = %i (large ib) OR\n",
			ib, smooth_ip (ip_int, ib, packetsize),
			normal_ip, big_ip);
		ib = 255;
	}
	printf ("ib = %i, ip = %i, normal_ip = %i, big_ip = %i\n",
		ib, smooth_ip (ip_int, ib, packetsize),
		normal_ip, big_ip);
	testrate = br (packetsize, ip_int, normal_ip, big_ip);
	printf ("Bitrate = %f bps; "
		"err = %.0f ppm, network jitter = %.0f ns p-p\n",
		testrate, ppm (testrate, bitrate), ft_jitter * 1E+09);

	/* Print the best stuffing parameters
	 * for transmitters without finetuning */
	printf ("\nRecommended stuffing parameters without finetuning:\n");
	printf ("ib = 0, ip = %i (burst mode) OR\n", coarse_ip);
	ib = coarse_ip / (packetsize - 1);
	while ((ib - smooth_ip (coarse_ip, ib, packetsize)) >
		(packetsize + 2) / 2) {
		ib--;
	}
	if (ib > 255) {
		ib = 255;
	}
	printf ("ib = %i, ip = %i\n",
		ib, smooth_ip (coarse_ip, ib, packetsize));
	testrate = br (packetsize, coarse_ip, 1, 0);
	printf ("Bitrate = %f bps; err = %.0f ppm, network jitter = 0 ns p-p\n",
		testrate, ppm (testrate, bitrate));

	/* Print a sample calculation of the interrupt rate and buffer time
	 * based on a reasonable number and size of driver buffers
	 * and the bitrate */
	bufsize = bitrate / (8 * 500);
	if (bufsize < 4) {
		bufsize = 4;
	}
	bufsize = (bufsize / 19176 + ((bufsize % 19176) ? 1 : 0)) * 19176;
	buffers = bitrate * 0.25 / (8 * bufsize);
	if (buffers < 2) {
		buffers = 2;
	}
	printf ("\nSample buffer parameter calculation:\n");
	printf ("At %f bps, %i x %i-byte buffers gives\n",
		bitrate, buffers, bufsize);
	printf ("%.0f interrupt(s) per second "
		"and up to %.3f seconds of buffering.\n",
		bitrate / (8 * bufsize), 8 * buffers * bufsize / bitrate);
	return 0;

USAGE:
	fprintf (stderr, "Try '%s -h' for more information.\n", argv[0]);
	return -1;
}