diff --git a/src/lib_ccx/telxcc.c b/src/lib_ccx/telxcc.c index c77ce9a8..316530ec 100644 --- a/src/lib_ccx/telxcc.c +++ b/src/lib_ccx/telxcc.c @@ -50,7 +50,7 @@ int _CRT_fmode = _O_BINARY; #endif long long int last_pes_pts = 0; // PTS of last PES packet (debug purposes) -int de_ctr = 0; // a keeps count of packets with flag subtitle ON and data packets +static int de_ctr = 0; // a keeps count of packets with flag subtitle ON and data packets typedef struct { uint64_t show_timestamp; // show at timestamp (in ms) uint64_t hide_timestamp; // hide at timestamp (in ms) @@ -955,7 +955,7 @@ void process_telx_packet(struct TeletextCtx *ctx, data_unit_t data_unit_id, tele if (m == 0) m = 8; y = (address >> 3) & 0x1f; designation_code = (y > 25) ? unham_8_4(packet->data[0]) : 0x00; - + uint8_t flag_subtitle; if (y == 0) { @@ -978,14 +978,12 @@ void process_telx_packet(struct TeletextCtx *ctx, data_unit_t data_unit_id, tele ctx->seen_sub_page[thisp]=1; mprint ("\rNotice: Teletext page with possible subtitles detected: %03d\n",thisp); } - ++de_ctr; } if ((tlt_config.page == 0) && (flag_subtitle == YES) && (i < 0xff)) { tlt_config.page = (m << 8) | (unham_8_4(packet->data[1]) << 4) | unham_8_4(packet->data[0]); mprint ("- No teletext page specified, first received suitable page is %03x, not guaranteed\n", tlt_config.page); - ++de_ctr; - } + } // Page number and control bits page_number = (m << 8) | (unham_8_4(packet->data[1]) << 4) | unham_8_4(packet->data[0]); @@ -1004,7 +1002,7 @@ void process_telx_packet(struct TeletextCtx *ctx, data_unit_t data_unit_id, tele ctx->transmission_mode = (transmission_mode_t) (unham_8_4(packet->data[7]) & 0x01); // FIXME: Well, this is not ETS 300 706 kosher, however we are interested in DATA_UNIT_EBU_TELETEXT_SUBTITLE only - if ((ctx->transmission_mode == TRANSMISSION_MODE_PARALLEL) && (data_unit_id != DATA_UNIT_EBU_TELETEXT_SUBTITLE) && !(de_ctr && flag_subtitle)) return; + if ((ctx->transmission_mode == TRANSMISSION_MODE_PARALLEL) && (data_unit_id != DATA_UNIT_EBU_TELETEXT_SUBTITLE) && !(de_ctr && flag_subtitle && ctx->receiving_data == YES)) return; if ((ctx->receiving_data == YES) && ( ((ctx->transmission_mode == TRANSMISSION_MODE_SERIAL) && (PAGE(page_number) != PAGE(tlt_config.page))) || @@ -1016,7 +1014,7 @@ void process_telx_packet(struct TeletextCtx *ctx, data_unit_t data_unit_id, tele } // Page transmission is terminated, however now we are waiting for our new page - if (page_number != tlt_config.page && !(de_ctr && flag_subtitle)) + if (page_number != tlt_config.page && !(de_ctr && flag_subtitle && ctx->receiving_data == YES)) return;