From 7e3c642cbceeec216a8d7a279a01de786f146f6f Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Sat, 13 Mar 2021 02:00:25 +0800 Subject: [PATCH] Upgrade cppsharp / run dotnet format after codegen (#156) * upgrade cppsharp to latest * dotnet format * remove commented code and // todo * ci * ci --- .github/workflows/main.yml | 13 +- .travis.yml | 4 +- .../CliOptions.cs | 4 +- ...peg.AutoGen.CppSharpUnsafeGenerator.csproj | 6 +- .../FunctionExportHelper.cs | 2 +- .../Generator.cs | 20 +- .../Processors/EnumerationProcessor.cs | 6 +- .../Processors/FunctionProcessor.cs | 12 +- .../Processors/MacroPostProcessor.cs | 36 ++-- .../Processors/StructureProcessor.cs | 14 +- .../Processors/TypeHelper.cs | 2 +- .../Program.cs | 36 +++- .../Writer.cs | 10 +- FFmpeg.AutoGen.Example/FFmpegHelper.cs | 4 +- .../H264VideoStreamEncoder.cs | 4 +- FFmpeg.AutoGen.Example/MediaDecoder.cs | 2 +- FFmpeg.AutoGen.Example/Program.cs | 18 +- FFmpeg.AutoGen.Example/VideoFrameConverter.cs | 12 +- FFmpeg.AutoGen.Example/VideoStreamDecoder.cs | 6 +- FFmpeg.AutoGen/FFmpeg.functions.export.g.cs | 24 +-- FFmpeg.AutoGen/FFmpeg.macros.g.cs | 172 ++++++++++++------ FFmpeg.AutoGen/FFmpeg.structs.g.cs | 8 +- FFmpeg.AutoGen/FFmpeg.structs.incomplete.g.cs | 2 +- FFmpeg.AutoGen/Native/LibraryLoader.cs | 2 +- 24 files changed, 260 insertions(+), 159 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index deb15089..4a2916d4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,12 +14,10 @@ jobs: os: [ubuntu-latest, windows-latest] steps: - uses: actions/checkout@v2 - - name: Build Library + - name: Library Build & Test run: | - dotnet build -c Release FFmpeg.AutoGen - - name: Build Example - run: | - dotnet build -c Release FFmpeg.AutoGen.Example + dotnet build -c Release + dotnet test -c Release - name: Build Redist windows x64 if: matrix.os == 'windows-latest' run: | @@ -39,3 +37,8 @@ jobs: with: path: FFmpeg.AutoGen.Redist.windows.x64/bin/Release/*.nupkg if-no-files-found: error + - name: Codegen Build & Test + if: matrix.os == 'windows-latest' + run: | + dotnet run -c Release -p FFmpeg.AutoGen.CppSharpUnsafeGenerator -- -i FFmpeg + dotnet build FFmpeg.AutoGen diff --git a/.travis.yml b/.travis.yml index 911c9e34..28030b48 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,5 +3,5 @@ language: csharp mono: none dotnet: 5.0.200 script: - - dotnet build -c Release ./FFmpeg.AutoGen - - dotnet build -c Release ./FFmpeg.AutoGen.Example + - dotnet build -c Release + - dotnet test -c Release diff --git a/FFmpeg.AutoGen.CppSharpUnsafeGenerator/CliOptions.cs b/FFmpeg.AutoGen.CppSharpUnsafeGenerator/CliOptions.cs index 26419e48..bb83a979 100644 --- a/FFmpeg.AutoGen.CppSharpUnsafeGenerator/CliOptions.cs +++ b/FFmpeg.AutoGen.CppSharpUnsafeGenerator/CliOptions.cs @@ -57,12 +57,12 @@ public static CliOptions ParseArgumentsStrict(string[] args) private void Normalize() { // Support for the original path setup - const string solutionDir = "../../../../../"; + string solutionDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../../../"); if (string.IsNullOrWhiteSpace(FFmpegDir) && string.IsNullOrWhiteSpace(FFmpegIncludesDir) && string.IsNullOrWhiteSpace(FFmpegBinDir)) - FFmpegDir = Path.Combine(solutionDir, "ffmpeg"); + FFmpegDir = Path.Combine(solutionDir, "FFmpeg"); if (string.IsNullOrWhiteSpace(OutputDir)) OutputDir = Path.Combine(solutionDir, "FFmpeg.AutoGen/"); diff --git a/FFmpeg.AutoGen.CppSharpUnsafeGenerator/FFmpeg.AutoGen.CppSharpUnsafeGenerator.csproj b/FFmpeg.AutoGen.CppSharpUnsafeGenerator/FFmpeg.AutoGen.CppSharpUnsafeGenerator.csproj index c05f38a7..eba21d4a 100644 --- a/FFmpeg.AutoGen.CppSharpUnsafeGenerator/FFmpeg.AutoGen.CppSharpUnsafeGenerator.csproj +++ b/FFmpeg.AutoGen.CppSharpUnsafeGenerator/FFmpeg.AutoGen.CppSharpUnsafeGenerator.csproj @@ -2,14 +2,14 @@ Exe - net472 + net5 AnyCPU;x64 - + - \ No newline at end of file + diff --git a/FFmpeg.AutoGen.CppSharpUnsafeGenerator/FunctionExportHelper.cs b/FFmpeg.AutoGen.CppSharpUnsafeGenerator/FunctionExportHelper.cs index 52446347..0bfd5db8 100644 --- a/FFmpeg.AutoGen.CppSharpUnsafeGenerator/FunctionExportHelper.cs +++ b/FFmpeg.AutoGen.CppSharpUnsafeGenerator/FunctionExportHelper.cs @@ -19,7 +19,7 @@ public static IEnumerable LoadFunctionExports(string path) var libraryVersion = int.Parse(libraryNameParts[1]); var exports = GetExports(libraryPath); - foreach (var export in exports) yield return new FunctionExport { LibraryName = libraryName, LibraryVersion = libraryVersion, Name = export}; + foreach (var export in exports) yield return new FunctionExport { LibraryName = libraryName, LibraryVersion = libraryVersion, Name = export }; } } diff --git a/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Generator.cs b/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Generator.cs index 7f730ec5..9017840d 100644 --- a/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Generator.cs +++ b/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Generator.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Runtime.InteropServices; using CppSharp; using CppSharp.AST; using CppSharp.Parser; @@ -56,7 +57,7 @@ public void WriteLibraries(string combine) "public static Dictionary LibraryVersionMap = new Dictionary"); using (writer.BeginBlock(true)) { - var libraryVersionMap = Exports.Select(x => new {x.LibraryName, x.LibraryVersion}).Distinct() + var libraryVersionMap = Exports.Select(x => new { x.LibraryName, x.LibraryVersion }).Distinct() .ToDictionary(x => x.LibraryName, x => x.LibraryVersion); foreach (var pair in libraryVersionMap) writer.WriteLine($"{{\"{pair.Key}\", {pair.Value}}},"); } @@ -208,16 +209,21 @@ private ASTContext ParseInternal(string[] sourceFiles) LanguageVersion = LanguageVersion.C99_GNU }; - parserOptions.SetupMSVC(VisualStudioVersion.Latest); + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + parserOptions.SetupMSVC(VisualStudioVersion.Latest); + } + else + { + throw new PlatformNotSupportedException(); + } foreach (var includeDir in IncludeDirs) parserOptions.AddIncludeDirs(includeDir); foreach (var define in Defines) parserOptions.AddDefines(define); - - var clangParser = new ClangParser(new CppSharp.Parser.AST.ASTContext()); - clangParser.SourcesParsed += OnSourceFileParsed; - clangParser.ParseSourceFiles(sourceFiles, parserOptions); - return ClangParser.ConvertASTContext(clangParser.ASTContext); + var result = ClangParser.ParseSourceFiles(sourceFiles, parserOptions); + OnSourceFileParsed(sourceFiles, result); + return ClangParser.ConvertASTContext(parserOptions.ASTContext); } private void OnSourceFileParsed(IEnumerable files, ParserResult result) diff --git a/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Processors/EnumerationProcessor.cs b/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Processors/EnumerationProcessor.cs index 14caad54..675abd68 100644 --- a/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Processors/EnumerationProcessor.cs +++ b/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Processors/EnumerationProcessor.cs @@ -57,11 +57,11 @@ private static object ConvertValue(ulong value, PrimitiveType primitiveType) switch (primitiveType) { case PrimitiveType.Int: - return (int) value; + return (int)value; case PrimitiveType.UInt: - return (uint) value; + return (uint)value; case PrimitiveType.Long: - return (long) value; + return (long)value; case PrimitiveType.ULong: return value; default: diff --git a/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Processors/FunctionProcessor.cs b/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Processors/FunctionProcessor.cs index 66fb748b..6f496da7 100644 --- a/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Processors/FunctionProcessor.cs +++ b/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Processors/FunctionProcessor.cs @@ -117,9 +117,9 @@ private TypeDefinition GetReturnTypeName(Type type, string name) } }; case PrimitiveType.Void: - return new TypeDefinition {Name = "void*"}; + return new TypeDefinition { Name = "void*" }; default: - return new TypeDefinition {Name = TypeHelper.GetTypeName(type)}; + return new TypeDefinition { Name = TypeHelper.GetTypeName(type) }; } } @@ -135,11 +135,11 @@ private TypeDefinition GetParameterType(Type type, string name) switch (builtinType.Type) { case PrimitiveType.Char: - return new TypeDefinition {Name = "string", Attributes = new[] {MarshalAsUtf8Macros}}; + return new TypeDefinition { Name = "string", Attributes = new[] { MarshalAsUtf8Macros } }; case PrimitiveType.Void: - return new TypeDefinition {Name = "void*"}; + return new TypeDefinition { Name = "void*" }; default: - return new TypeDefinition {Name = TypeHelper.GetTypeName(type)}; + return new TypeDefinition { Name = TypeHelper.GetTypeName(type) }; } } @@ -149,7 +149,7 @@ private TypeDefinition GetParameterType(Type type, string name) arrayType.Type is PointerType arrayPointerType && !(arrayPointerType.Pointee is BuiltinType || arrayPointerType.Pointee is TypedefType typedefType && typedefType.Declaration.Type is BuiltinType)) - return new TypeDefinition {Name = TypeHelper.GetTypeName(arrayPointerType) + "*"}; + return new TypeDefinition { Name = TypeHelper.GetTypeName(arrayPointerType) + "*" }; return _context.StructureProcessor.GetTypeDefinition(type, name); } diff --git a/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Processors/MacroPostProcessor.cs b/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Processors/MacroPostProcessor.cs index 30ee398a..ea084395 100644 --- a/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Processors/MacroPostProcessor.cs +++ b/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Processors/MacroPostProcessor.cs @@ -21,18 +21,22 @@ internal class MacroPostProcessor public void Process(IReadOnlyList macros) { - _macroExpressionMap = macros.ToDictionary(x => x.Name, x => + _macroExpressionMap = new Dictionary(macros.Count); + foreach (var x in macros) { try { - return Parser.Parse(x.Expression); + _macroExpressionMap.Add(x.Name, Parser.Parse(x.Expression)); } catch (NotSupportedException) { Trace.TraceError($"Cannot parse macro expression: {x.Expression}"); - return null; } - }); + catch (Exception e) + { + Trace.TraceError($"Cannot parse macro expression: {x.Expression}: {e.Message}"); + } + } foreach (var macro in macros) Process(macro); } @@ -52,7 +56,7 @@ private void Process(MacroDefinition macro) macro.Content = $"{macro.Name} = {macro.Expression}"; macro.Expression = Serialize(expression); macro.IsConst = IsConst(expression); - macro.IsValid = true; + macro.IsValid = !typeOrAlias.IsAlias || _astProcessor.TypeAliases.ContainsKey(typeOrAlias.Alias); } private static string CleanUp(string expression) @@ -95,19 +99,19 @@ private IExpression Rewrite(IExpression expression) switch (expression) { case BinaryExpression e: - { - var left = Rewrite(e.Left); - var right = Rewrite(e.Right); - var leftType = DeduceType(left); - var rightType = DeduceType(right); - if (e.OperationType.IsBitwise() && leftType.Precedence != rightType.Precedence) { - var toType = leftType.Precedence > rightType.Precedence ? rightType : leftType; - if (leftType != toType) left = new CastExpression(toType.ToString(), left); - if (rightType != toType) right = new CastExpression(toType.ToString(), right); + var left = Rewrite(e.Left); + var right = Rewrite(e.Right); + var leftType = DeduceType(left); + var rightType = DeduceType(right); + if (e.OperationType.IsBitwise() && leftType.Precedence != rightType.Precedence) + { + var toType = leftType.Precedence > rightType.Precedence ? rightType : leftType; + if (leftType != toType) left = new CastExpression(toType.ToString(), left); + if (rightType != toType) right = new CastExpression(toType.ToString(), right); + } + return new BinaryExpression(left, e.OperationType, right); } - return new BinaryExpression(left, e.OperationType, right); - } case UnaryExpression e: return new UnaryExpression(e.OperationType, Rewrite(e.Operand)); case CastExpression e: return new CastExpression(e.TargetType, Rewrite(e.Operand)); case CallExpression e: return new CallExpression(e.Name, e.Arguments.Select(Rewrite)); diff --git a/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Processors/StructureProcessor.cs b/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Processors/StructureProcessor.cs index e5a01866..87541708 100644 --- a/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Processors/StructureProcessor.cs +++ b/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Processors/StructureProcessor.cs @@ -103,7 +103,7 @@ internal TypeDefinition GetTypeDefinition(Type type, string name = null) case PointerType pointerType: return GetTypeDefinition(pointerType, name); default: - return new TypeDefinition {Name = TypeHelper.GetTypeName(type)}; + return new TypeDefinition { Name = TypeHelper.GetTypeName(type) }; } } @@ -132,7 +132,7 @@ private static StructureField GetBitField(IEnumerable names, long bitCou return new StructureField { Name = fieldName, - FieldType = new TypeDefinition {Name = fieldType}, + FieldType = new TypeDefinition { Name = fieldType }, Content = string.Join(" ", comments.Where(x => !string.IsNullOrWhiteSpace(x)).Select(x => x.Trim())) }; } @@ -161,14 +161,14 @@ private TypeDefinition GetFieldTypeForNestedDeclaration(Declaration declaration, if (@class != null) { MakeDefinition(@class, typeName); - return new TypeDefinition {Name = typeName}; + return new TypeDefinition { Name = typeName }; } var @enum = declaration as Enumeration; if (@enum != null) { _context.EnumerationProcessor.MakeDefinition(@enum, typeName); - return new TypeDefinition {Name = typeName}; + return new TypeDefinition { Name = typeName }; } throw new NotSupportedException(); @@ -177,7 +177,7 @@ private TypeDefinition GetFieldTypeForNestedDeclaration(Declaration declaration, private TypeDefinition GetFieldTypeForFixedArray(ArrayType arrayType) { - var fixedSize = (int) arrayType.Size; + var fixedSize = (int)arrayType.Size; var elementType = arrayType.Type; var elementTypeDefinition = GetTypeDefinition(elementType); @@ -186,7 +186,7 @@ private TypeDefinition GetFieldTypeForFixedArray(ArrayType arrayType) if (elementType.IsPointer()) name = TypeHelper.GetTypeName(elementType.GetPointee()) + "_ptrArray" + fixedSize; if (elementType is ArrayType) - name = TypeHelper.GetTypeName(((ArrayType) elementType).Type) + "_arrayOfArray" + fixedSize; + name = TypeHelper.GetTypeName(((ArrayType)elementType).Type) + "_arrayOfArray" + fixedSize; if (!_context.IsKnownUnitName(name)) { @@ -200,7 +200,7 @@ private TypeDefinition GetFieldTypeForFixedArray(ArrayType arrayType) _context.AddUnit(fixedArray); } - return new TypeDefinition {Name = name, ByReference = !arrayType.QualifiedType.Qualifiers.IsConst}; + return new TypeDefinition { Name = name, ByReference = !arrayType.QualifiedType.Qualifiers.IsConst }; } } } \ No newline at end of file diff --git a/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Processors/TypeHelper.cs b/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Processors/TypeHelper.cs index 64eef7a4..f4566223 100644 --- a/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Processors/TypeHelper.cs +++ b/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Processors/TypeHelper.cs @@ -31,7 +31,7 @@ private static string GetTypeName(TypedefType type) return type.Declaration.Name; } } - + private static string GetTypeName(PrimitiveType type) { switch (type) diff --git a/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Program.cs b/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Program.cs index ce88cae6..0d821799 100644 --- a/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Program.cs +++ b/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Program.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.IO; using System.Linq; using FFmpeg.AutoGen.CppSharpUnsafeGenerator.Processors; @@ -41,11 +42,11 @@ internal static void Main(string[] args) astProcessor.WellKnownMaros.Add("AV_VERSION_INT", typeof(int)); astProcessor.WellKnownMaros.Add("AV_VERSION", typeof(string)); - var defines = new[] {"__STDC_CONSTANT_MACROS"}; + var defines = new[] { "__STDC_CONSTANT_MACROS" }; var g = new Generator(astProcessor) { - IncludeDirs = new[] {options.FFmpegIncludesDir}, + IncludeDirs = new[] { options.FFmpegIncludesDir }, Defines = defines, Exports = exports, Namespace = options.Namespace, @@ -95,6 +96,35 @@ internal static void Main(string[] args) g.WriteIncompleteStructures(Path.Combine(options.OutputDir, "FFmpeg.structs.incomplete.g.cs")); g.WriteExportFunctions(Path.Combine(options.OutputDir, "FFmpeg.functions.export.g.cs")); g.WriteInlineFunctions(Path.Combine(options.OutputDir, "FFmpeg.functions.inline.g.cs")); + + // Run latest dotnet format + { + using var p = Process.Start(new ProcessStartInfo + { + FileName = "dotnet", + Arguments = "tool install --global dotnet-format", + WorkingDirectory = options.OutputDir, + }); + p.WaitForExit(); + } + { + using var p = Process.Start(new ProcessStartInfo + { + FileName = "dotnet", + Arguments = "tool update --global dotnet-format", + WorkingDirectory = options.OutputDir, + }); + p.WaitForExit(); + } + { + using var p = Process.Start(new ProcessStartInfo + { + FileName = "dotnet", + Arguments = "format", + WorkingDirectory = options.OutputDir, + }); + p.WaitForExit(); + } } } -} \ No newline at end of file +} diff --git a/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Writer.cs b/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Writer.cs index 8db33b3a..ac88dbc8 100644 --- a/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Writer.cs +++ b/FFmpeg.AutoGen.CppSharpUnsafeGenerator/Writer.cs @@ -20,11 +20,13 @@ public void WriteMacro(MacroDefinition macro) if (macro.IsValid) { WriteSummary(macro); - var constOrStatic = macro.IsConst ? "const" : "static"; + var constOrStatic = macro.IsConst ? "const" : "static readonly"; WriteLine($"public {constOrStatic} {macro.TypeName} {macro.Name} = {macro.Expression};"); } else + { WriteLine($"// public static {macro.Name} = {macro.Expression};"); + } } public void WriteEnumeration(EnumerationDefinition enumeration) @@ -112,8 +114,8 @@ public void WriteFunction(InlineFunctionDefinition function) WriteObsoletion(function); WriteLine($"public static {function.ReturnType.Name} {function.Name}({parameters})"); - - var lines = function.Body.Split(new [] {'\n', '\r'}, StringSplitOptions.RemoveEmptyEntries).ToList(); + + var lines = function.Body.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries).ToList(); lines.ForEach(WriteLineWithoutIntent); WriteLine($"// original body hash: {function.OriginalBodyHash}"); WriteLine(); @@ -284,7 +286,7 @@ private void WriteReturnComment(string content) { if (!string.IsNullOrWhiteSpace(content)) WriteLine($"/// {SecurityElement.Escape(content.Trim())}"); } - + private void WriteObsoletion(IObsoletionAware obsoletionAware) { var obsoletion = obsoletionAware.Obsoletion; diff --git a/FFmpeg.AutoGen.Example/FFmpegHelper.cs b/FFmpeg.AutoGen.Example/FFmpegHelper.cs index 69f43fa3..3b9995d9 100644 --- a/FFmpeg.AutoGen.Example/FFmpegHelper.cs +++ b/FFmpeg.AutoGen.Example/FFmpegHelper.cs @@ -9,8 +9,8 @@ public static unsafe string av_strerror(int error) { var bufferSize = 1024; var buffer = stackalloc byte[bufferSize]; - ffmpeg.av_strerror(error, buffer, (ulong) bufferSize); - var message = Marshal.PtrToStringAnsi((IntPtr) buffer); + ffmpeg.av_strerror(error, buffer, (ulong)bufferSize); + var message = Marshal.PtrToStringAnsi((IntPtr)buffer); return message; } diff --git a/FFmpeg.AutoGen.Example/H264VideoStreamEncoder.cs b/FFmpeg.AutoGen.Example/H264VideoStreamEncoder.cs index db62b6c8..8eb6888f 100644 --- a/FFmpeg.AutoGen.Example/H264VideoStreamEncoder.cs +++ b/FFmpeg.AutoGen.Example/H264VideoStreamEncoder.cs @@ -28,7 +28,7 @@ public H264VideoStreamEncoder(Stream stream, int fps, Size frameSize) _pCodecContext = ffmpeg.avcodec_alloc_context3(_pCodec); _pCodecContext->width = frameSize.Width; _pCodecContext->height = frameSize.Height; - _pCodecContext->time_base = new AVRational {num = 1, den = fps}; + _pCodecContext->time_base = new AVRational { num = 1, den = fps }; _pCodecContext->pix_fmt = AVPixelFormat.AV_PIX_FMT_YUV420P; ffmpeg.av_opt_set(_pCodecContext->priv_data, "preset", "veryslow", 0); @@ -51,7 +51,7 @@ public void Dispose() public void Encode(AVFrame frame) { - if (frame.format != (int) _pCodecContext->pix_fmt) throw new ArgumentException("Invalid pixel format.", nameof(frame)); + if (frame.format != (int)_pCodecContext->pix_fmt) throw new ArgumentException("Invalid pixel format.", nameof(frame)); if (frame.width != _frameSize.Width) throw new ArgumentException("Invalid width.", nameof(frame)); if (frame.height != _frameSize.Height) throw new ArgumentException("Invalid height.", nameof(frame)); if (frame.linesize[0] < _linesizeY) throw new ArgumentException("Invalid Y linesize.", nameof(frame)); diff --git a/FFmpeg.AutoGen.Example/MediaDecoder.cs b/FFmpeg.AutoGen.Example/MediaDecoder.cs index eda454b6..e410f92e 100644 --- a/FFmpeg.AutoGen.Example/MediaDecoder.cs +++ b/FFmpeg.AutoGen.Example/MediaDecoder.cs @@ -22,7 +22,7 @@ public VideoConverter(Size sourceSize, AVPixelFormat sourcePixelFormat, var dstData = new byte_ptrArray4(); var dstLinesize = new int_array4(); - ffmpeg.av_image_fill_arrays(ref dstData, ref dstLinesize, (byte*) convertedFrameBufferPtr, destinationPixelFormat, destinationSize.Width, destinationSize.Height, 1); + ffmpeg.av_image_fill_arrays(ref dstData, ref dstLinesize, (byte*)convertedFrameBufferPtr, destinationPixelFormat, destinationSize.Width, destinationSize.Height, 1); } public void Dispose() diff --git a/FFmpeg.AutoGen.Example/Program.cs b/FFmpeg.AutoGen.Example/Program.cs index 48ef31a0..92eb92aa 100644 --- a/FFmpeg.AutoGen.Example/Program.cs +++ b/FFmpeg.AutoGen.Example/Program.cs @@ -16,9 +16,9 @@ private static void Main(string[] args) Console.WriteLine("Running in {0}-bit mode.", Environment.Is64BitProcess ? "64" : "32"); FFmpegBinariesHelper.RegisterFFmpegBinaries(); - + Console.WriteLine($"FFmpeg version info: {ffmpeg.av_version_info()}"); - + SetupLogging(); ConfigureHWDecoder(out var deviceType); @@ -55,8 +55,8 @@ private static void ConfigureHWDecoder(out AVHWDeviceType HWtype) if (decoderNumber == 0) decoderNumber = availableHWDecoders.First().Key; Console.WriteLine($"Selected [{decoderNumber}]"); - int.TryParse(Console.ReadLine(),out var inputDecoderNumber); - availableHWDecoders.TryGetValue(inputDecoderNumber == 0 ? decoderNumber: inputDecoderNumber, out HWtype); + int.TryParse(Console.ReadLine(), out var inputDecoderNumber); + availableHWDecoders.TryGetValue(inputDecoderNumber == 0 ? decoderNumber : inputDecoderNumber, out HWtype); } } @@ -73,7 +73,7 @@ private static unsafe void SetupLogging() var lineBuffer = stackalloc byte[lineSize]; var printPrefix = 1; ffmpeg.av_log_format_line(p0, level, format, vl, lineBuffer, lineSize, &printPrefix); - var line = Marshal.PtrToStringAnsi((IntPtr) lineBuffer); + var line = Marshal.PtrToStringAnsi((IntPtr)lineBuffer); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write(line); Console.ResetColor(); @@ -86,7 +86,7 @@ private static unsafe void DecodeAllFramesToImages(AVHWDeviceType HWDevice) { // decode all frames from url, please not it might local resorce, e.g. string url = "../../sample_mpeg4.mp4"; var url = "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"; // be advised this file holds 1440 frames - using (var vsd = new VideoStreamDecoder(url,HWDevice)) + using (var vsd = new VideoStreamDecoder(url, HWDevice)) { Console.WriteLine($"codec name: {vsd.CodecName}"); @@ -104,9 +104,9 @@ private static unsafe void DecodeAllFramesToImages(AVHWDeviceType HWDevice) { var convertedFrame = vfc.Convert(frame); - using (var bitmap = new Bitmap(convertedFrame.width, convertedFrame.height, convertedFrame.linesize[0], PixelFormat.Format24bppRgb, (IntPtr) convertedFrame.data[0])) + using (var bitmap = new Bitmap(convertedFrame.width, convertedFrame.height, convertedFrame.linesize[0], PixelFormat.Format24bppRgb, (IntPtr)convertedFrame.data[0])) bitmap.Save($"frame.{frameNumber:D8}.jpg", ImageFormat.Jpeg); - + Console.WriteLine($"frame: {frameNumber}"); frameNumber++; } @@ -172,7 +172,7 @@ private static unsafe void EncodeImagesToH264() { bitmapData = GetBitmapData(frameBitmap); } - + fixed (byte* pBitmapData = bitmapData) { var data = new byte_ptrArray8 { [0] = pBitmapData }; diff --git a/FFmpeg.AutoGen.Example/VideoFrameConverter.cs b/FFmpeg.AutoGen.Example/VideoFrameConverter.cs index 6cf9d362..367eb15a 100644 --- a/FFmpeg.AutoGen.Example/VideoFrameConverter.cs +++ b/FFmpeg.AutoGen.Example/VideoFrameConverter.cs @@ -16,11 +16,11 @@ public VideoFrameConverter(Size sourceSize, AVPixelFormat sourcePixelFormat, Size destinationSize, AVPixelFormat destinationPixelFormat) { _destinationSize = destinationSize; - - _pConvertContext = ffmpeg.sws_getContext(sourceSize.Width, sourceSize.Height, sourcePixelFormat, - destinationSize.Width, - destinationSize.Height, destinationPixelFormat, - ffmpeg.SWS_FAST_BILINEAR, null, null, null); + + _pConvertContext = ffmpeg.sws_getContext(sourceSize.Width, sourceSize.Height, sourcePixelFormat, + destinationSize.Width, + destinationSize.Height, destinationPixelFormat, + ffmpeg.SWS_FAST_BILINEAR, null, null, null); if (_pConvertContext == null) throw new ApplicationException("Could not initialize the conversion context."); var convertedFrameBufferSize = ffmpeg.av_image_get_buffer_size(destinationPixelFormat, destinationSize.Width, destinationSize.Height, 1); @@ -28,7 +28,7 @@ public VideoFrameConverter(Size sourceSize, AVPixelFormat sourcePixelFormat, _dstData = new byte_ptrArray4(); _dstLinesize = new int_array4(); - ffmpeg.av_image_fill_arrays(ref _dstData, ref _dstLinesize, (byte*) _convertedFrameBufferPtr, destinationPixelFormat, destinationSize.Width, destinationSize.Height, 1); + ffmpeg.av_image_fill_arrays(ref _dstData, ref _dstLinesize, (byte*)_convertedFrameBufferPtr, destinationPixelFormat, destinationSize.Width, destinationSize.Height, 1); } public void Dispose() diff --git a/FFmpeg.AutoGen.Example/VideoStreamDecoder.cs b/FFmpeg.AutoGen.Example/VideoStreamDecoder.cs index 39342c21..07a235f3 100644 --- a/FFmpeg.AutoGen.Example/VideoStreamDecoder.cs +++ b/FFmpeg.AutoGen.Example/VideoStreamDecoder.cs @@ -31,7 +31,7 @@ public VideoStreamDecoder(string url, AVHWDeviceType HWDeviceType = AVHWDeviceTy } ffmpeg.avcodec_parameters_to_context(_pCodecContext, _pFormatContext->streams[_streamIndex]->codecpar).ThrowExceptionIfError(); ffmpeg.avcodec_open2(_pCodecContext, codec, null).ThrowExceptionIfError(); - + CodecName = ffmpeg.avcodec_get_name(codec->id); FrameSize = new Size(_pCodecContext->width, _pCodecContext->height); PixelFormat = _pCodecContext->pix_fmt; @@ -107,8 +107,8 @@ public IReadOnlyDictionary GetContextInfo() var result = new Dictionary(); while ((tag = ffmpeg.av_dict_get(_pFormatContext->metadata, "", tag, ffmpeg.AV_DICT_IGNORE_SUFFIX)) != null) { - var key = Marshal.PtrToStringAnsi((IntPtr) tag->key); - var value = Marshal.PtrToStringAnsi((IntPtr) tag->value); + var key = Marshal.PtrToStringAnsi((IntPtr)tag->key); + var value = Marshal.PtrToStringAnsi((IntPtr)tag->value); result.Add(key, value); } diff --git a/FFmpeg.AutoGen/FFmpeg.functions.export.g.cs b/FFmpeg.AutoGen/FFmpeg.functions.export.g.cs index 5ef541ec..868adbec 100644 --- a/FFmpeg.AutoGen/FFmpeg.functions.export.g.cs +++ b/FFmpeg.AutoGen/FFmpeg.functions.export.g.cs @@ -321,7 +321,7 @@ public static int av_bsf_init(AVBSFContext* @ctx) return av_bsf_list_alloc_fptr(); }; /// Allocate empty list of bitstream filters. The list must be later freed by av_bsf_list_free() or finalized by av_bsf_list_finalize(). - /// Pointer to + /// Pointer to on success, NULL in case of failure public static AVBSFList* av_bsf_list_alloc() { return av_bsf_list_alloc_fptr(); @@ -407,7 +407,7 @@ public static int av_bsf_list_append2(AVBSFList* @lst, }; /// Finalize list of bitstream filters. /// Filter list structure to be transformed - /// Pointer to be set to newly created + /// Pointer to be set to newly created structure representing the chain of bitstream filters /// >=0 on success, negative AVERROR in case of failure public static int av_bsf_list_finalize(AVBSFList** @lst, AVBSFContext** @bsf) { @@ -458,9 +458,9 @@ private delegate int av_bsf_list_parse_str_delegate( } return av_bsf_list_parse_str_fptr(@str, @bsf); }; - /// Parse string describing list of bitstream filters and create single Resulting allocated by av_bsf_alloc(). + /// Parse string describing list of bitstream filters and create single AVBSFContext describing the whole chain of bitstream filters. Resulting AVBSFContext can be treated as any other AVBSFContext freshly allocated by av_bsf_alloc(). /// String describing chain of bitstream filters in format `bsf1[=opt1=val1:opt2=val2][,bsf2]` - /// Pointer to be set to newly created + /// Pointer to be set to newly created structure representing the chain of bitstream filters /// >=0 on success, negative AVERROR in case of failure public static int av_bsf_list_parse_str( #if NET40 @@ -6875,7 +6875,7 @@ public static int av_index_search_timestamp(AVStream* @st, long @timestamp, int }; /// Write a packet to an output media file ensuring correct interleaving. /// media file handle - /// The packet containing the data to be written. If the packet is reference-counted, this function will take ownership of this reference and unreference it later when it sees fit. The caller must not access the data through this reference after this function returns. If the packet is not reference-counted, libavformat will make a copy. This parameter can be NULL (at any time, not just at the end), to flush the interleaving queues. Packet's + /// The packet containing the data to be written. If the packet is reference-counted, this function will take ownership of this reference and unreference it later when it sees fit. The caller must not access the data through this reference after this function returns. If the packet is not reference-counted, libavformat will make a copy. This parameter can be NULL (at any time, not just at the end), to flush the interleaving queues. Packet's "stream_index" field must be set to the index of the corresponding stream in "s->streams". The timestamps ( "pts", "dts") must be set to correct values in the stream's timebase (unless the output format is flagged with the AVFMT_NOTIMESTAMPS flag, then they can be set to AV_NOPTS_VALUE). The dts for subsequent packets in one stream must be strictly increasing (unless the output format is flagged with the AVFMT_TS_NONSTRICT, then they merely have to be nondecreasing). "duration") should also be set if known. /// 0 on success, a negative AVERROR on error. Libavformat will always take care of freeing the packet, even if this function fails. public static int av_interleaved_write_frame(AVFormatContext* @s, AVPacket* @pkt) { @@ -7704,7 +7704,7 @@ public static void av_url_split(byte* @proto, int @proto_size, byte* @authorizat }; /// Write a packet to an output media file. /// media file handle - /// The packet containing the data to be written. Note that unlike av_interleaved_write_frame(), this function does not take ownership of the packet passed to it (though some muxers may make an internal reference to the input packet). This parameter can be NULL (at any time, not just at the end), in order to immediately flush data buffered within the muxer, for muxers that buffer up data internally before writing it to the output. Packet's + /// The packet containing the data to be written. Note that unlike av_interleaved_write_frame(), this function does not take ownership of the packet passed to it (though some muxers may make an internal reference to the input packet). This parameter can be NULL (at any time, not just at the end), in order to immediately flush data buffered within the muxer, for muxers that buffer up data internally before writing it to the output. Packet's "stream_index" field must be set to the index of the corresponding stream in "s->streams". The timestamps ( "pts", "dts") must be set to correct values in the stream's timebase (unless the output format is flagged with the AVFMT_NOTIMESTAMPS flag, then they can be set to AV_NOPTS_VALUE). The dts for subsequent packets passed to this function must be strictly increasing when compared in their respective timebases (unless the output format is flagged with the AVFMT_TS_NONSTRICT, then they merely have to be nondecreasing). "duration") should also be set if known. /// < 0 on error, = 0 if OK, 1 if flushed and there is no more data to flush public static int av_write_frame(AVFormatContext* @s, AVPacket* @pkt) { @@ -14619,7 +14619,7 @@ private delegate void av_log_delegate(void* @avcl, int @level, }; /// Send the specified message to the log if the level is less than or equal to the current av_log_level. By default, all logging messages are sent to stderr. This behavior can be altered by setting a different logging callback function. /// A pointer to an arbitrary struct of which the first field is a pointer to an AVClass struct or NULL if general log. - /// The importance level of the message expressed using a + /// The importance level of the message expressed using a "Logging Constant". /// The format string (printf-compatible) that specifies how subsequent arguments are converted to output. public static void av_log(void* @avcl, int @level, #if NET40 @@ -14657,7 +14657,7 @@ private delegate void av_log_default_callback_delegate(void* @avcl, int @level, }; /// Default logging callback /// A pointer to an arbitrary struct of which the first field is a pointer to an AVClass struct. - /// The importance level of the message expressed using a + /// The importance level of the message expressed using a "Logging Constant". /// The format string (printf-compatible) that specifies how subsequent arguments are converted to output. /// The arguments referenced by the format string. public static void av_log_default_callback(void* @avcl, int @level, @@ -14815,8 +14815,8 @@ private delegate void av_log_once_delegate(void* @avcl, int @initial_level, int }; /// Send the specified message to the log once with the initial_level and then with the subsequent_level. By default, all logging messages are sent to stderr. This behavior can be altered by setting a different logging callback function. /// A pointer to an arbitrary struct of which the first field is a pointer to an AVClass struct or NULL if general log. - /// importance level of the message expressed using a - /// importance level of the message expressed using a + /// importance level of the message expressed using a "Logging Constant" for the first occurance. + /// importance level of the message expressed using a "Logging Constant" after the first occurance. /// a variable to keep trak of if a message has already been printed this must be initialized to 0 before the first use. The same state must not be accessed by 2 Threads simultaneously. /// The format string (printf-compatible) that specifies how subsequent arguments are converted to output. public static void av_log_once(void* @avcl, int @initial_level, int @subsequent_level, int* @state, @@ -18167,7 +18167,7 @@ private delegate void av_vlog_delegate(void* @avcl, int @level, }; /// Send the specified message to the log if the level is less than or equal to the current av_log_level. By default, all logging messages are sent to stderr. This behavior can be altered by setting a different logging callback function. /// A pointer to an arbitrary struct of which the first field is a pointer to an AVClass struct. - /// The importance level of the message expressed using a + /// The importance level of the message expressed using a "Logging Constant". /// The format string (printf-compatible) that specifies how subsequent arguments are converted to output. /// The arguments referenced by the format string. public static void av_vlog(void* @avcl, int @level, @@ -18998,7 +18998,7 @@ public static string swresample_license() } return swresample_version_fptr(); }; - /// Return the + /// Return the LIBSWRESAMPLE_VERSION_INT constant. public static uint swresample_version() { return swresample_version_fptr(); diff --git a/FFmpeg.AutoGen/FFmpeg.macros.g.cs b/FFmpeg.AutoGen/FFmpeg.macros.g.cs index 83fa000c..9f24b0c2 100644 --- a/FFmpeg.AutoGen/FFmpeg.macros.g.cs +++ b/FFmpeg.AutoGen/FFmpeg.macros.g.cs @@ -9,6 +9,7 @@ public unsafe static partial class ffmpeg public const int _WIN32_WINNT = 0x602; // public static attribute_deprecated = __declspec(deprecated); // public static av_alias = __attribute__((may_alias)); + // public static av_alloc_size = (...); // public static av_always_inline = __forceinline; /// AV_BUFFER_FLAG_READONLY = (1 << 0) public const int AV_BUFFER_FLAG_READONLY = 0x1 << 0x0; @@ -18,6 +19,7 @@ public unsafe static partial class ffmpeg public const int AV_BUFFERSINK_FLAG_PEEK = 0x1; // public static av_builtin_constant_p = __builtin_constant_p; // public static av_ceil_log2 = av_ceil_log2_c; + // public static AV_CEIL_RSHIFT = (a,b) (!av_builtin_constant_p(b) ? -((-(a)) >> (b)) : ((a) + (1<<(b)) - 1) >> (b)); /// AV_CH_BACK_CENTER = 0x00000100 public const int AV_CH_BACK_CENTER = 0x100; /// AV_CH_BACK_LEFT = 0x00000010 @@ -399,19 +401,25 @@ public unsafe static partial class ffmpeg public const int AV_EF_EXPLODE = 0x1 << 0x3; /// AV_EF_IGNORE_ERR = (1<<15) public const int AV_EF_IGNORE_ERR = 0x1 << 0xf; + // public static av_err2str = (errnum) av_make_error_string((char[AV_ERROR_MAX_STRING_SIZE]){0}, AV_ERROR_MAX_STRING_SIZE, errnum); /// AV_ERROR_MAX_STRING_SIZE = 64 public const int AV_ERROR_MAX_STRING_SIZE = 0x40; // public static av_extern_inline = inline; /// AV_FOURCC_MAX_STRING_SIZE = 32 public const int AV_FOURCC_MAX_STRING_SIZE = 0x20; + // public static av_fourcc2str = (fourcc) av_fourcc_make_string((char[AV_FOURCC_MAX_STRING_SIZE]){0}, fourcc); /// AV_FRAME_FILENAME_FLAGS_MULTIPLE = 1 public const int AV_FRAME_FILENAME_FLAGS_MULTIPLE = 0x1; /// AV_FRAME_FLAG_CORRUPT = (1 << 0) public const int AV_FRAME_FLAG_CORRUPT = 0x1 << 0x0; /// AV_FRAME_FLAG_DISCARD = (1 << 2) public const int AV_FRAME_FLAG_DISCARD = 0x1 << 0x2; + // public static AV_GCC_VERSION_AT_LEAST = (x,y) 0; + // public static AV_GCC_VERSION_AT_MOST = (x,y) 0; /// AV_GET_BUFFER_FLAG_REF = (1 << 0) public const int AV_GET_BUFFER_FLAG_REF = 0x1 << 0x0; + // public static AV_GLUE = (a, b) a ## b; + // public static AV_HAS_BUILTIN = (x)(__has_builtin(x)); /// AV_HAVE_BIGENDIAN = 0 public const int AV_HAVE_BIGENDIAN = 0x0; /// AV_HAVE_FAST_UNALIGNED = 1 @@ -428,6 +436,11 @@ public unsafe static partial class ffmpeg public const int AV_INPUT_BUFFER_MIN_SIZE = 0x4000; /// AV_INPUT_BUFFER_PADDING_SIZE = 64 public const int AV_INPUT_BUFFER_PADDING_SIZE = 0x40; + // public static av_int_list_length = (list, term) av_int_list_length_for_size(sizeof(*(list)), list, term); + // public static AV_IS_INPUT_DEVICE = (category)((category)(==AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT) || (category)(==AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT) || (category)(==AV_CLASS_CATEGORY_DEVICE_INPUT)); + // public static AV_IS_OUTPUT_DEVICE = (category)((category)(==AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT) || (category)(==AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT) || (category)(==AV_CLASS_CATEGORY_DEVICE_OUTPUT)); + // public static AV_JOIN = (a, b) AV_GLUE(a, b); + // public static AV_LOG_C = (x)((x)(<<0x8)); /// AV_LOG_DEBUG = 48 public const int AV_LOG_DEBUG = 0x30; /// AV_LOG_ERROR = 16 @@ -453,10 +466,12 @@ public unsafe static partial class ffmpeg /// AV_LOG_WARNING = 24 public const int AV_LOG_WARNING = 0x18; // public static av_mod_uintp2 = av_mod_uintp2_c; + // public static AV_NE = (be, le) (le); // public static av_noinline = __declspec(noinline); /// AV_NOPTS_VALUE = ((int64_t)UINT64_C(0x8000000000000000)) - public static long AV_NOPTS_VALUE = (long)(UINT64_C(0x8000000000000000L)); + public static readonly long AV_NOPTS_VALUE = (long)(UINT64_C(0x8000000000000000L)); // public static av_noreturn = __attribute__((noreturn)); + // public static AV_NOWARN_DEPRECATED = (code) __pragma(warning(push)) __pragma(warning(disable : 4996)) code; __pragma(warning(pop)); /// AV_NUM_DATA_POINTERS = 8 public const int AV_NUM_DATA_POINTERS = 0x8; /// AV_OPT_ALLOW_NULL = (1 << 2) @@ -495,6 +510,7 @@ public unsafe static partial class ffmpeg public const int AV_OPT_SERIALIZE_OPT_FLAGS_EXACT = 0x2; /// AV_OPT_SERIALIZE_SKIP_DEFAULTS = 0x00000001 public const int AV_OPT_SERIALIZE_SKIP_DEFAULTS = 0x1; + // public static av_opt_set_int_list = (obj, name, val, term, flags) (av_int_list_length(val, term) > INT_MAX / sizeof(*(val)) ? AVERROR(EINVAL) : av_opt_set_bin(obj, name, (const uint8_t *)(val), av_int_list_length(val, term) * sizeof(*(val)), flags)); // public static av_parity = av_parity_c; /// AV_PARSER_PTS_NB = 4 public const int AV_PARSER_PTS_NB = 0x4; @@ -548,6 +564,7 @@ public unsafe static partial class ffmpeg // public static AV_PIX_FMT_GRAY16 = AV_PIX_FMT_NE(GRAY16BE, GRAY16LE); // public static AV_PIX_FMT_GRAY9 = AV_PIX_FMT_NE(GRAY9BE, GRAY9LE); // public static AV_PIX_FMT_GRAYF32 = AV_PIX_FMT_NE(GRAYF32BE, GRAYF32LE); + // public static AV_PIX_FMT_NE = (be, le) AV_PIX_FMT_##le; // public static AV_PIX_FMT_NV20 = AV_PIX_FMT_NE(NV20BE, NV20LE); // public static AV_PIX_FMT_P010 = AV_PIX_FMT_NE(P010BE, P010LE); // public static AV_PIX_FMT_P016 = AV_PIX_FMT_NE(P016BE, P016LE); @@ -602,6 +619,8 @@ public unsafe static partial class ffmpeg public const int AV_PKT_FLAG_TRUSTED = 0x8; // public static av_popcount = av_popcount_c; // public static av_popcount64 = av_popcount64_c; + // public static AV_PRAGMA = (s) _Pragma(#s); + // public static av_printf_format = (fmtpos, attrpos) __attribute__((__format__(__printf__, fmtpos, attrpos))); /// AV_PROGRAM_RUNNING = 1 public const int AV_PROGRAM_RUNNING = 0x1; /// AV_PTS_WRAP_ADD_OFFSET = 1 @@ -617,6 +636,7 @@ public unsafe static partial class ffmpeg // public static av_sat_dsub32 = av_sat_dsub32_c; // public static av_sat_sub32 = av_sat_sub32_c; // public static av_sat_sub64 = av_sat_sub64_c; + // public static AV_STRINGIFY = (s)(AV_TOSTRING(s)); /// AV_SUBTITLE_FLAG_FORCED = 0x00000001 public const int AV_SUBTITLE_FLAG_FORCED = 0x1; /// AV_TIME_BASE = 1000000 @@ -624,62 +644,71 @@ public unsafe static partial class ffmpeg // public static AV_TIME_BASE_Q = (AVRational){1, AV_TIME_BASE}; /// AV_TIMECODE_STR_SIZE = 0x17 public const int AV_TIMECODE_STR_SIZE = 0x17; + // public static AV_TOSTRING = (s) #s; + // public static av_uninit = (x) x=x; // public static av_unused = __attribute__((unused)); // public static av_used = __attribute__((used)); + // public static AV_VERSION = (a, b, c) AV_VERSION_DOT(a, b, c); + // public static AV_VERSION_DOT = (a, b, c) a ##.## b ##.## c; + // public static AV_VERSION_INT = (a, b, c) ((a)<<16 | (b)<<8 | (c)); + // public static AV_VERSION_MAJOR = (a)((a)(>>0x10)); + // public static AV_VERSION_MICRO = (a)((a)(&0xff)); + // public static AV_VERSION_MINOR = (a)((a)(&0xff00) >> 0x8); + // public static AVERROR = (e) (-(e)); /// AVERROR_BSF_NOT_FOUND = FFERRTAG(0xF8,'B','S','F') - public static int AVERROR_BSF_NOT_FOUND = FFERRTAG(0xf8, 'B', 'S', 'F'); + public static readonly int AVERROR_BSF_NOT_FOUND = FFERRTAG(0xf8, 'B', 'S', 'F'); /// AVERROR_BUFFER_TOO_SMALL = FFERRTAG( 'B','U','F','S') - public static int AVERROR_BUFFER_TOO_SMALL = FFERRTAG('B', 'U', 'F', 'S'); + public static readonly int AVERROR_BUFFER_TOO_SMALL = FFERRTAG('B', 'U', 'F', 'S'); /// AVERROR_BUG = FFERRTAG( 'B','U','G','!') - public static int AVERROR_BUG = FFERRTAG('B', 'U', 'G', '!'); + public static readonly int AVERROR_BUG = FFERRTAG('B', 'U', 'G', '!'); /// AVERROR_BUG2 = FFERRTAG( 'B','U','G',' ') - public static int AVERROR_BUG2 = FFERRTAG('B', 'U', 'G', ' '); + public static readonly int AVERROR_BUG2 = FFERRTAG('B', 'U', 'G', ' '); /// AVERROR_DECODER_NOT_FOUND = FFERRTAG(0xF8,'D','E','C') - public static int AVERROR_DECODER_NOT_FOUND = FFERRTAG(0xf8, 'D', 'E', 'C'); + public static readonly int AVERROR_DECODER_NOT_FOUND = FFERRTAG(0xf8, 'D', 'E', 'C'); /// AVERROR_DEMUXER_NOT_FOUND = FFERRTAG(0xF8,'D','E','M') - public static int AVERROR_DEMUXER_NOT_FOUND = FFERRTAG(0xf8, 'D', 'E', 'M'); + public static readonly int AVERROR_DEMUXER_NOT_FOUND = FFERRTAG(0xf8, 'D', 'E', 'M'); /// AVERROR_ENCODER_NOT_FOUND = FFERRTAG(0xF8,'E','N','C') - public static int AVERROR_ENCODER_NOT_FOUND = FFERRTAG(0xf8, 'E', 'N', 'C'); + public static readonly int AVERROR_ENCODER_NOT_FOUND = FFERRTAG(0xf8, 'E', 'N', 'C'); /// AVERROR_EOF = FFERRTAG( 'E','O','F',' ') - public static int AVERROR_EOF = FFERRTAG('E', 'O', 'F', ' '); + public static readonly int AVERROR_EOF = FFERRTAG('E', 'O', 'F', ' '); /// AVERROR_EXIT = FFERRTAG( 'E','X','I','T') - public static int AVERROR_EXIT = FFERRTAG('E', 'X', 'I', 'T'); + public static readonly int AVERROR_EXIT = FFERRTAG('E', 'X', 'I', 'T'); /// AVERROR_EXPERIMENTAL = (-0x2bb2afa8) public const int AVERROR_EXPERIMENTAL = -0x2bb2afa8; /// AVERROR_EXTERNAL = FFERRTAG( 'E','X','T',' ') - public static int AVERROR_EXTERNAL = FFERRTAG('E', 'X', 'T', ' '); + public static readonly int AVERROR_EXTERNAL = FFERRTAG('E', 'X', 'T', ' '); /// AVERROR_FILTER_NOT_FOUND = FFERRTAG(0xF8,'F','I','L') - public static int AVERROR_FILTER_NOT_FOUND = FFERRTAG(0xf8, 'F', 'I', 'L'); + public static readonly int AVERROR_FILTER_NOT_FOUND = FFERRTAG(0xf8, 'F', 'I', 'L'); /// AVERROR_HTTP_BAD_REQUEST = FFERRTAG(0xF8,'4','0','0') - public static int AVERROR_HTTP_BAD_REQUEST = FFERRTAG(0xf8, '4', '0', '0'); + public static readonly int AVERROR_HTTP_BAD_REQUEST = FFERRTAG(0xf8, '4', '0', '0'); /// AVERROR_HTTP_FORBIDDEN = FFERRTAG(0xF8,'4','0','3') - public static int AVERROR_HTTP_FORBIDDEN = FFERRTAG(0xf8, '4', '0', '3'); + public static readonly int AVERROR_HTTP_FORBIDDEN = FFERRTAG(0xf8, '4', '0', '3'); /// AVERROR_HTTP_NOT_FOUND = FFERRTAG(0xF8,'4','0','4') - public static int AVERROR_HTTP_NOT_FOUND = FFERRTAG(0xf8, '4', '0', '4'); + public static readonly int AVERROR_HTTP_NOT_FOUND = FFERRTAG(0xf8, '4', '0', '4'); /// AVERROR_HTTP_OTHER_4XX = FFERRTAG(0xF8,'4','X','X') - public static int AVERROR_HTTP_OTHER_4XX = FFERRTAG(0xf8, '4', 'X', 'X'); + public static readonly int AVERROR_HTTP_OTHER_4XX = FFERRTAG(0xf8, '4', 'X', 'X'); /// AVERROR_HTTP_SERVER_ERROR = FFERRTAG(0xF8,'5','X','X') - public static int AVERROR_HTTP_SERVER_ERROR = FFERRTAG(0xf8, '5', 'X', 'X'); + public static readonly int AVERROR_HTTP_SERVER_ERROR = FFERRTAG(0xf8, '5', 'X', 'X'); /// AVERROR_HTTP_UNAUTHORIZED = FFERRTAG(0xF8,'4','0','1') - public static int AVERROR_HTTP_UNAUTHORIZED = FFERRTAG(0xf8, '4', '0', '1'); + public static readonly int AVERROR_HTTP_UNAUTHORIZED = FFERRTAG(0xf8, '4', '0', '1'); /// AVERROR_INPUT_CHANGED = (-0x636e6701) public const int AVERROR_INPUT_CHANGED = -0x636e6701; /// AVERROR_INVALIDDATA = FFERRTAG( 'I','N','D','A') - public static int AVERROR_INVALIDDATA = FFERRTAG('I', 'N', 'D', 'A'); + public static readonly int AVERROR_INVALIDDATA = FFERRTAG('I', 'N', 'D', 'A'); /// AVERROR_MUXER_NOT_FOUND = FFERRTAG(0xF8,'M','U','X') - public static int AVERROR_MUXER_NOT_FOUND = FFERRTAG(0xf8, 'M', 'U', 'X'); + public static readonly int AVERROR_MUXER_NOT_FOUND = FFERRTAG(0xf8, 'M', 'U', 'X'); /// AVERROR_OPTION_NOT_FOUND = FFERRTAG(0xF8,'O','P','T') - public static int AVERROR_OPTION_NOT_FOUND = FFERRTAG(0xf8, 'O', 'P', 'T'); + public static readonly int AVERROR_OPTION_NOT_FOUND = FFERRTAG(0xf8, 'O', 'P', 'T'); /// AVERROR_OUTPUT_CHANGED = (-0x636e6702) public const int AVERROR_OUTPUT_CHANGED = -0x636e6702; /// AVERROR_PATCHWELCOME = FFERRTAG( 'P','A','W','E') - public static int AVERROR_PATCHWELCOME = FFERRTAG('P', 'A', 'W', 'E'); + public static readonly int AVERROR_PATCHWELCOME = FFERRTAG('P', 'A', 'W', 'E'); /// AVERROR_PROTOCOL_NOT_FOUND = FFERRTAG(0xF8,'P','R','O') - public static int AVERROR_PROTOCOL_NOT_FOUND = FFERRTAG(0xf8, 'P', 'R', 'O'); + public static readonly int AVERROR_PROTOCOL_NOT_FOUND = FFERRTAG(0xf8, 'P', 'R', 'O'); /// AVERROR_STREAM_NOT_FOUND = FFERRTAG(0xF8,'S','T','R') - public static int AVERROR_STREAM_NOT_FOUND = FFERRTAG(0xf8, 'S', 'T', 'R'); + public static readonly int AVERROR_STREAM_NOT_FOUND = FFERRTAG(0xf8, 'S', 'T', 'R'); /// AVERROR_UNKNOWN = FFERRTAG( 'U','N','K','N') - public static int AVERROR_UNKNOWN = FFERRTAG('U', 'N', 'K', 'N'); + public static readonly int AVERROR_UNKNOWN = FFERRTAG('U', 'N', 'K', 'N'); /// AVFILTER_CMD_FLAG_FAST = 0x2 public const int AVFILTER_CMD_FLAG_FAST = 0x2; /// AVFILTER_CMD_FLAG_ONE = 0x1 @@ -794,6 +823,7 @@ public unsafe static partial class ffmpeg public const int AVIO_FLAG_READ_WRITE = AVIO_FLAG_READ | AVIO_FLAG_WRITE; /// AVIO_FLAG_WRITE = 2 public const int AVIO_FLAG_WRITE = 0x2; + // public static avio_print = (s, ...) avio_print_string_array(s, (const char*[]){__VA_ARGS__, NULL}); /// AVIO_SEEKABLE_NORMAL = (1 << 0) public const int AVIO_SEEKABLE_NORMAL = 0x1 << 0x0; /// AVIO_SEEKABLE_TIME = (1 << 1) @@ -832,6 +862,10 @@ public unsafe static partial class ffmpeg public const int AVSTREAM_INIT_IN_INIT_OUTPUT = 0x1; /// AVSTREAM_INIT_IN_WRITE_HEADER = 0 public const int AVSTREAM_INIT_IN_WRITE_HEADER = 0x0; + // public static AVUNERROR = (e) (-(e)); + // public static DECLARE_ALIGNED = (n,t,v) t __attribute__ ((aligned (n))) v; + // public static DECLARE_ASM_ALIGNED = (n,t,v) t av_used __attribute__ ((aligned (n))) v; + // public static DECLARE_ASM_CONST = (n,t,v) static const t av_used __attribute__ ((aligned (n))) v; /// FF_API_ASS_TIMING = (LIBAVCODEC_VERSION_MAJOR < 59) public const bool FF_API_ASS_TIMING = LIBAVCODEC_VERSION_MAJOR < 0x3b; /// FF_API_AVCTX_TIMEBASE = (LIBAVCODEC_VERSION_MAJOR < 59) @@ -954,6 +988,7 @@ public unsafe static partial class ffmpeg public const bool FF_API_VBV_DELAY = LIBAVCODEC_VERSION_MAJOR < 0x3b; /// FF_API_VDPAU_PROFILE = (LIBAVCODEC_VERSION_MAJOR < 59) public const bool FF_API_VDPAU_PROFILE = LIBAVCODEC_VERSION_MAJOR < 0x3b; + // public static FF_ARRAY_ELEMS = (a) (sizeof(a) / sizeof((a)[0])); /// FF_BUG_AMV = 32 public const int FF_BUG_AMV = 0x20; /// FF_BUG_AUTODETECT = 1 @@ -1389,14 +1424,29 @@ public unsafe static partial class ffmpeg public const int FF_THREAD_FRAME = 0x1; /// FF_THREAD_SLICE = 2 public const int FF_THREAD_SLICE = 0x2; + // public static FFABS = (a) ((a) >= 0 ? (a) : (-(a))); + // public static FFALIGN = (x, a) (((x)+(a)-1)&~((a)-1)); + // public static FFDIFFSIGN = (x,y) (((x)>(y)) - ((x)<(y))); + // public static FFERRTAG = (a, b, c, d) (-(int)MKTAG(a, b, c, d)); + // public static FFMAX = (a,b) ((a) > (b) ? (a) : (b)); + // public static FFMAX3 = (a,b,c) FFMAX(FFMAX(a,b),c); + // public static FFMIN = (a,b) ((a) > (b) ? (b) : (a)); + // public static FFMIN3 = (a,b,c) FFMIN(FFMIN(a,b),c); + // public static FFNABS = (a) ((a) <= 0 ? (a) : (-(a))); + // public static FFSIGN = (a) ((a) > 0 ? 1 : -1); + // public static FFSWAP = (type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0); + // public static FFUDIV = (a,b) (((a)>0 ?(a):(a)-(b)+1) / (b)); + // public static FFUMOD = (a,b) ((a)-(b)*FFUDIV(a,b)); + // public static GET_UTF16 = (val, GET_16BIT, ERROR)val = (GET_16BIT);{unsigned int hi = val - 0xD800;if (hi < 0x800) {val = (GET_16BIT) - 0xDC00;if (val > 0x3FFU || hi > 0x3FFU){ERROR}val += (hi<<10) + 0x10000;}}; + // public static GET_UTF8 = (val, GET_BYTE, ERROR)val= (GET_BYTE);{uint32_t top = (val & 128) >> 1;if ((val & 0xc0) == 0x80 || val >= 0xFE){ERROR}while (val & top) {unsigned int tmp = (GET_BYTE) - 128;if(tmp>>6){ERROR}val= (val<<6) + tmp;top <<= 5;}val &= (top << 1) - 1;}; /// LIBAVCODEC_BUILD = LIBAVCODEC_VERSION_INT - public static int LIBAVCODEC_BUILD = LIBAVCODEC_VERSION_INT; + public static readonly int LIBAVCODEC_BUILD = LIBAVCODEC_VERSION_INT; /// LIBAVCODEC_IDENT = "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION) public const string LIBAVCODEC_IDENT = "Lavc"; /// LIBAVCODEC_VERSION = AV_VERSION(LIBAVCODEC_VERSION_MAJOR, LIBAVCODEC_VERSION_MINOR, LIBAVCODEC_VERSION_MICRO) - public static string LIBAVCODEC_VERSION = AV_VERSION(LIBAVCODEC_VERSION_MAJOR, LIBAVCODEC_VERSION_MINOR, LIBAVCODEC_VERSION_MICRO); + public static readonly string LIBAVCODEC_VERSION = AV_VERSION(LIBAVCODEC_VERSION_MAJOR, LIBAVCODEC_VERSION_MINOR, LIBAVCODEC_VERSION_MICRO); /// LIBAVCODEC_VERSION_INT = AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, LIBAVCODEC_VERSION_MINOR, LIBAVCODEC_VERSION_MICRO) - public static int LIBAVCODEC_VERSION_INT = AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, LIBAVCODEC_VERSION_MINOR, LIBAVCODEC_VERSION_MICRO); + public static readonly int LIBAVCODEC_VERSION_INT = AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, LIBAVCODEC_VERSION_MINOR, LIBAVCODEC_VERSION_MICRO); /// LIBAVCODEC_VERSION_MAJOR = 58 public const int LIBAVCODEC_VERSION_MAJOR = 0x3a; /// LIBAVCODEC_VERSION_MICRO = 100 @@ -1404,13 +1454,13 @@ public unsafe static partial class ffmpeg /// LIBAVCODEC_VERSION_MINOR = 91 public const int LIBAVCODEC_VERSION_MINOR = 0x5b; /// LIBAVDEVICE_BUILD = LIBAVDEVICE_VERSION_INT - public static int LIBAVDEVICE_BUILD = LIBAVDEVICE_VERSION_INT; + public static readonly int LIBAVDEVICE_BUILD = LIBAVDEVICE_VERSION_INT; /// LIBAVDEVICE_IDENT = "Lavd" AV_STRINGIFY(LIBAVDEVICE_VERSION) public const string LIBAVDEVICE_IDENT = "Lavd"; /// LIBAVDEVICE_VERSION = AV_VERSION(LIBAVDEVICE_VERSION_MAJOR, LIBAVDEVICE_VERSION_MINOR, LIBAVDEVICE_VERSION_MICRO) - public static string LIBAVDEVICE_VERSION = AV_VERSION(LIBAVDEVICE_VERSION_MAJOR, LIBAVDEVICE_VERSION_MINOR, LIBAVDEVICE_VERSION_MICRO); + public static readonly string LIBAVDEVICE_VERSION = AV_VERSION(LIBAVDEVICE_VERSION_MAJOR, LIBAVDEVICE_VERSION_MINOR, LIBAVDEVICE_VERSION_MICRO); /// LIBAVDEVICE_VERSION_INT = AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, LIBAVDEVICE_VERSION_MINOR, LIBAVDEVICE_VERSION_MICRO) - public static int LIBAVDEVICE_VERSION_INT = AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, LIBAVDEVICE_VERSION_MINOR, LIBAVDEVICE_VERSION_MICRO); + public static readonly int LIBAVDEVICE_VERSION_INT = AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, LIBAVDEVICE_VERSION_MINOR, LIBAVDEVICE_VERSION_MICRO); /// LIBAVDEVICE_VERSION_MAJOR = 58 public const int LIBAVDEVICE_VERSION_MAJOR = 0x3a; /// LIBAVDEVICE_VERSION_MICRO = 100 @@ -1418,13 +1468,13 @@ public unsafe static partial class ffmpeg /// LIBAVDEVICE_VERSION_MINOR = 10 public const int LIBAVDEVICE_VERSION_MINOR = 0xa; /// LIBAVFILTER_BUILD = LIBAVFILTER_VERSION_INT - public static int LIBAVFILTER_BUILD = LIBAVFILTER_VERSION_INT; + public static readonly int LIBAVFILTER_BUILD = LIBAVFILTER_VERSION_INT; /// LIBAVFILTER_IDENT = "Lavfi" public const string LIBAVFILTER_IDENT = "Lavfi"; /// LIBAVFILTER_VERSION = AV_VERSION(LIBAVFILTER_VERSION_MAJOR, LIBAVFILTER_VERSION_MINOR, LIBAVFILTER_VERSION_MICRO) - public static string LIBAVFILTER_VERSION = AV_VERSION(LIBAVFILTER_VERSION_MAJOR, LIBAVFILTER_VERSION_MINOR, LIBAVFILTER_VERSION_MICRO); + public static readonly string LIBAVFILTER_VERSION = AV_VERSION(LIBAVFILTER_VERSION_MAJOR, LIBAVFILTER_VERSION_MINOR, LIBAVFILTER_VERSION_MICRO); /// LIBAVFILTER_VERSION_INT = AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, LIBAVFILTER_VERSION_MINOR, LIBAVFILTER_VERSION_MICRO) - public static int LIBAVFILTER_VERSION_INT = AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, LIBAVFILTER_VERSION_MINOR, LIBAVFILTER_VERSION_MICRO); + public static readonly int LIBAVFILTER_VERSION_INT = AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, LIBAVFILTER_VERSION_MINOR, LIBAVFILTER_VERSION_MICRO); /// LIBAVFILTER_VERSION_MAJOR = 0x7 public const int LIBAVFILTER_VERSION_MAJOR = 0x7; /// LIBAVFILTER_VERSION_MICRO = 0x64 @@ -1432,13 +1482,13 @@ public unsafe static partial class ffmpeg /// LIBAVFILTER_VERSION_MINOR = 0x55 public const int LIBAVFILTER_VERSION_MINOR = 0x55; /// LIBAVFORMAT_BUILD = LIBAVFORMAT_VERSION_INT - public static int LIBAVFORMAT_BUILD = LIBAVFORMAT_VERSION_INT; + public static readonly int LIBAVFORMAT_BUILD = LIBAVFORMAT_VERSION_INT; /// LIBAVFORMAT_IDENT = "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION) public const string LIBAVFORMAT_IDENT = "Lavf"; /// LIBAVFORMAT_VERSION = AV_VERSION(LIBAVFORMAT_VERSION_MAJOR, LIBAVFORMAT_VERSION_MINOR, LIBAVFORMAT_VERSION_MICRO) - public static string LIBAVFORMAT_VERSION = AV_VERSION(LIBAVFORMAT_VERSION_MAJOR, LIBAVFORMAT_VERSION_MINOR, LIBAVFORMAT_VERSION_MICRO); + public static readonly string LIBAVFORMAT_VERSION = AV_VERSION(LIBAVFORMAT_VERSION_MAJOR, LIBAVFORMAT_VERSION_MINOR, LIBAVFORMAT_VERSION_MICRO); /// LIBAVFORMAT_VERSION_INT = AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, LIBAVFORMAT_VERSION_MINOR, LIBAVFORMAT_VERSION_MICRO) - public static int LIBAVFORMAT_VERSION_INT = AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, LIBAVFORMAT_VERSION_MINOR, LIBAVFORMAT_VERSION_MICRO); + public static readonly int LIBAVFORMAT_VERSION_INT = AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, LIBAVFORMAT_VERSION_MINOR, LIBAVFORMAT_VERSION_MICRO); /// LIBAVFORMAT_VERSION_MAJOR = 58 public const int LIBAVFORMAT_VERSION_MAJOR = 0x3a; /// LIBAVFORMAT_VERSION_MICRO = 100 @@ -1446,13 +1496,13 @@ public unsafe static partial class ffmpeg /// LIBAVFORMAT_VERSION_MINOR = 45 public const int LIBAVFORMAT_VERSION_MINOR = 0x2d; /// LIBAVUTIL_BUILD = LIBAVUTIL_VERSION_INT - public static int LIBAVUTIL_BUILD = LIBAVUTIL_VERSION_INT; + public static readonly int LIBAVUTIL_BUILD = LIBAVUTIL_VERSION_INT; /// LIBAVUTIL_IDENT = "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION) public const string LIBAVUTIL_IDENT = "Lavu"; /// LIBAVUTIL_VERSION = AV_VERSION(LIBAVUTIL_VERSION_MAJOR, LIBAVUTIL_VERSION_MINOR, LIBAVUTIL_VERSION_MICRO) - public static string LIBAVUTIL_VERSION = AV_VERSION(LIBAVUTIL_VERSION_MAJOR, LIBAVUTIL_VERSION_MINOR, LIBAVUTIL_VERSION_MICRO); + public static readonly string LIBAVUTIL_VERSION = AV_VERSION(LIBAVUTIL_VERSION_MAJOR, LIBAVUTIL_VERSION_MINOR, LIBAVUTIL_VERSION_MICRO); /// LIBAVUTIL_VERSION_INT = AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, LIBAVUTIL_VERSION_MINOR, LIBAVUTIL_VERSION_MICRO) - public static int LIBAVUTIL_VERSION_INT = AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, LIBAVUTIL_VERSION_MINOR, LIBAVUTIL_VERSION_MICRO); + public static readonly int LIBAVUTIL_VERSION_INT = AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, LIBAVUTIL_VERSION_MINOR, LIBAVUTIL_VERSION_MICRO); /// LIBAVUTIL_VERSION_MAJOR = 56 public const int LIBAVUTIL_VERSION_MAJOR = 0x38; /// LIBAVUTIL_VERSION_MICRO = 100 @@ -1460,13 +1510,13 @@ public unsafe static partial class ffmpeg /// LIBAVUTIL_VERSION_MINOR = 51 public const int LIBAVUTIL_VERSION_MINOR = 0x33; /// LIBPOSTPROC_BUILD = LIBPOSTPROC_VERSION_INT - public static int LIBPOSTPROC_BUILD = LIBPOSTPROC_VERSION_INT; + public static readonly int LIBPOSTPROC_BUILD = LIBPOSTPROC_VERSION_INT; /// LIBPOSTPROC_IDENT = "postproc" public const string LIBPOSTPROC_IDENT = "postproc"; /// LIBPOSTPROC_VERSION = AV_VERSION(LIBPOSTPROC_VERSION_MAJOR, LIBPOSTPROC_VERSION_MINOR, LIBPOSTPROC_VERSION_MICRO) - public static string LIBPOSTPROC_VERSION = AV_VERSION(LIBPOSTPROC_VERSION_MAJOR, LIBPOSTPROC_VERSION_MINOR, LIBPOSTPROC_VERSION_MICRO); + public static readonly string LIBPOSTPROC_VERSION = AV_VERSION(LIBPOSTPROC_VERSION_MAJOR, LIBPOSTPROC_VERSION_MINOR, LIBPOSTPROC_VERSION_MICRO); /// LIBPOSTPROC_VERSION_INT = AV_VERSION_INT(LIBPOSTPROC_VERSION_MAJOR, LIBPOSTPROC_VERSION_MINOR, LIBPOSTPROC_VERSION_MICRO) - public static int LIBPOSTPROC_VERSION_INT = AV_VERSION_INT(LIBPOSTPROC_VERSION_MAJOR, LIBPOSTPROC_VERSION_MINOR, LIBPOSTPROC_VERSION_MICRO); + public static readonly int LIBPOSTPROC_VERSION_INT = AV_VERSION_INT(LIBPOSTPROC_VERSION_MAJOR, LIBPOSTPROC_VERSION_MINOR, LIBPOSTPROC_VERSION_MICRO); /// LIBPOSTPROC_VERSION_MAJOR = 0x37 public const int LIBPOSTPROC_VERSION_MAJOR = 0x37; /// LIBPOSTPROC_VERSION_MICRO = 0x64 @@ -1474,13 +1524,13 @@ public unsafe static partial class ffmpeg /// LIBPOSTPROC_VERSION_MINOR = 0x7 public const int LIBPOSTPROC_VERSION_MINOR = 0x7; /// LIBSWRESAMPLE_BUILD = LIBSWRESAMPLE_VERSION_INT - public static int LIBSWRESAMPLE_BUILD = LIBSWRESAMPLE_VERSION_INT; + public static readonly int LIBSWRESAMPLE_BUILD = LIBSWRESAMPLE_VERSION_INT; /// LIBSWRESAMPLE_IDENT = "SwR" public const string LIBSWRESAMPLE_IDENT = "SwR"; /// LIBSWRESAMPLE_VERSION = AV_VERSION(LIBSWRESAMPLE_VERSION_MAJOR, LIBSWRESAMPLE_VERSION_MINOR, LIBSWRESAMPLE_VERSION_MICRO) - public static string LIBSWRESAMPLE_VERSION = AV_VERSION(LIBSWRESAMPLE_VERSION_MAJOR, LIBSWRESAMPLE_VERSION_MINOR, LIBSWRESAMPLE_VERSION_MICRO); + public static readonly string LIBSWRESAMPLE_VERSION = AV_VERSION(LIBSWRESAMPLE_VERSION_MAJOR, LIBSWRESAMPLE_VERSION_MINOR, LIBSWRESAMPLE_VERSION_MICRO); /// LIBSWRESAMPLE_VERSION_INT = AV_VERSION_INT(LIBSWRESAMPLE_VERSION_MAJOR, LIBSWRESAMPLE_VERSION_MINOR, LIBSWRESAMPLE_VERSION_MICRO) - public static int LIBSWRESAMPLE_VERSION_INT = AV_VERSION_INT(LIBSWRESAMPLE_VERSION_MAJOR, LIBSWRESAMPLE_VERSION_MINOR, LIBSWRESAMPLE_VERSION_MICRO); + public static readonly int LIBSWRESAMPLE_VERSION_INT = AV_VERSION_INT(LIBSWRESAMPLE_VERSION_MAJOR, LIBSWRESAMPLE_VERSION_MINOR, LIBSWRESAMPLE_VERSION_MICRO); /// LIBSWRESAMPLE_VERSION_MAJOR = 0x3 public const int LIBSWRESAMPLE_VERSION_MAJOR = 0x3; /// LIBSWRESAMPLE_VERSION_MICRO = 0x64 @@ -1488,13 +1538,13 @@ public unsafe static partial class ffmpeg /// LIBSWRESAMPLE_VERSION_MINOR = 0x7 public const int LIBSWRESAMPLE_VERSION_MINOR = 0x7; /// LIBSWSCALE_BUILD = LIBSWSCALE_VERSION_INT - public static int LIBSWSCALE_BUILD = LIBSWSCALE_VERSION_INT; + public static readonly int LIBSWSCALE_BUILD = LIBSWSCALE_VERSION_INT; /// LIBSWSCALE_IDENT = "SwS" public const string LIBSWSCALE_IDENT = "SwS"; /// LIBSWSCALE_VERSION = AV_VERSION(LIBSWSCALE_VERSION_MAJOR, LIBSWSCALE_VERSION_MINOR, LIBSWSCALE_VERSION_MICRO) - public static string LIBSWSCALE_VERSION = AV_VERSION(LIBSWSCALE_VERSION_MAJOR, LIBSWSCALE_VERSION_MINOR, LIBSWSCALE_VERSION_MICRO); + public static readonly string LIBSWSCALE_VERSION = AV_VERSION(LIBSWSCALE_VERSION_MAJOR, LIBSWSCALE_VERSION_MINOR, LIBSWSCALE_VERSION_MICRO); /// LIBSWSCALE_VERSION_INT = AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, LIBSWSCALE_VERSION_MINOR, LIBSWSCALE_VERSION_MICRO) - public static int LIBSWSCALE_VERSION_INT = AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, LIBSWSCALE_VERSION_MINOR, LIBSWSCALE_VERSION_MICRO); + public static readonly int LIBSWSCALE_VERSION_INT = AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, LIBSWSCALE_VERSION_MINOR, LIBSWSCALE_VERSION_MICRO); /// LIBSWSCALE_VERSION_MAJOR = 0x5 public const int LIBSWSCALE_VERSION_MAJOR = 0x5; /// LIBSWSCALE_VERSION_MICRO = 0x64 @@ -1502,27 +1552,29 @@ public unsafe static partial class ffmpeg /// LIBSWSCALE_VERSION_MINOR = 0x7 public const int LIBSWSCALE_VERSION_MINOR = 0x7; /// M_E = 2.7182818284590452354 - public const double M_E = 2.71828182845905D; + public const double M_E = 2.718281828459045D; /// M_LN10 = 2.30258509299404568402 - public const double M_LN10 = 2.30258509299405D; + public const double M_LN10 = 2.302585092994046D; /// M_LN2 = 0.69314718055994530942 - public const double M_LN2 = 0.693147180559945D; + public const double M_LN2 = 0.6931471805599453D; /// M_LOG2_10 = 3.32192809488736234787 - public const double M_LOG2_10 = 3.32192809488736D; + public const double M_LOG2_10 = 3.321928094887362D; /// M_PHI = 1.61803398874989484820 - public const double M_PHI = 1.61803398874989D; + public const double M_PHI = 1.618033988749895D; /// M_PI = 3.14159265358979323846 - public const double M_PI = 3.14159265358979D; + public const double M_PI = 3.141592653589793D; /// M_PI_2 = 1.57079632679489661923 - public const double M_PI_2 = 1.5707963267949D; + public const double M_PI_2 = 1.5707963267948966D; /// M_SQRT1_2 = 0.70710678118654752440 - public const double M_SQRT1_2 = 0.707106781186548D; + public const double M_SQRT1_2 = 0.7071067811865476D; /// M_SQRT2 = 1.41421356237309504880 - public const double M_SQRT2 = 1.4142135623731D; + public const double M_SQRT2 = 1.4142135623730951D; /// MAX_REORDER_DELAY = 16 public const int MAX_REORDER_DELAY = 0x10; /// MAX_STD_TIMEBASES = (30*12+30+3+6) public const int MAX_STD_TIMEBASES = 0x1e * 0xc + 0x1e + 0x3 + 0x6; + // public static MKBETAG = (a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((unsigned)(a) << 24)); + // public static MKTAG = (a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((unsigned)(d) << 24)); /// PARSER_FLAG_COMPLETE_FRAMES = 0x0001 public const int PARSER_FLAG_COMPLETE_FRAMES = 0x1; /// PARSER_FLAG_FETCHED_OFFSET = 0x0004 @@ -1557,6 +1609,10 @@ public unsafe static partial class ffmpeg public const int PP_PICT_TYPE_QP2 = 0x10; /// PP_QUALITY_MAX = 0x6 public const int PP_QUALITY_MAX = 0x6; + // public static PUT_UTF16 = (val, tmp, PUT_16BIT){uint32_t in = val;if (in < 0x10000) {tmp = in;PUT_16BIT} else {tmp = 0xD800 | ((in - 0x10000) >> 10);PUT_16BITtmp = 0xDC00 | ((in - 0x10000) & 0x3FF);PUT_16BIT}}; + // public static PUT_UTF8 = (val, tmp, PUT_BYTE){int bytes, shift;uint32_t in = val;if (in < 0x80) {tmp = in;PUT_BYTE} else {bytes = (av_log2(in) + 4) / 5;shift = (bytes - 1) * 6;tmp = (256 - (256 >> bytes)) | (in >> shift);PUT_BYTEwhile (shift >= 6) {shift -= 6;tmp = 0x80 | ((in >> shift) & 0x3f);PUT_BYTE}}}; + // public static ROUNDED_DIV = (a,b) (((a)>=0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b)); + // public static RSHIFT = (a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b)); /// SLICE_FLAG_ALLOW_FIELD = 0x0002 public const int SLICE_FLAG_ALLOW_FIELD = 0x2; /// SLICE_FLAG_ALLOW_PLANE = 0x0004 diff --git a/FFmpeg.AutoGen/FFmpeg.structs.g.cs b/FFmpeg.AutoGen/FFmpeg.structs.g.cs index eb5e31bc..19749355 100644 --- a/FFmpeg.AutoGen/FFmpeg.structs.g.cs +++ b/FFmpeg.AutoGen/FFmpeg.structs.g.cs @@ -180,7 +180,7 @@ public unsafe struct AVFrame public int @nb_extended_buf; public AVFrameSideData** @side_data; public int @nb_side_data; - /// Frame flags, a combination of + /// Frame flags, a combination of lavu_frame_flags public int @flags; /// MPEG vs JPEG YUV range. - encoding: Set by user - decoding: Set by libavcodec public AVColorRange @color_range; @@ -1940,7 +1940,7 @@ public unsafe struct AVOutputFormat /// Format I/O context. New fields can be added to the end with minor version bumps. Removal, reordering and changes to existing fields require a major version bump. sizeof(AVFormatContext) must not be used outside libav*, use avformat_alloc_context() to create an AVFormatContext. public unsafe struct AVFormatContext { - /// A class for logging and Exports (de)muxer private options if they exist. + /// A class for logging and avoptions. Set by avformat_alloc_context(). Exports (de)muxer private options if they exist. public AVClass* @av_class; /// The input container format. public AVInputFormat* @iformat; @@ -2338,7 +2338,7 @@ public unsafe struct AVFilter public AVFilter_preinit_func @preinit; /// Filter initialization function. public AVFilter_init_func @init; - /// Should be set instead of want to pass a dictionary of AVOptions to nested contexts that are allocated during init. + /// Should be set instead of AVFilter.init "init" by the filters that want to pass a dictionary of AVOptions to nested contexts that are allocated during init. public AVFilter_init_dict_func @init_dict; /// Filter uninitialization function. public AVFilter_uninit_func @uninit; @@ -2447,7 +2447,7 @@ public unsafe struct AVFilterGraph public int @nb_threads; /// Opaque object for libavfilter internal use. public AVFilterGraphInternal* @internal; - /// Opaque user data. May be set by the caller to an arbitrary value, e.g. to be used from callbacks like Libavfilter will not touch this field in any way. + /// Opaque user data. May be set by the caller to an arbitrary value, e.g. to be used from callbacks like AVFilterGraph.execute. Libavfilter will not touch this field in any way. public void* @opaque; /// This callback may be set by the caller immediately after allocating the graph and before adding any filters to it, to provide a custom multithreading implementation. public AVFilterGraph_execute_func @execute; diff --git a/FFmpeg.AutoGen/FFmpeg.structs.incomplete.g.cs b/FFmpeg.AutoGen/FFmpeg.structs.incomplete.g.cs index d950184c..cbc248d5 100644 --- a/FFmpeg.AutoGen/FFmpeg.structs.incomplete.g.cs +++ b/FFmpeg.AutoGen/FFmpeg.structs.incomplete.g.cs @@ -47,7 +47,7 @@ public unsafe struct AVHWFramesInternal { } - /// The libswresample context. Unlike libavcodec and libavformat, this structure is opaque. This means that if you would like to set options, you must use the structure. + /// The libswresample context. Unlike libavcodec and libavformat, this structure is opaque. This means that if you would like to set options, you must use the avoptions API and cannot directly set values to members of the structure. /// This struct is incomplete. public unsafe struct SwrContext { diff --git a/FFmpeg.AutoGen/Native/LibraryLoader.cs b/FFmpeg.AutoGen/Native/LibraryLoader.cs index 3207cf4c..1206e2d4 100644 --- a/FFmpeg.AutoGen/Native/LibraryLoader.cs +++ b/FFmpeg.AutoGen/Native/LibraryLoader.cs @@ -23,7 +23,7 @@ static LibraryLoader() throw new PlatformNotSupportedException(); #endif }; - + switch (GetPlatformId()) { case PlatformID.MacOSX: