2014-11-27 22:43:54 -05:00
|
|
|
/*
|
|
|
|
* Mini Object Storage, (C) 2014 Minio, Inc.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2015-01-27 15:36:44 -05:00
|
|
|
#include "ec-code.h"
|
|
|
|
#include "ec-common.h"
|
2014-11-27 22:43:54 -05:00
|
|
|
|
2015-03-12 05:00:36 -04:00
|
|
|
/*
|
|
|
|
Generate encode matrix during the encoding phase
|
|
|
|
*/
|
|
|
|
|
2014-11-29 17:58:40 -05:00
|
|
|
int32_t minio_init_encoder (int technique, int k, int m,
|
2014-12-07 03:09:24 -05:00
|
|
|
uint8_t **encode_matrix,
|
|
|
|
uint8_t **encode_tbls)
|
2014-11-27 22:43:54 -05:00
|
|
|
{
|
|
|
|
size_t encode_matrix_size;
|
|
|
|
size_t encode_tbls_size;
|
2014-12-07 03:09:24 -05:00
|
|
|
uint8_t *tmp_matrix;
|
|
|
|
uint8_t *tmp_tbls;
|
2014-11-27 22:43:54 -05:00
|
|
|
|
2014-12-07 03:09:24 -05:00
|
|
|
tmp_matrix = (uint8_t *) malloc (k * (k + m));
|
|
|
|
tmp_tbls = (uint8_t *) malloc (k * (k + m) * 32);
|
2014-11-27 22:43:54 -05:00
|
|
|
|
|
|
|
if (technique == 0) {
|
|
|
|
/*
|
|
|
|
Commonly used method for choosing coefficients in erasure
|
|
|
|
encoding but does not guarantee invertable for every sub
|
|
|
|
matrix. For large k it is possible to find cases where the
|
|
|
|
decode matrix chosen from sources and parity not in erasure
|
|
|
|
are not invertable. Users may want to adjust for k > 5.
|
|
|
|
-- Intel
|
|
|
|
*/
|
|
|
|
gf_gen_rs_matrix (tmp_matrix, k + m, k);
|
|
|
|
} else if (technique == 1) {
|
|
|
|
gf_gen_cauchy1_matrix (tmp_matrix, k + m, k);
|
|
|
|
}
|
|
|
|
|
|
|
|
ec_init_tables(k, m, &tmp_matrix[k * k], tmp_tbls);
|
|
|
|
|
|
|
|
*encode_matrix = tmp_matrix;
|
|
|
|
*encode_tbls = tmp_tbls;
|
2014-11-29 17:58:40 -05:00
|
|
|
|
|
|
|
return 0;
|
2014-11-27 22:43:54 -05:00
|
|
|
}
|