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>
This commit is contained in:
Carlos Fernandez
2025-12-19 14:00:35 +01:00
parent 8988152fa5
commit 300f8ca65a
2 changed files with 11 additions and 4 deletions

View File

@@ -436,8 +436,15 @@ LLONG get_data(struct lib_ccx_ctx *ctx, struct wtv_chunked_buffer *cb, struct de
dbg_print(CCX_DMT_PARSE, "TIME: %ld\n", time);
if (time != -1 && time != WTV_CC_TIMESTAMP_MAGIC)
{ // Ignore -1 timestamps
set_current_pts(dec_ctx->timing, time_to_pes_time(time));
dec_ctx->timing->pts_set = 1;
LLONG pes_time = time_to_pes_time(time);
set_current_pts(dec_ctx->timing, pes_time);
// Set min_pts on first valid timestamp to enable fts_now calculation
if (dec_ctx->timing->min_pts == 0x01FFFFFFFF || pes_time < dec_ctx->timing->min_pts)
{
dec_ctx->timing->min_pts = pes_time;
}
// pts_set = 2 (MinPtsSet) is required for proper fts_now calculation
dec_ctx->timing->pts_set = 2;
frames_since_ref_time = 0;
set_fts(dec_ctx->timing);
}

View File

@@ -584,7 +584,7 @@ fn latin1_to_line21(c: Latin1Char) -> Line21Char {
0xbf => 0x83, // Inverted (open) question mark
0xa2 => 0x85, // Cents symbol
0xa3 => 0x86, // Pounds sterling
0xb6 => 0x87, // Music note (pilcrow in Latin-1)
b'#' => 0x87, // Music note (# in Latin-1)
0xe0 => 0x88, // lowercase a, grave accent
0x20 => 0x89, // transparent space
0xe8 => 0x8a, // lowercase e, grave accent
@@ -682,7 +682,7 @@ pub fn line21_to_latin1(c: Line21Char) -> Latin1Char {
0x84 => UNAVAILABLE_CHAR, // Trademark symbol (TM) - Does not exist in Latin 1
0x85 => 0xa2, // Cents symbol
0x86 => 0xa3, // Pounds sterling
0x87 => 0xb6, // Music note - Not in latin 1, so we use 'pilcrow'
0x87 => b'#', // Music note - Not in latin 1, so we use '#'
0x88 => 0xe0, // lowercase a, grave accent
0x89 => 0x20, // transparent space, we make it regular
0x8a => 0xe8, // lowercase e, grave accent