private void rdp_decoding_rd(char[][] g_data,int disks,int stripe_unit_size,int w,int x,int y){
  int packet_size=stripe_unit_size / w;
  int ccount, count, rcount;
  char[] rdata, xdata, ydata, row_data, diag_data;
  int g, gx, gy, coffset, i, j, k, c;
  int row_disk, diag_disk;
  rcount=stripe_unit_size;
  rdata=g_data[0];
  xdata=g_data[x];
  ydata=g_data[y];
  gx=(x >= 3 ? x - 3 : pnumRdp - 1);
  gy=(y >= 3 ? y - 3 : pnumRdp - 1);
  row_disk=x;
  diag_disk=y;
  row_data=xdata;
  diag_data=ydata;
  g=gx;
  while (true) {
    if (g == pnumRdp - 1) {
      if (gx == (row_disk >= 3 ? row_disk - 3 : row_disk + pnumRdp - 3)) {
        row_disk=y;
        diag_disk=x;
        row_data=ydata;
        diag_data=xdata;
        g=gy;
        continue;
      }
 else       break;
    }
 else {
      int row_index;
      char[] cdata;
      int diag_count;
      int row_count;
      diag_count=stripe_unit_size;
      row_count=stripe_unit_size;
      row_index=(g - diag_disk + pnumRdp + 2) % pnumRdp;
      coffset=(row_index + diag_disk - 2 + pnumRdp) % pnumRdp * packet_size;
      cdata=g_data[1];
      for (i=row_index * packet_size, j=coffset, k=0; i < diag_count && k < packet_size; i++, j++, k++) {
        diag_data[i]=cdata[j];
      }
      for (c=2; c < (disks + 2); c++) {
        if (c == diag_disk)         continue;
        ccount=stripe_unit_size;
        cdata=g_data[c];
        coffset=(row_index + diag_disk - c + pnumRdp) % pnumRdp * packet_size;
        for (i=row_index * packet_size, j=coffset, k=0; i < diag_count && j < ccount && k < packet_size; i++, j++, k++) {
          diag_data[i]^=cdata[j];
        }
      }
      ccount=rcount;
      cdata=rdata;
      coffset=(row_index + diag_disk - 1 + pnumRdp) % pnumRdp * packet_size;
      for (i=row_index * packet_size, j=coffset, k=0; i < diag_count && j < ccount && k < packet_size; i++, j++, k++) {
        diag_data[i]^=cdata[j];
      }
      coffset=row_index * packet_size;
      for (c=2; c < (disks + 2); c++) {
        if (c == row_disk)         continue;
        ccount=stripe_unit_size;
        cdata=g_data[c];
        coffset=row_index * packet_size;
        for (i=coffset, k=0; i < ccount && k < packet_size; i++, k++) {
          row_data[i]^=cdata[i];
        }
      }
      cdata=rdata;
      coffset=row_index * packet_size;
      count=row_count;
      for (i=coffset, k=0; i < count && k < packet_size; i++, k++) {
        row_data[i]^=cdata[i];
      }
      g=(row_index + row_disk - 2) % pnumRdp;
    }
  }
}

private void rdp_decoding_rd ( char [ ] [ ] g_data , int disks , int stripe_unit_size , int w , int x , int y ) { int packet_size = stripe_unit_size / w ; int ccount , count , rcount ; char [ ] rdata , xdata , ydata , row_data , diag_data ; int g , gx , gy , coffset , i , j , k , c ; int row_disk , diag_disk ; rcount = stripe_unit_size ; rdata = g_data [ 0 ] ; xdata = g_data [ x ] ; ydata = g_data [ y ] ; gx = ( x >= 3 ? x - 3 : pnumRdp - 1 ) ; gy = ( y >= 3 ? y - 3 : pnumRdp - 1 ) ; row_disk = x ; diag_disk = y ; row_data = xdata ; diag_data = ydata ; g = gx ; while ( true ) { if ( g == pnumRdp - 1 ) { if ( gx == ( row_disk >= 3 ? row_disk - 3 : row_disk + pnumRdp - 3 ) ) { row_disk = y ; diag_disk = x ; row_data = ydata ; diag_data = xdata ; g = gy ; continue ; } else break ; } else { int row_index ; char [ ] cdata ; int diag_count ; int row_count ; diag_count = stripe_unit_size ; row_count = stripe_unit_size ; row_index = ( g - diag_disk + pnumRdp + 2 ) % pnumRdp ; coffset = ( row_index + diag_disk - 2 + pnumRdp ) % pnumRdp * packet_size ; cdata = g_data [ 1 ] ; for ( i = row_index * packet_size , j = coffset , k = 0 ; i < diag_count && k < packet_size ; i ++ , j ++ , k ++ ) { diag_data [ i ] = cdata [ j ] ; } for ( c = 2 ; c < ( disks + 2 ) ; c ++ ) { if ( c == diag_disk ) continue ; ccount = stripe_unit_size ; cdata = g_data [ c ] ; coffset = ( row_index + diag_disk - c + pnumRdp ) % pnumRdp * packet_size ; for ( i = row_index * packet_size , j = coffset , k = 0 ; i < diag_count && j < ccount && k < packet_size ; i ++ , j ++ , k ++ ) { diag_data [ i ] ^= cdata [ j ] ; } } ccount = rcount ; cdata = rdata ; coffset = ( row_index + diag_disk - 1 + pnumRdp ) % pnumRdp * packet_size ; for ( i = row_index * packet_size , j = coffset , k = 0 ; i < diag_count && j < ccount && k < packet_size ; i ++ , j ++ , k ++ ) { diag_data [ i ] ^= cdata [ j ] ; } coffset = row_index * packet_size ; for ( c = 2 ; c < ( disks + 2 ) ; c ++ ) { if ( c == row_disk ) continue ; ccount = stripe_unit_size ; cdata = g_data [ c ] ; coffset = row_index * packet_size ; for ( i = coffset , k = 0 ; i < ccount && k < packet_size ; i ++ , k ++ ) { row_data [ i ] ^= cdata [ i ] ; } } cdata = rdata ; coffset = row_index * packet_size ; count = row_count ; for ( i = coffset , k = 0 ; i < count && k < packet_size ; i ++ , k ++ ) { row_data [ i ] ^= cdata [ i ] ; } g = ( row_index + row_disk - 2 ) % pnumRdp ; } } }
rdp decoding according r and d checkouts . x / y : the first / second error disk in g_data
