From f65b09547c1664aa887ae1f7187c217216c661ec Mon Sep 17 00:00:00 2001 From: Ke Gong Date: Thu, 23 Nov 2017 01:03:30 +0000 Subject: Revert "caption: fixed caption decoder [1/1]" This reverts commit c5d69bd0149f61ff4389007afab3a278609a1afd. --- diff --git a/src/caption.c b/src/caption.c index 040a658..3d7508c 100644 --- a/src/caption.c +++ b/src/caption.c @@ -908,7 +908,7 @@ erase_memory(struct caption *cc, cc_channel *ch, int page) { vbi_page *pg = ch->pg + page; vbi_char *acp = pg->text; - memset(pg->text, 0, sizeof(pg->text)); + memset(pg->text, 0, 1056*sizeof(vbi_char)); #if 0 //vbi_char c = cc->transp_space[ch >= &cc->channel[4]]; vbi_char c = {0}; @@ -980,7 +980,6 @@ caption_command(vbi_decoder *vbi, struct caption *cc, set_cursor(ch, 1, row); if (c2 & 0x10) { - /* col = ch->col; for (i = (c2 & 14) * 2; i > 0 && col < COLUMNS - 1; i--) @@ -988,9 +987,6 @@ caption_command(vbi_decoder *vbi, struct caption *cc, if (col > ch->col) ch->col = ch->col1 = col; - */ - - ch->col = (c2 & 14) * 2 + 1; ch->attr.italic = FALSE; ch->attr.foreground = VBI_WHITE; @@ -1058,19 +1054,6 @@ caption_command(vbi_decoder *vbi, struct caption *cc, case 2: /* Optional Extended Characters 001 c01f 01x xxxx */ case 3: /* Send specs to the maintainer of this code */ - { - vbi_char c; - - c = ch->attr; - c.unicode = vbi_caption_unicode((c1 << 8) | c2 | 0x1000, 0); - - if (c.unicode) { - if (ch->col > 1) - ch->col --; - - put_char(cc, ch, c); - } - } return; case 4: /* Misc Control Codes 001 c10f 010 xxxx */ @@ -1160,10 +1143,8 @@ caption_command(vbi_decoder *vbi, struct caption *cc, // not verified if (ch->mode) { if (ch->col > 1) { - if (ch->line[ch->col - 1].unicode == 0) - return; ch->col --; - } else if (ch->row > 0) { + } else if (ch->row > 1) { vbi_char *acp; ch->row --; @@ -1172,9 +1153,9 @@ caption_command(vbi_decoder *vbi, struct caption *cc, ch->col = COLUMNS - 1; acp = ch->line + COLUMNS - 1; - while (ch->col > 1) { + while (ch->col > 0) { if (acp->unicode != 0) - break; + break; acp --; ch->col --; @@ -1213,12 +1194,13 @@ caption_command(vbi_decoder *vbi, struct caption *cc, word_break(cc, ch, 1); ch->update = 1; - if (ch->mode == MODE_ROLL_UP) { - memmove(acp, acp + COLUMNS, sizeof(*acp) * (ch->roll - 1) * COLUMNS); - for (i = 0; i <= COLUMNS; i++) { - memset(&ch->line[i], 0, sizeof(vbi_char)); - } - } + if (ch->mode == MODE_ROLL_UP) + { + memmove(acp, acp + COLUMNS, sizeof(*acp) * (ch->roll - 1) * COLUMNS); + + for (i = 0; i <= COLUMNS; i++) + ch->line[i] = cc->transp_space[chan >> 2]; + } if (ch->mode != MODE_POP_ON) { ch->update = 1; @@ -1235,9 +1217,8 @@ caption_command(vbi_decoder *vbi, struct caption *cc, if (!ch->mode) return; - for (i = ch->col; i <= COLUMNS - 1; i++) { - memset(&ch->line[i], 0, sizeof(vbi_char)); - } + for (i = ch->col; i <= COLUMNS - 1; i++) + ch->line[i] = cc->transp_space[chan >> 2]; word_break(cc, ch, 0); @@ -1246,7 +1227,6 @@ caption_command(vbi_decoder *vbi, struct caption *cc, render(ch->pg + (ch->hidden ^ 1), ch->row); } - ch->update = 1; return; case 12: /* Erase Displayed Memory 001 c10f 010 1100 */ @@ -1273,16 +1253,12 @@ caption_command(vbi_decoder *vbi, struct caption *cc, clear(ch->pg + (ch->hidden ^ 1)); } - ch->update = 1; return; case 14: /* Erase Non-Displayed Memory 001 c10f 010 1110 */ // not verified if (ch->mode == MODE_POP_ON) erase_memory(cc, ch, ch->hidden); - erase_memory(cc, ch, ch->hidden ^ 1); - - ch->update = 1; return; } @@ -1297,18 +1273,13 @@ caption_command(vbi_decoder *vbi, struct caption *cc, switch (c2) { case 0x21 ... 0x23: /* Misc Control Codes, Tabs 001 c111 010 00xx */ // not verified - /* col = ch->col; for (i = c2 & 3; i > 0 && col < COLUMNS - 1; i--) ch->line[col++] = cc->transp_space[chan >> 2]; if (col > ch->col) - ch->col = ch->col1 = col;*/ - - ch->col += (c2 & 3); - if (ch->col >= COLUMNS) - ch->col = COLUMNS - 1; + ch->col = ch->col1 = col; return; @@ -1420,15 +1391,15 @@ vbi_decode_caption(vbi_decoder *vbi, int line, uint8_t *buf) vbi_char c; case 0x01 ... 0x0F: - /*if (!field2)*/ + if (!field2) cc->last[0] = 0; break; /* XDS field 1?? */ case 0x10 ... 0x1F: //if ( (buf[1]) >= 0) { // vbi_unpar8 (buf[1]) if ( vbi_unpar8 (buf[1]) >= 0) { - if (/*!field2 - &&*/ buf[0] == cc->last[0] + if (!field2 + && buf[0] == cc->last[0] && buf[1] == cc->last[1]) { /* cmd repetition F1: already executed */ cc->last[0] = 0; /* one rep */ @@ -1437,11 +1408,11 @@ vbi_decode_caption(vbi_decoder *vbi, int line, uint8_t *buf) caption_command(vbi, cc, c1, buf[1] & 0x7F, field2); - /*if (!field2)*/ { + if (!field2) { cc->last[0] = buf[0]; cc->last[1] = buf[1]; } - } else /*if (!field2)*/ + } else if (!field2) cc->last[0] = 0; break; @@ -1469,7 +1440,7 @@ vbi_decode_caption(vbi_decoder *vbi, int line, uint8_t *buf) break; } - /*if (!field2)*/ + if (!field2) cc->last[0] = 0; ch->nul_ct = 0; -- cgit