use JIT decompression

This commit is contained in:
hummypkg 2011-06-05 20:27:10 +00:00 committed by HummyPkg
parent c63e1251dc
commit 9c85217f8b
4 changed files with 50 additions and 32 deletions

View File

@ -64,22 +64,6 @@ read_lstring(struct epg *epg, unsigned int *len)
return c;
}
static void
uncompress_epg(char **epg, unsigned int *epglen)
{
char *new;
unsigned int newlen;
if ((new = (char *)
freeview_huffman_to_string((unsigned char *)(*epg),
*epglen, &newlen)))
{
free(*epg);
*epg = new;
*epglen = newlen;
}
}
void
read_descriptor(struct epg *epg, struct descriptor *d)
{
@ -95,13 +79,6 @@ read_descriptor(struct epg *epg, struct descriptor *d)
d->content.d77.text =
read_lstring(epg, &d->content.d77.textlen);
if (*d->content.d77.name == 0x1f)
uncompress_epg(&d->content.d77.name,
&d->content.d77.namelen);
if (*d->content.d77.text == 0x1f)
uncompress_epg(&d->content.d77.text,
&d->content.d77.textlen);
break;
case DS_COMPONENT:

1
lint.h
View File

@ -18,6 +18,7 @@ char *hexstr(uint8_t *, uint32_t);
char *ctime_nl(time_t *);
time_t mjd(uint16_t, int, int, int);
void safeprintf(char *, ...);
void uncompress_epg(char **, unsigned int *);
struct epg *open_file(char *);
void close_file(struct epg *);

42
main.c
View File

@ -55,6 +55,9 @@ syntax()
return 0;
}
#define DECOMPRESS(str, len) \
if (*(str) == 0x1f) uncompress_epg(&(str), &(len))
void
dumpraw(struct epg *epg __attribute__((unused)),
struct section *s, struct data *d, struct descriptor **ds,
@ -80,6 +83,13 @@ dump(struct epg *epg __attribute__((unused)),
tm = mjd(d->start_date, d->start_hour, d->start_min, d->start_sec);
if (ds[PARSER_SHORT_EVENT])
{
struct descriptor *d77 = ds[PARSER_SHORT_EVENT];
DECOMPRESS(d77->content.d77.name, d77->content.d77.namelen);
DECOMPRESS(d77->content.d77.text, d77->content.d77.textlen);
}
if (sysopts & SYSOPT_PARSABLE)
{
/* service_id, event_id, start, duration, encrypted, name, text
@ -212,9 +222,16 @@ search(struct epg *epg __attribute__((unused)),
struct section *s, struct data *d, struct descriptor **ds,
void *var)
{
if (ds[PARSER_SHORT_EVENT] &&
strcasestr(ds[PARSER_SHORT_EVENT]->content.d77.name, (char *)var))
dump(epg, s, d, ds, NULL);
if (ds[PARSER_SHORT_EVENT])
{
struct descriptor *d77 = ds[PARSER_SHORT_EVENT];
DECOMPRESS(d77->content.d77.name, d77->content.d77.namelen);
if (strcasestr(ds[PARSER_SHORT_EVENT]->content.d77.name,
(char *)var))
dump(epg, s, d, ds, NULL);
}
}
void
@ -222,12 +239,19 @@ searchall(struct epg *epg __attribute__((unused)),
struct section *s, struct data *d, struct descriptor **ds,
void *var)
{
if (ds[PARSER_SHORT_EVENT] && (
strcasestr(ds[PARSER_SHORT_EVENT]->content.d77.name, (char *)var)
||
strcasestr(ds[PARSER_SHORT_EVENT]->content.d77.text, (char *)var)
))
dump(epg, s, d, ds, NULL);
if (ds[PARSER_SHORT_EVENT])
{
struct descriptor *d77 = ds[PARSER_SHORT_EVENT];
DECOMPRESS(d77->content.d77.name, d77->content.d77.namelen);
DECOMPRESS(d77->content.d77.text, d77->content.d77.textlen);
if (strcasestr(ds[PARSER_SHORT_EVENT]->content.d77.name,
(char *)var) ||
strcasestr(ds[PARSER_SHORT_EVENT]->content.d77.text,
(char *)var))
dump(epg, s, d, ds, NULL);
}
}
#define GETOPT \

16
util.c
View File

@ -12,6 +12,22 @@
#include "lint.h"
void
uncompress_epg(char **epg, unsigned int *epglen)
{
char *new;
unsigned int newlen;
if ((new = (char *)
freeview_huffman_to_string((unsigned char *)(*epg),
*epglen, &newlen)))
{
free(*epg);
*epg = new;
*epglen = newlen;
}
}
#ifdef sun
char *
strcasestr (char *h, char *n)