#include <math.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include "rdd.h"
#include "rdd_internals.h"
#include "error.h"
#include "writer.h"
#include "filter.h"
#include "msgprinter.h"
Go to the source code of this file.
Data Structures | |
struct | _RDD_STATS_BLOCKFILTER |
Defines | |
#define | NUM_BYTE_VAL 256 |
#define | RDD_LN2 0.69314718055994530942 |
Typedefs | |
typedef struct _RDD_STATS_BLOCKFILTER | RDD_STATS_BLOCKFILTER |
Functions | |
static void | compute_histogram_stats (RDD_STATS_BLOCKFILTER *state, unsigned block_size, double *entropy, unsigned *modus_byteval, unsigned *modus_count) |
int | rdd_new_stats_blockfilter (RDD_FILTER **self, unsigned blocksize, const char *outpath, const int force_overwrite) |
static int | stats_block (RDD_FILTER *f, unsigned nbyte) |
static int | stats_close (RDD_FILTER *f) |
static int | stats_free (RDD_FILTER *f) |
static int | stats_input (RDD_FILTER *f, const unsigned char *buf, unsigned nbyte) |
Variables | |
static char | copyright [] |
static RDD_FILTER_OPS | stats_ops |
#define NUM_BYTE_VAL 256 |
Definition at line 60 of file statsblockfilter.c.
#define RDD_LN2 0.69314718055994530942 |
Definition at line 62 of file statsblockfilter.c.
typedef struct _RDD_STATS_BLOCKFILTER RDD_STATS_BLOCKFILTER |
static void compute_histogram_stats | ( | RDD_STATS_BLOCKFILTER * | state, | |
unsigned | block_size, | |||
double * | entropy, | |||
unsigned * | modus_byteval, | |||
unsigned * | modus_count | |||
) | [static] |
Computes block statistics based on the byte-value histogram. The modus is the byte value that occurs most in the block. Entropy measures randomness in a block. It is computed as sum(-Pi * (log2(Pi))), where Pi is the occurrence frequency of byte value i and where i ranges over all byte values with positive Pi.
Definition at line 140 of file statsblockfilter.c.
References _RDD_STATS_BLOCKFILTER::histogram, NUM_BYTE_VAL, and RDD_LN2.
int rdd_new_stats_blockfilter | ( | RDD_FILTER ** | self, | |
unsigned | blocksize, | |||
const char * | outpath, | |||
const int | force_overwrite | |||
) |
Definition at line 89 of file statsblockfilter.c.
References _RDD_STATS_BLOCKFILTER::blocknum, error(), _RDD_STATS_BLOCKFILTER::histogram, _RDD_STATS_BLOCKFILTER::maxbyte, _RDD_STATS_BLOCKFILTER::minbyte, NUM_BYTE_VAL, _RDD_STATS_BLOCKFILTER::path, _RDD_STATS_BLOCKFILTER::printer, rdd_mp_open_file_printer(), rdd_new_filter(), RDD_NOMEM, RDD_OK, and _RDD_FILTER::state.
static int stats_block | ( | RDD_FILTER * | f, | |
unsigned | nbyte | |||
) | [static] |
Computes and outputs the per-block histogramming statistics: entropy, mininum byte value, maximum byte value, and modus.
Definition at line 195 of file statsblockfilter.c.
References _RDD_STATS_BLOCKFILTER::blocknum, compute_histogram_stats(), _RDD_STATS_BLOCKFILTER::histogram, _RDD_STATS_BLOCKFILTER::maxbyte, _RDD_STATS_BLOCKFILTER::minbyte, NUM_BYTE_VAL, _RDD_STATS_BLOCKFILTER::printer, rdd_mp_message(), RDD_MSG_INFO, RDD_OK, and _RDD_FILTER::state.
static int stats_close | ( | RDD_FILTER * | f | ) | [static] |
Definition at line 219 of file statsblockfilter.c.
References _RDD_STATS_BLOCKFILTER::printer, rdd_mp_close(), RDD_MP_READONLY, RDD_MP_RECURSE, RDD_OK, and _RDD_FILTER::state.
static int stats_free | ( | RDD_FILTER * | f | ) | [static] |
Definition at line 233 of file statsblockfilter.c.
References _RDD_STATS_BLOCKFILTER::path, RDD_OK, and _RDD_FILTER::state.
static int stats_input | ( | RDD_FILTER * | f, | |
const unsigned char * | buf, | |||
unsigned | nbyte | |||
) | [static] |
Uses the byte values in buf to update the histogramming statistics for the current block.
Definition at line 174 of file statsblockfilter.c.
References _RDD_STATS_BLOCKFILTER::histogram, _RDD_STATS_BLOCKFILTER::maxbyte, _RDD_STATS_BLOCKFILTER::minbyte, RDD_OK, and _RDD_FILTER::state.
char copyright[] [static] |
Initial value:
"@(#) Copyright (c) 2002\n\ Netherlands Forensic Institute. All rights reserved.\n"
Definition at line 39 of file statsblockfilter.c.
RDD_FILTER_OPS stats_ops [static] |
Initial value:
{ stats_input, stats_block, stats_close, 0, stats_free }
Definition at line 79 of file statsblockfilter.c.