Skip to content

Commit

Permalink
upgrade to 6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sdcb committed Nov 15, 2023
1 parent 7da6295 commit 83ceade
Show file tree
Hide file tree
Showing 20 changed files with 557 additions and 240 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
using static FParsec.CharParsers;
using System.Text;
using static FParsec.CharParsers;

namespace Sdcb.FFmpeg.AutoGen.ClangMarcroParsers.Units
{
public record NumberExpression(NumberLiteral Number) : IExpression
{
public string Serialize() => Number.String;
public string Serialize()
{
StringBuilder suffixSb = new(4);

if (Number.SuffixChar1 != EOS) suffixSb.Append(Number.SuffixChar1);
if (Number.SuffixChar2 != EOS) suffixSb.Append(Number.SuffixChar2);
if (Number.SuffixChar3 != EOS) suffixSb.Append(Number.SuffixChar3);
if (Number.SuffixChar4 != EOS) suffixSb.Append(Number.SuffixChar4);

string suffix = suffixSb.ToString() switch
{
"ULL" => "UL",
var x => x,
};

return Number.String + suffix;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static (IReadOnlyList<MacroDefinitionBase>, IReadOnlyList<EnumerationDefi
MacroEnumDef.MakeFlags("AV_CODEC_FLAG_"),
MacroEnumDef.MakeFlags("AV_CODEC_FLAG2_"),
//new ("SLICE_FLAG_", "SLICE_FLAG"),
MacroEnumDef.MakeFlagsExcept("AV_CH_", HashSet("AV_CH_LAYOUT_NATIVE")),
MacroEnumDef.MakeFlags("AV_CH_"),
MacroEnumDef.MakeFlags("AV_CODEC_CAP_"),
//new ("FF_MB_DECISION_", "FFMacroblockDecision"),
//new ("FF_CMP_", "FFComparison"),
Expand Down
2 changes: 1 addition & 1 deletion src/Sdcb.FFmpeg.AutoGen/Processors/MacroPostProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ var x when x.Contains("_VERSION_") => "uint",
{ Op: ">" or "<" or "==" or "!=" or "&&" or "||" } => "bool",
_ => (DeduceType(e.Left), DeduceType(e.Right)) switch
{
(string left, string right) => TypeHelper.CalculatePrecedence(left) < TypeHelper.CalculatePrecedence(left) ? left : right,
(string left, string right) => TypeHelper.CalculatePrecedence(left) < TypeHelper.CalculatePrecedence(right) ? left : right,
}
},
CharExpression => "char",
Expand Down
4 changes: 2 additions & 2 deletions src/Sdcb.FFmpeg.NuGetBuilder/PackageInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public static class PackageInfo
{
public const string Version = "6.0.26";
public const string Version = "6.1.0";

public const string Url = $"https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2023-07-03-13-08/ffmpeg-n6.0-26-g3f345ebf21-win64-gpl-shared-6.0.zip";
public const string Url = $"https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-full-shared.7z";
}
26 changes: 17 additions & 9 deletions src/Sdcb.FFmpeg.NuGetBuilder/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// See https://aka.ms/new-console-template for more information
using Sdcb.FFmpeg.NuGetBuilder;
using SharpCompress.Archives;
using System.Diagnostics;
using System.IO.Compression;
using System.Xml;
Expand Down Expand Up @@ -113,19 +114,20 @@ async Task SetupFFmpegBinaries(string solutionDir, string ffmpegBinaryUrl)

Console.WriteLine($"(3 of 4) Extracting {destinationCacheFile}...");
{
using ZipArchive zip = ZipFile.OpenRead(destinationCacheFile);
ExtractPrefixToDest(zip, "/bin/", FFmpegBinDir);
ExtractPrefixToDest(zip, "/include/", FFmpegIncludeDir);
using IArchive archive = ArchiveFactory.Open(destinationCacheFile);
ExtractPrefixToDest(archive.Entries, "/bin", FFmpegBinDir);
ExtractPrefixToDest(archive.Entries, "/include", FFmpegIncludeDir);

static void ExtractPrefixToDest(ZipArchive zip, string prefix, string dest)
static void ExtractPrefixToDest(IEnumerable<IArchiveEntry> entries, string prefix, string dest)
{
string zipPrefix = zip.Entries.Single(x => x.FullName.EndsWith(prefix) && x.Length == 0).FullName;
IArchiveEntry zipPrefixEntry = entries.Single(x => x.Key.EndsWith(prefix) && x.IsDirectory);
string zipPrefix = zipPrefixEntry.Key + "/";
Directory.CreateDirectory(dest);

foreach (ZipArchiveEntry entry in zip.Entries.Where(x => x.FullName.StartsWith(zipPrefix) && x.FullName != zipPrefix))
foreach (IArchiveEntry entry in entries.Where(x => x.Key.StartsWith(zipPrefix) && x.Key != zipPrefix))
{
string path = Path.Combine(dest, entry.FullName.Replace(zipPrefix, ""));
if (entry.Length == 0 && entry.FullName.EndsWith("/"))
string path = Path.Combine(dest, entry.Key.Replace(zipPrefix, ""));
if (entry.IsDirectory)
{
// folder
Console.WriteLine($"Creating folder {path}...");
Expand All @@ -135,7 +137,13 @@ static void ExtractPrefixToDest(ZipArchive zip, string prefix, string dest)
{
// file
Console.WriteLine($"Extract file {path}...");
entry.ExtractToFile(path);
using (var entryStream = entry.OpenEntryStream())
{
using (var fileStream = File.Create(path))
{
entryStream.CopyTo(fileStream);
}
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/Sdcb.FFmpeg.NuGetBuilder/Sdcb.FFmpeg.NuGetBuilder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@
</Content>
</ItemGroup>

<ItemGroup>
<PackageReference Include="SharpCompress" Version="0.34.1" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/Sdcb.FFmpeg/Codecs/Codec.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private Codec(AVCodec* ptr)

/// <summary>
/// <para>original type: AVProfile*</para>
/// <para>array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}</para>
/// <para>array of recognized profiles, or NULL if unknown, array is terminated by {AV_PROFILE_UNKNOWN}</para>
/// <see cref="AVCodec.profiles" />
/// </summary>
public IEnumerable<MediaProfile> Profiles => NativeUtils.ReadSequence(
Expand Down
11 changes: 6 additions & 5 deletions src/Sdcb.FFmpeg/Codecs/CodecContext.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ public AVRational TimeBase
/// <para>For some codecs, the time base is closer to the field rate than the frame rate. Most notably, H.264 and MPEG-2 specify time_base as half of frame duration if no telecine is used ...</para>
/// <see cref="AVCodecContext.ticks_per_frame" />
/// </summary>
[Obsolete("- decoding: Use AVCodecDescriptor.props & AV_CODEC_PROP_FIELDS - encoding: Set AVCodecContext.framerate instead")]
public int TicksPerFrame
{
get => _ptr->ticks_per_frame;
Expand Down Expand Up @@ -694,7 +695,7 @@ public AVColorSpace Colorspace
}

/// <summary>
/// <para>MPEG vs JPEG YUV range. - encoding: Set by user - decoding: Set by libavcodec</para>
/// <para>MPEG vs JPEG YUV range. - encoding: Set by user to override the default output color range value, If not specified, libavcodec sets the color range depending on the output format. - decoding: Set by libavcodec, can be set by the user to propagate the color range to components reading from the decoder context.</para>
/// <see cref="AVCodecContext.color_range" />
/// </summary>
public AVColorRange ColorRange
Expand Down Expand Up @@ -898,7 +899,7 @@ public int MaxQdiff
}

/// <summary>
/// <para>decoder bitstream buffer size - encoding: Set by user. - decoding: unused</para>
/// <para>decoder bitstream buffer size - encoding: Set by user. - decoding: May be set by libavcodec.</para>
/// <see cref="AVCodecContext.rc_buffer_size" />
/// </summary>
public int RcBufferSize
Expand Down Expand Up @@ -1190,7 +1191,7 @@ public int NsseWeight
}

/// <summary>
/// <para>profile - encoding: Set by user. - decoding: Set by libavcodec.</para>
/// <para>profile - encoding: Set by user. - decoding: Set by libavcodec. See the AV_PROFILE_* defines in defs.h.</para>
/// <see cref="AVCodecContext.profile" />
/// </summary>
public int Profile
Expand All @@ -1200,7 +1201,7 @@ public int Profile
}

/// <summary>
/// <para>level - encoding: Set by user. - decoding: Set by libavcodec.</para>
/// <para>Encoding level descriptor. - encoding: Set by user, corresponds to a specific level defined by the codec, usually corresponding to the profile level, if not specified it is set to FF_LEVEL_UNKNOWN. - decoding: Set by libavcodec. See AV_LEVEL_* in defs.h.</para>
/// <see cref="AVCodecContext.level" />
/// </summary>
public int Level
Expand Down Expand Up @@ -1290,7 +1291,7 @@ public AVPixelFormat SwPixelFormat
}

/// <summary>
/// <para>Timebase in which pkt_dts/pts and AVPacket.dts/pts are. - encoding unused. - decoding set by user.</para>
/// <para>Timebase in which pkt_dts/pts and AVPacket.dts/pts are expressed. - encoding: unused. - decoding: set by user.</para>
/// <see cref="AVCodecContext.pkt_timebase" />
/// </summary>
public AVRational PktTimebase
Expand Down
31 changes: 31 additions & 0 deletions src/Sdcb.FFmpeg/Codecs/CodecParameters.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,35 @@ public AVChannelLayout ChLayout
get => _ptr->ch_layout;
set => _ptr->ch_layout = value;
}

/// <summary>
/// <para>Video only. Number of frames per second, for streams with constant frame durations. Should be set to { 0, 1 } when some frames have differing durations or if the value is not known.</para>
/// <see cref="AVCodecParameters.framerate" />
/// </summary>
public AVRational Framerate
{
get => _ptr->framerate;
set => _ptr->framerate = value;
}

/// <summary>
/// <para>original type: AVPacketSideData*</para>
/// <para>Additional data associated with the entire stream.</para>
/// <see cref="AVCodecParameters.coded_side_data" />
/// </summary>
public PacketSideData CodedSideData
{
get => PacketSideData.FromNative(_ptr->coded_side_data);
set => _ptr->coded_side_data = (AVPacketSideData*)value;
}

/// <summary>
/// <para>Amount of entries in coded_side_data.</para>
/// <see cref="AVCodecParameters.nb_coded_side_data" />
/// </summary>
public int NbCodedSideData
{
get => _ptr->nb_coded_side_data;
set => _ptr->nb_coded_side_data = value;
}
}
1 change: 1 addition & 0 deletions src/Sdcb.FFmpeg/Codecs/PacketSideData.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Sdcb.FFmpeg.Codecs;

/// <summary>
/// <para>This structure stores auxiliary information for decoding, presenting, or otherwise processing the coded stream. It is typically exported by demuxers and encoders and can be fed to decoders and muxers either in a per packet basis, or as global side data (applying to the entire coded stream).</para>
/// <see cref="AVPacketSideData" />
/// </summary>
public unsafe partial struct PacketSideData
Expand Down
2 changes: 2 additions & 0 deletions src/Sdcb.FFmpeg/Formats/MediaStream.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ public AVPacket AttachedPic
/// <para>An array of side data that applies to the whole stream (i.e. the container does not allow it to change between packets).</para>
/// <see cref="AVStream.side_data" />
/// </summary>
[Obsolete("use AVStream's \"codecpar side data\".")]
public PacketSideData? SideData
{
get => PacketSideData.FromNativeOrNull(_ptr->side_data);
Expand All @@ -203,6 +204,7 @@ public PacketSideData? SideData
/// <para>The number of elements in the AVStream.side_data array.</para>
/// <see cref="AVStream.nb_side_data" />
/// </summary>
[Obsolete("use AVStream's \"codecpar side data\".")]
public int NbSideData
{
get => _ptr->nb_side_data;
Expand Down
2 changes: 1 addition & 1 deletion src/Sdcb.FFmpeg/Formats/OutputFormat.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private OutputFormat(AVOutputFormat* ptr)

/// <summary>
/// <para>original type: int</para>
/// <para>can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS, AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH, AVFMT_TS_NONSTRICT, AVFMT_TS_NEGATIVE</para>
/// <para>can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS, AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_TS_NONSTRICT, AVFMT_TS_NEGATIVE</para>
/// <see cref="AVOutputFormat.flags" />
/// </summary>
public AVFMT Flags => (AVFMT)_ptr->flags;
Expand Down
88 changes: 0 additions & 88 deletions src/Sdcb.FFmpeg/Raw/FFmpeg.delegates.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,94 +237,6 @@ public unsafe record struct AVCodecContext_get_buffer2_func(IntPtr Pointer)
});
}

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate int AVHWAccel_alloc_frame (AVCodecContext* avctx, AVFrame* frame);
public unsafe record struct AVHWAccel_alloc_frame_func(IntPtr Pointer)
{
public static implicit operator AVHWAccel_alloc_frame_func(AVHWAccel_alloc_frame func) => new(func switch
{
null => IntPtr.Zero,
_ => Marshal.GetFunctionPointerForDelegate(func)
});
}

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate int AVHWAccel_start_frame (AVCodecContext* avctx, byte* buf, uint buf_size);
public unsafe record struct AVHWAccel_start_frame_func(IntPtr Pointer)
{
public static implicit operator AVHWAccel_start_frame_func(AVHWAccel_start_frame func) => new(func switch
{
null => IntPtr.Zero,
_ => Marshal.GetFunctionPointerForDelegate(func)
});
}

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate int AVHWAccel_decode_params (AVCodecContext* avctx, int type, byte* buf, uint buf_size);
public unsafe record struct AVHWAccel_decode_params_func(IntPtr Pointer)
{
public static implicit operator AVHWAccel_decode_params_func(AVHWAccel_decode_params func) => new(func switch
{
null => IntPtr.Zero,
_ => Marshal.GetFunctionPointerForDelegate(func)
});
}

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate int AVHWAccel_decode_slice (AVCodecContext* avctx, byte* buf, uint buf_size);
public unsafe record struct AVHWAccel_decode_slice_func(IntPtr Pointer)
{
public static implicit operator AVHWAccel_decode_slice_func(AVHWAccel_decode_slice func) => new(func switch
{
null => IntPtr.Zero,
_ => Marshal.GetFunctionPointerForDelegate(func)
});
}

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate int AVHWAccel_end_frame (AVCodecContext* avctx);
public unsafe record struct AVHWAccel_end_frame_func(IntPtr Pointer)
{
public static implicit operator AVHWAccel_end_frame_func(AVHWAccel_end_frame func) => new(func switch
{
null => IntPtr.Zero,
_ => Marshal.GetFunctionPointerForDelegate(func)
});
}

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate int AVHWAccel_init (AVCodecContext* avctx);
public unsafe record struct AVHWAccel_init_func(IntPtr Pointer)
{
public static implicit operator AVHWAccel_init_func(AVHWAccel_init func) => new(func switch
{
null => IntPtr.Zero,
_ => Marshal.GetFunctionPointerForDelegate(func)
});
}

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate int AVHWAccel_uninit (AVCodecContext* avctx);
public unsafe record struct AVHWAccel_uninit_func(IntPtr Pointer)
{
public static implicit operator AVHWAccel_uninit_func(AVHWAccel_uninit func) => new(func switch
{
null => IntPtr.Zero,
_ => Marshal.GetFunctionPointerForDelegate(func)
});
}

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate int AVHWAccel_frame_params (AVCodecContext* avctx, AVBufferRef* hw_frames_ctx);
public unsafe record struct AVHWAccel_frame_params_func(IntPtr Pointer)
{
public static implicit operator AVHWAccel_frame_params_func(AVHWAccel_frame_params func) => new(func switch
{
null => IntPtr.Zero,
_ => Marshal.GetFunctionPointerForDelegate(func)
});
}

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate int AVCodecContext_execute (AVCodecContext* c, func_func func, void* arg2, int* ret, int count, int size);
public unsafe record struct AVCodecContext_execute_func(IntPtr Pointer)
Expand Down
Loading

0 comments on commit 83ceade

Please sign in to comment.