[PR #1841] fix: Fix variable shadowing and teletext context refresh issues #2604

Closed
opened 2026-01-29 17:23:01 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/CCExtractor/ccextractor/pull/1841

State: closed
Merged: Yes


Summary

Fixes regression tests failing with exit code 10 (no captions found) on Sample Platform test 6904:

  • CEA-708 tests: 137, 141, 142, 146, 147, 149
  • Teletext tests: 78, 79, 80, 82
  • Options test: 217

Root Cause Analysis

Two bugs were identified:

1. Variable Shadowing in general_loop()

In general_loop(), the line:

int ret = process_non_multiprogram_general_loop(...)

declared a new local variable that shadowed the outer ret variable (initialized to 0). The outer ret determines the exit code via:

return ret ? EXIT_OK : EXIT_NO_CAPTIONS;

Since the outer ret was never updated, CCExtractor always reported "No captions found".

2. Missing private_data Refresh After PAT Changes

In update_decoder_list_cinfo(), when returning an existing decoder context in non-multiprogram mode, dec_ctx->private_data was not being refreshed from the new cap_info.

After PAT changes:

  1. dinit_cap() frees teletext context and NULLs dec_ctx->private_data
  2. New cap_info created with new codec_private_data
  3. update_decoder_list_cinfo() returned existing decoder without updating private_data
  4. All subsequent teletext processing skipped due to NULL check

Changes

  1. general_loop.c: Remove int declaration to update outer ret variable
  2. general_loop.c: Set ret = 1 when captions detected via counters (for CEA-708)
  3. lib_ccx.c: Refresh dec_ctx->private_data from cinfo->codec_private_data when returning existing decoder

Test plan

  • Teletext test (dcada745de) extracts 228 lines of captions
  • CEA-608 test (70000200c0) extracts captions correctly
  • Build succeeds with no new warnings

Note on CEA-708 Tests

Tests 137, 141, 142, etc. with --service 1 were also failing before the memory fixes merge. These samples may not have content in service 1. This fix addresses the variable shadowing issue; the underlying CEA-708 service detection may need separate investigation.

🤖 Generated with Claude Code

**Original Pull Request:** https://github.com/CCExtractor/ccextractor/pull/1841 **State:** closed **Merged:** Yes --- ## Summary Fixes regression tests failing with exit code 10 (no captions found) on Sample Platform test 6904: - CEA-708 tests: 137, 141, 142, 146, 147, 149 - Teletext tests: 78, 79, 80, 82 - Options test: 217 ## Root Cause Analysis Two bugs were identified: ### 1. Variable Shadowing in general_loop() In `general_loop()`, the line: ```c int ret = process_non_multiprogram_general_loop(...) ``` declared a **new local variable** that shadowed the outer `ret` variable (initialized to 0). The outer `ret` determines the exit code via: ```c return ret ? EXIT_OK : EXIT_NO_CAPTIONS; ``` Since the outer `ret` was never updated, CCExtractor always reported "No captions found". ### 2. Missing private_data Refresh After PAT Changes In `update_decoder_list_cinfo()`, when returning an existing decoder context in non-multiprogram mode, `dec_ctx->private_data` was not being refreshed from the new `cap_info`. After PAT changes: 1. `dinit_cap()` frees teletext context and NULLs `dec_ctx->private_data` 2. New `cap_info` created with new `codec_private_data` 3. `update_decoder_list_cinfo()` returned existing decoder **without updating `private_data`** 4. All subsequent teletext processing skipped due to NULL check ## Changes 1. **general_loop.c**: Remove `int` declaration to update outer `ret` variable 2. **general_loop.c**: Set `ret = 1` when captions detected via counters (for CEA-708) 3. **lib_ccx.c**: Refresh `dec_ctx->private_data` from `cinfo->codec_private_data` when returning existing decoder ## Test plan - [x] Teletext test (dcada745de) extracts 228 lines of captions - [x] CEA-608 test (70000200c0) extracts captions correctly - [x] Build succeeds with no new warnings ## Note on CEA-708 Tests Tests 137, 141, 142, etc. with `--service 1` were also failing **before** the memory fixes merge. These samples may not have content in service 1. This fix addresses the variable shadowing issue; the underlying CEA-708 service detection may need separate investigation. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
claunia added the pull-request label 2026-01-29 17:23:01 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#2604