Lines Matching refs:ctx

42 static void encode_rs(struct image_proc_ctx *ctx)  in encode_rs()  argument
44 struct image *fcx = ctx->ctx; in encode_rs()
49 for (i = ctx->start; i < ctx->end; i += fcx->rs_n) { in encode_rs()
54 encode_rs_char(ctx->rs, data, &fcx->fec[ctx->fec_pos]); in encode_rs()
55 ctx->fec_pos += fcx->roots; in encode_rs()
59 static void decode_rs(struct image_proc_ctx *ctx) in decode_rs() argument
61 struct image *fcx = ctx->ctx; in decode_rs()
68 for (i = ctx->start; i < ctx->end; i += fcx->rs_n) { in decode_rs()
73 memcpy(&data[fcx->rs_n], &fcx->fec[ctx->fec_pos], fcx->roots); in decode_rs()
74 rv = decode_rs_char(ctx->rs, data, NULL, 0); in decode_rs()
85 ctx->rv += rv; in decode_rs()
88 ctx->fec_pos += fcx->roots; in decode_rs()
136 static int print_size(image& ctx) in print_size() argument
139 printf("%" PRIu64 "\n", fec_ecc_get_size(ctx.inp_size, ctx.roots)); in print_size()
172 static int encode(image& ctx, const std::vector<std::string>& inp_filenames, in encode() argument
175 if (ctx.inplace) { in encode()
179 if (!image_load(inp_filenames, &ctx)) { in encode()
183 if (!image_ecc_new(fec_filename, &ctx)) { in encode()
187 INFO("encoding RS(255, %d) to '%s' for input files:\n", ctx.rs_n, in encode()
196 if (ctx.verbose) { in encode()
197 INFO("\traw fec size: %u\n", ctx.fec_size); in encode()
198 INFO("\tblocks: %" PRIu64 "\n", ctx.blocks); in encode()
199 INFO("\trounds: %" PRIu64 "\n", ctx.rounds); in encode()
202 if (!image_process(encode_rs, &ctx)) { in encode()
206 if (!image_ecc_save(&ctx)) { in encode()
210 image_free(&ctx); in encode()
214 static int decode(image& ctx, const std::vector<std::string>& inp_filenames, in decode() argument
219 if (ctx.inplace && ctx.sparse) { in decode()
224 if (ctx.padding) { in decode()
228 if (!image_ecc_load(fec_filename, &ctx) || in decode()
229 !image_load(inp_filenames, &ctx)) { in decode()
233 if (ctx.inplace) { in decode()
235 inp_filename.c_str(), ctx.rs_n, fec_filename.c_str()); in decode()
241 out_filename.empty() ? out_filename.c_str() : "<none>", ctx.rs_n, in decode()
245 if (ctx.verbose) { in decode()
246 INFO("\traw fec size: %u\n", ctx.fec_size); in decode()
247 INFO("\tblocks: %" PRIu64 "\n", ctx.blocks); in decode()
248 INFO("\trounds: %" PRIu64 "\n", ctx.rounds); in decode()
251 if (!image_process(decode_rs, &ctx)) { in decode()
255 if (ctx.rv) { in decode()
256 INFO("corrected %" PRIu64 " errors\n", ctx.rv); in decode()
261 if (!out_filename.empty() && !image_save(out_filename, &ctx)) { in decode()
265 image_free(&ctx); in decode()
275 image ctx; in main() local
277 image_init(&ctx); in main()
278 ctx.roots = FEC_DEFAULT_ROOTS; in main()
305 ctx.sparse = true; in main()
319 ctx.roots = (int)parse_arg(optarg, "roots", FEC_RSM); in main()
322 ctx.inplace = true; in main()
325 ctx.threads = (int)parse_arg(optarg, "threads", IMAGE_MAX_THREADS); in main()
332 ctx.inp_size = parse_arg(optarg, "print-fec-size", UINT64_MAX); in main()
349 ctx.padding = (uint32_t)parse_arg(optarg, "padding", UINT32_MAX); in main()
350 if (ctx.padding % FEC_BLOCKSIZE) { in main()
355 ctx.verbose = true; in main()
367 assert(ctx.roots > 0 && ctx.roots < FEC_RSM); in main()
386 if (ctx.inplace) { in main()
398 return print_size(ctx); in main()
403 return encode(ctx, inp_filenames, fec_filename); in main()
405 return decode(ctx, inp_filenames, fec_filename, out_filename); in main()