Skip to content
This repository has been archived by the owner on Apr 13, 2022. It is now read-only.

Commit

Permalink
Added support for x264vfw
Browse files Browse the repository at this point in the history
  • Loading branch information
AronParker committed Feb 21, 2018
1 parent 6f08e19 commit b7d58ef
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
1 change: 1 addition & 0 deletions AviRecorder/Video/Avi/FourCC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public static class FourCC
#if COMPATIBILITY
public const uint i420 = 'i' << 0 | '4' << 8 | '2' << 16 | '0' << 24;
public const uint LAGS = 'L' << 0 | 'A' << 8 | 'G' << 16 | 'S' << 24;
public const uint x264 = 'X' << 0 | '2' << 8 | '6' << 16 | '4' << 24;
#endif

public static uint Make(string fcc)
Expand Down
32 changes: 26 additions & 6 deletions AviRecorder/Video/Compression/VideoCompressorInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,41 @@ public static VideoCompressorInfo[] GetCompressorInfos()
#endif

using (var hic = ICOpen(FourCC.VIDC, icInfo.fccHandler, IcMode.Compress))
if (!hic.IsInvalid && ICGetInfo(hic, ref icInfo, (uint)Marshal.SizeOf<ICINFO>()) != IntPtr.Zero && SupportsFlags(icInfo.dwFlags))
results.Add(new VideoCompressorInfo(ref icInfo));
{
if (hic.IsInvalid)
continue;

if (ICGetInfo(hic, ref icInfo, (uint)Marshal.SizeOf<ICINFO>()) == IntPtr.Zero)
continue;

if (!SupportsVideoCompressor(ref icInfo))
continue;

results.Add(new VideoCompressorInfo(ref icInfo));
}
}

return results.ToArray();
}

private static bool SupportsFlags(VideoCompressorFlags dwFlags)
private static bool SupportsVideoCompressor(ref ICINFO icInfo)
{
const VideoCompressorFlags unsupportedFlags = VideoCompressorFlags.Quality | VideoCompressorFlags.Crunch | VideoCompressorFlags.CompressFrames;
#if COMPATIBILITY
if (icInfo.fccHandler == FourCC.x264)
return true;
#endif

if ((dwFlags & unsupportedFlags) != 0)
const VideoCompressorFlags unsupportedFlags = VideoCompressorFlags.Quality |
VideoCompressorFlags.Crunch |
VideoCompressorFlags.CompressFrames;

if ((icInfo.dwFlags & unsupportedFlags) != 0)
return false;

return (dwFlags & VideoCompressorFlags.Temporal) == 0 || (dwFlags & VideoCompressorFlags.FastTemporalC) != 0;
bool requiresPreviousFrame = (icInfo.dwFlags & VideoCompressorFlags.Temporal) != 0 &&
(icInfo.dwFlags & VideoCompressorFlags.FastTemporalC) == 0;

return !requiresPreviousFrame;
}
}
}

0 comments on commit b7d58ef

Please sign in to comment.