HEVC anche nei flussi di programma MPEG: codec e dimensioni dall'SPS
Il lettore MPEG arrivato con il ramo H.264 prendeva le dimensioni solo dall'SPS dell'H.264; un flusso con il tipo 0x24 nella mappa restava HEVC senza dimensioni. H265StreamInfo legge l'SPS di un flusso Annex B (dopo la finestra di conformità), come H264StreamInfo. Senza mappa un HEVC non si riconosce; i campioni non si elencano, quindi niente miniatura, come per l'H.264. Due righe in decisioni.md: questa e le scelte dell'unione (HEIC nella facciata dei codec, fotogrammi H.264 a 16 bit nel convertitore comune). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7e5eccd1ec
commit
281b2e5bc3
6 files changed
+115
-9
No files matched your search
@@ -25,7 +25,7 @@ internal sealed record AsfOptions
|
||||
/// <summary>What a test MPEG program stream holds.</summary>
|
||||
internal sealed record PsOptions
|
||||
{
|
||||
/// <summary>«mpeg2», «mpeg1» or «h264» (then <see cref="Stream"/> gives the pictures).</summary>
|
||||
/// <summary>«mpeg2», «mpeg1», «h264» or «hevc» (for these two <see cref="Stream"/> gives the pictures).</summary>
|
||||
public string Video { get; init; } = "mpeg2";
|
||||
public int Width { get; init; } = 720;
|
||||
public int Height { get; init; } = 576;
|
||||
@@ -358,13 +358,14 @@ internal static class LegacyTestVideos
|
||||
/// An MPEG program stream: a pack header before each picture, a system header, optionally a program stream map, the
|
||||
/// pictures as PES packets of at most 2,000 bytes (the first with its presentation time), and audio frames between.
|
||||
/// MPEG-1 and MPEG-2 pictures are a sequence header (with its extension in MPEG-2), a GOP header, a picture header
|
||||
/// and filler slice bytes; H.264 pictures are the access units of <see cref="PsOptions.Stream"/>.
|
||||
/// and filler slice bytes; H.264 and HEVC pictures are the access units of <see cref="PsOptions.Stream"/>.
|
||||
/// </summary>
|
||||
public static byte[] MpegPs(PsOptions o)
|
||||
{
|
||||
var random = new Random(o.Seed);
|
||||
var frameTicks = o.Video == "h264" ? 3000 : 3600; // 30 or 25 pictures a second
|
||||
var frames = o.Video == "h264" ? o.Stream!.Count : o.Frames;
|
||||
var coded = o.Video is "h264" or "hevc";
|
||||
var frameTicks = coded ? 3000 : 3600; // 30 or 25 pictures a second
|
||||
var frames = coded ? o.Stream!.Count : o.Frames;
|
||||
using var output = new MemoryStream();
|
||||
var audioTime = o.FirstPts;
|
||||
for (var i = 0; i < frames; i++)
|
||||
@@ -376,14 +377,14 @@ internal static class LegacyTestVideos
|
||||
output.Write([0, 0, 1, 0xBB, 0, 12, 0x80, 0x00, 0x01, 0x04, 0xE1, 0xFF, 0xE0, 0xE0, 0xE8, 0xC0, 0xC0, 0x20]);
|
||||
if (o.StreamMap)
|
||||
{
|
||||
var videoType = o.Video switch { "h264" => (byte)0x1B, "mpeg1" => (byte)0x01, _ => (byte)0x02 };
|
||||
var videoType = o.Video switch { "h264" => (byte)0x1B, "hevc" => (byte)0x24, "mpeg1" => (byte)0x01, _ => (byte)0x02 };
|
||||
byte[] map = [videoType, 0xE0, 0, 0, 0x04, 0xC0, 0, 0];
|
||||
byte[] body = [0x80, 0x01, 0, 0, .. U16((ushort)map.Length), .. map, 0, 0, 0, 0];
|
||||
output.Write([0, 0, 1, 0xBC, .. U16((ushort)body.Length), .. body]);
|
||||
}
|
||||
}
|
||||
|
||||
var picture = o.Video == "h264" ? o.Stream!.WithStartCodes(i) : MpegPicture(o, i, random);
|
||||
var picture = coded ? o.Stream!.WithStartCodes(i) : MpegPicture(o, i, random);
|
||||
for (var offset = 0; offset < picture.Length; offset += 2000)
|
||||
{
|
||||
var chunk = picture.AsSpan(offset, Math.Min(2000, picture.Length - offset)).ToArray();
|
||||
|
||||
Reference in new issue
Block a user