Correzioni dopo la revisione del decodificatore H.264, dei lettori FLV e della CI (#58)

- CI: le due prove MVC di FeaturesStillToDo finivano con «da verificare: …», che
  riepilogo-prove.sh contava come saltate: ogni verifica del ramo sarebbe fallita.
  Ora cominciano con «da fare: », e lo script esenta solo le inconclusive di
  FeaturesStillToDo il cui motivo comincia con «da fare: » subito dopo la cornice
  di MSTest (prima bastava la parola in qualunque punto di qualunque prova).
  PipelineTests prova lo script su .trx con le cornici inglese e italiana;
  processo.md, Sviluppo.md e verifica.yml descrivono la categoria.
- Partizionamento dei dati: una partizione B o C sperduta (partizione A persa)
  sovrascriveva il buffer delle partizioni della slice in attesa. Ora slice_id e
  redundant_pic_cnt si leggono prima di copiare, e contano l'ordine A, B, C.
- MVC: le viste tengono insieme al massimo 2 × MaxDpbMbs di immagini, e il
  decodificatore di una vista nuova si tiene solo dopo il controllo dell'SPS di
  sottoinsieme; Wanted vale per ogni vista.
- FLV: senza durata nei metadati la durata arriva alla fine dell'ultimo
  fotogramma, come per MPEG; «solo audio» solo con una prova vera nella testa
  (un onMetaData grande non fa più scartare un video).
- Flussi di conformità: tolti i 48 readme e schede di terzi (decisione di
  Alberto: nel repository solo flussi e MD5).
- Prove nuove: partizioni A perse, limite delle viste e Wanted in MVC, unità di
  estensione troncate, flussi rovinati 4:2:2, 10 bit, 4:0:0, SVC e MVC.
- Commenti sulla provenienza che citano i file di ricostruzione ufficiali e
  §8.7 invece del decodificatore di riferimento; commento di
  ImportEnvironment.VideoProbe aggiornato; righe nuove in decisioni.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-18 19:30:45 +01:00
1 parent 6c8b228333
commit cdc3cc11b9
71 files changed
+668 -2223

No files matched your search

@@ -125,7 +125,13 @@ public sealed class LegacyContainerTests
{
var es = ElementaryStream.Load("BA1_Sony_D");
var file = LegacyTestVideos.Flv(es, metadata: false, audio: true);
var expected = Math.Round((es.Count - 1) * 1000.0 / 30) / 1000;
// The last video tag plus one frame (the interval from the tag before it), as the MPEG reader counts the last
// frame and as the metadata of the same stream say: es.Count frames at 30 per second, to the millisecond of the
// tag times.
static double Dts(int i) => Math.Round(i * 1000.0 / 30);
var expected = ((2 * Dts(es.Count - 1)) - Dts(es.Count - 2)) / 1000;
Assert.AreEqual(expected, es.Count / 30.0, 0.002, "the metadata of the same stream");
foreach (var samples in new[] { false, true })
{
var container = Read(file, samples);
@@ -162,7 +168,7 @@ public sealed class LegacyContainerTests
var container = Read(LegacyTestVideos.SorensonFlv(code, width, height));
Assert.AreEqual(VideoCodec.H263, container.Video!.Codec);
Assert.AreEqual((width, height), (container.Video.Width, container.Video.Height));
Assert.AreEqual(0.36, container.Duration!.Value.TotalSeconds, 1e-6, "dal primo all'ultimo tag");
Assert.AreEqual(0.4, container.Duration!.Value.TotalSeconds, 1e-6, "dal primo tag alla fine dell'ultimo fotogramma: dieci da 40 ms");
Assert.IsEmpty(container.Video.Samples, "solo H.264 si decodifica");
}
@@ -186,6 +192,45 @@ public sealed class LegacyContainerTests
Assert.AreEqual(MediaKind.Video, MediaSniffer.Detect(hevc)?.Kind);
}
[TestMethod]
public void AnFlvIsAudioOnlyOnlyWithProofInItsHead()
{
using var temp = new TempFolder("flv-solo-audio");
// A header that says audio without video, an onMetaData larger than the 512 bytes of MediaSniffer.HeadLength and
// video tags after it: the head ends inside the metadata, which proves nothing, so it stays a video.
var video = LegacyTestVideos.AudioFlaggedFlv(metadataBytes: 4000, seconds: 3, videoFromMs: 500);
Assert.IsGreaterThan(MediaSniffer.HeadLength, video.Length);
Assert.IsFalse(FlvReader.IsAudioOnly(video.AsSpan(0, MediaSniffer.HeadLength)));
Assert.AreEqual(MediaKind.Video, MediaSniffer.DetectFile(TestVideos.Write(temp, "video.flv", video))?.Kind);
Assert.AreEqual(MediaKind.Video, MediaSniffer.Detect(Head(video))?.Kind);
Assert.IsNotNull(Read(video).Video, "il video c'è");
// The same with audio only: a whole file, or a head with five seconds of audio and no video tag, proves it; the
// first 512 bytes, or a head that holds only a little audio after the metadata, do not.
var audio = LegacyTestVideos.AudioFlaggedFlv(metadataBytes: 4000, seconds: 8);
Assert.IsTrue(FlvReader.IsAudioOnly(audio));
Assert.IsNull(MediaSniffer.Detect(Head(audio)));
Assert.IsTrue(FlvReader.IsAudioOnly(audio.AsSpan(0, audio.Length - 100)), "più di cinque secondi di solo audio");
Assert.AreEqual(MediaKind.Video, MediaSniffer.DetectFile(TestVideos.Write(temp, "audio.flv", audio))?.Kind);
var audioStart = 13 + 11 + ((audio[14] << 16) | (audio[15] << 8) | audio[16]) + 4; // after onMetaData
Assert.IsFalse(FlvReader.IsAudioOnly(audio.AsSpan(0, audioStart + (20 * 23) + 7)), "venti tag d'audio, mezzo secondo");
Assert.IsFalse(FlvReader.IsAudioOnly(audio.AsSpan(0, 13 + 11 + 3000)), "la testa finisce dentro i metadati");
// Video after five seconds of audio alone: a head that holds it sees the video tag.
var late = LegacyTestVideos.AudioFlaggedFlv(metadataBytes: 100, seconds: 8, videoFromMs: 6000);
Assert.IsFalse(FlvReader.IsAudioOnly(late));
}
[TestMethod]
public void WithoutADurationAnAudioFlvLastsUntilItsLastFrameEnds()
{
// onMetaData without a duration and no video: the last audio tag plus the interval from the one before it.
var audio = LegacyTestVideos.AudioFlaggedFlv(metadataBytes: 0, seconds: 2);
var last = (2000 - 1) / 26 * 26;
Assert.AreEqual((last + 26) / 1000.0, Read(audio, samples: false).Duration!.Value.TotalSeconds, 1e-6);
}
// ----- MPEG program stream -----
[TestMethod]
@@ -289,6 +289,32 @@ internal static class LegacyTestVideos
return output.ToArray();
}
/// <summary>
/// An FLV whose header says audio and no video, opened by an onMetaData tag of about <paramref name="metadataBytes"/>
/// bytes (a keyframe index), then MP3 tags every 26 ms for <paramref name="seconds"/>, and from
/// <paramref name="videoFromMs"/> on (when given) H.263 video tags among them every 40 ms.
/// </summary>
public static byte[] AudioFlaggedFlv(int metadataBytes, double seconds, int? videoFromMs = null)
{
using var output = new MemoryStream();
FlvHeader(output, audio: true, video: false);
var times = Enumerable.Range(0, Math.Max(1, metadataBytes / 9)).Select(i => i * 0.04);
FlvTag(output, 18, 0, [.. AmfString("onMetaData"), 8, .. U32(1), .. AmfProperty("times", AmfArray(times)), 0, 0, 9]);
var nextVideo = videoFromMs ?? int.MaxValue;
for (var time = 0; time < seconds * 1000; time += 26)
{
while (nextVideo <= time)
{
FlvTag(output, 9, nextVideo, [0x22, 0, 0, 0x80, 0, 0x0A, 0x00, 0x00, 0x00, 0x00]);
nextVideo += 40;
}
FlvTag(output, 8, time, [0x2F, 0xFF, 0xFB, 0x90, 0x64, 0, 0, 0]); // MP3, 44 kHz, stereo
}
return output.ToArray();
}
private static void FlvHeader(MemoryStream output, bool audio, bool video)
{
output.Write("FLV"u8);