E3: correzioni della revisione di formati e fotogrammi

Le 16 osservazioni confermate della revisione, ognuna con la sua prova:

- JPEG: il controllo stima la memoria di lavoro del decodificatore
  (progressivo), così un file che non si decodifica esce «troppo
  grande» e non «illeggibile».
- Un EXIF che non si tiene lascia un EXIF minimo con l'orientamento,
  perché la foto convertita non esca girata.
- Fotogrammi: istanti in millisecondi interi; la copia trova l'indice
  del nome dall'istante, non dall'ordine delle righe.
- Video di durata sconosciuta misurati prima di registrare: contano
  nei limiti di 500 per richiesta e 5000 per video.
- Rimuxaggio: la durata del segmento di elst passa nell'MP4, la fine
  tagliata resta nascosta (anche nei fotogrammi).
- H.264: il punto di recupero vale come IDR solo con exact_match_flag.
- MP3 in MP4: objectTypeIndication 0x69 fino a 24 kHz, 0x6B oltre.
- Conversione della libreria: il lavoro toglie le righe di un formato
  spento o cambiato; spegnere toglie anche i «Non riuscito»; «Riprova»
  solo i formati di adesso; pausa per spazio prima di rileggere
  l'originale.
- «Anche i N» conta e mette in coda solo il tipo che si cambia; le
  impostazioni dell'esportazione si salvano una per volta.
- Eliminazione e «Tieni il più grande» scelgono i convertiti nella
  stessa transazione: nessun convertito orfano.
- Un file arrivato tardi in un elemento vecchio mette in coda solo sé
  (file nuovo = salvato da quando il formato è scelto).
- Zip dei fotogrammi a pezzi di 64 KB: un browser lento che legge non
  si interrompe, uno fermo sì.

Decisioni in docs/decisioni.md (28/11), §4.10 della specifica precisato.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-28 13:30:33 +01:00
1 parent eb79b05fda
commit 958cb71cd6
38 files changed
+1276 -222

No files matched your search

+18 -4
View File
@@ -71,7 +71,10 @@ public sealed class FrameService(IClock clock)
/// <summary>The time a preview or a single frame may take, waiting included.</summary>
public TimeSpan Budget { get; init; } = TimeSpan.FromSeconds(30);
/// <summary>A write of the zip that makes no progress for this long aborts the download.</summary>
/// <summary>
/// A write of the zip that makes no progress for this long aborts the download: each piece of 64 KB sent restarts
/// the time, so a slow link that keeps reading is never cut.
/// </summary>
public TimeSpan WriteStall { get; init; } = TimeSpan.FromSeconds(60);
/// <summary>What a video allows, from the cache by SHA-256 when known (the file is opened only the first time).</summary>
@@ -371,6 +374,9 @@ public sealed class FrameService(IClock clock)
// A data descriptor is 16 or 24 bytes; anything far larger written synchronously is a change of the BCL.
private const int MaxPending = 64 * 1024;
// The bytes of one guarded write: the response buffer of Kestrel (64 KB).
private const int Piece = 64 * 1024;
private readonly MemoryStream _pending = new();
private long _position;
@@ -444,11 +450,19 @@ public sealed class FrameService(IClock clock)
await GuardedAsync(bytes, ct).ConfigureAwait(false);
}
/// <summary>
/// Sends <paramref name="buffer"/> in pieces of <see cref="Piece"/> bytes, each with its own time: a frame of
/// several megabytes on a slow link keeps going as long as every piece goes (a response write completes only once
/// the socket has taken nearly all of it), and stops after <c>stall</c> without one.
/// </summary>
private async Task GuardedAsync(ReadOnlyMemory<byte> buffer, CancellationToken ct)
{
using var guard = CancellationTokenSource.CreateLinkedTokenSource(ct);
guard.CancelAfter(stall);
await inner.WriteAsync(buffer, guard.Token).ConfigureAwait(false);
for (var offset = 0; offset < buffer.Length; offset += Piece)
{
using var guard = CancellationTokenSource.CreateLinkedTokenSource(ct);
guard.CancelAfter(stall);
await inner.WriteAsync(buffer.Slice(offset, Math.Min(Piece, buffer.Length - offset)), guard.Token).ConfigureAwait(false);
}
}
}
}