- 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>
112 lines
5.6 KiB
C#
112 lines
5.6 KiB
C#
using Febe.Core.Codecs.H264;
|
||
|
||
namespace Febe.Tests.Codecs.H264;
|
||
|
||
/// <summary>
|
||
/// Tools of the Baseline and Extended profiles that no stream of the ITU-T series uses — slice data partitioning,
|
||
/// redundant slices — and slices in another order than the one of the series, on conformance streams rewritten by
|
||
/// <see cref="StreamRewriter"/>: the macroblocks keep their bits, so every frame must still be the official one.
|
||
/// </summary>
|
||
[TestClass]
|
||
public sealed class H264ExtendedToolsTests
|
||
{
|
||
[TestMethod]
|
||
[DataRow("BA3_SVA_C")] // Extended, B slices
|
||
[DataRow("sp1_bt_a")] // SP slices
|
||
[DataRow("FM1_FT_E")] // slice groups of types 1–4
|
||
[DataRow("MR6_BT_B")] // Extended, field pictures
|
||
[DataRow("CVMAQP3_Sony_D")] // MBAFF
|
||
[DataRow("SVA_BA1_B")] // non-IDR I slices: residual in partition B only
|
||
public void DataPartitionsGiveTheOfficialFrames(string name)
|
||
{
|
||
var stream = StreamRewriter.Partition(Original(name));
|
||
var types = NalTypes(stream);
|
||
Assert.IsFalse(types.Contains(1), "restano slice non partizionate");
|
||
Assert.IsTrue(types.Contains(2), "manca la partizione A");
|
||
Assert.IsTrue(types.Contains(3) || types.Contains(4), "mancano le partizioni B e C");
|
||
H264ConformanceTests.AssertStreamMatches(name, stream);
|
||
}
|
||
|
||
[TestMethod]
|
||
[DataRow(false, true)]
|
||
[DataRow(true, false)]
|
||
[DataRow(false, false)]
|
||
public void MissingPartitionsLeaveTheirResidualOut(bool keepB, bool keepC)
|
||
{
|
||
// Without partition B or C a slice still decodes, without the residual of its intra or inter macroblocks: every
|
||
// picture comes out, and the IDR picture (never partitioned) is still the official one.
|
||
var name = "BA3_SVA_C";
|
||
var complete = H264ConformanceTests.FrameMd5s(StreamRewriter.Partition(Original(name)));
|
||
var partial = H264ConformanceTests.FrameMd5s(StreamRewriter.Partition(Original(name), keepB, keepC));
|
||
var expected = H264ConformanceTests.ReferenceFrames(name);
|
||
Assert.HasCount(expected.Count, partial);
|
||
Assert.AreEqual(expected[0], partial[0], "l'immagine IDR");
|
||
Assert.IsTrue(partial.Where((md5, i) => md5 != complete[i]).Any(), "togliere una partizione cambia qualcosa");
|
||
}
|
||
|
||
[TestMethod]
|
||
[DataRow("BA3_SVA_C", 4101)] // CAVLC
|
||
[DataRow("CABA3_SVA_B", 4102)] // CABAC
|
||
[DataRow("MR6_BT_B", 4103)] // fields, POC type 1
|
||
[DataRow("CAPAMA3_Sand_F", 4104)] // CABAC, MBAFF and fields
|
||
[DataRow("FM1_FT_E", 4105)] // slice groups, several PPS
|
||
[DataRow("sp1_bt_a", 4106)] // SP slices
|
||
public void RedundantSlicesAreSkipped(string name, int seed)
|
||
{
|
||
var stream = StreamRewriter.AddRedundantSlices(Original(name), seed);
|
||
Assert.IsGreaterThan(Original(name).Length, stream.Length);
|
||
H264ConformanceTests.AssertStreamMatches(name, stream);
|
||
}
|
||
|
||
[TestMethod]
|
||
public void RedundantSlicesAreSkippedAlsoWhenPartitioned()
|
||
{
|
||
// The redundant slices become partitions A (header and random bits) with slice_id and redundant_pic_cnt.
|
||
var name = "BA3_SVA_C";
|
||
H264ConformanceTests.AssertStreamMatches(name, StreamRewriter.Partition(StreamRewriter.AddRedundantSlices(Original(name), 4107)));
|
||
}
|
||
|
||
[TestMethod]
|
||
[DataRow("BASQP1_Sony_C")] // twenty slices per picture
|
||
[DataRow("FM1_FT_E")] // slice groups
|
||
[DataRow("CAMASL3_Sony_B")] // CABAC, MBAFF, four slices per picture
|
||
public void SlicesInReverseOrderGiveTheOfficialFrames(string name)
|
||
{
|
||
var original = Original(name);
|
||
var stream = StreamRewriter.ReverseSlices(original);
|
||
CollectionAssert.AreNotEqual(original, stream, "il flusso ha più slice per immagine");
|
||
H264ConformanceTests.AssertStreamMatches(name, stream);
|
||
}
|
||
|
||
[TestMethod]
|
||
[DataRow("FM1_FT_E")] // several slices per picture: the stray partitions have a slice_id of their own
|
||
[DataRow("BASQP1_Sony_C")] // twenty slices per picture
|
||
[DataRow("BA3_SVA_C")] // one slice per picture: the stray partitions come after both B and C of the slice before
|
||
public void PartitionsBAndCWithoutTheirPartitionAAreIgnored(string name)
|
||
{
|
||
// A lost partition A leaves its B and C right after the partitions of the slice before, which is still waiting
|
||
// to be decoded: they must change nothing, as if the whole slice had been lost, and above all not the residual
|
||
// of the waiting slice.
|
||
var partitioned = StreamRewriter.Partition(Original(name));
|
||
var strays = StreamRewriter.DropPartitionsA(partitioned, alsoBAndC: false, out var dropped);
|
||
var lost = StreamRewriter.DropPartitionsA(partitioned, alsoBAndC: true, out var droppedWhole);
|
||
Assert.AreEqual(dropped, droppedWhole);
|
||
Assert.IsGreaterThanOrEqualTo(5, dropped, "slice senza partizione A");
|
||
Assert.IsGreaterThan(StreamRewriter.Units(lost).Count, StreamRewriter.Units(strays).Count, "restano le partizioni B e C");
|
||
CollectionAssert.AreEqual(H264ConformanceTests.FrameMd5s(lost), H264ConformanceTests.FrameMd5s(strays));
|
||
}
|
||
|
||
[TestMethod]
|
||
[DataRow("FM1_FT_E", 4201)]
|
||
[DataRow("sp2_bt_b", 4202)]
|
||
[DataRow("BA3_SVA_C", 4203)]
|
||
public void DamagedPartitionedStreamsGiveFramesOrAnH264Exception(string name, int seed)
|
||
{
|
||
H264RobustnessTests.AssertDamagedCopiesDecode(name, StreamRewriter.Partition(Original(name)), seed, trials: 30);
|
||
}
|
||
|
||
private static byte[] Original(string name) => File.ReadAllBytes(H264ConformanceTests.StreamFile(H264ConformanceTests.Folder(name)));
|
||
|
||
private static HashSet<int> NalTypes(byte[] stream) => StreamRewriter.Units(stream).Select(u => u[0] & 0x1F).ToHashSet();
|
||
}
|