X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=input%2Fvcd.c;h=138aa3c1526bbebee085de5d4289f8bcda865b3d;hb=388f9d3e25da89df1fb01412688339b6de54e14e;hp=3aad3bd89b3c655308723abcce4d993846e73277;hpb=8be8746951e5538147370d9871a4c1ed0268db52;p=libsigrok.git diff --git a/input/vcd.c b/input/vcd.c index 3aad3bd8..138aa3c1 100644 --- a/input/vcd.c +++ b/input/vcd.c @@ -37,6 +37,10 @@ * downsample: Divide the samplerate by the given factor. * This can speed up analyzing of long captures. * + * compress: Compress idle periods longer than this value. + * This can speed up analyzing of long captures. + * Default 0 = don't compress. + * * Based on Verilog standard IEEE Std 1364-2001 Version C * * Supported features: @@ -167,6 +171,7 @@ struct context int maxprobes; int probecount; int downsample; + unsigned compress; int64_t skip; struct probe probes[SR_MAX_NUM_PROBES]; }; @@ -344,6 +349,11 @@ static int init(struct sr_input *in) } } + param = g_hash_table_lookup(in->param, "compress"); + if (param) { + ctx->compress = strtoul(param, NULL, 10); + } + param = g_hash_table_lookup(in->param, "skip"); if (param) { ctx->skip = strtoul(param, NULL, 10) / ctx->downsample; @@ -447,6 +457,12 @@ static void parse_contents(FILE *file, const struct sr_dev_inst *sdi, struct con } else { + if (ctx->compress != 0 && timestamp - prev_timestamp > ctx->compress) + { + /* Compress long idle periods */ + prev_timestamp = timestamp - ctx->compress; + } + sr_dbg("New timestamp: %" PRIu64, timestamp); /* Generate samples from prev_timestamp up to timestamp - 1. */