diff options
author | Tobias Grimm <git@e-tobi.net> | 2010-02-02 11:40:09 +0100 |
---|---|---|
committer | Tobias Grimm <git@e-tobi.net> | 2010-02-02 11:40:09 +0100 |
commit | ca85202fdca7097841010760ec25167ae7c994fb (patch) | |
tree | 789a2e842097f30024f03c9901736948d60a1134 | |
parent | da651bf5e4034b451687141066cb22245a1b7b62 (diff) | |
download | vdr-plugin-ttxtsubs-ca85202fdca7097841010760ec25167ae7c994fb.tar.gz vdr-plugin-ttxtsubs-ca85202fdca7097841010760ec25167ae7c994fb.tar.bz2 |
refactoring - removed dead '#if 0' code
-rw-r--r-- | siinfo.c | 97 | ||||
-rw-r--r-- | teletext.c | 415 | ||||
-rw-r--r-- | ttxtsubsdisplay.c | 32 | ||||
-rw-r--r-- | ttxtsubsfilter.c | 16 |
4 files changed, 0 insertions, 560 deletions
@@ -355,17 +355,6 @@ static void addpageinfo(struct ttxtinfo *info, uint16_t pid, struct ttxt_descr * pa->mag = descr->d[descr_index].type_mag & 0x7; pa->page = descr->d[descr_index].page_no; -#if 0 - // Test - rewrite initial page 100 into subtitles page 150 - if(pa->type == TTXT_INITIAL_PAGE && - pa->mag = 0x1 && - pa->page == 0x00) { - pa->type = TTXT_SUBTITLE_PAGE; // or TTXT_SUBTITLE_HEARING_IMPAIRED_PAGE ? - pa->mag = 0x1; - pa->page = 0x50; - } -#endif - if(globals.frenchSpecial()) { /* By some silly reason some French channels (Canal+ and CanalSatellite) announce subtitles with the page number in decimal, for example @@ -708,89 +697,3 @@ struct ttxtpidinfo *FindSubs(struct ttxtinfo *info, int *pid, int *pageno, char *pageno = -1; return NULL; } - - -#if 0 -int XX_GetTtxtSubtitleInfo(uint16_t pid, int card_no, struct ttxtinfo *info) -{ - int len; - char buf[4096]; - struct PMT_sect *p = (struct PMT_sect *) buf; - char *sp; - - memset((char *) info, 0, sizeof(*info)); - - len = GetSection(pid, 2, 0xFF, card_no, buf, sizeof(buf)); - - //dump_hex("Sect: ", (uint8_t *) buf, len); - - if(len < 0) - return len; - - if(len != ((ntohs(p->syntax_len) & 0xfff) + 3)) { - dprint("bad length: %x / %x!\n", len, ntohs(p->syntax_len)); - return -1; - } - - // also skip extra program info - sp = ((char *) &(p->s)) + (ntohs(p->res_program_info_length) & 0xfff); - - while(sp < buf + len - 4) { - struct PMT_stream *s = (struct PMT_stream *) sp; - - //printf("type: %d, pid: %d, len: %d\n", s->stream_type, ntohs(s->res_PID) & 0x1fff, ntohs(s->res_ES_info_len) & 0xfff); - //dump_hex("descr: ", sp, ntohs(s->res_ES_info_len) & 0xfff); - - if(s->stream_type == 6) { // PES private data - uint8_t *descr; - - for(descr = s->descrs; descr < s->descrs + (ntohs(s->res_ES_info_len) & 0xfff); descr += descr[1] + 2) { - //dump_hex("descr: ", descr, descr[1] + 2); - if(descr[0] == DESCR_TELETEXT) { - struct ttxt_descr *t = (struct ttxt_descr *) descr; - int i, count = t->length / sizeof(t->d[0]); - for(i = 0; i < count; i++) { - addpageinfo(info, ntohs(s->res_PID) & 0x1fff, t, i); - //printf("%c%c%c: type %d, page: %01x%02x\n", t->d[i].lang[0], t->d[i].lang[1], t->d[i].lang[2], t->d[i].type_mag >> 3, - //t->d[i].type_mag & 0x7, t->d[i].page_no); - } - } - } - } - - sp += (ntohs(s->res_ES_info_len) & 0xfff) + 5; - } - - return 0; -} -#endif - -#if 0 -//XXX temporary for testing! -int get_subs(char *lang, int sid, int vpid, int cardno, int *pid, int *page) { - struct ttxtinfo info; - int i, j; - int result = -1; - - GetTtxtInfo(cardno, sid, vpid, &info); - - for(i = 0; i < info.pidcount; i++) { - //printf("PID: %d ", info.p[i].pid); - for(j = 0; j < info.p[i].pagecount; j++) { - //printf(" %c%c%c: %01x%02x (%d) ", - // info.p[i].i[j].lang[0], info.p[i].i[j].lang[1], info.p[i].i[j].lang[2], - // info.p[i].i[j].mag, info.p[i].i[j].page, info.p[i].i[j].type); - if(info.p[i].i[j].lang[0] == lang[0] && info.p[i].i[j].lang[1] == lang[1] && - info.p[i].i[j].lang[2] == lang[2] && - (info.p[i].i[j].type == TTXT_SUBTITLE_PAGE || info.p[i].i[j].type == TTXT_SUBTITLE_HEARING_IMPAIRED_PAGE)) { - *pid = info.p[i].pid; - *page = info.p[i].i[j].mag * 0x100 + info.p[i].i[j].page; - result = 0; - } - } - //printf("\n"); - } - - return result; -} -#endif @@ -330,418 +330,3 @@ void print_line(char *p) dprint("\n"); } - - -#if 0 -void -show_page(struct ttxt_page *p) -{ - static cOsdBase *o = NULL; - static tWindowHandle w1 = 0; - static tWindowHandle w2 = 0; - static int open1 = 0, open2 = 0; - char *s1 = NULL, *s2 = NULL; - int i, j; - - for(i = 1; i < TTXT_ROWS; i++) { - char *s = NULL; - if(p->data[i][0]) { - int do_incr = 0; - dprint("Checking row %d\n", i); - for(j = 0; j < 40; j++) { - p->data[i][j] = p->data[i][j] & 0x7f; - switch(p->data[i][j]) { - case 0x0d: // double height - case 0x0f: // double size - do_incr = 1; - break; - case 0x0a: // box end - p->data[i][j] = '\0'; - break; - case 0x0b: // box begin - s = (char *) &(p->data[i][j+1]); - dprint("Using row %d\n", i); - break; - case '[': - p->data[i][j] = 'Ä'; - break; - case ']': - p->data[i][j] = 'Å'; - break; - case '\\': - p->data[i][j] = 'Ö'; - break; - case '{': - p->data[i][j] = 'ä'; - break; - case '}': - p->data[i][j] = 'å'; - break; - case '|': - p->data[i][j] = 'ö'; - break; - } - } - if(do_incr) - i++; - dprint("\n"); - } - - if(s) - if(!s1) - s1 = s; - else if(!s2) - s2 = s; - } - - if(s1 && !s2) { - s2 = s1; - s1 = NULL; - } - - if(s1) - dprint("S1: %s\n", s1); - else - dprint("S1: <none>\n"); - if(s2) - dprint("S2: %s\n", s2); - else - dprint("S2: <none>\n"); - - if(o != NULL) { - if(open1) { - o->Clear(w1); - open1 = 0; - } - if(open2) { - o->Clear(w2); - open2 = 0; - } - - o->Clear(); - delete o; - o = NULL; - } - - if(!s1 && !s2) - return; - - o = cOsd::OpenRaw(125, 450); - - if(o == NULL) - return; - - o->SetFont(fontOsd); - - if(s1) { - int w = o->Width((char *) s1); - dprint("w1: %d\n", w); - w = 450; - int h = 36; - w1 = o->Create(0, 0, w, h, 2); -#if 0 - o->AddColor(clrBackground, w1); - o->AddColor(clrWhite, w1); -#endif - o->Fill(0, 0, w, h, clrBackground, w1); - o->Text(15, 4, (char *) s1, clrWhite, clrBackground, w1); - open1 = 1; - } - - if(s2) { - int w = o->Width((char *) s2); - dprint("w2: %d\n", w); - w = 452; - int h = 36; - w2 = o->Create(0, 45, w, h, 2); -#if 0 - o->AddColor(clrBackground, w2); - o->AddColor(clrWhite, w2); -#endif - o->Fill(0, 45, w, 45 + h, clrBackground, w2); - o->Text(15, 45 + 4, (char *) s2, clrWhite, clrBackground, w2); - open2 = 1; - } - - o->Flush(); -} -#endif - -#if 0 -void -ttxt_packet_in(int data_unit_id, int mag, int pack, uint8_t *data) -{ - static int valid = 0; - static struct ttxt_page p; - int i; - - if(pack == 0) { - if(valid) - if(p.mag == TTXT_MAG && p.no == TTXT_PAGE) - if(p.subtitle) - //print_page(&p); - /* if(p.mag == 1) */{ - show_page(&p); - print_page(&p); - } - - memset(&p, 0, sizeof(p)); - p.data_unit_id = data_unit_id; - p.mag = mag; - p.no = unham(data[0], data[1]); - - if(data[3] & 0x80) { // Erase Page - memset(p.data, 0, sizeof(p.data)); - p.erasepage = 1; - } - if(data[5] & 0x20) // Newsflash - p.newsflash = 1; - if(data[5] & 0x80) // Subtitle - p.subtitle = 1; - if(data[6] & 0x02) // Suppress Header - p.suppress_header = 1; - //if(data[6] & 0x08) // Update Indicator - //if(data[6] & 0x20) // Interrupted Sequence - if(data[6] & 0x80) // Inhibit Display - p.inhibit_display = 1; - //if(data[7] & 0x02) // Magazine Serial - - p.national_charset = - ((data[7] & 0x80) >> 7) + ((data[7] & 0x20) >> 4) + ((data[7] & 0x08) >> 1); - - valid = 1; - - for(i = 0; i < 32; i++) - p.data[0][i] = data[i+8]; - } else if(pack < 26) { - for(i = 0; i < 42; i++) - p.data[pack][i] = data[i]; - } else { - if((valid && p.mag == TTXT_MAG && p.no == TTXT_PAGE) || - pack == 28) - dprint("mag: %d, pack: %d, page: %02x\n", p.mag, pack, p.no); - } -} -#endif - -#if 0 -void -ttxt_pes_data_in(struct ttxt_pes_data_field *t, int len) -{ - int i; - - if(len < 1) - return; - - if(t->data_identifier < 0x10 || t->data_identifier > 0x1F) { - dprint("Unknown data identifier: %02x\n", t->data_identifier); - return; - } - - for(i = 0; (uint8_t *) (&(t->d[i+1])) < (((uint8_t *) t) + len); i++) { - struct ttxt_data_field *d = &(t->d[i]); - int i; - uint8_t *p; - int uh; - int mag; - int pack; - - // if(d->data_unit_id != ttxt_subtitle) - // continue; - - p = (uint8_t *) &(d->mag_addr_ham); - for(i = 0; i < 42; i++) { - p[i] = invtab[p[i]]; - } - - uh = unham(d->mag_addr_ham[0], d->mag_addr_ham[1]); - mag = uh & 0x7; - pack = (uh >> 3) & 0x1f; - - // dump_hex("line", (uint8_t *) d, 20); - // dprint("id: %d, line: %d, mag %d, pack: %d\n", d->data_unit_id, TTXT_LINE_NO(*d), mag, pack); - - ttxt_packet_in(d->data_unit_id, mag, pack, d->data); - } -} - - -void -set_filt(int fd,uint16_t tt_pid, dmx_pes_type_t t) -{ - struct dmx_pes_filter_params pesFilterParams; - - memset(&pesFilterParams, 0, sizeof(pesFilterParams)); - - pesFilterParams.pid = tt_pid; - pesFilterParams.input = DMX_IN_FRONTEND; - pesFilterParams.output = DMX_OUT_TAP; - pesFilterParams.pes_type = t; - pesFilterParams.flags = DMX_IMMEDIATE_START; - - if (ioctl(fd, DMX_SET_PES_FILTER, &pesFilterParams) < 0) - perror("DMX SET PES FILTER:"); - - // XXX set buffer size too? -} -#endif - -#if 0 -#define BUFSIZE 2000 - -// external entry point -void ttxt_decode(int fd, int tpid, int *doRun) -{ - uint8_t buf[BUFSIZE]; - int n; - int hunt = 1; - - set_filt(fd, tpid, DMX_PES_OTHER); - - while (*doRun) { - restart: - if(hunt) { - int i; - - dprint("hunting...\n"); - n = read(fd, buf, 199); - if(n < 0) { - perror("ttxt_decode:read: "); - goto restart; - } - - for(i = 0; i < (n - 3); i++) { - if(buf[i] == 0 && buf[i+1] == 0 && buf[i+2] == 1 && buf[i+3] == 0xbd) { - struct ttxt_pes_header *p = (struct ttxt_pes_header *) (buf + i); - size_t skip = ntohs(p->len) + 6 - (n - i); - - if(skip > 0) { - read(fd, buf, skip < sizeof(buf) ? skip : sizeof(buf)); - if(n < 0) { - perror("ttxt_decode:read: "); - goto restart; - } - hunt = 0; - break; - } - } - } - } else { - struct ttxt_pes_header *p = (struct ttxt_pes_header *) buf; - - n = read(fd, buf, 6); - if(n < 0) { - perror("ttxt_decode:read: "); - goto restart; - } - - if(p->start[0] != 0 || p->start[1] != 0 || p->start[2] != 1 || - p->stream_id != 0xbd || // private_stream_1 - ntohs(p->len) > (sizeof(buf) - 6)) { - dprint("Lost PES packet sync, hunting...\n"); - hunt = 1; - continue; - } - - n = read(fd, buf + 6, ntohs(p->len)); - if(n < 0) { - perror("ttxt_decode:read: "); - goto restart; - } - - // dprint("len: %d\n", n); - - if(n != ntohs(p->len) || - p->header_len != 0x24) { // header should allways be 0x24 long (EN 300 472) - dprint("Error reading PES packet, hunting...\n"); - hunt = 1; - continue; - } - - ttxt_pes_data_in((struct ttxt_pes_data_field *) (buf + 45), n + 6 - 45); - } - - // fwrite(buf,1,n,stdout); - } - - dprint("ttxt_decode DONE!\n"); -} -#endif - - -#if 0 -int -main(int argc, char **argv) -{ - int fd; - int pid; - uint8_t buf[BUFSIZE]; - int n; - int hunt = 1; - - if (argc!=2) { - fprintf(stderr,"USAGE: %s PID\n", argv[0]); - return -1; - } - - pid = atoi(argv[1]); - - if((fd = open("/dev/dvb/adapter0/demux0", O_RDWR)) < 0){ - perror("Error opening demux device: "); - return -1; - } - - set_filt(fd, pid, DMX_PES_OTHER); - - for (;;) { - if(hunt) { - int i; - - dprint("hunting...\n"); - n = read(fd, buf, 199); - - for(i = 0; i < (n - 3); i++) { - if(buf[i] == 0 && buf[i+1] == 0 && buf[i+2] == 1 && buf[i+3] == 0xbd) { - struct ttxt_pes_header *p = (struct ttxt_pes_header *) (buf + i); - int skip = ntohs(p->len) + 6 - (n - i); - - if(skip > 0) { - read(fd, buf, skip < sizeof(buf) ? skip : sizeof(buf)); - hunt = 0; - break; - } - } - } - } else { - struct ttxt_pes_header *p = (struct ttxt_pes_header *) buf; - - n = read(fd, buf, 6); - - if(p->start[0] != 0 || p->start[1] != 0 || p->start[2] != 1 || - p->stream_id != 0xbd || // private_stream_1 - ntohs(p->len) > (sizeof(buf) - 6)) { - dprint("Lost PES packet sync, hunting...\n"); - hunt = 1; - continue; - } - - n = read(fd, buf + 6, ntohs(p->len)); - - // dprint("len: %d\n", n); - - if(n != ntohs(p->len) || - p->header_len != 0x24) { // header should allways be 0x24 long (EN 300 472) - dprint("Error reading PES packet, hunting...\n"); - hunt = 1; - continue; - } - - ttxt_pes_data_in((struct ttxt_pes_data_field *) (buf + 45), n + 6 - 45); - } - - // fwrite(buf,1,n,stdout); - } - - return 0; -} -#endif diff --git a/ttxtsubsdisplay.c b/ttxtsubsdisplay.c index 0ab1e9b..3f49cb9 100644 --- a/ttxtsubsdisplay.c +++ b/ttxtsubsdisplay.c @@ -326,38 +326,6 @@ ttxt2la1(uint8_t *p, char *buf, int natopts) return NULL; } -#if 0 - -#define TEST_CENTER 0 -#if TEST_CENTER -#define SCREENLEFT 0 -#define SCREENWIDTH 720 -#else -#define SCREENLEFT 125 -#endif - -#define TEST_169 0 -#if TEST_169 -#define SCREENBOT 480 -#else -#define SCREENBOT 540 -#endif - -#if 0 -#define ROWINCR 45 -#define ROWH 36 -#define TEXTY 4 -#else -#define ROWINCR 43 -#define ROWH 34 -#define TEXTY 3 -#endif -#define TEXTX 15 -//#define SCREENTOP (SCREENBOT - MAXTTXTROWS * ROWINCR) -#define SCREENTOP 100 - -#endif - enum { SCREENLEFT = 0, SCREENRIGHT = 719, diff --git a/ttxtsubsfilter.c b/ttxtsubsfilter.c index ea72844..ecfd170 100644 --- a/ttxtsubsfilter.c +++ b/ttxtsubsfilter.c @@ -52,13 +52,6 @@ void cTtxtSubsFilter::SetPages(size_t count, uint16_t *pages) memcpy((char *) mPages, (char *) pages, count * sizeof(uint16_t)); mCount = count; - -#if 0 - dprint("SetPages: %d, ", count); - for(size_t i = 0; i < count; i++) - dprint("%03x ", pages[i]); - dprint("\n"); -#endif } // XXX IF MERGING PAGES FROM SEVERAL PIDS (which we currently don't) @@ -80,15 +73,6 @@ int cTtxtSubsFilter::Filter(char *indata, char *outdata) mag = mp & 0x7; packet = (mp >> 3) & 0x1f; -#if 0 // XXX - uint8_t buf[2]; - ham8_4byte(mp, buf); - dprint("unham %02x %02x -> %02x, ham: %02x %02x\n", - invtab[d->mag_addr_ham[0]], invtab[d->mag_addr_ham[1]], - mp, - buf[0], buf[1]); -#endif - // packet 0, change page no in this magazine if(packet == 0) { uint8_t no; |