Example #1
0
bool         ffMpeg2Configure(void)
{   

diaMenuEntry  arE[]=
{
    {0,QT_TRANSLATE_NOOP("ffmpeg2","Normal (4:3)")},
    {1,QT_TRANSLATE_NOOP("ffmpeg2","Wide (16:9)")}
};
      
diaMenuEntry  matrixE[]=
{
    {MPEG2_MATRIX_DEFAULT,QT_TRANSLATE_NOOP("ffmpeg2","Default")},
    {MPEG2_MATRIX_TMPGENC,QT_TRANSLATE_NOOP("ffmpeg2","Tmpgenc")},
    {MPEG2_MATRIX_ANIME,QT_TRANSLATE_NOOP("ffmpeg2","Animes")},
    {MPEG2_MATRIX_KVCD,QT_TRANSLATE_NOOP("ffmpeg2","KVCD")},
};
      
diaMenuEntry rdE[]={
  {0,QT_TRANSLATE_NOOP("ffmpeg2","MB comparison")},
  {1,QT_TRANSLATE_NOOP("ffmpeg2","Fewest bits (vhq)")},
  {2,QT_TRANSLATE_NOOP("ffmpeg2","Rate distortion")}
};     
diaMenuEntry threads[]={
  {0,QT_TRANSLATE_NOOP("ffmpeg2","One thread")},
  {2,QT_TRANSLATE_NOOP("ffmpeg2","Two threads)")},
  {3,QT_TRANSLATE_NOOP("ffmpeg2","Three threads")},
  {99,QT_TRANSLATE_NOOP("ffmpeg2","Auto (#cpu)")}
};     
   
diaMenuEntry interE[]={
  {0,QT_TRANSLATE_NOOP("ffmpeg2","Progressive")},
  {1,QT_TRANSLATE_NOOP("ffmpeg2","Interlaced")},
};     
diaMenuEntry foE[]={
  {0,QT_TRANSLATE_NOOP("ffmpeg2","Top Field First")},
  {1,QT_TRANSLATE_NOOP("ffmpeg2","Bottom Field First")},
};     

        mpeg2_encoder *conf=&Mp2Settings;

uint32_t me=(uint32_t)conf->lavcSettings.me_method;  
#define PX(x) &(conf->lavcSettings.x)

         diaElemBitrate   bitrate(&(Mp2Settings.params),NULL);

         diaElemMenu      threadM(PX(MultiThreaded),QT_TRANSLATE_NOOP("ffmpeg2","Threading"),4,threads);
         diaElemUInteger  qminM(PX(qmin),QT_TRANSLATE_NOOP("ffmpeg2","Mi_n. quantizer:"),1,31);
         diaElemUInteger  qmaxM(PX(qmax),QT_TRANSLATE_NOOP("ffmpeg2","Ma_x. quantizer:"),1,31);
         diaElemUInteger  qdiffM(PX(max_qdiff),QT_TRANSLATE_NOOP("ffmpeg2","Max. quantizer _difference:"),1,31);
         diaElemUInteger  bufferS(PX(bufferSize),QT_TRANSLATE_NOOP("ffmpeg2","VBV Buffer Size:"),1,1024);
         diaElemUInteger  maxBitrate(PX(maxBitrate),QT_TRANSLATE_NOOP("ffmpeg2","Max bitrate (kb/s):"),1,50000);
         
         diaElemToggle    trellis(PX(_TRELLIS_QUANT),QT_TRANSLATE_NOOP("ffmpeg2","_Trellis quantization"));
         
         diaElemUInteger  max_b_frames(PX(max_b_frames),QT_TRANSLATE_NOOP("ffmpeg2","_Number of B frames:"),0,32);
         uint32_t widescreen= conf->lavcSettings.widescreen;
         uint32_t iinterlaced= conf->lavcSettings.interlaced;
         uint32_t bff= conf->lavcSettings.bff;
         diaElemMenu     rdM(PX(mb_eval),QT_TRANSLATE_NOOP("ffmpeg2","_Macroblock decision:"),3,rdE);
         diaElemMenu     arM(&(widescreen),QT_TRANSLATE_NOOP("ffmpeg2","Aspect ratio:"),2,arE);
         diaElemMenu     matrixM(&(Mp2Settings.matrix),QT_TRANSLATE_NOOP("ffmpeg2","Matrices:"),MPEG2_MATRIX_LAST,matrixE);
         diaElemUInteger filetol(PX(vratetol),QT_TRANSLATE_NOOP("ffmpeg2","_Filesize tolerance (kb):"),0,100000);
         
         diaElemFloat    qzComp(PX(qcompress),QT_TRANSLATE_NOOP("ffmpeg2","_Quantizer compression:"),0,1);
         diaElemFloat    qzBlur(PX(qblur),QT_TRANSLATE_NOOP("ffmpeg2","Quantizer _blur:"),0,1);
         
        diaElemUInteger GopSize(PX(gop_size),QT_TRANSLATE_NOOP("ffmpeg2","_Gop Size:"),1,30); 

        diaElemMenu     interlaced(&(iinterlaced),QT_TRANSLATE_NOOP("ffmpeg2","_Interlaced:"),2,interE);
        diaElemMenu     fieldOrder(&(bff),QT_TRANSLATE_NOOP("ffmpeg2","Field Order:"),2,foE);

          /* First Tab : encoding mode */
        diaElem *diamode[]={&arM,&threadM,&bitrate};
        diaElemTabs tabMode(QT_TRANSLATE_NOOP("ffmpeg2","Basic Settings"),3,diamode);
        
        /* 2nd Tab : advanced*/
        diaElem *diaAdv[]={&bufferS,&matrixM,&max_b_frames,&GopSize,&maxBitrate};
        diaElemTabs tabAdv(QT_TRANSLATE_NOOP("ffmpeg2","Adv. Settings"),5,diaAdv);

        /* 2ndb Tab : interlacing*/
        diaElem *diaInter[]={&interlaced,&fieldOrder};
        diaElemTabs tabInter(QT_TRANSLATE_NOOP("ffmpeg2","Interlacing"),2,diaInter);

        /* 3nd Tab : Qz */
        
        diaElem *diaQze[]={&rdM,&qminM,&qmaxM,&qdiffM,&trellis};
        diaElemTabs tabQz(QT_TRANSLATE_NOOP("ffmpeg2","Quantization"),5,diaQze);
        
        /* 4th Tab : RControl */
        
         diaElem *diaRC[]={&filetol,&qzComp,&qzBlur};
        diaElemTabs tabRC(QT_TRANSLATE_NOOP("ffmpeg2","Rate Control"),3,diaRC);
        
         diaElemTabs *tabs[]={&tabMode,&tabAdv,&tabInter,&tabQz,&tabRC};
        if( diaFactoryRunTabs(QT_TRANSLATE_NOOP("ffmpeg2","libavcodec MPEG-2 configuration"),5,tabs))
        {
          conf->lavcSettings.me_method=(Motion_Est_ID)me;
          conf->lavcSettings.widescreen= widescreen;
          conf->lavcSettings.interlaced= iinterlaced;
          conf->lavcSettings.bff= bff;
          return true;
        }
         return false;
}
Example #2
0
    shared_ptr<tnmmatrix<TYPE> >  tOLS<TYPE>::GetB()
    {
      if (B) {
	return B;
      }
      
      this->misc.clear();
      TYPE minDeterminant = _typeOpt::read(this->options.get(), "minDeterminant");
      bool _DB_PRINT_DET = _boolOpt::read(this->options.get(), "_DB_PRINT_DET");
      bool _DB_PRINT_XTX = _boolOpt::read(this->options.get(), "_DB_PRINT_XTX");
      
      int MM = this->GetX()->GetCols();
      int NN = this->GetX()->GetRows();
      int KK = this->GetK();
      TYPE rcond;
      TYPE det;
      
      _m Xtrp(MM,NN);
      _m Qinv(MM,MM);
      _m Xtrpyvec(MM,KK);
      _m I(NN,NN);
      B.reset(new _m(MM,KK));
      _mVec bCov;
      _m matrixM(NN,NN);
      _m e(NN,KK);
      _m eTrp(KK,NN);
      _m s2(KK,KK);
      TYPE cond = 0;
      
      I.I();
      if ( MM > 0 )
	{
	  //	tMathTools<TYPE>::PrintMatrix( std::cout , X , 6 , "" , "" , "X: " );
	  //	std::cout << std::flush;
	  
	this->GetX()->Trp( &Xtrp );
	Qinv.Mul( Xtrp , *this->GetX() ); 
	if (_DB_PRINT_XTX)
	  tMathTools<TYPE>::PrintMatrix( std::cout , Qinv , 6 , "" , "" , "X'X: " );

	try {
	  if ( minDeterminant >= 0 ) {
	    det = Qinv.Det();
	    if (_DB_PRINT_DET )
	      std::cout << "|X'X| = " << det << std::endl << std::flush;
	    if ( det <= minDeterminant )
	      throw aException(tOLS<TYPE>, "X'X is singular.");
	  }
	  Qinv.Inv( &rcond );
	} catch ( ... ) {
	  throw aException(tOLS<TYPE>, "Inversion failed!");
	};
	assert( rcond != 0.0 );
	cond = 1.0 / rcond;
	Xtrpyvec.Mul( Xtrp , *this->GetY() );
	B->Mul(Qinv , Xtrpyvec);

	matrixM = I - (*this->GetX()) * Qinv * Xtrp;
	e = matrixM * (*this->GetY());
	e.Trp( &eTrp );
	s2 = (TYPE)( 1.0 / ( NN - MM ) ) * eTrp * e;
	for ( int col = 1 ; col <= KK ; col++ ) {
	  bCov.emplace_back(s2(col,col) * Qinv);
	}
      } else
      B->Cpy(0.0);
    
    
    //Relay non standard fit data to owner
    this->misc["e"] = _mVec(1, e);
    this->misc["s2"] = _mVec(1, s2);
    this->misc["determinant"] = _mVec(1, _m(1,1,det));
    this->misc["conditionNumber"] = _mVec(1, _m(1,1,cond));
    this->misc["bCov"] = _mVec(bCov);
    return B;  
  }