Decodificatore H.264 per gli strumenti di Baseline ed Extended: FMO, ASO, slice ridondanti, partizionamento dei dati, slice SP e SI (#58)
Il decodificatore rifiutava i flussi con gruppi di slice e con slice SP o SI, e non leggeva le partizioni A, B e C: ora li gestisce tutti, perché sono parte di Baseline ed Extended e un file della libreria può usarli. - Gruppi di slice dal PPS, tipi da 0 a 6, con il cambio per immagine di slice_group_change_cycle; il macroblocco successivo segue il gruppo (§8.2.2). - Slice in ordine qualunque: la disponibilità dei vicini era già per slice, il deblocking a fine immagine. - Slice SP e SI con QS (§8.6): predizione trasformata e riquantizzata in QS, anche per P_Skip; sp_for_switch_flag e macroblocchi SI; nel deblocking contano come intra. - Partizionamento: A con intestazione e dati di categoria 2, B con il residuo intra (e gli I_PCM), C con quello inter; la regola del nN a zero con la predizione intra vincolata (§9.2.1). Una partizione che manca lascia a zero il suo residuo e, da lì in poi, quello della partizione che ne dipende. I cinque flussi FMO, ASO e SP della serie ITU-T (FM2_SVA_C, FM1_FT_E, FM1_BT_B, sp1_bt_a, sp2_bt_b) passano fra i verificati e coincidono fotogramma per fotogramma. Partizionamento, slice ridondanti e ASO si provano riscrivendo flussi verificati senza toccare i bit dei macroblocchi (StreamRewriter) e chiedendo di nuovo il riferimento ufficiale; le SI con un flusso sintetico calcolato a mano. Anche i flussi nuovi e quelli partizionati sono provati rovinati. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9c626f67ec
commit
8d03ca23de
19 files changed
+1738
-169
No files matched your search
@@ -8,12 +8,15 @@ namespace Febe.Tests.Codecs.H264;
|
||||
/// The decoder against streams of the ITU-T H.264.1 conformance suite: every output frame, in output order, must have the
|
||||
/// MD5 of the corresponding frame of the official reconstruction (see Conformita/LEGGIMI.md). The verified streams include
|
||||
/// interlaced video — field pictures, PAFF, MBAFF, both together — with memory management operations, long-term
|
||||
/// references and POC type 1 on fields (MR6_BT_B, MR9_BT_B). None of them uses weighted prediction, gaps in frame_num or
|
||||
/// I_PCM: those parts of the decoder have no reference MD5 here (some are reached by <see cref="H264SyntheticStreamTests"/>,
|
||||
/// without an official reference). The streams of the parts the decoder does not handle yet (FMO and ASO, SP slices,
|
||||
/// 4:2:2, more than 8 bits, 4:0:0, SVC, MVC) are in
|
||||
/// <see cref="FeaturesStillToDo"/>: they are inconclusive until the feature is written, and fail as soon as one of them
|
||||
/// matches its reference without having been moved among the verified ones.
|
||||
/// references and POC type 1 on fields (MR6_BT_B, MR9_BT_B), slice groups of every map type with slices in any order
|
||||
/// (FM1_BT_B, FM1_FT_E, FM2_SVA_C) and SP slices (sp1_bt_a, sp2_bt_b; sp2 with the deblocking filter on). None of them
|
||||
/// uses weighted prediction, gaps in frame_num, I_PCM, SI slices, sp_for_switch_flag, data partitioning or redundant
|
||||
/// slices: data partitioning, redundant slices and other slice orders are checked on conformance streams rewritten by
|
||||
/// <see cref="StreamRewriter"/> (<see cref="H264ExtendedToolsTests"/>), SI slices and the rest by
|
||||
/// <see cref="H264SyntheticStreamTests"/>, without an official reference. The streams of the parts the decoder does not
|
||||
/// handle yet (4:2:2, more than 8 bits, 4:0:0, SVC, MVC) are in <see cref="FeaturesStillToDo"/>: they are inconclusive
|
||||
/// until the feature is written, and fail as soon as one of them matches its reference without having been moved among
|
||||
/// the verified ones.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public sealed class H264ConformanceTests
|
||||
@@ -48,6 +51,11 @@ public sealed class H264ConformanceTests
|
||||
[DataRow("FRExt4_Panasonic_B")]
|
||||
[DataRow("MR6_BT_B")]
|
||||
[DataRow("MR9_BT_B")]
|
||||
[DataRow("FM2_SVA_C")]
|
||||
[DataRow("FM1_FT_E")]
|
||||
[DataRow("FM1_BT_B")]
|
||||
[DataRow("sp1_bt_a")]
|
||||
[DataRow("sp2_bt_b")]
|
||||
public void FramesMatchTheReference(string name) => AssertMatches(name, "riferimento.md5");
|
||||
|
||||
[TestMethod]
|
||||
@@ -62,11 +70,6 @@ public sealed class H264ConformanceTests
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow("FM2_SVA_C", "FMO (gruppi di slice di tipo 0) e ASO")]
|
||||
[DataRow("FM1_FT_E", "FMO (gruppi di slice di tipo 1, 2, 3 e 4)")]
|
||||
[DataRow("FM1_BT_B", "FMO (gruppi di slice di tipo 0-6) e ASO")]
|
||||
[DataRow("sp1_bt_a", "slice SP (Extended)")]
|
||||
[DataRow("sp2_bt_b", "slice SP (Extended)")]
|
||||
[DataRow("Hi422FR10_SONY_A", "4:2:2 a 8 bit, solo slice I (CABAC)")]
|
||||
[DataRow("Hi422FR11_SONY_A", "4:2:2 a 8 bit con slice P (CABAC)")]
|
||||
[DataRow("Hi422FR12_SONY_A", "4:2:2 a 8 bit con slice B (CABAC)")]
|
||||
@@ -162,7 +165,14 @@ public sealed class H264ConformanceTests
|
||||
internal static string StreamFile(string folder) =>
|
||||
Directory.EnumerateFiles(folder).Single(f => Path.GetExtension(f).ToLowerInvariant() is ".264" or ".jsv" or ".avc" or ".h264" or ".jvt");
|
||||
|
||||
private static void AssertMatches(string name, string reference)
|
||||
private static void AssertMatches(string name, string reference) =>
|
||||
AssertStreamMatches(name, File.ReadAllBytes(StreamFile(Folder(name))), reference);
|
||||
|
||||
/// <summary>
|
||||
/// <paramref name="stream"/> (the conformance stream <paramref name="name"/>, possibly rewritten) must give every frame
|
||||
/// of the official reconstruction.
|
||||
/// </summary>
|
||||
internal static void AssertStreamMatches(string name, byte[] stream, string reference = "riferimento.md5")
|
||||
{
|
||||
var folder = Folder(name);
|
||||
var expected = ReadReference(Path.Combine(folder, reference), out var declared);
|
||||
@@ -171,7 +181,7 @@ public sealed class H264ConformanceTests
|
||||
var frames = new List<H264Frame>();
|
||||
var decoder = new H264Decoder();
|
||||
decoder.FrameDecoded += frames.Add;
|
||||
decoder.DecodeAnnexB(File.ReadAllBytes(StreamFile(folder)));
|
||||
decoder.DecodeAnnexB(stream);
|
||||
|
||||
var ordered = OutputOrder(frames);
|
||||
var actual = ordered.Select(Md5).ToList();
|
||||
@@ -187,6 +197,19 @@ public sealed class H264ConformanceTests
|
||||
Assert.AreEqual(expected.Count, actual.Count, $"{name}: numero di fotogrammi");
|
||||
}
|
||||
|
||||
/// <summary>The frame MD5s of a riferimento.md5, in output order.</summary>
|
||||
internal static List<string> ReferenceFrames(string name) => ReadReference(Path.Combine(Folder(name), "riferimento.md5"), out _);
|
||||
|
||||
/// <summary>The MD5 of each frame of a stream, in output order.</summary>
|
||||
internal static List<string> FrameMd5s(byte[] stream)
|
||||
{
|
||||
var frames = new List<H264Frame>();
|
||||
var decoder = new H264Decoder();
|
||||
decoder.FrameDecoded += frames.Add;
|
||||
decoder.DecodeAnnexB(stream);
|
||||
return OutputOrder(frames).Select(Md5).ToList();
|
||||
}
|
||||
|
||||
private static List<string> Decode(string stream)
|
||||
{
|
||||
var frames = new List<H264Frame>();
|
||||
|
||||
Reference in new issue
Block a user