Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/lib_ccx/general_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1711,6 +1711,7 @@ int rcwt_loop(struct lib_ccx_ctx *ctx)
struct encoder_ctx *enc_ctx = update_encoder_list(ctx);
struct TeletextCtx *telctx;
int saved_binary_concat;
int is_teletext;
// As BUFSIZE is a macro this is just a reminder
if (BUFSIZE < (3 * 0xFFFF + 10))
fatal(CCX_COMMON_EXIT_BUG_BUG, "In rcwt_loop: BUFSIZE too small for RCWT caption block.\n");
Expand Down Expand Up @@ -1771,7 +1772,11 @@ int rcwt_loop(struct lib_ccx_ctx *ctx)
#else
dec_ctx->dtvcc->encoder = (void *)enc_ctx; // WARN: otherwise cea-708 will not work
#endif
if (parsebuf[6] == 0 && parsebuf[7] == 2)
// The file header decides the mode once: parsebuf is reused for data
// headers and caption blocks below, so re-reading it per iteration could
// route 608 caption data into the teletext decoder (whose context is NULL).
is_teletext = (parsebuf[6] == 0 && parsebuf[7] == 2);
if (is_teletext)
{
dec_ctx->codec = CCX_CODEC_TELETEXT;
dec_ctx->private_data = telxcc_init();
Expand All @@ -1789,7 +1794,7 @@ int rcwt_loop(struct lib_ccx_ctx *ctx)
// Loop until no more data is found
while (1)
{
if (parsebuf[6] == 0 && parsebuf[7] == 2)
if (is_teletext)
{
result = buffered_read(ctx->demux_ctx, buf, TELETEXT_CHUNK_LEN);
ctx->demux_ctx->past += result;
Expand Down
Loading