Decodificatore HEVC, seconda parte: predizione inter, tutti i flussi Main e Main 10 coincidono (#58)

La predizione inter scritta dalla norma ITU-T H.265 (§8.3.4, §8.5.3): liste di
riferimento con le modifiche, merge con candidati spaziali, temporale,
bi-predittivi combinati e nulli e livello di merge parallelo, AMVP con la scala
per distanza di POC, TMVP sull'immagine co-locata, interpolazione a 8 prese per
la luma e 4 per il croma, predizione pesata di base ed esplicita. Il deblocking
prende l'intensità 1 anche dal moto; ogni immagine conserva il moto dei blocchi
4x4, la slice di ogni CTB e le liste delle sue slice per chi la usa come
co-locata. Un riferimento mancante diventa un'immagine grigia fuori dal DPB.
I filtri d'interpolazione usano i vettori della BCL (Vector128).

Perché: senza inter nessun video HEVC reale si decodifica. Ora i 136 flussi
Main, Main 10 e Main Still Picture della serie ITU-T H.265.1 danno esattamente
il YUV ufficiale e ogni immagine il suo hash SEI; questo conferma anche il
numero di fotogrammi e gli MD5 scelti per i flussi senza YUV. Restano
inconcludenti solo i 10 flussi RExt, in attesa della decisione di Alberto.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-18 16:18:32 +01:00
1 parent f77b5e4db6
commit d5e1282261
10 files changed
+1219 -125

No files matched your search

+30
View File
@@ -20,6 +20,7 @@ internal sealed class Picture
new ushort[ChromaWidth * ChromaHeight],
new ushort[ChromaWidth * ChromaHeight],
];
Motion = new MvField[((Width + 3) >> 2) * ((Height + 3) >> 2)];
}
/// <summary>The SPS of the picture: a picture of the pool is reused for another SPS of the same size.</summary>
@@ -58,6 +59,15 @@ internal sealed class Picture
/// <summary>Every slice of the picture is an I slice: it does not depend on other pictures.</summary>
internal bool IntraOnly;
/// <summary>The motion of every 4×4 luma block (§8.5.3), kept for the pictures that take this one as collocated (TMVP).</summary>
internal MvField[] Motion { get; }
/// <summary>Index in <see cref="Slices"/> of the slice of each CTB (raster order), −1 where none was decoded.</summary>
internal int[] CtbSlice = [];
/// <summary>The independent slice segment headers of the picture, with their reference picture lists.</summary>
internal List<SliceHeader> Slices { get; } = [];
internal bool IsReference => ShortTerm || LongTerm;
internal int Stride(int cIdx) => cIdx == 0 ? Width : ChromaWidth;
@@ -98,6 +108,26 @@ internal sealed class Picture
}
}
/// <summary>
/// The motion of a prediction block: a motion vector in quarter luma samples and a reference index for each list, the
/// index −1 when the list is not used (both −1 for an intra block). An unused list always has a zero vector, so that
/// equal motion means equal fields.
/// </summary>
internal struct MvField
{
internal static readonly MvField Intra = new() { Ref0 = -1, Ref1 = -1 };
internal short X0;
internal short Y0;
internal short X1;
internal short Y1;
internal sbyte Ref0;
internal sbyte Ref1;
internal readonly bool SameAs(in MvField other) =>
X0 == other.X0 && Y0 == other.Y0 && X1 == other.X1 && Y1 == other.Y1 && Ref0 == other.Ref0 && Ref1 == other.Ref1;
}
/// <summary>A decoded HEVC frame, cropped to the conformance window, with one 16-bit value per sample.</summary>
/// <param name="Width">Luma width after cropping.</param>
/// <param name="Height">Luma height after cropping.</param>