mirror of https://github.com/SixLabors/ImageSharp
10 changed files with 416 additions and 330 deletions
@ -1,219 +0,0 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Buffers.Binary; |
|||
using System.CodeDom.Compiler; |
|||
using System.Text; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Heic; |
|||
|
|||
/// <summary>
|
|||
/// Provides constants for 4 Character codes used in HEIC images.
|
|||
/// </summary>
|
|||
[GeneratedCode("T4", null)] |
|||
public static class FourCharacterCode |
|||
{ |
|||
// TODO: Create T4 template for this file
|
|||
|
|||
/// <summary>
|
|||
/// File Type
|
|||
/// </summary>
|
|||
public const uint ftyp = 0x66747970U; |
|||
|
|||
/// <summary>
|
|||
/// Metadata container
|
|||
/// </summary>
|
|||
public const uint meta = 0x6D657461U; |
|||
|
|||
/// <summary>
|
|||
/// Media Data
|
|||
/// </summary>
|
|||
public const uint mdat = 0x6D646174U; |
|||
|
|||
/// <summary>
|
|||
/// Item Information Entry
|
|||
/// </summary>
|
|||
public const uint infe = 0x696E6665U; |
|||
|
|||
/// <summary>
|
|||
/// Item Data
|
|||
/// </summary>
|
|||
public const uint idat = 0x69646174U; |
|||
|
|||
/// <summary>
|
|||
/// Item Location
|
|||
/// </summary>
|
|||
public const uint iloc = 0x696C6F63U; |
|||
|
|||
/// <summary>
|
|||
/// EXIF metadata
|
|||
/// </summary>
|
|||
public const uint Exif = 0x45786966U; |
|||
|
|||
/// <summary>
|
|||
/// Data Reference
|
|||
/// </summary>
|
|||
public const uint dref = 0x64726566U; |
|||
|
|||
/// <summary>
|
|||
/// Primary Item
|
|||
/// </summary>
|
|||
public const uint pitm = 0x7069746DU; |
|||
|
|||
/// <summary>
|
|||
/// Item Spatial Extent
|
|||
/// </summary>
|
|||
public const uint ispe = 0x69737064U; |
|||
|
|||
/// <summary>
|
|||
/// Alternative text
|
|||
/// </summary>
|
|||
public const uint altt = 0; // 'altt'
|
|||
|
|||
/// <summary>
|
|||
/// Colour information
|
|||
/// </summary>
|
|||
public const uint colr = 0; // 'colr'
|
|||
|
|||
/// <summary>
|
|||
/// HVC configuration
|
|||
/// </summary>
|
|||
public const uint hvcC = 0; // 'hvcC'
|
|||
|
|||
/// <summary>
|
|||
/// Image Mirror
|
|||
/// </summary>
|
|||
public const uint imir = 0; // 'imir'
|
|||
|
|||
/// <summary>
|
|||
/// Image Rotation
|
|||
/// </summary>
|
|||
public const uint irot = 0; // 'irot'
|
|||
|
|||
/// <summary>
|
|||
/// Image Scaling
|
|||
/// </summary>
|
|||
public const uint iscl = 0; // 'iscl'
|
|||
|
|||
/// <summary>
|
|||
/// Pixel Aspect Ration
|
|||
/// </summary>
|
|||
public const uint pasp = 0; // 'pasp'
|
|||
|
|||
/// <summary>
|
|||
/// Pixel Information
|
|||
/// </summary>
|
|||
public const uint pixi = 0x70697869U; |
|||
|
|||
/// <summary>
|
|||
/// Reference Location
|
|||
/// </summary>
|
|||
public const uint rloc = 0; // 'rloc
|
|||
|
|||
/// <summary>
|
|||
/// User Description
|
|||
/// </summary>
|
|||
public const uint udes = 0; // 'udes'
|
|||
|
|||
/// <summary>
|
|||
/// Item Property Container
|
|||
/// </summary>
|
|||
public const uint ipco = 0; |
|||
|
|||
/// <summary>
|
|||
/// Item Property Association
|
|||
/// </summary>
|
|||
public const uint ipma = 0; |
|||
|
|||
/// <summary>
|
|||
/// High Efficient Image Coding
|
|||
/// </summary>
|
|||
public const uint heic = 0; |
|||
|
|||
/// <summary>
|
|||
/// High Efficiency Coding tile
|
|||
/// </summary>
|
|||
public const uint hvc1 = 0; |
|||
|
|||
/// <summary>
|
|||
/// Data Information
|
|||
/// </summary>
|
|||
public const uint dinf = 0; |
|||
|
|||
/// <summary>
|
|||
/// Group list
|
|||
/// </summary>
|
|||
public const uint grpl = 0; |
|||
|
|||
/// <summary>
|
|||
/// Handler
|
|||
/// </summary>
|
|||
public const uint hdlr = 0; |
|||
|
|||
/// <summary>
|
|||
/// Item Information
|
|||
/// </summary>
|
|||
public const uint iinf = 0; // 'iinf'
|
|||
|
|||
/// <summary>
|
|||
/// Item Property
|
|||
/// </summary>
|
|||
public const uint iprp = 0; // 'iprp'
|
|||
|
|||
/// <summary>
|
|||
/// Item Protection
|
|||
/// </summary>
|
|||
public const uint ipro = 0; // 'ipro'
|
|||
|
|||
/// <summary>
|
|||
/// Item Reference
|
|||
/// </summary>
|
|||
public const uint iref = 0; // 'iref'
|
|||
|
|||
/// <summary>
|
|||
/// Grid
|
|||
/// </summary>
|
|||
public const uint grid = 0; // 'grid'
|
|||
|
|||
/// <summary>
|
|||
/// Derived Image
|
|||
/// </summary>
|
|||
public const uint dimg = 0; // 'dimg'
|
|||
|
|||
/// <summary>
|
|||
/// Thumbnail
|
|||
/// </summary>
|
|||
public const uint thmb = 0; // 'thmb'
|
|||
|
|||
/// <summary>
|
|||
/// Content Description
|
|||
/// </summary>
|
|||
public const uint cdsc = 0; // 'cdsc'
|
|||
|
|||
/// <summary>
|
|||
/// MIME type
|
|||
/// </summary>
|
|||
public const uint mime = 0; // 'mime'
|
|||
|
|||
/// <summary>
|
|||
/// URI
|
|||
/// </summary>
|
|||
public const uint uri = 0; // 'uri '
|
|||
|
|||
public static uint Parse(string code) |
|||
{ |
|||
if (code.Length != 4) |
|||
{ |
|||
throw new ImageFormatException("Unbale to parse FourCC code of more than 4 characters."); |
|||
} |
|||
Span<byte> span = Encoding.UTF8.GetBytes(code); |
|||
return BinaryPrimitives.ReadUInt32BigEndian(span); |
|||
} |
|||
|
|||
public static string ToString(uint fourcc) |
|||
{ |
|||
Span<byte> span = stackalloc byte[4]; |
|||
BinaryPrimitives.WriteUInt32BigEndian(span, fourcc); |
|||
return Encoding.UTF8.GetString(span); |
|||
} |
|||
} |
|||
@ -0,0 +1,201 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
// <auto-generated />
|
|||
|
|||
using System.CodeDom.Compiler; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Heic; |
|||
|
|||
/// <summary>
|
|||
/// Supported 4 character codes for use in HEIC images.
|
|||
/// </summary>
|
|||
[GeneratedCode("T4", null)] |
|||
public enum Heic4CharCode : uint |
|||
{ |
|||
/// <summary>
|
|||
/// File Type.
|
|||
/// </summary>
|
|||
ftyp = 0x66747970U, |
|||
|
|||
/// <summary>
|
|||
/// Metadata.
|
|||
/// </summary>
|
|||
meta = 0x6D657461U, |
|||
|
|||
/// <summary>
|
|||
/// Media Data.
|
|||
/// </summary>
|
|||
mdat = 0x6D646174U, |
|||
|
|||
/// <summary>
|
|||
/// Item Information Entry.
|
|||
/// </summary>
|
|||
infe = 0x696E6665U, |
|||
|
|||
/// <summary>
|
|||
/// Item Data.
|
|||
/// </summary>
|
|||
idat = 0x69646174U, |
|||
|
|||
/// <summary>
|
|||
/// Item Location.
|
|||
/// </summary>
|
|||
iloc = 0x696C6F63U, |
|||
|
|||
/// <summary>
|
|||
/// EXIF metadata.
|
|||
/// </summary>
|
|||
Exif = 0x45786966U, |
|||
|
|||
/// <summary>
|
|||
/// Data Reference.
|
|||
/// </summary>
|
|||
dref = 0x64726566U, |
|||
|
|||
/// <summary>
|
|||
/// Primary Item.
|
|||
/// </summary>
|
|||
pitm = 0x7069746DU, |
|||
|
|||
/// <summary>
|
|||
/// Item Spatial Extent.
|
|||
/// </summary>
|
|||
ispe = 0x69737065U, |
|||
|
|||
/// <summary>
|
|||
/// Alternative text.
|
|||
/// </summary>
|
|||
altt = 0x616C7474U, |
|||
|
|||
/// <summary>
|
|||
/// Colour information.
|
|||
/// </summary>
|
|||
colr = 0x636F6C72U, |
|||
|
|||
/// <summary>
|
|||
/// HVC configuration.
|
|||
/// </summary>
|
|||
hvcC = 0x68766343U, |
|||
|
|||
/// <summary>
|
|||
/// Image Mirror.
|
|||
/// </summary>
|
|||
imir = 0x696D6972U, |
|||
|
|||
/// <summary>
|
|||
/// Image Rotation.
|
|||
/// </summary>
|
|||
irot = 0x69726F74U, |
|||
|
|||
/// <summary>
|
|||
/// Image Scaling.
|
|||
/// </summary>
|
|||
iscl = 0x6973636CU, |
|||
|
|||
/// <summary>
|
|||
/// Pixel Aspect Ratio.
|
|||
/// </summary>
|
|||
pasp = 0x70617370U, |
|||
|
|||
/// <summary>
|
|||
/// Pixel Information.
|
|||
/// </summary>
|
|||
pixi = 0x70697869U, |
|||
|
|||
/// <summary>
|
|||
/// Reference Location.
|
|||
/// </summary>
|
|||
rloc = 0x726C6F63U, |
|||
|
|||
/// <summary>
|
|||
/// User Description.
|
|||
/// </summary>
|
|||
udes = 0x75646573U, |
|||
|
|||
/// <summary>
|
|||
/// Item Property Container.
|
|||
/// </summary>
|
|||
ipco = 0x6970636FU, |
|||
|
|||
/// <summary>
|
|||
/// Item Property Association.
|
|||
/// </summary>
|
|||
ipma = 0x69706D61U, |
|||
|
|||
/// <summary>
|
|||
/// High Efficient Image Coding.
|
|||
/// </summary>
|
|||
heic = 0x68656963U, |
|||
|
|||
/// <summary>
|
|||
/// High Efficiency Coding tile.
|
|||
/// </summary>
|
|||
hvc1 = 0x68766331U, |
|||
|
|||
/// <summary>
|
|||
/// Data Information.
|
|||
/// </summary>
|
|||
dinf = 0x64696E66U, |
|||
|
|||
/// <summary>
|
|||
/// Group list.
|
|||
/// </summary>
|
|||
grpl = 0x6772706CU, |
|||
|
|||
/// <summary>
|
|||
/// Handler.
|
|||
/// </summary>
|
|||
hdlr = 0x68646C72U, |
|||
|
|||
/// <summary>
|
|||
/// Item Information.
|
|||
/// </summary>
|
|||
iinf = 0x69696E66U, |
|||
|
|||
/// <summary>
|
|||
/// Item Property.
|
|||
/// </summary>
|
|||
iprp = 0x69707270U, |
|||
|
|||
/// <summary>
|
|||
/// Item Protection.
|
|||
/// </summary>
|
|||
ipro = 0x6970726FU, |
|||
|
|||
/// <summary>
|
|||
/// Item Reference.
|
|||
/// </summary>
|
|||
iref = 0x69726566U, |
|||
|
|||
/// <summary>
|
|||
/// Grid.
|
|||
/// </summary>
|
|||
grid = 0x67726964U, |
|||
|
|||
/// <summary>
|
|||
/// Derived Image.
|
|||
/// </summary>
|
|||
dimg = 0x64696D67U, |
|||
|
|||
/// <summary>
|
|||
/// Thumbnail.
|
|||
/// </summary>
|
|||
thmb = 0x74686D62U, |
|||
|
|||
/// <summary>
|
|||
/// Content Description.
|
|||
/// </summary>
|
|||
cdsc = 0x63647363U, |
|||
|
|||
/// <summary>
|
|||
/// MIME type.
|
|||
/// </summary>
|
|||
mime = 0x6D696D65U, |
|||
|
|||
/// <summary>
|
|||
/// URI.
|
|||
/// </summary>
|
|||
uri = 0x75726920U, |
|||
|
|||
} |
|||
@ -0,0 +1,84 @@ |
|||
<#@ template language="C#" #> |
|||
<#@ import namespace="System.Text" #> |
|||
<#@ import namespace="System.Collections.Generic" #> |
|||
// Copyright (c) Six Labors. |
|||
// Licensed under the Six Labors Split License. |
|||
|
|||
// <auto-generated /> |
|||
<# |
|||
var codes = new []{ |
|||
"ftyp", "File Type", |
|||
"meta", "Metadata", |
|||
"mdat", "Media Data", |
|||
"infe", "Item Information Entry", |
|||
"idat", "Item Data", |
|||
"iloc", "Item Location", |
|||
"Exif", "EXIF metadata", |
|||
"dref", "Data Reference", |
|||
"pitm", "Primary Item", |
|||
"ispe", "Item Spatial Extent", |
|||
"altt", "Alternative text", |
|||
"colr", "Colour information", |
|||
"hvcC", "HVC configuration", |
|||
"imir", "Image Mirror", |
|||
"irot", "Image Rotation", |
|||
"iscl", "Image Scaling", |
|||
"pasp", "Pixel Aspect Ratio", |
|||
"pixi", "Pixel Information", |
|||
"rloc", "Reference Location", |
|||
"udes", "User Description", |
|||
"ipco", "Item Property Container", |
|||
"ipma", "Item Property Association", |
|||
"heic", "High Efficient Image Coding", |
|||
"hvc1", "High Efficiency Coding tile", |
|||
"dinf", "Data Information", |
|||
"grpl", "Group list", |
|||
"hdlr", "Handler", |
|||
"iinf", "Item Information", |
|||
"iprp", "Item Property", |
|||
"ipro", "Item Protection", |
|||
"iref", "Item Reference", |
|||
"grid", "Grid", |
|||
"dimg", "Derived Image", |
|||
"thmb", "Thumbnail", |
|||
"cdsc", "Content Description", |
|||
"mime", "MIME type", |
|||
"uri ", "URI", |
|||
}; |
|||
#> |
|||
|
|||
using System.CodeDom.Compiler; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Heic; |
|||
|
|||
/// <summary> |
|||
/// Supported 4 character codes for use in HEIC images. |
|||
/// </summary> |
|||
[GeneratedCode("T4", null)] |
|||
public enum Heic4CharCode : uint |
|||
{ |
|||
<# |
|||
for (int i = 0; i < codes.Length; i += 2) |
|||
{ |
|||
string shortName = codes[i]; |
|||
string longName = codes[i + 1]; |
|||
string hex = Code2Hex(shortName); |
|||
#> |
|||
/// <summary> |
|||
/// <#= longName #>. |
|||
/// </summary> |
|||
<#= shortName #> = <#= hex #>, |
|||
|
|||
<# |
|||
} |
|||
#> |
|||
} |
|||
<#+ |
|||
|
|||
private string Code2Hex(string code) |
|||
{ |
|||
byte[] b = Encoding.ASCII.GetBytes(code); |
|||
return String.Format("0x{0:X2}{1:X2}{2:X2}{3:X2}U", b[0], b[1], b[2], b[3]); |
|||
} |
|||
|
|||
#> |
|||
@ -1,36 +0,0 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Heic; |
|||
|
|||
/// <summary>
|
|||
/// Provides enumeration of supported x265's LAN Unit Types.
|
|||
/// </summary>
|
|||
public enum HeicNalUnitType : byte |
|||
{ |
|||
CODED_SLICE_TRAIL_N = 0, |
|||
CODED_SLICE_TRAIL_R = 1, |
|||
|
|||
CODED_SLICE_TSA_N = 2, |
|||
CODED_SLICE_TSA_R = 3, |
|||
|
|||
CODED_SLICE_STSA_N = 4, |
|||
CODED_SLICE_STSA_R = 5, |
|||
|
|||
CODED_SLICE_RADL_N = 6, |
|||
CODED_SLICE_RADL_R = 7, |
|||
|
|||
CODED_SLICE_RASL_N = 8, |
|||
CODED_SLICE_RASL_R = 9, |
|||
|
|||
VParameterSet = 32, |
|||
SequenceParameterSet = 33, |
|||
PictureParameterSet = 34, |
|||
AccessUnitDelimiter = 35, |
|||
EndOfSequence = 36, |
|||
IsEndOfStream = 37, |
|||
FillerData = 38, |
|||
PrefixSei = 39, |
|||
SuffixSei = 40, |
|||
Invalid = 64, |
|||
} |
|||
Loading…
Reference in new issue