HEVC e HEIF: limiti di memoria contro i file danneggiati e correzioni della revisione (#58)
Un flusso HEVC di pochi byte poteva far allocare gigabyte: ora un SPS il cui buffer supera il MaxDpbSize del livello 6.2 è rifiutato, il buffer non cresce oltre quanto l'SPS dichiara e una sola immagine grigia, riusata, sta per ogni riferimento mancante (il POC viaggia nelle liste). Nei file HEIF ogni immagine deve avere la dimensione del suo ispe, controllata dal decodificatore prima di allocare; i riquadri di una griglia devono coprire l'uscita senza traboccare, i loro byte non superano il file né MaxTotalBytes, e ciò che va storto nei riquadri decodificati in parallelo esce come HeifException. Inoltre: SPS e PPS ripetuti identici dentro un'immagine sono accettati (7.4.2.4.4) e uno cambiato vale dall'immagine dopo; le estensioni SCC sono rifiutate subito; l'intervallo di luma_offset segue l'alta precisione; YCgCo convertito, le altre matrici approssimate e documentate. «Oggetto» e «riquadro» al posto di «elemento» e «tessera» per HEIF (glossario). Righe nuove in decisioni.md: limiti, righe superate, consegne al binario dei documenti, piano per NSIS, Node e tini. Prove nuove su flussi HEVC scritti bit per bit con un codificatore CABAC di prova, su file HEIF costruiti apposta e sulla conversione YCgCo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ac85d1baed
commit
7b10f4ad4c
16 files changed
+1389
-131
No files matched your search
@@ -94,11 +94,11 @@ public sealed partial class H265Decoder
|
||||
{
|
||||
var entry = temp[h.ListModification[list] ? h.ListEntry[list][i] : i];
|
||||
var longTerm = entry >= before + after;
|
||||
var picture = entry < before ? refStCurrBefore[entry] : !longTerm ? refStCurrAfter[entry - before] : refLtCurr[entry - before - after];
|
||||
var (picture, refPoc) = entry < before ? refStCurrBefore[entry] : !longTerm ? refStCurrAfter[entry - before] : refLtCurr[entry - before - after];
|
||||
h.RefPicList[list][i] = picture;
|
||||
h.RefPoc[list][i] = picture.Poc;
|
||||
h.RefPoc[list][i] = refPoc;
|
||||
h.RefIsLongTerm[list][i] = longTerm;
|
||||
h.NoBackwardPred &= picture.Poc <= cur!.Poc;
|
||||
h.NoBackwardPred &= refPoc <= cur!.Poc;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,6 +307,7 @@ public sealed partial class H265Decoder
|
||||
var motion = cur!.Motion;
|
||||
var target = slice.RefPicList[x][refIdx];
|
||||
var targetLongTerm = slice.RefIsLongTerm[x][refIdx];
|
||||
var targetPoc = slice.RefPoc[x][refIdx];
|
||||
var poc = cur.Poc;
|
||||
|
||||
// A: A0 then A1.
|
||||
@@ -328,7 +329,7 @@ public sealed partial class H265Decoder
|
||||
{
|
||||
if (k == 0 ? availableA0 : availableA1)
|
||||
{
|
||||
flagA = ScaledCandidate(motion[Grid(xA0, k == 0 ? yA0 : yA1)], x, target, targetLongTerm, poc, out ax, out ay);
|
||||
flagA = ScaledCandidate(motion[Grid(xA0, k == 0 ? yA0 : yA1)], x, targetPoc, targetLongTerm, poc, out ax, out ay);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,7 +362,7 @@ public sealed partial class H265Decoder
|
||||
{
|
||||
if (k == 0 ? availableB0 : k == 1 ? availableB1 : availableB2)
|
||||
{
|
||||
flagB = ScaledCandidate(motion[Grid(k == 0 ? xB0 : k == 1 ? xB1 : xB2, yB)], x, target, targetLongTerm, poc, out bx, out by);
|
||||
flagB = ScaledCandidate(motion[Grid(k == 0 ? xB0 : k == 1 ? xB1 : xB2, yB)], x, targetPoc, targetLongTerm, poc, out bx, out by);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -434,7 +435,7 @@ public sealed partial class H265Decoder
|
||||
/// The second conditions of §8.5.3.2.7: a neighbour whose reference is long-term exactly when the target is, its
|
||||
/// vector scaled by the POC distances when both are short-term.
|
||||
/// </summary>
|
||||
private bool ScaledCandidate(in MvField n, int x, Picture target, bool targetLongTerm, int poc, out int mx, out int my)
|
||||
private bool ScaledCandidate(in MvField n, int x, int targetPoc, bool targetLongTerm, int poc, out int mx, out int my)
|
||||
{
|
||||
for (var pass = 0; pass < 2; pass++)
|
||||
{
|
||||
@@ -450,7 +451,7 @@ public sealed partial class H265Decoder
|
||||
if (!targetLongTerm)
|
||||
{
|
||||
var td = Math.Clamp(poc - slice.RefPoc[list][refIdx], -128, 127);
|
||||
var tb = Math.Clamp(poc - target.Poc, -128, 127);
|
||||
var tb = Math.Clamp(poc - targetPoc, -128, 127);
|
||||
if (td != 0)
|
||||
{
|
||||
mx = ScaleMv(mx, td, tb);
|
||||
|
||||
Reference in new issue
Block a user