summaryrefslogtreecommitdiff
authorHualing Chen <hualing.chen@amlogic.com>2017-12-12 02:52:03 (GMT)
committer hualing chen <hualing.chen@amlogic.com>2017-12-12 02:57:06 (GMT)
commit33a0d2c2aef2b9919b97f153c31fc4dc9bdb0ea7 (patch)
treeeaa93193e7cf81c07e17d9fecfc7b6cb95f6b0e4
parentb83ed7487e1ba31fcd1af454d7ae47f3db220980 (diff)
downloadlibzvbi-33a0d2c2aef2b9919b97f153c31fc4dc9bdb0ea7.zip
libzvbi-33a0d2c2aef2b9919b97f153c31fc4dc9bdb0ea7.tar.gz
libzvbi-33a0d2c2aef2b9919b97f153c31fc4dc9bdb0ea7.tar.bz2
PD#NONE: zvbi: fixed cc error
1.fixed cc error. Change-Id: Iab71f22f3a6ca5cfcb9350bcfe69908895867d98 Signed-off-by: Hualing Chen <hualing.chen@amlogic.com>
Diffstat
-rw-r--r--src/caption.c63
-rw-r--r--src/cc.h1
-rw-r--r--[-rwxr-xr-x]src/dtvcc.c214
-rw-r--r--src/dtvcc.h2
4 files changed, 152 insertions, 128 deletions
diff --git a/src/caption.c b/src/caption.c
index 23699d9..6320e9a 100644
--- a/src/caption.c
+++ b/src/caption.c
@@ -810,7 +810,7 @@ static inline void
update(cc_channel *ch)
{
#if 1
-int i;
+ int i;
vbi_char *acp = ch->line - ch->pg[ch->hidden].text + ch->pg[ch->hidden^1].text;
memcpy(acp, ch->line, sizeof(*acp) * COLUMNS);
@@ -1237,7 +1237,7 @@ caption_command(vbi_decoder *vbi, struct caption *cc,
word_break(cc, ch, 1);
ch->update = 1;
- /*if (ch->mode == MODE_ROLL_UP) */
+ if (ch->mode == MODE_ROLL_UP)
{
memmove(acp, acp + COLUMNS, sizeof(*acp) * (ch->roll - 1) * COLUMNS);
for (i = 0; i <= COLUMNS; i++) {
@@ -1376,6 +1376,20 @@ caption_command(vbi_decoder *vbi, struct caption *cc,
}
}
+static void
+update_display (vbi_decoder *vbi)
+{
+ struct caption *cc = &vbi->cc;
+ int i;
+
+ for (i=0; i<8; i++)
+ {
+ if (cc->channel[i].update == 1)
+ update(&cc->channel[i]);
+ cc->channel[i].update = 0;
+ }
+}
+
/**
* @internal
* @param vbi Initialized vbi decoding context.
@@ -1541,12 +1555,8 @@ vbi_decode_caption(vbi_decoder *vbi, int line, uint8_t *buf)
put_char(cc, ch, c);
}
}
- for (i=0; i<8; i++)
- {
- if (cc->channel[i].update == 1)
- update(&cc->channel[i]);
- cc->channel[i].update = 0;
- }
+
+ update_display(vbi);
if (line == 21) {
cc->curr_chan_f1 = cc->curr_chan;
@@ -1792,27 +1802,36 @@ void vbi_refresh_cc(vbi_decoder *vbi)
cc_channel *ch;
vbi_page *spg;
int i, j;
- int flash_flag = 0;
vbi_event event;
+ struct timespec now;
+ int flash;
+
+ clock_gettime(CLOCK_REALTIME, &now);
+
+ flash = (now.tv_nsec / 250000000) & 1;
+
pthread_mutex_lock(&vbi->cc.mutex);
- for (i = 0; i < 8; i++)
- {
- flash_flag = 0;
- ch = &vbi->cc.channel[i];
- spg = ch->pg + (ch->hidden ^ 1);
- for (j = 0; j < sizeof(spg->text)/sizeof(vbi_char); j++)
+
+ if (flash != vbi->cc.flash_state) {
+ vbi->cc.flash_state = flash;
+
+ for (i = 0; i < 8; i++)
{
- if (spg->text[j].flash)
+ ch = &vbi->cc.channel[i];
+ spg = ch->pg + (ch->hidden ^ 1);
+ for (j = 0; j < sizeof(spg->text)/sizeof(vbi_char); j++)
{
- flash_flag = 1;
- break;
+ if (spg->text[j].flash)
+ {
+ ch->update = 1;
+ break;
+ }
}
}
- if (flash_flag)
- {
- update(ch);
- }
+
+ update_display(vbi);
}
+
pthread_mutex_unlock(&vbi->cc.mutex);
}
diff --git a/src/cc.h b/src/cc.h
index 7800ff7..916448d 100644
--- a/src/cc.h
+++ b/src/cc.h
@@ -89,6 +89,7 @@ struct caption {
int itv_count;
int info_cycle[2];
+ int flash_state;
};
/* Public */
diff --git a/src/dtvcc.c b/src/dtvcc.c
index 0ea3a11..d7b6de5 100755..100644
--- a/src/dtvcc.c
+++ b/src/dtvcc.c
@@ -3817,6 +3817,108 @@ fetch_done:
/* ATSC A/53 Part 4:2007 Closed Caption Data decoder */
+/* Only handle effect */
+static void update_service_status_internal (struct tvcc_decoder *td)
+{
+ int i, j, k, l;
+ struct timespec ts_now;
+ struct dtvcc_decoder *decoder;
+ struct dtvcc_pen_style *target_pen;
+ int flash;
+
+ decoder = &td->dtvcc;
+ clock_gettime(CLOCK_REALTIME, &ts_now);
+
+ flash = (ts_now.tv_nsec / 250000000) & 1;
+
+ /* CS1 - CS6 */
+ for (i = 0; i < 6; ++i)
+ {
+ struct dtvcc_service *ds;
+ struct program *pr;
+ vbi_bool success;
+ ds = &decoder->service[i];
+ /* Check every effect */
+ if (ds->delay)
+ {
+ struct vbi_event event;
+ /* time is up */
+ if ((ts_now.tv_sec > ds->delay_timer.tv_sec) ||
+ ((ts_now.tv_sec == ds->delay_timer.tv_sec) &&(ts_now.tv_nsec > ds->delay_timer.tv_nsec)) ||
+ ds->delay_cancel)
+ {
+ //AM_DEBUG(1, "delay timeup");
+ ds->delay = 0;
+ ds->delay_cancel = 0;
+ dtvcc_decode_syntactic_elements
+ (decoder, ds, ds->service_data, ds->service_data_in);
+
+ ds->service_data_in = 0;
+ }
+ }
+
+ if (flash == decoder->flash_state)
+ continue;
+
+ for (j = 0; j < 8; j++)
+ {
+ /*window flash treatment */
+ if (ds->window[j].style.window_flash)
+ {
+ ds->window[j].style.fill_opacity = flash?0:3;
+ ds->update = 1;
+ }
+
+ /* Pen flash treatment */
+ for (k = 0; k < 16; k++)
+ {
+ for (l =0; l<42; l++)
+ {
+ target_pen = &ds->window[j].pen[k][l];
+ if (target_pen->bg_flash)
+ {
+ target_pen->bg_opacity = flash?0:3;
+ ds->update = 1;
+ }
+ if (target_pen->fg_flash)
+ {
+ target_pen->fg_opacity = flash?0:3;
+ ds->update = 1;
+ }
+ }
+ }
+ }
+ }
+
+ decoder->flash_state = flash;
+}
+
+static void
+update_display (struct tvcc_decoder *td)
+{
+ int i;
+
+ for (i = 0; i < N_ELEMENTS(td->dtvcc.service); i ++) {
+ struct dtvcc_service *ds = &td->dtvcc.service[i];
+
+ if (ds->update) {
+ struct vbi_event event;
+
+ event.type = VBI_EVENT_CAPTION;
+ event.ev.caption.pgno = i + 1 + 8/*after 8 cc channels*/;
+
+ /* Permits calling tvcc_fetch_page from handler */
+ pthread_mutex_unlock(&td->mutex);
+
+ vbi_send_event(td->vbi, &event);
+ pthread_mutex_lock(&td->mutex);
+
+ ds->update = 0;
+ }
+ }
+}
+
+
/* Note pts may be < 0 if no PTS was received. */
void
tvcc_decode_data (struct tvcc_decoder *td,
@@ -3936,121 +4038,21 @@ tvcc_decode_data (struct tvcc_decoder *td,
}
}
- {
- int i;
-
- for (i = 0; i < N_ELEMENTS(td->dtvcc.service); i ++) {
- struct dtvcc_service *ds = &td->dtvcc.service[i];
-
- if (ds->update) {
- struct vbi_event event;
-
- event.type = VBI_EVENT_CAPTION;
- event.ev.caption.pgno = i + 1 + 8/*after 8 cc channels*/;
-
- /* Permits calling tvcc_fetch_page from handler */
- pthread_mutex_unlock(&td->mutex);
-
- vbi_send_event(td->vbi, &event);
- pthread_mutex_lock(&td->mutex);
-
- ds->update = 0;
- }
- }
- }
+ update_service_status_internal(td);
+ update_display(td);
- pthread_mutex_unlock(&td->mutex);
+ pthread_mutex_unlock(&td->mutex);
}
/* Only handle effect */
void update_service_status(struct tvcc_decoder *td)
{
- int i, j, k, l;
- struct timespec ts_now;
- struct dtvcc_decoder *decoder;
- struct dtvcc_pen_style *target_pen;
- decoder = &td->dtvcc;
- clock_gettime(CLOCK_REALTIME, &ts_now);
pthread_mutex_lock(&td->mutex);
- /* CS1 - CS6 */
- for (i = 0; i < 6; ++i) {
- struct dtvcc_service *ds;
- struct program *pr;
- vbi_bool success;
- ds = &decoder->service[i];
- /* Check every effect */
- if (ds->delay)
- {
- struct vbi_event event;
- /* time is up */
- if ((ts_now.tv_sec > ds->delay_timer.tv_sec) ||
- ((ts_now.tv_sec == ds->delay_timer.tv_sec) &&(ts_now.tv_nsec > ds->delay_timer.tv_nsec)) ||
- ds->delay_cancel)
- {
- //AM_DEBUG(1, "delay timeup");
- ds->delay = 0;
- ds->delay_cancel = 0;
- dtvcc_decode_syntactic_elements
- (decoder, ds, ds->service_data, ds->service_data_in);
- ds->service_data_in = 0;
- }
- }
- for (j = 0; j < 8; j++)
- {
- if (ds->window[j].style.window_flash)
- {
- /*window flash treatment */
- if (ds->window[j].style.window_flash)
- {
- ds->window[j].style.fill_opacity = (ts_now.tv_sec%2)?0:3;
- ds->update = 1;
- }
+ update_service_status_internal(td);
+ update_display(td);
- /* Pen flash treatment */
- for (k = 0; k < 16; k++)
- {
- for (l =0; l<42; l++)
- {
- target_pen = &ds->window[j].pen[k][l];
- if (target_pen->bg_flash)
- {
- target_pen->bg_opacity = (ts_now.tv_sec%2)?0:3;
- ds->update = 1;
- }
- if (target_pen->fg_flash)
- {
- target_pen->fg_opacity = (ts_now.tv_sec%2)?0:3;
- ds->update = 1;
- }
- }
- }
- }
- }
- }
- {
- int i;
-
- for (i = 0; i < N_ELEMENTS(td->dtvcc.service); i ++) {
- struct dtvcc_service *ds = &td->dtvcc.service[i];
-
- if (ds->update) {
- struct vbi_event event;
-
- event.type = VBI_EVENT_CAPTION;
- event.ev.caption.pgno = i + 1 + 8/*after 8 cc channels*/;
-
- /* Permits calling tvcc_fetch_page from handler */
- pthread_mutex_unlock(&td->mutex);
-
- vbi_send_event(td->vbi, &event);
- pthread_mutex_lock(&td->mutex);
-
- ds->update = 0;
- }
- }
- }
- pthread_mutex_unlock(&td->mutex);
+ pthread_mutex_unlock(&td->mutex);
}
void tvcc_init(struct tvcc_decoder *td)
diff --git a/src/dtvcc.h b/src/dtvcc.h
index 09cf195..d69758b 100644
--- a/src/dtvcc.h
+++ b/src/dtvcc.h
@@ -428,6 +428,8 @@ struct dtvcc_decoder {
/** The time when we last received data. */
struct cc_timestamp timestamp;
+
+ int flash_state;
};
/* ATSC A/53 Part 4:2007 Closed Caption Data decoder. */