Decodificatore H.264 per i formati dei profili High: 4:2:2, 4:4:4, piani separati, 4:0:0, da 8 a 14 bit, senza perdita (#58)

Il decodificatore rifiutava tutto ciò che non era 4:2:0 a 8 bit, così i video
4:2:2, monocromatici o a 10 bit restavano senza miniatura. Ora i campioni stanno
in piani di uno o due byte e i nuclei di predizione, trasformata e filtro sono
generici su byte e ushort, specializzati dal JIT: a 8 bit i tempi restano quelli
di prima (misurati sui flussi di conformità, 100,4%).

- 4:2:2: DC della crominanza 2x4 con qP + 3, tabelle CAVLC di nC -2, contesti
  CABAC per NumC8x8, predizione intra 8x16, vettore verticale a piena
  risoluzione, bordi della crominanza alle righe 4, 8 e 12.
- 4:4:4: Cb e Cr codificati come la luminanza in CAVLC, con le loro matrici
  e il filtro della luminanza; separate_colour_plane_flag come tre immagini
  monocromatiche con i propri dati di macroblocco e di moto.
- 4:0:0 senza sintassi della crominanza; in uscita la crominanza 4:2:0 al
  valore medio, come il file ufficiale.
- Profondità da 8 a 14 bit: QP da -QpBdOffset, soglie del deblocking e scarti
  dei pesi scalati; uscita a due byte little-endian.
- Senza perdita: qpprime_y_zero_transform_bypass_flag a QP'Y 0, con la DPCM
  della predizione intra orizzontale e verticale.
- VideoFrameDecoder converte in RGB alla profondità e al campionamento del
  fotogramma.

I dieci flussi 4:2:2 (8 e 10 bit) e 4:0:0 della serie ITU-T coincidono con la
ricostruzione ufficiale e passano fra i verificati. 4:4:4, piani separati,
senza perdita e 11-14 bit si provano con flussi sintetici (H264FormatTests).
Il CABAC in 4:4:4 con i piani insieme si rifiuta: mancano i contesti 460-1023.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-18 17:31:12 +01:00
1 parent 8d03ca23de
commit da84c79f7e
23 files changed
+2016 -607

No files matched your search

@@ -9,12 +9,14 @@ namespace Febe.Tests.Codecs.H264;
/// 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), 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
/// (FM1_BT_B, FM1_FT_E, FM2_SVA_C), SP slices (sp1_bt_a, sp2_bt_b; sp2 with the deblocking filter on), 4:2:2 at 8 and 10
/// bits with CABAC and CAVLC (Hi422FR10–15_SONY_A, FREXT2/3_TANDBERG_A) and monochrome 4:0:0 (HPCAMOLQ_BRCM_B,
/// HPCVMOLQ_BRCM_B). 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
/// handle yet (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>
@@ -56,6 +58,16 @@ public sealed class H264ConformanceTests
[DataRow("FM1_BT_B")]
[DataRow("sp1_bt_a")]
[DataRow("sp2_bt_b")]
[DataRow("Hi422FR10_SONY_A")]
[DataRow("Hi422FR11_SONY_A")]
[DataRow("Hi422FR12_SONY_A")]
[DataRow("Hi422FR13_SONY_A")]
[DataRow("Hi422FR14_SONY_A")]
[DataRow("Hi422FR15_SONY_A")]
[DataRow("FREXT2_TANDBERG_A")]
[DataRow("FREXT3_TANDBERG_A")]
[DataRow("HPCAMOLQ_BRCM_B")]
[DataRow("HPCVMOLQ_BRCM_B")]
public void FramesMatchTheReference(string name) => AssertMatches(name, "riferimento.md5");
[TestMethod]
@@ -70,16 +82,6 @@ public sealed class H264ConformanceTests
}
[TestMethod]
[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)")]
[DataRow("Hi422FR13_SONY_A", "4:2:2 a 10 bit, solo slice I (CABAC)")]
[DataRow("Hi422FR14_SONY_A", "4:2:2 a 10 bit con slice P (CABAC)")]
[DataRow("Hi422FR15_SONY_A", "4:2:2 a 10 bit con slice B (CABAC)")]
[DataRow("FREXT2_TANDBERG_A", "4:2:2 a 8 bit con slice P (CAVLC)")]
[DataRow("FREXT3_TANDBERG_A", "4:2:2 a 8 bit con slice B (CAVLC)")]
[DataRow("HPCAMOLQ_BRCM_B", "monocromatico 4:0:0 (CABAC, High)")]
[DataRow("HPCVMOLQ_BRCM_B", "monocromatico 4:0:0 (CAVLC, High)")]
[DataRow("SVCBMT-13", "SVC, qualità MGS e scalabilità temporale (strato L2)")]
[DataRow("SVCBST-19", "SVC, scalabilità spaziale e temporale (strato L1, 640×480)")]
[DataRow("SVCBCT-1", "SVC, qualità CGS e scalabilità temporale (strato L1)")]
@@ -154,7 +156,7 @@ public sealed class H264ConformanceTests
{
var expected = all.Single(f => f.DecodeIndex == frame.DecodeIndex);
Assert.AreEqual((expected.Poc, expected.Period), (frame.Poc, frame.Period), $"{name}: ordine del fotogramma {frame.DecodeIndex}");
CollectionAssert.AreEqual(expected.ToI420(), frame.ToI420(), $"{name}: fotogramma {frame.DecodeIndex}");
CollectionAssert.AreEqual(expected.ToPlanar(), frame.ToPlanar(), $"{name}: fotogramma {frame.DecodeIndex}");
}
}
@@ -222,7 +224,7 @@ public sealed class H264ConformanceTests
private static List<H264Frame> OutputOrder(List<H264Frame> frames) =>
frames.OrderBy(f => f.Period).ThenBy(f => f.Poc).ThenBy(f => f.DecodeIndex).ToList();
private static string Md5(H264Frame frame) => Convert.ToHexStringLower(MD5.HashData(frame.ToI420()));
private static string Md5(H264Frame frame) => Convert.ToHexStringLower(MD5.HashData(frame.ToPlanar()));
/// <summary>
/// The frame MD5s of a riferimento.md5, in output order, and the number of frames its first line declares (0 when