Skip to content

Commit 300f8ca

Browse files
cfsmp3claude
andcommitted
fix(wtv,encoding): Fix WTV timing and Latin-1 music note encoding
WTV timing fix: - Set min_pts on first valid timestamp to enable fts_now calculation - Set pts_set = 2 (MinPtsSet) instead of 1 (Received) - This fixes WTV files where all timestamps were clustered around 1 second instead of being spread across the actual video duration Latin-1 encoding fix: - Change music note substitution from pilcrow (0xB6) to '#' (0x23) - Pilcrow caused grep to treat output files as binary - '#' is a more recognizable substitute for the musical note character 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 8988152 commit 300f8ca

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/lib_ccx/wtv_functions.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,15 @@ LLONG get_data(struct lib_ccx_ctx *ctx, struct wtv_chunked_buffer *cb, struct de
436436
dbg_print(CCX_DMT_PARSE, "TIME: %ld\n", time);
437437
if (time != -1 && time != WTV_CC_TIMESTAMP_MAGIC)
438438
{ // Ignore -1 timestamps
439-
set_current_pts(dec_ctx->timing, time_to_pes_time(time));
440-
dec_ctx->timing->pts_set = 1;
439+
LLONG pes_time = time_to_pes_time(time);
440+
set_current_pts(dec_ctx->timing, pes_time);
441+
// Set min_pts on first valid timestamp to enable fts_now calculation
442+
if (dec_ctx->timing->min_pts == 0x01FFFFFFFF || pes_time < dec_ctx->timing->min_pts)
443+
{
444+
dec_ctx->timing->min_pts = pes_time;
445+
}
446+
// pts_set = 2 (MinPtsSet) is required for proper fts_now calculation
447+
dec_ctx->timing->pts_set = 2;
441448
frames_since_ref_time = 0;
442449
set_fts(dec_ctx->timing);
443450
}

src/rust/lib_ccxr/src/util/encoding.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ fn latin1_to_line21(c: Latin1Char) -> Line21Char {
584584
0xbf => 0x83, // Inverted (open) question mark
585585
0xa2 => 0x85, // Cents symbol
586586
0xa3 => 0x86, // Pounds sterling
587-
0xb6 => 0x87, // Music note (pilcrow in Latin-1)
587+
b'#' => 0x87, // Music note (# in Latin-1)
588588
0xe0 => 0x88, // lowercase a, grave accent
589589
0x20 => 0x89, // transparent space
590590
0xe8 => 0x8a, // lowercase e, grave accent
@@ -682,7 +682,7 @@ pub fn line21_to_latin1(c: Line21Char) -> Latin1Char {
682682
0x84 => UNAVAILABLE_CHAR, // Trademark symbol (TM) - Does not exist in Latin 1
683683
0x85 => 0xa2, // Cents symbol
684684
0x86 => 0xa3, // Pounds sterling
685-
0x87 => 0xb6, // Music note - Not in latin 1, so we use 'pilcrow'
685+
0x87 => b'#', // Music note - Not in latin 1, so we use '#'
686686
0x88 => 0xe0, // lowercase a, grave accent
687687
0x89 => 0x20, // transparent space, we make it regular
688688
0x8a => 0xe8, // lowercase e, grave accent

0 commit comments

Comments
 (0)