示例#1
0
int main(int argc, char *argv[])
{
    int rv;
    char cmdstr[ROSH_CMD_SZ];

    /* Initialization */
    rv = 0;
    rosh_console_std();
    if (argc != 1) {
	rv = rosh_argcat(cmdstr, argc, argv, 1);
    } else {
	rosh_version(0);
	print_beta();
	cmdstr[0] = '\0';
    }
    rv = rosh_prompt(cmdstr);
    printf("--Exiting '%s'\n", APP_NAME);
    return rv;
}
示例#2
0
static void update_intra_xforms(intra_xform_ctx *_ctx){
  int mode;
  int pli;
  /*Update the model for each coefficient in each mode.*/
  printf("/* This file is generated automatically by init_intra_xform */\n");

  printf("#include \"intra.h\"\n");
  printf("\n");
  printf("const double OD_INTRA_PRED_WEIGHTS_%ix%i"
   "[OD_INTRA_NMODES][%i][%i][2*%i][2*%i]={\n",
   B_SZ,B_SZ,B_SZ,B_SZ,B_SZ,B_SZ);
  for(mode=0;mode<OD_INTRA_NMODES;mode++){
    int        xi[2*B_SZ*2*B_SZ];
    int        nxi;
    int        i;
    int        j;
    /*double    *r_x;*/
    r_xx_row  *r_xx;
    double    *scale;
    /*r_x=_ctx->r_x[mode];*/
    r_xx=_ctx->r_xx[mode];
    scale=_ctx->scale[mode];
    printf("  {\n");
    for(i=0;i<2*B_SZ*2*B_SZ;i++){
      scale[i]=sqrt(r_xx[i][i]);
      if(scale[i]<=0)scale[i]=1;
    }
    for(i=0;i<2*B_SZ*2*B_SZ;i++){
      for(j=0;j<2*B_SZ*2*B_SZ;j++){
        r_xx[i][j]/=scale[i]*scale[j];
      }
    }
    nxi=0;
    for(j=0;j<B_SZ;j++){
      for(i=0;i<B_SZ;i++){
        xi[nxi]=2*B_SZ*j+i;
        xi[nxi+B_SZ*B_SZ]=2*B_SZ*j+B_SZ+i;
        xi[nxi+2*B_SZ*B_SZ]=2*B_SZ*(B_SZ+j)+i;
        nxi++;
      }
    }
#if 0
    if(mode==0){
      for(i=0;i<2*B_SZ;i++){
        for(j=0;j<2*B_SZ;j++){
          int k;
          int l;
          for(k=0;k<2*B_SZ;k++){
            for(l=0;l<2*B_SZ;l++){
              printf("%0.18G%s",r_xx[2*B_SZ*i+j][2*B_SZ*k+l],2*B_SZ*k+l>=2*B_SZ*2*B_SZ-1?"\n":" ");
            }
          }
        }
      }
    }
#endif
    for(i=0;i<B_SZ;i++){
      printf("    {\n");
      for(j=0;j<B_SZ;j++){
        double  xty[2*B_SZ*2*B_SZ];
        double *beta;
        int     xii;
        int     xij;
        int     yi;
        nxi=3*B_SZ*B_SZ;
#if 0
        /*Include coefficients for the current block*/
        {
          int k;
          int l;
          for(k=0;k<=i;k++){
            for(l=0;l<=j;l++){
              xi[nxi++]=2*B_SZ*(B_SZ+k)+B_SZ+l;
            }
          }
          nxi--;
        }
#endif
        yi=2*B_SZ*(B_SZ+i)+B_SZ+j;
        for(xii=0;xii<nxi;xii++)xty[xii]=r_xx[xi[xii]][yi];
        beta=_ctx->beta[mode][B_SZ*i+j];
        memset(beta,0,2*B_SZ*2*B_SZ*sizeof(*beta));
#if defined(OD_USE_SVD)
        {
          double  xtx[2*2*B_SZ*2*B_SZ][2*B_SZ*2*B_SZ];
          double *xtxp[2*2*B_SZ*2*B_SZ];
          double  s[2*B_SZ*2*B_SZ];
          for(xii=0;xii<nxi;xii++){
            for(xij=0;xij<nxi;xij++){
              xtx[xii][xij]=r_xx[xi[xii]][xi[xij]];
            }
          }
          for(xii=0;xii<2*nxi;xii++)xtxp[xii]=xtx[xii];
          svd_pseudoinverse(xtxp,s,nxi,nxi);
          /*beta[yi]=r_x[yi];*/
          for(xii=0;xii<nxi;xii++){
            double beta_i;
            beta_i=0;
            for(xij=0;xij<nxi;xij++)beta_i+=xtx[xij][xii]*xty[xij];
            beta[xi[xii]]=beta_i*scale[yi]/scale[xi[xii]];
            /*beta[yi]-=beta_i*r_x[xi[xii]];*/
          }
        }
#else
        {
          double  xtx[UT_SZ(2*B_SZ*2*B_SZ,2*B_SZ*2*B_SZ)];
          double  tau[2*B_SZ*2*B_SZ];
          double  work[2*B_SZ*2*B_SZ];
          int     pivot[2*B_SZ*2*B_SZ];
          int     rank;
          for(xii=0;xii<nxi;xii++){
            for(xij=xii;xij<nxi;xij++){
              xtx[UT_IDX(xii,xij,nxi)]=r_xx[xi[xii]][xi[xij]];
            }
          }
          rank=cholesky(xtx,pivot,DBL_EPSILON,nxi);
          chdecomp(xtx,tau,rank,nxi);
          chsolve(xtx,pivot,tau,xty,xty,work,rank,nxi);
          for(xii=0;xii<nxi;xii++){
            beta[xi[xii]]=xty[xii]*scale[yi]/scale[xi[xii]];
            /*beta[yi]-=beta_i*r_x[xi[xii]];*/
          }
        }
#endif
        print_beta(mode,i,j,beta);
      }
      printf("    }%s\n",i<B_SZ-1?",":"");
    }
    printf("  }%s\n",mode<OD_INTRA_NMODES-1?",":"");
  }
  printf("};\n\n");

  printf("const unsigned char OD_INTRA_PRED_PROB_%dx%d[3][OD_INTRA_NMODES][OD_INTRA_NCONTEXTS]={\n",B_SZ,B_SZ);
  for(pli=0;pli<3;pli++)
  {
    int i;
    printf("{");
    for(i=0;i<OD_INTRA_NMODES;i++)
    {
      int j;
      printf("{");
      for(j=0;j<NB_CONTEXTS;j++)
        printf("%d, ", (int)floor(.5+256.*_ctx->freq[pli][i][j][1]/(float)_ctx->freq[pli][i][j][0]));
      printf("},\n");
    }
    printf("},\n");
  }
  printf("};\n\n");
}