Decodificatore H.264 per MVC e per le qualità MGS di SVC (#58)
MVC (Annex H): SPS di sottoinsieme, prefissi NAL 14 e slice NAL 20, un decodificatore per vista con il suo stato, predizione fra viste (riferimenti della stessa unità di accesso in coda alle liste, modifiche 4 e 5). Escono tutte le viste, ciascuna con il suo ViewId; VideoFrameDecoder chiede solo la vista base, che è il video 2D, per le miniature. I flussi MVC della serie non hanno ricostruzione ufficiale: le prove controllano che ogni vista si decodifichi pulita e che la vista base resti identica a quella di H.264 puro. SVC (Annex G): lo strato base sempre; sopra, gli strati di qualità della stessa risoluzione in CAVLC, decodificati uno sull'altro. Un macroblocco intra con base_mode_flag somma il residuo accumulato alla ricostruzione dello strato in cui era intra e per i vicini conta come I_BL. SVCBMT-13 coincide ora con lo strato L2 ufficiale in tutti i 20 fotogrammi. Scalabilità spaziale, CGS e CABAC negli strati di miglioramento non sono ancora scritti: il decodificatore dà lo strato base esatto e dice perché, e SVCBST-19 e SVCBCT-1 restano inconclusivi con l'elenco di ciò che manca. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
da84c79f7e
commit
898e9d60e7
13 files changed
+1754
-59
No files matched your search
@@ -122,11 +122,24 @@ internal sealed class RbspReader
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>One NAL unit, with its RBSP.</summary>
|
||||
/// <summary>
|
||||
/// One NAL unit, with its RBSP. The units of the scalable and multiview extensions (prefix 14, slice extension 20 and
|
||||
/// 21) carry three more header bytes (nal_unit_header_svc_extension or nal_unit_header_mvc_extension, §7.3.1), kept as
|
||||
/// they are in <see cref="Rbsp"/>[1..3]: the emulation prevention bytes are removed only after them.
|
||||
/// </summary>
|
||||
internal readonly record struct NalUnit(int Type, int RefIdc, byte[] Rbsp, int Length)
|
||||
{
|
||||
/// <summary>A reader positioned after the one-byte header.</summary>
|
||||
internal RbspReader Reader() => new(Rbsp, Length, 1);
|
||||
/// <summary>Bytes of the NAL unit header: 4 for the extension units, else 1.</summary>
|
||||
internal int HeaderLength => HasExtensionHeader(Type) && Length >= 4 ? 4 : 1;
|
||||
|
||||
/// <summary>svc_extension_flag of an extension unit: 1 for SVC (Annex G), 0 for MVC (Annex H).</summary>
|
||||
internal bool IsSvc => (Rbsp[1] & 0x80) != 0;
|
||||
|
||||
/// <summary>A reader positioned after the header.</summary>
|
||||
internal RbspReader Reader() => new(Rbsp, Length, HeaderLength);
|
||||
|
||||
/// <summary>NAL unit types whose header has the three extension bytes.</summary>
|
||||
internal static bool HasExtensionHeader(int type) => type is 14 or 20 or 21;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -161,11 +174,14 @@ internal static class NalUnits
|
||||
buffer = new byte[Math.Max(nal.Length + Padding, (buffer?.Length ?? 0) * 2)];
|
||||
}
|
||||
|
||||
// Copied run by run between the 0x000003 patterns (a vectorised search), as the byte-by-byte rule of §7.4.1.
|
||||
// Copied run by run between the 0x000003 patterns (a vectorised search), as the byte-by-byte rule of §7.4.1,
|
||||
// after the header: the three extension bytes of the units 14, 20 and 21 are not part of the RBSP.
|
||||
ReadOnlySpan<byte> pattern = [0, 0, 3];
|
||||
var target = buffer.AsSpan();
|
||||
var count = 0;
|
||||
var rest = nal;
|
||||
var head = NalUnit.HasExtensionHeader(nal[0] & 0x1F) ? Math.Min(4, nal.Length) : 0;
|
||||
nal[..head].CopyTo(target);
|
||||
var count = head;
|
||||
var rest = nal[head..];
|
||||
while (true)
|
||||
{
|
||||
var i = rest.IndexOf(pattern);
|
||||
|
||||
Reference in new issue
Block a user