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:
1 parent
8d03ca23de
commit
da84c79f7e
23 files changed
+2016
-607
No files matched your search
@@ -0,0 +1,43 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Febe.Core.Codecs.H264;
|
||||
|
||||
/// <summary>
|
||||
/// The two sample types of the decoder: <see cref="byte"/> for 8-bit video, <see cref="ushort"/> above 8 bits (up to 14,
|
||||
/// High 4:4:4). The planes of a picture are byte arrays of one or two bytes per sample (little-endian, as the official
|
||||
/// reconstructions store them); the prediction, transform and filter code is generic over the sample type, and the JIT
|
||||
/// compiles it once for each, so 8-bit video pays nothing for the wider one.
|
||||
/// </summary>
|
||||
internal static class Samples
|
||||
{
|
||||
/// <summary>The value of a sample.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static int Get<T>(T sample)
|
||||
where T : unmanaged =>
|
||||
typeof(T) == typeof(byte) ? Unsafe.As<T, byte>(ref sample) : Unsafe.As<T, ushort>(ref sample);
|
||||
|
||||
/// <summary>A sample of value <paramref name="value"/>, already within the range of the bit depth.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static T Make<T>(int value)
|
||||
where T : unmanaged
|
||||
{
|
||||
if (typeof(T) == typeof(byte))
|
||||
{
|
||||
var b = (byte)value;
|
||||
return Unsafe.As<byte, T>(ref b);
|
||||
}
|
||||
|
||||
var u = (ushort)value;
|
||||
return Unsafe.As<ushort, T>(ref u);
|
||||
}
|
||||
|
||||
/// <summary>A plane stored as bytes, seen as samples of type <typeparamref name="T"/>.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static Span<T> Plane<T>(byte[] plane)
|
||||
where T : unmanaged => MemoryMarshal.Cast<byte, T>(plane.AsSpan());
|
||||
|
||||
/// <summary>Clip1 of §5.7: <paramref name="value"/> within 0..<paramref name="max"/>.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static int Clip(int value, int max) => value < 0 ? 0 : value > max ? max : value;
|
||||
}
|
||||
Reference in new issue
Block a user