├── _config.yml ├── AVDump3CL ├── AVD3Icon.ico ├── AVD3CLException.cs ├── Properties │ ├── launchSettings.json │ └── PublishProfiles │ │ ├── CrossPlatform.pubxml │ │ ├── Windows.pubxml │ │ └── SelfContained.pubxml ├── AVD3CLSettings.cs └── AVDump3CL.csproj ├── AVDump3Tests ├── MediaInfo.dll ├── MediaInfo.so ├── AVDump3NativeLib.dll ├── AVDump3NativeLib.so ├── HashTestVectors.xml └── AVDump3Tests.csproj ├── AVDump3Lib ├── Libs │ ├── BXmlLib.dll │ ├── MediaInfo-linux-x64.so │ ├── MediaInfo-linux-arm64.so │ ├── MediaInfo-windows-x64.dll │ ├── MediaInfo-linux-x64-musl.so │ ├── AVDump3NativeLib-linux-x64.so │ ├── MediaInfo-linux-arm64-musl.so │ ├── AVDump3NativeLib-linux-arm64.so │ └── AVDump3NativeLib-windows-x64.dll ├── Processing │ ├── HashAlgorithms │ │ ├── XXHashNativeHashAlgorithm.cs │ │ ├── NullHashAlgorithm.cs │ │ ├── Md4NativeHashAlgorithm.cs │ │ ├── SHA1NativeHashAlgorithm.cs │ │ ├── Crc32NativeHashAlgorithm.cs │ │ ├── Crc32CIntelHashAlgorithm.cs │ │ ├── TigerNativeHashalgorithm.cs │ │ ├── SHA256NativeHashAlgorithm.cs │ │ ├── SHA3NativeHashAlgorithm.cs │ │ ├── KeccakNativeHashAlgorithm.cs │ │ ├── Crc32HashAlgorithm.cs │ │ └── AVDHashAlgorithm.cs │ ├── BlockConsumers │ │ ├── Ogg │ │ │ ├── BitStreams │ │ │ │ ├── IOGMStream.cs │ │ │ │ ├── Subtitle │ │ │ │ │ ├── SubtitleOGGBitStream.cs │ │ │ │ │ └── OGMTextOGGBitStream.cs │ │ │ │ ├── UnknownOGGBitStream.cs │ │ │ │ ├── Audio │ │ │ │ │ ├── CeltOGGBitStream.cs │ │ │ │ │ ├── AudioOGGBitStream.cs │ │ │ │ │ ├── FlacOGGBitStream.cs │ │ │ │ │ ├── VorbisOGGBitStream.cs │ │ │ │ │ └── OGMAudioOGGBitStream.cs │ │ │ │ ├── Video │ │ │ │ │ ├── VideoOGGBitStream.cs │ │ │ │ │ ├── OGMVideoOGGBitStream.cs │ │ │ │ │ └── TheoraOGGBitStream.cs │ │ │ │ └── OGGBitStream.cs │ │ │ ├── OggParser.cs │ │ │ ├── OggFile.cs │ │ │ └── OggBlockDataSource.cs │ │ ├── CopyToFileBlockConsumer.cs │ │ ├── Matroska │ │ │ ├── Segment │ │ │ │ ├── Tags │ │ │ │ │ ├── TagsSection.cs │ │ │ │ │ ├── TagSection.cs │ │ │ │ │ ├── SimpleTagSection.cs │ │ │ │ │ └── TargetsSection.cs │ │ │ │ ├── SeekHead │ │ │ │ │ ├── SeekHeadSection.cs │ │ │ │ │ └── SeekSection.cs │ │ │ │ ├── Chapters │ │ │ │ │ ├── ChaptersSection.cs │ │ │ │ │ ├── ChapterProcessCommandSection.cs │ │ │ │ │ ├── ChapterTrackSection.cs │ │ │ │ │ ├── ChapterProcessSection.cs │ │ │ │ │ ├── ChapterDisplaySection.cs │ │ │ │ │ └── EditionEntrySection.cs │ │ │ │ ├── Cues │ │ │ │ │ ├── CuesSection.cs │ │ │ │ │ ├── CuePointSection.cs │ │ │ │ │ ├── CueReferenceSection.cs │ │ │ │ │ └── CueTrackPositionsSection.cs │ │ │ │ ├── Attachments │ │ │ │ │ ├── AttachmentsSection.cs │ │ │ │ │ └── AttachedFileSection.cs │ │ │ │ ├── Tracks │ │ │ │ │ ├── ContentCompressionSection.cs │ │ │ │ │ ├── TracksSection.cs │ │ │ │ │ ├── ContentEncodingSection.cs │ │ │ │ │ ├── AudioSection.cs │ │ │ │ │ └── ContentEncryptionSection.cs │ │ │ │ └── SegmentInfo │ │ │ │ │ └── ChapterTranslateSection.cs │ │ │ ├── AVDEbmlBlockDataSource.cs │ │ │ ├── MatroskaParser.cs │ │ │ ├── EbmlList.cs │ │ │ ├── EbmlHeader │ │ │ │ └── EbmlHeaderSection.cs │ │ │ ├── MatroskaFile.cs │ │ │ └── Section.cs │ │ ├── MP4 │ │ │ ├── MP4Parser.cs │ │ │ ├── AVDMP4BlockDataSource.cs │ │ │ └── MP4Node.cs │ │ ├── BlockConsumer.cs │ │ ├── BlockConsumerFactory.cs │ │ ├── BlockConsumerSelector.cs │ │ └── HashCalculator.cs │ ├── BlockBuffers │ │ ├── Sources │ │ │ ├── IBlockSource.cs │ │ │ └── StreamBlockSource.cs │ │ ├── MirroredBufferPool.cs │ │ ├── MirroredBufferPoolPolyfill.cs │ │ ├── BlockStreamReader.cs │ │ └── MirroredBuffer.cs │ ├── FileMove │ │ ├── IFileMoveConfigure.cs │ │ ├── IFileMoveScript.cs │ │ ├── FileMoveContext.cs │ │ ├── FileMoveScriptByAssembly.cs │ │ ├── FileMoveScriptByInlineScript.cs │ │ └── FileMoveScriptByScriptFile.cs │ ├── StreamProvider │ │ ├── IStreamProvider.cs │ │ └── NullStreamProvider.cs │ ├── BlockConsumerFilterEventArgs.cs │ ├── CPUInstructions.cs │ ├── IAVD3ProcessingModule.cs │ └── StreamConsumer │ │ └── StreamConsumerFactory.cs ├── Properties │ ├── launchSettings.json │ └── PublishProfiles │ │ └── FolderProfile.pubxml ├── Settings │ ├── ISettingsHandler.cs │ ├── Core │ │ ├── ISettingGroup.cs │ │ ├── ISettingProperty.cs │ │ ├── ISettingStore.cs │ │ ├── SettingGroup.cs │ │ ├── SettingStore.cs │ │ └── SettingProperty.cs │ ├── SettingsHandlers │ │ └── ICLSettingsHandler.cs │ └── AVD3SettingsModule.cs ├── Information │ ├── MetaInfo │ │ ├── Core │ │ │ ├── MetaInfoContainerType.cs │ │ │ ├── MetaInfoItemType.cs │ │ │ ├── FileMetaInfo.cs │ │ │ ├── CompositeMetaDataProvider.cs │ │ │ ├── MetaInfoItem.cs │ │ │ ├── MetaInfoContainer.cs │ │ │ └── MetaDataProvider.cs │ │ └── HashProvider.cs │ ├── FormatHeaders │ │ ├── WaveFormatEx.cs │ │ ├── VMpeg4IsoAvcHeader.cs │ │ └── BitmapInfoHeader.cs │ ├── InfoProvider │ │ └── InfoProviderFactory.cs │ └── AVD3InformationModule.cs ├── UI │ └── AVD3UIException.cs ├── Reporting │ ├── Core │ │ ├── IReport.cs │ │ ├── ReportFactory.cs │ │ └── XmlReport.cs │ ├── AVD3ReportingModule.cs │ └── Reports │ │ ├── MatroskaReport.cs │ │ └── AVD3Report.cs ├── Modules │ ├── IAVD3Module.cs │ └── AVD3ModuleManagement.cs ├── DependencyInjection │ └── ServiceCollectionExtension.cs ├── Misc │ ├── FileTraversal.cs │ ├── KMeans.cs │ └── AppendLineManager.cs └── AVDump3Lib.csproj ├── AVDump3NativeLib ├── src │ ├── AVDump3NativeLib.so │ ├── AVD3NativeLibApi.c │ ├── DLLDefines.h │ └── CRC32C.c ├── Makefile └── AVDump3NativeLib.vcxproj.filters ├── .dockerhub ├── hooks │ └── build ├── Dockerfile └── Dockerfile-Entrypoint.sh ├── AVDump3GUI ├── Controls │ ├── Settings │ │ ├── SettingValueDisplayType.cs │ │ ├── ISettingGroupItem.cs │ │ ├── SettingValueConverter.cs │ │ ├── EnumToStringsValueConverter.cs │ │ ├── ISettingPropertyItem.cs │ │ ├── SettingValueTemplateSelector.cs │ │ ├── SettingsView.xaml.cs │ │ └── SettingValueDisplay.cs │ └── Files │ │ ├── FilesView.xaml │ │ └── FilesView.xaml.cs ├── ViewModels │ ├── AVDFile.cs │ ├── AVD3Console.cs │ ├── SettingsGroupViewModel.cs │ └── BytesReadProgress.cs ├── App.xaml ├── AssemblyInfo.cs ├── App.xaml.cs ├── AVD3GUISettings.cs ├── Converters │ ├── InverseBooleanConverter.cs │ └── BoolToVisibilityHiddenConverter.cs ├── AVDump3GUI.csproj └── Views │ └── MainWindow.xaml.cs ├── .editorconfig ├── LICENSE ├── Directory.Build.props └── .gitattributes /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-dinky -------------------------------------------------------------------------------- /AVDump3CL/AVD3Icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DvdKhl/AVDump3/HEAD/AVDump3CL/AVD3Icon.ico -------------------------------------------------------------------------------- /AVDump3Tests/MediaInfo.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DvdKhl/AVDump3/HEAD/AVDump3Tests/MediaInfo.dll -------------------------------------------------------------------------------- /AVDump3Tests/MediaInfo.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DvdKhl/AVDump3/HEAD/AVDump3Tests/MediaInfo.so -------------------------------------------------------------------------------- /AVDump3Lib/Libs/BXmlLib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DvdKhl/AVDump3/HEAD/AVDump3Lib/Libs/BXmlLib.dll -------------------------------------------------------------------------------- /AVDump3Lib/Processing/HashAlgorithms/XXHashNativeHashAlgorithm.cs: -------------------------------------------------------------------------------- 1 | namespace AVDump3Lib.Processing.HashAlgorithms; 2 | -------------------------------------------------------------------------------- /AVDump3Tests/AVDump3NativeLib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DvdKhl/AVDump3/HEAD/AVDump3Tests/AVDump3NativeLib.dll -------------------------------------------------------------------------------- /AVDump3Tests/AVDump3NativeLib.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DvdKhl/AVDump3/HEAD/AVDump3Tests/AVDump3NativeLib.so -------------------------------------------------------------------------------- /AVDump3Lib/Libs/MediaInfo-linux-x64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DvdKhl/AVDump3/HEAD/AVDump3Lib/Libs/MediaInfo-linux-x64.so -------------------------------------------------------------------------------- /AVDump3Lib/Libs/MediaInfo-linux-arm64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DvdKhl/AVDump3/HEAD/AVDump3Lib/Libs/MediaInfo-linux-arm64.so -------------------------------------------------------------------------------- /AVDump3Lib/Libs/MediaInfo-windows-x64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DvdKhl/AVDump3/HEAD/AVDump3Lib/Libs/MediaInfo-windows-x64.dll -------------------------------------------------------------------------------- /AVDump3NativeLib/src/AVDump3NativeLib.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DvdKhl/AVDump3/HEAD/AVDump3NativeLib/src/AVDump3NativeLib.so -------------------------------------------------------------------------------- /AVDump3Lib/Libs/MediaInfo-linux-x64-musl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DvdKhl/AVDump3/HEAD/AVDump3Lib/Libs/MediaInfo-linux-x64-musl.so -------------------------------------------------------------------------------- /AVDump3NativeLib/src/AVD3NativeLibApi.c: -------------------------------------------------------------------------------- 1 | #include "AVD3NativeLibApi.h" 2 | 3 | void FreeHashObject(void *obj) { 4 | free(obj); 5 | } 6 | -------------------------------------------------------------------------------- /AVDump3Lib/Libs/AVDump3NativeLib-linux-x64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DvdKhl/AVDump3/HEAD/AVDump3Lib/Libs/AVDump3NativeLib-linux-x64.so -------------------------------------------------------------------------------- /AVDump3Lib/Libs/MediaInfo-linux-arm64-musl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DvdKhl/AVDump3/HEAD/AVDump3Lib/Libs/MediaInfo-linux-arm64-musl.so -------------------------------------------------------------------------------- /AVDump3Lib/Libs/AVDump3NativeLib-linux-arm64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DvdKhl/AVDump3/HEAD/AVDump3Lib/Libs/AVDump3NativeLib-linux-arm64.so -------------------------------------------------------------------------------- /AVDump3Lib/Libs/AVDump3NativeLib-windows-x64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DvdKhl/AVDump3/HEAD/AVDump3Lib/Libs/AVDump3NativeLib-windows-x64.dll -------------------------------------------------------------------------------- /AVDump3Lib/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "AVDump3Lib": { 4 | "commandName": "Project" 5 | } 6 | } 7 | } -------------------------------------------------------------------------------- /.dockerhub/hooks/build: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | apt-get install -y curl zip 4 | 5 | docker build --build-arg TagName=$SOURCE_BRANCH -t $IMAGE_NAME . -------------------------------------------------------------------------------- /AVDump3GUI/Controls/Settings/SettingValueDisplayType.cs: -------------------------------------------------------------------------------- 1 | namespace AVDump3GUI.Controls.Settings; 2 | 3 | public enum SettingValueDisplayType { Default, Current, Active} 4 | -------------------------------------------------------------------------------- /AVDump3Lib/Settings/ISettingsHandler.cs: -------------------------------------------------------------------------------- 1 | namespace AVDump3Lib.Settings.Core; 2 | 3 | public interface ISettingsHandler { 4 | void Register(IEnumerable settingProperties); 5 | } 6 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/Ogg/BitStreams/IOGMStream.cs: -------------------------------------------------------------------------------- 1 | namespace AVDump3Lib.Processing.BlockConsumers.Ogg.BitStreams; 2 | 3 | public interface IOGMStream { 4 | string ActualCodecName { get; } 5 | } 6 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockBuffers/Sources/IBlockSource.cs: -------------------------------------------------------------------------------- 1 | namespace AVDump3Lib.Processing.BlockBuffers.Sources; 2 | 3 | public interface IBlockSource { 4 | int Read(Span block); 5 | long Length { get; } 6 | } 7 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | [*.cs] 2 | 3 | # CA1303: Do not pass literals as localized parameters 4 | dotnet_diagnostic.CA1303.severity = none 5 | csharp_space_after_keywords_in_control_flow_statements=false 6 | csharp_style_namespace_declarations=file_scoped:suggestion 7 | -------------------------------------------------------------------------------- /AVDump3Lib/Information/MetaInfo/Core/MetaInfoContainerType.cs: -------------------------------------------------------------------------------- 1 | namespace AVDump3Lib.Information.MetaInfo.Core; 2 | 3 | public class MetaInfoContainerType { 4 | public string Name { get; } 5 | 6 | public MetaInfoContainerType(string name) { 7 | Name = name; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /AVDump3Lib/Settings/Core/ISettingGroup.cs: -------------------------------------------------------------------------------- 1 | using System.Resources; 2 | 3 | namespace AVDump3Lib.Settings.Core; 4 | 5 | public interface ISettingGroup { 6 | string Name { get; } 7 | ISettingGroup? Parent { get; } 8 | string FullName { get; } 9 | ResourceManager ResourceManager { get; } 10 | } 11 | -------------------------------------------------------------------------------- /AVDump3CL/AVD3CLException.cs: -------------------------------------------------------------------------------- 1 | using AVDump3Lib; 2 | 3 | namespace AVDump3CL; 4 | 5 | public class AVD3CLException : AVD3LibException { 6 | public AVD3CLException(string message, Exception innerException) : base(message, innerException) { } 7 | public AVD3CLException(string message) : base(message) { } 8 | } 9 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/Ogg/BitStreams/Subtitle/SubtitleOGGBitStream.cs: -------------------------------------------------------------------------------- 1 | namespace AVDump3Lib.Processing.BlockConsumers.Ogg.BitStreams; 2 | 3 | public abstract class SubtitleOGGBitStream : OGGBitStream { 4 | public SubtitleOGGBitStream(bool isOfficiallySupported) : base(isOfficiallySupported) { } 5 | } 6 | -------------------------------------------------------------------------------- /AVDump3Lib/UI/AVD3UIException.cs: -------------------------------------------------------------------------------- 1 | using AVDump3Lib; 2 | 3 | namespace AVDump3Lib.UI; 4 | 5 | public class AVD3UIException : AVD3LibException { 6 | public AVD3UIException(string message, Exception innerException) : base(message, innerException) { } 7 | public AVD3UIException(string message) : base(message) { } 8 | } 9 | -------------------------------------------------------------------------------- /AVDump3Lib/Reporting/Core/IReport.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | namespace AVDump3Lib.Reporting.Core; 4 | 5 | public interface IReport { 6 | string FileExtension { get; } 7 | string ReportToString(Encoding encoding); 8 | void SaveToFile(string filePath, string reportContentPrefix, Encoding encoding); 9 | } 10 | -------------------------------------------------------------------------------- /.dockerhub/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/dotnet/core/runtime:latest 2 | ARG TagName 3 | 4 | WORKDIR /AVD3 5 | COPY Dockerfile-Entrypoint.sh / 6 | 7 | RUN apt-get update && apt-get install -y curl zip 8 | RUN /Dockerfile-Entrypoint.sh USEVERSION $TagName NOOP 9 | 10 | ENTRYPOINT ["/Dockerfile-Entrypoint.sh"] 11 | 12 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/FileMove/IFileMoveConfigure.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | 3 | namespace AVDump3Lib.Processing.FileMove; 4 | 5 | public interface IFileMoveConfigure { 6 | void ConfigureServiceCollection(IServiceCollection services); 7 | string? ReplaceToken(string key, FileMoveContext ctx); 8 | } 9 | -------------------------------------------------------------------------------- /AVDump3CL/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "AVDump3CL": { 4 | "commandName": "Project", 5 | "commandLineArgs": "FROMFILE DebugParams.txt", 6 | "nativeDebugging": false 7 | }, 8 | "WSL": { 9 | "commandName": "WSL2", 10 | "distributionName": "" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /AVDump3GUI/ViewModels/AVDFile.cs: -------------------------------------------------------------------------------- 1 | using Prism.Mvvm; 2 | using System.IO; 3 | 4 | namespace AVDump3GUI.ViewModels; 5 | 6 | public class AVDFile: BindableBase { 7 | public FileInfo Info { get; set; } 8 | 9 | public bool Completed { get => completed; set => SetProperty(ref completed, value); } 10 | private bool completed; 11 | } 12 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/Ogg/BitStreams/UnknownOGGBitStream.cs: -------------------------------------------------------------------------------- 1 | namespace AVDump3Lib.Processing.BlockConsumers.Ogg.BitStreams; 2 | 3 | public class UnknownOGGBitStream : OGGBitStream { 4 | public UnknownOGGBitStream() : base(false) { } 5 | 6 | public override string CodecName => "Unknown"; 7 | public override string CodecVersion { get; protected set; } 8 | } 9 | -------------------------------------------------------------------------------- /AVDump3Lib/Settings/SettingsHandlers/ICLSettingsHandler.cs: -------------------------------------------------------------------------------- 1 | using AVDump3Lib.Settings.Core; 2 | 3 | namespace AVDump3Lib.Settings.CLArguments; 4 | 5 | public interface ICLSettingsHandler : ISettingsHandler { 6 | bool ParseArgs(string[] args, ICollection unnamedArgs); 7 | void PrintHelp(bool detailed); 8 | void PrintHelpTopic(string topic, bool detailed); 9 | } 10 | -------------------------------------------------------------------------------- /AVDump3GUI/Controls/Settings/ISettingGroupItem.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Immutable; 2 | using System.Resources; 3 | 4 | namespace AVDump3GUI.Controls.Settings; 5 | 6 | public interface ISettingGroupItem { 7 | string Description { get; } 8 | string Name { get; } 9 | ImmutableArray Properties { get; } 10 | ResourceManager ResourceManager { get; } 11 | } 12 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/FileMove/IFileMoveScript.cs: -------------------------------------------------------------------------------- 1 | using AVDump3Lib.Information.MetaInfo.Core; 2 | 3 | namespace AVDump3Lib.Processing.FileMove; 4 | 5 | public interface IFileMoveScript : IDisposable { 6 | void Load(); 7 | bool CanReload { get; } 8 | 9 | Task GetFilePathAsync(FileMetaInfo fileMetaInfo); 10 | bool SourceChanged(); 11 | IFileMoveScript CreateScope(); 12 | } 13 | -------------------------------------------------------------------------------- /AVDump3GUI/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockBuffers/Sources/StreamBlockSource.cs: -------------------------------------------------------------------------------- 1 | namespace AVDump3Lib.Processing.BlockBuffers.Sources; 2 | 3 | public class StreamBlockSource : IBlockSource { 4 | private readonly Stream source; 5 | public string Path { get; } 6 | public long Length { get; } 7 | 8 | public StreamBlockSource(Stream source) { this.source = source; Length = source.Length; } 9 | 10 | public int Read(Span block) => source.Read(block); 11 | } 12 | -------------------------------------------------------------------------------- /AVDump3Lib/Settings/Core/ISettingProperty.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Immutable; 2 | 3 | namespace AVDump3Lib.Settings.Core; 4 | 5 | public interface ISettingProperty { 6 | ImmutableArray AlternativeNames { get; } 7 | object? DefaultValue { get; } 8 | ISettingGroup Group { get; } 9 | string Name { get; } 10 | Type ValueType { get; } 11 | object? UserValueType { get; } 12 | 13 | object? ToObject(string? stringValue); 14 | string? ToString(object? objectValue); 15 | } 16 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/Ogg/BitStreams/Audio/CeltOGGBitStream.cs: -------------------------------------------------------------------------------- 1 | namespace AVDump3Lib.Processing.BlockConsumers.Ogg.BitStreams; 2 | 3 | public class CeltOGGBitStream : AudioOGGBitStream { 4 | public override string CodecName => "Celt"; 5 | public override string CodecVersion { get; protected set; } 6 | public override long SampleCount => LastGranulePosition; 7 | public override double SampleRate { get; } 8 | 9 | public CeltOGGBitStream() 10 | : base(true) { 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /AVDump3GUI/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo( 4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 5 | //(used if a resource is not found in the page, 6 | // or application resource dictionaries) 7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 8 | //(used if a resource is not found in the page, 9 | // app, or any theme specific resource dictionaries) 10 | )] 11 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/StreamProvider/IStreamProvider.cs: -------------------------------------------------------------------------------- 1 | namespace AVDump3Lib.Processing.StreamProvider; 2 | 3 | public abstract class ProvidedStream : IDisposable { 4 | public object Tag { get; private set; } 5 | public Stream Stream { get; } 6 | public abstract void Dispose(); 7 | 8 | public ProvidedStream(object tag, Stream stream) { 9 | Tag = tag; 10 | Stream = stream; 11 | } 12 | } 13 | 14 | public interface IStreamProvider { 15 | IEnumerable GetConsumingEnumerable(CancellationToken ct); 16 | } 17 | -------------------------------------------------------------------------------- /AVDump3CL/Properties/PublishProfiles/CrossPlatform.pubxml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | FileSystem 8 | Release 9 | Any CPU 10 | net6.0 11 | bin\x64\Release\net6.0\publish\ 12 | false 13 | 14 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/Ogg/BitStreams/Audio/AudioOGGBitStream.cs: -------------------------------------------------------------------------------- 1 | namespace AVDump3Lib.Processing.BlockConsumers.Ogg.BitStreams; 2 | 3 | public abstract class AudioOGGBitStream : OGGBitStream { 4 | public AudioOGGBitStream(bool isOfficiallySupported) : base(isOfficiallySupported) { } 5 | public abstract long SampleCount { get; } 6 | public abstract double SampleRate { get; } 7 | public virtual TimeSpan Duration => TimeSpan.FromSeconds(SampleCount / SampleRate); 8 | public int ChannelCount { get; protected set; } 9 | } 10 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/HashAlgorithms/NullHashAlgorithm.cs: -------------------------------------------------------------------------------- 1 | namespace AVDump3Lib.Processing.HashAlgorithms; 2 | 3 | public sealed class NullHashAlgorithm : AVDHashAlgorithm { 4 | public override int BlockSize { get; } 5 | 6 | protected override void InitializeInternal() { } 7 | public override ReadOnlySpan TransformFinalBlock(in ReadOnlySpan data) => ReadOnlySpan.Empty; 8 | protected override unsafe void HashCore(in ReadOnlySpan data) { } 9 | 10 | public NullHashAlgorithm(int blockSize) => BlockSize = blockSize; 11 | } 12 | -------------------------------------------------------------------------------- /AVDump3NativeLib/src/DLLDefines.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined _WIN32 || defined __CYGWIN__ 4 | #ifdef __GNUC__ 5 | #define DLL_PUBLIC __attribute__ ((dllexport)) 6 | #else 7 | #define DLL_PUBLIC __declspec(dllexport) // Note: actually gcc seems to also supports this syntax. 8 | #endif 9 | #define DLL_LOCAL 10 | #else 11 | #if __GNUC__ >= 4 12 | #define DLL_PUBLIC __attribute__ ((visibility ("default"))) 13 | #define DLL_LOCAL __attribute__ ((visibility ("hidden"))) 14 | #else 15 | #define DLL_PUBLIC 16 | #define DLL_LOCAL 17 | #endif 18 | #endif 19 | -------------------------------------------------------------------------------- /AVDump3Lib/Settings/Core/ISettingStore.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Immutable; 2 | 3 | namespace AVDump3Lib.Settings.Core; 4 | 5 | public interface ISettingStore { 6 | static object Unset { get; } = new object(); 7 | 8 | ImmutableArray SettingProperties { get; } 9 | 10 | bool ContainsProperty(ISettingProperty settingProperty); 11 | object? GetPropertyValue(ISettingProperty settingProperty); 12 | object? GetRawPropertyValue(ISettingProperty settingProperty); 13 | void SetPropertyValue(ISettingProperty settingProperty, object? value); 14 | } 15 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/Ogg/BitStreams/Video/VideoOGGBitStream.cs: -------------------------------------------------------------------------------- 1 | namespace AVDump3Lib.Processing.BlockConsumers.Ogg.BitStreams; 2 | 3 | public abstract class VideoOGGBitStream : OGGBitStream { 4 | public VideoOGGBitStream(bool isOfficiallySupported) : base(isOfficiallySupported) { } 5 | 6 | public abstract long FrameCount { get; } 7 | public abstract double FrameRate { get; } 8 | public int Width { get; protected set; } 9 | public int Height { get; protected set; } 10 | public virtual TimeSpan Duration => TimeSpan.FromSeconds(FrameCount / FrameRate); 11 | } 12 | -------------------------------------------------------------------------------- /AVDump3Lib/Properties/PublishProfiles/FolderProfile.pubxml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | Release 8 | x64 9 | bin\Release\netcoreapp3.1\publish\ 10 | FileSystem 11 | netcoreapp3.1 12 | false 13 | 14 | -------------------------------------------------------------------------------- /AVDump3GUI/ViewModels/AVD3Console.cs: -------------------------------------------------------------------------------- 1 | using AVDump3Lib.UI; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace AVDump3GUI.ViewModels; 6 | 7 | public class AVD3Console : IAVD3UIConsole { 8 | public event Action ConsoleWrite = delegate { }; 9 | 10 | private class NopDisposable : IDisposable { public void Dispose() { } } 11 | public IDisposable LockConsole() { return new NopDisposable(); } 12 | public void WriteLine(IEnumerable values) { 13 | lock(this) ConsoleWrite(string.Join("\n", values)); 14 | } 15 | public void WriteLine(string value) { 16 | lock(this) ConsoleWrite(value); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumerFilterEventArgs.cs: -------------------------------------------------------------------------------- 1 | using AVDump3Lib.Processing.StreamConsumer; 2 | 3 | namespace AVDump3Lib.Processing; 4 | 5 | public class BlockConsumerFilterEventArgs : EventArgs { 6 | public IStreamConsumerCollection StreamConsumerCollection { get; } 7 | public string BlockConsumerName { get; } 8 | 9 | public bool Accepted { get; private set; } 10 | public void Accept() { Accepted = true; } 11 | 12 | public BlockConsumerFilterEventArgs(IStreamConsumerCollection streamConsumerCollection, string blockConsumerName) { 13 | StreamConsumerCollection = streamConsumerCollection; 14 | BlockConsumerName = blockConsumerName; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/Ogg/BitStreams/Audio/FlacOGGBitStream.cs: -------------------------------------------------------------------------------- 1 | namespace AVDump3Lib.Processing.BlockConsumers.Ogg.BitStreams; 2 | 3 | public class FlacOGGBitStream : AudioOGGBitStream { 4 | public override string CodecName => "Flac"; 5 | public override string CodecVersion { get; protected set; } 6 | public override long SampleCount => LastGranulePosition; 7 | public override double SampleRate { get; } 8 | 9 | public FlacOGGBitStream(ReadOnlySpan header) 10 | : base(true) { 11 | SampleRate = header[33] << 12 | header[34] << 4 | (header[35] & 0xF0) >> 4; //TODO: check offsets 12 | ChannelCount = ((header[35] & 0x0E) >> 1) + 1; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /AVDump3GUI/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using AVDump3GUI.Views; 2 | using Prism.Ioc; 3 | using Prism.Unity; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Configuration; 7 | using System.Data; 8 | using System.Linq; 9 | using System.Threading.Tasks; 10 | using System.Windows; 11 | 12 | namespace AVDump3GUI { 13 | /// 14 | /// Interaction logic for App.xaml 15 | /// 16 | public partial class App : PrismApplication { 17 | protected override Window CreateShell() { 18 | var w = Container.Resolve(); 19 | return w; 20 | } 21 | 22 | protected override void RegisterTypes(IContainerRegistry containerRegistry) { 23 | 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /AVDump3GUI/AVD3GUISettings.cs: -------------------------------------------------------------------------------- 1 | using AVDump3Lib.Settings.Core; 2 | using AVDump3Lib.UI; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Resources; 9 | 10 | namespace AVDump3GUI; 11 | 12 | 13 | public class AVD3GUISettings : AVD3UISettings { 14 | public static new ResourceManager ResourceManager => new ResourceManagerMerged(Lang.ResourceManager, AVD3UISettings.ResourceManager); 15 | 16 | public AVD3GUISettings(ISettingStore store) : base(store) { 17 | } 18 | 19 | public static new IEnumerable GetProperties() { 20 | return AVD3UISettings.GetProperties(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /AVDump3Lib/Modules/IAVD3Module.cs: -------------------------------------------------------------------------------- 1 | namespace AVDump3Lib.Modules; 2 | 3 | public class ModuleInitResult { 4 | public bool CancelStartup { get; private set; } 5 | public string Reason { get; private set; } 6 | 7 | public ModuleInitResult(bool cancelStartup) { CancelStartup = cancelStartup; } 8 | public ModuleInitResult(string cancelReason) { Cancel(cancelReason); } 9 | 10 | public void Cancel() { Cancel(""); } 11 | public void Cancel(string reason) { 12 | CancelStartup = true; 13 | Reason = reason; 14 | } 15 | } 16 | 17 | public interface IAVD3Module { 18 | void Initialize(IReadOnlyCollection modules); 19 | ModuleInitResult Initialized(); 20 | 21 | void Shutdown(); 22 | } 23 | -------------------------------------------------------------------------------- /AVDump3CL/Properties/PublishProfiles/Windows.pubxml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | FileSystem 8 | Release 9 | x64 10 | netcoreapp2.2 11 | bin\x64\Release\netcoreapp2.2\publish\ 12 | win-x64 13 | false 14 | <_IsPortable>true 15 | 16 | -------------------------------------------------------------------------------- /AVDump3GUI/Controls/Settings/SettingValueConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Data; 3 | using System.Globalization; 4 | 5 | namespace AVDump3GUI.Controls.Settings; 6 | 7 | public class SettingValueConverter : IValueConverter { 8 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { 9 | if(value is ISettingPropertyItem settingProperty) { 10 | return new SettingValueDisplay(settingProperty, (SettingValueDisplayType)parameter); 11 | 12 | } else { 13 | return Binding.DoNothing; 14 | } 15 | } 16 | 17 | 18 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotSupportedException(); 19 | } 20 | -------------------------------------------------------------------------------- /AVDump3GUI/Controls/Settings/EnumToStringsValueConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Windows.Data; 4 | using System.Globalization; 5 | 6 | namespace AVDump3GUI.Controls.Settings; 7 | 8 | public class EnumToStringsValueConverter : IValueConverter { 9 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { 10 | if(value.GetType().IsEnum) { 11 | return Enum.GetNames(value.GetType()).Select(x => Enum.Parse(value.GetType(), x)); 12 | 13 | } else { 14 | return Binding.DoNothing; 15 | } 16 | } 17 | 18 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotSupportedException(); 19 | } 20 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/FileMove/FileMoveContext.cs: -------------------------------------------------------------------------------- 1 | using AVDump3Lib.Information.MetaInfo.Core; 2 | 3 | namespace AVDump3Lib.Processing.FileMove; 4 | 5 | public class FileMoveContext { 6 | public FileMoveContext(Func getHandler, IServiceProvider serviceProvider, FileMetaInfo fileMetaInfo) { 7 | Get = getHandler ?? throw new ArgumentNullException(nameof(getHandler)); 8 | ServiceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); 9 | FileMetaInfo = fileMetaInfo ?? throw new ArgumentNullException(nameof(fileMetaInfo)); 10 | } 11 | 12 | public Func Get { get; } 13 | public FileMetaInfo FileMetaInfo { get; } 14 | public IServiceProvider ServiceProvider { get; } 15 | } 16 | -------------------------------------------------------------------------------- /AVDump3Lib/Information/MetaInfo/Core/MetaInfoItemType.cs: -------------------------------------------------------------------------------- 1 | namespace AVDump3Lib.Information.MetaInfo.Core; 2 | 3 | public class MetaInfoItemType : MetaInfoItemType { 4 | public MetaInfoItemType(string key, string unit) : base(key, unit, typeof(T)) { } 5 | public MetaInfoItemType(string key) : base(key, MetaInfoItemType.DimensionslessUnit, typeof(T)) { } 6 | } 7 | 8 | public class MetaInfoItemType { 9 | public string Key { get; private set; } 10 | public string Unit { get; private set; } 11 | public Type ValueType { get; private set; } 12 | 13 | public MetaInfoItemType(string key, string unit, Type valueType) { 14 | Key = key; 15 | Unit = unit; 16 | ValueType = valueType; 17 | } 18 | 19 | public static string DimensionslessUnit { get; } = "Dimensionsless"; 20 | } 21 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/CopyToFileBlockConsumer.cs: -------------------------------------------------------------------------------- 1 | using AVDump3Lib.Processing.BlockBuffers; 2 | 3 | namespace AVDump3Lib.Processing.BlockConsumers; 4 | 5 | public class CopyToFileBlockConsumer : BlockConsumer { 6 | public string FilePath { get; } 7 | 8 | public CopyToFileBlockConsumer(string name, IBlockStreamReader reader, string filePath) : base(name, reader) { 9 | FilePath = filePath; 10 | } 11 | 12 | protected override void DoWork(CancellationToken ct) { 13 | using var fileStream = File.OpenWrite(FilePath); 14 | ReadOnlySpan block; 15 | do { 16 | ct.ThrowIfCancellationRequested(); 17 | block = Reader.GetBlock(Reader.SuggestedReadLength); 18 | fileStream.Write(block); 19 | } while(Reader.Advance(block.Length)); 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockBuffers/MirroredBufferPool.cs: -------------------------------------------------------------------------------- 1 | namespace AVDump3Lib.Processing.BlockBuffers; 2 | 3 | public interface IMirroredBufferPool { 4 | int BufferSize { get; } 5 | IMirroredBuffer Take(); 6 | void Release(IMirroredBuffer buffer); 7 | } 8 | 9 | public class MirroredBufferPool : IMirroredBufferPool { 10 | public int BufferSize { get; } 11 | 12 | private readonly Stack slots = new(); 13 | 14 | public MirroredBufferPool(int bufferSize) { BufferSize = bufferSize; } 15 | 16 | public IMirroredBuffer Take() { 17 | lock(slots) { 18 | if(slots.Count != 0) { 19 | return slots.Pop(); 20 | } else { 21 | return new MirroredBuffer(BufferSize); 22 | } 23 | } 24 | } 25 | public void Release(IMirroredBuffer buffer) { lock(slots) slots.Push(buffer); } 26 | } 27 | -------------------------------------------------------------------------------- /AVDump3GUI/Controls/Settings/ISettingPropertyItem.cs: -------------------------------------------------------------------------------- 1 | using AVDump3Lib.Settings.Core; 2 | using System; 3 | using System.Collections.Immutable; 4 | 5 | namespace AVDump3GUI.Controls.Settings; 6 | 7 | public interface ISettingPropertyItem { 8 | 9 | ImmutableArray AlternativeNames { get; } 10 | object DefaultValue { get; } 11 | string Description { get; } 12 | string Example { get; } 13 | string Name { get; } 14 | Type ValueType { get; } 15 | //ISettingGroupItem Parent { get; } 16 | object? ToObject(string? stringValue); 17 | string? ToString(object? objectValue); 18 | void UpdateStoredValue(); 19 | 20 | object ValueRaw { get; set; } 21 | 22 | bool IsSet { get; } 23 | bool IsSetAndUnchanged { get; } 24 | bool IsChanged { get; } 25 | 26 | string ValueTypeKey { get; } 27 | object Value { get; set; } 28 | } 29 | -------------------------------------------------------------------------------- /AVDump3CL/Properties/PublishProfiles/SelfContained.pubxml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | FileSystem 8 | Release 9 | x64 10 | netcoreapp3.1 11 | bin\x64\Release\netcoreapp3.1\selfcontained\ 12 | linux-x64 13 | true 14 | False 15 | False 16 | False 17 | 18 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/CPUInstructions.cs: -------------------------------------------------------------------------------- 1 | namespace AVDump3Lib.Processing; 2 | 3 | [Flags] 4 | public enum CPUInstructions : long { 5 | MMX = 1 << 0, 6 | x64 = 1 << 1, 7 | ABM = 1 << 2, 8 | RDRAND = 1 << 3, 9 | BMI1 = 1 << 4, 10 | BMI2 = 1 << 5, 11 | ADX = 1 << 6, 12 | PREFETCHWT1 = 1 << 7, 13 | SSE = 1 << 8, 14 | SSE2 = 1 << 9, 15 | SSE3 = 1 << 10, 16 | SSSE3 = 1 << 11, 17 | SSE41 = 1 << 12, 18 | SSE42 = 1 << 13, 19 | SSE4a = 1 << 14, 20 | AES = 1 << 15, 21 | SHA = 1 << 16, 22 | AVX = 1 << 17, 23 | XOP = 1 << 18, 24 | FMA3 = 1 << 19, 25 | FMA4 = 1 << 20, 26 | AVX2 = 1 << 21, 27 | AVX512F = 1 << 22, 28 | AVX512CD = 1 << 23, 29 | AVX512PF = 1 << 24, 30 | AVX512ER = 1 << 25, 31 | AVX512VL = 1 << 26, 32 | AVX512BW = 1 << 27, 33 | AVX512DQ = 1 << 28, 34 | AVX512IFMA = 1 << 29, 35 | AVX512VBMI = 1 << 30 36 | } 37 | -------------------------------------------------------------------------------- /AVDump3Lib/DependencyInjection/ServiceCollectionExtension.cs: -------------------------------------------------------------------------------- 1 | using AVDump3Lib.Processing.BlockBuffers; 2 | using AVDump3Lib.Processing.StreamConsumer; 3 | using AVDump3Lib.Processing.StreamProvider; 4 | using Microsoft.Extensions.DependencyInjection; 5 | 6 | namespace AVDump3Lib.DependencyInjection; 7 | 8 | public static class ServiceCollectionExtension { 9 | public static IServiceCollection AddAVDump3(this IServiceCollection serviceCollection) { 10 | serviceCollection.AddTransient(); 11 | serviceCollection.AddSingleton(); 12 | serviceCollection.AddTransient(); 13 | serviceCollection.AddTransient(); 14 | 15 | return serviceCollection; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/Matroska/Segment/Tags/TagsSection.cs: -------------------------------------------------------------------------------- 1 | using BXmlLib; 2 | using BXmlLib.DocTypes.Matroska; 3 | 4 | namespace AVDump3Lib.Processing.BlockConsumers.Matroska.Segment.Tags; 5 | 6 | public class TagsSection : Section { 7 | public EbmlList Items { get; private set; } 8 | 9 | public TagsSection() { Items = new EbmlList(); } 10 | 11 | protected override bool ProcessElement(IBXmlReader reader) { 12 | if(reader.DocElement == MatroskaDocType.Tag) { 13 | Section.CreateReadAdd(new TagSection(), reader, Items); 14 | } else return false; 15 | 16 | return true; 17 | } 18 | protected override void Validate() { } 19 | 20 | public override IEnumerator> GetEnumerator() { 21 | foreach(var tag in Items) yield return CreatePair("Tag", tag); 22 | } 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /AVDump3NativeLib/Makefile: -------------------------------------------------------------------------------- 1 | ARCH ?= $(shell uname -m) 2 | SYS ?= $(shell uname -s) 3 | 4 | SOEXT = .so 5 | 6 | ifeq ($(SYS),Linux) 7 | CC = $(ARCH)-linux-gnu-gcc 8 | else ifeq ($(SYS),Darwin) 9 | CC = cc -arch $(ARCH) 10 | SOEXT = .dylib 11 | else 12 | CC = cc 13 | endif 14 | 15 | CFLAGS=-I. -Wall -Werror -fpic -O3 16 | OBJ = AVD3MirrorBuffer.o AVD3NativeLibApi.o InstructionCheck.o CRC32.o MD4.o SHA3.o Tiger.o 17 | 18 | SSE4_FLAGS := 19 | SHA_FLAGS := 20 | 21 | ifeq ($(ARCH),x86_64) 22 | OBJ += SHA1.o SHA256.o CRC32C.o 23 | OBJ_SSE4 = CRC32C.o SHA1.o SHA256.o 24 | OBJ_SHA = SHA1.o SHA256.o 25 | 26 | $(OBJ_SSE4): SSE4_FLAGS := -msse4 27 | $(OBJ_SHA): SHA_FLAGS := -msha 28 | endif 29 | 30 | AVDump3NativeLib$(SOEXT): $(OBJ) 31 | $(CC) -shared -o $@ $^ $(CFLAGS) 32 | 33 | %.o: src/%.c 34 | $(CC) -c -o $@ $< $(CFLAGS) $(SSE4_FLAGS) $(SHA_FLAGS) 35 | 36 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/Ogg/OggParser.cs: -------------------------------------------------------------------------------- 1 | using AVDump3Lib.Processing.BlockBuffers; 2 | 3 | namespace AVDump3Lib.Processing.BlockConsumers.Ogg; 4 | 5 | public class OggParser : BlockConsumer { 6 | 7 | public OggFile Info { get; private set; } 8 | 9 | public OggParser(string name, IBlockStreamReader reader) : base(name, reader) { } 10 | 11 | private bool isValidFile; 12 | public override bool IsConsuming => base.IsConsuming && isValidFile; 13 | 14 | protected override void DoWork(CancellationToken ct) { 15 | var info = new OggFile(); 16 | 17 | var page = new OggPage(); 18 | var stream = new OggBlockDataSource(Reader); 19 | 20 | if(!stream.SeekPastSyncBytes(false, 0)) return; 21 | isValidFile = true; 22 | 23 | while(stream.ReadOggPage(ref page)) { 24 | info.ProcessOggPage(ref page); 25 | } 26 | 27 | Info = info; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/Matroska/Segment/SeekHead/SeekHeadSection.cs: -------------------------------------------------------------------------------- 1 | using BXmlLib; 2 | using BXmlLib.DocTypes.Matroska; 3 | 4 | namespace AVDump3Lib.Processing.BlockConsumers.Matroska.Segment.SeekHead; 5 | 6 | public class SeekHeadSection : Section { 7 | public EbmlList Seeks { get; private set; } 8 | 9 | 10 | public SeekHeadSection() { Seeks = new EbmlList(); } 11 | 12 | protected override bool ProcessElement(IBXmlReader reader) { 13 | if(reader.DocElement == MatroskaDocType.Seek) { 14 | Section.CreateReadAdd(new SeekSection(), reader, Seeks); 15 | return true; 16 | } 17 | return false; 18 | } 19 | protected override void Validate() { } 20 | 21 | public override IEnumerator> GetEnumerator() { 22 | foreach(var seek in Seeks) yield return CreatePair("Seek", seek); 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/Matroska/Segment/Chapters/ChaptersSection.cs: -------------------------------------------------------------------------------- 1 | using BXmlLib; 2 | using BXmlLib.DocTypes.Matroska; 3 | 4 | namespace AVDump3Lib.Processing.BlockConsumers.Matroska.Segment.Chapters; 5 | 6 | public class ChaptersSection : Section { 7 | public EbmlList Items { get; private set; } 8 | 9 | public ChaptersSection() { Items = new EbmlList(); } 10 | 11 | protected override bool ProcessElement(IBXmlReader reader) { 12 | if(reader.DocElement == MatroskaDocType.EditionEntry) { 13 | Section.CreateReadAdd(new EditionEntrySection(), reader, Items); 14 | return true; 15 | } 16 | return false; 17 | } 18 | protected override void Validate() { } 19 | 20 | public override IEnumerator> GetEnumerator() { foreach(var item in Items) yield return CreatePair("EditionEntry", item); } 21 | } 22 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/Matroska/Segment/Cues/CuesSection.cs: -------------------------------------------------------------------------------- 1 | using BXmlLib; 2 | using BXmlLib.DocTypes.Matroska; 3 | 4 | namespace AVDump3Lib.Processing.BlockConsumers.Matroska.Segment.Cues; 5 | 6 | public class CuesSection : Section { 7 | public EbmlList CuePoints { get; private set; } 8 | 9 | 10 | public CuesSection() { CuePoints = new EbmlList(); } 11 | 12 | protected override bool ProcessElement(IBXmlReader reader) { 13 | if(reader.DocElement == MatroskaDocType.CuePoint) { 14 | Section.CreateReadAdd(new CuePointSection(), reader, CuePoints); 15 | return true; 16 | } 17 | return false; 18 | } 19 | protected override void Validate() { } 20 | 21 | public override IEnumerator> GetEnumerator() { 22 | foreach(var cuePoint in CuePoints) yield return CreatePair("CuePoint", cuePoint); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /AVDump3GUI/Converters/InverseBooleanConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows.Data; 7 | 8 | namespace AVDump3GUI.Converters; 9 | 10 | [ValueConversion(typeof(bool), typeof(bool))] 11 | public class InverseBooleanConverter : IValueConverter { 12 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { 13 | if(targetType != typeof(bool)) throw new InvalidOperationException("The target must be a boolean"); 14 | return !(bool)value; 15 | } 16 | 17 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { 18 | if(targetType != typeof(bool)) throw new InvalidOperationException("The target must be a boolean"); 19 | return !(bool)value; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/Ogg/OggFile.cs: -------------------------------------------------------------------------------- 1 | using AVDump3Lib.Processing.BlockConsumers.Ogg.BitStreams; 2 | 3 | namespace AVDump3Lib.Processing.BlockConsumers.Ogg; 4 | 5 | public class OggFile { 6 | public long FileSize { get; private set; } 7 | public long Overhead { get; private set; } 8 | public IEnumerable Bitstreams => bitStreams.Values; 9 | 10 | private readonly Dictionary bitStreams = new(); 11 | 12 | public void ProcessOggPage(ref OggPage page) { 13 | Overhead += 27 + page.SegmentCount; 14 | 15 | if(bitStreams.TryGetValue(page.StreamId, out var bitStream)) { 16 | bitStream.ProcessPage(ref page); 17 | 18 | } else if(page.Flags.HasFlag(PageFlags.Header)) { 19 | bitStream = OGGBitStream.ProcessBeginPage(ref page); 20 | bitStreams.Add(bitStream.Id, bitStream); 21 | 22 | } else { 23 | Overhead += page.Data.Length; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/Matroska/Segment/Chapters/ChapterProcessCommandSection.cs: -------------------------------------------------------------------------------- 1 | using BXmlLib; 2 | using BXmlLib.DocTypes.Matroska; 3 | 4 | namespace AVDump3Lib.Processing.BlockConsumers.Matroska.Segment.Chapters; 5 | 6 | public class ChapterProcessCommandSection : Section { 7 | public ProcessTime? ChapterProcessTime { get; private set; } 8 | //ChapProcessData 9 | 10 | protected override bool ProcessElement(IBXmlReader reader) { 11 | if(reader.DocElement == MatroskaDocType.ChapProcessTime) { 12 | ChapterProcessTime = (ProcessTime)reader.RetrieveValue(); 13 | } else return false; 14 | 15 | return true; 16 | } 17 | protected override void Validate() { } 18 | 19 | public override IEnumerator> GetEnumerator() { 20 | yield return CreatePair("ChapterProcessTime", ChapterProcessTime); 21 | } 22 | 23 | public enum ProcessTime { During, Before, After } 24 | } 25 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/Matroska/Segment/Attachments/AttachmentsSection.cs: -------------------------------------------------------------------------------- 1 | using BXmlLib; 2 | using BXmlLib.DocTypes.Matroska; 3 | 4 | namespace AVDump3Lib.Processing.BlockConsumers.Matroska.Segment.Attachments; 5 | 6 | public class AttachmentsSection : Section { 7 | public EbmlList Items { get; private set; } 8 | 9 | public AttachmentsSection() { Items = new EbmlList(); } 10 | 11 | protected override bool ProcessElement(IBXmlReader reader) { 12 | if(reader.DocElement == MatroskaDocType.AttachedFile) { 13 | CreateReadAdd(new AttachedFileSection(), reader, Items); 14 | return true; 15 | } 16 | return false; 17 | } 18 | protected override void Validate() { } 19 | 20 | public override IEnumerator> GetEnumerator() { 21 | foreach(var attachedFile in Items) yield return CreatePair("AttachedFile", attachedFile); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/HashAlgorithms/Md4NativeHashAlgorithm.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace AVDump3Lib.Processing.HashAlgorithms; 4 | 5 | public unsafe class Md4NativeHashAlgorithm : AVDNativeHashAlgorithm { 6 | private static class NativeMethods { 7 | [DllImport("AVDump3NativeLib")] 8 | internal static extern IntPtr MD4Create(ref int hashLength, out int blockSize); 9 | [DllImport("AVDump3NativeLib")] 10 | internal static extern void MD4Init(IntPtr handle); 11 | [DllImport("AVDump3NativeLib")] 12 | internal static extern void MD4Transform(IntPtr handle, byte* b, int length); 13 | [DllImport("AVDump3NativeLib")] 14 | internal static extern void MD4Final(IntPtr handle, byte* b, int length, byte* hash); 15 | } 16 | 17 | 18 | public Md4NativeHashAlgorithm() : base(NativeMethods.MD4Create, NativeMethods.MD4Init, NativeMethods.MD4Transform, NativeMethods.MD4Final, 128) { } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/HashAlgorithms/SHA1NativeHashAlgorithm.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace AVDump3Lib.Processing.HashAlgorithms; 4 | 5 | public unsafe class SHA1NativeHashAlgorithm : AVDNativeHashAlgorithm { 6 | internal static class NativeMethods { 7 | [DllImport("AVDump3NativeLib")] 8 | internal static extern IntPtr SHA1Create(ref int hashLength, out int blockSize); 9 | [DllImport("AVDump3NativeLib")] 10 | internal static extern void SHA1Init(IntPtr handle); 11 | [DllImport("AVDump3NativeLib")] 12 | internal static extern void SHA1Transform(IntPtr handle, byte* b, int length); 13 | [DllImport("AVDump3NativeLib")] 14 | internal static extern void SHA1Final(IntPtr handle, byte* b, int length, byte* hash); 15 | } 16 | 17 | public SHA1NativeHashAlgorithm() : base(NativeMethods.SHA1Create, NativeMethods.SHA1Init, NativeMethods.SHA1Transform, NativeMethods.SHA1Final, 160) { } //TODO 18 | } 19 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/HashAlgorithms/Crc32NativeHashAlgorithm.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace AVDump3Lib.Processing.HashAlgorithms; 4 | 5 | public unsafe class Crc32NativeHashAlgorithm : AVDNativeHashAlgorithm { 6 | internal static class NativeMethods { 7 | [DllImport("AVDump3NativeLib")] 8 | internal static extern IntPtr CRC32Create(ref int hashLength, out int blockSize); 9 | [DllImport("AVDump3NativeLib")] 10 | internal static extern void CRC32Init(IntPtr handle); 11 | [DllImport("AVDump3NativeLib")] 12 | internal static extern void CRC32Transform(IntPtr handle, byte* b, int length); 13 | [DllImport("AVDump3NativeLib")] 14 | internal static extern void CRC32Final(IntPtr handle, byte* b, int length, byte* hash); 15 | } 16 | 17 | public Crc32NativeHashAlgorithm() : base(NativeMethods.CRC32Create, NativeMethods.CRC32Init, NativeMethods.CRC32Transform, NativeMethods.CRC32Final, 32) { } 18 | } 19 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/HashAlgorithms/Crc32CIntelHashAlgorithm.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace AVDump3Lib.Processing.HashAlgorithms; 4 | 5 | public unsafe class Crc32CIntelHashAlgorithm : AVDNativeHashAlgorithm { 6 | private static class NativeMethods { 7 | [DllImport("AVDump3NativeLib")] 8 | internal static extern IntPtr CRC32CCreate(ref int hashLength, out int blockSize); 9 | [DllImport("AVDump3NativeLib")] 10 | internal static extern void CRC32CInit(IntPtr handle); 11 | [DllImport("AVDump3NativeLib")] 12 | internal static extern void CRC32CTransform(IntPtr handle, byte* b, int length); 13 | [DllImport("AVDump3NativeLib")] 14 | internal static extern void CRC32CFinal(IntPtr handle, byte* b, int length, byte* hash); 15 | } 16 | 17 | public Crc32CIntelHashAlgorithm() : base(NativeMethods.CRC32CCreate, NativeMethods.CRC32CInit, NativeMethods.CRC32CTransform, NativeMethods.CRC32CFinal, 32) { } 18 | } 19 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/HashAlgorithms/TigerNativeHashalgorithm.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace AVDump3Lib.Processing.HashAlgorithms; 4 | 5 | public unsafe class TigerNativeHashAlgorithm : AVDNativeHashAlgorithm { 6 | private static class NativeMethods { 7 | [DllImport("AVDump3NativeLib")] 8 | internal static extern IntPtr TigerCreate(ref int hashLength, out int blockSize); 9 | [DllImport("AVDump3NativeLib")] 10 | internal static extern void TigerInit(IntPtr handle); 11 | [DllImport("AVDump3NativeLib")] 12 | internal static extern void TigerTransform(IntPtr handle, byte* b, int length); 13 | [DllImport("AVDump3NativeLib")] 14 | internal static extern void TigerFinal(IntPtr handle, byte* b, int length, byte* hash); 15 | } 16 | 17 | public TigerNativeHashAlgorithm() : base(NativeMethods.TigerCreate, NativeMethods.TigerInit, NativeMethods.TigerTransform, NativeMethods.TigerFinal, 192) { } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/HashAlgorithms/SHA256NativeHashAlgorithm.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace AVDump3Lib.Processing.HashAlgorithms; 4 | 5 | public unsafe class SHA256NativeHashAlgorithm : AVDNativeHashAlgorithm { 6 | internal static class NativeMethods { 7 | [DllImport("AVDump3NativeLib")] 8 | internal static extern IntPtr SHA256Create(ref int hashLength, out int blockSize); 9 | [DllImport("AVDump3NativeLib")] 10 | internal static extern void SHA256Init(IntPtr handle); 11 | [DllImport("AVDump3NativeLib")] 12 | internal static extern void SHA256Transform(IntPtr handle, byte* b, int length); 13 | [DllImport("AVDump3NativeLib")] 14 | internal static extern void SHA256Final(IntPtr handle, byte* b, int length, byte* hash); 15 | } 16 | 17 | public SHA256NativeHashAlgorithm() : base(NativeMethods.SHA256Create, NativeMethods.SHA256Init, NativeMethods.SHA256Transform, NativeMethods.SHA256Final, 256) { } //TODO 18 | } 19 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/HashAlgorithms/SHA3NativeHashAlgorithm.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace AVDump3Lib.Processing.HashAlgorithms; 4 | 5 | public unsafe class SHA3NativeHashAlgorithm : AVDNativeHashAlgorithm { 6 | internal static class NativeMethods { 7 | [DllImport("AVDump3NativeLib")] 8 | internal static extern IntPtr SHA3Create(ref int hashLength, out int blockSize); 9 | [DllImport("AVDump3NativeLib")] 10 | internal static extern void SHA3Init(IntPtr handle); 11 | [DllImport("AVDump3NativeLib")] 12 | internal static extern void SHA3Transform(IntPtr handle, byte* b, int length); 13 | [DllImport("AVDump3NativeLib")] 14 | internal static extern void SHA3Final(IntPtr handle, byte* b, int length, byte* hash); 15 | } 16 | 17 | public SHA3NativeHashAlgorithm(int hashBitCount) : base(NativeMethods.SHA3Create, NativeMethods.SHA3Init, NativeMethods.SHA3Transform, NativeMethods.SHA3Final, hashBitCount) { } //TODO 18 | } 19 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/Matroska/Segment/Chapters/ChapterTrackSection.cs: -------------------------------------------------------------------------------- 1 | using BXmlLib; 2 | using BXmlLib.DocTypes.Matroska; 3 | 4 | namespace AVDump3Lib.Processing.BlockConsumers.Matroska.Segment.Chapters; 5 | 6 | public class ChapterTrackSection : Section { 7 | public EbmlList ChapterTrackNumbers { get; private set; } 8 | 9 | public ChapterTrackSection() { ChapterTrackNumbers = new EbmlList(); } 10 | 11 | protected override bool ProcessElement(IBXmlReader reader) { 12 | if(reader.DocElement == MatroskaDocType.ChapterTrackNumber) { 13 | ChapterTrackNumbers.Add((ulong)reader.RetrieveValue()); 14 | } else return false; 15 | 16 | return true; 17 | } 18 | protected override void Validate() { } 19 | 20 | public override IEnumerator> GetEnumerator() { 21 | foreach(var chapterTrackNumber in ChapterTrackNumbers) yield return new KeyValuePair("ChapterTrackNumber", chapterTrackNumber); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/Matroska/Segment/Tracks/ContentCompressionSection.cs: -------------------------------------------------------------------------------- 1 | using BXmlLib; 2 | using BXmlLib.DocTypes.Matroska; 3 | 4 | namespace AVDump3Lib.Processing.BlockConsumers.Matroska.Segment.Tracks; 5 | 6 | public class ContentCompressionSection : Section { 7 | private CompAlgos? contentCompAlgo; 8 | 9 | public CompAlgos ContentCompAlgo => contentCompAlgo ?? CompAlgos.zlib; 10 | //ContentCompSetting 11 | 12 | protected override bool ProcessElement(IBXmlReader reader) { 13 | if(reader.DocElement == MatroskaDocType.ContentCompAlgo) { 14 | contentCompAlgo = (CompAlgos)reader.RetrieveValue(); 15 | } else return false; 16 | 17 | return true; 18 | } 19 | protected override void Validate() { } 20 | 21 | public override IEnumerator> GetEnumerator() { 22 | yield return CreatePair("ContentCompAlgo", ContentCompAlgo); 23 | } 24 | 25 | public enum CompAlgos { zlib = 0, bzlib = 1, lzo1x = 2, HeaderScripting = 3 } 26 | } 27 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/HashAlgorithms/KeccakNativeHashAlgorithm.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace AVDump3Lib.Processing.HashAlgorithms; 4 | 5 | public unsafe class KeccakNativeHashAlgorithm : AVDNativeHashAlgorithm { 6 | internal static class NativeMethods { 7 | [DllImport("AVDump3NativeLib")] 8 | internal static extern IntPtr KeccakCreate(ref int hashLength, out int blockSize); 9 | [DllImport("AVDump3NativeLib")] 10 | internal static extern void KeccakInit(IntPtr handle); 11 | [DllImport("AVDump3NativeLib")] 12 | internal static extern void KeccakTransform(IntPtr handle, byte* b, int length); 13 | [DllImport("AVDump3NativeLib")] 14 | internal static extern void KeccakFinal(IntPtr handle, byte* b, int length, byte* hash); 15 | } 16 | 17 | public KeccakNativeHashAlgorithm(int hashBitCount) : base(NativeMethods.KeccakCreate, NativeMethods.KeccakInit, NativeMethods.KeccakTransform, NativeMethods.KeccakFinal, hashBitCount) { } //TODO 18 | } 19 | -------------------------------------------------------------------------------- /AVDump3Lib/Settings/Core/SettingGroup.cs: -------------------------------------------------------------------------------- 1 | using System.Resources; 2 | 3 | namespace AVDump3Lib.Settings.Core; 4 | 5 | public class SettingGroup : ISettingGroup { 6 | 7 | public string Name { get; } 8 | public string FullName { get; } 9 | 10 | public ISettingGroup? Parent { get; } 11 | public ResourceManager ResourceManager { get; } 12 | 13 | public SettingGroup(string name, ResourceManager resourceManager) : this(name, null, resourceManager) { 14 | ResourceManager = resourceManager; 15 | } 16 | public SettingGroup(string name, ISettingGroup? parent, ResourceManager resourceManager) { 17 | Name = name ?? throw new ArgumentNullException(nameof(name)); 18 | Parent = parent; 19 | ResourceManager = resourceManager ?? throw new ArgumentNullException(nameof(resourceManager)); 20 | FullName = name; 21 | var curGroup = Parent; 22 | while(curGroup != null) { 23 | FullName = curGroup.Name + '.' + FullName; 24 | curGroup = curGroup.Parent; 25 | } 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/MP4/MP4Parser.cs: -------------------------------------------------------------------------------- 1 | using AVDump3Lib.Processing.BlockBuffers; 2 | using BXmlLib; 3 | using BXmlLib.DataSource; 4 | using BXmlLib.DocTypes.MP4; 5 | 6 | namespace AVDump3Lib.Processing.BlockConsumers.MP4; 7 | 8 | public class MP4Parser : BlockConsumer { 9 | public MP4Node RootBox { get; private set; } 10 | 11 | public MP4Parser(string name, IBlockStreamReader reader) : base(name, reader) { } 12 | 13 | protected override void DoWork(CancellationToken ct) { 14 | IBXmlDataSource dataSrc = new AVDMP4BlockDataSource(Reader); 15 | using(var cts = new CancellationTokenSource()) 16 | using(ct.Register(() => cts.Cancel())) { 17 | var matroskaDocType = new MP4DocType(); //(MatroskaVersion.V3); 18 | var bxmlReader = new BXmlReader(dataSrc, matroskaDocType); 19 | 20 | try { 21 | RootBox = MP4Node.Read(bxmlReader, Reader.Length); 22 | 23 | } catch(Exception ex) { 24 | //TODO: Only ignore excpetion when it is not a matroska file 25 | } 26 | 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /AVDump3NativeLib/src/CRC32C.c: -------------------------------------------------------------------------------- 1 | #include "AVD3NativeLibApi.h" 2 | 3 | void* CRC32CCreate(uint32_t* hashLength, uint32_t* blockSize) { 4 | *blockSize = 8; 5 | *hashLength = 32; 6 | 7 | uint8_t *b = (uint8_t*)malloc(4); 8 | CRC32CInit(b); 9 | return b; 10 | } 11 | 12 | void CRC32CInit(void * handle) { 13 | memset((uint8_t*)handle, 0xFF, 4); 14 | } 15 | 16 | void CRC32CTransform(void* handle, uint8_t *b, int32_t length) { 17 | uint64_t state64 = *(uint32_t*)handle; 18 | 19 | uint64_t* words = (uint64_t*)b; 20 | uint64_t* wordEnd = words + (length >> 3); 21 | while (words != wordEnd) { 22 | state64 = _mm_crc32_u64(state64, *(words++)); 23 | } 24 | } 25 | 26 | void CRC32CFinal(void* handle, uint8_t* b, int32_t length, uint8_t* hash) { 27 | uint32_t state32 = *(uint32_t*)handle; 28 | uint8_t* bEnd = b + (length & 7); 29 | while (b != bEnd) { 30 | state32 = _mm_crc32_u8(state32, *(b++)); 31 | } 32 | *(uint32_t*)handle = state32; 33 | 34 | 35 | *((int32_t*)hash) = *(int32_t*)handle ^ 0xFFFFFFFF; 36 | } 37 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/MP4/AVDMP4BlockDataSource.cs: -------------------------------------------------------------------------------- 1 | using AVDump3Lib.Processing.BlockBuffers; 2 | using BXmlLib.DocTypes.MP4; 3 | 4 | namespace AVDump3Lib.Processing.BlockConsumers.MP4; 5 | 6 | public class AVDMP4BlockDataSource : MP4BlockDataSource { 7 | private readonly IBlockStreamReader reader; 8 | private int offset; 9 | 10 | public AVDMP4BlockDataSource(IBlockStreamReader reader) => this.reader = reader; 11 | 12 | public override long Position { 13 | get => reader.BytesRead + offset; 14 | set => Advance(checked((int)(value - reader.BytesRead))); 15 | } 16 | 17 | public override void CommitPosition() { 18 | reader.Advance(offset); 19 | offset = 0; 20 | } 21 | 22 | protected override void Advance(int length) { 23 | offset += length; 24 | if(offset >= reader.SuggestedReadLength) CommitPosition(); 25 | IsEndOfStream = reader.Length == reader.BytesRead + offset; 26 | } 27 | 28 | protected override ReadOnlySpan GetDataBlock(int minLength) => reader.GetBlock(minLength)[offset..]; 29 | } 30 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/Matroska/Segment/SeekHead/SeekSection.cs: -------------------------------------------------------------------------------- 1 | using BXmlLib; 2 | using BXmlLib.DocTypes.Matroska; 3 | 4 | namespace AVDump3Lib.Processing.BlockConsumers.Matroska.Segment.SeekHead; 5 | 6 | public class SeekSection : Section { 7 | private byte[] seekId; 8 | 9 | public byte[] SeekId => seekId != null ? (byte[])seekId.Clone() : null; 10 | public ulong SeekPosition { get; private set; } 11 | 12 | protected override bool ProcessElement(IBXmlReader reader) { 13 | if(reader.DocElement == MatroskaDocType.SeekID) { 14 | seekId = (byte[])reader.RetrieveValue(); 15 | } else if(reader.DocElement == MatroskaDocType.SeekPosition) { 16 | SeekPosition = (ulong)reader.RetrieveValue(); 17 | } else return false; 18 | 19 | return true; 20 | } 21 | 22 | protected override void Validate() { } 23 | 24 | public override IEnumerator> GetEnumerator() { 25 | yield return CreatePair("SeekId", SeekId); 26 | yield return CreatePair("SeekPosition", SeekPosition); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /AVDump3GUI/Controls/Settings/SettingValueTemplateSelector.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | 6 | namespace AVDump3GUI.Controls.Settings; 7 | 8 | public class SettingValueTemplateSelector : DataTemplateSelector { 9 | public Dictionary Templates { get; } = new Dictionary(); 10 | 11 | public override DataTemplate SelectTemplate(object item, DependencyObject container) { 12 | var settingValueDisplay = item as SettingValueDisplay; 13 | 14 | var key = ((SettingValueDisplay)item).Property.ValueTypeKey; 15 | if( 16 | !Templates.TryGetValue(key, out var dataTemplate) && 17 | !(Templates.TryGetValue("enum", out dataTemplate) && settingValueDisplay.Property.ValueType.IsEnum) && 18 | !Templates.TryGetValue("default", out dataTemplate) 19 | ) { 20 | throw new Exception("DataTemplate for key {} is missing and no default DataTemplate was provided"); 21 | } 22 | 23 | return dataTemplate; 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/Matroska/AVDEbmlBlockDataSource.cs: -------------------------------------------------------------------------------- 1 | using AVDump3Lib.Processing.BlockBuffers; 2 | using BXmlLib.DocTypes.Ebml; 3 | 4 | namespace AVDump3Lib.Processing.BlockConsumers.Matroska; 5 | 6 | public class AVDEbmlBlockDataSource : EbmlBlockDataSource { 7 | private readonly IBlockStreamReader reader; 8 | private int offset; 9 | 10 | public AVDEbmlBlockDataSource(IBlockStreamReader reader) => this.reader = reader; 11 | 12 | public override long Position { 13 | get => reader.BytesRead + offset; 14 | set => Advance(checked((int)(value - reader.BytesRead))); 15 | } 16 | 17 | public override void CommitPosition() { 18 | reader.Advance(offset); 19 | offset = 0; 20 | } 21 | 22 | protected override void Advance(int length) { 23 | offset += length; 24 | if(offset >= reader.SuggestedReadLength) CommitPosition(); 25 | IsEndOfStream = reader.BytesRead + offset >= reader.Length; 26 | } 27 | 28 | protected override ReadOnlySpan GetDataBlock(int minLength) => reader.GetBlock(minLength + offset)[offset..]; 29 | } 30 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/FileMove/FileMoveScriptByAssembly.cs: -------------------------------------------------------------------------------- 1 | namespace AVDump3Lib.Processing.FileMove; 2 | 3 | public interface IMoveScript { 4 | string GetFilePath(FileMoveContext ctx); 5 | } 6 | 7 | public class FileMoveScriptByAssembly : FileMoveScript { 8 | private readonly FileInfo assemblyFileInfo; 9 | 10 | public FileMoveScriptByAssembly(IEnumerable extensions, string filePath) : base(extensions) { 11 | if(string.IsNullOrEmpty(filePath)) throw new ArgumentException("Parameter may not be null or empty", nameof(filePath)); 12 | assemblyFileInfo = new FileInfo(filePath); 13 | } 14 | 15 | public override bool CanReload { get; } = true; 16 | public override Task ExecuteInternalAsync(FileMoveContext ctx) => throw new NotImplementedException(); 17 | public override void Load() => throw new NotImplementedException(); 18 | public override bool SourceChanged() { 19 | var lastWriteTime = assemblyFileInfo.LastWriteTime; 20 | assemblyFileInfo.Refresh(); 21 | return lastWriteTime != assemblyFileInfo.LastWriteTime; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /AVDump3GUI/AVDump3GUI.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinExe 5 | net10.0-windows 6 | enable 7 | true 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | True 22 | True 23 | Lang.resx 24 | 25 | 26 | 27 | 28 | 29 | ResXFileCodeGenerator 30 | Lang.Designer.cs 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /AVDump3Lib/Information/MetaInfo/Core/FileMetaInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.ObjectModel; 2 | 3 | namespace AVDump3Lib.Information.MetaInfo.Core; 4 | 5 | public class FileMetaInfo { 6 | public ReadOnlyCollection Providers { get; private set; } 7 | public ReadOnlyCollection CondensedProviders { get; private set; } 8 | 9 | public FileInfo FileInfo { get; private set; } 10 | public FileInfo ResolvedPathFileInfo { get; private set; } 11 | 12 | public FileMetaInfo(FileInfo fileInfo, IEnumerable items) { 13 | FileInfo = fileInfo; 14 | 15 | var resolvedPathInfo = fileInfo.ResolveLinkTarget(true); 16 | if (resolvedPathInfo != null) { 17 | ResolvedPathFileInfo = (FileInfo)resolvedPathInfo; 18 | } else { 19 | ResolvedPathFileInfo = fileInfo; 20 | } 21 | 22 | Providers = Array.AsReadOnly(items.Where(i => i != null).ToArray()); 23 | 24 | CondensedProviders = Array.AsReadOnly(Providers.GroupBy(x => x.Type).Select(x => x.Count() > 1 ? new CompositeMetaDataProvider(x.Key.Name, x) : x.First()).ToArray()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /AVDump3Lib/Information/FormatHeaders/WaveFormatEx.cs: -------------------------------------------------------------------------------- 1 | namespace AVDump3Lib.Information.FormatHeaders; 2 | 3 | public class WaveFormatEx { 4 | public const int LENGTH = 18; 5 | 6 | public ushort FormatTag { get; private set; } 7 | public ushort Channels { get; private set; } 8 | public uint SamplesPerSecond { get; private set; } 9 | public uint AverageBytesPerSecond { get; private set; } 10 | public ushort BlockAlign { get; private set; } 11 | public ushort BitsPerSample { get; private set; } 12 | public ushort Size { get; private set; } 13 | 14 | public string TwoCC => Convert.ToString(FormatTag, 16); 15 | 16 | public WaveFormatEx(byte[] b) { 17 | var pos = 0; 18 | 19 | FormatTag = BitConverter.ToUInt16(b, pos); pos += 2; 20 | Channels = BitConverter.ToUInt16(b, pos); pos += 2; 21 | SamplesPerSecond = BitConverter.ToUInt32(b, pos); pos += 4; 22 | AverageBytesPerSecond = BitConverter.ToUInt32(b, pos); pos += 4; 23 | BlockAlign = BitConverter.ToUInt16(b, pos); pos += 2; 24 | BitsPerSample = BitConverter.ToUInt16(b, pos); pos += 2; 25 | Size = BitConverter.ToUInt16(b, pos); 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 DvdKhl 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /AVDump3Lib/Information/MetaInfo/Core/CompositeMetaDataProvider.cs: -------------------------------------------------------------------------------- 1 | namespace AVDump3Lib.Information.MetaInfo.Core; 2 | 3 | public class CompositeMetaDataProvider : MetaDataProvider { 4 | public CompositeMetaDataProvider(string name, IEnumerable providers) : base(name, providers.First().Type) { 5 | ChooseFrom(providers, this); 6 | } 7 | 8 | private static void ChooseFrom(IEnumerable sources, MetaInfoContainer dest) { 9 | var type = sources.First().Type; 10 | var id = sources.First().Id; 11 | 12 | if(sources.Any(x => x.Type != type || x.Id != id)) { 13 | throw new InvalidOperationException(); 14 | } 15 | 16 | foreach(var container in sources) { 17 | foreach(var item in container.Items) { 18 | dest.Add(item); 19 | } 20 | } 21 | 22 | foreach(var group in from source in sources 23 | from container in source.Nodes 24 | group container by new { container.Id, container.Type }) { 25 | 26 | var subContainer = new MetaInfoContainer(group.Key.Id, group.Key.Type); 27 | ChooseFrom(group, subContainer); 28 | 29 | dest.AddNode(subContainer); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /AVDump3GUI/Converters/BoolToVisibilityHiddenConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace AVDump3GUI.Converters; 7 | 8 | [ValueConversion(typeof(bool), typeof(Visibility))] 9 | public sealed class BoolToVisibilityHiddenConverter : IValueConverter { 10 | public Visibility TrueValue { get; set; } 11 | public Visibility FalseValue { get; set; } 12 | 13 | public BoolToVisibilityHiddenConverter() { 14 | // set defaults 15 | TrueValue = Visibility.Visible; 16 | FalseValue = Visibility.Hidden; 17 | } 18 | 19 | public object? Convert(object value, Type targetType, 20 | object parameter, CultureInfo culture) { 21 | if(!(value is bool)) 22 | return null; 23 | return (bool)value ? TrueValue : FalseValue; 24 | } 25 | 26 | public object? ConvertBack(object value, Type targetType, 27 | object parameter, CultureInfo culture) { 28 | if(Equals(value, TrueValue)) 29 | return true; 30 | if(Equals(value, FalseValue)) 31 | return false; 32 | return null; 33 | } 34 | } -------------------------------------------------------------------------------- /AVDump3GUI/Views/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using AVDump3GUI.ViewModels; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using System.Windows.Data; 10 | using System.Windows.Documents; 11 | using System.Windows.Input; 12 | using System.Windows.Media; 13 | using System.Windows.Media.Imaging; 14 | using System.Windows.Navigation; 15 | using System.Windows.Shapes; 16 | 17 | namespace AVDump3GUI.Views { 18 | /// 19 | /// Interaction logic for MainWindow.xaml 20 | /// 21 | public partial class MainWindow : Window { 22 | public MainWindow() { 23 | InitializeComponent(); 24 | 25 | var vm = (MainWindowViewModel)DataContext; 26 | vm.ConsoleWrite += Vm_ConsoleWrite; 27 | } 28 | 29 | private void Vm_ConsoleWrite(string obj) { 30 | Dispatcher.Invoke(() => { 31 | ConsoleTextBox.AppendText(obj + "\n"); 32 | }); 33 | } 34 | 35 | private void FilesView_FilesDrop(object sender, string[] e) { 36 | var vm = (MainWindowViewModel)DataContext; 37 | vm.AddPaths(e); 38 | 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /AVDump3Lib/Settings/Core/SettingStore.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Immutable; 2 | 3 | namespace AVDump3Lib.Settings.Core; 4 | 5 | public class SettingStore : ISettingStore { 6 | private readonly Dictionary values = new(); 7 | 8 | public SettingStore(ImmutableArray settingProperties) => SettingProperties = settingProperties; 9 | 10 | public ImmutableArray SettingProperties { get; } 11 | 12 | public object? GetRawPropertyValue(ISettingProperty settingProperty) => values.TryGetValue(settingProperty, out var value) ? value : ISettingStore.Unset; 13 | public object? GetPropertyValue(ISettingProperty settingProperty) => values.TryGetValue(settingProperty, out var value) ? value : (settingProperty ?? throw new ArgumentNullException(nameof(settingProperty))).DefaultValue; 14 | public bool ContainsProperty(ISettingProperty settingProperty) => values.ContainsKey(settingProperty); 15 | public void SetPropertyValue(ISettingProperty settingProperty, object? value) { 16 | if(value == ISettingStore.Unset) { 17 | values.Remove(settingProperty); 18 | } else { 19 | values[settingProperty] = value; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/FileMove/FileMoveScriptByInlineScript.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.CodeAnalysis.CSharp.Scripting; 2 | using Microsoft.CodeAnalysis.Scripting; 3 | 4 | namespace AVDump3Lib.Processing.FileMove; 5 | 6 | public class FileMoveScriptByInlineScript : FileMoveScript { 7 | private readonly string script; 8 | private ScriptRunner? scriptRunner; 9 | 10 | public FileMoveScriptByInlineScript(IEnumerable extensions, string script) : base(extensions) { 11 | if(string.IsNullOrEmpty(script)) throw new ArgumentException("Parameter may not be null or empty", nameof(script)); 12 | this.script = script; 13 | } 14 | 15 | public override bool CanReload { get; } = false; 16 | 17 | public override async Task ExecuteInternalAsync(FileMoveContext ctx) { 18 | if(scriptRunner == null) return null; 19 | 20 | var dstFilePath = await scriptRunner(ctx); 21 | return dstFilePath; 22 | } 23 | 24 | public override void Load() { 25 | var fileMoveScript = CSharpScript.Create(script, ScriptOptions.Default.WithReferences(AppDomain.CurrentDomain.GetAssemblies()), typeof(FileMoveContext)); 26 | scriptRunner = fileMoveScript.CreateDelegate(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/Matroska/Segment/Tags/TagSection.cs: -------------------------------------------------------------------------------- 1 | using BXmlLib; 2 | using BXmlLib.DocTypes.Matroska; 3 | 4 | namespace AVDump3Lib.Processing.BlockConsumers.Matroska.Segment.Tags; 5 | 6 | public class TagSection : Section { 7 | public TargetsSection Targets { get; private set; } 8 | public EbmlList SimpleTags { get; private set; } 9 | 10 | public TagSection() { SimpleTags = new EbmlList(); } 11 | 12 | protected override bool ProcessElement(IBXmlReader reader) { 13 | if(reader.DocElement == MatroskaDocType.Targets) { 14 | Targets = Section.CreateRead(new TargetsSection(), reader); 15 | } else if(reader.DocElement == MatroskaDocType.SimpleTag) { 16 | Section.CreateReadAdd(new SimpleTagSection(), reader, SimpleTags); 17 | } else return false; 18 | 19 | return true; 20 | } 21 | protected override void Validate() { if(Targets == null) Targets = new TargetsSection(); } 22 | public override IEnumerator> GetEnumerator() { 23 | yield return new KeyValuePair("Targets", Targets); 24 | foreach(var simpleTag in SimpleTags) yield return CreatePair("SimpleTag", simpleTag); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/Matroska/Segment/Cues/CuePointSection.cs: -------------------------------------------------------------------------------- 1 | using BXmlLib; 2 | using BXmlLib.DocTypes.Matroska; 3 | 4 | namespace AVDump3Lib.Processing.BlockConsumers.Matroska.Segment.Cues; 5 | 6 | public class CuePointSection : Section { 7 | public EbmlList CueTrackPositions { get; private set; } 8 | public ulong CueTime { get; private set; } 9 | 10 | public CuePointSection() { CueTrackPositions = new EbmlList(); } 11 | 12 | protected override bool ProcessElement(IBXmlReader reader) { 13 | if(reader.DocElement == MatroskaDocType.CueTrackPositions) { 14 | Section.CreateReadAdd(new CueTrackPositionsSection(), reader, CueTrackPositions); 15 | } else if(reader.DocElement == MatroskaDocType.CueTime) { 16 | CueTime = (ulong)reader.RetrieveValue(); 17 | } else return false; 18 | 19 | return true; 20 | } 21 | 22 | protected override void Validate() { } 23 | 24 | public override IEnumerator> GetEnumerator() { 25 | foreach(var cueTrackPosition in CueTrackPositions) yield return CreatePair("CueTrackPositions", cueTrackPosition); 26 | yield return CreatePair("CueTime", CueTime); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /AVDump3GUI/ViewModels/SettingsGroupViewModel.cs: -------------------------------------------------------------------------------- 1 | using AVDump3Lib.Settings.Core; 2 | using AVDump3GUI.Controls.Settings; 3 | using ExtKnot.StringInvariants; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Collections.Immutable; 7 | using System.Linq; 8 | using System.Resources; 9 | 10 | namespace AVDump3GUI.ViewModels; 11 | 12 | public class SettingsGroupViewModel : ISettingGroupItem { 13 | public string Description => ResourceManager.GetInvString($"{Name}.Description"); 14 | 15 | public ResourceManager ResourceManager { get; } 16 | public ISettingGroup Base { get; } 17 | 18 | public string Name => Base.Name; 19 | public ImmutableArray Properties { get; set; } 20 | 21 | public SettingsGroupViewModel(IEnumerable settingPropertyItems, ResourceManager resourceManager) { 22 | if(settingPropertyItems.Any(x => x.Base.Group != settingPropertyItems.First().Base.Group)) throw new Exception(); 23 | 24 | Base = settingPropertyItems.First().Base.Group; 25 | Properties = settingPropertyItems.Cast().ToImmutableArray(); 26 | ResourceManager = resourceManager ?? throw new ArgumentNullException(nameof(resourceManager)); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /.dockerhub/Dockerfile-Entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | doReset=0 4 | useVersion="-1" 5 | 6 | echo "Arguments: $@" 7 | 8 | if [ "$1" == "RESET" ] 9 | then 10 | doReset=1; shift 11 | fi 12 | 13 | if [ ! -f "/AVD3/AVDump3CL.dll" ] 14 | then 15 | doReset=1; 16 | fi 17 | 18 | if [ "$1" == "USEVERSION" ] 19 | then 20 | doReset=1; shift 21 | useVersion=$(echo $1 | sed -n -r 's/.*(B[[:digit:]]+).*/\1/p'); shift 22 | echo "Using Version $useVersion" 23 | fi 24 | 25 | if [ $doReset -eq 1 ] 26 | then 27 | if [ "$useVersion" == "-1" ] 28 | then 29 | echo "Getting Latest Version Info" 30 | useVersion=$(curl -s https://github.com/DvdKhl/AVDump3/releases/latest | sed -n -r 's/^.*DvdKhl\/AVDump3\/releases\/tag\/(B[[:digit:]]+).*$/\1/p') 31 | echo "Latest Version: $useVersion" 32 | fi 33 | rm -rf /AVD3/* 34 | 35 | dlUrl="https://github.com/DvdKhl/AVDump3/releases/download/$useVersion-GitHubRelease/AVDump3CL-$useVersion.zip" 36 | echo "Downloading Version: $useVersion - $dlUrl" 37 | curl -s -L --output /AVD3/AVDump3CL.zip "$dlUrl" 38 | unzip -q /AVD3/AVDump3CL.zip -d /AVD3 39 | ls -lh 40 | fi 41 | 42 | if [ "$1" != "NOOP" ] 43 | then 44 | dotnet /AVD3/AVDump3CL.dll $@ 45 | fi 46 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/BlockConsumer.cs: -------------------------------------------------------------------------------- 1 | using AVDump3Lib.Processing.BlockBuffers; 2 | 3 | namespace AVDump3Lib.Processing.BlockConsumers; 4 | 5 | public interface IBlockConsumer : IDisposable { 6 | string Name { get; } 7 | Exception Exception { get; } 8 | void ProcessBlocks(CancellationToken ct); 9 | bool IsConsuming { get; } 10 | } 11 | 12 | 13 | public abstract class BlockConsumer : IBlockConsumer { 14 | protected IBlockStreamReader Reader { get; } 15 | 16 | public Exception Exception { get; private set; } 17 | 18 | public string Name { get; } //TODO 19 | 20 | public virtual bool IsConsuming => !Reader.Completed; 21 | 22 | public BlockConsumer(string name, IBlockStreamReader reader) { 23 | Name = name; 24 | Reader = reader; 25 | } 26 | 27 | public void ProcessBlocks(CancellationToken ct) { 28 | try { 29 | DoWork(ct); 30 | } catch(Exception ex) { 31 | ex.Data.Add("BlockConsumerName", Name); 32 | ex.Data.Add("BlockConsumerReadBytes", Reader.BytesRead); 33 | Exception = ex; 34 | 35 | } finally { 36 | Reader.Complete(); 37 | } 38 | } 39 | 40 | protected abstract void DoWork(CancellationToken ct); 41 | 42 | public virtual void Dispose() { 43 | GC.SuppressFinalize(this); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 3 5 | 2 6 | 7 | 8665 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 0 17 | 18 | 19 | $([MSBuild]::Add($(GitHeight), $(GitHeightOffset))) 20 | $(VersionMajor).$(VersionMinor).$(ComputedPatch) 21 | $(Version).0 22 | $(Version).0 23 | $(Version) 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /AVDump3Lib/Information/InfoProvider/InfoProviderFactory.cs: -------------------------------------------------------------------------------- 1 | using AVDump3Lib.Information.MetaInfo.Core; 2 | using AVDump3Lib.Processing.BlockConsumers; 3 | 4 | namespace AVDump3Lib.Information.InfoProvider; 5 | 6 | public interface IInfoProviderFactory { 7 | Type ProviderType { get; } 8 | 9 | MetaDataProvider Create(InfoProviderSetup setup); 10 | } 11 | 12 | public class InfoProviderSetup { 13 | public InfoProviderSetup(string filePath, IReadOnlyCollection blockConsumers) { 14 | FilePath = filePath; 15 | BlockConsumers = blockConsumers; 16 | } 17 | 18 | public string FilePath { get; } 19 | public IReadOnlyCollection BlockConsumers { get; } 20 | } 21 | 22 | public delegate MetaDataProvider CreateInfoProvider(InfoProviderSetup reader); 23 | 24 | public class InfoProviderFactory : IInfoProviderFactory { 25 | private readonly CreateInfoProvider createInfoProvider; 26 | 27 | 28 | public InfoProviderFactory(Type providerType, CreateInfoProvider createInfoProvider) { 29 | ProviderType = providerType; 30 | this.createInfoProvider = createInfoProvider; 31 | } 32 | 33 | public Type ProviderType { get; } 34 | public MetaDataProvider Create(InfoProviderSetup setup) { 35 | return createInfoProvider(setup); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/Matroska/Segment/Tracks/TracksSection.cs: -------------------------------------------------------------------------------- 1 | using BXmlLib; 2 | using BXmlLib.DocTypes.Matroska; 3 | 4 | namespace AVDump3Lib.Processing.BlockConsumers.Matroska.Segment.Tracks; 5 | 6 | public class TracksSection : Section { 7 | public EbmlList Items { get; private set; } 8 | 9 | public TrackEntrySection this[TrackEntrySection.Types type, int index] { 10 | get { 11 | for(var i = 0; i < Items.Count; i++) if(Items[i].TrackType == type && index-- == 0) return Items[i]; 12 | throw new Exception("Index out of range"); 13 | } 14 | } 15 | public int Count(TrackEntrySection.Types type) { return Items.Sum(ldItem => ldItem.TrackType == type ? 1 : 0); } 16 | 17 | public TracksSection() { Items = new EbmlList(); } 18 | 19 | protected override bool ProcessElement(IBXmlReader reader) { 20 | if(reader.DocElement == MatroskaDocType.TrackEntry) { 21 | Section.CreateReadAdd(new TrackEntrySection(), reader, Items); 22 | return true; 23 | } 24 | return false; 25 | } 26 | protected override void Validate() { } 27 | 28 | public override IEnumerator> GetEnumerator() { 29 | foreach(var item in Items) yield return CreatePair("Track", item); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /AVDump3Lib/Reporting/Core/ReportFactory.cs: -------------------------------------------------------------------------------- 1 | using AVDump3Lib.Information.MetaInfo.Core; 2 | using ExtKnot.StringInvariants; 3 | 4 | namespace AVDump3Lib.Reporting.Core; 5 | 6 | public interface IReportFactory { 7 | string Name { get; } 8 | string Description { get; } 9 | IReport Create(FileMetaInfo fileMetaInfo); 10 | } 11 | 12 | public delegate IReport CreateReport(FileMetaInfo fileMetaInfo); 13 | public class ReportFactory : IReportFactory { 14 | private readonly CreateReport createReport; 15 | 16 | public string Name { get; } 17 | public string Description { get; } 18 | 19 | internal ReportFactory(string name, CreateReport createReport) : this(name, GetDescription(name), createReport) { } 20 | 21 | public ReportFactory(string name, string description, CreateReport createReport) { 22 | Name = name; 23 | Description = description; 24 | this.createReport = createReport; 25 | } 26 | 27 | 28 | private static string GetDescription(string name) { 29 | var description = Lang.ResourceManager.GetInvString("Report." + name + ".Description"); 30 | return !string.IsNullOrEmpty(description) ? description : ""; 31 | } 32 | 33 | public IReport Create(FileMetaInfo fileMetaInfo) { 34 | return createReport(fileMetaInfo); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/Matroska/Segment/SegmentInfo/ChapterTranslateSection.cs: -------------------------------------------------------------------------------- 1 | using BXmlLib; 2 | using BXmlLib.DocTypes.Matroska; 3 | 4 | namespace AVDump3Lib.Processing.BlockConsumers.Matroska.Segment.SegmentInfo; 5 | 6 | public class ChapterTranslateSection : Section { 7 | private byte[] id; 8 | 9 | public EbmlList EditionUId { get; private set; } 10 | public ulong? Codec { get; private set; } 11 | public byte[] Id => id != null ? (byte[])id.Clone() : null; 12 | 13 | protected override bool ProcessElement(IBXmlReader reader) { 14 | if(reader.DocElement == MatroskaDocType.ChapterTranslateEditionUID) { 15 | EditionUId.Add((ulong)reader.RetrieveValue()); 16 | } else if(reader.DocElement == MatroskaDocType.ChapterTranslateCodec) { 17 | Codec = (ulong)reader.RetrieveValue(); 18 | } else if(reader.DocElement == MatroskaDocType.ChapterTranslateID) { 19 | id = (byte[])reader.RetrieveValue(); 20 | } else return false; 21 | 22 | return true; 23 | } 24 | protected override void Validate() { } 25 | 26 | public override IEnumerator> GetEnumerator() { 27 | yield return CreatePair("EditionUId", EditionUId); 28 | yield return CreatePair("Codec", Codec); 29 | yield return CreatePair("Id", Id); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /AVDump3Lib/Information/MetaInfo/Core/MetaInfoItem.cs: -------------------------------------------------------------------------------- 1 | namespace AVDump3Lib.Information.MetaInfo.Core; 2 | 3 | public class MetaInfoItem : MetaInfoItem { 4 | public new T Value { get; } 5 | public MetaInfoItem(MetaInfoItemType type, T value, MetaDataProvider provider, IReadOnlyDictionary notes) 6 | : base(type, provider, notes) { 7 | Value = value; 8 | } 9 | public override string ToString() { 10 | return string.Format("MetaInfoItem(Key={0}, Value={1}, Provider={2})", Type.Key, Value, Provider); 11 | } 12 | 13 | protected override object GetValue() { return Value; } 14 | } 15 | 16 | public abstract class MetaInfoItem { 17 | public MetaInfoItemType Type { get; private set; } 18 | public object Value => GetValue(); 19 | public IReadOnlyDictionary Notes { get; private set; } 20 | public MetaDataProvider Provider { get; private set; } 21 | 22 | //public T Select() => (T)GetValue(); 23 | 24 | public TValue Select(MetaInfoItemType? type) { return (TValue)Value; } 25 | 26 | 27 | protected abstract object GetValue(); 28 | protected MetaInfoItem(MetaInfoItemType type, MetaDataProvider provider, IReadOnlyDictionary notes) { 29 | Type = type; 30 | Provider = provider; 31 | Notes = notes; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /AVDump3Tests/HashTestVectors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /AVDump3Lib/Reporting/AVD3ReportingModule.cs: -------------------------------------------------------------------------------- 1 | using AVDump3Lib.Modules; 2 | using AVDump3Lib.Reporting.Core; 3 | using AVDump3Lib.Reporting.Reports; 4 | 5 | namespace AVDump3Lib.Reporting; 6 | 7 | public interface IAVD3ReportingModule : IAVD3Module { 8 | IReadOnlyCollection ReportFactories { get; } 9 | void AddReportFactory(ReportFactory reportFactory); 10 | } 11 | public class AVD3ReportingModule : IAVD3ReportingModule { 12 | private readonly List reportFactories; 13 | 14 | public IReadOnlyCollection ReportFactories { get; } 15 | 16 | 17 | public AVD3ReportingModule() { 18 | reportFactories = new List { 19 | new ReportFactory("AVD3", fileMetaInfo => new AVD3Report(fileMetaInfo)), 20 | new ReportFactory("MediaInfoXml", fileMetaInfo => new MediaInfoLibXmlReport(fileMetaInfo.FileInfo.FullName)), 21 | new ReportFactory("Matroska", fileMetaInfo => new MatroskaReport(fileMetaInfo)) 22 | }; 23 | 24 | ReportFactories = reportFactories.AsReadOnly(); 25 | } 26 | 27 | public void AddReportFactory(ReportFactory reportFactory) { reportFactories.Add(reportFactory); } 28 | 29 | public void Initialize(IReadOnlyCollection modules) { } 30 | public ModuleInitResult Initialized() => new(false); 31 | public void Shutdown() { } 32 | } 33 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/IAVD3ProcessingModule.cs: -------------------------------------------------------------------------------- 1 | using AVDump3Lib.Modules; 2 | using AVDump3Lib.Processing.BlockConsumers; 3 | using AVDump3Lib.Processing.StreamConsumer; 4 | using AVDump3Lib.Processing.StreamProvider; 5 | using Microsoft.Extensions.DependencyInjection; 6 | using System.Collections.Immutable; 7 | 8 | namespace AVDump3Lib.Processing; 9 | 10 | public interface IAVD3ProcessingModule : IAVD3Module { 11 | CPUInstructions? GetAvailableSIMD(); 12 | 13 | ImmutableArray BlockConsumerFactories { get; } 14 | 15 | event EventHandler BlockConsumerFilter; 16 | event EventHandler FilePathFilter; 17 | 18 | IStreamProvider CreateFileStreamProvider(string[] paths, bool recursive, PathPartitions pathPartitions, Action onPathAccepted, Action onError); 19 | IStreamConsumerCollection CreateStreamConsumerCollection(IStreamProvider streamProvider, int bufferLength, int minProducerReadLength, int maxProducerReadLength); 20 | void RegisterDefaultBlockConsumers(IDictionary> arguments); 21 | } 22 | 23 | public static class AVD3ProcessingModuleService { 24 | public static IServiceCollection AddAVD3ProcessingModule(this IServiceCollection services) { 25 | 26 | 27 | 28 | 29 | return services; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /AVDump3Lib/Misc/FileTraversal.cs: -------------------------------------------------------------------------------- 1 | namespace AVDump3Lib.Misc; 2 | 3 | public static class FileTraversal { 4 | public static void Traverse(IEnumerable fileSystemEntries, bool includeSubFolders, Action onFile, Action onError) { 5 | foreach(var path in fileSystemEntries.Where(path => !Directory.Exists(path) && !File.Exists(path))) { 6 | onError?.Invoke(new Exception("Path not found: " + path)); 7 | } 8 | 9 | foreach(var filePath in fileSystemEntries.Where(path => File.Exists(path))) { 10 | try { onFile(filePath); } catch(Exception ex) { onError?.Invoke(ex); } 11 | } 12 | 13 | TraverseDirectories(fileSystemEntries.Where(path => Directory.Exists(path)), includeSubFolders, onFile, onError); 14 | } 15 | 16 | public static void TraverseDirectories(IEnumerable directoryPaths, bool includeSubFolders, Action onFile, Action onError) { 17 | foreach(var directoryPath in directoryPaths) { 18 | try { 19 | foreach(var filePath in Directory.EnumerateFiles(directoryPath).OrderBy(x => x)) { 20 | try { 21 | onFile(filePath); 22 | } catch(Exception ex) { onError?.Invoke(ex); } 23 | } 24 | 25 | if(includeSubFolders) TraverseDirectories(Directory.EnumerateDirectories(directoryPath).OrderBy(x => x), includeSubFolders, onFile, onError); 26 | 27 | } catch(Exception ex) { 28 | onError?.Invoke(ex); 29 | } 30 | } 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /AVDump3Lib/Processing/BlockConsumers/Matroska/Segment/Chapters/ChapterProcessSection.cs: -------------------------------------------------------------------------------- 1 | using BXmlLib; 2 | using BXmlLib.DocTypes.Matroska; 3 | 4 | namespace AVDump3Lib.Processing.BlockConsumers.Matroska.Segment.Chapters; 5 | 6 | public class ChapterProcessSection : Section { 7 | private ulong? chapterProcessCodecId; 8 | 9 | public ulong ChapterProcessCodecId => chapterProcessCodecId ?? 0; 10 | public EbmlList ChapterProcessCommands { get; private set; } 11 | //ChapProcessPrivate 12 | 13 | public ChapterProcessSection() { ChapterProcessCommands = new EbmlList(); } 14 | 15 | protected override bool ProcessElement(IBXmlReader reader) { 16 | if(reader.DocElement == MatroskaDocType.ChapProcessCommand) { 17 | Section.CreateReadAdd(new ChapterProcessCommandSection(), reader, ChapterProcessCommands); 18 | } else if(reader.DocElement == MatroskaDocType.ChapProcessCodecID) { 19 | chapterProcessCodecId = (ulong)reader.RetrieveValue(); 20 | } else return false; 21 | 22 | return true; 23 | } 24 | protected override void Validate() { } 25 | 26 | public override IEnumerator> GetEnumerator() { 27 | yield return CreatePair("ChapterProcessCodecId", ChapterProcessCodecId); 28 | foreach(var chapterProcessCommand in ChapterProcessCommands) yield return CreatePair("ChapterProcessCommand", chapterProcessCommand); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /AVDump3Lib/Reporting/Core/XmlReport.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using System.Xml; 3 | using System.Xml.Linq; 4 | 5 | namespace AVDump3Lib.Reporting.Core; 6 | 7 | public abstract class XmlReport : IReport { 8 | protected abstract XDocument Report { get; } 9 | public string FileExtension { get; } = "xml"; 10 | 11 | public string ReportToString(Encoding encoding) { 12 | var settings = new XmlWriterSettings { 13 | Indent = true, 14 | NewLineChars = "\n", 15 | CheckCharacters = false, 16 | Encoding = Encoding.UTF8, 17 | OmitXmlDeclaration = true, 18 | ConformanceLevel = ConformanceLevel.Fragment 19 | }; 20 | 21 | return ReportToString(settings); 22 | } 23 | public string ReportToString(XmlWriterSettings settings) { 24 | using var memStream = new MemoryStream(); 25 | using(var xmlWriter = XmlWriter.Create(memStream, settings)) { 26 | Report.Root.WriteTo(xmlWriter); 27 | } 28 | memStream.Position = 0; 29 | 30 | using var strReader = new StreamReader(memStream); 31 | 32 | return strReader.ReadToEnd(); 33 | } 34 | 35 | public XDocument ReportToXml() { return new XDocument(Report); } 36 | 37 | public void SaveToFile(string filePath, string reportContentPrefix, Encoding encoding) { 38 | Directory.CreateDirectory(Path.GetDirectoryName(filePath)); 39 | File.AppendAllText(filePath, (!string.IsNullOrEmpty(reportContentPrefix) ? reportContentPrefix + "\n" : "") + ReportToString(encoding) + "\n\n", encoding); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /AVDump3GUI/Controls/Files/FilesView.xaml: -------------------------------------------------------------------------------- 1 | 10 | 11 |