Codebase list libisal / 438ecd8
Update custom hufftable tool for saving histogram Change-Id: I515217b19373b8f996ff887268862cf2b102f3a4 Signed-off-by: Greg Tucker <greg.b.tucker@intel.com> Greg Tucker 3 years ago
1 changed file(s) with 29 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
348348 struct isal_zstream tmp_stream;
349349 FILE *file = NULL;
350350 FILE *dict_file = NULL;
351 FILE *hist_file = NULL;
351352 long int dict_file_length = 0;
353 long int hist_file_length = 0;
352354 uint8_t *dict_stream = NULL;
353355
354356 if (argc == 1) {
383385 free(dict_stream);
384386 }
385387
386 memset(&histogram, 0, sizeof(histogram)); /* Initialize histograms. */
388 if ((argc > argi + 1) && argv[argi][0] == '-' && argv[argi][1] == 'h') {
389 hist_file = fopen(argv[argi + 1], "r+");
390 fseek(hist_file, 0, SEEK_END);
391 hist_file_length = ftell(hist_file);
392 fseek(hist_file, 0, SEEK_SET);
393 hist_file_length -= ftell(hist_file);
394 if (hist_file_length > sizeof(histogram)) {
395 printf("Histogram file too long\n");
396 return 1;
397 }
398 if (fread(&histogram, 1, hist_file_length, hist_file) != hist_file_length) {
399 printf("Error occurred when reading history file");
400 fclose(hist_file);
401 return 1;
402 }
403 fseek(hist_file, 0, SEEK_SET);
404
405 printf("Read %ld bytes of history file %s\n", hist_file_length,
406 argv[argi + 1]);
407 argi += 2;
408 } else
409 memset(&histogram, 0, sizeof(histogram)); /* Initialize histograms. */
387410
388411 while (argi < argc) {
389412 printf("Processing %s\n", argv[argi]);
447470
448471 fclose(file);
449472
473 if (hist_file) {
474 int len = fwrite(&histogram, 1, sizeof(histogram), hist_file);
475 printf("wrote %d bytes of histogram file\n", len);
476 fclose(hist_file);
477 }
450478 return 0;
451479 }